All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v1 0/25] Add Marvell Armada XP MV78460 SoC support
@ 2014-06-27  9:54 Stefan Roese
  2014-06-27  9:54 ` [U-Boot] [PATCH v1 01/25] sf: Add M25PX64 SPI NOR flash ID Stefan Roese
                   ` (25 more replies)
  0 siblings, 26 replies; 50+ messages in thread
From: Stefan Roese @ 2014-06-27  9:54 UTC (permalink / raw)
  To: u-boot


This patch series adds support for the Marvell Armada XP SoC's. Specifically
the MV78460.

Basic support for the db-78460-bp evaluation board is added. Supporting the
following interfaces:
- UART
- SPI (including SPI NOR flash)
- I2C
- Ethernet (neta)

While doing this port, I tried to consolidate common Marvell code into
the arch/arm/mvebu-common directory. This directory should be used to
collect more common code for the MVEBU SoC's (Dove, Kirkwood, Armada 370,
Armada 380, Armada XP). I started with Kirkwood and some of its
interfaces. Dove is definitely a candidate to move some of its code
into thise directory as well.

Because of the renaming of some functions from kirkwood to mvebu (to make
them better usable on other MVEBU SoCs), this patch series not only
touches the ARM SoC specific files (in arch/arm/...). But also some
device drivers (e.g. SPI, I2C). Separating these driver specific patches
into different patches that are not depending on this ARM patch series
seems hard if not impossible. Thats why I would really like to get this
patch series to get  applied completely be one custodian. Not sure if
this could / should go through Tom directly? Only if all the subsystem
custodians have given their "Acked-by ..." of course.

Testing on Kirkwood based boards would be greatly appreciated. So anyone with
access to some of those board, please give this patch series a try. I really
hope that I didn't break anything while merging some of the code into the
common mvebu directory.

Please note that this Armada XP port still requires the "Binary Header"
(bin_hdr) from the Marvell U-Boot tree to be included as a binary blob
into the resulting image (u-boot.kwb) that can be booted by the MVEBU
BootROM. This binary bin_hdr is usually responsible for the DDR3
controller configuration and the DDR3 training. One way to extract this
bin_hdr binary from an existing Marvell boot image right now is to use
the "kwbimage" tool from Barebox. Please refer to the documentation
thats available there for more details.

Thanks,
Stefan


Stefan Roese (25):
  sf: Add M25PX64 SPI NOR flash ID
  arm: kirkwood: spi.h: Add some missing parenthesis
  spi: kirkwood_spi.c: Some fixes and cleanup
  spi: kirkwood_spi.c: Make global variable static
  spi: kirkwood_spi.c: cosmetic: Fix minor coding style issues
  arm: kirkwood: Move some SoC files into new arch/arm/mvebu-common
  arm: marvell: Move arch/kirkwood.h to arch/soc.h
  arm: marvell: Move arch-kirkwood/spi.h to arch-mvebu/spi.h
  arm: marvell: Rework timer.c to make it usable for other MVEBU
    platforms
  arm: mvebu: Add common mbus functions to use on Marvell SoCs
  spi: kirkwood_spi.c: Compile MPP (pin-mux) only for kirkwood SoC's
  arm: marvell: Extract kirkwood gpio functions into new common file
    gpio.c
  spi: kirkwood_spi.c: Change KW_SPI_BASE to MVEBU_SPI_BASE
  arm: kirkwood: Change naming of dram functions from km_foo() to
    mvebu_foo()
  net: mvneta.c: Add support for the ethernet controller of the Marvell
    Armada XP SoC
  net: phy.h: Make PHY autonegotiation timeout configurable
  i2c: mvtwsi: Add support for Marvell Armada XP
  arm: armada-xp: Add basic support for Marvell Armada XP SoC
  arm: armada-xp: Add basic support for the Marvell DB-78460-BP board
  arm: kirkwood: Remove some dead code from cpu.c
  arm: kirkwood: Use mvebu new common mbus API
  tools/kwboot: Sync with latest barebox version to support Armada XP
  tools: Compile kwboot for Marvell Armada XP as those SoCs are now
    supported
  tools: kwbimage: Add image version 1 support for Armada XP / 370
  Makefile: Add CONFIG_BUILD_TARGET to automatically build an special
    image

 Makefile                                           |    9 +
 README                                             |    8 +
 arch/arm/cpu/arm926ejs/kirkwood/Makefile           |    4 +-
 arch/arm/cpu/arm926ejs/kirkwood/cpu.c              |  174 +--
 arch/arm/cpu/arm926ejs/kirkwood/mpp.c              |    2 +-
 arch/arm/cpu/armv7/armada-xp/Makefile              |    7 +
 arch/arm/cpu/armv7/armada-xp/cpu.c                 |  186 +++
 arch/arm/include/asm/arch-armada-xp/config.h       |   80 +
 arch/arm/include/asm/arch-armada-xp/cpu.h          |  103 ++
 arch/arm/include/asm/arch-armada-xp/soc.h          |   57 +
 arch/arm/include/asm/arch-kirkwood/config.h        |    2 +-
 arch/arm/include/asm/arch-kirkwood/cpu.h           |   71 +-
 arch/arm/include/asm/arch-kirkwood/gpio.h          |   16 +-
 .../asm/arch-kirkwood/{kirkwood.h => soc.h}        |   25 +-
 .../asm/{arch-kirkwood => arch-mvebu}/spi.h        |    8 +-
 arch/arm/mvebu-common/Makefile                     |   12 +
 .../arm926ejs/kirkwood => mvebu-common}/dram.c     |   63 +-
 arch/arm/mvebu-common/gpio.c                       |   30 +
 arch/arm/mvebu-common/mbus.c                       |  477 ++++++
 .../arm926ejs/kirkwood => mvebu-common}/timer.c    |   92 +-
 board/LaCie/net2big_v2/net2big_v2.c                |    8 +-
 board/LaCie/netspace_v2/netspace_v2.c              |    8 +-
 board/LaCie/wireless_space/wireless_space.c        |    8 +-
 board/Marvell/db-78460-bp/Makefile                 |    7 +
 board/Marvell/db-78460-bp/db-78460-bp.c            |  120 ++
 board/Marvell/db-78460-bp/kwbimage.cfg             |   12 +
 board/Marvell/dreamplug/dreamplug.c                |   10 +-
 board/Marvell/guruplug/guruplug.c                  |   10 +-
 board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c    |   10 +-
 board/Marvell/openrd/openrd.c                      |   10 +-
 board/Marvell/rd6281a/rd6281a.c                    |   10 +-
 board/Marvell/sheevaplug/sheevaplug.c              |   10 +-
 board/Seagate/dockstar/dockstar.c                  |   12 +-
 board/Seagate/goflexhome/goflexhome.c              |   12 +-
 board/buffalo/lsxl/lsxl.c                          |   10 +-
 board/cloudengines/pogo_e02/pogo_e02.c             |   10 +-
 board/d-link/dns325/dns325.c                       |    8 +-
 board/iomega/iconnect/iconnect.c                   |   10 +-
 board/karo/tk71/tk71.c                             |   10 +-
 board/keymile/km_arm/km_arm.c                      |   10 +-
 board/raidsonic/ib62x0/ib62x0.c                    |   10 +-
 boards.cfg                                         |    1 +
 drivers/block/mvsata_ide.c                         |    2 +-
 drivers/gpio/kw_gpio.c                             |    2 +-
 drivers/i2c/mvtwsi.c                               |    4 +-
 drivers/mtd/nand/kirkwood_nand.c                   |    2 +-
 drivers/mtd/spi/sf_params.c                        |    1 +
 drivers/net/Makefile                               |    1 +
 drivers/net/mvgbe.c                                |    2 +-
 drivers/net/mvneta.c                               | 1653 ++++++++++++++++++++
 drivers/rtc/mvrtc.h                                |    2 +-
 drivers/spi/kirkwood_spi.c                         |   44 +-
 drivers/usb/host/ehci-marvell.c                    |   45 +-
 include/configs/db-78460-bp.h                      |   67 +
 include/linux/mbus.h                               |   61 +
 include/netdev.h                                   |    1 +
 include/phy.h                                      |    2 +
 tools/Makefile                                     |    1 +
 tools/kwbimage.c                                   | 1050 +++++++++----
 tools/kwboot.c                                     |   97 +-
 60 files changed, 4056 insertions(+), 723 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/armada-xp/Makefile
 create mode 100644 arch/arm/cpu/armv7/armada-xp/cpu.c
 create mode 100644 arch/arm/include/asm/arch-armada-xp/config.h
 create mode 100644 arch/arm/include/asm/arch-armada-xp/cpu.h
 create mode 100644 arch/arm/include/asm/arch-armada-xp/soc.h
 rename arch/arm/include/asm/arch-kirkwood/{kirkwood.h => soc.h} (74%)
 rename arch/arm/include/asm/{arch-kirkwood => arch-mvebu}/spi.h (90%)
 create mode 100644 arch/arm/mvebu-common/Makefile
 rename arch/arm/{cpu/arm926ejs/kirkwood => mvebu-common}/dram.c (57%)
 create mode 100644 arch/arm/mvebu-common/gpio.c
 create mode 100644 arch/arm/mvebu-common/mbus.c
 rename arch/arm/{cpu/arm926ejs/kirkwood => mvebu-common}/timer.c (63%)
 create mode 100644 board/Marvell/db-78460-bp/Makefile
 create mode 100644 board/Marvell/db-78460-bp/db-78460-bp.c
 create mode 100644 board/Marvell/db-78460-bp/kwbimage.cfg
 create mode 100644 drivers/net/mvneta.c
 create mode 100644 include/configs/db-78460-bp.h
 create mode 100644 include/linux/mbus.h

-- 
2.0.1

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 01/25] sf: Add M25PX64 SPI NOR flash ID
  2014-06-27  9:54 [U-Boot] [PATCH v1 0/25] Add Marvell Armada XP MV78460 SoC support Stefan Roese
@ 2014-06-27  9:54 ` Stefan Roese
  2014-07-03 20:14   ` Jagan Teki
  2014-06-27  9:54 ` [U-Boot] [PATCH v1 02/25] arm: kirkwood: spi.h: Add some missing parenthesis Stefan Roese
                   ` (24 subsequent siblings)
  25 siblings, 1 reply; 50+ messages in thread
From: Stefan Roese @ 2014-06-27  9:54 UTC (permalink / raw)
  To: u-boot

Add ID for this Numonix / STMicro chip.

Tested on Marvell DB-78460-BP board.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
---

 drivers/mtd/spi/sf_params.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mtd/spi/sf_params.c b/drivers/mtd/spi/sf_params.c
index ac886fd..b8186e9 100644
--- a/drivers/mtd/spi/sf_params.c
+++ b/drivers/mtd/spi/sf_params.c
@@ -71,6 +71,7 @@ const struct spi_flash_params spi_flash_params_table[] = {
 	{"M25P32",	   0x202016, 0x0,       64 * 1024,    64,	0,			  0},
 	{"M25P64",	   0x202017, 0x0,       64 * 1024,   128,	0,			  0},
 	{"M25P128",	   0x202018, 0x0,      256 * 1024,    64,	0,			  0},
+	{"M25PX64",	   0x207117, 0x0,       64 * 1024,   128,	0,		    SECT_4K},
 	{"N25Q32",	   0x20ba16, 0x0,       64 * 1024,    64, RD_FULL,	   WR_QPP | SECT_4K},
 	{"N25Q32A",	   0x20bb16, 0x0,       64 * 1024,    64, RD_FULL,	   WR_QPP | SECT_4K},
 	{"N25Q64",	   0x20ba17, 0x0,       64 * 1024,   128, RD_FULL,	   WR_QPP | SECT_4K},
-- 
2.0.1

^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 02/25] arm: kirkwood: spi.h: Add some missing parenthesis
  2014-06-27  9:54 [U-Boot] [PATCH v1 0/25] Add Marvell Armada XP MV78460 SoC support Stefan Roese
  2014-06-27  9:54 ` [U-Boot] [PATCH v1 01/25] sf: Add M25PX64 SPI NOR flash ID Stefan Roese
@ 2014-06-27  9:54 ` Stefan Roese
  2014-07-03 20:15   ` Jagan Teki
  2014-06-27  9:54 ` [U-Boot] [PATCH v1 03/25] spi: kirkwood_spi.c: Some fixes and cleanup Stefan Roese
                   ` (23 subsequent siblings)
  25 siblings, 1 reply; 50+ messages in thread
From: Stefan Roese @ 2014-06-27  9:54 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
---

 arch/arm/include/asm/arch-kirkwood/spi.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm/include/asm/arch-kirkwood/spi.h b/arch/arm/include/asm/arch-kirkwood/spi.h
index b1cf614..e512dce 100644
--- a/arch/arm/include/asm/arch-kirkwood/spi.h
+++ b/arch/arm/include/asm/arch-kirkwood/spi.h
@@ -43,10 +43,10 @@ struct kwspi_registers {
 #define KWSPI_XFERLEN_2BYTE	(1 << 5)
 #define KWSPI_XFERLEN_MASK	(1 << 5)
 #define KWSPI_ADRLEN_1BYTE	0
-#define KWSPI_ADRLEN_2BYTE	1 << 8
-#define KWSPI_ADRLEN_3BYTE	2 << 8
-#define KWSPI_ADRLEN_4BYTE	3 << 8
-#define KWSPI_ADRLEN_MASK	3 << 8
+#define KWSPI_ADRLEN_2BYTE	(1 << 8)
+#define KWSPI_ADRLEN_3BYTE	(2 << 8)
+#define KWSPI_ADRLEN_4BYTE	(3 << 8)
+#define KWSPI_ADRLEN_MASK	(3 << 8)
 #define KWSPI_TIMEOUT		10000
 
 #endif /* __KW_SPI_H__ */
-- 
2.0.1

^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 03/25] spi: kirkwood_spi.c: Some fixes and cleanup
  2014-06-27  9:54 [U-Boot] [PATCH v1 0/25] Add Marvell Armada XP MV78460 SoC support Stefan Roese
  2014-06-27  9:54 ` [U-Boot] [PATCH v1 01/25] sf: Add M25PX64 SPI NOR flash ID Stefan Roese
  2014-06-27  9:54 ` [U-Boot] [PATCH v1 02/25] arm: kirkwood: spi.h: Add some missing parenthesis Stefan Roese
@ 2014-06-27  9:54 ` Stefan Roese
  2014-07-03 20:16   ` Jagan Teki
  2014-06-27  9:54 ` [U-Boot] [PATCH v1 04/25] spi: kirkwood_spi.c: Make global variable static Stefan Roese
                   ` (22 subsequent siblings)
  25 siblings, 1 reply; 50+ messages in thread
From: Stefan Roese @ 2014-06-27  9:54 UTC (permalink / raw)
  To: u-boot

This patch introduces the clrsetbits_le32() accessor functions in the
kirkwood SPI driver. Note that it also includes a fix:

-	 writel(~KWSPI_CSN_ACT | KWSPI_SMEMRDY, &spireg->ctrl);
+	 writel(KWSPI_SMEMRDY, &spireg->ctrl);

Here the bit KWSPI_CSN_ACT (0x1) should have been cleared. Instead
0xfffffffe is written into this control register. This is the main
reason to use the clrsetbits() functions now. As they make clearing
bits much less error prone.

Additionally KWSPI_IRQUNMASK is not used in spi_cs_activate() and
spi_cs_deactivate() any more. Its the wrong macro but has the same
value as the correct one (KWSPI_CSN_ACT).

This is in preparation for use of this driver on the Marvell Armada XP
platform as well.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
---

 drivers/spi/kirkwood_spi.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/spi/kirkwood_spi.c b/drivers/spi/kirkwood_spi.c
index 942a208..449e9f8 100644
--- a/drivers/spi/kirkwood_spi.c
+++ b/drivers/spi/kirkwood_spi.c
@@ -37,7 +37,7 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
 	if (!slave)
 		return NULL;
 
-	writel(~KWSPI_CSN_ACT | KWSPI_SMEMRDY, &spireg->ctrl);
+	writel(KWSPI_SMEMRDY, &spireg->ctrl);
 
 	/* calculate spi clock prescaller using max_hz */
 	data = ((CONFIG_SYS_TCLK / 2) / max_hz) + 0x10;
@@ -137,12 +137,12 @@ void spi_init(void)
 
 void spi_cs_activate(struct spi_slave *slave)
 {
-	writel(readl(&spireg->ctrl) | KWSPI_IRQUNMASK, &spireg->ctrl);
+	setbits_le32(&spireg->ctrl, KWSPI_CSN_ACT);
 }
 
 void spi_cs_deactivate(struct spi_slave *slave)
 {
-	writel(readl(&spireg->ctrl) & KWSPI_IRQMASK, &spireg->ctrl);
+	clrbits_le32(&spireg->ctrl, KWSPI_CSN_ACT);
 }
 
 int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
@@ -161,8 +161,7 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
 	 * handle data in 8-bit chunks
 	 * TBD: 2byte xfer mode to be enabled
 	 */
-	writel(((readl(&spireg->cfg) & ~KWSPI_XFERLEN_MASK) |
-		KWSPI_XFERLEN_1BYTE), &spireg->cfg);
+	clrsetbits_le32(&spireg->cfg, KWSPI_XFERLEN_MASK, KWSPI_XFERLEN_1BYTE);
 
 	while (bitlen > 4) {
 		debug("loopstart bitlen %d\n", bitlen);
@@ -172,7 +171,7 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
 		if (dout)
 			tmpdout = *(u32 *) dout & 0x0ff;
 
-		writel(~KWSPI_SMEMRDIRQ, &spireg->irq_cause);
+		clrbits_le32(&spireg->irq_cause, KWSPI_SMEMRDIRQ);
 		writel(tmpdout, &spireg->dout);	/* Write the data out */
 		debug("*** spi_xfer: ... %08x written, bitlen %d\n",
 		      tmpdout, bitlen);
-- 
2.0.1

^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 04/25] spi: kirkwood_spi.c: Make global variable static
  2014-06-27  9:54 [U-Boot] [PATCH v1 0/25] Add Marvell Armada XP MV78460 SoC support Stefan Roese
                   ` (2 preceding siblings ...)
  2014-06-27  9:54 ` [U-Boot] [PATCH v1 03/25] spi: kirkwood_spi.c: Some fixes and cleanup Stefan Roese
@ 2014-06-27  9:54 ` Stefan Roese
  2014-07-03 20:18   ` Jagan Teki
  2014-06-27  9:54 ` [U-Boot] [PATCH v1 05/25] spi: kirkwood_spi.c: cosmetic: Fix minor coding style issues Stefan Roese
                   ` (21 subsequent siblings)
  25 siblings, 1 reply; 50+ messages in thread
From: Stefan Roese @ 2014-06-27  9:54 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
---

 drivers/spi/kirkwood_spi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/kirkwood_spi.c b/drivers/spi/kirkwood_spi.c
index 449e9f8..7d1c1f9 100644
--- a/drivers/spi/kirkwood_spi.c
+++ b/drivers/spi/kirkwood_spi.c
@@ -18,7 +18,7 @@
 
 static struct kwspi_registers *spireg = (struct kwspi_registers *)KW_SPI_BASE;
 
-u32 cs_spi_mpp_back[2];
+static u32 cs_spi_mpp_back[2];
 
 struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
 				unsigned int max_hz, unsigned int mode)
-- 
2.0.1

^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 05/25] spi: kirkwood_spi.c: cosmetic: Fix minor coding style issues
  2014-06-27  9:54 [U-Boot] [PATCH v1 0/25] Add Marvell Armada XP MV78460 SoC support Stefan Roese
                   ` (3 preceding siblings ...)
  2014-06-27  9:54 ` [U-Boot] [PATCH v1 04/25] spi: kirkwood_spi.c: Make global variable static Stefan Roese
@ 2014-06-27  9:54 ` Stefan Roese
  2014-07-03 20:18   ` Jagan Teki
  2014-06-27  9:54 ` [U-Boot] [PATCH v1 06/25] arm: kirkwood: Move some SoC files into new arch/arm/mvebu-common Stefan Roese
                   ` (20 subsequent siblings)
  25 siblings, 1 reply; 50+ messages in thread
From: Stefan Roese @ 2014-06-27  9:54 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
---

 drivers/spi/kirkwood_spi.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/spi/kirkwood_spi.c b/drivers/spi/kirkwood_spi.c
index 7d1c1f9..3d58bcc 100644
--- a/drivers/spi/kirkwood_spi.c
+++ b/drivers/spi/kirkwood_spi.c
@@ -46,7 +46,7 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
 
 	/* program spi clock prescaller using max_hz */
 	writel(KWSPI_ADRLEN_3BYTE | data, &spireg->cfg);
-	debug("data = 0x%08x \n", data);
+	debug("data = 0x%08x\n", data);
 
 	writel(KWSPI_SMEMRDIRQ, &spireg->irq_cause);
 	writel(KWSPI_IRQMASK, &spireg->irq_mask);
@@ -100,7 +100,6 @@ int spi_claim_bus(struct spi_slave *slave)
 
 	/* set new spi mpp and save current mpp config */
 	kirkwood_mpp_conf(spi_mpp_config, spi_mpp_backup);
-
 #endif
 
 	return board_spi_claim_bus(slave);
@@ -127,7 +126,7 @@ void spi_release_bus(struct spi_slave *slave)
  */
 int spi_cs_is_valid(unsigned int bus, unsigned int cs)
 {
-	return (bus == 0 && (cs == 0 || cs == 1));
+	return bus == 0 && (cs == 0 || cs == 1);
 }
 #endif
 
@@ -169,7 +168,7 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
 
 		/* Shift data so it's msb-justified */
 		if (dout)
-			tmpdout = *(u32 *) dout & 0x0ff;
+			tmpdout = *(u32 *)dout & 0xff;
 
 		clrbits_le32(&spireg->irq_cause, KWSPI_SMEMRDIRQ);
 		writel(tmpdout, &spireg->dout);	/* Write the data out */
@@ -185,12 +184,11 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
 			if (readl(&spireg->irq_cause) & KWSPI_SMEMRDIRQ) {
 				isread = 1;
 				tmpdin = readl(&spireg->din);
-				debug
-					("spi_xfer: din %p..%08x read\n",
-					din, tmpdin);
+				debug("spi_xfer: din %p..%08x read\n",
+				      din, tmpdin);
 
 				if (din) {
-					*((u8 *) din) = (u8) tmpdin;
+					*((u8 *)din) = (u8)tmpdin;
 					din += 1;
 				}
 				if (dout)
-- 
2.0.1

^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 06/25] arm: kirkwood: Move some SoC files into new arch/arm/mvebu-common
  2014-06-27  9:54 [U-Boot] [PATCH v1 0/25] Add Marvell Armada XP MV78460 SoC support Stefan Roese
                   ` (4 preceding siblings ...)
  2014-06-27  9:54 ` [U-Boot] [PATCH v1 05/25] spi: kirkwood_spi.c: cosmetic: Fix minor coding style issues Stefan Roese
@ 2014-06-27  9:54 ` Stefan Roese
  2014-06-27  9:54 ` [U-Boot] [PATCH v1 07/25] arm: marvell: Move arch/kirkwood.h to arch/soc.h Stefan Roese
                   ` (19 subsequent siblings)
  25 siblings, 0 replies; 50+ messages in thread
From: Stefan Roese @ 2014-06-27  9:54 UTC (permalink / raw)
  To: u-boot

By moving some kirkwood files into a Marvell common directory, those files
can be used by other Marvell platforms as well. The name mvebu is taken
from the Linux kernel source tree. It has been chosen there to represent
the SoC's from the Marvell EBU (Engineering Business Unit). Those SoC's
currently are:

Armada 370/375/XP, Dove, mv78xx0, Kirkwood, Orion5x

This will be used by the upcoming Armada XP (MV78460) platform support.

Signed-off-by: Stefan Roese <sr@denx.de>
---

 Makefile                                                  |  4 ++++
 arch/arm/cpu/arm926ejs/kirkwood/Makefile                  |  4 +---
 arch/arm/mvebu-common/Makefile                            | 10 ++++++++++
 arch/arm/{cpu/arm926ejs/kirkwood => mvebu-common}/dram.c  |  8 +++++++-
 arch/arm/{cpu/arm926ejs/kirkwood => mvebu-common}/timer.c |  0
 5 files changed, 22 insertions(+), 4 deletions(-)
 create mode 100644 arch/arm/mvebu-common/Makefile
 rename arch/arm/{cpu/arm926ejs/kirkwood => mvebu-common}/dram.c (91%)
 rename arch/arm/{cpu/arm926ejs/kirkwood => mvebu-common}/timer.c (100%)

diff --git a/Makefile b/Makefile
index e429212..106840a 100644
--- a/Makefile
+++ b/Makefile
@@ -636,6 +636,10 @@ ifneq (,$(filter $(SOC), mx25 mx27 mx5 mx6 mx31 mx35 mxs vf610))
 libs-y += arch/$(ARCH)/imx-common/
 endif
 
+ifneq (,$(filter $(SOC), kirkwood))
+libs-y += arch/$(ARCH)/mvebu-common/
+endif
+
 libs-$(CONFIG_ARM) += arch/arm/cpu/
 libs-$(CONFIG_PPC) += arch/powerpc/cpu/
 
diff --git a/arch/arm/cpu/arm926ejs/kirkwood/Makefile b/arch/arm/cpu/arm926ejs/kirkwood/Makefile
index c230ce8..df4756e 100644
--- a/arch/arm/cpu/arm926ejs/kirkwood/Makefile
+++ b/arch/arm/cpu/arm926ejs/kirkwood/Makefile
@@ -7,7 +7,5 @@
 #
 
 obj-y	= cpu.o
-obj-y	+= dram.o
-obj-y	+= mpp.o
-obj-y	+= timer.o
 obj-y	+= cache.o
+obj-y	+= mpp.o
diff --git a/arch/arm/mvebu-common/Makefile b/arch/arm/mvebu-common/Makefile
new file mode 100644
index 0000000..4d20d2c
--- /dev/null
+++ b/arch/arm/mvebu-common/Makefile
@@ -0,0 +1,10 @@
+#
+# (C) Copyright 2009
+# Marvell Semiconductor <www.marvell.com>
+# Written-by: Prafulla Wadaskar <prafulla@marvell.com>
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+obj-y	= dram.o
+obj-y	+= timer.o
diff --git a/arch/arm/cpu/arm926ejs/kirkwood/dram.c b/arch/arm/mvebu-common/dram.c
similarity index 91%
rename from arch/arm/cpu/arm926ejs/kirkwood/dram.c
rename to arch/arm/mvebu-common/dram.c
index d73ae47..bb5989b 100644
--- a/arch/arm/cpu/arm926ejs/kirkwood/dram.c
+++ b/arch/arm/mvebu-common/dram.c
@@ -110,7 +110,13 @@ int dram_init(void)
 		if (gd->bd->bi_dram[i].start != gd->ram_size)
 			break;
 
-		gd->ram_size += gd->bd->bi_dram[i].size;
+		/*
+		 * Don't report more than 3GiB of SDRAM, otherwise there is no
+		 * address space left for the internal registers etc.
+		 */
+		if ((gd->ram_size + gd->bd->bi_dram[i].size != 0) &&
+		    (gd->ram_size + gd->bd->bi_dram[i].size <= (3 << 30)))
+			gd->ram_size += gd->bd->bi_dram[i].size;
 
 	}
 
diff --git a/arch/arm/cpu/arm926ejs/kirkwood/timer.c b/arch/arm/mvebu-common/timer.c
similarity index 100%
rename from arch/arm/cpu/arm926ejs/kirkwood/timer.c
rename to arch/arm/mvebu-common/timer.c
-- 
2.0.1

^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 07/25] arm: marvell: Move arch/kirkwood.h to arch/soc.h
  2014-06-27  9:54 [U-Boot] [PATCH v1 0/25] Add Marvell Armada XP MV78460 SoC support Stefan Roese
                   ` (5 preceding siblings ...)
  2014-06-27  9:54 ` [U-Boot] [PATCH v1 06/25] arm: kirkwood: Move some SoC files into new arch/arm/mvebu-common Stefan Roese
@ 2014-06-27  9:54 ` Stefan Roese
  2014-06-27  9:54 ` [U-Boot] [PATCH v1 08/25] arm: marvell: Move arch-kirkwood/spi.h to arch-mvebu/spi.h Stefan Roese
                   ` (18 subsequent siblings)
  25 siblings, 0 replies; 50+ messages in thread
From: Stefan Roese @ 2014-06-27  9:54 UTC (permalink / raw)
  To: u-boot

This move makes is possible to use this header not only from kirkwood
platforms but from all Marvell mvebu platforms.

Signed-off-by: Stefan Roese <sr@denx.de>
---

 arch/arm/cpu/arm926ejs/kirkwood/cpu.c                    | 2 +-
 arch/arm/cpu/arm926ejs/kirkwood/mpp.c                    | 2 +-
 arch/arm/include/asm/arch-kirkwood/config.h              | 2 +-
 arch/arm/include/asm/arch-kirkwood/{kirkwood.h => soc.h} | 0
 arch/arm/mvebu-common/dram.c                             | 2 +-
 arch/arm/mvebu-common/timer.c                            | 2 +-
 board/LaCie/net2big_v2/net2big_v2.c                      | 2 +-
 board/LaCie/netspace_v2/netspace_v2.c                    | 2 +-
 board/LaCie/wireless_space/wireless_space.c              | 2 +-
 board/Marvell/dreamplug/dreamplug.c                      | 2 +-
 board/Marvell/guruplug/guruplug.c                        | 2 +-
 board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c          | 2 +-
 board/Marvell/openrd/openrd.c                            | 2 +-
 board/Marvell/rd6281a/rd6281a.c                          | 2 +-
 board/Marvell/sheevaplug/sheevaplug.c                    | 2 +-
 board/Seagate/dockstar/dockstar.c                        | 2 +-
 board/Seagate/goflexhome/goflexhome.c                    | 2 +-
 board/buffalo/lsxl/lsxl.c                                | 2 +-
 board/cloudengines/pogo_e02/pogo_e02.c                   | 2 +-
 board/d-link/dns325/dns325.c                             | 2 +-
 board/iomega/iconnect/iconnect.c                         | 2 +-
 board/karo/tk71/tk71.c                                   | 2 +-
 board/keymile/km_arm/km_arm.c                            | 2 +-
 board/raidsonic/ib62x0/ib62x0.c                          | 2 +-
 drivers/block/mvsata_ide.c                               | 2 +-
 drivers/gpio/kw_gpio.c                                   | 2 +-
 drivers/i2c/mvtwsi.c                                     | 2 +-
 drivers/mtd/nand/kirkwood_nand.c                         | 2 +-
 drivers/net/mvgbe.c                                      | 2 +-
 drivers/rtc/mvrtc.h                                      | 2 +-
 drivers/spi/kirkwood_spi.c                               | 2 +-
 drivers/usb/host/ehci-marvell.c                          | 2 +-
 32 files changed, 31 insertions(+), 31 deletions(-)
 rename arch/arm/include/asm/arch-kirkwood/{kirkwood.h => soc.h} (100%)

diff --git a/arch/arm/cpu/arm926ejs/kirkwood/cpu.c b/arch/arm/cpu/arm926ejs/kirkwood/cpu.c
index da80240..c8f90ba 100644
--- a/arch/arm/cpu/arm926ejs/kirkwood/cpu.c
+++ b/arch/arm/cpu/arm926ejs/kirkwood/cpu.c
@@ -12,7 +12,7 @@
 #include <u-boot/md5.h>
 #include <asm/io.h>
 #include <asm/arch/cpu.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 
 #define BUFLEN	16
 
diff --git a/arch/arm/cpu/arm926ejs/kirkwood/mpp.c b/arch/arm/cpu/arm926ejs/kirkwood/mpp.c
index 0ba6f09..7222504 100644
--- a/arch/arm/cpu/arm926ejs/kirkwood/mpp.c
+++ b/arch/arm/cpu/arm926ejs/kirkwood/mpp.c
@@ -12,7 +12,7 @@
 #include <common.h>
 #include <asm/io.h>
 #include <asm/arch/cpu.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <asm/arch/mpp.h>
 
 static u32 kirkwood_variant(void)
diff --git a/arch/arm/include/asm/arch-kirkwood/config.h b/arch/arm/include/asm/arch-kirkwood/config.h
index 7a688e4..01bbfc4 100644
--- a/arch/arm/include/asm/arch-kirkwood/config.h
+++ b/arch/arm/include/asm/arch-kirkwood/config.h
@@ -23,7 +23,7 @@
 #error "SOC Name not defined"
 #endif /* CONFIG_KW88F6281 */
 
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #define CONFIG_ARM926EJS	1	/* Basic Architecture */
 #define CONFIG_SYS_CACHELINE_SIZE	32
 				/* default Dcache Line length for kirkwood */
diff --git a/arch/arm/include/asm/arch-kirkwood/kirkwood.h b/arch/arm/include/asm/arch-kirkwood/soc.h
similarity index 100%
rename from arch/arm/include/asm/arch-kirkwood/kirkwood.h
rename to arch/arm/include/asm/arch-kirkwood/soc.h
diff --git a/arch/arm/mvebu-common/dram.c b/arch/arm/mvebu-common/dram.c
index bb5989b..e468136 100644
--- a/arch/arm/mvebu-common/dram.c
+++ b/arch/arm/mvebu-common/dram.c
@@ -10,7 +10,7 @@
 #include <common.h>
 #include <asm/io.h>
 #include <asm/arch/cpu.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
diff --git a/arch/arm/mvebu-common/timer.c b/arch/arm/mvebu-common/timer.c
index a08f4a1..b7aa645 100644
--- a/arch/arm/mvebu-common/timer.c
+++ b/arch/arm/mvebu-common/timer.c
@@ -7,7 +7,7 @@
 
 #include <common.h>
 #include <asm/io.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 
 #define UBOOT_CNTR	0	/* counter to use for uboot timer */
 
diff --git a/board/LaCie/net2big_v2/net2big_v2.c b/board/LaCie/net2big_v2/net2big_v2.c
index 4c3a9ba..471db77 100644
--- a/board/LaCie/net2big_v2/net2big_v2.c
+++ b/board/LaCie/net2big_v2/net2big_v2.c
@@ -13,7 +13,7 @@
 #include <command.h>
 #include <i2c.h>
 #include <asm/arch/cpu.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <asm/arch/mpp.h>
 #include <asm/arch/gpio.h>
 
diff --git a/board/LaCie/netspace_v2/netspace_v2.c b/board/LaCie/netspace_v2/netspace_v2.c
index 3773587..6a16e7b 100644
--- a/board/LaCie/netspace_v2/netspace_v2.c
+++ b/board/LaCie/netspace_v2/netspace_v2.c
@@ -12,7 +12,7 @@
 #include <common.h>
 #include <command.h>
 #include <asm/arch/cpu.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <asm/arch/mpp.h>
 #include <asm/arch/gpio.h>
 
diff --git a/board/LaCie/wireless_space/wireless_space.c b/board/LaCie/wireless_space/wireless_space.c
index 2dc5018..53f5d2f 100644
--- a/board/LaCie/wireless_space/wireless_space.c
+++ b/board/LaCie/wireless_space/wireless_space.c
@@ -12,7 +12,7 @@
 #include <common.h>
 #include <command.h>
 #include <asm/arch/cpu.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <asm/arch/mpp.h>
 #include <asm/arch/gpio.h>
 
diff --git a/board/Marvell/dreamplug/dreamplug.c b/board/Marvell/dreamplug/dreamplug.c
index b53c810..3c286be 100644
--- a/board/Marvell/dreamplug/dreamplug.c
+++ b/board/Marvell/dreamplug/dreamplug.c
@@ -12,7 +12,7 @@
 #include <common.h>
 #include <miiphy.h>
 #include <asm/arch/cpu.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <asm/arch/mpp.h>
 #include "dreamplug.h"
 
diff --git a/board/Marvell/guruplug/guruplug.c b/board/Marvell/guruplug/guruplug.c
index 72bccc8..a5b42b4 100644
--- a/board/Marvell/guruplug/guruplug.c
+++ b/board/Marvell/guruplug/guruplug.c
@@ -9,7 +9,7 @@
 #include <common.h>
 #include <miiphy.h>
 #include <asm/arch/cpu.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <asm/arch/mpp.h>
 #include "guruplug.h"
 
diff --git a/board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c b/board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c
index e1652c0..ee665c1 100644
--- a/board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c
+++ b/board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c
@@ -11,7 +11,7 @@
 #include <common.h>
 #include <netdev.h>
 #include <asm/arch/cpu.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <asm/arch/mpp.h>
 #include "mv88f6281gtw_ge.h"
 
diff --git a/board/Marvell/openrd/openrd.c b/board/Marvell/openrd/openrd.c
index a005a2f..78ebb64 100644
--- a/board/Marvell/openrd/openrd.c
+++ b/board/Marvell/openrd/openrd.c
@@ -14,7 +14,7 @@
 #include <common.h>
 #include <miiphy.h>
 #include <asm/arch/cpu.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <asm/arch/mpp.h>
 #include "openrd.h"
 
diff --git a/board/Marvell/rd6281a/rd6281a.c b/board/Marvell/rd6281a/rd6281a.c
index 33ef0c7..8248274 100644
--- a/board/Marvell/rd6281a/rd6281a.c
+++ b/board/Marvell/rd6281a/rd6281a.c
@@ -10,7 +10,7 @@
 #include <miiphy.h>
 #include <netdev.h>
 #include <asm/arch/cpu.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <asm/arch/mpp.h>
 #include "rd6281a.h"
 
diff --git a/board/Marvell/sheevaplug/sheevaplug.c b/board/Marvell/sheevaplug/sheevaplug.c
index 87e49f4..4f17e09 100644
--- a/board/Marvell/sheevaplug/sheevaplug.c
+++ b/board/Marvell/sheevaplug/sheevaplug.c
@@ -9,7 +9,7 @@
 #include <common.h>
 #include <miiphy.h>
 #include <asm/arch/cpu.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <asm/arch/mpp.h>
 #include "sheevaplug.h"
 
diff --git a/board/Seagate/dockstar/dockstar.c b/board/Seagate/dockstar/dockstar.c
index ff6a6a0..dc73dfa 100644
--- a/board/Seagate/dockstar/dockstar.c
+++ b/board/Seagate/dockstar/dockstar.c
@@ -11,7 +11,7 @@
 
 #include <common.h>
 #include <miiphy.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <asm/arch/mpp.h>
 #include <asm/arch/cpu.h>
 #include <asm/io.h>
diff --git a/board/Seagate/goflexhome/goflexhome.c b/board/Seagate/goflexhome/goflexhome.c
index a6598e9..3e4ae89 100644
--- a/board/Seagate/goflexhome/goflexhome.c
+++ b/board/Seagate/goflexhome/goflexhome.c
@@ -14,7 +14,7 @@
 
 #include <common.h>
 #include <miiphy.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <asm/arch/mpp.h>
 #include <asm/arch/cpu.h>
 #include <asm/io.h>
diff --git a/board/buffalo/lsxl/lsxl.c b/board/buffalo/lsxl/lsxl.c
index 659a124..26b8576 100644
--- a/board/buffalo/lsxl/lsxl.c
+++ b/board/buffalo/lsxl/lsxl.c
@@ -13,7 +13,7 @@
 #include <malloc.h>
 #include <netdev.h>
 #include <miiphy.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <asm/arch/cpu.h>
 #include <asm/arch/mpp.h>
 #include <asm/arch/gpio.h>
diff --git a/board/cloudengines/pogo_e02/pogo_e02.c b/board/cloudengines/pogo_e02/pogo_e02.c
index 0e63258..ddc3fa6 100644
--- a/board/cloudengines/pogo_e02/pogo_e02.c
+++ b/board/cloudengines/pogo_e02/pogo_e02.c
@@ -13,7 +13,7 @@
 #include <common.h>
 #include <miiphy.h>
 #include <asm/arch/cpu.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <asm/arch/mpp.h>
 #include "pogo_e02.h"
 
diff --git a/board/d-link/dns325/dns325.c b/board/d-link/dns325/dns325.c
index ff70e94..f2f43f5 100644
--- a/board/d-link/dns325/dns325.c
+++ b/board/d-link/dns325/dns325.c
@@ -14,7 +14,7 @@
 #include <miiphy.h>
 #include <netdev.h>
 #include <asm/arch/cpu.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <asm/arch/mpp.h>
 #include <asm/arch/gpio.h>
 #include "dns325.h"
diff --git a/board/iomega/iconnect/iconnect.c b/board/iomega/iconnect/iconnect.c
index c3443bd..f376d3d 100644
--- a/board/iomega/iconnect/iconnect.c
+++ b/board/iomega/iconnect/iconnect.c
@@ -9,7 +9,7 @@
 #include <common.h>
 #include <miiphy.h>
 #include <asm/arch/cpu.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <asm/arch/mpp.h>
 #include "iconnect.h"
 
diff --git a/board/karo/tk71/tk71.c b/board/karo/tk71/tk71.c
index ed0575c..e877aa3 100644
--- a/board/karo/tk71/tk71.c
+++ b/board/karo/tk71/tk71.c
@@ -8,7 +8,7 @@
 #include <common.h>
 #include <miiphy.h>
 #include <asm/arch/cpu.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <asm/arch/mpp.h>
 #include <asm/io.h>
 
diff --git a/board/keymile/km_arm/km_arm.c b/board/keymile/km_arm/km_arm.c
index 35402c8..cd508d2 100644
--- a/board/keymile/km_arm/km_arm.c
+++ b/board/keymile/km_arm/km_arm.c
@@ -20,7 +20,7 @@
 #include <spi.h>
 #include <asm/io.h>
 #include <asm/arch/cpu.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <asm/arch/mpp.h>
 
 #include "../common/common.h"
diff --git a/board/raidsonic/ib62x0/ib62x0.c b/board/raidsonic/ib62x0/ib62x0.c
index 976ba4c..47956b2 100644
--- a/board/raidsonic/ib62x0/ib62x0.c
+++ b/board/raidsonic/ib62x0/ib62x0.c
@@ -11,7 +11,7 @@
 #include <miiphy.h>
 #include <asm/io.h>
 #include <asm/arch/cpu.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <asm/arch/mpp.h>
 #include "ib62x0.h"
 
diff --git a/drivers/block/mvsata_ide.c b/drivers/block/mvsata_ide.c
index 574bc40..e54d564 100644
--- a/drivers/block/mvsata_ide.c
+++ b/drivers/block/mvsata_ide.c
@@ -12,7 +12,7 @@
 #if defined(CONFIG_ORION5X)
 #include <asm/arch/orion5x.h>
 #elif defined(CONFIG_KIRKWOOD)
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #endif
 
 /* SATA port registers */
diff --git a/drivers/gpio/kw_gpio.c b/drivers/gpio/kw_gpio.c
index 0af75a8..4fca089 100644
--- a/drivers/gpio/kw_gpio.c
+++ b/drivers/gpio/kw_gpio.c
@@ -16,7 +16,7 @@
 #include <common.h>
 #include <asm/bitops.h>
 #include <asm/io.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <asm/arch/gpio.h>
 
 static unsigned long gpio_valid_input[BITS_TO_LONGS(GPIO_MAX)];
diff --git a/drivers/i2c/mvtwsi.c b/drivers/i2c/mvtwsi.c
index 5ba0e03..4a49291 100644
--- a/drivers/i2c/mvtwsi.c
+++ b/drivers/i2c/mvtwsi.c
@@ -21,7 +21,7 @@
 #if defined(CONFIG_ORION5X)
 #include <asm/arch/orion5x.h>
 #elif defined(CONFIG_KIRKWOOD)
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #else
 #error Driver mvtwsi not supported by SoC or board
 #endif
diff --git a/drivers/mtd/nand/kirkwood_nand.c b/drivers/mtd/nand/kirkwood_nand.c
index 72687a1..ad32700 100644
--- a/drivers/mtd/nand/kirkwood_nand.c
+++ b/drivers/mtd/nand/kirkwood_nand.c
@@ -8,7 +8,7 @@
 
 #include <common.h>
 #include <asm/io.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <nand.h>
 
 /* NAND Flash Soc registers */
diff --git a/drivers/net/mvgbe.c b/drivers/net/mvgbe.c
index 0cd06b6..6ef6cac 100644
--- a/drivers/net/mvgbe.c
+++ b/drivers/net/mvgbe.c
@@ -24,7 +24,7 @@
 #include <asm/arch/cpu.h>
 
 #if defined(CONFIG_KIRKWOOD)
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #elif defined(CONFIG_ORION5X)
 #include <asm/arch/orion5x.h>
 #elif defined(CONFIG_DOVE)
diff --git a/drivers/rtc/mvrtc.h b/drivers/rtc/mvrtc.h
index ce7a69b..ebddc12 100644
--- a/drivers/rtc/mvrtc.h
+++ b/drivers/rtc/mvrtc.h
@@ -12,7 +12,7 @@
 #ifndef _MVRTC_H_
 #define _MVRTC_H_
 
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <compiler.h>
 
 /* RTC registers */
diff --git a/drivers/spi/kirkwood_spi.c b/drivers/spi/kirkwood_spi.c
index 3d58bcc..de0e914 100644
--- a/drivers/spi/kirkwood_spi.c
+++ b/drivers/spi/kirkwood_spi.c
@@ -12,7 +12,7 @@
 #include <malloc.h>
 #include <spi.h>
 #include <asm/io.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <asm/arch/spi.h>
 #include <asm/arch/mpp.h>
 
diff --git a/drivers/usb/host/ehci-marvell.c b/drivers/usb/host/ehci-marvell.c
index 52c43fd..1a5fd6e 100644
--- a/drivers/usb/host/ehci-marvell.c
+++ b/drivers/usb/host/ehci-marvell.c
@@ -13,7 +13,7 @@
 #include <asm/arch/cpu.h>
 
 #if defined(CONFIG_KIRKWOOD)
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #elif defined(CONFIG_ORION5X)
 #include <asm/arch/orion5x.h>
 #endif
-- 
2.0.1

^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 08/25] arm: marvell: Move arch-kirkwood/spi.h to arch-mvebu/spi.h
  2014-06-27  9:54 [U-Boot] [PATCH v1 0/25] Add Marvell Armada XP MV78460 SoC support Stefan Roese
                   ` (6 preceding siblings ...)
  2014-06-27  9:54 ` [U-Boot] [PATCH v1 07/25] arm: marvell: Move arch/kirkwood.h to arch/soc.h Stefan Roese
@ 2014-06-27  9:54 ` Stefan Roese
  2014-07-13 16:16   ` Jagan Teki
  2014-06-27  9:54 ` [U-Boot] [PATCH v1 09/25] arm: marvell: Rework timer.c to make it usable for other MVEBU platforms Stefan Roese
                   ` (17 subsequent siblings)
  25 siblings, 1 reply; 50+ messages in thread
From: Stefan Roese @ 2014-06-27  9:54 UTC (permalink / raw)
  To: u-boot

This move makes it possible to use this kirkwood SPI driver from other
MVEBU platforms as well. This will be used by the upcoming Armada XP
support.

Signed-off-by: Stefan Roese <sr@denx.de>
---

 arch/arm/include/asm/{arch-kirkwood => arch-mvebu}/spi.h | 0
 drivers/spi/kirkwood_spi.c                               | 2 +-
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename arch/arm/include/asm/{arch-kirkwood => arch-mvebu}/spi.h (100%)

diff --git a/arch/arm/include/asm/arch-kirkwood/spi.h b/arch/arm/include/asm/arch-mvebu/spi.h
similarity index 100%
rename from arch/arm/include/asm/arch-kirkwood/spi.h
rename to arch/arm/include/asm/arch-mvebu/spi.h
diff --git a/drivers/spi/kirkwood_spi.c b/drivers/spi/kirkwood_spi.c
index de0e914..9710f12 100644
--- a/drivers/spi/kirkwood_spi.c
+++ b/drivers/spi/kirkwood_spi.c
@@ -13,8 +13,8 @@
 #include <spi.h>
 #include <asm/io.h>
 #include <asm/arch/soc.h>
-#include <asm/arch/spi.h>
 #include <asm/arch/mpp.h>
+#include <asm/arch-mvebu/spi.h>
 
 static struct kwspi_registers *spireg = (struct kwspi_registers *)KW_SPI_BASE;
 
-- 
2.0.1

^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 09/25] arm: marvell: Rework timer.c to make it usable for other MVEBU platforms
  2014-06-27  9:54 [U-Boot] [PATCH v1 0/25] Add Marvell Armada XP MV78460 SoC support Stefan Roese
                   ` (7 preceding siblings ...)
  2014-06-27  9:54 ` [U-Boot] [PATCH v1 08/25] arm: marvell: Move arch-kirkwood/spi.h to arch-mvebu/spi.h Stefan Roese
@ 2014-06-27  9:54 ` Stefan Roese
  2014-06-27  9:54 ` [U-Boot] [PATCH v1 10/25] arm: mvebu: Add common mbus functions to use on Marvell SoCs Stefan Roese
                   ` (16 subsequent siblings)
  25 siblings, 0 replies; 50+ messages in thread
From: Stefan Roese @ 2014-06-27  9:54 UTC (permalink / raw)
  To: u-boot

This patch does the following:
- Rename defines and registers to not use kirkwood
- Remove unused defines
- Use clrsetbits() accessor functions
- Coding style cleanup
- Clear 25MHZ bit in timer controller register init for Armada XP

There is no functional change for kirkwood. At least not intentionally.

This will be used by the upcoming Armada XP support.

Signed-off-by: Stefan Roese <sr@denx.de>
---

 arch/arm/include/asm/arch-kirkwood/soc.h |  2 +-
 arch/arm/mvebu-common/timer.c            | 90 ++++++++++++++------------------
 2 files changed, 41 insertions(+), 51 deletions(-)

diff --git a/arch/arm/include/asm/arch-kirkwood/soc.h b/arch/arm/include/asm/arch-kirkwood/soc.h
index bc207f5..4261c35 100644
--- a/arch/arm/include/asm/arch-kirkwood/soc.h
+++ b/arch/arm/include/asm/arch-kirkwood/soc.h
@@ -33,7 +33,7 @@
 #define KW_SPI_BASE			(KW_REGISTER(0x10600))
 #define KW_CPU_WIN_BASE			(KW_REGISTER(0x20000))
 #define KW_CPU_REG_BASE			(KW_REGISTER(0x20100))
-#define KW_TIMER_BASE			(KW_REGISTER(0x20300))
+#define MVEBU_TIMER_BASE			(KW_REGISTER(0x20300))
 #define KW_REG_PCIE_BASE		(KW_REGISTER(0x40000))
 #define KW_USB20_BASE			(KW_REGISTER(0x50000))
 #define KW_EGIGA0_BASE			(KW_REGISTER(0x72000))
diff --git a/arch/arm/mvebu-common/timer.c b/arch/arm/mvebu-common/timer.c
index b7aa645..40c4bc2 100644
--- a/arch/arm/mvebu-common/timer.c
+++ b/arch/arm/mvebu-common/timer.c
@@ -9,73 +9,66 @@
 #include <asm/io.h>
 #include <asm/arch/soc.h>
 
-#define UBOOT_CNTR	0	/* counter to use for uboot timer */
-
-/* Timer reload and current value registers */
-struct kwtmr_val {
-	u32 reload;	/* Timer reload reg */
-	u32 val;	/* Timer value reg */
-};
-
-/* Timer registers */
-struct kwtmr_registers {
-	u32 ctrl;	/* Timer control reg */
-	u32 pad[3];
-	struct kwtmr_val tmr[2];
-	u32 wdt_reload;
-	u32 wdt_val;
-};
-
-struct kwtmr_registers *kwtmr_regs = (struct kwtmr_registers *)KW_TIMER_BASE;
+#define UBOOT_CNTR	0	/* counter to use for U-Boot timer */
 
 /*
  * ARM Timers Registers Map
  */
-#define CNTMR_CTRL_REG			&kwtmr_regs->ctrl
-#define CNTMR_RELOAD_REG(tmrnum)	&kwtmr_regs->tmr[tmrnum].reload
-#define CNTMR_VAL_REG(tmrnum)		&kwtmr_regs->tmr[tmrnum].val
+#define CNTMR_CTRL_REG			&tmr_regs->ctrl
+#define CNTMR_RELOAD_REG(tmrnum)	&tmr_regs->tmr[tmrnum].reload
+#define CNTMR_VAL_REG(tmrnum)		&tmr_regs->tmr[tmrnum].val
 
 /*
  * ARM Timers Control Register
  * CPU_TIMERS_CTRL_REG (CTCR)
  */
 #define CTCR_ARM_TIMER_EN_OFFS(cntr)	(cntr * 2)
-#define CTCR_ARM_TIMER_EN_MASK(cntr)	(1 << CTCR_ARM_TIMER_EN_OFFS)
 #define CTCR_ARM_TIMER_EN(cntr)		(1 << CTCR_ARM_TIMER_EN_OFFS(cntr))
-#define CTCR_ARM_TIMER_DIS(cntr)	(0 << CTCR_ARM_TIMER_EN_OFFS(cntr))
 
 #define CTCR_ARM_TIMER_AUTO_OFFS(cntr)	((cntr * 2) + 1)
-#define CTCR_ARM_TIMER_AUTO_MASK(cntr)	(1 << 1)
 #define CTCR_ARM_TIMER_AUTO_EN(cntr)	(1 << CTCR_ARM_TIMER_AUTO_OFFS(cntr))
-#define CTCR_ARM_TIMER_AUTO_DIS(cntr)	(0 << CTCR_ARM_TIMER_AUTO_OFFS(cntr))
 
-/*
- * ARM Timer\Watchdog Reload Register
- * CNTMR_RELOAD_REG (TRR)
- */
-#define TRG_ARM_TIMER_REL_OFFS		0
-#define TRG_ARM_TIMER_REL_MASK		0xffffffff
+/* Only Armada XP have the 25MHz enable bit (Kirkwood doesn't) */
+#if defined(CONFIG_ARMADA_XP)
+#define CTCR_ARM_TIMER_25MHZ_OFFS(cntr)	(cntr + 11)
+#define CTCR_ARM_TIMER_25MHZ(cntr)	(1 << CTCR_ARM_TIMER_25MHZ_OFFS(cntr))
+#else
+#define CTCR_ARM_TIMER_25MHZ(cntr)	0
+#endif
 
-/*
- * ARM Timer\Watchdog Register
- * CNTMR_VAL_REG (TVRG)
- */
-#define TVR_ARM_TIMER_OFFS		0
-#define TVR_ARM_TIMER_MASK		0xffffffff
-#define TVR_ARM_TIMER_MAX		0xffffffff
 #define TIMER_LOAD_VAL 			0xffffffff
 
-#define READ_TIMER			(readl(CNTMR_VAL_REG(UBOOT_CNTR)) /	\
-					 (CONFIG_SYS_TCLK / 1000))
+#define timestamp			gd->arch.tbl
+#define lastdec				gd->arch.lastinc
+
+/* Timer reload and current value registers */
+struct kwtmr_val {
+	u32 reload;	/* Timer reload reg */
+	u32 val;	/* Timer value reg */
+};
+
+/* Timer registers */
+struct kwtmr_registers {
+	u32 ctrl;	/* Timer control reg */
+	u32 pad[3];
+	struct kwtmr_val tmr[4];
+	u32 wdt_reload;
+	u32 wdt_val;
+};
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#define timestamp gd->arch.tbl
-#define lastdec gd->arch.lastinc
+static struct kwtmr_registers *tmr_regs =
+	(struct kwtmr_registers *)MVEBU_TIMER_BASE;
+
+static inline ulong read_timer(void)
+{
+	return readl(CNTMR_VAL_REG(UBOOT_CNTR))	/ (CONFIG_SYS_TCLK / 1000);
+}
 
 ulong get_timer_masked(void)
 {
-	ulong now = READ_TIMER;
+	ulong now = read_timer();
 
 	if (lastdec >= now) {
 		/* normal mode */
@@ -119,20 +112,17 @@ void __udelay(unsigned long usec)
  */
 int timer_init(void)
 {
-	unsigned int cntmrctrl;
-
 	/* load value into timer */
 	writel(TIMER_LOAD_VAL, CNTMR_RELOAD_REG(UBOOT_CNTR));
 	writel(TIMER_LOAD_VAL, CNTMR_VAL_REG(UBOOT_CNTR));
 
 	/* enable timer in auto reload mode */
-	cntmrctrl = readl(CNTMR_CTRL_REG);
-	cntmrctrl |= CTCR_ARM_TIMER_EN(UBOOT_CNTR);
-	cntmrctrl |= CTCR_ARM_TIMER_AUTO_EN(UBOOT_CNTR);
-	writel(cntmrctrl, CNTMR_CTRL_REG);
+	clrsetbits_le32(CNTMR_CTRL_REG, CTCR_ARM_TIMER_25MHZ(UBOOT_CNTR),
+			CTCR_ARM_TIMER_EN(UBOOT_CNTR) |
+			CTCR_ARM_TIMER_AUTO_EN(UBOOT_CNTR));
 
 	/* init the timestamp and lastdec value */
-	lastdec = READ_TIMER;
+	lastdec = read_timer();
 	timestamp = 0;
 
 	return 0;
-- 
2.0.1

^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 10/25] arm: mvebu: Add common mbus functions to use on Marvell SoCs
  2014-06-27  9:54 [U-Boot] [PATCH v1 0/25] Add Marvell Armada XP MV78460 SoC support Stefan Roese
                   ` (8 preceding siblings ...)
  2014-06-27  9:54 ` [U-Boot] [PATCH v1 09/25] arm: marvell: Rework timer.c to make it usable for other MVEBU platforms Stefan Roese
@ 2014-06-27  9:54 ` Stefan Roese
  2014-06-27  9:54 ` [U-Boot] [PATCH v1 11/25] spi: kirkwood_spi.c: Compile MPP (pin-mux) only for kirkwood SoC's Stefan Roese
                   ` (15 subsequent siblings)
  25 siblings, 0 replies; 50+ messages in thread
From: Stefan Roese @ 2014-06-27  9:54 UTC (permalink / raw)
  To: u-boot

These mbus functions are ported from Barebox. The Barebox version is
ported from Linux. These functions will be first used by the upcoming
Armada XP support. Later other Marvell SoC's will be adopted to use
these functions as well (Kirkwood, Orion).

Signed-off-by: Stefan Roese <sr@denx.de>
---

 arch/arm/mvebu-common/Makefile |   1 +
 arch/arm/mvebu-common/mbus.c   | 477 +++++++++++++++++++++++++++++++++++++++++
 include/linux/mbus.h           |  61 ++++++
 3 files changed, 539 insertions(+)
 create mode 100644 arch/arm/mvebu-common/mbus.c
 create mode 100644 include/linux/mbus.h

diff --git a/arch/arm/mvebu-common/Makefile b/arch/arm/mvebu-common/Makefile
index 4d20d2c..391a125 100644
--- a/arch/arm/mvebu-common/Makefile
+++ b/arch/arm/mvebu-common/Makefile
@@ -7,4 +7,5 @@
 #
 
 obj-y	= dram.o
+obj-$(CONFIG_ARMADA_XP) += mbus.o
 obj-y	+= timer.o
diff --git a/arch/arm/mvebu-common/mbus.c b/arch/arm/mvebu-common/mbus.c
new file mode 100644
index 0000000..3db28a0
--- /dev/null
+++ b/arch/arm/mvebu-common/mbus.c
@@ -0,0 +1,477 @@
+/*
+ * Address map functions for Marvell EBU SoCs (Kirkwood, Armada
+ * 370/XP, Dove, Orion5x and MV78xx0)
+ *
+ * Ported from the Barebox version to U-Boot by:
+ * Stefan Roese <sr@denx.de>
+ *
+ * The Barebox version is:
+ * Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
+ *
+ * based on mbus driver from Linux
+ *   (C) Copyright 2008 Marvell Semiconductor
+ *
+ * SPDX-License-Identifier:	GPL-2.0
+ *
+ * The Marvell EBU SoCs have a configurable physical address space:
+ * the physical address at which certain devices (PCIe, NOR, NAND,
+ * etc.) sit can be configured. The configuration takes place through
+ * two sets of registers:
+ *
+ * - One to configure the access of the CPU to the devices. Depending
+ *   on the families, there are between 8 and 20 configurable windows,
+ *   each can be use to create a physical memory window that maps to a
+ *   specific device. Devices are identified by a tuple (target,
+ *   attribute).
+ *
+ * - One to configure the access to the CPU to the SDRAM. There are
+ *   either 2 (for Dove) or 4 (for other families) windows to map the
+ *   SDRAM into the physical address space.
+ *
+ * This driver:
+ *
+ * - Reads out the SDRAM address decoding windows at initialization
+ *   time, and fills the mbus_dram_info structure with these
+ *   informations. The exported function mv_mbus_dram_info() allow
+ *   device drivers to get those informations related to the SDRAM
+ *   address decoding windows. This is because devices also have their
+ *   own windows (configured through registers that are part of each
+ *   device register space), and therefore the drivers for Marvell
+ *   devices have to configure those device -> SDRAM windows to ensure
+ *   that DMA works properly.
+ *
+ * - Provides an API for platform code or device drivers to
+ *   dynamically add or remove address decoding windows for the CPU ->
+ *   device accesses. This API is mvebu_mbus_add_window_by_id(),
+ *   mvebu_mbus_add_window_remap_by_id() and
+ *   mvebu_mbus_del_window().
+ */
+
+#include <common.h>
+#include <asm/errno.h>
+#include <asm/io.h>
+#include <asm/arch/cpu.h>
+#include <asm/arch/soc.h>
+#include <linux/mbus.h>
+
+#define BIT(nr)			(1UL << (nr))
+
+/* DDR target is the same on all platforms */
+#define TARGET_DDR		0
+
+/* CPU Address Decode Windows registers */
+#define WIN_CTRL_OFF		0x0000
+#define   WIN_CTRL_ENABLE       BIT(0)
+#define   WIN_CTRL_TGT_MASK     0xf0
+#define   WIN_CTRL_TGT_SHIFT    4
+#define   WIN_CTRL_ATTR_MASK    0xff00
+#define   WIN_CTRL_ATTR_SHIFT   8
+#define   WIN_CTRL_SIZE_MASK    0xffff0000
+#define   WIN_CTRL_SIZE_SHIFT   16
+#define WIN_BASE_OFF		0x0004
+#define   WIN_BASE_LOW          0xffff0000
+#define   WIN_BASE_HIGH         0xf
+#define WIN_REMAP_LO_OFF	0x0008
+#define   WIN_REMAP_LOW         0xffff0000
+#define WIN_REMAP_HI_OFF	0x000c
+
+#define ATTR_HW_COHERENCY	(0x1 << 4)
+
+#define DDR_BASE_CS_OFF(n)	(0x0000 + ((n) << 3))
+#define  DDR_BASE_CS_HIGH_MASK  0xf
+#define  DDR_BASE_CS_LOW_MASK   0xff000000
+#define DDR_SIZE_CS_OFF(n)	(0x0004 + ((n) << 3))
+#define  DDR_SIZE_ENABLED       BIT(0)
+#define  DDR_SIZE_CS_MASK       0x1c
+#define  DDR_SIZE_CS_SHIFT      2
+#define  DDR_SIZE_MASK          0xff000000
+
+#define DOVE_DDR_BASE_CS_OFF(n) ((n) << 4)
+
+struct mvebu_mbus_state;
+
+struct mvebu_mbus_soc_data {
+	unsigned int num_wins;
+	unsigned int num_remappable_wins;
+	unsigned int (*win_cfg_offset)(const int win);
+	void (*setup_cpu_target)(struct mvebu_mbus_state *s);
+};
+
+struct mvebu_mbus_state {
+	void __iomem *mbuswins_base;
+	void __iomem *sdramwins_base;
+	struct dentry *debugfs_root;
+	struct dentry *debugfs_sdram;
+	struct dentry *debugfs_devs;
+	const struct mvebu_mbus_soc_data *soc;
+	int hw_io_coherency;
+};
+
+static struct mvebu_mbus_state mbus_state
+	__attribute__ ((section(".data")));
+static struct mbus_dram_target_info mbus_dram_info
+	__attribute__ ((section(".data")));
+
+/*
+ * Functions to manipulate the address decoding windows
+ */
+
+static void mvebu_mbus_read_window(struct mvebu_mbus_state *mbus,
+				   int win, int *enabled, u64 *base,
+				   u32 *size, u8 *target, u8 *attr,
+				   u64 *remap)
+{
+	void __iomem *addr = mbus->mbuswins_base +
+		mbus->soc->win_cfg_offset(win);
+	u32 basereg = readl(addr + WIN_BASE_OFF);
+	u32 ctrlreg = readl(addr + WIN_CTRL_OFF);
+
+	if (!(ctrlreg & WIN_CTRL_ENABLE)) {
+		*enabled = 0;
+		return;
+	}
+
+	*enabled = 1;
+	*base = ((u64)basereg & WIN_BASE_HIGH) << 32;
+	*base |= (basereg & WIN_BASE_LOW);
+	*size = (ctrlreg | ~WIN_CTRL_SIZE_MASK) + 1;
+
+	if (target)
+		*target = (ctrlreg & WIN_CTRL_TGT_MASK) >> WIN_CTRL_TGT_SHIFT;
+
+	if (attr)
+		*attr = (ctrlreg & WIN_CTRL_ATTR_MASK) >> WIN_CTRL_ATTR_SHIFT;
+
+	if (remap) {
+		if (win < mbus->soc->num_remappable_wins) {
+			u32 remap_low = readl(addr + WIN_REMAP_LO_OFF);
+			u32 remap_hi  = readl(addr + WIN_REMAP_HI_OFF);
+			*remap = ((u64)remap_hi << 32) | remap_low;
+		} else {
+			*remap = 0;
+		}
+	}
+}
+
+static void mvebu_mbus_disable_window(struct mvebu_mbus_state *mbus,
+				      int win)
+{
+	void __iomem *addr;
+
+	addr = mbus->mbuswins_base + mbus->soc->win_cfg_offset(win);
+
+	writel(0, addr + WIN_BASE_OFF);
+	writel(0, addr + WIN_CTRL_OFF);
+	if (win < mbus->soc->num_remappable_wins) {
+		writel(0, addr + WIN_REMAP_LO_OFF);
+		writel(0, addr + WIN_REMAP_HI_OFF);
+	}
+}
+
+/* Checks whether the given window number is available */
+static int mvebu_mbus_window_is_free(struct mvebu_mbus_state *mbus,
+				     const int win)
+{
+	void __iomem *addr = mbus->mbuswins_base +
+		mbus->soc->win_cfg_offset(win);
+	u32 ctrl = readl(addr + WIN_CTRL_OFF);
+	return !(ctrl & WIN_CTRL_ENABLE);
+}
+
+/*
+ * Checks whether the given (base, base+size) area doesn't overlap an
+ * existing region
+ */
+static int mvebu_mbus_window_conflicts(struct mvebu_mbus_state *mbus,
+				       phys_addr_t base, size_t size,
+				       u8 target, u8 attr)
+{
+	u64 end = (u64)base + size;
+	int win;
+
+	for (win = 0; win < mbus->soc->num_wins; win++) {
+		u64 wbase, wend;
+		u32 wsize;
+		u8 wtarget, wattr;
+		int enabled;
+
+		mvebu_mbus_read_window(mbus, win,
+				       &enabled, &wbase, &wsize,
+				       &wtarget, &wattr, NULL);
+
+		if (!enabled)
+			continue;
+
+		wend = wbase + wsize;
+
+		/*
+		 * Check if the current window overlaps with the
+		 * proposed physical range
+		 */
+		if ((u64)base < wend && end > wbase)
+			return 0;
+
+		/*
+		 * Check if target/attribute conflicts
+		 */
+		if (target == wtarget && attr == wattr)
+			return 0;
+	}
+
+	return 1;
+}
+
+static int mvebu_mbus_find_window(struct mvebu_mbus_state *mbus,
+				  phys_addr_t base, size_t size)
+{
+	int win;
+
+	for (win = 0; win < mbus->soc->num_wins; win++) {
+		u64 wbase;
+		u32 wsize;
+		int enabled;
+
+		mvebu_mbus_read_window(mbus, win,
+				       &enabled, &wbase, &wsize,
+				       NULL, NULL, NULL);
+
+		if (!enabled)
+			continue;
+
+		if (base == wbase && size == wsize)
+			return win;
+	}
+
+	return -ENODEV;
+}
+
+static int mvebu_mbus_setup_window(struct mvebu_mbus_state *mbus,
+				   int win, phys_addr_t base, size_t size,
+				   phys_addr_t remap, u8 target,
+				   u8 attr)
+{
+	void __iomem *addr = mbus->mbuswins_base +
+		mbus->soc->win_cfg_offset(win);
+	u32 ctrl, remap_addr;
+
+	ctrl = ((size - 1) & WIN_CTRL_SIZE_MASK) |
+		(attr << WIN_CTRL_ATTR_SHIFT)    |
+		(target << WIN_CTRL_TGT_SHIFT)   |
+		WIN_CTRL_ENABLE;
+
+	writel(base & WIN_BASE_LOW, addr + WIN_BASE_OFF);
+	writel(ctrl, addr + WIN_CTRL_OFF);
+	if (win < mbus->soc->num_remappable_wins) {
+		if (remap == MVEBU_MBUS_NO_REMAP)
+			remap_addr = base;
+		else
+			remap_addr = remap;
+		writel(remap_addr & WIN_REMAP_LOW, addr + WIN_REMAP_LO_OFF);
+		writel(0, addr + WIN_REMAP_HI_OFF);
+	}
+
+	return 0;
+}
+
+static int mvebu_mbus_alloc_window(struct mvebu_mbus_state *mbus,
+				   phys_addr_t base, size_t size,
+				   phys_addr_t remap, u8 target,
+				   u8 attr)
+{
+	int win;
+
+	if (remap == MVEBU_MBUS_NO_REMAP) {
+		for (win = mbus->soc->num_remappable_wins;
+		     win < mbus->soc->num_wins; win++)
+			if (mvebu_mbus_window_is_free(mbus, win))
+				return mvebu_mbus_setup_window(mbus, win, base,
+							       size, remap,
+							       target, attr);
+	}
+
+
+	for (win = 0; win < mbus->soc->num_wins; win++)
+		if (mvebu_mbus_window_is_free(mbus, win))
+			return mvebu_mbus_setup_window(mbus, win, base, size,
+						       remap, target, attr);
+
+	return -ENOMEM;
+}
+
+/*
+ * SoC-specific functions and definitions
+ */
+
+static unsigned int armada_370_xp_mbus_win_offset(int win)
+{
+	/* The register layout is a bit annoying and the below code
+	 * tries to cope with it.
+	 * - At offset 0x0, there are the registers for the first 8
+	 *   windows, with 4 registers of 32 bits per window (ctrl,
+	 *   base, remap low, remap high)
+	 * - Then at offset 0x80, there is a hole of 0x10 bytes for
+	 *   the internal registers base address and internal units
+	 *   sync barrier register.
+	 * - Then at offset 0x90, there the registers for 12
+	 *   windows, with only 2 registers of 32 bits per window
+	 *   (ctrl, base).
+	 */
+	if (win < 8)
+		return win << 4;
+	else
+		return 0x90 + ((win - 8) << 3);
+}
+
+static unsigned int orion5x_mbus_win_offset(int win)
+{
+	return win << 4;
+}
+
+static void mvebu_mbus_default_setup_cpu_target(struct mvebu_mbus_state *mbus)
+{
+	int i;
+	int cs;
+
+	mbus_dram_info.mbus_dram_target_id = TARGET_DDR;
+
+	for (i = 0, cs = 0; i < 4; i++) {
+		u32 base = readl(mbus->sdramwins_base + DDR_BASE_CS_OFF(i));
+		u32 size = readl(mbus->sdramwins_base + DDR_SIZE_CS_OFF(i));
+
+		/*
+		 * We only take care of entries for which the chip
+		 * select is enabled, and that don't have high base
+		 * address bits set (devices can only access the first
+		 * 32 bits of the memory).
+		 */
+		if ((size & DDR_SIZE_ENABLED) &&
+		    !(base & DDR_BASE_CS_HIGH_MASK)) {
+			struct mbus_dram_window *w;
+
+			w = &mbus_dram_info.cs[cs++];
+			w->cs_index = i;
+			w->mbus_attr = 0xf & ~(1 << i);
+#if defined(CONFIG_ARMADA_XP)
+			w->mbus_attr |= ATTR_HW_COHERENCY;
+#endif
+			w->base = base & DDR_BASE_CS_LOW_MASK;
+			w->size = (size | ~DDR_SIZE_MASK) + 1;
+		}
+	}
+	mbus_dram_info.num_cs = cs;
+}
+
+static const struct mvebu_mbus_soc_data
+armada_370_xp_mbus_data __maybe_unused = {
+	.num_wins            = 20,
+	.num_remappable_wins = 8,
+	.win_cfg_offset      = armada_370_xp_mbus_win_offset,
+	.setup_cpu_target    = mvebu_mbus_default_setup_cpu_target,
+};
+
+static const struct mvebu_mbus_soc_data
+kirkwood_mbus_data __maybe_unused = {
+	.num_wins            = 8,
+	.num_remappable_wins = 4,
+	.win_cfg_offset      = orion5x_mbus_win_offset,
+	.setup_cpu_target    = mvebu_mbus_default_setup_cpu_target,
+};
+
+/*
+ * Public API of the driver
+ */
+const struct mbus_dram_target_info *mvebu_mbus_dram_info(void)
+{
+	return &mbus_dram_info;
+}
+
+int mvebu_mbus_add_window_remap_by_id(unsigned int target,
+				      unsigned int attribute,
+				      phys_addr_t base, size_t size,
+				      phys_addr_t remap)
+{
+	struct mvebu_mbus_state *s = &mbus_state;
+
+	if (!mvebu_mbus_window_conflicts(s, base, size, target, attribute)) {
+		printf("Cannot add window '%x:%x', conflicts with another window\n",
+		       target, attribute);
+		return -EINVAL;
+	}
+
+	return mvebu_mbus_alloc_window(s, base, size, remap, target, attribute);
+}
+
+int mvebu_mbus_add_window_by_id(unsigned int target, unsigned int attribute,
+				phys_addr_t base, size_t size)
+{
+	return mvebu_mbus_add_window_remap_by_id(target, attribute, base,
+						 size, MVEBU_MBUS_NO_REMAP);
+}
+
+int mvebu_mbus_del_window(phys_addr_t base, size_t size)
+{
+	int win;
+
+	win = mvebu_mbus_find_window(&mbus_state, base, size);
+	if (win < 0)
+		return win;
+
+	mvebu_mbus_disable_window(&mbus_state, win);
+	return 0;
+}
+
+static int mbus_dt_setup_win(struct mvebu_mbus_state *mbus,
+			     u32 base, u32 size, u8 target, u8 attr)
+{
+	if (!mvebu_mbus_window_conflicts(mbus, base, size, target, attr)) {
+		printf("Cannot add window '%04x:%04x', conflicts with another window\n",
+		       target, attr);
+		return -EBUSY;
+	}
+
+	if (mvebu_mbus_alloc_window(mbus, base, size, MVEBU_MBUS_NO_REMAP,
+				    target, attr)) {
+		printf("Cannot add window '%04x:%04x', too many windows\n",
+		       target, attr);
+		return -ENOMEM;
+	}
+	return 0;
+}
+
+int mvebu_mbus_probe(struct mbus_win windows[], int count)
+{
+	int win;
+	int ret;
+	int i;
+
+#if defined(CONFIG_KIRKWOOD)
+	mbus_state.soc = &kirkwood_mbus_data;
+#endif
+#if defined(CONFIG_ARMADA_XP)
+	mbus_state.soc = &armada_370_xp_mbus_data;
+#endif
+
+	mbus_state.mbuswins_base = (void __iomem *)MVEBU_CPU_WIN_BASE;
+	mbus_state.sdramwins_base = (void __iomem *)MVEBU_SDRAM_BASE;
+
+	for (win = 0; win < mbus_state.soc->num_wins; win++)
+		mvebu_mbus_disable_window(&mbus_state, win);
+
+	mbus_state.soc->setup_cpu_target(&mbus_state);
+
+	/* Setup statically declared windows in the DT */
+	for (i = 0; i < count; i++) {
+		u32 base, size;
+		u8 target, attr;
+
+		target = windows[i].target;
+		attr = windows[i].attr;
+		base = windows[i].base;
+		size = windows[i].size;
+		ret = mbus_dt_setup_win(&mbus_state, base, size, target, attr);
+		if (ret < 0)
+			return ret;
+	}
+
+	return 0;
+}
diff --git a/include/linux/mbus.h b/include/linux/mbus.h
new file mode 100644
index 0000000..578ff33
--- /dev/null
+++ b/include/linux/mbus.h
@@ -0,0 +1,61 @@
+/*
+ * Marvell MBUS common definitions.
+ *
+ * Copyright (C) 2008 Marvell Semiconductor
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#ifndef __LINUX_MBUS_H
+#define __LINUX_MBUS_H
+
+struct resource;
+
+struct mbus_dram_target_info {
+	/*
+	 * The 4-bit MBUS target ID of the DRAM controller.
+	 */
+	u8		mbus_dram_target_id;
+
+	/*
+	 * The base address, size, and MBUS attribute ID for each
+	 * of the possible DRAM chip selects.  Peripherals are
+	 * required to support@least 4 decode windows.
+	 */
+	int		num_cs;
+	struct mbus_dram_window {
+		u8	cs_index;
+		u8	mbus_attr;
+		u32	base;
+		u32	size;
+	} cs[4];
+};
+
+/* Flags for PCI/PCIe address decoding regions */
+#define MVEBU_MBUS_PCI_IO  0x1
+#define MVEBU_MBUS_PCI_MEM 0x2
+#define MVEBU_MBUS_PCI_WA  0x3
+
+/*
+ * Magic value that explicits that we don't need a remapping-capable
+ * address decoding window.
+ */
+#define MVEBU_MBUS_NO_REMAP (0xffffffff)
+
+/* Maximum size of a mbus window name */
+#define MVEBU_MBUS_MAX_WINNAME_SZ 32
+
+const struct mbus_dram_target_info *mvebu_mbus_dram_info(void);
+void mvebu_mbus_get_pcie_mem_aperture(struct resource *res);
+void mvebu_mbus_get_pcie_io_aperture(struct resource *res);
+int mvebu_mbus_add_window_remap_by_id(unsigned int target,
+				      unsigned int attribute,
+				      phys_addr_t base, size_t size,
+				      phys_addr_t remap);
+int mvebu_mbus_add_window_by_id(unsigned int target, unsigned int attribute,
+				phys_addr_t base, size_t size);
+int mvebu_mbus_del_window(phys_addr_t base, size_t size);
+
+#endif /* __LINUX_MBUS_H */
-- 
2.0.1

^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 11/25] spi: kirkwood_spi.c: Compile MPP (pin-mux) only for kirkwood SoC's
  2014-06-27  9:54 [U-Boot] [PATCH v1 0/25] Add Marvell Armada XP MV78460 SoC support Stefan Roese
                   ` (9 preceding siblings ...)
  2014-06-27  9:54 ` [U-Boot] [PATCH v1 10/25] arm: mvebu: Add common mbus functions to use on Marvell SoCs Stefan Roese
@ 2014-06-27  9:54 ` Stefan Roese
  2014-07-13 16:18   ` Jagan Teki
  2014-06-27  9:54 ` [U-Boot] [PATCH v1 12/25] arm: marvell: Extract kirkwood gpio functions into new common file gpio.c Stefan Roese
                   ` (14 subsequent siblings)
  25 siblings, 1 reply; 50+ messages in thread
From: Stefan Roese @ 2014-06-27  9:54 UTC (permalink / raw)
  To: u-boot

Compile the pin multiplexing only on Kirkwood platforms. As the
Armada XP doesn't need it.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
---

 drivers/spi/kirkwood_spi.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/spi/kirkwood_spi.c b/drivers/spi/kirkwood_spi.c
index 9710f12..ce2ba96 100644
--- a/drivers/spi/kirkwood_spi.c
+++ b/drivers/spi/kirkwood_spi.c
@@ -13,22 +13,28 @@
 #include <spi.h>
 #include <asm/io.h>
 #include <asm/arch/soc.h>
+#ifdef CONFIG_KIRKWOOD
 #include <asm/arch/mpp.h>
+#endif
 #include <asm/arch-mvebu/spi.h>
 
 static struct kwspi_registers *spireg = (struct kwspi_registers *)KW_SPI_BASE;
 
+#ifdef CONFIG_KIRKWOOD
 static u32 cs_spi_mpp_back[2];
+#endif
 
 struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
 				unsigned int max_hz, unsigned int mode)
 {
 	struct spi_slave *slave;
 	u32 data;
+#ifdef CONFIG_KIRKWOOD
 	static const u32 kwspi_mpp_config[2][2] = {
 		{ MPP0_SPI_SCn, 0 }, /* if cs == 0 */
 		{ MPP7_SPI_SCn, 0 } /* if cs != 0 */
 	};
+#endif
 
 	if (!spi_cs_is_valid(bus, cs))
 		return NULL;
@@ -51,15 +57,19 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
 	writel(KWSPI_SMEMRDIRQ, &spireg->irq_cause);
 	writel(KWSPI_IRQMASK, &spireg->irq_mask);
 
+#ifdef CONFIG_KIRKWOOD
 	/* program mpp registers to select  SPI_CSn */
 	kirkwood_mpp_conf(kwspi_mpp_config[cs ? 1 : 0], cs_spi_mpp_back);
+#endif
 
 	return slave;
 }
 
 void spi_free_slave(struct spi_slave *slave)
 {
+#ifdef CONFIG_KIRKWOOD
 	kirkwood_mpp_conf(cs_spi_mpp_back, NULL);
+#endif
 	free(slave);
 }
 
-- 
2.0.1

^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 12/25] arm: marvell: Extract kirkwood gpio functions into new common file gpio.c
  2014-06-27  9:54 [U-Boot] [PATCH v1 0/25] Add Marvell Armada XP MV78460 SoC support Stefan Roese
                   ` (10 preceding siblings ...)
  2014-06-27  9:54 ` [U-Boot] [PATCH v1 11/25] spi: kirkwood_spi.c: Compile MPP (pin-mux) only for kirkwood SoC's Stefan Roese
@ 2014-06-27  9:54 ` Stefan Roese
  2014-06-27  9:54 ` [U-Boot] [PATCH v1 13/25] spi: kirkwood_spi.c: Change KW_SPI_BASE to MVEBU_SPI_BASE Stefan Roese
                   ` (13 subsequent siblings)
  25 siblings, 0 replies; 50+ messages in thread
From: Stefan Roese @ 2014-06-27  9:54 UTC (permalink / raw)
  To: u-boot

This makes is possible to use those gpio functions from other MVEBU SoC's as well.

Signed-off-by: Stefan Roese <sr@denx.de>
---

 arch/arm/cpu/arm926ejs/kirkwood/cpu.c           | 17 --------------
 arch/arm/include/asm/arch-kirkwood/cpu.h        |  2 +-
 arch/arm/include/asm/arch-kirkwood/gpio.h       | 16 ++++++-------
 arch/arm/include/asm/arch-kirkwood/soc.h        |  4 ++--
 arch/arm/mvebu-common/Makefile                  |  1 +
 arch/arm/mvebu-common/gpio.c                    | 30 +++++++++++++++++++++++++
 board/LaCie/net2big_v2/net2big_v2.c             |  4 ++--
 board/LaCie/netspace_v2/netspace_v2.c           |  4 ++--
 board/LaCie/wireless_space/wireless_space.c     |  4 ++--
 board/Marvell/dreamplug/dreamplug.c             |  6 ++---
 board/Marvell/guruplug/guruplug.c               |  6 ++---
 board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c |  6 ++---
 board/Marvell/openrd/openrd.c                   |  6 ++---
 board/Marvell/rd6281a/rd6281a.c                 |  6 ++---
 board/Marvell/sheevaplug/sheevaplug.c           |  6 ++---
 board/Seagate/dockstar/dockstar.c               |  8 +++----
 board/Seagate/goflexhome/goflexhome.c           |  8 +++----
 board/buffalo/lsxl/lsxl.c                       |  6 ++---
 board/cloudengines/pogo_e02/pogo_e02.c          |  6 ++---
 board/d-link/dns325/dns325.c                    |  4 ++--
 board/iomega/iconnect/iconnect.c                |  6 ++---
 board/karo/tk71/tk71.c                          |  6 ++---
 board/keymile/km_arm/km_arm.c                   |  4 ++--
 board/raidsonic/ib62x0/ib62x0.c                 |  6 ++---
 24 files changed, 93 insertions(+), 79 deletions(-)
 create mode 100644 arch/arm/mvebu-common/gpio.c

diff --git a/arch/arm/cpu/arm926ejs/kirkwood/cpu.c b/arch/arm/cpu/arm926ejs/kirkwood/cpu.c
index c8f90ba..00abcfd 100644
--- a/arch/arm/cpu/arm926ejs/kirkwood/cpu.c
+++ b/arch/arm/cpu/arm926ejs/kirkwood/cpu.c
@@ -139,23 +139,6 @@ int kw_config_adr_windows(void)
 }
 
 /*
- * kw_config_gpio - GPIO configuration
- */
-void kw_config_gpio(u32 gpp0_oe_val, u32 gpp1_oe_val, u32 gpp0_oe, u32 gpp1_oe)
-{
-	struct kwgpio_registers *gpio0reg =
-		(struct kwgpio_registers *)KW_GPIO0_BASE;
-	struct kwgpio_registers *gpio1reg =
-		(struct kwgpio_registers *)KW_GPIO1_BASE;
-
-	/* Init GPIOS to default values as per board requirement */
-	writel(gpp0_oe_val, &gpio0reg->dout);
-	writel(gpp1_oe_val, &gpio1reg->dout);
-	writel(gpp0_oe, &gpio0reg->oe);
-	writel(gpp1_oe, &gpio1reg->oe);
-}
-
-/*
  * kw_config_mpp - Multi-Purpose Pins Functionality configuration
  *
  * Each MPP can be configured to different functionality through
diff --git a/arch/arm/include/asm/arch-kirkwood/cpu.h b/arch/arm/include/asm/arch-kirkwood/cpu.h
index 97daa40..5900a15 100644
--- a/arch/arm/include/asm/arch-kirkwood/cpu.h
+++ b/arch/arm/include/asm/arch-kirkwood/cpu.h
@@ -144,7 +144,7 @@ unsigned int kw_sdram_bar(enum memory_bank bank);
 unsigned int kw_sdram_bs(enum memory_bank bank);
 void kw_sdram_size_adjust(enum memory_bank bank);
 int kw_config_adr_windows(void);
-void kw_config_gpio(unsigned int gpp0_oe_val, unsigned int gpp1_oe_val,
+void mvebu_config_gpio(unsigned int gpp0_oe_val, unsigned int gpp1_oe_val,
 		unsigned int gpp0_oe, unsigned int gpp1_oe);
 int kw_config_mpp(unsigned int mpp0_7, unsigned int mpp8_15,
 		unsigned int mpp16_23, unsigned int mpp24_31,
diff --git a/arch/arm/include/asm/arch-kirkwood/gpio.h b/arch/arm/include/asm/arch-kirkwood/gpio.h
index 5f4d786..aa8c5da 100644
--- a/arch/arm/include/asm/arch-kirkwood/gpio.h
+++ b/arch/arm/include/asm/arch-kirkwood/gpio.h
@@ -21,14 +21,14 @@
 
 #define GPIO_MAX		50
 #define GPIO_OFF(pin)		(((pin) >> 5) ? 0x0040 : 0x0000)
-#define GPIO_OUT(pin)		(KW_GPIO0_BASE + GPIO_OFF(pin) + 0x00)
-#define GPIO_IO_CONF(pin)	(KW_GPIO0_BASE + GPIO_OFF(pin) + 0x04)
-#define GPIO_BLINK_EN(pin)	(KW_GPIO0_BASE + GPIO_OFF(pin) + 0x08)
-#define GPIO_IN_POL(pin)	(KW_GPIO0_BASE + GPIO_OFF(pin) + 0x0c)
-#define GPIO_DATA_IN(pin)	(KW_GPIO0_BASE + GPIO_OFF(pin) + 0x10)
-#define GPIO_EDGE_CAUSE(pin)	(KW_GPIO0_BASE + GPIO_OFF(pin) + 0x14)
-#define GPIO_EDGE_MASK(pin)	(KW_GPIO0_BASE + GPIO_OFF(pin) + 0x18)
-#define GPIO_LEVEL_MASK(pin)	(KW_GPIO0_BASE + GPIO_OFF(pin) + 0x1c)
+#define GPIO_OUT(pin)		(MVEBU_GPIO0_BASE + GPIO_OFF(pin) + 0x00)
+#define GPIO_IO_CONF(pin)	(MVEBU_GPIO0_BASE + GPIO_OFF(pin) + 0x04)
+#define GPIO_BLINK_EN(pin)	(MVEBU_GPIO0_BASE + GPIO_OFF(pin) + 0x08)
+#define GPIO_IN_POL(pin)	(MVEBU_GPIO0_BASE + GPIO_OFF(pin) + 0x0c)
+#define GPIO_DATA_IN(pin)	(MVEBU_GPIO0_BASE + GPIO_OFF(pin) + 0x10)
+#define GPIO_EDGE_CAUSE(pin)	(MVEBU_GPIO0_BASE + GPIO_OFF(pin) + 0x14)
+#define GPIO_EDGE_MASK(pin)	(MVEBU_GPIO0_BASE + GPIO_OFF(pin) + 0x18)
+#define GPIO_LEVEL_MASK(pin)	(MVEBU_GPIO0_BASE + GPIO_OFF(pin) + 0x1c)
 
 /*
  * Kirkwood-specific GPIO API
diff --git a/arch/arm/include/asm/arch-kirkwood/soc.h b/arch/arm/include/asm/arch-kirkwood/soc.h
index 4261c35..37cbae9 100644
--- a/arch/arm/include/asm/arch-kirkwood/soc.h
+++ b/arch/arm/include/asm/arch-kirkwood/soc.h
@@ -26,8 +26,8 @@
 #define KW_UART0_BASE			(KW_REGISTER(0x12000))
 #define KW_UART1_BASE			(KW_REGISTER(0x12100))
 #define KW_MPP_BASE			(KW_REGISTER(0x10000))
-#define KW_GPIO0_BASE			(KW_REGISTER(0x10100))
-#define KW_GPIO1_BASE			(KW_REGISTER(0x10140))
+#define MVEBU_GPIO0_BASE			(KW_REGISTER(0x10100))
+#define MVEBU_GPIO1_BASE			(KW_REGISTER(0x10140))
 #define KW_RTC_BASE			(KW_REGISTER(0x10300))
 #define KW_NANDF_BASE			(KW_REGISTER(0x10418))
 #define KW_SPI_BASE			(KW_REGISTER(0x10600))
diff --git a/arch/arm/mvebu-common/Makefile b/arch/arm/mvebu-common/Makefile
index 391a125..9dcab69 100644
--- a/arch/arm/mvebu-common/Makefile
+++ b/arch/arm/mvebu-common/Makefile
@@ -7,5 +7,6 @@
 #
 
 obj-y	= dram.o
+obj-y	+= gpio.o
 obj-$(CONFIG_ARMADA_XP) += mbus.o
 obj-y	+= timer.o
diff --git a/arch/arm/mvebu-common/gpio.c b/arch/arm/mvebu-common/gpio.c
new file mode 100644
index 0000000..56e54e0
--- /dev/null
+++ b/arch/arm/mvebu-common/gpio.c
@@ -0,0 +1,30 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/arch/cpu.h>
+#include <asm/arch/soc.h>
+
+/*
+ * mvebu_config_gpio - GPIO configuration
+ */
+void mvebu_config_gpio(u32 gpp0_oe_val, u32 gpp1_oe_val,
+		       u32 gpp0_oe, u32 gpp1_oe)
+{
+	struct kwgpio_registers *gpio0reg =
+		(struct kwgpio_registers *)MVEBU_GPIO0_BASE;
+	struct kwgpio_registers *gpio1reg =
+		(struct kwgpio_registers *)MVEBU_GPIO1_BASE;
+
+	/* Init GPIOS to default values as per board requirement */
+	writel(gpp0_oe_val, &gpio0reg->dout);
+	writel(gpp1_oe_val, &gpio1reg->dout);
+	writel(gpp0_oe, &gpio0reg->oe);
+	writel(gpp1_oe, &gpio1reg->oe);
+}
diff --git a/board/LaCie/net2big_v2/net2big_v2.c b/board/LaCie/net2big_v2/net2big_v2.c
index 471db77..12a516e 100644
--- a/board/LaCie/net2big_v2/net2big_v2.c
+++ b/board/LaCie/net2big_v2/net2big_v2.c
@@ -26,8 +26,8 @@ DECLARE_GLOBAL_DATA_PTR;
 int board_early_init_f(void)
 {
 	/* GPIO configuration */
-	kw_config_gpio(NET2BIG_V2_OE_VAL_LOW, NET2BIG_V2_OE_VAL_HIGH,
-			NET2BIG_V2_OE_LOW, NET2BIG_V2_OE_HIGH);
+	mvebu_config_gpio(NET2BIG_V2_OE_VAL_LOW, NET2BIG_V2_OE_VAL_HIGH,
+			  NET2BIG_V2_OE_LOW, NET2BIG_V2_OE_HIGH);
 
 	/* Multi-Purpose Pins Functionality configuration */
 	static const u32 kwmpp_config[] = {
diff --git a/board/LaCie/netspace_v2/netspace_v2.c b/board/LaCie/netspace_v2/netspace_v2.c
index 6a16e7b..323e34a 100644
--- a/board/LaCie/netspace_v2/netspace_v2.c
+++ b/board/LaCie/netspace_v2/netspace_v2.c
@@ -24,8 +24,8 @@ DECLARE_GLOBAL_DATA_PTR;
 int board_early_init_f(void)
 {
 	/* Gpio configuration */
-	kw_config_gpio(NETSPACE_V2_OE_VAL_LOW, NETSPACE_V2_OE_VAL_HIGH,
-			NETSPACE_V2_OE_LOW, NETSPACE_V2_OE_HIGH);
+	mvebu_config_gpio(NETSPACE_V2_OE_VAL_LOW, NETSPACE_V2_OE_VAL_HIGH,
+			  NETSPACE_V2_OE_LOW, NETSPACE_V2_OE_HIGH);
 
 	/* Multi-Purpose Pins Functionality configuration */
 	static const u32 kwmpp_config[] = {
diff --git a/board/LaCie/wireless_space/wireless_space.c b/board/LaCie/wireless_space/wireless_space.c
index 53f5d2f..15b34a3 100644
--- a/board/LaCie/wireless_space/wireless_space.c
+++ b/board/LaCie/wireless_space/wireless_space.c
@@ -97,8 +97,8 @@ struct mv88e61xx_config swcfg = {
 int board_early_init_f(void)
 {
 	/* Gpio configuration */
-	kw_config_gpio(WIRELESS_SPACE_OE_VAL_LOW, WIRELESS_SPACE_OE_VAL_HIGH,
-			WIRELESS_SPACE_OE_LOW, WIRELESS_SPACE_OE_HIGH);
+	mvebu_config_gpio(WIRELESS_SPACE_OE_VAL_LOW, WIRELESS_SPACE_OE_VAL_HIGH,
+			  WIRELESS_SPACE_OE_LOW, WIRELESS_SPACE_OE_HIGH);
 
 	/* Multi-Purpose Pins Functionality configuration */
 	kirkwood_mpp_conf(kwmpp_config, NULL);
diff --git a/board/Marvell/dreamplug/dreamplug.c b/board/Marvell/dreamplug/dreamplug.c
index 3c286be..07b7496 100644
--- a/board/Marvell/dreamplug/dreamplug.c
+++ b/board/Marvell/dreamplug/dreamplug.c
@@ -25,9 +25,9 @@ int board_early_init_f(void)
 	 * There are maximum 64 gpios controlled through 2 sets of registers
 	 * the  below configuration configures mainly initial LED status
 	 */
-	kw_config_gpio(DREAMPLUG_OE_VAL_LOW,
-			DREAMPLUG_OE_VAL_HIGH,
-			DREAMPLUG_OE_LOW, DREAMPLUG_OE_HIGH);
+	mvebu_config_gpio(DREAMPLUG_OE_VAL_LOW,
+			  DREAMPLUG_OE_VAL_HIGH,
+			  DREAMPLUG_OE_LOW, DREAMPLUG_OE_HIGH);
 
 	/* Multi-Purpose Pins Functionality configuration */
 	static const u32 kwmpp_config[] = {
diff --git a/board/Marvell/guruplug/guruplug.c b/board/Marvell/guruplug/guruplug.c
index a5b42b4..b18a306 100644
--- a/board/Marvell/guruplug/guruplug.c
+++ b/board/Marvell/guruplug/guruplug.c
@@ -22,9 +22,9 @@ int board_early_init_f(void)
 	 * There are maximum 64 gpios controlled through 2 sets of registers
 	 * the  below configuration configures mainly initial LED status
 	 */
-	kw_config_gpio(GURUPLUG_OE_VAL_LOW,
-			GURUPLUG_OE_VAL_HIGH,
-			GURUPLUG_OE_LOW, GURUPLUG_OE_HIGH);
+	mvebu_config_gpio(GURUPLUG_OE_VAL_LOW,
+			  GURUPLUG_OE_VAL_HIGH,
+			  GURUPLUG_OE_LOW, GURUPLUG_OE_HIGH);
 
 	/* Multi-Purpose Pins Functionality configuration */
 	static const u32 kwmpp_config[] = {
diff --git a/board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c b/board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c
index ee665c1..97fb61b 100644
--- a/board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c
+++ b/board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c
@@ -24,9 +24,9 @@ int board_early_init_f(void)
 	 * There are maximum 64 gpios controlled through 2 sets of registers
 	 * the  below configuration configures mainly initial LED status
 	 */
-	kw_config_gpio(MV88F6281GTW_GE_OE_VAL_LOW,
-			MV88F6281GTW_GE_OE_VAL_HIGH,
-			MV88F6281GTW_GE_OE_LOW, MV88F6281GTW_GE_OE_HIGH);
+	mvebu_config_gpio(MV88F6281GTW_GE_OE_VAL_LOW,
+			  MV88F6281GTW_GE_OE_VAL_HIGH,
+			  MV88F6281GTW_GE_OE_LOW, MV88F6281GTW_GE_OE_HIGH);
 
 	/* Multi-Purpose Pins Functionality configuration */
 	static const u32 kwmpp_config[] = {
diff --git a/board/Marvell/openrd/openrd.c b/board/Marvell/openrd/openrd.c
index 78ebb64..52dd083 100644
--- a/board/Marvell/openrd/openrd.c
+++ b/board/Marvell/openrd/openrd.c
@@ -27,9 +27,9 @@ int board_early_init_f(void)
 	 * There are maximum 64 gpios controlled through 2 sets of registers
 	 * the  below configuration configures mainly initial LED status
 	 */
-	kw_config_gpio(OPENRD_OE_VAL_LOW,
-			OPENRD_OE_VAL_HIGH,
-			OPENRD_OE_LOW, OPENRD_OE_HIGH);
+	mvebu_config_gpio(OPENRD_OE_VAL_LOW,
+			  OPENRD_OE_VAL_HIGH,
+			  OPENRD_OE_LOW, OPENRD_OE_HIGH);
 
 	/* Multi-Purpose Pins Functionality configuration */
 	static const u32 kwmpp_config[] = {
diff --git a/board/Marvell/rd6281a/rd6281a.c b/board/Marvell/rd6281a/rd6281a.c
index 8248274..df5fbea 100644
--- a/board/Marvell/rd6281a/rd6281a.c
+++ b/board/Marvell/rd6281a/rd6281a.c
@@ -23,9 +23,9 @@ int board_early_init_f(void)
 	 * There are maximum 64 gpios controlled through 2 sets of registers
 	 * the  below configuration configures mainly initial LED status
 	 */
-	kw_config_gpio(RD6281A_OE_VAL_LOW,
-			RD6281A_OE_VAL_HIGH,
-			RD6281A_OE_LOW, RD6281A_OE_HIGH);
+	mvebu_config_gpio(RD6281A_OE_VAL_LOW,
+			  RD6281A_OE_VAL_HIGH,
+			  RD6281A_OE_LOW, RD6281A_OE_HIGH);
 
 	/* Multi-Purpose Pins Functionality configuration */
 	static const u32 kwmpp_config[] = {
diff --git a/board/Marvell/sheevaplug/sheevaplug.c b/board/Marvell/sheevaplug/sheevaplug.c
index 4f17e09..18eeb4c 100644
--- a/board/Marvell/sheevaplug/sheevaplug.c
+++ b/board/Marvell/sheevaplug/sheevaplug.c
@@ -22,9 +22,9 @@ int board_early_init_f(void)
 	 * There are maximum 64 gpios controlled through 2 sets of registers
 	 * the  below configuration configures mainly initial LED status
 	 */
-	kw_config_gpio(SHEEVAPLUG_OE_VAL_LOW,
-			SHEEVAPLUG_OE_VAL_HIGH,
-			SHEEVAPLUG_OE_LOW, SHEEVAPLUG_OE_HIGH);
+	mvebu_config_gpio(SHEEVAPLUG_OE_VAL_LOW,
+			  SHEEVAPLUG_OE_VAL_HIGH,
+			  SHEEVAPLUG_OE_LOW, SHEEVAPLUG_OE_HIGH);
 
 	/* Multi-Purpose Pins Functionality configuration */
 	static const u32 kwmpp_config[] = {
diff --git a/board/Seagate/dockstar/dockstar.c b/board/Seagate/dockstar/dockstar.c
index dc73dfa..838f578 100644
--- a/board/Seagate/dockstar/dockstar.c
+++ b/board/Seagate/dockstar/dockstar.c
@@ -26,9 +26,9 @@ int board_early_init_f(void)
 	 * There are maximum 64 gpios controlled through 2 sets of registers
 	 * the  below configuration configures mainly initial LED status
 	 */
-	kw_config_gpio(DOCKSTAR_OE_VAL_LOW,
-			DOCKSTAR_OE_VAL_HIGH,
-			DOCKSTAR_OE_LOW, DOCKSTAR_OE_HIGH);
+	mvebu_config_gpio(DOCKSTAR_OE_VAL_LOW,
+			  DOCKSTAR_OE_VAL_HIGH,
+			  DOCKSTAR_OE_LOW, DOCKSTAR_OE_HIGH);
 
 	/* Multi-Purpose Pins Functionality configuration */
 	static const u32 kwmpp_config[] = {
@@ -143,7 +143,7 @@ void reset_phy(void)
 
 static void set_leds(u32 leds, u32 blinking)
 {
-	struct kwgpio_registers *r = (struct kwgpio_registers *)KW_GPIO1_BASE;
+	struct kwgpio_registers *r = (struct kwgpio_registers *)MVEBU_GPIO1_BASE;
 	u32 oe = readl(&r->oe) | BOTH_LEDS;
 	writel(oe & ~leds, &r->oe);	/* active low */
 	u32 bl = readl(&r->blink_en) & ~BOTH_LEDS;
diff --git a/board/Seagate/goflexhome/goflexhome.c b/board/Seagate/goflexhome/goflexhome.c
index 3e4ae89..c3f4cbf 100644
--- a/board/Seagate/goflexhome/goflexhome.c
+++ b/board/Seagate/goflexhome/goflexhome.c
@@ -83,9 +83,9 @@ int board_early_init_f(void)
 	 * There are maximum 64 gpios controlled through 2 sets of registers
 	 * the  below configuration configures mainly initial LED status
 	 */
-	kw_config_gpio(GOFLEXHOME_OE_VAL_LOW,
-		       GOFLEXHOME_OE_VAL_HIGH,
-		       GOFLEXHOME_OE_LOW, GOFLEXHOME_OE_HIGH);
+	mvebu_config_gpio(GOFLEXHOME_OE_VAL_LOW,
+			  GOFLEXHOME_OE_VAL_HIGH,
+			  GOFLEXHOME_OE_LOW, GOFLEXHOME_OE_HIGH);
 	kirkwood_mpp_conf(kwmpp_config, NULL);
 	return 0;
 }
@@ -149,7 +149,7 @@ static void set_leds(u32 leds, u32 blinking)
 	u32 oe;
 	u32 bl;
 
-	r = (struct kwgpio_registers *)KW_GPIO1_BASE;
+	r = (struct kwgpio_registers *)MVEBU_GPIO1_BASE;
 	oe = readl(&r->oe) | BOTH_LEDS;
 	writel(oe & ~leds, &r->oe);	/* active low */
 	bl = readl(&r->blink_en) & ~BOTH_LEDS;
diff --git a/board/buffalo/lsxl/lsxl.c b/board/buffalo/lsxl/lsxl.c
index 26b8576..042132e 100644
--- a/board/buffalo/lsxl/lsxl.c
+++ b/board/buffalo/lsxl/lsxl.c
@@ -51,9 +51,9 @@ int board_early_init_f(void)
 	 * There are maximum 64 gpios controlled through 2 sets of registers
 	 * the below configuration configures mainly initial LED status
 	 */
-	kw_config_gpio(LSXL_OE_VAL_LOW,
-			LSXL_OE_VAL_HIGH,
-			LSXL_OE_LOW, LSXL_OE_HIGH);
+	mvebu_config_gpio(LSXL_OE_VAL_LOW,
+			  LSXL_OE_VAL_HIGH,
+			  LSXL_OE_LOW, LSXL_OE_HIGH);
 
 	/*
 	 * Multi-Purpose Pins Functionality configuration
diff --git a/board/cloudengines/pogo_e02/pogo_e02.c b/board/cloudengines/pogo_e02/pogo_e02.c
index ddc3fa6..314834f 100644
--- a/board/cloudengines/pogo_e02/pogo_e02.c
+++ b/board/cloudengines/pogo_e02/pogo_e02.c
@@ -26,9 +26,9 @@ int board_early_init_f(void)
 	 * There are maximum 64 gpios controlled through 2 sets of registers
 	 * the  below configuration configures mainly initial LED status
 	 */
-	kw_config_gpio(POGO_E02_OE_VAL_LOW,
-			POGO_E02_OE_VAL_HIGH,
-			POGO_E02_OE_LOW, POGO_E02_OE_HIGH);
+	mvebu_config_gpio(POGO_E02_OE_VAL_LOW,
+			  POGO_E02_OE_VAL_HIGH,
+			  POGO_E02_OE_LOW, POGO_E02_OE_HIGH);
 
 	/* Multi-Purpose Pins Functionality configuration */
 	static const u32 kwmpp_config[] = {
diff --git a/board/d-link/dns325/dns325.c b/board/d-link/dns325/dns325.c
index f2f43f5..fd23696 100644
--- a/board/d-link/dns325/dns325.c
+++ b/board/d-link/dns325/dns325.c
@@ -24,8 +24,8 @@ DECLARE_GLOBAL_DATA_PTR;
 int board_early_init_f(void)
 {
 	/* Gpio configuration */
-	kw_config_gpio(DNS325_OE_VAL_LOW, DNS325_OE_VAL_HIGH,
-			DNS325_OE_LOW, DNS325_OE_HIGH);
+	mvebu_config_gpio(DNS325_OE_VAL_LOW, DNS325_OE_VAL_HIGH,
+			  DNS325_OE_LOW, DNS325_OE_HIGH);
 
 	/* Multi-Purpose Pins Functionality configuration */
 	static const u32 kwmpp_config[] = {
diff --git a/board/iomega/iconnect/iconnect.c b/board/iomega/iconnect/iconnect.c
index f376d3d..76c945a 100644
--- a/board/iomega/iconnect/iconnect.c
+++ b/board/iomega/iconnect/iconnect.c
@@ -22,9 +22,9 @@ int board_early_init_f(void)
 	 * There are maximum 64 gpios controlled through 2 sets of registers
 	 * the below configuration configures mainly initial LED status
 	 */
-	kw_config_gpio(ICONNECT_OE_VAL_LOW,
-			ICONNECT_OE_VAL_HIGH,
-			ICONNECT_OE_LOW, ICONNECT_OE_HIGH);
+	mvebu_config_gpio(ICONNECT_OE_VAL_LOW,
+			  ICONNECT_OE_VAL_HIGH,
+			  ICONNECT_OE_LOW, ICONNECT_OE_HIGH);
 
 	/* Multi-Purpose Pins Functionality configuration */
 	static const u32 kwmpp_config[] = {
diff --git a/board/karo/tk71/tk71.c b/board/karo/tk71/tk71.c
index e877aa3..7aec5f9 100644
--- a/board/karo/tk71/tk71.c
+++ b/board/karo/tk71/tk71.c
@@ -26,9 +26,9 @@ int board_early_init_f(void)
 	 * There are maximum 64 gpios controlled through 2 sets of registers
 	 * the  below configuration configures mainly initial LED status
 	 */
-	kw_config_gpio(TK71_OE_VAL_LOW,
-			TK71_OE_VAL_HIGH,
-			TK71_OE_LOW, TK71_OE_HIGH);
+	mvebu_config_gpio(TK71_OE_VAL_LOW,
+			  TK71_OE_VAL_HIGH,
+			  TK71_OE_LOW, TK71_OE_HIGH);
 
 	/* Multi-Purpose Pins Functionality configuration */
 	static const u32 kwmpp_config[] = {
diff --git a/board/keymile/km_arm/km_arm.c b/board/keymile/km_arm/km_arm.c
index cd508d2..6621464 100644
--- a/board/keymile/km_arm/km_arm.c
+++ b/board/keymile/km_arm/km_arm.c
@@ -222,8 +222,8 @@ int board_early_init_f(void)
 	u32 tmp;
 
 	/* set the 2 bitbang i2c pins as output gpios */
-	tmp = readl(KW_GPIO0_BASE + 4);
-	writel(tmp & (~KM_KIRKWOOD_SOFT_I2C_GPIOS) , KW_GPIO0_BASE + 4);
+	tmp = readl(MVEBU_GPIO0_BASE + 4);
+	writel(tmp & (~KM_KIRKWOOD_SOFT_I2C_GPIOS) , MVEBU_GPIO0_BASE + 4);
 #endif
 	/* adjust SDRAM size for bank 0 */
 	kw_sdram_size_adjust(0);
diff --git a/board/raidsonic/ib62x0/ib62x0.c b/board/raidsonic/ib62x0/ib62x0.c
index 47956b2..dbcfb43 100644
--- a/board/raidsonic/ib62x0/ib62x0.c
+++ b/board/raidsonic/ib62x0/ib62x0.c
@@ -24,9 +24,9 @@ int board_early_init_f(void)
 	 * There are maximum 64 gpios controlled through 2 sets of registers
 	 * the below configuration configures mainly initial LED status
 	 */
-	kw_config_gpio(IB62x0_OE_VAL_LOW,
-			IB62x0_OE_VAL_HIGH,
-			IB62x0_OE_LOW, IB62x0_OE_HIGH);
+	mvebu_config_gpio(IB62x0_OE_VAL_LOW,
+			  IB62x0_OE_VAL_HIGH,
+			  IB62x0_OE_LOW, IB62x0_OE_HIGH);
 
 	/* Set SATA activity LEDs to default off */
 	writel(MVSATAHC_LED_POLARITY_CTRL, MVSATAHC_LED_CONF_REG);
-- 
2.0.1

^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 13/25] spi: kirkwood_spi.c: Change KW_SPI_BASE to MVEBU_SPI_BASE
  2014-06-27  9:54 [U-Boot] [PATCH v1 0/25] Add Marvell Armada XP MV78460 SoC support Stefan Roese
                   ` (11 preceding siblings ...)
  2014-06-27  9:54 ` [U-Boot] [PATCH v1 12/25] arm: marvell: Extract kirkwood gpio functions into new common file gpio.c Stefan Roese
@ 2014-06-27  9:54 ` Stefan Roese
  2014-07-13 16:18   ` Jagan Teki
  2014-06-27  9:55 ` [U-Boot] [PATCH v1 14/25] arm: kirkwood: Change naming of dram functions from km_foo() to mvebu_foo() Stefan Roese
                   ` (12 subsequent siblings)
  25 siblings, 1 reply; 50+ messages in thread
From: Stefan Roese @ 2014-06-27  9:54 UTC (permalink / raw)
  To: u-boot

This makes is possible to use this SPI driver from other MVEBU SoC's as well.
As the upcoming Armada XP support will do.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
---

 arch/arm/include/asm/arch-kirkwood/soc.h | 2 +-
 drivers/spi/kirkwood_spi.c               | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/arm/include/asm/arch-kirkwood/soc.h b/arch/arm/include/asm/arch-kirkwood/soc.h
index 37cbae9..379ce13 100644
--- a/arch/arm/include/asm/arch-kirkwood/soc.h
+++ b/arch/arm/include/asm/arch-kirkwood/soc.h
@@ -30,7 +30,7 @@
 #define MVEBU_GPIO1_BASE			(KW_REGISTER(0x10140))
 #define KW_RTC_BASE			(KW_REGISTER(0x10300))
 #define KW_NANDF_BASE			(KW_REGISTER(0x10418))
-#define KW_SPI_BASE			(KW_REGISTER(0x10600))
+#define MVEBU_SPI_BASE			(KW_REGISTER(0x10600))
 #define KW_CPU_WIN_BASE			(KW_REGISTER(0x20000))
 #define KW_CPU_REG_BASE			(KW_REGISTER(0x20100))
 #define MVEBU_TIMER_BASE			(KW_REGISTER(0x20300))
diff --git a/drivers/spi/kirkwood_spi.c b/drivers/spi/kirkwood_spi.c
index ce2ba96..e7b0982 100644
--- a/drivers/spi/kirkwood_spi.c
+++ b/drivers/spi/kirkwood_spi.c
@@ -18,7 +18,8 @@
 #endif
 #include <asm/arch-mvebu/spi.h>
 
-static struct kwspi_registers *spireg = (struct kwspi_registers *)KW_SPI_BASE;
+static struct kwspi_registers *spireg =
+	(struct kwspi_registers *)MVEBU_SPI_BASE;
 
 #ifdef CONFIG_KIRKWOOD
 static u32 cs_spi_mpp_back[2];
-- 
2.0.1

^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 14/25] arm: kirkwood: Change naming of dram functions from km_foo() to mvebu_foo()
  2014-06-27  9:54 [U-Boot] [PATCH v1 0/25] Add Marvell Armada XP MV78460 SoC support Stefan Roese
                   ` (12 preceding siblings ...)
  2014-06-27  9:54 ` [U-Boot] [PATCH v1 13/25] spi: kirkwood_spi.c: Change KW_SPI_BASE to MVEBU_SPI_BASE Stefan Roese
@ 2014-06-27  9:55 ` Stefan Roese
  2014-06-27  9:55 ` [U-Boot] [PATCH v1 15/25] net: mvneta.c: Add support for the ethernet controller of the Marvell Armada XP SoC Stefan Roese
                   ` (11 subsequent siblings)
  25 siblings, 0 replies; 50+ messages in thread
From: Stefan Roese @ 2014-06-27  9:55 UTC (permalink / raw)
  To: u-boot

Additionally the SDRAM address decoding register address is not hard coded
in the C code any more. A define is introduced for this base address.

This makes is possible to use those gpio functions from other MVEBU SoC's
as well.

Signed-off-by: Stefan Roese <sr@denx.de>
---

 arch/arm/include/asm/arch-kirkwood/cpu.h        |  6 +--
 arch/arm/include/asm/arch-kirkwood/soc.h        |  1 +
 arch/arm/mvebu-common/dram.c                    | 53 +++++++++++++------------
 board/LaCie/net2big_v2/net2big_v2.c             |  2 +-
 board/LaCie/netspace_v2/netspace_v2.c           |  2 +-
 board/LaCie/wireless_space/wireless_space.c     |  2 +-
 board/Marvell/dreamplug/dreamplug.c             |  2 +-
 board/Marvell/guruplug/guruplug.c               |  2 +-
 board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c |  2 +-
 board/Marvell/openrd/openrd.c                   |  2 +-
 board/Marvell/rd6281a/rd6281a.c                 |  2 +-
 board/Marvell/sheevaplug/sheevaplug.c           |  2 +-
 board/Seagate/dockstar/dockstar.c               |  2 +-
 board/Seagate/goflexhome/goflexhome.c           |  2 +-
 board/buffalo/lsxl/lsxl.c                       |  2 +-
 board/cloudengines/pogo_e02/pogo_e02.c          |  2 +-
 board/d-link/dns325/dns325.c                    |  2 +-
 board/iomega/iconnect/iconnect.c                |  2 +-
 board/karo/tk71/tk71.c                          |  2 +-
 board/keymile/km_arm/km_arm.c                   |  4 +-
 board/raidsonic/ib62x0/ib62x0.c                 |  2 +-
 21 files changed, 50 insertions(+), 48 deletions(-)

diff --git a/arch/arm/include/asm/arch-kirkwood/cpu.h b/arch/arm/include/asm/arch-kirkwood/cpu.h
index 5900a15..926d347 100644
--- a/arch/arm/include/asm/arch-kirkwood/cpu.h
+++ b/arch/arm/include/asm/arch-kirkwood/cpu.h
@@ -140,9 +140,9 @@ struct kwgpio_registers {
  * functions
  */
 unsigned char get_random_hex(void);
-unsigned int kw_sdram_bar(enum memory_bank bank);
-unsigned int kw_sdram_bs(enum memory_bank bank);
-void kw_sdram_size_adjust(enum memory_bank bank);
+unsigned int mvebu_sdram_bar(enum memory_bank bank);
+unsigned int mvebu_sdram_bs(enum memory_bank bank);
+void mvebu_sdram_size_adjust(enum memory_bank bank);
 int kw_config_adr_windows(void);
 void mvebu_config_gpio(unsigned int gpp0_oe_val, unsigned int gpp1_oe_val,
 		unsigned int gpp0_oe, unsigned int gpp1_oe);
diff --git a/arch/arm/include/asm/arch-kirkwood/soc.h b/arch/arm/include/asm/arch-kirkwood/soc.h
index 379ce13..75120b1 100644
--- a/arch/arm/include/asm/arch-kirkwood/soc.h
+++ b/arch/arm/include/asm/arch-kirkwood/soc.h
@@ -22,6 +22,7 @@
 #define KW_REG_UNDOC_0x1470		(KW_REGISTER(0x1470))
 #define KW_REG_UNDOC_0x1478		(KW_REGISTER(0x1478))
 
+#define MVEBU_SDRAM_BASE		(KW_REGISTER(0x1500))
 #define KW_TWSI_BASE			(KW_REGISTER(0x11000))
 #define KW_UART0_BASE			(KW_REGISTER(0x12000))
 #define KW_UART1_BASE			(KW_REGISTER(0x12100))
diff --git a/arch/arm/mvebu-common/dram.c b/arch/arm/mvebu-common/dram.c
index e468136..db18791 100644
--- a/arch/arm/mvebu-common/dram.c
+++ b/arch/arm/mvebu-common/dram.c
@@ -14,27 +14,27 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-struct kw_sdram_bank {
+struct sdram_bank {
 	u32	win_bar;
 	u32	win_sz;
 };
 
-struct kw_sdram_addr_dec {
-	struct kw_sdram_bank	sdram_bank[4];
+struct sdram_addr_dec {
+	struct sdram_bank sdram_bank[4];
 };
 
-#define KW_REG_CPUCS_WIN_ENABLE		(1 << 0)
-#define KW_REG_CPUCS_WIN_WR_PROTECT	(1 << 1)
-#define KW_REG_CPUCS_WIN_WIN0_CS(x)	(((x) & 0x3) << 2)
-#define KW_REG_CPUCS_WIN_SIZE(x)	(((x) & 0xff) << 24)
+#define REG_CPUCS_WIN_ENABLE		(1 << 0)
+#define REG_CPUCS_WIN_WR_PROTECT	(1 << 1)
+#define REG_CPUCS_WIN_WIN0_CS(x)	(((x) & 0x3) << 2)
+#define REG_CPUCS_WIN_SIZE(x)		(((x) & 0xff) << 24)
 
 /*
- * kw_sdram_bar - reads SDRAM Base Address Register
+ * mvebu_sdram_bar - reads SDRAM Base Address Register
  */
-u32 kw_sdram_bar(enum memory_bank bank)
+u32 mvebu_sdram_bar(enum memory_bank bank)
 {
-	struct kw_sdram_addr_dec *base =
-		(struct kw_sdram_addr_dec *)KW_REGISTER(0x1500);
+	struct sdram_addr_dec *base =
+		(struct sdram_addr_dec *)MVEBU_SDRAM_BASE;
 	u32 result = 0;
 	u32 enable = 0x01 & readl(&base->sdram_bank[bank].win_sz);
 
@@ -46,31 +46,31 @@ u32 kw_sdram_bar(enum memory_bank bank)
 }
 
 /*
- * kw_sdram_bs_set - writes SDRAM Bank size
+ * mvebu_sdram_bs_set - writes SDRAM Bank size
  */
-static void kw_sdram_bs_set(enum memory_bank bank, u32 size)
+static void mvebu_sdram_bs_set(enum memory_bank bank, u32 size)
 {
-	struct kw_sdram_addr_dec *base =
-		(struct kw_sdram_addr_dec *)KW_REGISTER(0x1500);
+	struct sdram_addr_dec *base =
+		(struct sdram_addr_dec *)MVEBU_SDRAM_BASE;
 	/* Read current register value */
 	u32 reg = readl(&base->sdram_bank[bank].win_sz);
 
 	/* Clear window size */
-	reg &= ~KW_REG_CPUCS_WIN_SIZE(0xFF);
+	reg &= ~REG_CPUCS_WIN_SIZE(0xFF);
 
 	/* Set new window size */
-	reg |= KW_REG_CPUCS_WIN_SIZE((size - 1) >> 24);
+	reg |= REG_CPUCS_WIN_SIZE((size - 1) >> 24);
 
 	writel(reg, &base->sdram_bank[bank].win_sz);
 }
 
 /*
- * kw_sdram_bs - reads SDRAM Bank size
+ * mvebu_sdram_bs - reads SDRAM Bank size
  */
-u32 kw_sdram_bs(enum memory_bank bank)
+u32 mvebu_sdram_bs(enum memory_bank bank)
 {
-	struct kw_sdram_addr_dec *base =
-		(struct kw_sdram_addr_dec *)KW_REGISTER(0x1500);
+	struct sdram_addr_dec *base =
+		(struct sdram_addr_dec *)MVEBU_SDRAM_BASE;
 	u32 result = 0;
 	u32 enable = 0x01 & readl(&base->sdram_bank[bank].win_sz);
 
@@ -81,15 +81,16 @@ u32 kw_sdram_bs(enum memory_bank bank)
 	return result;
 }
 
-void kw_sdram_size_adjust(enum memory_bank bank)
+void mvebu_sdram_size_adjust(enum memory_bank bank)
 {
 	u32 size;
 
 	/* probe currently equipped RAM size */
-	size = get_ram_size((void *)kw_sdram_bar(bank), kw_sdram_bs(bank));
+	size = get_ram_size((void *)mvebu_sdram_bar(bank),
+			    mvebu_sdram_bs(bank));
 
 	/* adjust SDRAM window size accordingly */
-	kw_sdram_bs_set(bank, size);
+	mvebu_sdram_bs_set(bank, size);
 }
 
 #ifndef CONFIG_SYS_BOARD_DRAM_INIT
@@ -99,8 +100,8 @@ int dram_init(void)
 
 	gd->ram_size = 0;
 	for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
-		gd->bd->bi_dram[i].start = kw_sdram_bar(i);
-		gd->bd->bi_dram[i].size = kw_sdram_bs(i);
+		gd->bd->bi_dram[i].start = mvebu_sdram_bar(i);
+		gd->bd->bi_dram[i].size = mvebu_sdram_bs(i);
 		/*
 		 * It is assumed that all memory banks are consecutive
 		 * and without gaps.
diff --git a/board/LaCie/net2big_v2/net2big_v2.c b/board/LaCie/net2big_v2/net2big_v2.c
index 12a516e..263bb54 100644
--- a/board/LaCie/net2big_v2/net2big_v2.c
+++ b/board/LaCie/net2big_v2/net2big_v2.c
@@ -77,7 +77,7 @@ int board_init(void)
 	gd->bd->bi_arch_number = MACH_TYPE_NET2BIG_V2;
 
 	/* Boot parameters address */
-	gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+	gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
 
 	return 0;
 }
diff --git a/board/LaCie/netspace_v2/netspace_v2.c b/board/LaCie/netspace_v2/netspace_v2.c
index 323e34a..17e6296 100644
--- a/board/LaCie/netspace_v2/netspace_v2.c
+++ b/board/LaCie/netspace_v2/netspace_v2.c
@@ -73,7 +73,7 @@ int board_init(void)
 	gd->bd->bi_arch_number = CONFIG_MACH_TYPE;
 
 	/* Boot parameters address */
-	gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+	gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
 
 	return 0;
 }
diff --git a/board/LaCie/wireless_space/wireless_space.c b/board/LaCie/wireless_space/wireless_space.c
index 15b34a3..8620e4b 100644
--- a/board/LaCie/wireless_space/wireless_space.c
+++ b/board/LaCie/wireless_space/wireless_space.c
@@ -112,7 +112,7 @@ int board_init(void)
 	gd->bd->bi_arch_number = CONFIG_MACH_TYPE;
 
 	/* Boot parameters address */
-	gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+	gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
 
 	return 0;
 }
diff --git a/board/Marvell/dreamplug/dreamplug.c b/board/Marvell/dreamplug/dreamplug.c
index 07b7496..0887d92 100644
--- a/board/Marvell/dreamplug/dreamplug.c
+++ b/board/Marvell/dreamplug/dreamplug.c
@@ -90,7 +90,7 @@ int board_early_init_f(void)
 int board_init(void)
 {
 	/* adress of boot parameters */
-	gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+	gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
 
 	return 0;
 }
diff --git a/board/Marvell/guruplug/guruplug.c b/board/Marvell/guruplug/guruplug.c
index b18a306..b0d5f1e 100644
--- a/board/Marvell/guruplug/guruplug.c
+++ b/board/Marvell/guruplug/guruplug.c
@@ -92,7 +92,7 @@ int board_init(void)
 	gd->bd->bi_arch_number = MACH_TYPE_GURUPLUG;
 
 	/* adress of boot parameters */
-	gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+	gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
 
 	return 0;
 }
diff --git a/board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c b/board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c
index 97fb61b..ef08ad8 100644
--- a/board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c
+++ b/board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c
@@ -94,7 +94,7 @@ int board_init(void)
 	gd->bd->bi_arch_number = MACH_TYPE_MV88F6281GTW_GE;
 
 	/* adress of boot parameters */
-	gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+	gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
 
 	return 0;
 }
diff --git a/board/Marvell/openrd/openrd.c b/board/Marvell/openrd/openrd.c
index 52dd083..55cf525 100644
--- a/board/Marvell/openrd/openrd.c
+++ b/board/Marvell/openrd/openrd.c
@@ -104,7 +104,7 @@ int board_init(void)
 #endif
 
 	/* adress of boot parameters */
-	gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+	gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
 	return 0;
 }
 
diff --git a/board/Marvell/rd6281a/rd6281a.c b/board/Marvell/rd6281a/rd6281a.c
index df5fbea..b0020c9 100644
--- a/board/Marvell/rd6281a/rd6281a.c
+++ b/board/Marvell/rd6281a/rd6281a.c
@@ -93,7 +93,7 @@ int board_init(void)
 	gd->bd->bi_arch_number = MACH_TYPE_RD88F6281;
 
 	/* adress of boot parameters */
-	gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+	gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
 
 	return 0;
 }
diff --git a/board/Marvell/sheevaplug/sheevaplug.c b/board/Marvell/sheevaplug/sheevaplug.c
index 18eeb4c..8907fb5 100644
--- a/board/Marvell/sheevaplug/sheevaplug.c
+++ b/board/Marvell/sheevaplug/sheevaplug.c
@@ -92,7 +92,7 @@ int board_init(void)
 	gd->bd->bi_arch_number = MACH_TYPE_SHEEVAPLUG;
 
 	/* adress of boot parameters */
-	gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+	gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
 
 	return 0;
 }
diff --git a/board/Seagate/dockstar/dockstar.c b/board/Seagate/dockstar/dockstar.c
index 838f578..83ab1bc 100644
--- a/board/Seagate/dockstar/dockstar.c
+++ b/board/Seagate/dockstar/dockstar.c
@@ -96,7 +96,7 @@ int board_init(void)
 	gd->bd->bi_arch_number = MACH_TYPE_DOCKSTAR;
 
 	/* address of boot parameters */
-	gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+	gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
 
 	return 0;
 }
diff --git a/board/Seagate/goflexhome/goflexhome.c b/board/Seagate/goflexhome/goflexhome.c
index c3f4cbf..1f4fb92 100644
--- a/board/Seagate/goflexhome/goflexhome.c
+++ b/board/Seagate/goflexhome/goflexhome.c
@@ -98,7 +98,7 @@ int board_init(void)
 	gd->bd->bi_arch_number = MACH_TYPE_GOFLEXHOME;
 
 	/* address of boot parameters */
-	gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+	gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
 
 	return 0;
 }
diff --git a/board/buffalo/lsxl/lsxl.c b/board/buffalo/lsxl/lsxl.c
index 042132e..92292ae 100644
--- a/board/buffalo/lsxl/lsxl.c
+++ b/board/buffalo/lsxl/lsxl.c
@@ -167,7 +167,7 @@ static void set_led(int state)
 int board_init(void)
 {
 	/* address of boot parameters */
-	gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+	gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
 
 	set_led(LED_POWER_BLINKING);
 
diff --git a/board/cloudengines/pogo_e02/pogo_e02.c b/board/cloudengines/pogo_e02/pogo_e02.c
index 314834f..8309d06 100644
--- a/board/cloudengines/pogo_e02/pogo_e02.c
+++ b/board/cloudengines/pogo_e02/pogo_e02.c
@@ -64,7 +64,7 @@ int board_early_init_f(void)
 int board_init(void)
 {
 	/* Boot parameters address */
-	gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+	gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
 
 	return 0;
 }
diff --git a/board/d-link/dns325/dns325.c b/board/d-link/dns325/dns325.c
index fd23696..a022daf 100644
--- a/board/d-link/dns325/dns325.c
+++ b/board/d-link/dns325/dns325.c
@@ -92,7 +92,7 @@ int board_early_init_f(void)
 int board_init(void)
 {
 	/* Boot parameters address */
-	gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+	gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
 
 	return 0;
 }
diff --git a/board/iomega/iconnect/iconnect.c b/board/iomega/iconnect/iconnect.c
index 76c945a..086a473 100644
--- a/board/iomega/iconnect/iconnect.c
+++ b/board/iomega/iconnect/iconnect.c
@@ -87,7 +87,7 @@ int board_early_init_f(void)
 int board_init(void)
 {
 	/* adress of boot parameters */
-	gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+	gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
 
 	return 0;
 }
diff --git a/board/karo/tk71/tk71.c b/board/karo/tk71/tk71.c
index 7aec5f9..35546d2 100644
--- a/board/karo/tk71/tk71.c
+++ b/board/karo/tk71/tk71.c
@@ -97,7 +97,7 @@ int board_init(void)
 	gd->bd->bi_arch_number = CONFIG_MACH_TYPE;
 
 	/* adress of boot parameters */
-	gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+	gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
 
 	return 0;
 }
diff --git a/board/keymile/km_arm/km_arm.c b/board/keymile/km_arm/km_arm.c
index 6621464..1c7c108 100644
--- a/board/keymile/km_arm/km_arm.c
+++ b/board/keymile/km_arm/km_arm.c
@@ -226,7 +226,7 @@ int board_early_init_f(void)
 	writel(tmp & (~KM_KIRKWOOD_SOFT_I2C_GPIOS) , MVEBU_GPIO0_BASE + 4);
 #endif
 	/* adjust SDRAM size for bank 0 */
-	kw_sdram_size_adjust(0);
+	mvebu_sdram_size_adjust(0);
 	kirkwood_mpp_conf(kwmpp_config, NULL);
 	return 0;
 }
@@ -234,7 +234,7 @@ int board_early_init_f(void)
 int board_init(void)
 {
 	/* address of boot parameters */
-	gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+	gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
 
 	/*
 	 * The KM_FLASH_GPIO_PIN switches between using a
diff --git a/board/raidsonic/ib62x0/ib62x0.c b/board/raidsonic/ib62x0/ib62x0.c
index dbcfb43..f01fb1c 100644
--- a/board/raidsonic/ib62x0/ib62x0.c
+++ b/board/raidsonic/ib62x0/ib62x0.c
@@ -62,7 +62,7 @@ int board_early_init_f(void)
 int board_init(void)
 {
 	/* adress of boot parameters */
-	gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+	gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
 
 	return 0;
 }
-- 
2.0.1

^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 15/25] net: mvneta.c: Add support for the ethernet controller of the Marvell Armada XP SoC
  2014-06-27  9:54 [U-Boot] [PATCH v1 0/25] Add Marvell Armada XP MV78460 SoC support Stefan Roese
                   ` (13 preceding siblings ...)
  2014-06-27  9:55 ` [U-Boot] [PATCH v1 14/25] arm: kirkwood: Change naming of dram functions from km_foo() to mvebu_foo() Stefan Roese
@ 2014-06-27  9:55 ` Stefan Roese
  2014-06-27  9:55 ` [U-Boot] [PATCH v1 16/25] net: phy.h: Make PHY autonegotiation timeout configurable Stefan Roese
                   ` (10 subsequent siblings)
  25 siblings, 0 replies; 50+ messages in thread
From: Stefan Roese @ 2014-06-27  9:55 UTC (permalink / raw)
  To: u-boot

This patch adds support for the NETA ethernet controller which is integrated
in the Marvell Armada XP SoC's. This port is based on the Linux driver which
has been stripped of the in U-Boot unused portions.

Tested on the Marvell MV78460 eval board db-78460-bp.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Joe Hershberger <joe.hershberger@gmail.com>
---

 drivers/net/Makefile |    1 +
 drivers/net/mvneta.c | 1653 ++++++++++++++++++++++++++++++++++++++++++++++++++
 include/netdev.h     |    1 +
 3 files changed, 1655 insertions(+)
 create mode 100644 drivers/net/mvneta.c

diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 6005f7e..a30254d 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -39,6 +39,7 @@ obj-$(CONFIG_MCFFEC) += mcffec.o mcfmii.o
 obj-$(CONFIG_MPC5xxx_FEC) += mpc5xxx_fec.o
 obj-$(CONFIG_MPC512x_FEC) += mpc512x_fec.o
 obj-$(CONFIG_MVGBE) += mvgbe.o
+obj-$(CONFIG_MVNETA) += mvneta.o
 obj-$(CONFIG_NATSEMI) += natsemi.o
 obj-$(CONFIG_DRIVER_NE2000) += ne2000.o ne2000_base.o
 obj-$(CONFIG_DRIVER_AX88796L) += ax88796.o ne2000_base.o
diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
new file mode 100644
index 0000000..a2a69b4
--- /dev/null
+++ b/drivers/net/mvneta.c
@@ -0,0 +1,1653 @@
+/*
+ * Driver for Marvell NETA network card for Armada XP and Armada 370 SoCs.
+ *
+ * U-Boot version:
+ * Copyright (C) 2014 Stefan Roese <sr@denx.de>
+ *
+ * Based on the Linux version which is:
+ * Copyright (C) 2012 Marvell
+ *
+ * Rami Rosen <rosenr@marvell.com>
+ * Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0
+ */
+
+#include <common.h>
+#include <net.h>
+#include <netdev.h>
+#include <config.h>
+#include <malloc.h>
+#include <asm/io.h>
+#include <asm/errno.h>
+#include <phy.h>
+#include <miiphy.h>
+#include <watchdog.h>
+#include <asm/arch/cpu.h>
+#include <asm/arch/soc.h>
+#include <linux/compat.h>
+#include <linux/mbus.h>
+
+#if !defined(CONFIG_PHYLIB)
+# error Marvell mvneta requires PHYLIB
+#endif
+
+/* Some linux -> U-Boot compatibility stuff */
+#define netdev_err(dev, fmt, args...)		\
+	printf(fmt, ##args)
+#define netdev_warn(dev, fmt, args...)		\
+	printf(fmt, ##args)
+#define netdev_info(dev, fmt, args...)		\
+	printf(fmt, ##args)
+
+#define CONFIG_NR_CPUS		1
+#define BIT(nr)			(1UL << (nr))
+#define ETH_HLEN		14	/* Total octets in header */
+
+/* 2(HW hdr) 14(MAC hdr) 4(CRC) 32(extra for cache prefetch) */
+#define WRAP			(2 + ETH_HLEN + 4 + 32)
+#define MTU			1500
+#define RX_BUFFER_SIZE		(ALIGN(MTU + WRAP, ARCH_DMA_MINALIGN))
+
+#define MVNETA_SMI_TIMEOUT			10000
+
+/* Registers */
+#define MVNETA_RXQ_CONFIG_REG(q)                (0x1400 + ((q) << 2))
+#define	     MVNETA_RXQ_HW_BUF_ALLOC            BIT(1)
+#define      MVNETA_RXQ_PKT_OFFSET_ALL_MASK     (0xf    << 8)
+#define      MVNETA_RXQ_PKT_OFFSET_MASK(offs)   ((offs) << 8)
+#define MVNETA_RXQ_THRESHOLD_REG(q)             (0x14c0 + ((q) << 2))
+#define      MVNETA_RXQ_NON_OCCUPIED(v)         ((v) << 16)
+#define MVNETA_RXQ_BASE_ADDR_REG(q)             (0x1480 + ((q) << 2))
+#define MVNETA_RXQ_SIZE_REG(q)                  (0x14a0 + ((q) << 2))
+#define      MVNETA_RXQ_BUF_SIZE_SHIFT          19
+#define      MVNETA_RXQ_BUF_SIZE_MASK           (0x1fff << 19)
+#define MVNETA_RXQ_STATUS_REG(q)                (0x14e0 + ((q) << 2))
+#define      MVNETA_RXQ_OCCUPIED_ALL_MASK       0x3fff
+#define MVNETA_RXQ_STATUS_UPDATE_REG(q)         (0x1500 + ((q) << 2))
+#define      MVNETA_RXQ_ADD_NON_OCCUPIED_SHIFT  16
+#define      MVNETA_RXQ_ADD_NON_OCCUPIED_MAX    255
+#define MVNETA_PORT_RX_RESET                    0x1cc0
+#define      MVNETA_PORT_RX_DMA_RESET           BIT(0)
+#define MVNETA_PHY_ADDR                         0x2000
+#define      MVNETA_PHY_ADDR_MASK               0x1f
+#define MVNETA_SMI                              0x2004
+#define      MVNETA_PHY_REG_MASK                0x1f
+/* SMI register fields */
+#define     MVNETA_SMI_DATA_OFFS		0	/* Data */
+#define     MVNETA_SMI_DATA_MASK		(0xffff << MVNETA_SMI_DATA_OFFS)
+#define     MVNETA_SMI_DEV_ADDR_OFFS		16	/* PHY device address */
+#define     MVNETA_SMI_REG_ADDR_OFFS		21	/* PHY device reg addr*/
+#define     MVNETA_SMI_OPCODE_OFFS		26	/* Write/Read opcode */
+#define     MVNETA_SMI_OPCODE_READ		(1 << MVNETA_SMI_OPCODE_OFFS)
+#define     MVNETA_SMI_READ_VALID		(1 << 27)	/* Read Valid */
+#define     MVNETA_SMI_BUSY			(1 << 28)	/* Busy */
+#define MVNETA_MBUS_RETRY                       0x2010
+#define MVNETA_UNIT_INTR_CAUSE                  0x2080
+#define MVNETA_UNIT_CONTROL                     0x20B0
+#define      MVNETA_PHY_POLLING_ENABLE          BIT(1)
+#define MVNETA_WIN_BASE(w)                      (0x2200 + ((w) << 3))
+#define MVNETA_WIN_SIZE(w)                      (0x2204 + ((w) << 3))
+#define MVNETA_WIN_REMAP(w)                     (0x2280 + ((w) << 2))
+#define MVNETA_BASE_ADDR_ENABLE                 0x2290
+#define MVNETA_PORT_CONFIG                      0x2400
+#define      MVNETA_UNI_PROMISC_MODE            BIT(0)
+#define      MVNETA_DEF_RXQ(q)                  ((q) << 1)
+#define      MVNETA_DEF_RXQ_ARP(q)              ((q) << 4)
+#define      MVNETA_TX_UNSET_ERR_SUM            BIT(12)
+#define      MVNETA_DEF_RXQ_TCP(q)              ((q) << 16)
+#define      MVNETA_DEF_RXQ_UDP(q)              ((q) << 19)
+#define      MVNETA_DEF_RXQ_BPDU(q)             ((q) << 22)
+#define      MVNETA_RX_CSUM_WITH_PSEUDO_HDR     BIT(25)
+#define      MVNETA_PORT_CONFIG_DEFL_VALUE(q)   (MVNETA_DEF_RXQ(q)       | \
+						 MVNETA_DEF_RXQ_ARP(q)	 | \
+						 MVNETA_DEF_RXQ_TCP(q)	 | \
+						 MVNETA_DEF_RXQ_UDP(q)	 | \
+						 MVNETA_DEF_RXQ_BPDU(q)	 | \
+						 MVNETA_TX_UNSET_ERR_SUM | \
+						 MVNETA_RX_CSUM_WITH_PSEUDO_HDR)
+#define MVNETA_PORT_CONFIG_EXTEND                0x2404
+#define MVNETA_MAC_ADDR_LOW                      0x2414
+#define MVNETA_MAC_ADDR_HIGH                     0x2418
+#define MVNETA_SDMA_CONFIG                       0x241c
+#define      MVNETA_SDMA_BRST_SIZE_16            4
+#define      MVNETA_RX_BRST_SZ_MASK(burst)       ((burst) << 1)
+#define      MVNETA_RX_NO_DATA_SWAP              BIT(4)
+#define      MVNETA_TX_NO_DATA_SWAP              BIT(5)
+#define      MVNETA_DESC_SWAP                    BIT(6)
+#define      MVNETA_TX_BRST_SZ_MASK(burst)       ((burst) << 22)
+#define MVNETA_PORT_STATUS                       0x2444
+#define      MVNETA_TX_IN_PRGRS                  BIT(1)
+#define      MVNETA_TX_FIFO_EMPTY                BIT(8)
+#define MVNETA_RX_MIN_FRAME_SIZE                 0x247c
+#define MVNETA_SERDES_CFG			 0x24A0
+#define      MVNETA_SGMII_SERDES_PROTO		 0x0cc7
+#define      MVNETA_QSGMII_SERDES_PROTO		 0x0667
+#define MVNETA_TYPE_PRIO                         0x24bc
+#define      MVNETA_FORCE_UNI                    BIT(21)
+#define MVNETA_TXQ_CMD_1                         0x24e4
+#define MVNETA_TXQ_CMD                           0x2448
+#define      MVNETA_TXQ_DISABLE_SHIFT            8
+#define      MVNETA_TXQ_ENABLE_MASK              0x000000ff
+#define MVNETA_ACC_MODE                          0x2500
+#define MVNETA_CPU_MAP(cpu)                      (0x2540 + ((cpu) << 2))
+#define      MVNETA_CPU_RXQ_ACCESS_ALL_MASK      0x000000ff
+#define      MVNETA_CPU_TXQ_ACCESS_ALL_MASK      0x0000ff00
+#define MVNETA_RXQ_TIME_COAL_REG(q)              (0x2580 + ((q) << 2))
+
+/* Exception Interrupt Port/Queue Cause register */
+
+#define MVNETA_INTR_NEW_CAUSE                    0x25a0
+#define MVNETA_INTR_NEW_MASK                     0x25a4
+
+/* bits  0..7  = TXQ SENT, one bit per queue.
+ * bits  8..15 = RXQ OCCUP, one bit per queue.
+ * bits 16..23 = RXQ FREE, one bit per queue.
+ * bit  29 = OLD_REG_SUM, see old reg ?
+ * bit  30 = TX_ERR_SUM, one bit for 4 ports
+ * bit  31 = MISC_SUM,   one bit for 4 ports
+ */
+#define      MVNETA_TX_INTR_MASK(nr_txqs)        (((1 << nr_txqs) - 1) << 0)
+#define      MVNETA_TX_INTR_MASK_ALL             (0xff << 0)
+#define      MVNETA_RX_INTR_MASK(nr_rxqs)        (((1 << nr_rxqs) - 1) << 8)
+#define      MVNETA_RX_INTR_MASK_ALL             (0xff << 8)
+
+#define MVNETA_INTR_OLD_CAUSE                    0x25a8
+#define MVNETA_INTR_OLD_MASK                     0x25ac
+
+/* Data Path Port/Queue Cause Register */
+#define MVNETA_INTR_MISC_CAUSE                   0x25b0
+#define MVNETA_INTR_MISC_MASK                    0x25b4
+#define MVNETA_INTR_ENABLE                       0x25b8
+
+#define MVNETA_RXQ_CMD                           0x2680
+#define      MVNETA_RXQ_DISABLE_SHIFT            8
+#define      MVNETA_RXQ_ENABLE_MASK              0x000000ff
+#define MVETH_TXQ_TOKEN_COUNT_REG(q)             (0x2700 + ((q) << 4))
+#define MVETH_TXQ_TOKEN_CFG_REG(q)               (0x2704 + ((q) << 4))
+#define MVNETA_GMAC_CTRL_0                       0x2c00
+#define      MVNETA_GMAC_MAX_RX_SIZE_SHIFT       2
+#define      MVNETA_GMAC_MAX_RX_SIZE_MASK        0x7ffc
+#define      MVNETA_GMAC0_PORT_ENABLE            BIT(0)
+#define MVNETA_GMAC_CTRL_2                       0x2c08
+#define      MVNETA_GMAC2_PCS_ENABLE             BIT(3)
+#define      MVNETA_GMAC2_PORT_RGMII             BIT(4)
+#define      MVNETA_GMAC2_PORT_RESET             BIT(6)
+#define MVNETA_GMAC_STATUS                       0x2c10
+#define      MVNETA_GMAC_LINK_UP                 BIT(0)
+#define      MVNETA_GMAC_SPEED_1000              BIT(1)
+#define      MVNETA_GMAC_SPEED_100               BIT(2)
+#define      MVNETA_GMAC_FULL_DUPLEX             BIT(3)
+#define      MVNETA_GMAC_RX_FLOW_CTRL_ENABLE     BIT(4)
+#define      MVNETA_GMAC_TX_FLOW_CTRL_ENABLE     BIT(5)
+#define      MVNETA_GMAC_RX_FLOW_CTRL_ACTIVE     BIT(6)
+#define      MVNETA_GMAC_TX_FLOW_CTRL_ACTIVE     BIT(7)
+#define MVNETA_GMAC_AUTONEG_CONFIG               0x2c0c
+#define      MVNETA_GMAC_FORCE_LINK_DOWN         BIT(0)
+#define      MVNETA_GMAC_FORCE_LINK_PASS         BIT(1)
+#define      MVNETA_GMAC_CONFIG_MII_SPEED        BIT(5)
+#define      MVNETA_GMAC_CONFIG_GMII_SPEED       BIT(6)
+#define      MVNETA_GMAC_AN_SPEED_EN             BIT(7)
+#define      MVNETA_GMAC_CONFIG_FULL_DUPLEX      BIT(12)
+#define      MVNETA_GMAC_AN_DUPLEX_EN            BIT(13)
+#define MVNETA_MIB_COUNTERS_BASE                 0x3080
+#define      MVNETA_MIB_LATE_COLLISION           0x7c
+#define MVNETA_DA_FILT_SPEC_MCAST                0x3400
+#define MVNETA_DA_FILT_OTH_MCAST                 0x3500
+#define MVNETA_DA_FILT_UCAST_BASE                0x3600
+#define MVNETA_TXQ_BASE_ADDR_REG(q)              (0x3c00 + ((q) << 2))
+#define MVNETA_TXQ_SIZE_REG(q)                   (0x3c20 + ((q) << 2))
+#define      MVNETA_TXQ_SENT_THRESH_ALL_MASK     0x3fff0000
+#define      MVNETA_TXQ_SENT_THRESH_MASK(coal)   ((coal) << 16)
+#define MVNETA_TXQ_UPDATE_REG(q)                 (0x3c60 + ((q) << 2))
+#define      MVNETA_TXQ_DEC_SENT_SHIFT           16
+#define MVNETA_TXQ_STATUS_REG(q)                 (0x3c40 + ((q) << 2))
+#define      MVNETA_TXQ_SENT_DESC_SHIFT          16
+#define      MVNETA_TXQ_SENT_DESC_MASK           0x3fff0000
+#define MVNETA_PORT_TX_RESET                     0x3cf0
+#define      MVNETA_PORT_TX_DMA_RESET            BIT(0)
+#define MVNETA_TX_MTU                            0x3e0c
+#define MVNETA_TX_TOKEN_SIZE                     0x3e14
+#define      MVNETA_TX_TOKEN_SIZE_MAX            0xffffffff
+#define MVNETA_TXQ_TOKEN_SIZE_REG(q)             (0x3e40 + ((q) << 2))
+#define      MVNETA_TXQ_TOKEN_SIZE_MAX           0x7fffffff
+
+/* Descriptor ring Macros */
+#define MVNETA_QUEUE_NEXT_DESC(q, index)	\
+	(((index) < (q)->last_desc) ? ((index) + 1) : 0)
+
+/* Various constants */
+
+/* Coalescing */
+#define MVNETA_TXDONE_COAL_PKTS		16
+#define MVNETA_RX_COAL_PKTS		32
+#define MVNETA_RX_COAL_USEC		100
+
+/* The two bytes Marvell header. Either contains a special value used
+ * by Marvell switches when a specific hardware mode is enabled (not
+ * supported by this driver) or is filled automatically by zeroes on
+ * the RX side. Those two bytes being at the front of the Ethernet
+ * header, they allow to have the IP header aligned on a 4 bytes
+ * boundary automatically: the hardware skips those two bytes on its
+ * own.
+ */
+#define MVNETA_MH_SIZE			2
+
+#define MVNETA_VLAN_TAG_LEN             4
+
+#define MVNETA_CPU_D_CACHE_LINE_SIZE    32
+#define MVNETA_TX_CSUM_MAX_SIZE		9800
+#define MVNETA_ACC_MODE_EXT		1
+
+/* Timeout constants */
+#define MVNETA_TX_DISABLE_TIMEOUT_MSEC	1000
+#define MVNETA_RX_DISABLE_TIMEOUT_MSEC	1000
+#define MVNETA_TX_FIFO_EMPTY_TIMEOUT	10000
+
+#define MVNETA_TX_MTU_MAX		0x3ffff
+
+/* Max number of Rx descriptors */
+#define MVNETA_MAX_RXD 16
+
+/* Max number of Tx descriptors */
+#define MVNETA_MAX_TXD 16
+
+/* descriptor aligned size */
+#define MVNETA_DESC_ALIGNED_SIZE	32
+
+struct mvneta_port {
+	void __iomem *base;
+	struct mvneta_rx_queue *rxqs;
+	struct mvneta_tx_queue *txqs;
+
+	u8 mcast_count[256];
+	u16 tx_ring_size;
+	u16 rx_ring_size;
+
+	phy_interface_t phy_interface;
+	unsigned int link;
+	unsigned int duplex;
+	unsigned int speed;
+
+	int init;
+	int phyaddr;
+	struct phy_device *phydev;
+	struct mii_dev *bus;
+};
+
+/* The mvneta_tx_desc and mvneta_rx_desc structures describe the
+ * layout of the transmit and reception DMA descriptors, and their
+ * layout is therefore defined by the hardware design
+ */
+
+#define MVNETA_TX_L3_OFF_SHIFT	0
+#define MVNETA_TX_IP_HLEN_SHIFT	8
+#define MVNETA_TX_L4_UDP	BIT(16)
+#define MVNETA_TX_L3_IP6	BIT(17)
+#define MVNETA_TXD_IP_CSUM	BIT(18)
+#define MVNETA_TXD_Z_PAD	BIT(19)
+#define MVNETA_TXD_L_DESC	BIT(20)
+#define MVNETA_TXD_F_DESC	BIT(21)
+#define MVNETA_TXD_FLZ_DESC	(MVNETA_TXD_Z_PAD  | \
+				 MVNETA_TXD_L_DESC | \
+				 MVNETA_TXD_F_DESC)
+#define MVNETA_TX_L4_CSUM_FULL	BIT(30)
+#define MVNETA_TX_L4_CSUM_NOT	BIT(31)
+
+#define MVNETA_RXD_ERR_CRC		0x0
+#define MVNETA_RXD_ERR_SUMMARY		BIT(16)
+#define MVNETA_RXD_ERR_OVERRUN		BIT(17)
+#define MVNETA_RXD_ERR_LEN		BIT(18)
+#define MVNETA_RXD_ERR_RESOURCE		(BIT(17) | BIT(18))
+#define MVNETA_RXD_ERR_CODE_MASK	(BIT(17) | BIT(18))
+#define MVNETA_RXD_L3_IP4		BIT(25)
+#define MVNETA_RXD_FIRST_LAST_DESC	(BIT(26) | BIT(27))
+#define MVNETA_RXD_L4_CSUM_OK		BIT(30)
+
+struct mvneta_tx_desc {
+	u32  command;		/* Options used by HW for packet transmitting.*/
+	u16  reserverd1;	/* csum_l4 (for future use)		*/
+	u16  data_size;		/* Data size of transmitted packet in bytes */
+	u32  buf_phys_addr;	/* Physical addr of transmitted buffer	*/
+	u32  reserved2;		/* hw_cmd - (for future use, PMT)	*/
+	u32  reserved3[4];	/* Reserved - (for future use)		*/
+};
+
+struct mvneta_rx_desc {
+	u32  status;		/* Info about received packet		*/
+	u16  reserved1;		/* pnc_info - (for future use, PnC)	*/
+	u16  data_size;		/* Size of received packet in bytes	*/
+
+	u32  buf_phys_addr;	/* Physical address of the buffer	*/
+	u32  reserved2;		/* pnc_flow_id  (for future use, PnC)	*/
+
+	u32  buf_cookie;	/* cookie for access to RX buffer in rx path */
+	u16  reserved3;		/* prefetch_cmd, for future use		*/
+	u16  reserved4;		/* csum_l4 - (for future use, PnC)	*/
+
+	u32  reserved5;		/* pnc_extra PnC (for future use, PnC)	*/
+	u32  reserved6;		/* hw_cmd (for future use, PnC and HWF)	*/
+};
+
+struct mvneta_tx_queue {
+	/* Number of this TX queue, in the range 0-7 */
+	u8 id;
+
+	/* Number of TX DMA descriptors in the descriptor ring */
+	int size;
+
+	/* Index of last TX DMA descriptor that was inserted */
+	int txq_put_index;
+
+	/* Index of the TX DMA descriptor to be cleaned up */
+	int txq_get_index;
+
+	/* Virtual address of the TX DMA descriptors array */
+	struct mvneta_tx_desc *descs;
+
+	/* DMA address of the TX DMA descriptors array */
+	dma_addr_t descs_phys;
+
+	/* Index of the last TX DMA descriptor */
+	int last_desc;
+
+	/* Index of the next TX DMA descriptor to process */
+	int next_desc_to_proc;
+};
+
+struct mvneta_rx_queue {
+	/* rx queue number, in the range 0-7 */
+	u8 id;
+
+	/* num of rx descriptors in the rx descriptor ring */
+	int size;
+
+	/* Virtual address of the RX DMA descriptors array */
+	struct mvneta_rx_desc *descs;
+
+	/* DMA address of the RX DMA descriptors array */
+	dma_addr_t descs_phys;
+
+	/* Index of the last RX DMA descriptor */
+	int last_desc;
+
+	/* Index of the next RX DMA descriptor to process */
+	int next_desc_to_proc;
+};
+
+/* U-Boot doesn't use the queues, so set the number to 1 */
+static int rxq_number = 1;
+static int txq_number = 1;
+static int rxq_def;
+
+struct buffer_location {
+	struct mvneta_tx_desc *tx_descs;
+	struct mvneta_rx_desc *rx_descs;
+	u32 rx_buffers;
+};
+
+/*
+ * All 4 interfaces use the same global buffer, since only one interface
+ * can be enabled at once
+ */
+static struct buffer_location buffer_loc;
+
+/*
+ * Page table entries are set to 1MB, or multiples of 1MB
+ * (not < 1MB). driver uses less bd's so use 1MB bdspace.
+ */
+#define BD_SPACE	(1 << 20)
+
+/* Utility/helper methods */
+
+/* Write helper method */
+static void mvreg_write(struct mvneta_port *pp, u32 offset, u32 data)
+{
+	writel(data, pp->base + offset);
+}
+
+/* Read helper method */
+static u32 mvreg_read(struct mvneta_port *pp, u32 offset)
+{
+	return readl(pp->base + offset);
+}
+
+/* Clear all MIB counters */
+static void mvneta_mib_counters_clear(struct mvneta_port *pp)
+{
+	int i;
+
+	/* Perform dummy reads from MIB counters */
+	for (i = 0; i < MVNETA_MIB_LATE_COLLISION; i += 4)
+		mvreg_read(pp, (MVNETA_MIB_COUNTERS_BASE + i));
+}
+
+/* Rx descriptors helper methods */
+
+/* Checks whether the RX descriptor having this status is both the first
+ * and the last descriptor for the RX packet. Each RX packet is currently
+ * received through a single RX descriptor, so not having each RX
+ * descriptor with its first and last bits set is an error
+ */
+static int mvneta_rxq_desc_is_first_last(u32 status)
+{
+	return (status & MVNETA_RXD_FIRST_LAST_DESC) ==
+		MVNETA_RXD_FIRST_LAST_DESC;
+}
+
+/* Add number of descriptors ready to receive new packets */
+static void mvneta_rxq_non_occup_desc_add(struct mvneta_port *pp,
+					  struct mvneta_rx_queue *rxq,
+					  int ndescs)
+{
+	/* Only MVNETA_RXQ_ADD_NON_OCCUPIED_MAX (255) descriptors can
+	 * be added@once
+	 */
+	while (ndescs > MVNETA_RXQ_ADD_NON_OCCUPIED_MAX) {
+		mvreg_write(pp, MVNETA_RXQ_STATUS_UPDATE_REG(rxq->id),
+			    (MVNETA_RXQ_ADD_NON_OCCUPIED_MAX <<
+			     MVNETA_RXQ_ADD_NON_OCCUPIED_SHIFT));
+		ndescs -= MVNETA_RXQ_ADD_NON_OCCUPIED_MAX;
+	}
+
+	mvreg_write(pp, MVNETA_RXQ_STATUS_UPDATE_REG(rxq->id),
+		    (ndescs << MVNETA_RXQ_ADD_NON_OCCUPIED_SHIFT));
+}
+
+/* Get number of RX descriptors occupied by received packets */
+static int mvneta_rxq_busy_desc_num_get(struct mvneta_port *pp,
+					struct mvneta_rx_queue *rxq)
+{
+	u32 val;
+
+	val = mvreg_read(pp, MVNETA_RXQ_STATUS_REG(rxq->id));
+	return val & MVNETA_RXQ_OCCUPIED_ALL_MASK;
+}
+
+/* Update num of rx desc called upon return from rx path or
+ * from mvneta_rxq_drop_pkts().
+ */
+static void mvneta_rxq_desc_num_update(struct mvneta_port *pp,
+				       struct mvneta_rx_queue *rxq,
+				       int rx_done, int rx_filled)
+{
+	u32 val;
+
+	if ((rx_done <= 0xff) && (rx_filled <= 0xff)) {
+		val = rx_done |
+		  (rx_filled << MVNETA_RXQ_ADD_NON_OCCUPIED_SHIFT);
+		mvreg_write(pp, MVNETA_RXQ_STATUS_UPDATE_REG(rxq->id), val);
+		return;
+	}
+
+	/* Only 255 descriptors can be added at once */
+	while ((rx_done > 0) || (rx_filled > 0)) {
+		if (rx_done <= 0xff) {
+			val = rx_done;
+			rx_done = 0;
+		} else {
+			val = 0xff;
+			rx_done -= 0xff;
+		}
+		if (rx_filled <= 0xff) {
+			val |= rx_filled << MVNETA_RXQ_ADD_NON_OCCUPIED_SHIFT;
+			rx_filled = 0;
+		} else {
+			val |= 0xff << MVNETA_RXQ_ADD_NON_OCCUPIED_SHIFT;
+			rx_filled -= 0xff;
+		}
+		mvreg_write(pp, MVNETA_RXQ_STATUS_UPDATE_REG(rxq->id), val);
+	}
+}
+
+/* Get pointer to next RX descriptor to be processed by SW */
+static struct mvneta_rx_desc *
+mvneta_rxq_next_desc_get(struct mvneta_rx_queue *rxq)
+{
+	int rx_desc = rxq->next_desc_to_proc;
+
+	rxq->next_desc_to_proc = MVNETA_QUEUE_NEXT_DESC(rxq, rx_desc);
+	return rxq->descs + rx_desc;
+}
+
+/* Tx descriptors helper methods */
+
+/* Update HW with number of TX descriptors to be sent */
+static void mvneta_txq_pend_desc_add(struct mvneta_port *pp,
+				     struct mvneta_tx_queue *txq,
+				     int pend_desc)
+{
+	u32 val;
+
+	/* Only 255 descriptors can be added at once ; Assume caller
+	 * process TX desriptors in quanta less than 256
+	 */
+	val = pend_desc;
+	mvreg_write(pp, MVNETA_TXQ_UPDATE_REG(txq->id), val);
+}
+
+/* Get pointer to next TX descriptor to be processed (send) by HW */
+static struct mvneta_tx_desc *
+mvneta_txq_next_desc_get(struct mvneta_tx_queue *txq)
+{
+	int tx_desc = txq->next_desc_to_proc;
+
+	txq->next_desc_to_proc = MVNETA_QUEUE_NEXT_DESC(txq, tx_desc);
+	return txq->descs + tx_desc;
+}
+
+/* Set rxq buf size */
+static void mvneta_rxq_buf_size_set(struct mvneta_port *pp,
+				    struct mvneta_rx_queue *rxq,
+				    int buf_size)
+{
+	u32 val;
+
+	val = mvreg_read(pp, MVNETA_RXQ_SIZE_REG(rxq->id));
+
+	val &= ~MVNETA_RXQ_BUF_SIZE_MASK;
+	val |= ((buf_size >> 3) << MVNETA_RXQ_BUF_SIZE_SHIFT);
+
+	mvreg_write(pp, MVNETA_RXQ_SIZE_REG(rxq->id), val);
+}
+
+/* Start the Ethernet port RX and TX activity */
+static void mvneta_port_up(struct mvneta_port *pp)
+{
+	int queue;
+	u32 q_map;
+
+	/* Enable all initialized TXs. */
+	mvneta_mib_counters_clear(pp);
+	q_map = 0;
+	for (queue = 0; queue < txq_number; queue++) {
+		struct mvneta_tx_queue *txq = &pp->txqs[queue];
+		if (txq->descs != NULL)
+			q_map |= (1 << queue);
+	}
+	mvreg_write(pp, MVNETA_TXQ_CMD, q_map);
+
+	/* Enable all initialized RXQs. */
+	q_map = 0;
+	for (queue = 0; queue < rxq_number; queue++) {
+		struct mvneta_rx_queue *rxq = &pp->rxqs[queue];
+		if (rxq->descs != NULL)
+			q_map |= (1 << queue);
+	}
+	mvreg_write(pp, MVNETA_RXQ_CMD, q_map);
+}
+
+/* Stop the Ethernet port activity */
+static void mvneta_port_down(struct mvneta_port *pp)
+{
+	u32 val;
+	int count;
+
+	/* Stop Rx port activity. Check port Rx activity. */
+	val = mvreg_read(pp, MVNETA_RXQ_CMD) & MVNETA_RXQ_ENABLE_MASK;
+
+	/* Issue stop command for active channels only */
+	if (val != 0)
+		mvreg_write(pp, MVNETA_RXQ_CMD,
+			    val << MVNETA_RXQ_DISABLE_SHIFT);
+
+	/* Wait for all Rx activity to terminate. */
+	count = 0;
+	do {
+		if (count++ >= MVNETA_RX_DISABLE_TIMEOUT_MSEC) {
+			netdev_warn(pp->dev,
+				    "TIMEOUT for RX stopped ! rx_queue_cmd: 0x08%x\n",
+				    val);
+			break;
+		}
+		mdelay(1);
+
+		val = mvreg_read(pp, MVNETA_RXQ_CMD);
+	} while (val & 0xff);
+
+	/* Stop Tx port activity. Check port Tx activity. Issue stop
+	 * command for active channels only
+	 */
+	val = (mvreg_read(pp, MVNETA_TXQ_CMD)) & MVNETA_TXQ_ENABLE_MASK;
+
+	if (val != 0)
+		mvreg_write(pp, MVNETA_TXQ_CMD,
+			    (val << MVNETA_TXQ_DISABLE_SHIFT));
+
+	/* Wait for all Tx activity to terminate. */
+	count = 0;
+	do {
+		if (count++ >= MVNETA_TX_DISABLE_TIMEOUT_MSEC) {
+			netdev_warn(pp->dev,
+				    "TIMEOUT for TX stopped status=0x%08x\n",
+				    val);
+			break;
+		}
+		mdelay(1);
+
+		/* Check TX Command reg that all Txqs are stopped */
+		val = mvreg_read(pp, MVNETA_TXQ_CMD);
+
+	} while (val & 0xff);
+
+	/* Double check to verify that TX FIFO is empty */
+	count = 0;
+	do {
+		if (count++ >= MVNETA_TX_FIFO_EMPTY_TIMEOUT) {
+			netdev_warn(pp->dev,
+				    "TX FIFO empty timeout status=0x08%x\n",
+				    val);
+			break;
+		}
+		mdelay(1);
+
+		val = mvreg_read(pp, MVNETA_PORT_STATUS);
+	} while (!(val & MVNETA_TX_FIFO_EMPTY) &&
+		 (val & MVNETA_TX_IN_PRGRS));
+
+	udelay(200);
+}
+
+/* Enable the port by setting the port enable bit of the MAC control register */
+static void mvneta_port_enable(struct mvneta_port *pp)
+{
+	u32 val;
+
+	/* Enable port */
+	val = mvreg_read(pp, MVNETA_GMAC_CTRL_0);
+	val |= MVNETA_GMAC0_PORT_ENABLE;
+	mvreg_write(pp, MVNETA_GMAC_CTRL_0, val);
+}
+
+/* Disable the port and wait for about 200 usec before retuning */
+static void mvneta_port_disable(struct mvneta_port *pp)
+{
+	u32 val;
+
+	/* Reset the Enable bit in the Serial Control Register */
+	val = mvreg_read(pp, MVNETA_GMAC_CTRL_0);
+	val &= ~MVNETA_GMAC0_PORT_ENABLE;
+	mvreg_write(pp, MVNETA_GMAC_CTRL_0, val);
+
+	udelay(200);
+}
+
+/* Multicast tables methods */
+
+/* Set all entries in Unicast MAC Table; queue==-1 means reject all */
+static void mvneta_set_ucast_table(struct mvneta_port *pp, int queue)
+{
+	int offset;
+	u32 val;
+
+	if (queue == -1) {
+		val = 0;
+	} else {
+		val = 0x1 | (queue << 1);
+		val |= (val << 24) | (val << 16) | (val << 8);
+	}
+
+	for (offset = 0; offset <= 0xc; offset += 4)
+		mvreg_write(pp, MVNETA_DA_FILT_UCAST_BASE + offset, val);
+}
+
+/* Set all entries in Special Multicast MAC Table; queue==-1 means reject all */
+static void mvneta_set_special_mcast_table(struct mvneta_port *pp, int queue)
+{
+	int offset;
+	u32 val;
+
+	if (queue == -1) {
+		val = 0;
+	} else {
+		val = 0x1 | (queue << 1);
+		val |= (val << 24) | (val << 16) | (val << 8);
+	}
+
+	for (offset = 0; offset <= 0xfc; offset += 4)
+		mvreg_write(pp, MVNETA_DA_FILT_SPEC_MCAST + offset, val);
+}
+
+/* Set all entries in Other Multicast MAC Table. queue==-1 means reject all */
+static void mvneta_set_other_mcast_table(struct mvneta_port *pp, int queue)
+{
+	int offset;
+	u32 val;
+
+	if (queue == -1) {
+		memset(pp->mcast_count, 0, sizeof(pp->mcast_count));
+		val = 0;
+	} else {
+		memset(pp->mcast_count, 1, sizeof(pp->mcast_count));
+		val = 0x1 | (queue << 1);
+		val |= (val << 24) | (val << 16) | (val << 8);
+	}
+
+	for (offset = 0; offset <= 0xfc; offset += 4)
+		mvreg_write(pp, MVNETA_DA_FILT_OTH_MCAST + offset, val);
+}
+
+/* This method sets defaults to the NETA port:
+ *	Clears interrupt Cause and Mask registers.
+ *	Clears all MAC tables.
+ *	Sets defaults to all registers.
+ *	Resets RX and TX descriptor rings.
+ *	Resets PHY.
+ * This method can be called after mvneta_port_down() to return the port
+ *	settings to defaults.
+ */
+static void mvneta_defaults_set(struct mvneta_port *pp)
+{
+	int cpu;
+	int queue;
+	u32 val;
+
+	/* Clear all Cause registers */
+	mvreg_write(pp, MVNETA_INTR_NEW_CAUSE, 0);
+	mvreg_write(pp, MVNETA_INTR_OLD_CAUSE, 0);
+	mvreg_write(pp, MVNETA_INTR_MISC_CAUSE, 0);
+
+	/* Mask all interrupts */
+	mvreg_write(pp, MVNETA_INTR_NEW_MASK, 0);
+	mvreg_write(pp, MVNETA_INTR_OLD_MASK, 0);
+	mvreg_write(pp, MVNETA_INTR_MISC_MASK, 0);
+	mvreg_write(pp, MVNETA_INTR_ENABLE, 0);
+
+	/* Enable MBUS Retry bit16 */
+	mvreg_write(pp, MVNETA_MBUS_RETRY, 0x20);
+
+	/* Set CPU queue access map - all CPUs have access to all RX
+	 * queues and to all TX queues
+	 */
+	for (cpu = 0; cpu < CONFIG_NR_CPUS; cpu++)
+		mvreg_write(pp, MVNETA_CPU_MAP(cpu),
+			    (MVNETA_CPU_RXQ_ACCESS_ALL_MASK |
+			     MVNETA_CPU_TXQ_ACCESS_ALL_MASK));
+
+	/* Reset RX and TX DMAs */
+	mvreg_write(pp, MVNETA_PORT_RX_RESET, MVNETA_PORT_RX_DMA_RESET);
+	mvreg_write(pp, MVNETA_PORT_TX_RESET, MVNETA_PORT_TX_DMA_RESET);
+
+	/* Disable Legacy WRR, Disable EJP, Release from reset */
+	mvreg_write(pp, MVNETA_TXQ_CMD_1, 0);
+	for (queue = 0; queue < txq_number; queue++) {
+		mvreg_write(pp, MVETH_TXQ_TOKEN_COUNT_REG(queue), 0);
+		mvreg_write(pp, MVETH_TXQ_TOKEN_CFG_REG(queue), 0);
+	}
+
+	mvreg_write(pp, MVNETA_PORT_TX_RESET, 0);
+	mvreg_write(pp, MVNETA_PORT_RX_RESET, 0);
+
+	/* Set Port Acceleration Mode */
+	val = MVNETA_ACC_MODE_EXT;
+	mvreg_write(pp, MVNETA_ACC_MODE, val);
+
+	/* Update val of portCfg register accordingly with all RxQueue types */
+	val = MVNETA_PORT_CONFIG_DEFL_VALUE(rxq_def);
+	mvreg_write(pp, MVNETA_PORT_CONFIG, val);
+
+	val = 0;
+	mvreg_write(pp, MVNETA_PORT_CONFIG_EXTEND, val);
+	mvreg_write(pp, MVNETA_RX_MIN_FRAME_SIZE, 64);
+
+	/* Build PORT_SDMA_CONFIG_REG */
+	val = 0;
+
+	/* Default burst size */
+	val |= MVNETA_TX_BRST_SZ_MASK(MVNETA_SDMA_BRST_SIZE_16);
+	val |= MVNETA_RX_BRST_SZ_MASK(MVNETA_SDMA_BRST_SIZE_16);
+	val |= MVNETA_RX_NO_DATA_SWAP | MVNETA_TX_NO_DATA_SWAP;
+
+	/* Assign port SDMA configuration */
+	mvreg_write(pp, MVNETA_SDMA_CONFIG, val);
+
+	/* Enable PHY polling in hardware for U-Boot */
+	val = mvreg_read(pp, MVNETA_UNIT_CONTROL);
+	val |= MVNETA_PHY_POLLING_ENABLE;
+	mvreg_write(pp, MVNETA_UNIT_CONTROL, val);
+
+	mvneta_set_ucast_table(pp, -1);
+	mvneta_set_special_mcast_table(pp, -1);
+	mvneta_set_other_mcast_table(pp, -1);
+}
+
+/* Set unicast address */
+static void mvneta_set_ucast_addr(struct mvneta_port *pp, u8 last_nibble,
+				  int queue)
+{
+	unsigned int unicast_reg;
+	unsigned int tbl_offset;
+	unsigned int reg_offset;
+
+	/* Locate the Unicast table entry */
+	last_nibble = (0xf & last_nibble);
+
+	/* offset from unicast tbl base */
+	tbl_offset = (last_nibble / 4) * 4;
+
+	/* offset within the above reg  */
+	reg_offset = last_nibble % 4;
+
+	unicast_reg = mvreg_read(pp, (MVNETA_DA_FILT_UCAST_BASE + tbl_offset));
+
+	if (queue == -1) {
+		/* Clear accepts frame bit@specified unicast DA tbl entry */
+		unicast_reg &= ~(0xff << (8 * reg_offset));
+	} else {
+		unicast_reg &= ~(0xff << (8 * reg_offset));
+		unicast_reg |= ((0x01 | (queue << 1)) << (8 * reg_offset));
+	}
+
+	mvreg_write(pp, (MVNETA_DA_FILT_UCAST_BASE + tbl_offset), unicast_reg);
+}
+
+/* Set mac address */
+static void mvneta_mac_addr_set(struct mvneta_port *pp, unsigned char *addr,
+				int queue)
+{
+	unsigned int mac_h;
+	unsigned int mac_l;
+
+	if (queue != -1) {
+		mac_l = (addr[4] << 8) | (addr[5]);
+		mac_h = (addr[0] << 24) | (addr[1] << 16) |
+			(addr[2] << 8) | (addr[3] << 0);
+
+		mvreg_write(pp, MVNETA_MAC_ADDR_LOW, mac_l);
+		mvreg_write(pp, MVNETA_MAC_ADDR_HIGH, mac_h);
+	}
+
+	/* Accept frames of this address */
+	mvneta_set_ucast_addr(pp, addr[5], queue);
+}
+
+/* Handle rx descriptor fill by setting buf_cookie and buf_phys_addr */
+static void mvneta_rx_desc_fill(struct mvneta_rx_desc *rx_desc,
+				u32 phys_addr, u32 cookie)
+{
+	rx_desc->buf_cookie = cookie;
+	rx_desc->buf_phys_addr = phys_addr;
+}
+
+/* Decrement sent descriptors counter */
+static void mvneta_txq_sent_desc_dec(struct mvneta_port *pp,
+				     struct mvneta_tx_queue *txq,
+				     int sent_desc)
+{
+	u32 val;
+
+	/* Only 255 TX descriptors can be updated at once */
+	while (sent_desc > 0xff) {
+		val = 0xff << MVNETA_TXQ_DEC_SENT_SHIFT;
+		mvreg_write(pp, MVNETA_TXQ_UPDATE_REG(txq->id), val);
+		sent_desc = sent_desc - 0xff;
+	}
+
+	val = sent_desc << MVNETA_TXQ_DEC_SENT_SHIFT;
+	mvreg_write(pp, MVNETA_TXQ_UPDATE_REG(txq->id), val);
+}
+
+/* Get number of TX descriptors already sent by HW */
+static int mvneta_txq_sent_desc_num_get(struct mvneta_port *pp,
+					struct mvneta_tx_queue *txq)
+{
+	u32 val;
+	int sent_desc;
+
+	val = mvreg_read(pp, MVNETA_TXQ_STATUS_REG(txq->id));
+	sent_desc = (val & MVNETA_TXQ_SENT_DESC_MASK) >>
+		MVNETA_TXQ_SENT_DESC_SHIFT;
+
+	return sent_desc;
+}
+
+/* Display more error info */
+static void mvneta_rx_error(struct mvneta_port *pp,
+			    struct mvneta_rx_desc *rx_desc)
+{
+	u32 status = rx_desc->status;
+
+	if (!mvneta_rxq_desc_is_first_last(status)) {
+		netdev_err(pp->dev,
+			   "bad rx status %08x (buffer oversize), size=%d\n",
+			   status, rx_desc->data_size);
+		return;
+	}
+
+	switch (status & MVNETA_RXD_ERR_CODE_MASK) {
+	case MVNETA_RXD_ERR_CRC:
+		netdev_err(pp->dev, "bad rx status %08x (crc error), size=%d\n",
+			   status, rx_desc->data_size);
+		break;
+	case MVNETA_RXD_ERR_OVERRUN:
+		netdev_err(pp->dev, "bad rx status %08x (overrun error), size=%d\n",
+			   status, rx_desc->data_size);
+		break;
+	case MVNETA_RXD_ERR_LEN:
+		netdev_err(pp->dev, "bad rx status %08x (max frame length error), size=%d\n",
+			   status, rx_desc->data_size);
+		break;
+	case MVNETA_RXD_ERR_RESOURCE:
+		netdev_err(pp->dev, "bad rx status %08x (resource error), size=%d\n",
+			   status, rx_desc->data_size);
+		break;
+	}
+}
+
+static struct mvneta_rx_queue *mvneta_rxq_handle_get(struct mvneta_port *pp,
+						     int rxq)
+{
+	return &pp->rxqs[rxq];
+}
+
+
+/* Drop packets received by the RXQ and free buffers */
+static void mvneta_rxq_drop_pkts(struct mvneta_port *pp,
+				 struct mvneta_rx_queue *rxq)
+{
+	int rx_done;
+
+	rx_done = mvneta_rxq_busy_desc_num_get(pp, rxq);
+	if (rx_done)
+		mvneta_rxq_desc_num_update(pp, rxq, rx_done, rx_done);
+}
+
+/* Handle rxq fill: allocates rxq skbs; called when initializing a port */
+static int mvneta_rxq_fill(struct mvneta_port *pp, struct mvneta_rx_queue *rxq,
+			   int num)
+{
+	int i;
+
+	for (i = 0; i < num; i++) {
+		u32 addr;
+
+		/* U-Boot special: Fill in the rx buffer addresses */
+		addr = buffer_loc.rx_buffers + (i * RX_BUFFER_SIZE);
+		mvneta_rx_desc_fill(rxq->descs + i, addr, addr);
+	}
+
+	/* Add this number of RX descriptors as non occupied (ready to
+	 * get packets)
+	 */
+	mvneta_rxq_non_occup_desc_add(pp, rxq, i);
+
+	return 0;
+}
+
+/* Rx/Tx queue initialization/cleanup methods */
+
+/* Create a specified RX queue */
+static int mvneta_rxq_init(struct mvneta_port *pp,
+			   struct mvneta_rx_queue *rxq)
+
+{
+	rxq->size = pp->rx_ring_size;
+
+	/* Allocate memory for RX descriptors */
+	rxq->descs_phys = (dma_addr_t)rxq->descs;
+	if (rxq->descs == NULL)
+		return -ENOMEM;
+
+	rxq->last_desc = rxq->size - 1;
+
+	/* Set Rx descriptors queue starting address */
+	mvreg_write(pp, MVNETA_RXQ_BASE_ADDR_REG(rxq->id), rxq->descs_phys);
+	mvreg_write(pp, MVNETA_RXQ_SIZE_REG(rxq->id), rxq->size);
+
+	/* Fill RXQ with buffers from RX pool */
+	mvneta_rxq_buf_size_set(pp, rxq, RX_BUFFER_SIZE);
+	mvneta_rxq_fill(pp, rxq, rxq->size);
+
+	return 0;
+}
+
+/* Cleanup Rx queue */
+static void mvneta_rxq_deinit(struct mvneta_port *pp,
+			      struct mvneta_rx_queue *rxq)
+{
+	mvneta_rxq_drop_pkts(pp, rxq);
+
+	rxq->descs             = NULL;
+	rxq->last_desc         = 0;
+	rxq->next_desc_to_proc = 0;
+	rxq->descs_phys        = 0;
+}
+
+/* Create and initialize a tx queue */
+static int mvneta_txq_init(struct mvneta_port *pp,
+			   struct mvneta_tx_queue *txq)
+{
+	txq->size = pp->tx_ring_size;
+
+	/* Allocate memory for TX descriptors */
+	txq->descs_phys = (u32)txq->descs;
+	if (txq->descs == NULL)
+		return -ENOMEM;
+
+	txq->last_desc = txq->size - 1;
+
+	/* Set maximum bandwidth for enabled TXQs */
+	mvreg_write(pp, MVETH_TXQ_TOKEN_CFG_REG(txq->id), 0x03ffffff);
+	mvreg_write(pp, MVETH_TXQ_TOKEN_COUNT_REG(txq->id), 0x3fffffff);
+
+	/* Set Tx descriptors queue starting address */
+	mvreg_write(pp, MVNETA_TXQ_BASE_ADDR_REG(txq->id), txq->descs_phys);
+	mvreg_write(pp, MVNETA_TXQ_SIZE_REG(txq->id), txq->size);
+
+	return 0;
+}
+
+/* Free allocated resources when mvneta_txq_init() fails to allocate memory*/
+static void mvneta_txq_deinit(struct mvneta_port *pp,
+			      struct mvneta_tx_queue *txq)
+{
+	txq->descs             = NULL;
+	txq->last_desc         = 0;
+	txq->next_desc_to_proc = 0;
+	txq->descs_phys        = 0;
+
+	/* Set minimum bandwidth for disabled TXQs */
+	mvreg_write(pp, MVETH_TXQ_TOKEN_CFG_REG(txq->id), 0);
+	mvreg_write(pp, MVETH_TXQ_TOKEN_COUNT_REG(txq->id), 0);
+
+	/* Set Tx descriptors queue starting address and size */
+	mvreg_write(pp, MVNETA_TXQ_BASE_ADDR_REG(txq->id), 0);
+	mvreg_write(pp, MVNETA_TXQ_SIZE_REG(txq->id), 0);
+}
+
+/* Cleanup all Tx queues */
+static void mvneta_cleanup_txqs(struct mvneta_port *pp)
+{
+	int queue;
+
+	for (queue = 0; queue < txq_number; queue++)
+		mvneta_txq_deinit(pp, &pp->txqs[queue]);
+}
+
+/* Cleanup all Rx queues */
+static void mvneta_cleanup_rxqs(struct mvneta_port *pp)
+{
+	int queue;
+
+	for (queue = 0; queue < rxq_number; queue++)
+		mvneta_rxq_deinit(pp, &pp->rxqs[queue]);
+}
+
+
+/* Init all Rx queues */
+static int mvneta_setup_rxqs(struct mvneta_port *pp)
+{
+	int queue;
+
+	for (queue = 0; queue < rxq_number; queue++) {
+		int err = mvneta_rxq_init(pp, &pp->rxqs[queue]);
+		if (err) {
+			netdev_err(pp->dev, "%s: can't create rxq=%d\n",
+				   __func__, queue);
+			mvneta_cleanup_rxqs(pp);
+			return err;
+		}
+	}
+
+	return 0;
+}
+
+/* Init all tx queues */
+static int mvneta_setup_txqs(struct mvneta_port *pp)
+{
+	int queue;
+
+	for (queue = 0; queue < txq_number; queue++) {
+		int err = mvneta_txq_init(pp, &pp->txqs[queue]);
+		if (err) {
+			netdev_err(pp->dev, "%s: can't create txq=%d\n",
+				   __func__, queue);
+			mvneta_cleanup_txqs(pp);
+			return err;
+		}
+	}
+
+	return 0;
+}
+
+static void mvneta_start_dev(struct mvneta_port *pp)
+{
+	/* start the Rx/Tx activity */
+	mvneta_port_enable(pp);
+}
+
+static void mvneta_adjust_link(struct eth_device *dev)
+{
+	struct mvneta_port *pp = dev->priv;
+	struct phy_device *phydev = pp->phydev;
+	int status_change = 0;
+
+	if (phydev->link) {
+		if ((pp->speed != phydev->speed) ||
+		    (pp->duplex != phydev->duplex)) {
+			u32 val;
+
+			val = mvreg_read(pp, MVNETA_GMAC_AUTONEG_CONFIG);
+			val &= ~(MVNETA_GMAC_CONFIG_MII_SPEED |
+				 MVNETA_GMAC_CONFIG_GMII_SPEED |
+				 MVNETA_GMAC_CONFIG_FULL_DUPLEX |
+				 MVNETA_GMAC_AN_SPEED_EN |
+				 MVNETA_GMAC_AN_DUPLEX_EN);
+
+			if (phydev->duplex)
+				val |= MVNETA_GMAC_CONFIG_FULL_DUPLEX;
+
+			if (phydev->speed == SPEED_1000)
+				val |= MVNETA_GMAC_CONFIG_GMII_SPEED;
+			else
+				val |= MVNETA_GMAC_CONFIG_MII_SPEED;
+
+			mvreg_write(pp, MVNETA_GMAC_AUTONEG_CONFIG, val);
+
+			pp->duplex = phydev->duplex;
+			pp->speed  = phydev->speed;
+		}
+	}
+
+	if (phydev->link != pp->link) {
+		if (!phydev->link) {
+			pp->duplex = -1;
+			pp->speed = 0;
+		}
+
+		pp->link = phydev->link;
+		status_change = 1;
+	}
+
+	if (status_change) {
+		if (phydev->link) {
+			u32 val = mvreg_read(pp, MVNETA_GMAC_AUTONEG_CONFIG);
+			val |= (MVNETA_GMAC_FORCE_LINK_PASS |
+				MVNETA_GMAC_FORCE_LINK_DOWN);
+			mvreg_write(pp, MVNETA_GMAC_AUTONEG_CONFIG, val);
+			mvneta_port_up(pp);
+		} else {
+			mvneta_port_down(pp);
+		}
+	}
+}
+
+static int mvneta_open(struct eth_device *dev)
+{
+	struct mvneta_port *pp = dev->priv;
+	int ret;
+
+	ret = mvneta_setup_rxqs(pp);
+	if (ret)
+		return ret;
+
+	ret = mvneta_setup_txqs(pp);
+	if (ret)
+		return ret;
+
+	mvneta_adjust_link(dev);
+
+	mvneta_start_dev(pp);
+
+	return 0;
+}
+
+/* Initialize hw */
+static int mvneta_init(struct mvneta_port *pp)
+{
+	int queue;
+
+	/* Disable port */
+	mvneta_port_disable(pp);
+
+	/* Set port default values */
+	mvneta_defaults_set(pp);
+
+	pp->txqs = kzalloc(txq_number * sizeof(struct mvneta_tx_queue),
+			   GFP_KERNEL);
+	if (!pp->txqs)
+		return -ENOMEM;
+
+	/* U-Boot special: use preallocated area */
+	pp->txqs[0].descs = buffer_loc.tx_descs;
+
+	/* Initialize TX descriptor rings */
+	for (queue = 0; queue < txq_number; queue++) {
+		struct mvneta_tx_queue *txq = &pp->txqs[queue];
+		txq->id = queue;
+		txq->size = pp->tx_ring_size;
+	}
+
+	pp->rxqs = kzalloc(rxq_number * sizeof(struct mvneta_rx_queue),
+			   GFP_KERNEL);
+	if (!pp->rxqs) {
+		kfree(pp->txqs);
+		return -ENOMEM;
+	}
+
+	/* U-Boot special: use preallocated area */
+	pp->rxqs[0].descs = buffer_loc.rx_descs;
+
+	/* Create Rx descriptor rings */
+	for (queue = 0; queue < rxq_number; queue++) {
+		struct mvneta_rx_queue *rxq = &pp->rxqs[queue];
+		rxq->id = queue;
+		rxq->size = pp->rx_ring_size;
+	}
+
+	return 0;
+}
+
+/* platform glue : initialize decoding windows */
+static void mvneta_conf_mbus_windows(struct mvneta_port *pp)
+{
+	const struct mbus_dram_target_info *dram;
+	u32 win_enable;
+	u32 win_protect;
+	int i;
+
+	dram = mvebu_mbus_dram_info();
+	for (i = 0; i < 6; i++) {
+		mvreg_write(pp, MVNETA_WIN_BASE(i), 0);
+		mvreg_write(pp, MVNETA_WIN_SIZE(i), 0);
+
+		if (i < 4)
+			mvreg_write(pp, MVNETA_WIN_REMAP(i), 0);
+	}
+
+	win_enable = 0x3f;
+	win_protect = 0;
+
+	for (i = 0; i < dram->num_cs; i++) {
+		const struct mbus_dram_window *cs = dram->cs + i;
+		mvreg_write(pp, MVNETA_WIN_BASE(i), (cs->base & 0xffff0000) |
+			    (cs->mbus_attr << 8) | dram->mbus_dram_target_id);
+
+		mvreg_write(pp, MVNETA_WIN_SIZE(i),
+			    (cs->size - 1) & 0xffff0000);
+
+		win_enable &= ~(1 << i);
+		win_protect |= 3 << (2 * i);
+	}
+
+	mvreg_write(pp, MVNETA_BASE_ADDR_ENABLE, win_enable);
+}
+
+/* Power up the port */
+static int mvneta_port_power_up(struct mvneta_port *pp, int phy_mode)
+{
+	u32 ctrl;
+
+	/* MAC Cause register should be cleared */
+	mvreg_write(pp, MVNETA_UNIT_INTR_CAUSE, 0);
+
+	ctrl = mvreg_read(pp, MVNETA_GMAC_CTRL_2);
+
+	/* Even though it might look weird, when we're configured in
+	 * SGMII or QSGMII mode, the RGMII bit needs to be set.
+	 */
+	switch (phy_mode) {
+	case PHY_INTERFACE_MODE_QSGMII:
+		mvreg_write(pp, MVNETA_SERDES_CFG, MVNETA_QSGMII_SERDES_PROTO);
+		ctrl |= MVNETA_GMAC2_PCS_ENABLE | MVNETA_GMAC2_PORT_RGMII;
+		break;
+	case PHY_INTERFACE_MODE_SGMII:
+		mvreg_write(pp, MVNETA_SERDES_CFG, MVNETA_SGMII_SERDES_PROTO);
+		ctrl |= MVNETA_GMAC2_PCS_ENABLE | MVNETA_GMAC2_PORT_RGMII;
+		break;
+	case PHY_INTERFACE_MODE_RGMII:
+	case PHY_INTERFACE_MODE_RGMII_ID:
+		ctrl |= MVNETA_GMAC2_PORT_RGMII;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	/* Cancel Port Reset */
+	ctrl &= ~MVNETA_GMAC2_PORT_RESET;
+	mvreg_write(pp, MVNETA_GMAC_CTRL_2, ctrl);
+
+	while ((mvreg_read(pp, MVNETA_GMAC_CTRL_2) &
+		MVNETA_GMAC2_PORT_RESET) != 0)
+		continue;
+
+	return 0;
+}
+
+/* Device initialization routine */
+static int mvneta_probe(struct eth_device *dev)
+{
+	struct mvneta_port *pp = dev->priv;
+	int err;
+
+	pp->tx_ring_size = MVNETA_MAX_TXD;
+	pp->rx_ring_size = MVNETA_MAX_RXD;
+
+	err = mvneta_init(pp);
+	if (err < 0) {
+		dev_err(&pdev->dev, "can't init eth hal\n");
+		return err;
+	}
+
+	mvneta_conf_mbus_windows(pp);
+
+	mvneta_mac_addr_set(pp, dev->enetaddr, rxq_def);
+
+	err = mvneta_port_power_up(pp, pp->phy_interface);
+	if (err < 0) {
+		dev_err(&pdev->dev, "can't power up port\n");
+		return err;
+	}
+
+	/* Call open() now as it needs to be done before runing send() */
+	mvneta_open(dev);
+
+	return 0;
+}
+
+/* U-Boot only functions follow here */
+
+/* SMI / MDIO functions */
+
+static int smi_wait_ready(struct mvneta_port *pp)
+{
+	u32 timeout = MVNETA_SMI_TIMEOUT;
+	u32 smi_reg;
+
+	/* wait till the SMI is not busy */
+	do {
+		/* read smi register */
+		smi_reg = mvreg_read(pp, MVNETA_SMI);
+		if (timeout-- == 0) {
+			printf("Error: SMI busy timeout\n");
+			return -EFAULT;
+		}
+	} while (smi_reg & MVNETA_SMI_BUSY);
+
+	return 0;
+}
+
+/*
+ * smi_reg_read - miiphy_read callback function.
+ *
+ * Returns 16bit phy register value, or 0xffff on error
+ */
+static int smi_reg_read(const char *devname, u8 phy_adr, u8 reg_ofs, u16 *data)
+{
+	struct eth_device *dev = eth_get_dev_by_name(devname);
+	struct mvneta_port *pp = dev->priv;
+	u32 smi_reg;
+	u32 timeout;
+
+	/* check parameters */
+	if (phy_adr > MVNETA_PHY_ADDR_MASK) {
+		printf("Error: Invalid PHY address %d\n", phy_adr);
+		return -EFAULT;
+	}
+
+	if (reg_ofs > MVNETA_PHY_REG_MASK) {
+		printf("Err: Invalid register offset %d\n", reg_ofs);
+		return -EFAULT;
+	}
+
+	/* wait till the SMI is not busy */
+	if (smi_wait_ready(pp) < 0)
+		return -EFAULT;
+
+	/* fill the phy address and regiser offset and read opcode */
+	smi_reg = (phy_adr << MVNETA_SMI_DEV_ADDR_OFFS)
+		| (reg_ofs << MVNETA_SMI_REG_ADDR_OFFS)
+		| MVNETA_SMI_OPCODE_READ;
+
+	/* write the smi register */
+	mvreg_write(pp, MVNETA_SMI, smi_reg);
+
+	/*wait till read value is ready */
+	timeout = MVNETA_SMI_TIMEOUT;
+
+	do {
+		/* read smi register */
+		smi_reg = mvreg_read(pp, MVNETA_SMI);
+		if (timeout-- == 0) {
+			printf("Err: SMI read ready timeout\n");
+			return -EFAULT;
+		}
+	} while (!(smi_reg & MVNETA_SMI_READ_VALID));
+
+	/* Wait for the data to update in the SMI register */
+	for (timeout = 0; timeout < MVNETA_SMI_TIMEOUT; timeout++)
+		;
+
+	*data = (u16)(mvreg_read(pp, MVNETA_SMI) & MVNETA_SMI_DATA_MASK);
+
+	return 0;
+}
+
+/*
+ * smi_reg_write - imiiphy_write callback function.
+ *
+ * Returns 0 if write succeed, -EINVAL on bad parameters
+ * -ETIME on timeout
+ */
+static int smi_reg_write(const char *devname, u8 phy_adr, u8 reg_ofs, u16 data)
+{
+	struct eth_device *dev = eth_get_dev_by_name(devname);
+	struct mvneta_port *pp = dev->priv;
+	u32 smi_reg;
+
+	/* check parameters */
+	if (phy_adr > MVNETA_PHY_ADDR_MASK) {
+		printf("Error: Invalid PHY address %d\n", phy_adr);
+		return -EFAULT;
+	}
+
+	if (reg_ofs > MVNETA_PHY_REG_MASK) {
+		printf("Err: Invalid register offset %d\n", reg_ofs);
+		return -EFAULT;
+	}
+
+	/* wait till the SMI is not busy */
+	if (smi_wait_ready(pp) < 0)
+		return -EFAULT;
+
+	/* fill the phy addr and reg offset and write opcode and data */
+	smi_reg = (data << MVNETA_SMI_DATA_OFFS);
+	smi_reg |= (phy_adr << MVNETA_SMI_DEV_ADDR_OFFS)
+		| (reg_ofs << MVNETA_SMI_REG_ADDR_OFFS);
+	smi_reg &= ~MVNETA_SMI_OPCODE_READ;
+
+	/* write the smi register */
+	mvreg_write(pp, MVNETA_SMI, smi_reg);
+
+	return 0;
+}
+
+static int mvneta_init_u_boot(struct eth_device *dev, bd_t *bis)
+{
+	struct mvneta_port *pp = dev->priv;
+	struct phy_device *phydev;
+
+	mvneta_port_power_up(pp, pp->phy_interface);
+
+	if (!pp->init || pp->link == 0) {
+		/* Set phy address of the port */
+		mvreg_write(pp, MVNETA_PHY_ADDR, pp->phyaddr);
+		phydev = phy_connect(pp->bus, pp->phyaddr, dev,
+				     pp->phy_interface);
+
+		pp->phydev = phydev;
+		phy_config(phydev);
+		phy_startup(phydev);
+		if (!phydev->link) {
+			printf("%s: No link.\n", phydev->dev->name);
+			return -1;
+		}
+
+		/* Full init on first call */
+		mvneta_probe(dev);
+		pp->init = 1;
+	} else {
+		/* Upon all following calls, this is enough */
+		mvneta_port_up(pp);
+		mvneta_port_enable(pp);
+	}
+
+	return 0;
+}
+
+static int mvneta_send(struct eth_device *dev, void *ptr, int len)
+{
+	struct mvneta_port *pp = dev->priv;
+	struct mvneta_tx_queue *txq = &pp->txqs[0];
+	struct mvneta_tx_desc *tx_desc;
+	int sent_desc;
+	u32 timeout = 0;
+
+	/* Get a descriptor for the first part of the packet */
+	tx_desc = mvneta_txq_next_desc_get(txq);
+
+	tx_desc->buf_phys_addr = (u32)ptr;
+	tx_desc->data_size = len;
+	flush_dcache_range((u32)ptr, (u32)ptr + len);
+
+	/* First and Last descriptor */
+	tx_desc->command = MVNETA_TX_L4_CSUM_NOT | MVNETA_TXD_FLZ_DESC;
+	mvneta_txq_pend_desc_add(pp, txq, 1);
+
+	/* Wait for packet to be sent (queue might help with speed here) */
+	sent_desc = mvneta_txq_sent_desc_num_get(pp, txq);
+	while (!sent_desc) {
+		if (timeout++ > 10000) {
+			printf("timeout: packet not sent\n");
+			return -1;
+		}
+		sent_desc = mvneta_txq_sent_desc_num_get(pp, txq);
+	}
+
+	/* txDone has increased - hw sent packet */
+	mvneta_txq_sent_desc_dec(pp, txq, sent_desc);
+	return 0;
+
+	return 0;
+}
+
+static int mvneta_recv(struct eth_device *dev)
+{
+	struct mvneta_port *pp = dev->priv;
+	int rx_done;
+	int packets_done;
+	struct mvneta_rx_queue *rxq;
+
+	/* get rx queue */
+	rxq = mvneta_rxq_handle_get(pp, rxq_def);
+	rx_done = mvneta_rxq_busy_desc_num_get(pp, rxq);
+	packets_done = rx_done;
+
+	while (packets_done--) {
+		struct mvneta_rx_desc *rx_desc;
+		unsigned char *data;
+		u32 rx_status;
+		int rx_bytes;
+
+		/*
+		 * No cache invalidation needed here, since the desc's are
+		 * located in a uncached memory region
+		 */
+		rx_desc = mvneta_rxq_next_desc_get(rxq);
+
+		rx_status = rx_desc->status;
+		if (!mvneta_rxq_desc_is_first_last(rx_status) ||
+		    (rx_status & MVNETA_RXD_ERR_SUMMARY)) {
+			mvneta_rx_error(pp, rx_desc);
+			/* leave the descriptor untouched */
+			continue;
+		}
+
+		/* 2 bytes for marvell header. 4 bytes for crc */
+		rx_bytes = rx_desc->data_size - 6;
+
+		/* give packet to stack - skip on first 2 bytes */
+		data = (u8 *)rx_desc->buf_cookie + 2;
+		/*
+		 * No cache invalidation needed here, since the rx_buffer's are
+		 * located in a uncached memory region
+		 */
+		NetReceive(data, rx_bytes);
+	}
+
+	/* Update rxq management counters */
+	if (rx_done)
+		mvneta_rxq_desc_num_update(pp, rxq, rx_done, rx_done);
+
+	return 0;
+}
+
+static void mvneta_halt(struct eth_device *dev)
+{
+	struct mvneta_port *pp = dev->priv;
+
+	mvneta_port_down(pp);
+	mvneta_port_disable(pp);
+}
+
+int mvneta_initialize(bd_t *bis, int base_addr, int devnum, int phy_addr)
+{
+	struct eth_device *dev;
+	struct mvneta_port *pp;
+	void *bd_space;
+
+	dev = calloc(1, sizeof(*dev));
+	if (dev == NULL)
+		return -ENOMEM;
+
+	pp = calloc(1, sizeof(*pp));
+	if (pp == NULL)
+		return -ENOMEM;
+
+	dev->priv = pp;
+
+	/*
+	 * Allocate buffer area for descs and rx_buffers. This is only
+	 * done once for all interfaces. As only one interface can
+	 * be active. Make this area DMA save by disabling the D-cache
+	 */
+	if (!buffer_loc.tx_descs) {
+		/* Align buffer area for descs and rx_buffers to 1MiB */
+		bd_space = memalign(1 << MMU_SECTION_SHIFT, BD_SPACE);
+		mmu_set_region_dcache_behaviour((u32)bd_space, BD_SPACE,
+						DCACHE_OFF);
+		buffer_loc.tx_descs = (struct mvneta_tx_desc *)bd_space;
+		buffer_loc.rx_descs = (struct mvneta_rx_desc *)
+			((u32)bd_space +
+			 MVNETA_MAX_TXD * sizeof(struct mvneta_tx_desc));
+		buffer_loc.rx_buffers = (u32)
+			(bd_space +
+			 MVNETA_MAX_TXD * sizeof(struct mvneta_tx_desc) +
+			 MVNETA_MAX_RXD * sizeof(struct mvneta_rx_desc));
+	}
+
+	sprintf(dev->name, "neta%d", devnum);
+
+	pp->base = (void __iomem *)base_addr;
+	dev->iobase = base_addr;
+	dev->init = mvneta_init_u_boot;
+	dev->halt = mvneta_halt;
+	dev->send = mvneta_send;
+	dev->recv = mvneta_recv;
+	dev->write_hwaddr = NULL;
+
+	/*
+	 * The PHY interface type is configured via the
+	 * board specific CONFIG_SYS_NETA_INTERFACE_TYPE
+	 * define.
+	 */
+	pp->phy_interface = CONFIG_SYS_NETA_INTERFACE_TYPE;
+
+	eth_register(dev);
+
+	pp->phyaddr = phy_addr;
+	miiphy_register(dev->name, smi_reg_read, smi_reg_write);
+	pp->bus = miiphy_get_dev_by_name(dev->name);
+
+	return 1;
+}
diff --git a/include/netdev.h b/include/netdev.h
index 63481ec..0d07e33 100644
--- a/include/netdev.h
+++ b/include/netdev.h
@@ -64,6 +64,7 @@ int mpc512x_fec_initialize(bd_t *bis);
 int mpc5xxx_fec_initialize(bd_t *bis);
 int mpc82xx_scc_enet_initialize(bd_t *bis);
 int mvgbe_initialize(bd_t *bis);
+int mvneta_initialize(bd_t *bis, int base_addr, int devnum, int phy_addr);
 int natsemi_initialize(bd_t *bis);
 int ne2k_register(void);
 int npe_initialize(bd_t *bis);
-- 
2.0.1

^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 16/25] net: phy.h: Make PHY autonegotiation timeout configurable
  2014-06-27  9:54 [U-Boot] [PATCH v1 0/25] Add Marvell Armada XP MV78460 SoC support Stefan Roese
                   ` (14 preceding siblings ...)
  2014-06-27  9:55 ` [U-Boot] [PATCH v1 15/25] net: mvneta.c: Add support for the ethernet controller of the Marvell Armada XP SoC Stefan Roese
@ 2014-06-27  9:55 ` Stefan Roese
  2014-06-27  9:55 ` [U-Boot] [PATCH v1 17/25] i2c: mvtwsi: Add support for Marvell Armada XP Stefan Roese
                   ` (9 subsequent siblings)
  25 siblings, 0 replies; 50+ messages in thread
From: Stefan Roese @ 2014-06-27  9:55 UTC (permalink / raw)
  To: u-boot

The Marvell MV78460 eval board DB-78460-BP seems to need a longer
PHY autonegotiation timeout than the "standard" 4 seconds. So lets
make this timeout configurable. If not defined in the board config
header the original 4000ms is used.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Joe Hershberger <joe.hershberger@gmail.com>
---

 include/phy.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/phy.h b/include/phy.h
index d3ecd63..713742e 100644
--- a/include/phy.h
+++ b/include/phy.h
@@ -32,7 +32,9 @@
 #define PHY_10G_FEATURES	(PHY_GBIT_FEATURES | \
 				SUPPORTED_10000baseT_Full)
 
+#ifndef PHY_ANEG_TIMEOUT
 #define PHY_ANEG_TIMEOUT	4000
+#endif
 
 
 typedef enum {
-- 
2.0.1

^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 17/25] i2c: mvtwsi: Add support for Marvell Armada XP
  2014-06-27  9:54 [U-Boot] [PATCH v1 0/25] Add Marvell Armada XP MV78460 SoC support Stefan Roese
                   ` (15 preceding siblings ...)
  2014-06-27  9:55 ` [U-Boot] [PATCH v1 16/25] net: phy.h: Make PHY autonegotiation timeout configurable Stefan Roese
@ 2014-06-27  9:55 ` Stefan Roese
  2014-07-01  5:48   ` Heiko Schocher
  2014-06-27  9:55 ` [U-Boot] [PATCH v1 18/25] arm: armada-xp: Add basic support for Marvell Armada XP SoC Stefan Roese
                   ` (8 subsequent siblings)
  25 siblings, 1 reply; 50+ messages in thread
From: Stefan Roese @ 2014-06-27  9:55 UTC (permalink / raw)
  To: u-boot

To support the Armada XP SoC, we just need to include the correct header.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Heiko Schocher <hs@denx.de>
---

 drivers/i2c/mvtwsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/mvtwsi.c b/drivers/i2c/mvtwsi.c
index 4a49291..7cbf109 100644
--- a/drivers/i2c/mvtwsi.c
+++ b/drivers/i2c/mvtwsi.c
@@ -20,7 +20,7 @@
 
 #if defined(CONFIG_ORION5X)
 #include <asm/arch/orion5x.h>
-#elif defined(CONFIG_KIRKWOOD)
+#elif (defined(CONFIG_KIRKWOOD) || defined(CONFIG_ARMADA_XP))
 #include <asm/arch/soc.h>
 #else
 #error Driver mvtwsi not supported by SoC or board
-- 
2.0.1

^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 18/25] arm: armada-xp: Add basic support for Marvell Armada XP SoC
  2014-06-27  9:54 [U-Boot] [PATCH v1 0/25] Add Marvell Armada XP MV78460 SoC support Stefan Roese
                   ` (16 preceding siblings ...)
  2014-06-27  9:55 ` [U-Boot] [PATCH v1 17/25] i2c: mvtwsi: Add support for Marvell Armada XP Stefan Roese
@ 2014-06-27  9:55 ` Stefan Roese
  2014-06-27  9:55 ` [U-Boot] [PATCH v1 19/25] arm: armada-xp: Add basic support for the Marvell DB-78460-BP board Stefan Roese
                   ` (7 subsequent siblings)
  25 siblings, 0 replies; 50+ messages in thread
From: Stefan Roese @ 2014-06-27  9:55 UTC (permalink / raw)
  To: u-boot

This basic support for the Marvell Armada XP is base on the existing kirkwood
support. Which has been generatized by moving some common files into
common marvell locations.

This is in preparation for the upcoming Armada XP MV78460 support.

Signed-off-by: Stefan Roese <sr@denx.de>
---

 Makefile                                     |   2 +-
 arch/arm/cpu/armv7/armada-xp/Makefile        |   7 +
 arch/arm/cpu/armv7/armada-xp/cpu.c           | 186 +++++++++++++++++++++++++++
 arch/arm/include/asm/arch-armada-xp/config.h |  80 ++++++++++++
 arch/arm/include/asm/arch-armada-xp/cpu.h    | 103 +++++++++++++++
 arch/arm/include/asm/arch-armada-xp/soc.h    |  57 ++++++++
 6 files changed, 434 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/cpu/armv7/armada-xp/Makefile
 create mode 100644 arch/arm/cpu/armv7/armada-xp/cpu.c
 create mode 100644 arch/arm/include/asm/arch-armada-xp/config.h
 create mode 100644 arch/arm/include/asm/arch-armada-xp/cpu.h
 create mode 100644 arch/arm/include/asm/arch-armada-xp/soc.h

diff --git a/Makefile b/Makefile
index 106840a..e45a25c 100644
--- a/Makefile
+++ b/Makefile
@@ -636,7 +636,7 @@ ifneq (,$(filter $(SOC), mx25 mx27 mx5 mx6 mx31 mx35 mxs vf610))
 libs-y += arch/$(ARCH)/imx-common/
 endif
 
-ifneq (,$(filter $(SOC), kirkwood))
+ifneq (,$(filter $(SOC), armada-xp kirkwood))
 libs-y += arch/$(ARCH)/mvebu-common/
 endif
 
diff --git a/arch/arm/cpu/armv7/armada-xp/Makefile b/arch/arm/cpu/armv7/armada-xp/Makefile
new file mode 100644
index 0000000..885dcee
--- /dev/null
+++ b/arch/arm/cpu/armv7/armada-xp/Makefile
@@ -0,0 +1,7 @@
+#
+# Copyright (C) 2014 Stefan Roese <sr@denx.de>
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+obj-y	= cpu.o
diff --git a/arch/arm/cpu/armv7/armada-xp/cpu.c b/arch/arm/cpu/armv7/armada-xp/cpu.c
new file mode 100644
index 0000000..3ad43d2
--- /dev/null
+++ b/arch/arm/cpu/armv7/armada-xp/cpu.c
@@ -0,0 +1,186 @@
+/*
+ * Copyright (C) 2014 Stefan Roese <sr@denx.de>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <netdev.h>
+#include <asm/io.h>
+#include <asm/arch/cpu.h>
+#include <asm/arch/soc.h>
+
+#define DDR_BASE_CS_OFF(n)	(0x0000 + ((n) << 3))
+#define DDR_SIZE_CS_OFF(n)	(0x0004 + ((n) << 3))
+
+static struct mbus_win windows[] = {
+	/* PCIE MEM address space */
+	{ DEFADR_PCI_MEM, 256 << 20, CPU_TARGET_PCIE13, CPU_ATTR_PCIE_MEM },
+
+	/* PCIE IO address space */
+	{ DEFADR_PCI_IO, 64 << 10, CPU_TARGET_PCIE13, CPU_ATTR_PCIE_IO },
+
+	/* SPI */
+	{ DEFADR_SPIF, 8 << 20, CPU_TARGET_DEVICEBUS_BOOTROM_SPI,
+	  CPU_ATTR_SPIFLASH },
+
+	/* NOR */
+	{ DEFADR_BOOTROM, 8 << 20, CPU_TARGET_DEVICEBUS_BOOTROM_SPI,
+	  CPU_ATTR_BOOTROM },
+};
+
+void reset_cpu(unsigned long ignored)
+{
+	struct mvebu_system_registers *reg =
+		(struct mvebu_system_registers *)MVEBU_SYSTEM_REG_BASE;
+
+	writel(readl(&reg->rstoutn_mask) | 1, &reg->rstoutn_mask);
+	writel(readl(&reg->sys_soft_rst) | 1, &reg->sys_soft_rst);
+	while (1)
+		;
+}
+
+#if defined(CONFIG_DISPLAY_CPUINFO)
+int print_cpuinfo(void)
+{
+	u16 devid = (readl(MVEBU_REG_PCIE_DEVID) >> 16) & 0xffff;
+	u8 revid = readl(MVEBU_REG_PCIE_REVID) & 0xff;
+
+	puts("SoC:   ");
+
+	switch (devid) {
+	case SOC_MV78460_ID:
+		puts("MV78460-");
+		break;
+	default:
+		puts("Unknown-");
+		break;
+	}
+
+	switch (revid) {
+	case 1:
+		puts("A0\n");
+		break;
+	case 2:
+		puts("B0\n");
+		break;
+	default:
+		puts("??\n");
+		break;
+	}
+
+	return 0;
+}
+#endif /* CONFIG_DISPLAY_CPUINFO */
+
+/*
+ * This function initialize Controller DRAM Fastpath windows.
+ * It takes the CS size information from the 0x1500 scratch registers
+ * and sets the correct windows sizes and base addresses accordingly.
+ *
+ * These values are set in the scratch registers by the Marvell
+ * DDR3 training code, which is executed by the BootROM before the
+ * main payload (U-Boot) is executed. This training code is currently
+ * only available in the Marvell U-Boot version. It needs to be
+ * ported to mainline U-Boot SPL at some point.
+ */
+static void update_sdram_window_sizes(void)
+{
+	u64 base = 0;
+	u32 size, temp;
+	int i;
+
+	for (i = 0; i < SDRAM_MAX_CS; i++) {
+		size = readl((MVEBU_SDRAM_SCRATCH + (i * 8))) & SDRAM_ADDR_MASK;
+		if (size != 0) {
+			size |= ~(SDRAM_ADDR_MASK);
+
+			/* Set Base Address */
+			temp = (base & 0xFF000000ll) | ((base >> 32) & 0xF);
+			writel(temp, MVEBU_SDRAM_BASE + DDR_BASE_CS_OFF(i));
+
+			/*
+			 * Check if out of max window size and resize
+			 * the window
+			 */
+			temp = (readl(MVEBU_SDRAM_BASE + DDR_SIZE_CS_OFF(i)) &
+				~(SDRAM_ADDR_MASK)) | 1;
+			temp |= (size & SDRAM_ADDR_MASK);
+			writel(temp, MVEBU_SDRAM_BASE + DDR_SIZE_CS_OFF(i));
+
+			base += ((u64)size + 1);
+		}
+	}
+}
+
+#ifdef CONFIG_ARCH_CPU_INIT
+int arch_cpu_init(void)
+{
+	/* Linux expects the internal registers to be at 0xf1000000 */
+	writel(SOC_REGS_PHY_BASE, INTREG_BASE_ADDR_REG);
+
+	/*
+	 * We need to call mvebu_mbus_probe() before calling
+	 * update_sdram_window_sizes() as it disables all previously
+	 * configured mbus windows and then configures them as
+	 * required for U-Boot. Calling update_sdram_window_sizes()
+	 * without this configuration will not work, as the internal
+	 * registers can't be accessed reliably because of potenial
+	 * double mapping.
+	 * After updating the SDRAM access windows we need to call
+	 * mvebu_mbus_probe() again, as this now correctly configures
+	 * the SDRAM areas that are later used by the MVEBU drivers
+	 * (e.g. USB, NETA).
+	 */
+
+	/*
+	 * First disable all windows
+	 */
+	mvebu_mbus_probe(NULL, 0);
+
+	/*
+	 * Now the SDRAM access windows can be reconfigured using
+	 * the information in the SDRAM scratch pad registers
+	 */
+	update_sdram_window_sizes();
+
+	/*
+	 * Finally the mbus windows can be configured with the
+	 * updated SDRAM sizes
+	 */
+	mvebu_mbus_probe(windows, ARRAY_SIZE(windows));
+
+	return 0;
+}
+#endif /* CONFIG_ARCH_CPU_INIT */
+
+/*
+ * SOC specific misc init
+ */
+#if defined(CONFIG_ARCH_MISC_INIT)
+int arch_misc_init(void)
+{
+	/* Nothing yet, perhaps we need something here later */
+	return 0;
+}
+#endif /* CONFIG_ARCH_MISC_INIT */
+
+#ifdef CONFIG_MVNETA
+int cpu_eth_init(bd_t *bis)
+{
+	mvneta_initialize(bis, MVEBU_EGIGA0_BASE, 0, CONFIG_PHY_BASE_ADDR + 0);
+	mvneta_initialize(bis, MVEBU_EGIGA1_BASE, 1, CONFIG_PHY_BASE_ADDR + 1);
+	mvneta_initialize(bis, MVEBU_EGIGA2_BASE, 2, CONFIG_PHY_BASE_ADDR + 2);
+	mvneta_initialize(bis, MVEBU_EGIGA3_BASE, 3, CONFIG_PHY_BASE_ADDR + 3);
+
+	return 0;
+}
+#endif
+
+#ifndef CONFIG_SYS_DCACHE_OFF
+void enable_caches(void)
+{
+	/* Enable D-cache. I-cache is already enabled in start.S */
+	dcache_enable();
+}
+#endif
diff --git a/arch/arm/include/asm/arch-armada-xp/config.h b/arch/arm/include/asm/arch-armada-xp/config.h
new file mode 100644
index 0000000..6300dff
--- /dev/null
+++ b/arch/arm/include/asm/arch-armada-xp/config.h
@@ -0,0 +1,80 @@
+/*
+ * (C) Copyright 2011
+ * Marvell Semiconductor <www.marvell.com>
+ * Written-by: Lei Wen <leiwen@marvell.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+/*
+ * This file should be included in board config header file.
+ *
+ * It supports common definitions for Armada XP platforms
+ */
+
+#ifndef _ARMADA_XP_CONFIG_H
+#define _ARMADA_XP_CONFIG_H
+
+#include <asm/arch/soc.h>
+
+#define CONFIG_SYS_CACHELINE_SIZE	32
+
+/*
+ * By default kwbimage.cfg from board specific folder is used
+ * If for some board, different configuration file need to be used,
+ * CONFIG_SYS_KWD_CONFIG should be defined in board specific header file
+ */
+#ifndef CONFIG_SYS_KWD_CONFIG
+#define	CONFIG_SYS_KWD_CONFIG	$(CONFIG_BOARDDIR)/kwbimage.cfg
+#endif /* CONFIG_SYS_KWD_CONFIG */
+
+/* Add target to build it automatically upon "make" */
+#define CONFIG_BUILD_TARGET	"u-boot.kwb"
+
+/* end of 16M scrubbed by training in bootrom */
+#define CONFIG_SYS_INIT_SP_ADDR		0x00FF0000
+#define CONFIG_NR_DRAM_BANKS_MAX	2
+
+#define MV_UART_CONSOLE_BASE		MVEBU_UART0_BASE
+
+/*
+ * SPI Flash configuration
+ */
+#ifdef CONFIG_CMD_SF
+#define CONFIG_HARD_SPI			1
+#define CONFIG_KIRKWOOD_SPI		1
+#ifndef CONFIG_ENV_SPI_BUS
+# define CONFIG_ENV_SPI_BUS		0
+#endif
+#ifndef CONFIG_ENV_SPI_CS
+# define CONFIG_ENV_SPI_CS		0
+#endif
+#ifndef CONFIG_ENV_SPI_MAX_HZ
+# define CONFIG_ENV_SPI_MAX_HZ		50000000
+#endif
+#endif
+
+/*
+ * Ethernet Driver configuration
+ */
+#ifdef CONFIG_CMD_NET
+#define CONFIG_CMD_MII
+#define CONFIG_MII		/* expose smi ove miiphy interface */
+#define CONFIG_MVNETA		/* Enable Marvell Gbe Controller Driver */
+#define CONFIG_PHYLIB
+#define CONFIG_ENV_OVERWRITE	/* ethaddr can be reprogrammed */
+#define CONFIG_PHY_GIGE		/* GbE speed/duplex detect */
+#endif /* CONFIG_CMD_NET */
+
+/*
+ * I2C related stuff
+ */
+#ifdef CONFIG_CMD_I2C
+#ifndef CONFIG_SYS_I2C_SOFT
+#define CONFIG_I2C_MVTWSI
+#endif
+#define CONFIG_SYS_I2C_SLAVE		0x0
+#define CONFIG_SYS_I2C_SPEED		100000
+#endif
+
+#endif /* _ARMADA_XP_CONFIG_H */
diff --git a/arch/arm/include/asm/arch-armada-xp/cpu.h b/arch/arm/include/asm/arch-armada-xp/cpu.h
new file mode 100644
index 0000000..a853ba5
--- /dev/null
+++ b/arch/arm/include/asm/arch-armada-xp/cpu.h
@@ -0,0 +1,103 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef _ARMADA_XP_CPU_H
+#define _ARMADA_XP_CPU_H
+
+#include <asm/system.h>
+
+#ifndef __ASSEMBLY__
+
+#define MVEBU_REG_PCIE_DEVID		(MVEBU_REG_PCIE_BASE + 0x00)
+#define MVEBU_REG_PCIE_REVID		(MVEBU_REG_PCIE_BASE + 0x08)
+
+enum memory_bank {
+	BANK0,
+	BANK1,
+	BANK2,
+	BANK3
+};
+
+enum cpu_winen {
+	CPU_WIN_DISABLE,
+	CPU_WIN_ENABLE
+};
+
+enum cpu_target {
+	CPU_TARGET_DRAM = 0x0,
+	CPU_TARGET_DEVICEBUS_BOOTROM_SPI = 0x1,
+	CPU_TARGET_ETH23 = 0x3,
+	CPU_TARGET_PCIE02 = 0x4,
+	CPU_TARGET_ETH01 = 0x7,
+	CPU_TARGET_PCIE13 = 0x8,
+	CPU_TARGET_SASRAM = 0x9,
+	CPU_TARGET_NAND = 0xd,
+};
+
+enum cpu_attrib {
+	CPU_ATTR_SASRAM = 0x01,
+	CPU_ATTR_DRAM_CS0 = 0x0e,
+	CPU_ATTR_DRAM_CS1 = 0x0d,
+	CPU_ATTR_DRAM_CS2 = 0x0b,
+	CPU_ATTR_DRAM_CS3 = 0x07,
+	CPU_ATTR_NANDFLASH = 0x2f,
+	CPU_ATTR_SPIFLASH = 0x1e,
+	CPU_ATTR_BOOTROM = 0x1d,
+	CPU_ATTR_PCIE_IO = 0xe0,
+	CPU_ATTR_PCIE_MEM = 0xe8
+};
+
+/*
+ * Default Device Address MAP BAR values
+ */
+#define DEFADR_PCI_MEM		0x90000000
+#define DEFADR_PCI_IO		0xC0000000
+#define DEFADR_SPIF		0xF4000000
+#define DEFADR_BOOTROM		0xF8000000
+
+struct mbus_win {
+	u32 base;
+	u32 size;
+	u8 target;
+	u8 attr;
+};
+
+/*
+ * System registers
+ * Ref: Datasheet sec:A.28
+ */
+struct mvebu_system_registers {
+	u8 pad1[0x60];
+	u32 rstoutn_mask; /* 0x60 */
+	u32 sys_soft_rst; /* 0x64 */
+};
+
+/*
+ * GPIO Registers
+ * Ref: Datasheet sec:A.19
+ */
+struct kwgpio_registers {
+	u32 dout;
+	u32 oe;
+	u32 blink_en;
+	u32 din_pol;
+	u32 din;
+	u32 irq_cause;
+	u32 irq_mask;
+	u32 irq_level;
+};
+
+/*
+ * functions
+ */
+unsigned int mvebu_sdram_bar(enum memory_bank bank);
+unsigned int mvebu_sdram_bs(enum memory_bank bank);
+void mvebu_sdram_size_adjust(enum memory_bank bank);
+int mvebu_mbus_probe(struct mbus_win windows[], int count);
+#endif /* __ASSEMBLY__ */
+#endif /* _ARMADA_XP_CPU_H */
diff --git a/arch/arm/include/asm/arch-armada-xp/soc.h b/arch/arm/include/asm/arch-armada-xp/soc.h
new file mode 100644
index 0000000..963e7ac
--- /dev/null
+++ b/arch/arm/include/asm/arch-armada-xp/soc.h
@@ -0,0 +1,57 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
+ *
+ * Header file for the Marvell's Feroceon CPU core.
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef _ASM_ARCH_ARMADA_XP_H
+#define _ASM_ARCH_ARMADA_XP_H
+
+#define SOC_MV78460_ID		0x7846
+
+/* TCLK Core Clock definition */
+#ifndef CONFIG_SYS_TCLK
+#define CONFIG_SYS_TCLK		250000000	/* 250MHz */
+#endif
+
+/* SOC specific definations */
+#define INTREG_BASE		0xd0000000
+#define INTREG_BASE_ADDR_REG	(INTREG_BASE + 0x20080)
+#define SOC_REGS_PHY_BASE	0xf1000000
+#define MVEBU_REGISTER(x)	(SOC_REGS_PHY_BASE + x)
+
+#define MVEBU_SDRAM_SCRATCH	(MVEBU_REGISTER(0x01504))
+#define MVEBU_SPI_BASE		(MVEBU_REGISTER(0x10600))
+#define MVEBU_TWSI_BASE		(MVEBU_REGISTER(0x11000))
+#define MVEBU_UART0_BASE	(MVEBU_REGISTER(0x12000))
+#define MVEBU_UART1_BASE	(MVEBU_REGISTER(0x12100))
+#define MVEBU_MPP_BASE		(MVEBU_REGISTER(0x18000))
+#define MVEBU_GPIO0_BASE	(MVEBU_REGISTER(0x18100))
+#define MVEBU_GPIO1_BASE	(MVEBU_REGISTER(0x18140))
+#define MVEBU_GPIO2_BASE	(MVEBU_REGISTER(0x18180))
+#define MVEBU_SYSTEM_REG_BASE	(MVEBU_REGISTER(0x18200))
+#define MVEBU_CPU_WIN_BASE	(MVEBU_REGISTER(0x20000))
+#define MVEBU_SDRAM_BASE	(MVEBU_REGISTER(0x20180))
+#define MVEBU_TIMER_BASE	(MVEBU_REGISTER(0x20300))
+#define MVEBU_EGIGA2_BASE	(MVEBU_REGISTER(0x30000))
+#define MVEBU_EGIGA3_BASE	(MVEBU_REGISTER(0x34000))
+#define MVEBU_REG_PCIE_BASE	(MVEBU_REGISTER(0x40000))
+#define MVEBU_EGIGA0_BASE	(MVEBU_REGISTER(0x70000))
+#define MVEBU_EGIGA1_BASE	(MVEBU_REGISTER(0x74000))
+
+#define SDRAM_MAX_CS		4
+#define SDRAM_ADDR_MASK		0xFF000000
+
+/* Armada XP GbE controller has 4 ports */
+#define MAX_MVNETA_DEVS		4
+
+/* Kirkwood CPU memory windows */
+#define MVCPU_WIN_CTRL_DATA	CPU_WIN_CTRL_DATA
+#define MVCPU_WIN_ENABLE	CPU_WIN_ENABLE
+#define MVCPU_WIN_DISABLE	CPU_WIN_DISABLE
+
+#endif /* _ASM_ARCH_ARMADA_XP_H */
-- 
2.0.1

^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 19/25] arm: armada-xp: Add basic support for the Marvell DB-78460-BP board
  2014-06-27  9:54 [U-Boot] [PATCH v1 0/25] Add Marvell Armada XP MV78460 SoC support Stefan Roese
                   ` (17 preceding siblings ...)
  2014-06-27  9:55 ` [U-Boot] [PATCH v1 18/25] arm: armada-xp: Add basic support for Marvell Armada XP SoC Stefan Roese
@ 2014-06-27  9:55 ` Stefan Roese
  2014-06-27  9:55 ` [U-Boot] [PATCH v1 20/25] arm: kirkwood: Remove some dead code from cpu.c Stefan Roese
                   ` (6 subsequent siblings)
  25 siblings, 0 replies; 50+ messages in thread
From: Stefan Roese @ 2014-06-27  9:55 UTC (permalink / raw)
  To: u-boot

This patch adds basic support for the Marvell DB-78460-BP evaulation
board. This is the first board that uses the recently created
Armada XP 78460 SoC support.

Signed-off-by: Stefan Roese <sr@denx.de>
---

 board/Marvell/db-78460-bp/Makefile      |   7 ++
 board/Marvell/db-78460-bp/db-78460-bp.c | 120 ++++++++++++++++++++++++++++++++
 board/Marvell/db-78460-bp/kwbimage.cfg  |  12 ++++
 boards.cfg                              |   1 +
 include/configs/db-78460-bp.h           |  67 ++++++++++++++++++
 5 files changed, 207 insertions(+)
 create mode 100644 board/Marvell/db-78460-bp/Makefile
 create mode 100644 board/Marvell/db-78460-bp/db-78460-bp.c
 create mode 100644 board/Marvell/db-78460-bp/kwbimage.cfg
 create mode 100644 include/configs/db-78460-bp.h

diff --git a/board/Marvell/db-78460-bp/Makefile b/board/Marvell/db-78460-bp/Makefile
new file mode 100644
index 0000000..c7006d0
--- /dev/null
+++ b/board/Marvell/db-78460-bp/Makefile
@@ -0,0 +1,7 @@
+#
+# Copyright (C) 2014 Stefan Roese <sr@denx.de>
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+obj-y	:= db-78460-bp.o
diff --git a/board/Marvell/db-78460-bp/db-78460-bp.c b/board/Marvell/db-78460-bp/db-78460-bp.c
new file mode 100644
index 0000000..369b3a8
--- /dev/null
+++ b/board/Marvell/db-78460-bp/db-78460-bp.c
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2014 Stefan Roese <sr@denx.de>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <miiphy.h>
+#include <asm/io.h>
+#include <asm/arch/cpu.h>
+#include <asm/arch/soc.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#define BIT(nr)				(1UL << (nr))
+
+#define ETH_PHY_CTRL_REG		0
+#define ETH_PHY_CTRL_POWER_DOWN_BIT	11
+#define ETH_PHY_CTRL_POWER_DOWN_MASK	(1 << ETH_PHY_CTRL_POWER_DOWN_BIT)
+
+/*
+ * Those values and defines are taken from the Marvell U-Boot version
+ * "u-boot-2011.12-2014_T1.0" for the board rd78460gp aka
+ * "RD-AXP-GP rev 1.0".
+ *
+ * GPPs
+ * MPP#		NAME			IN/OUT
+ * ----------------------------------------------
+ * 21		SW_Reset_		OUT
+ * 25		Phy_Int#		IN
+ * 28		SDI_WP			IN
+ * 29		SDI_Status		IN
+ * 54-61	On GPP Connector	?
+ * 62		Switch Interrupt	IN
+ * 63-65	Reserved from SW Board	?
+ * 66		SW_BRD connected	IN
+ */
+#define RD_78460_GP_GPP_OUT_ENA_LOW	(~(BIT(21) | BIT(20)))
+#define RD_78460_GP_GPP_OUT_ENA_MID	(~(BIT(26) | BIT(27)))
+#define RD_78460_GP_GPP_OUT_ENA_HIGH	(~(0x0))
+
+#define RD_78460_GP_GPP_OUT_VAL_LOW	(BIT(21) | BIT(20))
+#define RD_78460_GP_GPP_OUT_VAL_MID	(BIT(26) | BIT(27))
+#define RD_78460_GP_GPP_OUT_VAL_HIGH	0x0
+
+int board_early_init_f(void)
+{
+	/* Configure MPP */
+	writel(0x00000000, MVEBU_MPP_BASE + 0x00);
+	writel(0x00000000, MVEBU_MPP_BASE + 0x04);
+	writel(0x33000000, MVEBU_MPP_BASE + 0x08);
+	writel(0x11000000, MVEBU_MPP_BASE + 0x0c);
+	writel(0x11111111, MVEBU_MPP_BASE + 0x10);
+	writel(0x00221100, MVEBU_MPP_BASE + 0x14);
+	writel(0x00000003, MVEBU_MPP_BASE + 0x18);
+	writel(0x00000000, MVEBU_MPP_BASE + 0x1c);
+	writel(0x00000000, MVEBU_MPP_BASE + 0x20);
+
+	/* Configure GPIO */
+	writel(RD_78460_GP_GPP_OUT_VAL_LOW, MVEBU_GPIO0_BASE + 0x00);
+	writel(RD_78460_GP_GPP_OUT_ENA_LOW, MVEBU_GPIO0_BASE + 0x04);
+	writel(RD_78460_GP_GPP_OUT_VAL_MID, MVEBU_GPIO1_BASE + 0x00);
+	writel(RD_78460_GP_GPP_OUT_ENA_MID, MVEBU_GPIO1_BASE + 0x04);
+	writel(RD_78460_GP_GPP_OUT_VAL_HIGH, MVEBU_GPIO2_BASE + 0x00);
+	writel(RD_78460_GP_GPP_OUT_ENA_HIGH, MVEBU_GPIO2_BASE + 0x04);
+
+	return 0;
+}
+
+int board_init(void)
+{
+	/* adress of boot parameters */
+	gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
+
+	return 0;
+}
+
+int checkboard(void)
+{
+	puts("Board: Marvell DB-78460-BP\n");
+
+	return 0;
+}
+
+#ifdef CONFIG_RESET_PHY_R
+/* Configure and enable MV88E1545 PHY */
+void reset_phy(void)
+{
+	u16 devadr = CONFIG_PHY_BASE_ADDR;
+	char *name = "neta0";
+	u16 reg;
+
+	if (miiphy_set_current_dev(name))
+		return;
+
+	/* Enable QSGMII AN */
+	/* Set page to 4 */
+	miiphy_write(name, devadr, 0x16, 4);
+	/* Enable AN */
+	miiphy_write(name, devadr, 0x0, 0x1140);
+	/* Set page to 0 */
+	miiphy_write(name, devadr, 0x16, 0);
+
+	/* Phy C_ANEG */
+	miiphy_read(name, devadr, 0x4, &reg);
+	reg |= 0x1E0;
+	miiphy_write(name, devadr, 0x4, reg);
+
+	/* Soft-Reset */
+	miiphy_write(name, devadr, 22, 0x0000);
+	miiphy_write(name, devadr, 0, 0x9140);
+
+	/* Power up the phy */
+	miiphy_read(name, devadr, ETH_PHY_CTRL_REG, &reg);
+	reg &= ~(ETH_PHY_CTRL_POWER_DOWN_MASK);
+	miiphy_write(name, devadr, ETH_PHY_CTRL_REG, reg);
+
+	printf("88E1545 Initialized on %s\n", name);
+}
+#endif /* CONFIG_RESET_PHY_R */
diff --git a/board/Marvell/db-78460-bp/kwbimage.cfg b/board/Marvell/db-78460-bp/kwbimage.cfg
new file mode 100644
index 0000000..719145f
--- /dev/null
+++ b/board/Marvell/db-78460-bp/kwbimage.cfg
@@ -0,0 +1,12 @@
+#
+# Copyright (C) 2014 Stefan Roese <sr@denx.de>
+#
+
+# Armada XP uses version 1 image format
+VERSION		1
+
+# Boot Media configurations
+BOOT_FROM	spi
+
+# Binary Header (bin_hdr) with DDR3 training code
+BINARY board/Marvell/db-78460-bp/binary.0 0000005b 00000068
diff --git a/boards.cfg b/boards.cfg
index 947f2bc..a94b225 100644
--- a/boards.cfg
+++ b/boards.cfg
@@ -247,6 +247,7 @@ Active  arm         arm946es       -           armltd          integrator
 Active  arm         armv7          -           armltd          vexpress            vexpress_ca15_tc2                     -                                                                                                                                 -
 Active  arm         armv7          -           armltd          vexpress            vexpress_ca5x2                        -                                                                                                                                 Matt Waddel <matt.waddel@linaro.org>
 Active  arm         armv7          -           armltd          vexpress            vexpress_ca9x4                        -                                                                                                                                 Matt Waddel <matt.waddel@linaro.org>
+Active  arm         armv7          armada-xp   Marvell         -                   db-78460-bp                           -                                                                                                                                 Stefan Roese <sr@denx.de>
 Active  arm         armv7          am33xx      BuR             kwb                 kwb                                   kwb:SERIAL1,CONS_INDEX=1                                                                                                          Hannes Petermaier <hannes.petermaier@br-automation.com>
 Active  arm         armv7          am33xx      BuR             tseries             tseries_mmc                           tseries:SERIAL1,CONS_INDEX=1,EMMC_BOOT                                                                                            Hannes Petermaier <hannes.petermaier@br-automation.com>
 Active  arm         armv7          am33xx      BuR             tseries             tseries_nand                          tseries:SERIAL1,CONS_INDEX=1,NAND                                                                                                 Hannes Petermaier <hannes.petermaier@br-automation.com>
diff --git a/include/configs/db-78460-bp.h b/include/configs/db-78460-bp.h
new file mode 100644
index 0000000..ae48655
--- /dev/null
+++ b/include/configs/db-78460-bp.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2014 Stefan Roese <sr@denx.de>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef _CONFIG_DB_78460_BP_H
+#define _CONFIG_DB_78460_BP_H
+
+/*
+ * High Level Configuration Options (easy to change)
+ */
+#define CONFIG_ARMADA_XP		/* SOC Family Name */
+#define CONFIG_SKIP_LOWLEVEL_INIT	/* disable board lowlevel_init */
+#define CONFIG_SYS_GENERIC_BOARD
+#define CONFIG_DISPLAY_BOARDINFO_LATE
+
+#define	CONFIG_SYS_TEXT_BASE	0x04000000
+#define CONFIG_SYS_TCLK		250000000	/* 250MHz */
+
+/*
+ * Commands configuration
+ */
+#define CONFIG_SYS_NO_FLASH		/* Declare no flash (NOR/SPI) */
+#include <config_cmd_default.h>
+#define CONFIG_CMD_DHCP
+#define CONFIG_CMD_ENV
+#define CONFIG_CMD_I2C
+#define CONFIG_CMD_PING
+#define CONFIG_CMD_SF
+#define CONFIG_CMD_SPI
+#define CONFIG_CMD_TFTPPUT
+#define CONFIG_CMD_TIME
+
+/* I2C */
+#define CONFIG_I2C_MVTWSI
+#define CONFIG_I2C_MVTWSI_BASE		MVEBU_TWSI_BASE
+#define CONFIG_SYS_I2C_SLAVE		0x0
+#define CONFIG_SYS_I2C_SPEED		100000
+
+/* SPI NOR flash default params, used by sf commands */
+#define CONFIG_SF_DEFAULT_SPEED		1000000
+#define CONFIG_SF_DEFAULT_MODE		SPI_MODE_3
+#define CONFIG_SPI_FLASH_STMICRO
+
+/* Environment in SPI NOR flash */
+#define CONFIG_ENV_IS_IN_SPI_FLASH
+#define CONFIG_ENV_OFFSET		(1 << 20) /* 1MiB in */
+#define CONFIG_ENV_SIZE			(64 << 10) /* 64KiB */
+#define CONFIG_ENV_SECT_SIZE		(64 << 10) /* 64KiB sectors */
+
+#define CONFIG_PHY_MARVELL		/* there is a marvell phy */
+#define CONFIG_PHY_BASE_ADDR	0x10
+#define CONFIG_SYS_NETA_INTERFACE_TYPE	PHY_INTERFACE_MODE_QSGMII
+#define PHY_ANEG_TIMEOUT	8000	/* PHY needs a longer aneg time */
+#define CONFIG_RESET_PHY_R
+
+#define CONFIG_SYS_CONSOLE_INFO_QUIET	/* don't print console @ startup */
+#define CONFIG_SYS_ALT_MEMTEST
+
+/*
+ * mv-common.h should be defined after CMD configs since it used them
+ * to enable certain macros
+ */
+#include "mv-common.h"
+
+#endif /* _CONFIG_DB_78460_BP_H */
-- 
2.0.1

^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 20/25] arm: kirkwood: Remove some dead code from cpu.c
  2014-06-27  9:54 [U-Boot] [PATCH v1 0/25] Add Marvell Armada XP MV78460 SoC support Stefan Roese
                   ` (18 preceding siblings ...)
  2014-06-27  9:55 ` [U-Boot] [PATCH v1 19/25] arm: armada-xp: Add basic support for the Marvell DB-78460-BP board Stefan Roese
@ 2014-06-27  9:55 ` Stefan Roese
  2014-07-01 23:45   ` Luka Perkov
  2014-06-27  9:55 ` [U-Boot] [PATCH v1 21/25] arm: kirkwood: Use mvebu new common mbus API Stefan Roese
                   ` (5 subsequent siblings)
  25 siblings, 1 reply; 50+ messages in thread
From: Stefan Roese @ 2014-06-27  9:55 UTC (permalink / raw)
  To: u-boot

All those functions removed with this patch are not accessed at all. So lets
remove them.

Signed-off-by: Stefan Roese <sr@denx.de>
---

 arch/arm/cpu/arm926ejs/kirkwood/cpu.c | 55 -----------------------------------
 1 file changed, 55 deletions(-)

diff --git a/arch/arm/cpu/arm926ejs/kirkwood/cpu.c b/arch/arm/cpu/arm926ejs/kirkwood/cpu.c
index 00abcfd..c384565 100644
--- a/arch/arm/cpu/arm926ejs/kirkwood/cpu.c
+++ b/arch/arm/cpu/arm926ejs/kirkwood/cpu.c
@@ -9,13 +9,10 @@
 #include <common.h>
 #include <netdev.h>
 #include <asm/cache.h>
-#include <u-boot/md5.h>
 #include <asm/io.h>
 #include <asm/arch/cpu.h>
 #include <asm/arch/soc.h>
 
-#define BUFLEN	16
-
 void reset_cpu(unsigned long ignored)
 {
 	struct kwcpu_registers *cpureg =
@@ -29,31 +26,6 @@ void reset_cpu(unsigned long ignored)
 }
 
 /*
- * Generates Ramdom hex number reading some time varient system registers
- * and using md5 algorithm
- */
-unsigned char get_random_hex(void)
-{
-	int i;
-	u32 inbuf[BUFLEN];
-	u8 outbuf[BUFLEN];
-
-	/*
-	 * in case of 88F6281/88F6282/88F6192 A0,
-	 * Bit7 need to reset to generate random values in KW_REG_UNDOC_0x1470
-	 * Soc reg offsets KW_REG_UNDOC_0x1470 and KW_REG_UNDOC_0x1478 are
-	 * reserved regs and does not have names at this moment
-	 * (no errata available)
-	 */
-	writel(readl(KW_REG_UNDOC_0x1478) & ~(1 << 7), KW_REG_UNDOC_0x1478);
-	for (i = 0; i < BUFLEN; i++) {
-		inbuf[i] = readl(KW_REG_UNDOC_0x1470);
-	}
-	md5((u8 *) inbuf, (BUFLEN * sizeof(u32)), outbuf);
-	return outbuf[outbuf[7] % 0x0f];
-}
-
-/*
  * Window Size
  * Used with the Base register to set the address window size and location.
  * Must be programmed from LSB to MSB as sequence of ones followed by
@@ -139,33 +111,6 @@ int kw_config_adr_windows(void)
 }
 
 /*
- * kw_config_mpp - Multi-Purpose Pins Functionality configuration
- *
- * Each MPP can be configured to different functionality through
- * MPP control register, ref (sec 6.1 of kirkwood h/w specification)
- *
- * There are maximum 64 Multi-Pourpose Pins on Kirkwood
- * Each MPP functionality can be configuration by a 4bit value
- * of MPP control reg, the value and associated functionality depends
- * upon used SoC varient
- */
-int kw_config_mpp(u32 mpp0_7, u32 mpp8_15, u32 mpp16_23, u32 mpp24_31,
-		u32 mpp32_39, u32 mpp40_47, u32 mpp48_55)
-{
-	u32 *mppreg = (u32 *) KW_MPP_BASE;
-
-	/* program mpp registers */
-	writel(mpp0_7, &mppreg[0]);
-	writel(mpp8_15, &mppreg[1]);
-	writel(mpp16_23, &mppreg[2]);
-	writel(mpp24_31, &mppreg[3]);
-	writel(mpp32_39, &mppreg[4]);
-	writel(mpp40_47, &mppreg[5]);
-	writel(mpp48_55, &mppreg[6]);
-	return 0;
-}
-
-/*
  * SYSRSTn Duration Counter Support
  *
  * Kirkwood SoC implements a hardware-based SYSRSTn duration counter.
-- 
2.0.1

^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 21/25] arm: kirkwood: Use mvebu new common mbus API
  2014-06-27  9:54 [U-Boot] [PATCH v1 0/25] Add Marvell Armada XP MV78460 SoC support Stefan Roese
                   ` (19 preceding siblings ...)
  2014-06-27  9:55 ` [U-Boot] [PATCH v1 20/25] arm: kirkwood: Remove some dead code from cpu.c Stefan Roese
@ 2014-06-27  9:55 ` Stefan Roese
  2014-06-27  9:55 ` [U-Boot] [PATCH v1 22/25] tools/kwboot: Sync with latest barebox version to support Armada XP Stefan Roese
                   ` (4 subsequent siblings)
  25 siblings, 0 replies; 50+ messages in thread
From: Stefan Roese @ 2014-06-27  9:55 UTC (permalink / raw)
  To: u-boot

Now that the new common mvebu mbus API is available, lets use it
on kirkwood as well. This includes a small change in the kirkwood
EHCI driver. Making it more similar to the Linux driver from which
it is ported.

Signed-off-by: Stefan Roese <sr@denx.de>
---

 arch/arm/cpu/arm926ejs/kirkwood/cpu.c    | 102 ++++++-------------------------
 arch/arm/include/asm/arch-kirkwood/cpu.h |  63 ++++++++++---------
 arch/arm/include/asm/arch-kirkwood/soc.h |  16 ++---
 arch/arm/mvebu-common/Makefile           |   2 +-
 drivers/usb/host/ehci-marvell.c          |  43 ++++---------
 5 files changed, 74 insertions(+), 152 deletions(-)

diff --git a/arch/arm/cpu/arm926ejs/kirkwood/cpu.c b/arch/arm/cpu/arm926ejs/kirkwood/cpu.c
index c384565..6bfa4ec 100644
--- a/arch/arm/cpu/arm926ejs/kirkwood/cpu.c
+++ b/arch/arm/cpu/arm926ejs/kirkwood/cpu.c
@@ -13,101 +13,37 @@
 #include <asm/arch/cpu.h>
 #include <asm/arch/soc.h>
 
-void reset_cpu(unsigned long ignored)
-{
-	struct kwcpu_registers *cpureg =
-	    (struct kwcpu_registers *)KW_CPU_REG_BASE;
-
-	writel(readl(&cpureg->rstoutn_mask) | (1 << 2),
-		&cpureg->rstoutn_mask);
-	writel(readl(&cpureg->sys_soft_rst) | 1,
-		&cpureg->sys_soft_rst);
-	while (1) ;
-}
-
-/*
- * Window Size
- * Used with the Base register to set the address window size and location.
- * Must be programmed from LSB to MSB as sequence of ones followed by
- * sequence of zeros. The number of ones specifies the size of the window in
- * 64 KByte granularity (e.g., a value of 0x00FF specifies 256 = 16 MByte).
- * NOTE: A value of 0x0 specifies 64-KByte size.
- */
-unsigned int kw_winctrl_calcsize(unsigned int sizeval)
-{
-	int i;
-	unsigned int j = 0;
-	u32 val = sizeval >> 1;
-
-	for (i = 0; val >= 0x10000; i++) {
-		j |= (1 << i);
-		val = val >> 1;
-	}
-	return (0x0000ffff & j);
-}
-
-/*
- * kw_config_adr_windows - Configure address Windows
- *
- * There are 8 address windows supported by Kirkwood Soc to addess different
- * devices. Each window can be configured for size, BAR and remap addr
- * Below configuration is standard for most of the cases
- *
- * If remap function not used, remap_lo must be set as base
- *
- * Reference Documentation:
- * Mbus-L to Mbus Bridge Registers Configuration.
- * (Sec 25.1 and 25.3 of Datasheet)
- */
-int kw_config_adr_windows(void)
-{
-	struct kwwin_registers *winregs =
-		(struct kwwin_registers *)KW_CPU_WIN_BASE;
-
+static struct mbus_win windows[] = {
 	/* Window 0: PCIE MEM address space */
-	writel(KWCPU_WIN_CTRL_DATA(1024 * 1024 * 256, KWCPU_TARGET_PCIE,
-		KWCPU_ATTR_PCIE_MEM, KWCPU_WIN_ENABLE), &winregs[0].ctrl);
-
-	writel(KW_DEFADR_PCI_MEM, &winregs[0].base);
-	writel(KW_DEFADR_PCI_MEM, &winregs[0].remap_lo);
-	writel(0x0, &winregs[0].remap_hi);
+	{ DEFADR_PCI_MEM, 256 << 20, CPU_TARGET_PCIE, CPU_ATTR_PCIE_MEM },
 
 	/* Window 1: PCIE IO address space */
-	writel(KWCPU_WIN_CTRL_DATA(1024 * 64, KWCPU_TARGET_PCIE,
-		KWCPU_ATTR_PCIE_IO, KWCPU_WIN_ENABLE), &winregs[1].ctrl);
-	writel(KW_DEFADR_PCI_IO, &winregs[1].base);
-	writel(KW_DEFADR_PCI_IO_REMAP, &winregs[1].remap_lo);
-	writel(0x0, &winregs[1].remap_hi);
+	{ DEFADR_PCI_IO, 64 << 10, CPU_TARGET_PCIE, CPU_ATTR_PCIE_IO },
 
 	/* Window 2: NAND Flash address space */
-	writel(KWCPU_WIN_CTRL_DATA(1024 * 1024 * 128, KWCPU_TARGET_MEMORY,
-		KWCPU_ATTR_NANDFLASH, KWCPU_WIN_ENABLE), &winregs[2].ctrl);
-	writel(KW_DEFADR_NANDF, &winregs[2].base);
-	writel(KW_DEFADR_NANDF, &winregs[2].remap_lo);
-	writel(0x0, &winregs[2].remap_hi);
+	{ DEFADR_NANDF, 128 << 20, CPU_TARGET_MEMORY, CPU_ATTR_NANDFLASH },
 
 	/* Window 3: SPI Flash address space */
-	writel(KWCPU_WIN_CTRL_DATA(1024 * 1024 * 128, KWCPU_TARGET_MEMORY,
-		KWCPU_ATTR_SPIFLASH, KWCPU_WIN_ENABLE), &winregs[3].ctrl);
-	writel(KW_DEFADR_SPIF, &winregs[3].base);
-	writel(KW_DEFADR_SPIF, &winregs[3].remap_lo);
-	writel(0x0, &winregs[3].remap_hi);
+	{ DEFADR_SPIF, 128 << 20, CPU_TARGET_MEMORY, CPU_ATTR_SPIFLASH },
 
 	/* Window 4: BOOT Memory address space */
-	writel(KWCPU_WIN_CTRL_DATA(1024 * 1024 * 128, KWCPU_TARGET_MEMORY,
-		KWCPU_ATTR_BOOTROM, KWCPU_WIN_ENABLE), &winregs[4].ctrl);
-	writel(KW_DEFADR_BOOTROM, &winregs[4].base);
+	{ DEFADR_BOOTROM, 128 << 20, CPU_TARGET_MEMORY, CPU_ATTR_BOOTROM },
 
 	/* Window 5: Security SRAM address space */
-	writel(KWCPU_WIN_CTRL_DATA(1024 * 64, KWCPU_TARGET_SASRAM,
-		KWCPU_ATTR_SASRAM, KWCPU_WIN_ENABLE), &winregs[5].ctrl);
-	writel(KW_DEFADR_SASRAM, &winregs[5].base);
+	{ DEFADR_SASRAM, 64 << 10, CPU_TARGET_SASRAM, CPU_ATTR_SASRAM },
+};
 
-	/* Window 6-7: Disabled */
-	writel(KWCPU_WIN_DISABLE, &winregs[6].ctrl);
-	writel(KWCPU_WIN_DISABLE, &winregs[7].ctrl);
+void reset_cpu(unsigned long ignored)
+{
+	struct kwcpu_registers *cpureg =
+		(struct kwcpu_registers *)KW_CPU_REG_BASE;
 
-	return 0;
+	writel(readl(&cpureg->rstoutn_mask) | (1 << 2),
+	       &cpureg->rstoutn_mask);
+	writel(readl(&cpureg->sys_soft_rst) | 1,
+	       &cpureg->sys_soft_rst);
+	while (1)
+		;
 }
 
 /*
@@ -223,7 +159,7 @@ int arch_cpu_init(void)
 	writel(readl(&cpureg->l2_cfg) | 0x18, &cpureg->l2_cfg);
 	invalidate_l2_cache();
 
-	kw_config_adr_windows();
+	mvebu_mbus_probe(windows, ARRAY_SIZE(windows));
 
 #ifdef CONFIG_KIRKWOOD_RGMII_PAD_1V8
 	/*
diff --git a/arch/arm/include/asm/arch-kirkwood/cpu.h b/arch/arm/include/asm/arch-kirkwood/cpu.h
index 926d347..cde978e 100644
--- a/arch/arm/include/asm/arch-kirkwood/cpu.h
+++ b/arch/arm/include/asm/arch-kirkwood/cpu.h
@@ -13,9 +13,6 @@
 
 #ifndef __ASSEMBLY__
 
-#define KWCPU_WIN_CTRL_DATA(size, target, attr, en) (en | (target << 4) \
-			| (attr << 8) | (kw_winctrl_calcsize(size) << 16))
-
 #define KWGBE_PORT_SERIAL_CONTROL1_REG(_x)	\
 		((_x ? KW_EGIGA1_BASE : KW_EGIGA0_BASE) + 0x44c)
 
@@ -34,41 +31,48 @@ enum memory_bank {
 };
 
 enum kwcpu_winen {
-	KWCPU_WIN_DISABLE,
-	KWCPU_WIN_ENABLE
+	CPU_WIN_DISABLE,
+	CPU_WIN_ENABLE
 };
 
 enum kwcpu_target {
-	KWCPU_TARGET_RESERVED,
-	KWCPU_TARGET_MEMORY,
-	KWCPU_TARGET_1RESERVED,
-	KWCPU_TARGET_SASRAM,
-	KWCPU_TARGET_PCIE
+	CPU_TARGET_RESERVED,
+	CPU_TARGET_MEMORY,
+	CPU_TARGET_1RESERVED,
+	CPU_TARGET_SASRAM,
+	CPU_TARGET_PCIE
 };
 
 enum kwcpu_attrib {
-	KWCPU_ATTR_SASRAM = 0x01,
-	KWCPU_ATTR_DRAM_CS0 = 0x0e,
-	KWCPU_ATTR_DRAM_CS1 = 0x0d,
-	KWCPU_ATTR_DRAM_CS2 = 0x0b,
-	KWCPU_ATTR_DRAM_CS3 = 0x07,
-	KWCPU_ATTR_NANDFLASH = 0x2f,
-	KWCPU_ATTR_SPIFLASH = 0x1e,
-	KWCPU_ATTR_BOOTROM = 0x1d,
-	KWCPU_ATTR_PCIE_IO = 0xe0,
-	KWCPU_ATTR_PCIE_MEM = 0xe8
+	CPU_ATTR_SASRAM = 0x01,
+	CPU_ATTR_DRAM_CS0 = 0x0e,
+	CPU_ATTR_DRAM_CS1 = 0x0d,
+	CPU_ATTR_DRAM_CS2 = 0x0b,
+	CPU_ATTR_DRAM_CS3 = 0x07,
+	CPU_ATTR_NANDFLASH = 0x2f,
+	CPU_ATTR_SPIFLASH = 0x1e,
+	CPU_ATTR_BOOTROM = 0x1d,
+	CPU_ATTR_PCIE_IO = 0xe0,
+	CPU_ATTR_PCIE_MEM = 0xe8
 };
 
 /*
  * Default Device Address MAP BAR values
  */
-#define KW_DEFADR_PCI_MEM	0x90000000
-#define KW_DEFADR_PCI_IO	0xC0000000
-#define KW_DEFADR_PCI_IO_REMAP	0xC0000000
-#define KW_DEFADR_SASRAM	0xC8010000
-#define KW_DEFADR_NANDF		0xD8000000
-#define KW_DEFADR_SPIF		0xE8000000
-#define KW_DEFADR_BOOTROM	0xF8000000
+#define DEFADR_PCI_MEM		0x90000000
+#define DEFADR_PCI_IO		0xC0000000
+#define DEFADR_PCI_IO_REMAP	0xC0000000
+#define DEFADR_SASRAM		0xC8010000
+#define DEFADR_NANDF		0xD8000000
+#define DEFADR_SPIF		0xE8000000
+#define DEFADR_BOOTROM		0xF8000000
+
+struct mbus_win {
+	u32 base;
+	u32 size;
+	u8 target;
+	u8 attr;
+};
 
 /*
  * read feroceon/sheeva core extra feature register
@@ -97,7 +101,7 @@ static inline void writefr_extra_feature_reg(unsigned int val)
  * MBus-L to Mbus Bridge Registers
  * Ref: Datasheet sec:A.3
  */
-struct kwwin_registers {
+struct mvebu_win_registers {
 	u32 ctrl;
 	u32 base;
 	u32 remap_lo;
@@ -143,13 +147,12 @@ unsigned char get_random_hex(void);
 unsigned int mvebu_sdram_bar(enum memory_bank bank);
 unsigned int mvebu_sdram_bs(enum memory_bank bank);
 void mvebu_sdram_size_adjust(enum memory_bank bank);
-int kw_config_adr_windows(void);
+int mvebu_mbus_probe(struct mbus_win windows[], int count);
 void mvebu_config_gpio(unsigned int gpp0_oe_val, unsigned int gpp1_oe_val,
 		unsigned int gpp0_oe, unsigned int gpp1_oe);
 int kw_config_mpp(unsigned int mpp0_7, unsigned int mpp8_15,
 		unsigned int mpp16_23, unsigned int mpp24_31,
 		unsigned int mpp32_39, unsigned int mpp40_47,
 		unsigned int mpp48_55);
-unsigned int kw_winctrl_calcsize(unsigned int sizeval);
 #endif /* __ASSEMBLY__ */
 #endif /* _KWCPU_H */
diff --git a/arch/arm/include/asm/arch-kirkwood/soc.h b/arch/arm/include/asm/arch-kirkwood/soc.h
index 75120b1..41a6f85 100644
--- a/arch/arm/include/asm/arch-kirkwood/soc.h
+++ b/arch/arm/include/asm/arch-kirkwood/soc.h
@@ -32,7 +32,7 @@
 #define KW_RTC_BASE			(KW_REGISTER(0x10300))
 #define KW_NANDF_BASE			(KW_REGISTER(0x10418))
 #define MVEBU_SPI_BASE			(KW_REGISTER(0x10600))
-#define KW_CPU_WIN_BASE			(KW_REGISTER(0x20000))
+#define MVEBU_CPU_WIN_BASE			(KW_REGISTER(0x20000))
 #define KW_CPU_REG_BASE			(KW_REGISTER(0x20100))
 #define MVEBU_TIMER_BASE			(KW_REGISTER(0x20300))
 #define KW_REG_PCIE_BASE		(KW_REGISTER(0x40000))
@@ -52,15 +52,15 @@
 
 /* Kirkwood USB Host controller */
 #define MVUSB0_BASE			KW_USB20_BASE
-#define MVUSB0_CPU_ATTR_DRAM_CS0	KWCPU_ATTR_DRAM_CS0
-#define MVUSB0_CPU_ATTR_DRAM_CS1	KWCPU_ATTR_DRAM_CS1
-#define MVUSB0_CPU_ATTR_DRAM_CS2	KWCPU_ATTR_DRAM_CS2
-#define MVUSB0_CPU_ATTR_DRAM_CS3	KWCPU_ATTR_DRAM_CS3
+#define MVUSB0_CPU_ATTR_DRAM_CS0	CPU_ATTR_DRAM_CS0
+#define MVUSB0_CPU_ATTR_DRAM_CS1	CPU_ATTR_DRAM_CS1
+#define MVUSB0_CPU_ATTR_DRAM_CS2	CPU_ATTR_DRAM_CS2
+#define MVUSB0_CPU_ATTR_DRAM_CS3	CPU_ATTR_DRAM_CS3
 
 /* Kirkwood CPU memory windows */
-#define MVCPU_WIN_CTRL_DATA	KWCPU_WIN_CTRL_DATA
-#define MVCPU_WIN_ENABLE	KWCPU_WIN_ENABLE
-#define MVCPU_WIN_DISABLE	KWCPU_WIN_DISABLE
+#define MVCPU_WIN_CTRL_DATA	CPU_WIN_CTRL_DATA
+#define MVCPU_WIN_ENABLE	CPU_WIN_ENABLE
+#define MVCPU_WIN_DISABLE	CPU_WIN_DISABLE
 
 #if defined (CONFIG_KW88F6281)
 #include <asm/arch/kw88f6281.h>
diff --git a/arch/arm/mvebu-common/Makefile b/arch/arm/mvebu-common/Makefile
index 9dcab69..ed75ffb 100644
--- a/arch/arm/mvebu-common/Makefile
+++ b/arch/arm/mvebu-common/Makefile
@@ -8,5 +8,5 @@
 
 obj-y	= dram.o
 obj-y	+= gpio.o
-obj-$(CONFIG_ARMADA_XP) += mbus.o
+obj-y	+= mbus.o
 obj-y	+= timer.o
diff --git a/drivers/usb/host/ehci-marvell.c b/drivers/usb/host/ehci-marvell.c
index 1a5fd6e..2d75031 100644
--- a/drivers/usb/host/ehci-marvell.c
+++ b/drivers/usb/host/ehci-marvell.c
@@ -11,6 +11,7 @@
 #include <usb.h>
 #include "ehci.h"
 #include <asm/arch/cpu.h>
+#include <linux/mbus.h>
 
 #if defined(CONFIG_KIRKWOOD)
 #include <asm/arch/soc.h>
@@ -32,41 +33,23 @@ DECLARE_GLOBAL_DATA_PTR;
  */
 static void usb_brg_adrdec_setup(void)
 {
+	const struct mbus_dram_target_info *dram;
 	int i;
-	u32 size, base, attrib;
 
-	for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
+	dram = mvebu_mbus_dram_info();
 
-		/* Enable DRAM bank */
-		switch (i) {
-		case 0:
-			attrib = MVUSB0_CPU_ATTR_DRAM_CS0;
-			break;
-		case 1:
-			attrib = MVUSB0_CPU_ATTR_DRAM_CS1;
-			break;
-		case 2:
-			attrib = MVUSB0_CPU_ATTR_DRAM_CS2;
-			break;
-		case 3:
-			attrib = MVUSB0_CPU_ATTR_DRAM_CS3;
-			break;
-		default:
-			/* invalide bank, disable access */
-			attrib = 0;
-			break;
-		}
+	for (i = 0; i < 4; i++) {
+		wrl(USB_WINDOW_CTRL(i), 0);
+		wrl(USB_WINDOW_BASE(i), 0);
+	}
 
-		size = gd->bd->bi_dram[i].size;
-		base = gd->bd->bi_dram[i].start;
-		if ((size) && (attrib))
-			wrl(USB_WINDOW_CTRL(i),
-				MVCPU_WIN_CTRL_DATA(size, USB_TARGET_DRAM,
-					attrib, MVCPU_WIN_ENABLE));
-		else
-			wrl(USB_WINDOW_CTRL(i), MVCPU_WIN_DISABLE);
+	for (i = 0; i < dram->num_cs; i++) {
+		const struct mbus_dram_window *cs = dram->cs + i;
 
-		wrl(USB_WINDOW_BASE(i), base);
+		wrl(USB_WINDOW_CTRL(i), ((cs->size - 1) & 0xffff0000) |
+					(cs->mbus_attr << 8) |
+					(dram->mbus_dram_target_id << 4) | 1);
+		wrl(USB_WINDOW_BASE(i), cs->base);
 	}
 }
 
-- 
2.0.1

^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 22/25] tools/kwboot: Sync with latest barebox version to support Armada XP
  2014-06-27  9:54 [U-Boot] [PATCH v1 0/25] Add Marvell Armada XP MV78460 SoC support Stefan Roese
                   ` (20 preceding siblings ...)
  2014-06-27  9:55 ` [U-Boot] [PATCH v1 21/25] arm: kirkwood: Use mvebu new common mbus API Stefan Roese
@ 2014-06-27  9:55 ` Stefan Roese
  2014-06-27 19:06   ` Luka Perkov
                     ` (2 more replies)
  2014-06-27  9:55 ` [U-Boot] [PATCH v1 23/25] tools: Compile kwboot for Marvell Armada XP as those SoCs are now supported Stefan Roese
                   ` (3 subsequent siblings)
  25 siblings, 3 replies; 50+ messages in thread
From: Stefan Roese @ 2014-06-27  9:55 UTC (permalink / raw)
  To: u-boot

The barebox version of the kwboot tool has evolved a bit. To support
Armada XP and Dove. Additionally a few minor fixes have been applied.
So lets sync with the latest barebox version.

Please note that the main difference between both versions now is, that
the U-Boot version still supports the -p option, to dynamically patch
an image for UART boot mode. I didn't test it now though.

Signed-off-by: Stefan Roese <sr@denx.de>
---

 tools/kwboot.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 83 insertions(+), 14 deletions(-)

diff --git a/tools/kwboot.c b/tools/kwboot.c
index e773f01..c47970e 100644
--- a/tools/kwboot.c
+++ b/tools/kwboot.c
@@ -1,5 +1,6 @@
 /*
- * Boot a Marvell Kirkwood SoC, with Xmodem over UART0.
+ * Boot a Marvell SoC, with Xmodem over UART0.
+ *  supports Kirkwood, Dove, Armada 370, Armada XP
  *
  * (c) 2012 Daniel Stodden <daniel.stodden@gmail.com>
  *
@@ -37,8 +38,12 @@ static unsigned char kwboot_msg_boot[] = {
 	0xBB, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77
 };
 
-#define KWBOOT_MSG_REQ_DELAY	10 /* ms */
-#define KWBOOT_MSG_RSP_TIMEO	50 /* ms */
+static unsigned char kwboot_msg_debug[] = {
+	0xDD, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77
+};
+
+#define KWBOOT_MSG_REQ_DELAY	1000 /* ms */
+#define KWBOOT_MSG_RSP_TIMEO	1000 /* ms */
 
 /*
  * Xmodem Transfers
@@ -184,6 +189,9 @@ kwboot_tty_send(int fd, const void *buf, size_t len)
 	int rc;
 	ssize_t n;
 
+	if (!buf)
+		return 0;
+
 	rc = -1;
 
 	do {
@@ -268,7 +276,10 @@ kwboot_bootmsg(int tty, void *msg)
 	int rc;
 	char c;
 
-	kwboot_printv("Sending boot message. Please reboot the target...");
+	if (msg == NULL)
+		kwboot_printv("Please reboot the target into UART boot mode...");
+	else
+		kwboot_printv("Sending boot message. Please reboot the target...");
 
 	do {
 		rc = tcflush(tty, TCIOFLUSH);
@@ -293,6 +304,37 @@ kwboot_bootmsg(int tty, void *msg)
 }
 
 static int
+kwboot_debugmsg(int tty, void *msg)
+{
+	int rc;
+
+	kwboot_printv("Sending debug message. Please reboot the target...");
+
+	do {
+		char buf[16];
+
+		rc = tcflush(tty, TCIOFLUSH);
+		if (rc)
+			break;
+
+		rc = kwboot_tty_send(tty, msg, 8);
+		if (rc) {
+			usleep(KWBOOT_MSG_REQ_DELAY * 1000);
+			continue;
+		}
+
+		rc = kwboot_tty_recv(tty, buf, 16, KWBOOT_MSG_RSP_TIMEO);
+
+		kwboot_spinner();
+
+	} while (rc);
+
+	kwboot_printv("\n");
+
+	return rc;
+}
+
+static int
 kwboot_xm_makeblock(struct kwboot_block *block, const void *data,
 		    size_t size, int pnum)
 {
@@ -300,6 +342,7 @@ kwboot_xm_makeblock(struct kwboot_block *block, const void *data,
 	size_t n;
 	int i;
 
+	block->soh = SOH;
 	block->pnum = pnum;
 	block->_pnum = ~block->pnum;
 
@@ -326,9 +369,15 @@ kwboot_xm_sendblock(int fd, struct kwboot_block *block)
 		if (rc)
 			break;
 
-		rc = kwboot_tty_recv(fd, &c, 1, KWBOOT_BLK_RSP_TIMEO);
-		if (rc)
-			break;
+		do {
+			rc = kwboot_tty_recv(fd, &c, 1, KWBOOT_BLK_RSP_TIMEO);
+			if (rc)
+				break;
+
+			if (c != ACK && c != NAK && c != CAN)
+				printf("%c", c);
+
+		} while (c != ACK && c != NAK && c != CAN);
 
 		if (c != ACK)
 			kwboot_progress(-1, '+');
@@ -511,7 +560,6 @@ kwboot_mmap_image(const char *path, size_t *size, int prot)
 	void *img;
 
 	rc = -1;
-	fd = -1;
 	img = NULL;
 
 	fd = open(path, O_RDONLY);
@@ -601,11 +649,15 @@ static void
 kwboot_usage(FILE *stream, char *progname)
 {
 	fprintf(stream,
-		"Usage: %s -b <image> [ -p ] [ -t ] "
-		"[-B <baud> ] <TTY>\n", progname);
+		"Usage: %s [-d | -b <image> | -D <image> ] [ -t ] [-B <baud> ] <TTY>\n",
+		progname);
 	fprintf(stream, "\n");
-	fprintf(stream, "  -b <image>: boot <image>\n");
+	fprintf(stream,
+		"  -b <image>: boot <image> with preamble (Kirkwood, Armada 370/XP)\n");
 	fprintf(stream, "  -p: patch <image> to type 0x69 (uart boot)\n");
+	fprintf(stream,
+		"  -D <image>: boot <image> without preamble (Dove)\n");
+	fprintf(stream, "  -d: enter debug mode\n");
 	fprintf(stream, "\n");
 	fprintf(stream, "  -t: mini terminal\n");
 	fprintf(stream, "\n");
@@ -619,6 +671,7 @@ main(int argc, char **argv)
 	const char *ttypath, *imgpath;
 	int rv, rc, tty, term, prot, patch;
 	void *bootmsg;
+	void *debugmsg;
 	void *img;
 	size_t size;
 	speed_t speed;
@@ -626,6 +679,7 @@ main(int argc, char **argv)
 	rv = 1;
 	tty = -1;
 	bootmsg = NULL;
+	debugmsg = NULL;
 	imgpath = NULL;
 	img = NULL;
 	term = 0;
@@ -636,7 +690,7 @@ main(int argc, char **argv)
 	kwboot_verbose = isatty(STDOUT_FILENO);
 
 	do {
-		int c = getopt(argc, argv, "hb:ptB:");
+		int c = getopt(argc, argv, "hb:ptB:dD:");
 		if (c < 0)
 			break;
 
@@ -646,6 +700,15 @@ main(int argc, char **argv)
 			imgpath = optarg;
 			break;
 
+		case 'D':
+			bootmsg = NULL;
+			imgpath = optarg;
+			break;
+
+		case 'd':
+			debugmsg = kwboot_msg_debug;
+			break;
+
 		case 'p':
 			patch = 1;
 			break;
@@ -667,7 +730,7 @@ main(int argc, char **argv)
 		}
 	} while (1);
 
-	if (!bootmsg && !term)
+	if (!bootmsg && !term && !debugmsg)
 		goto usage;
 
 	if (patch && !imgpath)
@@ -702,7 +765,13 @@ main(int argc, char **argv)
 		}
 	}
 
-	if (bootmsg) {
+	if (debugmsg) {
+		rc = kwboot_debugmsg(tty, debugmsg);
+		if (rc) {
+			perror("debugmsg");
+			goto out;
+		}
+	} else {
 		rc = kwboot_bootmsg(tty, bootmsg);
 		if (rc) {
 			perror("bootmsg");
-- 
2.0.1

^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 23/25] tools: Compile kwboot for Marvell Armada XP as those SoCs are now supported
  2014-06-27  9:54 [U-Boot] [PATCH v1 0/25] Add Marvell Armada XP MV78460 SoC support Stefan Roese
                   ` (21 preceding siblings ...)
  2014-06-27  9:55 ` [U-Boot] [PATCH v1 22/25] tools/kwboot: Sync with latest barebox version to support Armada XP Stefan Roese
@ 2014-06-27  9:55 ` Stefan Roese
  2014-07-03 22:03   ` Luka Perkov
  2014-06-27  9:55 ` [U-Boot] [PATCH v1 24/25] tools: kwbimage: Add image version 1 support for Armada XP / 370 Stefan Roese
                   ` (2 subsequent siblings)
  25 siblings, 1 reply; 50+ messages in thread
From: Stefan Roese @ 2014-06-27  9:55 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Stefan Roese <sr@denx.de>
---

 tools/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/Makefile b/tools/Makefile
index 61b2048..9aab9da 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -139,6 +139,7 @@ ubsha1-objs := os_support.o ubsha1.o lib/sha1.o
 HOSTCFLAGS_ubsha1.o := -pedantic
 
 hostprogs-$(CONFIG_KIRKWOOD) += kwboot
+hostprogs-$(CONFIG_ARMADA_XP) += kwboot
 hostprogs-y += proftool
 hostprogs-$(CONFIG_STATIC_RELA) += relocate-rela
 
-- 
2.0.1

^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 24/25] tools: kwbimage: Add image version 1 support for Armada XP / 370
  2014-06-27  9:54 [U-Boot] [PATCH v1 0/25] Add Marvell Armada XP MV78460 SoC support Stefan Roese
                   ` (22 preceding siblings ...)
  2014-06-27  9:55 ` [U-Boot] [PATCH v1 23/25] tools: Compile kwboot for Marvell Armada XP as those SoCs are now supported Stefan Roese
@ 2014-06-27  9:55 ` Stefan Roese
  2014-07-03 22:03   ` Luka Perkov
  2014-06-27  9:55 ` [U-Boot] [PATCH v1 25/25] Makefile: Add CONFIG_BUILD_TARGET to automatically build an special image Stefan Roese
  2014-06-27 10:18 ` [U-Boot] [PATCH v1 0/25] Add Marvell Armada XP MV78460 SoC support Prafulla Wadaskar
  25 siblings, 1 reply; 50+ messages in thread
From: Stefan Roese @ 2014-06-27  9:55 UTC (permalink / raw)
  To: u-boot

This patch integrates the Barebox version of this kwbimage.c file into
U-Boot. As this version supports the image version 1 type for the
Armada XP / 370 SoCs.

It was easier to integrate the existing and known to be working Barebox
source than to update the current U-Boot version to support this
v1 image header format. Now all Marvell MVEBU SoCs are supported:

Image type 0: Kirkwood & Dove
Image type 1: Armada 370 & Armada XP

Please note that the current v1 support has this restuction (same as
has Barebox version):

Not implemented: support for the register headers and secure headers
in v1 images

Tested on Marvell DB-78460-BP eval board.

Signed-off-by: Stefan Roese <sr@denx.de>
---

 tools/kwbimage.c | 1050 ++++++++++++++++++++++++++++++++++++++++--------------
 1 file changed, 782 insertions(+), 268 deletions(-)

diff --git a/tools/kwbimage.c b/tools/kwbimage.c
index 109d616..1120e9b 100644
--- a/tools/kwbimage.c
+++ b/tools/kwbimage.c
@@ -1,364 +1,805 @@
 /*
- * (C) Copyright 2008
- * Marvell Semiconductor <www.marvell.com>
- * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
+ * Image manipulator for Marvell SoCs
+ *  supports Kirkwood, Dove, Armada 370, and Armada XP
+ *
+ * (C) Copyright 2013 Thomas Petazzoni
+ * <thomas.petazzoni@free-electrons.com>
  *
  * SPDX-License-Identifier:	GPL-2.0+
+ *
+ * Not implemented: support for the register headers and secure
+ * headers in v1 images
  */
 
 #include "imagetool.h"
 #include <image.h>
+#include <stdint.h>
 #include "kwbimage.h"
 
-/*
- * Supported commands for configuration file
- */
-static table_entry_t kwbimage_cmds[] = {
-	{CMD_BOOT_FROM,		"BOOT_FROM",		"boot command",	},
-	{CMD_NAND_ECC_MODE,	"NAND_ECC_MODE",	"NAND mode",	},
-	{CMD_NAND_PAGE_SIZE,	"NAND_PAGE_SIZE",	"NAND size",	},
-	{CMD_SATA_PIO_MODE,	"SATA_PIO_MODE",	"SATA mode",	},
-	{CMD_DDR_INIT_DELAY,	"DDR_INIT_DELAY",	"DDR init dly",	},
-	{CMD_DATA,		"DATA",			"Reg Write Data", },
-	{CMD_INVALID,		"",			"",	},
+#define ALIGN_SUP(x, a) (((x) + (a - 1)) & ~(a - 1))
+
+/* Structure of the main header, version 0 (Kirkwood, Dove) */
+struct main_hdr_v0 {
+	uint8_t  blockid;		/*0     */
+	uint8_t  nandeccmode;		/*1     */
+	uint16_t nandpagesize;		/*2-3   */
+	uint32_t blocksize;		/*4-7   */
+	uint32_t rsvd1;			/*8-11  */
+	uint32_t srcaddr;		/*12-15 */
+	uint32_t destaddr;		/*16-19 */
+	uint32_t execaddr;		/*20-23 */
+	uint8_t  satapiomode;		/*24    */
+	uint8_t  rsvd3;			/*25    */
+	uint16_t ddrinitdelay;		/*26-27 */
+	uint16_t rsvd2;			/*28-29 */
+	uint8_t  ext;			/*30    */
+	uint8_t  checksum;		/*31    */
+};
+
+struct ext_hdr_v0_reg {
+	uint32_t raddr;
+	uint32_t rdata;
+};
+
+#define EXT_HDR_V0_REG_COUNT ((0x1dc - 0x20) / sizeof(struct ext_hdr_v0_reg))
+
+struct ext_hdr_v0 {
+	uint32_t              offset;
+	uint8_t               reserved[0x20 - sizeof(uint32_t)];
+	struct ext_hdr_v0_reg rcfg[EXT_HDR_V0_REG_COUNT];
+	uint8_t               reserved2[7];
+	uint8_t               checksum;
+};
+
+/* Structure of the main header, version 1 (Armada 370, Armada XP) */
+struct main_hdr_v1 {
+	uint8_t  blockid;               /* 0 */
+	uint8_t  reserved1;             /* 1 */
+	uint16_t reserved2;             /* 2-3 */
+	uint32_t blocksize;             /* 4-7 */
+	uint8_t  version;               /* 8 */
+	uint8_t  headersz_msb;          /* 9 */
+	uint16_t headersz_lsb;          /* A-B */
+	uint32_t srcaddr;               /* C-F */
+	uint32_t destaddr;              /* 10-13 */
+	uint32_t execaddr;              /* 14-17 */
+	uint8_t  reserved3;             /* 18 */
+	uint8_t  nandblocksize;         /* 19 */
+	uint8_t  nandbadblklocation;    /* 1A */
+	uint8_t  reserved4;             /* 1B */
+	uint16_t reserved5;             /* 1C-1D */
+	uint8_t  ext;                   /* 1E */
+	uint8_t  checksum;              /* 1F */
 };
 
 /*
- * Supported Boot options for configuration file
+ * Header for the optional headers, version 1 (Armada 370, Armada XP)
  */
-static table_entry_t kwbimage_bootops[] = {
-	{IBR_HDR_SPI_ID,	"spi",		"SPI Flash",	},
-	{IBR_HDR_NAND_ID,	"nand",		"NAND Flash",	},
-	{IBR_HDR_SATA_ID,	"sata",		"Sata port",	},
-	{IBR_HDR_PEX_ID,	"pex",		"PCIe port",	},
-	{IBR_HDR_UART_ID,	"uart",		"Serial port",	},
-	{-1,			"",		"Invalid",	},
+struct opt_hdr_v1 {
+	uint8_t  headertype;
+	uint8_t  headersz_msb;
+	uint16_t headersz_lsb;
+	char     data[0];
 };
 
 /*
- * Supported NAND ecc options configuration file
+ * Various values for the opt_hdr_v1->headertype field, describing the
+ * different types of optional headers. The "secure" header contains
+ * informations related to secure boot (encryption keys, etc.). The
+ * "binary" header contains ARM binary code to be executed prior to
+ * executing the main payload (usually the bootloader). This is
+ * typically used to execute DDR3 training code. The "register" header
+ * allows to describe a set of (address, value) tuples that are
+ * generally used to configure the DRAM controller.
  */
-static table_entry_t kwbimage_eccmodes[] = {
-	{IBR_HDR_ECC_DEFAULT,		"default",	"Default mode",	},
-	{IBR_HDR_ECC_FORCED_HAMMING,	"hamming",	"Hamming mode",	},
-	{IBR_HDR_ECC_FORCED_RS,		"rs",		"RS mode",	},
-	{IBR_HDR_ECC_DISABLED,		"disabled",	"ECC Disabled",	},
-	{-1,				"",		"",	},
+#define OPT_HDR_V1_SECURE_TYPE   0x1
+#define OPT_HDR_V1_BINARY_TYPE   0x2
+#define OPT_HDR_V1_REGISTER_TYPE 0x3
+
+#define KWBHEADER_V1_SIZE(hdr) \
+	(((hdr)->headersz_msb << 16) | (hdr)->headersz_lsb)
+
+static struct image_cfg_element *image_cfg;
+static int cfgn;
+
+struct boot_mode {
+	unsigned int id;
+	const char *name;
+};
+
+struct boot_mode boot_modes[] = {
+	{ 0x4D, "i2c"  },
+	{ 0x5A, "spi"  },
+	{ 0x8B, "nand" },
+	{ 0x78, "sata" },
+	{ 0x9C, "pex"  },
+	{ 0x69, "uart" },
+	{},
 };
 
-static struct kwb_header kwbimage_header;
-static int datacmd_cnt = 0;
-static char * fname = "Unknown";
-static int lineno = -1;
+struct nand_ecc_mode {
+	unsigned int id;
+	const char *name;
+};
+
+struct nand_ecc_mode nand_ecc_modes[] = {
+	{ 0x00, "default" },
+	{ 0x01, "hamming" },
+	{ 0x02, "rs" },
+	{ 0x03, "disabled" },
+	{},
+};
+
+/* Used to identify an undefined execution or destination address */
+#define ADDR_INVALID ((uint32_t)-1)
+
+#define BINARY_MAX_ARGS 8
+
+/* In-memory representation of a line of the configuration file */
+struct image_cfg_element {
+	enum {
+		IMAGE_CFG_VERSION = 0x1,
+		IMAGE_CFG_BOOT_FROM,
+		IMAGE_CFG_DEST_ADDR,
+		IMAGE_CFG_EXEC_ADDR,
+		IMAGE_CFG_NAND_BLKSZ,
+		IMAGE_CFG_NAND_BADBLK_LOCATION,
+		IMAGE_CFG_NAND_ECC_MODE,
+		IMAGE_CFG_NAND_PAGESZ,
+		IMAGE_CFG_BINARY,
+		IMAGE_CFG_PAYLOAD,
+		IMAGE_CFG_DATA,
+	} type;
+	union {
+		unsigned int version;
+		unsigned int bootfrom;
+		struct {
+			const char *file;
+			unsigned int args[BINARY_MAX_ARGS];
+			unsigned int nargs;
+		} binary;
+		const char *payload;
+		unsigned int dstaddr;
+		unsigned int execaddr;
+		unsigned int nandblksz;
+		unsigned int nandbadblklocation;
+		unsigned int nandeccmode;
+		unsigned int nandpagesz;
+		struct ext_hdr_v0_reg regdata;
+	};
+};
+
+#define IMAGE_CFG_ELEMENT_MAX 256
 
 /*
- * Report Error if xflag is set in addition to default
+ * Byte 8 of the image header contains the version number. In the v0
+ * header, byte 8 was reserved, and always set to 0. In the v1 header,
+ * byte 8 has been changed to a proper field, set to 1.
  */
-static int kwbimage_check_params(struct image_tool_params *params)
+static unsigned int image_version(void *header)
 {
-	if (!strlen (params->imagename)) {
-		printf ("Error:%s - Configuration file not specified, "
-			"it is needed for kwbimage generation\n",
-			params->cmdname);
-		return CFG_INVALID;
-	}
-	return	((params->dflag && (params->fflag || params->lflag)) ||
-		(params->fflag && (params->dflag || params->lflag)) ||
-		(params->lflag && (params->dflag || params->fflag)) ||
-		(params->xflag) || !(strlen (params->imagename)));
+	unsigned char *ptr = header;
+	return ptr[8];
+}
+
+/*
+ * Utility functions to manipulate boot mode and ecc modes (convert
+ * them back and forth between description strings and the
+ * corresponding numerical identifiers).
+ */
+
+static const char *image_boot_mode_name(unsigned int id)
+{
+	int i;
+	for (i = 0; boot_modes[i].name; i++)
+		if (boot_modes[i].id == id)
+			return boot_modes[i].name;
+	return NULL;
+}
+
+int image_boot_mode_id(const char *boot_mode_name)
+{
+	int i;
+	for (i = 0; boot_modes[i].name; i++)
+		if (!strcmp(boot_modes[i].name, boot_mode_name))
+			return boot_modes[i].id;
+
+	return -1;
+}
+
+int image_nand_ecc_mode_id(const char *nand_ecc_mode_name)
+{
+	int i;
+	for (i = 0; nand_ecc_modes[i].name; i++)
+		if (!strcmp(nand_ecc_modes[i].name, nand_ecc_mode_name))
+			return nand_ecc_modes[i].id;
+	return -1;
 }
 
-static uint32_t check_get_hexval (char *token)
+static struct image_cfg_element *
+image_find_option(unsigned int optiontype)
 {
-	uint32_t hexval;
+	int i;
 
-	if (!sscanf (token, "%x", &hexval)) {
-		printf ("Error:%s[%d] - Invalid hex data(%s)\n", fname,
-			lineno, token);
-		exit (EXIT_FAILURE);
+	for (i = 0; i < cfgn; i++) {
+		if (image_cfg[i].type == optiontype)
+			return &image_cfg[i];
 	}
-	return hexval;
+
+	return NULL;
+}
+
+static unsigned int
+image_count_options(unsigned int optiontype)
+{
+	int i;
+	unsigned int count = 0;
+
+	for (i = 0; i < cfgn; i++)
+		if (image_cfg[i].type == optiontype)
+			count++;
+
+	return count;
 }
 
 /*
- * Generates 8 bit checksum
+ * Compute a 8-bit checksum of a memory area. This algorithm follows
+ * the requirements of the Marvell SoC BootROM specifications.
  */
-static uint8_t kwbimage_checksum8 (void *start, uint32_t len, uint8_t csum)
+static uint8_t image_checksum8(void *start, uint32_t len)
 {
-	register uint8_t sum = csum;
-	volatile uint8_t *p = (volatile uint8_t *)start;
+	uint8_t csum = 0;
+	uint8_t *p = start;
 
 	/* check len and return zero checksum if invalid */
 	if (!len)
 		return 0;
 
 	do {
-		sum += *p;
+		csum += *p;
 		p++;
 	} while (--len);
-	return (sum);
+
+	return csum;
 }
 
-/*
- * Generates 32 bit checksum
- */
-static uint32_t kwbimage_checksum32 (uint32_t *start, uint32_t len, uint32_t csum)
+static uint32_t image_checksum32(void *start, uint32_t len)
 {
-	register uint32_t sum = csum;
-	volatile uint32_t *p = start;
+	uint32_t csum = 0;
+	uint32_t *p = start;
 
 	/* check len and return zero checksum if invalid */
 	if (!len)
 		return 0;
 
 	if (len % sizeof(uint32_t)) {
-		printf ("Error:%s[%d] - length is not in multiple of %zu\n",
-			__FUNCTION__, len, sizeof(uint32_t));
+		fprintf(stderr, "Length %d is not in multiple of %zu\n",
+			len, sizeof(uint32_t));
 		return 0;
 	}
 
 	do {
-		sum += *p;
+		csum += *p;
 		p++;
 		len -= sizeof(uint32_t);
 	} while (len > 0);
-	return (sum);
+
+	return csum;
 }
 
-static void kwbimage_check_cfgdata (char *token, enum kwbimage_cmd cmdsw,
-					struct kwb_header *kwbhdr)
+static void *image_create_v0(size_t *imagesz, struct image_tool_params *params,
+			     int payloadsz)
 {
-	bhr_t *mhdr = &kwbhdr->kwb_hdr;
-	extbhr_t *exthdr = &kwbhdr->kwb_exthdr;
-	int i;
+	struct image_cfg_element *e;
+	size_t headersz;
+	struct main_hdr_v0 *main_hdr;
+	struct ext_hdr_v0 *ext_hdr;
+	void *image;
+	int has_ext = 0;
+
+	/*
+	 * Calculate the size of the header and the size of the
+	 * payload
+	 */
+	headersz  = sizeof(struct main_hdr_v0);
+
+	if (image_count_options(IMAGE_CFG_DATA) > 0) {
+		has_ext = 1;
+		headersz += sizeof(struct ext_hdr_v0);
+	}
+
+	if (image_count_options(IMAGE_CFG_PAYLOAD) > 1) {
+		fprintf(stderr, "More than one payload, not possible\n");
+		return NULL;
+	}
 
-	switch (cmdsw) {
-	case CMD_BOOT_FROM:
-		i = get_table_entry_id (kwbimage_bootops,
-				"Kwbimage boot option", token);
-
-		if (i < 0)
-			goto INVL_DATA;
-
-		mhdr->blockid = i;
-		printf ("Preparing kirkwood boot image to boot "
-			"from %s\n", token);
-		break;
-	case CMD_NAND_ECC_MODE:
-		i = get_table_entry_id (kwbimage_eccmodes,
-			"NAND ecc mode", token);
-
-		if (i < 0)
-			goto INVL_DATA;
-
-		mhdr->nandeccmode = i;
-		printf ("Nand ECC mode = %s\n", token);
-		break;
-	case CMD_NAND_PAGE_SIZE:
-		mhdr->nandpagesize =
-			(uint16_t) check_get_hexval (token);
-		printf ("Nand page size = 0x%x\n", mhdr->nandpagesize);
-		break;
-	case CMD_SATA_PIO_MODE:
-		mhdr->satapiomode =
-			(uint8_t) check_get_hexval (token);
-		printf ("Sata PIO mode = 0x%x\n",
-				mhdr->satapiomode);
-		break;
-	case CMD_DDR_INIT_DELAY:
-		mhdr->ddrinitdelay =
-			(uint16_t) check_get_hexval (token);
-		printf ("DDR init delay = %d msec\n", mhdr->ddrinitdelay);
-		break;
-	case CMD_DATA:
-		exthdr->rcfg[datacmd_cnt].raddr =
-			check_get_hexval (token);
-
-		break;
-	case CMD_INVALID:
-		goto INVL_DATA;
-	default:
-		goto INVL_DATA;
+	image = malloc(headersz);
+	if (!image) {
+		fprintf(stderr, "Cannot allocate memory for image\n");
+		return NULL;
 	}
-	return;
 
-INVL_DATA:
-	printf ("Error:%s[%d] - Invalid data\n", fname, lineno);
-	exit (EXIT_FAILURE);
+	memset(image, 0, headersz);
+
+	main_hdr = image;
+
+	/* Fill in the main header */
+	main_hdr->blocksize = payloadsz + sizeof(uint32_t);
+	main_hdr->srcaddr   = headersz;
+	main_hdr->ext       = has_ext;
+	main_hdr->destaddr  = params->addr;
+	main_hdr->execaddr  = params->ep;
+
+	e = image_find_option(IMAGE_CFG_BOOT_FROM);
+	if (e)
+		main_hdr->blockid = e->bootfrom;
+	e = image_find_option(IMAGE_CFG_NAND_ECC_MODE);
+	if (e)
+		main_hdr->nandeccmode = e->nandeccmode;
+	e = image_find_option(IMAGE_CFG_NAND_PAGESZ);
+	if (e)
+		main_hdr->nandpagesize = e->nandpagesz;
+	main_hdr->checksum = image_checksum8(image,
+					     sizeof(struct main_hdr_v0));
+
+	/* Generate the ext header */
+	if (has_ext) {
+		int cfgi, datai;
+
+		ext_hdr = image + sizeof(struct main_hdr_v0);
+		ext_hdr->offset = 0x40;
+
+		for (cfgi = 0, datai = 0; cfgi < cfgn; cfgi++) {
+			e = &image_cfg[cfgi];
+			if (e->type != IMAGE_CFG_DATA)
+				continue;
+
+			ext_hdr->rcfg[datai].raddr = e->regdata.raddr;
+			ext_hdr->rcfg[datai].rdata = e->regdata.rdata;
+			datai++;
+		}
+
+		ext_hdr->checksum = image_checksum8(ext_hdr,
+						    sizeof(struct ext_hdr_v0));
+	}
+
+	*imagesz = headersz;
+	return image;
 }
 
-/*
- * this function sets the kwbimage header by-
- * 	1. Abstracting input command line arguments data
- *	2. parses the kwbimage configuration file and update extebded header data
- *	3. calculates header, extended header and image checksums
- */
-static void kwdimage_set_ext_header (struct kwb_header *kwbhdr, char* name) {
-	bhr_t *mhdr = &kwbhdr->kwb_hdr;
-	extbhr_t *exthdr = &kwbhdr->kwb_exthdr;
-	FILE *fd = NULL;
-	int j;
-	char *line = NULL;
-	char * token, *saveptr1, *saveptr2;
-	size_t len = 0;
-	enum kwbimage_cmd cmd;
-
-	fname = name;
-	/* set dram register offset */
-	exthdr->dramregsoffs = (intptr_t)&exthdr->rcfg - (intptr_t)mhdr;
-
-	if ((fd = fopen (name, "r")) == 0) {
-		printf ("Error:%s - Can't open\n", fname);
-		exit (EXIT_FAILURE);
+static size_t image_headersz_v1(struct image_tool_params *params,
+				int *hasext)
+{
+	struct image_cfg_element *binarye;
+	size_t headersz;
+	int ret;
+
+	/*
+	 * Calculate the size of the header and the size of the
+	 * payload
+	 */
+	headersz = sizeof(struct main_hdr_v1);
+
+	if (image_count_options(IMAGE_CFG_BINARY) > 1) {
+		fprintf(stderr, "More than one binary blob, not supported\n");
+		return 0;
 	}
 
-	/* Simple kwimage.cfg file parser */
-	lineno=0;
-	while ((getline (&line, &len, fd)) > 0) {
-		lineno++;
-		token = strtok_r (line, "\r\n", &saveptr1);
-		/* drop all lines with zero tokens (= empty lines) */
-		if (token == NULL)
-			continue;
+	if (image_count_options(IMAGE_CFG_PAYLOAD) > 1) {
+		fprintf(stderr, "More than one payload, not possible\n");
+		return 0;
+	}
 
-		for (j = 0, cmd = CMD_INVALID, line = token; ; line = NULL) {
-			token = strtok_r (line, " \t", &saveptr2);
-			if (token == NULL)
-			break;
-			/* Drop all text starting with '#' as comments */
-			if (token[0] == '#')
-				break;
+	binarye = image_find_option(IMAGE_CFG_BINARY);
+	if (binarye) {
+		struct stat s;
+
+		ret = stat(binarye->binary.file, &s);
+		if (ret < 0) {
+			char *cwd = get_current_dir_name();
+			fprintf(stderr,
+				"Didn't find the file '%s' in '%s' which is mandatory to generate the image\n"
+				"This file generally contains the DDR3 training code, and should be extracted from an existing bootable\n"
+				"image for your board. See 'kwbimage -x' to extract it from an existing image.\n",
+				binarye->binary.file, cwd);
+			free(cwd);
+			return 0;
+		}
 
-			/* Process rest as valid config command line */
-			switch (j) {
-			case CFG_COMMAND:
-				cmd = get_table_entry_id (kwbimage_cmds,
-						"Kwbimage command", token);
+		headersz += s.st_size +
+			binarye->binary.nargs * sizeof(unsigned int);
+		if (hasext)
+			*hasext = 1;
+	}
 
-				if (cmd == CMD_INVALID)
-					goto INVL_CMD;
-				break;
+	/*
+	 * The payload should be aligned on some reasonable
+	 * boundary
+	 */
+	return ALIGN_SUP(headersz, 4096);
+}
 
-			case CFG_DATA0:
-				kwbimage_check_cfgdata (token, cmd, kwbhdr);
-				break;
+static void *image_create_v1(size_t *imagesz, struct image_tool_params *params,
+			     int payloadsz)
+{
+	struct image_cfg_element *e, *binarye;
+	struct main_hdr_v1 *main_hdr;
+	size_t headersz;
+	void *image, *cur;
+	int hasext = 0;
+	int ret;
+
+	/*
+	 * Calculate the size of the header and the size of the
+	 * payload
+	 */
+	headersz = image_headersz_v1(params, &hasext);
+	if (headersz == 0)
+		return NULL;
+
+	image = malloc(headersz);
+	if (!image) {
+		fprintf(stderr, "Cannot allocate memory for image\n");
+		return NULL;
+	}
 
-			case CFG_DATA1:
-				if (cmd != CMD_DATA)
-					goto INVL_CMD;
-
-				exthdr->rcfg[datacmd_cnt].rdata =
-						check_get_hexval (token);
-
-				if (datacmd_cnt > KWBIMAGE_MAX_CONFIG ) {
-					printf ("Error:%s[%d] - Found more "
-						"than max(%zd) allowed "
-						"data configurations\n",
-						fname, lineno,
-						KWBIMAGE_MAX_CONFIG);
-				exit (EXIT_FAILURE);
-				} else
-					datacmd_cnt++;
-				break;
+	memset(image, 0, headersz);
+
+	cur = main_hdr = image;
+	cur += sizeof(struct main_hdr_v1);
+
+	/* Fill the main header */
+	main_hdr->blocksize    = payloadsz - headersz + sizeof(uint32_t);
+	main_hdr->headersz_lsb = headersz & 0xFFFF;
+	main_hdr->headersz_msb = (headersz & 0xFFFF0000) >> 16;
+	main_hdr->destaddr     = params->addr;
+	main_hdr->execaddr     = params->ep;
+	main_hdr->srcaddr      = headersz;
+	main_hdr->ext          = hasext;
+	main_hdr->version      = 1;
+	e = image_find_option(IMAGE_CFG_BOOT_FROM);
+	if (e)
+		main_hdr->blockid = e->bootfrom;
+	e = image_find_option(IMAGE_CFG_NAND_BLKSZ);
+	if (e)
+		main_hdr->nandblocksize = e->nandblksz / (64 * 1024);
+	e = image_find_option(IMAGE_CFG_NAND_BADBLK_LOCATION);
+	if (e)
+		main_hdr->nandbadblklocation = e->nandbadblklocation;
+
+	binarye = image_find_option(IMAGE_CFG_BINARY);
+	if (binarye) {
+		struct opt_hdr_v1 *hdr = cur;
+		unsigned int *args;
+		size_t binhdrsz;
+		struct stat s;
+		int argi;
+		FILE *bin;
+
+		hdr->headertype = OPT_HDR_V1_BINARY_TYPE;
+
+		bin = fopen(binarye->binary.file, "r");
+		if (!bin) {
+			fprintf(stderr, "Cannot open binary file %s\n",
+				binarye->binary.file);
+			return NULL;
+		}
+
+		fstat(fileno(bin), &s);
+
+		binhdrsz = sizeof(struct opt_hdr_v1) +
+			(binarye->binary.nargs + 1) * sizeof(unsigned int) +
+			s.st_size;
+		hdr->headersz_lsb = binhdrsz & 0xFFFF;
+		hdr->headersz_msb = (binhdrsz & 0xFFFF0000) >> 16;
+
+		cur += sizeof(struct opt_hdr_v1);
+
+		args = cur;
+		*args = binarye->binary.nargs;
+		args++;
+		for (argi = 0; argi < binarye->binary.nargs; argi++)
+			args[argi] = binarye->binary.args[argi];
+
+		cur += (binarye->binary.nargs + 1) * sizeof(unsigned int);
+
+		ret = fread(cur, s.st_size, 1, bin);
+		if (ret != 1) {
+			fprintf(stderr,
+				"Could not read binary image %s\n",
+				binarye->binary.file);
+			return NULL;
+		}
+
+		fclose(bin);
 
-			default:
-				goto INVL_CMD;
+		cur += s.st_size;
+
+		/*
+		 * For now, we don't support more than one binary
+		 * header, and no other header types are
+		 * supported. So, the binary header is necessarily the
+		 * last one
+		 */
+		*((unsigned char *)cur) = 0;
+
+		cur += sizeof(uint32_t);
+	}
+
+	/* Calculate and set the header checksum */
+	main_hdr->checksum = image_checksum8(main_hdr, headersz);
+
+	*imagesz = headersz;
+	return image;
+}
+
+static int image_create_config_parse_oneline(char *line,
+					     struct image_cfg_element *el)
+{
+	char *keyword, *saveptr;
+	char deliminiters[] = " \t";
+
+	keyword = strtok_r(line, deliminiters, &saveptr);
+	if (!strcmp(keyword, "VERSION")) {
+		char *value = strtok_r(NULL, deliminiters, &saveptr);
+		el->type = IMAGE_CFG_VERSION;
+		el->version = atoi(value);
+	} else if (!strcmp(keyword, "BOOT_FROM")) {
+		char *value = strtok_r(NULL, deliminiters, &saveptr);
+		el->type = IMAGE_CFG_BOOT_FROM;
+		el->bootfrom = image_boot_mode_id(value);
+		if (el->bootfrom < 0) {
+			fprintf(stderr,
+				"Invalid boot media '%s'\n", value);
+			return -1;
+		}
+	} else if (!strcmp(keyword, "NAND_BLKSZ")) {
+		char *value = strtok_r(NULL, deliminiters, &saveptr);
+		el->type = IMAGE_CFG_NAND_BLKSZ;
+		el->nandblksz = strtoul(value, NULL, 16);
+	} else if (!strcmp(keyword, "NAND_BADBLK_LOCATION")) {
+		char *value = strtok_r(NULL, deliminiters, &saveptr);
+		el->type = IMAGE_CFG_NAND_BADBLK_LOCATION;
+		el->nandbadblklocation =
+			strtoul(value, NULL, 16);
+	} else if (!strcmp(keyword, "NAND_ECC_MODE")) {
+		char *value = strtok_r(NULL, deliminiters, &saveptr);
+		el->type = IMAGE_CFG_NAND_ECC_MODE;
+		el->nandeccmode = image_nand_ecc_mode_id(value);
+		if (el->nandeccmode < 0) {
+			fprintf(stderr,
+				"Invalid NAND ECC mode '%s'\n", value);
+			return -1;
+		}
+	} else if (!strcmp(keyword, "NAND_PAGE_SIZE")) {
+		char *value = strtok_r(NULL, deliminiters, &saveptr);
+		el->type = IMAGE_CFG_NAND_PAGESZ;
+		el->nandpagesz = strtoul(value, NULL, 16);
+	} else if (!strcmp(keyword, "BINARY")) {
+		char *value = strtok_r(NULL, deliminiters, &saveptr);
+		int argi = 0;
+
+		el->type = IMAGE_CFG_BINARY;
+		el->binary.file = strdup(value);
+		while (1) {
+			value = strtok_r(NULL, deliminiters, &saveptr);
+			if (!value)
+				break;
+			el->binary.args[argi] = strtoul(value, NULL, 16);
+			argi++;
+			if (argi >= BINARY_MAX_ARGS) {
+				fprintf(stderr,
+					"Too many argument for binary\n");
+				return -1;
 			}
-			j++;
 		}
+		el->binary.nargs = argi;
+	} else if (!strcmp(keyword, "DATA")) {
+		char *value1 = strtok_r(NULL, deliminiters, &saveptr);
+		char *value2 = strtok_r(NULL, deliminiters, &saveptr);
+
+		if (!value1 || !value2) {
+			fprintf(stderr,
+				"Invalid number of arguments for DATA\n");
+			return -1;
+		}
+
+		el->type = IMAGE_CFG_DATA;
+		el->regdata.raddr = strtoul(value1, NULL, 16);
+		el->regdata.rdata = strtoul(value2, NULL, 16);
+	} else {
+		fprintf(stderr, "Ignoring unknown line '%s'\n", line);
 	}
-	if (line)
-		free (line);
 
-	fclose (fd);
-	return;
+	return 0;
+}
 
 /*
- * Invalid Command error reporring
- *
- * command CMD_DATA needs three strings on a line
- * whereas other commands need only two.
- *
- * if more than two/three (as per command type) are observed,
- * then error will be reported
+ * Parse the configuration file 'fcfg' into the array of configuration
+ * elements 'image_cfg', and return the number of configuration
+ * elements in 'cfgn'.
  */
-INVL_CMD:
-	printf ("Error:%s[%d] - Invalid command\n", fname, lineno);
-	exit (EXIT_FAILURE);
+static int image_create_config_parse(FILE *fcfg)
+{
+	int ret;
+	int cfgi = 0;
+
+	/* Parse the configuration file */
+	while (!feof(fcfg)) {
+		char *line;
+		char buf[256];
+
+		/* Read the current line */
+		memset(buf, 0, sizeof(buf));
+		line = fgets(buf, sizeof(buf), fcfg);
+		if (!line)
+			break;
+
+		/* Ignore useless lines */
+		if (line[0] == '\n' || line[0] == '#')
+			continue;
+
+		/* Strip final newline */
+		if (line[strlen(line) - 1] == '\n')
+			line[strlen(line) - 1] = 0;
+
+		/* Parse the current line */
+		ret = image_create_config_parse_oneline(line,
+							&image_cfg[cfgi]);
+		if (ret)
+			return ret;
+
+		cfgi++;
+
+		if (cfgi >= IMAGE_CFG_ELEMENT_MAX) {
+			fprintf(stderr,
+				"Too many configuration elements in .cfg file\n");
+			return -1;
+		}
+	}
+
+	cfgn = cfgi;
+	return 0;
+}
+
+static int image_get_version(void)
+{
+	struct image_cfg_element *e;
+
+	e = image_find_option(IMAGE_CFG_VERSION);
+	if (!e)
+		return -1;
+
+	return e->version;
+}
+
+static int image_version_file(const char *input)
+{
+	FILE *fcfg;
+	int version;
+	int ret;
+
+	fcfg = fopen(input, "r");
+	if (!fcfg) {
+		fprintf(stderr, "Could not open input file %s\n", input);
+		return -1;
+	}
+
+	image_cfg = malloc(IMAGE_CFG_ELEMENT_MAX *
+			   sizeof(struct image_cfg_element));
+	if (!image_cfg) {
+		fprintf(stderr, "Cannot allocate memory\n");
+		fclose(fcfg);
+		return -1;
+	}
+
+	memset(image_cfg, 0,
+	       IMAGE_CFG_ELEMENT_MAX * sizeof(struct image_cfg_element));
+	rewind(fcfg);
+
+	ret = image_create_config_parse(fcfg);
+	fclose(fcfg);
+	if (ret) {
+		free(image_cfg);
+		return -1;
+	}
+
+	version = image_get_version();
+	/* Fallback to version 0 is no version is provided in the cfg file */
+	if (version == -1)
+		version = 0;
+
+	free(image_cfg);
+
+	return version;
 }
 
-static void kwbimage_set_header (void *ptr, struct stat *sbuf, int ifd,
+static void kwbimage_set_header(void *ptr, struct stat *sbuf, int ifd,
 				struct image_tool_params *params)
 {
-	struct kwb_header *hdr = (struct kwb_header *)ptr;
-	bhr_t *mhdr = &hdr->kwb_hdr;
-	extbhr_t *exthdr = &hdr->kwb_exthdr;
+	FILE *fcfg;
+	void *image = NULL;
+	int version;
+	size_t headersz;
 	uint32_t checksum;
+	int ret;
 	int size;
 
-	/* Build and add image checksum header */
-	checksum = kwbimage_checksum32 ((uint32_t *)ptr, sbuf->st_size, 0);
+	fcfg = fopen(params->imagename, "r");
+	if (!fcfg) {
+		fprintf(stderr, "Could not open input file %s\n",
+			params->imagename);
+		exit(EXIT_FAILURE);
+	}
+
+	image_cfg = malloc(IMAGE_CFG_ELEMENT_MAX *
+			   sizeof(struct image_cfg_element));
+	if (!image_cfg) {
+		fprintf(stderr, "Cannot allocate memory\n");
+		fclose(fcfg);
+		exit(EXIT_FAILURE);
+	}
+
+	memset(image_cfg, 0,
+	       IMAGE_CFG_ELEMENT_MAX * sizeof(struct image_cfg_element));
+	rewind(fcfg);
+
+	ret = image_create_config_parse(fcfg);
+	fclose(fcfg);
+	if (ret) {
+		free(image_cfg);
+		exit(EXIT_FAILURE);
+	}
+
+	version = image_get_version();
+	/* Fallback to version 0 is no version is provided in the cfg file */
+	if (version == -1)
+		version = 0;
+
+	if (version == 0)
+		image = image_create_v0(&headersz, params, sbuf->st_size);
+	else if (version == 1)
+		image = image_create_v1(&headersz, params, sbuf->st_size);
+
+	if (!image) {
+		fprintf(stderr, "Could not create image\n");
+		free(image_cfg);
+		exit(EXIT_FAILURE);
+	}
+
+	free(image_cfg);
 
-	size = write (ifd, &checksum, sizeof(uint32_t));
+	/* Build and add image checksum header */
+	checksum = image_checksum32((uint32_t *)ptr, sbuf->st_size);
+	size = write(ifd, &checksum, sizeof(uint32_t));
 	if (size != sizeof(uint32_t)) {
-		printf ("Error:%s - Checksum write %d bytes %s\n",
+		fprintf(stderr, "Error:%s - Checksum write %d bytes %s\n",
 			params->cmdname, size, params->imagefile);
-		exit (EXIT_FAILURE);
+		exit(EXIT_FAILURE);
 	}
 
 	sbuf->st_size += sizeof(uint32_t);
 
-	mhdr->blocksize = sbuf->st_size - sizeof(struct kwb_header);
-	mhdr->srcaddr = sizeof(struct kwb_header);
-	mhdr->destaddr= params->addr;
-	mhdr->execaddr =params->ep;
-	mhdr->ext = 0x1; /* header extension appended */
-
-	kwdimage_set_ext_header (hdr, params->imagename);
-	/* calculate checksums */
-	mhdr->checkSum = kwbimage_checksum8 ((void *)mhdr, sizeof(bhr_t), 0);
-	exthdr->checkSum = kwbimage_checksum8 ((void *)exthdr,
-						sizeof(extbhr_t), 0);
-}
-
-static int kwbimage_verify_header (unsigned char *ptr, int image_size,
-			struct image_tool_params *params)
-{
-	struct kwb_header *hdr = (struct kwb_header *)ptr;
-	bhr_t *mhdr = &hdr->kwb_hdr;
-	extbhr_t *exthdr = &hdr->kwb_exthdr;
-	uint8_t calc_hdrcsum;
-	uint8_t calc_exthdrcsum;
-
-	calc_hdrcsum = kwbimage_checksum8 ((void *)mhdr,
-			sizeof(bhr_t) - sizeof(uint8_t), 0);
-	if (calc_hdrcsum != mhdr->checkSum)
-		return -FDT_ERR_BADSTRUCTURE;	/* mhdr csum not matched */
-
-	calc_exthdrcsum = kwbimage_checksum8 ((void *)exthdr,
-			sizeof(extbhr_t) - sizeof(uint8_t), 0);
-	if (calc_exthdrcsum != exthdr->checkSum)
-		return -FDT_ERR_BADSTRUCTURE; /* exthdr csum not matched */
+	/* Finally copy the header into the image area */
+	memcpy(ptr, image, headersz);
 
-	return 0;
+	free(image);
 }
 
-static void kwbimage_print_header (const void *ptr)
+static void kwbimage_print_header(const void *ptr)
 {
-	struct kwb_header *hdr = (struct kwb_header *) ptr;
-	bhr_t *mhdr = &hdr->kwb_hdr;
-	char *name = get_table_entry_name (kwbimage_bootops,
-				"Kwbimage boot option",
-				(int) mhdr->blockid);
-
-	printf ("Image Type:   Kirkwood Boot from %s Image\n", name);
-	printf ("Data Size:    ");
-	genimg_print_size (mhdr->blocksize - sizeof(uint32_t));
-	printf ("Load Address: %08x\n", mhdr->destaddr);
-	printf ("Entry Point:  %08x\n", mhdr->execaddr);
+	struct main_hdr_v0 *mhdr = (struct main_hdr_v0 *)ptr;
+
+	printf("Image Type:   MVEBU Boot from %s Image\n",
+	       image_boot_mode_name(mhdr->blockid));
+	printf("Data Size:    ");
+	printf("Image version:%d\n", image_version((void *)ptr));
+	genimg_print_size(mhdr->blocksize - sizeof(uint32_t));
+	printf("Load Address: %08x\n", mhdr->destaddr);
+	printf("Entry Point:  %08x\n", mhdr->execaddr);
 }
 
-static int kwbimage_check_image_types (uint8_t type)
+static int kwbimage_check_image_types(uint8_t type)
 {
 	if (type == IH_TYPE_KWBIMAGE)
 		return EXIT_SUCCESS;
@@ -366,18 +807,91 @@ static int kwbimage_check_image_types (uint8_t type)
 		return EXIT_FAILURE;
 }
 
+static int kwbimage_verify_header(unsigned char *ptr, int image_size,
+				  struct image_tool_params *params)
+{
+	struct main_hdr_v0 *main_hdr;
+	struct ext_hdr_v0 *ext_hdr;
+	uint8_t checksum;
+
+	main_hdr = (void *)ptr;
+	checksum = image_checksum8(ptr,
+				   sizeof(struct main_hdr_v0));
+	if (checksum != main_hdr->checksum)
+		return -FDT_ERR_BADSTRUCTURE;
+
+	/* Only version 0 extended header has checksum */
+	if (image_version((void *)ptr) == 0) {
+		ext_hdr = (void *)ptr + sizeof(struct main_hdr_v0);
+		checksum = image_checksum8(ext_hdr,
+					   sizeof(struct ext_hdr_v0));
+		if (checksum != ext_hdr->checksum)
+			return -FDT_ERR_BADSTRUCTURE;
+	}
+
+	return 0;
+}
+
+static int kwbimage_generate(struct image_tool_params *params,
+			     struct image_type_params *tparams)
+{
+	int alloc_len;
+	void *hdr;
+	int version = 0;
+
+	version = image_version_file(params->imagename);
+	if (version == 0) {
+		alloc_len = sizeof(struct main_hdr_v0) +
+			sizeof(struct ext_hdr_v0);
+	} else {
+		alloc_len = image_headersz_v1(params, NULL);
+	}
+
+	hdr = malloc(alloc_len);
+	if (!hdr) {
+		fprintf(stderr, "%s: malloc return failure: %s\n",
+			params->cmdname, strerror(errno));
+		exit(EXIT_FAILURE);
+	}
+
+	memset(hdr, 0, alloc_len);
+	tparams->header_size = alloc_len;
+	tparams->hdr = hdr;
+
+	return 0;
+}
+
+/*
+ * Report Error if xflag is set in addition to default
+ */
+static int kwbimage_check_params(struct image_tool_params *params)
+{
+	if (!strlen(params->imagename)) {
+		fprintf(stderr, "Error:%s - Configuration file not specified, "
+			"it is needed for kwbimage generation\n",
+			params->cmdname);
+		return CFG_INVALID;
+	}
+
+	return (params->dflag && (params->fflag || params->lflag)) ||
+		(params->fflag && (params->dflag || params->lflag)) ||
+		(params->lflag && (params->dflag || params->fflag)) ||
+		(params->xflag) || !(strlen(params->imagename));
+}
+
 /*
  * kwbimage type parameters definition
  */
 static struct image_type_params kwbimage_params = {
-	.name = "Kirkwood Boot Image support",
-	.header_size = sizeof(struct kwb_header),
-	.hdr = (void*)&kwbimage_header,
+	.name		= "Marvell MVEBU Boot Image support",
+	.header_size	= 0,		/* no fixed header size */
+	.hdr		= NULL,
+	.vrec_header	= kwbimage_generate,
 	.check_image_type = kwbimage_check_image_types,
-	.verify_header = kwbimage_verify_header,
-	.print_header = kwbimage_print_header,
-	.set_header = kwbimage_set_header,
-	.check_params = kwbimage_check_params,
+	.verify_header	= kwbimage_verify_header,
+	.print_header	= kwbimage_print_header,
+	.set_header	= kwbimage_set_header,
+	.check_params	= kwbimage_check_params,
 };
 
 void init_kwb_image_type (void)
-- 
2.0.1

^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 25/25] Makefile: Add CONFIG_BUILD_TARGET to automatically build an special image
  2014-06-27  9:54 [U-Boot] [PATCH v1 0/25] Add Marvell Armada XP MV78460 SoC support Stefan Roese
                   ` (23 preceding siblings ...)
  2014-06-27  9:55 ` [U-Boot] [PATCH v1 24/25] tools: kwbimage: Add image version 1 support for Armada XP / 370 Stefan Roese
@ 2014-06-27  9:55 ` Stefan Roese
  2014-06-27 10:18 ` [U-Boot] [PATCH v1 0/25] Add Marvell Armada XP MV78460 SoC support Prafulla Wadaskar
  25 siblings, 0 replies; 50+ messages in thread
From: Stefan Roese @ 2014-06-27  9:55 UTC (permalink / raw)
  To: u-boot

Add target to build it automatically upon "make" / MAKEALL. This can/should
be set by board / cpu specific headers if a special U-Boot image is
required for this SoC / board.

E.g. used by Marvell Armada XP to automatically build the u-boot.kwb
target.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Masahiro Yamada <yamada.m@jp.panasonic.com>

---

 Makefile | 5 +++++
 README   | 8 ++++++++
 2 files changed, 13 insertions(+)

diff --git a/Makefile b/Makefile
index e45a25c..44572c0 100644
--- a/Makefile
+++ b/Makefile
@@ -742,6 +742,11 @@ endif
 endif
 endif
 
+# Add optional build target if defined in board/cpu/soc headers
+ifneq ($(CONFIG_BUILD_TARGET),)
+ALL-y += $(CONFIG_BUILD_TARGET:"%"=%)
+endif
+
 LDFLAGS_u-boot += $(LDFLAGS_FINAL)
 ifneq ($(CONFIG_SYS_TEXT_BASE),)
 LDFLAGS_u-boot += -Ttext $(CONFIG_SYS_TEXT_BASE)
diff --git a/README b/README
index fe5cacb..4b4633c 100644
--- a/README
+++ b/README
@@ -2657,6 +2657,14 @@ CBFS (Coreboot Filesystem) support
 		200 ms.
 
 - Configuration Management:
+		CONFIG_BUILD_TARGET
+
+		Some SoCs need special image types (e.g. U-Boot binary
+		with a special header) as build targets. By defining
+		CONFIG_BUILD_TARGET in the SoC / board header, this
+		special image will be automatically built upon calling
+		make / MAKEALL.
+
 		CONFIG_IDENT_STRING
 
 		If defined, this string will be added to the U-Boot
-- 
2.0.1

^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 0/25] Add Marvell Armada XP MV78460 SoC support
  2014-06-27  9:54 [U-Boot] [PATCH v1 0/25] Add Marvell Armada XP MV78460 SoC support Stefan Roese
                   ` (24 preceding siblings ...)
  2014-06-27  9:55 ` [U-Boot] [PATCH v1 25/25] Makefile: Add CONFIG_BUILD_TARGET to automatically build an special image Stefan Roese
@ 2014-06-27 10:18 ` Prafulla Wadaskar
  2014-07-13 16:15   ` Jagan Teki
  25 siblings, 1 reply; 50+ messages in thread
From: Prafulla Wadaskar @ 2014-06-27 10:18 UTC (permalink / raw)
  To: u-boot



> -----Original Message-----
> From: Stefan Roese [mailto:sr at denx.de]
> Sent: 27 June 2014 15:25
> To: u-boot at lists.denx.de
> Cc: Prafulla Wadaskar; trini at ti.com
> Subject: [PATCH v1 0/25] Add Marvell Armada XP MV78460
> SoC support
> 
> 
> This patch series adds support for the Marvell Armada
> XP SoC's. Specifically
> the MV78460.
> 
> Basic support for the db-78460-bp evaluation board is
> added. Supporting the
> following interfaces:
> - UART
> - SPI (including SPI NOR flash)
> - I2C
> - Ethernet (neta)
> 
> While doing this port, I tried to consolidate common
> Marvell code into
> the arch/arm/mvebu-common directory. This directory
> should be used to
> collect more common code for the MVEBU SoC's (Dove,
> Kirkwood, Armada 370,
> Armada 380, Armada XP). I started with Kirkwood and
> some of its
> interfaces. Dove is definitely a candidate to move some
> of its code
> into thise directory as well.
> 
> Because of the renaming of some functions from kirkwood
> to mvebu (to make
> them better usable on other MVEBU SoCs), this patch
> series not only
> touches the ARM SoC specific files (in arch/arm/...).
> But also some
> device drivers (e.g. SPI, I2C). Separating these driver
> specific patches
> into different patches that are not depending on this
> ARM patch series
> seems hard if not impossible. Thats why I would really
> like to get this
> patch series to get  applied completely be one
> custodian. Not sure if
> this could / should go through Tom directly? Only if
> all the subsystem
> custodians have given their "Acked-by ..." of course.

Hi Stefan,
I agree with you, since this patch series have huge changes it may go to Tom directly, I will review, test and provide ack/nack accordingly.

> 
> Testing on Kirkwood based boards would be greatly
> appreciated. So anyone with
> access to some of those board, please give this patch
> series a try. I really
> hope that I didn't break anything while merging some of
> the code into the
> common mvebu directory.

I will certainly help to test testing this stuff on all possible boards that I can access.

> 
> Please note that this Armada XP port still requires the
> "Binary Header"
> (bin_hdr) from the Marvell U-Boot tree to be included
> as a binary blob
> into the resulting image (u-boot.kwb) that can be
> booted by the MVEBU
> BootROM. This binary bin_hdr is usually responsible for
> the DDR3
> controller configuration and the DDR3 training. One way
> to extract this
> bin_hdr binary from an existing Marvell boot image
> right now is to use
> the "kwbimage" tool from Barebox. Please refer to the
> documentation
> thats available there for more details.

Finally, last but not least, may thanks for your efforts and all the best for smooth migration ahead.

Regards...
Prafulla . . .

> 
> Thanks,
> Stefan
> 
> 
> Stefan Roese (25):
>   sf: Add M25PX64 SPI NOR flash ID
>   arm: kirkwood: spi.h: Add some missing parenthesis
>   spi: kirkwood_spi.c: Some fixes and cleanup
>   spi: kirkwood_spi.c: Make global variable static
>   spi: kirkwood_spi.c: cosmetic: Fix minor coding style
> issues
>   arm: kirkwood: Move some SoC files into new
> arch/arm/mvebu-common
>   arm: marvell: Move arch/kirkwood.h to arch/soc.h
>   arm: marvell: Move arch-kirkwood/spi.h to arch-
> mvebu/spi.h
>   arm: marvell: Rework timer.c to make it usable for
> other MVEBU
>     platforms
>   arm: mvebu: Add common mbus functions to use on
> Marvell SoCs
>   spi: kirkwood_spi.c: Compile MPP (pin-mux) only for
> kirkwood SoC's
>   arm: marvell: Extract kirkwood gpio functions into
> new common file
>     gpio.c
>   spi: kirkwood_spi.c: Change KW_SPI_BASE to
> MVEBU_SPI_BASE
>   arm: kirkwood: Change naming of dram functions from
> km_foo() to
>     mvebu_foo()
>   net: mvneta.c: Add support for the ethernet
> controller of the Marvell
>     Armada XP SoC
>   net: phy.h: Make PHY autonegotiation timeout
> configurable
>   i2c: mvtwsi: Add support for Marvell Armada XP
>   arm: armada-xp: Add basic support for Marvell Armada
> XP SoC
>   arm: armada-xp: Add basic support for the Marvell DB-
> 78460-BP board
>   arm: kirkwood: Remove some dead code from cpu.c
>   arm: kirkwood: Use mvebu new common mbus API
>   tools/kwboot: Sync with latest barebox version to
> support Armada XP
>   tools: Compile kwboot for Marvell Armada XP as those
> SoCs are now
>     supported
>   tools: kwbimage: Add image version 1 support for
> Armada XP / 370
>   Makefile: Add CONFIG_BUILD_TARGET to automatically
> build an special
>     image
> 
>  Makefile                                           |
> 9 +
>  README                                             |
> 8 +
>  arch/arm/cpu/arm926ejs/kirkwood/Makefile           |
> 4 +-
>  arch/arm/cpu/arm926ejs/kirkwood/cpu.c              |
> 174 +--
>  arch/arm/cpu/arm926ejs/kirkwood/mpp.c              |
> 2 +-
>  arch/arm/cpu/armv7/armada-xp/Makefile              |
> 7 +
>  arch/arm/cpu/armv7/armada-xp/cpu.c                 |
> 186 +++
>  arch/arm/include/asm/arch-armada-xp/config.h       |
> 80 +
>  arch/arm/include/asm/arch-armada-xp/cpu.h          |
> 103 ++
>  arch/arm/include/asm/arch-armada-xp/soc.h          |
> 57 +
>  arch/arm/include/asm/arch-kirkwood/config.h        |
> 2 +-
>  arch/arm/include/asm/arch-kirkwood/cpu.h           |
> 71 +-
>  arch/arm/include/asm/arch-kirkwood/gpio.h          |
> 16 +-
>  .../asm/arch-kirkwood/{kirkwood.h => soc.h}        |
> 25 +-
>  .../asm/{arch-kirkwood => arch-mvebu}/spi.h        |
> 8 +-
>  arch/arm/mvebu-common/Makefile                     |
> 12 +
>  .../arm926ejs/kirkwood => mvebu-common}/dram.c     |
> 63 +-
>  arch/arm/mvebu-common/gpio.c                       |
> 30 +
>  arch/arm/mvebu-common/mbus.c                       |
> 477 ++++++
>  .../arm926ejs/kirkwood => mvebu-common}/timer.c    |
> 92 +-
>  board/LaCie/net2big_v2/net2big_v2.c                |
> 8 +-
>  board/LaCie/netspace_v2/netspace_v2.c              |
> 8 +-
>  board/LaCie/wireless_space/wireless_space.c        |
> 8 +-
>  board/Marvell/db-78460-bp/Makefile                 |
> 7 +
>  board/Marvell/db-78460-bp/db-78460-bp.c            |
> 120 ++
>  board/Marvell/db-78460-bp/kwbimage.cfg             |
> 12 +
>  board/Marvell/dreamplug/dreamplug.c                |
> 10 +-
>  board/Marvell/guruplug/guruplug.c                  |
> 10 +-
>  board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c    |
> 10 +-
>  board/Marvell/openrd/openrd.c                      |
> 10 +-
>  board/Marvell/rd6281a/rd6281a.c                    |
> 10 +-
>  board/Marvell/sheevaplug/sheevaplug.c              |
> 10 +-
>  board/Seagate/dockstar/dockstar.c                  |
> 12 +-
>  board/Seagate/goflexhome/goflexhome.c              |
> 12 +-
>  board/buffalo/lsxl/lsxl.c                          |
> 10 +-
>  board/cloudengines/pogo_e02/pogo_e02.c             |
> 10 +-
>  board/d-link/dns325/dns325.c                       |
> 8 +-
>  board/iomega/iconnect/iconnect.c                   |
> 10 +-
>  board/karo/tk71/tk71.c                             |
> 10 +-
>  board/keymile/km_arm/km_arm.c                      |
> 10 +-
>  board/raidsonic/ib62x0/ib62x0.c                    |
> 10 +-
>  boards.cfg                                         |
> 1 +
>  drivers/block/mvsata_ide.c                         |
> 2 +-
>  drivers/gpio/kw_gpio.c                             |
> 2 +-
>  drivers/i2c/mvtwsi.c                               |
> 4 +-
>  drivers/mtd/nand/kirkwood_nand.c                   |
> 2 +-
>  drivers/mtd/spi/sf_params.c                        |
> 1 +
>  drivers/net/Makefile                               |
> 1 +
>  drivers/net/mvgbe.c                                |
> 2 +-
>  drivers/net/mvneta.c                               |
> 1653 ++++++++++++++++++++
>  drivers/rtc/mvrtc.h                                |
> 2 +-
>  drivers/spi/kirkwood_spi.c                         |
> 44 +-
>  drivers/usb/host/ehci-marvell.c                    |
> 45 +-
>  include/configs/db-78460-bp.h                      |
> 67 +
>  include/linux/mbus.h                               |
> 61 +
>  include/netdev.h                                   |
> 1 +
>  include/phy.h                                      |
> 2 +
>  tools/Makefile                                     |
> 1 +
>  tools/kwbimage.c                                   |
> 1050 +++++++++----
>  tools/kwboot.c                                     |
> 97 +-
>  60 files changed, 4056 insertions(+), 723 deletions(-)
>  create mode 100644 arch/arm/cpu/armv7/armada-
> xp/Makefile
>  create mode 100644 arch/arm/cpu/armv7/armada-xp/cpu.c
>  create mode 100644 arch/arm/include/asm/arch-armada-
> xp/config.h
>  create mode 100644 arch/arm/include/asm/arch-armada-
> xp/cpu.h
>  create mode 100644 arch/arm/include/asm/arch-armada-
> xp/soc.h
>  rename arch/arm/include/asm/arch-kirkwood/{kirkwood.h
> => soc.h} (74%)
>  rename arch/arm/include/asm/{arch-kirkwood => arch-
> mvebu}/spi.h (90%)
>  create mode 100644 arch/arm/mvebu-common/Makefile
>  rename arch/arm/{cpu/arm926ejs/kirkwood => mvebu-
> common}/dram.c (57%)
>  create mode 100644 arch/arm/mvebu-common/gpio.c
>  create mode 100644 arch/arm/mvebu-common/mbus.c
>  rename arch/arm/{cpu/arm926ejs/kirkwood => mvebu-
> common}/timer.c (63%)
>  create mode 100644 board/Marvell/db-78460-bp/Makefile
>  create mode 100644 board/Marvell/db-78460-bp/db-78460-
> bp.c
>  create mode 100644 board/Marvell/db-78460-
> bp/kwbimage.cfg
>  create mode 100644 drivers/net/mvneta.c
>  create mode 100644 include/configs/db-78460-bp.h
>  create mode 100644 include/linux/mbus.h
> 
> --
> 2.0.1

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 22/25] tools/kwboot: Sync with latest barebox version to support Armada XP
  2014-06-27  9:55 ` [U-Boot] [PATCH v1 22/25] tools/kwboot: Sync with latest barebox version to support Armada XP Stefan Roese
@ 2014-06-27 19:06   ` Luka Perkov
  2014-06-28  1:25     ` Daniel Stodden
  2014-06-28  7:43     ` Stefan Roese
  2014-07-03 22:02   ` Luka Perkov
  2014-07-28  8:12   ` Wolfgang Denk
  2 siblings, 2 replies; 50+ messages in thread
From: Luka Perkov @ 2014-06-27 19:06 UTC (permalink / raw)
  To: u-boot

Hi Stefan,

It's great to see you working on adding support for Marvell's new SoCs :)

Since now kwboot is going to support more SoCs except kirkwood it makes
sense to rename it to mvboot. I've sent this patch long ago, dunno if it
still applies:

http://patchwork.ozlabs.org/patch/219741/

Also, I'd like to test this series on some boards I have - do you have
patches on some git tree that can be pulled easily?

Luka

On Fri, Jun 27, 2014 at 11:55:08AM +0200, Stefan Roese wrote:
> The barebox version of the kwboot tool has evolved a bit. To support
> Armada XP and Dove. Additionally a few minor fixes have been applied.
> So lets sync with the latest barebox version.
> 
> Please note that the main difference between both versions now is, that
> the U-Boot version still supports the -p option, to dynamically patch
> an image for UART boot mode. I didn't test it now though.
> 
> Signed-off-by: Stefan Roese <sr@denx.de>
> ---
> 
>  tools/kwboot.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++++---------
>  1 file changed, 83 insertions(+), 14 deletions(-)
> 
> diff --git a/tools/kwboot.c b/tools/kwboot.c
> index e773f01..c47970e 100644
> --- a/tools/kwboot.c
> +++ b/tools/kwboot.c
> @@ -1,5 +1,6 @@
>  /*
> - * Boot a Marvell Kirkwood SoC, with Xmodem over UART0.
> + * Boot a Marvell SoC, with Xmodem over UART0.
> + *  supports Kirkwood, Dove, Armada 370, Armada XP
>   *
>   * (c) 2012 Daniel Stodden <daniel.stodden@gmail.com>
>   *
> @@ -37,8 +38,12 @@ static unsigned char kwboot_msg_boot[] = {
>  	0xBB, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77
>  };
>  
> -#define KWBOOT_MSG_REQ_DELAY	10 /* ms */
> -#define KWBOOT_MSG_RSP_TIMEO	50 /* ms */
> +static unsigned char kwboot_msg_debug[] = {
> +	0xDD, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77
> +};
> +
> +#define KWBOOT_MSG_REQ_DELAY	1000 /* ms */
> +#define KWBOOT_MSG_RSP_TIMEO	1000 /* ms */
>  
>  /*
>   * Xmodem Transfers
> @@ -184,6 +189,9 @@ kwboot_tty_send(int fd, const void *buf, size_t len)
>  	int rc;
>  	ssize_t n;
>  
> +	if (!buf)
> +		return 0;
> +
>  	rc = -1;
>  
>  	do {
> @@ -268,7 +276,10 @@ kwboot_bootmsg(int tty, void *msg)
>  	int rc;
>  	char c;
>  
> -	kwboot_printv("Sending boot message. Please reboot the target...");
> +	if (msg == NULL)
> +		kwboot_printv("Please reboot the target into UART boot mode...");
> +	else
> +		kwboot_printv("Sending boot message. Please reboot the target...");
>  
>  	do {
>  		rc = tcflush(tty, TCIOFLUSH);
> @@ -293,6 +304,37 @@ kwboot_bootmsg(int tty, void *msg)
>  }
>  
>  static int
> +kwboot_debugmsg(int tty, void *msg)
> +{
> +	int rc;
> +
> +	kwboot_printv("Sending debug message. Please reboot the target...");
> +
> +	do {
> +		char buf[16];
> +
> +		rc = tcflush(tty, TCIOFLUSH);
> +		if (rc)
> +			break;
> +
> +		rc = kwboot_tty_send(tty, msg, 8);
> +		if (rc) {
> +			usleep(KWBOOT_MSG_REQ_DELAY * 1000);
> +			continue;
> +		}
> +
> +		rc = kwboot_tty_recv(tty, buf, 16, KWBOOT_MSG_RSP_TIMEO);
> +
> +		kwboot_spinner();
> +
> +	} while (rc);
> +
> +	kwboot_printv("\n");
> +
> +	return rc;
> +}
> +
> +static int
>  kwboot_xm_makeblock(struct kwboot_block *block, const void *data,
>  		    size_t size, int pnum)
>  {
> @@ -300,6 +342,7 @@ kwboot_xm_makeblock(struct kwboot_block *block, const void *data,
>  	size_t n;
>  	int i;
>  
> +	block->soh = SOH;
>  	block->pnum = pnum;
>  	block->_pnum = ~block->pnum;
>  
> @@ -326,9 +369,15 @@ kwboot_xm_sendblock(int fd, struct kwboot_block *block)
>  		if (rc)
>  			break;
>  
> -		rc = kwboot_tty_recv(fd, &c, 1, KWBOOT_BLK_RSP_TIMEO);
> -		if (rc)
> -			break;
> +		do {
> +			rc = kwboot_tty_recv(fd, &c, 1, KWBOOT_BLK_RSP_TIMEO);
> +			if (rc)
> +				break;
> +
> +			if (c != ACK && c != NAK && c != CAN)
> +				printf("%c", c);
> +
> +		} while (c != ACK && c != NAK && c != CAN);
>  
>  		if (c != ACK)
>  			kwboot_progress(-1, '+');
> @@ -511,7 +560,6 @@ kwboot_mmap_image(const char *path, size_t *size, int prot)
>  	void *img;
>  
>  	rc = -1;
> -	fd = -1;
>  	img = NULL;
>  
>  	fd = open(path, O_RDONLY);
> @@ -601,11 +649,15 @@ static void
>  kwboot_usage(FILE *stream, char *progname)
>  {
>  	fprintf(stream,
> -		"Usage: %s -b <image> [ -p ] [ -t ] "
> -		"[-B <baud> ] <TTY>\n", progname);
> +		"Usage: %s [-d | -b <image> | -D <image> ] [ -t ] [-B <baud> ] <TTY>\n",
> +		progname);
>  	fprintf(stream, "\n");
> -	fprintf(stream, "  -b <image>: boot <image>\n");
> +	fprintf(stream,
> +		"  -b <image>: boot <image> with preamble (Kirkwood, Armada 370/XP)\n");
>  	fprintf(stream, "  -p: patch <image> to type 0x69 (uart boot)\n");
> +	fprintf(stream,
> +		"  -D <image>: boot <image> without preamble (Dove)\n");
> +	fprintf(stream, "  -d: enter debug mode\n");
>  	fprintf(stream, "\n");
>  	fprintf(stream, "  -t: mini terminal\n");
>  	fprintf(stream, "\n");
> @@ -619,6 +671,7 @@ main(int argc, char **argv)
>  	const char *ttypath, *imgpath;
>  	int rv, rc, tty, term, prot, patch;
>  	void *bootmsg;
> +	void *debugmsg;
>  	void *img;
>  	size_t size;
>  	speed_t speed;
> @@ -626,6 +679,7 @@ main(int argc, char **argv)
>  	rv = 1;
>  	tty = -1;
>  	bootmsg = NULL;
> +	debugmsg = NULL;
>  	imgpath = NULL;
>  	img = NULL;
>  	term = 0;
> @@ -636,7 +690,7 @@ main(int argc, char **argv)
>  	kwboot_verbose = isatty(STDOUT_FILENO);
>  
>  	do {
> -		int c = getopt(argc, argv, "hb:ptB:");
> +		int c = getopt(argc, argv, "hb:ptB:dD:");
>  		if (c < 0)
>  			break;
>  
> @@ -646,6 +700,15 @@ main(int argc, char **argv)
>  			imgpath = optarg;
>  			break;
>  
> +		case 'D':
> +			bootmsg = NULL;
> +			imgpath = optarg;
> +			break;
> +
> +		case 'd':
> +			debugmsg = kwboot_msg_debug;
> +			break;
> +
>  		case 'p':
>  			patch = 1;
>  			break;
> @@ -667,7 +730,7 @@ main(int argc, char **argv)
>  		}
>  	} while (1);
>  
> -	if (!bootmsg && !term)
> +	if (!bootmsg && !term && !debugmsg)
>  		goto usage;
>  
>  	if (patch && !imgpath)
> @@ -702,7 +765,13 @@ main(int argc, char **argv)
>  		}
>  	}
>  
> -	if (bootmsg) {
> +	if (debugmsg) {
> +		rc = kwboot_debugmsg(tty, debugmsg);
> +		if (rc) {
> +			perror("debugmsg");
> +			goto out;
> +		}
> +	} else {
>  		rc = kwboot_bootmsg(tty, bootmsg);
>  		if (rc) {
>  			perror("bootmsg");
> -- 
> 2.0.1
> 
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 22/25] tools/kwboot: Sync with latest barebox version to support Armada XP
  2014-06-27 19:06   ` Luka Perkov
@ 2014-06-28  1:25     ` Daniel Stodden
  2014-06-28  7:43     ` Stefan Roese
  1 sibling, 0 replies; 50+ messages in thread
From: Daniel Stodden @ 2014-06-28  1:25 UTC (permalink / raw)
  To: u-boot

On Fri, 2014-06-27 at 21:06 +0200, Luka Perkov wrote:
> Hi Stefan,
> 
> It's great to see you working on adding support for Marvell's new SoCs :)
> 
> Since now kwboot is going to support more SoCs except kirkwood it makes
> sense to rename it to mvboot. I've sent this patch long ago, dunno if it
> still applies:
> 
> http://patchwork.ozlabs.org/patch/219741/
> 
> Also, I'd like to test this series on some boards I have - do you have
> patches on some git tree that can be pulled easily?

In case Marvell gets bought out: wouldn't it make more sense to rename
to mrvlboot and point a curl script at the nasdaq quotes to validate the
build? 

Related, I don't think Marvell guarantees to not either yank or
completely overhaul their SoC boot code entirely next September.

I'm sorry for "kwboot" if it violates your aesthetic senses. Those as of
2014. Indeed, naming programs by product is often a weak choice, but
there wasn't a more robust one available. But: there still isn't.

Program paths don't get renamed at will. That's because once it's
deployed it's not arbitrary anymore, and some real value in doing so
better compensates for the overall pain.

Here's one fix: one could write a yet better one with yet a better name,
convince everyone to switch, and just obsolete the existing one.

An easier, sometimes funnier, alternative is to learn to enjoy the
historical trivia surrounding all those seemingly stupid names.

Yeah, an 'apt-get git' used to install GNU interactive tools, then at
some point it suddenly didn't. But NIS support still runs as ypbind for
all the good reasons, too.

Cheers,
Daniel

> Luka
> 
> On Fri, Jun 27, 2014 at 11:55:08AM +0200, Stefan Roese wrote:
> > The barebox version of the kwboot tool has evolved a bit. To support
> > Armada XP and Dove. Additionally a few minor fixes have been applied.
> > So lets sync with the latest barebox version.
> > 
> > Please note that the main difference between both versions now is, that
> > the U-Boot version still supports the -p option, to dynamically patch
> > an image for UART boot mode. I didn't test it now though.
> > 
> > Signed-off-by: Stefan Roese <sr@denx.de>
> > ---
> > 
> >  tools/kwboot.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++++---------
> >  1 file changed, 83 insertions(+), 14 deletions(-)
> > 
> > diff --git a/tools/kwboot.c b/tools/kwboot.c
> > index e773f01..c47970e 100644
> > --- a/tools/kwboot.c
> > +++ b/tools/kwboot.c
> > @@ -1,5 +1,6 @@
> >  /*
> > - * Boot a Marvell Kirkwood SoC, with Xmodem over UART0.
> > + * Boot a Marvell SoC, with Xmodem over UART0.
> > + *  supports Kirkwood, Dove, Armada 370, Armada XP
> >   *
> >   * (c) 2012 Daniel Stodden <daniel.stodden@gmail.com>
> >   *
> > @@ -37,8 +38,12 @@ static unsigned char kwboot_msg_boot[] = {
> >  	0xBB, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77
> >  };
> >  
> > -#define KWBOOT_MSG_REQ_DELAY	10 /* ms */
> > -#define KWBOOT_MSG_RSP_TIMEO	50 /* ms */
> > +static unsigned char kwboot_msg_debug[] = {
> > +	0xDD, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77
> > +};
> > +
> > +#define KWBOOT_MSG_REQ_DELAY	1000 /* ms */
> > +#define KWBOOT_MSG_RSP_TIMEO	1000 /* ms */
> >  
> >  /*
> >   * Xmodem Transfers
> > @@ -184,6 +189,9 @@ kwboot_tty_send(int fd, const void *buf, size_t len)
> >  	int rc;
> >  	ssize_t n;
> >  
> > +	if (!buf)
> > +		return 0;
> > +
> >  	rc = -1;
> >  
> >  	do {
> > @@ -268,7 +276,10 @@ kwboot_bootmsg(int tty, void *msg)
> >  	int rc;
> >  	char c;
> >  
> > -	kwboot_printv("Sending boot message. Please reboot the target...");
> > +	if (msg == NULL)
> > +		kwboot_printv("Please reboot the target into UART boot mode...");
> > +	else
> > +		kwboot_printv("Sending boot message. Please reboot the target...");
> >  
> >  	do {
> >  		rc = tcflush(tty, TCIOFLUSH);
> > @@ -293,6 +304,37 @@ kwboot_bootmsg(int tty, void *msg)
> >  }
> >  
> >  static int
> > +kwboot_debugmsg(int tty, void *msg)
> > +{
> > +	int rc;
> > +
> > +	kwboot_printv("Sending debug message. Please reboot the target...");
> > +
> > +	do {
> > +		char buf[16];
> > +
> > +		rc = tcflush(tty, TCIOFLUSH);
> > +		if (rc)
> > +			break;
> > +
> > +		rc = kwboot_tty_send(tty, msg, 8);
> > +		if (rc) {
> > +			usleep(KWBOOT_MSG_REQ_DELAY * 1000);
> > +			continue;
> > +		}
> > +
> > +		rc = kwboot_tty_recv(tty, buf, 16, KWBOOT_MSG_RSP_TIMEO);
> > +
> > +		kwboot_spinner();
> > +
> > +	} while (rc);
> > +
> > +	kwboot_printv("\n");
> > +
> > +	return rc;
> > +}
> > +
> > +static int
> >  kwboot_xm_makeblock(struct kwboot_block *block, const void *data,
> >  		    size_t size, int pnum)
> >  {
> > @@ -300,6 +342,7 @@ kwboot_xm_makeblock(struct kwboot_block *block, const void *data,
> >  	size_t n;
> >  	int i;
> >  
> > +	block->soh = SOH;
> >  	block->pnum = pnum;
> >  	block->_pnum = ~block->pnum;
> >  
> > @@ -326,9 +369,15 @@ kwboot_xm_sendblock(int fd, struct kwboot_block *block)
> >  		if (rc)
> >  			break;
> >  
> > -		rc = kwboot_tty_recv(fd, &c, 1, KWBOOT_BLK_RSP_TIMEO);
> > -		if (rc)
> > -			break;
> > +		do {
> > +			rc = kwboot_tty_recv(fd, &c, 1, KWBOOT_BLK_RSP_TIMEO);
> > +			if (rc)
> > +				break;
> > +
> > +			if (c != ACK && c != NAK && c != CAN)
> > +				printf("%c", c);
> > +
> > +		} while (c != ACK && c != NAK && c != CAN);
> >  
> >  		if (c != ACK)
> >  			kwboot_progress(-1, '+');
> > @@ -511,7 +560,6 @@ kwboot_mmap_image(const char *path, size_t *size, int prot)
> >  	void *img;
> >  
> >  	rc = -1;
> > -	fd = -1;
> >  	img = NULL;
> >  
> >  	fd = open(path, O_RDONLY);
> > @@ -601,11 +649,15 @@ static void
> >  kwboot_usage(FILE *stream, char *progname)
> >  {
> >  	fprintf(stream,
> > -		"Usage: %s -b <image> [ -p ] [ -t ] "
> > -		"[-B <baud> ] <TTY>\n", progname);
> > +		"Usage: %s [-d | -b <image> | -D <image> ] [ -t ] [-B <baud> ] <TTY>\n",
> > +		progname);
> >  	fprintf(stream, "\n");
> > -	fprintf(stream, "  -b <image>: boot <image>\n");
> > +	fprintf(stream,
> > +		"  -b <image>: boot <image> with preamble (Kirkwood, Armada 370/XP)\n");
> >  	fprintf(stream, "  -p: patch <image> to type 0x69 (uart boot)\n");
> > +	fprintf(stream,
> > +		"  -D <image>: boot <image> without preamble (Dove)\n");
> > +	fprintf(stream, "  -d: enter debug mode\n");
> >  	fprintf(stream, "\n");
> >  	fprintf(stream, "  -t: mini terminal\n");
> >  	fprintf(stream, "\n");
> > @@ -619,6 +671,7 @@ main(int argc, char **argv)
> >  	const char *ttypath, *imgpath;
> >  	int rv, rc, tty, term, prot, patch;
> >  	void *bootmsg;
> > +	void *debugmsg;
> >  	void *img;
> >  	size_t size;
> >  	speed_t speed;
> > @@ -626,6 +679,7 @@ main(int argc, char **argv)
> >  	rv = 1;
> >  	tty = -1;
> >  	bootmsg = NULL;
> > +	debugmsg = NULL;
> >  	imgpath = NULL;
> >  	img = NULL;
> >  	term = 0;
> > @@ -636,7 +690,7 @@ main(int argc, char **argv)
> >  	kwboot_verbose = isatty(STDOUT_FILENO);
> >  
> >  	do {
> > -		int c = getopt(argc, argv, "hb:ptB:");
> > +		int c = getopt(argc, argv, "hb:ptB:dD:");
> >  		if (c < 0)
> >  			break;
> >  
> > @@ -646,6 +700,15 @@ main(int argc, char **argv)
> >  			imgpath = optarg;
> >  			break;
> >  
> > +		case 'D':
> > +			bootmsg = NULL;
> > +			imgpath = optarg;
> > +			break;
> > +
> > +		case 'd':
> > +			debugmsg = kwboot_msg_debug;
> > +			break;
> > +
> >  		case 'p':
> >  			patch = 1;
> >  			break;
> > @@ -667,7 +730,7 @@ main(int argc, char **argv)
> >  		}
> >  	} while (1);
> >  
> > -	if (!bootmsg && !term)
> > +	if (!bootmsg && !term && !debugmsg)
> >  		goto usage;
> >  
> >  	if (patch && !imgpath)
> > @@ -702,7 +765,13 @@ main(int argc, char **argv)
> >  		}
> >  	}
> >  
> > -	if (bootmsg) {
> > +	if (debugmsg) {
> > +		rc = kwboot_debugmsg(tty, debugmsg);
> > +		if (rc) {
> > +			perror("debugmsg");
> > +			goto out;
> > +		}
> > +	} else {
> >  		rc = kwboot_bootmsg(tty, bootmsg);
> >  		if (rc) {
> >  			perror("bootmsg");
> > -- 
> > 2.0.1
> > 
> > _______________________________________________
> > U-Boot mailing list
> > U-Boot at lists.denx.de
> > http://lists.denx.de/mailman/listinfo/u-boot
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 22/25] tools/kwboot: Sync with latest barebox version to support Armada XP
  2014-06-27 19:06   ` Luka Perkov
  2014-06-28  1:25     ` Daniel Stodden
@ 2014-06-28  7:43     ` Stefan Roese
  1 sibling, 0 replies; 50+ messages in thread
From: Stefan Roese @ 2014-06-28  7:43 UTC (permalink / raw)
  To: u-boot

Hi Luka!

On 27.06.2014 21:06, Luka Perkov wrote:
> It's great to see you working on adding support for Marvell's new SoCs :)

Thanks.

> Since now kwboot is going to support more SoCs except kirkwood it makes
> sense to rename it to mvboot. I've sent this patch long ago, dunno if it
> still applies:
>
> http://patchwork.ozlabs.org/patch/219741/

I thought about renaming the tool(s) as well. But decided against it. 
Mostly because of historical reasons. This name for the tools has been 
around for quite some time. And is documented in many README / HOWTO 
files on the web. That's why I chose to not change it, at least for now.

> Also, I'd like to test this series on some boards I have

That would be great. Thanks. Please keep me informed.

Note that I only merged some of the Kirkwood U-Boot code with the Armada 
XP code. More work could be done here. And Dove definitely can be 
squashed into this now common MVEBU infrastructure as well. Patches as 
always very welcome (after this patchset is accepted as a basis). ;)

> - do you have
> patches on some git tree that can be pulled easily?

Sure. I just uploaded a branch "marvell-armada-xp-2014-06-27" to the 
u-boot-testing git repository:

http://git.denx.de/?p=u-boot/u-boot-testing.git;a=shortlog;h=refs/heads/marvell-armada-xp-2014-06-27

Thanks,
Stefan

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 17/25] i2c: mvtwsi: Add support for Marvell Armada XP
  2014-06-27  9:55 ` [U-Boot] [PATCH v1 17/25] i2c: mvtwsi: Add support for Marvell Armada XP Stefan Roese
@ 2014-07-01  5:48   ` Heiko Schocher
  0 siblings, 0 replies; 50+ messages in thread
From: Heiko Schocher @ 2014-07-01  5:48 UTC (permalink / raw)
  To: u-boot

Hello Stefan,

Am 27.06.2014 11:55, schrieb Stefan Roese:
> To support the Armada XP SoC, we just need to include the correct header.
>
> Signed-off-by: Stefan Roese<sr@denx.de>
> Cc: Heiko Schocher<hs@denx.de>
> ---
>
>   drivers/i2c/mvtwsi.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Acked-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 20/25] arm: kirkwood: Remove some dead code from cpu.c
  2014-06-27  9:55 ` [U-Boot] [PATCH v1 20/25] arm: kirkwood: Remove some dead code from cpu.c Stefan Roese
@ 2014-07-01 23:45   ` Luka Perkov
  0 siblings, 0 replies; 50+ messages in thread
From: Luka Perkov @ 2014-07-01 23:45 UTC (permalink / raw)
  To: u-boot

On Fri, Jun 27, 2014 at 11:55:06AM +0200, Stefan Roese wrote:
> All those functions removed with this patch are not accessed at all. So lets
> remove them.
> 
> Signed-off-by: Stefan Roese <sr@denx.de>
> ---
> 
>  arch/arm/cpu/arm926ejs/kirkwood/cpu.c | 55 -----------------------------------
>  1 file changed, 55 deletions(-)

Up until this patch I have tested the series without problems on ib62x0.
This is the last patch that I can apply and still boot the board. That
said, for this patch and those before it:

Tested-by: Luka Perkov <luka@openwrt.org>


After the next patch in series is applied uboot does not come up - there
is no output on the console. I've used kwboot in testing:

$ sudo ./tools/kwboot -t -p -B 115200 -b u-boot.kwb /dev/ttyUSB0

Unrelated to this series I am going to mail a couple of kirkwood
patches. Those can be applied without conflicts before or after this
series.

Luka

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 01/25] sf: Add M25PX64 SPI NOR flash ID
  2014-06-27  9:54 ` [U-Boot] [PATCH v1 01/25] sf: Add M25PX64 SPI NOR flash ID Stefan Roese
@ 2014-07-03 20:14   ` Jagan Teki
  2014-07-13 16:20     ` Jagan Teki
  0 siblings, 1 reply; 50+ messages in thread
From: Jagan Teki @ 2014-07-03 20:14 UTC (permalink / raw)
  To: u-boot

Reviewed-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>

On Fri, Jun 27, 2014 at 3:24 PM, Stefan Roese <sr@denx.de> wrote:
> Add ID for this Numonix / STMicro chip.
>
> Tested on Marvell DB-78460-BP board.
>
> Signed-off-by: Stefan Roese <sr@denx.de>
> Cc: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
> ---
>
>  drivers/mtd/spi/sf_params.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/mtd/spi/sf_params.c b/drivers/mtd/spi/sf_params.c
> index ac886fd..b8186e9 100644
> --- a/drivers/mtd/spi/sf_params.c
> +++ b/drivers/mtd/spi/sf_params.c
> @@ -71,6 +71,7 @@ const struct spi_flash_params spi_flash_params_table[] = {
>         {"M25P32",         0x202016, 0x0,       64 * 1024,    64,       0,                        0},
>         {"M25P64",         0x202017, 0x0,       64 * 1024,   128,       0,                        0},
>         {"M25P128",        0x202018, 0x0,      256 * 1024,    64,       0,                        0},
> +       {"M25PX64",        0x207117, 0x0,       64 * 1024,   128,       0,                  SECT_4K},
>         {"N25Q32",         0x20ba16, 0x0,       64 * 1024,    64, RD_FULL,         WR_QPP | SECT_4K},
>         {"N25Q32A",        0x20bb16, 0x0,       64 * 1024,    64, RD_FULL,         WR_QPP | SECT_4K},
>         {"N25Q64",         0x20ba17, 0x0,       64 * 1024,   128, RD_FULL,         WR_QPP | SECT_4K},
> --
> 2.0.1
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot



-- 
Jagan.

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 02/25] arm: kirkwood: spi.h: Add some missing parenthesis
  2014-06-27  9:54 ` [U-Boot] [PATCH v1 02/25] arm: kirkwood: spi.h: Add some missing parenthesis Stefan Roese
@ 2014-07-03 20:15   ` Jagan Teki
  0 siblings, 0 replies; 50+ messages in thread
From: Jagan Teki @ 2014-07-03 20:15 UTC (permalink / raw)
  To: u-boot

Reviewed-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>

On Fri, Jun 27, 2014 at 3:24 PM, Stefan Roese <sr@denx.de> wrote:
> Signed-off-by: Stefan Roese <sr@denx.de>
> Cc: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
> ---
>
>  arch/arm/include/asm/arch-kirkwood/spi.h | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/arch/arm/include/asm/arch-kirkwood/spi.h b/arch/arm/include/asm/arch-kirkwood/spi.h
> index b1cf614..e512dce 100644
> --- a/arch/arm/include/asm/arch-kirkwood/spi.h
> +++ b/arch/arm/include/asm/arch-kirkwood/spi.h
> @@ -43,10 +43,10 @@ struct kwspi_registers {
>  #define KWSPI_XFERLEN_2BYTE    (1 << 5)
>  #define KWSPI_XFERLEN_MASK     (1 << 5)
>  #define KWSPI_ADRLEN_1BYTE     0
> -#define KWSPI_ADRLEN_2BYTE     1 << 8
> -#define KWSPI_ADRLEN_3BYTE     2 << 8
> -#define KWSPI_ADRLEN_4BYTE     3 << 8
> -#define KWSPI_ADRLEN_MASK      3 << 8
> +#define KWSPI_ADRLEN_2BYTE     (1 << 8)
> +#define KWSPI_ADRLEN_3BYTE     (2 << 8)
> +#define KWSPI_ADRLEN_4BYTE     (3 << 8)
> +#define KWSPI_ADRLEN_MASK      (3 << 8)
>  #define KWSPI_TIMEOUT          10000
>
>  #endif /* __KW_SPI_H__ */
> --
> 2.0.1
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot



-- 
Jagan.

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 03/25] spi: kirkwood_spi.c: Some fixes and cleanup
  2014-06-27  9:54 ` [U-Boot] [PATCH v1 03/25] spi: kirkwood_spi.c: Some fixes and cleanup Stefan Roese
@ 2014-07-03 20:16   ` Jagan Teki
  0 siblings, 0 replies; 50+ messages in thread
From: Jagan Teki @ 2014-07-03 20:16 UTC (permalink / raw)
  To: u-boot

Reviewed-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>

On Fri, Jun 27, 2014 at 3:24 PM, Stefan Roese <sr@denx.de> wrote:
> This patch introduces the clrsetbits_le32() accessor functions in the
> kirkwood SPI driver. Note that it also includes a fix:
>
> -        writel(~KWSPI_CSN_ACT | KWSPI_SMEMRDY, &spireg->ctrl);
> +        writel(KWSPI_SMEMRDY, &spireg->ctrl);
>
> Here the bit KWSPI_CSN_ACT (0x1) should have been cleared. Instead
> 0xfffffffe is written into this control register. This is the main
> reason to use the clrsetbits() functions now. As they make clearing
> bits much less error prone.
>
> Additionally KWSPI_IRQUNMASK is not used in spi_cs_activate() and
> spi_cs_deactivate() any more. Its the wrong macro but has the same
> value as the correct one (KWSPI_CSN_ACT).
>
> This is in preparation for use of this driver on the Marvell Armada XP
> platform as well.
>
> Signed-off-by: Stefan Roese <sr@denx.de>
> Cc: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
> ---
>
>  drivers/spi/kirkwood_spi.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/spi/kirkwood_spi.c b/drivers/spi/kirkwood_spi.c
> index 942a208..449e9f8 100644
> --- a/drivers/spi/kirkwood_spi.c
> +++ b/drivers/spi/kirkwood_spi.c
> @@ -37,7 +37,7 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
>         if (!slave)
>                 return NULL;
>
> -       writel(~KWSPI_CSN_ACT | KWSPI_SMEMRDY, &spireg->ctrl);
> +       writel(KWSPI_SMEMRDY, &spireg->ctrl);
>
>         /* calculate spi clock prescaller using max_hz */
>         data = ((CONFIG_SYS_TCLK / 2) / max_hz) + 0x10;
> @@ -137,12 +137,12 @@ void spi_init(void)
>
>  void spi_cs_activate(struct spi_slave *slave)
>  {
> -       writel(readl(&spireg->ctrl) | KWSPI_IRQUNMASK, &spireg->ctrl);
> +       setbits_le32(&spireg->ctrl, KWSPI_CSN_ACT);
>  }
>
>  void spi_cs_deactivate(struct spi_slave *slave)
>  {
> -       writel(readl(&spireg->ctrl) & KWSPI_IRQMASK, &spireg->ctrl);
> +       clrbits_le32(&spireg->ctrl, KWSPI_CSN_ACT);
>  }
>
>  int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
> @@ -161,8 +161,7 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
>          * handle data in 8-bit chunks
>          * TBD: 2byte xfer mode to be enabled
>          */
> -       writel(((readl(&spireg->cfg) & ~KWSPI_XFERLEN_MASK) |
> -               KWSPI_XFERLEN_1BYTE), &spireg->cfg);
> +       clrsetbits_le32(&spireg->cfg, KWSPI_XFERLEN_MASK, KWSPI_XFERLEN_1BYTE);
>
>         while (bitlen > 4) {
>                 debug("loopstart bitlen %d\n", bitlen);
> @@ -172,7 +171,7 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
>                 if (dout)
>                         tmpdout = *(u32 *) dout & 0x0ff;
>
> -               writel(~KWSPI_SMEMRDIRQ, &spireg->irq_cause);
> +               clrbits_le32(&spireg->irq_cause, KWSPI_SMEMRDIRQ);
>                 writel(tmpdout, &spireg->dout); /* Write the data out */
>                 debug("*** spi_xfer: ... %08x written, bitlen %d\n",
>                       tmpdout, bitlen);
> --
> 2.0.1
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot



-- 
Jagan.

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 04/25] spi: kirkwood_spi.c: Make global variable static
  2014-06-27  9:54 ` [U-Boot] [PATCH v1 04/25] spi: kirkwood_spi.c: Make global variable static Stefan Roese
@ 2014-07-03 20:18   ` Jagan Teki
  0 siblings, 0 replies; 50+ messages in thread
From: Jagan Teki @ 2014-07-03 20:18 UTC (permalink / raw)
  To: u-boot

May possible to include in different patch.

Reviewed-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>

On Fri, Jun 27, 2014 at 3:24 PM, Stefan Roese <sr@denx.de> wrote:
> Signed-off-by: Stefan Roese <sr@denx.de>
> Cc: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
> ---
>
>  drivers/spi/kirkwood_spi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/spi/kirkwood_spi.c b/drivers/spi/kirkwood_spi.c
> index 449e9f8..7d1c1f9 100644
> --- a/drivers/spi/kirkwood_spi.c
> +++ b/drivers/spi/kirkwood_spi.c
> @@ -18,7 +18,7 @@
>
>  static struct kwspi_registers *spireg = (struct kwspi_registers *)KW_SPI_BASE;
>
> -u32 cs_spi_mpp_back[2];
> +static u32 cs_spi_mpp_back[2];
>
>  struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
>                                 unsigned int max_hz, unsigned int mode)
> --
> 2.0.1
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot



-- 
Jagan.

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 05/25] spi: kirkwood_spi.c: cosmetic: Fix minor coding style issues
  2014-06-27  9:54 ` [U-Boot] [PATCH v1 05/25] spi: kirkwood_spi.c: cosmetic: Fix minor coding style issues Stefan Roese
@ 2014-07-03 20:18   ` Jagan Teki
  0 siblings, 0 replies; 50+ messages in thread
From: Jagan Teki @ 2014-07-03 20:18 UTC (permalink / raw)
  To: u-boot

Reviewed-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>

On Fri, Jun 27, 2014 at 3:24 PM, Stefan Roese <sr@denx.de> wrote:
> Signed-off-by: Stefan Roese <sr@denx.de>
> Cc: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
> ---
>
>  drivers/spi/kirkwood_spi.c | 14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/spi/kirkwood_spi.c b/drivers/spi/kirkwood_spi.c
> index 7d1c1f9..3d58bcc 100644
> --- a/drivers/spi/kirkwood_spi.c
> +++ b/drivers/spi/kirkwood_spi.c
> @@ -46,7 +46,7 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
>
>         /* program spi clock prescaller using max_hz */
>         writel(KWSPI_ADRLEN_3BYTE | data, &spireg->cfg);
> -       debug("data = 0x%08x \n", data);
> +       debug("data = 0x%08x\n", data);
>
>         writel(KWSPI_SMEMRDIRQ, &spireg->irq_cause);
>         writel(KWSPI_IRQMASK, &spireg->irq_mask);
> @@ -100,7 +100,6 @@ int spi_claim_bus(struct spi_slave *slave)
>
>         /* set new spi mpp and save current mpp config */
>         kirkwood_mpp_conf(spi_mpp_config, spi_mpp_backup);
> -
>  #endif
>
>         return board_spi_claim_bus(slave);
> @@ -127,7 +126,7 @@ void spi_release_bus(struct spi_slave *slave)
>   */
>  int spi_cs_is_valid(unsigned int bus, unsigned int cs)
>  {
> -       return (bus == 0 && (cs == 0 || cs == 1));
> +       return bus == 0 && (cs == 0 || cs == 1);
>  }
>  #endif
>
> @@ -169,7 +168,7 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
>
>                 /* Shift data so it's msb-justified */
>                 if (dout)
> -                       tmpdout = *(u32 *) dout & 0x0ff;
> +                       tmpdout = *(u32 *)dout & 0xff;
>
>                 clrbits_le32(&spireg->irq_cause, KWSPI_SMEMRDIRQ);
>                 writel(tmpdout, &spireg->dout); /* Write the data out */
> @@ -185,12 +184,11 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
>                         if (readl(&spireg->irq_cause) & KWSPI_SMEMRDIRQ) {
>                                 isread = 1;
>                                 tmpdin = readl(&spireg->din);
> -                               debug
> -                                       ("spi_xfer: din %p..%08x read\n",
> -                                       din, tmpdin);
> +                               debug("spi_xfer: din %p..%08x read\n",
> +                                     din, tmpdin);
>
>                                 if (din) {
> -                                       *((u8 *) din) = (u8) tmpdin;
> +                                       *((u8 *)din) = (u8)tmpdin;
>                                         din += 1;
>                                 }
>                                 if (dout)
> --
> 2.0.1
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot



-- 
Jagan.

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 22/25] tools/kwboot: Sync with latest barebox version to support Armada XP
  2014-06-27  9:55 ` [U-Boot] [PATCH v1 22/25] tools/kwboot: Sync with latest barebox version to support Armada XP Stefan Roese
  2014-06-27 19:06   ` Luka Perkov
@ 2014-07-03 22:02   ` Luka Perkov
  2014-07-28  6:47     ` Stefan Roese
  2014-07-28  8:12   ` Wolfgang Denk
  2 siblings, 1 reply; 50+ messages in thread
From: Luka Perkov @ 2014-07-03 22:02 UTC (permalink / raw)
  To: u-boot

Hi Stefan,

On Fri, Jun 27, 2014 at 11:55:08AM +0200, Stefan Roese wrote:
> The barebox version of the kwboot tool has evolved a bit. To support
> Armada XP and Dove. Additionally a few minor fixes have been applied.
> So lets sync with the latest barebox version.
> 
> Please note that the main difference between both versions now is, that
> the U-Boot version still supports the -p option, to dynamically patch
> an image for UART boot mode. I didn't test it now though.
> 
> Signed-off-by: Stefan Roese <sr@denx.de>
> ---
> 
>  tools/kwboot.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++++---------
>  1 file changed, 83 insertions(+), 14 deletions(-)

...

> -#define KWBOOT_MSG_REQ_DELAY	10 /* ms */
> -#define KWBOOT_MSG_RSP_TIMEO	50 /* ms */
> +static unsigned char kwboot_msg_debug[] = {
> +	0xDD, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77
> +};
> +
> +#define KWBOOT_MSG_REQ_DELAY	1000 /* ms */
> +#define KWBOOT_MSG_RSP_TIMEO	1000 /* ms */

This causes problems on kirkwood. The old values should be kept, apply
the patch below to this one. After that chage feel free to add Tested-by
line.

Tested-by: Luka Perkov <luka@openwrt.org>

Now only to figure out why 21/25 breaks things on kirkwood.

Luka

diff --git a/tools/kwboot.c b/tools/kwboot.c
index c47970e..ccc9d90 100644
--- a/tools/kwboot.c
+++ b/tools/kwboot.c
@@ -42,8 +42,8 @@ static unsigned char kwboot_msg_debug[] = {
 	0xDD, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77
 };
 
-#define KWBOOT_MSG_REQ_DELAY	1000 /* ms */
-#define KWBOOT_MSG_RSP_TIMEO	1000 /* ms */
+#define KWBOOT_MSG_REQ_DELAY	10 /* ms */
+#define KWBOOT_MSG_RSP_TIMEO	50 /* ms */
 
 /*
  * Xmodem Transfers

^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 23/25] tools: Compile kwboot for Marvell Armada XP as those SoCs are now supported
  2014-06-27  9:55 ` [U-Boot] [PATCH v1 23/25] tools: Compile kwboot for Marvell Armada XP as those SoCs are now supported Stefan Roese
@ 2014-07-03 22:03   ` Luka Perkov
  0 siblings, 0 replies; 50+ messages in thread
From: Luka Perkov @ 2014-07-03 22:03 UTC (permalink / raw)
  To: u-boot

On Fri, Jun 27, 2014 at 11:55:09AM +0200, Stefan Roese wrote:
> Signed-off-by: Stefan Roese <sr@denx.de>
> ---
> 
>  tools/Makefile | 1 +
>  1 file changed, 1 insertion(+)

Tested-by: Luka Perkov <luka@openwrt.org>

Luka

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 24/25] tools: kwbimage: Add image version 1 support for Armada XP / 370
  2014-06-27  9:55 ` [U-Boot] [PATCH v1 24/25] tools: kwbimage: Add image version 1 support for Armada XP / 370 Stefan Roese
@ 2014-07-03 22:03   ` Luka Perkov
  0 siblings, 0 replies; 50+ messages in thread
From: Luka Perkov @ 2014-07-03 22:03 UTC (permalink / raw)
  To: u-boot

On Fri, Jun 27, 2014 at 11:55:10AM +0200, Stefan Roese wrote:
> This patch integrates the Barebox version of this kwbimage.c file into
> U-Boot. As this version supports the image version 1 type for the
> Armada XP / 370 SoCs.
> 
> It was easier to integrate the existing and known to be working Barebox
> source than to update the current U-Boot version to support this
> v1 image header format. Now all Marvell MVEBU SoCs are supported:
> 
> Image type 0: Kirkwood & Dove
> Image type 1: Armada 370 & Armada XP
> 
> Please note that the current v1 support has this restuction (same as
> has Barebox version):
> 
> Not implemented: support for the register headers and secure headers
> in v1 images
> 
> Tested on Marvell DB-78460-BP eval board.
> 
> Signed-off-by: Stefan Roese <sr@denx.de>
> ---
> 
>  tools/kwbimage.c | 1050 ++++++++++++++++++++++++++++++++++++++++--------------
>  1 file changed, 782 insertions(+), 268 deletions(-)

Tested-by: Luka Perkov <luka@openwrt.org>

Luka

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 0/25] Add Marvell Armada XP MV78460 SoC support
  2014-06-27 10:18 ` [U-Boot] [PATCH v1 0/25] Add Marvell Armada XP MV78460 SoC support Prafulla Wadaskar
@ 2014-07-13 16:15   ` Jagan Teki
  2014-07-14 14:51     ` Tom Rini
  0 siblings, 1 reply; 50+ messages in thread
From: Jagan Teki @ 2014-07-13 16:15 UTC (permalink / raw)
  To: u-boot

On Fri, Jun 27, 2014 at 3:48 PM, Prafulla Wadaskar <prafulla@marvell.com> wrote:
>
>
>> -----Original Message-----
>> From: Stefan Roese [mailto:sr at denx.de]
>> Sent: 27 June 2014 15:25
>> To: u-boot at lists.denx.de
>> Cc: Prafulla Wadaskar; trini at ti.com
>> Subject: [PATCH v1 0/25] Add Marvell Armada XP MV78460
>> SoC support
>>
>>
>> This patch series adds support for the Marvell Armada
>> XP SoC's. Specifically
>> the MV78460.
>>
>> Basic support for the db-78460-bp evaluation board is
>> added. Supporting the
>> following interfaces:
>> - UART
>> - SPI (including SPI NOR flash)
>> - I2C
>> - Ethernet (neta)
>>
>> While doing this port, I tried to consolidate common
>> Marvell code into
>> the arch/arm/mvebu-common directory. This directory
>> should be used to
>> collect more common code for the MVEBU SoC's (Dove,
>> Kirkwood, Armada 370,
>> Armada 380, Armada XP). I started with Kirkwood and
>> some of its
>> interfaces. Dove is definitely a candidate to move some
>> of its code
>> into thise directory as well.
>>
>> Because of the renaming of some functions from kirkwood
>> to mvebu (to make
>> them better usable on other MVEBU SoCs), this patch
>> series not only
>> touches the ARM SoC specific files (in arch/arm/...).
>> But also some
>> device drivers (e.g. SPI, I2C). Separating these driver
>> specific patches
>> into different patches that are not depending on this
>> ARM patch series
>> seems hard if not impossible. Thats why I would really
>> like to get this
>> patch series to get  applied completely be one
>> custodian. Not sure if
>> this could / should go through Tom directly? Only if
>> all the subsystem
>> custodians have given their "Acked-by ..." of course.
>
> Hi Stefan,
> I agree with you, since this patch series have huge changes it may go to Tom directly, I will review, test and provide ack/nack accordingly.
>
>>
>> Testing on Kirkwood based boards would be greatly
>> appreciated. So anyone with
>> access to some of those board, please give this patch
>> series a try. I really
>> hope that I didn't break anything while merging some of
>> the code into the
>> common mvebu directory.
>
> I will certainly help to test testing this stuff on all possible boards that I can access.
>
>>
>> Please note that this Armada XP port still requires the
>> "Binary Header"
>> (bin_hdr) from the Marvell U-Boot tree to be included
>> as a binary blob
>> into the resulting image (u-boot.kwb) that can be
>> booted by the MVEBU
>> BootROM. This binary bin_hdr is usually responsible for
>> the DDR3
>> controller configuration and the DDR3 training. One way
>> to extract this
>> bin_hdr binary from an existing Marvell boot image
>> right now is to use
>> the "kwbimage" tool from Barebox. Please refer to the
>> documentation
>> thats available there for more details.
>
> Finally, last but not least, may thanks for your efforts and all the best for smooth migration ahead.
>
> Regards...
> Prafulla . . .
>
>>
>> Thanks,
>> Stefan
>>
>>
>> Stefan Roese (25):
>>   sf: Add M25PX64 SPI NOR flash ID
>>   arm: kirkwood: spi.h: Add some missing parenthesis
>>   spi: kirkwood_spi.c: Some fixes and cleanup
>>   spi: kirkwood_spi.c: Make global variable static
>>   spi: kirkwood_spi.c: cosmetic: Fix minor coding style
>> issues

I took these spi stuff patches, rest of spi require dependencies - So I Acked.

Pls- Tom or someone push those as well while taking this series.

>>   arm: kirkwood: Move some SoC files into new
>> arch/arm/mvebu-common
>>   arm: marvell: Move arch/kirkwood.h to arch/soc.h
>>   arm: marvell: Move arch-kirkwood/spi.h to arch-
>> mvebu/spi.h
>>   arm: marvell: Rework timer.c to make it usable for
>> other MVEBU
>>     platforms
>>   arm: mvebu: Add common mbus functions to use on
>> Marvell SoCs
>>   spi: kirkwood_spi.c: Compile MPP (pin-mux) only for
>> kirkwood SoC's
>>   arm: marvell: Extract kirkwood gpio functions into
>> new common file
>>     gpio.c
>>   spi: kirkwood_spi.c: Change KW_SPI_BASE to
>> MVEBU_SPI_BASE
>>   arm: kirkwood: Change naming of dram functions from
>> km_foo() to
>>     mvebu_foo()
>>   net: mvneta.c: Add support for the ethernet
>> controller of the Marvell
>>     Armada XP SoC
>>   net: phy.h: Make PHY autonegotiation timeout
>> configurable
>>   i2c: mvtwsi: Add support for Marvell Armada XP
>>   arm: armada-xp: Add basic support for Marvell Armada
>> XP SoC
>>   arm: armada-xp: Add basic support for the Marvell DB-
>> 78460-BP board
>>   arm: kirkwood: Remove some dead code from cpu.c
>>   arm: kirkwood: Use mvebu new common mbus API
>>   tools/kwboot: Sync with latest barebox version to
>> support Armada XP
>>   tools: Compile kwboot for Marvell Armada XP as those
>> SoCs are now
>>     supported
>>   tools: kwbimage: Add image version 1 support for
>> Armada XP / 370
>>   Makefile: Add CONFIG_BUILD_TARGET to automatically
>> build an special
>>     image
>>
>>  Makefile                                           |
>> 9 +
>>  README                                             |
>> 8 +
>>  arch/arm/cpu/arm926ejs/kirkwood/Makefile           |
>> 4 +-
>>  arch/arm/cpu/arm926ejs/kirkwood/cpu.c              |
>> 174 +--
>>  arch/arm/cpu/arm926ejs/kirkwood/mpp.c              |
>> 2 +-
>>  arch/arm/cpu/armv7/armada-xp/Makefile              |
>> 7 +
>>  arch/arm/cpu/armv7/armada-xp/cpu.c                 |
>> 186 +++
>>  arch/arm/include/asm/arch-armada-xp/config.h       |
>> 80 +
>>  arch/arm/include/asm/arch-armada-xp/cpu.h          |
>> 103 ++
>>  arch/arm/include/asm/arch-armada-xp/soc.h          |
>> 57 +
>>  arch/arm/include/asm/arch-kirkwood/config.h        |
>> 2 +-
>>  arch/arm/include/asm/arch-kirkwood/cpu.h           |
>> 71 +-
>>  arch/arm/include/asm/arch-kirkwood/gpio.h          |
>> 16 +-
>>  .../asm/arch-kirkwood/{kirkwood.h => soc.h}        |
>> 25 +-
>>  .../asm/{arch-kirkwood => arch-mvebu}/spi.h        |
>> 8 +-
>>  arch/arm/mvebu-common/Makefile                     |
>> 12 +
>>  .../arm926ejs/kirkwood => mvebu-common}/dram.c     |
>> 63 +-
>>  arch/arm/mvebu-common/gpio.c                       |
>> 30 +
>>  arch/arm/mvebu-common/mbus.c                       |
>> 477 ++++++
>>  .../arm926ejs/kirkwood => mvebu-common}/timer.c    |
>> 92 +-
>>  board/LaCie/net2big_v2/net2big_v2.c                |
>> 8 +-
>>  board/LaCie/netspace_v2/netspace_v2.c              |
>> 8 +-
>>  board/LaCie/wireless_space/wireless_space.c        |
>> 8 +-
>>  board/Marvell/db-78460-bp/Makefile                 |
>> 7 +
>>  board/Marvell/db-78460-bp/db-78460-bp.c            |
>> 120 ++
>>  board/Marvell/db-78460-bp/kwbimage.cfg             |
>> 12 +
>>  board/Marvell/dreamplug/dreamplug.c                |
>> 10 +-
>>  board/Marvell/guruplug/guruplug.c                  |
>> 10 +-
>>  board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c    |
>> 10 +-
>>  board/Marvell/openrd/openrd.c                      |
>> 10 +-
>>  board/Marvell/rd6281a/rd6281a.c                    |
>> 10 +-
>>  board/Marvell/sheevaplug/sheevaplug.c              |
>> 10 +-
>>  board/Seagate/dockstar/dockstar.c                  |
>> 12 +-
>>  board/Seagate/goflexhome/goflexhome.c              |
>> 12 +-
>>  board/buffalo/lsxl/lsxl.c                          |
>> 10 +-
>>  board/cloudengines/pogo_e02/pogo_e02.c             |
>> 10 +-
>>  board/d-link/dns325/dns325.c                       |
>> 8 +-
>>  board/iomega/iconnect/iconnect.c                   |
>> 10 +-
>>  board/karo/tk71/tk71.c                             |
>> 10 +-
>>  board/keymile/km_arm/km_arm.c                      |
>> 10 +-
>>  board/raidsonic/ib62x0/ib62x0.c                    |
>> 10 +-
>>  boards.cfg                                         |
>> 1 +
>>  drivers/block/mvsata_ide.c                         |
>> 2 +-
>>  drivers/gpio/kw_gpio.c                             |
>> 2 +-
>>  drivers/i2c/mvtwsi.c                               |
>> 4 +-
>>  drivers/mtd/nand/kirkwood_nand.c                   |
>> 2 +-
>>  drivers/mtd/spi/sf_params.c                        |
>> 1 +
>>  drivers/net/Makefile                               |
>> 1 +
>>  drivers/net/mvgbe.c                                |
>> 2 +-
>>  drivers/net/mvneta.c                               |
>> 1653 ++++++++++++++++++++
>>  drivers/rtc/mvrtc.h                                |
>> 2 +-
>>  drivers/spi/kirkwood_spi.c                         |
>> 44 +-
>>  drivers/usb/host/ehci-marvell.c                    |
>> 45 +-
>>  include/configs/db-78460-bp.h                      |
>> 67 +
>>  include/linux/mbus.h                               |
>> 61 +
>>  include/netdev.h                                   |
>> 1 +
>>  include/phy.h                                      |
>> 2 +
>>  tools/Makefile                                     |
>> 1 +
>>  tools/kwbimage.c                                   |
>> 1050 +++++++++----
>>  tools/kwboot.c                                     |
>> 97 +-
>>  60 files changed, 4056 insertions(+), 723 deletions(-)
>>  create mode 100644 arch/arm/cpu/armv7/armada-
>> xp/Makefile
>>  create mode 100644 arch/arm/cpu/armv7/armada-xp/cpu.c
>>  create mode 100644 arch/arm/include/asm/arch-armada-
>> xp/config.h
>>  create mode 100644 arch/arm/include/asm/arch-armada-
>> xp/cpu.h
>>  create mode 100644 arch/arm/include/asm/arch-armada-
>> xp/soc.h
>>  rename arch/arm/include/asm/arch-kirkwood/{kirkwood.h
>> => soc.h} (74%)
>>  rename arch/arm/include/asm/{arch-kirkwood => arch-
>> mvebu}/spi.h (90%)
>>  create mode 100644 arch/arm/mvebu-common/Makefile
>>  rename arch/arm/{cpu/arm926ejs/kirkwood => mvebu-
>> common}/dram.c (57%)
>>  create mode 100644 arch/arm/mvebu-common/gpio.c
>>  create mode 100644 arch/arm/mvebu-common/mbus.c
>>  rename arch/arm/{cpu/arm926ejs/kirkwood => mvebu-
>> common}/timer.c (63%)
>>  create mode 100644 board/Marvell/db-78460-bp/Makefile
>>  create mode 100644 board/Marvell/db-78460-bp/db-78460-
>> bp.c
>>  create mode 100644 board/Marvell/db-78460-
>> bp/kwbimage.cfg
>>  create mode 100644 drivers/net/mvneta.c
>>  create mode 100644 include/configs/db-78460-bp.h
>>  create mode 100644 include/linux/mbus.h

thanks!
-- 
Jagan.

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 08/25] arm: marvell: Move arch-kirkwood/spi.h to arch-mvebu/spi.h
  2014-06-27  9:54 ` [U-Boot] [PATCH v1 08/25] arm: marvell: Move arch-kirkwood/spi.h to arch-mvebu/spi.h Stefan Roese
@ 2014-07-13 16:16   ` Jagan Teki
  0 siblings, 0 replies; 50+ messages in thread
From: Jagan Teki @ 2014-07-13 16:16 UTC (permalink / raw)
  To: u-boot

On Fri, Jun 27, 2014 at 3:24 PM, Stefan Roese <sr@denx.de> wrote:
> This move makes it possible to use this kirkwood SPI driver from other
> MVEBU platforms as well. This will be used by the upcoming Armada XP
> support.
>
> Signed-off-by: Stefan Roese <sr@denx.de>
> ---
>
>  arch/arm/include/asm/{arch-kirkwood => arch-mvebu}/spi.h | 0
>  drivers/spi/kirkwood_spi.c                               | 2 +-
>  2 files changed, 1 insertion(+), 1 deletion(-)
>  rename arch/arm/include/asm/{arch-kirkwood => arch-mvebu}/spi.h (100%)
>
> diff --git a/arch/arm/include/asm/arch-kirkwood/spi.h b/arch/arm/include/asm/arch-mvebu/spi.h
> similarity index 100%
> rename from arch/arm/include/asm/arch-kirkwood/spi.h
> rename to arch/arm/include/asm/arch-mvebu/spi.h
> diff --git a/drivers/spi/kirkwood_spi.c b/drivers/spi/kirkwood_spi.c
> index de0e914..9710f12 100644
> --- a/drivers/spi/kirkwood_spi.c
> +++ b/drivers/spi/kirkwood_spi.c
> @@ -13,8 +13,8 @@
>  #include <spi.h>
>  #include <asm/io.h>
>  #include <asm/arch/soc.h>
> -#include <asm/arch/spi.h>
>  #include <asm/arch/mpp.h>
> +#include <asm/arch-mvebu/spi.h>
>
>  static struct kwspi_registers *spireg = (struct kwspi_registers *)KW_SPI_BASE;
>

Reviewed-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>

thanks!
-- 
Jagan.

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 11/25] spi: kirkwood_spi.c: Compile MPP (pin-mux) only for kirkwood SoC's
  2014-06-27  9:54 ` [U-Boot] [PATCH v1 11/25] spi: kirkwood_spi.c: Compile MPP (pin-mux) only for kirkwood SoC's Stefan Roese
@ 2014-07-13 16:18   ` Jagan Teki
  0 siblings, 0 replies; 50+ messages in thread
From: Jagan Teki @ 2014-07-13 16:18 UTC (permalink / raw)
  To: u-boot

On Fri, Jun 27, 2014 at 3:24 PM, Stefan Roese <sr@denx.de> wrote:
> Compile the pin multiplexing only on Kirkwood platforms. As the
> Armada XP doesn't need it.
>
> Signed-off-by: Stefan Roese <sr@denx.de>
> Cc: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
> ---
>
>  drivers/spi/kirkwood_spi.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/drivers/spi/kirkwood_spi.c b/drivers/spi/kirkwood_spi.c
> index 9710f12..ce2ba96 100644
> --- a/drivers/spi/kirkwood_spi.c
> +++ b/drivers/spi/kirkwood_spi.c
> @@ -13,22 +13,28 @@
>  #include <spi.h>
>  #include <asm/io.h>
>  #include <asm/arch/soc.h>
> +#ifdef CONFIG_KIRKWOOD
>  #include <asm/arch/mpp.h>
> +#endif
>  #include <asm/arch-mvebu/spi.h>
>
>  static struct kwspi_registers *spireg = (struct kwspi_registers *)KW_SPI_BASE;
>
> +#ifdef CONFIG_KIRKWOOD
>  static u32 cs_spi_mpp_back[2];
> +#endif
>
>  struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
>                                 unsigned int max_hz, unsigned int mode)
>  {
>         struct spi_slave *slave;
>         u32 data;
> +#ifdef CONFIG_KIRKWOOD
>         static const u32 kwspi_mpp_config[2][2] = {
>                 { MPP0_SPI_SCn, 0 }, /* if cs == 0 */
>                 { MPP7_SPI_SCn, 0 } /* if cs != 0 */
>         };
> +#endif
>
>         if (!spi_cs_is_valid(bus, cs))
>                 return NULL;
> @@ -51,15 +57,19 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
>         writel(KWSPI_SMEMRDIRQ, &spireg->irq_cause);
>         writel(KWSPI_IRQMASK, &spireg->irq_mask);
>
> +#ifdef CONFIG_KIRKWOOD
>         /* program mpp registers to select  SPI_CSn */
>         kirkwood_mpp_conf(kwspi_mpp_config[cs ? 1 : 0], cs_spi_mpp_back);
> +#endif
>
>         return slave;
>  }
>
>  void spi_free_slave(struct spi_slave *slave)
>  {
> +#ifdef CONFIG_KIRKWOOD
>         kirkwood_mpp_conf(cs_spi_mpp_back, NULL);
> +#endif
>         free(slave);
>  }


Reviewed-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>

thanks!
-- 
Jagan.

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 13/25] spi: kirkwood_spi.c: Change KW_SPI_BASE to MVEBU_SPI_BASE
  2014-06-27  9:54 ` [U-Boot] [PATCH v1 13/25] spi: kirkwood_spi.c: Change KW_SPI_BASE to MVEBU_SPI_BASE Stefan Roese
@ 2014-07-13 16:18   ` Jagan Teki
  0 siblings, 0 replies; 50+ messages in thread
From: Jagan Teki @ 2014-07-13 16:18 UTC (permalink / raw)
  To: u-boot

On Fri, Jun 27, 2014 at 3:24 PM, Stefan Roese <sr@denx.de> wrote:
> This makes is possible to use this SPI driver from other MVEBU SoC's as well.
> As the upcoming Armada XP support will do.
>
> Signed-off-by: Stefan Roese <sr@denx.de>
> Cc: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
> ---
>
>  arch/arm/include/asm/arch-kirkwood/soc.h | 2 +-
>  drivers/spi/kirkwood_spi.c               | 3 ++-
>  2 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/include/asm/arch-kirkwood/soc.h b/arch/arm/include/asm/arch-kirkwood/soc.h
> index 37cbae9..379ce13 100644
> --- a/arch/arm/include/asm/arch-kirkwood/soc.h
> +++ b/arch/arm/include/asm/arch-kirkwood/soc.h
> @@ -30,7 +30,7 @@
>  #define MVEBU_GPIO1_BASE                       (KW_REGISTER(0x10140))
>  #define KW_RTC_BASE                    (KW_REGISTER(0x10300))
>  #define KW_NANDF_BASE                  (KW_REGISTER(0x10418))
> -#define KW_SPI_BASE                    (KW_REGISTER(0x10600))
> +#define MVEBU_SPI_BASE                 (KW_REGISTER(0x10600))
>  #define KW_CPU_WIN_BASE                        (KW_REGISTER(0x20000))
>  #define KW_CPU_REG_BASE                        (KW_REGISTER(0x20100))
>  #define MVEBU_TIMER_BASE                       (KW_REGISTER(0x20300))
> diff --git a/drivers/spi/kirkwood_spi.c b/drivers/spi/kirkwood_spi.c
> index ce2ba96..e7b0982 100644
> --- a/drivers/spi/kirkwood_spi.c
> +++ b/drivers/spi/kirkwood_spi.c
> @@ -18,7 +18,8 @@
>  #endif
>  #include <asm/arch-mvebu/spi.h>
>
> -static struct kwspi_registers *spireg = (struct kwspi_registers *)KW_SPI_BASE;
> +static struct kwspi_registers *spireg =
> +       (struct kwspi_registers *)MVEBU_SPI_BASE;
>
>  #ifdef CONFIG_KIRKWOOD
>  static u32 cs_spi_mpp_back[2];
> --

Reviewed-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>

thanks!
-- 
Jagan.

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 01/25] sf: Add M25PX64 SPI NOR flash ID
  2014-07-03 20:14   ` Jagan Teki
@ 2014-07-13 16:20     ` Jagan Teki
  0 siblings, 0 replies; 50+ messages in thread
From: Jagan Teki @ 2014-07-13 16:20 UTC (permalink / raw)
  To: u-boot

On Fri, Jul 4, 2014 at 1:44 AM, Jagan Teki <jagannadh.teki@gmail.com> wrote:
> Reviewed-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
>
> On Fri, Jun 27, 2014 at 3:24 PM, Stefan Roese <sr@denx.de> wrote:
>> Add ID for this Numonix / STMicro chip.
>>
>> Tested on Marvell DB-78460-BP board.
>>
>> Signed-off-by: Stefan Roese <sr@denx.de>
>> Cc: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
>> ---
>>
>>  drivers/mtd/spi/sf_params.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/mtd/spi/sf_params.c b/drivers/mtd/spi/sf_params.c
>> index ac886fd..b8186e9 100644
>> --- a/drivers/mtd/spi/sf_params.c
>> +++ b/drivers/mtd/spi/sf_params.c
>> @@ -71,6 +71,7 @@ const struct spi_flash_params spi_flash_params_table[] = {
>>         {"M25P32",         0x202016, 0x0,       64 * 1024,    64,       0,                        0},
>>         {"M25P64",         0x202017, 0x0,       64 * 1024,   128,       0,                        0},
>>         {"M25P128",        0x202018, 0x0,      256 * 1024,    64,       0,                        0},
>> +       {"M25PX64",        0x207117, 0x0,       64 * 1024,   128,       0,                  SECT_4K},
>>         {"N25Q32",         0x20ba16, 0x0,       64 * 1024,    64, RD_FULL,         WR_QPP | SECT_4K},
>>         {"N25Q32A",        0x20bb16, 0x0,       64 * 1024,    64, RD_FULL,         WR_QPP | SECT_4K},
>>         {"N25Q64",         0x20ba17, 0x0,       64 * 1024,   128, RD_FULL,         WR_QPP | SECT_4K},
>> --
>> 2.0.1
>>

Applied 01/25 to 05/25 to u-boot-spi/master

thanks!
-- 
Jagan.

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 0/25] Add Marvell Armada XP MV78460 SoC support
  2014-07-13 16:15   ` Jagan Teki
@ 2014-07-14 14:51     ` Tom Rini
  0 siblings, 0 replies; 50+ messages in thread
From: Tom Rini @ 2014-07-14 14:51 UTC (permalink / raw)
  To: u-boot

On Sun, Jul 13, 2014 at 09:45:51PM +0530, Jagan Teki wrote:
> On Fri, Jun 27, 2014 at 3:48 PM, Prafulla Wadaskar <prafulla@marvell.com> wrote:
> >
> >
> >> -----Original Message-----
> >> From: Stefan Roese [mailto:sr at denx.de]
> >> Sent: 27 June 2014 15:25
> >> To: u-boot at lists.denx.de
> >> Cc: Prafulla Wadaskar; trini at ti.com
> >> Subject: [PATCH v1 0/25] Add Marvell Armada XP MV78460
> >> SoC support
> >>
> >>
> >> This patch series adds support for the Marvell Armada
> >> XP SoC's. Specifically
> >> the MV78460.
> >>
> >> Basic support for the db-78460-bp evaluation board is
> >> added. Supporting the
> >> following interfaces:
> >> - UART
> >> - SPI (including SPI NOR flash)
> >> - I2C
> >> - Ethernet (neta)
> >>
> >> While doing this port, I tried to consolidate common
> >> Marvell code into
> >> the arch/arm/mvebu-common directory. This directory
> >> should be used to
> >> collect more common code for the MVEBU SoC's (Dove,
> >> Kirkwood, Armada 370,
> >> Armada 380, Armada XP). I started with Kirkwood and
> >> some of its
> >> interfaces. Dove is definitely a candidate to move some
> >> of its code
> >> into thise directory as well.
> >>
> >> Because of the renaming of some functions from kirkwood
> >> to mvebu (to make
> >> them better usable on other MVEBU SoCs), this patch
> >> series not only
> >> touches the ARM SoC specific files (in arch/arm/...).
> >> But also some
> >> device drivers (e.g. SPI, I2C). Separating these driver
> >> specific patches
> >> into different patches that are not depending on this
> >> ARM patch series
> >> seems hard if not impossible. Thats why I would really
> >> like to get this
> >> patch series to get  applied completely be one
> >> custodian. Not sure if
> >> this could / should go through Tom directly? Only if
> >> all the subsystem
> >> custodians have given their "Acked-by ..." of course.
> >
> > Hi Stefan,
> > I agree with you, since this patch series have huge changes it may go to Tom directly, I will review, test and provide ack/nack accordingly.
> >
> >>
> >> Testing on Kirkwood based boards would be greatly
> >> appreciated. So anyone with
> >> access to some of those board, please give this patch
> >> series a try. I really
> >> hope that I didn't break anything while merging some of
> >> the code into the
> >> common mvebu directory.
> >
> > I will certainly help to test testing this stuff on all possible boards that I can access.
> >
> >>
> >> Please note that this Armada XP port still requires the
> >> "Binary Header"
> >> (bin_hdr) from the Marvell U-Boot tree to be included
> >> as a binary blob
> >> into the resulting image (u-boot.kwb) that can be
> >> booted by the MVEBU
> >> BootROM. This binary bin_hdr is usually responsible for
> >> the DDR3
> >> controller configuration and the DDR3 training. One way
> >> to extract this
> >> bin_hdr binary from an existing Marvell boot image
> >> right now is to use
> >> the "kwbimage" tool from Barebox. Please refer to the
> >> documentation
> >> thats available there for more details.
> >
> > Finally, last but not least, may thanks for your efforts and all the best for smooth migration ahead.
> >
> > Regards...
> > Prafulla . . .
> >
> >>
> >> Thanks,
> >> Stefan
> >>
> >>
> >> Stefan Roese (25):
> >>   sf: Add M25PX64 SPI NOR flash ID
> >>   arm: kirkwood: spi.h: Add some missing parenthesis
> >>   spi: kirkwood_spi.c: Some fixes and cleanup
> >>   spi: kirkwood_spi.c: Make global variable static
> >>   spi: kirkwood_spi.c: cosmetic: Fix minor coding style
> >> issues
> 
> I took these spi stuff patches, rest of spi require dependencies - So I Acked.
> 
> Pls- Tom or someone push those as well while taking this series.

FWIW, in the future I'm fine with things like this coming in via the ARM
SoC sub-tree with acks/reviewed-by's from the relevant other subsystem
maintainers, to make dependencies easier.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140714/1a27fd02/attachment.pgp>

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 22/25] tools/kwboot: Sync with latest barebox version to support Armada XP
  2014-07-03 22:02   ` Luka Perkov
@ 2014-07-28  6:47     ` Stefan Roese
  2014-07-29 23:16       ` Luka Perkov
  0 siblings, 1 reply; 50+ messages in thread
From: Stefan Roese @ 2014-07-28  6:47 UTC (permalink / raw)
  To: u-boot

Hi Luka!

Sorry for the late reply to this comment.

On 04.07.2014 00:02, Luka Perkov wrote:
> Hi Stefan,
>
> On Fri, Jun 27, 2014 at 11:55:08AM +0200, Stefan Roese wrote:
>> The barebox version of the kwboot tool has evolved a bit. To support
>> Armada XP and Dove. Additionally a few minor fixes have been applied.
>> So lets sync with the latest barebox version.
>>
>> Please note that the main difference between both versions now is, that
>> the U-Boot version still supports the -p option, to dynamically patch
>> an image for UART boot mode. I didn't test it now though.
>>
>> Signed-off-by: Stefan Roese <sr@denx.de>
>> ---
>>
>>   tools/kwboot.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++++---------
>>   1 file changed, 83 insertions(+), 14 deletions(-)
>
> ...
>
>> -#define KWBOOT_MSG_REQ_DELAY	10 /* ms */
>> -#define KWBOOT_MSG_RSP_TIMEO	50 /* ms */
>> +static unsigned char kwboot_msg_debug[] = {
>> +	0xDD, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77
>> +};
>> +
>> +#define KWBOOT_MSG_REQ_DELAY	1000 /* ms */
>> +#define KWBOOT_MSG_RSP_TIMEO	1000 /* ms */
>
> This causes problems on kirkwood. The old values should be kept, apply
> the patch below to this one. After that chage feel free to add Tested-by
> line.
>
> Tested-by: Luka Perkov <luka@openwrt.org>
>
> Now only to figure out why 21/25 breaks things on kirkwood.
>
> Luka
>
> diff --git a/tools/kwboot.c b/tools/kwboot.c
> index c47970e..ccc9d90 100644
> --- a/tools/kwboot.c
> +++ b/tools/kwboot.c
> @@ -42,8 +42,8 @@ static unsigned char kwboot_msg_debug[] = {
>   	0xDD, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77
>   };
>
> -#define KWBOOT_MSG_REQ_DELAY	1000 /* ms */
> -#define KWBOOT_MSG_RSP_TIMEO	1000 /* ms */
> +#define KWBOOT_MSG_REQ_DELAY	10 /* ms */
> +#define KWBOOT_MSG_RSP_TIMEO	50 /* ms */

Unfortunately these settings do not work with Armada XP. I tested a bit 
and it seems that e.g. this setting works on Armada XP:

#define KWBOOT_MSG_REQ_DELAY	10 /* ms */
#define KWBOOT_MSG_RSP_TIMEO	1000 /* ms */

Could you please check this on your Kirkwood platform? And perhaps find 
a configuration that works for the SoC's? That would be great!

Thanks,
Stefan

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 22/25] tools/kwboot: Sync with latest barebox version to support Armada XP
  2014-06-27  9:55 ` [U-Boot] [PATCH v1 22/25] tools/kwboot: Sync with latest barebox version to support Armada XP Stefan Roese
  2014-06-27 19:06   ` Luka Perkov
  2014-07-03 22:02   ` Luka Perkov
@ 2014-07-28  8:12   ` Wolfgang Denk
  2 siblings, 0 replies; 50+ messages in thread
From: Wolfgang Denk @ 2014-07-28  8:12 UTC (permalink / raw)
  To: u-boot

Dear Daniel,

In message <1403862911-6138-23-git-send-email-sr@denx.de> Stefan Roese wrote:
...
>  tools/kwboot.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++++---------
>  1 file changed, 83 insertions(+), 14 deletions(-)

It appears that you are the original author of the kwboot.c code,
is this correct?

The file does not include any license information.  As you submitted
it to the U-Boot project, we can assume they are supposed to be
covered by the project wide license terms, but I'd rather be sure
about that.

Could you please elucidate?

Thanks.

Best regards,

Wolfgang Denk

-- 
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
If you believe that feeling bad or worrying long enough will change a
past or future event, then you are residing on another planet with  a
different reality system.

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 22/25] tools/kwboot: Sync with latest barebox version to support Armada XP
  2014-07-28  6:47     ` Stefan Roese
@ 2014-07-29 23:16       ` Luka Perkov
  2014-07-30  8:53         ` Stefan Roese
  0 siblings, 1 reply; 50+ messages in thread
From: Luka Perkov @ 2014-07-29 23:16 UTC (permalink / raw)
  To: u-boot

Hi Stefan,

On Mon, Jul 28, 2014 at 08:47:13AM +0200, Stefan Roese wrote:
> Sorry for the late reply to this comment.
> 
> On 04.07.2014 00:02, Luka Perkov wrote:
> >On Fri, Jun 27, 2014 at 11:55:08AM +0200, Stefan Roese wrote:
> >>The barebox version of the kwboot tool has evolved a bit. To support
> >>Armada XP and Dove. Additionally a few minor fixes have been applied.
> >>So lets sync with the latest barebox version.
> >>
> >>Please note that the main difference between both versions now is, that
> >>the U-Boot version still supports the -p option, to dynamically patch
> >>an image for UART boot mode. I didn't test it now though.
> >>
> >>Signed-off-by: Stefan Roese <sr@denx.de>
> >>---
> >>
> >>  tools/kwboot.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++++---------
> >>  1 file changed, 83 insertions(+), 14 deletions(-)
> >
> >...
> >
> >>-#define KWBOOT_MSG_REQ_DELAY	10 /* ms */
> >>-#define KWBOOT_MSG_RSP_TIMEO	50 /* ms */
> >>+static unsigned char kwboot_msg_debug[] = {
> >>+	0xDD, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77
> >>+};
> >>+
> >>+#define KWBOOT_MSG_REQ_DELAY	1000 /* ms */
> >>+#define KWBOOT_MSG_RSP_TIMEO	1000 /* ms */
> >
> >This causes problems on kirkwood. The old values should be kept, apply
> >the patch below to this one. After that chage feel free to add Tested-by
> >line.
> >
> >Tested-by: Luka Perkov <luka@openwrt.org>
> >
> >Now only to figure out why 21/25 breaks things on kirkwood.
> >
> >Luka
> >
> >diff --git a/tools/kwboot.c b/tools/kwboot.c
> >index c47970e..ccc9d90 100644
> >--- a/tools/kwboot.c
> >+++ b/tools/kwboot.c
> >@@ -42,8 +42,8 @@ static unsigned char kwboot_msg_debug[] = {
> >  	0xDD, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77
> >  };
> >
> >-#define KWBOOT_MSG_REQ_DELAY	1000 /* ms */
> >-#define KWBOOT_MSG_RSP_TIMEO	1000 /* ms */
> >+#define KWBOOT_MSG_REQ_DELAY	10 /* ms */
> >+#define KWBOOT_MSG_RSP_TIMEO	50 /* ms */
> 
> Unfortunately these settings do not work with Armada XP. I tested a bit and
> it seems that e.g. this setting works on Armada XP:
> 
> #define KWBOOT_MSG_REQ_DELAY	10 /* ms */
> #define KWBOOT_MSG_RSP_TIMEO	1000 /* ms */
> 
> Could you please check this on your Kirkwood platform? And perhaps find a
> configuration that works for the SoC's? That would be great!

I just tried this and it does not work on kirkwood. I've stumbled upon
this thread though, it might be useful:

http://lists.infradead.org/pipermail/barebox/2014-June/019618.html

Can we just add a flag to kwboot which will use appropriate values for
kirkwood and armada? We can keep kirkwood by default, that way we won't
break anything.

Luka

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [U-Boot] [PATCH v1 22/25] tools/kwboot: Sync with latest barebox version to support Armada XP
  2014-07-29 23:16       ` Luka Perkov
@ 2014-07-30  8:53         ` Stefan Roese
  0 siblings, 0 replies; 50+ messages in thread
From: Stefan Roese @ 2014-07-30  8:53 UTC (permalink / raw)
  To: u-boot

Hi Luka,

On 30.07.2014 01:16, Luka Perkov wrote:

<snip>

>>> -#define KWBOOT_MSG_REQ_DELAY	1000 /* ms */
>>> -#define KWBOOT_MSG_RSP_TIMEO	1000 /* ms */
>>> +#define KWBOOT_MSG_REQ_DELAY	10 /* ms */
>>> +#define KWBOOT_MSG_RSP_TIMEO	50 /* ms */
>>
>> Unfortunately these settings do not work with Armada XP. I tested a bit and
>> it seems that e.g. this setting works on Armada XP:
>>
>> #define KWBOOT_MSG_REQ_DELAY	10 /* ms */
>> #define KWBOOT_MSG_RSP_TIMEO	1000 /* ms */
>>
>> Could you please check this on your Kirkwood platform? And perhaps find a
>> configuration that works for the SoC's? That would be great!
>
> I just tried this and it does not work on kirkwood. I've stumbled upon
> this thread though, it might be useful:
>
> http://lists.infradead.org/pipermail/barebox/2014-June/019618.html

Yes, thanks.

> Can we just add a flag to kwboot which will use appropriate values for
> kirkwood and armada? We can keep kirkwood by default, that way we won't
> break anything.

If nobody comes up with a working solution (timeout values that work for 
both SoC's), then such a parameter is of course an option.

Thanks,
Stefan

^ permalink raw reply	[flat|nested] 50+ messages in thread

end of thread, other threads:[~2014-07-30  8:53 UTC | newest]

Thread overview: 50+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-27  9:54 [U-Boot] [PATCH v1 0/25] Add Marvell Armada XP MV78460 SoC support Stefan Roese
2014-06-27  9:54 ` [U-Boot] [PATCH v1 01/25] sf: Add M25PX64 SPI NOR flash ID Stefan Roese
2014-07-03 20:14   ` Jagan Teki
2014-07-13 16:20     ` Jagan Teki
2014-06-27  9:54 ` [U-Boot] [PATCH v1 02/25] arm: kirkwood: spi.h: Add some missing parenthesis Stefan Roese
2014-07-03 20:15   ` Jagan Teki
2014-06-27  9:54 ` [U-Boot] [PATCH v1 03/25] spi: kirkwood_spi.c: Some fixes and cleanup Stefan Roese
2014-07-03 20:16   ` Jagan Teki
2014-06-27  9:54 ` [U-Boot] [PATCH v1 04/25] spi: kirkwood_spi.c: Make global variable static Stefan Roese
2014-07-03 20:18   ` Jagan Teki
2014-06-27  9:54 ` [U-Boot] [PATCH v1 05/25] spi: kirkwood_spi.c: cosmetic: Fix minor coding style issues Stefan Roese
2014-07-03 20:18   ` Jagan Teki
2014-06-27  9:54 ` [U-Boot] [PATCH v1 06/25] arm: kirkwood: Move some SoC files into new arch/arm/mvebu-common Stefan Roese
2014-06-27  9:54 ` [U-Boot] [PATCH v1 07/25] arm: marvell: Move arch/kirkwood.h to arch/soc.h Stefan Roese
2014-06-27  9:54 ` [U-Boot] [PATCH v1 08/25] arm: marvell: Move arch-kirkwood/spi.h to arch-mvebu/spi.h Stefan Roese
2014-07-13 16:16   ` Jagan Teki
2014-06-27  9:54 ` [U-Boot] [PATCH v1 09/25] arm: marvell: Rework timer.c to make it usable for other MVEBU platforms Stefan Roese
2014-06-27  9:54 ` [U-Boot] [PATCH v1 10/25] arm: mvebu: Add common mbus functions to use on Marvell SoCs Stefan Roese
2014-06-27  9:54 ` [U-Boot] [PATCH v1 11/25] spi: kirkwood_spi.c: Compile MPP (pin-mux) only for kirkwood SoC's Stefan Roese
2014-07-13 16:18   ` Jagan Teki
2014-06-27  9:54 ` [U-Boot] [PATCH v1 12/25] arm: marvell: Extract kirkwood gpio functions into new common file gpio.c Stefan Roese
2014-06-27  9:54 ` [U-Boot] [PATCH v1 13/25] spi: kirkwood_spi.c: Change KW_SPI_BASE to MVEBU_SPI_BASE Stefan Roese
2014-07-13 16:18   ` Jagan Teki
2014-06-27  9:55 ` [U-Boot] [PATCH v1 14/25] arm: kirkwood: Change naming of dram functions from km_foo() to mvebu_foo() Stefan Roese
2014-06-27  9:55 ` [U-Boot] [PATCH v1 15/25] net: mvneta.c: Add support for the ethernet controller of the Marvell Armada XP SoC Stefan Roese
2014-06-27  9:55 ` [U-Boot] [PATCH v1 16/25] net: phy.h: Make PHY autonegotiation timeout configurable Stefan Roese
2014-06-27  9:55 ` [U-Boot] [PATCH v1 17/25] i2c: mvtwsi: Add support for Marvell Armada XP Stefan Roese
2014-07-01  5:48   ` Heiko Schocher
2014-06-27  9:55 ` [U-Boot] [PATCH v1 18/25] arm: armada-xp: Add basic support for Marvell Armada XP SoC Stefan Roese
2014-06-27  9:55 ` [U-Boot] [PATCH v1 19/25] arm: armada-xp: Add basic support for the Marvell DB-78460-BP board Stefan Roese
2014-06-27  9:55 ` [U-Boot] [PATCH v1 20/25] arm: kirkwood: Remove some dead code from cpu.c Stefan Roese
2014-07-01 23:45   ` Luka Perkov
2014-06-27  9:55 ` [U-Boot] [PATCH v1 21/25] arm: kirkwood: Use mvebu new common mbus API Stefan Roese
2014-06-27  9:55 ` [U-Boot] [PATCH v1 22/25] tools/kwboot: Sync with latest barebox version to support Armada XP Stefan Roese
2014-06-27 19:06   ` Luka Perkov
2014-06-28  1:25     ` Daniel Stodden
2014-06-28  7:43     ` Stefan Roese
2014-07-03 22:02   ` Luka Perkov
2014-07-28  6:47     ` Stefan Roese
2014-07-29 23:16       ` Luka Perkov
2014-07-30  8:53         ` Stefan Roese
2014-07-28  8:12   ` Wolfgang Denk
2014-06-27  9:55 ` [U-Boot] [PATCH v1 23/25] tools: Compile kwboot for Marvell Armada XP as those SoCs are now supported Stefan Roese
2014-07-03 22:03   ` Luka Perkov
2014-06-27  9:55 ` [U-Boot] [PATCH v1 24/25] tools: kwbimage: Add image version 1 support for Armada XP / 370 Stefan Roese
2014-07-03 22:03   ` Luka Perkov
2014-06-27  9:55 ` [U-Boot] [PATCH v1 25/25] Makefile: Add CONFIG_BUILD_TARGET to automatically build an special image Stefan Roese
2014-06-27 10:18 ` [U-Boot] [PATCH v1 0/25] Add Marvell Armada XP MV78460 SoC support Prafulla Wadaskar
2014-07-13 16:15   ` Jagan Teki
2014-07-14 14:51     ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.