Skip to contentSkip to conversation

Add mpc5125ads board and processor to the mpc512x family

PATCH New Martha Stan 2 participants 2 messages Oct 8, 2009 – Oct 13, 2009

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

PATCH 1/1 Add mpc5125ads board and processor to the mpc512x family

---
 MAINTAINERS                             |    5 +
 MAKEALL                                 |    1 +
 Makefile                                |    3 +
 board/freescale/mpc5125ads/Makefile     |   53 ++++
 board/freescale/mpc5125ads/config.mk    |   23 ++
 board/freescale/mpc5125ads/cpld.h       |   50 ++++
 board/freescale/mpc5125ads/mpc5125ads.c |  415 ++++++++++++++++++++++++++
 cpu/mpc512x/asm-offsets.h               |    6 +
 cpu/mpc512x/cpu.c                       |    3 +
 cpu/mpc512x/fixed_sdram.c               |    6 +
 cpu/mpc512x/iopin.c                     |   22 ++
 cpu/mpc512x/serial.c                    |   17 +-
 cpu/mpc512x/start.S                     |   15 +
 drivers/net/mpc512x_fec.c               |   51 +++-
 include/asm-ppc/immap_512x.h            |  285 +++++++++++++++++-
 include/configs/mpc5125ads.h            |  486 +++++++++++++++++++++++++++++++
 16 files changed, 1418 insertions(+), 23 deletions(-)
 create mode 100644 board/freescale/mpc5125ads/Makefile
 create mode 100644 board/freescale/mpc5125ads/config.mk
 create mode 100644 board/freescale/mpc5125ads/cpld.h
 create mode 100644 board/freescale/mpc5125ads/mpc5125ads.c
 create mode 100644 include/configs/mpc5125ads.h
MAINTAINERS +5 -0
index f42c8f0..b2eaa8d 100644
@@ -424,6 +424,11 @@ Jon Smirl <[email protected]>
 
 	pcm030		MPC5200
 
+Martha Marx Stan <[email protected]>
+
+	mpc5121ads	MPC5121E
+	mpc5125ads	MPC5125
+
 Timur Tabi <[email protected]>
 
 	MPC8349E-mITX	MPC8349
MAKEALL +1 -0
index 8ff6987..3e84356 100755
@@ -91,6 +91,7 @@ LIST_512x="		\
 	aria		\
 	mecp5123	\
 	mpc5121ads	\
+	mpc5125ads	\
 "
 
 #########################################################################
Makefile +3 -0
index 5857b52..a4ad8e7 100644
@@ -844,6 +844,9 @@ mpc5121ads_rev2_config	\
 	fi
 	@$(MKCONFIG) -a mpc5121ads ppc mpc512x mpc5121ads freescale
 
+mpc5125ads_config:	unconfig
+	@$(MKCONFIG) -a mpc5125ads ppc mpc512x mpc5125ads freescale
+
 #########################################################################
 ## MPC8xx Systems
 #########################################################################
board/freescale/mpc5125ads/Makefile new file +53 -0

53 lines not on this page · raw message

board/freescale/mpc5125ads/config.mk new file +23 -0
new file mode 100644
index 0000000..14998f4
@@ -0,0 +1,23 @@
+#
+# (C) Copyright 2007 DENX Software Engineering
+#
+# 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
+#
+
+TEXT_BASE  =   0xFFF00000
board/freescale/mpc5125ads/cpld.h new file +50 -0

50 lines not on this page · raw message

board/freescale/mpc5125ads/mpc5125ads.c new file +415 -0

415 lines not on this page · raw message

cpu/mpc512x/asm-offsets.h +6 -0
index 4b14778..b79c656 100644
@@ -11,5 +11,11 @@
 #define CS_CTRL			0x00020
 #define CS_CTRL_ME		0x01000000	/* CS Master Enable bit */
 
+/* needed for pin muxing in MPC5125 */
+#define IOCTRL_OFFSET	0xA000
+#define IOCTRL_LPC_AX03	0x09
+#define IOCTRL_I2C1_SCL	0x4f
+#define IOCTRL_I2C1_SDA	0x50
+
 #define EXC_OFF_SYS_RESET	0x0100
 #define	_START_OFFSET		EXC_OFF_SYS_RESET
cpu/mpc512x/cpu.c +3 -0
index 42ccd81..6d9a5ec 100644
@@ -53,6 +53,9 @@ int checkcpu (void)
 	case SPR_5121E:
 		puts ("MPC5121e ");
 		break;
+	case SPR_5125:
+		puts ("MPC5125 ");
+		break;
 	default:
 		printf ("Unknown part ID %08x ", spridr & 0xffff0000);
 	}
cpu/mpc512x/fixed_sdram.c +6 -0
index 673d61e..09985e7 100644
@@ -36,6 +36,7 @@ u32 default_mddrc_config[4] = {
 };
 
 u32 default_init_seq[] = {
+#ifndef CONFIG_SYS_DDR_OVRIDE_DEF /* makes it unnecessary to declare these */
 	CONFIG_SYS_DDRCMD_NOP,
 	CONFIG_SYS_DDRCMD_NOP,
 	CONFIG_SYS_DDRCMD_NOP,
@@ -67,6 +68,7 @@ u32 default_init_seq[] = {
 	CONFIG_SYS_DDRCMD_OCD_DEFAULT,
 	CONFIG_SYS_DDRCMD_PCHG_ALL,
 	CONFIG_SYS_DDRCMD_NOP
+#endif
 };
 
 /*
@@ -90,7 +92,11 @@ long int fixed_sdram(u32 *mddrc_config, u32 *dram_init_seq, int seq_sz)
 	}
 
 	/* Initialize IO Control */
+#ifdef CONFIG_MPC5125
+	out_8(&im->io_ctrl.io_control_mem, IOCTRL_MUX_DDR);
+#else
 	out_be32(&im->io_ctrl.io_control_mem, IOCTRL_MUX_DDR);
+#endif
 
 	/* Initialize DDR Local Window */
 	out_be32(&im->sysconf.ddrlaw.bar, CONFIG_SYS_DDR_BASE & 0xFFFFF000);
cpu/mpc512x/iopin.c +22 -0
index be20947..d923e1d 100644
@@ -47,3 +47,25 @@ void iopin_initialize(iopin_t *ioregs_init, int len)
 	}
 	return;
 }
+
+void iopin5125_initialize(iopin5125_t *ioregs_init, int len)
+{
+	short i, j, p;
+	immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
+
+	u8 *reg = (u8 *)&(im->io_ctrl);
+
+	if (sizeof(ioregs_init) == 0)
+		return;
+
+	for (i = 0; i < len; i++) {
+		for (p = 0, j = ioregs_init[i].p_offset;
+			p < ioregs_init[i].nr_pins; p++, j++) {
+			if (ioregs_init[i].bit_or)
+				setbits_8(&(reg[j]), ioregs_init[i].val);
+			else
+				out_8(&reg[j], ioregs_init[i].val);
+		}
+	}
+	return;
+}
cpu/mpc512x/serial.c +15 -2
index 4fc4693..89fa139 100644
@@ -80,7 +80,7 @@ int serial_init(void)
 	volatile psc512x_t *psc = (psc512x_t *) &im->psc[CONFIG_PSC_CONSOLE];
 
 	fifo_init (psc);
-
+#ifndef CONFIG_MPC5125
 	/* set MR register to point to MR1 */
 	out_8(&psc->command, PSC_SEL_MODE_REG_1);
 
@@ -93,12 +93,25 @@ int serial_init(void)
 	/* switch to UART mode */
 	out_be32(&psc->sicr, 0);
 
-	/* mode register points to mr1 */
 	/* configure parity, bit length and so on in mode register 1*/
+	/* mode register points to mr1 */
 	out_8(&psc->mode, PSC_MODE_8_BITS | PSC_MODE_PARNONE);
 	/* now, mode register points to mr2 */
 	out_8(&psc->mode, PSC_MODE_1_STOPBIT);
+#else
+	/* disable Tx/Rx */
+	out_8(&psc->command, PSC_TX_DISABLE | PSC_RX_DISABLE);
+
+	/* choose the prescaler	the Tx/Rx clock generation */
+	out_8(&psc->psc_clock_select, 0xdd);
+
+	/* switch to UART mode */
+	out_be32(&psc->sicr, 0);
 
+	/* configure parity, bit length and so on in mode registers */
+	out_8(&psc->mr1, PSC_MODE_8_BITS | PSC_MODE_PARNONE);
+	out_8(&psc->mr2, PSC_MODE_1_STOPBIT);
+#endif
 	/* set baudrate */
 	serial_setbrg();
 
cpu/mpc512x/start.S +15 -0
index 2e3f645..205208f 100644
@@ -243,6 +243,21 @@ boot_cold:
 	lis     r4, CONFIG_SYS_CS0_CFG at h
 	ori     r4, r4, CONFIG_SYS_CS0_CFG at l
 	stw     r4, CS0_CONFIG(r3)
+#ifdef CONFIG_MPC5125
+	/* CS2 FUNC MUX must be done before CS is enabled */
+	lis     r5, (CONFIG_SYS_IMMR + IOCTRL_OFFSET)@h
+	ori     r5, r5, (CONFIG_SYS_IMMR + IOCTRL_OFFSET)@l
+
+	li	r4, CONFIG_SYS_IOCTRL_MUX_CS2
+	stb	r4, IOCTRL_LPC_AX03(r5)
+
+	/* change the pin muxing on PSC9 if it is being used as console */
+#if (CONFIG_PSC_CONSOLE == 9)
+	li	r4, CONFIG_SYS_IOCTRL_MUX_PSC9
+	stb	r4, IOCTRL_I2C1_SCL(r5)
+	stb	r4, IOCTRL_I2C1_SDA(r5)
+#endif
+#endif
 
 	/* Master enable all CS's */
 	lis	r4, CS_CTRL_ME at h
drivers/net/mpc512x_fec.c +42 -9

106 lines not on this page · raw message

include/asm-ppc/immap_512x.h +273 -12

375 lines not on this page · raw message

include/configs/mpc5125ads.h new file +486 -0

486 lines not on this page · raw message

Signature · 1 line
1.6.0.2
#1 lore raw

PATCH 1/1 Add mpc5125ads board and processor to the mpc512x family

Dear Martha Stan,

Quoted 16 lines · In message <[email protected]> you wrote:
---
 MAINTAINERS                             |    5 +
 MAKEALL                                 |    1 +
 Makefile                                |    3 +
 board/freescale/mpc5125ads/Makefile     |   53 ++++
 board/freescale/mpc5125ads/config.mk    |   23 ++
 board/freescale/mpc5125ads/cpld.h       |   50 ++++
 board/freescale/mpc5125ads/mpc5125ads.c |  415 ++++++++++++++++++++++++++
 cpu/mpc512x/asm-offsets.h               |    6 +
 cpu/mpc512x/cpu.c                       |    3 +
 cpu/mpc512x/fixed_sdram.c               |    6 +
 cpu/mpc512x/iopin.c                     |   22 ++
 cpu/mpc512x/serial.c                    |   17 +-
 cpu/mpc512x/start.S                     |   15 +
 drivers/net/mpc512x_fec.c               |   51 +++-
Quoted 8 lines
 include/asm-ppc/immap_512x.h            |  285 +++++++++++++++++-
 include/configs/mpc5125ads.h            |  486 +++++++++++++++++++++++++++++++
 16 files changed, 1418 insertions(+), 23 deletions(-)
 create mode 100644 board/freescale/mpc5125ads/Makefile
 create mode 100644 board/freescale/mpc5125ads/config.mk
 create mode 100644 board/freescale/mpc5125ads/cpld.h
 create mode 100644 board/freescale/mpc5125ads/mpc5125ads.c
 create mode 100644 include/configs/mpc5125ads.h

First, I want to point out that I am well aware that a lot of the trouble with this patch is caused by factors completely out of your control (like Freescale coming up with such an ugly incompatibility in the register interface between chips in the same CPU family), and that you are not the culprit but the victim actually.

However, I think this current version of the patch is still not ripe for inclusion into mainline - there are still way too many ugly #ifdef's everywhere.

We need to find a way to work around these register interface issues more intelligently.

Besides that, there are a few formal issues with your patch:

- there are whitespace errors:

Applying: Add mpc5125ads board and processor to the mpc512x
family
/home/wd/git/u-boot/work/.git/rebase-apply/patch:815: trailing whitespace.
out_be32(&fec->eth->r_cntrl, (FEC_MAX_FRAME_LEN << 16) | 0x124);
warning: 1 line applied after fixing whitespace errors.

- checkpatch.pl reports a number of issues, especially inconsistent use of white space

Quoted 2 lines

+++ b/board/freescale/mpc5125ads/cpld.h

(quoted diff) +0 -0
@@ -0,0 +1,50 @@

...

Quoted 8 lines
board/freescale/mpc5125ads/cpld.h new file +8 -0
+/*
+ * MPC5125ADS CPLD Registers
+ */
+typedef struct mpc5125ads_cpld {
+	u16 board_id;
+	u8 cpld_rev[2];
+	u8 reset_cfg_word[4];
+	u8 nor_flash_ctl;

board/freescale/mpc5125ads/cpld.h line 42

Quoted 10 lines
board/freescale/mpc5125ads/cpld.h new file +10 -0
+	u8 nand_can_gpio_ctl;
+	u8 res1[3];
+	u8 int_mask;
+	u8 int_satus;
+	u8 misc_ctl;
+	u8 video_ctl;
+	u8 user_led;
+	u8 res2;
+	u8 cfg_switch;
+} mpc5125ads_cpld_t;

This is unrelated to this patch - but could we please have such a struct for the mpc5121ads CPLD registers, too? Thanks in advance.

board/freescale/mpc5125ads/mpc5125ads.c line 363

Quoted 5 lines
board/freescale/mpc5125ads/mpc5125ads.c new file +5 -0
+#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
+	/*
+	 * DIU init before the driver in linux takes over
+	 * Enable the TFP410 Encoder (I2C address 0x38)
+	 */

This seems logically wrong to me. Why does the DIU init code depend on CONFIG_HARD_I2C or CONFIG_SOFT_I2C? Support for the DIU is an unrelated feature, which should separately be enabled. And if it's enabled, you must make sure to enable the prerequisites (like I2C suport), too.

Quoted 13 lines
board/freescale/mpc5125ads/mpc5125ads.c new file +13 -0
+	i2c_set_bus_num(1);
+	tmp_val = 0xBF;
+	if (i2c_write(0x38, 0x08, 1, &tmp_val, sizeof(tmp_val)) != 0)
+		goto i2c_err;
+
+	/* Verify if enabled */
+	if (i2c_read(0x38, 0x08, 1, &tmp_val, sizeof(tmp_val)) != 0)
+		goto i2c_err;
+	debug("DVI Encoder Read: 0x%02lx\n", tmp_val);
+	tmp_val = 0x10;
+	if (i2c_write(0x38, 0x0A, 1, &tmp_val, sizeof(tmp_val)) != 0)
+		goto i2c_err;
+

board/freescale/mpc5125ads/mpc5125ads.c line 386

Quoted 10 lines
board/freescale/mpc5125ads/mpc5125ads.c new file +10 -0
+	/* Verify if enabled */
+	if (i2c_read(0x38, 0x0A, 1, &tmp_val, sizeof(tmp_val)) != 0)
+		goto i2c_err;
+	debug("DVI Encoder Read: 0x%02lx\n", tmp_val);
+#endif
+#ifdef CONFIG_FSL_DIU_FB
+#if	!(defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE))
+	mpc5121_diu_init();
+#endif
+#endif

Actually it seems we have copies of identical code in board/freescale/mpc5121ads/mpc5121ads.c and in board/freescale/mpc8610hpcd/mpc8610hpcd.c already. So instead of adding a third copy of that code please factor this out into a separate, common function that can be called by all such boards (this needs to be done in a separate patch).

cpu/mpc512x/asm-offsets.h line 18

Quoted 13 lines
cpu/mpc512x/asm-offsets.h +5 -0
index 4b14778..b79c656 100644
@@ -11,5 +11,11 @@
 #define CS_CTRL			0x00020
 #define CS_CTRL_ME		0x01000000	/* CS Master Enable bit */
 
+/* needed for pin muxing in MPC5125 */
+#define IOCTRL_OFFSET	0xA000
+#define IOCTRL_LPC_AX03	0x09
+#define IOCTRL_I2C1_SCL	0x4f
+#define IOCTRL_I2C1_SDA	0x50

We should avoid adding stuff to asm-offsets.h; instead, we should finally auto-generate this file from the respective C structs as it's done in Linux. Do you dare to tackle this?

Quoted 13 lines
cpu/mpc512x/fixed_sdram.c +1 -0
index 673d61e..09985e7 100644
@@ -36,6 +36,7 @@ u32 default_mddrc_config[4] = {
 };
 
 u32 default_init_seq[] = {
+#ifndef CONFIG_SYS_DDR_OVRIDE_DEF /* makes it unnecessary to declare these */
 	CONFIG_SYS_DDRCMD_NOP,
 	CONFIG_SYS_DDRCMD_NOP,
 	CONFIG_SYS_DDRCMD_NOP,

cpu/mpc512x/fixed_sdram.c u32 default_init_seq[] = { · line 72

Quoted 5 lines
cpu/mpc512x/fixed_sdram.c +1 -0
@@ -67,6 +68,7 @@ u32 default_init_seq[] = {
 	CONFIG_SYS_DDRCMD_OCD_DEFAULT,
 	CONFIG_SYS_DDRCMD_PCHG_ALL,
 	CONFIG_SYS_DDRCMD_NOP
+#endif
 };

NAK. Please don't add #ifdef's here. This is the default init sequence, and if it does not fit your purposes, then please use a private one.

cpu/mpc512x/fixed_sdram.c long int fixed_sdram(u32 *mddrc_config, u32 *dram_init_seq, int seq_sz) · line 99

Quoted 6 lines
cpu/mpc512x/fixed_sdram.c +4 -0
 	/* Initialize IO Control */
+#ifdef CONFIG_MPC5125
+	out_8(&im->io_ctrl.io_control_mem, IOCTRL_MUX_DDR);
+#else
 	out_be32(&im->io_ctrl.io_control_mem, IOCTRL_MUX_DDR);
+#endif

This is something which happens a lot in the remaining code - so often that it is plain unacceptable. As mentioned above, I know that you are just a victim here, but we need a less ugly implementation.

If I understand correctly, all MPC512x actually use 8 bit only here, even though the register declarations on MPC5121/5123 are 32 bit wide. Eventually we should do what Grant Likely already did in the Linux kernel and change all thjis code to use 8 bit accesses only, which means to add the needed padding to the respective data stricts
- similar to what was done to make the 16550 serial driver really generic.

However, this is a pretty invasive operation, that will have to wait for the next release in any case. And actually I would like to delay this until at least an official Reference Manual for the MPC5125 has been publicly released by Freescale.

Quoted 29 lines
cpu/mpc512x/serial.c +8 -2
index 4fc4693..89fa139 100644
@@ -80,7 +80,7 @@ int serial_init(void)
 	volatile psc512x_t *psc = (psc512x_t *) &im->psc[CONFIG_PSC_CONSOLE];
 
 	fifo_init (psc);
-
+#ifndef CONFIG_MPC5125
 	/* set MR register to point to MR1 */
 	out_8(&psc->command, PSC_SEL_MODE_REG_1);
 
@@ -93,12 +93,25 @@ int serial_init(void)
 	/* switch to UART mode */
 	out_be32(&psc->sicr, 0);
 
-	/* mode register points to mr1 */
 	/* configure parity, bit length and so on in mode register 1*/
+	/* mode register points to mr1 */
 	out_8(&psc->mode, PSC_MODE_8_BITS | PSC_MODE_PARNONE);
 	/* now, mode register points to mr2 */
 	out_8(&psc->mode, PSC_MODE_1_STOPBIT);
+#else
+	/* disable Tx/Rx */
+	out_8(&psc->command, PSC_TX_DISABLE | PSC_RX_DISABLE);
+
+	/* choose the prescaler	the Tx/Rx clock generation */
+	out_8(&psc->psc_clock_select, 0xdd);

cpu/mpc512x/serial.c int serial_init(void) · line 116

Quoted 10 lines
cpu/mpc512x/serial.c +7 -0
+
+	/* switch to UART mode */
+	out_be32(&psc->sicr, 0);
 
+	/* configure parity, bit length and so on in mode registers */
+	out_8(&psc->mr1, PSC_MODE_8_BITS | PSC_MODE_PARNONE);
+	out_8(&psc->mr2, PSC_MODE_1_STOPBIT);
+#endif
 	/* set baudrate */
 	serial_setbrg();

I think we should move the differing code into separate functions.

Quoted 5 lines
drivers/net/mpc512x_fec.c +0 -0
index fb2c19a..9f839a1 100644

drivers/net/mpc512x_fec.c static int rx_buff_idx = 0; · line 49

Quoted 10 lines
drivers/net/mpc512x_fec.c +6 -1
@@ -41,7 +41,12 @@ static int rx_buff_idx = 0;
 static void mpc512x_fec_phydump (char *devname)
 {
 	u16 phyStatus, i;
-	u8 phyAddr = CONFIG_PHY_ADDR;
+#ifdef CONFIG_MPC5125
+	uint8 phyAddr = ((devname[3] == '2') ? CONFIG_PHY2_ADDR :
+				CONFIG_PHY_ADDR);
+#else
+	uint8 phyAddr = CONFIG_PHY_ADDR;
+#endif

Can we not do without this #ifdef here?

Quoted 7 lines
drivers/net/mpc512x_fec.c +0 -0
 	u8 reg_mask[] = {
 		/* regs to print: 0...8, 21,27,31 */
 		1, 1, 1, 1,  1, 1, 1, 1,     1, 0, 0, 0,  0, 0, 0, 0,
@@ -242,9 +247,17 @@ static int mpc512x_fec_init (struct eth_device *dev, bd_t * bis)
 	/* Set Opcode/Pause Duration Register */
 	out_be32(&fec->eth->op_pause, 0x00010020);
 

drivers/net/mpc512x_fec.c static int mpc512x_fec_init (struct eth_device *dev, bd_t * bis) · line 259

Quoted 10 lines
drivers/net/mpc512x_fec.c +8 -0
+#ifdef CONFIG_MPC5125
+	/* RMII Mode */
+	if (dev->name[3] == '2')
+		out_be32(&fec->eth->r_cntrl, (FEC_MAX_FRAME_LEN << 16) | 0x124);	
+	else
+	/* Frame length=1522; MII mode */
+		out_be32(&fec->eth->r_cntrl, (FEC_MAX_FRAME_LEN << 16) | 0x24);
+#else
 	/* Frame length=1522; MII mode */
 	out_be32(&fec->eth->r_cntrl, (FEC_MAX_FRAME_LEN << 16) | 0x24);

Ditto. There is a lot of code duplication here. How about something similar to this:

	/* Frame length=1522; MII mode */
	val = (FEC_MAX_FRAME_LEN << 16) | 0x24;

	if (dev->name[3] == '2')
		val |= 0x100;		/* RMII Mode */

	out_be32(&fec->eth->r_cntrl, val);

etc.

More simplifications like this should be applied elsewhere. Please rework globally.

drivers/net/mpc512x_fec.c int mpc512x_fec_initialize (bd_t * bis) · line 662

Quoted 6 lines
drivers/net/mpc512x_fec.c +5 -1
-	sprintf (dev->name, "FEC ETHERNET");
+	if (cur_fec == &(im->fec))
+		sprintf (dev->name, "FEC ETHERNET");
+	else
+		sprintf (dev->name, "FEC2 ETHERNET");
+

Maybe

	sprintf (dev->name, "FEC%s ETHERNET",
		(cur_fec == &(im->fec)) ? "" : "2");

or similar?

drivers/net/mpc512x_fec.c int mpc512x_fec_initialize (bd_t * bis) · line 721

Quoted 8 lines
drivers/net/mpc512x_fec.c +8 -0
+#ifdef CONFIG_MPC5125
+	/* 2nd fec may not be in use */
+	if (cur_fec == &(im->fec) &&
+		(in_be32(&im->clk.sccr[0]) & CLOCK_SCCR1_FEC2_EN)) {
+		cur_fec = &(im->fec2);
+		goto fec_init_start;
+	}
+#endif

What do you mean by "2nd fec may not be in use"?

Quoted 4 lines
include/asm-ppc/immap_512x.h +0 -0
index 79cdd80..1c1d235 100644

...

Quoted 4 lines

+#ifndef CONFIG_MPC5125
/*
- * PSC
+ * MPC5121 PSC

Quoted 8 lines

+ * note: MPC5121e register overloading is handled by unions with #defines to
+ * reference the reg seemlessly these #defines must not exist for MPC5125 code
+ * since it does not have this overloading. Since the register naming is the
+ * same as the MPC5125 Reference Manual and this naming is exactly the reg names
+ * used in the init code (which is nearly identical) it causes compile errors to
+ * leave in and must be #ifdef'ed out. It also helps to share code to have the
+ * same structure for both MPC5121 and MPC5125
*/

I disagree. To me the code becomes pretty much unreadable. I think we need to find a better implementation for this.

Quoted 16 lines
include/asm-ppc/immap_512x.h +10 -0
@@ -1200,23 +1445,39 @@ typedef struct immap {
 	fec512x_t		fec;		/* Fast Ethernet Controller */
 	ulpi512x_t		ulpi;		/* USB ULPI */
 	u8			res4[0xa00];
+#ifdef CONFIG_MPC5125
+	ulpi512x_t		ulpi2;		/* USB ULPI */
+	u8			res5[0x200];
+	fec512x_t		fec2;		/* 2nd Fast Eth Controller */
+	gpt512x_t		gpt2;		/* 2nd General Purpose Timer */
+	sdhc512x_t		sdhc2;		/* 2nd SDHC */
+	u8			res6[0x3e00];
+	ddr512x_t		mddrc;		/* DDR Memory Controller */
+	ioctrl5125_t		io_ctrl;	/* IO Control */
+#else
 	utmi512x_t		utmi;		/* USB UTMI */
 	u8			res5[0x1000];

include/asm-ppc/immap_512x.h typedef struct immap { · line 1468

Quoted 10 lines
include/asm-ppc/immap_512x.h +2 -1
 	pcidma512x_t		pci_dma;	/* PCI DMA */
 	pciconf512x_t		pci_conf;	/* PCI Configuration */
 	u8			res6[0x80];
 	ios512x_t		ios;		/* PCI Sequencer */
-	pcictrl512x_t		pci_ctrl;	/* PCI Controller Control and Status */
+	pcictrl512x_t		pci_ctrl;	/* PCI Controller Control */
 	u8			res7[0xa00];
 	ddr512x_t		mddrc;		/* Multi-port DDR Memory Controller */
 	ioctrl512x_t		io_ctrl;	/* IO Control */
+#endif

Is there any reason for having identical entries (mddrc, io_ctrl) in both branches? Whyno factor these out, too?

include/asm-ppc/immap_512x.h typedef struct immap { · line 1480

Quoted 7 lines
include/asm-ppc/immap_512x.h +5 -0
+#ifdef CONFIG_MPC5125
+	psc512x_t		psc[10];	/* PSCs */
+	u8			res10[0x500];
+#else
 	psc512x_t		psc[12];	/* PSCs */
 	u8			res10[0x300];
+#endif

This should be handled by #defining constants and without an #ifdef here.

...

Quoted 5 lines
include/asm-ppc/immap_512x.h +5 -0
+#include <config_cmd_default.h>
+
+#define CONFIG_CMD_ASKENV
+#define CONFIG_CMD_DHCP
+#define CONFIG_CMD_MII

include/asm-ppc/immap_512x.h typedef struct immap {

Quoted 10 lines
include/asm-ppc/immap_512x.h +10 -0
+#define CONFIG_CMD_NFS
+#define CONFIG_CMD_PING
+#define CONFIG_CMD_REGINFO
+#define CONFIG_CMD_FUSE
+
+#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
+#define CONFIG_CMD_EEPROM
+#define CONFIG_CMD_DATE
+#define CONFIG_CMD_I2C
+#endif

You may want to keep such lists sorted.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"We all agree on the necessity of compromise. We just can't agree  on
when it's necessary to compromise."
                - Larry Wall in  <[email protected]>