diff mbox

[U-Boot,6/8] powerpc/boot: Slave uploads ucode when boot from SRIO

Message ID 1326195751-20729-6-git-send-email-Gang.Liu@freescale.com
State Changes Requested
Headers show

Commit Message

Liu Gang Jan. 10, 2012, 11:42 a.m. UTC
When boot from SRIO, slave's ucode can be stored in master's memory space,
then slave can fetch the ucode image through SRIO interface.

Master needs to:
	1. Put the slave's ucode image into it's own memory space.
	2. Set an inbound SRIO window covered slave's ucode stored in master's
	   memory space.
Slave needs to:
	1. Set a specific TLB entry in order to fetch ucode from master.
	2. Set a LAW entry with the TargetID SRIO1 or SRIO2 for ucode.

Signed-off-by: Liu Gang <Gang.Liu@freescale.com>
Signed-off-by: Shaohui Xie <Shaohui.Xie@freescale.com>
---
 arch/powerpc/cpu/mpc8xxx/srio.c        |   14 ++++++++++++++
 board/freescale/common/p_corenet/law.c |    4 ++++
 board/freescale/common/p_corenet/tlb.c |   10 ++++++++++
 include/configs/corenet_ds.h           |   17 ++++++++++++++++-
 4 files changed, 44 insertions(+), 1 deletions(-)

Comments

Tabi Timur-B04825 Jan. 10, 2012, 5:02 p.m. UTC | #1
On Tue, Jan 10, 2012 at 5:42 AM, Liu Gang <Gang.Liu@freescale.com> wrote:
> When boot from SRIO, slave's ucode can be stored in master's memory space,
> then slave can fetch the ucode image through SRIO interface.

What kind of ucode is this?  Fman or QE?

> +
> +       /* configure inbound window for slave's ucode */
> +       printf("SRIOBOOT - MASTER: Inbound window for slave's ucode; "
> +                       "Local = 0x%llx, Srio = 0x%llx, Size = 0x%x\n",
> +                       (u64)CONFIG_SRIOBOOT_SLAVE_UCODE_LAW_PHYS,
> +                       (u64)CONFIG_SRIOBOOT_SLAVE_UCODE_SRIO_PHYS,
> +                       CONFIG_SRIOBOOT_SLAVE_UCODE_SIZE);
> +       out_be32((u32)&srio->riwtar3 + CONFIG_SRIOBOOT_MASTER_PORT * 0x200,

These should be "(void *)" instead of "(u32)".
Liu Gang Jan. 11, 2012, 2:13 a.m. UTC | #2
-----Original Message-----
From: Tabi Timur-B04825 
Sent: Wednesday, January 11, 2012 1:03 AM
To: Liu Gang-B34182
Cc: u-boot@lists.denx.de; Alexandre.Bounine@idt.com; Gala Kumar-B11780; Zang Roy-R61911; Xie Shaohui-B21989
Subject: Re: [U-Boot] [PATCH 6/8] powerpc/boot: Slave uploads ucode when boot from SRIO

On Tue, Jan 10, 2012 at 5:42 AM, Liu Gang <Gang.Liu@freescale.com> wrote:
> When boot from SRIO, slave's ucode can be stored in master's memory 
> space, then slave can fetch the ucode image through SRIO interface.

What kind of ucode is this?  Fman or QE?
[Liu Gang-B34182] Right now the ucode is for Fman.

> +
> +       /* configure inbound window for slave's ucode */
> +       printf("SRIOBOOT - MASTER: Inbound window for slave's ucode; "
> +                       "Local = 0x%llx, Srio = 0x%llx, Size = 
> + 0x%x\n",
> +                       (u64)CONFIG_SRIOBOOT_SLAVE_UCODE_LAW_PHYS,
> +                       (u64)CONFIG_SRIOBOOT_SLAVE_UCODE_SRIO_PHYS,
> +                       CONFIG_SRIOBOOT_SLAVE_UCODE_SIZE);
> +       out_be32((u32)&srio->riwtar3 + CONFIG_SRIOBOOT_MASTER_PORT * 
> + 0x200,

These should be "(void *)" instead of "(u32)".
[Liu Gang-B34182] Thanks very much!

--
Timur Tabi
Linux kernel developer at Freescale
Wolfgang Denk Jan. 11, 2012, 7:23 a.m. UTC | #3
Dear Liu Gang,

In message <1326195751-20729-6-git-send-email-Gang.Liu@freescale.com> you wrote:
> When boot from SRIO, slave's ucode can be stored in master's memory space,
> then slave can fetch the ucode image through SRIO interface.
...
> +	/* configure inbound window for slave's ucode */
> +	printf("SRIOBOOT - MASTER: Inbound window for slave's ucode; "
> +			"Local = 0x%llx, Srio = 0x%llx, Size = 0x%x\n",
> +			(u64)CONFIG_SRIOBOOT_SLAVE_UCODE_LAW_PHYS,
> +			(u64)CONFIG_SRIOBOOT_SLAVE_UCODE_SRIO_PHYS,
> +			CONFIG_SRIOBOOT_SLAVE_UCODE_SIZE);

Is this really needed in production code?  Or should this be changed
into a debug() ?

> +	out_be32((u32)&srio->riwtar3 + CONFIG_SRIOBOOT_MASTER_PORT * 0x200,
> +			CONFIG_SRIOBOOT_SLAVE_UCODE_LAW_PHYS >> 12);
> +	out_be32((u32)&srio->riwbar3 + CONFIG_SRIOBOOT_MASTER_PORT * 0x200,
> +			CONFIG_SRIOBOOT_SLAVE_UCODE_SRIO_PHYS >> 12);

NAK.  We don't allow base address + offset notation.  Please use
proper C structs instead.

Please fix globally.

> +	out_be32((u32)&srio->riwar3 + CONFIG_SRIOBOOT_MASTER_PORT * 0x200,
> +			0x80f55000

Please don't hard code magic numbers.

Please fix globally.

> +#ifdef CONFIG_SRIOBOOT_SLAVE
> +	/*
> +	 * *I*G - SRIOBOOT-SLAVE. 1M space from 0xffe00000 for fetching ucode
> +	 * and ENV from master
> +	 */

What is this "*I*G - " doing here?

> +/*
> + *for slave UCODE instored in master memory space,
> + *PHYS must be aligned based on the SIZE
> + */

Please add a space between the '*' anf the text.

Please fix globally.


Best regards,

Wolfgang Denk
Liu Gang Jan. 13, 2012, 7:04 a.m. UTC | #4
Dear Wolfgang,

On Wed, 2012-01-11 at 08:23 +0100, Wolfgang Denk wrote:
> > +#ifdef CONFIG_SRIOBOOT_SLAVE
> > +	/*
> > +	 * *I*G - SRIOBOOT-SLAVE. 1M space from 0xffe00000 for fetching ucode
> > +	 * and ENV from master
> > +	 */
> 
> What is this "*I*G - " doing here?

This means that the TLB entry will be set with attribute "MAS2_I"
and "MAS2_G".

This follows the existing style of the file.

> > +/*
> > + *for slave UCODE instored in master memory space,
> > + *PHYS must be aligned based on the SIZE
> > + */
> 
> Please add a space between the '*' anf the text.
> 
> Please fix globally.

Thanks, will add.

Best Regards,

Liu Gang
diff mbox

Patch

diff --git a/arch/powerpc/cpu/mpc8xxx/srio.c b/arch/powerpc/cpu/mpc8xxx/srio.c
index e8ce3a3..740d28a 100644
--- a/arch/powerpc/cpu/mpc8xxx/srio.c
+++ b/arch/powerpc/cpu/mpc8xxx/srio.c
@@ -124,5 +124,19 @@  void srio_boot_master(void)
 	out_be32((u32)&srio->riwar2 + CONFIG_SRIOBOOT_MASTER_PORT * 0x200,
 			0x80f55000
 			| atmu_size_mask(CONFIG_SRIOBOOT_SLAVE_IMAGE_SIZE));
+
+	/* configure inbound window for slave's ucode */
+	printf("SRIOBOOT - MASTER: Inbound window for slave's ucode; "
+			"Local = 0x%llx, Srio = 0x%llx, Size = 0x%x\n",
+			(u64)CONFIG_SRIOBOOT_SLAVE_UCODE_LAW_PHYS,
+			(u64)CONFIG_SRIOBOOT_SLAVE_UCODE_SRIO_PHYS,
+			CONFIG_SRIOBOOT_SLAVE_UCODE_SIZE);
+	out_be32((u32)&srio->riwtar3 + CONFIG_SRIOBOOT_MASTER_PORT * 0x200,
+			CONFIG_SRIOBOOT_SLAVE_UCODE_LAW_PHYS >> 12);
+	out_be32((u32)&srio->riwbar3 + CONFIG_SRIOBOOT_MASTER_PORT * 0x200,
+			CONFIG_SRIOBOOT_SLAVE_UCODE_SRIO_PHYS >> 12);
+	out_be32((u32)&srio->riwar3 + CONFIG_SRIOBOOT_MASTER_PORT * 0x200,
+			0x80f55000
+			| atmu_size_mask(CONFIG_SRIOBOOT_SLAVE_UCODE_SIZE));
 }
 #endif
diff --git a/board/freescale/common/p_corenet/law.c b/board/freescale/common/p_corenet/law.c
index 1fbab4d..c4566dd 100644
--- a/board/freescale/common/p_corenet/law.c
+++ b/board/freescale/common/p_corenet/law.c
@@ -52,9 +52,13 @@  struct law_entry law_table[] = {
 #if defined(CONFIG_SRIOBOOT_SLAVE_PORT0)
 	SET_LAW(CONFIG_SYS_SRIOBOOT_SLAVE_ADDR_PHYS,
 				LAW_SIZE_1M, LAW_TRGT_IF_RIO_1),
+	SET_LAW(CONFIG_SYS_SRIOBOOT_UCODE_ENV_ADDR_PHYS,
+				LAW_SIZE_1M, LAW_TRGT_IF_RIO_1),
 #elif defined(CONFIG_SRIOBOOT_SLAVE_PORT1)
 	SET_LAW(CONFIG_SYS_SRIOBOOT_SLAVE_ADDR_PHYS,
 				LAW_SIZE_1M, LAW_TRGT_IF_RIO_2),
+	SET_LAW(CONFIG_SYS_SRIOBOOT_UCODE_ENV_ADDR_PHYS,
+				LAW_SIZE_1M, LAW_TRGT_IF_RIO_2),
 #endif
 #endif
 };
diff --git a/board/freescale/common/p_corenet/tlb.c b/board/freescale/common/p_corenet/tlb.c
index cb4339f..70779f1 100644
--- a/board/freescale/common/p_corenet/tlb.c
+++ b/board/freescale/common/p_corenet/tlb.c
@@ -147,6 +147,16 @@  struct fsl_e_tlb_entry tlb_table[] = {
 			MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
 			0, 16, BOOKE_PAGESZ_1M, 1),
 #endif
+#ifdef CONFIG_SRIOBOOT_SLAVE
+	/*
+	 * *I*G - SRIOBOOT-SLAVE. 1M space from 0xffe00000 for fetching ucode
+	 * and ENV from master
+	 */
+	SET_TLB_ENTRY(1, CONFIG_SYS_SRIOBOOT_UCODE_ENV_ADDR,
+		CONFIG_SYS_SRIOBOOT_UCODE_ENV_ADDR_PHYS,
+		MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
+		0, 17, BOOKE_PAGESZ_1M, 1),
+#endif
 };
 
 int num_tlb_entries = ARRAY_SIZE(tlb_table);
diff --git a/include/configs/corenet_ds.h b/include/configs/corenet_ds.h
index e4f562c..3b2ff15 100644
--- a/include/configs/corenet_ds.h
+++ b/include/configs/corenet_ds.h
@@ -398,6 +398,13 @@ 
 #define CONFIG_SRIOBOOT_SLAVE_IMAGE_SIZE 0x80000	/* 512K */
 #define CONFIG_SRIOBOOT_SLAVE_IMAGE_LAW_PHYS2 0xfef080000ull
 #define CONFIG_SRIOBOOT_SLAVE_IMAGE_SRIO_PHYS2 0x3fff80000ull
+/*
+ *for slave UCODE instored in master memory space,
+ *PHYS must be aligned based on the SIZE
+ */
+#define CONFIG_SRIOBOOT_SLAVE_UCODE_LAW_PHYS 0xfef020000ull
+#define CONFIG_SRIOBOOT_SLAVE_UCODE_SRIO_PHYS 0x3ffe00000ull
+#define CONFIG_SRIOBOOT_SLAVE_UCODE_SIZE 0x10000	/* 64K */
 #endif
 
 /*
@@ -407,6 +414,9 @@ 
 /* slave port for srioboot*/
 #define CONFIG_SRIOBOOT_SLAVE_PORT0
 /* #define CONFIG_SRIOBOOT_SLAVE_PORT1 */
+#define CONFIG_SYS_SRIOBOOT_UCODE_ENV_ADDR 0xFFE00000
+#define CONFIG_SYS_SRIOBOOT_UCODE_ENV_ADDR_PHYS \
+		(0x300000000ull | CONFIG_SYS_SRIOBOOT_UCODE_ENV_ADDR)
 #endif
 
 /*
@@ -530,8 +540,13 @@ 
 #define CONFIG_SYS_QE_FMAN_FW_IN_NAND
 #define CONFIG_SYS_QE_FMAN_FW_ADDR	(6 * CONFIG_SYS_NAND_BLOCK_SIZE)
 #elif defined(CONFIG_SRIOBOOT_SLAVE)
+/*
+ * slave's ucode is stored in master's Nor flash, the address 0xFFE00000 can be
+ * mapped from slave TLB->slave LAW->slave SRIO outbound window->master
+ * inbound window->master LAW->the ucode address in master's Nor flash.
+ */
 #define CONFIG_SYS_QE_FMAN_FW_IN_REMOTE
-#define CONFIG_SYS_QE_FMAN_FW_ADDR	0
+#define CONFIG_SYS_QE_FMAN_FW_ADDR	0xFFE00000
 #else
 #define CONFIG_SYS_QE_FMAN_FW_IN_NOR
 #define CONFIG_SYS_QE_FMAN_FW_ADDR		0xEF000000