mpc832x: add support for the mpc8321 based suvd3 board

- serial console on UART1
- Ethernet RMII over UCC4
- PHY SMSC LAN8700
- 64MB Flash
- 128 MB DDR2 RAM
- I2C
- bootcount

This board is similiar to the kmeter1 (8360) board,
so common config options are extracted into the
include/configs/km83xx-common.h file.

Signed-off-by: Heiko Schocher <hs@denx.de>
Acked-by: Kim Phillips <kim.phillips@freescale.com>
cc: Kim Phillips <kim.phillips@freescale.com>
cc: Holger Brunck <holger.brunck@keymile.com>
cc: Valentin Longchamp <valentin.longchamp@keymile.com>
diff --git a/board/keymile/common/common.c b/board/keymile/common/common.c
index ea32028..85538d0 100644
--- a/board/keymile/common/common.c
+++ b/board/keymile/common/common.c
@@ -29,6 +29,7 @@
 #include <malloc.h>
 #include <hush.h>
 #include <net.h>
+#include <netdev.h>
 #include <asm/io.h>
 
 #if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT)
@@ -402,7 +403,7 @@
 #endif
 #endif
 
-#if !defined(CONFIG_KMETER1)
+#if !defined(CONFIG_MPC83xx)
 static void writeStartSeq(void)
 {
 	set_sda(1);
@@ -461,7 +462,7 @@
  */
 void i2c_init_board(void)
 {
-#if defined(CONFIG_KMETER1)
+#if defined(CONFIG_MPC83xx)
 	struct fsl_i2c *dev;
 	dev = (struct fsl_i2c *) (CONFIG_SYS_IMMR + CONFIG_SYS_I2C_OFFSET);
 	uchar	dummy;
@@ -573,6 +574,7 @@
 	(void)keymile_hdlc_enet_initialize(bis);
 #endif
 	if (ethernet_present())
-		return -1;
-	return 0;
+		return cpu_eth_init(bis);
+
+	return -1;
 }
diff --git a/board/keymile/kmeter1/Makefile b/board/keymile/km83xx/Makefile
similarity index 100%
rename from board/keymile/kmeter1/Makefile
rename to board/keymile/km83xx/Makefile
diff --git a/board/keymile/kmeter1/kmeter1.c b/board/keymile/km83xx/km83xx.c
similarity index 66%
rename from board/keymile/kmeter1/kmeter1.c
rename to board/keymile/km83xx/km83xx.c
index 9c18168..98aceef 100644
--- a/board/keymile/kmeter1/kmeter1.c
+++ b/board/keymile/km83xx/km83xx.c
@@ -8,7 +8,7 @@
  * Copyright (C) 2007 MontaVista Software, Inc.
  *                    Anton Vorontsov <avorontsov@ru.mvista.com>
  *
- * (C) Copyright 2008
+ * (C) Copyright 2008 - 2010
  * Heiko Schocher, DENX Software Engineering, hs@denx.de.
  *
  * This program is free software; you can redistribute it and/or
@@ -32,7 +32,7 @@
 
 const qe_iop_conf_t qe_iop_conf_tab[] = {
 	/* port pin dir open_drain assign */
-
+#if defined(CONFIG_KMETER1)
 	/* MDIO */
 	{0,  1, 3, 0, 2}, /* MDIO */
 	{0,  2, 1, 0, 1}, /* MDC */
@@ -55,6 +55,40 @@
 	{5,  2, 1, 0, 1}, /* UART2_RTS */
 	{5,  3, 2, 0, 2}, /* UART2_SIN */
 	{5,  1, 2, 0, 3}, /* UART2_CTS */
+#else
+	/* Local Bus */
+	{0, 16, 1, 0, 3}, /* LA00 */
+	{0, 17, 1, 0, 3}, /* LA01 */
+	{0, 18, 1, 0, 3}, /* LA02 */
+	{0, 19, 1, 0, 3}, /* LA03 */
+	{0, 20, 1, 0, 3}, /* LA04 */
+	{0, 21, 1, 0, 3}, /* LA05 */
+	{0, 22, 1, 0, 3}, /* LA06 */
+	{0, 23, 1, 0, 3}, /* LA07 */
+	{0, 24, 1, 0, 3}, /* LA08 */
+	{0, 25, 1, 0, 3}, /* LA09 */
+	{0, 26, 1, 0, 3}, /* LA10 */
+	{0, 27, 1, 0, 3}, /* LA11 */
+	{0, 28, 1, 0, 3}, /* LA12 */
+	{0, 29, 1, 0, 3}, /* LA13 */
+	{0, 30, 1, 0, 3}, /* LA14 */
+	{0, 31, 1, 0, 3}, /* LA15 */
+
+	/* MDIO */
+	{3,  4, 3, 0, 2}, /* MDIO */
+	{3,  5, 1, 0, 2}, /* MDC */
+
+	/* UCC4 - UEC */
+	{1, 18, 1, 0, 1}, /* TxD0 */
+	{1, 19, 1, 0, 1}, /* TxD1 */
+	{1, 22, 2, 0, 1}, /* RxD0 */
+	{1, 23, 2, 0, 1}, /* RxD1 */
+	{1, 26, 2, 0, 1}, /* RxER */
+	{1, 28, 2, 0, 1}, /* Rx_DV */
+	{1, 30, 1, 0, 1}, /* TxEN */
+	{1, 31, 2, 0, 1}, /* CRS */
+	{3, 10, 2, 0, 3}, /* TxCLK->CLK17 */
+#endif
 
 	/* END of table */
 	{0,  0, 0, 0, QE_IOP_TAB_END},
@@ -77,11 +111,38 @@
 	return 0;
 }
 
+#if defined(CONFIG_SUVD3)
+const uint upma_table[] = {
+	0x1ffedc00, 0x0ffcdc80, 0x0ffcdc80, 0x0ffcdc04, /* Words 0 to 3 */
+	0x0ffcdc00, 0xffffcc00, 0xffffcc01, 0xfffffc01, /* Words 4 to 7 */
+	0xfffffc01, 0xfffffc01, 0xfffffc01, 0xfffffc01, /* Words 8 to 11 */
+	0xfffffc01, 0xfffffc01, 0xfffffc01, 0xfffffc01, /* Words 12 to 15 */
+	0xfffffc01, 0xfffffc01, 0xfffffc01, 0xfffffc01, /* Words 16 to 19 */
+	0xfffffc01, 0xfffffc01, 0xfffffc01, 0xfffffc01, /* Words 20 to 23 */
+	0x9cfffc00, 0x00fffc80, 0x00fffc80, 0x00fffc00, /* Words 24 to 27 */
+	0xffffec04, 0xffffec01, 0xfffffc01, 0xfffffc01, /* Words 28 to 31 */
+	0xfffffc01, 0xfffffc01, 0xfffffc01, 0xfffffc01, /* Words 32 to 35 */
+	0xfffffc01, 0xfffffc01, 0xfffffc01, 0xfffffc01, /* Words 36 to 39 */
+	0xfffffc01, 0xfffffc01, 0xfffffc01, 0xfffffc01, /* Words 40 to 43 */
+	0xfffffc01, 0xfffffc01, 0xfffffc01, 0xfffffc01, /* Words 44 to 47 */
+	0xfffffc01, 0xfffffc01, 0xfffffc01, 0xfffffc01, /* Words 48 to 51 */
+	0xfffffc01, 0xfffffc01, 0xfffffc01, 0xfffffc01, /* Words 52 to 55 */
+	0xfffffc01, 0xfffffc01, 0xfffffc01, 0xfffffc01, /* Words 56 to 59 */
+	0xfffffc01, 0xfffffc01, 0xfffffc01, 0xfffffc01  /* Words 60 to 63 */
+};
+#endif
+
 int board_early_init_r(void)
 {
 	struct km_bec_fpga *base = (struct km_bec_fpga *)CONFIG_SYS_PIGGY_BASE;
-	unsigned short	svid;
+#if defined(CONFIG_SUVD3)
+	immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
+	fsl_lbc_t *lbc = &immap->im_lbc;
+	u32 *mxmr = &lbc->mamr;
+#endif
 
+#if defined(CONFIG_MPC8360)
+	unsigned short	svid;
 	/*
 	 * Because of errata in the UCCs, we have to write to the reserved
 	 * registers to slow the clocks down.
@@ -105,13 +166,19 @@
 			0x00000050, 0x000000a0);
 		break;
 	}
+#endif
+
 	/* enable the PHY on the PIGGY */
 	setbits_8(&base->pgy_eth, 0x01);
 	/* enable the Unit LED (green) */
 	setbits_8(&base->oprth, WRL_BOOT);
-	/* take FE/GbE PHYs out of reset */
-	setbits_8(&base->prst, 0x1c);
 
+#if defined(CONFIG_SUVD3)
+	/* configure UPMA for APP1 */
+	upmconfig(UPMA, (uint *) upma_table,
+		sizeof(upma_table) / sizeof(uint));
+	out_be32(mxmr, CONFIG_SYS_MAMR);
+#endif
 	return 0;
 }
 
@@ -185,12 +252,13 @@
 #endif
 
 	/* return total bus SDRAM size(bytes)  -- DDR */
-	return (msize * 1024 * 1024);
+	return msize * 1024 * 1024;
 }
 
 int checkboard(void)
 {
-	puts("Board: Keymile kmeter1");
+	puts("Board: Keymile " CONFIG_KM_BOARD_NAME);
+
 	if (ethernet_present())
 		puts(" with PIGGY.");
 	puts("\n");
@@ -198,19 +266,9 @@
 }
 
 #if defined(CONFIG_OF_BOARD_SETUP)
-/*
- * update property in the blob
- */
-void ft_blob_update(void *blob, bd_t *bd)
-{
-  /* no board specific update */
-}
-
-
 void ft_board_setup(void *blob, bd_t *bd)
 {
-	ft_cpu_setup (blob, bd);
-	ft_blob_update (blob, bd);
+	ft_cpu_setup(blob, bd);
 }
 #endif