Skip to contentSkip to conversation

mpc85xx: Add support for the supplement configuration unit register

PATCH New Tang Yuantian 2 participants 3 messages Mar 26, 2014 – Apr 23, 2014 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 mpc85xx: Add support for the supplement configuration unit register

From: Tang Yuantian <[email protected]>

The supplement configuration unit (SCFG) provides chip-specific configuration and status registers for the device. It is the chip defined module for extending the device configuration unit (DCFG) module. It provides a set of CCSR registers in addition to those available in the device configuration unit.
The base address for this unit is 0x0F_C000.

---
v2:
- fix checkpatch warning

 arch/powerpc/include/asm/immap_85xx.h | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
arch/powerpc/include/asm/immap_85xx.h +22 -0
index 4b6f9d0..0f0f3d4 100644
@@ -3151,4 +3151,26 @@ struct dcsr_dcfg_regs {
 #define	DCSR_DCFG_ECC_DISABLE_USB2	0x00004000
 	u8  res_524[0x1000 - 0x524]; /* 0x524 - 0x1000 */
 };
+
+#define CONFIG_SYS_MPC85xx_SCFG \
+	(CONFIG_SYS_IMMR + CONFIG_SYS_MPC85xx_SCFG_OFFSET)
+#define CONFIG_SYS_MPC85xx_SCFG_OFFSET	0xfc000
+/* The supplement configuration unit register */
+struct ccsr_scfg {
+	u32 dpslpcr;	/* 0x000 Deep Sleep Control register */
+	u32 usb1dpslpcsr;/* 0x004 USB1 Deep Sleep Control Status register */
+	u32 usb2dpslpcsr;/* 0x008 USB2 Deep Sleep Control Status register */
+	u32 fmclkdpslpcr;/* 0x00c FM Clock Deep Sleep Control register */
+	u32 res1[4];
+	u32 esgmiiselcr;/* 0x020 Ethernet Switch SGMII Select Control reg */
+	u32 res2;
+	u32 pixclkcr;	/* 0x028 Pixel Clock Control register */
+	u32 res3[245];
+	u32 qeioclkcr;	/* 0x400 QUICC Engine IO Clock Control register */
+	u32 emiiocr;	/* 0x404 EMI MDIO Control Register */
+	u32 sdhciovselcr;/* 0x408 SDHC IO VSEL Control register */
+	u32 qmifrstcr;	/* 0x40c QMAN Interface Reset Control register */
+	u32 res4[60];
+	u32 sparecr[8];	/* 0x500 Spare Control register(0-7) */
+};
 #endif /*__IMMAP_85xx__*/
Signature · 1 line
1.8.5
#1 lore raw

PATCH v3 2/2 mpc85xx/t104x: Add deep sleep framework support

From: Tang Yuantian <[email protected]>

When T104x soc wakes up from deep sleep, control is passed to the primary core that starts executing uboot. After re-initialized some IP blocks, like DDRC, kernel will take responsibility to continue to restore environment it leaves before.

---
v3:
- fix out-of-tree compile warning
v2:
- added explaination for CONFIG_DEEP_SLEEP
- fixed some issues

 README                                 |  4 +++
 arch/powerpc/cpu/mpc85xx/cpu_init.c    |  7 ++++
 arch/powerpc/cpu/mpc85xx/fdt.c         | 22 ++++++++++++
 arch/powerpc/cpu/mpc85xx/liodn.c       | 27 ++++++++++----
 arch/powerpc/cpu/mpc85xx/start.S       |  9 +++++
 arch/powerpc/include/asm/global_data.h |  2 ++
 arch/powerpc/lib/board.c               | 66 +++++++++++++++++++++++++++++++---
 drivers/ddr/fsl/mpc85xx_ddr_gen3.c     | 42 +++++++++++++++++++---
 include/fdt_support.h                  |  4 +++
 include/fsl_ddr_sdram.h                |  4 +++
 10 files changed, 171 insertions(+), 16 deletions(-)
README +4 -0
index 216f0c7..25ffb90 100644
@@ -427,6 +427,10 @@ The following options need to be configured:
 		In this mode, a single differential clock is used to supply
 		clocks to the sysclock, ddrclock and usbclock.
 
+		CONFIG_DEEP_SLEEP
+		Inidcates this SoC supports deep sleep feature. If deep sleep is
+		supported, core will start to execute uboot when wakes up.
+
 - Generic CPU options:
 		CONFIG_SYS_BIG_ENDIAN, CONFIG_SYS_LITTLE_ENDIAN
 
arch/powerpc/cpu/mpc85xx/cpu_init.c +7 -0
index 81aeadd..1be29f8 100644
@@ -279,6 +279,7 @@ void cpu_init_f (void)
 #ifdef CONFIG_MPC8548
 	ccsr_local_ecm_t *ecm = (void *)(CONFIG_SYS_MPC85xx_ECM_ADDR);
 	uint svr = get_svr();
+	gd = (gd_t *)(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET);
 
 	/*
 	 * CPU2 errata workaround: A core hang possible while executing
@@ -330,6 +331,12 @@ void cpu_init_f (void)
 	in_be32(&gur->dcsrcr);
 #endif
 
+#ifdef CONFIG_DEEP_SLEEP
+	/* disable the console if boot from deep sleep */
+	if (in_be32(&gur->scrtsr[0]) & (1 << 3))
+		gd->flags |= GD_FLG_SILENT |
+		    GD_FLG_DEEP_SLEEP | GD_FLG_DISABLE_CONSOLE;
+#endif
 }
 
 /* Implement a dummy function for those platforms w/o SERDES */
arch/powerpc/cpu/mpc85xx/fdt.c +22 -0
index 33bc900..9351f63 100644
@@ -35,6 +35,9 @@ void ft_fixup_cpu(void *blob, u64 memory_limit)
 	u32 bootpg = determine_mp_bootpg(NULL);
 	u32 id = get_my_id();
 	const char *enable_method;
+#ifdef CONFIG_DEEP_SLEEP
+	ulong len;
+#endif
 
 	off = fdt_node_offset_by_prop_value(blob, -1, "device_type", "cpu", 4);
 	while (off != -FDT_ERR_NOTFOUND) {
@@ -108,6 +111,25 @@ void ft_fixup_cpu(void *blob, u64 memory_limit)
 			printf("Failed to reserve memory for spin table: %s\n",
 				fdt_strerror(off));
 	}
+
+#ifdef CONFIG_DEEP_SLEEP
+	/*
+	 * reserve the memory space for deep sleep.
+	 * This space will be re-used next time when boot from deep sleep.
+	 * The space includes bd_t, gd_t, stack and uboot image.
+	 * Reserve 1K for stack.
+	 */
+	len = sizeof(bd_t) + sizeof(gd_t) + (1 << 10);
+	/* round up to 4K */
+	len = (len + (4096 - 1)) & ~(4096 - 1);
+
+	off = fdt_add_mem_rsv(blob, gd->relocaddr - len,
+			len + ((ulong)&__bss_end - gd->relocaddr));
+	if (off < 0)
+		printf("Failed to reserve memory for deep sleep: %s\n",
+		       fdt_strerror(off));
+
+#endif
 }
 #endif
 
arch/powerpc/cpu/mpc85xx/liodn.c +20 -7
index 19e130e..a166765 100644
@@ -14,6 +14,8 @@
 #include <asm/fsl_portals.h>
 #include <asm/fsl_liodn.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 int get_dpaa_liodn(enum fsl_dpaa_dev dpaa_dev, u32 *liodns, int liodn_offset)
 {
 	liodns[0] = liodn_bases[dpaa_dev].id[0] + liodn_offset;
@@ -164,6 +166,8 @@ static void setup_rman_liodn_base(struct liodn_id_table *tbl, int size)
 
 void set_liodns(void)
 {
+	bool is_deepsleep = false;
+
 	/* setup general liodn offsets */
 	set_liodn(liodn_tbl, liodn_tbl_sz);
 
@@ -179,16 +183,25 @@ void set_liodns(void)
 	}
 
 	/* setup FMAN block(s) liodn bases & offsets if we have one */
+#ifdef CONFIG_DEEP_SLEEP
+	if (gd->flags & GD_FLG_DEEP_SLEEP)
+		is_deepsleep = true;
+#endif
+
 #ifdef CONFIG_SYS_DPAA_FMAN
-	set_liodn(fman1_liodn_tbl, fman1_liodn_tbl_sz);
-	setup_fman_liodn_base(FSL_HW_PORTAL_FMAN1, fman1_liodn_tbl,
-				fman1_liodn_tbl_sz);
+	if (!is_deepsleep) {
+		set_liodn(fman1_liodn_tbl, fman1_liodn_tbl_sz);
+		setup_fman_liodn_base(FSL_HW_PORTAL_FMAN1, fman1_liodn_tbl,
+				      fman1_liodn_tbl_sz);
+	}
+#endif
 
 #if (CONFIG_SYS_NUM_FMAN == 2)
-	set_liodn(fman2_liodn_tbl, fman2_liodn_tbl_sz);
-	setup_fman_liodn_base(FSL_HW_PORTAL_FMAN2, fman2_liodn_tbl,
-				fman2_liodn_tbl_sz);
-#endif
+	if (!is_deepsleep) {
+		set_liodn(fman2_liodn_tbl, fman2_liodn_tbl_sz);
+		setup_fman_liodn_base(FSL_HW_PORTAL_FMAN2, fman2_liodn_tbl,
+				      fman2_liodn_tbl_sz);
+	}
 #endif
 	/* setup PME liodn base */
 	setup_pme_liodn_base();
arch/powerpc/cpu/mpc85xx/start.S +9 -0
index dbbd8e5..4af7a80 100644
@@ -1669,6 +1669,15 @@ relocate_code:
 	 * Now relocate code
 	 */
 
+#ifdef CONFIG_DEEP_SLEEP
+	/* don't copy uboot again in warm reset case */
+	mr	r0, r3
+	bl	check_warmboot
+	cmpwi	r3, 0
+	bne	7f
+	mr	r3, r0
+#endif
+
 	cmplw	cr1,r3,r4
 	addi	r0,r5,3
 	srwi.	r0,r0,2
arch/powerpc/include/asm/global_data.h +2 -0
index 8e59e8b..219e112 100644
@@ -117,6 +117,8 @@ struct arch_global_data {
 #include <asm-generic/global_data.h>
 
 #if 1
+/* Indicates the deep sleep case */
+#define GD_FLG_DEEP_SLEEP	0x10000
 #define DECLARE_GLOBAL_DATA_PTR     register volatile gd_t *gd asm ("r2")
 #else /* We could use plain global data, but the resulting code is bigger */
 #define XTRN_DECLARE_GLOBAL_DATA_PTR	extern
arch/powerpc/lib/board.c +61 -5

109 lines not on this page · raw message

drivers/ddr/fsl/mpc85xx_ddr_gen3.c +38 -4

71 lines not on this page · raw message

include/fdt_support.h +4 -0
index 9871e2f..43986dc 100644
@@ -12,6 +12,10 @@
 
 #include <libfdt.h>
 
+#ifdef CONFIG_DEEP_SLEEP
+extern ulong __bss_end;
+#endif
+
 u32 fdt_getprop_u32_default(const void *fdt, const char *path,
 				const char *prop, const u32 dflt);
 int fdt_chosen(void *fdt, int force);
include/fsl_ddr_sdram.h +4 -0
index 2a36431..1629ea9 100644
@@ -357,6 +357,10 @@ static int __board_need_mem_reset(void)
 int board_need_mem_reset(void)
 	__attribute__((weak, alias("__board_need_mem_reset")));
 
+void __weak board_mem_sleep_setup(void)
+{
+}
+
 /*
  * The 85xx boards have a common prototype for fixed_sdram so put the
  * declaration here.
Signature · 1 line
1.8.5
#2 lore raw

PATCH v2 1/2 mpc85xx: Add support for the supplement configuration unit register

In reply to Tang Yuantian
Quoted 9 lines · Tang Yuantian

From: Tang Yuantian <[email protected]>

The supplement configuration unit (SCFG) provides chip-specific configuration and status registers for the device. It is the chip defined module for extending the device configuration unit (DCFG) module. It provides a set of CCSR registers in addition to those available in the device configuration unit.
The base address for this unit is 0x0F_C000.

Quoted 4 lines

---
v2:
- fix checkpatch warning

Applied to u-boot-mpc85xx/master, thanks.

York