diff mbox

[U-Boot,3/5] fsl: csu: add an API to set individual device access permission

Message ID 1467613697-18128-3-git-send-email-Zhiqiang.Hou@nxp.com
State Accepted
Commit c37fdbdbb0dd65cb4aa147c9cf9352901014be3b
Delegated to: York Sun
Headers show

Commit Message

Z.Q. Hou July 4, 2016, 6:28 a.m. UTC
From: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>

Add this API to make the individual device is able to be set to
the specified permission.

Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
---
 board/freescale/common/ns_access.c | 34 ++++++++++++++++++++--------------
 include/fsl_csu.h                  |  1 +
 2 files changed, 21 insertions(+), 14 deletions(-)

Comments

Prabhakar Kushwaha July 21, 2016, 4:38 a.m. UTC | #1
> -----Original Message-----
> From: Zhiqiang Hou [mailto:Zhiqiang.Hou@nxp.com]
> Sent: Monday, July 04, 2016 11:58 AM
> To: u-boot@lists.denx.de; albert.u.boot@aribaud.net; york sun
> <york.sun@nxp.com>; wd@denx.de; Prabhakar Kushwaha
> <prabhakar.kushwaha@nxp.com>; alison.wang@freescale.com;
> Mingkai.Hu@freescale.com
> Cc: yao.yuan@freescale.com; Qianyu.Gong@freescale.com;
> bmeng.cn@gmail.com; Shengzhou Liu <shengzhou.liu@nxp.com>; Zhiqiang Hou
> <zhiqiang.hou@nxp.com>
> Subject: [PATCH 3/5] fsl: csu: add an API to set individual device access
> permission
> 
> From: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
> 
> Add this API to make the individual device is able to be set to
> the specified permission.
> 

I am curious about requirement of devices to configure CSU in their driver. 
Why cannot it be done during early boot sequence as part of normal boot-flow for all devices

--prabhakar
Z.Q. Hou July 21, 2016, 7:55 a.m. UTC | #2
Hi Prabhakar,

Thanks for your comments!

> -----Original Message-----

> From: Prabhakar Kushwaha

> Sent: 2016年7月21日 12:39

> To: Zhiqiang Hou <zhiqiang.hou@nxp.com>; u-boot@lists.denx.de;

> albert.u.boot@aribaud.net; york sun <york.sun@nxp.com>; wd@denx.de;

> alison.wang@freescale.com; Mingkai.Hu@freescale.com

> Cc: yao.yuan@freescale.com; Qianyu.Gong@freescale.com;

> bmeng.cn@gmail.com; Shengzhou Liu <shengzhou.liu@nxp.com>; Zhiqiang Hou

> <zhiqiang.hou@nxp.com>

> Subject: RE: [PATCH 3/5] fsl: csu: add an API to set individual device access

> permission

> 

> 

> > -----Original Message-----

> > From: Zhiqiang Hou [mailto:Zhiqiang.Hou@nxp.com]

> > Sent: Monday, July 04, 2016 11:58 AM

> > To: u-boot@lists.denx.de; albert.u.boot@aribaud.net; york sun

> > <york.sun@nxp.com>; wd@denx.de; Prabhakar Kushwaha

> > <prabhakar.kushwaha@nxp.com>; alison.wang@freescale.com;

> > Mingkai.Hu@freescale.com

> > Cc: yao.yuan@freescale.com; Qianyu.Gong@freescale.com;

> > bmeng.cn@gmail.com; Shengzhou Liu <shengzhou.liu@nxp.com>; Zhiqiang

> > Hou <zhiqiang.hou@nxp.com>

> > Subject: [PATCH 3/5] fsl: csu: add an API to set individual device

> > access permission

> >

> > From: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>

> >

> > Add this API to make the individual device is able to be set to the

> > specified permission.

> >

> 

> I am curious about requirement of devices to configure CSU in their driver.

> Why cannot it be done during early boot sequence as part of normal boot-flow for

> all devices

> 

All devices' access permission is set based on the array ns_dev[] during early boot sequence.
But there is a workaround for PCIE errata need to modify the CSU according to the current
serdes protocol.

Thanks,
Zhiqiang
diff mbox

Patch

diff --git a/board/freescale/common/ns_access.c b/board/freescale/common/ns_access.c
index d8d16c5..c3d7a5e 100644
--- a/board/freescale/common/ns_access.c
+++ b/board/freescale/common/ns_access.c
@@ -9,25 +9,31 @@ 
 #include <fsl_csu.h>
 #include <asm/arch/ns_access.h>
 
-static void enable_devices_ns_access(struct csu_ns_dev *ns_dev, uint32_t num)
+void set_devices_ns_access(struct csu_ns_dev *ns_dev, u16 val)
 {
 	u32 *base = (u32 *)CONFIG_SYS_FSL_CSU_ADDR;
 	u32 *reg;
-	uint32_t val;
-	int i;
+	uint32_t tmp;
 
-	for (i = 0; i < num; i++) {
-		reg = base + ns_dev[i].ind / 2;
-		val = in_be32(reg);
-		if (ns_dev[i].ind % 2 == 0) {
-			val &= 0x0000ffff;
-			val |= ns_dev[i].val << 16;
-		} else {
-			val &= 0xffff0000;
-			val |= ns_dev[i].val;
-		}
-		out_be32(reg, val);
+	reg = base + ns_dev->ind / 2;
+	tmp = in_be32(reg);
+	if (ns_dev->ind % 2 == 0) {
+		tmp &= 0x0000ffff;
+		tmp |= val << 16;
+	} else {
+		tmp &= 0xffff0000;
+		tmp |= val;
 	}
+
+	out_be32(reg, tmp);
+}
+
+static void enable_devices_ns_access(struct csu_ns_dev *ns_dev, uint32_t num)
+{
+	int i;
+
+	for (i = 0; i < num; i++)
+		set_devices_ns_access(ns_dev + i, ns_dev[i].val);
 }
 
 void enable_layerscape_ns_access(void)
diff --git a/include/fsl_csu.h b/include/fsl_csu.h
index f4d97fb..57a9985 100644
--- a/include/fsl_csu.h
+++ b/include/fsl_csu.h
@@ -30,5 +30,6 @@  struct csu_ns_dev {
 };
 
 void enable_layerscape_ns_access(void);
+void set_devices_ns_access(struct csu_ns_dev *ns_dev, u16 val);
 
 #endif