All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vincent Siles <vincent.siles@provenrun.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] arm: Fix SCFG ICID reg addresses
Date: Thu, 21 Apr 2016 09:53:23 +0200	[thread overview]
Message-ID: <20160421075323.GA15701@vsiles-Desktop> (raw)
In-Reply-To: <5717B40C.2040804@nxp.com>

Hi !

On 20-04-16 09:53:32, York Sun wrote:
> On 04/12/2016 05:28 AM, Vincent Siles wrote:
> > On the LS102x boards, in order to initialize the ICID values of masters,
> > the dev_stream_id array holds absolute offsets from the base of SCFG.
> > 
> > In ls102xa_config_ssmu_stream_id, the base pointer is cast to uint32_t *
> > before adding the offset, leading to an invalid address. Casting it to
> > unsigned char * solves the issue.
> > 
> > Also minor cosmetic renaming of uint32_t into u32 to be consistent in
> > the whole file.
> > 
> > Signed-off-by: Vincent Siles <vincent.siles@provenrun.com>
> > ---
> > 
> >  board/freescale/common/ls102xa_stream_id.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/board/freescale/common/ls102xa_stream_id.c b/board/freescale/common/ls102xa_stream_id.c
> > index f434269..2a4ef3e 100644
> > --- a/board/freescale/common/ls102xa_stream_id.c
> > +++ b/board/freescale/common/ls102xa_stream_id.c
> > @@ -10,11 +10,11 @@
> >  
> >  void ls102xa_config_smmu_stream_id(struct smmu_stream_id *id, uint32_t num)
> >  {
> > -	uint32_t *scfg = (uint32_t *)CONFIG_SYS_FSL_SCFG_ADDR;
> > +	unsigned char *scfg = (unsigned char *)CONFIG_SYS_FSL_SCFG_ADDR;
> >  	int i;
> >  
> >  	for (i = 0; i < num; i++)
> > -		out_be32(scfg + id[i].offset, id[i].stream_id);
> > +		out_be32((u32 *)(scfg + id[i].offset), id[i].stream_id);
> >  }
> >  
> >  void ls1021x_config_caam_stream_id(struct liodn_id_table *tbl, int size)
> > @@ -28,6 +28,6 @@ void ls1021x_config_caam_stream_id(struct liodn_id_table *tbl, int size)
> >  		else
> >  			liodn = tbl[i].id[0];
> >  
> > -		out_le32((uint32_t *)(tbl[i].reg_offset), liodn);
> > +		out_le32((u32 *)(tbl[i].reg_offset), liodn);
> >  	}
> >  }
> > 
> 
> If the size of the pointer is an issue, maybe you ca use "void *"? Can you check
> if "struct ccsr_scfg" should/can be used?
> 
> York

By using the 'struct ccsr_scfg' type we won't be able to have the same
kind of loop. Since the code is board dependent, I'm not sure it really
matters.

Here what I would do instead. Tell me which style do you prefer.

Best,
Vincent

---

diff --git a/arch/arm/cpu/armv7/ls102xa/soc.c b/arch/arm/cpu/armv7/ls102xa/soc.c
index b1b0c71..9c78efc 100644
--- a/arch/arm/cpu/armv7/ls102xa/soc.c
+++ b/arch/arm/cpu/armv7/ls102xa/soc.c
@@ -30,21 +30,21 @@ struct liodn_id_table sec_liodn_tbl[] = {
 	SET_SEC_DECO_LIODN_ENTRY(7, 0x10, 0x10),
 };
 
-struct smmu_stream_id dev_stream_id[] = {
-	{ 0x100, 0x01, "ETSEC MAC1" },
-	{ 0x104, 0x02, "ETSEC MAC2" },
-	{ 0x108, 0x03, "ETSEC MAC3" },
-	{ 0x10c, 0x04, "PEX1" },
-	{ 0x110, 0x05, "PEX2" },
-	{ 0x114, 0x06, "qDMA" },
-	{ 0x118, 0x07, "SATA" },
-	{ 0x11c, 0x08, "USB3" },
-	{ 0x120, 0x09, "QE" },
-	{ 0x124, 0x0a, "eSDHC" },
-	{ 0x128, 0x0b, "eMA" },
-	{ 0x14c, 0x0c, "2D-ACE" },
-	{ 0x150, 0x0d, "USB2" },
-	{ 0x18c, 0x0e, "DEBUG" },
+struct smmu_stream_id dev_stream_id = {
+	.mac1 = 0x01,
+	.mac2 = 0x02,
+	.mac3 = 0x03,
+	.pex1 = 0x04,
+	.pex2 = 0x05,
+	.dma = 0x06,
+	.sata = 0x07,
+	.usb3 = 0x08,
+	.qe = 0x09,
+	.sdhc = 0x0a,
+	.adma = 0x0b,
+	.dcu = 0x0c,
+	.usb2 = 0x0d,
+	.debug = 0x0e
 };
 
 unsigned int get_soc_major_rev(void)
@@ -131,8 +131,7 @@ int ls102xa_smmu_stream_id_init(void)
 	ls1021x_config_caam_stream_id(sec_liodn_tbl,
 				      ARRAY_SIZE(sec_liodn_tbl));
 
-	ls102xa_config_smmu_stream_id(dev_stream_id,
-				      ARRAY_SIZE(dev_stream_id));
+	ls102xa_config_smmu_stream_id(&dev_stream_id);
 
 	return 0;
 }
diff --git a/arch/arm/include/asm/arch-ls102xa/ls102xa_stream_id.h b/arch/arm/include/asm/arch-ls102xa/ls102xa_stream_id.h
index fa571b3..3815673 100644
--- a/arch/arm/include/asm/arch-ls102xa/ls102xa_stream_id.h
+++ b/arch/arm/include/asm/arch-ls102xa/ls102xa_stream_id.h
@@ -64,11 +64,22 @@ struct liodn_id_table {
 };
 
 struct smmu_stream_id {
-	uint16_t offset;
-	uint16_t stream_id;
-	char dev_name[32];
+	uint16_t mac1;
+	uint16_t mac2;
+	uint16_t mac3;
+	uint16_t pex1;
+	uint16_t pex2;
+	uint16_t dma;
+	uint16_t sata;
+	uint16_t usb3;
+	uint16_t qe;
+	uint16_t sdhc;
+	uint16_t adma;
+	uint16_t dcu;
+	uint16_t usb2;
+	uint16_t debug;
 };
 
 void ls1021x_config_caam_stream_id(struct liodn_id_table *tbl, int size);
-void ls102xa_config_smmu_stream_id(struct smmu_stream_id *id, uint32_t num);
+void ls102xa_config_smmu_stream_id(struct smmu_stream_id *id);
 #endif
diff --git a/board/freescale/common/ls102xa_stream_id.c b/board/freescale/common/ls102xa_stream_id.c
index f434269..941f22d 100644
--- a/board/freescale/common/ls102xa_stream_id.c
+++ b/board/freescale/common/ls102xa_stream_id.c
@@ -7,14 +7,25 @@
 #include <common.h>
 #include <asm/io.h>
 #include <asm/arch/ls102xa_stream_id.h>
+#include <asm/arch/immap_ls102xa.h>
 
-void ls102xa_config_smmu_stream_id(struct smmu_stream_id *id, uint32_t num)
+void ls102xa_config_smmu_stream_id(struct smmu_stream_id *id)
 {
-	uint32_t *scfg = (uint32_t *)CONFIG_SYS_FSL_SCFG_ADDR;
-	int i;
-
-	for (i = 0; i < num; i++)
-		out_be32(scfg + id[i].offset, id[i].stream_id);
+	struct ccsr_scfg *scfg = (struct ccsr_scfg *)CONFIG_SYS_FSL_SCFG_ADDR;
+	scfg->mac1_streamid	= id->mac1;
+	scfg->mac2_streamid	= id->mac2;
+	scfg->mac3_streamid	= id->mac3;
+	scfg->pex1_streamid	= id->pex1;
+	scfg->pex2_streamid	= id->pex2;
+	scfg->dma_streamid	= id->dma;
+	scfg->sata_streamid	= id->sata;
+	scfg->usb3_streamid	= id->usb3;
+	scfg->qe_streamid	= id->qe;
+	scfg->sdhc_streamid	= id->sdhc;
+	scfg->adma_streamid	= id->adma;
+	scfg->dcu_streamid	= id->dcu;
+	scfg->usb2_streamid	= id->usb2;
+	scfg->debug_streamid	= id->debug;
 }
 
 void ls1021x_config_caam_stream_id(struct liodn_id_table *tbl, int size)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160421/8a9422a8/attachment.sig>

  reply	other threads:[~2016-04-21  7:53 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-12 12:15 [U-Boot] [PATCH 0/1] Vincent Siles
2016-04-12 12:15 ` [U-Boot] [PATCH] arm: Fix SCFG ICID reg addresses Vincent Siles
2016-04-20 16:53   ` York Sun
2016-04-21  7:53     ` Vincent Siles [this message]
2016-04-21 15:45       ` york sun
2016-04-21 15:56         ` Vincent Siles
2016-04-21 16:19           ` York Sun
2016-04-22  7:52             ` [U-Boot] [PATCH v2 1/2] " Vincent Siles
2016-04-22  7:52               ` [U-Boot] [PATCH v2 2/2] arm: uniform usage of u32 in ls102x caam config Vincent Siles
2016-05-24 17:13                 ` York Sun
2016-05-24 17:13               ` [U-Boot] [PATCH v2 1/2] arm: Fix SCFG ICID reg addresses York Sun

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160421075323.GA15701@vsiles-Desktop \
    --to=vincent.siles@provenrun.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.