Skip to contentSkip to conversation

Add TPL and P1021MDS board support

PATCH New Haiying.Wang at freescale.com 2 participants 11 messages Feb 7, 2011 – Feb 10, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/4 Add TPL and P1021MDS board support

From: Haiying Wang <[email protected]>

This patch supports P1021MDS board to boot from NAND flash (No NOR flash on this board). And because P1021 only has 256K L2 SRAM, which can not used for final uboot image, this patch also introduces TPL(Tertiary Program loader) to enable a loader stub that boots out of some type of RAM, after being loaded by an SPL or similar platform-specific mechanism.

This patch enables the TPL BOOT on P1021MDS so that DDR can be initialized in L2 SRAM through SPD code. So there are three stage uboot images:
* nand_spl, pad from 4KB size to 16KB, load tpl_boot from offset 16KB in NAND.
* tpl_boot, 112KB size. The env variables are copied to offset 128KB in L2 SRAM, so that ddr spd code can get the interleaving mode setting in env. It loads final uboot image from offset 128KB in NAND.
* final uboot image, size is variable depends on the functions enabled.

README is updated by this patch to support TPL as well as NAND SPL boot.

---
v2: Move TPL common codes to this patch which calls them, move README to here. make changes to board ddr.c and law.c based on the latest commits in u-boot-85xx git tree, make change to board header file according to Wolfgang's comments.

 MAINTAINERS                                   |    4 +
 Makefile                                      |   15 +-
 README                                        |   27 ++
 arch/powerpc/cpu/mpc85xx/cpu.c                |    7 +
 arch/powerpc/cpu/mpc85xx/cpu_init_nand.c      |   20 +-
 arch/powerpc/cpu/mpc85xx/start.S              |   12 +-
 arch/powerpc/cpu/mpc85xx/u-boot-tpl.lds       |   99 +++++
 board/freescale/p1021mds/Makefile             |   52 +++
 board/freescale/p1021mds/ddr.c                |   81 ++++
 board/freescale/p1021mds/law.c                |   32 ++
 board/freescale/p1021mds/p1021mds.c           |  123 ++++++
 board/freescale/p1021mds/tlb.c                |  102 +++++
 boards.cfg                                    |    1 +
 include/configs/P1021MDS.h                    |  537 +++++++++++++++++++++++++
 nand_spl/board/freescale/p1021mds/Makefile    |  134 ++++++
 nand_spl/board/freescale/p1021mds/nand_boot.c |   69 ++++
 nand_spl/nand_boot_fsl_elbc.c                 |    6 +-
 tpl/board/freescale/p1021mds/Makefile         |  257 ++++++++++++
 tpl/board/freescale/p1021mds/tpl_boot.c       |   76 ++++
 19 files changed, 1644 insertions(+), 10 deletions(-)
 create mode 100644 arch/powerpc/cpu/mpc85xx/u-boot-tpl.lds
 create mode 100644 board/freescale/p1021mds/Makefile
 create mode 100644 board/freescale/p1021mds/ddr.c
 create mode 100644 board/freescale/p1021mds/law.c
 create mode 100644 board/freescale/p1021mds/p1021mds.c
 create mode 100644 board/freescale/p1021mds/tlb.c
 create mode 100644 include/configs/P1021MDS.h
 create mode 100644 nand_spl/board/freescale/p1021mds/Makefile
 create mode 100644 nand_spl/board/freescale/p1021mds/nand_boot.c
 create mode 100644 tpl/board/freescale/p1021mds/Makefile
 create mode 100644 tpl/board/freescale/p1021mds/tpl_boot.c
MAINTAINERS +4 -0
index b37ed0c..d2d467f 100644
@@ -17,6 +17,10 @@
 #	Board		CPU						#
 #########################################################################
 
+Haiying Wang <[email protected]>
+
+	P1021MDS	P1021
+
 Poonam Aggrwal <[email protected]>
 
 	P2020RDB	P2020
Makefile +14 -1
index 63e6e1a..62d51d1 100644
@@ -402,8 +402,19 @@ $(obj)u-boot.lds: $(LDSCRIPT)
 nand_spl:	$(TIMESTAMP_FILE) $(VERSION_FILE) $(obj)include/autoconf.mk
 		$(MAKE) -C nand_spl/board/$(BOARDDIR) all
 
+tpl:		$(TIMESTAMP_FILE) $(VERSION_FILE) depend
+		$(MAKE) -C tpl/board/$(BOARDDIR) all
+
+NAND_SPL_OBJS-y += $(obj)nand_spl/u-boot-spl-16k.bin
+NAND_SPL_OBJS-$(CONFIG_HAS_TPL) += $(obj)tpl/u-boot-tpl.bin
+NAND_SPL_OBJS-y += $(obj)u-boot.bin
+
+ifeq ($(CONFIG_HAS_TPL),y)
+$(obj)u-boot-nand.bin:	nand_spl tpl $(obj)u-boot.bin
+else
 $(obj)u-boot-nand.bin:	nand_spl $(obj)u-boot.bin
-		cat $(obj)nand_spl/u-boot-spl-16k.bin $(obj)u-boot.bin > $(obj)u-boot-nand.bin
+endif
+		cat $(NAND_SPL_OBJS-y) > $(obj)u-boot-nand.bin
 
 onenand_ipl:	$(TIMESTAMP_FILE) $(VERSION_FILE) $(obj)include/autoconf.mk
 		$(MAKE) -C onenand_ipl/board/$(BOARDDIR) all
@@ -1225,6 +1236,7 @@ clean:
 	@rm -f $(obj)lib/asm-offsets.s
 	@rm -f $(obj)nand_spl/{u-boot.lds,u-boot-spl,u-boot-spl.map,System.map}
 	@rm -f $(obj)onenand_ipl/onenand-{ipl,ipl.bin,ipl.map}
+	@rm -f $(obj)tpl/{u-boot-tpl,u-boot-tpl.map}
 	@rm -f $(ONENAND_BIN)
 	@rm -f $(obj)onenand_ipl/u-boot.lds
 	@rm -f $(TIMESTAMP_FILE) $(VERSION_FILE)
@@ -1249,6 +1261,7 @@ clobber:	clean
 	@rm -fr $(obj)include/generated
 	@[ ! -d $(obj)nand_spl ] || find $(obj)nand_spl -name "*" -type l -print | xargs rm -f
 	@[ ! -d $(obj)onenand_ipl ] || find $(obj)onenand_ipl -name "*" -type l -print | xargs rm -f
+	@[ ! -d $(obj)tpl ] || find $(obj)tpl -name "*" -type l -print | xargs rm -f
 
 ifeq ($(OBJTREE),$(SRCTREE))
 mrproper \
README +27 -0
index 755d17c..447fff0 100644
@@ -2124,6 +2124,33 @@ FIT uImage format:
 		Adds the MTD partitioning infrastructure from the Linux
 		kernel. Needed for UBI support.
 
+- NAND Boot Support
+		CONFIG_NAND_U_BOOT
+
+		Builds a U-Boot image that boots from NAND, prefixed by a small
+		loader stub (secondary program loader -- SPL) that loads the
+		rest of U-Boot into RAM.  This symbol will be set in all build
+		phases.
+
+		CONFIG_NAND_SPL
+
+		This is set by the build system when compiling code to go into
+		the SPL.  It is not set when building the code that the SPL
+		loads.
+
+- TPL Boot Support
+		CONFIG_HAS_TPL
+
+		Builds a U-Boot image that contains a loader stub (tertiary
+		program loader -- TPL) that boots out of some type of RAM,
+		after being loaded by an SPL or similar platform-specific
+		mechanism.  This symbol will be set in all build phases.
+
+		CONFIG_IN_TPL
+
+		This is set by the build system when compiling code to go into
+		the TPL.  It is not set when building the code that the TPL
+		loads, or when building the SPL.
 
 Modem Support:
 --------------
arch/powerpc/cpu/mpc85xx/cpu.c +7 -0
index 1aad2ba..e923547 100644
@@ -296,6 +296,12 @@ void mpc85xx_reginfo(void)
 #ifndef CONFIG_FSL_CORENET
 phys_size_t initdram(int board_type)
 {
+#if defined(CONFIG_HAS_TPL) && !defined(CONFIG_IN_TPL)
+	/* ddr has been initialized in tpl boot stage thus we only need
+	 * to get the ddr dram size for the final uboot.
+	 */
+	return fsl_ddr_sdram_size();
+#else
 	phys_size_t dram_size = 0;
 
 #if defined(CONFIG_SYS_FSL_ERRATUM_DDR_MSYNC_IN)
@@ -342,6 +348,7 @@ phys_size_t initdram(int board_type)
 
 	puts("DDR: ");
 	return dram_size;
+#endif /* CONFIG_HAS_TPL */
 }
 #endif
 
arch/powerpc/cpu/mpc85xx/cpu_init_nand.c +18 -2
index 8fb27ab..5e346b2 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright 2009 Freescale Semiconductor, Inc.
+ * Copyright 2009 - 2011 Freescale Semiconductor, Inc.
  *
  * See file CREDITS for list of people who contributed to this
  * project.
@@ -40,7 +40,8 @@ void cpu_init_f(void)
 #error  CONFIG_NAND_BR_PRELIM, CONFIG_NAND_OR_PRELIM must be defined
 #endif
 
-#if defined(CONFIG_SYS_RAMBOOT) && defined(CONFIG_SYS_INIT_L2_ADDR)
+#if defined(CONFIG_SYS_RAMBOOT) && defined(CONFIG_SYS_INIT_L2_ADDR) \
+	&& !defined(CONFIG_IN_TPL)
 	ccsr_l2cache_t *l2cache = (void *)CONFIG_SYS_MPC85xx_L2_ADDR;
 	char *l2srbar;
 	int i;
@@ -60,4 +61,19 @@ void cpu_init_f(void)
 	for (i = 0; i < CONFIG_SYS_L2_SIZE; i++)
 		l2srbar[i] = 0;
 #endif
+#ifdef CONFIG_IN_TPL
+	init_used_tlb_cams();
+#endif
+}
+
+#ifdef CONFIG_IN_TPL
+/*
+ * Because the primary cpu's info is enough for the 2nd stage,  we define the
+ * cpu number to 1 so as to keep code size for 2nd stage binary as small as
+ * possible.
+ */
+int cpu_numcores()
+{
+	return 1;
 }
+#endif /* CONFIG_IN_TPL */
arch/powerpc/cpu/mpc85xx/start.S +6 -6
index fa98af6..5496fc4 100644
@@ -58,12 +58,12 @@
 	GOT_ENTRY(_GOT2_TABLE_)
 	GOT_ENTRY(_FIXUP_TABLE_)
 
-#ifndef CONFIG_NAND_SPL
+#if !defined(CONFIG_NAND_SPL) && !defined(CONFIG_IN_TPL)
 	GOT_ENTRY(_start)
 	GOT_ENTRY(_start_of_vectors)
 	GOT_ENTRY(_end_of_vectors)
 	GOT_ENTRY(transfer_to_handler)
-#endif
+#endif /* !CONFIG_NAND_SPL && !CONFIG_IN_TPL*/
 
 	GOT_ENTRY(__init_end)
 	GOT_ENTRY(_end)
@@ -435,7 +435,7 @@ _start_cont:
 
 	/* NOTREACHED - board_init_f() does not return */
 
-#ifndef CONFIG_NAND_SPL
+#if !defined(CONFIG_NAND_SPL) && !defined(CONFIG_IN_TPL)
 	. = EXC_OFF_SYS_RESET
 	.globl	_start_of_vectors
 _start_of_vectors:
@@ -877,7 +877,7 @@ in32:
 in32r:
 	lwbrx	r3,r0,r3
 	blr
-#endif  /* !CONFIG_NAND_SPL */
+#endif  /* !CONFIG_NAND_SPL && !CONFIG_IN_TPL */
 
 /*------------------------------------------------------------------------------*/
 
@@ -1067,7 +1067,7 @@ clear_bss:
 	mr	r4,r10		/* Destination Address		*/
 	bl	board_init_r
 
-#ifndef CONFIG_NAND_SPL
+#if !defined(CONFIG_NAND_SPL) && !defined(CONFIG_IN_TPL)
 	/*
 	 * Copy exception vector code to low memory
 	 *
@@ -1207,4 +1207,4 @@ setup_ivors:
 
 #include "fixed_ivor.S"
 	blr
-#endif /* !CONFIG_NAND_SPL */
+#endif /* !CONFIG_NAND_SPL && !CONFIG_IN_TPL */
arch/powerpc/cpu/mpc85xx/u-boot-tpl.lds new file +99 -0

99 lines not on this page · raw message

board/freescale/p1021mds/Makefile new file +52 -0

52 lines not on this page · raw message

board/freescale/p1021mds/ddr.c new file +81 -0

81 lines not on this page · raw message

board/freescale/p1021mds/law.c new file +32 -0
new file mode 100644
index 0000000..2f70320
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2010 - 2011 Freescale Semiconductor, Inc.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <asm/fsl_law.h>
+#include <asm/mmu.h>
+
+struct law_entry law_table[] = {
+	SET_LAW(CONFIG_SYS_BCSR_BASE_PHYS, LAW_SIZE_256K, LAW_TRGT_IF_LBC),
+	SET_LAW(CONFIG_SYS_NAND_BASE_PHYS, LAW_SIZE_1M, LAW_TRGT_IF_LBC),
+};
+
+int num_law_entries = ARRAY_SIZE(law_table);
board/freescale/p1021mds/p1021mds.c new file +123 -0

123 lines not on this page · raw message

board/freescale/p1021mds/tlb.c new file +102 -0

102 lines not on this page · raw message

boards.cfg +1 -0
index c3b164e..5feb595 100644
@@ -488,6 +488,7 @@ P1020RDB                     powerpc     mpc85xx     p1_p2_rdb           freesca
 P1020RDB_NAND                powerpc     mpc85xx     p1_p2_rdb           freescale      -           P1_P2_RDB:P1020RDB,NAND
 P1020RDB_SDCARD              powerpc     mpc85xx     p1_p2_rdb           freescale      -           P1_P2_RDB:P1020RDB,SDCARD
 P1020RDB_SPIFLASH            powerpc     mpc85xx     p1_p2_rdb           freescale      -           P1_P2_RDB:P1020,SPIFLASH
+P1021MDS_NAND		     powerpc     mpc85xx     p1021mds            freescale      -           P1021MDS:NAND
 P1022DS                      powerpc     mpc85xx     p1022ds             freescale
 P2010RDB                     powerpc     mpc85xx     p1_p2_rdb           freescale      -           P1_P2_RDB:P2010
 P2010RDB_NAND                powerpc     mpc85xx     p1_p2_rdb           freescale      -           P1_P2_RDB:P2010,NAND
include/configs/P1021MDS.h new file +537 -0

537 lines not on this page · raw message

nand_spl/board/freescale/p1021mds/Makefile new file +134 -0

134 lines not on this page · raw message

nand_spl/board/freescale/p1021mds/nand_boot.c new file +69 -0

69 lines not on this page · raw message

nand_spl/nand_boot_fsl_elbc.c +5 -1
index 9547d44..8b135bc 100644
@@ -4,7 +4,7 @@
  * (C) Copyright 2006-2008
  * Stefan Roese, DENX Software Engineering, sr at denx.de.
  *
- * Copyright (c) 2008 Freescale Semiconductor, Inc.
+ * Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
  * Author: Scott Wood <[email protected]>
  *
  * This program is free software; you can redistribute it and/or
@@ -47,7 +47,11 @@ static void nand_wait(void)
 	}
 }
 
+#ifdef CONFIG_IN_TPL
+void nand_load(unsigned int offs, int uboot_size, uchar *dst)
+#else
 static void nand_load(unsigned int offs, int uboot_size, uchar *dst)
+#endif
 {
 	fsl_lbc_t *regs = LBC_BASE_ADDR;
 	uchar *buf = (uchar *)CONFIG_SYS_NAND_BASE;
tpl/board/freescale/p1021mds/Makefile new file +257 -0

257 lines not on this page · raw message

tpl/board/freescale/p1021mds/tpl_boot.c new file +76 -0

76 lines not on this page · raw message

Signature · 1 line
1.7.3.1.50.g1e633
#1 lore raw

PATCH v2 2/4 powerpc/85xx: Add more P1021 defines

From: Haiying Wang <[email protected]>

---
v2: re-number the res defines in immap_85xx.h, make changes to P1021 specific defines based on the latest commit in u-boot-85xx git tree.

 arch/powerpc/include/asm/config_mpc85xx.h |    4 ++++
 arch/powerpc/include/asm/immap_85xx.h     |   24 +++++++++++++++---------
 2 files changed, 19 insertions(+), 9 deletions(-)
arch/powerpc/include/asm/config_mpc85xx.h +4 -0
index d7d1fb6..b25cd30 100644
@@ -125,6 +125,10 @@
 #define CONFIG_SYS_FSL_NUM_LAWS		12
 #define CONFIG_TSECV2
 #define CONFIG_SYS_FSL_SEC_COMPAT	2
+#define QE_MURAM_SIZE			0x6000UL
+#define MAX_QE_RISC			1
+#define QE_NUM_OF_SNUM			28
+
 
 #elif defined(CONFIG_P1022)
 #define CONFIG_MAX_CPUS			2
arch/powerpc/include/asm/immap_85xx.h +15 -9
index 6bd83ba..99ecb83 100644
@@ -1942,29 +1942,35 @@ typedef struct ccsr_gur {
 	u8	res9[12];
 	u32	pvr;		/* Processor version */
 	u32	svr;		/* System version */
-	u8	res10a[8];
+	u8	res10[8];
 	u32	rstcr;		/* Reset control */
 #if defined(CONFIG_MPC8568)||defined(CONFIG_MPC8569)
-	u8	res10b[76];
+	u8	res11a[76];
 	par_io_t qe_par_io[7];
-	u8	res10c[1600];
+	u8	res11b[1600];
+#elif defined(CONFIG_P1021)
+	u8      res11a[12];
+	u32     iovselsr;
+	u8      res11b[60];
+	par_io_t qe_par_io[3];
+	u8      res11c[1496];
 #else
-	u8	res10b[1868];
+	u8	res11a[1868];
 #endif
 	u32	clkdvdr;	/* Clock Divide register */
-	u8	res10d[1532];
+	u8	res12[1532];
 	u32	clkocr;		/* Clock out select */
-	u8	res11[12];
+	u8	res13[12];
 	u32	ddrdllcr;	/* DDR DLL control */
-	u8	res12[12];
+	u8	res14[12];
 	u32	lbcdllcr;	/* LBC DLL control */
-	u8	res13[248];
+	u8	res15[248];
 	u32	lbiuiplldcr0;	/* LBIU PLL Debug Reg 0 */
 	u32	lbiuiplldcr1;	/* LBIU PLL Debug Reg 1 */
 	u32	ddrioovcr;	/* DDR IO Override Control */
 	u32	tsec12ioovcr;	/* eTSEC 1/2 IO override control */
 	u32	tsec34ioovcr;	/* eTSEC 3/4 IO override control */
-	u8	res15[61648];
+	u8	res16[61648];
 } ccsr_gur_t;
 #endif
 
Signature · 1 line
1.7.3.1.50.g1e633
#2 lore raw

PATCH 3/4 powerpc/85xx: load ucode from nand flash before qe_init

In reply to Haiying.Wang at freescale.com

From: Haiying Wang <[email protected]>

In the case the QE's microcode is stored in nand flash, we need to load it from NAND flash to ddr first then the qe_init can get the ucode correctly.

---
 arch/powerpc/cpu/mpc85xx/cpu_init.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
arch/powerpc/cpu/mpc85xx/cpu_init.c +17 -0
index 215b7b3..5642cd7 100644
@@ -37,6 +37,10 @@
 #include <asm/fsl_law.h>
 #include <asm/fsl_serdes.h>
 #include "mp.h"
+#ifdef CONFIG_SYS_QE_FW_IN_NAND
+#include <nand.h>
+#include <errno.h>
+#endif
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -448,6 +452,19 @@ void cpu_secondary_init_r(void)
 {
 #ifdef CONFIG_QE
 	uint qe_base = CONFIG_SYS_IMMR + 0x00080000; /* QE immr base */
+#ifdef CONFIG_SYS_QE_FW_IN_NAND
+	int ret;
+	size_t fw_length = CONFIG_SYS_QE_FW_LENGTH;
+
+	/* load QE firmware from NAND flash to DDR first */
+	ret = nand_read(&nand_info[0], (loff_t)CONFIG_SYS_QE_FW_IN_NAND,
+			&fw_length, (u_char *)CONFIG_SYS_QE_FW_ADDR);
+
+	if (ret && ret == -EUCLEAN) {
+		printf ("NAND read for QE firmware at offset %x failed %d\n",
+				CONFIG_SYS_QE_FW_IN_NAND, ret);
+	}
+#endif
 	qe_init(qe_base);
 	qe_reset();
 #endif
Signature · 1 line
1.7.3.1.50.g1e633
Applied
#3 lore raw

PATCH 3/4 powerpc/85xx: load ucode from nand flash before qe_init

Quoted 9 lines · On Feb 7, 2011, at 3:14 PM, <[email protected]>…

From: Haiying Wang <[email protected]>

In the case the QE's microcode is stored in nand flash, we need to load it from NAND flash to ddr first then the qe_init can get the ucode correctly.

---
arch/powerpc/cpu/mpc85xx/cpu_init.c | 17 +++++++++++++++++

1 files changed, 17 insertions(+), 0 deletions(-)

applied to 85xx dev

- k

#4 lore raw

PATCH v2 4/4 p1021mds: add QE and UEC support

In reply to Haiying.Wang at freescale.com

From: Haiying Wang <[email protected]>

P1021 has some QE pins which need to be set in pmuxcr register before using QE functions. In this patch, pin QE0 and QE3 are set for UCC1 and UCC5 in Eth mode. QE9 and QE12 are set for MII management. QE12 needs to be released after MII access because QE12 pin is muxed with LBCTL signal.

P1021MDS has to load the microcode from NAND flash, this patchs add support to load ucode from NAND before initializing qe.

---
v2: remove misc_init_r, make changes based on laste commits in u-boot-85xx.git

 arch/powerpc/cpu/mpc85xx/speed.c      |    4 ++
 arch/powerpc/include/asm/immap_85xx.h |   13 ++++++++
 board/freescale/p1021mds/p1021mds.c   |   51 +++++++++++++++++++++++++++++++++
 drivers/qe/uec.c                      |   40 +++++++++++++++++++++++++-
 include/configs/P1021MDS.h            |   44 ++++++++++++++++++++++++++++
 5 files changed, 151 insertions(+), 1 deletions(-)
arch/powerpc/cpu/mpc85xx/speed.c +4 -0
index f2aa8d0..ae94ee8 100644
@@ -165,10 +165,14 @@ void get_sys_info (sys_info_t * sysInfo)
 #endif
 
 #ifdef CONFIG_QE
+#ifdef CONFIG_P1021
+	sysInfo->freqQE =  sysInfo->freqSystemBus;
+#else
 	qe_ratio = ((gur->porpllsr) & MPC85xx_PORPLLSR_QE_RATIO)
 			>> MPC85xx_PORPLLSR_QE_RATIO_SHIFT;
 	sysInfo->freqQE = qe_ratio * CONFIG_SYS_CLK_FREQ;
 #endif
+#endif
 
 #if defined(CONFIG_FSL_LBC)
 #if defined(CONFIG_SYS_LBC_LCRR)
arch/powerpc/include/asm/immap_85xx.h +13 -0
index 99ecb83..d0fa79b 100644
@@ -1909,6 +1909,19 @@ typedef struct ccsr_gur {
 #define MPC85xx_PMUXCR_SD_DATA		0x80000000
 #define MPC85xx_PMUXCR_SDHC_CD		0x40000000
 #define MPC85xx_PMUXCR_SDHC_WP		0x20000000
+#define MPC85xx_PMUXCR_QE0             0x00008000
+#define MPC85xx_PMUXCR_QE1             0x00004000
+#define MPC85xx_PMUXCR_QE2             0x00002000
+#define MPC85xx_PMUXCR_QE3             0x00001000
+#define MPC85xx_PMUXCR_QE4             0x00000800
+#define MPC85xx_PMUXCR_QE5             0x00000400
+#define MPC85xx_PMUXCR_QE6             0x00000200
+#define MPC85xx_PMUXCR_QE7             0x00000100
+#define MPC85xx_PMUXCR_QE8             0x00000080
+#define MPC85xx_PMUXCR_QE9             0x00000040
+#define MPC85xx_PMUXCR_QE10            0x00000020
+#define MPC85xx_PMUXCR_QE11            0x00000010
+#define MPC85xx_PMUXCR_QE12            0x00000008
 	u32	pmuxcr2;	/* Alt. function signal multiplex control 2 */
 	u8	res6[8];
 	u32	devdisr;	/* Device disable control */
board/freescale/p1021mds/p1021mds.c +51 -0

68 lines not on this page · raw message

drivers/qe/uec.c +39 -1
index 282ab23..04d7987 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006-2010 Freescale Semiconductor, Inc.
+ * Copyright (C) 2006-2011 Freescale Semiconductor, Inc.
  *
  * Dave Liu <[email protected]>
  *
@@ -30,6 +30,9 @@
 #include "uec.h"
 #include "uec_phy.h"
 #include "miiphy.h"
+#ifdef CONFIG_P1021
+#define BCSR11_ENET_MICRST	0x20
+#endif
 
 /* Default UTBIPAR SMI address */
 #ifndef CONFIG_UTBIPAR_INIT_TBIPA
@@ -588,9 +591,25 @@ static void phy_change(struct eth_device *dev)
 {
 	uec_private_t	*uec = (uec_private_t *)dev->priv;
 
+#ifdef CONFIG_P1021
+	ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
+
+	/* QE9 and QE12 need to be set for enabling QE MII managment signals */
+	setbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_QE9);
+	setbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_QE12);
+#endif
+
 	/* Update the link, speed, duplex */
 	uec->mii_info->phyinfo->read_status(uec->mii_info);
 
+#ifdef CONFIG_P1021
+	/*
+	 * QE12 is muxed with LBCTL, it needs to be released for enabling
+	 * LBCTL signal for LBC usage.
+	 */
+	clrbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_QE12);
+#endif
+
 	/* Adjust the interface according to speed */
 	adjust_link(dev);
 }
@@ -1198,10 +1217,24 @@ static int uec_init(struct eth_device* dev, bd_t *bd)
 	uec_private_t		*uec;
 	int			err, i;
 	struct phy_info         *curphy;
+#ifdef CONFIG_P1021
+	ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
+#endif
 
 	uec = (uec_private_t *)dev->priv;
 
 	if (uec->the_first_run == 0) {
+#ifdef CONFIG_P1021
+	/* reset micrel phy for each UEC */
+	clrbits_8((u8 *)(CONFIG_SYS_BCSR_BASE + 11), BCSR11_ENET_MICRST);
+	udelay(200);
+	setbits_8((u8 *)(CONFIG_SYS_BCSR_BASE + 11), BCSR11_ENET_MICRST);
+
+	/* QE9 and QE12 need to be set for enabling QE MII managment signals */
+	setbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_QE9);
+	setbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_QE12);
+#endif
+
 		err = init_phy(dev);
 		if (err) {
 			printf("%s: Cannot initialize PHY, aborting.\n",
@@ -1228,6 +1261,11 @@ static int uec_init(struct eth_device* dev, bd_t *bd)
 			udelay(100000);
 		} while (1);
 
+#ifdef CONFIG_P1021
+		/* QE12 needs to be released for enabling LBCTL signal*/
+		clrbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_QE12);
+#endif
+
 		if (err || i <= 0)
 			printf("warning: %s: timeout on PHY link\n", dev->name);
 
include/configs/P1021MDS.h +44 -0

50 lines not on this page · raw message

Signature · 1 line
1.7.3.1.50.g1e633
#5 lore raw

PATCH v2 4/4 p1021mds: add QE and UEC support

Quoted 11 lines · On Feb 7, 2011, at 3:14 PM, <[email protected]>…

From: Haiying Wang <[email protected]>

P1021 has some QE pins which need to be set in pmuxcr register before using QE functions. In this patch, pin QE0 and QE3 are set for UCC1 and UCC5 in Eth mode. QE9 and QE12 are set for MII management. QE12 needs to be released after MII access because QE12 pin is muxed with LBCTL signal.

P1021MDS has to load the microcode from NAND flash, this patchs add support to load ucode from NAND before initializing qe.

Quoted 8 lines

---
v2: remove misc_init_r, make changes based on laste commits in u-boot-85xx.git

arch/powerpc/cpu/mpc85xx/speed.c      |    4 ++
arch/powerpc/include/asm/immap_85xx.h |   13 ++++++++
board/freescale/p1021mds/p1021mds.c   |   51 +++++++++++++++++++++++++++++++++
drivers/qe/uec.c                      |   40 +++++++++++++++++++++++++-
include/configs/P1021MDS.h            |   44 ++++++++++++++++++++++++++++
5 files changed, 151 insertions(+), 1 deletions(-)

Can we split this patch up into the QE parts for P1021 and the board parts for P1021MDS

Quoted 173 lines
arch/powerpc/cpu/mpc85xx/speed.c +4 -0
index f2aa8d0..ae94ee8 100644
@@ -165,10 +165,14 @@ void get_sys_info (sys_info_t * sysInfo)
 #endif
 
 #ifdef CONFIG_QE
+#ifdef CONFIG_P1021
+	sysInfo->freqQE =  sysInfo->freqSystemBus;
+#else
 	qe_ratio = ((gur->porpllsr) & MPC85xx_PORPLLSR_QE_RATIO)
 			>> MPC85xx_PORPLLSR_QE_RATIO_SHIFT;
 	sysInfo->freqQE = qe_ratio * CONFIG_SYS_CLK_FREQ;
 #endif
+#endif
 
 #if defined(CONFIG_FSL_LBC)
 #if defined(CONFIG_SYS_LBC_LCRR)
arch/powerpc/include/asm/immap_85xx.h +13 -0
index 99ecb83..d0fa79b 100644
@@ -1909,6 +1909,19 @@ typedef struct ccsr_gur {
 #define MPC85xx_PMUXCR_SD_DATA		0x80000000
 #define MPC85xx_PMUXCR_SDHC_CD		0x40000000
 #define MPC85xx_PMUXCR_SDHC_WP		0x20000000
+#define MPC85xx_PMUXCR_QE0             0x00008000
+#define MPC85xx_PMUXCR_QE1             0x00004000
+#define MPC85xx_PMUXCR_QE2             0x00002000
+#define MPC85xx_PMUXCR_QE3             0x00001000
+#define MPC85xx_PMUXCR_QE4             0x00000800
+#define MPC85xx_PMUXCR_QE5             0x00000400
+#define MPC85xx_PMUXCR_QE6             0x00000200
+#define MPC85xx_PMUXCR_QE7             0x00000100
+#define MPC85xx_PMUXCR_QE8             0x00000080
+#define MPC85xx_PMUXCR_QE9             0x00000040
+#define MPC85xx_PMUXCR_QE10            0x00000020
+#define MPC85xx_PMUXCR_QE11            0x00000010
+#define MPC85xx_PMUXCR_QE12            0x00000008
 	u32	pmuxcr2;	/* Alt. function signal multiplex control 2 */
 	u8	res6[8];
 	u32	devdisr;	/* Device disable control */
board/freescale/p1021mds/p1021mds.c +51 -0
index 2dfcf13..29972f8 100644
@@ -37,6 +37,45 @@
 #include <tsec.h>
 #include <netdev.h>
 
+#ifdef CONFIG_QE
+const qe_iop_conf_t qe_iop_conf_tab[] = {
+	/* QE_MUX_MDC */
+	{1,  19, 1, 0, 1}, /* QE_MUX_MDC	*/
+	/* QE_MUX_MDIO */
+	{1,  20, 3, 0, 1}, /* QE_MUX_MDIO	*/
+
+	/* UCC_1_MII */
+	{0, 23, 2, 0, 2}, /* CLK12 */
+	{0, 24, 2, 0, 1}, /* CLK9 */
+	{0,  7, 1, 0, 2}, /* ENET1_TXD0_SER1_TXD0      */
+	{0,  9, 1, 0, 2}, /* ENET1_TXD1_SER1_TXD1      */
+	{0, 11, 1, 0, 2}, /* ENET1_TXD2_SER1_TXD2      */
+	{0, 12, 1, 0, 2}, /* ENET1_TXD3_SER1_TXD3      */
+	{0,  6, 2, 0, 2}, /* ENET1_RXD0_SER1_RXD0      */
+	{0, 10, 2, 0, 2}, /* ENET1_RXD1_SER1_RXD1      */
+	{0, 14, 2, 0, 2}, /* ENET1_RXD2_SER1_RXD2      */
+	{0, 15, 2, 0, 2}, /* ENET1_RXD3_SER1_RXD3      */
+	{0,  5, 1, 0, 2}, /* ENET1_TX_EN_SER1_RTS_B    */
+	{0, 13, 1, 0, 2}, /* ENET1_TX_ER               */
+	{0,  4, 2, 0, 2}, /* ENET1_RX_DV_SER1_CTS_B    */
+	{0,  8, 2, 0, 2}, /* ENET1_RX_ER_SER1_CD_B    */
+	{0, 17, 2, 0, 2}, /* ENET1_CRS    */
+	{0, 16, 2, 0, 2}, /* ENET1_COL    */
+
+	/* UCC_5_RMII */
+	{1, 11, 2, 0, 1}, /* CLK13 */
+	{1, 7,  1, 0, 2}, /* ENET5_TXD0_SER5_TXD0      */
+	{1, 10, 1, 0, 2}, /* ENET5_TXD1_SER5_TXD1      */
+	{1, 6, 2, 0, 2}, /* ENET5_RXD0_SER5_RXD0      */
+	{1, 9, 2, 0, 2}, /* ENET5_RXD1_SER5_RXD1      */
+	{1, 5, 1, 0, 2}, /* ENET5_TX_EN_SER5_RTS_B    */
+	{1, 4, 2, 0, 2}, /* ENET5_RX_DV_SER5_CTS_B    */
+	{1, 8, 2, 0, 2}, /* ENET5_RX_ER_SER5_CD_B    */
+
+	{0,  0, 0, 0, QE_IOP_TAB_END} /* END of table */
+};
+#endif
+
 int board_early_init_f(void)
 {
 
@@ -100,6 +139,14 @@ int board_eth_init(bd_t *bis)
 
 	tsec_eth_init(bis, tsec_info, num);
 
+#if defined(CONFIG_UEC_ETH)
+	/*  QE0 and QE3 need to be exposed for UCC1 and UCC5 Eth mode */
+	setbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_QE0);
+	setbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_QE3);
+
+	uec_standard_init(bis);
+#endif
+
 	return pci_eth_init(bis);
 }
 #endif
@@ -119,5 +166,9 @@ void ft_board_setup(void *blob, bd_t *bd)
 
 	FT_FSL_PCI_SETUP;
 
+#ifdef CONFIG_QE
+	do_fixup_by_compat(blob, "fsl,qe", "status", "okay",
+			sizeof("okay"), 0);
+#endif
 }
 #endif
drivers/qe/uec.c +23 -1
index 282ab23..04d7987 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006-2010 Freescale Semiconductor, Inc.
+ * Copyright (C) 2006-2011 Freescale Semiconductor, Inc.
 *
 * Dave Liu <[email protected]>
 *
@@ -30,6 +30,9 @@
 #include "uec.h"
 #include "uec_phy.h"
 #include "miiphy.h"
+#ifdef CONFIG_P1021
+#define BCSR11_ENET_MICRST	0x20
+#endif
 
 /* Default UTBIPAR SMI address */
 #ifndef CONFIG_UTBIPAR_INIT_TBIPA
@@ -588,9 +591,25 @@ static void phy_change(struct eth_device *dev)
 {
 	uec_private_t	*uec = (uec_private_t *)dev->priv;
 
+#ifdef CONFIG_P1021
+	ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
+
+	/* QE9 and QE12 need to be set for enabling QE MII managment signals */
+	setbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_QE9);
+	setbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_QE12);
+#endif
+
 	/* Update the link, speed, duplex */
 	uec->mii_info->phyinfo->read_status(uec->mii_info);
 
+#ifdef CONFIG_P1021
+	/*
+	 * QE12 is muxed with LBCTL, it needs to be released for enabling
+	 * LBCTL signal for LBC usage.
+	 */
+	clrbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_QE12);
+#endif
+
 	/* Adjust the interface according to speed */
 	adjust_link(dev);
 }
@@ -1198,10 +1217,24 @@ static int uec_init(struct eth_device* dev, bd_t *bd)
 	uec_private_t		*uec;
 	int			err, i;
 	struct phy_info         *curphy;
+#ifdef CONFIG_P1021
+	ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
+#endif

drivers/qe/uec.c static int uec_init(struct eth_device* dev, bd_t *bd) · line 1232

Quoted 10 lines
drivers/qe/uec.c +6 -0
 
 	uec = (uec_private_t *)dev->priv;
 
 	if (uec->the_first_run == 0) {
+#ifdef CONFIG_P1021
+	/* reset micrel phy for each UEC */
+	clrbits_8((u8 *)(CONFIG_SYS_BCSR_BASE + 11), BCSR11_ENET_MICRST);
+	udelay(200);
+	setbits_8((u8 *)(CONFIG_SYS_BCSR_BASE + 11), BCSR11_ENET_MICRST);
+

Hmm, this is board specific, can we not do this in board_*_f or _r?

Quoted 9 lines
drivers/qe/uec.c +5 -0
+	/* QE9 and QE12 need to be set for enabling QE MII managment signals */
+	setbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_QE9);
+	setbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_QE12);
+#endif
+
 		err = init_phy(dev);
 		if (err) {
 			printf("%s: Cannot initialize PHY, aborting.\n",

drivers/qe/uec.c static int uec_init(struct eth_device* dev, bd_t *bd) · line 1270

Quoted 10 lines
drivers/qe/uec.c +5 -0
@@ -1228,6 +1261,11 @@ static int uec_init(struct eth_device* dev, bd_t *bd)
 			udelay(100000);
 		} while (1);
 
+#ifdef CONFIG_P1021
+		/* QE12 needs to be released for enabling LBCTL signal*/
+		clrbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_QE12);
+#endif
+
 		if (err || i <= 0)
 			printf("warning: %s: timeout on PHY link\n", dev->name);

- k

#6 lore raw

PATCH v2 4/4 p1021mds: add QE and UEC support

Quoted 4 lines · Kumar Gala
Quoted 4 lines

+#endif

	uec = (uec_private_t *)dev->priv;
Quoted 10 lines

drivers/qe/uec.c static int uec_init(struct eth_device* dev, bd_t *bd) · line 1232

Quoted 7 lines
	if (uec->the_first_run == 0) {
drivers/qe/uec.c +6 -0
+#ifdef CONFIG_P1021
+	/* reset micrel phy for each UEC */
+	clrbits_8((u8 *)(CONFIG_SYS_BCSR_BASE + 11), BCSR11_ENET_MICRST);
+	udelay(200);
+	setbits_8((u8 *)(CONFIG_SYS_BCSR_BASE + 11), BCSR11_ENET_MICRST);
+

Hmm, this is board specific, can we not do this in board_*_f or _r?

It did not work to do this in board_*_f/r. The board designer to me to reset the phy before initializing it for each UEC separately. Here is the right place to do so.

Haiying

#7 lore raw

PATCH v2 4/4 p1021mds: add QE and UEC support

Quoted 17 lines · Haiying Wang
Quoted 4 lines · Kumar Gala
Quoted 4 lines

+#endif

	uec = (uec_private_t *)dev->priv;
Quoted 10 lines

drivers/qe/uec.c static int uec_init(struct eth_device* dev, bd_t *bd) · line 1232

Quoted 7 lines
	if (uec->the_first_run == 0) {
drivers/qe/uec.c +6 -0
+#ifdef CONFIG_P1021
+	/* reset micrel phy for each UEC */
+	clrbits_8((u8 *)(CONFIG_SYS_BCSR_BASE + 11), BCSR11_ENET_MICRST);
+	udelay(200);
+	setbits_8((u8 *)(CONFIG_SYS_BCSR_BASE + 11), BCSR11_ENET_MICRST);
+

Hmm, this is board specific, can we not do this in board_*_f or _r?

Quoted 1 line

It did not work to do this in board_*_f/r. The board designer to me to

:%s/to me/told me/

Quoted 2 lines

reset the phy before initializing it for each UEC separately. Here is the right place to do so.

Haiying

#8 lore raw

PATCH v2 4/4 p1021mds: add QE and UEC support

Quoted 18 lines · Haiying Wang
Quoted 17 lines · Haiying Wang
Quoted 14 lines · Kumar Gala

drivers/qe/uec.c static int uec_init(struct eth_device* dev, bd_t *bd) · line 1232

Quoted 11 lines

+#endif

	uec = (uec_private_t *)dev->priv;

	if (uec->the_first_run == 0) {
drivers/qe/uec.c +6 -0
+#ifdef CONFIG_P1021
+	/* reset micrel phy for each UEC */
+	clrbits_8((u8 *)(CONFIG_SYS_BCSR_BASE + 11), BCSR11_ENET_MICRST);
+	udelay(200);
+	setbits_8((u8 *)(CONFIG_SYS_BCSR_BASE + 11), BCSR11_ENET_MICRST);
+

Hmm, this is board specific, can we not do this in board_*_f or _r?

Quoted 7 lines
Quoted 1 line

It did not work to do this in board_*_f/r. The board designer to me to

:%s/to me/told me/

Quoted 2 lines

reset the phy before initializing it for each UEC separately. Here is the right place to do so.

Haiying

At a minimum this ifdef should be #ifdef CONFIG_P1021MDS

- k

#9 lore raw

PATCH v3 4/4 p1021mds: add QE and UEC support

In reply to Haiying.Wang at freescale.com

P1021 has some QE pins which need to be set in pmuxcr register before using QE functions. In this patch, pin QE0 and QE3 are set for UCC1 and UCC5 in Eth mode. QE9 and QE12 are set for MII management. QE12 needs to be released after MII access because QE12 pin is muxed with LBCTL signal.

---
v3: change resetting micrel phy via bcsr to board specific.

 arch/powerpc/cpu/mpc85xx/speed.c      |    4 ++
 arch/powerpc/include/asm/immap_85xx.h |   13 ++++++++
 board/freescale/p1021mds/p1021mds.c   |   51 +++++++++++++++++++++++++++++++++
 drivers/qe/uec.c                      |   41 +++++++++++++++++++++++++-
 include/configs/P1021MDS.h            |   44 ++++++++++++++++++++++++++++
 5 files changed, 152 insertions(+), 1 deletions(-)
arch/powerpc/cpu/mpc85xx/speed.c +4 -0
index f2aa8d0..ae94ee8 100644
@@ -165,10 +165,14 @@ void get_sys_info (sys_info_t * sysInfo)
 #endif
 
 #ifdef CONFIG_QE
+#ifdef CONFIG_P1021
+	sysInfo->freqQE =  sysInfo->freqSystemBus;
+#else
 	qe_ratio = ((gur->porpllsr) & MPC85xx_PORPLLSR_QE_RATIO)
 			>> MPC85xx_PORPLLSR_QE_RATIO_SHIFT;
 	sysInfo->freqQE = qe_ratio * CONFIG_SYS_CLK_FREQ;
 #endif
+#endif
 
 #if defined(CONFIG_FSL_LBC)
 #if defined(CONFIG_SYS_LBC_LCRR)
arch/powerpc/include/asm/immap_85xx.h +13 -0
index 99ecb83..d0fa79b 100644
@@ -1909,6 +1909,19 @@ typedef struct ccsr_gur {
 #define MPC85xx_PMUXCR_SD_DATA		0x80000000
 #define MPC85xx_PMUXCR_SDHC_CD		0x40000000
 #define MPC85xx_PMUXCR_SDHC_WP		0x20000000
+#define MPC85xx_PMUXCR_QE0             0x00008000
+#define MPC85xx_PMUXCR_QE1             0x00004000
+#define MPC85xx_PMUXCR_QE2             0x00002000
+#define MPC85xx_PMUXCR_QE3             0x00001000
+#define MPC85xx_PMUXCR_QE4             0x00000800
+#define MPC85xx_PMUXCR_QE5             0x00000400
+#define MPC85xx_PMUXCR_QE6             0x00000200
+#define MPC85xx_PMUXCR_QE7             0x00000100
+#define MPC85xx_PMUXCR_QE8             0x00000080
+#define MPC85xx_PMUXCR_QE9             0x00000040
+#define MPC85xx_PMUXCR_QE10            0x00000020
+#define MPC85xx_PMUXCR_QE11            0x00000010
+#define MPC85xx_PMUXCR_QE12            0x00000008
 	u32	pmuxcr2;	/* Alt. function signal multiplex control 2 */
 	u8	res6[8];
 	u32	devdisr;	/* Device disable control */
board/freescale/p1021mds/p1021mds.c +51 -0

68 lines not on this page · raw message

drivers/qe/uec.c +40 -1

76 lines not on this page · raw message

include/configs/P1021MDS.h +44 -0

50 lines not on this page · raw message

Signature · 1 line
1.7.3.1.50.g1e633
#10 lore raw

PATCH v3 4/4 p1021mds: add QE and UEC support

Quoted 6 lines · Haiying Wang

P1021 has some QE pins which need to be set in pmuxcr register before using QE functions. In this patch, pin QE0 and QE3 are set for UCC1 and UCC5 in Eth mode. QE9 and QE12 are set for MII management. QE12 needs to be released after MII access because QE12 pin is muxed with LBCTL signal.

Quoted 8 lines

---
v3: change resetting micrel phy via bcsr to board specific.

arch/powerpc/cpu/mpc85xx/speed.c      |    4 ++
arch/powerpc/include/asm/immap_85xx.h |   13 ++++++++
board/freescale/p1021mds/p1021mds.c   |   51 +++++++++++++++++++++++++++++++++
drivers/qe/uec.c                      |   41 +++++++++++++++++++++++++-
include/configs/P1021MDS.h            |   44 ++++++++++++++++++++++++++++
5 files changed, 152 insertions(+), 1 deletions(-)

still want to see QE related changes in their own patch, I'll post a version that merges part of this and part of 2/4 into one patch.

- k