From shc_work at mail.ru  Thu Nov  1 01:20:38 2012
From: shc_work at mail.ru (Alexander Shiyan)
Date: Thu, 1 Nov 2012 09:20:38 +0400
Subject: [PATCH v3 1/3] ARM: Add CLPS711X architecture
In-Reply-To: <20121031213608.GR1641@pengutronix.de>
References: <1351613312-4506-1-git-send-email-shc_work@mail.ru>
 <20121031213608.GR1641@pengutronix.de>
Message-ID: <20121101092038.0b71630228ecac770b8b1128@mail.ru>

On Wed, 31 Oct 2012 22:36:08 +0100
Sascha Hauer <s.hauer at pengutronix.de> wrote:

...
> > +
> > +	asm("mov pc, #0");
> 
> Or is it because you do not have a real reset function and have to jump
> through zero instead? Still common_reset() shouldn't be necessary. What
Yes.
> you may have to do here is to make sure the MMU is disabled and caches
> are flushed.
Yes. This call was be added for do it.
I may replace entrie function by calling start(). Is it a better way()?

-- 
Alexander Shiyan <shc_work at mail.ru>


From s.hauer at pengutronix.de  Thu Nov  1 03:32:51 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu, 1 Nov 2012 08:32:51 +0100
Subject: [PATCH v3 1/3] ARM: Add CLPS711X architecture
In-Reply-To: <20121101092038.0b71630228ecac770b8b1128@mail.ru>
References: <1351613312-4506-1-git-send-email-shc_work@mail.ru>
 <20121031213608.GR1641@pengutronix.de>
 <20121101092038.0b71630228ecac770b8b1128@mail.ru>
Message-ID: <20121101073251.GS1641@pengutronix.de>

On Thu, Nov 01, 2012 at 09:20:38AM +0400, Alexander Shiyan wrote:
> On Wed, 31 Oct 2012 22:36:08 +0100
> Sascha Hauer <s.hauer at pengutronix.de> wrote:
> 
> ...
> > > +
> > > +	asm("mov pc, #0");
> > 
> > Or is it because you do not have a real reset function and have to jump
> > through zero instead? Still common_reset() shouldn't be necessary. What
> Yes.
> > you may have to do here is to make sure the MMU is disabled and caches
> > are flushed.
> Yes. This call was be added for do it.
> I may replace entrie function by calling start(). Is it a better way()?

arch_shutdown() should do it.

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Thu Nov  1 03:43:20 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu,  1 Nov 2012 08:43:20 +0100
Subject: [PATCH] net usb asix: Add missing line breaks in dev_* messages
Message-ID: <1351755800-11279-1-git-send-email-s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/net/usb/asix.c |   56 ++++++++++++++++++++++++------------------------
 1 file changed, 28 insertions(+), 28 deletions(-)

diff --git a/drivers/net/usb/asix.c b/drivers/net/usb/asix.c
index 97680cf..5975e2a 100644
--- a/drivers/net/usb/asix.c
+++ b/drivers/net/usb/asix.c
@@ -154,7 +154,7 @@ static int asix_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
 	void *buf;
 	int err = -ENOMEM;
 
-	dev_dbg(&dev->edev.dev, "asix_read_cmd() cmd=0x%02x value=0x%04x index=0x%04x size=%d",
+	dev_dbg(&dev->edev.dev, "asix_read_cmd() cmd=0x%02x value=0x%04x index=0x%04x size=%d\n",
 		cmd, value, index, size);
 
 	buf = malloc(size);
@@ -187,7 +187,7 @@ static int asix_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
 	void *buf = NULL;
 	int err = -ENOMEM;
 
-	dev_dbg(&dev->edev.dev, "asix_write_cmd() cmd=0x%02x value=0x%04x index=0x%04x size=%d",
+	dev_dbg(&dev->edev.dev, "asix_write_cmd() cmd=0x%02x value=0x%04x index=0x%04x size=%d\n",
 		cmd, value, index, size);
 
 	if (data) {
@@ -218,7 +218,7 @@ static inline int asix_set_sw_mii(struct usbnet *dev)
 	int ret;
 	ret = asix_write_cmd(dev, AX_CMD_SET_SW_MII, 0x0000, 0, 0, NULL);
 	if (ret < 0)
-		dev_err(&dev->edev.dev, "Failed to enable software MII access");
+		dev_err(&dev->edev.dev, "Failed to enable software MII access\n");
 	return ret;
 }
 
@@ -227,7 +227,7 @@ static inline int asix_set_hw_mii(struct usbnet *dev)
 	int ret;
 	ret = asix_write_cmd(dev, AX_CMD_SET_HW_MII, 0x0000, 0, 0, NULL);
 	if (ret < 0)
-		dev_err(&dev->edev.dev, "Failed to enable hardware MII access");
+		dev_err(&dev->edev.dev, "Failed to enable hardware MII access\n");
 	return ret;
 }
 
@@ -241,7 +241,7 @@ static int asix_mdio_read(struct mii_bus *bus, int phy_id, int loc)
 				(__u16)loc, 2, &res);
 	asix_set_hw_mii(dev);
 
-	dev_dbg(&dev->edev.dev, "asix_mdio_read() phy_id=0x%02x, loc=0x%02x, returns=0x%04x",
+	dev_dbg(&dev->edev.dev, "asix_mdio_read() phy_id=0x%02x, loc=0x%02x, returns=0x%04x\n",
 			phy_id, loc, le16_to_cpu(res));
 
 	return le16_to_cpu(res);
@@ -252,7 +252,7 @@ static int asix_mdio_write(struct mii_bus *bus, int phy_id, int loc, u16 val)
 	struct usbnet *dev = bus->priv;
 	__le16 res = cpu_to_le16(val);
 
-	dev_dbg(&dev->edev.dev, "asix_mdio_write() phy_id=0x%02x, loc=0x%02x, val=0x%04x",
+	dev_dbg(&dev->edev.dev, "asix_mdio_write() phy_id=0x%02x, loc=0x%02x, val=0x%04x\n",
 			phy_id, loc, val);
 
 	asix_set_sw_mii(dev);
@@ -270,10 +270,10 @@ static inline int asix_get_phy_addr(struct usbnet *dev)
 	dev_dbg(&dev->edev.dev, "asix_get_phy_addr()");
 
 	if (ret < 0) {
-		dev_err(&dev->edev.dev, "Error reading PHYID register: %02x", ret);
+		dev_err(&dev->edev.dev, "Error reading PHYID register: %02x\n", ret);
 		goto out;
 	}
-	dev_dbg(&dev->edev.dev, "asix_get_phy_addr() returning 0x%04x", *((__le16 *)buf));
+	dev_dbg(&dev->edev.dev, "asix_get_phy_addr() returning 0x%04x\n", *((__le16 *)buf));
 	ret = buf[1];
 
 out:
@@ -286,7 +286,7 @@ static int asix_sw_reset(struct usbnet *dev, u8 flags)
 
         ret = asix_write_cmd(dev, AX_CMD_SW_RESET, flags, 0, 0, NULL);
 	if (ret < 0)
-		dev_err(&dev->edev.dev, "Failed to send software reset: %02x", ret);
+		dev_err(&dev->edev.dev, "Failed to send software reset: %02x\n", ret);
 
 	return ret;
 }
@@ -297,7 +297,7 @@ static u16 asix_read_rx_ctl(struct usbnet *dev)
 	int ret = asix_read_cmd(dev, AX_CMD_READ_RX_CTL, 0, 0, 2, &v);
 
 	if (ret < 0) {
-		dev_err(&dev->edev.dev, "Error reading RX_CTL register: %02x", ret);
+		dev_err(&dev->edev.dev, "Error reading RX_CTL register: %02x\n", ret);
 		goto out;
 	}
 	ret = le16_to_cpu(v);
@@ -309,10 +309,10 @@ static int asix_write_rx_ctl(struct usbnet *dev, u16 mode)
 {
 	int ret;
 
-	dev_dbg(&dev->edev.dev, "asix_write_rx_ctl() - mode = 0x%04x", mode);
+	dev_dbg(&dev->edev.dev, "asix_write_rx_ctl() - mode = 0x%04x\n", mode);
 	ret = asix_write_cmd(dev, AX_CMD_WRITE_RX_CTL, mode, 0, 0, NULL);
 	if (ret < 0)
-		dev_err(&dev->edev.dev, "Failed to write RX_CTL mode to 0x%04x: %02x",
+		dev_err(&dev->edev.dev, "Failed to write RX_CTL mode to 0x%04x: %02x\n",
 		       mode, ret);
 
 	return ret;
@@ -324,7 +324,7 @@ static u16 asix_read_medium_status(struct usbnet *dev)
 	int ret = asix_read_cmd(dev, AX_CMD_READ_MEDIUM_STATUS, 0, 0, 2, &v);
 
 	if (ret < 0) {
-		dev_err(&dev->edev.dev, "Error reading Medium Status register: %02x", ret);
+		dev_err(&dev->edev.dev, "Error reading Medium Status register: %02x\n", ret);
 		goto out;
 	}
 	ret = le16_to_cpu(v);
@@ -336,10 +336,10 @@ static int asix_write_medium_mode(struct usbnet *dev, u16 mode)
 {
 	int ret;
 
-	dev_dbg(&dev->edev.dev, "asix_write_medium_mode() - mode = 0x%04x", mode);
+	dev_dbg(&dev->edev.dev, "asix_write_medium_mode() - mode = 0x%04x\n", mode);
 	ret = asix_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE, mode, 0, 0, NULL);
 	if (ret < 0)
-		dev_err(&dev->edev.dev, "Failed to write Medium Mode mode to 0x%04x: %02x",
+		dev_err(&dev->edev.dev, "Failed to write Medium Mode mode to 0x%04x: %02x\n",
 			mode, ret);
 
 	return ret;
@@ -349,10 +349,10 @@ static int asix_write_gpio(struct usbnet *dev, u16 value, int sleep)
 {
 	int ret;
 
-	dev_dbg(&dev->edev.dev,"asix_write_gpio() - value = 0x%04x", value);
+	dev_dbg(&dev->edev.dev,"asix_write_gpio() - value = 0x%04x\n", value);
 	ret = asix_write_cmd(dev, AX_CMD_WRITE_GPIOS, value, 0, 0, NULL);
 	if (ret < 0)
-		dev_err(&dev->edev.dev, "Failed to write GPIO value 0x%04x: %02x",
+		dev_err(&dev->edev.dev, "Failed to write GPIO value 0x%04x: %02x\n",
 			value, ret);
 
 	if (sleep)
@@ -369,7 +369,7 @@ static int asix_get_ethaddr(struct eth_device *edev, unsigned char *adr)
 	/* Get the MAC address */
 	if ((ret = asix_read_cmd(udev, AX_CMD_READ_NODE_ID,
 				0, 0, 6, adr)) < 0) {
-		debug("Failed to read MAC address: %d", ret);
+		debug("Failed to read MAC address: %d\n", ret);
 		return -1;
 	}
 
@@ -390,7 +390,7 @@ static int ax88172_get_ethaddr(struct eth_device *edev, unsigned char *adr)
 	/* Get the MAC address */
 	if ((ret = asix_read_cmd(udev, AX88172_CMD_READ_NODE_ID,
 				0, 0, 6, adr)) < 0) {
-		debug("read AX_CMD_READ_NODE_ID failed: %d", ret);
+		debug("read AX_CMD_READ_NODE_ID failed: %d\n", ret);
 		return -1;
 	}
 
@@ -409,13 +409,13 @@ static int asix_rx_fixup(struct usbnet *dev, void *buf, int len)
 
 	while (len > 0) {
 		if ((short)(header & 0x0000ffff) != ~((short)((header & 0xffff0000) >> 16)))
-			dev_err(&dev->edev.dev, "asix_rx_fixup() Bad Header Length");
+			dev_err(&dev->edev.dev, "asix_rx_fixup() Bad Header Length\n");
 
 		/* get the packet length */
 		size = (unsigned short) (header & 0x0000ffff);
 
 		if (size > 1514) {
-			dev_err(&dev->edev.dev, "asix_rx_fixup() Bad RX Length %d", size);
+			dev_err(&dev->edev.dev, "asix_rx_fixup() Bad RX Length %d\n", size);
 			return 0;
 		}
 
@@ -434,7 +434,7 @@ static int asix_rx_fixup(struct usbnet *dev, void *buf, int len)
 	}
 
 	if (len < 0) {
-		dev_err(&dev->edev.dev,"asix_rx_fixup() Bad SKB Length %d", len);
+		dev_err(&dev->edev.dev,"asix_rx_fixup() Bad SKB Length %d\n", len);
 		return -1;
 	}
 	return 0;
@@ -549,7 +549,7 @@ static int ax88772_bind(struct usbnet *dev)
 	embd_phy = ((asix_get_phy_addr(dev) & 0x1f) == 0x10 ? 1 : 0);
 	if ((ret = asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT,
 				embd_phy, 0, 0, NULL)) < 0) {
-		debug("Select PHY #1 failed: %d", ret);
+		debug("Select PHY #1 failed: %d\n", ret);
 		goto out;
 	}
 
@@ -572,12 +572,12 @@ static int ax88772_bind(struct usbnet *dev)
 
 	mdelay(150);
 	rx_ctl = asix_read_rx_ctl(dev);
-	debug("RX_CTL is 0x%04x after software reset", rx_ctl);
+	debug("RX_CTL is 0x%04x after software reset\n", rx_ctl);
 	if ((ret = asix_write_rx_ctl(dev, 0x0000)) < 0)
 		goto out;
 
 	rx_ctl = asix_read_rx_ctl(dev);
-	debug("RX_CTL is 0x%04x setting to 0x0000", rx_ctl);
+	debug("RX_CTL is 0x%04x setting to 0x0000\n", rx_ctl);
 
 	dev->edev.get_ethaddr = asix_get_ethaddr;
 	dev->edev.set_ethaddr = asix_set_ethaddr;
@@ -599,7 +599,7 @@ static int ax88772_bind(struct usbnet *dev)
 	if ((ret = asix_write_cmd(dev, AX_CMD_WRITE_IPG0,
 				AX88772_IPG0_DEFAULT | AX88772_IPG1_DEFAULT,
 				AX88772_IPG2_DEFAULT, 0, NULL)) < 0) {
-		debug("Write IPG,IPG1,IPG2 failed: %d", ret);
+		debug("Write IPG,IPG1,IPG2 failed: %d\n", ret);
 		goto out;
 	}
 
@@ -608,10 +608,10 @@ static int ax88772_bind(struct usbnet *dev)
 		goto out;
 
 	rx_ctl = asix_read_rx_ctl(dev);
-	debug("RX_CTL is 0x%04x after all initializations", rx_ctl);
+	debug("RX_CTL is 0x%04x after all initializations\n", rx_ctl);
 
 	rx_ctl = asix_read_medium_status(dev);
-	debug("Medium Status is 0x%04x after all initializations", rx_ctl);
+	debug("Medium Status is 0x%04x after all initializations\n", rx_ctl);
 
 	/* Asix framing packs multiple eth frames into a 2K usb bulk transfer */
 	if (dev->driver_info->flags & FLAG_FRAMING_AX) {
-- 
1.7.10.4



From s.hauer at pengutronix.de  Thu Nov  1 03:55:43 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu,  1 Nov 2012 08:55:43 +0100
Subject: [PATCH 1/6] ARM OMAP4: Turn puts into debug
In-Reply-To: <1351756548-24640-1-git-send-email-s.hauer@pengutronix.de>
References: <1351756548-24640-1-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1351756548-24640-2-git-send-email-s.hauer@pengutronix.de>

When compiled with pbl support puts is not available, so turn it
into debug.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/arm/mach-omap/omap4_clock.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mach-omap/omap4_clock.c b/arch/arm/mach-omap/omap4_clock.c
index 1481f16..b489d59 100644
--- a/arch/arm/mach-omap/omap4_clock.c
+++ b/arch/arm/mach-omap/omap4_clock.c
@@ -410,5 +410,5 @@ void omap4_do_scale_tps62361(u32 reg, u32 volt_mv)
 	writel(temp, OMAP44XX_PRM_VC_VAL_BYPASS);
 	if (!wait_on_value(OMAP44XX_PRM_VC_VAL_BYPASS_VALID_BIT, 0,
 				OMAP44XX_PRM_VC_VAL_BYPASS, LDELAY))
-		puts("Scaling voltage failed for vdd_mpu from TPS\n");
+		debug("Scaling voltage failed for vdd_mpu from TPS\n");
 }
-- 
1.7.10.4



From s.hauer at pengutronix.de  Thu Nov  1 03:55:48 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu,  1 Nov 2012 08:55:48 +0100
Subject: [PATCH 6/6] ARM OMAP3: Put reset() into its own section
In-Reply-To: <1351756548-24640-1-git-send-email-s.hauer@pengutronix.de>
References: <1351756548-24640-1-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1351756548-24640-7-git-send-email-s.hauer@pengutronix.de>

Needed so that the linker can throw it away when unused. This is needed
at least on current master for being able to enable pbl support for omap3
boards.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/arm/mach-omap/omap3_core.S |    1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/mach-omap/omap3_core.S b/arch/arm/mach-omap/omap3_core.S
index df7c5b4..c3e4086 100644
--- a/arch/arm/mach-omap/omap3_core.S
+++ b/arch/arm/mach-omap/omap3_core.S
@@ -39,6 +39,7 @@
 #include <asm/barebox-arm-head.h>
 
 #ifdef CONFIG_MACH_DO_LOWLEVEL_INIT
+.section .text.__reset
 ENTRY(reset)
 	/* Invalidate all Dcaches */
 #ifndef CONFIG_CPU_V7_DCACHE_SKIP
-- 
1.7.10.4



From s.hauer at pengutronix.de  Thu Nov  1 03:55:45 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu,  1 Nov 2012 08:55:45 +0100
Subject: [PATCH 3/6] ARM OMAP4 panda xload: Enable MMU and Thumb2 support
In-Reply-To: <1351756548-24640-1-git-send-email-s.hauer@pengutronix.de>
References: <1351756548-24640-1-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1351756548-24640-4-git-send-email-s.hauer@pengutronix.de>

MMU for the speed and Thumb2 for the size.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/arm/configs/panda_xload_defconfig |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/arm/configs/panda_xload_defconfig b/arch/arm/configs/panda_xload_defconfig
index f8f0ae9..fec09ce 100644
--- a/arch/arm/configs/panda_xload_defconfig
+++ b/arch/arm/configs/panda_xload_defconfig
@@ -2,8 +2,9 @@ CONFIG_ARCH_OMAP=y
 CONFIG_ARCH_OMAP4=y
 # CONFIG_OMAP_GPMC is not set
 CONFIG_OMAP_BUILD_IFT=y
-CONFIG_AEABI=y
+CONFIG_THUMB2_BAREBOX=y
 # CONFIG_CMD_ARM_CPUINFO is not set
+CONFIG_MMU=y
 CONFIG_TEXT_BASE=0x40300000
 CONFIG_MEMORY_LAYOUT_FIXED=y
 CONFIG_STACK_BASE=0x8f000000
@@ -14,9 +15,7 @@ CONFIG_SHELL_NONE=y
 # CONFIG_ERRNO_MESSAGES is not set
 # CONFIG_TIMESTAMP is not set
 # CONFIG_CONSOLE_FULL is not set
-CONFIG_PARTITION=y
 # CONFIG_DEFAULT_ENVIRONMENT is not set
-# CONFIG_COMMAND_SUPPORT is not set
 CONFIG_DRIVER_SERIAL_NS16550=y
 CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS=y
 # CONFIG_SPI is not set
-- 
1.7.10.4



From s.hauer at pengutronix.de  Thu Nov  1 03:55:47 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu,  1 Nov 2012 08:55:47 +0100
Subject: [PATCH 5/6] ARM OMAP3 boards: Call omap3_core_init only from SRAM
In-Reply-To: <1351756548-24640-1-git-send-email-s.hauer@pengutronix.de>
References: <1351756548-24640-1-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1351756548-24640-6-git-send-email-s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/arm/boards/beagle/board.c          |    3 ++-
 arch/arm/boards/omap343xdsp/board.c     |    3 ++-
 arch/arm/boards/phycard-a-l1/pca-a-l1.c |    3 ++-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/arch/arm/boards/beagle/board.c b/arch/arm/boards/beagle/board.c
index 19bf740..ec26528 100644
--- a/arch/arm/boards/beagle/board.c
+++ b/arch/arm/boards/beagle/board.c
@@ -220,7 +220,8 @@ static int beagle_board_init(void)
 {
 	int in_sdram = running_in_sdram();
 
-	omap3_core_init();
+	if (!in_sdram)
+		omap3_core_init();
 
 	mux_config();
 	/* Dont reconfigure SDRAM while running in SDRAM! */
diff --git a/arch/arm/boards/omap343xdsp/board.c b/arch/arm/boards/omap343xdsp/board.c
index 2343dc0..692cf9a 100644
--- a/arch/arm/boards/omap343xdsp/board.c
+++ b/arch/arm/boards/omap343xdsp/board.c
@@ -76,7 +76,8 @@ static int sdp343x_board_init(void)
 {
 	int in_sdram = running_in_sdram();
 
-	omap3_core_init();
+	if (!in_sdram)
+		omap3_core_init();
 
 	mux_config();
 	if (!in_sdram)
diff --git a/arch/arm/boards/phycard-a-l1/pca-a-l1.c b/arch/arm/boards/phycard-a-l1/pca-a-l1.c
index f2d10f2..6652242 100644
--- a/arch/arm/boards/phycard-a-l1/pca-a-l1.c
+++ b/arch/arm/boards/phycard-a-l1/pca-a-l1.c
@@ -297,7 +297,8 @@ static int pcaal1_board_init(void)
 {
 	int in_sdram = running_in_sdram();
 
-	omap3_core_init();
+	if (!in_sdram)
+		omap3_core_init();
 
 	pcaal1_mux_config();
 	/* Dont reconfigure SDRAM while running in SDRAM! */
-- 
1.7.10.4



From s.hauer at pengutronix.de  Thu Nov  1 03:55:46 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu,  1 Nov 2012 08:55:46 +0100
Subject: [PATCH 4/6] ARM OMAP3 beagle: switch to new environment
In-Reply-To: <1351756548-24640-1-git-send-email-s.hauer@pengutronix.de>
References: <1351756548-24640-1-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1351756548-24640-5-git-send-email-s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/arm/boards/beagle/env/boot/mmc              |   10 +++++
 arch/arm/boards/beagle/env/init/bootargs-base    |    8 ++++
 arch/arm/boards/beagle/env/init/hostname         |    8 ++++
 arch/arm/boards/beagle/env/network/eth0-discover |    5 +++
 arch/arm/configs/omap3530_beagle_defconfig       |   49 ++++++++++++++++------
 arch/arm/mach-omap/Kconfig                       |    1 +
 6 files changed, 69 insertions(+), 12 deletions(-)
 create mode 100644 arch/arm/boards/beagle/env/boot/mmc
 create mode 100644 arch/arm/boards/beagle/env/init/bootargs-base
 create mode 100644 arch/arm/boards/beagle/env/init/hostname
 create mode 100644 arch/arm/boards/beagle/env/network/eth0-discover

diff --git a/arch/arm/boards/beagle/env/boot/mmc b/arch/arm/boards/beagle/env/boot/mmc
new file mode 100644
index 0000000..58bd557
--- /dev/null
+++ b/arch/arm/boards/beagle/env/boot/mmc
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+	boot-menu-add-entry "$0" "MMC (ext3)"
+	exit
+fi
+
+global.bootm.image="/boot/zImage"
+#global.bootm.oftree="/boot/oftree"
+global.linux.bootargs.dyn.root="root=mmcblk0p2 rootfstype=ext3 rootwait"
diff --git a/arch/arm/boards/beagle/env/init/bootargs-base b/arch/arm/boards/beagle/env/init/bootargs-base
new file mode 100644
index 0000000..442cce3
--- /dev/null
+++ b/arch/arm/boards/beagle/env/init/bootargs-base
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+	init-menu-add-entry "$0" "Base bootargs"
+	exit
+fi
+
+global.linux.bootargs.base="console=ttyO2,115200"
diff --git a/arch/arm/boards/beagle/env/init/hostname b/arch/arm/boards/beagle/env/init/hostname
new file mode 100644
index 0000000..996c2d9
--- /dev/null
+++ b/arch/arm/boards/beagle/env/init/hostname
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+	init-menu-add-entry "$0" "hostname"
+	exit
+fi
+
+global.hostname=panda
diff --git a/arch/arm/boards/beagle/env/network/eth0-discover b/arch/arm/boards/beagle/env/network/eth0-discover
new file mode 100644
index 0000000..77552d3
--- /dev/null
+++ b/arch/arm/boards/beagle/env/network/eth0-discover
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+# Panda has a network adapter on USB
+
+usb
diff --git a/arch/arm/configs/omap3530_beagle_defconfig b/arch/arm/configs/omap3530_beagle_defconfig
index 0d83a4f..1807e04 100644
--- a/arch/arm/configs/omap3530_beagle_defconfig
+++ b/arch/arm/configs/omap3530_beagle_defconfig
@@ -1,44 +1,67 @@
 CONFIG_ARCH_OMAP=y
-# CONFIG_OMAP3_COPY_CLOCK_SRAM is not set
 CONFIG_MACH_BEAGLE=y
-CONFIG_AEABI=y
+CONFIG_THUMB2_BAREBOX=y
+CONFIG_CMD_ARM_MMUINFO=y
 CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y
 CONFIG_ARM_UNWIND=y
-CONFIG_TEXT_BASE=0x81000000
+CONFIG_PBL_IMAGE=y
+CONFIG_MMU=y
+CONFIG_TEXT_BASE=0x87e00000
+CONFIG_MALLOC_SIZE=0x2000000
+CONFIG_MALLOC_TLSF=y
+CONFIG_KALLSYMS=y
 CONFIG_PROMPT="barebox> "
 CONFIG_LONGHELP=y
-CONFIG_GLOB=y
 CONFIG_HUSH_FANCY_PROMPT=y
-CONFIG_HUSH_GETOPT=y
 CONFIG_CMDLINE_EDITING=y
 CONFIG_AUTO_COMPLETE=y
-# CONFIG_TIMESTAMP is not set
-CONFIG_PARTITION=y
-CONFIG_DEFAULT_ENVIRONMENT_GENERIC=y
+CONFIG_MENU=y
+CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y
+CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/arm/boards/beagle/env"
 CONFIG_CMD_EDIT=y
 CONFIG_CMD_SLEEP=y
+CONFIG_CMD_MSLEEP=y
 CONFIG_CMD_SAVEENV=y
-CONFIG_CMD_LOADENV=y
 CONFIG_CMD_EXPORT=y
 CONFIG_CMD_PRINTENV=y
 CONFIG_CMD_READLINE=y
+CONFIG_CMD_MENU=y
+CONFIG_CMD_MENU_MANAGEMENT=y
+CONFIG_CMD_TIME=y
+CONFIG_CMD_DIRNAME=y
+CONFIG_CMD_LN=y
+CONFIG_CMD_READLINK=y
+CONFIG_CMD_TFTP=y
 CONFIG_CMD_ECHO_E=y
 CONFIG_CMD_LOADB=y
+CONFIG_CMD_MEMINFO=y
+CONFIG_CMD_IOMEM=y
+CONFIG_CMD_CRC=y
+CONFIG_CMD_CRC_CMP=y
+CONFIG_CMD_MD5SUM=y
 CONFIG_CMD_FLASH=y
-# CONFIG_CMD_BOOTM is not set
+CONFIG_CMD_BOOTM_SHOW_TYPE=y
+CONFIG_CMD_BOOTM_VERBOSE=y
+CONFIG_CMD_BOOTM_INITRD=y
+CONFIG_CMD_BOOTM_OFTREE=y
+CONFIG_CMD_BOOTM_OFTREE_UIMAGE=y
+# CONFIG_CMD_BOOTU is not set
 CONFIG_CMD_RESET=y
 CONFIG_CMD_GO=y
 CONFIG_CMD_TIMEOUT=y
 CONFIG_CMD_PARTITION=y
+CONFIG_CMD_MAGICVAR=y
+CONFIG_CMD_MAGICVAR_HELP=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_UNCOMPRESS=y
 CONFIG_CMD_I2C=y
+CONFIG_CMD_MIITOOL=y
 CONFIG_NET=y
 CONFIG_NET_DHCP=y
 CONFIG_NET_NFS=y
 CONFIG_NET_PING=y
-CONFIG_CMD_TFTP=y
-CONFIG_FS_TFTP=y
+CONFIG_NET_NETCONSOLE=y
+CONFIG_NET_RESOLV=y
 CONFIG_DRIVER_SERIAL_NS16550=y
 CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS=y
 CONFIG_NET_USB=y
@@ -58,6 +81,8 @@ CONFIG_MCI=y
 CONFIG_MCI_STARTUP=y
 CONFIG_MCI_OMAP_HSMMC=y
 CONFIG_I2C_TWL4030=y
+CONFIG_FS_TFTP=y
+CONFIG_FS_NFS=y
 CONFIG_FS_FAT=y
 CONFIG_FS_FAT_WRITE=y
 CONFIG_FS_FAT_LFN=y
diff --git a/arch/arm/mach-omap/Kconfig b/arch/arm/mach-omap/Kconfig
index c4a88ab..3315d1c 100644
--- a/arch/arm/mach-omap/Kconfig
+++ b/arch/arm/mach-omap/Kconfig
@@ -103,6 +103,7 @@ config MACH_OMAP343xSDP
 config MACH_BEAGLE
 	bool "Texas Instrument's Beagle Board"
 	select HAVE_NOSHELL
+	select HAVE_DEFAULT_ENVIRONMENT_NEW
 	depends on ARCH_OMAP3
 	  help
 	  Say Y here if you are using Beagle Board
-- 
1.7.10.4



From s.hauer at pengutronix.de  Thu Nov  1 03:55:44 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu,  1 Nov 2012 08:55:44 +0100
Subject: [PATCH 2/6] ARM OMAP4 panda: switch to new environment
In-Reply-To: <1351756548-24640-1-git-send-email-s.hauer@pengutronix.de>
References: <1351756548-24640-1-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1351756548-24640-3-git-send-email-s.hauer@pengutronix.de>

Switch to new environment and add the bootscripts needed for mmc. Also,
update defconfig for new environment.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/arm/boards/panda/env/boot/mmc              |   10 ++++++
 arch/arm/boards/panda/env/config                |   40 -----------------------
 arch/arm/boards/panda/env/init/bootargs-base    |    8 +++++
 arch/arm/boards/panda/env/init/hostname         |    8 +++++
 arch/arm/boards/panda/env/network/eth0-discover |    5 +++
 arch/arm/configs/panda_defconfig                |   34 ++++++++++++++-----
 arch/arm/mach-omap/Kconfig                      |    1 +
 7 files changed, 58 insertions(+), 48 deletions(-)
 create mode 100644 arch/arm/boards/panda/env/boot/mmc
 delete mode 100644 arch/arm/boards/panda/env/config
 create mode 100644 arch/arm/boards/panda/env/init/bootargs-base
 create mode 100644 arch/arm/boards/panda/env/init/hostname
 create mode 100644 arch/arm/boards/panda/env/network/eth0-discover

diff --git a/arch/arm/boards/panda/env/boot/mmc b/arch/arm/boards/panda/env/boot/mmc
new file mode 100644
index 0000000..58bd557
--- /dev/null
+++ b/arch/arm/boards/panda/env/boot/mmc
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+	boot-menu-add-entry "$0" "MMC (ext3)"
+	exit
+fi
+
+global.bootm.image="/boot/zImage"
+#global.bootm.oftree="/boot/oftree"
+global.linux.bootargs.dyn.root="root=mmcblk0p2 rootfstype=ext3 rootwait"
diff --git a/arch/arm/boards/panda/env/config b/arch/arm/boards/panda/env/config
deleted file mode 100644
index 1cd7eaa..0000000
--- a/arch/arm/boards/panda/env/config
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/bin/sh
-
-global.hostname=panda
-user=
-
-# use 'dhcp' to do dhcp in barebox and in kernel
-# use 'none' if you want to skip kernel ip autoconfiguration
-ip=dhcp
-
-# or set your networking parameters here
-#eth0.ipaddr=a.b.c.d
-#eth0.netmask=a.b.c.d
-#eth0.gateway=a.b.c.d
-#eth0.serverip=a.b.c.d
-
-# can be either 'nfs', 'tftp', 'nor' or 'nand'
-kernel_loc=tftp
-# can be either 'net', 'nor', 'nand' or 'initrd'
-rootfs_loc=net
-
-kernelimage=zImage-${global.hostname}
-#kernelimage=uImage-${global.hostname}
-#kernelimage=Image-${global.hostname}
-#kernelimage=Image-${global.hostname}.lzo
-
-if [ -n $user ]; then
-	kernelimage="$user"-"$kernelimage"
-	nfsroot="$eth0.serverip:/home/$user/nfsroot/${global.hostname}"
-	rootfsimage="$user"-"$rootfsimage"
-else
-	nfsroot="$eth0.serverip:/path/to/nfs/root"
-fi
-
-autoboot_timeout=3
-
-bootargs="console=ttyO2,115200"
-
-# set a fancy prompt (if support is compiled in)
-PS1="\e[1;32mbarebox@\e[1;31m\h:\w\e[0m "
-
diff --git a/arch/arm/boards/panda/env/init/bootargs-base b/arch/arm/boards/panda/env/init/bootargs-base
new file mode 100644
index 0000000..442cce3
--- /dev/null
+++ b/arch/arm/boards/panda/env/init/bootargs-base
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+	init-menu-add-entry "$0" "Base bootargs"
+	exit
+fi
+
+global.linux.bootargs.base="console=ttyO2,115200"
diff --git a/arch/arm/boards/panda/env/init/hostname b/arch/arm/boards/panda/env/init/hostname
new file mode 100644
index 0000000..996c2d9
--- /dev/null
+++ b/arch/arm/boards/panda/env/init/hostname
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+	init-menu-add-entry "$0" "hostname"
+	exit
+fi
+
+global.hostname=panda
diff --git a/arch/arm/boards/panda/env/network/eth0-discover b/arch/arm/boards/panda/env/network/eth0-discover
new file mode 100644
index 0000000..77552d3
--- /dev/null
+++ b/arch/arm/boards/panda/env/network/eth0-discover
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+# Panda has a network adapter on USB
+
+usb
diff --git a/arch/arm/configs/panda_defconfig b/arch/arm/configs/panda_defconfig
index 5f53ff9..7be86ac 100644
--- a/arch/arm/configs/panda_defconfig
+++ b/arch/arm/configs/panda_defconfig
@@ -1,38 +1,51 @@
 CONFIG_ARCH_OMAP=y
 CONFIG_ARCH_OMAP4=y
-CONFIG_AEABI=y
+CONFIG_THUMB2_BAREBOX=y
+CONFIG_CMD_ARM_MMUINFO=y
 CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y
 CONFIG_ARM_UNWIND=y
+CONFIG_PBL_IMAGE=y
 CONFIG_MMU=y
 CONFIG_TEXT_BASE=0x8f000000
 CONFIG_MALLOC_SIZE=0x2000000
+CONFIG_MALLOC_TLSF=y
 CONFIG_KALLSYMS=y
 CONFIG_PROMPT="barebox> "
 CONFIG_LONGHELP=y
-CONFIG_GLOB=y
 CONFIG_HUSH_FANCY_PROMPT=y
 CONFIG_CMDLINE_EDITING=y
 CONFIG_AUTO_COMPLETE=y
+CONFIG_MENU=y
 # CONFIG_TIMESTAMP is not set
-CONFIG_DEFAULT_ENVIRONMENT_GENERIC=y
+CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y
 CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/arm/boards/panda/env"
 CONFIG_CMD_EDIT=y
 CONFIG_CMD_SLEEP=y
+CONFIG_CMD_MSLEEP=y
 CONFIG_CMD_SAVEENV=y
 CONFIG_CMD_EXPORT=y
 CONFIG_CMD_PRINTENV=y
 CONFIG_CMD_READLINE=y
+CONFIG_CMD_MENU=y
+CONFIG_CMD_MENU_MANAGEMENT=y
 CONFIG_CMD_TIME=y
+CONFIG_CMD_DIRNAME=y
+CONFIG_CMD_LN=y
+CONFIG_CMD_READLINK=y
+CONFIG_CMD_TFTP=y
 CONFIG_CMD_ECHO_E=y
-CONFIG_CMD_LOADB=y
+CONFIG_CMD_MEMINFO=y
 CONFIG_CMD_IOMEM=y
+CONFIG_CMD_CRC=y
+CONFIG_CMD_CRC_CMP=y
+CONFIG_CMD_MD5SUM=y
 CONFIG_CMD_FLASH=y
 CONFIG_CMD_BOOTM_SHOW_TYPE=y
 CONFIG_CMD_BOOTM_VERBOSE=y
 CONFIG_CMD_BOOTM_INITRD=y
 CONFIG_CMD_BOOTM_OFTREE=y
 CONFIG_CMD_BOOTM_OFTREE_UIMAGE=y
-# CONFIG_CMD_BOOTZ is not set
+CONFIG_CMD_UIMAGE=y
 # CONFIG_CMD_BOOTU is not set
 CONFIG_CMD_RESET=y
 CONFIG_CMD_GO=y
@@ -44,12 +57,13 @@ CONFIG_CMD_GPIO=y
 CONFIG_CMD_UNCOMPRESS=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_LED=y
+CONFIG_CMD_LED_TRIGGER=y
+CONFIG_CMD_MIITOOL=y
 CONFIG_NET=y
 CONFIG_NET_DHCP=y
-CONFIG_NET_NFS=y
 CONFIG_NET_PING=y
-CONFIG_CMD_TFTP=y
-CONFIG_FS_TFTP=y
+CONFIG_NET_NETCONSOLE=y
+CONFIG_NET_RESOLV=y
 CONFIG_DRIVER_SERIAL_NS16550=y
 CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS=y
 CONFIG_NET_USB=y
@@ -65,6 +79,10 @@ CONFIG_MCI_OMAP_HSMMC=y
 CONFIG_LED=y
 CONFIG_LED_GPIO=y
 CONFIG_LED_TRIGGERS=y
+CONFIG_FS_TFTP=y
+CONFIG_FS_NFS=y
 CONFIG_FS_FAT=y
 CONFIG_FS_FAT_WRITE=y
 CONFIG_FS_FAT_LFN=y
+CONFIG_ZLIB=y
+CONFIG_LZO_DECOMPRESS=y
diff --git a/arch/arm/mach-omap/Kconfig b/arch/arm/mach-omap/Kconfig
index aa31633..c4a88ab 100644
--- a/arch/arm/mach-omap/Kconfig
+++ b/arch/arm/mach-omap/Kconfig
@@ -118,6 +118,7 @@ config MACH_PANDA
 	bool "Texas Instrument's Panda Board"
 	select HAVE_NOSHELL
 	select MACH_HAS_LOWLEVEL_INIT
+	select HAVE_DEFAULT_ENVIRONMENT_NEW
 	depends on ARCH_OMAP4
 	help
 	  Say Y here if you are using OMAP4 Panda board
-- 
1.7.10.4



From s.hauer at pengutronix.de  Thu Nov  1 03:55:42 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu,  1 Nov 2012 08:55:42 +0100
Subject: [PATCH] panda and beagle update
Message-ID: <1351756548-24640-1-git-send-email-s.hauer@pengutronix.de>

The following puts some efforts into the OMAP3/4 beagle and panda
boards. The boards are switched to the new environment, MMU is enabled,
Thumb2 and compilation of OMAP3 boards with PBL enabled is fixed.

----------------------------------------------------------------
Sascha Hauer (6):
      ARM OMAP4: Turn puts into debug
      ARM OMAP4 panda: switch to new environment
      ARM OMAP4 panda xload: Enable MMU and Thumb2 support
      ARM OMAP3 beagle: switch to new environment
      ARM OMAP3 boards: Call omap3_core_init only from SRAM
      ARM OMAP3: Put reset() into its own section

 arch/arm/boards/beagle/board.c                   |    3 +-
 arch/arm/boards/beagle/env/boot/mmc              |   10 +++++
 arch/arm/boards/beagle/env/init/bootargs-base    |    8 ++++
 arch/arm/boards/beagle/env/init/hostname         |    8 ++++
 arch/arm/boards/beagle/env/network/eth0-discover |    5 +++
 arch/arm/boards/omap343xdsp/board.c              |    3 +-
 arch/arm/boards/panda/env/boot/mmc               |   10 +++++
 arch/arm/boards/panda/env/config                 |   40 ------------------
 arch/arm/boards/panda/env/init/bootargs-base     |    8 ++++
 arch/arm/boards/panda/env/init/hostname          |    8 ++++
 arch/arm/boards/panda/env/network/eth0-discover  |    5 +++
 arch/arm/boards/phycard-a-l1/pca-a-l1.c          |    3 +-
 arch/arm/configs/omap3530_beagle_defconfig       |   49 ++++++++++++++++------
 arch/arm/configs/panda_defconfig                 |   34 +++++++++++----
 arch/arm/configs/panda_xload_defconfig           |    5 +--
 arch/arm/mach-omap/Kconfig                       |    2 +
 arch/arm/mach-omap/omap3_core.S                  |    1 +
 arch/arm/mach-omap/omap4_clock.c                 |    2 +-
 18 files changed, 137 insertions(+), 67 deletions(-)
 create mode 100644 arch/arm/boards/beagle/env/boot/mmc
 create mode 100644 arch/arm/boards/beagle/env/init/bootargs-base
 create mode 100644 arch/arm/boards/beagle/env/init/hostname
 create mode 100644 arch/arm/boards/beagle/env/network/eth0-discover
 create mode 100644 arch/arm/boards/panda/env/boot/mmc
 delete mode 100644 arch/arm/boards/panda/env/config
 create mode 100644 arch/arm/boards/panda/env/init/bootargs-base
 create mode 100644 arch/arm/boards/panda/env/init/hostname
 create mode 100644 arch/arm/boards/panda/env/network/eth0-discover


From bogus@does.not.exist.com  Thu Nov  1 05:16:55 2012
From: bogus@does.not.exist.com ()
Date: Thu,  1 Nov 2012 10:16:55 +0100
Subject: [PATCH 1/1] mtd: dataflash: fix spi_transfer init
Message-ID: <1351761415-3199-1-git-send-email-plagnioj@jcrosoft.com>

From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>

on some system as the spi_transfer is not set to 0 if the rx_buf or tx_buf
are not used they are not set to NULL

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/mtd/devices/mtd_dataflash.c |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/mtd/devices/mtd_dataflash.c b/drivers/mtd/devices/mtd_dataflash.c
index cbed15b..3b7b9c6 100644
--- a/drivers/mtd/devices/mtd_dataflash.c
+++ b/drivers/mtd/devices/mtd_dataflash.c
@@ -161,6 +161,8 @@ static int dataflash_erase(struct mtd_info *mtd, struct erase_info *instr)
 
 	spi_message_init(&msg);
 
+	memset(&x, 0, sizeof(x));
+
 	x.tx_buf = command = priv->command;
 	x.len = 4;
 	spi_message_add_tail(&x, &msg);
@@ -246,6 +248,8 @@ static int dataflash_read(struct mtd_info *mtd, loff_t from, size_t len,
 
 	spi_message_init(&msg);
 
+	memset(&x[0], 0, sizeof(struct spi_transfer) * 2);
+
 	x[0].tx_buf = command;
 	x[0].len = 8;
 	spi_message_add_tail(&x[0], &msg);
@@ -302,6 +306,8 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len,
 
 	spi_message_init(&msg);
 
+	memset(&x[0], 0, sizeof(struct spi_transfer) * 2);
+
 	x[0].tx_buf = command = priv->command;
 	x[0].len = 4;
 	spi_message_add_tail(&x[0], &msg);
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Thu Nov  1 05:32:05 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu, 1 Nov 2012 10:32:05 +0100
Subject: [PATCH 0/2] m25p80: re-import it againt mtd_add_host
In-Reply-To: <20121031212902.GQ1641@pengutronix.de>
References: <20121031120122.GF29599@game.jcrosoft.org>
 <20121031212902.GQ1641@pengutronix.de>
Message-ID: <20121101093205.GH29599@game.jcrosoft.org>

On 22:29 Wed 31 Oct     , Sascha Hauer wrote:
> On Wed, Oct 31, 2012 at 01:01:22PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > Hi,
> > 
> > 	so we now create the cdev via mtd
> > 
> > 	This will also simplify sync with linux
> > 
> > 	to avoid the m25p8000 or m25p00 the cdev is still named name m25p and the
> > 	drivers m25p80
> > 
> > 	sync with linux too
> > 
> > 	this patch series is agianst mtd_dataflash support
> > 
> > The following changes since commit 9428c386f876fa3a8871eeea4725a805cea5c367:
> > 
> >   mtd: add dataflash support (2012-10-31 04:48:39 +0800)
> > 
> > are available in the git repository at:
> > 
> >   git://git.jcrosoft.org/barebox.git delivery/m25p80
> 
> Sometimes I get the feeling that you do this only to break other peoples
> setup:
I forget to include a fix from my next

I send it and re pushed the brnach

The following changes since commit 9bd9176fdafac1566107da3f3a0ed55094907d91:

  mtd: dataflash: fix spi_transfer init (2012-11-01 02:22:22 +0800)

are available in the git repository at:

  git://git.jcrosoft.org/barebox.git delivery/m25p80

for you to fetch changes up to 3b672b01bb8bba0c61886bdcb85b70009673372d:

  m25p80: sync flash support with the kernel (2012-11-01 02:22:28 +0800)

----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (3):
      mtd: introduce mtd_block_isbad
      m25p80: re-import it againt mtd_add_host
      m25p80: sync flash support with the kernel

 arch/arm/boards/freescale-mx6-sabrelite/board.c |    2 +-
 drivers/mtd/core.c                              |   13 +++++-
 drivers/mtd/devices/Kconfig                     |   27 ++++++++++++
 drivers/mtd/devices/Makefile                    |    1 +
 drivers/{nor => mtd/devices}/m25p80.c           |  512 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------------
 drivers/mtd/mtdraw.c                            |    2 +-
 drivers/mtd/partition.c                         |    2 +-
 drivers/mtd/ubi/io.c                            |    2 +-
 drivers/nor/Kconfig                             |   27 ------------
 drivers/nor/Makefile                            |    1 -
 drivers/nor/m25p80.h                            |   84 ------------------------------------
 include/linux/mtd/cfi.h                         |   65 ++++++++++++++++++++++++++++
 include/linux/mtd/mtd.h                         |    2 +
 13 files changed, 387 insertions(+), 353 deletions(-)
 rename drivers/{nor => mtd/devices}/m25p80.c (65%)
 delete mode 100644 drivers/nor/m25p80.h
 create mode 100644 include/linux/mtd/cfi.h

Best Regards,
J.


From plagnioj at jcrosoft.com  Thu Nov  1 05:33:14 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu,  1 Nov 2012 10:33:14 +0100
Subject: [PATCH 1/1] mtd: introduce mtd_block_isbad
In-Reply-To: <20121031120122.GF29599@game.jcrosoft.org>
References: <20121031120122.GF29599@game.jcrosoft.org>
Message-ID: <1351762394-4597-1-git-send-email-plagnioj@jcrosoft.com>

this allow to do not provide block_isbad at mtd driver level
as example spi flash

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/mtd/core.c      |   13 +++++++++++--
 drivers/mtd/mtdraw.c    |    2 +-
 drivers/mtd/partition.c |    2 +-
 drivers/mtd/ubi/io.c    |    2 +-
 include/linux/mtd/mtd.h |    2 ++
 5 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/mtd/core.c b/drivers/mtd/core.c
index 7c323a1..0139851 100644
--- a/drivers/mtd/core.c
+++ b/drivers/mtd/core.c
@@ -30,6 +30,15 @@
 
 static LIST_HEAD(mtd_register_hooks);
 
+int mtd_block_isbad(struct mtd_info *mtd, loff_t ofs)
+{
+	if (!mtd->block_isbad)
+		return 0;
+	if (ofs < 0 || ofs > mtd->size)
+		return -EINVAL;
+	return mtd->block_isbad(mtd, ofs);
+}
+
 static 	ssize_t mtd_read(struct cdev *cdev, void* buf, size_t count,
 			  loff_t _offset, ulong flags)
 {
@@ -130,7 +139,7 @@ int mtd_ioctl(struct cdev *cdev, int request, void *buf)
 	switch (request) {
 	case MEMGETBADBLOCK:
 		dev_dbg(cdev->dev, "MEMGETBADBLOCK: 0x%08llx\n", *offset);
-		ret = mtd->block_isbad(mtd, *offset);
+		ret = mtd_block_isbad(mtd, *offset);
 		break;
 #ifdef CONFIG_MTD_WRITE
 	case MEMSETBADBLOCK:
@@ -189,7 +198,7 @@ static int mtd_erase(struct cdev *cdev, size_t count, loff_t offset)
 	while (count > 0) {
 		dev_dbg(cdev->dev, "erase %d %d\n", erase.addr, erase.len);
 
-		ret = mtd->block_isbad(mtd, erase.addr);
+		ret = mtd_block_isbad(mtd, erase.addr);
 		if (ret > 0) {
 			printf("Skipping bad block at 0x%08x\n", erase.addr);
 		} else {
diff --git a/drivers/mtd/mtdraw.c b/drivers/mtd/mtdraw.c
index 079575c..ec77692 100644
--- a/drivers/mtd/mtdraw.c
+++ b/drivers/mtd/mtdraw.c
@@ -241,7 +241,7 @@ static int mtdraw_erase(struct cdev *cdev, size_t count, loff_t _offset)
 	while (count > 0) {
 		debug("erase %d %d\n", erase.addr, erase.len);
 
-		ret = mtd->block_isbad(mtd, erase.addr);
+		ret = mtd_block_isbad(mtd, erase.addr);
 		if (ret > 0) {
 			printf("Skipping bad block at 0x%08x\n", erase.addr);
 		} else {
diff --git a/drivers/mtd/partition.c b/drivers/mtd/partition.c
index df2eb40..85f486d 100644
--- a/drivers/mtd/partition.c
+++ b/drivers/mtd/partition.c
@@ -71,7 +71,7 @@ static int mtd_part_block_isbad(struct mtd_info *mtd, loff_t ofs)
 	if (ofs >= mtd->size)
 		return -EINVAL;
 	ofs += part->offset;
-	return part->master->block_isbad(part->master, ofs);
+	return mtd_block_isbad(part->master, ofs);
 }
 
 static int mtd_part_block_markbad(struct mtd_info *mtd, loff_t ofs)
diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
index da38837..e3598b9 100644
--- a/drivers/mtd/ubi/io.c
+++ b/drivers/mtd/ubi/io.c
@@ -513,7 +513,7 @@ int ubi_io_is_bad(const struct ubi_device *ubi, int pnum)
 	if (ubi->bad_allowed) {
 		int ret;
 
-		ret = mtd->block_isbad(mtd, (loff_t)pnum * ubi->peb_size);
+		ret = mtd_block_isbad(mtd, (loff_t)pnum * ubi->peb_size);
 		if (ret < 0)
 			ubi_err("error %d while checking if PEB %d is bad",
 				ret, pnum);
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index 71d3c6f..5db884c 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -251,6 +251,8 @@ static inline void mtd_erase_callback(struct erase_info *instr)
 }
 #endif
 
+int mtd_block_isbad(struct mtd_info *mtd, loff_t ofs);
+
 /*
  * Debugging macro and defines
  */
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Thu Nov  1 05:42:16 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu, 1 Nov 2012 10:42:16 +0100
Subject: [PATCH 0/4] i2c: add algo-bit support with gpio and versatile support
Message-ID: <20121101094216.GI29599@game.jcrosoft.org>

HI,

	the foloing patch series add the i2c algo bit support with 2 drivers
	that use it

	 - gpio
	 - versatile

	 thie also create a device for i2c bus itself

The following changes since commit 2d1ceaff2f905f4a2bd7e6c539e7dd3d8d8e9bef:

  uimage: Fix deleting of temporary file (2012-10-30 18:39:38 +0100)

are available in the git repository at:

  git://git.jcrosoft.org/barebox.git delivery/i2c

for you to fetch changes up to d56fd9fa4f6872c2ce109fb25e8a48110750320b:

  i2c: add versatile support (2012-11-01 02:28:11 +0800)

----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (4):
      i2c: adapter: register it's own device
      i2c: add i2c algo bit support
      i2c: add i2c-gpio support
      i2c: add versatile support

 drivers/i2c/Kconfig                |    1 +
 drivers/i2c/Makefile               |    2 +-
 drivers/i2c/algos/Kconfig          |    6 +++
 drivers/i2c/algos/Makefile         |    5 ++
 drivers/i2c/algos/i2c-algo-bit.c   |  585 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/i2c/busses/Kconfig         |   16 +++++++
 drivers/i2c/busses/Makefile        |    2 +
 drivers/i2c/busses/i2c-gpio.c      |  177 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/i2c/busses/i2c-imx.c       |   20 ++++----
 drivers/i2c/busses/i2c-omap.c      |   30 ++++++------
 drivers/i2c/busses/i2c-versatile.c |  112 +++++++++++++++++++++++++++++++++++++++++++++
 drivers/i2c/i2c.c                  |   18 ++++++--
 include/i2c/i2c-algo-bit.h         |   55 ++++++++++++++++++++++
 include/i2c/i2c-gpio.h             |   38 +++++++++++++++
 include/i2c/i2c.h                  |    4 +-
 15 files changed, 1041 insertions(+), 30 deletions(-)
 create mode 100644 drivers/i2c/algos/Kconfig
 create mode 100644 drivers/i2c/algos/Makefile
 create mode 100644 drivers/i2c/algos/i2c-algo-bit.c
 create mode 100644 drivers/i2c/busses/i2c-gpio.c
 create mode 100644 drivers/i2c/busses/i2c-versatile.c
 create mode 100644 include/i2c/i2c-algo-bit.h
 create mode 100644 include/i2c/i2c-gpio.h

Best Regards,
J.


From plagnioj at jcrosoft.com  Thu Nov  1 05:44:51 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu,  1 Nov 2012 10:44:51 +0100
Subject: [PATCH 3/4] i2c: add i2c-gpio support
In-Reply-To: <1351763092-5781-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121101094216.GI29599@game.jcrosoft.org>
 <1351763092-5781-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1351763092-5781-3-git-send-email-plagnioj@jcrosoft.com>

Based on linux 3.7-rc2

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/i2c/busses/Kconfig    |    8 ++
 drivers/i2c/busses/Makefile   |    1 +
 drivers/i2c/busses/i2c-gpio.c |  177 +++++++++++++++++++++++++++++++++++++++++
 include/i2c/i2c-gpio.h        |   38 +++++++++
 4 files changed, 224 insertions(+)
 create mode 100644 drivers/i2c/busses/i2c-gpio.c
 create mode 100644 include/i2c/i2c-gpio.h

diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 3f998ea..17e33cb 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -4,6 +4,14 @@
 
 menu "I2C Hardware Bus support"
 
+config I2C_GPIO
+	tristate "GPIO-based bitbanging I2C"
+	depends on GENERIC_GPIO
+	select I2C_ALGOBIT
+	help
+	  This is a very simple bitbanging I2C driver utilizing the
+	  arch-neutral GPIO API to control the SCL and SDA lines.
+
 config I2C_IMX
 	bool "MPC85xx/i.MX I2C Master driver"
 	depends on (ARCH_IMX && !ARCH_IMX1) || ARCH_MPC85XX
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index e4c5125..18c7c46 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -1,2 +1,3 @@
+obj-$(CONFIG_I2C_GPIO)		+= i2c-gpio.o
 obj-$(CONFIG_I2C_IMX) += i2c-imx.o
 obj-$(CONFIG_I2C_OMAP) += i2c-omap.o
diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c
new file mode 100644
index 0000000..98ce2d5
--- /dev/null
+++ b/drivers/i2c/busses/i2c-gpio.c
@@ -0,0 +1,177 @@
+/*
+ * Bitbanging I2C bus driver using the GPIO API
+ *
+ * Copyright (C) 2007 Atmel Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <common.h>
+#include <driver.h>
+#include <i2c/i2c.h>
+#include <i2c/i2c-algo-bit.h>
+#include <i2c/i2c-gpio.h>
+#include <init.h>
+#include <gpio.h>
+
+struct i2c_gpio_private_data {
+	struct i2c_adapter adap;
+	struct i2c_algo_bit_data bit_data;
+	struct i2c_gpio_platform_data pdata;
+};
+
+/* Toggle SDA by changing the direction of the pin */
+static void i2c_gpio_setsda_dir(void *data, int state)
+{
+	struct i2c_gpio_platform_data *pdata = data;
+
+	if (state)
+		gpio_direction_input(pdata->sda_pin);
+	else
+		gpio_direction_output(pdata->sda_pin, 0);
+}
+
+/*
+ * Toggle SDA by changing the output value of the pin. This is only
+ * valid for pins configured as open drain (i.e. setting the value
+ * high effectively turns off the output driver.)
+ */
+static void i2c_gpio_setsda_val(void *data, int state)
+{
+	struct i2c_gpio_platform_data *pdata = data;
+
+	gpio_set_value(pdata->sda_pin, state);
+}
+
+/* Toggle SCL by changing the direction of the pin. */
+static void i2c_gpio_setscl_dir(void *data, int state)
+{
+	struct i2c_gpio_platform_data *pdata = data;
+
+	if (state)
+		gpio_direction_input(pdata->scl_pin);
+	else
+		gpio_direction_output(pdata->scl_pin, 0);
+}
+
+/*
+ * Toggle SCL by changing the output value of the pin. This is used
+ * for pins that are configured as open drain and for output-only
+ * pins. The latter case will break the i2c protocol, but it will
+ * often work in practice.
+ */
+static void i2c_gpio_setscl_val(void *data, int state)
+{
+	struct i2c_gpio_platform_data *pdata = data;
+
+	gpio_set_value(pdata->scl_pin, state);
+}
+
+static int i2c_gpio_getsda(void *data)
+{
+	struct i2c_gpio_platform_data *pdata = data;
+
+	return gpio_get_value(pdata->sda_pin);
+}
+
+static int i2c_gpio_getscl(void *data)
+{
+	struct i2c_gpio_platform_data *pdata = data;
+
+	return gpio_get_value(pdata->scl_pin);
+}
+
+static int i2c_gpio_probe(struct device_d *dev)
+{
+	struct i2c_gpio_private_data *priv;
+	struct i2c_gpio_platform_data *pdata;
+	struct i2c_algo_bit_data *bit_data;
+	struct i2c_adapter *adap;
+	int ret;
+
+	priv = xzalloc(sizeof(*priv));
+
+	adap = &priv->adap;
+	bit_data = &priv->bit_data;
+	pdata = &priv->pdata;
+
+	if (!dev->platform_data)
+		return -ENXIO;
+	memcpy(pdata, dev->platform_data, sizeof(*pdata));
+
+	ret = gpio_request(pdata->sda_pin, "sda");
+	if (ret)
+		goto err_request_sda;
+	ret = gpio_request(pdata->scl_pin, "scl");
+	if (ret)
+		goto err_request_scl;
+
+	if (pdata->sda_is_open_drain) {
+		gpio_direction_output(pdata->sda_pin, 1);
+		bit_data->setsda = i2c_gpio_setsda_val;
+	} else {
+		gpio_direction_input(pdata->sda_pin);
+		bit_data->setsda = i2c_gpio_setsda_dir;
+	}
+
+	if (pdata->scl_is_open_drain || pdata->scl_is_output_only) {
+		gpio_direction_output(pdata->scl_pin, 1);
+		bit_data->setscl = i2c_gpio_setscl_val;
+	} else {
+		gpio_direction_input(pdata->scl_pin);
+		bit_data->setscl = i2c_gpio_setscl_dir;
+	}
+
+	if (!pdata->scl_is_output_only)
+		bit_data->getscl = i2c_gpio_getscl;
+	bit_data->getsda = i2c_gpio_getsda;
+
+	if (pdata->udelay)
+		bit_data->udelay = pdata->udelay;
+	else if (pdata->scl_is_output_only)
+		bit_data->udelay = 50;			/* 10 kHz */
+	else
+		bit_data->udelay = 5;			/* 100 kHz */
+
+	if (pdata->timeout_ms)
+		bit_data->timeout_ms = pdata->timeout_ms;
+	else
+		bit_data->timeout_ms = 100;		/* 100 ms */
+
+	bit_data->data = pdata;
+
+	adap->algo_data = bit_data;
+	adap->dev.parent = dev;
+
+	adap->nr = dev->id;
+	ret = i2c_bit_add_numbered_bus(adap);
+	if (ret)
+		goto err_add_bus;
+
+	dev_info(dev, "using pins %u (SDA) and %u (SCL%s)\n",
+		 pdata->sda_pin, pdata->scl_pin,
+		 pdata->scl_is_output_only
+		 ? ", no clock stretching" : "");
+
+	return 0;
+
+err_add_bus:
+	gpio_free(pdata->scl_pin);
+err_request_scl:
+	gpio_free(pdata->sda_pin);
+err_request_sda:
+	return ret;
+}
+
+static struct driver_d i2c_gpio_driver = {
+	.name	= "i2c-gpio",
+	.probe	= i2c_gpio_probe,
+};
+
+static int __init i2c_gpio_init(void)
+{
+	return platform_driver_register(&i2c_gpio_driver);
+}
+device_initcall(i2c_gpio_init);
diff --git a/include/i2c/i2c-gpio.h b/include/i2c/i2c-gpio.h
new file mode 100644
index 0000000..55feb82
--- /dev/null
+++ b/include/i2c/i2c-gpio.h
@@ -0,0 +1,38 @@
+/*
+ * i2c-gpio interface to platform code
+ *
+ * Copyright (C) 2007 Atmel Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#ifndef _LINUX_I2C_GPIO_H
+#define _LINUX_I2C_GPIO_H
+
+/**
+ * struct i2c_gpio_platform_data - Platform-dependent data for i2c-gpio
+ * @sda_pin: GPIO pin ID to use for SDA
+ * @scl_pin: GPIO pin ID to use for SCL
+ * @udelay: signal toggle delay. SCL frequency is (500 / udelay) kHz
+ * @timeout_ms: clock stretching timeout in ms. If the slave keeps
+ *	SCL low for longer than this, the transfer will time out.
+ * @sda_is_open_drain: SDA is configured as open drain, i.e. the pin
+ *	isn't actively driven high when setting the output value high.
+ *	gpio_get_value() must return the actual pin state even if the
+ *	pin is configured as an output.
+ * @scl_is_open_drain: SCL is set up as open drain. Same requirements
+ *	as for sda_is_open_drain apply.
+ * @scl_is_output_only: SCL output drivers cannot be turned off.
+ */
+struct i2c_gpio_platform_data {
+	unsigned int	sda_pin;
+	unsigned int	scl_pin;
+	int		udelay;
+	int		timeout_ms;
+	unsigned int	sda_is_open_drain:1;
+	unsigned int	scl_is_open_drain:1;
+	unsigned int	scl_is_output_only:1;
+};
+
+#endif /* _LINUX_I2C_GPIO_H */
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Thu Nov  1 05:44:52 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu,  1 Nov 2012 10:44:52 +0100
Subject: [PATCH 4/4] i2c: add versatile support
In-Reply-To: <1351763092-5781-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121101094216.GI29599@game.jcrosoft.org>
 <1351763092-5781-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1351763092-5781-4-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/i2c/busses/Kconfig         |    8 +++
 drivers/i2c/busses/Makefile        |    1 +
 drivers/i2c/busses/i2c-versatile.c |  112 ++++++++++++++++++++++++++++++++++++
 3 files changed, 121 insertions(+)
 create mode 100644 drivers/i2c/busses/i2c-versatile.c

diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 17e33cb..68d9b46 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -20,4 +20,12 @@ config I2C_OMAP
 	bool "OMAP I2C Master driver"
 	depends on ARCH_OMAP
 
+config I2C_VERSATILE
+	tristate "ARM Versatile/Realview I2C bus support"
+	depends on ARCH_VERSATILE
+	select I2C_ALGOBIT
+	help
+	  Say yes if you want to support the I2C serial bus on ARMs Versatile
+	  range of platforms.
+
 endmenu
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 18c7c46..a30f9b8 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -1,3 +1,4 @@
 obj-$(CONFIG_I2C_GPIO)		+= i2c-gpio.o
 obj-$(CONFIG_I2C_IMX) += i2c-imx.o
 obj-$(CONFIG_I2C_OMAP) += i2c-omap.o
+obj-$(CONFIG_I2C_VERSATILE)	+= i2c-versatile.o
diff --git a/drivers/i2c/busses/i2c-versatile.c b/drivers/i2c/busses/i2c-versatile.c
new file mode 100644
index 0000000..7c99322
--- /dev/null
+++ b/drivers/i2c/busses/i2c-versatile.c
@@ -0,0 +1,112 @@
+/*
+ *  i2c-versatile.c
+ *
+ *  Copyright (C) 2006 ARM Ltd.
+ *  written by Russell King, Deep Blue Solutions Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include <common.h>
+#include <driver.h>
+#include <i2c/i2c.h>
+#include <i2c/i2c-algo-bit.h>
+#include <init.h>
+#include <malloc.h>
+#include <io.h>
+
+#define I2C_CONTROL	0x00
+#define I2C_CONTROLS	0x00
+#define I2C_CONTROLC	0x04
+#define SCL		(1 << 0)
+#define SDA		(1 << 1)
+
+struct i2c_versatile {
+	struct i2c_adapter	 adap;
+	struct i2c_algo_bit_data algo;
+	void __iomem		 *base;
+};
+
+static void i2c_versatile_setsda(void *data, int state)
+{
+	struct i2c_versatile *i2c = data;
+
+	writel(SDA, i2c->base + (state ? I2C_CONTROLS : I2C_CONTROLC));
+}
+
+static void i2c_versatile_setscl(void *data, int state)
+{
+	struct i2c_versatile *i2c = data;
+
+	writel(SCL, i2c->base + (state ? I2C_CONTROLS : I2C_CONTROLC));
+}
+
+static int i2c_versatile_getsda(void *data)
+{
+	struct i2c_versatile *i2c = data;
+	return !!(readl(i2c->base + I2C_CONTROL) & SDA);
+}
+
+static int i2c_versatile_getscl(void *data)
+{
+	struct i2c_versatile *i2c = data;
+	return !!(readl(i2c->base + I2C_CONTROL) & SCL);
+}
+
+static struct i2c_algo_bit_data i2c_versatile_algo = {
+	.setsda	= i2c_versatile_setsda,
+	.setscl = i2c_versatile_setscl,
+	.getsda	= i2c_versatile_getsda,
+	.getscl = i2c_versatile_getscl,
+	.udelay	= 30,
+	.timeout_ms = 100,
+};
+
+static int i2c_versatile_probe(struct device_d *dev)
+{
+	struct i2c_versatile *i2c;
+	int ret;
+
+	i2c = kzalloc(sizeof(struct i2c_versatile), GFP_KERNEL);
+	if (!i2c) {
+		ret = -ENOMEM;
+		goto err_release;
+	}
+
+	i2c->base = dev_request_mem_region(dev, 0);
+	if (!i2c->base) {
+		ret = -ENOMEM;
+		goto err_free;
+	}
+
+	writel(SCL | SDA, i2c->base + I2C_CONTROLS);
+
+	i2c->adap.algo_data = &i2c->algo;
+	i2c->adap.dev.parent = dev;
+	i2c->algo = i2c_versatile_algo;
+	i2c->algo.data = i2c;
+
+	i2c->adap.nr = dev->id;
+	ret = i2c_bit_add_numbered_bus(&i2c->adap);
+	if (ret >= 0) {
+		return 0;
+	}
+
+ err_free:
+	kfree(i2c);
+ err_release:
+	return ret;
+}
+
+static struct driver_d i2c_versatile_driver = {
+	.name	= "versatile-i2c",
+	.probe	= i2c_versatile_probe,
+};
+
+static int __init i2c_versatile_init(void)
+{
+	return platform_driver_register(&i2c_versatile_driver);
+}
+
+device_initcall(i2c_versatile_init);
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Thu Nov  1 05:44:50 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu,  1 Nov 2012 10:44:50 +0100
Subject: =?UTF-8?q?=5BPATCH=202/4=5D=20i2c=3A=20add=20i2c=20algo=20bit=20support?=
In-Reply-To: <1351763092-5781-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121101094216.GI29599@game.jcrosoft.org>
 <1351763092-5781-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1351763092-5781-2-git-send-email-plagnioj@jcrosoft.com>

This is needed for i2c-gpio support

Based on linux 3.7-rc2

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/i2c/Kconfig              |    1 +
 drivers/i2c/Makefile             |    2 +-
 drivers/i2c/algos/Kconfig        |    6 +
 drivers/i2c/algos/Makefile       |    5 +
 drivers/i2c/algos/i2c-algo-bit.c |  585 ++++++++++++++++++++++++++++++++++++++
 include/i2c/i2c-algo-bit.h       |   55 ++++
 include/i2c/i2c.h                |    2 +
 7 files changed, 655 insertions(+), 1 deletion(-)
 create mode 100644 drivers/i2c/algos/Kconfig
 create mode 100644 drivers/i2c/algos/Makefile
 create mode 100644 drivers/i2c/algos/i2c-algo-bit.c
 create mode 100644 include/i2c/i2c-algo-bit.h

diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig
index c2af818..038e2ee 100644
--- a/drivers/i2c/Kconfig
+++ b/drivers/i2c/Kconfig
@@ -3,6 +3,7 @@ menuconfig I2C
 
 if I2C
 
+source drivers/i2c/algos/Kconfig
 source drivers/i2c/busses/Kconfig
 
 endif
diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
index 42e22c0..5ce0324 100644
--- a/drivers/i2c/Makefile
+++ b/drivers/i2c/Makefile
@@ -1 +1 @@
-obj-$(CONFIG_I2C) += i2c.o busses/
+obj-$(CONFIG_I2C) += i2c.o busses/ algos/
diff --git a/drivers/i2c/algos/Kconfig b/drivers/i2c/algos/Kconfig
new file mode 100644
index 0000000..c74b148
--- /dev/null
+++ b/drivers/i2c/algos/Kconfig
@@ -0,0 +1,6 @@
+#
+# I2C algorithm drivers configuration
+#
+
+config I2C_ALGOBIT
+	bool
diff --git a/drivers/i2c/algos/Makefile b/drivers/i2c/algos/Makefile
new file mode 100644
index 0000000..e0a0399
--- /dev/null
+++ b/drivers/i2c/algos/Makefile
@@ -0,0 +1,5 @@
+#
+# Makefile for the i2c algorithms
+#
+
+obj-$(CONFIG_I2C_ALGOBIT)	+= i2c-algo-bit.o
diff --git a/drivers/i2c/algos/i2c-algo-bit.c b/drivers/i2c/algos/i2c-algo-bit.c
new file mode 100644
index 0000000..37af27c
--- /dev/null
+++ b/drivers/i2c/algos/i2c-algo-bit.c
@@ -0,0 +1,585 @@
+/* -------------------------------------------------------------------------
+ * i2c-algo-bit.c i2c driver algorithms for bit-shift adapters
+ * -------------------------------------------------------------------------
+ *   Copyright (C) 1995-2000 Simon G. Vogl
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+    MA 02110-1301 USA.
+ * ------------------------------------------------------------------------- */
+
+/* With some changes from Frodo Looijaard <frodol at dds.nl>, Ky?sti M?lkki
+   <kmalkki at cc.hut.fi> and Jean Delvare <khali at linux-fr.org> */
+
+#include <common.h>
+#include <init.h>
+#include <errno.h>
+#include <clock.h>
+#include <i2c/i2c.h>
+#include <i2c/i2c-algo-bit.h>
+
+/* ----- global defines ----------------------------------------------- */
+
+#ifdef DEBUG
+#define bit_dbg(level, dev, format, args...) \
+	do { \
+		if (i2c_debug >= level) \
+			dev_dbg(dev, format, ##args); \
+	} while (0)
+#else
+#define bit_dbg(level, dev, format, args...) \
+	do {} while (0)
+#endif /* DEBUG */
+
+/* ----- global variables ---------------------------------------------	*/
+
+static int bit_test;	/* see if the line-setting functions work	*/
+
+#ifdef DEBUG
+static int i2c_debug = 1;
+#endif
+
+/* --- setting states on the bus with the right timing: ---------------	*/
+
+#define setsda(adap, val)	adap->setsda(adap->data, val)
+#define setscl(adap, val)	adap->setscl(adap->data, val)
+#define getsda(adap)		adap->getsda(adap->data)
+#define getscl(adap)		adap->getscl(adap->data)
+
+static inline void sdalo(struct i2c_algo_bit_data *adap)
+{
+	setsda(adap, 0);
+	udelay((adap->udelay + 1) / 2);
+}
+
+static inline void sdahi(struct i2c_algo_bit_data *adap)
+{
+	setsda(adap, 1);
+	udelay((adap->udelay + 1) / 2);
+}
+
+static inline void scllo(struct i2c_algo_bit_data *adap)
+{
+	setscl(adap, 0);
+	udelay(adap->udelay / 2);
+}
+
+/*
+ * Raise scl line, and do checking for delays. This is necessary for slower
+ * devices.
+ */
+static int sclhi(struct i2c_algo_bit_data *adap)
+{
+	uint64_t start;
+
+	setscl(adap, 1);
+
+	/* Not all adapters have scl sense line... */
+	if (!adap->getscl)
+		goto done;
+
+	start = get_time_ns();
+	while (!getscl(adap)) {
+		/* This hw knows how to read the clock line, so we wait
+		 * until it actually gets high.  This is safer as some
+		 * chips may hold it low ("clock stretching") while they
+		 * are processing data internally.
+		 */
+		if (is_timeout(start, adap->timeout_ms * MSECOND)) {
+			/* Test one last time, as we may have been preempted
+			 * between last check and timeout test.
+			 */
+			if (getscl(adap))
+				break;
+			return -ETIMEDOUT;
+		}
+	}
+#ifdef DEBUG
+	if (jiffies != start && i2c_debug >= 3)
+		pr_debug("i2c-algo-bit: needed %ld jiffies for SCL to go "
+			 "high\n", jiffies - start);
+#endif
+
+done:
+	udelay(adap->udelay);
+	return 0;
+}
+
+
+/* --- other auxiliary functions --------------------------------------	*/
+static void i2c_start(struct i2c_algo_bit_data *adap)
+{
+	/* assert: scl, sda are high */
+	setsda(adap, 0);
+	udelay(adap->udelay);
+	scllo(adap);
+}
+
+static void i2c_repstart(struct i2c_algo_bit_data *adap)
+{
+	/* assert: scl is low */
+	sdahi(adap);
+	sclhi(adap);
+	setsda(adap, 0);
+	udelay(adap->udelay);
+	scllo(adap);
+}
+
+
+static void i2c_stop(struct i2c_algo_bit_data *adap)
+{
+	/* assert: scl is low */
+	sdalo(adap);
+	sclhi(adap);
+	setsda(adap, 1);
+	udelay(adap->udelay);
+}
+
+
+
+/* send a byte without start cond., look for arbitration,
+   check ackn. from slave */
+/* returns:
+ * 1 if the device acknowledged
+ * 0 if the device did not ack
+ * -ETIMEDOUT if an error occurred (while raising the scl line)
+ */
+static int i2c_outb(struct i2c_adapter *i2c_adap, unsigned char c)
+{
+	int i;
+	int sb;
+	int ack;
+	struct i2c_algo_bit_data *adap = i2c_adap->algo_data;
+
+	/* assert: scl is low */
+	for (i = 7; i >= 0; i--) {
+		sb = (c >> i) & 1;
+		setsda(adap, sb);
+		udelay((adap->udelay + 1) / 2);
+		if (sclhi(adap) < 0) { /* timed out */
+			bit_dbg(1, &i2c_adap->dev, "i2c_outb: 0x%02x, "
+				"timeout at bit #%d\n", (int)c, i);
+			return -ETIMEDOUT;
+		}
+		/* FIXME do arbitration here:
+		 * if (sb && !getsda(adap)) -> ouch! Get out of here.
+		 *
+		 * Report a unique code, so higher level code can retry
+		 * the whole (combined) message and *NOT* issue STOP.
+		 */
+		scllo(adap);
+	}
+	sdahi(adap);
+	if (sclhi(adap) < 0) { /* timeout */
+		bit_dbg(1, &i2c_adap->dev, "i2c_outb: 0x%02x, "
+			"timeout at ack\n", (int)c);
+		return -ETIMEDOUT;
+	}
+
+	/* read ack: SDA should be pulled down by slave, or it may
+	 * NAK (usually to report problems with the data we wrote).
+	 */
+	ack = !getsda(adap);    /* ack: sda is pulled low -> success */
+	bit_dbg(2, &i2c_adap->dev, "i2c_outb: 0x%02x %s\n", (int)c,
+		ack ? "A" : "NA");
+
+	scllo(adap);
+	return ack;
+	/* assert: scl is low (sda undef) */
+}
+
+
+static int i2c_inb(struct i2c_adapter *i2c_adap)
+{
+	/* read byte via i2c port, without start/stop sequence	*/
+	/* acknowledge is sent in i2c_read.			*/
+	int i;
+	unsigned char indata = 0;
+	struct i2c_algo_bit_data *adap = i2c_adap->algo_data;
+
+	/* assert: scl is low */
+	sdahi(adap);
+	for (i = 0; i < 8; i++) {
+		if (sclhi(adap) < 0) { /* timeout */
+			bit_dbg(1, &i2c_adap->dev, "i2c_inb: timeout at bit "
+				"#%d\n", 7 - i);
+			return -ETIMEDOUT;
+		}
+		indata *= 2;
+		if (getsda(adap))
+			indata |= 0x01;
+		setscl(adap, 0);
+		udelay(i == 7 ? adap->udelay / 2 : adap->udelay);
+	}
+	/* assert: scl is low */
+	return indata;
+}
+
+/*
+ * Sanity check for the adapter hardware - check the reaction of
+ * the bus lines only if it seems to be idle.
+ */
+static int test_bus(struct i2c_adapter *i2c_adap)
+{
+	struct i2c_algo_bit_data *adap = i2c_adap->algo_data;
+	struct device_d *dev = &i2c_adap->dev;
+	int scl, sda, ret;
+
+	if (adap->pre_xfer) {
+		ret = adap->pre_xfer(i2c_adap);
+		if (ret < 0)
+			return -ENODEV;
+	}
+
+	if (adap->getscl == NULL)
+		dev_info(dev, "Testing SDA only, SCL is not readable\n");
+
+	sda = getsda(adap);
+	scl = (adap->getscl == NULL) ? 1 : getscl(adap);
+	if (!scl || !sda) {
+		dev_warn(dev, "bus seems to be busy (scl=%d, sda=%d)\n", scl, sda);
+		goto bailout;
+	}
+
+	sdalo(adap);
+	sda = getsda(adap);
+	scl = (adap->getscl == NULL) ? 1 : getscl(adap);
+	if (sda) {
+		dev_warn(dev, "SDA stuck high!\n");
+		goto bailout;
+	}
+	if (!scl) {
+		dev_warn(dev, "SCL unexpected low while pulling SDA low!\n");
+		goto bailout;
+	}
+
+	sdahi(adap);
+	sda = getsda(adap);
+	scl = (adap->getscl == NULL) ? 1 : getscl(adap);
+	if (!sda) {
+		dev_warn(dev, "SDA stuck low!\n");
+		goto bailout;
+	}
+	if (!scl) {
+		dev_warn(dev, "SCL unexpected low while pulling SDA high!\n");
+		goto bailout;
+	}
+
+	scllo(adap);
+	sda = getsda(adap);
+	scl = (adap->getscl == NULL) ? 0 : getscl(adap);
+	if (scl) {
+		dev_warn(dev, "SCL stuck high!\n");
+		goto bailout;
+	}
+	if (!sda) {
+		dev_warn(dev, "SDA unexpected low while pulling SCL low!\n");
+		goto bailout;
+	}
+
+	sclhi(adap);
+	sda = getsda(adap);
+	scl = (adap->getscl == NULL) ? 1 : getscl(adap);
+	if (!scl) {
+		dev_warn(dev, "SCL stuck low!\n");
+		goto bailout;
+	}
+	if (!sda) {
+		dev_warn(dev, "SDA unexpected low while pulling SCL high!\n");
+		goto bailout;
+	}
+
+	if (adap->post_xfer)
+		adap->post_xfer(i2c_adap);
+
+	dev_info(dev, "Test OK\n");
+	return 0;
+bailout:
+	sdahi(adap);
+	sclhi(adap);
+
+	if (adap->post_xfer)
+		adap->post_xfer(i2c_adap);
+
+	return -ENODEV;
+}
+
+/* ----- Utility functions
+ */
+
+/* try_address tries to contact a chip for a number of
+ * times before it gives up.
+ * return values:
+ * 1 chip answered
+ * 0 chip did not answer
+ * -x transmission error
+ */
+static int try_address(struct i2c_adapter *i2c_adap,
+		       unsigned char addr, int retries)
+{
+	struct i2c_algo_bit_data *adap = i2c_adap->algo_data;
+	int i, ret = 0;
+
+	for (i = 0; i <= retries; i++) {
+		ret = i2c_outb(i2c_adap, addr);
+		if (ret == 1 || i == retries)
+			break;
+		bit_dbg(3, &i2c_adap->dev, "emitting stop condition\n");
+		i2c_stop(adap);
+		udelay(adap->udelay);
+		bit_dbg(3, &i2c_adap->dev, "emitting start condition\n");
+		i2c_start(adap);
+	}
+	if (i && ret)
+		bit_dbg(1, &i2c_adap->dev, "Used %d tries to %s client at "
+			"0x%02x: %s\n", i + 1,
+			addr & 1 ? "read from" : "write to", addr >> 1,
+			ret == 1 ? "success" : "failed, timeout?");
+	return ret;
+}
+
+static int sendbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg)
+{
+	const unsigned char *temp = msg->buf;
+	int count = msg->len;
+	unsigned short nak_ok = msg->flags & I2C_M_IGNORE_NAK;
+	int retval;
+	int wrcount = 0;
+
+	while (count > 0) {
+		retval = i2c_outb(i2c_adap, *temp);
+
+		/* OK/ACK; or ignored NAK */
+		if ((retval > 0) || (nak_ok && (retval == 0))) {
+			count--;
+			temp++;
+			wrcount++;
+
+		/* A slave NAKing the master means the slave didn't like
+		 * something about the data it saw.  For example, maybe
+		 * the SMBus PEC was wrong.
+		 */
+		} else if (retval == 0) {
+			dev_err(&i2c_adap->dev, "sendbytes: NAK bailout.\n");
+			return -EIO;
+
+		/* Timeout; or (someday) lost arbitration
+		 *
+		 * FIXME Lost ARB implies retrying the transaction from
+		 * the first message, after the "winning" master issues
+		 * its STOP.  As a rule, upper layer code has no reason
+		 * to know or care about this ... it is *NOT* an error.
+		 */
+		} else {
+			dev_err(&i2c_adap->dev, "sendbytes: error %d\n",
+					retval);
+			return retval;
+		}
+	}
+	return wrcount;
+}
+
+static int readbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg)
+{
+	int inval;
+	int rdcount = 0;	/* counts bytes read */
+	unsigned char *temp = msg->buf;
+	int count = msg->len;
+
+	while (count > 0) {
+		inval = i2c_inb(i2c_adap);
+		if (inval >= 0) {
+			*temp = inval;
+			rdcount++;
+		} else {   /* read timed out */
+			break;
+		}
+
+		temp++;
+		count--;
+
+		bit_dbg(2, &i2c_adap->dev, "readbytes: 0x%02x %s\n",
+			inval,
+			(flags & I2C_M_NO_RD_ACK)
+				? "(no ack/nak)"
+				: (count ? "A" : "NA"));
+	}
+	return rdcount;
+}
+
+/* doAddress initiates the transfer by generating the start condition (in
+ * try_address) and transmits the address in the necessary format to handle
+ * reads, writes as well as 10bit-addresses.
+ * returns:
+ *  0 everything went okay, the chip ack'ed, or IGNORE_NAK flag was set
+ * -x an error occurred (like: -ENXIO if the device did not answer, or
+ *	-ETIMEDOUT, for example if the lines are stuck...)
+ */
+static int bit_doAddress(struct i2c_adapter *i2c_adap, struct i2c_msg *msg)
+{
+	unsigned short flags = msg->flags;
+	unsigned short nak_ok = msg->flags & I2C_M_IGNORE_NAK;
+	struct i2c_algo_bit_data *adap = i2c_adap->algo_data;
+
+	unsigned char addr;
+	int ret, retries;
+
+	retries = nak_ok ? 0 : i2c_adap->retries;
+
+	if (flags & I2C_M_TEN) {
+		/* a ten bit address */
+		addr = 0xf0 | ((msg->addr >> 7) & 0x06);
+		bit_dbg(2, &i2c_adap->dev, "addr0: %d\n", addr);
+		/* try extended address code...*/
+		ret = try_address(i2c_adap, addr, retries);
+		if ((ret != 1) && !nak_ok)  {
+			dev_err(&i2c_adap->dev,
+				"died at extended address code\n");
+			return -ENXIO;
+		}
+		/* the remaining 8 bit address */
+		ret = i2c_outb(i2c_adap, msg->addr & 0xff);
+		if ((ret != 1) && !nak_ok) {
+			/* the chip did not ack / xmission error occurred */
+			dev_err(&i2c_adap->dev, "died at 2nd address code\n");
+			return -ENXIO;
+		}
+		if (flags & I2C_M_RD) {
+			bit_dbg(3, &i2c_adap->dev, "emitting repeated "
+				"start condition\n");
+			i2c_repstart(adap);
+			/* okay, now switch into reading mode */
+			addr |= 0x01;
+			ret = try_address(i2c_adap, addr, retries);
+			if ((ret != 1) && !nak_ok) {
+				dev_err(&i2c_adap->dev,
+					"died at repeated address code\n");
+				return -EIO;
+			}
+		}
+	} else {		/* normal 7bit address	*/
+		addr = msg->addr << 1;
+		if (flags & I2C_M_RD)
+			addr |= 1;
+		ret = try_address(i2c_adap, addr, retries);
+		if ((ret != 1) && !nak_ok)
+			return -ENXIO;
+	}
+
+	return 0;
+}
+
+static int bit_xfer(struct i2c_adapter *i2c_adap,
+		    struct i2c_msg msgs[], int num)
+{
+	struct i2c_msg *pmsg;
+	struct i2c_algo_bit_data *adap = i2c_adap->algo_data;
+	int i, ret;
+	unsigned short nak_ok;
+
+	if (adap->pre_xfer) {
+		ret = adap->pre_xfer(i2c_adap);
+		if (ret < 0)
+			return ret;
+	}
+
+	bit_dbg(3, &i2c_adap->dev, "emitting start condition\n");
+	i2c_start(adap);
+	for (i = 0; i < num; i++) {
+		pmsg = &msgs[i];
+		nak_ok = pmsg->flags & I2C_M_IGNORE_NAK;
+		if (i) {
+			bit_dbg(3, &i2c_adap->dev, "emitting "
+				"repeated start condition\n");
+			i2c_repstart(adap);
+		}
+		ret = bit_doAddress(i2c_adap, pmsg);
+		if ((ret != 0) && !nak_ok) {
+			bit_dbg(1, &i2c_adap->dev, "NAK from "
+				"device addr 0x%02x msg #%d\n",
+				msgs[i].addr, i);
+			goto bailout;
+		}
+		if (pmsg->flags & I2C_M_RD) {
+			/* read bytes into buffer*/
+			ret = readbytes(i2c_adap, pmsg);
+			if (ret >= 1)
+				bit_dbg(2, &i2c_adap->dev, "read %d byte%s\n",
+					ret, ret == 1 ? "" : "s");
+			if (ret < pmsg->len) {
+				if (ret >= 0)
+					ret = -EIO;
+				goto bailout;
+			}
+		} else {
+			/* write bytes from buffer */
+			ret = sendbytes(i2c_adap, pmsg);
+			if (ret >= 1)
+				bit_dbg(2, &i2c_adap->dev, "wrote %d byte%s\n",
+					ret, ret == 1 ? "" : "s");
+			if (ret < pmsg->len) {
+				if (ret >= 0)
+					ret = -EIO;
+				goto bailout;
+			}
+		}
+	}
+	ret = i;
+
+bailout:
+	bit_dbg(3, &i2c_adap->dev, "emitting stop condition\n");
+	i2c_stop(adap);
+
+	if (adap->post_xfer)
+		adap->post_xfer(i2c_adap);
+	return ret;
+}
+
+/*
+ * registering functions to load algorithms at runtime
+ */
+static int __i2c_bit_add_bus(struct i2c_adapter *adap,
+			     int (*add_adapter)(struct i2c_adapter *))
+{
+	struct i2c_algo_bit_data *bit_adap = adap->algo_data;
+	int ret;
+
+	if (bit_test) {
+		ret = test_bus(adap);
+		if (bit_test >= 2 && ret < 0)
+			return -ENODEV;
+	}
+
+	/* register new adapter to i2c module... */
+	//adap->algo = &i2c_bit_algo;
+	adap->retries = 3;
+	adap->master_xfer = bit_xfer;
+
+	ret = add_adapter(adap);
+	if (ret < 0)
+		return ret;
+
+	/* Complain if SCL can't be read */
+	if (bit_adap->getscl == NULL) {
+		dev_warn(&adap->dev, "Not I2C compliant: can't read SCL\n");
+		dev_warn(&adap->dev, "Bus may be unreliable\n");
+	}
+	return 0;
+}
+
+int i2c_bit_add_numbered_bus(struct i2c_adapter *adap)
+{
+	return __i2c_bit_add_bus(adap, i2c_add_numbered_adapter);
+}
+EXPORT_SYMBOL(i2c_bit_add_numbered_bus);
diff --git a/include/i2c/i2c-algo-bit.h b/include/i2c/i2c-algo-bit.h
new file mode 100644
index 0000000..1b72219
--- /dev/null
+++ b/include/i2c/i2c-algo-bit.h
@@ -0,0 +1,55 @@
+/* ------------------------------------------------------------------------- */
+/* i2c-algo-bit.h i2c driver algorithms for bit-shift adapters               */
+/* ------------------------------------------------------------------------- */
+/*   Copyright (C) 1995-99 Simon G. Vogl
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+    MA 02110-1301 USA.							     */
+/* ------------------------------------------------------------------------- */
+
+/* With some changes from Ky?sti M?lkki <kmalkki at cc.hut.fi> and even
+   Frodo Looijaard <frodol at dds.nl> */
+
+#ifndef _LINUX_I2C_ALGO_BIT_H
+#define _LINUX_I2C_ALGO_BIT_H
+
+/* --- Defines for bit-adapters ---------------------------------------	*/
+/*
+ * This struct contains the hw-dependent functions of bit-style adapters to
+ * manipulate the line states, and to init any hw-specific features. This is
+ * only used if you have more than one hw-type of adapter running.
+ */
+struct i2c_algo_bit_data {
+	void *data;		/* private data for lowlevel routines */
+	void (*setsda) (void *data, int state);
+	void (*setscl) (void *data, int state);
+	int  (*getsda) (void *data);
+	int  (*getscl) (void *data);
+	int  (*pre_xfer)  (struct i2c_adapter *);
+	void (*post_xfer) (struct i2c_adapter *);
+
+	/* local settings */
+	int udelay;		/* half clock cycle time in us,
+				   minimum 2 us for fast-mode I2C,
+				   minimum 5 us for standard-mode I2C and SMBus,
+				   maximum 50 us for SMBus */
+	int timeout_ms;		/* in ms */
+};
+
+int i2c_bit_add_bus(struct i2c_adapter *);
+int i2c_bit_add_numbered_bus(struct i2c_adapter *);
+extern const struct i2c_algorithm i2c_bit_algo;
+
+#endif /* _LINUX_I2C_ALGO_BIT_H */
diff --git a/include/i2c/i2c.h b/include/i2c/i2c.h
index 5021dd4..b059119 100644
--- a/include/i2c/i2c.h
+++ b/include/i2c/i2c.h
@@ -70,6 +70,8 @@ struct i2c_adapter {
 	int			nr;	/* bus number */
 	int (*master_xfer)(struct i2c_adapter *adap, struct i2c_msg *msgs, int num);
 	struct list_head	list;
+	int			retries;
+	void 			*algo_data;
 };
 
 
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Thu Nov  1 05:44:49 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu,  1 Nov 2012 10:44:49 +0100
Subject: [PATCH 1/4] i2c: adapter: register it's own device
In-Reply-To: <20121101094216.GI29599@game.jcrosoft.org>
References: <20121101094216.GI29599@game.jcrosoft.org>
Message-ID: <1351763092-5781-1-git-send-email-plagnioj@jcrosoft.com>

so we can show the this of i2c busses
set the bus device as parent of all devices.

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/i2c/busses/i2c-imx.c  |   20 ++++++++++----------
 drivers/i2c/busses/i2c-omap.c |   30 +++++++++++++++---------------
 drivers/i2c/i2c.c             |   18 +++++++++++++++---
 include/i2c/i2c.h             |    2 +-
 4 files changed, 41 insertions(+), 29 deletions(-)

diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index a1012a7..7f9a2dc 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -154,7 +154,7 @@ static int i2c_fsl_bus_busy(struct i2c_adapter *adapter, int for_busy)
 		if (!for_busy && !(temp & I2SR_IBB))
 			break;
 		if (is_timeout(start, 500 * MSECOND)) {
-			dev_err(adapter->dev,
+			dev_err(&adapter->dev,
 				 "<%s> timeout waiting for I2C bus %s\n",
 				 __func__,for_busy ? "busy" : "not busy");
 			return -EIO;
@@ -177,7 +177,7 @@ static int i2c_fsl_trx_complete(struct i2c_adapter *adapter)
 			break;
 
 		if (is_timeout(start, 100 * MSECOND)) {
-			dev_err(adapter->dev, "<%s> TXR timeout\n", __func__);
+			dev_err(&adapter->dev, "<%s> TXR timeout\n", __func__);
 			return -EIO;
 		}
 	}
@@ -199,7 +199,7 @@ static int i2c_fsl_acked(struct i2c_adapter *adapter)
 			break;
 
 		if (is_timeout(start, MSECOND)) {
-			dev_dbg(adapter->dev, "<%s> No ACK\n", __func__);
+			dev_dbg(&adapter->dev, "<%s> No ACK\n", __func__);
 			return -EIO;
 		}
 	}
@@ -368,9 +368,9 @@ static void i2c_fsl_set_clk(struct fsl_i2c_struct *i2c_fsl,
 		(500000U * i2c_clk_div[i][0] + (i2c_clk_rate / 2) - 1) /
 		(i2c_clk_rate / 2);
 
-	dev_dbg(i2c_fsl->adapter.dev, "<%s> I2C_CLK=%d, REQ DIV=%d\n",
+	dev_dbg(&i2c_fsl->adapter.dev, "<%s> I2C_CLK=%d, REQ DIV=%d\n",
 		__func__, i2c_clk_rate, div);
-	dev_dbg(i2c_fsl->adapter.dev, "<%s> IFDR[IC]=0x%x, REAL DIV=%d\n",
+	dev_dbg(&i2c_fsl->adapter.dev, "<%s> IFDR[IC]=0x%x, REAL DIV=%d\n",
 		__func__, i2c_clk_div[i][1], i2c_clk_div[i][0]);
 }
 #endif
@@ -382,7 +382,7 @@ static int i2c_fsl_write(struct i2c_adapter *adapter, struct i2c_msg *msgs)
 	int i, result;
 
 	if ( !(msgs->flags & I2C_M_DATA_ONLY) ) {
-		dev_dbg(adapter->dev,
+		dev_dbg(&adapter->dev,
 			"<%s> write slave address: addr=0x%02x\n",
 			__func__, msgs->addr << 1);
 
@@ -399,7 +399,7 @@ static int i2c_fsl_write(struct i2c_adapter *adapter, struct i2c_msg *msgs)
 
 	/* write data */
 	for (i = 0; i < msgs->len; i++) {
-		dev_dbg(adapter->dev,
+		dev_dbg(&adapter->dev,
 			"<%s> write byte: B%d=0x%02X\n",
 			__func__, i, msgs->buf[i]);
 		writeb(msgs->buf[i], base + FSL_I2C_I2DR);
@@ -425,7 +425,7 @@ static int i2c_fsl_read(struct i2c_adapter *adapter, struct i2c_msg *msgs)
 	writeb(0x0, base + FSL_I2C_I2SR);
 
 	if ( !(msgs->flags & I2C_M_DATA_ONLY) ) {
-		dev_dbg(adapter->dev,
+		dev_dbg(&adapter->dev,
 			"<%s> write slave address: addr=0x%02x\n",
 			__func__, (msgs->addr << 1) | 0x01);
 
@@ -478,7 +478,7 @@ static int i2c_fsl_read(struct i2c_adapter *adapter, struct i2c_msg *msgs)
 		}
 		msgs->buf[i] = readb(base + FSL_I2C_I2DR);
 
-		dev_dbg(adapter->dev, "<%s> read byte: B%d=0x%02X\n",
+		dev_dbg(&adapter->dev, "<%s> read byte: B%d=0x%02X\n",
 			__func__, i, msgs->buf[i]);
 	}
 	return 0;
@@ -544,7 +544,7 @@ static int __init i2c_fsl_probe(struct device_d *pdev)
 	/* Setup i2c_fsl driver structure */
 	i2c_fsl->adapter.master_xfer = i2c_fsl_xfer;
 	i2c_fsl->adapter.nr = pdev->id;
-	i2c_fsl->adapter.dev = pdev;
+	i2c_fsl->adapter.dev.parent = pdev;
 	i2c_fsl->base = dev_request_mem_region(pdev, 0);
 	i2c_fsl->dfsrr = -1;
 
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 24961eb..f371875 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -318,7 +318,7 @@ static int omap_i2c_init(struct omap_i2c_struct *i2c_omap)
 		while (!(omap_i2c_read_reg(i2c_omap, OMAP_I2C_SYSS_REG) &
 			 SYSS_RESETDONE_MASK)) {
 			if (is_timeout(start, MSECOND)) {
-				dev_warn(i2c_omap->adapter.dev, "timeout waiting "
+				dev_warn(&i2c_omap->adapter.dev, "timeout waiting "
 						"for controller reset\n");
 				return -ETIMEDOUT;
 			}
@@ -453,7 +453,7 @@ static int omap_i2c_wait_for_bb(struct i2c_adapter *adapter)
 	start = get_time_ns();
 	while (omap_i2c_read_reg(i2c_omap, OMAP_I2C_STAT_REG) & OMAP_I2C_STAT_BB) {
 		if (is_timeout(start, MSECOND)) {
-			dev_warn(adapter->dev, "timeout waiting for bus ready\n");
+			dev_warn(&adapter->dev, "timeout waiting for bus ready\n");
 			return -ETIMEDOUT;
 		}
 	}
@@ -476,9 +476,9 @@ omap_i2c_isr(struct omap_i2c_struct *dev)
 
 	bits = omap_i2c_read_reg(dev, OMAP_I2C_IE_REG);
 	while ((stat = (omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG))) & bits) {
-		dev_dbg(dev->adapter.dev, "IRQ (ISR = 0x%04x)\n", stat);
+		dev_dbg(&dev->adapter.dev, "IRQ (ISR = 0x%04x)\n", stat);
 		if (count++ == 100) {
-			dev_warn(dev->adapter.dev, "Too much work in one IRQ\n");
+			dev_warn(&dev->adapter.dev, "Too much work in one IRQ\n");
 			break;
 		}
 
@@ -499,7 +499,7 @@ complete:
 					   OMAP_I2C_CON_STP);
 		}
 		if (stat & OMAP_I2C_STAT_AL) {
-			dev_err(dev->adapter.dev, "Arbitration lost\n");
+			dev_err(&dev->adapter.dev, "Arbitration lost\n");
 			err |= OMAP_I2C_STAT_AL;
 		}
 		if (stat & (OMAP_I2C_STAT_ARDY | OMAP_I2C_STAT_NACK |
@@ -536,11 +536,11 @@ complete:
 					}
 				} else {
 					if (stat & OMAP_I2C_STAT_RRDY)
-						dev_err(dev->adapter.dev,
+						dev_err(&dev->adapter.dev,
 							"RRDY IRQ while no data"
 								" requested\n");
 					if (stat & OMAP_I2C_STAT_RDR)
-						dev_err(dev->adapter.dev,
+						dev_err(&dev->adapter.dev,
 							"RDR IRQ while no data"
 								" requested\n");
 					break;
@@ -577,11 +577,11 @@ complete:
 					}
 				} else {
 					if (stat & OMAP_I2C_STAT_XRDY)
-						dev_err(dev->adapter.dev,
+						dev_err(&dev->adapter.dev,
 							"XRDY IRQ while no "
 							"data to send\n");
 					if (stat & OMAP_I2C_STAT_XDR)
-						dev_err(dev->adapter.dev,
+						dev_err(&dev->adapter.dev,
 							"XDR IRQ while no "
 							"data to send\n");
 					break;
@@ -613,11 +613,11 @@ complete:
 			continue;
 		}
 		if (stat & OMAP_I2C_STAT_ROVR) {
-			dev_err(dev->adapter.dev, "Receive overrun\n");
+			dev_err(&dev->adapter.dev, "Receive overrun\n");
 			dev->cmd_err |= OMAP_I2C_STAT_ROVR;
 		}
 		if (stat & OMAP_I2C_STAT_XUDF) {
-			dev_err(dev->adapter.dev, "Transmit underflow\n");
+			dev_err(&dev->adapter.dev, "Transmit underflow\n");
 			dev->cmd_err |= OMAP_I2C_STAT_XUDF;
 		}
 	}
@@ -639,7 +639,7 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adapter,
 	int ret = 0;
 
 
-	dev_dbg(adapter->dev, "addr: 0x%04x, len: %d, flags: 0x%x, stop: %d\n",
+	dev_dbg(&adapter->dev, "addr: 0x%04x, len: %d, flags: 0x%x, stop: %d\n",
 		msg->addr, msg->len, msg->flags, stop);
 
 	if (msg->len == 0)
@@ -687,7 +687,7 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adapter,
 
 			/* Let the user know if i2c is in a bad state */
 			if (is_timeout(start, MSECOND)) {
-				dev_err(adapter->dev, "controller timed out "
+				dev_err(&adapter->dev, "controller timed out "
 				"waiting for start condition to finish\n");
 				return -ETIMEDOUT;
 			}
@@ -707,7 +707,7 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adapter,
 	while (ret){
 		ret = omap_i2c_isr(i2c_omap);
 		if (is_timeout(start, MSECOND)) {
-				dev_err(adapter->dev,
+				dev_err(&adapter->dev,
 				"timed out on polling for "
 				"open i2c message handling\n");
 				return -ETIMEDOUT;
@@ -835,7 +835,7 @@ i2c_omap_probe(struct device_d *pdev)
 
 	i2c_omap->adapter.master_xfer	= omap_i2c_xfer,
 	i2c_omap->adapter.nr = pdev->id;
-	i2c_omap->adapter.dev = pdev;
+	i2c_omap->adapter.dev.parent = pdev;
 
 	/* i2c device drivers may be active on return from add_adapter() */
 	r = i2c_add_numbered_adapter(&i2c_omap->adapter);
diff --git a/drivers/i2c/i2c.c b/drivers/i2c/i2c.c
index 27fd256..2ca3aef 100644
--- a/drivers/i2c/i2c.c
+++ b/drivers/i2c/i2c.c
@@ -80,7 +80,7 @@ int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
 	 */
 
 	for (ret = 0; ret < num; ret++) {
-		dev_dbg(adap->dev, "master_xfer[%d] %c, addr=0x%02x, "
+		dev_dbg(&adap->dev, "master_xfer[%d] %c, addr=0x%02x, "
 			"len=%d\n", ret, (msgs[ret].flags & I2C_M_RD)
 			? 'R' : 'W', msgs[ret].addr, msgs[ret].len);
 	}
@@ -256,6 +256,9 @@ struct i2c_client *i2c_new_device(struct i2c_adapter *adapter,
 	client->adapter = adapter;
 	client->addr = chip->addr;
 
+	client->dev.parent = &adapter->dev;
+	dev_add_child(client->dev.parent, &client->dev);
+
 	status = register_device(&client->dev);
 
 #if 0
@@ -363,8 +366,17 @@ struct i2c_adapter *i2c_get_adapter(int busnum)
  */
 int i2c_add_numbered_adapter(struct i2c_adapter *adapter)
 {
-	if (i2c_get_adapter(adapter->nr))
-		return -EBUSY;
+	int ret;
+
+	adapter->dev.id = adapter->nr;
+	strcpy(adapter->dev.name, "i2c");
+
+	if (adapter->dev.parent)
+		dev_add_child(adapter->dev.parent, &adapter->dev);
+
+	ret = register_device(&adapter->dev);
+	if (ret)
+		return ret;
 
 	list_add_tail(&adapter->list, &adapter_list);
 
diff --git a/include/i2c/i2c.h b/include/i2c/i2c.h
index de2a7ea..5021dd4 100644
--- a/include/i2c/i2c.h
+++ b/include/i2c/i2c.h
@@ -66,7 +66,7 @@ struct i2c_msg {
  *
  */
 struct i2c_adapter {
-	struct device_d		*dev;	/* ptr to device */
+	struct device_d		dev;	/* ptr to device */
 	int			nr;	/* bus number */
 	int (*master_xfer)(struct i2c_adapter *adap, struct i2c_msg *msgs, int num);
 	struct list_head	list;
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Thu Nov  1 05:52:47 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu,  1 Nov 2012 10:52:47 +0100
Subject: [For next PATCH 1/1] versatilepb: add i2c support
Message-ID: <1351763567-6641-1-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
apply over next

depends on verstile i2c driver send via i2c algo-bit series

Best Regards,
J.
 arch/arm/boards/versatile/versatilepb.c     |    1 +
 arch/arm/configs/versatilepb_defconfig      |    3 +++
 arch/arm/mach-versatile/core.c              |    7 +++++++
 arch/arm/mach-versatile/include/mach/init.h |    1 +
 4 files changed, 12 insertions(+)

diff --git a/arch/arm/boards/versatile/versatilepb.c b/arch/arm/boards/versatile/versatilepb.c
index 5a9c0b6..2eb7473 100644
--- a/arch/arm/boards/versatile/versatilepb.c
+++ b/arch/arm/boards/versatile/versatilepb.c
@@ -47,6 +47,7 @@ mem_initcall(vpb_mem_init);
 static int vpb_devices_init(void)
 {
 	add_cfi_flash_device(DEVICE_ID_DYNAMIC, VERSATILE_FLASH_BASE, VERSATILE_FLASH_SIZE, 0);
+	versatile_register_i2c();
 	devfs_add_partition("nor0", 0x00000, 0x40000, DEVFS_PARTITION_FIXED, "self");
 	devfs_add_partition("nor0", 0x40000, 0x20000, DEVFS_PARTITION_FIXED, "env0");
 
diff --git a/arch/arm/configs/versatilepb_defconfig b/arch/arm/configs/versatilepb_defconfig
index 4c71c3c..f6fa454 100644
--- a/arch/arm/configs/versatilepb_defconfig
+++ b/arch/arm/configs/versatilepb_defconfig
@@ -34,6 +34,7 @@ CONFIG_CMD_TIMEOUT=y
 CONFIG_CMD_PARTITION=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_UNCOMPRESS=y
+CONFIG_CMD_I2C=y
 CONFIG_NET=y
 CONFIG_NET_DHCP=y
 CONFIG_NET_NFS=y
@@ -44,6 +45,8 @@ CONFIG_NET_NETCONSOLE=y
 CONFIG_NET_RESOLV=y
 CONFIG_SERIAL_AMBA_PL011=y
 CONFIG_DRIVER_NET_SMC91111=y
+CONFIG_I2C=y
+CONFIG_I2C_VERSATILE=y
 CONFIG_GPIO_PL061=y
 CONFIG_FS_CRAMFS=y
 CONFIG_SHA1=y
diff --git a/arch/arm/mach-versatile/core.c b/arch/arm/mach-versatile/core.c
index 6e913df..8aca2a1 100644
--- a/arch/arm/mach-versatile/core.c
+++ b/arch/arm/mach-versatile/core.c
@@ -26,6 +26,7 @@
 #include <init.h>
 #include <clock.h>
 #include <debug_ll.h>
+#include <sizes.h>
 
 #include <linux/clkdev.h>
 #include <linux/clk.h>
@@ -182,6 +183,12 @@ void versatile_register_uart(unsigned id)
 	amba_apb_device_add(NULL, "uart-pl011", id, start, 4096, NULL, 0);
 }
 
+void versatile_register_i2c(void)
+{
+	add_generic_device("versatile-i2c", DEVICE_ID_DYNAMIC, NULL,
+			VERSATILE_I2C_BASE, SZ_4K, IORESOURCE_MEM, NULL);
+}
+
 void __noreturn reset_cpu (unsigned long ignored)
 {
 	u32 val;
diff --git a/arch/arm/mach-versatile/include/mach/init.h b/arch/arm/mach-versatile/include/mach/init.h
index 878cde0..b40e4f9 100644
--- a/arch/arm/mach-versatile/include/mach/init.h
+++ b/arch/arm/mach-versatile/include/mach/init.h
@@ -4,5 +4,6 @@
 
 void versatile_add_sdram(u32 size);
 void versatile_register_uart(unsigned id);
+void versatile_register_i2c(void);
 
 #endif
-- 
1.7.10.4



From s.hauer at pengutronix.de  Thu Nov  1 07:49:31 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu,  1 Nov 2012 12:49:31 +0100
Subject: [PATCH] fix devicetree alignment
Message-ID: <1351770573-30009-1-git-send-email-s.hauer@pengutronix.de>

The following fixes a nasty problem with passing devicetrees to
the (ARM-) Kernel. In short, we are not allowed to cross 1MiB
boundaries with the devicetree. This can happen sometimes since
we allocate space for the devicetree using memalign(). I think
this is rather a kernel bug since this restriction is not documented
anywhere. Anyway, working around it in barebox is easy enough.

Sascha

----------------------------------------------------------------
Sascha Hauer (2):
      bootm: Add a define for the additional devicetree size
      bootm: Do not cross 1MiB sections for the devicetree

 commands/bootm.c |   19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)


From s.hauer at pengutronix.de  Thu Nov  1 07:49:32 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu,  1 Nov 2012 12:49:32 +0100
Subject: [PATCH 1/2] bootm: Add a define for the additional devicetree size
In-Reply-To: <1351770573-30009-1-git-send-email-s.hauer@pengutronix.de>
References: <1351770573-30009-1-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1351770573-30009-2-git-send-email-s.hauer@pengutronix.de>

The fixed devicetree may need more space than the original one.
We used to use 0x8000 here. Add a define for it to have the
space defined at a single place.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 commands/bootm.c |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/commands/bootm.c b/commands/bootm.c
index 20b49f0..d14ec2b 100644
--- a/commands/bootm.c
+++ b/commands/bootm.c
@@ -49,6 +49,11 @@
 
 static LIST_HEAD(handler_list);
 
+/*
+ * Additional oftree size for the fixed tree
+ */
+#define OFTREE_SIZE_INCREASE	0x8000
+
 int register_image_handler(struct image_handler *handler)
 {
 	list_add_tail(&handler->list, &handler_list);
@@ -184,12 +189,14 @@ static int bootm_open_oftree(struct image_data *data, const char *oftree, int nu
 				file_type_to_string(ft));
 	}
 
-	fixfdt = xmemalign(4096, size + 0x8000);
+	fixfdt = xmemalign(4096, size + OFTREE_SIZE_INCREASE);
 	memcpy(fixfdt, fdt, size);
 
+
+	ret = fdt_open_into(fdt, fixfdt, size + OFTREE_SIZE_INCREASE);
+
 	free(fdt);
 
-	ret = fdt_open_into(fixfdt, fixfdt, size + 0x8000);
 	if (ret) {
 		printf("unable to parse %s\n", oftree);
 		return -ENODEV;
-- 
1.7.10.4



From s.hauer at pengutronix.de  Thu Nov  1 07:49:33 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu,  1 Nov 2012 12:49:33 +0100
Subject: [PATCH 2/2] bootm: Do not cross 1MiB sections for the devicetree
In-Reply-To: <1351770573-30009-1-git-send-email-s.hauer@pengutronix.de>
References: <1351770573-30009-1-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1351770573-30009-3-git-send-email-s.hauer@pengutronix.de>

ARM Linux only maps a single 1MiB section for the devicetree. This has
a 1Mib alignment, so we are not allowed to cross such a boundary. Align
the devicetree to the next power of two so that this never happens.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 commands/bootm.c |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/commands/bootm.c b/commands/bootm.c
index d14ec2b..98d2e4f 100644
--- a/commands/bootm.c
+++ b/commands/bootm.c
@@ -141,6 +141,7 @@ static int bootm_open_oftree(struct image_data *data, const char *oftree, int nu
 	struct fdt_header *fdt, *fixfdt;
 	int ret;
 	size_t size;
+	unsigned int align;
 
 	if (bootm_verbose(data))
 		printf("Loading oftree from '%s'\n", oftree);
@@ -189,7 +190,14 @@ static int bootm_open_oftree(struct image_data *data, const char *oftree, int nu
 				file_type_to_string(ft));
 	}
 
-	fixfdt = xmemalign(4096, size + OFTREE_SIZE_INCREASE);
+	/*
+	 * ARM Linux uses a single 1MiB section (with 1MiB alignment)
+	 * for mapping the devicetree, so we are not allowed to cross
+	 * 1MiB boundaries.
+	 */
+	align = 1 << fls(size + OFTREE_SIZE_INCREASE - 1);
+
+	fixfdt = xmemalign(align, size + OFTREE_SIZE_INCREASE);
 	memcpy(fixfdt, fdt, size);
 
 
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Thu Nov  1 09:22:42 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu,  1 Nov 2012 14:22:42 +0100
Subject: [PATCH 1/1] input: add qt1070 touch keyboard support
Message-ID: <1351776162-23461-1-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/input/Kconfig  |    7 ++
 drivers/input/Makefile |    1 +
 drivers/input/qt1070.c |  228 ++++++++++++++++++++++++++++++++++++++++++++++++
 include/input/qt1070.h |   17 ++++
 4 files changed, 253 insertions(+)
 create mode 100644 drivers/input/qt1070.c
 create mode 100644 include/input/qt1070.h

diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig
index 15979a2..8c528b4 100644
--- a/drivers/input/Kconfig
+++ b/drivers/input/Kconfig
@@ -30,4 +30,11 @@ config KEYBOARD_IMX_KEYPAD
 	  setup logic must also provide a 'matrix_keymap_data' structure,
 	  defining the used keys.
 
+config KEYBOARD_QT1070
+	tristate "Atmel AT42QT1070 Touch Sensor Chip"
+	depends on I2C
+	help
+	  Say Y here if you want to use Atmel AT42QT1070 QTouch
+	  Sensor chip as input device.
+
 endmenu
diff --git a/drivers/input/Makefile b/drivers/input/Makefile
index 3d105cc..d042980 100644
--- a/drivers/input/Makefile
+++ b/drivers/input/Makefile
@@ -1,2 +1,3 @@
 obj-$(CONFIG_KEYBOARD_GPIO) += gpio_keys.o
 obj-$(CONFIG_KEYBOARD_IMX_KEYPAD) += imx_keypad.o
+obj-$(CONFIG_KEYBOARD_QT1070) += qt1070.o
diff --git a/drivers/input/qt1070.c b/drivers/input/qt1070.c
new file mode 100644
index 0000000..cd9c5a6
--- /dev/null
+++ b/drivers/input/qt1070.c
@@ -0,0 +1,228 @@
+/*
+ * Copyright (C) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
+ *
+ * Under GPLv2
+ */
+
+#include <common.h>
+#include <errno.h>
+#include <init.h>
+#include <clock.h>
+#include <poller.h>
+#include <kfifo.h>
+#include <i2c/i2c.h>
+#include <malloc.h>
+#include <readkey.h>
+#include <input/qt1070.h>
+
+#define QT1070_CHIP_ID		0x2e
+
+#define QT1070_READ_CHIP_ID	0x00
+#define QT1070_FW_VERSION	0x01
+#define QT1070_DET_STATUS	0x02
+#define QT1070_KEY_STATUS	0x03
+
+/* Calibrate */
+#define QT1070_CALIBRATE_CMD	0x38
+#define QT1070_CAL_TIME		200
+
+/* Reset */
+#define QT1070_RESET		0x39
+#define QT1070_RESET_TIME	255
+
+static int default_code[QT1070_NB_BUTTONS] = {
+	KEY_ENTER, KEY_HOME, KEY_UP, KEY_DOWN,
+	KEY_RIGHT, KEY_LEFT, KEY_CLEAR_SCREEN };
+
+struct qt1070_data {
+	int code[QT1070_NB_BUTTONS];
+
+	/* optional */
+	int fifo_size;
+
+	struct i2c_client *client;
+	u8 button_state[QT1070_NB_BUTTONS];
+	u8 previous_state;
+
+	struct kfifo *recv_fifo;
+	struct poller_struct poller;
+	struct console_device cdev;
+};
+
+static inline struct qt1070_data *
+poller_to_qt_data(struct poller_struct *poller)
+{
+	return container_of(poller, struct qt1070_data, poller);
+}
+
+static inline struct qt1070_data *
+cdev_to_qt_data(struct console_device *cdev)
+{
+	return container_of(cdev, struct qt1070_data, cdev);
+}
+
+static bool qt1070_read(struct qt1070_data *data, u8 reg, u8 *val)
+{
+	int ret;
+
+	ret = i2c_read_reg(data->client, reg, val, 1);
+
+	if (ret < 0)
+		return ret;
+	if (ret != 1)
+		return -EIO;
+	return 0;
+}
+
+static bool qt1070_write(struct qt1070_data *data, u8 reg, const u8 val)
+{
+	int ret;
+
+	ret = i2c_write_reg(data->client, reg, &val, 1);
+	if (ret < 0)
+		return ret;
+	if (ret != 1)
+		return -EIO;
+	return 0;
+}
+
+static void qt1070_poller(struct poller_struct *poller)
+{
+	struct qt1070_data *data = poller_to_qt_data(poller);
+	int i;
+	u8 buf, bt;
+	u8 mask = 0x1;
+
+	qt1070_read(data, QT1070_DET_STATUS, &buf);
+
+	if (qt1070_read(data, QT1070_KEY_STATUS, &buf))
+		return;
+
+	if (!buf & !data->previous_state)
+		return;
+
+	for (i = 0; i < QT1070_NB_BUTTONS; i++) {
+		bt = buf & mask;
+
+		if (!bt && data->button_state[i]) {
+			debug("release key(%d) as %d\n", i, data->code[i]);
+			kfifo_put(data->recv_fifo, (u_char*)&data->code[i], sizeof(int));
+		} else if (bt) {
+			debug("pressed key(%d) as %d\n", i, data->code[i]);
+		}
+
+		data->button_state[i] = bt;
+		mask <<= 1;
+	}
+
+	data->previous_state = buf;
+}
+
+static int qt1070_tstc(struct console_device *cdev)
+{
+	struct qt1070_data *data = cdev_to_qt_data(cdev);
+
+	return (kfifo_len(data->recv_fifo) == 0) ? 0 : 1;
+}
+
+static int qt1070_getc(struct console_device *cdev)
+{
+	int code = 0;
+	struct qt1070_data *data = cdev_to_qt_data(cdev);
+
+	kfifo_get(data->recv_fifo, (u_char*)&code, sizeof(int));
+	return code;
+}
+
+static int __init qt1070_probe(struct device_d *dev)
+{
+	struct console_device *cdev;
+	struct qt1070_data *data;
+	u8 fw_version, chip_id;
+	int ret;
+	char buf[6];
+
+	data = xzalloc(sizeof(*data));
+	data->client = to_i2c_client(dev);
+
+	ret = qt1070_read(data, QT1070_READ_CHIP_ID, &chip_id);
+	if (ret) {
+		dev_err(dev, "can not read chip id (%d)\n", ret);
+		goto err;
+	}
+
+	if (chip_id != QT1070_CHIP_ID) {
+		dev_err(dev, "unsupported id 0x%x\n", chip_id);
+		ret = -ENXIO;
+		goto err;
+	}
+
+	ret = qt1070_read(data, QT1070_FW_VERSION, &fw_version);
+	if (ret) {
+		dev_err(dev, "can not read firmware version (%d)\n", ret);
+		goto err;
+	}
+
+	sprintf(buf, "0x%x", fw_version);
+	dev_add_param_fixed(dev, "fw_version", buf);
+	sprintf(buf, "0x%x", chip_id);
+	dev_add_param_fixed(dev, "chip_ip", buf);
+
+	/* Calibrate device */
+	qt1070_write(data, QT1070_CALIBRATE_CMD, 1);
+	if (ret) {
+		dev_err(dev, "can not calibreate the chip (%d)\n", ret);
+		goto err;
+	}
+	mdelay(QT1070_CAL_TIME);
+
+	/* Soft reset */
+	ret = qt1070_write(data, QT1070_RESET, 1);
+	if (ret) {
+		dev_err(dev, "can not reset the chip (%d)\n", ret);
+		goto err;
+	}
+	mdelay(QT1070_RESET_TIME);
+
+	memcpy(data->code, default_code, sizeof(int) * ARRAY_SIZE(default_code));
+	if (dev->platform_data) {
+		struct qt1070_platform_data pdata = dev->platform_data;
+
+		memcpy(data->code, pdata->code, sizeof(int) * pdata->nb_code);
+	}
+
+	data->fifo_size = 50;
+	data->recv_fifo = kfifo_alloc(data->fifo_size);
+
+	data->poller.func = qt1070_poller;
+
+	cdev = &data->cdev;
+	dev->type_data = cdev;
+	cdev->dev = dev;
+	cdev->f_caps = CONSOLE_STDIN;
+	cdev->tstc = qt1070_tstc;
+	cdev->getc = qt1070_getc;
+
+	console_register(&data->cdev);
+
+	ret = poller_register(&data->poller);
+	if (ret)
+		goto err;
+
+	return 0;
+err:
+	free(data);
+	return ret;
+}
+
+static struct driver_d qt1070_driver = {
+	.name	= "qt1070",
+	.probe	= qt1070_probe,
+};
+
+static int qt1070_init(void)
+{
+	i2c_register_driver(&qt1070_driver);
+	return 0;
+}
+device_initcall(qt1070_init);
diff --git a/include/input/qt1070.h b/include/input/qt1070.h
new file mode 100644
index 0000000..8a29559
--- /dev/null
+++ b/include/input/qt1070.h
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
+ *
+ * Under GPLv2
+ */
+
+#ifndef __QT1070_H__
+#define __QT1070_H__
+
+#define QT1070_NB_BUTTONS	7
+
+struct qt1070_platform_data {
+	int code[QT1070_NB_BUTTONS];
+	int nb_code;
+};
+
+#endif /* __QT1070_H__ */
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Thu Nov  1 09:52:53 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu,  1 Nov 2012 14:52:53 +0100
Subject: [PATCH 1/1 v2] input: add qt1070 touch keyboard support
In-Reply-To: <1351776162-23461-1-git-send-email-plagnioj@jcrosoft.com>
References: <1351776162-23461-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1351777973-26024-1-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
fix typo add when checking the patch

Best Regards,
J.
 drivers/input/Kconfig  |    7 ++
 drivers/input/Makefile |    1 +
 drivers/input/qt1070.c |  228 ++++++++++++++++++++++++++++++++++++++++++++++++
 include/input/qt1070.h |   17 ++++
 4 files changed, 253 insertions(+)
 create mode 100644 drivers/input/qt1070.c
 create mode 100644 include/input/qt1070.h

diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig
index 15979a2..8c528b4 100644
--- a/drivers/input/Kconfig
+++ b/drivers/input/Kconfig
@@ -30,4 +30,11 @@ config KEYBOARD_IMX_KEYPAD
 	  setup logic must also provide a 'matrix_keymap_data' structure,
 	  defining the used keys.
 
+config KEYBOARD_QT1070
+	tristate "Atmel AT42QT1070 Touch Sensor Chip"
+	depends on I2C
+	help
+	  Say Y here if you want to use Atmel AT42QT1070 QTouch
+	  Sensor chip as input device.
+
 endmenu
diff --git a/drivers/input/Makefile b/drivers/input/Makefile
index 3d105cc..d042980 100644
--- a/drivers/input/Makefile
+++ b/drivers/input/Makefile
@@ -1,2 +1,3 @@
 obj-$(CONFIG_KEYBOARD_GPIO) += gpio_keys.o
 obj-$(CONFIG_KEYBOARD_IMX_KEYPAD) += imx_keypad.o
+obj-$(CONFIG_KEYBOARD_QT1070) += qt1070.o
diff --git a/drivers/input/qt1070.c b/drivers/input/qt1070.c
new file mode 100644
index 0000000..49cd836
--- /dev/null
+++ b/drivers/input/qt1070.c
@@ -0,0 +1,228 @@
+/*
+ * Copyright (C) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
+ *
+ * Under GPLv2
+ */
+
+#include <common.h>
+#include <errno.h>
+#include <init.h>
+#include <clock.h>
+#include <poller.h>
+#include <kfifo.h>
+#include <i2c/i2c.h>
+#include <malloc.h>
+#include <readkey.h>
+#include <input/qt1070.h>
+
+#define QT1070_CHIP_ID		0x2e
+
+#define QT1070_READ_CHIP_ID	0x00
+#define QT1070_FW_VERSION	0x01
+#define QT1070_DET_STATUS	0x02
+#define QT1070_KEY_STATUS	0x03
+
+/* Calibrate */
+#define QT1070_CALIBRATE_CMD	0x38
+#define QT1070_CAL_TIME		200
+
+/* Reset */
+#define QT1070_RESET		0x39
+#define QT1070_RESET_TIME	255
+
+static int default_code[QT1070_NB_BUTTONS] = {
+	KEY_ENTER, KEY_HOME, KEY_UP, KEY_DOWN,
+	KEY_RIGHT, KEY_LEFT, KEY_CLEAR_SCREEN };
+
+struct qt1070_data {
+	int code[QT1070_NB_BUTTONS];
+
+	/* optional */
+	int fifo_size;
+
+	struct i2c_client *client;
+	u8 button_state[QT1070_NB_BUTTONS];
+	u8 previous_state;
+
+	struct kfifo *recv_fifo;
+	struct poller_struct poller;
+	struct console_device cdev;
+};
+
+static inline struct qt1070_data *
+poller_to_qt_data(struct poller_struct *poller)
+{
+	return container_of(poller, struct qt1070_data, poller);
+}
+
+static inline struct qt1070_data *
+cdev_to_qt_data(struct console_device *cdev)
+{
+	return container_of(cdev, struct qt1070_data, cdev);
+}
+
+static bool qt1070_read(struct qt1070_data *data, u8 reg, u8 *val)
+{
+	int ret;
+
+	ret = i2c_read_reg(data->client, reg, val, 1);
+
+	if (ret < 0)
+		return ret;
+	if (ret != 1)
+		return -EIO;
+	return 0;
+}
+
+static bool qt1070_write(struct qt1070_data *data, u8 reg, const u8 val)
+{
+	int ret;
+
+	ret = i2c_write_reg(data->client, reg, &val, 1);
+	if (ret < 0)
+		return ret;
+	if (ret != 1)
+		return -EIO;
+	return 0;
+}
+
+static void qt1070_poller(struct poller_struct *poller)
+{
+	struct qt1070_data *data = poller_to_qt_data(poller);
+	int i;
+	u8 buf, bt;
+	u8 mask = 0x1;
+
+	qt1070_read(data, QT1070_DET_STATUS, &buf);
+
+	if (qt1070_read(data, QT1070_KEY_STATUS, &buf))
+		return;
+
+	if (!buf & !data->previous_state)
+		return;
+
+	for (i = 0; i < QT1070_NB_BUTTONS; i++) {
+		bt = buf & mask;
+
+		if (!bt && data->button_state[i]) {
+			debug("release key(%d) as %d\n", i, data->code[i]);
+			kfifo_put(data->recv_fifo, (u_char*)&data->code[i], sizeof(int));
+		} else if (bt) {
+			debug("pressed key(%d) as %d\n", i, data->code[i]);
+		}
+
+		data->button_state[i] = bt;
+		mask <<= 1;
+	}
+
+	data->previous_state = buf;
+}
+
+static int qt1070_tstc(struct console_device *cdev)
+{
+	struct qt1070_data *data = cdev_to_qt_data(cdev);
+
+	return (kfifo_len(data->recv_fifo) == 0) ? 0 : 1;
+}
+
+static int qt1070_getc(struct console_device *cdev)
+{
+	int code = 0;
+	struct qt1070_data *data = cdev_to_qt_data(cdev);
+
+	kfifo_get(data->recv_fifo, (u_char*)&code, sizeof(int));
+	return code;
+}
+
+static int __init qt1070_probe(struct device_d *dev)
+{
+	struct console_device *cdev;
+	struct qt1070_data *data;
+	u8 fw_version, chip_id;
+	int ret;
+	char buf[6];
+
+	data = xzalloc(sizeof(*data));
+	data->client = to_i2c_client(dev);
+
+	ret = qt1070_read(data, QT1070_READ_CHIP_ID, &chip_id);
+	if (ret) {
+		dev_err(dev, "can not read chip id (%d)\n", ret);
+		goto err;
+	}
+
+	if (chip_id != QT1070_CHIP_ID) {
+		dev_err(dev, "unsupported id 0x%x\n", chip_id);
+		ret = -ENXIO;
+		goto err;
+	}
+
+	ret = qt1070_read(data, QT1070_FW_VERSION, &fw_version);
+	if (ret) {
+		dev_err(dev, "can not read firmware version (%d)\n", ret);
+		goto err;
+	}
+
+	sprintf(buf, "0x%x", fw_version);
+	dev_add_param_fixed(dev, "fw_version", buf);
+	sprintf(buf, "0x%x", chip_id);
+	dev_add_param_fixed(dev, "chip_ip", buf);
+
+	/* Calibrate device */
+	qt1070_write(data, QT1070_CALIBRATE_CMD, 1);
+	if (ret) {
+		dev_err(dev, "can not calibreate the chip (%d)\n", ret);
+		goto err;
+	}
+	mdelay(QT1070_CAL_TIME);
+
+	/* Soft reset */
+	ret = qt1070_write(data, QT1070_RESET, 1);
+	if (ret) {
+		dev_err(dev, "can not reset the chip (%d)\n", ret);
+		goto err;
+	}
+	mdelay(QT1070_RESET_TIME);
+
+	memcpy(data->code, default_code, sizeof(int) * ARRAY_SIZE(default_code));
+	if (dev->platform_data) {
+		struct qt1070_platform_data *pdata = dev->platform_data;
+
+		memcpy(data->code, pdata->code, sizeof(int) * pdata->nb_code);
+	}
+
+	data->fifo_size = 50;
+	data->recv_fifo = kfifo_alloc(data->fifo_size);
+
+	data->poller.func = qt1070_poller;
+
+	cdev = &data->cdev;
+	dev->type_data = cdev;
+	cdev->dev = dev;
+	cdev->f_caps = CONSOLE_STDIN;
+	cdev->tstc = qt1070_tstc;
+	cdev->getc = qt1070_getc;
+
+	console_register(&data->cdev);
+
+	ret = poller_register(&data->poller);
+	if (ret)
+		goto err;
+
+	return 0;
+err:
+	free(data);
+	return ret;
+}
+
+static struct driver_d qt1070_driver = {
+	.name	= "qt1070",
+	.probe	= qt1070_probe,
+};
+
+static int qt1070_init(void)
+{
+	i2c_register_driver(&qt1070_driver);
+	return 0;
+}
+device_initcall(qt1070_init);
diff --git a/include/input/qt1070.h b/include/input/qt1070.h
new file mode 100644
index 0000000..8a29559
--- /dev/null
+++ b/include/input/qt1070.h
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
+ *
+ * Under GPLv2
+ */
+
+#ifndef __QT1070_H__
+#define __QT1070_H__
+
+#define QT1070_NB_BUTTONS	7
+
+struct qt1070_platform_data {
+	int code[QT1070_NB_BUTTONS];
+	int nb_code;
+};
+
+#endif /* __QT1070_H__ */
-- 
1.7.10.4



From s.hauer at pengutronix.de  Thu Nov  1 10:14:21 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu,  1 Nov 2012 15:14:21 +0100
Subject: [PATCH] command: return 1 on unknown command
Message-ID: <1351779261-10913-1-git-send-email-s.hauer@pengutronix.de>

hush now prints the error value if a command returns a value < 0,
so do not return -1 (EPERM) when we encounter an unknown command.
Instead, return 1 so that hush is quiet.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 common/command.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/command.c b/common/command.c
index 873b3ff..7f2b777 100644
--- a/common/command.c
+++ b/common/command.c
@@ -85,7 +85,7 @@ int execute_command(int argc, char **argv)
 #else
 		printf ("Unknown command '%s'\n", argv[0]);
 #endif
-		ret = -1;	/* give up after bad command */
+		ret = 1;	/* give up after bad command */
 	}
 
 	getopt_context_restore(&gc);
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Thu Nov  1 10:33:52 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu, 1 Nov 2012 15:33:52 +0100
Subject: [PATCH 0/7] at91 add i2c-gpio suport
Message-ID: <20121101143352.GJ29599@game.jcrosoft.org>

Hi,

	This paatch serie add the i2c suport to at91 using the i2c-gpio as teh
	IP is broken until the sam9x5. For the sam9x5 untill we have the hw
	driver support use the i2c-gpio too

	on the sam9x5ek enable the i2c and the qt1070

	This patch serie depends on i2c qt1070 patch and the at91sam9x5ek
	1-wire one

The following changes since commit 3a5609a37a19b0b6b5f4c61e3c561b7bf2d25b72:

  i2c: add versatile support (2012-11-01 06:58:21 +0800)

are available in the git repository at:

  git://git.jcrosoft.org/barebox.git delivery/at91_i2c

for you to fetch changes up to 2d2aee2451a0210cfb0d141db7729b648d0a32a4:

  at91sam9x5ek: add i2c support (2012-11-01 06:58:25 +0800)

----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (7):
      at91sam9x5: add i2c support
      at91rm9200: add i2c support
      at91sam9260/sam9g20: add i2c support
      at91sam9263: add i2c support
      at91sam9261/sam9g10: add i2c support
      at91sam9g45: add i2c support
      at91sam9x5ek: add i2c support

 arch/arm/boards/at91sam9x5ek/init.c      |   12 ++++++++++++
 arch/arm/configs/at91sam9x5ek_defconfig  |    5 ++++-
 arch/arm/mach-at91/at91rm9200_devices.c  |   28 ++++++++++++++++++++++++++++
 arch/arm/mach-at91/at91sam9260_devices.c |   32 ++++++++++++++++++++++++++++++++
 arch/arm/mach-at91/at91sam9261_devices.c |   31 +++++++++++++++++++++++++++++++
 arch/arm/mach-at91/at91sam9263_devices.c |   31 +++++++++++++++++++++++++++++++
 arch/arm/mach-at91/at91sam9g45_devices.c |   50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-at91/at91sam9x5_devices.c  |   58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-at91/include/mach/board.h  |    3 +++
 9 files changed, 249 insertions(+), 1 deletion(-)

Best Regards,
J.


From plagnioj at jcrosoft.com  Thu Nov  1 11:07:24 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu,  1 Nov 2012 16:07:24 +0100
Subject: [PATCH 4/7] at91sam9263: add i2c support
In-Reply-To: <1351782447-32199-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121101143352.GJ29599@game.jcrosoft.org>
 <1351782447-32199-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1351782447-32199-4-git-send-email-plagnioj@jcrosoft.com>

use i2c-gpio as the hw ip is broken

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/mach-at91/at91sam9263_devices.c |   31 ++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/arch/arm/mach-at91/at91sam9263_devices.c b/arch/arm/mach-at91/at91sam9263_devices.c
index e686480..deffc27 100644
--- a/arch/arm/mach-at91/at91sam9263_devices.c
+++ b/arch/arm/mach-at91/at91sam9263_devices.c
@@ -19,6 +19,7 @@
 #include <mach/board.h>
 #include <mach/gpio.h>
 #include <mach/io.h>
+#include <i2c/i2c-gpio.h>
 
 #include "generic.h"
 
@@ -157,6 +158,36 @@ void at91_add_device_nand(struct atmel_nand_data *data) {}
 #endif
 
 /* --------------------------------------------------------------------
+ *  TWI (i2c)
+ * -------------------------------------------------------------------- */
+#if defined(CONFIG_I2C_GPIO)
+static struct i2c_gpio_platform_data pdata_i2c = {
+	.sda_pin		= AT91_PIN_PB4,
+	.sda_is_open_drain	= 1,
+	.scl_pin		= AT91_PIN_PB5,
+	.scl_is_open_drain	= 1,
+	.udelay			= 5,		/* ~100 kHz */
+};
+
+void at91_add_device_i2c(short i2c_id, struct i2c_board_info *devices, int nr_devices)
+{
+	struct i2c_gpio_platform_data *pdata = &pdata_i2c;
+
+	i2c_register_board_info(0, devices, nr_devices);
+
+	at91_set_GPIO_periph(pdata->sda_pin, 1);		/* TWD (SDA) */
+	at91_set_multi_drive(pdata->sda_pin, 1);
+
+	at91_set_GPIO_periph(pdata->scl_pin, 1);		/* TWCK (SCL) */
+	at91_set_multi_drive(pdata->scl_pin, 1);
+
+	add_generic_device_res("i2c-gpio", 0, NULL, 0, pdata);
+}
+#else
+void at91_add_device_i2c(short i2c_id, struct i2c_board_info *devices, int nr_devices) {}
+#endif
+
+/* --------------------------------------------------------------------
  *  SPI
  * -------------------------------------------------------------------- */
 
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Thu Nov  1 11:07:25 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu,  1 Nov 2012 16:07:25 +0100
Subject: [PATCH 5/7] at91sam9261/sam9g10: add i2c support
In-Reply-To: <1351782447-32199-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121101143352.GJ29599@game.jcrosoft.org>
 <1351782447-32199-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1351782447-32199-5-git-send-email-plagnioj@jcrosoft.com>

use i2c-gpio as the hw ip is broken

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/mach-at91/at91sam9261_devices.c |   31 ++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/arch/arm/mach-at91/at91sam9261_devices.c b/arch/arm/mach-at91/at91sam9261_devices.c
index 0091e2d..68d75c3 100644
--- a/arch/arm/mach-at91/at91sam9261_devices.c
+++ b/arch/arm/mach-at91/at91sam9261_devices.c
@@ -20,6 +20,7 @@
 #include <mach/gpio.h>
 #include <mach/io.h>
 #include <mach/cpu.h>
+#include <i2c/i2c-gpio.h>
 
 #include "generic.h"
 
@@ -107,6 +108,36 @@ void at91_add_device_nand(struct atmel_nand_data *data) {}
 #endif
 
 /* --------------------------------------------------------------------
+ *  TWI (i2c)
+ * -------------------------------------------------------------------- */
+#if defined(CONFIG_I2C_GPIO)
+static struct i2c_gpio_platform_data pdata_i2c = {
+	.sda_pin		= AT91_PIN_PA7,
+	.sda_is_open_drain	= 1,
+	.scl_pin		= AT91_PIN_PA8,
+	.scl_is_open_drain	= 1,
+	.udelay			= 5,		/* ~100 kHz */
+};
+
+void at91_add_device_i2c(short i2c_id, struct i2c_board_info *devices, int nr_devices)
+{
+	struct i2c_gpio_platform_data *pdata = &pdata_i2c;
+
+	i2c_register_board_info(0, devices, nr_devices);
+
+	at91_set_GPIO_periph(pdata->sda_pin, 1);		/* TWD (SDA) */
+	at91_set_multi_drive(pdata->sda_pin, 1);
+
+	at91_set_GPIO_periph(pdata->scl_pin, 1);		/* TWCK (SCL) */
+	at91_set_multi_drive(pdata->scl_pin, 1);
+
+	add_generic_device_res("i2c-gpio", 0, NULL, 0, pdata);
+}
+#else
+void at91_add_device_i2c(short i2c_id, struct i2c_board_info *devices, int nr_devices) {}
+#endif
+
+/* --------------------------------------------------------------------
  *  SPI
  * -------------------------------------------------------------------- */
 
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Thu Nov  1 11:07:22 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu,  1 Nov 2012 16:07:22 +0100
Subject: [PATCH 2/7] at91rm9200: add i2c support
In-Reply-To: <1351782447-32199-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121101143352.GJ29599@game.jcrosoft.org>
 <1351782447-32199-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1351782447-32199-2-git-send-email-plagnioj@jcrosoft.com>

use i2c-gpio as the hw ip is broken

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/mach-at91/at91rm9200_devices.c |   28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/arch/arm/mach-at91/at91rm9200_devices.c b/arch/arm/mach-at91/at91rm9200_devices.c
index 8cb2f57..1a2d0fd 100644
--- a/arch/arm/mach-at91/at91rm9200_devices.c
+++ b/arch/arm/mach-at91/at91rm9200_devices.c
@@ -18,6 +18,7 @@
 #include <mach/gpio.h>
 #include <mach/io.h>
 #include <mach/at91rm9200_mc.h>
+#include <i2c/i2c-gpio.h>
 #include <sizes.h>
 
 #include "generic.h"
@@ -154,6 +155,33 @@ void __init at91_add_device_nand(struct atmel_nand_data *data)
 void __init at91_add_device_nand(struct atmel_nand_data *data) {}
 #endif
 
+#if defined(CONFIG_I2C_GPIO)
+static struct i2c_gpio_platform_data pdata_i2c = {
+	.sda_pin		= AT91_PIN_PA25,
+	.sda_is_open_drain	= 1,
+	.scl_pin		= AT91_PIN_PA26,
+	.scl_is_open_drain	= 1,
+	.udelay			= 5,		/* ~100 kHz */
+};
+
+void at91_add_device_i2c(short i2c_id, struct i2c_board_info *devices, int nr_devices)
+{
+	struct i2c_gpio_platform_data *pdata = &pdata_i2c;
+
+	i2c_register_board_info(0, devices, nr_devices);
+
+	at91_set_GPIO_periph(pdata->sda_pin, 1);		/* TWD (SDA) */
+	at91_set_multi_drive(pdata->sda_pin, 1);
+
+	at91_set_GPIO_periph(pdata->scl_pin, 1);		/* TWCK (SCL) */
+	at91_set_multi_drive(pdata->scl_pin, 1);
+
+	add_generic_device_res("i2c-gpio", 0, NULL, 0, pdata);
+}
+#else
+void at91_add_device_i2c(short i2c_id, struct i2c_board_info *devices, int nr_devices) {}
+#endif
+
 /* --------------------------------------------------------------------
  *  SPI
  * -------------------------------------------------------------------- */
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Thu Nov  1 11:07:23 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu,  1 Nov 2012 16:07:23 +0100
Subject: [PATCH 3/7] at91sam9260/sam9g20: add i2c support
In-Reply-To: <1351782447-32199-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121101143352.GJ29599@game.jcrosoft.org>
 <1351782447-32199-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1351782447-32199-3-git-send-email-plagnioj@jcrosoft.com>

use i2c-gpio as the hw ip is broken

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/mach-at91/at91sam9260_devices.c |   32 ++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/arch/arm/mach-at91/at91sam9260_devices.c b/arch/arm/mach-at91/at91sam9260_devices.c
index 9c9534e..7450ec1 100644
--- a/arch/arm/mach-at91/at91sam9260_devices.c
+++ b/arch/arm/mach-at91/at91sam9260_devices.c
@@ -20,6 +20,7 @@
 #include <mach/gpio.h>
 #include <mach/io.h>
 #include <mach/cpu.h>
+#include <i2c/i2c-gpio.h>
 
 #include "generic.h"
 
@@ -155,6 +156,37 @@ void at91_add_device_nand(struct atmel_nand_data *data) {}
 #endif
 
 /* --------------------------------------------------------------------
+ *  TWI (i2c)
+ * -------------------------------------------------------------------- */
+
+#if defined(CONFIG_I2C_GPIO)
+static struct i2c_gpio_platform_data pdata_i2c = {
+	.sda_pin		= AT91_PIN_PA23,
+	.sda_is_open_drain	= 1,
+	.scl_pin		= AT91_PIN_PA24,
+	.scl_is_open_drain	= 1,
+	.udelay			= 5,		/* ~100 kHz */
+};
+
+void at91_add_device_i2c(short i2c_id, struct i2c_board_info *devices, int nr_devices)
+{
+	struct i2c_gpio_platform_data *pdata = &pdata_i2c;
+
+	i2c_register_board_info(0, devices, nr_devices);
+
+	at91_set_GPIO_periph(pdata->sda_pin, 1);		/* TWD (SDA) */
+	at91_set_multi_drive(pdata->sda_pin, 1);
+
+	at91_set_GPIO_periph(pdata->scl_pin, 1);		/* TWCK (SCL) */
+	at91_set_multi_drive(pdata->scl_pin, 1);
+
+	add_generic_device_res("i2c-gpio", 0, NULL, 0, pdata);
+}
+#else
+void at91_add_device_i2c(short i2c_id, struct i2c_board_info *devices, int nr_devices) {}
+#endif
+
+/* --------------------------------------------------------------------
  *  SPI
  * -------------------------------------------------------------------- */
 
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Thu Nov  1 11:07:27 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu,  1 Nov 2012 16:07:27 +0100
Subject: [PATCH 7/7] at91sam9x5ek: add i2c support
In-Reply-To: <1351782447-32199-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121101143352.GJ29599@game.jcrosoft.org>
 <1351782447-32199-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1351782447-32199-7-git-send-email-plagnioj@jcrosoft.com>

enable qt1070 support

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/boards/at91sam9x5ek/init.c     |   12 ++++++++++++
 arch/arm/configs/at91sam9x5ek_defconfig |    5 ++++-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boards/at91sam9x5ek/init.c b/arch/arm/boards/at91sam9x5ek/init.c
index 78f7349..48eebac 100644
--- a/arch/arm/boards/at91sam9x5ek/init.c
+++ b/arch/arm/boards/at91sam9x5ek/init.c
@@ -114,6 +114,17 @@ static void ek_add_device_eth(void)
 	at91_add_device_eth(0, &macb_pdata);
 }
 
+static struct i2c_board_info i2c_devices[] = {
+	{
+		I2C_BOARD_INFO("qt1070", 0x1b),
+	},
+};
+
+static void ek_add_device_i2c(void)
+{
+	at91_add_device_i2c(0, i2c_devices, ARRAY_SIZE(i2c_devices));
+}
+
 /*
  * USB Host port
  */
@@ -172,6 +183,7 @@ static int at91sam9x5ek_devices_init(void)
 	ek_add_device_eth();
 	at91_add_device_usbh_ohci(&ek_usbh_data);
 	ek_add_led();
+	ek_add_device_i2c();
 
 	armlinux_set_bootparams((void *)(AT91_CHIPSELECT_1 + 0x100));
 	armlinux_set_architecture(CONFIG_MACH_AT91SAM9X5EK);
diff --git a/arch/arm/configs/at91sam9x5ek_defconfig b/arch/arm/configs/at91sam9x5ek_defconfig
index 6315d9f..3e66c44 100644
--- a/arch/arm/configs/at91sam9x5ek_defconfig
+++ b/arch/arm/configs/at91sam9x5ek_defconfig
@@ -41,6 +41,7 @@ CONFIG_CMD_OFTREE=y
 CONFIG_CMD_TIMEOUT=y
 CONFIG_CMD_PARTITION=y
 CONFIG_CMD_GPIO=y
+CONFIG_CMD_I2C=y
 CONFIG_CMD_LED=y
 CONFIG_CMD_LED_TRIGGER=y
 CONFIG_NET=y
@@ -52,6 +53,8 @@ CONFIG_FS_TFTP=y
 CONFIG_NET_NETCONSOLE=y
 CONFIG_DRIVER_NET_MACB=y
 # CONFIG_SPI is not set
+CONFIG_I2C=y
+CONFIG_I2C_GPIO=y
 CONFIG_MTD=y
 CONFIG_NAND=y
 # CONFIG_NAND_ECC_HW is not set
@@ -64,7 +67,7 @@ CONFIG_DISK_WRITE=y
 CONFIG_LED=y
 CONFIG_LED_GPIO=y
 CONFIG_LED_TRIGGERS=y
-CONFIG_KEYBOARD_GPIO=y
+CONFIG_KEYBOARD_QT1070=y
 CONFIG_W1=y
 CONFIG_W1_MASTER_GPIO=y
 CONFIG_W1_SLAVE_DS2431=y
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Thu Nov  1 11:07:21 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu,  1 Nov 2012 16:07:21 +0100
Subject: [PATCH 1/7] at91sam9x5: add i2c support
In-Reply-To: <20121101143352.GJ29599@game.jcrosoft.org>
References: <20121101143352.GJ29599@game.jcrosoft.org>
Message-ID: <1351782447-32199-1-git-send-email-plagnioj@jcrosoft.com>

use i2c-gpio until we add the hw drivers

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/mach-at91/at91sam9x5_devices.c |   58 +++++++++++++++++++++++++++++++
 arch/arm/mach-at91/include/mach/board.h |    3 ++
 2 files changed, 61 insertions(+)

diff --git a/arch/arm/mach-at91/at91sam9x5_devices.c b/arch/arm/mach-at91/at91sam9x5_devices.c
index 26a380d..5a24325 100644
--- a/arch/arm/mach-at91/at91sam9x5_devices.c
+++ b/arch/arm/mach-at91/at91sam9x5_devices.c
@@ -19,6 +19,7 @@
 #include <mach/gpio.h>
 #include <mach/io.h>
 #include <mach/cpu.h>
+#include <i2c/i2c-gpio.h>
 
 #include "generic.h"
 
@@ -169,6 +170,63 @@ void __init at91_add_device_nand(struct atmel_nand_data *data)
 void __init at91_add_device_nand(struct atmel_nand_data *data) {}
 #endif
 
+#if defined(CONFIG_I2C_GPIO)
+static struct i2c_gpio_platform_data pdata_i2c0 = {
+	.sda_pin		= AT91_PIN_PA30,
+	.sda_is_open_drain	= 1,
+	.scl_pin		= AT91_PIN_PA31,
+	.scl_is_open_drain	= 1,
+	.udelay			= 5,		/* ~100 kHz */
+};
+
+static struct i2c_gpio_platform_data pdata_i2c1 = {
+	.sda_pin		= AT91_PIN_PC0,
+	.sda_is_open_drain	= 1,
+	.scl_pin		= AT91_PIN_PC1,
+	.scl_is_open_drain	= 1,
+	.udelay			= 5,		/* ~100 kHz */
+};
+
+static struct i2c_gpio_platform_data pdata_i2c2 = {
+	.sda_pin		= AT91_PIN_PB4,
+	.sda_is_open_drain	= 1,
+	.scl_pin		= AT91_PIN_PB5,
+	.scl_is_open_drain	= 1,
+	.udelay			= 5,		/* ~100 kHz */
+};
+
+void at91_add_device_i2c(short i2c_id, struct i2c_board_info *devices, int nr_devices)
+{
+	struct i2c_gpio_platform_data *pdata;
+
+	i2c_register_board_info(i2c_id, devices, nr_devices);
+
+	switch (i2c_id) {
+	case 0:
+		pdata = &pdata_i2c0;
+		break;
+	case 1:
+		pdata = &pdata_i2c1;
+		break;
+	case 2:
+		pdata = &pdata_i2c2;
+		break;
+	default:
+		return;
+	}
+
+	at91_set_GPIO_periph(pdata->sda_pin, 1);		/* TWD (SDA) */
+	at91_set_multi_drive(pdata->sda_pin, 1);
+
+	at91_set_GPIO_periph(pdata->scl_pin, 1);		/* TWCK (SCL) */
+	at91_set_multi_drive(pdata->scl_pin, 1);
+
+	add_generic_device_res("i2c-gpio", i2c_id, NULL, 0, pdata);
+}
+#else
+void at91_add_device_i2c(short i2c_id, struct i2c_board_info *devices, int nr_devices) {}
+#endif
+
 /* --------------------------------------------------------------------
  *  UART
  * -------------------------------------------------------------------- */
diff --git a/arch/arm/mach-at91/include/mach/board.h b/arch/arm/mach-at91/include/mach/board.h
index 670c73d..1ce0762 100644
--- a/arch/arm/mach-at91/include/mach/board.h
+++ b/arch/arm/mach-at91/include/mach/board.h
@@ -21,6 +21,7 @@
 #include <mach/hardware.h>
 #include <sizes.h>
 #include <net.h>
+#include <i2c/i2c.h>
 #include <spi/spi.h>
 #include <linux/mtd/mtd.h>
 
@@ -71,6 +72,8 @@ struct at91_ether_platform_data {
 
 void at91_add_device_eth(int id, struct at91_ether_platform_data *data);
 
+void at91_add_device_i2c(short i2c_id, struct i2c_board_info *devices, int nr_devices);
+
 /* SDRAM */
 void at91_add_device_sdram(u32 size);
 
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Thu Nov  1 11:07:26 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu,  1 Nov 2012 16:07:26 +0100
Subject: [PATCH 6/7] at91sam9g45: add i2c support
In-Reply-To: <1351782447-32199-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121101143352.GJ29599@game.jcrosoft.org>
 <1351782447-32199-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1351782447-32199-6-git-send-email-plagnioj@jcrosoft.com>

use i2c-gpio as the hw ip is broken

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/mach-at91/at91sam9g45_devices.c |   50 ++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/arch/arm/mach-at91/at91sam9g45_devices.c b/arch/arm/mach-at91/at91sam9g45_devices.c
index 22b455e..35cd2e7 100644
--- a/arch/arm/mach-at91/at91sam9g45_devices.c
+++ b/arch/arm/mach-at91/at91sam9g45_devices.c
@@ -18,6 +18,7 @@
 #include <mach/board.h>
 #include <mach/gpio.h>
 #include <mach/io.h>
+#include <i2c/i2c-gpio.h>
 
 #include "generic.h"
 
@@ -132,6 +133,55 @@ void at91_add_device_nand(struct atmel_nand_data *data)
 void at91_add_device_nand(struct atmel_nand_data *data) {}
 #endif
 
+/* --------------------------------------------------------------------
+ *  TWI (i2c)
+ * -------------------------------------------------------------------- */
+#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
+static struct i2c_gpio_platform_data pdata_i2c0 = {
+	.sda_pin		= AT91_PIN_PA20,
+	.sda_is_open_drain	= 1,
+	.scl_pin		= AT91_PIN_PA21,
+	.scl_is_open_drain	= 1,
+	.udelay			= 5,		/* ~100 kHz */
+};
+
+static struct i2c_gpio_platform_data pdata_i2c1 = {
+	.sda_pin		= AT91_PIN_PB10,
+	.sda_is_open_drain	= 1,
+	.scl_pin		= AT91_PIN_PB11,
+	.scl_is_open_drain	= 1,
+	.udelay			= 5,		/* ~100 kHz */
+};
+
+void at91_add_device_i2c(short i2c_id, struct i2c_board_info *devices, int nr_devices)
+{
+	struct i2c_gpio_platform_data *pdata = &pdata_i2c;
+
+	i2c_register_board_info(i2c_id, devices, nr_devices);
+
+	switch (i2c_id) {
+	case 0;
+		pdata = &pdata_i2c0;
+		break;
+	case 1;
+		pdata = &pdata_i2c1;
+		break;
+	default:
+		return;
+	}
+
+	at91_set_GPIO_periph(pdata->sda_pin, 1);		/* TWD (SDA) */
+	at91_set_multi_drive(pdata->sda_pin, 1);
+
+	at91_set_GPIO_periph(pdata->scl_pin, 1);		/* TWCK (SCL) */
+	at91_set_multi_drive(pdata->scl_pin, 1);
+
+	add_generic_device_res("i2c-gpio", i2c_id, NULL, 0, pdata);
+}
+#else
+void at91_add_device_i2c(short i2c_id, struct i2c_board_info *devices, int nr_devices) {}
+#endif
+
 resource_size_t __init at91_configure_dbgu(void)
 {
 	at91_set_A_periph(AT91_PIN_PB12, 0);		/* DRXD */
-- 
1.7.10.4



From s.hauer at pengutronix.de  Thu Nov  1 11:29:05 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu, 1 Nov 2012 16:29:05 +0100
Subject: [PATCH 1/1] at91sam9xek: fix mtd partition
In-Reply-To: <1351698431-15255-1-git-send-email-plagnioj@jcrosoft.com>
References: <1351698431-15255-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <20121101152905.GU1641@pengutronix.de>

On Wed, Oct 31, 2012 at 04:47:11PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> barebox size is 384KiB
> and for the official atmel release we need to rootfs at 8M
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>

Applied, thanks

Sascha

> ---
>  arch/arm/boards/at91sam9x5ek/env/config |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/boards/at91sam9x5ek/env/config b/arch/arm/boards/at91sam9x5ek/env/config
> index 19457be..b8cf4e3 100644
> --- a/arch/arm/boards/at91sam9x5ek/env/config
> +++ b/arch/arm/boards/at91sam9x5ek/env/config
> @@ -22,6 +22,7 @@ oftree_loc=nfs
>  # can be either 'jffs2' or 'ubifs'
>  rootfs_type=ubifs
>  rootfsimage=root.$rootfs_type
> +ubiroot=rootfs
>  
>  # The image type of the kernel. Can be uimage, zimage, raw, or raw_lzo
>  kernelimage=zImage
> @@ -30,7 +31,7 @@ kernelimage=zImage
>  #kernelimage=Image.lzo
>  
>  nand_device=atmel_nand
> -nand_parts="256k(at91bootstrap),256k(barebox)ro,128k(bareboxenv),128k(bareboxenv2),128k(oftree),1M(free),4M(kernel),120M(rootfs),-(data)"
> +nand_parts="256k(at91bootstrap),384k(barebox)ro,128k(bareboxenv),128k(bareboxenv2),128k(oftree),1M(free),6M(kernel),120M(rootfs),-(data)"
>  rootfs_mtdblock_nand=7
>  
>  autoboot_timeout=3
> -- 
> 1.7.10.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Thu Nov  1 11:29:52 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu, 1 Nov 2012 16:29:52 +0100
Subject: [PATCH 0/8 v3] pm9g45/pm9253/pm9261: add 1-wire support
In-Reply-To: <20121030205459.GE29599@game.jcrosoft.org>
References: <20121030205459.GE29599@game.jcrosoft.org>
Message-ID: <20121101152952.GV1641@pengutronix.de>

On Tue, Oct 30, 2012 at 09:54:59PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> Hi,
> 
> 	v3: comment
> 
> 	v2: fixup and add comment
> 
> 	add 1-wire support for:
> 	 - pm9g45
> 	 - pm9263
> 	 - pm9261
> 
> 	use the 1-wire uniq id to generate a local mac address
> 	The OUI will be 'ron' => 72:6F:6E
> 
> 	The patch series go on the top of the 1-wire support v2
> 
> The following changes since commit acaa716bce8cd1373cb5dabff54332fb1da7355b:
> 
>   1-wire: add ds2433 support (2012-10-29 04:46:21 +0800)
> 
> are available in the git repository at:
> 
>   git://git.jcrosoft.org/barebox.git delivery/ronetix_w1
> 
> for you to fetch changes up to 7fb0cb2ce2f7800341ab8de711dccbd2c4753c84:
> 
>   pm9261: use w1 serial number to generate local mac address (2012-10-30 13:44:54 +0800)

Applied, thanks.

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Thu Nov  1 11:30:15 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu, 1 Nov 2012 16:30:15 +0100
Subject: [PATCH 0/4] at91sam9x5ek: add 1-wire support and hardware
 detection support
In-Reply-To: <20121031165240.GG29599@game.jcrosoft.org>
References: <20121031165240.GG29599@game.jcrosoft.org>
Message-ID: <20121101153015.GW1641@pengutronix.de>

On Wed, Oct 31, 2012 at 05:52:40PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> HI,
> 
> 	This patch serie add the 1-wire support to the at91sam9x5ek
> 
> 	on sam9x5ek we have on each module and motherboard a 1-wire eeprom
> 	that describe the hardware revision and type
> 
> 	And on the Cogent Cpu Module we have some difference with teh others
> 	modules and some bug
> 
> 	So fix
> 
> 	Also use the 1-wire to generate a local mac address
> 
> 	This patch series depends on the pm9g45/pm9263/pm9261 v3
> 
> The following changes since commit 7fb0cb2ce2f7800341ab8de711dccbd2c4753c84:
> 
>   pm9261: use w1 serial number to generate local mac address (2012-10-30 13:44:54 +0800)
> 
> are available in the git repository at:
> 
>   git://git.jcrosoft.org/barebox.git delivery/at91sam9x5ek_w1
> 
> for you to fetch changes up to 4e088306b778a5f14c2503be54b061e60e27e6a0:
> 
>   at91sam9x5ek: use w1 serial number to generate local mac address (2012-10-31 09:33:38 +0800)

Also applied

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Thu Nov  1 11:32:25 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu, 1 Nov 2012 16:32:25 +0100
Subject: [PATCH] iomux-imx35: add missing comma in pad definition
In-Reply-To: <1351679790-15305-1-git-send-email-uwe@kleine-koenig.org>
References: <1351679790-15305-1-git-send-email-uwe@kleine-koenig.org>
Message-ID: <20121101153225.GX1641@pengutronix.de>

On Wed, Oct 31, 2012 at 11:36:30AM +0100, Uwe Kleine-K?nig wrote:
> The same issue was fixed in the Linux kernel in commit
> 
> 	66ddfc6 (mx35: add a missing comma in a pad definition)
> 
> for 2.6.33-rc7.
> 
> Signed-off-by: Uwe Kleine-K?nig <u.kleine-koenig at pengutronix.de>

Applied, thanks

Sascha

> ---
>  arch/arm/mach-imx/include/mach/iomux-mx35.h |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm/mach-imx/include/mach/iomux-mx35.h b/arch/arm/mach-imx/include/mach/iomux-mx35.h
> index ad7ff56..0d76e43 100644
> --- a/arch/arm/mach-imx/include/mach/iomux-mx35.h
> +++ b/arch/arm/mach-imx/include/mach/iomux-mx35.h
> @@ -671,7 +671,7 @@
>  #define MX35_PAD_LD8__SDMA_SDMA_DEBUG_PC_8			IOMUX_PAD(0x634, 0x1d0, 6, 0x0,   0, NO_PAD_CTRL)
>  
>  #define MX35_PAD_LD9__IPU_DISPB_DAT_9				IOMUX_PAD(0x638, 0x1d4, 0, 0x0,   0, NO_PAD_CTRL)
> -#define MX35_PAD_LD9__GPIO2_9					IOMUX_PAD(0x638, 0x1d4, 5, 0x8e4  0, NO_PAD_CTRL)
> +#define MX35_PAD_LD9__GPIO2_9					IOMUX_PAD(0x638, 0x1d4, 5, 0x8e4, 0, NO_PAD_CTRL)
>  #define MX35_PAD_LD9__SDMA_SDMA_DEBUG_PC_9			IOMUX_PAD(0x638, 0x1d4, 6, 0x0,   0, NO_PAD_CTRL)
>  
>  #define MX35_PAD_LD10__IPU_DISPB_DAT_10				IOMUX_PAD(0x63c, 0x1d8, 0, 0x0,   0, NO_PAD_CTRL)
> -- 
> 1.7.10.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Thu Nov  1 13:08:53 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu,  1 Nov 2012 18:08:53 +0100
Subject: [PATCH] mount: add compatibility to old mount command
Message-ID: <1351789733-28638-1-git-send-email-s.hauer@pengutronix.de>

the mount command used to have the syntax 'mount <dev> <type> <mountpoint>'.
This was changed to the more Linux like behaviour which specifies the
type with the -t <type> option. If a newer barebox is run on a device
with an older environment the mount command no longer works. This patch
adds compatibility to the old behaviour.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 commands/mount.c |   17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/commands/mount.c b/commands/mount.c
index f339c37..be26af8 100644
--- a/commands/mount.c
+++ b/commands/mount.c
@@ -33,7 +33,8 @@ static int do_mount(int argc, char *argv[])
 	int opt;
 	int ret = 0;
 	struct fs_device_d *fsdev;
-	char *type = NULL;
+	const char *type = NULL;
+	const char *mountpoint, *dev;
 
 	if (argc == 1) {
 		for_each_fs_device(fsdev) {
@@ -56,7 +57,19 @@ static int do_mount(int argc, char *argv[])
 	if (argc < optind + 2)
 		return COMMAND_ERROR_USAGE;
 
-	if ((ret = mount(argv[optind], type, argv[optind + 1]))) {
+	dev = argv[optind];
+
+	if (argc == optind + 3) {
+		/*
+		 * Old behaviour: mount <dev> <type> <mountpoint>
+		 */
+		type = argv[optind + 1];
+		mountpoint = argv[optind + 2];
+	} else {
+		mountpoint = argv[optind + 1];
+	}
+
+	if ((ret = mount(dev, type, mountpoint))) {
 		perror("mount");
 		return 1;
 	}
-- 
1.7.10.4



From robert.jarzmik at free.fr  Thu Nov  1 13:37:16 2012
From: robert.jarzmik at free.fr (Robert Jarzmik)
Date: Thu,  1 Nov 2012 18:37:16 +0100
Subject: [PATCH 0/2] Y-Modem implementation change
Message-ID: <1351791438-29967-1-git-send-email-robert.jarzmik@free.fr>

Hi everyone,

This patchset aims at changing the Y-Modem protocol implementation.
You have already seen the RFC version, this is the next version, which :
 - provides a much more tested version
 - is ready for review

The following comments have been taken into account :
 - Antony: testing on a serial line
 - Sascha: split between protocol and commands
 - Jean-Christophe: kermit protocol change

So before doing the real review, could I ask of you :
 - Antony: could you redo your test over a serial line by applying only
           the first patch so that you can compare loady and loady2 ?
           Don't use "loady2 -g", as Y-Modem/G protocol requires a 
           lossless line (USB), and a serial line cannot guarantee it.
 - Sascha: does the split command/protocol suit you ?
 - Jean-Christophe: I left the loadb implementation as it is. The goal
                    of the patch is to change X-Modem and Y-Modem(G)
                    implementation, not kermit. Could you test that I
                    have not created a regression of loadb ?

Cheers.

--
Robert

Robert Jarzmik (2):
  commands: change Y-Modem implementation
  commands: remove old Y-Modem implementation

 commands/Makefile   |    4 +-
 commands/loadb.c    |  102 +------
 commands/loads.c    |    1 -
 commands/loadxy.c   |  238 ++++++++++++++++
 commands/xymodem.c  |  552 ++++++++++++++++++++++++++++++++++++
 commands/xyzModem.c |  785 ---------------------------------------------------
 include/xymodem.h   |   25 ++
 include/xyzModem.h  |  109 -------
 8 files changed, 826 insertions(+), 990 deletions(-)
 create mode 100644 commands/loadxy.c
 create mode 100644 commands/xymodem.c
 delete mode 100644 commands/xyzModem.c
 create mode 100644 include/xymodem.h
 delete mode 100644 include/xyzModem.h

-- 
1.7.10



From robert.jarzmik at free.fr  Thu Nov  1 13:37:17 2012
From: robert.jarzmik at free.fr (Robert Jarzmik)
Date: Thu,  1 Nov 2012 18:37:17 +0100
Subject: [PATCH 1/2] commands: change Y-Modem implementation
In-Reply-To: <1351791438-29967-1-git-send-email-robert.jarzmik@free.fr>
References: <1351791438-29967-1-git-send-email-robert.jarzmik@free.fr>
Message-ID: <1351791438-29967-2-git-send-email-robert.jarzmik@free.fr>

The current Y-Modem implementation has some limitations:
 - Y-Modem/G protocol is not supported
 - Multiple files (aka. batch) transfers are not supported
 - Transfer speed over fast lines (USB console) is slow
 - Code is not trivial to maintain (personnal opinion)

This implementation tries to address all these points by
introducing loady2 command.

The effects are :
 - transfer speed for Y-Modem over USB jumps from 2kBytes/s
   to 180kBytes/s
 - transfer speed for Y-Modem/G jumps to 200kBytes/s
 - multiple file transfers are possible

This command was tested on a USB console and UART 9600bps
serial line :
 - NAKs (and retransmissions) were tested for faulty
   serial lines
 - multiple file transfers were tested
 - Y-Modem, Y-Modem/G and X-Modem transfers were tested

Signed-off-by: Robert Jarzmik <robert.jarzmik at free.fr>
---
 commands/Makefile  |    2 +-
 commands/loadxy.c  |  238 ++++++++++++++++++++++
 commands/xymodem.c |  552 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/xymodem.h  |   25 +++
 4 files changed, 816 insertions(+), 1 deletion(-)
 create mode 100644 commands/loadxy.c
 create mode 100644 commands/xymodem.c
 create mode 100644 include/xymodem.h

diff --git a/commands/Makefile b/commands/Makefile
index ff98051..342c1ee 100644
--- a/commands/Makefile
+++ b/commands/Makefile
@@ -3,7 +3,7 @@ obj-$(CONFIG_CMD_BOOTM)		+= bootm.o
 obj-$(CONFIG_CMD_UIMAGE)	+= uimage.o
 obj-$(CONFIG_CMD_LINUX16)	+= linux16.o
 obj-$(CONFIG_CMD_LOADB)		+= loadb.o xyzModem.o
-obj-$(CONFIG_CMD_LOADY)		+= loadb.o xyzModem.o
+obj-$(CONFIG_CMD_LOADY)		+= loadb.o xyzModem.o loadxy.o xymodem.o
 obj-$(CONFIG_CMD_LOADS)		+= loads.o
 obj-$(CONFIG_CMD_ECHO)		+= echo.o
 obj-$(CONFIG_CMD_MEMORY)	+= mem.o
diff --git a/commands/loadxy.c b/commands/loadxy.c
new file mode 100644
index 0000000..141bd7b
--- /dev/null
+++ b/commands/loadxy.c
@@ -0,0 +1,238 @@
+/**
+ * @file
+ * @brief loady and loadx  support.
+ *
+ * Provides loadx (over X-Modem) and loady(over Y-Modem) support to download
+ * images.
+ *
+ * FileName: commands/loadxy.c
+ */
+/*
+ * (C) Copyright 2012 Robert Jarzmik <robert.jarzmik at free.fr>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+/*
+ * Serial up- and download support
+ */
+#include <common.h>
+#include <command.h>
+#include <console.h>
+#include <xymodem.h>
+#include <errno.h>
+#include <getopt.h>
+#include <fcntl.h>
+#include <fs.h>
+#include <malloc.h>
+
+#define DEF_FILE	"image.bin"
+
+/**
+ * @brief returns current used console device
+ *
+ * @return console device which is registered with CONSOLE_STDIN and
+ * CONSOLE_STDOUT
+ */
+static struct console_device *get_current_console(void)
+{
+	struct console_device *cdev;
+	/*
+	 * Assumption to have BOTH CONSOLE_STDIN AND STDOUT in the
+	 * same output console
+	 */
+	for_each_console(cdev) {
+		if ((cdev->f_active & (CONSOLE_STDIN | CONSOLE_STDOUT)))
+			return cdev;
+	}
+	return NULL;
+}
+
+static int console_change_speed(struct console_device *cdev, int baudrate)
+{
+	int current_baudrate;
+
+	current_baudrate =
+		(int)simple_strtoul(dev_get_param(&cdev->class_dev,
+						  "baudrate"), NULL, 10);
+	if (baudrate && baudrate != current_baudrate) {
+		printf("## Switch baudrate from %d to %d bps and press ENTER ...\n",
+		       current_baudrate, baudrate);
+		mdelay(50);
+		cdev->setbrg(cdev, baudrate);
+		mdelay(50);
+	}
+	return current_baudrate;
+}
+
+/**
+ * @brief provide the loady(Y-Modem or Y-Modem/G) support
+ *
+ * @param argc number of arguments
+ * @param argv arguments of loady command
+ *
+ * @return success or failure
+ */
+static int do_loady(int argc, char *argv[])
+{
+	int is_ymodemg = 0, rc = 0, opt, rcode = 0;
+	int load_baudrate = 0, current_baudrate;
+	struct console_device *cdev = NULL;
+
+	while ((opt = getopt(argc, argv, "b:g")) > 0) {
+		switch (opt) {
+		case 'b':
+			load_baudrate = (int)simple_strtoul(optarg, NULL, 10);
+			break;
+		case 'g':
+			is_ymodemg = 1;
+			break;
+		default:
+			perror(argv[0]);
+			return 1;
+		}
+	}
+
+	cdev = get_current_console();
+	if (NULL == cdev) {
+		printf("%s:No console device with STDIN and STDOUT\n", argv[0]);
+		return -ENODEV;
+	}
+
+	current_baudrate = console_change_speed(cdev, load_baudrate);
+	printf("## Ready for binary (ymodem) download at %d bps...\n",
+	       load_baudrate ? load_baudrate : current_baudrate);
+
+	if (is_ymodemg)
+		rc = do_load_serial_ymodemg(cdev);
+	else
+		rc = do_load_serial_ymodem(cdev);
+
+	if (rc < 0) {
+		printf("## Binary (ymodem) download aborted (%d)\n", rc);
+		rcode = 1;
+	}
+
+	console_change_speed(cdev, current_baudrate);
+
+	return rcode;
+}
+
+/**
+ * @brief provide the loadx(X-Modem) support
+ *
+ * @param argc number of arguments
+ * @param argv arguments of loadx command
+ *
+ * @return success or failure
+ */
+static int do_loadx(int argc, char *argv[])
+{
+	ulong offset = 0;
+	int load_baudrate = 0, current_baudrate, ofd, opt, rcode = 0;
+	int open_mode = O_WRONLY;
+	char *output_file = NULL;
+	struct console_device *cdev = NULL;
+
+	while ((opt = getopt(argc, argv, "f:b:o:c")) > 0) {
+		switch (opt) {
+		case 'f':
+			output_file = optarg;
+			break;
+		case 'b':
+			load_baudrate = (int)simple_strtoul(optarg, NULL, 10);
+			break;
+		case 'o':
+			offset = (int)simple_strtoul(optarg, NULL, 10);
+			break;
+		case 'c':
+			open_mode |= O_CREAT;
+			break;
+		default:
+			perror(argv[0]);
+			return 1;
+		}
+	}
+
+	cdev = get_current_console();
+	if (NULL == cdev) {
+		printf("%s:No console device with STDIN and STDOUT\n", argv[0]);
+		return -ENODEV;
+	}
+
+	/* Load Defaults */
+	if (NULL == output_file)
+		output_file = DEF_FILE;
+
+	/* File should exist */
+	ofd = open(output_file, open_mode);
+	if (ofd < 0) {
+		perror(argv[0]);
+		return 3;
+	}
+	/* Seek to the right offset */
+	if (offset) {
+		int seek = lseek(ofd, offset, SEEK_SET);
+		if (seek != offset) {
+			close(ofd);
+			ofd = 0;
+			perror(argv[0]);
+			return 4;
+		}
+	}
+
+	current_baudrate = console_change_speed(cdev, load_baudrate);
+	printf("## Ready for binary (X-Modem) download "
+	       "to 0x%08lX offset on %s device at %d bps...\n", offset,
+	       output_file, load_baudrate);
+	rcode = do_load_serial_ymodem(cdev);
+	if (rcode < 0) {
+		printf("## Binary (kermit) download aborted (%d)\n", rcode);
+		rcode = 1;
+	}
+	console_change_speed(cdev, current_baudrate);
+
+	return rcode;
+}
+
+static const __maybe_unused char cmd_loadx_help[] =
+	"[OPTIONS]\n"
+	"  -f file   - where to download to - defaults to " DEF_FILE "\n"
+	"  -o offset - what offset to download - defaults to 0\n"
+	"  -b baud   - baudrate at which to download - defaults to "
+	"console baudrate\n"
+	"  -c        - Create file if it is not present - default disabled";
+
+#ifdef CONFIG_CMD_LOADB
+BAREBOX_CMD_START(loadx)
+	.cmd = do_loadx,
+	.usage = "Load binary file over serial line (X-Modem)",
+BAREBOX_CMD_HELP(cmd_loadx_help)
+BAREBOX_CMD_END
+#endif
+
+static const __maybe_unused char cmd_loady_help[] =
+	"[OPTIONS]\n"
+	"  -y        - use Y-Modem/G (only for lossless tty as USB)\n"
+	"  -b baud   - baudrate at which to download - defaults to "
+	"console baudrate\n";
+
+#ifdef CONFIG_CMD_LOADY
+BAREBOX_CMD_START(loady2)
+	.cmd = do_loady,
+	.usage = "Load binary file over serial line (Y-Modem or Y-Modem/G)",
+BAREBOX_CMD_HELP(cmd_loady_help)
+BAREBOX_CMD_END
+#endif
diff --git a/commands/xymodem.c b/commands/xymodem.c
new file mode 100644
index 0000000..90bbf1f
--- /dev/null
+++ b/commands/xymodem.c
@@ -0,0 +1,552 @@
+/*
+ * Handles the X-Modem, Y-Modem and Y-Modem/G protocols
+ *
+ * Copyright (C) 2008 Robert Jarzmik
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+#include <common.h>
+#include <xfuncs.h>
+#include <errno.h>
+#include <crc.h>
+#include <clock.h>
+#include <console.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <getopt.h>
+#include <fs.h>
+#include <poller.h>
+#include <linux/byteorder/generic.h>
+
+#include <kfifo.h>
+
+#define proto_dbg(fmt, args...)
+
+/* Values magic to the protocol */
+#define SOH 0x01
+#define STX 0x02
+#define EOT 0x04
+#define ACK 0x06
+#define BSP 0x08
+#define NAK 0x15
+#define CAN 0x18
+
+#define PROTO_XMODEM	0
+#define PROTO_YMODEM	1
+#define PROTO_YMODEM_G	2
+#define MAX_PROTOS	3
+
+#define CRC_NONE	0	/* No CRC checking */
+#define CRC_ADD8	1	/* Add of all data bytes */
+#define CRC_CRC16	2	/* CCCIT CRC16 */
+#define MAX_CRCS	3
+
+#define MAX_RETRIES		10
+#define MAX_RETRIES_WITH_CRC	5
+#define TIMEOUT_READ		(1 * SECOND)
+#define MAX_CAN_BEFORE_ABORT	5
+
+enum proto_state {
+	PROTO_STATE_GET_FILENAME = 0,
+	PROTO_STATE_NEGOCIATE_CRC,
+	PROTO_STATE_RECEIVE_BODY,
+	PROTO_STATE_FINISHED_FILE,
+	PROTO_STATE_FINISHED_XFER,
+};
+
+/**
+ * struct xyz_ctxt - context of a x/y modem (g) transfer
+ *
+ * @cdev: console device to support *MODEM transfer
+ * @mode: protocol (XMODEM, YMODEM or YMODEM/G)
+ * @crc_mode: CRC_NONE, CRC_ADD8 or CRC_CRC16
+ * @state: protocol state (as in "state machine")
+ * @buf: buffer to store the last tranfered buffer chunk
+ * @filename : filename transmitted by sender (YMODEM* only)
+ * @fd : file descriptor of the current stored file
+ * @file_len: length declared by sender (YMODEM* only)
+ * @nb_received: number of data bytes received since session open
+ *               (this doesn't count resends)
+ * @total_SOH: number of SOH frames received (128 bytes chunks)
+ * @total_STX: number of STX frames received (1024 bytes chunks)
+ * @total_CAN: nubmer of CAN frames received (cancel frames)
+ */
+struct xyz_ctxt {
+	struct console_device *cdev;
+	int mode;
+	int crc_mode;
+	enum proto_state state;
+	char filename[1024];
+	int fd;
+	int file_len;
+	int nb_received;
+	int next_blk;
+	int total_SOH, total_STX, total_CAN, total_retries;
+};
+
+/**
+ * struct proto_block - one unitary block of x/y modem (g) transfer
+ *
+ * @buf: data buffer
+ * @len: length of data buffer (can only be 128 or 1024)
+ * @seq: block sequence number (as in X/Y/YG MODEM protocol)
+ */
+struct proto_block {
+	unsigned char buf[1024];
+	int len;
+	int seq;
+};
+
+/*
+ * For XMODEM/YMODEM, always try to use the CRC16 versions, called also
+ * XMODEM/CRC and YMODEM.
+ * Only fallback to additive CRC (8 bits) if sender doesn't cope with CRC16.
+ */
+static const char invite_filename_hdr[MAX_PROTOS][MAX_CRCS] = {
+	{ 0, NAK, 'C' },	/* XMODEM */
+	{ 0, NAK, 'C' },	/* YMODEM */
+	{ 0, 'G', 'G' },	/* YMODEM-G */
+};
+
+static const char invite_file_body[MAX_PROTOS][MAX_CRCS] = {
+	{ 0, NAK, 'C' },	/* XMODEM */
+	{ 0, NAK, 'C' },	/* YMODEM */
+	{ 0, 'G', 'G' },	/* YMODEM-G */
+};
+
+static const char block_ack[MAX_PROTOS][MAX_CRCS] = {
+	{ 0, ACK, ACK },	/* XMODEM */
+	{ 0, ACK, ACK },	/* YMODEM */
+	{ 0, 0, 0 },		/* YMODEM-G */
+};
+
+static const char block_nack[MAX_PROTOS][MAX_CRCS] = {
+	{ 0, NAK, NAK },	/* XMODEM */
+	{ 0, NAK, NAK },	/* YMODEM */
+	{ 0, 0, 0 },		/* YMODEM-G */
+};
+
+static int proto_gets(struct console_device *cdev, unsigned char *buf, int len,
+		      uint64_t timeout)
+{
+	int i, rc;
+	uint64_t start = get_time_ns();
+
+	for (i = 0, rc = 0; rc >= 0 && i < len; ) {
+		if (is_timeout(start, timeout)) {
+			rc = -ETIMEDOUT;
+			continue;
+		}
+		if (cdev->tstc(cdev))
+			buf[i++] = (unsigned char)(cdev->getc(cdev));
+	}
+
+	return rc < 0 ? rc : i;
+}
+
+static void proto_putc(struct console_device *cdev, unsigned char c)
+{
+	cdev->putc(cdev, c);
+}
+
+static void proto_flush(struct console_device *cdev)
+{
+	while (cdev->tstc(cdev))
+		cdev->getc(cdev);
+	mdelay(250);
+	while (cdev->tstc(cdev))
+		cdev->getc(cdev);
+}
+
+static int is_xmodem(struct xyz_ctxt *proto)
+{
+	return proto->mode == PROTO_XMODEM;
+}
+
+static void proto_block_ack(struct xyz_ctxt *proto)
+{
+	unsigned char c = block_ack[proto->mode][proto->crc_mode];
+
+	if (c)
+		proto_putc(proto->cdev, c);
+}
+
+static void proto_block_nack(struct xyz_ctxt *proto)
+{
+	unsigned char c = block_nack[proto->mode][proto->crc_mode];
+
+	if (c)
+		proto_putc(proto->cdev, c);
+	proto->total_retries++;
+}
+
+static int check_crc(unsigned char *buf, int len, int crc, int crc_mode)
+{
+	unsigned char crc8 = 0;
+	uint16_t crc16;
+	int i;
+
+	switch (crc_mode) {
+	case CRC_ADD8:
+		for (i = 0; i < len; i++)
+			crc8 += buf[i];
+		return crc8 == crc ? 0 : -EBADMSG;
+	case CRC_CRC16:
+		crc16 = cyg_crc16(buf, len);
+		proto_dbg("crc16: received = %x, calculated=%x\n", crc, crc16);
+		return crc16 == crc ? 0 : -EBADMSG;
+	case CRC_NONE:
+		return 0;
+	default:
+		return -EBADMSG;
+	}
+}
+
+static ssize_t proto_read_block(struct xyz_ctxt *proto, struct proto_block *blk,
+	uint64_t timeout)
+{
+	ssize_t rc, data_len = 0;
+	unsigned char hdr, seqs[2];
+	int crc = 0, hdr_found = 0;
+	uint64_t start = get_time_ns();
+
+	while (!hdr_found) {
+		rc = proto_gets(proto->cdev, &hdr, 1, timeout);
+		proto_dbg("read 0x%x(%c) -> %d\n", hdr, hdr, rc);
+		if (rc < 0)
+			goto out;
+		if (is_timeout(start, timeout))
+			goto timeout;
+		switch (hdr) {
+		case SOH:
+			data_len = 128;
+			hdr_found = 1;
+			proto->total_SOH++;
+			break;
+		case STX:
+			data_len = 1024;
+			hdr_found = 1;
+			proto->total_STX++;
+			break;
+		case CAN:
+			rc = -ECONNABORTED;
+			if (proto->total_CAN++ > MAX_CAN_BEFORE_ABORT)
+				goto out;
+			break;
+		case EOT:
+			rc = 0;
+			blk->len = 0;
+			goto out;
+		default:
+			break;
+		}
+	}
+
+	blk->seq = 0;
+	rc = proto_gets(proto->cdev, seqs, 2, timeout);
+	if (rc < 0)
+		goto out;
+	blk->seq = seqs[0];
+	if (255 - seqs[0] != seqs[1])
+		return -EBADMSG;
+
+	rc = proto_gets(proto->cdev, blk->buf, data_len, timeout);
+	if (rc < 0)
+		goto out;
+	blk->len = rc;
+
+	switch (proto->crc_mode) {
+	case CRC_ADD8:
+		rc = proto_gets(proto->cdev,
+				(unsigned char *)&crc, 1, timeout);
+		break;
+	case CRC_CRC16:
+		rc = proto_gets(proto->cdev,
+				(unsigned char *)&crc, 2, timeout);
+		crc = be16_to_cpu(crc);
+		break;
+	case CRC_NONE:
+		rc = 0;
+		break;
+	}
+	if (rc < 0)
+		goto out;
+
+	rc = check_crc(blk->buf, data_len, crc, proto->crc_mode);
+	if (rc < 0)
+		goto out;
+	return data_len;
+timeout:
+	return -ETIMEDOUT;
+out:
+	return rc;
+}
+
+static int check_blk_seq(struct xyz_ctxt *proto, struct proto_block *blk,
+	int read_rc)
+{
+	if (blk->seq == ((proto->next_blk - 1) % 256))
+		return -EALREADY;
+	if (blk->seq != proto->next_blk)
+		return -EILSEQ;
+	return read_rc;
+}
+
+static int parse_first_block(struct xyz_ctxt *proto, struct proto_block *blk)
+{
+	int filename_len;
+	char *str_num;
+
+	filename_len = strlen(blk->buf);
+	if (filename_len > blk->len)
+		return -EINVAL;
+	memset(proto->filename, 0, sizeof(proto->filename));
+	strncpy(proto->filename, blk->buf, filename_len);
+	str_num = blk->buf + filename_len + 1;
+	strsep(&str_num, " ");
+	proto->file_len = simple_strtoul(blk->buf + filename_len + 1, NULL, 10);
+	return 1;
+}
+
+static int proto_get_file_header(struct xyz_ctxt *proto)
+{
+	struct proto_block blk;
+	int tries, rc = 0;
+
+	memset(&blk, 0, sizeof(blk));
+	proto->state = PROTO_STATE_GET_FILENAME;
+	proto->crc_mode = CRC_CRC16;
+	for (tries = 0; tries < MAX_RETRIES; tries++) {
+		proto_putc(proto->cdev,
+			   invite_filename_hdr[proto->mode][proto->crc_mode]);
+		rc = proto_read_block(proto, &blk, 3 * SECOND);
+		proto_dbg("read block returned %d\n", rc);
+		switch (rc) {
+		case -ECONNABORTED:
+			goto fail;
+		case -ETIMEDOUT:
+			if (proto->mode != PROTO_YMODEM_G)
+				mdelay(1000);
+			break;
+		case -EBADMSG:
+			/* The NACK/C/G char will be sent by invite_file_body */
+			break;
+		case -EALREADY:
+		default:
+			proto->next_blk = 1;
+			proto_block_ack(proto);
+			proto->crc_mode = CRC_CRC16;
+			proto->state = PROTO_STATE_NEGOCIATE_CRC;
+			rc = parse_first_block(proto, &blk);
+			return rc;
+		}
+
+		if (rc < 0 && tries++ >= MAX_RETRIES_WITH_CRC)
+			proto->crc_mode = CRC_ADD8;
+	}
+	rc = -ETIMEDOUT;
+fail:
+	return rc;
+}
+
+static int proto_await_header(struct xyz_ctxt *proto)
+{
+	int rc;
+
+	rc = proto_get_file_header(proto);
+	if (rc < 0)
+		return rc;
+	proto->state = PROTO_STATE_NEGOCIATE_CRC;
+	proto_dbg("header received, filename=%s, file length=%d\n",
+	       proto->filename, proto->file_len);
+	if (proto->filename[0])
+		proto->fd = open(proto->filename, O_WRONLY | O_CREAT);
+	else
+		proto->state = PROTO_STATE_FINISHED_XFER;
+	proto->nb_received = 0;
+	return rc;
+}
+
+static void proto_finish_file(struct xyz_ctxt *proto)
+{
+	close(proto->fd);
+	proto->fd = 0;
+	proto->state = PROTO_STATE_FINISHED_FILE;
+}
+
+static struct xyz_ctxt *xymodem_open(struct console_device *cdev,
+				     int proto_mode, int xmodem_fd)
+{
+	struct xyz_ctxt *proto;
+
+	proto = xzalloc(sizeof(struct xyz_ctxt));
+	proto->mode = proto_mode;
+	proto->cdev = cdev;
+	proto->crc_mode = CRC_CRC16;
+
+	if (is_xmodem(proto)) {
+		proto->fd = xmodem_fd;
+		proto->state = PROTO_STATE_NEGOCIATE_CRC;
+	} else {
+		proto->state = PROTO_STATE_GET_FILENAME;
+	}
+	proto_flush(proto->cdev);
+	return proto;
+}
+
+static int xymodem_handle(struct xyz_ctxt *proto)
+{
+	int rc = 0, xfer_max, len = 0, again = 1, remain;
+	int crc_tries = 0, same_blk_retries = 0;
+	unsigned char invite;
+	struct proto_block blk;
+
+	while (again) {
+		switch (proto->state) {
+		case PROTO_STATE_GET_FILENAME:
+			crc_tries = 0;
+			rc = proto_await_header(proto);
+			if (rc < 0)
+				goto fail;
+			continue;
+		case PROTO_STATE_FINISHED_FILE:
+			if (is_xmodem(proto))
+				proto->state = PROTO_STATE_FINISHED_XFER;
+			else
+				proto->state = PROTO_STATE_GET_FILENAME;
+			proto_putc(proto->cdev, ACK);
+			continue;
+		case PROTO_STATE_FINISHED_XFER:
+			again = 0;
+			rc = 0;
+			goto out;
+		case PROTO_STATE_NEGOCIATE_CRC:
+			invite = invite_file_body[proto->mode][proto->crc_mode];
+			proto->next_blk = 1;
+			if (crc_tries++ > MAX_RETRIES_WITH_CRC)
+				proto->crc_mode = CRC_ADD8;
+			proto_putc(proto->cdev, invite);
+			/* Fall through */
+		case PROTO_STATE_RECEIVE_BODY:
+			rc = proto_read_block(proto, &blk, 3 * SECOND);
+			if (rc > 0) {
+				rc = check_blk_seq(proto, &blk, rc);
+				proto->state = PROTO_STATE_RECEIVE_BODY;
+			}
+			break;
+		}
+
+		if (proto->state != PROTO_STATE_RECEIVE_BODY)
+			continue;
+
+		switch (rc) {
+		case -ECONNABORTED:
+			goto fail;
+		case -ETIMEDOUT:
+			if (proto->mode == PROTO_YMODEM_G)
+				goto fail;
+			proto_flush(proto->cdev);
+			proto_block_nack(proto);
+			break;
+		case -EBADMSG:
+		case -EILSEQ:
+			if (proto->mode == PROTO_YMODEM_G)
+				goto fail;
+			proto_flush(proto->cdev);
+			proto_block_nack(proto);
+			break;
+		case -EALREADY:
+			proto_block_ack(proto);
+			break;
+		case 0:
+			proto_finish_file(proto);
+			break;
+		default:
+			remain = proto->file_len - proto->nb_received;
+			if (is_xmodem(proto))
+				xfer_max = blk.len;
+			else
+				xfer_max = min(blk.len, remain);
+			rc = write(proto->fd, blk.buf, xfer_max);
+			proto->next_blk = ((blk.seq + 1) % 256);
+			proto->nb_received += rc;
+			len += rc;
+			proto_block_ack(proto);
+			break;
+		}
+		if (rc < 0)
+			same_blk_retries++;
+		else
+			same_blk_retries = 0;
+		if (same_blk_retries > MAX_RETRIES)
+			goto fail;
+	}
+out:
+	return rc;
+fail:
+	if (proto->fd)
+		close(proto->fd);
+	return rc;
+}
+
+static void xymodem_close(struct xyz_ctxt *proto)
+{
+	printf("xyModem - %d(SOH)/%d(STX)/%d(CAN) packets,"
+	       " %d retries\n",
+	       proto->total_SOH, proto->total_STX,
+	       proto->total_CAN, proto->total_retries);
+}
+
+int do_load_serial_xmodem(struct console_device *cdev, int fd)
+{
+	struct xyz_ctxt *proto;
+	int rc;
+
+	proto_flush(cdev);
+	proto = xymodem_open(cdev, PROTO_XMODEM, fd);
+	do {
+		rc = xymodem_handle(proto);
+	} while (rc > 0);
+	xymodem_close(proto);
+	return rc < 0 ? rc : 0;
+}
+EXPORT_SYMBOL(do_load_serial_xmodem);
+
+int do_load_serial_ymodem(struct console_device *cdev)
+{
+	struct xyz_ctxt *proto;
+	int rc;
+
+	proto_flush(cdev);
+	proto = xymodem_open(cdev, PROTO_YMODEM, 0);
+	do {
+		rc = xymodem_handle(proto);
+	} while (rc > 0);
+	xymodem_close(proto);
+	return rc < 0 ? rc : 0;
+}
+EXPORT_SYMBOL(do_load_serial_ymodem);
+
+int do_load_serial_ymodemg(struct console_device *cdev)
+{
+	struct xyz_ctxt *proto;
+	int rc;
+
+	proto_flush(cdev);
+	proto = xymodem_open(cdev, PROTO_YMODEM_G, 0);
+	do {
+		rc = xymodem_handle(proto);
+	} while (rc > 0);
+	xymodem_close(proto);
+	return rc < 0 ? rc : 0;
+}
+EXPORT_SYMBOL(do_load_serial_ymodemg);
diff --git a/include/xymodem.h b/include/xymodem.h
new file mode 100644
index 0000000..917cecc
--- /dev/null
+++ b/include/xymodem.h
@@ -0,0 +1,25 @@
+/*
+ * Handles the X-Modem, Y-Modem and Y-Modem/G protocols
+ *
+ * Copyright (C) 2008 Robert Jarzmik
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef _XYMODEM_
+#define _XYMODEM_
+struct xyz_ctxt;
+struct console_device;
+
+int do_load_serial_xmodem(struct console_device *cdev, int fd);
+int do_load_serial_ymodem(struct console_device *cdev);
+int do_load_serial_ymodemg(struct console_device *cdev);
+#endif
-- 
1.7.10



From robert.jarzmik at free.fr  Thu Nov  1 13:37:18 2012
From: robert.jarzmik at free.fr (Robert Jarzmik)
Date: Thu,  1 Nov 2012 18:37:18 +0100
Subject: [PATCH 2/2] commands: remove old Y-Modem implementation
In-Reply-To: <1351791438-29967-1-git-send-email-robert.jarzmik@free.fr>
References: <1351791438-29967-1-git-send-email-robert.jarzmik@free.fr>
Message-ID: <1351791438-29967-3-git-send-email-robert.jarzmik@free.fr>

From: Robert Jarzmik <robert.jarzmik at intel.com>

As a new implementation of Y-Modem protocol is available,
switch from old implementation to the new one :
 - remove old xyzModem* files
 - remove old command loady2
 - rename command loady2 to loady

Signed-off-by: Robert Jarzmik <robert.jarzmik at intel.com>
---
 commands/Makefile   |    4 +-
 commands/loadb.c    |  102 +------
 commands/loads.c    |    1 -
 commands/loadxy.c   |    2 +-
 commands/xyzModem.c |  785 ---------------------------------------------------
 include/xyzModem.h  |  109 -------
 6 files changed, 12 insertions(+), 991 deletions(-)
 delete mode 100644 commands/xyzModem.c
 delete mode 100644 include/xyzModem.h

diff --git a/commands/Makefile b/commands/Makefile
index 342c1ee..833b41f 100644
--- a/commands/Makefile
+++ b/commands/Makefile
@@ -2,8 +2,8 @@ obj-$(CONFIG_STDDEV)		+= stddev.o
 obj-$(CONFIG_CMD_BOOTM)		+= bootm.o
 obj-$(CONFIG_CMD_UIMAGE)	+= uimage.o
 obj-$(CONFIG_CMD_LINUX16)	+= linux16.o
-obj-$(CONFIG_CMD_LOADB)		+= loadb.o xyzModem.o
-obj-$(CONFIG_CMD_LOADY)		+= loadb.o xyzModem.o loadxy.o xymodem.o
+obj-$(CONFIG_CMD_LOADB)		+= loadb.o
+obj-$(CONFIG_CMD_LOADY)		+= loadxy.o xymodem.o
 obj-$(CONFIG_CMD_LOADS)		+= loads.o
 obj-$(CONFIG_CMD_ECHO)		+= echo.o
 obj-$(CONFIG_CMD_MEMORY)	+= mem.o
diff --git a/commands/loadb.c b/commands/loadb.c
index 898b9e3..a2f3315 100644
--- a/commands/loadb.c
+++ b/commands/loadb.c
@@ -31,7 +31,6 @@
  */
 #include <common.h>
 #include <command.h>
-#include <xyzModem.h>
 #include <console.h>
 #include <errno.h>
 #include <environment.h>
@@ -59,8 +58,6 @@
 
 static int ofd;			/* output file descriptor */
 
-#ifdef CONFIG_CMD_LOADB
-
 /* Size of my buffer to write to o/p file */
 #define MAX_WRITE_BUFFER 4096	/* Write size to o/p file */
 static char *write_buffer;	/* buffer for finalized data to write */
@@ -593,66 +590,6 @@ err_quit:
 	return size;
 }
 
-#endif				/* CONFIG_CMD_LOADB */
-
-#ifdef CONFIG_CMD_LOADY
-/**
- * @brief getcxmodem
- *
- * @return if character avaiable, return the same, else return -1
- */
-static int getcxmodem(void)
-{
-	if (tstc())
-		return (getc());
-	return -1;
-}
-
-/**
- * @brief  LoadY over ymodem protocol
- *
- * @return download size
- */
-static ulong load_serial_ymodem(void)
-{
-	int size;
-	char buf[32];
-	int err;
-	int res, wr;
-	connection_info_t info;
-	char ymodemBuf[1024];
-	ulong addr = 0;
-
-	size = 0;
-	info.mode = xyzModem_ymodem;
-	res = xyzModem_stream_open(&info, &err);
-	if (!res) {
-		while ((res = xyzModem_stream_read(ymodemBuf, 1024, &err)) >
-				0) {
-			size += res;
-			addr += res;
-			wr = write(ofd, ymodemBuf, res);
-			if (res != wr) {
-				perror("ymodem");
-				break;
-			}
-
-		}
-	} else {
-		printf("%s\n", xyzModem_error(err));
-	}
-
-	xyzModem_stream_close(&err);
-	xyzModem_stream_terminate(false, &getcxmodem);
-
-	printf("## Total Size      = 0x%08x = %d Bytes\n", size, size);
-	sprintf(buf, "%X", size);
-	setenv("filesize", buf);
-
-	return res;
-}
-#endif
-
 /**
  * @brief returns current used console device
  *
@@ -754,27 +691,16 @@ static int do_load_serial_bin(int argc, char *argv[])
 				break;
 		}
 	}
-#ifdef CONFIG_CMD_LOADY
-	if (strcmp(argv[0], "loady") == 0) {
-		printf("## Ready for binary (ymodem) download "
-		       "to 0x%08lX offset on %s device at %d bps...\n", offset,
-		       output_file, load_baudrate);
-		addr = load_serial_ymodem();
-	}
-#endif
-#ifdef CONFIG_CMD_LOADB
-	if (strcmp(argv[0], "loadb") == 0) {
-
-		printf("## Ready for binary (kermit) download "
-		       "to 0x%08lX offset on %s device at %d bps...\n", offset,
-		       output_file, load_baudrate);
-		addr = load_serial_bin();
-		if (addr == 0) {
-			printf("## Binary (kermit) download aborted\n");
-			rcode = 1;
-		}
+
+	printf("## Ready for binary (kermit) download "
+	       "to 0x%08lX offset on %s device at %d bps...\n", offset,
+	       output_file, load_baudrate);
+	addr = load_serial_bin();
+	if (addr == 0) {
+		printf("## Binary (kermit) download aborted\n");
+		rcode = 1;
 	}
-#endif
+
 	if (load_baudrate != current_baudrate) {
 		printf("## Switch baudrate to %d bps and press ESC ...\n",
 		       current_baudrate);
@@ -799,18 +725,8 @@ static const __maybe_unused char cmd_loadb_help[] =
     "  -b baud   - baudrate at which to download - defaults to "
     "console baudrate\n"
     "  -c        - Create file if it is not present - default disabled";
-#ifdef CONFIG_CMD_LOADB
 BAREBOX_CMD_START(loadb)
 	.cmd = do_load_serial_bin,
 	.usage = "Load binary file over serial line (kermit mode)",
 	BAREBOX_CMD_HELP(cmd_loadb_help)
 BAREBOX_CMD_END
-#endif
-#ifdef CONFIG_CMD_LOADY
-BAREBOX_CMD_START(loady)
-	.cmd = do_load_serial_bin,
-	.usage = "Load binary file over serial line (ymodem mode)",
-	BAREBOX_CMD_HELP(cmd_loadb_help)
-BAREBOX_CMD_END
-#endif
-
diff --git a/commands/loads.c b/commands/loads.c
index 7f4c647..bfc465b 100644
--- a/commands/loads.c
+++ b/commands/loads.c
@@ -25,7 +25,6 @@
 #include <environment.h>
 #include <s_record.h>
 #include <net.h>
-#include <xyzModem.h>
 
 static ulong load_serial(ulong offset);
 static int read_record(char *buf, ulong len);
diff --git a/commands/loadxy.c b/commands/loadxy.c
index 141bd7b..8914655 100644
--- a/commands/loadxy.c
+++ b/commands/loadxy.c
@@ -230,7 +230,7 @@ static const __maybe_unused char cmd_loady_help[] =
 	"console baudrate\n";
 
 #ifdef CONFIG_CMD_LOADY
-BAREBOX_CMD_START(loady2)
+BAREBOX_CMD_START(loady)
 	.cmd = do_loady,
 	.usage = "Load binary file over serial line (Y-Modem or Y-Modem/G)",
 BAREBOX_CMD_HELP(cmd_loady_help)
diff --git a/commands/xyzModem.c b/commands/xyzModem.c
deleted file mode 100644
index 71d7d68..0000000
--- a/commands/xyzModem.c
+++ /dev/null
@@ -1,785 +0,0 @@
-/**
- * @file
- * @brief RedBoot stream handler for xyzModem protocol
- *
- * FileName: commands/xyzModem.c
- * Originally from u-boot xyzModem.c
- */
-/*
- * 2008 - Nishanth Menon <x0nishan at ti.com>
- * Modified for sparse and checkpatch.pl compliance
- */
-/*
- *==========================================================================
- *
- *      xyzModem.c
- *
- *      RedBoot stream handler for xyzModem protocol
- *
- *==========================================================================
- *####ECOSGPLCOPYRIGHTBEGIN####
- * -------------------------------------------
- * This file is part of eCos, the Embedded Configurable Operating System.
- * Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
- * Copyright (C) 2002 Gary Thomas
- *
- * eCos is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 or (at your option) any later version.
- *
- * eCos is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with eCos; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * As a special exception, if other files instantiate templates or use macros
- * or inline functions from this file, or you compile this file and link it
- * with other works to produce a work based on this file, this file does not
- * by itself cause the resulting work to be covered by the GNU General Public
- * License. However the source code for this file must still be made available
- * in accordance with section (3) of the GNU General Public License.
- *
- * This exception does not invalidate any other reasons why a work based on
- * this file might be covered by the GNU General Public License.
- *
- * Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
- * at http: *sources.redhat.com/ecos/ecos-license/
- * -------------------------------------------
- *####ECOSGPLCOPYRIGHTEND####
- *==========================================================================
- *#####DESCRIPTIONBEGIN####
- *
- * Author(s):    gthomas
- * Contributors: gthomas, tsmith, Yoshinori Sato
- * Date:         2000-07-14
- * Purpose:
- * Description:
- *
- * This code is part of RedBoot (tm).
- *
- *####DESCRIPTIONEND####
- *
- *==========================================================================
- */
-#include <common.h>
-#include <xyzModem.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <console.h>
-#include <crc.h>
-#include <linux/ctype.h>
-
-/* Assumption - run xyzModem protocol over the console port */
-
-/* Values magic to the protocol */
-#define SOH 0x01
-#define STX 0x02
-#define EOT 0x04
-#define ACK 0x06
-#define BSP 0x08
-#define NAK 0x15
-#define CAN 0x18
-#define EOF 0x1A		/* ^Z for DOS officionados */
-
-#define USE_YMODEM_LENGTH
-
-/* Data & state local to the protocol */
-static struct {
-#ifdef REDBOOT
-	hal_virtual_comm_table_t *__chan;
-#else
-	int *__chan;
-#endif
-	unsigned char pkt[1024], *bufp;
-	unsigned char blk, cblk, crc1, crc2;
-	unsigned char next_blk;	/* Expected block */
-	int len, mode, total_retries;
-	int total_SOH, total_STX, total_CAN;
-	bool crc_mode, at_eof, tx_ack;
-#ifdef USE_YMODEM_LENGTH
-	unsigned long file_length, read_length;
-#endif
-} xyz;
-
-#define xyzModem_CHAR_TIMEOUT            2000	/* 2 seconds */
-#define xyzModem_MAX_RETRIES             20
-#define xyzModem_MAX_RETRIES_WITH_CRC    10
-/* Wait for 3 CAN before quitting */
-#define xyzModem_CAN_COUNT                3
-
-#ifndef REDBOOT			/*SB */
-typedef int cyg_int32;
-static int CYGACC_COMM_IF_GETC_TIMEOUT(char chan, char *c)
-{
-#define DELAY 20
-	unsigned long counter = 0;
-	while (!tstc() && (counter < xyzModem_CHAR_TIMEOUT * 1000 / DELAY)) {
-		udelay(DELAY);
-		counter++;
-	}
-	if (tstc()) {
-		*c = getc();
-		return 1;
-	}
-	return 0;
-}
-
-static void CYGACC_COMM_IF_PUTC(char x, char y)
-{
-	console_putc(CONSOLE_STDOUT, y);
-}
-
-/* Validate a hex character */
-static inline bool _is_hex(char c)
-{
-	return (((c >= '0') && (c <= '9')) ||
-		((c >= 'A') && (c <= 'F')) || ((c >= 'a') && (c <= 'f')));
-}
-
-/* Convert a single hex nibble */
-static inline int _from_hex(char c)
-{
-	int ret = 0;
-
-	if ((c >= '0') && (c <= '9'))
-		ret = (c - '0');
-	else if ((c >= 'a') && (c <= 'f'))
-		ret = (c - 'a' + 0x0a);
-	else if ((c >= 'A') && (c <= 'F'))
-		ret = (c - 'A' + 0x0A);
-
-	return ret;
-}
-
-/* Parse (scan) a number */
-static bool parse_num(char *s, unsigned long *val, char **es, char *delim)
-{
-	bool first = true;
-	int radix = 10;
-	char c;
-	unsigned long result = 0;
-	int digit = 0;
-
-	while (*s == ' ')
-		s++;
-	while (*s) {
-		if (first && (s[0] == '0') && (tolower(s[1]) == 'x')) {
-			radix = 16;
-			s += 2;
-		}
-		first = false;
-		c = *s++;
-		if (_is_hex(c))
-			digit = _from_hex(c);
-		if (_is_hex(c) && (digit < radix)) {
-			/* Valid digit */
-#ifdef CYGPKG_HAL_MIPS
-			/* FIXME: tx49 compiler generates 0x2539018 for
-			 * MUL which isn't any good. */
-			if (16 == radix)
-				result = result << 4;
-			else
-				result = 10 * result;
-			result += digit;
-#else
-			result = (result * radix) + digit;
-#endif
-		} else {
-			if (delim != (char *)0) {
-				/* See if this character is one of the
-				 * delimiters */
-				char *dp = delim;
-				while (*dp && (c != *dp))
-					dp++;
-				if (*dp)
-					break;	/* Found a good delimiter */
-			}
-			return false;	/* Malformatted number */
-		}
-	}
-	*val = result;
-	if (es != (char **)0)
-		*es = s;
-	return true;
-}
-
-#endif
-
-#define USE_SPRINTF
-#ifdef DEBUG
-#ifndef USE_SPRINTF
-/*
- * Note: this debug setup only works if the target platform has two serial ports
- * available so that the other one (currently only port 1) can be used for debug
- * messages.
- */
-static int zm_dprintf(char *fmt, ...)
-{
-	int cur_console;
-	va_list args;
-
-	va_start(args, fmt);
-#ifdef REDBOOT
-	cur_console =
-	    CYGACC_CALL_IF_SET_CONSOLE_COMM
-	    (CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT);
-	CYGACC_CALL_IF_SET_CONSOLE_COMM(1);
-#endif
-	diag_vprintf(fmt, args);
-#ifdef REDBOOT
-	CYGACC_CALL_IF_SET_CONSOLE_COMM(cur_console);
-#endif
-}
-
-static void zm_flush(void)
-{
-}
-
-#else
-/*
- * Note: this debug setup works by storing the strings in a fixed buffer
- */
-#define FINAL
-#ifdef FINAL
-static char *zm_out = (char *)0x00380000;
-static char *zm_out_start = (char *)0x00380000;
-#else
-static char zm_buf[8192];
-static char *zm_out = zm_buf;
-static char *zm_out_start = zm_buf;
-
-#endif
-static int zm_dprintf(char *fmt, ...)
-{
-	int len;
-	va_list args;
-
-	va_start(args, fmt);
-	len = diag_vsprintf(zm_out, fmt, args);
-	zm_out += len;
-	return len;
-}
-
-static void zm_flush(void)
-{
-#ifdef REDBOOT
-	char *p = zm_out_start;
-	while (*p)
-		mon_write_char(*p++);
-#endif
-	zm_out = zm_out_start;
-}
-#endif
-
-static void zm_dump_buf(void *buf, int len)
-{
-#ifdef REDBOOT
-	diag_vdump_buf_with_offset(zm_dprintf, buf, len, 0);
-#else
-
-#endif
-}
-
-static unsigned char zm_buf[2048];
-static unsigned char *zm_bp;
-
-static void zm_new(void)
-{
-	zm_bp = zm_buf;
-}
-
-static void zm_save(unsigned char c)
-{
-	*zm_bp++ = c;
-}
-
-static void zm_dump(int line)
-{
-	zm_dprintf("Packet at line: %d\n", line);
-	zm_dump_buf(zm_buf, zm_bp - zm_buf);
-}
-
-#define ZM_DEBUG(x) x
-#else
-#define ZM_DEBUG(x)
-#endif
-
-/* Wait for the line to go idle */
-static void xyzModem_flush(void)
-{
-	int res;
-	char c;
-	while (true) {
-		res = CYGACC_COMM_IF_GETC_TIMEOUT(*xyz.__chan, &c);
-		if (!res)
-			return;
-	}
-}
-
-static int xyzModem_get_hdr(void)
-{
-	char c;
-	int res;
-	bool hdr_found = false;
-	int i, can_total, hdr_chars;
-	unsigned short cksum;
-
-	ZM_DEBUG(zm_new());
-	/* Find the start of a header */
-	can_total = 0;
-	hdr_chars = 0;
-
-	if (xyz.tx_ack) {
-		CYGACC_COMM_IF_PUTC(*xyz.__chan, ACK);
-		xyz.tx_ack = false;
-	}
-	while (!hdr_found) {
-		res = CYGACC_COMM_IF_GETC_TIMEOUT(*xyz.__chan, &c);
-		ZM_DEBUG(zm_save(c));
-		if (res) {
-			hdr_chars++;
-			switch (c) {
-			case SOH:
-				xyz.total_SOH++;
-			case STX:
-				if (c == STX)
-					xyz.total_STX++;
-				hdr_found = true;
-				break;
-			case CAN:
-				xyz.total_CAN++;
-				ZM_DEBUG(zm_dump(__LINE__));
-				if (++can_total == xyzModem_CAN_COUNT) {
-					return xyzModem_cancel;
-				} else {
-					/* Wait for multiple CAN to avoid
-					 * early quits */
-					break;
-				}
-			case EOT:
-				/* EOT only supported if no noise */
-				if (hdr_chars == 1) {
-					CYGACC_COMM_IF_PUTC(*xyz.__chan, ACK);
-					ZM_DEBUG(zm_dprintf
-						 ("ACK on EOT #%d\n",
-						  __LINE__));
-					ZM_DEBUG(zm_dump(__LINE__));
-					return xyzModem_eof;
-				}
-			default:
-				/* Ignore, waiting for start of header */
-				;
-			}
-		} else {
-			/* Data stream timed out */
-			xyzModem_flush();	/* Toss any current input */
-			ZM_DEBUG(zm_dump(__LINE__));
-			CYGACC_CALL_IF_DELAY_US((cyg_int32) 250000);
-			return xyzModem_timeout;
-		}
-	}
-
-	/* Header found, now read the data */
-	res = CYGACC_COMM_IF_GETC_TIMEOUT(*xyz.__chan, (char *)&xyz.blk);
-	ZM_DEBUG(zm_save(xyz.blk));
-	if (!res) {
-		ZM_DEBUG(zm_dump(__LINE__));
-		return xyzModem_timeout;
-	}
-	res = CYGACC_COMM_IF_GETC_TIMEOUT(*xyz.__chan, (char *)&xyz.cblk);
-	ZM_DEBUG(zm_save(xyz.cblk));
-	if (!res) {
-		ZM_DEBUG(zm_dump(__LINE__));
-		return xyzModem_timeout;
-	}
-	xyz.len = (c == SOH) ? 128 : 1024;
-	xyz.bufp = xyz.pkt;
-	for (i = 0; i < xyz.len; i++) {
-		res = CYGACC_COMM_IF_GETC_TIMEOUT(*xyz.__chan, &c);
-		ZM_DEBUG(zm_save(c));
-		if (res) {
-			xyz.pkt[i] = c;
-		} else {
-			ZM_DEBUG(zm_dump(__LINE__));
-			return xyzModem_timeout;
-		}
-	}
-	res = CYGACC_COMM_IF_GETC_TIMEOUT(*xyz.__chan, (char *)&xyz.crc1);
-	ZM_DEBUG(zm_save(xyz.crc1));
-	if (!res) {
-		ZM_DEBUG(zm_dump(__LINE__));
-		return xyzModem_timeout;
-	}
-	if (xyz.crc_mode) {
-		res =
-		    CYGACC_COMM_IF_GETC_TIMEOUT(*xyz.__chan, (char *)&xyz.crc2);
-		ZM_DEBUG(zm_save(xyz.crc2));
-		if (!res) {
-			ZM_DEBUG(zm_dump(__LINE__));
-			return xyzModem_timeout;
-		}
-	}
-	ZM_DEBUG(zm_dump(__LINE__));
-	/* Validate the message */
-	if ((xyz.blk ^ xyz.cblk) != (unsigned char)0xFF) {
-		ZM_DEBUG(zm_dprintf
-			 ("Framing error - blk: %x/%x/%x\n", xyz.blk, xyz.cblk,
-			  (xyz.blk ^ xyz.cblk)));
-		ZM_DEBUG(zm_dump_buf(xyz.pkt, xyz.len));
-		xyzModem_flush();
-		return xyzModem_frame;
-	}
-	/* Verify checksum/CRC */
-	if (xyz.crc_mode) {
-		cksum = cyg_crc16(xyz.pkt, xyz.len);
-		if (cksum != ((xyz.crc1 << 8) | xyz.crc2)) {
-			ZM_DEBUG(zm_dprintf
-				 ("CRC error - recvd: %02x%02x, computed: %x\n",
-				  xyz.crc1, xyz.crc2, cksum & 0xFFFF));
-			return xyzModem_cksum;
-		}
-	} else {
-		cksum = 0;
-		for (i = 0; i < xyz.len; i++)
-			cksum += xyz.pkt[i];
-		if (xyz.crc1 != (cksum & 0xFF)) {
-			ZM_DEBUG(zm_dprintf
-				 ("Checksum error - recvd: %x, computed: %x\n",
-				  xyz.crc1, cksum & 0xFF));
-			return xyzModem_cksum;
-		}
-	}
-	/* If we get here, the message passes [structural] muster */
-	return 0;
-}
-
-int xyzModem_stream_open(connection_info_t *info, int *err)
-{
-#ifdef REDBOOT
-	int console_chan;
-#endif
-	int stat = 0;
-	int retries = xyzModem_MAX_RETRIES;
-	int crc_retries = xyzModem_MAX_RETRIES_WITH_CRC;
-
-/*    ZM_DEBUG(zm_out = zm_out_start); */
-#ifdef xyzModem_zmodem
-	if (info->mode == xyzModem_zmodem) {
-		*err = xyzModem_noZmodem;
-		return -1;
-	}
-#endif
-
-#ifdef REDBOOT
-	/* Set up the I/O channel.  Note: this allows for using a different
-	 * port in the future */
-	console_chan =
-	    CYGACC_CALL_IF_SET_CONSOLE_COMM
-	    (CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT);
-	if (info->chan >= 0)
-		CYGACC_CALL_IF_SET_CONSOLE_COMM(info->chan);
-	else
-		CYGACC_CALL_IF_SET_CONSOLE_COMM(console_chan);
-
-	xyz.__chan = CYGACC_CALL_IF_CONSOLE_PROCS();
-
-	CYGACC_CALL_IF_SET_CONSOLE_COMM(console_chan);
-	CYGACC_COMM_IF_CONTROL(*xyz.__chan, __COMMCTL_SET_TIMEOUT,
-			       xyzModem_CHAR_TIMEOUT);
-#else
-/* TODO: CHECK ! */
-	int dummy = 0;
-	xyz.__chan = &dummy;
-#endif
-	xyz.len = 0;
-	xyz.crc_mode = true;
-	xyz.at_eof = false;
-	xyz.tx_ack = false;
-	xyz.mode = info->mode;
-	xyz.total_retries = 0;
-	xyz.total_SOH = 0;
-	xyz.total_STX = 0;
-	xyz.total_CAN = 0;
-#ifdef USE_YMODEM_LENGTH
-	xyz.read_length = 0;
-	xyz.file_length = 0;
-#endif
-
-	CYGACC_COMM_IF_PUTC(*xyz.__chan, (xyz.crc_mode ? 'C' : NAK));
-
-	if (xyz.mode == xyzModem_xmodem) {
-		/* X-modem doesn't have an information header - exit here */
-		xyz.next_blk = 1;
-		return 0;
-	}
-
-	while (retries-- > 0) {
-		stat = xyzModem_get_hdr();
-		if (stat == 0) {
-			/* Y-modem file information header */
-			if (xyz.blk == 0) {
-#ifdef USE_YMODEM_LENGTH
-				/* skip filename */
-				while (*xyz.bufp++) ;
-				/* get the length */
-				parse_num((char *)xyz.bufp, &xyz.file_length,
-					  NULL, " ");
-#endif
-				/* The rest of the file name data block
-				 * quietly discarded
-				 */
-				xyz.tx_ack = true;
-			}
-			xyz.next_blk = 1;
-			xyz.len = 0;
-			return 0;
-		} else if (stat == xyzModem_timeout) {
-			if (--crc_retries <= 0)
-				xyz.crc_mode = false;
-			/* Extra delay for startup */
-			CYGACC_CALL_IF_DELAY_US(5 * 100000);
-			CYGACC_COMM_IF_PUTC(*xyz.__chan,
-					    (xyz.crc_mode ? 'C' : NAK));
-			xyz.total_retries++;
-			ZM_DEBUG(zm_dprintf("NAK (%d)\n", __LINE__));
-		}
-		if (stat == xyzModem_cancel)
-			break;
-	}
-	*err = stat;
-	ZM_DEBUG(zm_flush());
-	return -1;
-}
-
-int xyzModem_stream_read(char *buf, int size, int *err)
-{
-	int stat, total, len;
-	int retries;
-
-	total = 0;
-	stat = xyzModem_cancel;
-	/* Try and get 'size' bytes into the buffer */
-	while (!xyz.at_eof && (size > 0)) {
-		if (xyz.len == 0) {
-			retries = xyzModem_MAX_RETRIES;
-			while (retries-- > 0) {
-				stat = xyzModem_get_hdr();
-				if (stat == 0) {
-					if (xyz.blk == xyz.next_blk) {
-						xyz.tx_ack = true;
-						ZM_DEBUG(zm_dprintf
-							 ("ACK block %d (%d)\n",
-							  xyz.blk, __LINE__));
-						xyz.next_blk =
-						    (xyz.next_blk + 1) & 0xFF;
-
-#if defined(xyzModem_zmodem) || defined(USE_YMODEM_LENGTH)
-						if (xyz.mode == xyzModem_xmodem
-						    || xyz.file_length == 0) {
-#else
-						if (1) {
-#endif
-			/* WARNING - Leaving formatting aside for code
-			 * clarity */
-			/* Data blocks can be padded with ^Z (EOF) characters */
-			/* This code tries to detect and remove them */
-			if ((xyz.bufp[xyz.len - 1] == EOF)
-			    && (xyz.bufp[xyz.len - 2] == EOF)
-			    && (xyz.bufp[xyz.len - 3] == EOF)) {
-				while (xyz.len &&
-					(xyz.bufp[xyz.len - 1] == EOF))
-						xyz.len--;
-				}
-			}
-#ifdef USE_YMODEM_LENGTH
-			/* WARNING - Leaving formatting aside for code
-			 * clarity */
-			/*
-			 * See if accumulated length exceeds that of the file.
-			 * If so, reduce size (i.e., cut out pad bytes)
-			 * Only do this for Y-modem (and Z-modem should it ever
-			 * be supported since it can fall back to Y-modem mode).
-			 */
-			if (xyz.mode != xyzModem_xmodem
-			    && 0 != xyz.file_length) {
-				xyz.read_length += xyz.len;
-				if (xyz.read_length > xyz.file_length)
-					xyz.len -= (xyz.read_length -
-					     xyz.file_length);
-			}
-#endif
-						break;
-					} else if (xyz.blk ==
-						   ((xyz.next_blk - 1) &
-						    0xFF)) {
-						/* Just re-ACK this so sender
-						 * will get on with it */
-						CYGACC_COMM_IF_PUTC(*xyz.__chan,
-								    ACK);
-						/* Need new header */
-						continue;
-					} else
-						stat = xyzModem_sequence;
-				}
-				if (stat == xyzModem_cancel)
-					break;
-				if (stat == xyzModem_eof) {
-					CYGACC_COMM_IF_PUTC(*xyz.__chan, ACK);
-					ZM_DEBUG(zm_dprintf
-						 ("ACK (%d)\n", __LINE__));
-					if (xyz.mode == xyzModem_ymodem) {
-						CYGACC_COMM_IF_PUTC(*xyz.__chan,
-								    (xyz.
-								     crc_mode ?
-								     'C' :
-								     NAK));
-						xyz.total_retries++;
-						ZM_DEBUG(zm_dprintf
-						 ("Reading Final Header\n"));
-						stat = xyzModem_get_hdr();
-						CYGACC_COMM_IF_PUTC(*xyz.__chan,
-								    ACK);
-						ZM_DEBUG(zm_dprintf
-							 ("FINAL ACK (%d)\n",
-							  __LINE__));
-					}
-					xyz.at_eof = true;
-					break;
-				}
-				CYGACC_COMM_IF_PUTC(*xyz.__chan,
-						    (xyz.crc_mode ? 'C' : NAK));
-				xyz.total_retries++;
-				ZM_DEBUG(zm_dprintf("NAK (%d)\n", __LINE__));
-			}
-			if (stat < 0) {
-				*err = stat;
-				xyz.len = -1;
-				return total;
-			}
-		}
-		/* Don't "read" data from the EOF protocol package */
-		if (!xyz.at_eof) {
-			len = xyz.len;
-			if (size < len)
-				len = size;
-			memcpy(buf, xyz.bufp, len);
-			size -= len;
-			buf += len;
-			total += len;
-			xyz.len -= len;
-			xyz.bufp += len;
-		}
-	}
-	return total;
-}
-
-void xyzModem_stream_close(int *err)
-{
-	diag_printf
-	    ("xyzModem - %s mode, %d(SOH)/%d(STX)/%d(CAN) packets,"
-	     " %d retries\n",
-	     xyz.crc_mode ? "CRC" : "Cksum", xyz.total_SOH, xyz.total_STX,
-	     xyz.total_CAN, xyz.total_retries);
-	ZM_DEBUG(zm_flush());
-}
-
-/* Need to be able to clean out the input buffer, so have to take the */
-/* getc */
-void xyzModem_stream_terminate(bool abort, int (*getc) (void))
-{
-	int c;
-
-	if (abort) {
-		ZM_DEBUG(zm_dprintf("!!!! TRANSFER ABORT !!!!\n"));
-		switch (xyz.mode) {
-		case xyzModem_xmodem:
-		case xyzModem_ymodem:
-			/* The X/YMODEM Spec seems to suggest that multiple CAN
-			 * followed by an equal number of Backspaces is a
-			 * friendly way to get the other end to abort. */
-			CYGACC_COMM_IF_PUTC(*xyz.__chan, CAN);
-			CYGACC_COMM_IF_PUTC(*xyz.__chan, CAN);
-			CYGACC_COMM_IF_PUTC(*xyz.__chan, CAN);
-			CYGACC_COMM_IF_PUTC(*xyz.__chan, CAN);
-			CYGACC_COMM_IF_PUTC(*xyz.__chan, BSP);
-			CYGACC_COMM_IF_PUTC(*xyz.__chan, BSP);
-			CYGACC_COMM_IF_PUTC(*xyz.__chan, BSP);
-			CYGACC_COMM_IF_PUTC(*xyz.__chan, BSP);
-			/* Now consume the rest of what's waiting on the line.*/
-			ZM_DEBUG(zm_dprintf("Flushing serial line.\n"));
-			xyzModem_flush();
-			xyz.at_eof = true;
-			break;
-#ifdef xyzModem_zmodem
-		case xyzModem_zmodem:
-			/* Might support it some day I suppose. */
-#endif
-			break;
-		}
-	} else {
-		ZM_DEBUG(zm_dprintf("Engaging cleanup mode...\n"));
-		/*
-		 * Consume any trailing crap left in the inbuffer from
-		 * previous recieved blocks. Since very few files are an
-		 * exact multiple of the transfer block size, there will
-		 * almost always be some gunk here.
-		 * If we don't eat it now, RedBoot will think the user typed it.
-		 */
-		ZM_DEBUG(zm_dprintf("Trailing gunk:\n"));
-		while ((c = (*getc) ()) > -1) ;
-		ZM_DEBUG(zm_dprintf("\n"));
-		/*
-		 * Make a small delay to give terminal programs like minicom
-		 * time to get control again after their file transfer program
-		 * exits.
-		 */
-		CYGACC_CALL_IF_DELAY_US((cyg_int32) 250000);
-	}
-}
-
-char *xyzModem_error(int err)
-{
-	switch (err) {
-	case xyzModem_access:
-		return "Can't access file";
-		break;
-	case xyzModem_noZmodem:
-		return "Sorry, zModem not available yet";
-		break;
-	case xyzModem_timeout:
-		return "Timed out";
-		break;
-	case xyzModem_eof:
-		return "End of file";
-		break;
-	case xyzModem_cancel:
-		return "Cancelled";
-		break;
-	case xyzModem_frame:
-		return "Invalid framing";
-		break;
-	case xyzModem_cksum:
-		return "CRC/checksum error";
-		break;
-	case xyzModem_sequence:
-		return "Block sequence error";
-		break;
-	default:
-		return "Unknown error";
-		break;
-	}
-}
-
-/*
- * RedBoot interface
- */
-#if 0				/* SB */
-GETC_IO_FUNCS(xyzModem_io, xyzModem_stream_open, xyzModem_stream_close,
-	      xyzModem_stream_terminate, xyzModem_stream_read, xyzModem_error);
-RedBoot_load(xmodem, xyzModem_io, false, false, xyzModem_xmodem);
-RedBoot_load(ymodem, xyzModem_io, false, false, xyzModem_ymodem);
-#endif
diff --git a/include/xyzModem.h b/include/xyzModem.h
deleted file mode 100644
index a3ea768..0000000
--- a/include/xyzModem.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- *==========================================================================
- *
- *      xyzModem.h
- *
- *      RedBoot stream handler for xyzModem protocol
- *
- *==========================================================================
- *####ECOSGPLCOPYRIGHTBEGIN####
- * -------------------------------------------
- * This file is part of eCos, the Embedded Configurable Operating System.
- * Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
- * Copyright (C) 2002 Gary Thomas
- *
- * eCos is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 or (at your option) any later version.
- *
- * eCos is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with eCos; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * As a special exception, if other files instantiate templates or use macros
- * or inline functions from this file, or you compile this file and link it
- * with other works to produce a work based on this file, this file does not
- * by itself cause the resulting work to be covered by the GNU General Public
- * License. However the source code for this file must still be made available
- * in accordance with section (3) of the GNU General Public License.
- *
- * This exception does not invalidate any other reasons why a work based on
- * this file might be covered by the GNU General Public License.
- *
- * Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
- * at http: *sources.redhat.com/ecos/ecos-license/
- * -------------------------------------------
- *####ECOSGPLCOPYRIGHTEND####
- *==========================================================================
- *#####DESCRIPTIONBEGIN####
- *
- * Author(s):    gthomas
- * Contributors: gthomas
- * Date:         2000-07-14
- * Purpose:
- * Description:
- *
- * This code is part of RedBoot (tm).
- *
- *####DESCRIPTIONEND####
- *
- *==========================================================================
- */
-
-#ifndef _XYZMODEM_H_
-#define _XYZMODEM_H_
-
-#define xyzModem_xmodem 1
-#define xyzModem_ymodem 2
-/* Don't define this until the protocol support is in place */
-/*#define xyzModem_zmodem 3 */
-
-#define xyzModem_access   -1
-#define xyzModem_noZmodem -2
-#define xyzModem_timeout  -3
-#define xyzModem_eof      -4
-#define xyzModem_cancel   -5
-#define xyzModem_frame    -6
-#define xyzModem_cksum    -7
-#define xyzModem_sequence -8
-
-#define xyzModem_close 1
-#define xyzModem_abort 2
-
-
-#ifdef REDBOOT
-extern getc_io_funcs_t xyzModem_io;
-#else
-#define CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT
-#define CYGACC_CALL_IF_SET_CONSOLE_COMM(x)
-
-#define diag_vprintf vprintf
-#define diag_printf printf
-#define diag_vsprintf vsprintf
-
-#define CYGACC_CALL_IF_DELAY_US(x) udelay(x)
-
-typedef struct {
-    char *filename;
-    int   mode;
-    int   chan;
-#ifdef CYGPKG_REDBOOT_NETWORKING
-    struct sockaddr_in *server;
-#endif
-} connection_info_t;
-
-#endif
-
-
-int   xyzModem_stream_open(connection_info_t *info, int *err);
-void  xyzModem_stream_close(int *err);
-void  xyzModem_stream_terminate(bool method, int (*getc)(void));
-int   xyzModem_stream_read(char *buf, int size, int *err);
-char *xyzModem_error(int err);
-
-#endif /* _XYZMODEM_H_ */
-- 
1.7.10



From plagnioj at jcrosoft.com  Thu Nov  1 13:50:49 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu, 1 Nov 2012 18:50:49 +0100
Subject: [PATCH 0/2] Y-Modem implementation change
In-Reply-To: <1351791438-29967-1-git-send-email-robert.jarzmik@free.fr>
References: <1351791438-29967-1-git-send-email-robert.jarzmik@free.fr>
Message-ID: <20121101175049.GK29599@game.jcrosoft.org>

On 18:37 Thu 01 Nov     , Robert Jarzmik wrote:
> Hi everyone,
> 
> This patchset aims at changing the Y-Modem protocol implementation.
> You have already seen the RFC version, this is the next version, which :
>  - provides a much more tested version
>  - is ready for review
> 
> The following comments have been taken into account :
>  - Antony: testing on a serial line
>  - Sascha: split between protocol and commands
>  - Jean-Christophe: kermit protocol change
> 
> So before doing the real review, could I ask of you :
>  - Antony: could you redo your test over a serial line by applying only
>            the first patch so that you can compare loady and loady2 ?
>            Don't use "loady2 -g", as Y-Modem/G protocol requires a 
>            lossless line (USB), and a serial line cannot guarantee it.
>  - Sascha: does the split command/protocol suit you ?
>  - Jean-Christophe: I left the loadb implementation as it is. The goal
>                     of the patch is to change X-Modem and Y-Modem(G)
>                     implementation, not kermit. Could you test that I
>                     have not created a regression of loadb ?

I'll prefer to have a new command named xyz so we have no confusion between
loadb and the new one

Best Regards,
J.


From antonynpavlov at gmail.com  Thu Nov  1 14:47:35 2012
From: antonynpavlov at gmail.com (Antony Pavlov)
Date: Thu, 1 Nov 2012 22:47:35 +0400
Subject: [PATCH 0/2] Y-Modem implementation change
In-Reply-To: <20121101175049.GK29599@game.jcrosoft.org>
References: <1351791438-29967-1-git-send-email-robert.jarzmik@free.fr>
 <20121101175049.GK29599@game.jcrosoft.org>
Message-ID: <CAA4bVAESn=h7+5Wt6TQxuzjGN67uXvDNbQRW5eib2hNq-QGZeA@mail.gmail.com>

On 1 November 2012 21:50, Jean-Christophe PLAGNIOL-VILLARD
<plagnioj at jcrosoft.com> wrote:
> On 18:37 Thu 01 Nov     , Robert Jarzmik wrote:
>> Hi everyone,
>>
>> This patchset aims at changing the Y-Modem protocol implementation.
>> You have already seen the RFC version, this is the next version, which :
>>  - provides a much more tested version
>>  - is ready for review
>>
>> The following comments have been taken into account :
>>  - Antony: testing on a serial line
>>  - Sascha: split between protocol and commands
>>  - Jean-Christophe: kermit protocol change
>>
>> So before doing the real review, could I ask of you :
>>  - Antony: could you redo your test over a serial line by applying only
>>            the first patch so that you can compare loady and loady2 ?
>>            Don't use "loady2 -g", as Y-Modem/G protocol requires a
>>            lossless line (USB), and a serial line cannot guarantee it.
>>  - Sascha: does the split command/protocol suit you ?
>>  - Jean-Christophe: I left the loadb implementation as it is. The goal
>>                     of the patch is to change X-Modem and Y-Modem(G)
>>                     implementation, not kermit. Could you test that I
>>                     have not created a regression of loadb ?
>
> I'll prefer to have a new command named xyz so we have no confusion between
> loadb and the new one

AFAIK, the lrzsz's command for Y-Modem file receive is named 'rb'.

-- 
Best regards,
  Antony Pavlov


From s.hauer at pengutronix.de  Thu Nov  1 14:52:46 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu,  1 Nov 2012 19:52:46 +0100
Subject: [PATCH 1/3] defenv-2: remove initrd boot script
In-Reply-To: <1351795968-2352-1-git-send-email-s.hauer@pengutronix.de>
References: <1351795968-2352-1-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1351795968-2352-2-git-send-email-s.hauer@pengutronix.de>

This is mostly an example and does not have a real use, so remove
it to not have it in each and every environment.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 defaultenv-2/base/boot/initrd |   17 -----------------
 1 file changed, 17 deletions(-)
 delete mode 100644 defaultenv-2/base/boot/initrd

diff --git a/defaultenv-2/base/boot/initrd b/defaultenv-2/base/boot/initrd
deleted file mode 100644
index 7c44d07..0000000
--- a/defaultenv-2/base/boot/initrd
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/sh
-
-if [ "$1" = menu ]; then
-	boot-menu-add-entry "$0" "kernel + initrd via tftp"
-	exit
-fi
-
-path="/mnt/tftp"
-global.bootm.image="${path}/${global.user}-linux-${global.hostname}"
-global.bootm.initrd="${path}/initramfs"
-bootargs-root-initrd
-#global.bootm.oftree=<path to oftree>
-
-global.linux.bootargs.dyn.root="root=/dev/ram0"
-
-#bootargs-root-nfs -n "<path on server>" -s <serverip>
-#bootargs-root-ubi -r <volume> -m <mtdname>
-- 
1.7.10.4



From s.hauer at pengutronix.de  Thu Nov  1 14:52:45 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu,  1 Nov 2012 19:52:45 +0100
Subject: [PATCH] defenv-2: Make it simpler
Message-ID: <1351795968-2352-1-git-send-email-s.hauer@pengutronix.de>

The feedback I got from defenv-2 is often that it's too complicated. This
is an attempt to make it simpler to increase its acceptance. First several
of the /env/bin/bootargs-* scripts are removed since it adds complexity
for doubtful value. Then the content of several scripts from /env/init/*
is moved to the good old /env/config file. This way the things get back
more concentrated to a single place which is easier to remember.

Sascha

----------------------------------------------------------------
Sascha Hauer (3):
      defenv-2: remove initrd boot script
      defenv-2: remove some helper scripts
      defenv-2: bring back /env/config

 .../boards/crystalfontz-cfa10036/env/boot/mmc-ext3 |    2 +-
 .../crystalfontz-cfa10036/env/init/bootargs-base   |    8 ------
 .../crystalfontz-cfa10036/env/init/config-board    |    7 ++++++
 .../boards/crystalfontz-cfa10036/env/init/hostname |    8 ------
 .../freescale-mx51-pdk/env/init/bootargs-base      |    8 ------
 .../freescale-mx51-pdk/env/init/config-board       |    7 ++++++
 .../boards/freescale-mx51-pdk/env/init/hostname    |    8 ------
 .../freescale-mx6-sabrelite/env/init/bootargs-base |    8 ------
 .../freescale-mx6-sabrelite/env/init/config-board  |    7 ++++++
 .../freescale-mx6-sabrelite/env/init/hostname      |    8 ------
 arch/arm/boards/karo-tx53/env/init/bootargs-base   |    8 ------
 arch/arm/boards/karo-tx53/env/init/config-board    |    7 ++++++
 arch/arm/boards/karo-tx53/env/init/hostname        |    8 ------
 arch/arm/boards/pcm038/env/boot/nand-ubi           |    2 +-
 arch/arm/boards/pcm038/env/init/bootargs-base      |    8 ------
 arch/arm/boards/pcm038/env/init/config-board       |    7 ++++++
 arch/arm/boards/pcm038/env/init/hostname           |    8 ------
 arch/arm/boards/tqma53/env/init/bootargs-base      |    8 ------
 arch/arm/boards/tqma53/env/init/config-board       |    7 ++++++
 arch/arm/boards/tqma53/env/init/hostname           |    8 ------
 defaultenv-2/base/bin/bootargs-ip-barebox          |    7 ------
 defaultenv-2/base/bin/bootargs-ip-dhcp             |    5 ----
 defaultenv-2/base/bin/bootargs-ip-none             |    5 ----
 defaultenv-2/base/bin/bootargs-root-disk           |   26 --------------------
 defaultenv-2/base/bin/bootargs-root-ext            |   12 ---------
 defaultenv-2/base/bin/bootargs-root-initrd         |   16 ------------
 defaultenv-2/base/bin/bootargs-root-jffs2          |   21 ----------------
 defaultenv-2/base/bin/bootargs-root-nfs            |   20 ---------------
 defaultenv-2/base/bin/bootargs-root-ubi            |   24 ------------------
 defaultenv-2/base/bin/init                         |   10 ++++++--
 defaultenv-2/base/boot/initrd                      |   17 -------------
 defaultenv-2/base/boot/net                         |    2 +-
 defaultenv-2/base/config                           |   21 ++++++++++++++++
 defaultenv-2/base/data/boot-template               |    4 +--
 defaultenv-2/base/init/bootargs-base               |    8 ------
 defaultenv-2/base/init/general                     |   15 -----------
 defaultenv-2/base/init/hostname                    |    8 ------
 defaultenv-2/base/init/prompt                      |    7 ------
 defaultenv-2/menu/menu/mainmenu                    |    1 +
 39 files changed, 76 insertions(+), 295 deletions(-)
 delete mode 100644 arch/arm/boards/crystalfontz-cfa10036/env/init/bootargs-base
 create mode 100644 arch/arm/boards/crystalfontz-cfa10036/env/init/config-board
 delete mode 100644 arch/arm/boards/crystalfontz-cfa10036/env/init/hostname
 delete mode 100644 arch/arm/boards/freescale-mx51-pdk/env/init/bootargs-base
 create mode 100644 arch/arm/boards/freescale-mx51-pdk/env/init/config-board
 delete mode 100644 arch/arm/boards/freescale-mx51-pdk/env/init/hostname
 delete mode 100644 arch/arm/boards/freescale-mx6-sabrelite/env/init/bootargs-base
 create mode 100644 arch/arm/boards/freescale-mx6-sabrelite/env/init/config-board
 delete mode 100644 arch/arm/boards/freescale-mx6-sabrelite/env/init/hostname
 delete mode 100644 arch/arm/boards/karo-tx53/env/init/bootargs-base
 create mode 100644 arch/arm/boards/karo-tx53/env/init/config-board
 delete mode 100644 arch/arm/boards/karo-tx53/env/init/hostname
 delete mode 100644 arch/arm/boards/pcm038/env/init/bootargs-base
 create mode 100644 arch/arm/boards/pcm038/env/init/config-board
 delete mode 100644 arch/arm/boards/pcm038/env/init/hostname
 delete mode 100644 arch/arm/boards/tqma53/env/init/bootargs-base
 create mode 100644 arch/arm/boards/tqma53/env/init/config-board
 delete mode 100644 arch/arm/boards/tqma53/env/init/hostname
 delete mode 100644 defaultenv-2/base/bin/bootargs-ip-barebox
 delete mode 100644 defaultenv-2/base/bin/bootargs-ip-dhcp
 delete mode 100644 defaultenv-2/base/bin/bootargs-ip-none
 delete mode 100644 defaultenv-2/base/bin/bootargs-root-disk
 delete mode 100644 defaultenv-2/base/bin/bootargs-root-ext
 delete mode 100644 defaultenv-2/base/bin/bootargs-root-initrd
 delete mode 100644 defaultenv-2/base/bin/bootargs-root-jffs2
 delete mode 100644 defaultenv-2/base/bin/bootargs-root-nfs
 delete mode 100644 defaultenv-2/base/bin/bootargs-root-ubi
 delete mode 100644 defaultenv-2/base/boot/initrd
 create mode 100644 defaultenv-2/base/config
 delete mode 100644 defaultenv-2/base/init/bootargs-base
 delete mode 100644 defaultenv-2/base/init/general
 delete mode 100644 defaultenv-2/base/init/hostname
 delete mode 100644 defaultenv-2/base/init/prompt


From s.hauer at pengutronix.de  Thu Nov  1 14:52:47 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu,  1 Nov 2012 19:52:47 +0100
Subject: [PATCH 2/3] defenv-2: remove some helper scripts
In-Reply-To: <1351795968-2352-1-git-send-email-s.hauer@pengutronix.de>
References: <1351795968-2352-1-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1351795968-2352-3-git-send-email-s.hauer@pengutronix.de>

The added complexity of bootargs-ip-* and bootargs-root-* makes
understanding defenv-2 more complicated. remove them and open
code the scripts instead in their users.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 .../boards/crystalfontz-cfa10036/env/boot/mmc-ext3 |    2 +-
 arch/arm/boards/pcm038/env/boot/nand-ubi           |    2 +-
 defaultenv-2/base/bin/bootargs-ip-barebox          |    7 ------
 defaultenv-2/base/bin/bootargs-ip-dhcp             |    5 ----
 defaultenv-2/base/bin/bootargs-ip-none             |    5 ----
 defaultenv-2/base/bin/bootargs-root-disk           |   26 --------------------
 defaultenv-2/base/bin/bootargs-root-ext            |   12 ---------
 defaultenv-2/base/bin/bootargs-root-initrd         |   16 ------------
 defaultenv-2/base/bin/bootargs-root-jffs2          |   21 ----------------
 defaultenv-2/base/bin/bootargs-root-nfs            |   20 ---------------
 defaultenv-2/base/bin/bootargs-root-ubi            |   24 ------------------
 defaultenv-2/base/boot/net                         |    2 +-
 defaultenv-2/base/data/boot-template               |    4 +--
 13 files changed, 4 insertions(+), 142 deletions(-)
 delete mode 100644 defaultenv-2/base/bin/bootargs-ip-barebox
 delete mode 100644 defaultenv-2/base/bin/bootargs-ip-dhcp
 delete mode 100644 defaultenv-2/base/bin/bootargs-ip-none
 delete mode 100644 defaultenv-2/base/bin/bootargs-root-disk
 delete mode 100644 defaultenv-2/base/bin/bootargs-root-ext
 delete mode 100644 defaultenv-2/base/bin/bootargs-root-initrd
 delete mode 100644 defaultenv-2/base/bin/bootargs-root-jffs2
 delete mode 100644 defaultenv-2/base/bin/bootargs-root-nfs
 delete mode 100644 defaultenv-2/base/bin/bootargs-root-ubi

diff --git a/arch/arm/boards/crystalfontz-cfa10036/env/boot/mmc-ext3 b/arch/arm/boards/crystalfontz-cfa10036/env/boot/mmc-ext3
index 7d7eb50..b2325af 100644
--- a/arch/arm/boards/crystalfontz-cfa10036/env/boot/mmc-ext3
+++ b/arch/arm/boards/crystalfontz-cfa10036/env/boot/mmc-ext3
@@ -7,4 +7,4 @@ fi
 
 global.bootm.image="/mnt/disk0.1/zImage-cfa10036"
 global.bootm.oftree="/mnt/disk0.1/oftree-cfa10036"
-bootargs-root-ext -r 3 -m mmcblk0p3
+global.linux.bootargs.dyn.root="root=/dev/mmcblk0p3 rootfstype=ext3 rootwait"
diff --git a/arch/arm/boards/pcm038/env/boot/nand-ubi b/arch/arm/boards/pcm038/env/boot/nand-ubi
index a3f748e..67b0cb4 100644
--- a/arch/arm/boards/pcm038/env/boot/nand-ubi
+++ b/arch/arm/boards/pcm038/env/boot/nand-ubi
@@ -7,4 +7,4 @@ fi
 
 global.bootm.image="/dev/nand0.kernel.bb"
 #global.bootm.oftree="/env/oftree"
-bootargs-root-ubi -r root -m nand0.root
+global.linux.bootargs.dyn.root="root=ubi0:root ubi.mtd=nand0.root rootfstype=ubifs"
diff --git a/defaultenv-2/base/bin/bootargs-ip-barebox b/defaultenv-2/base/bin/bootargs-ip-barebox
deleted file mode 100644
index 5a3b984..0000000
--- a/defaultenv-2/base/bin/bootargs-ip-barebox
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-
-# pass barebox ip settings for eth0 to Linux
-
-ifup eth0
-
-global.linux.bootargs.dyn.ip="ip=$eth0.ipaddr:$eth0.serverip:$eth0.gateway:$eth0.netmask::eth0:"
diff --git a/defaultenv-2/base/bin/bootargs-ip-dhcp b/defaultenv-2/base/bin/bootargs-ip-dhcp
deleted file mode 100644
index dec8ae4..0000000
--- a/defaultenv-2/base/bin/bootargs-ip-dhcp
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-
-# Do dhcp in Linux
-
-global.linux.bootargs.dyn.ip="ip=dhcp"
diff --git a/defaultenv-2/base/bin/bootargs-ip-none b/defaultenv-2/base/bin/bootargs-ip-none
deleted file mode 100644
index 88aaa21..0000000
--- a/defaultenv-2/base/bin/bootargs-ip-none
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-
-# disable ip setup in Linux
-
-global.linux.bootargs.dyn.ip="ip=none"
diff --git a/defaultenv-2/base/bin/bootargs-root-disk b/defaultenv-2/base/bin/bootargs-root-disk
deleted file mode 100644
index aa60cf3..0000000
--- a/defaultenv-2/base/bin/bootargs-root-disk
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/bin/sh
-
-usage="$0 [OPTIONS]\n -p <partition>\n -t <fstype>"
-
-while getopt "p:t:h" opt; do
-	if [ ${opt} = p ]; then
-		part=${OPTARG}
-	elif [ ${opt} = t ]; then
-		fstype=${OPTARG}
-	elif [ ${opt} = h ]; then
-		echo -e "$usage"
-		exit 0
-	fi
-done
-
-if [ -z "${part}" ]; then
-	echo "$0: no partition given"
-	exit 1
-fi
-
-if [ -z "${fstype}" ]; then
-	echo "$0: no filesystem type given"
-	exit 1
-fi
-
-global.linux.bootargs.dyn.root="root=/dev/$part rootfstype=$fstype rootwait"
diff --git a/defaultenv-2/base/bin/bootargs-root-ext b/defaultenv-2/base/bin/bootargs-root-ext
deleted file mode 100644
index dbdddb9..0000000
--- a/defaultenv-2/base/bin/bootargs-root-ext
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/sh
-
-while getopt "m:r:" opt; do
-	if [ ${opt} = m ]; then
-		part=${OPTARG}
-	fi
-	if [ ${opt} = r ]; then
-		type=${OPTARG}
-	fi
-done
-
-global.linux.bootargs.dyn.root="root=/dev/$part rootfstype=ext$type rootwait"
diff --git a/defaultenv-2/base/bin/bootargs-root-initrd b/defaultenv-2/base/bin/bootargs-root-initrd
deleted file mode 100644
index cc711a1..0000000
--- a/defaultenv-2/base/bin/bootargs-root-initrd
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/sh
-
-rdinit="/sbin/init"
-
-usage="$0 [OPTIONS]\n -i <rdinitpath> (/sbin/init)"
-
-while getopt "i:h" opt; do
-	if [ ${opt} = i ]; then
-		rdinit=${OPTARG}
-	elif [ ${opt} = h ]; then
-		echo -e "$usage"
-		exit 0
-	fi
-done
-
-global.linux.bootargs.dyn.root="root=/dev/ram0 rdinit=${rdinit}"
diff --git a/defaultenv-2/base/bin/bootargs-root-jffs2 b/defaultenv-2/base/bin/bootargs-root-jffs2
deleted file mode 100644
index a8eb5e7..0000000
--- a/defaultenv-2/base/bin/bootargs-root-jffs2
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/bin/sh
-
-mtd=
-
-usage="$0 [OPTIONS]\n -m <mtd>"
-
-while getopt "m:h" opt; do
-	if [ ${opt} = m ]; then
-		mtd=${OPTARG}
-	elif [ ${opt} = h ]; then
-		echo -e "$usage"
-		exit 0
-	fi
-done
-
-if [ -z "$mtd" ]; then
-	echo -e "$usage"
-	exit 1
-fi
-
-global.linux.bootargs.dyn.root="root=$mtd rootfstype=jffs2"
diff --git a/defaultenv-2/base/bin/bootargs-root-nfs b/defaultenv-2/base/bin/bootargs-root-nfs
deleted file mode 100644
index 355f93d..0000000
--- a/defaultenv-2/base/bin/bootargs-root-nfs
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/sh
-
-usage="$0 [OPTIONS]\n -n <nfspath>\n -s <serverip>"
-
-while getopt "n:s:h" opt; do
-	if [ ${opt} = n ]; then
-		nfsroot=${OPTARG}
-	elif [ ${opt} = s ]; then
-		serverip=${OPTARG}
-	elif [ ${opt} = h ]; then
-		echo -e "$usage"
-		exit 0
-	fi
-done
-
-if [ -n ${serverip} ]; then
-	nfsroot="$serverip:$nfsroot"
-fi
-
-global.linux.bootargs.dyn.root="root=/dev/nfs nfsroot=$nfsroot,v3,tcp"
diff --git a/defaultenv-2/base/bin/bootargs-root-ubi b/defaultenv-2/base/bin/bootargs-root-ubi
deleted file mode 100644
index 4260336..0000000
--- a/defaultenv-2/base/bin/bootargs-root-ubi
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/sh
-
-ubiroot=root
-mtd=
-
-usage="$0 [OPTIONS]\n -r <ubiroot> (root)\n -m <mtd>"
-
-while getopt "m:r:h" opt; do
-	if [ ${opt} = r ]; then
-		ubiroot=${OPTARG}
-	elif [ ${opt} = m ]; then
-		mtd=${OPTARG}
-	elif [ ${opt} = h ]; then
-		echo -e "$usage"
-		exit 0
-	fi
-done
-
-if [ -z "$mtd" ]; then
-	echo -e "$usage"
-	exit 1
-fi
-
-global.linux.bootargs.dyn.root="root=ubi0:$ubiroot ubi.mtd=$mtd rootfstype=ubifs"
diff --git a/defaultenv-2/base/boot/net b/defaultenv-2/base/boot/net
index 922bef1..90c25aa 100644
--- a/defaultenv-2/base/boot/net
+++ b/defaultenv-2/base/boot/net
@@ -11,4 +11,4 @@ global.bootm.image="${path}/${global.user}-linux-${global.hostname}"
 #global.bootm.oftree="${path}/${global.user}-oftree-${global.hostname}"
 nfsroot="/home/${global.user}/nfsroot/${global.hostname}"
 bootargs-ip
-bootargs-root-nfs -n "$nfsroot"
+global.linux.bootargs.dyn.root="root=/dev/nfs nfsroot=$nfsroot,v3,tcp"
diff --git a/defaultenv-2/base/data/boot-template b/defaultenv-2/base/data/boot-template
index 1cacf18..9297499 100644
--- a/defaultenv-2/base/data/boot-template
+++ b/defaultenv-2/base/data/boot-template
@@ -11,6 +11,4 @@ global.bootm.image=<path to image>
 
 #bootargs-ip
 
-#bootargs-root-nfs -n "<path on server>" -s <serverip>
-#bootargs-root-jffs2 -m <mtdname>
-#bootargs-root-ubi -r <volume> -m <mtdname>
+global.linux.bootargs.dyn.root="root=<rootfs here>"
-- 
1.7.10.4



From s.hauer at pengutronix.de  Thu Nov  1 14:52:48 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu,  1 Nov 2012 19:52:48 +0100
Subject: [PATCH 3/3] defenv-2: bring back /env/config
In-Reply-To: <1351795968-2352-1-git-send-email-s.hauer@pengutronix.de>
References: <1351795968-2352-1-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1351795968-2352-4-git-send-email-s.hauer@pengutronix.de>

The idea of having /env/init/* scripts was to make the configuration
more flexible and customizable for boards. It turned out though that
people (including myself) do not find the place where they should
change these settings.

So this patch brings back /env/config for defenv-2. The individual
env/init/* scripts are removed and their content is added to
/env/init/config-board. This makes the values from /env/init/config-board
the board specific defaults which can be overwritten in /env/config.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 .../crystalfontz-cfa10036/env/init/bootargs-base   |    8 --------
 .../crystalfontz-cfa10036/env/init/config-board    |    7 +++++++
 .../boards/crystalfontz-cfa10036/env/init/hostname |    8 --------
 .../freescale-mx51-pdk/env/init/bootargs-base      |    8 --------
 .../freescale-mx51-pdk/env/init/config-board       |    7 +++++++
 .../boards/freescale-mx51-pdk/env/init/hostname    |    8 --------
 .../freescale-mx6-sabrelite/env/init/bootargs-base |    8 --------
 .../freescale-mx6-sabrelite/env/init/config-board  |    7 +++++++
 .../freescale-mx6-sabrelite/env/init/hostname      |    8 --------
 arch/arm/boards/karo-tx53/env/init/bootargs-base   |    8 --------
 arch/arm/boards/karo-tx53/env/init/config-board    |    7 +++++++
 arch/arm/boards/karo-tx53/env/init/hostname        |    8 --------
 arch/arm/boards/pcm038/env/init/bootargs-base      |    8 --------
 arch/arm/boards/pcm038/env/init/config-board       |    7 +++++++
 arch/arm/boards/pcm038/env/init/hostname           |    8 --------
 arch/arm/boards/tqma53/env/init/bootargs-base      |    8 --------
 arch/arm/boards/tqma53/env/init/config-board       |    7 +++++++
 arch/arm/boards/tqma53/env/init/hostname           |    8 --------
 defaultenv-2/base/bin/init                         |   10 ++++++++--
 defaultenv-2/base/config                           |   21 ++++++++++++++++++++
 defaultenv-2/base/init/bootargs-base               |    8 --------
 defaultenv-2/base/init/general                     |   15 --------------
 defaultenv-2/base/init/hostname                    |    8 --------
 defaultenv-2/base/init/prompt                      |    7 -------
 defaultenv-2/menu/menu/mainmenu                    |    1 +
 25 files changed, 72 insertions(+), 136 deletions(-)
 delete mode 100644 arch/arm/boards/crystalfontz-cfa10036/env/init/bootargs-base
 create mode 100644 arch/arm/boards/crystalfontz-cfa10036/env/init/config-board
 delete mode 100644 arch/arm/boards/crystalfontz-cfa10036/env/init/hostname
 delete mode 100644 arch/arm/boards/freescale-mx51-pdk/env/init/bootargs-base
 create mode 100644 arch/arm/boards/freescale-mx51-pdk/env/init/config-board
 delete mode 100644 arch/arm/boards/freescale-mx51-pdk/env/init/hostname
 delete mode 100644 arch/arm/boards/freescale-mx6-sabrelite/env/init/bootargs-base
 create mode 100644 arch/arm/boards/freescale-mx6-sabrelite/env/init/config-board
 delete mode 100644 arch/arm/boards/freescale-mx6-sabrelite/env/init/hostname
 delete mode 100644 arch/arm/boards/karo-tx53/env/init/bootargs-base
 create mode 100644 arch/arm/boards/karo-tx53/env/init/config-board
 delete mode 100644 arch/arm/boards/karo-tx53/env/init/hostname
 delete mode 100644 arch/arm/boards/pcm038/env/init/bootargs-base
 create mode 100644 arch/arm/boards/pcm038/env/init/config-board
 delete mode 100644 arch/arm/boards/pcm038/env/init/hostname
 delete mode 100644 arch/arm/boards/tqma53/env/init/bootargs-base
 create mode 100644 arch/arm/boards/tqma53/env/init/config-board
 delete mode 100644 arch/arm/boards/tqma53/env/init/hostname
 create mode 100644 defaultenv-2/base/config
 delete mode 100644 defaultenv-2/base/init/bootargs-base
 delete mode 100644 defaultenv-2/base/init/general
 delete mode 100644 defaultenv-2/base/init/hostname
 delete mode 100644 defaultenv-2/base/init/prompt

diff --git a/arch/arm/boards/crystalfontz-cfa10036/env/init/bootargs-base b/arch/arm/boards/crystalfontz-cfa10036/env/init/bootargs-base
deleted file mode 100644
index 4dda550..0000000
--- a/arch/arm/boards/crystalfontz-cfa10036/env/init/bootargs-base
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-
-if [ "$1" = menu ]; then
-	init-menu-add-entry "$0" "Base bootargs"
-	exit
-fi
-
-global.linux.bootargs.base="console=ttyAMA0,115200"
diff --git a/arch/arm/boards/crystalfontz-cfa10036/env/init/config-board b/arch/arm/boards/crystalfontz-cfa10036/env/init/config-board
new file mode 100644
index 0000000..b99866e
--- /dev/null
+++ b/arch/arm/boards/crystalfontz-cfa10036/env/init/config-board
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+# board defaults, do not change in running system. Change /env/config
+# instead
+
+global.hostname=cfa10036
+global.linux.bootargs.base="console=ttyAMA0,115200"
diff --git a/arch/arm/boards/crystalfontz-cfa10036/env/init/hostname b/arch/arm/boards/crystalfontz-cfa10036/env/init/hostname
deleted file mode 100644
index 1dbe346..0000000
--- a/arch/arm/boards/crystalfontz-cfa10036/env/init/hostname
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-
-if [ "$1" = menu ]; then
-	init-menu-add-entry "$0" "hostname"
-	exit
-fi
-
-global.hostname=cfa10036
diff --git a/arch/arm/boards/freescale-mx51-pdk/env/init/bootargs-base b/arch/arm/boards/freescale-mx51-pdk/env/init/bootargs-base
deleted file mode 100644
index d869754..0000000
--- a/arch/arm/boards/freescale-mx51-pdk/env/init/bootargs-base
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-
-if [ "$1" = menu ]; then
-	init-menu-add-entry "$0" "Base bootargs"
-	exit
-fi
-
-global.linux.bootargs.base="console=ttymxc0,115200"
diff --git a/arch/arm/boards/freescale-mx51-pdk/env/init/config-board b/arch/arm/boards/freescale-mx51-pdk/env/init/config-board
new file mode 100644
index 0000000..cfc483e
--- /dev/null
+++ b/arch/arm/boards/freescale-mx51-pdk/env/init/config-board
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+# board defaults, do not change in running system. Change /env/config
+# instead
+
+global.hostname=babbage
+global.linux.bootargs.base="console=ttymxc0,115200"
diff --git a/arch/arm/boards/freescale-mx51-pdk/env/init/hostname b/arch/arm/boards/freescale-mx51-pdk/env/init/hostname
deleted file mode 100644
index 4c78902..0000000
--- a/arch/arm/boards/freescale-mx51-pdk/env/init/hostname
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-
-if [ "$1" = menu ]; then
-	init-menu-add-entry "$0" "hostname"
-	exit
-fi
-
-global.hostname=babbage
diff --git a/arch/arm/boards/freescale-mx6-sabrelite/env/init/bootargs-base b/arch/arm/boards/freescale-mx6-sabrelite/env/init/bootargs-base
deleted file mode 100644
index 2c51feb..0000000
--- a/arch/arm/boards/freescale-mx6-sabrelite/env/init/bootargs-base
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-
-if [ "$1" = menu ]; then
-	init-menu-add-entry "$0" "Base bootargs"
-	exit
-fi
-
-global.linux.bootargs.base="console=ttymxc1,115200"
diff --git a/arch/arm/boards/freescale-mx6-sabrelite/env/init/config-board b/arch/arm/boards/freescale-mx6-sabrelite/env/init/config-board
new file mode 100644
index 0000000..e39e4b6
--- /dev/null
+++ b/arch/arm/boards/freescale-mx6-sabrelite/env/init/config-board
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+# board defaults, do not change in running system. Change /env/config
+# instead
+
+global.hostname=SabreLite
+global.linux.bootargs.base="console=ttymxc1,115200"
diff --git a/arch/arm/boards/freescale-mx6-sabrelite/env/init/hostname b/arch/arm/boards/freescale-mx6-sabrelite/env/init/hostname
deleted file mode 100644
index db5b2b2..0000000
--- a/arch/arm/boards/freescale-mx6-sabrelite/env/init/hostname
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-
-if [ "$1" = menu ]; then
-	init-menu-add-entry "$0" "hostname"
-	exit
-fi
-
-global.hostname=SabreLite
diff --git a/arch/arm/boards/karo-tx53/env/init/bootargs-base b/arch/arm/boards/karo-tx53/env/init/bootargs-base
deleted file mode 100644
index d869754..0000000
--- a/arch/arm/boards/karo-tx53/env/init/bootargs-base
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-
-if [ "$1" = menu ]; then
-	init-menu-add-entry "$0" "Base bootargs"
-	exit
-fi
-
-global.linux.bootargs.base="console=ttymxc0,115200"
diff --git a/arch/arm/boards/karo-tx53/env/init/config-board b/arch/arm/boards/karo-tx53/env/init/config-board
new file mode 100644
index 0000000..3ebfac6
--- /dev/null
+++ b/arch/arm/boards/karo-tx53/env/init/config-board
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+# board defaults, do not change in running system. Change /env/config
+# instead
+
+global.hostname=tx53
+global.linux.bootargs.base="console=ttymxc0,115200"
diff --git a/arch/arm/boards/karo-tx53/env/init/hostname b/arch/arm/boards/karo-tx53/env/init/hostname
deleted file mode 100644
index 2de9130..0000000
--- a/arch/arm/boards/karo-tx53/env/init/hostname
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-
-if [ "$1" = menu ]; then
-	init-menu-add-entry "$0" "hostname"
-	exit
-fi
-
-global.hostname=tx53
diff --git a/arch/arm/boards/pcm038/env/init/bootargs-base b/arch/arm/boards/pcm038/env/init/bootargs-base
deleted file mode 100644
index d869754..0000000
--- a/arch/arm/boards/pcm038/env/init/bootargs-base
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-
-if [ "$1" = menu ]; then
-	init-menu-add-entry "$0" "Base bootargs"
-	exit
-fi
-
-global.linux.bootargs.base="console=ttymxc0,115200"
diff --git a/arch/arm/boards/pcm038/env/init/config-board b/arch/arm/boards/pcm038/env/init/config-board
new file mode 100644
index 0000000..93fd41b
--- /dev/null
+++ b/arch/arm/boards/pcm038/env/init/config-board
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+# board defaults, do not change in running system. Change /env/config
+# instead
+
+global.hostname=pcm038
+global.linux.bootargs.base="console=ttymxc0,115200"
diff --git a/arch/arm/boards/pcm038/env/init/hostname b/arch/arm/boards/pcm038/env/init/hostname
deleted file mode 100644
index 09c2f08..0000000
--- a/arch/arm/boards/pcm038/env/init/hostname
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-
-if [ "$1" = menu ]; then
-	init-menu-add-entry "$0" "hostname"
-	exit
-fi
-
-global.hostname=pcm038
diff --git a/arch/arm/boards/tqma53/env/init/bootargs-base b/arch/arm/boards/tqma53/env/init/bootargs-base
deleted file mode 100644
index d869754..0000000
--- a/arch/arm/boards/tqma53/env/init/bootargs-base
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-
-if [ "$1" = menu ]; then
-	init-menu-add-entry "$0" "Base bootargs"
-	exit
-fi
-
-global.linux.bootargs.base="console=ttymxc0,115200"
diff --git a/arch/arm/boards/tqma53/env/init/config-board b/arch/arm/boards/tqma53/env/init/config-board
new file mode 100644
index 0000000..4776438
--- /dev/null
+++ b/arch/arm/boards/tqma53/env/init/config-board
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+# board defaults, do not change in running system. Change /env/config
+# instead
+
+global.hostname=tqma53
+global.linux.bootargs.base="console=ttymxc0,115200"
diff --git a/arch/arm/boards/tqma53/env/init/hostname b/arch/arm/boards/tqma53/env/init/hostname
deleted file mode 100644
index c56ac6a..0000000
--- a/arch/arm/boards/tqma53/env/init/hostname
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-
-if [ "$1" = menu ]; then
-	init-menu-add-entry "$0" "hostname"
-	exit
-fi
-
-global.hostname=tqma53
diff --git a/defaultenv-2/base/bin/init b/defaultenv-2/base/bin/init
index 8e8871d..bb4abcd 100644
--- a/defaultenv-2/base/bin/init
+++ b/defaultenv-2/base/bin/init
@@ -8,12 +8,18 @@ global autoboot_timeout=3
 global boot.default=net
 global allow_color=true
 global linux.bootargs.base
-#linux.bootargs.dyn.* will be clearer at the beginning of boot
+#linux.bootargs.dyn.* will be cleared at the beginning of boot
 global linux.bootargs.dyn.ip
 global linux.bootargs.dyn.root
 global editcmd=sedit
 
-/env/init/general
+/env/config
+
+if [ ${global.allow_color} = "true" ]; then
+        export PS1="\e[1;32mbarebox@\e[1;36m\h:\w\e[0m "
+else
+        export PS1="barebox@\h:\w "
+fi
 
 if [ -e /env/menu ]; then
 	echo -e -n "\nHit m for menu or any other key to stop autoboot: "
diff --git a/defaultenv-2/base/config b/defaultenv-2/base/config
new file mode 100644
index 0000000..189e5a6
--- /dev/null
+++ b/defaultenv-2/base/config
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+# change network settings in /env/network/eth0
+# change mtd partition settings and automountpoints in /env/init/*
+
+#global.hostname=
+
+# set to false if you do not want to have colors
+global.allow_color=true
+
+# user (used for network filenames)
+global.user=none
+
+# timeout in seconds before the default boot entry is started
+global.autoboot_timeout=3
+
+# default boot entry (one of /env/boot/*)
+global.boot.default=net
+
+# base bootargs
+#global.linux.bootargs.base="console=ttyS0,115200"
diff --git a/defaultenv-2/base/init/bootargs-base b/defaultenv-2/base/init/bootargs-base
deleted file mode 100644
index 8e588ad..0000000
--- a/defaultenv-2/base/init/bootargs-base
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-
-if [ "$1" = menu ]; then
-	init-menu-add-entry "$0" "Base bootargs"
-	exit
-fi
-
-global.linux.bootargs.base="console=ttyS0,115200"
diff --git a/defaultenv-2/base/init/general b/defaultenv-2/base/init/general
deleted file mode 100644
index 1de06ce..0000000
--- a/defaultenv-2/base/init/general
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-
-if [ "$1" = menu ]; then
-	init-menu-add-entry "$0" "general config settings"
-	exit
-fi
-
-# user (used for network filenames)
-global.user=none
-
-# timeout in seconds before the default boot entry is started
-global.autoboot_timeout=3
-
-# default boot entry (one of /env/boot/*)
-global.boot.default=net
diff --git a/defaultenv-2/base/init/hostname b/defaultenv-2/base/init/hostname
deleted file mode 100644
index 57a2c94..0000000
--- a/defaultenv-2/base/init/hostname
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-
-if [ "$1" = menu ]; then
-	init-menu-add-entry "$0" "hostname"
-	exit
-fi
-
-global.hostname=generic
diff --git a/defaultenv-2/base/init/prompt b/defaultenv-2/base/init/prompt
deleted file mode 100644
index 11dce9f..0000000
--- a/defaultenv-2/base/init/prompt
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-
-if [ ${global.allow_color} = "true" ]; then
-	export PS1="\e[1;32mbarebox@\e[1;36m\h:\w\e[0m "
-else
-	export PS1="barebox@\h:\w "
-fi
diff --git a/defaultenv-2/menu/menu/mainmenu b/defaultenv-2/menu/menu/mainmenu
index 5bd7027..c74cc9c 100644
--- a/defaultenv-2/menu/menu/mainmenu
+++ b/defaultenv-2/menu/menu/mainmenu
@@ -15,6 +15,7 @@ while true; do
 	boot-entries-collect
 
 	menu -e -a -R -m boot -c "$global.editcmd /env/network/eth0" -d "Network settings"
+	menu -e -a -R -m boot -c "$global.editcmd /env/config" -d "Config settings"
 	menu -e -a -m boot -c "boot-entries-edit" -d "Edit boot entries"
 	menu -e -a -m boot -c "init-entries-edit" -d "Edit init entries"
 	menu -e -a -R -m boot -c "saveenv || echo \"failed to save environment\" && sleep 2" -d "Save settings"
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Thu Nov  1 14:52:08 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu,  1 Nov 2012 19:52:08 +0100
Subject: [PATCH 1/1 v2] at91sam9x5ek: add i2c support
In-Reply-To: <1351782447-32199-7-git-send-email-plagnioj@jcrosoft.com>
References: <1351782447-32199-7-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1351795928-18677-1-git-send-email-plagnioj@jcrosoft.com>

enable the qt1070 for debug only as this slow down barebox a lot
as we need to read the i2c via poller

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
HI

branch updated

The following changes since commit 3a5609a37a19b0b6b5f4c61e3c561b7bf2d25b72:

  i2c: add versatile support (2012-11-01 06:58:21 +0800)

are available in the git repository at:

  git://git.jcrosoft.org/barebox.git delivery/at91_i2c

for you to fetch changes up to 3c67dcab6fc9b1ab0966b2693f2952209f18cdda:

  at91sam9x5ek: add i2c support (2012-11-01 11:26:25 +0800)

Jean-Christophe PLAGNIOL-VILLARD (7):
      at91sam9x5: add i2c support
      at91rm9200: add i2c support
      at91sam9260/sam9g20: add i2c support
      at91sam9263: add i2c support
      at91sam9261/sam9g10: add i2c support
      at91sam9g45: add i2c support
      at91sam9x5ek: add i2c support

 arch/arm/boards/at91sam9x5ek/init.c      |   12 ++++++++++++
 arch/arm/configs/at91sam9x5ek_defconfig  |    3 +++
 arch/arm/mach-at91/at91rm9200_devices.c  |   28 ++++++++++++++++++++++++++++
 arch/arm/mach-at91/at91sam9260_devices.c |   32 ++++++++++++++++++++++++++++++++
 arch/arm/mach-at91/at91sam9261_devices.c |   31 +++++++++++++++++++++++++++++++
 arch/arm/mach-at91/at91sam9263_devices.c |   31 +++++++++++++++++++++++++++++++
 arch/arm/mach-at91/at91sam9g45_devices.c |   50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-at91/at91sam9x5_devices.c  |   58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-at91/include/mach/board.h  |    3 +++
 9 files changed, 248 insertions(+)

Best Regards,
J.
 arch/arm/configs/at91sam9x5ek_defconfig |    3 +++
 2 files changed, 15 insertions(+)

diff --git a/arch/arm/boards/at91sam9x5ek/init.c b/arch/arm/boards/at91sam9x5ek/init.c
index 78f7349..48eebac 100644
--- a/arch/arm/boards/at91sam9x5ek/init.c
+++ b/arch/arm/boards/at91sam9x5ek/init.c
@@ -114,6 +114,17 @@ static void ek_add_device_eth(void)
 	at91_add_device_eth(0, &macb_pdata);
 }
 
+static struct i2c_board_info i2c_devices[] = {
+	{
+		I2C_BOARD_INFO("qt1070", 0x1b),
+	},
+};
+
+static void ek_add_device_i2c(void)
+{
+	at91_add_device_i2c(0, i2c_devices, ARRAY_SIZE(i2c_devices));
+}
+
 /*
  * USB Host port
  */
@@ -172,6 +183,7 @@ static int at91sam9x5ek_devices_init(void)
 	ek_add_device_eth();
 	at91_add_device_usbh_ohci(&ek_usbh_data);
 	ek_add_led();
+	ek_add_device_i2c();
 
 	armlinux_set_bootparams((void *)(AT91_CHIPSELECT_1 + 0x100));
 	armlinux_set_architecture(CONFIG_MACH_AT91SAM9X5EK);
diff --git a/arch/arm/configs/at91sam9x5ek_defconfig b/arch/arm/configs/at91sam9x5ek_defconfig
index 6315d9f..c71fe0d 100644
--- a/arch/arm/configs/at91sam9x5ek_defconfig
+++ b/arch/arm/configs/at91sam9x5ek_defconfig
@@ -41,6 +41,7 @@ CONFIG_CMD_OFTREE=y
 CONFIG_CMD_TIMEOUT=y
 CONFIG_CMD_PARTITION=y
 CONFIG_CMD_GPIO=y
+CONFIG_CMD_I2C=y
 CONFIG_CMD_LED=y
 CONFIG_CMD_LED_TRIGGER=y
 CONFIG_NET=y
@@ -52,6 +53,8 @@ CONFIG_FS_TFTP=y
 CONFIG_NET_NETCONSOLE=y
 CONFIG_DRIVER_NET_MACB=y
 # CONFIG_SPI is not set
+CONFIG_I2C=y
+CONFIG_I2C_GPIO=y
 CONFIG_MTD=y
 CONFIG_NAND=y
 # CONFIG_NAND_ECC_HW is not set
-- 
1.7.10.4



From antonynpavlov at gmail.com  Thu Nov  1 15:19:36 2012
From: antonynpavlov at gmail.com (Antony Pavlov)
Date: Thu, 1 Nov 2012 23:19:36 +0400
Subject: [PATCH 0/2] Y-Modem implementation change
In-Reply-To: <1351791438-29967-1-git-send-email-robert.jarzmik@free.fr>
References: <1351791438-29967-1-git-send-email-robert.jarzmik@free.fr>
Message-ID: <CAA4bVAFj-_LAKnedX-epOv_9EatCvYGCRLe3SS=g8QqDTw+q_g@mail.gmail.com>

On 1 November 2012 21:37, Robert Jarzmik <robert.jarzmik at free.fr> wrote:
> Hi everyone,
>
> This patchset aims at changing the Y-Modem protocol implementation.
> You have already seen the RFC version, this is the next version, which :
>  - provides a much more tested version
>  - is ready for review
>
> The following comments have been taken into account :
>  - Antony: testing on a serial line
>  - Sascha: split between protocol and commands
>  - Jean-Christophe: kermit protocol change
>
> So before doing the real review, could I ask of you :
>  - Antony: could you redo your test over a serial line by applying only
>            the first patch so that you can compare loady and loady2 ?
>            Don't use "loady2 -g", as Y-Modem/G protocol requires a
>            lossless line (USB), and a serial line cannot guarantee it.

I have redone the test.

Sorry, but the new 'loady2' does not work. I tested it over 9600 and
over 115200 serial line.

>  - Sascha: does the split command/protocol suit you ?
>  - Jean-Christophe: I left the loadb implementation as it is. The goal
>                     of the patch is to change X-Modem and Y-Modem(G)
>                     implementation, not kermit. Could you test that I
>                     have not created a regression of loadb ?
>
> Cheers.
>
> --
> Robert
>
> Robert Jarzmik (2):
>   commands: change Y-Modem implementation
>   commands: remove old Y-Modem implementation
>
>  commands/Makefile   |    4 +-
>  commands/loadb.c    |  102 +------
>  commands/loads.c    |    1 -
>  commands/loadxy.c   |  238 ++++++++++++++++
>  commands/xymodem.c  |  552 ++++++++++++++++++++++++++++++++++++
>  commands/xyzModem.c |  785 ---------------------------------------------------
>  include/xymodem.h   |   25 ++
>  include/xyzModem.h  |  109 -------
>  8 files changed, 826 insertions(+), 990 deletions(-)
>  create mode 100644 commands/loadxy.c
>  create mode 100644 commands/xymodem.c
>  delete mode 100644 commands/xyzModem.c
>  create mode 100644 include/xymodem.h
>  delete mode 100644 include/xyzModem.h
>
> --
> 1.7.10
>



-- 
Best regards,
  Antony Pavlov


From s.hauer at pengutronix.de  Thu Nov  1 15:21:07 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu, 1 Nov 2012 20:21:07 +0100
Subject: [PATCH 06/28] ARM i.MX boards: switch to barebox_arm_entry
In-Reply-To: <1350508337.128691867@f327.mail.ru>
References: <1350507817-7819-1-git-send-email-s.hauer@pengutronix.de>
 <1350507817-7819-7-git-send-email-s.hauer@pengutronix.de>
 <1350508337.128691867@f327.mail.ru>
Message-ID: <20121101192107.GZ24458@pengutronix.de>

Hi Alexander,

On Thu, Oct 18, 2012 at 01:12:17AM +0400, Alexander Shiyan wrote:
> Wed, 17 Oct 2012 23:03:15 +0200 ?? Sascha Hauer <s.hauer at pengutronix.de>:
> >Most i.MX boards can use the imx*_barebox_entry functions. The remaining
> (i.MX21, i.MX6) use hardcoded base addresses.
> Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
> >
> Sascha, stop. Too many patches while you need to prepare stable version for conference.
> Really, stop and try to make one more stable version for your presentation.
> ;) Sorry, but I think about all :)

Although until now I haven't answered this mail I for sure have read it,
and yes, you are right. That's why I have concentrated on getting some
fixes out rather than adding more features. Thanks for pointing that out
;)

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From plagnioj at jcrosoft.com  Thu Nov  1 15:30:02 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu, 1 Nov 2012 20:30:02 +0100
Subject: [PATCH 0/4] at91sam9x5ek: add spi and mci support
Message-ID: <20121101193002.GL29599@game.jcrosoft.org>

HI,

	with this +1 patch serie the support of the at91sam9x5ek is mostly
	complete

	This will add spi and mci0 support as spi0 and mci0 conflict

	We are still missing framebuffer, usb host and device and hardware i2c support
	but this wil be added later

	This patch serie depedsn on the at91sam9x5ek i2c and m25p80 patcheries

The following changes since commit 04ffb7b107af50bd64d803b72e5fc315180381a2:

  m25p80: sync flash support with the kernel (2012-11-01 12:15:26 +0800)

are available in the git repository at:

  git://git.jcrosoft.org/barebox.git delivery/at91sam9x5ek_mci_spi

for you to fetch changes up to 2c12218e89c0318dc9bed4f7f397b68903b4203e:

  at91sam9x5ek: add mci support (2012-11-01 12:15:41 +0800)

----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (4):
      at91sam9x5: add spi support
      at91sam9x5ek: add spi support
      at91sam9x5: add mci support
      at91sam9x5ek: add mci support

 arch/arm/boards/at91sam9x5ek/init.c     |   51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 arch/arm/configs/at91sam9x5ek_defconfig |   10 +++++++---
 arch/arm/mach-at91/at91sam9x5.c         |    4 ++++
 arch/arm/mach-at91/at91sam9x5_devices.c |  124 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 186 insertions(+), 3 deletions(-)

Best Regards,
J.


From s.hauer at pengutronix.de  Thu Nov  1 15:33:51 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu, 1 Nov 2012 20:33:51 +0100
Subject: [PATCH 0/2] Y-Modem implementation change
In-Reply-To: <1351791438-29967-1-git-send-email-robert.jarzmik@free.fr>
References: <1351791438-29967-1-git-send-email-robert.jarzmik@free.fr>
Message-ID: <20121101193351.GZ1641@pengutronix.de>

On Thu, Nov 01, 2012 at 06:37:16PM +0100, Robert Jarzmik wrote:
> Hi everyone,
> 
> This patchset aims at changing the Y-Modem protocol implementation.
> You have already seen the RFC version, this is the next version, which :
>  - provides a much more tested version
>  - is ready for review
> 
> The following comments have been taken into account :
>  - Antony: testing on a serial line
>  - Sascha: split between protocol and commands
>  - Jean-Christophe: kermit protocol change
> 
> So before doing the real review, could I ask of you :
>  - Antony: could you redo your test over a serial line by applying only
>            the first patch so that you can compare loady and loady2 ?
>            Don't use "loady2 -g", as Y-Modem/G protocol requires a 
>            lossless line (USB), and a serial line cannot guarantee it.
>  - Sascha: does the split command/protocol suit you ?

Almost, yes. The backend support should go to common/ or lib/ and get
its own (invisible) Kconfig symbol which is then selected by the command.
So:

lib/ or common/:

config XYZMODEM
	bool

command/:

config CMD_XYZMODEM
	bool "bla"
	select XYZMODEM
	help
	  ...

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From plagnioj at jcrosoft.com  Thu Nov  1 15:36:19 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu,  1 Nov 2012 20:36:19 +0100
Subject: [PATCH 1/4] at91sam9x5: add spi support
In-Reply-To: <20121101193002.GL29599@game.jcrosoft.org>
References: <20121101193002.GL29599@game.jcrosoft.org>
Message-ID: <1351798582-22667-1-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/mach-at91/at91sam9x5.c         |    2 +
 arch/arm/mach-at91/at91sam9x5_devices.c |   62 +++++++++++++++++++++++++++++++
 2 files changed, 64 insertions(+)

diff --git a/arch/arm/mach-at91/at91sam9x5.c b/arch/arm/mach-at91/at91sam9x5.c
index c256989..a9065ff 100644
--- a/arch/arm/mach-at91/at91sam9x5.c
+++ b/arch/arm/mach-at91/at91sam9x5.c
@@ -205,6 +205,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
 	CLKDEV_CON_DEV_ID("macb_clk", "macb0", &macb0_clk),
 	CLKDEV_CON_DEV_ID("macb_clk", "macb1", &macb1_clk),
 	CLKDEV_CON_ID("ohci_clk", &uhphs_clk),
+	CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi0", &spi0_clk),
+	CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi1", &spi1_clk),
 };
 
 static struct clk_lookup usart_clocks_lookups[] = {
diff --git a/arch/arm/mach-at91/at91sam9x5_devices.c b/arch/arm/mach-at91/at91sam9x5_devices.c
index 5a24325..710ded7 100644
--- a/arch/arm/mach-at91/at91sam9x5_devices.c
+++ b/arch/arm/mach-at91/at91sam9x5_devices.c
@@ -228,6 +228,68 @@ void at91_add_device_i2c(short i2c_id, struct i2c_board_info *devices, int nr_de
 #endif
 
 /* --------------------------------------------------------------------
+ *  SPI
+ * -------------------------------------------------------------------- */
+
+#if defined(CONFIG_DRIVER_SPI_ATMEL)
+static unsigned spi0_standard_cs[4] = { AT91_PIN_PA14, AT91_PIN_PA7, AT91_PIN_PA1, AT91_PIN_PB3 };
+
+static unsigned spi1_standard_cs[4] = { AT91_PIN_PA8, AT91_PIN_PA0, AT91_PIN_PA31, AT91_PIN_PA30 };
+
+static struct at91_spi_platform_data spi_pdata[] = {
+	[0] = {
+		.chipselect = spi0_standard_cs,
+		.num_chipselect = ARRAY_SIZE(spi0_standard_cs),
+	},
+	[1] = {
+		.chipselect = spi1_standard_cs,
+		.num_chipselect = ARRAY_SIZE(spi1_standard_cs),
+	},
+};
+
+void at91_add_device_spi(int spi_id, struct at91_spi_platform_data *pdata)
+{
+	int i;
+	int cs_pin;
+	resource_size_t start = ~0;
+
+	BUG_ON(spi_id > 1);
+
+	if (!pdata)
+		pdata = &spi_pdata[spi_id];
+
+	for (i = 0; i < pdata->num_chipselect; i++) {
+		cs_pin = pdata->chipselect[i];
+
+		/* enable chip-select pin */
+		if (cs_pin > 0)
+			at91_set_gpio_output(cs_pin, 1);
+	}
+
+	/* Configure SPI bus(es) */
+	switch (spi_id) {
+	case 0:
+		start = AT91SAM9X5_BASE_SPI0;
+		at91_set_A_periph(AT91_PIN_PA11, 0);	/* SPI0_MISO */
+		at91_set_A_periph(AT91_PIN_PA12, 0);	/* SPI0_MOSI */
+		at91_set_A_periph(AT91_PIN_PA13, 0);	/* SPI0_SPCK */
+		break;
+	case 1:
+		start = AT91SAM9X5_BASE_SPI1;
+		at91_set_B_periph(AT91_PIN_PA21, 0);	/* SPI1_MISO */
+		at91_set_B_periph(AT91_PIN_PA22, 0);	/* SPI1_MOSI */
+		at91_set_B_periph(AT91_PIN_PA23, 0);	/* SPI1_SPCK */
+		break;
+	}
+
+	add_generic_device("atmel_spi", spi_id, NULL, start, SZ_16K,
+			   IORESOURCE_MEM, pdata);
+}
+#else
+void at91_add_device_spi(int spi_id, struct at91_spi_platform_data *pdata) {}
+#endif
+
+/* --------------------------------------------------------------------
  *  UART
  * -------------------------------------------------------------------- */
 
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Thu Nov  1 15:36:22 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu,  1 Nov 2012 20:36:22 +0100
Subject: [PATCH 4/4] at91sam9x5ek: add mci support
In-Reply-To: <1351798582-22667-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121101193002.GL29599@game.jcrosoft.org>
 <1351798582-22667-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1351798582-22667-4-git-send-email-plagnioj@jcrosoft.com>

only add mci0 (microSD slot) as mci1 conflict with spi0

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/boards/at91sam9x5ek/init.c     |   20 ++++++++++++++++++++
 arch/arm/configs/at91sam9x5ek_defconfig |    5 +++--
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boards/at91sam9x5ek/init.c b/arch/arm/boards/at91sam9x5ek/init.c
index 8f9fc0f..681be32 100644
--- a/arch/arm/boards/at91sam9x5ek/init.c
+++ b/arch/arm/boards/at91sam9x5ek/init.c
@@ -115,6 +115,25 @@ static void ek_add_device_eth(void)
 	at91_add_device_eth(0, &macb_pdata);
 }
 
+/*
+ * MCI (SD/MMC)
+ */
+/* mci0 detect_pin is revision dependent */
+static struct atmel_mci_platform_data mci0_data = {
+	.bus_width	= 4,
+	.detect_pin	= AT91_PIN_PD15,
+	.wp_pin		= 0,
+};
+
+static void ek_add_device_mci(void)
+{
+	if (at91sam9x5ek_cm_is_vendor(VENDOR_COGENT))
+		mci0_data.detect_pin = 0;
+
+	/* MMC0 */
+	at91_add_device_mci(0, &mci0_data);
+}
+
 static struct i2c_board_info i2c_devices[] = {
 	{
 		I2C_BOARD_INFO("qt1070", 0x1b),
@@ -212,6 +231,7 @@ static int at91sam9x5ek_devices_init(void)
 	ek_add_device_nand();
 	ek_add_device_eth();
 	ek_add_device_spi();
+	ek_add_device_mci();
 	at91_add_device_usbh_ohci(&ek_usbh_data);
 	ek_add_led();
 	ek_add_device_i2c();
diff --git a/arch/arm/configs/at91sam9x5ek_defconfig b/arch/arm/configs/at91sam9x5ek_defconfig
index 5611b95..d097683 100644
--- a/arch/arm/configs/at91sam9x5ek_defconfig
+++ b/arch/arm/configs/at91sam9x5ek_defconfig
@@ -65,8 +65,9 @@ CONFIG_NAND=y
 # CONFIG_NAND_ECC_HW_NONE is not set
 CONFIG_NAND_ATMEL=y
 CONFIG_UBI=y
-CONFIG_DISK=y
-CONFIG_DISK_WRITE=y
+CONFIG_MCI=y
+CONFIG_MCI_STARTUP=y
+CONFIG_MCI_ATMEL=y
 CONFIG_LED=y
 CONFIG_LED_GPIO=y
 CONFIG_LED_TRIGGERS=y
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Thu Nov  1 15:36:20 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu,  1 Nov 2012 20:36:20 +0100
Subject: [PATCH 2/4] at91sam9x5ek: add spi support
In-Reply-To: <1351798582-22667-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121101193002.GL29599@game.jcrosoft.org>
 <1351798582-22667-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1351798582-22667-2-git-send-email-plagnioj@jcrosoft.com>

on all the cpu module we have a at25 except on the cogent where we have a at45

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/boards/at91sam9x5ek/init.c     |   31 +++++++++++++++++++++++++++++++
 arch/arm/configs/at91sam9x5ek_defconfig |    5 ++++-
 2 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boards/at91sam9x5ek/init.c b/arch/arm/boards/at91sam9x5ek/init.c
index 48eebac..8f9fc0f 100644
--- a/arch/arm/boards/at91sam9x5ek/init.c
+++ b/arch/arm/boards/at91sam9x5ek/init.c
@@ -41,6 +41,7 @@
 #include <readkey.h>
 #include <linux/w1-gpio.h>
 #include <w1_mac_address.h>
+#include <spi/spi.h>
 
 #include "hw_version.h"
 
@@ -125,6 +126,35 @@ static void ek_add_device_i2c(void)
 	at91_add_device_i2c(0, i2c_devices, ARRAY_SIZE(i2c_devices));
 }
 
+static const struct spi_board_info ek_cm_cogent_spi_devices[] = {
+	{
+		.name		= "mtd_dataflash",
+		.chip_select	= 0,
+		.max_speed_hz	= 15 * 1000 * 1000,
+		.bus_num	= 0,
+	}
+};
+
+static const struct spi_board_info ek_spi_devices[] = {
+	{
+		.name		= "m25p80",
+		.chip_select	= 0,
+		.max_speed_hz	= 30 * 1000 * 1000,
+		.bus_num	= 0,
+	}
+};
+
+static void ek_add_device_spi(void)
+{
+	if (at91sam9x5ek_cm_is_vendor(VENDOR_COGENT))
+		spi_register_board_info(ek_cm_cogent_spi_devices,
+				ARRAY_SIZE(ek_cm_cogent_spi_devices));
+	else
+		spi_register_board_info(ek_spi_devices,
+				ARRAY_SIZE(ek_spi_devices));
+	at91_add_device_spi(0, NULL);
+}
+
 /*
  * USB Host port
  */
@@ -181,6 +211,7 @@ static int at91sam9x5ek_devices_init(void)
 	ek_add_device_w1();
 	ek_add_device_nand();
 	ek_add_device_eth();
+	ek_add_device_spi();
 	at91_add_device_usbh_ohci(&ek_usbh_data);
 	ek_add_led();
 	ek_add_device_i2c();
diff --git a/arch/arm/configs/at91sam9x5ek_defconfig b/arch/arm/configs/at91sam9x5ek_defconfig
index c71fe0d..5611b95 100644
--- a/arch/arm/configs/at91sam9x5ek_defconfig
+++ b/arch/arm/configs/at91sam9x5ek_defconfig
@@ -52,10 +52,13 @@ CONFIG_CMD_TFTP=y
 CONFIG_FS_TFTP=y
 CONFIG_NET_NETCONSOLE=y
 CONFIG_DRIVER_NET_MACB=y
-# CONFIG_SPI is not set
+CONFIG_DRIVER_SPI_ATMEL=y
+CONFIG_MTD_M25P80=y
 CONFIG_I2C=y
 CONFIG_I2C_GPIO=y
 CONFIG_MTD=y
+# CONFIG_MTD_OOB_DEVICE is not set
+CONFIG_MTD_DATAFLASH=y
 CONFIG_NAND=y
 # CONFIG_NAND_ECC_HW is not set
 # CONFIG_NAND_ECC_HW_SYNDROME is not set
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Thu Nov  1 15:36:21 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu,  1 Nov 2012 20:36:21 +0100
Subject: [PATCH 3/4] at91sam9x5: add mci support
In-Reply-To: <1351798582-22667-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121101193002.GL29599@game.jcrosoft.org>
 <1351798582-22667-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1351798582-22667-3-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/mach-at91/at91sam9x5.c         |    2 +
 arch/arm/mach-at91/at91sam9x5_devices.c |   62 +++++++++++++++++++++++++++++++
 2 files changed, 64 insertions(+)

diff --git a/arch/arm/mach-at91/at91sam9x5.c b/arch/arm/mach-at91/at91sam9x5.c
index a9065ff..7c7d997 100644
--- a/arch/arm/mach-at91/at91sam9x5.c
+++ b/arch/arm/mach-at91/at91sam9x5.c
@@ -207,6 +207,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
 	CLKDEV_CON_ID("ohci_clk", &uhphs_clk),
 	CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi0", &spi0_clk),
 	CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi1", &spi1_clk),
+	CLKDEV_CON_DEV_ID("mci_clk", "atmel_mci0", &mmc0_clk),
+	CLKDEV_CON_DEV_ID("mci_clk", "atmel_mci1", &mmc1_clk),
 };
 
 static struct clk_lookup usart_clocks_lookups[] = {
diff --git a/arch/arm/mach-at91/at91sam9x5_devices.c b/arch/arm/mach-at91/at91sam9x5_devices.c
index 710ded7..14fcb1e 100644
--- a/arch/arm/mach-at91/at91sam9x5_devices.c
+++ b/arch/arm/mach-at91/at91sam9x5_devices.c
@@ -123,6 +123,68 @@ void at91_add_device_eth(int id, struct at91_ether_platform_data *data)
 void at91_add_device_eth(int id, struct at91_ether_platform_data *data) {}
 #endif
 
+#if defined(CONFIG_MCI_ATMEL)
+/* Consider only one slot : slot 0 */
+void __init at91_add_device_mci(short mmc_id, struct atmel_mci_platform_data *data)
+{
+	resource_size_t start = ~0;
+
+	if (!data)
+		return;
+
+	/* Must have at least one usable slot */
+	if (!data->bus_width)
+		return;
+
+	/* input/irq */
+	if (data->detect_pin) {
+		at91_set_gpio_input(data->detect_pin, 1);
+		at91_set_deglitch(data->detect_pin, 1);
+	}
+	if (data->wp_pin)
+		at91_set_gpio_input(data->wp_pin, 1);
+
+	if (mmc_id == 0) {		/* MCI0 */
+		start = AT91SAM9X5_BASE_MCI0;
+
+		/* CLK */
+		at91_set_A_periph(AT91_PIN_PA17, 0);
+
+		/* CMD */
+		at91_set_A_periph(AT91_PIN_PA16, 1);
+
+		/* DAT0, maybe DAT1..DAT3 */
+		at91_set_A_periph(AT91_PIN_PA15, 1);
+		if (data->bus_width == 4) {
+			at91_set_A_periph(AT91_PIN_PA18, 1);
+			at91_set_A_periph(AT91_PIN_PA19, 1);
+			at91_set_A_periph(AT91_PIN_PA20, 1);
+		}
+	} else {			/* MCI1 */
+		start = AT91SAM9X5_BASE_MCI1;
+
+		/* CLK */
+		at91_set_B_periph(AT91_PIN_PA13, 0);
+
+		/* CMD */
+		at91_set_B_periph(AT91_PIN_PA12, 1);
+
+		/* DAT0, maybe DAT1..DAT3 */
+		at91_set_B_periph(AT91_PIN_PA11, 1);
+		if (data->bus_width == 4) {
+			at91_set_B_periph(AT91_PIN_PA2, 1);
+			at91_set_B_periph(AT91_PIN_PA3, 1);
+			at91_set_B_periph(AT91_PIN_PA4, 1);
+		}
+	}
+
+	add_generic_device("atmel_mci", mmc_id, NULL, start, SZ_16K,
+			   IORESOURCE_MEM, data);
+}
+#else
+void __init at91_add_device_mci(short mmc_id, struct atmel_mci_platform_data *data) {}
+#endif
+
 /* --------------------------------------------------------------------
  *  NAND / SmartMedia
  * -------------------------------------------------------------------- */
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Thu Nov  1 15:50:08 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu, 1 Nov 2012 20:50:08 +0100
Subject: [PATCH 0/4 v2] at91sam9x5ek: add spi and mci support
Message-ID: <20121101195008.GM29599@game.jcrosoft.org>

HI,

	with this +1 patch serie the support of the at91sam9x5ek is mostly
	complete

	This will add spi and mci0 support as spi0 and mci0 conflict

	We are still missing framebuffer, usb host and device and hardware i2c support
	but this wil be added later

	This patch serie depedsn on the at91sam9x5ek i2c and m25p80 patcheries

	the correct version

	this one work but brake the etherent as it mux the 4 cs as gpio and we
	use them on the eth0

The following changes since commit 04ffb7b107af50bd64d803b72e5fc315180381a2:

  m25p80: sync flash support with the kernel (2012-11-01 12:15:26 +0800)

are available in the git repository at:

  git://git.jcrosoft.org/barebox.git delivery/at91sam9x5ek_mci_spi

for you to fetch changes up to 86d0ef8200bfea132613e7654a6eb4f0d1c77cba:

  at91sam9x5ek: add mci support (2012-11-01 12:39:52 +0800)

----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (4):
      at91sam9x5: add spi support
      at91sam9x5ek: add spi support
      at91sam9x5: add mci support
      at91sam9x5ek: add mci support

 arch/arm/boards/at91sam9x5ek/init.c     |   57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 arch/arm/configs/at91sam9x5ek_defconfig |   10 +++++++---
 arch/arm/mach-at91/at91sam9x5.c         |    4 ++++
 arch/arm/mach-at91/at91sam9x5_devices.c |  124 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 192 insertions(+), 3 deletions(-)

Best Regards,
J.


From robert.jarzmik at free.fr  Thu Nov  1 15:57:18 2012
From: robert.jarzmik at free.fr (Robert Jarzmik)
Date: Thu, 01 Nov 2012 20:57:18 +0100
Subject: [PATCH 0/2] Y-Modem implementation change
In-Reply-To: <CAA4bVAFj-_LAKnedX-epOv_9EatCvYGCRLe3SS=g8QqDTw+q_g@mail.gmail.com>
 (Antony Pavlov's message of "Thu, 1 Nov 2012 23:19:36 +0400")
References: <1351791438-29967-1-git-send-email-robert.jarzmik@free.fr>
 <CAA4bVAFj-_LAKnedX-epOv_9EatCvYGCRLe3SS=g8QqDTw+q_g@mail.gmail.com>
Message-ID: <871ugdayg1.fsf@free.fr>

Antony Pavlov <antonynpavlov at gmail.com> writes:

>> So before doing the real review, could I ask of you :
>>  - Antony: could you redo your test over a serial line by applying only
>>            the first patch so that you can compare loady and loady2 ?
>>            Don't use "loady2 -g", as Y-Modem/G protocol requires a
>>            lossless line (USB), and a serial line cannot guarantee it.
>
> I have redone the test.
>
> Sorry, but the new 'loady2' does not work. I tested it over 9600 and
> over 115200 serial line.
Oh that's very disappointing.
I have tested that on a serial line, and it does work in my case ...

Could you provide me the "sb" command line you use (or rather your minicom or
other tool) uses please ?

And by private mail, I'd like the output of :
while true; do strace -T -tt -f -xx -s 4096 -o /tmp/forRobert.txt -p $(pidof sb); done

Cheers.

-- 
Robert


From plagnioj at jcrosoft.com  Thu Nov  1 17:16:56 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu,  1 Nov 2012 22:16:56 +0100
Subject: [PATCH 4/4] at91sam9x5ek: add mci support
In-Reply-To: <1351804616-31047-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121101195008.GM29599@game.jcrosoft.org>
 <1351804616-31047-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1351804616-31047-4-git-send-email-plagnioj@jcrosoft.com>

only add mci0 (microSD slot) as mci1 conflict with spi0

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/boards/at91sam9x5ek/init.c     |   20 ++++++++++++++++++++
 arch/arm/configs/at91sam9x5ek_defconfig |    5 +++--
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boards/at91sam9x5ek/init.c b/arch/arm/boards/at91sam9x5ek/init.c
index afb50e8..da488bd 100644
--- a/arch/arm/boards/at91sam9x5ek/init.c
+++ b/arch/arm/boards/at91sam9x5ek/init.c
@@ -115,6 +115,25 @@ static void ek_add_device_eth(void)
 	at91_add_device_eth(0, &macb_pdata);
 }
 
+/*
+ * MCI (SD/MMC)
+ */
+/* mci0 detect_pin is revision dependent */
+static struct atmel_mci_platform_data mci0_data = {
+	.bus_width	= 4,
+	.detect_pin	= AT91_PIN_PD15,
+	.wp_pin		= 0,
+};
+
+static void ek_add_device_mci(void)
+{
+	if (at91sam9x5ek_cm_is_vendor(VENDOR_COGENT))
+		mci0_data.detect_pin = 0;
+
+	/* MMC0 */
+	at91_add_device_mci(0, &mci0_data);
+}
+
 static struct i2c_board_info i2c_devices[] = {
 	{
 		I2C_BOARD_INFO("qt1070", 0x1b),
@@ -218,6 +237,7 @@ static int at91sam9x5ek_devices_init(void)
 	ek_add_device_nand();
 	ek_add_device_eth();
 	ek_add_device_spi();
+	ek_add_device_mci();
 	at91_add_device_usbh_ohci(&ek_usbh_data);
 	ek_add_led();
 	ek_add_device_i2c();
diff --git a/arch/arm/configs/at91sam9x5ek_defconfig b/arch/arm/configs/at91sam9x5ek_defconfig
index 5611b95..d097683 100644
--- a/arch/arm/configs/at91sam9x5ek_defconfig
+++ b/arch/arm/configs/at91sam9x5ek_defconfig
@@ -65,8 +65,9 @@ CONFIG_NAND=y
 # CONFIG_NAND_ECC_HW_NONE is not set
 CONFIG_NAND_ATMEL=y
 CONFIG_UBI=y
-CONFIG_DISK=y
-CONFIG_DISK_WRITE=y
+CONFIG_MCI=y
+CONFIG_MCI_STARTUP=y
+CONFIG_MCI_ATMEL=y
 CONFIG_LED=y
 CONFIG_LED_GPIO=y
 CONFIG_LED_TRIGGERS=y
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Thu Nov  1 17:16:55 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu,  1 Nov 2012 22:16:55 +0100
Subject: [PATCH 3/4] at91sam9x5: add mci support
In-Reply-To: <1351804616-31047-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121101195008.GM29599@game.jcrosoft.org>
 <1351804616-31047-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1351804616-31047-3-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/mach-at91/at91sam9x5.c         |    2 +
 arch/arm/mach-at91/at91sam9x5_devices.c |   62 +++++++++++++++++++++++++++++++
 2 files changed, 64 insertions(+)

diff --git a/arch/arm/mach-at91/at91sam9x5.c b/arch/arm/mach-at91/at91sam9x5.c
index a9065ff..7c7d997 100644
--- a/arch/arm/mach-at91/at91sam9x5.c
+++ b/arch/arm/mach-at91/at91sam9x5.c
@@ -207,6 +207,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
 	CLKDEV_CON_ID("ohci_clk", &uhphs_clk),
 	CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi0", &spi0_clk),
 	CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi1", &spi1_clk),
+	CLKDEV_CON_DEV_ID("mci_clk", "atmel_mci0", &mmc0_clk),
+	CLKDEV_CON_DEV_ID("mci_clk", "atmel_mci1", &mmc1_clk),
 };
 
 static struct clk_lookup usart_clocks_lookups[] = {
diff --git a/arch/arm/mach-at91/at91sam9x5_devices.c b/arch/arm/mach-at91/at91sam9x5_devices.c
index 710ded7..14fcb1e 100644
--- a/arch/arm/mach-at91/at91sam9x5_devices.c
+++ b/arch/arm/mach-at91/at91sam9x5_devices.c
@@ -123,6 +123,68 @@ void at91_add_device_eth(int id, struct at91_ether_platform_data *data)
 void at91_add_device_eth(int id, struct at91_ether_platform_data *data) {}
 #endif
 
+#if defined(CONFIG_MCI_ATMEL)
+/* Consider only one slot : slot 0 */
+void __init at91_add_device_mci(short mmc_id, struct atmel_mci_platform_data *data)
+{
+	resource_size_t start = ~0;
+
+	if (!data)
+		return;
+
+	/* Must have at least one usable slot */
+	if (!data->bus_width)
+		return;
+
+	/* input/irq */
+	if (data->detect_pin) {
+		at91_set_gpio_input(data->detect_pin, 1);
+		at91_set_deglitch(data->detect_pin, 1);
+	}
+	if (data->wp_pin)
+		at91_set_gpio_input(data->wp_pin, 1);
+
+	if (mmc_id == 0) {		/* MCI0 */
+		start = AT91SAM9X5_BASE_MCI0;
+
+		/* CLK */
+		at91_set_A_periph(AT91_PIN_PA17, 0);
+
+		/* CMD */
+		at91_set_A_periph(AT91_PIN_PA16, 1);
+
+		/* DAT0, maybe DAT1..DAT3 */
+		at91_set_A_periph(AT91_PIN_PA15, 1);
+		if (data->bus_width == 4) {
+			at91_set_A_periph(AT91_PIN_PA18, 1);
+			at91_set_A_periph(AT91_PIN_PA19, 1);
+			at91_set_A_periph(AT91_PIN_PA20, 1);
+		}
+	} else {			/* MCI1 */
+		start = AT91SAM9X5_BASE_MCI1;
+
+		/* CLK */
+		at91_set_B_periph(AT91_PIN_PA13, 0);
+
+		/* CMD */
+		at91_set_B_periph(AT91_PIN_PA12, 1);
+
+		/* DAT0, maybe DAT1..DAT3 */
+		at91_set_B_periph(AT91_PIN_PA11, 1);
+		if (data->bus_width == 4) {
+			at91_set_B_periph(AT91_PIN_PA2, 1);
+			at91_set_B_periph(AT91_PIN_PA3, 1);
+			at91_set_B_periph(AT91_PIN_PA4, 1);
+		}
+	}
+
+	add_generic_device("atmel_mci", mmc_id, NULL, start, SZ_16K,
+			   IORESOURCE_MEM, data);
+}
+#else
+void __init at91_add_device_mci(short mmc_id, struct atmel_mci_platform_data *data) {}
+#endif
+
 /* --------------------------------------------------------------------
  *  NAND / SmartMedia
  * -------------------------------------------------------------------- */
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Thu Nov  1 17:16:53 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu,  1 Nov 2012 22:16:53 +0100
Subject: [PATCH 1/4] at91sam9x5: add spi support
In-Reply-To: <20121101195008.GM29599@game.jcrosoft.org>
References: <20121101195008.GM29599@game.jcrosoft.org>
Message-ID: <1351804616-31047-1-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/mach-at91/at91sam9x5.c         |    2 +
 arch/arm/mach-at91/at91sam9x5_devices.c |   62 +++++++++++++++++++++++++++++++
 2 files changed, 64 insertions(+)

diff --git a/arch/arm/mach-at91/at91sam9x5.c b/arch/arm/mach-at91/at91sam9x5.c
index c256989..a9065ff 100644
--- a/arch/arm/mach-at91/at91sam9x5.c
+++ b/arch/arm/mach-at91/at91sam9x5.c
@@ -205,6 +205,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
 	CLKDEV_CON_DEV_ID("macb_clk", "macb0", &macb0_clk),
 	CLKDEV_CON_DEV_ID("macb_clk", "macb1", &macb1_clk),
 	CLKDEV_CON_ID("ohci_clk", &uhphs_clk),
+	CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi0", &spi0_clk),
+	CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi1", &spi1_clk),
 };
 
 static struct clk_lookup usart_clocks_lookups[] = {
diff --git a/arch/arm/mach-at91/at91sam9x5_devices.c b/arch/arm/mach-at91/at91sam9x5_devices.c
index 5a24325..710ded7 100644
--- a/arch/arm/mach-at91/at91sam9x5_devices.c
+++ b/arch/arm/mach-at91/at91sam9x5_devices.c
@@ -228,6 +228,68 @@ void at91_add_device_i2c(short i2c_id, struct i2c_board_info *devices, int nr_de
 #endif
 
 /* --------------------------------------------------------------------
+ *  SPI
+ * -------------------------------------------------------------------- */
+
+#if defined(CONFIG_DRIVER_SPI_ATMEL)
+static unsigned spi0_standard_cs[4] = { AT91_PIN_PA14, AT91_PIN_PA7, AT91_PIN_PA1, AT91_PIN_PB3 };
+
+static unsigned spi1_standard_cs[4] = { AT91_PIN_PA8, AT91_PIN_PA0, AT91_PIN_PA31, AT91_PIN_PA30 };
+
+static struct at91_spi_platform_data spi_pdata[] = {
+	[0] = {
+		.chipselect = spi0_standard_cs,
+		.num_chipselect = ARRAY_SIZE(spi0_standard_cs),
+	},
+	[1] = {
+		.chipselect = spi1_standard_cs,
+		.num_chipselect = ARRAY_SIZE(spi1_standard_cs),
+	},
+};
+
+void at91_add_device_spi(int spi_id, struct at91_spi_platform_data *pdata)
+{
+	int i;
+	int cs_pin;
+	resource_size_t start = ~0;
+
+	BUG_ON(spi_id > 1);
+
+	if (!pdata)
+		pdata = &spi_pdata[spi_id];
+
+	for (i = 0; i < pdata->num_chipselect; i++) {
+		cs_pin = pdata->chipselect[i];
+
+		/* enable chip-select pin */
+		if (cs_pin > 0)
+			at91_set_gpio_output(cs_pin, 1);
+	}
+
+	/* Configure SPI bus(es) */
+	switch (spi_id) {
+	case 0:
+		start = AT91SAM9X5_BASE_SPI0;
+		at91_set_A_periph(AT91_PIN_PA11, 0);	/* SPI0_MISO */
+		at91_set_A_periph(AT91_PIN_PA12, 0);	/* SPI0_MOSI */
+		at91_set_A_periph(AT91_PIN_PA13, 0);	/* SPI0_SPCK */
+		break;
+	case 1:
+		start = AT91SAM9X5_BASE_SPI1;
+		at91_set_B_periph(AT91_PIN_PA21, 0);	/* SPI1_MISO */
+		at91_set_B_periph(AT91_PIN_PA22, 0);	/* SPI1_MOSI */
+		at91_set_B_periph(AT91_PIN_PA23, 0);	/* SPI1_SPCK */
+		break;
+	}
+
+	add_generic_device("atmel_spi", spi_id, NULL, start, SZ_16K,
+			   IORESOURCE_MEM, pdata);
+}
+#else
+void at91_add_device_spi(int spi_id, struct at91_spi_platform_data *pdata) {}
+#endif
+
+/* --------------------------------------------------------------------
  *  UART
  * -------------------------------------------------------------------- */
 
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Thu Nov  1 17:16:54 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu,  1 Nov 2012 22:16:54 +0100
Subject: [PATCH 2/4] at91sam9x5ek: add spi support
In-Reply-To: <1351804616-31047-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121101195008.GM29599@game.jcrosoft.org>
 <1351804616-31047-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1351804616-31047-2-git-send-email-plagnioj@jcrosoft.com>

on all the cpu module we have a at25 except on the cogent where we have a at45

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/boards/at91sam9x5ek/init.c     |   37 +++++++++++++++++++++++++++++++
 arch/arm/configs/at91sam9x5ek_defconfig |    5 ++++-
 2 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boards/at91sam9x5ek/init.c b/arch/arm/boards/at91sam9x5ek/init.c
index 48eebac..afb50e8 100644
--- a/arch/arm/boards/at91sam9x5ek/init.c
+++ b/arch/arm/boards/at91sam9x5ek/init.c
@@ -41,6 +41,7 @@
 #include <readkey.h>
 #include <linux/w1-gpio.h>
 #include <w1_mac_address.h>
+#include <spi/spi.h>
 
 #include "hw_version.h"
 
@@ -125,6 +126,41 @@ static void ek_add_device_i2c(void)
 	at91_add_device_i2c(0, i2c_devices, ARRAY_SIZE(i2c_devices));
 }
 
+static const struct spi_board_info ek_cm_cogent_spi_devices[] = {
+	{
+		.name		= "mtd_dataflash",
+		.chip_select	= 0,
+		.max_speed_hz	= 15 * 1000 * 1000,
+		.bus_num	= 0,
+	}
+};
+
+static const struct spi_board_info ek_spi_devices[] = {
+	{
+		.name		= "m25p80",
+		.chip_select	= 0,
+		.max_speed_hz	= 30 * 1000 * 1000,
+		.bus_num	= 0,
+	}
+};
+
+static unsigned spi0_standard_cs[] = { AT91_PIN_PA14};
+static struct at91_spi_platform_data spi_pdata = {
+	.chipselect = spi0_standard_cs,
+	.num_chipselect = ARRAY_SIZE(spi0_standard_cs),
+};
+
+static void ek_add_device_spi(void)
+{
+	if (at91sam9x5ek_cm_is_vendor(VENDOR_COGENT))
+		spi_register_board_info(ek_cm_cogent_spi_devices,
+				ARRAY_SIZE(ek_cm_cogent_spi_devices));
+	else
+		spi_register_board_info(ek_spi_devices,
+				ARRAY_SIZE(ek_spi_devices));
+	at91_add_device_spi(0, &spi_pdata);
+}
+
 /*
  * USB Host port
  */
@@ -181,6 +217,7 @@ static int at91sam9x5ek_devices_init(void)
 	ek_add_device_w1();
 	ek_add_device_nand();
 	ek_add_device_eth();
+	ek_add_device_spi();
 	at91_add_device_usbh_ohci(&ek_usbh_data);
 	ek_add_led();
 	ek_add_device_i2c();
diff --git a/arch/arm/configs/at91sam9x5ek_defconfig b/arch/arm/configs/at91sam9x5ek_defconfig
index c71fe0d..5611b95 100644
--- a/arch/arm/configs/at91sam9x5ek_defconfig
+++ b/arch/arm/configs/at91sam9x5ek_defconfig
@@ -52,10 +52,13 @@ CONFIG_CMD_TFTP=y
 CONFIG_FS_TFTP=y
 CONFIG_NET_NETCONSOLE=y
 CONFIG_DRIVER_NET_MACB=y
-# CONFIG_SPI is not set
+CONFIG_DRIVER_SPI_ATMEL=y
+CONFIG_MTD_M25P80=y
 CONFIG_I2C=y
 CONFIG_I2C_GPIO=y
 CONFIG_MTD=y
+# CONFIG_MTD_OOB_DEVICE is not set
+CONFIG_MTD_DATAFLASH=y
 CONFIG_NAND=y
 # CONFIG_NAND_ECC_HW is not set
 # CONFIG_NAND_ECC_HW_SYNDROME is not set
-- 
1.7.10.4



From s.hauer at pengutronix.de  Thu Nov  1 18:42:32 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu,  1 Nov 2012 23:42:32 +0100
Subject: [PATCH] defenv-2 menu: when booting failed wait for key press
Message-ID: <1351809753-28816-1-git-send-email-s.hauer@pengutronix.de>

When booting fails we will be immediately be back into the menu,
so the error message can't be seen. Also, boot in verbose mode
since in interactive mode the last bit of performance is not that
necessary.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 defaultenv-2/menu/menu/boot-menu-add-entry |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/defaultenv-2/menu/menu/boot-menu-add-entry b/defaultenv-2/menu/menu/boot-menu-add-entry
index 7e1d9c6..f06c524 100644
--- a/defaultenv-2/menu/menu/boot-menu-add-entry
+++ b/defaultenv-2/menu/menu/boot-menu-add-entry
@@ -1,5 +1,5 @@
 #!/bin/sh
 
-menu -e -a -m boot -c "boot $1" -d "Boot: ${GREEN}$2${NC}"
+menu -e -a -m boot -c "boot -v $1; echo; readline \"press enter to continue\" a " -d "Boot: ${GREEN}$2${NC}"
 menu -e -a -m boot_entries_edit -c "$global.editcmd /env/boot/$1" -d "${GREEN}$2${NC}"
 menu -e -a -m boot_entries_remove -c "rm /env/boot/$1" -d "${GREEN}$2${NC}"
-- 
1.7.10.4



From shc_work at mail.ru  Fri Nov  2 02:24:19 2012
From: shc_work at mail.ru (Alexander Shiyan)
Date: Fri, 2 Nov 2012 10:24:19 +0400
Subject: [PATCH v3 1/3] ARM: Add CLPS711X architecture
In-Reply-To: <20121101073251.GS1641@pengutronix.de>
References: <1351613312-4506-1-git-send-email-shc_work@mail.ru>
 <20121031213608.GR1641@pengutronix.de>
 <20121101092038.0b71630228ecac770b8b1128@mail.ru>
 <20121101073251.GS1641@pengutronix.de>
Message-ID: <20121102102419.52e6cc0269ae07ef1b3ff26d@mail.ru>

On Thu, 1 Nov 2012 08:32:51 +0100
Sascha Hauer <s.hauer at pengutronix.de> wrote:

> On Thu, Nov 01, 2012 at 09:20:38AM +0400, Alexander Shiyan wrote:
> > On Wed, 31 Oct 2012 22:36:08 +0100
> > Sascha Hauer <s.hauer at pengutronix.de> wrote:
> > 
> > ...
> > > > +
> > > > +	asm("mov pc, #0");
> > > 
> > > Or is it because you do not have a real reset function and have to jump
> > > through zero instead? Still common_reset() shouldn't be necessary. What
> > Yes.
> > > you may have to do here is to make sure the MMU is disabled and caches
> > > are flushed.
> > Yes. This call was be added for do it.
> > I may replace entrie function by calling start(). Is it a better way()?
> 
> arch_shutdown() should do it.
Well, if there are no more comments for this series, I will create a v4 with
one more forgotten fix for serial driver (IS_ERR clock check).

-- 
Alexander Shiyan <shc_work at mail.ru>


From s.hauer at pengutronix.de  Fri Nov  2 03:29:40 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Fri, 2 Nov 2012 08:29:40 +0100
Subject: [PATCH 1/4] i2c: adapter: register it's own device
In-Reply-To: <1351763092-5781-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121101094216.GI29599@game.jcrosoft.org>
 <1351763092-5781-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <20121102072940.GB1641@pengutronix.de>

On Thu, Nov 01, 2012 at 10:44:49AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> so we can show the this of i2c busses
> set the bus device as parent of all devices.
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
> ---
>  drivers/i2c/busses/i2c-imx.c  |   20 ++++++++++----------
>  drivers/i2c/busses/i2c-omap.c |   30 +++++++++++++++---------------
>  drivers/i2c/i2c.c             |   18 +++++++++++++++---
>  include/i2c/i2c.h             |    2 +-
>  4 files changed, 41 insertions(+), 29 deletions(-)
> 
>  int i2c_add_numbered_adapter(struct i2c_adapter *adapter)
>  {
> -	if (i2c_get_adapter(adapter->nr))
> -		return -EBUSY;

If you remove this and instead depend on register_device bailing out
later then you should change the error value register_device returns
to -EBUSY. Currently it returns -EINVAL, -EBUSY seems much better here.


> +	int ret;
> +
> +	adapter->dev.id = adapter->nr;
> +	strcpy(adapter->dev.name, "i2c");
> +
> +	if (adapter->dev.parent)
> +		dev_add_child(adapter->dev.parent, &adapter->dev);

We should push the dev_add_child to the driver core. Doing this here
means that...

> +
> +	ret = register_device(&adapter->dev);
> +	if (ret)
> +		return ret;

... the parents child list will be corrupted when register_device fails.
At least w1 and mdiobus have the same problem. But ok, we can fix that
later.

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Fri Nov  2 04:21:13 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Fri, 2 Nov 2012 09:21:13 +0100
Subject: [PATCH v3 1/3] ARM: Add CLPS711X architecture
In-Reply-To: <20121102102419.52e6cc0269ae07ef1b3ff26d@mail.ru>
References: <1351613312-4506-1-git-send-email-shc_work@mail.ru>
 <20121031213608.GR1641@pengutronix.de>
 <20121101092038.0b71630228ecac770b8b1128@mail.ru>
 <20121101073251.GS1641@pengutronix.de>
 <20121102102419.52e6cc0269ae07ef1b3ff26d@mail.ru>
Message-ID: <20121102082113.GC1641@pengutronix.de>

On Fri, Nov 02, 2012 at 10:24:19AM +0400, Alexander Shiyan wrote:
> On Thu, 1 Nov 2012 08:32:51 +0100
> Sascha Hauer <s.hauer at pengutronix.de> wrote:
> 
> > On Thu, Nov 01, 2012 at 09:20:38AM +0400, Alexander Shiyan wrote:
> > > On Wed, 31 Oct 2012 22:36:08 +0100
> > > Sascha Hauer <s.hauer at pengutronix.de> wrote:
> > > 
> > > ...
> > > > > +
> > > > > +	asm("mov pc, #0");
> > > > 
> > > > Or is it because you do not have a real reset function and have to jump
> > > > through zero instead? Still common_reset() shouldn't be necessary. What
> > > Yes.
> > > > you may have to do here is to make sure the MMU is disabled and caches
> > > > are flushed.
> > > Yes. This call was be added for do it.
> > > I may replace entrie function by calling start(). Is it a better way()?
> > 
> > arch_shutdown() should do it.
> Well, if there are no more comments for this series, I will create a v4 with
> one more forgotten fix for serial driver (IS_ERR clock check).

Fine, thanks. This should be the final one.

Two last things:

You should add pbl-y += lowlevel.o to your board Makefile. This allows
it to compile barebox as a compressed image.

You shouldn't have to overwrite env/bin/mtdparts-add. Instead this
should be called from env/init/mtdparts*

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From shc_work at mail.ru  Fri Nov  2 04:44:43 2012
From: shc_work at mail.ru (Alexander Shiyan)
Date: Fri, 2 Nov 2012 12:44:43 +0400
Subject: [PATCH v3 1/3] ARM: Add CLPS711X architecture
In-Reply-To: <20121102082113.GC1641@pengutronix.de>
References: <1351613312-4506-1-git-send-email-shc_work@mail.ru>
 <20121031213608.GR1641@pengutronix.de>
 <20121101092038.0b71630228ecac770b8b1128@mail.ru>
 <20121101073251.GS1641@pengutronix.de>
 <20121102102419.52e6cc0269ae07ef1b3ff26d@mail.ru>
 <20121102082113.GC1641@pengutronix.de>
Message-ID: <20121102124443.66678a1d76cceaf646c4507b@mail.ru>

On Fri, 2 Nov 2012 09:21:13 +0100
Sascha Hauer <s.hauer at pengutronix.de> wrote:

...
> > Well, if there are no more comments for this series, I will create a v4 with
> > one more forgotten fix for serial driver (IS_ERR clock check).
> 
> Fine, thanks. This should be the final one.
> 
> Two last things:
> 
> You should add pbl-y += lowlevel.o to your board Makefile. This allows
> it to compile barebox as a compressed image.
> 
> You shouldn't have to overwrite env/bin/mtdparts-add. Instead this
> should be called from env/init/mtdparts*

OK, but the changes I'll have to test, so the revised version will be in a week.
Thank you.

-- 
Alexander Shiyan <shc_work at mail.ru>


From s.hauer at pengutronix.de  Fri Nov  2 04:54:12 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Fri, 2 Nov 2012 09:54:12 +0100
Subject: [PATCH v3 1/3] ARM: Add CLPS711X architecture
In-Reply-To: <20121102124443.66678a1d76cceaf646c4507b@mail.ru>
References: <1351613312-4506-1-git-send-email-shc_work@mail.ru>
 <20121031213608.GR1641@pengutronix.de>
 <20121101092038.0b71630228ecac770b8b1128@mail.ru>
 <20121101073251.GS1641@pengutronix.de>
 <20121102102419.52e6cc0269ae07ef1b3ff26d@mail.ru>
 <20121102082113.GC1641@pengutronix.de>
 <20121102124443.66678a1d76cceaf646c4507b@mail.ru>
Message-ID: <20121102085411.GF1641@pengutronix.de>

On Fri, Nov 02, 2012 at 12:44:43PM +0400, Alexander Shiyan wrote:
> On Fri, 2 Nov 2012 09:21:13 +0100
> Sascha Hauer <s.hauer at pengutronix.de> wrote:
> 
> ...
> > > Well, if there are no more comments for this series, I will create a v4 with
> > > one more forgotten fix for serial driver (IS_ERR clock check).
> > 
> > Fine, thanks. This should be the final one.
> > 
> > Two last things:
> > 
> > You should add pbl-y += lowlevel.o to your board Makefile. This allows
> > it to compile barebox as a compressed image.
> > 
> > You shouldn't have to overwrite env/bin/mtdparts-add. Instead this
> > should be called from env/init/mtdparts*
> 
> OK, but the changes I'll have to test, so the revised version will be in a week.
> Thank you.

If it works for you then you could fix this later so that you do not
miss the next merge window.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Fri Nov  2 04:57:29 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Fri, 2 Nov 2012 09:57:29 +0100
Subject: [PATCH 1/1] mtd: dataflash: fix spi_transfer init
In-Reply-To: <1351761415-3199-1-git-send-email-plagnioj@jcrosoft.com>
References: <1351761415-3199-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <20121102085729.GH1641@pengutronix.de>

On Thu, Nov 01, 2012 at 10:16:55AM +0100,  wrote:
> From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
> 
> on some system as the spi_transfer is not set to 0 if the rx_buf or tx_buf
> are not used they are not set to NULL
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>

Applied, thanks

Sascha

> ---
>  drivers/mtd/devices/mtd_dataflash.c |    6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/mtd/devices/mtd_dataflash.c b/drivers/mtd/devices/mtd_dataflash.c
> index cbed15b..3b7b9c6 100644
> --- a/drivers/mtd/devices/mtd_dataflash.c
> +++ b/drivers/mtd/devices/mtd_dataflash.c
> @@ -161,6 +161,8 @@ static int dataflash_erase(struct mtd_info *mtd, struct erase_info *instr)
>  
>  	spi_message_init(&msg);
>  
> +	memset(&x, 0, sizeof(x));
> +
>  	x.tx_buf = command = priv->command;
>  	x.len = 4;
>  	spi_message_add_tail(&x, &msg);
> @@ -246,6 +248,8 @@ static int dataflash_read(struct mtd_info *mtd, loff_t from, size_t len,
>  
>  	spi_message_init(&msg);
>  
> +	memset(&x[0], 0, sizeof(struct spi_transfer) * 2);
> +
>  	x[0].tx_buf = command;
>  	x[0].len = 8;
>  	spi_message_add_tail(&x[0], &msg);
> @@ -302,6 +306,8 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len,
>  
>  	spi_message_init(&msg);
>  
> +	memset(&x[0], 0, sizeof(struct spi_transfer) * 2);
> +
>  	x[0].tx_buf = command = priv->command;
>  	x[0].len = 4;
>  	spi_message_add_tail(&x[0], &msg);
> -- 
> 1.7.10.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From shc_work at mail.ru  Fri Nov  2 05:06:52 2012
From: shc_work at mail.ru (Alexander Shiyan)
Date: Fri, 2 Nov 2012 13:06:52 +0400
Subject: [PATCH v3 1/3] ARM: Add CLPS711X architecture
In-Reply-To: <20121102085411.GF1641@pengutronix.de>
References: <1351613312-4506-1-git-send-email-shc_work@mail.ru>
 <20121031213608.GR1641@pengutronix.de>
 <20121101092038.0b71630228ecac770b8b1128@mail.ru>
 <20121101073251.GS1641@pengutronix.de>
 <20121102102419.52e6cc0269ae07ef1b3ff26d@mail.ru>
 <20121102082113.GC1641@pengutronix.de>
 <20121102124443.66678a1d76cceaf646c4507b@mail.ru>
 <20121102085411.GF1641@pengutronix.de>
Message-ID: <20121102130652.22c805c52e576929e387d66a@mail.ru>

On Fri, 2 Nov 2012 09:54:12 +0100
Sascha Hauer <s.hauer at pengutronix.de> wrote:

...
> > > Two last things:
> > > 
> > > You should add pbl-y += lowlevel.o to your board Makefile. This allows
> > > it to compile barebox as a compressed image.
> > > 
> > > You shouldn't have to overwrite env/bin/mtdparts-add. Instead this
> > > should be called from env/init/mtdparts*
> > 
> > OK, but the changes I'll have to test, so the revised version will be in a week.
> > Thank you.
> 
> If it works for you then you could fix this later so that you do not
> miss the next merge window.

Understood, now prepare to send the current tested version.
Thanks one more time.

-- 
Alexander Shiyan <shc_work at mail.ru>


From shc_work at mail.ru  Fri Nov  2 05:17:14 2012
From: shc_work at mail.ru (Alexander Shiyan)
Date: Fri,  2 Nov 2012 13:17:14 +0400
Subject: [PATCH v4 1/3] ARM: Add initial support for CLPS711X architecture
Message-ID: <1351847836-8221-1-git-send-email-shc_work@mail.ru>

This patch adds new architecture (CLPS711X) into barebox.
The core-logic functionality of the device is built around an ARM720T
processor running at clock speeds up to 90 MHz.

Signed-off-by: Alexander Shiyan <shc_work at mail.ru>
---
 arch/arm/Kconfig                               |    6 +
 arch/arm/Makefile                              |    1 +
 arch/arm/mach-clps711x/Kconfig                 |    8 +
 arch/arm/mach-clps711x/Makefile                |    1 +
 arch/arm/mach-clps711x/clock.c                 |  113 ++++++++++
 arch/arm/mach-clps711x/devices.c               |   37 +++
 arch/arm/mach-clps711x/include/mach/clkdev.h   |    7 +
 arch/arm/mach-clps711x/include/mach/clps711x.h |  284 ++++++++++++++++++++++++
 arch/arm/mach-clps711x/include/mach/devices.h  |    6 +
 arch/arm/mach-clps711x/reset.c                 |   21 ++
 10 files changed, 484 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-clps711x/Kconfig
 create mode 100644 arch/arm/mach-clps711x/Makefile
 create mode 100644 arch/arm/mach-clps711x/clock.c
 create mode 100644 arch/arm/mach-clps711x/devices.c
 create mode 100644 arch/arm/mach-clps711x/include/mach/clkdev.h
 create mode 100644 arch/arm/mach-clps711x/include/mach/clps711x.h
 create mode 100644 arch/arm/mach-clps711x/include/mach/devices.h
 create mode 100644 arch/arm/mach-clps711x/reset.c

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 57b3ca7..28071a5 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -31,6 +31,11 @@ config ARCH_AT91
 	select HAS_DEBUG_LL
 	select HAVE_MACH_ARM_HEAD
 
+config ARCH_CLPS711X
+	bool "Cirrus Logic EP711x/EP721x/EP731x"
+	select CLKDEV_LOOKUP
+	select CPU_32v4T
+
 config ARCH_EP93XX
 	bool "Cirrus Logic EP93xx"
 	select CPU_ARM920T
@@ -97,6 +102,7 @@ endchoice
 
 source arch/arm/cpu/Kconfig
 source arch/arm/mach-at91/Kconfig
+source arch/arm/mach-clps711x/Kconfig
 source arch/arm/mach-ep93xx/Kconfig
 source arch/arm/mach-imx/Kconfig
 source arch/arm/mach-mxs/Kconfig
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 855043a..da80e00 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -52,6 +52,7 @@ AFLAGS   += -include asm/unified.h -msoft-float $(AFLAGS_THUMB2)
 # Machine directory name.  This list is sorted alphanumerically
 # by CONFIG_* macro name.
 machine-$(CONFIG_ARCH_AT91)		:= at91
+machine-$(CONFIG_ARCH_CLPS711X)		:= clps711x
 machine-$(CONFIG_ARCH_EP93XX)		:= ep93xx
 machine-$(CONFIG_ARCH_IMX)		:= imx
 machine-$(CONFIG_ARCH_MXS)		:= mxs
diff --git a/arch/arm/mach-clps711x/Kconfig b/arch/arm/mach-clps711x/Kconfig
new file mode 100644
index 0000000..56ca2ca
--- /dev/null
+++ b/arch/arm/mach-clps711x/Kconfig
@@ -0,0 +1,8 @@
+if ARCH_CLPS711X
+
+choice
+	prompt "Cirrus Logic EP711x/EP721x/EP731x Board Type"
+
+endchoice
+
+endif
diff --git a/arch/arm/mach-clps711x/Makefile b/arch/arm/mach-clps711x/Makefile
new file mode 100644
index 0000000..41012bc
--- /dev/null
+++ b/arch/arm/mach-clps711x/Makefile
@@ -0,0 +1 @@
+obj-y += clock.o devices.o reset.o
diff --git a/arch/arm/mach-clps711x/clock.c b/arch/arm/mach-clps711x/clock.c
new file mode 100644
index 0000000..5cafba9
--- /dev/null
+++ b/arch/arm/mach-clps711x/clock.c
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 2012 Alexander Shiyan <shc_work at mail.ru>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ */
+
+#include <common.h>
+#include <init.h>
+#include <clock.h>
+#include <asm/io.h>
+#include <linux/clkdev.h>
+
+#include <mach/clps711x.h>
+
+struct clk {
+	unsigned long	rate;
+};
+
+static struct clk uart_clk, bus_clk;
+
+uint64_t clocksource_read(void)
+{
+	return ~readw(TC2D);
+}
+
+static struct clocksource cs = {
+	.read	= clocksource_read,
+	.mask	= CLOCKSOURCE_MASK(16),
+};
+
+unsigned long clk_get_rate(struct clk *clk)
+{
+	return clk->rate;
+}
+EXPORT_SYMBOL(clk_get_rate);
+
+int clk_enable(struct clk *clk)
+{
+	/* Do nothing */
+	return 0;
+}
+EXPORT_SYMBOL(clk_enable);
+
+void clk_disable(struct clk *clk)
+{
+	/* Do nothing */
+}
+EXPORT_SYMBOL(clk_disable);
+
+static int clocks_init(void)
+{
+	int osc, ext, pll, cpu, timer;
+	u32 tmp;
+
+	osc = 3686400;
+	ext = 13000000;
+
+	tmp = readl(PLLR) >> 24;
+	if (tmp)
+		pll = (osc * tmp) / 2;
+	else
+		pll = 73728000; /* Default value for old CPUs */
+
+	tmp = readl(SYSFLG2);
+	if (tmp & SYSFLG2_CKMODE) {
+		cpu = ext;
+		bus_clk.rate = cpu;
+	} else {
+		cpu = pll;
+		if (cpu >= 36864000)
+			bus_clk.rate = cpu / 2;
+		else
+			bus_clk.rate = 36864000 / 2;
+	}
+
+	uart_clk.rate = bus_clk.rate / 10;
+
+	if (tmp & SYSFLG2_CKMODE) {
+		tmp = readw(SYSCON2);
+		if (tmp & SYSCON2_OSTB)
+			timer = ext / 26;
+		else
+			timer = 541440;
+	} else
+		timer = cpu / 144;
+
+	tmp = readl(SYSCON1);
+	tmp &= ~SYSCON1_TC2M;	/* Free running mode */
+	tmp |= SYSCON1_TC2S;	/* High frequency source */
+	writel(tmp, SYSCON1);
+
+	clocks_calc_mult_shift(&cs.mult, &cs.shift, timer, NSEC_PER_SEC, 10);
+
+	return init_clock(&cs);
+}
+core_initcall(clocks_init);
+
+static struct clk_lookup clocks_lookups[] = {
+	CLKDEV_CON_ID("bus", &bus_clk),
+	CLKDEV_DEV_ID("clps711x_serial0", &uart_clk),
+	CLKDEV_DEV_ID("clps711x_serial1", &uart_clk),
+};
+
+static int clkdev_init(void)
+{
+	clkdev_add_table(clocks_lookups, ARRAY_SIZE(clocks_lookups));
+
+	return 0;
+}
+postcore_initcall(clkdev_init);
diff --git a/arch/arm/mach-clps711x/devices.c b/arch/arm/mach-clps711x/devices.c
new file mode 100644
index 0000000..c5fcbf2
--- /dev/null
+++ b/arch/arm/mach-clps711x/devices.c
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2012 Alexander Shiyan <shc_work at mail.ru>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ */
+
+#include <common.h>
+#include <init.h>
+
+#include <asm/io.h>
+
+#include <mach/clps711x.h>
+
+inline void _clps711x_setup_memcfg(int bank, u32 addr, u32 val)
+{
+	u32 tmp = readl(addr);
+
+	tmp &= ~(0xff << (bank * 8));
+	tmp |= val << (bank * 8);
+
+	writel(tmp, addr);
+}
+
+void clps711x_setup_memcfg(int bank, u32 val)
+{
+	switch (bank) {
+	case 0 ... 3:
+		_clps711x_setup_memcfg(bank, MEMCFG1, val);
+		break;
+	case 4 ... 7:
+		_clps711x_setup_memcfg(bank - 4, MEMCFG2, val);
+		break;
+	}
+}
diff --git a/arch/arm/mach-clps711x/include/mach/clkdev.h b/arch/arm/mach-clps711x/include/mach/clkdev.h
new file mode 100644
index 0000000..9278209
--- /dev/null
+++ b/arch/arm/mach-clps711x/include/mach/clkdev.h
@@ -0,0 +1,7 @@
+#ifndef __MACH_CLKDEV_H
+#define __MACH_CLKDEV_H
+
+#define __clk_get(clk)	({ 1; })
+#define __clk_put(clk)	do { } while (0)
+
+#endif
diff --git a/arch/arm/mach-clps711x/include/mach/clps711x.h b/arch/arm/mach-clps711x/include/mach/clps711x.h
new file mode 100644
index 0000000..048992a
--- /dev/null
+++ b/arch/arm/mach-clps711x/include/mach/clps711x.h
@@ -0,0 +1,284 @@
+/*
+ *  Hardware definitions for Cirrus Logic CLPS711X
+ *
+ *  Copyright (C) 2000 Deep Blue Solutions Ltd.
+ *  Copyright (C) 2012 Alexander Shiyan <shc_work at mail.ru>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef __MACH_CLPS711X_H
+#define __MACH_CLPS711X_H
+
+#define CS0_BASE		(0x00000000)
+#define CS1_BASE		(0x10000000)
+#define CS2_BASE		(0x20000000)
+#define CS3_BASE		(0x30000000)
+#define CS4_BASE		(0x40000000)
+#define CS5_BASE		(0x50000000)
+#define CS6_BASE		(0x60000000)
+#define CS7_BASE		(0x70000000)
+#define REGS_BASE		(0x80000000)
+#define SDRAM0_BASE		(0xc0000000)
+#define SDRAM1_BASE		(0xd0000000)
+
+#define PADR			(REGS_BASE + 0x0000)
+#define PBDR			(REGS_BASE + 0x0001)
+#define PCDR			(REGS_BASE + 0x0002)
+#define PDDR			(REGS_BASE + 0x0003)
+#define PADDR			(REGS_BASE + 0x0040)
+#define PBDDR			(REGS_BASE + 0x0041)
+#define PCDDR			(REGS_BASE + 0x0042)
+#define PDDDR			(REGS_BASE + 0x0043)
+#define PEDR			(REGS_BASE + 0x0083)
+#define PEDDR			(REGS_BASE + 0x00c3)
+#define SYSCON1			(REGS_BASE + 0x0100)
+#define SYSFLG1			(REGS_BASE + 0x0140)
+#define MEMCFG1			(REGS_BASE + 0x0180)
+#define MEMCFG2			(REGS_BASE + 0x01c0)
+#define DRFPR			(REGS_BASE + 0x0200)
+#define INTSR1			(REGS_BASE + 0x0240)
+#define INTMR1			(REGS_BASE + 0x0280)
+#define LCDCON			(REGS_BASE + 0x02c0)
+#define TC1D			(REGS_BASE + 0x0300)
+#define TC2D			(REGS_BASE + 0x0340)
+#define RTCDR			(REGS_BASE + 0x0380)
+#define RTCMR			(REGS_BASE + 0x03c0)
+#define PMPCON			(REGS_BASE + 0x0400)
+#define CODR			(REGS_BASE + 0x0440)
+#define UARTDR1			(REGS_BASE + 0x0480)
+#define UBRLCR1			(REGS_BASE + 0x04c0)
+#define SYNCIO			(REGS_BASE + 0x0500)
+#define PALLSW			(REGS_BASE + 0x0540)
+#define PALMSW			(REGS_BASE + 0x0580)
+#define STFCLR			(REGS_BASE + 0x05c0)
+#define BLEOI			(REGS_BASE + 0x0600)
+#define MCEOI			(REGS_BASE + 0x0640)
+#define TEOI			(REGS_BASE + 0x0680)
+#define TC1EOI			(REGS_BASE + 0x06c0)
+#define TC2EOI			(REGS_BASE + 0x0700)
+#define RTCEOI			(REGS_BASE + 0x0740)
+#define UMSEOI			(REGS_BASE + 0x0780)
+#define COEOI			(REGS_BASE + 0x07c0)
+#define HALT			(REGS_BASE + 0x0800)
+#define STDBY			(REGS_BASE + 0x0840)
+
+#define FBADDR			(REGS_BASE + 0x1000)
+#define SYSCON2			(REGS_BASE + 0x1100)
+#define SYSFLG2			(REGS_BASE + 0x1140)
+#define INTSR2			(REGS_BASE + 0x1240)
+#define INTMR2			(REGS_BASE + 0x1280)
+#define UARTDR2			(REGS_BASE + 0x1480)
+#define UBRLCR2			(REGS_BASE + 0x14c0)
+#define SS2DR			(REGS_BASE + 0x1500)
+#define SRXEOF			(REGS_BASE + 0x1600)
+#define SS2POP			(REGS_BASE + 0x16c0)
+#define KBDEOI			(REGS_BASE + 0x1700)
+
+#define DAIR			(REGS_BASE + 0x2000)
+#define DAIDR0			(REGS_BASE + 0x2040)
+#define DAIDR1			(REGS_BASE + 0x2080)
+#define DAIDR2			(REGS_BASE + 0x20c0)
+#define DAISR			(REGS_BASE + 0x2100)
+#define SYSCON3			(REGS_BASE + 0x2200)
+#define INTSR3			(REGS_BASE + 0x2240)
+#define INTMR3			(REGS_BASE + 0x2280)
+#define LEDFLSH			(REGS_BASE + 0x22c0)
+#define SDCONF			(REGS_BASE + 0x2300)
+#define SDRFPR			(REGS_BASE + 0x2340)
+#define UNIQID			(REGS_BASE + 0x2440)
+#define DAI64FS			(REGS_BASE + 0x2600)
+#define PLLW			(REGS_BASE + 0x2610)
+#define PLLR			(REGS_BASE + 0xa5a8)
+#define RANDID0			(REGS_BASE + 0x2700)
+#define RANDID1			(REGS_BASE + 0x2704)
+#define RANDID2			(REGS_BASE + 0x2708)
+#define RANDID3			(REGS_BASE + 0x270c)
+
+/* common bits: SYSCON1 / SYSCON2 */
+#define SYSCON_UARTEN		(1 << 8)
+
+#define SYSCON1_KBDSCAN(x)	((x) & 15)
+#define SYSCON1_KBDSCANMASK	(15)
+#define SYSCON1_TC1M		(1 << 4)
+#define SYSCON1_TC1S		(1 << 5)
+#define SYSCON1_TC2M		(1 << 6)
+#define SYSCON1_TC2S		(1 << 7)
+#define SYSCON1_UART1EN		SYSCON_UARTEN
+#define SYSCON1_BZTOG		(1 << 9)
+#define SYSCON1_BZMOD		(1 << 10)
+#define SYSCON1_DBGEN		(1 << 11)
+#define SYSCON1_LCDEN		(1 << 12)
+#define SYSCON1_CDENTX		(1 << 13)
+#define SYSCON1_CDENRX		(1 << 14)
+#define SYSCON1_SIREN		(1 << 15)
+#define SYSCON1_ADCKSEL(x)	(((x) & 3) << 16)
+#define SYSCON1_ADCKSEL_MASK	(3 << 16)
+#define SYSCON1_EXCKEN		(1 << 18)
+#define SYSCON1_WAKEDIS		(1 << 19)
+#define SYSCON1_IRTXM		(1 << 20)
+
+/* common bits: SYSFLG1 / SYSFLG2 */
+#define SYSFLG_UBUSY		(1 << 11)
+#define SYSFLG_URXFE		(1 << 22)
+#define SYSFLG_UTXFF		(1 << 23)
+
+#define SYSFLG1_MCDR		(1 << 0)
+#define SYSFLG1_DCDET		(1 << 1)
+#define SYSFLG1_WUDR		(1 << 2)
+#define SYSFLG1_WUON		(1 << 3)
+#define SYSFLG1_CTS		(1 << 8)
+#define SYSFLG1_DSR		(1 << 9)
+#define SYSFLG1_DCD		(1 << 10)
+#define SYSFLG1_UBUSY		SYSFLG_UBUSY
+#define SYSFLG1_NBFLG		(1 << 12)
+#define SYSFLG1_RSTFLG		(1 << 13)
+#define SYSFLG1_PFFLG		(1 << 14)
+#define SYSFLG1_CLDFLG		(1 << 15)
+#define SYSFLG1_URXFE		SYSFLG_URXFE
+#define SYSFLG1_UTXFF		SYSFLG_UTXFF
+#define SYSFLG1_CRXFE		(1 << 24)
+#define SYSFLG1_CTXFF		(1 << 25)
+#define SYSFLG1_SSIBUSY		(1 << 26)
+#define SYSFLG1_ID		(1 << 29)
+#define SYSFLG1_VERID(x)	(((x) >> 30) & 3)
+#define SYSFLG1_VERID_MASK	(3 << 30)
+
+#define SYSFLG2_SSRXOF		(1 << 0)
+#define SYSFLG2_RESVAL		(1 << 1)
+#define SYSFLG2_RESFRM		(1 << 2)
+#define SYSFLG2_SS2RXFE		(1 << 3)
+#define SYSFLG2_SS2TXFF		(1 << 4)
+#define SYSFLG2_SS2TXUF		(1 << 5)
+#define SYSFLG2_CKMODE		(1 << 6)
+#define SYSFLG2_UBUSY		SYSFLG_UBUSY
+#define SYSFLG2_URXFE		SYSFLG_URXFE
+#define SYSFLG2_UTXFF		SYSFLG_UTXFF
+
+#define LCDCON_GSEN		(1 << 30)
+#define LCDCON_GSMD		(1 << 31)
+
+#define SYSCON2_SERSEL		(1 << 0)
+#define SYSCON2_KBD6		(1 << 1)
+#define SYSCON2_DRAMZ		(1 << 2)
+#define SYSCON2_KBWEN		(1 << 3)
+#define SYSCON2_SS2TXEN		(1 << 4)
+#define SYSCON2_PCCARD1		(1 << 5)
+#define SYSCON2_PCCARD2		(1 << 6)
+#define SYSCON2_SS2RXEN		(1 << 7)
+#define SYSCON2_UART2EN		SYSCON_UARTEN
+#define SYSCON2_SS2MAEN		(1 << 9)
+#define SYSCON2_OSTB		(1 << 12)
+#define SYSCON2_CLKENSL		(1 << 13)
+#define SYSCON2_BUZFREQ		(1 << 14)
+
+/* common bits: UARTDR1 / UARTDR2 */
+#define UARTDR_FRMERR		(1 << 8)
+#define UARTDR_PARERR		(1 << 9)
+#define UARTDR_OVERR		(1 << 10)
+
+/* common bits: UBRLCR1 / UBRLCR2 */
+#define UBRLCR_BAUD_MASK	((1 << 12) - 1)
+#define UBRLCR_BREAK		(1 << 12)
+#define UBRLCR_PRTEN		(1 << 13)
+#define UBRLCR_EVENPRT		(1 << 14)
+#define UBRLCR_XSTOP		(1 << 15)
+#define UBRLCR_FIFOEN		(1 << 16)
+#define UBRLCR_WRDLEN5		(0 << 17)
+#define UBRLCR_WRDLEN6		(1 << 17)
+#define UBRLCR_WRDLEN7		(2 << 17)
+#define UBRLCR_WRDLEN8		(3 << 17)
+#define UBRLCR_WRDLEN_MASK	(3 << 17)
+
+#define SYNCIO_FRMLEN(x)	(((x) & 0x1f) << 8)
+#define SYNCIO_SMCKEN		(1 << 13)
+#define SYNCIO_TXFRMEN		(1 << 14)
+
+#define DAIR_RESERVED		(0x0404)
+#define DAIR_DAIEN		(1 << 16)
+#define DAIR_ECS		(1 << 17)
+#define DAIR_LCTM		(1 << 19)
+#define DAIR_LCRM		(1 << 20)
+#define DAIR_RCTM		(1 << 21)
+#define DAIR_RCRM		(1 << 22)
+#define DAIR_LBM		(1 << 23)
+
+#define DAIDR2_FIFOEN		(1 << 15)
+#define DAIDR2_FIFOLEFT		(0x0d << 16)
+#define DAIDR2_FIFORIGHT	(0x11 << 16)
+
+#define DAISR_RCTS		(1 << 0)
+#define DAISR_RCRS		(1 << 1)
+#define DAISR_LCTS		(1 << 2)
+#define DAISR_LCRS		(1 << 3)
+#define DAISR_RCTU		(1 << 4)
+#define DAISR_RCRO		(1 << 5)
+#define DAISR_LCTU		(1 << 6)
+#define DAISR_LCRO		(1 << 7)
+#define DAISR_RCNF		(1 << 8)
+#define DAISR_RCNE		(1 << 9)
+#define DAISR_LCNF		(1 << 10)
+#define DAISR_LCNE		(1 << 11)
+#define DAISR_FIFO		(1 << 12)
+
+#define DAI64FS_I2SF64		(1 << 0)
+#define DAI64FS_AUDIOCLKEN	(1 << 1)
+#define DAI64FS_AUDIOCLKSRC	(1 << 2)
+#define DAI64FS_MCLK256EN	(1 << 3)
+#define DAI64FS_LOOPBACK	(1 << 5)
+#define DAI64FS_AUDIV_MASK	(0x7f)
+#define DAI64FS_AUDIV(x)	(((x) & DAI64FS_AUDIV_MASK) << 8)
+
+#define SYSCON3_ADCCON		(1 << 0)
+#define SYSCON3_CLKCTL0		(1 << 1)
+#define SYSCON3_CLKCTL1		(1 << 2)
+#define SYSCON3_DAISEL		(1 << 3)
+#define SYSCON3_ADCCKNSEN	(1 << 4)
+#define SYSCON3_VERSN(x)	(((x) >> 5) & 7)
+#define SYSCON3_VERSN_MASK	(7 << 5)
+#define SYSCON3_FASTWAKE	(1 << 8)
+#define SYSCON3_DAIEN		(1 << 9)
+#define SYSCON3_128FS		SYSCON3_DAIEN
+#define SYSCON3_ENPD67		(1 << 10)
+
+#define SDCONF_ACTIVE		(1 << 10)
+#define SDCONF_CLKCTL		(1 << 9)
+#define SDCONF_WIDTH_4		(0 << 7)
+#define SDCONF_WIDTH_8		(1 << 7)
+#define SDCONF_WIDTH_16		(2 << 7)
+#define SDCONF_WIDTH_32		(3 << 7)
+#define SDCONF_SIZE_16		(0 << 5)
+#define SDCONF_SIZE_64		(1 << 5)
+#define SDCONF_SIZE_128		(2 << 5)
+#define SDCONF_SIZE_256		(3 << 5)
+#define SDCONF_CASLAT_2		(2)
+#define SDCONF_CASLAT_3		(3)
+
+#define MEMCFG_BUS_WIDTH_32	(1)
+#define MEMCFG_BUS_WIDTH_16	(0)
+#define MEMCFG_BUS_WIDTH_8	(3)
+
+#define MEMCFG_SQAEN		(1 << 6)
+#define MEMCFG_CLKENB		(1 << 7)
+
+#define MEMCFG_WAITSTATE_8_3	(0 << 2)
+#define MEMCFG_WAITSTATE_7_3	(1 << 2)
+#define MEMCFG_WAITSTATE_6_3	(2 << 2)
+#define MEMCFG_WAITSTATE_5_3	(3 << 2)
+#define MEMCFG_WAITSTATE_4_2	(4 << 2)
+#define MEMCFG_WAITSTATE_3_2	(5 << 2)
+#define MEMCFG_WAITSTATE_2_2	(6 << 2)
+#define MEMCFG_WAITSTATE_1_2	(7 << 2)
+#define MEMCFG_WAITSTATE_8_1	(8 << 2)
+#define MEMCFG_WAITSTATE_7_1	(9 << 2)
+#define MEMCFG_WAITSTATE_6_1	(10 << 2)
+#define MEMCFG_WAITSTATE_5_1	(11 << 2)
+#define MEMCFG_WAITSTATE_4_0	(12 << 2)
+#define MEMCFG_WAITSTATE_3_0	(13 << 2)
+#define MEMCFG_WAITSTATE_2_0	(14 << 2)
+#define MEMCFG_WAITSTATE_1_0	(15 << 2)
+
+#endif
diff --git a/arch/arm/mach-clps711x/include/mach/devices.h b/arch/arm/mach-clps711x/include/mach/devices.h
new file mode 100644
index 0000000..7e5eaf9
--- /dev/null
+++ b/arch/arm/mach-clps711x/include/mach/devices.h
@@ -0,0 +1,6 @@
+#ifndef __MACH_DEVICES_H
+#define __MACH_DEVICES_H
+
+void clps711x_setup_memcfg(int bank, u32 val);
+
+#endif
diff --git a/arch/arm/mach-clps711x/reset.c b/arch/arm/mach-clps711x/reset.c
new file mode 100644
index 0000000..4a42ef4
--- /dev/null
+++ b/arch/arm/mach-clps711x/reset.c
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2012 Alexander Shiyan <shc_work at mail.ru>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ */
+
+#include <common.h>
+
+extern void start(void);
+
+void __noreturn reset_cpu(unsigned long addr)
+{
+	arch_shutdown();
+
+	asm("mov pc, #0");
+
+	hang();
+}
-- 
1.7.8.6



From shc_work at mail.ru  Fri Nov  2 05:17:15 2012
From: shc_work at mail.ru (Alexander Shiyan)
Date: Fri,  2 Nov 2012 13:17:15 +0400
Subject: [PATCH v4 2/3] ARM: clps711x: Add serial driver
In-Reply-To: <1351847836-8221-1-git-send-email-shc_work@mail.ru>
References: <1351847836-8221-1-git-send-email-shc_work@mail.ru>
Message-ID: <1351847836-8221-2-git-send-email-shc_work@mail.ru>

This patch adds a simple serial driver for CLPS711X architecture.

Signed-off-by: Alexander Shiyan <shc_work at mail.ru>
---
 arch/arm/mach-clps711x/devices.c              |   60 ++++++++++
 arch/arm/mach-clps711x/include/mach/devices.h |    1 +
 drivers/serial/Kconfig                        |    5 +
 drivers/serial/Makefile                       |    1 +
 drivers/serial/serial_clps711x.c              |  157 +++++++++++++++++++++++++
 5 files changed, 224 insertions(+), 0 deletions(-)
 create mode 100644 drivers/serial/serial_clps711x.c

diff --git a/arch/arm/mach-clps711x/devices.c b/arch/arm/mach-clps711x/devices.c
index c5fcbf2..08f27d2 100644
--- a/arch/arm/mach-clps711x/devices.c
+++ b/arch/arm/mach-clps711x/devices.c
@@ -35,3 +35,63 @@ void clps711x_setup_memcfg(int bank, u32 val)
 		break;
 	}
 }
+
+static struct resource uart0_resources[] = {
+	{
+		.start	= UBRLCR1,
+		.end	= UBRLCR1,
+		.flags	= IORESOURCE_MEM,
+	},
+	{
+		.start	= SYSCON1,
+		.end	= SYSCON1,
+		.flags	= IORESOURCE_MEM,
+	},
+	{
+		.start	= SYSFLG1,
+		.end	= SYSFLG1,
+		.flags	= IORESOURCE_MEM,
+	},
+	{
+		.start	= UARTDR1,
+		.end	= UARTDR1,
+		.flags	= IORESOURCE_MEM,
+	},
+};
+
+static struct resource uart1_resources[] = {
+	{
+		.start	= UBRLCR2,
+		.end	= UBRLCR2,
+		.flags	= IORESOURCE_MEM,
+	},
+	{
+		.start	= SYSCON2,
+		.end	= SYSCON2,
+		.flags	= IORESOURCE_MEM,
+	},
+	{
+		.start	= SYSFLG2,
+		.end	= SYSFLG2,
+		.flags	= IORESOURCE_MEM,
+	},
+	{
+		.start	= UARTDR2,
+		.end	= UARTDR2,
+		.flags	= IORESOURCE_MEM,
+	},
+};
+
+void clps711x_add_uart(unsigned int id)
+{
+	switch (id) {
+	case 0:
+		add_generic_device_res("clps711x_serial", 0, uart0_resources,
+				       ARRAY_SIZE(uart0_resources), NULL);
+		break;
+	case 1:
+		add_generic_device_res("clps711x_serial", 1, uart1_resources,
+				       ARRAY_SIZE(uart1_resources), NULL);
+		break;
+	}
+}
diff --git a/arch/arm/mach-clps711x/include/mach/devices.h b/arch/arm/mach-clps711x/include/mach/devices.h
index 7e5eaf9..18a251a 100644
--- a/arch/arm/mach-clps711x/include/mach/devices.h
+++ b/arch/arm/mach-clps711x/include/mach/devices.h
@@ -2,5 +2,6 @@
 #define __MACH_DEVICES_H
 
 void clps711x_setup_memcfg(int bank, u32 val);
+void clps711x_add_uart(unsigned int id);
 
 #endif
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 7eb96ed..02bc8bf 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -43,6 +43,11 @@ config DRIVER_SERIAL_BLACKFIN
 	default y
 	bool "Blackfin serial driver"
 
+config DRIVER_SERIAL_CLPS711X
+	depends on ARCH_CLPS711X
+	default y
+	bool "CLPS711X serial driver"
+
 config DRIVER_SERIAL_ALTERA
 	depends on NIOS2
 	default y
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index e2d56b9..e6f1e22 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -13,6 +13,7 @@ obj-$(CONFIG_DRIVER_SERIAL_NETX)		+= serial_netx.o
 obj-$(CONFIG_DRIVER_SERIAL_LINUX_CONSOLE)	+= linux_console.o
 obj-$(CONFIG_DRIVER_SERIAL_MPC5XXX)		+= serial_mpc5xxx.o
 obj-$(CONFIG_DRIVER_SERIAL_BLACKFIN)		+= serial_blackfin.o
+obj-$(CONFIG_DRIVER_SERIAL_CLPS711X)		+= serial_clps711x.o
 obj-$(CONFIG_DRIVER_SERIAL_NS16550)		+= serial_ns16550.o
 obj-$(CONFIG_DRIVER_SERIAL_PL010)		+= serial_pl010.o
 obj-$(CONFIG_DRIVER_SERIAL_S3C)			+= serial_s3c.o
diff --git a/drivers/serial/serial_clps711x.c b/drivers/serial/serial_clps711x.c
new file mode 100644
index 0000000..21d0b55
--- /dev/null
+++ b/drivers/serial/serial_clps711x.c
@@ -0,0 +1,157 @@
+/*
+ * Simple CLPS711X serial driver
+ *
+ * (C) Copyright 2012 Alexander Shiyan <shc_work at mail.ru>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ */
+
+#include <common.h>
+#include <malloc.h>
+#include <init.h>
+#include <io.h>
+#include <linux/clk.h>
+#include <linux/err.h>
+
+#include <mach/clps711x.h>
+
+struct clps711x_uart {
+	void __iomem		*UBRLCR;
+	void __iomem		*SYSCON;
+	void __iomem		*SYSFLG;
+	void __iomem		*UARTDR;
+	struct clk		*uart_clk;
+	struct console_device	cdev;
+};
+
+static int clps711x_setbaudrate(struct console_device *cdev, int baudrate)
+{
+	struct clps711x_uart *s = cdev->dev->priv;
+	int divisor;
+	u32 tmp;
+
+	divisor = (clk_get_rate(s->uart_clk) / 16) / baudrate;
+
+	tmp = readl(s->UBRLCR) & ~UBRLCR_BAUD_MASK;
+	tmp |= divisor - 1;
+	writel(tmp, s->UBRLCR);
+
+	return 0;
+}
+
+static void clps711x_init_port(struct console_device *cdev)
+{
+	struct clps711x_uart *s = cdev->dev->priv;
+	u32 tmp;
+
+	/* Disable the UART */
+	writel(readl(s->SYSCON) & ~SYSCON_UARTEN, s->SYSCON);
+
+	/* Setup Line Control Register */
+	tmp = readl(s->UBRLCR) & UBRLCR_BAUD_MASK;
+	tmp |= UBRLCR_FIFOEN | UBRLCR_WRDLEN8; /* FIFO on, 8N1 mode */
+	writel(tmp, s->UBRLCR);
+
+	/* Set default baudrate on initialization */
+	clps711x_setbaudrate(cdev, CONFIG_BAUDRATE);
+
+	/* Enable the UART */
+	writel(readl(s->SYSCON) | SYSCON_UARTEN, s->SYSCON);
+}
+
+static void clps711x_putc(struct console_device *cdev, char c)
+{
+	struct clps711x_uart *s = cdev->dev->priv;
+
+	/* Wait until there is space in the FIFO */
+	while (readl(s->SYSFLG) & SYSFLG_UTXFF)
+		barrier();
+
+	/* Send the character */
+	writew(c, s->UARTDR);
+}
+
+static int clps711x_getc(struct console_device *cdev)
+{
+	struct clps711x_uart *s = cdev->dev->priv;
+	u16 data;
+
+	/* Wait until there is data in the FIFO */
+	while (readl(s->SYSFLG) & SYSFLG_URXFE)
+		barrier();
+
+	data = readw(s->UARTDR);
+
+	/* Check for an error flag */
+	if (data & (UARTDR_FRMERR | UARTDR_PARERR | UARTDR_OVERR))
+		return -1;
+
+	return (int)data;
+}
+
+static int clps711x_tstc(struct console_device *cdev)
+{
+	struct clps711x_uart *s = cdev->dev->priv;
+
+	return !(readl(s->SYSFLG) & SYSFLG_URXFE);
+}
+
+static void clps711x_flush(struct console_device *cdev)
+{
+	struct clps711x_uart *s = cdev->dev->priv;
+
+	while (readl(s->SYSFLG) & SYSFLG_UBUSY)
+		barrier();
+}
+
+static int clps711x_probe(struct device_d *dev)
+{
+	struct clps711x_uart *s;
+
+	BUG_ON(dev->num_resources != 4);
+
+	s = xzalloc(sizeof(struct clps711x_uart));
+	s->uart_clk = clk_get(dev, NULL);
+	BUG_ON(IS_ERR(s->uart_clk));
+
+	s->UBRLCR = dev_get_mem_region(dev, 0);
+	s->SYSCON = dev_get_mem_region(dev, 1);
+	s->SYSFLG = dev_get_mem_region(dev, 2);
+	s->UARTDR = dev_get_mem_region(dev, 3);
+
+	dev->priv	= s;
+	s->cdev.dev	= dev;
+	s->cdev.f_caps	= CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR;
+	s->cdev.tstc	= clps711x_tstc;
+	s->cdev.putc	= clps711x_putc;
+	s->cdev.getc	= clps711x_getc;
+	s->cdev.flush	= clps711x_flush;
+	s->cdev.setbrg	= clps711x_setbaudrate;
+	clps711x_init_port(&s->cdev);
+
+	return console_register(&s->cdev);
+}
+
+static void clps711x_remove(struct device_d *dev)
+{
+	struct clps711x_uart *s = dev->priv;
+
+	clps711x_flush(&s->cdev);
+	console_unregister(&s->cdev);
+	free(s);
+}
+
+static struct driver_d clps711x_driver = {
+	.name	= "clps711x_serial",
+	.probe	= clps711x_probe,
+	.remove	= clps711x_remove,
+};
+
+static int clps711x_init(void)
+{
+	return platform_driver_register(&clps711x_driver);
+}
+console_initcall(clps711x_init);
-- 
1.7.8.6



From shc_work at mail.ru  Fri Nov  2 05:17:16 2012
From: shc_work at mail.ru (Alexander Shiyan)
Date: Fri,  2 Nov 2012 13:17:16 +0400
Subject: [PATCH v4 3/3] ARM: clps711x: Add generic board support (CLEP7212)
In-Reply-To: <1351847836-8221-1-git-send-email-shc_work@mail.ru>
References: <1351847836-8221-1-git-send-email-shc_work@mail.ru>
Message-ID: <1351847836-8221-3-git-send-email-shc_work@mail.ru>

This patch adds generic board support (CLEP7212, Linux ARM ID=91)
for CLPS711X-target.

Signed-off-by: Alexander Shiyan <shc_work at mail.ru>
---
 arch/arm/Makefile                               |    1 +
 arch/arm/boards/clep7212/Makefile               |    2 +
 arch/arm/boards/clep7212/clep7212.c             |   64 +++++++++++++++++++++++
 arch/arm/boards/clep7212/config.h               |    4 ++
 arch/arm/boards/clep7212/env/bin/mtdparts-add   |   21 +++++++
 arch/arm/boards/clep7212/env/boot/nor           |    9 +++
 arch/arm/boards/clep7212/env/init/automount     |    6 ++
 arch/arm/boards/clep7212/env/init/bootargs-base |    8 +++
 arch/arm/boards/clep7212/env/init/general       |   12 ++++
 arch/arm/boards/clep7212/env/init/hostname      |    8 +++
 arch/arm/boards/clep7212/lowlevel.c             |   56 ++++++++++++++++++++
 arch/arm/configs/clps711x_defconfig             |   42 +++++++++++++++
 arch/arm/mach-clps711x/Kconfig                  |   18 ++++++
 13 files changed, 251 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/boards/clep7212/Makefile
 create mode 100644 arch/arm/boards/clep7212/clep7212.c
 create mode 100644 arch/arm/boards/clep7212/config.h
 create mode 100644 arch/arm/boards/clep7212/env/bin/mtdparts-add
 create mode 100644 arch/arm/boards/clep7212/env/boot/nor
 create mode 100644 arch/arm/boards/clep7212/env/init/automount
 create mode 100644 arch/arm/boards/clep7212/env/init/bootargs-base
 create mode 100644 arch/arm/boards/clep7212/env/init/general
 create mode 100644 arch/arm/boards/clep7212/env/init/hostname
 create mode 100644 arch/arm/boards/clep7212/lowlevel.c
 create mode 100644 arch/arm/configs/clps711x_defconfig

diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index da80e00..05f9943 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -76,6 +76,7 @@ board-$(CONFIG_MACH_AT91SAM9G10EK)		:= at91sam9261ek
 board-$(CONFIG_MACH_AT91SAM9G20EK)		:= at91sam9260ek
 board-$(CONFIG_MACH_AT91SAM9X5EK)		:= at91sam9x5ek
 board-$(CONFIG_MACH_AT91SAM9M10G45EK)		:= at91sam9m10g45ek
+board-$(CONFIG_MACH_CLEP7212)			:= clep7212
 board-$(CONFIG_MACH_DSS11)			:= dss11
 board-$(CONFIG_MACH_EDB9301)			:= edb93xx
 board-$(CONFIG_MACH_EDB9302)			:= edb93xx
diff --git a/arch/arm/boards/clep7212/Makefile b/arch/arm/boards/clep7212/Makefile
new file mode 100644
index 0000000..a63aeae
--- /dev/null
+++ b/arch/arm/boards/clep7212/Makefile
@@ -0,0 +1,2 @@
+obj-y += lowlevel.o clep7212.o
+pbl-y += lowlevel.o
diff --git a/arch/arm/boards/clep7212/clep7212.c b/arch/arm/boards/clep7212/clep7212.c
new file mode 100644
index 0000000..a32337f
--- /dev/null
+++ b/arch/arm/boards/clep7212/clep7212.c
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2012 Alexander Shiyan <shc_work at mail.ru>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ */
+
+#include <common.h>
+#include <driver.h>
+#include <init.h>
+#include <partition.h>
+#include <io.h>
+#include <sizes.h>
+#include <asm/armlinux.h>
+#include <generated/mach-types.h>
+
+#include <mach/clps711x.h>
+#include <mach/devices.h>
+
+static int clps711x_mem_init(void)
+{
+	ulong memsize = get_ram_size((ulong *)SDRAM0_BASE, SZ_32M);
+
+	arm_add_mem_device("ram0", SDRAM0_BASE, memsize);
+
+	return 0;
+}
+mem_initcall(clps711x_mem_init);
+
+static int clps711x_devices_init(void)
+{
+	u32 serial_h = 0, serial_l = readl(UNIQID);
+
+	/* Setup Chipselects */
+	clps711x_setup_memcfg(0, MEMCFG_WAITSTATE_6_1 | MEMCFG_BUS_WIDTH_16);
+	clps711x_setup_memcfg(1, MEMCFG_WAITSTATE_6_1 | MEMCFG_BUS_WIDTH_8);
+	clps711x_setup_memcfg(2, MEMCFG_WAITSTATE_8_3 | MEMCFG_BUS_WIDTH_16 |
+			      MEMCFG_CLKENB);
+	clps711x_setup_memcfg(3, MEMCFG_WAITSTATE_6_1 | MEMCFG_BUS_WIDTH_32);
+
+	add_cfi_flash_device(0, CS0_BASE, SZ_32M, 0);
+
+	devfs_add_partition("nor0", 0x00000, SZ_256K, DEVFS_PARTITION_FIXED,
+			    "self0");
+	devfs_add_partition("nor0", SZ_256K, SZ_256K, DEVFS_PARTITION_FIXED,
+			    "env0");
+
+	armlinux_set_bootparams((void *)SDRAM0_BASE + 0x100);
+	armlinux_set_architecture(MACH_TYPE_CLEP7212);
+	armlinux_set_serial(((u64)serial_h << 32) | serial_l);
+
+	return 0;
+}
+device_initcall(clps711x_devices_init);
+
+static int clps711x_console_init(void)
+{
+	clps711x_add_uart(0);
+
+	return 0;
+}
+console_initcall(clps711x_console_init);
diff --git a/arch/arm/boards/clep7212/config.h b/arch/arm/boards/clep7212/config.h
new file mode 100644
index 0000000..6ae9a40
--- /dev/null
+++ b/arch/arm/boards/clep7212/config.h
@@ -0,0 +1,4 @@
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+#endif  /* __CONFIG_H */
diff --git a/arch/arm/boards/clep7212/env/bin/mtdparts-add b/arch/arm/boards/clep7212/env/bin/mtdparts-add
new file mode 100644
index 0000000..ef1bc02
--- /dev/null
+++ b/arch/arm/boards/clep7212/env/bin/mtdparts-add
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+	init-menu-add-entry "$0" "Partitions"
+	exit
+fi
+
+norparts="256k(barebox),256k(bareboxenv),3584k(kernel),-(root)"
+ramparts="-(ramdisk)"
+
+if [ -e /dev/nor0 ]; then
+	addpart -n /dev/nor0 "${norparts}"
+
+	global linux.mtdparts.nor
+	global.linux.mtdparts.nor="physmap-flash.0:${norparts}"
+else
+	echo "NOR Flash not found."
+fi
+
+global linux.mtdparts.ram
+global.linux.mtdparts.ram="mtd-ram.0:${ramparts}"
diff --git a/arch/arm/boards/clep7212/env/boot/nor b/arch/arm/boards/clep7212/env/boot/nor
new file mode 100644
index 0000000..5cf1e15
--- /dev/null
+++ b/arch/arm/boards/clep7212/env/boot/nor
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+	boot-menu-add-entry "$0" "NOR Flash"
+	exit
+fi
+
+global.bootm.image="/dev/kernel"
+global.linux.bootargs.dyn.root="root=/dev/mtdblock4 ro"
diff --git a/arch/arm/boards/clep7212/env/init/automount b/arch/arm/boards/clep7212/env/init/automount
new file mode 100644
index 0000000..978b964
--- /dev/null
+++ b/arch/arm/boards/clep7212/env/init/automount
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+	init-menu-add-entry "$0" "Automountpoints"
+	exit
+fi
diff --git a/arch/arm/boards/clep7212/env/init/bootargs-base b/arch/arm/boards/clep7212/env/init/bootargs-base
new file mode 100644
index 0000000..ec08e39
--- /dev/null
+++ b/arch/arm/boards/clep7212/env/init/bootargs-base
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+	init-menu-add-entry "$0" "Base bootargs"
+	exit
+fi
+
+global.linux.bootargs.base="earlyprintk console=ttyCL0,57600n8"
diff --git a/arch/arm/boards/clep7212/env/init/general b/arch/arm/boards/clep7212/env/init/general
new file mode 100644
index 0000000..77e6a59
--- /dev/null
+++ b/arch/arm/boards/clep7212/env/init/general
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+	init-menu-add-entry "$0" "general config settings"
+	exit
+fi
+
+global.user=barebox
+global.autoboot_timeout=2
+global.boot.default=nor
+
+/env/bin/mtdparts-add
diff --git a/arch/arm/boards/clep7212/env/init/hostname b/arch/arm/boards/clep7212/env/init/hostname
new file mode 100644
index 0000000..684ee63
--- /dev/null
+++ b/arch/arm/boards/clep7212/env/init/hostname
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+	init-menu-add-entry "$0" "hostname"
+	exit
+fi
+
+global.hostname=clep7212
diff --git a/arch/arm/boards/clep7212/lowlevel.c b/arch/arm/boards/clep7212/lowlevel.c
new file mode 100644
index 0000000..9b7e241
--- /dev/null
+++ b/arch/arm/boards/clep7212/lowlevel.c
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2012 Alexander Shiyan <shc_work at mail.ru>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ */
+
+#include <common.h>
+#include <init.h>
+
+#include <asm/io.h>
+#include <asm/barebox-arm.h>
+#include <asm/barebox-arm-head.h>
+
+#include <mach/clps711x.h>
+
+#define MAIN_CLOCK		3686400
+#define CPU_SPEED		92160000
+#define BUS_SPEED		(CPU_SPEED / 2)
+
+#define PLL_VALUE		(((CPU_SPEED * 2) / MAIN_CLOCK) << 24)
+#define SDRAM_REFRESH_RATE	(64 * (BUS_SPEED / (8192 * 1000)))
+
+void __naked __bare_init reset(void)
+{
+	u32 tmp;
+
+	common_reset();
+
+	/* Setup base clock */
+	writel(SYSCON3_CLKCTL0 | SYSCON3_CLKCTL1, SYSCON3);
+	asm("nop");
+
+	/* Setup PLL */
+	writel(PLL_VALUE, PLLW);
+	asm("nop");
+
+	/* CLKEN select, SDRAM width=32 */
+	writel(SYSCON2_CLKENSL, SYSCON2);
+
+	/* Enable SDQM pins */
+	tmp = readl(SYSCON3);
+	tmp &= ~SYSCON3_ENPD67;
+	writel(tmp, SYSCON3);
+
+	/* Setup Refresh Rate (64ms 8K Blocks) */
+	writel(SDRAM_REFRESH_RATE, SDRFPR);
+
+	/* Setup SDRAM (32MB, 16Bit*2, CAS=3) */
+	writel(SDCONF_CASLAT_3 | SDCONF_SIZE_256 | SDCONF_WIDTH_16 |
+	       SDCONF_CLKCTL | SDCONF_ACTIVE, SDCONF);
+
+	board_init_lowlevel_return();
+}
diff --git a/arch/arm/configs/clps711x_defconfig b/arch/arm/configs/clps711x_defconfig
new file mode 100644
index 0000000..cf2b3b6
--- /dev/null
+++ b/arch/arm/configs/clps711x_defconfig
@@ -0,0 +1,42 @@
+CONFIG_ARCH_CLPS711X=y
+CONFIG_AEABI=y
+CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y
+# CONFIG_MEMINFO is not set
+CONFIG_TEXT_BASE=0xc0780000
+CONFIG_EXPERIMENTAL=y
+CONFIG_BAUDRATE=57600
+CONFIG_CMDLINE_EDITING=y
+CONFIG_AUTO_COMPLETE=y
+CONFIG_DEFAULT_ENVIRONMENT_COMPRESSED_LZO=y
+CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y
+CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/arm/boards/clep7212/env"
+CONFIG_CMD_EDIT=y
+CONFIG_CMD_SAVEENV=y
+CONFIG_CMD_EXPORT=y
+CONFIG_CMD_PRINTENV=y
+CONFIG_CMD_ECHO_E=y
+CONFIG_CMD_IOMEM=y
+CONFIG_CMD_CRC=y
+CONFIG_CMD_CRC_CMP=y
+CONFIG_CMD_FLASH=y
+CONFIG_CMD_BOOTM_SHOW_TYPE=y
+CONFIG_CMD_BOOTM_INITRD=y
+CONFIG_CMD_BOOTZ=y
+# CONFIG_CMD_BOOTU is not set
+CONFIG_CMD_RESET=y
+CONFIG_CMD_TIMEOUT=y
+CONFIG_CMD_PARTITION=y
+CONFIG_CMD_MAGICVAR=y
+CONFIG_CMD_MAGICVAR_HELP=y
+# CONFIG_SPI is not set
+CONFIG_DRIVER_CFI=y
+# CONFIG_DRIVER_CFI_BANK_WIDTH_1 is not set
+# CONFIG_DRIVER_CFI_BANK_WIDTH_4 is not set
+CONFIG_MTD=y
+CONFIG_DISK=y
+CONFIG_DISK_WRITE=y
+CONFIG_DISK_INTF_PLATFORM_IDE=y
+CONFIG_FS_CRAMFS=y
+CONFIG_FS_FAT=y
+CONFIG_FS_FAT_LFN=y
+CONFIG_LZO_DECOMPRESS=y
diff --git a/arch/arm/mach-clps711x/Kconfig b/arch/arm/mach-clps711x/Kconfig
index 56ca2ca..469ca72 100644
--- a/arch/arm/mach-clps711x/Kconfig
+++ b/arch/arm/mach-clps711x/Kconfig
@@ -3,6 +3,24 @@ if ARCH_CLPS711X
 choice
 	prompt "Cirrus Logic EP711x/EP721x/EP731x Board Type"
 
+config MACH_CLEP7212
+	bool "Cirrus Logic CLEP7212"
+	select MACH_HAS_LOWLEVEL_INIT
+	select MACH_DO_LOWLEVEL_INIT
+	help
+	  Boards based on the Cirrus Logic 7212/7312 CPU.
+
 endchoice
 
+config BOARDINFO
+	default "Cirrus Logic CLEP7212" if MACH_CLEP7212
+
+config ARCH_TEXT_BASE
+	hex
+	default 0xc0780000 if MACH_CLEP7212
+
+config BAREBOX_MAX_IMAGE_SIZE
+	hex
+	default 0x00080000 if MACH_CLEP7212
+
 endif
-- 
1.7.8.6



From plagnioj at jcrosoft.com  Fri Nov  2 05:24:19 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri, 2 Nov 2012 10:24:19 +0100
Subject: [PATCH 1/4] i2c: adapter: register it's own device
In-Reply-To: <20121102072940.GB1641@pengutronix.de>
References: <20121101094216.GI29599@game.jcrosoft.org>
 <1351763092-5781-1-git-send-email-plagnioj@jcrosoft.com>
 <20121102072940.GB1641@pengutronix.de>
Message-ID: <20121102092419.GN29599@game.jcrosoft.org>

On 08:29 Fri 02 Nov     , Sascha Hauer wrote:
> On Thu, Nov 01, 2012 at 10:44:49AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > so we can show the this of i2c busses
> > set the bus device as parent of all devices.
> > 
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
> > ---
> >  drivers/i2c/busses/i2c-imx.c  |   20 ++++++++++----------
> >  drivers/i2c/busses/i2c-omap.c |   30 +++++++++++++++---------------
> >  drivers/i2c/i2c.c             |   18 +++++++++++++++---
> >  include/i2c/i2c.h             |    2 +-
> >  4 files changed, 41 insertions(+), 29 deletions(-)
> > 
> >  int i2c_add_numbered_adapter(struct i2c_adapter *adapter)
> >  {
> > -	if (i2c_get_adapter(adapter->nr))
> > -		return -EBUSY;
> 
> If you remove this and instead depend on register_device bailing out
> later then you should change the error value register_device returns
> to -EBUSY. Currently it returns -EINVAL, -EBUSY seems much better here.
> 
> 
> > +	int ret;
> > +
> > +	adapter->dev.id = adapter->nr;
> > +	strcpy(adapter->dev.name, "i2c");
> > +
> > +	if (adapter->dev.parent)
> > +		dev_add_child(adapter->dev.parent, &adapter->dev);
> 
> We should push the dev_add_child to the driver core. Doing this here
> means that...
> 
> > +
> > +	ret = register_device(&adapter->dev);
> > +	if (ret)
> > +		return ret;
> 
> ... the parents child list will be corrupted when register_device fails.
> At least w1 and mdiobus have the same problem. But ok, we can fix that
> later.

ok I'll take a look after the whole sam9x5 stuff will merged

Best Regards,
J.


From plagnioj at jcrosoft.com  Fri Nov  2 05:27:18 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri, 2 Nov 2012 10:27:18 +0100
Subject: [PATCH 0/4 v2] i2c: add algo-bit support with gpio and versatile
 support
Message-ID: <20121102092718.GO29599@game.jcrosoft.org>

HI,

	v2: keep return -EBUSY if the adapter is already present

	the foloing patch series add the i2c algo bit support with 2 drivers
	that use it

	 - gpio
	 - versatile

	 thie also create a device for i2c bus itself

	 all the pedending branch are rebased on it

The following changes since commit 2d1ceaff2f905f4a2bd7e6c539e7dd3d8d8e9bef:

  uimage: Fix deleting of temporary file (2012-10-30 18:39:38 +0100)

are available in the git repository at:

  git://git.jcrosoft.org/barebox.git delivery/i2c

for you to fetch changes up to 5c90416b6ffb8d4ca7c4bc6aff92578b555cb965:

  i2c: add versatile support (2012-11-02 02:17:04 +0800)

----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (4):
      i2c: adapter: register it's own device
      i2c: add i2c algo bit support
      i2c: add i2c-gpio support
      i2c: add versatile support

 drivers/i2c/Kconfig                |    1 +
 drivers/i2c/Makefile               |    2 +-
 drivers/i2c/algos/Kconfig          |    6 +++
 drivers/i2c/algos/Makefile         |    5 ++
 drivers/i2c/algos/i2c-algo-bit.c   |  585 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/i2c/busses/Kconfig         |   16 +++++++
 drivers/i2c/busses/Makefile        |    2 +
 drivers/i2c/busses/i2c-gpio.c      |  177 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/i2c/busses/i2c-imx.c       |   20 ++++----
 drivers/i2c/busses/i2c-omap.c      |   30 ++++++------
 drivers/i2c/busses/i2c-versatile.c |  112 +++++++++++++++++++++++++++++++++++++++++++++
 drivers/i2c/i2c.c                  |   17 ++++++-
 include/i2c/i2c-algo-bit.h         |   55 ++++++++++++++++++++++
 include/i2c/i2c-gpio.h             |   38 +++++++++++++++
 include/i2c/i2c.h                  |    4 +-
 15 files changed, 1042 insertions(+), 28 deletions(-)
 create mode 100644 drivers/i2c/algos/Kconfig
 create mode 100644 drivers/i2c/algos/Makefile
 create mode 100644 drivers/i2c/algos/i2c-algo-bit.c
 create mode 100644 drivers/i2c/busses/i2c-gpio.c
 create mode 100644 drivers/i2c/busses/i2c-versatile.c
 create mode 100644 include/i2c/i2c-algo-bit.h
 create mode 100644 include/i2c/i2c-gpio.h

Best Regards,
J.


From plagnioj at jcrosoft.com  Fri Nov  2 05:34:11 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri, 2 Nov 2012 10:34:11 +0100
Subject: [PATCH 0/7] at91 add i2c-gpio suport
In-Reply-To: <20121101143352.GJ29599@game.jcrosoft.org>
References: <20121101143352.GJ29599@game.jcrosoft.org>
Message-ID: <20121102093411.GP29599@game.jcrosoft.org>

On 15:33 Thu 01 Nov     , Jean-Christophe PLAGNIOL-VILLARD wrote:
> Hi,
> 
> 	This paatch serie add the i2c suport to at91 using the i2c-gpio as teh
> 	IP is broken until the sam9x5. For the sam9x5 untill we have the hw
> 	driver support use the i2c-gpio too
> 
> 	on the sam9x5ek enable the i2c and the qt1070
> 
> 	This patch serie depends on i2c qt1070 patch and the at91sam9x5ek
> 	1-wire one
> 
v2 rebase on i2c v2 patch series

The following changes since commit d3298969a9fcc5d95c2c4f8a39c1d4aa21780009:

  i2c: add versatile support (2012-11-02 02:24:49 +0800)

are available in the git repository at:

  git://git.jcrosoft.org/barebox.git delivery/at91_i2c

for you to fetch changes up to 972103b8b146974e4d1ed6a5912f6b0172c40d02:

  at91sam9x5ek: add i2c support (2012-11-02 02:24:59 +0800)

----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (7):
      at91sam9x5: add i2c support
      at91rm9200: add i2c support
      at91sam9260/sam9g20: add i2c support
      at91sam9263: add i2c support
      at91sam9261/sam9g10: add i2c support
      at91sam9g45: add i2c support
      at91sam9x5ek: add i2c support

 arch/arm/boards/at91sam9x5ek/init.c      |   12 ++++++++++++
 arch/arm/configs/at91sam9x5ek_defconfig  |    3 +++
 arch/arm/mach-at91/at91rm9200_devices.c  |   28 ++++++++++++++++++++++++++++
 arch/arm/mach-at91/at91sam9260_devices.c |   32 ++++++++++++++++++++++++++++++++
 arch/arm/mach-at91/at91sam9261_devices.c |   31 +++++++++++++++++++++++++++++++
 arch/arm/mach-at91/at91sam9263_devices.c |   31 +++++++++++++++++++++++++++++++
 arch/arm/mach-at91/at91sam9g45_devices.c |   50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-at91/at91sam9x5_devices.c  |   58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-at91/include/mach/board.h  |    3 +++
 9 files changed, 248 insertions(+)

Best Regards,
J.


From plagnioj at jcrosoft.com  Fri Nov  2 05:36:49 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri,  2 Nov 2012 10:36:49 +0100
Subject: [PATCH 1/4] i2c: adapter: register it's own device
In-Reply-To: <20121102092718.GO29599@game.jcrosoft.org>
References: <20121102092718.GO29599@game.jcrosoft.org>
Message-ID: <1351849012-26236-1-git-send-email-plagnioj@jcrosoft.com>

so we can show the this of i2c busses
set the bus device as parent of all devices.

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/i2c/busses/i2c-imx.c  |   20 ++++++++++----------
 drivers/i2c/busses/i2c-omap.c |   30 +++++++++++++++---------------
 drivers/i2c/i2c.c             |   17 ++++++++++++++++-
 include/i2c/i2c.h             |    2 +-
 4 files changed, 42 insertions(+), 27 deletions(-)

diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index a1012a7..7f9a2dc 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -154,7 +154,7 @@ static int i2c_fsl_bus_busy(struct i2c_adapter *adapter, int for_busy)
 		if (!for_busy && !(temp & I2SR_IBB))
 			break;
 		if (is_timeout(start, 500 * MSECOND)) {
-			dev_err(adapter->dev,
+			dev_err(&adapter->dev,
 				 "<%s> timeout waiting for I2C bus %s\n",
 				 __func__,for_busy ? "busy" : "not busy");
 			return -EIO;
@@ -177,7 +177,7 @@ static int i2c_fsl_trx_complete(struct i2c_adapter *adapter)
 			break;
 
 		if (is_timeout(start, 100 * MSECOND)) {
-			dev_err(adapter->dev, "<%s> TXR timeout\n", __func__);
+			dev_err(&adapter->dev, "<%s> TXR timeout\n", __func__);
 			return -EIO;
 		}
 	}
@@ -199,7 +199,7 @@ static int i2c_fsl_acked(struct i2c_adapter *adapter)
 			break;
 
 		if (is_timeout(start, MSECOND)) {
-			dev_dbg(adapter->dev, "<%s> No ACK\n", __func__);
+			dev_dbg(&adapter->dev, "<%s> No ACK\n", __func__);
 			return -EIO;
 		}
 	}
@@ -368,9 +368,9 @@ static void i2c_fsl_set_clk(struct fsl_i2c_struct *i2c_fsl,
 		(500000U * i2c_clk_div[i][0] + (i2c_clk_rate / 2) - 1) /
 		(i2c_clk_rate / 2);
 
-	dev_dbg(i2c_fsl->adapter.dev, "<%s> I2C_CLK=%d, REQ DIV=%d\n",
+	dev_dbg(&i2c_fsl->adapter.dev, "<%s> I2C_CLK=%d, REQ DIV=%d\n",
 		__func__, i2c_clk_rate, div);
-	dev_dbg(i2c_fsl->adapter.dev, "<%s> IFDR[IC]=0x%x, REAL DIV=%d\n",
+	dev_dbg(&i2c_fsl->adapter.dev, "<%s> IFDR[IC]=0x%x, REAL DIV=%d\n",
 		__func__, i2c_clk_div[i][1], i2c_clk_div[i][0]);
 }
 #endif
@@ -382,7 +382,7 @@ static int i2c_fsl_write(struct i2c_adapter *adapter, struct i2c_msg *msgs)
 	int i, result;
 
 	if ( !(msgs->flags & I2C_M_DATA_ONLY) ) {
-		dev_dbg(adapter->dev,
+		dev_dbg(&adapter->dev,
 			"<%s> write slave address: addr=0x%02x\n",
 			__func__, msgs->addr << 1);
 
@@ -399,7 +399,7 @@ static int i2c_fsl_write(struct i2c_adapter *adapter, struct i2c_msg *msgs)
 
 	/* write data */
 	for (i = 0; i < msgs->len; i++) {
-		dev_dbg(adapter->dev,
+		dev_dbg(&adapter->dev,
 			"<%s> write byte: B%d=0x%02X\n",
 			__func__, i, msgs->buf[i]);
 		writeb(msgs->buf[i], base + FSL_I2C_I2DR);
@@ -425,7 +425,7 @@ static int i2c_fsl_read(struct i2c_adapter *adapter, struct i2c_msg *msgs)
 	writeb(0x0, base + FSL_I2C_I2SR);
 
 	if ( !(msgs->flags & I2C_M_DATA_ONLY) ) {
-		dev_dbg(adapter->dev,
+		dev_dbg(&adapter->dev,
 			"<%s> write slave address: addr=0x%02x\n",
 			__func__, (msgs->addr << 1) | 0x01);
 
@@ -478,7 +478,7 @@ static int i2c_fsl_read(struct i2c_adapter *adapter, struct i2c_msg *msgs)
 		}
 		msgs->buf[i] = readb(base + FSL_I2C_I2DR);
 
-		dev_dbg(adapter->dev, "<%s> read byte: B%d=0x%02X\n",
+		dev_dbg(&adapter->dev, "<%s> read byte: B%d=0x%02X\n",
 			__func__, i, msgs->buf[i]);
 	}
 	return 0;
@@ -544,7 +544,7 @@ static int __init i2c_fsl_probe(struct device_d *pdev)
 	/* Setup i2c_fsl driver structure */
 	i2c_fsl->adapter.master_xfer = i2c_fsl_xfer;
 	i2c_fsl->adapter.nr = pdev->id;
-	i2c_fsl->adapter.dev = pdev;
+	i2c_fsl->adapter.dev.parent = pdev;
 	i2c_fsl->base = dev_request_mem_region(pdev, 0);
 	i2c_fsl->dfsrr = -1;
 
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 24961eb..f371875 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -318,7 +318,7 @@ static int omap_i2c_init(struct omap_i2c_struct *i2c_omap)
 		while (!(omap_i2c_read_reg(i2c_omap, OMAP_I2C_SYSS_REG) &
 			 SYSS_RESETDONE_MASK)) {
 			if (is_timeout(start, MSECOND)) {
-				dev_warn(i2c_omap->adapter.dev, "timeout waiting "
+				dev_warn(&i2c_omap->adapter.dev, "timeout waiting "
 						"for controller reset\n");
 				return -ETIMEDOUT;
 			}
@@ -453,7 +453,7 @@ static int omap_i2c_wait_for_bb(struct i2c_adapter *adapter)
 	start = get_time_ns();
 	while (omap_i2c_read_reg(i2c_omap, OMAP_I2C_STAT_REG) & OMAP_I2C_STAT_BB) {
 		if (is_timeout(start, MSECOND)) {
-			dev_warn(adapter->dev, "timeout waiting for bus ready\n");
+			dev_warn(&adapter->dev, "timeout waiting for bus ready\n");
 			return -ETIMEDOUT;
 		}
 	}
@@ -476,9 +476,9 @@ omap_i2c_isr(struct omap_i2c_struct *dev)
 
 	bits = omap_i2c_read_reg(dev, OMAP_I2C_IE_REG);
 	while ((stat = (omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG))) & bits) {
-		dev_dbg(dev->adapter.dev, "IRQ (ISR = 0x%04x)\n", stat);
+		dev_dbg(&dev->adapter.dev, "IRQ (ISR = 0x%04x)\n", stat);
 		if (count++ == 100) {
-			dev_warn(dev->adapter.dev, "Too much work in one IRQ\n");
+			dev_warn(&dev->adapter.dev, "Too much work in one IRQ\n");
 			break;
 		}
 
@@ -499,7 +499,7 @@ complete:
 					   OMAP_I2C_CON_STP);
 		}
 		if (stat & OMAP_I2C_STAT_AL) {
-			dev_err(dev->adapter.dev, "Arbitration lost\n");
+			dev_err(&dev->adapter.dev, "Arbitration lost\n");
 			err |= OMAP_I2C_STAT_AL;
 		}
 		if (stat & (OMAP_I2C_STAT_ARDY | OMAP_I2C_STAT_NACK |
@@ -536,11 +536,11 @@ complete:
 					}
 				} else {
 					if (stat & OMAP_I2C_STAT_RRDY)
-						dev_err(dev->adapter.dev,
+						dev_err(&dev->adapter.dev,
 							"RRDY IRQ while no data"
 								" requested\n");
 					if (stat & OMAP_I2C_STAT_RDR)
-						dev_err(dev->adapter.dev,
+						dev_err(&dev->adapter.dev,
 							"RDR IRQ while no data"
 								" requested\n");
 					break;
@@ -577,11 +577,11 @@ complete:
 					}
 				} else {
 					if (stat & OMAP_I2C_STAT_XRDY)
-						dev_err(dev->adapter.dev,
+						dev_err(&dev->adapter.dev,
 							"XRDY IRQ while no "
 							"data to send\n");
 					if (stat & OMAP_I2C_STAT_XDR)
-						dev_err(dev->adapter.dev,
+						dev_err(&dev->adapter.dev,
 							"XDR IRQ while no "
 							"data to send\n");
 					break;
@@ -613,11 +613,11 @@ complete:
 			continue;
 		}
 		if (stat & OMAP_I2C_STAT_ROVR) {
-			dev_err(dev->adapter.dev, "Receive overrun\n");
+			dev_err(&dev->adapter.dev, "Receive overrun\n");
 			dev->cmd_err |= OMAP_I2C_STAT_ROVR;
 		}
 		if (stat & OMAP_I2C_STAT_XUDF) {
-			dev_err(dev->adapter.dev, "Transmit underflow\n");
+			dev_err(&dev->adapter.dev, "Transmit underflow\n");
 			dev->cmd_err |= OMAP_I2C_STAT_XUDF;
 		}
 	}
@@ -639,7 +639,7 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adapter,
 	int ret = 0;
 
 
-	dev_dbg(adapter->dev, "addr: 0x%04x, len: %d, flags: 0x%x, stop: %d\n",
+	dev_dbg(&adapter->dev, "addr: 0x%04x, len: %d, flags: 0x%x, stop: %d\n",
 		msg->addr, msg->len, msg->flags, stop);
 
 	if (msg->len == 0)
@@ -687,7 +687,7 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adapter,
 
 			/* Let the user know if i2c is in a bad state */
 			if (is_timeout(start, MSECOND)) {
-				dev_err(adapter->dev, "controller timed out "
+				dev_err(&adapter->dev, "controller timed out "
 				"waiting for start condition to finish\n");
 				return -ETIMEDOUT;
 			}
@@ -707,7 +707,7 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adapter,
 	while (ret){
 		ret = omap_i2c_isr(i2c_omap);
 		if (is_timeout(start, MSECOND)) {
-				dev_err(adapter->dev,
+				dev_err(&adapter->dev,
 				"timed out on polling for "
 				"open i2c message handling\n");
 				return -ETIMEDOUT;
@@ -835,7 +835,7 @@ i2c_omap_probe(struct device_d *pdev)
 
 	i2c_omap->adapter.master_xfer	= omap_i2c_xfer,
 	i2c_omap->adapter.nr = pdev->id;
-	i2c_omap->adapter.dev = pdev;
+	i2c_omap->adapter.dev.parent = pdev;
 
 	/* i2c device drivers may be active on return from add_adapter() */
 	r = i2c_add_numbered_adapter(&i2c_omap->adapter);
diff --git a/drivers/i2c/i2c.c b/drivers/i2c/i2c.c
index 27fd256..3af5c32 100644
--- a/drivers/i2c/i2c.c
+++ b/drivers/i2c/i2c.c
@@ -80,7 +80,7 @@ int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
 	 */
 
 	for (ret = 0; ret < num; ret++) {
-		dev_dbg(adap->dev, "master_xfer[%d] %c, addr=0x%02x, "
+		dev_dbg(&adap->dev, "master_xfer[%d] %c, addr=0x%02x, "
 			"len=%d\n", ret, (msgs[ret].flags & I2C_M_RD)
 			? 'R' : 'W', msgs[ret].addr, msgs[ret].len);
 	}
@@ -256,6 +256,9 @@ struct i2c_client *i2c_new_device(struct i2c_adapter *adapter,
 	client->adapter = adapter;
 	client->addr = chip->addr;
 
+	client->dev.parent = &adapter->dev;
+	dev_add_child(client->dev.parent, &client->dev);
+
 	status = register_device(&client->dev);
 
 #if 0
@@ -363,9 +366,21 @@ struct i2c_adapter *i2c_get_adapter(int busnum)
  */
 int i2c_add_numbered_adapter(struct i2c_adapter *adapter)
 {
+	int ret;
+
 	if (i2c_get_adapter(adapter->nr))
 		return -EBUSY;
 
+	adapter->dev.id = adapter->nr;
+	strcpy(adapter->dev.name, "i2c");
+
+	if (adapter->dev.parent)
+		dev_add_child(adapter->dev.parent, &adapter->dev);
+
+	ret = register_device(&adapter->dev);
+	if (ret)
+		return ret;
+
 	list_add_tail(&adapter->list, &adapter_list);
 
 	/* populate children from any i2c device tables */
diff --git a/include/i2c/i2c.h b/include/i2c/i2c.h
index de2a7ea..5021dd4 100644
--- a/include/i2c/i2c.h
+++ b/include/i2c/i2c.h
@@ -66,7 +66,7 @@ struct i2c_msg {
  *
  */
 struct i2c_adapter {
-	struct device_d		*dev;	/* ptr to device */
+	struct device_d		dev;	/* ptr to device */
 	int			nr;	/* bus number */
 	int (*master_xfer)(struct i2c_adapter *adap, struct i2c_msg *msgs, int num);
 	struct list_head	list;
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Fri Nov  2 05:36:52 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri,  2 Nov 2012 10:36:52 +0100
Subject: [PATCH 4/4] i2c: add versatile support
In-Reply-To: <1351849012-26236-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121102092718.GO29599@game.jcrosoft.org>
 <1351849012-26236-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1351849012-26236-4-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/i2c/busses/Kconfig         |    8 +++
 drivers/i2c/busses/Makefile        |    1 +
 drivers/i2c/busses/i2c-versatile.c |  112 ++++++++++++++++++++++++++++++++++++
 3 files changed, 121 insertions(+)
 create mode 100644 drivers/i2c/busses/i2c-versatile.c

diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 17e33cb..68d9b46 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -20,4 +20,12 @@ config I2C_OMAP
 	bool "OMAP I2C Master driver"
 	depends on ARCH_OMAP
 
+config I2C_VERSATILE
+	tristate "ARM Versatile/Realview I2C bus support"
+	depends on ARCH_VERSATILE
+	select I2C_ALGOBIT
+	help
+	  Say yes if you want to support the I2C serial bus on ARMs Versatile
+	  range of platforms.
+
 endmenu
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 18c7c46..a30f9b8 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -1,3 +1,4 @@
 obj-$(CONFIG_I2C_GPIO)		+= i2c-gpio.o
 obj-$(CONFIG_I2C_IMX) += i2c-imx.o
 obj-$(CONFIG_I2C_OMAP) += i2c-omap.o
+obj-$(CONFIG_I2C_VERSATILE)	+= i2c-versatile.o
diff --git a/drivers/i2c/busses/i2c-versatile.c b/drivers/i2c/busses/i2c-versatile.c
new file mode 100644
index 0000000..7c99322
--- /dev/null
+++ b/drivers/i2c/busses/i2c-versatile.c
@@ -0,0 +1,112 @@
+/*
+ *  i2c-versatile.c
+ *
+ *  Copyright (C) 2006 ARM Ltd.
+ *  written by Russell King, Deep Blue Solutions Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include <common.h>
+#include <driver.h>
+#include <i2c/i2c.h>
+#include <i2c/i2c-algo-bit.h>
+#include <init.h>
+#include <malloc.h>
+#include <io.h>
+
+#define I2C_CONTROL	0x00
+#define I2C_CONTROLS	0x00
+#define I2C_CONTROLC	0x04
+#define SCL		(1 << 0)
+#define SDA		(1 << 1)
+
+struct i2c_versatile {
+	struct i2c_adapter	 adap;
+	struct i2c_algo_bit_data algo;
+	void __iomem		 *base;
+};
+
+static void i2c_versatile_setsda(void *data, int state)
+{
+	struct i2c_versatile *i2c = data;
+
+	writel(SDA, i2c->base + (state ? I2C_CONTROLS : I2C_CONTROLC));
+}
+
+static void i2c_versatile_setscl(void *data, int state)
+{
+	struct i2c_versatile *i2c = data;
+
+	writel(SCL, i2c->base + (state ? I2C_CONTROLS : I2C_CONTROLC));
+}
+
+static int i2c_versatile_getsda(void *data)
+{
+	struct i2c_versatile *i2c = data;
+	return !!(readl(i2c->base + I2C_CONTROL) & SDA);
+}
+
+static int i2c_versatile_getscl(void *data)
+{
+	struct i2c_versatile *i2c = data;
+	return !!(readl(i2c->base + I2C_CONTROL) & SCL);
+}
+
+static struct i2c_algo_bit_data i2c_versatile_algo = {
+	.setsda	= i2c_versatile_setsda,
+	.setscl = i2c_versatile_setscl,
+	.getsda	= i2c_versatile_getsda,
+	.getscl = i2c_versatile_getscl,
+	.udelay	= 30,
+	.timeout_ms = 100,
+};
+
+static int i2c_versatile_probe(struct device_d *dev)
+{
+	struct i2c_versatile *i2c;
+	int ret;
+
+	i2c = kzalloc(sizeof(struct i2c_versatile), GFP_KERNEL);
+	if (!i2c) {
+		ret = -ENOMEM;
+		goto err_release;
+	}
+
+	i2c->base = dev_request_mem_region(dev, 0);
+	if (!i2c->base) {
+		ret = -ENOMEM;
+		goto err_free;
+	}
+
+	writel(SCL | SDA, i2c->base + I2C_CONTROLS);
+
+	i2c->adap.algo_data = &i2c->algo;
+	i2c->adap.dev.parent = dev;
+	i2c->algo = i2c_versatile_algo;
+	i2c->algo.data = i2c;
+
+	i2c->adap.nr = dev->id;
+	ret = i2c_bit_add_numbered_bus(&i2c->adap);
+	if (ret >= 0) {
+		return 0;
+	}
+
+ err_free:
+	kfree(i2c);
+ err_release:
+	return ret;
+}
+
+static struct driver_d i2c_versatile_driver = {
+	.name	= "versatile-i2c",
+	.probe	= i2c_versatile_probe,
+};
+
+static int __init i2c_versatile_init(void)
+{
+	return platform_driver_register(&i2c_versatile_driver);
+}
+
+device_initcall(i2c_versatile_init);
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Fri Nov  2 05:36:51 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri,  2 Nov 2012 10:36:51 +0100
Subject: [PATCH 3/4] i2c: add i2c-gpio support
In-Reply-To: <1351849012-26236-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121102092718.GO29599@game.jcrosoft.org>
 <1351849012-26236-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1351849012-26236-3-git-send-email-plagnioj@jcrosoft.com>

Based on linux 3.7-rc2

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/i2c/busses/Kconfig    |    8 ++
 drivers/i2c/busses/Makefile   |    1 +
 drivers/i2c/busses/i2c-gpio.c |  177 +++++++++++++++++++++++++++++++++++++++++
 include/i2c/i2c-gpio.h        |   38 +++++++++
 4 files changed, 224 insertions(+)
 create mode 100644 drivers/i2c/busses/i2c-gpio.c
 create mode 100644 include/i2c/i2c-gpio.h

diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 3f998ea..17e33cb 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -4,6 +4,14 @@
 
 menu "I2C Hardware Bus support"
 
+config I2C_GPIO
+	tristate "GPIO-based bitbanging I2C"
+	depends on GENERIC_GPIO
+	select I2C_ALGOBIT
+	help
+	  This is a very simple bitbanging I2C driver utilizing the
+	  arch-neutral GPIO API to control the SCL and SDA lines.
+
 config I2C_IMX
 	bool "MPC85xx/i.MX I2C Master driver"
 	depends on (ARCH_IMX && !ARCH_IMX1) || ARCH_MPC85XX
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index e4c5125..18c7c46 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -1,2 +1,3 @@
+obj-$(CONFIG_I2C_GPIO)		+= i2c-gpio.o
 obj-$(CONFIG_I2C_IMX) += i2c-imx.o
 obj-$(CONFIG_I2C_OMAP) += i2c-omap.o
diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c
new file mode 100644
index 0000000..98ce2d5
--- /dev/null
+++ b/drivers/i2c/busses/i2c-gpio.c
@@ -0,0 +1,177 @@
+/*
+ * Bitbanging I2C bus driver using the GPIO API
+ *
+ * Copyright (C) 2007 Atmel Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <common.h>
+#include <driver.h>
+#include <i2c/i2c.h>
+#include <i2c/i2c-algo-bit.h>
+#include <i2c/i2c-gpio.h>
+#include <init.h>
+#include <gpio.h>
+
+struct i2c_gpio_private_data {
+	struct i2c_adapter adap;
+	struct i2c_algo_bit_data bit_data;
+	struct i2c_gpio_platform_data pdata;
+};
+
+/* Toggle SDA by changing the direction of the pin */
+static void i2c_gpio_setsda_dir(void *data, int state)
+{
+	struct i2c_gpio_platform_data *pdata = data;
+
+	if (state)
+		gpio_direction_input(pdata->sda_pin);
+	else
+		gpio_direction_output(pdata->sda_pin, 0);
+}
+
+/*
+ * Toggle SDA by changing the output value of the pin. This is only
+ * valid for pins configured as open drain (i.e. setting the value
+ * high effectively turns off the output driver.)
+ */
+static void i2c_gpio_setsda_val(void *data, int state)
+{
+	struct i2c_gpio_platform_data *pdata = data;
+
+	gpio_set_value(pdata->sda_pin, state);
+}
+
+/* Toggle SCL by changing the direction of the pin. */
+static void i2c_gpio_setscl_dir(void *data, int state)
+{
+	struct i2c_gpio_platform_data *pdata = data;
+
+	if (state)
+		gpio_direction_input(pdata->scl_pin);
+	else
+		gpio_direction_output(pdata->scl_pin, 0);
+}
+
+/*
+ * Toggle SCL by changing the output value of the pin. This is used
+ * for pins that are configured as open drain and for output-only
+ * pins. The latter case will break the i2c protocol, but it will
+ * often work in practice.
+ */
+static void i2c_gpio_setscl_val(void *data, int state)
+{
+	struct i2c_gpio_platform_data *pdata = data;
+
+	gpio_set_value(pdata->scl_pin, state);
+}
+
+static int i2c_gpio_getsda(void *data)
+{
+	struct i2c_gpio_platform_data *pdata = data;
+
+	return gpio_get_value(pdata->sda_pin);
+}
+
+static int i2c_gpio_getscl(void *data)
+{
+	struct i2c_gpio_platform_data *pdata = data;
+
+	return gpio_get_value(pdata->scl_pin);
+}
+
+static int i2c_gpio_probe(struct device_d *dev)
+{
+	struct i2c_gpio_private_data *priv;
+	struct i2c_gpio_platform_data *pdata;
+	struct i2c_algo_bit_data *bit_data;
+	struct i2c_adapter *adap;
+	int ret;
+
+	priv = xzalloc(sizeof(*priv));
+
+	adap = &priv->adap;
+	bit_data = &priv->bit_data;
+	pdata = &priv->pdata;
+
+	if (!dev->platform_data)
+		return -ENXIO;
+	memcpy(pdata, dev->platform_data, sizeof(*pdata));
+
+	ret = gpio_request(pdata->sda_pin, "sda");
+	if (ret)
+		goto err_request_sda;
+	ret = gpio_request(pdata->scl_pin, "scl");
+	if (ret)
+		goto err_request_scl;
+
+	if (pdata->sda_is_open_drain) {
+		gpio_direction_output(pdata->sda_pin, 1);
+		bit_data->setsda = i2c_gpio_setsda_val;
+	} else {
+		gpio_direction_input(pdata->sda_pin);
+		bit_data->setsda = i2c_gpio_setsda_dir;
+	}
+
+	if (pdata->scl_is_open_drain || pdata->scl_is_output_only) {
+		gpio_direction_output(pdata->scl_pin, 1);
+		bit_data->setscl = i2c_gpio_setscl_val;
+	} else {
+		gpio_direction_input(pdata->scl_pin);
+		bit_data->setscl = i2c_gpio_setscl_dir;
+	}
+
+	if (!pdata->scl_is_output_only)
+		bit_data->getscl = i2c_gpio_getscl;
+	bit_data->getsda = i2c_gpio_getsda;
+
+	if (pdata->udelay)
+		bit_data->udelay = pdata->udelay;
+	else if (pdata->scl_is_output_only)
+		bit_data->udelay = 50;			/* 10 kHz */
+	else
+		bit_data->udelay = 5;			/* 100 kHz */
+
+	if (pdata->timeout_ms)
+		bit_data->timeout_ms = pdata->timeout_ms;
+	else
+		bit_data->timeout_ms = 100;		/* 100 ms */
+
+	bit_data->data = pdata;
+
+	adap->algo_data = bit_data;
+	adap->dev.parent = dev;
+
+	adap->nr = dev->id;
+	ret = i2c_bit_add_numbered_bus(adap);
+	if (ret)
+		goto err_add_bus;
+
+	dev_info(dev, "using pins %u (SDA) and %u (SCL%s)\n",
+		 pdata->sda_pin, pdata->scl_pin,
+		 pdata->scl_is_output_only
+		 ? ", no clock stretching" : "");
+
+	return 0;
+
+err_add_bus:
+	gpio_free(pdata->scl_pin);
+err_request_scl:
+	gpio_free(pdata->sda_pin);
+err_request_sda:
+	return ret;
+}
+
+static struct driver_d i2c_gpio_driver = {
+	.name	= "i2c-gpio",
+	.probe	= i2c_gpio_probe,
+};
+
+static int __init i2c_gpio_init(void)
+{
+	return platform_driver_register(&i2c_gpio_driver);
+}
+device_initcall(i2c_gpio_init);
diff --git a/include/i2c/i2c-gpio.h b/include/i2c/i2c-gpio.h
new file mode 100644
index 0000000..55feb82
--- /dev/null
+++ b/include/i2c/i2c-gpio.h
@@ -0,0 +1,38 @@
+/*
+ * i2c-gpio interface to platform code
+ *
+ * Copyright (C) 2007 Atmel Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#ifndef _LINUX_I2C_GPIO_H
+#define _LINUX_I2C_GPIO_H
+
+/**
+ * struct i2c_gpio_platform_data - Platform-dependent data for i2c-gpio
+ * @sda_pin: GPIO pin ID to use for SDA
+ * @scl_pin: GPIO pin ID to use for SCL
+ * @udelay: signal toggle delay. SCL frequency is (500 / udelay) kHz
+ * @timeout_ms: clock stretching timeout in ms. If the slave keeps
+ *	SCL low for longer than this, the transfer will time out.
+ * @sda_is_open_drain: SDA is configured as open drain, i.e. the pin
+ *	isn't actively driven high when setting the output value high.
+ *	gpio_get_value() must return the actual pin state even if the
+ *	pin is configured as an output.
+ * @scl_is_open_drain: SCL is set up as open drain. Same requirements
+ *	as for sda_is_open_drain apply.
+ * @scl_is_output_only: SCL output drivers cannot be turned off.
+ */
+struct i2c_gpio_platform_data {
+	unsigned int	sda_pin;
+	unsigned int	scl_pin;
+	int		udelay;
+	int		timeout_ms;
+	unsigned int	sda_is_open_drain:1;
+	unsigned int	scl_is_open_drain:1;
+	unsigned int	scl_is_output_only:1;
+};
+
+#endif /* _LINUX_I2C_GPIO_H */
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Fri Nov  2 05:36:50 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri,  2 Nov 2012 10:36:50 +0100
Subject: =?UTF-8?q?=5BPATCH=202/4=5D=20i2c=3A=20add=20i2c=20algo=20bit=20support?=
In-Reply-To: <1351849012-26236-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121102092718.GO29599@game.jcrosoft.org>
 <1351849012-26236-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1351849012-26236-2-git-send-email-plagnioj@jcrosoft.com>

This is needed for i2c-gpio support

Based on linux 3.7-rc2

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/i2c/Kconfig              |    1 +
 drivers/i2c/Makefile             |    2 +-
 drivers/i2c/algos/Kconfig        |    6 +
 drivers/i2c/algos/Makefile       |    5 +
 drivers/i2c/algos/i2c-algo-bit.c |  585 ++++++++++++++++++++++++++++++++++++++
 include/i2c/i2c-algo-bit.h       |   55 ++++
 include/i2c/i2c.h                |    2 +
 7 files changed, 655 insertions(+), 1 deletion(-)
 create mode 100644 drivers/i2c/algos/Kconfig
 create mode 100644 drivers/i2c/algos/Makefile
 create mode 100644 drivers/i2c/algos/i2c-algo-bit.c
 create mode 100644 include/i2c/i2c-algo-bit.h

diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig
index c2af818..038e2ee 100644
--- a/drivers/i2c/Kconfig
+++ b/drivers/i2c/Kconfig
@@ -3,6 +3,7 @@ menuconfig I2C
 
 if I2C
 
+source drivers/i2c/algos/Kconfig
 source drivers/i2c/busses/Kconfig
 
 endif
diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
index 42e22c0..5ce0324 100644
--- a/drivers/i2c/Makefile
+++ b/drivers/i2c/Makefile
@@ -1 +1 @@
-obj-$(CONFIG_I2C) += i2c.o busses/
+obj-$(CONFIG_I2C) += i2c.o busses/ algos/
diff --git a/drivers/i2c/algos/Kconfig b/drivers/i2c/algos/Kconfig
new file mode 100644
index 0000000..c74b148
--- /dev/null
+++ b/drivers/i2c/algos/Kconfig
@@ -0,0 +1,6 @@
+#
+# I2C algorithm drivers configuration
+#
+
+config I2C_ALGOBIT
+	bool
diff --git a/drivers/i2c/algos/Makefile b/drivers/i2c/algos/Makefile
new file mode 100644
index 0000000..e0a0399
--- /dev/null
+++ b/drivers/i2c/algos/Makefile
@@ -0,0 +1,5 @@
+#
+# Makefile for the i2c algorithms
+#
+
+obj-$(CONFIG_I2C_ALGOBIT)	+= i2c-algo-bit.o
diff --git a/drivers/i2c/algos/i2c-algo-bit.c b/drivers/i2c/algos/i2c-algo-bit.c
new file mode 100644
index 0000000..37af27c
--- /dev/null
+++ b/drivers/i2c/algos/i2c-algo-bit.c
@@ -0,0 +1,585 @@
+/* -------------------------------------------------------------------------
+ * i2c-algo-bit.c i2c driver algorithms for bit-shift adapters
+ * -------------------------------------------------------------------------
+ *   Copyright (C) 1995-2000 Simon G. Vogl
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+    MA 02110-1301 USA.
+ * ------------------------------------------------------------------------- */
+
+/* With some changes from Frodo Looijaard <frodol at dds.nl>, Ky?sti M?lkki
+   <kmalkki at cc.hut.fi> and Jean Delvare <khali at linux-fr.org> */
+
+#include <common.h>
+#include <init.h>
+#include <errno.h>
+#include <clock.h>
+#include <i2c/i2c.h>
+#include <i2c/i2c-algo-bit.h>
+
+/* ----- global defines ----------------------------------------------- */
+
+#ifdef DEBUG
+#define bit_dbg(level, dev, format, args...) \
+	do { \
+		if (i2c_debug >= level) \
+			dev_dbg(dev, format, ##args); \
+	} while (0)
+#else
+#define bit_dbg(level, dev, format, args...) \
+	do {} while (0)
+#endif /* DEBUG */
+
+/* ----- global variables ---------------------------------------------	*/
+
+static int bit_test;	/* see if the line-setting functions work	*/
+
+#ifdef DEBUG
+static int i2c_debug = 1;
+#endif
+
+/* --- setting states on the bus with the right timing: ---------------	*/
+
+#define setsda(adap, val)	adap->setsda(adap->data, val)
+#define setscl(adap, val)	adap->setscl(adap->data, val)
+#define getsda(adap)		adap->getsda(adap->data)
+#define getscl(adap)		adap->getscl(adap->data)
+
+static inline void sdalo(struct i2c_algo_bit_data *adap)
+{
+	setsda(adap, 0);
+	udelay((adap->udelay + 1) / 2);
+}
+
+static inline void sdahi(struct i2c_algo_bit_data *adap)
+{
+	setsda(adap, 1);
+	udelay((adap->udelay + 1) / 2);
+}
+
+static inline void scllo(struct i2c_algo_bit_data *adap)
+{
+	setscl(adap, 0);
+	udelay(adap->udelay / 2);
+}
+
+/*
+ * Raise scl line, and do checking for delays. This is necessary for slower
+ * devices.
+ */
+static int sclhi(struct i2c_algo_bit_data *adap)
+{
+	uint64_t start;
+
+	setscl(adap, 1);
+
+	/* Not all adapters have scl sense line... */
+	if (!adap->getscl)
+		goto done;
+
+	start = get_time_ns();
+	while (!getscl(adap)) {
+		/* This hw knows how to read the clock line, so we wait
+		 * until it actually gets high.  This is safer as some
+		 * chips may hold it low ("clock stretching") while they
+		 * are processing data internally.
+		 */
+		if (is_timeout(start, adap->timeout_ms * MSECOND)) {
+			/* Test one last time, as we may have been preempted
+			 * between last check and timeout test.
+			 */
+			if (getscl(adap))
+				break;
+			return -ETIMEDOUT;
+		}
+	}
+#ifdef DEBUG
+	if (jiffies != start && i2c_debug >= 3)
+		pr_debug("i2c-algo-bit: needed %ld jiffies for SCL to go "
+			 "high\n", jiffies - start);
+#endif
+
+done:
+	udelay(adap->udelay);
+	return 0;
+}
+
+
+/* --- other auxiliary functions --------------------------------------	*/
+static void i2c_start(struct i2c_algo_bit_data *adap)
+{
+	/* assert: scl, sda are high */
+	setsda(adap, 0);
+	udelay(adap->udelay);
+	scllo(adap);
+}
+
+static void i2c_repstart(struct i2c_algo_bit_data *adap)
+{
+	/* assert: scl is low */
+	sdahi(adap);
+	sclhi(adap);
+	setsda(adap, 0);
+	udelay(adap->udelay);
+	scllo(adap);
+}
+
+
+static void i2c_stop(struct i2c_algo_bit_data *adap)
+{
+	/* assert: scl is low */
+	sdalo(adap);
+	sclhi(adap);
+	setsda(adap, 1);
+	udelay(adap->udelay);
+}
+
+
+
+/* send a byte without start cond., look for arbitration,
+   check ackn. from slave */
+/* returns:
+ * 1 if the device acknowledged
+ * 0 if the device did not ack
+ * -ETIMEDOUT if an error occurred (while raising the scl line)
+ */
+static int i2c_outb(struct i2c_adapter *i2c_adap, unsigned char c)
+{
+	int i;
+	int sb;
+	int ack;
+	struct i2c_algo_bit_data *adap = i2c_adap->algo_data;
+
+	/* assert: scl is low */
+	for (i = 7; i >= 0; i--) {
+		sb = (c >> i) & 1;
+		setsda(adap, sb);
+		udelay((adap->udelay + 1) / 2);
+		if (sclhi(adap) < 0) { /* timed out */
+			bit_dbg(1, &i2c_adap->dev, "i2c_outb: 0x%02x, "
+				"timeout at bit #%d\n", (int)c, i);
+			return -ETIMEDOUT;
+		}
+		/* FIXME do arbitration here:
+		 * if (sb && !getsda(adap)) -> ouch! Get out of here.
+		 *
+		 * Report a unique code, so higher level code can retry
+		 * the whole (combined) message and *NOT* issue STOP.
+		 */
+		scllo(adap);
+	}
+	sdahi(adap);
+	if (sclhi(adap) < 0) { /* timeout */
+		bit_dbg(1, &i2c_adap->dev, "i2c_outb: 0x%02x, "
+			"timeout at ack\n", (int)c);
+		return -ETIMEDOUT;
+	}
+
+	/* read ack: SDA should be pulled down by slave, or it may
+	 * NAK (usually to report problems with the data we wrote).
+	 */
+	ack = !getsda(adap);    /* ack: sda is pulled low -> success */
+	bit_dbg(2, &i2c_adap->dev, "i2c_outb: 0x%02x %s\n", (int)c,
+		ack ? "A" : "NA");
+
+	scllo(adap);
+	return ack;
+	/* assert: scl is low (sda undef) */
+}
+
+
+static int i2c_inb(struct i2c_adapter *i2c_adap)
+{
+	/* read byte via i2c port, without start/stop sequence	*/
+	/* acknowledge is sent in i2c_read.			*/
+	int i;
+	unsigned char indata = 0;
+	struct i2c_algo_bit_data *adap = i2c_adap->algo_data;
+
+	/* assert: scl is low */
+	sdahi(adap);
+	for (i = 0; i < 8; i++) {
+		if (sclhi(adap) < 0) { /* timeout */
+			bit_dbg(1, &i2c_adap->dev, "i2c_inb: timeout at bit "
+				"#%d\n", 7 - i);
+			return -ETIMEDOUT;
+		}
+		indata *= 2;
+		if (getsda(adap))
+			indata |= 0x01;
+		setscl(adap, 0);
+		udelay(i == 7 ? adap->udelay / 2 : adap->udelay);
+	}
+	/* assert: scl is low */
+	return indata;
+}
+
+/*
+ * Sanity check for the adapter hardware - check the reaction of
+ * the bus lines only if it seems to be idle.
+ */
+static int test_bus(struct i2c_adapter *i2c_adap)
+{
+	struct i2c_algo_bit_data *adap = i2c_adap->algo_data;
+	struct device_d *dev = &i2c_adap->dev;
+	int scl, sda, ret;
+
+	if (adap->pre_xfer) {
+		ret = adap->pre_xfer(i2c_adap);
+		if (ret < 0)
+			return -ENODEV;
+	}
+
+	if (adap->getscl == NULL)
+		dev_info(dev, "Testing SDA only, SCL is not readable\n");
+
+	sda = getsda(adap);
+	scl = (adap->getscl == NULL) ? 1 : getscl(adap);
+	if (!scl || !sda) {
+		dev_warn(dev, "bus seems to be busy (scl=%d, sda=%d)\n", scl, sda);
+		goto bailout;
+	}
+
+	sdalo(adap);
+	sda = getsda(adap);
+	scl = (adap->getscl == NULL) ? 1 : getscl(adap);
+	if (sda) {
+		dev_warn(dev, "SDA stuck high!\n");
+		goto bailout;
+	}
+	if (!scl) {
+		dev_warn(dev, "SCL unexpected low while pulling SDA low!\n");
+		goto bailout;
+	}
+
+	sdahi(adap);
+	sda = getsda(adap);
+	scl = (adap->getscl == NULL) ? 1 : getscl(adap);
+	if (!sda) {
+		dev_warn(dev, "SDA stuck low!\n");
+		goto bailout;
+	}
+	if (!scl) {
+		dev_warn(dev, "SCL unexpected low while pulling SDA high!\n");
+		goto bailout;
+	}
+
+	scllo(adap);
+	sda = getsda(adap);
+	scl = (adap->getscl == NULL) ? 0 : getscl(adap);
+	if (scl) {
+		dev_warn(dev, "SCL stuck high!\n");
+		goto bailout;
+	}
+	if (!sda) {
+		dev_warn(dev, "SDA unexpected low while pulling SCL low!\n");
+		goto bailout;
+	}
+
+	sclhi(adap);
+	sda = getsda(adap);
+	scl = (adap->getscl == NULL) ? 1 : getscl(adap);
+	if (!scl) {
+		dev_warn(dev, "SCL stuck low!\n");
+		goto bailout;
+	}
+	if (!sda) {
+		dev_warn(dev, "SDA unexpected low while pulling SCL high!\n");
+		goto bailout;
+	}
+
+	if (adap->post_xfer)
+		adap->post_xfer(i2c_adap);
+
+	dev_info(dev, "Test OK\n");
+	return 0;
+bailout:
+	sdahi(adap);
+	sclhi(adap);
+
+	if (adap->post_xfer)
+		adap->post_xfer(i2c_adap);
+
+	return -ENODEV;
+}
+
+/* ----- Utility functions
+ */
+
+/* try_address tries to contact a chip for a number of
+ * times before it gives up.
+ * return values:
+ * 1 chip answered
+ * 0 chip did not answer
+ * -x transmission error
+ */
+static int try_address(struct i2c_adapter *i2c_adap,
+		       unsigned char addr, int retries)
+{
+	struct i2c_algo_bit_data *adap = i2c_adap->algo_data;
+	int i, ret = 0;
+
+	for (i = 0; i <= retries; i++) {
+		ret = i2c_outb(i2c_adap, addr);
+		if (ret == 1 || i == retries)
+			break;
+		bit_dbg(3, &i2c_adap->dev, "emitting stop condition\n");
+		i2c_stop(adap);
+		udelay(adap->udelay);
+		bit_dbg(3, &i2c_adap->dev, "emitting start condition\n");
+		i2c_start(adap);
+	}
+	if (i && ret)
+		bit_dbg(1, &i2c_adap->dev, "Used %d tries to %s client at "
+			"0x%02x: %s\n", i + 1,
+			addr & 1 ? "read from" : "write to", addr >> 1,
+			ret == 1 ? "success" : "failed, timeout?");
+	return ret;
+}
+
+static int sendbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg)
+{
+	const unsigned char *temp = msg->buf;
+	int count = msg->len;
+	unsigned short nak_ok = msg->flags & I2C_M_IGNORE_NAK;
+	int retval;
+	int wrcount = 0;
+
+	while (count > 0) {
+		retval = i2c_outb(i2c_adap, *temp);
+
+		/* OK/ACK; or ignored NAK */
+		if ((retval > 0) || (nak_ok && (retval == 0))) {
+			count--;
+			temp++;
+			wrcount++;
+
+		/* A slave NAKing the master means the slave didn't like
+		 * something about the data it saw.  For example, maybe
+		 * the SMBus PEC was wrong.
+		 */
+		} else if (retval == 0) {
+			dev_err(&i2c_adap->dev, "sendbytes: NAK bailout.\n");
+			return -EIO;
+
+		/* Timeout; or (someday) lost arbitration
+		 *
+		 * FIXME Lost ARB implies retrying the transaction from
+		 * the first message, after the "winning" master issues
+		 * its STOP.  As a rule, upper layer code has no reason
+		 * to know or care about this ... it is *NOT* an error.
+		 */
+		} else {
+			dev_err(&i2c_adap->dev, "sendbytes: error %d\n",
+					retval);
+			return retval;
+		}
+	}
+	return wrcount;
+}
+
+static int readbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg)
+{
+	int inval;
+	int rdcount = 0;	/* counts bytes read */
+	unsigned char *temp = msg->buf;
+	int count = msg->len;
+
+	while (count > 0) {
+		inval = i2c_inb(i2c_adap);
+		if (inval >= 0) {
+			*temp = inval;
+			rdcount++;
+		} else {   /* read timed out */
+			break;
+		}
+
+		temp++;
+		count--;
+
+		bit_dbg(2, &i2c_adap->dev, "readbytes: 0x%02x %s\n",
+			inval,
+			(flags & I2C_M_NO_RD_ACK)
+				? "(no ack/nak)"
+				: (count ? "A" : "NA"));
+	}
+	return rdcount;
+}
+
+/* doAddress initiates the transfer by generating the start condition (in
+ * try_address) and transmits the address in the necessary format to handle
+ * reads, writes as well as 10bit-addresses.
+ * returns:
+ *  0 everything went okay, the chip ack'ed, or IGNORE_NAK flag was set
+ * -x an error occurred (like: -ENXIO if the device did not answer, or
+ *	-ETIMEDOUT, for example if the lines are stuck...)
+ */
+static int bit_doAddress(struct i2c_adapter *i2c_adap, struct i2c_msg *msg)
+{
+	unsigned short flags = msg->flags;
+	unsigned short nak_ok = msg->flags & I2C_M_IGNORE_NAK;
+	struct i2c_algo_bit_data *adap = i2c_adap->algo_data;
+
+	unsigned char addr;
+	int ret, retries;
+
+	retries = nak_ok ? 0 : i2c_adap->retries;
+
+	if (flags & I2C_M_TEN) {
+		/* a ten bit address */
+		addr = 0xf0 | ((msg->addr >> 7) & 0x06);
+		bit_dbg(2, &i2c_adap->dev, "addr0: %d\n", addr);
+		/* try extended address code...*/
+		ret = try_address(i2c_adap, addr, retries);
+		if ((ret != 1) && !nak_ok)  {
+			dev_err(&i2c_adap->dev,
+				"died at extended address code\n");
+			return -ENXIO;
+		}
+		/* the remaining 8 bit address */
+		ret = i2c_outb(i2c_adap, msg->addr & 0xff);
+		if ((ret != 1) && !nak_ok) {
+			/* the chip did not ack / xmission error occurred */
+			dev_err(&i2c_adap->dev, "died at 2nd address code\n");
+			return -ENXIO;
+		}
+		if (flags & I2C_M_RD) {
+			bit_dbg(3, &i2c_adap->dev, "emitting repeated "
+				"start condition\n");
+			i2c_repstart(adap);
+			/* okay, now switch into reading mode */
+			addr |= 0x01;
+			ret = try_address(i2c_adap, addr, retries);
+			if ((ret != 1) && !nak_ok) {
+				dev_err(&i2c_adap->dev,
+					"died at repeated address code\n");
+				return -EIO;
+			}
+		}
+	} else {		/* normal 7bit address	*/
+		addr = msg->addr << 1;
+		if (flags & I2C_M_RD)
+			addr |= 1;
+		ret = try_address(i2c_adap, addr, retries);
+		if ((ret != 1) && !nak_ok)
+			return -ENXIO;
+	}
+
+	return 0;
+}
+
+static int bit_xfer(struct i2c_adapter *i2c_adap,
+		    struct i2c_msg msgs[], int num)
+{
+	struct i2c_msg *pmsg;
+	struct i2c_algo_bit_data *adap = i2c_adap->algo_data;
+	int i, ret;
+	unsigned short nak_ok;
+
+	if (adap->pre_xfer) {
+		ret = adap->pre_xfer(i2c_adap);
+		if (ret < 0)
+			return ret;
+	}
+
+	bit_dbg(3, &i2c_adap->dev, "emitting start condition\n");
+	i2c_start(adap);
+	for (i = 0; i < num; i++) {
+		pmsg = &msgs[i];
+		nak_ok = pmsg->flags & I2C_M_IGNORE_NAK;
+		if (i) {
+			bit_dbg(3, &i2c_adap->dev, "emitting "
+				"repeated start condition\n");
+			i2c_repstart(adap);
+		}
+		ret = bit_doAddress(i2c_adap, pmsg);
+		if ((ret != 0) && !nak_ok) {
+			bit_dbg(1, &i2c_adap->dev, "NAK from "
+				"device addr 0x%02x msg #%d\n",
+				msgs[i].addr, i);
+			goto bailout;
+		}
+		if (pmsg->flags & I2C_M_RD) {
+			/* read bytes into buffer*/
+			ret = readbytes(i2c_adap, pmsg);
+			if (ret >= 1)
+				bit_dbg(2, &i2c_adap->dev, "read %d byte%s\n",
+					ret, ret == 1 ? "" : "s");
+			if (ret < pmsg->len) {
+				if (ret >= 0)
+					ret = -EIO;
+				goto bailout;
+			}
+		} else {
+			/* write bytes from buffer */
+			ret = sendbytes(i2c_adap, pmsg);
+			if (ret >= 1)
+				bit_dbg(2, &i2c_adap->dev, "wrote %d byte%s\n",
+					ret, ret == 1 ? "" : "s");
+			if (ret < pmsg->len) {
+				if (ret >= 0)
+					ret = -EIO;
+				goto bailout;
+			}
+		}
+	}
+	ret = i;
+
+bailout:
+	bit_dbg(3, &i2c_adap->dev, "emitting stop condition\n");
+	i2c_stop(adap);
+
+	if (adap->post_xfer)
+		adap->post_xfer(i2c_adap);
+	return ret;
+}
+
+/*
+ * registering functions to load algorithms at runtime
+ */
+static int __i2c_bit_add_bus(struct i2c_adapter *adap,
+			     int (*add_adapter)(struct i2c_adapter *))
+{
+	struct i2c_algo_bit_data *bit_adap = adap->algo_data;
+	int ret;
+
+	if (bit_test) {
+		ret = test_bus(adap);
+		if (bit_test >= 2 && ret < 0)
+			return -ENODEV;
+	}
+
+	/* register new adapter to i2c module... */
+	//adap->algo = &i2c_bit_algo;
+	adap->retries = 3;
+	adap->master_xfer = bit_xfer;
+
+	ret = add_adapter(adap);
+	if (ret < 0)
+		return ret;
+
+	/* Complain if SCL can't be read */
+	if (bit_adap->getscl == NULL) {
+		dev_warn(&adap->dev, "Not I2C compliant: can't read SCL\n");
+		dev_warn(&adap->dev, "Bus may be unreliable\n");
+	}
+	return 0;
+}
+
+int i2c_bit_add_numbered_bus(struct i2c_adapter *adap)
+{
+	return __i2c_bit_add_bus(adap, i2c_add_numbered_adapter);
+}
+EXPORT_SYMBOL(i2c_bit_add_numbered_bus);
diff --git a/include/i2c/i2c-algo-bit.h b/include/i2c/i2c-algo-bit.h
new file mode 100644
index 0000000..1b72219
--- /dev/null
+++ b/include/i2c/i2c-algo-bit.h
@@ -0,0 +1,55 @@
+/* ------------------------------------------------------------------------- */
+/* i2c-algo-bit.h i2c driver algorithms for bit-shift adapters               */
+/* ------------------------------------------------------------------------- */
+/*   Copyright (C) 1995-99 Simon G. Vogl
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+    MA 02110-1301 USA.							     */
+/* ------------------------------------------------------------------------- */
+
+/* With some changes from Ky?sti M?lkki <kmalkki at cc.hut.fi> and even
+   Frodo Looijaard <frodol at dds.nl> */
+
+#ifndef _LINUX_I2C_ALGO_BIT_H
+#define _LINUX_I2C_ALGO_BIT_H
+
+/* --- Defines for bit-adapters ---------------------------------------	*/
+/*
+ * This struct contains the hw-dependent functions of bit-style adapters to
+ * manipulate the line states, and to init any hw-specific features. This is
+ * only used if you have more than one hw-type of adapter running.
+ */
+struct i2c_algo_bit_data {
+	void *data;		/* private data for lowlevel routines */
+	void (*setsda) (void *data, int state);
+	void (*setscl) (void *data, int state);
+	int  (*getsda) (void *data);
+	int  (*getscl) (void *data);
+	int  (*pre_xfer)  (struct i2c_adapter *);
+	void (*post_xfer) (struct i2c_adapter *);
+
+	/* local settings */
+	int udelay;		/* half clock cycle time in us,
+				   minimum 2 us for fast-mode I2C,
+				   minimum 5 us for standard-mode I2C and SMBus,
+				   maximum 50 us for SMBus */
+	int timeout_ms;		/* in ms */
+};
+
+int i2c_bit_add_bus(struct i2c_adapter *);
+int i2c_bit_add_numbered_bus(struct i2c_adapter *);
+extern const struct i2c_algorithm i2c_bit_algo;
+
+#endif /* _LINUX_I2C_ALGO_BIT_H */
diff --git a/include/i2c/i2c.h b/include/i2c/i2c.h
index 5021dd4..b059119 100644
--- a/include/i2c/i2c.h
+++ b/include/i2c/i2c.h
@@ -70,6 +70,8 @@ struct i2c_adapter {
 	int			nr;	/* bus number */
 	int (*master_xfer)(struct i2c_adapter *adap, struct i2c_msg *msgs, int num);
 	struct list_head	list;
+	int			retries;
+	void 			*algo_data;
 };
 
 
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Fri Nov  2 05:39:23 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri, 2 Nov 2012 10:39:23 +0100
Subject: [PATCH 0/4 v2] at91sam9x5ek: add spi and mci support
In-Reply-To: <20121101195008.GM29599@game.jcrosoft.org>
References: <20121101195008.GM29599@game.jcrosoft.org>
Message-ID: <20121102093923.GQ29599@game.jcrosoft.org>

On 20:50 Thu 01 Nov     , Jean-Christophe PLAGNIOL-VILLARD wrote:
> HI,
> 
> 	with this +1 patch serie the support of the at91sam9x5ek is mostly
> 	complete
> 
> 	This will add spi and mci0 support as spi0 and mci0 conflict
> 
> 	We are still missing framebuffer, usb host and device and hardware i2c support
> 	but this wil be added later
> 
> 	This patch serie depedsn on the at91sam9x5ek i2c and m25p80 patcheries
> 
> 	the correct version
> 
> 	this one work but brake the etherent as it mux the 4 cs as gpio and we
> 	use them on the eth0

v2 rebase agains i2c patch serie v2

The following changes since commit 244b46fb5c4663cba1df182670c212b8b4b7a4b0:

  m25p80: sync flash support with the kernel (2012-11-02 02:28:41 +0800)

are available in the git repository at:

  git://git.jcrosoft.org/barebox.git delivery/at91sam9x5ek_mci_spi

for you to fetch changes up to 9d74c51ca7d8d9a959aa989f83bbb3e1a9e3a129:

  at91sam9x5ek: add mci support (2012-11-02 02:28:42 +0800)

----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (4):
      at91sam9x5: add spi support
      at91sam9x5ek: add spi support
      at91sam9x5: add mci support
      at91sam9x5ek: add mci support

 arch/arm/boards/at91sam9x5ek/init.c     |   57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 arch/arm/configs/at91sam9x5ek_defconfig |   10 +++++++---
 arch/arm/mach-at91/at91sam9x5.c         |    4 ++++
 arch/arm/mach-at91/at91sam9x5_devices.c |  124 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 192 insertions(+), 3 deletions(-)

Best Regards,
J.


From s.hauer at pengutronix.de  Fri Nov  2 06:25:31 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Fri, 2 Nov 2012 11:25:31 +0100
Subject: [PATCH v4 1/3] ARM: Add initial support for CLPS711X architecture
In-Reply-To: <1351847836-8221-1-git-send-email-shc_work@mail.ru>
References: <1351847836-8221-1-git-send-email-shc_work@mail.ru>
Message-ID: <20121102102531.GJ1641@pengutronix.de>

On Fri, Nov 02, 2012 at 01:17:14PM +0400, Alexander Shiyan wrote:
> This patch adds new architecture (CLPS711X) into barebox.
> The core-logic functionality of the device is built around an ARM720T
> processor running at clock speeds up to 90 MHz.
> 
> Signed-off-by: Alexander Shiyan <shc_work at mail.ru>

Applied, thanks

Sascha

> ---
>  arch/arm/Kconfig                               |    6 +
>  arch/arm/Makefile                              |    1 +
>  arch/arm/mach-clps711x/Kconfig                 |    8 +
>  arch/arm/mach-clps711x/Makefile                |    1 +
>  arch/arm/mach-clps711x/clock.c                 |  113 ++++++++++
>  arch/arm/mach-clps711x/devices.c               |   37 +++
>  arch/arm/mach-clps711x/include/mach/clkdev.h   |    7 +
>  arch/arm/mach-clps711x/include/mach/clps711x.h |  284 ++++++++++++++++++++++++
>  arch/arm/mach-clps711x/include/mach/devices.h  |    6 +
>  arch/arm/mach-clps711x/reset.c                 |   21 ++
>  10 files changed, 484 insertions(+), 0 deletions(-)
>  create mode 100644 arch/arm/mach-clps711x/Kconfig
>  create mode 100644 arch/arm/mach-clps711x/Makefile
>  create mode 100644 arch/arm/mach-clps711x/clock.c
>  create mode 100644 arch/arm/mach-clps711x/devices.c
>  create mode 100644 arch/arm/mach-clps711x/include/mach/clkdev.h
>  create mode 100644 arch/arm/mach-clps711x/include/mach/clps711x.h
>  create mode 100644 arch/arm/mach-clps711x/include/mach/devices.h
>  create mode 100644 arch/arm/mach-clps711x/reset.c
> 
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index 57b3ca7..28071a5 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -31,6 +31,11 @@ config ARCH_AT91
>  	select HAS_DEBUG_LL
>  	select HAVE_MACH_ARM_HEAD
>  
> +config ARCH_CLPS711X
> +	bool "Cirrus Logic EP711x/EP721x/EP731x"
> +	select CLKDEV_LOOKUP
> +	select CPU_32v4T
> +
>  config ARCH_EP93XX
>  	bool "Cirrus Logic EP93xx"
>  	select CPU_ARM920T
> @@ -97,6 +102,7 @@ endchoice
>  
>  source arch/arm/cpu/Kconfig
>  source arch/arm/mach-at91/Kconfig
> +source arch/arm/mach-clps711x/Kconfig
>  source arch/arm/mach-ep93xx/Kconfig
>  source arch/arm/mach-imx/Kconfig
>  source arch/arm/mach-mxs/Kconfig
> diff --git a/arch/arm/Makefile b/arch/arm/Makefile
> index 855043a..da80e00 100644
> --- a/arch/arm/Makefile
> +++ b/arch/arm/Makefile
> @@ -52,6 +52,7 @@ AFLAGS   += -include asm/unified.h -msoft-float $(AFLAGS_THUMB2)
>  # Machine directory name.  This list is sorted alphanumerically
>  # by CONFIG_* macro name.
>  machine-$(CONFIG_ARCH_AT91)		:= at91
> +machine-$(CONFIG_ARCH_CLPS711X)		:= clps711x
>  machine-$(CONFIG_ARCH_EP93XX)		:= ep93xx
>  machine-$(CONFIG_ARCH_IMX)		:= imx
>  machine-$(CONFIG_ARCH_MXS)		:= mxs
> diff --git a/arch/arm/mach-clps711x/Kconfig b/arch/arm/mach-clps711x/Kconfig
> new file mode 100644
> index 0000000..56ca2ca
> --- /dev/null
> +++ b/arch/arm/mach-clps711x/Kconfig
> @@ -0,0 +1,8 @@
> +if ARCH_CLPS711X
> +
> +choice
> +	prompt "Cirrus Logic EP711x/EP721x/EP731x Board Type"
> +
> +endchoice
> +
> +endif
> diff --git a/arch/arm/mach-clps711x/Makefile b/arch/arm/mach-clps711x/Makefile
> new file mode 100644
> index 0000000..41012bc
> --- /dev/null
> +++ b/arch/arm/mach-clps711x/Makefile
> @@ -0,0 +1 @@
> +obj-y += clock.o devices.o reset.o
> diff --git a/arch/arm/mach-clps711x/clock.c b/arch/arm/mach-clps711x/clock.c
> new file mode 100644
> index 0000000..5cafba9
> --- /dev/null
> +++ b/arch/arm/mach-clps711x/clock.c
> @@ -0,0 +1,113 @@
> +/*
> + * Copyright (C) 2012 Alexander Shiyan <shc_work at mail.ru>
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation; either version 2 of
> + * the License, or (at your option) any later version.
> + */
> +
> +#include <common.h>
> +#include <init.h>
> +#include <clock.h>
> +#include <asm/io.h>
> +#include <linux/clkdev.h>
> +
> +#include <mach/clps711x.h>
> +
> +struct clk {
> +	unsigned long	rate;
> +};
> +
> +static struct clk uart_clk, bus_clk;
> +
> +uint64_t clocksource_read(void)
> +{
> +	return ~readw(TC2D);
> +}
> +
> +static struct clocksource cs = {
> +	.read	= clocksource_read,
> +	.mask	= CLOCKSOURCE_MASK(16),
> +};
> +
> +unsigned long clk_get_rate(struct clk *clk)
> +{
> +	return clk->rate;
> +}
> +EXPORT_SYMBOL(clk_get_rate);
> +
> +int clk_enable(struct clk *clk)
> +{
> +	/* Do nothing */
> +	return 0;
> +}
> +EXPORT_SYMBOL(clk_enable);
> +
> +void clk_disable(struct clk *clk)
> +{
> +	/* Do nothing */
> +}
> +EXPORT_SYMBOL(clk_disable);
> +
> +static int clocks_init(void)
> +{
> +	int osc, ext, pll, cpu, timer;
> +	u32 tmp;
> +
> +	osc = 3686400;
> +	ext = 13000000;
> +
> +	tmp = readl(PLLR) >> 24;
> +	if (tmp)
> +		pll = (osc * tmp) / 2;
> +	else
> +		pll = 73728000; /* Default value for old CPUs */
> +
> +	tmp = readl(SYSFLG2);
> +	if (tmp & SYSFLG2_CKMODE) {
> +		cpu = ext;
> +		bus_clk.rate = cpu;
> +	} else {
> +		cpu = pll;
> +		if (cpu >= 36864000)
> +			bus_clk.rate = cpu / 2;
> +		else
> +			bus_clk.rate = 36864000 / 2;
> +	}
> +
> +	uart_clk.rate = bus_clk.rate / 10;
> +
> +	if (tmp & SYSFLG2_CKMODE) {
> +		tmp = readw(SYSCON2);
> +		if (tmp & SYSCON2_OSTB)
> +			timer = ext / 26;
> +		else
> +			timer = 541440;
> +	} else
> +		timer = cpu / 144;
> +
> +	tmp = readl(SYSCON1);
> +	tmp &= ~SYSCON1_TC2M;	/* Free running mode */
> +	tmp |= SYSCON1_TC2S;	/* High frequency source */
> +	writel(tmp, SYSCON1);
> +
> +	clocks_calc_mult_shift(&cs.mult, &cs.shift, timer, NSEC_PER_SEC, 10);
> +
> +	return init_clock(&cs);
> +}
> +core_initcall(clocks_init);
> +
> +static struct clk_lookup clocks_lookups[] = {
> +	CLKDEV_CON_ID("bus", &bus_clk),
> +	CLKDEV_DEV_ID("clps711x_serial0", &uart_clk),
> +	CLKDEV_DEV_ID("clps711x_serial1", &uart_clk),
> +};
> +
> +static int clkdev_init(void)
> +{
> +	clkdev_add_table(clocks_lookups, ARRAY_SIZE(clocks_lookups));
> +
> +	return 0;
> +}
> +postcore_initcall(clkdev_init);
> diff --git a/arch/arm/mach-clps711x/devices.c b/arch/arm/mach-clps711x/devices.c
> new file mode 100644
> index 0000000..c5fcbf2
> --- /dev/null
> +++ b/arch/arm/mach-clps711x/devices.c
> @@ -0,0 +1,37 @@
> +/*
> + * Copyright (C) 2012 Alexander Shiyan <shc_work at mail.ru>
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation; either version 2 of
> + * the License, or (at your option) any later version.
> + */
> +
> +#include <common.h>
> +#include <init.h>
> +
> +#include <asm/io.h>
> +
> +#include <mach/clps711x.h>
> +
> +inline void _clps711x_setup_memcfg(int bank, u32 addr, u32 val)
> +{
> +	u32 tmp = readl(addr);
> +
> +	tmp &= ~(0xff << (bank * 8));
> +	tmp |= val << (bank * 8);
> +
> +	writel(tmp, addr);
> +}
> +
> +void clps711x_setup_memcfg(int bank, u32 val)
> +{
> +	switch (bank) {
> +	case 0 ... 3:
> +		_clps711x_setup_memcfg(bank, MEMCFG1, val);
> +		break;
> +	case 4 ... 7:
> +		_clps711x_setup_memcfg(bank - 4, MEMCFG2, val);
> +		break;
> +	}
> +}
> diff --git a/arch/arm/mach-clps711x/include/mach/clkdev.h b/arch/arm/mach-clps711x/include/mach/clkdev.h
> new file mode 100644
> index 0000000..9278209
> --- /dev/null
> +++ b/arch/arm/mach-clps711x/include/mach/clkdev.h
> @@ -0,0 +1,7 @@
> +#ifndef __MACH_CLKDEV_H
> +#define __MACH_CLKDEV_H
> +
> +#define __clk_get(clk)	({ 1; })
> +#define __clk_put(clk)	do { } while (0)
> +
> +#endif
> diff --git a/arch/arm/mach-clps711x/include/mach/clps711x.h b/arch/arm/mach-clps711x/include/mach/clps711x.h
> new file mode 100644
> index 0000000..048992a
> --- /dev/null
> +++ b/arch/arm/mach-clps711x/include/mach/clps711x.h
> @@ -0,0 +1,284 @@
> +/*
> + *  Hardware definitions for Cirrus Logic CLPS711X
> + *
> + *  Copyright (C) 2000 Deep Blue Solutions Ltd.
> + *  Copyright (C) 2012 Alexander Shiyan <shc_work at mail.ru>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + */
> +
> +#ifndef __MACH_CLPS711X_H
> +#define __MACH_CLPS711X_H
> +
> +#define CS0_BASE		(0x00000000)
> +#define CS1_BASE		(0x10000000)
> +#define CS2_BASE		(0x20000000)
> +#define CS3_BASE		(0x30000000)
> +#define CS4_BASE		(0x40000000)
> +#define CS5_BASE		(0x50000000)
> +#define CS6_BASE		(0x60000000)
> +#define CS7_BASE		(0x70000000)
> +#define REGS_BASE		(0x80000000)
> +#define SDRAM0_BASE		(0xc0000000)
> +#define SDRAM1_BASE		(0xd0000000)
> +
> +#define PADR			(REGS_BASE + 0x0000)
> +#define PBDR			(REGS_BASE + 0x0001)
> +#define PCDR			(REGS_BASE + 0x0002)
> +#define PDDR			(REGS_BASE + 0x0003)
> +#define PADDR			(REGS_BASE + 0x0040)
> +#define PBDDR			(REGS_BASE + 0x0041)
> +#define PCDDR			(REGS_BASE + 0x0042)
> +#define PDDDR			(REGS_BASE + 0x0043)
> +#define PEDR			(REGS_BASE + 0x0083)
> +#define PEDDR			(REGS_BASE + 0x00c3)
> +#define SYSCON1			(REGS_BASE + 0x0100)
> +#define SYSFLG1			(REGS_BASE + 0x0140)
> +#define MEMCFG1			(REGS_BASE + 0x0180)
> +#define MEMCFG2			(REGS_BASE + 0x01c0)
> +#define DRFPR			(REGS_BASE + 0x0200)
> +#define INTSR1			(REGS_BASE + 0x0240)
> +#define INTMR1			(REGS_BASE + 0x0280)
> +#define LCDCON			(REGS_BASE + 0x02c0)
> +#define TC1D			(REGS_BASE + 0x0300)
> +#define TC2D			(REGS_BASE + 0x0340)
> +#define RTCDR			(REGS_BASE + 0x0380)
> +#define RTCMR			(REGS_BASE + 0x03c0)
> +#define PMPCON			(REGS_BASE + 0x0400)
> +#define CODR			(REGS_BASE + 0x0440)
> +#define UARTDR1			(REGS_BASE + 0x0480)
> +#define UBRLCR1			(REGS_BASE + 0x04c0)
> +#define SYNCIO			(REGS_BASE + 0x0500)
> +#define PALLSW			(REGS_BASE + 0x0540)
> +#define PALMSW			(REGS_BASE + 0x0580)
> +#define STFCLR			(REGS_BASE + 0x05c0)
> +#define BLEOI			(REGS_BASE + 0x0600)
> +#define MCEOI			(REGS_BASE + 0x0640)
> +#define TEOI			(REGS_BASE + 0x0680)
> +#define TC1EOI			(REGS_BASE + 0x06c0)
> +#define TC2EOI			(REGS_BASE + 0x0700)
> +#define RTCEOI			(REGS_BASE + 0x0740)
> +#define UMSEOI			(REGS_BASE + 0x0780)
> +#define COEOI			(REGS_BASE + 0x07c0)
> +#define HALT			(REGS_BASE + 0x0800)
> +#define STDBY			(REGS_BASE + 0x0840)
> +
> +#define FBADDR			(REGS_BASE + 0x1000)
> +#define SYSCON2			(REGS_BASE + 0x1100)
> +#define SYSFLG2			(REGS_BASE + 0x1140)
> +#define INTSR2			(REGS_BASE + 0x1240)
> +#define INTMR2			(REGS_BASE + 0x1280)
> +#define UARTDR2			(REGS_BASE + 0x1480)
> +#define UBRLCR2			(REGS_BASE + 0x14c0)
> +#define SS2DR			(REGS_BASE + 0x1500)
> +#define SRXEOF			(REGS_BASE + 0x1600)
> +#define SS2POP			(REGS_BASE + 0x16c0)
> +#define KBDEOI			(REGS_BASE + 0x1700)
> +
> +#define DAIR			(REGS_BASE + 0x2000)
> +#define DAIDR0			(REGS_BASE + 0x2040)
> +#define DAIDR1			(REGS_BASE + 0x2080)
> +#define DAIDR2			(REGS_BASE + 0x20c0)
> +#define DAISR			(REGS_BASE + 0x2100)
> +#define SYSCON3			(REGS_BASE + 0x2200)
> +#define INTSR3			(REGS_BASE + 0x2240)
> +#define INTMR3			(REGS_BASE + 0x2280)
> +#define LEDFLSH			(REGS_BASE + 0x22c0)
> +#define SDCONF			(REGS_BASE + 0x2300)
> +#define SDRFPR			(REGS_BASE + 0x2340)
> +#define UNIQID			(REGS_BASE + 0x2440)
> +#define DAI64FS			(REGS_BASE + 0x2600)
> +#define PLLW			(REGS_BASE + 0x2610)
> +#define PLLR			(REGS_BASE + 0xa5a8)
> +#define RANDID0			(REGS_BASE + 0x2700)
> +#define RANDID1			(REGS_BASE + 0x2704)
> +#define RANDID2			(REGS_BASE + 0x2708)
> +#define RANDID3			(REGS_BASE + 0x270c)
> +
> +/* common bits: SYSCON1 / SYSCON2 */
> +#define SYSCON_UARTEN		(1 << 8)
> +
> +#define SYSCON1_KBDSCAN(x)	((x) & 15)
> +#define SYSCON1_KBDSCANMASK	(15)
> +#define SYSCON1_TC1M		(1 << 4)
> +#define SYSCON1_TC1S		(1 << 5)
> +#define SYSCON1_TC2M		(1 << 6)
> +#define SYSCON1_TC2S		(1 << 7)
> +#define SYSCON1_UART1EN		SYSCON_UARTEN
> +#define SYSCON1_BZTOG		(1 << 9)
> +#define SYSCON1_BZMOD		(1 << 10)
> +#define SYSCON1_DBGEN		(1 << 11)
> +#define SYSCON1_LCDEN		(1 << 12)
> +#define SYSCON1_CDENTX		(1 << 13)
> +#define SYSCON1_CDENRX		(1 << 14)
> +#define SYSCON1_SIREN		(1 << 15)
> +#define SYSCON1_ADCKSEL(x)	(((x) & 3) << 16)
> +#define SYSCON1_ADCKSEL_MASK	(3 << 16)
> +#define SYSCON1_EXCKEN		(1 << 18)
> +#define SYSCON1_WAKEDIS		(1 << 19)
> +#define SYSCON1_IRTXM		(1 << 20)
> +
> +/* common bits: SYSFLG1 / SYSFLG2 */
> +#define SYSFLG_UBUSY		(1 << 11)
> +#define SYSFLG_URXFE		(1 << 22)
> +#define SYSFLG_UTXFF		(1 << 23)
> +
> +#define SYSFLG1_MCDR		(1 << 0)
> +#define SYSFLG1_DCDET		(1 << 1)
> +#define SYSFLG1_WUDR		(1 << 2)
> +#define SYSFLG1_WUON		(1 << 3)
> +#define SYSFLG1_CTS		(1 << 8)
> +#define SYSFLG1_DSR		(1 << 9)
> +#define SYSFLG1_DCD		(1 << 10)
> +#define SYSFLG1_UBUSY		SYSFLG_UBUSY
> +#define SYSFLG1_NBFLG		(1 << 12)
> +#define SYSFLG1_RSTFLG		(1 << 13)
> +#define SYSFLG1_PFFLG		(1 << 14)
> +#define SYSFLG1_CLDFLG		(1 << 15)
> +#define SYSFLG1_URXFE		SYSFLG_URXFE
> +#define SYSFLG1_UTXFF		SYSFLG_UTXFF
> +#define SYSFLG1_CRXFE		(1 << 24)
> +#define SYSFLG1_CTXFF		(1 << 25)
> +#define SYSFLG1_SSIBUSY		(1 << 26)
> +#define SYSFLG1_ID		(1 << 29)
> +#define SYSFLG1_VERID(x)	(((x) >> 30) & 3)
> +#define SYSFLG1_VERID_MASK	(3 << 30)
> +
> +#define SYSFLG2_SSRXOF		(1 << 0)
> +#define SYSFLG2_RESVAL		(1 << 1)
> +#define SYSFLG2_RESFRM		(1 << 2)
> +#define SYSFLG2_SS2RXFE		(1 << 3)
> +#define SYSFLG2_SS2TXFF		(1 << 4)
> +#define SYSFLG2_SS2TXUF		(1 << 5)
> +#define SYSFLG2_CKMODE		(1 << 6)
> +#define SYSFLG2_UBUSY		SYSFLG_UBUSY
> +#define SYSFLG2_URXFE		SYSFLG_URXFE
> +#define SYSFLG2_UTXFF		SYSFLG_UTXFF
> +
> +#define LCDCON_GSEN		(1 << 30)
> +#define LCDCON_GSMD		(1 << 31)
> +
> +#define SYSCON2_SERSEL		(1 << 0)
> +#define SYSCON2_KBD6		(1 << 1)
> +#define SYSCON2_DRAMZ		(1 << 2)
> +#define SYSCON2_KBWEN		(1 << 3)
> +#define SYSCON2_SS2TXEN		(1 << 4)
> +#define SYSCON2_PCCARD1		(1 << 5)
> +#define SYSCON2_PCCARD2		(1 << 6)
> +#define SYSCON2_SS2RXEN		(1 << 7)
> +#define SYSCON2_UART2EN		SYSCON_UARTEN
> +#define SYSCON2_SS2MAEN		(1 << 9)
> +#define SYSCON2_OSTB		(1 << 12)
> +#define SYSCON2_CLKENSL		(1 << 13)
> +#define SYSCON2_BUZFREQ		(1 << 14)
> +
> +/* common bits: UARTDR1 / UARTDR2 */
> +#define UARTDR_FRMERR		(1 << 8)
> +#define UARTDR_PARERR		(1 << 9)
> +#define UARTDR_OVERR		(1 << 10)
> +
> +/* common bits: UBRLCR1 / UBRLCR2 */
> +#define UBRLCR_BAUD_MASK	((1 << 12) - 1)
> +#define UBRLCR_BREAK		(1 << 12)
> +#define UBRLCR_PRTEN		(1 << 13)
> +#define UBRLCR_EVENPRT		(1 << 14)
> +#define UBRLCR_XSTOP		(1 << 15)
> +#define UBRLCR_FIFOEN		(1 << 16)
> +#define UBRLCR_WRDLEN5		(0 << 17)
> +#define UBRLCR_WRDLEN6		(1 << 17)
> +#define UBRLCR_WRDLEN7		(2 << 17)
> +#define UBRLCR_WRDLEN8		(3 << 17)
> +#define UBRLCR_WRDLEN_MASK	(3 << 17)
> +
> +#define SYNCIO_FRMLEN(x)	(((x) & 0x1f) << 8)
> +#define SYNCIO_SMCKEN		(1 << 13)
> +#define SYNCIO_TXFRMEN		(1 << 14)
> +
> +#define DAIR_RESERVED		(0x0404)
> +#define DAIR_DAIEN		(1 << 16)
> +#define DAIR_ECS		(1 << 17)
> +#define DAIR_LCTM		(1 << 19)
> +#define DAIR_LCRM		(1 << 20)
> +#define DAIR_RCTM		(1 << 21)
> +#define DAIR_RCRM		(1 << 22)
> +#define DAIR_LBM		(1 << 23)
> +
> +#define DAIDR2_FIFOEN		(1 << 15)
> +#define DAIDR2_FIFOLEFT		(0x0d << 16)
> +#define DAIDR2_FIFORIGHT	(0x11 << 16)
> +
> +#define DAISR_RCTS		(1 << 0)
> +#define DAISR_RCRS		(1 << 1)
> +#define DAISR_LCTS		(1 << 2)
> +#define DAISR_LCRS		(1 << 3)
> +#define DAISR_RCTU		(1 << 4)
> +#define DAISR_RCRO		(1 << 5)
> +#define DAISR_LCTU		(1 << 6)
> +#define DAISR_LCRO		(1 << 7)
> +#define DAISR_RCNF		(1 << 8)
> +#define DAISR_RCNE		(1 << 9)
> +#define DAISR_LCNF		(1 << 10)
> +#define DAISR_LCNE		(1 << 11)
> +#define DAISR_FIFO		(1 << 12)
> +
> +#define DAI64FS_I2SF64		(1 << 0)
> +#define DAI64FS_AUDIOCLKEN	(1 << 1)
> +#define DAI64FS_AUDIOCLKSRC	(1 << 2)
> +#define DAI64FS_MCLK256EN	(1 << 3)
> +#define DAI64FS_LOOPBACK	(1 << 5)
> +#define DAI64FS_AUDIV_MASK	(0x7f)
> +#define DAI64FS_AUDIV(x)	(((x) & DAI64FS_AUDIV_MASK) << 8)
> +
> +#define SYSCON3_ADCCON		(1 << 0)
> +#define SYSCON3_CLKCTL0		(1 << 1)
> +#define SYSCON3_CLKCTL1		(1 << 2)
> +#define SYSCON3_DAISEL		(1 << 3)
> +#define SYSCON3_ADCCKNSEN	(1 << 4)
> +#define SYSCON3_VERSN(x)	(((x) >> 5) & 7)
> +#define SYSCON3_VERSN_MASK	(7 << 5)
> +#define SYSCON3_FASTWAKE	(1 << 8)
> +#define SYSCON3_DAIEN		(1 << 9)
> +#define SYSCON3_128FS		SYSCON3_DAIEN
> +#define SYSCON3_ENPD67		(1 << 10)
> +
> +#define SDCONF_ACTIVE		(1 << 10)
> +#define SDCONF_CLKCTL		(1 << 9)
> +#define SDCONF_WIDTH_4		(0 << 7)
> +#define SDCONF_WIDTH_8		(1 << 7)
> +#define SDCONF_WIDTH_16		(2 << 7)
> +#define SDCONF_WIDTH_32		(3 << 7)
> +#define SDCONF_SIZE_16		(0 << 5)
> +#define SDCONF_SIZE_64		(1 << 5)
> +#define SDCONF_SIZE_128		(2 << 5)
> +#define SDCONF_SIZE_256		(3 << 5)
> +#define SDCONF_CASLAT_2		(2)
> +#define SDCONF_CASLAT_3		(3)
> +
> +#define MEMCFG_BUS_WIDTH_32	(1)
> +#define MEMCFG_BUS_WIDTH_16	(0)
> +#define MEMCFG_BUS_WIDTH_8	(3)
> +
> +#define MEMCFG_SQAEN		(1 << 6)
> +#define MEMCFG_CLKENB		(1 << 7)
> +
> +#define MEMCFG_WAITSTATE_8_3	(0 << 2)
> +#define MEMCFG_WAITSTATE_7_3	(1 << 2)
> +#define MEMCFG_WAITSTATE_6_3	(2 << 2)
> +#define MEMCFG_WAITSTATE_5_3	(3 << 2)
> +#define MEMCFG_WAITSTATE_4_2	(4 << 2)
> +#define MEMCFG_WAITSTATE_3_2	(5 << 2)
> +#define MEMCFG_WAITSTATE_2_2	(6 << 2)
> +#define MEMCFG_WAITSTATE_1_2	(7 << 2)
> +#define MEMCFG_WAITSTATE_8_1	(8 << 2)
> +#define MEMCFG_WAITSTATE_7_1	(9 << 2)
> +#define MEMCFG_WAITSTATE_6_1	(10 << 2)
> +#define MEMCFG_WAITSTATE_5_1	(11 << 2)
> +#define MEMCFG_WAITSTATE_4_0	(12 << 2)
> +#define MEMCFG_WAITSTATE_3_0	(13 << 2)
> +#define MEMCFG_WAITSTATE_2_0	(14 << 2)
> +#define MEMCFG_WAITSTATE_1_0	(15 << 2)
> +
> +#endif
> diff --git a/arch/arm/mach-clps711x/include/mach/devices.h b/arch/arm/mach-clps711x/include/mach/devices.h
> new file mode 100644
> index 0000000..7e5eaf9
> --- /dev/null
> +++ b/arch/arm/mach-clps711x/include/mach/devices.h
> @@ -0,0 +1,6 @@
> +#ifndef __MACH_DEVICES_H
> +#define __MACH_DEVICES_H
> +
> +void clps711x_setup_memcfg(int bank, u32 val);
> +
> +#endif
> diff --git a/arch/arm/mach-clps711x/reset.c b/arch/arm/mach-clps711x/reset.c
> new file mode 100644
> index 0000000..4a42ef4
> --- /dev/null
> +++ b/arch/arm/mach-clps711x/reset.c
> @@ -0,0 +1,21 @@
> +/*
> + * Copyright (C) 2012 Alexander Shiyan <shc_work at mail.ru>
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation; either version 2 of
> + * the License, or (at your option) any later version.
> + */
> +
> +#include <common.h>
> +
> +extern void start(void);
> +
> +void __noreturn reset_cpu(unsigned long addr)
> +{
> +	arch_shutdown();
> +
> +	asm("mov pc, #0");
> +
> +	hang();
> +}
> -- 
> 1.7.8.6
> 
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From plagnioj at jcrosoft.com  Fri Nov  2 06:24:29 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri, 2 Nov 2012 11:24:29 +0100
Subject: [PATCH v4 1/3] ARM: Add initial support for CLPS711X architecture
In-Reply-To: <1351847836-8221-1-git-send-email-shc_work@mail.ru>
References: <1351847836-8221-1-git-send-email-shc_work@mail.ru>
Message-ID: <20121102102429.GR29599@game.jcrosoft.org>

On 13:17 Fri 02 Nov     , Alexander Shiyan wrote:
> This patch adds new architecture (CLPS711X) into barebox.
> The core-logic functionality of the device is built around an ARM720T
> processor running at clock speeds up to 90 MHz.
> 
> Signed-off-by: Alexander Shiyan <shc_work at mail.ru>
> ---
>  arch/arm/Kconfig                               |    6 +
>  arch/arm/Makefile                              |    1 +
>  arch/arm/mach-clps711x/Kconfig                 |    8 +
>  arch/arm/mach-clps711x/Makefile                |    1 +
>  arch/arm/mach-clps711x/clock.c                 |  113 ++++++++++
>  arch/arm/mach-clps711x/devices.c               |   37 +++
>  arch/arm/mach-clps711x/include/mach/clkdev.h   |    7 +
>  arch/arm/mach-clps711x/include/mach/clps711x.h |  284 ++++++++++++++++++++++++
>  arch/arm/mach-clps711x/include/mach/devices.h  |    6 +
>  arch/arm/mach-clps711x/reset.c                 |   21 ++
>  10 files changed, 484 insertions(+), 0 deletions(-)
>  create mode 100644 arch/arm/mach-clps711x/Kconfig
>  create mode 100644 arch/arm/mach-clps711x/Makefile
>  create mode 100644 arch/arm/mach-clps711x/clock.c
>  create mode 100644 arch/arm/mach-clps711x/devices.c
>  create mode 100644 arch/arm/mach-clps711x/include/mach/clkdev.h
>  create mode 100644 arch/arm/mach-clps711x/include/mach/clps711x.h
>  create mode 100644 arch/arm/mach-clps711x/include/mach/devices.h
>  create mode 100644 arch/arm/mach-clps711x/reset.c
> 
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index 57b3ca7..28071a5 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -31,6 +31,11 @@ config ARCH_AT91
>  	select HAS_DEBUG_LL
>  	select HAVE_MACH_ARM_HEAD
>  
> +config ARCH_CLPS711X
> +	bool "Cirrus Logic EP711x/EP721x/EP731x"
> +	select CLKDEV_LOOKUP
> +	select CPU_32v4T
> +
>  config ARCH_EP93XX
>  	bool "Cirrus Logic EP93xx"
>  	select CPU_ARM920T
> @@ -97,6 +102,7 @@ endchoice
>  
>  source arch/arm/cpu/Kconfig
>  source arch/arm/mach-at91/Kconfig
> +source arch/arm/mach-clps711x/Kconfig
>  source arch/arm/mach-ep93xx/Kconfig
>  source arch/arm/mach-imx/Kconfig
>  source arch/arm/mach-mxs/Kconfig
> diff --git a/arch/arm/Makefile b/arch/arm/Makefile
> index 855043a..da80e00 100644
> --- a/arch/arm/Makefile
> +++ b/arch/arm/Makefile
> @@ -52,6 +52,7 @@ AFLAGS   += -include asm/unified.h -msoft-float $(AFLAGS_THUMB2)
>  # Machine directory name.  This list is sorted alphanumerically
>  # by CONFIG_* macro name.
>  machine-$(CONFIG_ARCH_AT91)		:= at91
> +machine-$(CONFIG_ARCH_CLPS711X)		:= clps711x
>  machine-$(CONFIG_ARCH_EP93XX)		:= ep93xx
>  machine-$(CONFIG_ARCH_IMX)		:= imx
>  machine-$(CONFIG_ARCH_MXS)		:= mxs
> diff --git a/arch/arm/mach-clps711x/Kconfig b/arch/arm/mach-clps711x/Kconfig
> new file mode 100644
> index 0000000..56ca2ca
> --- /dev/null
> +++ b/arch/arm/mach-clps711x/Kconfig
> @@ -0,0 +1,8 @@
> +if ARCH_CLPS711X
> +
> +choice
> +	prompt "Cirrus Logic EP711x/EP721x/EP731x Board Type"
> +
> +endchoice
> +
> +endif
> diff --git a/arch/arm/mach-clps711x/Makefile b/arch/arm/mach-clps711x/Makefile
> new file mode 100644
> index 0000000..41012bc
> --- /dev/null
> +++ b/arch/arm/mach-clps711x/Makefile
> @@ -0,0 +1 @@
> +obj-y += clock.o devices.o reset.o
> diff --git a/arch/arm/mach-clps711x/clock.c b/arch/arm/mach-clps711x/clock.c
> new file mode 100644
> index 0000000..5cafba9
> --- /dev/null
> +++ b/arch/arm/mach-clps711x/clock.c
> @@ -0,0 +1,113 @@
> +/*
> + * Copyright (C) 2012 Alexander Shiyan <shc_work at mail.ru>
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation; either version 2 of
> + * the License, or (at your option) any later version.
> + */
> +
> +#include <common.h>
> +#include <init.h>
> +#include <clock.h>
> +#include <asm/io.h>
> +#include <linux/clkdev.h>
> +
> +#include <mach/clps711x.h>
> +
> +struct clk {
> +	unsigned long	rate;
> +};
> +
> +static struct clk uart_clk, bus_clk;
> +
> +uint64_t clocksource_read(void)
> +{
> +	return ~readw(TC2D);
> +}
> +
> +static struct clocksource cs = {
> +	.read	= clocksource_read,
> +	.mask	= CLOCKSOURCE_MASK(16),
> +};
> +
> +unsigned long clk_get_rate(struct clk *clk)
> +{
> +	return clk->rate;
> +}
> +EXPORT_SYMBOL(clk_get_rate);
> +
> +int clk_enable(struct clk *clk)
> +{
> +	/* Do nothing */
> +	return 0;
> +}
> +EXPORT_SYMBOL(clk_enable);
> +
> +void clk_disable(struct clk *clk)
> +{
> +	/* Do nothing */
> +}
> +EXPORT_SYMBOL(clk_disable);
> +
> +static int clocks_init(void)
> +{
> +	int osc, ext, pll, cpu, timer;
> +	u32 tmp;
> +
> +	osc = 3686400;
> +	ext = 13000000;
> +
> +	tmp = readl(PLLR) >> 24;
> +	if (tmp)
> +		pll = (osc * tmp) / 2;
> +	else
> +		pll = 73728000; /* Default value for old CPUs */
> +
> +	tmp = readl(SYSFLG2);
> +	if (tmp & SYSFLG2_CKMODE) {
> +		cpu = ext;
> +		bus_clk.rate = cpu;
> +	} else {
> +		cpu = pll;
> +		if (cpu >= 36864000)
> +			bus_clk.rate = cpu / 2;
> +		else
> +			bus_clk.rate = 36864000 / 2;
> +	}
> +
> +	uart_clk.rate = bus_clk.rate / 10;
this wrong split clocksource driver and clocks init

the clock driver will have to go to drivers/clocksource
> +
> +	if (tmp & SYSFLG2_CKMODE) {
> +		tmp = readw(SYSCON2);
> +		if (tmp & SYSCON2_OSTB)
> +			timer = ext / 26;
> +		else
> +			timer = 541440;
> +	} else
> +		timer = cpu / 144;
> +
> +	tmp = readl(SYSCON1);
> +	tmp &= ~SYSCON1_TC2M;	/* Free running mode */
> +	tmp |= SYSCON1_TC2S;	/* High frequency source */
> +	writel(tmp, SYSCON1);
> +
> +	clocks_calc_mult_shift(&cs.mult, &cs.shift, timer, NSEC_PER_SEC, 10);
> +
> +	return init_clock(&cs);
> +}
> +core_initcall(clocks_init);
> +
> +static struct clk_lookup clocks_lookups[] = {
> +	CLKDEV_CON_ID("bus", &bus_clk),
> +	CLKDEV_DEV_ID("clps711x_serial0", &uart_clk),
> +	CLKDEV_DEV_ID("clps711x_serial1", &uart_clk),
> +};
> +
> +static int clkdev_init(void)
> +{
> +	clkdev_add_table(clocks_lookups, ARRAY_SIZE(clocks_lookups));
> +
> +	return 0;
> +}
> +postcore_initcall(clkdev_init);
Best Regards,
J.


From s.hauer at pengutronix.de  Fri Nov  2 06:27:24 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Fri, 2 Nov 2012 11:27:24 +0100
Subject: [PATCH 0/4 v2] i2c: add algo-bit support with gpio and versatile
 support
In-Reply-To: <20121102092718.GO29599@game.jcrosoft.org>
References: <20121102092718.GO29599@game.jcrosoft.org>
Message-ID: <20121102102724.GK1641@pengutronix.de>

On Fri, Nov 02, 2012 at 10:27:18AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> HI,
> 
> 	v2: keep return -EBUSY if the adapter is already present
> 
> 	the foloing patch series add the i2c algo bit support with 2 drivers
> 	that use it
> 
> 	 - gpio
> 	 - versatile
> 
> 	 thie also create a device for i2c bus itself
> 
> 	 all the pedending branch are rebased on it
> 
> The following changes since commit 2d1ceaff2f905f4a2bd7e6c539e7dd3d8d8e9bef:
> 
>   uimage: Fix deleting of temporary file (2012-10-30 18:39:38 +0100)
> 
> are available in the git repository at:
> 
>   git://git.jcrosoft.org/barebox.git delivery/i2c
> 
> for you to fetch changes up to 5c90416b6ffb8d4ca7c4bc6aff92578b555cb965:
> 

Applied, thanks

Sascha

>   i2c: add versatile support (2012-11-02 02:17:04 +0800)
> 
> ----------------------------------------------------------------
> Jean-Christophe PLAGNIOL-VILLARD (4):
>       i2c: adapter: register it's own device
>       i2c: add i2c algo bit support
>       i2c: add i2c-gpio support
>       i2c: add versatile support
> 
>  drivers/i2c/Kconfig                |    1 +
>  drivers/i2c/Makefile               |    2 +-
>  drivers/i2c/algos/Kconfig          |    6 +++
>  drivers/i2c/algos/Makefile         |    5 ++
>  drivers/i2c/algos/i2c-algo-bit.c   |  585 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  drivers/i2c/busses/Kconfig         |   16 +++++++
>  drivers/i2c/busses/Makefile        |    2 +
>  drivers/i2c/busses/i2c-gpio.c      |  177 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  drivers/i2c/busses/i2c-imx.c       |   20 ++++----
>  drivers/i2c/busses/i2c-omap.c      |   30 ++++++------
>  drivers/i2c/busses/i2c-versatile.c |  112 +++++++++++++++++++++++++++++++++++++++++++++
>  drivers/i2c/i2c.c                  |   17 ++++++-
>  include/i2c/i2c-algo-bit.h         |   55 ++++++++++++++++++++++
>  include/i2c/i2c-gpio.h             |   38 +++++++++++++++
>  include/i2c/i2c.h                  |    4 +-
>  15 files changed, 1042 insertions(+), 28 deletions(-)
>  create mode 100644 drivers/i2c/algos/Kconfig
>  create mode 100644 drivers/i2c/algos/Makefile
>  create mode 100644 drivers/i2c/algos/i2c-algo-bit.c
>  create mode 100644 drivers/i2c/busses/i2c-gpio.c
>  create mode 100644 drivers/i2c/busses/i2c-versatile.c
>  create mode 100644 include/i2c/i2c-algo-bit.h
>  create mode 100644 include/i2c/i2c-gpio.h
> 
> Best Regards,
> J.
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Fri Nov  2 06:30:59 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Fri, 2 Nov 2012 11:30:59 +0100
Subject: [For next PATCH 1/1] versatilepb: add i2c support
In-Reply-To: <1351763567-6641-1-git-send-email-plagnioj@jcrosoft.com>
References: <1351763567-6641-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <20121102103059.GL1641@pengutronix.de>

On Thu, Nov 01, 2012 at 10:52:47AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
> ---
> apply over next
> 
> depends on verstile i2c driver send via i2c algo-bit series

Applied, thanks

Sascha

> 
> Best Regards,
> J.
>  arch/arm/boards/versatile/versatilepb.c     |    1 +
>  arch/arm/configs/versatilepb_defconfig      |    3 +++
>  arch/arm/mach-versatile/core.c              |    7 +++++++
>  arch/arm/mach-versatile/include/mach/init.h |    1 +
>  4 files changed, 12 insertions(+)
> 
> diff --git a/arch/arm/boards/versatile/versatilepb.c b/arch/arm/boards/versatile/versatilepb.c
> index 5a9c0b6..2eb7473 100644
> --- a/arch/arm/boards/versatile/versatilepb.c
> +++ b/arch/arm/boards/versatile/versatilepb.c
> @@ -47,6 +47,7 @@ mem_initcall(vpb_mem_init);
>  static int vpb_devices_init(void)
>  {
>  	add_cfi_flash_device(DEVICE_ID_DYNAMIC, VERSATILE_FLASH_BASE, VERSATILE_FLASH_SIZE, 0);
> +	versatile_register_i2c();
>  	devfs_add_partition("nor0", 0x00000, 0x40000, DEVFS_PARTITION_FIXED, "self");
>  	devfs_add_partition("nor0", 0x40000, 0x20000, DEVFS_PARTITION_FIXED, "env0");
>  
> diff --git a/arch/arm/configs/versatilepb_defconfig b/arch/arm/configs/versatilepb_defconfig
> index 4c71c3c..f6fa454 100644
> --- a/arch/arm/configs/versatilepb_defconfig
> +++ b/arch/arm/configs/versatilepb_defconfig
> @@ -34,6 +34,7 @@ CONFIG_CMD_TIMEOUT=y
>  CONFIG_CMD_PARTITION=y
>  CONFIG_CMD_GPIO=y
>  CONFIG_CMD_UNCOMPRESS=y
> +CONFIG_CMD_I2C=y
>  CONFIG_NET=y
>  CONFIG_NET_DHCP=y
>  CONFIG_NET_NFS=y
> @@ -44,6 +45,8 @@ CONFIG_NET_NETCONSOLE=y
>  CONFIG_NET_RESOLV=y
>  CONFIG_SERIAL_AMBA_PL011=y
>  CONFIG_DRIVER_NET_SMC91111=y
> +CONFIG_I2C=y
> +CONFIG_I2C_VERSATILE=y
>  CONFIG_GPIO_PL061=y
>  CONFIG_FS_CRAMFS=y
>  CONFIG_SHA1=y
> diff --git a/arch/arm/mach-versatile/core.c b/arch/arm/mach-versatile/core.c
> index 6e913df..8aca2a1 100644
> --- a/arch/arm/mach-versatile/core.c
> +++ b/arch/arm/mach-versatile/core.c
> @@ -26,6 +26,7 @@
>  #include <init.h>
>  #include <clock.h>
>  #include <debug_ll.h>
> +#include <sizes.h>
>  
>  #include <linux/clkdev.h>
>  #include <linux/clk.h>
> @@ -182,6 +183,12 @@ void versatile_register_uart(unsigned id)
>  	amba_apb_device_add(NULL, "uart-pl011", id, start, 4096, NULL, 0);
>  }
>  
> +void versatile_register_i2c(void)
> +{
> +	add_generic_device("versatile-i2c", DEVICE_ID_DYNAMIC, NULL,
> +			VERSATILE_I2C_BASE, SZ_4K, IORESOURCE_MEM, NULL);
> +}
> +
>  void __noreturn reset_cpu (unsigned long ignored)
>  {
>  	u32 val;
> diff --git a/arch/arm/mach-versatile/include/mach/init.h b/arch/arm/mach-versatile/include/mach/init.h
> index 878cde0..b40e4f9 100644
> --- a/arch/arm/mach-versatile/include/mach/init.h
> +++ b/arch/arm/mach-versatile/include/mach/init.h
> @@ -4,5 +4,6 @@
>  
>  void versatile_add_sdram(u32 size);
>  void versatile_register_uart(unsigned id);
> +void versatile_register_i2c(void);
>  
>  #endif
> -- 
> 1.7.10.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From shc_work at mail.ru  Fri Nov  2 06:35:03 2012
From: shc_work at mail.ru (Alexander Shiyan)
Date: Fri, 2 Nov 2012 14:35:03 +0400
Subject: [PATCH v4 1/3] ARM: Add initial support for CLPS711X architecture
In-Reply-To: <20121102102429.GR29599@game.jcrosoft.org>
References: <1351847836-8221-1-git-send-email-shc_work@mail.ru>
 <20121102102429.GR29599@game.jcrosoft.org>
Message-ID: <20121102143503.c0daefb7b5f19478daf95720@mail.ru>

On Fri, 2 Nov 2012 11:24:29 +0100
Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com> wrote:

...
> > +static int clocks_init(void)
> > +{
> > +	int osc, ext, pll, cpu, timer;
> > +	u32 tmp;
> > +
> > +	osc = 3686400;
> > +	ext = 13000000;
> > +
> > +	tmp = readl(PLLR) >> 24;
> > +	if (tmp)
> > +		pll = (osc * tmp) / 2;
> > +	else
> > +		pll = 73728000; /* Default value for old CPUs */
> > +
> > +	tmp = readl(SYSFLG2);
> > +	if (tmp & SYSFLG2_CKMODE) {
> > +		cpu = ext;
> > +		bus_clk.rate = cpu;
> > +	} else {
> > +		cpu = pll;
> > +		if (cpu >= 36864000)
> > +			bus_clk.rate = cpu / 2;
> > +		else
> > +			bus_clk.rate = 36864000 / 2;
> > +	}
> > +
> > +	uart_clk.rate = bus_clk.rate / 10;
> this wrong split clocksource driver and clocks init
> 
> the clock driver will have to go to drivers/clocksource
I remember about it, and as soon as clocksource go into master, I will
make the necessary modifications.

-- 
Alexander Shiyan <shc_work at mail.ru>


From plagnioj at jcrosoft.com  Fri Nov  2 12:06:59 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri, 2 Nov 2012 17:06:59 +0100
Subject: [PATCH 0/2] add spi command
Message-ID: <20121102160659.GS29599@game.jcrosoft.org>

HI,

	while debugging a spi issue I found we have a i2c commands but no spi
	command

	So introduce one

The following changes since commit 56371f4e8446d04d2a5608dd5890fd87a50f888e:

  iomux-imx35: add missing comma in pad definition (2012-11-01 16:32:12 +0100)

are available in the git repository at:

  git://git.jcrosoft.org/barebox.git delivery/command_spi

for you to fetch changes up to 3d6660a40aa5a51215a1909fd2fb5702f0e6558b:

  introduce spi command (2012-11-02 08:55:11 +0800)

----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (2):
      spi: introduce spi_get_master
      introduce spi command

 commands/Kconfig  |    6 ++++++
 commands/Makefile |    1 +
 commands/spi.c    |  126 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/spi/spi.c |   12 ++++++++++++
 include/spi/spi.h |    2 ++
 5 files changed, 147 insertions(+)
 create mode 100644 commands/spi.c

Best Regards,
J.


From plagnioj at jcrosoft.com  Fri Nov  2 12:17:39 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri,  2 Nov 2012 17:17:39 +0100
Subject: [PATCH 1/2] spi: introduce spi_get_master
In-Reply-To: <20121102160659.GS29599@game.jcrosoft.org>
References: <20121102160659.GS29599@game.jcrosoft.org>
Message-ID: <1351873060-27968-1-git-send-email-plagnioj@jcrosoft.com>

so we can request a master usefull for the spi command

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/spi/spi.c |   12 ++++++++++++
 include/spi/spi.h |    2 ++
 2 files changed, 14 insertions(+)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 44040e5..6a5bd6d 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -219,6 +219,18 @@ int spi_register_master(struct spi_master *master)
 }
 EXPORT_SYMBOL(spi_register_master);
 
+struct spi_master *spi_get_master(int bus)
+{
+	struct spi_master* m;
+
+	list_for_each_entry(m, &spi_master_list, list) {
+		if (m->bus_num == bus)
+			return m;
+	}
+
+	return NULL;
+}
+
 int spi_sync(struct spi_device *spi, struct spi_message *message)
 {
 	return spi->master->transfer(spi, message);
diff --git a/include/spi/spi.h b/include/spi/spi.h
index 1773ca2..d6570a4 100644
--- a/include/spi/spi.h
+++ b/include/spi/spi.h
@@ -432,6 +432,8 @@ static inline ssize_t spi_w8r8(struct spi_device *spi, u8 cmd)
 
 extern struct bus_type spi_bus;
 
+struct spi_master *spi_get_master(int bus);
+
 static inline int spi_register_driver(struct driver_d *drv)
 {
 	drv->bus = &spi_bus;
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Fri Nov  2 12:17:40 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri,  2 Nov 2012 17:17:40 +0100
Subject: [PATCH 2/2] introduce spi command
In-Reply-To: <1351873060-27968-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121102160659.GS29599@game.jcrosoft.org>
 <1351873060-27968-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1351873060-27968-2-git-send-email-plagnioj@jcrosoft.com>

usefull to debug spi

The command allow to read/write on a spi device

Usage: spi [OPTION] [data to write 0xXX]
write/read spi device.
  -b <bus_num>  spi bus number (default = 0)
  -r <count>    to read
  -c <cs>       chip select (default = 0)
  -m <mode>     spi mode (default = 0)
  -f <hz>       max_speed_hz (default = 1MHz)
  -w <bit>      bits_per_word (default = 8)
  -v            verbose

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 commands/Kconfig  |    6 +++
 commands/Makefile |    1 +
 commands/spi.c    |  126 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 133 insertions(+)
 create mode 100644 commands/spi.c

diff --git a/commands/Kconfig b/commands/Kconfig
index 16706d3..f7cbd67 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -597,6 +597,12 @@ config CMD_I2C
 	  include i2c_probe, i2c_read and i2c_write commands to communicate
 	  on i2c bus.
 
+config CMD_SPI
+	bool
+	depends on SPI
+	prompt "spi command"
+	help
+
 config CMD_LED
 	bool
 	depends on LED
diff --git a/commands/Makefile b/commands/Makefile
index 610be55..19d496e 100644
--- a/commands/Makefile
+++ b/commands/Makefile
@@ -55,6 +55,7 @@ obj-$(CONFIG_USB_GADGET_SERIAL)	+= usbserial.o
 obj-$(CONFIG_CMD_GPIO)		+= gpio.o
 obj-$(CONFIG_CMD_UNCOMPRESS)	+= uncompress.o
 obj-$(CONFIG_CMD_I2C)		+= i2c.o
+obj-$(CONFIG_CMD_SPI)		+= spi.o
 obj-$(CONFIG_CMD_UBI)		+= ubi.o
 obj-$(CONFIG_CMD_MENU)		+= menu.o
 obj-$(CONFIG_CMD_PASSWD)	+= passwd.o
diff --git a/commands/spi.c b/commands/spi.c
new file mode 100644
index 0000000..599637c
--- /dev/null
+++ b/commands/spi.c
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
+ *
+ * Under GPLv2 only
+ *
+ */
+
+#include <common.h>
+#include <command.h>
+#include <errno.h>
+#include <malloc.h>
+#include <getopt.h>
+#include <spi/spi.h>
+
+static int do_spi(int argc, char *argv[])
+{
+	struct spi_device spi;
+	int bus = 0;
+	int read = 0;
+	int verbose = 0;
+	int opt, count, i, ret;
+
+	u8 *tx_buf, *rx_buf;
+
+	memset(&spi, 0, sizeof(struct spi_device));
+
+	spi.max_speed_hz = 1 * 1000 * 1000;
+	spi.bits_per_word = 8;
+
+	while ((opt = getopt(argc, argv, "b:c:r:m:f:w:v")) > 0) {
+		switch (opt) {
+		case 'b':
+			bus = simple_strtol(optarg, NULL, 0);
+			break;
+		case 'r':
+			read = simple_strtol(optarg, NULL, 0);
+			break;
+		case 'c':
+			spi.chip_select = simple_strtoul(optarg, NULL, 0);
+			break;
+		case 'm':
+			spi.mode = simple_strtoul(optarg, NULL, 0);
+			break;
+		case 'f':
+			spi.max_speed_hz = simple_strtoul(optarg, NULL, 0);
+			break;
+		case 'w':
+			spi.bits_per_word = simple_strtoul(optarg, NULL, 0);
+			break;
+		case 'v':
+			verbose = 1;
+			break;
+		}
+	}
+
+	count = argc - optind;
+
+	if ((!read && !count) || !spi.max_speed_hz || !spi.bits_per_word)
+		return COMMAND_ERROR_USAGE;
+
+
+	spi.master = spi_get_master(bus);
+	if (!spi.master) {
+		printf("spi bus %d not found\n", bus);
+		return -ENODEV;
+	}
+
+	if (spi.chip_select > spi.master->num_chipselect) {
+		printf("spi chip select (%d)> master num chipselect (%d)\n",
+			spi.chip_select, spi.master->num_chipselect);
+		return -EINVAL;
+	}
+
+	tx_buf = xmalloc(count);
+	rx_buf = xmalloc(count);
+
+	for (i = 0; i < count; i++)
+		tx_buf[i] = (char) simple_strtol(argv[optind+i], NULL, 16);
+
+	ret = spi_write_then_read(&spi, tx_buf, count, rx_buf, read);
+	if (ret)
+		goto out;
+
+	if (verbose) {
+		printf("device config\n");
+		printf("    bus_num       = %d\n", spi.master->bus_num);
+		printf("    max_speed_hz  = %d\n", spi.max_speed_hz);
+		printf("    chip_select   = %d\n", spi.chip_select);
+		printf("    mode          = 0x%x\n", spi.mode);
+		printf("    bits_per_word = %d\n", spi.bits_per_word);
+		printf("\n");
+
+		printf("wrote %i bytes\n", count);
+		for (i = 0; i < count; i++)
+			printf("0x%02x ", tx_buf[i]);
+		printf("\n");
+
+		printf("read %i bytes\n", read);
+	}
+
+	for (i = 0; i < read; i++)
+		printf("0x%02x ", rx_buf[i]);
+	printf("\n");
+
+out:
+	free(rx_buf);
+	free(tx_buf);
+	return ret;
+}
+
+static const __maybe_unused char cmd_spi_help[] =
+"Usage: spi [OPTION] [data to write 0xXX]\n"
+"write/read spi device.\n"
+"  -b <bus_num>  spi bus number (default = 0)\n"
+"  -r <count>    to read\n"
+"  -c <cs>       chip select (default = 0)\n"
+"  -m <mode>     spi mode (default = 0)\n"
+"  -f <hz>       max_speed_hz (default = 1MHz)\n"
+"  -w <bit>      bits_per_word (default = 8)\n"
+"  -v            verbose\n";
+
+BAREBOX_CMD_START(spi)
+	.cmd		= do_spi,
+	.usage		= "write/read spi device",
+	BAREBOX_CMD_HELP(cmd_spi_help)
+BAREBOX_CMD_END
-- 
1.7.10.4



From shc_work at mail.ru  Fri Nov  2 12:26:00 2012
From: shc_work at mail.ru (=?UTF-8?B?QWxleGFuZGVyIFNoaXlhbg==?=)
Date: Fri, 02 Nov 2012 20:26:00 +0400
Subject: =?UTF-8?B?UmU6IFtQQVRDSCAyLzJdIGludHJvZHVjZSBzcGkgY29tbWFuZA==?=
In-Reply-To: <1351873060-27968-2-git-send-email-plagnioj@jcrosoft.com>
References: <1351873060-27968-1-git-send-email-plagnioj@jcrosoft.com>
 <20121102160659.GS29599@game.jcrosoft.org>
 <1351873060-27968-2-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1351873560.417163578@f213.mail.ru>

Fri,  2 Nov 2012 17:17:40 +0100 ?? Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>:
> usefull to debug spi
> 
> The command allow to read/write on a spi device
> 
> Usage: spi [OPTION] [data to write 0xXX]
> write/read spi device.
>   -b <bus_num>  spi bus number (default = 0)
>   -r <count>    to read
>   -c <cs>       chip select (default = 0)
>   -m <mode>     spi mode (default = 0)
>   -f <hz>       max_speed_hz (default = 1MHz)
>   -w <bit>      bits_per_word (default = 8)
>   -v            verbose
...
> +static int do_spi(int argc, char *argv[])
> +{
> +	struct spi_device spi;
> +	int bus = 0;
> +	int read = 0;
> +	int verbose = 0;
> +	int opt, count, i, ret;
> +
> +	u8 *tx_buf, *rx_buf;
> +
> +	memset(&spi, 0, sizeof(struct spi_device));
> +
> +	spi.max_speed_hz = 1 * 1000 * 1000;
> +	spi.bits_per_word = 8;

I suggest using the default data from master for these parameters.

---

From plagnioj at jcrosoft.com  Fri Nov  2 12:45:31 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri, 2 Nov 2012 17:45:31 +0100
Subject: [PATCH 2/2] introduce spi command
In-Reply-To: <1351873560.417163578@f213.mail.ru>
References: <1351873060-27968-1-git-send-email-plagnioj@jcrosoft.com>
 <20121102160659.GS29599@game.jcrosoft.org>
 <1351873060-27968-2-git-send-email-plagnioj@jcrosoft.com>
 <1351873560.417163578@f213.mail.ru>
Message-ID: <20121102164531.GT29599@game.jcrosoft.org>

On 20:26 Fri 02 Nov     , Alexander Shiyan wrote:
> Fri,  2 Nov 2012 17:17:40 +0100 ?? Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>:
> > usefull to debug spi
> > 
> > The command allow to read/write on a spi device
> > 
> > Usage: spi [OPTION] [data to write 0xXX]
> > write/read spi device.
> >   -b <bus_num>  spi bus number (default = 0)
> >   -r <count>    to read
> >   -c <cs>       chip select (default = 0)
> >   -m <mode>     spi mode (default = 0)
> >   -f <hz>       max_speed_hz (default = 1MHz)
> >   -w <bit>      bits_per_word (default = 8)
> >   -v            verbose
> ...
> > +static int do_spi(int argc, char *argv[])
> > +{
> > +	struct spi_device spi;
> > +	int bus = 0;
> > +	int read = 0;
> > +	int verbose = 0;
> > +	int opt, count, i, ret;
> > +
> > +	u8 *tx_buf, *rx_buf;
> > +
> > +	memset(&spi, 0, sizeof(struct spi_device));
> > +
> > +	spi.max_speed_hz = 1 * 1000 * 1000;
> > +	spi.bits_per_word = 8;
> 
> I suggest using the default data from master for these parameters.
no otherwise we can not write the help and bits_et_word it's default value at
spi framework level is 8

and thh max_speed_hz is slow already

and it has always been the device to control it no the master

Best Regards,
J.


From s.hauer at pengutronix.de  Fri Nov  2 15:01:41 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Fri, 2 Nov 2012 20:01:41 +0100
Subject: [PATCH 0/2] add spi command
In-Reply-To: <20121102160659.GS29599@game.jcrosoft.org>
References: <20121102160659.GS29599@game.jcrosoft.org>
Message-ID: <20121102190141.GN1641@pengutronix.de>

On Fri, Nov 02, 2012 at 05:06:59PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> HI,
> 
> 	while debugging a spi issue I found we have a i2c commands but no spi
> 	command
> 
> 	So introduce one
> 
> The following changes since commit 56371f4e8446d04d2a5608dd5890fd87a50f888e:
> 
>   iomux-imx35: add missing comma in pad definition (2012-11-01 16:32:12 +0100)
> 
> are available in the git repository at:
> 
>   git://git.jcrosoft.org/barebox.git delivery/command_spi
> 
> for you to fetch changes up to 3d6660a40aa5a51215a1909fd2fb5702f0e6558b:
> 

I recently used the i2c_* commands and thought it would be a good idea
to introduce regmap for barebox. This way we could add a regmap command
which just maps arbitrary i2c/spi devices as a cdev. Also we could
replace several drivers in drivers/mfd/ with nearly one-liners.

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Fri Nov  2 16:15:35 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Fri, 2 Nov 2012 21:15:35 +0100
Subject: [PATCH 1/1 v2] input: add qt1070 touch keyboard support
In-Reply-To: <1351777973-26024-1-git-send-email-plagnioj@jcrosoft.com>
References: <1351776162-23461-1-git-send-email-plagnioj@jcrosoft.com>
 <1351777973-26024-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <20121102201535.GO1641@pengutronix.de>

On Thu, Nov 01, 2012 at 02:52:53PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
> ---
> fix typo add when checking the patch
>

select POLLER missing in Kconfig

> +static void qt1070_poller(struct poller_struct *poller)
> +{
> +	struct qt1070_data *data = poller_to_qt_data(poller);
> +	int i;
> +	u8 buf, bt;
> +	u8 mask = 0x1;
> +
> +	qt1070_read(data, QT1070_DET_STATUS, &buf);
> +
> +	if (qt1070_read(data, QT1070_KEY_STATUS, &buf))
> +		return;
> +
> +	if (!buf & !data->previous_state)
> +		return;
> +
> +	for (i = 0; i < QT1070_NB_BUTTONS; i++) {
> +		bt = buf & mask;
> +
> +		if (!bt && data->button_state[i]) {
> +			debug("release key(%d) as %d\n", i, data->code[i]);
> +			kfifo_put(data->recv_fifo, (u_char*)&data->code[i], sizeof(int));
> +		} else if (bt) {
> +			debug("pressed key(%d) as %d\n", i, data->code[i]);
> +		}
> +
> +		data->button_state[i] = bt;
> +		mask <<= 1;
> +	}
> +
> +	data->previous_state = buf;
> +}
> +
> +static int qt1070_tstc(struct console_device *cdev)
> +{
> +	struct qt1070_data *data = cdev_to_qt_data(cdev);
> +
> +	return (kfifo_len(data->recv_fifo) == 0) ? 0 : 1;
> +}
> +
> +static int qt1070_getc(struct console_device *cdev)
> +{
> +	int code = 0;
> +	struct qt1070_data *data = cdev_to_qt_data(cdev);
> +
> +	kfifo_get(data->recv_fifo, (u_char*)&code, sizeof(int));
> +	return code;
> +}
> +
> +static int __init qt1070_probe(struct device_d *dev)
> +{
> +	struct console_device *cdev;
> +	struct qt1070_data *data;
> +	u8 fw_version, chip_id;
> +	int ret;
> +	char buf[6];
> +
> +	data = xzalloc(sizeof(*data));
> +	data->client = to_i2c_client(dev);
> +
> +	ret = qt1070_read(data, QT1070_READ_CHIP_ID, &chip_id);
> +	if (ret) {
> +		dev_err(dev, "can not read chip id (%d)\n", ret);
> +		goto err;
> +	}
> +
> +	if (chip_id != QT1070_CHIP_ID) {
> +		dev_err(dev, "unsupported id 0x%x\n", chip_id);
> +		ret = -ENXIO;
> +		goto err;
> +	}
> +
> +	ret = qt1070_read(data, QT1070_FW_VERSION, &fw_version);
> +	if (ret) {
> +		dev_err(dev, "can not read firmware version (%d)\n", ret);
> +		goto err;
> +	}
> +
> +	sprintf(buf, "0x%x", fw_version);
> +	dev_add_param_fixed(dev, "fw_version", buf);
> +	sprintf(buf, "0x%x", chip_id);
> +	dev_add_param_fixed(dev, "chip_ip", buf);
> +
> +	/* Calibrate device */
> +	qt1070_write(data, QT1070_CALIBRATE_CMD, 1);
> +	if (ret) {
> +		dev_err(dev, "can not calibreate the chip (%d)\n", ret);

s/calibreate/calibrate/

> +		goto err;
> +	}
> +	mdelay(QT1070_CAL_TIME);
> +
> +	/* Soft reset */
> +	ret = qt1070_write(data, QT1070_RESET, 1);
> +	if (ret) {
> +		dev_err(dev, "can not reset the chip (%d)\n", ret);
> +		goto err;
> +	}
> +	mdelay(QT1070_RESET_TIME);
> +

This delays the boot by about half a second. If you register
a poller anyway you could use it to wait until the reset finished.

> +	memcpy(data->code, default_code, sizeof(int) * ARRAY_SIZE(default_code));
> +	if (dev->platform_data) {
> +		struct qt1070_platform_data *pdata = dev->platform_data;
> +
> +		memcpy(data->code, pdata->code, sizeof(int) * pdata->nb_code);
> +	}
> +
> +	data->fifo_size = 50;

I wonder if such a deep fifo is useful. If the user
plays with the buttons when and nobody empties the fifo
at that time you will end up with 50 old button presses
in the fifo. It may be better to just store the last button
in a variable. This would also fix the problem that when
the fifo is full you discard the newest buttons. It's
better to drop the oldest buttons.

> +	data->recv_fifo = kfifo_alloc(data->fifo_size);
> +
> +	data->poller.func = qt1070_poller;
> +
> +	cdev = &data->cdev;
> +	dev->type_data = cdev;

This is unused in the console layer. Please drop.

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Fri Nov  2 16:24:02 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Fri, 2 Nov 2012 21:24:02 +0100
Subject: [PATCH 0/7] at91 add i2c-gpio suport
In-Reply-To: <20121101143352.GJ29599@game.jcrosoft.org>
References: <20121101143352.GJ29599@game.jcrosoft.org>
Message-ID: <20121102202402.GP1641@pengutronix.de>

On Thu, Nov 01, 2012 at 03:33:52PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> Hi,
> 
> 	This paatch serie add the i2c suport to at91 using the i2c-gpio as teh
> 	IP is broken until the sam9x5. For the sam9x5 untill we have the hw
> 	driver support use the i2c-gpio too
> 
> 	on the sam9x5ek enable the i2c and the qt1070
> 
> 	This patch serie depends on i2c qt1070 patch and the at91sam9x5ek
> 	1-wire one
> 
> The following changes since commit 3a5609a37a19b0b6b5f4c61e3c561b7bf2d25b72:
> 
>   i2c: add versatile support (2012-11-01 06:58:21 +0800)
> 
> are available in the git repository at:
> 
>   git://git.jcrosoft.org/barebox.git delivery/at91_i2c
> 
> for you to fetch changes up to 2d2aee2451a0210cfb0d141db7729b648d0a32a4:

Applied up to 6/7 as the qt1070 driver needs some updates.

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From plagnioj at jcrosoft.com  Sat Nov  3 03:25:46 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Sat, 3 Nov 2012 08:25:46 +0100
Subject: [PATCH 0/7] at91 add i2c-gpio suport
In-Reply-To: <20121102202402.GP1641@pengutronix.de>
References: <20121101143352.GJ29599@game.jcrosoft.org>
 <20121102202402.GP1641@pengutronix.de>
Message-ID: <20121103072546.GU29599@game.jcrosoft.org>

On 21:24 Fri 02 Nov     , Sascha Hauer wrote:
> On Thu, Nov 01, 2012 at 03:33:52PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > Hi,
> > 
> > 	This paatch serie add the i2c suport to at91 using the i2c-gpio as teh
> > 	IP is broken until the sam9x5. For the sam9x5 untill we have the hw
> > 	driver support use the i2c-gpio too
> > 
> > 	on the sam9x5ek enable the i2c and the qt1070
> > 
> > 	This patch serie depends on i2c qt1070 patch and the at91sam9x5ek
> > 	1-wire one
> > 
> > The following changes since commit 3a5609a37a19b0b6b5f4c61e3c561b7bf2d25b72:
> > 
> >   i2c: add versatile support (2012-11-01 06:58:21 +0800)
> > 
> > are available in the git repository at:
> > 
> >   git://git.jcrosoft.org/barebox.git delivery/at91_i2c
> > 
> > for you to fetch changes up to 2d2aee2451a0210cfb0d141db7729b648d0a32a4:
> 
> Applied up to 6/7 as the qt1070 driver needs some updates.
You apply it too as the qt1070 is not in the defconfig

this will not break anything

Best Regards,
J.


From plagnioj at jcrosoft.com  Sat Nov  3 03:32:43 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Sat, 3 Nov 2012 08:32:43 +0100
Subject: [PATCH 1/1 v2] input: add qt1070 touch keyboard support
In-Reply-To: <20121102201535.GO1641@pengutronix.de>
References: <1351776162-23461-1-git-send-email-plagnioj@jcrosoft.com>
 <1351777973-26024-1-git-send-email-plagnioj@jcrosoft.com>
 <20121102201535.GO1641@pengutronix.de>
Message-ID: <20121103073243.GV29599@game.jcrosoft.org>

> > +}
> > +
> > +static int __init qt1070_probe(struct device_d *dev)
> > +{
> > +	struct console_device *cdev;
> > +	struct qt1070_data *data;
> > +	u8 fw_version, chip_id;
> > +	int ret;
> > +	char buf[6];
> > +
> > +	data = xzalloc(sizeof(*data));
> > +	data->client = to_i2c_client(dev);
> > +
> > +	ret = qt1070_read(data, QT1070_READ_CHIP_ID, &chip_id);
> > +	if (ret) {
> > +		dev_err(dev, "can not read chip id (%d)\n", ret);
> > +		goto err;
> > +	}
> > +
> > +	if (chip_id != QT1070_CHIP_ID) {
> > +		dev_err(dev, "unsupported id 0x%x\n", chip_id);
> > +		ret = -ENXIO;
> > +		goto err;
> > +	}
> > +
> > +	ret = qt1070_read(data, QT1070_FW_VERSION, &fw_version);
> > +	if (ret) {
> > +		dev_err(dev, "can not read firmware version (%d)\n", ret);
> > +		goto err;
> > +	}
> > +
> > +	sprintf(buf, "0x%x", fw_version);
> > +	dev_add_param_fixed(dev, "fw_version", buf);
> > +	sprintf(buf, "0x%x", chip_id);
> > +	dev_add_param_fixed(dev, "chip_ip", buf);
> > +
> > +	/* Calibrate device */
> > +	qt1070_write(data, QT1070_CALIBRATE_CMD, 1);
> > +	if (ret) {
> > +		dev_err(dev, "can not calibreate the chip (%d)\n", ret);
> 
> s/calibreate/calibrate/
> 
> > +		goto err;
> > +	}
> > +	mdelay(QT1070_CAL_TIME);
> > +
> > +	/* Soft reset */
> > +	ret = qt1070_write(data, QT1070_RESET, 1);
> > +	if (ret) {
> > +		dev_err(dev, "can not reset the chip (%d)\n", ret);
> > +		goto err;
> > +	}
> > +	mdelay(QT1070_RESET_TIME);
> > +
> 
> This delays the boot by about half a second. If you register
> a poller anyway you could use it to wait until the reset finished.
ok
> 
> > +	memcpy(data->code, default_code, sizeof(int) * ARRAY_SIZE(default_code));
> > +	if (dev->platform_data) {
> > +		struct qt1070_platform_data *pdata = dev->platform_data;
> > +
> > +		memcpy(data->code, pdata->code, sizeof(int) * pdata->nb_code);
> > +	}
> > +
> > +	data->fifo_size = 50;
> 
> I wonder if such a deep fifo is useful. If the user
> plays with the buttons when and nobody empties the fifo
> at that time you will end up with 50 old button presses
> in the fifo. It may be better to just store the last button
> in a variable. This would also fix the problem that when
> the fifo is full you discard the newest buttons. It's
> better to drop the oldest buttons.
no the touch can report 7 keys at the same time so I put 50.

If we pessed 2 times 7 keys before barebox read we have 14 * sifeod(int) = 56
bytes so I think 50 is ok

Best Regards,
J.


From plagnioj at jcrosoft.com  Sat Nov  3 03:36:56 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Sat, 3 Nov 2012 08:36:56 +0100
Subject: [PATCH 0/2] add spi command
In-Reply-To: <20121102190141.GN1641@pengutronix.de>
References: <20121102160659.GS29599@game.jcrosoft.org>
 <20121102190141.GN1641@pengutronix.de>
Message-ID: <20121103073656.GW29599@game.jcrosoft.org>

On 20:01 Fri 02 Nov     , Sascha Hauer wrote:
> On Fri, Nov 02, 2012 at 05:06:59PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > HI,
> > 
> > 	while debugging a spi issue I found we have a i2c commands but no spi
> > 	command
> > 
> > 	So introduce one
> > 
> > The following changes since commit 56371f4e8446d04d2a5608dd5890fd87a50f888e:
> > 
> >   iomux-imx35: add missing comma in pad definition (2012-11-01 16:32:12 +0100)
> > 
> > are available in the git repository at:
> > 
> >   git://git.jcrosoft.org/barebox.git delivery/command_spi
> > 
> > for you to fetch changes up to 3d6660a40aa5a51215a1909fd2fb5702f0e6558b:
> > 
> 
> I recently used the i2c_* commands and thought it would be a good idea
> to introduce regmap for barebox. This way we could add a regmap command
> which just maps arbitrary i2c/spi devices as a cdev. Also we could
> replace several drivers in drivers/mfd/ with nearly one-liners.

why not but how to pass all the parameter to this cdev

on SPI we need some on i2c it's more simple

If this will be for the next release ok otherwise can we have this command
until then

Best Regards,
J.


From plagnioj at jcrosoft.com  Sat Nov  3 07:26:19 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Sat,  3 Nov 2012 12:26:19 +0100
Subject: [PATCH 1/1 v3] input: add qt1070 touch keyboard support
In-Reply-To: <1351777973-26024-1-git-send-email-plagnioj@jcrosoft.com>
References: <1351777973-26024-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1351941979-25433-1-git-send-email-plagnioj@jcrosoft.com>

use irq pin as the pin is asserted untill we clear it
This will allow to do not poll on i2c which slow down barebox

If no irq_pin is provided fall back on i2c polling

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
v3:

	add irq_pin support
	use different poll function to wait for calibration and reset
	so we do not endup with a delay of nearly 500ms at boot time

Best Regards,
J.
 drivers/input/Kconfig  |    8 ++
 drivers/input/Makefile |    1 +
 drivers/input/qt1070.c |  296 ++++++++++++++++++++++++++++++++++++++++++++++++
 include/input/qt1070.h |   18 +++
 4 files changed, 323 insertions(+)
 create mode 100644 drivers/input/qt1070.c
 create mode 100644 include/input/qt1070.h

diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig
index 15979a2..846483c 100644
--- a/drivers/input/Kconfig
+++ b/drivers/input/Kconfig
@@ -30,4 +30,12 @@ config KEYBOARD_IMX_KEYPAD
 	  setup logic must also provide a 'matrix_keymap_data' structure,
 	  defining the used keys.
 
+config KEYBOARD_QT1070
+	tristate "Atmel AT42QT1070 Touch Sensor Chip"
+	depends on I2C
+	select POLLER
+	help
+	  Say Y here if you want to use Atmel AT42QT1070 QTouch
+	  Sensor chip as input device.
+
 endmenu
diff --git a/drivers/input/Makefile b/drivers/input/Makefile
index 3d105cc..d042980 100644
--- a/drivers/input/Makefile
+++ b/drivers/input/Makefile
@@ -1,2 +1,3 @@
 obj-$(CONFIG_KEYBOARD_GPIO) += gpio_keys.o
 obj-$(CONFIG_KEYBOARD_IMX_KEYPAD) += imx_keypad.o
+obj-$(CONFIG_KEYBOARD_QT1070) += qt1070.o
diff --git a/drivers/input/qt1070.c b/drivers/input/qt1070.c
new file mode 100644
index 0000000..c66189e
--- /dev/null
+++ b/drivers/input/qt1070.c
@@ -0,0 +1,296 @@
+/*
+ * Copyright (C) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
+ *
+ * Under GPLv2
+ */
+
+#include <common.h>
+#include <errno.h>
+#include <init.h>
+#include <clock.h>
+#include <poller.h>
+#include <kfifo.h>
+#include <i2c/i2c.h>
+#include <malloc.h>
+#include <readkey.h>
+#include <input/qt1070.h>
+#include <gpio.h>
+
+#define QT1070_CHIP_ID		0x2e
+
+#define QT1070_READ_CHIP_ID	0x00
+#define QT1070_FW_VERSION	0x01
+#define QT1070_DET_STATUS	0x02
+#define QT1070_KEY_STATUS	0x03
+
+/* Calibrate */
+#define QT1070_CALIBRATE_CMD	0x38
+#define QT1070_CAL_TIME		200
+
+/* Reset */
+#define QT1070_RESET		0x39
+#define QT1070_RESET_TIME	255
+
+static int default_code[QT1070_NB_BUTTONS] = {
+	KEY_ENTER, KEY_HOME, KEY_UP, KEY_DOWN,
+	KEY_RIGHT, KEY_LEFT, KEY_CLEAR_SCREEN };
+
+struct qt1070_data {
+	int code[QT1070_NB_BUTTONS];
+
+	int irq_pin;
+
+	u64 start;
+
+	/* optional */
+	int fifo_size;
+
+	struct i2c_client *client;
+	u8 button_state[QT1070_NB_BUTTONS];
+	u8 previous_state;
+
+	struct kfifo *recv_fifo;
+	struct poller_struct poller;
+	struct console_device cdev;
+};
+
+static inline struct qt1070_data *
+poller_to_qt_data(struct poller_struct *poller)
+{
+	return container_of(poller, struct qt1070_data, poller);
+}
+
+static inline struct qt1070_data *
+cdev_to_qt_data(struct console_device *cdev)
+{
+	return container_of(cdev, struct qt1070_data, cdev);
+}
+
+static bool qt1070_read(struct qt1070_data *data, u8 reg, u8 *val)
+{
+	int ret;
+
+	ret = i2c_read_reg(data->client, reg, val, 1);
+
+	if (ret < 0)
+		return ret;
+	if (ret != 1)
+		return -EIO;
+	return 0;
+}
+
+static bool qt1070_write(struct qt1070_data *data, u8 reg, const u8 val)
+{
+	int ret;
+
+	ret = i2c_write_reg(data->client, reg, &val, 1);
+	if (ret < 0)
+		return ret;
+	if (ret != 1)
+		return -EIO;
+	return 0;
+}
+
+static void qt1070_poller(struct poller_struct *poller)
+{
+	struct qt1070_data *data = poller_to_qt_data(poller);
+	int i;
+	u8 buf, bt;
+	u8 mask = 0x1;
+
+	if (gpio_is_valid(data->irq_pin)) {
+		/* active low */
+		if (gpio_get_value(data->irq_pin))
+			return;
+	}
+
+	qt1070_read(data, QT1070_DET_STATUS, &buf);
+
+	if (qt1070_read(data, QT1070_KEY_STATUS, &buf))
+		return;
+
+	if (!buf & !data->previous_state)
+		return;
+
+	for (i = 0; i < QT1070_NB_BUTTONS; i++) {
+		bt = buf & mask;
+
+		if (!bt && data->button_state[i]) {
+			dev_dbg(data->cdev.dev, "release key(%d) as %d\n", i, data->code[i]);
+			kfifo_put(data->recv_fifo, (u_char*)&data->code[i], sizeof(int));
+		} else if (bt) {
+			dev_dbg(data->cdev.dev, "pressed key(%d) as %d\n", i, data->code[i]);
+		}
+
+		data->button_state[i] = bt;
+		mask <<= 1;
+	}
+
+	data->previous_state = buf;
+}
+
+static void qt1070_reset_poller(struct poller_struct *poller)
+{
+	struct qt1070_data *data = poller_to_qt_data(poller);
+	u8 buf;
+
+	if (!is_timeout_non_interruptible(data->start, QT1070_RESET_TIME * MSECOND))
+		return;
+
+	/* clear the status */
+	qt1070_read(data, QT1070_DET_STATUS, &buf);
+
+	poller->func = qt1070_poller;
+}
+
+static void qt1070_calibrate_poller(struct poller_struct *poller)
+{
+	struct qt1070_data *data = poller_to_qt_data(poller);
+	int ret;
+
+	if (!is_timeout_non_interruptible(data->start, QT1070_CAL_TIME * MSECOND))
+		return;
+
+	/* Soft reset */
+	ret = qt1070_write(data, QT1070_RESET, 1);
+	if (ret) {
+		dev_err(data->cdev.dev, "can not reset the chip (%d)\n", ret);
+		poller_unregister(poller);
+		return;
+	}
+	data->start = get_time_ns();
+
+	poller->func = qt1070_reset_poller;
+}
+
+static int qt1070_tstc(struct console_device *cdev)
+{
+	struct qt1070_data *data = cdev_to_qt_data(cdev);
+
+	return (kfifo_len(data->recv_fifo) == 0) ? 0 : 1;
+}
+
+static int qt1070_getc(struct console_device *cdev)
+{
+	int code = 0;
+	struct qt1070_data *data = cdev_to_qt_data(cdev);
+
+	kfifo_get(data->recv_fifo, (u_char*)&code, sizeof(int));
+	return code;
+}
+
+static int qt1070_pdata_init(struct device_d *dev, struct qt1070_data *data)
+{
+	struct qt1070_platform_data *pdata = dev->platform_data;
+	int ret;
+
+	if (!pdata)
+		return 0;
+
+	if (pdata->nb_code)
+		memcpy(data->code, pdata->code, sizeof(int) * pdata->nb_code);
+
+	if (!gpio_is_valid(pdata->irq_pin))
+		return 0;
+
+	ret = gpio_request(pdata->irq_pin, "qt1070");
+	if (ret)
+		return ret;
+
+	ret = gpio_direction_input(pdata->irq_pin);
+	if (ret)
+		goto err;
+
+	data->irq_pin = pdata->irq_pin;
+
+	return 0;
+err:
+	gpio_free(pdata->irq_pin);
+	return ret;
+}
+
+static int qt1070_probe(struct device_d *dev)
+{
+	struct console_device *cdev;
+	struct qt1070_data *data;
+	u8 fw_version, chip_id;
+	int ret;
+	char buf[6];
+
+	data = xzalloc(sizeof(*data));
+	data->client = to_i2c_client(dev);
+	data->irq_pin = -EINVAL;
+
+	ret = qt1070_read(data, QT1070_READ_CHIP_ID, &chip_id);
+	if (ret) {
+		dev_err(dev, "can not read chip id (%d)\n", ret);
+		goto err;
+	}
+
+	if (chip_id != QT1070_CHIP_ID) {
+		dev_err(dev, "unsupported id 0x%x\n", chip_id);
+		ret = -ENXIO;
+		goto err;
+	}
+
+	ret = qt1070_read(data, QT1070_FW_VERSION, &fw_version);
+	if (ret) {
+		dev_err(dev, "can not read firmware version (%d)\n", ret);
+		goto err;
+	}
+
+	sprintf(buf, "0x%x", fw_version);
+	dev_add_param_fixed(dev, "fw_version", buf);
+	sprintf(buf, "0x%x", chip_id);
+	dev_add_param_fixed(dev, "chip_ip", buf);
+
+	ret = qt1070_pdata_init(dev, data);
+	if (ret) {
+		dev_err(dev, "can not get pdata (%d)\n", ret);
+		goto err;
+	}
+
+	/* Calibrate device */
+	ret = qt1070_write(data, QT1070_CALIBRATE_CMD, 1);
+	if (ret) {
+		dev_err(dev, "can not calibrate the chip (%d)\n", ret);
+		goto err;
+	}
+	data->start = get_time_ns();
+
+	memcpy(data->code, default_code, sizeof(int) * ARRAY_SIZE(default_code));
+
+	data->fifo_size = 50;
+	data->recv_fifo = kfifo_alloc(data->fifo_size);
+
+	data->poller.func = qt1070_calibrate_poller;
+
+	cdev = &data->cdev;
+	cdev->dev = dev;
+	cdev->f_caps = CONSOLE_STDIN;
+	cdev->tstc = qt1070_tstc;
+	cdev->getc = qt1070_getc;
+
+	console_register(&data->cdev);
+
+	ret = poller_register(&data->poller);
+	if (ret)
+		goto err;
+
+	return 0;
+err:
+	free(data);
+	return ret;
+}
+
+static struct driver_d qt1070_driver = {
+	.name	= "qt1070",
+	.probe	= qt1070_probe,
+};
+
+static int qt1070_init(void)
+{
+	i2c_register_driver(&qt1070_driver);
+	return 0;
+}
+device_initcall(qt1070_init);
diff --git a/include/input/qt1070.h b/include/input/qt1070.h
new file mode 100644
index 0000000..014f67b
--- /dev/null
+++ b/include/input/qt1070.h
@@ -0,0 +1,18 @@
+/*
+ * Copyright (C) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
+ *
+ * Under GPLv2
+ */
+
+#ifndef __QT1070_H__
+#define __QT1070_H__
+
+#define QT1070_NB_BUTTONS	7
+
+struct qt1070_platform_data {
+	int code[QT1070_NB_BUTTONS];
+	int nb_code;
+	int irq_pin;
+};
+
+#endif /* __QT1070_H__ */
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Sat Nov  3 07:29:48 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Sat,  3 Nov 2012 12:29:48 +0100
Subject: [PATCH 1/1 v3] at91sam9x5ek: add i2c support
In-Reply-To: <1351795928-18677-1-git-send-email-plagnioj@jcrosoft.com>
References: <1351795928-18677-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1351942188-25775-1-git-send-email-plagnioj@jcrosoft.com>

enable qt1070 support

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
v3:

	provide irq_pin for qt1070
	and enable it by default

	branch updated

The following changes since commit 220c2476bc88b8297607ca0a3f8e2e3495da6edb:

  i2c: add versatile support (2012-11-03 04:09:17 +0800)

are available in the git repository at:

  git://git.jcrosoft.org/barebox.git delivery/at91_i2c

for you to fetch changes up to 5824ffb7201d38315a24fa4ba21124ffaf86068f:

  at91sam9x5ek: add i2c support (2012-11-03 04:09:55 +0800)

----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (7):
      at91sam9x5: add i2c support
      at91rm9200: add i2c support
      at91sam9260/sam9g20: add i2c support
      at91sam9263: add i2c support
      at91sam9261/sam9g10: add i2c support
      at91sam9g45: add i2c support
      at91sam9x5ek: add i2c support

 arch/arm/boards/at91sam9x5ek/init.c      |   21 ++++++++++++++++++++-
 arch/arm/configs/at91sam9x5ek_defconfig  |    5 ++++-
 arch/arm/mach-at91/at91rm9200_devices.c  |   28 ++++++++++++++++++++++++++++
 arch/arm/mach-at91/at91sam9260_devices.c |   32 ++++++++++++++++++++++++++++++++
 arch/arm/mach-at91/at91sam9261_devices.c |   31 +++++++++++++++++++++++++++++++
 arch/arm/mach-at91/at91sam9263_devices.c |   31 +++++++++++++++++++++++++++++++
 arch/arm/mach-at91/at91sam9g45_devices.c |   50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-at91/at91sam9x5_devices.c  |   58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-at91/include/mach/board.h  |    3 +++
 9 files changed, 257 insertions(+), 2 deletions(-)

Best Regards,
J.
 arch/arm/boards/at91sam9x5ek/init.c     |   21 ++++++++++++++++++++-
 arch/arm/configs/at91sam9x5ek_defconfig |    5 ++++-
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boards/at91sam9x5ek/init.c b/arch/arm/boards/at91sam9x5ek/init.c
index 78f7349..dbb9bb5 100644
--- a/arch/arm/boards/at91sam9x5ek/init.c
+++ b/arch/arm/boards/at91sam9x5ek/init.c
@@ -37,7 +37,7 @@
 #include <mach/at91_pmc.h>
 #include <mach/at91_rstc.h>
 #include <mach/at91sam9x5_matrix.h>
-#include <gpio_keys.h>
+#include <input/qt1070.h>
 #include <readkey.h>
 #include <linux/w1-gpio.h>
 #include <w1_mac_address.h>
@@ -114,6 +114,24 @@ static void ek_add_device_eth(void)
 	at91_add_device_eth(0, &macb_pdata);
 }
 
+struct qt1070_platform_data qt1070_pdata = {
+	.irq_pin	= AT91_PIN_PA7,
+};
+
+static struct i2c_board_info i2c_devices[] = {
+	{
+		.platform_data = &qt1070_pdata,
+		I2C_BOARD_INFO("qt1070", 0x1b),
+	},
+};
+
+static void ek_add_device_i2c(void)
+{
+	at91_set_gpio_input(qt1070_pdata.irq_pin, 0);
+	at91_set_deglitch(qt1070_pdata.irq_pin, 1);
+	at91_add_device_i2c(0, i2c_devices, ARRAY_SIZE(i2c_devices));
+}
+
 /*
  * USB Host port
  */
@@ -172,6 +190,7 @@ static int at91sam9x5ek_devices_init(void)
 	ek_add_device_eth();
 	at91_add_device_usbh_ohci(&ek_usbh_data);
 	ek_add_led();
+	ek_add_device_i2c();
 
 	armlinux_set_bootparams((void *)(AT91_CHIPSELECT_1 + 0x100));
 	armlinux_set_architecture(CONFIG_MACH_AT91SAM9X5EK);
diff --git a/arch/arm/configs/at91sam9x5ek_defconfig b/arch/arm/configs/at91sam9x5ek_defconfig
index 6315d9f..3e66c44 100644
--- a/arch/arm/configs/at91sam9x5ek_defconfig
+++ b/arch/arm/configs/at91sam9x5ek_defconfig
@@ -41,6 +41,7 @@ CONFIG_CMD_OFTREE=y
 CONFIG_CMD_TIMEOUT=y
 CONFIG_CMD_PARTITION=y
 CONFIG_CMD_GPIO=y
+CONFIG_CMD_I2C=y
 CONFIG_CMD_LED=y
 CONFIG_CMD_LED_TRIGGER=y
 CONFIG_NET=y
@@ -52,6 +53,8 @@ CONFIG_FS_TFTP=y
 CONFIG_NET_NETCONSOLE=y
 CONFIG_DRIVER_NET_MACB=y
 # CONFIG_SPI is not set
+CONFIG_I2C=y
+CONFIG_I2C_GPIO=y
 CONFIG_MTD=y
 CONFIG_NAND=y
 # CONFIG_NAND_ECC_HW is not set
@@ -64,7 +67,7 @@ CONFIG_DISK_WRITE=y
 CONFIG_LED=y
 CONFIG_LED_GPIO=y
 CONFIG_LED_TRIGGERS=y
-CONFIG_KEYBOARD_GPIO=y
+CONFIG_KEYBOARD_QT1070=y
 CONFIG_W1=y
 CONFIG_W1_MASTER_GPIO=y
 CONFIG_W1_SLAVE_DS2431=y
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Sat Nov  3 07:34:06 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Sat, 3 Nov 2012 12:34:06 +0100
Subject: [PATCH 0/4 v3] at91sam9x5ek: add spi and mci support
Message-ID: <20121103113406.GX29599@game.jcrosoft.org>

HI,
	v3: rebase on the v3 of at91sam9xek i2c support

	with this +1 patch serie the support of the at91sam9x5ek is mostly
	complete

	This will add spi and mci0 support as spi0 and mci0 conflict

	We are still missing framebuffer, usb host and device and hardware i2c support
	but this wil be added later

	This patch serie depedsn on the at91sam9x5ek i2c and m25p80 patcheries

	the correct version

	this one work but brake the etherent as it mux the 4 cs as gpio and we
	use them on the eth0

The following changes since commit b3a0963d358e14180e9bbde68ab78fdebae071b7:

  m25p80: sync flash support with the kernel (2012-11-03 04:23:15 +0800)

are available in the git repository at:

  git://git.jcrosoft.org/barebox.git delivery/at91sam9x5ek_mci_spi

for you to fetch changes up to dc7e1ce2a4ca879d07ba5786cfaa84f54d2ee763:

  at91sam9x5ek: add mci support (2012-11-03 04:23:48 +0800)

----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (4):
      at91sam9x5: add spi support
      at91sam9x5ek: add spi support
      at91sam9x5: add mci support
      at91sam9x5ek: add mci support

 arch/arm/boards/at91sam9x5ek/init.c     |   57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 arch/arm/configs/at91sam9x5ek_defconfig |   10 +++++++---
 arch/arm/mach-at91/at91sam9x5.c         |    4 ++++
 arch/arm/mach-at91/at91sam9x5_devices.c |  124 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 192 insertions(+), 3 deletions(-)

Best Regards,
J.


From plagnioj at jcrosoft.com  Sat Nov  3 07:36:30 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Sat,  3 Nov 2012 12:36:30 +0100
Subject: [PATCH 1/4] at91sam9x5: add spi support
In-Reply-To: <20121103113406.GX29599@game.jcrosoft.org>
References: <20121103113406.GX29599@game.jcrosoft.org>
Message-ID: <1351942593-26400-1-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/mach-at91/at91sam9x5.c         |    2 +
 arch/arm/mach-at91/at91sam9x5_devices.c |   62 +++++++++++++++++++++++++++++++
 2 files changed, 64 insertions(+)

diff --git a/arch/arm/mach-at91/at91sam9x5.c b/arch/arm/mach-at91/at91sam9x5.c
index c256989..a9065ff 100644
--- a/arch/arm/mach-at91/at91sam9x5.c
+++ b/arch/arm/mach-at91/at91sam9x5.c
@@ -205,6 +205,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
 	CLKDEV_CON_DEV_ID("macb_clk", "macb0", &macb0_clk),
 	CLKDEV_CON_DEV_ID("macb_clk", "macb1", &macb1_clk),
 	CLKDEV_CON_ID("ohci_clk", &uhphs_clk),
+	CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi0", &spi0_clk),
+	CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi1", &spi1_clk),
 };
 
 static struct clk_lookup usart_clocks_lookups[] = {
diff --git a/arch/arm/mach-at91/at91sam9x5_devices.c b/arch/arm/mach-at91/at91sam9x5_devices.c
index 5a24325..710ded7 100644
--- a/arch/arm/mach-at91/at91sam9x5_devices.c
+++ b/arch/arm/mach-at91/at91sam9x5_devices.c
@@ -228,6 +228,68 @@ void at91_add_device_i2c(short i2c_id, struct i2c_board_info *devices, int nr_de
 #endif
 
 /* --------------------------------------------------------------------
+ *  SPI
+ * -------------------------------------------------------------------- */
+
+#if defined(CONFIG_DRIVER_SPI_ATMEL)
+static unsigned spi0_standard_cs[4] = { AT91_PIN_PA14, AT91_PIN_PA7, AT91_PIN_PA1, AT91_PIN_PB3 };
+
+static unsigned spi1_standard_cs[4] = { AT91_PIN_PA8, AT91_PIN_PA0, AT91_PIN_PA31, AT91_PIN_PA30 };
+
+static struct at91_spi_platform_data spi_pdata[] = {
+	[0] = {
+		.chipselect = spi0_standard_cs,
+		.num_chipselect = ARRAY_SIZE(spi0_standard_cs),
+	},
+	[1] = {
+		.chipselect = spi1_standard_cs,
+		.num_chipselect = ARRAY_SIZE(spi1_standard_cs),
+	},
+};
+
+void at91_add_device_spi(int spi_id, struct at91_spi_platform_data *pdata)
+{
+	int i;
+	int cs_pin;
+	resource_size_t start = ~0;
+
+	BUG_ON(spi_id > 1);
+
+	if (!pdata)
+		pdata = &spi_pdata[spi_id];
+
+	for (i = 0; i < pdata->num_chipselect; i++) {
+		cs_pin = pdata->chipselect[i];
+
+		/* enable chip-select pin */
+		if (cs_pin > 0)
+			at91_set_gpio_output(cs_pin, 1);
+	}
+
+	/* Configure SPI bus(es) */
+	switch (spi_id) {
+	case 0:
+		start = AT91SAM9X5_BASE_SPI0;
+		at91_set_A_periph(AT91_PIN_PA11, 0);	/* SPI0_MISO */
+		at91_set_A_periph(AT91_PIN_PA12, 0);	/* SPI0_MOSI */
+		at91_set_A_periph(AT91_PIN_PA13, 0);	/* SPI0_SPCK */
+		break;
+	case 1:
+		start = AT91SAM9X5_BASE_SPI1;
+		at91_set_B_periph(AT91_PIN_PA21, 0);	/* SPI1_MISO */
+		at91_set_B_periph(AT91_PIN_PA22, 0);	/* SPI1_MOSI */
+		at91_set_B_periph(AT91_PIN_PA23, 0);	/* SPI1_SPCK */
+		break;
+	}
+
+	add_generic_device("atmel_spi", spi_id, NULL, start, SZ_16K,
+			   IORESOURCE_MEM, pdata);
+}
+#else
+void at91_add_device_spi(int spi_id, struct at91_spi_platform_data *pdata) {}
+#endif
+
+/* --------------------------------------------------------------------
  *  UART
  * -------------------------------------------------------------------- */
 
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Sat Nov  3 07:36:31 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Sat,  3 Nov 2012 12:36:31 +0100
Subject: [PATCH 2/4] at91sam9x5ek: add spi support
In-Reply-To: <1351942593-26400-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121103113406.GX29599@game.jcrosoft.org>
 <1351942593-26400-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1351942593-26400-2-git-send-email-plagnioj@jcrosoft.com>

on all the cpu module we have a at25 except on the cogent where we have a at45

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/boards/at91sam9x5ek/init.c     |   37 +++++++++++++++++++++++++++++++
 arch/arm/configs/at91sam9x5ek_defconfig |    5 ++++-
 2 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boards/at91sam9x5ek/init.c b/arch/arm/boards/at91sam9x5ek/init.c
index dbb9bb5..d97da2b 100644
--- a/arch/arm/boards/at91sam9x5ek/init.c
+++ b/arch/arm/boards/at91sam9x5ek/init.c
@@ -41,6 +41,7 @@
 #include <readkey.h>
 #include <linux/w1-gpio.h>
 #include <w1_mac_address.h>
+#include <spi/spi.h>
 
 #include "hw_version.h"
 
@@ -132,6 +133,41 @@ static void ek_add_device_i2c(void)
 	at91_add_device_i2c(0, i2c_devices, ARRAY_SIZE(i2c_devices));
 }
 
+static const struct spi_board_info ek_cm_cogent_spi_devices[] = {
+	{
+		.name		= "mtd_dataflash",
+		.chip_select	= 0,
+		.max_speed_hz	= 15 * 1000 * 1000,
+		.bus_num	= 0,
+	}
+};
+
+static const struct spi_board_info ek_spi_devices[] = {
+	{
+		.name		= "m25p80",
+		.chip_select	= 0,
+		.max_speed_hz	= 30 * 1000 * 1000,
+		.bus_num	= 0,
+	}
+};
+
+static unsigned spi0_standard_cs[] = { AT91_PIN_PA14};
+static struct at91_spi_platform_data spi_pdata = {
+	.chipselect = spi0_standard_cs,
+	.num_chipselect = ARRAY_SIZE(spi0_standard_cs),
+};
+
+static void ek_add_device_spi(void)
+{
+	if (at91sam9x5ek_cm_is_vendor(VENDOR_COGENT))
+		spi_register_board_info(ek_cm_cogent_spi_devices,
+				ARRAY_SIZE(ek_cm_cogent_spi_devices));
+	else
+		spi_register_board_info(ek_spi_devices,
+				ARRAY_SIZE(ek_spi_devices));
+	at91_add_device_spi(0, &spi_pdata);
+}
+
 /*
  * USB Host port
  */
@@ -188,6 +224,7 @@ static int at91sam9x5ek_devices_init(void)
 	ek_add_device_w1();
 	ek_add_device_nand();
 	ek_add_device_eth();
+	ek_add_device_spi();
 	at91_add_device_usbh_ohci(&ek_usbh_data);
 	ek_add_led();
 	ek_add_device_i2c();
diff --git a/arch/arm/configs/at91sam9x5ek_defconfig b/arch/arm/configs/at91sam9x5ek_defconfig
index 3e66c44..5b17002 100644
--- a/arch/arm/configs/at91sam9x5ek_defconfig
+++ b/arch/arm/configs/at91sam9x5ek_defconfig
@@ -52,10 +52,13 @@ CONFIG_CMD_TFTP=y
 CONFIG_FS_TFTP=y
 CONFIG_NET_NETCONSOLE=y
 CONFIG_DRIVER_NET_MACB=y
-# CONFIG_SPI is not set
+CONFIG_DRIVER_SPI_ATMEL=y
+CONFIG_MTD_M25P80=y
 CONFIG_I2C=y
 CONFIG_I2C_GPIO=y
 CONFIG_MTD=y
+# CONFIG_MTD_OOB_DEVICE is not set
+CONFIG_MTD_DATAFLASH=y
 CONFIG_NAND=y
 # CONFIG_NAND_ECC_HW is not set
 # CONFIG_NAND_ECC_HW_SYNDROME is not set
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Sat Nov  3 07:36:33 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Sat,  3 Nov 2012 12:36:33 +0100
Subject: [PATCH 4/4] at91sam9x5ek: add mci support
In-Reply-To: <1351942593-26400-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121103113406.GX29599@game.jcrosoft.org>
 <1351942593-26400-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1351942593-26400-4-git-send-email-plagnioj@jcrosoft.com>

only add mci0 (microSD slot) as mci1 conflict with spi0

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/boards/at91sam9x5ek/init.c     |   20 ++++++++++++++++++++
 arch/arm/configs/at91sam9x5ek_defconfig |    5 +++--
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boards/at91sam9x5ek/init.c b/arch/arm/boards/at91sam9x5ek/init.c
index d97da2b..4b3c099 100644
--- a/arch/arm/boards/at91sam9x5ek/init.c
+++ b/arch/arm/boards/at91sam9x5ek/init.c
@@ -115,6 +115,25 @@ static void ek_add_device_eth(void)
 	at91_add_device_eth(0, &macb_pdata);
 }
 
+/*
+ * MCI (SD/MMC)
+ */
+/* mci0 detect_pin is revision dependent */
+static struct atmel_mci_platform_data mci0_data = {
+	.bus_width	= 4,
+	.detect_pin	= AT91_PIN_PD15,
+	.wp_pin		= 0,
+};
+
+static void ek_add_device_mci(void)
+{
+	if (at91sam9x5ek_cm_is_vendor(VENDOR_COGENT))
+		mci0_data.detect_pin = 0;
+
+	/* MMC0 */
+	at91_add_device_mci(0, &mci0_data);
+}
+
 struct qt1070_platform_data qt1070_pdata = {
 	.irq_pin	= AT91_PIN_PA7,
 };
@@ -225,6 +244,7 @@ static int at91sam9x5ek_devices_init(void)
 	ek_add_device_nand();
 	ek_add_device_eth();
 	ek_add_device_spi();
+	ek_add_device_mci();
 	at91_add_device_usbh_ohci(&ek_usbh_data);
 	ek_add_led();
 	ek_add_device_i2c();
diff --git a/arch/arm/configs/at91sam9x5ek_defconfig b/arch/arm/configs/at91sam9x5ek_defconfig
index 5b17002..354cf08 100644
--- a/arch/arm/configs/at91sam9x5ek_defconfig
+++ b/arch/arm/configs/at91sam9x5ek_defconfig
@@ -65,8 +65,9 @@ CONFIG_NAND=y
 # CONFIG_NAND_ECC_HW_NONE is not set
 CONFIG_NAND_ATMEL=y
 CONFIG_UBI=y
-CONFIG_DISK=y
-CONFIG_DISK_WRITE=y
+CONFIG_MCI=y
+CONFIG_MCI_STARTUP=y
+CONFIG_MCI_ATMEL=y
 CONFIG_LED=y
 CONFIG_LED_GPIO=y
 CONFIG_LED_TRIGGERS=y
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Sat Nov  3 07:36:32 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Sat,  3 Nov 2012 12:36:32 +0100
Subject: [PATCH 3/4] at91sam9x5: add mci support
In-Reply-To: <1351942593-26400-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121103113406.GX29599@game.jcrosoft.org>
 <1351942593-26400-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1351942593-26400-3-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/mach-at91/at91sam9x5.c         |    2 +
 arch/arm/mach-at91/at91sam9x5_devices.c |   62 +++++++++++++++++++++++++++++++
 2 files changed, 64 insertions(+)

diff --git a/arch/arm/mach-at91/at91sam9x5.c b/arch/arm/mach-at91/at91sam9x5.c
index a9065ff..7c7d997 100644
--- a/arch/arm/mach-at91/at91sam9x5.c
+++ b/arch/arm/mach-at91/at91sam9x5.c
@@ -207,6 +207,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
 	CLKDEV_CON_ID("ohci_clk", &uhphs_clk),
 	CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi0", &spi0_clk),
 	CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi1", &spi1_clk),
+	CLKDEV_CON_DEV_ID("mci_clk", "atmel_mci0", &mmc0_clk),
+	CLKDEV_CON_DEV_ID("mci_clk", "atmel_mci1", &mmc1_clk),
 };
 
 static struct clk_lookup usart_clocks_lookups[] = {
diff --git a/arch/arm/mach-at91/at91sam9x5_devices.c b/arch/arm/mach-at91/at91sam9x5_devices.c
index 710ded7..14fcb1e 100644
--- a/arch/arm/mach-at91/at91sam9x5_devices.c
+++ b/arch/arm/mach-at91/at91sam9x5_devices.c
@@ -123,6 +123,68 @@ void at91_add_device_eth(int id, struct at91_ether_platform_data *data)
 void at91_add_device_eth(int id, struct at91_ether_platform_data *data) {}
 #endif
 
+#if defined(CONFIG_MCI_ATMEL)
+/* Consider only one slot : slot 0 */
+void __init at91_add_device_mci(short mmc_id, struct atmel_mci_platform_data *data)
+{
+	resource_size_t start = ~0;
+
+	if (!data)
+		return;
+
+	/* Must have at least one usable slot */
+	if (!data->bus_width)
+		return;
+
+	/* input/irq */
+	if (data->detect_pin) {
+		at91_set_gpio_input(data->detect_pin, 1);
+		at91_set_deglitch(data->detect_pin, 1);
+	}
+	if (data->wp_pin)
+		at91_set_gpio_input(data->wp_pin, 1);
+
+	if (mmc_id == 0) {		/* MCI0 */
+		start = AT91SAM9X5_BASE_MCI0;
+
+		/* CLK */
+		at91_set_A_periph(AT91_PIN_PA17, 0);
+
+		/* CMD */
+		at91_set_A_periph(AT91_PIN_PA16, 1);
+
+		/* DAT0, maybe DAT1..DAT3 */
+		at91_set_A_periph(AT91_PIN_PA15, 1);
+		if (data->bus_width == 4) {
+			at91_set_A_periph(AT91_PIN_PA18, 1);
+			at91_set_A_periph(AT91_PIN_PA19, 1);
+			at91_set_A_periph(AT91_PIN_PA20, 1);
+		}
+	} else {			/* MCI1 */
+		start = AT91SAM9X5_BASE_MCI1;
+
+		/* CLK */
+		at91_set_B_periph(AT91_PIN_PA13, 0);
+
+		/* CMD */
+		at91_set_B_periph(AT91_PIN_PA12, 1);
+
+		/* DAT0, maybe DAT1..DAT3 */
+		at91_set_B_periph(AT91_PIN_PA11, 1);
+		if (data->bus_width == 4) {
+			at91_set_B_periph(AT91_PIN_PA2, 1);
+			at91_set_B_periph(AT91_PIN_PA3, 1);
+			at91_set_B_periph(AT91_PIN_PA4, 1);
+		}
+	}
+
+	add_generic_device("atmel_mci", mmc_id, NULL, start, SZ_16K,
+			   IORESOURCE_MEM, data);
+}
+#else
+void __init at91_add_device_mci(short mmc_id, struct atmel_mci_platform_data *data) {}
+#endif
+
 /* --------------------------------------------------------------------
  *  NAND / SmartMedia
  * -------------------------------------------------------------------- */
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Sat Nov  3 10:56:38 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Sat,  3 Nov 2012 15:56:38 +0100
Subject: [PATCH 1/1] eth: register device a pure device
Message-ID: <1351954598-10541-1-git-send-email-plagnioj@jcrosoft.com>

as we do not need to probe them and they have no driver or bus attached

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 net/eth.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/eth.c b/net/eth.c
index 2cfdb96..0a1850f 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -261,7 +261,7 @@ int eth_register(struct eth_device *edev)
 	if (edev->parent)
 		dev_add_child(edev->parent, &edev->dev);
 
-	platform_device_register(&edev->dev);
+	register_device(&edev->dev);
 
 	dev_add_param(dev, "ipaddr", eth_set_ipaddr, NULL, 0);
 	dev_add_param(dev, "ethaddr", eth_set_ethaddr, NULL, 0);
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Sat Nov  3 11:08:23 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Sat, 3 Nov 2012 16:08:23 +0100
Subject: [PATCH 0/2 v2] add bus device
Message-ID: <20121103150823.GY29599@game.jcrosoft.org>

Hi,

The following changes since commit 37b37cb2bff79f4edbbcaf316149d814e11a358e:

  eth: register device a pure device (2012-11-03 07:48:12 +0800)

are available in the git repository at:

  git://git.jcrosoft.org/barebox.git tags/bus_device

for you to fetch changes up to 35f8933bf003b5049131487882d8ae57a1a50d3a:

  bus: add bus device (2012-11-03 07:52:49 +0800)

----------------------------------------------------------------
add bus device

This patch serie add a pure device for each bus

And set this device to each bus device as a parent if the device
does not have a parent already

we have now a nice output per bus

barebox at Atmel at91sam9x5-ek:/
devices:
`---- platform
     `---- atmel_usart0
          `---- cs0
     `---- atmel_usart1
          `---- cs1
     `---- mem0
          `---- 0x00000000-0x07ffffff: /dev/ram0
     `---- mem1
          `---- 0x00000000-0x00007fff: /dev/sram0
     `---- mem2
          `---- 0x00000000-0x000037bf: /dev/defaultenv
     `---- mem3
          `---- 0x00000000-0xfffffffe: /dev/mem
     `---- cs2
     `---- w1-gpio
          `---- w1_bus0
               `---- w1-2d-0
                    `---- 0x00000000-0x0000007f: /dev/ds24310
               `---- w1-2d-1
                    `---- 0x00000000-0x0000007f: /dev/ds24311
               `---- w1-23-0
                    `---- 0x00000000-0x000001ff: /dev/ds24330
     `---- at91sam9x5cm
     `---- at91sam9x5ek
     `---- at91sam9x5dm
     `---- atmel_nand0
          `---- nand0
               `---- 0x00000000-0x1fffffff: /dev/nand0
               `---- 0x00000000-0x0003ffff: /dev/at91bootstrap_raw
               `---- 0x00040000-0x0009ffff: /dev/self_raw
               `---- 0x000a0000-0x000bffff: /dev/env_raw
               `---- 0x000c0000-0x000dffff: /dev/env_raw1
               `---- 0x00000000-0x0003ffff: /dev/nand0.at91bootstrap
               `---- 0x00040000-0x0009ffff: /dev/nand0.barebox
               `---- 0x000a0000-0x000bffff: /dev/nand0.bareboxenv
               `---- 0x000c0000-0x000dffff: /dev/nand0.bareboxenv2
               `---- 0x000e0000-0x000fffff: /dev/nand0.oftree
               `---- 0x00100000-0x001fffff: /dev/nand0.free
               `---- 0x00200000-0x007fffff: /dev/nand0.kernel
               `---- 0x00800000-0x07ffffff: /dev/nand0.rootfs
               `---- 0x08000000-0x1fffffff: /dev/nand0.data
     `---- macb0
          `---- miibus0
          `---- eth0
     `---- atmel_spi0
          `---- mtd_dataflash0
                    `---- 0x00000000-0x0041ffff: /dev/dataflash0
     `---- atmel_mci0
          `---- mci0
               `---- 0x00000000-0x1d9bfffff: /dev/disk0
               `---- 0x00100000-0x064fffff: /dev/disk0.0
               `---- 0x06500000-0x1d9bfffff: /dev/disk0.1
     `---- i2c-gpio0
          `---- i2c0
               `---- qt10700
                    `---- cs3
`---- mdio_bus
`---- spi
`---- i2c
`---- w1_bus
`---- fs
     `---- ramfs0
     `---- devfs0
`---- net
`---- global

drivers:
atmel_usart
ramfs
devfs
fat
macb
Generic PHY
atmel_nand
mtd_dataflash
m25p80
atmel_spi
i2c-gpio
mci
atmel_mci
qt1070
w1-gpio
ds2431
ds2433
mem

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>

----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (2):
      bus_for_each_device/bus_for_each_driver: add () to allow use &bus
      bus: add bus device

 drivers/base/bus.c    |   10 ++++++++++
 drivers/base/driver.c |    5 +++++
 include/driver.h      |    6 ++++--
 3 files changed, 19 insertions(+), 2 deletions(-)

Best Regards,
J.


From plagnioj at jcrosoft.com  Sat Nov  3 11:11:04 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Sat,  3 Nov 2012 16:11:04 +0100
Subject: [PATCH 1/2] bus_for_each_device/bus_for_each_driver: add () to allow
 use &bus
In-Reply-To: <20121103150823.GY29599@game.jcrosoft.org>
References: <20121103150823.GY29599@game.jcrosoft.org>
Message-ID: <1351955465-12206-1-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 include/driver.h |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/driver.h b/include/driver.h
index 4918054..dd22c77 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -393,11 +393,11 @@ extern struct list_head bus_list;
 
 /* Iterate over all devices of a bus
  */
-#define bus_for_each_device(bus, dev) list_for_each_entry(dev, &bus->device_list, bus_list)
+#define bus_for_each_device(bus, dev) list_for_each_entry(dev, &(bus)->device_list, bus_list)
 
 /* Iterate over all drivers of a bus
  */
-#define bus_for_each_driver(bus, drv) list_for_each_entry(drv, &bus->driver_list, bus_list)
+#define bus_for_each_driver(bus, drv) list_for_each_entry(drv, &(bus)->driver_list, bus_list)
 
 extern struct bus_type platform_bus;
 
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Sat Nov  3 11:11:05 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Sat,  3 Nov 2012 16:11:05 +0100
Subject: [PATCH 2/2] bus: add bus device
In-Reply-To: <1351955465-12206-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121103150823.GY29599@game.jcrosoft.org>
 <1351955465-12206-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1351955465-12206-2-git-send-email-plagnioj@jcrosoft.com>

automatically add it as parent of any bus device if none already specified

we have now a nice output per bus

barebox at Atmel at91sam9x5-ek:/
devices:
`---- platform
     `---- atmel_usart0
          `---- cs0
     `---- atmel_usart1
          `---- cs1
     `---- mem0
          `---- 0x00000000-0x07ffffff: /dev/ram0
     `---- mem1
          `---- 0x00000000-0x00007fff: /dev/sram0
     `---- mem2
          `---- 0x00000000-0x000037bf: /dev/defaultenv
     `---- mem3
          `---- 0x00000000-0xfffffffe: /dev/mem
     `---- cs2
     `---- w1-gpio
          `---- w1_bus0
               `---- w1-2d-0
                    `---- 0x00000000-0x0000007f: /dev/ds24310
               `---- w1-2d-1
                    `---- 0x00000000-0x0000007f: /dev/ds24311
               `---- w1-23-0
                    `---- 0x00000000-0x000001ff: /dev/ds24330
     `---- at91sam9x5cm
     `---- at91sam9x5ek
     `---- at91sam9x5dm
     `---- atmel_nand0
          `---- nand0
               `---- 0x00000000-0x1fffffff: /dev/nand0
               `---- 0x00000000-0x0003ffff: /dev/at91bootstrap_raw
               `---- 0x00040000-0x0009ffff: /dev/self_raw
               `---- 0x000a0000-0x000bffff: /dev/env_raw
               `---- 0x000c0000-0x000dffff: /dev/env_raw1
               `---- 0x00000000-0x0003ffff: /dev/nand0.at91bootstrap
               `---- 0x00040000-0x0009ffff: /dev/nand0.barebox
               `---- 0x000a0000-0x000bffff: /dev/nand0.bareboxenv
               `---- 0x000c0000-0x000dffff: /dev/nand0.bareboxenv2
               `---- 0x000e0000-0x000fffff: /dev/nand0.oftree
               `---- 0x00100000-0x001fffff: /dev/nand0.free
               `---- 0x00200000-0x007fffff: /dev/nand0.kernel
               `---- 0x00800000-0x07ffffff: /dev/nand0.rootfs
               `---- 0x08000000-0x1fffffff: /dev/nand0.data
     `---- macb0
          `---- miibus0
          `---- eth0
     `---- atmel_spi0
          `---- mtd_dataflash0
               `---- dataflash0
                    `---- 0x00000000-0x0041ffff: /dev/dataflash0
     `---- atmel_mci0
          `---- mci0
               `---- 0x00000000-0x1d9bfffff: /dev/disk0
               `---- 0x00100000-0x064fffff: /dev/disk0.0
               `---- 0x06500000-0x1d9bfffff: /dev/disk0.1
     `---- i2c-gpio0
          `---- i2c0
               `---- qt10700
                    `---- cs3
`---- mdio_bus
`---- spi
`---- i2c
`---- w1_bus
`---- fs
     `---- ramfs0
     `---- devfs0
`---- net
`---- global

drivers:
atmel_usart
ramfs
devfs
fat
macb
Generic PHY
atmel_nand
mtd_dataflash
m25p80
atmel_spi
i2c-gpio
mci
atmel_mci
qt1070
w1-gpio
ds2431
ds2433
mem

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/base/bus.c    |   10 ++++++++++
 drivers/base/driver.c |    5 +++++
 include/driver.h      |    2 ++
 3 files changed, 17 insertions(+)

diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 69782d2..e2204da 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -25,9 +25,19 @@ static struct bus_type *get_bus_by_name(const char *name)
 
 int bus_register(struct bus_type *bus)
 {
+	int ret;
+
 	if (get_bus_by_name(bus->name))
 		return -EEXIST;
 
+	strcpy(bus->dev.name, bus->name);
+	bus->dev.id = DEVICE_ID_SINGLE;
+
+	ret = register_device(&bus->dev);
+	if (ret)
+		return ret;
+
+
 	INIT_LIST_HEAD(&bus->device_list);
 	INIT_LIST_HEAD(&bus->driver_list);
 
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 64fe289..eaedac7 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -120,6 +120,11 @@ int register_device(struct device_d *new_device)
 	if (!new_device->bus)
 		return 0;
 
+	if (!new_device->parent) {
+		new_device->parent = &new_device->bus->dev;
+		dev_add_child(new_device->parent, new_device);
+	}
+
 	list_add_tail(&new_device->bus_list, &new_device->bus->device_list);
 
 	bus_for_each_driver(new_device->bus, drv) {
diff --git a/include/driver.h b/include/driver.h
index dd22c77..5d433ec 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -378,6 +378,8 @@ struct bus_type {
 	int (*probe)(struct device_d *dev);
 	void (*remove)(struct device_d *dev);
 
+	struct device_d dev;
+
 	struct list_head list;
 	struct list_head device_list;
 	struct list_head driver_list;
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Sat Nov  3 16:46:13 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Sat, 3 Nov 2012 21:46:13 +0100
Subject: [PATCH 0/3] i2c fix + prepare for at24 support
Message-ID: <20121103204613.GZ29599@game.jcrosoft.org>

HI,

	algo-bit: fix sequential read/write support

	i2c: add id_table support
	i2c: add i2c_new_dummy

	This prepare for the at24 eeprom support

The following changes since commit 5c90416b6ffb8d4ca7c4bc6aff92578b555cb965:

  i2c: add versatile support (2012-11-02 02:17:04 +0800)

are available in the git repository at:

  git://git.jcrosoft.org/barebox.git delivery/i2c

for you to fetch changes up to 5526278ac77ecd7109c9c1bbc35d7c74875902e7:

  i2c: add id_table support (2012-11-03 13:33:54 +0800)

----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (3):
      i2c: algo-bit add missing acknak
      i2c: introduce i2c_new_dummy
      i2c: add id_table support

 drivers/i2c/algos/i2c-algo-bit.c |   20 ++++++++++++++++++++
 drivers/i2c/i2c.c                |   45 ++++++++++++++++++++++++++++++++++++++++++++-
 include/i2c/i2c.h                |    8 ++++++++
 3 files changed, 72 insertions(+), 1 deletion(-)

Best Regards,
J.


From plagnioj at jcrosoft.com  Sat Nov  3 16:53:07 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Sat,  3 Nov 2012 21:53:07 +0100
Subject: [PATCH 1/3] i2c: algo-bit add missing acknak
In-Reply-To: <20121103204613.GZ29599@game.jcrosoft.org>
References: <20121103204613.GZ29599@game.jcrosoft.org>
Message-ID: <1351975989-8218-1-git-send-email-plagnioj@jcrosoft.com>

This is need for sequential read/write.

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/i2c/algos/i2c-algo-bit.c |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/i2c/algos/i2c-algo-bit.c b/drivers/i2c/algos/i2c-algo-bit.c
index 37af27c..dc43eb8 100644
--- a/drivers/i2c/algos/i2c-algo-bit.c
+++ b/drivers/i2c/algos/i2c-algo-bit.c
@@ -390,6 +390,22 @@ static int sendbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg)
 	return wrcount;
 }
 
+static int acknak(struct i2c_adapter *i2c_adap, int is_ack)
+{
+	struct i2c_algo_bit_data *adap = i2c_adap->algo_data;
+
+	/* assert: sda is high */
+	if (is_ack)		/* send ack */
+		setsda(adap, 0);
+	udelay((adap->udelay + 1) / 2);
+	if (sclhi(adap) < 0) {	/* timeout */
+		dev_err(&i2c_adap->dev, "readbytes: ack/nak timeout\n");
+		return -ETIMEDOUT;
+	}
+	scllo(adap);
+	return 0;
+}
+
 static int readbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg)
 {
 	int inval;
@@ -414,6 +430,10 @@ static int readbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg)
 			(flags & I2C_M_NO_RD_ACK)
 				? "(no ack/nak)"
 				: (count ? "A" : "NA"));
+
+		inval = acknak(i2c_adap, count);
+		if (inval < 0)
+			return inval;
 	}
 	return rdcount;
 }
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Sat Nov  3 16:53:09 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Sat,  3 Nov 2012 21:53:09 +0100
Subject: [PATCH 3/3] i2c: add id_table support
In-Reply-To: <1351975989-8218-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121103204613.GZ29599@game.jcrosoft.org>
 <1351975989-8218-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1351975989-8218-3-git-send-email-plagnioj@jcrosoft.com>

this will be use by at24 driver

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/i2c/i2c.c |   17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/i2c.c b/drivers/i2c/i2c.c
index 92d9442..94f23dd 100644
--- a/drivers/i2c/i2c.c
+++ b/drivers/i2c/i2c.c
@@ -420,7 +420,22 @@ EXPORT_SYMBOL(i2c_add_numbered_adapter);
 
 static int i2c_match(struct device_d *dev, struct driver_d *drv)
 {
-	return strcmp(dev->name, drv->name) ? -1 : 0;
+	if (!strcmp(dev->name, drv->name))
+		return 0;
+
+	if (drv->id_table) {
+		struct platform_device_id *id = drv->id_table;
+
+		while (id->name) {
+			if (!strcmp(id->name, dev->name)) {
+				dev->id_entry = id;
+				return 0;
+			}
+			id++;
+		}
+	}
+
+	return -1;
 }
 
 static int i2c_probe(struct device_d *dev)
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Sat Nov  3 16:53:08 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Sat,  3 Nov 2012 21:53:08 +0100
Subject: [PATCH 2/3] i2c: introduce i2c_new_dummy
In-Reply-To: <1351975989-8218-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121103204613.GZ29599@game.jcrosoft.org>
 <1351975989-8218-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1351975989-8218-2-git-send-email-plagnioj@jcrosoft.com>

This returns an I2C client bound to the "dummy" driver, intended for use
with devices that consume multiple addresses.  Examples of such chips
include various EEPROMS (like 24c04 and 24c08 models).

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/i2c/i2c.c |   28 ++++++++++++++++++++++++++++
 include/i2c/i2c.h |    8 ++++++++
 2 files changed, 36 insertions(+)

diff --git a/drivers/i2c/i2c.c b/drivers/i2c/i2c.c
index 3af5c32..92d9442 100644
--- a/drivers/i2c/i2c.c
+++ b/drivers/i2c/i2c.c
@@ -282,6 +282,34 @@ struct i2c_client *i2c_new_device(struct i2c_adapter *adapter,
 EXPORT_SYMBOL(i2c_new_device);
 
 /**
+ * i2c_new_dummy - return a new i2c device bound to a dummy driver
+ * @adapter: the adapter managing the device
+ * @address: seven bit address to be used
+ * Context: can sleep
+ *
+ * This returns an I2C client bound to the "dummy" driver, intended for use
+ * with devices that consume multiple addresses.  Examples of such chips
+ * include various EEPROMS (like 24c04 and 24c08 models).
+ *
+ * These dummy devices have two main uses.  First, most I2C and SMBus calls
+ * except i2c_transfer() need a client handle; the dummy will be that handle.
+ * And second, this prevents the specified address from being bound to a
+ * different driver.
+ *
+ * This returns the new i2c client, which should be saved for later use with
+ * i2c_unregister_device(); or NULL to indicate an error.
+ */
+struct i2c_client *i2c_new_dummy(struct i2c_adapter *adapter, u16 address)
+{
+	struct i2c_board_info info = {
+		I2C_BOARD_INFO("dummy", address),
+	};
+
+	return i2c_new_device(adapter, &info);
+}
+EXPORT_SYMBOL_GPL(i2c_new_dummy);
+
+/**
  * i2c_register_board_info - register I2C devices for a given board
  *
  * @param	info	array of chip descriptors
diff --git a/include/i2c/i2c.h b/include/i2c/i2c.h
index b059119..dc5e5fc 100644
--- a/include/i2c/i2c.h
+++ b/include/i2c/i2c.h
@@ -129,6 +129,14 @@ static inline int i2c_register_board_info(int busnum,
 extern int i2c_add_numbered_adapter(struct i2c_adapter *adapter);
 struct i2c_adapter *i2c_get_adapter(int busnum);
 
+/* For devices that use several addresses, use i2c_new_dummy() to make
+ * client handles for the extra addresses.
+ */
+extern struct i2c_client *
+i2c_new_dummy(struct i2c_adapter *adap, u16 address);
+
+
+
 extern int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num);
 extern int i2c_master_send(struct i2c_client *client, const char *buf, int count);
 extern int i2c_master_recv(struct i2c_client *client, char *buf, int count);
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Sat Nov  3 16:56:55 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Sat, 3 Nov 2012 21:56:55 +0100
Subject: [PATCH 0/3] i2c: add at24 eeprom support
Message-ID: <20121103205655.GA29599@game.jcrosoft.org>

HI,

	this patch serie add the at24 eeprom support based on linux 3.6

	the depends on the i2c prepare 1t24 support patch series

The following changes since commit 5526278ac77ecd7109c9c1bbc35d7c74875902e7:

  i2c: add id_table support (2012-11-03 13:33:54 +0800)

are available in the git repository at:

  git://git.jcrosoft.org/barebox.git delivery/at24

for you to fetch changes up to fe6968e20c39461df068d5cc15869012be4a3161:

  eeprom: add at24 support (2012-11-03 13:46:50 +0800)

----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (3):
      import log2 support from linux
      add roundup and rounddown support
      eeprom: add at24 support

 drivers/eeprom/Kconfig  |   19 ++++++++++
 drivers/eeprom/Makefile |    1 +
 drivers/eeprom/at24.c   |  460 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/i2c/at24.h      |   35 +++++++++++++++++++
 include/linux/kernel.h  |   15 ++++++++
 include/linux/log2.h    |  190 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 720 insertions(+)
 create mode 100644 drivers/eeprom/at24.c
 create mode 100644 include/i2c/at24.h
 create mode 100644 include/linux/log2.h

Best Regards,
J.


From plagnioj at jcrosoft.com  Sat Nov  3 16:58:29 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Sat,  3 Nov 2012 21:58:29 +0100
Subject: [PATCH 2/3] add roundup and rounddown support
In-Reply-To: <1351976310-9312-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121103205655.GA29599@game.jcrosoft.org>
 <1351976310-9312-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1351976310-9312-2-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 include/linux/kernel.h |   15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index e9e2f07..92c3391 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -90,5 +90,20 @@
 	__val = __val < __min ? __min: __val;	\
 	__val > __max ? __max: __val; })
 
+
+/* The `const' in roundup() prevents gcc-3.3 from calling __divdi3 */
+#define roundup(x, y) (					\
+{							\
+	const typeof(y) __y = y;			\
+	(((x) + (__y - 1)) / __y) * __y;		\
+}							\
+)
+#define rounddown(x, y) (				\
+{							\
+	typeof(x) __x = (x);				\
+	__x - (__x % (y));				\
+}							\
+)
+
 #endif /* _LINUX_KERNEL_H */
 
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Sat Nov  3 16:58:28 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Sat,  3 Nov 2012 21:58:28 +0100
Subject: [PATCH 1/3] import log2 support from linux
In-Reply-To: <20121103205655.GA29599@game.jcrosoft.org>
References: <20121103205655.GA29599@game.jcrosoft.org>
Message-ID: <1351976310-9312-1-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 include/linux/log2.h |  190 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 190 insertions(+)
 create mode 100644 include/linux/log2.h

diff --git a/include/linux/log2.h b/include/linux/log2.h
new file mode 100644
index 0000000..389043a
--- /dev/null
+++ b/include/linux/log2.h
@@ -0,0 +1,190 @@
+/* Integer base 2 logarithm calculation
+ *
+ * Copyright (C) 2006 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowells at redhat.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#ifndef _LINUX_LOG2_H
+#define _LINUX_LOG2_H
+
+#include <linux/types.h>
+#include <linux/bitops.h>
+
+/*
+ * deal with unrepresentable constant logarithms
+ */
+extern __attribute__((const, noreturn))
+int ____ilog2_NaN(void);
+
+/*
+ * non-constant log of base 2 calculators
+ * - the arch may override these in asm/bitops.h if they can be implemented
+ *   more efficiently than using fls() and fls64()
+ * - the arch is not required to handle n==0 if implementing the fallback
+ */
+#ifndef CONFIG_ARCH_HAS_ILOG2_U32
+static inline __attribute__((const))
+int __ilog2_u32(u32 n)
+{
+	return fls(n) - 1;
+}
+#endif
+
+#ifndef CONFIG_ARCH_HAS_ILOG2_U64
+static inline __attribute__((const))
+int __ilog2_u64(u64 n)
+{
+	return fls64(n) - 1;
+}
+#endif
+
+/*
+ *  Determine whether some value is a power of two, where zero is
+ * *not* considered a power of two.
+ */
+
+static inline __attribute__((const))
+bool is_power_of_2(unsigned long n)
+{
+	return (n != 0 && ((n & (n - 1)) == 0));
+}
+
+/**
+ * ilog2 - log of base 2 of 32-bit or a 64-bit unsigned value
+ * @n - parameter
+ *
+ * constant-capable log of base 2 calculation
+ * - this can be used to initialise global variables from constant data, hence
+ *   the massive ternary operator construction
+ *
+ * selects the appropriately-sized optimised version depending on sizeof(n)
+ */
+#define ilog2(n)				\
+(						\
+	__builtin_constant_p(n) ? (		\
+		(n) < 1 ? ____ilog2_NaN() :	\
+		(n) & (1ULL << 63) ? 63 :	\
+		(n) & (1ULL << 62) ? 62 :	\
+		(n) & (1ULL << 61) ? 61 :	\
+		(n) & (1ULL << 60) ? 60 :	\
+		(n) & (1ULL << 59) ? 59 :	\
+		(n) & (1ULL << 58) ? 58 :	\
+		(n) & (1ULL << 57) ? 57 :	\
+		(n) & (1ULL << 56) ? 56 :	\
+		(n) & (1ULL << 55) ? 55 :	\
+		(n) & (1ULL << 54) ? 54 :	\
+		(n) & (1ULL << 53) ? 53 :	\
+		(n) & (1ULL << 52) ? 52 :	\
+		(n) & (1ULL << 51) ? 51 :	\
+		(n) & (1ULL << 50) ? 50 :	\
+		(n) & (1ULL << 49) ? 49 :	\
+		(n) & (1ULL << 48) ? 48 :	\
+		(n) & (1ULL << 47) ? 47 :	\
+		(n) & (1ULL << 46) ? 46 :	\
+		(n) & (1ULL << 45) ? 45 :	\
+		(n) & (1ULL << 44) ? 44 :	\
+		(n) & (1ULL << 43) ? 43 :	\
+		(n) & (1ULL << 42) ? 42 :	\
+		(n) & (1ULL << 41) ? 41 :	\
+		(n) & (1ULL << 40) ? 40 :	\
+		(n) & (1ULL << 39) ? 39 :	\
+		(n) & (1ULL << 38) ? 38 :	\
+		(n) & (1ULL << 37) ? 37 :	\
+		(n) & (1ULL << 36) ? 36 :	\
+		(n) & (1ULL << 35) ? 35 :	\
+		(n) & (1ULL << 34) ? 34 :	\
+		(n) & (1ULL << 33) ? 33 :	\
+		(n) & (1ULL << 32) ? 32 :	\
+		(n) & (1ULL << 31) ? 31 :	\
+		(n) & (1ULL << 30) ? 30 :	\
+		(n) & (1ULL << 29) ? 29 :	\
+		(n) & (1ULL << 28) ? 28 :	\
+		(n) & (1ULL << 27) ? 27 :	\
+		(n) & (1ULL << 26) ? 26 :	\
+		(n) & (1ULL << 25) ? 25 :	\
+		(n) & (1ULL << 24) ? 24 :	\
+		(n) & (1ULL << 23) ? 23 :	\
+		(n) & (1ULL << 22) ? 22 :	\
+		(n) & (1ULL << 21) ? 21 :	\
+		(n) & (1ULL << 20) ? 20 :	\
+		(n) & (1ULL << 19) ? 19 :	\
+		(n) & (1ULL << 18) ? 18 :	\
+		(n) & (1ULL << 17) ? 17 :	\
+		(n) & (1ULL << 16) ? 16 :	\
+		(n) & (1ULL << 15) ? 15 :	\
+		(n) & (1ULL << 14) ? 14 :	\
+		(n) & (1ULL << 13) ? 13 :	\
+		(n) & (1ULL << 12) ? 12 :	\
+		(n) & (1ULL << 11) ? 11 :	\
+		(n) & (1ULL << 10) ? 10 :	\
+		(n) & (1ULL <<  9) ?  9 :	\
+		(n) & (1ULL <<  8) ?  8 :	\
+		(n) & (1ULL <<  7) ?  7 :	\
+		(n) & (1ULL <<  6) ?  6 :	\
+		(n) & (1ULL <<  5) ?  5 :	\
+		(n) & (1ULL <<  4) ?  4 :	\
+		(n) & (1ULL <<  3) ?  3 :	\
+		(n) & (1ULL <<  2) ?  2 :	\
+		(n) & (1ULL <<  1) ?  1 :	\
+		(n) & (1ULL <<  0) ?  0 :	\
+		____ilog2_NaN()			\
+				   ) :		\
+	(sizeof(n) <= 4) ?			\
+	__ilog2_u32(n) :			\
+	__ilog2_u64(n)				\
+ )
+
+/**
+ * roundup_pow_of_two - round the given value up to nearest power of two
+ * @n - parameter
+ *
+ * round the given value up to the nearest power of two
+ * - the result is undefined when n == 0
+ * - this can be used to initialise global variables from constant data
+ */
+#define roundup_pow_of_two(n)			\
+(						\
+	__builtin_constant_p(n) ? (		\
+		(n == 1) ? 1 :			\
+		(1UL << (ilog2((n) - 1) + 1))	\
+				   ) :		\
+	__roundup_pow_of_two(n)			\
+ )
+
+/**
+ * rounddown_pow_of_two - round the given value down to nearest power of two
+ * @n - parameter
+ *
+ * round the given value down to the nearest power of two
+ * - the result is undefined when n == 0
+ * - this can be used to initialise global variables from constant data
+ */
+#define rounddown_pow_of_two(n)			\
+(						\
+	__builtin_constant_p(n) ? (		\
+		(1UL << ilog2(n))) :		\
+	__rounddown_pow_of_two(n)		\
+ )
+
+/**
+ * order_base_2 - calculate the (rounded up) base 2 order of the argument
+ * @n: parameter
+ *
+ * The first few values calculated by this routine:
+ *  ob2(0) = 0
+ *  ob2(1) = 0
+ *  ob2(2) = 1
+ *  ob2(3) = 2
+ *  ob2(4) = 2
+ *  ob2(5) = 3
+ *  ... and so on.
+ */
+
+#define order_base_2(n) ilog2(roundup_pow_of_two(n))
+
+#endif /* _LINUX_LOG2_H */
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Sat Nov  3 16:58:30 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Sat,  3 Nov 2012 21:58:30 +0100
Subject: [PATCH 3/3] eeprom: add at24 support
In-Reply-To: <1351976310-9312-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121103205655.GA29599@game.jcrosoft.org>
 <1351976310-9312-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1351976310-9312-3-git-send-email-plagnioj@jcrosoft.com>

This driver to get read/write support to most I2C EEPROMs,
after you configure the driver to know about each EEPROM on
your target board.  Use these generic chip names, instead of
vendor-specific ones like at24c64 or 24lc02:

   24c00, 24c01, 24c02, spd (readonly 24c02), 24c04, 24c08,
   24c16, 24c32, 24c64, 24c128, 24c256, 24c512, 24c1024

Unless you like data loss puzzles, always be sure that any chip
you configure as a 24c32 (32 kbit) or larger is NOT really a
24c16 (16 kbit) or smaller, and vice versa. Marking the chip
as read-only won't help recover from this. Also, if your chip
has any software write-protect mechanism you may want to review the
code to make sure this driver won't turn it on by accident.

Based on linux 3.6

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/eeprom/Kconfig  |   19 ++
 drivers/eeprom/Makefile |    1 +
 drivers/eeprom/at24.c   |  460 +++++++++++++++++++++++++++++++++++++++++++++++
 include/i2c/at24.h      |   35 ++++
 4 files changed, 515 insertions(+)
 create mode 100644 drivers/eeprom/at24.c
 create mode 100644 include/i2c/at24.h

diff --git a/drivers/eeprom/Kconfig b/drivers/eeprom/Kconfig
index a0b5489..ce9cfe7 100644
--- a/drivers/eeprom/Kconfig
+++ b/drivers/eeprom/Kconfig
@@ -8,4 +8,23 @@ config EEPROM_AT25
 	  after you configure the board init code to know about each eeprom
 	  on your target board.
 
+config EEPROM_AT24
+	bool "at24 based eeprom"
+	depends on I2C
+	help
+	  Enable this driver to get read/write support to most I2C EEPROMs,
+	  after you configure the driver to know about each EEPROM on
+	  your target board.  Use these generic chip names, instead of
+	  vendor-specific ones like at24c64 or 24lc02:
+
+	     24c00, 24c01, 24c02, spd (readonly 24c02), 24c04, 24c08,
+	     24c16, 24c32, 24c64, 24c128, 24c256, 24c512, 24c1024
+
+	  Unless you like data loss puzzles, always be sure that any chip
+	  you configure as a 24c32 (32 kbit) or larger is NOT really a
+	  24c16 (16 kbit) or smaller, and vice versa. Marking the chip
+	  as read-only won't help recover from this. Also, if your chip
+	  has any software write-protect mechanism you may want to review the
+	  code to make sure this driver won't turn it on by accident.
+
 endmenu
diff --git a/drivers/eeprom/Makefile b/drivers/eeprom/Makefile
index e323bd0..e287eb0 100644
--- a/drivers/eeprom/Makefile
+++ b/drivers/eeprom/Makefile
@@ -1 +1,2 @@
 obj-$(CONFIG_EEPROM_AT25)	+= at25.o
+obj-$(CONFIG_EEPROM_AT24)	+= at24.o
diff --git a/drivers/eeprom/at24.c b/drivers/eeprom/at24.c
new file mode 100644
index 0000000..6f0133a
--- /dev/null
+++ b/drivers/eeprom/at24.c
@@ -0,0 +1,460 @@
+/*
+ * at24.c - handle most I2C EEPROMs
+ *
+ * Copyright (C) 2005-2007 David Brownell
+ * Copyright (C) 2008 Wolfram Sang, Pengutronix
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include <common.h>
+#include <init.h>
+#include <malloc.h>
+#include <clock.h>
+#include <driver.h>
+#include <xfuncs.h>
+#include <errno.h>
+#include <linux/math64.h>
+#include <linux/log2.h>
+#include <i2c/i2c.h>
+#include <i2c/at24.h>
+
+/*
+ * I2C EEPROMs from most vendors are inexpensive and mostly interchangeable.
+ * Differences between different vendor product lines (like Atmel AT24C or
+ * MicroChip 24LC, etc) won't much matter for typical read/write access.
+ * There are also I2C RAM chips, likewise interchangeable. One example
+ * would be the PCF8570, which acts like a 24c02 EEPROM (256 bytes).
+ *
+ * However, misconfiguration can lose data. "Set 16-bit memory address"
+ * to a part with 8-bit addressing will overwrite data. Writing with too
+ * big a page size also loses data. And it's not safe to assume that the
+ * conventional addresses 0x50..0x57 only hold eeproms; a PCF8563 RTC
+ * uses 0x51, for just one example.
+ *
+ * So this driver uses "new style" I2C driver binding, expecting to be
+ * told what devices exist. That may be in arch/X/mach-Y/board-Z.c or
+ * similar kernel-resident tables; or, configuration data coming from
+ * a bootloader.
+ *
+ * Other than binding model, current differences from "eeprom" driver are
+ * that this one handles write access and isn't restricted to 24c02 devices.
+ * It also handles larger devices (32 kbit and up) with two-byte addresses,
+ * which won't work on pure SMBus systems.
+ */
+
+struct at24_data {
+	struct at24_platform_data chip;
+
+	struct cdev		cdev;
+	struct file_operations	fops;
+
+	u8 *writebuf;
+	unsigned write_max;
+	unsigned num_addresses;
+
+	/*
+	 * Some chips tie up multiple I2C addresses; dummy devices reserve
+	 * them for us.
+	 */
+	struct i2c_client *client[];
+};
+
+/*
+ * This parameter is to help this driver avoid blocking other drivers out
+ * of I2C for potentially troublesome amounts of time. With a 100 kHz I2C
+ * clock, one 256 byte read takes about 1/43 second which is excessive;
+ * but the 1/170 second it takes at 400 kHz may be quite reasonable; and
+ * at 1 MHz (Fm+) a 1/430 second delay could easily be invisible.
+ *
+ * This value is forced to be a power of two so that writes align on pages.
+ */
+static unsigned io_limit = 128;
+
+/*
+ * Specs often allow 5 msec for a page write, sometimes 20 msec;
+ * it's important to recover from write timeouts.
+ */
+static unsigned write_timeout = 25;
+
+#define AT24_SIZE_BYTELEN 5
+#define AT24_SIZE_FLAGS 8
+
+#define AT24_BITMASK(x) (BIT(x) - 1)
+
+/* create non-zero magic value for given eeprom parameters */
+#define AT24_DEVICE_MAGIC(_len, _flags) 		\
+	((1 << AT24_SIZE_FLAGS | (_flags)) 		\
+	    << AT24_SIZE_BYTELEN | ilog2(_len))
+
+static struct platform_device_id at24_ids[] = {
+	/* needs 8 addresses as A0-A2 are ignored */
+	{ "24c00", AT24_DEVICE_MAGIC(128 / 8, AT24_FLAG_TAKE8ADDR) },
+	/* old variants can't be handled with this generic entry! */
+	{ "24c01", AT24_DEVICE_MAGIC(1024 / 8, 0) },
+	{ "24c02", AT24_DEVICE_MAGIC(2048 / 8, 0) },
+	/* spd is a 24c02 in memory DIMMs */
+	{ "spd", AT24_DEVICE_MAGIC(2048 / 8,
+		AT24_FLAG_READONLY | AT24_FLAG_IRUGO) },
+	{ "24c04", AT24_DEVICE_MAGIC(4096 / 8, 0) },
+	/* 24rf08 quirk is handled at i2c-core */
+	{ "24c08", AT24_DEVICE_MAGIC(8192 / 8, 0) },
+	{ "24c16", AT24_DEVICE_MAGIC(16384 / 8, 0) },
+	{ "24c32", AT24_DEVICE_MAGIC(32768 / 8, AT24_FLAG_ADDR16) },
+	{ "24c64", AT24_DEVICE_MAGIC(65536 / 8, AT24_FLAG_ADDR16) },
+	{ "24c128", AT24_DEVICE_MAGIC(131072 / 8, AT24_FLAG_ADDR16) },
+	{ "24c256", AT24_DEVICE_MAGIC(262144 / 8, AT24_FLAG_ADDR16) },
+	{ "24c512", AT24_DEVICE_MAGIC(524288 / 8, AT24_FLAG_ADDR16) },
+	{ "24c1024", AT24_DEVICE_MAGIC(1048576 / 8, AT24_FLAG_ADDR16) },
+	{ "at24", 0 },
+	{ /* END OF LIST */ }
+};
+
+/*-------------------------------------------------------------------------*/
+
+/*
+ * This routine supports chips which consume multiple I2C addresses. It
+ * computes the addressing information to be used for a given r/w request.
+ * Assumes that sanity checks for offset happened at sysfs-layer.
+ */
+static struct i2c_client *at24_translate_offset(struct at24_data *at24,
+		unsigned *offset)
+{
+	unsigned i;
+
+	if (at24->chip.flags & AT24_FLAG_ADDR16) {
+		i = *offset >> 16;
+		*offset &= 0xffff;
+	} else {
+		i = *offset >> 8;
+		*offset &= 0xff;
+	}
+
+	return at24->client[i];
+}
+
+static ssize_t at24_eeprom_read(struct at24_data *at24, char *buf,
+		unsigned offset, size_t count)
+{
+	struct i2c_msg msg[2];
+	u8 msgbuf[2];
+	struct i2c_client *client;
+	int status, i;
+	uint64_t start, read_time;
+
+	memset(msg, 0, sizeof(msg));
+
+	/*
+	 * REVISIT some multi-address chips don't rollover page reads to
+	 * the next slave address, so we may need to truncate the count.
+	 * Those chips might need another quirk flag.
+	 *
+	 * If the real hardware used four adjacent 24c02 chips and that
+	 * were misconfigured as one 24c08, that would be a similar effect:
+	 * one "eeprom" file not four, but larger reads would fail when
+	 * they crossed certain pages.
+	 */
+
+	/*
+	 * Slave address and byte offset derive from the offset. Always
+	 * set the byte address; on a multi-master board, another master
+	 * may have changed the chip's "current" address pointer.
+	 */
+	client = at24_translate_offset(at24, &offset);
+
+	if (count > io_limit)
+		count = io_limit;
+
+	i = 0;
+	if (at24->chip.flags & AT24_FLAG_ADDR16)
+		msgbuf[i++] = offset >> 8;
+	msgbuf[i++] = offset;
+
+	msg[0].addr = client->addr;
+	msg[0].buf = msgbuf;
+	msg[0].len = i;
+
+	msg[1].addr = client->addr;
+	msg[1].flags = I2C_M_RD;
+	msg[1].buf = buf;
+	msg[1].len = count;
+
+	/*
+	 * Reads fail if the previous write didn't complete yet. We may
+	 * loop a few times until this one succeeds, waiting at least
+	 * long enough for one entire page write to work.
+	 */
+	start = get_time_ns();
+	do {
+		read_time = get_time_ns();
+		status = i2c_transfer(client->adapter, msg, 2);
+		if (status == 2)
+			status = count;
+		dev_dbg(&client->dev, "read %zu@%d --> %d (%llu)\n",
+				count, offset, status, read_time);
+
+		if (status == count)
+			return count;
+
+		/* REVISIT: at HZ=100, this is sloooow */
+		mdelay(1);
+	} while (!is_timeout(start, write_timeout * MSECOND));
+
+	return -ETIMEDOUT;
+}
+
+static ssize_t at24_read(struct at24_data *at24,
+		char *buf, loff_t off, size_t count)
+{
+	ssize_t retval = 0;
+
+	if (unlikely(!count))
+		return count;
+
+	/*
+	 * Read data from chip, protecting against concurrent updates
+	 * from this host, but not from other I2C masters.
+	 */
+	while (count) {
+		ssize_t	status;
+
+		status = at24_eeprom_read(at24, buf, off, count);
+		if (status <= 0) {
+			if (retval == 0)
+				retval = status;
+			break;
+		}
+		buf += status;
+		off += status;
+		count -= status;
+		retval += status;
+	}
+
+	return retval;
+}
+
+static ssize_t at24_cdev_read(struct cdev *cdev, void *buf, size_t count,
+		loff_t off, ulong flags)
+{
+	struct at24_data *at24 = cdev->priv;
+
+	return at24_read(at24, buf, off, count);
+}
+
+/*
+ * Note that if the hardware write-protect pin is pulled high, the whole
+ * chip is normally write protected. But there are plenty of product
+ * variants here, including OTP fuses and partial chip protect.
+ *
+ * We only use page mode writes; the alternative is sloooow. This routine
+ * writes at most one page.
+ */
+static ssize_t at24_eeprom_write(struct at24_data *at24, const char *buf,
+		unsigned offset, size_t count)
+{
+	struct i2c_client *client;
+	struct i2c_msg msg;
+	ssize_t status;
+	uint64_t start, write_time;
+	unsigned next_page;
+	int i = 0;
+
+	/* Get corresponding I2C address and adjust offset */
+	client = at24_translate_offset(at24, &offset);
+
+	/* write_max is at most a page */
+	if (count > at24->write_max)
+		count = at24->write_max;
+
+	/* Never roll over backwards, to the start of this page */
+	next_page = roundup(offset + 1, at24->chip.page_size);
+	if (offset + count > next_page)
+		count = next_page - offset;
+
+
+	msg.addr = client->addr;
+	msg.flags = 0;
+
+	/* msg.buf is u8 and casts will mask the values */
+	msg.buf = at24->writebuf;
+	if (at24->chip.flags & AT24_FLAG_ADDR16)
+		msg.buf[i++] = offset >> 8;
+
+	msg.buf[i++] = offset;
+	memcpy(&msg.buf[i], buf, count);
+	msg.len = i + count;
+
+	/*
+	 * Writes fail if the previous one didn't complete yet. We may
+	 * loop a few times until this one succeeds, waiting at least
+	 * long enough for one entire page write to work.
+	 */
+	start = get_time_ns();
+	do {
+		write_time = get_time_ns();
+		status = i2c_transfer(client->adapter, &msg, 1);
+		if (status == 1)
+			status = count;
+		dev_dbg(&client->dev, "write %zu@%d --> %zd (%llu)\n",
+				count, offset, status, write_time);
+
+		if (status == count)
+			return count;
+
+		/* REVISIT: at HZ=100, this is sloooow */
+		mdelay(1);
+	} while (!is_timeout(start, write_timeout * MSECOND));
+
+	return -ETIMEDOUT;
+}
+
+static ssize_t at24_write(struct at24_data *at24, const char *buf, loff_t off,
+			  size_t count)
+{
+	ssize_t retval = 0;
+
+	if (unlikely(!count))
+		return count;
+
+	while (count) {
+		ssize_t	status;
+
+		status = at24_eeprom_write(at24, buf, off, count);
+		if (status <= 0) {
+			if (retval == 0)
+				retval = status;
+			break;
+		}
+		buf += status;
+		off += status;
+		count -= status;
+		retval += status;
+	}
+
+	return retval;
+}
+
+static ssize_t at24_cdev_write(struct cdev *cdev, const void *buf, size_t count,
+		loff_t off, ulong flags)
+{
+	struct at24_data *at24 = cdev->priv;
+
+	return at24_write(at24, buf, off, count);
+}
+
+static int at24_probe(struct device_d *dev)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct at24_platform_data chip;
+	bool writable;
+	struct at24_data *at24;
+	int err;
+	unsigned i, num_addresses;
+
+	if (dev->platform_data) {
+		chip = *(struct at24_platform_data *)dev->platform_data;
+	} else {
+		unsigned long magic;
+
+		err = dev_get_drvdata(dev, (unsigned long *)&magic);
+		if (err)
+			return err;
+
+		chip.byte_len = BIT(magic & AT24_BITMASK(AT24_SIZE_BYTELEN));
+		magic >>= AT24_SIZE_BYTELEN;
+		chip.flags = magic & AT24_BITMASK(AT24_SIZE_FLAGS);
+		/*
+		 * This is slow, but we can't know all eeproms, so we better
+		 * play safe. Specifying custom eeprom-types via platform_data
+		 * is recommended anyhow.
+		 */
+		chip.page_size = 1;
+	}
+
+	if (!is_power_of_2(chip.byte_len))
+		dev_warn(&client->dev,
+			"byte_len looks suspicious (no power of 2)!\n");
+	if (!chip.page_size) {
+		dev_err(&client->dev, "page_size must not be 0!\n");
+		err = -EINVAL;
+		goto err_out;
+	}
+	if (!is_power_of_2(chip.page_size))
+		dev_warn(&client->dev,
+			"page_size looks suspicious (no power of 2)!\n");
+
+	if (chip.flags & AT24_FLAG_TAKE8ADDR)
+		num_addresses = 8;
+	else
+		num_addresses =	DIV_ROUND_UP(chip.byte_len,
+			(chip.flags & AT24_FLAG_ADDR16) ? 65536 : 256);
+
+	at24 = xzalloc(sizeof(struct at24_data) +
+		num_addresses * sizeof(struct i2c_client *));
+
+	at24->chip = chip;
+	at24->num_addresses = num_addresses;
+	at24->cdev.name = asprintf("eeprom%d", dev->id);
+	at24->cdev.priv = at24;
+	at24->cdev.dev = dev;
+	at24->cdev.ops = &at24->fops;
+	at24->fops.lseek = dev_lseek_default;
+	at24->fops.read	= at24_cdev_read,
+	at24->cdev.size = chip.byte_len;
+
+	writable = !(chip.flags & AT24_FLAG_READONLY);
+	if (writable) {
+		unsigned write_max = chip.page_size;
+
+		at24->fops.write = at24_cdev_write;
+
+		if (write_max > io_limit)
+			write_max = io_limit;
+		at24->write_max = write_max;
+
+		/* buffer (data + address at the beginning) */
+		at24->writebuf = xmalloc(write_max + 2);
+	}
+
+	at24->client[0] = client;
+
+	/* use dummy devices for multiple-address chips */
+	for (i = 1; i < num_addresses; i++) {
+		at24->client[i] = i2c_new_dummy(client->adapter,
+					client->addr + i);
+		if (!at24->client[i]) {
+			dev_err(&client->dev, "address 0x%02x unavailable\n",
+					client->addr + i);
+			err = -EADDRINUSE;
+			goto err_clients;
+		}
+	}
+
+	devfs_create(&at24->cdev);
+
+	return 0;
+
+err_clients:
+	kfree(at24->writebuf);
+	kfree(at24);
+err_out:
+	dev_dbg(&client->dev, "probe error %d\n", err);
+	return err;
+
+}
+
+static struct driver_d at24_driver = {
+	.name		= "at24",
+	.probe		= at24_probe,
+	.id_table	= at24_ids,
+};
+
+static int at24_init(void)
+{
+	i2c_register_driver(&at24_driver);
+	return 0;
+}
+device_initcall(at24_init);
diff --git a/include/i2c/at24.h b/include/i2c/at24.h
new file mode 100644
index 0000000..1013308
--- /dev/null
+++ b/include/i2c/at24.h
@@ -0,0 +1,35 @@
+/*
+ * at24.h - platform_data for the at24 (generic eeprom) driver
+ * (C) Copyright 2008 by Pengutronix
+ * (C) Copyright 2012 by Wolfram Sang
+ * same license as the driver
+ */
+
+#ifndef _LINUX_AT24_H
+#define _LINUX_AT24_H
+
+#include <linux/types.h>
+
+/**
+ * struct at24_platform_data - data to set up at24 (generic eeprom) driver
+ * @byte_len: size of eeprom in byte
+ * @page_size: number of byte which can be written in one go
+ * @flags: tunable options, check AT24_FLAG_* defines
+ *
+ * If you set up a custom eeprom type, please double-check the parameters.
+ * Especially page_size needs extra care, as you risk data loss if your value
+ * is bigger than what the chip actually supports!
+ *
+ */
+
+struct at24_platform_data {
+	u32		byte_len;		/* size (sum of all addr) */
+	u16		page_size;		/* for writes */
+	u8		flags;
+#define AT24_FLAG_ADDR16	0x80	/* address pointer is 16 bit */
+#define AT24_FLAG_READONLY	0x40	/* sysfs-entry will be read-only */
+#define AT24_FLAG_IRUGO		0x20	/* sysfs-entry will be world-readable */
+#define AT24_FLAG_TAKE8ADDR	0x10	/* take always 8 addresses (24c00) */
+};
+
+#endif /* _LINUX_AT24_H */
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Sat Nov  3 17:02:02 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Sat,  3 Nov 2012 22:02:02 +0100
Subject: [PATCH 1/1] at91sam9x5ek: add at24c512 support
Message-ID: <1351976522-9785-1-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
Hi,

	this depends on the at24 support patch serie + at91sam9x5ek add i2c
	with qt1070 support

The following changes since commit 9277684dbac6ae0b66f23bcb730a9737d22a335c:

  eeprom: add at24 support (2012-11-03 13:41:58 +0800)

are available in the git repository at:

  git://git.jcrosoft.org/barebox.git delivery/at91_i2c

for you to fetch changes up to 706c6d5c382803959e89218bb0ffb0890cf885cd:

  at91sam9x5ek: add at24c512 support (2012-11-03 13:44:16 +0800)

Jean-Christophe PLAGNIOL-VILLARD (1):
      at91sam9x5ek: add at24c512 support

 arch/arm/boards/at91sam9x5ek/init.c     |    2 ++
 arch/arm/configs/at91sam9x5ek_defconfig |    1 +
 2 files changed, 3 insertions(+)

Best Regards,
J.

diff --git a/arch/arm/boards/at91sam9x5ek/init.c b/arch/arm/boards/at91sam9x5ek/init.c
index dbb9bb5..dc8853e 100644
--- a/arch/arm/boards/at91sam9x5ek/init.c
+++ b/arch/arm/boards/at91sam9x5ek/init.c
@@ -122,6 +122,8 @@ static struct i2c_board_info i2c_devices[] = {
 	{
 		.platform_data = &qt1070_pdata,
 		I2C_BOARD_INFO("qt1070", 0x1b),
+	}, {
+		I2C_BOARD_INFO("24c512", 0x51)
 	},
 };
 
diff --git a/arch/arm/configs/at91sam9x5ek_defconfig b/arch/arm/configs/at91sam9x5ek_defconfig
index 3e66c44..cbbd780 100644
--- a/arch/arm/configs/at91sam9x5ek_defconfig
+++ b/arch/arm/configs/at91sam9x5ek_defconfig
@@ -67,6 +67,7 @@ CONFIG_DISK_WRITE=y
 CONFIG_LED=y
 CONFIG_LED_GPIO=y
 CONFIG_LED_TRIGGERS=y
+CONFIG_EEPROM_AT24=y
 CONFIG_KEYBOARD_QT1070=y
 CONFIG_W1=y
 CONFIG_W1_MASTER_GPIO=y
-- 
1.7.10.4



From s.hauer at pengutronix.de  Sat Nov  3 17:39:28 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Sat, 3 Nov 2012 22:39:28 +0100
Subject: [PATCH 2/2] introduce spi command
In-Reply-To: <1351873060-27968-2-git-send-email-plagnioj@jcrosoft.com>
References: <20121102160659.GS29599@game.jcrosoft.org>
 <1351873060-27968-1-git-send-email-plagnioj@jcrosoft.com>
 <1351873060-27968-2-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <20121103213928.GT1641@pengutronix.de>

On Fri, Nov 02, 2012 at 05:17:40PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> usefull to debug spi
> 
> The command allow to read/write on a spi device
> 
> Usage: spi [OPTION] [data to write 0xXX]
> write/read spi device.
>   -b <bus_num>  spi bus number (default = 0)
>   -r <count>    to read
>   -c <cs>       chip select (default = 0)
>   -m <mode>     spi mode (default = 0)
>   -f <hz>       max_speed_hz (default = 1MHz)
>   -w <bit>      bits_per_word (default = 8)
>   -v            verbose
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
> ---
>  commands/Kconfig  |    6 +++
>  commands/Makefile |    1 +
>  commands/spi.c    |  126 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 133 insertions(+)
>  create mode 100644 commands/spi.c
> 
> diff --git a/commands/Kconfig b/commands/Kconfig
> index 16706d3..f7cbd67 100644
> --- a/commands/Kconfig
> +++ b/commands/Kconfig
> @@ -597,6 +597,12 @@ config CMD_I2C
>  	  include i2c_probe, i2c_read and i2c_write commands to communicate
>  	  on i2c bus.
>  
> +config CMD_SPI
> +	bool
> +	depends on SPI
> +	prompt "spi command"
> +	help
> +
>  config CMD_LED
>  	bool
>  	depends on LED
> diff --git a/commands/Makefile b/commands/Makefile
> index 610be55..19d496e 100644
> --- a/commands/Makefile
> +++ b/commands/Makefile
> @@ -55,6 +55,7 @@ obj-$(CONFIG_USB_GADGET_SERIAL)	+= usbserial.o
>  obj-$(CONFIG_CMD_GPIO)		+= gpio.o
>  obj-$(CONFIG_CMD_UNCOMPRESS)	+= uncompress.o
>  obj-$(CONFIG_CMD_I2C)		+= i2c.o
> +obj-$(CONFIG_CMD_SPI)		+= spi.o
>  obj-$(CONFIG_CMD_UBI)		+= ubi.o
>  obj-$(CONFIG_CMD_MENU)		+= menu.o
>  obj-$(CONFIG_CMD_PASSWD)	+= passwd.o
> diff --git a/commands/spi.c b/commands/spi.c
> new file mode 100644
> index 0000000..599637c
> --- /dev/null
> +++ b/commands/spi.c
> @@ -0,0 +1,126 @@
> +/*
> + * Copyright (c) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
> + *
> + * Under GPLv2 only
> + *
> + */
> +
> +#include <common.h>
> +#include <command.h>
> +#include <errno.h>
> +#include <malloc.h>
> +#include <getopt.h>
> +#include <spi/spi.h>
> +
> +static int do_spi(int argc, char *argv[])
> +{
> +	struct spi_device spi;
> +	int bus = 0;
> +	int read = 0;
> +	int verbose = 0;
> +	int opt, count, i, ret;
> +
> +	u8 *tx_buf, *rx_buf;
> +
> +	memset(&spi, 0, sizeof(struct spi_device));
> +
> +	spi.max_speed_hz = 1 * 1000 * 1000;
> +	spi.bits_per_word = 8;
> +
> +	while ((opt = getopt(argc, argv, "b:c:r:m:f:w:v")) > 0) {
> +		switch (opt) {
> +		case 'b':
> +			bus = simple_strtol(optarg, NULL, 0);
> +			break;
> +		case 'r':
> +			read = simple_strtol(optarg, NULL, 0);
> +			break;
> +		case 'c':
> +			spi.chip_select = simple_strtoul(optarg, NULL, 0);
> +			break;
> +		case 'm':
> +			spi.mode = simple_strtoul(optarg, NULL, 0);
> +			break;
> +		case 'f':
> +			spi.max_speed_hz = simple_strtoul(optarg, NULL, 0);
> +			break;
> +		case 'w':
> +			spi.bits_per_word = simple_strtoul(optarg, NULL, 0);
> +			break;
> +		case 'v':
> +			verbose = 1;
> +			break;

		default:
			return COMMAND_ERROR_USAGE;

I still didn't find the time to fix the other commands, but for new ones
we should get used to it.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From plagnioj at jcrosoft.com  Sun Nov  4 03:54:53 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Sun, 4 Nov 2012 09:54:53 +0100
Subject: [PATCH 0/2 v2] add spi command
Message-ID: <20121104085453.GB29599@game.jcrosoft.org>

HI,

	v2:
	add default return usage
	use memory_display

	while debugging a spi issue I found we have a i2c commands but no spi
	command

	So introduce one

The following changes since commit 8f839b51047593bdd63d485006237111cd3a0547:

  spi: introduce spi_get_master (2012-11-02 08:55:10 +0800)

are available in the git repository at:

  git://git.jcrosoft.org/barebox.git delivery/command_spi

for you to fetch changes up to 2bfe0a6d58edae296b384b14e86e9efad148bfb7:

  introduce spi command (2012-11-04 01:45:34 +0800)

----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (1):
      introduce spi command

 commands/Kconfig  |    6 ++++++
 commands/Makefile |    1 +
 commands/spi.c    |  126 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 133 insertions(+)
 create mode 100644 commands/spi.c

Best Regards,
J.


From plagnioj at jcrosoft.com  Sun Nov  4 03:59:01 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Sun,  4 Nov 2012 09:59:01 +0100
Subject: [PATCH 1/2] spi: introduce spi_get_master
In-Reply-To: <20121104085453.GB29599@game.jcrosoft.org>
References: <20121104085453.GB29599@game.jcrosoft.org>
Message-ID: <1352019542-3237-1-git-send-email-plagnioj@jcrosoft.com>

so we can request a master usefull for the spi command

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/spi/spi.c |   12 ++++++++++++
 include/spi/spi.h |    2 ++
 2 files changed, 14 insertions(+)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 44040e5..6a5bd6d 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -219,6 +219,18 @@ int spi_register_master(struct spi_master *master)
 }
 EXPORT_SYMBOL(spi_register_master);
 
+struct spi_master *spi_get_master(int bus)
+{
+	struct spi_master* m;
+
+	list_for_each_entry(m, &spi_master_list, list) {
+		if (m->bus_num == bus)
+			return m;
+	}
+
+	return NULL;
+}
+
 int spi_sync(struct spi_device *spi, struct spi_message *message)
 {
 	return spi->master->transfer(spi, message);
diff --git a/include/spi/spi.h b/include/spi/spi.h
index 1773ca2..d6570a4 100644
--- a/include/spi/spi.h
+++ b/include/spi/spi.h
@@ -432,6 +432,8 @@ static inline ssize_t spi_w8r8(struct spi_device *spi, u8 cmd)
 
 extern struct bus_type spi_bus;
 
+struct spi_master *spi_get_master(int bus);
+
 static inline int spi_register_driver(struct driver_d *drv)
 {
 	drv->bus = &spi_bus;
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Sun Nov  4 03:59:02 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Sun,  4 Nov 2012 09:59:02 +0100
Subject: [PATCH 2/2] introduce spi command
In-Reply-To: <1352019542-3237-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121104085453.GB29599@game.jcrosoft.org>
 <1352019542-3237-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1352019542-3237-2-git-send-email-plagnioj@jcrosoft.com>

usefull to debug spi

The command allow to read/write on a spi device

Usage: spi [OPTION] [data to write 0xXX]
write/read spi device.
  -b <bus_num>  spi bus number (default = 0)
  -r <count>    to read
  -c <cs>       chip select (default = 0)
  -m <mode>     spi mode (default = 0)
  -f <hz>       max_speed_hz (default = 1MHz)
  -w <bit>      bits_per_word (default = 8)
  -v            verbose

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 commands/Kconfig  |    6 +++
 commands/Makefile |    1 +
 commands/spi.c    |  126 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 133 insertions(+)
 create mode 100644 commands/spi.c

diff --git a/commands/Kconfig b/commands/Kconfig
index 16706d3..f7cbd67 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -597,6 +597,12 @@ config CMD_I2C
 	  include i2c_probe, i2c_read and i2c_write commands to communicate
 	  on i2c bus.
 
+config CMD_SPI
+	bool
+	depends on SPI
+	prompt "spi command"
+	help
+
 config CMD_LED
 	bool
 	depends on LED
diff --git a/commands/Makefile b/commands/Makefile
index 610be55..19d496e 100644
--- a/commands/Makefile
+++ b/commands/Makefile
@@ -55,6 +55,7 @@ obj-$(CONFIG_USB_GADGET_SERIAL)	+= usbserial.o
 obj-$(CONFIG_CMD_GPIO)		+= gpio.o
 obj-$(CONFIG_CMD_UNCOMPRESS)	+= uncompress.o
 obj-$(CONFIG_CMD_I2C)		+= i2c.o
+obj-$(CONFIG_CMD_SPI)		+= spi.o
 obj-$(CONFIG_CMD_UBI)		+= ubi.o
 obj-$(CONFIG_CMD_MENU)		+= menu.o
 obj-$(CONFIG_CMD_PASSWD)	+= passwd.o
diff --git a/commands/spi.c b/commands/spi.c
new file mode 100644
index 0000000..b4663f2
--- /dev/null
+++ b/commands/spi.c
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
+ *
+ * Under GPLv2 only
+ *
+ */
+
+#include <common.h>
+#include <command.h>
+#include <errno.h>
+#include <malloc.h>
+#include <getopt.h>
+#include <spi/spi.h>
+
+static int do_spi(int argc, char *argv[])
+{
+	struct spi_device spi;
+	int bus = 0;
+	int read = 0;
+	int verbose = 0;
+	int opt, count, i, ret;
+	int byte_per_word;
+
+	u8 *tx_buf, *rx_buf;
+
+	memset(&spi, 0, sizeof(struct spi_device));
+
+	spi.max_speed_hz = 1 * 1000 * 1000;
+	spi.bits_per_word = 8;
+
+	while ((opt = getopt(argc, argv, "b:c:r:m:f:w:v")) > 0) {
+		switch (opt) {
+		case 'b':
+			bus = simple_strtol(optarg, NULL, 0);
+			break;
+		case 'r':
+			read = simple_strtol(optarg, NULL, 0);
+			break;
+		case 'c':
+			spi.chip_select = simple_strtoul(optarg, NULL, 0);
+			break;
+		case 'm':
+			spi.mode = simple_strtoul(optarg, NULL, 0);
+			break;
+		case 'f':
+			spi.max_speed_hz = simple_strtoul(optarg, NULL, 0);
+			break;
+		case 'w':
+			spi.bits_per_word = simple_strtoul(optarg, NULL, 0);
+			break;
+		case 'v':
+			verbose = 1;
+			break;
+		default:
+			return COMMAND_ERROR_USAGE;
+		}
+	}
+
+	count = argc - optind;
+
+	if ((!read && !count) || !spi.max_speed_hz || !spi.bits_per_word)
+		return COMMAND_ERROR_USAGE;
+
+
+	spi.master = spi_get_master(bus);
+	if (!spi.master) {
+		printf("spi bus %d not found\n", bus);
+		return -ENODEV;
+	}
+
+	if (spi.chip_select > spi.master->num_chipselect) {
+		printf("spi chip select (%d)> master num chipselect (%d)\n",
+			spi.chip_select, spi.master->num_chipselect);
+		return -EINVAL;
+	}
+
+	tx_buf = xmalloc(count);
+	rx_buf = xmalloc(count);
+
+	for (i = 0; i < count; i++)
+		tx_buf[i] = (u8) simple_strtol(argv[optind + i], NULL, 16);
+
+	ret = spi_write_then_read(&spi, tx_buf, count, rx_buf, read);
+	if (ret)
+		goto out;
+
+	byte_per_word = min(spi.bits_per_word / 8, 1);
+	if (verbose) {
+		printf("device config\n");
+		printf("    bus_num       = %d\n", spi.master->bus_num);
+		printf("    max_speed_hz  = %d\n", spi.max_speed_hz);
+		printf("    chip_select   = %d\n", spi.chip_select);
+		printf("    mode          = 0x%x\n", spi.mode);
+		printf("    bits_per_word = %d\n", spi.bits_per_word);
+		printf("\n");
+
+		printf("wrote %i bytes\n", count);
+		memory_display(tx_buf, 0, count, byte_per_word);
+
+		printf("read %i bytes\n", read);
+	}
+
+	memory_display(rx_buf, 0, read, byte_per_word);
+
+out:
+	free(rx_buf);
+	free(tx_buf);
+	return ret;
+}
+
+static const __maybe_unused char cmd_spi_help[] =
+"Usage: spi [OPTION] [data to write 0xXX]\n"
+"write/read spi device.\n"
+"  -b <bus_num>  spi bus number (default = 0)\n"
+"  -r <count>    to read\n"
+"  -c <cs>       chip select (default = 0)\n"
+"  -m <mode>     spi mode (default = 0)\n"
+"  -f <hz>       max_speed_hz (default = 1MHz)\n"
+"  -w <bit>      bits_per_word (default = 8)\n"
+"  -v            verbose\n";
+
+BAREBOX_CMD_START(spi)
+	.cmd		= do_spi,
+	.usage		= "write/read spi device",
+	BAREBOX_CMD_HELP(cmd_spi_help)
+BAREBOX_CMD_END
-- 
1.7.10.4



From robert.jarzmik at free.fr  Sun Nov  4 12:53:51 2012
From: robert.jarzmik at free.fr (Robert Jarzmik)
Date: Sun, 04 Nov 2012 18:53:51 +0100
Subject: Ramfs and NULL pointer
Message-ID: <87zk2xuuds.fsf@free.fr>

Hi there,

Lately, I see null pointer dereferences in barebox.
I traced the culprit to ramfs ...
>From what I've seen, the inodes list is a bit ... weird ... especially the last
item in the list contains null pointers ...

I wonder if anybody sees such an effect ...
My board (arm/mioa701) has not changed much wrt the environment embedded ... The
only thing I did lately was to rebase against "next" branch.

I joined my debugging session at the end to show my problem. The rjk_abort()
function was introduced for breakpoint purpose only.

If anybody has any clue please tell me.

Cheers.

--
Robert

#0  rjk_abort () at lib/string.c:144
#1  0xa3f19a10 in strcmp (cs=0x0, ct=0xa3025c99 "env") at lib/string.c:157
#2  0xa3f28758 in lookup (priv=<value optimized out>, path=<value optimized out>) at fs/ramfs.c:72
#3  rlookup (priv=<value optimized out>, path=<value optimized out>) at fs/ramfs.c:95
#4  0xa3f287a0 in ramfs_stat (dev=<value optimized out>, filename=0xa3025c99 "env", s=0x2e) at fs/ramfs.c:549
#5  0xa3f2d8a4 in lstat (filename=<value optimized out>, s=0xa2effb10) at fs/fs.c:1412
#6  0xa3f2e10c in realfile (pathname=<value optimized out>, s=0xa2effb10) at fs/fs.c:582
#7  0xa3f2e2cc in open (pathname=0x0, flags=0) at fs/fs.c:624
#8  0xa3f2e508 in read_file (filename=0xa2f55220 "/env/bin/mtd_env_override", size=0x0) at fs/fs.c:47
#9  0xa3f01dfc in source_script (path=0x0, argc=<value optimized out>, argv=0xfffffff2) at common/hush.c:1809
#10 0xa3f01e80 in execute_script (path=0xa2f55220 "/env/bin/mtd_env_override", argc=1, argv=0xa2fa5668) at common/hush.c:1794
#11 0xa3f00140 in binfmt_run (file=0xa2f55220 "/env/bin/mtd_env_override", argc=1, argv=0xa2fa5668) at common/binfmt.c:26
#12 0xa3f001cc in execute_binfmt (argc=1, argv=0xa2fa5668) at common/binfmt.c:65
#13 0xa3f01964 in run_pipe_real (ctx=0xa2effda8, pi=0xa2fa5028) at common/hush.c:790
#14 run_list_real (ctx=0xa2effda8, pi=0xa2fa5028) at common/hush.c:914
#15 0xa3f01bfc in run_list (ctx=0xa2effda8, inp=0xa2effd7c, flag=2) at common/hush.c:1033
#16 parse_stream_outer (ctx=0xa2effda8, inp=0xa2effd7c, flag=2) at common/hush.c:1618
#17 0xa3f01d80 in parse_string_outer (ctx=0xa2effda8, 
    s=0xa2f015a0 "#!/bin/sh\n\nPATH=/env/bin\nexport PATH\n\n. /env/config\naddpart /dev/mtd0 $mtdparts\n\nusbserial -s \"Mio A701 usb gadget\"\nled keyboard 0\n\nsdcard_override\n\nfb0.enable=1\nsplash /dev/mtd0.barebox-logo\n\nmtd_env"..., flag=2) at common/hush.c:1662
#18 0xa3f01e24 in source_script (path=<value optimized out>, argc=<value optimized out>, argv=<value optimized out>) at common/hush.c:1815
#19 0xa3f01fdc in do_source (argc=2, argv=<value optimized out>) at common/hush.c:1877
#20 0xa3f05b2c in execute_command (argc=2, argv=0xa2f01530) at common/command.c:77
#21 0xa3f01964 in run_pipe_real (ctx=0xa2efff58, pi=0xa2f0fe10) at common/hush.c:790
#22 run_list_real (ctx=0xa2efff58, pi=0xa2f0fe10) at common/hush.c:914
#23 0xa3f01bfc in run_list (ctx=0xa2efff58, inp=0xa2efff2c, flag=2) at common/hush.c:1033
#24 parse_stream_outer (ctx=0xa2efff58, inp=0xa2efff2c, flag=2) at common/hush.c:1618
#25 0xa3f01d80 in parse_string_outer (ctx=0xa2efff58, s=0xa3f31bda "source /env/bin/init", flag=2) at common/hush.c:1662
#26 0xa3f01eb8 in run_command (cmd=0x0, flag=<value optimized out>) at common/hush.c:1783
#27 0xa3f073a0 in start_barebox () at common/startup.c:124
#28 0xa3f305b8 in board_init_lowlevel_return () at arch/arm/cpu/start.c:62
Backtrace stopped: frame did not save the PC

(gdb) up
#5  0xa3f2d8a4 in lstat (filename=<value optimized out>, s=0xa2effb10) at fs/fs.c:1412
1412		ret = fsdrv->stat(dev, f, s);
(gdb) p dev
$14 = (struct device_d *) 0xa2f00644
(gdb) p *dev
$15 = {name = "ramfs", '\000' <repeats 26 times>, id = 0, resource = 0x0, num_resources = 0, platform_data = 0x0, priv = 0xa2f00708, type_data = 0x0, driver = 0xa3f3b2dc, list = {
    next = 0xa2f00cd8, prev = 0xa2f004f4}, bus_list = {next = 0xa2f00ce0, prev = 0xa3f3b464}, children = {next = 0xa2f00690, prev = 0xa2f00690}, sibling = {next = 0x0, prev = 0x0}, active = {
    next = 0xa3f3a658, prev = 0xa2f00cf8}, parent = 0x0, bus = 0xa3f3b44c, parameters = {next = 0xa2f006b0, prev = 0xa2f006b0}, cdevs = {next = 0xa2f006b8, prev = 0xa2f006b8}, id_entry = 0x0, 
  device_node = 0x0, of_id_entry = 0x0}

(gdb) p *(struct ramfs_node *)0xa2f00738
No struct type named ramfs_node.
(gdb) p *(struct ramfs_inode *)0xa2f00738
$19 = {name = 0xa2f00768 ".", parent = 0xa2f00708, next = 0xa2f00778, child = 0xa2f00738, symlink = 0x0, mode = 16384, handle = 0x0, size = 0, data = 0x0, recent_chunk = 0, 
  recent_chunkp = 0x0}
(gdb) p *(struct ramfs_inode *)Quitf00738
(gdb) p *(struct ramfs_inode *)0xa2f00738
$20 = {name = 0xa2f00768 ".", parent = 0xa2f00708, next = 0xa2f00778, child = 0xa2f00738, symlink = 0x0, mode = 16384, handle = 0x0, size = 0, data = 0x0, recent_chunk = 0, 
  recent_chunkp = 0x0}
(gdb) p *(struct ramfs_inode *)0xa2f00778
$21 = {name = 0xa2f007a8 "..", parent = 0xa2f00708, next = 0xa2f007c8, child = 0xa2f00738, symlink = 0x0, mode = 16895, handle = 0x0, size = 0, data = 0x0, recent_chunk = 0, 
  recent_chunkp = 0x0}
(gdb) p *(struct ramfs_inode *)0xa2f007c8
$22 = {name = 0x0, parent = 0x0, next = 0x0, child = 0x0, symlink = 0x0, mode = 0, handle = 0x0, size = 0, data = 0x0, recent_chunk = 0, recent_chunkp = 0x0}
(gdb) p *(struct ramfs_inode *)0xa2f00738
$23 = {name = 0xa2f00768 ".", parent = 0xa2f00708, next = 0xa2f00778, child = 0xa2f00738, symlink = 0x0, mode = 16384, handle = 0x0, size = 0, data = 0x0, recent_chunk = 0, 
  recent_chunkp = 0x0}
(gdb) p *(struct ramfs_priv *)0xa2f00708
$18 = {root = {name = 0xa3f314f8 "/", parent = 0xa2f00708, next = 0x0, child = 0xa2f00738, symlink = 0x0, mode = 16895, handle = 0x0, size = 0, data = 0x0, recent_chunk = 0, 
    recent_chunkp = 0x0}}
(gdb) quit


From robert.jarzmik at free.fr  Sun Nov  4 12:55:23 2012
From: robert.jarzmik at free.fr (Robert Jarzmik)
Date: Sun,  4 Nov 2012 18:55:23 +0100
Subject: [PATCH v2 1/2] commands: change Y-Modem implementation
In-Reply-To: <1351791438-29967-1-git-send-email-robert.jarzmik@free.fr>
References: <1351791438-29967-1-git-send-email-robert.jarzmik@free.fr>
Message-ID: <1352051724-16253-1-git-send-email-robert.jarzmik@free.fr>

The current Y-Modem implementation has some limitations:
 - Y-Modem/G protocol is not supported
 - Multiple files (aka. batch) transfers are not supported
 - Transfer speed over fast lines (USB console) is slow
 - Code is not trivial to maintain (personnal opinion)

This implementation tries to address all these points by
introducing loady2 command.

The effects are :
 - transfer speed for Y-Modem over USB jumps from 2kBytes/s
   to 180kBytes/s
 - transfer speed for Y-Modem/G jumps to 200kBytes/s
 - multiple file transfers are possible

This command was tested on a USB console and UART 9600bps
serial line :
 - NAKs (and retransmissions) were tested for faulty
   serial lines
 - multiple file transfers were tested
 - Y-Modem, Y-Modem/G and X-Modem transfers were tested

Signed-off-by: Robert Jarzmik <robert.jarzmik at free.fr>

---
Since V1:
 - add input fifo for small fifo hardwares
Add a FIFO so that each getc will empty the hardware
FIFO. This is very similar to the generic console code,
except that the getc won't block each time for 100us,
enabling faster lines (USB) to benefit their full speed.
 - fix CRC calculation for big endian architectures
   Thanks a lot Antony for the many patches testing !
 - added some documentation
 - amended the split as Sascha recommended
---
 commands/Kconfig  |    1 +
 commands/Makefile |    2 +-
 commands/loadxy.c |  238 +++++++++++++++++++++
 include/xymodem.h |   25 +++
 lib/Kconfig       |    3 +
 lib/Makefile      |    1 +
 lib/xymodem.c     |  591 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 7 files changed, 860 insertions(+), 1 deletion(-)
 create mode 100644 commands/loadxy.c
 create mode 100644 include/xymodem.h
 create mode 100644 lib/xymodem.c

diff --git a/commands/Kconfig b/commands/Kconfig
index a52a01a..a7e9974 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -261,6 +261,7 @@ config CMD_LOADB
 
 config CMD_LOADY
 	select CRC16
+	select XYMODEM
 	tristate
 	prompt "loady"
 
diff --git a/commands/Makefile b/commands/Makefile
index ff98051..44ad904 100644
--- a/commands/Makefile
+++ b/commands/Makefile
@@ -3,7 +3,7 @@ obj-$(CONFIG_CMD_BOOTM)		+= bootm.o
 obj-$(CONFIG_CMD_UIMAGE)	+= uimage.o
 obj-$(CONFIG_CMD_LINUX16)	+= linux16.o
 obj-$(CONFIG_CMD_LOADB)		+= loadb.o xyzModem.o
-obj-$(CONFIG_CMD_LOADY)		+= loadb.o xyzModem.o
+obj-$(CONFIG_CMD_LOADY)		+= loadb.o xyzModem.o loadxy.o
 obj-$(CONFIG_CMD_LOADS)		+= loads.o
 obj-$(CONFIG_CMD_ECHO)		+= echo.o
 obj-$(CONFIG_CMD_MEMORY)	+= mem.o
diff --git a/commands/loadxy.c b/commands/loadxy.c
new file mode 100644
index 0000000..141bd7b
--- /dev/null
+++ b/commands/loadxy.c
@@ -0,0 +1,238 @@
+/**
+ * @file
+ * @brief loady and loadx  support.
+ *
+ * Provides loadx (over X-Modem) and loady(over Y-Modem) support to download
+ * images.
+ *
+ * FileName: commands/loadxy.c
+ */
+/*
+ * (C) Copyright 2012 Robert Jarzmik <robert.jarzmik at free.fr>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+/*
+ * Serial up- and download support
+ */
+#include <common.h>
+#include <command.h>
+#include <console.h>
+#include <xymodem.h>
+#include <errno.h>
+#include <getopt.h>
+#include <fcntl.h>
+#include <fs.h>
+#include <malloc.h>
+
+#define DEF_FILE	"image.bin"
+
+/**
+ * @brief returns current used console device
+ *
+ * @return console device which is registered with CONSOLE_STDIN and
+ * CONSOLE_STDOUT
+ */
+static struct console_device *get_current_console(void)
+{
+	struct console_device *cdev;
+	/*
+	 * Assumption to have BOTH CONSOLE_STDIN AND STDOUT in the
+	 * same output console
+	 */
+	for_each_console(cdev) {
+		if ((cdev->f_active & (CONSOLE_STDIN | CONSOLE_STDOUT)))
+			return cdev;
+	}
+	return NULL;
+}
+
+static int console_change_speed(struct console_device *cdev, int baudrate)
+{
+	int current_baudrate;
+
+	current_baudrate =
+		(int)simple_strtoul(dev_get_param(&cdev->class_dev,
+						  "baudrate"), NULL, 10);
+	if (baudrate && baudrate != current_baudrate) {
+		printf("## Switch baudrate from %d to %d bps and press ENTER ...\n",
+		       current_baudrate, baudrate);
+		mdelay(50);
+		cdev->setbrg(cdev, baudrate);
+		mdelay(50);
+	}
+	return current_baudrate;
+}
+
+/**
+ * @brief provide the loady(Y-Modem or Y-Modem/G) support
+ *
+ * @param argc number of arguments
+ * @param argv arguments of loady command
+ *
+ * @return success or failure
+ */
+static int do_loady(int argc, char *argv[])
+{
+	int is_ymodemg = 0, rc = 0, opt, rcode = 0;
+	int load_baudrate = 0, current_baudrate;
+	struct console_device *cdev = NULL;
+
+	while ((opt = getopt(argc, argv, "b:g")) > 0) {
+		switch (opt) {
+		case 'b':
+			load_baudrate = (int)simple_strtoul(optarg, NULL, 10);
+			break;
+		case 'g':
+			is_ymodemg = 1;
+			break;
+		default:
+			perror(argv[0]);
+			return 1;
+		}
+	}
+
+	cdev = get_current_console();
+	if (NULL == cdev) {
+		printf("%s:No console device with STDIN and STDOUT\n", argv[0]);
+		return -ENODEV;
+	}
+
+	current_baudrate = console_change_speed(cdev, load_baudrate);
+	printf("## Ready for binary (ymodem) download at %d bps...\n",
+	       load_baudrate ? load_baudrate : current_baudrate);
+
+	if (is_ymodemg)
+		rc = do_load_serial_ymodemg(cdev);
+	else
+		rc = do_load_serial_ymodem(cdev);
+
+	if (rc < 0) {
+		printf("## Binary (ymodem) download aborted (%d)\n", rc);
+		rcode = 1;
+	}
+
+	console_change_speed(cdev, current_baudrate);
+
+	return rcode;
+}
+
+/**
+ * @brief provide the loadx(X-Modem) support
+ *
+ * @param argc number of arguments
+ * @param argv arguments of loadx command
+ *
+ * @return success or failure
+ */
+static int do_loadx(int argc, char *argv[])
+{
+	ulong offset = 0;
+	int load_baudrate = 0, current_baudrate, ofd, opt, rcode = 0;
+	int open_mode = O_WRONLY;
+	char *output_file = NULL;
+	struct console_device *cdev = NULL;
+
+	while ((opt = getopt(argc, argv, "f:b:o:c")) > 0) {
+		switch (opt) {
+		case 'f':
+			output_file = optarg;
+			break;
+		case 'b':
+			load_baudrate = (int)simple_strtoul(optarg, NULL, 10);
+			break;
+		case 'o':
+			offset = (int)simple_strtoul(optarg, NULL, 10);
+			break;
+		case 'c':
+			open_mode |= O_CREAT;
+			break;
+		default:
+			perror(argv[0]);
+			return 1;
+		}
+	}
+
+	cdev = get_current_console();
+	if (NULL == cdev) {
+		printf("%s:No console device with STDIN and STDOUT\n", argv[0]);
+		return -ENODEV;
+	}
+
+	/* Load Defaults */
+	if (NULL == output_file)
+		output_file = DEF_FILE;
+
+	/* File should exist */
+	ofd = open(output_file, open_mode);
+	if (ofd < 0) {
+		perror(argv[0]);
+		return 3;
+	}
+	/* Seek to the right offset */
+	if (offset) {
+		int seek = lseek(ofd, offset, SEEK_SET);
+		if (seek != offset) {
+			close(ofd);
+			ofd = 0;
+			perror(argv[0]);
+			return 4;
+		}
+	}
+
+	current_baudrate = console_change_speed(cdev, load_baudrate);
+	printf("## Ready for binary (X-Modem) download "
+	       "to 0x%08lX offset on %s device at %d bps...\n", offset,
+	       output_file, load_baudrate);
+	rcode = do_load_serial_ymodem(cdev);
+	if (rcode < 0) {
+		printf("## Binary (kermit) download aborted (%d)\n", rcode);
+		rcode = 1;
+	}
+	console_change_speed(cdev, current_baudrate);
+
+	return rcode;
+}
+
+static const __maybe_unused char cmd_loadx_help[] =
+	"[OPTIONS]\n"
+	"  -f file   - where to download to - defaults to " DEF_FILE "\n"
+	"  -o offset - what offset to download - defaults to 0\n"
+	"  -b baud   - baudrate at which to download - defaults to "
+	"console baudrate\n"
+	"  -c        - Create file if it is not present - default disabled";
+
+#ifdef CONFIG_CMD_LOADB
+BAREBOX_CMD_START(loadx)
+	.cmd = do_loadx,
+	.usage = "Load binary file over serial line (X-Modem)",
+BAREBOX_CMD_HELP(cmd_loadx_help)
+BAREBOX_CMD_END
+#endif
+
+static const __maybe_unused char cmd_loady_help[] =
+	"[OPTIONS]\n"
+	"  -y        - use Y-Modem/G (only for lossless tty as USB)\n"
+	"  -b baud   - baudrate at which to download - defaults to "
+	"console baudrate\n";
+
+#ifdef CONFIG_CMD_LOADY
+BAREBOX_CMD_START(loady2)
+	.cmd = do_loady,
+	.usage = "Load binary file over serial line (Y-Modem or Y-Modem/G)",
+BAREBOX_CMD_HELP(cmd_loady_help)
+BAREBOX_CMD_END
+#endif
diff --git a/include/xymodem.h b/include/xymodem.h
new file mode 100644
index 0000000..917cecc
--- /dev/null
+++ b/include/xymodem.h
@@ -0,0 +1,25 @@
+/*
+ * Handles the X-Modem, Y-Modem and Y-Modem/G protocols
+ *
+ * Copyright (C) 2008 Robert Jarzmik
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef _XYMODEM_
+#define _XYMODEM_
+struct xyz_ctxt;
+struct console_device;
+
+int do_load_serial_xmodem(struct console_device *cdev, int fd);
+int do_load_serial_ymodem(struct console_device *cdev);
+int do_load_serial_ymodemg(struct console_device *cdev);
+#endif
diff --git a/lib/Kconfig b/lib/Kconfig
index 9882d2d..13ecab0 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -38,6 +38,9 @@ config BITREV
 config QSORT
 	bool
 
+config XYMODEM
+	bool
+
 source lib/gui/Kconfig
 
 endmenu
diff --git a/lib/Makefile b/lib/Makefile
index 41e6a0f..eb0af92 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -35,3 +35,4 @@ obj-$(CONFIG_BCH)	+= bch.o
 obj-$(CONFIG_BITREV)	+= bitrev.o
 obj-$(CONFIG_QSORT)	+= qsort.o
 obj-y			+= gui/
+obj-$(CONFIG_XYMODEM)	+= xymodem.o
diff --git a/lib/xymodem.c b/lib/xymodem.c
new file mode 100644
index 0000000..1469a9a
--- /dev/null
+++ b/lib/xymodem.c
@@ -0,0 +1,591 @@
+/*
+ * Handles the X-Modem, Y-Modem and Y-Modem/G protocols
+ *
+ * Copyright (C) 2008 Robert Jarzmik
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * This file provides functions to receive X-Modem or Y-Modem(/G) protocols.
+ *
+ * References:
+ *   *-Modem: http://www.techfest.com/hardware/modem/xymodem.htm
+ *            XMODEM/YMODEM PROTOCOL REFERENCE, Chuck Forsberg
+ */
+#include <common.h>
+#include <xfuncs.h>
+#include <errno.h>
+#include <crc.h>
+#include <clock.h>
+#include <console.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <fs.h>
+#include <kfifo.h>
+#include <linux/byteorder/generic.h>
+
+
+#define xy_dbg(fmt, args...)
+
+/* Values magic to the protocol */
+#define SOH 0x01
+#define STX 0x02
+#define EOT 0x04
+#define ACK 0x06
+#define BSP 0x08
+#define NAK 0x15
+#define CAN 0x18
+
+#define PROTO_XMODEM	0
+#define PROTO_YMODEM	1
+#define PROTO_YMODEM_G	2
+#define MAX_PROTOS	3
+
+#define CRC_NONE	0	/* No CRC checking */
+#define CRC_ADD8	1	/* Add of all data bytes */
+#define CRC_CRC16	2	/* CCCIT CRC16 */
+#define MAX_CRCS	3
+
+#define MAX_RETRIES		10
+#define MAX_RETRIES_WITH_CRC	5
+#define TIMEOUT_READ		(1 * SECOND)
+#define MAX_CAN_BEFORE_ABORT	5
+#define INPUT_FIFO_SIZE		(4 * 1024)	/* Should always be > 1029 */
+
+enum proto_state {
+	PROTO_STATE_GET_FILENAME = 0,
+	PROTO_STATE_NEGOCIATE_CRC,
+	PROTO_STATE_RECEIVE_BODY,
+	PROTO_STATE_FINISHED_FILE,
+	PROTO_STATE_FINISHED_XFER,
+};
+
+/**
+ * struct xyz_ctxt - context of a x/y modem (g) transfer
+ *
+ * @cdev: console device to support *MODEM transfer
+ * @fifo: fifo to buffer input from serial line
+ *        This is necessary for low hardware FIFOs buffers as UARTs.
+ * @mode: protocol (XMODEM, YMODEM or YMODEM/G)
+ * @crc_mode: CRC_NONE, CRC_ADD8 or CRC_CRC16
+ * @state: protocol state (as in "state machine")
+ * @buf: buffer to store the last tranfered buffer chunk
+ * @filename : filename transmitted by sender (YMODEM* only)
+ * @fd : file descriptor of the current stored file
+ * @file_len: length declared by sender (YMODEM* only)
+ * @nb_received: number of data bytes received since session open
+ *               (this doesn't count resends)
+ * @total_SOH: number of SOH frames received (128 bytes chunks)
+ * @total_STX: number of STX frames received (1024 bytes chunks)
+ * @total_CAN: nubmer of CAN frames received (cancel frames)
+ */
+struct xyz_ctxt {
+	struct console_device *cdev;
+	struct kfifo *fifo;
+	int mode;
+	int crc_mode;
+	enum proto_state state;
+	char filename[1024];
+	int fd;
+	int file_len;
+	int nb_received;
+	int next_blk;
+	int total_SOH, total_STX, total_CAN, total_retries;
+};
+
+/**
+ * struct xy_block - one unitary block of x/y modem (g) transfer
+ *
+ * @buf: data buffer
+ * @len: length of data buffer (can only be 128 or 1024)
+ * @seq: block sequence number (as in X/Y/YG MODEM protocol)
+ */
+struct xy_block {
+	unsigned char buf[1024];
+	int len;
+	int seq;
+};
+
+/*
+ * For XMODEM/YMODEM, always try to use the CRC16 versions, called also
+ * XMODEM/CRC and YMODEM.
+ * Only fallback to additive CRC (8 bits) if sender doesn't cope with CRC16.
+ */
+static const char invite_filename_hdr[MAX_PROTOS][MAX_CRCS] = {
+	{ 0, NAK, 'C' },	/* XMODEM */
+	{ 0, NAK, 'C' },	/* YMODEM */
+	{ 0, 'G', 'G' },	/* YMODEM-G */
+};
+
+static const char invite_file_body[MAX_PROTOS][MAX_CRCS] = {
+	{ 0, NAK, 'C' },	/* XMODEM */
+	{ 0, NAK, 'C' },	/* YMODEM */
+	{ 0, 'G', 'G' },	/* YMODEM-G */
+};
+
+static const char block_ack[MAX_PROTOS][MAX_CRCS] = {
+	{ 0, ACK, ACK },	/* XMODEM */
+	{ 0, ACK, ACK },	/* YMODEM */
+	{ 0, 0, 0 },		/* YMODEM-G */
+};
+
+static const char block_nack[MAX_PROTOS][MAX_CRCS] = {
+	{ 0, NAK, NAK },	/* XMODEM */
+	{ 0, NAK, NAK },	/* YMODEM */
+	{ 0, 0, 0 },		/* YMODEM-G */
+};
+
+static int input_fifo_fill(struct console_device *cdev, struct kfifo *fifo)
+{
+	while (cdev->tstc(cdev) && kfifo_len(fifo) < INPUT_FIFO_SIZE)
+		kfifo_putc(fifo, (unsigned char)(cdev->getc(cdev)));
+	return kfifo_len(fifo);
+}
+
+/*
+ * This function is optimized to :
+ * - maximize throughput (ie. read as much as is available in lower layer fifo)
+ * - minimize latencies (no delay or wait timeout if data available)
+ * - have a timeout
+ * This is why standard getc() is not used, and input_fifo_fill() exists.
+ */
+static int xy_gets(struct console_device *cdev, struct kfifo *fifo,
+		      unsigned char *buf, int len, uint64_t timeout)
+{
+	int i, rc;
+	uint64_t start = get_time_ns();
+
+	for (i = 0, rc = 0; rc >= 0 && i < len; ) {
+		if (is_timeout(start, timeout)) {
+			rc = -ETIMEDOUT;
+			continue;
+		}
+		if (input_fifo_fill(cdev, fifo))
+			kfifo_getc(fifo, &buf[i++]);
+	}
+
+	return rc < 0 ? rc : i;
+}
+
+static void xy_putc(struct console_device *cdev, unsigned char c)
+{
+	cdev->putc(cdev, c);
+}
+
+static void xy_flush(struct console_device *cdev, struct kfifo *fifo)
+{
+	while (cdev->tstc(cdev))
+		cdev->getc(cdev);
+	mdelay(250);
+	while (cdev->tstc(cdev))
+		cdev->getc(cdev);
+	kfifo_reset(fifo);
+}
+
+static int is_xmodem(struct xyz_ctxt *proto)
+{
+	return proto->mode == PROTO_XMODEM;
+}
+
+static void xy_block_ack(struct xyz_ctxt *proto)
+{
+	unsigned char c = block_ack[proto->mode][proto->crc_mode];
+
+	if (c)
+		xy_putc(proto->cdev, c);
+}
+
+static void xy_block_nack(struct xyz_ctxt *proto)
+{
+	unsigned char c = block_nack[proto->mode][proto->crc_mode];
+
+	if (c)
+		xy_putc(proto->cdev, c);
+	proto->total_retries++;
+}
+
+static int check_crc(unsigned char *buf, int len, int crc, int crc_mode)
+{
+	unsigned char crc8 = 0;
+	uint16_t crc16;
+	int i;
+
+	switch (crc_mode) {
+	case CRC_ADD8:
+		for (i = 0; i < len; i++)
+			crc8 += buf[i];
+		return crc8 == crc ? 0 : -EBADMSG;
+	case CRC_CRC16:
+		crc16 = cyg_crc16(buf, len);
+		xy_dbg("crc16: received = %x, calculated=%x\n", crc, crc16);
+		return crc16 == crc ? 0 : -EBADMSG;
+	case CRC_NONE:
+		return 0;
+	default:
+		return -EBADMSG;
+	}
+}
+
+/**
+ * xy_read_block - read a X-Modem or Y-Modem(G) block
+ * @proto: protocol control structure
+ * @blk: block read
+ * @timeout: maximal time to get data
+ *
+ * This is the pivotal function for block receptions. It attempts to receive one
+ * block, ie. one 128 bytes or one 1024 bytes block.  The received data can also
+ * be an end of transmission, or a cancel.
+ *
+ * Returns :
+ *  >0           : size of the received block
+ *  0            : last block, ie. end of transmission, ie. EOT
+ * -EBADMSG      : malformed message (ie. sequence bi-bytes are not
+ *                 complementary), or CRC check error
+ * -EILSEQ       : block sequence number error wrt previously received block
+ * -ETIMEDOUT    : block not received before timeout passed
+ * -ECONNABORTED : transfer aborted by sender, ie. CAN
+ */
+static ssize_t xy_read_block(struct xyz_ctxt *proto, struct xy_block *blk,
+	uint64_t timeout)
+{
+	ssize_t rc, data_len = 0;
+	unsigned char hdr, seqs[2], crcs[2];
+	int crc = 0, hdr_found = 0;
+	uint64_t start = get_time_ns();
+
+	while (!hdr_found) {
+		rc = xy_gets(proto->cdev, proto->fifo, &hdr, 1, timeout);
+		xy_dbg("read 0x%x(%c) -> %d\n", hdr, hdr, rc);
+		if (rc < 0)
+			goto out;
+		if (is_timeout(start, timeout))
+			goto timeout;
+		switch (hdr) {
+		case SOH:
+			data_len = 128;
+			hdr_found = 1;
+			proto->total_SOH++;
+			break;
+		case STX:
+			data_len = 1024;
+			hdr_found = 1;
+			proto->total_STX++;
+			break;
+		case CAN:
+			rc = -ECONNABORTED;
+			if (proto->total_CAN++ > MAX_CAN_BEFORE_ABORT)
+				goto out;
+			break;
+		case EOT:
+			rc = 0;
+			blk->len = 0;
+			goto out;
+		default:
+			break;
+		}
+	}
+
+	blk->seq = 0;
+	rc = xy_gets(proto->cdev, proto->fifo, seqs, 2, timeout);
+	if (rc < 0)
+		goto out;
+	blk->seq = seqs[0];
+	if (255 - seqs[0] != seqs[1])
+		return -EBADMSG;
+
+	rc = xy_gets(proto->cdev, proto->fifo, blk->buf, data_len, timeout);
+	if (rc < 0)
+		goto out;
+	blk->len = rc;
+
+	switch (proto->crc_mode) {
+	case CRC_ADD8:
+		rc = xy_gets(proto->cdev, proto->fifo, crcs, 1, timeout);
+		crc = crcs[0];
+		break;
+	case CRC_CRC16:
+		rc = xy_gets(proto->cdev, proto->fifo, crcs, 2, timeout);
+		crc = be16_to_cpu(*(uint16_t *)crcs);
+		break;
+	case CRC_NONE:
+		rc = 0;
+		break;
+	}
+	if (rc < 0)
+		goto out;
+
+	rc = check_crc(blk->buf, data_len, crc, proto->crc_mode);
+	if (rc < 0)
+		goto out;
+	return data_len;
+timeout:
+	return -ETIMEDOUT;
+out:
+	return rc;
+}
+
+static int check_blk_seq(struct xyz_ctxt *proto, struct xy_block *blk,
+	int read_rc)
+{
+	if (blk->seq == ((proto->next_blk - 1) % 256))
+		return -EALREADY;
+	if (blk->seq != proto->next_blk)
+		return -EILSEQ;
+	return read_rc;
+}
+
+static int parse_first_block(struct xyz_ctxt *proto, struct xy_block *blk)
+{
+	int filename_len;
+	char *str_num;
+
+	filename_len = strlen(blk->buf);
+	if (filename_len > blk->len)
+		return -EINVAL;
+	memset(proto->filename, 0, sizeof(proto->filename));
+	strncpy(proto->filename, blk->buf, filename_len);
+	str_num = blk->buf + filename_len + 1;
+	strsep(&str_num, " ");
+	proto->file_len = simple_strtoul(blk->buf + filename_len + 1, NULL, 10);
+	return 1;
+}
+
+static int xy_get_file_header(struct xyz_ctxt *proto)
+{
+	struct xy_block blk;
+	int tries, rc = 0;
+
+	memset(&blk, 0, sizeof(blk));
+	proto->state = PROTO_STATE_GET_FILENAME;
+	proto->crc_mode = CRC_CRC16;
+	for (tries = 0; tries < MAX_RETRIES; tries++) {
+		xy_putc(proto->cdev,
+			   invite_filename_hdr[proto->mode][proto->crc_mode]);
+		rc = xy_read_block(proto, &blk, 3 * SECOND);
+		xy_dbg("read block returned %d\n", rc);
+		switch (rc) {
+		case -ECONNABORTED:
+			goto fail;
+		case -ETIMEDOUT:
+		case -EBADMSG:
+			if (proto->mode != PROTO_YMODEM_G)
+				xy_flush(proto->cdev, proto->fifo);
+			break;
+		case -EALREADY:
+		default:
+			proto->next_blk = 1;
+			xy_block_ack(proto);
+			proto->state = PROTO_STATE_NEGOCIATE_CRC;
+			rc = parse_first_block(proto, &blk);
+			return rc;
+		}
+
+		if (rc < 0 && tries++ >= MAX_RETRIES_WITH_CRC)
+			proto->crc_mode = CRC_ADD8;
+	}
+	rc = -ETIMEDOUT;
+fail:
+	proto->total_retries += tries;
+	return rc;
+}
+
+static int xy_await_header(struct xyz_ctxt *proto)
+{
+	int rc;
+
+	rc = xy_get_file_header(proto);
+	if (rc < 0)
+		return rc;
+	proto->state = PROTO_STATE_NEGOCIATE_CRC;
+	xy_dbg("header received, filename=%s, file length=%d\n",
+	       proto->filename, proto->file_len);
+	if (proto->filename[0])
+		proto->fd = open(proto->filename, O_WRONLY | O_CREAT);
+	else
+		proto->state = PROTO_STATE_FINISHED_XFER;
+	proto->nb_received = 0;
+	return rc;
+}
+
+static void xy_finish_file(struct xyz_ctxt *proto)
+{
+	close(proto->fd);
+	proto->fd = 0;
+	proto->state = PROTO_STATE_FINISHED_FILE;
+}
+
+static struct xyz_ctxt *xymodem_open(struct console_device *cdev,
+				     int proto_mode, int xmodem_fd)
+{
+	struct xyz_ctxt *proto;
+
+	proto = xzalloc(sizeof(struct xyz_ctxt));
+	proto->fifo = kfifo_alloc(INPUT_FIFO_SIZE);
+	proto->mode = proto_mode;
+	proto->cdev = cdev;
+	proto->crc_mode = CRC_CRC16;
+
+	if (is_xmodem(proto)) {
+		proto->fd = xmodem_fd;
+		proto->state = PROTO_STATE_NEGOCIATE_CRC;
+	} else {
+		proto->state = PROTO_STATE_GET_FILENAME;
+	}
+	xy_flush(proto->cdev, proto->fifo);
+	return proto;
+}
+
+static int xymodem_handle(struct xyz_ctxt *proto)
+{
+	int rc = 0, xfer_max, len = 0, again = 1, remain;
+	int crc_tries = 0, same_blk_retries = 0;
+	unsigned char invite;
+	struct xy_block blk;
+
+	while (again) {
+		switch (proto->state) {
+		case PROTO_STATE_GET_FILENAME:
+			crc_tries = 0;
+			rc = xy_await_header(proto);
+			if (rc < 0)
+				goto fail;
+			continue;
+		case PROTO_STATE_FINISHED_FILE:
+			if (is_xmodem(proto))
+				proto->state = PROTO_STATE_FINISHED_XFER;
+			else
+				proto->state = PROTO_STATE_GET_FILENAME;
+			xy_putc(proto->cdev, ACK);
+			continue;
+		case PROTO_STATE_FINISHED_XFER:
+			again = 0;
+			rc = 0;
+			goto out;
+		case PROTO_STATE_NEGOCIATE_CRC:
+			invite = invite_file_body[proto->mode][proto->crc_mode];
+			proto->next_blk = 1;
+			if (crc_tries++ > MAX_RETRIES_WITH_CRC)
+				proto->crc_mode = CRC_ADD8;
+			xy_putc(proto->cdev, invite);
+			/* Fall through */
+		case PROTO_STATE_RECEIVE_BODY:
+			rc = xy_read_block(proto, &blk, 3 * SECOND);
+			if (rc > 0) {
+				rc = check_blk_seq(proto, &blk, rc);
+				proto->state = PROTO_STATE_RECEIVE_BODY;
+			}
+			break;
+		}
+
+		if (proto->state != PROTO_STATE_RECEIVE_BODY)
+			continue;
+
+		switch (rc) {
+		case -ECONNABORTED:
+			goto fail;
+		case -ETIMEDOUT:
+			if (proto->mode == PROTO_YMODEM_G)
+				goto fail;
+			xy_flush(proto->cdev, proto->fifo);
+			xy_block_nack(proto);
+			break;
+		case -EBADMSG:
+		case -EILSEQ:
+			if (proto->mode == PROTO_YMODEM_G)
+				goto fail;
+			xy_flush(proto->cdev, proto->fifo);
+			xy_block_nack(proto);
+			break;
+		case -EALREADY:
+			xy_block_ack(proto);
+			break;
+		case 0:
+			xy_finish_file(proto);
+			break;
+		default:
+			remain = proto->file_len - proto->nb_received;
+			if (is_xmodem(proto))
+				xfer_max = blk.len;
+			else
+				xfer_max = min(blk.len, remain);
+			rc = write(proto->fd, blk.buf, xfer_max);
+			proto->next_blk = ((blk.seq + 1) % 256);
+			proto->nb_received += rc;
+			len += rc;
+			xy_block_ack(proto);
+			break;
+		}
+		if (rc < 0)
+			same_blk_retries++;
+		else
+			same_blk_retries = 0;
+		if (same_blk_retries > MAX_RETRIES)
+			goto fail;
+	}
+out:
+	return rc;
+fail:
+	if (proto->fd)
+		close(proto->fd);
+	return rc;
+}
+
+static void xymodem_close(struct xyz_ctxt *proto)
+{
+	xy_flush(proto->cdev, proto->fifo);
+	printf("\nxyModem - %d(SOH)/%d(STX)/%d(CAN) packets,"
+	       " %d retries\n",
+	       proto->total_SOH, proto->total_STX,
+	       proto->total_CAN, proto->total_retries);
+	kfifo_free(proto->fifo);
+}
+
+int do_load_serial_xmodem(struct console_device *cdev, int fd)
+{
+	struct xyz_ctxt *proto;
+	int rc;
+
+	proto = xymodem_open(cdev, PROTO_XMODEM, fd);
+	do {
+		rc = xymodem_handle(proto);
+	} while (rc > 0);
+	xymodem_close(proto);
+	return rc < 0 ? rc : 0;
+}
+EXPORT_SYMBOL(do_load_serial_xmodem);
+
+int do_load_serial_ymodem(struct console_device *cdev)
+{
+	struct xyz_ctxt *proto;
+	int rc;
+
+	proto = xymodem_open(cdev, PROTO_YMODEM, 0);
+	do {
+		rc = xymodem_handle(proto);
+	} while (rc > 0);
+	xymodem_close(proto);
+	return rc < 0 ? rc : 0;
+}
+EXPORT_SYMBOL(do_load_serial_ymodem);
+
+int do_load_serial_ymodemg(struct console_device *cdev)
+{
+	struct xyz_ctxt *proto;
+	int rc;
+
+	proto = xymodem_open(cdev, PROTO_YMODEM_G, 0);
+	do {
+		rc = xymodem_handle(proto);
+	} while (rc > 0);
+	xymodem_close(proto);
+	return rc < 0 ? rc : 0;
+}
+EXPORT_SYMBOL(do_load_serial_ymodemg);
-- 
1.7.10



From robert.jarzmik at free.fr  Sun Nov  4 12:55:24 2012
From: robert.jarzmik at free.fr (Robert Jarzmik)
Date: Sun,  4 Nov 2012 18:55:24 +0100
Subject: [PATCH v2 2/2] commands: remove old Y-Modem implementation
In-Reply-To: <1352051724-16253-1-git-send-email-robert.jarzmik@free.fr>
References: <1351791438-29967-1-git-send-email-robert.jarzmik@free.fr>
 <1352051724-16253-1-git-send-email-robert.jarzmik@free.fr>
Message-ID: <1352051724-16253-2-git-send-email-robert.jarzmik@free.fr>

From: Robert Jarzmik <robert.jarzmik at intel.com>

As a new implementation of Y-Modem protocol is available,
switch from old implementation to the new one :
 - remove old xyzModem* files
 - remove old command loady2
 - rename command loady2 to loady

Signed-off-by: Robert Jarzmik <robert.jarzmik at intel.com>
---
 commands/Makefile   |    4 +-
 commands/loadb.c    |  102 +------
 commands/loads.c    |    1 -
 commands/loadxy.c   |    2 +-
 commands/xyzModem.c |  785 ---------------------------------------------------
 include/xyzModem.h  |  109 -------
 6 files changed, 12 insertions(+), 991 deletions(-)
 delete mode 100644 commands/xyzModem.c
 delete mode 100644 include/xyzModem.h

diff --git a/commands/Makefile b/commands/Makefile
index 44ad904..14c68dd 100644
--- a/commands/Makefile
+++ b/commands/Makefile
@@ -2,8 +2,8 @@ obj-$(CONFIG_STDDEV)		+= stddev.o
 obj-$(CONFIG_CMD_BOOTM)		+= bootm.o
 obj-$(CONFIG_CMD_UIMAGE)	+= uimage.o
 obj-$(CONFIG_CMD_LINUX16)	+= linux16.o
-obj-$(CONFIG_CMD_LOADB)		+= loadb.o xyzModem.o
-obj-$(CONFIG_CMD_LOADY)		+= loadb.o xyzModem.o loadxy.o
+obj-$(CONFIG_CMD_LOADB)		+= loadb.o
+obj-$(CONFIG_CMD_LOADY)		+= loadxy.o
 obj-$(CONFIG_CMD_LOADS)		+= loads.o
 obj-$(CONFIG_CMD_ECHO)		+= echo.o
 obj-$(CONFIG_CMD_MEMORY)	+= mem.o
diff --git a/commands/loadb.c b/commands/loadb.c
index 898b9e3..a2f3315 100644
--- a/commands/loadb.c
+++ b/commands/loadb.c
@@ -31,7 +31,6 @@
  */
 #include <common.h>
 #include <command.h>
-#include <xyzModem.h>
 #include <console.h>
 #include <errno.h>
 #include <environment.h>
@@ -59,8 +58,6 @@
 
 static int ofd;			/* output file descriptor */
 
-#ifdef CONFIG_CMD_LOADB
-
 /* Size of my buffer to write to o/p file */
 #define MAX_WRITE_BUFFER 4096	/* Write size to o/p file */
 static char *write_buffer;	/* buffer for finalized data to write */
@@ -593,66 +590,6 @@ err_quit:
 	return size;
 }
 
-#endif				/* CONFIG_CMD_LOADB */
-
-#ifdef CONFIG_CMD_LOADY
-/**
- * @brief getcxmodem
- *
- * @return if character avaiable, return the same, else return -1
- */
-static int getcxmodem(void)
-{
-	if (tstc())
-		return (getc());
-	return -1;
-}
-
-/**
- * @brief  LoadY over ymodem protocol
- *
- * @return download size
- */
-static ulong load_serial_ymodem(void)
-{
-	int size;
-	char buf[32];
-	int err;
-	int res, wr;
-	connection_info_t info;
-	char ymodemBuf[1024];
-	ulong addr = 0;
-
-	size = 0;
-	info.mode = xyzModem_ymodem;
-	res = xyzModem_stream_open(&info, &err);
-	if (!res) {
-		while ((res = xyzModem_stream_read(ymodemBuf, 1024, &err)) >
-				0) {
-			size += res;
-			addr += res;
-			wr = write(ofd, ymodemBuf, res);
-			if (res != wr) {
-				perror("ymodem");
-				break;
-			}
-
-		}
-	} else {
-		printf("%s\n", xyzModem_error(err));
-	}
-
-	xyzModem_stream_close(&err);
-	xyzModem_stream_terminate(false, &getcxmodem);
-
-	printf("## Total Size      = 0x%08x = %d Bytes\n", size, size);
-	sprintf(buf, "%X", size);
-	setenv("filesize", buf);
-
-	return res;
-}
-#endif
-
 /**
  * @brief returns current used console device
  *
@@ -754,27 +691,16 @@ static int do_load_serial_bin(int argc, char *argv[])
 				break;
 		}
 	}
-#ifdef CONFIG_CMD_LOADY
-	if (strcmp(argv[0], "loady") == 0) {
-		printf("## Ready for binary (ymodem) download "
-		       "to 0x%08lX offset on %s device at %d bps...\n", offset,
-		       output_file, load_baudrate);
-		addr = load_serial_ymodem();
-	}
-#endif
-#ifdef CONFIG_CMD_LOADB
-	if (strcmp(argv[0], "loadb") == 0) {
-
-		printf("## Ready for binary (kermit) download "
-		       "to 0x%08lX offset on %s device at %d bps...\n", offset,
-		       output_file, load_baudrate);
-		addr = load_serial_bin();
-		if (addr == 0) {
-			printf("## Binary (kermit) download aborted\n");
-			rcode = 1;
-		}
+
+	printf("## Ready for binary (kermit) download "
+	       "to 0x%08lX offset on %s device at %d bps...\n", offset,
+	       output_file, load_baudrate);
+	addr = load_serial_bin();
+	if (addr == 0) {
+		printf("## Binary (kermit) download aborted\n");
+		rcode = 1;
 	}
-#endif
+
 	if (load_baudrate != current_baudrate) {
 		printf("## Switch baudrate to %d bps and press ESC ...\n",
 		       current_baudrate);
@@ -799,18 +725,8 @@ static const __maybe_unused char cmd_loadb_help[] =
     "  -b baud   - baudrate at which to download - defaults to "
     "console baudrate\n"
     "  -c        - Create file if it is not present - default disabled";
-#ifdef CONFIG_CMD_LOADB
 BAREBOX_CMD_START(loadb)
 	.cmd = do_load_serial_bin,
 	.usage = "Load binary file over serial line (kermit mode)",
 	BAREBOX_CMD_HELP(cmd_loadb_help)
 BAREBOX_CMD_END
-#endif
-#ifdef CONFIG_CMD_LOADY
-BAREBOX_CMD_START(loady)
-	.cmd = do_load_serial_bin,
-	.usage = "Load binary file over serial line (ymodem mode)",
-	BAREBOX_CMD_HELP(cmd_loadb_help)
-BAREBOX_CMD_END
-#endif
-
diff --git a/commands/loads.c b/commands/loads.c
index 7f4c647..bfc465b 100644
--- a/commands/loads.c
+++ b/commands/loads.c
@@ -25,7 +25,6 @@
 #include <environment.h>
 #include <s_record.h>
 #include <net.h>
-#include <xyzModem.h>
 
 static ulong load_serial(ulong offset);
 static int read_record(char *buf, ulong len);
diff --git a/commands/loadxy.c b/commands/loadxy.c
index 141bd7b..8914655 100644
--- a/commands/loadxy.c
+++ b/commands/loadxy.c
@@ -230,7 +230,7 @@ static const __maybe_unused char cmd_loady_help[] =
 	"console baudrate\n";
 
 #ifdef CONFIG_CMD_LOADY
-BAREBOX_CMD_START(loady2)
+BAREBOX_CMD_START(loady)
 	.cmd = do_loady,
 	.usage = "Load binary file over serial line (Y-Modem or Y-Modem/G)",
 BAREBOX_CMD_HELP(cmd_loady_help)
diff --git a/commands/xyzModem.c b/commands/xyzModem.c
deleted file mode 100644
index 71d7d68..0000000
--- a/commands/xyzModem.c
+++ /dev/null
@@ -1,785 +0,0 @@
-/**
- * @file
- * @brief RedBoot stream handler for xyzModem protocol
- *
- * FileName: commands/xyzModem.c
- * Originally from u-boot xyzModem.c
- */
-/*
- * 2008 - Nishanth Menon <x0nishan at ti.com>
- * Modified for sparse and checkpatch.pl compliance
- */
-/*
- *==========================================================================
- *
- *      xyzModem.c
- *
- *      RedBoot stream handler for xyzModem protocol
- *
- *==========================================================================
- *####ECOSGPLCOPYRIGHTBEGIN####
- * -------------------------------------------
- * This file is part of eCos, the Embedded Configurable Operating System.
- * Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
- * Copyright (C) 2002 Gary Thomas
- *
- * eCos is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 or (at your option) any later version.
- *
- * eCos is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with eCos; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * As a special exception, if other files instantiate templates or use macros
- * or inline functions from this file, or you compile this file and link it
- * with other works to produce a work based on this file, this file does not
- * by itself cause the resulting work to be covered by the GNU General Public
- * License. However the source code for this file must still be made available
- * in accordance with section (3) of the GNU General Public License.
- *
- * This exception does not invalidate any other reasons why a work based on
- * this file might be covered by the GNU General Public License.
- *
- * Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
- * at http: *sources.redhat.com/ecos/ecos-license/
- * -------------------------------------------
- *####ECOSGPLCOPYRIGHTEND####
- *==========================================================================
- *#####DESCRIPTIONBEGIN####
- *
- * Author(s):    gthomas
- * Contributors: gthomas, tsmith, Yoshinori Sato
- * Date:         2000-07-14
- * Purpose:
- * Description:
- *
- * This code is part of RedBoot (tm).
- *
- *####DESCRIPTIONEND####
- *
- *==========================================================================
- */
-#include <common.h>
-#include <xyzModem.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <console.h>
-#include <crc.h>
-#include <linux/ctype.h>
-
-/* Assumption - run xyzModem protocol over the console port */
-
-/* Values magic to the protocol */
-#define SOH 0x01
-#define STX 0x02
-#define EOT 0x04
-#define ACK 0x06
-#define BSP 0x08
-#define NAK 0x15
-#define CAN 0x18
-#define EOF 0x1A		/* ^Z for DOS officionados */
-
-#define USE_YMODEM_LENGTH
-
-/* Data & state local to the protocol */
-static struct {
-#ifdef REDBOOT
-	hal_virtual_comm_table_t *__chan;
-#else
-	int *__chan;
-#endif
-	unsigned char pkt[1024], *bufp;
-	unsigned char blk, cblk, crc1, crc2;
-	unsigned char next_blk;	/* Expected block */
-	int len, mode, total_retries;
-	int total_SOH, total_STX, total_CAN;
-	bool crc_mode, at_eof, tx_ack;
-#ifdef USE_YMODEM_LENGTH
-	unsigned long file_length, read_length;
-#endif
-} xyz;
-
-#define xyzModem_CHAR_TIMEOUT            2000	/* 2 seconds */
-#define xyzModem_MAX_RETRIES             20
-#define xyzModem_MAX_RETRIES_WITH_CRC    10
-/* Wait for 3 CAN before quitting */
-#define xyzModem_CAN_COUNT                3
-
-#ifndef REDBOOT			/*SB */
-typedef int cyg_int32;
-static int CYGACC_COMM_IF_GETC_TIMEOUT(char chan, char *c)
-{
-#define DELAY 20
-	unsigned long counter = 0;
-	while (!tstc() && (counter < xyzModem_CHAR_TIMEOUT * 1000 / DELAY)) {
-		udelay(DELAY);
-		counter++;
-	}
-	if (tstc()) {
-		*c = getc();
-		return 1;
-	}
-	return 0;
-}
-
-static void CYGACC_COMM_IF_PUTC(char x, char y)
-{
-	console_putc(CONSOLE_STDOUT, y);
-}
-
-/* Validate a hex character */
-static inline bool _is_hex(char c)
-{
-	return (((c >= '0') && (c <= '9')) ||
-		((c >= 'A') && (c <= 'F')) || ((c >= 'a') && (c <= 'f')));
-}
-
-/* Convert a single hex nibble */
-static inline int _from_hex(char c)
-{
-	int ret = 0;
-
-	if ((c >= '0') && (c <= '9'))
-		ret = (c - '0');
-	else if ((c >= 'a') && (c <= 'f'))
-		ret = (c - 'a' + 0x0a);
-	else if ((c >= 'A') && (c <= 'F'))
-		ret = (c - 'A' + 0x0A);
-
-	return ret;
-}
-
-/* Parse (scan) a number */
-static bool parse_num(char *s, unsigned long *val, char **es, char *delim)
-{
-	bool first = true;
-	int radix = 10;
-	char c;
-	unsigned long result = 0;
-	int digit = 0;
-
-	while (*s == ' ')
-		s++;
-	while (*s) {
-		if (first && (s[0] == '0') && (tolower(s[1]) == 'x')) {
-			radix = 16;
-			s += 2;
-		}
-		first = false;
-		c = *s++;
-		if (_is_hex(c))
-			digit = _from_hex(c);
-		if (_is_hex(c) && (digit < radix)) {
-			/* Valid digit */
-#ifdef CYGPKG_HAL_MIPS
-			/* FIXME: tx49 compiler generates 0x2539018 for
-			 * MUL which isn't any good. */
-			if (16 == radix)
-				result = result << 4;
-			else
-				result = 10 * result;
-			result += digit;
-#else
-			result = (result * radix) + digit;
-#endif
-		} else {
-			if (delim != (char *)0) {
-				/* See if this character is one of the
-				 * delimiters */
-				char *dp = delim;
-				while (*dp && (c != *dp))
-					dp++;
-				if (*dp)
-					break;	/* Found a good delimiter */
-			}
-			return false;	/* Malformatted number */
-		}
-	}
-	*val = result;
-	if (es != (char **)0)
-		*es = s;
-	return true;
-}
-
-#endif
-
-#define USE_SPRINTF
-#ifdef DEBUG
-#ifndef USE_SPRINTF
-/*
- * Note: this debug setup only works if the target platform has two serial ports
- * available so that the other one (currently only port 1) can be used for debug
- * messages.
- */
-static int zm_dprintf(char *fmt, ...)
-{
-	int cur_console;
-	va_list args;
-
-	va_start(args, fmt);
-#ifdef REDBOOT
-	cur_console =
-	    CYGACC_CALL_IF_SET_CONSOLE_COMM
-	    (CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT);
-	CYGACC_CALL_IF_SET_CONSOLE_COMM(1);
-#endif
-	diag_vprintf(fmt, args);
-#ifdef REDBOOT
-	CYGACC_CALL_IF_SET_CONSOLE_COMM(cur_console);
-#endif
-}
-
-static void zm_flush(void)
-{
-}
-
-#else
-/*
- * Note: this debug setup works by storing the strings in a fixed buffer
- */
-#define FINAL
-#ifdef FINAL
-static char *zm_out = (char *)0x00380000;
-static char *zm_out_start = (char *)0x00380000;
-#else
-static char zm_buf[8192];
-static char *zm_out = zm_buf;
-static char *zm_out_start = zm_buf;
-
-#endif
-static int zm_dprintf(char *fmt, ...)
-{
-	int len;
-	va_list args;
-
-	va_start(args, fmt);
-	len = diag_vsprintf(zm_out, fmt, args);
-	zm_out += len;
-	return len;
-}
-
-static void zm_flush(void)
-{
-#ifdef REDBOOT
-	char *p = zm_out_start;
-	while (*p)
-		mon_write_char(*p++);
-#endif
-	zm_out = zm_out_start;
-}
-#endif
-
-static void zm_dump_buf(void *buf, int len)
-{
-#ifdef REDBOOT
-	diag_vdump_buf_with_offset(zm_dprintf, buf, len, 0);
-#else
-
-#endif
-}
-
-static unsigned char zm_buf[2048];
-static unsigned char *zm_bp;
-
-static void zm_new(void)
-{
-	zm_bp = zm_buf;
-}
-
-static void zm_save(unsigned char c)
-{
-	*zm_bp++ = c;
-}
-
-static void zm_dump(int line)
-{
-	zm_dprintf("Packet at line: %d\n", line);
-	zm_dump_buf(zm_buf, zm_bp - zm_buf);
-}
-
-#define ZM_DEBUG(x) x
-#else
-#define ZM_DEBUG(x)
-#endif
-
-/* Wait for the line to go idle */
-static void xyzModem_flush(void)
-{
-	int res;
-	char c;
-	while (true) {
-		res = CYGACC_COMM_IF_GETC_TIMEOUT(*xyz.__chan, &c);
-		if (!res)
-			return;
-	}
-}
-
-static int xyzModem_get_hdr(void)
-{
-	char c;
-	int res;
-	bool hdr_found = false;
-	int i, can_total, hdr_chars;
-	unsigned short cksum;
-
-	ZM_DEBUG(zm_new());
-	/* Find the start of a header */
-	can_total = 0;
-	hdr_chars = 0;
-
-	if (xyz.tx_ack) {
-		CYGACC_COMM_IF_PUTC(*xyz.__chan, ACK);
-		xyz.tx_ack = false;
-	}
-	while (!hdr_found) {
-		res = CYGACC_COMM_IF_GETC_TIMEOUT(*xyz.__chan, &c);
-		ZM_DEBUG(zm_save(c));
-		if (res) {
-			hdr_chars++;
-			switch (c) {
-			case SOH:
-				xyz.total_SOH++;
-			case STX:
-				if (c == STX)
-					xyz.total_STX++;
-				hdr_found = true;
-				break;
-			case CAN:
-				xyz.total_CAN++;
-				ZM_DEBUG(zm_dump(__LINE__));
-				if (++can_total == xyzModem_CAN_COUNT) {
-					return xyzModem_cancel;
-				} else {
-					/* Wait for multiple CAN to avoid
-					 * early quits */
-					break;
-				}
-			case EOT:
-				/* EOT only supported if no noise */
-				if (hdr_chars == 1) {
-					CYGACC_COMM_IF_PUTC(*xyz.__chan, ACK);
-					ZM_DEBUG(zm_dprintf
-						 ("ACK on EOT #%d\n",
-						  __LINE__));
-					ZM_DEBUG(zm_dump(__LINE__));
-					return xyzModem_eof;
-				}
-			default:
-				/* Ignore, waiting for start of header */
-				;
-			}
-		} else {
-			/* Data stream timed out */
-			xyzModem_flush();	/* Toss any current input */
-			ZM_DEBUG(zm_dump(__LINE__));
-			CYGACC_CALL_IF_DELAY_US((cyg_int32) 250000);
-			return xyzModem_timeout;
-		}
-	}
-
-	/* Header found, now read the data */
-	res = CYGACC_COMM_IF_GETC_TIMEOUT(*xyz.__chan, (char *)&xyz.blk);
-	ZM_DEBUG(zm_save(xyz.blk));
-	if (!res) {
-		ZM_DEBUG(zm_dump(__LINE__));
-		return xyzModem_timeout;
-	}
-	res = CYGACC_COMM_IF_GETC_TIMEOUT(*xyz.__chan, (char *)&xyz.cblk);
-	ZM_DEBUG(zm_save(xyz.cblk));
-	if (!res) {
-		ZM_DEBUG(zm_dump(__LINE__));
-		return xyzModem_timeout;
-	}
-	xyz.len = (c == SOH) ? 128 : 1024;
-	xyz.bufp = xyz.pkt;
-	for (i = 0; i < xyz.len; i++) {
-		res = CYGACC_COMM_IF_GETC_TIMEOUT(*xyz.__chan, &c);
-		ZM_DEBUG(zm_save(c));
-		if (res) {
-			xyz.pkt[i] = c;
-		} else {
-			ZM_DEBUG(zm_dump(__LINE__));
-			return xyzModem_timeout;
-		}
-	}
-	res = CYGACC_COMM_IF_GETC_TIMEOUT(*xyz.__chan, (char *)&xyz.crc1);
-	ZM_DEBUG(zm_save(xyz.crc1));
-	if (!res) {
-		ZM_DEBUG(zm_dump(__LINE__));
-		return xyzModem_timeout;
-	}
-	if (xyz.crc_mode) {
-		res =
-		    CYGACC_COMM_IF_GETC_TIMEOUT(*xyz.__chan, (char *)&xyz.crc2);
-		ZM_DEBUG(zm_save(xyz.crc2));
-		if (!res) {
-			ZM_DEBUG(zm_dump(__LINE__));
-			return xyzModem_timeout;
-		}
-	}
-	ZM_DEBUG(zm_dump(__LINE__));
-	/* Validate the message */
-	if ((xyz.blk ^ xyz.cblk) != (unsigned char)0xFF) {
-		ZM_DEBUG(zm_dprintf
-			 ("Framing error - blk: %x/%x/%x\n", xyz.blk, xyz.cblk,
-			  (xyz.blk ^ xyz.cblk)));
-		ZM_DEBUG(zm_dump_buf(xyz.pkt, xyz.len));
-		xyzModem_flush();
-		return xyzModem_frame;
-	}
-	/* Verify checksum/CRC */
-	if (xyz.crc_mode) {
-		cksum = cyg_crc16(xyz.pkt, xyz.len);
-		if (cksum != ((xyz.crc1 << 8) | xyz.crc2)) {
-			ZM_DEBUG(zm_dprintf
-				 ("CRC error - recvd: %02x%02x, computed: %x\n",
-				  xyz.crc1, xyz.crc2, cksum & 0xFFFF));
-			return xyzModem_cksum;
-		}
-	} else {
-		cksum = 0;
-		for (i = 0; i < xyz.len; i++)
-			cksum += xyz.pkt[i];
-		if (xyz.crc1 != (cksum & 0xFF)) {
-			ZM_DEBUG(zm_dprintf
-				 ("Checksum error - recvd: %x, computed: %x\n",
-				  xyz.crc1, cksum & 0xFF));
-			return xyzModem_cksum;
-		}
-	}
-	/* If we get here, the message passes [structural] muster */
-	return 0;
-}
-
-int xyzModem_stream_open(connection_info_t *info, int *err)
-{
-#ifdef REDBOOT
-	int console_chan;
-#endif
-	int stat = 0;
-	int retries = xyzModem_MAX_RETRIES;
-	int crc_retries = xyzModem_MAX_RETRIES_WITH_CRC;
-
-/*    ZM_DEBUG(zm_out = zm_out_start); */
-#ifdef xyzModem_zmodem
-	if (info->mode == xyzModem_zmodem) {
-		*err = xyzModem_noZmodem;
-		return -1;
-	}
-#endif
-
-#ifdef REDBOOT
-	/* Set up the I/O channel.  Note: this allows for using a different
-	 * port in the future */
-	console_chan =
-	    CYGACC_CALL_IF_SET_CONSOLE_COMM
-	    (CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT);
-	if (info->chan >= 0)
-		CYGACC_CALL_IF_SET_CONSOLE_COMM(info->chan);
-	else
-		CYGACC_CALL_IF_SET_CONSOLE_COMM(console_chan);
-
-	xyz.__chan = CYGACC_CALL_IF_CONSOLE_PROCS();
-
-	CYGACC_CALL_IF_SET_CONSOLE_COMM(console_chan);
-	CYGACC_COMM_IF_CONTROL(*xyz.__chan, __COMMCTL_SET_TIMEOUT,
-			       xyzModem_CHAR_TIMEOUT);
-#else
-/* TODO: CHECK ! */
-	int dummy = 0;
-	xyz.__chan = &dummy;
-#endif
-	xyz.len = 0;
-	xyz.crc_mode = true;
-	xyz.at_eof = false;
-	xyz.tx_ack = false;
-	xyz.mode = info->mode;
-	xyz.total_retries = 0;
-	xyz.total_SOH = 0;
-	xyz.total_STX = 0;
-	xyz.total_CAN = 0;
-#ifdef USE_YMODEM_LENGTH
-	xyz.read_length = 0;
-	xyz.file_length = 0;
-#endif
-
-	CYGACC_COMM_IF_PUTC(*xyz.__chan, (xyz.crc_mode ? 'C' : NAK));
-
-	if (xyz.mode == xyzModem_xmodem) {
-		/* X-modem doesn't have an information header - exit here */
-		xyz.next_blk = 1;
-		return 0;
-	}
-
-	while (retries-- > 0) {
-		stat = xyzModem_get_hdr();
-		if (stat == 0) {
-			/* Y-modem file information header */
-			if (xyz.blk == 0) {
-#ifdef USE_YMODEM_LENGTH
-				/* skip filename */
-				while (*xyz.bufp++) ;
-				/* get the length */
-				parse_num((char *)xyz.bufp, &xyz.file_length,
-					  NULL, " ");
-#endif
-				/* The rest of the file name data block
-				 * quietly discarded
-				 */
-				xyz.tx_ack = true;
-			}
-			xyz.next_blk = 1;
-			xyz.len = 0;
-			return 0;
-		} else if (stat == xyzModem_timeout) {
-			if (--crc_retries <= 0)
-				xyz.crc_mode = false;
-			/* Extra delay for startup */
-			CYGACC_CALL_IF_DELAY_US(5 * 100000);
-			CYGACC_COMM_IF_PUTC(*xyz.__chan,
-					    (xyz.crc_mode ? 'C' : NAK));
-			xyz.total_retries++;
-			ZM_DEBUG(zm_dprintf("NAK (%d)\n", __LINE__));
-		}
-		if (stat == xyzModem_cancel)
-			break;
-	}
-	*err = stat;
-	ZM_DEBUG(zm_flush());
-	return -1;
-}
-
-int xyzModem_stream_read(char *buf, int size, int *err)
-{
-	int stat, total, len;
-	int retries;
-
-	total = 0;
-	stat = xyzModem_cancel;
-	/* Try and get 'size' bytes into the buffer */
-	while (!xyz.at_eof && (size > 0)) {
-		if (xyz.len == 0) {
-			retries = xyzModem_MAX_RETRIES;
-			while (retries-- > 0) {
-				stat = xyzModem_get_hdr();
-				if (stat == 0) {
-					if (xyz.blk == xyz.next_blk) {
-						xyz.tx_ack = true;
-						ZM_DEBUG(zm_dprintf
-							 ("ACK block %d (%d)\n",
-							  xyz.blk, __LINE__));
-						xyz.next_blk =
-						    (xyz.next_blk + 1) & 0xFF;
-
-#if defined(xyzModem_zmodem) || defined(USE_YMODEM_LENGTH)
-						if (xyz.mode == xyzModem_xmodem
-						    || xyz.file_length == 0) {
-#else
-						if (1) {
-#endif
-			/* WARNING - Leaving formatting aside for code
-			 * clarity */
-			/* Data blocks can be padded with ^Z (EOF) characters */
-			/* This code tries to detect and remove them */
-			if ((xyz.bufp[xyz.len - 1] == EOF)
-			    && (xyz.bufp[xyz.len - 2] == EOF)
-			    && (xyz.bufp[xyz.len - 3] == EOF)) {
-				while (xyz.len &&
-					(xyz.bufp[xyz.len - 1] == EOF))
-						xyz.len--;
-				}
-			}
-#ifdef USE_YMODEM_LENGTH
-			/* WARNING - Leaving formatting aside for code
-			 * clarity */
-			/*
-			 * See if accumulated length exceeds that of the file.
-			 * If so, reduce size (i.e., cut out pad bytes)
-			 * Only do this for Y-modem (and Z-modem should it ever
-			 * be supported since it can fall back to Y-modem mode).
-			 */
-			if (xyz.mode != xyzModem_xmodem
-			    && 0 != xyz.file_length) {
-				xyz.read_length += xyz.len;
-				if (xyz.read_length > xyz.file_length)
-					xyz.len -= (xyz.read_length -
-					     xyz.file_length);
-			}
-#endif
-						break;
-					} else if (xyz.blk ==
-						   ((xyz.next_blk - 1) &
-						    0xFF)) {
-						/* Just re-ACK this so sender
-						 * will get on with it */
-						CYGACC_COMM_IF_PUTC(*xyz.__chan,
-								    ACK);
-						/* Need new header */
-						continue;
-					} else
-						stat = xyzModem_sequence;
-				}
-				if (stat == xyzModem_cancel)
-					break;
-				if (stat == xyzModem_eof) {
-					CYGACC_COMM_IF_PUTC(*xyz.__chan, ACK);
-					ZM_DEBUG(zm_dprintf
-						 ("ACK (%d)\n", __LINE__));
-					if (xyz.mode == xyzModem_ymodem) {
-						CYGACC_COMM_IF_PUTC(*xyz.__chan,
-								    (xyz.
-								     crc_mode ?
-								     'C' :
-								     NAK));
-						xyz.total_retries++;
-						ZM_DEBUG(zm_dprintf
-						 ("Reading Final Header\n"));
-						stat = xyzModem_get_hdr();
-						CYGACC_COMM_IF_PUTC(*xyz.__chan,
-								    ACK);
-						ZM_DEBUG(zm_dprintf
-							 ("FINAL ACK (%d)\n",
-							  __LINE__));
-					}
-					xyz.at_eof = true;
-					break;
-				}
-				CYGACC_COMM_IF_PUTC(*xyz.__chan,
-						    (xyz.crc_mode ? 'C' : NAK));
-				xyz.total_retries++;
-				ZM_DEBUG(zm_dprintf("NAK (%d)\n", __LINE__));
-			}
-			if (stat < 0) {
-				*err = stat;
-				xyz.len = -1;
-				return total;
-			}
-		}
-		/* Don't "read" data from the EOF protocol package */
-		if (!xyz.at_eof) {
-			len = xyz.len;
-			if (size < len)
-				len = size;
-			memcpy(buf, xyz.bufp, len);
-			size -= len;
-			buf += len;
-			total += len;
-			xyz.len -= len;
-			xyz.bufp += len;
-		}
-	}
-	return total;
-}
-
-void xyzModem_stream_close(int *err)
-{
-	diag_printf
-	    ("xyzModem - %s mode, %d(SOH)/%d(STX)/%d(CAN) packets,"
-	     " %d retries\n",
-	     xyz.crc_mode ? "CRC" : "Cksum", xyz.total_SOH, xyz.total_STX,
-	     xyz.total_CAN, xyz.total_retries);
-	ZM_DEBUG(zm_flush());
-}
-
-/* Need to be able to clean out the input buffer, so have to take the */
-/* getc */
-void xyzModem_stream_terminate(bool abort, int (*getc) (void))
-{
-	int c;
-
-	if (abort) {
-		ZM_DEBUG(zm_dprintf("!!!! TRANSFER ABORT !!!!\n"));
-		switch (xyz.mode) {
-		case xyzModem_xmodem:
-		case xyzModem_ymodem:
-			/* The X/YMODEM Spec seems to suggest that multiple CAN
-			 * followed by an equal number of Backspaces is a
-			 * friendly way to get the other end to abort. */
-			CYGACC_COMM_IF_PUTC(*xyz.__chan, CAN);
-			CYGACC_COMM_IF_PUTC(*xyz.__chan, CAN);
-			CYGACC_COMM_IF_PUTC(*xyz.__chan, CAN);
-			CYGACC_COMM_IF_PUTC(*xyz.__chan, CAN);
-			CYGACC_COMM_IF_PUTC(*xyz.__chan, BSP);
-			CYGACC_COMM_IF_PUTC(*xyz.__chan, BSP);
-			CYGACC_COMM_IF_PUTC(*xyz.__chan, BSP);
-			CYGACC_COMM_IF_PUTC(*xyz.__chan, BSP);
-			/* Now consume the rest of what's waiting on the line.*/
-			ZM_DEBUG(zm_dprintf("Flushing serial line.\n"));
-			xyzModem_flush();
-			xyz.at_eof = true;
-			break;
-#ifdef xyzModem_zmodem
-		case xyzModem_zmodem:
-			/* Might support it some day I suppose. */
-#endif
-			break;
-		}
-	} else {
-		ZM_DEBUG(zm_dprintf("Engaging cleanup mode...\n"));
-		/*
-		 * Consume any trailing crap left in the inbuffer from
-		 * previous recieved blocks. Since very few files are an
-		 * exact multiple of the transfer block size, there will
-		 * almost always be some gunk here.
-		 * If we don't eat it now, RedBoot will think the user typed it.
-		 */
-		ZM_DEBUG(zm_dprintf("Trailing gunk:\n"));
-		while ((c = (*getc) ()) > -1) ;
-		ZM_DEBUG(zm_dprintf("\n"));
-		/*
-		 * Make a small delay to give terminal programs like minicom
-		 * time to get control again after their file transfer program
-		 * exits.
-		 */
-		CYGACC_CALL_IF_DELAY_US((cyg_int32) 250000);
-	}
-}
-
-char *xyzModem_error(int err)
-{
-	switch (err) {
-	case xyzModem_access:
-		return "Can't access file";
-		break;
-	case xyzModem_noZmodem:
-		return "Sorry, zModem not available yet";
-		break;
-	case xyzModem_timeout:
-		return "Timed out";
-		break;
-	case xyzModem_eof:
-		return "End of file";
-		break;
-	case xyzModem_cancel:
-		return "Cancelled";
-		break;
-	case xyzModem_frame:
-		return "Invalid framing";
-		break;
-	case xyzModem_cksum:
-		return "CRC/checksum error";
-		break;
-	case xyzModem_sequence:
-		return "Block sequence error";
-		break;
-	default:
-		return "Unknown error";
-		break;
-	}
-}
-
-/*
- * RedBoot interface
- */
-#if 0				/* SB */
-GETC_IO_FUNCS(xyzModem_io, xyzModem_stream_open, xyzModem_stream_close,
-	      xyzModem_stream_terminate, xyzModem_stream_read, xyzModem_error);
-RedBoot_load(xmodem, xyzModem_io, false, false, xyzModem_xmodem);
-RedBoot_load(ymodem, xyzModem_io, false, false, xyzModem_ymodem);
-#endif
diff --git a/include/xyzModem.h b/include/xyzModem.h
deleted file mode 100644
index a3ea768..0000000
--- a/include/xyzModem.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- *==========================================================================
- *
- *      xyzModem.h
- *
- *      RedBoot stream handler for xyzModem protocol
- *
- *==========================================================================
- *####ECOSGPLCOPYRIGHTBEGIN####
- * -------------------------------------------
- * This file is part of eCos, the Embedded Configurable Operating System.
- * Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
- * Copyright (C) 2002 Gary Thomas
- *
- * eCos is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 or (at your option) any later version.
- *
- * eCos is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with eCos; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * As a special exception, if other files instantiate templates or use macros
- * or inline functions from this file, or you compile this file and link it
- * with other works to produce a work based on this file, this file does not
- * by itself cause the resulting work to be covered by the GNU General Public
- * License. However the source code for this file must still be made available
- * in accordance with section (3) of the GNU General Public License.
- *
- * This exception does not invalidate any other reasons why a work based on
- * this file might be covered by the GNU General Public License.
- *
- * Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
- * at http: *sources.redhat.com/ecos/ecos-license/
- * -------------------------------------------
- *####ECOSGPLCOPYRIGHTEND####
- *==========================================================================
- *#####DESCRIPTIONBEGIN####
- *
- * Author(s):    gthomas
- * Contributors: gthomas
- * Date:         2000-07-14
- * Purpose:
- * Description:
- *
- * This code is part of RedBoot (tm).
- *
- *####DESCRIPTIONEND####
- *
- *==========================================================================
- */
-
-#ifndef _XYZMODEM_H_
-#define _XYZMODEM_H_
-
-#define xyzModem_xmodem 1
-#define xyzModem_ymodem 2
-/* Don't define this until the protocol support is in place */
-/*#define xyzModem_zmodem 3 */
-
-#define xyzModem_access   -1
-#define xyzModem_noZmodem -2
-#define xyzModem_timeout  -3
-#define xyzModem_eof      -4
-#define xyzModem_cancel   -5
-#define xyzModem_frame    -6
-#define xyzModem_cksum    -7
-#define xyzModem_sequence -8
-
-#define xyzModem_close 1
-#define xyzModem_abort 2
-
-
-#ifdef REDBOOT
-extern getc_io_funcs_t xyzModem_io;
-#else
-#define CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT
-#define CYGACC_CALL_IF_SET_CONSOLE_COMM(x)
-
-#define diag_vprintf vprintf
-#define diag_printf printf
-#define diag_vsprintf vsprintf
-
-#define CYGACC_CALL_IF_DELAY_US(x) udelay(x)
-
-typedef struct {
-    char *filename;
-    int   mode;
-    int   chan;
-#ifdef CYGPKG_REDBOOT_NETWORKING
-    struct sockaddr_in *server;
-#endif
-} connection_info_t;
-
-#endif
-
-
-int   xyzModem_stream_open(connection_info_t *info, int *err);
-void  xyzModem_stream_close(int *err);
-void  xyzModem_stream_terminate(bool method, int (*getc)(void));
-int   xyzModem_stream_read(char *buf, int size, int *err);
-char *xyzModem_error(int err);
-
-#endif /* _XYZMODEM_H_ */
-- 
1.7.10



From plagnioj at jcrosoft.com  Sun Nov  4 13:36:59 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Sun, 4 Nov 2012 19:36:59 +0100
Subject: [PATCH v2 1/2] commands: change Y-Modem implementation
In-Reply-To: <1352051724-16253-1-git-send-email-robert.jarzmik@free.fr>
References: <1351791438-29967-1-git-send-email-robert.jarzmik@free.fr>
 <1352051724-16253-1-git-send-email-robert.jarzmik@free.fr>
Message-ID: <20121104183659.GC29599@game.jcrosoft.org>

On 18:55 Sun 04 Nov     , Robert Jarzmik wrote:
> The current Y-Modem implementation has some limitations:
>  - Y-Modem/G protocol is not supported
>  - Multiple files (aka. batch) transfers are not supported
>  - Transfer speed over fast lines (USB console) is slow
>  - Code is not trivial to maintain (personnal opinion)
> 
> This implementation tries to address all these points by
> introducing loady2 command.
> 
> The effects are :
>  - transfer speed for Y-Modem over USB jumps from 2kBytes/s
>    to 180kBytes/s
>  - transfer speed for Y-Modem/G jumps to 200kBytes/s
>  - multiple file transfers are possible
> 
> This command was tested on a USB console and UART 9600bps
> serial line :
>  - NAKs (and retransmissions) were tested for faulty
>    serial lines
>  - multiple file transfers were tested
>  - Y-Modem, Y-Modem/G and X-Modem transfers were tested
> 
> Signed-off-by: Robert Jarzmik <robert.jarzmik at free.fr>
> 
> ---
> Since V1:
>  - add input fifo for small fifo hardwares
> Add a FIFO so that each getc will empty the hardware
> FIFO. This is very similar to the generic console code,
> except that the getc won't block each time for 100us,
> enabling faster lines (USB) to benefit their full speed.
>  - fix CRC calculation for big endian architectures
>    Thanks a lot Antony for the many patches testing !
>  - added some documentation
>  - amended the split as Sascha recommended
> ---
>  commands/Kconfig  |    1 +
>  commands/Makefile |    2 +-
>  commands/loadxy.c |  238 +++++++++++++++++++++
>  include/xymodem.h |   25 +++
>  lib/Kconfig       |    3 +
>  lib/Makefile      |    1 +
>  lib/xymodem.c     |  591 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  7 files changed, 860 insertions(+), 1 deletion(-)
>  create mode 100644 commands/loadxy.c
>  create mode 100644 include/xymodem.h
>  create mode 100644 lib/xymodem.c
> 
> diff --git a/commands/Kconfig b/commands/Kconfig
> index a52a01a..a7e9974 100644
> --- a/commands/Kconfig
> +++ b/commands/Kconfig
> @@ -261,6 +261,7 @@ config CMD_LOADB
>  
>  config CMD_LOADY
>  	select CRC16
> +	select XYMODEM
>  	tristate
>  	prompt "loady"
>  
> diff --git a/commands/Makefile b/commands/Makefile
> index ff98051..44ad904 100644
> --- a/commands/Makefile
> +++ b/commands/Makefile
> @@ -3,7 +3,7 @@ obj-$(CONFIG_CMD_BOOTM)		+= bootm.o
>  obj-$(CONFIG_CMD_UIMAGE)	+= uimage.o
>  obj-$(CONFIG_CMD_LINUX16)	+= linux16.o
>  obj-$(CONFIG_CMD_LOADB)		+= loadb.o xyzModem.o
> -obj-$(CONFIG_CMD_LOADY)		+= loadb.o xyzModem.o
> +obj-$(CONFIG_CMD_LOADY)		+= loadb.o xyzModem.o loadxy.o
>  obj-$(CONFIG_CMD_LOADS)		+= loads.o
>  obj-$(CONFIG_CMD_ECHO)		+= echo.o
>  obj-$(CONFIG_CMD_MEMORY)	+= mem.o
> diff --git a/commands/loadxy.c b/commands/loadxy.c
> new file mode 100644
> index 0000000..141bd7b
> --- /dev/null
> +++ b/commands/loadxy.c
> @@ -0,0 +1,238 @@
> +/**
> + * @file
> + * @brief loady and loadx  support.
> + *
> + * Provides loadx (over X-Modem) and loady(over Y-Modem) support to download
> + * images.
> + *
> + * FileName: commands/loadxy.c
> + */
> +/*
> + * (C) Copyright 2012 Robert Jarzmik <robert.jarzmik at free.fr>
> + *
> + * See file CREDITS for list of people who contributed to this
> + * project.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation; either version 2 of
> + * the License, or (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + */
> +
> +/*
> + * Serial up- and download support
> + */
> +#include <common.h>
> +#include <command.h>
> +#include <console.h>
> +#include <xymodem.h>
> +#include <errno.h>
> +#include <getopt.h>
> +#include <fcntl.h>
> +#include <fs.h>
> +#include <malloc.h>
> +
> +#define DEF_FILE	"image.bin"
> +
> +/**
> + * @brief returns current used console device
> + *
> + * @return console device which is registered with CONSOLE_STDIN and
> + * CONSOLE_STDOUT
> + */
> +static struct console_device *get_current_console(void)
> +{
> +	struct console_device *cdev;
> +	/*
> +	 * Assumption to have BOTH CONSOLE_STDIN AND STDOUT in the
> +	 * same output console
> +	 */
> +	for_each_console(cdev) {
> +		if ((cdev->f_active & (CONSOLE_STDIN | CONSOLE_STDOUT)))
> +			return cdev;
> +	}
> +	return NULL;
> +}
> +
> +static int console_change_speed(struct console_device *cdev, int baudrate)
> +{
> +	int current_baudrate;
> +
> +	current_baudrate =
> +		(int)simple_strtoul(dev_get_param(&cdev->class_dev,
> +						  "baudrate"), NULL, 10);
> +	if (baudrate && baudrate != current_baudrate) {
> +		printf("## Switch baudrate from %d to %d bps and press ENTER ...\n",
> +		       current_baudrate, baudrate);
> +		mdelay(50);
> +		cdev->setbrg(cdev, baudrate);
> +		mdelay(50);
> +	}
> +	return current_baudrate;
> +}
> +
> +/**
> + * @brief provide the loady(Y-Modem or Y-Modem/G) support
> + *
> + * @param argc number of arguments
> + * @param argv arguments of loady command
> + *
> + * @return success or failure
> + */
> +static int do_loady(int argc, char *argv[])
> +{
> +	int is_ymodemg = 0, rc = 0, opt, rcode = 0;
> +	int load_baudrate = 0, current_baudrate;
> +	struct console_device *cdev = NULL;
> +
> +	while ((opt = getopt(argc, argv, "b:g")) > 0) {
> +		switch (opt) {
> +		case 'b':
> +			load_baudrate = (int)simple_strtoul(optarg, NULL, 10);
> +			break;
> +		case 'g':
> +			is_ymodemg = 1;
> +			break;
> +		default:
> +			perror(argv[0]);
> +			return 1;
> +		}
> +	}
> +
> +	cdev = get_current_console();
> +	if (NULL == cdev) {
this really look wired
	if (!cdev)
> +		printf("%s:No console device with STDIN and STDOUT\n", argv[0]);
> +		return -ENODEV;
> +	}
> +
> +	current_baudrate = console_change_speed(cdev, load_baudrate);
> +	printf("## Ready for binary (ymodem) download at %d bps...\n",
> +	       load_baudrate ? load_baudrate : current_baudrate);
> +
> +	if (is_ymodemg)
> +		rc = do_load_serial_ymodemg(cdev);
> +	else
> +		rc = do_load_serial_ymodem(cdev);
> +
> +	if (rc < 0) {
> +		printf("## Binary (ymodem) download aborted (%d)\n", rc);
> +		rcode = 1;
> +	}
> +
> +	console_change_speed(cdev, current_baudrate);
> +
> +	return rcode;
> +}
> +
> +/**
> + * @brief provide the loadx(X-Modem) support
> + *
> + * @param argc number of arguments
> + * @param argv arguments of loadx command
> + *
> + * @return success or failure
> + */
> +static int do_loadx(int argc, char *argv[])
> +{
> +	ulong offset = 0;
> +	int load_baudrate = 0, current_baudrate, ofd, opt, rcode = 0;
> +	int open_mode = O_WRONLY;
> +	char *output_file = NULL;
> +	struct console_device *cdev = NULL;
> +
> +	while ((opt = getopt(argc, argv, "f:b:o:c")) > 0) {
> +		switch (opt) {
> +		case 'f':
> +			output_file = optarg;
> +			break;
> +		case 'b':
> +			load_baudrate = (int)simple_strtoul(optarg, NULL, 10);
> +			break;
> +		case 'o':
> +			offset = (int)simple_strtoul(optarg, NULL, 10);
> +			break;
> +		case 'c':
> +			open_mode |= O_CREAT;
> +			break;
> +		default:
> +			perror(argv[0]);
> +			return 1;
> +		}
> +	}
> +
> +	cdev = get_current_console();
> +	if (NULL == cdev) {
	ditto
> +		printf("%s:No console device with STDIN and STDOUT\n", argv[0]);
> +		return -ENODEV;
> +	}
> +
> +	/* Load Defaults */
> +	if (NULL == output_file)
	ditto
> +		output_file = DEF_FILE;
> +
> +	/* File should exist */
> +	ofd = open(output_file, open_mode);
> +	if (ofd < 0) {
> +		perror(argv[0]);
> +		return 3;
> +	}
> +	/* Seek to the right offset */
> +	if (offset) {
> +		int seek = lseek(ofd, offset, SEEK_SET);
> +		if (seek != offset) {
> +			close(ofd);
> +			ofd = 0;
> +			perror(argv[0]);
> +			return 4;
> +		}
> +	}
> +
> +	current_baudrate = console_change_speed(cdev, load_baudrate);
> +	printf("## Ready for binary (X-Modem) download "
> +	       "to 0x%08lX offset on %s device at %d bps...\n", offset,
> +	       output_file, load_baudrate);
> +	rcode = do_load_serial_ymodem(cdev);
> +	if (rcode < 0) {
> +		printf("## Binary (kermit) download aborted (%d)\n", rcode);
> +		rcode = 1;
> +	}
> +	console_change_speed(cdev, current_baudrate);
> +
> +	return rcode;
> +}

> +static void xy_flush(struct console_device *cdev, struct kfifo *fifo)
> +{
> +	while (cdev->tstc(cdev))
no timeout?
> +		cdev->getc(cdev);
> +	mdelay(250);
> +	while (cdev->tstc(cdev))
ditto
> +		cdev->getc(cdev);
> +	kfifo_reset(fifo);
> +}
> +

> + */
> +static ssize_t xy_read_block(struct xyz_ctxt *proto, struct xy_block *blk,
> +	uint64_t timeout)
> +{
> +	ssize_t rc, data_len = 0;
> +	unsigned char hdr, seqs[2], crcs[2];
> +	int crc = 0, hdr_found = 0;
> +	uint64_t start = get_time_ns();
> +
> +	while (!hdr_found) {
> +		rc = xy_gets(proto->cdev, proto->fifo, &hdr, 1, timeout);
> +		xy_dbg("read 0x%x(%c) -> %d\n", hdr, hdr, rc);
> +		if (rc < 0)
> +			goto out;
> +		if (is_timeout(start, timeout))
> +			goto timeout;
> +		switch (hdr) {
> +		case SOH:
> +			data_len = 128;
> +			hdr_found = 1;
> +			proto->total_SOH++;
no capital please
> +			break;
> +		case STX:
> +			data_len = 1024;
> +			hdr_found = 1;
boolean
> +			proto->total_STX++;
> +			break;
> +		case CAN:
> +			rc = -ECONNABORTED;
> +			if (proto->total_CAN++ > MAX_CAN_BEFORE_ABORT)
> +				goto out;
> +			break;
> +		case EOT:
> +			rc = 0;
> +			blk->len = 0;
> +			goto out;
> +		default:
> +			break;
> +		}
> +	}
> +
> +	blk->seq = 0;
> +	rc = xy_gets(proto->cdev, proto->fifo, seqs, 2, timeout);
> +	if (rc < 0)
> +		goto out;
> +	blk->seq = seqs[0];
> +	if (255 - seqs[0] != seqs[1])
> +		return -EBADMSG;
> +
> +	rc = xy_gets(proto->cdev, proto->fifo, blk->buf, data_len, timeout);
> +	if (rc < 0)
> +		goto out;
> +	blk->len = rc;
> +
> +	switch (proto->crc_mode) {
> +	case CRC_ADD8:
> +		rc = xy_gets(proto->cdev, proto->fifo, crcs, 1, timeout);
> +		crc = crcs[0];
> +		break;
> +	case CRC_CRC16:
> +		rc = xy_gets(proto->cdev, proto->fifo, crcs, 2, timeout);
> +		crc = be16_to_cpu(*(uint16_t *)crcs);
> +		break;
> +	case CRC_NONE:
> +		rc = 0;
> +		break;
> +	}
> +	if (rc < 0)
> +		goto out;
> +
> +	rc = check_crc(blk->buf, data_len, crc, proto->crc_mode);
> +	if (rc < 0)
> +		goto out;
> +	return data_len;
> +timeout:
> +	return -ETIMEDOUT;
> +out:
> +	return rc;
> +}
> +
> +static int check_blk_seq(struct xyz_ctxt *proto, struct xy_block *blk,
> +	int read_rc)
> +{
> +	if (blk->seq == ((proto->next_blk - 1) % 256))
> +		return -EALREADY;
> +	if (blk->seq != proto->next_blk)
> +		return -EILSEQ;
> +	return read_rc;
> +}
> +
> +static int parse_first_block(struct xyz_ctxt *proto, struct xy_block *blk)
> +{
> +	int filename_len;
> +	char *str_num;
> +
> +	filename_len = strlen(blk->buf);
> +	if (filename_len > blk->len)
> +		return -EINVAL;
> +	memset(proto->filename, 0, sizeof(proto->filename));
no need just add 0 at the end
> +	strncpy(proto->filename, blk->buf, filename_len);
> +	str_num = blk->buf + filename_len + 1;
> +	strsep(&str_num, " ");
> +	proto->file_len = simple_strtoul(blk->buf + filename_len + 1, NULL, 10);
> +	return 1;
> +}
Best Regards,
J.


From plagnioj at jcrosoft.com  Sun Nov  4 13:42:32 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Sun,  4 Nov 2012 19:42:32 +0100
Subject: [PATCH 1/1] atmel_spi: fix multiple instance support
Message-ID: <1352054552-20299-1-git-send-email-plagnioj@jcrosoft.com>

use device id as bus num

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/spi/atmel_spi.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c
index 4256572..353a24a 100644
--- a/drivers/spi/atmel_spi.c
+++ b/drivers/spi/atmel_spi.c
@@ -286,6 +286,7 @@ static int atmel_spi_probe(struct device_d *dev)
 
 	master = &as->master;
 	master->dev = dev;
+	master->bus_num = dev->id;
 
 	as->clk = clk_get(dev, "spi_clk");
 	if (IS_ERR(as->clk)) {
-- 
1.7.10.4



From robert.jarzmik at free.fr  Sun Nov  4 13:48:07 2012
From: robert.jarzmik at free.fr (Robert Jarzmik)
Date: Sun, 04 Nov 2012 19:48:07 +0100
Subject: Ramfs and NULL pointer
In-Reply-To: <87zk2xuuds.fsf@free.fr> (Robert Jarzmik's message of "Sun, 04
 Nov 2012 18:53:51 +0100")
References: <87zk2xuuds.fsf@free.fr>
Message-ID: <87vcdlurvc.fsf@free.fr>

Robert Jarzmik <robert.jarzmik at free.fr> writes:

> Hi there,
>
> Lately, I see null pointer dereferences in barebox.
> I traced the culprit to ramfs ...

Ah and if I take back v2012.09.0, the problem disappears. 
I'm not fully in the mood for a bisection of 544 commits ... any idea ?

-- 
Robert


From plagnioj at jcrosoft.com  Sun Nov  4 13:51:32 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Sun,  4 Nov 2012 19:51:32 +0100
Subject: [PATCH 1/1] at91rm9200ek: enable dt support
Message-ID: <1352055092-21128-1-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/boards/at91rm9200ek/env/config |    2 ++
 arch/arm/configs/at91rm9200ek_defconfig |    5 +++++
 2 files changed, 7 insertions(+)

diff --git a/arch/arm/boards/at91rm9200ek/env/config b/arch/arm/boards/at91rm9200ek/env/config
index a3830cb..76c180b 100644
--- a/arch/arm/boards/at91rm9200ek/env/config
+++ b/arch/arm/boards/at91rm9200ek/env/config
@@ -15,6 +15,8 @@ global.dhcp.vendor_id=barebox-at91rm9200ek
 kernel_loc=nfs
 # can be either 'net', 'nor' or 'initrd'
 rootfs_loc=net
+# can be either 'nfs', 'tftp', or empty
+oftree_loc=nfs
 
 # can be either 'jffs2' or 'ubifs'
 rootfs_type=ubifs
diff --git a/arch/arm/configs/at91rm9200ek_defconfig b/arch/arm/configs/at91rm9200ek_defconfig
index 6a105c6..2bcade9 100644
--- a/arch/arm/configs/at91rm9200ek_defconfig
+++ b/arch/arm/configs/at91rm9200ek_defconfig
@@ -32,9 +32,14 @@ CONFIG_CMD_FLASH=y
 CONFIG_CMD_BOOTM_ZLIB=y
 CONFIG_CMD_BOOTM_BZLIB=y
 CONFIG_CMD_BOOTM_SHOW_TYPE=y
+CONFIG_CMD_BOOTM_VERBOSE=y
 CONFIG_CMD_BOOTM_INITRD=y
+CONFIG_CMD_BOOTM_OFTREE=y
+CONFIG_CMD_BOOTM_OFTREE_UIMAGE=y
+# CONFIG_CMD_BOOTU is not set
 CONFIG_CMD_RESET=y
 CONFIG_CMD_GO=y
+CONFIG_CMD_OFTREE=y
 CONFIG_CMD_TIMEOUT=y
 CONFIG_CMD_PARTITION=y
 CONFIG_CMD_GPIO=y
-- 
1.7.10.4



From s.hauer at pengutronix.de  Sun Nov  4 17:56:14 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Sun, 4 Nov 2012 23:56:14 +0100
Subject: Ramfs and NULL pointer
In-Reply-To: <87vcdlurvc.fsf@free.fr>
References: <87zk2xuuds.fsf@free.fr>
 <87vcdlurvc.fsf@free.fr>
Message-ID: <20121104225614.GU1641@pengutronix.de>

On Sun, Nov 04, 2012 at 07:48:07PM +0100, Robert Jarzmik wrote:
> Robert Jarzmik <robert.jarzmik at free.fr> writes:
> 
> > Hi there,
> >
> > Lately, I see null pointer dereferences in barebox.
> > I traced the culprit to ramfs ...
> 
> Ah and if I take back v2012.09.0, the problem disappears. 
> I'm not fully in the mood for a bisection of 544 commits ... any idea ?

sha at dude:~/dude/barebox/barebox git lg v2012.09.0..origin/master fs/ramfs.c
77322aa Treewide: remove address of the Free Software Foundation
ad6c28a ramfs: add symlink and readlink support

Both look harmless, so I don't think that the culprit is ramfs itself.

Sorry, no idea. The good news is that due to my compile tests all 544
commits at least should compile ;)

Do you have some specific command sequence to provoke this?

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From robert.jarzmik at free.fr  Mon Nov  5 03:23:04 2012
From: robert.jarzmik at free.fr (Robert Jarzmik)
Date: Mon, 05 Nov 2012 09:23:04 +0100
Subject: Ramfs and NULL pointer
In-Reply-To: <20121104225614.GU1641@pengutronix.de> (Sascha Hauer's message of
 "Sun, 4 Nov 2012 23:56:14 +0100")
References: <87zk2xuuds.fsf@free.fr> <87vcdlurvc.fsf@free.fr>
 <20121104225614.GU1641@pengutronix.de>
Message-ID: <87r4o8v4pj.fsf@free.fr>

Sascha Hauer <s.hauer at pengutronix.de> writes:

> Both look harmless, so I don't think that the culprit is ramfs itself.
Agreed. Looks rather like someone is filling up with 0 the structure.

> Sorry, no idea. The good news is that due to my compile tests all 544
> commits at least should compile ;)
>
> Do you have some specific command sequence to provoke this?
Well, yes : arch/arm/boards/mioa701/env/bin/init
It's in the boot sequence, before I have a chance of typing a command.

The only special point I see about the script is that for "mtd_env_override"
script, /dev/mtd0.barebox-env is ... full of zeroes.

-- 
Robert


From plagnioj at jcrosoft.com  Mon Nov  5 04:29:00 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Mon, 5 Nov 2012 10:29:00 +0100
Subject: [PATCH 0/2 v3] add spi command
Message-ID: <20121105092900.GD29599@game.jcrosoft.org>

HI,

	v3:
	call setup before accesing the device
	This was working properly on at91 as the driver is wrong.
	It call setup for every transfer. I will fix the atmel_spi.

	v2:
	add default return usage
	use memory_display

	while debugging a spi issue I found we have a i2c commands but no spi
	command

	So introduce one

The following changes since commit 56371f4e8446d04d2a5608dd5890fd87a50f888e:

  iomux-imx35: add missing comma in pad definition (2012-11-01 16:32:12 +0100)

are available in the git repository at:

  git://git.jcrosoft.org/barebox.git delivery/command_spi

for you to fetch changes up to da7ef46034f3f0344a8fbbd3ce2bde70c9ec4685:

  introduce spi command (2012-11-05 02:18:14 +0800)

----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (2):
      spi: introduce spi_get_master
      introduce spi command

 commands/Kconfig        |    6 ++++++
 commands/Makefile       |    1 +
 commands/spi.c          |  132 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/spi/atmel_spi.c |    1 +
 drivers/spi/spi.c       |   12 ++++++++++++
 include/spi/spi.h       |    2 ++
 6 files changed, 154 insertions(+)
 create mode 100644 commands/spi.c

Best Regards,
J.


From plagnioj at jcrosoft.com  Mon Nov  5 04:36:28 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Mon,  5 Nov 2012 10:36:28 +0100
Subject: [PATCH 1/2] spi: introduce spi_get_master
In-Reply-To: <20121105092900.GD29599@game.jcrosoft.org>
References: <20121105092900.GD29599@game.jcrosoft.org>
Message-ID: <1352108189-29964-1-git-send-email-plagnioj@jcrosoft.com>

so we can request a master usefull for the spi command

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/spi/spi.c |   12 ++++++++++++
 include/spi/spi.h |    2 ++
 2 files changed, 14 insertions(+)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 44040e5..6a5bd6d 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -219,6 +219,18 @@ int spi_register_master(struct spi_master *master)
 }
 EXPORT_SYMBOL(spi_register_master);
 
+struct spi_master *spi_get_master(int bus)
+{
+	struct spi_master* m;
+
+	list_for_each_entry(m, &spi_master_list, list) {
+		if (m->bus_num == bus)
+			return m;
+	}
+
+	return NULL;
+}
+
 int spi_sync(struct spi_device *spi, struct spi_message *message)
 {
 	return spi->master->transfer(spi, message);
diff --git a/include/spi/spi.h b/include/spi/spi.h
index 1773ca2..d6570a4 100644
--- a/include/spi/spi.h
+++ b/include/spi/spi.h
@@ -432,6 +432,8 @@ static inline ssize_t spi_w8r8(struct spi_device *spi, u8 cmd)
 
 extern struct bus_type spi_bus;
 
+struct spi_master *spi_get_master(int bus);
+
 static inline int spi_register_driver(struct driver_d *drv)
 {
 	drv->bus = &spi_bus;
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Mon Nov  5 04:36:29 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Mon,  5 Nov 2012 10:36:29 +0100
Subject: [PATCH 2/2] introduce spi command
In-Reply-To: <1352108189-29964-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121105092900.GD29599@game.jcrosoft.org>
 <1352108189-29964-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1352108189-29964-2-git-send-email-plagnioj@jcrosoft.com>

usefull to debug spi

The command allow to read/write on a spi device

Usage: spi [OPTION] [data to write 0xXX]
write/read spi device.
  -b <bus_num>  spi bus number (default = 0)
  -r <count>    to read
  -c <cs>       chip select (default = 0)
  -m <mode>     spi mode (default = 0)
  -f <hz>       max_speed_hz (default = 1MHz)
  -w <bit>      bits_per_word (default = 8)
  -v            verbose

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 commands/Kconfig        |    6 +++
 commands/Makefile       |    1 +
 commands/spi.c          |  132 +++++++++++++++++++++++++++++++++++++++++++++++
 drivers/spi/atmel_spi.c |    1 +
 4 files changed, 140 insertions(+)
 create mode 100644 commands/spi.c

diff --git a/commands/Kconfig b/commands/Kconfig
index 16706d3..f7cbd67 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -597,6 +597,12 @@ config CMD_I2C
 	  include i2c_probe, i2c_read and i2c_write commands to communicate
 	  on i2c bus.
 
+config CMD_SPI
+	bool
+	depends on SPI
+	prompt "spi command"
+	help
+
 config CMD_LED
 	bool
 	depends on LED
diff --git a/commands/Makefile b/commands/Makefile
index 610be55..19d496e 100644
--- a/commands/Makefile
+++ b/commands/Makefile
@@ -55,6 +55,7 @@ obj-$(CONFIG_USB_GADGET_SERIAL)	+= usbserial.o
 obj-$(CONFIG_CMD_GPIO)		+= gpio.o
 obj-$(CONFIG_CMD_UNCOMPRESS)	+= uncompress.o
 obj-$(CONFIG_CMD_I2C)		+= i2c.o
+obj-$(CONFIG_CMD_SPI)		+= spi.o
 obj-$(CONFIG_CMD_UBI)		+= ubi.o
 obj-$(CONFIG_CMD_MENU)		+= menu.o
 obj-$(CONFIG_CMD_PASSWD)	+= passwd.o
diff --git a/commands/spi.c b/commands/spi.c
new file mode 100644
index 0000000..32a047d
--- /dev/null
+++ b/commands/spi.c
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
+ *
+ * Under GPLv2 only
+ *
+ */
+
+#include <common.h>
+#include <command.h>
+#include <errno.h>
+#include <malloc.h>
+#include <getopt.h>
+#include <spi/spi.h>
+
+static int do_spi(int argc, char *argv[])
+{
+	struct spi_device spi;
+	int bus = 0;
+	int read = 0;
+	int verbose = 0;
+	int opt, count, i, ret;
+	int byte_per_word;
+
+	u8 *tx_buf, *rx_buf;
+
+	memset(&spi, 0, sizeof(struct spi_device));
+
+	spi.max_speed_hz = 1 * 1000 * 1000;
+	spi.bits_per_word = 8;
+
+	while ((opt = getopt(argc, argv, "b:c:r:m:f:w:v")) > 0) {
+		switch (opt) {
+		case 'b':
+			bus = simple_strtol(optarg, NULL, 0);
+			break;
+		case 'r':
+			read = simple_strtol(optarg, NULL, 0);
+			break;
+		case 'c':
+			spi.chip_select = simple_strtoul(optarg, NULL, 0);
+			break;
+		case 'm':
+			spi.mode = simple_strtoul(optarg, NULL, 0);
+			break;
+		case 'f':
+			spi.max_speed_hz = simple_strtoul(optarg, NULL, 0);
+			break;
+		case 'w':
+			spi.bits_per_word = simple_strtoul(optarg, NULL, 0);
+			break;
+		case 'v':
+			verbose = 1;
+			break;
+		default:
+			return COMMAND_ERROR_USAGE;
+		}
+	}
+
+	count = argc - optind;
+
+	if ((!read && !count) || !spi.max_speed_hz || !spi.bits_per_word)
+		return COMMAND_ERROR_USAGE;
+
+
+	spi.master = spi_get_master(bus);
+	if (!spi.master) {
+		printf("spi bus %d not found\n", bus);
+		return -ENODEV;
+	}
+
+	if (spi.chip_select > spi.master->num_chipselect) {
+		printf("spi chip select (%d)> master num chipselect (%d)\n",
+			spi.chip_select, spi.master->num_chipselect);
+		return -EINVAL;
+	}
+
+	ret = spi.master->setup(&spi);
+	if (ret) {
+		printf("can not setup the master (%d)\n", ret);
+		return -ret;
+	}
+
+	tx_buf = xmalloc(count);
+	rx_buf = xmalloc(count);
+
+	for (i = 0; i < count; i++)
+		tx_buf[i] = (u8) simple_strtol(argv[optind + i], NULL, 16);
+
+	ret = spi_write_then_read(&spi, tx_buf, count, rx_buf, read);
+	if (ret)
+		goto out;
+
+	byte_per_word = max(spi.bits_per_word / 8, 1);
+	if (verbose) {
+		printf("device config\n");
+		printf("    bus_num       = %d\n", spi.master->bus_num);
+		printf("    max_speed_hz  = %d\n", spi.max_speed_hz);
+		printf("    chip_select   = %d\n", spi.chip_select);
+		printf("    mode          = 0x%x\n", spi.mode);
+		printf("    bits_per_word = %d\n", spi.bits_per_word);
+		printf("\n");
+
+		printf("wrote %i bytes\n", count);
+		memory_display(tx_buf, 0, count, byte_per_word);
+
+		printf("read %i bytes\n", read);
+	}
+
+	memory_display(rx_buf, 0, read, byte_per_word);
+
+out:
+	free(rx_buf);
+	free(tx_buf);
+	return ret;
+}
+
+static const __maybe_unused char cmd_spi_help[] =
+"Usage: spi [OPTION] [data to write 0xXX]\n"
+"write/read spi device.\n"
+"  -b <bus_num>  spi bus number (default = 0)\n"
+"  -r <count>    to read\n"
+"  -c <cs>       chip select (default = 0)\n"
+"  -m <mode>     spi mode (default = 0)\n"
+"  -f <hz>       max_speed_hz (default = 1MHz)\n"
+"  -w <bit>      bits_per_word (default = 8)\n"
+"  -v            verbose\n";
+
+BAREBOX_CMD_START(spi)
+	.cmd		= do_spi,
+	.usage		= "write/read spi device",
+	BAREBOX_CMD_HELP(cmd_spi_help)
+BAREBOX_CMD_END
diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c
index 43aec8e..4a6ed96 100644
--- a/drivers/spi/atmel_spi.c
+++ b/drivers/spi/atmel_spi.c
@@ -21,6 +21,7 @@
  *
  *
  */
+#define DEBUG
 
 #include <common.h>
 #include <init.h>
-- 
1.7.10.4



From christian.kapeller at cmotion.eu  Mon Nov  5 06:08:10 2012
From: christian.kapeller at cmotion.eu (Christian Kapeller)
Date: Mon, 05 Nov 2012 12:08:10 +0100
Subject: TX53: Not Bootable from next tree
Message-ID: <50979E1A.2000707@cmotion.eu>

Hi,

I've just flashed barebox from the next tree onto a TX53-8030 module,
and have to report, that the board won't boot.

Currently I've tried to run it with MMU off and setting the text-base
to 0x71000000, with no positive results.

I'll do further investigation, but meanwhile does anyone have barebox
running on a TX53 board?

Cheers,
Christian


From s.hauer at pengutronix.de  Mon Nov  5 07:52:58 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 5 Nov 2012 13:52:58 +0100
Subject: TX53: Not Bootable from next tree
In-Reply-To: <50979E1A.2000707@cmotion.eu>
References: <50979E1A.2000707@cmotion.eu>
Message-ID: <20121105125258.GV1641@pengutronix.de>

On Mon, Nov 05, 2012 at 12:08:10PM +0100, Christian Kapeller wrote:
> Hi,
> 
> I've just flashed barebox from the next tree onto a TX53-8030 module,
> and have to report, that the board won't boot.
> 
> Currently I've tried to run it with MMU off and setting the text-base
> to 0x71000000, with no positive results.
> 
> I'll do further investigation, but meanwhile does anyone have barebox
> running on a TX53 board?

I just tested that it works for me as second stage. I can't test 1st
stage atm as I currently have no physical access to the board.

Some guesses: Have you checked the correct the correct board revision in
the config? It's the default, so I assume it's correct.

Are you using the barebox-flash-image link or barebox.bin? You have to
use the former because it's a compressed image.

You might want to disable compressed image support in
 General settings ->
  memory layout ->
   [ ] pre-bootoloader image

And see if that works.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From christian.kapeller at cmotion.eu  Mon Nov  5 08:27:26 2012
From: christian.kapeller at cmotion.eu (Christian Kapeller)
Date: Mon, 05 Nov 2012 14:27:26 +0100
Subject: TX53: Not Bootable from next tree
In-Reply-To: <20121105125258.GV1641@pengutronix.de>
References: <50979E1A.2000707@cmotion.eu>
 <20121105125258.GV1641@pengutronix.de>
Message-ID: <5097BEBE.5040706@cmotion.eu>


>> I've just flashed barebox from the next tree onto a TX53-8030 module,
>> and have to report, that the board won't boot.
>>
>> Currently I've tried to run it with MMU off and setting the text-base
>> to 0x71000000, with no positive results.
>>
>> I'll do further investigation, but meanwhile does anyone have barebox
>> running on a TX53 board?
> 
> I just tested that it works for me as second stage. I can't test 1st
> stage atm as I currently have no physical access to the board.

Until now I've used bb in a 2nd stage configuration on top of the supplied
Redboot, and it worked without any problem.

Additionally I had CONFIG_MACH_DO_LOW_LEVEL_INIT disabled which skips
another pll setup step, that was already done by Redboot.

> Some guesses: Have you checked the correct the correct board revision in
> the config? It's the default, so I assume it's correct.

Yes, I did check for the correct board revision, and am using the
correct one: CONFIG_TX53_REV_XX30=y

> Are you using the barebox-flash-image link or barebox.bin? You have to
> use the former because it's a compressed image.

I've noticed, that the link target changes depending on build
configuration. So I've flashed the file pointed to by barebox-flash-image.

> You might want to disable compressed image support in
>  General settings ->
>   memory layout ->
>    [ ] pre-bootoloader image

Just tried that, but without changed result.

Currently I am trying to get my PEEDI JTAG probe working with the
board, but until then I stay in the dark.

Cheers,
Christian


From robert.jarzmik at free.fr  Mon Nov  5 13:07:39 2012
From: robert.jarzmik at free.fr (Robert Jarzmik)
Date: Mon, 05 Nov 2012 19:07:39 +0100
Subject: [PATCH v2 1/2] commands: change Y-Modem implementation
In-Reply-To: <20121104183659.GC29599@game.jcrosoft.org> (Jean-Christophe
 PLAGNIOL-VILLARD's message of "Sun, 4 Nov 2012 19:36:59 +0100")
References: <1351791438-29967-1-git-send-email-robert.jarzmik@free.fr>
 <1352051724-16253-1-git-send-email-robert.jarzmik@free.fr>
 <20121104183659.GC29599@game.jcrosoft.org>
Message-ID: <87mwyvvs7o.fsf@free.fr>

Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com> writes:

>> +	cdev = get_current_console();
>> +	if (NULL == cdev) {
> this really look wired
> 	if (!cdev)
Yes, true. A copy-paste from loadb.c, I'll amend for v3.

>> +	if (NULL == cdev) {
> 	ditto
Yes again.

>> +		printf("%s:No console device with STDIN and STDOUT\n", argv[0]);
>> +		return -ENODEV;
>> +	}
>> +
>> +	/* Load Defaults */
>> +	if (NULL == output_file)
> 	ditto
Yes again.

>> +static void xy_flush(struct console_device *cdev, struct kfifo *fifo)
>> +{
>> +	while (cdev->tstc(cdev))
> no timeout?
No timeout indeed, on purpose.

The short explanation is that in a purge situation, all incoming data must be
flushed, regardless of the time it takes.

The long explantion is :
 - suppose the while(cdev->tstc(cdev)) takes a lot of time
 - this implies that :
   => the sender is sending data as fast as the reader can consume (not quite
   probable, but why not ...)
   => the sender has gone crazy, as in *-Modem protocol when this function is
   called, no more than 1029 bytes can be sent by a *sane* sender

So let's take as granted that the sender has gone crazy (or hardware is brain
dead). What will happen if I place a timeout here ?
 - first, I'll obviously get out of xy_flush()
 - then, as I receive garbage, xy_handle() will exit with either -EBADMSG or
 -EILSEQ. So far so good.
 - then the loady command will finish on error. Still good.
 - then the input console will take over, and execute all the garbage sent to
 it.
   This is definitely something we don't want. Imagine in the garbage you have
   something like "erase /dev/mtd0" ... Therefore, no timeout.

>> +	while (cdev->tstc(cdev))
> ditto
Ditto.

>> +			proto->total_SOH++;
> no capital please
Yep, for v3.

>> +			break;
>> +		case STX:
>> +			data_len = 1024;
>> +			hdr_found = 1;
> boolean
I don't catch that one.
Did you mean that hdr_found should be declared as "bool" ?

>> +static int parse_first_block(struct xyz_ctxt *proto, struct xy_block *blk)
>> +{
>> +	int filename_len;
>> +	char *str_num;
>> +
>> +	filename_len = strlen(blk->buf);
>> +	if (filename_len > blk->len)
>> +		return -EINVAL;
>> +	memset(proto->filename, 0, sizeof(proto->filename));
> no need just add 0 at the end
>> +	strncpy(proto->filename, blk->buf, filename_len);
Why not use strlcpy instead of memset+strncpy now I think of it ?

Cheers, and thanks for the review.

-- 
Robert


From plagnioj at jcrosoft.com  Mon Nov  5 13:25:44 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Mon, 5 Nov 2012 19:25:44 +0100
Subject: [PATCH v2 1/2] commands: change Y-Modem implementation
In-Reply-To: <87mwyvvs7o.fsf@free.fr>
References: <1351791438-29967-1-git-send-email-robert.jarzmik@free.fr>
 <1352051724-16253-1-git-send-email-robert.jarzmik@free.fr>
 <20121104183659.GC29599@game.jcrosoft.org> <87mwyvvs7o.fsf@free.fr>
Message-ID: <20121105182544.GB25679@game.jcrosoft.org>

On 19:07 Mon 05 Nov     , Robert Jarzmik wrote:
> Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com> writes:
> 
> >> +	cdev = get_current_console();
> >> +	if (NULL == cdev) {
> > this really look wired
> > 	if (!cdev)
> Yes, true. A copy-paste from loadb.c, I'll amend for v3.
> 
> >> +	if (NULL == cdev) {
> > 	ditto
> Yes again.
> 
> >> +		printf("%s:No console device with STDIN and STDOUT\n", argv[0]);
> >> +		return -ENODEV;
> >> +	}
> >> +
> >> +	/* Load Defaults */
> >> +	if (NULL == output_file)
> > 	ditto
> Yes again.
> 
> >> +static void xy_flush(struct console_device *cdev, struct kfifo *fifo)
> >> +{
> >> +	while (cdev->tstc(cdev))
> > no timeout?
> No timeout indeed, on purpose.
> 
> The short explanation is that in a purge situation, all incoming data must be
> flushed, regardless of the time it takes.
> 
> The long explantion is :
>  - suppose the while(cdev->tstc(cdev)) takes a lot of time
>  - this implies that :
>    => the sender is sending data as fast as the reader can consume (not quite
>    probable, but why not ...)
>    => the sender has gone crazy, as in *-Modem protocol when this function is
>    called, no more than 1029 bytes can be sent by a *sane* sender
> 
> So let's take as granted that the sender has gone crazy (or hardware is brain
> dead). What will happen if I place a timeout here ?
>  - first, I'll obviously get out of xy_flush()
>  - then, as I receive garbage, xy_handle() will exit with either -EBADMSG or
>  -EILSEQ. So far so good.
>  - then the loady command will finish on error. Still good.
>  - then the input console will take over, and execute all the garbage sent to
>  it.
>    This is definitely something we don't want. Imagine in the garbage you have
>    something like "erase /dev/mtd0" ... Therefore, no timeout.
my issue is how can I interrupt it from barebox
> 
> >> +	while (cdev->tstc(cdev))
> > ditto
> Ditto.
> 
> >> +			proto->total_SOH++;
> > no capital please
> Yep, for v3.
> 
> >> +			break;
> >> +		case STX:
> >> +			data_len = 1024;
> >> +			hdr_found = 1;
> > boolean
> I don't catch that one.
> Did you mean that hdr_found should be declared as "bool" ?
yes
> 
> >> +static int parse_first_block(struct xyz_ctxt *proto, struct xy_block *blk)
> >> +{
> >> +	int filename_len;
> >> +	char *str_num;
> >> +
> >> +	filename_len = strlen(blk->buf);
> >> +	if (filename_len > blk->len)
> >> +		return -EINVAL;
> >> +	memset(proto->filename, 0, sizeof(proto->filename));
> > no need just add 0 at the end
> >> +	strncpy(proto->filename, blk->buf, filename_len);
> Why not use strlcpy instead of memset+strncpy now I think of it ?
> 
yeap

can you put the v3 on a tree somewhere so I can pull it

Best Regards,
J.


From plagnioj at jcrosoft.com  Mon Nov  5 13:21:48 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Mon, 5 Nov 2012 19:21:48 +0100
Subject: [PATCH 0/2 v4] add spi command
Message-ID: <20121105182148.GA25679@game.jcrosoft.org>

HI,

	v4:
	do not touch the atmel_spi

	v3:
	call setup before accesing the device
	This was working properly on at91 as the driver is wrong.
	It call setup for every transfer. I will fix the atmel_spi.

	v2:
	add default return usage
	use memory_display

	while debugging a spi issue I found we have a i2c commands but no spi
	command

	So introduce one

The following changes since commit 56371f4e8446d04d2a5608dd5890fd87a50f888e:

  iomux-imx35: add missing comma in pad definition (2012-11-01 16:32:12 +0100)

are available in the git repository at:

  git://git.jcrosoft.org/barebox.git delivery/command_spi

for you to fetch changes up to 268e3d4f67da35571159fd096c62fa2e660783b0:

  introduce spi command (2012-11-05 11:13:25 +0800)

----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (2):
      spi: introduce spi_get_master
      introduce spi command

 commands/Kconfig  |    6 ++++++
 commands/Makefile |    1 +
 commands/spi.c    |  132 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/spi/spi.c |   12 ++++++++++++
 include/spi/spi.h |    2 ++
 5 files changed, 153 insertions(+)
 create mode 100644 commands/spi.c

Best Regards,
J.


From plagnioj at jcrosoft.com  Mon Nov  5 13:30:18 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Mon,  5 Nov 2012 19:30:18 +0100
Subject: [PATCH 1/2] spi: introduce spi_get_master
In-Reply-To: <20121105182148.GA25679@game.jcrosoft.org>
References: <20121105182148.GA25679@game.jcrosoft.org>
Message-ID: <1352140219-11309-1-git-send-email-plagnioj@jcrosoft.com>

so we can request a master usefull for the spi command

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/spi/spi.c |   12 ++++++++++++
 include/spi/spi.h |    2 ++
 2 files changed, 14 insertions(+)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 44040e5..6a5bd6d 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -219,6 +219,18 @@ int spi_register_master(struct spi_master *master)
 }
 EXPORT_SYMBOL(spi_register_master);
 
+struct spi_master *spi_get_master(int bus)
+{
+	struct spi_master* m;
+
+	list_for_each_entry(m, &spi_master_list, list) {
+		if (m->bus_num == bus)
+			return m;
+	}
+
+	return NULL;
+}
+
 int spi_sync(struct spi_device *spi, struct spi_message *message)
 {
 	return spi->master->transfer(spi, message);
diff --git a/include/spi/spi.h b/include/spi/spi.h
index 1773ca2..d6570a4 100644
--- a/include/spi/spi.h
+++ b/include/spi/spi.h
@@ -432,6 +432,8 @@ static inline ssize_t spi_w8r8(struct spi_device *spi, u8 cmd)
 
 extern struct bus_type spi_bus;
 
+struct spi_master *spi_get_master(int bus);
+
 static inline int spi_register_driver(struct driver_d *drv)
 {
 	drv->bus = &spi_bus;
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Mon Nov  5 13:30:19 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Mon,  5 Nov 2012 19:30:19 +0100
Subject: [PATCH 2/2] introduce spi command
In-Reply-To: <1352140219-11309-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121105182148.GA25679@game.jcrosoft.org>
 <1352140219-11309-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1352140219-11309-2-git-send-email-plagnioj@jcrosoft.com>

usefull to debug spi

The command allow to read/write on a spi device

Usage: spi [OPTION] [data to write 0xXX]
write/read spi device.
  -b <bus_num>  spi bus number (default = 0)
  -r <count>    to read
  -c <cs>       chip select (default = 0)
  -m <mode>     spi mode (default = 0)
  -f <hz>       max_speed_hz (default = 1MHz)
  -w <bit>      bits_per_word (default = 8)
  -v            verbose

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 commands/Kconfig  |    6 +++
 commands/Makefile |    1 +
 commands/spi.c    |  132 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 139 insertions(+)
 create mode 100644 commands/spi.c

diff --git a/commands/Kconfig b/commands/Kconfig
index 16706d3..f7cbd67 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -597,6 +597,12 @@ config CMD_I2C
 	  include i2c_probe, i2c_read and i2c_write commands to communicate
 	  on i2c bus.
 
+config CMD_SPI
+	bool
+	depends on SPI
+	prompt "spi command"
+	help
+
 config CMD_LED
 	bool
 	depends on LED
diff --git a/commands/Makefile b/commands/Makefile
index 610be55..19d496e 100644
--- a/commands/Makefile
+++ b/commands/Makefile
@@ -55,6 +55,7 @@ obj-$(CONFIG_USB_GADGET_SERIAL)	+= usbserial.o
 obj-$(CONFIG_CMD_GPIO)		+= gpio.o
 obj-$(CONFIG_CMD_UNCOMPRESS)	+= uncompress.o
 obj-$(CONFIG_CMD_I2C)		+= i2c.o
+obj-$(CONFIG_CMD_SPI)		+= spi.o
 obj-$(CONFIG_CMD_UBI)		+= ubi.o
 obj-$(CONFIG_CMD_MENU)		+= menu.o
 obj-$(CONFIG_CMD_PASSWD)	+= passwd.o
diff --git a/commands/spi.c b/commands/spi.c
new file mode 100644
index 0000000..899bf62
--- /dev/null
+++ b/commands/spi.c
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
+ *
+ * Under GPLv2 only
+ *
+ */
+
+#include <common.h>
+#include <command.h>
+#include <errno.h>
+#include <malloc.h>
+#include <getopt.h>
+#include <spi/spi.h>
+
+static int do_spi(int argc, char *argv[])
+{
+	struct spi_device spi;
+	int bus = 0;
+	int read = 0;
+	int verbose = 0;
+	int opt, count, i, ret;
+	int byte_per_word;
+
+	u8 *tx_buf, *rx_buf;
+
+	memset(&spi, 0, sizeof(struct spi_device));
+
+	spi.max_speed_hz = 1 * 1000 * 1000;
+	spi.bits_per_word = 8;
+
+	while ((opt = getopt(argc, argv, "b:c:r:m:f:w:v")) > 0) {
+		switch (opt) {
+		case 'b':
+			bus = simple_strtol(optarg, NULL, 0);
+			break;
+		case 'r':
+			read = simple_strtol(optarg, NULL, 0);
+			break;
+		case 'c':
+			spi.chip_select = simple_strtoul(optarg, NULL, 0);
+			break;
+		case 'm':
+			spi.mode = simple_strtoul(optarg, NULL, 0);
+			break;
+		case 'f':
+			spi.max_speed_hz = simple_strtoul(optarg, NULL, 0);
+			break;
+		case 'w':
+			spi.bits_per_word = simple_strtoul(optarg, NULL, 0);
+			break;
+		case 'v':
+			verbose = 1;
+			break;
+		default:
+			return COMMAND_ERROR_USAGE;
+		}
+	}
+
+	count = argc - optind;
+
+	if ((!read && !count) || !spi.max_speed_hz || !spi.bits_per_word)
+		return COMMAND_ERROR_USAGE;
+
+
+	spi.master = spi_get_master(bus);
+	if (!spi.master) {
+		printf("spi bus %d not found\n", bus);
+		return -ENODEV;
+	}
+
+	if (spi.chip_select > spi.master->num_chipselect) {
+		printf("spi chip select (%d)> master num chipselect (%d)\n",
+			spi.chip_select, spi.master->num_chipselect);
+		return -EINVAL;
+	}
+
+	ret = spi.master->setup(&spi);
+	if (ret) {
+		printf("can not setup the master (%d)\n", ret);
+		return ret;
+	}
+
+	tx_buf = xmalloc(count);
+	rx_buf = xmalloc(count);
+
+	for (i = 0; i < count; i++)
+		tx_buf[i] = (u8) simple_strtol(argv[optind + i], NULL, 16);
+
+	ret = spi_write_then_read(&spi, tx_buf, count, rx_buf, read);
+	if (ret)
+		goto out;
+
+	byte_per_word = max(spi.bits_per_word / 8, 1);
+	if (verbose) {
+		printf("device config\n");
+		printf("    bus_num       = %d\n", spi.master->bus_num);
+		printf("    max_speed_hz  = %d\n", spi.max_speed_hz);
+		printf("    chip_select   = %d\n", spi.chip_select);
+		printf("    mode          = 0x%x\n", spi.mode);
+		printf("    bits_per_word = %d\n", spi.bits_per_word);
+		printf("\n");
+
+		printf("wrote %i bytes\n", count);
+		memory_display(tx_buf, 0, count, byte_per_word);
+
+		printf("read %i bytes\n", read);
+	}
+
+	memory_display(rx_buf, 0, read, byte_per_word);
+
+out:
+	free(rx_buf);
+	free(tx_buf);
+	return ret;
+}
+
+static const __maybe_unused char cmd_spi_help[] =
+"Usage: spi [OPTION] [data to write 0xXX]\n"
+"write/read spi device.\n"
+"  -b <bus_num>  spi bus number (default = 0)\n"
+"  -r <count>    to read\n"
+"  -c <cs>       chip select (default = 0)\n"
+"  -m <mode>     spi mode (default = 0)\n"
+"  -f <hz>       max_speed_hz (default = 1MHz)\n"
+"  -w <bit>      bits_per_word (default = 8)\n"
+"  -v            verbose\n";
+
+BAREBOX_CMD_START(spi)
+	.cmd		= do_spi,
+	.usage		= "write/read spi device",
+	BAREBOX_CMD_HELP(cmd_spi_help)
+BAREBOX_CMD_END
-- 
1.7.10.4



From robert.jarzmik at free.fr  Mon Nov  5 13:49:52 2012
From: robert.jarzmik at free.fr (Robert Jarzmik)
Date: Mon, 05 Nov 2012 19:49:52 +0100
Subject: [PATCH v2 1/2] commands: change Y-Modem implementation
In-Reply-To: <20121105182544.GB25679@game.jcrosoft.org> (Jean-Christophe
 PLAGNIOL-VILLARD's message of "Mon, 5 Nov 2012 19:25:44 +0100")
References: <1351791438-29967-1-git-send-email-robert.jarzmik@free.fr>
 <1352051724-16253-1-git-send-email-robert.jarzmik@free.fr>
 <20121104183659.GC29599@game.jcrosoft.org> <87mwyvvs7o.fsf@free.fr>
 <20121105182544.GB25679@game.jcrosoft.org>
Message-ID: <878vafvq9b.fsf@free.fr>

Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com> writes:
> On 19:07 Mon 05 Nov     , Robert Jarzmik wrote:
>> Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com> writes:
>> No timeout indeed, on purpose.
>> 
>> The short explanation is that in a purge situation, all incoming data must be
>> flushed, regardless of the time it takes.
>> 
>> The long explantion is :
>>  - suppose the while(cdev->tstc(cdev)) takes a lot of time
>>  - this implies that :
>>    => the sender is sending data as fast as the reader can consume (not quite
>>    probable, but why not ...)
>>    => the sender has gone crazy, as in *-Modem protocol when this function is
>>    called, no more than 1029 bytes can be sent by a *sane* sender
>> 
>> So let's take as granted that the sender has gone crazy (or hardware is brain
>> dead). What will happen if I place a timeout here ?
>>  - first, I'll obviously get out of xy_flush()
>>  - then, as I receive garbage, xy_handle() will exit with either -EBADMSG or
>>  -EILSEQ. So far so good.
>>  - then the loady command will finish on error. Still good.
>>  - then the input console will take over, and execute all the garbage sent to
>>  it.
>>    This is definitely something we don't want. Imagine in the garbage you have
>>    something like "erase /dev/mtd0" ... Therefore, no timeout.
> my issue is how can I interrupt it from barebox
You can't, how could you ? Your console is overwhelmed by garbage input, what
could you possibly do to interrupt it apart from cutting down the sender ?

> can you put the v3 on a tree somewhere so I can pull it
I'll try. I have no external git I can push to. If you have a hint ...

-- 
Robert


From plagnioj at jcrosoft.com  Mon Nov  5 14:49:07 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Mon, 5 Nov 2012 20:49:07 +0100
Subject: [PATCH v2 1/2] commands: change Y-Modem implementation
In-Reply-To: <878vafvq9b.fsf@free.fr>
References: <1351791438-29967-1-git-send-email-robert.jarzmik@free.fr>
 <1352051724-16253-1-git-send-email-robert.jarzmik@free.fr>
 <20121104183659.GC29599@game.jcrosoft.org> <87mwyvvs7o.fsf@free.fr>
 <20121105182544.GB25679@game.jcrosoft.org> <878vafvq9b.fsf@free.fr>
Message-ID: <20121105194907.GC25679@game.jcrosoft.org>

On 19:49 Mon 05 Nov     , Robert Jarzmik wrote:
> Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com> writes:
> > On 19:07 Mon 05 Nov     , Robert Jarzmik wrote:
> >> Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com> writes:
> >> No timeout indeed, on purpose.
> >> 
> >> The short explanation is that in a purge situation, all incoming data must be
> >> flushed, regardless of the time it takes.
> >> 
> >> The long explantion is :
> >>  - suppose the while(cdev->tstc(cdev)) takes a lot of time
> >>  - this implies that :
> >>    => the sender is sending data as fast as the reader can consume (not quite
> >>    probable, but why not ...)
> >>    => the sender has gone crazy, as in *-Modem protocol when this function is
> >>    called, no more than 1029 bytes can be sent by a *sane* sender
> >> 
> >> So let's take as granted that the sender has gone crazy (or hardware is brain
> >> dead). What will happen if I place a timeout here ?
> >>  - first, I'll obviously get out of xy_flush()
> >>  - then, as I receive garbage, xy_handle() will exit with either -EBADMSG or
> >>  -EILSEQ. So far so good.
> >>  - then the loady command will finish on error. Still good.
> >>  - then the input console will take over, and execute all the garbage sent to
> >>  it.
> >>    This is definitely something we don't want. Imagine in the garbage you have
> >>    something like "erase /dev/mtd0" ... Therefore, no timeout.
> > my issue is how can I interrupt it from barebox
> You can't, how could you ? Your console is overwhelmed by garbage input, what
> could you possibly do to interrupt it apart from cutting down the sender ?
this is an issue if we have more than one we need be able to do so and I may
want to use it on an other console_device not necessarely the current one

I have often hw that have more than one uart
> 
> > can you put the v3 on a tree somewhere so I can pull it
> I'll try. I have no external git I can push to. If you have a hint ...
https://git.wiki.kernel.org/index.php/GitHosting

Best Regards,
J.
> 
> -- 
> Robert


From robert.jarzmik at free.fr  Mon Nov  5 16:31:02 2012
From: robert.jarzmik at free.fr (Robert Jarzmik)
Date: Mon, 05 Nov 2012 22:31:02 +0100
Subject: [PATCH v2 1/2] commands: change Y-Modem implementation
In-Reply-To: <20121105194907.GC25679@game.jcrosoft.org> (Jean-Christophe
 PLAGNIOL-VILLARD's message of "Mon, 5 Nov 2012 20:49:07 +0100")
References: <1351791438-29967-1-git-send-email-robert.jarzmik@free.fr>
 <1352051724-16253-1-git-send-email-robert.jarzmik@free.fr>
 <20121104183659.GC29599@game.jcrosoft.org> <87mwyvvs7o.fsf@free.fr>
 <20121105182544.GB25679@game.jcrosoft.org> <878vafvq9b.fsf@free.fr>
 <20121105194907.GC25679@game.jcrosoft.org>
Message-ID: <871ug7visp.fsf@free.fr>

Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com> writes:

>> You can't, how could you ? Your console is overwhelmed by garbage input, what
>> could you possibly do to interrupt it apart from cutting down the sender ?
> this is an issue if we have more than one we need be able to do so and I may
> want to use it on an other console_device not necessarely the current one
>
> I have often hw that have more than one uart
And how do you choose the alternative UART ? loady is not provided such a
parameter in its new form.
Now if you want, I can add it. And if I add it, I'll add a timeout also to the
xy_flush() function ...

>> > can you put the v3 on a tree somewhere so I can pull it
>> I'll try. I have no external git I can push to. If you have a hint ...
> https://git.wiki.kernel.org/index.php/GitHosting
Ah yes, ok. I'll send you the URL once I've amended the patches, along the
patch mails.

Cheers.

-- 
Robert


From plagnioj at jcrosoft.com  Tue Nov  6 02:34:58 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Tue, 6 Nov 2012 08:34:58 +0100
Subject: [PATCH v2 1/2] commands: change Y-Modem implementation
In-Reply-To: <871ug7visp.fsf@free.fr>
References: <1351791438-29967-1-git-send-email-robert.jarzmik@free.fr>
 <1352051724-16253-1-git-send-email-robert.jarzmik@free.fr>
 <20121104183659.GC29599@game.jcrosoft.org> <87mwyvvs7o.fsf@free.fr>
 <20121105182544.GB25679@game.jcrosoft.org> <878vafvq9b.fsf@free.fr>
 <20121105194907.GC25679@game.jcrosoft.org> <871ug7visp.fsf@free.fr>
Message-ID: <20121106073458.GD25679@game.jcrosoft.org>

On 22:31 Mon 05 Nov     , Robert Jarzmik wrote:
> Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com> writes:
> 
> >> You can't, how could you ? Your console is overwhelmed by garbage input, what
> >> could you possibly do to interrupt it apart from cutting down the sender ?
> > this is an issue if we have more than one we need be able to do so and I may
> > want to use it on an other console_device not necessarely the current one
> >
> > I have often hw that have more than one uart
> And how do you choose the alternative UART ? loady is not provided such a
> parameter in its new form.
by it's name cs1 as example

> Now if you want, I can add it. And if I add it, I'll add a timeout also to the
> xy_flush() function ...
yes please
> 
> >> > can you put the v3 on a tree somewhere so I can pull it
> >> I'll try. I have no external git I can push to. If you have a hint ...
> > https://git.wiki.kernel.org/index.php/GitHosting
> Ah yes, ok. I'll send you the URL once I've amended the patches, along the
> patch mails.
personnaly for at91 we use github tks

Best Regards,
J.


From pewi at gw-instruments.de  Tue Nov  6 08:49:06 2012
From: pewi at gw-instruments.de (Peter Wippich)
Date: Tue, 6 Nov 2012 14:49:06 +0100 (CET)
Subject: TX53: Not Bootable from next tree
Message-ID: <alpine.LSU.2.00.1211061440560.27068@redbean.intranet.gw-instruments.de>


Hi,

got the same problem here. Double checked Board Version (8030) and
that I have the right binary (compressed with flash header). After 
flashing and reset nothing happens....

Used default config tx53stk5_defconfig.

Swiched back to old u-boot for now.

Regards,

Peter


|       Peter Wippich                   Voice: +49 30 46776411          |
|       G&W Instruments GmbH            fax:   +49 30 46776419          |
|       Gustav-Meyer-Allee 25, Geb. 12  Email: pewi at gw-instruments.de   |
|       D-13355 Berlin  / Germany                                       |



From plagnioj at jcrosoft.com  Tue Nov  6 14:30:10 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Tue, 6 Nov 2012 20:30:10 +0100
Subject: [PATCH 0/8] atmtel: fix spi driver + rm9200
Message-ID: <20121106193010.GE25679@game.jcrosoft.org>

HI,

The following changes since commit d74bef2b04a3ccf7339ba916e56830bb2feae957:

  mount: add compatibility to old mount command (2012-11-02 21:26:29 +0100)

are available in the git repository at:

  git://git.jcrosoft.org/barebox.git tags/atmel_spi_fix

for you to fetch changes up to 7e7b7aa81cdf7e47a8f828818f1e453a27046c38:

  at91rm9200: fix spi cs support (2012-11-06 04:39:09 +0800)

----------------------------------------------------------------
atmel spi support fix

The current drivers for atmel have a lot of issues but we are lucky
enough if you use it one device + one master instance it will work on
most of the spi device

but this will not work on mmc spi or multi-master instance or multi-device

so now fix all those issues
 - fix the cs support
 - fix setup setup support
 - do not call setup before each transfert
 - add sanity check

now the atmel spi work on rm9200, mmc spi and at24, at45, eeprom

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>

----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (8):
      atmel_spi: use device id as bus num
      atmel_spi: split transfert to atmel_spi_do_xfer
      atmel_spi: after setup the cs need to be disable
      atmel_spi: add sanity check in setup
      atmel_spi: fix cs support
      atmel_spi: drop setup during transfer
      atmel_spi: add cs change support
      at91rm9200: fix spi cs support

 arch/arm/mach-at91/at91rm9200_devices.c |    7 ++++++-
 drivers/spi/atmel_spi.c                 |  260 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------------------
 2 files changed, 196 insertions(+), 71 deletions(-)

Best Regards,
J.


From plagnioj at jcrosoft.com  Tue Nov  6 14:33:29 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Tue,  6 Nov 2012 20:33:29 +0100
Subject: [PATCH 1/8] atmel_spi: use device id as bus num
In-Reply-To: <20121106193010.GE25679@game.jcrosoft.org>
References: <20121106193010.GE25679@game.jcrosoft.org>
Message-ID: <1352230416-9396-1-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/spi/atmel_spi.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c
index 43aec8e..3375f81 100644
--- a/drivers/spi/atmel_spi.c
+++ b/drivers/spi/atmel_spi.c
@@ -265,6 +265,7 @@ static int atmel_spi_probe(struct device_d *dev)
 
 	master = &as->master;
 	master->dev = dev;
+	master->bus_num = dev->id;
 
 	as->clk = clk_get(dev, "spi_clk");
 	if (IS_ERR(as->clk)) {
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Tue Nov  6 14:33:32 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Tue,  6 Nov 2012 20:33:32 +0100
Subject: [PATCH 4/8] atmel_spi: add sanity check in setup
In-Reply-To: <1352230416-9396-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121106193010.GE25679@game.jcrosoft.org>
 <1352230416-9396-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1352230416-9396-4-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/spi/atmel_spi.c |   14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c
index dbf6af8..17b91eb 100644
--- a/drivers/spi/atmel_spi.c
+++ b/drivers/spi/atmel_spi.c
@@ -87,6 +87,20 @@ static int atmel_spi_setup(struct spi_device *spi)
 	unsigned int		bits = spi->bits_per_word;
 	unsigned long		bus_hz;
 
+	if (spi->chip_select > spi->master->num_chipselect) {
+		dev_dbg(&spi->dev,
+				"setup: invalid chipselect %u (%u defined)\n",
+				spi->chip_select, spi->master->num_chipselect);
+		return -EINVAL;
+	}
+
+	if (bits < 8 || bits > 16) {
+		dev_dbg(&spi->dev,
+				"setup: invalid bits_per_word %u (8 to 16)\n",
+				bits);
+		return -EINVAL;
+	}
+
 	if (spi->controller_data) {
 		csr = (u32)spi->controller_data;
 		spi_writel(as, CSR0, csr);
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Tue Nov  6 14:33:31 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Tue,  6 Nov 2012 20:33:31 +0100
Subject: [PATCH 3/8] atmel_spi: after setup the cs need to be disable
In-Reply-To: <1352230416-9396-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121106193010.GE25679@game.jcrosoft.org>
 <1352230416-9396-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1352230416-9396-3-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/spi/atmel_spi.c |   29 ++++++++++++++++-------------
 1 file changed, 16 insertions(+), 13 deletions(-)

diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c
index afbca9f..dbf6af8 100644
--- a/drivers/spi/atmel_spi.c
+++ b/drivers/spi/atmel_spi.c
@@ -66,6 +66,18 @@ static inline bool atmel_spi_is_v2(void)
 	return !cpu_is_at91rm9200();
 }
 
+static void atmel_spi_chipselect(struct spi_device *spi, struct atmel_spi *as, int on)
+{
+	struct spi_master *master = &as->master;
+	int cs_pin;
+	int val = ((spi->mode & SPI_CS_HIGH) != 0) == on;
+
+	BUG_ON(spi->chip_select >= master->num_chipselect);
+	cs_pin = as->cs_pins[spi->chip_select];
+
+	gpio_direction_output(cs_pin, val);
+}
+
 static int atmel_spi_setup(struct spi_device *spi)
 {
 	struct spi_master	*master = spi->master;
@@ -78,7 +90,7 @@ static int atmel_spi_setup(struct spi_device *spi)
 	if (spi->controller_data) {
 		csr = (u32)spi->controller_data;
 		spi_writel(as, CSR0, csr);
-		return 0;
+		goto out;
 	}
 
 	dev_dbg(master->dev, "%s mode 0x%08x bits_per_word: %d speed: %d\n",
@@ -140,19 +152,10 @@ static int atmel_spi_setup(struct spi_device *spi)
 	if (bits > 0)
 		spi->controller_data = (void *)csr;
 
-	return 0;
-}
-
-static void atmel_spi_chipselect(struct spi_device *spi, struct atmel_spi *as, int on)
-{
-	struct spi_master *master = &as->master;
-	int cs_pin;
-	int val = ((spi->mode & SPI_CS_HIGH) != 0) == on;
-
-	BUG_ON(spi->chip_select >= master->num_chipselect);
-	cs_pin = as->cs_pins[spi->chip_select];
+out:
+	atmel_spi_chipselect(spi, as, 0);
 
-	gpio_direction_output(cs_pin, val);
+	return 0;
 }
 
 static int atmel_spi_xchg(struct atmel_spi *as, u32 tx_val)
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Tue Nov  6 14:33:30 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Tue,  6 Nov 2012 20:33:30 +0100
Subject: [PATCH 2/8] atmel_spi: split transfert to atmel_spi_do_xfer
In-Reply-To: <1352230416-9396-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121106193010.GE25679@game.jcrosoft.org>
 <1352230416-9396-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1352230416-9396-2-git-send-email-plagnioj@jcrosoft.com>

This make the code mre readable

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/spi/atmel_spi.c |   89 ++++++++++++++++++++++++++---------------------
 1 file changed, 49 insertions(+), 40 deletions(-)

diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c
index 3375f81..afbca9f 100644
--- a/drivers/spi/atmel_spi.c
+++ b/drivers/spi/atmel_spi.c
@@ -178,13 +178,54 @@ static int atmel_spi_xchg(struct atmel_spi *as, u32 tx_val)
 	return spi_readl(as, RDR) & 0xffff;
 }
 
+static int atmel_spi_do_xfer(struct spi_device *spi, struct atmel_spi *as,
+			     struct spi_transfer *t)
+{
+	unsigned int bits = spi->bits_per_word;
+	u32 tx_val;
+	int i = 0, rx_val;
+
+	if (bits <= 8) {
+		const u8 *txbuf = t->tx_buf;
+		u8 *rxbuf = t->rx_buf;
+
+		while (i < t->len) {
+			tx_val = txbuf ? txbuf[i] : 0;
+
+			rx_val = atmel_spi_xchg(as, tx_val);
+			if (rx_val < 0)
+				return rx_val;
+
+			if (rxbuf)
+				rxbuf[i] = rx_val;
+			i++;
+		}
+	} else if (bits <= 16) {
+		const u16 *txbuf = t->tx_buf;
+		u16 *rxbuf = t->rx_buf;
+
+		while (i < t->len >> 1) {
+			tx_val = txbuf ? txbuf[i] : 0;
+
+			rx_val = atmel_spi_xchg(as, tx_val);
+			if (rx_val < 0)
+				return rx_val;
+
+			if (rxbuf)
+				rxbuf[i] = rx_val;
+			i++;
+		}
+	}
+
+	return t->len;
+}
+
 static int atmel_spi_transfer(struct spi_device *spi, struct spi_message *mesg)
 {
 	int ret;
 	struct spi_master *master	= spi->master;
 	struct atmel_spi *as		= to_atmel_spi(master);
 	struct spi_transfer *t		= NULL;
-	unsigned int bits		= spi->bits_per_word;
 
 	mesg->actual_length = 0;
 	ret = master->setup(spi);
@@ -203,47 +244,15 @@ static int atmel_spi_transfer(struct spi_device *spi, struct spi_message *mesg)
 	}
 #endif
 	atmel_spi_chipselect(spi, as, 1);
+
 	list_for_each_entry(t, &mesg->transfers, transfer_list) {
-		u32 tx_val;
-		int i = 0, rx_val;
-
-		mesg->actual_length += t->len;
-		if (bits <= 8) {
-			const u8 *txbuf = t->tx_buf;
-			u8 *rxbuf = t->rx_buf;
-
-			while (i < t->len) {
-				tx_val = txbuf ? txbuf[i] : 0;
-
-				rx_val = atmel_spi_xchg(as, tx_val);
-				if (rx_val < 0) {
-					ret = rx_val;
-					goto out;
-				}
-
-				if (rxbuf)
-					rxbuf[i] = rx_val;
-				i++;
-			}
-		} else if (bits <= 16) {
-			const u16 *txbuf = t->tx_buf;
-			u16 *rxbuf = t->rx_buf;
-
-			while (i < t->len >> 1) {
-				tx_val = txbuf ? txbuf[i] : 0;
-
-				rx_val = atmel_spi_xchg(as, tx_val);
-				if (rx_val < 0) {
-					ret = rx_val;
-					goto out;
-				}
-
-				if (rxbuf)
-					rxbuf[i] = rx_val;
-				i++;
-			}
-		}
+
+		ret = atmel_spi_do_xfer(spi, as, t);
+		if (ret < 0)
+			goto out;
+		mesg->actual_length += ret;
 	}
+
 out:
 	atmel_spi_chipselect(spi, as, 0);
 	return ret;
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Tue Nov  6 14:33:34 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Tue,  6 Nov 2012 20:33:34 +0100
Subject: [PATCH 6/8] atmel_spi: drop setup during transfer
In-Reply-To: <1352230416-9396-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121106193010.GE25679@game.jcrosoft.org>
 <1352230416-9396-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1352230416-9396-6-git-send-email-plagnioj@jcrosoft.com>

this need to be handle at framework and driver level

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/spi/atmel_spi.c |    5 -----
 1 file changed, 5 deletions(-)

diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c
index ba1e467..ee0c4b4 100644
--- a/drivers/spi/atmel_spi.c
+++ b/drivers/spi/atmel_spi.c
@@ -322,11 +322,6 @@ static int atmel_spi_transfer(struct spi_device *spi, struct spi_message *mesg)
 	struct spi_transfer *t		= NULL;
 
 	mesg->actual_length = 0;
-	ret = master->setup(spi);
-	if (ret < 0) {
-		dev_dbg(master->dev, "transfer: master setup failed\n");
-		return ret;
-	}
 
 	dev_dbg(master->dev, "  csr0: %08x\n", spi_readl(as, CSR0));
 
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Tue Nov  6 14:33:35 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Tue,  6 Nov 2012 20:33:35 +0100
Subject: [PATCH 7/8] atmel_spi: add cs change support
In-Reply-To: <1352230416-9396-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121106193010.GE25679@game.jcrosoft.org>
 <1352230416-9396-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1352230416-9396-7-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/spi/atmel_spi.c |   24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c
index ee0c4b4..793933e 100644
--- a/drivers/spi/atmel_spi.c
+++ b/drivers/spi/atmel_spi.c
@@ -320,6 +320,7 @@ static int atmel_spi_transfer(struct spi_device *spi, struct spi_message *mesg)
 	struct spi_master *master	= spi->master;
 	struct atmel_spi *as		= to_atmel_spi(master);
 	struct spi_transfer *t		= NULL;
+	unsigned int cs_change;
 
 	mesg->actual_length = 0;
 
@@ -335,15 +336,34 @@ static int atmel_spi_transfer(struct spi_device *spi, struct spi_message *mesg)
 
 	cs_activate(as, spi);
 
+	cs_change = 0;
+
 	list_for_each_entry(t, &mesg->transfers, transfer_list) {
 
+		if (cs_change) {
+			udelay(1);
+			cs_deactivate(as, spi);
+			udelay(1);
+			cs_activate(as, spi);
+		}
+
+		cs_change = t->cs_change;
+
 		ret = atmel_spi_do_xfer(spi, as, t);
 		if (ret < 0)
-			goto out;
+			goto err;
 		mesg->actual_length += ret;
+
+		if (cs_change)
+			cs_activate(as, spi);
 	}
 
-out:
+	if (!cs_change)
+		cs_deactivate(as, spi);
+
+	return 0;
+
+err:
 	cs_deactivate(as, spi);
 	return ret;
 }
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Tue Nov  6 14:33:33 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Tue,  6 Nov 2012 20:33:33 +0100
Subject: [PATCH 5/8] atmel_spi: fix cs support
In-Reply-To: <1352230416-9396-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121106193010.GE25679@game.jcrosoft.org>
 <1352230416-9396-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1352230416-9396-5-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/spi/atmel_spi.c |  122 ++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 100 insertions(+), 22 deletions(-)

diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c
index 17b91eb..ba1e467 100644
--- a/drivers/spi/atmel_spi.c
+++ b/drivers/spi/atmel_spi.c
@@ -66,16 +66,104 @@ static inline bool atmel_spi_is_v2(void)
 	return !cpu_is_at91rm9200();
 }
 
-static void atmel_spi_chipselect(struct spi_device *spi, struct atmel_spi *as, int on)
+/*
+ * Earlier SPI controllers (e.g. on at91rm9200) have a design bug whereby
+ * they assume that spi slave device state will not change on deselect, so
+ * that automagic deselection is OK.  ("NPCSx rises if no data is to be
+ * transmitted")  Not so!  Workaround uses nCSx pins as GPIOs; or newer
+ * controllers have CSAAT and friends.
+ *
+ * Since the CSAAT functionality is a bit weird on newer controllers as
+ * well, we use GPIO to control nCSx pins on all controllers, updating
+ * MR.PCS to avoid confusing the controller.  Using GPIOs also lets us
+ * support active-high chipselects despite the controller's belief that
+ * only active-low devices/systems exists.
+ *
+ * However, at91rm9200 has a second erratum whereby nCS0 doesn't work
+ * right when driven with GPIO.  ("Mode Fault does not allow more than one
+ * Master on Chip Select 0.")  No workaround exists for that ... so for
+ * nCS0 on that chip, we (a) don't use the GPIO, (b) can't support CS_HIGH,
+ * and (c) will trigger that first erratum in some cases.
+ *
+ * TODO: Test if the atmel_spi_is_v2() branch below works on
+ * AT91RM9200 if we use some other register than CSR0. However, don't
+ * do this unconditionally since AP7000 has an errata where the BITS
+ * field in CSR0 overrides all other CSRs.
+ */
+
+static void cs_activate(struct atmel_spi *as, struct spi_device *spi)
 {
 	struct spi_master *master = &as->master;
-	int cs_pin;
-	int val = ((spi->mode & SPI_CS_HIGH) != 0) == on;
+	int npcs_pin;
+	unsigned active = spi->mode & SPI_CS_HIGH;
+	u32 mr, csr;
 
 	BUG_ON(spi->chip_select >= master->num_chipselect);
-	cs_pin = as->cs_pins[spi->chip_select];
+	npcs_pin = as->cs_pins[spi->chip_select];
+
+	csr = (u32)spi->controller_data;
 
-	gpio_direction_output(cs_pin, val);
+	if (atmel_spi_is_v2()) {
+		/*
+		 * Always use CSR0. This ensures that the clock
+		 * switches to the correct idle polarity before we
+		 * toggle the CS.
+		 */
+		spi_writel(as, CSR0, csr);
+		spi_writel(as, MR, SPI_BF(PCS, 0x0e) | SPI_BIT(MODFDIS)
+				| SPI_BIT(MSTR));
+		mr = spi_readl(as, MR);
+		gpio_set_value(npcs_pin, active);
+	} else {
+		u32 cpol = (spi->mode & SPI_CPOL) ? SPI_BIT(CPOL) : 0;
+		int i;
+		u32 csr;
+
+		/* Make sure clock polarity is correct */
+		for (i = 0; i < spi->master->num_chipselect; i++) {
+			csr = spi_readl(as, CSR0 + 4 * i);
+			if ((csr ^ cpol) & SPI_BIT(CPOL))
+				spi_writel(as, CSR0 + 4 * i,
+						csr ^ SPI_BIT(CPOL));
+		}
+
+		mr = spi_readl(as, MR);
+		mr = SPI_BFINS(PCS, ~(1 << spi->chip_select), mr);
+		if (npcs_pin != AT91_PIN_PA3)
+			gpio_set_value(npcs_pin, active);
+		spi_writel(as, MR, mr);
+	}
+
+	dev_dbg(&spi->dev, "activate %u%s, mr %08x\n",
+			npcs_pin, active ? " (high)" : "",
+			mr);
+}
+
+static void cs_deactivate(struct atmel_spi *as, struct spi_device *spi)
+{
+	struct spi_master *master = &as->master;
+	int npcs_pin;
+	unsigned active = spi->mode & SPI_CS_HIGH;
+	u32 mr;
+
+	BUG_ON(spi->chip_select >= master->num_chipselect);
+	npcs_pin = as->cs_pins[spi->chip_select];
+
+	/* only deactivate *this* device; sometimes transfers to
+	 * another device may be active when this routine is called.
+	 */
+	mr = spi_readl(as, MR);
+	if (~SPI_BFEXT(PCS, mr) & (1 << spi->chip_select)) {
+		mr = SPI_BFINS(PCS, 0xf, mr);
+		spi_writel(as, MR, mr);
+	}
+
+	dev_dbg(&spi->dev, "DEactivate %u%s, mr %08x\n",
+			npcs_pin, active ? " (low)" : "",
+			mr);
+
+	if (atmel_spi_is_v2() || npcs_pin != AT91_PIN_PA3)
+		gpio_set_value(npcs_pin, !active);
 }
 
 static int atmel_spi_setup(struct spi_device *spi)
@@ -101,12 +189,6 @@ static int atmel_spi_setup(struct spi_device *spi)
 		return -EINVAL;
 	}
 
-	if (spi->controller_data) {
-		csr = (u32)spi->controller_data;
-		spi_writel(as, CSR0, csr);
-		goto out;
-	}
-
 	dev_dbg(master->dev, "%s mode 0x%08x bits_per_word: %d speed: %d\n",
 			__func__, spi->mode, spi->bits_per_word,
 			spi->max_speed_hz);
@@ -157,17 +239,12 @@ static int atmel_spi_setup(struct spi_device *spi)
 		"setup: %lu Hz bpw %u mode 0x%x -> csr%d %08x\n",
 		bus_hz / scbr, bits, spi->mode, spi->chip_select, csr);
 
-	spi_writel(as, CSR0, csr);
+	spi->controller_data = (void *)csr;
 
-	/*
-	 * store the csr-setting when bits are defined. This happens usually
-	 * after the specific spi_device driver has been probed.
-	 */
-	if (bits > 0)
-		spi->controller_data = (void *)csr;
+	cs_deactivate(as, spi);
 
-out:
-	atmel_spi_chipselect(spi, as, 0);
+	if (!atmel_spi_is_v2())
+		spi_writel(as, CSR0 + 4 * spi->chip_select, csr);
 
 	return 0;
 }
@@ -260,7 +337,8 @@ static int atmel_spi_transfer(struct spi_device *spi, struct spi_message *mesg)
 			t, t->len, t->tx_buf, t->rx_buf);
 	}
 #endif
-	atmel_spi_chipselect(spi, as, 1);
+
+	cs_activate(as, spi);
 
 	list_for_each_entry(t, &mesg->transfers, transfer_list) {
 
@@ -271,7 +349,7 @@ static int atmel_spi_transfer(struct spi_device *spi, struct spi_message *mesg)
 	}
 
 out:
-	atmel_spi_chipselect(spi, as, 0);
+	cs_deactivate(as, spi);
 	return ret;
 }
 
-- 
1.7.10.4



From mdburkey at gmail.com  Tue Nov  6 14:48:32 2012
From: mdburkey at gmail.com (Michael Burkey)
Date: Tue, 6 Nov 2012 19:48:32 +0000 (UTC)
Subject: [RFC][PATCH] pcm043: usb support --not working--
References: <loom.20120719T173418-826@post.gmane.org>
 <20120719161139.GB30009@pengutronix.de>
 <loom.20120719T224910-551@post.gmane.org>
 <20120720080435.GP30009@pengutronix.de> <1343827988.3466.76.camel@mars>
 <20120801185644.52c45c4b@eb-e6520> <1343855078.3466.85.camel@mars>
 <20120802081509.GH30009@pengutronix.de>
Message-ID: <loom.20121106T203753-607@post.gmane.org>

Sascha Hauer <s.hauer at ...> writes:

> 
> On Wed, Aug 01, 2012 at 11:04:38PM +0200, Christoph Fritz wrote:
> > On Wed, 2012-08-01 at 18:56 +0200, Eric B?nard wrote: 
> > > > The clock settings seems to be the same as for eukrea_cpuimx35. Eric:
> > > > Does USB work for you on your board?
> > > > 
> > > thanks for the heads up : now it works.
> > 
> > great 
> > 
> > > > Sascha, I currently have no working config for kernel >=3.5 to check for
> > > > clocks in debugfs.
> > > > 
> > > > Any thoughts on this?
> > > > 
> > > try to copy the config in that patch I just sent 
> > 
> > I did - without success. I suppose the external phy needs to be
> > configured properly.
> > 
> > When you type the command "usb", you are getting a list of connected
> > devices. Can you execute command "usb" a second and third time with the
> > same result?
> 
> By default 'usb' now only probes once. That is because the USB stack is
> too silly to just keep already enumarated devices, but instead just
> removes all devices and reenumarates them. Bad things happen if one of
> your devices was a mounted USB mass storage device for example.
> If you want to probe multiple times try the -f aka force aka I know what
> I'm doing option.
> 
> Sascha
> 

Sascha,

I work with Jerry and I've been doing a lot more testing with USB lately and 
we are still having issues under Barebox. We are on new hardware that now 
uses the internal Phy and everything seems to work find under Linux itself.
However,under Barebox I am still seeing the following behaviour:

1) The first time after reset, when I do the "USB" command it detects the
built-in hub device and any HID devices I have tested without issue. 
2) Any additional times I do "USB -F" after that it ONLY detects the
internal hub.
3) USB Mass Storage devices (flash drives, hard drives, et al) are NEVER
detected -- and I've tried a LOT of different ones. The vast majority are
never even detected at all, but I have one really old one that it will at
least say "2 devices detected" on the probe but never shows any description
of the device.

We are using a PCM043 SOM on a custom carrier board -- and to the best of 
my knowledge everything is setup properly. I've also checked the USB clock
and it is correct. I have so far tried this with both Barebox 9 and Barebox
10, with no success. I have made sure that USB support is compiled in, as
well as mass storage support and FAT support.

Do you have any ideas as to what might be going on or what we should be 
looking at? 

Thanks,
Michael Burkey






From plagnioj at jcrosoft.com  Tue Nov  6 14:33:36 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Tue,  6 Nov 2012 20:33:36 +0100
Subject: [PATCH 8/8] at91rm9200: fix spi cs support
In-Reply-To: <1352230416-9396-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121106193010.GE25679@game.jcrosoft.org>
 <1352230416-9396-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1352230416-9396-8-git-send-email-plagnioj@jcrosoft.com>

the rm9200 have a errata the cs0 must be used via hw cs not gpio

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/mach-at91/at91rm9200_devices.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-at91/at91rm9200_devices.c b/arch/arm/mach-at91/at91rm9200_devices.c
index 8cb2f57..c9ceef9 100644
--- a/arch/arm/mach-at91/at91rm9200_devices.c
+++ b/arch/arm/mach-at91/at91rm9200_devices.c
@@ -182,7 +182,12 @@ void at91_add_device_spi(int spi_id, struct at91_spi_platform_data *pdata)
 		cs_pin = pdata->chipselect[i];
 
 		/* enable chip-select pin */
-		if (cs_pin > 0)
+		if (!gpio_is_valid(cs_pin))
+			continue;
+
+		if (cs_pin == AT91_PIN_PA3)
+			at91_set_A_periph(cs_pin, 0);
+		else
 			at91_set_gpio_output(cs_pin, 1);
 	}
 
-- 
1.7.10.4



From robert.jarzmik at free.fr  Tue Nov  6 15:50:39 2012
From: robert.jarzmik at free.fr (Robert Jarzmik)
Date: Tue, 06 Nov 2012 21:50:39 +0100
Subject: [PATCH v2 1/2] commands: change Y-Modem implementation
In-Reply-To: <20121106073458.GD25679@game.jcrosoft.org> (Jean-Christophe
 PLAGNIOL-VILLARD's message of "Tue, 6 Nov 2012 08:34:58 +0100")
References: <1351791438-29967-1-git-send-email-robert.jarzmik@free.fr>
 <1352051724-16253-1-git-send-email-robert.jarzmik@free.fr>
 <20121104183659.GC29599@game.jcrosoft.org> <87mwyvvs7o.fsf@free.fr>
 <20121105182544.GB25679@game.jcrosoft.org> <878vafvq9b.fsf@free.fr>
 <20121105194907.GC25679@game.jcrosoft.org> <871ug7visp.fsf@free.fr>
 <20121106073458.GD25679@game.jcrosoft.org>
Message-ID: <87wqxytq00.fsf@free.fr>

Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com> writes:

> On 22:31 Mon 05 Nov     , Robert Jarzmik wrote:
>> Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com> writes:
>> And how do you choose the alternative UART ? loady is not provided such a
>> parameter in its new form.
> by it's name cs1 as example

>> Now if you want, I can add it. And if I add it, I'll add a timeout also to the
>> xy_flush() function ...
> yes please

>> >> > can you put the v3 on a tree somewhere so I can pull it
>> >> I'll try. I have no external git I can push to. If you have a hint ...
>> > https://git.wiki.kernel.org/index.php/GitHosting
>> Ah yes, ok. I'll send you the URL once I've amended the patches, along the
>> patch mails.
> personnaly for at91 we use github tks
Here is my candidate for v3 :
     git fetch git at github.com:rjarzmik/barebox.git xymodem

If you could test the "loady -t cs1", as I don't happen to have multiple
consoles ...
And Antony, if you have a little bit of time, would you test it also, as that
endianess bug drove me mad.

If it does work, I'll send the v3 of the patchset.

-- 
Robert


From apr at cn-eng.de  Tue Nov  6 20:52:19 2012
From: apr at cn-eng.de (Andreas Pretzsch)
Date: Wed,  7 Nov 2012 02:52:19 +0100
Subject: [PATCH] mdiobus: unbreak phy_device_connect() "scan all PHY
 addresses" feature
Message-ID: <1352253139-19430-1-git-send-email-apr@cn-eng.de>

Calling phy_device_connect() with a PHY address of -1 will scan for a PHY
in the address range of 0..PHY_MAX_ADDR and registers the first one found.
This was broken by commit 09254f639c94cc7dc47fff7638dc8c7f88d700b1
"mdiobus: do not scan the bus at registration time", erroneously scanning
for -1 as PHY address.

Signed-off-by: Andreas Pretzsch <apr at cn-eng.de>
---
patch against branch "next" / commit 129300139cbe7265c4b8b4142740c59b5b997e4d

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

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 8d36300..547e269 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -169,7 +169,7 @@ int phy_device_connect(struct eth_device *edev, struct mii_bus *bus, int addr,
 				goto fail;
 		} else {
 			for (i = 0; i < PHY_MAX_ADDR && !edev->phydev; i++) {
-				dev = mdiobus_scan(bus, addr);
+				dev = mdiobus_scan(bus, i);
 				if (!dev || dev->attached_dev)
 					continue;
 
-- 
1.7.10.4



From s.hauer at pengutronix.de  Wed Nov  7 03:04:22 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Wed, 7 Nov 2012 09:04:22 +0100
Subject: TX53: Not Bootable from next tree
In-Reply-To: <alpine.LSU.2.00.1211061440560.27068@redbean.intranet.gw-instruments.de>
References: <alpine.LSU.2.00.1211061440560.27068@redbean.intranet.gw-instruments.de>
Message-ID: <20121107080422.GA10369@pengutronix.de>

On Tue, Nov 06, 2012 at 02:49:06PM +0100, Peter Wippich wrote:
> 
> Hi,
> 
> got the same problem here. Double checked Board Version (8030) and
> that I have the right binary (compressed with flash header). After
> flashing and reset nothing happens....
> 

I'll recheck when I'm back in the office next week. I have no idea what
is going wrong atm.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Wed Nov  7 03:05:50 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Wed, 7 Nov 2012 09:05:50 +0100
Subject: [PATCH] mdiobus: unbreak phy_device_connect() "scan all PHY
 addresses" feature
In-Reply-To: <1352253139-19430-1-git-send-email-apr@cn-eng.de>
References: <1352253139-19430-1-git-send-email-apr@cn-eng.de>
Message-ID: <20121107080550.GB10369@pengutronix.de>

Hi Andreas,

On Wed, Nov 07, 2012 at 02:52:19AM +0100, Andreas Pretzsch wrote:
> Calling phy_device_connect() with a PHY address of -1 will scan for a PHY
> in the address range of 0..PHY_MAX_ADDR and registers the first one found.
> This was broken by commit 09254f639c94cc7dc47fff7638dc8c7f88d700b1
> "mdiobus: do not scan the bus at registration time", erroneously scanning
> for -1 as PHY address.
> 

Folded this into the original patch breaking it.

Thanks
 Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From antonynpavlov at gmail.com  Wed Nov  7 03:22:53 2012
From: antonynpavlov at gmail.com (Antony Pavlov)
Date: Wed, 7 Nov 2012 12:22:53 +0400
Subject: [PATCH v2 1/2] commands: change Y-Modem implementation
In-Reply-To: <87wqxytq00.fsf@free.fr>
References: <1351791438-29967-1-git-send-email-robert.jarzmik@free.fr>
 <1352051724-16253-1-git-send-email-robert.jarzmik@free.fr>
 <20121104183659.GC29599@game.jcrosoft.org> <87mwyvvs7o.fsf@free.fr>
 <20121105182544.GB25679@game.jcrosoft.org> <878vafvq9b.fsf@free.fr>
 <20121105194907.GC25679@game.jcrosoft.org> <871ug7visp.fsf@free.fr>
 <20121106073458.GD25679@game.jcrosoft.org> <87wqxytq00.fsf@free.fr>
Message-ID: <CAA4bVAHpB2zxpC1LznHG1A64BohWEZSA6D3Wocx0y2fK+5CcXw@mail.gmail.com>

On 7 November 2012 00:50, Robert Jarzmik <robert.jarzmik at free.fr> wrote:
> Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com> writes:
>
>> On 22:31 Mon 05 Nov     , Robert Jarzmik wrote:
>>> Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com> writes:
>>> And how do you choose the alternative UART ? loady is not provided such a
>>> parameter in its new form.
>> by it's name cs1 as example
>
>>> Now if you want, I can add it. And if I add it, I'll add a timeout also to the
>>> xy_flush() function ...
>> yes please
>
>>> >> > can you put the v3 on a tree somewhere so I can pull it
>>> >> I'll try. I have no external git I can push to. If you have a hint ...
>>> > https://git.wiki.kernel.org/index.php/GitHosting
>>> Ah yes, ok. I'll send you the URL once I've amended the patches, along the
>>> patch mails.
>> personnaly for at91 we use github tks
> Here is my candidate for v3 :
>      git fetch git at github.com:rjarzmik/barebox.git xymodem
>
> If you could test the "loady -t cs1", as I don't happen to have multiple
> consoles ...
> And Antony, if you have a little bit of time, would you test it also, as that
> endianess bug drove me mad.

I just have tested your v3 patchset. It works fine on my little-endian
MIPS CPU, but it needs a small patch for correct work on the
big-endian one. You can find the patch in my next message.

I have fetched your v3 branch from your github repo. I'm sorry, but I
have no time to test it just now on my hardware. But I think where
will be no problems with squashing my patch into it.

-- 
Best regards,
  Antony Pavlov


From antonynpavlov at gmail.com  Wed Nov  7 03:23:05 2012
From: antonynpavlov at gmail.com (Antony Pavlov)
Date: Wed,  7 Nov 2012 12:23:05 +0400
Subject: [PATCH] make new y-modem (PATCH v2) work on big-endian CPU
Message-ID: <1352276585-20262-1-git-send-email-antonynpavlov@gmail.com>

apply this commit after that one:

    Author: Robert Jarzmik <robert.jarzmik at free.fr>
    Date:   Sun Nov 4 18:55:23 2012 +0100

        commands: change Y-Modem implementation
---
 lib/xymodem.c |   13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/lib/xymodem.c b/lib/xymodem.c
index 1469a9a..0e82ce2 100644
--- a/lib/xymodem.c
+++ b/lib/xymodem.c
@@ -257,8 +257,8 @@ static ssize_t xy_read_block(struct xyz_ctxt *proto, struct xy_block *blk,
 	uint64_t timeout)
 {
 	ssize_t rc, data_len = 0;
-	unsigned char hdr, seqs[2], crcs[2];
-	int crc = 0, hdr_found = 0;
+	unsigned char hdr, seqs[2];
+	uint16_t crc = 0, hdr_found = 0;
 	uint64_t start = get_time_ns();
 
 	while (!hdr_found) {
@@ -308,12 +308,13 @@ static ssize_t xy_read_block(struct xyz_ctxt *proto, struct xy_block *blk,
 
 	switch (proto->crc_mode) {
 	case CRC_ADD8:
-		rc = xy_gets(proto->cdev, proto->fifo, crcs, 1, timeout);
-		crc = crcs[0];
+		rc = xy_gets(proto->cdev, proto->fifo,
+				(unsigned char *)&crc, 1, timeout);
 		break;
 	case CRC_CRC16:
-		rc = xy_gets(proto->cdev, proto->fifo, crcs, 2, timeout);
-		crc = be16_to_cpu(*(uint16_t *)crcs);
+		rc = xy_gets(proto->cdev, proto->fifo,
+				(unsigned char *)&crc, 2, timeout);
+		crc = be16_to_cpu(crc);
 		break;
 	case CRC_NONE:
 		rc = 0;
-- 
1.7.10.4



From apr at cn-eng.de  Wed Nov  7 17:59:39 2012
From: apr at cn-eng.de (Andreas Pretzsch)
Date: Wed,  7 Nov 2012 23:59:39 +0100
Subject: [PATCH] mdiobus: unbreak phy_device_connect(): honor masked out PHYs
Message-ID: <1352329179-19809-1-git-send-email-apr@cn-eng.de>

commit 89dfe2d2af87f1b803f611d986d4ef383b6ad964 "mdiobus: do not scan
the bus at registration time" dropped the check for struct mii_bus
element phy_mask while scanning through all addresses.
Re-add this check.

Signed-off-by: Andreas Pretzsch <apr at cn-eng.de>
---
patch against branch "next" / commit 89dfe2d2af87f1b803f611d986d4ef383b6ad964
Another one to fold into original patch. Sorry for missing it the first round.

 drivers/net/phy/phy.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 547e269..d8132b9 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -169,6 +169,10 @@ int phy_device_connect(struct eth_device *edev, struct mii_bus *bus, int addr,
 				goto fail;
 		} else {
 			for (i = 0; i < PHY_MAX_ADDR && !edev->phydev; i++) {
+				/* skip masked out PHY addresses */
+				if (bus->phy_mask & (1 << i))
+					continue;
+
 				dev = mdiobus_scan(bus, i);
 				if (!dev || dev->attached_dev)
 					continue;
-- 
1.7.10.4



From apr at cn-eng.de  Wed Nov  7 18:25:03 2012
From: apr at cn-eng.de (Andreas Pretzsch)
Date: Thu,  8 Nov 2012 00:25:03 +0100
Subject: [PATCH] net smc911x: add support for external PHY
Message-ID: <1352330703-27402-1-git-send-email-apr@cn-eng.de>

On LAN9115/LAN9117/LAN9215/LAN9217, external PHYs are supported.
Switch to external PHY based on hardware strap pin and/or override flags.
Also add a mask to platform data selecting external PHY address to be used.

Code based on linux/drivers/net/ethernet/smsc/smsc911x.c (fd9abb3d, d23f028a).
---
Code is tested on a SMSC LAN9217 with an external PHY (switch chip attached
in PHY mode via MII), the external mode works as expected.
As I have no board at hand using the internal PHY of the controller (or any
of these family), I cannot verify the current behaviour, beside looking at
the internal PHY register (which are fine).
But as the modifications are mostly 1:1 copies of the respective Linux mainline
code, slightly adapted for Barebox, I expect no problems here.

Patch is against current next, but should also match current master.
CC'ing last active authors.

 drivers/net/smc911x.c |   97 +++++++++++++++++++++++++++++++++++++++++++++++--
 include/smc911x.h     |    6 +++
 2 files changed, 99 insertions(+), 4 deletions(-)

diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index c657fec..28c69ba 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -44,6 +44,10 @@ struct smc911x_priv {
 
 	int shift;
 	int generation;
+	unsigned int flags;
+	unsigned int idrev;
+	unsigned int using_extphy;
+	unsigned int phy_mask;
 
 	u32 (*reg_read)(struct smc911x_priv *priv, u32 reg);
 	void (*reg_write)(struct smc911x_priv *priv, u32 reg, u32 val);
@@ -225,6 +229,60 @@ static int smc911x_phy_write(struct mii_bus *bus, int phy_addr,
 	return 0;
 }
 
+/* Switch to external phy. Assumes tx and rx are stopped. */
+static void smsc911x_phy_enable_external(struct eth_device *edev)
+{
+	struct smc911x_priv *priv = edev->priv;
+	u32 hwcfg = smc911x_reg_read(priv, HW_CFG);
+
+	/* Disable phy clocks to the MAC */
+	hwcfg &= (~HW_CFG_PHY_CLK_SEL);
+	hwcfg |= HW_CFG_PHY_CLK_SEL_CLK_DIS;
+	smc911x_reg_write(priv, HW_CFG, hwcfg);
+	udelay(10);	/* Enough time for clocks to stop */
+
+	/* Switch to external phy */
+	hwcfg |= HW_CFG_EXT_PHY_EN;
+	smc911x_reg_write(priv, HW_CFG, hwcfg);
+
+	/* Enable phy clocks to the MAC */
+	hwcfg &= (~HW_CFG_PHY_CLK_SEL);
+	hwcfg |= HW_CFG_PHY_CLK_SEL_EXT_PHY;
+	smc911x_reg_write(priv, HW_CFG, hwcfg);
+	udelay(10);	/* Enough time for clocks to restart */
+
+	/* Switch MDIO/MDC to external PHY */
+	hwcfg |= HW_CFG_SMI_SEL;
+	smc911x_reg_write(priv, HW_CFG, hwcfg);
+}
+
+/* Autodetects and enables external phy if present on supported chips.
+ * autodetection can be overridden by specifying SMC911X_FORCE_INTERNAL_PHY
+ * or SMC911X_FORCE_EXTERNAL_PHY in the platform_data flags. */
+static void smsc911x_phy_initialise_external(struct eth_device *edev)
+{
+	struct smc911x_priv *priv = edev->priv;
+	u32 hwcfg = smc911x_reg_read(priv, HW_CFG);
+
+	if (priv->flags & SMC911X_FORCE_INTERNAL_PHY) {
+		dev_info(edev->parent, "Forcing internal PHY\n");
+		priv->using_extphy = 0;
+	} else if (priv->flags & SMC911X_FORCE_EXTERNAL_PHY) {
+		dev_info(edev->parent, "Forcing external PHY\n");
+		smsc911x_phy_enable_external(edev);
+		priv->using_extphy = 1;
+	} else if (hwcfg & HW_CFG_EXT_PHY_DET) {
+		dev_info(edev->parent,
+			"HW_CFG EXT_PHY_DET set, using external PHY\n");
+		smsc911x_phy_enable_external(edev);
+		priv->using_extphy = 1;
+	} else {
+		dev_info(edev->parent,
+			"HW_CFG EXT_PHY_DET clear, using internal PHY\n");
+		priv->using_extphy = 0;
+	}
+}
+
 static int smc911x_phy_reset(struct eth_device *edev)
 {
 	struct smc911x_priv *priv = edev->priv;
@@ -284,14 +342,41 @@ static void smc911x_reset(struct eth_device *edev)
 
 	/* Set to LED outputs */
 	smc911x_reg_write(priv, GPIO_CFG, 0x70070000);
+
+	/* Select internal/external PHY */
+	switch (priv->idrev & 0xFFFF0000) {
+	case 0x01170000:
+	case 0x01150000:
+	case 0x117A0000:
+	case 0x115A0000:
+		/* External PHY supported, try to autodetect */
+		smsc911x_phy_initialise_external(edev);
+		break;
+	default:
+		dev_dbg(edev->parent, "External PHY is not supported, "
+			"using internal PHY\n");
+		priv->using_extphy = 0;
+		break;
+	}
+
+	if (!priv->using_extphy) {
+		/* Mask all PHYs except ID 1 (internal) */
+		priv->miibus.phy_mask = ~(1 << 1);
+	} else {
+		/* Mask PHYs as requested (or try all if mask is 0) */
+		/* Attn.: first probed PHY is used by phy_device_connect */
+		priv->miibus.phy_mask = priv->phy_mask;
+	}
 }
 
 static void smc911x_enable(struct eth_device *edev)
 {
 	struct smc911x_priv *priv = edev->priv;
+	u32 hw_cfg_phy_settings;
 
 	/* Enable TX */
-	smc911x_reg_write(priv, HW_CFG, 8 << 16 | HW_CFG_SF);
+	hw_cfg_phy_settings = smc911x_reg_read(priv, HW_CFG) & (HW_CFG_PHY_CLK_SEL|HW_CFG_SMI_SEL|HW_CFG_EXT_PHY_EN);
+	smc911x_reg_write(priv, HW_CFG, 8 << 16 | HW_CFG_SF | hw_cfg_phy_settings);
 
 	smc911x_reg_write(priv, GPT_CFG, GPT_CFG_TIMER_EN | 10000);
 
@@ -306,7 +391,8 @@ static int smc911x_eth_open(struct eth_device *edev)
 	struct smc911x_priv *priv = (struct smc911x_priv *)edev->priv;
 	int ret;
 
-	ret = phy_device_connect(edev, &priv->miibus, 1, NULL,
+	/* use first probed PHY (see also phy_mask) */
+	ret = phy_device_connect(edev, &priv->miibus, -1, NULL,
 				 0, PHY_INTERFACE_MODE_NA);
 	if (ret)
 		return ret;
@@ -426,8 +512,11 @@ static int smc911x_probe(struct device_d *dev)
 		is_32bit = is_32bit == IORESOURCE_MEM_32BIT;
 	priv->base = dev_request_mem_region(dev, 0);
 
-	if (pdata && pdata->shift)
+	if (pdata) {
 		priv->shift = pdata->shift;
+		priv->flags = pdata->flags;
+		priv->phy_mask = pdata->phy_mask;
+	}
 
 	if (is_32bit) {
 		if (priv->shift) {
@@ -483,7 +572,7 @@ static int smc911x_probe(struct device_d *dev)
 		return -ENODEV;
 	}
 
-	val = smc911x_reg_read(priv, ID_REV);
+	priv->idrev = val = smc911x_reg_read(priv, ID_REV);
 	switch (val & 0xFFFF0000) {
 	case 0x01180000:
 	case 0x01170000:
diff --git a/include/smc911x.h b/include/smc911x.h
index 148906b..4a802ee 100644
--- a/include/smc911x.h
+++ b/include/smc911x.h
@@ -13,6 +13,12 @@
  */
 struct smc911x_plat {
 	int shift;
+	unsigned int flags;
+	unsigned int phy_mask;	/* external PHY only: mask out PHYs,
+				   e.g. ~(1 << 5) to use PHY addr 5 */
 };
 
+#define SMC911X_FORCE_INTERNAL_PHY	0x01
+#define SMC911X_FORCE_EXTERNAL_PHY	0x02
+
 #endif /* __SMC911X_PLATFORM_H_ */
-- 
1.7.10.4



From robert.jarzmik at free.fr  Wed Nov  7 18:41:38 2012
From: robert.jarzmik at free.fr (Robert Jarzmik)
Date: Thu, 08 Nov 2012 00:41:38 +0100
Subject: [PATCH] make new y-modem (PATCH v2) work on big-endian CPU
In-Reply-To: <1352276585-20262-1-git-send-email-antonynpavlov@gmail.com>
 (Antony Pavlov's message of "Wed, 7 Nov 2012 12:23:05 +0400")
References: <1352276585-20262-1-git-send-email-antonynpavlov@gmail.com>
Message-ID: <87pq3pt1zh.fsf@free.fr>

Antony Pavlov <antonynpavlov at gmail.com> writes:

> apply this commit after that one:
>
>     Author: Robert Jarzmik <robert.jarzmik at free.fr>
>     Date:   Sun Nov 4 18:55:23 2012 +0100
>
>         commands: change Y-Modem implementation
> ---
>  lib/xymodem.c |   13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/lib/xymodem.c b/lib/xymodem.c
> index 1469a9a..0e82ce2 100644
> --- a/lib/xymodem.c
> +++ b/lib/xymodem.c
> @@ -257,8 +257,8 @@ static ssize_t xy_read_block(struct xyz_ctxt *proto, struct xy_block *blk,
>  	uint64_t timeout)
>  {
>  	ssize_t rc, data_len = 0;
> -	unsigned char hdr, seqs[2], crcs[2];
> -	int crc = 0, hdr_found = 0;
> +	unsigned char hdr, seqs[2];
> +	uint16_t crc = 0, hdr_found = 0;
>  	uint64_t start = get_time_ns();
>  
>  	while (!hdr_found) {
> @@ -308,12 +308,13 @@ static ssize_t xy_read_block(struct xyz_ctxt *proto, struct xy_block *blk,
>  
>  	switch (proto->crc_mode) {
>  	case CRC_ADD8:
> -		rc = xy_gets(proto->cdev, proto->fifo, crcs, 1, timeout);
> -		crc = crcs[0];
> +		rc = xy_gets(proto->cdev, proto->fifo,
> +				(unsigned char *)&crc, 1, timeout);
This doesn't look good to me.
In big-endian arch, suppose you read 0xab as the crc.
In that case, won't crc be equal to 0xab00 instead of 0x00ab in this code ? If
that's the case, the previous code was right ...

>  		break;
>  	case CRC_CRC16:
> -		rc = xy_gets(proto->cdev, proto->fifo, crcs, 2, timeout);
> -		crc = be16_to_cpu(*(uint16_t *)crcs);
> +		rc = xy_gets(proto->cdev, proto->fifo,
> +				(unsigned char *)&crc, 2, timeout);
> +		crc = be16_to_cpu(crc);

Does that mean that the code up there doesn't work on big endian ? I'm really
puzzled, as the sender sends in big endian, the xy_gets() receives the bytes
into crcs[2], and the be16_to_cpu() should be a no-op ...

I think that we should do this simpler :
  crc = crcs[0] << 8 + crcs[1]

I'll put that into my github branch for testing.

Cheers.

-- 
Robert


From antonynpavlov at gmail.com  Thu Nov  8 00:49:15 2012
From: antonynpavlov at gmail.com (Antony Pavlov)
Date: Thu, 8 Nov 2012 09:49:15 +0400
Subject: [PATCH] make new y-modem (PATCH v2) work on big-endian CPU
In-Reply-To: <87pq3pt1zh.fsf@free.fr>
References: <1352276585-20262-1-git-send-email-antonynpavlov@gmail.com>
 <87pq3pt1zh.fsf@free.fr>
Message-ID: <CAA4bVAFtC4WscuH_e+wFnQnt33tg4v4iOtHiSsw7S6Fq4YJf0Q@mail.gmail.com>

On 8 November 2012 03:41, Robert Jarzmik <robert.jarzmik at free.fr> wrote:
> Antony Pavlov <antonynpavlov at gmail.com> writes:
>
>> apply this commit after that one:
>>
>>     Author: Robert Jarzmik <robert.jarzmik at free.fr>
>>     Date:   Sun Nov 4 18:55:23 2012 +0100
>>
>>         commands: change Y-Modem implementation
>> ---
>>  lib/xymodem.c |   13 +++++++------
>>  1 file changed, 7 insertions(+), 6 deletions(-)
>>
>> diff --git a/lib/xymodem.c b/lib/xymodem.c
>> index 1469a9a..0e82ce2 100644
>> --- a/lib/xymodem.c
>> +++ b/lib/xymodem.c
>> @@ -257,8 +257,8 @@ static ssize_t xy_read_block(struct xyz_ctxt *proto, struct xy_block *blk,
>>       uint64_t timeout)
>>  {
>>       ssize_t rc, data_len = 0;
>> -     unsigned char hdr, seqs[2], crcs[2];
>> -     int crc = 0, hdr_found = 0;
>> +     unsigned char hdr, seqs[2];
>> +     uint16_t crc = 0, hdr_found = 0;
>>       uint64_t start = get_time_ns();
>>
>>       while (!hdr_found) {
>> @@ -308,12 +308,13 @@ static ssize_t xy_read_block(struct xyz_ctxt *proto, struct xy_block *blk,
>>
>>       switch (proto->crc_mode) {
>>       case CRC_ADD8:
>> -             rc = xy_gets(proto->cdev, proto->fifo, crcs, 1, timeout);
>> -             crc = crcs[0];
>> +             rc = xy_gets(proto->cdev, proto->fifo,
>> +                             (unsigned char *)&crc, 1, timeout);
> This doesn't look good to me.
> In big-endian arch, suppose you read 0xab as the crc.
> In that case, won't crc be equal to 0xab00 instead of 0x00ab in this code ? If
> that's the case, the previous code was right ...

To make the patch I got your old working version and your PATCH v2
branches. I got 'git diff'. I found the key difference and tested the
patch. That is all.

May be the 'proto->crc_mode==CRC_ADD8' condition is always false
during my tests?

>>               break;
>>       case CRC_CRC16:
>> -             rc = xy_gets(proto->cdev, proto->fifo, crcs, 2, timeout);
>> -             crc = be16_to_cpu(*(uint16_t *)crcs);
>> +             rc = xy_gets(proto->cdev, proto->fifo,
>> +                             (unsigned char *)&crc, 2, timeout);
>> +             crc = be16_to_cpu(crc);
>
> Does that mean that the code up there doesn't work on big endian ? I'm really
> puzzled, as the sender sends in big endian, the xy_gets() receives the bytes
> into crcs[2], and the be16_to_cpu() should be a no-op ...

I have no idea just now. I'll try to disassemble generated code.

> I think that we should do this simpler :
>   crc = crcs[0] << 8 + crcs[1]
>
> I'll put that into my github branch for testing.

-- 
Best regards,
  Antony Pavlov


From antonynpavlov at gmail.com  Thu Nov  8 14:57:44 2012
From: antonynpavlov at gmail.com (Antony Pavlov)
Date: Thu, 8 Nov 2012 23:57:44 +0400
Subject: [PATCH] make new y-modem (PATCH v2) work on big-endian CPU
In-Reply-To: <87pq3pt1zh.fsf@free.fr>
References: <1352276585-20262-1-git-send-email-antonynpavlov@gmail.com>
 <87pq3pt1zh.fsf@free.fr>
Message-ID: <CAA4bVAF68HGdDqgtUCvxTiJJnGjb2j2sziQpLNY4e-fMFJOwcw@mail.gmail.com>

On 8 November 2012 03:41, Robert Jarzmik <robert.jarzmik at free.fr> wrote:
> Antony Pavlov <antonynpavlov at gmail.com> writes:
>
>> apply this commit after that one:
>>
>>     Author: Robert Jarzmik <robert.jarzmik at free.fr>
>>     Date:   Sun Nov 4 18:55:23 2012 +0100
>>
>>         commands: change Y-Modem implementation
>> ---
>>  lib/xymodem.c |   13 +++++++------
>>  1 file changed, 7 insertions(+), 6 deletions(-)
>>
>> diff --git a/lib/xymodem.c b/lib/xymodem.c
>> index 1469a9a..0e82ce2 100644
>> --- a/lib/xymodem.c
>> +++ b/lib/xymodem.c
>> @@ -257,8 +257,8 @@ static ssize_t xy_read_block(struct xyz_ctxt *proto, struct xy_block *blk,
>>       uint64_t timeout)
>>  {
>>       ssize_t rc, data_len = 0;
>> -     unsigned char hdr, seqs[2], crcs[2];
>> -     int crc = 0, hdr_found = 0;
>> +     unsigned char hdr, seqs[2];
>> +     uint16_t crc = 0, hdr_found = 0;
>>       uint64_t start = get_time_ns();
>>
>>       while (!hdr_found) {
>> @@ -308,12 +308,13 @@ static ssize_t xy_read_block(struct xyz_ctxt *proto, struct xy_block *blk,
>>
>>       switch (proto->crc_mode) {
>>       case CRC_ADD8:
>> -             rc = xy_gets(proto->cdev, proto->fifo, crcs, 1, timeout);
>> -             crc = crcs[0];
>> +             rc = xy_gets(proto->cdev, proto->fifo,
>> +                             (unsigned char *)&crc, 1, timeout);
> This doesn't look good to me.
> In big-endian arch, suppose you read 0xab as the crc.
> In that case, won't crc be equal to 0xab00 instead of 0x00ab in this code ? If
> that's the case, the previous code was right ...
>
>>               break;
>>       case CRC_CRC16:
>> -             rc = xy_gets(proto->cdev, proto->fifo, crcs, 2, timeout);
>> -             crc = be16_to_cpu(*(uint16_t *)crcs);
>> +             rc = xy_gets(proto->cdev, proto->fifo,
>> +                             (unsigned char *)&crc, 2, timeout);
>> +             crc = be16_to_cpu(crc);
>
> Does that mean that the code up there doesn't work on big endian ? I'm really
> puzzled, as the sender sends in big endian, the xy_gets() receives the bytes
> into crcs[2], and the be16_to_cpu() should be a no-op ...
>
> I think that we should do this simpler :
>   crc = crcs[0] << 8 + crcs[1]
>
> I'll put that into my github branch for testing.

I have just tested the commits from your github 'xymodem' branch on my
big-endian and little-endian MIPS boards.

It works perfect!

Tested-by: Antony Pavlov <antonynpavlov at gmail.com>

-- 
Best regards,
  Antony Pavlov


From robert.jarzmik at free.fr  Thu Nov  8 14:59:22 2012
From: robert.jarzmik at free.fr (Robert Jarzmik)
Date: Thu, 08 Nov 2012 20:59:22 +0100
Subject: [PATCH] make new y-modem (PATCH v2) work on big-endian CPU
In-Reply-To: <CAA4bVAFtC4WscuH_e+wFnQnt33tg4v4iOtHiSsw7S6Fq4YJf0Q@mail.gmail.com>
 (Antony Pavlov's message of "Thu, 8 Nov 2012 09:49:15 +0400")
References: <1352276585-20262-1-git-send-email-antonynpavlov@gmail.com>
 <87pq3pt1zh.fsf@free.fr>
 <CAA4bVAFtC4WscuH_e+wFnQnt33tg4v4iOtHiSsw7S6Fq4YJf0Q@mail.gmail.com>
Message-ID: <87liebuaqt.fsf@free.fr>

Antony Pavlov <antonynpavlov at gmail.com> writes:

> May be the 'proto->crc_mode==CRC_ADD8' condition is always false
> during my tests?
Yes, surely. CRC8 is a fallback when the sender is unable to cope with CRC16. As
you use linux sb, it does cope with CRC16 :)

Cheers.

-- 
Robert


From robert.jarzmik at free.fr  Thu Nov  8 16:16:40 2012
From: robert.jarzmik at free.fr (Robert Jarzmik)
Date: Thu,  8 Nov 2012 22:16:40 +0100
Subject: [PATCH v3 1/2] commands: change Y-Modem implementation
Message-ID: <1352409401-3333-1-git-send-email-robert.jarzmik@free.fr>

The current Y-Modem implementation has some limitations:
 - Y-Modem/G protocol is not supported
 - Multiple files (aka. batch) transfers are not supported
 - Transfer speed over fast lines (USB console) is slow
 - Code is not trivial to maintain (personnal opinion)

This implementation tries to address all these points by
introducing loady2 command.

The effects are :
 - transfer speed for Y-Modem over USB jumps from 2kBytes/s
   to 180kBytes/s
 - transfer speed for Y-Modem/G jumps to 200kBytes/s
 - multiple file transfers are possible

This command was tested on a USB console and UART 9600bps
serial line :
 - NAKs (and retransmissions) were tested for faulty
   serial lines
 - multiple file transfers were tested
 - Y-Modem, Y-Modem/G and X-Modem transfers were tested

Signed-off-by: Robert Jarzmik <robert.jarzmik at free.fr>
Tested-by: Antony Pavlov <antonynpavlov at gmail.com>

---
Since V1:
 - add input fifo for small fifo hardwares
Add a FIFO so that each getc will empty the hardware
FIFO. This is very similar to the generic console code,
except that the getc won't block each time for 100us,
enabling faster lines (USB) to benefit their full speed.
 - fix CRC calculation for big endian architectures
   Thanks a lot Antony for the many patches testing !
 - added some documentation
 - amended the split as Sascha recommended

Since V2:
 - Jean-Christophe's review
 - added timeout to flush function
---
 commands/Kconfig  |    1 +
 commands/Makefile |    2 +-
 commands/loadxy.c |  238 +++++++++++++++++++++
 include/xymodem.h |   25 +++
 lib/Kconfig       |    3 +
 lib/Makefile      |    1 +
 lib/xymodem.c     |  597 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 7 files changed, 866 insertions(+), 1 deletion(-)
 create mode 100644 commands/loadxy.c
 create mode 100644 include/xymodem.h
 create mode 100644 lib/xymodem.c

diff --git a/commands/Kconfig b/commands/Kconfig
index 16706d3..ce04bb2 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -261,6 +261,7 @@ config CMD_LOADB
 
 config CMD_LOADY
 	select CRC16
+	select XYMODEM
 	tristate
 	prompt "loady"
 
diff --git a/commands/Makefile b/commands/Makefile
index 610be55..2be5f9c 100644
--- a/commands/Makefile
+++ b/commands/Makefile
@@ -3,7 +3,7 @@ obj-$(CONFIG_CMD_BOOTM)		+= bootm.o
 obj-$(CONFIG_CMD_UIMAGE)	+= uimage.o
 obj-$(CONFIG_CMD_LINUX16)	+= linux16.o
 obj-$(CONFIG_CMD_LOADB)		+= loadb.o xyzModem.o
-obj-$(CONFIG_CMD_LOADY)		+= loadb.o xyzModem.o
+obj-$(CONFIG_CMD_LOADY)		+= loadb.o xyzModem.o loadxy.o
 obj-$(CONFIG_CMD_LOADS)		+= loads.o
 obj-$(CONFIG_CMD_ECHO)		+= echo.o
 obj-$(CONFIG_CMD_MEMORY)	+= mem.o
diff --git a/commands/loadxy.c b/commands/loadxy.c
new file mode 100644
index 0000000..141bd7b
--- /dev/null
+++ b/commands/loadxy.c
@@ -0,0 +1,238 @@
+/**
+ * @file
+ * @brief loady and loadx  support.
+ *
+ * Provides loadx (over X-Modem) and loady(over Y-Modem) support to download
+ * images.
+ *
+ * FileName: commands/loadxy.c
+ */
+/*
+ * (C) Copyright 2012 Robert Jarzmik <robert.jarzmik at free.fr>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+/*
+ * Serial up- and download support
+ */
+#include <common.h>
+#include <command.h>
+#include <console.h>
+#include <xymodem.h>
+#include <errno.h>
+#include <getopt.h>
+#include <fcntl.h>
+#include <fs.h>
+#include <malloc.h>
+
+#define DEF_FILE	"image.bin"
+
+/**
+ * @brief returns current used console device
+ *
+ * @return console device which is registered with CONSOLE_STDIN and
+ * CONSOLE_STDOUT
+ */
+static struct console_device *get_current_console(void)
+{
+	struct console_device *cdev;
+	/*
+	 * Assumption to have BOTH CONSOLE_STDIN AND STDOUT in the
+	 * same output console
+	 */
+	for_each_console(cdev) {
+		if ((cdev->f_active & (CONSOLE_STDIN | CONSOLE_STDOUT)))
+			return cdev;
+	}
+	return NULL;
+}
+
+static int console_change_speed(struct console_device *cdev, int baudrate)
+{
+	int current_baudrate;
+
+	current_baudrate =
+		(int)simple_strtoul(dev_get_param(&cdev->class_dev,
+						  "baudrate"), NULL, 10);
+	if (baudrate && baudrate != current_baudrate) {
+		printf("## Switch baudrate from %d to %d bps and press ENTER ...\n",
+		       current_baudrate, baudrate);
+		mdelay(50);
+		cdev->setbrg(cdev, baudrate);
+		mdelay(50);
+	}
+	return current_baudrate;
+}
+
+/**
+ * @brief provide the loady(Y-Modem or Y-Modem/G) support
+ *
+ * @param argc number of arguments
+ * @param argv arguments of loady command
+ *
+ * @return success or failure
+ */
+static int do_loady(int argc, char *argv[])
+{
+	int is_ymodemg = 0, rc = 0, opt, rcode = 0;
+	int load_baudrate = 0, current_baudrate;
+	struct console_device *cdev = NULL;
+
+	while ((opt = getopt(argc, argv, "b:g")) > 0) {
+		switch (opt) {
+		case 'b':
+			load_baudrate = (int)simple_strtoul(optarg, NULL, 10);
+			break;
+		case 'g':
+			is_ymodemg = 1;
+			break;
+		default:
+			perror(argv[0]);
+			return 1;
+		}
+	}
+
+	cdev = get_current_console();
+	if (NULL == cdev) {
+		printf("%s:No console device with STDIN and STDOUT\n", argv[0]);
+		return -ENODEV;
+	}
+
+	current_baudrate = console_change_speed(cdev, load_baudrate);
+	printf("## Ready for binary (ymodem) download at %d bps...\n",
+	       load_baudrate ? load_baudrate : current_baudrate);
+
+	if (is_ymodemg)
+		rc = do_load_serial_ymodemg(cdev);
+	else
+		rc = do_load_serial_ymodem(cdev);
+
+	if (rc < 0) {
+		printf("## Binary (ymodem) download aborted (%d)\n", rc);
+		rcode = 1;
+	}
+
+	console_change_speed(cdev, current_baudrate);
+
+	return rcode;
+}
+
+/**
+ * @brief provide the loadx(X-Modem) support
+ *
+ * @param argc number of arguments
+ * @param argv arguments of loadx command
+ *
+ * @return success or failure
+ */
+static int do_loadx(int argc, char *argv[])
+{
+	ulong offset = 0;
+	int load_baudrate = 0, current_baudrate, ofd, opt, rcode = 0;
+	int open_mode = O_WRONLY;
+	char *output_file = NULL;
+	struct console_device *cdev = NULL;
+
+	while ((opt = getopt(argc, argv, "f:b:o:c")) > 0) {
+		switch (opt) {
+		case 'f':
+			output_file = optarg;
+			break;
+		case 'b':
+			load_baudrate = (int)simple_strtoul(optarg, NULL, 10);
+			break;
+		case 'o':
+			offset = (int)simple_strtoul(optarg, NULL, 10);
+			break;
+		case 'c':
+			open_mode |= O_CREAT;
+			break;
+		default:
+			perror(argv[0]);
+			return 1;
+		}
+	}
+
+	cdev = get_current_console();
+	if (NULL == cdev) {
+		printf("%s:No console device with STDIN and STDOUT\n", argv[0]);
+		return -ENODEV;
+	}
+
+	/* Load Defaults */
+	if (NULL == output_file)
+		output_file = DEF_FILE;
+
+	/* File should exist */
+	ofd = open(output_file, open_mode);
+	if (ofd < 0) {
+		perror(argv[0]);
+		return 3;
+	}
+	/* Seek to the right offset */
+	if (offset) {
+		int seek = lseek(ofd, offset, SEEK_SET);
+		if (seek != offset) {
+			close(ofd);
+			ofd = 0;
+			perror(argv[0]);
+			return 4;
+		}
+	}
+
+	current_baudrate = console_change_speed(cdev, load_baudrate);
+	printf("## Ready for binary (X-Modem) download "
+	       "to 0x%08lX offset on %s device at %d bps...\n", offset,
+	       output_file, load_baudrate);
+	rcode = do_load_serial_ymodem(cdev);
+	if (rcode < 0) {
+		printf("## Binary (kermit) download aborted (%d)\n", rcode);
+		rcode = 1;
+	}
+	console_change_speed(cdev, current_baudrate);
+
+	return rcode;
+}
+
+static const __maybe_unused char cmd_loadx_help[] =
+	"[OPTIONS]\n"
+	"  -f file   - where to download to - defaults to " DEF_FILE "\n"
+	"  -o offset - what offset to download - defaults to 0\n"
+	"  -b baud   - baudrate at which to download - defaults to "
+	"console baudrate\n"
+	"  -c        - Create file if it is not present - default disabled";
+
+#ifdef CONFIG_CMD_LOADB
+BAREBOX_CMD_START(loadx)
+	.cmd = do_loadx,
+	.usage = "Load binary file over serial line (X-Modem)",
+BAREBOX_CMD_HELP(cmd_loadx_help)
+BAREBOX_CMD_END
+#endif
+
+static const __maybe_unused char cmd_loady_help[] =
+	"[OPTIONS]\n"
+	"  -y        - use Y-Modem/G (only for lossless tty as USB)\n"
+	"  -b baud   - baudrate at which to download - defaults to "
+	"console baudrate\n";
+
+#ifdef CONFIG_CMD_LOADY
+BAREBOX_CMD_START(loady2)
+	.cmd = do_loady,
+	.usage = "Load binary file over serial line (Y-Modem or Y-Modem/G)",
+BAREBOX_CMD_HELP(cmd_loady_help)
+BAREBOX_CMD_END
+#endif
diff --git a/include/xymodem.h b/include/xymodem.h
new file mode 100644
index 0000000..917cecc
--- /dev/null
+++ b/include/xymodem.h
@@ -0,0 +1,25 @@
+/*
+ * Handles the X-Modem, Y-Modem and Y-Modem/G protocols
+ *
+ * Copyright (C) 2008 Robert Jarzmik
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef _XYMODEM_
+#define _XYMODEM_
+struct xyz_ctxt;
+struct console_device;
+
+int do_load_serial_xmodem(struct console_device *cdev, int fd);
+int do_load_serial_ymodem(struct console_device *cdev);
+int do_load_serial_ymodemg(struct console_device *cdev);
+#endif
diff --git a/lib/Kconfig b/lib/Kconfig
index 9882d2d..13ecab0 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -38,6 +38,9 @@ config BITREV
 config QSORT
 	bool
 
+config XYMODEM
+	bool
+
 source lib/gui/Kconfig
 
 endmenu
diff --git a/lib/Makefile b/lib/Makefile
index 41e6a0f..eb0af92 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -35,3 +35,4 @@ obj-$(CONFIG_BCH)	+= bch.o
 obj-$(CONFIG_BITREV)	+= bitrev.o
 obj-$(CONFIG_QSORT)	+= qsort.o
 obj-y			+= gui/
+obj-$(CONFIG_XYMODEM)	+= xymodem.o
diff --git a/lib/xymodem.c b/lib/xymodem.c
new file mode 100644
index 0000000..558f6e8
--- /dev/null
+++ b/lib/xymodem.c
@@ -0,0 +1,597 @@
+/*
+ * Handles the X-Modem, Y-Modem and Y-Modem/G protocols
+ *
+ * Copyright (C) 2008 Robert Jarzmik
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * This file provides functions to receive X-Modem or Y-Modem(/G) protocols.
+ *
+ * References:
+ *   *-Modem: http://www.techfest.com/hardware/modem/xymodem.htm
+ *            XMODEM/YMODEM PROTOCOL REFERENCE, Chuck Forsberg
+ */
+#include <common.h>
+#include <xfuncs.h>
+#include <errno.h>
+#include <crc.h>
+#include <clock.h>
+#include <console.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <fs.h>
+#include <kfifo.h>
+#include <linux/byteorder/generic.h>
+
+
+#define xy_dbg(fmt, args...)
+
+/* Values magic to the protocol */
+#define SOH 0x01
+#define STX 0x02
+#define EOT 0x04
+#define ACK 0x06
+#define BSP 0x08
+#define NAK 0x15
+#define CAN 0x18
+
+#define PROTO_XMODEM	0
+#define PROTO_YMODEM	1
+#define PROTO_YMODEM_G	2
+#define MAX_PROTOS	3
+
+#define CRC_NONE	0	/* No CRC checking */
+#define CRC_ADD8	1	/* Add of all data bytes */
+#define CRC_CRC16	2	/* CCCIT CRC16 */
+#define MAX_CRCS	3
+
+#define MAX_RETRIES		10
+#define MAX_RETRIES_WITH_CRC	5
+#define TIMEOUT_READ		(1 * SECOND)
+#define TIMEOUT_FLUSH		(1 * SECOND)
+#define MAX_CAN_BEFORE_ABORT	5
+#define INPUT_FIFO_SIZE		(4 * 1024)	/* Should always be > 1029 */
+
+enum proto_state {
+	PROTO_STATE_GET_FILENAME = 0,
+	PROTO_STATE_NEGOCIATE_CRC,
+	PROTO_STATE_RECEIVE_BODY,
+	PROTO_STATE_FINISHED_FILE,
+	PROTO_STATE_FINISHED_XFER,
+};
+
+/**
+ * struct xyz_ctxt - context of a x/y modem (g) transfer
+ *
+ * @cdev: console device to support *MODEM transfer
+ * @fifo: fifo to buffer input from serial line
+ *        This is necessary for low hardware FIFOs buffers as UARTs.
+ * @mode: protocol (XMODEM, YMODEM or YMODEM/G)
+ * @crc_mode: CRC_NONE, CRC_ADD8 or CRC_CRC16
+ * @state: protocol state (as in "state machine")
+ * @buf: buffer to store the last tranfered buffer chunk
+ * @filename : filename transmitted by sender (YMODEM* only)
+ * @fd : file descriptor of the current stored file
+ * @file_len: length declared by sender (YMODEM* only)
+ * @nb_received: number of data bytes received since session open
+ *               (this doesn't count resends)
+ * @total_SOH: number of SOH frames received (128 bytes chunks)
+ * @total_STX: number of STX frames received (1024 bytes chunks)
+ * @total_CAN: nubmer of CAN frames received (cancel frames)
+ */
+struct xyz_ctxt {
+	struct console_device *cdev;
+	struct kfifo *fifo;
+	int mode;
+	int crc_mode;
+	enum proto_state state;
+	char filename[1024];
+	int fd;
+	int file_len;
+	int nb_received;
+	int next_blk;
+	int total_SOH, total_STX, total_CAN, total_retries;
+};
+
+/**
+ * struct xy_block - one unitary block of x/y modem (g) transfer
+ *
+ * @buf: data buffer
+ * @len: length of data buffer (can only be 128 or 1024)
+ * @seq: block sequence number (as in X/Y/YG MODEM protocol)
+ */
+struct xy_block {
+	unsigned char buf[1024];
+	int len;
+	int seq;
+};
+
+/*
+ * For XMODEM/YMODEM, always try to use the CRC16 versions, called also
+ * XMODEM/CRC and YMODEM.
+ * Only fallback to additive CRC (8 bits) if sender doesn't cope with CRC16.
+ */
+static const char invite_filename_hdr[MAX_PROTOS][MAX_CRCS] = {
+	{ 0, NAK, 'C' },	/* XMODEM */
+	{ 0, NAK, 'C' },	/* YMODEM */
+	{ 0, 'G', 'G' },	/* YMODEM-G */
+};
+
+static const char invite_file_body[MAX_PROTOS][MAX_CRCS] = {
+	{ 0, NAK, 'C' },	/* XMODEM */
+	{ 0, NAK, 'C' },	/* YMODEM */
+	{ 0, 'G', 'G' },	/* YMODEM-G */
+};
+
+static const char block_ack[MAX_PROTOS][MAX_CRCS] = {
+	{ 0, ACK, ACK },	/* XMODEM */
+	{ 0, ACK, ACK },	/* YMODEM */
+	{ 0, 0, 0 },		/* YMODEM-G */
+};
+
+static const char block_nack[MAX_PROTOS][MAX_CRCS] = {
+	{ 0, NAK, NAK },	/* XMODEM */
+	{ 0, NAK, NAK },	/* YMODEM */
+	{ 0, 0, 0 },		/* YMODEM-G */
+};
+
+static int input_fifo_fill(struct console_device *cdev, struct kfifo *fifo)
+{
+	while (cdev->tstc(cdev) && kfifo_len(fifo) < INPUT_FIFO_SIZE)
+		kfifo_putc(fifo, (unsigned char)(cdev->getc(cdev)));
+	return kfifo_len(fifo);
+}
+
+/*
+ * This function is optimized to :
+ * - maximize throughput (ie. read as much as is available in lower layer fifo)
+ * - minimize latencies (no delay or wait timeout if data available)
+ * - have a timeout
+ * This is why standard getc() is not used, and input_fifo_fill() exists.
+ */
+static int xy_gets(struct console_device *cdev, struct kfifo *fifo,
+		      unsigned char *buf, int len, uint64_t timeout)
+{
+	int i, rc;
+	uint64_t start = get_time_ns();
+
+	for (i = 0, rc = 0; rc >= 0 && i < len; ) {
+		if (is_timeout(start, timeout)) {
+			rc = -ETIMEDOUT;
+			continue;
+		}
+		if (input_fifo_fill(cdev, fifo))
+			kfifo_getc(fifo, &buf[i++]);
+	}
+
+	return rc < 0 ? rc : i;
+}
+
+static void xy_putc(struct console_device *cdev, unsigned char c)
+{
+	cdev->putc(cdev, c);
+}
+
+static void xy_flush(struct console_device *cdev, struct kfifo *fifo)
+{
+	uint64_t start;
+
+	start = get_time_ns();
+	while (cdev->tstc(cdev) &&
+	       !is_timeout(start, TIMEOUT_FLUSH))
+		cdev->getc(cdev);
+	mdelay(250);
+	while (cdev->tstc(cdev) &&
+	       !is_timeout(start, TIMEOUT_FLUSH))
+		cdev->getc(cdev);
+	kfifo_reset(fifo);
+}
+
+static int is_xmodem(struct xyz_ctxt *proto)
+{
+	return proto->mode == PROTO_XMODEM;
+}
+
+static void xy_block_ack(struct xyz_ctxt *proto)
+{
+	unsigned char c = block_ack[proto->mode][proto->crc_mode];
+
+	if (c)
+		xy_putc(proto->cdev, c);
+}
+
+static void xy_block_nack(struct xyz_ctxt *proto)
+{
+	unsigned char c = block_nack[proto->mode][proto->crc_mode];
+
+	if (c)
+		xy_putc(proto->cdev, c);
+	proto->total_retries++;
+}
+
+static int check_crc(unsigned char *buf, int len, int crc, int crc_mode)
+{
+	unsigned char crc8 = 0;
+	uint16_t crc16;
+	int i;
+
+	switch (crc_mode) {
+	case CRC_ADD8:
+		for (i = 0; i < len; i++)
+			crc8 += buf[i];
+		return crc8 == crc ? 0 : -EBADMSG;
+	case CRC_CRC16:
+		crc16 = cyg_crc16(buf, len);
+		xy_dbg("crc16: received = %x, calculated=%x\n", crc, crc16);
+		return crc16 == crc ? 0 : -EBADMSG;
+	case CRC_NONE:
+		return 0;
+	default:
+		return -EBADMSG;
+	}
+}
+
+/**
+ * xy_read_block - read a X-Modem or Y-Modem(G) block
+ * @proto: protocol control structure
+ * @blk: block read
+ * @timeout: maximal time to get data
+ *
+ * This is the pivotal function for block receptions. It attempts to receive one
+ * block, ie. one 128 bytes or one 1024 bytes block.  The received data can also
+ * be an end of transmission, or a cancel.
+ *
+ * Returns :
+ *  >0           : size of the received block
+ *  0            : last block, ie. end of transmission, ie. EOT
+ * -EBADMSG      : malformed message (ie. sequence bi-bytes are not
+ *                 complementary), or CRC check error
+ * -EILSEQ       : block sequence number error wrt previously received block
+ * -ETIMEDOUT    : block not received before timeout passed
+ * -ECONNABORTED : transfer aborted by sender, ie. CAN
+ */
+static ssize_t xy_read_block(struct xyz_ctxt *proto, struct xy_block *blk,
+	uint64_t timeout)
+{
+	ssize_t rc, data_len = 0;
+	unsigned char hdr, seqs[2], crcs[2];
+	int crc = 0;
+	bool hdr_found = 0;
+	uint64_t start = get_time_ns();
+
+	while (!hdr_found) {
+		rc = xy_gets(proto->cdev, proto->fifo, &hdr, 1, timeout);
+		xy_dbg("read 0x%x(%c) -> %d\n", hdr, hdr, rc);
+		if (rc < 0)
+			goto out;
+		if (is_timeout(start, timeout))
+			goto timeout;
+		switch (hdr) {
+		case SOH:
+			data_len = 128;
+			hdr_found = 1;
+			proto->total_SOH++;
+			break;
+		case STX:
+			data_len = 1024;
+			hdr_found = 1;
+			proto->total_STX++;
+			break;
+		case CAN:
+			rc = -ECONNABORTED;
+			if (proto->total_CAN++ > MAX_CAN_BEFORE_ABORT)
+				goto out;
+			break;
+		case EOT:
+			rc = 0;
+			blk->len = 0;
+			goto out;
+		default:
+			break;
+		}
+	}
+
+	blk->seq = 0;
+	rc = xy_gets(proto->cdev, proto->fifo, seqs, 2, timeout);
+	if (rc < 0)
+		goto out;
+	blk->seq = seqs[0];
+	if (255 - seqs[0] != seqs[1])
+		return -EBADMSG;
+
+	rc = xy_gets(proto->cdev, proto->fifo, blk->buf, data_len, timeout);
+	if (rc < 0)
+		goto out;
+	blk->len = rc;
+
+	switch (proto->crc_mode) {
+	case CRC_ADD8:
+		rc = xy_gets(proto->cdev, proto->fifo, crcs, 1, timeout);
+		crc = crcs[0];
+		break;
+	case CRC_CRC16:
+		rc = xy_gets(proto->cdev, proto->fifo, crcs, 2, timeout);
+		crc = (crcs[0] << 8) + crcs[1];
+		break;
+	case CRC_NONE:
+		rc = 0;
+		break;
+	}
+	if (rc < 0)
+		goto out;
+
+	rc = check_crc(blk->buf, data_len, crc, proto->crc_mode);
+	if (rc < 0)
+		goto out;
+	return data_len;
+timeout:
+	return -ETIMEDOUT;
+out:
+	return rc;
+}
+
+static int check_blk_seq(struct xyz_ctxt *proto, struct xy_block *blk,
+	int read_rc)
+{
+	if (blk->seq == ((proto->next_blk - 1) % 256))
+		return -EALREADY;
+	if (blk->seq != proto->next_blk)
+		return -EILSEQ;
+	return read_rc;
+}
+
+static int parse_first_block(struct xyz_ctxt *proto, struct xy_block *blk)
+{
+	int filename_len;
+	char *str_num;
+
+	filename_len = strlen(blk->buf);
+	if (filename_len > blk->len)
+		return -EINVAL;
+	strlcpy(proto->filename, blk->buf, sizeof(proto->filename));
+	str_num = blk->buf + filename_len + 1;
+	strsep(&str_num, " ");
+	proto->file_len = simple_strtoul(blk->buf + filename_len + 1, NULL, 10);
+	return 1;
+}
+
+static int xy_get_file_header(struct xyz_ctxt *proto)
+{
+	struct xy_block blk;
+	int tries, rc = 0;
+
+	memset(&blk, 0, sizeof(blk));
+	proto->state = PROTO_STATE_GET_FILENAME;
+	proto->crc_mode = CRC_CRC16;
+	for (tries = 0; tries < MAX_RETRIES; tries++) {
+		xy_putc(proto->cdev,
+			   invite_filename_hdr[proto->mode][proto->crc_mode]);
+		rc = xy_read_block(proto, &blk, 3 * SECOND);
+		xy_dbg("read block returned %d\n", rc);
+		switch (rc) {
+		case -ECONNABORTED:
+			goto fail;
+		case -ETIMEDOUT:
+		case -EBADMSG:
+			if (proto->mode != PROTO_YMODEM_G)
+				xy_flush(proto->cdev, proto->fifo);
+			break;
+		case -EALREADY:
+		default:
+			proto->next_blk = 1;
+			xy_block_ack(proto);
+			proto->state = PROTO_STATE_NEGOCIATE_CRC;
+			rc = parse_first_block(proto, &blk);
+			return rc;
+		}
+
+		if (rc < 0 && tries++ >= MAX_RETRIES_WITH_CRC)
+			proto->crc_mode = CRC_ADD8;
+	}
+	rc = -ETIMEDOUT;
+fail:
+	proto->total_retries += tries;
+	return rc;
+}
+
+static int xy_await_header(struct xyz_ctxt *proto)
+{
+	int rc;
+
+	rc = xy_get_file_header(proto);
+	if (rc < 0)
+		return rc;
+	proto->state = PROTO_STATE_NEGOCIATE_CRC;
+	xy_dbg("header received, filename=%s, file length=%d\n",
+	       proto->filename, proto->file_len);
+	if (proto->filename[0])
+		proto->fd = open(proto->filename, O_WRONLY | O_CREAT);
+	else
+		proto->state = PROTO_STATE_FINISHED_XFER;
+	proto->nb_received = 0;
+	return rc;
+}
+
+static void xy_finish_file(struct xyz_ctxt *proto)
+{
+	close(proto->fd);
+	proto->fd = 0;
+	proto->state = PROTO_STATE_FINISHED_FILE;
+}
+
+static struct xyz_ctxt *xymodem_open(struct console_device *cdev,
+				     int proto_mode, int xmodem_fd)
+{
+	struct xyz_ctxt *proto;
+
+	proto = xzalloc(sizeof(struct xyz_ctxt));
+	proto->fifo = kfifo_alloc(INPUT_FIFO_SIZE);
+	proto->mode = proto_mode;
+	proto->cdev = cdev;
+	proto->crc_mode = CRC_CRC16;
+
+	if (is_xmodem(proto)) {
+		proto->fd = xmodem_fd;
+		proto->state = PROTO_STATE_NEGOCIATE_CRC;
+	} else {
+		proto->state = PROTO_STATE_GET_FILENAME;
+	}
+	xy_flush(proto->cdev, proto->fifo);
+	return proto;
+}
+
+static int xymodem_handle(struct xyz_ctxt *proto)
+{
+	int rc = 0, xfer_max, len = 0, again = 1, remain;
+	int crc_tries = 0, same_blk_retries = 0;
+	unsigned char invite;
+	struct xy_block blk;
+
+	while (again) {
+		switch (proto->state) {
+		case PROTO_STATE_GET_FILENAME:
+			crc_tries = 0;
+			rc = xy_await_header(proto);
+			if (rc < 0)
+				goto fail;
+			continue;
+		case PROTO_STATE_FINISHED_FILE:
+			if (is_xmodem(proto))
+				proto->state = PROTO_STATE_FINISHED_XFER;
+			else
+				proto->state = PROTO_STATE_GET_FILENAME;
+			xy_putc(proto->cdev, ACK);
+			continue;
+		case PROTO_STATE_FINISHED_XFER:
+			again = 0;
+			rc = 0;
+			goto out;
+		case PROTO_STATE_NEGOCIATE_CRC:
+			invite = invite_file_body[proto->mode][proto->crc_mode];
+			proto->next_blk = 1;
+			if (crc_tries++ > MAX_RETRIES_WITH_CRC)
+				proto->crc_mode = CRC_ADD8;
+			xy_putc(proto->cdev, invite);
+			/* Fall through */
+		case PROTO_STATE_RECEIVE_BODY:
+			rc = xy_read_block(proto, &blk, 3 * SECOND);
+			if (rc > 0) {
+				rc = check_blk_seq(proto, &blk, rc);
+				proto->state = PROTO_STATE_RECEIVE_BODY;
+			}
+			break;
+		}
+
+		if (proto->state != PROTO_STATE_RECEIVE_BODY)
+			continue;
+
+		switch (rc) {
+		case -ECONNABORTED:
+			goto fail;
+		case -ETIMEDOUT:
+			if (proto->mode == PROTO_YMODEM_G)
+				goto fail;
+			xy_flush(proto->cdev, proto->fifo);
+			xy_block_nack(proto);
+			break;
+		case -EBADMSG:
+		case -EILSEQ:
+			if (proto->mode == PROTO_YMODEM_G)
+				goto fail;
+			xy_flush(proto->cdev, proto->fifo);
+			xy_block_nack(proto);
+			break;
+		case -EALREADY:
+			xy_block_ack(proto);
+			break;
+		case 0:
+			xy_finish_file(proto);
+			break;
+		default:
+			remain = proto->file_len - proto->nb_received;
+			if (is_xmodem(proto))
+				xfer_max = blk.len;
+			else
+				xfer_max = min(blk.len, remain);
+			rc = write(proto->fd, blk.buf, xfer_max);
+			proto->next_blk = ((blk.seq + 1) % 256);
+			proto->nb_received += rc;
+			len += rc;
+			xy_block_ack(proto);
+			break;
+		}
+		if (rc < 0)
+			same_blk_retries++;
+		else
+			same_blk_retries = 0;
+		if (same_blk_retries > MAX_RETRIES)
+			goto fail;
+	}
+out:
+	return rc;
+fail:
+	if (proto->fd)
+		close(proto->fd);
+	return rc;
+}
+
+static void xymodem_close(struct xyz_ctxt *proto)
+{
+	xy_flush(proto->cdev, proto->fifo);
+	printf("\nxyModem - %d(SOH)/%d(STX)/%d(CAN) packets,"
+	       " %d retries\n",
+	       proto->total_SOH, proto->total_STX,
+	       proto->total_CAN, proto->total_retries);
+	kfifo_free(proto->fifo);
+}
+
+int do_load_serial_xmodem(struct console_device *cdev, int fd)
+{
+	struct xyz_ctxt *proto;
+	int rc;
+
+	proto = xymodem_open(cdev, PROTO_XMODEM, fd);
+	do {
+		rc = xymodem_handle(proto);
+	} while (rc > 0);
+	xymodem_close(proto);
+	return rc < 0 ? rc : 0;
+}
+EXPORT_SYMBOL(do_load_serial_xmodem);
+
+int do_load_serial_ymodem(struct console_device *cdev)
+{
+	struct xyz_ctxt *proto;
+	int rc;
+
+	proto = xymodem_open(cdev, PROTO_YMODEM, 0);
+	do {
+		rc = xymodem_handle(proto);
+	} while (rc > 0);
+	xymodem_close(proto);
+	return rc < 0 ? rc : 0;
+}
+EXPORT_SYMBOL(do_load_serial_ymodem);
+
+int do_load_serial_ymodemg(struct console_device *cdev)
+{
+	struct xyz_ctxt *proto;
+	int rc;
+
+	proto = xymodem_open(cdev, PROTO_YMODEM_G, 0);
+	do {
+		rc = xymodem_handle(proto);
+	} while (rc > 0);
+	xymodem_close(proto);
+	return rc < 0 ? rc : 0;
+}
+EXPORT_SYMBOL(do_load_serial_ymodemg);
-- 
1.7.10



From robert.jarzmik at free.fr  Thu Nov  8 16:16:41 2012
From: robert.jarzmik at free.fr (Robert Jarzmik)
Date: Thu,  8 Nov 2012 22:16:41 +0100
Subject: [PATCH v3 2/2] commands: remove old Y-Modem implementation
In-Reply-To: <1352409401-3333-1-git-send-email-robert.jarzmik@free.fr>
References: <1352409401-3333-1-git-send-email-robert.jarzmik@free.fr>
Message-ID: <1352409401-3333-2-git-send-email-robert.jarzmik@free.fr>

As a new implementation of Y-Modem protocol is available,
switch from old implementation to the new one :
 - remove old xyzModem* files
 - remove old command loady2
 - rename command loady2 to loady

Signed-off-by: Robert Jarzmik <robert.jarzmik at free.fr>
Tested-by: Antony Pavlov <antonynpavlov at gmail.com>

---
Since V2:
 - Jean-Christophe's review
 - added "-t" options to loadx and loady to select console
---
 commands/Makefile   |    4 +-
 commands/loadb.c    |  102 +------
 commands/loads.c    |    1 -
 commands/loadxy.c   |   69 +++--
 commands/xyzModem.c |  785 ---------------------------------------------------
 include/xyzModem.h  |  109 -------
 6 files changed, 63 insertions(+), 1007 deletions(-)
 delete mode 100644 commands/xyzModem.c
 delete mode 100644 include/xyzModem.h

diff --git a/commands/Makefile b/commands/Makefile
index 2be5f9c..c5539a7 100644
--- a/commands/Makefile
+++ b/commands/Makefile
@@ -2,8 +2,8 @@ obj-$(CONFIG_STDDEV)		+= stddev.o
 obj-$(CONFIG_CMD_BOOTM)		+= bootm.o
 obj-$(CONFIG_CMD_UIMAGE)	+= uimage.o
 obj-$(CONFIG_CMD_LINUX16)	+= linux16.o
-obj-$(CONFIG_CMD_LOADB)		+= loadb.o xyzModem.o
-obj-$(CONFIG_CMD_LOADY)		+= loadb.o xyzModem.o loadxy.o
+obj-$(CONFIG_CMD_LOADB)		+= loadb.o
+obj-$(CONFIG_CMD_LOADY)		+= loadxy.o
 obj-$(CONFIG_CMD_LOADS)		+= loads.o
 obj-$(CONFIG_CMD_ECHO)		+= echo.o
 obj-$(CONFIG_CMD_MEMORY)	+= mem.o
diff --git a/commands/loadb.c b/commands/loadb.c
index 898b9e3..a2f3315 100644
--- a/commands/loadb.c
+++ b/commands/loadb.c
@@ -31,7 +31,6 @@
  */
 #include <common.h>
 #include <command.h>
-#include <xyzModem.h>
 #include <console.h>
 #include <errno.h>
 #include <environment.h>
@@ -59,8 +58,6 @@
 
 static int ofd;			/* output file descriptor */
 
-#ifdef CONFIG_CMD_LOADB
-
 /* Size of my buffer to write to o/p file */
 #define MAX_WRITE_BUFFER 4096	/* Write size to o/p file */
 static char *write_buffer;	/* buffer for finalized data to write */
@@ -593,66 +590,6 @@ err_quit:
 	return size;
 }
 
-#endif				/* CONFIG_CMD_LOADB */
-
-#ifdef CONFIG_CMD_LOADY
-/**
- * @brief getcxmodem
- *
- * @return if character avaiable, return the same, else return -1
- */
-static int getcxmodem(void)
-{
-	if (tstc())
-		return (getc());
-	return -1;
-}
-
-/**
- * @brief  LoadY over ymodem protocol
- *
- * @return download size
- */
-static ulong load_serial_ymodem(void)
-{
-	int size;
-	char buf[32];
-	int err;
-	int res, wr;
-	connection_info_t info;
-	char ymodemBuf[1024];
-	ulong addr = 0;
-
-	size = 0;
-	info.mode = xyzModem_ymodem;
-	res = xyzModem_stream_open(&info, &err);
-	if (!res) {
-		while ((res = xyzModem_stream_read(ymodemBuf, 1024, &err)) >
-				0) {
-			size += res;
-			addr += res;
-			wr = write(ofd, ymodemBuf, res);
-			if (res != wr) {
-				perror("ymodem");
-				break;
-			}
-
-		}
-	} else {
-		printf("%s\n", xyzModem_error(err));
-	}
-
-	xyzModem_stream_close(&err);
-	xyzModem_stream_terminate(false, &getcxmodem);
-
-	printf("## Total Size      = 0x%08x = %d Bytes\n", size, size);
-	sprintf(buf, "%X", size);
-	setenv("filesize", buf);
-
-	return res;
-}
-#endif
-
 /**
  * @brief returns current used console device
  *
@@ -754,27 +691,16 @@ static int do_load_serial_bin(int argc, char *argv[])
 				break;
 		}
 	}
-#ifdef CONFIG_CMD_LOADY
-	if (strcmp(argv[0], "loady") == 0) {
-		printf("## Ready for binary (ymodem) download "
-		       "to 0x%08lX offset on %s device at %d bps...\n", offset,
-		       output_file, load_baudrate);
-		addr = load_serial_ymodem();
-	}
-#endif
-#ifdef CONFIG_CMD_LOADB
-	if (strcmp(argv[0], "loadb") == 0) {
-
-		printf("## Ready for binary (kermit) download "
-		       "to 0x%08lX offset on %s device at %d bps...\n", offset,
-		       output_file, load_baudrate);
-		addr = load_serial_bin();
-		if (addr == 0) {
-			printf("## Binary (kermit) download aborted\n");
-			rcode = 1;
-		}
+
+	printf("## Ready for binary (kermit) download "
+	       "to 0x%08lX offset on %s device at %d bps...\n", offset,
+	       output_file, load_baudrate);
+	addr = load_serial_bin();
+	if (addr == 0) {
+		printf("## Binary (kermit) download aborted\n");
+		rcode = 1;
 	}
-#endif
+
 	if (load_baudrate != current_baudrate) {
 		printf("## Switch baudrate to %d bps and press ESC ...\n",
 		       current_baudrate);
@@ -799,18 +725,8 @@ static const __maybe_unused char cmd_loadb_help[] =
     "  -b baud   - baudrate at which to download - defaults to "
     "console baudrate\n"
     "  -c        - Create file if it is not present - default disabled";
-#ifdef CONFIG_CMD_LOADB
 BAREBOX_CMD_START(loadb)
 	.cmd = do_load_serial_bin,
 	.usage = "Load binary file over serial line (kermit mode)",
 	BAREBOX_CMD_HELP(cmd_loadb_help)
 BAREBOX_CMD_END
-#endif
-#ifdef CONFIG_CMD_LOADY
-BAREBOX_CMD_START(loady)
-	.cmd = do_load_serial_bin,
-	.usage = "Load binary file over serial line (ymodem mode)",
-	BAREBOX_CMD_HELP(cmd_loadb_help)
-BAREBOX_CMD_END
-#endif
-
diff --git a/commands/loads.c b/commands/loads.c
index 7f4c647..bfc465b 100644
--- a/commands/loads.c
+++ b/commands/loads.c
@@ -25,7 +25,6 @@
 #include <environment.h>
 #include <s_record.h>
 #include <net.h>
-#include <xyzModem.h>
 
 static ulong load_serial(ulong offset);
 static int read_record(char *buf, ulong len);
diff --git a/commands/loadxy.c b/commands/loadxy.c
index 141bd7b..52ecdca 100644
--- a/commands/loadxy.c
+++ b/commands/loadxy.c
@@ -77,6 +77,28 @@ static int console_change_speed(struct console_device *cdev, int baudrate)
 	return current_baudrate;
 }
 
+static struct console_device *get_named_console(const char *cname)
+{
+	struct console_device *cdev;
+	const char *target;
+
+	/*
+	 * Assumption to have BOTH CONSOLE_STDIN AND STDOUT in the
+	 * same output console
+	 */
+	for_each_console(cdev) {
+		target = dev_id(&cdev->class_dev);
+		if (strlen(target) != strlen(cname))
+			continue;
+		printf("RJK: looking for %s in console name %s\n",
+		       cname, target);
+		if ((cdev->f_active & (CONSOLE_STDIN | CONSOLE_STDOUT))
+		    && !strcmp(cname, target))
+			return cdev;
+	}
+	return NULL;
+}
+
 /**
  * @brief provide the loady(Y-Modem or Y-Modem/G) support
  *
@@ -89,9 +111,10 @@ static int do_loady(int argc, char *argv[])
 {
 	int is_ymodemg = 0, rc = 0, opt, rcode = 0;
 	int load_baudrate = 0, current_baudrate;
+	char *cname = NULL;
 	struct console_device *cdev = NULL;
 
-	while ((opt = getopt(argc, argv, "b:g")) > 0) {
+	while ((opt = getopt(argc, argv, "b:t:g")) > 0) {
 		switch (opt) {
 		case 'b':
 			load_baudrate = (int)simple_strtoul(optarg, NULL, 10);
@@ -99,15 +122,22 @@ static int do_loady(int argc, char *argv[])
 		case 'g':
 			is_ymodemg = 1;
 			break;
+		case 't':
+			cname = optarg;
+			break;
 		default:
 			perror(argv[0]);
 			return 1;
 		}
 	}
 
-	cdev = get_current_console();
-	if (NULL == cdev) {
-		printf("%s:No console device with STDIN and STDOUT\n", argv[0]);
+	if (cname)
+		cdev = get_named_console(cname);
+	else
+		cdev = get_current_console();
+	if (!cdev) {
+		printf("%s:No console device %s with STDIN and STDOUT\n",
+		       argv[0], cname ? cname : "default");
 		return -ENODEV;
 	}
 
@@ -143,7 +173,7 @@ static int do_loadx(int argc, char *argv[])
 	ulong offset = 0;
 	int load_baudrate = 0, current_baudrate, ofd, opt, rcode = 0;
 	int open_mode = O_WRONLY;
-	char *output_file = NULL;
+	char *output_file = NULL, *cname = NULL;
 	struct console_device *cdev = NULL;
 
 	while ((opt = getopt(argc, argv, "f:b:o:c")) > 0) {
@@ -160,20 +190,27 @@ static int do_loadx(int argc, char *argv[])
 		case 'c':
 			open_mode |= O_CREAT;
 			break;
+		case 't':
+			cname = optarg;
+			break;
 		default:
 			perror(argv[0]);
 			return 1;
 		}
 	}
 
-	cdev = get_current_console();
-	if (NULL == cdev) {
-		printf("%s:No console device with STDIN and STDOUT\n", argv[0]);
+	if (cname)
+		cdev = get_named_console(cname);
+	else
+		cdev = get_current_console();
+	if (!cdev) {
+		printf("%s:No console device %s with STDIN and STDOUT\n",
+		       argv[0], cname ? cname : "default");
 		return -ENODEV;
 	}
 
 	/* Load Defaults */
-	if (NULL == output_file)
+	if (!output_file)
 		output_file = DEF_FILE;
 
 	/* File should exist */
@@ -211,26 +248,24 @@ static const __maybe_unused char cmd_loadx_help[] =
 	"[OPTIONS]\n"
 	"  -f file   - where to download to - defaults to " DEF_FILE "\n"
 	"  -o offset - what offset to download - defaults to 0\n"
-	"  -b baud   - baudrate at which to download - defaults to "
-	"console baudrate\n"
+	"  -t name   - console device name to use - defaults to current console\n"
+	"  -b baud   - baudrate at which to download - defaults to console baudrate\n"
 	"  -c        - Create file if it is not present - default disabled";
 
-#ifdef CONFIG_CMD_LOADB
+#ifdef CONFIG_CMD_LOADY
 BAREBOX_CMD_START(loadx)
 	.cmd = do_loadx,
 	.usage = "Load binary file over serial line (X-Modem)",
 BAREBOX_CMD_HELP(cmd_loadx_help)
 BAREBOX_CMD_END
-#endif
 
 static const __maybe_unused char cmd_loady_help[] =
 	"[OPTIONS]\n"
 	"  -y        - use Y-Modem/G (only for lossless tty as USB)\n"
-	"  -b baud   - baudrate at which to download - defaults to "
-	"console baudrate\n";
+	"  -t name   - console device name to use - defaults to current console\n"
+	"  -b baud   - baudrate at which to download - defaults to console baudrate\n";
 
-#ifdef CONFIG_CMD_LOADY
-BAREBOX_CMD_START(loady2)
+BAREBOX_CMD_START(loady)
 	.cmd = do_loady,
 	.usage = "Load binary file over serial line (Y-Modem or Y-Modem/G)",
 BAREBOX_CMD_HELP(cmd_loady_help)
diff --git a/commands/xyzModem.c b/commands/xyzModem.c
deleted file mode 100644
index 71d7d68..0000000
--- a/commands/xyzModem.c
+++ /dev/null
@@ -1,785 +0,0 @@
-/**
- * @file
- * @brief RedBoot stream handler for xyzModem protocol
- *
- * FileName: commands/xyzModem.c
- * Originally from u-boot xyzModem.c
- */
-/*
- * 2008 - Nishanth Menon <x0nishan at ti.com>
- * Modified for sparse and checkpatch.pl compliance
- */
-/*
- *==========================================================================
- *
- *      xyzModem.c
- *
- *      RedBoot stream handler for xyzModem protocol
- *
- *==========================================================================
- *####ECOSGPLCOPYRIGHTBEGIN####
- * -------------------------------------------
- * This file is part of eCos, the Embedded Configurable Operating System.
- * Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
- * Copyright (C) 2002 Gary Thomas
- *
- * eCos is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 or (at your option) any later version.
- *
- * eCos is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with eCos; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * As a special exception, if other files instantiate templates or use macros
- * or inline functions from this file, or you compile this file and link it
- * with other works to produce a work based on this file, this file does not
- * by itself cause the resulting work to be covered by the GNU General Public
- * License. However the source code for this file must still be made available
- * in accordance with section (3) of the GNU General Public License.
- *
- * This exception does not invalidate any other reasons why a work based on
- * this file might be covered by the GNU General Public License.
- *
- * Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
- * at http: *sources.redhat.com/ecos/ecos-license/
- * -------------------------------------------
- *####ECOSGPLCOPYRIGHTEND####
- *==========================================================================
- *#####DESCRIPTIONBEGIN####
- *
- * Author(s):    gthomas
- * Contributors: gthomas, tsmith, Yoshinori Sato
- * Date:         2000-07-14
- * Purpose:
- * Description:
- *
- * This code is part of RedBoot (tm).
- *
- *####DESCRIPTIONEND####
- *
- *==========================================================================
- */
-#include <common.h>
-#include <xyzModem.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <console.h>
-#include <crc.h>
-#include <linux/ctype.h>
-
-/* Assumption - run xyzModem protocol over the console port */
-
-/* Values magic to the protocol */
-#define SOH 0x01
-#define STX 0x02
-#define EOT 0x04
-#define ACK 0x06
-#define BSP 0x08
-#define NAK 0x15
-#define CAN 0x18
-#define EOF 0x1A		/* ^Z for DOS officionados */
-
-#define USE_YMODEM_LENGTH
-
-/* Data & state local to the protocol */
-static struct {
-#ifdef REDBOOT
-	hal_virtual_comm_table_t *__chan;
-#else
-	int *__chan;
-#endif
-	unsigned char pkt[1024], *bufp;
-	unsigned char blk, cblk, crc1, crc2;
-	unsigned char next_blk;	/* Expected block */
-	int len, mode, total_retries;
-	int total_SOH, total_STX, total_CAN;
-	bool crc_mode, at_eof, tx_ack;
-#ifdef USE_YMODEM_LENGTH
-	unsigned long file_length, read_length;
-#endif
-} xyz;
-
-#define xyzModem_CHAR_TIMEOUT            2000	/* 2 seconds */
-#define xyzModem_MAX_RETRIES             20
-#define xyzModem_MAX_RETRIES_WITH_CRC    10
-/* Wait for 3 CAN before quitting */
-#define xyzModem_CAN_COUNT                3
-
-#ifndef REDBOOT			/*SB */
-typedef int cyg_int32;
-static int CYGACC_COMM_IF_GETC_TIMEOUT(char chan, char *c)
-{
-#define DELAY 20
-	unsigned long counter = 0;
-	while (!tstc() && (counter < xyzModem_CHAR_TIMEOUT * 1000 / DELAY)) {
-		udelay(DELAY);
-		counter++;
-	}
-	if (tstc()) {
-		*c = getc();
-		return 1;
-	}
-	return 0;
-}
-
-static void CYGACC_COMM_IF_PUTC(char x, char y)
-{
-	console_putc(CONSOLE_STDOUT, y);
-}
-
-/* Validate a hex character */
-static inline bool _is_hex(char c)
-{
-	return (((c >= '0') && (c <= '9')) ||
-		((c >= 'A') && (c <= 'F')) || ((c >= 'a') && (c <= 'f')));
-}
-
-/* Convert a single hex nibble */
-static inline int _from_hex(char c)
-{
-	int ret = 0;
-
-	if ((c >= '0') && (c <= '9'))
-		ret = (c - '0');
-	else if ((c >= 'a') && (c <= 'f'))
-		ret = (c - 'a' + 0x0a);
-	else if ((c >= 'A') && (c <= 'F'))
-		ret = (c - 'A' + 0x0A);
-
-	return ret;
-}
-
-/* Parse (scan) a number */
-static bool parse_num(char *s, unsigned long *val, char **es, char *delim)
-{
-	bool first = true;
-	int radix = 10;
-	char c;
-	unsigned long result = 0;
-	int digit = 0;
-
-	while (*s == ' ')
-		s++;
-	while (*s) {
-		if (first && (s[0] == '0') && (tolower(s[1]) == 'x')) {
-			radix = 16;
-			s += 2;
-		}
-		first = false;
-		c = *s++;
-		if (_is_hex(c))
-			digit = _from_hex(c);
-		if (_is_hex(c) && (digit < radix)) {
-			/* Valid digit */
-#ifdef CYGPKG_HAL_MIPS
-			/* FIXME: tx49 compiler generates 0x2539018 for
-			 * MUL which isn't any good. */
-			if (16 == radix)
-				result = result << 4;
-			else
-				result = 10 * result;
-			result += digit;
-#else
-			result = (result * radix) + digit;
-#endif
-		} else {
-			if (delim != (char *)0) {
-				/* See if this character is one of the
-				 * delimiters */
-				char *dp = delim;
-				while (*dp && (c != *dp))
-					dp++;
-				if (*dp)
-					break;	/* Found a good delimiter */
-			}
-			return false;	/* Malformatted number */
-		}
-	}
-	*val = result;
-	if (es != (char **)0)
-		*es = s;
-	return true;
-}
-
-#endif
-
-#define USE_SPRINTF
-#ifdef DEBUG
-#ifndef USE_SPRINTF
-/*
- * Note: this debug setup only works if the target platform has two serial ports
- * available so that the other one (currently only port 1) can be used for debug
- * messages.
- */
-static int zm_dprintf(char *fmt, ...)
-{
-	int cur_console;
-	va_list args;
-
-	va_start(args, fmt);
-#ifdef REDBOOT
-	cur_console =
-	    CYGACC_CALL_IF_SET_CONSOLE_COMM
-	    (CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT);
-	CYGACC_CALL_IF_SET_CONSOLE_COMM(1);
-#endif
-	diag_vprintf(fmt, args);
-#ifdef REDBOOT
-	CYGACC_CALL_IF_SET_CONSOLE_COMM(cur_console);
-#endif
-}
-
-static void zm_flush(void)
-{
-}
-
-#else
-/*
- * Note: this debug setup works by storing the strings in a fixed buffer
- */
-#define FINAL
-#ifdef FINAL
-static char *zm_out = (char *)0x00380000;
-static char *zm_out_start = (char *)0x00380000;
-#else
-static char zm_buf[8192];
-static char *zm_out = zm_buf;
-static char *zm_out_start = zm_buf;
-
-#endif
-static int zm_dprintf(char *fmt, ...)
-{
-	int len;
-	va_list args;
-
-	va_start(args, fmt);
-	len = diag_vsprintf(zm_out, fmt, args);
-	zm_out += len;
-	return len;
-}
-
-static void zm_flush(void)
-{
-#ifdef REDBOOT
-	char *p = zm_out_start;
-	while (*p)
-		mon_write_char(*p++);
-#endif
-	zm_out = zm_out_start;
-}
-#endif
-
-static void zm_dump_buf(void *buf, int len)
-{
-#ifdef REDBOOT
-	diag_vdump_buf_with_offset(zm_dprintf, buf, len, 0);
-#else
-
-#endif
-}
-
-static unsigned char zm_buf[2048];
-static unsigned char *zm_bp;
-
-static void zm_new(void)
-{
-	zm_bp = zm_buf;
-}
-
-static void zm_save(unsigned char c)
-{
-	*zm_bp++ = c;
-}
-
-static void zm_dump(int line)
-{
-	zm_dprintf("Packet at line: %d\n", line);
-	zm_dump_buf(zm_buf, zm_bp - zm_buf);
-}
-
-#define ZM_DEBUG(x) x
-#else
-#define ZM_DEBUG(x)
-#endif
-
-/* Wait for the line to go idle */
-static void xyzModem_flush(void)
-{
-	int res;
-	char c;
-	while (true) {
-		res = CYGACC_COMM_IF_GETC_TIMEOUT(*xyz.__chan, &c);
-		if (!res)
-			return;
-	}
-}
-
-static int xyzModem_get_hdr(void)
-{
-	char c;
-	int res;
-	bool hdr_found = false;
-	int i, can_total, hdr_chars;
-	unsigned short cksum;
-
-	ZM_DEBUG(zm_new());
-	/* Find the start of a header */
-	can_total = 0;
-	hdr_chars = 0;
-
-	if (xyz.tx_ack) {
-		CYGACC_COMM_IF_PUTC(*xyz.__chan, ACK);
-		xyz.tx_ack = false;
-	}
-	while (!hdr_found) {
-		res = CYGACC_COMM_IF_GETC_TIMEOUT(*xyz.__chan, &c);
-		ZM_DEBUG(zm_save(c));
-		if (res) {
-			hdr_chars++;
-			switch (c) {
-			case SOH:
-				xyz.total_SOH++;
-			case STX:
-				if (c == STX)
-					xyz.total_STX++;
-				hdr_found = true;
-				break;
-			case CAN:
-				xyz.total_CAN++;
-				ZM_DEBUG(zm_dump(__LINE__));
-				if (++can_total == xyzModem_CAN_COUNT) {
-					return xyzModem_cancel;
-				} else {
-					/* Wait for multiple CAN to avoid
-					 * early quits */
-					break;
-				}
-			case EOT:
-				/* EOT only supported if no noise */
-				if (hdr_chars == 1) {
-					CYGACC_COMM_IF_PUTC(*xyz.__chan, ACK);
-					ZM_DEBUG(zm_dprintf
-						 ("ACK on EOT #%d\n",
-						  __LINE__));
-					ZM_DEBUG(zm_dump(__LINE__));
-					return xyzModem_eof;
-				}
-			default:
-				/* Ignore, waiting for start of header */
-				;
-			}
-		} else {
-			/* Data stream timed out */
-			xyzModem_flush();	/* Toss any current input */
-			ZM_DEBUG(zm_dump(__LINE__));
-			CYGACC_CALL_IF_DELAY_US((cyg_int32) 250000);
-			return xyzModem_timeout;
-		}
-	}
-
-	/* Header found, now read the data */
-	res = CYGACC_COMM_IF_GETC_TIMEOUT(*xyz.__chan, (char *)&xyz.blk);
-	ZM_DEBUG(zm_save(xyz.blk));
-	if (!res) {
-		ZM_DEBUG(zm_dump(__LINE__));
-		return xyzModem_timeout;
-	}
-	res = CYGACC_COMM_IF_GETC_TIMEOUT(*xyz.__chan, (char *)&xyz.cblk);
-	ZM_DEBUG(zm_save(xyz.cblk));
-	if (!res) {
-		ZM_DEBUG(zm_dump(__LINE__));
-		return xyzModem_timeout;
-	}
-	xyz.len = (c == SOH) ? 128 : 1024;
-	xyz.bufp = xyz.pkt;
-	for (i = 0; i < xyz.len; i++) {
-		res = CYGACC_COMM_IF_GETC_TIMEOUT(*xyz.__chan, &c);
-		ZM_DEBUG(zm_save(c));
-		if (res) {
-			xyz.pkt[i] = c;
-		} else {
-			ZM_DEBUG(zm_dump(__LINE__));
-			return xyzModem_timeout;
-		}
-	}
-	res = CYGACC_COMM_IF_GETC_TIMEOUT(*xyz.__chan, (char *)&xyz.crc1);
-	ZM_DEBUG(zm_save(xyz.crc1));
-	if (!res) {
-		ZM_DEBUG(zm_dump(__LINE__));
-		return xyzModem_timeout;
-	}
-	if (xyz.crc_mode) {
-		res =
-		    CYGACC_COMM_IF_GETC_TIMEOUT(*xyz.__chan, (char *)&xyz.crc2);
-		ZM_DEBUG(zm_save(xyz.crc2));
-		if (!res) {
-			ZM_DEBUG(zm_dump(__LINE__));
-			return xyzModem_timeout;
-		}
-	}
-	ZM_DEBUG(zm_dump(__LINE__));
-	/* Validate the message */
-	if ((xyz.blk ^ xyz.cblk) != (unsigned char)0xFF) {
-		ZM_DEBUG(zm_dprintf
-			 ("Framing error - blk: %x/%x/%x\n", xyz.blk, xyz.cblk,
-			  (xyz.blk ^ xyz.cblk)));
-		ZM_DEBUG(zm_dump_buf(xyz.pkt, xyz.len));
-		xyzModem_flush();
-		return xyzModem_frame;
-	}
-	/* Verify checksum/CRC */
-	if (xyz.crc_mode) {
-		cksum = cyg_crc16(xyz.pkt, xyz.len);
-		if (cksum != ((xyz.crc1 << 8) | xyz.crc2)) {
-			ZM_DEBUG(zm_dprintf
-				 ("CRC error - recvd: %02x%02x, computed: %x\n",
-				  xyz.crc1, xyz.crc2, cksum & 0xFFFF));
-			return xyzModem_cksum;
-		}
-	} else {
-		cksum = 0;
-		for (i = 0; i < xyz.len; i++)
-			cksum += xyz.pkt[i];
-		if (xyz.crc1 != (cksum & 0xFF)) {
-			ZM_DEBUG(zm_dprintf
-				 ("Checksum error - recvd: %x, computed: %x\n",
-				  xyz.crc1, cksum & 0xFF));
-			return xyzModem_cksum;
-		}
-	}
-	/* If we get here, the message passes [structural] muster */
-	return 0;
-}
-
-int xyzModem_stream_open(connection_info_t *info, int *err)
-{
-#ifdef REDBOOT
-	int console_chan;
-#endif
-	int stat = 0;
-	int retries = xyzModem_MAX_RETRIES;
-	int crc_retries = xyzModem_MAX_RETRIES_WITH_CRC;
-
-/*    ZM_DEBUG(zm_out = zm_out_start); */
-#ifdef xyzModem_zmodem
-	if (info->mode == xyzModem_zmodem) {
-		*err = xyzModem_noZmodem;
-		return -1;
-	}
-#endif
-
-#ifdef REDBOOT
-	/* Set up the I/O channel.  Note: this allows for using a different
-	 * port in the future */
-	console_chan =
-	    CYGACC_CALL_IF_SET_CONSOLE_COMM
-	    (CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT);
-	if (info->chan >= 0)
-		CYGACC_CALL_IF_SET_CONSOLE_COMM(info->chan);
-	else
-		CYGACC_CALL_IF_SET_CONSOLE_COMM(console_chan);
-
-	xyz.__chan = CYGACC_CALL_IF_CONSOLE_PROCS();
-
-	CYGACC_CALL_IF_SET_CONSOLE_COMM(console_chan);
-	CYGACC_COMM_IF_CONTROL(*xyz.__chan, __COMMCTL_SET_TIMEOUT,
-			       xyzModem_CHAR_TIMEOUT);
-#else
-/* TODO: CHECK ! */
-	int dummy = 0;
-	xyz.__chan = &dummy;
-#endif
-	xyz.len = 0;
-	xyz.crc_mode = true;
-	xyz.at_eof = false;
-	xyz.tx_ack = false;
-	xyz.mode = info->mode;
-	xyz.total_retries = 0;
-	xyz.total_SOH = 0;
-	xyz.total_STX = 0;
-	xyz.total_CAN = 0;
-#ifdef USE_YMODEM_LENGTH
-	xyz.read_length = 0;
-	xyz.file_length = 0;
-#endif
-
-	CYGACC_COMM_IF_PUTC(*xyz.__chan, (xyz.crc_mode ? 'C' : NAK));
-
-	if (xyz.mode == xyzModem_xmodem) {
-		/* X-modem doesn't have an information header - exit here */
-		xyz.next_blk = 1;
-		return 0;
-	}
-
-	while (retries-- > 0) {
-		stat = xyzModem_get_hdr();
-		if (stat == 0) {
-			/* Y-modem file information header */
-			if (xyz.blk == 0) {
-#ifdef USE_YMODEM_LENGTH
-				/* skip filename */
-				while (*xyz.bufp++) ;
-				/* get the length */
-				parse_num((char *)xyz.bufp, &xyz.file_length,
-					  NULL, " ");
-#endif
-				/* The rest of the file name data block
-				 * quietly discarded
-				 */
-				xyz.tx_ack = true;
-			}
-			xyz.next_blk = 1;
-			xyz.len = 0;
-			return 0;
-		} else if (stat == xyzModem_timeout) {
-			if (--crc_retries <= 0)
-				xyz.crc_mode = false;
-			/* Extra delay for startup */
-			CYGACC_CALL_IF_DELAY_US(5 * 100000);
-			CYGACC_COMM_IF_PUTC(*xyz.__chan,
-					    (xyz.crc_mode ? 'C' : NAK));
-			xyz.total_retries++;
-			ZM_DEBUG(zm_dprintf("NAK (%d)\n", __LINE__));
-		}
-		if (stat == xyzModem_cancel)
-			break;
-	}
-	*err = stat;
-	ZM_DEBUG(zm_flush());
-	return -1;
-}
-
-int xyzModem_stream_read(char *buf, int size, int *err)
-{
-	int stat, total, len;
-	int retries;
-
-	total = 0;
-	stat = xyzModem_cancel;
-	/* Try and get 'size' bytes into the buffer */
-	while (!xyz.at_eof && (size > 0)) {
-		if (xyz.len == 0) {
-			retries = xyzModem_MAX_RETRIES;
-			while (retries-- > 0) {
-				stat = xyzModem_get_hdr();
-				if (stat == 0) {
-					if (xyz.blk == xyz.next_blk) {
-						xyz.tx_ack = true;
-						ZM_DEBUG(zm_dprintf
-							 ("ACK block %d (%d)\n",
-							  xyz.blk, __LINE__));
-						xyz.next_blk =
-						    (xyz.next_blk + 1) & 0xFF;
-
-#if defined(xyzModem_zmodem) || defined(USE_YMODEM_LENGTH)
-						if (xyz.mode == xyzModem_xmodem
-						    || xyz.file_length == 0) {
-#else
-						if (1) {
-#endif
-			/* WARNING - Leaving formatting aside for code
-			 * clarity */
-			/* Data blocks can be padded with ^Z (EOF) characters */
-			/* This code tries to detect and remove them */
-			if ((xyz.bufp[xyz.len - 1] == EOF)
-			    && (xyz.bufp[xyz.len - 2] == EOF)
-			    && (xyz.bufp[xyz.len - 3] == EOF)) {
-				while (xyz.len &&
-					(xyz.bufp[xyz.len - 1] == EOF))
-						xyz.len--;
-				}
-			}
-#ifdef USE_YMODEM_LENGTH
-			/* WARNING - Leaving formatting aside for code
-			 * clarity */
-			/*
-			 * See if accumulated length exceeds that of the file.
-			 * If so, reduce size (i.e., cut out pad bytes)
-			 * Only do this for Y-modem (and Z-modem should it ever
-			 * be supported since it can fall back to Y-modem mode).
-			 */
-			if (xyz.mode != xyzModem_xmodem
-			    && 0 != xyz.file_length) {
-				xyz.read_length += xyz.len;
-				if (xyz.read_length > xyz.file_length)
-					xyz.len -= (xyz.read_length -
-					     xyz.file_length);
-			}
-#endif
-						break;
-					} else if (xyz.blk ==
-						   ((xyz.next_blk - 1) &
-						    0xFF)) {
-						/* Just re-ACK this so sender
-						 * will get on with it */
-						CYGACC_COMM_IF_PUTC(*xyz.__chan,
-								    ACK);
-						/* Need new header */
-						continue;
-					} else
-						stat = xyzModem_sequence;
-				}
-				if (stat == xyzModem_cancel)
-					break;
-				if (stat == xyzModem_eof) {
-					CYGACC_COMM_IF_PUTC(*xyz.__chan, ACK);
-					ZM_DEBUG(zm_dprintf
-						 ("ACK (%d)\n", __LINE__));
-					if (xyz.mode == xyzModem_ymodem) {
-						CYGACC_COMM_IF_PUTC(*xyz.__chan,
-								    (xyz.
-								     crc_mode ?
-								     'C' :
-								     NAK));
-						xyz.total_retries++;
-						ZM_DEBUG(zm_dprintf
-						 ("Reading Final Header\n"));
-						stat = xyzModem_get_hdr();
-						CYGACC_COMM_IF_PUTC(*xyz.__chan,
-								    ACK);
-						ZM_DEBUG(zm_dprintf
-							 ("FINAL ACK (%d)\n",
-							  __LINE__));
-					}
-					xyz.at_eof = true;
-					break;
-				}
-				CYGACC_COMM_IF_PUTC(*xyz.__chan,
-						    (xyz.crc_mode ? 'C' : NAK));
-				xyz.total_retries++;
-				ZM_DEBUG(zm_dprintf("NAK (%d)\n", __LINE__));
-			}
-			if (stat < 0) {
-				*err = stat;
-				xyz.len = -1;
-				return total;
-			}
-		}
-		/* Don't "read" data from the EOF protocol package */
-		if (!xyz.at_eof) {
-			len = xyz.len;
-			if (size < len)
-				len = size;
-			memcpy(buf, xyz.bufp, len);
-			size -= len;
-			buf += len;
-			total += len;
-			xyz.len -= len;
-			xyz.bufp += len;
-		}
-	}
-	return total;
-}
-
-void xyzModem_stream_close(int *err)
-{
-	diag_printf
-	    ("xyzModem - %s mode, %d(SOH)/%d(STX)/%d(CAN) packets,"
-	     " %d retries\n",
-	     xyz.crc_mode ? "CRC" : "Cksum", xyz.total_SOH, xyz.total_STX,
-	     xyz.total_CAN, xyz.total_retries);
-	ZM_DEBUG(zm_flush());
-}
-
-/* Need to be able to clean out the input buffer, so have to take the */
-/* getc */
-void xyzModem_stream_terminate(bool abort, int (*getc) (void))
-{
-	int c;
-
-	if (abort) {
-		ZM_DEBUG(zm_dprintf("!!!! TRANSFER ABORT !!!!\n"));
-		switch (xyz.mode) {
-		case xyzModem_xmodem:
-		case xyzModem_ymodem:
-			/* The X/YMODEM Spec seems to suggest that multiple CAN
-			 * followed by an equal number of Backspaces is a
-			 * friendly way to get the other end to abort. */
-			CYGACC_COMM_IF_PUTC(*xyz.__chan, CAN);
-			CYGACC_COMM_IF_PUTC(*xyz.__chan, CAN);
-			CYGACC_COMM_IF_PUTC(*xyz.__chan, CAN);
-			CYGACC_COMM_IF_PUTC(*xyz.__chan, CAN);
-			CYGACC_COMM_IF_PUTC(*xyz.__chan, BSP);
-			CYGACC_COMM_IF_PUTC(*xyz.__chan, BSP);
-			CYGACC_COMM_IF_PUTC(*xyz.__chan, BSP);
-			CYGACC_COMM_IF_PUTC(*xyz.__chan, BSP);
-			/* Now consume the rest of what's waiting on the line.*/
-			ZM_DEBUG(zm_dprintf("Flushing serial line.\n"));
-			xyzModem_flush();
-			xyz.at_eof = true;
-			break;
-#ifdef xyzModem_zmodem
-		case xyzModem_zmodem:
-			/* Might support it some day I suppose. */
-#endif
-			break;
-		}
-	} else {
-		ZM_DEBUG(zm_dprintf("Engaging cleanup mode...\n"));
-		/*
-		 * Consume any trailing crap left in the inbuffer from
-		 * previous recieved blocks. Since very few files are an
-		 * exact multiple of the transfer block size, there will
-		 * almost always be some gunk here.
-		 * If we don't eat it now, RedBoot will think the user typed it.
-		 */
-		ZM_DEBUG(zm_dprintf("Trailing gunk:\n"));
-		while ((c = (*getc) ()) > -1) ;
-		ZM_DEBUG(zm_dprintf("\n"));
-		/*
-		 * Make a small delay to give terminal programs like minicom
-		 * time to get control again after their file transfer program
-		 * exits.
-		 */
-		CYGACC_CALL_IF_DELAY_US((cyg_int32) 250000);
-	}
-}
-
-char *xyzModem_error(int err)
-{
-	switch (err) {
-	case xyzModem_access:
-		return "Can't access file";
-		break;
-	case xyzModem_noZmodem:
-		return "Sorry, zModem not available yet";
-		break;
-	case xyzModem_timeout:
-		return "Timed out";
-		break;
-	case xyzModem_eof:
-		return "End of file";
-		break;
-	case xyzModem_cancel:
-		return "Cancelled";
-		break;
-	case xyzModem_frame:
-		return "Invalid framing";
-		break;
-	case xyzModem_cksum:
-		return "CRC/checksum error";
-		break;
-	case xyzModem_sequence:
-		return "Block sequence error";
-		break;
-	default:
-		return "Unknown error";
-		break;
-	}
-}
-
-/*
- * RedBoot interface
- */
-#if 0				/* SB */
-GETC_IO_FUNCS(xyzModem_io, xyzModem_stream_open, xyzModem_stream_close,
-	      xyzModem_stream_terminate, xyzModem_stream_read, xyzModem_error);
-RedBoot_load(xmodem, xyzModem_io, false, false, xyzModem_xmodem);
-RedBoot_load(ymodem, xyzModem_io, false, false, xyzModem_ymodem);
-#endif
diff --git a/include/xyzModem.h b/include/xyzModem.h
deleted file mode 100644
index a3ea768..0000000
--- a/include/xyzModem.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- *==========================================================================
- *
- *      xyzModem.h
- *
- *      RedBoot stream handler for xyzModem protocol
- *
- *==========================================================================
- *####ECOSGPLCOPYRIGHTBEGIN####
- * -------------------------------------------
- * This file is part of eCos, the Embedded Configurable Operating System.
- * Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
- * Copyright (C) 2002 Gary Thomas
- *
- * eCos is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 or (at your option) any later version.
- *
- * eCos is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with eCos; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * As a special exception, if other files instantiate templates or use macros
- * or inline functions from this file, or you compile this file and link it
- * with other works to produce a work based on this file, this file does not
- * by itself cause the resulting work to be covered by the GNU General Public
- * License. However the source code for this file must still be made available
- * in accordance with section (3) of the GNU General Public License.
- *
- * This exception does not invalidate any other reasons why a work based on
- * this file might be covered by the GNU General Public License.
- *
- * Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
- * at http: *sources.redhat.com/ecos/ecos-license/
- * -------------------------------------------
- *####ECOSGPLCOPYRIGHTEND####
- *==========================================================================
- *#####DESCRIPTIONBEGIN####
- *
- * Author(s):    gthomas
- * Contributors: gthomas
- * Date:         2000-07-14
- * Purpose:
- * Description:
- *
- * This code is part of RedBoot (tm).
- *
- *####DESCRIPTIONEND####
- *
- *==========================================================================
- */
-
-#ifndef _XYZMODEM_H_
-#define _XYZMODEM_H_
-
-#define xyzModem_xmodem 1
-#define xyzModem_ymodem 2
-/* Don't define this until the protocol support is in place */
-/*#define xyzModem_zmodem 3 */
-
-#define xyzModem_access   -1
-#define xyzModem_noZmodem -2
-#define xyzModem_timeout  -3
-#define xyzModem_eof      -4
-#define xyzModem_cancel   -5
-#define xyzModem_frame    -6
-#define xyzModem_cksum    -7
-#define xyzModem_sequence -8
-
-#define xyzModem_close 1
-#define xyzModem_abort 2
-
-
-#ifdef REDBOOT
-extern getc_io_funcs_t xyzModem_io;
-#else
-#define CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT
-#define CYGACC_CALL_IF_SET_CONSOLE_COMM(x)
-
-#define diag_vprintf vprintf
-#define diag_printf printf
-#define diag_vsprintf vsprintf
-
-#define CYGACC_CALL_IF_DELAY_US(x) udelay(x)
-
-typedef struct {
-    char *filename;
-    int   mode;
-    int   chan;
-#ifdef CYGPKG_REDBOOT_NETWORKING
-    struct sockaddr_in *server;
-#endif
-} connection_info_t;
-
-#endif
-
-
-int   xyzModem_stream_open(connection_info_t *info, int *err);
-void  xyzModem_stream_close(int *err);
-void  xyzModem_stream_terminate(bool method, int (*getc)(void));
-int   xyzModem_stream_read(char *buf, int size, int *err);
-char *xyzModem_error(int err);
-
-#endif /* _XYZMODEM_H_ */
-- 
1.7.10



From antonynpavlov at gmail.com  Thu Nov  8 16:44:46 2012
From: antonynpavlov at gmail.com (Antony Pavlov)
Date: Fri, 9 Nov 2012 01:44:46 +0400
Subject: [PATCH v3 1/2] commands: change Y-Modem implementation
In-Reply-To: <1352409401-3333-1-git-send-email-robert.jarzmik@free.fr>
References: <1352409401-3333-1-git-send-email-robert.jarzmik@free.fr>
Message-ID: <CAA4bVAHfj7jX-Qb_4OvOPe73nSLaRmEadQd=c_cRHemODgxZzg@mail.gmail.com>

On 9 November 2012 01:16, Robert Jarzmik <robert.jarzmik at free.fr> wrote:
> The current Y-Modem implementation has some limitations:
>  - Y-Modem/G protocol is not supported
>  - Multiple files (aka. batch) transfers are not supported
>  - Transfer speed over fast lines (USB console) is slow
>  - Code is not trivial to maintain (personnal opinion)

personal


> This implementation tries to address all these points by
> introducing loady2 command.

-- 
Best regards,
  Antony Pavlov


From fabio.porcedda at gmail.com  Fri Nov  9 06:06:38 2012
From: fabio.porcedda at gmail.com (Fabio Porcedda)
Date: Fri, 9 Nov 2012 12:06:38 +0100
Subject: defaultenv-2: how to update a flash partition?
Message-ID: <CAHkwnC-dDfPesg5vy5V2rj7vdY_DH9cjfJ3gCVsm8xY-DPf35A@mail.gmail.com>

Hi all,

I want to use the defaultenv-2 but i don't find any more the "update"
command
like in the defaultenv.
What is the recommended way to update a flash partition in the new
environment?

Best regards
-- 
Fabio Porcedda
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/barebox/attachments/20121109/29c7bfe8/attachment.html>

From s.hauer at pengutronix.de  Mon Nov 12 02:28:39 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 12 Nov 2012 08:28:39 +0100
Subject: [PATCH] mdiobus: unbreak phy_device_connect(): honor masked out
 PHYs
In-Reply-To: <1352329179-19809-1-git-send-email-apr@cn-eng.de>
References: <1352329179-19809-1-git-send-email-apr@cn-eng.de>
Message-ID: <20121112072839.GF10369@pengutronix.de>

On Wed, Nov 07, 2012 at 11:59:39PM +0100, Andreas Pretzsch wrote:
> commit 89dfe2d2af87f1b803f611d986d4ef383b6ad964 "mdiobus: do not scan
> the bus at registration time" dropped the check for struct mii_bus
> element phy_mask while scanning through all addresses.
> Re-add this check.
> 
> Signed-off-by: Andreas Pretzsch <apr at cn-eng.de>

Applied, thanks

Sascha

> ---
> patch against branch "next" / commit 89dfe2d2af87f1b803f611d986d4ef383b6ad964
> Another one to fold into original patch. Sorry for missing it the first round.
> 
>  drivers/net/phy/phy.c |    4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index 547e269..d8132b9 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -169,6 +169,10 @@ int phy_device_connect(struct eth_device *edev, struct mii_bus *bus, int addr,
>  				goto fail;
>  		} else {
>  			for (i = 0; i < PHY_MAX_ADDR && !edev->phydev; i++) {
> +				/* skip masked out PHY addresses */
> +				if (bus->phy_mask & (1 << i))
> +					continue;
> +
>  				dev = mdiobus_scan(bus, i);
>  				if (!dev || dev->attached_dev)
>  					continue;
> -- 
> 1.7.10.4
> 
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Mon Nov 12 02:30:00 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 12 Nov 2012 08:30:00 +0100
Subject: [PATCH] net smc911x: add support for external PHY
In-Reply-To: <1352330703-27402-1-git-send-email-apr@cn-eng.de>
References: <1352330703-27402-1-git-send-email-apr@cn-eng.de>
Message-ID: <20121112073000.GG10369@pengutronix.de>

On Thu, Nov 08, 2012 at 12:25:03AM +0100, Andreas Pretzsch wrote:
> On LAN9115/LAN9117/LAN9215/LAN9217, external PHYs are supported.
> Switch to external PHY based on hardware strap pin and/or override flags.
> Also add a mask to platform data selecting external PHY address to be used.
> 
> Code based on linux/drivers/net/ethernet/smsc/smsc911x.c (fd9abb3d, d23f028a).

Applied, thanks

Sascha

> ---
> Code is tested on a SMSC LAN9217 with an external PHY (switch chip attached
> in PHY mode via MII), the external mode works as expected.
> As I have no board at hand using the internal PHY of the controller (or any
> of these family), I cannot verify the current behaviour, beside looking at
> the internal PHY register (which are fine).
> But as the modifications are mostly 1:1 copies of the respective Linux mainline
> code, slightly adapted for Barebox, I expect no problems here.
> 
> Patch is against current next, but should also match current master.
> CC'ing last active authors.
> 
>  drivers/net/smc911x.c |   97 +++++++++++++++++++++++++++++++++++++++++++++++--
>  include/smc911x.h     |    6 +++
>  2 files changed, 99 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
> index c657fec..28c69ba 100644
> --- a/drivers/net/smc911x.c
> +++ b/drivers/net/smc911x.c
> @@ -44,6 +44,10 @@ struct smc911x_priv {
>  
>  	int shift;
>  	int generation;
> +	unsigned int flags;
> +	unsigned int idrev;
> +	unsigned int using_extphy;
> +	unsigned int phy_mask;
>  
>  	u32 (*reg_read)(struct smc911x_priv *priv, u32 reg);
>  	void (*reg_write)(struct smc911x_priv *priv, u32 reg, u32 val);
> @@ -225,6 +229,60 @@ static int smc911x_phy_write(struct mii_bus *bus, int phy_addr,
>  	return 0;
>  }
>  
> +/* Switch to external phy. Assumes tx and rx are stopped. */
> +static void smsc911x_phy_enable_external(struct eth_device *edev)
> +{
> +	struct smc911x_priv *priv = edev->priv;
> +	u32 hwcfg = smc911x_reg_read(priv, HW_CFG);
> +
> +	/* Disable phy clocks to the MAC */
> +	hwcfg &= (~HW_CFG_PHY_CLK_SEL);
> +	hwcfg |= HW_CFG_PHY_CLK_SEL_CLK_DIS;
> +	smc911x_reg_write(priv, HW_CFG, hwcfg);
> +	udelay(10);	/* Enough time for clocks to stop */
> +
> +	/* Switch to external phy */
> +	hwcfg |= HW_CFG_EXT_PHY_EN;
> +	smc911x_reg_write(priv, HW_CFG, hwcfg);
> +
> +	/* Enable phy clocks to the MAC */
> +	hwcfg &= (~HW_CFG_PHY_CLK_SEL);
> +	hwcfg |= HW_CFG_PHY_CLK_SEL_EXT_PHY;
> +	smc911x_reg_write(priv, HW_CFG, hwcfg);
> +	udelay(10);	/* Enough time for clocks to restart */
> +
> +	/* Switch MDIO/MDC to external PHY */
> +	hwcfg |= HW_CFG_SMI_SEL;
> +	smc911x_reg_write(priv, HW_CFG, hwcfg);
> +}
> +
> +/* Autodetects and enables external phy if present on supported chips.
> + * autodetection can be overridden by specifying SMC911X_FORCE_INTERNAL_PHY
> + * or SMC911X_FORCE_EXTERNAL_PHY in the platform_data flags. */
> +static void smsc911x_phy_initialise_external(struct eth_device *edev)
> +{
> +	struct smc911x_priv *priv = edev->priv;
> +	u32 hwcfg = smc911x_reg_read(priv, HW_CFG);
> +
> +	if (priv->flags & SMC911X_FORCE_INTERNAL_PHY) {
> +		dev_info(edev->parent, "Forcing internal PHY\n");
> +		priv->using_extphy = 0;
> +	} else if (priv->flags & SMC911X_FORCE_EXTERNAL_PHY) {
> +		dev_info(edev->parent, "Forcing external PHY\n");
> +		smsc911x_phy_enable_external(edev);
> +		priv->using_extphy = 1;
> +	} else if (hwcfg & HW_CFG_EXT_PHY_DET) {
> +		dev_info(edev->parent,
> +			"HW_CFG EXT_PHY_DET set, using external PHY\n");
> +		smsc911x_phy_enable_external(edev);
> +		priv->using_extphy = 1;
> +	} else {
> +		dev_info(edev->parent,
> +			"HW_CFG EXT_PHY_DET clear, using internal PHY\n");
> +		priv->using_extphy = 0;
> +	}
> +}
> +
>  static int smc911x_phy_reset(struct eth_device *edev)
>  {
>  	struct smc911x_priv *priv = edev->priv;
> @@ -284,14 +342,41 @@ static void smc911x_reset(struct eth_device *edev)
>  
>  	/* Set to LED outputs */
>  	smc911x_reg_write(priv, GPIO_CFG, 0x70070000);
> +
> +	/* Select internal/external PHY */
> +	switch (priv->idrev & 0xFFFF0000) {
> +	case 0x01170000:
> +	case 0x01150000:
> +	case 0x117A0000:
> +	case 0x115A0000:
> +		/* External PHY supported, try to autodetect */
> +		smsc911x_phy_initialise_external(edev);
> +		break;
> +	default:
> +		dev_dbg(edev->parent, "External PHY is not supported, "
> +			"using internal PHY\n");
> +		priv->using_extphy = 0;
> +		break;
> +	}
> +
> +	if (!priv->using_extphy) {
> +		/* Mask all PHYs except ID 1 (internal) */
> +		priv->miibus.phy_mask = ~(1 << 1);
> +	} else {
> +		/* Mask PHYs as requested (or try all if mask is 0) */
> +		/* Attn.: first probed PHY is used by phy_device_connect */
> +		priv->miibus.phy_mask = priv->phy_mask;
> +	}
>  }
>  
>  static void smc911x_enable(struct eth_device *edev)
>  {
>  	struct smc911x_priv *priv = edev->priv;
> +	u32 hw_cfg_phy_settings;
>  
>  	/* Enable TX */
> -	smc911x_reg_write(priv, HW_CFG, 8 << 16 | HW_CFG_SF);
> +	hw_cfg_phy_settings = smc911x_reg_read(priv, HW_CFG) & (HW_CFG_PHY_CLK_SEL|HW_CFG_SMI_SEL|HW_CFG_EXT_PHY_EN);
> +	smc911x_reg_write(priv, HW_CFG, 8 << 16 | HW_CFG_SF | hw_cfg_phy_settings);
>  
>  	smc911x_reg_write(priv, GPT_CFG, GPT_CFG_TIMER_EN | 10000);
>  
> @@ -306,7 +391,8 @@ static int smc911x_eth_open(struct eth_device *edev)
>  	struct smc911x_priv *priv = (struct smc911x_priv *)edev->priv;
>  	int ret;
>  
> -	ret = phy_device_connect(edev, &priv->miibus, 1, NULL,
> +	/* use first probed PHY (see also phy_mask) */
> +	ret = phy_device_connect(edev, &priv->miibus, -1, NULL,
>  				 0, PHY_INTERFACE_MODE_NA);
>  	if (ret)
>  		return ret;
> @@ -426,8 +512,11 @@ static int smc911x_probe(struct device_d *dev)
>  		is_32bit = is_32bit == IORESOURCE_MEM_32BIT;
>  	priv->base = dev_request_mem_region(dev, 0);
>  
> -	if (pdata && pdata->shift)
> +	if (pdata) {
>  		priv->shift = pdata->shift;
> +		priv->flags = pdata->flags;
> +		priv->phy_mask = pdata->phy_mask;
> +	}
>  
>  	if (is_32bit) {
>  		if (priv->shift) {
> @@ -483,7 +572,7 @@ static int smc911x_probe(struct device_d *dev)
>  		return -ENODEV;
>  	}
>  
> -	val = smc911x_reg_read(priv, ID_REV);
> +	priv->idrev = val = smc911x_reg_read(priv, ID_REV);
>  	switch (val & 0xFFFF0000) {
>  	case 0x01180000:
>  	case 0x01170000:
> diff --git a/include/smc911x.h b/include/smc911x.h
> index 148906b..4a802ee 100644
> --- a/include/smc911x.h
> +++ b/include/smc911x.h
> @@ -13,6 +13,12 @@
>   */
>  struct smc911x_plat {
>  	int shift;
> +	unsigned int flags;
> +	unsigned int phy_mask;	/* external PHY only: mask out PHYs,
> +				   e.g. ~(1 << 5) to use PHY addr 5 */
>  };
>  
> +#define SMC911X_FORCE_INTERNAL_PHY	0x01
> +#define SMC911X_FORCE_EXTERNAL_PHY	0x02
> +
>  #endif /* __SMC911X_PLATFORM_H_ */
> -- 
> 1.7.10.4
> 
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Mon Nov 12 02:32:33 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 12 Nov 2012 08:32:33 +0100
Subject: [PATCH 0/2 v4] add spi command
In-Reply-To: <20121105182148.GA25679@game.jcrosoft.org>
References: <20121105182148.GA25679@game.jcrosoft.org>
Message-ID: <20121112073233.GH10369@pengutronix.de>

On Mon, Nov 05, 2012 at 07:21:48PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> HI,
> 
> 	v4:
> 	do not touch the atmel_spi
> 
> 	v3:
> 	call setup before accesing the device
> 	This was working properly on at91 as the driver is wrong.
> 	It call setup for every transfer. I will fix the atmel_spi.
> 
> 	v2:
> 	add default return usage
> 	use memory_display
> 
> 	while debugging a spi issue I found we have a i2c commands but no spi
> 	command
> 
> 	So introduce one
> 
> The following changes since commit 56371f4e8446d04d2a5608dd5890fd87a50f888e:

Applied, thanks

Sascha

> 
>   iomux-imx35: add missing comma in pad definition (2012-11-01 16:32:12 +0100)
> 
> are available in the git repository at:
> 
>   git://git.jcrosoft.org/barebox.git delivery/command_spi
> 
> for you to fetch changes up to 268e3d4f67da35571159fd096c62fa2e660783b0:
> 
>   introduce spi command (2012-11-05 11:13:25 +0800)
> 
> ----------------------------------------------------------------
> Jean-Christophe PLAGNIOL-VILLARD (2):
>       spi: introduce spi_get_master
>       introduce spi command
> 
>  commands/Kconfig  |    6 ++++++
>  commands/Makefile |    1 +
>  commands/spi.c    |  132 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  drivers/spi/spi.c |   12 ++++++++++++
>  include/spi/spi.h |    2 ++
>  5 files changed, 153 insertions(+)
>  create mode 100644 commands/spi.c
> 
> Best Regards,
> J.
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Mon Nov 12 02:33:46 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 12 Nov 2012 08:33:46 +0100
Subject: [PATCH 1/1] at91rm9200ek: enable dt support
In-Reply-To: <1352055092-21128-1-git-send-email-plagnioj@jcrosoft.com>
References: <1352055092-21128-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <20121112073346.GI10369@pengutronix.de>

On Sun, Nov 04, 2012 at 07:51:32PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
> ---
>  arch/arm/boards/at91rm9200ek/env/config |    2 ++
>  arch/arm/configs/at91rm9200ek_defconfig |    5 +++++
>  2 files changed, 7 insertions(+)
> 

Applied, thanks

Sascha

> diff --git a/arch/arm/boards/at91rm9200ek/env/config b/arch/arm/boards/at91rm9200ek/env/config
> index a3830cb..76c180b 100644
> --- a/arch/arm/boards/at91rm9200ek/env/config
> +++ b/arch/arm/boards/at91rm9200ek/env/config
> @@ -15,6 +15,8 @@ global.dhcp.vendor_id=barebox-at91rm9200ek
>  kernel_loc=nfs
>  # can be either 'net', 'nor' or 'initrd'
>  rootfs_loc=net
> +# can be either 'nfs', 'tftp', or empty
> +oftree_loc=nfs
>  
>  # can be either 'jffs2' or 'ubifs'
>  rootfs_type=ubifs
> diff --git a/arch/arm/configs/at91rm9200ek_defconfig b/arch/arm/configs/at91rm9200ek_defconfig
> index 6a105c6..2bcade9 100644
> --- a/arch/arm/configs/at91rm9200ek_defconfig
> +++ b/arch/arm/configs/at91rm9200ek_defconfig
> @@ -32,9 +32,14 @@ CONFIG_CMD_FLASH=y
>  CONFIG_CMD_BOOTM_ZLIB=y
>  CONFIG_CMD_BOOTM_BZLIB=y
>  CONFIG_CMD_BOOTM_SHOW_TYPE=y
> +CONFIG_CMD_BOOTM_VERBOSE=y
>  CONFIG_CMD_BOOTM_INITRD=y
> +CONFIG_CMD_BOOTM_OFTREE=y
> +CONFIG_CMD_BOOTM_OFTREE_UIMAGE=y
> +# CONFIG_CMD_BOOTU is not set
>  CONFIG_CMD_RESET=y
>  CONFIG_CMD_GO=y
> +CONFIG_CMD_OFTREE=y
>  CONFIG_CMD_TIMEOUT=y
>  CONFIG_CMD_PARTITION=y
>  CONFIG_CMD_GPIO=y
> -- 
> 1.7.10.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Mon Nov 12 02:36:37 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 12 Nov 2012 08:36:37 +0100
Subject: [PATCH 0/8] atmtel: fix spi driver + rm9200
In-Reply-To: <20121106193010.GE25679@game.jcrosoft.org>
References: <20121106193010.GE25679@game.jcrosoft.org>
Message-ID: <20121112073637.GJ10369@pengutronix.de>

On Tue, Nov 06, 2012 at 08:30:10PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> HI,
> 
> The following changes since commit d74bef2b04a3ccf7339ba916e56830bb2feae957:
> 
>   mount: add compatibility to old mount command (2012-11-02 21:26:29 +0100)
> 
> are available in the git repository at:
> 
>   git://git.jcrosoft.org/barebox.git tags/atmel_spi_fix
> 
> for you to fetch changes up to 7e7b7aa81cdf7e47a8f828818f1e453a27046c38:
> 
>   at91rm9200: fix spi cs support (2012-11-06 04:39:09 +0800)

Applied, thanks

Sascha

> 
> ----------------------------------------------------------------
> atmel spi support fix
> 
> The current drivers for atmel have a lot of issues but we are lucky
> enough if you use it one device + one master instance it will work on
> most of the spi device
> 
> but this will not work on mmc spi or multi-master instance or multi-device
> 
> so now fix all those issues
>  - fix the cs support
>  - fix setup setup support
>  - do not call setup before each transfert
>  - add sanity check
> 
> now the atmel spi work on rm9200, mmc spi and at24, at45, eeprom
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
> 
> ----------------------------------------------------------------
> Jean-Christophe PLAGNIOL-VILLARD (8):
>       atmel_spi: use device id as bus num
>       atmel_spi: split transfert to atmel_spi_do_xfer
>       atmel_spi: after setup the cs need to be disable
>       atmel_spi: add sanity check in setup
>       atmel_spi: fix cs support
>       atmel_spi: drop setup during transfer
>       atmel_spi: add cs change support
>       at91rm9200: fix spi cs support
> 
>  arch/arm/mach-at91/at91rm9200_devices.c |    7 ++++++-
>  drivers/spi/atmel_spi.c                 |  260 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------------------
>  2 files changed, 196 insertions(+), 71 deletions(-)
> 
> Best Regards,
> J.
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Mon Nov 12 02:38:19 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 12 Nov 2012 08:38:19 +0100
Subject: [PATCH 0/3] i2c: add at24 eeprom support
In-Reply-To: <20121103205655.GA29599@game.jcrosoft.org>
References: <20121103205655.GA29599@game.jcrosoft.org>
Message-ID: <20121112073819.GK10369@pengutronix.de>

On Sat, Nov 03, 2012 at 09:56:55PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> HI,
> 
> 	this patch serie add the at24 eeprom support based on linux 3.6
> 
> 	the depends on the i2c prepare 1t24 support patch series
> 
> The following changes since commit 5526278ac77ecd7109c9c1bbc35d7c74875902e7:
> 
>   i2c: add id_table support (2012-11-03 13:33:54 +0800)
> 
> are available in the git repository at:
> 
>   git://git.jcrosoft.org/barebox.git delivery/at24
> 
> for you to fetch changes up to fe6968e20c39461df068d5cc15869012be4a3161:

Applied, thanks

Sascha

> 
>   eeprom: add at24 support (2012-11-03 13:46:50 +0800)
> 
> ----------------------------------------------------------------
> Jean-Christophe PLAGNIOL-VILLARD (3):
>       import log2 support from linux
>       add roundup and rounddown support
>       eeprom: add at24 support
> 
>  drivers/eeprom/Kconfig  |   19 ++++++++++
>  drivers/eeprom/Makefile |    1 +
>  drivers/eeprom/at24.c   |  460 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  include/i2c/at24.h      |   35 +++++++++++++++++++
>  include/linux/kernel.h  |   15 ++++++++
>  include/linux/log2.h    |  190 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  6 files changed, 720 insertions(+)
>  create mode 100644 drivers/eeprom/at24.c
>  create mode 100644 include/i2c/at24.h
>  create mode 100644 include/linux/log2.h
> 
> Best Regards,
> J.
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Mon Nov 12 02:40:14 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 12 Nov 2012 08:40:14 +0100
Subject: [PATCH 0/3] i2c fix + prepare for at24 support
In-Reply-To: <20121103204613.GZ29599@game.jcrosoft.org>
References: <20121103204613.GZ29599@game.jcrosoft.org>
Message-ID: <20121112074014.GL10369@pengutronix.de>

On Sat, Nov 03, 2012 at 09:46:13PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> HI,
> 
> 	algo-bit: fix sequential read/write support
> 
> 	i2c: add id_table support
> 	i2c: add i2c_new_dummy
> 
> 	This prepare for the at24 eeprom support
> 
> The following changes since commit 5c90416b6ffb8d4ca7c4bc6aff92578b555cb965:
> 
>   i2c: add versatile support (2012-11-02 02:17:04 +0800)
> 
> are available in the git repository at:
> 
>   git://git.jcrosoft.org/barebox.git delivery/i2c
> 
> for you to fetch changes up to 5526278ac77ecd7109c9c1bbc35d7c74875902e7:
> 
>   i2c: add id_table support (2012-11-03 13:33:54 +0800)

Applied, thanks

Sascha

> 
> ----------------------------------------------------------------
> Jean-Christophe PLAGNIOL-VILLARD (3):
>       i2c: algo-bit add missing acknak
>       i2c: introduce i2c_new_dummy
>       i2c: add id_table support
> 
>  drivers/i2c/algos/i2c-algo-bit.c |   20 ++++++++++++++++++++
>  drivers/i2c/i2c.c                |   45 ++++++++++++++++++++++++++++++++++++++++++++-
>  include/i2c/i2c.h                |    8 ++++++++
>  3 files changed, 72 insertions(+), 1 deletion(-)
> 
> Best Regards,
> J.
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Mon Nov 12 02:42:05 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 12 Nov 2012 08:42:05 +0100
Subject: [PATCH 1/1] eth: register device a pure device
In-Reply-To: <1351954598-10541-1-git-send-email-plagnioj@jcrosoft.com>
References: <1351954598-10541-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <20121112074205.GM10369@pengutronix.de>

On Sat, Nov 03, 2012 at 03:56:38PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> as we do not need to probe them and they have no driver or bus attached
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>

Applied, thanks

Sascha

> ---
>  net/eth.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/eth.c b/net/eth.c
> index 2cfdb96..0a1850f 100644
> --- a/net/eth.c
> +++ b/net/eth.c
> @@ -261,7 +261,7 @@ int eth_register(struct eth_device *edev)
>  	if (edev->parent)
>  		dev_add_child(edev->parent, &edev->dev);
>  
> -	platform_device_register(&edev->dev);
> +	register_device(&edev->dev);
>  
>  	dev_add_param(dev, "ipaddr", eth_set_ipaddr, NULL, 0);
>  	dev_add_param(dev, "ethaddr", eth_set_ethaddr, NULL, 0);
> -- 
> 1.7.10.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Mon Nov 12 02:43:07 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 12 Nov 2012 08:43:07 +0100
Subject: [PATCH 1/1] at91sam9x5ek: add at24c512 support
In-Reply-To: <1351976522-9785-1-git-send-email-plagnioj@jcrosoft.com>
References: <1351976522-9785-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <20121112074307.GN10369@pengutronix.de>

On Sat, Nov 03, 2012 at 10:02:02PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
> ---
> Hi,
> 
> 	this depends on the at24 support patch serie + at91sam9x5ek add i2c
> 	with qt1070 support
> 
> The following changes since commit 9277684dbac6ae0b66f23bcb730a9737d22a335c:
> 
>   eeprom: add at24 support (2012-11-03 13:41:58 +0800)
> 
> are available in the git repository at:
> 
>   git://git.jcrosoft.org/barebox.git delivery/at91_i2c
> 
> for you to fetch changes up to 706c6d5c382803959e89218bb0ffb0890cf885cd:
> 
>   at91sam9x5ek: add at24c512 support (2012-11-03 13:44:16 +0800)

Applied, thanks

Sascha

> 
> Jean-Christophe PLAGNIOL-VILLARD (1):
>       at91sam9x5ek: add at24c512 support
> 
>  arch/arm/boards/at91sam9x5ek/init.c     |    2 ++
>  arch/arm/configs/at91sam9x5ek_defconfig |    1 +
>  2 files changed, 3 insertions(+)
> 
> Best Regards,
> J.
> 
> diff --git a/arch/arm/boards/at91sam9x5ek/init.c b/arch/arm/boards/at91sam9x5ek/init.c
> index dbb9bb5..dc8853e 100644
> --- a/arch/arm/boards/at91sam9x5ek/init.c
> +++ b/arch/arm/boards/at91sam9x5ek/init.c
> @@ -122,6 +122,8 @@ static struct i2c_board_info i2c_devices[] = {
>  	{
>  		.platform_data = &qt1070_pdata,
>  		I2C_BOARD_INFO("qt1070", 0x1b),
> +	}, {
> +		I2C_BOARD_INFO("24c512", 0x51)
>  	},
>  };
>  
> diff --git a/arch/arm/configs/at91sam9x5ek_defconfig b/arch/arm/configs/at91sam9x5ek_defconfig
> index 3e66c44..cbbd780 100644
> --- a/arch/arm/configs/at91sam9x5ek_defconfig
> +++ b/arch/arm/configs/at91sam9x5ek_defconfig
> @@ -67,6 +67,7 @@ CONFIG_DISK_WRITE=y
>  CONFIG_LED=y
>  CONFIG_LED_GPIO=y
>  CONFIG_LED_TRIGGERS=y
> +CONFIG_EEPROM_AT24=y
>  CONFIG_KEYBOARD_QT1070=y
>  CONFIG_W1=y
>  CONFIG_W1_MASTER_GPIO=y
> -- 
> 1.7.10.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Mon Nov 12 02:55:36 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 12 Nov 2012 08:55:36 +0100
Subject: defaultenv-2: how to update a flash partition?
In-Reply-To: <CAHkwnC-dDfPesg5vy5V2rj7vdY_DH9cjfJ3gCVsm8xY-DPf35A@mail.gmail.com>
References: <CAHkwnC-dDfPesg5vy5V2rj7vdY_DH9cjfJ3gCVsm8xY-DPf35A@mail.gmail.com>
Message-ID: <20121112075536.GP10369@pengutronix.de>

On Fri, Nov 09, 2012 at 12:06:38PM +0100, Fabio Porcedda wrote:
> Hi all,
> 
> I want to use the defaultenv-2 but i don't find any more the "update"
> command
> like in the defaultenv.
> What is the recommended way to update a flash partition in the new
> environment?

erase /dev/env0
cp /mnt/tftp/your-new-env /dev/env0

(I was thinking about adding a -e parameter to cp to eventually skip the
first step)

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Mon Nov 12 03:33:39 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 12 Nov 2012 09:33:39 +0100
Subject: TX53: Not Bootable from next tree
In-Reply-To: <alpine.LSU.2.00.1211061440560.27068@redbean.intranet.gw-instruments.de>
References: <alpine.LSU.2.00.1211061440560.27068@redbean.intranet.gw-instruments.de>
Message-ID: <20121112083339.GQ10369@pengutronix.de>

On Tue, Nov 06, 2012 at 02:49:06PM +0100, Peter Wippich wrote:
> 
> Hi,
> 
> got the same problem here. Double checked Board Version (8030) and
> that I have the right binary (compressed with flash header). After
> flashing and reset nothing happens....

I'm back in the office now and realized that we have the 1011
revision in our remotelab. That at least explains why I can't reproduce
this issue. Unfortunately I can't find the 8030 revision anywhere in the
office, I'll wait for my collegue.
In the meantime, could you try removing the call to
imx53_init_lowlevel() and try booting 2nd stage (from U-Boot or
redboot)?

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Mon Nov 12 03:36:15 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 12 Nov 2012 09:36:15 +0100
Subject: [PATCH v3 1/2] commands: change Y-Modem implementation
In-Reply-To: <1352409401-3333-1-git-send-email-robert.jarzmik@free.fr>
References: <1352409401-3333-1-git-send-email-robert.jarzmik@free.fr>
Message-ID: <20121112083615.GR10369@pengutronix.de>

On Thu, Nov 08, 2012 at 10:16:40PM +0100, Robert Jarzmik wrote:
> The current Y-Modem implementation has some limitations:
>  - Y-Modem/G protocol is not supported
>  - Multiple files (aka. batch) transfers are not supported
>  - Transfer speed over fast lines (USB console) is slow
>  - Code is not trivial to maintain (personnal opinion)
> 
> This implementation tries to address all these points by
> introducing loady2 command.
> 
> The effects are :
>  - transfer speed for Y-Modem over USB jumps from 2kBytes/s
>    to 180kBytes/s
>  - transfer speed for Y-Modem/G jumps to 200kBytes/s
>  - multiple file transfers are possible
> 
> This command was tested on a USB console and UART 9600bps
> serial line :
>  - NAKs (and retransmissions) were tested for faulty
>    serial lines
>  - multiple file transfers were tested
>  - Y-Modem, Y-Modem/G and X-Modem transfers were tested
> 
> Signed-off-by: Robert Jarzmik <robert.jarzmik at free.fr>
> Tested-by: Antony Pavlov <antonynpavlov at gmail.com>

Applied, thanks

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Mon Nov 12 03:38:19 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 12 Nov 2012 09:38:19 +0100
Subject: [PATCH] omap3_spi: fix bus numbers according to omap3_add_spi[1-4]
In-Reply-To: <1348663120-18758-1-git-send-email-jlu@pengutronix.de>
References: <1348663120-18758-1-git-send-email-jlu@pengutronix.de>
Message-ID: <20121112083819.GS10369@pengutronix.de>

On Wed, Sep 26, 2012 at 02:38:40PM +0200, Jan Luebbe wrote:
> Signed-off-by: Jan Luebbe <jlu at pengutronix.de>
> ---
>  drivers/spi/omap3_spi.c |   14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)

Applied, thanks

Sascha

> 
> diff --git a/drivers/spi/omap3_spi.c b/drivers/spi/omap3_spi.c
> index 3008977..bf98092 100644
> --- a/drivers/spi/omap3_spi.c
> +++ b/drivers/spi/omap3_spi.c
> @@ -327,10 +327,10 @@ static int omap3_spi_setup(struct spi_device *spi)
>  {
>  	struct spi_master *master = spi->master;
>  
> -	if (((master->bus_num == 0) && (spi->chip_select > 3)) ||
> -			((master->bus_num == 1) && (spi->chip_select > 1)) ||
> +	if (((master->bus_num == 1) && (spi->chip_select > 3)) ||
>  			((master->bus_num == 2) && (spi->chip_select > 1)) ||
> -			((master->bus_num == 3) && (spi->chip_select > 0))) {
> +			((master->bus_num == 3) && (spi->chip_select > 1)) ||
> +			((master->bus_num == 4) && (spi->chip_select > 0))) {
>  		printf("SPI error: unsupported chip select %i \
>  			on bus %i\n", spi->chip_select, master->bus_num);
>  		return -EINVAL;
> @@ -363,10 +363,10 @@ static int omap3_spi_probe(struct device_d *dev)
>  	/*
>  	 * OMAP3 McSPI (MultiChannel SPI) has 4 busses (modules)
>  	 * with different number of chip selects (CS, channels):
> -	 * McSPI1 has 4 CS (bus 0, cs 0 - 3)
> -	 * McSPI2 has 2 CS (bus 1, cs 0 - 1)
> -	 * McSPI3 has 2 CS (bus 2, cs 0 - 1)
> -	 * McSPI4 has 1 CS (bus 3, cs 0)
> +	 * McSPI1 has 4 CS (bus 1, cs 0 - 3)
> +	 * McSPI2 has 2 CS (bus 2, cs 0 - 1)
> +	 * McSPI3 has 2 CS (bus 3, cs 0 - 1)
> +	 * McSPI4 has 1 CS (bus 4, cs 0)
>  	 *
>  	 * The board code has to make sure that it does not use
>  	 * invalid buses or chip selects.
> -- 
> 1.7.10.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From fabio.porcedda at gmail.com  Mon Nov 12 05:29:07 2012
From: fabio.porcedda at gmail.com (Fabio Porcedda)
Date: Mon, 12 Nov 2012 11:29:07 +0100
Subject: [PATCH] ARM pbl: add generated file zbarebox.map to .gitignore
Message-ID: <1352716147-13515-1-git-send-email-fabio.porcedda@gmail.com>

Signed-off-by: Fabio Porcedda <fabio.porcedda at gmail.com>
---
 arch/arm/pbl/.gitignore | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/pbl/.gitignore b/arch/arm/pbl/.gitignore
index 3384d8b..d71bb7c 100644
--- a/arch/arm/pbl/.gitignore
+++ b/arch/arm/pbl/.gitignore
@@ -3,3 +3,4 @@ piggy.lzo
 zbarebox
 zbarebox.bin
 zbarebox.lds
+zbarebox.map
-- 
1.8.0



From pewi at gw-instruments.de  Mon Nov 12 06:22:33 2012
From: pewi at gw-instruments.de (Peter Wippich)
Date: Mon, 12 Nov 2012 12:22:33 +0100 (CET)
Subject: TX53: Not Bootable from next tree
In-Reply-To: <20121112083339.GQ10369@pengutronix.de>
References: <alpine.LSU.2.00.1211061440560.27068@redbean.intranet.gw-instruments.de>
 <20121112083339.GQ10369@pengutronix.de>
Message-ID: <alpine.LSU.2.00.1211121220380.14365@redbean.intranet.gw-instruments.de>




On Mon, 12 Nov 2012, Sascha Hauer wrote:

> On Tue, Nov 06, 2012 at 02:49:06PM +0100, Peter Wippich wrote:
>>
>> Hi,
>>
>> got the same problem here. Double checked Board Version (8030) and
>> that I have the right binary (compressed with flash header). After
>> flashing and reset nothing happens....
>
> I'm back in the office now and realized that we have the 1011
> revision in our remotelab. That at least explains why I can't reproduce
> this issue. Unfortunately I can't find the 8030 revision anywhere in the
> office, I'll wait for my collegue.
> In the meantime, could you try removing the call to
> imx53_init_lowlevel() and try booting 2nd stage (from U-Boot or
> redboot)?
>
> Sascha


Hi Sascha,

bad enough my test board is out for some customer tests. I'll try a second 
stage boot as soon as it is back.

Best regards,

Peter


>
> -- 
> Pengutronix e.K.                           |                             |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
>


|       Peter Wippich                   Voice: +49 30 46776411          |
|       G&W Instruments GmbH            fax:   +49 30 46776419          |
|       Gustav-Meyer-Allee 25, Geb. 12  Email: pewi at gw-instruments.de   |
|       D-13355 Berlin  / Germany                                       |



From christian.kapeller at cmotion.eu  Mon Nov 12 08:02:01 2012
From: christian.kapeller at cmotion.eu (Christian Kapeller)
Date: Mon, 12 Nov 2012 14:02:01 +0100
Subject: TX53: Not Bootable from next tree
In-Reply-To: <20121112083339.GQ10369@pengutronix.de>
References: <alpine.LSU.2.00.1211061440560.27068@redbean.intranet.gw-instruments.de>
 <20121112083339.GQ10369@pengutronix.de>
Message-ID: <50A0F349.6070008@cmotion.eu>

Hi,

> In the meantime, could you try removing the call to
> imx53_init_lowlevel() and try booting 2nd stage (from U-Boot or
> redboot)?

2nd stage booting TX83-8030 from redboot works with and without call to
imx53_init_lowlevel (boards/karo-tx53/lowlevel.c)

I've also looked at the DCD sequence at the beginning of the redboot and
bb (CONFIG_PBL=y) binaries and saw, that what set's them appart is:

flash_header.entry RB: 0x8FFC0000
flash_header.entry BB: 0x71000000

flash_header.boot_data_size = 0x1fd87;
flash_header.boot_data_size = 0x40000;


Barebox has an additional DCD Item compared to redboot:

arch/arm/boards/karo-tx53/dcd-data-xx30.h line 15:
DCD_NAME_XX30[] = {
	DCD_WR_CMD(0x21c),
	DCD_ITEM(0x53fd4068, 0xffcc0fff),
	DCD_ITEM(0x53fd406c, 0x000fffc3),


The DCD_WR_CMD(0x21c) duplicates the the last entries of the
flash_header_section structure:

arch/arm/boards/karo-tx53/flash_header.h line 68:
	.dcd.command.tag	= DCD_COMMAND_WRITE_TAG,
#ifdef CONFIG_TX53_REV_1011
	.dcd.command.length	= cpu_to_be16(sizeof(struct imx_dcd_command) +
sizeof(dcd_entry)),
#elif defined(CONFIG_TX53_REV_XX30)
	.dcd.command.length	= cpu_to_be16(0x21c),

So the DCD_WR_CMD(0x21c) seems to be superfluous.



I've adjusted entry address, the boot_data_size, and removed the
DCD_WR_CMD entry, to match the flash header to that of redboot, and
flashed that. That didn't show any improvement.

Also here the situation is the same with and without imx53_init_lowlevel.


Cheers,
Christian


-- 
Christian Kapeller
cmotion GmbH
Kriehubergasse 16
1050 Wien / Austria
http://www.cmotion.eu

christian.kapeller at cmotion.eu
Phone: +43 1 789 1096 38


From franck.jullien at gmail.com  Mon Nov 12 16:16:31 2012
From: franck.jullien at gmail.com (Franck Jullien)
Date: Mon, 12 Nov 2012 22:16:31 +0100
Subject: [PATCH] mci_spi: always compute command crc byte
Message-ID: <1352754991-11660-1-git-send-email-franck.jullien@gmail.com>

The spec says: "the CMD8 CRC verification is always enabled.
The Host shall set correct CRC in the argument ofCMD8. If
CRC error is detected, card returns CRC error in R1 response
regardless of command index."

Make it simple, and compute crc on every commands.

Signed-off-by: Franck Jullien <franck.jullien at gmail.com>
---
 drivers/mci/Kconfig   |    2 +-
 drivers/mci/mci_spi.c |   12 ------------
 2 files changed, 1 insertions(+), 13 deletions(-)

diff --git a/drivers/mci/Kconfig b/drivers/mci/Kconfig
index b1a678e..5c0ca4d 100644
--- a/drivers/mci/Kconfig
+++ b/drivers/mci/Kconfig
@@ -88,6 +88,7 @@ config MCI_ATMEL
 
 config MCI_SPI
 	bool "MMC/SD over SPI"
+	select CRC7
 	depends on SPI
 	help
 	  Some systems access MMC/SD/SDIO cards using a SPI controller
@@ -98,7 +99,6 @@ config MCI_SPI
 
 config MMC_SPI_CRC_ON
 	bool "Enable CRC protection for transfers"
-	select CRC7
 	select CRC16
 	depends on MCI_SPI
 	help
diff --git a/drivers/mci/mci_spi.c b/drivers/mci/mci_spi.c
index 5894104..cb5e0bb 100644
--- a/drivers/mci/mci_spi.c
+++ b/drivers/mci/mci_spi.c
@@ -121,14 +121,6 @@ mmc_spi_writebytes(struct mmc_spi_host *host, unsigned len, void *data)
 	return status;
 }
 
-/*
- * Note that while the CRC, in general, is ignored in SPI mode, the very first
- * command must be followed by a valid CRC, since the card is not yet in SPI mode.
- * The CRC byte for a CMD0 command with a zero argument is a constant 0x4A. For
- * simplicity, this CRC byte is always sent with every command.
- */
-#define MMC_SPI_CMD0_CRC	((0x4a << 1) | 0x1)
-
 static int mmc_spi_command_send(struct mmc_spi_host *host, struct mci_cmd *cmd)
 {
 	uint8_t r1;
@@ -141,11 +133,7 @@ static int mmc_spi_command_send(struct mmc_spi_host *host, struct mci_cmd *cmd)
 	command[3] = cmd->cmdarg >> 16;
 	command[4] = cmd->cmdarg >> 8;
 	command[5] = cmd->cmdarg;
-#ifdef CONFIG_MMC_SPI_CRC_ON
 	command[6] = (crc7(0, &command[1], 5) << 1) | 0x01;
-#else
-	command[6] = MMC_SPI_CMD0_CRC;
-#endif
 
 	mmc_spi_writebytes(host, 7, command);
 
-- 
1.7.1



From fabio.porcedda at gmail.com  Tue Nov 13 06:10:45 2012
From: fabio.porcedda at gmail.com (Fabio Porcedda)
Date: Tue, 13 Nov 2012 12:10:45 +0100
Subject: defaultenv-2: how to update a flash partition?
In-Reply-To: <20121112075536.GP10369@pengutronix.de>
References: <CAHkwnC-dDfPesg5vy5V2rj7vdY_DH9cjfJ3gCVsm8xY-DPf35A@mail.gmail.com>
 <20121112075536.GP10369@pengutronix.de>
Message-ID: <CAHkwnC_FXJ3reNcwDuxhsC=fSG-dDSgg+7njS5sy7aCG5QCRoQ@mail.gmail.com>

On Mon, Nov 12, 2012 at 8:55 AM, Sascha Hauer <s.hauer at pengutronix.de>wrote:

> On Fri, Nov 09, 2012 at 12:06:38PM +0100, Fabio Porcedda wrote:
> > Hi all,
> >
> > I want to use the defaultenv-2 but i don't find any more the "update"
> > command
> > like in the defaultenv.
> > What is the recommended way to update a flash partition in the new
> > environment?
>
> erase /dev/env0
> cp /mnt/tftp/your-new-env /dev/env0
>
>
Thanks, it worked.


> (I was thinking about adding a -e parameter to cp to eventually skip the
> first step)
>

It seems a nice addition for me.

There is some plane in the future to add a "update" command, like in
"defaultenv"?

Thanks for the help and the great work with barebox, i like it very much.
-- 
Fabio Porcedda
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/barebox/attachments/20121113/5502ccc7/attachment.html>

From thomas.petazzoni at free-electrons.com  Tue Nov 13 09:45:23 2012
From: thomas.petazzoni at free-electrons.com (Thomas Petazzoni)
Date: Tue, 13 Nov 2012 15:45:23 +0100
Subject: [PATCH 2/8] atmel_spi: split transfert to atmel_spi_do_xfer
In-Reply-To: <1352230416-9396-2-git-send-email-plagnioj@jcrosoft.com>
References: <20121106193010.GE25679@game.jcrosoft.org>
 <1352230416-9396-1-git-send-email-plagnioj@jcrosoft.com>
 <1352230416-9396-2-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <20121113154523.75dbe972@skate>

Hello,

Just some stupid nitpicks:

atmel_spi: split transfert to atmel_spi_do_xfer

should probably be:

atmel_spi: move transfer code into a separate atmel_spi_do_xfer function

On Tue,  6 Nov 2012 20:33:30 +0100, Jean-Christophe PLAGNIOL-VILLARD
wrote:
> This make the code mre readable

       makes         more

Thomas
-- 
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com


From plagnioj at jcrosoft.com  Tue Nov 13 13:00:01 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Tue, 13 Nov 2012 19:00:01 +0100
Subject: [PATCH 1/1] phylib: add fixup support
Message-ID: <1352829601-5352-1-git-send-email-plagnioj@jcrosoft.com>

if board need specific phy fixup they can register it and then the code will
executed only if needed

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/net/phy/mdio_bus.c |   19 +++++----
 drivers/net/phy/phy.c      |   96 ++++++++++++++++++++++++++++++++++++++++++++
 include/linux/phy.h        |   18 +++++++++
 3 files changed, 125 insertions(+), 8 deletions(-)

diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 35319b4..e36641e 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -153,6 +153,7 @@ static int mdio_bus_probe(struct device_d *_dev)
 	struct phy_device *dev = to_phy_device(_dev);
 	struct phy_driver *drv = to_phy_driver(_dev->driver);
 
+	int ret;
 	char str[16];
 
 	dev->attached_dev->phydev = dev;
@@ -160,14 +161,9 @@ static int mdio_bus_probe(struct device_d *_dev)
 	dev_add_child(dev->dev.parent, _dev);
 
 	if (drv->probe) {
-		int ret;
-
 		ret = drv->probe(dev);
-		if (ret) {
-			dev->attached_dev->phydev = NULL;
-			dev->attached_dev = NULL;
-			return ret;
-		}
+		if (ret)
+			goto err;
 	}
 
 	if (dev->dev_flags) {
@@ -184,7 +180,9 @@ static int mdio_bus_probe(struct device_d *_dev)
 	dev->supported = drv->features;
 	dev->advertising = drv->features;
 
-	drv->config_init(dev);
+	ret = phy_init_hw(dev);
+	if (ret)
+		goto err;
 
 	/* Sanitize settings based on PHY capabilities */
 	if ((dev->supported & SUPPORTED_Autoneg) == 0)
@@ -201,6 +199,11 @@ static int mdio_bus_probe(struct device_d *_dev)
 	devfs_create(&dev->cdev);
 
 	return 0;
+
+err:
+	dev->attached_dev->phydev = NULL;
+	dev->attached_dev = NULL;
+	return ret;
 }
 
 static void mdio_bus_remove(struct device_d *_dev)
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 8d36300..7bd4003 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -53,6 +53,87 @@ int phy_update_status(struct phy_device *dev)
 	return 0;
 }
 
+static LIST_HEAD(phy_fixup_list);
+
+/*
+ * Creates a new phy_fixup and adds it to the list
+ * @bus_id: A string which matches phydev->dev.bus_id (or PHY_ANY_ID)
+ * @phy_uid: Used to match against phydev->phy_id (the UID of the PHY)
+ * 	It can also be PHY_ANY_UID
+ * @phy_uid_mask: Applied to phydev->phy_id and fixup->phy_uid before
+ * 	comparison
+ * @run: The actual code to be run when a matching PHY is found
+ */
+int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask,
+		int (*run)(struct phy_device *))
+{
+	struct phy_fixup *fixup;
+
+	fixup = kzalloc(sizeof(struct phy_fixup), GFP_KERNEL);
+	if (!fixup)
+		return -ENOMEM;
+
+	strlcpy(fixup->bus_id, bus_id, sizeof(fixup->bus_id));
+	fixup->phy_uid = phy_uid;
+	fixup->phy_uid_mask = phy_uid_mask;
+	fixup->run = run;
+
+	list_add_tail(&fixup->list, &phy_fixup_list);
+
+	return 0;
+}
+
+/* Registers a fixup to be run on any PHY with the UID in phy_uid */
+int phy_register_fixup_for_uid(u32 phy_uid, u32 phy_uid_mask,
+		int (*run)(struct phy_device *))
+{
+	return phy_register_fixup(PHY_ANY_ID, phy_uid, phy_uid_mask, run);
+}
+
+/* Registers a fixup to be run on the PHY with id string bus_id */
+int phy_register_fixup_for_id(const char *bus_id,
+		int (*run)(struct phy_device *))
+{
+	return phy_register_fixup(bus_id, PHY_ANY_UID, 0xffffffff, run);
+}
+
+/*
+ * Returns 1 if fixup matches phydev in bus_id and phy_uid.
+ * Fixups can be set to match any in one or more fields.
+ */
+static int phy_needs_fixup(struct phy_device *phydev, struct phy_fixup *fixup)
+{
+	if (strcmp(fixup->bus_id, dev_name(&phydev->dev)) != 0)
+		if (strcmp(fixup->bus_id, PHY_ANY_ID) != 0)
+			return 0;
+
+	if ((fixup->phy_uid & fixup->phy_uid_mask) !=
+			(phydev->phy_id & fixup->phy_uid_mask))
+		if (fixup->phy_uid != PHY_ANY_UID)
+			return 0;
+
+	return 1;
+}
+/* Runs any matching fixups for this phydev */
+int phy_scan_fixups(struct phy_device *phydev)
+{
+	struct phy_fixup *fixup;
+
+	list_for_each_entry(fixup, &phy_fixup_list, list) {
+		if (phy_needs_fixup(phydev, fixup)) {
+			int err;
+
+			err = fixup->run(phydev);
+
+			if (err < 0) {
+				return err;
+			}
+		}
+	}
+
+	return 0;
+}
+
 struct phy_device *phy_device_create(struct mii_bus *bus, int addr, int phy_id)
 {
 	struct phy_device *dev;
@@ -581,3 +662,18 @@ int phy_driver_register(struct phy_driver *phydrv)
 
 	return register_driver(&phydrv->drv);
 }
+
+int phy_init_hw(struct phy_device *phydev)
+{
+	struct phy_driver *phydrv = to_phy_driver(phydev->dev.driver);
+	int ret;
+
+	if (!phydrv || !phydrv->config_init)
+		return 0;
+
+	ret = phy_scan_fixups(phydev);
+	if (ret < 0)
+		return ret;
+
+	return phydrv->config_init(phydev);
+}
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 76f9edb..fa21984 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -225,9 +225,19 @@ struct phy_driver {
 #define PHY_ANY_ID "MATCH ANY PHY"
 #define PHY_ANY_UID 0xffffffff
 
+/* A Structure for boards to register fixups with the PHY Lib */
+struct phy_fixup {
+	struct list_head list;
+	char bus_id[20];
+	u32 phy_uid;
+	u32 phy_uid_mask;
+	int (*run)(struct phy_device *phydev);
+};
+
 int phy_driver_register(struct phy_driver *drv);
 struct phy_device *get_phy_device(struct mii_bus *bus, int addr);
 int phy_init(void);
+int phy_init_hw(struct phy_device *phydev);
 
 /**
  * phy_read - Convenience function for reading a given PHY register
@@ -265,5 +275,13 @@ int genphy_config_advert(struct phy_device *phydev);
 int genphy_setup_forced(struct phy_device *phydev);
 int get_phy_id(struct mii_bus *bus, int addr, u32 *phy_id);
 
+int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask,
+		int (*run)(struct phy_device *));
+int phy_register_fixup_for_id(const char *bus_id,
+		int (*run)(struct phy_device *));
+int phy_register_fixup_for_uid(u32 phy_uid, u32 phy_uid_mask,
+		int (*run)(struct phy_device *));
+int phy_scan_fixups(struct phy_device *phydev);
+
 extern struct bus_type mdio_bus_type;
 #endif /* __PHYDEV_H__ */
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Tue Nov 13 15:02:48 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Tue, 13 Nov 2012 21:02:48 +0100
Subject: [PATCH 0/4] mci-spi fix
Message-ID: <20121113200248.GG25679@game.jcrosoft.org>

HI,

	THis patch series fix multiple issue on mci-issue
	 - sd version 2.0 support
	 - clock frequency support
	 - sanity check
	 - always compute crc on command

	 it include a patch from Franck

The following changes since commit d74bef2b04a3ccf7339ba916e56830bb2feae957:

  mount: add compatibility to old mount command (2012-11-02 21:26:29 +0100)

are available in the git repository at:

  git://git.jcrosoft.org/barebox.git delivery/mci_spi

for you to fetch changes up to 84368c260b7cf78fe3006368d4a5fa06e722eacf:

  mci_spi: add clock frequency change support (2012-11-12 08:50:20 +0800)

----------------------------------------------------------------
Franck Jullien (1):
      mci_spi: always compute command crc byte

Jean-Christophe PLAGNIOL-VILLARD (3):
      mci-core: spi fix op cond support
      mci_spi: add sanity check
      mci_spi: add clock frequency change support

 drivers/mci/Kconfig    |    2 +-
 drivers/mci/mci-core.c |   10 +++++++---
 drivers/mci/mci_spi.c  |   52 +++++++++++++++++++++++++++++++++++++++-------------
 3 files changed, 47 insertions(+), 17 deletions(-)

Best Regards,
J.


From plagnioj at jcrosoft.com  Tue Nov 13 15:07:20 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Tue, 13 Nov 2012 21:07:20 +0100
Subject: [PATCH 3/4] mci_spi: add sanity check
In-Reply-To: <1352837241-16777-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121113200248.GG25679@game.jcrosoft.org>
 <1352837241-16777-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1352837241-16777-3-git-send-email-plagnioj@jcrosoft.com>

as in linux

SD/MMC support only mode 0 or 3 (if 0 not supported by the spi master)
so if the mode is not 3 force 0

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/mci/mci_spi.c |   11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/mci/mci_spi.c b/drivers/mci/mci_spi.c
index cb5e0bb..08939be 100644
--- a/drivers/mci/mci_spi.c
+++ b/drivers/mci/mci_spi.c
@@ -366,6 +366,7 @@ static int spi_mci_probe(struct device_d *dev)
 	struct spi_device	*spi = (struct spi_device *)dev->type_data;
 	struct mmc_spi_host	*host;
 	void			*ones;
+	int			status;
 
 	host = xzalloc(sizeof(*host));
 	host->mci.send_cmd = mmc_spi_request;
@@ -373,6 +374,16 @@ static int spi_mci_probe(struct device_d *dev)
 	host->mci.init = mmc_spi_init;
 	host->mci.hw_dev = dev;
 
+	/* MMC and SD specs only seem to care that sampling is on the
+	 * rising edge ... meaning SPI modes 0 or 3.  So either SPI mode
+	 * should be legit.  We'll use mode 0 since the steady state is 0,
+	 * which is appropriate for hotplugging, unless the platform data
+	 * specify mode 3 (if hardware is not compatible to mode 0).
+	 */
+	if (spi->mode != SPI_MODE_3)
+		spi->mode = SPI_MODE_0;
+	spi->bits_per_word = 8;
+
 	host->dev = dev;
 	host->spi = spi;
 	dev->priv = host;
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Tue Nov 13 15:07:19 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Tue, 13 Nov 2012 21:07:19 +0100
Subject: [PATCH 2/4] mci-core: spi fix op cond support
In-Reply-To: <1352837241-16777-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121113200248.GG25679@game.jcrosoft.org>
 <1352837241-16777-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1352837241-16777-2-git-send-email-plagnioj@jcrosoft.com>

so we can detect sd card version 2.0 on spi

as we need to the OCR_HCS on version 2.0 regardless if it's a SPI or not

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/mci/mci-core.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 216a8a5..d006869 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -222,6 +222,7 @@ static int sd_send_op_cond(struct mci *mci)
 	int err;
 	unsigned voltages;
 	unsigned busy;
+	unsigned arg;
 
 	/*
 	 * Most cards do not answer if some reserved bits
@@ -240,9 +241,12 @@ static int sd_send_op_cond(struct mci *mci)
 			return err;
 		}
 
-		mci_setup_cmd(&cmd, SD_CMD_APP_SEND_OP_COND,
-			mmc_host_is_spi(host) ? 0 : (voltages | (mci->version == SD_VERSION_2 ? OCR_HCS : 0)),
-			MMC_RSP_R3);
+		arg = mmc_host_is_spi(host) ? 0 : voltages;
+
+		if (mci->version == SD_VERSION_2)
+			arg |= OCR_HCS;
+
+		mci_setup_cmd(&cmd, SD_CMD_APP_SEND_OP_COND, arg, MMC_RSP_R3);
 		err = mci_send_cmd(mci, &cmd, NULL);
 		if (err) {
 			dev_dbg(mci->mci_dev, "SD operation condition set failed: %d\n", err);
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Tue Nov 13 15:07:18 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Tue, 13 Nov 2012 21:07:18 +0100
Subject: [PATCH 1/4] mci_spi: always compute command crc byte
In-Reply-To: <20121113200248.GG25679@game.jcrosoft.org>
References: <20121113200248.GG25679@game.jcrosoft.org>
Message-ID: <1352837241-16777-1-git-send-email-plagnioj@jcrosoft.com>

From: Franck Jullien <franck.jullien at gmail.com>

The spec says: "the CMD8 CRC verification is always enabled.
The Host shall set correct CRC in the argument ofCMD8. If
CRC error is detected, card returns CRC error in R1 response
regardless of command index."

Make it simple, and compute crc on every commands.

Signed-off-by: Franck Jullien <franck.jullien at gmail.com>
---
 drivers/mci/Kconfig   |    2 +-
 drivers/mci/mci_spi.c |   12 ------------
 2 files changed, 1 insertion(+), 13 deletions(-)

diff --git a/drivers/mci/Kconfig b/drivers/mci/Kconfig
index b1a678e..5c0ca4d 100644
--- a/drivers/mci/Kconfig
+++ b/drivers/mci/Kconfig
@@ -88,6 +88,7 @@ config MCI_ATMEL
 
 config MCI_SPI
 	bool "MMC/SD over SPI"
+	select CRC7
 	depends on SPI
 	help
 	  Some systems access MMC/SD/SDIO cards using a SPI controller
@@ -98,7 +99,6 @@ config MCI_SPI
 
 config MMC_SPI_CRC_ON
 	bool "Enable CRC protection for transfers"
-	select CRC7
 	select CRC16
 	depends on MCI_SPI
 	help
diff --git a/drivers/mci/mci_spi.c b/drivers/mci/mci_spi.c
index 5894104..cb5e0bb 100644
--- a/drivers/mci/mci_spi.c
+++ b/drivers/mci/mci_spi.c
@@ -121,14 +121,6 @@ mmc_spi_writebytes(struct mmc_spi_host *host, unsigned len, void *data)
 	return status;
 }
 
-/*
- * Note that while the CRC, in general, is ignored in SPI mode, the very first
- * command must be followed by a valid CRC, since the card is not yet in SPI mode.
- * The CRC byte for a CMD0 command with a zero argument is a constant 0x4A. For
- * simplicity, this CRC byte is always sent with every command.
- */
-#define MMC_SPI_CMD0_CRC	((0x4a << 1) | 0x1)
-
 static int mmc_spi_command_send(struct mmc_spi_host *host, struct mci_cmd *cmd)
 {
 	uint8_t r1;
@@ -141,11 +133,7 @@ static int mmc_spi_command_send(struct mmc_spi_host *host, struct mci_cmd *cmd)
 	command[3] = cmd->cmdarg >> 16;
 	command[4] = cmd->cmdarg >> 8;
 	command[5] = cmd->cmdarg;
-#ifdef CONFIG_MMC_SPI_CRC_ON
 	command[6] = (crc7(0, &command[1], 5) << 1) | 0x01;
-#else
-	command[6] = MMC_SPI_CMD0_CRC;
-#endif
 
 	mmc_spi_writebytes(host, 7, command);
 
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Tue Nov 13 15:07:21 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Tue, 13 Nov 2012 21:07:21 +0100
Subject: [PATCH 4/4] mci_spi: add clock frequency change support
In-Reply-To: <1352837241-16777-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121113200248.GG25679@game.jcrosoft.org>
 <1352837241-16777-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1352837241-16777-4-git-send-email-plagnioj@jcrosoft.com>

setup the spi master correctly

provide f_min and f_max

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/mci/mci_spi.c |   29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/drivers/mci/mci_spi.c b/drivers/mci/mci_spi.c
index 08939be..679a0e1 100644
--- a/drivers/mci/mci_spi.c
+++ b/drivers/mci/mci_spi.c
@@ -318,7 +318,15 @@ static void mmc_spi_set_ios(struct mci_host *mci, struct mci_ios *ios)
 {
 	struct mmc_spi_host	*host = to_spi_host(mci);
 
-	spi_setup(host->spi);
+	if (host->spi->max_speed_hz != ios->clock && ios->clock != 0) {
+		int		status;
+
+		host->spi->max_speed_hz = ios->clock;
+		status = spi_setup(host->spi);
+		dev_dbg(&host->spi->dev,
+			"mmc_spi:  clock to %d Hz, %d\n",
+			host->spi->max_speed_hz, status);
+	}
 }
 
 static int mmc_spi_init(struct mci_host *mci, struct device_d *mci_dev)
@@ -384,6 +392,25 @@ static int spi_mci_probe(struct device_d *dev)
 		spi->mode = SPI_MODE_0;
 	spi->bits_per_word = 8;
 
+	status = spi_setup(spi);
+	if (status < 0) {
+		dev_dbg(&spi->dev, "needs SPI mode %02x, %d KHz; %d\n",
+				spi->mode, spi->max_speed_hz / 1000,
+				status);
+		return status;
+	}
+
+	/* SPI doesn't need the lowspeed device identification thing for
+	 * MMC or SD cards, since it never comes up in open drain mode.
+	 * That's good; some SPI masters can't handle very low speeds!
+	 *
+	 * However, low speed SDIO cards need not handle over 400 KHz;
+	 * that's the only reason not to use a few MHz for f_min (until
+	 * the upper layer reads the target frequency from the CSD).
+	 */
+	host->mci.f_min = 400000;
+	host->mci.f_max = spi->max_speed_hz;
+
 	host->dev = dev;
 	host->spi = spi;
 	dev->priv = host;
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Tue Nov 13 16:13:16 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Tue, 13 Nov 2012 22:13:16 +0100
Subject: [PATCH 1/3] at91sam9: add detection of low power sdram
Message-ID: <1352841198-22595-1-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/mach-at91/include/mach/at91sam9_sdramc.h |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/mach-at91/include/mach/at91sam9_sdramc.h b/arch/arm/mach-at91/include/mach/at91sam9_sdramc.h
index 1ab61e9..971a772 100644
--- a/arch/arm/mach-at91/include/mach/at91sam9_sdramc.h
+++ b/arch/arm/mach-at91/include/mach/at91sam9_sdramc.h
@@ -110,6 +110,11 @@ static inline u32 at91_get_sdram_size(void)
 
 	return size;
 }
+
+static inline bool at91_is_low_power_sdram(void)
+{
+	return at91_sys_read(AT91_SDRAMC_MDR) & AT91_SDRAMC_MD_LOW_POWER_SDRAM;
+}
 #endif
 
 #endif
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Tue Nov 13 16:13:18 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Tue, 13 Nov 2012 22:13:18 +0100
Subject: [PATCH 3/3] tny-a9g20: add mmc spi support
In-Reply-To: <1352841198-22595-1-git-send-email-plagnioj@jcrosoft.com>
References: <1352841198-22595-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1352841198-22595-3-git-send-email-plagnioj@jcrosoft.com>

on the 9g20 low power version we have a mmc spi as microSD

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/boards/tny-a926x/init.c     |   41 ++++++++++++++++++++++++++++------
 arch/arm/configs/tny_a9g20_defconfig |    5 +++++
 2 files changed, 39 insertions(+), 7 deletions(-)

diff --git a/arch/arm/boards/tny-a926x/init.c b/arch/arm/boards/tny-a926x/init.c
index ce36570..270becf 100644
--- a/arch/arm/boards/tny-a926x/init.c
+++ b/arch/arm/boards/tny-a926x/init.c
@@ -31,6 +31,7 @@
 #include <linux/clk.h>
 #include <mach/board.h>
 #include <mach/at91sam9_smc.h>
+#include <mach/at91sam9_sdramc.h>
 #include <mach/sam9_smc.h>
 #include <gpio.h>
 #include <mach/io.h>
@@ -151,12 +152,27 @@ static struct spi_board_info tny_a9g20_spi_devices[] = {
 	},
 };
 
+static struct spi_board_info tny_a9g20_lpw_spi_devices[] = {
+	{
+		.name = "spi_mci",
+		.max_speed_hz = 25 * 1000 * 1000,
+		.bus_num = 1,
+		.chip_select = 0,
+	},
+};
+
 static int spi0_standard_cs[] = { AT91_PIN_PC11 };
-struct at91_spi_platform_data spi_pdata = {
+struct at91_spi_platform_data spi0_pdata = {
 	.chipselect = spi0_standard_cs,
 	.num_chipselect = ARRAY_SIZE(spi0_standard_cs),
 };
 
+static int spi1_standard_cs[] = { AT91_PIN_PC3 };
+struct at91_spi_platform_data spi1_pdata = {
+	.chipselect = spi1_standard_cs,
+	.num_chipselect = ARRAY_SIZE(spi1_standard_cs),
+};
+
 static void __init ek_add_device_udc(void)
 {
 	if (machine_is_tny_a9260() || machine_is_tny_a9g20())
@@ -165,6 +181,22 @@ static void __init ek_add_device_udc(void)
 	at91_add_device_udc(&ek_udc_data);
 }
 
+static void __init ek_add_device_spi(void)
+{
+	if (machine_is_tny_a9263())
+		return;
+
+	if (machine_is_tny_a9g20() && at91_is_low_power_sdram()) {
+		spi_register_board_info(tny_a9g20_lpw_spi_devices,
+			ARRAY_SIZE(tny_a9g20_lpw_spi_devices));
+		at91_add_device_spi(1, &spi1_pdata);
+	} else {
+		spi_register_board_info(tny_a9g20_spi_devices,
+			ARRAY_SIZE(tny_a9g20_spi_devices));
+		at91_add_device_spi(0, &spi0_pdata);
+	}
+}
+
 static int tny_a9260_mem_init(void)
 {
 	at91_add_device_sdram(0);
@@ -178,16 +210,11 @@ static int tny_a9260_devices_init(void)
 	tny_a9260_add_device_nand();
 	ek_add_device_macb();
 	ek_add_device_udc();
+	ek_add_device_spi();
 
 	armlinux_set_bootparams((void *)(AT91_CHIPSELECT_1 + 0x100));
 	tny_a9260_set_board_type();
 
-	if (machine_is_tny_a9260() || machine_is_tny_a9g20()) {
-		spi_register_board_info(tny_a9g20_spi_devices,
-			ARRAY_SIZE(tny_a9g20_spi_devices));
-		at91_add_device_spi(0, &spi_pdata);
-	}
-
 	devfs_add_partition("nand0", 0x00000, SZ_128K, DEVFS_PARTITION_FIXED, "at91bootstrap_raw");
 	dev_add_bb_dev("at91bootstrap_raw", "at91bootstrap");
 	devfs_add_partition("nand0", SZ_128K, SZ_256K, DEVFS_PARTITION_FIXED, "self_raw");
diff --git a/arch/arm/configs/tny_a9g20_defconfig b/arch/arm/configs/tny_a9g20_defconfig
index cf5d4c5..a84e90f 100644
--- a/arch/arm/configs/tny_a9g20_defconfig
+++ b/arch/arm/configs/tny_a9g20_defconfig
@@ -51,6 +51,7 @@ CONFIG_CMD_OFTREE=y
 CONFIG_CMD_TIMEOUT=y
 CONFIG_CMD_PARTITION=y
 CONFIG_CMD_GPIO=y
+CONFIG_CMD_SPI=y
 CONFIG_NET=y
 CONFIG_NET_DHCP=y
 CONFIG_NET_NFS=y
@@ -70,4 +71,8 @@ CONFIG_NAND_ATMEL=y
 CONFIG_UBI=y
 CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_SERIAL=y
+CONFIG_MCI=y
+CONFIG_MCI_STARTUP=y
+CONFIG_MCI_SPI=y
+CONFIG_MMC_SPI_CRC_ON=y
 CONFIG_EEPROM_AT25=y
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Tue Nov 13 16:13:17 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Tue, 13 Nov 2012 22:13:17 +0100
Subject: [PATCH 2/3] usb-a9g20: add mmc spi support
In-Reply-To: <1352841198-22595-1-git-send-email-plagnioj@jcrosoft.com>
References: <1352841198-22595-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1352841198-22595-2-git-send-email-plagnioj@jcrosoft.com>

on the 9g20 low power version we have a mmc spi as microSD

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/boards/usb-a926x/init.c            |   37 ++++++++++++++++++++++-----
 arch/arm/configs/usb_a9g20_128mib_defconfig |   10 +++++++-
 arch/arm/configs/usb_a9g20_defconfig        |   10 +++++++-
 3 files changed, 49 insertions(+), 8 deletions(-)

diff --git a/arch/arm/boards/usb-a926x/init.c b/arch/arm/boards/usb-a926x/init.c
index cd0df50..e57591b 100644
--- a/arch/arm/boards/usb-a926x/init.c
+++ b/arch/arm/boards/usb-a926x/init.c
@@ -31,6 +31,7 @@
 #include <linux/clk.h>
 #include <mach/board.h>
 #include <mach/at91sam9_smc.h>
+#include <mach/at91sam9_sdramc.h>
 #include <mach/sam9_smc.h>
 #include <gpio.h>
 #include <led.h>
@@ -158,14 +159,38 @@ static const struct spi_board_info usb_a9263_spi_devices[] = {
 	}
 };
 
+static const struct spi_board_info usb_a9g20_spi_devices[] = {
+	{
+		.name		= "spi_mci",
+		.chip_select	= 0,
+		.max_speed_hz	= 25 * 1000 * 1000,
+		.bus_num	= 1,
+	}
+};
+
+static unsigned spi0_standard_cs_a9263[] = { AT91_PIN_PA5 };
+static struct at91_spi_platform_data spi_a9263_pdata = {
+	.chipselect = spi0_standard_cs_a9263,
+	.num_chipselect = ARRAY_SIZE(spi0_standard_cs_a9263),
+};
+
+static unsigned spi0_standard_cs_a9g20[] = { AT91_PIN_PB3 };
+static struct at91_spi_platform_data spi_a9g20_pdata = {
+	.chipselect = spi0_standard_cs_a9g20,
+	.num_chipselect = ARRAY_SIZE(spi0_standard_cs_a9g20),
+};
+
 static void usb_a9260_add_spi(void)
 {
-	if (!machine_is_usb_a9263())
-		return;
-
-	spi_register_board_info(usb_a9263_spi_devices,
-			ARRAY_SIZE(usb_a9263_spi_devices));
-	at91_add_device_spi(0, NULL);
+	if (machine_is_usb_a9263()) {
+		spi_register_board_info(usb_a9263_spi_devices,
+				ARRAY_SIZE(usb_a9263_spi_devices));
+		at91_add_device_spi(0, &spi_a9263_pdata);
+	} else if (machine_is_usb_a9g20() && at91_is_low_power_sdram()) {
+		spi_register_board_info(usb_a9g20_spi_devices,
+				ARRAY_SIZE(usb_a9g20_spi_devices));
+		at91_add_device_spi(1, &spi_a9g20_pdata);
+	}
 }
 
 #if defined(CONFIG_MCI_ATMEL)
diff --git a/arch/arm/configs/usb_a9g20_128mib_defconfig b/arch/arm/configs/usb_a9g20_128mib_defconfig
index 4a6c933..f4d412c 100644
--- a/arch/arm/configs/usb_a9g20_128mib_defconfig
+++ b/arch/arm/configs/usb_a9g20_128mib_defconfig
@@ -53,6 +53,7 @@ CONFIG_CMD_OFTREE=y
 CONFIG_CMD_TIMEOUT=y
 CONFIG_CMD_PARTITION=y
 CONFIG_CMD_GPIO=y
+CONFIG_CMD_SPI=y
 CONFIG_CMD_LED=y
 CONFIG_CMD_LED_TRIGGER=y
 CONFIG_NET=y
@@ -64,7 +65,7 @@ CONFIG_FS_TFTP=y
 CONFIG_NET_NETCONSOLE=y
 CONFIG_NET_RESOLV=y
 CONFIG_DRIVER_NET_MACB=y
-# CONFIG_SPI is not set
+CONFIG_DRIVER_SPI_ATMEL=y
 CONFIG_MTD=y
 # CONFIG_MTD_OOB_DEVICE is not set
 CONFIG_NAND=y
@@ -76,6 +77,13 @@ CONFIG_UBI=y
 CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_DFU=y
 CONFIG_USB_GADGET_SERIAL=y
+CONFIG_MCI=y
+CONFIG_MCI_STARTUP=y
+CONFIG_MCI_SPI=y
+CONFIG_MMC_SPI_CRC_ON=y
 CONFIG_LED=y
 CONFIG_LED_GPIO=y
 CONFIG_LED_TRIGGERS=y
+CONFIG_FS_FAT=y
+CONFIG_FS_FAT_WRITE=y
+CONFIG_FS_FAT_LFN=y
diff --git a/arch/arm/configs/usb_a9g20_defconfig b/arch/arm/configs/usb_a9g20_defconfig
index e851b9c..3062fb4 100644
--- a/arch/arm/configs/usb_a9g20_defconfig
+++ b/arch/arm/configs/usb_a9g20_defconfig
@@ -52,6 +52,7 @@ CONFIG_CMD_OFTREE=y
 CONFIG_CMD_TIMEOUT=y
 CONFIG_CMD_PARTITION=y
 CONFIG_CMD_GPIO=y
+CONFIG_CMD_SPI=y
 CONFIG_CMD_LED=y
 CONFIG_CMD_LED_TRIGGER=y
 CONFIG_NET=y
@@ -63,7 +64,7 @@ CONFIG_FS_TFTP=y
 CONFIG_NET_NETCONSOLE=y
 CONFIG_NET_RESOLV=y
 CONFIG_DRIVER_NET_MACB=y
-# CONFIG_SPI is not set
+CONFIG_DRIVER_SPI_ATMEL=y
 CONFIG_MTD=y
 # CONFIG_MTD_OOB_DEVICE is not set
 CONFIG_NAND=y
@@ -75,6 +76,13 @@ CONFIG_UBI=y
 CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_DFU=y
 CONFIG_USB_GADGET_SERIAL=y
+CONFIG_MCI=y
+CONFIG_MCI_STARTUP=y
+CONFIG_MCI_SPI=y
+CONFIG_MMC_SPI_CRC_ON=y
 CONFIG_LED=y
 CONFIG_LED_GPIO=y
 CONFIG_LED_TRIGGERS=y
+CONFIG_FS_FAT=y
+CONFIG_FS_FAT_WRITE=y
+CONFIG_FS_FAT_LFN=y
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Tue Nov 13 16:14:05 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Tue, 13 Nov 2012 22:14:05 +0100
Subject: [PATCH 1/1] phy: phy_update_status wait auto neg done when enabled
Message-ID: <1352841245-22767-1-git-send-email-plagnioj@jcrosoft.com>

if the autoneg was start by the hw wait it to be finished

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/net/phy/phy.c |   26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 0c2e602..43738c2 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -28,6 +28,25 @@
 #define PHY_AN_TIMEOUT	10
 
 static int genphy_config_init(struct phy_device *phydev);
+static int phy_aneg_done(struct phy_device *phydev);
+
+static int phy_wait_aneg_read_status(struct phy_device *dev, struct phy_driver *drv)
+{
+	int ret;
+
+	if (AUTONEG_ENABLE != dev->autoneg)
+		return 0;
+
+	ret = phy_aneg_done(dev);
+	if (ret)
+		return ret;
+
+	/*
+	 * re-read the status as the aneg may not be finished
+	 * when we read it the first time
+	 */
+	return drv->read_status(dev);
+}
 
 int phy_update_status(struct phy_device *dev)
 {
@@ -35,11 +54,18 @@ int phy_update_status(struct phy_device *dev)
 	struct eth_device *edev = dev->attached_dev;
 	int ret;
 	int oldspeed = dev->speed, oldduplex = dev->duplex;
+	int old_link = dev->link;
 
 	ret = drv->read_status(dev);
 	if (ret)
 		return ret;
 
+	if (dev->link && !old_link) {
+		ret = phy_wait_aneg_read_status(dev, drv);
+		if (ret)
+			return ret;
+	}
+
 	if (dev->speed == oldspeed && dev->duplex == oldduplex)
 		return 0;
 
-- 
1.7.10.4



From s.hauer at pengutronix.de  Wed Nov 14 03:05:28 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Wed, 14 Nov 2012 09:05:28 +0100
Subject: [PATCH 1/1] phy: phy_update_status wait auto neg done when enabled
In-Reply-To: <1352841245-22767-1-git-send-email-plagnioj@jcrosoft.com>
References: <1352841245-22767-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <20121114080528.GF10369@pengutronix.de>

On Tue, Nov 13, 2012 at 10:14:05PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> if the autoneg was start by the hw wait it to be finished
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
> ---
>  drivers/net/phy/phy.c |   26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
> 
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index 0c2e602..43738c2 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -28,6 +28,25 @@
>  #define PHY_AN_TIMEOUT	10
>  
>  static int genphy_config_init(struct phy_device *phydev);
> +static int phy_aneg_done(struct phy_device *phydev);
> +
> +static int phy_wait_aneg_read_status(struct phy_device *dev, struct phy_driver *drv)
> +{
> +	int ret;
> +
> +	if (AUTONEG_ENABLE != dev->autoneg)
> +		return 0;
> +
> +	ret = phy_aneg_done(dev);
> +	if (ret)
> +		return ret;
> +
> +	/*
> +	 * re-read the status as the aneg may not be finished
> +	 * when we read it the first time
> +	 */
> +	return drv->read_status(dev);
> +}
>  
>  int phy_update_status(struct phy_device *dev)
>  {
> @@ -35,11 +54,18 @@ int phy_update_status(struct phy_device *dev)
>  	struct eth_device *edev = dev->attached_dev;
>  	int ret;
>  	int oldspeed = dev->speed, oldduplex = dev->duplex;
> +	int old_link = dev->link;
>  
>  	ret = drv->read_status(dev);
>  	if (ret)
>  		return ret;
>  
> +	if (dev->link && !old_link) {
> +		ret = phy_wait_aneg_read_status(dev, drv);
> +		if (ret)
> +			return ret;
> +	}

This does not help. dev->link is false after reset, so we never get into
phy_wait_aneg_read_status() which waits for a link.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Wed Nov 14 03:10:51 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Wed, 14 Nov 2012 09:10:51 +0100
Subject: defaultenv-2: how to update a flash partition?
In-Reply-To: <CAHkwnC_FXJ3reNcwDuxhsC=fSG-dDSgg+7njS5sy7aCG5QCRoQ@mail.gmail.com>
References: <CAHkwnC-dDfPesg5vy5V2rj7vdY_DH9cjfJ3gCVsm8xY-DPf35A@mail.gmail.com>
 <20121112075536.GP10369@pengutronix.de>
 <CAHkwnC_FXJ3reNcwDuxhsC=fSG-dDSgg+7njS5sy7aCG5QCRoQ@mail.gmail.com>
Message-ID: <20121114081051.GG10369@pengutronix.de>

On Tue, Nov 13, 2012 at 12:10:45PM +0100, Fabio Porcedda wrote:
> On Mon, Nov 12, 2012 at 8:55 AM, Sascha Hauer <s.hauer at pengutronix.de>wrote:
> 
> > On Fri, Nov 09, 2012 at 12:06:38PM +0100, Fabio Porcedda wrote:
> > > Hi all,
> > >
> > > I want to use the defaultenv-2 but i don't find any more the "update"
> > > command
> > > like in the defaultenv.
> > > What is the recommended way to update a flash partition in the new
> > > environment?
> >
> > erase /dev/env0
> > cp /mnt/tftp/your-new-env /dev/env0
> >
> >
> Thanks, it worked.
> 
> 
> > (I was thinking about adding a -e parameter to cp to eventually skip the
> > first step)
> >
> 
> It seems a nice addition for me.

I'll look into it.

> 
> There is some plane in the future to add a "update" command, like in
> "defaultenv"?

I have no plans doing so. Basically not because I do not want such a
command, but because I do not know what such should do. The old command
took parameters like 'mmc' or 'net' which was hard to dispatch into
the different files and does not work with multiple mmc cards, so I
thought doing it completely on file level would be enough (with the
above additions added, maybe).

> 
> Thanks for the help and the great work with barebox, i like it very much.

Thanks. I appreciate that ;)

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Wed Nov 14 03:21:41 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Wed, 14 Nov 2012 09:21:41 +0100
Subject: [PATCH] replace barebox* in .gitignore with individual files
Message-ID: <1352881301-9744-1-git-send-email-s.hauer@pengutronix.de>

This effectively reverts:

| commit f9df22b002af99532b66360e08128ea3e7e82a97
| Author: Alexander Shiyan <shc_work at mail.ru>
| Date:   Mon Oct 8 10:35:04 2012 +0400
|
|    Add more generated files to .gitignore

barebox* is not limited to the toplevel directory, so this ignores
all files starting with 'barebox' from which we have several we do
not wish to ignore. Add barebox-flash-image to the ignore list which
seemed to be the motivation for the original patch.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
Cc: Alexander Shiyan <shc_work at mail.ru>
---
 .gitignore |   13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/.gitignore b/.gitignore
index 81e74a0..064753d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -26,11 +26,22 @@
 #
 tags
 TAGS
-barebox*
 cross_arch
 cross_compile
+barebox
+barebox.S
+barebox.bin
+barebox.srec
+barebox.netx
+barebox.s5p
+barebox.spi
+barebox.ubl
+barebox.uimage
+barebox.map
+barebox-flash-image
 System.map
 Module.symvers
+barebox_default_env*
 
 #
 # Generated include files
-- 
1.7.10.4



From s.hauer at pengutronix.de  Wed Nov 14 03:23:27 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Wed, 14 Nov 2012 09:23:27 +0100
Subject: [PATCH] ARM pbl: add generated file zbarebox.map to .gitignore
In-Reply-To: <1352716147-13515-1-git-send-email-fabio.porcedda@gmail.com>
References: <1352716147-13515-1-git-send-email-fabio.porcedda@gmail.com>
Message-ID: <20121114082327.GI10369@pengutronix.de>

On Mon, Nov 12, 2012 at 11:29:07AM +0100, Fabio Porcedda wrote:
> Signed-off-by: Fabio Porcedda <fabio.porcedda at gmail.com>
> ---
>  arch/arm/pbl/.gitignore | 1 +
>  1 file changed, 1 insertion(+)

Applied, thanks

Sascha

> 
> diff --git a/arch/arm/pbl/.gitignore b/arch/arm/pbl/.gitignore
> index 3384d8b..d71bb7c 100644
> --- a/arch/arm/pbl/.gitignore
> +++ b/arch/arm/pbl/.gitignore
> @@ -3,3 +3,4 @@ piggy.lzo
>  zbarebox
>  zbarebox.bin
>  zbarebox.lds
> +zbarebox.map
> -- 
> 1.8.0
> 
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Wed Nov 14 03:25:37 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Wed, 14 Nov 2012 09:25:37 +0100
Subject: [PATCH] mci_spi: always compute command crc byte
In-Reply-To: <1352754991-11660-1-git-send-email-franck.jullien@gmail.com>
References: <1352754991-11660-1-git-send-email-franck.jullien@gmail.com>
Message-ID: <20121114082537.GJ10369@pengutronix.de>

On Mon, Nov 12, 2012 at 10:16:31PM +0100, Franck Jullien wrote:
> The spec says: "the CMD8 CRC verification is always enabled.
> The Host shall set correct CRC in the argument ofCMD8. If
> CRC error is detected, card returns CRC error in R1 response
> regardless of command index."
> 
> Make it simple, and compute crc on every commands.
> 
> Signed-off-by: Franck Jullien <franck.jullien at gmail.com>

Applied, thanks

Sascha

> ---
>  drivers/mci/Kconfig   |    2 +-
>  drivers/mci/mci_spi.c |   12 ------------
>  2 files changed, 1 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/mci/Kconfig b/drivers/mci/Kconfig
> index b1a678e..5c0ca4d 100644
> --- a/drivers/mci/Kconfig
> +++ b/drivers/mci/Kconfig
> @@ -88,6 +88,7 @@ config MCI_ATMEL
>  
>  config MCI_SPI
>  	bool "MMC/SD over SPI"
> +	select CRC7
>  	depends on SPI
>  	help
>  	  Some systems access MMC/SD/SDIO cards using a SPI controller
> @@ -98,7 +99,6 @@ config MCI_SPI
>  
>  config MMC_SPI_CRC_ON
>  	bool "Enable CRC protection for transfers"
> -	select CRC7
>  	select CRC16
>  	depends on MCI_SPI
>  	help
> diff --git a/drivers/mci/mci_spi.c b/drivers/mci/mci_spi.c
> index 5894104..cb5e0bb 100644
> --- a/drivers/mci/mci_spi.c
> +++ b/drivers/mci/mci_spi.c
> @@ -121,14 +121,6 @@ mmc_spi_writebytes(struct mmc_spi_host *host, unsigned len, void *data)
>  	return status;
>  }
>  
> -/*
> - * Note that while the CRC, in general, is ignored in SPI mode, the very first
> - * command must be followed by a valid CRC, since the card is not yet in SPI mode.
> - * The CRC byte for a CMD0 command with a zero argument is a constant 0x4A. For
> - * simplicity, this CRC byte is always sent with every command.
> - */
> -#define MMC_SPI_CMD0_CRC	((0x4a << 1) | 0x1)
> -
>  static int mmc_spi_command_send(struct mmc_spi_host *host, struct mci_cmd *cmd)
>  {
>  	uint8_t r1;
> @@ -141,11 +133,7 @@ static int mmc_spi_command_send(struct mmc_spi_host *host, struct mci_cmd *cmd)
>  	command[3] = cmd->cmdarg >> 16;
>  	command[4] = cmd->cmdarg >> 8;
>  	command[5] = cmd->cmdarg;
> -#ifdef CONFIG_MMC_SPI_CRC_ON
>  	command[6] = (crc7(0, &command[1], 5) << 1) | 0x01;
> -#else
> -	command[6] = MMC_SPI_CMD0_CRC;
> -#endif
>  
>  	mmc_spi_writebytes(host, 7, command);
>  
> -- 
> 1.7.1
> 
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From plagnioj at jcrosoft.com  Wed Nov 14 04:34:58 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Wed, 14 Nov 2012 10:34:58 +0100
Subject: [PATCH 1/1] phy: phy_update_status wait auto neg done when enabled
In-Reply-To: <20121114080528.GF10369@pengutronix.de>
References: <1352841245-22767-1-git-send-email-plagnioj@jcrosoft.com>
 <20121114080528.GF10369@pengutronix.de>
Message-ID: <20121114093458.GH25679@game.jcrosoft.org>

On 09:05 Wed 14 Nov     , Sascha Hauer wrote:
> On Tue, Nov 13, 2012 at 10:14:05PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > if the autoneg was start by the hw wait it to be finished
> > 
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
> > ---
> >  drivers/net/phy/phy.c |   26 ++++++++++++++++++++++++++
> >  1 file changed, 26 insertions(+)
> > 
> > diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> > index 0c2e602..43738c2 100644
> > --- a/drivers/net/phy/phy.c
> > +++ b/drivers/net/phy/phy.c
> > @@ -28,6 +28,25 @@
> >  #define PHY_AN_TIMEOUT	10
> >  
> >  static int genphy_config_init(struct phy_device *phydev);
> > +static int phy_aneg_done(struct phy_device *phydev);
> > +
> > +static int phy_wait_aneg_read_status(struct phy_device *dev, struct phy_driver *drv)
> > +{
> > +	int ret;
> > +
> > +	if (AUTONEG_ENABLE != dev->autoneg)
> > +		return 0;
> > +
> > +	ret = phy_aneg_done(dev);
> > +	if (ret)
> > +		return ret;
> > +
> > +	/*
> > +	 * re-read the status as the aneg may not be finished
> > +	 * when we read it the first time
> > +	 */
> > +	return drv->read_status(dev);
> > +}
> >  
> >  int phy_update_status(struct phy_device *dev)
> >  {
> > @@ -35,11 +54,18 @@ int phy_update_status(struct phy_device *dev)
> >  	struct eth_device *edev = dev->attached_dev;
> >  	int ret;
> >  	int oldspeed = dev->speed, oldduplex = dev->duplex;
> > +	int old_link = dev->link;
> >  
> >  	ret = drv->read_status(dev);
> >  	if (ret)
> >  		return ret;
> >  
> > +	if (dev->link && !old_link) {
> > +		ret = phy_wait_aneg_read_status(dev, drv);
> > +		if (ret)
> > +			return ret;
> > +	}
> 
> This does not help. dev->link is false after reset, so we never get into
> phy_wait_aneg_read_status() which waits for a link.
read_status update the dev->link as we call update_link

if !dev->link means no cable detected

if the phy is reset the link is ready immediately or that means the reset is
not finished and the phy is not stable

this may means the phy need specific init

Best Regards,
J.


From s.hauer at pengutronix.de  Wed Nov 14 07:04:36 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Wed, 14 Nov 2012 13:04:36 +0100
Subject: [PATCH 1/1] phy: phy_update_status wait auto neg done when enabled
In-Reply-To: <20121114093458.GH25679@game.jcrosoft.org>
References: <1352841245-22767-1-git-send-email-plagnioj@jcrosoft.com>
 <20121114080528.GF10369@pengutronix.de>
 <20121114093458.GH25679@game.jcrosoft.org>
Message-ID: <20121114120436.GL10369@pengutronix.de>

On Wed, Nov 14, 2012 at 10:34:58AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 09:05 Wed 14 Nov     , Sascha Hauer wrote:
> > On Tue, Nov 13, 2012 at 10:14:05PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > >  
> > >  int phy_update_status(struct phy_device *dev)
> > >  {
> > > @@ -35,11 +54,18 @@ int phy_update_status(struct phy_device *dev)
> > >  	struct eth_device *edev = dev->attached_dev;
> > >  	int ret;
> > >  	int oldspeed = dev->speed, oldduplex = dev->duplex;
> > > +	int old_link = dev->link;
> > >  
> > >  	ret = drv->read_status(dev);
> > >  	if (ret)
> > >  		return ret;
> > >  
> > > +	if (dev->link && !old_link) {
> > > +		ret = phy_wait_aneg_read_status(dev, drv);
> > > +		if (ret)
> > > +			return ret;
> > > +	}
> > 
> > This does not help. dev->link is false after reset, so we never get into
> > phy_wait_aneg_read_status() which waits for a link.
> read_status update the dev->link as we call update_link
> 
> if !dev->link means no cable detected

How should the phy detect the cable if we do not wait for it being
detected?

Here's what I get from my board:

> barebox at Freescale i.MX53 LOCO:/ dhcp 
> r 0x0000 0x0001 0x7809

BMSR_ANEGCOMPLETE (1<<5) not set, this means autonegotiation is not complete

> r 0x0000 0x0004 0x01e1
> r 0x0000 0x0000 0x3000
> r 0x0000 0x0001 0x7809

Still not complete,

> r 0x0000 0x0001 0x7809
> r 0x0000 0x0005 0x0001
> r 0x0000 0x0004 0x01e1
> dhcp failed: Network is down

but we do not wait for it, so network down

> dhcp: Network is down
> barebox at Freescale i.MX53 LOCO:/ dhcp 
> r 0x0000 0x0001 0x782d

Next try, a few seconds later. BMSR_ANEGCOMPLETE is set, autonegotiation is complete,
BMSR_LSTATUS showd that link status is up.

> r 0x0000 0x0001 0x782d
> r 0x0000 0x0005 0x45e1
> r 0x0000 0x0004 0x01e1
> 100Mbps full duplex link detected

And it works.

I do not believe that this behaviour is specific to the special phy on
this board.

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From plagnioj at jcrosoft.com  Wed Nov 14 12:24:17 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Wed, 14 Nov 2012 18:24:17 +0100
Subject: [PATCH 1/1] phy: phy_update_status wait auto neg done when enabled
In-Reply-To: <20121114120436.GL10369@pengutronix.de>
References: <1352841245-22767-1-git-send-email-plagnioj@jcrosoft.com>
 <20121114080528.GF10369@pengutronix.de>
 <20121114093458.GH25679@game.jcrosoft.org>
 <20121114120436.GL10369@pengutronix.de>
Message-ID: <20121114172417.GA31820@game.jcrosoft.org>

On 13:04 Wed 14 Nov     , Sascha Hauer wrote:
> On Wed, Nov 14, 2012 at 10:34:58AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > On 09:05 Wed 14 Nov     , Sascha Hauer wrote:
> > > On Tue, Nov 13, 2012 at 10:14:05PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > >  
> > > >  int phy_update_status(struct phy_device *dev)
> > > >  {
> > > > @@ -35,11 +54,18 @@ int phy_update_status(struct phy_device *dev)
> > > >  	struct eth_device *edev = dev->attached_dev;
> > > >  	int ret;
> > > >  	int oldspeed = dev->speed, oldduplex = dev->duplex;
> > > > +	int old_link = dev->link;
> > > >  
> > > >  	ret = drv->read_status(dev);
> > > >  	if (ret)
> > > >  		return ret;
> > > >  
> > > > +	if (dev->link && !old_link) {
> > > > +		ret = phy_wait_aneg_read_status(dev, drv);
> > > > +		if (ret)
> > > > +			return ret;
> > > > +	}
> > > 
> > > This does not help. dev->link is false after reset, so we never get into
> > > phy_wait_aneg_read_status() which waits for a link.
> > read_status update the dev->link as we call update_link
> > 
> > if !dev->link means no cable detected
> 
> How should the phy detect the cable if we do not wait for it being
> detected?
we do not have too

I'm going to try on the loco

Best Regards,
J.


From plagnioj at jcrosoft.com  Wed Nov 14 16:03:19 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Wed, 14 Nov 2012 22:03:19 +0100
Subject: [PATCH 1/1] phy: if the link partner just ack us wait the end of the
 autoneg
Message-ID: <1352926999-14981-1-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/net/phy/phy.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 43738c2..daa657f 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -578,6 +578,18 @@ int genphy_read_status(struct phy_device *phydev)
 		if (lpa < 0)
 			return lpa;
 
+		if (lpa & LPA_LPACK) {
+			int ret;
+
+			ret = phy_aneg_done(phydev);
+			if (ret)
+				return ret;
+
+			lpa = phy_read(phydev, MII_LPA);
+			if (lpa < 0)
+				return lpa;
+		}
+
 		adv = phy_read(phydev, MII_ADVERTISE);
 
 		if (adv < 0)
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Wed Nov 14 16:04:30 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Wed, 14 Nov 2012 22:04:30 +0100
Subject: [PATCH 1/1] phy: if the link partner just ack us wait the end
 of the autoneg
In-Reply-To: <1352926999-14981-1-git-send-email-plagnioj@jcrosoft.com>
References: <1352926999-14981-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <20121114210430.GB31820@game.jcrosoft.org>

On 22:03 Wed 14 Nov     , Jean-Christophe PLAGNIOL-VILLARD wrote:
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
> ---
this will detect that the phy was jsut notified that the link is up

Best Regards,
J.
>  drivers/net/phy/phy.c |   12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index 43738c2..daa657f 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -578,6 +578,18 @@ int genphy_read_status(struct phy_device *phydev)
>  		if (lpa < 0)
>  			return lpa;
>  
> +		if (lpa & LPA_LPACK) {
> +			int ret;
> +
> +			ret = phy_aneg_done(phydev);
> +			if (ret)
> +				return ret;
> +
> +			lpa = phy_read(phydev, MII_LPA);
> +			if (lpa < 0)
> +				return lpa;
> +		}
> +
>  		adv = phy_read(phydev, MII_ADVERTISE);
>  
>  		if (adv < 0)
> -- 
> 1.7.10.4
> 


From franck.jullien at gmail.com  Wed Nov 14 17:23:32 2012
From: franck.jullien at gmail.com (Franck Jullien)
Date: Wed, 14 Nov 2012 23:23:32 +0100
Subject: [PATCH 1/2] nios2: use barebox_add_memory_bank in generic.c
Message-ID: <1352931813-2817-1-git-send-email-franck.jullien@gmail.com>

In the nios2 generic board generic.c file, use the
new barebox_add_memory_bank to init ram memory.

Signed-off-by: Franck Jullien <franck.jullien at gmail.com>
---
 arch/nios2/boards/generic/generic.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/arch/nios2/boards/generic/generic.c b/arch/nios2/boards/generic/generic.c
index 66eb856..499d93b 100644
--- a/arch/nios2/boards/generic/generic.c
+++ b/arch/nios2/boards/generic/generic.c
@@ -3,6 +3,7 @@
 #include <driver.h>
 #include <partition.h>
 #include <fs.h>
+#include <memory.h>
 
 static int phy_address = 1;
 
@@ -32,11 +33,17 @@ static struct device_d mac_dev = {
 	.platform_data = &phy_address,
 };
 
+static int mem_init(void)
+{
+	barebox_add_memory_bank("ram0", NIOS_SOPC_MEMORY_BASE, NIOS_SOPC_MEMORY_SIZE);
+
+	return 0;
+}
+mem_initcall(mem_init);
+
 static int generic_devices_init(void)
 {
 	add_cfi_flash_device(DEVICE_ID_DYNAMIC, NIOS_SOPC_FLASH_BASE, NIOS_SOPC_FLASH_SIZE, 0);
-	add_mem_device("ram0", NIOS_SOPC_MEMORY_BASE, NIOS_SOPC_MEMORY_SIZE,
-		       IORESOURCE_MEM_WRITEABLE);
 	platform_device_register(&mac_dev);
 	/*register_device(&epcs_flash_device);*/
 
-- 
1.7.1



From franck.jullien at gmail.com  Wed Nov 14 17:23:33 2012
From: franck.jullien at gmail.com (Franck Jullien)
Date: Wed, 14 Nov 2012 23:23:33 +0100
Subject: [PATCH 2/2] nios2: update generic_defconfig
In-Reply-To: <1352931813-2817-1-git-send-email-franck.jullien@gmail.com>
References: <1352931813-2817-1-git-send-email-franck.jullien@gmail.com>
Message-ID: <1352931813-2817-2-git-send-email-franck.jullien@gmail.com>

Signed-off-by: Franck Jullien <franck.jullien at gmail.com>
---
 arch/nios2/configs/generic_defconfig |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/arch/nios2/configs/generic_defconfig b/arch/nios2/configs/generic_defconfig
index 279a71e..5e27cc8 100644
--- a/arch/nios2/configs/generic_defconfig
+++ b/arch/nios2/configs/generic_defconfig
@@ -14,10 +14,19 @@ CONFIG_CMD_LOADENV=y
 CONFIG_CMD_EXPORT=y
 CONFIG_CMD_PRINTENV=y
 CONFIG_CMD_READLINE=y
+CONFIG_CMD_TFTP=y
+CONFIG_CMD_ECHO_E=y
 CONFIG_CMD_FLASH=y
-CONFIG_CMD_BOOTM_ZLIB=y
+CONFIG_CMD_BOOTM_SHOW_TYPE=y
+CONFIG_CMD_BOOTM_VERBOSE=y
+CONFIG_CMD_UIMAGE=y
 CONFIG_CMD_RESET=y
 CONFIG_CMD_GO=y
 CONFIG_CMD_TIMEOUT=y
 CONFIG_CMD_PARTITION=y
+CONFIG_NET=y
+CONFIG_NET_PING=y
+CONFIG_DRIVER_NET_TSE=y
 CONFIG_DRIVER_CFI=y
+CONFIG_FS_TFTP=y
+CONFIG_ZLIB=y
-- 
1.7.1



From zzs213 at 126.com  Wed Nov 14 21:40:18 2012
From: zzs213 at 126.com (zzs)
Date: Thu, 15 Nov 2012 10:40:18 +0800
Subject: why eth0 not in /dev
Message-ID: <20121115024018.GA30674@greatfirst.com>

When barebox starts, devinfo can show eth0's info
like this

9200-EK:/dev devinfo eth0
resources:
driver: none
bus: platform

Parameters:
          ipaddr = 192.168.0.109
         ethaddr =
         gateway =
         netmask =
        serverip =

But I can't see it in /dev, Why?

-- 
Best Regards,
zzs




From zzs213 at 126.com  Wed Nov 14 22:11:46 2012
From: zzs213 at 126.com (zzs)
Date: Thu, 15 Nov 2012 11:11:46 +0800
Subject: how to download a file to specified mem location using tftp
Message-ID: <20121115031146.GA31296@greatfirst.com>

tftp command only have filename args, Now I want
download a file to mem loctaion, ex 0x21f00000.
How to do that?

-- 
Best Regards,
zzs




From antonynpavlov at gmail.com  Thu Nov 15 00:45:40 2012
From: antonynpavlov at gmail.com (Antony Pavlov)
Date: Thu, 15 Nov 2012 09:45:40 +0400
Subject: how to download a file to specified mem location using tftp
In-Reply-To: <20121115031146.GA31296@greatfirst.com>
References: <20121115031146.GA31296@greatfirst.com>
Message-ID: <CAA4bVAFqCPkRGrz1oENQ3s9k99o=wPVq1RWSdiRJjeY1Mgkt3g@mail.gmail.com>

On 15 November 2012 07:11, zzs <zzs213 at 126.com> wrote:
> tftp command only have filename args, Now I want
> download a file to mem loctaion, ex 0x21f00000.
> How to do that?
>
> --
> Best Regards,
> zzs


AFAIR,
 memcpy -s /mnt/tftp/file -d /dev/mem 0 <memaddr> <size>

(but /dev/mem is default value for -d).


> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox



-- 
Best regards,
  Antony Pavlov


From antonynpavlov at gmail.com  Thu Nov 15 01:02:09 2012
From: antonynpavlov at gmail.com (Antony Pavlov)
Date: Thu, 15 Nov 2012 10:02:09 +0400
Subject: how to download a file to specified mem location using tftp
In-Reply-To: <CAA4bVAFqCPkRGrz1oENQ3s9k99o=wPVq1RWSdiRJjeY1Mgkt3g@mail.gmail.com>
References: <20121115031146.GA31296@greatfirst.com>
 <CAA4bVAFqCPkRGrz1oENQ3s9k99o=wPVq1RWSdiRJjeY1Mgkt3g@mail.gmail.com>
Message-ID: <CAA4bVAEhhLxXfzNZ_mBP_=W-TNOHOkEnwF=vgBMBy16ezd2_NA@mail.gmail.com>

On 15 November 2012 09:45, Antony Pavlov <antonynpavlov at gmail.com> wrote:
> On 15 November 2012 07:11, zzs <zzs213 at 126.com> wrote:
>> tftp command only have filename args, Now I want
>> download a file to mem loctaion, ex 0x21f00000.
>> How to do that?
>
> AFAIR,
>  memcpy -s /mnt/tftp/file -d /dev/mem 0 <memaddr> <size>
>
> (but /dev/mem is default value for -d).
>

If you have tftp command only (old barebox without tftp filesystem support)
then use

 barebox:/ tftp your_file
 barebox:/ memcpy -s your_file 0 0x21f00000 <file size>

-- 
Best regards,
  Antony Pavlov


From zzs213 at 126.com  Thu Nov 15 01:30:11 2012
From: zzs213 at 126.com (zzs)
Date: Thu, 15 Nov 2012 14:30:11 +0800
Subject: how to download a file to specified mem location using tftp
In-Reply-To: <CAA4bVAEhhLxXfzNZ_mBP_=W-TNOHOkEnwF=vgBMBy16ezd2_NA@mail.gmail.com>
References: <20121115031146.GA31296@greatfirst.com>
 <CAA4bVAFqCPkRGrz1oENQ3s9k99o=wPVq1RWSdiRJjeY1Mgkt3g@mail.gmail.com>
 <CAA4bVAEhhLxXfzNZ_mBP_=W-TNOHOkEnwF=vgBMBy16ezd2_NA@mail.gmail.com>
Message-ID: <20121115063011.GB31296@greatfirst.com>

In message <CAA4bVAEhhLxXfzNZ_mBP_=W-TNOHOkEnwF=vgBMBy16ezd2_NA at mail.gmail.com> Antony Pavlov wrote:
> >> tftp command only have filename args, Now I want
> >> download a file to mem loctaion, ex 0x21f00000.
> >> How to do that?
> >
> > AFAIR,
> >  memcpy -s /mnt/tftp/file -d /dev/mem 0 <memaddr> <size>
> >
> > (but /dev/mem is default value for -d).
> >
>
> If you have tftp command only (old barebox without tftp filesystem support)
> then use
>
>  barebox:/ tftp your_file
>  barebox:/ memcpy -s your_file 0 0x21f00000 <file size>
>

Thanks, I'm a barebox beginner.

So how to mount tftp to /mnt/tftp

my barebox version is 2012.10.0


-- 
Best Regards,
zzs




From zzs213 at 126.com  Thu Nov 15 02:07:55 2012
From: zzs213 at 126.com (zzs)
Date: Thu, 15 Nov 2012 15:07:55 +0800
Subject: how to download a file to specified mem location using tftp
In-Reply-To: <20121115063011.GB31296@greatfirst.com>
References: <20121115031146.GA31296@greatfirst.com>
 <CAA4bVAFqCPkRGrz1oENQ3s9k99o=wPVq1RWSdiRJjeY1Mgkt3g@mail.gmail.com>
 <CAA4bVAEhhLxXfzNZ_mBP_=W-TNOHOkEnwF=vgBMBy16ezd2_NA@mail.gmail.com>
 <20121115063011.GB31296@greatfirst.com>
Message-ID: <20121115070755.GC31296@greatfirst.com>

> So how to mount tftp to /mnt/tftp
>
Greped barebox code, Now I SEE

mkdir /mnt/tftp -p && mount -t tftp $eth0.serverip /mnt/tftP

-- 
Best Regards,
zzs




From guenter.gebhardt at freenet.de  Thu Nov 15 01:59:22 2012
From: guenter.gebhardt at freenet.de (=?ISO-8859-1?Q?G=FCnter?= Gebhardt)
Date: Thu, 15 Nov 2012 07:59:22 +0100
Subject: TX53-8030 Memory Speed
Message-ID: <4801591.VRVUpK1jDH@linux-xmcx>

Hello,

we integrated KARO TX53-8030 support into our barebox 2012.07.0 some month 
ago.

We measured the performance of memcpy() and found that the throughput is only 
19MB/s. We expected it to be something like 10 times faster.

We saw that there is support for the TX-53 in general within the head of 
barebox.

Within the file arch/arm/boards/karo-tx53/flash_header.c it 
is stated that it only supports TX53 1011 (i.e. 1GB RAM).

Do You have settings applicable to our device? 

What throughput do You expect from this device? 

Are there some things to be aware of?

Kind Regard,
Guenter Gebhadt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/barebox/attachments/20121115/79475448/attachment.html>

From s.hauer at pengutronix.de  Thu Nov 15 02:39:29 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu, 15 Nov 2012 08:39:29 +0100
Subject: why eth0 not in /dev
In-Reply-To: <20121115024018.GA30674@greatfirst.com>
References: <20121115024018.GA30674@greatfirst.com>
Message-ID: <20121115073929.GR10369@pengutronix.de>

On Thu, Nov 15, 2012 at 10:40:18AM +0800, zzs wrote:
> When barebox starts, devinfo can show eth0's info
> like this
> 
> 9200-EK:/dev devinfo eth0
> resources:
> driver: none
> bus: platform
> 
> Parameters:
>           ipaddr = 192.168.0.109
>          ethaddr =
>          gateway =
>          netmask =
>         serverip =
> 
> But I can't see it in /dev, Why?

Files are registered manually under /dev/ by device drivers when they
want to provide a file there. A network device does not have anything
useful to register as a file, so there is none. Files under /dev/ often
have the same name as the devices, but this does not have to be the
case, they are two different things.

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Thu Nov 15 02:41:34 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu, 15 Nov 2012 08:41:34 +0100
Subject: how to download a file to specified mem location using tftp
In-Reply-To: <20121115070755.GC31296@greatfirst.com>
References: <20121115031146.GA31296@greatfirst.com>
 <CAA4bVAFqCPkRGrz1oENQ3s9k99o=wPVq1RWSdiRJjeY1Mgkt3g@mail.gmail.com>
 <CAA4bVAEhhLxXfzNZ_mBP_=W-TNOHOkEnwF=vgBMBy16ezd2_NA@mail.gmail.com>
 <20121115063011.GB31296@greatfirst.com>
 <20121115070755.GC31296@greatfirst.com>
Message-ID: <20121115074134.GS10369@pengutronix.de>

On Thu, Nov 15, 2012 at 03:07:55PM +0800, zzs wrote:
> > So how to mount tftp to /mnt/tftp
> >
> Greped barebox code, Now I SEE
> 
> mkdir /mnt/tftp -p && mount -t tftp $eth0.serverip /mnt/tftP

Additionally you'll find this:

mkdir /mnt/tftp
automount /mnt/tftp 'ifup eth0 && mount -t tftp $eth0.serverip /mnt/tftp'

which will automount it for you once you need it.

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Thu Nov 15 02:46:50 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu, 15 Nov 2012 08:46:50 +0100
Subject: TX53-8030 Memory Speed
In-Reply-To: <4801591.VRVUpK1jDH@linux-xmcx>
References: <4801591.VRVUpK1jDH@linux-xmcx>
Message-ID: <20121115074650.GT10369@pengutronix.de>

On Thu, Nov 15, 2012 at 07:59:22AM +0100, G?nter Gebhardt wrote:
> Hello,
> 
> we integrated KARO TX53-8030 support into our barebox 2012.07.0 some month 
> ago.
> 
> We measured the performance of memcpy() and found that the throughput is only 
> 19MB/s. We expected it to be something like 10 times faster.
> 
> We saw that there is support for the TX-53 in general within the head of 
> barebox.
> 
> Within the file arch/arm/boards/karo-tx53/flash_header.c it 
> is stated that it only supports TX53 1011 (i.e. 1GB RAM).

Support for the TX53-8030 is currently in the -next branch, but
unfortunately it doesn't seem to work properly, see this thread:

http://lists.infradead.org/pipermail/barebox/2012-November/010983.html

> 
> Do You have settings applicable to our device? 
> 
> What throughput do You expect from this device? 

Just rechecked on my 1011 board (I can't find the 8030 board atm,
otherwise I would have fixed the support already), it's about
230MB/s using memcpy on the commandline. Probably you don't have
the MMU turned on which means you're running without data chaches.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Thu Nov 15 02:47:40 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu, 15 Nov 2012 08:47:40 +0100
Subject: [PATCH 1/2] nios2: use barebox_add_memory_bank in generic.c
In-Reply-To: <1352931813-2817-1-git-send-email-franck.jullien@gmail.com>
References: <1352931813-2817-1-git-send-email-franck.jullien@gmail.com>
Message-ID: <20121115074740.GU10369@pengutronix.de>

On Wed, Nov 14, 2012 at 11:23:32PM +0100, Franck Jullien wrote:
> In the nios2 generic board generic.c file, use the
> new barebox_add_memory_bank to init ram memory.
> 
> Signed-off-by: Franck Jullien <franck.jullien at gmail.com>

Applied, thanks

Sascha

> ---
>  arch/nios2/boards/generic/generic.c |   11 +++++++++--
>  1 files changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/nios2/boards/generic/generic.c b/arch/nios2/boards/generic/generic.c
> index 66eb856..499d93b 100644
> --- a/arch/nios2/boards/generic/generic.c
> +++ b/arch/nios2/boards/generic/generic.c
> @@ -3,6 +3,7 @@
>  #include <driver.h>
>  #include <partition.h>
>  #include <fs.h>
> +#include <memory.h>
>  
>  static int phy_address = 1;
>  
> @@ -32,11 +33,17 @@ static struct device_d mac_dev = {
>  	.platform_data = &phy_address,
>  };
>  
> +static int mem_init(void)
> +{
> +	barebox_add_memory_bank("ram0", NIOS_SOPC_MEMORY_BASE, NIOS_SOPC_MEMORY_SIZE);
> +
> +	return 0;
> +}
> +mem_initcall(mem_init);
> +
>  static int generic_devices_init(void)
>  {
>  	add_cfi_flash_device(DEVICE_ID_DYNAMIC, NIOS_SOPC_FLASH_BASE, NIOS_SOPC_FLASH_SIZE, 0);
> -	add_mem_device("ram0", NIOS_SOPC_MEMORY_BASE, NIOS_SOPC_MEMORY_SIZE,
> -		       IORESOURCE_MEM_WRITEABLE);
>  	platform_device_register(&mac_dev);
>  	/*register_device(&epcs_flash_device);*/
>  
> -- 
> 1.7.1
> 
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Thu Nov 15 03:01:51 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu, 15 Nov 2012 09:01:51 +0100
Subject: [PATCH 1/1] phy: if the link partner just ack us wait the end of
 the autoneg
In-Reply-To: <1352926999-14981-1-git-send-email-plagnioj@jcrosoft.com>
References: <1352926999-14981-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <20121115080150.GV10369@pengutronix.de>

On Wed, Nov 14, 2012 at 10:03:19PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
> ---
>  drivers/net/phy/phy.c |   12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index 43738c2..daa657f 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -578,6 +578,18 @@ int genphy_read_status(struct phy_device *phydev)
>  		if (lpa < 0)
>  			return lpa;
>  
> +		if (lpa & LPA_LPACK) {
> +			int ret;
> +
> +			ret = phy_aneg_done(phydev);
> +			if (ret)
> +				return ret;
> +
> +			lpa = phy_read(phydev, MII_LPA);
> +			if (lpa < 0)
> +				return lpa;
> +		}
> +

Still does not work:

barebox at Freescale i.MX53 LOCO:/ while [ ${done} != 0 ]; do dhcp;
done=$?; msleep 500; done
genphy_read_status MII_LPA 0x0001
dhcp failed: Network is down
dhcp: Network is down
dhcp failed: Network is down
dhcp: Network is down
dhcp failed: Network is down
dhcp: Network is down
dhcp failed: Network is down
dhcp: Network is down
dhcp failed: Network is down
dhcp: Network is down
dhcp failed: Network is down
dhcp: Network is down
dhcp failed: Network is down
dhcp: Network is down
dhcp failed: Network is down
dhcp: Network is down
dhcp failed: Network is down
dhcp: Network is down
dhcp failed: Network is down
dhcp: Network is down
genphy_read_status MII_LPA 0x45e1
100Mbps full duplex link detected
DHCP client bound to address 192.168.24.118


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From plagnioj at jcrosoft.com  Thu Nov 15 04:29:41 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu, 15 Nov 2012 10:29:41 +0100
Subject: [PATCH 1/1] phy: if the link partner just ack us wait the end
 of the autoneg
In-Reply-To: <20121115080150.GV10369@pengutronix.de>
References: <1352926999-14981-1-git-send-email-plagnioj@jcrosoft.com>
 <20121115080150.GV10369@pengutronix.de>
Message-ID: <20121115092941.GC31820@game.jcrosoft.org>

On 09:01 Thu 15 Nov     , Sascha Hauer wrote:
> On Wed, Nov 14, 2012 at 10:03:19PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
> > ---
> >  drivers/net/phy/phy.c |   12 ++++++++++++
> >  1 file changed, 12 insertions(+)
> > 
> > diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> > index 43738c2..daa657f 100644
> > --- a/drivers/net/phy/phy.c
> > +++ b/drivers/net/phy/phy.c
> > @@ -578,6 +578,18 @@ int genphy_read_status(struct phy_device *phydev)
> >  		if (lpa < 0)
> >  			return lpa;
> >  
> > +		if (lpa & LPA_LPACK) {
> > +			int ret;
> > +
> > +			ret = phy_aneg_done(phydev);
> > +			if (ret)
> > +				return ret;
> > +
> > +			lpa = phy_read(phydev, MII_LPA);
> > +			if (lpa < 0)
> > +				return lpa;
> > +		}
> > +
> 
> Still does not work:
> 
> barebox at Freescale i.MX53 LOCO:/ while [ ${done} != 0 ]; do dhcp;
> done=$?; msleep 500; done
> genphy_read_status MII_LPA 0x0001
> dhcp failed: Network is down
> dhcp: Network is down
> dhcp failed: Network is down
> dhcp: Network is down
> dhcp failed: Network is down
> dhcp: Network is down
> dhcp failed: Network is down
> dhcp: Network is down
> dhcp failed: Network is down
> dhcp: Network is down
> dhcp failed: Network is down
> dhcp: Network is down
> dhcp failed: Network is down
> dhcp: Network is down
> dhcp failed: Network is down
> dhcp: Network is down
> dhcp failed: Network is down
> dhcp: Network is down
> dhcp failed: Network is down
> dhcp: Network is down
> genphy_read_status MII_LPA 0x45e1
> 100Mbps full duplex link detected
> DHCP client bound to address 192.168.24.118
this is a bug on LAN8720 which may cause this


Make sure the EDPWRDOWN bit is NOT set. Setting this bit on
LAN8710/LAN8720 PHY causes the PHY to misbehave, likely due
to a bug on the chip.

When the system is powered on with the network cable being
disconnected all the way until after ifconfig ethX up is
ssued for the LAN port with this PHY, connecting the cable
afterwards does not cause LINK change detection, while the
expected behavior is the Link UP being detected.

Best Regards,
J. 
> -- 
> Pengutronix e.K.                           |                             |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From plagnioj at jcrosoft.com  Thu Nov 15 04:31:43 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu, 15 Nov 2012 10:31:43 +0100
Subject: [PATCH 1/2] phy: add phy_drivers_register
Message-ID: <1352971904-12409-1-git-send-email-plagnioj@jcrosoft.com>

to allow to register an array of drivers

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/net/phy/phy.c |   12 ++++++++++++
 include/linux/phy.h   |    1 +
 2 files changed, 13 insertions(+)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index daa657f..5a4be54 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -705,6 +705,18 @@ int phy_driver_register(struct phy_driver *phydrv)
 	return register_driver(&phydrv->drv);
 }
 
+int phy_drivers_register(struct phy_driver *new_driver, int n)
+{
+	int i, ret = 0;
+
+	for (i = 0; i < n; i++) {
+		ret = phy_driver_register(new_driver + i);
+		if (ret)
+			return ret;
+	}
+	return ret;
+}
+
 int phy_init_hw(struct phy_device *phydev)
 {
 	struct phy_driver *phydrv = to_phy_driver(phydev->dev.driver);
diff --git a/include/linux/phy.h b/include/linux/phy.h
index fa21984..ce6f22c 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -235,6 +235,7 @@ struct phy_fixup {
 };
 
 int phy_driver_register(struct phy_driver *drv);
+int phy_drivers_register(struct phy_driver *new_driver, int n);
 struct phy_device *get_phy_device(struct mii_bus *bus, int addr);
 int phy_init(void);
 int phy_init_hw(struct phy_device *phydev);
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Thu Nov 15 04:31:44 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu, 15 Nov 2012 10:31:44 +0100
Subject: [PATCH 2/2] phy: add smsc phy driver support
In-Reply-To: <1352971904-12409-1-git-send-email-plagnioj@jcrosoft.com>
References: <1352971904-12409-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1352971904-12409-2-git-send-email-plagnioj@jcrosoft.com>

as we to have specific phy init to fix chip issue link detection support

based on linux 3.6

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/net/phy/Kconfig  |    5 ++
 drivers/net/phy/Makefile |    1 +
 drivers/net/phy/smsc.c   |  146 ++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/smscphy.h  |   25 ++++++++
 4 files changed, 177 insertions(+)
 create mode 100644 drivers/net/phy/smsc.c
 create mode 100644 include/linux/smscphy.h

diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index b66261a..616b539 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -14,4 +14,9 @@ config GENERIC_PHY
 
 endif
 
+config SMSC_PHY
+	bool "Drivers for SMSC PHYs"
+	---help---
+	  Currently supports the LAN83C185, LAN8187 and LAN8700 PHYs
+
 endmenu
diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
index 82e90d4..0caeb70 100644
--- a/drivers/net/phy/Makefile
+++ b/drivers/net/phy/Makefile
@@ -1,2 +1,3 @@
 obj-y += phy.o mdio_bus.o
 obj-$(CONFIG_GENERIC_PHY) += generic.o
+obj-$(CONFIG_SMSC_PHY)		+= smsc.o
diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c
new file mode 100644
index 0000000..3c201f6
--- /dev/null
+++ b/drivers/net/phy/smsc.c
@@ -0,0 +1,146 @@
+/*
+ * drivers/net/phy/smsc.c
+ *
+ * Driver for SMSC PHYs
+ *
+ * Author: Herbert Valerio Riedel
+ *
+ * Copyright (c) 2006 Herbert Valerio Riedel <hvr at gnu.org>
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ *
+ * Support added for SMSC LAN8187 and LAN8700 by steve.glendinning at shawell.net
+ *
+ */
+
+#include <common.h>
+#include <init.h>
+#include <linux/mii.h>
+#include <linux/ethtool.h>
+#include <linux/phy.h>
+#include <linux/smscphy.h>
+
+static int smsc_phy_ack_interrupt(struct phy_device *phydev)
+{
+	int rc = phy_read (phydev, MII_LAN83C185_ISF);
+
+	return rc < 0 ? rc : 0;
+}
+
+static int smsc_phy_config_init(struct phy_device *phydev)
+{
+	int rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
+	if (rc < 0)
+		return rc;
+
+	/* Enable energy detect mode for this SMSC Transceivers */
+	rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS,
+		       rc | MII_LAN83C185_EDPWRDOWN);
+	if (rc < 0)
+		return rc;
+
+	return smsc_phy_ack_interrupt (phydev);
+}
+
+static int lan87xx_config_init(struct phy_device *phydev)
+{
+	/*
+	 * Make sure the EDPWRDOWN bit is NOT set. Setting this bit on
+	 * LAN8710/LAN8720 PHY causes the PHY to misbehave, likely due
+	 * to a bug on the chip.
+	 *
+	 * When the system is powered on with the network cable being
+	 * disconnected all the way until after ifconfig ethX up is
+	 * issued for the LAN port with this PHY, connecting the cable
+	 * afterwards does not cause LINK change detection, while the
+	 * expected behavior is the Link UP being detected.
+	 */
+	int rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
+	if (rc < 0)
+		return rc;
+
+	rc &= ~MII_LAN83C185_EDPWRDOWN;
+
+	rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS, rc);
+	if (rc < 0)
+		return rc;
+
+	return smsc_phy_ack_interrupt(phydev);
+}
+
+static int lan911x_config_init(struct phy_device *phydev)
+{
+	return smsc_phy_ack_interrupt(phydev);
+}
+
+static struct phy_driver smsc_phy_driver[] = {
+{
+	.phy_id		= 0x0007c0a0, /* OUI=0x00800f, Model#=0x0a */
+	.phy_id_mask	= 0xfffffff0,
+	.drv.name	= "SMSC LAN83C185",
+
+	.features	= (PHY_BASIC_FEATURES | SUPPORTED_Pause
+				| SUPPORTED_Asym_Pause),
+
+	/* basic functions */
+	.config_aneg	= genphy_config_aneg,
+	.read_status	= genphy_read_status,
+	.config_init	= smsc_phy_config_init,
+}, {
+	.phy_id		= 0x0007c0b0, /* OUI=0x00800f, Model#=0x0b */
+	.phy_id_mask	= 0xfffffff0,
+	.drv.name	= "SMSC LAN8187",
+
+	.features	= (PHY_BASIC_FEATURES | SUPPORTED_Pause
+				| SUPPORTED_Asym_Pause),
+
+	/* basic functions */
+	.config_aneg	= genphy_config_aneg,
+	.read_status	= genphy_read_status,
+	.config_init	= smsc_phy_config_init,
+}, {
+	.phy_id		= 0x0007c0c0, /* OUI=0x00800f, Model#=0x0c */
+	.phy_id_mask	= 0xfffffff0,
+	.drv.name	= "SMSC LAN8700",
+
+	.features	= (PHY_BASIC_FEATURES | SUPPORTED_Pause
+				| SUPPORTED_Asym_Pause),
+
+	/* basic functions */
+	.config_aneg	= genphy_config_aneg,
+	.read_status	= genphy_read_status,
+	.config_init	= smsc_phy_config_init,
+}, {
+	.phy_id		= 0x0007c0d0, /* OUI=0x00800f, Model#=0x0d */
+	.phy_id_mask	= 0xfffffff0,
+	.drv.name	= "SMSC LAN911x Internal PHY",
+
+	.features	= (PHY_BASIC_FEATURES | SUPPORTED_Pause
+				| SUPPORTED_Asym_Pause),
+
+	/* basic functions */
+	.config_aneg	= genphy_config_aneg,
+	.read_status	= genphy_read_status,
+	.config_init	= lan911x_config_init,
+}, {
+	.phy_id		= 0x0007c0f0, /* OUI=0x00800f, Model#=0x0f */
+	.phy_id_mask	= 0xfffffff0,
+	.drv.name	= "SMSC LAN8710/LAN8720",
+
+	.features	= (PHY_BASIC_FEATURES | SUPPORTED_Pause
+				| SUPPORTED_Asym_Pause),
+
+	/* basic functions */
+	.config_aneg	= genphy_config_aneg,
+	.read_status	= genphy_read_status,
+	.config_init	= lan87xx_config_init,
+} };
+
+static int __init smsc_init(void)
+{
+	return phy_drivers_register(smsc_phy_driver, ARRAY_SIZE(smsc_phy_driver));
+}
+device_initcall(smsc_init);
diff --git a/include/linux/smscphy.h b/include/linux/smscphy.h
new file mode 100644
index 0000000..ce718cb
--- /dev/null
+++ b/include/linux/smscphy.h
@@ -0,0 +1,25 @@
+#ifndef __LINUX_SMSCPHY_H__
+#define __LINUX_SMSCPHY_H__
+
+#define MII_LAN83C185_ISF 29 /* Interrupt Source Flags */
+#define MII_LAN83C185_IM  30 /* Interrupt Mask */
+#define MII_LAN83C185_CTRL_STATUS 17 /* Mode/Status Register */
+
+#define MII_LAN83C185_ISF_INT1 (1<<1) /* Auto-Negotiation Page Received */
+#define MII_LAN83C185_ISF_INT2 (1<<2) /* Parallel Detection Fault */
+#define MII_LAN83C185_ISF_INT3 (1<<3) /* Auto-Negotiation LP Ack */
+#define MII_LAN83C185_ISF_INT4 (1<<4) /* Link Down */
+#define MII_LAN83C185_ISF_INT5 (1<<5) /* Remote Fault Detected */
+#define MII_LAN83C185_ISF_INT6 (1<<6) /* Auto-Negotiation complete */
+#define MII_LAN83C185_ISF_INT7 (1<<7) /* ENERGYON */
+
+#define MII_LAN83C185_ISF_INT_ALL (0x0e)
+
+#define MII_LAN83C185_ISF_INT_PHYLIB_EVENTS \
+	(MII_LAN83C185_ISF_INT6 | MII_LAN83C185_ISF_INT4 | \
+	 MII_LAN83C185_ISF_INT7)
+
+#define MII_LAN83C185_EDPWRDOWN (1 << 13) /* EDPWRDOWN */
+#define MII_LAN83C185_ENERGYON  (1 << 1)  /* ENERGYON */
+
+#endif /* __LINUX_SMSCPHY_H__ */
-- 
1.7.10.4



From christian.kapeller at cmotion.eu  Thu Nov 15 04:57:13 2012
From: christian.kapeller at cmotion.eu (Christian Kapeller)
Date: Thu, 15 Nov 2012 10:57:13 +0100
Subject: [TX53: boot fixes 0/2] Make TX53 bootable again
In-Reply-To: <alpine.LSU.2.00.1211121220380.14365@redbean.intranet.gw-instruments.de>
References: <alpine.LSU.2.00.1211121220380.14365@redbean.intranet.gw-instruments.de>
Message-ID: <1352973435-11618-1-git-send-email-christian.kapeller@cmotion.eu>

Currently KaRo TX53-8030 soc module support is present in next branch, but
compiling the default config tx53stk5_defconfig results in an unbootable image.

This series 
 * makes the TX53-8030 board boot again [1/2]
 * fixes compilation of the TX53 board with PBL_IMAGE=n and DO_LOWLEVEL_RESET=n [2/2]

Christian Kapeller (2):
  tx53: Fix unbootable TX53-8030.
  tx53: remove reset() when not doing lowlevel init.

 arch/arm/boards/karo-tx53/dcd-data-xx30.h |    1 -
 arch/arm/boards/karo-tx53/lowlevel.c      |    3 +++
 2 files changed, 3 insertions(+), 1 deletions(-)

-- 
1.7.5.4



From christian.kapeller at cmotion.eu  Thu Nov 15 04:57:14 2012
From: christian.kapeller at cmotion.eu (Christian Kapeller)
Date: Thu, 15 Nov 2012 10:57:14 +0100
Subject: [TX53: boot fixes 1/2] tx53: Fix unbootable TX53-8030.
In-Reply-To: <1352973435-11618-1-git-send-email-christian.kapeller@cmotion.eu>
References: <1352973435-11618-1-git-send-email-christian.kapeller@cmotion.eu>
Message-ID: <1352973435-11618-2-git-send-email-christian.kapeller@cmotion.eu>

This patch remove a superfluous DCD command in TX53-xx30 flash header.
The entry DCD_WR_CMD(0x21c) just duplicates the contents of the last
imx_flash_header_v2 struct member dcd.

Removal of this DCD entry is needed to make the TX53 board boot again
from NAND.

Signed-off-by: Christian Kapeller <christian.kapeller at cmotion.eu>
---
 arch/arm/boards/karo-tx53/dcd-data-xx30.h |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/arch/arm/boards/karo-tx53/dcd-data-xx30.h b/arch/arm/boards/karo-tx53/dcd-data-xx30.h
index aa569c2..cb982dc 100644
--- a/arch/arm/boards/karo-tx53/dcd-data-xx30.h
+++ b/arch/arm/boards/karo-tx53/dcd-data-xx30.h
@@ -13,7 +13,6 @@
  */
 
 DCD_NAME_XX30[] = {
-	DCD_WR_CMD(0x21c),
 	DCD_ITEM(0x53fd4068, 0xffcc0fff),
 	DCD_ITEM(0x53fd406c, 0x000fffc3),
 	DCD_ITEM(0x53fd4070, 0x033c0000),
-- 
1.7.5.4



From christian.kapeller at cmotion.eu  Thu Nov 15 04:57:15 2012
From: christian.kapeller at cmotion.eu (Christian Kapeller)
Date: Thu, 15 Nov 2012 10:57:15 +0100
Subject: [TX53: boot fixes 2/2] tx53: remove reset() when not doing lowlevel
 init.
In-Reply-To: <1352973435-11618-1-git-send-email-christian.kapeller@cmotion.eu>
References: <1352973435-11618-1-git-send-email-christian.kapeller@cmotion.eu>
Message-ID: <1352973435-11618-3-git-send-email-christian.kapeller@cmotion.eu>

This patch fixes a linker error when PBL_IMAGE=n and DO_LOW_LEVEL_INIT=n.
In this configuration the symbol reset() was present multiple times,
and prevented the barebox image to be linked.


Signed-off-by: Christian Kapeller <christian.kapeller at cmotion.eu>
---
 arch/arm/boards/karo-tx53/lowlevel.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boards/karo-tx53/lowlevel.c b/arch/arm/boards/karo-tx53/lowlevel.c
index 6b7314c..0ca164b 100644
--- a/arch/arm/boards/karo-tx53/lowlevel.c
+++ b/arch/arm/boards/karo-tx53/lowlevel.c
@@ -3,6 +3,8 @@
 #include <asm/barebox-arm.h>
 #include <mach/imx5.h>
 
+#ifdef CONFIG_MACH_DO_LOWLEVEL_INIT
+
 void __naked reset(void)
 {
 	common_reset();
@@ -17,3 +19,4 @@ void __naked reset(void)
 
 	board_init_lowlevel_return();
 }
+#endif
-- 
1.7.5.4



From plagnioj at jcrosoft.com  Thu Nov 15 05:11:09 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu, 15 Nov 2012 11:11:09 +0100
Subject: [PATCH 0/2 v2] add bus device
In-Reply-To: <20121103150823.GY29599@game.jcrosoft.org>
References: <20121103150823.GY29599@game.jcrosoft.org>
Message-ID: <20121115101109.GD31820@game.jcrosoft.org>

ping
On 16:08 Sat 03 Nov     , Jean-Christophe PLAGNIOL-VILLARD wrote:
> Hi,
> 
> The following changes since commit 37b37cb2bff79f4edbbcaf316149d814e11a358e:
> 
>   eth: register device a pure device (2012-11-03 07:48:12 +0800)
> 
> are available in the git repository at:
> 
>   git://git.jcrosoft.org/barebox.git tags/bus_device
> 
> for you to fetch changes up to 35f8933bf003b5049131487882d8ae57a1a50d3a:
> 
>   bus: add bus device (2012-11-03 07:52:49 +0800)
> 
> ----------------------------------------------------------------
> add bus device
> 
> This patch serie add a pure device for each bus
> 
> And set this device to each bus device as a parent if the device
> does not have a parent already
> 
> we have now a nice output per bus
> 
> barebox at Atmel at91sam9x5-ek:/
> devices:
> `---- platform
>      `---- atmel_usart0
>           `---- cs0
>      `---- atmel_usart1
>           `---- cs1
>      `---- mem0
>           `---- 0x00000000-0x07ffffff: /dev/ram0
>      `---- mem1
>           `---- 0x00000000-0x00007fff: /dev/sram0
>      `---- mem2
>           `---- 0x00000000-0x000037bf: /dev/defaultenv
>      `---- mem3
>           `---- 0x00000000-0xfffffffe: /dev/mem
>      `---- cs2
>      `---- w1-gpio
>           `---- w1_bus0
>                `---- w1-2d-0
>                     `---- 0x00000000-0x0000007f: /dev/ds24310
>                `---- w1-2d-1
>                     `---- 0x00000000-0x0000007f: /dev/ds24311
>                `---- w1-23-0
>                     `---- 0x00000000-0x000001ff: /dev/ds24330
>      `---- at91sam9x5cm
>      `---- at91sam9x5ek
>      `---- at91sam9x5dm
>      `---- atmel_nand0
>           `---- nand0
>                `---- 0x00000000-0x1fffffff: /dev/nand0
>                `---- 0x00000000-0x0003ffff: /dev/at91bootstrap_raw
>                `---- 0x00040000-0x0009ffff: /dev/self_raw
>                `---- 0x000a0000-0x000bffff: /dev/env_raw
>                `---- 0x000c0000-0x000dffff: /dev/env_raw1
>                `---- 0x00000000-0x0003ffff: /dev/nand0.at91bootstrap
>                `---- 0x00040000-0x0009ffff: /dev/nand0.barebox
>                `---- 0x000a0000-0x000bffff: /dev/nand0.bareboxenv
>                `---- 0x000c0000-0x000dffff: /dev/nand0.bareboxenv2
>                `---- 0x000e0000-0x000fffff: /dev/nand0.oftree
>                `---- 0x00100000-0x001fffff: /dev/nand0.free
>                `---- 0x00200000-0x007fffff: /dev/nand0.kernel
>                `---- 0x00800000-0x07ffffff: /dev/nand0.rootfs
>                `---- 0x08000000-0x1fffffff: /dev/nand0.data
>      `---- macb0
>           `---- miibus0
>           `---- eth0
>      `---- atmel_spi0
>           `---- mtd_dataflash0
>                     `---- 0x00000000-0x0041ffff: /dev/dataflash0
>      `---- atmel_mci0
>           `---- mci0
>                `---- 0x00000000-0x1d9bfffff: /dev/disk0
>                `---- 0x00100000-0x064fffff: /dev/disk0.0
>                `---- 0x06500000-0x1d9bfffff: /dev/disk0.1
>      `---- i2c-gpio0
>           `---- i2c0
>                `---- qt10700
>                     `---- cs3
> `---- mdio_bus
> `---- spi
> `---- i2c
> `---- w1_bus
> `---- fs
>      `---- ramfs0
>      `---- devfs0
> `---- net
> `---- global
> 
> drivers:
> atmel_usart
> ramfs
> devfs
> fat
> macb
> Generic PHY
> atmel_nand
> mtd_dataflash
> m25p80
> atmel_spi
> i2c-gpio
> mci
> atmel_mci
> qt1070
> w1-gpio
> ds2431
> ds2433
> mem
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
> 
> ----------------------------------------------------------------
> Jean-Christophe PLAGNIOL-VILLARD (2):
>       bus_for_each_device/bus_for_each_driver: add () to allow use &bus
>       bus: add bus device
> 
>  drivers/base/bus.c    |   10 ++++++++++
>  drivers/base/driver.c |    5 +++++
>  include/driver.h      |    6 ++++--
>  3 files changed, 19 insertions(+), 2 deletions(-)
> 
> Best Regards,
> J.
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox


From plagnioj at jcrosoft.com  Thu Nov 15 05:11:22 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu, 15 Nov 2012 11:11:22 +0100
Subject: [PATCH 0/4 v3] at91sam9x5ek: add spi and mci support
In-Reply-To: <20121103113406.GX29599@game.jcrosoft.org>
References: <20121103113406.GX29599@game.jcrosoft.org>
Message-ID: <20121115101122.GE31820@game.jcrosoft.org>

ping
On 12:34 Sat 03 Nov     , Jean-Christophe PLAGNIOL-VILLARD wrote:
> HI,
> 	v3: rebase on the v3 of at91sam9xek i2c support
> 
> 	with this +1 patch serie the support of the at91sam9x5ek is mostly
> 	complete
> 
> 	This will add spi and mci0 support as spi0 and mci0 conflict
> 
> 	We are still missing framebuffer, usb host and device and hardware i2c support
> 	but this wil be added later
> 
> 	This patch serie depedsn on the at91sam9x5ek i2c and m25p80 patcheries
> 
> 	the correct version
> 
> 	this one work but brake the etherent as it mux the 4 cs as gpio and we
> 	use them on the eth0
> 
> The following changes since commit b3a0963d358e14180e9bbde68ab78fdebae071b7:
> 
>   m25p80: sync flash support with the kernel (2012-11-03 04:23:15 +0800)
> 
> are available in the git repository at:
> 
>   git://git.jcrosoft.org/barebox.git delivery/at91sam9x5ek_mci_spi
> 
> for you to fetch changes up to dc7e1ce2a4ca879d07ba5786cfaa84f54d2ee763:
> 
>   at91sam9x5ek: add mci support (2012-11-03 04:23:48 +0800)
> 
> ----------------------------------------------------------------
> Jean-Christophe PLAGNIOL-VILLARD (4):
>       at91sam9x5: add spi support
>       at91sam9x5ek: add spi support
>       at91sam9x5: add mci support
>       at91sam9x5ek: add mci support
> 
>  arch/arm/boards/at91sam9x5ek/init.c     |   57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  arch/arm/configs/at91sam9x5ek_defconfig |   10 +++++++---
>  arch/arm/mach-at91/at91sam9x5.c         |    4 ++++
>  arch/arm/mach-at91/at91sam9x5_devices.c |  124 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 192 insertions(+), 3 deletions(-)
> 
> Best Regards,
> J.
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox


From plagnioj at jcrosoft.com  Thu Nov 15 05:11:50 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu, 15 Nov 2012 11:11:50 +0100
Subject: [PATCH 0/2] m25p80: re-import it againt mtd_add_host
In-Reply-To: <20121031120122.GF29599@game.jcrosoft.org>
References: <20121031120122.GF29599@game.jcrosoft.org>
Message-ID: <20121115101150.GF31820@game.jcrosoft.org>

ping

work on next
On 13:01 Wed 31 Oct     , Jean-Christophe PLAGNIOL-VILLARD wrote:
> Hi,
> 
> 	so we now create the cdev via mtd
> 
> 	This will also simplify sync with linux
> 
> 	to avoid the m25p8000 or m25p00 the cdev is still named name m25p and the
> 	drivers m25p80
> 
> 	sync with linux too
> 
> 	this patch series is agianst mtd_dataflash support
> 
> The following changes since commit 9428c386f876fa3a8871eeea4725a805cea5c367:
> 
>   mtd: add dataflash support (2012-10-31 04:48:39 +0800)
> 
> are available in the git repository at:
> 
>   git://git.jcrosoft.org/barebox.git delivery/m25p80
> 
> for you to fetch changes up to 35b8b98230dbcfe25973d5ed52a874027b4f3f05:
> 
>   m25p80: sync flash support with the kernel (2012-10-31 04:51:08 +0800)
> 
> ----------------------------------------------------------------
> Jean-Christophe PLAGNIOL-VILLARD (2):
>       m25p80: re-import it againt mtd_add_host
>       m25p80: sync flash support with the kernel
> 
>  arch/arm/boards/freescale-mx6-sabrelite/board.c |    2 +-
>  drivers/mtd/devices/Kconfig                     |   27 ++++++++++++
>  drivers/mtd/devices/Makefile                    |    1 +
>  drivers/{nor => mtd/devices}/m25p80.c           |  512 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------------
>  drivers/nor/Kconfig                             |   27 ------------
>  drivers/nor/Makefile                            |    1 -
>  drivers/nor/m25p80.h                            |   84 ------------------------------------
>  include/linux/mtd/cfi.h                         |   65 ++++++++++++++++++++++++++++
>  8 files changed, 371 insertions(+), 348 deletions(-)
>  rename drivers/{nor => mtd/devices}/m25p80.c (65%)
>  delete mode 100644 drivers/nor/m25p80.h
>  create mode 100644 include/linux/mtd/cfi.h
> 
> Best Regards,
> J.
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox


From plagnioj at jcrosoft.com  Thu Nov 15 05:41:04 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu, 15 Nov 2012 11:41:04 +0100
Subject: [PATCH 1/1] mx53-loco: fix phy reset
Message-ID: <1352976064-18544-1-git-send-email-plagnioj@jcrosoft.com>

the phy reset neet to be done before the fec driver is registered
as we accesst the phy at the fec probe time

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/boards/freescale-mx53-loco/board.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/arm/boards/freescale-mx53-loco/board.c b/arch/arm/boards/freescale-mx53-loco/board.c
index 45c05c2..216d26a 100644
--- a/arch/arm/boards/freescale-mx53-loco/board.c
+++ b/arch/arm/boards/freescale-mx53-loco/board.c
@@ -187,6 +187,7 @@ static int loco_devices_init(void)
 {
 
 	imx53_iim_register_fec_ethaddr();
+	loco_fec_reset();
 	imx53_add_fec(&fec_info);
 	imx53_add_mmc0(&loco_sd1_data);
 	imx53_add_mmc2(&loco_sd3_data);
@@ -196,8 +197,6 @@ static int loco_devices_init(void)
 	if (IS_ENABLED(CONFIG_USB_EHCI))
 		loco_ehci_init();
 
-	loco_fec_reset();
-
 	set_silicon_rev(imx_silicon_revision());
 
 	armlinux_set_bootparams((void *)0x70000100);
-- 
1.7.10.4



From christian.kapeller at cmotion.eu  Thu Nov 15 05:51:11 2012
From: christian.kapeller at cmotion.eu (Christian Kapeller)
Date: Thu, 15 Nov 2012 11:51:11 +0100
Subject: [PATCH] imx53: implement imx53_add_kpp
Message-ID: <1352976671-17492-1-git-send-email-christian.kapeller@cmotion.eu>

Allows usage of imx keypad driver in imx53 platforms

---
 arch/arm/mach-imx/include/mach/devices-imx53.h |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-imx/include/mach/devices-imx53.h b/arch/arm/mach-imx/include/mach/devices-imx53.h
index 5f967ea..6692396 100644
--- a/arch/arm/mach-imx/include/mach/devices-imx53.h
+++ b/arch/arm/mach-imx/include/mach/devices-imx53.h
@@ -82,3 +82,8 @@ static inline struct device_d *imx53_add_nand(struct imx_nand_platform_data *pda
 
 	return dev;
 }
+
+static inline struct device_d *imx53_add_kpp(struct matrix_keymap_data *pdata)
+{
+	return imx_add_kpp((void *)MX53_KPP_BASE_ADDR, pdata);
+}
-- 
1.7.5.4



From s.hauer at pengutronix.de  Thu Nov 15 06:27:46 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu, 15 Nov 2012 12:27:46 +0100
Subject: [PATCH 1/1] mx53-loco: fix phy reset
In-Reply-To: <1352976064-18544-1-git-send-email-plagnioj@jcrosoft.com>
References: <1352976064-18544-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <20121115112746.GA10369@pengutronix.de>

On Thu, Nov 15, 2012 at 11:41:04AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> the phy reset neet to be done before the fec driver is registered
> as we accesst the phy at the fec probe time

I spotted that aswell in the meantime. Applied, thanks

Sascha

> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
> ---
>  arch/arm/boards/freescale-mx53-loco/board.c |    3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/arch/arm/boards/freescale-mx53-loco/board.c b/arch/arm/boards/freescale-mx53-loco/board.c
> index 45c05c2..216d26a 100644
> --- a/arch/arm/boards/freescale-mx53-loco/board.c
> +++ b/arch/arm/boards/freescale-mx53-loco/board.c
> @@ -187,6 +187,7 @@ static int loco_devices_init(void)
>  {
>  
>  	imx53_iim_register_fec_ethaddr();
> +	loco_fec_reset();
>  	imx53_add_fec(&fec_info);
>  	imx53_add_mmc0(&loco_sd1_data);
>  	imx53_add_mmc2(&loco_sd3_data);
> @@ -196,8 +197,6 @@ static int loco_devices_init(void)
>  	if (IS_ENABLED(CONFIG_USB_EHCI))
>  		loco_ehci_init();
>  
> -	loco_fec_reset();
> -
>  	set_silicon_rev(imx_silicon_revision());
>  
>  	armlinux_set_bootparams((void *)0x70000100);
> -- 
> 1.7.10.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Thu Nov 15 06:29:19 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu, 15 Nov 2012 12:29:19 +0100
Subject: [PATCH 2/2] phy: add smsc phy driver support
In-Reply-To: <1352971904-12409-2-git-send-email-plagnioj@jcrosoft.com>
References: <1352971904-12409-1-git-send-email-plagnioj@jcrosoft.com>
 <1352971904-12409-2-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <20121115112919.GB10369@pengutronix.de>

On Thu, Nov 15, 2012 at 10:31:44AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> as we to have specific phy init to fix chip issue link detection support
> 
> based on linux 3.6
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>

The driver is never used here, because the generic phy is probed first.
For this to work we somehow have to make sure that the generic phy is
probed last.

Sascha

> ---
>  drivers/net/phy/Kconfig  |    5 ++
>  drivers/net/phy/Makefile |    1 +
>  drivers/net/phy/smsc.c   |  146 ++++++++++++++++++++++++++++++++++++++++++++++
>  include/linux/smscphy.h  |   25 ++++++++
>  4 files changed, 177 insertions(+)
>  create mode 100644 drivers/net/phy/smsc.c
>  create mode 100644 include/linux/smscphy.h
> 
> diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
> index b66261a..616b539 100644
> --- a/drivers/net/phy/Kconfig
> +++ b/drivers/net/phy/Kconfig
> @@ -14,4 +14,9 @@ config GENERIC_PHY
>  
>  endif
>  
> +config SMSC_PHY
> +	bool "Drivers for SMSC PHYs"
> +	---help---
> +	  Currently supports the LAN83C185, LAN8187 and LAN8700 PHYs
> +
>  endmenu
> diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
> index 82e90d4..0caeb70 100644
> --- a/drivers/net/phy/Makefile
> +++ b/drivers/net/phy/Makefile
> @@ -1,2 +1,3 @@
>  obj-y += phy.o mdio_bus.o
>  obj-$(CONFIG_GENERIC_PHY) += generic.o
> +obj-$(CONFIG_SMSC_PHY)		+= smsc.o
> diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c
> new file mode 100644
> index 0000000..3c201f6
> --- /dev/null
> +++ b/drivers/net/phy/smsc.c
> @@ -0,0 +1,146 @@
> +/*
> + * drivers/net/phy/smsc.c
> + *
> + * Driver for SMSC PHYs
> + *
> + * Author: Herbert Valerio Riedel
> + *
> + * Copyright (c) 2006 Herbert Valerio Riedel <hvr at gnu.org>
> + *
> + * This program is free software; you can redistribute  it and/or modify it
> + * under  the terms of  the GNU General  Public License as published by the
> + * Free Software Foundation;  either version 2 of the  License, or (at your
> + * option) any later version.
> + *
> + * Support added for SMSC LAN8187 and LAN8700 by steve.glendinning at shawell.net
> + *
> + */
> +
> +#include <common.h>
> +#include <init.h>
> +#include <linux/mii.h>
> +#include <linux/ethtool.h>
> +#include <linux/phy.h>
> +#include <linux/smscphy.h>
> +
> +static int smsc_phy_ack_interrupt(struct phy_device *phydev)
> +{
> +	int rc = phy_read (phydev, MII_LAN83C185_ISF);
> +
> +	return rc < 0 ? rc : 0;
> +}
> +
> +static int smsc_phy_config_init(struct phy_device *phydev)
> +{
> +	int rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
> +	if (rc < 0)
> +		return rc;
> +
> +	/* Enable energy detect mode for this SMSC Transceivers */
> +	rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS,
> +		       rc | MII_LAN83C185_EDPWRDOWN);
> +	if (rc < 0)
> +		return rc;
> +
> +	return smsc_phy_ack_interrupt (phydev);
> +}
> +
> +static int lan87xx_config_init(struct phy_device *phydev)
> +{
> +	/*
> +	 * Make sure the EDPWRDOWN bit is NOT set. Setting this bit on
> +	 * LAN8710/LAN8720 PHY causes the PHY to misbehave, likely due
> +	 * to a bug on the chip.
> +	 *
> +	 * When the system is powered on with the network cable being
> +	 * disconnected all the way until after ifconfig ethX up is
> +	 * issued for the LAN port with this PHY, connecting the cable
> +	 * afterwards does not cause LINK change detection, while the
> +	 * expected behavior is the Link UP being detected.
> +	 */
> +	int rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
> +	if (rc < 0)
> +		return rc;
> +
> +	rc &= ~MII_LAN83C185_EDPWRDOWN;
> +
> +	rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS, rc);
> +	if (rc < 0)
> +		return rc;
> +
> +	return smsc_phy_ack_interrupt(phydev);
> +}
> +
> +static int lan911x_config_init(struct phy_device *phydev)
> +{
> +	return smsc_phy_ack_interrupt(phydev);
> +}
> +
> +static struct phy_driver smsc_phy_driver[] = {
> +{
> +	.phy_id		= 0x0007c0a0, /* OUI=0x00800f, Model#=0x0a */
> +	.phy_id_mask	= 0xfffffff0,
> +	.drv.name	= "SMSC LAN83C185",
> +
> +	.features	= (PHY_BASIC_FEATURES | SUPPORTED_Pause
> +				| SUPPORTED_Asym_Pause),
> +
> +	/* basic functions */
> +	.config_aneg	= genphy_config_aneg,
> +	.read_status	= genphy_read_status,
> +	.config_init	= smsc_phy_config_init,
> +}, {
> +	.phy_id		= 0x0007c0b0, /* OUI=0x00800f, Model#=0x0b */
> +	.phy_id_mask	= 0xfffffff0,
> +	.drv.name	= "SMSC LAN8187",
> +
> +	.features	= (PHY_BASIC_FEATURES | SUPPORTED_Pause
> +				| SUPPORTED_Asym_Pause),
> +
> +	/* basic functions */
> +	.config_aneg	= genphy_config_aneg,
> +	.read_status	= genphy_read_status,
> +	.config_init	= smsc_phy_config_init,
> +}, {
> +	.phy_id		= 0x0007c0c0, /* OUI=0x00800f, Model#=0x0c */
> +	.phy_id_mask	= 0xfffffff0,
> +	.drv.name	= "SMSC LAN8700",
> +
> +	.features	= (PHY_BASIC_FEATURES | SUPPORTED_Pause
> +				| SUPPORTED_Asym_Pause),
> +
> +	/* basic functions */
> +	.config_aneg	= genphy_config_aneg,
> +	.read_status	= genphy_read_status,
> +	.config_init	= smsc_phy_config_init,
> +}, {
> +	.phy_id		= 0x0007c0d0, /* OUI=0x00800f, Model#=0x0d */
> +	.phy_id_mask	= 0xfffffff0,
> +	.drv.name	= "SMSC LAN911x Internal PHY",
> +
> +	.features	= (PHY_BASIC_FEATURES | SUPPORTED_Pause
> +				| SUPPORTED_Asym_Pause),
> +
> +	/* basic functions */
> +	.config_aneg	= genphy_config_aneg,
> +	.read_status	= genphy_read_status,
> +	.config_init	= lan911x_config_init,
> +}, {
> +	.phy_id		= 0x0007c0f0, /* OUI=0x00800f, Model#=0x0f */
> +	.phy_id_mask	= 0xfffffff0,
> +	.drv.name	= "SMSC LAN8710/LAN8720",
> +
> +	.features	= (PHY_BASIC_FEATURES | SUPPORTED_Pause
> +				| SUPPORTED_Asym_Pause),
> +
> +	/* basic functions */
> +	.config_aneg	= genphy_config_aneg,
> +	.read_status	= genphy_read_status,
> +	.config_init	= lan87xx_config_init,
> +} };
> +
> +static int __init smsc_init(void)
> +{
> +	return phy_drivers_register(smsc_phy_driver, ARRAY_SIZE(smsc_phy_driver));
> +}
> +device_initcall(smsc_init);
> diff --git a/include/linux/smscphy.h b/include/linux/smscphy.h
> new file mode 100644
> index 0000000..ce718cb
> --- /dev/null
> +++ b/include/linux/smscphy.h
> @@ -0,0 +1,25 @@
> +#ifndef __LINUX_SMSCPHY_H__
> +#define __LINUX_SMSCPHY_H__
> +
> +#define MII_LAN83C185_ISF 29 /* Interrupt Source Flags */
> +#define MII_LAN83C185_IM  30 /* Interrupt Mask */
> +#define MII_LAN83C185_CTRL_STATUS 17 /* Mode/Status Register */
> +
> +#define MII_LAN83C185_ISF_INT1 (1<<1) /* Auto-Negotiation Page Received */
> +#define MII_LAN83C185_ISF_INT2 (1<<2) /* Parallel Detection Fault */
> +#define MII_LAN83C185_ISF_INT3 (1<<3) /* Auto-Negotiation LP Ack */
> +#define MII_LAN83C185_ISF_INT4 (1<<4) /* Link Down */
> +#define MII_LAN83C185_ISF_INT5 (1<<5) /* Remote Fault Detected */
> +#define MII_LAN83C185_ISF_INT6 (1<<6) /* Auto-Negotiation complete */
> +#define MII_LAN83C185_ISF_INT7 (1<<7) /* ENERGYON */
> +
> +#define MII_LAN83C185_ISF_INT_ALL (0x0e)
> +
> +#define MII_LAN83C185_ISF_INT_PHYLIB_EVENTS \
> +	(MII_LAN83C185_ISF_INT6 | MII_LAN83C185_ISF_INT4 | \
> +	 MII_LAN83C185_ISF_INT7)
> +
> +#define MII_LAN83C185_EDPWRDOWN (1 << 13) /* EDPWRDOWN */
> +#define MII_LAN83C185_ENERGYON  (1 << 1)  /* ENERGYON */
> +
> +#endif /* __LINUX_SMSCPHY_H__ */
> -- 
> 1.7.10.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Thu Nov 15 06:46:49 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu, 15 Nov 2012 12:46:49 +0100
Subject: [TX53: boot fixes 0/2] Make TX53 bootable again
In-Reply-To: <1352973435-11618-1-git-send-email-christian.kapeller@cmotion.eu>
References: <alpine.LSU.2.00.1211121220380.14365@redbean.intranet.gw-instruments.de>
 <1352973435-11618-1-git-send-email-christian.kapeller@cmotion.eu>
Message-ID: <20121115114649.GC10369@pengutronix.de>

On Thu, Nov 15, 2012 at 10:57:13AM +0100, Christian Kapeller wrote:
> Currently KaRo TX53-8030 soc module support is present in next branch, but
> compiling the default config tx53stk5_defconfig results in an unbootable image.
> 
> This series 
>  * makes the TX53-8030 board boot again [1/2]
>  * fixes compilation of the TX53 board with PBL_IMAGE=n and DO_LOWLEVEL_RESET=n [2/2]

Applied. Thanks for fixing this.

Sascha

> 
> Christian Kapeller (2):
>   tx53: Fix unbootable TX53-8030.
>   tx53: remove reset() when not doing lowlevel init.
> 
>  arch/arm/boards/karo-tx53/dcd-data-xx30.h |    1 -
>  arch/arm/boards/karo-tx53/lowlevel.c      |    3 +++
>  2 files changed, 3 insertions(+), 1 deletions(-)
> 
> -- 
> 1.7.5.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From plagnioj at jcrosoft.com  Thu Nov 15 06:51:22 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu, 15 Nov 2012 12:51:22 +0100
Subject: [PATCH 1/1] mx53-loco: fix phy reset
Message-ID: <1352980282-24731-1-git-send-email-plagnioj@jcrosoft.com>

the phy reset neet to be done before the fec driver is registered
as we accesst the phy at the fec probe time

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/boards/freescale-mx53-loco/board.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/arm/boards/freescale-mx53-loco/board.c b/arch/arm/boards/freescale-mx53-loco/board.c
index 45c05c2..216d26a 100644
--- a/arch/arm/boards/freescale-mx53-loco/board.c
+++ b/arch/arm/boards/freescale-mx53-loco/board.c
@@ -187,6 +187,7 @@ static int loco_devices_init(void)
 {
 
 	imx53_iim_register_fec_ethaddr();
+	loco_fec_reset();
 	imx53_add_fec(&fec_info);
 	imx53_add_mmc0(&loco_sd1_data);
 	imx53_add_mmc2(&loco_sd3_data);
@@ -196,8 +197,6 @@ static int loco_devices_init(void)
 	if (IS_ENABLED(CONFIG_USB_EHCI))
 		loco_ehci_init();
 
-	loco_fec_reset();
-
 	set_silicon_rev(imx_silicon_revision());
 
 	armlinux_set_bootparams((void *)0x70000100);
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Thu Nov 15 06:52:43 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu, 15 Nov 2012 12:52:43 +0100
Subject: [PATCH 1/1] mx53-loco: fix phy reset
In-Reply-To: <1352980282-24731-1-git-send-email-plagnioj@jcrosoft.com>
References: <1352980282-24731-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <20121115115243.GG31820@game.jcrosoft.org>

On 12:51 Thu 15 Nov     , Jean-Christophe PLAGNIOL-VILLARD wrote:
> the phy reset neet to be done before the fec driver is registered
> as we accesst the phy at the fec probe time
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
> ---
forget this one this was send twice

Best Regards,
J.
>  arch/arm/boards/freescale-mx53-loco/board.c |    3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/arch/arm/boards/freescale-mx53-loco/board.c b/arch/arm/boards/freescale-mx53-loco/board.c
> index 45c05c2..216d26a 100644
> --- a/arch/arm/boards/freescale-mx53-loco/board.c
> +++ b/arch/arm/boards/freescale-mx53-loco/board.c
> @@ -187,6 +187,7 @@ static int loco_devices_init(void)
>  {
>  
>  	imx53_iim_register_fec_ethaddr();
> +	loco_fec_reset();
>  	imx53_add_fec(&fec_info);
>  	imx53_add_mmc0(&loco_sd1_data);
>  	imx53_add_mmc2(&loco_sd3_data);
> @@ -196,8 +197,6 @@ static int loco_devices_init(void)
>  	if (IS_ENABLED(CONFIG_USB_EHCI))
>  		loco_ehci_init();
>  
> -	loco_fec_reset();
> -
>  	set_silicon_rev(imx_silicon_revision());
>  
>  	armlinux_set_bootparams((void *)0x70000100);
> -- 
> 1.7.10.4
> 


From plagnioj at jcrosoft.com  Thu Nov 15 06:56:02 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu, 15 Nov 2012 12:56:02 +0100
Subject: [PATCH 1/1] mx53 loco: enable smsc phy driver
Message-ID: <1352980562-25383-1-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/configs/freescale_mx53_loco_defconfig |    1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/configs/freescale_mx53_loco_defconfig b/arch/arm/configs/freescale_mx53_loco_defconfig
index 37aa182..b50b050 100644
--- a/arch/arm/configs/freescale_mx53_loco_defconfig
+++ b/arch/arm/configs/freescale_mx53_loco_defconfig
@@ -53,6 +53,7 @@ CONFIG_NET_PING=y
 CONFIG_CMD_TFTP=y
 CONFIG_FS_TFTP=y
 CONFIG_NET_NETCONSOLE=y
+CONFIG_SMSC_PHY=y
 CONFIG_DRIVER_NET_FEC_IMX=y
 # CONFIG_SPI is not set
 CONFIG_I2C=y
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Thu Nov 15 06:58:08 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu, 15 Nov 2012 12:58:08 +0100
Subject: [PATCH 1/1 v2] phy: add smsc phy driver support
In-Reply-To: <1352971904-12409-2-git-send-email-plagnioj@jcrosoft.com>
References: <1352971904-12409-2-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1352980688-25683-1-git-send-email-plagnioj@jcrosoft.com>

as we to have specific phy init to fix chip issue link detection support

based on linux 3.6

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
v2:

	ensure the phy driver are probe before the generic one
	so register them first

Best Regards,
J.
 drivers/net/phy/Kconfig  |    5 ++
 drivers/net/phy/Makefile |    1 +
 drivers/net/phy/smsc.c   |  146 ++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/smscphy.h  |   25 ++++++++
 4 files changed, 177 insertions(+)
 create mode 100644 drivers/net/phy/smsc.c
 create mode 100644 include/linux/smscphy.h

diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index b66261a..616b539 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -14,4 +14,9 @@ config GENERIC_PHY
 
 endif
 
+config SMSC_PHY
+	bool "Drivers for SMSC PHYs"
+	---help---
+	  Currently supports the LAN83C185, LAN8187 and LAN8700 PHYs
+
 endmenu
diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
index 82e90d4..0caeb70 100644
--- a/drivers/net/phy/Makefile
+++ b/drivers/net/phy/Makefile
@@ -1,2 +1,3 @@
 obj-y += phy.o mdio_bus.o
 obj-$(CONFIG_GENERIC_PHY) += generic.o
+obj-$(CONFIG_SMSC_PHY)		+= smsc.o
diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c
new file mode 100644
index 0000000..a318624
--- /dev/null
+++ b/drivers/net/phy/smsc.c
@@ -0,0 +1,146 @@
+/*
+ * drivers/net/phy/smsc.c
+ *
+ * Driver for SMSC PHYs
+ *
+ * Author: Herbert Valerio Riedel
+ *
+ * Copyright (c) 2006 Herbert Valerio Riedel <hvr at gnu.org>
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ *
+ * Support added for SMSC LAN8187 and LAN8700 by steve.glendinning at shawell.net
+ *
+ */
+
+#include <common.h>
+#include <init.h>
+#include <linux/mii.h>
+#include <linux/ethtool.h>
+#include <linux/phy.h>
+#include <linux/smscphy.h>
+
+static int smsc_phy_ack_interrupt(struct phy_device *phydev)
+{
+	int rc = phy_read (phydev, MII_LAN83C185_ISF);
+
+	return rc < 0 ? rc : 0;
+}
+
+static int smsc_phy_config_init(struct phy_device *phydev)
+{
+	int rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
+	if (rc < 0)
+		return rc;
+
+	/* Enable energy detect mode for this SMSC Transceivers */
+	rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS,
+		       rc | MII_LAN83C185_EDPWRDOWN);
+	if (rc < 0)
+		return rc;
+
+	return smsc_phy_ack_interrupt (phydev);
+}
+
+static int lan87xx_config_init(struct phy_device *phydev)
+{
+	/*
+	 * Make sure the EDPWRDOWN bit is NOT set. Setting this bit on
+	 * LAN8710/LAN8720 PHY causes the PHY to misbehave, likely due
+	 * to a bug on the chip.
+	 *
+	 * When the system is powered on with the network cable being
+	 * disconnected all the way until after ifconfig ethX up is
+	 * issued for the LAN port with this PHY, connecting the cable
+	 * afterwards does not cause LINK change detection, while the
+	 * expected behavior is the Link UP being detected.
+	 */
+	int rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
+	if (rc < 0)
+		return rc;
+
+	rc &= ~MII_LAN83C185_EDPWRDOWN;
+
+	rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS, rc);
+	if (rc < 0)
+		return rc;
+
+	return smsc_phy_ack_interrupt(phydev);
+}
+
+static int lan911x_config_init(struct phy_device *phydev)
+{
+	return smsc_phy_ack_interrupt(phydev);
+}
+
+static struct phy_driver smsc_phy_driver[] = {
+{
+	.phy_id		= 0x0007c0a0, /* OUI=0x00800f, Model#=0x0a */
+	.phy_id_mask	= 0xfffffff0,
+	.drv.name	= "SMSC LAN83C185",
+
+	.features	= (PHY_BASIC_FEATURES | SUPPORTED_Pause
+				| SUPPORTED_Asym_Pause),
+
+	/* basic functions */
+	.config_aneg	= genphy_config_aneg,
+	.read_status	= genphy_read_status,
+	.config_init	= smsc_phy_config_init,
+}, {
+	.phy_id		= 0x0007c0b0, /* OUI=0x00800f, Model#=0x0b */
+	.phy_id_mask	= 0xfffffff0,
+	.drv.name	= "SMSC LAN8187",
+
+	.features	= (PHY_BASIC_FEATURES | SUPPORTED_Pause
+				| SUPPORTED_Asym_Pause),
+
+	/* basic functions */
+	.config_aneg	= genphy_config_aneg,
+	.read_status	= genphy_read_status,
+	.config_init	= smsc_phy_config_init,
+}, {
+	.phy_id		= 0x0007c0c0, /* OUI=0x00800f, Model#=0x0c */
+	.phy_id_mask	= 0xfffffff0,
+	.drv.name	= "SMSC LAN8700",
+
+	.features	= (PHY_BASIC_FEATURES | SUPPORTED_Pause
+				| SUPPORTED_Asym_Pause),
+
+	/* basic functions */
+	.config_aneg	= genphy_config_aneg,
+	.read_status	= genphy_read_status,
+	.config_init	= smsc_phy_config_init,
+}, {
+	.phy_id		= 0x0007c0d0, /* OUI=0x00800f, Model#=0x0d */
+	.phy_id_mask	= 0xfffffff0,
+	.drv.name	= "SMSC LAN911x Internal PHY",
+
+	.features	= (PHY_BASIC_FEATURES | SUPPORTED_Pause
+				| SUPPORTED_Asym_Pause),
+
+	/* basic functions */
+	.config_aneg	= genphy_config_aneg,
+	.read_status	= genphy_read_status,
+	.config_init	= lan911x_config_init,
+}, {
+	.phy_id		= 0x0007c0f0, /* OUI=0x00800f, Model#=0x0f */
+	.phy_id_mask	= 0xfffffff0,
+	.drv.name	= "SMSC LAN8710/LAN8720",
+
+	.features	= (PHY_BASIC_FEATURES | SUPPORTED_Pause
+				| SUPPORTED_Asym_Pause),
+
+	/* basic functions */
+	.config_aneg	= genphy_config_aneg,
+	.read_status	= genphy_read_status,
+	.config_init	= lan87xx_config_init,
+} };
+
+static int __init smsc_init(void)
+{
+	return phy_drivers_register(smsc_phy_driver, ARRAY_SIZE(smsc_phy_driver));
+}
+fs_initcall(smsc_init);
diff --git a/include/linux/smscphy.h b/include/linux/smscphy.h
new file mode 100644
index 0000000..ce718cb
--- /dev/null
+++ b/include/linux/smscphy.h
@@ -0,0 +1,25 @@
+#ifndef __LINUX_SMSCPHY_H__
+#define __LINUX_SMSCPHY_H__
+
+#define MII_LAN83C185_ISF 29 /* Interrupt Source Flags */
+#define MII_LAN83C185_IM  30 /* Interrupt Mask */
+#define MII_LAN83C185_CTRL_STATUS 17 /* Mode/Status Register */
+
+#define MII_LAN83C185_ISF_INT1 (1<<1) /* Auto-Negotiation Page Received */
+#define MII_LAN83C185_ISF_INT2 (1<<2) /* Parallel Detection Fault */
+#define MII_LAN83C185_ISF_INT3 (1<<3) /* Auto-Negotiation LP Ack */
+#define MII_LAN83C185_ISF_INT4 (1<<4) /* Link Down */
+#define MII_LAN83C185_ISF_INT5 (1<<5) /* Remote Fault Detected */
+#define MII_LAN83C185_ISF_INT6 (1<<6) /* Auto-Negotiation complete */
+#define MII_LAN83C185_ISF_INT7 (1<<7) /* ENERGYON */
+
+#define MII_LAN83C185_ISF_INT_ALL (0x0e)
+
+#define MII_LAN83C185_ISF_INT_PHYLIB_EVENTS \
+	(MII_LAN83C185_ISF_INT6 | MII_LAN83C185_ISF_INT4 | \
+	 MII_LAN83C185_ISF_INT7)
+
+#define MII_LAN83C185_EDPWRDOWN (1 << 13) /* EDPWRDOWN */
+#define MII_LAN83C185_ENERGYON  (1 << 1)  /* ENERGYON */
+
+#endif /* __LINUX_SMSCPHY_H__ */
-- 
1.7.10.4



From christian.kapeller at cmotion.eu  Thu Nov 15 07:00:54 2012
From: christian.kapeller at cmotion.eu (Christian Kapeller)
Date: Thu, 15 Nov 2012 13:00:54 +0100
Subject: [TX53: boot fixes 0/2] Make TX53 bootable again
In-Reply-To: <20121115114649.GC10369@pengutronix.de>
References: <alpine.LSU.2.00.1211121220380.14365@redbean.intranet.gw-instruments.de>
 <1352973435-11618-1-git-send-email-christian.kapeller@cmotion.eu>
 <20121115114649.GC10369@pengutronix.de>
Message-ID: <50A4D976.4050409@cmotion.eu>

On 11/15/2012 12:46 PM, Sascha Hauer wrote:
> On Thu, Nov 15, 2012 at 10:57:13AM +0100, Christian Kapeller wrote:
>> Currently KaRo TX53-8030 soc module support is present in next branch, but
>> compiling the default config tx53stk5_defconfig results in an unbootable image.
>>
>> This series 
>>  * makes the TX53-8030 board boot again [1/2]
>>  * fixes compilation of the TX53 board with PBL_IMAGE=n and DO_LOWLEVEL_RESET=n [2/2]
> 
> Applied. Thanks for fixing this.

You're welcome. After all, I am happy to enable others to use hot piece of
boot software on the Karo hardware. Also it is good to see, that other
people are using it.

Cheers,
Christian






From plagnioj at jcrosoft.com  Thu Nov 15 07:45:58 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu, 15 Nov 2012 13:45:58 +0100
Subject: [PATCH 1/1] mci-core: fix debug Capacity cast
Message-ID: <1352983558-29740-1-git-send-email-plagnioj@jcrosoft.com>

so we print the correct size

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/mci/mci-core.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index b01b7ec..b6f9076 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -753,7 +753,7 @@ static void mci_extract_card_capacity_from_csd(struct mci *mci)
 
 	mci->capacity = (csize + 1) << (cmult + 2);
 	mci->capacity *= mci->read_bl_len;
-	dev_dbg(mci->mci_dev, "Capacity: %u MiB\n", (unsigned)mci->capacity >> 20);
+	dev_dbg(mci->mci_dev, "Capacity: %u MiB\n", (unsigned)(mci->capacity >> 20));
 }
 
 static int mmc_compare_ext_csds(struct mci *mci, unsigned bus_width)
-- 
1.7.10.4



From s.hauer at pengutronix.de  Thu Nov 15 08:40:19 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu, 15 Nov 2012 14:40:19 +0100
Subject: [PATCH 1/1] mx53 loco: enable smsc phy driver
In-Reply-To: <1352980562-25383-1-git-send-email-plagnioj@jcrosoft.com>
References: <1352980562-25383-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <20121115134019.GE10369@pengutronix.de>

On Thu, Nov 15, 2012 at 12:56:02PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
> ---
>  arch/arm/configs/freescale_mx53_loco_defconfig |    1 +
>  1 file changed, 1 insertion(+)

We're getting closer \o/

With this the LOCO correctly waits for a link, unfortunately during
board init time. This is due to:

commit 3a17af33c01fd066ab3939c8218037c87ba26eed
Author: Sascha Hauer <s.hauer at pengutronix.de>
Date:   Fri Oct 26 16:16:54 2012 +0200

    net fec: connect phy at probe time
    
    Several i.MX boards (all i.MX6 boards) need to do some adjustments
    to phy registers. If barebox itself does not use network, networking
    won't work in the kernel if the kernel does not have the fixups. Connect
    the phy at probe time so that these tweaks are done during probe so that
    the kernel works without phy register tweaks. Also this has the effect
    that the phy device is present and introspectable without doing fake
    network transfers beforehand.

We could revert it which fixes things for the LOCO, but then we also
lose the phy fixups which this commit intentionally pushed to probe
time.

It would be nice to separate phy registration from actually waiting for
a link. I find it rather inconvenient anyway that the phy device pops
up during the first network transfer.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Thu Nov 15 08:41:10 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu, 15 Nov 2012 14:41:10 +0100
Subject: [PATCH 1/1] mci-core: fix debug Capacity cast
In-Reply-To: <1352983558-29740-1-git-send-email-plagnioj@jcrosoft.com>
References: <1352983558-29740-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <20121115134110.GF10369@pengutronix.de>

On Thu, Nov 15, 2012 at 01:45:58PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> so we print the correct size
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>

Applied, thanks

Sascha

> ---
>  drivers/mci/mci-core.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
> index b01b7ec..b6f9076 100644
> --- a/drivers/mci/mci-core.c
> +++ b/drivers/mci/mci-core.c
> @@ -753,7 +753,7 @@ static void mci_extract_card_capacity_from_csd(struct mci *mci)
>  
>  	mci->capacity = (csize + 1) << (cmult + 2);
>  	mci->capacity *= mci->read_bl_len;
> -	dev_dbg(mci->mci_dev, "Capacity: %u MiB\n", (unsigned)mci->capacity >> 20);
> +	dev_dbg(mci->mci_dev, "Capacity: %u MiB\n", (unsigned)(mci->capacity >> 20));
>  }
>  
>  static int mmc_compare_ext_csds(struct mci *mci, unsigned bus_width)
> -- 
> 1.7.10.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From plagnioj at jcrosoft.com  Thu Nov 15 08:48:23 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu, 15 Nov 2012 14:48:23 +0100
Subject: [PATCH 1/1] mx53 loco: enable smsc phy driver
In-Reply-To: <20121115134019.GE10369@pengutronix.de>
References: <1352980562-25383-1-git-send-email-plagnioj@jcrosoft.com>
 <20121115134019.GE10369@pengutronix.de>
Message-ID: <20121115134823.GH31820@game.jcrosoft.org>

On 14:40 Thu 15 Nov     , Sascha Hauer wrote:
> On Thu, Nov 15, 2012 at 12:56:02PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
> > ---
> >  arch/arm/configs/freescale_mx53_loco_defconfig |    1 +
> >  1 file changed, 1 insertion(+)
> 
> We're getting closer \o/
> 
> With this the LOCO correctly waits for a link, unfortunately during
> board init time. This is due to:
> 
> commit 3a17af33c01fd066ab3939c8218037c87ba26eed
> Author: Sascha Hauer <s.hauer at pengutronix.de>
> Date:   Fri Oct 26 16:16:54 2012 +0200
> 
>     net fec: connect phy at probe time
>     
>     Several i.MX boards (all i.MX6 boards) need to do some adjustments
>     to phy registers. If barebox itself does not use network, networking
>     won't work in the kernel if the kernel does not have the fixups. Connect
>     the phy at probe time so that these tweaks are done during probe so that
>     the kernel works without phy register tweaks. Also this has the effect
>     that the phy device is present and introspectable without doing fake
>     network transfers beforehand.
> 
> We could revert it which fixes things for the LOCO, but then we also
> lose the phy fixups which this commit intentionally pushed to probe
> time.
> 
> It would be nice to separate phy registration from actually waiting for
> a link. I find it rather inconvenient anyway that the phy device pops
> up during the first network transfer.

so we need to introduce a phy_start

that start the check of the link

but I think the kernel need to its own fixup and do not relay on the booloader
to do it for him

Best Regards,
J.


From s.hauer at pengutronix.de  Thu Nov 15 09:11:26 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu, 15 Nov 2012 15:11:26 +0100
Subject: [PATCH 1/1] mx53 loco: enable smsc phy driver
In-Reply-To: <20121115134823.GH31820@game.jcrosoft.org>
References: <1352980562-25383-1-git-send-email-plagnioj@jcrosoft.com>
 <20121115134019.GE10369@pengutronix.de>
 <20121115134823.GH31820@game.jcrosoft.org>
Message-ID: <20121115141126.GH10369@pengutronix.de>

On Thu, Nov 15, 2012 at 02:48:23PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 14:40 Thu 15 Nov     , Sascha Hauer wrote:
> > On Thu, Nov 15, 2012 at 12:56:02PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
> > > ---
> > >  arch/arm/configs/freescale_mx53_loco_defconfig |    1 +
> > >  1 file changed, 1 insertion(+)
> > 
> > We're getting closer \o/
> > 
> > With this the LOCO correctly waits for a link, unfortunately during
> > board init time. This is due to:
> > 
> > commit 3a17af33c01fd066ab3939c8218037c87ba26eed
> > Author: Sascha Hauer <s.hauer at pengutronix.de>
> > Date:   Fri Oct 26 16:16:54 2012 +0200
> > 
> >     net fec: connect phy at probe time
> >     
> >     Several i.MX boards (all i.MX6 boards) need to do some adjustments
> >     to phy registers. If barebox itself does not use network, networking
> >     won't work in the kernel if the kernel does not have the fixups. Connect
> >     the phy at probe time so that these tweaks are done during probe so that
> >     the kernel works without phy register tweaks. Also this has the effect
> >     that the phy device is present and introspectable without doing fake
> >     network transfers beforehand.
> > 
> > We could revert it which fixes things for the LOCO, but then we also
> > lose the phy fixups which this commit intentionally pushed to probe
> > time.
> > 
> > It would be nice to separate phy registration from actually waiting for
> > a link. I find it rather inconvenient anyway that the phy device pops
> > up during the first network transfer.
> 
> so we need to introduce a phy_start
> 
> that start the check of the link
> 
> but I think the kernel need to its own fixup and do not relay on the booloader
> to do it for him

I agree, the kernel should not depend on the bootloader, still it's
convenient that kernels without support for this specific board will
just work. I can live with reverting the patch for this release though.

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From plagnioj at jcrosoft.com  Thu Nov 15 09:11:47 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu, 15 Nov 2012 15:11:47 +0100
Subject: [PATCH 1/1] phylib: split config start to connect
Message-ID: <1352988707-4745-1-git-send-email-plagnioj@jcrosoft.com>

so we can detect and attached the phy without waiting for the link
and wait for the link only at open

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/net/altera_tse.c   |    2 +-
 drivers/net/at91_ether.c   |    4 ++++
 drivers/net/davinci_emac.c |    4 ++++
 drivers/net/designware.c   |    4 ++++
 drivers/net/dm9k.c         |    8 +++++++-
 drivers/net/ep93xx.c       |    4 ++++
 drivers/net/fec_imx.c      |    5 +++++
 drivers/net/fec_mpc5200.c  |    8 +++++++-
 drivers/net/gianfar.c      |    4 ++++
 drivers/net/ks8851_mll.c   |    4 ++++
 drivers/net/macb.c         |    7 ++++++-
 drivers/net/netx_eth.c     |    7 ++++++-
 drivers/net/phy/phy.c      |   13 +++++++++++--
 drivers/net/smc91111.c     |    7 ++++++-
 drivers/net/smc911x.c      |    4 ++++
 drivers/net/usb/usbnet.c   |    7 ++++++-
 include/linux/phy.h        |    1 +
 17 files changed, 84 insertions(+), 9 deletions(-)

diff --git a/drivers/net/altera_tse.c b/drivers/net/altera_tse.c
index f0e907e..c69e461 100644
--- a/drivers/net/altera_tse.c
+++ b/drivers/net/altera_tse.c
@@ -348,7 +348,7 @@ static int tse_eth_open(struct eth_device *edev)
 	if (ret)
 		return ret;
 
-	return 0;
+	return phy_start(edev->phydev);
 }
 
 static int tse_eth_send(struct eth_device *edev, void *packet, int length)
diff --git a/drivers/net/at91_ether.c b/drivers/net/at91_ether.c
index a6d6183..90fabab 100644
--- a/drivers/net/at91_ether.c
+++ b/drivers/net/at91_ether.c
@@ -163,6 +163,10 @@ static int at91_ether_open(struct eth_device *edev)
 	if (ret)
 		return ret;
 
+	ret = phy_start(edev->phydev);
+	if (ret)
+		return ret;
+
 	/* Clear internal statistics */
 	ctl = at91_emac_read(AT91_EMAC_CTL);
 	at91_emac_write(AT91_EMAC_CTL, ctl | AT91_EMAC_CSR);
diff --git a/drivers/net/davinci_emac.c b/drivers/net/davinci_emac.c
index 989e119..8421c4f 100644
--- a/drivers/net/davinci_emac.c
+++ b/drivers/net/davinci_emac.c
@@ -312,6 +312,10 @@ static int davinci_emac_open(struct eth_device *edev)
 	if (ret)
 		return ret;
 
+	ret = phy_start(edev->phydev);
+	if (ret)
+		return ret;
+
 	dev_dbg(priv->dev, "- emac_open\n");
 
 	return 0;
diff --git a/drivers/net/designware.c b/drivers/net/designware.c
index f803e66..4d63188 100644
--- a/drivers/net/designware.c
+++ b/drivers/net/designware.c
@@ -267,6 +267,10 @@ static int dwc_ether_open(struct eth_device *dev)
 	if (ret)
 		return ret;
 
+	ret = phy_start(dev->phydev);
+	if (ret)
+		return ret;
+
 	descs_init(dev);
 
 	/*
diff --git a/drivers/net/dm9k.c b/drivers/net/dm9k.c
index 8be0f16..db619da 100644
--- a/drivers/net/dm9k.c
+++ b/drivers/net/dm9k.c
@@ -468,10 +468,16 @@ static void dm9k_reset(struct dm9k *priv)
 
 static int dm9k_eth_open(struct eth_device *edev)
 {
+	int ret;
+
 	struct dm9k *priv = (struct dm9k *)edev->priv;
 
-	return phy_device_connect(edev, &priv->miibus, 0, NULL,
+	ret = phy_device_connect(edev, &priv->miibus, 0, NULL,
 				 0, PHY_INTERFACE_MODE_NA);
+	if (ret)
+		return ret;
+
+	return phy_start(edev->phydev);
 }
 
 static void dm9k_write_length(struct dm9k *priv, unsigned length)
diff --git a/drivers/net/ep93xx.c b/drivers/net/ep93xx.c
index 37c9f0a..2ae45d9 100644
--- a/drivers/net/ep93xx.c
+++ b/drivers/net/ep93xx.c
@@ -208,6 +208,10 @@ static int ep93xx_eth_open(struct eth_device *edev)
 	if (ret)
 		return ret;
 
+	ret =  phy_start(edev->phydev);
+	if (ret)
+		return ret;
+
 	ep93xx_eth_reset(edev);
 
 	/* Reset the descriptor queues' current and end address values */
diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c
index 9a17e6d..f709c1f 100644
--- a/drivers/net/fec_imx.c
+++ b/drivers/net/fec_imx.c
@@ -397,6 +397,11 @@ static int fec_open(struct eth_device *edev)
 {
 	struct fec_priv *fec = (struct fec_priv *)edev->priv;
 	u32 ecr;
+	int ret;
+
+	ret = phy_start(edev->phydev);
+	if (ret)
+		return ret;
 
 	/*
 	 * Initialize RxBD/TxBD rings
diff --git a/drivers/net/fec_mpc5200.c b/drivers/net/fec_mpc5200.c
index a14c8d1..7716978 100644
--- a/drivers/net/fec_mpc5200.c
+++ b/drivers/net/fec_mpc5200.c
@@ -407,8 +407,14 @@ static int mpc5xxx_fec_open(struct eth_device *edev)
 	SDMA_TASK_ENABLE(FEC_RECV_TASK_NO);
 
 	if (fec->xcv_type != SEVENWIRE) {
-		return phy_device_connect(edev, &fec->miibus, CONFIG_PHY_ADDR,
+		int ret;
+
+		ret = phy_device_connect(edev, &fec->miibus, CONFIG_PHY_ADDR,
 				 NULL, fec->phy_flags, fec->interface);
+		if (ret)
+			return ret;
+
+		return phy_start(edev->phydev);
 	}
 
 	return 0;
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index 55675ba..eed8569 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -192,6 +192,10 @@ static int gfar_open(struct eth_device *edev)
 	if (ret)
 		return ret;
 
+	ret = phy_start(edev->phydev);
+	if (ret)
+		return ret;
+
 	/* Point to the buffer descriptors */
 	out_be32(regs + GFAR_TBASE0_OFFSET, (unsigned int)priv->txbd);
 	out_be32(regs + GFAR_RBASE0_OFFSET, (unsigned int)priv->rxbd);
diff --git a/drivers/net/ks8851_mll.c b/drivers/net/ks8851_mll.c
index 79b88f2..52f6a6c 100644
--- a/drivers/net/ks8851_mll.c
+++ b/drivers/net/ks8851_mll.c
@@ -786,6 +786,10 @@ static int ks8851_eth_open(struct eth_device *edev)
 	if (ret)
 		return ret;
 
+	ret = phy_start(edev->phydev);
+	if (ret)
+		return ret;
+
 	dev_dbg(dev, "eth_open\n");
 
 	return 0;
diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index ce3ef66..d25fb79 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -233,14 +233,19 @@ static void macb_adjust_link(struct eth_device *edev)
 
 static int macb_open(struct eth_device *edev)
 {
+	int ret;
 	struct macb_device *macb = edev->priv;
 
 	debug("%s\n", __func__);
 
 	/* Obtain the PHY's address/id */
-	return phy_device_connect(edev, &macb->miibus, macb->phy_addr,
+	ret = phy_device_connect(edev, &macb->miibus, macb->phy_addr,
 			       macb_adjust_link, macb->phy_flags,
 			       macb->interface);
+	if (ret)
+		return ret;
+
+	return phy_start(edev->phydev);
 }
 
 static int macb_init(struct eth_device *edev)
diff --git a/drivers/net/netx_eth.c b/drivers/net/netx_eth.c
index e2b5591..d4deede 100644
--- a/drivers/net/netx_eth.c
+++ b/drivers/net/netx_eth.c
@@ -194,10 +194,15 @@ static int netx_eth_init_dev(struct eth_device *edev)
 
 static int netx_eth_open(struct eth_device *edev)
 {
+	int ret;
 	struct netx_eth_priv *priv = (struct netx_eth_priv *)edev->priv;
 
-	return phy_device_connect(edev, &priv->miibus, 0, NULL,
+	ret = phy_device_connect(edev, &priv->miibus, 0, NULL,
 				 0, PHY_INTERFACE_MODE_NA);
+	if (ret)
+		return ret;
+
+	return phy_start(edev->phydev);
 }
 
 static void netx_eth_halt (struct eth_device *edev)
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 5a4be54..adcbf6c 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -305,8 +305,6 @@ int phy_device_connect(struct eth_device *edev, struct mii_bus *bus, int addr,
 	dev = edev->phydev;
 	drv = to_phy_driver(dev->dev.driver);
 
-	drv->config_aneg(dev);
-
 	dev->adjust_link = adjust_link;
 
 	return 0;
@@ -318,6 +316,17 @@ fail:
 	return ret;
 }
 
+int phy_start(struct phy_device* dev)
+{
+	struct phy_driver *drv;
+	if (!dev)
+		return -ENODEV;
+
+	drv = to_phy_driver(dev->dev.driver);
+
+	return drv->config_aneg(dev);
+}
+
 /* Generic PHY support and helper functions */
 
 /**
diff --git a/drivers/net/smc91111.c b/drivers/net/smc91111.c
index ac978d9..2c87364 100644
--- a/drivers/net/smc91111.c
+++ b/drivers/net/smc91111.c
@@ -886,6 +886,7 @@ static void smc91c111_enable(struct eth_device *edev)
 static int smc91c111_eth_open(struct eth_device *edev)
 {
 	struct smc91c111_priv *priv = (struct smc91c111_priv *)edev->priv;
+	int ret;
 
 	/* Configure the Receive/Phy Control register */
 	SMC_SELECT_BANK(priv, 0);
@@ -893,8 +894,12 @@ static int smc91c111_eth_open(struct eth_device *edev)
 
 	smc91c111_enable(edev);
 
-	return phy_device_connect(edev, &priv->miibus, 0, NULL,
+	ret = phy_device_connect(edev, &priv->miibus, 0, NULL,
 				 0, PHY_INTERFACE_MODE_NA);
+	if (ret)
+		return ret;
+
+	return phy_start(edev->phydev);
 }
 
 static int smc91c111_eth_send(struct eth_device *edev, void *packet,
diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index 28c69ba..ea4a2dc 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -397,6 +397,10 @@ static int smc911x_eth_open(struct eth_device *edev)
 	if (ret)
 		return ret;
 
+	ret = phy_start(edev->phydev);
+	if (ret)
+		return ret;
+
 	/* Turn on Tx + Rx */
 	smc911x_enable(edev);
 	return 0;
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 80b4ae7..7c916dc 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -167,11 +167,16 @@ static int usbnet_init(struct eth_device *edev)
 static int usbnet_open(struct eth_device *edev)
 {
 	struct usbnet		*dev = (struct usbnet*)edev->priv;
+	int ret;
 
 	dev_dbg(&edev->dev, "%s\n",__func__);
 
-	return phy_device_connect(edev, &dev->miibus, dev->phy_addr, NULL,
+	ret = phy_device_connect(edev, &dev->miibus, dev->phy_addr, NULL,
 				0, PHY_INTERFACE_MODE_NA);
+	if (ret)
+		return ret;
+
+	return phy_start(edev->phydev);
 }
 
 static void usbnet_halt(struct eth_device *edev)
diff --git a/include/linux/phy.h b/include/linux/phy.h
index ce6f22c..3892bb3 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -238,6 +238,7 @@ int phy_driver_register(struct phy_driver *drv);
 int phy_drivers_register(struct phy_driver *new_driver, int n);
 struct phy_device *get_phy_device(struct mii_bus *bus, int addr);
 int phy_init(void);
+int phy_start(struct phy_device* dev);
 int phy_init_hw(struct phy_device *phydev);
 
 /**
-- 
1.7.10.4



From rpjday at crashcourse.ca  Thu Nov 15 09:36:37 2012
From: rpjday at crashcourse.ca (Robert P. J. Day)
Date: Thu, 15 Nov 2012 09:36:37 -0500 (EST)
Subject: how easy to add extra config for NAND-less beagle?
Message-ID: <alpine.DEB.2.02.1211150924030.1247@oneiric>


  returning to playing with barebox after lengthy hiatus and i asked
an equivalent question on the u-boot list, let's see if it's relevant
here.

  i did a regular configure and build for my beagle xM (rev C) which,
unlike the beagle classic, has no NAND flash:

$ make omap3530_beagle_xload_defconfig ; make
$ make omap3530_beagle_defconfig ; make

then copied MLO and barebox.bin to an appropriate card and, lo, it
booted nicely and i'm currently sitting in barebox:

  barebox at Texas Instrument's Beagle:/ version

  barebox 2012.10.0-00283-gd65d9df #2 Thu Nov 15 06:45:21 EST 2012

thing is, this build has a good deal of NAND-related functionality
that is of no use whatsoever on the current beagle xMs, so i'm
interested in how little work it would take to add an extra config
that would deselect everything related to NAND.  (obviously, having
that functionality there doesn't *hurt*, but i'm planning to use
barebox in my new embedded linux courses and it would be nice to be
able to build for an xM and have it *totally* correspond to the actual
hardware.)  it shouldn't be hard -- simply deselecting anything
related to NAND, MTD or JFFS2 should do the trick.

rday

p.s.  when i run "devinfo", i see a couple NAND-related entries:

devices:
... snip ...
`---- gpmc_nand0
... snip ...

drivers:
... snip ...
 gpmc_nand
... snip ...

  somewhat embarrassed to admit that i don't know what "gpmc_nand"
represents, but i'll google shortly.  however, no matter what it is,
would it be relevant on a board with no NAND flash?  thanks muchly for
any advice.




From s.hauer at pengutronix.de  Thu Nov 15 11:16:15 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu, 15 Nov 2012 17:16:15 +0100
Subject: how easy to add extra config for NAND-less beagle?
In-Reply-To: <alpine.DEB.2.02.1211150924030.1247@oneiric>
References: <alpine.DEB.2.02.1211150924030.1247@oneiric>
Message-ID: <20121115161615.GI10369@pengutronix.de>

Hi Robert,

On Thu, Nov 15, 2012 at 09:36:37AM -0500, Robert P. J. Day wrote:
> 
>   returning to playing with barebox after lengthy hiatus and i asked
> an equivalent question on the u-boot list, let's see if it's relevant
> here.
> 
>   i did a regular configure and build for my beagle xM (rev C) which,
> unlike the beagle classic, has no NAND flash:
> 
> $ make omap3530_beagle_xload_defconfig ; make
> $ make omap3530_beagle_defconfig ; make
> 
> then copied MLO and barebox.bin to an appropriate card and, lo, it
> booted nicely and i'm currently sitting in barebox:
> 
>   barebox at Texas Instrument's Beagle:/ version
> 
>   barebox 2012.10.0-00283-gd65d9df #2 Thu Nov 15 06:45:21 EST 2012
> 
> thing is, this build has a good deal of NAND-related functionality
> that is of no use whatsoever on the current beagle xMs, so i'm
> interested in how little work it would take to add an extra config
> that would deselect everything related to NAND.  (obviously, having
> that functionality there doesn't *hurt*, but i'm planning to use
> barebox in my new embedded linux courses and it would be nice to be
> able to build for an xM and have it *totally* correspond to the actual
> hardware.)  it shouldn't be hard -- simply deselecting anything
> related to NAND, MTD or JFFS2 should do the trick.

Disable MTD support and if you want also the protect/erase commands:

make menuconfig

Drivers                         --->
  [ ] Memory Technology Device (MTD) support  --->

commands                        --->
  flash                           --->
    [ ] protect/erase

Saves you around 35Kb of binary space

> 
> rday
> 
> p.s.  when i run "devinfo", i see a couple NAND-related entries:
> 
> devices:
> ... snip ...
> `---- gpmc_nand0

The nand device, probably present even when you disable nand support.
However, no driver will bind to it if you disable it.

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From plagnioj at jcrosoft.com  Thu Nov 15 11:21:16 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu, 15 Nov 2012 17:21:16 +0100
Subject: [PATCH 1/1] at91rm9200ek: add spi support
Message-ID: <1352996476-16071-1-git-send-email-plagnioj@jcrosoft.com>

as the support atmel mci drivers does not work on rm9200 and we have the
possibility to use it as spi use it

Originally on rm9200 when the interface mci is in SPI mode we use a DataFlash Card
so allow it but if no dataflash card option is enable use as mmc spi.

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/boards/at91rm9200ek/init.c     |   49 +++++++++++++++++++++++++++++++
 arch/arm/configs/at91rm9200ek_defconfig |   10 ++++++-
 arch/arm/mach-at91/Kconfig              |   10 +++++++
 3 files changed, 68 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boards/at91rm9200ek/init.c b/arch/arm/boards/at91rm9200ek/init.c
index 20e9ad1..439ee9e 100644
--- a/arch/arm/boards/at91rm9200ek/init.c
+++ b/arch/arm/boards/at91rm9200ek/init.c
@@ -30,6 +30,7 @@
 #include <mach/board.h>
 #include <mach/gpio.h>
 #include <mach/io.h>
+#include <spi/spi.h>
 
 static struct at91_ether_platform_data ether_pdata = {
 	.flags = AT91SAM_ETHER_RMII,
@@ -103,6 +104,53 @@ static void ek_add_device_udc(void)
 static void ek_add_device_udc(void) {}
 #endif
 
+static struct spi_board_info ek_dataflash_spi_devices[] = {
+	{	/* DataFlash chip */
+		.name		= "mtd_dataflash",
+		.chip_select	= 0,
+		.max_speed_hz	= 15 * 1000 * 1000,
+	},
+#ifdef CONFIG_MTD_AT91_DATAFLASH_CARD
+	{	/* DataFlash card */
+		.name		= "mtd_dataflash",
+		.chip_select	= 1,
+		.max_speed_hz	= 15 * 1000 * 1000,
+	},
+#endif
+};
+
+static struct spi_board_info ek_mmc_spi_devices[] = {
+#if !defined(CONFIG_MTD_DATAFLASH)
+	{
+		.name		= "spi_mci",
+		.chip_select	= 0,
+		.max_speed_hz	= 20 * 1000 * 1000,
+	},
+#endif
+#if !defined(CONFIG_MTD_AT91_DATAFLASH_CARD)
+	{
+		.name		= "spi_mci",
+		.chip_select	= 1,
+		.max_speed_hz	= 20 * 1000 * 1000,
+	},
+#endif
+};
+
+static unsigned spi0_standard_cs[] = { AT91_PIN_PA3, AT91_PIN_PA6 };
+static struct at91_spi_platform_data spi_pdata = {
+	.chipselect = spi0_standard_cs,
+	.num_chipselect = ARRAY_SIZE(spi0_standard_cs),
+};
+
+static void ek_add_device_spi(void)
+{
+	/* select mci0 as spi */
+	at91_set_gpio_output(AT91_PIN_PB22, 0);
+	spi_register_board_info(ek_dataflash_spi_devices, ARRAY_SIZE(ek_dataflash_spi_devices));
+	spi_register_board_info(ek_mmc_spi_devices, ARRAY_SIZE(ek_mmc_spi_devices));
+	at91_add_device_spi(0, &spi_pdata);
+}
+
 static int at91rm9200ek_devices_init(void)
 {
 	/*
@@ -118,6 +166,7 @@ static int at91rm9200ek_devices_init(void)
 	at91_add_device_usbh_ohci(&ek_usbh_data);
 	ek_device_add_leds();
 	ek_add_device_udc();
+	ek_add_device_spi();
 
 #if defined(CONFIG_DRIVER_CFI) || defined(CONFIG_DRIVER_CFI_OLD)
 	devfs_add_partition("nor0", 0x00000, 0x40000, DEVFS_PARTITION_FIXED, "self");
diff --git a/arch/arm/configs/at91rm9200ek_defconfig b/arch/arm/configs/at91rm9200ek_defconfig
index 2bcade9..cc63445 100644
--- a/arch/arm/configs/at91rm9200ek_defconfig
+++ b/arch/arm/configs/at91rm9200ek_defconfig
@@ -44,6 +44,7 @@ CONFIG_CMD_TIMEOUT=y
 CONFIG_CMD_PARTITION=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_UNCOMPRESS=y
+CONFIG_CMD_SPI=y
 CONFIG_CMD_LED=y
 CONFIG_CMD_LED_TRIGGER=y
 CONFIG_NET=y
@@ -55,14 +56,21 @@ CONFIG_FS_TFTP=y
 CONFIG_NET_NETCONSOLE=y
 CONFIG_NET_RESOLV=y
 CONFIG_DRIVER_NET_AT91_ETHER=y
-# CONFIG_SPI is not set
+CONFIG_DRIVER_SPI_ATMEL=y
 CONFIG_DRIVER_CFI=y
 # CONFIG_DRIVER_CFI_INTEL is not set
 # CONFIG_DRIVER_CFI_BANK_WIDTH_1 is not set
 # CONFIG_DRIVER_CFI_BANK_WIDTH_4 is not set
 CONFIG_CFI_BUFFER_WRITE=y
+CONFIG_MTD=y
+# CONFIG_MTD_OOB_DEVICE is not set
+CONFIG_MTD_DATAFLASH=y
 CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_SERIAL=y
+CONFIG_MCI=y
+CONFIG_MCI_STARTUP=y
+CONFIG_MCI_SPI=y
+CONFIG_MMC_SPI_CRC_ON=y
 CONFIG_LED=y
 CONFIG_LED_GPIO=y
 CONFIG_LED_TRIGGERS=y
diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index b3f1885..3a985f7 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -31,6 +31,9 @@ config BOARDINFO
 config HAVE_NAND_ATMEL_BUSWIDTH_16
 	bool
 
+config HAVE_AT91_DATAFLASH_CARD
+	bool
+
 config AT91SAM9_RESET
 	bool
 
@@ -119,6 +122,7 @@ choice
 config MACH_AT91RM9200EK
 	bool "Atmel AT91RM9200-EK Evaluation Kit"
 	help
+	select HAVE_AT91_DATAFLASH_CARD
 	  Select this if you are using Atmel's AT91RM9200-EK Evaluation Kit.
 	  <http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3507>
 
@@ -334,6 +338,12 @@ endif
 
 comment "AT91 Board Options"
 
+config MTD_AT91_DATAFLASH_CARD
+	bool "Enable DataFlash Card support"
+	depends on HAVE_AT91_DATAFLASH_CARD
+	help
+	  Enable support for the DataFlash card.
+
 config MTD_NAND_ATMEL_BUSWIDTH_16
 	bool "Enable 16-bit data bus interface to NAND flash"
 	depends on HAVE_NAND_ATMEL_BUSWIDTH_16
-- 
1.7.10.4



From rpjday at crashcourse.ca  Thu Nov 15 11:39:58 2012
From: rpjday at crashcourse.ca (Robert P. J. Day)
Date: Thu, 15 Nov 2012 11:39:58 -0500 (EST)
Subject: how easy to add extra config for NAND-less beagle?
In-Reply-To: <20121115161615.GI10369@pengutronix.de>
References: <alpine.DEB.2.02.1211150924030.1247@oneiric>
 <20121115161615.GI10369@pengutronix.de>
Message-ID: <alpine.DEB.2.02.1211151128470.5359@oneiric>

On Thu, 15 Nov 2012, Sascha Hauer wrote:

> Hi Robert,
>
> On Thu, Nov 15, 2012 at 09:36:37AM -0500, Robert P. J. Day wrote:
> >
> >   returning to playing with barebox after lengthy hiatus and i asked
> > an equivalent question on the u-boot list, let's see if it's relevant
> > here.
> >
> >   i did a regular configure and build for my beagle xM (rev C) which,
> > unlike the beagle classic, has no NAND flash:
> >
> > $ make omap3530_beagle_xload_defconfig ; make
> > $ make omap3530_beagle_defconfig ; make
> >
> > then copied MLO and barebox.bin to an appropriate card and, lo, it
> > booted nicely and i'm currently sitting in barebox:
> >
> >   barebox at Texas Instrument's Beagle:/ version
> >
> >   barebox 2012.10.0-00283-gd65d9df #2 Thu Nov 15 06:45:21 EST 2012
> >
> > thing is, this build has a good deal of NAND-related functionality
> > that is of no use whatsoever on the current beagle xMs, so i'm
> > interested in how little work it would take to add an extra config
> > that would deselect everything related to NAND.  (obviously, having
> > that functionality there doesn't *hurt*, but i'm planning to use
> > barebox in my new embedded linux courses and it would be nice to be
> > able to build for an xM and have it *totally* correspond to the actual
> > hardware.)  it shouldn't be hard -- simply deselecting anything
> > related to NAND, MTD or JFFS2 should do the trick.
>
> Disable MTD support and if you want also the protect/erase commands:
>
> make menuconfig
>
> Drivers                         --->
>   [ ] Memory Technology Device (MTD) support  --->
>
> commands                        --->
>   flash                           --->
>     [ ] protect/erase
>
> Saves you around 35Kb of binary space

  yup, i'm testing that shortly, but my question was more along the
lines of, rather than having to disable all NAND-related
functionality *manually*, how easy/worthwhile would it be to create an
additional make target that reflects a beagle *without* NAND flash?

  one significant difference between a classic beagle and a current xM
is the total lack of NAND flash, and that's not a minor difference.
it means you can remove all barebox functionality related to that --
NAND routines and support, MTD stuff, JFFS2(?) support, and so on.
this could be automated by creating a couple new configs, say:

  make dm3730_beaglexm_xload_defconfig
  make dm3730_beaglexm_defconfig

so that the result really matches the underlying board.

  is this worth doing?  it would seem to be fairly easy, i can whip
something up and test it.

rday

p.s.  there are other significant differences as well -- onboard
ethernet, 4-port USB hub.  it seems to me that there is enough of a
difference to warrant a separate configuration.  thoughts?

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================



From m.olbrich at pengutronix.de  Thu Nov 15 12:28:06 2012
From: m.olbrich at pengutronix.de (Michael Olbrich)
Date: Thu, 15 Nov 2012 18:28:06 +0100
Subject: [PATCH] replace barebox* in .gitignore with individual files
In-Reply-To: <1352881301-9744-1-git-send-email-s.hauer@pengutronix.de>
References: <1352881301-9744-1-git-send-email-s.hauer@pengutronix.de>
Message-ID: <20121115172806.GD8330@pengutronix.de>

On Wed, Nov 14, 2012 at 09:21:41AM +0100, Sascha Hauer wrote:
> This effectively reverts:
> 
> | commit f9df22b002af99532b66360e08128ea3e7e82a97
> | Author: Alexander Shiyan <shc_work at mail.ru>
> | Date:   Mon Oct 8 10:35:04 2012 +0400
> |
> |    Add more generated files to .gitignore
> 
> barebox* is not limited to the toplevel directory, so this ignores
> all files starting with 'barebox' from which we have several we do
> not wish to ignore. Add barebox-flash-image to the ignore list which
> seemed to be the motivation for the original patch.

You could use:

/barebox*

This will not match any files in sub-directories.

Michael


> Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
> Cc: Alexander Shiyan <shc_work at mail.ru>
> ---
>  .gitignore |   13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/.gitignore b/.gitignore
> index 81e74a0..064753d 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -26,11 +26,22 @@
>  #
>  tags
>  TAGS
> -barebox*
>  cross_arch
>  cross_compile
> +barebox
> +barebox.S
> +barebox.bin
> +barebox.srec
> +barebox.netx
> +barebox.s5p
> +barebox.spi
> +barebox.ubl
> +barebox.uimage
> +barebox.map
> +barebox-flash-image
>  System.map
>  Module.symvers
> +barebox_default_env*
>  
>  #
>  # Generated include files
> -- 
> 1.7.10.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From plagnioj at jcrosoft.com  Thu Nov 15 14:22:29 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu, 15 Nov 2012 20:22:29 +0100
Subject: how easy to add extra config for NAND-less beagle?
In-Reply-To: <alpine.DEB.2.02.1211151128470.5359@oneiric>
References: <alpine.DEB.2.02.1211150924030.1247@oneiric>
 <20121115161615.GI10369@pengutronix.de>
 <alpine.DEB.2.02.1211151128470.5359@oneiric>
Message-ID: <20121115192229.GI31820@game.jcrosoft.org>

On 11:39 Thu 15 Nov     , Robert P. J. Day wrote:
> On Thu, 15 Nov 2012, Sascha Hauer wrote:
> 
> > Hi Robert,
> >
> > On Thu, Nov 15, 2012 at 09:36:37AM -0500, Robert P. J. Day wrote:
> > >
> > >   returning to playing with barebox after lengthy hiatus and i asked
> > > an equivalent question on the u-boot list, let's see if it's relevant
> > > here.
> > >
> > >   i did a regular configure and build for my beagle xM (rev C) which,
> > > unlike the beagle classic, has no NAND flash:
> > >
> > > $ make omap3530_beagle_xload_defconfig ; make
> > > $ make omap3530_beagle_defconfig ; make
> > >
> > > then copied MLO and barebox.bin to an appropriate card and, lo, it
> > > booted nicely and i'm currently sitting in barebox:
> > >
> > >   barebox at Texas Instrument's Beagle:/ version
> > >
> > >   barebox 2012.10.0-00283-gd65d9df #2 Thu Nov 15 06:45:21 EST 2012
> > >
> > > thing is, this build has a good deal of NAND-related functionality
> > > that is of no use whatsoever on the current beagle xMs, so i'm
> > > interested in how little work it would take to add an extra config
> > > that would deselect everything related to NAND.  (obviously, having
> > > that functionality there doesn't *hurt*, but i'm planning to use
> > > barebox in my new embedded linux courses and it would be nice to be
> > > able to build for an xM and have it *totally* correspond to the actual
> > > hardware.)  it shouldn't be hard -- simply deselecting anything
> > > related to NAND, MTD or JFFS2 should do the trick.
> >
> > Disable MTD support and if you want also the protect/erase commands:
> >
> > make menuconfig
> >
> > Drivers                         --->
> >   [ ] Memory Technology Device (MTD) support  --->
> >
> > commands                        --->
> >   flash                           --->
> >     [ ] protect/erase
> >
> > Saves you around 35Kb of binary space
> 
>   yup, i'm testing that shortly, but my question was more along the
> lines of, rather than having to disable all NAND-related
> functionality *manually*, how easy/worthwhile would it be to create an
> additional make target that reflects a beagle *without* NAND flash?
> 
>   one significant difference between a classic beagle and a current xM
> is the total lack of NAND flash, and that's not a minor difference.
> it means you can remove all barebox functionality related to that --
> NAND routines and support, MTD stuff, JFFS2(?) support, and so on.
> this could be automated by creating a couple new configs, say:
> 
>   make dm3730_beaglexm_xload_defconfig
>   make dm3730_beaglexm_defconfig
> 
> so that the result really matches the underlying board.
> 
>   is this worth doing?  it would seem to be fairly easy, i can whip
> something up and test it.
> 
> rday
> 
> p.s.  there are other significant differences as well -- onboard
> ethernet, 4-port USB hub.  it seems to me that there is enough of a
> difference to warrant a separate configuration.  thoughts?
no can you detect it?

on at91 we have teh 9x5ek which can a 5 different soc with different daughter

which we detetct

Best Regards,
J.
> 
> -- 
> 
> ========================================================================
> Robert P. J. Day                                 Ottawa, Ontario, CANADA
>                         http://crashcourse.ca
> 
> Twitter:                                       http://twitter.com/rpjday
> LinkedIn:                               http://ca.linkedin.com/in/rpjday
> ========================================================================
> 
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox


From s.hauer at pengutronix.de  Thu Nov 15 14:26:30 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu, 15 Nov 2012 20:26:30 +0100
Subject: how easy to add extra config for NAND-less beagle?
In-Reply-To: <alpine.DEB.2.02.1211151128470.5359@oneiric>
References: <alpine.DEB.2.02.1211150924030.1247@oneiric>
 <20121115161615.GI10369@pengutronix.de>
 <alpine.DEB.2.02.1211151128470.5359@oneiric>
Message-ID: <20121115192630.GJ10369@pengutronix.de>

On Thu, Nov 15, 2012 at 11:39:58AM -0500, Robert P. J. Day wrote:
> 
>   yup, i'm testing that shortly, but my question was more along the
> lines of, rather than having to disable all NAND-related
> functionality *manually*, how easy/worthwhile would it be to create an
> additional make target that reflects a beagle *without* NAND flash?
> 
>   one significant difference between a classic beagle and a current xM
> is the total lack of NAND flash, and that's not a minor difference.
> it means you can remove all barebox functionality related to that --
> NAND routines and support, MTD stuff, JFFS2(?) support, and so on.
> this could be automated by creating a couple new configs, say:
> 
>   make dm3730_beaglexm_xload_defconfig
>   make dm3730_beaglexm_defconfig
> 
> so that the result really matches the underlying board.
> 
>   is this worth doing?  it would seem to be fairly easy, i can whip
> something up and test it.

I don't think this is worth it. We should rather keep the number of
defconfigs low. Splitting them means we have to maintain them and
keep them in sync. Also it means to increase the time needed to compile
all defconfigs (which I do routinely, currently on every commit).

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From q24688 at gmail.com  Fri Nov 16 02:01:55 2012
From: q24688 at gmail.com (Kevin Huanpeng Du)
Date: Fri, 16 Nov 2012 15:01:55 +0800
Subject: common.h dependence leak
Message-ID: <CAG9dEfJuCxdatiXCK-iWK=hOFEPJ8rjwB_SfC0uOBH5WT_tyzQ@mail.gmail.com>

Hi, all:
I am study barebox, I want to remove all files not used, so I write this script.
here is a part of removing header (.h) files.
firstly, I didnot add LINE22 for speed.
but it not works for common.h.
I guess the file 'include/common.h' is leak of dependence in Makefiles.
Is anyone can check.

 1
  2 git checkout -f
  3 git clean -dfx
  4
  5
  6 hh=`find -name "*.h"`
  7
  8
  9 echo "CLEAN"
 10 make distclean  2>/dev/null 1>/dev/null
 11 wait
 12 echo "CONFIG"
 13 make -s omap3530_beagle_xload_defconfig  2>/dev/null 1>/dev/null
 14 wait
 15
 16 echo "START"
 17 for f in $hh
 18 do
 19
 20   rm $f
 21   echo -n -e "        $f\r"
 22   make clean 2>/dev/null 1>/dev/null   # LINE 22
 23   wait
 24   make -s -j24 2>/dev/null 1>/dev/null
 25   r=$?
 26   wait
 27
 28   if [ $r != 0 ]
 29   then
 30     echo "[KEEP]"
 31     git checkout $f
 32   else
 33     echo "[DEL]"
 34   fi
 35
 36
 37 done
 38


From rpjday at crashcourse.ca  Fri Nov 16 06:01:10 2012
From: rpjday at crashcourse.ca (Robert P. J. Day)
Date: Fri, 16 Nov 2012 06:01:10 -0500 (EST)
Subject: pedantry alert -- what is the proper spelling of "barebox"?
Message-ID: <alpine.DEB.2.02.1211160557150.3959@oneiric>


  sascha already knows that i'm going to be poking around the wiki
documentation and doing some editing, so what is the proper spelling
of barebox, particularly in the middle of a sentence? i'm asking this
publicly so that others can see the answer in case they were going to
do any writing, for the sake of consistency.

  for example, in the very first section of the wiki, it's spelled
both as "barebox" and "Barebox".  it really should be consistent.

rday

p.s.  just to be annoying, from a technical writing point of view, if
the proper name is "barebox", then it should be rendered that way,
even if it's the first word in a sentence, which will look weird but
them's the rules. :-)

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================


From rpjday at crashcourse.ca  Fri Nov 16 06:16:03 2012
From: rpjday at crashcourse.ca (Robert P. J. Day)
Date: Fri, 16 Nov 2012 06:16:03 -0500 (EST)
Subject: how easy to add extra config for NAND-less beagle?
In-Reply-To: <20121115192630.GJ10369@pengutronix.de>
References: <alpine.DEB.2.02.1211150924030.1247@oneiric>
 <20121115161615.GI10369@pengutronix.de>
 <alpine.DEB.2.02.1211151128470.5359@oneiric>
 <20121115192630.GJ10369@pengutronix.de>
Message-ID: <alpine.DEB.2.02.1211160614560.4073@oneiric>

On Thu, 15 Nov 2012, Sascha Hauer wrote:

> On Thu, Nov 15, 2012 at 11:39:58AM -0500, Robert P. J. Day wrote:
> >
> >   yup, i'm testing that shortly, but my question was more along the
> > lines of, rather than having to disable all NAND-related
> > functionality *manually*, how easy/worthwhile would it be to create an
> > additional make target that reflects a beagle *without* NAND flash?
> >
> >   one significant difference between a classic beagle and a current xM
> > is the total lack of NAND flash, and that's not a minor difference.
> > it means you can remove all barebox functionality related to that --
> > NAND routines and support, MTD stuff, JFFS2(?) support, and so on.
> > this could be automated by creating a couple new configs, say:
> >
> >   make dm3730_beaglexm_xload_defconfig
> >   make dm3730_beaglexm_defconfig
> >
> > so that the result really matches the underlying board.
> >
> >   is this worth doing?  it would seem to be fairly easy, i can whip
> > something up and test it.
>
> I don't think this is worth it. We should rather keep the number of
> defconfigs low. Splitting them means we have to maintain them and
> keep them in sync. Also it means to increase the time needed to
> compile all defconfigs (which I do routinely, currently on every
> commit).

  ok, that makes sense.  i'll still have a couple questions later on
the proper configuration of barebox for flash-less systems like the
xM.  thanks.

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================


From s.hauer at pengutronix.de  Fri Nov 16 06:18:02 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Fri, 16 Nov 2012 12:18:02 +0100
Subject: pedantry alert -- what is the proper spelling of "barebox"?
In-Reply-To: <alpine.DEB.2.02.1211160557150.3959@oneiric>
References: <alpine.DEB.2.02.1211160557150.3959@oneiric>
Message-ID: <20121116111802.GN10369@pengutronix.de>

On Fri, Nov 16, 2012 at 06:01:10AM -0500, Robert P. J. Day wrote:
> 
>   sascha already knows that i'm going to be poking around the wiki
> documentation and doing some editing, so what is the proper spelling
> of barebox, particularly in the middle of a sentence? i'm asking this
> publicly so that others can see the answer in case they were going to
> do any writing, for the sake of consistency.
> 
>   for example, in the very first section of the wiki, it's spelled
> both as "barebox" and "Barebox".  it really should be consistent.

It's 'barebox'. barebox even has a small letter when at the beginning of
a sentence. I'm normally after this, but espially office programs are
sometimes hard to convince that this is correct.

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From rpjday at crashcourse.ca  Fri Nov 16 06:33:05 2012
From: rpjday at crashcourse.ca (Robert P. J. Day)
Date: Fri, 16 Nov 2012 06:33:05 -0500 (EST)
Subject: pedantry alert -- what is the proper spelling of "barebox"?
In-Reply-To: <20121116111802.GN10369@pengutronix.de>
References: <alpine.DEB.2.02.1211160557150.3959@oneiric>
 <20121116111802.GN10369@pengutronix.de>
Message-ID: <alpine.DEB.2.02.1211160632050.4136@oneiric>

On Fri, 16 Nov 2012, Sascha Hauer wrote:

> On Fri, Nov 16, 2012 at 06:01:10AM -0500, Robert P. J. Day wrote:
> >
> >   sascha already knows that i'm going to be poking around the wiki
> > documentation and doing some editing, so what is the proper spelling
> > of barebox, particularly in the middle of a sentence? i'm asking this
> > publicly so that others can see the answer in case they were going to
> > do any writing, for the sake of consistency.
> >
> >   for example, in the very first section of the wiki, it's spelled
> > both as "barebox" and "Barebox".  it really should be consistent.
>
> It's 'barebox'. barebox even has a small letter when at the
> beginning of a sentence. I'm normally after this, but espially
> office programs are sometimes hard to convince that this is correct.

  ok, thanks for the clarification, i'll even add that note to the
wiki early on.

rday


-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================


From s.hauer at pengutronix.de  Fri Nov 16 08:00:04 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Fri, 16 Nov 2012 14:00:04 +0100
Subject: v2012.11.0 - The late one
Message-ID: <20121116130004.GS10369@pengutronix.de>

Finally released. With the latest phy related fixes this hopefully is
ready for release.

Have fun,
 Sascha

----------------------------------------------------------------
Alexander Aring (12):
      libbb: remove vi tabwidth setting
      commands: add testing menu
      commands: move nandtest to testing
      commands: move memtest to testing
      sandbox-unaligned: better usement of ifdef
      sandbox: fix posix_types
      sandbox: add missed case statement
      sandbox: move add_image for env in second getopt
      sandbox: fix malloc argument string
      documentation: add sandbox malloc argument
      mtd-core: add writesize in MEMGETINFO ioctl
      devfs-core: add writesize in mtd partition ioctl

Alexander Shiyan (2):
      ARM: Fix Kconfig link for Cirrus Logic EP9312 CPU.
      Add more generated files to .gitignore

Antony Pavlov (1):
      davinci_emac: fix comment for the _send function

Carlo Caione (1):
      cosmetic: extra new line in automount usage command

Eric B?nard (1):
      miidev: fix 1G wrong detection

Fabio Porcedda (1):
      ARM pbl: add generated file zbarebox.map to .gitignore

Fadil Berisha (1):
      boards: Add support for imx233-olinuxino board

Franck Jullien (6):
      Add __ashrdi3 and remove link to libgcc
      Add OpenRISC Image type
      Fix endianness error on be target
      filetype: Improve FAT detection
      fs/fat: Handle MBR on the first sector
      common/paritions.c: force little endian reads

Jan Luebbe (24):
      drivers/nor/m25p80: add JEDEC ID for Micron/Numonyx SPI NOR flash
      common: split out meminfo output and make it optional
      omap3: remove unused coded for clock configuration
      kbuild: keep the barebox binary accessible
      ARM Makefile: switch to kbuild command definition for mkublheader
      drivers/spi: add driver for the Multichannel SPI controller found in TI SoCs
      xload: make internal functions static
      xload: add SPI as a boot mode
      drivers/net/ksz8864rmn: add driver for Micrel KSZ8864RMN Ethernet Switch
      drivers/nor/m25p80: add MTD support
      drivers/nor/cfi_flash: use IS_ENABLED instead of an ifdef
      drivers/net: add driver for the EMAC device found in some TI SoCs
      spi: switch from printf back to debug
      ARM: give boards control of the reset entry point
      gpio: reduce verbosity while probing
      gpio: reduce verbosity while probing
      davinci_emac: return 0 on successful transmit
      davinci_emac: adjust to new phylib framework
      davinci_emac: get rid of mdio wrapper functions
      Makefile: add target to produce a SPL compatible uImage
      scripts: add tool to create image for SPI boot on AM35xx
      commands/mount: fix typo and wording in help message
      parameter: fix memory leak
      defaultenv-2: boot: add missing space in error message

Jan Weitzel (2):
      xload: get barebox size from barebox_arm_head
      pcm049 phycard l + xl2: update partion sizes

Jean-Christophe PLAGNIOL-VILLARD (60):
      Introduce ARM AMBA bus
      amba-pl011: switch to amba bus
      amba-pl011: add st specific init
      genenv: Allow to also specify files for the environment instead of only directories
      bmp: rename it to splash
      bmp: Move bmp rendering to lib/bmp.c
      Introduce graphic utils
      introduce image_renderer framework
      filetype: add BMP support
      splash/bmp: switch to image_renderer
      splash: add support to set a background color
      graphic_utils: add rgba support
      filetype: add PNG support
      add PNG support
      png: add picoPNG lib support
      globalvar: add inline when not enabled
      echo: always allow to pass -e option
      defaultenv-2/ansi-colors: export color only if enable
      globalvar: add support to set a value to of all globalvars beginning with 'match'
      defaultenv-2: boot use global.linux.bootargs.dyn for dynamic globalvar
      defaultenv-2: boot reset linux.bootargs.dyn. and bootm. globalvar
      net: catch error on eth_send
      add barebox logo
      driver: register bus
      driver: search device and driver based on the bus instead of all
      fb: add it's own bus for fb devices
      net: introduce phylib
      sandbox: add sdl video support
      defaultenv: enable glovalvar support
      defaultenv: switch hostname to global.hostname
      dhcp: switch to global var support
      dhcp: add copy_only_if_valid support
      dhcp: add retries limit support
      defaultenv-2: eth0 add default global.dhcp.vendor_id
      fb: move add param to bus probe
      switch all platform_bus device/driver registering to platform_driver/device_register
      devinfo: display device bus name
      amba/bus: add missing bus_register
      net/designware: update version display to print user ID and Synosys ID
      net/designware: fix phy_addr type to int
      net/designware: fix phylib support
      image_renderer: fix size type
      gui: move gui file to include/gui and lib/gui
      graphic_utils: pass image so we can draw only the visible part of the image
      gui: introduce screen and surface to factorize and simplify code
      graphic_utils: introduce common fb_open/close
      gui: blit the surface on demand
      calao: at91 qil/tny/usb auto detect the phy addr
      designware: fix 100mps phy support
      at91sam9x5: udpate default ARCH_TEXT to 0x26f00000
      sam9x5ek: drop uart2 as it's not always present
      at91sam9x5ek: fix bootstrap size to 256KiB
      pm9g45: fix nand partition in c code
      pm9g45: fix config and defconfig
      at91sam9xek: fix mtd partition
      mx53-loco: fix phy reset
      phy: add phy_drivers_register
      phy: add smsc phy driver support
      mx53 loco: enable smsc phy driver
      mci-core: fix debug Capacity cast

Marcus Folkesson (1):
      mtd: nand: extend NAND flash detection to new MLC chips

Maxime Ripard (1):
      arm: cfa10036: Add the OCOTP device

Sascha Hauer (166):
      ARM lowlevel: Update function documentation
      ARM: Add assembler function to get runtime offset
      ARM lowlevel: Use get_runtime_offset
      mfd mc13xxx: Separate I2C and SPI probe
      Merge tag 'amba_bus' of git://git.jcrosoft.org/barebox into for-next/amba
      mfd mc34708: Separate I2C and SPI probe
      SPI: Put SPI devices on their own bus
      I2C: Put I2C devices on their own bus
      driver: rewrite dev_printf as a function
      driver: Add platform_device_id mechanism
      driver: add dev_get_drvdata function
      of: add devicetree probing support
      oftree command: Add devicetree probe support
      of: Add devicetree partition parsing
      spi: add oftree support
      ARM i.MX: Use platform_device_id for gpio driver
      ARM i.MX: Add Ka-Ro TX53 board support
      ARM i.MX TX53: Add defconfig
      ARM mxs: Clear USB boot mode during startup
      Merge tag 'logo' of git://git.jcrosoft.org/barebox into for-next/logo
      Treewide: remove address of the Free Software Foundation
      ARM i.MX: implement clocksource as driver
      serial i.MX: oftree support
      net fec_mpc5200: Use same platform_data as i.MX fec driver
      spi imx: dt support
      mfd mc13xxx: Add devicetree support
      cfi-flash: Add devicetree probe support
      mci i.MX esdhc: Add oftree support
      ARM i.MX: add devicetree support for gpio driver
      ARM i.MX: Add devicetree support for clocksource driver
      ARM OMAP: remove SRAM stack
      ARM OMAP3: rename arch_init_lowlevel to board_init_lowlevel
      ARM: remove ARCH_HAS_LOWLEVEL_INIT
      ARM OMAP: remove SRAM stack
      ARM OMAP3: rename arch_init_lowlevel to board_init_lowlevel
      ARM: remove ARCH_HAS_LOWLEVEL_INIT
      net/eth: fix link handling
      net: remove unused prototypes for eth_[open|halt]
      ARM i.MX: add debug for iomux-v3
      scripts/bareboxenv: Only print information if -v is given
      environment generation: remove unused CLEAN_FILES
      environment generation: Fix dependencies
      net: Add tftp command which uses the new tftp code
      defconfig: Switch all defconfig to new tftp command
      net: remove old tftp support
      net: remove unused miidev.h
      Merge branch 'for-next/driver'
      Merge branch 'for-next/net'
      Merge branch 'for-next/amba'
      Merge branch 'for-next/arm'
      Merge branch 'for-next/boot-sequence-dhcp'
      Merge branch 'for-next/fat-detection'
      Merge branch 'for-next/karo-tx53'
      Merge branch 'for-next/logo'
      Merge branch 'for-next/make'
      Merge branch 'for-next/misc'
      Merge branch 'for-next/mmc'
      Merge branch 'for-next/mtd'
      Merge branch 'for-next/mxs'
      Merge branch 'for-next/omap'
      Merge branch 'for-next/openrisc'
      Merge branch 'for-next/png'
      Merge branch 'for-next/remove-fsf-address'
      Merge branch 'for-next/sandbox'
      Merge branch 'for-next/spi'
      Merge branch 'for-next/testing-menu'
      Merge branch 'for-next/arm-remove-arch-init-ll'
      Merge branch 'for-next/tftp'
      Merge branch 'for-next/defaultenv-deps'
      Merge branch 'for-next/arm-board-reset'
      driver: move dev_get_drvdata out of CONFIG_CMD_DEVINFO
      provide static inline function for export
      ARM i.MX31: give register base addresses a proper MX31_ prefix
      ARM i.MX35: give register base addresses a proper MX35_ prefix
      ARM i.MX21: give register base addresses a proper MX21_ prefix
      ARM i.MX1: give register base addresses a proper MX1_ prefix
      ARM i.MX27: give register base addresses a proper MX27_ prefix
      ARM i.MX25: give register base addresses a proper MX25_ prefix
      ARM i.MX/MXS: Allow to include imx*-regs.h directly
      ARM i.MX51: Use defines rather than hardcoded addresses
      ARM i.MX: Add header file for WEIM cs setup
      ARM i.MX1: Add function to setup chipselect
      ARM i.MX21: Add function to setup chipselect
      ARM i.MX31: Add function to setup chipselect
      ARM i.MX35: Add function to setup chipselect
      ARM i.MX25: Add function to setup chipselect
      err.h: introduce IS_ERR_OR_NULL
      clk clkdev: Add clkdev matching based on physbase
      clk: initial common clk support
      commands: Add clk commands
      ARM i.MX: initial clk support
      ARM i.MX27: implement clk support
      ARM i.MX25: Switch to common clk support
      ARM i.MX5: Switch to common clk support
      ARM i.MX1: Switch to common clk support
      ARM i.MX31: Switch to common clk
      ARM i.MX6: Switch to common clk
      ARM i.MX21: Switch to common clk
      ARM i.MX35: Switch to common clk
      net fec: Switch to clk support
      serial i.MX: Switch to clk support
      spi i.MX: Switch to clk support
      ARM i.MX: Switch clocksource to clk_get
      mci i.MX ESDHC: Switch to clock support
      mci i.MX: Switch to clock support
      i2c i.MX: Switch to clock support
      video i.MX: Switch to clock support
      video i.MX IPU: Switch to clock support
      ARM i.MX: Remove old clock support
      ARM i.MX clocksource: fix timer source selection
      ARM i.MX51 babbage: Add delay after phy reset
      Merge branch 'for-next/imx-clk'
      Merge branch 'for-next/fixes'
      nios2: Fix stray comment start in longlong.h
      driver: make get_bus_by_name static
      net mdio_bus: Add missing bus_register
      i2c i.MX: fixup clock support for powerpc
      ARM pbl: Provide a dummy error function for the decompressor
      ARM pbl: actually create cached mappings in the decompressor
      Merge branch 'pu/misc-fixes'
      ARM i.MX gpio: fix of gpio base
      ARM i.MX25: Enable all needed clocks during startup
      Makefile: Add missing force for barebox-flash-image
      defaultenv: dependencies fixes
      platform driver: Drop check for resource conflicts
      ARM a9m2440: Fix lowlevel init
      ARM samsung S5P: Enable board support
      mips: remove unused variable
      sandbox: only test for sdl libs when sdl is enabled
      net gianfar: remove unused variable
      Merge branch 'pu/compiler-warnings'
      fs tftp: Only request a block once
      fs tftp: Fix possible fifo overflow
      defenv-2: set username to 'none'
      pbl: Add missing FORCE
      wd: Provide default value for watchdog timeout
      mtd: fix mtdraw_write/mtdraw_erase arguments
      ARM: let THUMB2 select EABI
      ARM Samsung: fix pbl build for tiny210 board
      ARM omap: pbl fixes
      ARM Samsung: Let Nand boot depend on ARCH_S3C24xx
      mfd stmpe: Add missing semicolons at end of EXPORT_SYMBOL
      misc JTAG: Let Jtag driver depend on GENERIC_GPIO
      mtd mxs nand: select NAND_BBT
      mtd nand i.MX: fix compilation for unsupported SoC
      of gpio: Build gpio helper only when gpiolib is selected
      pbl: provide hang() function for the pbl
      ARM omap spi image: relax size constrains
      ARM omap spi image: print error to stderr
      misc JTAG: include fixes
      of: Check for NULL pointer in of_find_property
      net fec: connect phy at probe time
      net eth: make edev->init optional
      uimage: Fix deleting of temporary file
      net fec: call fec_init at probe time
      Merge branch 'pu/net-fixes'
      net usb asix: Add missing line breaks in dev_* messages
      bootm: Add a define for the additional devicetree size
      bootm: Do not cross 1MiB sections for the devicetree
      command: return 1 on unknown command
      mount: add compatibility to old mount command
      defenv-2 menu: when booting failed wait for key press
      replace barebox* in .gitignore with individual files
      Revert "net fec: connect phy at probe time"
      Merge branch 'phy-fixes'
      Release v2012.11.0

Teresa G?mez (5):
      ARM OMAP: switch to gpiolib support
      ARM OMAP: gpiolib fix chip.base
      ARM OMAP: Remove usage of gpio lib calls in lowlevel code
      ARM OMAP: change region size for gpio banks
      ARM OMAP: Enable gpio output

Uwe Kleine-K?nig (1):
      iomux-imx35: add missing comma in pad definition

Vicente (1):
      bootm: close open files

Wolfram Sang (3):
      mtd: ubi: cdev: fix build warning for 64-bit
      Makefile: disable CDPATH
      mtd: ubi: fix typos in comment of build.c

vicencb at gmail.com (1):
      regression: reset can not return

 .gitignore                                         |    3 +
 Documentation/barebox-main.dox                     |    4 -
 Documentation/commands.dox                         |    2 +-
 Documentation/porting.txt                          |    2 +-
 Makefile                                           |   44 +-
 arch/arm/Kconfig                                   |   18 +-
 arch/arm/Makefile                                  |   34 +-
 arch/arm/boards/a9m2410/a9m2410.c                  |    4 -
 arch/arm/boards/a9m2410/config.h                   |    4 -
 arch/arm/boards/a9m2410/lowlevel_init.S            |   17 +-
 arch/arm/boards/a9m2440/a9m2410dev.c               |    4 -
 arch/arm/boards/a9m2440/a9m2440.c                  |    4 -
 arch/arm/boards/a9m2440/baseboards.h               |    4 -
 arch/arm/boards/a9m2440/config.h                   |    4 -
 arch/arm/boards/a9m2440/lowlevel_init.S            |   17 +-
 arch/arm/boards/at91rm9200ek/env/config            |    2 +-
 arch/arm/boards/at91rm9200ek/init.c                |    4 -
 arch/arm/boards/at91sam9260ek/env/config           |    4 +-
 arch/arm/boards/at91sam9260ek/init.c               |    4 -
 arch/arm/boards/at91sam9260ek/lowlevel_init.S      |   13 +-
 arch/arm/boards/at91sam9261ek/env/config           |    4 +-
 arch/arm/boards/at91sam9261ek/init.c               |    4 -
 arch/arm/boards/at91sam9263ek/env/config           |    2 +-
 arch/arm/boards/at91sam9263ek/init.c               |    4 -
 arch/arm/boards/at91sam9m10g45ek/env/config        |    2 +-
 arch/arm/boards/at91sam9m10g45ek/init.c            |    4 -
 arch/arm/boards/at91sam9x5ek/env/config            |    5 +-
 arch/arm/boards/at91sam9x5ek/init.c                |    5 -
 arch/arm/boards/beagle/board.c                     |    4 -
 arch/arm/boards/beagle/config.h                    |    4 -
 arch/arm/boards/chumby_falconwing/config.h         |    4 -
 arch/arm/boards/chumby_falconwing/env/config       |    2 +-
 arch/arm/boards/chumby_falconwing/falconwing.c     |    4 -
 arch/arm/boards/crystalfontz-cfa10036/cfa10036.c   |    4 +
 arch/arm/boards/edb93xx/early_udelay.h             |    4 -
 arch/arm/boards/edb93xx/edb93xx.c                  |    4 -
 arch/arm/boards/edb93xx/edb93xx.h                  |    4 -
 arch/arm/boards/edb93xx/flash_cfg.c                |    4 -
 arch/arm/boards/edb93xx/pll_cfg.c                  |    4 -
 arch/arm/boards/edb93xx/pll_cfg.h                  |    4 -
 arch/arm/boards/edb93xx/sdram_cfg.c                |    4 -
 arch/arm/boards/edb93xx/sdram_cfg.h                |    4 -
 arch/arm/boards/eukrea_cpuimx25/Makefile           |    4 -
 arch/arm/boards/eukrea_cpuimx25/config.h           |    4 -
 arch/arm/boards/eukrea_cpuimx25/env/bin/init_board |    4 +-
 arch/arm/boards/eukrea_cpuimx25/env/config         |   14 +-
 arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c  |   36 +-
 arch/arm/boards/eukrea_cpuimx25/lowlevel.c         |   41 +-
 arch/arm/boards/eukrea_cpuimx27/config.h           |    4 -
 arch/arm/boards/eukrea_cpuimx27/env/bin/init       |    4 +-
 arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c  |    9 +-
 arch/arm/boards/eukrea_cpuimx27/lowlevel_init.S    |   15 +-
 arch/arm/boards/eukrea_cpuimx35/Makefile           |    4 -
 arch/arm/boards/eukrea_cpuimx35/config.h           |    4 -
 arch/arm/boards/eukrea_cpuimx35/env/bin/init_board |    4 +-
 arch/arm/boards/eukrea_cpuimx35/env/config         |   14 +-
 arch/arm/boards/eukrea_cpuimx35/eukrea_cpuimx35.c  |  104 +-
 arch/arm/boards/eukrea_cpuimx35/lowlevel.c         |   33 +-
 arch/arm/boards/eukrea_cpuimx51/config.h           |    4 -
 arch/arm/boards/eukrea_cpuimx51/env/bin/init_board |    4 +-
 arch/arm/boards/eukrea_cpuimx51/env/config         |   14 +-
 arch/arm/boards/eukrea_cpuimx51/eukrea_cpuimx51.c  |    4 -
 arch/arm/boards/freescale-mx23-evk/config.h        |    4 -
 arch/arm/boards/freescale-mx23-evk/mx23-evk.c      |    4 -
 arch/arm/boards/freescale-mx25-3-stack/3stack.c    |   24 +-
 arch/arm/boards/freescale-mx25-3-stack/Makefile    |    4 -
 arch/arm/boards/freescale-mx25-3-stack/config.h    |    4 -
 .../boards/freescale-mx25-3-stack/lowlevel_init.S  |   41 +-
 arch/arm/boards/freescale-mx28-evk/env/config      |   12 +-
 arch/arm/boards/freescale-mx35-3-stack/3stack.c    |   92 +-
 .../freescale-mx35-3-stack/board-mx35_3stack.h     |    4 -
 arch/arm/boards/freescale-mx35-3-stack/config.h    |    4 -
 arch/arm/boards/freescale-mx35-3-stack/env/config  |   14 +-
 .../boards/freescale-mx35-3-stack/lowlevel_init.S  |   22 +-
 arch/arm/boards/freescale-mx51-pdk/board.c         |    8 +-
 arch/arm/boards/freescale-mx51-pdk/config.h        |    4 -
 arch/arm/boards/freescale-mx53-loco/board.c        |    3 +-
 arch/arm/boards/freescale-mx53-loco/config.h       |    4 -
 arch/arm/boards/freescale-mx53-loco/env/config     |   16 +-
 arch/arm/boards/freescale-mx53-smd/config.h        |    4 -
 arch/arm/boards/freescale-mx53-smd/env/config      |   14 +-
 arch/arm/boards/freescale-mx6-arm2/board.c         |   48 +-
 arch/arm/boards/freescale-mx6-sabrelite/board.c    |   45 +-
 arch/arm/boards/friendlyarm-mini2440/config.h      |    4 -
 arch/arm/boards/friendlyarm-mini2440/env/config    |   14 +-
 .../boards/friendlyarm-mini2440/lowlevel_init.S    |   18 +-
 arch/arm/boards/friendlyarm-mini2440/mini2440.c    |    4 -
 arch/arm/boards/friendlyarm-tiny210/Makefile       |    1 +
 arch/arm/boards/friendlyarm-tiny210/lowlevel.c     |    7 +-
 arch/arm/boards/guf-cupid/Makefile                 |    4 -
 arch/arm/boards/guf-cupid/board.c                  |   84 +-
 arch/arm/boards/guf-cupid/config.h                 |    4 -
 arch/arm/boards/guf-cupid/env/config               |   14 +-
 arch/arm/boards/guf-cupid/lowlevel.c               |   39 +-
 arch/arm/boards/guf-neso/board.c                   |   16 +-
 arch/arm/boards/guf-neso/config.h                  |    4 -
 arch/arm/boards/guf-neso/env/config                |   14 +-
 arch/arm/boards/guf-neso/lowlevel.c                |   14 +-
 arch/arm/boards/imx21ads/config.h                  |    4 -
 arch/arm/boards/imx21ads/imx21ads.c                |   37 +-
 arch/arm/boards/imx21ads/lowlevel_init.S           |   20 +-
 arch/arm/boards/imx233-olinuxino/Makefile          |    1 +
 arch/arm/boards/imx233-olinuxino/config.h          |   21 +
 arch/arm/boards/imx233-olinuxino/env/bin/boot      |   32 +
 arch/arm/boards/imx233-olinuxino/env/bin/init      |   15 +
 arch/arm/boards/imx233-olinuxino/env/config        |   42 +
 arch/arm/boards/imx233-olinuxino/imx23-olinuxino.c |  254 +
 arch/arm/boards/imx27ads/config.h                  |    4 -
 arch/arm/boards/imx27ads/imx27ads.c                |    9 +-
 arch/arm/boards/imx27ads/lowlevel_init.S           |   11 +-
 arch/arm/boards/karo-tx25/Makefile                 |    4 -
 arch/arm/boards/karo-tx25/board.c                  |   10 +-
 arch/arm/boards/karo-tx25/config.h                 |    4 -
 arch/arm/boards/karo-tx25/env/bin/init_board       |    2 +-
 arch/arm/boards/karo-tx25/env/config               |   14 +-
 arch/arm/boards/karo-tx25/lowlevel.c               |   23 +-
 arch/arm/boards/karo-tx28/env/config               |   14 +-
 arch/arm/boards/karo-tx51/config.h                 |    4 -
 arch/arm/boards/karo-tx51/flash_header.c           |    4 -
 arch/arm/boards/karo-tx51/tx51.c                   |    4 -
 arch/arm/boards/karo-tx53/Makefile                 |    2 +
 arch/arm/boards/karo-tx53/board.c                  |  240 +
 arch/arm/boards/karo-tx53/config.h                 |   24 +
 arch/arm/boards/karo-tx53/env/init/bootargs-base   |    8 +
 arch/arm/boards/karo-tx53/env/init/hostname        |    8 +
 arch/arm/boards/karo-tx53/flash_header.c           |  147 +
 arch/arm/boards/mioa701/env/bin/init               |    2 +-
 arch/arm/boards/mmccpu/init.c                      |    4 -
 arch/arm/boards/netx/netx.c                        |    4 -
 arch/arm/boards/netx/platform.S                    |   13 +-
 arch/arm/boards/nhk8815/setup.c                    |    6 +-
 arch/arm/boards/omap343xdsp/board.c                |    4 -
 arch/arm/boards/omap343xdsp/config.h               |    4 -
 arch/arm/boards/omap3evm/board.c                   |    4 -
 arch/arm/boards/omap3evm/config.h                  |    4 -
 arch/arm/boards/panda/env/config                   |   12 +-
 arch/arm/boards/panda/lowlevel.c                   |   13 +-
 arch/arm/boards/pcm027/board.c                     |    4 -
 arch/arm/boards/pcm027/config.h                    |    4 -
 arch/arm/boards/pcm027/env/config                  |   14 +-
 arch/arm/boards/pcm027/lowlevel_init.S             |   14 +-
 arch/arm/boards/pcm037/Makefile                    |    4 -
 arch/arm/boards/pcm037/config.h                    |    4 -
 arch/arm/boards/pcm037/env/config                  |   14 +-
 arch/arm/boards/pcm037/lowlevel_init.S             |   57 +-
 arch/arm/boards/pcm037/pcm037.c                    |   70 +-
 arch/arm/boards/pcm038/config.h                    |    4 -
 arch/arm/boards/pcm038/lowlevel.c                  |   13 +-
 arch/arm/boards/pcm038/pcm038.c                    |    5 +-
 arch/arm/boards/pcm038/pcm970.c                    |   23 +-
 arch/arm/boards/pcm038/pll.h                       |    4 -
 arch/arm/boards/pcm043/Makefile                    |    4 -
 arch/arm/boards/pcm043/config.h                    |    4 -
 arch/arm/boards/pcm043/env/config                  |   14 +-
 arch/arm/boards/pcm043/lowlevel.c                  |   35 +-
 arch/arm/boards/pcm043/pcm043.c                    |   87 +-
 arch/arm/boards/pcm049/board.c                     |    8 +-
 arch/arm/boards/pcm049/env/config                  |   16 +-
 arch/arm/boards/pcm049/lowlevel.c                  |   11 +-
 arch/arm/boards/phycard-a-l1/Makefile              |    4 -
 arch/arm/boards/phycard-a-l1/config.h              |    4 -
 arch/arm/boards/phycard-a-l1/env/config            |   20 +-
 arch/arm/boards/phycard-a-l1/pca-a-l1.c            |   10 +-
 arch/arm/boards/phycard-a-l1/pca-a-l1.h            |    4 -
 arch/arm/boards/phycard-a-xl2/Makefile             |    4 -
 arch/arm/boards/phycard-a-xl2/env/config           |   16 +-
 arch/arm/boards/phycard-a-xl2/lowlevel.c           |   11 +-
 arch/arm/boards/phycard-a-xl2/pca-a-xl2.c          |    8 +-
 arch/arm/boards/phycard-i.MX27/config.h            |    4 -
 arch/arm/boards/phycard-i.MX27/env/config          |   14 +-
 arch/arm/boards/phycard-i.MX27/lowlevel_init.S     |   16 +-
 arch/arm/boards/phycard-i.MX27/pca100.c            |   24 +-
 arch/arm/boards/pm9261/init.c                      |    4 -
 arch/arm/boards/pm9263/init.c                      |    4 -
 arch/arm/boards/pm9g45/env/config                  |   13 +-
 arch/arm/boards/pm9g45/init.c                      |   11 +-
 arch/arm/boards/qil-a9260/env/config               |    2 +-
 arch/arm/boards/qil-a9260/init.c                   |    2 +-
 arch/arm/boards/scb9328/config.h                   |    4 -
 arch/arm/boards/scb9328/env/config                 |   14 +-
 arch/arm/boards/scb9328/lowlevel_init.S            |   17 +-
 arch/arm/boards/scb9328/scb9328.c                  |   23 +-
 arch/arm/boards/tny-a926x/env/config               |    6 +-
 arch/arm/boards/tny-a926x/init.c                   |    6 +-
 arch/arm/boards/toshiba-ac100/board.c              |    4 -
 arch/arm/boards/toshiba-ac100/serial.c             |    4 -
 arch/arm/boards/usb-a926x/env/config               |    6 +-
 arch/arm/boards/usb-a926x/init.c                   |    6 +-
 arch/arm/boards/versatile/versatilepb.c            |    4 -
 arch/arm/configs/a9m2410_defconfig                 |    3 +-
 arch/arm/configs/a9m2440_defconfig                 |    3 +-
 arch/arm/configs/at91rm9200ek_defconfig            |    4 +-
 arch/arm/configs/at91sam9260ek_defconfig           |    3 +-
 arch/arm/configs/at91sam9261ek_defconfig           |    4 +-
 arch/arm/configs/at91sam9263ek_defconfig           |    3 +-
 arch/arm/configs/at91sam9g10ek_defconfig           |    4 +-
 arch/arm/configs/at91sam9g20ek_defconfig           |    3 +-
 arch/arm/configs/at91sam9m10g45ek_defconfig        |    4 +-
 arch/arm/configs/at91sam9x5ek_defconfig            |    3 +-
 arch/arm/configs/chumbyone_defconfig               |    6 +-
 arch/arm/configs/cupid_defconfig                   |    6 +-
 arch/arm/configs/dss11_defconfig                   |    4 +-
 arch/arm/configs/edb93xx_defconfig                 |    3 +-
 arch/arm/configs/eukrea_cpuimx25_defconfig         |    6 +-
 arch/arm/configs/eukrea_cpuimx27_defconfig         |    5 +-
 arch/arm/configs/eukrea_cpuimx35_defconfig         |    6 +-
 arch/arm/configs/eukrea_cpuimx51_defconfig         |    4 +-
 arch/arm/configs/freescale-mx6-arm2_defconfig      |    4 +-
 arch/arm/configs/freescale-mx6-sabrelite_defconfig |    3 +
 arch/arm/configs/freescale_mx25_3stack_defconfig   |    3 +-
 arch/arm/configs/freescale_mx35_3stack_defconfig   |    5 +-
 arch/arm/configs/freescale_mx53_loco_defconfig     |    5 +-
 arch/arm/configs/freescale_mx53_smd_defconfig      |    4 +-
 arch/arm/configs/friendlyarm_mini2440_defconfig    |    3 +-
 arch/arm/configs/imx233-olinuxino_defconfig        |   63 +
 arch/arm/configs/imx28evk_defconfig                |    5 +-
 arch/arm/configs/mioa701_defconfig                 |    2 +-
 arch/arm/configs/mmccpu_defconfig                  |    3 +-
 arch/arm/configs/mx21ads_defconfig                 |    3 +-
 arch/arm/configs/mx27ads_defconfig                 |    3 +-
 arch/arm/configs/neso_defconfig                    |    6 +-
 arch/arm/configs/netx_nxdb500_defconfig            |    3 +-
 arch/arm/configs/nhk8815_defconfig                 |    4 +-
 arch/arm/configs/omap3530_beagle_defconfig         |    4 +-
 arch/arm/configs/panda_defconfig                   |    4 +-
 arch/arm/configs/pca100_defconfig                  |    4 +-
 arch/arm/configs/pcm027_defconfig                  |    6 +-
 arch/arm/configs/pcm037_defconfig                  |    4 +-
 arch/arm/configs/pcm038_defconfig                  |    2 +-
 arch/arm/configs/pcm043_defconfig                  |    4 +-
 arch/arm/configs/pcm049_defconfig                  |    4 +-
 arch/arm/configs/phycard_a_l1_defconfig            |    6 +-
 arch/arm/configs/phycard_a_xl2_defconfig           |    4 +-
 arch/arm/configs/pm9261_defconfig                  |    4 +-
 arch/arm/configs/pm9263_defconfig                  |    3 +-
 arch/arm/configs/pm9g45_defconfig                  |   32 +-
 arch/arm/configs/qil_a9260_128mib_defconfig        |    4 +-
 arch/arm/configs/qil_a9260_defconfig               |    4 +-
 arch/arm/configs/scb9328_defconfig                 |    4 +-
 arch/arm/configs/tny_a9260_defconfig               |    3 +-
 arch/arm/configs/tny_a9263_defconfig               |    3 +-
 arch/arm/configs/tny_a9g20_defconfig               |    3 +-
 arch/arm/configs/toshiba_ac100_defconfig           |    4 +-
 arch/arm/configs/tx25stk5_defconfig                |    6 +-
 arch/arm/configs/tx28stk5_defconfig                |    5 +-
 arch/arm/configs/tx51stk5_defconfig                |    6 +-
 arch/arm/configs/tx53stk5_defconfig                |   76 +
 arch/arm/configs/usb_a9260_defconfig               |    4 +-
 arch/arm/configs/usb_a9263_128mib_defconfig        |    4 +-
 arch/arm/configs/usb_a9263_defconfig               |    4 +-
 arch/arm/configs/usb_a9g20_128mib_defconfig        |    4 +-
 arch/arm/configs/usb_a9g20_defconfig               |    4 +-
 arch/arm/configs/versatilepb_defconfig             |    4 +-
 arch/arm/cpu/Kconfig                               |    2 +-
 arch/arm/cpu/Makefile                              |    4 +-
 arch/arm/cpu/cpu.c                                 |    4 -
 arch/arm/cpu/cpuinfo.c                             |    4 -
 arch/arm/cpu/interrupts.c                          |    3 -
 arch/arm/cpu/start-pbl.c                           |   41 +-
 arch/arm/cpu/start-reset.c                         |   67 -
 arch/arm/cpu/start.c                               |   32 +-
 arch/arm/include/asm/barebox-arm-head.h            |   68 +
 arch/arm/include/asm/barebox-arm.h                 |    7 +-
 arch/arm/include/asm/cache-l2x0.h                  |    3 -
 arch/arm/include/asm/system.h                      |    4 +
 arch/arm/include/asm/unified.h                     |    3 -
 arch/arm/include/asm/unwind.h                      |    3 -
 arch/arm/lib/Makefile                              |    2 +
 arch/arm/lib/armlinux.c                            |    5 -
 arch/arm/lib/ashldi3.S                             |    6 +-
 arch/arm/lib/ashrdi3.S                             |    6 +-
 arch/arm/lib/barebox.lds.S                         |    6 -
 arch/arm/lib/bootm.c                               |    4 +-
 arch/arm/lib/div0.c                                |    4 -
 arch/arm/lib/lib1funcs.S                           |    6 +-
 arch/arm/lib/lshrdi3.S                             |    6 +-
 arch/arm/lib/runtime-offset.S                      |   17 +
 arch/arm/mach-at91/Kconfig                         |    1 +
 arch/arm/mach-at91/at91rm9200_lowlevel_init.c      |    5 +-
 arch/arm/mach-at91/at91rm9200_time.c               |    4 -
 arch/arm/mach-at91/at91sam926x_lowlevel_init.c     |    5 +-
 arch/arm/mach-at91/at91sam926x_time.c              |    4 -
 arch/arm/mach-at91/gpio.c                          |    4 -
 arch/arm/mach-at91/include/mach/board.h            |    3 -
 arch/arm/mach-at91/include/mach/io.h               |    3 -
 arch/arm/mach-ep93xx/clocksource.c                 |    4 -
 arch/arm/mach-ep93xx/gpio.c                        |    3 -
 arch/arm/mach-ep93xx/include/mach/gpio.h           |    3 -
 arch/arm/mach-ep93xx/led.c                         |    4 -
 arch/arm/mach-ep93xx/led.h                         |    4 -
 arch/arm/mach-ep93xx/lowlevel_init.S               |   19 +-
 arch/arm/mach-imx/Kconfig                          |   16 +-
 arch/arm/mach-imx/Makefile                         |   21 +-
 arch/arm/mach-imx/boot.c                           |    4 -
 arch/arm/mach-imx/clk-imx1.c                       |  108 +
 arch/arm/mach-imx/clk-imx21.c                      |  119 +
 arch/arm/mach-imx/clk-imx25.c                      |  164 +
 arch/arm/mach-imx/clk-imx27.c                      |  154 +
 arch/arm/mach-imx/clk-imx31.c                      |  133 +
 arch/arm/mach-imx/clk-imx35.c                      |  186 +
 arch/arm/mach-imx/clk-imx5.c                       |  298 +
 arch/arm/mach-imx/clk-imx6.c                       |  306 +
 arch/arm/mach-imx/clk-pfd.c                        |  148 +
 arch/arm/mach-imx/{speed.c => clk-pllv1.c}         |   74 +-
 arch/arm/mach-imx/clk-pllv2.c                      |  164 +
 arch/arm/mach-imx/clk-pllv3.c                      |  386 ++
 arch/arm/mach-imx/clk.h                            |   66 +
 arch/arm/mach-imx/clko.c                           |   60 -
 arch/arm/mach-imx/clocksource.c                    |  112 +-
 arch/arm/mach-imx/external-nand-boot.c             |    6 +-
 arch/arm/mach-imx/gpio.c                           |  119 +-
 arch/arm/mach-imx/iim.c                            |    2 +-
 arch/arm/mach-imx/imx1.c                           |   25 +-
 arch/arm/mach-imx/imx21.c                          |   28 +-
 arch/arm/mach-imx/imx25.c                          |   36 +-
 arch/arm/mach-imx/imx27.c                          |   34 +-
 arch/arm/mach-imx/imx31.c                          |   26 +-
 arch/arm/mach-imx/imx35.c                          |   29 +-
 arch/arm/mach-imx/imx51.c                          |   16 +-
 arch/arm/mach-imx/imx53.c                          |   23 +-
 arch/arm/mach-imx/imx6.c                           |   22 +-
 arch/arm/mach-imx/include/mach/clkdev.h            |    7 +
 arch/arm/mach-imx/include/mach/clock.h             |   42 +-
 arch/arm/mach-imx/include/mach/devices-imx1.h      |    4 +-
 arch/arm/mach-imx/include/mach/devices-imx21.h     |    8 +-
 arch/arm/mach-imx/include/mach/devices-imx25.h     |   55 +-
 arch/arm/mach-imx/include/mach/devices-imx27.h     |   28 +-
 arch/arm/mach-imx/include/mach/devices-imx31.h     |   34 +-
 arch/arm/mach-imx/include/mach/devices-imx35.h     |   34 +-
 arch/arm/mach-imx/include/mach/devices-imx51.h     |    2 +-
 arch/arm/mach-imx/include/mach/devices-imx53.h     |    2 +-
 arch/arm/mach-imx/include/mach/iim.h               |    4 -
 arch/arm/mach-imx/include/mach/imx-regs.h          |    4 -
 arch/arm/mach-imx/include/mach/imx1-regs.h         |  154 +-
 arch/arm/mach-imx/include/mach/imx21-regs.h        |  197 +-
 arch/arm/mach-imx/include/mach/imx25-regs.h        |  163 +-
 arch/arm/mach-imx/include/mach/imx27-regs.h        |  244 +-
 arch/arm/mach-imx/include/mach/imx31-regs.h        |  248 +-
 arch/arm/mach-imx/include/mach/imx35-regs.h        |  203 +-
 arch/arm/mach-imx/include/mach/imx51-regs.h        |   19 -
 arch/arm/mach-imx/include/mach/imx53-regs.h        |   19 -
 arch/arm/mach-imx/include/mach/imx6-anadig.h       |    5 -
 arch/arm/mach-imx/include/mach/imx6-regs.h         |   19 -
 arch/arm/mach-imx/include/mach/iomux-mx21.h        |    5 -
 arch/arm/mach-imx/include/mach/iomux-mx27.h        |    4 -
 arch/arm/mach-imx/include/mach/iomux-mx2x.h        |    4 -
 arch/arm/mach-imx/include/mach/iomux-mx31.h        |    4 -
 arch/arm/mach-imx/include/mach/iomux-mx35.h        |    6 +-
 arch/arm/mach-imx/include/mach/iomux-v3.h          |    4 -
 arch/arm/mach-imx/include/mach/weim.h              |   20 +
 arch/arm/mach-imx/iomux-v2.c                       |    3 -
 arch/arm/mach-imx/iomux-v3.c                       |    8 +-
 arch/arm/mach-imx/nand.c                           |    4 -
 arch/arm/mach-imx/speed-imx1.c                     |   95 -
 arch/arm/mach-imx/speed-imx21.c                    |  197 -
 arch/arm/mach-imx/speed-imx25.c                    |  155 -
 arch/arm/mach-imx/speed-imx27.c                    |  231 -
 arch/arm/mach-imx/speed-imx31.c                    |   83 -
 arch/arm/mach-imx/speed-imx35.c                    |  259 -
 arch/arm/mach-imx/speed-imx51.c                    |  311 -
 arch/arm/mach-imx/speed-imx53.c                    |  236 -
 arch/arm/mach-imx/speed-imx6.c                     |  404 --
 arch/arm/mach-mxs/Kconfig                          |    7 +
 arch/arm/mach-mxs/clocksource-imx23.c              |    4 -
 arch/arm/mach-mxs/imx.c                            |   28 +-
 arch/arm/mach-mxs/include/mach/clock.h             |    4 -
 arch/arm/mach-mxs/include/mach/generic.h           |    4 -
 arch/arm/mach-mxs/include/mach/gpio.h              |    4 -
 arch/arm/mach-mxs/include/mach/imx-regs.h          |    4 -
 arch/arm/mach-mxs/include/mach/imx23-regs.h        |   11 -
 arch/arm/mach-mxs/include/mach/imx28-regs.h        |    7 -
 arch/arm/mach-mxs/include/mach/iomux-imx23.h       |    4 -
 arch/arm/mach-mxs/include/mach/mci.h               |    4 -
 arch/arm/mach-mxs/iomux-imx.c                      |    4 -
 arch/arm/mach-mxs/ocotp.c                          |    2 +-
 arch/arm/mach-mxs/speed-imx23.c                    |    4 -
 arch/arm/mach-mxs/usb-imx23.c                      |    4 -
 arch/arm/mach-netx/clocksource.c                   |    4 -
 arch/arm/mach-netx/generic.c                       |    4 -
 arch/arm/mach-netx/include/mach/netx-regs.h        |    3 -
 arch/arm/mach-nomadik/8815.c                       |   13 +-
 arch/arm/mach-nomadik/include/mach/board.h         |    4 -
 arch/arm/mach-nomadik/include/mach/hardware.h      |    4 -
 arch/arm/mach-nomadik/reset.c                      |    3 -
 arch/arm/mach-omap/Kconfig                         |   34 +-
 arch/arm/mach-omap/Makefile                        |    5 +-
 arch/arm/mach-omap/arch-omap.dox                   |    2 +-
 arch/arm/mach-omap/devices-gpmc-nand.c             |    4 -
 arch/arm/mach-omap/gpio.c                          |  174 +-
 arch/arm/mach-omap/gpmc.c                          |    4 -
 arch/arm/mach-omap/include/mach/clocks.h           |    4 -
 arch/arm/mach-omap/include/mach/control.h          |    4 -
 arch/arm/mach-omap/include/mach/debug_ll.h         |    3 -
 arch/arm/mach-omap/include/mach/emac_defs.h        |   48 +
 arch/arm/mach-omap/include/mach/gpio.h             |    4 -
 arch/arm/mach-omap/include/mach/gpmc.h             |    4 -
 arch/arm/mach-omap/include/mach/intc.h             |    4 -
 arch/arm/mach-omap/include/mach/mcspi.h            |   11 +
 arch/arm/mach-omap/include/mach/omap3-clock.h      |    4 -
 arch/arm/mach-omap/include/mach/omap3-devices.h    |   32 +
 arch/arm/mach-omap/include/mach/omap3-mux.h        |    4 -
 arch/arm/mach-omap/include/mach/omap3-silicon.h    |    6 -
 arch/arm/mach-omap/include/mach/omap3-smx.h        |    3 -
 arch/arm/mach-omap/include/mach/omap4-mux.h        |    4 -
 arch/arm/mach-omap/include/mach/omap4-silicon.h    |    6 -
 arch/arm/mach-omap/include/mach/sdrc.h             |    4 -
 arch/arm/mach-omap/include/mach/silicon.h          |    4 -
 arch/arm/mach-omap/include/mach/sys_info.h         |    4 -
 arch/arm/mach-omap/include/mach/syslib.h           |    4 -
 arch/arm/mach-omap/include/mach/timers.h           |    4 -
 arch/arm/mach-omap/include/mach/wdt.h              |    4 -
 arch/arm/mach-omap/include/mach/xload.h            |    4 +-
 arch/arm/mach-omap/omap3_clock.c                   |   18 +-
 arch/arm/mach-omap/omap3_core.S                    |   19 +-
 arch/arm/mach-omap/omap3_generic.c                 |   25 +-
 arch/arm/mach-omap/omap4_generic.c                 |   48 +-
 arch/arm/mach-omap/omap4_twl6030_mmc.c             |    4 -
 arch/arm/mach-omap/s32k_clksource.c                |    4 -
 arch/arm/mach-omap/syslib.c                        |    4 -
 arch/arm/mach-omap/xload.c                         |   99 +-
 arch/arm/mach-samsung/Kconfig                      |    1 +
 arch/arm/mach-samsung/Makefile                     |    1 +
 arch/arm/mach-samsung/generic.c                    |    4 -
 arch/arm/mach-samsung/gpio-s3c24x0.c               |    4 -
 arch/arm/mach-samsung/include/mach/iomux-s3c24x0.h |    4 -
 arch/arm/mach-samsung/include/mach/s3c-clocks.h    |    4 -
 arch/arm/mach-samsung/include/mach/s3c-generic.h   |    4 -
 arch/arm/mach-samsung/include/mach/s3c-iomap.h     |    4 -
 arch/arm/mach-samsung/include/mach/s3c-mci.h       |    4 -
 arch/arm/mach-samsung/include/mach/s3c24xx-fb.h    |    4 -
 arch/arm/mach-samsung/include/mach/s3c24xx-iomap.h |    4 -
 arch/arm/mach-samsung/include/mach/s3c24xx-nand.h  |    4 -
 arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h  |    4 -
 arch/arm/mach-samsung/lowlevel-s3c24x0.S           |    4 -
 arch/arm/mach-samsung/mem-s3c24x0.c                |    4 -
 arch/arm/mach-tegra/clock.c                        |    3 -
 arch/arm/mach-tegra/include/mach/debug_ll.h        |    3 -
 arch/arm/mach-tegra/reset.c                        |    3 -
 arch/arm/mach-versatile/core.c                     |   11 +-
 arch/arm/mach-versatile/include/mach/debug_ll.h    |    3 -
 arch/arm/mach-versatile/include/mach/platform.h    |    3 -
 arch/arm/pbl/.gitignore                            |    1 +
 arch/arm/pbl/zbarebox.lds.S                        |    2 -
 arch/blackfin/boards/ipe337/barebox.lds.S          |    4 -
 arch/blackfin/configs/ipe337_defconfig             |    3 +-
 arch/blackfin/cpu-bf561/start.S                    |    4 -
 arch/blackfin/include/asm/barebox.h                |    4 -
 arch/blackfin/include/asm/bitops.h                 |    4 -
 arch/blackfin/include/asm/blackfin.h               |    4 -
 arch/blackfin/include/asm/blackfin_defs.h          |    4 -
 arch/blackfin/include/asm/byteorder.h              |    4 -
 arch/blackfin/include/asm/cpu.h                    |    4 -
 arch/blackfin/include/asm/current.h                |    4 -
 arch/blackfin/include/asm/entry.h                  |    4 -
 arch/blackfin/include/asm/hw_irq.h                 |    4 -
 arch/blackfin/include/asm/io.h                     |    4 -
 arch/blackfin/include/asm/linkage.h                |    4 -
 arch/blackfin/include/asm/mem_init.h               |    4 -
 arch/blackfin/include/asm/page.h                   |    4 -
 arch/blackfin/include/asm/page_offset.h            |    4 -
 arch/blackfin/include/asm/posix_types.h            |    4 -
 arch/blackfin/include/asm/processor.h              |    4 -
 arch/blackfin/include/asm/ptrace.h                 |    4 -
 arch/blackfin/include/asm/segment.h                |    4 -
 arch/blackfin/include/asm/setup.h                  |    4 -
 arch/blackfin/include/asm/string.h                 |    4 -
 arch/blackfin/include/asm/system.h                 |    4 -
 arch/blackfin/include/asm/traps.h                  |    4 -
 arch/blackfin/include/asm/types.h                  |    4 -
 arch/blackfin/lib/ashldi3.c                        |    5 -
 arch/blackfin/lib/bf533_string.c                   |    4 -
 arch/blackfin/lib/blackfin_linux.c                 |    4 -
 arch/blackfin/lib/board.c                          |    4 -
 arch/blackfin/lib/cpu.c                            |    4 -
 arch/blackfin/lib/divsi3.S                         |    5 -
 arch/blackfin/lib/gcclib.h                         |    5 -
 arch/blackfin/lib/interrupt.S                      |    4 -
 arch/blackfin/lib/lshrdi3.c                        |    5 -
 arch/blackfin/lib/modsi3.S                         |    5 -
 arch/blackfin/lib/module.c                         |    5 -
 arch/blackfin/lib/muldi3.c                         |    4 -
 arch/blackfin/lib/traps.c                          |    4 -
 arch/blackfin/lib/udivsi3.S                        |    5 -
 arch/blackfin/lib/umodsi3.S                        |    5 -
 arch/mips/boards/dlink-dir-320/config.h            |    4 -
 arch/mips/boards/dlink-dir-320/serial.c            |    3 -
 arch/mips/boards/qemu-malta/config.h               |    4 -
 arch/mips/boards/qemu-malta/init.c                 |    3 -
 arch/mips/boards/rzx50/config.h                    |    4 -
 arch/mips/boards/rzx50/include/board/debug_ll.h    |    3 -
 arch/mips/boards/rzx50/serial.c                    |    3 -
 arch/mips/boot/main_entry.c                        |    4 -
 arch/mips/boot/start.S                             |    3 -
 arch/mips/configs/dlink-dir-320_defconfig          |    4 +-
 arch/mips/configs/qemu-malta_defconfig             |    4 +-
 arch/mips/include/asm/barebox.h                    |    4 -
 arch/mips/include/asm/bitops.h                     |    4 -
 arch/mips/include/asm/common.h                     |    4 -
 arch/mips/include/asm/mipsregs.h                   |    3 -
 arch/mips/include/asm/module.h                     |    4 -
 arch/mips/include/asm/string.h                     |    4 -
 arch/mips/include/debug_ll_ns16550.h               |    3 -
 arch/mips/lib/barebox.lds.S                        |    3 -
 arch/mips/lib/cpuinfo.c                            |    3 -
 arch/mips/lib/csrc-r4k.c                           |    3 -
 arch/mips/lib/memory.c                             |    3 -
 arch/mips/mach-bcm47xx/include/mach/debug_ll.h     |    3 -
 arch/mips/mach-bcm47xx/include/mach/hardware.h     |    3 -
 arch/mips/mach-bcm47xx/reset.c                     |    3 -
 arch/mips/mach-malta/include/mach/debug_ll.h       |    3 -
 arch/mips/mach-malta/include/mach/hardware.h       |    3 -
 arch/mips/mach-malta/reset.c                       |    3 -
 arch/mips/mach-xburst/csrc-jz4750.c                |    3 -
 arch/mips/mach-xburst/include/mach/debug_ll.h      |    3 -
 arch/mips/mach-xburst/reset-jz4750.c               |    3 -
 arch/nios2/boards/generic/generic.c                |    2 +-
 arch/nios2/cpu/barebox.lds.S                       |    4 -
 arch/nios2/cpu/cpu.c                               |    4 -
 arch/nios2/cpu/exceptions.S                        |    4 -
 arch/nios2/cpu/start.S                             |    4 -
 arch/nios2/cpu/traps.c                             |    4 -
 arch/nios2/include/asm/io.h                        |    4 -
 arch/nios2/include/asm/nios2-io.h                  |    4 -
 arch/nios2/include/asm/nios2.h                     |    4 -
 arch/nios2/include/asm/opcodes.h                   |    4 -
 arch/nios2/include/asm/ptrace.h                    |    4 -
 arch/nios2/include/asm/string.h                    |    4 -
 arch/nios2/include/asm/system.h                    |    4 -
 arch/nios2/lib/board.c                             |    4 -
 arch/nios2/lib/bootm.c                             |    4 -
 arch/nios2/lib/clock.c                             |    4 -
 arch/nios2/lib/early_printf.c                      |    4 -
 arch/nios2/lib/longlong.h                          |    7 +-
 arch/openrisc/Makefile                             |    4 -
 arch/openrisc/cpu/barebox.lds.S                    |    4 -
 arch/openrisc/cpu/cache.c                          |    4 -
 arch/openrisc/cpu/cpu.c                            |    4 -
 arch/openrisc/cpu/exceptions.c                     |    4 -
 arch/openrisc/cpu/start.S                          |    4 -
 arch/openrisc/include/asm/bitops.h                 |    4 -
 arch/openrisc/include/asm/cache.h                  |    4 -
 arch/openrisc/include/asm/io.h                     |    4 -
 arch/openrisc/include/asm/openrisc_exc.h           |    4 -
 arch/openrisc/include/asm/system.h                 |    4 -
 arch/openrisc/include/asm/types.h                  |    4 -
 arch/openrisc/lib/Makefile                         |    1 +
 arch/openrisc/lib/ashrdi3.S                        |   59 +
 arch/openrisc/lib/board.c                          |    4 -
 arch/openrisc/lib/clock.c                          |    4 -
 arch/openrisc/lib/cpuinfo.c                        |    4 -
 arch/ppc/boards/freescale-p2020rdb/barebox.lds.S   |    4 -
 arch/ppc/boards/freescale-p2020rdb/config.h        |    4 -
 arch/ppc/boards/freescale-p2020rdb/law.c           |    4 -
 arch/ppc/boards/freescale-p2020rdb/p2020rdb.c      |    4 -
 arch/ppc/boards/freescale-p2020rdb/tlb.c           |    4 -
 arch/ppc/boards/pcm030/barebox.lds.S               |    4 -
 arch/ppc/boards/pcm030/config.h                    |    4 -
 arch/ppc/boards/pcm030/mt46v32m16-75.h             |    4 -
 arch/ppc/boards/pcm030/pcm030.c                    |    9 +-
 arch/ppc/configs/pcm030_defconfig                  |    3 +-
 arch/ppc/cpu-85xx/fixed_ivor.S                     |    4 -
 arch/ppc/cpu-85xx/start.S                          |    4 -
 arch/ppc/cpu-85xx/tlb.c                            |    4 -
 arch/ppc/cpu-85xx/traps.c                          |    4 -
 arch/ppc/include/asm/barebox.h                     |    4 -
 arch/ppc/include/asm/config.h                      |    4 -
 arch/ppc/include/asm/ppc_asm.tmpl                  |    4 -
 arch/ppc/include/asm/ppc_defs.h                    |    4 -
 arch/ppc/lib/bat_rw.c                              |    4 -
 arch/ppc/lib/board.c                               |    4 -
 arch/ppc/lib/crtsavres.S                           |    5 -
 arch/ppc/lib/extable.c                             |    4 -
 arch/ppc/lib/module.c                              |    3 -
 arch/ppc/lib/reloc.S                               |    4 -
 arch/ppc/lib/ticks.S                               |    4 -
 arch/ppc/mach-mpc5xxx/cpu.c                        |    4 -
 arch/ppc/mach-mpc5xxx/cpu_init.c                   |    4 -
 arch/ppc/mach-mpc5xxx/include/mach/fec.h           |   14 -
 arch/ppc/mach-mpc5xxx/include/mach/mpc5xxx.h       |    4 -
 arch/ppc/mach-mpc5xxx/io.S                         |    4 -
 arch/ppc/mach-mpc5xxx/pci_mpc5200.c                |    4 -
 arch/ppc/mach-mpc5xxx/speed.c                      |    4 -
 arch/ppc/mach-mpc5xxx/start.S                      |    4 -
 arch/ppc/mach-mpc5xxx/time.c                       |    4 -
 arch/ppc/mach-mpc5xxx/traps.c                      |    4 -
 arch/ppc/mach-mpc85xx/cpu.c                        |    4 -
 arch/ppc/mach-mpc85xx/cpu_init.c                   |    4 -
 arch/ppc/mach-mpc85xx/cpuid.c                      |    4 -
 arch/ppc/mach-mpc85xx/fsl_law.c                    |    4 -
 .../ppc/mach-mpc85xx/include/mach/config_mpc85xx.h |    4 -
 arch/ppc/mach-mpc85xx/include/mach/early_udelay.h  |    4 -
 arch/ppc/mach-mpc85xx/include/mach/immap_85xx.h    |    4 -
 arch/ppc/mach-mpc85xx/speed.c                      |    4 -
 arch/ppc/mach-mpc85xx/time.c                       |    4 -
 arch/sandbox/Kconfig                               |    3 +
 arch/sandbox/Makefile                              |    9 +-
 arch/sandbox/board/board.c                         |   26 +-
 arch/sandbox/board/clock.c                         |    3 -
 arch/sandbox/board/console.c                       |    3 -
 arch/sandbox/board/devices.c                       |    2 +-
 arch/sandbox/board/hostfile.c                      |    5 +-
 arch/sandbox/configs/sandbox_defconfig             |    3 +-
 arch/sandbox/include/asm/posix_types.h             |   14 +
 arch/sandbox/include/asm/processor.h               |    4 -
 arch/sandbox/include/asm/unaligned.h               |    2 +-
 arch/sandbox/mach-sandbox/include/mach/linux.h     |   14 +
 arch/sandbox/os/Makefile                           |    2 +
 arch/sandbox/os/common.c                           |   54 +-
 arch/sandbox/os/sdl.c                              |  108 +
 arch/sandbox/os/tap.c                              |    3 -
 arch/x86/boards/x86_generic/config.h               |    4 -
 arch/x86/boards/x86_generic/generic_pc.c           |    4 -
 arch/x86/boot/boot_hdisk.S                         |    4 -
 arch/x86/boot/boot_main.S                          |    4 -
 arch/x86/boot/main_entry.c                         |    4 -
 arch/x86/include/asm/barebox.h                     |    4 -
 arch/x86/include/asm/bitops.h                      |    4 -
 arch/x86/include/asm/byteorder.h                   |    4 -
 arch/x86/include/asm/common.h                      |    4 -
 arch/x86/include/asm/elf.h                         |    4 -
 arch/x86/include/asm/modes.h                       |    4 -
 arch/x86/include/asm/module.h                      |    4 -
 arch/x86/include/asm/posix_types.h                 |    4 -
 arch/x86/include/asm/segment.h                     |    4 -
 arch/x86/include/asm/string.h                      |    4 -
 arch/x86/include/asm/syslib.h                      |    4 -
 arch/x86/include/asm/types.h                       |    4 -
 arch/x86/lib/barebox.lds.S                         |    4 -
 arch/x86/lib/bios_disk.S                           |    4 -
 arch/x86/lib/gdt.c                                 |    4 -
 arch/x86/lib/linux_start.S                         |    4 -
 arch/x86/lib/memory.c                              |    4 -
 arch/x86/lib/memory16.S                            |    4 -
 arch/x86/lib/traveler.S                            |    4 -
 arch/x86/mach-i386/generic.c                       |    4 -
 arch/x86/mach-i386/include/mach/barebox.lds.h      |    4 -
 arch/x86/mach-i386/pit_timer.c                     |    4 -
 arch/x86/mach-i386/reset.c                         |    4 -
 commands/Kconfig                                   |   89 +-
 commands/Makefile                                  |    4 +-
 commands/automount.c                               |    6 +-
 commands/bmp.c                                     |  221 -
 commands/bootm.c                                   |   29 +-
 commands/cat.c                                     |    3 -
 commands/cd.c                                      |    3 -
 commands/clear.c                                   |    3 -
 commands/clk.c                                     |  144 +
 commands/cp.c                                      |    3 -
 commands/crc.c                                     |    3 -
 commands/dfu.c                                     |    3 -
 commands/digest.c                                  |    3 -
 commands/echo.c                                    |   15 +-
 commands/edit.c                                    |    3 -
 commands/exec.c                                    |    3 -
 commands/export.c                                  |    3 -
 commands/false.c                                   |    4 -
 commands/flash.c                                   |    4 -
 commands/global.c                                  |   54 +-
 commands/go.c                                      |    4 -
 commands/gpio.c                                    |    4 -
 commands/help.c                                    |    4 -
 commands/i2c.c                                     |    4 -
 commands/iomem.c                                   |    4 -
 commands/led.c                                     |    4 -
 commands/linux16.c                                 |    4 -
 commands/linux_exec.c                              |    3 -
 commands/loadb.c                                   |    4 -
 commands/loadenv.c                                 |    3 -
 commands/loads.c                                   |    4 -
 commands/login.c                                   |    3 -
 commands/ls.c                                      |    3 -
 commands/mem.c                                     |    6 +-
 commands/meminfo.c                                 |    3 -
 commands/memtest.c                                 |    4 -
 commands/menu.c                                    |    4 -
 commands/mkdir.c                                   |    3 -
 commands/mount.c                                   |   22 +-
 commands/nand.c                                    |    3 -
 commands/nandtest.c                                |    3 -
 commands/net.c                                     |    4 -
 commands/oftree.c                                  |   31 +-
 commands/partition.c                               |    3 -
 commands/passwd.c                                  |    3 -
 commands/printenv.c                                |    3 -
 commands/pwd.c                                     |    3 -
 commands/readline.c                                |    4 -
 commands/reginfo.c                                 |    3 -
 commands/reset.c                                   |    3 -
 commands/rm.c                                      |    3 -
 commands/saveenv.c                                 |    3 -
 commands/setenv.c                                  |    3 -
 commands/sleep.c                                   |    3 -
 commands/splash.c                                  |  103 +
 commands/test.c                                    |    3 -
 commands/tftp.c                                    |  103 +
 commands/timeout.c                                 |    3 -
 commands/trigger.c                                 |    4 -
 commands/true.c                                    |    4 -
 commands/umount.c                                  |    3 -
 commands/uncompress.c                              |    3 -
 commands/usb.c                                     |    3 -
 commands/usbserial.c                               |    3 -
 commands/version.c                                 |    4 -
 common/Kconfig                                     |    8 +-
 common/Makefile                                    |   38 +-
 common/block.c                                     |    3 -
 common/bootargs.c                                  |    3 -
 common/clock.c                                     |    3 -
 common/command.c                                   |    6 +-
 common/complete.c                                  |    3 -
 common/console.c                                   |    6 +-
 common/date.c                                      |    4 -
 common/digest.c                                    |    4 -
 common/env.c                                       |    3 -
 common/environment.c                               |    3 -
 common/filetype.c                                  |   81 +-
 common/globalvar.c                                 |   10 +
 common/hush.c                                      |    3 -
 common/image.c                                     |    6 +-
 common/meminfo.c                                   |   23 +
 common/memory.c                                    |    3 -
 common/memsize.c                                   |    4 -
 common/menu.c                                      |    4 -
 common/misc.c                                      |    3 -
 common/module.c                                    |    3 -
 common/module.lds.S                                |    4 -
 common/oftree.c                                    |    4 +-
 common/partitions.c                                |   12 +-
 common/password.c                                  |    3 -
 common/resource.c                                  |    4 -
 common/s_record.c                                  |    4 -
 common/startup.c                                   |   27 +-
 common/tlsf_malloc.c                               |    3 -
 common/uimage.c                                    |    8 +-
 crypto/sha1.c                                      |    5 -
 crypto/sha2.c                                      |    3 -
 defaultenv-2/base/bin/boot                         |    6 +-
 defaultenv-2/base/bin/bootargs-ip                  |    4 +-
 defaultenv-2/base/bin/bootargs-ip-barebox          |    2 +-
 defaultenv-2/base/bin/bootargs-ip-dhcp             |    2 +-
 defaultenv-2/base/bin/bootargs-ip-none             |    2 +-
 defaultenv-2/base/bin/bootargs-root-disk           |    2 +-
 defaultenv-2/base/bin/bootargs-root-ext            |    2 +-
 defaultenv-2/base/bin/bootargs-root-initrd         |    2 +-
 defaultenv-2/base/bin/bootargs-root-jffs2          |    2 +-
 defaultenv-2/base/bin/bootargs-root-nfs            |    2 +-
 defaultenv-2/base/bin/bootargs-root-ubi            |    2 +-
 defaultenv-2/base/bin/init                         |    5 +-
 defaultenv-2/base/boot/initrd                      |    2 +-
 defaultenv-2/base/data/ansi-colors                 |    4 +
 defaultenv-2/base/init/general                     |    2 +-
 defaultenv-2/base/network/eth0                     |    1 +
 defaultenv-2/menu/menu/boot-menu-add-entry         |    2 +-
 defaultenv-2/menu/menu/mainmenu                    |    4 +-
 defaultenv/bin/boot                                |   12 +-
 defaultenv/bin/init                                |    2 +
 defaultenv/config                                  |   18 +-
 drivers/Kconfig                                    |    1 +
 drivers/Makefile                                   |    2 +
 drivers/amba/Makefile                              |    2 +
 drivers/amba/bus.c                                 |  217 +
 drivers/ata/disk_bios_drive.c                      |    6 +-
 drivers/ata/intf_platform_ide.c                    |    2 +-
 drivers/base/Makefile                              |    1 +
 drivers/base/bus.c                                 |   37 +
 drivers/base/driver.c                              |   71 +-
 drivers/base/platform.c                            |   53 +-
 drivers/base/resource.c                            |    6 +-
 drivers/clk/Kconfig                                |    3 +
 drivers/clk/Makefile                               |    2 +-
 drivers/clk/clk-divider.c                          |   98 +
 drivers/clk/clk-fixed-factor.c                     |   63 +
 drivers/clk/clk-fixed.c                            |   55 +
 drivers/clk/clk-mux.c                              |   77 +
 drivers/clk/clk.c                                  |  224 +
 drivers/clk/clkdev.c                               |   55 +
 drivers/eeprom/at25.c                              |    2 +-
 drivers/gpio/gpio-stmpe.c                          |    4 +-
 drivers/i2c/busses/i2c-imx.c                       |   17 +-
 drivers/i2c/busses/i2c-omap.c                      |    6 +-
 drivers/i2c/i2c.c                                  |   30 +
 drivers/input/gpio_keys.c                          |    2 +-
 drivers/input/imx_keypad.c                         |    2 +-
 drivers/led/core.c                                 |    4 -
 drivers/led/led-gpio.c                             |    4 -
 drivers/led/led-triggers.c                         |    4 -
 drivers/mci/atmel_mci.c                            |    2 +-
 drivers/mci/imx-esdhc.c                            |   42 +-
 drivers/mci/imx-esdhc.h                            |    4 -
 drivers/mci/imx.c                                  |   17 +-
 drivers/mci/mci-core.c                             |   10 +-
 drivers/mci/mci_spi.c                              |   13 +-
 drivers/mci/mxs.c                                  |    6 +-
 drivers/mci/omap_hsmmc.c                           |    6 +-
 drivers/mci/pxamci.c                               |    2 +-
 drivers/mci/s3c.c                                  |    6 +-
 drivers/mfd/lp3972.c                               |    6 +-
 drivers/mfd/mc13xxx.c                              |   44 +-
 drivers/mfd/mc34704.c                              |    8 +-
 drivers/mfd/mc34708.c                              |   33 +-
 drivers/mfd/mc9sdz60.c                             |    6 +-
 drivers/mfd/stmpe-i2c.c                            |    6 +-
 drivers/mfd/twl4030.c                              |    2 +-
 drivers/mfd/twl6030.c                              |    2 +-
 drivers/misc/Kconfig                               |    1 +
 drivers/misc/jtag.c                                |    6 +-
 drivers/mtd/core.c                                 |    3 +-
 drivers/mtd/devices/docg3.c                        |    2 +-
 drivers/mtd/mtdraw.c                               |    4 +-
 drivers/mtd/nand/Kconfig                           |    1 +
 drivers/mtd/nand/atmel_nand.c                      |    2 +-
 drivers/mtd/nand/nand-bb.c                         |    3 -
 drivers/mtd/nand/nand_base.c                       |   97 +-
 drivers/mtd/nand/nand_ids.c                        |   30 +
 drivers/mtd/nand/nand_imx.c                        |    5 +-
 drivers/mtd/nand/nand_mxs.c                        |    2 +-
 drivers/mtd/nand/nand_omap_gpmc.c                  |    2 +-
 drivers/mtd/nand/nand_s3c24xx.c                    |    5 +-
 drivers/mtd/nand/nomadik_nand.c                    |    2 +-
 drivers/mtd/ubi/build.c                            |    5 +-
 drivers/mtd/ubi/cdev.c                             |    2 +-
 drivers/mtd/ubi/debug.c                            |    3 -
 drivers/mtd/ubi/debug.h                            |    3 -
 drivers/mtd/ubi/eba.c                              |    3 -
 drivers/mtd/ubi/io.c                               |    3 -
 drivers/mtd/ubi/kapi.c                             |    3 -
 drivers/mtd/ubi/misc.c                             |    3 -
 drivers/mtd/ubi/scan.c                             |    3 -
 drivers/mtd/ubi/scan.h                             |    3 -
 drivers/mtd/ubi/ubi-media.h                        |    3 -
 drivers/mtd/ubi/ubi.h                              |    3 -
 drivers/mtd/ubi/upd.c                              |    3 -
 drivers/mtd/ubi/vmt.c                              |    3 -
 drivers/mtd/ubi/vtbl.c                             |    3 -
 drivers/mtd/ubi/wl.c                               |    3 -
 drivers/net/Kconfig                                |   42 +-
 drivers/net/Makefile                               |    4 +-
 drivers/net/altera_tse.c                           |   54 +-
 drivers/net/altera_tse.h                           |    3 +-
 drivers/net/at91_ether.c                           |   55 +-
 drivers/net/cs8900.c                               |    2 +-
 drivers/net/davinci_emac.c                         |  618 ++
 drivers/net/davinci_emac.h                         |  289 +
 drivers/net/designware.c                           |   84 +-
 drivers/net/dm9k.c                                 |   52 +-
 drivers/net/ep93xx.c                               |   37 +-
 drivers/net/ep93xx.h                               |    6 +-
 drivers/net/fec_imx.c                              |  134 +-
 drivers/net/fec_imx.h                              |   11 +-
 drivers/net/fec_mpc5200.c                          |   60 +-
 drivers/net/fec_mpc5200.h                          |    4 +-
 drivers/net/gianfar.c                              |   64 +-
 drivers/net/gianfar.h                              |    2 +-
 drivers/net/ks8851_mll.c                           |   42 +-
 drivers/net/ksz8864rmn.c                           |  191 +
 drivers/net/macb.c                                 |   84 +-
 drivers/net/macb.h                                 |    4 -
 drivers/net/miidev.c                               |  316 --
 drivers/net/netx_eth.c                             |   28 +-
 drivers/net/phy/Kconfig                            |   22 +
 drivers/net/phy/Makefile                           |    3 +
 drivers/net/phy/generic.c                          |   36 +
 drivers/net/phy/mdio_bus.c                         |  248 +
 drivers/net/phy/phy.c                              |  595 ++
 drivers/net/phy/smsc.c                             |  146 +
 drivers/net/smc91111.c                             |   53 +-
 drivers/net/smc911x.c                              |   43 +-
 drivers/net/tap.c                                  |    5 +-
 drivers/net/usb/Kconfig                            |    4 +-
 drivers/net/usb/asix.c                             |   85 +-
 drivers/net/usb/smsc95xx.c                         |   45 +-
 drivers/net/usb/smsc95xx.h                         |    4 -
 drivers/net/usb/usbnet.c                           |   11 +-
 drivers/nor/cfi_flash.c                            |   41 +-
 drivers/nor/cfi_flash.h                            |    6 -
 drivers/nor/m25p80.c                               |   76 +-
 drivers/nor/m25p80.h                               |    2 +-
 drivers/of/Kconfig                                 |    2 +
 drivers/of/Makefile                                |    3 +
 drivers/of/base.c                                  |  805 +++
 drivers/of/gpio.c                                  |   28 +
 drivers/of/partition.c                             |   64 +
 drivers/pwm/core.c                                 |    4 -
 drivers/pwm/pxa_pwm.c                              |    2 +-
 drivers/serial/amba-pl011.c                        |   78 +-
 drivers/serial/arm_dcc.c                           |    7 +-
 drivers/serial/atmel.c                             |    5 +-
 drivers/serial/linux_console.c                     |    5 +-
 drivers/serial/serial_altera.c                     |    6 +-
 drivers/serial/serial_altera_jtag.c                |    6 +-
 drivers/serial/serial_blackfin.c                   |    6 +-
 drivers/serial/serial_imx.c                        |   48 +-
 drivers/serial/serial_mpc5xxx.c                    |    6 +-
 drivers/serial/serial_netx.c                       |    6 +-
 drivers/serial/serial_ns16550.c                    |    8 +-
 drivers/serial/serial_pl010.c                      |    6 +-
 drivers/serial/serial_pl010.h                      |    4 -
 drivers/serial/serial_pxa.c                        |    2 +-
 drivers/serial/serial_s3c.c                        |    5 +-
 drivers/serial/stm-serial.c                        |    5 +-
 drivers/spi/Kconfig                                |    6 +
 drivers/spi/Makefile                               |    1 +
 drivers/spi/altera_spi.c                           |    6 +-
 drivers/spi/atmel_spi.c                            |    6 +-
 drivers/spi/imx_spi.c                              |   77 +-
 drivers/spi/omap3_spi.c                            |  399 ++
 drivers/spi/omap3_spi.h                            |   94 +
 drivers/spi/spi.c                                  |   65 +-
 drivers/usb/core/usb.c                             |    9 +-
 drivers/usb/gadget/at91_udc.c                      |    2 +-
 drivers/usb/gadget/composite.c                     |    3 -
 drivers/usb/gadget/dfu.c                           |    4 -
 drivers/usb/gadget/epautoconf.c                    |    3 -
 drivers/usb/gadget/fsl_udc.c                       |    2 +-
 drivers/usb/gadget/pxa27x_udc.c                    |    5 +-
 drivers/usb/gadget/pxa27x_udc.h                    |    4 -
 drivers/usb/host/ehci-core.h                       |    4 -
 drivers/usb/host/ehci-hcd.c                        |    6 +-
 drivers/usb/host/ehci.h                            |    4 -
 drivers/usb/host/ohci-at91.c                       |    6 +-
 drivers/usb/host/ohci-hcd.c                        |    6 +-
 drivers/usb/otg/twl4030.c                          |    4 -
 drivers/usb/otg/ulpi.c                             |    5 -
 drivers/usb/storage/transport.c                    |    4 -
 drivers/usb/storage/transport.h                    |    4 -
 drivers/usb/storage/usb.c                          |    4 -
 drivers/usb/storage/usb.h                          |    4 -
 drivers/video/Kconfig                              |    4 +
 drivers/video/Makefile                             |    1 +
 drivers/video/fb.c                                 |   52 +-
 drivers/video/imx-ipu-fb.c                         |   16 +-
 drivers/video/imx.c                                |   12 +-
 drivers/video/pxa.c                                |    7 +-
 drivers/video/s3c24xx.c                            |    6 +-
 drivers/video/sdl.c                                |  101 +
 drivers/video/stm.c                                |    2 +-
 drivers/watchdog/im28wd.c                          |    2 +-
 fs/devfs-core.c                                    |    4 +-
 fs/devfs.c                                         |    3 -
 fs/fat/fat.c                                       |    3 -
 fs/fat/ff.c                                        |   37 +-
 fs/fs.c                                            |    9 +-
 fs/nfs.c                                           |    3 -
 fs/ramfs.c                                         |    3 -
 fs/tftp.c                                          |   15 +-
 include/command.h                                  |    4 -
 include/common.h                                   |    8 +-
 include/console.h                                  |    4 -
 include/debug_ll.h                                 |    6 -
 include/digest.h                                   |    4 -
 include/driver.h                                   |   52 +-
 include/environment.h                              |   10 +-
 include/fb.h                                       |    2 +
 include/fec.h                                      |    7 +-
 include/filetype.h                                 |   20 +
 include/getopt.h                                   |    3 -
 include/globalvar.h                                |   23 +
 include/gui/graphic_utils.h                        |   24 +
 include/gui/gui.h                                  |   38 +
 include/gui/image.h                                |   20 +
 include/gui/image_renderer.h                       |   74 +
 include/i2c/i2c.h                                  |    8 +
 include/image.h                                    |    9 +-
 include/kfifo.h                                    |    5 -
 include/linux/amba/bus.h                           |  153 +
 include/linux/amba/serial.h                        |   32 +-
 include/linux/clk.h                                |   42 +
 include/linux/clkdev.h                             |    3 +
 include/linux/err.h                                |    5 +
 include/linux/ethtool.h                            |  114 +
 include/linux/mii.h                                |  421 +-
 include/linux/mtd/ubi.h                            |    3 -
 include/linux/phy.h                                |  270 +
 include/linux/rbtree.h                             |    3 -
 include/linux/smscphy.h                            |   25 +
 include/mci.h                                      |    4 -
 include/menu.h                                     |    4 -
 include/miidev.h                                   |   77 -
 include/mtd/ubi-user.h                             |    3 -
 include/net.h                                      |    6 +-
 include/net/davinci_emac.h                         |   10 +
 include/net/designware.h                           |    2 +-
 include/ns16550.h                                  |    4 -
 include/of.h                                       |  113 +
 include/part.h                                     |    4 -
 include/password.h                                 |    3 -
 include/rtc.h                                      |    4 -
 include/s_record.h                                 |    4 -
 include/scsi.h                                     |    4 -
 include/sizes.h                                    |    4 -
 include/spi/spi.h                                  |   13 +
 include/ubi-media.h                                |    3 -
 include/usb/composite.h                            |    4 -
 include/usb/dfu.h                                  |    3 -
 include/usb/usb.h                                  |    4 -
 include/usb/usb_defs.h                             |    4 -
 include/usb/usbnet.h                               |    8 +-
 lib/Kconfig                                        |    2 +
 lib/Makefile                                       |    1 +
 lib/ctype.c                                        |    4 -
 lib/decompress_unlzo.c                             |    5 -
 lib/display_options.c                              |    4 -
 lib/getopt.c                                       |    3 -
 lib/gui/Kconfig                                    |   39 +
 lib/gui/Makefile                                   |    5 +
 lib/gui/bmp.c                                      |  134 +
 {include => lib/gui}/bmp_layout.h                  |   15 +-
 lib/gui/graphic_utils.c                            |  252 +
 lib/gui/image_renderer.c                           |   95 +
 lib/gui/lodepng.c                                  | 5928 ++++++++++++++++++++
 lib/gui/lodepng.h                                  | 1640 ++++++
 lib/gui/picopng.c                                  |  810 +++
 lib/gui/picopng.h                                  |   34 +
 lib/gui/png.c                                      |   86 +
 lib/gui/png.h                                      |   21 +
 lib/gui/png_lode.c                                 |   90 +
 lib/gui/png_pico.c                                 |   85 +
 lib/kfifo.c                                        |    5 -
 lib/libbb.c                                        |    1 -
 lib/libgen.c                                       |    3 -
 lib/misc.c                                         |    3 -
 lib/parameter.c                                    |    4 +-
 lib/process_escape_sequence.c                      |    3 -
 lib/rbtree.c                                       |    3 -
 lib/readkey.c                                      |    3 -
 lib/show_progress.c                                |    3 -
 lib/uncompress.c                                   |    3 -
 lib/xfuncs.c                                       |    3 -
 logo/LICENCE                                       |   22 +
 logo/png24/100x100/color/barebox.png               |  Bin 0 -> 22724 bytes
 logo/png24/100x100/white/barebox.png               |  Bin 0 -> 12053 bytes
 logo/png24/200x200/color/barebox.png               |  Bin 0 -> 71557 bytes
 logo/png24/200x200/white/barebox.png               |  Bin 0 -> 31132 bytes
 logo/png24/400x400/color/barebox.png               |  Bin 0 -> 217170 bytes
 logo/png24/400x400/white/barebox.png               |  Bin 0 -> 78591 bytes
 logo/png24/600x600/color/barebox.png               |  Bin 0 -> 406788 bytes
 logo/png24/600x600/while/barebox.png               |  Bin 0 -> 137235 bytes
 logo/png24/800x800/color/barebox.png               |  Bin 0 -> 627433 bytes
 logo/png24/800x800/white/barebox.png               |  Bin 0 -> 210397 bytes
 logo/png8/100x100/color/blackbg/barebox.png        |  Bin 0 -> 8279 bytes
 logo/png8/100x100/white/blackbg/barebox.png        |  Bin 0 -> 6089 bytes
 logo/png8/200x200/color/blackbg/barebox.png        |  Bin 0 -> 23616 bytes
 logo/png8/200x200/white/blackbg/barebox.png        |  Bin 0 -> 14838 bytes
 logo/png8/400x400/color/blackbg/barebox.png        |  Bin 0 -> 71295 bytes
 logo/png8/400x400/white/blackbg/barebox.png        |  Bin 0 -> 38480 bytes
 logo/png8/600x600/color/blackbg/barebox.png        |  Bin 0 -> 130709 bytes
 logo/png8/600x600/while/blackbg/barebox.png        |  Bin 0 -> 68648 bytes
 logo/png8/800x800/color/blackbg/barebox.png        |  Bin 0 -> 205281 bytes
 logo/png8/800x800/white/blackbg/barebox.png        |  Bin 0 -> 104173 bytes
 net/Kconfig                                        |    8 -
 net/Makefile                                       |    1 -
 net/dhcp.c                                         |  167 +-
 net/eth.c                                          |   82 +-
 net/net.c                                          |   21 +-
 net/netconsole.c                                   |    3 -
 net/rarp.h                                         |    4 -
 net/tftp.c                                         |  412 --
 net/tftp.h                                         |   18 -
 pbl/misc.c                                         |    5 +
 scripts/.gitignore                                 |    1 +
 scripts/Makefile                                   |    2 +-
 scripts/Makefile.build                             |    4 +-
 scripts/bareboxenv.c                               |   18 +-
 scripts/genenv                                     |   23 +-
 scripts/kconfig/lxdialog/checklist.c               |    4 -
 scripts/kconfig/lxdialog/dialog.h                  |    4 -
 scripts/kconfig/lxdialog/inputbox.c                |    4 -
 scripts/kconfig/lxdialog/menubox.c                 |    4 -
 scripts/kconfig/lxdialog/textbox.c                 |    4 -
 scripts/kconfig/lxdialog/util.c                    |    4 -
 scripts/kconfig/lxdialog/yesno.c                   |    4 -
 scripts/kconfig/zconf.tab.c_shipped                |    5 +-
 scripts/mk-am35xx-spi-image.c                      |  139 +
 scripts/mkimage.c                                  |    4 -
 scripts/omap_signGP.c                              |    3 -
 scripts/s5p_cksum.c                                |    4 -
 scripts/setupmbr/setupmbr.c                        |    4 -
 1077 files changed, 23738 insertions(+), 8787 deletions(-)
 create mode 100644 arch/arm/boards/imx233-olinuxino/Makefile
 create mode 100644 arch/arm/boards/imx233-olinuxino/config.h
 create mode 100644 arch/arm/boards/imx233-olinuxino/env/bin/boot
 create mode 100644 arch/arm/boards/imx233-olinuxino/env/bin/init
 create mode 100644 arch/arm/boards/imx233-olinuxino/env/config
 create mode 100644 arch/arm/boards/imx233-olinuxino/imx23-olinuxino.c
 create mode 100644 arch/arm/boards/karo-tx53/Makefile
 create mode 100644 arch/arm/boards/karo-tx53/board.c
 create mode 100644 arch/arm/boards/karo-tx53/config.h
 create mode 100644 arch/arm/boards/karo-tx53/env/init/bootargs-base
 create mode 100644 arch/arm/boards/karo-tx53/env/init/hostname
 create mode 100644 arch/arm/boards/karo-tx53/flash_header.c
 create mode 100644 arch/arm/configs/imx233-olinuxino_defconfig
 create mode 100644 arch/arm/configs/tx53stk5_defconfig
 delete mode 100644 arch/arm/cpu/start-reset.c
 create mode 100644 arch/arm/lib/runtime-offset.S
 create mode 100644 arch/arm/mach-imx/clk-imx1.c
 create mode 100644 arch/arm/mach-imx/clk-imx21.c
 create mode 100644 arch/arm/mach-imx/clk-imx25.c
 create mode 100644 arch/arm/mach-imx/clk-imx27.c
 create mode 100644 arch/arm/mach-imx/clk-imx31.c
 create mode 100644 arch/arm/mach-imx/clk-imx35.c
 create mode 100644 arch/arm/mach-imx/clk-imx5.c
 create mode 100644 arch/arm/mach-imx/clk-imx6.c
 create mode 100644 arch/arm/mach-imx/clk-pfd.c
 rename arch/arm/mach-imx/{speed.c => clk-pllv1.c} (53%)
 create mode 100644 arch/arm/mach-imx/clk-pllv2.c
 create mode 100644 arch/arm/mach-imx/clk-pllv3.c
 create mode 100644 arch/arm/mach-imx/clk.h
 delete mode 100644 arch/arm/mach-imx/clko.c
 create mode 100644 arch/arm/mach-imx/include/mach/clkdev.h
 create mode 100644 arch/arm/mach-imx/include/mach/weim.h
 delete mode 100644 arch/arm/mach-imx/speed-imx1.c
 delete mode 100644 arch/arm/mach-imx/speed-imx21.c
 delete mode 100644 arch/arm/mach-imx/speed-imx25.c
 delete mode 100644 arch/arm/mach-imx/speed-imx27.c
 delete mode 100644 arch/arm/mach-imx/speed-imx31.c
 delete mode 100644 arch/arm/mach-imx/speed-imx35.c
 delete mode 100644 arch/arm/mach-imx/speed-imx51.c
 delete mode 100644 arch/arm/mach-imx/speed-imx53.c
 delete mode 100644 arch/arm/mach-imx/speed-imx6.c
 create mode 100644 arch/arm/mach-omap/include/mach/emac_defs.h
 create mode 100644 arch/arm/mach-omap/include/mach/mcspi.h
 create mode 100644 arch/arm/mach-omap/include/mach/omap3-devices.h
 create mode 100644 arch/openrisc/lib/ashrdi3.S
 delete mode 100644 arch/ppc/mach-mpc5xxx/include/mach/fec.h
 create mode 100644 arch/sandbox/os/sdl.c
 delete mode 100644 commands/bmp.c
 create mode 100644 commands/clk.c
 create mode 100644 commands/splash.c
 create mode 100644 commands/tftp.c
 create mode 100644 common/meminfo.c
 create mode 100644 drivers/amba/Makefile
 create mode 100644 drivers/amba/bus.c
 create mode 100644 drivers/base/bus.c
 create mode 100644 drivers/clk/clk-divider.c
 create mode 100644 drivers/clk/clk-fixed-factor.c
 create mode 100644 drivers/clk/clk-fixed.c
 create mode 100644 drivers/clk/clk-mux.c
 create mode 100644 drivers/clk/clk.c
 create mode 100644 drivers/net/davinci_emac.c
 create mode 100644 drivers/net/davinci_emac.h
 create mode 100644 drivers/net/ksz8864rmn.c
 delete mode 100644 drivers/net/miidev.c
 create mode 100644 drivers/net/phy/Kconfig
 create mode 100644 drivers/net/phy/Makefile
 create mode 100644 drivers/net/phy/generic.c
 create mode 100644 drivers/net/phy/mdio_bus.c
 create mode 100644 drivers/net/phy/phy.c
 create mode 100644 drivers/net/phy/smsc.c
 create mode 100644 drivers/of/Kconfig
 create mode 100644 drivers/of/Makefile
 create mode 100644 drivers/of/base.c
 create mode 100644 drivers/of/gpio.c
 create mode 100644 drivers/of/partition.c
 create mode 100644 drivers/spi/omap3_spi.c
 create mode 100644 drivers/spi/omap3_spi.h
 create mode 100644 drivers/video/sdl.c
 create mode 100644 include/gui/graphic_utils.h
 create mode 100644 include/gui/gui.h
 create mode 100644 include/gui/image.h
 create mode 100644 include/gui/image_renderer.h
 create mode 100644 include/linux/amba/bus.h
 create mode 100644 include/linux/ethtool.h
 create mode 100644 include/linux/phy.h
 create mode 100644 include/linux/smscphy.h
 delete mode 100644 include/miidev.h
 create mode 100644 include/net/davinci_emac.h
 create mode 100644 lib/gui/Kconfig
 create mode 100644 lib/gui/Makefile
 create mode 100644 lib/gui/bmp.c
 rename {include => lib/gui}/bmp_layout.h (84%)
 create mode 100644 lib/gui/graphic_utils.c
 create mode 100644 lib/gui/image_renderer.c
 create mode 100644 lib/gui/lodepng.c
 create mode 100644 lib/gui/lodepng.h
 create mode 100644 lib/gui/picopng.c
 create mode 100644 lib/gui/picopng.h
 create mode 100644 lib/gui/png.c
 create mode 100644 lib/gui/png.h
 create mode 100644 lib/gui/png_lode.c
 create mode 100644 lib/gui/png_pico.c
 create mode 100644 logo/LICENCE
 create mode 100644 logo/png24/100x100/color/barebox.png
 create mode 100644 logo/png24/100x100/white/barebox.png
 create mode 100644 logo/png24/200x200/color/barebox.png
 create mode 100644 logo/png24/200x200/white/barebox.png
 create mode 100644 logo/png24/400x400/color/barebox.png
 create mode 100644 logo/png24/400x400/white/barebox.png
 create mode 100644 logo/png24/600x600/color/barebox.png
 create mode 100644 logo/png24/600x600/while/barebox.png
 create mode 100644 logo/png24/800x800/color/barebox.png
 create mode 100644 logo/png24/800x800/white/barebox.png
 create mode 100644 logo/png8/100x100/color/blackbg/barebox.png
 create mode 100644 logo/png8/100x100/white/blackbg/barebox.png
 create mode 100644 logo/png8/200x200/color/blackbg/barebox.png
 create mode 100644 logo/png8/200x200/white/blackbg/barebox.png
 create mode 100644 logo/png8/400x400/color/blackbg/barebox.png
 create mode 100644 logo/png8/400x400/white/blackbg/barebox.png
 create mode 100644 logo/png8/600x600/color/blackbg/barebox.png
 create mode 100644 logo/png8/600x600/while/blackbg/barebox.png
 create mode 100644 logo/png8/800x800/color/blackbg/barebox.png
 create mode 100644 logo/png8/800x800/white/blackbg/barebox.png
 delete mode 100644 net/tftp.c
 delete mode 100644 net/tftp.h
 create mode 100644 scripts/mk-am35xx-spi-image.c

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From plagnioj at jcrosoft.com  Fri Nov 16 11:57:29 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri, 16 Nov 2012 17:57:29 +0100
Subject: [PATCH 0/7] at91sam9 add  watchdog support with keep alive
Message-ID: <20121116165729.GA8327@game.jcrosoft.org>

HI,

	The following patch series add the at91sam9 watchdog present on 
	sam9260/9g20/9261/9g10/9g45/9x5

	and introdudce the kep a live support so we can reset the watchdog via
	poller


The following changes since commit 281b927f44ae94280648714e3587efa4419f6ce3:

  Release v2012.11.0 (2012-11-16 13:54:49 +0100)

are available in the git repository at:

  git://git.jcrosoft.org/barebox.git delivery/at91sam9_wdt

for you to fetch changes up to 9bef4b05631b352e9dc842fbf68f84532c5cc257:

  at91sam9x5: add wathdog support (2012-11-15 03:24:29 +0800)

----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (7):
      watchdog: add keep alive support
      watchdog: add at91sam9 watchdog support
      at91sam9260/9g20: add wathdog support
      at91sam9261/9g10: add wathdog support
      at91sam9263: add wathdog support
      at91sam9g45: add wathdog support
      at91sam9x5: add wathdog support

 arch/arm/mach-at91/at91sam9260_devices.c |   12 ++++++++++++
 arch/arm/mach-at91/at91sam9261_devices.c |   12 ++++++++++++
 arch/arm/mach-at91/at91sam9263_devices.c |   11 +++++++++++
 arch/arm/mach-at91/at91sam9g45_devices.c |   12 ++++++++++++
 arch/arm/mach-at91/at91sam9x5_devices.c  |   12 ++++++++++++
 drivers/watchdog/Kconfig                 |    8 ++++++++
 drivers/watchdog/Makefile                |    1 +
 drivers/watchdog/at91sam9_wdt.c          |  131 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/watchdog/at91sam9_wdt.h          |   38 ++++++++++++++++++++++++++++++++++++++
 drivers/watchdog/wd_core.c               |   20 ++++++++++++++++++++
 include/watchdog.h                       |    2 ++
 11 files changed, 259 insertions(+)
 create mode 100644 drivers/watchdog/at91sam9_wdt.c
 create mode 100644 drivers/watchdog/at91sam9_wdt.h

Best Regards,
J.


From plagnioj at jcrosoft.com  Fri Nov 16 12:02:59 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri, 16 Nov 2012 18:02:59 +0100
Subject: [PATCH 1/7] watchdog: add keep alive support
In-Reply-To: <20121116165729.GA8327@game.jcrosoft.org>
References: <20121116165729.GA8327@game.jcrosoft.org>
Message-ID: <1353085385-14090-1-git-send-email-plagnioj@jcrosoft.com>

this will allow to ping the watchdog via poller

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/watchdog/Kconfig   |    1 +
 drivers/watchdog/wd_core.c |   20 ++++++++++++++++++++
 include/watchdog.h         |    2 ++
 3 files changed, 23 insertions(+)

diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 8fdc7a5..21480a1 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -1,5 +1,6 @@
 menuconfig WATCHDOG
 	bool "Watchdog support              "
+	select GENERIC_POLLER
 	help
 	  Many platforms support a watchdog to keep track of a working machine.
 	  This framework provides routines to handle these watchdogs.
diff --git a/drivers/watchdog/wd_core.c b/drivers/watchdog/wd_core.c
index 3d0cfc6..f0a43f3 100644
--- a/drivers/watchdog/wd_core.c
+++ b/drivers/watchdog/wd_core.c
@@ -17,18 +17,38 @@
 #include <errno.h>
 #include <linux/ctype.h>
 #include <watchdog.h>
+#include <poller.h>
 
 /*
  * Note: this simple framework supports one watchdog only.
  */
 static struct watchdog *watchdog;
 
+static void watchdog_poller_func(struct poller_struct *poller)
+{
+	watchdog->keep_alive(watchdog);
+}
+
+struct poller_struct watchdog_poller = {
+	.func = watchdog_poller_func,
+};
+
 int watchdog_register(struct watchdog *wd)
 {
 	if (watchdog != NULL)
 		return -EBUSY;
 
+	if (watchdog->keep_alive) {
+		int ret;
+	
+		ret = poller_register(&watchdog_poller);
+		if (ret)
+			return ret;
+	}
+
 	watchdog = wd;
+
+
 	return 0;
 }
 EXPORT_SYMBOL(watchdog_register);
diff --git a/include/watchdog.h b/include/watchdog.h
index 3e2d08e..d5ecf2f 100644
--- a/include/watchdog.h
+++ b/include/watchdog.h
@@ -13,8 +13,10 @@
 #ifndef INCLUDE_WATCHDOG_H
 # define INCLUDE_WATCHDOG_H
 
+
 struct watchdog {
 	int (*set_timeout)(struct watchdog *, unsigned);
+	void (*keep_alive)(struct watchdog *);
 };
 
 int watchdog_register(struct watchdog *);
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Fri Nov 16 12:03:02 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri, 16 Nov 2012 18:03:02 +0100
Subject: [PATCH 4/7] at91sam9261/9g10: add wathdog support
In-Reply-To: <1353085385-14090-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121116165729.GA8327@game.jcrosoft.org>
 <1353085385-14090-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1353085385-14090-4-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/mach-at91/at91sam9261_devices.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/mach-at91/at91sam9261_devices.c b/arch/arm/mach-at91/at91sam9261_devices.c
index 0091e2d..5784e13 100644
--- a/arch/arm/mach-at91/at91sam9261_devices.c
+++ b/arch/arm/mach-at91/at91sam9261_devices.c
@@ -10,6 +10,7 @@
  *
  */
 #include <common.h>
+#include <init.h>
 #include <sizes.h>
 #include <asm/armlinux.h>
 #include <asm/hardware.h>
@@ -257,3 +258,14 @@ void at91_add_device_mci(short mmc_id, struct atmel_mci_platform_data *data)
 #else
 void at91_add_device_mci(short mmc_id, struct atmel_mci_platform_data *data) {}
 #endif
+
+#ifdef CONFIG_WATCHDOG_AT91SAM9X
+static int at91_add_device_watchdog(void)
+{
+	add_generic_device("at91sam9_wdt", DEVICE_ID_SINGLE, NULL,
+		AT91_WDT + AT91_BASE_SYS, 16, IORESOURCE_MEM, NULL);
+
+	return 0;
+}
+coredevice_initcall(at91_add_device_watchdog);
+#endif
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Fri Nov 16 12:03:00 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri, 16 Nov 2012 18:03:00 +0100
Subject: [PATCH 2/7] watchdog: add at91sam9 watchdog support
In-Reply-To: <1353085385-14090-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121116165729.GA8327@game.jcrosoft.org>
 <1353085385-14090-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1353085385-14090-2-git-send-email-plagnioj@jcrosoft.com>

with keep alive support

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/watchdog/Kconfig        |    7 +++
 drivers/watchdog/Makefile       |    1 +
 drivers/watchdog/at91sam9_wdt.c |  131 +++++++++++++++++++++++++++++++++++++++
 drivers/watchdog/at91sam9_wdt.h |   38 ++++++++++++
 4 files changed, 177 insertions(+)
 create mode 100644 drivers/watchdog/at91sam9_wdt.c
 create mode 100644 drivers/watchdog/at91sam9_wdt.h

diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 21480a1..5bd1083 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -7,6 +7,13 @@ menuconfig WATCHDOG
 
 if WATCHDOG
 
+config WATCHDOG_AT91SAM9X
+	tristate "AT91SAM9X / AT91CAP9 watchdog"
+	depends on ARCH_AT91
+	help
+	  Watchdog timer embedded into AT91SAM9X and AT91CAP9 chips. This will
+	  reboot your system when the timeout is reached.
+
 config WATCHDOG_MXS28
 	bool "i.MX28"
 	depends on ARCH_IMX28
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index b29103b..4e863a5 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -1,2 +1,3 @@
 obj-$(CONFIG_WATCHDOG) += wd_core.o
+obj-$(CONFIG_WATCHDOG_AT91SAM9X) += at91sam9_wdt.o
 obj-$(CONFIG_WATCHDOG_MXS28) += im28wd.o
diff --git a/drivers/watchdog/at91sam9_wdt.c b/drivers/watchdog/at91sam9_wdt.c
new file mode 100644
index 0000000..c76ceee
--- /dev/null
+++ b/drivers/watchdog/at91sam9_wdt.c
@@ -0,0 +1,131 @@
+/*
+ * (c) 2012 Juergen Beisert <kernel at pengutronix.de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Note: this driver works for the i.MX28 SoC. It might work for the
+ * i.MX23 Soc as well, but is not tested yet.
+ */
+
+#include <common.h>
+#include <init.h>
+#include <io.h>
+#include <errno.h>
+#include <malloc.h>
+#include <watchdog.h>
+
+#include "at91sam9_wdt.h"
+
+struct at91sam9_wdt {
+	struct watchdog wdt;
+	void __iomem *base;
+};
+
+#define to_at91sam9_wdt(h) container_of(h, struct at91sam9_wdt, wdt)
+
+#define wdt_read(at91wdt, field) \
+	__raw_readl(at91wdt->base + field)
+#define wdt_write(at91wdt, field, val) \
+	__raw_writel((val), at91wdt->base + field)
+
+static void at91sam9_wdt_keep_alive(struct watchdog *wdt)
+{
+	struct at91sam9_wdt *at91wdt = to_at91sam9_wdt(wdt);
+	
+	wdt_write(at91wdt, AT91_WDT_CR, AT91_WDT_KEY | AT91_WDT_WDRSTT);
+}
+
+static int at91sam9_wdt_settimeout(struct watchdog *wdt, unsigned int timeout)
+{
+	struct at91sam9_wdt *at91wdt = to_at91sam9_wdt(wdt);
+	unsigned int reg;
+	unsigned int mr;
+
+	/* Check if disabled */
+	mr = wdt_read(at91wdt, AT91_WDT_MR);
+	if (mr & AT91_WDT_WDDIS) {
+		pr_err("sorry, watchdog is disabled\n");
+		return -EIO;
+	}
+
+	if (!timeout) {
+		wdt_write(at91wdt, AT91_WDT_MR, AT91_WDT_WDDIS);
+		return 0;
+	}
+
+	/*
+	 * All counting occurs at SLOW_CLOCK / 128 = 256 Hz
+	 *
+	 * Since WDV is a 12-bit counter, the maximum period is
+	 * 4096 / 256 = 16 seconds.
+	 */
+	reg = AT91_WDT_WDRSTEN	/* causes watchdog reset */
+		/* | AT91_WDT_WDRPROC	causes processor reset only */
+		| AT91_WDT_WDDBGHLT	/* disabled in debug mode */
+		| AT91_WDT_WDD		/* restart at any time */
+		| (timeout & AT91_WDT_WDV);  /* timer value */
+	wdt_write(at91wdt, AT91_WDT_MR, reg);
+
+	return 0;
+}
+
+static int at91sam9_wdt_probe(struct device_d *dev)
+{
+	struct at91sam9_wdt *priv;
+	struct watchdog *wdt;
+	int ret;
+	unsigned int mr;
+
+	priv = xzalloc(sizeof(struct at91sam9_wdt));
+	priv->base = dev_request_mem_region(dev, 0);
+	wdt = &priv->wdt;
+	
+	wdt->set_timeout = at91sam9_wdt_settimeout;
+	wdt->keep_alive = at91sam9_wdt_keep_alive;
+
+	/* Check if disabled */
+	mr = wdt_read(priv, AT91_WDT_MR);
+	if (mr & AT91_WDT_WDDIS) {
+		dev_err(dev, "sorry, watchdog is disabled\n");
+		ret = -EIO;
+		goto err;
+	}
+
+	ret = watchdog_register(wdt);
+	if (ret != 0)
+		goto err;
+
+	dev->priv = priv;
+	return 0;
+
+err:
+	free(priv);
+	return ret;
+}
+
+static void at91sam9_wdt_remove(struct device_d *dev)
+{
+	struct at91sam9_wdt *priv= dev->priv;
+	watchdog_deregister(&priv->wdt);
+	free(priv);
+}
+
+static struct driver_d at91sam9_wdt_driver = {
+	.name   = "at91sam9_wdt",
+	.probe  = at91sam9_wdt_probe,
+	.remove = at91sam9_wdt_remove,
+};
+
+static int at91sam9_wdt_init(void)
+{
+	return platform_driver_register(&at91sam9_wdt_driver);
+}
+device_initcall(at91sam9_wdt_init);
diff --git a/drivers/watchdog/at91sam9_wdt.h b/drivers/watchdog/at91sam9_wdt.h
new file mode 100644
index 0000000..2b68c1a
--- /dev/null
+++ b/drivers/watchdog/at91sam9_wdt.h
@@ -0,0 +1,38 @@
+/*
+ * drivers/watchdog/at91sam9_wdt.h
+ *
+ * Copyright (C) 2007 Andrew Victor
+ * Copyright (C) 2007 Atmel Corporation.
+ *
+ * Watchdog Timer (WDT) - System peripherals regsters.
+ * Based on AT91SAM9261 datasheet revision D.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef AT91_WDT_H
+#define AT91_WDT_H
+
+#define AT91_WDT_CR		0x00			/* Watchdog Control Register */
+#define		AT91_WDT_WDRSTT		(1    << 0)		/* Restart */
+#define		AT91_WDT_KEY		(0xa5 << 24)		/* KEY Password */
+
+#define AT91_WDT_MR		0x04			/* Watchdog Mode Register */
+#define		AT91_WDT_WDV		(0xfff << 0)		/* Counter Value */
+#define		AT91_WDT_WDFIEN		(1     << 12)		/* Fault Interrupt Enable */
+#define		AT91_WDT_WDRSTEN	(1     << 13)		/* Reset Processor */
+#define		AT91_WDT_WDRPROC	(1     << 14)		/* Timer Restart */
+#define		AT91_WDT_WDDIS		(1     << 15)		/* Watchdog Disable */
+#define		AT91_WDT_WDD		(0xfff << 16)		/* Delta Value */
+#define		AT91_WDT_WDDBGHLT	(1     << 28)		/* Debug Halt */
+#define		AT91_WDT_WDIDLEHLT	(1     << 29)		/* Idle Halt */
+
+#define AT91_WDT_SR		0x08			/* Watchdog Status Register */
+#define		AT91_WDT_WDUNF		(1 << 0)		/* Watchdog Underflow */
+#define		AT91_WDT_WDERR		(1 << 1)		/* Watchdog Error */
+
+
+#endif
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Fri Nov 16 12:03:03 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri, 16 Nov 2012 18:03:03 +0100
Subject: [PATCH 5/7] at91sam9263: add wathdog support
In-Reply-To: <1353085385-14090-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121116165729.GA8327@game.jcrosoft.org>
 <1353085385-14090-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1353085385-14090-5-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/mach-at91/at91sam9263_devices.c |   11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/arch/arm/mach-at91/at91sam9263_devices.c b/arch/arm/mach-at91/at91sam9263_devices.c
index e686480..0386d79 100644
--- a/arch/arm/mach-at91/at91sam9263_devices.c
+++ b/arch/arm/mach-at91/at91sam9263_devices.c
@@ -10,6 +10,7 @@
  *
  */
 #include <common.h>
+#include <init.h>
 #include <sizes.h>
 #include <asm/armlinux.h>
 #include <asm/hardware.h>
@@ -351,3 +352,13 @@ void at91_add_device_mci(short mmc_id, struct atmel_mci_platform_data *data)
 void at91_add_device_mci(short mmc_id, struct atmel_mci_platform_data *data) {}
 #endif
 
+#ifdef CONFIG_WATCHDOG_AT91SAM9X
+static int at91_add_device_watchdog(void)
+{
+	add_generic_device("at91sam9_wdt", DEVICE_ID_SINGLE, NULL,
+		AT91_WDT + AT91_BASE_SYS, 16, IORESOURCE_MEM, NULL);
+
+	return 0;
+}
+coredevice_initcall(at91_add_device_watchdog);
+#endif
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Fri Nov 16 12:03:01 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri, 16 Nov 2012 18:03:01 +0100
Subject: [PATCH 3/7] at91sam9260/9g20: add wathdog support
In-Reply-To: <1353085385-14090-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121116165729.GA8327@game.jcrosoft.org>
 <1353085385-14090-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1353085385-14090-3-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/mach-at91/at91sam9260_devices.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/mach-at91/at91sam9260_devices.c b/arch/arm/mach-at91/at91sam9260_devices.c
index 9c9534e..e781de0 100644
--- a/arch/arm/mach-at91/at91sam9260_devices.c
+++ b/arch/arm/mach-at91/at91sam9260_devices.c
@@ -10,6 +10,7 @@
  *
  */
 #include <common.h>
+#include <init.h>
 #include <sizes.h>
 #include <asm/armlinux.h>
 #include <asm/hardware.h>
@@ -356,3 +357,14 @@ void at91_add_device_mci(short mmc_id, struct atmel_mci_platform_data *data)
 #else
 void at91_add_device_mci(short mmc_id, struct atmel_mci_platform_data *data) {}
 #endif
+
+#ifdef CONFIG_WATCHDOG_AT91SAM9X
+static int at91_add_device_watchdog(void)
+{
+	add_generic_device("at91sam9_wdt", DEVICE_ID_SINGLE, NULL,
+		AT91_WDT + AT91_BASE_SYS, 16, IORESOURCE_MEM, NULL);
+
+	return 0;
+}
+coredevice_initcall(at91_add_device_watchdog);
+#endif
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Fri Nov 16 12:03:05 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri, 16 Nov 2012 18:03:05 +0100
Subject: [PATCH 7/7] at91sam9x5: add wathdog support
In-Reply-To: <1353085385-14090-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121116165729.GA8327@game.jcrosoft.org>
 <1353085385-14090-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1353085385-14090-7-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/mach-at91/at91sam9x5_devices.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/mach-at91/at91sam9x5_devices.c b/arch/arm/mach-at91/at91sam9x5_devices.c
index 26a380d..27e9ec9 100644
--- a/arch/arm/mach-at91/at91sam9x5_devices.c
+++ b/arch/arm/mach-at91/at91sam9x5_devices.c
@@ -10,6 +10,7 @@
  *
  */
 #include <common.h>
+#include <init.h>
 #include <sizes.h>
 #include <asm/armlinux.h>
 #include <asm/hardware.h>
@@ -234,3 +235,14 @@ resource_size_t __init at91_configure_usart3(unsigned pins)
 	return AT91SAM9X5_BASE_USART3;
 }
 #endif
+
+#ifdef CONFIG_WATCHDOG_AT91SAM9X
+static int at91_add_device_watchdog(void)
+{
+	add_generic_device("at91sam9_wdt", DEVICE_ID_SINGLE, NULL,
+		AT91_WDT + AT91_BASE_SYS, 16, IORESOURCE_MEM, NULL);
+
+	return 0;
+}
+coredevice_initcall(at91_add_device_watchdog);
+#endif
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Fri Nov 16 12:03:04 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri, 16 Nov 2012 18:03:04 +0100
Subject: [PATCH 6/7] at91sam9g45: add wathdog support
In-Reply-To: <1353085385-14090-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121116165729.GA8327@game.jcrosoft.org>
 <1353085385-14090-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1353085385-14090-6-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/mach-at91/at91sam9g45_devices.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/mach-at91/at91sam9g45_devices.c b/arch/arm/mach-at91/at91sam9g45_devices.c
index 22b455e..38593fc 100644
--- a/arch/arm/mach-at91/at91sam9g45_devices.c
+++ b/arch/arm/mach-at91/at91sam9g45_devices.c
@@ -10,6 +10,7 @@
  *
  */
 #include <common.h>
+#include <init.h>
 #include <sizes.h>
 #include <asm/armlinux.h>
 #include <asm/hardware.h>
@@ -324,3 +325,14 @@ void at91_add_device_spi(int spi_id, struct at91_spi_platform_data *pdata)
 #else
 void at91_add_device_spi(int spi_id, struct at91_spi_platform_data *pdata) {}
 #endif
+
+#ifdef CONFIG_WATCHDOG_AT91SAM9X
+static int at91_add_device_watchdog(void)
+{
+	add_generic_device("at91sam9_wdt", DEVICE_ID_SINGLE, NULL,
+		AT91_WDT + AT91_BASE_SYS, 16, IORESOURCE_MEM, NULL);
+
+	return 0;
+}
+coredevice_initcall(at91_add_device_watchdog);
+#endif
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Fri Nov 16 12:19:51 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri, 16 Nov 2012 18:19:51 +0100
Subject: [PATCH 1/3] phylib: export phy_id via param
In-Reply-To: <1353086393-16213-1-git-send-email-plagnioj@jcrosoft.com>
References: <1353086393-16213-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1353086393-16213-2-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/net/phy/mdio_bus.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index e36641e..b0c6231 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -191,6 +191,9 @@ static int mdio_bus_probe(struct device_d *_dev)
 	sprintf(str, "%d", dev->addr);
 	dev_add_param_fixed(&dev->dev, "phy_addr", str);
 
+	sprintf(str, "0x%08x", dev->phy_id);
+	dev_add_param_fixed(&dev->dev, "phy_id", str);
+
 	dev->cdev.name = asprintf("phy%d", _dev->id);
 	dev->cdev.size = 64;
 	dev->cdev.ops = &phydev_ops;
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Fri Nov 16 12:19:52 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri, 16 Nov 2012 18:19:52 +0100
Subject: [PATCH 2/3] phylib: introduction of forced 100Mbps
In-Reply-To: <1353086393-16213-1-git-send-email-plagnioj@jcrosoft.com>
References: <1353086393-16213-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1353086393-16213-3-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/net/phy/mdio_bus.c |    4 ++++
 include/linux/phy.h        |    3 ++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index b0c6231..0e7ca93 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -171,6 +171,10 @@ static int mdio_bus_probe(struct device_d *_dev)
 			dev->speed = SPEED_10;
 			dev->duplex = DUPLEX_FULL;
 			dev->autoneg = !AUTONEG_ENABLE;
+		} else if (dev->dev_flags & PHYLIB_FORCE_100) {
+			dev->speed = SPEED_100;
+			dev->duplex = DUPLEX_FULL;
+			dev->autoneg = !AUTONEG_ENABLE;
 		}
 	}
 
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 3892bb3..af61fa7 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -60,7 +60,8 @@ typedef enum {
 #define MII_BUS_ID_SIZE	(20 - 3)
 
 #define PHYLIB_FORCE_10		(1 << 0)
-#define PHYLIB_FORCE_LINK	(1 << 1)
+#define PHYLIB_FORCE_100	(1 << 1)
+#define PHYLIB_FORCE_LINK	(1 << 2)
 
 #define PHYLIB_CAPABLE_1000M	(1 << 0)
 
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Fri Nov 16 12:19:50 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri, 16 Nov 2012 18:19:50 +0100
Subject: [PATCH 1/1] at91sam9260ek: specify mach entry
Message-ID: <1353086393-16213-1-git-send-email-plagnioj@jcrosoft.com>

as the sam9260ek may not be the first one in the list

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/configs/at91sam9260ek_defconfig |    1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/configs/at91sam9260ek_defconfig b/arch/arm/configs/at91sam9260ek_defconfig
index b746bc8..9c5c7d5 100644
--- a/arch/arm/configs/at91sam9260ek_defconfig
+++ b/arch/arm/configs/at91sam9260ek_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARCH_AT91SAM9260=y
+CONFIG_MACH_AT91SAM9260EK=y
 CONFIG_AEABI=y
 # CONFIG_CMD_ARM_CPUINFO is not set
 CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Fri Nov 16 12:19:53 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri, 16 Nov 2012 18:19:53 +0100
Subject: [PATCH 3/3] macb/ether: split flags for drivers and phylib
In-Reply-To: <1353086393-16213-1-git-send-email-plagnioj@jcrosoft.com>
References: <1353086393-16213-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1353086393-16213-4-git-send-email-plagnioj@jcrosoft.com>

as in the kernel use is_rmii
flags for pinctrl
phy_flags for phylib flags

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/boards/at91rm9200ek/init.c      |    2 +-
 arch/arm/boards/at91sam9260ek/init.c     |    2 +-
 arch/arm/boards/at91sam9263ek/init.c     |    2 +-
 arch/arm/boards/at91sam9m10g45ek/init.c  |    2 +-
 arch/arm/boards/at91sam9x5ek/init.c      |    2 +-
 arch/arm/boards/mmccpu/init.c            |    2 +-
 arch/arm/boards/pm9263/init.c            |    2 +-
 arch/arm/boards/pm9g45/init.c            |    2 +-
 arch/arm/boards/qil-a9260/init.c         |    2 +-
 arch/arm/boards/tny-a926x/init.c         |    2 +-
 arch/arm/boards/usb-a926x/init.c         |    2 +-
 arch/arm/mach-at91/at91rm9200_devices.c  |    2 +-
 arch/arm/mach-at91/at91sam9260_devices.c |    2 +-
 arch/arm/mach-at91/at91sam9263_devices.c |    2 +-
 arch/arm/mach-at91/at91sam9g45_devices.c |    2 +-
 arch/arm/mach-at91/at91sam9x5_devices.c  |    4 ++--
 arch/arm/mach-at91/include/mach/board.h  |    7 +++----
 drivers/net/at91_ether.c                 |    2 +-
 drivers/net/macb.c                       |    5 ++---
 19 files changed, 23 insertions(+), 25 deletions(-)

diff --git a/arch/arm/boards/at91rm9200ek/init.c b/arch/arm/boards/at91rm9200ek/init.c
index 439ee9e..f5d242f 100644
--- a/arch/arm/boards/at91rm9200ek/init.c
+++ b/arch/arm/boards/at91rm9200ek/init.c
@@ -33,7 +33,7 @@
 #include <spi/spi.h>
 
 static struct at91_ether_platform_data ether_pdata = {
-	.flags = AT91SAM_ETHER_RMII,
+	.is_rmii = 1,
 	.phy_addr = 0,
 };
 
diff --git a/arch/arm/boards/at91sam9260ek/init.c b/arch/arm/boards/at91sam9260ek/init.c
index d0a8458..e9bfee6 100644
--- a/arch/arm/boards/at91sam9260ek/init.c
+++ b/arch/arm/boards/at91sam9260ek/init.c
@@ -128,7 +128,7 @@ static void ek_add_device_nand(void)
 }
 
 static struct at91_ether_platform_data macb_pdata = {
-	.flags    = AT91SAM_ETHER_RMII,
+	.is_rmii = 1,
 	.phy_addr = 0,
 };
 
diff --git a/arch/arm/boards/at91sam9263ek/init.c b/arch/arm/boards/at91sam9263ek/init.c
index b577f4d..45a30fd 100644
--- a/arch/arm/boards/at91sam9263ek/init.c
+++ b/arch/arm/boards/at91sam9263ek/init.c
@@ -84,7 +84,7 @@ static void ek_add_device_nand(void)
 }
 
 static struct at91_ether_platform_data macb_pdata = {
-	.flags = AT91SAM_ETHER_RMII,
+	.is_rmii = 1,
 	.phy_addr = 0,
 };
 
diff --git a/arch/arm/boards/at91sam9m10g45ek/init.c b/arch/arm/boards/at91sam9m10g45ek/init.c
index f1c43cc..0c03dea 100644
--- a/arch/arm/boards/at91sam9m10g45ek/init.c
+++ b/arch/arm/boards/at91sam9m10g45ek/init.c
@@ -107,7 +107,7 @@ static void ek_add_device_nand(void)
 }
 
 static struct at91_ether_platform_data macb_pdata = {
-	.flags = AT91SAM_ETHER_RMII,
+	.is_rmii = 1,
 	.phy_addr = 0,
 };
 
diff --git a/arch/arm/boards/at91sam9x5ek/init.c b/arch/arm/boards/at91sam9x5ek/init.c
index 5626577..ba5bc47 100644
--- a/arch/arm/boards/at91sam9x5ek/init.c
+++ b/arch/arm/boards/at91sam9x5ek/init.c
@@ -106,7 +106,7 @@ static void ek_add_device_nand(void)
 }
 
 static struct at91_ether_platform_data macb_pdata = {
-	.flags    = AT91SAM_ETHER_RMII,
+	.is_rmii = 1,
 	.phy_addr = 0,
 };
 
diff --git a/arch/arm/boards/mmccpu/init.c b/arch/arm/boards/mmccpu/init.c
index 97248b9..67bfcea 100644
--- a/arch/arm/boards/mmccpu/init.c
+++ b/arch/arm/boards/mmccpu/init.c
@@ -34,7 +34,7 @@
 #include <mach/io.h>
 
 static struct at91_ether_platform_data macb_pdata = {
-	.flags		= AT91SAM_ETHER_MII | AT91SAM_ETHER_FORCE_LINK,
+	.phy_flags	= PHYLIB_FORCE_LINK,
 	.phy_addr	= 4,
 };
 
diff --git a/arch/arm/boards/pm9263/init.c b/arch/arm/boards/pm9263/init.c
index 14e821f..486df9a 100644
--- a/arch/arm/boards/pm9263/init.c
+++ b/arch/arm/boards/pm9263/init.c
@@ -90,7 +90,7 @@ static void pm_add_device_nand(void)
 }
 
 static struct at91_ether_platform_data macb_pdata = {
-	.flags = AT91SAM_ETHER_RMII,
+	.is_rmii = 1,
 	.phy_addr = 0,
 };
 
diff --git a/arch/arm/boards/pm9g45/init.c b/arch/arm/boards/pm9g45/init.c
index 675ebe8..a79b128 100644
--- a/arch/arm/boards/pm9g45/init.c
+++ b/arch/arm/boards/pm9g45/init.c
@@ -114,7 +114,7 @@ static void __init pm9g45_add_device_usbh(void) {}
 #endif
 
 static struct at91_ether_platform_data macb_pdata = {
-	.flags = AT91SAM_ETHER_RMII,
+	.is_rmii = 1,
 	.phy_addr = 0,
 };
 
diff --git a/arch/arm/boards/qil-a9260/init.c b/arch/arm/boards/qil-a9260/init.c
index 8a12b17..3bec4e2 100644
--- a/arch/arm/boards/qil-a9260/init.c
+++ b/arch/arm/boards/qil-a9260/init.c
@@ -79,7 +79,7 @@ static void qil_a9260_add_device_mci(void) {}
 
 #ifdef CONFIG_CALAO_MB_QIL_A9260
 static struct at91_ether_platform_data macb_pdata = {
-	.flags		= AT91SAM_ETHER_RMII,
+	.is_rmii	= 1,
 	.phy_addr	= -1,
 };
 
diff --git a/arch/arm/boards/tny-a926x/init.c b/arch/arm/boards/tny-a926x/init.c
index 270becf..98f1d2b 100644
--- a/arch/arm/boards/tny-a926x/init.c
+++ b/arch/arm/boards/tny-a926x/init.c
@@ -114,7 +114,7 @@ static void tny_a9260_add_device_nand(void)
 
 #ifdef CONFIG_DRIVER_NET_MACB
 static struct at91_ether_platform_data macb_pdata = {
-	.flags		= AT91SAM_ETHER_RMII,
+	.is_rmii	= 1,
 	.phy_addr	= -1,
 };
 
diff --git a/arch/arm/boards/usb-a926x/init.c b/arch/arm/boards/usb-a926x/init.c
index e57591b..8f57aa4 100644
--- a/arch/arm/boards/usb-a926x/init.c
+++ b/arch/arm/boards/usb-a926x/init.c
@@ -114,7 +114,7 @@ static void usb_a9260_add_device_nand(void)
 }
 
 static struct at91_ether_platform_data macb_pdata = {
-	.flags		= AT91SAM_ETHER_RMII,
+	.is_rmii	= 1,
 	.phy_addr	= -1,
 };
 
diff --git a/arch/arm/mach-at91/at91rm9200_devices.c b/arch/arm/mach-at91/at91rm9200_devices.c
index a676436..4751664 100644
--- a/arch/arm/mach-at91/at91rm9200_devices.c
+++ b/arch/arm/mach-at91/at91rm9200_devices.c
@@ -91,7 +91,7 @@ void __init at91_add_device_eth(int id, struct at91_ether_platform_data *data)
 	at91_set_A_periph(AT91_PIN_PA8, 0);	/* ETXEN */
 	at91_set_A_periph(AT91_PIN_PA7, 0);	/* ETXCK_EREFCK */
 
-	if (!(data->flags & AT91SAM_ETHER_RMII)) {
+	if (!data->is_rmii) {
 		at91_set_B_periph(AT91_PIN_PB19, 0);	/* ERXCK */
 		at91_set_B_periph(AT91_PIN_PB18, 0);	/* ECOL */
 		at91_set_B_periph(AT91_PIN_PB17, 0);	/* ERXDV */
diff --git a/arch/arm/mach-at91/at91sam9260_devices.c b/arch/arm/mach-at91/at91sam9260_devices.c
index eedb495..4e67126 100644
--- a/arch/arm/mach-at91/at91sam9260_devices.c
+++ b/arch/arm/mach-at91/at91sam9260_devices.c
@@ -90,7 +90,7 @@ void at91_add_device_eth(int id, struct at91_ether_platform_data *data)
 	at91_set_A_periph(AT91_PIN_PA21, 0);	/* EMDIO */
 	at91_set_A_periph(AT91_PIN_PA20, 0);	/* EMDC */
 
-	if (!(data->flags & AT91SAM_ETHER_RMII)) {
+	if (!data->is_rmii) {
 		at91_set_B_periph(AT91_PIN_PA28, 0);	/* ECRS */
 		at91_set_B_periph(AT91_PIN_PA29, 0);	/* ECOL */
 		at91_set_B_periph(AT91_PIN_PA25, 0);	/* ERX2 */
diff --git a/arch/arm/mach-at91/at91sam9263_devices.c b/arch/arm/mach-at91/at91sam9263_devices.c
index 45fbb9b..be89bc6 100644
--- a/arch/arm/mach-at91/at91sam9263_devices.c
+++ b/arch/arm/mach-at91/at91sam9263_devices.c
@@ -97,7 +97,7 @@ void at91_add_device_eth(int id, struct at91_ether_platform_data *data)
 	at91_set_A_periph(AT91_PIN_PE30, 0);	/* EMDIO */
 	at91_set_A_periph(AT91_PIN_PE29, 0);	/* EMDC */
 
-	if (!(data->flags & AT91SAM_ETHER_RMII)) {
+	if (!data->is_rmii) {
 		at91_set_A_periph(AT91_PIN_PE22, 0);	/* ECRS */
 		at91_set_B_periph(AT91_PIN_PC26, 0);	/* ECOL */
 		at91_set_B_periph(AT91_PIN_PC22, 0);	/* ERX2 */
diff --git a/arch/arm/mach-at91/at91sam9g45_devices.c b/arch/arm/mach-at91/at91sam9g45_devices.c
index 73bac9f..89d5689 100644
--- a/arch/arm/mach-at91/at91sam9g45_devices.c
+++ b/arch/arm/mach-at91/at91sam9g45_devices.c
@@ -73,7 +73,7 @@ void at91_add_device_eth(int id, struct at91_ether_platform_data *data)
 	at91_set_A_periph(AT91_PIN_PA19, 0);	/* EMDIO */
 	at91_set_A_periph(AT91_PIN_PA18, 0);	/* EMDC */
 
-	if (!(data->flags & AT91SAM_ETHER_RMII)) {
+	if (!data->is_rmii) {
 		at91_set_B_periph(AT91_PIN_PA29, 0);	/* ECRS */
 		at91_set_B_periph(AT91_PIN_PA30, 0);	/* ECOL */
 		at91_set_B_periph(AT91_PIN_PA8,  0);	/* ERX2 */
diff --git a/arch/arm/mach-at91/at91sam9x5_devices.c b/arch/arm/mach-at91/at91sam9x5_devices.c
index 0909461..bfb22fd 100644
--- a/arch/arm/mach-at91/at91sam9x5_devices.c
+++ b/arch/arm/mach-at91/at91sam9x5_devices.c
@@ -85,7 +85,7 @@ void at91_add_device_eth(int id, struct at91_ether_platform_data *data)
 		at91_set_A_periph(AT91_PIN_PB5,  0);	/* EMDIO */
 		at91_set_A_periph(AT91_PIN_PB6,  0);	/* EMDC */
 
-		if (!(data->flags & AT91SAM_ETHER_RMII)) {
+		if (!data->is_rmii) {
 			at91_set_A_periph(AT91_PIN_PB16, 0);	/* ECRS */
 			at91_set_A_periph(AT91_PIN_PB17, 0);	/* ECOL */
 			at91_set_A_periph(AT91_PIN_PB13, 0);	/* ERX2 */
@@ -98,7 +98,7 @@ void at91_add_device_eth(int id, struct at91_ether_platform_data *data)
 		break;
 	case 1:
 		start = AT91SAM9X5_BASE_EMAC1;
-		if (!(data->flags & AT91SAM_ETHER_RMII))
+		if (!data->is_rmii)
 			pr_warn("AT91: Only RMII available on interface macb%d.\n", id);
 
 		/* Pins used for RMII */
diff --git a/arch/arm/mach-at91/include/mach/board.h b/arch/arm/mach-at91/include/mach/board.h
index dcea9f3..433915f 100644
--- a/arch/arm/mach-at91/include/mach/board.h
+++ b/arch/arm/mach-at91/include/mach/board.h
@@ -63,14 +63,13 @@ struct atmel_nand_data {
 void at91_add_device_nand(struct atmel_nand_data *data);
 
  /* Ethernet (EMAC & MACB) */
-#define AT91SAM_ETHER_MII		(0 << 0)
-#define AT91SAM_ETHER_RMII		(1 << 0)
-#define AT91SAM_ETHER_FORCE_LINK	(1 << 1)
-#define AT91SAM_ETX2_ETX3_ALTERNATIVE	(1 << 2)
+#define AT91SAM_ETX2_ETX3_ALTERNATIVE	(1 << 0)
 
 struct at91_ether_platform_data {
+	unsigned int phy_flags;
 	unsigned int flags;
 	int phy_addr;
+	int is_rmii;
 	int (*get_ethaddr)(struct eth_device*, unsigned char *adr);
 };
 
diff --git a/drivers/net/at91_ether.c b/drivers/net/at91_ether.c
index 90fabab..f6ce0a1 100644
--- a/drivers/net/at91_ether.c
+++ b/drivers/net/at91_ether.c
@@ -346,7 +346,7 @@ static int at91_ether_probe(struct device_d *dev)
 
 	mac_cfg |= AT91_EMAC_CLK_DIV32 | AT91_EMAC_BIG;
 
-	if (pdata->flags & AT91SAM_ETHER_RMII) {
+	if (pdata->is_rmii) {
 		ether_dev->interface = PHY_INTERFACE_MODE_RGMII;
 		mac_cfg |= AT91_EMAC_RMII;
 	} else {
diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index d25fb79..1d37251 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -444,13 +444,12 @@ static int macb_probe(struct device_d *dev)
 	macb->miibus.priv = macb;
 	macb->miibus.parent = dev;
 
-	if (pdata->flags & AT91SAM_ETHER_RMII)
+	if (pdata->is_rmii)
 		macb->interface = PHY_INTERFACE_MODE_RMII;
 	else
 		macb->interface = PHY_INTERFACE_MODE_MII;
 
-	macb->phy_flags = pdata->flags & AT91SAM_ETHER_FORCE_LINK ?
-					PHYLIB_FORCE_LINK : 0;
+	macb->phy_flags = pdata->phy_flags;
 
 	macb->rx_buffer = dma_alloc_coherent(CFG_MACB_RX_BUFFER_SIZE);
 	macb->rx_ring = dma_alloc_coherent(CFG_MACB_RX_RING_SIZE * sizeof(struct macb_dma_desc));
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Fri Nov 16 12:53:55 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri, 16 Nov 2012 18:53:55 +0100
Subject: [PATCH 0/7 v2] at91sam9 add watchdog support with keep alive
Message-ID: <20121116175355.GB8327@game.jcrosoft.org>

HI,

	v2:

	 found a bug on MMU platform the watchdodog need to init before the
	 poll register on non-MMU it work fine

	 btw register the wdt drvier as coredevice asame as the device

	The following patch series add the at91sam9 watchdog present on 
	sam9260/9g20/9261/9g10/9g45/9x5

	and introdudce the kep a live support so we can reset the watchdog via
	poller

The following changes since commit 281b927f44ae94280648714e3587efa4419f6ce3:

  Release v2012.11.0 (2012-11-16 13:54:49 +0100)

are available in the git repository at:

  git://git.jcrosoft.org/barebox.git delivery/at91sam9_wdt

for you to fetch changes up to 4b4830060956d58f924fc14020609ba5c4fe44ca:

  at91sam9x5: add wathdog support (2012-11-15 04:20:49 +0800)

----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (7):
      watchdog: add keep alive support
      watchdog: add at91sam9 watchdog support
      at91sam9260/9g20: add wathdog support
      at91sam9261/9g10: add wathdog support
      at91sam9263: add wathdog support
      at91sam9g45: add wathdog support
      at91sam9x5: add wathdog support

 arch/arm/mach-at91/at91sam9260_devices.c |   12 ++++++++++++
 arch/arm/mach-at91/at91sam9261_devices.c |   12 ++++++++++++
 arch/arm/mach-at91/at91sam9263_devices.c |   11 +++++++++++
 arch/arm/mach-at91/at91sam9g45_devices.c |   12 ++++++++++++
 arch/arm/mach-at91/at91sam9x5_devices.c  |   12 ++++++++++++
 drivers/watchdog/Kconfig                 |    8 ++++++++
 drivers/watchdog/Makefile                |    1 +
 drivers/watchdog/at91sam9_wdt.c          |  131 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/watchdog/at91sam9_wdt.h          |   38 ++++++++++++++++++++++++++++++++++++++
 drivers/watchdog/wd_core.c               |   21 +++++++++++++++++++++
 include/watchdog.h                       |    2 ++
 11 files changed, 260 insertions(+)
 create mode 100644 drivers/watchdog/at91sam9_wdt.c
 create mode 100644 drivers/watchdog/at91sam9_wdt.h

Best Regards,
J.


From plagnioj at jcrosoft.com  Fri Nov 16 12:55:41 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri, 16 Nov 2012 18:55:41 +0100
Subject: [PATCH 3/7] at91sam9260/9g20: add wathdog support
In-Reply-To: <1353088545-19406-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121116175355.GB8327@game.jcrosoft.org>
 <1353088545-19406-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1353088545-19406-3-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/mach-at91/at91sam9260_devices.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/mach-at91/at91sam9260_devices.c b/arch/arm/mach-at91/at91sam9260_devices.c
index 9c9534e..e781de0 100644
--- a/arch/arm/mach-at91/at91sam9260_devices.c
+++ b/arch/arm/mach-at91/at91sam9260_devices.c
@@ -10,6 +10,7 @@
  *
  */
 #include <common.h>
+#include <init.h>
 #include <sizes.h>
 #include <asm/armlinux.h>
 #include <asm/hardware.h>
@@ -356,3 +357,14 @@ void at91_add_device_mci(short mmc_id, struct atmel_mci_platform_data *data)
 #else
 void at91_add_device_mci(short mmc_id, struct atmel_mci_platform_data *data) {}
 #endif
+
+#ifdef CONFIG_WATCHDOG_AT91SAM9X
+static int at91_add_device_watchdog(void)
+{
+	add_generic_device("at91sam9_wdt", DEVICE_ID_SINGLE, NULL,
+		AT91_WDT + AT91_BASE_SYS, 16, IORESOURCE_MEM, NULL);
+
+	return 0;
+}
+coredevice_initcall(at91_add_device_watchdog);
+#endif
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Fri Nov 16 12:55:43 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri, 16 Nov 2012 18:55:43 +0100
Subject: [PATCH 5/7] at91sam9263: add wathdog support
In-Reply-To: <1353088545-19406-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121116175355.GB8327@game.jcrosoft.org>
 <1353088545-19406-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1353088545-19406-5-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/mach-at91/at91sam9263_devices.c |   11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/arch/arm/mach-at91/at91sam9263_devices.c b/arch/arm/mach-at91/at91sam9263_devices.c
index e686480..0386d79 100644
--- a/arch/arm/mach-at91/at91sam9263_devices.c
+++ b/arch/arm/mach-at91/at91sam9263_devices.c
@@ -10,6 +10,7 @@
  *
  */
 #include <common.h>
+#include <init.h>
 #include <sizes.h>
 #include <asm/armlinux.h>
 #include <asm/hardware.h>
@@ -351,3 +352,13 @@ void at91_add_device_mci(short mmc_id, struct atmel_mci_platform_data *data)
 void at91_add_device_mci(short mmc_id, struct atmel_mci_platform_data *data) {}
 #endif
 
+#ifdef CONFIG_WATCHDOG_AT91SAM9X
+static int at91_add_device_watchdog(void)
+{
+	add_generic_device("at91sam9_wdt", DEVICE_ID_SINGLE, NULL,
+		AT91_WDT + AT91_BASE_SYS, 16, IORESOURCE_MEM, NULL);
+
+	return 0;
+}
+coredevice_initcall(at91_add_device_watchdog);
+#endif
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Fri Nov 16 12:55:42 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri, 16 Nov 2012 18:55:42 +0100
Subject: [PATCH 4/7] at91sam9261/9g10: add wathdog support
In-Reply-To: <1353088545-19406-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121116175355.GB8327@game.jcrosoft.org>
 <1353088545-19406-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1353088545-19406-4-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/mach-at91/at91sam9261_devices.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/mach-at91/at91sam9261_devices.c b/arch/arm/mach-at91/at91sam9261_devices.c
index 0091e2d..5784e13 100644
--- a/arch/arm/mach-at91/at91sam9261_devices.c
+++ b/arch/arm/mach-at91/at91sam9261_devices.c
@@ -10,6 +10,7 @@
  *
  */
 #include <common.h>
+#include <init.h>
 #include <sizes.h>
 #include <asm/armlinux.h>
 #include <asm/hardware.h>
@@ -257,3 +258,14 @@ void at91_add_device_mci(short mmc_id, struct atmel_mci_platform_data *data)
 #else
 void at91_add_device_mci(short mmc_id, struct atmel_mci_platform_data *data) {}
 #endif
+
+#ifdef CONFIG_WATCHDOG_AT91SAM9X
+static int at91_add_device_watchdog(void)
+{
+	add_generic_device("at91sam9_wdt", DEVICE_ID_SINGLE, NULL,
+		AT91_WDT + AT91_BASE_SYS, 16, IORESOURCE_MEM, NULL);
+
+	return 0;
+}
+coredevice_initcall(at91_add_device_watchdog);
+#endif
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Fri Nov 16 12:55:45 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri, 16 Nov 2012 18:55:45 +0100
Subject: [PATCH 7/7] at91sam9x5: add wathdog support
In-Reply-To: <1353088545-19406-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121116175355.GB8327@game.jcrosoft.org>
 <1353088545-19406-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1353088545-19406-7-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/mach-at91/at91sam9x5_devices.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/mach-at91/at91sam9x5_devices.c b/arch/arm/mach-at91/at91sam9x5_devices.c
index 26a380d..27e9ec9 100644
--- a/arch/arm/mach-at91/at91sam9x5_devices.c
+++ b/arch/arm/mach-at91/at91sam9x5_devices.c
@@ -10,6 +10,7 @@
  *
  */
 #include <common.h>
+#include <init.h>
 #include <sizes.h>
 #include <asm/armlinux.h>
 #include <asm/hardware.h>
@@ -234,3 +235,14 @@ resource_size_t __init at91_configure_usart3(unsigned pins)
 	return AT91SAM9X5_BASE_USART3;
 }
 #endif
+
+#ifdef CONFIG_WATCHDOG_AT91SAM9X
+static int at91_add_device_watchdog(void)
+{
+	add_generic_device("at91sam9_wdt", DEVICE_ID_SINGLE, NULL,
+		AT91_WDT + AT91_BASE_SYS, 16, IORESOURCE_MEM, NULL);
+
+	return 0;
+}
+coredevice_initcall(at91_add_device_watchdog);
+#endif
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Fri Nov 16 12:55:44 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri, 16 Nov 2012 18:55:44 +0100
Subject: [PATCH 6/7] at91sam9g45: add wathdog support
In-Reply-To: <1353088545-19406-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121116175355.GB8327@game.jcrosoft.org>
 <1353088545-19406-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1353088545-19406-6-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/mach-at91/at91sam9g45_devices.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/mach-at91/at91sam9g45_devices.c b/arch/arm/mach-at91/at91sam9g45_devices.c
index 22b455e..38593fc 100644
--- a/arch/arm/mach-at91/at91sam9g45_devices.c
+++ b/arch/arm/mach-at91/at91sam9g45_devices.c
@@ -10,6 +10,7 @@
  *
  */
 #include <common.h>
+#include <init.h>
 #include <sizes.h>
 #include <asm/armlinux.h>
 #include <asm/hardware.h>
@@ -324,3 +325,14 @@ void at91_add_device_spi(int spi_id, struct at91_spi_platform_data *pdata)
 #else
 void at91_add_device_spi(int spi_id, struct at91_spi_platform_data *pdata) {}
 #endif
+
+#ifdef CONFIG_WATCHDOG_AT91SAM9X
+static int at91_add_device_watchdog(void)
+{
+	add_generic_device("at91sam9_wdt", DEVICE_ID_SINGLE, NULL,
+		AT91_WDT + AT91_BASE_SYS, 16, IORESOURCE_MEM, NULL);
+
+	return 0;
+}
+coredevice_initcall(at91_add_device_watchdog);
+#endif
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Fri Nov 16 12:55:39 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri, 16 Nov 2012 18:55:39 +0100
Subject: [PATCH 1/7] watchdog: add keep alive support
In-Reply-To: <20121116175355.GB8327@game.jcrosoft.org>
References: <20121116175355.GB8327@game.jcrosoft.org>
Message-ID: <1353088545-19406-1-git-send-email-plagnioj@jcrosoft.com>

this will allow to ping the watchdog via poller

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/watchdog/Kconfig   |    1 +
 drivers/watchdog/wd_core.c |   21 +++++++++++++++++++++
 include/watchdog.h         |    2 ++
 3 files changed, 24 insertions(+)

diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 8fdc7a5..21480a1 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -1,5 +1,6 @@
 menuconfig WATCHDOG
 	bool "Watchdog support              "
+	select GENERIC_POLLER
 	help
 	  Many platforms support a watchdog to keep track of a working machine.
 	  This framework provides routines to handle these watchdogs.
diff --git a/drivers/watchdog/wd_core.c b/drivers/watchdog/wd_core.c
index 3d0cfc6..a1b9e28 100644
--- a/drivers/watchdog/wd_core.c
+++ b/drivers/watchdog/wd_core.c
@@ -17,18 +17,39 @@
 #include <errno.h>
 #include <linux/ctype.h>
 #include <watchdog.h>
+#include <poller.h>
 
 /*
  * Note: this simple framework supports one watchdog only.
  */
 static struct watchdog *watchdog;
 
+static void watchdog_poller_func(struct poller_struct *poller)
+{
+	watchdog->keep_alive(watchdog);
+}
+
+static struct poller_struct watchdog_poller = {
+	.func = watchdog_poller_func,
+};
+
 int watchdog_register(struct watchdog *wd)
 {
 	if (watchdog != NULL)
 		return -EBUSY;
 
 	watchdog = wd;
+
+	if (watchdog->keep_alive) {
+		int ret;
+
+		ret = poller_register(&watchdog_poller);
+		if (ret) {
+			watchdog = NULL;
+			return ret;
+		}
+	}
+
 	return 0;
 }
 EXPORT_SYMBOL(watchdog_register);
diff --git a/include/watchdog.h b/include/watchdog.h
index 3e2d08e..d5ecf2f 100644
--- a/include/watchdog.h
+++ b/include/watchdog.h
@@ -13,8 +13,10 @@
 #ifndef INCLUDE_WATCHDOG_H
 # define INCLUDE_WATCHDOG_H
 
+
 struct watchdog {
 	int (*set_timeout)(struct watchdog *, unsigned);
+	void (*keep_alive)(struct watchdog *);
 };
 
 int watchdog_register(struct watchdog *);
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Fri Nov 16 12:55:40 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri, 16 Nov 2012 18:55:40 +0100
Subject: [PATCH 2/7] watchdog: add at91sam9 watchdog support
In-Reply-To: <1353088545-19406-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121116175355.GB8327@game.jcrosoft.org>
 <1353088545-19406-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1353088545-19406-2-git-send-email-plagnioj@jcrosoft.com>

with keep alive support

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/watchdog/Kconfig        |    7 +++
 drivers/watchdog/Makefile       |    1 +
 drivers/watchdog/at91sam9_wdt.c |  131 +++++++++++++++++++++++++++++++++++++++
 drivers/watchdog/at91sam9_wdt.h |   38 ++++++++++++
 4 files changed, 177 insertions(+)
 create mode 100644 drivers/watchdog/at91sam9_wdt.c
 create mode 100644 drivers/watchdog/at91sam9_wdt.h

diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 21480a1..5bd1083 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -7,6 +7,13 @@ menuconfig WATCHDOG
 
 if WATCHDOG
 
+config WATCHDOG_AT91SAM9X
+	tristate "AT91SAM9X / AT91CAP9 watchdog"
+	depends on ARCH_AT91
+	help
+	  Watchdog timer embedded into AT91SAM9X and AT91CAP9 chips. This will
+	  reboot your system when the timeout is reached.
+
 config WATCHDOG_MXS28
 	bool "i.MX28"
 	depends on ARCH_IMX28
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index b29103b..4e863a5 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -1,2 +1,3 @@
 obj-$(CONFIG_WATCHDOG) += wd_core.o
+obj-$(CONFIG_WATCHDOG_AT91SAM9X) += at91sam9_wdt.o
 obj-$(CONFIG_WATCHDOG_MXS28) += im28wd.o
diff --git a/drivers/watchdog/at91sam9_wdt.c b/drivers/watchdog/at91sam9_wdt.c
new file mode 100644
index 0000000..203d83a
--- /dev/null
+++ b/drivers/watchdog/at91sam9_wdt.c
@@ -0,0 +1,131 @@
+/*
+ * (c) 2012 Juergen Beisert <kernel at pengutronix.de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Note: this driver works for the i.MX28 SoC. It might work for the
+ * i.MX23 Soc as well, but is not tested yet.
+ */
+
+#include <common.h>
+#include <init.h>
+#include <io.h>
+#include <errno.h>
+#include <malloc.h>
+#include <watchdog.h>
+
+#include "at91sam9_wdt.h"
+
+struct at91sam9_wdt {
+	struct watchdog wdt;
+	void __iomem *base;
+};
+
+#define to_at91sam9_wdt(h) container_of(h, struct at91sam9_wdt, wdt)
+
+#define wdt_read(at91wdt, field) \
+	__raw_readl(at91wdt->base + field)
+#define wdt_write(at91wdt, field, val) \
+	__raw_writel((val), at91wdt->base + field)
+
+static void at91sam9_wdt_keep_alive(struct watchdog *wdt)
+{
+	struct at91sam9_wdt *at91wdt = to_at91sam9_wdt(wdt);
+
+	wdt_write(at91wdt, AT91_WDT_CR, AT91_WDT_KEY | AT91_WDT_WDRSTT);
+}
+
+static int at91sam9_wdt_settimeout(struct watchdog *wdt, unsigned int timeout)
+{
+	struct at91sam9_wdt *at91wdt = to_at91sam9_wdt(wdt);
+	unsigned int reg;
+	unsigned int mr;
+
+	/* Check if disabled */
+	mr = wdt_read(at91wdt, AT91_WDT_MR);
+	if (mr & AT91_WDT_WDDIS) {
+		pr_err("sorry, watchdog is disabled\n");
+		return -EIO;
+	}
+
+	if (!timeout) {
+		wdt_write(at91wdt, AT91_WDT_MR, AT91_WDT_WDDIS);
+		return 0;
+	}
+
+	/*
+	 * All counting occurs at SLOW_CLOCK / 128 = 256 Hz
+	 *
+	 * Since WDV is a 12-bit counter, the maximum period is
+	 * 4096 / 256 = 16 seconds.
+	 */
+	reg = AT91_WDT_WDRSTEN	/* causes watchdog reset */
+		/* | AT91_WDT_WDRPROC	causes processor reset only */
+		| AT91_WDT_WDDBGHLT	/* disabled in debug mode */
+		| AT91_WDT_WDD		/* restart at any time */
+		| (timeout & AT91_WDT_WDV);  /* timer value */
+	wdt_write(at91wdt, AT91_WDT_MR, reg);
+
+	return 0;
+}
+
+static int at91sam9_wdt_probe(struct device_d *dev)
+{
+	struct at91sam9_wdt *priv;
+	struct watchdog *wdt;
+	int ret;
+	unsigned int mr;
+
+	priv = xzalloc(sizeof(struct at91sam9_wdt));
+	priv->base = dev_request_mem_region(dev, 0);
+	wdt = &priv->wdt;
+
+	wdt->set_timeout = at91sam9_wdt_settimeout;
+	wdt->keep_alive = at91sam9_wdt_keep_alive;
+
+	/* Check if disabled */
+	mr = wdt_read(priv, AT91_WDT_MR);
+	if (mr & AT91_WDT_WDDIS) {
+		dev_err(dev, "sorry, watchdog is disabled\n");
+		ret = -EIO;
+		goto err;
+	}
+
+	ret = watchdog_register(wdt);
+	if (ret != 0)
+		goto err;
+
+	dev->priv = priv;
+	return 0;
+
+err:
+	free(priv);
+	return ret;
+}
+
+static void at91sam9_wdt_remove(struct device_d *dev)
+{
+	struct at91sam9_wdt *priv= dev->priv;
+	watchdog_deregister(&priv->wdt);
+	free(priv);
+}
+
+static struct driver_d at91sam9_wdt_driver = {
+	.name	= "at91sam9_wdt",
+	.probe	= at91sam9_wdt_probe,
+	.remove = at91sam9_wdt_remove,
+};
+
+static int at91sam9_wdt_init(void)
+{
+	return platform_driver_register(&at91sam9_wdt_driver);
+}
+coredevice_initcall(at91sam9_wdt_init);
diff --git a/drivers/watchdog/at91sam9_wdt.h b/drivers/watchdog/at91sam9_wdt.h
new file mode 100644
index 0000000..2b68c1a
--- /dev/null
+++ b/drivers/watchdog/at91sam9_wdt.h
@@ -0,0 +1,38 @@
+/*
+ * drivers/watchdog/at91sam9_wdt.h
+ *
+ * Copyright (C) 2007 Andrew Victor
+ * Copyright (C) 2007 Atmel Corporation.
+ *
+ * Watchdog Timer (WDT) - System peripherals regsters.
+ * Based on AT91SAM9261 datasheet revision D.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef AT91_WDT_H
+#define AT91_WDT_H
+
+#define AT91_WDT_CR		0x00			/* Watchdog Control Register */
+#define		AT91_WDT_WDRSTT		(1    << 0)		/* Restart */
+#define		AT91_WDT_KEY		(0xa5 << 24)		/* KEY Password */
+
+#define AT91_WDT_MR		0x04			/* Watchdog Mode Register */
+#define		AT91_WDT_WDV		(0xfff << 0)		/* Counter Value */
+#define		AT91_WDT_WDFIEN		(1     << 12)		/* Fault Interrupt Enable */
+#define		AT91_WDT_WDRSTEN	(1     << 13)		/* Reset Processor */
+#define		AT91_WDT_WDRPROC	(1     << 14)		/* Timer Restart */
+#define		AT91_WDT_WDDIS		(1     << 15)		/* Watchdog Disable */
+#define		AT91_WDT_WDD		(0xfff << 16)		/* Delta Value */
+#define		AT91_WDT_WDDBGHLT	(1     << 28)		/* Debug Halt */
+#define		AT91_WDT_WDIDLEHLT	(1     << 29)		/* Idle Halt */
+
+#define AT91_WDT_SR		0x08			/* Watchdog Status Register */
+#define		AT91_WDT_WDUNF		(1 << 0)		/* Watchdog Underflow */
+#define		AT91_WDT_WDERR		(1 << 1)		/* Watchdog Error */
+
+
+#endif
-- 
1.7.10.4



From rpjday at crashcourse.ca  Fri Nov 16 14:18:54 2012
From: rpjday at crashcourse.ca (Robert P. J. Day)
Date: Fri, 16 Nov 2012 14:18:54 -0500 (EST)
Subject: after "git pull", building for beagle complains about missing "lzop"
Message-ID: <alpine.DEB.2.02.1211161416260.30355@oneiric>


  after i "git pull"ed all the recent updates and tried to rebuild
from scratch for my beagle xm, the barebox build failed with:

  OBJCOPY barebox.bin
  LDS     arch/arm/pbl/zbarebox.lds
  LZO     arch/arm/pbl/piggy.lzo
/bin/sh: lzop: command not found
make[2]: *** [arch/arm/pbl/piggy.lzo] Error 1
make[1]: *** [zbarebox.bin] Error 2
make: *** [_all] Error 2
$

  i've never had "lzop" installed on this system before and never had
a complaint, so i'm assuming something about the default config has
changed that suddenly requires lzop, is that correct?

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================


From plagnioj at jcrosoft.com  Fri Nov 16 14:57:03 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri, 16 Nov 2012 20:57:03 +0100
Subject: after "git pull", building for beagle complains about missing
 "lzop"
In-Reply-To: <alpine.DEB.2.02.1211161416260.30355@oneiric>
References: <alpine.DEB.2.02.1211161416260.30355@oneiric>
Message-ID: <20121116195703.GC8327@game.jcrosoft.org>

On 14:18 Fri 16 Nov     , Robert P. J. Day wrote:
> 
>   after i "git pull"ed all the recent updates and tried to rebuild
> from scratch for my beagle xm, the barebox build failed with:
> 
>   OBJCOPY barebox.bin
>   LDS     arch/arm/pbl/zbarebox.lds
>   LZO     arch/arm/pbl/piggy.lzo
> /bin/sh: lzop: command not found
> make[2]: *** [arch/arm/pbl/piggy.lzo] Error 1
> make[1]: *** [zbarebox.bin] Error 2
> make: *** [_all] Error 2
> $
> 
>   i've never had "lzop" installed on this system before and never had
> a complaint, so i'm assuming something about the default config has
> changed that suddenly requires lzop, is that correct?

yes because we now compress barebox
as you see in the log LZO

Best Regards,
J.


From rpjday at crashcourse.ca  Fri Nov 16 15:01:41 2012
From: rpjday at crashcourse.ca (Robert P. J. Day)
Date: Fri, 16 Nov 2012 15:01:41 -0500 (EST)
Subject: after "git pull", building for beagle complains about missing
 "lzop"
In-Reply-To: <20121116195703.GC8327@game.jcrosoft.org>
References: <alpine.DEB.2.02.1211161416260.30355@oneiric>
 <20121116195703.GC8327@game.jcrosoft.org>
Message-ID: <alpine.DEB.2.02.1211161501001.5043@oneiric>

On Fri, 16 Nov 2012, Jean-Christophe PLAGNIOL-VILLARD wrote:

> On 14:18 Fri 16 Nov     , Robert P. J. Day wrote:
> >
> >   after i "git pull"ed all the recent updates and tried to rebuild
> > from scratch for my beagle xm, the barebox build failed with:
> >
> >   OBJCOPY barebox.bin
> >   LDS     arch/arm/pbl/zbarebox.lds
> >   LZO     arch/arm/pbl/piggy.lzo
> > /bin/sh: lzop: command not found
> > make[2]: *** [arch/arm/pbl/piggy.lzo] Error 1
> > make[1]: *** [zbarebox.bin] Error 2
> > make: *** [_all] Error 2
> > $
> >
> >   i've never had "lzop" installed on this system before and never had
> > a complaint, so i'm assuming something about the default config has
> > changed that suddenly requires lzop, is that correct?
>
> yes because we now compress barebox
> as you see in the log LZO

  yes, i did notice that shortly thereafter, should have perused the
log first before asking.

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================


From plagnioj at jcrosoft.com  Fri Nov 16 15:16:04 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri, 16 Nov 2012 21:16:04 +0100
Subject: [PATCH 0/2] m25p80: re-import it againt mtd_add_host
In-Reply-To: <20121115101150.GF31820@game.jcrosoft.org>
References: <20121031120122.GF29599@game.jcrosoft.org>
 <20121115101150.GF31820@game.jcrosoft.org>
Message-ID: <20121116201604.GD8327@game.jcrosoft.org>

HI,

	just retested on master on sam9x5ek work fine

	can you check on sabrelite too

Best Regards,
J.
On 11:11 Thu 15 Nov     , Jean-Christophe PLAGNIOL-VILLARD wrote:
> ping
> 
> work on next
> On 13:01 Wed 31 Oct     , Jean-Christophe PLAGNIOL-VILLARD wrote:
> > Hi,
> > 
> > 	so we now create the cdev via mtd
> > 
> > 	This will also simplify sync with linux
> > 
> > 	to avoid the m25p8000 or m25p00 the cdev is still named name m25p and the
> > 	drivers m25p80
> > 
> > 	sync with linux too
> > 
> > 	this patch series is agianst mtd_dataflash support
> > 
> > The following changes since commit 9428c386f876fa3a8871eeea4725a805cea5c367:
> > 
> >   mtd: add dataflash support (2012-10-31 04:48:39 +0800)
> > 
> > are available in the git repository at:
> > 
> >   git://git.jcrosoft.org/barebox.git delivery/m25p80
> > 
> > for you to fetch changes up to 35b8b98230dbcfe25973d5ed52a874027b4f3f05:
> > 
> >   m25p80: sync flash support with the kernel (2012-10-31 04:51:08 +0800)
> > 
> > ----------------------------------------------------------------
> > Jean-Christophe PLAGNIOL-VILLARD (2):
> >       m25p80: re-import it againt mtd_add_host
> >       m25p80: sync flash support with the kernel
> > 
> >  arch/arm/boards/freescale-mx6-sabrelite/board.c |    2 +-
> >  drivers/mtd/devices/Kconfig                     |   27 ++++++++++++
> >  drivers/mtd/devices/Makefile                    |    1 +
> >  drivers/{nor => mtd/devices}/m25p80.c           |  512 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------------
> >  drivers/nor/Kconfig                             |   27 ------------
> >  drivers/nor/Makefile                            |    1 -
> >  drivers/nor/m25p80.h                            |   84 ------------------------------------
> >  include/linux/mtd/cfi.h                         |   65 ++++++++++++++++++++++++++++
> >  8 files changed, 371 insertions(+), 348 deletions(-)
> >  rename drivers/{nor => mtd/devices}/m25p80.c (65%)
> >  delete mode 100644 drivers/nor/m25p80.h
> >  create mode 100644 include/linux/mtd/cfi.h
> > 
> > Best Regards,
> > J.
> > 
> > _______________________________________________
> > barebox mailing list
> > barebox at lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/barebox
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox


From plagnioj at jcrosoft.com  Fri Nov 16 15:17:23 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri, 16 Nov 2012 21:17:23 +0100
Subject: [PATCH 1/1] led-gpio: add bicolor led support
Message-ID: <1353097043-31250-1-git-send-email-plagnioj@jcrosoft.com>

those led can have 2 colors but one at a time otherwise they are black

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/led/Kconfig    |    4 ++++
 drivers/led/led-gpio.c |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 include/led.h          |   20 ++++++++++++++++++++
 3 files changed, 71 insertions(+)

diff --git a/drivers/led/Kconfig b/drivers/led/Kconfig
index 106093b..8ca6ab8 100644
--- a/drivers/led/Kconfig
+++ b/drivers/led/Kconfig
@@ -11,6 +11,10 @@ config LED_GPIO_RGB
 	bool "gpio rgb LED support"
 	depends on LED_GPIO
 
+config LED_GPIO_BICOLOR
+	bool "gpio bicolor LED support"
+	depends on LED_GPIO
+
 config LED_TRIGGERS
 	select POLLER
 	bool "LED triggers support"
diff --git a/drivers/led/led-gpio.c b/drivers/led/led-gpio.c
index 711146b..c78ef9e 100644
--- a/drivers/led/led-gpio.c
+++ b/drivers/led/led-gpio.c
@@ -52,6 +52,53 @@ void led_gpio_unregister(struct gpio_led *led)
 	led_unregister(&led->led);
 }
 
+#ifdef CONFIG_LED_GPIO_BICOLOR
+static void led_gpio_bicolor_set(struct led *led, unsigned int value)
+{
+	struct gpio_bicolor_led *bi = container_of(led, struct gpio_bicolor_led, led);
+	int al = bi->active_low;
+
+	switch (value) {
+	case 0:
+		gpio_direction_output(bi->gpio_c0, al);
+		gpio_direction_output(bi->gpio_c1, al);
+		break;
+	case 1:
+		gpio_direction_output(bi->gpio_c0, !al);
+		gpio_direction_output(bi->gpio_c1, al);
+		break;
+	case 2:
+		gpio_direction_output(bi->gpio_c0, al);
+		gpio_direction_output(bi->gpio_c1, !al);
+		break;
+	}
+}
+
+/**
+ * led_gpio_bicolor_register - register three gpios as a bicolor LED
+ * @param led	The gpio bicolor LED
+ *
+ * This function registers three gpios as a bicolor LED. led->gpio[rg]
+ * should be initialized to the gpios to control.
+ */
+int led_gpio_bicolor_register(struct gpio_bicolor_led *led)
+{
+	led->led.set = led_gpio_bicolor_set;
+	led->led.max_value = 2;
+
+	return led_register(&led->led);
+}
+
+/**
+ * led_gpio_bicolor_unregister - remove a gpio controlled bicolor LED from the framework
+ * @param led	The gpio LED
+ */
+void led_gpio_bicolor_unregister(struct gpio_bicolor_led *led)
+{
+	led_unregister(&led->led);
+}
+#endif
+
 #ifdef CONFIG_LED_GPIO_RGB
 
 static void led_gpio_rgb_set(struct led *led, unsigned int value)
diff --git a/include/led.h b/include/led.h
index 9ec1f0d..dd551fe 100644
--- a/include/led.h
+++ b/include/led.h
@@ -65,6 +65,12 @@ struct gpio_led {
 	struct led led;
 };
 
+struct gpio_bicolor_led {
+	int gpio_c0, gpio_c1;
+	bool active_low;
+	struct led led;
+};
+
 struct gpio_rgb_led {
 	int gpio_r, gpio_g, gpio_b;
 	bool active_low;
@@ -85,6 +91,20 @@ static inline void led_gpio_unregister(struct gpio_led *led)
 }
 #endif
 
+#ifdef CONFIG_LED_GPIO_BICOLOR
+int led_gpio_bicolor_register(struct gpio_bicolor_led *led);
+void led_gpio_bicolor_unregister(struct gpio_bicolor_led *led);
+#else
+static inline int led_gpio_bicolor_register(struct gpio_bicolor_led *led)
+{
+	return -ENOSYS;
+}
+
+static inline void led_gpio_bicolor_unregister(struct gpio_bicolor_led *led)
+{
+}
+#endif
+
 #ifdef CONFIG_LED_GPIO_RGB
 int led_gpio_rgb_register(struct gpio_rgb_led *led);
 void led_gpio_rgb_unregister(struct gpio_led *led);
-- 
1.7.10.4



From rpjday at crashcourse.ca  Fri Nov 16 15:27:55 2012
From: rpjday at crashcourse.ca (Robert P. J. Day)
Date: Fri, 16 Nov 2012 15:27:55 -0500 (EST)
Subject: are there still issues with building sandbox on x86_64?
Message-ID: <alpine.DEB.2.02.1211161526150.8404@oneiric>


  perusing the page in the wiki discussing sandbox:

http://wiki.barebox.org/doku.php?id=user:building

which mentions problems with sandbox on x86_64.  i've had no trouble
building and running sandbox under ubuntu on my 64-bit asus laptop.
are there specific known issues?  thanks.

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================


From chf.fritz at googlemail.com  Fri Nov 16 16:16:46 2012
From: chf.fritz at googlemail.com (Christoph Fritz)
Date: Fri, 16 Nov 2012 22:16:46 +0100
Subject: [PATCH] i.MX25 & 35 usb config bits : fix host power bit
Message-ID: <1353100606.3647.40.camel@mars>

This patch sets HPM (Host power mask bit) to bit 16 according to i.MX
Reference Manual. Falsely it was set to bit 8, but this controls pull-up
Impedance.

Reported-by: Michael Burkey <mdburkey at gmail.com>
Signed-off-by: Christoph Fritz <chf.fritz at googlemail.com>
---
 arch/arm/mach-imx/include/mach/usb.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mach-imx/include/mach/usb.h b/arch/arm/mach-imx/include/mach/usb.h
index 9244989..0a88e7f 100644
--- a/arch/arm/mach-imx/include/mach/usb.h
+++ b/arch/arm/mach-imx/include/mach/usb.h
@@ -4,7 +4,7 @@
 /* configuration bits for i.MX25 and i.MX35 */
 #define MX35_H1_SIC_SHIFT	21
 #define MX35_H1_SIC_MASK	(0x3 << MX35_H1_SIC_SHIFT)
-#define MX35_H1_PM_BIT		(1 << 8)
+#define MX35_H1_PM_BIT		(1 << 16)
 #define MX35_H1_IPPUE_UP_BIT	(1 << 7)
 #define MX35_H1_IPPUE_DOWN_BIT	(1 << 6)
 #define MX35_H1_TLL_BIT		(1 << 5)
-- 
1.7.10.4





From rpjday at crashcourse.ca  Fri Nov 16 17:45:38 2012
From: rpjday at crashcourse.ca (Robert P. J. Day)
Date: Fri, 16 Nov 2012 17:45:38 -0500 (EST)
Subject: [PATCH] bareboxenv.c: simple grammatical fix
Message-ID: <alpine.DEB.2.02.1211161745310.10167@oneiric>


Signed-off-by: Robert P. J. Day <rpjday at crashcourse.ca>

---

diff --git a/scripts/bareboxenv.c b/scripts/bareboxenv.c
index f44a1f8..5fdc62e 100644
--- a/scripts/bareboxenv.c
+++ b/scripts/bareboxenv.c
@@ -124,8 +124,8 @@ char *concat_subpath_file(const char *path, const char *f)
 void usage(char *prgname)
 {
 	printf( "Usage : %s [OPTION] DIRECTORY FILE\n"
-		"Load an barebox environment sector into a directory or\n"
-		"save a directory into an barebox environment sector\n"
+		"Load a barebox environment sector into a directory or\n"
+		"save a directory into a barebox environment sector\n"
 		"\n"
 		"options:\n"
 		"  -s        save (directory -> environment sector)\n"

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================


From antonynpavlov at gmail.com  Sat Nov 17 04:23:43 2012
From: antonynpavlov at gmail.com (Antony Pavlov)
Date: Sat, 17 Nov 2012 13:23:43 +0400
Subject: [PATCH] MIPS: main_entry.c: fix typo
Message-ID: <1353144223-9047-1-git-send-email-antonynpavlov@gmail.com>

Signed-off-by: Antony Pavlov <antonynpavlov at gmail.com>
---
 arch/mips/boot/main_entry.c |    1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/mips/boot/main_entry.c b/arch/mips/boot/main_entry.c
index c221288..0a33c45 100644
--- a/arch/mips/boot/main_entry.c
+++ b/arch/mips/boot/main_entry.c
@@ -14,7 +14,6 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- *
  */
 
 #include <common.h>
-- 
1.7.10.4



From antonynpavlov at gmail.com  Sat Nov 17 04:25:58 2012
From: antonynpavlov at gmail.com (Antony Pavlov)
Date: Sat, 17 Nov 2012 13:25:58 +0400
Subject: ARM: pbl: short patches
Message-ID: <1353144361-9089-1-git-send-email-antonynpavlov@gmail.com>

[PATCH 1/3] ARM: pbl: remove zbarebox.map during 'make clean'
[PATCH 2/3] ARM: start-pbl.c: make errorfn() static
[PATCH 3/3] ARM: start-pbl.c: unificate path to lib/decompress_*.c


From antonynpavlov at gmail.com  Sat Nov 17 04:25:59 2012
From: antonynpavlov at gmail.com (Antony Pavlov)
Date: Sat, 17 Nov 2012 13:25:59 +0400
Subject: [PATCH 1/3] ARM: pbl: remove zbarebox.map during 'make clean'
In-Reply-To: <1353144361-9089-1-git-send-email-antonynpavlov@gmail.com>
References: <1353144361-9089-1-git-send-email-antonynpavlov@gmail.com>
Message-ID: <1353144361-9089-2-git-send-email-antonynpavlov@gmail.com>

Signed-off-by: Antony Pavlov <antonynpavlov at gmail.com>
---
 arch/arm/pbl/Makefile |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/pbl/Makefile b/arch/arm/pbl/Makefile
index 286f8b5..7faa51a 100644
--- a/arch/arm/pbl/Makefile
+++ b/arch/arm/pbl/Makefile
@@ -9,7 +9,7 @@ targets := zbarebox.lds zbarebox zbarebox.bin zbarebox.S \
 	   $(piggy_o) piggy.$(suffix_y)
 
 # Make sure files are removed during clean
-extra-y       += piggy.gzip piggy.lzo piggy.lzma piggy.xzkern
+extra-y       += piggy.gzip piggy.lzo piggy.lzma piggy.xzkern zbarebox.map
 
 $(obj)/zbarebox.bin:	$(obj)/zbarebox FORCE
 	$(call if_changed,objcopy)
-- 
1.7.10.4



From antonynpavlov at gmail.com  Sat Nov 17 04:26:00 2012
From: antonynpavlov at gmail.com (Antony Pavlov)
Date: Sat, 17 Nov 2012 13:26:00 +0400
Subject: [PATCH 2/3] ARM: start-pbl.c: make errorfn() static
In-Reply-To: <1353144361-9089-1-git-send-email-antonynpavlov@gmail.com>
References: <1353144361-9089-1-git-send-email-antonynpavlov@gmail.com>
Message-ID: <1353144361-9089-3-git-send-email-antonynpavlov@gmail.com>

Signed-off-by: Antony Pavlov <antonynpavlov at gmail.com>
---
 arch/arm/cpu/start-pbl.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/cpu/start-pbl.c b/arch/arm/cpu/start-pbl.c
index 609aedb..79a3cdd 100644
--- a/arch/arm/cpu/start-pbl.c
+++ b/arch/arm/cpu/start-pbl.c
@@ -127,7 +127,7 @@ static void mmu_disable(void)
 	__mmu_cache_off();
 }
 
-void noinline errorfn(char *error)
+static void noinline errorfn(char *error)
 {
 	while (1);
 }
-- 
1.7.10.4



From antonynpavlov at gmail.com  Sat Nov 17 04:26:01 2012
From: antonynpavlov at gmail.com (Antony Pavlov)
Date: Sat, 17 Nov 2012 13:26:01 +0400
Subject: [PATCH 3/3] ARM: start-pbl.c: unificate path to lib/decompress_*.c
In-Reply-To: <1353144361-9089-1-git-send-email-antonynpavlov@gmail.com>
References: <1353144361-9089-1-git-send-email-antonynpavlov@gmail.com>
Message-ID: <1353144361-9089-4-git-send-email-antonynpavlov@gmail.com>

Signed-off-by: Antony Pavlov <antonynpavlov at gmail.com>
---
 arch/arm/cpu/start-pbl.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/cpu/start-pbl.c b/arch/arm/cpu/start-pbl.c
index 79a3cdd..c5f9705 100644
--- a/arch/arm/cpu/start-pbl.c
+++ b/arch/arm/cpu/start-pbl.c
@@ -66,7 +66,7 @@ extern void *input_data_end;
 #endif
 
 #ifdef CONFIG_IMAGE_COMPRESSION_GZIP
-#include "../../../../lib/decompress_inflate.c"
+#include "../../../lib/decompress_inflate.c"
 #endif
 
 static unsigned long *ttb;
-- 
1.7.10.4



From antonynpavlov at gmail.com  Sat Nov 17 07:10:36 2012
From: antonynpavlov at gmail.com (Antony Pavlov)
Date: Sat, 17 Nov 2012 16:10:36 +0400
Subject: [RFC 0/3] MIPS: add pre-bootloader (pbl) image support
Message-ID: <1353154239-31574-1-git-send-email-antonynpavlov@gmail.com>

This patch series is based on ARM pbl support and allows
creating a pre-bootloader binary for compressed image.

TODO:
 * add lowlevel init;
 * current MIPS pbl run only on qemu-malta; make it work
on other boards (e.g. add mmc/nand boot support on Ingenic SOCs).

[RFC 1/3] MIPS: add pre-bootloader (pbl) image support
[RFC 2/3] MIPS: boot: realize _start in C
[RFC 3/3] MIPS: qemu-malta_defconfig: use pbl


From antonynpavlov at gmail.com  Sat Nov 17 07:10:38 2012
From: antonynpavlov at gmail.com (Antony Pavlov)
Date: Sat, 17 Nov 2012 16:10:38 +0400
Subject: [RFC 2/3] MIPS: boot: realize _start in C
In-Reply-To: <1353154239-31574-1-git-send-email-antonynpavlov@gmail.com>
References: <1353154239-31574-1-git-send-email-antonynpavlov@gmail.com>
Message-ID: <1353154239-31574-3-git-send-email-antonynpavlov@gmail.com>

The pbl will be incharge of the lowlevel init and
barebox relocation. So we can skip it in barebox itself
and use simple _start.

Signed-off-by: Antony Pavlov <antonynpavlov at gmail.com>
---
 arch/mips/boot/Makefile     |    1 -
 arch/mips/boot/main_entry.c |   18 ++++++
 arch/mips/boot/start.S      |  142 -------------------------------------------
 3 files changed, 18 insertions(+), 143 deletions(-)
 delete mode 100644 arch/mips/boot/start.S

diff --git a/arch/mips/boot/Makefile b/arch/mips/boot/Makefile
index 6b093f1..4f11a48 100644
--- a/arch/mips/boot/Makefile
+++ b/arch/mips/boot/Makefile
@@ -1,4 +1,3 @@
-obj-y += start.o
 obj-y += main_entry.o
 
 pbl-y += start-pbl.o main_entry-pbl.o
diff --git a/arch/mips/boot/main_entry.c b/arch/mips/boot/main_entry.c
index 0a33c45..422d40b 100644
--- a/arch/mips/boot/main_entry.c
+++ b/arch/mips/boot/main_entry.c
@@ -22,6 +22,8 @@
 #include <asm/cpu-features.h>
 #include <asm/mipsregs.h>
 #include <asm/addrspace.h>
+#include <asm/regdef.h>
+#include <asm-generic/memory_layout.h>
 
 extern void start_barebox(void);
 extern void handle_reserved(void);
@@ -92,3 +94,19 @@ void main_entry(void)
 
 	start_barebox();
 }
+
+void __naked __section(.text_entry) _start(void)
+{
+	u32 r;
+
+	/* setup the stack */
+	r = STACK_BASE + STACK_SIZE - 16;
+
+	__asm__ __volatile__(
+		"move\t$sp, %0\n\t"
+		: /* no outputs */
+		: "r" (r)
+	);
+
+	main_entry();
+}
diff --git a/arch/mips/boot/start.S b/arch/mips/boot/start.S
deleted file mode 100644
index 7e2ae5e..0000000
--- a/arch/mips/boot/start.S
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Startup Code for MIPS CPU
- *
- * Copyright (C) 2011 Antony Pavlov <antonynpavlov at gmail.com>
- * Used code copyrighted (C) 2009 by Shinya Kuribayashi <skuribay at pobox.com>
- *
- * This file is part of barebox.
- * See file CREDITS for list of people who contributed to this project.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- */
-
-#include <asm/regdef.h>
-#include <asm/mipsregs.h>
-#include <asm/asm.h>
-#include <asm-generic/memory_layout.h>
-#include <generated/compile.h>
-#include <generated/utsrelease.h>
-
-	/*
-	 * ADR macro instruction (inspired by ARM)
-	 *
-	 * ARM architecture doesn't have PC-relative jump instruction
-	 * like MIPS' B/BAL insns.  When ARM makes PC-relative jumps,
-	 * it uses ADR insn.  ADR is used to get a destination address
-	 * of 'label' against current PC.  With this, ARM can safely
-	 * make PC-relative jumps.
-	 */
-	.macro	ADR rd label temp
-	.set	push
-	.set	noreorder
-	move	\temp, ra			# preserve ra beforehand
-	bal	_pc
-	 nop
-_pc:	addiu	\rd, ra, \label - _pc		# label is assumed to be
-	move	ra, \temp			# within pc +/- 32KB
-	.set	pop
-	.endm
-
-	.set noreorder
-	.text
-	.section ".text_bare_init"
-	.align 4
-
-EXPORT(_start)
-
-	b	__start
-	 nop
-
-	.org	0x10
-	.ascii	"barebox " UTS_RELEASE " " UTS_VERSION
-	.byte	0
-
-	.align 4
-__start:
-	/* disable watchpoints */
-	mtc0	zero, CP0_WATCHLO
-	mtc0	zero, CP0_WATCHHI
-
-	/* disable interrupts */
-	mfc0	k0, CP0_STATUS
-	li	k1, ~ST0_IE
-	and	k0, k1
-	mtc0	k0, CP0_STATUS
-
-	/* copy barebox to link location */
-	ADR	a0, _start, t1	/* a0 <- pc-relative position of _start */
-
-	la	a1, _start	/* link (RAM) _start address */
-
-	beq	a0, a1, stack_setup
-	 nop
-
-	la	t0, _start
-	la	t1, __bss_start
-	subu	t2, t1, t0	/* t2 <- size of barebox */
-	addu	a2, a0, t2	/* a2 <- source end address */
-
-#define LONGSIZE	4
-
-copy_loop:
-	/* copy from source address [a0] */
-	lw		t4, LONGSIZE * 0(a0)
-	lw		t5, LONGSIZE * 1(a0)
-	lw		t6, LONGSIZE * 2(a0)
-	lw		t7, LONGSIZE * 3(a0)
-	/* copy fo target address [a1] */
-	sw		t4, LONGSIZE * 0(a1)
-	sw		t5, LONGSIZE * 1(a1)
-	sw		t6, LONGSIZE * 2(a1)
-	sw		t7, LONGSIZE * 3(a1)
-	addi		a0, LONGSIZE * 4
-	subu		t3, a0, a2
-	blez		t3, copy_loop
-	addi		a1, LONGSIZE * 4
-
-	/*
-	 * Dominic Sweetman, See MIPS Run, Morgan Kaufmann, 2nd edition, 2006
-	 *
-	 * 11.2.2 Stack Argument Structure in o32
-	 * ...
-	 * At the point where a function is called, sp must be
-	 * eight-byte-aligned, matching the alignment of the largest
-	 * basic types -- a long long integer or a floating-point double.
-	 * The eight-byte alignment is not required by 32-bit MIPS integer
-	 * hardware, but it's essential for compatibility with CPUs with
-	 * 64-bit registers, and thus part of the rules. Subroutines fit
-	 * in with this by always adjusting the stack pointer by a multiple
-	 * of eight.
-	 * ...
-	 * SGI's n32 and n64 standards call for the stack to be maintained
-	 * with 16-byte alignment.
-	 *
-	 */
-
-#if (STACK_BASE + STACK_SIZE) % 16 != 0
-#error stack pointer must be 16-byte-aligned
-#endif
-
-stack_setup:
-	la	sp, STACK_BASE + STACK_SIZE
-
-	/* reserve four 32-bit argument slots */
-	addiu	sp, -16
-
-	la	v0, main_entry
-	jal     v0
-	 nop
-
-	/* No return */
-
-__error:
-	b __error
-	 nop
-- 
1.7.10.4



From antonynpavlov at gmail.com  Sat Nov 17 07:10:39 2012
From: antonynpavlov at gmail.com (Antony Pavlov)
Date: Sat, 17 Nov 2012 16:10:39 +0400
Subject: [RFC 3/3] MIPS: qemu-malta_defconfig: use pbl
In-Reply-To: <1353154239-31574-1-git-send-email-antonynpavlov@gmail.com>
References: <1353154239-31574-1-git-send-email-antonynpavlov@gmail.com>
Message-ID: <1353154239-31574-4-git-send-email-antonynpavlov@gmail.com>

Signed-off-by: Antony Pavlov <antonynpavlov at gmail.com>
---
 arch/mips/configs/qemu-malta_defconfig |    1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/mips/configs/qemu-malta_defconfig b/arch/mips/configs/qemu-malta_defconfig
index 7ade1aa..7dab969 100644
--- a/arch/mips/configs/qemu-malta_defconfig
+++ b/arch/mips/configs/qemu-malta_defconfig
@@ -1,3 +1,4 @@
+CONFIG_PBL_IMAGE=y
 CONFIG_STACK_SIZE=0x7000
 CONFIG_BROKEN=y
 CONFIG_EXPERIMENTAL=y
-- 
1.7.10.4



From antonynpavlov at gmail.com  Sat Nov 17 07:10:37 2012
From: antonynpavlov at gmail.com (Antony Pavlov)
Date: Sat, 17 Nov 2012 16:10:37 +0400
Subject: [RFC 1/3] MIPS: add pre-bootloader (pbl) image support
In-Reply-To: <1353154239-31574-1-git-send-email-antonynpavlov@gmail.com>
References: <1353154239-31574-1-git-send-email-antonynpavlov@gmail.com>
Message-ID: <1353154239-31574-2-git-send-email-antonynpavlov@gmail.com>

This patch is based on ARM pbl support and allows
creating a pre-bootloader binary for compressed image.

Signed-off-by: Antony Pavlov <antonynpavlov at gmail.com>
---
 arch/mips/Kconfig               |    2 +
 arch/mips/Makefile              |   18 +++++
 arch/mips/boot/Makefile         |    2 +
 arch/mips/boot/main_entry-pbl.c |   90 ++++++++++++++++++++++++
 arch/mips/boot/start-pbl.S      |  146 +++++++++++++++++++++++++++++++++++++++
 arch/mips/pbl/.gitignore        |    6 ++
 arch/mips/pbl/Makefile          |   40 +++++++++++
 arch/mips/pbl/piggy.gzip.S      |    6 ++
 arch/mips/pbl/piggy.lzo.S       |    6 ++
 arch/mips/pbl/zbarebox.lds.S    |   57 +++++++++++++++
 10 files changed, 373 insertions(+)
 create mode 100644 arch/mips/boot/main_entry-pbl.c
 create mode 100644 arch/mips/boot/start-pbl.S
 create mode 100644 arch/mips/pbl/.gitignore
 create mode 100644 arch/mips/pbl/Makefile
 create mode 100644 arch/mips/pbl/piggy.gzip.S
 create mode 100644 arch/mips/pbl/piggy.lzo.S
 create mode 100644 arch/mips/pbl/zbarebox.lds.S

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 7a1eeac..853d406 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -6,6 +6,8 @@ config MIPS
 	select HAS_KALLSYMS
 	select HAVE_CONFIGURABLE_MEMORY_LAYOUT
 	select HAVE_CONFIGURABLE_TEXT_BASE
+	select HAVE_PBL_IMAGE
+	select HAVE_IMAGE_COMPRESSION
 	default y
 
 config SYS_SUPPORTS_BIG_ENDIAN
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index 5e40de7..819e7a3 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -58,6 +58,15 @@ CPPFLAGS += -fdata-sections -ffunction-sections
 LDFLAGS_barebox += -static --gc-sections
 endif
 
+ifdef CONFIG_IMAGE_COMPRESSION
+KBUILD_BINARY := arch/mips/pbl/zbarebox.bin
+KBUILD_TARGET := zbarebox.bin
+$(KBUILD_BINARY): $(KBUILD_TARGET)
+else
+KBUILD_BINARY := barebox.bin
+KBUILD_TARGET := barebox.bin
+endif
+
 LDFLAGS_barebox += -nostdlib
 
 machine-$(CONFIG_MACH_MIPS_MALTA)	:= malta
@@ -106,3 +115,12 @@ CFLAGS += $(cflags-y)
 lds-$(CONFIG_GENERIC_LINKER_SCRIPT)   := arch/mips/lib/barebox.lds
 
 CLEAN_FILES    += arch/mips/lib/barebox.lds barebox.map barebox.S
+
+pbl := arch/mips/pbl
+zbarebox.S zbarebox.bin zbarebox: barebox.bin
+	$(Q)$(MAKE) $(build)=$(pbl) $(pbl)/$@
+
+archclean:
+	$(MAKE) $(clean)=$(pbl)
+
+KBUILD_IMAGE ?= $(KBUILD_BINARY)
diff --git a/arch/mips/boot/Makefile b/arch/mips/boot/Makefile
index d6d28ce..6b093f1 100644
--- a/arch/mips/boot/Makefile
+++ b/arch/mips/boot/Makefile
@@ -1,2 +1,4 @@
 obj-y += start.o
 obj-y += main_entry.o
+
+pbl-y += start-pbl.o main_entry-pbl.o
diff --git a/arch/mips/boot/main_entry-pbl.c b/arch/mips/boot/main_entry-pbl.c
new file mode 100644
index 0000000..51b9176
--- /dev/null
+++ b/arch/mips/boot/main_entry-pbl.c
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2012 Antony Pavlov <antonynpavlov at gmail.com>
+ *
+ * This file is part of barebox.
+ * See file CREDITS for list of people who contributed to this project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <common.h>
+#include <init.h>
+#include <sizes.h>
+#include <string.h>
+#include <asm/sections.h>
+#include <asm-generic/memory_layout.h>
+#include <debug_ll.h>
+
+extern void *input_data;
+extern void *input_data_end;
+
+unsigned long free_mem_ptr;
+unsigned long free_mem_end_ptr;
+
+#define STATIC static
+
+#ifdef CONFIG_IMAGE_COMPRESSION_LZO
+#include "../../../lib/decompress_unlzo.c"
+#endif
+
+#ifdef CONFIG_IMAGE_COMPRESSION_GZIP
+#include "../../../lib/decompress_inflate.c"
+#endif
+
+void pbl_main_entry(void);
+
+static unsigned long *ttb;
+
+static noinline void errorfn(char *error)
+{
+	PUTS_LL(error);
+	PUTC_LL('\n');
+
+	unreachable();
+}
+
+static void barebox_uncompress(void *compressed_start, unsigned int len)
+{
+	/* set 128 KiB at the end of the MALLOC_BASE for early malloc */
+	free_mem_ptr = MALLOC_BASE + MALLOC_SIZE - SZ_128K;
+	free_mem_end_ptr = free_mem_ptr + SZ_128K;
+
+	ttb = (void *)((free_mem_ptr - 0x4000) & ~0x3fff);
+
+	decompress((void *)compressed_start,
+			len,
+			NULL, NULL,
+			(void *)TEXT_BASE, NULL, errorfn);
+
+	/* FIXME: just now we have no MIPS cache support */
+	/* flush_icache(); */
+}
+
+void __section(.text_entry) pbl_main_entry(void)
+{
+	u32 pg_start, pg_end, pg_len;
+	void (*barebox)(void);
+
+	PUTS_LL("pbl_main_entry()\n");
+
+	/* clear bss */
+	memset(__bss_start, 0, __bss_stop - __bss_start);
+
+	pg_start = (u32)&input_data;
+	pg_end = (u32)&input_data_end;
+	pg_len = pg_end - pg_start;
+
+	barebox_uncompress(&input_data, pg_len);
+
+	barebox = (void *)TEXT_BASE;
+	barebox();
+}
diff --git a/arch/mips/boot/start-pbl.S b/arch/mips/boot/start-pbl.S
new file mode 100644
index 0000000..ad39f42
--- /dev/null
+++ b/arch/mips/boot/start-pbl.S
@@ -0,0 +1,146 @@
+/*
+ * Startup Code for MIPS CPU
+ *
+ * Copyright (C) 2011, 2012 Antony Pavlov <antonynpavlov at gmail.com>
+ * ADR macro copyrighted (C) 2009 by Shinya Kuribayashi <skuribay at pobox.com>
+ *
+ * This file is part of barebox.
+ * See file CREDITS for list of people who contributed to this project.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <asm/regdef.h>
+#include <asm/mipsregs.h>
+#include <asm/asm.h>
+#include <asm-generic/memory_layout.h>
+#include <generated/compile.h>
+#include <generated/utsrelease.h>
+
+//#include <mach/kernel-entry-init.h>
+
+	/*
+	 * ADR macro instruction (inspired by ARM)
+	 *
+	 * ARM architecture doesn't have PC-relative jump instruction
+	 * like MIPS' B/BAL insns. When ARM makes PC-relative jumps,
+	 * it uses ADR insn. ADR is used to get a destination address
+	 * of 'label' against current PC. With this, ARM can safely
+	 * make PC-relative jumps.
+	 */
+	.macro	ADR rd label temp
+	.set	push
+	.set	noreorder
+	move	\temp, ra			# preserve ra beforehand
+	bal	_pc
+	 nop
+_pc:	addiu	\rd, ra, \label - _pc		# label is assumed to be
+	move	ra, \temp			# within pc +/- 32KB
+	.set	pop
+	.endm
+
+	.set noreorder
+	.text
+	.section ".text_head_entry"
+	.align 4
+
+EXPORT(pbl_start)
+
+	b	__start
+	 nop
+
+	.org	0x10
+	.ascii	"barebox " UTS_RELEASE " " UTS_VERSION
+	.byte	0
+
+	.align 4
+__start:
+	/* disable watchpoints */
+	mtc0	zero, CP0_WATCHLO
+	mtc0	zero, CP0_WATCHHI
+
+	/* disable interrupts */
+	mfc0	k0, CP0_STATUS
+	li	k1, ~ST0_IE
+	and	k0, k1
+	mtc0	k0, CP0_STATUS
+
+	/* cpu specific setup */
+	//kernel_entry_setup
+
+	/* copy barebox to link location */
+	ADR	a0, pbl_start, t1	/* a0 <- pc-relative
+					position of pbl_start */
+
+	la	a1, pbl_start	/* a1 <- link (RAM) pbl_start address */
+
+	beq	a0, a1, stack_setup
+	 nop
+
+	la	t0, pbl_start
+	la	t1, __bss_start
+	subu	t2, t1, t0	/* t2 <- size of pbl */
+	addu	a2, a0, t2	/* a2 <- source end address */
+
+#define LONGSIZE	4
+
+copy_loop:
+	/* copy from source address [a0] */
+	lw	t4, LONGSIZE * 0(a0)
+	lw	t5, LONGSIZE * 1(a0)
+	lw	t6, LONGSIZE * 2(a0)
+	lw	t7, LONGSIZE * 3(a0)
+	/* copy fo target address [a1] */
+	sw	t4, LONGSIZE * 0(a1)
+	sw	t5, LONGSIZE * 1(a1)
+	sw	t6, LONGSIZE * 2(a1)
+	sw	t7, LONGSIZE * 3(a1)
+	addi	a0, LONGSIZE * 4
+	subu	t3, a0, a2
+	blez	t3, copy_loop
+	 addi	a1, LONGSIZE * 4
+
+	/*
+	 * Dominic Sweetman, See MIPS Run, Morgan Kaufmann, 2nd edition, 2006
+	 *
+	 * 11.2.2 Stack Argument Structure in o32
+	 * ...
+	 * At the point where a function is called, sp must be
+	 * eight-byte-aligned, matching the alignment of the largest
+	 * basic types -- a long long integer or a floating-point double.
+	 * The eight-byte alignment is not required by 32-bit MIPS integer
+	 * hardware, but it's essential for compatibility with CPUs with
+	 * 64-bit registers, and thus part of the rules. Subroutines fit
+	 * in with this by always adjusting the stack pointer by a multiple
+	 * of eight.
+	 * ...
+	 * SGI's n32 and n64 standards call for the stack to be maintained
+	 * with 16-byte alignment.
+	 *
+	 */
+
+#if (STACK_BASE + STACK_SIZE) % 16 != 0
+#error stack pointer must be 16-byte-aligned
+#endif
+
+stack_setup:
+
+	/* set stack pointer; reserve four 32-bit argument slots */
+	la	sp, STACK_BASE + STACK_SIZE - 16
+
+	la	v0, pbl_main_entry
+	jal	v0
+	 nop
+
+	/* No return */
+__error:
+	b	__error
+	 nop
diff --git a/arch/mips/pbl/.gitignore b/arch/mips/pbl/.gitignore
new file mode 100644
index 0000000..d71bb7c
--- /dev/null
+++ b/arch/mips/pbl/.gitignore
@@ -0,0 +1,6 @@
+piggy.gzip
+piggy.lzo
+zbarebox
+zbarebox.bin
+zbarebox.lds
+zbarebox.map
diff --git a/arch/mips/pbl/Makefile b/arch/mips/pbl/Makefile
new file mode 100644
index 0000000..7faa51a
--- /dev/null
+++ b/arch/mips/pbl/Makefile
@@ -0,0 +1,40 @@
+
+suffix_$(CONFIG_IMAGE_COMPRESSION_GZIP) = gzip
+suffix_$(CONFIG_IMAGE_COMPRESSION_LZO)	= lzo
+
+OBJCOPYFLAGS_zbarebox.bin = -O binary
+piggy_o := piggy.$(suffix_y).o
+
+targets := zbarebox.lds zbarebox zbarebox.bin zbarebox.S \
+	   $(piggy_o) piggy.$(suffix_y)
+
+# Make sure files are removed during clean
+extra-y       += piggy.gzip piggy.lzo piggy.lzma piggy.xzkern zbarebox.map
+
+$(obj)/zbarebox.bin:	$(obj)/zbarebox FORCE
+	$(call if_changed,objcopy)
+	$(call cmd,check_file_size,$(CONFIG_BAREBOX_MAX_IMAGE_SIZE))
+	$(Q)$(kecho) '  Barebox: $@ is ready'
+
+$(obj)/zbarebox.S: $(obj)/zbarebox FORCE
+	$(call if_changed,disasm)
+
+PBL_CPPFLAGS		+= -fdata-sections -ffunction-sections
+LDFLAGS_zbarebox	:= -Map $(obj)/zbarebox.map
+LDFLAGS_zbarebox	+= -static --gc-sections
+zbarebox-common := $(barebox-pbl-common) $(obj)/$(piggy_o)
+zbarebox-lds := $(obj)/zbarebox.lds
+
+quiet_cmd_zbarebox__ ?= LD      $@
+      cmd_zbarebox__ ?= $(LD) $(LDFLAGS) $(LDFLAGS_zbarebox) -o $@ \
+      -T $(zbarebox-lds)                                           \
+      --start-group $(zbarebox-common) --end-group                 \
+      $(filter-out $(zbarebox-lds) $(zbarebox-common) FORCE ,$^)
+
+$(obj)/zbarebox: $(zbarebox-lds) $(zbarebox-common) FORCE
+	$(call if_changed,zbarebox__)
+
+$(obj)/piggy.$(suffix_y): $(obj)/../../../barebox.bin FORCE
+	$(call if_changed,$(suffix_y))
+
+$(obj)/$(piggy_o): $(obj)/piggy.$(suffix_y) FORCE
diff --git a/arch/mips/pbl/piggy.gzip.S b/arch/mips/pbl/piggy.gzip.S
new file mode 100644
index 0000000..1e6bbef
--- /dev/null
+++ b/arch/mips/pbl/piggy.gzip.S
@@ -0,0 +1,6 @@
+#include <asm/asm.h>
+
+	.section .data
+EXPORT(input_data)
+	.incbin "arch/mips/pbl/piggy.gzip"
+EXPORT(input_data_end)
diff --git a/arch/mips/pbl/piggy.lzo.S b/arch/mips/pbl/piggy.lzo.S
new file mode 100644
index 0000000..6f1af1f
--- /dev/null
+++ b/arch/mips/pbl/piggy.lzo.S
@@ -0,0 +1,6 @@
+#include <asm/asm.h>
+
+	.section .data
+EXPORT(input_data)
+	.incbin	"arch/mips/pbl/piggy.lzo"
+EXPORT(input_data_end)
diff --git a/arch/mips/pbl/zbarebox.lds.S b/arch/mips/pbl/zbarebox.lds.S
new file mode 100644
index 0000000..3a26942
--- /dev/null
+++ b/arch/mips/pbl/zbarebox.lds.S
@@ -0,0 +1,57 @@
+/*
+ * (C) Copyright 2012 Sascha Hauer <s.hauer at pengutronix.de>, Pengutronix
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <asm-generic/barebox.lds.h>
+#include <asm-generic/memory_layout.h>
+
+OUTPUT_ARCH("mips")
+ENTRY(pbl_start)
+SECTIONS
+{
+	. = HEAD_TEXT_BASE;
+
+	PRE_IMAGE
+
+	. = ALIGN(4);
+	.text      :
+	{
+		_stext = .;
+		_text = .;
+		*(.text_head_entry*)
+		__bare_init_start = .;
+		*(.text_bare_init*)
+		__bare_init_end = .;
+		*(.text*)
+	}
+
+	BAREBOX_BARE_INIT_SIZE
+
+	. = ALIGN(4);
+	.rodata : { *(.rodata*) }
+
+	_etext = .;			/* End of text and rodata section */
+
+	. = ALIGN(4);
+	.data : { *(.data*) }
+
+	. = ALIGN(4);
+	__bss_start = .;
+	.bss : { *(.bss*) }
+	__bss_stop = .;
+	_end = .;
+}
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Sun Nov 18 07:46:27 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Sun, 18 Nov 2012 13:46:27 +0100
Subject: [PATCH 0/7] phylib: fix + drivers
Message-ID: <20121118124627.GE8327@game.jcrosoft.org>

HI,

	Today we have a bug on the match the logic is inverted.
	We are lucky as the generic Phy driver is not suppoed to match with
	any device it work so fix it. Ensure the generic phy driver is
	probe last if needed.

	for mx53-loco we are lucky too the first phy found is the right one

The following changes since commit 272a5d738ab152347d67be062e8a4e771825493a:

  at91rm9200ek: add spi support (2012-11-16 15:33:50 +0100)

are available in the git repository at:

  git://git.jcrosoft.org/barebox.git delivery/phylib_fix

for you to fetch changes up to 5ea00036e330ea58293774a36d3ee5f9c1fbe895:

  phylib: add micrel support (2012-11-16 23:11:16 +0800)

----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (7):
      driver: introduce device_probe to manully probe a device
      phylib: fix generic phy driver probe
      mdio_bus: fix match
      phylib: export phy_id via param
      phylib: introduction of forced 100Mbps
      phylib: add fixup support
      phylib: add micrel support

 drivers/base/driver.c      |   23 +++++++++----
 drivers/net/phy/Kconfig    |   11 +++---
 drivers/net/phy/Makefile   |    2 +-
 drivers/net/phy/generic.c  |   36 --------------------
 drivers/net/phy/mdio_bus.c |   28 ++++++++++-----
 drivers/net/phy/micrel.c   |  174 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/net/phy/phy.c      |  130 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 include/driver.h           |    5 +++
 include/linux/micrel_phy.h |   30 ++++++++++++++++
 include/linux/phy.h        |   21 +++++++++++-
 10 files changed, 400 insertions(+), 60 deletions(-)
 delete mode 100644 drivers/net/phy/generic.c
 create mode 100644 drivers/net/phy/micrel.c
 create mode 100644 include/linux/micrel_phy.h

Best Regards,
J.


From plagnioj at jcrosoft.com  Sun Nov 18 07:49:42 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Sun, 18 Nov 2012 13:49:42 +0100
Subject: [PATCH 4/7] phylib: export phy_id via param
In-Reply-To: <1353242985-7539-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121118124627.GE8327@game.jcrosoft.org>
 <1353242985-7539-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1353242985-7539-4-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/net/phy/mdio_bus.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 762adfe..41c8a96 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -193,6 +193,9 @@ static int mdio_bus_probe(struct device_d *_dev)
 	sprintf(str, "%d", dev->addr);
 	dev_add_param_fixed(&dev->dev, "phy_addr", str);
 
+	sprintf(str, "0x%08x", dev->phy_id);
+	dev_add_param_fixed(&dev->dev, "phy_id", str);
+
 	dev->cdev.name = asprintf("phy%d", _dev->id);
 	dev->cdev.size = 64;
 	dev->cdev.ops = &phydev_ops;
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Sun Nov 18 07:49:39 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Sun, 18 Nov 2012 13:49:39 +0100
Subject: [PATCH 1/7] driver: introduce device_probe to manully probe a device
In-Reply-To: <20121118124627.GE8327@game.jcrosoft.org>
References: <20121118124627.GE8327@game.jcrosoft.org>
Message-ID: <1353242985-7539-1-git-send-email-plagnioj@jcrosoft.com>

This will expect a driver to be specified
This is needed by the phylib the probe the generic phy if not driver found

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/base/driver.c |   23 +++++++++++++++++------
 include/driver.h      |    5 +++++
 2 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index dc2df91..1f4031a 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -75,6 +75,21 @@ int get_free_deviceid(const char *name_template)
 	};
 }
 
+int device_probe(struct device_d *dev)
+{
+	int ret;
+
+	ret = dev->bus->probe(dev);
+	if (ret) {
+		dev_err(dev, "probe failed: %s\n", strerror(-ret));
+		return ret;
+	}
+
+	list_add(&dev->active, &active);
+
+	return 0;
+}
+
 static int match(struct driver_d *drv, struct device_d *dev)
 {
 	int ret;
@@ -86,13 +101,9 @@ static int match(struct driver_d *drv, struct device_d *dev)
 
 	if (dev->bus->match(dev, drv))
 		goto err_out;
-	ret = dev->bus->probe(dev);
-	if (ret) {
-		dev_err(dev, "probe failed: %s\n", strerror(-ret));
+	ret = device_probe(dev);
+	if (ret)
 		goto err_out;
-	}
-
-	list_add(&dev->active, &active);
 
 	return 0;
 err_out:
diff --git a/include/driver.h b/include/driver.h
index f8d815c..a085981 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -148,6 +148,11 @@ struct driver_d {
 int register_driver(struct driver_d *);
 int register_device(struct device_d *);
 
+/* manualy probe a device
+ * the driver need to be specified
+ */
+int device_probe(struct device_d *dev);
+
 /* Unregister a device. This function can fail, e.g. when the device
  * has children.
  */
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Sun Nov 18 07:49:41 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Sun, 18 Nov 2012 13:49:41 +0100
Subject: [PATCH 3/7] mdio_bus: fix match
In-Reply-To: <1353242985-7539-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121118124627.GE8327@game.jcrosoft.org>
 <1353242985-7539-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1353242985-7539-3-git-send-email-plagnioj@jcrosoft.com>

on barebox we have the weird way the return 0 true on bus match

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/net/phy/mdio_bus.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 35319b4..762adfe 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -106,7 +106,7 @@ static int mdio_bus_match(struct device_d *dev, struct driver_d *drv)
 	struct phy_device *phydev = to_phy_device(dev);
 	struct phy_driver *phydrv = to_phy_driver(drv);
 
-	return ((phydrv->phy_id & phydrv->phy_id_mask) ==
+	return ((phydrv->phy_id & phydrv->phy_id_mask) !=
 		(phydev->phy_id & phydrv->phy_id_mask));
 }
 
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Sun Nov 18 07:49:43 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Sun, 18 Nov 2012 13:49:43 +0100
Subject: [PATCH 5/7] phylib: introduction of forced 100Mbps
In-Reply-To: <1353242985-7539-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121118124627.GE8327@game.jcrosoft.org>
 <1353242985-7539-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1353242985-7539-5-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/net/phy/mdio_bus.c |    4 ++++
 include/linux/phy.h        |    3 ++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 41c8a96..3e79345 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -175,6 +175,10 @@ static int mdio_bus_probe(struct device_d *_dev)
 			dev->speed = SPEED_10;
 			dev->duplex = DUPLEX_FULL;
 			dev->autoneg = !AUTONEG_ENABLE;
+		} else if (dev->dev_flags & PHYLIB_FORCE_100) {
+			dev->speed = SPEED_100;
+			dev->duplex = DUPLEX_FULL;
+			dev->autoneg = !AUTONEG_ENABLE;
 		}
 	}
 
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 4f14dae..791d657 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -60,7 +60,8 @@ typedef enum {
 #define MII_BUS_ID_SIZE	(20 - 3)
 
 #define PHYLIB_FORCE_10		(1 << 0)
-#define PHYLIB_FORCE_LINK	(1 << 1)
+#define PHYLIB_FORCE_100	(1 << 1)
+#define PHYLIB_FORCE_LINK	(1 << 2)
 
 #define PHYLIB_CAPABLE_1000M	(1 << 0)
 
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Sun Nov 18 07:49:40 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Sun, 18 Nov 2012 13:49:40 +0100
Subject: [PATCH 2/7] phylib: fix generic phy driver probe
In-Reply-To: <1353242985-7539-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121118124627.GE8327@game.jcrosoft.org>
 <1353242985-7539-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1353242985-7539-2-git-send-email-plagnioj@jcrosoft.com>

the generic phy driver is used if no driver are found

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/net/phy/Kconfig   |    8 ++------
 drivers/net/phy/Makefile  |    1 -
 drivers/net/phy/generic.c |   36 ------------------------------------
 drivers/net/phy/phy.c     |   34 ++++++++++++++++++++++++++++++++--
 4 files changed, 34 insertions(+), 45 deletions(-)
 delete mode 100644 drivers/net/phy/generic.c

diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index 616b539..3f7c150 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -8,15 +8,11 @@ if PHYLIB
 
 comment "MII PHY device drivers"
 
-config GENERIC_PHY
-	bool "Drivers for the Generic PHYs"
-	default y
-
-endif
-
 config SMSC_PHY
 	bool "Drivers for SMSC PHYs"
 	---help---
 	  Currently supports the LAN83C185, LAN8187 and LAN8700 PHYs
 
+endif
+
 endmenu
diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
index 0caeb70..dfc709a 100644
--- a/drivers/net/phy/Makefile
+++ b/drivers/net/phy/Makefile
@@ -1,3 +1,2 @@
 obj-y += phy.o mdio_bus.o
-obj-$(CONFIG_GENERIC_PHY) += generic.o
 obj-$(CONFIG_SMSC_PHY)		+= smsc.o
diff --git a/drivers/net/phy/generic.c b/drivers/net/phy/generic.c
deleted file mode 100644
index 3f5f127..0000000
--- a/drivers/net/phy/generic.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2009 Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- *
- */
-
-#include <common.h>
-#include <linux/phy.h>
-#include <init.h>
-
-static struct phy_driver generic_phy = {
-	.drv.name = "Generic PHY",
-	.phy_id = PHY_ANY_UID,
-	.phy_id_mask = PHY_ANY_UID,
-	.features = 0,
-};
-
-static int generic_phy_register(void)
-{
-	return phy_driver_register(&generic_phy);
-}
-device_initcall(generic_phy_register);
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 4478d9f..2fd0440 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -19,6 +19,7 @@
 
 #include <common.h>
 #include <driver.h>
+#include <init.h>
 #include <net.h>
 #include <malloc.h>
 #include <linux/phy.h>
@@ -27,6 +28,7 @@
 
 #define PHY_AN_TIMEOUT	10
 
+static struct phy_driver genphy_driver;
 static int genphy_config_init(struct phy_device *phydev);
 
 int phy_update_status(struct phy_device *dev)
@@ -142,6 +144,21 @@ struct phy_device *get_phy_device(struct mii_bus *bus, int addr)
 	return dev;
 }
 
+static int phy_register_device(struct phy_device* dev)
+{
+	int ret;
+
+	ret = register_device(&dev->dev);
+	if (ret)
+		return ret;
+
+	if (dev->dev.driver)
+		return 0;
+
+	dev->dev.driver = &genphy_driver.drv;
+	return device_probe(&dev->dev);
+}
+
 /* Automatically gets and returns the PHY device */
 int phy_device_connect(struct eth_device *edev, struct mii_bus *bus, int addr,
 		       void (*adjust_link) (struct eth_device *edev),
@@ -164,7 +181,7 @@ int phy_device_connect(struct eth_device *edev, struct mii_bus *bus, int addr,
 			dev->interface = interface;
 			dev->dev_flags = flags;
 
-			ret = register_device(&dev->dev);
+			ret = phy_register_device(dev);
 			if (ret)
 				goto fail;
 		} else {
@@ -181,7 +198,7 @@ int phy_device_connect(struct eth_device *edev, struct mii_bus *bus, int addr,
 				dev->interface = interface;
 				dev->dev_flags = flags;
 
-				ret = register_device(&dev->dev);
+				ret = phy_register_device(dev);
 				if (ret)
 					goto fail;
 
@@ -597,3 +614,16 @@ int phy_drivers_register(struct phy_driver *new_driver, int n)
 	}
 	return ret;
 }
+
+static struct phy_driver genphy_driver = {
+	.drv.name = "Generic PHY",
+	.phy_id = PHY_ANY_UID,
+	.phy_id_mask = PHY_ANY_UID,
+	.features = 0,
+};
+
+static int generic_phy_register(void)
+{
+	return phy_driver_register(&genphy_driver);
+}
+device_initcall(generic_phy_register);
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Sun Nov 18 07:49:45 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Sun, 18 Nov 2012 13:49:45 +0100
Subject: [PATCH 7/7] phylib: add micrel support
In-Reply-To: <1353242985-7539-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121118124627.GE8327@game.jcrosoft.org>
 <1353242985-7539-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1353242985-7539-7-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/net/phy/Kconfig    |    5 ++
 drivers/net/phy/Makefile   |    1 +
 drivers/net/phy/micrel.c   |  174 ++++++++++++++++++++++++++++++++++++++++++++
 include/linux/micrel_phy.h |   30 ++++++++
 4 files changed, 210 insertions(+)
 create mode 100644 drivers/net/phy/micrel.c
 create mode 100644 include/linux/micrel_phy.h

diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index 3f7c150..c75d73d 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -8,6 +8,11 @@ if PHYLIB
 
 comment "MII PHY device drivers"
 
+config MICREL_PHY
+	bool "Driver for Micrel PHYs"
+	---help---
+	  Supports the KSZ9021, VSC8201, KS8001 PHYs.
+
 config SMSC_PHY
 	bool "Drivers for SMSC PHYs"
 	---help---
diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
index dfc709a..5f8191d 100644
--- a/drivers/net/phy/Makefile
+++ b/drivers/net/phy/Makefile
@@ -1,2 +1,3 @@
 obj-y += phy.o mdio_bus.o
+obj-$(CONFIG_MICREL_PHY)	+= micrel.o
 obj-$(CONFIG_SMSC_PHY)		+= smsc.o
diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
new file mode 100644
index 0000000..0c6d43e
--- /dev/null
+++ b/drivers/net/phy/micrel.c
@@ -0,0 +1,174 @@
+/*
+ * drivers/net/phy/micrel.c
+ *
+ * Driver for Micrel PHYs
+ *
+ * Author: David J. Choi
+ *
+ * Copyright (c) 2010 Micrel, Inc.
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ *
+ * Support : ksz9021 1000/100/10 phy from Micrel
+ *		ks8001, ks8737, ks8721, ks8041, ks8051 100/10 phy
+ */
+
+#include <common.h>
+#include <init.h>
+#include <linux/mii.h>
+#include <linux/ethtool.h>
+#include <linux/phy.h>
+#include <linux/micrel_phy.h>
+
+/* Operation Mode Strap Override */
+#define MII_KSZPHY_OMSO				0x16
+#define KSZPHY_OMSO_B_CAST_OFF			(1 << 9)
+#define KSZPHY_OMSO_RMII_OVERRIDE		(1 << 1)
+#define KSZPHY_OMSO_MII_OVERRIDE		(1 << 0)
+
+/* general PHY control reg in vendor specific block. */
+#define	MII_KSZPHY_CTRL			0x1F
+/* bitmap of PHY register to set interrupt mode */
+#define KSZPHY_CTRL_INT_ACTIVE_HIGH		(1 << 9)
+#define KSZ9021_CTRL_INT_ACTIVE_HIGH		(1 << 14)
+#define KS8737_CTRL_INT_ACTIVE_HIGH		(1 << 14)
+#define KSZ8051_RMII_50MHZ_CLK			(1 << 7)
+
+static int kszphy_config_init(struct phy_device *phydev)
+{
+	return 0;
+}
+
+static int ksz8021_config_init(struct phy_device *phydev)
+{
+	const u16 val = KSZPHY_OMSO_B_CAST_OFF | KSZPHY_OMSO_RMII_OVERRIDE;
+	phy_write(phydev, MII_KSZPHY_OMSO, val);
+	return 0;
+}
+
+static int ks8051_config_init(struct phy_device *phydev)
+{
+	int regval;
+
+	if (phydev->dev_flags & MICREL_PHY_50MHZ_CLK) {
+		regval = phy_read(phydev, MII_KSZPHY_CTRL);
+		regval |= KSZ8051_RMII_50MHZ_CLK;
+		phy_write(phydev, MII_KSZPHY_CTRL, regval);
+	}
+
+	return 0;
+}
+
+#define KSZ8873MLL_GLOBAL_CONTROL_4	0x06
+#define KSZ8873MLL_GLOBAL_CONTROL_4_DUPLEX	(1 << 6)
+#define KSZ8873MLL_GLOBAL_CONTROL_4_SPEED	(1 << 4)
+int ksz8873mll_read_status(struct phy_device *phydev)
+{
+	int regval;
+
+	/* dummy read */
+	regval = phy_read(phydev, KSZ8873MLL_GLOBAL_CONTROL_4);
+
+	regval = phy_read(phydev, KSZ8873MLL_GLOBAL_CONTROL_4);
+
+	if (regval & KSZ8873MLL_GLOBAL_CONTROL_4_DUPLEX)
+		phydev->duplex = DUPLEX_HALF;
+	else
+		phydev->duplex = DUPLEX_FULL;
+
+	if (regval & KSZ8873MLL_GLOBAL_CONTROL_4_SPEED)
+		phydev->speed = SPEED_10;
+	else
+		phydev->speed = SPEED_100;
+
+	phydev->link = 1;
+	phydev->pause = phydev->asym_pause = 0;
+
+	return 0;
+}
+
+static int ksz8873mll_config_aneg(struct phy_device *phydev)
+{
+	return 0;
+}
+
+static int ksz8873mll_config_init(struct phy_device *phydev)
+{
+	phydev->autoneg = AUTONEG_DISABLE;
+	phydev->link = 1;
+
+	return 0;
+}
+
+static struct phy_driver ksphy_driver[] = {
+{
+	.phy_id		= PHY_ID_KS8737,
+	.phy_id_mask	= 0x00fffff0,
+	.drv.name	= "Micrel KS8737",
+	.features	= (PHY_BASIC_FEATURES | SUPPORTED_Pause),
+	.config_init	= kszphy_config_init,
+	.config_aneg	= genphy_config_aneg,
+	.read_status	= genphy_read_status,
+}, {
+	.phy_id		= PHY_ID_KSZ8021,
+	.phy_id_mask	= 0x00ffffff,
+	.drv.name	= "Micrel KSZ8021",
+	.features	= (PHY_BASIC_FEATURES | SUPPORTED_Pause |
+			   SUPPORTED_Asym_Pause),
+	.config_init	= ksz8021_config_init,
+	.config_aneg	= genphy_config_aneg,
+	.read_status	= genphy_read_status,
+}, {
+	.phy_id		= PHY_ID_KSZ8041,
+	.phy_id_mask	= 0x00fffff0,
+	.drv.name	= "Micrel KSZ8041",
+	.features	= (PHY_BASIC_FEATURES | SUPPORTED_Pause
+				| SUPPORTED_Asym_Pause),
+	.config_init	= kszphy_config_init,
+	.config_aneg	= genphy_config_aneg,
+	.read_status	= genphy_read_status,
+}, {
+	.phy_id		= PHY_ID_KSZ8051,
+	.phy_id_mask	= 0x00fffff0,
+	.drv.name		= "Micrel KSZ8051",
+	.features	= (PHY_BASIC_FEATURES | SUPPORTED_Pause
+				| SUPPORTED_Asym_Pause),
+	.config_init	= ks8051_config_init,
+	.config_aneg	= genphy_config_aneg,
+	.read_status	= genphy_read_status,
+}, {
+	.phy_id		= PHY_ID_KSZ8001,
+	.drv.name	= "Micrel KSZ8001 or KS8721",
+	.phy_id_mask	= 0x00ffffff,
+	.features	= (PHY_BASIC_FEATURES | SUPPORTED_Pause),
+	.config_init	= kszphy_config_init,
+	.config_aneg	= genphy_config_aneg,
+	.read_status	= genphy_read_status,
+}, {
+	.phy_id		= PHY_ID_KSZ9021,
+	.phy_id_mask	= 0x000ffffe,
+	.drv.name	= "Micrel KSZ9021 Gigabit PHY",
+	.features	= (PHY_GBIT_FEATURES | SUPPORTED_Pause
+				| SUPPORTED_Asym_Pause),
+	.config_init	= kszphy_config_init,
+	.config_aneg	= genphy_config_aneg,
+	.read_status	= genphy_read_status,
+}, {
+	.phy_id		= PHY_ID_KSZ8873MLL,
+	.phy_id_mask	= 0x00fffff0,
+	.drv.name	= "Micrel KSZ8873MLL Swithch",
+	.features	= (SUPPORTED_Pause | SUPPORTED_Asym_Pause),
+	.config_init	= ksz8873mll_config_init,
+	.config_aneg	= ksz8873mll_config_aneg,
+	.read_status	= ksz8873mll_read_status,
+} };
+
+static int ksphy_init(void)
+{
+	return phy_drivers_register(ksphy_driver,
+		ARRAY_SIZE(ksphy_driver));
+}
+fs_initcall(ksphy_init);
diff --git a/include/linux/micrel_phy.h b/include/linux/micrel_phy.h
new file mode 100644
index 0000000..adfe8c0
--- /dev/null
+++ b/include/linux/micrel_phy.h
@@ -0,0 +1,30 @@
+/*
+ * include/linux/micrel_phy.h
+ *
+ * Micrel PHY IDs
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ *
+ */
+
+#ifndef _MICREL_PHY_H
+#define _MICREL_PHY_H
+
+#define MICREL_PHY_ID_MASK	0x00fffff0
+
+#define PHY_ID_KSZ8873MLL	0x000e7237
+#define PHY_ID_KSZ9021		0x00221610
+#define PHY_ID_KS8737		0x00221720
+#define PHY_ID_KSZ8021		0x00221555
+#define PHY_ID_KSZ8041		0x00221510
+#define PHY_ID_KSZ8051		0x00221550
+/* both for ks8001 Rev. A/B, and for ks8721 Rev 3. */
+#define PHY_ID_KSZ8001		0x0022161A
+
+/* struct phy_device dev_flags definitions */
+#define MICREL_PHY_50MHZ_CLK	0x00000001
+
+#endif /* _MICREL_PHY_H */
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Sun Nov 18 07:49:44 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Sun, 18 Nov 2012 13:49:44 +0100
Subject: [PATCH 6/7] phylib: add fixup support
In-Reply-To: <1353242985-7539-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121118124627.GE8327@game.jcrosoft.org>
 <1353242985-7539-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1353242985-7539-6-git-send-email-plagnioj@jcrosoft.com>

if board need specific phy fixup they can register it and then the code will
executed only if needed

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/net/phy/mdio_bus.c |   19 +++++----
 drivers/net/phy/phy.c      |   96 ++++++++++++++++++++++++++++++++++++++++++++
 include/linux/phy.h        |   18 +++++++++
 3 files changed, 125 insertions(+), 8 deletions(-)

diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 3e79345..1d20bb0 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -153,6 +153,7 @@ static int mdio_bus_probe(struct device_d *_dev)
 	struct phy_device *dev = to_phy_device(_dev);
 	struct phy_driver *drv = to_phy_driver(_dev->driver);
 
+	int ret;
 	char str[16];
 
 	dev->attached_dev->phydev = dev;
@@ -160,14 +161,9 @@ static int mdio_bus_probe(struct device_d *_dev)
 	dev_add_child(dev->dev.parent, _dev);
 
 	if (drv->probe) {
-		int ret;
-
 		ret = drv->probe(dev);
-		if (ret) {
-			dev->attached_dev->phydev = NULL;
-			dev->attached_dev = NULL;
-			return ret;
-		}
+		if (ret)
+			goto err;
 	}
 
 	if (dev->dev_flags) {
@@ -188,7 +184,9 @@ static int mdio_bus_probe(struct device_d *_dev)
 	dev->supported = drv->features;
 	dev->advertising = drv->features;
 
-	drv->config_init(dev);
+	ret = phy_init_hw(dev);
+	if (ret)
+		goto err;
 
 	/* Sanitize settings based on PHY capabilities */
 	if ((dev->supported & SUPPORTED_Autoneg) == 0)
@@ -208,6 +206,11 @@ static int mdio_bus_probe(struct device_d *_dev)
 	devfs_create(&dev->cdev);
 
 	return 0;
+
+err:
+	dev->attached_dev->phydev = NULL;
+	dev->attached_dev = NULL;
+	return ret;
 }
 
 static void mdio_bus_remove(struct device_d *_dev)
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 2fd0440..59df742 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -55,6 +55,87 @@ int phy_update_status(struct phy_device *dev)
 	return 0;
 }
 
+static LIST_HEAD(phy_fixup_list);
+
+/*
+ * Creates a new phy_fixup and adds it to the list
+ * @bus_id: A string which matches phydev->dev.bus_id (or PHY_ANY_ID)
+ * @phy_uid: Used to match against phydev->phy_id (the UID of the PHY)
+ * 	It can also be PHY_ANY_UID
+ * @phy_uid_mask: Applied to phydev->phy_id and fixup->phy_uid before
+ * 	comparison
+ * @run: The actual code to be run when a matching PHY is found
+ */
+int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask,
+		int (*run)(struct phy_device *))
+{
+	struct phy_fixup *fixup;
+
+	fixup = kzalloc(sizeof(struct phy_fixup), GFP_KERNEL);
+	if (!fixup)
+		return -ENOMEM;
+
+	strlcpy(fixup->bus_id, bus_id, sizeof(fixup->bus_id));
+	fixup->phy_uid = phy_uid;
+	fixup->phy_uid_mask = phy_uid_mask;
+	fixup->run = run;
+
+	list_add_tail(&fixup->list, &phy_fixup_list);
+
+	return 0;
+}
+
+/* Registers a fixup to be run on any PHY with the UID in phy_uid */
+int phy_register_fixup_for_uid(u32 phy_uid, u32 phy_uid_mask,
+		int (*run)(struct phy_device *))
+{
+	return phy_register_fixup(PHY_ANY_ID, phy_uid, phy_uid_mask, run);
+}
+
+/* Registers a fixup to be run on the PHY with id string bus_id */
+int phy_register_fixup_for_id(const char *bus_id,
+		int (*run)(struct phy_device *))
+{
+	return phy_register_fixup(bus_id, PHY_ANY_UID, 0xffffffff, run);
+}
+
+/*
+ * Returns 1 if fixup matches phydev in bus_id and phy_uid.
+ * Fixups can be set to match any in one or more fields.
+ */
+static int phy_needs_fixup(struct phy_device *phydev, struct phy_fixup *fixup)
+{
+	if (strcmp(fixup->bus_id, dev_name(&phydev->dev)) != 0)
+		if (strcmp(fixup->bus_id, PHY_ANY_ID) != 0)
+			return 0;
+
+	if ((fixup->phy_uid & fixup->phy_uid_mask) !=
+			(phydev->phy_id & fixup->phy_uid_mask))
+		if (fixup->phy_uid != PHY_ANY_UID)
+			return 0;
+
+	return 1;
+}
+/* Runs any matching fixups for this phydev */
+int phy_scan_fixups(struct phy_device *phydev)
+{
+	struct phy_fixup *fixup;
+
+	list_for_each_entry(fixup, &phy_fixup_list, list) {
+		if (phy_needs_fixup(phydev, fixup)) {
+			int err;
+
+			err = fixup->run(phydev);
+
+			if (err < 0) {
+				return err;
+			}
+		}
+	}
+
+	return 0;
+}
+
 struct phy_device *phy_device_create(struct mii_bus *bus, int addr, int phy_id)
 {
 	struct phy_device *dev;
@@ -615,6 +696,21 @@ int phy_drivers_register(struct phy_driver *new_driver, int n)
 	return ret;
 }
 
+int phy_init_hw(struct phy_device *phydev)
+{
+	struct phy_driver *phydrv = to_phy_driver(phydev->dev.driver);
+	int ret;
+
+	if (!phydrv || !phydrv->config_init)
+		return 0;
+
+	ret = phy_scan_fixups(phydev);
+	if (ret < 0)
+		return ret;
+
+	return phydrv->config_init(phydev);
+}
+
 static struct phy_driver genphy_driver = {
 	.drv.name = "Generic PHY",
 	.phy_id = PHY_ANY_UID,
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 791d657..b39eca5 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -226,10 +226,20 @@ struct phy_driver {
 #define PHY_ANY_ID "MATCH ANY PHY"
 #define PHY_ANY_UID 0xffffffff
 
+/* A Structure for boards to register fixups with the PHY Lib */
+struct phy_fixup {
+	struct list_head list;
+	char bus_id[20];
+	u32 phy_uid;
+	u32 phy_uid_mask;
+	int (*run)(struct phy_device *phydev);
+};
+
 int phy_driver_register(struct phy_driver *drv);
 int phy_drivers_register(struct phy_driver *new_driver, int n);
 struct phy_device *get_phy_device(struct mii_bus *bus, int addr);
 int phy_init(void);
+int phy_init_hw(struct phy_device *phydev);
 
 /**
  * phy_read - Convenience function for reading a given PHY register
@@ -267,5 +277,13 @@ int genphy_config_advert(struct phy_device *phydev);
 int genphy_setup_forced(struct phy_device *phydev);
 int get_phy_id(struct mii_bus *bus, int addr, u32 *phy_id);
 
+int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask,
+		int (*run)(struct phy_device *));
+int phy_register_fixup_for_id(const char *bus_id,
+		int (*run)(struct phy_device *));
+int phy_register_fixup_for_uid(u32 phy_uid, u32 phy_uid_mask,
+		int (*run)(struct phy_device *));
+int phy_scan_fixups(struct phy_device *phydev);
+
 extern struct bus_type mdio_bus_type;
 #endif /* __PHYDEV_H__ */
-- 
1.7.10.4



From rpjday at crashcourse.ca  Sun Nov 18 08:30:44 2012
From: rpjday at crashcourse.ca (Robert P. J. Day)
Date: Sun, 18 Nov 2012 08:30:44 -0500 (EST)
Subject: [PATCH] mach-imx: Comment typo fix, "enviroment" -> "environment"
Message-ID: <alpine.DEB.2.02.1211180828470.17933@oneiric>


A couple trivial spelling fixes.

Signed-off-by: Robert P. J. Day <rpjday at crashcourse.ca>

---

  i thought i'd sent this in already but don't see it in outbox so
just playing it safe.

diff --git a/arch/arm/mach-imx/boot.c b/arch/arm/mach-imx/boot.c
index cdddbe5..ae7c48b 100644
--- a/arch/arm/mach-imx/boot.c
+++ b/arch/arm/mach-imx/boot.c
@@ -77,7 +77,7 @@ static const enum imx_bootsource locations[4][4] = {
 };

 /*
- * Saves the boot source media into the $barebox_loc enviroment variable
+ * Saves the boot source media into the $barebox_loc environment variable
  *
  * This information is useful for barebox init scripts as we can then easily
  * use a kernel image stored on the same media that we launch barebox with
diff --git a/arch/arm/mach-imx/imx51.c b/arch/arm/mach-imx/imx51.c
index f5a867b..4b0786b 100644
--- a/arch/arm/mach-imx/imx51.c
+++ b/arch/arm/mach-imx/imx51.c
@@ -75,7 +75,7 @@ static int imx51_init(void)
 postcore_initcall(imx51_init);

 /*
- * Saves the boot source media into the $barebox_loc enviroment variable
+ * Saves the boot source media into the $barebox_loc environment variable
  *
  * This information is useful for barebox init scripts as we can then easily
  * use a kernel image stored on the same media that we launch barebox with
-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================


From rpjday at crashcourse.ca  Sun Nov 18 08:39:51 2012
From: rpjday at crashcourse.ca (Robert P. J. Day)
Date: Sun, 18 Nov 2012 08:39:51 -0500 (EST)
Subject: [PATCH] arm lib: Remove redundant boot usage info from boot[uz].c
Message-ID: <alpine.DEB.2.02.1211180836390.17973@oneiric>


There is no need to add the command name to the "usage" info when
defining a command.

Signed-off-by: Robert P. J. Day <rpjday at crashcourse.ca>

---

  fairly sure the command name is superfluous in the usage string,
yes?

diff --git a/arch/arm/lib/bootu.c b/arch/arm/lib/bootu.c
index 0d155cb..75e0de3 100644
--- a/arch/arm/lib/bootu.c
+++ b/arch/arm/lib/bootu.c
@@ -36,7 +36,7 @@ static const __maybe_unused char cmd_bootu_help[] =

 BAREBOX_CMD_START(bootu)
 	.cmd            = do_bootu,
-	.usage          = "bootu - start a raw linux image",
+	.usage          = "start a raw linux image",
 	BAREBOX_CMD_HELP(cmd_bootu_help)
 BAREBOX_CMD_END

diff --git a/arch/arm/lib/bootz.c b/arch/arm/lib/bootz.c
index f069127..9f5b3b4 100644
--- a/arch/arm/lib/bootz.c
+++ b/arch/arm/lib/bootz.c
@@ -133,7 +133,7 @@ static const __maybe_unused char cmd_bootz_help[] =

 BAREBOX_CMD_START(bootz)
 	.cmd            = do_bootz,
-	.usage          = "bootz - start a zImage",
+	.usage          = "start a zImage",
 	BAREBOX_CMD_HELP(cmd_bootz_help)
 BAREBOX_CMD_END


-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================


From rpjday at crashcourse.ca  Sun Nov 18 08:48:51 2012
From: rpjday at crashcourse.ca (Robert P. J. Day)
Date: Sun, 18 Nov 2012 08:48:51 -0500 (EST)
Subject: is there a standard for putting the name of a source file in the file?
Message-ID: <alpine.DEB.2.02.1211180844430.18098@oneiric>


  as i'm working my way thru the lib/ routines in barebox, i notice
that some source files there, like getopt.c, conveniently have the
filename right at the top:

/*
 * getopt.c - a simple getopt(3) implementation. See getopt.h for explanation.
...

i really like this habit as it makes it easy to send a file to the
printer and not forget what the file was.

  however, most of the files in lib/ don't have that.  as i work my
way through the files, i'd be happy to add something like that to each
file, and submit the changes all as one patch.  is there a standard?
from what i can see, there's quite the variety in how people add that
to a source file.

  i'm open to guidance and i can take it from there.

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================


From antonynpavlov at gmail.com  Sun Nov 18 10:29:29 2012
From: antonynpavlov at gmail.com (Antony Pavlov)
Date: Sun, 18 Nov 2012 19:29:29 +0400
Subject: [PATCH 3/3] ARM: start-pbl.c: unificate path to lib/decompress_*.c
In-Reply-To: <1353144361-9089-4-git-send-email-antonynpavlov@gmail.com>
References: <1353144361-9089-1-git-send-email-antonynpavlov@gmail.com>
 <1353144361-9089-4-git-send-email-antonynpavlov@gmail.com>
Message-ID: <CAA4bVAE=TQmPG+KPG4nVLg_V4q98D_W_rjtbTAgXkZTTseQ6mg@mail.gmail.com>

Sorry, not "unificate" but "unify" of course.

On 17 November 2012 13:26, Antony Pavlov <antonynpavlov at gmail.com> wrote:
> Signed-off-by: Antony Pavlov <antonynpavlov at gmail.com>
> ---
>  arch/arm/cpu/start-pbl.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm/cpu/start-pbl.c b/arch/arm/cpu/start-pbl.c
> index 79a3cdd..c5f9705 100644
> --- a/arch/arm/cpu/start-pbl.c
> +++ b/arch/arm/cpu/start-pbl.c
> @@ -66,7 +66,7 @@ extern void *input_data_end;
>  #endif
>
>  #ifdef CONFIG_IMAGE_COMPRESSION_GZIP
> -#include "../../../../lib/decompress_inflate.c"
> +#include "../../../lib/decompress_inflate.c"
>  #endif
>
>  static unsigned long *ttb;
> --
> 1.7.10.4
>



-- 
Best regards,
  Antony Pavlov


From plagnioj at jcrosoft.com  Sun Nov 18 11:26:37 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Sun, 18 Nov 2012 17:26:37 +0100
Subject: is there a standard for putting the name of a source file in
 the file?
In-Reply-To: <alpine.DEB.2.02.1211180844430.18098@oneiric>
References: <alpine.DEB.2.02.1211180844430.18098@oneiric>
Message-ID: <20121118162637.GF8327@game.jcrosoft.org>

On 08:48 Sun 18 Nov     , Robert P. J. Day wrote:
> 
>   as i'm working my way thru the lib/ routines in barebox, i notice
> that some source files there, like getopt.c, conveniently have the
> filename right at the top:
> 
> /*
>  * getopt.c - a simple getopt(3) implementation. See getopt.h for explanation.
> ...
> 
> i really like this habit as it makes it easy to send a file to the
> printer and not forget what the file was.
> 
>   however, most of the files in lib/ don't have that.  as i work my
> way through the files, i'd be happy to add something like that to each
> file, and submit the changes all as one patch.  is there a standard?
> from what i can see, there's quite the variety in how people add that
> to a source file.
> 
>   i'm open to guidance and i can take it from there.
no this is a pain in the ass to maintian when we move file

I' drop it and I'm against it

Best Regards,
J.
> 
> rday
> 
> -- 
> 
> ========================================================================
> Robert P. J. Day                                 Ottawa, Ontario, CANADA
>                         http://crashcourse.ca
> 
> Twitter:                                       http://twitter.com/rpjday
> LinkedIn:                               http://ca.linkedin.com/in/rpjday
> ========================================================================
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox


From rpjday at crashcourse.ca  Sun Nov 18 11:39:48 2012
From: rpjday at crashcourse.ca (Robert P. J. Day)
Date: Sun, 18 Nov 2012 11:39:48 -0500 (EST)
Subject: is there a standard for putting the name of a source file in
 the file?
In-Reply-To: <20121118162637.GF8327@game.jcrosoft.org>
References: <alpine.DEB.2.02.1211180844430.18098@oneiric>
 <20121118162637.GF8327@game.jcrosoft.org>
Message-ID: <alpine.DEB.2.02.1211181139290.32036@oneiric>

On Sun, 18 Nov 2012, Jean-Christophe PLAGNIOL-VILLARD wrote:

> On 08:48 Sun 18 Nov     , Robert P. J. Day wrote:
> >
> >   as i'm working my way thru the lib/ routines in barebox, i notice
> > that some source files there, like getopt.c, conveniently have the
> > filename right at the top:
> >
> > /*
> >  * getopt.c - a simple getopt(3) implementation. See getopt.h for explanation.
> > ...
> >
> > i really like this habit as it makes it easy to send a file to the
> > printer and not forget what the file was.
> >
> >   however, most of the files in lib/ don't have that.  as i work my
> > way through the files, i'd be happy to add something like that to each
> > file, and submit the changes all as one patch.  is there a standard?
> > from what i can see, there's quite the variety in how people add that
> > to a source file.
> >
> >   i'm open to guidance and i can take it from there.
> no this is a pain in the ass to maintian when we move file
>
> I' drop it and I'm against it

  ok, that logic makes sense, i'm good with that.

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================


From rpjday at crashcourse.ca  Sun Nov 18 12:52:48 2012
From: rpjday at crashcourse.ca (Robert P. J. Day)
Date: Sun, 18 Nov 2012 12:52:48 -0500 (EST)
Subject: shouldn't asm-generic/barebox.lds.h be arch-independent?
Message-ID: <alpine.DEB.2.02.1211181240360.32651@oneiric>


  perusing the code to see how the final barebox executable is created
and ran across this opening to include/asm-generic/barebox.lds.h:

#if defined CONFIG_ARCH_IMX25 || \
        defined CONFIG_ARCH_IMX35 || \
        defined CONFIG_ARCH_IMX51 || \
        defined CONFIG_ARCH_IMX53 || \
        defined CONFIG_ARCH_IMX6 || \
        defined CONFIG_X86 || \
        defined CONFIG_ARCH_EP93XX
#include <mach/barebox.lds.h>
#endif

#ifndef PRE_IMAGE
#define PRE_IMAGE
#endif

  i find that more than a little confusing and inappropriate -- it
strikes me that the allegedly "generic" lds.h file shouldn't be
testing for an arbitrary set of inexplicable machine/arch
combinations, especially when there is absolutely no explanation about
what makes that particular set of symbols magic with respect to this
file.

  a minute or two of perusing shows that what it's for is inserting
some special "pre-image" content into the executable, but that means
that for each new selection that needs that, this file will have to be
changed and that's just messy.

  the linux kernel has a simpler strategy for
asm-generic/vmlinux.lds.h, as you see in this patch snippet that added
bss first section functionality to that file earlier this year:

+/*
+ * Allow archectures to redefine BSS_FIRST_SECTIONS to add extra
+ * sections to the front of bss.
+ */
+#ifndef BSS_FIRST_SECTIONS
+#define BSS_FIRST_SECTIONS
+#endif
+
 #define BSS(bss_align)                                                 \
        . = ALIGN(bss_align);                                           \
        .bss : AT(ADDR(.bss) - LOAD_OFFSET) {                           \
+               BSS_FIRST_SECTIONS                                      \
                *(.bss..page_aligned)                                   \
                *(.dynbss)                                              \
                *(.bss)                                                 \

  that would seem to be a much nicer solution as it pushes the
selection of pre-image content back to the architectures where it
belongs.

  the fact that the current approach is prone to "error" can be seen
in the file arch/mips/lib/barebox.lds.S:

#include <asm-generic/barebox.lds.h>

OUTPUT_ARCH(mips)
ENTRY(_start)
SECTIONS
{
        . = TEXT_BASE;

        . = ALIGN(4);
        .text      :
        {
                _start = .;
                *(.text_entry*)
                _stext = .;
                _text = .;
                __bare_init_start = .;
                *(.text_bare_init*)
                __bare_init_end = .;
                *(.text*)
        }
        BAREBOX_BARE_INIT_SIZE

        PRE_IMAGE  <--- ?????

apparently, the MIPS architecture is including the "PRE_IMAGE"
content, despite the fact that it can't possibly be defined.  it's not
wrong, it's just pointless and potentially confusing.

  is there some reason this wasn't done the same way the linux kernel
does it?

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================



From antonynpavlov at gmail.com  Sun Nov 18 13:21:20 2012
From: antonynpavlov at gmail.com (Antony Pavlov)
Date: Sun, 18 Nov 2012 22:21:20 +0400
Subject: shouldn't asm-generic/barebox.lds.h be arch-independent?
In-Reply-To: <alpine.DEB.2.02.1211181240360.32651@oneiric>
References: <alpine.DEB.2.02.1211181240360.32651@oneiric>
Message-ID: <CAA4bVAEpXjiv-DAG=aF9OfmJBOqHZKadr6xpXOznEB6MPdQMkA@mail.gmail.com>

On 18 November 2012 21:52, Robert P. J. Day <rpjday at crashcourse.ca> wrote:
>
>   perusing the code to see how the final barebox executable is created
> and ran across this opening to include/asm-generic/barebox.lds.h:
>
> #if defined CONFIG_ARCH_IMX25 || \
>         defined CONFIG_ARCH_IMX35 || \
>         defined CONFIG_ARCH_IMX51 || \
>         defined CONFIG_ARCH_IMX53 || \
>         defined CONFIG_ARCH_IMX6 || \
>         defined CONFIG_X86 || \
>         defined CONFIG_ARCH_EP93XX
> #include <mach/barebox.lds.h>
> #endif
>
> #ifndef PRE_IMAGE
> #define PRE_IMAGE
> #endif
>
>   i find that more than a little confusing and inappropriate -- it
> strikes me that the allegedly "generic" lds.h file shouldn't be
> testing for an arbitrary set of inexplicable machine/arch
> combinations, especially when there is absolutely no explanation about
> what makes that particular set of symbols magic with respect to this
> file.
>
>   a minute or two of perusing shows that what it's for is inserting
> some special "pre-image" content into the executable, but that means
> that for each new selection that needs that, this file will have to be
> changed and that's just messy.
>
>   the linux kernel has a simpler strategy for
> asm-generic/vmlinux.lds.h, as you see in this patch snippet that added
> bss first section functionality to that file earlier this year:
>
> +/*
> + * Allow archectures to redefine BSS_FIRST_SECTIONS to add extra
> + * sections to the front of bss.
> + */
> +#ifndef BSS_FIRST_SECTIONS
> +#define BSS_FIRST_SECTIONS
> +#endif
> +
>  #define BSS(bss_align)                                                 \
>         . = ALIGN(bss_align);                                           \
>         .bss : AT(ADDR(.bss) - LOAD_OFFSET) {                           \
> +               BSS_FIRST_SECTIONS                                      \
>                 *(.bss..page_aligned)                                   \
>                 *(.dynbss)                                              \
>                 *(.bss)                                                 \
>
>   that would seem to be a much nicer solution as it pushes the
> selection of pre-image content back to the architectures where it
> belongs.
>
>   the fact that the current approach is prone to "error" can be seen
> in the file arch/mips/lib/barebox.lds.S:
>
> #include <asm-generic/barebox.lds.h>
>
> OUTPUT_ARCH(mips)
> ENTRY(_start)
> SECTIONS
> {
>         . = TEXT_BASE;
>
>         . = ALIGN(4);
>         .text      :
>         {
>                 _start = .;
>                 *(.text_entry*)
>                 _stext = .;
>                 _text = .;
>                 __bare_init_start = .;
>                 *(.text_bare_init*)
>                 __bare_init_end = .;
>                 *(.text*)
>         }
>         BAREBOX_BARE_INIT_SIZE
>
>         PRE_IMAGE  <--- ?????
>
> apparently, the MIPS architecture is including the "PRE_IMAGE"
> content, despite the fact that it can't possibly be defined.  it's not
> wrong, it's just pointless and potentially confusing.

Unfortunately nowadays MIPS lacks lowlevel initialization support.
Yesterday I mailed RFC about pbl (prebootloader) support. It needs
much work, but IMHO after incorporating MIPS pbl support the status of
"PRE_IMAGE" will be more clear.

-- 
Best regards,
  Antony Pavlov


From rpjday at crashcourse.ca  Sun Nov 18 13:24:47 2012
From: rpjday at crashcourse.ca (Robert P. J. Day)
Date: Sun, 18 Nov 2012 13:24:47 -0500 (EST)
Subject: shouldn't asm-generic/barebox.lds.h be arch-independent?
In-Reply-To: <CAA4bVAEpXjiv-DAG=aF9OfmJBOqHZKadr6xpXOznEB6MPdQMkA@mail.gmail.com>
References: <alpine.DEB.2.02.1211181240360.32651@oneiric>
 <CAA4bVAEpXjiv-DAG=aF9OfmJBOqHZKadr6xpXOznEB6MPdQMkA@mail.gmail.com>
Message-ID: <alpine.DEB.2.02.1211181322590.680@oneiric>

On Sun, 18 Nov 2012, Antony Pavlov wrote:

> On 18 November 2012 21:52, Robert P. J. Day <rpjday at crashcourse.ca> wrote:

... snip ...

> >   the fact that the current approach is prone to "error" can be seen
> > in the file arch/mips/lib/barebox.lds.S:
> >
> > #include <asm-generic/barebox.lds.h>
> >
> > OUTPUT_ARCH(mips)
> > ENTRY(_start)
> > SECTIONS
> > {
> >         . = TEXT_BASE;
> >
> >         . = ALIGN(4);
> >         .text      :
> >         {
> >                 _start = .;
> >                 *(.text_entry*)
> >                 _stext = .;
> >                 _text = .;
> >                 __bare_init_start = .;
> >                 *(.text_bare_init*)
> >                 __bare_init_end = .;
> >                 *(.text*)
> >         }
> >         BAREBOX_BARE_INIT_SIZE
> >
> >         PRE_IMAGE  <--- ?????
> >
> > apparently, the MIPS architecture is including the "PRE_IMAGE"
> > content, despite the fact that it can't possibly be defined.
> > it's not wrong, it's just pointless and potentially confusing.
>
> Unfortunately nowadays MIPS lacks lowlevel initialization support.
> Yesterday I mailed RFC about pbl (prebootloader) support. It needs
> much work, but IMHO after incorporating MIPS pbl support the status
> of "PRE_IMAGE" will be more clear.

  ok, but that still doesn't address the bigger issue that the
allegedly "generic" barebox.lds.h file really shouldn't be checking
for individual machines or architectures.  IMHO.

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================


From rpjday at crashcourse.ca  Sun Nov 18 13:31:06 2012
From: rpjday at crashcourse.ca (Robert P. J. Day)
Date: Sun, 18 Nov 2012 13:31:06 -0500 (EST)
Subject: shouldn't asm-generic/barebox.lds.h be arch-independent?
In-Reply-To: <alpine.DEB.2.02.1211181240360.32651@oneiric>
References: <alpine.DEB.2.02.1211181240360.32651@oneiric>
Message-ID: <alpine.DEB.2.02.1211181326250.704@oneiric>


  there is one more oddity(?) with the way the linker "lds" files are
set up.  if i read this correctly (and i could be wrong), here's
arch/x86/lib/barebox.lds.S:

#undef i386
#include <asm-generic/barebox.lds.h>

  which gets us to that included file, which contains:

#if defined CONFIG_ARCH_IMX25 || \
        defined CONFIG_ARCH_IMX35 || \
        defined CONFIG_ARCH_IMX51 || \
        defined CONFIG_ARCH_IMX53 || \
        defined CONFIG_ARCH_IMX6 || \
        defined CONFIG_X86 || \       <-- that will be true, correct?
        defined CONFIG_ARCH_EP93XX
#include <mach/barebox.lds.h>
#endif

  which finally takes us to
arch/x86/mach-i386/include/mach/barebox.lds.h, which is nothing more
than a collection of macro definitions.  there's no "pre-image"
content to be incorporated into the final image -- it's just
preprocessor content.  so why isn't all that simply at the beginning
of the main x86 barebox.lds.S file?

  or am i missing something?

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================


From zzs213 at 126.com  Mon Nov 19 03:18:16 2012
From: zzs213 at 126.com (zzs)
Date: Mon, 19 Nov 2012 16:18:16 +0800
Subject: howto cp to flash
Message-ID: <20121119081815.GA8572@greatfirst.com>

After download zbarebox.bin to /, I wrote it to flash

   tftp barebox.bin
   memcpy -b -s./zbarebox.bin -d/dev/nor0.root 0 0

Then I dump both:

# md -s /dev/nor0.root
00000000: ffffffff ffffffff ffffffff ffffffff                ................
00000010: ffffffff ffffffff ffffffff ffffffff                ................
00000020: ffffffff ffffffff ffffffff ffffffff                ................

# md -s ./zbarebox.bin
00000000: ea00000a eafffffe eafffffe eafffffe                ................
00000010: eafffffe 0000016c eafffffe eafffffe                ....l...........
00000020: 65726162 00786f62 23b00000 0002389c                barebox....#.8..

No contents in flash, Why?

Another question:

How can I get file size in script?

-- 
Best Regards,
zzs




From s.hauer at pengutronix.de  Mon Nov 19 03:20:15 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 19 Nov 2012 09:20:15 +0100
Subject: are there still issues with building sandbox on x86_64?
In-Reply-To: <alpine.DEB.2.02.1211161526150.8404@oneiric>
References: <alpine.DEB.2.02.1211161526150.8404@oneiric>
Message-ID: <20121119082015.GZ10369@pengutronix.de>

On Fri, Nov 16, 2012 at 03:27:55PM -0500, Robert P. J. Day wrote:
> 
>   perusing the page in the wiki discussing sandbox:
> 
> http://wiki.barebox.org/doku.php?id=user:building
> 
> which mentions problems with sandbox on x86_64.  i've had no trouble
> building and running sandbox under ubuntu on my 64-bit asus laptop.
> are there specific known issues?  thanks.

Not that I know of. It should be fine now.

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From franck.jullien at gmail.com  Mon Nov 19 03:24:07 2012
From: franck.jullien at gmail.com (Franck Jullien)
Date: Mon, 19 Nov 2012 09:24:07 +0100
Subject: howto cp to flash
In-Reply-To: <20121119081815.GA8572@greatfirst.com>
References: <20121119081815.GA8572@greatfirst.com>
Message-ID: <CAJfOKByh0QaW_UwoXVztcwR8VmZp8M3w+_95q=xTYYgorTNCxw@mail.gmail.com>

2012/11/19 zzs <zzs213 at 126.com>:
> After download zbarebox.bin to /, I wrote it to flash
>
>    tftp barebox.bin
>    memcpy -b -s./zbarebox.bin -d/dev/nor0.root 0 0
>
> Then I dump both:
>
> # md -s /dev/nor0.root
> 00000000: ffffffff ffffffff ffffffff ffffffff                ................
> 00000010: ffffffff ffffffff ffffffff ffffffff                ................
> 00000020: ffffffff ffffffff ffffffff ffffffff                ................
>
> # md -s ./zbarebox.bin
> 00000000: ea00000a eafffffe eafffffe eafffffe                ................
> 00000010: eafffffe 0000016c eafffffe eafffffe                ....l...........
> 00000020: 65726162 00786f62 23b00000 0002389c                barebox....#.8..
>
> No contents in flash, Why?
>
> Another question:
>
> How can I get file size in script?
>
> --
> Best Regards,
> zzs
>
>
>
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox

Hi,

Did you erase the flash ?
You can also directly do a tftp barebox.bin /dev/nor0.your_partition

Franck.


From zzs213 at 126.com  Mon Nov 19 03:36:22 2012
From: zzs213 at 126.com (zzs)
Date: Mon, 19 Nov 2012 16:36:22 +0800
Subject: howto cp to flash
In-Reply-To: <20121119081815.GA8572@greatfirst.com>
References: <20121119081815.GA8572@greatfirst.com>
Message-ID: <20121119083622.GB8572@greatfirst.com>

I use cp command, the result is same

cp ./zbarebox.bin /dev/nor0.root

md -s /dev/nor0.root
00000000: ffffffff ffffffff ffffffff ffffffff                ................
00000010: ffffffff ffffffff ffffffff ffffffff                ................
00000020: ffffffff ffffffff ffffffff ffffffff                ................

ls /dev/nor0.* -l
crw-------    4849664 /dev/nor0.root
crw-------    3145728 /dev/nor0.kernel
crw-------     131072 /dev/nor0.bareboxenv
crw-------     262144 /dev/nor0.barebox

My flash write OK in u-boot

-- 
Best Regards,
zzs




From s.hauer at pengutronix.de  Mon Nov 19 03:32:21 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 19 Nov 2012 09:32:21 +0100
Subject: shouldn't asm-generic/barebox.lds.h be arch-independent?
In-Reply-To: <alpine.DEB.2.02.1211181326250.704@oneiric>
References: <alpine.DEB.2.02.1211181240360.32651@oneiric>
 <alpine.DEB.2.02.1211181326250.704@oneiric>
Message-ID: <20121119083221.GA10369@pengutronix.de>

On Sun, Nov 18, 2012 at 01:31:06PM -0500, Robert P. J. Day wrote:
> 
>   there is one more oddity(?) with the way the linker "lds" files are
> set up.  if i read this correctly (and i could be wrong), here's
> arch/x86/lib/barebox.lds.S:
> 
> #undef i386
> #include <asm-generic/barebox.lds.h>
> 
>   which gets us to that included file, which contains:
> 
> #if defined CONFIG_ARCH_IMX25 || \
>         defined CONFIG_ARCH_IMX35 || \
>         defined CONFIG_ARCH_IMX51 || \
>         defined CONFIG_ARCH_IMX53 || \
>         defined CONFIG_ARCH_IMX6 || \
>         defined CONFIG_X86 || \       <-- that will be true, correct?
>         defined CONFIG_ARCH_EP93XX
> #include <mach/barebox.lds.h>
> #endif

Instead of having this the users should include asm/barebox.lds.h which
then in turn includes asm-generic/barebox.lds.h.

> 
>   which finally takes us to
> arch/x86/mach-i386/include/mach/barebox.lds.h, which is nothing more
> than a collection of macro definitions.  there's no "pre-image"
> content to be incorporated into the final image -- it's just
> preprocessor content.  so why isn't all that simply at the beginning
> of the main x86 barebox.lds.S file?

I don't know. It should probably be moved there.

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From eric at eukrea.com  Mon Nov 19 03:32:47 2012
From: eric at eukrea.com (Eric =?ISO-8859-1?B?QuluYXJk?=)
Date: Mon, 19 Nov 2012 09:32:47 +0100
Subject: howto cp to flash
In-Reply-To: <20121119081815.GA8572@greatfirst.com>
References: <20121119081815.GA8572@greatfirst.com>
Message-ID: <20121119093247.6ae12da4@eb-e6520>

Hi,

Le Mon, 19 Nov 2012 16:18:16 +0800,
zzs <zzs213 at 126.com> a ?crit :

> After download zbarebox.bin to /, I wrote it to flash
> 
>    tftp barebox.bin
>    memcpy -b -s./zbarebox.bin -d/dev/nor0.root 0 0
> 
this should work :
tftp barebox.bin
unprotect /dev/nor0.root
erase /dev/nor0.root
cp barebox.bin /dev/nor0.root

or with less operations :
unprotect /dev/nor0.root
erase /dev/nor0.root
tftp barebox.bin /dev/nor0.root

Eric


From rpjday at crashcourse.ca  Mon Nov 19 04:12:56 2012
From: rpjday at crashcourse.ca (Robert P. J. Day)
Date: Mon, 19 Nov 2012 04:12:56 -0500 (EST)
Subject: are there still issues with building sandbox on x86_64?
In-Reply-To: <20121119082015.GZ10369@pengutronix.de>
References: <alpine.DEB.2.02.1211161526150.8404@oneiric>
 <20121119082015.GZ10369@pengutronix.de>
Message-ID: <alpine.DEB.2.02.1211190412330.7224@oneiric>

On Mon, 19 Nov 2012, Sascha Hauer wrote:

> On Fri, Nov 16, 2012 at 03:27:55PM -0500, Robert P. J. Day wrote:
> >
> >   perusing the page in the wiki discussing sandbox:
> >
> > http://wiki.barebox.org/doku.php?id=user:building
> >
> > which mentions problems with sandbox on x86_64.  i've had no trouble
> > building and running sandbox under ubuntu on my 64-bit asus laptop.
> > are there specific known issues?  thanks.
>
> Not that I know of. It should be fine now.

  ok, i'll remove the warning about x86_64 from that page.

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================


From s.hauer at pengutronix.de  Mon Nov 19 04:14:31 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 19 Nov 2012 10:14:31 +0100
Subject: [PATCH] mach-imx: Comment typo fix, "enviroment" -> "environment"
In-Reply-To: <alpine.DEB.2.02.1211180828470.17933@oneiric>
References: <alpine.DEB.2.02.1211180828470.17933@oneiric>
Message-ID: <20121119091431.GD10369@pengutronix.de>

On Sun, Nov 18, 2012 at 08:30:44AM -0500, Robert P. J. Day wrote:
> 
> A couple trivial spelling fixes.
> 
> Signed-off-by: Robert P. J. Day <rpjday at crashcourse.ca>

Applied, thanks

Sascha

> 
> ---
> 
>   i thought i'd sent this in already but don't see it in outbox so
> just playing it safe.
> 
> diff --git a/arch/arm/mach-imx/boot.c b/arch/arm/mach-imx/boot.c
> index cdddbe5..ae7c48b 100644
> --- a/arch/arm/mach-imx/boot.c
> +++ b/arch/arm/mach-imx/boot.c
> @@ -77,7 +77,7 @@ static const enum imx_bootsource locations[4][4] = {
>  };
> 
>  /*
> - * Saves the boot source media into the $barebox_loc enviroment variable
> + * Saves the boot source media into the $barebox_loc environment variable
>   *
>   * This information is useful for barebox init scripts as we can then easily
>   * use a kernel image stored on the same media that we launch barebox with
> diff --git a/arch/arm/mach-imx/imx51.c b/arch/arm/mach-imx/imx51.c
> index f5a867b..4b0786b 100644
> --- a/arch/arm/mach-imx/imx51.c
> +++ b/arch/arm/mach-imx/imx51.c
> @@ -75,7 +75,7 @@ static int imx51_init(void)
>  postcore_initcall(imx51_init);
> 
>  /*
> - * Saves the boot source media into the $barebox_loc enviroment variable
> + * Saves the boot source media into the $barebox_loc environment variable
>   *
>   * This information is useful for barebox init scripts as we can then easily
>   * use a kernel image stored on the same media that we launch barebox with
> -- 
> 
> ========================================================================
> Robert P. J. Day                                 Ottawa, Ontario, CANADA
>                         http://crashcourse.ca
> 
> Twitter:                                       http://twitter.com/rpjday
> LinkedIn:                               http://ca.linkedin.com/in/rpjday
> ========================================================================
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Mon Nov 19 04:14:43 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 19 Nov 2012 10:14:43 +0100
Subject: [PATCH] arm lib: Remove redundant boot usage info from boot[uz].c
In-Reply-To: <alpine.DEB.2.02.1211180836390.17973@oneiric>
References: <alpine.DEB.2.02.1211180836390.17973@oneiric>
Message-ID: <20121119091443.GE10369@pengutronix.de>

On Sun, Nov 18, 2012 at 08:39:51AM -0500, Robert P. J. Day wrote:
> 
> There is no need to add the command name to the "usage" info when
> defining a command.
> 
> Signed-off-by: Robert P. J. Day <rpjday at crashcourse.ca>

Applied, thanks

Sascha

> 
> ---
> 
>   fairly sure the command name is superfluous in the usage string,
> yes?
> 
> diff --git a/arch/arm/lib/bootu.c b/arch/arm/lib/bootu.c
> index 0d155cb..75e0de3 100644
> --- a/arch/arm/lib/bootu.c
> +++ b/arch/arm/lib/bootu.c
> @@ -36,7 +36,7 @@ static const __maybe_unused char cmd_bootu_help[] =
> 
>  BAREBOX_CMD_START(bootu)
>  	.cmd            = do_bootu,
> -	.usage          = "bootu - start a raw linux image",
> +	.usage          = "start a raw linux image",
>  	BAREBOX_CMD_HELP(cmd_bootu_help)
>  BAREBOX_CMD_END
> 
> diff --git a/arch/arm/lib/bootz.c b/arch/arm/lib/bootz.c
> index f069127..9f5b3b4 100644
> --- a/arch/arm/lib/bootz.c
> +++ b/arch/arm/lib/bootz.c
> @@ -133,7 +133,7 @@ static const __maybe_unused char cmd_bootz_help[] =
> 
>  BAREBOX_CMD_START(bootz)
>  	.cmd            = do_bootz,
> -	.usage          = "bootz - start a zImage",
> +	.usage          = "start a zImage",
>  	BAREBOX_CMD_HELP(cmd_bootz_help)
>  BAREBOX_CMD_END
> 
> 
> -- 
> 
> ========================================================================
> Robert P. J. Day                                 Ottawa, Ontario, CANADA
>                         http://crashcourse.ca
> 
> Twitter:                                       http://twitter.com/rpjday
> LinkedIn:                               http://ca.linkedin.com/in/rpjday
> ========================================================================
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Mon Nov 19 04:16:36 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 19 Nov 2012 10:16:36 +0100
Subject: [PATCH] bareboxenv.c: simple grammatical fix
In-Reply-To: <alpine.DEB.2.02.1211161745310.10167@oneiric>
References: <alpine.DEB.2.02.1211161745310.10167@oneiric>
Message-ID: <20121119091636.GF10369@pengutronix.de>

On Fri, Nov 16, 2012 at 05:45:38PM -0500, Robert P. J. Day wrote:
> 
> Signed-off-by: Robert P. J. Day <rpjday at crashcourse.ca>

Applied, thanks

Sascha

> 
> ---
> 
> diff --git a/scripts/bareboxenv.c b/scripts/bareboxenv.c
> index f44a1f8..5fdc62e 100644
> --- a/scripts/bareboxenv.c
> +++ b/scripts/bareboxenv.c
> @@ -124,8 +124,8 @@ char *concat_subpath_file(const char *path, const char *f)
>  void usage(char *prgname)
>  {
>  	printf( "Usage : %s [OPTION] DIRECTORY FILE\n"
> -		"Load an barebox environment sector into a directory or\n"
> -		"save a directory into an barebox environment sector\n"
> +		"Load a barebox environment sector into a directory or\n"
> +		"save a directory into a barebox environment sector\n"
>  		"\n"
>  		"options:\n"
>  		"  -s        save (directory -> environment sector)\n"
> 
> -- 
> 
> ========================================================================
> Robert P. J. Day                                 Ottawa, Ontario, CANADA
>                         http://crashcourse.ca
> 
> Twitter:                                       http://twitter.com/rpjday
> LinkedIn:                               http://ca.linkedin.com/in/rpjday
> ========================================================================
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Mon Nov 19 04:17:04 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 19 Nov 2012 10:17:04 +0100
Subject: [PATCH] MIPS: main_entry.c: fix typo
In-Reply-To: <1353144223-9047-1-git-send-email-antonynpavlov@gmail.com>
References: <1353144223-9047-1-git-send-email-antonynpavlov@gmail.com>
Message-ID: <20121119091704.GG10369@pengutronix.de>

On Sat, Nov 17, 2012 at 01:23:43PM +0400, Antony Pavlov wrote:
> Signed-off-by: Antony Pavlov <antonynpavlov at gmail.com>

Applied, thanks

Sascha

> ---
>  arch/mips/boot/main_entry.c |    1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/arch/mips/boot/main_entry.c b/arch/mips/boot/main_entry.c
> index c221288..0a33c45 100644
> --- a/arch/mips/boot/main_entry.c
> +++ b/arch/mips/boot/main_entry.c
> @@ -14,7 +14,6 @@
>   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>   * GNU General Public License for more details.
>   *
> - *
>   */
>  
>  #include <common.h>
> -- 
> 1.7.10.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Mon Nov 19 04:20:46 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 19 Nov 2012 10:20:46 +0100
Subject: [PATCH 1/1] at91sam9260ek: specify mach entry
In-Reply-To: <1353086393-16213-1-git-send-email-plagnioj@jcrosoft.com>
References: <1353086393-16213-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <20121119092046.GH10369@pengutronix.de>

On Fri, Nov 16, 2012 at 06:19:50PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> as the sam9260ek may not be the first one in the list
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
> ---
>  arch/arm/configs/at91sam9260ek_defconfig |    1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch/arm/configs/at91sam9260ek_defconfig b/arch/arm/configs/at91sam9260ek_defconfig
> index b746bc8..9c5c7d5 100644
> --- a/arch/arm/configs/at91sam9260ek_defconfig
> +++ b/arch/arm/configs/at91sam9260ek_defconfig
> @@ -1,4 +1,5 @@
>  CONFIG_ARCH_AT91SAM9260=y
> +CONFIG_MACH_AT91SAM9260EK=y

Won't this be removed again when we regenerate this file with make
safedefconfig? It seems a bit fragile to keep this change manually. I
have no good idea how to do this better though.


Applied the rest of this series for now.

Sascha

>  CONFIG_AEABI=y
>  # CONFIG_CMD_ARM_CPUINFO is not set
>  CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y
> -- 
> 1.7.10.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Mon Nov 19 04:36:13 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 19 Nov 2012 10:36:13 +0100
Subject: [PATCH 2/7] watchdog: add at91sam9 watchdog support
In-Reply-To: <1353088545-19406-2-git-send-email-plagnioj@jcrosoft.com>
References: <20121116175355.GB8327@game.jcrosoft.org>
 <1353088545-19406-1-git-send-email-plagnioj@jcrosoft.com>
 <1353088545-19406-2-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <20121119093613.GI10369@pengutronix.de>

On Fri, Nov 16, 2012 at 06:55:40PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> with keep alive support
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
> ---
>  drivers/watchdog/Kconfig        |    7 +++
>  drivers/watchdog/Makefile       |    1 +
>  drivers/watchdog/at91sam9_wdt.c |  131 +++++++++++++++++++++++++++++++++++++++
>  drivers/watchdog/at91sam9_wdt.h |   38 ++++++++++++
>  4 files changed, 177 insertions(+)
>  create mode 100644 drivers/watchdog/at91sam9_wdt.c
>  create mode 100644 drivers/watchdog/at91sam9_wdt.h
> 
> diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
> index 21480a1..5bd1083 100644
> --- a/drivers/watchdog/Kconfig
> +++ b/drivers/watchdog/Kconfig
> @@ -7,6 +7,13 @@ menuconfig WATCHDOG
>  
>  if WATCHDOG
>  
> +config WATCHDOG_AT91SAM9X
> +	tristate "AT91SAM9X / AT91CAP9 watchdog"
> +	depends on ARCH_AT91
> +	help
> +	  Watchdog timer embedded into AT91SAM9X and AT91CAP9 chips. This will
> +	  reboot your system when the timeout is reached.
> +
>  config WATCHDOG_MXS28
>  	bool "i.MX28"
>  	depends on ARCH_IMX28
> diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
> index b29103b..4e863a5 100644
> --- a/drivers/watchdog/Makefile
> +++ b/drivers/watchdog/Makefile
> @@ -1,2 +1,3 @@
>  obj-$(CONFIG_WATCHDOG) += wd_core.o
> +obj-$(CONFIG_WATCHDOG_AT91SAM9X) += at91sam9_wdt.o
>  obj-$(CONFIG_WATCHDOG_MXS28) += im28wd.o
> diff --git a/drivers/watchdog/at91sam9_wdt.c b/drivers/watchdog/at91sam9_wdt.c
> new file mode 100644
> index 0000000..203d83a
> --- /dev/null
> +++ b/drivers/watchdog/at91sam9_wdt.c
> @@ -0,0 +1,131 @@
> +/*
> + * (c) 2012 Juergen Beisert <kernel at pengutronix.de>

Juergen Beisert?

> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * Note: this driver works for the i.MX28 SoC. It might work for the
> + * i.MX23 Soc as well, but is not tested yet.

This might work on i.MX23?

> +
> +static void at91sam9_wdt_keep_alive(struct watchdog *wdt)
> +{
> +	struct at91sam9_wdt *at91wdt = to_at91sam9_wdt(wdt);
> +
> +	wdt_write(at91wdt, AT91_WDT_CR, AT91_WDT_KEY | AT91_WDT_WDRSTT);
> +}
> +
> +static int at91sam9_wdt_settimeout(struct watchdog *wdt, unsigned int timeout)
> +{
> +	struct at91sam9_wdt *at91wdt = to_at91sam9_wdt(wdt);
> +	unsigned int reg;
> +	unsigned int mr;
> +
> +	/* Check if disabled */
> +	mr = wdt_read(at91wdt, AT91_WDT_MR);
> +	if (mr & AT91_WDT_WDDIS) {
> +		pr_err("sorry, watchdog is disabled\n");
> +		return -EIO;
> +	}
> +
> +	if (!timeout) {
> +		wdt_write(at91wdt, AT91_WDT_MR, AT91_WDT_WDDIS);
> +		return 0;
> +	}
> +
> +	/*
> +	 * All counting occurs at SLOW_CLOCK / 128 = 256 Hz
> +	 *
> +	 * Since WDV is a 12-bit counter, the maximum period is
> +	 * 4096 / 256 = 16 seconds.
> +	 */
> +	reg = AT91_WDT_WDRSTEN	/* causes watchdog reset */
> +		/* | AT91_WDT_WDRPROC	causes processor reset only */
> +		| AT91_WDT_WDDBGHLT	/* disabled in debug mode */
> +		| AT91_WDT_WDD		/* restart at any time */
> +		| (timeout & AT91_WDT_WDV);  /* timer value */
> +	wdt_write(at91wdt, AT91_WDT_MR, reg);

This driver does not work like the watchdog API is supposed to work. It
currently works in the way that the watchdog command calls the
settimeout callback to keep the watchdog alive, hence we do not need
an explicit keepalive callback. Whether this API is good is debatable,
but this patch violates it and renders the watchdog command useless.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Mon Nov 19 04:38:44 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 19 Nov 2012 10:38:44 +0100
Subject: [PATCH 1/7] watchdog: add keep alive support
In-Reply-To: <1353088545-19406-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121116175355.GB8327@game.jcrosoft.org>
 <1353088545-19406-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <20121119093844.GJ10369@pengutronix.de>

On Fri, Nov 16, 2012 at 06:55:39PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> this will allow to ping the watchdog via poller
> 
>  /*
>   * Note: this simple framework supports one watchdog only.
>   */
>  static struct watchdog *watchdog;
>  
> +static void watchdog_poller_func(struct poller_struct *poller)
> +{
> +	watchdog->keep_alive(watchdog);
> +}
> +
> +static struct poller_struct watchdog_poller = {
> +	.func = watchdog_poller_func,
> +};
> +
>  int watchdog_register(struct watchdog *wd)
>  {
>  	if (watchdog != NULL)
>  		return -EBUSY;
>  
>  	watchdog = wd;
> +
> +	if (watchdog->keep_alive) {
> +		int ret;
> +
> +		ret = poller_register(&watchdog_poller);
> +		if (ret) {
> +			watchdog = NULL;
> +			return ret;
> +		}
> +	}

Currently the watchdog is supposed to be kept alive with periodically
calling the watchdog (or wd) command. A user may decide to just
periodically ping the watchdog from C code, but this should be a users
decision (i.e. some enhancement to the wd command) and should be
available for i.MX aswell.

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Mon Nov 19 04:41:01 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 19 Nov 2012 10:41:01 +0100
Subject: is there a standard for putting the name of a source file in the
 file?
In-Reply-To: <alpine.DEB.2.02.1211181139290.32036@oneiric>
References: <alpine.DEB.2.02.1211180844430.18098@oneiric>
 <20121118162637.GF8327@game.jcrosoft.org>
 <alpine.DEB.2.02.1211181139290.32036@oneiric>
Message-ID: <20121119094101.GK10369@pengutronix.de>

On Sun, Nov 18, 2012 at 11:39:48AM -0500, Robert P. J. Day wrote:
> On Sun, 18 Nov 2012, Jean-Christophe PLAGNIOL-VILLARD wrote:
> 
> > On 08:48 Sun 18 Nov     , Robert P. J. Day wrote:
> > >
> > >   as i'm working my way thru the lib/ routines in barebox, i notice
> > > that some source files there, like getopt.c, conveniently have the
> > > filename right at the top:
> > >
> > > /*
> > >  * getopt.c - a simple getopt(3) implementation. See getopt.h for explanation.
> > > ...
> > >
> > > i really like this habit as it makes it easy to send a file to the
> > > printer and not forget what the file was.
> > >
> > >   however, most of the files in lib/ don't have that.  as i work my
> > > way through the files, i'd be happy to add something like that to each
> > > file, and submit the changes all as one patch.  is there a standard?
> > > from what i can see, there's quite the variety in how people add that
> > > to a source file.
> > >
> > >   i'm open to guidance and i can take it from there.
> > no this is a pain in the ass to maintian when we move file
> >
> > I' drop it and I'm against it
> 
>   ok, that logic makes sense, i'm good with that.

Me aswell. Tools like a2ps also print the filename ;)

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From rpjday at crashcourse.ca  Mon Nov 19 04:46:29 2012
From: rpjday at crashcourse.ca (Robert P. J. Day)
Date: Mon, 19 Nov 2012 04:46:29 -0500 (EST)
Subject: is there a standard for putting the name of a source file in
 the file?
In-Reply-To: <20121119094101.GK10369@pengutronix.de>
References: <alpine.DEB.2.02.1211180844430.18098@oneiric>
 <20121118162637.GF8327@game.jcrosoft.org>
 <alpine.DEB.2.02.1211181139290.32036@oneiric>
 <20121119094101.GK10369@pengutronix.de>
Message-ID: <alpine.DEB.2.02.1211190445360.7567@oneiric>

On Mon, 19 Nov 2012, Sascha Hauer wrote:

> On Sun, Nov 18, 2012 at 11:39:48AM -0500, Robert P. J. Day wrote:
> > On Sun, 18 Nov 2012, Jean-Christophe PLAGNIOL-VILLARD wrote:
> >
> > > On 08:48 Sun 18 Nov     , Robert P. J. Day wrote:
> > > >
> > > >   as i'm working my way thru the lib/ routines in barebox, i notice
> > > > that some source files there, like getopt.c, conveniently have the
> > > > filename right at the top:
> > > >
> > > > /*
> > > >  * getopt.c - a simple getopt(3) implementation. See getopt.h for explanation.
> > > > ...
> > > >
> > > > i really like this habit as it makes it easy to send a file to the
> > > > printer and not forget what the file was.
> > > >
> > > >   however, most of the files in lib/ don't have that.  as i work my
> > > > way through the files, i'd be happy to add something like that to each
> > > > file, and submit the changes all as one patch.  is there a standard?
> > > > from what i can see, there's quite the variety in how people add that
> > > > to a source file.
> > > >
> > > >   i'm open to guidance and i can take it from there.
> > > no this is a pain in the ass to maintian when we move file
> > >
> > > I' drop it and I'm against it
> >
> >   ok, that logic makes sense, i'm good with that.
>
> Me aswell. Tools like a2ps also print the filename ;)

  yes, i agree, it was a silly idea, i only brought it up since some
of the files under lib/ were doing that and some weren't and i didn't
know if there was a standard of some kind.  movin' on ...

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================


From plagnioj at jcrosoft.com  Mon Nov 19 04:56:11 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Mon, 19 Nov 2012 10:56:11 +0100
Subject: [PATCH 1/1] at91sam9260ek: specify mach entry
In-Reply-To: <20121119092046.GH10369@pengutronix.de>
References: <1353086393-16213-1-git-send-email-plagnioj@jcrosoft.com>
 <20121119092046.GH10369@pengutronix.de>
Message-ID: <20121119095611.GG8327@game.jcrosoft.org>

On 10:20 Mon 19 Nov     , Sascha Hauer wrote:
> 
> On Fri, Nov 16, 2012 at 06:19:50PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > as the sam9260ek may not be the first one in the list
> > 
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
> > ---
> >  arch/arm/configs/at91sam9260ek_defconfig |    1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/arch/arm/configs/at91sam9260ek_defconfig b/arch/arm/configs/at91sam9260ek_defconfig
> > index b746bc8..9c5c7d5 100644
> > --- a/arch/arm/configs/at91sam9260ek_defconfig
> > +++ b/arch/arm/configs/at91sam9260ek_defconfig
> > @@ -1,4 +1,5 @@
> >  CONFIG_ARCH_AT91SAM9260=y
> > +CONFIG_MACH_AT91SAM9260EK=y
> 
> Won't this be removed again when we regenerate this file with make
> safedefconfig? It seems a bit fragile to keep this change manually. I
> have no good idea how to do this better though.
> 
the isssue that I'm going to add a new board that will be named animeo-ip

so the at91sam9260ek will be broken as it will be configured as the animeo-ip

Best Regards,
J.
> 
> Applied the rest of this series for now.
> 
> Sascha
> 
> >  CONFIG_AEABI=y
> >  # CONFIG_CMD_ARM_CPUINFO is not set
> >  CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y
> > -- 
> > 1.7.10.4
> > 
> > 
> > _______________________________________________
> > barebox mailing list
> > barebox at lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/barebox
> > 
> 
> -- 
> Pengutronix e.K.                           |                             |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From plagnioj at jcrosoft.com  Mon Nov 19 04:59:29 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Mon, 19 Nov 2012 10:59:29 +0100
Subject: [PATCH 2/7] watchdog: add at91sam9 watchdog support
In-Reply-To: <20121119093613.GI10369@pengutronix.de>
References: <20121116175355.GB8327@game.jcrosoft.org>
 <1353088545-19406-1-git-send-email-plagnioj@jcrosoft.com>
 <1353088545-19406-2-git-send-email-plagnioj@jcrosoft.com>
 <20121119093613.GI10369@pengutronix.de>
Message-ID: <20121119095929.GH8327@game.jcrosoft.org>

On 10:36 Mon 19 Nov     , Sascha Hauer wrote:
> 
> On Fri, Nov 16, 2012 at 06:55:40PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > with keep alive support
> > 
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
> > ---
> >  drivers/watchdog/Kconfig        |    7 +++
> >  drivers/watchdog/Makefile       |    1 +
> >  drivers/watchdog/at91sam9_wdt.c |  131 +++++++++++++++++++++++++++++++++++++++
> >  drivers/watchdog/at91sam9_wdt.h |   38 ++++++++++++
> >  4 files changed, 177 insertions(+)
> >  create mode 100644 drivers/watchdog/at91sam9_wdt.c
> >  create mode 100644 drivers/watchdog/at91sam9_wdt.h
> > 
> > diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
> > index 21480a1..5bd1083 100644
> > --- a/drivers/watchdog/Kconfig
> > +++ b/drivers/watchdog/Kconfig
> > @@ -7,6 +7,13 @@ menuconfig WATCHDOG
> >  
> >  if WATCHDOG
> >  
> > +config WATCHDOG_AT91SAM9X
> > +	tristate "AT91SAM9X / AT91CAP9 watchdog"
> > +	depends on ARCH_AT91
> > +	help
> > +	  Watchdog timer embedded into AT91SAM9X and AT91CAP9 chips. This will
> > +	  reboot your system when the timeout is reached.
> > +
> >  config WATCHDOG_MXS28
> >  	bool "i.MX28"
> >  	depends on ARCH_IMX28
> > diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
> > index b29103b..4e863a5 100644
> > --- a/drivers/watchdog/Makefile
> > +++ b/drivers/watchdog/Makefile
> > @@ -1,2 +1,3 @@
> >  obj-$(CONFIG_WATCHDOG) += wd_core.o
> > +obj-$(CONFIG_WATCHDOG_AT91SAM9X) += at91sam9_wdt.o
> >  obj-$(CONFIG_WATCHDOG_MXS28) += im28wd.o
> > diff --git a/drivers/watchdog/at91sam9_wdt.c b/drivers/watchdog/at91sam9_wdt.c
> > new file mode 100644
> > index 0000000..203d83a
> > --- /dev/null
> > +++ b/drivers/watchdog/at91sam9_wdt.c
> > @@ -0,0 +1,131 @@
> > +/*
> > + * (c) 2012 Juergen Beisert <kernel at pengutronix.de>
> 
> Juergen Beisert?
> 
> > + *
> > + * This program is free software; you can redistribute it and/or modify
> > + * it under the terms of the GNU General Public License as published by
> > + * the Free Software Foundation; either version 2 of the License, or
> > + * (at your option) any later version.
> > + *
> > + * This program is distributed in the hope that it will be useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > + * GNU General Public License for more details.
> > + *
> > + * Note: this driver works for the i.MX28 SoC. It might work for the
> > + * i.MX23 Soc as well, but is not tested yet.
> 
> This might work on i.MX23?
> 
> > +
> > +static void at91sam9_wdt_keep_alive(struct watchdog *wdt)
> > +{
> > +	struct at91sam9_wdt *at91wdt = to_at91sam9_wdt(wdt);
> > +
> > +	wdt_write(at91wdt, AT91_WDT_CR, AT91_WDT_KEY | AT91_WDT_WDRSTT);
> > +}
> > +
> > +static int at91sam9_wdt_settimeout(struct watchdog *wdt, unsigned int timeout)
> > +{
> > +	struct at91sam9_wdt *at91wdt = to_at91sam9_wdt(wdt);
> > +	unsigned int reg;
> > +	unsigned int mr;
> > +
> > +	/* Check if disabled */
> > +	mr = wdt_read(at91wdt, AT91_WDT_MR);
> > +	if (mr & AT91_WDT_WDDIS) {
> > +		pr_err("sorry, watchdog is disabled\n");
> > +		return -EIO;
> > +	}
> > +
> > +	if (!timeout) {
> > +		wdt_write(at91wdt, AT91_WDT_MR, AT91_WDT_WDDIS);
> > +		return 0;
> > +	}
> > +
> > +	/*
> > +	 * All counting occurs at SLOW_CLOCK / 128 = 256 Hz
> > +	 *
> > +	 * Since WDV is a 12-bit counter, the maximum period is
> > +	 * 4096 / 256 = 16 seconds.
> > +	 */
> > +	reg = AT91_WDT_WDRSTEN	/* causes watchdog reset */
> > +		/* | AT91_WDT_WDRPROC	causes processor reset only */
> > +		| AT91_WDT_WDDBGHLT	/* disabled in debug mode */
> > +		| AT91_WDT_WDD		/* restart at any time */
> > +		| (timeout & AT91_WDT_WDV);  /* timer value */
> > +	wdt_write(at91wdt, AT91_WDT_MR, reg);
> 
> This driver does not work like the watchdog API is supposed to work. It
> currently works in the way that the watchdog command calls the
> settimeout callback to keep the watchdog alive, hence we do not need
> an explicit keepalive callback. Whether this API is good is debatable,
> but this patch violates it and renders the watchdog command useless.
The watchdod commad just need to enable the watchdog/change the timeout or
diabled 

the rest need to be automatic

so we need to fix the API

because I can not add wd command in long nfs or tftp transfert

Best Regards,
J.


From s.hauer at pengutronix.de  Mon Nov 19 05:05:44 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 19 Nov 2012 11:05:44 +0100
Subject: howto cp to flash
In-Reply-To: <20121119083622.GB8572@greatfirst.com>
References: <20121119081815.GA8572@greatfirst.com>
 <20121119083622.GB8572@greatfirst.com>
Message-ID: <20121119100544.GM10369@pengutronix.de>

On Mon, Nov 19, 2012 at 04:36:22PM +0800, zzs wrote:
> I use cp command, the result is same
> 
> cp ./zbarebox.bin /dev/nor0.root
> 
> md -s /dev/nor0.root
> 00000000: ffffffff ffffffff ffffffff ffffffff                ................
> 00000010: ffffffff ffffffff ffffffff ffffffff                ................
> 00000020: ffffffff ffffffff ffffffff ffffffff                ................

Have you tried the unprotect command like Eric suggested?

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Mon Nov 19 05:08:29 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 19 Nov 2012 11:08:29 +0100
Subject: [PATCH] i.MX25 & 35 usb config bits : fix host power bit
In-Reply-To: <1353100606.3647.40.camel@mars>
References: <1353100606.3647.40.camel@mars>
Message-ID: <20121119100829.GN10369@pengutronix.de>

On Fri, Nov 16, 2012 at 10:16:46PM +0100, Christoph Fritz wrote:
> This patch sets HPM (Host power mask bit) to bit 16 according to i.MX
> Reference Manual. Falsely it was set to bit 8, but this controls pull-up
> Impedance.
> 
> Reported-by: Michael Burkey <mdburkey at gmail.com>
> Signed-off-by: Christoph Fritz <chf.fritz at googlemail.com>

Applied, thanks

Sascha

> ---
>  arch/arm/mach-imx/include/mach/usb.h |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm/mach-imx/include/mach/usb.h b/arch/arm/mach-imx/include/mach/usb.h
> index 9244989..0a88e7f 100644
> --- a/arch/arm/mach-imx/include/mach/usb.h
> +++ b/arch/arm/mach-imx/include/mach/usb.h
> @@ -4,7 +4,7 @@
>  /* configuration bits for i.MX25 and i.MX35 */
>  #define MX35_H1_SIC_SHIFT	21
>  #define MX35_H1_SIC_MASK	(0x3 << MX35_H1_SIC_SHIFT)
> -#define MX35_H1_PM_BIT		(1 << 8)
> +#define MX35_H1_PM_BIT		(1 << 16)
>  #define MX35_H1_IPPUE_UP_BIT	(1 << 7)
>  #define MX35_H1_IPPUE_DOWN_BIT	(1 << 6)
>  #define MX35_H1_TLL_BIT		(1 << 5)
> -- 
> 1.7.10.4
> 
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From plagnioj at jcrosoft.com  Mon Nov 19 05:08:02 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Mon, 19 Nov 2012 11:08:02 +0100
Subject: [PATCH 1/7] watchdog: add keep alive support
In-Reply-To: <20121119093844.GJ10369@pengutronix.de>
References: <20121116175355.GB8327@game.jcrosoft.org>
 <1353088545-19406-1-git-send-email-plagnioj@jcrosoft.com>
 <20121119093844.GJ10369@pengutronix.de>
Message-ID: <20121119100802.GI8327@game.jcrosoft.org>

On 10:38 Mon 19 Nov     , Sascha Hauer wrote:
> 
> On Fri, Nov 16, 2012 at 06:55:39PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > this will allow to ping the watchdog via poller
> > 
> >  /*
> >   * Note: this simple framework supports one watchdog only.
> >   */
> >  static struct watchdog *watchdog;
> >  
> > +static void watchdog_poller_func(struct poller_struct *poller)
> > +{
> > +	watchdog->keep_alive(watchdog);
> > +}
> > +
> > +static struct poller_struct watchdog_poller = {
> > +	.func = watchdog_poller_func,
> > +};
> > +
> >  int watchdog_register(struct watchdog *wd)
> >  {
> >  	if (watchdog != NULL)
> >  		return -EBUSY;
> >  
> >  	watchdog = wd;
> > +
> > +	if (watchdog->keep_alive) {
> > +		int ret;
> > +
> > +		ret = poller_register(&watchdog_poller);
> > +		if (ret) {
> > +			watchdog = NULL;
> > +			return ret;
> > +		}
> > +	}
> 
> Currently the watchdog is supposed to be kept alive with periodically
> calling the watchdog (or wd) command. A user may decide to just
> periodically ping the watchdog from C code, but this should be a users
> decision (i.e. some enhancement to the wd command) and should be
> available for i.MX aswell.

no this is broken

this should be completly automatic I agree that the user need to control it

we are not going to add 100s of call in barebox for this

like did U-Boot

Barebox need to ping the wtach automticly via poler
and manage soft timeout

as some watchdog have short timeout so this will make the soft tiemout (user
timeout) hw indepedant as in linux

Best Regards,
J.


From s.hauer at pengutronix.de  Mon Nov 19 05:24:26 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 19 Nov 2012 11:24:26 +0100
Subject: [PATCH 1/1] at91sam9260ek: specify mach entry
In-Reply-To: <20121119095611.GG8327@game.jcrosoft.org>
References: <1353086393-16213-1-git-send-email-plagnioj@jcrosoft.com>
 <20121119092046.GH10369@pengutronix.de>
 <20121119095611.GG8327@game.jcrosoft.org>
Message-ID: <20121119102426.GP10369@pengutronix.de>

On Mon, Nov 19, 2012 at 10:56:11AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 10:20 Mon 19 Nov     , Sascha Hauer wrote:
> > 
> > On Fri, Nov 16, 2012 at 06:19:50PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > as the sam9260ek may not be the first one in the list
> > > 
> > > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
> > > ---
> > >  arch/arm/configs/at91sam9260ek_defconfig |    1 +
> > >  1 file changed, 1 insertion(+)
> > > 
> > > diff --git a/arch/arm/configs/at91sam9260ek_defconfig b/arch/arm/configs/at91sam9260ek_defconfig
> > > index b746bc8..9c5c7d5 100644
> > > --- a/arch/arm/configs/at91sam9260ek_defconfig
> > > +++ b/arch/arm/configs/at91sam9260ek_defconfig
> > > @@ -1,4 +1,5 @@
> > >  CONFIG_ARCH_AT91SAM9260=y
> > > +CONFIG_MACH_AT91SAM9260EK=y
> > 
> > Won't this be removed again when we regenerate this file with make
> > safedefconfig? It seems a bit fragile to keep this change manually. I
> > have no good idea how to do this better though.
> > 
> the isssue that I'm going to add a new board that will be named animeo-ip
> 
> so the at91sam9260ek will be broken as it will be configured as the animeo-ip

Can you resend this patch then along with the animeo-ip patches? At that
point we can be sure that the next at91sam9260ek config generated with
make savedefconfig will be correct.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Mon Nov 19 05:26:23 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 19 Nov 2012 11:26:23 +0100
Subject: [PATCH 1/1] led-gpio: add bicolor led support
In-Reply-To: <1353097043-31250-1-git-send-email-plagnioj@jcrosoft.com>
References: <1353097043-31250-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <20121119102623.GQ10369@pengutronix.de>

On Fri, Nov 16, 2012 at 09:17:23PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> those led can have 2 colors but one at a time otherwise they are black
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>

Applied, thanks

Sascha

> ---
>  drivers/led/Kconfig    |    4 ++++
>  drivers/led/led-gpio.c |   47 +++++++++++++++++++++++++++++++++++++++++++++++
>  include/led.h          |   20 ++++++++++++++++++++
>  3 files changed, 71 insertions(+)
> 
> diff --git a/drivers/led/Kconfig b/drivers/led/Kconfig
> index 106093b..8ca6ab8 100644
> --- a/drivers/led/Kconfig
> +++ b/drivers/led/Kconfig
> @@ -11,6 +11,10 @@ config LED_GPIO_RGB
>  	bool "gpio rgb LED support"
>  	depends on LED_GPIO
>  
> +config LED_GPIO_BICOLOR
> +	bool "gpio bicolor LED support"
> +	depends on LED_GPIO
> +
>  config LED_TRIGGERS
>  	select POLLER
>  	bool "LED triggers support"
> diff --git a/drivers/led/led-gpio.c b/drivers/led/led-gpio.c
> index 711146b..c78ef9e 100644
> --- a/drivers/led/led-gpio.c
> +++ b/drivers/led/led-gpio.c
> @@ -52,6 +52,53 @@ void led_gpio_unregister(struct gpio_led *led)
>  	led_unregister(&led->led);
>  }
>  
> +#ifdef CONFIG_LED_GPIO_BICOLOR
> +static void led_gpio_bicolor_set(struct led *led, unsigned int value)
> +{
> +	struct gpio_bicolor_led *bi = container_of(led, struct gpio_bicolor_led, led);
> +	int al = bi->active_low;
> +
> +	switch (value) {
> +	case 0:
> +		gpio_direction_output(bi->gpio_c0, al);
> +		gpio_direction_output(bi->gpio_c1, al);
> +		break;
> +	case 1:
> +		gpio_direction_output(bi->gpio_c0, !al);
> +		gpio_direction_output(bi->gpio_c1, al);
> +		break;
> +	case 2:
> +		gpio_direction_output(bi->gpio_c0, al);
> +		gpio_direction_output(bi->gpio_c1, !al);
> +		break;
> +	}
> +}
> +
> +/**
> + * led_gpio_bicolor_register - register three gpios as a bicolor LED
> + * @param led	The gpio bicolor LED
> + *
> + * This function registers three gpios as a bicolor LED. led->gpio[rg]
> + * should be initialized to the gpios to control.
> + */
> +int led_gpio_bicolor_register(struct gpio_bicolor_led *led)
> +{
> +	led->led.set = led_gpio_bicolor_set;
> +	led->led.max_value = 2;
> +
> +	return led_register(&led->led);
> +}
> +
> +/**
> + * led_gpio_bicolor_unregister - remove a gpio controlled bicolor LED from the framework
> + * @param led	The gpio LED
> + */
> +void led_gpio_bicolor_unregister(struct gpio_bicolor_led *led)
> +{
> +	led_unregister(&led->led);
> +}
> +#endif
> +
>  #ifdef CONFIG_LED_GPIO_RGB
>  
>  static void led_gpio_rgb_set(struct led *led, unsigned int value)
> diff --git a/include/led.h b/include/led.h
> index 9ec1f0d..dd551fe 100644
> --- a/include/led.h
> +++ b/include/led.h
> @@ -65,6 +65,12 @@ struct gpio_led {
>  	struct led led;
>  };
>  
> +struct gpio_bicolor_led {
> +	int gpio_c0, gpio_c1;
> +	bool active_low;
> +	struct led led;
> +};
> +
>  struct gpio_rgb_led {
>  	int gpio_r, gpio_g, gpio_b;
>  	bool active_low;
> @@ -85,6 +91,20 @@ static inline void led_gpio_unregister(struct gpio_led *led)
>  }
>  #endif
>  
> +#ifdef CONFIG_LED_GPIO_BICOLOR
> +int led_gpio_bicolor_register(struct gpio_bicolor_led *led);
> +void led_gpio_bicolor_unregister(struct gpio_bicolor_led *led);
> +#else
> +static inline int led_gpio_bicolor_register(struct gpio_bicolor_led *led)
> +{
> +	return -ENOSYS;
> +}
> +
> +static inline void led_gpio_bicolor_unregister(struct gpio_bicolor_led *led)
> +{
> +}
> +#endif
> +
>  #ifdef CONFIG_LED_GPIO_RGB
>  int led_gpio_rgb_register(struct gpio_rgb_led *led);
>  void led_gpio_rgb_unregister(struct gpio_led *led);
> -- 
> 1.7.10.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Mon Nov 19 05:30:37 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 19 Nov 2012 11:30:37 +0100
Subject: [PATCH 3/3] ARM: start-pbl.c: unificate path to lib/decompress_*.c
In-Reply-To: <1353144361-9089-4-git-send-email-antonynpavlov@gmail.com>
References: <1353144361-9089-1-git-send-email-antonynpavlov@gmail.com>
 <1353144361-9089-4-git-send-email-antonynpavlov@gmail.com>
Message-ID: <20121119103037.GR10369@pengutronix.de>

On Sat, Nov 17, 2012 at 01:26:01PM +0400, Antony Pavlov wrote:
> Signed-off-by: Antony Pavlov <antonynpavlov at gmail.com>
> ---
>  arch/arm/cpu/start-pbl.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm/cpu/start-pbl.c b/arch/arm/cpu/start-pbl.c
> index 79a3cdd..c5f9705 100644
> --- a/arch/arm/cpu/start-pbl.c
> +++ b/arch/arm/cpu/start-pbl.c
> @@ -66,7 +66,7 @@ extern void *input_data_end;
>  #endif
>  
>  #ifdef CONFIG_IMAGE_COMPRESSION_GZIP
> -#include "../../../../lib/decompress_inflate.c"
> +#include "../../../lib/decompress_inflate.c"

This is strange. Why did this work beforehand?

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Mon Nov 19 05:32:12 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 19 Nov 2012 11:32:12 +0100
Subject: [PATCH] imx53: implement imx53_add_kpp
In-Reply-To: <1352976671-17492-1-git-send-email-christian.kapeller@cmotion.eu>
References: <1352976671-17492-1-git-send-email-christian.kapeller@cmotion.eu>
Message-ID: <20121119103212.GS10369@pengutronix.de>

On Thu, Nov 15, 2012 at 11:51:11AM +0100, Christian Kapeller wrote:
> Allows usage of imx keypad driver in imx53 platforms

Applied, thanks

Sascha

> 
> ---
>  arch/arm/mach-imx/include/mach/devices-imx53.h |    5 +++++
>  1 files changed, 5 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/arm/mach-imx/include/mach/devices-imx53.h b/arch/arm/mach-imx/include/mach/devices-imx53.h
> index 5f967ea..6692396 100644
> --- a/arch/arm/mach-imx/include/mach/devices-imx53.h
> +++ b/arch/arm/mach-imx/include/mach/devices-imx53.h
> @@ -82,3 +82,8 @@ static inline struct device_d *imx53_add_nand(struct imx_nand_platform_data *pda
>  
>  	return dev;
>  }
> +
> +static inline struct device_d *imx53_add_kpp(struct matrix_keymap_data *pdata)
> +{
> +	return imx_add_kpp((void *)MX53_KPP_BASE_ADDR, pdata);
> +}
> -- 
> 1.7.5.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Mon Nov 19 05:36:59 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 19 Nov 2012 11:36:59 +0100
Subject: [PATCH 0/2 v2] add bus device
In-Reply-To: <20121103150823.GY29599@game.jcrosoft.org>
References: <20121103150823.GY29599@game.jcrosoft.org>
Message-ID: <20121119103659.GT10369@pengutronix.de>

On Sat, Nov 03, 2012 at 04:08:23PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> Hi,
> 
> The following changes since commit 37b37cb2bff79f4edbbcaf316149d814e11a358e:
> 
>   eth: register device a pure device (2012-11-03 07:48:12 +0800)
> 
> are available in the git repository at:
> 
>   git://git.jcrosoft.org/barebox.git tags/bus_device
> 
> for you to fetch changes up to 35f8933bf003b5049131487882d8ae57a1a50d3a:
> 
>   bus: add bus device (2012-11-03 07:52:49 +0800)

Applied, thanks

Sascha

> 
> ----------------------------------------------------------------
> add bus device
> 
> This patch serie add a pure device for each bus
> 
> And set this device to each bus device as a parent if the device
> does not have a parent already
> 
> we have now a nice output per bus
> 
> barebox at Atmel at91sam9x5-ek:/
> devices:
> `---- platform
>      `---- atmel_usart0
>           `---- cs0
>      `---- atmel_usart1
>           `---- cs1
>      `---- mem0
>           `---- 0x00000000-0x07ffffff: /dev/ram0
>      `---- mem1
>           `---- 0x00000000-0x00007fff: /dev/sram0
>      `---- mem2
>           `---- 0x00000000-0x000037bf: /dev/defaultenv
>      `---- mem3
>           `---- 0x00000000-0xfffffffe: /dev/mem
>      `---- cs2
>      `---- w1-gpio
>           `---- w1_bus0
>                `---- w1-2d-0
>                     `---- 0x00000000-0x0000007f: /dev/ds24310
>                `---- w1-2d-1
>                     `---- 0x00000000-0x0000007f: /dev/ds24311
>                `---- w1-23-0
>                     `---- 0x00000000-0x000001ff: /dev/ds24330
>      `---- at91sam9x5cm
>      `---- at91sam9x5ek
>      `---- at91sam9x5dm
>      `---- atmel_nand0
>           `---- nand0
>                `---- 0x00000000-0x1fffffff: /dev/nand0
>                `---- 0x00000000-0x0003ffff: /dev/at91bootstrap_raw
>                `---- 0x00040000-0x0009ffff: /dev/self_raw
>                `---- 0x000a0000-0x000bffff: /dev/env_raw
>                `---- 0x000c0000-0x000dffff: /dev/env_raw1
>                `---- 0x00000000-0x0003ffff: /dev/nand0.at91bootstrap
>                `---- 0x00040000-0x0009ffff: /dev/nand0.barebox
>                `---- 0x000a0000-0x000bffff: /dev/nand0.bareboxenv
>                `---- 0x000c0000-0x000dffff: /dev/nand0.bareboxenv2
>                `---- 0x000e0000-0x000fffff: /dev/nand0.oftree
>                `---- 0x00100000-0x001fffff: /dev/nand0.free
>                `---- 0x00200000-0x007fffff: /dev/nand0.kernel
>                `---- 0x00800000-0x07ffffff: /dev/nand0.rootfs
>                `---- 0x08000000-0x1fffffff: /dev/nand0.data
>      `---- macb0
>           `---- miibus0
>           `---- eth0
>      `---- atmel_spi0
>           `---- mtd_dataflash0
>                     `---- 0x00000000-0x0041ffff: /dev/dataflash0
>      `---- atmel_mci0
>           `---- mci0
>                `---- 0x00000000-0x1d9bfffff: /dev/disk0
>                `---- 0x00100000-0x064fffff: /dev/disk0.0
>                `---- 0x06500000-0x1d9bfffff: /dev/disk0.1
>      `---- i2c-gpio0
>           `---- i2c0
>                `---- qt10700
>                     `---- cs3
> `---- mdio_bus
> `---- spi
> `---- i2c
> `---- w1_bus
> `---- fs
>      `---- ramfs0
>      `---- devfs0
> `---- net
> `---- global
> 
> drivers:
> atmel_usart
> ramfs
> devfs
> fat
> macb
> Generic PHY
> atmel_nand
> mtd_dataflash
> m25p80
> atmel_spi
> i2c-gpio
> mci
> atmel_mci
> qt1070
> w1-gpio
> ds2431
> ds2433
> mem
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
> 
> ----------------------------------------------------------------
> Jean-Christophe PLAGNIOL-VILLARD (2):
>       bus_for_each_device/bus_for_each_driver: add () to allow use &bus
>       bus: add bus device
> 
>  drivers/base/bus.c    |   10 ++++++++++
>  drivers/base/driver.c |    5 +++++
>  include/driver.h      |    6 ++++--
>  3 files changed, 19 insertions(+), 2 deletions(-)
> 
> Best Regards,
> J.
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From antonynpavlov at gmail.com  Mon Nov 19 06:34:02 2012
From: antonynpavlov at gmail.com (Antony Pavlov)
Date: Mon, 19 Nov 2012 15:34:02 +0400
Subject: [PATCH 3/3] ARM: start-pbl.c: unificate path to lib/decompress_*.c
In-Reply-To: <20121119103037.GR10369@pengutronix.de>
References: <1353144361-9089-1-git-send-email-antonynpavlov@gmail.com>
 <1353144361-9089-4-git-send-email-antonynpavlov@gmail.com>
 <20121119103037.GR10369@pengutronix.de>
Message-ID: <CAA4bVAEmibj5RkfNr8yRjaApEwABB-jaKQUP8SiZOzp4fhpezg@mail.gmail.com>

On 19 November 2012 14:30, Sascha Hauer <s.hauer at pengutronix.de> wrote:
> On Sat, Nov 17, 2012 at 01:26:01PM +0400, Antony Pavlov wrote:
>> Signed-off-by: Antony Pavlov <antonynpavlov at gmail.com>
>> ---
>>  arch/arm/cpu/start-pbl.c |    2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/arm/cpu/start-pbl.c b/arch/arm/cpu/start-pbl.c
>> index 79a3cdd..c5f9705 100644
>> --- a/arch/arm/cpu/start-pbl.c
>> +++ b/arch/arm/cpu/start-pbl.c
>> @@ -66,7 +66,7 @@ extern void *input_data_end;
>>  #endif
>>
>>  #ifdef CONFIG_IMAGE_COMPRESSION_GZIP
>> -#include "../../../../lib/decompress_inflate.c"
>> +#include "../../../lib/decompress_inflate.c"
>
> This is strange. Why did this work beforehand?

Look above in the arch/arm/cpu/start-pbl.c:

#ifdef CONFIG_IMAGE_COMPRESSION_LZO
#include "../../../lib/decompress_unlzo.c"
#endif

#ifdef CONFIG_IMAGE_COMPRESSION_GZIP
#include "../../../../lib/decompress_inflate.c"
#endif

The files decompress_inflate.c and decompress_unlzo.c are in the same
directory. Why we use different prefixes to address them?

-- 
Best regards,
  Antony Pavlov


From s.hauer at pengutronix.de  Mon Nov 19 07:07:01 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 19 Nov 2012 13:07:01 +0100
Subject: [PATCH 3/3] ARM: start-pbl.c: unificate path to lib/decompress_*.c
In-Reply-To: <CAA4bVAEmibj5RkfNr8yRjaApEwABB-jaKQUP8SiZOzp4fhpezg@mail.gmail.com>
References: <1353144361-9089-1-git-send-email-antonynpavlov@gmail.com>
 <1353144361-9089-4-git-send-email-antonynpavlov@gmail.com>
 <20121119103037.GR10369@pengutronix.de>
 <CAA4bVAEmibj5RkfNr8yRjaApEwABB-jaKQUP8SiZOzp4fhpezg@mail.gmail.com>
Message-ID: <20121119120701.GW10369@pengutronix.de>

On Mon, Nov 19, 2012 at 03:34:02PM +0400, Antony Pavlov wrote:
> On 19 November 2012 14:30, Sascha Hauer <s.hauer at pengutronix.de> wrote:
> > On Sat, Nov 17, 2012 at 01:26:01PM +0400, Antony Pavlov wrote:
> >> Signed-off-by: Antony Pavlov <antonynpavlov at gmail.com>
> >> ---
> >>  arch/arm/cpu/start-pbl.c |    2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/arch/arm/cpu/start-pbl.c b/arch/arm/cpu/start-pbl.c
> >> index 79a3cdd..c5f9705 100644
> >> --- a/arch/arm/cpu/start-pbl.c
> >> +++ b/arch/arm/cpu/start-pbl.c
> >> @@ -66,7 +66,7 @@ extern void *input_data_end;
> >>  #endif
> >>
> >>  #ifdef CONFIG_IMAGE_COMPRESSION_GZIP
> >> -#include "../../../../lib/decompress_inflate.c"
> >> +#include "../../../lib/decompress_inflate.c"
> >
> > This is strange. Why did this work beforehand?
> 
> Look above in the arch/arm/cpu/start-pbl.c:
> 
> #ifdef CONFIG_IMAGE_COMPRESSION_LZO
> #include "../../../lib/decompress_unlzo.c"
> #endif
> 
> #ifdef CONFIG_IMAGE_COMPRESSION_GZIP
> #include "../../../../lib/decompress_inflate.c"
> #endif
> 
> The files decompress_inflate.c and decompress_unlzo.c are in the same
> directory. Why we use different prefixes to address them?

I understand the patch and why it's correct. I just wondered why it
works correctly without this patch.

ls arch/arm/cpu/../../../../lib/decompress_inflate.c
ls: cannot access arch/arm/cpu/../../../../lib/decompress_inflate.c: No such file or directory

This is correct, we only have to go three directories up. Still it
compiles fine.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From antonynpavlov at gmail.com  Mon Nov 19 07:37:38 2012
From: antonynpavlov at gmail.com (Antony Pavlov)
Date: Mon, 19 Nov 2012 16:37:38 +0400
Subject: [PATCH 3/3] ARM: start-pbl.c: unificate path to lib/decompress_*.c
In-Reply-To: <20121119120701.GW10369@pengutronix.de>
References: <1353144361-9089-1-git-send-email-antonynpavlov@gmail.com>
 <1353144361-9089-4-git-send-email-antonynpavlov@gmail.com>
 <20121119103037.GR10369@pengutronix.de>
 <CAA4bVAEmibj5RkfNr8yRjaApEwABB-jaKQUP8SiZOzp4fhpezg@mail.gmail.com>
 <20121119120701.GW10369@pengutronix.de>
Message-ID: <CAA4bVAEhKuc3FdpqV5VNxXw7PKw9k0Qd-Ssnjpxjru6=A37Ncw@mail.gmail.com>

On 19 November 2012 16:07, Sascha Hauer <s.hauer at pengutronix.de> wrote:
> On Mon, Nov 19, 2012 at 03:34:02PM +0400, Antony Pavlov wrote:
>> On 19 November 2012 14:30, Sascha Hauer <s.hauer at pengutronix.de> wrote:
>> > On Sat, Nov 17, 2012 at 01:26:01PM +0400, Antony Pavlov wrote:
>> >> Signed-off-by: Antony Pavlov <antonynpavlov at gmail.com>
>> >> ---
>> >>  arch/arm/cpu/start-pbl.c |    2 +-
>> >>  1 file changed, 1 insertion(+), 1 deletion(-)
>> >>
>> >> diff --git a/arch/arm/cpu/start-pbl.c b/arch/arm/cpu/start-pbl.c
>> >> index 79a3cdd..c5f9705 100644
>> >> --- a/arch/arm/cpu/start-pbl.c
>> >> +++ b/arch/arm/cpu/start-pbl.c
>> >> @@ -66,7 +66,7 @@ extern void *input_data_end;
>> >>  #endif
>> >>
>> >>  #ifdef CONFIG_IMAGE_COMPRESSION_GZIP
>> >> -#include "../../../../lib/decompress_inflate.c"
>> >> +#include "../../../lib/decompress_inflate.c"
>> >
>> > This is strange. Why did this work beforehand?
>>
>> Look above in the arch/arm/cpu/start-pbl.c:
>>
>> #ifdef CONFIG_IMAGE_COMPRESSION_LZO
>> #include "../../../lib/decompress_unlzo.c"
>> #endif
>>
>> #ifdef CONFIG_IMAGE_COMPRESSION_GZIP
>> #include "../../../../lib/decompress_inflate.c"
>> #endif
>>
>> The files decompress_inflate.c and decompress_unlzo.c are in the same
>> directory. Why we use different prefixes to address them?
>
> I understand the patch and why it's correct. I just wondered why it
> works correctly without this patch.
>
> ls arch/arm/cpu/../../../../lib/decompress_inflate.c
> ls: cannot access arch/arm/cpu/../../../../lib/decompress_inflate.c: No such file or directory
>
> This is correct, we only have to go three directories up. Still it
> compiles fine.

IMHO we use very many '-I' options when running C compiler. Some of
them make possible to include the decompres-related files with the
'../../../../' prefix,
the other ones make possible to use '../../../'.

If you will ally the patch, please don't forget to change 'unificate'
to 'unify'.

-- 
Best regards,
  Antony Pavlov


From J.Kilb at phytec.de  Mon Nov 19 08:22:05 2012
From: J.Kilb at phytec.de (Juergen Kilb)
Date: Mon, 19 Nov 2012 14:22:05 +0100
Subject: [PATCH] nand-bb: Fix remove of nand-bb device.
Message-ID: <1353331325-6778-1-git-send-email-J.Kilb@phytec.de>

Fixed possible crashs if nand-bb device is removed
and the list entry was not deleted from the list.

Signed-off-by: Juergen Kilb <J.Kilb at phytec.de>
---
 drivers/mtd/nand/nand-bb.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/mtd/nand/nand-bb.c b/drivers/mtd/nand/nand-bb.c
index cdb4663..0292f2f 100644
--- a/drivers/mtd/nand/nand-bb.c
+++ b/drivers/mtd/nand/nand-bb.c
@@ -314,6 +314,7 @@ int dev_remove_bb_dev(const char *name)
 		if (!strcmp(bb->cdev.name, name)) {
 			devfs_remove(&bb->cdev);
 			cdev_close(bb->cdev_parent);
+			list_del_init(&bb->list);
 			free(bb);
 			return 0;
 		}
-- 
1.7.0.4



From rpjday at crashcourse.ca  Mon Nov 19 08:53:45 2012
From: rpjday at crashcourse.ca (Robert P. J. Day)
Date: Mon, 19 Nov 2012 08:53:45 -0500 (EST)
Subject: RFC: first patch for getting arch-specific stuff out of
 asm-generic/barebox.lds.h
Message-ID: <alpine.DEB.2.02.1211190847250.11705@oneiric>


  looking for comments on this patch as simply the *first* tweak to
start cleaning arch-specific content out of that barebox.lds.h.
here's the incredibly simple change to handle just x86:

===== start =====

diff --git a/arch/x86/lib/barebox.lds.S b/arch/x86/lib/barebox.lds.S
index 8bd2a7b..500fa91 100644
--- a/arch/x86/lib/barebox.lds.S
+++ b/arch/x86/lib/barebox.lds.S
@@ -16,6 +16,7 @@
  */

 #undef i386
+#include <mach/barebox.lds.h>
 #include <asm-generic/barebox.lds.h>

 OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
diff --git a/include/asm-generic/barebox.lds.h b/include/asm-generic/barebox.lds.h
index b2bd19e..6e09de1 100644
--- a/include/asm-generic/barebox.lds.h
+++ b/include/asm-generic/barebox.lds.h
@@ -4,7 +4,6 @@
 	defined CONFIG_ARCH_IMX51 || \
 	defined CONFIG_ARCH_IMX53 || \
 	defined CONFIG_ARCH_IMX6 || \
-	defined CONFIG_X86 || \
 	defined CONFIG_ARCH_EP93XX
 #include <mach/barebox.lds.h>
 #endif

===== end =====

  of all the tests in the asm-generic file, the x86-related test is
unique in that it would end up including nothing but macro
definitions, so all the above does is remove that check from the
asm-generic file and explicitly put it into the x86 file -- it
*appears* that this has the same effect, and i tested it by building a
regular sandbox, which worked fine.  (does that represent a reasonable
test?)

  there's more that can be done, but the above at least gets rid of
one silly test in asm-generic/barebox.lds.h that doesn't need to be
there.

  thoughts?  if it looks reasonable, i can submit it as an official
patch.

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================




From rpjday at crashcourse.ca  Mon Nov 19 09:48:41 2012
From: rpjday at crashcourse.ca (Robert P. J. Day)
Date: Mon, 19 Nov 2012 09:48:41 -0500 (EST)
Subject: where is tftp mounting documented in the source code?
Message-ID: <alpine.DEB.2.02.1211190946120.13661@oneiric>


  perusing the wiki and ran across page on TFTP support:
http://wiki.barebox.org/doku.php?id=filesystems:tftp which suggests:

  mount 192.168.1.1 tftp /mnt/tftp
  bootm /mnt/tftp/uImage

but where is that documented in the source or help?  if i configure in
long help options, then i get:

barebox:/ help mount
Usage: mount [[-t <fstype] <device> <mountpoint>]
Mount a filesystem of a given type to a mountpoint.
If no fstype is specified, try to detect it automatically.
If no argument is given, list mounted filesystems.

which says nothing about tftp mounting.  where would someone already
running barebox bring up help info that explains the tftp mounting?

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================


From rpjday at crashcourse.ca  Mon Nov 19 09:58:45 2012
From: rpjday at crashcourse.ca (Robert P. J. Day)
Date: Mon, 19 Nov 2012 09:58:45 -0500 (EST)
Subject: [PATCH] mach-imx: Add/correct help info in mach-imx/Kconfig
Message-ID: <alpine.DEB.2.02.1211190956260.13911@oneiric>


Update help info, it's slightly out of date, and a grammatical fix.
No functional change.

Signed-off-by: Robert P. J. Day <rpjday at crashcourse.ca>

---

  are there any other updates that can be made to that help info?

diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index cca8394..3f4b452 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -65,15 +65,15 @@ choice
 	  used to setup SDRAM. The internal ROM code then initializes SDRAM
 	  using the register/value table, loads the whole barebox image to
 	  SDRAM and starts it. The internal boot mode is available on newer
-	  i.MX processors (i.MX25, i.MX35, i.MX51 and i.MX53). and supports
-	  booting from NOR, NAND, MMC/SD and serial ROMs.
-	  The external boot mode only supports booting from NAND and NOR. With
+	  i.MX processors (i.MX25, i.MX35, i.MX51, i.MX53 and i.MX6), and
+	  supports booting from NOR, NAND, MMC/SD and serial ROMs.
+	  The external boot mode supports booting only from NAND and NOR. With
 	  NOR flash the image is just started in NOR flash. With NAND flash
 	  the NAND controller loads the first 2kbyte from NAND into the NAND
 	  controllers internal SRAM where it is then started. It's the
 	  responsibility of these 2kbyte to load the rest of the boot image.
 	  The external boot mode is supported on older i.MX processors (i.MX1,
-	  i.MX21, i.MX25, i.MX27, i.MX21, i.MX35).
+	  i.MX21, i.MX25, i.MX27, i.MX31, i.MX35).

 config ARCH_IMX_INTERNAL_BOOT
 	bool "support internal boot mode"

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================


From zzs213 at 126.com  Mon Nov 19 22:54:12 2012
From: zzs213 at 126.com (zzs)
Date: Tue, 20 Nov 2012 11:54:12 +0800
Subject: wrong cfi flash device id
Message-ID: <20121120035412.GC8572@greatfirst.com>

My board is very similar to at91rm9200ek but using
a 8MB cfi flash AT49BV642D.

When barebox started, the flash info as blow:

# devinfo cfi_flash0
CFI conformant FLASH (16 x 16)  Size: 8 MB in 135 Sectors
  AMD Standard command set, Manufacturer ID: 0x1F, Device ID: 0xD6
  Erase timeout: 8192 ms, write timeout: 256 us
  Buffer write timeout: 64 us, buffer size: 4 bytes

  Sector Start Addresses:
  10000000        10010000        10020000        10030000        10040000
  10050000        10060000        10070000        10080000        10090000
  100A0000        100B0000        100C0000        100D0000        100E0000

Barebox said the device id is 0xD6, But it should be 0x1D6.

Because of this wrong ID, In function drivers/nor/cfi_flash_amd.c:flash_fixup_atmel()
the erase region were reversed.

So I can't erase the first few sectors

I think it should use read8 or read16 according the portwidth like
u-boot does.

Am I right?

-- 
Best Regards,
zzs




From c.hemp at phytec.de  Tue Nov 20 02:12:00 2012
From: c.hemp at phytec.de (Christian Hemp)
Date: Tue, 20 Nov 2012 08:12:00 +0100
Subject: [PATCH] ARM pcm043: Fix macro name
Message-ID: <1353395520-13679-1-git-send-email-c.hemp@phytec.de>

Since commit dc9d70e2 the define CCM_PDR4 is called MX35_CCM_PDR4.

Signed-off-by: Christian Hemp <c.hemp at phytec.de>
---
 arch/arm/boards/pcm043/lowlevel.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boards/pcm043/lowlevel.c b/arch/arm/boards/pcm043/lowlevel.c
index 06f05ab..751f6ae 100644
--- a/arch/arm/boards/pcm043/lowlevel.c
+++ b/arch/arm/boards/pcm043/lowlevel.c
@@ -46,10 +46,10 @@ static void __bare_init __naked insdram(void)
 	uint32_t r;
 
 	/* Speed up NAND controller by adjusting the NFC divider */
-	r = readl(MX35_CCM_BASE_ADDR + CCM_PDR4);
+	r = readl(MX35_CCM_BASE_ADDR + MX35_CCM_PDR4);
 	r &= ~(0xf << 28);
 	r |= 0x1 << 28;
-	writel(r, MX35_CCM_BASE_ADDR + CCM_PDR4);
+	writel(r, MX35_CCM_BASE_ADDR + MX35_CCM_PDR4);
 
 	/* setup a stack to be able to call imx_nand_load_image() */
 	arm_setup_stack(STACK_BASE + STACK_SIZE - 12);
-- 
1.7.0.4



From s.hauer at pengutronix.de  Tue Nov 20 02:24:22 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Tue, 20 Nov 2012 08:24:22 +0100
Subject: [PATCH 3/3] ARM: start-pbl.c: unificate path to lib/decompress_*.c
In-Reply-To: <CAA4bVAEhKuc3FdpqV5VNxXw7PKw9k0Qd-Ssnjpxjru6=A37Ncw@mail.gmail.com>
References: <1353144361-9089-1-git-send-email-antonynpavlov@gmail.com>
 <1353144361-9089-4-git-send-email-antonynpavlov@gmail.com>
 <20121119103037.GR10369@pengutronix.de>
 <CAA4bVAEmibj5RkfNr8yRjaApEwABB-jaKQUP8SiZOzp4fhpezg@mail.gmail.com>
 <20121119120701.GW10369@pengutronix.de>
 <CAA4bVAEhKuc3FdpqV5VNxXw7PKw9k0Qd-Ssnjpxjru6=A37Ncw@mail.gmail.com>
Message-ID: <20121120072422.GY10369@pengutronix.de>

On Mon, Nov 19, 2012 at 04:37:38PM +0400, Antony Pavlov wrote:
> >> The files decompress_inflate.c and decompress_unlzo.c are in the same
> >> directory. Why we use different prefixes to address them?
> >
> > I understand the patch and why it's correct. I just wondered why it
> > works correctly without this patch.
> >
> > ls arch/arm/cpu/../../../../lib/decompress_inflate.c
> > ls: cannot access arch/arm/cpu/../../../../lib/decompress_inflate.c: No such file or directory
> >
> > This is correct, we only have to go three directories up. Still it
> > compiles fine.
> 
> IMHO we use very many '-I' options when running C compiler. Some of
> them make possible to include the decompres-related files with the
> '../../../../' prefix,
> the other ones make possible to use '../../../'.

I wasn't aware that files included with "" also evaluate the -i options.

Applied, thanks.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Tue Nov 20 02:25:20 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Tue, 20 Nov 2012 08:25:20 +0100
Subject: [PATCH] nand-bb: Fix remove of nand-bb device.
In-Reply-To: <1353331325-6778-1-git-send-email-J.Kilb@phytec.de>
References: <1353331325-6778-1-git-send-email-J.Kilb@phytec.de>
Message-ID: <20121120072520.GZ10369@pengutronix.de>

On Mon, Nov 19, 2012 at 02:22:05PM +0100, Juergen Kilb wrote:
> Fixed possible crashs if nand-bb device is removed
> and the list entry was not deleted from the list.
> 
> Signed-off-by: Juergen Kilb <J.Kilb at phytec.de>

Applied, thanks

Sascha

> ---
>  drivers/mtd/nand/nand-bb.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/mtd/nand/nand-bb.c b/drivers/mtd/nand/nand-bb.c
> index cdb4663..0292f2f 100644
> --- a/drivers/mtd/nand/nand-bb.c
> +++ b/drivers/mtd/nand/nand-bb.c
> @@ -314,6 +314,7 @@ int dev_remove_bb_dev(const char *name)
>  		if (!strcmp(bb->cdev.name, name)) {
>  			devfs_remove(&bb->cdev);
>  			cdev_close(bb->cdev_parent);
> +			list_del_init(&bb->list);
>  			free(bb);
>  			return 0;
>  		}
> -- 
> 1.7.0.4
> 
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Tue Nov 20 02:58:18 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Tue, 20 Nov 2012 08:58:18 +0100
Subject: [RFC 2/3] MIPS: boot: realize _start in C
In-Reply-To: <1353154239-31574-3-git-send-email-antonynpavlov@gmail.com>
References: <1353154239-31574-1-git-send-email-antonynpavlov@gmail.com>
 <1353154239-31574-3-git-send-email-antonynpavlov@gmail.com>
Message-ID: <20121120075818.GB10369@pengutronix.de>

On Sat, Nov 17, 2012 at 04:10:38PM +0400, Antony Pavlov wrote:
> The pbl will be incharge of the lowlevel init and
> barebox relocation. So we can skip it in barebox itself
> and use simple _start.
> 
> Signed-off-by: Antony Pavlov <antonynpavlov at gmail.com>
> ---
>  arch/mips/boot/Makefile     |    1 -
>  arch/mips/boot/main_entry.c |   18 ++++++
>  arch/mips/boot/start.S      |  142 -------------------------------------------
>  3 files changed, 18 insertions(+), 143 deletions(-)
>  delete mode 100644 arch/mips/boot/start.S
> 
> diff --git a/arch/mips/boot/Makefile b/arch/mips/boot/Makefile
> index 6b093f1..4f11a48 100644
> --- a/arch/mips/boot/Makefile
> +++ b/arch/mips/boot/Makefile
> @@ -1,4 +1,3 @@
> -obj-y += start.o
>  obj-y += main_entry.o
>  
>  pbl-y += start-pbl.o main_entry-pbl.o
> diff --git a/arch/mips/boot/main_entry.c b/arch/mips/boot/main_entry.c
> index 0a33c45..422d40b 100644
> --- a/arch/mips/boot/main_entry.c
> +++ b/arch/mips/boot/main_entry.c
> @@ -22,6 +22,8 @@
>  #include <asm/cpu-features.h>
>  #include <asm/mipsregs.h>
>  #include <asm/addrspace.h>
> +#include <asm/regdef.h>
> +#include <asm-generic/memory_layout.h>
>  
>  extern void start_barebox(void);
>  extern void handle_reserved(void);
> @@ -92,3 +94,19 @@ void main_entry(void)
>  
>  	start_barebox();
>  }
> +
> +void __naked __section(.text_entry) _start(void)
> +{
> +	u32 r;
> +
> +	/* setup the stack */
> +	r = STACK_BASE + STACK_SIZE - 16;
> +
> +	__asm__ __volatile__(
> +		"move\t$sp, %0\n\t"
> +		: /* no outputs */
> +		: "r" (r)
> +	);
> +
> +	main_entry();

I wonder that the C function skips several things the Assembler version
does. Is this done in the pbl now? Does this patch make the pbl
mandatory? We haven't done this on Arm, mostly because we were not
confident enough that it works on every board. That may be different on
mips, but should be mentioned in the commit log. But maybe I am
misreading the patches...

Sascha


> +}
> diff --git a/arch/mips/boot/start.S b/arch/mips/boot/start.S
> deleted file mode 100644
> index 7e2ae5e..0000000
> --- a/arch/mips/boot/start.S
> +++ /dev/null
> @@ -1,142 +0,0 @@
> -/*
> - * Startup Code for MIPS CPU
> - *
> - * Copyright (C) 2011 Antony Pavlov <antonynpavlov at gmail.com>
> - * Used code copyrighted (C) 2009 by Shinya Kuribayashi <skuribay at pobox.com>
> - *
> - * This file is part of barebox.
> - * See file CREDITS for list of people who contributed to this project.
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License version 2
> - * as published by the Free Software Foundation.
> - *
> - * This program is distributed in the hope that it will be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> - * GNU General Public License for more details.
> - *
> - */
> -
> -#include <asm/regdef.h>
> -#include <asm/mipsregs.h>
> -#include <asm/asm.h>
> -#include <asm-generic/memory_layout.h>
> -#include <generated/compile.h>
> -#include <generated/utsrelease.h>
> -
> -	/*
> -	 * ADR macro instruction (inspired by ARM)
> -	 *
> -	 * ARM architecture doesn't have PC-relative jump instruction
> -	 * like MIPS' B/BAL insns.  When ARM makes PC-relative jumps,
> -	 * it uses ADR insn.  ADR is used to get a destination address
> -	 * of 'label' against current PC.  With this, ARM can safely
> -	 * make PC-relative jumps.
> -	 */
> -	.macro	ADR rd label temp
> -	.set	push
> -	.set	noreorder
> -	move	\temp, ra			# preserve ra beforehand
> -	bal	_pc
> -	 nop
> -_pc:	addiu	\rd, ra, \label - _pc		# label is assumed to be
> -	move	ra, \temp			# within pc +/- 32KB
> -	.set	pop
> -	.endm
> -
> -	.set noreorder
> -	.text
> -	.section ".text_bare_init"
> -	.align 4
> -
> -EXPORT(_start)
> -
> -	b	__start
> -	 nop
> -
> -	.org	0x10
> -	.ascii	"barebox " UTS_RELEASE " " UTS_VERSION
> -	.byte	0
> -
> -	.align 4
> -__start:
> -	/* disable watchpoints */
> -	mtc0	zero, CP0_WATCHLO
> -	mtc0	zero, CP0_WATCHHI
> -
> -	/* disable interrupts */
> -	mfc0	k0, CP0_STATUS
> -	li	k1, ~ST0_IE
> -	and	k0, k1
> -	mtc0	k0, CP0_STATUS
> -
> -	/* copy barebox to link location */
> -	ADR	a0, _start, t1	/* a0 <- pc-relative position of _start */
> -
> -	la	a1, _start	/* link (RAM) _start address */
> -
> -	beq	a0, a1, stack_setup
> -	 nop
> -
> -	la	t0, _start
> -	la	t1, __bss_start
> -	subu	t2, t1, t0	/* t2 <- size of barebox */
> -	addu	a2, a0, t2	/* a2 <- source end address */
> -
> -#define LONGSIZE	4
> -
> -copy_loop:
> -	/* copy from source address [a0] */
> -	lw		t4, LONGSIZE * 0(a0)
> -	lw		t5, LONGSIZE * 1(a0)
> -	lw		t6, LONGSIZE * 2(a0)
> -	lw		t7, LONGSIZE * 3(a0)
> -	/* copy fo target address [a1] */
> -	sw		t4, LONGSIZE * 0(a1)
> -	sw		t5, LONGSIZE * 1(a1)
> -	sw		t6, LONGSIZE * 2(a1)
> -	sw		t7, LONGSIZE * 3(a1)
> -	addi		a0, LONGSIZE * 4
> -	subu		t3, a0, a2
> -	blez		t3, copy_loop
> -	addi		a1, LONGSIZE * 4
> -
> -	/*
> -	 * Dominic Sweetman, See MIPS Run, Morgan Kaufmann, 2nd edition, 2006
> -	 *
> -	 * 11.2.2 Stack Argument Structure in o32
> -	 * ...
> -	 * At the point where a function is called, sp must be
> -	 * eight-byte-aligned, matching the alignment of the largest
> -	 * basic types -- a long long integer or a floating-point double.
> -	 * The eight-byte alignment is not required by 32-bit MIPS integer
> -	 * hardware, but it's essential for compatibility with CPUs with
> -	 * 64-bit registers, and thus part of the rules. Subroutines fit
> -	 * in with this by always adjusting the stack pointer by a multiple
> -	 * of eight.
> -	 * ...
> -	 * SGI's n32 and n64 standards call for the stack to be maintained
> -	 * with 16-byte alignment.
> -	 *
> -	 */
> -
> -#if (STACK_BASE + STACK_SIZE) % 16 != 0
> -#error stack pointer must be 16-byte-aligned
> -#endif
> -
> -stack_setup:
> -	la	sp, STACK_BASE + STACK_SIZE
> -
> -	/* reserve four 32-bit argument slots */
> -	addiu	sp, -16
> -
> -	la	v0, main_entry
> -	jal     v0
> -	 nop
> -
> -	/* No return */
> -
> -__error:
> -	b __error
> -	 nop
> -- 
> 1.7.10.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Tue Nov 20 02:59:25 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Tue, 20 Nov 2012 08:59:25 +0100
Subject: [RFC 1/3] MIPS: add pre-bootloader (pbl) image support
In-Reply-To: <1353154239-31574-2-git-send-email-antonynpavlov@gmail.com>
References: <1353154239-31574-1-git-send-email-antonynpavlov@gmail.com>
 <1353154239-31574-2-git-send-email-antonynpavlov@gmail.com>
Message-ID: <20121120075925.GC10369@pengutronix.de>

On Sat, Nov 17, 2012 at 04:10:37PM +0400, Antony Pavlov wrote:
> This patch is based on ARM pbl support and allows
> creating a pre-bootloader binary for compressed image.
> 
> Signed-off-by: Antony Pavlov <antonynpavlov at gmail.com>
> ---
>  arch/mips/Kconfig               |    2 +
>  arch/mips/Makefile              |   18 +++++
>  arch/mips/boot/Makefile         |    2 +
>  arch/mips/boot/main_entry-pbl.c |   90 ++++++++++++++++++++++++
>  arch/mips/boot/start-pbl.S      |  146 +++++++++++++++++++++++++++++++++++++++
>  arch/mips/pbl/.gitignore        |    6 ++
>  arch/mips/pbl/Makefile          |   40 +++++++++++
>  arch/mips/pbl/piggy.gzip.S      |    6 ++
>  arch/mips/pbl/piggy.lzo.S       |    6 ++
>  arch/mips/pbl/zbarebox.lds.S    |   57 +++++++++++++++
>  10 files changed, 373 insertions(+)
>  create mode 100644 arch/mips/boot/main_entry-pbl.c
>  create mode 100644 arch/mips/boot/start-pbl.S
>  create mode 100644 arch/mips/pbl/.gitignore
>  create mode 100644 arch/mips/pbl/Makefile
>  create mode 100644 arch/mips/pbl/piggy.gzip.S
>  create mode 100644 arch/mips/pbl/piggy.lzo.S
>  create mode 100644 arch/mips/pbl/zbarebox.lds.S
> 
> diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
> index 7a1eeac..853d406 100644
> --- a/arch/mips/Kconfig
> +++ b/arch/mips/Kconfig
> @@ -6,6 +6,8 @@ config MIPS
>  	select HAS_KALLSYMS
>  	select HAVE_CONFIGURABLE_MEMORY_LAYOUT
>  	select HAVE_CONFIGURABLE_TEXT_BASE
> +	select HAVE_PBL_IMAGE
> +	select HAVE_IMAGE_COMPRESSION
>  	default y
>  
>  config SYS_SUPPORTS_BIG_ENDIAN
> diff --git a/arch/mips/Makefile b/arch/mips/Makefile
> index 5e40de7..819e7a3 100644
> --- a/arch/mips/Makefile
> +++ b/arch/mips/Makefile
> @@ -58,6 +58,15 @@ CPPFLAGS += -fdata-sections -ffunction-sections
>  LDFLAGS_barebox += -static --gc-sections
>  endif
>  
> +ifdef CONFIG_IMAGE_COMPRESSION
> +KBUILD_BINARY := arch/mips/pbl/zbarebox.bin
> +KBUILD_TARGET := zbarebox.bin
> +$(KBUILD_BINARY): $(KBUILD_TARGET)
> +else
> +KBUILD_BINARY := barebox.bin
> +KBUILD_TARGET := barebox.bin
> +endif
> +
>  LDFLAGS_barebox += -nostdlib
>  
>  machine-$(CONFIG_MACH_MIPS_MALTA)	:= malta
> @@ -106,3 +115,12 @@ CFLAGS += $(cflags-y)
>  lds-$(CONFIG_GENERIC_LINKER_SCRIPT)   := arch/mips/lib/barebox.lds
>  
>  CLEAN_FILES    += arch/mips/lib/barebox.lds barebox.map barebox.S
> +
> +pbl := arch/mips/pbl
> +zbarebox.S zbarebox.bin zbarebox: barebox.bin
> +	$(Q)$(MAKE) $(build)=$(pbl) $(pbl)/$@
> +
> +archclean:
> +	$(MAKE) $(clean)=$(pbl)
> +
> +KBUILD_IMAGE ?= $(KBUILD_BINARY)
> diff --git a/arch/mips/boot/Makefile b/arch/mips/boot/Makefile
> index d6d28ce..6b093f1 100644
> --- a/arch/mips/boot/Makefile
> +++ b/arch/mips/boot/Makefile
> @@ -1,2 +1,4 @@
>  obj-y += start.o
>  obj-y += main_entry.o
> +
> +pbl-y += start-pbl.o main_entry-pbl.o
> diff --git a/arch/mips/boot/main_entry-pbl.c b/arch/mips/boot/main_entry-pbl.c
> new file mode 100644
> index 0000000..51b9176
> --- /dev/null
> +++ b/arch/mips/boot/main_entry-pbl.c
> @@ -0,0 +1,90 @@
> +/*
> + * Copyright (C) 2012 Antony Pavlov <antonynpavlov at gmail.com>
> + *
> + * This file is part of barebox.
> + * See file CREDITS for list of people who contributed to this project.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation; either version 2 of
> + * the License, or (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + */
> +
> +#include <common.h>
> +#include <init.h>
> +#include <sizes.h>
> +#include <string.h>
> +#include <asm/sections.h>
> +#include <asm-generic/memory_layout.h>
> +#include <debug_ll.h>
> +
> +extern void *input_data;
> +extern void *input_data_end;
> +
> +unsigned long free_mem_ptr;
> +unsigned long free_mem_end_ptr;
> +
> +#define STATIC static
> +
> +#ifdef CONFIG_IMAGE_COMPRESSION_LZO
> +#include "../../../lib/decompress_unlzo.c"
> +#endif
> +
> +#ifdef CONFIG_IMAGE_COMPRESSION_GZIP
> +#include "../../../lib/decompress_inflate.c"
> +#endif
> +
> +void pbl_main_entry(void);
> +
> +static unsigned long *ttb;
> +
> +static noinline void errorfn(char *error)
> +{
> +	PUTS_LL(error);
> +	PUTC_LL('\n');
> +
> +	unreachable();
> +}
> +
> +static void barebox_uncompress(void *compressed_start, unsigned int len)
> +{
> +	/* set 128 KiB at the end of the MALLOC_BASE for early malloc */
> +	free_mem_ptr = MALLOC_BASE + MALLOC_SIZE - SZ_128K;
> +	free_mem_end_ptr = free_mem_ptr + SZ_128K;
> +
> +	ttb = (void *)((free_mem_ptr - 0x4000) & ~0x3fff);
> +
> +	decompress((void *)compressed_start,
> +			len,
> +			NULL, NULL,
> +			(void *)TEXT_BASE, NULL, errorfn);
> +
> +	/* FIXME: just now we have no MIPS cache support */
> +	/* flush_icache(); */
> +}
> +
> +void __section(.text_entry) pbl_main_entry(void)
> +{
> +	u32 pg_start, pg_end, pg_len;
> +	void (*barebox)(void);
> +
> +	PUTS_LL("pbl_main_entry()\n");
> +
> +	/* clear bss */
> +	memset(__bss_start, 0, __bss_stop - __bss_start);
> +
> +	pg_start = (u32)&input_data;
> +	pg_end = (u32)&input_data_end;
> +	pg_len = pg_end - pg_start;
> +
> +	barebox_uncompress(&input_data, pg_len);
> +
> +	barebox = (void *)TEXT_BASE;
> +	barebox();
> +}
> diff --git a/arch/mips/boot/start-pbl.S b/arch/mips/boot/start-pbl.S
> new file mode 100644
> index 0000000..ad39f42
> --- /dev/null
> +++ b/arch/mips/boot/start-pbl.S
> @@ -0,0 +1,146 @@
> +/*
> + * Startup Code for MIPS CPU
> + *
> + * Copyright (C) 2011, 2012 Antony Pavlov <antonynpavlov at gmail.com>
> + * ADR macro copyrighted (C) 2009 by Shinya Kuribayashi <skuribay at pobox.com>
> + *
> + * This file is part of barebox.
> + * See file CREDITS for list of people who contributed to this project.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2
> + * as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + */
> +
> +#include <asm/regdef.h>
> +#include <asm/mipsregs.h>
> +#include <asm/asm.h>
> +#include <asm-generic/memory_layout.h>
> +#include <generated/compile.h>
> +#include <generated/utsrelease.h>
> +
> +//#include <mach/kernel-entry-init.h>
> +
> +	/*
> +	 * ADR macro instruction (inspired by ARM)
> +	 *
> +	 * ARM architecture doesn't have PC-relative jump instruction
> +	 * like MIPS' B/BAL insns. When ARM makes PC-relative jumps,
> +	 * it uses ADR insn. ADR is used to get a destination address
> +	 * of 'label' against current PC. With this, ARM can safely
> +	 * make PC-relative jumps.
> +	 */
> +	.macro	ADR rd label temp
> +	.set	push
> +	.set	noreorder
> +	move	\temp, ra			# preserve ra beforehand
> +	bal	_pc
> +	 nop

This file contains some whitespace damages you could cleanup along the
way.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Tue Nov 20 03:01:22 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Tue, 20 Nov 2012 09:01:22 +0100
Subject: [PATCH] mach-imx: Add/correct help info in mach-imx/Kconfig
In-Reply-To: <alpine.DEB.2.02.1211190956260.13911@oneiric>
References: <alpine.DEB.2.02.1211190956260.13911@oneiric>
Message-ID: <20121120080122.GD10369@pengutronix.de>

On Mon, Nov 19, 2012 at 09:58:45AM -0500, Robert P. J. Day wrote:
> 
> Update help info, it's slightly out of date, and a grammatical fix.
> No functional change.
> 
> Signed-off-by: Robert P. J. Day <rpjday at crashcourse.ca>

Applied, thanks

Sascha

> 
> ---
> 
>   are there any other updates that can be made to that help info?
> 
> diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
> index cca8394..3f4b452 100644
> --- a/arch/arm/mach-imx/Kconfig
> +++ b/arch/arm/mach-imx/Kconfig
> @@ -65,15 +65,15 @@ choice
>  	  used to setup SDRAM. The internal ROM code then initializes SDRAM
>  	  using the register/value table, loads the whole barebox image to
>  	  SDRAM and starts it. The internal boot mode is available on newer
> -	  i.MX processors (i.MX25, i.MX35, i.MX51 and i.MX53). and supports
> -	  booting from NOR, NAND, MMC/SD and serial ROMs.
> -	  The external boot mode only supports booting from NAND and NOR. With
> +	  i.MX processors (i.MX25, i.MX35, i.MX51, i.MX53 and i.MX6), and
> +	  supports booting from NOR, NAND, MMC/SD and serial ROMs.
> +	  The external boot mode supports booting only from NAND and NOR. With
>  	  NOR flash the image is just started in NOR flash. With NAND flash
>  	  the NAND controller loads the first 2kbyte from NAND into the NAND
>  	  controllers internal SRAM where it is then started. It's the
>  	  responsibility of these 2kbyte to load the rest of the boot image.
>  	  The external boot mode is supported on older i.MX processors (i.MX1,
> -	  i.MX21, i.MX25, i.MX27, i.MX21, i.MX35).
> +	  i.MX21, i.MX25, i.MX27, i.MX31, i.MX35).
> 
>  config ARCH_IMX_INTERNAL_BOOT
>  	bool "support internal boot mode"
> 
> -- 
> 
> ========================================================================
> Robert P. J. Day                                 Ottawa, Ontario, CANADA
>                         http://crashcourse.ca
> 
> Twitter:                                       http://twitter.com/rpjday
> LinkedIn:                               http://ca.linkedin.com/in/rpjday
> ========================================================================
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Tue Nov 20 03:08:31 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Tue, 20 Nov 2012 09:08:31 +0100
Subject: where is tftp mounting documented in the source code?
In-Reply-To: <alpine.DEB.2.02.1211190946120.13661@oneiric>
References: <alpine.DEB.2.02.1211190946120.13661@oneiric>
Message-ID: <20121120080831.GE10369@pengutronix.de>

On Mon, Nov 19, 2012 at 09:48:41AM -0500, Robert P. J. Day wrote:
> 
>   perusing the wiki and ran across page on TFTP support:
> http://wiki.barebox.org/doku.php?id=filesystems:tftp which suggests:
> 
>   mount 192.168.1.1 tftp /mnt/tftp

This was the original mount behaviour. This was recently changed to
mount -t fstype <ip> /dir, mainly to allow making the fstype option
optional for autodetecting the type. The wiki page is out of date here.
As a sidenote I brought back the old behaviour as a compatibility option
to not break old environments.

>   bootm /mnt/tftp/uImage
> 
> but where is that documented in the source or help?  if i configure in
> long help options, then i get:
> 
> barebox:/ help mount
> Usage: mount [[-t <fstype] <device> <mountpoint>]
> Mount a filesystem of a given type to a mountpoint.
> If no fstype is specified, try to detect it automatically.
> If no argument is given, list mounted filesystems.
> 
> which says nothing about tftp mounting.  where would someone already
> running barebox bring up help info that explains the tftp mounting?

mount -t tftp 192.168.1.1 /mnt/tftp

The special thing about tftp is that tftp does not have directory
listing support, so you will always see an empty directory, even when
mounted. The files are there nevertheless and can be accessed.

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From plagnioj at jcrosoft.com  Tue Nov 20 03:07:26 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Tue, 20 Nov 2012 09:07:26 +0100
Subject: wrong cfi flash device id
In-Reply-To: <20121120035412.GC8572@greatfirst.com>
References: <20121120035412.GC8572@greatfirst.com>
Message-ID: <20121120080726.GJ8327@game.jcrosoft.org>

On 11:54 Tue 20 Nov     , zzs wrote:
> My board is very similar to at91rm9200ek but using
> a 8MB cfi flash AT49BV642D.
> 
> When barebox started, the flash info as blow:
> 
> # devinfo cfi_flash0
> CFI conformant FLASH (16 x 16)  Size: 8 MB in 135 Sectors
>   AMD Standard command set, Manufacturer ID: 0x1F, Device ID: 0xD6
>   Erase timeout: 8192 ms, write timeout: 256 us
>   Buffer write timeout: 64 us, buffer size: 4 bytes
> 
>   Sector Start Addresses:
>   10000000        10010000        10020000        10030000        10040000
>   10050000        10060000        10070000        10080000        10090000
>   100A0000        100B0000        100C0000        100D0000        100E0000
> 
> Barebox said the device id is 0xD6, But it should be 0x1D6.
> 
> Because of this wrong ID, In function drivers/nor/cfi_flash_amd.c:flash_fixup_atmel()
> the erase region were reversed.
> 
> So I can't erase the first few sectors
> 
> I think it should use read8 or read16 according the portwidth like
> u-boot does.
I check the kernel we need to read the id according the bus width

btw please use a real name zzs is either an english name or a chinese name

Best Regards,
J.


From zzs213 at 126.com  Tue Nov 20 03:29:14 2012
From: zzs213 at 126.com (=?utf-8?B?5byg5b+g5bGx?=)
Date: Tue, 20 Nov 2012 16:29:14 +0800
Subject: wrong cfi flash device id
In-Reply-To: <20121120080726.GJ8327@game.jcrosoft.org>
References: <20121120035412.GC8572@greatfirst.com>
 <20121120080726.GJ8327@game.jcrosoft.org>
Message-ID: <20121120082914.GA24454@greatfirst.com>

> > I think it should use read8 or read16 according the portwidth like
> > u-boot does.
> I check the kernel we need to read the id according the bus width
>
> btw please use a real name zzs is either an english name or a chinese name
>
This is my chinese name

-- 
Best Regards,
zzs




From s.hauer at pengutronix.de  Tue Nov 20 03:33:07 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Tue, 20 Nov 2012 09:33:07 +0100
Subject: [PATCH] ARM pcm043: Fix macro name
In-Reply-To: <1353395520-13679-1-git-send-email-c.hemp@phytec.de>
References: <1353395520-13679-1-git-send-email-c.hemp@phytec.de>
Message-ID: <20121120083307.GF10369@pengutronix.de>

On Tue, Nov 20, 2012 at 08:12:00AM +0100, Christian Hemp wrote:
> Since commit dc9d70e2 the define CCM_PDR4 is called MX35_CCM_PDR4.
> 
> Signed-off-by: Christian Hemp <c.hemp at phytec.de>

Applied, thanks. Added the same fix for cupid aswell.

Sascha

> ---
>  arch/arm/boards/pcm043/lowlevel.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/boards/pcm043/lowlevel.c b/arch/arm/boards/pcm043/lowlevel.c
> index 06f05ab..751f6ae 100644
> --- a/arch/arm/boards/pcm043/lowlevel.c
> +++ b/arch/arm/boards/pcm043/lowlevel.c
> @@ -46,10 +46,10 @@ static void __bare_init __naked insdram(void)
>  	uint32_t r;
>  
>  	/* Speed up NAND controller by adjusting the NFC divider */
> -	r = readl(MX35_CCM_BASE_ADDR + CCM_PDR4);
> +	r = readl(MX35_CCM_BASE_ADDR + MX35_CCM_PDR4);
>  	r &= ~(0xf << 28);
>  	r |= 0x1 << 28;
> -	writel(r, MX35_CCM_BASE_ADDR + CCM_PDR4);
> +	writel(r, MX35_CCM_BASE_ADDR + MX35_CCM_PDR4);
>  
>  	/* setup a stack to be able to call imx_nand_load_image() */
>  	arm_setup_stack(STACK_BASE + STACK_SIZE - 12);
> -- 
> 1.7.0.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Tue Nov 20 03:39:19 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Tue, 20 Nov 2012 09:39:19 +0100
Subject: [PATCH 0/7] phylib: fix + drivers
In-Reply-To: <20121118124627.GE8327@game.jcrosoft.org>
References: <20121118124627.GE8327@game.jcrosoft.org>
Message-ID: <20121120083919.GH10369@pengutronix.de>

On Sun, Nov 18, 2012 at 01:46:27PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> HI,
> 
> 	Today we have a bug on the match the logic is inverted.
> 	We are lucky as the generic Phy driver is not suppoed to match with
> 	any device it work so fix it. Ensure the generic phy driver is
> 	probe last if needed.
> 
> 	for mx53-loco we are lucky too the first phy found is the right one
> 
> The following changes since commit 272a5d738ab152347d67be062e8a4e771825493a:
> 
>   at91rm9200ek: add spi support (2012-11-16 15:33:50 +0100)
> 
> are available in the git repository at:
> 
>   git://git.jcrosoft.org/barebox.git delivery/phylib_fix
> 
> for you to fetch changes up to 5ea00036e330ea58293774a36d3ee5f9c1fbe895:
> 
>   phylib: add micrel support (2012-11-16 23:11:16 +0800)

Applied, thanks

Sascha

> 
> ----------------------------------------------------------------
> Jean-Christophe PLAGNIOL-VILLARD (7):
>       driver: introduce device_probe to manully probe a device
>       phylib: fix generic phy driver probe
>       mdio_bus: fix match
>       phylib: export phy_id via param
>       phylib: introduction of forced 100Mbps
>       phylib: add fixup support
>       phylib: add micrel support
> 
>  drivers/base/driver.c      |   23 +++++++++----
>  drivers/net/phy/Kconfig    |   11 +++---
>  drivers/net/phy/Makefile   |    2 +-
>  drivers/net/phy/generic.c  |   36 --------------------
>  drivers/net/phy/mdio_bus.c |   28 ++++++++++-----
>  drivers/net/phy/micrel.c   |  174 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  drivers/net/phy/phy.c      |  130 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
>  include/driver.h           |    5 +++
>  include/linux/micrel_phy.h |   30 ++++++++++++++++
>  include/linux/phy.h        |   21 +++++++++++-
>  10 files changed, 400 insertions(+), 60 deletions(-)
>  delete mode 100644 drivers/net/phy/generic.c
>  create mode 100644 drivers/net/phy/micrel.c
>  create mode 100644 include/linux/micrel_phy.h
> 
> Best Regards,
> J.
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Tue Nov 20 03:41:00 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Tue, 20 Nov 2012 09:41:00 +0100
Subject: [PATCH 0/2] m25p80: re-import it againt mtd_add_host
In-Reply-To: <20121115101150.GF31820@game.jcrosoft.org>
References: <20121031120122.GF29599@game.jcrosoft.org>
 <20121115101150.GF31820@game.jcrosoft.org>
Message-ID: <20121120084100.GI10369@pengutronix.de>

On Thu, Nov 15, 2012 at 11:11:50AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> ping
> 
> work on next
> On 13:01 Wed 31 Oct     , Jean-Christophe PLAGNIOL-VILLARD wrote:
> > Hi,
> > 
> > 	so we now create the cdev via mtd
> > 
> > 	This will also simplify sync with linux
> > 
> > 	to avoid the m25p8000 or m25p00 the cdev is still named name m25p and the
> > 	drivers m25p80
> > 
> > 	sync with linux too
> > 
> > 	this patch series is agianst mtd_dataflash support
> > 
> > The following changes since commit 9428c386f876fa3a8871eeea4725a805cea5c367:
> > 
> >   mtd: add dataflash support (2012-10-31 04:48:39 +0800)
> > 
> > are available in the git repository at:
> > 
> >   git://git.jcrosoft.org/barebox.git delivery/m25p80

Applied, thanks

Sascha

> > 
> > for you to fetch changes up to 35b8b98230dbcfe25973d5ed52a874027b4f3f05:
> > 
> >   m25p80: sync flash support with the kernel (2012-10-31 04:51:08 +0800)
> > 
> > ----------------------------------------------------------------
> > Jean-Christophe PLAGNIOL-VILLARD (2):
> >       m25p80: re-import it againt mtd_add_host
> >       m25p80: sync flash support with the kernel
> > 
> >  arch/arm/boards/freescale-mx6-sabrelite/board.c |    2 +-
> >  drivers/mtd/devices/Kconfig                     |   27 ++++++++++++
> >  drivers/mtd/devices/Makefile                    |    1 +
> >  drivers/{nor => mtd/devices}/m25p80.c           |  512 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------------
> >  drivers/nor/Kconfig                             |   27 ------------
> >  drivers/nor/Makefile                            |    1 -
> >  drivers/nor/m25p80.h                            |   84 ------------------------------------
> >  include/linux/mtd/cfi.h                         |   65 ++++++++++++++++++++++++++++
> >  8 files changed, 371 insertions(+), 348 deletions(-)
> >  rename drivers/{nor => mtd/devices}/m25p80.c (65%)
> >  delete mode 100644 drivers/nor/m25p80.h
> >  create mode 100644 include/linux/mtd/cfi.h
> > 
> > Best Regards,
> > J.
> > 
> > _______________________________________________
> > barebox mailing list
> > barebox at lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/barebox
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From rpjday at crashcourse.ca  Tue Nov 20 07:03:58 2012
From: rpjday at crashcourse.ca (Robert P. J. Day)
Date: Tue, 20 Nov 2012 07:03:58 -0500 (EST)
Subject: where is tftp mounting documented in the source code?
In-Reply-To: <20121120080831.GE10369@pengutronix.de>
References: <alpine.DEB.2.02.1211190946120.13661@oneiric>
 <20121120080831.GE10369@pengutronix.de>
Message-ID: <alpine.DEB.2.02.1211200702001.26129@oneiric>

On Tue, 20 Nov 2012, Sascha Hauer wrote:

> On Mon, Nov 19, 2012 at 09:48:41AM -0500, Robert P. J. Day wrote:
> >
> >   perusing the wiki and ran across page on TFTP support:
> > http://wiki.barebox.org/doku.php?id=filesystems:tftp which suggests:
> >
> >   mount 192.168.1.1 tftp /mnt/tftp
>
> This was the original mount behaviour. This was recently changed to
> mount -t fstype <ip> /dir, mainly to allow making the fstype option
> optional for autodetecting the type. The wiki page is out of date
> here. As a sidenote I brought back the old behaviour as a
> compatibility option to not break old environments.

  so ... the wiki page should be updated to show both the old and new
behaviour?  and the "help mount" content should be extended as well?
what's the proper fix here?

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================




From fabio.porcedda at gmail.com  Tue Nov 20 07:21:06 2012
From: fabio.porcedda at gmail.com (Fabio Porcedda)
Date: Tue, 20 Nov 2012 13:21:06 +0100
Subject: defaultenv-2: how to update a flash partition?
In-Reply-To: <20121114081051.GG10369@pengutronix.de>
References: <CAHkwnC-dDfPesg5vy5V2rj7vdY_DH9cjfJ3gCVsm8xY-DPf35A@mail.gmail.com>
 <20121112075536.GP10369@pengutronix.de>
 <CAHkwnC_FXJ3reNcwDuxhsC=fSG-dDSgg+7njS5sy7aCG5QCRoQ@mail.gmail.com>
 <20121114081051.GG10369@pengutronix.de>
Message-ID: <CAHkwnC8VEYf_DvsywSZ2cUM7QAN0EtRpmd2gKGOuXLaT-4+y9g@mail.gmail.com>

On Wed, Nov 14, 2012 at 9:10 AM, Sascha Hauer <s.hauer at pengutronix.de>wrote:

> On Tue, Nov 13, 2012 at 12:10:45PM +0100, Fabio Porcedda wrote:
> > On Mon, Nov 12, 2012 at 8:55 AM, Sascha Hauer <s.hauer at pengutronix.de
> >wrote:
> >
> > > On Fri, Nov 09, 2012 at 12:06:38PM +0100, Fabio Porcedda wrote:
> > > > ...
> > > ...
> > ...
> > > (I was thinking about adding a -e parameter to cp to eventually skip
> the
> > > first step)
> > >
> >
> > It seems a nice addition for me.
>
> I'll look into it.
>
>
Thanks.


> >
> > There is some plane in the future to add a "update" command, like in
> > "defaultenv"?
>
> I have no plans doing so. Basically not because I do not want such a
> command, but because I do not know what such should do. The old command
> took parameters like 'mmc' or 'net' which was hard to dispatch into
> the different files and does not work with multiple mmc cards, so I
> thought doing it completely on file level would be enough (with the
> above additions added, maybe).
>
>
Thanks for the explanation.


> ...
>

I hope to submit soon the support for the Telit EVK-PRO3.

Best regards
-- 
Fabio Porcedda
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/barebox/attachments/20121120/14f77ac6/attachment.html>

From plagnioj at jcrosoft.com  Tue Nov 20 07:37:38 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Tue, 20 Nov 2012 13:37:38 +0100
Subject: [PATCH 0/2] m25p80: re-import it againt mtd_add_host
In-Reply-To: <20121120084100.GI10369@pengutronix.de>
References: <20121031120122.GF29599@game.jcrosoft.org>
 <20121115101150.GF31820@game.jcrosoft.org>
 <20121120084100.GI10369@pengutronix.de>
Message-ID: <20121120123738.GK8327@game.jcrosoft.org>

On 09:41 Tue 20 Nov     , Sascha Hauer wrote:
> On Thu, Nov 15, 2012 at 11:11:50AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > ping
> > 
> > work on next
> > On 13:01 Wed 31 Oct     , Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > Hi,
> > > 
> > > 	so we now create the cdev via mtd
> > > 
> > > 	This will also simplify sync with linux
> > > 
> > > 	to avoid the m25p8000 or m25p00 the cdev is still named name m25p and the
> > > 	drivers m25p80
> > > 
> > > 	sync with linux too
> > > 
> > > 	this patch series is agianst mtd_dataflash support
> > > 
> > > The following changes since commit 9428c386f876fa3a8871eeea4725a805cea5c367:
> > > 
> > >   mtd: add dataflash support (2012-10-31 04:48:39 +0800)
> > > 
> > > are available in the git repository at:
> > > 
> > >   git://git.jcrosoft.org/barebox.git delivery/m25p80
> 
> Applied, thanks
can we have this one on master it's there for a while

Best Regards,
J.
> 
> Sascha
> 
> > > 
> > > for you to fetch changes up to 35b8b98230dbcfe25973d5ed52a874027b4f3f05:
> > > 
> > >   m25p80: sync flash support with the kernel (2012-10-31 04:51:08 +0800)
> > > 
> > > ----------------------------------------------------------------
> > > Jean-Christophe PLAGNIOL-VILLARD (2):
> > >       m25p80: re-import it againt mtd_add_host
> > >       m25p80: sync flash support with the kernel
> > > 
> > >  arch/arm/boards/freescale-mx6-sabrelite/board.c |    2 +-
> > >  drivers/mtd/devices/Kconfig                     |   27 ++++++++++++
> > >  drivers/mtd/devices/Makefile                    |    1 +
> > >  drivers/{nor => mtd/devices}/m25p80.c           |  512 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------------
> > >  drivers/nor/Kconfig                             |   27 ------------
> > >  drivers/nor/Makefile                            |    1 -
> > >  drivers/nor/m25p80.h                            |   84 ------------------------------------
> > >  include/linux/mtd/cfi.h                         |   65 ++++++++++++++++++++++++++++
> > >  8 files changed, 371 insertions(+), 348 deletions(-)
> > >  rename drivers/{nor => mtd/devices}/m25p80.c (65%)
> > >  delete mode 100644 drivers/nor/m25p80.h
> > >  create mode 100644 include/linux/mtd/cfi.h
> > > 
> > > Best Regards,
> > > J.
> > > 
> > > _______________________________________________
> > > barebox mailing list
> > > barebox at lists.infradead.org
> > > http://lists.infradead.org/mailman/listinfo/barebox
> > 
> > _______________________________________________
> > barebox mailing list
> > barebox at lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/barebox
> > 
> 
> -- 
> Pengutronix e.K.                           |                             |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From plagnioj at jcrosoft.com  Tue Nov 20 09:34:16 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Tue, 20 Nov 2012 15:34:16 +0100
Subject: [PATCH 0/2] m25p80: re-import it againt mtd_add_host
In-Reply-To: <20121120123738.GK8327@game.jcrosoft.org>
References: <20121031120122.GF29599@game.jcrosoft.org>
 <20121115101150.GF31820@game.jcrosoft.org>
 <20121120084100.GI10369@pengutronix.de>
 <20121120123738.GK8327@game.jcrosoft.org>
Message-ID: <20121120143416.GL8327@game.jcrosoft.org>

On 13:37 Tue 20 Nov     , Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 09:41 Tue 20 Nov     , Sascha Hauer wrote:
> > On Thu, Nov 15, 2012 at 11:11:50AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > ping
> > > 
> > > work on next
> > > On 13:01 Wed 31 Oct     , Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > > Hi,
> > > > 
> > > > 	so we now create the cdev via mtd
> > > > 
> > > > 	This will also simplify sync with linux
> > > > 
> > > > 	to avoid the m25p8000 or m25p00 the cdev is still named name m25p and the
> > > > 	drivers m25p80
> > > > 
> > > > 	sync with linux too
> > > > 
> > > > 	this patch series is agianst mtd_dataflash support
> > > > 
> > > > The following changes since commit 9428c386f876fa3a8871eeea4725a805cea5c367:
> > > > 
> > > >   mtd: add dataflash support (2012-10-31 04:48:39 +0800)
> > > > 
> > > > are available in the git repository at:
> > > > 
> > > >   git://git.jcrosoft.org/barebox.git delivery/m25p80
> > 
> > Applied, thanks
> can we have this one on master it's there for a while

And I need on sam9x5ek to have the spi flash

with 2012.12 we will do an official release on linux4sam

Best Regards,
J.


From robert.jarzmik at free.fr  Tue Nov 20 15:43:14 2012
From: robert.jarzmik at free.fr (Robert Jarzmik)
Date: Tue, 20 Nov 2012 21:43:14 +0100
Subject: Ramfs and NULL pointer
In-Reply-To: <20121104225614.GU1641@pengutronix.de> (Sascha Hauer's message of
 "Sun, 4 Nov 2012 23:56:14 +0100")
References: <87zk2xuuds.fsf@free.fr> <87vcdlurvc.fsf@free.fr>
 <20121104225614.GU1641@pengutronix.de>
Message-ID: <87lidwdmzh.fsf@free.fr>

Sascha Hauer <s.hauer at pengutronix.de> writes:

> On Sun, Nov 04, 2012 at 07:48:07PM +0100, Robert Jarzmik wrote:
>> Robert Jarzmik <robert.jarzmik at free.fr> writes:
>> 
>> > Hi there,
>> >
>> > Lately, I see null pointer dereferences in barebox.
>> > I traced the culprit to ramfs ...
>> 
>> Ah and if I take back v2012.09.0, the problem disappears. 
>> I'm not fully in the mood for a bisection of 544 commits ... any idea ?
>
> sha at dude:~/dude/barebox/barebox git lg v2012.09.0..origin/master fs/ramfs.c
> 77322aa Treewide: remove address of the Free Software Foundation
> ad6c28a ramfs: add symlink and readlink support
>
> Both look harmless, so I don't think that the culprit is ramfs itself.
>
> Sorry, no idea. The good news is that due to my compile tests all 544
> commits at least should compile ;)
>
> Do you have some specific command sequence to provoke this?
One part of the problem is a memory corruption from recent commits on
splash/bmp.

Please have a look at the attached patch. I joined Jean-Christophe, as he is the
original author AFAICS, and he might think of another regression along this
patchset which could lighten my debugging sessions.

My board still doesn't boot correctly, so there's probably another regression.

Cheers.

--
Robert

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-splash-fix-splash-breakage.patch
Type: text/x-diff
Size: 1005 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/barebox/attachments/20121120/b20ca1d7/attachment.bin>

From robert.jarzmik at free.fr  Tue Nov 20 15:50:56 2012
From: robert.jarzmik at free.fr (Robert Jarzmik)
Date: Tue, 20 Nov 2012 21:50:56 +0100
Subject: Ramfs and NULL pointer
In-Reply-To: <87lidwdmzh.fsf@free.fr> (Robert Jarzmik's message of "Tue, 20
 Nov 2012 21:43:14 +0100")
References: <87zk2xuuds.fsf@free.fr> <87vcdlurvc.fsf@free.fr>
 <20121104225614.GU1641@pengutronix.de> <87lidwdmzh.fsf@free.fr>
Message-ID: <87haokdmmn.fsf@free.fr>

Robert Jarzmik <robert.jarzmik at free.fr> writes:

> diff --git a/commands/splash.c b/commands/splash.c
> index 65dd530..b0830fb 100644
> --- a/commands/splash.c
> +++ b/commands/splash.c
> @@ -49,6 +49,8 @@ static int do_splash(int argc, char *argv[])
>  	}
>  	image_file = argv[optind];
>  
> +	memset(&sc, 0, sizeof(sc));
> +	memset(&s, 0, sizeof(s));
This last memset is misplaced actually, it should be far upper in the funciton.
So the correct patch would be :

----8>----
>From ea8d7e02533bea9908d8a56ef6b59483f65a3530 Mon Sep 17 00:00:00 2001
From: Robert Jarzmik <robert.jarzmik at free.fr>
Date: Tue, 20 Nov 2012 21:33:49 +0100
Subject: [PATCH] splash: fix splash breakage

Commit 3fa8d74a introduced structures screen and surface.
Unfortunately, these structures are allocated on the stack,
and not initialized.

As a consequence, sc->offscreen might contain a random
value, which is used later for memcpy operations, corrupting
memory.

Fix it by initializing the structures.

Signed-off-by: Robert Jarzmik <robert.jarzmik at free.fr>
---
 commands/splash.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/commands/splash.c b/commands/splash.c
index 65dd530..370c3a2 100644
--- a/commands/splash.c
+++ b/commands/splash.c
@@ -19,6 +19,7 @@ static int do_splash(int argc, char *argv[])
 	u32 bg_color = 0x00000000;
 	bool do_bg = false;
 
+	memset(&s, 0, sizeof(s));
 	s.x = -1;
 	s.y = -1;
 	s.width = -1;
@@ -49,6 +50,7 @@ static int do_splash(int argc, char *argv[])
 	}
 	image_file = argv[optind];
 
+	memset(&sc, 0, sizeof(sc));
 	fd = fb_open(fbdev, &sc, offscreen);
 	if (fd < 0) {
 		perror("fd_open");
-- 
1.7.10.4

-- 
Robert


From plagnioj at jcrosoft.com  Tue Nov 20 16:26:25 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Tue, 20 Nov 2012 22:26:25 +0100
Subject: [PATCH 1/5] pinctrl: at91: provide gpio names
In-Reply-To: <20121120212326.GO4398@game.jcrosoft.org>
References: <20121120212326.GO4398@game.jcrosoft.org>
Message-ID: <1353446789-30819-1-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/pinctrl/pinctrl-at91.c |   15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
index b9e2cbd..401fc96 100644
--- a/drivers/pinctrl/pinctrl-at91.c
+++ b/drivers/pinctrl/pinctrl-at91.c
@@ -1364,9 +1364,10 @@ static int __devinit at91_gpio_probe(struct platform_device *pdev)
 	struct gpio_chip *chip;
 	struct pinctrl_gpio_range *range;
 	int ret = 0;
-	int irq;
+	int irq, i;
 	int alias_idx = of_alias_get_id(np, "gpio");
 	uint32_t ngpio;
+	char **names;
 
 	BUG_ON(alias_idx >= ARRAY_SIZE(gpio_chips));
 	if (gpio_chips[alias_idx]) {
@@ -1436,6 +1437,18 @@ static int __devinit at91_gpio_probe(struct platform_device *pdev)
 			chip->ngpio = ngpio;
 	}
 
+	names = devm_kzalloc(&pdev->dev, sizeof(char*) * chip->ngpio, GFP_KERNEL);
+
+	if (!names) {
+		ret = -ENOMEM;
+		goto clk_err;
+	}
+
+	for (i = 0; i < chip->ngpio; i++)
+		names[i] = kasprintf(GFP_KERNEL, "pio%c%d", alias_idx + 'A', i);
+
+	chip->names = (const char*const*)names;
+
 	range = &at91_chip->range;
 	range->name = chip->label;
 	range->id = alias_idx;
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Tue Nov 20 16:26:26 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Tue, 20 Nov 2012 22:26:26 +0100
Subject: [PATCH 2/5] pinctrl: at91 add deglitch, debounce,
 pull down and schmitt trigger mux option support
In-Reply-To: <1353446789-30819-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121120212326.GO4398@game.jcrosoft.org>
 <1353446789-30819-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1353446789-30819-2-git-send-email-plagnioj@jcrosoft.com>

add :
 set_deglitch: enable/disable deglitch
 set_debounce: enable/disable debounce
 set_pulldown: enable/disable pulldown
 disable_schmitt_trig: disable schmitt trigger

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 .../bindings/pinctrl/atmel,at91-pinctrl.txt        |    9 +-
 drivers/pinctrl/pinctrl-at91.c                     |  111 ++++++++++++++++++++
 2 files changed, 118 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/pinctrl/atmel,at91-pinctrl.txt b/Documentation/devicetree/bindings/pinctrl/atmel,at91-pinctrl.txt
index 20a987e..3a26812 100644
--- a/Documentation/devicetree/bindings/pinctrl/atmel,at91-pinctrl.txt
+++ b/Documentation/devicetree/bindings/pinctrl/atmel,at91-pinctrl.txt
@@ -84,8 +84,13 @@ Required properties for pin configuration node:
   The PERIPH 0 means gpio.
 
 Bits used for CONFIG:
-PULL_UP(1 << 0): indicate this pin need a pull up.
-MULTIDRIVE(1 << 1): indicate this pin need to be configured as multidrive.
+PULL_UP		(1 << 0): indicate this pin need a pull up.
+MULTIDRIVE	(1 << 1): indicate this pin need to be configured as multidrive.
+DEGLITCH	(1 << 2): indicate this pin need deglitch.
+PULL_DOWN	(1 << 3): indicate this pin need a pull down.
+DIS_SCHMIT	(1 << 4): indicate this pin need to disable schmit trigger.
+DEBOUNCE	(1 << 16): indicate this pin need debounce.
+DEBOUNCE_VAL	(0x3fff << 17): debounce val.
 
 NOTE:
 Some requirements for using atmel,at91rm9200-pinctrl binding:
diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
index 401fc96..0d7e6c3 100644
--- a/drivers/pinctrl/pinctrl-at91.c
+++ b/drivers/pinctrl/pinctrl-at91.c
@@ -59,6 +59,12 @@ static int gpio_banks;
 
 #define PULL_UP		(1 << 0)
 #define MULTI_DRIVE	(1 << 1)
+#define DEGLITCH	(1 << 2)
+#define PULL_DOWN	(1 << 3)
+#define DIS_SCHMIT	(1 << 4)
+#define DEBOUNCE	(1 << 16)
+#define DEBOUNCE_VAL_SHIFT	17
+#define DEBOUNCE_VAL	(0x3fff << DEBOUNCE_VAL_SHIFT)
 
 /**
  * struct at91_pmx_func - describes AT91 pinmux functions
@@ -122,6 +128,14 @@ struct at91_pin_group {
  * @mux_B_periph: mux as periph B
  * @mux_C_periph: mux as periph C
  * @mux_D_periph: mux as periph D
+ * @get_deglitch: get deglitch status
+ * @set_deglitch: enable/disable deglitch
+ * @get_debounce: get debounce status
+ * @set_debounce: enable/disable debounce
+ * @get_pulldown: get pulldown status
+ * @set_pulldown: enable/disable pulldown
+ * @get_schmitt_trig: get schmitt trigger status
+ * @disable_schmitt_trig: disable schmitt trigger
  * @irq_type: return irq type
  */
 struct at91_pinctrl_mux_ops {
@@ -130,6 +144,14 @@ struct at91_pinctrl_mux_ops {
 	void (*mux_B_periph)(void __iomem *pio, unsigned mask);
 	void (*mux_C_periph)(void __iomem *pio, unsigned mask);
 	void (*mux_D_periph)(void __iomem *pio, unsigned mask);
+	bool (*get_deglitch)(void __iomem *pio, unsigned pin);
+	void (*set_deglitch)(void __iomem *pio, unsigned mask, bool in_on);
+	bool (*get_debounce)(void __iomem *pio, unsigned pin, u32 *div);
+	void (*set_debounce)(void __iomem *pio, unsigned mask, bool in_on, u32 div);
+	bool (*get_pulldown)(void __iomem *pio, unsigned pin);
+	void (*set_pulldown)(void __iomem *pio, unsigned mask, bool in_on);
+	bool (*get_schmitt_trig)(void __iomem *pio, unsigned pin);
+	void (*disable_schmitt_trig)(void __iomem *pio, unsigned mask);
 	/* irq */
 	int (*irq_type)(struct irq_data *d, unsigned type);
 };
@@ -386,10 +408,68 @@ static enum at91_mux at91_mux_get_periph(void __iomem *pio, unsigned mask)
 	return select + 1;
 }
 
+static bool at91_mux_get_deglitch(void __iomem *pio, unsigned pin)
+{
+	return (__raw_readl(pio + PIO_IFSR) >> pin) & 0x1;
+}
+
+static void at91_mux_set_deglitch(void __iomem *pio, unsigned mask, bool is_on)
+{
+	__raw_writel(mask, pio + (is_on ? PIO_IFER : PIO_IFDR));
+}
+
+static void at91_mux_pio3_set_deglitch(void __iomem *pio, unsigned mask, bool is_on)
+{
+	if (is_on)
+		__raw_writel(mask, pio + PIO_IFSCDR);
+	at91_mux_set_deglitch(pio, mask, is_on);
+}
+
+static bool at91_mux_pio3_get_debounce(void __iomem *pio, unsigned pin, u32 *div)
+{
+	*div = __raw_readl(pio + PIO_SCDR);
+
+	return (__raw_readl(pio + PIO_IFSCSR) >> pin) & 0x1;
+}
+
+static void at91_mux_pio3_set_debounce(void __iomem *pio, unsigned mask,
+				bool is_on, u32 div)
+{
+	if (is_on) {
+		__raw_writel(mask, pio + PIO_IFSCER);
+		__raw_writel(div & PIO_SCDR_DIV, pio + PIO_SCDR);
+		__raw_writel(mask, pio + PIO_IFER);
+	} else {
+		__raw_writel(mask, pio + PIO_IFDR);
+	}
+}
+
+static bool at91_mux_pio3_get_pulldown(void __iomem *pio, unsigned pin)
+{
+	return (__raw_readl(pio + PIO_PPDSR) >> pin) & 0x1;
+}
+
+static void at91_mux_pio3_set_pulldown(void __iomem *pio, unsigned mask, bool is_on)
+{
+	__raw_writel(mask, pio + (is_on ? PIO_PPDER : PIO_PPDDR));
+}
+
+static void at91_mux_pio3_disable_schmitt_trig(void __iomem *pio, unsigned mask)
+{
+	__raw_writel(__raw_readl(pio + PIO_SCHMITT) | mask, pio + PIO_SCHMITT);
+}
+
+static bool at91_mux_pio3_get_schmitt_trig(void __iomem *pio, unsigned pin)
+{
+	return (__raw_readl(pio + PIO_SCHMITT) >> pin) & 0x1;
+}
+
 static struct at91_pinctrl_mux_ops at91rm9200_ops = {
 	.get_periph	= at91_mux_get_periph,
 	.mux_A_periph	= at91_mux_set_A_periph,
 	.mux_B_periph	= at91_mux_set_B_periph,
+	.get_deglitch	= at91_mux_get_deglitch,
+	.set_deglitch	= at91_mux_set_deglitch,
 	.irq_type	= gpio_irq_type,
 };
 
@@ -399,6 +479,14 @@ static struct at91_pinctrl_mux_ops at91sam9x5_ops = {
 	.mux_B_periph	= at91_mux_pio3_set_B_periph,
 	.mux_C_periph	= at91_mux_pio3_set_C_periph,
 	.mux_D_periph	= at91_mux_pio3_set_D_periph,
+	.get_deglitch	= at91_mux_get_deglitch,
+	.set_deglitch	= at91_mux_pio3_set_deglitch,
+	.get_debounce	= at91_mux_pio3_get_debounce,
+	.set_debounce	= at91_mux_pio3_set_debounce,
+	.get_pulldown	= at91_mux_pio3_get_pulldown,
+	.set_pulldown	= at91_mux_pio3_set_pulldown,
+	.get_schmitt_trig = at91_mux_pio3_get_schmitt_trig,
+	.disable_schmitt_trig = at91_mux_pio3_disable_schmitt_trig,
 	.irq_type	= alt_gpio_irq_type,
 };
 
@@ -624,6 +712,7 @@ static int at91_pinconf_get(struct pinctrl_dev *pctldev,
 	struct at91_pinctrl *info = pinctrl_dev_get_drvdata(pctldev);
 	void __iomem *pio;
 	unsigned pin;
+	int div;
 
 	dev_dbg(info->dev, "%s:%d, pin_id=%d, config=0x%lx", __func__, __LINE__, pin_id, *config);
 	pio = pin_to_controller(info, pin_to_bank(pin_id));
@@ -635,6 +724,15 @@ static int at91_pinconf_get(struct pinctrl_dev *pctldev,
 	if (at91_mux_get_pullup(pio, pin))
 		*config |= PULL_UP;
 
+	if (info->ops->get_deglitch && info->ops->get_deglitch(pio, pin))
+		*config |= DEGLITCH;
+	if (info->ops->get_debounce && info->ops->get_debounce(pio, pin, &div))
+		*config |= DEBOUNCE | (div << DEBOUNCE_VAL_SHIFT);
+	if (info->ops->get_pulldown && info->ops->get_pulldown(pio, pin))
+		*config |= PULL_DOWN;
+	if (info->ops->get_schmitt_trig && info->ops->get_schmitt_trig(pio, pin))
+		*config |= DIS_SCHMIT;
+
 	return 0;
 }
 
@@ -649,8 +747,21 @@ static int at91_pinconf_set(struct pinctrl_dev *pctldev,
 	pio = pin_to_controller(info, pin_to_bank(pin_id));
 	mask = pin_to_mask(pin_id % MAX_NB_GPIO_PER_BANK);
 
+	if (config & PULL_UP && config & PULL_DOWN)
+		return -EINVAL;
+
 	at91_mux_set_pullup(pio, mask, config & PULL_UP);
 	at91_mux_set_multidrive(pio, mask, config & MULTI_DRIVE);
+	if (info->ops->set_deglitch)
+		info->ops->set_deglitch(pio, mask, config & DEGLITCH);
+	if (info->ops->set_debounce)
+		info->ops->set_debounce(pio, mask, config & DEBOUNCE,
+				(config & DEBOUNCE_VAL) >> DEBOUNCE_VAL_SHIFT);
+	if (info->ops->set_pulldown)
+		info->ops->set_pulldown(pio, mask, config & PULL_DOWN);
+	if (info->ops->disable_schmitt_trig && config & DIS_SCHMIT)
+		info->ops->disable_schmitt_trig(pio, mask);
+
 	return 0;
 }
 
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Tue Nov 20 16:26:27 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Tue, 20 Nov 2012 22:26:27 +0100
Subject: [PATCH 3/5] ARM: at91sam9: add macb pinctrl support
In-Reply-To: <1353446789-30819-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121120212326.GO4398@game.jcrosoft.org>
 <1353446789-30819-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1353446789-30819-3-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/boot/dts/at91sam9260.dtsi |   42 ++++++++++++++++++++++++++++++++++++
 arch/arm/boot/dts/at91sam9263.dtsi |   30 ++++++++++++++++++++++++++
 arch/arm/boot/dts/at91sam9g45.dtsi |   30 ++++++++++++++++++++++++++
 arch/arm/boot/dts/at91sam9x25.dtsi |   21 ++++++++++++++++++
 arch/arm/boot/dts/at91sam9x5.dtsi  |   30 ++++++++++++++++++++++++++
 5 files changed, 153 insertions(+)

diff --git a/arch/arm/boot/dts/at91sam9260.dtsi b/arch/arm/boot/dts/at91sam9260.dtsi
index 9a24ffb..36f55e3 100644
--- a/arch/arm/boot/dts/at91sam9260.dtsi
+++ b/arch/arm/boot/dts/at91sam9260.dtsi
@@ -216,6 +216,46 @@
 					};
 				};
 
+				macb {
+					pinctrl_macb_rmii: macb_rmii-0 {
+						atmel,pins =
+							<0 12 0x1 0x0	/* PA12 periph A */
+							 0 13 0x1 0x0	/* PA13 periph A */
+							 0 14 0x1 0x0	/* PA14 periph A */
+							 0 15 0x1 0x0	/* PA15 periph A */
+							 0 16 0x1 0x0	/* PA16 periph A */
+							 0 17 0x1 0x0	/* PA17 periph A */
+							 0 18 0x1 0x0	/* PA18 periph A */
+							 0 19 0x1 0x0	/* PA19 periph A */
+							 0 20 0x1 0x0	/* PA20 periph A */
+							 0 21 0x1 0x0>;	/* PA21 periph A */
+					};
+
+					pinctrl_macb_rmii_mii: macb_rmii_mii-0 {
+						atmel,pins =
+							<0 22 0x2 0x0	/* PA22 periph B */
+							 0 23 0x2 0x0	/* PA23 periph B */
+							 0 24 0x2 0x0	/* PA24 periph B */
+							 0 25 0x2 0x0	/* PA25 periph B */
+							 0 26 0x2 0x0	/* PA26 periph B */
+							 0 27 0x2 0x0	/* PA27 periph B */
+							 0 28 0x2 0x0	/* PA28 periph B */
+							 0 29 0x2 0x0>;	/* PA29 periph B */
+					};
+
+					pinctrl_macb_rmii_mii_alt: macb_rmii_mii-1 {
+						atmel,pins =
+							<0 10 0x2 0x0	/* PA10 periph B */
+							 0 11 0x2 0x0	/* PA11 periph B */
+							 0 24 0x2 0x0	/* PA24 periph B */
+							 0 25 0x2 0x0	/* PA25 periph B */
+							 0 26 0x2 0x0	/* PA26 periph B */
+							 0 27 0x2 0x0	/* PA27 periph B */
+							 0 28 0x2 0x0	/* PA28 periph B */
+							 0 29 0x2 0x0>;	/* PA29 periph B */
+					};
+				};
+
 				pioA: gpio at fffff400 {
 					compatible = "atmel,at91rm9200-gpio";
 					reg = <0xfffff400 0x200>;
@@ -326,6 +366,8 @@
 				compatible = "cdns,at32ap7000-macb", "cdns,macb";
 				reg = <0xfffc4000 0x100>;
 				interrupts = <21 4 3>;
+				pinctrl-names = "default";
+				pinctrl-0 = <&pinctrl_macb_rmii>;
 				status = "disabled";
 			};
 
diff --git a/arch/arm/boot/dts/at91sam9263.dtsi b/arch/arm/boot/dts/at91sam9263.dtsi
index 251ccec..148b89a 100644
--- a/arch/arm/boot/dts/at91sam9263.dtsi
+++ b/arch/arm/boot/dts/at91sam9263.dtsi
@@ -163,6 +163,34 @@
 					};
 				};
 
+				macb {
+					pinctrl_macb_rmii: macb_rmii-0 {
+						atmel,pins =
+							<2 25 0x2 0x0	/* PC25 periph B */
+							 4 21 0x1 0x0	/* PE21 periph A */
+							 4 23 0x1 0x0	/* PE23 periph A */
+							 4 24 0x1 0x0	/* PE24 periph A */
+							 4 25 0x1 0x0	/* PE25 periph A */
+							 4 26 0x1 0x0	/* PE26 periph A */
+							 4 27 0x1 0x0	/* PE27 periph A */
+							 4 28 0x1 0x0	/* PE28 periph A */
+							 4 29 0x1 0x0	/* PE29 periph A */
+							 4 30 0x1 0x0>;	/* PE30 periph A */
+					};
+
+					pinctrl_macb_rmii_mii: macb_rmii_mii-0 {
+						atmel,pins =
+							<2 20 0x2 0x0	/* PC20 periph B */
+							 2 21 0x2 0x0	/* PC21 periph B */
+							 2 22 0x2 0x0	/* PC22 periph B */
+							 2 23 0x2 0x0	/* PC23 periph B */
+							 2 24 0x2 0x0	/* PC24 periph B */
+							 2 25 0x2 0x0	/* PC25 periph B */
+							 2 27 0x2 0x0	/* PC27 periph B */
+							 4 22 0x2 0x0>;	/* PE22 periph B */
+					};
+				};
+
 				pioA: gpio at fffff200 {
 					compatible = "atmel,at91rm9200-gpio";
 					reg = <0xfffff200 0x200>;
@@ -260,6 +288,8 @@
 				compatible = "cdns,at32ap7000-macb", "cdns,macb";
 				reg = <0xfffbc000 0x100>;
 				interrupts = <21 4 3>;
+				pinctrl-names = "default";
+				pinctrl-0 = <&pinctrl_macb_rmii>;
 				status = "disabled";
 			};
 
diff --git a/arch/arm/boot/dts/at91sam9g45.dtsi b/arch/arm/boot/dts/at91sam9g45.dtsi
index c340f66..0ad84b6 100644
--- a/arch/arm/boot/dts/at91sam9g45.dtsi
+++ b/arch/arm/boot/dts/at91sam9g45.dtsi
@@ -196,6 +196,34 @@
 					};
 				};
 
+				macb {
+					pinctrl_macb_rmii: macb_rmii-0 {
+						atmel,pins =
+							<0 10 0x1 0x0	/* PA10 periph A */
+							 0 11 0x1 0x0	/* PA11 periph A */
+							 0 12 0x1 0x0	/* PA12 periph A */
+							 0 13 0x1 0x0	/* PA13 periph A */
+							 0 14 0x1 0x0	/* PA14 periph A */
+							 0 15 0x1 0x0	/* PA15 periph A */
+							 0 16 0x1 0x0	/* PA16 periph A */
+							 0 17 0x1 0x0	/* PA17 periph A */
+							 0 18 0x1 0x0	/* PA18 periph A */
+							 0 19 0x1 0x0>;	/* PA19 periph A */
+					};
+
+					pinctrl_macb_rmii_mii: macb_rmii_mii-0 {
+						atmel,pins =
+							<0 6 0x2 0x0	/* PA6 periph B */
+							 0 7 0x2 0x0	/* PA7 periph B */
+							 0 8 0x2 0x0	/* PA8 periph B */
+							 0 9 0x2 0x0	/* PA9 periph B */
+							 0 27 0x2 0x0	/* PA27 periph B */
+							 0 28 0x2 0x0	/* PA28 periph B */
+							 0 29 0x2 0x0	/* PA29 periph B */
+							 0 30 0x2 0x0>;	/* PA30 periph B */
+					};
+				};
+
 				pioA: gpio at fffff200 {
 					compatible = "atmel,at91rm9200-gpio";
 					reg = <0xfffff200 0x200>;
@@ -304,6 +332,8 @@
 				compatible = "cdns,at32ap7000-macb", "cdns,macb";
 				reg = <0xfffbc000 0x100>;
 				interrupts = <25 4 3>;
+				pinctrl-names = "default";
+				pinctrl-0 = <&pinctrl_macb_rmii>;
 				status = "disabled";
 			};
 
diff --git a/arch/arm/boot/dts/at91sam9x25.dtsi b/arch/arm/boot/dts/at91sam9x25.dtsi
index 956c65f..54eb33b 100644
--- a/arch/arm/boot/dts/at91sam9x25.dtsi
+++ b/arch/arm/boot/dts/at91sam9x25.dtsi
@@ -22,6 +22,27 @@
 				       0x80000000 0xfffd0000 0xb83fffff  /* pioC */
 				       0x003fffff 0x003f8000 0x00000000  /* pioD */
 				      >;
+
+				macb1 {
+					pinctrl_macb1_rmii: macb1_rmii-0 {
+						atmel,pins =
+							<2 16 0x2 0x0	/* PC16 periph B */
+							 2 18 0x2 0x0	/* PC18 periph B */
+							 2 19 0x2 0x0	/* PC19 periph B */
+							 2 20 0x2 0x0	/* PC20 periph B */
+							 2 21 0x2 0x0	/* PC21 periph B */
+							 2 27 0x2 0x0	/* PC27 periph B */
+							 2 28 0x2 0x0	/* PC28 periph B */
+							 2 29 0x2 0x0	/* PC29 periph B */
+							 2 30 0x2 0x0	/* PC30 periph B */
+							 2 31 0x2 0x0>;	/* PC31 periph B */
+					};
+				};
+			};
+
+			macb1: ethernet at f8030000 {
+				pinctrl-names = "default";
+				pinctrl-0 = <&pinctrl_macb1_rmii>;
 			};
 		};
 	};
diff --git a/arch/arm/boot/dts/at91sam9x5.dtsi b/arch/arm/boot/dts/at91sam9x5.dtsi
index 6a40b77..9fd7159 100644
--- a/arch/arm/boot/dts/at91sam9x5.dtsi
+++ b/arch/arm/boot/dts/at91sam9x5.dtsi
@@ -206,6 +206,34 @@
 					};
 				};
 
+				macb0 {
+					pinctrl_macb0_rmii: macb0_rmii-0 {
+						atmel,pins =
+							<1 0 0x1 0x0	/* PB0 periph A */
+							 1 1 0x1 0x0	/* PB1 periph A */
+							 1 2 0x1 0x0	/* PB2 periph A */
+							 1 3 0x1 0x0	/* PB3 periph A */
+							 1 4 0x1 0x0	/* PB4 periph A */
+							 1 5 0x1 0x0	/* PB5 periph A */
+							 1 6 0x1 0x0	/* PB6 periph A */
+							 1 7 0x1 0x0	/* PB7 periph A */
+							 1 9 0x1 0x0	/* PB9 periph A */
+							 1 10 0x1 0x0>;	/* PB10 periph A */
+					};
+
+					pinctrl_macb0_rmii_mii: macb0_rmii_mii-0 {
+						atmel,pins =
+							<1 8 0x1 0x0	/* PA8 periph A */
+							 1 11 0x1 0x0	/* PA11 periph A */
+							 1 12 0x1 0x0	/* PA12 periph A */
+							 1 13 0x1 0x0	/* PA13 periph A */
+							 1 14 0x1 0x0	/* PA14 periph A */
+							 1 15 0x1 0x0	/* PA15 periph A */
+							 1 16 0x1 0x0	/* PA16 periph A */
+							 1 17 0x1 0x0>;	/* PA17 periph A */
+					};
+				};
+
 				pioA: gpio at fffff400 {
 					compatible = "atmel,at91sam9x5-gpio", "atmel,at91rm9200-gpio";
 					reg = <0xfffff400 0x200>;
@@ -295,6 +323,8 @@
 				compatible = "cdns,at32ap7000-macb", "cdns,macb";
 				reg = <0xf802c000 0x100>;
 				interrupts = <24 4 3>;
+				pinctrl-names = "default";
+				pinctrl-0 = <&pinctrl_macb0_rmii>;
 				status = "disabled";
 			};
 
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Tue Nov 20 16:26:29 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Tue, 20 Nov 2012 22:26:29 +0100
Subject: [PATCH 5/5] ARM: at91: dt: at91sam9260: split rts and cts pinctrl not
In-Reply-To: <1353446789-30819-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121120212326.GO4398@game.jcrosoft.org>
 <1353446789-30819-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1353446789-30819-5-git-send-email-plagnioj@jcrosoft.com>

as we just use the rts and not the rts & cts for rs485

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/boot/dts/at91sam9260.dtsi          |   40 +++++++++++++++++++--------
 arch/arm/boot/dts/at91sam9263.dtsi          |   30 ++++++++++++++------
 arch/arm/boot/dts/at91sam9263ek.dts         |    5 +++-
 arch/arm/boot/dts/at91sam9g20ek_common.dtsi |    3 +-
 arch/arm/boot/dts/at91sam9g45.dtsi          |   40 +++++++++++++++++++--------
 arch/arm/boot/dts/at91sam9m10g45ek.dts      |    5 +++-
 arch/arm/boot/dts/at91sam9n12.dtsi          |   30 ++++++++++++++------
 arch/arm/boot/dts/at91sam9x5.dtsi           |   40 +++++++++++++++++++--------
 8 files changed, 136 insertions(+), 57 deletions(-)

diff --git a/arch/arm/boot/dts/at91sam9260.dtsi b/arch/arm/boot/dts/at91sam9260.dtsi
index 40bf329..a5d9460 100644
--- a/arch/arm/boot/dts/at91sam9260.dtsi
+++ b/arch/arm/boot/dts/at91sam9260.dtsi
@@ -127,10 +127,14 @@
 							 1 5 0x1 0x0>;	/* PB5 periph A */
 					};
 
-					pinctrl_usart0_rts_cts: usart0_rts_cts-0 {
+					pinctrl_usart0_rts: usart0_rts-0 {
 						atmel,pins =
-							<1 26 0x1 0x0	/* PB26 periph A */
-							 1 27 0x1 0x0>;	/* PB27 periph A */
+							<1 26 0x1 0x0>;	/* PB26 periph A */
+					};
+
+					pinctrl_usart0_cts: usart0_cts-0 {
+						atmel,pins =
+							<1 27 0x1 0x0>;	/* PB27 periph A */
 					};
 
 					pinctrl_usart0_dtr_dsr: usart0_dtr_dsr-0 {
@@ -157,10 +161,14 @@
 							 2 7 0x1 0x0>;	/* PB7 periph A */
 					};
 
-					pinctrl_usart1_rts_cts: usart1_rts_cts-0 {
+					pinctrl_usart1_rts: usart1_rts-0 {
+						atmel,pins =
+							<1 28 0x1 0x0>;	/* PB28 periph A */
+					};
+
+					pinctrl_usart1_cts: usart1_cts-0 {
 						atmel,pins =
-							<1 28 0x1 0x0	/* PB28 periph A */
-							 1 29 0x1 0x0>;	/* PB29 periph A */
+							<1 29 0x1 0x0>;	/* PB29 periph A */
 					};
 				};
 
@@ -171,10 +179,14 @@
 							 1 9 0x1 0x0>;	/* PB9 periph A */
 					};
 
-					pinctrl_usart2_rts_cts: usart2_rts_cts-0 {
+					pinctrl_usart2_rts: usart2_rts-0 {
 						atmel,pins =
-							<0 4 0x1 0x0	/* PA4 periph A */
-							 0 5 0x1 0x0>;	/* PA5 periph A */
+							<0 4 0x1 0x0>;	/* PA4 periph A */
+					};
+
+					pinctrl_usart2_cts: usart2_cts-0 {
+						atmel,pins =
+							<0 5 0x1 0x0>;	/* PA5 periph A */
 					};
 				};
 
@@ -185,10 +197,14 @@
 							 2 11 0x1 0x0>;	/* PB11 periph A */
 					};
 
-					pinctrl_usart3_rts_cts: usart3_rts_cts-0 {
+					pinctrl_usart3_rts: usart3_rts-0 {
+						atmel,pins =
+							<3 8 0x2 0x0>;	/* PB8 periph B */
+					};
+
+					pinctrl_usart3_cts: usart3_cts-0 {
 						atmel,pins =
-							<3 8 0x2 0x0	/* PB8 periph B */
-							 3 10 0x2 0x0>;	/* PB10 periph B */
+							<3 10 0x2 0x0>;	/* PB10 periph B */
 					};
 				};
 
diff --git a/arch/arm/boot/dts/at91sam9263.dtsi b/arch/arm/boot/dts/at91sam9263.dtsi
index cf4b59f..a14aa3d 100644
--- a/arch/arm/boot/dts/at91sam9263.dtsi
+++ b/arch/arm/boot/dts/at91sam9263.dtsi
@@ -120,10 +120,14 @@
 							 0 27 0x1 0x0>;	/* PA27 periph A */
 					};
 
-					pinctrl_usart0_rts_cts: usart0_rts_cts-0 {
+					pinctrl_usart0_rts: usart0_rts-0 {
 						atmel,pins =
-							<0 28 0x1 0x0	/* PA28 periph A */
-							 0 29 0x1 0x0>;	/* PA29 periph A */
+							<0 28 0x1 0x0>;	/* PA28 periph A */
+					};
+
+					pinctrl_usart0_cts: usart0_cts-0 {
+						atmel,pins =
+							<0 29 0x1 0x0>;	/* PA29 periph A */
 					};
 				};
 
@@ -134,10 +138,14 @@
 							 3 1 0x1 0x0>;	/* PD1 periph A */
 					};
 
-					pinctrl_usart1_rts_cts: usart1_rts_cts-0 {
+					pinctrl_usart1_rts: usart1_rts-0 {
 						atmel,pins =
-							<3 7 0x2 0x0	/* PD7 periph B */
-							 3 8 0x2 0x0>;	/* PD8 periph B */
+							<3 7 0x2 0x0>;	/* PD7 periph B */
+					};
+
+					pinctrl_usart1_cts: usart1_cts-0 {
+						atmel,pins =
+							<3 8 0x2 0x0>;	/* PD8 periph B */
 					};
 				};
 
@@ -148,10 +156,14 @@
 							 3 3 0x1 0x0>;	/* PD3 periph A */
 					};
 
-					pinctrl_usart2_rts_cts: usart2_rts_cts-0 {
+					pinctrl_usart2_rts: usart2_rts-0 {
+						atmel,pins =
+							<3 5 0x2 0x0>;	/* PD5 periph B */
+					};
+
+					pinctrl_usart2_cts: usart2_cts-0 {
 						atmel,pins =
-							<3 5 0x2 0x0	/* PD5 periph B */
-							 4 6 0x2 0x0>;	/* PD6 periph B */
+							<4 6 0x2 0x0>;	/* PD6 periph B */
 					};
 				};
 
diff --git a/arch/arm/boot/dts/at91sam9263ek.dts b/arch/arm/boot/dts/at91sam9263ek.dts
index 3434373..e6a57a3 100644
--- a/arch/arm/boot/dts/at91sam9263ek.dts
+++ b/arch/arm/boot/dts/at91sam9263ek.dts
@@ -38,7 +38,10 @@
 			};
 
 			usart0: serial at fff8c000 {
-				pinctrl-0 = <&pinctrl_usart0 &pinctrl_usart0_rts_cts>;
+				pinctrl-0 = <
+					&pinctrl_usart0
+					&pinctrl_usart0_rts
+					&pinctrl_usart0_cts>;
 				status = "okay";
 			};
 
diff --git a/arch/arm/boot/dts/at91sam9g20ek_common.dtsi b/arch/arm/boot/dts/at91sam9g20ek_common.dtsi
index 04f048f..59244d9 100644
--- a/arch/arm/boot/dts/at91sam9g20ek_common.dtsi
+++ b/arch/arm/boot/dts/at91sam9g20ek_common.dtsi
@@ -37,7 +37,8 @@
 			usart0: serial at fffb0000 {
 				pinctrl-0 =
 					<&pinctrl_usart0
-					 &pinctrl_usart0_rts_cts
+					 &pinctrl_usart0_rts
+					 &pinctrl_usart0_cts
 					 &pinctrl_usart0_dtr_dsr
 					 &pinctrl_usart0_dcd
 					 &pinctrl_usart0_ri>;
diff --git a/arch/arm/boot/dts/at91sam9g45.dtsi b/arch/arm/boot/dts/at91sam9g45.dtsi
index 56ce896..dc9a4ee 100644
--- a/arch/arm/boot/dts/at91sam9g45.dtsi
+++ b/arch/arm/boot/dts/at91sam9g45.dtsi
@@ -139,10 +139,14 @@
 							 1 18 0x1 0x0>;	/* PB18 periph A */
 					};
 
-					pinctrl_usart0_rts_cts: usart0_rts_cts-0 {
+					pinctrl_usart0_rts: usart0_rts-0 {
 						atmel,pins =
-							<1 17 0x2 0x0	/* PB17 periph B */
-							 1 15 0x2 0x0>;	/* PB15 periph B */
+							<1 17 0x2 0x0>;	/* PB17 periph B */
+					};
+
+					pinctrl_usart0_cts: usart0_cts-0 {
+						atmel,pins =
+							<1 15 0x2 0x0>;	/* PB15 periph B */
 					};
 				};
 
@@ -153,10 +157,14 @@
 							 1 5 0x1 0x0>;	/* PB5 periph A */
 					};
 
-					pinctrl_usart1_rts_cts: usart1_rts_cts-0 {
+					pinctrl_usart1_rts: usart1_rts-0 {
+						atmel,pins =
+							<3 16 0x1 0x0>;	/* PD16 periph A */
+					};
+
+					pinctrl_usart1_cts: usart1_cts-0 {
 						atmel,pins =
-							<3 16 0x1 0x0	/* PD16 periph A */
-							 3 17 0x1 0x0>;	/* PD17 periph A */
+							<3 17 0x1 0x0>;	/* PD17 periph A */
 					};
 				};
 
@@ -167,10 +175,14 @@
 							 1 7 0x1 0x0>;	/* PB7 periph A */
 					};
 
-					pinctrl_usart2_rts_cts: usart2_rts_cts-0 {
+					pinctrl_usart2_rts: usart2_rts-0 {
 						atmel,pins =
-							<2 9 0x2 0x0	/* PC9 periph B */
-							 2 11 0x2 0x0>;	/* PC11 periph B */
+							<2 9 0x2 0x0>;	/* PC9 periph B */
+					};
+
+					pinctrl_usart2_cts: usart2_cts-0 {
+						atmel,pins =
+							<2 11 0x2 0x0>;	/* PC11 periph B */
 					};
 				};
 
@@ -181,10 +193,14 @@
 							 1 9 0x1 0x0>;	/* PB8 periph A */
 					};
 
-					pinctrl_usart3_rts_cts: usart3_rts_cts-0 {
+					pinctrl_usart3_rts: usart3_rts-0 {
+						atmel,pins =
+							<0 23 0x2 0x0>;	/* PA23 periph B */
+					};
+
+					pinctrl_usart3_cts: usart3_cts-0 {
 						atmel,pins =
-							<0 23 0x2 0x0	/* PA23 periph B */
-							 0 24 0x2 0x0>;	/* PA24 periph B */
+							<0 24 0x2 0x0>;	/* PA24 periph B */
 					};
 				};
 
diff --git a/arch/arm/boot/dts/at91sam9m10g45ek.dts b/arch/arm/boot/dts/at91sam9m10g45ek.dts
index 0d9674b..afd5867 100644
--- a/arch/arm/boot/dts/at91sam9m10g45ek.dts
+++ b/arch/arm/boot/dts/at91sam9m10g45ek.dts
@@ -39,7 +39,10 @@
 			};
 
 			usart1: serial at fff90000 {
-				pinctrl-0 = <&pinctrl_usart1 &pinctrl_usart1_rts_cts>;
+				pinctrl-0 =
+					<&pinctrl_usart1
+					 &pinctrl_usart1_rts
+					 &pinctrl_usart1_cts>;
 				status = "okay";
 			};
 
diff --git a/arch/arm/boot/dts/at91sam9n12.dtsi b/arch/arm/boot/dts/at91sam9n12.dtsi
index 10547bc..1667937 100644
--- a/arch/arm/boot/dts/at91sam9n12.dtsi
+++ b/arch/arm/boot/dts/at91sam9n12.dtsi
@@ -132,10 +132,14 @@
 							 0 0 0x1 0x0>;	/* PA0 periph A */
 					};
 
-					pinctrl_usart0_rts_cts: usart0_rts_cts-0 {
+					pinctrl_usart0_rts: usart0_rts-0 {
 						atmel,pins =
-							<0 2 0x1 0x0	/* PA2 periph A */
-							 0 3 0x1 0x0>;	/* PA3 periph A */
+							<0 2 0x1 0x0>;	/* PA2 periph A */
+					};
+
+					pinctrl_usart0_cts: usart0_cts-0 {
+						atmel,pins =
+							<0 3 0x1 0x0>;	/* PA3 periph A */
 					};
 				};
 
@@ -154,10 +158,14 @@
 							 0 7 0x1 0x0>;	/* PA7 periph A */
 					};
 
-					pinctrl_usart2_rts_cts: usart2_rts_cts-0 {
+					pinctrl_usart2_rts: usart2_rts-0 {
 						atmel,pins =
-							<1 0 0x2 0x0	/* PB0 periph B */
-							 1 1 0x2 0x0>;	/* PB1 periph B */
+							<1 0 0x2 0x0>;	/* PB0 periph B */
+					};
+
+					pinctrl_usart2_cts: usart2_cts-0 {
+						atmel,pins =
+							<1 1 0x2 0x0>;	/* PB1 periph B */
 					};
 				};
 
@@ -168,10 +176,14 @@
 							 2 22 0x2 0x0>;	/* PC22 periph B */
 					};
 
-					pinctrl_usart3_rts_cts: usart3_rts_cts-0 {
+					pinctrl_usart3_rts: usart3_rts-0 {
+						atmel,pins =
+							<2 24 0x2 0x0>;	/* PC24 periph B */
+					};
+
+					pinctrl_usart3_cts: usart3_cts-0 {
 						atmel,pins =
-							<2 24 0x2 0x0	/* PC24 periph B */
-							 2 25 0x2 0x0>;	/* PC25 periph B */
+							<2 25 0x2 0x0>;	/* PC25 periph B */
 					};
 				};
 
diff --git a/arch/arm/boot/dts/at91sam9x5.dtsi b/arch/arm/boot/dts/at91sam9x5.dtsi
index 9dac006..3642ab1 100644
--- a/arch/arm/boot/dts/at91sam9x5.dtsi
+++ b/arch/arm/boot/dts/at91sam9x5.dtsi
@@ -133,10 +133,14 @@
 							 0 1 0x1 0x0>;	/* PA1 periph A */
 					};
 
-					pinctrl_usart0_rts_cts: usart0_rts_cts-0 {
+					pinctrl_usart0_rts: usart0_rts-0 {
 						atmel,pins =
-							<0 2 0x1 0x0	/* PA2 periph A */
-							 0 3 0x1 0x0>;	/* PA3 periph A */
+							<0 2 0x1 0x0>;	/* PA2 periph A */
+					};
+
+					pinctrl_usart0_cts: usart0_cts-0 {
+						atmel,pins =
+							<0 3 0x1 0x0>;	/* PA3 periph A */
 					};
 				};
 
@@ -147,10 +151,14 @@
 							 0 6 0x1 0x0>;	/* PA6 periph A */
 					};
 
-					pinctrl_usart1_rts_cts: usart1_rts_cts-0 {
+					pinctrl_usart1_rts: usart1_rts-0 {
+						atmel,pins =
+							<3 27 0x3 0x0>;	/* PC27 periph C */
+					};
+
+					pinctrl_usart1_cts: usart1_cts-0 {
 						atmel,pins =
-							<3 27 0x3 0x0	/* PC27 periph C */
-							 3 28 0x3 0x0>;	/* PC28 periph C */
+							<3 28 0x3 0x0>;	/* PC28 periph C */
 					};
 				};
 
@@ -161,10 +169,14 @@
 							 0 8 0x1 0x0>;	/* PA8 periph A */
 					};
 
-					pinctrl_uart2_rts_cts: uart2_rts_cts-0 {
+					pinctrl_uart2_rts: uart2_rts-0 {
 						atmel,pins =
-							<0 0 0x2 0x0	/* PB0 periph B */
-							 0 1 0x2 0x0>;	/* PB1 periph B */
+							<0 0 0x2 0x0>;	/* PB0 periph B */
+					};
+
+					pinctrl_uart2_cts: uart2_cts-0 {
+						atmel,pins =
+							<0 1 0x2 0x0>;	/* PB1 periph B */
 					};
 				};
 
@@ -175,10 +187,14 @@
 							 3 23 0x2 0x0>;	/* PC23 periph B */
 					};
 
-					pinctrl_usart3_rts_cts: usart3_rts_cts-0 {
+					pinctrl_usart3_rts: usart3_rts-0 {
+						atmel,pins =
+							<3 24 0x2 0x0>;	/* PC24 periph B */
+					};
+
+					pinctrl_usart3_cts: usart3_cts-0 {
 						atmel,pins =
-							<3 24 0x2 0x0	/* PC24 periph B */
-							 3 25 0x2 0x0>;	/* PC25 periph B */
+							<3 25 0x2 0x0>;	/* PC25 periph B */
 					};
 				};
 
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Tue Nov 20 16:26:28 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Tue, 20 Nov 2012 22:26:28 +0100
Subject: [PATCH 4/5] ARM: at91: fix usart/uart namimg in pinctrl
In-Reply-To: <1353446789-30819-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121120212326.GO4398@game.jcrosoft.org>
 <1353446789-30819-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1353446789-30819-4-git-send-email-plagnioj@jcrosoft.com>

USART are the full pin uart
DBGU the debug Unit
UART the two pin uart

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/boot/dts/at91sam9260.dtsi          |   58 +++++++++++++--------------
 arch/arm/boot/dts/at91sam9263.dtsi          |   24 +++++------
 arch/arm/boot/dts/at91sam9263ek.dts         |    2 +-
 arch/arm/boot/dts/at91sam9g20ek_common.dtsi |   10 ++---
 arch/arm/boot/dts/at91sam9g45.dtsi          |   30 +++++++-------
 arch/arm/boot/dts/at91sam9m10g45ek.dts      |    2 +-
 arch/arm/boot/dts/at91sam9n12.dtsi          |   38 +++++++++---------
 arch/arm/boot/dts/at91sam9x5.dtsi           |   36 ++++++++---------
 8 files changed, 100 insertions(+), 100 deletions(-)

diff --git a/arch/arm/boot/dts/at91sam9260.dtsi b/arch/arm/boot/dts/at91sam9260.dtsi
index 36f55e3..40bf329 100644
--- a/arch/arm/boot/dts/at91sam9260.dtsi
+++ b/arch/arm/boot/dts/at91sam9260.dtsi
@@ -21,8 +21,8 @@
 		serial2 = &usart1;
 		serial3 = &usart2;
 		serial4 = &usart3;
-		serial5 = &usart4;
-		serial6 = &usart5;
+		serial5 = &uart0;
+		serial6 = &uart1;
 		gpio0 = &pioA;
 		gpio1 = &pioB;
 		gpio2 = &pioC;
@@ -120,88 +120,88 @@
 					};
 				};
 
-				uart0 {
-					pinctrl_uart0: uart0-0 {
+				usart0 {
+					pinctrl_usart0: usart0-0 {
 						atmel,pins =
 							<1 4 0x1 0x0	/* PB4 periph A */
 							 1 5 0x1 0x0>;	/* PB5 periph A */
 					};
 
-					pinctrl_uart0_rts_cts: uart0_rts_cts-0 {
+					pinctrl_usart0_rts_cts: usart0_rts_cts-0 {
 						atmel,pins =
 							<1 26 0x1 0x0	/* PB26 periph A */
 							 1 27 0x1 0x0>;	/* PB27 periph A */
 					};
 
-					pinctrl_uart0_dtr_dsr: uart0_dtr_dsr-0 {
+					pinctrl_usart0_dtr_dsr: usart0_dtr_dsr-0 {
 						atmel,pins =
 							<1 24 0x1 0x0	/* PB24 periph A */
 							 1 22 0x1 0x0>;	/* PB22 periph A */
 					};
 
-					pinctrl_uart0_dcd: uart0_dcd-0 {
+					pinctrl_usart0_dcd: usart0_dcd-0 {
 						atmel,pins =
 							<1 23 0x1 0x0>;	/* PB23 periph A */
 					};
 
-					pinctrl_uart0_ri: uart0_ri-0 {
+					pinctrl_usart0_ri: usart0_ri-0 {
 						atmel,pins =
 							<1 25 0x1 0x0>;	/* PB25 periph A */
 					};
 				};
 
-				uart1 {
-					pinctrl_uart1: uart1-0 {
+				usart1 {
+					pinctrl_usart1: usart1-0 {
 						atmel,pins =
 							<2 6 0x1 0x1	/* PB6 periph A with pullup */
 							 2 7 0x1 0x0>;	/* PB7 periph A */
 					};
 
-					pinctrl_uart1_rts_cts: uart1_rts_cts-0 {
+					pinctrl_usart1_rts_cts: usart1_rts_cts-0 {
 						atmel,pins =
 							<1 28 0x1 0x0	/* PB28 periph A */
 							 1 29 0x1 0x0>;	/* PB29 periph A */
 					};
 				};
 
-				uart2 {
-					pinctrl_uart2: uart2-0 {
+				usart2 {
+					pinctrl_usart2: usart2-0 {
 						atmel,pins =
 							<1 8 0x1 0x1	/* PB8 periph A with pullup */
 							 1 9 0x1 0x0>;	/* PB9 periph A */
 					};
 
-					pinctrl_uart2_rts_cts: uart2_rts_cts-0 {
+					pinctrl_usart2_rts_cts: usart2_rts_cts-0 {
 						atmel,pins =
 							<0 4 0x1 0x0	/* PA4 periph A */
 							 0 5 0x1 0x0>;	/* PA5 periph A */
 					};
 				};
 
-				uart3 {
-					pinctrl_uart3: uart3-0 {
+				usart3 {
+					pinctrl_usart3: usart3-0 {
 						atmel,pins =
 							<2 10 0x1 0x1	/* PB10 periph A with pullup */
 							 2 11 0x1 0x0>;	/* PB11 periph A */
 					};
 
-					pinctrl_uart3_rts_cts: uart3_rts_cts-0 {
+					pinctrl_usart3_rts_cts: usart3_rts_cts-0 {
 						atmel,pins =
 							<3 8 0x2 0x0	/* PB8 periph B */
 							 3 10 0x2 0x0>;	/* PB10 periph B */
 					};
 				};
 
-				uart4 {
-					pinctrl_uart4: uart4-0 {
+				uart0 {
+					pinctrl_uart0: uart0-0 {
 						atmel,pins =
 							<0 31 0x2 0x1	/* PA31 periph B with pullup */
 							 0 30 0x2 0x0>;	/* PA30 periph B */
 					};
 				};
 
-				uart5 {
-					pinctrl_uart5: uart5-0 {
+				uart1 {
+					pinctrl_uart1: uart1-0 {
 						atmel,pins =
 							<2 12 0x1 0x1	/* PB12 periph A with pullup */
 							 2 13 0x1 0x0>;	/* PB13 periph A */
@@ -303,7 +303,7 @@
 				atmel,use-dma-rx;
 				atmel,use-dma-tx;
 				pinctrl-names = "default";
-				pinctrl-0 = <&pinctrl_uart0>;
+				pinctrl-0 = <&pinctrl_usart0>;
 				status = "disabled";
 			};
 
@@ -314,7 +314,7 @@
 				atmel,use-dma-rx;
 				atmel,use-dma-tx;
 				pinctrl-names = "default";
-				pinctrl-0 = <&pinctrl_uart1>;
+				pinctrl-0 = <&pinctrl_usart1>;
 				status = "disabled";
 			};
 
@@ -325,7 +325,7 @@
 				atmel,use-dma-rx;
 				atmel,use-dma-tx;
 				pinctrl-names = "default";
-				pinctrl-0 = <&pinctrl_uart2>;
+				pinctrl-0 = <&pinctrl_usart2>;
 				status = "disabled";
 			};
 
@@ -336,29 +336,29 @@
 				atmel,use-dma-rx;
 				atmel,use-dma-tx;
 				pinctrl-names = "default";
-				pinctrl-0 = <&pinctrl_uart3>;
+				pinctrl-0 = <&pinctrl_usart3>;
 				status = "disabled";
 			};
 
-			usart4: serial at fffd4000 {
+			uart0: serial at fffd4000 {
 				compatible = "atmel,at91sam9260-usart";
 				reg = <0xfffd4000 0x200>;
 				interrupts = <24 4 5>;
 				atmel,use-dma-rx;
 				atmel,use-dma-tx;
 				pinctrl-names = "default";
-				pinctrl-0 = <&pinctrl_uart4>;
+				pinctrl-0 = <&pinctrl_uart0>;
 				status = "disabled";
 			};
 
-			usart5: serial at fffd8000 {
+			uart1: serial at fffd8000 {
 				compatible = "atmel,at91sam9260-usart";
 				reg = <0xfffd8000 0x200>;
 				interrupts = <25 4 5>;
 				atmel,use-dma-rx;
 				atmel,use-dma-tx;
 				pinctrl-names = "default";
-				pinctrl-0 = <&pinctrl_uart5>;
+				pinctrl-0 = <&pinctrl_uart1>;
 				status = "disabled";
 			};
 
diff --git a/arch/arm/boot/dts/at91sam9263.dtsi b/arch/arm/boot/dts/at91sam9263.dtsi
index 148b89a..cf4b59f 100644
--- a/arch/arm/boot/dts/at91sam9263.dtsi
+++ b/arch/arm/boot/dts/at91sam9263.dtsi
@@ -113,42 +113,42 @@
 					};
 				};
 
-				uart0 {
-					pinctrl_uart0: uart0-0 {
+				usart0 {
+					pinctrl_usart0: usart0-0 {
 						atmel,pins =
 							<0 26 0x1 0x1	/* PA26 periph A with pullup */
 							 0 27 0x1 0x0>;	/* PA27 periph A */
 					};
 
-					pinctrl_uart0_rts_cts: uart0_rts_cts-0 {
+					pinctrl_usart0_rts_cts: usart0_rts_cts-0 {
 						atmel,pins =
 							<0 28 0x1 0x0	/* PA28 periph A */
 							 0 29 0x1 0x0>;	/* PA29 periph A */
 					};
 				};
 
-				uart1 {
-					pinctrl_uart1: uart1-0 {
+				usart1 {
+					pinctrl_usart1: usart1-0 {
 						atmel,pins =
 							<3 0 0x1 0x1	/* PD0 periph A with pullup */
 							 3 1 0x1 0x0>;	/* PD1 periph A */
 					};
 
-					pinctrl_uart1_rts_cts: uart1_rts_cts-0 {
+					pinctrl_usart1_rts_cts: usart1_rts_cts-0 {
 						atmel,pins =
 							<3 7 0x2 0x0	/* PD7 periph B */
 							 3 8 0x2 0x0>;	/* PD8 periph B */
 					};
 				};
 
-				uart2 {
-					pinctrl_uart2: uart2-0 {
+				usart2 {
+					pinctrl_usart2: usart2-0 {
 						atmel,pins =
 							<3 2 0x1 0x1	/* PD2 periph A with pullup */
 							 3 3 0x1 0x0>;	/* PD3 periph A */
 					};
 
-					pinctrl_uart2_rts_cts: uart2_rts_cts-0 {
+					pinctrl_usart2_rts_cts: usart2_rts_cts-0 {
 						atmel,pins =
 							<3 5 0x2 0x0	/* PD5 periph B */
 							 4 6 0x2 0x0>;	/* PD6 periph B */
@@ -258,7 +258,7 @@
 				atmel,use-dma-rx;
 				atmel,use-dma-tx;
 				pinctrl-names = "default";
-				pinctrl-0 = <&pinctrl_uart0>;
+				pinctrl-0 = <&pinctrl_usart0>;
 				status = "disabled";
 			};
 
@@ -269,7 +269,7 @@
 				atmel,use-dma-rx;
 				atmel,use-dma-tx;
 				pinctrl-names = "default";
-				pinctrl-0 = <&pinctrl_uart1>;
+				pinctrl-0 = <&pinctrl_usart1>;
 				status = "disabled";
 			};
 
@@ -280,7 +280,7 @@
 				atmel,use-dma-rx;
 				atmel,use-dma-tx;
 				pinctrl-names = "default";
-				pinctrl-0 = <&pinctrl_uart2>;
+				pinctrl-0 = <&pinctrl_usart2>;
 				status = "disabled";
 			};
 
diff --git a/arch/arm/boot/dts/at91sam9263ek.dts b/arch/arm/boot/dts/at91sam9263ek.dts
index 7cfe9d5..3434373 100644
--- a/arch/arm/boot/dts/at91sam9263ek.dts
+++ b/arch/arm/boot/dts/at91sam9263ek.dts
@@ -38,7 +38,7 @@
 			};
 
 			usart0: serial at fff8c000 {
-				pinctrl-0 = <&pinctrl_uart0 &pinctrl_uart0_rts_cts>;
+				pinctrl-0 = <&pinctrl_usart0 &pinctrl_usart0_rts_cts>;
 				status = "okay";
 			};
 
diff --git a/arch/arm/boot/dts/at91sam9g20ek_common.dtsi b/arch/arm/boot/dts/at91sam9g20ek_common.dtsi
index e33ab0a..04f048f 100644
--- a/arch/arm/boot/dts/at91sam9g20ek_common.dtsi
+++ b/arch/arm/boot/dts/at91sam9g20ek_common.dtsi
@@ -36,11 +36,11 @@
 
 			usart0: serial at fffb0000 {
 				pinctrl-0 =
-					<&pinctrl_uart0
-					 &pinctrl_uart0_rts_cts
-					 &pinctrl_uart0_dtr_dsr
-					 &pinctrl_uart0_dcd
-					 &pinctrl_uart0_ri>;
+					<&pinctrl_usart0
+					 &pinctrl_usart0_rts_cts
+					 &pinctrl_usart0_dtr_dsr
+					 &pinctrl_usart0_dcd
+					 &pinctrl_usart0_ri>;
 				status = "okay";
 			};
 
diff --git a/arch/arm/boot/dts/at91sam9g45.dtsi b/arch/arm/boot/dts/at91sam9g45.dtsi
index 0ad84b6..56ce896 100644
--- a/arch/arm/boot/dts/at91sam9g45.dtsi
+++ b/arch/arm/boot/dts/at91sam9g45.dtsi
@@ -132,14 +132,14 @@
 					};
 				};
 
-				uart0 {
-					pinctrl_uart0: uart0-0 {
+				usart0 {
+					pinctrl_usart0: usart0-0 {
 						atmel,pins =
 							<1 19 0x1 0x1	/* PB19 periph A with pullup */
 							 1 18 0x1 0x0>;	/* PB18 periph A */
 					};
 
-					pinctrl_uart0_rts_cts: uart0_rts_cts-0 {
+					pinctrl_usart0_rts_cts: usart0_rts_cts-0 {
 						atmel,pins =
 							<1 17 0x2 0x0	/* PB17 periph B */
 							 1 15 0x2 0x0>;	/* PB15 periph B */
@@ -147,41 +147,41 @@
 				};
 
 				uart1 {
-					pinctrl_uart1: uart1-0 {
+					pinctrl_usart1: usart1-0 {
 						atmel,pins =
 							<1 4 0x1 0x1	/* PB4 periph A with pullup */
 							 1 5 0x1 0x0>;	/* PB5 periph A */
 					};
 
-					pinctrl_uart1_rts_cts: uart1_rts_cts-0 {
+					pinctrl_usart1_rts_cts: usart1_rts_cts-0 {
 						atmel,pins =
 							<3 16 0x1 0x0	/* PD16 periph A */
 							 3 17 0x1 0x0>;	/* PD17 periph A */
 					};
 				};
 
-				uart2 {
-					pinctrl_uart2: uart2-0 {
+				usart2 {
+					pinctrl_usart2: usart2-0 {
 						atmel,pins =
 							<1 6 0x1 0x1	/* PB6 periph A with pullup */
 							 1 7 0x1 0x0>;	/* PB7 periph A */
 					};
 
-					pinctrl_uart2_rts_cts: uart2_rts_cts-0 {
+					pinctrl_usart2_rts_cts: usart2_rts_cts-0 {
 						atmel,pins =
 							<2 9 0x2 0x0	/* PC9 periph B */
 							 2 11 0x2 0x0>;	/* PC11 periph B */
 					};
 				};
 
-				uart3 {
-					pinctrl_uart3: uart3-0 {
+				usart3 {
+					pinctrl_usart3: usart3-0 {
 						atmel,pins =
 							<1 8 0x1 0x1	/* PB9 periph A with pullup */
 							 1 9 0x1 0x0>;	/* PB8 periph A */
 					};
 
-					pinctrl_uart3_rts_cts: uart3_rts_cts-0 {
+					pinctrl_usart3_rts_cts: usart3_rts_cts-0 {
 						atmel,pins =
 							<0 23 0x2 0x0	/* PA23 periph B */
 							 0 24 0x2 0x0>;	/* PA24 periph B */
@@ -291,7 +291,7 @@
 				atmel,use-dma-rx;
 				atmel,use-dma-tx;
 				pinctrl-names = "default";
-				pinctrl-0 = <&pinctrl_uart0>;
+				pinctrl-0 = <&pinctrl_usart0>;
 				status = "disabled";
 			};
 
@@ -302,7 +302,7 @@
 				atmel,use-dma-rx;
 				atmel,use-dma-tx;
 				pinctrl-names = "default";
-				pinctrl-0 = <&pinctrl_uart1>;
+				pinctrl-0 = <&pinctrl_usart1>;
 				status = "disabled";
 			};
 
@@ -313,7 +313,7 @@
 				atmel,use-dma-rx;
 				atmel,use-dma-tx;
 				pinctrl-names = "default";
-				pinctrl-0 = <&pinctrl_uart2>;
+				pinctrl-0 = <&pinctrl_usart2>;
 				status = "disabled";
 			};
 
@@ -324,7 +324,7 @@
 				atmel,use-dma-rx;
 				atmel,use-dma-tx;
 				pinctrl-names = "default";
-				pinctrl-0 = <&pinctrl_uart3>;
+				pinctrl-0 = <&pinctrl_usart3>;
 				status = "disabled";
 			};
 
diff --git a/arch/arm/boot/dts/at91sam9m10g45ek.dts b/arch/arm/boot/dts/at91sam9m10g45ek.dts
index 6aa28b9..0d9674b 100644
--- a/arch/arm/boot/dts/at91sam9m10g45ek.dts
+++ b/arch/arm/boot/dts/at91sam9m10g45ek.dts
@@ -39,7 +39,7 @@
 			};
 
 			usart1: serial at fff90000 {
-				pinctrl-0 = <&pinctrl_uart0 &pinctrl_uart1_rts_cts>;
+				pinctrl-0 = <&pinctrl_usart1 &pinctrl_usart1_rts_cts>;
 				status = "okay";
 			};
 
diff --git a/arch/arm/boot/dts/at91sam9n12.dtsi b/arch/arm/boot/dts/at91sam9n12.dtsi
index 7b644c5..10547bc 100644
--- a/arch/arm/boot/dts/at91sam9n12.dtsi
+++ b/arch/arm/boot/dts/at91sam9n12.dtsi
@@ -125,66 +125,66 @@
 					};
 				};
 
-				uart0 {
-					pinctrl_uart0: uart0-0 {
+				usart0 {
+					pinctrl_usart0: usart0-0 {
 						atmel,pins =
 							<0 1 0x1 0x1	/* PA1 periph A with pullup */
 							 0 0 0x1 0x0>;	/* PA0 periph A */
 					};
 
-					pinctrl_uart0_rts_cts: uart0_rts_cts-0 {
+					pinctrl_usart0_rts_cts: usart0_rts_cts-0 {
 						atmel,pins =
 							<0 2 0x1 0x0	/* PA2 periph A */
 							 0 3 0x1 0x0>;	/* PA3 periph A */
 					};
 				};
 
-				uart1 {
-					pinctrl_uart1: uart1-0 {
+				usart1 {
+					pinctrl_usart1: usart1-0 {
 						atmel,pins =
 							<0 6 0x1 0x1	/* PA6 periph A with pullup */
 							 0 5 0x1 0x0>;	/* PA5 periph A */
 					};
 				};
 
-				uart2 {
-					pinctrl_uart2: uart2-0 {
+				usart2 {
+					pinctrl_usart2: usart2-0 {
 						atmel,pins =
 							<0 8 0x1 0x1	/* PA8 periph A with pullup */
 							 0 7 0x1 0x0>;	/* PA7 periph A */
 					};
 
-					pinctrl_uart2_rts_cts: uart2_rts_cts-0 {
+					pinctrl_usart2_rts_cts: usart2_rts_cts-0 {
 						atmel,pins =
 							<1 0 0x2 0x0	/* PB0 periph B */
 							 1 1 0x2 0x0>;	/* PB1 periph B */
 					};
 				};
 
-				uart3 {
-					pinctrl_uart3: uart3-0 {
+				usart3 {
+					pinctrl_usart3: usart3-0 {
 						atmel,pins =
 							<2 23 0x2 0x1	/* PC23 periph B with pullup */
 							 2 22 0x2 0x0>;	/* PC22 periph B */
 					};
 
-					pinctrl_uart3_rts_cts: uart3_rts_cts-0 {
+					pinctrl_usart3_rts_cts: usart3_rts_cts-0 {
 						atmel,pins =
 							<2 24 0x2 0x0	/* PC24 periph B */
 							 2 25 0x2 0x0>;	/* PC25 periph B */
 					};
 				};
 
-				usart0 {
-					pinctrl_usart0: usart0-0 {
+				uart0 {
+					pinctrl_uart0: uart0-0 {
 						atmel,pins =
 							<2 9 0x3 0x1	/* PC9 periph C with pullup */
 							 2 8 0x3 0x0>;	/* PC8 periph C */
 					};
 				};
 
-				usart1 {
-					pinctrl_usart1: usart1-0 {
+				uart1 {
+					pinctrl_uart1: uart1-0 {
 						atmel,pins =
 							<2 16 0x3 0x1	/* PC17 periph C with pullup */
 							 2 17 0x3 0x0>;	/* PC16 periph C */
@@ -256,7 +256,7 @@
 				atmel,use-dma-rx;
 				atmel,use-dma-tx;
 				pinctrl-names = "default";
-				pinctrl-0 = <&pinctrl_uart0>;
+				pinctrl-0 = <&pinctrl_usart0>;
 				status = "disabled";
 			};
 
@@ -267,7 +267,7 @@
 				atmel,use-dma-rx;
 				atmel,use-dma-tx;
 				pinctrl-names = "default";
-				pinctrl-0 = <&pinctrl_uart1>;
+				pinctrl-0 = <&pinctrl_usart1>;
 				status = "disabled";
 			};
 
@@ -278,7 +278,7 @@
 				atmel,use-dma-rx;
 				atmel,use-dma-tx;
 				pinctrl-names = "default";
-				pinctrl-0 = <&pinctrl_uart2>;
+				pinctrl-0 = <&pinctrl_usart2>;
 				status = "disabled";
 			};
 
@@ -289,7 +289,7 @@
 				atmel,use-dma-rx;
 				atmel,use-dma-tx;
 				pinctrl-names = "default";
-				pinctrl-0 = <&pinctrl_uart3>;
+				pinctrl-0 = <&pinctrl_usart3>;
 				status = "disabled";
 			};
 
diff --git a/arch/arm/boot/dts/at91sam9x5.dtsi b/arch/arm/boot/dts/at91sam9x5.dtsi
index 9fd7159..9dac006 100644
--- a/arch/arm/boot/dts/at91sam9x5.dtsi
+++ b/arch/arm/boot/dts/at91sam9x5.dtsi
@@ -126,36 +126,36 @@
 					};
 				};
 
-				uart0 {
-					pinctrl_uart0: uart0-0 {
+				usart0 {
+					pinctrl_usart0: usart0-0 {
 						atmel,pins =
 							<0 0 0x1 0x1	/* PA0 periph A with pullup */
 							 0 1 0x1 0x0>;	/* PA1 periph A */
 					};
 
-					pinctrl_uart0_rts_cts: uart0_rts_cts-0 {
+					pinctrl_usart0_rts_cts: usart0_rts_cts-0 {
 						atmel,pins =
 							<0 2 0x1 0x0	/* PA2 periph A */
 							 0 3 0x1 0x0>;	/* PA3 periph A */
 					};
 				};
 
-				uart1 {
-					pinctrl_uart1: uart1-0 {
+				usart1 {
+					pinctrl_usart1: usart1-0 {
 						atmel,pins =
 							<0 5 0x1 0x1	/* PA5 periph A with pullup */
 							 0 6 0x1 0x0>;	/* PA6 periph A */
 					};
 
-					pinctrl_uart1_rts_cts: uart1_rts_cts-0 {
+					pinctrl_usart1_rts_cts: usart1_rts_cts-0 {
 						atmel,pins =
 							<3 27 0x3 0x0	/* PC27 periph C */
 							 3 28 0x3 0x0>;	/* PC28 periph C */
 					};
 				};
 
-				uart2 {
-					pinctrl_uart2: uart2-0 {
+				usart2 {
+					pinctrl_usart2: usart2-0 {
 						atmel,pins =
 							<0 7 0x1 0x1	/* PA7 periph A with pullup */
 							 0 8 0x1 0x0>;	/* PA8 periph A */
@@ -168,30 +168,30 @@
 					};
 				};
 
-				uart3 {
-					pinctrl_uart3: uart3-0 {
+				usart3 {
+					pinctrl_uart3: usart3-0 {
 						atmel,pins =
 							<3 23 0x2 0x1	/* PC22 periph B with pullup */
 							 3 23 0x2 0x0>;	/* PC23 periph B */
 					};
 
-					pinctrl_uart3_rts_cts: uart3_rts_cts-0 {
+					pinctrl_usart3_rts_cts: usart3_rts_cts-0 {
 						atmel,pins =
 							<3 24 0x2 0x0	/* PC24 periph B */
 							 3 25 0x2 0x0>;	/* PC25 periph B */
 					};
 				};
 
-				usart0 {
-					pinctrl_usart0: usart0-0 {
+				uart0 {
+					pinctrl_uart0: uart0-0 {
 						atmel,pins =
 							<3 8 0x3 0x0	/* PC8 periph C */
 							 3 9 0x3 0x1>;	/* PC9 periph C with pullup */
 					};
 				};
 
-				usart1 {
-					pinctrl_usart1: usart1-0 {
+				uart1 {
+					pinctrl_uart1: uart1-0 {
 						atmel,pins =
 							<3 16 0x3 0x0	/* PC16 periph C */
 							 3 17 0x3 0x1>;	/* PC17 periph C with pullup */
@@ -293,7 +293,7 @@
 				atmel,use-dma-rx;
 				atmel,use-dma-tx;
 				pinctrl-names = "default";
-				pinctrl-0 = <&pinctrl_uart0>;
+				pinctrl-0 = <&pinctrl_usart0>;
 				status = "disabled";
 			};
 
@@ -304,7 +304,7 @@
 				atmel,use-dma-rx;
 				atmel,use-dma-tx;
 				pinctrl-names = "default";
-				pinctrl-0 = <&pinctrl_uart1>;
+				pinctrl-0 = <&pinctrl_usart1>;
 				status = "disabled";
 			};
 
@@ -315,7 +315,7 @@
 				atmel,use-dma-rx;
 				atmel,use-dma-tx;
 				pinctrl-names = "default";
-				pinctrl-0 = <&pinctrl_uart2>;
+				pinctrl-0 = <&pinctrl_usart2>;
 				status = "disabled";
 			};
 
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Tue Nov 20 16:35:38 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Tue, 20 Nov 2012 22:35:38 +0100
Subject: [PATCH 1/5] pinctrl: at91: provide gpio names
In-Reply-To: <1353446789-30819-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121120212326.GO4398@game.jcrosoft.org>
 <1353446789-30819-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <20121120213538.GM8327@game.jcrosoft.org>

HI,

	wrong ml

	sorry

Best Regards,
J.
On 22:26 Tue 20 Nov     , Jean-Christophe PLAGNIOL-VILLARD wrote:
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
> ---
>  drivers/pinctrl/pinctrl-at91.c |   15 ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
> index b9e2cbd..401fc96 100644
> --- a/drivers/pinctrl/pinctrl-at91.c
> +++ b/drivers/pinctrl/pinctrl-at91.c
> @@ -1364,9 +1364,10 @@ static int __devinit at91_gpio_probe(struct platform_device *pdev)
>  	struct gpio_chip *chip;
>  	struct pinctrl_gpio_range *range;
>  	int ret = 0;
> -	int irq;
> +	int irq, i;
>  	int alias_idx = of_alias_get_id(np, "gpio");
>  	uint32_t ngpio;
> +	char **names;
>  
>  	BUG_ON(alias_idx >= ARRAY_SIZE(gpio_chips));
>  	if (gpio_chips[alias_idx]) {
> @@ -1436,6 +1437,18 @@ static int __devinit at91_gpio_probe(struct platform_device *pdev)
>  			chip->ngpio = ngpio;
>  	}
>  
> +	names = devm_kzalloc(&pdev->dev, sizeof(char*) * chip->ngpio, GFP_KERNEL);
> +
> +	if (!names) {
> +		ret = -ENOMEM;
> +		goto clk_err;
> +	}
> +
> +	for (i = 0; i < chip->ngpio; i++)
> +		names[i] = kasprintf(GFP_KERNEL, "pio%c%d", alias_idx + 'A', i);
> +
> +	chip->names = (const char*const*)names;
> +
>  	range = &at91_chip->range;
>  	range->name = chip->label;
>  	range->id = alias_idx;
> -- 
> 1.7.10.4
> 


From robert.jarzmik at free.fr  Tue Nov 20 16:57:15 2012
From: robert.jarzmik at free.fr (Robert Jarzmik)
Date: Tue, 20 Nov 2012 22:57:15 +0100
Subject: bmp splash memory corruption
Message-ID: <87boesdjk4.fsf@free.fr>

Hi Jean-Christophe,

I'm having another bmp memory corruption, could you have a look at this too :
(gdb) bt
#0  free (mem=0xa3026688) at common/dlmalloc.c:1362
#1  0xa3f242a4 in image_renderer_close (img=0xa2fa5228) at lib/gui/image_renderer.c:69
#2  0xa3f18ea0 in image_renderer_file (argc=2, argv=<value optimized out>) at include/gui/image_renderer.h:69
#3  do_splash (argc=2, argv=<value optimized out>) at commands/splash.c:70
#4  0xa3f05b2c in execute_command (argc=2, argv=0xa2fa4968) at common/command.c:77
#5  0xa3f01964 in run_pipe_real (ctx=0xa2effda8, pi=0xa2fa4288) at common/hush.c:790
#6  run_list_real (ctx=0xa2effda8, pi=0xa2fa4288) at common/hush.c:914
#7  0xa3f01bfc in run_list (ctx=0xa2effda8, inp=0xa2effd7c, flag=2) at common/hush.c:1033
#8  parse_stream_outer (ctx=0xa2effda8, inp=0xa2effd7c, flag=2) at common/hush.c:1618
#9  0xa3f01d80 in parse_string_outer (ctx=0xa2effda8, 
    s=0xa2f01890 "#!/bin/sh\n\nPATH=/env/bin\nexport PATH\n\n. /env/config\naddpart /dev/mtd0 $mtdparts\n\nusbserial -s \"Mio A701 usb gadget\"\nled keyboard 0\n\nsdcard_override\n\nfb0.enable=1\nsplash /dev/mtd0.barebox-logo\n\nmtd_env"..., flag=2) at common/hush.c:1662
#10 0xa3f01e24 in source_script (path=<value optimized out>, argc=<value optimized out>, argv=<value optimized out>) at common/hush.c:1815
#11 0xa3f01fdc in do_source (argc=2, argv=<value optimized out>) at common/hush.c:1877
#12 0xa3f05b2c in execute_command (argc=2, argv=0xa2f01708) at common/command.c:77
#13 0xa3f01964 in run_pipe_real (ctx=0xa2efff58, pi=0xa2f0ffc8) at common/hush.c:790
#14 run_list_real (ctx=0xa2efff58, pi=0xa2f0ffc8) at common/hush.c:914
#15 0xa3f01bfc in run_list (ctx=0xa2efff58, inp=0xa2efff2c, flag=2) at common/hush.c:1033
#16 parse_stream_outer (ctx=0xa2efff58, inp=0xa2efff2c, flag=2) at common/hush.c:1618
#17 0xa3f01d80 in parse_string_outer (ctx=0xa2efff58, s=0xa3f3477a "source /env/bin/init", flag=2) at common/hush.c:1662
#18 0xa3f01eb8 in run_command (cmd=0xa2f7b7fe "\377\377", flag=<value optimized out>) at common/hush.c:1783
#19 0xa3f07428 in start_barebox () at common/startup.c:124
#20 0xa3f33158 in board_init_lowlevel_return () at arch/arm/cpu/start.c:62

(gdb) p *p
$10 = {prev_size = 15, size = 2750562700, fd = 0xa3f24184, bk = 0xa3f23f24}
(gdb) p/x p->size
$11 = 0xa3f2418c
(gdb) p bmp_open
$12 = {struct image *(char *, int)} 0xa3f2418c <bmp_open>

As you can see here, p->size equals bmp_open(), while p is the
mem2chunk(mem). This _seems_ to imply that the memchunk headers were somehow
corrupted by bmp_open address ... hence my mail to see if that rings a bell to
you.

Cheers.

-- 
Robert


From plagnioj at jcrosoft.com  Wed Nov 21 04:06:25 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Wed, 21 Nov 2012 10:06:25 +0100
Subject: bmp splash memory corruption
In-Reply-To: <87boesdjk4.fsf@free.fr>
References: <87boesdjk4.fsf@free.fr>
Message-ID: <20121121090625.GN8327@game.jcrosoft.org>

On 22:57 Tue 20 Nov     , Robert Jarzmik wrote:
> Hi Jean-Christophe,
try the replied patch
> 
> I'm having another bmp memory corruption, could you have a look at this too :
> (gdb) bt
> #0  free (mem=0xa3026688) at common/dlmalloc.c:1362
> #1  0xa3f242a4 in image_renderer_close (img=0xa2fa5228) at lib/gui/image_renderer.c:69
> #2  0xa3f18ea0 in image_renderer_file (argc=2, argv=<value optimized out>) at include/gui/image_renderer.h:69
> #3  do_splash (argc=2, argv=<value optimized out>) at commands/splash.c:70
> #4  0xa3f05b2c in execute_command (argc=2, argv=0xa2fa4968) at common/command.c:77
> #5  0xa3f01964 in run_pipe_real (ctx=0xa2effda8, pi=0xa2fa4288) at common/hush.c:790
> #6  run_list_real (ctx=0xa2effda8, pi=0xa2fa4288) at common/hush.c:914
> #7  0xa3f01bfc in run_list (ctx=0xa2effda8, inp=0xa2effd7c, flag=2) at common/hush.c:1033
> #8  parse_stream_outer (ctx=0xa2effda8, inp=0xa2effd7c, flag=2) at common/hush.c:1618
> #9  0xa3f01d80 in parse_string_outer (ctx=0xa2effda8, 
>     s=0xa2f01890 "#!/bin/sh\n\nPATH=/env/bin\nexport PATH\n\n. /env/config\naddpart /dev/mtd0 $mtdparts\n\nusbserial -s \"Mio A701 usb gadget\"\nled keyboard 0\n\nsdcard_override\n\nfb0.enable=1\nsplash /dev/mtd0.barebox-logo\n\nmtd_env"..., flag=2) at common/hush.c:1662
> #10 0xa3f01e24 in source_script (path=<value optimized out>, argc=<value optimized out>, argv=<value optimized out>) at common/hush.c:1815
> #11 0xa3f01fdc in do_source (argc=2, argv=<value optimized out>) at common/hush.c:1877
> #12 0xa3f05b2c in execute_command (argc=2, argv=0xa2f01708) at common/command.c:77
> #13 0xa3f01964 in run_pipe_real (ctx=0xa2efff58, pi=0xa2f0ffc8) at common/hush.c:790
> #14 run_list_real (ctx=0xa2efff58, pi=0xa2f0ffc8) at common/hush.c:914
> #15 0xa3f01bfc in run_list (ctx=0xa2efff58, inp=0xa2efff2c, flag=2) at common/hush.c:1033
> #16 parse_stream_outer (ctx=0xa2efff58, inp=0xa2efff2c, flag=2) at common/hush.c:1618
> #17 0xa3f01d80 in parse_string_outer (ctx=0xa2efff58, s=0xa3f3477a "source /env/bin/init", flag=2) at common/hush.c:1662
> #18 0xa3f01eb8 in run_command (cmd=0xa2f7b7fe "\377\377", flag=<value optimized out>) at common/hush.c:1783
> #19 0xa3f07428 in start_barebox () at common/startup.c:124
> #20 0xa3f33158 in board_init_lowlevel_return () at arch/arm/cpu/start.c:62
> 
> (gdb) p *p
> $10 = {prev_size = 15, size = 2750562700, fd = 0xa3f24184, bk = 0xa3f23f24}
> (gdb) p/x p->size
> $11 = 0xa3f2418c
> (gdb) p bmp_open
> $12 = {struct image *(char *, int)} 0xa3f2418c <bmp_open>
> 
> As you can see here, p->size equals bmp_open(), while p is the
> mem2chunk(mem). This _seems_ to imply that the memchunk headers were somehow
> corrupted by bmp_open address ... hence my mail to see if that rings a bell to
> you.
> 
> Cheers.
> 
> -- 
> Robert


From plagnioj at jcrosoft.com  Wed Nov 21 04:07:46 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Wed, 21 Nov 2012 10:07:46 +0100
Subject: [PATCH 1/2] splash: init struct allocated the stack to 0
In-Reply-To: <87boesdjk4.fsf@free.fr>
References: <87boesdjk4.fsf@free.fr>
Message-ID: <1353488867-24020-1-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 commands/splash.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/commands/splash.c b/commands/splash.c
index 65dd530..4cc463e 100644
--- a/commands/splash.c
+++ b/commands/splash.c
@@ -19,6 +19,10 @@ static int do_splash(int argc, char *argv[])
 	u32 bg_color = 0x00000000;
 	bool do_bg = false;
 
+	memset(&s, 0, sizeof(s));
+	memset(&sc, 0, sizeof(sc));
+	memset(&info, 0, sizeof(info));
+
 	s.x = -1;
 	s.y = -1;
 	s.width = -1;
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Wed Nov 21 04:07:47 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Wed, 21 Nov 2012 10:07:47 +0100
Subject: [PATCH 2/2] bmp: specify we need to keep the data read from the file
In-Reply-To: <1353488867-24020-1-git-send-email-plagnioj@jcrosoft.com>
References: <87boesdjk4.fsf@free.fr>
 <1353488867-24020-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1353488867-24020-2-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 lib/gui/bmp.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/gui/bmp.c b/lib/gui/bmp.c
index d576121..fce0e69 100644
--- a/lib/gui/bmp.c
+++ b/lib/gui/bmp.c
@@ -125,6 +125,7 @@ static struct image_renderer bmp = {
 	.open = bmp_open,
 	.close = bmp_close,
 	.renderer = bmp_renderer,
+	.keep_file_data = 1,
 };
 
 static int bmp_init(void)
-- 
1.7.10.4



From s.hauer at pengutronix.de  Wed Nov 21 04:11:28 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Wed, 21 Nov 2012 10:11:28 +0100
Subject: where is tftp mounting documented in the source code?
In-Reply-To: <alpine.DEB.2.02.1211200702001.26129@oneiric>
References: <alpine.DEB.2.02.1211190946120.13661@oneiric>
 <20121120080831.GE10369@pengutronix.de>
 <alpine.DEB.2.02.1211200702001.26129@oneiric>
Message-ID: <20121121091128.GO10369@pengutronix.de>

On Tue, Nov 20, 2012 at 07:03:58AM -0500, Robert P. J. Day wrote:
> On Tue, 20 Nov 2012, Sascha Hauer wrote:
> 
> > On Mon, Nov 19, 2012 at 09:48:41AM -0500, Robert P. J. Day wrote:
> > >
> > >   perusing the wiki and ran across page on TFTP support:
> > > http://wiki.barebox.org/doku.php?id=filesystems:tftp which suggests:
> > >
> > >   mount 192.168.1.1 tftp /mnt/tftp
> >
> > This was the original mount behaviour. This was recently changed to
> > mount -t fstype <ip> /dir, mainly to allow making the fstype option
> > optional for autodetecting the type. The wiki page is out of date
> > here. As a sidenote I brought back the old behaviour as a
> > compatibility option to not break old environments.
> 
>   so ... the wiki page should be updated to show both the old and new
> behaviour?  and the "help mount" content should be extended as well?
> what's the proper fix here?

I intentionally did not document the old behaviour. I think the help
texts in the binary should be rather terse. In the wiki though it
shouldn't hurt to add a side note explaining the old behaviour along
with a "don't use it".

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From robert.jarzmik at free.fr  Wed Nov 21 05:48:42 2012
From: robert.jarzmik at free.fr (Robert Jarzmik)
Date: Wed, 21 Nov 2012 11:48:42 +0100
Subject: [PATCH 2/2] bmp: specify we need to keep the data read from the
 file
In-Reply-To: <1353488867-24020-2-git-send-email-plagnioj@jcrosoft.com>
 (Jean-Christophe PLAGNIOL-VILLARD's message of "Wed, 21 Nov 2012
 10:07:47 +0100")
References: <87boesdjk4.fsf@free.fr>
 <1353488867-24020-1-git-send-email-plagnioj@jcrosoft.com>
 <1353488867-24020-2-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <87d2z75j05.fsf@free.fr>

Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com> writes:
... zip ...

Yeah, that's it, I don't have my corruptions anymore.

Tested-by: Robert Jarzmik <robert.jarzmik at free.fr>

-- 
Robert


From s.hauer at pengutronix.de  Wed Nov 21 05:55:23 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Wed, 21 Nov 2012 11:55:23 +0100
Subject: [PATCH 2/2] bmp: specify we need to keep the data read from the
 file
In-Reply-To: <87d2z75j05.fsf@free.fr>
References: <87boesdjk4.fsf@free.fr>
 <1353488867-24020-1-git-send-email-plagnioj@jcrosoft.com>
 <1353488867-24020-2-git-send-email-plagnioj@jcrosoft.com>
 <87d2z75j05.fsf@free.fr>
Message-ID: <20121121105523.GQ10369@pengutronix.de>

On Wed, Nov 21, 2012 at 11:48:42AM +0100, Robert Jarzmik wrote:
> Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com> writes:
> ... zip ...
> 
> Yeah, that's it, I don't have my corruptions anymore.
> 
> Tested-by: Robert Jarzmik <robert.jarzmik at free.fr>

Applied, thanks

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From richard.genoud at gmail.com  Wed Nov 21 08:52:18 2012
From: richard.genoud at gmail.com (Richard Genoud)
Date: Wed, 21 Nov 2012 14:52:18 +0100
Subject: USB host Unrecoverable Error on AT91SAM9x5-ek
Message-ID: <CACQ1gAiZgvEkppTdJheWxsDYGW8LpiAPe6eU-jO9x3i5x9Q+sQ@mail.gmail.com>

Hi,

I'm trying to use the usb host on an at91sam9x5-ek bord (g35 based)
and all I get is an error. :

# usb
USB: scanning bus for devices...
ERROR: OHCI Unrecoverable Error, controller usb-ohci disabled

     Couldn't reset port 1
Bus 001 Device 001: ID 0000:0000 OHCI Root Hub
2 USB Device(s) found
(tried with an usb key or a usb mouse)

I'm on the next branch commit 502779a91f6421de1b3538711a40cb6fcd4012ae

With DEBUG defined, I get :
# usb
USB: scanning bus for devices...
hc_reset
USB HC reset_hc usb-ohci: ctrl = 0x0 ;
OHCI controller usb-ohci state
control: 0x0000008f HCFS=operational IE PLE CBSR=3
cmdstatus: 0x00000000 SOC=0
intrstatus: 0x00000014 UE SF
intrenable: 0x00000053 RHSC UE WDH SO
ed_periodcurrent fc665320
unable to handle paging request at address 0xfc665320
pc : [<26f1d6c4>]    lr : [<26f1d6bc>]
sp : 26affd78  ip : 00000000  fp : 00000000
r10: 26f52356  r9 : 00000000  r8 : 26f52356
r7 : 26f52356  r6 : 26b0c0b8  r5 : 26f52356  r4 : fc665320
r3 : 00000000  r2 : f801c014  r1 : 0000000a  r0 : 0000001a
Flags: nZCv  IRQs off  FIQs off  Mode SVC_32
[<26f1d6c4>] (maybe_print_eds+0x28/0x5c) from [<26f1dde4>]
(ohci_dump.clone.16+0x178/0x25c)
[<26f1dde4>] (ohci_dump.clone.16+0x178/0x25c) from [<26f1dff8>]
(ohci_init+0x130/0x160)
[<26f1dff8>] (ohci_init+0x130/0x160) from [<26f1ad84>] (usb_rescan+0xc0/0x118)
[<26f1ad84>] (usb_rescan+0xc0/0x118) from [<26f28aac>] (do_usb+0x4c/0x64)
[<26f28aac>] (do_usb+0x4c/0x64) from [<26f056b4>] (execute_command+0x38/0x78)
[<26f056b4>] (execute_command+0x38/0x78) from [<26f01a5c>]
(run_list_real+0x8e4/0xa10)
[<26f01a5c>] (run_list_real+0x8e4/0xa10) from [<26f01ce8>]
(parse_stream_outer+0x160/0x288)
[<26f01ce8>] (parse_stream_outer+0x160/0x288) from [<26f020ac>]
(run_shell+0x44/0x84)
[<26f020ac>] (run_shell+0x44/0x84) from [<26f07260>] (start_barebox+0xac/0xdc)
[<26f07260>] (start_barebox+0xac/0xdc) from [<26f44014>]
(board_init_lowlevel_return+0xc/0x14)

[<26f43ad0>] (unwind_backtrace+0x0/0xb0) from [<26f2ae10>] (panic+0x28/0x48)
[<26f2ae10>] (panic+0x28/0x48) from [<26f43f38>] (do_exception+0x10/0x14)
[<26f43f38>] (do_exception+0x10/0x14) from [<26f43fc4>]
(do_data_abort+0x2c/0x38)
[<26f43fc4>] (do_data_abort+0x2c/0x38) from [<26f43ce8>] (data_abort+0x48/0x60)

=> If I comment the line "maybe_print_eds("ed_periodcurrent",
readl(&regs->ed_periodcurrent));" in drivers/usb/host/ohci-hcd.c
I get:
usb
USB: scanning bus for devices...
hc_reset
USB HC reset_hc usb-ohci: ctrl = 0x0 ;
OHCI controller usb-ohci state
control: 0x0000008f HCFS=operational IE PLE CBSR=3
cmdstatus: 0x00000000 SOC=0
intrstatus: 0x00000014 UE SF
intrenable: 0x00000053 RHSC UE WDH SO
drivers/usb/host/ohci-hcd.c: hcca branch int  1( 1): ed: c0000000; ed:
a22cbed9; ed: f587ccb0; ed: f4f98a01; ed: a49dee9e;
drivers/usb/host/ohci-hcd.c: hcca branch int  2( 2): ed: fc66532e; ed:
f09ae433; ed: e447ffc; ed: 654be7df; ed: cbedae0c;
drivers/usb/host/ohci-hcd.c: hcca branch int  3( 3): ed: fc1accdf; ed:
4316d7b9; ed: c4a2999a; ed: a5b87a57; ed: fc2aeffe;
drivers/usb/host/ohci-hcd.c: hcca branch int  4( 4): ed: a22cbed9; ed:
f587ccb0; ed: f4f98a01; ed: a49dee9e; ed: f2acc667;
drivers/usb/host/ohci-hcd.c: hcca branch int  5( 5): ed: f09ae433; ed:
e447ffc; ed: 654be7df; ed: cbedae0c; ed: e79be57a;
drivers/usb/host/ohci-hcd.c: hcca branch int  6( 6): ed: 4316d7b9; ed:
c4a2999a; ed: a5b87a57; ed: fc2aeffe; ed: ab73c4ea;
drivers/usb/host/ohci-hcd.c: hcca branch int  7( 7): ed: f587ccb0; ed:
f4f98a01; ed: a49dee9e; ed: f2acc667; ed: 49bcfe93;
drivers/usb/host/ohci-hcd.c: hcca branch int  8( 8): ed: e447ffc; ed:
654be7df; ed: cbedae0c; ed: e79be57a; ed: 79ff7a6d;
drivers/usb/host/ohci-hcd.c: hcca branch int  9( 9): ed: c4a2999a; ed:
a5b87a57; ed: fc2aeffe; ed: ab73c4ea; ed: ac2fee9a;
drivers/usb/host/ohci-hcd.c: hcca branch int 10( a): ed: f4f98a01; ed:
a49dee9e; ed: f2acc667; ed: 49bcfe93; ed: fc3d3c04;
drivers/usb/host/ohci-hcd.c: hcca branch int 11( b): ed: 654be7df; ed:
cbedae0c; ed: e79be57a; ed: 79ff7a6d; ed: 30fef681;
drivers/usb/host/ohci-hcd.c: hcca branch int 12( c): ed: a5b87a57; ed:
fc2aeffe; ed: ab73c4ea; ed: ac2fee9a; ed: 8ae337d9;
drivers/usb/host/ohci-hcd.c: hcca branch int 13( d): ed: a49dee9e; ed:
f2acc667; ed: 49bcfe93; ed: fc3d3c04; ed: 54dc01a2;
drivers/usb/host/ohci-hcd.c: hcca branch int 14( e): ed: cbedae0c; ed:
e79be57a; ed: 79ff7a6d; ed: 30fef681; ed: ec7f3dcd;
drivers/usb/host/ohci-hcd.c: hcca branch int 15( f): ed: fc2aeffe; ed:
ab73c4ea; ed: ac2fee9a; ed: 8ae337d9; ed: f6dda7ba;
drivers/usb/host/ohci-hcd.c: hcca branch int 16(10): ed: f2acc667; ed:
49bcfe93; ed: fc3d3c04; ed: 54dc01a2; ed: 3478aeb3;
drivers/usb/host/ohci-hcd.c: hcca branch int 17(11): ed: e79be57a; ed:
79ff7a6d; ed: 30fef681; ed: ec7f3dcd; ed: a31e44db;
drivers/usb/host/ohci-hcd.c: hcca branch int 18(12): ed: ab73c4ea; ed:
ac2fee9a; ed: 8ae337d9; ed: f6dda7ba; ed: 1d579bf2;
drivers/usb/host/ohci-hcd.c: hcca branch int 19(13): ed: 49bcfe93; ed:
fc3d3c04; ed: 54dc01a2; ed: 3478aeb3; ed: ecbaecbe;
drivers/usb/host/ohci-hcd.c: hcca branch int 20(14): ed: 79ff7a6d; ed:
30fef681; ed: ec7f3dcd; ed: a31e44db; ed:    2;
drivers/usb/host/ohci-hcd.c: hcca branch int 21(15): ed: ac2fee9a; ed:
8ae337d9; ed: f6dda7ba; ed: 1d579bf2; ed: d7bfa9cb;
drivers/usb/host/ohci-hcd.c: hcca branch int 22(16): ed: fc3d3c04; ed:
54dc01a2; ed: 3478aeb3; ed: ecbaecbe; ed: 97da4aad;
drivers/usb/host/ohci-hcd.c: hcca branch int 23(17): ed: 30fef681; ed:
ec7f3dcd; ed: a31e44db; ed:    2; ed: f9c2ce1f;
drivers/usb/host/ohci-hcd.c: hcca branch int 24(18): ed: 8ae337d9; ed:
f6dda7ba; ed: 1d579bf2; ed: d7bfa9cb; ed: 351dada6;
drivers/usb/host/ohci-hcd.c: hcca branch int 25(19): ed: 54dc01a2; ed:
3478aeb3; ed: ecbaecbe; ed: 97da4aad; ed: ca9fb47b;
drivers/usb/host/ohci-hcd.c: hcca branch int 26(1a): ed: ec7f3dcd; ed:
a31e44db; ed:    2; ed: f9c2ce1f; ed: cfca54cd;
drivers/usb/host/ohci-hcd.c: hcca branch int 27(1b): ed: f6dda7ba; ed:
1d579bf2; ed: d7bfa9cb; ed: 351dada6; ed: fd3b46fe;
drivers/usb/host/ohci-hcd.c: hcca branch int 28(1c): ed: 3478aeb3; ed:
ecbaecbe; ed: 97da4aad; ed: ca9fb47b; ed: 5702ef67;
drivers/usb/host/ohci-hcd.c: hcca branch int 29(1d): ed: a31e44db; ed:
   2; ed: f9c2ce1f; ed: cfca54cd; ed: 76d8fdfe;
drivers/usb/host/ohci-hcd.c: hcca branch int 30(1e): ed: 1d579bf2; ed:
d7bfa9cb; ed: 351dada6; ed: fd3b46fe; ed: 88ffff16;
drivers/usb/host/ohci-hcd.c: hcca branch int 31(1f): ed: ecbaecbe; ed:
97da4aad; ed: ca9fb47b; ed: 5702ef67; ed: 5cb8e55a;
hcca frame #0002
roothub.a: 02000003 POTPGT=2 NDP=3
roothub.b: 00000000 PPCM=0000 DR=0000
roothub.status: 00000000
roothub.portstatus [0] = 0x00000000
roothub.portstatus [1] = 0x00000000
roothub.portstatus [2] = 0x00000000
SUB URB:[   2] dev: 0,ep: 0-I,type:CTRL,len:0/64 stat:0x80000000
SUB(rh) URB:[   2] dev: 0,ep: 0-I,type:CTRL,len:0/64 stat:0x80000000
roothub.a: 02000003 POTPGT=2 NDP=3
roothub.b: 00000000 PPCM=0000 DR=0000
roothub.status: 00000000
roothub.portstatus [0] = 0x00000000
roothub.portstatus [1] = 0x00000000
roothub.portstatus [2] = 0x00000000
RET(rh) URB:[   2] dev: 0,ep: 0-I,type:CTRL,len:0/64 stat:0x0
SUB URB:[   2] dev: 0,ep: 0-O,type:CTRL,len:0/0 stat:0x80000000
SUB(rh) URB:[   2] dev: 0,ep: 0-O,type:CTRL,len:0/0 stat:0x80000000
roothub.a: 02000003 POTPGT=2 NDP=3
roothub.b: 00000000 PPCM=0000 DR=0000
roothub.status: 00000000
roothub.portstatus [0] = 0x00000000
roothub.portstatus [1] = 0x00000000
roothub.portstatus [2] = 0x00000000
RET(rh) URB:[   2] dev: 0,ep: 0-O,type:CTRL,len:0/0 stat:0x0
SUB URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/18 stat:0x80000000
SUB(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/18 stat:0x80000000
roothub.a: 02000003 POTPGT=2 NDP=3
roothub.b: 00000000 PPCM=0000 DR=0000
roothub.status: 00000000
roothub.portstatus [0] = 0x00000000
roothub.portstatus [1] = 0x00000000
roothub.portstatus [2] = 0x00000000
RET(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/18 stat:0x0
SUB URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/9 stat:0x80000000
SUB(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/9 stat:0x80000000
roothub.a: 02000003 POTPGT=2 NDP=3
roothub.b: 00000000 PPCM=0000 DR=0000
roothub.status: 00000000
roothub.portstatus [0] = 0x00000000
roothub.portstatus [1] = 0x00000000
roothub.portstatus [2] = 0x00000000
RET(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/9 stat:0x0
SUB URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/25 stat:0x80000000
SUB(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/25 stat:0x80000000
roothub.a: 02000003 POTPGT=2 NDP=3
roothub.b: 00000000 PPCM=0000 DR=0000
roothub.status: 00000000
roothub.portstatus [0] = 0x00000000
roothub.portstatus [1] = 0x00000000
roothub.portstatus [2] = 0x00000000
RET(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/25 stat:0x0
SUB URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x80000000
SUB(rh) URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x80000000
roothub.a: 02000003 POTPGT=2 NDP=3
roothub.b: 00000000 PPCM=0000 DR=0000
roothub.status: 00000000
roothub.portstatus [0] = 0x00000100 PPS
roothub.portstatus [1] = 0x00010301 CSC LSDA PPS CCS
roothub.portstatus [2] = 0x00000100 PPS
RET(rh) URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x0
SUB URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/255 stat:0x80000000
SUB(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/255 stat:0x80000000
roothub.a: 02000003 POTPGT=2 NDP=3
roothub.b: 00000000 PPCM=0000 DR=0000
roothub.status: 00000000
roothub.portstatus [0] = 0x00000100 PPS
roothub.portstatus [1] = 0x00010301 CSC LSDA PPS CCS
roothub.portstatus [2] = 0x00000100 PPS
RET(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/255 stat:0x0
SUB URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/255 stat:0x80000000
SUB(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/255 stat:0x80000000
roothub.a: 02000003 POTPGT=2 NDP=3
roothub.b: 00000000 PPCM=0000 DR=0000
roothub.status: 00000000
roothub.portstatus [0] = 0x00000100 PPS
roothub.portstatus [1] = 0x00010301 CSC LSDA PPS CCS
roothub.portstatus [2] = 0x00000100 PPS
RET(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/255 stat:0x0
SUB URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x80000000
SUB(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x80000000
roothub.a: 02000003 POTPGT=2 NDP=3
roothub.b: 00000000 PPCM=0000 DR=0000
roothub.status: 00000000
roothub.portstatus [0] = 0x00000100 PPS
roothub.portstatus [1] = 0x00010301 CSC LSDA PPS CCS
roothub.portstatus [2] = 0x00000100 PPS
RET(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x0
SUB URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/9 stat:0x80000000
SUB(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/9 stat:0x80000000
roothub.a: 02000003 POTPGT=2 NDP=3
roothub.b: 00000000 PPCM=0000 DR=0000
roothub.status: 00000000
roothub.portstatus [0] = 0x00000100 PPS
roothub.portstatus [1] = 0x00010301 CSC LSDA PPS CCS
roothub.portstatus [2] = 0x00000100 PPS
RET(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/9 stat:0x0
SUB URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x80000000
SUB(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x80000000
roothub.a: 02000003 POTPGT=2 NDP=3
roothub.b: 00000000 PPCM=0000 DR=0000
roothub.status: 00000000
roothub.portstatus [0] = 0x00000100 PPS
roothub.portstatus [1] = 0x00010301 CSC LSDA PPS CCS
roothub.portstatus [2] = 0x00000100 PPS
RET(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x0
SUB URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x80000000
SUB(rh) URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x80000000
roothub.a: 02000003 POTPGT=2 NDP=3
roothub.b: 00000000 PPCM=0000 DR=0000
roothub.status: 00000000
roothub.portstatus [0] = 0x00000100 PPS
roothub.portstatus [1] = 0x00010301 CSC LSDA PPS CCS
roothub.portstatus [2] = 0x00000100 PPS
RET(rh) URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x0
SUB URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x80000000
SUB(rh) URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x80000000
roothub.a: 02000003 POTPGT=2 NDP=3
roothub.b: 00000000 PPCM=0000 DR=0000
roothub.status: 00000000
roothub.portstatus [0] = 0x00000100 PPS
roothub.portstatus [1] = 0x00010301 CSC LSDA PPS CCS
roothub.portstatus [2] = 0x00000100 PPS
RET(rh) URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x0
SUB URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x80000000
SUB(rh) URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x80000000
roothub.a: 02000003 POTPGT=2 NDP=3
roothub.b: 00000000 PPCM=0000 DR=0000
roothub.status: 00000000
roothub.portstatus [0] = 0x00000100 PPS
roothub.portstatus [1] = 0x00010301 CSC LSDA PPS CCS
roothub.portstatus [2] = 0x00000100 PPS
RET(rh) URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x0
SUB URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x80000000
SUB(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x80000000
roothub.a: 02000003 POTPGT=2 NDP=3
roothub.b: 00000000 PPCM=0000 DR=0000
roothub.status: 00000000
roothub.portstatus [0] = 0x00000100 PPS
roothub.portstatus [1] = 0x00010301 CSC LSDA PPS CCS
roothub.portstatus [2] = 0x00000100 PPS
RET(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x0
SUB URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x80000000
SUB(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x80000000
roothub.a: 02000003 POTPGT=2 NDP=3
roothub.b: 00000000 PPCM=0000 DR=0000
roothub.status: 00000000
roothub.portstatus [0] = 0x00000100 PPS
roothub.portstatus [1] = 0x00010301 CSC LSDA PPS CCS
roothub.portstatus [2] = 0x00000100 PPS
RET(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x0
SUB URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x80000000
SUB(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x80000000
roothub.a: 02000003 POTPGT=2 NDP=3
roothub.b: 00000000 PPCM=0000 DR=0000
roothub.status: 00000000
roothub.portstatus [0] = 0x00000100 PPS
roothub.portstatus [1] = 0x00010301 CSC LSDA PPS CCS
roothub.portstatus [2] = 0x00000100 PPS
RET(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x0
SUB URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x80000000
SUB(rh) URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x80000000
roothub.a: 02000003 POTPGT=2 NDP=3
roothub.b: 00000000 PPCM=0000 DR=0000
roothub.status: 00000000
roothub.portstatus [0] = 0x00000100 PPS
roothub.portstatus [1] = 0x00000301 LSDA PPS CCS
roothub.portstatus [2] = 0x00000100 PPS
RET(rh) URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x0
SUB URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x80000000
SUB(rh) URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x80000000
roothub.a: 02000003 POTPGT=2 NDP=3
roothub.b: 00000000 PPCM=0000 DR=0000
roothub.status: 00000000
roothub.portstatus [0] = 0x00000100 PPS
roothub.portstatus [1] = 0x00100303 PRSC LSDA PPS PES CCS
roothub.portstatus [2] = 0x00000100 PPS
RET(rh) URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x0
SUB URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x80000000
SUB(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x80000000
roothub.a: 02000003 POTPGT=2 NDP=3
roothub.b: 00000000 PPCM=0000 DR=0000
roothub.status: 00000000
roothub.portstatus [0] = 0x00000100 PPS
roothub.portstatus [1] = 0x00100303 PRSC LSDA PPS PES CCS
roothub.portstatus [2] = 0x00000100 PPS
RET(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x0
SUB URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x80000000
SUB(rh) URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x80000000
roothub.a: 02000003 POTPGT=2 NDP=3
roothub.b: 00000000 PPCM=0000 DR=0000
roothub.status: 00000000
roothub.portstatus [0] = 0x00000100 PPS
roothub.portstatus [1] = 0x00000303 LSDA PPS PES CCS
roothub.portstatus [2] = 0x00000100 PPS
RET(rh) URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x0
SUB URB:[   2] dev: 0,ep: 0-I,type:CTRL,len:0/64 stat:0x80000000
SUB URB:[   2] dev: 0,ep: 0-I,type:CTRL,len:0/64 stat:0x80000000
Interrupt: 50 frame: 2
ERROR: OHCI Unrecoverable Error, controller usb-ohci disabled
OHCI controller usb-ohci state
control: 0x0000009f HCFS=operational CLE IE PLE CBSR=3
cmdstatus: 0x00000002 SOC=0 CLF
intrstatus: 0x00000054 RHSC UE SF
intrenable: 0x00000053 RHSC UE WDH SO
ed_controlhead 26b98000
00402000
26baa0c0
26baa000
00000000
drivers/usb/host/ohci-hcd.c: hcca branch int  1( 1): ed: c0000000; ed:
a22cbed9; ed: f587ccb0; ed: f4f98a01; ed: a49dee9e;
drivers/usb/host/ohci-hcd.c: hcca branch int  2( 2): ed: fc66532e; ed:
f09ae433; ed: e447ffc; ed: 654be7df; ed: cbedae0c;
drivers/usb/host/ohci-hcd.c: hcca branch int  3( 3): ed: fc1accdf; ed:
4316d7b9; ed: c4a2999a; ed: a5b87a57; ed: fc2aeffe;
drivers/usb/host/ohci-hcd.c: hcca branch int  4( 4): ed: a22cbed9; ed:
f587ccb0; ed: f4f98a01; ed: a49dee9e; ed: f2acc667;
drivers/usb/host/ohci-hcd.c: hcca branch int  5( 5): ed: f09ae433; ed:
e447ffc; ed: 654be7df; ed: cbedae0c; ed: e79be57a;
drivers/usb/host/ohci-hcd.c: hcca branch int  6( 6): ed: 4316d7b9; ed:
c4a2999a; ed: a5b87a57; ed: fc2aeffe; ed: ab73c4ea;
drivers/usb/host/ohci-hcd.c: hcca branch int  7( 7): ed: f587ccb0; ed:
f4f98a01; ed: a49dee9e; ed: f2acc667; ed: 49bcfe93;
drivers/usb/host/ohci-hcd.c: hcca branch int  8( 8): ed: e447ffc; ed:
654be7df; ed: cbedae0c; ed: e79be57a; ed: 79ff7a6d;
drivers/usb/host/ohci-hcd.c: hcca branch int  9( 9): ed: c4a2999a; ed:
a5b87a57; ed: fc2aeffe; ed: ab73c4ea; ed: ac2fee9a;
drivers/usb/host/ohci-hcd.c: hcca branch int 10( a): ed: f4f98a01; ed:
a49dee9e; ed: f2acc667; ed: 49bcfe93; ed: fc3d3c04;
drivers/usb/host/ohci-hcd.c: hcca branch int 11( b): ed: 654be7df; ed:
cbedae0c; ed: e79be57a; ed: 79ff7a6d; ed: 30fef681;
drivers/usb/host/ohci-hcd.c: hcca branch int 12( c): ed: a5b87a57; ed:
fc2aeffe; ed: ab73c4ea; ed: ac2fee9a; ed: 8ae337d9;
drivers/usb/host/ohci-hcd.c: hcca branch int 13( d): ed: a49dee9e; ed:
f2acc667; ed: 49bcfe93; ed: fc3d3c04; ed: 54dc01a2;
drivers/usb/host/ohci-hcd.c: hcca branch int 14( e): ed: cbedae0c; ed:
e79be57a; ed: 79ff7a6d; ed: 30fef681; ed: ec7f3dcd;
drivers/usb/host/ohci-hcd.c: hcca branch int 15( f): ed: fc2aeffe; ed:
ab73c4ea; ed: ac2fee9a; ed: 8ae337d9; ed: f6dda7ba;
drivers/usb/host/ohci-hcd.c: hcca branch int 16(10): ed: f2acc667; ed:
49bcfe93; ed: fc3d3c04; ed: 54dc01a2; ed: 3478aeb3;
drivers/usb/host/ohci-hcd.c: hcca branch int 17(11): ed: e79be57a; ed:
79ff7a6d; ed: 30fef681; ed: ec7f3dcd; ed: a31e44db;
drivers/usb/host/ohci-hcd.c: hcca branch int 18(12): ed: ab73c4ea; ed:
ac2fee9a; ed: 8ae337d9; ed: f6dda7ba; ed: 1d579bf2;
drivers/usb/host/ohci-hcd.c: hcca branch int 19(13): ed: 49bcfe93; ed:
fc3d3c04; ed: 54dc01a2; ed: 3478aeb3; ed: ecbaecbe;
drivers/usb/host/ohci-hcd.c: hcca branch int 20(14): ed: 79ff7a6d; ed:
30fef681; ed: ec7f3dcd; ed: a31e44db; ed:    2;
drivers/usb/host/ohci-hcd.c: hcca branch int 21(15): ed: ac2fee9a; ed:
8ae337d9; ed: f6dda7ba; ed: 1d579bf2; ed: d7bfa9cb;
drivers/usb/host/ohci-hcd.c: hcca branch int 22(16): ed: fc3d3c04; ed:
54dc01a2; ed: 3478aeb3; ed: ecbaecbe; ed: 97da4aad;
drivers/usb/host/ohci-hcd.c: hcca branch int 23(17): ed: 30fef681; ed:
ec7f3dcd; ed: a31e44db; ed:    2; ed: f9c2ce1f;
drivers/usb/host/ohci-hcd.c: hcca branch int 24(18): ed: 8ae337d9; ed:
f6dda7ba; ed: 1d579bf2; ed: d7bfa9cb; ed: 351dada6;
drivers/usb/host/ohci-hcd.c: hcca branch int 25(19): ed: 54dc01a2; ed:
3478aeb3; ed: ecbaecbe; ed: 97da4aad; ed: ca9fb47b;
drivers/usb/host/ohci-hcd.c: hcca branch int 26(1a): ed: ec7f3dcd; ed:
a31e44db; ed:    2; ed: f9c2ce1f; ed: cfca54cd;
drivers/usb/host/ohci-hcd.c: hcca branch int 27(1b): ed: f6dda7ba; ed:
1d579bf2; ed: d7bfa9cb; ed: 351dada6; ed: fd3b46fe;
drivers/usb/host/ohci-hcd.c: hcca branch int 28(1c): ed: 3478aeb3; ed:
ecbaecbe; ed: 97da4aad; ed: ca9fb47b; ed: 5702ef67;
drivers/usb/host/ohci-hcd.c: hcca branch int 29(1d): ed: a31e44db; ed:
   2; ed: f9c2ce1f; ed: cfca54cd; ed: 76d8fdfe;
drivers/usb/host/ohci-hcd.c: hcca branch int 30(1e): ed: 1d579bf2; ed:
d7bfa9cb; ed: 351dada6; ed: fd3b46fe; ed: 88ffff16;
drivers/usb/host/ohci-hcd.c: hcca branch int 31(1f): ed: ecbaecbe; ed:
97da4aad; ed: ca9fb47b; ed: 5702ef67; ed: 5cb8e55a;
hcca frame #0002
roothub.a: 02000003 POTPGT=2 NDP=3
roothub.b: 00000000 PPCM=0000 DR=0000
roothub.status: 00000000
roothub.portstatus [0] = 0x00000100 PPS
roothub.portstatus [1] = 0x00000303 LSDA PPS PES CCS
roothub.portstatus [2] = 0x00000100 PPS
hc_reset
USB HC reset_hc usb-ohci: ctrl = 0x9F ;
RET(ctlr) URB:[   2] dev: 0,ep: 0-I,type:CTRL,len:0/64 stat:0xfffffffb
SUB URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x80000000
SUB(rh) URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x80000000
roothub.a: 02000003 POTPGT=2 NDP=3
roothub.b: 00000000 PPCM=0000 DR=0000
roothub.status: 00000000
roothub.portstatus [0] = 0x00000000
roothub.portstatus [1] = 0x00000000
roothub.portstatus [2] = 0x00000000
RET(rh) URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x0
SUB URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x80000000
SUB(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x80000000
roothub.a: 02000003 POTPGT=2 NDP=3
roothub.b: 00000000 PPCM=0000 DR=0000
roothub.status: 00000000
roothub.portstatus [0] = 0x00000000
roothub.portstatus [1] = 0x00000000
roothub.portstatus [2] = 0x00000000
RET(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x0

     Couldn't reset port 1
SUB URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x80000000
SUB(rh) URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x80000000
roothub.a: 02000003 POTPGT=2 NDP=3
roothub.b: 00000000 PPCM=0000 DR=0000
roothub.status: 00000000
roothub.portstatus [0] = 0x00000000
roothub.portstatus [1] = 0x00000000
roothub.portstatus [2] = 0x00000000
RET(rh) URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x0
SUB URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x80000000
SUB(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x80000000
roothub.a: 02000003 POTPGT=2 NDP=3
roothub.b: 00000000 PPCM=0000 DR=0000
roothub.status: 00000000
roothub.portstatus [0] = 0x00000000
roothub.portstatus [1] = 0x00000000
roothub.portstatus [2] = 0x00000000
RET(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x0
Bus 001 Device 001: ID 0000:0000 OHCI Root Hub
2 USB Device(s) found


Does this ring a bell to someone ?

regards,

Richard


From plagnioj at jcrosoft.com  Wed Nov 21 09:58:29 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Wed, 21 Nov 2012 15:58:29 +0100
Subject: USB host Unrecoverable Error on AT91SAM9x5-ek
In-Reply-To: <CACQ1gAiZgvEkppTdJheWxsDYGW8LpiAPe6eU-jO9x3i5x9Q+sQ@mail.gmail.com>
References: <CACQ1gAiZgvEkppTdJheWxsDYGW8LpiAPe6eU-jO9x3i5x9Q+sQ@mail.gmail.com>
Message-ID: <20121121145829.GO8327@game.jcrosoft.org>

On 14:52 Wed 21 Nov     , Richard Genoud wrote:
> Hi,
> 
> I'm trying to use the usb host on an at91sam9x5-ek bord (g35 based)
> and all I get is an error. :


I known this issue thats why we do not have it yet the USB supprot on sam9x5
and other Atmel soc

This is a ohci core issue O do not yet get the time and the tools to debug it

Best Regards,
J.
> 
> # usb
> USB: scanning bus for devices...
> ERROR: OHCI Unrecoverable Error, controller usb-ohci disabled
> 
>      Couldn't reset port 1
> Bus 001 Device 001: ID 0000:0000 OHCI Root Hub
> 2 USB Device(s) found
> (tried with an usb key or a usb mouse)
> 
> I'm on the next branch commit 502779a91f6421de1b3538711a40cb6fcd4012ae
> 
> With DEBUG defined, I get :
> # usb
> USB: scanning bus for devices...
> hc_reset
> USB HC reset_hc usb-ohci: ctrl = 0x0 ;
> OHCI controller usb-ohci state
> control: 0x0000008f HCFS=operational IE PLE CBSR=3
> cmdstatus: 0x00000000 SOC=0
> intrstatus: 0x00000014 UE SF
> intrenable: 0x00000053 RHSC UE WDH SO
> ed_periodcurrent fc665320
> unable to handle paging request at address 0xfc665320
> pc : [<26f1d6c4>]    lr : [<26f1d6bc>]
> sp : 26affd78  ip : 00000000  fp : 00000000
> r10: 26f52356  r9 : 00000000  r8 : 26f52356
> r7 : 26f52356  r6 : 26b0c0b8  r5 : 26f52356  r4 : fc665320
> r3 : 00000000  r2 : f801c014  r1 : 0000000a  r0 : 0000001a
> Flags: nZCv  IRQs off  FIQs off  Mode SVC_32
> [<26f1d6c4>] (maybe_print_eds+0x28/0x5c) from [<26f1dde4>]
> (ohci_dump.clone.16+0x178/0x25c)
> [<26f1dde4>] (ohci_dump.clone.16+0x178/0x25c) from [<26f1dff8>]
> (ohci_init+0x130/0x160)
> [<26f1dff8>] (ohci_init+0x130/0x160) from [<26f1ad84>] (usb_rescan+0xc0/0x118)
> [<26f1ad84>] (usb_rescan+0xc0/0x118) from [<26f28aac>] (do_usb+0x4c/0x64)
> [<26f28aac>] (do_usb+0x4c/0x64) from [<26f056b4>] (execute_command+0x38/0x78)
> [<26f056b4>] (execute_command+0x38/0x78) from [<26f01a5c>]
> (run_list_real+0x8e4/0xa10)
> [<26f01a5c>] (run_list_real+0x8e4/0xa10) from [<26f01ce8>]
> (parse_stream_outer+0x160/0x288)
> [<26f01ce8>] (parse_stream_outer+0x160/0x288) from [<26f020ac>]
> (run_shell+0x44/0x84)
> [<26f020ac>] (run_shell+0x44/0x84) from [<26f07260>] (start_barebox+0xac/0xdc)
> [<26f07260>] (start_barebox+0xac/0xdc) from [<26f44014>]
> (board_init_lowlevel_return+0xc/0x14)
> 
> [<26f43ad0>] (unwind_backtrace+0x0/0xb0) from [<26f2ae10>] (panic+0x28/0x48)
> [<26f2ae10>] (panic+0x28/0x48) from [<26f43f38>] (do_exception+0x10/0x14)
> [<26f43f38>] (do_exception+0x10/0x14) from [<26f43fc4>]
> (do_data_abort+0x2c/0x38)
> [<26f43fc4>] (do_data_abort+0x2c/0x38) from [<26f43ce8>] (data_abort+0x48/0x60)
> 
> => If I comment the line "maybe_print_eds("ed_periodcurrent",
> readl(&regs->ed_periodcurrent));" in drivers/usb/host/ohci-hcd.c
> I get:
> usb
> USB: scanning bus for devices...
> hc_reset
> USB HC reset_hc usb-ohci: ctrl = 0x0 ;
> OHCI controller usb-ohci state
> control: 0x0000008f HCFS=operational IE PLE CBSR=3
> cmdstatus: 0x00000000 SOC=0
> intrstatus: 0x00000014 UE SF
> intrenable: 0x00000053 RHSC UE WDH SO
> drivers/usb/host/ohci-hcd.c: hcca branch int  1( 1): ed: c0000000; ed:
> a22cbed9; ed: f587ccb0; ed: f4f98a01; ed: a49dee9e;
> drivers/usb/host/ohci-hcd.c: hcca branch int  2( 2): ed: fc66532e; ed:
> f09ae433; ed: e447ffc; ed: 654be7df; ed: cbedae0c;
> drivers/usb/host/ohci-hcd.c: hcca branch int  3( 3): ed: fc1accdf; ed:
> 4316d7b9; ed: c4a2999a; ed: a5b87a57; ed: fc2aeffe;
> drivers/usb/host/ohci-hcd.c: hcca branch int  4( 4): ed: a22cbed9; ed:
> f587ccb0; ed: f4f98a01; ed: a49dee9e; ed: f2acc667;
> drivers/usb/host/ohci-hcd.c: hcca branch int  5( 5): ed: f09ae433; ed:
> e447ffc; ed: 654be7df; ed: cbedae0c; ed: e79be57a;
> drivers/usb/host/ohci-hcd.c: hcca branch int  6( 6): ed: 4316d7b9; ed:
> c4a2999a; ed: a5b87a57; ed: fc2aeffe; ed: ab73c4ea;
> drivers/usb/host/ohci-hcd.c: hcca branch int  7( 7): ed: f587ccb0; ed:
> f4f98a01; ed: a49dee9e; ed: f2acc667; ed: 49bcfe93;
> drivers/usb/host/ohci-hcd.c: hcca branch int  8( 8): ed: e447ffc; ed:
> 654be7df; ed: cbedae0c; ed: e79be57a; ed: 79ff7a6d;
> drivers/usb/host/ohci-hcd.c: hcca branch int  9( 9): ed: c4a2999a; ed:
> a5b87a57; ed: fc2aeffe; ed: ab73c4ea; ed: ac2fee9a;
> drivers/usb/host/ohci-hcd.c: hcca branch int 10( a): ed: f4f98a01; ed:
> a49dee9e; ed: f2acc667; ed: 49bcfe93; ed: fc3d3c04;
> drivers/usb/host/ohci-hcd.c: hcca branch int 11( b): ed: 654be7df; ed:
> cbedae0c; ed: e79be57a; ed: 79ff7a6d; ed: 30fef681;
> drivers/usb/host/ohci-hcd.c: hcca branch int 12( c): ed: a5b87a57; ed:
> fc2aeffe; ed: ab73c4ea; ed: ac2fee9a; ed: 8ae337d9;
> drivers/usb/host/ohci-hcd.c: hcca branch int 13( d): ed: a49dee9e; ed:
> f2acc667; ed: 49bcfe93; ed: fc3d3c04; ed: 54dc01a2;
> drivers/usb/host/ohci-hcd.c: hcca branch int 14( e): ed: cbedae0c; ed:
> e79be57a; ed: 79ff7a6d; ed: 30fef681; ed: ec7f3dcd;
> drivers/usb/host/ohci-hcd.c: hcca branch int 15( f): ed: fc2aeffe; ed:
> ab73c4ea; ed: ac2fee9a; ed: 8ae337d9; ed: f6dda7ba;
> drivers/usb/host/ohci-hcd.c: hcca branch int 16(10): ed: f2acc667; ed:
> 49bcfe93; ed: fc3d3c04; ed: 54dc01a2; ed: 3478aeb3;
> drivers/usb/host/ohci-hcd.c: hcca branch int 17(11): ed: e79be57a; ed:
> 79ff7a6d; ed: 30fef681; ed: ec7f3dcd; ed: a31e44db;
> drivers/usb/host/ohci-hcd.c: hcca branch int 18(12): ed: ab73c4ea; ed:
> ac2fee9a; ed: 8ae337d9; ed: f6dda7ba; ed: 1d579bf2;
> drivers/usb/host/ohci-hcd.c: hcca branch int 19(13): ed: 49bcfe93; ed:
> fc3d3c04; ed: 54dc01a2; ed: 3478aeb3; ed: ecbaecbe;
> drivers/usb/host/ohci-hcd.c: hcca branch int 20(14): ed: 79ff7a6d; ed:
> 30fef681; ed: ec7f3dcd; ed: a31e44db; ed:    2;
> drivers/usb/host/ohci-hcd.c: hcca branch int 21(15): ed: ac2fee9a; ed:
> 8ae337d9; ed: f6dda7ba; ed: 1d579bf2; ed: d7bfa9cb;
> drivers/usb/host/ohci-hcd.c: hcca branch int 22(16): ed: fc3d3c04; ed:
> 54dc01a2; ed: 3478aeb3; ed: ecbaecbe; ed: 97da4aad;
> drivers/usb/host/ohci-hcd.c: hcca branch int 23(17): ed: 30fef681; ed:
> ec7f3dcd; ed: a31e44db; ed:    2; ed: f9c2ce1f;
> drivers/usb/host/ohci-hcd.c: hcca branch int 24(18): ed: 8ae337d9; ed:
> f6dda7ba; ed: 1d579bf2; ed: d7bfa9cb; ed: 351dada6;
> drivers/usb/host/ohci-hcd.c: hcca branch int 25(19): ed: 54dc01a2; ed:
> 3478aeb3; ed: ecbaecbe; ed: 97da4aad; ed: ca9fb47b;
> drivers/usb/host/ohci-hcd.c: hcca branch int 26(1a): ed: ec7f3dcd; ed:
> a31e44db; ed:    2; ed: f9c2ce1f; ed: cfca54cd;
> drivers/usb/host/ohci-hcd.c: hcca branch int 27(1b): ed: f6dda7ba; ed:
> 1d579bf2; ed: d7bfa9cb; ed: 351dada6; ed: fd3b46fe;
> drivers/usb/host/ohci-hcd.c: hcca branch int 28(1c): ed: 3478aeb3; ed:
> ecbaecbe; ed: 97da4aad; ed: ca9fb47b; ed: 5702ef67;
> drivers/usb/host/ohci-hcd.c: hcca branch int 29(1d): ed: a31e44db; ed:
>    2; ed: f9c2ce1f; ed: cfca54cd; ed: 76d8fdfe;
> drivers/usb/host/ohci-hcd.c: hcca branch int 30(1e): ed: 1d579bf2; ed:
> d7bfa9cb; ed: 351dada6; ed: fd3b46fe; ed: 88ffff16;
> drivers/usb/host/ohci-hcd.c: hcca branch int 31(1f): ed: ecbaecbe; ed:
> 97da4aad; ed: ca9fb47b; ed: 5702ef67; ed: 5cb8e55a;
> hcca frame #0002
> roothub.a: 02000003 POTPGT=2 NDP=3
> roothub.b: 00000000 PPCM=0000 DR=0000
> roothub.status: 00000000
> roothub.portstatus [0] = 0x00000000
> roothub.portstatus [1] = 0x00000000
> roothub.portstatus [2] = 0x00000000
> SUB URB:[   2] dev: 0,ep: 0-I,type:CTRL,len:0/64 stat:0x80000000
> SUB(rh) URB:[   2] dev: 0,ep: 0-I,type:CTRL,len:0/64 stat:0x80000000
> roothub.a: 02000003 POTPGT=2 NDP=3
> roothub.b: 00000000 PPCM=0000 DR=0000
> roothub.status: 00000000
> roothub.portstatus [0] = 0x00000000
> roothub.portstatus [1] = 0x00000000
> roothub.portstatus [2] = 0x00000000
> RET(rh) URB:[   2] dev: 0,ep: 0-I,type:CTRL,len:0/64 stat:0x0
> SUB URB:[   2] dev: 0,ep: 0-O,type:CTRL,len:0/0 stat:0x80000000
> SUB(rh) URB:[   2] dev: 0,ep: 0-O,type:CTRL,len:0/0 stat:0x80000000
> roothub.a: 02000003 POTPGT=2 NDP=3
> roothub.b: 00000000 PPCM=0000 DR=0000
> roothub.status: 00000000
> roothub.portstatus [0] = 0x00000000
> roothub.portstatus [1] = 0x00000000
> roothub.portstatus [2] = 0x00000000
> RET(rh) URB:[   2] dev: 0,ep: 0-O,type:CTRL,len:0/0 stat:0x0
> SUB URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/18 stat:0x80000000
> SUB(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/18 stat:0x80000000
> roothub.a: 02000003 POTPGT=2 NDP=3
> roothub.b: 00000000 PPCM=0000 DR=0000
> roothub.status: 00000000
> roothub.portstatus [0] = 0x00000000
> roothub.portstatus [1] = 0x00000000
> roothub.portstatus [2] = 0x00000000
> RET(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/18 stat:0x0
> SUB URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/9 stat:0x80000000
> SUB(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/9 stat:0x80000000
> roothub.a: 02000003 POTPGT=2 NDP=3
> roothub.b: 00000000 PPCM=0000 DR=0000
> roothub.status: 00000000
> roothub.portstatus [0] = 0x00000000
> roothub.portstatus [1] = 0x00000000
> roothub.portstatus [2] = 0x00000000
> RET(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/9 stat:0x0
> SUB URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/25 stat:0x80000000
> SUB(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/25 stat:0x80000000
> roothub.a: 02000003 POTPGT=2 NDP=3
> roothub.b: 00000000 PPCM=0000 DR=0000
> roothub.status: 00000000
> roothub.portstatus [0] = 0x00000000
> roothub.portstatus [1] = 0x00000000
> roothub.portstatus [2] = 0x00000000
> RET(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/25 stat:0x0
> SUB URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x80000000
> SUB(rh) URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x80000000
> roothub.a: 02000003 POTPGT=2 NDP=3
> roothub.b: 00000000 PPCM=0000 DR=0000
> roothub.status: 00000000
> roothub.portstatus [0] = 0x00000100 PPS
> roothub.portstatus [1] = 0x00010301 CSC LSDA PPS CCS
> roothub.portstatus [2] = 0x00000100 PPS
> RET(rh) URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x0
> SUB URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/255 stat:0x80000000
> SUB(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/255 stat:0x80000000
> roothub.a: 02000003 POTPGT=2 NDP=3
> roothub.b: 00000000 PPCM=0000 DR=0000
> roothub.status: 00000000
> roothub.portstatus [0] = 0x00000100 PPS
> roothub.portstatus [1] = 0x00010301 CSC LSDA PPS CCS
> roothub.portstatus [2] = 0x00000100 PPS
> RET(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/255 stat:0x0
> SUB URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/255 stat:0x80000000
> SUB(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/255 stat:0x80000000
> roothub.a: 02000003 POTPGT=2 NDP=3
> roothub.b: 00000000 PPCM=0000 DR=0000
> roothub.status: 00000000
> roothub.portstatus [0] = 0x00000100 PPS
> roothub.portstatus [1] = 0x00010301 CSC LSDA PPS CCS
> roothub.portstatus [2] = 0x00000100 PPS
> RET(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/255 stat:0x0
> SUB URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x80000000
> SUB(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x80000000
> roothub.a: 02000003 POTPGT=2 NDP=3
> roothub.b: 00000000 PPCM=0000 DR=0000
> roothub.status: 00000000
> roothub.portstatus [0] = 0x00000100 PPS
> roothub.portstatus [1] = 0x00010301 CSC LSDA PPS CCS
> roothub.portstatus [2] = 0x00000100 PPS
> RET(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x0
> SUB URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/9 stat:0x80000000
> SUB(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/9 stat:0x80000000
> roothub.a: 02000003 POTPGT=2 NDP=3
> roothub.b: 00000000 PPCM=0000 DR=0000
> roothub.status: 00000000
> roothub.portstatus [0] = 0x00000100 PPS
> roothub.portstatus [1] = 0x00010301 CSC LSDA PPS CCS
> roothub.portstatus [2] = 0x00000100 PPS
> RET(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/9 stat:0x0
> SUB URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x80000000
> SUB(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x80000000
> roothub.a: 02000003 POTPGT=2 NDP=3
> roothub.b: 00000000 PPCM=0000 DR=0000
> roothub.status: 00000000
> roothub.portstatus [0] = 0x00000100 PPS
> roothub.portstatus [1] = 0x00010301 CSC LSDA PPS CCS
> roothub.portstatus [2] = 0x00000100 PPS
> RET(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x0
> SUB URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x80000000
> SUB(rh) URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x80000000
> roothub.a: 02000003 POTPGT=2 NDP=3
> roothub.b: 00000000 PPCM=0000 DR=0000
> roothub.status: 00000000
> roothub.portstatus [0] = 0x00000100 PPS
> roothub.portstatus [1] = 0x00010301 CSC LSDA PPS CCS
> roothub.portstatus [2] = 0x00000100 PPS
> RET(rh) URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x0
> SUB URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x80000000
> SUB(rh) URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x80000000
> roothub.a: 02000003 POTPGT=2 NDP=3
> roothub.b: 00000000 PPCM=0000 DR=0000
> roothub.status: 00000000
> roothub.portstatus [0] = 0x00000100 PPS
> roothub.portstatus [1] = 0x00010301 CSC LSDA PPS CCS
> roothub.portstatus [2] = 0x00000100 PPS
> RET(rh) URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x0
> SUB URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x80000000
> SUB(rh) URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x80000000
> roothub.a: 02000003 POTPGT=2 NDP=3
> roothub.b: 00000000 PPCM=0000 DR=0000
> roothub.status: 00000000
> roothub.portstatus [0] = 0x00000100 PPS
> roothub.portstatus [1] = 0x00010301 CSC LSDA PPS CCS
> roothub.portstatus [2] = 0x00000100 PPS
> RET(rh) URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x0
> SUB URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x80000000
> SUB(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x80000000
> roothub.a: 02000003 POTPGT=2 NDP=3
> roothub.b: 00000000 PPCM=0000 DR=0000
> roothub.status: 00000000
> roothub.portstatus [0] = 0x00000100 PPS
> roothub.portstatus [1] = 0x00010301 CSC LSDA PPS CCS
> roothub.portstatus [2] = 0x00000100 PPS
> RET(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x0
> SUB URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x80000000
> SUB(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x80000000
> roothub.a: 02000003 POTPGT=2 NDP=3
> roothub.b: 00000000 PPCM=0000 DR=0000
> roothub.status: 00000000
> roothub.portstatus [0] = 0x00000100 PPS
> roothub.portstatus [1] = 0x00010301 CSC LSDA PPS CCS
> roothub.portstatus [2] = 0x00000100 PPS
> RET(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x0
> SUB URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x80000000
> SUB(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x80000000
> roothub.a: 02000003 POTPGT=2 NDP=3
> roothub.b: 00000000 PPCM=0000 DR=0000
> roothub.status: 00000000
> roothub.portstatus [0] = 0x00000100 PPS
> roothub.portstatus [1] = 0x00010301 CSC LSDA PPS CCS
> roothub.portstatus [2] = 0x00000100 PPS
> RET(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x0
> SUB URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x80000000
> SUB(rh) URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x80000000
> roothub.a: 02000003 POTPGT=2 NDP=3
> roothub.b: 00000000 PPCM=0000 DR=0000
> roothub.status: 00000000
> roothub.portstatus [0] = 0x00000100 PPS
> roothub.portstatus [1] = 0x00000301 LSDA PPS CCS
> roothub.portstatus [2] = 0x00000100 PPS
> RET(rh) URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x0
> SUB URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x80000000
> SUB(rh) URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x80000000
> roothub.a: 02000003 POTPGT=2 NDP=3
> roothub.b: 00000000 PPCM=0000 DR=0000
> roothub.status: 00000000
> roothub.portstatus [0] = 0x00000100 PPS
> roothub.portstatus [1] = 0x00100303 PRSC LSDA PPS PES CCS
> roothub.portstatus [2] = 0x00000100 PPS
> RET(rh) URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x0
> SUB URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x80000000
> SUB(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x80000000
> roothub.a: 02000003 POTPGT=2 NDP=3
> roothub.b: 00000000 PPCM=0000 DR=0000
> roothub.status: 00000000
> roothub.portstatus [0] = 0x00000100 PPS
> roothub.portstatus [1] = 0x00100303 PRSC LSDA PPS PES CCS
> roothub.portstatus [2] = 0x00000100 PPS
> RET(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x0
> SUB URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x80000000
> SUB(rh) URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x80000000
> roothub.a: 02000003 POTPGT=2 NDP=3
> roothub.b: 00000000 PPCM=0000 DR=0000
> roothub.status: 00000000
> roothub.portstatus [0] = 0x00000100 PPS
> roothub.portstatus [1] = 0x00000303 LSDA PPS PES CCS
> roothub.portstatus [2] = 0x00000100 PPS
> RET(rh) URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x0
> SUB URB:[   2] dev: 0,ep: 0-I,type:CTRL,len:0/64 stat:0x80000000
> SUB URB:[   2] dev: 0,ep: 0-I,type:CTRL,len:0/64 stat:0x80000000
> Interrupt: 50 frame: 2
> ERROR: OHCI Unrecoverable Error, controller usb-ohci disabled
> OHCI controller usb-ohci state
> control: 0x0000009f HCFS=operational CLE IE PLE CBSR=3
> cmdstatus: 0x00000002 SOC=0 CLF
> intrstatus: 0x00000054 RHSC UE SF
> intrenable: 0x00000053 RHSC UE WDH SO
> ed_controlhead 26b98000
> 00402000
> 26baa0c0
> 26baa000
> 00000000
> drivers/usb/host/ohci-hcd.c: hcca branch int  1( 1): ed: c0000000; ed:
> a22cbed9; ed: f587ccb0; ed: f4f98a01; ed: a49dee9e;
> drivers/usb/host/ohci-hcd.c: hcca branch int  2( 2): ed: fc66532e; ed:
> f09ae433; ed: e447ffc; ed: 654be7df; ed: cbedae0c;
> drivers/usb/host/ohci-hcd.c: hcca branch int  3( 3): ed: fc1accdf; ed:
> 4316d7b9; ed: c4a2999a; ed: a5b87a57; ed: fc2aeffe;
> drivers/usb/host/ohci-hcd.c: hcca branch int  4( 4): ed: a22cbed9; ed:
> f587ccb0; ed: f4f98a01; ed: a49dee9e; ed: f2acc667;
> drivers/usb/host/ohci-hcd.c: hcca branch int  5( 5): ed: f09ae433; ed:
> e447ffc; ed: 654be7df; ed: cbedae0c; ed: e79be57a;
> drivers/usb/host/ohci-hcd.c: hcca branch int  6( 6): ed: 4316d7b9; ed:
> c4a2999a; ed: a5b87a57; ed: fc2aeffe; ed: ab73c4ea;
> drivers/usb/host/ohci-hcd.c: hcca branch int  7( 7): ed: f587ccb0; ed:
> f4f98a01; ed: a49dee9e; ed: f2acc667; ed: 49bcfe93;
> drivers/usb/host/ohci-hcd.c: hcca branch int  8( 8): ed: e447ffc; ed:
> 654be7df; ed: cbedae0c; ed: e79be57a; ed: 79ff7a6d;
> drivers/usb/host/ohci-hcd.c: hcca branch int  9( 9): ed: c4a2999a; ed:
> a5b87a57; ed: fc2aeffe; ed: ab73c4ea; ed: ac2fee9a;
> drivers/usb/host/ohci-hcd.c: hcca branch int 10( a): ed: f4f98a01; ed:
> a49dee9e; ed: f2acc667; ed: 49bcfe93; ed: fc3d3c04;
> drivers/usb/host/ohci-hcd.c: hcca branch int 11( b): ed: 654be7df; ed:
> cbedae0c; ed: e79be57a; ed: 79ff7a6d; ed: 30fef681;
> drivers/usb/host/ohci-hcd.c: hcca branch int 12( c): ed: a5b87a57; ed:
> fc2aeffe; ed: ab73c4ea; ed: ac2fee9a; ed: 8ae337d9;
> drivers/usb/host/ohci-hcd.c: hcca branch int 13( d): ed: a49dee9e; ed:
> f2acc667; ed: 49bcfe93; ed: fc3d3c04; ed: 54dc01a2;
> drivers/usb/host/ohci-hcd.c: hcca branch int 14( e): ed: cbedae0c; ed:
> e79be57a; ed: 79ff7a6d; ed: 30fef681; ed: ec7f3dcd;
> drivers/usb/host/ohci-hcd.c: hcca branch int 15( f): ed: fc2aeffe; ed:
> ab73c4ea; ed: ac2fee9a; ed: 8ae337d9; ed: f6dda7ba;
> drivers/usb/host/ohci-hcd.c: hcca branch int 16(10): ed: f2acc667; ed:
> 49bcfe93; ed: fc3d3c04; ed: 54dc01a2; ed: 3478aeb3;
> drivers/usb/host/ohci-hcd.c: hcca branch int 17(11): ed: e79be57a; ed:
> 79ff7a6d; ed: 30fef681; ed: ec7f3dcd; ed: a31e44db;
> drivers/usb/host/ohci-hcd.c: hcca branch int 18(12): ed: ab73c4ea; ed:
> ac2fee9a; ed: 8ae337d9; ed: f6dda7ba; ed: 1d579bf2;
> drivers/usb/host/ohci-hcd.c: hcca branch int 19(13): ed: 49bcfe93; ed:
> fc3d3c04; ed: 54dc01a2; ed: 3478aeb3; ed: ecbaecbe;
> drivers/usb/host/ohci-hcd.c: hcca branch int 20(14): ed: 79ff7a6d; ed:
> 30fef681; ed: ec7f3dcd; ed: a31e44db; ed:    2;
> drivers/usb/host/ohci-hcd.c: hcca branch int 21(15): ed: ac2fee9a; ed:
> 8ae337d9; ed: f6dda7ba; ed: 1d579bf2; ed: d7bfa9cb;
> drivers/usb/host/ohci-hcd.c: hcca branch int 22(16): ed: fc3d3c04; ed:
> 54dc01a2; ed: 3478aeb3; ed: ecbaecbe; ed: 97da4aad;
> drivers/usb/host/ohci-hcd.c: hcca branch int 23(17): ed: 30fef681; ed:
> ec7f3dcd; ed: a31e44db; ed:    2; ed: f9c2ce1f;
> drivers/usb/host/ohci-hcd.c: hcca branch int 24(18): ed: 8ae337d9; ed:
> f6dda7ba; ed: 1d579bf2; ed: d7bfa9cb; ed: 351dada6;
> drivers/usb/host/ohci-hcd.c: hcca branch int 25(19): ed: 54dc01a2; ed:
> 3478aeb3; ed: ecbaecbe; ed: 97da4aad; ed: ca9fb47b;
> drivers/usb/host/ohci-hcd.c: hcca branch int 26(1a): ed: ec7f3dcd; ed:
> a31e44db; ed:    2; ed: f9c2ce1f; ed: cfca54cd;
> drivers/usb/host/ohci-hcd.c: hcca branch int 27(1b): ed: f6dda7ba; ed:
> 1d579bf2; ed: d7bfa9cb; ed: 351dada6; ed: fd3b46fe;
> drivers/usb/host/ohci-hcd.c: hcca branch int 28(1c): ed: 3478aeb3; ed:
> ecbaecbe; ed: 97da4aad; ed: ca9fb47b; ed: 5702ef67;
> drivers/usb/host/ohci-hcd.c: hcca branch int 29(1d): ed: a31e44db; ed:
>    2; ed: f9c2ce1f; ed: cfca54cd; ed: 76d8fdfe;
> drivers/usb/host/ohci-hcd.c: hcca branch int 30(1e): ed: 1d579bf2; ed:
> d7bfa9cb; ed: 351dada6; ed: fd3b46fe; ed: 88ffff16;
> drivers/usb/host/ohci-hcd.c: hcca branch int 31(1f): ed: ecbaecbe; ed:
> 97da4aad; ed: ca9fb47b; ed: 5702ef67; ed: 5cb8e55a;
> hcca frame #0002
> roothub.a: 02000003 POTPGT=2 NDP=3
> roothub.b: 00000000 PPCM=0000 DR=0000
> roothub.status: 00000000
> roothub.portstatus [0] = 0x00000100 PPS
> roothub.portstatus [1] = 0x00000303 LSDA PPS PES CCS
> roothub.portstatus [2] = 0x00000100 PPS
> hc_reset
> USB HC reset_hc usb-ohci: ctrl = 0x9F ;
> RET(ctlr) URB:[   2] dev: 0,ep: 0-I,type:CTRL,len:0/64 stat:0xfffffffb
> SUB URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x80000000
> SUB(rh) URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x80000000
> roothub.a: 02000003 POTPGT=2 NDP=3
> roothub.b: 00000000 PPCM=0000 DR=0000
> roothub.status: 00000000
> roothub.portstatus [0] = 0x00000000
> roothub.portstatus [1] = 0x00000000
> roothub.portstatus [2] = 0x00000000
> RET(rh) URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x0
> SUB URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x80000000
> SUB(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x80000000
> roothub.a: 02000003 POTPGT=2 NDP=3
> roothub.b: 00000000 PPCM=0000 DR=0000
> roothub.status: 00000000
> roothub.portstatus [0] = 0x00000000
> roothub.portstatus [1] = 0x00000000
> roothub.portstatus [2] = 0x00000000
> RET(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x0
> 
>      Couldn't reset port 1
> SUB URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x80000000
> SUB(rh) URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x80000000
> roothub.a: 02000003 POTPGT=2 NDP=3
> roothub.b: 00000000 PPCM=0000 DR=0000
> roothub.status: 00000000
> roothub.portstatus [0] = 0x00000000
> roothub.portstatus [1] = 0x00000000
> roothub.portstatus [2] = 0x00000000
> RET(rh) URB:[   2] dev: 1,ep: 0-O,type:CTRL,len:0/0 stat:0x0
> SUB URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x80000000
> SUB(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x80000000
> roothub.a: 02000003 POTPGT=2 NDP=3
> roothub.b: 00000000 PPCM=0000 DR=0000
> roothub.status: 00000000
> roothub.portstatus [0] = 0x00000000
> roothub.portstatus [1] = 0x00000000
> roothub.portstatus [2] = 0x00000000
> RET(rh) URB:[   2] dev: 1,ep: 0-I,type:CTRL,len:0/4 stat:0x0
> Bus 001 Device 001: ID 0000:0000 OHCI Root Hub
> 2 USB Device(s) found
> 
> 
> Does this ring a bell to someone ?
> 
> regards,
> 
> Richard
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox


From richard.genoud at gmail.com  Wed Nov 21 10:15:57 2012
From: richard.genoud at gmail.com (Richard Genoud)
Date: Wed, 21 Nov 2012 16:15:57 +0100
Subject: USB host Unrecoverable Error on AT91SAM9x5-ek
In-Reply-To: <20121121145829.GO8327@game.jcrosoft.org>
References: <CACQ1gAiZgvEkppTdJheWxsDYGW8LpiAPe6eU-jO9x3i5x9Q+sQ@mail.gmail.com>
 <20121121145829.GO8327@game.jcrosoft.org>
Message-ID: <CACQ1gAiOu8LRcyeACSwFiiPUYw=AfLZzys2f7MD0-rq55mHsBw@mail.gmail.com>

2012/11/21 Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>:
>
> I known this issue thats why we do not have it yet the USB supprot on sam9x5
> and other Atmel soc
>
> This is a ohci core issue O do not yet get the time and the tools to debug it
>
> Best Regards,
> J.

ok. I'll try to have a look, but I'm not familiar with usb...
Thanks !

Richard


From zzs213 at 126.com  Wed Nov 21 20:22:19 2012
From: zzs213 at 126.com (=?utf-8?B?5byg5b+g5bGx?=)
Date: Thu, 22 Nov 2012 09:22:19 +0800
Subject: test
Message-ID: <20121122012219.GA3022@greatfirst.com>

test

-- 
Best Regards,
zzs




From zzs213 at 126.com  Wed Nov 21 20:48:16 2012
From: zzs213 at 126.com (=?UTF-8?q?=E5=BC=A0=E5=BF=A0=E5=B1=B1?=)
Date: Thu, 22 Nov 2012 09:48:16 +0800
Subject: [PATCH] read cfi device id according the bus width
Message-ID: <1353548896-5506-1-git-send-email-zzs213@126.com>

Signed-off-by: ??? <zzs213 at 126.com>
---
 drivers/nor/cfi_flash_amd.c |   22 +++++++++++++---------
 1 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/drivers/nor/cfi_flash_amd.c b/drivers/nor/cfi_flash_amd.c
index 45c59b9..8384f46 100644
--- a/drivers/nor/cfi_flash_amd.c
+++ b/drivers/nor/cfi_flash_amd.c
@@ -62,15 +62,19 @@ static void amd_read_jedec_ids (struct flash_info *info)
 	udelay(1000); /* some flash are slow to respond */
 
 	info->manufacturer_id = jedec_read_mfr(info);
-	info->device_id = flash_read_uchar (info,
-					FLASH_OFFSET_DEVICE_ID);
-	if (info->device_id == 0x7E) {
-		/* AMD 3-byte (expanded) device ids */
-		info->device_id2 = flash_read_uchar (info,
-					FLASH_OFFSET_DEVICE_ID2);
-		info->device_id2 <<= 8;
-		info->device_id2 |= flash_read_uchar (info,
-					FLASH_OFFSET_DEVICE_ID3);
+	if(info->chipwidth == FLASH_CFI_BY16) {
+		info->device_id = flash_read16(flash_make_addr(info, 0, FLASH_OFFSET_DEVICE_ID));
+	} else {
+		info->device_id = flash_read_uchar (info,
+						FLASH_OFFSET_DEVICE_ID);
+		if (info->device_id == 0x7E) {
+			/* AMD 3-byte (expanded) device ids */
+			info->device_id2 = flash_read_uchar (info,
+						FLASH_OFFSET_DEVICE_ID2);
+			info->device_id2 <<= 8;
+			info->device_id2 |= flash_read_uchar (info,
+						FLASH_OFFSET_DEVICE_ID3);
+		}
 	}
 	flash_write_cmd(info, 0, 0, info->cmd_reset);
 }
-- 
1.7.4.4




From zzs213 at 126.com  Wed Nov 21 22:59:41 2012
From: zzs213 at 126.com (=?utf-8?B?5byg5b+g5bGx?=)
Date: Thu, 22 Nov 2012 11:59:41 +0800
Subject: Can I use NAND_ATMEL on at91rm9200 board
Message-ID: <20121122035941.GC3022@greatfirst.com>

config menu says that NAND_ATMEL is for AT91SAM9xxx
Can I use it on at91rm9200 boards?

-- 
Best Regards,
zzs




From plagnioj at jcrosoft.com  Thu Nov 22 00:45:32 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu, 22 Nov 2012 06:45:32 +0100
Subject: Can I use NAND_ATMEL on at91rm9200 board
In-Reply-To: <20121122035941.GC3022@greatfirst.com>
References: <20121122035941.GC3022@greatfirst.com>
Message-ID: <20121122054532.GP8327@game.jcrosoft.org>

On 11:59 Thu 22 Nov     , ??? wrote:
> config menu says that NAND_ATMEL is for AT91SAM9xxx
> Can I use it on at91rm9200 boards?

the rm9200 use the same IP as all the at91

Best Regards,
J.


From plagnioj at jcrosoft.com  Thu Nov 22 00:46:38 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu, 22 Nov 2012 06:46:38 +0100
Subject: [PATCH] read cfi device id according the bus width
In-Reply-To: <1353548896-5506-1-git-send-email-zzs213@126.com>
References: <1353548896-5506-1-git-send-email-zzs213@126.com>
Message-ID: <20121122054638.GQ8327@game.jcrosoft.org>

On 09:48 Thu 22 Nov     , ??? wrote:
> Signed-off-by: ??? <zzs213 at 126.com>
> ---
>  drivers/nor/cfi_flash_amd.c |   22 +++++++++++++---------
>  1 files changed, 13 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/nor/cfi_flash_amd.c b/drivers/nor/cfi_flash_amd.c
> index 45c59b9..8384f46 100644
> --- a/drivers/nor/cfi_flash_amd.c
> +++ b/drivers/nor/cfi_flash_amd.c
> @@ -62,15 +62,19 @@ static void amd_read_jedec_ids (struct flash_info *info)
>  	udelay(1000); /* some flash are slow to respond */
>  
>  	info->manufacturer_id = jedec_read_mfr(info);
> -	info->device_id = flash_read_uchar (info,
> -					FLASH_OFFSET_DEVICE_ID);
> -	if (info->device_id == 0x7E) {
> -		/* AMD 3-byte (expanded) device ids */
> -		info->device_id2 = flash_read_uchar (info,
> -					FLASH_OFFSET_DEVICE_ID2);
> -		info->device_id2 <<= 8;
> -		info->device_id2 |= flash_read_uchar (info,
> -					FLASH_OFFSET_DEVICE_ID3);
> +	if(info->chipwidth == FLASH_CFI_BY16) {
> +		info->device_id = flash_read16(flash_make_addr(info, 0, FLASH_OFFSET_DEVICE_ID));
> +	} else {
> +		info->device_id = flash_read_uchar (info,
> +						FLASH_OFFSET_DEVICE_ID);
> +		if (info->device_id == 0x7E) {
> +			/* AMD 3-byte (expanded) device ids */
> +			info->device_id2 = flash_read_uchar (info,
> +						FLASH_OFFSET_DEVICE_ID2);
> +			info->device_id2 <<= 8;
> +			info->device_id2 |= flash_read_uchar (info,
> +						FLASH_OFFSET_DEVICE_ID3);
> +		}
id2 is present nom matter the bus width

Best Regards,
J.
>  	}
>  	flash_write_cmd(info, 0, 0, info->cmd_reset);
>  }
> -- 
> 1.7.4.4
> 
> 
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox


From zzs213 at 126.com  Thu Nov 22 01:01:36 2012
From: zzs213 at 126.com (=?UTF-8?q?=E5=BC=A0=E5=BF=A0=E5=B1=B1?=)
Date: Thu, 22 Nov 2012 14:01:36 +0800
Subject: [PATCH] read cfi device id according the bus width
Message-ID: <1353564096-18861-1-git-send-email-zzs213@126.com>

Signed-off-by: ??? <zzs213 at 126.com>
---
 drivers/nor/cfi_flash_amd.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/nor/cfi_flash_amd.c b/drivers/nor/cfi_flash_amd.c
index 45c59b9..3ab4be0 100644
--- a/drivers/nor/cfi_flash_amd.c
+++ b/drivers/nor/cfi_flash_amd.c
@@ -62,8 +62,11 @@ static void amd_read_jedec_ids (struct flash_info *info)
 	udelay(1000); /* some flash are slow to respond */
 
 	info->manufacturer_id = jedec_read_mfr(info);
-	info->device_id = flash_read_uchar (info,
-					FLASH_OFFSET_DEVICE_ID);
+	if(info->chipwidth == FLASH_CFI_BY16)
+		info->device_id = flash_read16(flash_make_addr(info, 0, FLASH_OFFSET_DEVICE_ID));
+	else
+		info->device_id = flash_read_uchar (info,
+						FLASH_OFFSET_DEVICE_ID);
 	if (info->device_id == 0x7E) {
 		/* AMD 3-byte (expanded) device ids */
 		info->device_id2 = flash_read_uchar (info,
-- 
1.7.4.4




From plagnioj at jcrosoft.com  Thu Nov 22 01:14:38 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu, 22 Nov 2012 07:14:38 +0100
Subject: [PATCH] read cfi device id according the bus width
In-Reply-To: <1353564096-18861-1-git-send-email-zzs213@126.com>
References: <1353564096-18861-1-git-send-email-zzs213@126.com>
Message-ID: <20121122061438.GR8327@game.jcrosoft.org>

On 14:01 Thu 22 Nov     , ??? wrote:
> Signed-off-by: ??? <zzs213 at 126.com>
> ---
>  drivers/nor/cfi_flash_amd.c |    7 +++++--
>  1 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/nor/cfi_flash_amd.c b/drivers/nor/cfi_flash_amd.c
> index 45c59b9..3ab4be0 100644
> --- a/drivers/nor/cfi_flash_amd.c
> +++ b/drivers/nor/cfi_flash_amd.c
> @@ -62,8 +62,11 @@ static void amd_read_jedec_ids (struct flash_info *info)
>  	udelay(1000); /* some flash are slow to respond */
>  
>  	info->manufacturer_id = jedec_read_mfr(info);
> -	info->device_id = flash_read_uchar (info,
> -					FLASH_OFFSET_DEVICE_ID);
> +	if(info->chipwidth == FLASH_CFI_BY16)
> +		info->device_id = flash_read16(flash_make_addr(info, 0, FLASH_OFFSET_DEVICE_ID));
> +	else
> +		info->device_id = flash_read_uchar (info,
> +						FLASH_OFFSET_DEVICE_ID);

make this global with all with support
as don in linux

as this is valid for amd and intel and st

Best Regards.
J.
>  	if (info->device_id == 0x7E) {
>  		/* AMD 3-byte (expanded) device ids */
>  		info->device_id2 = flash_read_uchar (info,
> -- 
> 1.7.4.4
> 
> 
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox


From zzs213 at 126.com  Thu Nov 22 01:26:17 2012
From: zzs213 at 126.com (=?utf-8?B?5byg5b+g5bGx?=)
Date: Thu, 22 Nov 2012 14:26:17 +0800
Subject: [PATCH] read cfi device id according the bus width
In-Reply-To: <20121122061438.GR8327@game.jcrosoft.org>
References: <1353564096-18861-1-git-send-email-zzs213@126.com>
 <20121122061438.GR8327@game.jcrosoft.org>
Message-ID: <20121122062616.GD3022@greatfirst.com>

In message <20121122061438.GR8327 at game.jcrosoft.org> Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 14:01 Thu 22 Nov     , ??? wrote:
> > Signed-off-by: ??? <zzs213 at 126.com>
> > ---
> >  drivers/nor/cfi_flash_amd.c |    7 +++++--
> >  1 files changed, 5 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/nor/cfi_flash_amd.c b/drivers/nor/cfi_flash_amd.c
> > index 45c59b9..3ab4be0 100644
> > --- a/drivers/nor/cfi_flash_amd.c
> > +++ b/drivers/nor/cfi_flash_amd.c
> > @@ -62,8 +62,11 @@ static void amd_read_jedec_ids (struct flash_info *info)
> >  	udelay(1000); /* some flash are slow to respond */
> >
> >  	info->manufacturer_id = jedec_read_mfr(info);
> > -	info->device_id = flash_read_uchar (info,
> > -					FLASH_OFFSET_DEVICE_ID);
> > +	if(info->chipwidth == FLASH_CFI_BY16)
> > +		info->device_id = flash_read16(flash_make_addr(info, 0, FLASH_OFFSET_DEVICE_ID));
> > +	else
> > +		info->device_id = flash_read_uchar (info,
> > +						FLASH_OFFSET_DEVICE_ID);
>
> make this global with all with support
> as don in linux
>
> as this is valid for amd and intel and st
>
Does this mean cp this code to the function
drivers/nor/cfi_flash_intel.c:intel_read_jedec_ids() ?
-- 
Best Regards,
zzs




From plagnioj at jcrosoft.com  Thu Nov 22 01:38:26 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu, 22 Nov 2012 07:38:26 +0100
Subject: [PATCH] read cfi device id according the bus width
In-Reply-To: <20121122062616.GD3022@greatfirst.com>
References: <1353564096-18861-1-git-send-email-zzs213@126.com>
 <20121122061438.GR8327@game.jcrosoft.org>
 <20121122062616.GD3022@greatfirst.com>
Message-ID: <20121122063826.GS8327@game.jcrosoft.org>

On 14:26 Thu 22 Nov     , ??? wrote:
> In message <20121122061438.GR8327 at game.jcrosoft.org> Jean-Christophe PLAGNIOL-VILLARD wrote:
> > On 14:01 Thu 22 Nov     , ??? wrote:
> > > Signed-off-by: ??? <zzs213 at 126.com>
> > > ---
> > >  drivers/nor/cfi_flash_amd.c |    7 +++++--
> > >  1 files changed, 5 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/nor/cfi_flash_amd.c b/drivers/nor/cfi_flash_amd.c
> > > index 45c59b9..3ab4be0 100644
> > > --- a/drivers/nor/cfi_flash_amd.c
> > > +++ b/drivers/nor/cfi_flash_amd.c
> > > @@ -62,8 +62,11 @@ static void amd_read_jedec_ids (struct flash_info *info)
> > >  	udelay(1000); /* some flash are slow to respond */
> > >
> > >  	info->manufacturer_id = jedec_read_mfr(info);
> > > -	info->device_id = flash_read_uchar (info,
> > > -					FLASH_OFFSET_DEVICE_ID);
> > > +	if(info->chipwidth == FLASH_CFI_BY16)
> > > +		info->device_id = flash_read16(flash_make_addr(info, 0, FLASH_OFFSET_DEVICE_ID));
> > > +	else
> > > +		info->device_id = flash_read_uchar (info,
> > > +						FLASH_OFFSET_DEVICE_ID);
> >
> > make this global with all with support
> > as don in linux
> >
> > as this is valid for amd and intel and st
> >
> Does this mean cp this code to the function
> drivers/nor/cfi_flash_intel.c:intel_read_jedec_ids() ?
you can not as the reset is flash depedent

just factorise teh device_id read

Best Regards,
J.


From zzs213 at 126.com  Thu Nov 22 01:49:47 2012
From: zzs213 at 126.com (=?UTF-8?q?=E5=BC=A0=E5=BF=A0=E5=B1=B1?=)
Date: Thu, 22 Nov 2012 14:49:47 +0800
Subject: [PATCH] read cfi device id according the bus width
Message-ID: <1353566987-20609-1-git-send-email-zzs213@126.com>

Signed-off-by: ??? <zzs213 at 126.com>
---
 drivers/nor/cfi_flash_amd.c   |    7 +++++--
 drivers/nor/cfi_flash_intel.c |    7 +++++--
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/nor/cfi_flash_amd.c b/drivers/nor/cfi_flash_amd.c
index 45c59b9..3ab4be0 100644
--- a/drivers/nor/cfi_flash_amd.c
+++ b/drivers/nor/cfi_flash_amd.c
@@ -62,8 +62,11 @@ static void amd_read_jedec_ids (struct flash_info *info)
 	udelay(1000); /* some flash are slow to respond */
 
 	info->manufacturer_id = jedec_read_mfr(info);
-	info->device_id = flash_read_uchar (info,
-					FLASH_OFFSET_DEVICE_ID);
+	if(info->chipwidth == FLASH_CFI_BY16)
+		info->device_id = flash_read16(flash_make_addr(info, 0, FLASH_OFFSET_DEVICE_ID));
+	else
+		info->device_id = flash_read_uchar (info,
+						FLASH_OFFSET_DEVICE_ID);
 	if (info->device_id == 0x7E) {
 		/* AMD 3-byte (expanded) device ids */
 		info->device_id2 = flash_read_uchar (info,
diff --git a/drivers/nor/cfi_flash_intel.c b/drivers/nor/cfi_flash_intel.c
index 32e581a..75dc5a8 100644
--- a/drivers/nor/cfi_flash_intel.c
+++ b/drivers/nor/cfi_flash_intel.c
@@ -19,8 +19,11 @@ static void intel_read_jedec_ids (struct flash_info *info)
 	udelay(1000); /* some flash are slow to respond */
 
 	info->manufacturer_id = jedec_read_mfr(info);
-	info->device_id = flash_read_uchar (info,
-					FLASH_OFFSET_DEVICE_ID);
+	if(info->chipwidth == FLASH_CFI_BY16)
+		info->device_id = flash_read16(flash_make_addr(info, 0, FLASH_OFFSET_DEVICE_ID));
+	else
+		info->device_id = flash_read_uchar (info,
+						FLASH_OFFSET_DEVICE_ID);
 	flash_write_cmd(info, 0, 0, info->cmd_reset);
 }
 
-- 
1.7.4.4




From plagnioj at jcrosoft.com  Thu Nov 22 02:25:03 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Thu, 22 Nov 2012 08:25:03 +0100
Subject: [PATCH] read cfi device id according the bus width
In-Reply-To: <1353566987-20609-1-git-send-email-zzs213@126.com>
References: <1353566987-20609-1-git-send-email-zzs213@126.com>
Message-ID: <20121122072503.GT8327@game.jcrosoft.org>

On 14:49 Thu 22 Nov     , ??? wrote:
> Signed-off-by: ??? <zzs213 at 126.com>
> ---
>  drivers/nor/cfi_flash_amd.c   |    7 +++++--
>  drivers/nor/cfi_flash_intel.c |    7 +++++--
>  2 files changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/nor/cfi_flash_amd.c b/drivers/nor/cfi_flash_amd.c
> index 45c59b9..3ab4be0 100644
> --- a/drivers/nor/cfi_flash_amd.c
> +++ b/drivers/nor/cfi_flash_amd.c
> @@ -62,8 +62,11 @@ static void amd_read_jedec_ids (struct flash_info *info)
>  	udelay(1000); /* some flash are slow to respond */
>  
>  	info->manufacturer_id = jedec_read_mfr(info);
> -	info->device_id = flash_read_uchar (info,
> -					FLASH_OFFSET_DEVICE_ID);
> +	if(info->chipwidth == FLASH_CFI_BY16)
> +		info->device_id = flash_read16(flash_make_addr(info, 0, FLASH_OFFSET_DEVICE_ID));
> +	else
> +		info->device_id = flash_read_uchar (info,
> +						FLASH_OFFSET_DEVICE_ID);
>  	if (info->device_id == 0x7E) {
>  		/* AMD 3-byte (expanded) device ids */
>  		info->device_id2 = flash_read_uchar (info,
> diff --git a/drivers/nor/cfi_flash_intel.c b/drivers/nor/cfi_flash_intel.c
> index 32e581a..75dc5a8 100644
> --- a/drivers/nor/cfi_flash_intel.c
> +++ b/drivers/nor/cfi_flash_intel.c
> @@ -19,8 +19,11 @@ static void intel_read_jedec_ids (struct flash_info *info)
>  	udelay(1000); /* some flash are slow to respond */
>  
>  	info->manufacturer_id = jedec_read_mfr(info);
> -	info->device_id = flash_read_uchar (info,
> -					FLASH_OFFSET_DEVICE_ID);
> +	if(info->chipwidth == FLASH_CFI_BY16)
> +		info->device_id = flash_read16(flash_make_addr(info, 0, FLASH_OFFSET_DEVICE_ID));
> +	else
> +		info->device_id = flash_read_uchar (info,
> +						FLASH_OFFSET_DEVICE_ID);
>  	flash_write_cmd(info, 0, 0, info->cmd_reset);

I said factorize not duplicate

and you need to handle all the with not only 8 and 16

Best Regards,
J.
>  }
>  
> -- 
> 1.7.4.4
> 
> 
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox


From zzs213 at 126.com  Thu Nov 22 03:06:14 2012
From: zzs213 at 126.com (=?utf-8?B?5byg5b+g5bGx?=)
Date: Thu, 22 Nov 2012 16:06:14 +0800
Subject: [PATCH] read cfi device id according the bus width
In-Reply-To: <20121122072503.GT8327@game.jcrosoft.org>
References: <1353566987-20609-1-git-send-email-zzs213@126.com>
 <20121122072503.GT8327@game.jcrosoft.org>
Message-ID: <20121122080614.GE3022@greatfirst.com>

> I said factorize not duplicate
>
> and you need to handle all the with not only 8 and 16
>
I check the kernel code, th id defined in cfi_private is "int",
but in barebox is a ushort.

When width is 32, How to save the id?

-- 
Best Regards,
zzs




From zzs213 at 126.com  Fri Nov 23 04:17:53 2012
From: zzs213 at 126.com (=?utf-8?B?5byg5b+g5bGx?=)
Date: Fri, 23 Nov 2012 17:17:53 +0800
Subject: NAND_ATMEL strange behavior on at91rm9200 board
Message-ID: <20121123091753.GF3022@greatfirst.com>

when NAND_ATMEL used on at91rm9200, it's behavior very strange

write to nand have no effect, Read out of nand, the contents
very strange.

So I write some date to nand using u-boot and then start barebox

----------
# md -s/dev/nand0 0+0x400
00000000: ea00000a eafffffe eafffffe eafffffe                ................
00000010: eafffffe 0000016c eafffffe eafffffe                ....l...........
00000020: 65726162 00786f62 23b00000 00020ea9                barebox....#....
00000030: e10f3000 e3c3301f e38330d3 e129f003                .0...0...0....).
00000040: 00000000 00000000 00000000 00000400                ................
00000050: 00000000 00000000 00000000 00000000                ................
00000060: 00000000 00000000 00000000 00000000                ................
00000070: 00000000 00000000 00000000 00000000                ................
00000080: 00000000 00000000 00000000 00000000                ................
00000090: 00000000 00000000 00000000 00000000                ................
000000a0: 00000000 00000000 00000000 00000000                ................
000000b0: 00000000 00000000 00000000 00000000                ................
000000c0: 00000000 00000000 00000000 00000000                ................
000000d0: 00000000 00000000 00000000 00000000                ................
000000e0: 00000000 00000000 00000000 00000000                ................
000000f0: 00000000 00000000 00000000 00000000                ................
00000100: e1a04000 e50c306f e1a01002 e1a03002                . at ..o0.......0..
00000110: e28ee001 e35e0008 e5843000 1afffffb                ......^..0......
00000120: e3e02000 e3a03003 e502306f e3a03e2e                . ...0..o0...>..
00000130: e5841000 e502306b e5841000 e502106f                ....k0......o...
00000140: 00000000 00000000 00000000 00000000                ................
00000150: 00000000 00000000 00000000 00000000                ................
00000160: 00000000 00000000 00000000 00000000                ................
00000170: 00000000 00000000 00000000 00000000                ................
00000180: 00000000 00000000 00000000 00000004                ................
00000190: 00000000 00000000 00000000 00000000                ................
....

But the datas should be:
00000000: ea00000a eafffffe eafffffe eafffffe                ................
00000010: eafffffe 0000016c eafffffe eafffffe                ....l...........
00000020: 65726162 00786f62 23b00000 000200fa                barebox....#....
00000030: e10f3000 e3c3301f e38330d3 e129f003                .0...0...0....).
00000040: ee113f10 e3c33d8e e3c33005 e3833a01                .?...=...0...:..
00000050: e3833002 ee013f10 e3e02000 e51233cf                .0...?... ...3..
00000060: e3130003 1a000039 e59f30e4 e1a01002                ....9....0......
00000070: e50233df e5113397 e3130001 0afffffc                .3...3..........
00000080: e3a03000 e501309b e59f30c8 e3e02000                .0...0...0... ..
00000090: e501308f e59f30c0 e50133d7 e5123397                .0...0...3...3..
000000a0: e3130002 0afffffc e3a03c01 e50233cf                .........<...3..
000000b0: e59f30a8 e3e0c000 e50233cf e51c3397                .0.......3...3..
000000c0: e3130008 0afffffc e59f3094 e3a02000                .........0... ..
000000d0: e50c378f e50c278b e50c37fb e59f3084                .7...'...7...0..
000000e0: e3a01002 e50c109f e3a00202 e50c3067                ............g0..
000000f0: e3a03004 e50c106f e1a0e002 e5802000                .0..o........ ..
......

It looks like there are 64bytes correct data in every 256 bytes. It's so
strange!!

After study barebox source codes. I found atmel_read_buf use
memcpy_fromio to read. I can't understand it. May be on at91samxxx cpu
it's right.

So I let "nand_chip->read_buf = NULL" to let it use the default read
function.

After this , It's OK

I has no at91sam board, So anybody tell me is this behavior specific to
at91rm9200?

-- 
Best Regards,
zzs




From plagnioj at jcrosoft.com  Fri Nov 23 10:12:28 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri, 23 Nov 2012 16:12:28 +0100
Subject: NAND_ATMEL strange behavior on at91rm9200 board
In-Reply-To: <20121123091753.GF3022@greatfirst.com>
References: <20121123091753.GF3022@greatfirst.com>
Message-ID: <20121123151228.GU8327@game.jcrosoft.org>

On 17:17 Fri 23 Nov     , ??? wrote:
> when NAND_ATMEL used on at91rm9200, it's behavior very strange
> 
> write to nand have no effect, Read out of nand, the contents
> very strange.
> 
> So I write some date to nand using u-boot and then start barebox
if you do not sedn you code we can not help

Best Regards,
J.
> 
> ----------
> # md -s/dev/nand0 0+0x400
> 00000000: ea00000a eafffffe eafffffe eafffffe                ................
> 00000010: eafffffe 0000016c eafffffe eafffffe                ....l...........
> 00000020: 65726162 00786f62 23b00000 00020ea9                barebox....#....
> 00000030: e10f3000 e3c3301f e38330d3 e129f003                .0...0...0....).
> 00000040: 00000000 00000000 00000000 00000400                ................
> 00000050: 00000000 00000000 00000000 00000000                ................
> 00000060: 00000000 00000000 00000000 00000000                ................
> 00000070: 00000000 00000000 00000000 00000000                ................
> 00000080: 00000000 00000000 00000000 00000000                ................
> 00000090: 00000000 00000000 00000000 00000000                ................
> 000000a0: 00000000 00000000 00000000 00000000                ................
> 000000b0: 00000000 00000000 00000000 00000000                ................
> 000000c0: 00000000 00000000 00000000 00000000                ................
> 000000d0: 00000000 00000000 00000000 00000000                ................
> 000000e0: 00000000 00000000 00000000 00000000                ................
> 000000f0: 00000000 00000000 00000000 00000000                ................
> 00000100: e1a04000 e50c306f e1a01002 e1a03002                . at ..o0.......0..
> 00000110: e28ee001 e35e0008 e5843000 1afffffb                ......^..0......
> 00000120: e3e02000 e3a03003 e502306f e3a03e2e                . ...0..o0...>..
> 00000130: e5841000 e502306b e5841000 e502106f                ....k0......o...
> 00000140: 00000000 00000000 00000000 00000000                ................
> 00000150: 00000000 00000000 00000000 00000000                ................
> 00000160: 00000000 00000000 00000000 00000000                ................
> 00000170: 00000000 00000000 00000000 00000000                ................
> 00000180: 00000000 00000000 00000000 00000004                ................
> 00000190: 00000000 00000000 00000000 00000000                ................
> ....
> 
> But the datas should be:
> 00000000: ea00000a eafffffe eafffffe eafffffe                ................
> 00000010: eafffffe 0000016c eafffffe eafffffe                ....l...........
> 00000020: 65726162 00786f62 23b00000 000200fa                barebox....#....
> 00000030: e10f3000 e3c3301f e38330d3 e129f003                .0...0...0....).
> 00000040: ee113f10 e3c33d8e e3c33005 e3833a01                .?...=...0...:..
> 00000050: e3833002 ee013f10 e3e02000 e51233cf                .0...?... ...3..
> 00000060: e3130003 1a000039 e59f30e4 e1a01002                ....9....0......
> 00000070: e50233df e5113397 e3130001 0afffffc                .3...3..........
> 00000080: e3a03000 e501309b e59f30c8 e3e02000                .0...0...0... ..
> 00000090: e501308f e59f30c0 e50133d7 e5123397                .0...0...3...3..
> 000000a0: e3130002 0afffffc e3a03c01 e50233cf                .........<...3..
> 000000b0: e59f30a8 e3e0c000 e50233cf e51c3397                .0.......3...3..
> 000000c0: e3130008 0afffffc e59f3094 e3a02000                .........0... ..
> 000000d0: e50c378f e50c278b e50c37fb e59f3084                .7...'...7...0..
> 000000e0: e3a01002 e50c109f e3a00202 e50c3067                ............g0..
> 000000f0: e3a03004 e50c106f e1a0e002 e5802000                .0..o........ ..
> ......
> 
> It looks like there are 64bytes correct data in every 256 bytes. It's so
> strange!!
> 
> After study barebox source codes. I found atmel_read_buf use
> memcpy_fromio to read. I can't understand it. May be on at91samxxx cpu
> it's right.
> 
> So I let "nand_chip->read_buf = NULL" to let it use the default read
> function.
> 
> After this , It's OK
> 
> I has no at91sam board, So anybody tell me is this behavior specific to
> at91rm9200?
> 
> -- 
> Best Regards,
> zzs
> 
> 
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox


From plagnioj at jcrosoft.com  Fri Nov 23 10:52:24 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri, 23 Nov 2012 16:52:24 +0100
Subject: [PATCH 0/4] at91: some fixes
Message-ID: <20121123155224.GV8327@game.jcrosoft.org>

HI,

	some fixe for at91

	they are needed for at91sam9n12 support

The following changes since commit c7a729aefe13104b6f3a9f2150a9e993bb510d43:

  Merge branch 'for-next/m25p80' (2012-11-21 11:54:34 +0100)

are available in the git repository at:


  git://git.jcrosoft.org/barebox.git delivery/at91_fixes

for you to fetch changes up to 02d37b5d4598cd3ffea4730aa027c8c04ab1f58d:

  Revert "mtd: atmel_nand: optimize read/write buffer functions" (2012-11-22 02:21:14 +0800)

----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (4):
      at91: fix timer rate
      atmel_nand: fix pmecc timeout
      at91: clock: check overclock for sam9260/9261/9263/9rl
      Revert "mtd: atmel_nand: optimize read/write buffer functions"

 arch/arm/mach-at91/at91sam926x_time.c |    7 ++++++-
 arch/arm/mach-at91/clock.c            |   12 ++++++++++++
 drivers/mtd/nand/atmel_nand.c         |   33 +++++++++++++++++++++++++--------
 drivers/mtd/nand/atmel_nand_ecc.h     |    2 +-
 4 files changed, 44 insertions(+), 10 deletions(-)

Best Regards,
J.


From plagnioj at jcrosoft.com  Fri Nov 23 10:55:01 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri, 23 Nov 2012 16:55:01 +0100
Subject: [PATCH 1/4] at91: fix timer rate
In-Reply-To: <20121123155224.GV8327@game.jcrosoft.org>
References: <20121123155224.GV8327@game.jcrosoft.org>
Message-ID: <1353686104-31295-1-git-send-email-plagnioj@jcrosoft.com>

today the timer rate is hardcoded to 6MHz which is wrong the PIT rate is MCK / 16

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/mach-at91/at91sam926x_time.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-at91/at91sam926x_time.c b/arch/arm/mach-at91/at91sam926x_time.c
index 7411ad8..7425e0a 100644
--- a/arch/arm/mach-at91/at91sam926x_time.c
+++ b/arch/arm/mach-at91/at91sam926x_time.c
@@ -34,6 +34,7 @@
 #include <mach/at91_rstc.h>
 #include <mach/io.h>
 #include <io.h>
+#include <linux/clk.h>
 
 uint64_t at91sam9_clocksource_read(void)
 {
@@ -48,16 +49,20 @@ static struct clocksource cs = {
 
 static int clocksource_init (void)
 {
+	u32 pit_rate;
+
 	/*
 	 * Enable PITC Clock
 	 * The clock is already enabled for system controller in boot
 	 */
 	at91_sys_write(AT91_PMC_PCER, 1 << AT91_ID_SYS);
 
+	pit_rate = clk_get_rate(clk_get(NULL, "mck")) / 16;
+
 	/* Enable PITC */
 	at91_sys_write(AT91_PIT_MR, 0xfffff | AT91_PIT_PITEN);
 
-	cs.mult = clocksource_hz2mult(1000000 * 6, cs.shift);
+	cs.mult = clocksource_hz2mult(pit_rate, cs.shift);
 
 	init_clock(&cs);
 
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Fri Nov 23 10:55:03 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri, 23 Nov 2012 16:55:03 +0100
Subject: [PATCH 3/4] at91: clock: check overclock for sam9260/9261/9263/9rl
In-Reply-To: <1353686104-31295-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121123155224.GV8327@game.jcrosoft.org>
 <1353686104-31295-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1353686104-31295-3-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/mach-at91/clock.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/mach-at91/clock.c b/arch/arm/mach-at91/clock.c
index bda02fd..fd9ba46 100644
--- a/arch/arm/mach-at91/clock.c
+++ b/arch/arm/mach-at91/clock.c
@@ -50,6 +50,12 @@
 
 #define cpu_has_300M_plla()	(cpu_is_at91sam9g10())
 
+#define cpu_has_240M_plla()	(cpu_is_at91sam9261() \
+				|| cpu_is_at91sam9263() \
+				|| cpu_is_at91sam9rl())
+
+#define cpu_has_210M_plla()	(cpu_is_at91sam9260())
+
 #define cpu_has_pllb()		(!(cpu_is_at91sam9rl() \
 				|| cpu_is_at91sam9g45() \
 				|| cpu_is_at91sam9x5()))
@@ -602,6 +608,12 @@ int at91_clock_init(unsigned long main_clock)
 	} else if (cpu_has_800M_plla()) {
 		if (plla.rate_hz > 800000000)
 			pll_overclock = 1;
+	} else if (cpu_has_240M_plla()) {
+		if (plla.rate_hz > 240000000)
+			pll_overclock = 1;
+	} else if (cpu_has_210M_plla()) {
+		if (plla.rate_hz > 210000000)
+			pll_overclock = 1;
 	} else {
 		if (plla.rate_hz > 209000000)
 			pll_overclock = 1;
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Fri Nov 23 10:55:02 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri, 23 Nov 2012 16:55:02 +0100
Subject: [PATCH 2/4] atmel_nand: fix pmecc timeout
In-Reply-To: <1353686104-31295-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121123155224.GV8327@game.jcrosoft.org>
 <1353686104-31295-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1353686104-31295-2-git-send-email-plagnioj@jcrosoft.com>

the timeout is 100ms not 100ns

on sam9x5 the SoC is fast enough so we can not see it
but not on sam9n12

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/mtd/nand/atmel_nand_ecc.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/atmel_nand_ecc.h b/drivers/mtd/nand/atmel_nand_ecc.h
index 34f481e..e39aada 100644
--- a/drivers/mtd/nand/atmel_nand_ecc.h
+++ b/drivers/mtd/nand/atmel_nand_ecc.h
@@ -146,6 +146,6 @@
 #define PMECC_LOOKUP_TABLE_SIZE_1024		0x4000
 
 /* Time out value for reading PMECC status register */
-#define PMECC_MAX_TIMEOUT_MS			100
+#define PMECC_MAX_TIMEOUT_MS			100 * MSECOND
 
 #endif
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Fri Nov 23 10:55:04 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri, 23 Nov 2012 16:55:04 +0100
Subject: [PATCH 4/4] Revert "mtd: atmel_nand: optimize read/write buffer
 functions"
In-Reply-To: <1353686104-31295-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121123155224.GV8327@game.jcrosoft.org>
 <1353686104-31295-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1353686104-31295-4-git-send-email-plagnioj@jcrosoft.com>

As in the kernel we revert as this was supposed to work but does not yet
this may need more work on the smc to be able to use it
So for now revert it

This reverts commit 809f0f6327241504b5071622a8d573255f91a875.

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/mtd/nand/atmel_nand.c |   33 +++++++++++++++++++++++++--------
 1 file changed, 25 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index 0477178..69e8171 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -159,16 +159,30 @@ static int atmel_nand_device_ready(struct mtd_info *mtd)
  */
 static void atmel_read_buf(struct mtd_info *mtd, u8 *buf, int len)
 {
-	struct nand_chip *chip = mtd->priv;
+	struct nand_chip	*nand_chip = mtd->priv;
 
-	memcpy_fromio(buf, chip->IO_ADDR_R, len);
+	readsb(nand_chip->IO_ADDR_R, buf, len);
+}
+
+static void atmel_read_buf16(struct mtd_info *mtd, u8 *buf, int len)
+{
+	struct nand_chip	*nand_chip = mtd->priv;
+
+	readsw(nand_chip->IO_ADDR_R, buf, len / 2);
 }
 
 static void atmel_write_buf(struct mtd_info *mtd, const u8 *buf, int len)
 {
-	struct nand_chip *chip = mtd->priv;
+	struct nand_chip	*nand_chip = mtd->priv;
 
-	memcpy_toio(chip->IO_ADDR_W, buf, len);
+	writesb(nand_chip->IO_ADDR_W, buf, len);
+}
+
+static void atmel_write_buf16(struct mtd_info *mtd, const u8 *buf, int len)
+{
+	struct nand_chip	*nand_chip = mtd->priv;
+
+	writesw(nand_chip->IO_ADDR_W, buf, len / 2);
 }
 
 /*
@@ -1112,11 +1126,14 @@ static int __init atmel_nand_probe(struct device_d *dev)
 
 	nand_chip->chip_delay = 20;		/* 20us command delay time */
 
-	if (host->board->bus_width_16)		/* 16-bit bus width */
+	if (host->board->bus_width_16) {	/* 16-bit bus width */
 		nand_chip->options |= NAND_BUSWIDTH_16;
-
-	nand_chip->read_buf = atmel_read_buf;
-	nand_chip->write_buf = atmel_write_buf;
+		nand_chip->read_buf = atmel_read_buf16;
+		nand_chip->write_buf = atmel_write_buf16;
+	} else {
+		nand_chip->read_buf = atmel_read_buf;
+		nand_chip->write_buf = atmel_write_buf;
+	}
 
 	atmel_nand_enable(host);
 
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Fri Nov 23 10:59:45 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri, 23 Nov 2012 16:59:45 +0100
Subject: [PATCH 0/2] at91: at91sam9n12 support
Message-ID: <20121123155945.GW8327@game.jcrosoft.org>

Hi,

	this patch serie add the support of the at91sam9n12 with it's
	reference board the n12ek

	we do not switch to the defaultenv-2 as I need nfs boot with symlink
	and this is not support yet in it

	I'll switch all my platform when we will have it

	This patch serie depends on the at91_fixes send just before


wing changes since commit 02d37b5d4598cd3ffea4730aa027c8c04ab1f58d:

  Revert "mtd: atmel_nand: optimize read/write buffer functions" (2012-11-22 02:21:14 +0800)

are available in the git repository at:

  git://git.jcrosoft.org/barebox.git delivery/at91sam9n12

for you to fetch changes up to 96a5ef4e557a816e50e66d9f708934e68b49ea76:

  at91: add at91sam9n12ek board support (2012-11-22 02:24:59 +0800)

----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (2):
      arm: at91: add at91sam9n12 support
      at91: add at91sam9n12ek board support

 arch/arm/Makefile                                    |    1 +
 arch/arm/boards/at91sam9n12ek/Makefile               |    1 +
 arch/arm/boards/at91sam9n12ek/config.h               |    6 ++
 arch/arm/boards/at91sam9n12ek/env/bin/init_board     |   50 +++++++++++++
 arch/arm/boards/at91sam9n12ek/env/config             |   41 +++++++++++
 arch/arm/boards/at91sam9n12ek/init.c                 |  270 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 arch/arm/configs/at91sam9n12ek_defconfig             |   87 +++++++++++++++++++++++
 arch/arm/mach-at91/Kconfig                           |   23 ++++++
 arch/arm/mach-at91/Makefile                          |    1 +
 arch/arm/mach-at91/at91sam9n12.c                     |  233 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-at91/at91sam9n12_devices.c             |  374 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-at91/clock.c                           |   15 ++--
 arch/arm/mach-at91/gpio.c                            |    2 +-
 arch/arm/mach-at91/include/mach/at91sam9n12.h        |  166 ++++++++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-at91/include/mach/at91sam9n12_matrix.h |   98 ++++++++++++++++++++++++++
 arch/arm/mach-at91/include/mach/board.h              |    1 +
 arch/arm/mach-at91/include/mach/cpu.h                |    7 ++
 arch/arm/mach-at91/include/mach/hardware.h           |    2 +
 18 files changed, 1372 insertions(+), 6 deletions(-)
 create mode 100644 arch/arm/boards/at91sam9n12ek/Makefile
 create mode 100644 arch/arm/boards/at91sam9n12ek/config.h
 create mode 100644 arch/arm/boards/at91sam9n12ek/env/bin/init_board
 create mode 100644 arch/arm/boards/at91sam9n12ek/env/config
 create mode 100644 arch/arm/boards/at91sam9n12ek/init.c
 create mode 100644 arch/arm/configs/at91sam9n12ek_defconfig
 create mode 100644 arch/arm/mach-at91/at91sam9n12.c
 create mode 100644 arch/arm/mach-at91/at91sam9n12_devices.c
 create mode 100644 arch/arm/mach-at91/include/mach/at91sam9n12.h
 create mode 100644 arch/arm/mach-at91/include/mach/at91sam9n12_matrix.h

Best Regards,
J.


From plagnioj at jcrosoft.com  Fri Nov 23 11:01:35 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri, 23 Nov 2012 17:01:35 +0100
Subject: [PATCH 2/2] at91: add at91sam9n12ek board support
In-Reply-To: <1353686495-31912-1-git-send-email-plagnioj@jcrosoft.com>
References: <20121123155945.GW8327@game.jcrosoft.org>
 <1353686495-31912-1-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <1353686495-31912-2-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/Makefile                                |    1 +
 arch/arm/boards/at91sam9n12ek/Makefile           |    1 +
 arch/arm/boards/at91sam9n12ek/config.h           |    6 +
 arch/arm/boards/at91sam9n12ek/env/bin/init_board |   50 ++++
 arch/arm/boards/at91sam9n12ek/env/config         |   41 ++++
 arch/arm/boards/at91sam9n12ek/init.c             |  270 ++++++++++++++++++++++
 arch/arm/configs/at91sam9n12ek_defconfig         |   87 +++++++
 arch/arm/mach-at91/Kconfig                       |   17 ++
 8 files changed, 473 insertions(+)
 create mode 100644 arch/arm/boards/at91sam9n12ek/Makefile
 create mode 100644 arch/arm/boards/at91sam9n12ek/config.h
 create mode 100644 arch/arm/boards/at91sam9n12ek/env/bin/init_board
 create mode 100644 arch/arm/boards/at91sam9n12ek/env/config
 create mode 100644 arch/arm/boards/at91sam9n12ek/init.c
 create mode 100644 arch/arm/configs/at91sam9n12ek_defconfig

diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 8cef771..d911ffe 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -75,6 +75,7 @@ board-$(CONFIG_MACH_AT91SAM9261EK)		:= at91sam9261ek
 board-$(CONFIG_MACH_AT91SAM9263EK)		:= at91sam9263ek
 board-$(CONFIG_MACH_AT91SAM9G10EK)		:= at91sam9261ek
 board-$(CONFIG_MACH_AT91SAM9G20EK)		:= at91sam9260ek
+board-$(CONFIG_MACH_AT91SAM9N12EK)		:= at91sam9n12ek
 board-$(CONFIG_MACH_AT91SAM9X5EK)		:= at91sam9x5ek
 board-$(CONFIG_MACH_AT91SAM9M10G45EK)		:= at91sam9m10g45ek
 board-$(CONFIG_MACH_CLEP7212)			:= clep7212
diff --git a/arch/arm/boards/at91sam9n12ek/Makefile b/arch/arm/boards/at91sam9n12ek/Makefile
new file mode 100644
index 0000000..eb072c0
--- /dev/null
+++ b/arch/arm/boards/at91sam9n12ek/Makefile
@@ -0,0 +1 @@
+obj-y += init.o
diff --git a/arch/arm/boards/at91sam9n12ek/config.h b/arch/arm/boards/at91sam9n12ek/config.h
new file mode 100644
index 0000000..5779a47
--- /dev/null
+++ b/arch/arm/boards/at91sam9n12ek/config.h
@@ -0,0 +1,6 @@
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+#define AT91_MAIN_CLOCK		16000000	/* 16 MHz crystal */
+
+#endif	/* __CONFIG_H */
diff --git a/arch/arm/boards/at91sam9n12ek/env/bin/init_board b/arch/arm/boards/at91sam9n12ek/env/bin/init_board
new file mode 100644
index 0000000..977430d
--- /dev/null
+++ b/arch/arm/boards/at91sam9n12ek/env/bin/init_board
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+button_name="dfu_bp"
+button_wait=5
+
+product_id=0x1234
+vendor_id=0x4321
+
+dfu_config="/dev/nand0.barebox.bb(barebox)sr,/dev/nand0.kernel.bb(kernel)r,/dev/nand0.rootfs.bb(rootfs)r"
+
+if [ $at91_udc0.vbus != 1 ]
+then
+	echo "No USB Device cable plugged, normal boot"
+	exit
+fi
+
+gpio_get_value ${dfu_button}
+if [ $? != 0 ]
+then
+	autoboot_timeout=16
+	echo "enable tty over USB Device, increase the boot delay to ${autoboot_timeout}s"
+	usbserial
+	exit
+fi
+
+echo "${button_name} pressed detected wait ${button_wait}s"
+timeout -s -a ${button_wait}
+
+if [ $at91_udc0.vbus != 1 ]
+then
+	echo "No USB Device cable plugged, normal boot"
+	exit
+fi
+
+gpio_get_value ${dfu_button}
+if [ $? != 0 ]
+then
+	echo "${button_name} released, normal boot"
+	autoboot_timeout=16
+	echo "enable tty over USB Device, increase the boot delay to ${autoboot_timeout}s"
+	usbserial
+	exit
+fi
+
+echo ""
+echo "Start DFU Mode"
+echo ""
+
+led ds5 1
+dfu ${dfu_config} -P ${product_id} -V ${vendor_id}
diff --git a/arch/arm/boards/at91sam9n12ek/env/config b/arch/arm/boards/at91sam9n12ek/env/config
new file mode 100644
index 0000000..f5cd1cc
--- /dev/null
+++ b/arch/arm/boards/at91sam9n12ek/env/config
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+# use 'dhcp' to do dhcp in barebox and in kernel
+# use 'none' if you want to skip kernel ip autoconfiguration
+ip=dhcp-barebox
+global.dhcp.vendor_id=barebox-at91sam9n12ek
+
+# or set your networking parameters here
+#eth0.ipaddr=a.b.c.d
+#eth0.netmask=a.b.c.d
+#eth0.gateway=a.b.c.d
+#eth0.serverip=a.b.c.d
+
+# can be either 'nfs', 'tftp', 'nor' or 'nand'
+kernel_loc=nfs
+# can be either 'net', 'nor', 'nand' or 'initrd'
+rootfs_loc=net
+# can be either 'nfs', 'tftp', 'nand' or empty
+oftree_loc=nfs
+
+# can be either 'jffs2' or 'ubifs'
+rootfs_type=ubifs
+rootfsimage=root.$rootfs_type
+ubiroot=rootfs
+
+# The image type of the kernel. Can be uimage, zimage, raw, or raw_lzo
+kernelimage=zImage
+#kernelimage=uImage
+#kernelimage=Image
+#kernelimage=Image.lzo
+
+nand_device=atmel_nand
+nand_parts="256k(at91bootstrap),384k(barebox)ro,128k(bareboxenv),128k(bareboxenv2),128k(oftree),1M(free),6M(kernel),120M(rootfs),-(data)"
+rootfs_mtdblock_nand=7
+
+autoboot_timeout=3
+
+bootargs="console=ttyS0,115200"
+
+# set a fancy prompt (if support is compiled in)
+PS1="\e[1;32mbarebox@\e[1;31m\h:\w\e[0m\n# "
diff --git a/arch/arm/boards/at91sam9n12ek/init.c b/arch/arm/boards/at91sam9n12ek/init.c
new file mode 100644
index 0000000..3d4ab5b
--- /dev/null
+++ b/arch/arm/boards/at91sam9n12ek/init.c
@@ -0,0 +1,270 @@
+/*
+ * Copyright (C) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ *
+ */
+
+#include <common.h>
+#include <net.h>
+#include <init.h>
+#include <environment.h>
+#include <fec.h>
+#include <asm/armlinux.h>
+#include <generated/mach-types.h>
+#include <partition.h>
+#include <fs.h>
+#include <fcntl.h>
+#include <io.h>
+#include <asm/hardware.h>
+#include <nand.h>
+#include <sizes.h>
+#include <linux/mtd/nand.h>
+#include <mach/board.h>
+#include <mach/at91sam9_smc.h>
+#include <mach/sam9_smc.h>
+#include <gpio.h>
+#include <mach/io.h>
+#include <mach/at91_pmc.h>
+#include <mach/at91_rstc.h>
+#include <mach/at91sam9x5_matrix.h>
+#include <input/qt1070.h>
+#include <readkey.h>
+#include <spi/spi.h>
+
+static struct atmel_nand_data nand_pdata = {
+	.ale		= 21,
+	.cle		= 22,
+	.det_pin	= 0,
+	.rdy_pin	= AT91_PIN_PD5,
+	.enable_pin	= AT91_PIN_PD4,
+	.ecc_mode	= NAND_ECC_HW,
+	.pmecc_sector_size = 512,
+	.pmecc_corr_cap = 2,
+	.bus_on_d0	= 1,
+	.on_flash_bbt	= 1,
+};
+
+static struct sam9_smc_config ek_nand_smc_config = {
+	.ncs_read_setup		= 0,
+	.nrd_setup		= 2,
+	.ncs_write_setup	= 0,
+	.nwe_setup		= 1,
+
+	.ncs_read_pulse		= 6,
+	.nrd_pulse		= 4,
+	.ncs_write_pulse	= 5,
+	.nwe_pulse		= 3,
+
+	.read_cycle		= 7,
+	.write_cycle		= 5,
+
+	.mode			= AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE,
+	.tdf_cycles		= 1,
+};
+
+static void ek_add_device_nand(void)
+{
+	ek_nand_smc_config.mode |= AT91_SMC_DBW_8;
+
+	/* configure chip-select 3 (NAND) */
+	sam9_smc_configure(3, &ek_nand_smc_config);
+
+	at91_add_device_nand(&nand_pdata);
+}
+
+/*
+ * KS8851 ethernet device
+ */
+#if defined(CONFIG_DRIVER_NET_KS8851_MLL)
+/*
+ * SMC timings for the KS8851.
+ * Note: These timings were calculated
+ * for MASTER_CLOCK = 100000000 according to the KS8851 timings.
+ */
+static struct sam9_smc_config __initdata ks8851_smc_config = {
+	.ncs_read_setup		= 0,
+	.nrd_setup		= 1,
+	.ncs_write_setup	= 0,
+	.nwe_setup		= 2,
+
+	.ncs_read_pulse		= 7,
+	.nrd_pulse		= 7,
+	.ncs_write_pulse	= 7,
+	.nwe_pulse		= 7,
+
+	.read_cycle		= 9,
+	.write_cycle		= 9,
+
+	.mode			= AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_BAT_SELECT | AT91_SMC_DBW_16,
+	.tdf_cycles		= 1,
+};
+
+static void __init ek_add_device_ks8851(void)
+{
+	/* Configure chip-select 2 (KS8851) */
+	sam9_smc_configure(2, &ks8851_smc_config);
+	/* Configure NCS signal */
+	at91_set_B_periph(AT91_PIN_PD19, 0);
+	/* Configure Interrupt pin as input, no pull-up */
+	at91_set_gpio_input(AT91_PIN_PD21, 0);
+
+	add_ks8851_device(DEVICE_ID_SINGLE, AT91_CHIPSELECT_2, AT91_CHIPSELECT_2 + 2,
+				IORESOURCE_MEM_16BIT, NULL);
+}
+#else
+static void __init ek_add_device_ks8851(void) {}
+#endif /* CONFIG_DRIVER_NET_KS8851_MLL */
+
+/*
+ * MCI (SD/MMC)
+ */
+/* mci0 detect_pin is revision dependent */
+static struct atmel_mci_platform_data mci0_data = {
+	.bus_width	= 4,
+	.detect_pin	= AT91_PIN_PA7,
+	.wp_pin		= 0,
+};
+
+static void ek_add_device_mci(void)
+{
+	/* MMC0 */
+	at91_add_device_mci(0, &mci0_data);
+}
+
+struct qt1070_platform_data qt1070_pdata = {
+	.irq_pin	= AT91_PIN_PA2,
+};
+
+static struct i2c_board_info i2c_devices[] = {
+	{
+		.platform_data = &qt1070_pdata,
+		I2C_BOARD_INFO("qt1070", 0x1b),
+	},
+};
+
+static void ek_add_device_i2c(void)
+{
+	at91_set_gpio_input(qt1070_pdata.irq_pin, 0);
+	at91_set_deglitch(qt1070_pdata.irq_pin, 1);
+	at91_add_device_i2c(0, i2c_devices, ARRAY_SIZE(i2c_devices));
+}
+
+static const struct spi_board_info ek_spi_devices[] = {
+	{
+		.name		= "m25p80",
+		.chip_select	= 0,
+		.max_speed_hz	= 1 * 1000 * 1000,
+		.bus_num	= 0,
+	},
+};
+
+static unsigned spi0_standard_cs[] = { AT91_PIN_PA14 };
+static struct at91_spi_platform_data spi_pdata = {
+	.chipselect = spi0_standard_cs,
+	.num_chipselect = ARRAY_SIZE(spi0_standard_cs),
+};
+
+static void ek_add_device_spi(void)
+{
+	spi_register_board_info(ek_spi_devices,
+				ARRAY_SIZE(ek_spi_devices));
+	at91_add_device_spi(0, &spi_pdata);
+}
+
+/*
+ * USB Device port
+ */
+static struct at91_udc_data __initdata ek_udc_data = {
+	.vbus_pin	= AT91_PIN_PB16,
+	.pullup_pin	= 0,		/* pull-up driven by UDC */
+};
+
+struct gpio_led leds[] = {
+	{
+		.gpio	= AT91_PIN_PB4,
+		.led	= {
+			.name = "d8",
+		},
+	}, {
+		.gpio	= AT91_PIN_PB5,
+		.active_low	= 1,
+		.led	= {
+			.name = "d9",
+		},
+	}, {
+		.gpio	= AT91_PIN_PB6,
+		.led	= {
+			.name = "10",
+		},
+	},
+};
+
+static void __init ek_add_led(void)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(leds); i++) {
+		at91_set_gpio_output(leds[i].gpio, leds[i].active_low);
+		led_gpio_register(&leds[i]);
+	}
+	led_set_trigger(LED_TRIGGER_HEARTBEAT, &leds[0].led);
+}
+
+static void __init ek_add_device_buttons(void)
+{
+	at91_set_gpio_input(AT91_PIN_PB3, 1);
+	at91_set_deglitch(AT91_PIN_PB3, 1);
+	export_env_ull("dfu_button", AT91_PIN_PB3);
+}
+
+static int at91sam9n12ek_mem_init(void)
+{
+	at91_add_device_sdram(128 * 1024 * 1024);
+
+	return 0;
+}
+mem_initcall(at91sam9n12ek_mem_init);
+
+static int at91sam9n12ek_devices_init(void)
+{
+	ek_add_device_spi();
+	ek_add_device_nand();
+	ek_add_device_mci();
+	ek_add_led();
+	at91_add_device_udc(&ek_udc_data);
+	ek_add_device_i2c();
+	ek_add_device_ks8851();
+	ek_add_device_buttons();
+
+	armlinux_set_bootparams((void *)(AT91_CHIPSELECT_1 + 0x100));
+	armlinux_set_architecture(CONFIG_MACH_AT91SAM9N12EK);
+
+	devfs_add_partition("nand0", 0x00000, SZ_256K, DEVFS_PARTITION_FIXED, "at91bootstrap_raw");
+	dev_add_bb_dev("at91bootstrap_raw", "at91bootstrap");
+	devfs_add_partition("nand0", SZ_256K, SZ_256K + SZ_128K, DEVFS_PARTITION_FIXED, "self_raw");
+	dev_add_bb_dev("self_raw", "self0");
+	devfs_add_partition("nand0", SZ_512K + SZ_128K, SZ_128K, DEVFS_PARTITION_FIXED, "env_raw");
+	dev_add_bb_dev("env_raw", "env0");
+	devfs_add_partition("nand0", SZ_512K + SZ_256K, SZ_128K, DEVFS_PARTITION_FIXED, "env_raw1");
+	dev_add_bb_dev("env_raw1", "env1");
+
+	return 0;
+}
+device_initcall(at91sam9n12ek_devices_init);
+
+static int at91sam9n12ek_console_init(void)
+{
+	at91_register_uart(0, 0);
+	return 0;
+}
+console_initcall(at91sam9n12ek_console_init);
diff --git a/arch/arm/configs/at91sam9n12ek_defconfig b/arch/arm/configs/at91sam9n12ek_defconfig
new file mode 100644
index 0000000..d46a9bd
--- /dev/null
+++ b/arch/arm/configs/at91sam9n12ek_defconfig
@@ -0,0 +1,87 @@
+CONFIG_ARCH_AT91SAM9N12=y
+CONFIG_BAREBOX_MAX_IMAGE_SIZE=0x40000
+CONFIG_AEABI=y
+# CONFIG_CMD_ARM_CPUINFO is not set
+CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y
+CONFIG_PBL_IMAGE=y
+CONFIG_MMU=y
+CONFIG_TEXT_BASE=0x26f00000
+CONFIG_BAREBOX_MAX_IMAGE_SIZE=0x40000
+CONFIG_EXPERIMENTAL=y
+CONFIG_MALLOC_TLSF=y
+CONFIG_PROMPT="9G20-EK:"
+CONFIG_LONGHELP=y
+CONFIG_GLOB=y
+CONFIG_PROMPT_HUSH_PS2="y"
+CONFIG_HUSH_FANCY_PROMPT=y
+CONFIG_CMDLINE_EDITING=y
+CONFIG_AUTO_COMPLETE=y
+CONFIG_CONSOLE_ACTIVATE_ALL=y
+CONFIG_DEFAULT_ENVIRONMENT_GENERIC=y
+CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/arm/boards/at91sam9n12ek/env"
+CONFIG_CMD_EDIT=y
+CONFIG_CMD_SLEEP=y
+CONFIG_CMD_SAVEENV=y
+CONFIG_CMD_EXPORT=y
+CONFIG_CMD_PRINTENV=y
+CONFIG_CMD_READLINE=y
+CONFIG_CMD_TFTP=y
+CONFIG_CMD_ECHO_E=y
+CONFIG_CMD_LOADB=y
+CONFIG_CMD_MEMINFO=y
+CONFIG_CMD_FLASH=y
+CONFIG_CMD_BOOTM_SHOW_TYPE=y
+CONFIG_CMD_BOOTM_INITRD=y
+CONFIG_CMD_BOOTM_OFTREE=y
+CONFIG_CMD_BOOTM_OFTREE_UIMAGE=y
+CONFIG_CMD_UIMAGE=y
+# CONFIG_CMD_BOOTU is not set
+CONFIG_CMD_RESET=y
+CONFIG_CMD_GO=y
+CONFIG_CMD_OFTREE=y
+CONFIG_CMD_MTEST=y
+CONFIG_CMD_MTEST_ALTERNATIVE=y
+CONFIG_CMD_TIMEOUT=y
+CONFIG_CMD_PARTITION=y
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_I2C=y
+CONFIG_CMD_SPI=y
+CONFIG_CMD_LED=y
+CONFIG_CMD_LED_TRIGGER=y
+CONFIG_CMD_MIITOOL=y
+CONFIG_NET=y
+CONFIG_NET_DHCP=y
+CONFIG_NET_NFS=y
+CONFIG_NET_PING=y
+CONFIG_NET_NETCONSOLE=y
+CONFIG_DRIVER_NET_KS8851_MLL=y
+CONFIG_DRIVER_SPI_ATMEL=y
+CONFIG_I2C=y
+CONFIG_I2C_GPIO=y
+CONFIG_MTD=y
+# CONFIG_MTD_OOB_DEVICE is not set
+CONFIG_MTD_M25P80=y
+CONFIG_NAND=y
+# CONFIG_NAND_ECC_SOFT is not set
+# CONFIG_NAND_ECC_HW_SYNDROME is not set
+# CONFIG_NAND_ECC_HW_NONE is not set
+CONFIG_NAND_ATMEL=y
+CONFIG_NAND_ATMEL_PMECC=y
+CONFIG_UBI=y
+CONFIG_USB_GADGET=y
+CONFIG_USB_GADGET_DFU=y
+CONFIG_USB_GADGET_SERIAL=y
+CONFIG_MCI=y
+CONFIG_MCI_STARTUP=y
+CONFIG_MCI_ATMEL=y
+CONFIG_LED=y
+CONFIG_LED_GPIO=y
+CONFIG_LED_TRIGGERS=y
+CONFIG_EEPROM_AT24=y
+CONFIG_KEYBOARD_GPIO=y
+CONFIG_KEYBOARD_QT1070=y
+CONFIG_FS_TFTP=y
+CONFIG_FS_FAT=y
+CONFIG_FS_FAT_WRITE=y
+CONFIG_FS_FAT_LFN=y
+CONFIG_ZLIB=y
diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index e7e1c84..1af5cc2 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -14,6 +14,7 @@ config BOARDINFO
 	default "Atmel at91sam9g10-ek" if MACH_AT91SAM9G10EK
 	default "Atmel at91sam9g20-ek" if MACH_AT91SAM9G20EK
 	default "Atmel at91sam9m10g45-ek" if MACH_AT91SAM9M10G45EK
+	default "Atmel at91sam9n12-ek" if MACH_AT91SAM9N12EK
 	default "Atmel at91sam9x5-ek" if MACH_AT91SAM9X5EK
 	default "Bucyrus MMC-CPU" if MACH_MMCCPU
 	default "Calao USB-A9260" if MACH_USB_A9260
@@ -342,6 +343,22 @@ endif
 
 # ----------------------------------------------------------
 
+if ARCH_AT91SAM9N12
+
+choice
+	prompt "AT91SAM9N12 Board Type"
+
+config MACH_AT91SAM9N12EK
+	bool "Atmel AT91SAM9N12 Evaluation Kit"
+	help
+	  Select this if you are using Atmel's AT91SAM9N12-EK Evaluation Kit.
+
+endchoice
+
+endif
+
+# ----------------------------------------------------------
+
 comment "AT91 Board Options"
 
 config MTD_AT91_DATAFLASH_CARD
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Fri Nov 23 11:01:34 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri, 23 Nov 2012 17:01:34 +0100
Subject: [PATCH 1/2] arm: at91: add at91sam9n12 support
In-Reply-To: <20121123155945.GW8327@game.jcrosoft.org>
References: <20121123155945.GW8327@game.jcrosoft.org>
Message-ID: <1353686495-31912-1-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/arm/mach-at91/Kconfig                         |    6 +
 arch/arm/mach-at91/Makefile                        |    1 +
 arch/arm/mach-at91/at91sam9n12.c                   |  233 ++++++++++++
 arch/arm/mach-at91/at91sam9n12_devices.c           |  374 ++++++++++++++++++++
 arch/arm/mach-at91/clock.c                         |   15 +-
 arch/arm/mach-at91/gpio.c                          |    2 +-
 arch/arm/mach-at91/include/mach/at91sam9n12.h      |  166 +++++++++
 .../mach-at91/include/mach/at91sam9n12_matrix.h    |   98 +++++
 arch/arm/mach-at91/include/mach/board.h            |    1 +
 arch/arm/mach-at91/include/mach/cpu.h              |    7 +
 arch/arm/mach-at91/include/mach/hardware.h         |    2 +
 11 files changed, 899 insertions(+), 6 deletions(-)
 create mode 100644 arch/arm/mach-at91/at91sam9n12.c
 create mode 100644 arch/arm/mach-at91/at91sam9n12_devices.c
 create mode 100644 arch/arm/mach-at91/include/mach/at91sam9n12.h
 create mode 100644 arch/arm/mach-at91/include/mach/at91sam9n12_matrix.h

diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index 3a985f7..e7e1c84 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -92,6 +92,11 @@ config ARCH_AT91SAM9X5
 	select HAS_MACB
 	select AT91SAM9G45_RESET
 
+config ARCH_AT91SAM9N12
+	bool "AT91SAM9N12"
+	select CPU_ARM926T
+	select AT91SAM9G45_RESET
+
 endchoice
 
 config ARCH_BAREBOX_MAX_BARE_INIT_SIZE
@@ -103,6 +108,7 @@ config ARCH_BAREBOX_MAX_BARE_INIT_SIZE
 	default 0x3000 if ARCH_AT91SAM9G10
 	default 0xF000 if ARCH_AT91SAM9G45
 	default 0x6000 if ARCH_AT91SAM9X5
+	default 0x6000 if ARCH_AT91SAM9N12
 	default 0xffffffff
 
 config SUPPORT_CALAO_DAB_MMX
diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile
index 3ade725..7a1e506 100644
--- a/arch/arm/mach-at91/Makefile
+++ b/arch/arm/mach-at91/Makefile
@@ -18,3 +18,4 @@ obj-$(CONFIG_ARCH_AT91SAM9G10) += at91sam9261.o at91sam926x_time.o at91sam9261_d
 obj-$(CONFIG_ARCH_AT91SAM9G20) += at91sam9260.o at91sam926x_time.o at91sam9260_devices.o sam9_smc.o
 obj-$(CONFIG_ARCH_AT91SAM9G45) += at91sam9g45.o at91sam926x_time.o at91sam9g45_devices.o sam9_smc.o
 obj-$(CONFIG_ARCH_AT91SAM9X5)	+= at91sam9x5.o at91sam926x_time.o at91sam9x5_devices.o sam9_smc.o
+obj-$(CONFIG_ARCH_AT91SAM9N12)	+= at91sam9n12.o at91sam926x_time.o at91sam9n12_devices.o sam9_smc.o
diff --git a/arch/arm/mach-at91/at91sam9n12.c b/arch/arm/mach-at91/at91sam9n12.c
new file mode 100644
index 0000000..b74a72a
--- /dev/null
+++ b/arch/arm/mach-at91/at91sam9n12.c
@@ -0,0 +1,233 @@
+#include <common.h>
+#include <gpio.h>
+#include <init.h>
+#include <asm/hardware.h>
+#include <mach/at91_pmc.h>
+#include <mach/io.h>
+#include <mach/cpu.h>
+
+#include "generic.h"
+#include "clock.h"
+
+/* --------------------------------------------------------------------
+ *  Clocks
+ * -------------------------------------------------------------------- */
+
+/*
+ * The peripheral clocks.
+ */
+static struct clk pioAB_clk = {
+	.name		= "pioAB_clk",
+	.pmc_mask	= 1 << AT91SAM9N12_ID_PIOAB,
+	.type		= CLK_TYPE_PERIPHERAL,
+};
+static struct clk pioCD_clk = {
+	.name		= "pioCD_clk",
+	.pmc_mask	= 1 << AT91SAM9N12_ID_PIOCD,
+	.type		= CLK_TYPE_PERIPHERAL,
+};
+static struct clk usart0_clk = {
+	.name		= "usart0_clk",
+	.pmc_mask	= 1 << AT91SAM9N12_ID_USART0,
+	.type		= CLK_TYPE_PERIPHERAL,
+};
+static struct clk usart1_clk = {
+	.name		= "usart1_clk",
+	.pmc_mask	= 1 << AT91SAM9N12_ID_USART1,
+	.type		= CLK_TYPE_PERIPHERAL,
+};
+static struct clk usart2_clk = {
+	.name		= "usart2_clk",
+	.pmc_mask	= 1 << AT91SAM9N12_ID_USART2,
+	.type		= CLK_TYPE_PERIPHERAL,
+};
+static struct clk usart3_clk = {
+	.name		= "usart3_clk",
+	.pmc_mask	= 1 << AT91SAM9N12_ID_USART3,
+	.type		= CLK_TYPE_PERIPHERAL,
+};
+static struct clk twi0_clk = {
+	.name		= "twi0_clk",
+	.pmc_mask	= 1 << AT91SAM9N12_ID_TWI0,
+	.type		= CLK_TYPE_PERIPHERAL,
+};
+static struct clk twi1_clk = {
+	.name		= "twi1_clk",
+	.pmc_mask	= 1 << AT91SAM9N12_ID_TWI1,
+	.type		= CLK_TYPE_PERIPHERAL,
+};
+static struct clk mmc_clk = {
+	.name		= "mci_clk",
+	.pmc_mask	= 1 << AT91SAM9N12_ID_MCI,
+	.type		= CLK_TYPE_PERIPHERAL,
+};
+static struct clk spi0_clk = {
+	.name		= "spi0_clk",
+	.pmc_mask	= 1 << AT91SAM9N12_ID_SPI0,
+	.type		= CLK_TYPE_PERIPHERAL,
+};
+static struct clk spi1_clk = {
+	.name		= "spi1_clk",
+	.pmc_mask	= 1 << AT91SAM9N12_ID_SPI1,
+	.type		= CLK_TYPE_PERIPHERAL,
+};
+static struct clk uart0_clk = {
+	.name		= "uart0_clk",
+	.pmc_mask	= 1 << AT91SAM9N12_ID_UART0,
+	.type		= CLK_TYPE_PERIPHERAL,
+};
+static struct clk uart1_clk = {
+	.name		= "uart1_clk",
+	.pmc_mask	= 1 << AT91SAM9N12_ID_UART1,
+	.type		= CLK_TYPE_PERIPHERAL,
+};
+static struct clk tcb0_clk = {
+	.name		= "tcb0_clk",
+	.pmc_mask	= 1 << AT91SAM9N12_ID_TCB,
+	.type		= CLK_TYPE_PERIPHERAL,
+};
+static struct clk pwm_clk = {
+	.name		= "pwm_clk",
+	.pmc_mask	= 1 << AT91SAM9N12_ID_PWM,
+	.type		= CLK_TYPE_PERIPHERAL,
+};
+static struct clk adc_clk = {
+	.name		= "adc_clk",
+	.pmc_mask	= 1 << AT91SAM9N12_ID_ADC,
+	.type	= CLK_TYPE_PERIPHERAL,
+};
+static struct clk dma_clk = {
+	.name		= "dma_clk",
+	.pmc_mask	= 1 << AT91SAM9N12_ID_DMA,
+	.type	= CLK_TYPE_PERIPHERAL,
+};
+static struct clk uhpfs_clk = {
+	.name		= "uhpfs_clk",
+	.pmc_mask	= 1 << AT91SAM9N12_ID_UHPFS,
+	.type		= CLK_TYPE_PERIPHERAL,
+};
+static struct clk udc_clk = {
+	.name		= "udc_clk",
+	.pmc_mask	= 1 << AT91SAM9N12_ID_UDPFS,
+	.type		= CLK_TYPE_PERIPHERAL,
+};
+static struct clk lcdc_clk = {
+	.name		= "lcdc_clk",
+	.pmc_mask	= 1 << AT91SAM9N12_ID_LCDC,
+	.type		= CLK_TYPE_PERIPHERAL,
+};
+static struct clk ssc_clk = {
+	.name		= "ssc_clk",
+	.pmc_mask	= 1 << AT91SAM9N12_ID_SSC,
+	.type		= CLK_TYPE_PERIPHERAL,
+};
+
+static struct clk *periph_clocks[] __initdata = {
+	&pioAB_clk,
+	&pioCD_clk,
+	&usart0_clk,
+	&usart1_clk,
+	&usart2_clk,
+	&usart3_clk,
+	&twi0_clk,
+	&twi1_clk,
+	&mmc_clk,
+	&spi0_clk,
+	&spi1_clk,
+	&uart0_clk,
+	&uart1_clk,
+	&tcb0_clk,
+	&pwm_clk,
+	&adc_clk,
+	&dma_clk,
+	&lcdc_clk,
+	&uhpfs_clk,
+	&udc_clk,
+	&ssc_clk,
+};
+
+static struct clk_lookup periph_clocks_lookups[] = {
+	CLKDEV_CON_ID("ohci_clk", &uhpfs_clk),
+	CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi0", &spi0_clk),
+	CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi1", &spi1_clk),
+};
+
+static struct clk_lookup usart_clocks_lookups[] = {
+	CLKDEV_CON_DEV_ID("usart", "atmel_usart0", &mck),
+	CLKDEV_CON_DEV_ID("usart", "atmel_usart1", &usart0_clk),
+	CLKDEV_CON_DEV_ID("usart", "atmel_usart2", &usart1_clk),
+	CLKDEV_CON_DEV_ID("usart", "atmel_usart3", &usart2_clk),
+	CLKDEV_CON_DEV_ID("usart", "atmel_usart4", &usart3_clk),
+};
+
+/*
+ * The two programmable clocks.
+ * You must configure pin multiplexing to bring these signals out.
+ */
+static struct clk pck0 = {
+	.name		= "pck0",
+	.pmc_mask	= AT91_PMC_PCK0,
+	.type		= CLK_TYPE_PROGRAMMABLE,
+	.id		= 0,
+};
+static struct clk pck1 = {
+	.name		= "pck1",
+	.pmc_mask	= AT91_PMC_PCK1,
+	.type		= CLK_TYPE_PROGRAMMABLE,
+	.id		= 1,
+};
+
+static void __init at91sam9n12_register_clocks(void)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(periph_clocks); i++)
+		clk_register(periph_clocks[i]);
+
+	clk_register(&pck0);
+	clk_register(&pck1);
+
+	clkdev_add_table(periph_clocks_lookups,
+			 ARRAY_SIZE(periph_clocks_lookups));
+	clkdev_add_table(usart_clocks_lookups,
+			 ARRAY_SIZE(usart_clocks_lookups));
+
+}
+
+/* --------------------------------------------------------------------
+ *  GPIO
+ * -------------------------------------------------------------------- */
+
+static struct at91_gpio_bank at91sam9n12_gpio[] = {
+	{
+		.regbase	= IOMEM(AT91_BASE_PIOA),
+		.clock		= &pioAB_clk,
+	}, {
+		.regbase	= IOMEM(AT91_BASE_PIOB),
+		.clock		= &pioAB_clk,
+	}, {
+		.regbase	= IOMEM(AT91_BASE_PIOC),
+		.clock		= &pioCD_clk,
+	}, {
+		.regbase	= IOMEM(AT91_BASE_PIOD),
+		.clock		= &pioCD_clk,
+	}
+};
+
+/* --------------------------------------------------------------------
+ *  AT91SAM9N12 processor initialization
+ * -------------------------------------------------------------------- */
+
+static int at91sam9n12_initialize(void)
+{
+	/* Init clock subsystem */
+	at91_clock_init(AT91_MAIN_CLOCK);
+
+	/* Register the processor-specific clocks */
+	at91sam9n12_register_clocks();
+
+	/* Register GPIO subsystem */
+	at91_gpio_init(at91sam9n12_gpio, 4);
+	return 0;
+}
+core_initcall(at91sam9n12_initialize);
diff --git a/arch/arm/mach-at91/at91sam9n12_devices.c b/arch/arm/mach-at91/at91sam9n12_devices.c
new file mode 100644
index 0000000..33baf41
--- /dev/null
+++ b/arch/arm/mach-at91/at91sam9n12_devices.c
@@ -0,0 +1,374 @@
+/*
+ *  On-Chip devices setup code for the AT91SAM9x5 family
+ *
+ *  Copyright (C) 2010 Atmel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+#include <common.h>
+#include <init.h>
+#include <sizes.h>
+#include <asm/armlinux.h>
+#include <asm/hardware.h>
+#include <mach/board.h>
+#include <mach/at91_pmc.h>
+#include <mach/at91sam9n12_matrix.h>
+#include <mach/gpio.h>
+#include <mach/io.h>
+#include <mach/cpu.h>
+#include <i2c/i2c-gpio.h>
+
+#include "generic.h"
+
+void at91_add_device_sdram(u32 size)
+{
+	arm_add_mem_device("ram0", AT91_CHIPSELECT_1, size);
+	add_mem_device("sram0", AT91SAM9N12_SRAM_BASE,
+			AT91SAM9N12_SRAM_SIZE, IORESOURCE_MEM_WRITEABLE);
+}
+
+/* --------------------------------------------------------------------
+ *  USB Host (OHCI)
+ * -------------------------------------------------------------------- */
+
+#if defined(CONFIG_USB_OHCI)
+void __init at91_add_device_usbh_ohci(struct at91_usbh_data *data)
+{
+	int i;
+
+	if (!data)
+		return;
+
+	/* Enable VBus control for UHP ports */
+	for (i = 0; i < data->ports; i++) {
+		if (data->vbus_pin[i])
+			at91_set_gpio_output(data->vbus_pin[i], 0);
+	}
+
+	add_generic_device("at91_ohci", DEVICE_ID_DYNAMIC, NULL, AT91SAM9N12_OHCI_BASE,
+			SZ_1M, IORESOURCE_MEM, data);
+}
+#else
+void __init at91_add_device_usbh_ohci(struct at91_usbh_data *data) {}
+#endif
+
+/* --------------------------------------------------------------------
+ *  USB Device (Gadget)
+ * -------------------------------------------------------------------- */
+
+#ifdef CONFIG_USB_GADGET_DRIVER_AT91
+void __init at91_add_device_udc(struct at91_udc_data *data)
+{
+	if (data->vbus_pin > 0) {
+		at91_set_gpio_input(data->vbus_pin, 0);
+		at91_set_deglitch(data->vbus_pin, 1);
+	}
+
+	add_generic_device("at91_udc", DEVICE_ID_SINGLE, NULL, AT91SAM9N12_BASE_UDPFS,
+			SZ_16K,  IORESOURCE_MEM, data);
+}
+#else
+void __init at91_add_device_udc(struct at91_udc_data *data) {}
+#endif
+
+#if defined(CONFIG_MCI_ATMEL)
+/* Consider only one slot : slot 0 */
+void __init at91_add_device_mci(short mmc_id, struct atmel_mci_platform_data *data)
+{
+	if (!data)
+		return;
+
+	/* Must have at least one usable slot */
+	if (!data->bus_width)
+		return;
+
+	/* input/irq */
+	if (data->detect_pin) {
+		at91_set_gpio_input(data->detect_pin, 1);
+		at91_set_deglitch(data->detect_pin, 1);
+	}
+	if (data->wp_pin)
+		at91_set_gpio_input(data->wp_pin, 1);
+
+	/* CLK */
+	at91_set_A_periph(AT91_PIN_PA17, 0);
+
+	/* CMD */
+	at91_set_A_periph(AT91_PIN_PA16, 1);
+
+	/* DAT0, maybe DAT1..DAT3 */
+	at91_set_A_periph(AT91_PIN_PA15, 1);
+	if (data->bus_width == 4) {
+		at91_set_A_periph(AT91_PIN_PA18, 1);
+		at91_set_A_periph(AT91_PIN_PA19, 1);
+		at91_set_A_periph(AT91_PIN_PA20, 1);
+	}
+
+	add_generic_device("atmel_mci", DEVICE_ID_SINGLE, NULL, AT91SAM9N12_BASE_MCI, SZ_16K,
+			   IORESOURCE_MEM, data);
+}
+#else
+void __init at91_add_device_mci(short mmc_id, struct atmel_mci_platform_data *data) {}
+#endif
+
+/* --------------------------------------------------------------------
+ *  NAND / SmartMedia
+ * -------------------------------------------------------------------- */
+
+#if defined(CONFIG_NAND_ATMEL)
+static struct resource nand_resources[] = {
+	[0] = {
+		.start	= AT91_CHIPSELECT_3,
+		.end	= AT91_CHIPSELECT_3 + SZ_256M - 1,
+		.flags	= IORESOURCE_MEM,
+	},
+	[1] = {
+		.start	= AT91_BASE_SYS + AT91_PMECC,
+		.end	= AT91_BASE_SYS + AT91_PMECC + 0x600 - 1,
+		.flags	= IORESOURCE_MEM,
+	},
+	[2] = {
+		.start	= AT91_BASE_SYS + AT91_PMERRLOC,
+		.end	= AT91_BASE_SYS + AT91_PMERRLOC + 0x200 - 1,
+		.flags	= IORESOURCE_MEM,
+	},
+	[3] = {
+		.start	= AT91SAM9N12_ROM_BASE,
+		.end	= AT91SAM9N12_ROM_BASE + AT91SAM9N12_ROM_SIZE - 1,
+		.flags	= IORESOURCE_MEM,
+	},
+};
+
+void __init at91_add_device_nand(struct atmel_nand_data *data)
+{
+	unsigned long csa;
+
+	if (!data)
+		return;
+
+	data->pmecc_lookup_table_offset = 0x8000;
+
+	csa = at91_sys_read(AT91_MATRIX_EBICSA);
+
+	/* Assign CS3 to NAND/SmartMedia Interface */
+	csa |= AT91_MATRIX_EBI_CS3A_SMC_NANDFLASH;
+	/* Configure databus */
+	if (!data->bus_on_d0)
+		csa |= AT91_MATRIX_NFD0_ON_D16;
+	else
+		csa &= ~AT91_MATRIX_NFD0_ON_D16;
+	/* Configure IO drive */
+	csa |= AT91_MATRIX_EBI_HIGH_DRIVE;
+
+	at91_sys_write(AT91_MATRIX_EBICSA, csa);
+
+	/* enable pin */
+	if (data->enable_pin)
+		at91_set_gpio_output(data->enable_pin, 1);
+
+	/* ready/busy pin */
+	if (data->rdy_pin)
+		at91_set_gpio_input(data->rdy_pin, 1);
+
+	/* card detect pin */
+	if (data->det_pin)
+		at91_set_gpio_input(data->det_pin, 1);
+
+	/* configure NANDOE */
+	at91_set_A_periph(AT91_PIN_PD0, 1);
+	/* configure NANDWE */
+	at91_set_A_periph(AT91_PIN_PD1, 1);
+	/* configure ALE */
+	at91_set_A_periph(AT91_PIN_PD2, 1);
+	/* configure CLE */
+	at91_set_A_periph(AT91_PIN_PD3, 1);
+
+	/* configure multiplexed pins for D16~D31 */
+	if (!data->bus_on_d0) {
+		at91_set_A_periph(AT91_PIN_PD6, 1);
+		at91_set_A_periph(AT91_PIN_PD7, 1);
+		at91_set_A_periph(AT91_PIN_PD8, 1);
+		at91_set_A_periph(AT91_PIN_PD9, 1);
+		at91_set_A_periph(AT91_PIN_PD10, 1);
+		at91_set_A_periph(AT91_PIN_PD11, 1);
+		at91_set_A_periph(AT91_PIN_PD12, 1);
+		at91_set_A_periph(AT91_PIN_PD13, 1);
+
+		if (data->bus_width_16) {
+			at91_set_A_periph(AT91_PIN_PD14, 1);
+			at91_set_A_periph(AT91_PIN_PD15, 1);
+			at91_set_A_periph(AT91_PIN_PD16, 1);
+			at91_set_A_periph(AT91_PIN_PD17, 1);
+			at91_set_A_periph(AT91_PIN_PD18, 1);
+			at91_set_A_periph(AT91_PIN_PD19, 1);
+			at91_set_A_periph(AT91_PIN_PD20, 1);
+			at91_set_A_periph(AT91_PIN_PD21, 1);
+		}
+
+	}
+
+	add_generic_device_res("atmel_nand", DEVICE_ID_SINGLE, nand_resources,
+			       ARRAY_SIZE(nand_resources), data);
+}
+#else
+void __init at91_add_device_nand(struct atmel_nand_data *data) {}
+#endif
+
+#if defined(CONFIG_I2C_GPIO)
+static struct i2c_gpio_platform_data pdata_i2c0 = {
+	.sda_pin		= AT91_PIN_PA30,
+	.sda_is_open_drain	= 1,
+	.scl_pin		= AT91_PIN_PA31,
+	.scl_is_open_drain	= 1,
+	.udelay			= 5,		/* ~100 kHz */
+};
+
+void at91_add_device_i2c(short i2c_id, struct i2c_board_info *devices, int nr_devices)
+{
+	struct i2c_gpio_platform_data *pdata = &pdata_i2c0;
+
+	i2c_register_board_info(0, devices, nr_devices);
+
+	at91_set_GPIO_periph(pdata->sda_pin, 1);		/* TWD (SDA) */
+	at91_set_multi_drive(pdata->sda_pin, 1);
+
+	at91_set_GPIO_periph(pdata->scl_pin, 1);		/* TWCK (SCL) */
+	at91_set_multi_drive(pdata->scl_pin, 1);
+
+	add_generic_device_res("i2c-gpio", 0, NULL, 0, pdata);
+}
+#else
+void at91_add_device_i2c(short i2c_id, struct i2c_board_info *devices, int nr_devices) {}
+#endif
+
+/* --------------------------------------------------------------------
+ *  SPI
+ * -------------------------------------------------------------------- */
+
+#if defined(CONFIG_DRIVER_SPI_ATMEL)
+static unsigned spi0_standard_cs[4] = { AT91_PIN_PA14, AT91_PIN_PA7, AT91_PIN_PA1, AT91_PIN_PB3 };
+
+static unsigned spi1_standard_cs[4] = { AT91_PIN_PA8, AT91_PIN_PA0, AT91_PIN_PA31, AT91_PIN_PA30 };
+
+static struct at91_spi_platform_data spi_pdata[] = {
+	[0] = {
+		.chipselect = spi0_standard_cs,
+		.num_chipselect = ARRAY_SIZE(spi0_standard_cs),
+	},
+	[1] = {
+		.chipselect = spi1_standard_cs,
+		.num_chipselect = ARRAY_SIZE(spi1_standard_cs),
+	},
+};
+
+void at91_add_device_spi(int spi_id, struct at91_spi_platform_data *pdata)
+{
+	int i;
+	int cs_pin;
+	resource_size_t start = ~0;
+
+	BUG_ON(spi_id > 1);
+
+	if (!pdata)
+		pdata = &spi_pdata[spi_id];
+
+	for (i = 0; i < pdata->num_chipselect; i++) {
+		cs_pin = pdata->chipselect[i];
+
+		/* enable chip-select pin */
+		if (gpio_is_valid(cs_pin))
+			at91_set_gpio_output(cs_pin, 1);
+	}
+
+	/* Configure SPI bus(es) */
+	switch (spi_id) {
+	case 0:
+		start = AT91SAM9N12_BASE_SPI0;
+		at91_set_A_periph(AT91_PIN_PA11, 0);	/* SPI0_MISO */
+		at91_set_A_periph(AT91_PIN_PA12, 0);	/* SPI0_MOSI */
+		at91_set_A_periph(AT91_PIN_PA13, 0);	/* SPI0_SPCK */
+		break;
+	case 1:
+		start = AT91SAM9N12_BASE_SPI1;
+		at91_set_B_periph(AT91_PIN_PA21, 0);	/* SPI1_MISO */
+		at91_set_B_periph(AT91_PIN_PA22, 0);	/* SPI1_MOSI */
+		at91_set_B_periph(AT91_PIN_PA23, 0);	/* SPI1_SPCK */
+		break;
+	}
+
+	add_generic_device("atmel_spi", spi_id, NULL, start, SZ_16K,
+			   IORESOURCE_MEM, pdata);
+}
+#else
+void at91_add_device_spi(int spi_id, struct at91_spi_platform_data *pdata) {}
+#endif
+
+/* --------------------------------------------------------------------
+ *  UART
+ * -------------------------------------------------------------------- */
+
+#if defined(CONFIG_DRIVER_SERIAL_ATMEL)
+resource_size_t __init at91_configure_dbgu(void)
+{
+	at91_set_A_periph(AT91_PIN_PA9, 0);		/* DRXD */
+	at91_set_A_periph(AT91_PIN_PA10, 1);		/* DTXD */
+
+	return AT91_BASE_SYS + AT91_DBGU;
+}
+
+resource_size_t __init at91_configure_usart0(unsigned pins)
+{
+	at91_set_A_periph(AT91_PIN_PA0, 1);		/* TXD0 */
+	at91_set_A_periph(AT91_PIN_PA1, 0);		/* RXD0 */
+
+	if (pins & ATMEL_UART_RTS)
+		at91_set_A_periph(AT91_PIN_PA2, 0);	/* RTS0 */
+	if (pins & ATMEL_UART_CTS)
+		at91_set_A_periph(AT91_PIN_PA3, 0);	/* CTS0 */
+
+	return AT91SAM9N12_BASE_USART0;
+}
+
+resource_size_t __init at91_configure_usart1(unsigned pins)
+{
+	at91_set_A_periph(AT91_PIN_PA5, 1);		/* TXD1 */
+	at91_set_A_periph(AT91_PIN_PA6, 0);		/* RXD1 */
+
+	if (pins & ATMEL_UART_RTS)
+		at91_set_C_periph(AT91_PIN_PC27, 0);	/* RTS1 */
+	if (pins & ATMEL_UART_CTS)
+		at91_set_C_periph(AT91_PIN_PC28, 0);	/* CTS1 */
+
+	return AT91SAM9N12_BASE_USART1;
+}
+
+resource_size_t __init at91_configure_usart2(unsigned pins)
+{
+	at91_set_A_periph(AT91_PIN_PA7, 1);		/* TXD2 */
+	at91_set_A_periph(AT91_PIN_PA8, 0);		/* RXD2 */
+
+	if (pins & ATMEL_UART_RTS)
+		at91_set_B_periph(AT91_PIN_PB0, 0);	/* RTS2 */
+	if (pins & ATMEL_UART_CTS)
+		at91_set_B_periph(AT91_PIN_PB1, 0);	/* CTS2 */
+
+	return AT91SAM9N12_BASE_USART2;
+}
+
+resource_size_t __init at91_configure_usart3(unsigned pins)
+{
+	at91_set_B_periph(AT91_PIN_PC22, 1);		/* TXD3 */
+	at91_set_B_periph(AT91_PIN_PC23, 0);		/* RXD3 */
+
+	if (pins & ATMEL_UART_RTS)
+		at91_set_B_periph(AT91_PIN_PC24, 0);	/* RTS3 */
+	if (pins & ATMEL_UART_CTS)
+		at91_set_B_periph(AT91_PIN_PC25, 0);	/* CTS3 */
+
+	return AT91SAM9N12_BASE_USART3;
+}
+#endif
diff --git a/arch/arm/mach-at91/clock.c b/arch/arm/mach-at91/clock.c
index fd9ba46..e911270 100644
--- a/arch/arm/mach-at91/clock.c
+++ b/arch/arm/mach-at91/clock.c
@@ -46,7 +46,8 @@
 
 #define cpu_has_800M_plla()	(  cpu_is_at91sam9g20() \
 				|| cpu_is_at91sam9g45() \
-				|| cpu_is_at91sam9x5())
+				|| cpu_is_at91sam9x5() \
+				|| cpu_is_at91sam9n12())
 
 #define cpu_has_300M_plla()	(cpu_is_at91sam9g10())
 
@@ -58,7 +59,8 @@
 
 #define cpu_has_pllb()		(!(cpu_is_at91sam9rl() \
 				|| cpu_is_at91sam9g45() \
-				|| cpu_is_at91sam9x5()))
+				|| cpu_is_at91sam9x5() \
+				|| cpu_is_at91sam9n12()))
 
 #define cpu_has_upll()		(cpu_is_at91sam9g45() \
 				|| cpu_is_at91sam9x5())
@@ -72,12 +74,15 @@
 				|| cpu_is_at91sam9x5()))
 
 #define cpu_has_plladiv2()	(cpu_is_at91sam9g45() \
-				|| cpu_is_at91sam9x5())
+				|| cpu_is_at91sam9x5() \
+				|| cpu_is_at91sam9n12())
 
 #define cpu_has_mdiv3()		(cpu_is_at91sam9g45() \
-				|| cpu_is_at91sam9x5())
+				|| cpu_is_at91sam9x5() \
+				|| cpu_is_at91sam9n12())
 
-#define cpu_has_alt_prescaler()	(cpu_is_at91sam9x5())
+#define cpu_has_alt_prescaler()	(cpu_is_at91sam9x5() \
+				|| cpu_is_at91sam9n12())
 
 static LIST_HEAD(clocks);
 
diff --git a/arch/arm/mach-at91/gpio.c b/arch/arm/mach-at91/gpio.c
index c303326..c35f00e 100644
--- a/arch/arm/mach-at91/gpio.c
+++ b/arch/arm/mach-at91/gpio.c
@@ -364,7 +364,7 @@ int at91_gpio_init(struct at91_gpio_bank *data, int nr_banks)
 		clk_enable(data->clock);
 	}
 
-	cpu_has_pio3 = cpu_is_at91sam9x5();
+	cpu_has_pio3 = cpu_is_at91sam9x5() || cpu_is_at91sam9n12();
 
 	return 0;
 }
diff --git a/arch/arm/mach-at91/include/mach/at91sam9n12.h b/arch/arm/mach-at91/include/mach/at91sam9n12.h
new file mode 100644
index 0000000..dcbdb1b
--- /dev/null
+++ b/arch/arm/mach-at91/include/mach/at91sam9n12.h
@@ -0,0 +1,166 @@
+/*
+ * Chip-specific header file for the AT91SAM9N12 SoC
+ *
+ *  Copyright (C) 2011 Atmel Corporation
+ *
+ * Common definitions.
+ * Based on AT91SAM9N12 preliminary datasheet
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef __MACH_AT91SAM9N12_H_
+#define __MACH_AT91SAM9N12_H_
+
+/*
+ * Peripheral identifiers/interrupts.
+ */
+#define AT91_ID_FIQ		0	/* Advanced Interrupt Controller (FIQ) */
+#define AT91_ID_SYS		1	/* System Controller Interrupt */
+#define AT91SAM9N12_ID_PIOAB	2	/* Parallel I/O Controller A and B */
+#define AT91SAM9N12_ID_PIOCD	3	/* Parallel I/O Controller C and D */
+/* Reserved			4	*/
+#define AT91SAM9N12_ID_USART0	5	/* USART 0 */
+#define AT91SAM9N12_ID_USART1	6	/* USART 1 */
+#define AT91SAM9N12_ID_USART2	7	/* USART 2 */
+#define AT91SAM9N12_ID_USART3	8	/* USART 3 */
+#define AT91SAM9N12_ID_TWI0	9	/* Two-Wire Interface 0 */
+#define AT91SAM9N12_ID_TWI1	10	/* Two-Wire Interface 1 */
+/* Reserved			11	*/
+#define AT91SAM9N12_ID_MCI	12	/* High Speed Multimedia Card Interface 0 */
+#define AT91SAM9N12_ID_SPI0	13	/* Serial Peripheral Interface 0 */
+#define AT91SAM9N12_ID_SPI1	14	/* Serial Peripheral Interface 1 */
+#define AT91SAM9N12_ID_UART0	15	/* UART 0 */
+#define AT91SAM9N12_ID_UART1	16	/* UART 1 */
+#define AT91SAM9N12_ID_TCB	17	/* Timer Counter 0, 1, 2, 3, 4 and 5 */
+#define AT91SAM9N12_ID_PWM	18	/* Pulse Width Modulation Controller */
+#define AT91SAM9N12_ID_ADC	19	/* ADC Controller */
+#define AT91SAM9N12_ID_DMA	20	/* DMA Controller 0 */
+/* Reserved			21	*/
+#define AT91SAM9N12_ID_UHPFS	22	/* USB Host Full Speed */
+#define AT91SAM9N12_ID_UDPFS	23	/* USB Device Full Speed */
+/* Reserved			24	*/
+#define AT91SAM9N12_ID_LCDC	25	/* LCD Controller */
+/* Reserved			26	*/
+/* Reserved			27	*/
+#define AT91SAM9N12_ID_SSC	28	/* Synchronous Serial Controller */
+/* Reserved			29	*/
+#define AT91SAM9N12_ID_TRNG	30	/* True Random Number Generator */
+#define AT91SAM9N12_ID_IRQ0	31	/* Advanced Interrupt Controller */
+
+/*
+ * User Peripheral physical base addresses.
+ */
+#define AT91SAM9N12_BASE_SPI0		0xf0000000
+#define AT91SAM9N12_BASE_SPI1		0xf0004000
+#define AT91SAM9N12_BASE_MCI		0xf0008000
+#define AT91SAM9N12_BASE_SSC		0xf0010000
+#define AT91SAM9N12_BASE_TCB0		0xf8008000
+#define AT91SAM9N12_BASE_TC0		0xf8008000
+#define AT91SAM9N12_BASE_TC1		0xf8008040
+#define AT91SAM9N12_BASE_TC2		0xf8008080
+#define AT91SAM9N12_BASE_TCB1		0xf800c000
+#define AT91SAM9N12_BASE_TC3		0xf800c000
+#define AT91SAM9N12_BASE_TC4		0xf800c040
+#define AT91SAM9N12_BASE_TC5		0xf800c080
+#define AT91SAM9N12_BASE_TWI0		0xf8010000
+#define AT91SAM9N12_BASE_TWI1		0xf8014000
+#define AT91SAM9N12_BASE_USART0		0xf801c000
+#define AT91SAM9N12_BASE_USART1		0xf8020000
+#define AT91SAM9N12_BASE_USART2		0xf8024000
+#define AT91SAM9N12_BASE_USART3		0xf8028000
+#define AT91SAM9N12_BASE_PWMC		0xf8034000
+#define AT91SAM9N12_BASE_LCDC		0xf8038000
+#define AT91SAM9N12_BASE_UDPFS		0xf803c000
+#define AT91SAM9N12_BASE_UART0		0xf8040000
+#define AT91SAM9N12_BASE_UART1		0xf8044000
+#define AT91SAM9N12_BASE_TRNG		0xf8048000
+#define AT91SAM9N12_BASE_ADC		0xf804c000
+#define AT91_BASE_SYS			0xffffc000
+
+/*
+ * System Peripherals (offset from AT91_BASE_SYS)
+ */
+#define AT91_FUSE	(0xffffdc00 - AT91_BASE_SYS)
+#define AT91_MATRIX	(0xffffde00 - AT91_BASE_SYS)
+#define AT91_PMECC	(0xffffe000 - AT91_BASE_SYS)
+#define AT91_PMERRLOC	(0xffffe600 - AT91_BASE_SYS)
+#define AT91_DDRSDRC0	(0xffffe800 - AT91_BASE_SYS)
+#define AT91_SMC	(0xffffea00 - AT91_BASE_SYS)
+#define AT91_DMA	(0xffffec00 - AT91_BASE_SYS)
+#define AT91_AIC	(0xfffff000 - AT91_BASE_SYS)
+#define AT91_DBGU	(0xfffff200 - AT91_BASE_SYS)
+#define AT91_PMC	(0xfffffc00 - AT91_BASE_SYS)
+#define AT91_RSTC	(0xfffffe00 - AT91_BASE_SYS)
+#define AT91_SHDWC	(0xfffffe10 - AT91_BASE_SYS)
+#define AT91_PIT	(0xfffffe30 - AT91_BASE_SYS)
+#define AT91_WDT	(0xfffffe40 - AT91_BASE_SYS)
+#define AT91_GPBR	(0xfffffe60 - AT91_BASE_SYS)
+#define AT91_RTC	(0xfffffeb0 - AT91_BASE_SYS)
+
+#define AT91_BASE_PIOA	0xfffff400
+#define AT91_BASE_PIOB	0xfffff600
+#define AT91_BASE_PIOC	0xfffff800
+#define AT91_BASE_PIOD	0xfffffa00
+
+#define AT91_USART0	AT91SAM9X5_BASE_US0
+#define AT91_USART1	AT91SAM9X5_BASE_US1
+#define AT91_USART2	AT91SAM9X5_BASE_US2
+#define AT91_USART3	AT91SAM9X5_BASE_US3
+#define AT91_NB_USART	5
+
+
+/*
+ * Internal Memory.
+ */
+#define AT91SAM9N12_SRAM_BASE	0x00300000	/* Internal SRAM base address */
+#define AT91SAM9N12_SRAM_SIZE	SZ_32K		/* Internal SRAM size (32Kb) */
+
+#define AT91SAM9N12_ROM_BASE	0x00100000	/* Internal ROM base address */
+#define AT91SAM9N12_ROM_SIZE	SZ_1M		/* Internal ROM size (1Mb) */
+
+#define AT91SAM9N12_SMD_BASE	0x00400000	/* SMD Controller */
+#define AT91SAM9N12_OHCI_BASE	0x00500000	/* USB Host controller (OHCI) */
+
+#define CONFIG_DRAM_BASE	AT91_CHIPSELECT_1
+
+#define CONSISTENT_DMA_SIZE	(14 * SZ_1M)
+
+/*
+ * DMA0 peripheral identifiers
+ * for hardware handshaking interface
+ */
+#define AT_DMA_ID_MCI		0
+#define AT_DMA_ID_SPI0_TX	1
+#define AT_DMA_ID_SPI0_RX	2
+#define AT_DMA_ID_SPI1_TX	3
+#define AT_DMA_ID_SPI1_RX	4
+#define AT_DMA_ID_USART0_TX	5
+#define AT_DMA_ID_USART0_RX	6
+#define AT_DMA_ID_USART1_TX	7
+#define AT_DMA_ID_USART1_RX	8
+#define AT_DMA_ID_USART2_TX	9
+#define AT_DMA_ID_USART2_RX	10
+#define AT_DMA_ID_USART3_TX	11
+#define AT_DMA_ID_USART3_RX	12
+#define AT_DMA_ID_TWI0_TX	13
+#define AT_DMA_ID_TWI0_RX	14
+#define AT_DMA_ID_TWI1_TX	15
+#define AT_DMA_ID_TWI1_RX	16
+#define AT_DMA_ID_UART0_TX	17
+#define AT_DMA_ID_UART0_RX	18
+#define AT_DMA_ID_UART1_TX	19
+#define AT_DMA_ID_UART1_RX	20
+#define AT_DMA_ID_SSC_TX	21
+#define AT_DMA_ID_SSC_RX	22
+#define AT_DMA_ID_ADC_RX	23
+#define AT_DMA_ID_DBGU_TX	24
+#define AT_DMA_ID_DBGU_RX	25
+#define AT_DMA_ID_AES_TX	26
+#define AT_DMA_ID_AES_RX	27
+#define AT_DMA_ID_SHA_RX	28
+
+#endif
diff --git a/arch/arm/mach-at91/include/mach/at91sam9n12_matrix.h b/arch/arm/mach-at91/include/mach/at91sam9n12_matrix.h
new file mode 100644
index 0000000..0e42918
--- /dev/null
+++ b/arch/arm/mach-at91/include/mach/at91sam9n12_matrix.h
@@ -0,0 +1,98 @@
+/*
+ * Matrix-Centric header file for the AT91SAM9N12 SoC
+ *
+ *  Copyright (C) 2011 Atmel Corporation
+ *
+ * Memory Controllers (MATRIX, EBI) - System peripherals registers.
+ * Based on AT91SAM9N12 preliminary datasheet.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef _AT91SAM9N12_MATRIX_H_
+#define _AT91SAM9N12_MATRIX_H_
+
+#define AT91_MATRIX_MCFG0	(AT91_MATRIX + 0x00)	/* Master Configuration Register 0 */
+#define AT91_MATRIX_MCFG1	(AT91_MATRIX + 0x04)	/* Master Configuration Register 1 */
+#define AT91_MATRIX_MCFG2	(AT91_MATRIX + 0x08)	/* Master Configuration Register 2 */
+#define AT91_MATRIX_MCFG3	(AT91_MATRIX + 0x0C)	/* Master Configuration Register 3 */
+#define AT91_MATRIX_MCFG4	(AT91_MATRIX + 0x10)	/* Master Configuration Register 4 */
+#define AT91_MATRIX_MCFG5	(AT91_MATRIX + 0x14)	/* Master Configuration Register 5 */
+#define		AT91_MATRIX_ULBT	(7 << 0)	/* Undefined Length Burst Type */
+#define			AT91_MATRIX_ULBT_INFINITE	(0 << 0)
+#define			AT91_MATRIX_ULBT_SINGLE		(1 << 0)
+#define			AT91_MATRIX_ULBT_FOUR		(2 << 0)
+#define			AT91_MATRIX_ULBT_EIGHT		(3 << 0)
+#define			AT91_MATRIX_ULBT_SIXTEEN	(4 << 0)
+#define			AT91_MATRIX_ULBT_THIRTYTWO	(5 << 0)
+#define			AT91_MATRIX_ULBT_SIXTYFOUR	(6 << 0)
+#define			AT91_MATRIX_ULBT_128		(7 << 0)
+
+#define AT91_MATRIX_SCFG0	(AT91_MATRIX + 0x40)	/* Slave Configuration Register 0 */
+#define AT91_MATRIX_SCFG1	(AT91_MATRIX + 0x44)	/* Slave Configuration Register 1 */
+#define AT91_MATRIX_SCFG2	(AT91_MATRIX + 0x48)	/* Slave Configuration Register 2 */
+#define AT91_MATRIX_SCFG3	(AT91_MATRIX + 0x4C)	/* Slave Configuration Register 3 */
+#define AT91_MATRIX_SCFG4	(AT91_MATRIX + 0x50)	/* Slave Configuration Register 4 */
+#define		AT91_MATRIX_SLOT_CYCLE		(0x1ff << 0)	/* Maximum Number of Allowed Cycles for a Burst */
+#define		AT91_MATRIX_DEFMSTR_TYPE	(3 << 16)	/* Default Master Type */
+#define			AT91_MATRIX_DEFMSTR_TYPE_NONE	(0 << 16)
+#define			AT91_MATRIX_DEFMSTR_TYPE_LAST	(1 << 16)
+#define			AT91_MATRIX_DEFMSTR_TYPE_FIXED	(2 << 16)
+#define		AT91_MATRIX_FIXED_DEFMSTR	(0xf << 18)	/* Fixed Index of Default Master */
+
+#define AT91_MATRIX_PRAS0	(AT91_MATRIX + 0x80)	/* Priority Register A for Slave 0 */
+#define AT91_MATRIX_PRAS1	(AT91_MATRIX + 0x88)	/* Priority Register A for Slave 1 */
+#define AT91_MATRIX_PRAS2	(AT91_MATRIX + 0x90)	/* Priority Register A for Slave 2 */
+#define AT91_MATRIX_PRAS3	(AT91_MATRIX + 0x98)	/* Priority Register A for Slave 3 */
+#define AT91_MATRIX_PRAS4	(AT91_MATRIX + 0xA0)	/* Priority Register A for Slave 4 */
+#define		AT91_MATRIX_M0PR		(3 << 0)	/* Master 0 Priority */
+#define		AT91_MATRIX_M1PR		(3 << 4)	/* Master 1 Priority */
+#define		AT91_MATRIX_M2PR		(3 << 8)	/* Master 2 Priority */
+#define		AT91_MATRIX_M3PR		(3 << 12)	/* Master 3 Priority */
+#define		AT91_MATRIX_M4PR		(3 << 16)	/* Master 4 Priority */
+#define		AT91_MATRIX_M5PR		(3 << 20)	/* Master 5 Priority */
+
+#define AT91_MATRIX_MRCR	(AT91_MATRIX + 0x100)	/* Master Remap Control Register */
+#define		AT91_MATRIX_RCB0		(1 << 0)	/* Remap Command for AHB Master 0 (ARM926EJ-S Instruction Master) */
+#define		AT91_MATRIX_RCB1		(1 << 1)	/* Remap Command for AHB Master 1 (ARM926EJ-S Data Master) */
+#define		AT91_MATRIX_RCB2		(1 << 2)
+#define		AT91_MATRIX_RCB3		(1 << 3)
+#define		AT91_MATRIX_RCB4		(1 << 4)
+#define		AT91_MATRIX_RCB5		(1 << 5)
+
+#define AT91_MATRIX_EBICSA	(AT91_MATRIX + 0x118)	/* EBI Chip Select Assignment Register */
+#define		AT91_MATRIX_EBI_CS1A		(1 << 1)	/* Chip Select 1 Assignment */
+#define			AT91_MATRIX_EBI_CS1A_SMC		(0 << 1)
+#define			AT91_MATRIX_EBI_CS1A_SDRAMC		(1 << 1)
+#define		AT91_MATRIX_EBI_CS3A		(1 << 3)	/* Chip Select 3 Assignment */
+#define			AT91_MATRIX_EBI_CS3A_SMC		(0 << 3)
+#define			AT91_MATRIX_EBI_CS3A_SMC_NANDFLASH	(1 << 3)
+#define		AT91_MATRIX_EBI_DBPUC		(1 << 8)	/* Data Bus Pull-up Configuration */
+#define			AT91_MATRIX_EBI_DBPU_ON			(0 << 8)
+#define			AT91_MATRIX_EBI_DBPU_OFF		(1 << 8)
+#define		AT91_MATRIX_EBI_DBPDC		(1 << 9)	/* Data Bus Pull-up Configuration */
+#define			AT91_MATRIX_EBI_DBPD_ON			(0 << 9)
+#define			AT91_MATRIX_EBI_DBPD_OFF		(1 << 9)
+#define		AT91_MATRIX_EBI_DRIVE		(1 << 17)	/* EBI I/O Drive Configuration */
+#define			AT91_MATRIX_EBI_LOW_DRIVE		(0 << 17)
+#define			AT91_MATRIX_EBI_HIGH_DRIVE		(1 << 17)
+#define		AT91_MATRIX_NFD0_SELECT		(1 << 24)	/* NAND Flash Data Bus Selection */
+#define			AT91_MATRIX_NFD0_ON_D0			(0 << 24)
+#define			AT91_MATRIX_NFD0_ON_D16			(1 << 24)
+
+#define AT91_MATRIX_WPMR	(AT91_MATRIX + 0x1E4)	/* Write Protect Mode Register */
+#define		AT91_MATRIX_WPMR_WPEN		(1 << 0)	/* Write Protect ENable */
+#define			AT91_MATRIX_WPMR_WP_WPDIS		(0 << 0)
+#define			AT91_MATRIX_WPMR_WP_WPEN		(1 << 0)
+#define		AT91_MATRIX_WPMR_WPKEY		(0xFFFFFF << 8)	/* Write Protect KEY */
+
+#define AT91_MATRIX_WPSR	(AT91_MATRIX + 0x1E8)	/* Write Protect Status Register */
+#define		AT91_MATRIX_WPSR_WPVS		(1 << 0)	/* Write Protect Violation Status */
+#define			AT91_MATRIX_WPSR_NO_WPV		(0 << 0)
+#define			AT91_MATRIX_WPSR_WPV		(1 << 0)
+#define		AT91_MATRIX_WPSR_WPVSRC		(0xFFFF << 8)	/* Write Protect Violation Source */
+
+#endif
diff --git a/arch/arm/mach-at91/include/mach/board.h b/arch/arm/mach-at91/include/mach/board.h
index dcea9f3..98c69f9 100644
--- a/arch/arm/mach-at91/include/mach/board.h
+++ b/arch/arm/mach-at91/include/mach/board.h
@@ -54,6 +54,7 @@ struct atmel_nand_data {
 	u8		bus_width_16;	/* buswidth is 16 bit */
 	u8		ecc_mode;	/* NAND_ECC_* */
 	u8		on_flash_bbt;	/* Use flash based bbt */
+	u8		bus_on_d0;
 
 	u8		pmecc_corr_cap;
 	u16		pmecc_sector_size;
diff --git a/arch/arm/mach-at91/include/mach/cpu.h b/arch/arm/mach-at91/include/mach/cpu.h
index 0700f21..90b9f8a 100644
--- a/arch/arm/mach-at91/include/mach/cpu.h
+++ b/arch/arm/mach-at91/include/mach/cpu.h
@@ -28,6 +28,7 @@
 #define ARCH_ID_AT91SAM9G45MRL	0x819b05a2	/* aka 9G45-ES2 & non ES lots */
 #define ARCH_ID_AT91SAM9G45ES	0x819b05a1	/* 9G45-ES (Engineering Sample) */
 #define ARCH_ID_AT91SAM9X5	0x819a05a0
+#define ARCH_ID_AT91SAM9N12	0x819a07a0
 #define ARCH_ID_AT91CAP9	0x039A03A0
 
 #define ARCH_ID_AT91SAM9XE128	0x329973a0
@@ -171,6 +172,12 @@ static inline unsigned long at91cap9_rev_identify(void)
 #define cpu_is_at91sam9x25()	(0)
 #endif
 
+#ifdef CONFIG_ARCH_AT91SAM9N12
+#define cpu_is_at91sam9n12()	(at91_cpu_identify() == ARCH_ID_AT91SAM9N12)
+#else
+#define cpu_is_at91sam9n12()	(0)
+#endif
+
 #ifdef CONFIG_ARCH_AT91CAP9
 #define cpu_is_at91cap9()	(at91_cpu_identify() == ARCH_ID_AT91CAP9)
 #define cpu_is_at91cap9_revB()	(at91cap9_rev_identify() == ARCH_REVISION_CAP9_B)
diff --git a/arch/arm/mach-at91/include/mach/hardware.h b/arch/arm/mach-at91/include/mach/hardware.h
index 7af8803..f8ac791 100644
--- a/arch/arm/mach-at91/include/mach/hardware.h
+++ b/arch/arm/mach-at91/include/mach/hardware.h
@@ -26,6 +26,8 @@
 #include <mach/at91sam9rl.h>
 #elif defined(CONFIG_ARCH_AT91SAM9G45)
 #include <mach/at91sam9g45.h>
+#elif defined(CONFIG_ARCH_AT91SAM9N12)
+#include <mach/at91sam9n12.h>
 #elif defined(CONFIG_ARCH_AT91SAM9X5)
 #include <mach/at91sam9x5.h>
 #elif defined(CONFIG_ARCH_AT91CAP9)
-- 
1.7.10.4



From antonynpavlov at gmail.com  Fri Nov 23 16:10:57 2012
From: antonynpavlov at gmail.com (Antony Pavlov)
Date: Sat, 24 Nov 2012 01:10:57 +0400
Subject: [RFC 1/3] add swab (swap bytes) option to memory_display()
In-Reply-To: <1353705059-7792-1-git-send-email-antonynpavlov@gmail.com>
References: <1353705059-7792-1-git-send-email-antonynpavlov@gmail.com>
Message-ID: <1353705059-7792-2-git-send-email-antonynpavlov@gmail.com>

Signed-off-by: Antony Pavlov <antonynpavlov at gmail.com>
---
 commands/mem.c   |   17 +++++++++++++----
 commands/spi.c   |    4 ++--
 fs/tftp.c        |    2 +-
 include/common.h |    2 +-
 net/net.c        |    2 +-
 5 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/commands/mem.c b/commands/mem.c
index 6fbc7cc..a42b7ba 100644
--- a/commands/mem.c
+++ b/commands/mem.c
@@ -51,7 +51,7 @@ static char *DEVMEM = "/dev/mem";
  */
 #define DISP_LINE_LEN	16
 
-int memory_display(char *addr, loff_t offs, ulong nbytes, int size)
+int memory_display(char *addr, loff_t offs, ulong nbytes, int size, int swab)
 {
 	ulong linebytes, i;
 	u_char	*cp;
@@ -73,9 +73,17 @@ int memory_display(char *addr, loff_t offs, ulong nbytes, int size)
 
 		for (i = 0; i < linebytes; i += size) {
 			if (size == 4) {
-				count -= printf(" %08x", (*uip++ = *((uint *)addr)));
+				u32 res;
+				res = (*uip++ = *((uint *)addr));
+				if (swab)
+					res = __swab32(res);
+				count -= printf(" %08x", res);
 			} else if (size == 2) {
-				count -= printf(" %04x", (*usp++ = *((ushort *)addr)));
+				u16 res;
+				res = (*usp++ = *((ushort *)addr));
+				if (swab)
+					res = __swab16(res);
+				count -= printf(" %04x", res);
 			} else {
 				count -= printf(" %02x", (*ucp++ = *((u_char *)addr)));
 			}
@@ -195,7 +203,8 @@ static int do_mem_md(int argc, char *argv[])
 		if (!r)
 			goto out;
 
-		if ((ret = memory_display(rw_buf, start, r, mode >> O_RWSIZE_SHIFT)))
+		if ((ret = memory_display(rw_buf, start, r,
+				mode >> O_RWSIZE_SHIFT, 0)))
 			goto out;
 
 		start += r;
diff --git a/commands/spi.c b/commands/spi.c
index 899bf62..2f6b430 100644
--- a/commands/spi.c
+++ b/commands/spi.c
@@ -101,12 +101,12 @@ static int do_spi(int argc, char *argv[])
 		printf("\n");
 
 		printf("wrote %i bytes\n", count);
-		memory_display(tx_buf, 0, count, byte_per_word);
+		memory_display(tx_buf, 0, count, byte_per_word, 0);
 
 		printf("read %i bytes\n", read);
 	}
 
-	memory_display(rx_buf, 0, read, byte_per_word);
+	memory_display(rx_buf, 0, read, byte_per_word, 0);
 
 out:
 	free(rx_buf);
diff --git a/fs/tftp.c b/fs/tftp.c
index dff41e9..98cbb37 100644
--- a/fs/tftp.c
+++ b/fs/tftp.c
@@ -227,7 +227,7 @@ static void tftp_parse_oack(struct file_priv *priv, unsigned char *pkt, int len)
 
 	debug("got OACK\n");
 #ifdef DEBUG
-	memory_display(pkt, 0, len, 1);
+	memory_display(pkt, 0, len, 1, 0);
 #endif
 
 	s = pkt;
diff --git a/include/common.h b/include/common.h
index e30774a..6256879 100644
--- a/include/common.h
+++ b/include/common.h
@@ -226,7 +226,7 @@ int run_shell(void);
 #define PAGE_SIZE	4096
 #define PAGE_SHIFT	12
 
-int memory_display(char *addr, loff_t offs, ulong nbytes, int size);
+int memory_display(char *addr, loff_t offs, ulong nbytes, int size, int swab);
 
 extern const char version_string[];
 #ifdef CONFIG_BANNER
diff --git a/net/net.c b/net/net.c
index 3ac098f..639bc2d 100644
--- a/net/net.c
+++ b/net/net.c
@@ -511,7 +511,7 @@ static void net_bad_packet(unsigned char *pkt, int len)
 	 * We received a bad packet. for now just dump it.
 	 * We could add more sophisticated debugging here
 	 */
-	memory_display(pkt, 0, len, 1);
+	memory_display(pkt, 0, len, 1, 0);
 #endif
 }
 
-- 
1.7.10.4



From antonynpavlov at gmail.com  Fri Nov 23 16:10:56 2012
From: antonynpavlov at gmail.com (Antony Pavlov)
Date: Sat, 24 Nov 2012 01:10:56 +0400
Subject: [RFC 0/3] commands: md, mw: add '-x' option (swap bytes)
Message-ID: <1353705059-7792-1-git-send-email-antonynpavlov@gmail.com>

Most of my MIPS boards run barebox in big-endian mode, but
sometimes I need see state of little-endian registers
(e.g. registers of PCI-connected peripherals) and it is not
very hande to swap bytes manually.

This patch series add to memory commands (md and mw) ability
to swap bytes "on the fly".

[RFC 1/3] add swab (swap bytes) option to memory_display()
[RFC 2/3] commands: md: add '-x' option (swap bytes)
[RFC 3/3] commands: mw: add '-x' option (swap bytes)


From antonynpavlov at gmail.com  Fri Nov 23 16:10:58 2012
From: antonynpavlov at gmail.com (Antony Pavlov)
Date: Sat, 24 Nov 2012 01:10:58 +0400
Subject: [RFC 2/3] commands: md: add '-x' option (swap bytes)
In-Reply-To: <1353705059-7792-1-git-send-email-antonynpavlov@gmail.com>
References: <1353705059-7792-1-git-send-email-antonynpavlov@gmail.com>
Message-ID: <1353705059-7792-3-git-send-email-antonynpavlov@gmail.com>

Signed-off-by: Antony Pavlov <antonynpavlov at gmail.com>
---
 commands/mem.c |   24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/commands/mem.c b/commands/mem.c
index a42b7ba..9873e52 100644
--- a/commands/mem.c
+++ b/commands/mem.c
@@ -136,7 +136,7 @@ static int open_and_lseek(const char *filename, int mode, loff_t pos)
 }
 
 static int mem_parse_options(int argc, char *argv[], char *optstr, int *mode,
-		char **sourcefile, char **destfile)
+		char **sourcefile, char **destfile, int *swab)
 {
 	int opt;
 
@@ -157,6 +157,9 @@ static int mem_parse_options(int argc, char *argv[], char *optstr, int *mode,
 		case 'd':
 			*destfile = optarg;
 			break;
+		case 'x':
+			*swab = 1;
+			break;
 		default:
 			return -1;
 		}
@@ -173,11 +176,13 @@ static int do_mem_md(int argc, char *argv[])
 	int fd;
 	char *filename = DEVMEM;
 	int mode = O_RWSIZE_4;
+	int swab = 0;
 
 	if (argc < 2)
 		return COMMAND_ERROR_USAGE;
 
-	if (mem_parse_options(argc, argv, "bwls:", &mode, &filename, NULL) < 0)
+	if (mem_parse_options(argc, argv, "bwls:x", &mode, &filename, NULL,
+			&swab) < 0)
 		return 1;
 
 	if (optind < argc) {
@@ -204,7 +209,7 @@ static int do_mem_md(int argc, char *argv[])
 			goto out;
 
 		if ((ret = memory_display(rw_buf, start, r,
-				mode >> O_RWSIZE_SHIFT, 0)))
+				mode >> O_RWSIZE_SHIFT, swab)))
 			goto out;
 
 		start += r;
@@ -225,6 +230,7 @@ static const __maybe_unused char cmd_md_help[] =
 "  -b          output in bytes\n"
 "  -w          output in halfwords (16bit)\n"
 "  -l          output in words (32bit)\n"
+"  -x          swap bytes at output\n"
 "\n"
 "Memory regions:\n"
 "Memory regions can be specified in two different forms: start+size\n"
@@ -250,7 +256,8 @@ static int do_mem_mw(int argc, char *argv[])
 	int mode = O_RWSIZE_4;
 	loff_t adr;
 
-	if (mem_parse_options(argc, argv, "bwld:", &mode, NULL, &filename) < 0)
+	if (mem_parse_options(argc, argv, "bwld:", &mode, NULL, &filename,
+			NULL) < 0)
 		return 1;
 
 	if (optind + 1 >= argc)
@@ -318,7 +325,8 @@ static int do_mem_cmp(int argc, char *argv[])
 	int     offset = 0;
 	struct  stat statbuf;
 
-	if (mem_parse_options(argc, argv, "bwls:d:", &mode, &sourcefile, &destfile) < 0)
+	if (mem_parse_options(argc, argv, "bwls:d:", &mode, &sourcefile,
+			&destfile, NULL) < 0)
 		return 1;
 
 	if (optind + 2 > argc)
@@ -425,7 +433,8 @@ static int do_mem_cp(int argc, char *argv[])
 	struct stat statbuf;
 	int ret = 0;
 
-	if (mem_parse_options(argc, argv, "bwls:d:", &mode, &sourcefile, &destfile) < 0)
+	if (mem_parse_options(argc, argv, "bwls:d:", &mode, &sourcefile,
+			&destfile, NULL) < 0)
 		return 1;
 
 	if (optind + 2 > argc)
@@ -530,7 +539,8 @@ static int do_memset(int argc, char *argv[])
 	int     ret = 1;
 	char	*file = DEVMEM;
 
-	if (mem_parse_options(argc, argv, "bwld:", &mode, NULL, &file) < 0)
+	if (mem_parse_options(argc, argv, "bwld:", &mode, NULL, &file,
+			NULL) < 0)
 		return 1;
 
 	if (optind + 3 > argc)
-- 
1.7.10.4



From antonynpavlov at gmail.com  Fri Nov 23 16:10:59 2012
From: antonynpavlov at gmail.com (Antony Pavlov)
Date: Sat, 24 Nov 2012 01:10:59 +0400
Subject: [RFC 3/3] commands: mw: add '-x' option (swap bytes)
In-Reply-To: <1353705059-7792-1-git-send-email-antonynpavlov@gmail.com>
References: <1353705059-7792-1-git-send-email-antonynpavlov@gmail.com>
Message-ID: <1353705059-7792-4-git-send-email-antonynpavlov@gmail.com>

Signed-off-by: Antony Pavlov <antonynpavlov at gmail.com>
---
 commands/mem.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/commands/mem.c b/commands/mem.c
index 9873e52..51aa04d 100644
--- a/commands/mem.c
+++ b/commands/mem.c
@@ -255,9 +255,10 @@ static int do_mem_mw(int argc, char *argv[])
 	char *filename = DEVMEM;
 	int mode = O_RWSIZE_4;
 	loff_t adr;
+	int swab = 0;
 
-	if (mem_parse_options(argc, argv, "bwld:", &mode, NULL, &filename,
-			NULL) < 0)
+	if (mem_parse_options(argc, argv, "bwld:x", &mode, NULL, &filename,
+			&swab) < 0)
 		return 1;
 
 	if (optind + 1 >= argc)
@@ -280,10 +281,14 @@ static int do_mem_mw(int argc, char *argv[])
 			break;
 		case O_RWSIZE_2:
 			val16 = simple_strtoul(argv[optind], NULL, 0);
+			if (swab)
+				val16 = __swab16(val16);
 			ret = write(fd, &val16, 2);
 			break;
 		case O_RWSIZE_4:
 			val32 = simple_strtoul(argv[optind], NULL, 0);
+			if (swab)
+				val32 = __swab32(val32);
 			ret = write(fd, &val32, 4);
 			break;
 		}
-- 
1.7.10.4



From vicencb at gmail.com  Fri Nov 23 22:24:23 2012
From: vicencb at gmail.com (Vicente Bergas)
Date: Sat, 24 Nov 2012 04:24:23 +0100
Subject: [PATCH 1/2] uimage: fix misunderstanding in common/uimage.c
In-Reply-To: <1353727464-15175-1-git-send-email-vicencb@gmail.com>
References: <1353727464-15175-1-git-send-email-vicencb@gmail.com>
Message-ID: <1353727464-15175-2-git-send-email-vicencb@gmail.com>

The option of reading the file at once was discarded because
the option of increasing the buffer size provided almost the
same benefit.

Signed-off-by: Vicente Bergas <vicencb at gmail.com>
---
 common/uimage.c | 24 ------------------------
 1 file changed, 24 deletions(-)

diff --git a/common/uimage.c b/common/uimage.c
index 3f5a3d5..8bcbfdd 100644
--- a/common/uimage.c
+++ b/common/uimage.c
@@ -28,8 +28,6 @@
 #include <rtc.h>
 #include <filetype.h>
 #include <memory.h>
-#include <linux/stat.h>
-#include <sizes.h>
 
 #ifdef CONFIG_UIMAGE_MULTI
 static inline int uimage_is_multi_image(struct uimage_handle *handle)
@@ -384,33 +382,11 @@ struct resource *file_to_sdram(const char *filename, unsigned long adr)
 	size_t ofs = 0;
 	size_t now;
 	int fd;
-	struct stat s;
 
 	fd = open(filename, O_RDONLY);
 	if (fd < 0)
 		return NULL;
 
-	/* TODO: use fstat(fd, &s) when implemented and avoid reopening file */
-	if (stat(filename, &s) == 0 && s.st_size <= SZ_1G) {
-		/*
-		 * As the file size is known we can read it at once and improve
-		 * transfer speed.
-		 */
-		size = s.st_size;
-		res = request_sdram_region("image", adr, size);
-		if (!res) {
-			printf("unable to request SDRAM 0x%08lx-0x%08lx\n",
-				adr, adr + size - 1);
-			goto out;
-		}
-
-		now = read_full(fd, (void *)(res->start), size);
-		if (now < size) {
-			release_sdram_region(res);
-			res = NULL;
-		}
-		goto out;
-	}
 	while (1) {
 		res = request_sdram_region("image", adr, size);
 		if (!res) {
-- 
1.8.0



From vicencb at gmail.com  Fri Nov 23 22:24:24 2012
From: vicencb at gmail.com (Vicente Bergas)
Date: Sat, 24 Nov 2012 04:24:24 +0100
Subject: [PATCH 2/2] archosg9: improve configuration
In-Reply-To: <1353727464-15175-1-git-send-email-vicencb@gmail.com>
References: <1353727464-15175-1-git-send-email-vicencb@gmail.com>
Message-ID: <1353727464-15175-3-git-send-email-vicencb@gmail.com>


Signed-off-by: Vicente Bergas <vicencb at gmail.com>
---
 arch/arm/boards/archosg9/env/config       | 4 +++-
 arch/arm/boards/archosg9/env/init/usbboot | 9 +++++----
 arch/arm/configs/archosg9_defconfig       | 2 +-
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/arch/arm/boards/archosg9/env/config b/arch/arm/boards/archosg9/env/config
index 38fc51c..8f3edb0 100644
--- a/arch/arm/boards/archosg9/env/config
+++ b/arch/arm/boards/archosg9/env/config
@@ -1 +1,3 @@
-global.linux.bootargs.base="earlyprintk=serial console=ttyO1,1000000n8 keep_bootcon pm_disable initcall_debug ignore_loglevel no_console_suspend=1 root=/dev/ram0 init=/linuxrc"
+global.bootm.image="${TARGET_ROOT}/boot/zImage"
+global.bootm.initrd="${TARGET_ROOT}/boot/initrd"
+global.linux.bootargs.base="console=ttyO0,115200n8 root=/dev/ram0"
diff --git a/arch/arm/boards/archosg9/env/init/usbboot b/arch/arm/boards/archosg9/env/init/usbboot
index 25536e2..83dd19a 100644
--- a/arch/arm/boards/archosg9/env/init/usbboot
+++ b/arch/arm/boards/archosg9/env/init/usbboot
@@ -1,5 +1,6 @@
-mkdir /usb
-mount -t omap4_usbbootfs omap4_usbboot /usb
+TARGET_ROOT="/mnt/usb"
+mkdir ${TARGET_ROOT}
+mount -t omap4_usbbootfs omap4_usbboot ${TARGET_ROOT}
 . /env/config
-. /usb/boot/config
-bootm -r /usb/boot/initrd /usb/boot/zImage
+. ${TARGET_ROOT}/boot/config
+bootm
diff --git a/arch/arm/configs/archosg9_defconfig b/arch/arm/configs/archosg9_defconfig
index e598258..2a20dd7 100644
--- a/arch/arm/configs/archosg9_defconfig
+++ b/arch/arm/configs/archosg9_defconfig
@@ -55,7 +55,7 @@ CONFIG_CMD_I2C=y
 CONFIG_DRIVER_SERIAL_OMAP4_USBBOOT=y
 CONFIG_DRIVER_SERIAL_NS16550=y
 CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS=y
-CONFIG_BAUDRATE=1000000
+CONFIG_BAUDRATE=115200
 # CONFIG_SPI is not set
 CONFIG_I2C=y
 CONFIG_I2C_OMAP=y
-- 
1.8.0



From vicencb at gmail.com  Fri Nov 23 22:24:22 2012
From: vicencb at gmail.com (Vicente Bergas)
Date: Sat, 24 Nov 2012 04:24:22 +0100
Subject: [PATCH 0/2] Some corrections on archosG9
Message-ID: <1353727464-15175-1-git-send-email-vicencb@gmail.com>

In the patch series for archosG9 there were an attempt to improve file
transfers by reading files at once, but finally this solution was discarded.
Today I've checked the repository and found this solution there, perhaps this
is a misunderstanding and it's corrected here.
Sorry for not checking before.

The other change is just the inverse: a submitted patch that was not applied.

Vicente Bergas (2):
  uimage: fix misunderstanding in common/uimage.c
  archosg9: improve configuration

 arch/arm/boards/archosg9/env/config       |  4 +++-
 arch/arm/boards/archosg9/env/init/usbboot |  9 +++++----
 arch/arm/configs/archosg9_defconfig       |  2 +-
 common/uimage.c                           | 24 ------------------------
 4 files changed, 9 insertions(+), 30 deletions(-)

-- 
1.8.0



From zzs213 at 126.com  Fri Nov 23 22:42:42 2012
From: zzs213 at 126.com (=?utf-8?B?5byg5b+g5bGx?=)
Date: Sat, 24 Nov 2012 11:42:42 +0800
Subject: [PATCH 4/4] Revert "mtd: atmel_nand: optimize read/write buffer
 functions"
In-Reply-To: <1353686104-31295-4-git-send-email-plagnioj@jcrosoft.com>
References: <20121123155224.GV8327@game.jcrosoft.org>
 <1353686104-31295-1-git-send-email-plagnioj@jcrosoft.com>
 <1353686104-31295-4-git-send-email-plagnioj@jcrosoft.com>
Message-ID: <20121124034241.GA19824@greatfirst.com>

In message <1353686104-31295-4-git-send-email-plagnioj at jcrosoft.com> Jean-Christophe PLAGNIOL-VILLARD wrote:
> As in the kernel we revert as this was supposed to work but does not yet
> this may need more work on the smc to be able to use it
> So for now revert it
>
> This reverts commit 809f0f6327241504b5071622a8d573255f91a875.
>
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
> ---
>  drivers/mtd/nand/atmel_nand.c |   33 +++++++++++++++++++++++++--------
>  1 file changed, 25 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
> index 0477178..69e8171 100644
> --- a/drivers/mtd/nand/atmel_nand.c
> +++ b/drivers/mtd/nand/atmel_nand.c
> @@ -159,16 +159,30 @@ static int atmel_nand_device_ready(struct mtd_info *mtd)
>   */
>  static void atmel_read_buf(struct mtd_info *mtd, u8 *buf, int len)
>  {
> -	struct nand_chip *chip = mtd->priv;
> +	struct nand_chip	*nand_chip = mtd->priv;
>
> -	memcpy_fromio(buf, chip->IO_ADDR_R, len);
> +	readsb(nand_chip->IO_ADDR_R, buf, len);
> +}
> +
> +static void atmel_read_buf16(struct mtd_info *mtd, u8 *buf, int len)
> +{
> +	struct nand_chip	*nand_chip = mtd->priv;
> +
> +	readsw(nand_chip->IO_ADDR_R, buf, len / 2);
>  }
>
>  static void atmel_write_buf(struct mtd_info *mtd, const u8 *buf, int len)
>  {
> -	struct nand_chip *chip = mtd->priv;
> +	struct nand_chip	*nand_chip = mtd->priv;
>
> -	memcpy_toio(chip->IO_ADDR_W, buf, len);
> +	writesb(nand_chip->IO_ADDR_W, buf, len);
> +}
> +
> +static void atmel_write_buf16(struct mtd_info *mtd, const u8 *buf, int len)
> +{
> +	struct nand_chip	*nand_chip = mtd->priv;
> +
> +	writesw(nand_chip->IO_ADDR_W, buf, len / 2);
>  }
>
>  /*
> @@ -1112,11 +1126,14 @@ static int __init atmel_nand_probe(struct device_d *dev)
>
>  	nand_chip->chip_delay = 20;		/* 20us command delay time */
>
> -	if (host->board->bus_width_16)		/* 16-bit bus width */
> +	if (host->board->bus_width_16) {	/* 16-bit bus width */
>  		nand_chip->options |= NAND_BUSWIDTH_16;
> -
> -	nand_chip->read_buf = atmel_read_buf;
> -	nand_chip->write_buf = atmel_write_buf;
> +		nand_chip->read_buf = atmel_read_buf16;
> +		nand_chip->write_buf = atmel_write_buf16;
> +	} else {
> +		nand_chip->read_buf = atmel_read_buf;
> +		nand_chip->write_buf = atmel_write_buf;
> +	}
>
>  	atmel_nand_enable(host);
>
> --
> 1.7.10.4
>

This patch resolves my problem

-- 
Best Regards,
zzs




From plagnioj at jcrosoft.com  Sat Nov 24 03:45:07 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Sat, 24 Nov 2012 09:45:07 +0100
Subject: [PATCH 1/2] uimage: fix misunderstanding in common/uimage.c
In-Reply-To: <1353727464-15175-2-git-send-email-vicencb@gmail.com>
References: <1353727464-15175-1-git-send-email-vicencb@gmail.com>
 <1353727464-15175-2-git-send-email-vicencb@gmail.com>
Message-ID: <20121124084507.GX8327@game.jcrosoft.org>

On 04:24 Sat 24 Nov     , Vicente Bergas wrote:
> The option of reading the file at once was discarded because
> the option of increasing the buffer size provided almost the
> same benefit.
nack

this is mandatory for tftp fs support

Best Regarfd,
J.
> 
> Signed-off-by: Vicente Bergas <vicencb at gmail.com>
> ---
>  common/uimage.c | 24 ------------------------
>  1 file changed, 24 deletions(-)
> 
> diff --git a/common/uimage.c b/common/uimage.c
> index 3f5a3d5..8bcbfdd 100644
> --- a/common/uimage.c
> +++ b/common/uimage.c
> @@ -28,8 +28,6 @@
>  #include <rtc.h>
>  #include <filetype.h>
>  #include <memory.h>
> -#include <linux/stat.h>
> -#include <sizes.h>
>  
>  #ifdef CONFIG_UIMAGE_MULTI
>  static inline int uimage_is_multi_image(struct uimage_handle *handle)
> @@ -384,33 +382,11 @@ struct resource *file_to_sdram(const char *filename, unsigned long adr)
>  	size_t ofs = 0;
>  	size_t now;
>  	int fd;
> -	struct stat s;
>  
>  	fd = open(filename, O_RDONLY);
>  	if (fd < 0)
>  		return NULL;
>  
> -	/* TODO: use fstat(fd, &s) when implemented and avoid reopening file */
> -	if (stat(filename, &s) == 0 && s.st_size <= SZ_1G) {
> -		/*
> -		 * As the file size is known we can read it at once and improve
> -		 * transfer speed.
> -		 */
> -		size = s.st_size;
> -		res = request_sdram_region("image", adr, size);
> -		if (!res) {
> -			printf("unable to request SDRAM 0x%08lx-0x%08lx\n",
> -				adr, adr + size - 1);
> -			goto out;
> -		}
> -
> -		now = read_full(fd, (void *)(res->start), size);
> -		if (now < size) {
> -			release_sdram_region(res);
> -			res = NULL;
> -		}
> -		goto out;
> -	}
>  	while (1) {
>  		res = request_sdram_region("image", adr, size);
>  		if (!res) {
> -- 
> 1.8.0
> 
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox


From plagnioj at jcrosoft.com  Sat Nov 24 03:45:44 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Sat, 24 Nov 2012 09:45:44 +0100
Subject: [PATCH 4/4] Revert "mtd: atmel_nand: optimize read/write
 buffer functions"
In-Reply-To: <20121124034241.GA19824@greatfirst.com>
References: <20121123155224.GV8327@game.jcrosoft.org>
 <1353686104-31295-1-git-send-email-plagnioj@jcrosoft.com>
 <1353686104-31295-4-git-send-email-plagnioj@jcrosoft.com>
 <20121124034241.GA19824@greatfirst.com>
Message-ID: <20121124084544.GY8327@game.jcrosoft.org>

On 11:42 Sat 24 Nov     , ??? wrote:
> In message <1353686104-31295-4-git-send-email-plagnioj at jcrosoft.com> Jean-Christophe PLAGNIOL-VILLARD wrote:
> > As in the kernel we revert as this was supposed to work but does not yet
> > this may need more work on the smc to be able to use it
> > So for now revert it
> >
> > This reverts commit 809f0f6327241504b5071622a8d573255f91a875.
> >
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
> > ---
> >  drivers/mtd/nand/atmel_nand.c |   33 +++++++++++++++++++++++++--------
> >  1 file changed, 25 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
> > index 0477178..69e8171 100644
> > --- a/drivers/mtd/nand/atmel_nand.c
> > +++ b/drivers/mtd/nand/atmel_nand.c
> > @@ -159,16 +159,30 @@ static int atmel_nand_device_ready(struct mtd_info *mtd)
> >   */
> >  static void atmel_read_buf(struct mtd_info *mtd, u8 *buf, int len)
> >  {
> > -	struct nand_chip *chip = mtd->priv;
> > +	struct nand_chip	*nand_chip = mtd->priv;
> >
> > -	memcpy_fromio(buf, chip->IO_ADDR_R, len);
> > +	readsb(nand_chip->IO_ADDR_R, buf, len);
> > +}
> > +
> > +static void atmel_read_buf16(struct mtd_info *mtd, u8 *buf, int len)
> > +{
> > +	struct nand_chip	*nand_chip = mtd->priv;
> > +
> > +	readsw(nand_chip->IO_ADDR_R, buf, len / 2);
> >  }
> >
> >  static void atmel_write_buf(struct mtd_info *mtd, const u8 *buf, int len)
> >  {
> > -	struct nand_chip *chip = mtd->priv;
> > +	struct nand_chip	*nand_chip = mtd->priv;
> >
> > -	memcpy_toio(chip->IO_ADDR_W, buf, len);
> > +	writesb(nand_chip->IO_ADDR_W, buf, len);
> > +}
> > +
> > +static void atmel_write_buf16(struct mtd_info *mtd, const u8 *buf, int len)
> > +{
> > +	struct nand_chip	*nand_chip = mtd->priv;
> > +
> > +	writesw(nand_chip->IO_ADDR_W, buf, len / 2);
> >  }
> >
> >  /*
> > @@ -1112,11 +1126,14 @@ static int __init atmel_nand_probe(struct device_d *dev)
> >
> >  	nand_chip->chip_delay = 20;		/* 20us command delay time */
> >
> > -	if (host->board->bus_width_16)		/* 16-bit bus width */
> > +	if (host->board->bus_width_16) {	/* 16-bit bus width */
> >  		nand_chip->options |= NAND_BUSWIDTH_16;
> > -
> > -	nand_chip->read_buf = atmel_read_buf;
> > -	nand_chip->write_buf = atmel_write_buf;
> > +		nand_chip->read_buf = atmel_read_buf16;
> > +		nand_chip->write_buf = atmel_write_buf16;
> > +	} else {
> > +		nand_chip->read_buf = atmel_read_buf;
> > +		nand_chip->write_buf = atmel_write_buf;
> > +	}
> >
> >  	atmel_nand_enable(host);
> >
> > --
> > 1.7.10.4
> >
> 
> This patch resolves my problem
I'm expecting to see your patches

Best Regards,
J.


From vicencb at gmail.com  Sat Nov 24 08:31:19 2012
From: vicencb at gmail.com (vj)
Date: Sat, 24 Nov 2012 14:31:19 +0100
Subject: [PATCH 1/2] uimage: fix misunderstanding in common/uimage.c
In-Reply-To: <20121124084507.GX8327@game.jcrosoft.org>
References: <1353727464-15175-1-git-send-email-vicencb@gmail.com>
 <1353727464-15175-2-git-send-email-vicencb@gmail.com>
 <20121124084507.GX8327@game.jcrosoft.org>
Message-ID: <CAAMcf8Bbrmez79fh5FwSgB3i46cO5WEU833QeTT+dvg5LN24hg@mail.gmail.com>

On Sat, Nov 24, 2012 at 9:45 AM, Jean-Christophe PLAGNIOL-VILLARD
<plagnioj at jcrosoft.com> wrote:
> On 04:24 Sat 24 Nov     , Vicente Bergas wrote:
>> The option of reading the file at once was discarded because
>> the option of increasing the buffer size provided almost the
>> same benefit.
> nack
>
> this is mandatory for tftp fs support
>
> Best Regarfd,
> J.

I'll try to explain it more clearly:
Firstly file_to_sdram read files a chunck of 2 pages at a time because
not all file systems (e.g. TFTP) didn't report the file size.
This provided a slow transfer speed, because the overhead of reading
each chunck is nonzero.
So I proposed a First patch to file_to_sdram which first checked for a
known/correct file size. If the file size was unknown/incorrect the
original method was still used (so TFTP worked), else the whole file
was read at once.
Sascha Hauer proposed an alternative to this First patch of only
increase the chunck size, which, after benchmarking, was set to 32
pages and was considered a reasonable size. This was the Second patch
to file_to_sdram.
The performance between the First and the Second patches was
comparable, so the First was discarded in favor of the Second, which
is much more simple.
But yesterday I checked and found both patches were applied in git master.
Hope this clarifies the issue.

Best Regards,
  Vicente.

>>
>> Signed-off-by: Vicente Bergas <vicencb at gmail.com>
>> ---
>>  common/uimage.c | 24 ------------------------
>>  1 file changed, 24 deletions(-)
>>
>> diff --git a/common/uimage.c b/common/uimage.c
>> index 3f5a3d5..8bcbfdd 100644
>> --- a/common/uimage.c
>> +++ b/common/uimage.c
>> @@ -28,8 +28,6 @@
>>  #include <rtc.h>
>>  #include <filetype.h>
>>  #include <memory.h>
>> -#include <linux/stat.h>
>> -#include <sizes.h>
>>
>>  #ifdef CONFIG_UIMAGE_MULTI
>>  static inline int uimage_is_multi_image(struct uimage_handle *handle)
>> @@ -384,33 +382,11 @@ struct resource *file_to_sdram(const char *filename, unsigned long adr)
>>       size_t ofs = 0;
>>       size_t now;
>>       int fd;
>> -     struct stat s;
>>
>>       fd = open(filename, O_RDONLY);
>>       if (fd < 0)
>>               return NULL;
>>
>> -     /* TODO: use fstat(fd, &s) when implemented and avoid reopening file */
>> -     if (stat(filename, &s) == 0 && s.st_size <= SZ_1G) {
>> -             /*
>> -              * As the file size is known we can read it at once and improve
>> -              * transfer speed.
>> -              */
>> -             size = s.st_size;
>> -             res = request_sdram_region("image", adr, size);
>> -             if (!res) {
>> -                     printf("unable to request SDRAM 0x%08lx-0x%08lx\n",
>> -                             adr, adr + size - 1);
>> -                     goto out;
>> -             }
>> -
>> -             now = read_full(fd, (void *)(res->start), size);
>> -             if (now < size) {
>> -                     release_sdram_region(res);
>> -                     res = NULL;
>> -             }
>> -             goto out;
>> -     }
>>       while (1) {
>>               res = request_sdram_region("image", adr, size);
>>               if (!res) {
>> --
>> 1.8.0
>>
>>
>> _______________________________________________
>> barebox mailing list
>> barebox at lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/barebox


From antonynpavlov at gmail.com  Sat Nov 24 10:28:46 2012
From: antonynpavlov at gmail.com (Antony Pavlov)
Date: Sat, 24 Nov 2012 19:28:46 +0400
Subject: [PATCH] xymodem.c: fix compiler warning
Message-ID: <1353770926-24496-1-git-send-email-antonynpavlov@gmail.com>

Fixes:
 lib/xymodem.c:558: warning: no previous prototype for ?do_load_serial_xmodem?
 lib/xymodem.c:572: warning: no previous prototype for ?do_load_serial_ymodem?
 lib/xymodem.c:586: warning: no previous prototype for ?do_load_serial_ymodemg?

Signed-off-by: Antony Pavlov <antonynpavlov at gmail.com>
---
 lib/xymodem.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/xymodem.c b/lib/xymodem.c
index 558f6e8..37202e6 100644
--- a/lib/xymodem.c
+++ b/lib/xymodem.c
@@ -31,7 +31,7 @@
 #include <fs.h>
 #include <kfifo.h>
 #include <linux/byteorder/generic.h>
-
+#include <xymodem.h>
 
 #define xy_dbg(fmt, args...)
 
-- 
1.7.10.4



From antonynpavlov at gmail.com  Sat Nov 24 10:45:01 2012
From: antonynpavlov at gmail.com (Antony Pavlov)
Date: Sat, 24 Nov 2012 19:45:01 +0400
Subject: [RFC 1/3] MIPS: add pre-bootloader (pbl) image support
In-Reply-To: <20121120075925.GC10369@pengutronix.de>
References: <1353154239-31574-1-git-send-email-antonynpavlov@gmail.com>
 <1353154239-31574-2-git-send-email-antonynpavlov@gmail.com>
 <20121120075925.GC10369@pengutronix.de>
Message-ID: <CAA4bVAFgwUzppRGvq1SAnSYqwOA3pXKmihdOZ=6tO=vAKuNaoQ@mail.gmail.com>

Sorry for delay.

On 20 November 2012 11:59, Sascha Hauer <s.hauer at pengutronix.de> wrote:
> On Sat, Nov 17, 2012 at 04:10:37PM +0400, Antony Pavlov wrote:
>> This patch is based on ARM pbl support and allows
>> creating a pre-bootloader binary for compressed image.
>>
>> Signed-off-by: Antony Pavlov <antonynpavlov at gmail.com>
>> ---
>>  arch/mips/Kconfig               |    2 +
>>  arch/mips/Makefile              |   18 +++++
>>  arch/mips/boot/Makefile         |    2 +
>>  arch/mips/boot/main_entry-pbl.c |   90 ++++++++++++++++++++++++
>>  arch/mips/boot/start-pbl.S      |  146 +++++++++++++++++++++++++++++++++++++++
>>  arch/mips/pbl/.gitignore        |    6 ++
>>  arch/mips/pbl/Makefile          |   40 +++++++++++
>>  arch/mips/pbl/piggy.gzip.S      |    6 ++
>>  arch/mips/pbl/piggy.lzo.S       |    6 ++
>>  arch/mips/pbl/zbarebox.lds.S    |   57 +++++++++++++++
>>  10 files changed, 373 insertions(+)
>>  create mode 100644 arch/mips/boot/main_entry-pbl.c
>>  create mode 100644 arch/mips/boot/start-pbl.S
>>  create mode 100644 arch/mips/pbl/.gitignore
>>  create mode 100644 arch/mips/pbl/Makefile
>>  create mode 100644 arch/mips/pbl/piggy.gzip.S
>>  create mode 100644 arch/mips/pbl/piggy.lzo.S
>>  create mode 100644 arch/mips/pbl/zbarebox.lds.S
>>
>> diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
>> index 7a1eeac..853d406 100644
>> --- a/arch/mips/Kconfig
>> +++ b/arch/mips/Kconfig
>> @@ -6,6 +6,8 @@ config MIPS
>>       select HAS_KALLSYMS
>>       select HAVE_CONFIGURABLE_MEMORY_LAYOUT
>>       select HAVE_CONFIGURABLE_TEXT_BASE
>> +     select HAVE_PBL_IMAGE
>> +     select HAVE_IMAGE_COMPRESSION
>>       default y
>>
>>  config SYS_SUPPORTS_BIG_ENDIAN
>> diff --git a/arch/mips/Makefile b/arch/mips/Makefile
>> index 5e40de7..819e7a3 100644
>> --- a/arch/mips/Makefile
>> +++ b/arch/mips/Makefile
>> @@ -58,6 +58,15 @@ CPPFLAGS += -fdata-sections -ffunction-sections
>>  LDFLAGS_barebox += -static --gc-sections
>>  endif
>>
>> +ifdef CONFIG_IMAGE_COMPRESSION
>> +KBUILD_BINARY := arch/mips/pbl/zbarebox.bin
>> +KBUILD_TARGET := zbarebox.bin
>> +$(KBUILD_BINARY): $(KBUILD_TARGET)
>> +else
>> +KBUILD_BINARY := barebox.bin
>> +KBUILD_TARGET := barebox.bin
>> +endif
>> +
>>  LDFLAGS_barebox += -nostdlib
>>
>>  machine-$(CONFIG_MACH_MIPS_MALTA)    := malta
>> @@ -106,3 +115,12 @@ CFLAGS += $(cflags-y)
>>  lds-$(CONFIG_GENERIC_LINKER_SCRIPT)   := arch/mips/lib/barebox.lds
>>
>>  CLEAN_FILES    += arch/mips/lib/barebox.lds barebox.map barebox.S
>> +
>> +pbl := arch/mips/pbl
>> +zbarebox.S zbarebox.bin zbarebox: barebox.bin
>> +     $(Q)$(MAKE) $(build)=$(pbl) $(pbl)/$@
>> +
>> +archclean:
>> +     $(MAKE) $(clean)=$(pbl)
>> +
>> +KBUILD_IMAGE ?= $(KBUILD_BINARY)
>> diff --git a/arch/mips/boot/Makefile b/arch/mips/boot/Makefile
>> index d6d28ce..6b093f1 100644
>> --- a/arch/mips/boot/Makefile
>> +++ b/arch/mips/boot/Makefile
>> @@ -1,2 +1,4 @@
>>  obj-y += start.o
>>  obj-y += main_entry.o
>> +
>> +pbl-y += start-pbl.o main_entry-pbl.o
>> diff --git a/arch/mips/boot/main_entry-pbl.c b/arch/mips/boot/main_entry-pbl.c
>> new file mode 100644
>> index 0000000..51b9176
>> --- /dev/null
>> +++ b/arch/mips/boot/main_entry-pbl.c
>> @@ -0,0 +1,90 @@
>> +/*
>> + * Copyright (C) 2012 Antony Pavlov <antonynpavlov at gmail.com>
>> + *
>> + * This file is part of barebox.
>> + * See file CREDITS for list of people who contributed to this project.
>> + *
>> + * This program is free software; you can redistribute it and/or
>> + * modify it under the terms of the GNU General Public License as
>> + * published by the Free Software Foundation; either version 2 of
>> + * the License, or (at your option) any later version.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> + * GNU General Public License for more details.
>> + *
>> + */
>> +
>> +#include <common.h>
>> +#include <init.h>
>> +#include <sizes.h>
>> +#include <string.h>
>> +#include <asm/sections.h>
>> +#include <asm-generic/memory_layout.h>
>> +#include <debug_ll.h>
>> +
>> +extern void *input_data;
>> +extern void *input_data_end;
>> +
>> +unsigned long free_mem_ptr;
>> +unsigned long free_mem_end_ptr;
>> +
>> +#define STATIC static
>> +
>> +#ifdef CONFIG_IMAGE_COMPRESSION_LZO
>> +#include "../../../lib/decompress_unlzo.c"
>> +#endif
>> +
>> +#ifdef CONFIG_IMAGE_COMPRESSION_GZIP
>> +#include "../../../lib/decompress_inflate.c"
>> +#endif
>> +
>> +void pbl_main_entry(void);
>> +
>> +static unsigned long *ttb;
>> +
>> +static noinline void errorfn(char *error)
>> +{
>> +     PUTS_LL(error);
>> +     PUTC_LL('\n');
>> +
>> +     unreachable();
>> +}
>> +
>> +static void barebox_uncompress(void *compressed_start, unsigned int len)
>> +{
>> +     /* set 128 KiB at the end of the MALLOC_BASE for early malloc */
>> +     free_mem_ptr = MALLOC_BASE + MALLOC_SIZE - SZ_128K;
>> +     free_mem_end_ptr = free_mem_ptr + SZ_128K;
>> +
>> +     ttb = (void *)((free_mem_ptr - 0x4000) & ~0x3fff);
>> +
>> +     decompress((void *)compressed_start,
>> +                     len,
>> +                     NULL, NULL,
>> +                     (void *)TEXT_BASE, NULL, errorfn);
>> +
>> +     /* FIXME: just now we have no MIPS cache support */
>> +     /* flush_icache(); */
>> +}
>> +
>> +void __section(.text_entry) pbl_main_entry(void)
>> +{
>> +     u32 pg_start, pg_end, pg_len;
>> +     void (*barebox)(void);
>> +
>> +     PUTS_LL("pbl_main_entry()\n");
>> +
>> +     /* clear bss */
>> +     memset(__bss_start, 0, __bss_stop - __bss_start);
>> +
>> +     pg_start = (u32)&input_data;
>> +     pg_end = (u32)&input_data_end;
>> +     pg_len = pg_end - pg_start;
>> +
>> +     barebox_uncompress(&input_data, pg_len);
>> +
>> +     barebox = (void *)TEXT_BASE;
>> +     barebox();
>> +}
>> diff --git a/arch/mips/boot/start-pbl.S b/arch/mips/boot/start-pbl.S
>> new file mode 100644
>> index 0000000..ad39f42
>> --- /dev/null
>> +++ b/arch/mips/boot/start-pbl.S
>> @@ -0,0 +1,146 @@
>> +/*
>> + * Startup Code for MIPS CPU
>> + *
>> + * Copyright (C) 2011, 2012 Antony Pavlov <antonynpavlov at gmail.com>
>> + * ADR macro copyrighted (C) 2009 by Shinya Kuribayashi <skuribay at pobox.com>
>> + *
>> + * This file is part of barebox.
>> + * See file CREDITS for list of people who contributed to this project.
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License version 2
>> + * as published by the Free Software Foundation.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>> + * GNU General Public License for more details.
>> + *
>> + */
>> +
>> +#include <asm/regdef.h>
>> +#include <asm/mipsregs.h>
>> +#include <asm/asm.h>
>> +#include <asm-generic/memory_layout.h>
>> +#include <generated/compile.h>
>> +#include <generated/utsrelease.h>
>> +
>> +//#include <mach/kernel-entry-init.h>
>> +
>> +     /*
>> +      * ADR macro instruction (inspired by ARM)
>> +      *
>> +      * ARM architecture doesn't have PC-relative jump instruction
>> +      * like MIPS' B/BAL insns. When ARM makes PC-relative jumps,
>> +      * it uses ADR insn. ADR is used to get a destination address
>> +      * of 'label' against current PC. With this, ARM can safely
>> +      * make PC-relative jumps.
>> +      */
>> +     .macro  ADR rd label temp
>> +     .set    push
>> +     .set    noreorder
>> +     move    \temp, ra                       # preserve ra beforehand
>> +     bal     _pc
>> +      nop
>
> This file contains some whitespace damages you could cleanup along the
> way.

If you are about this fragment
>> +     bal     _pc
>> +      nop

then there is no whitespace damage --- the 'nop' instruction is in the
delay slot of the branch instruction (bal).

-- 
Best regards,
  Antony Pavlov


From antonynpavlov at gmail.com  Sat Nov 24 11:18:09 2012
From: antonynpavlov at gmail.com (Antony Pavlov)
Date: Sat, 24 Nov 2012 20:18:09 +0400
Subject: [RFC 2/3] MIPS: boot: realize _start in C
In-Reply-To: <20121120075818.GB10369@pengutronix.de>
References: <1353154239-31574-1-git-send-email-antonynpavlov@gmail.com>
 <1353154239-31574-3-git-send-email-antonynpavlov@gmail.com>
 <20121120075818.GB10369@pengutronix.de>
Message-ID: <CAA4bVAGVQGgDcxvRJtSfwGGgYb6DBy9wsdh3gWiu+yBxfDXKfQ@mail.gmail.com>

Sorry for delay.

On 20 November 2012 11:58, Sascha Hauer <s.hauer at pengutronix.de> wrote:
> On Sat, Nov 17, 2012 at 04:10:38PM +0400, Antony Pavlov wrote:
>> The pbl will be incharge of the lowlevel init and
>> barebox relocation. So we can skip it in barebox itself
>> and use simple _start.
>>
>> Signed-off-by: Antony Pavlov <antonynpavlov at gmail.com>
>> ---
>>  arch/mips/boot/Makefile     |    1 -
>>  arch/mips/boot/main_entry.c |   18 ++++++
>>  arch/mips/boot/start.S      |  142 -------------------------------------------
>>  3 files changed, 18 insertions(+), 143 deletions(-)
>>  delete mode 100644 arch/mips/boot/start.S
>>
>> diff --git a/arch/mips/boot/Makefile b/arch/mips/boot/Makefile
>> index 6b093f1..4f11a48 100644
>> --- a/arch/mips/boot/Makefile
>> +++ b/arch/mips/boot/Makefile
>> @@ -1,4 +1,3 @@
>> -obj-y += start.o
>>  obj-y += main_entry.o
>>
>>  pbl-y += start-pbl.o main_entry-pbl.o
>> diff --git a/arch/mips/boot/main_entry.c b/arch/mips/boot/main_entry.c
>> index 0a33c45..422d40b 100644
>> --- a/arch/mips/boot/main_entry.c
>> +++ b/arch/mips/boot/main_entry.c
>> @@ -22,6 +22,8 @@
>>  #include <asm/cpu-features.h>
>>  #include <asm/mipsregs.h>
>>  #include <asm/addrspace.h>
>> +#include <asm/regdef.h>
>> +#include <asm-generic/memory_layout.h>
>>
>>  extern void start_barebox(void);
>>  extern void handle_reserved(void);
>> @@ -92,3 +94,19 @@ void main_entry(void)
>>
>>       start_barebox();
>>  }
>> +
>> +void __naked __section(.text_entry) _start(void)
>> +{
>> +     u32 r;
>> +
>> +     /* setup the stack */
>> +     r = STACK_BASE + STACK_SIZE - 16;
>> +
>> +     __asm__ __volatile__(
>> +             "move\t$sp, %0\n\t"
>> +             : /* no outputs */
>> +             : "r" (r)
>> +     );
>> +
>> +     main_entry();
>
> I wonder that the C function skips several things the Assembler version
> does. Is this done in the pbl now?

Yes, all lowlevel init is in pbl after this patch.

> Does this patch make the pbl mandatory?

Not at all, but the patch decrease pbl-free barebox "survival".

> We haven't done this on Arm, mostly because we were not
> confident enough that it works on every board. That may be different on
> mips, but should be mentioned in the commit log. But maybe I am
> misreading the patches...

Now I think you are right and we must postpone this patch. It make
sense to introduce this patch after full ELF support adding. If we had
ELF support, we should load barebox ELF image without pbl and drop
bin-image support in bootm.

-- 
Best regards,
  Antony Pavlov


From antonynpavlov at gmail.com  Sat Nov 24 11:46:02 2012
From: antonynpavlov at gmail.com (Antony Pavlov)
Date: Sat, 24 Nov 2012 20:46:02 +0400
Subject: [PATCH] phylib: fix compiler warning
Message-ID: <1353775562-2747-1-git-send-email-antonynpavlov@gmail.com>

fixes:
 drivers/net/phy/phy.c:57: warning: no previous prototype for ?phy_device_create?

Signed-off-by: Antony Pavlov <antonynpavlov at gmail.com>
---
 drivers/net/phy/phy.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 59df742..ed185e1 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -136,7 +136,7 @@ int phy_scan_fixups(struct phy_device *phydev)
 	return 0;
 }
 
-struct phy_device *phy_device_create(struct mii_bus *bus, int addr, int phy_id)
+static struct phy_device *phy_device_create(struct mii_bus *bus, int addr, int phy_id)
 {
 	struct phy_device *dev;
 
-- 
1.7.10.4



From shc_work at mail.ru  Sat Nov 24 13:53:29 2012
From: shc_work at mail.ru (Alexander Shiyan)
Date: Sat, 24 Nov 2012 22:53:29 +0400
Subject: [PATCH] Cleanup Kconfig files
Message-ID: <1353783209-16451-1-git-send-email-shc_work@mail.ru>

This patch provides a global cleanup barebox Kconfig files. This includes
replacing spaces to tabs, formatting in accordance format, removing
extraneous lines and spaces. No functional changes.

Signed-off-by: Alexander Shiyan <shc_work at mail.ru>
---
 arch/arm/Kconfig              |    6 ++--
 arch/arm/cpu/Kconfig          |    7 ++--
 arch/arm/mach-at91/Kconfig    |    4 +-
 arch/arm/mach-imx/Kconfig     |    8 ++--
 arch/arm/mach-mxs/Kconfig     |    6 ++--
 arch/arm/mach-omap/Kconfig    |   39 ++++++++++++----------
 arch/arm/mach-samsung/Kconfig |   16 ++++-----
 arch/blackfin/Kconfig         |    2 +-
 arch/mips/Kconfig             |   25 +++++++-------
 arch/nios2/Kconfig            |    5 +--
 arch/openrisc/Kconfig         |    2 +-
 arch/ppc/mach-mpc85xx/Kconfig |    2 +-
 arch/x86/Kconfig              |   29 +++++++---------
 arch/x86/boot/Kconfig         |    2 +-
 arch/x86/mach-i386/Kconfig    |    2 +-
 commands/Kconfig              |   31 ++++++++---------
 common/Kconfig                |   73 +++++++++++++++++++++--------------------
 crypto/Kconfig                |    2 +-
 drivers/Kconfig               |    2 +-
 drivers/ata/Kconfig           |    2 +-
 drivers/dma/Kconfig           |    2 +-
 drivers/eeprom/Kconfig        |    6 ++--
 drivers/gpio/Kconfig          |    2 +-
 drivers/i2c/Kconfig           |    2 +-
 drivers/input/Kconfig         |    4 +-
 drivers/mci/Kconfig           |    4 +-
 drivers/misc/Kconfig          |    2 +-
 drivers/mtd/Kconfig           |    2 +-
 drivers/mtd/devices/Kconfig   |    8 ++--
 drivers/mtd/nand/Kconfig      |    8 ++--
 drivers/mtd/ubi/Kconfig       |    2 +-
 drivers/net/Kconfig           |    2 +-
 drivers/net/phy/Kconfig       |    2 +-
 drivers/nor/Kconfig           |    6 ++--
 drivers/serial/Kconfig        |    4 +-
 drivers/spi/Kconfig           |    2 +-
 drivers/usb/Kconfig           |    2 +-
 drivers/usb/gadget/Kconfig    |    2 +-
 drivers/video/Kconfig         |    2 +-
 drivers/watchdog/Kconfig      |    2 +-
 fs/Kconfig                    |    2 +-
 lib/Kconfig                   |    6 ++--
 lib/gui/Kconfig               |    2 +-
 net/Kconfig                   |    2 +-
 44 files changed, 169 insertions(+), 174 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 3afd885..01fe9de 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -19,7 +19,7 @@ config ARM_LINUX
 config HAVE_MACH_ARM_HEAD
 	bool
 
-menu "System Type                   "
+menu "System Type"
 
 choice
 	prompt "ARM system type"
@@ -71,7 +71,7 @@ config ARCH_NOMADIK
 	select CPU_ARM926T
 	select CLOCKSOURCE_NOMADIK
 	help
-	 Support for the Nomadik platform by ST-Ericsson
+	  Support for the Nomadik platform by ST-Ericsson
 
 config ARCH_OMAP
 	bool "TI OMAP"
@@ -153,7 +153,7 @@ config THUMB2_BAREBOX
 
 endmenu
 
-menu "Arm specific settings         "
+menu "Arm specific settings"
 
 config CMD_ARM_CPUINFO
 	bool "cpuinfo command"
diff --git a/arch/arm/cpu/Kconfig b/arch/arm/cpu/Kconfig
index d8a5fb1..86bc174 100644
--- a/arch/arm/cpu/Kconfig
+++ b/arch/arm/cpu/Kconfig
@@ -4,7 +4,7 @@ config CPU_32
 	bool
 	default y
 
-# Select CPU types depending on the architecture selected.  This selects
+# Select CPU types depending on the architecture selected. This selects
 # which CPUs we support in the kernel image, and the compiler instruction
 # optimiser behaviour.
 
@@ -27,14 +27,13 @@ config CPU_ARM920T
 	  Say Y if you want support for the ARM920T processor.
 	  Otherwise, say N.
 
-
 # ARM926T
 config CPU_ARM926T
 	bool
 	select CPU_32v5
 	help
-	  This is a variant of the ARM920.  It has slightly different
-	  instruction sequences for cache and TLB operations.  Curiously,
+	  This is a variant of the ARM920. It has slightly different
+	  instruction sequences for cache and TLB operations. Curiously,
 	  there is no documentation on it at the ARM corporate website.
 
 	  Say Y if you want support for the ARM926T processor.
diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index 3a985f7..b01d84b 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -121,8 +121,8 @@ choice
 
 config MACH_AT91RM9200EK
 	bool "Atmel AT91RM9200-EK Evaluation Kit"
-	help
 	select HAVE_AT91_DATAFLASH_CARD
+	help
 	  Select this if you are using Atmel's AT91RM9200-EK Evaluation Kit.
 	  <http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3507>
 
@@ -390,7 +390,7 @@ config CALAO_MOB_TNY_MD2
 	depends on SUPPORT_CALAO_MOB_TNY_MD2
 
 config CALAO_MB_QIL_A9260
-	bool "MB-QIL A9260  Motherboard Board support"
+	bool "MB-QIL A9260 Motherboard Board support"
 	depends on MACH_QIL_A9260
 
 endif
diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index 3f4b452..11d2767 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -500,7 +500,7 @@ endif
 
 # ----------------------------------------------------------
 
-menu "Board specific settings       "
+menu "Board specific settings"
 
 if MACH_PCM037
 choice
@@ -561,13 +561,13 @@ endchoice
 endif
 endmenu
 
-menu "i.MX specific settings        "
+menu "i.MX specific settings"
 
 config IMX_IIM
 	tristate "IIM fusebox device"
 	depends on !ARCH_IMX21 && !ARCH_IMX21
 	help
-	  Device driver for the IC Identification Module (IIM) fusebox. Use the 
+	  Device driver for the IC Identification Module (IIM) fusebox. Use the
 	  regular md/mw commands to program and read the fusebox.
 
 	  Fuses are grouped in "rows", 8 bits per row. When using md/mw commands,
@@ -588,7 +588,7 @@ config IMX_IIM_FUSE_BLOW
 
 	  Before being actually able to blow the fuses, you need to explicitely
 	  enable it:
-	  	 imx_iim0.permanent_write_enable=1
+	    imx_iim0.permanent_write_enable=1
 
 endmenu
 
diff --git a/arch/arm/mach-mxs/Kconfig b/arch/arm/mach-mxs/Kconfig
index ff295f1..853d81a 100644
--- a/arch/arm/mach-mxs/Kconfig
+++ b/arch/arm/mach-mxs/Kconfig
@@ -84,7 +84,7 @@ endchoice
 
 endif
 
-menu "i.MX specific settings        "
+menu "i.MX specific settings"
 
 config MXS_OCOTP
 	tristate "OCOTP device"
@@ -105,7 +105,7 @@ config MXS_OCOTP_WRITABLE
 
 	  Before being actually able to blow the bits, you need to explicitely
 	  enable writing:
-		 ocotp0.permanent_write_enable=1
+	    ocotp0.permanent_write_enable=1
 
 config MXS_CMD_BCB
 	depends on NAND_MXS
@@ -117,7 +117,7 @@ config MXS_CMD_BCB
 
 endmenu
 
-menu "Board specific settings       "
+menu "Board specific settings"
 
 if MACH_TX28
 
diff --git a/arch/arm/mach-omap/Kconfig b/arch/arm/mach-omap/Kconfig
index 81f6127..acf70b9 100644
--- a/arch/arm/mach-omap/Kconfig
+++ b/arch/arm/mach-omap/Kconfig
@@ -12,7 +12,7 @@
 #
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 # GNU General Public License for more details.
 #
 
@@ -59,7 +59,7 @@ config OMAP3_CLOCK_CONFIG
 config OMAP_GPMC
 	prompt "Support for GPMC configuration"
 	bool
-	depends on  (ARCH_OMAP2 || ARCH_OMAP3 || ARCH_OMAP4)
+	depends on (ARCH_OMAP2 || ARCH_OMAP3 || ARCH_OMAP4)
 	default y
 	help
 	  Enable this if you use Texas Instrument's General purpose Memory
@@ -115,14 +115,14 @@ config MACH_BEAGLE
 	select HAVE_NOSHELL
 	select HAVE_DEFAULT_ENVIRONMENT_NEW
 	depends on ARCH_OMAP3
-	  help
+	help
 	  Say Y here if you are using Beagle Board
 
 config MACH_OMAP3EVM
 	bool "Texas Instrument's OMAP3 EVM"
 	select HAVE_NOSHELL
 	depends on ARCH_OMAP3
-	  help
+	help
 	  Say Y here if you are using OMAP3EVM
 
 config MACH_PANDA
@@ -155,7 +155,7 @@ config MACH_PCAAL1
 	bool "Phytec phyCARD-A-L1"
 	select HAVE_NOSHELL
 	depends on ARCH_OMAP3
-	  help
+	help
 	  Say Y here if you are using a phyCARD-A-L1 PCA-A-L1
 
 config MACH_PCAAXL2
@@ -169,21 +169,24 @@ config MACH_PCAAXL2
 endchoice
 
 if MACH_OMAP3EVM
-	choice
+
+choice
 	prompt "Select UART"
 
-	config OMAP3EVM_UART1
-		bool "Use UART1"
-		depends on MACH_OMAP3EVM
-		help
-		  Say Y here if you would like to use UART1 as console.
-
-	config OMAP3EVM_UART3
-		bool "Use UART3"
-		depends on MACH_OMAP3EVM
-		help
-		  Say Y here if you would like to use UART3 as console.
-	endchoice
+config OMAP3EVM_UART1
+	bool "Use UART1"
+	depends on MACH_OMAP3EVM
+	help
+	  Say Y here if you would like to use UART1 as console.
+
+config OMAP3EVM_UART3
+	bool "Use UART3"
+	depends on MACH_OMAP3EVM
+	help
+	  Say Y here if you would like to use UART3 as console.
+
+endchoice
+
 endif
 
 config MACH_OMAP_ADVANCED_MUX
diff --git a/arch/arm/mach-samsung/Kconfig b/arch/arm/mach-samsung/Kconfig
index 3a4d910..4c7412a 100644
--- a/arch/arm/mach-samsung/Kconfig
+++ b/arch/arm/mach-samsung/Kconfig
@@ -13,17 +13,16 @@ config ARCH_TEXT_BASE
 	default 0x23e00000 if MACH_TINY210
 
 config BOARDINFO
-	default "Mini 2440"    if MACH_MINI2440
-	default "Mini 6410"    if MACH_MINI6410
-	default "Tiny 6410"    if MACH_TINY6410
+	default "Mini 2440" if MACH_MINI2440
+	default "Mini 6410" if MACH_MINI6410
+	default "Tiny 6410" if MACH_TINY6410
 	default "Digi A9M2440" if MACH_A9M2440
 	default "Digi A9M2410" if MACH_A9M2410
-	default "Tiny 210"     if MACH_TINY210
+	default "Tiny 210" if MACH_TINY210
 
 config ARCH_BAREBOX_MAX_BARE_INIT_SIZE
 	hex
 	default 0x1ff0 if ARCH_S5PCxx
-# TODO
 	default 0x2000 if ARCH_S3C64xx
 
 if ARCH_S3C24xx
@@ -71,7 +70,7 @@ config MACH_MINI2440
 
 endchoice
 
-menu "Board specific settings       "
+menu "Board specific settings"
 
 choice
 	prompt "A9M2440 baseboard"
@@ -118,7 +117,7 @@ config MACH_TINY6410
 
 endchoice
 
-menu "Board specific settings       "
+menu "Board specific settings"
 
 source arch/arm/boards/friendlyarm-tiny6410/Kconfig
 
@@ -149,8 +148,7 @@ endchoice
 
 endif
 
-
-menu "S3C Features              "
+menu "S3C Features"
 
 config S3C_LOWLEVEL_INIT
 	bool
diff --git a/arch/blackfin/Kconfig b/arch/blackfin/Kconfig
index 1c58ba8..5d8a2e2 100644
--- a/arch/blackfin/Kconfig
+++ b/arch/blackfin/Kconfig
@@ -29,7 +29,7 @@ config MACH_IPE337
 
 endchoice
 
-choice 
+choice
 	prompt "Select your board options"
 	depends on MACH_IPE337
 	default MACH_IPE337_V2
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 7a1eeac..6c16c2d 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -62,8 +62,8 @@ source arch/mips/mach-xburst/Kconfig
 endmenu
 
 #
-# Endianess selection.  Sufficiently obscure so many users don't know what to
-# answer,so we try hard to limit the available choices.  Also the use of a
+# Endianess selection. Sufficiently obscure so many users don't know what to
+# answer,so we try hard to limit the available choices. Also the use of a
 # choice statement should be more obvious to the user.
 #
 choice
@@ -98,8 +98,8 @@ config CPU_MIPS32_R1
 	select CPU_SUPPORTS_32BIT_KERNEL
 	help
 	  Choose this option to build a barebox for release 1 or later of the
-	  MIPS32 architecture.  Most modern embedded systems with a 32-bit
-	  MIPS processor are based on a MIPS32 processor.  If you know the
+	  MIPS32 architecture. Most modern embedded systems with a 32-bit
+	  MIPS processor are based on a MIPS32 processor. If you know the
 	  specific type of processor in your system, choose those that one
 	  otherwise CPU_MIPS32_R1 is a safe bet for any MIPS32 system.
 	  Release 2 of the MIPS32 architecture is available since several
@@ -113,8 +113,8 @@ config CPU_MIPS32_R2
 	select CPU_SUPPORTS_32BIT_KERNEL
 	help
 	  Choose this option to build a barebox for release 2 or later of the
-	  MIPS32 architecture.  Most modern embedded systems with a 32-bit
-	  MIPS processor are based on a MIPS32 processor.  If you know the
+	  MIPS32 architecture. Most modern embedded systems with a 32-bit
+	  MIPS processor are based on a MIPS32 processor. If you know the
 	  specific type of processor in your system, choose those that one
 	  otherwise CPU_MIPS32_R1 is a safe bet for any MIPS32 system.
 
@@ -125,8 +125,8 @@ config CPU_MIPS64_R1
 	select CPU_SUPPORTS_64BIT_KERNEL
 	help
 	  Choose this option to build a barebox for release 1 or later of the
-	  MIPS64 architecture.  Many modern embedded systems with a 64-bit
-	  MIPS processor are based on a MIPS64 processor.  If you know the
+	  MIPS64 architecture. Many modern embedded systems with a 64-bit
+	  MIPS processor are based on a MIPS64 processor. If you know the
 	  specific type of processor in your system, choose those that one
 	  otherwise CPU_MIPS64_R1 is a safe bet for any MIPS64 system.
 	  Release 2 of the MIPS64 architecture is available since several
@@ -141,14 +141,13 @@ config CPU_MIPS64_R2
 	select CPU_SUPPORTS_64BIT_KERNEL
 	help
 	  Choose this option to build a barebox for release 2 or later of the
-	  MIPS64 architecture.  Many modern embedded systems with a 64-bit
-	  MIPS processor are based on a MIPS64 processor.  If you know the
+	  MIPS64 architecture. Many modern embedded systems with a 64-bit
+	  MIPS processor are based on a MIPS64 processor. If you know the
 	  specific type of processor in your system, choose those that one
 	  otherwise CPU_MIPS64_R1 is a safe bet for any MIPS64 system.
 
 endchoice
 
-
 config SYS_HAS_CPU_MIPS32_R1
 	bool
 
@@ -199,7 +198,7 @@ choice
 	help
 	  You should only select this option if you have a workload that
 	  actually benefits from 64-bit processing or if your machine has
-	  large memory.  You will only be presented a single option in this
+	  large memory. You will only be presented a single option in this
 	  menu if your system does not support both 32-bit and 64-bit modes.
 
 config 32BIT
@@ -216,7 +215,7 @@ config 64BIT
 
 endchoice
 
-menu "MIPS specific settings        "
+menu "MIPS specific settings"
 
 config CMD_MIPS_CPUINFO
 	bool "cpuinfo command"
diff --git a/arch/nios2/Kconfig b/arch/nios2/Kconfig
index e1af0c0..c49f6e9 100644
--- a/arch/nios2/Kconfig
+++ b/arch/nios2/Kconfig
@@ -16,13 +16,12 @@ choice
 	prompt "Select your board"
 
 config GENERIC
-	bool "Generic   "
+	bool "Generic"
 	select NIOS2
 
-
 endchoice
 
-menu "Board configuration           "
+menu "Board configuration"
 
 config EARLY_PRINTF
 	default n
diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig
index bcfd67f..47ee3fe 100644
--- a/arch/openrisc/Kconfig
+++ b/arch/openrisc/Kconfig
@@ -16,7 +16,7 @@ choice
 	prompt "Select your board"
 
 config GENERIC
-	bool "Generic   "
+	bool "Generic"
 	select OPENRISC
 
 endchoice
diff --git a/arch/ppc/mach-mpc85xx/Kconfig b/arch/ppc/mach-mpc85xx/Kconfig
index b2af05e..b3738c7 100644
--- a/arch/ppc/mach-mpc85xx/Kconfig
+++ b/arch/ppc/mach-mpc85xx/Kconfig
@@ -17,7 +17,7 @@ choice
 config P2020RDB
 	bool "P2020RDB"
 	help
-	Say Y here if you are using the Freescale P2020RDB
+	  Say Y here if you are using the Freescale P2020RDB
 
 endchoice
 endif
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 711bbfe..9bb93db 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -1,6 +1,3 @@
-#
-#
-#
 config ARCH_TEXT_BASE
 	hex
 	default 0x00007c00 if MACH_X86_GENERIC
@@ -39,20 +36,20 @@ endchoice
 choice
 	prompt "Bring up type"
 
-	config X86_BIOS_BRINGUP
-		prompt "16 bit BIOS"
-		bool
-		help
-		   Barebox will act as a BIOS based bootloader. This includes
-		   some 16 bit real mode code and some restrictions everyone knows
-		   from BIOS based systems.
+config X86_BIOS_BRINGUP
+	prompt "16 bit BIOS"
+	bool
+	help
+	  Barebox will act as a BIOS based bootloader. This includes
+	  some 16 bit real mode code and some restrictions everyone knows
+	  from BIOS based systems.
 
-	config X86_NATIVE_BRINGUP
-		bool "native"
-		help
-		   Barebox will act as a native bootloader. This includes all the
-		   required initialization needed to bring up a piece of hardware.
-		   Note: Not implemented yet
+config X86_NATIVE_BRINGUP
+	bool "native"
+	help
+	  Barebox will act as a native bootloader. This includes all the
+	  required initialization needed to bring up a piece of hardware.
+	  Note: Not implemented yet
 
 endchoice
 
diff --git a/arch/x86/boot/Kconfig b/arch/x86/boot/Kconfig
index cdb82e4..8dba00d 100644
--- a/arch/x86/boot/Kconfig
+++ b/arch/x86/boot/Kconfig
@@ -1,6 +1,6 @@
 if X86_BIOS_BRINGUP
 
-menu "BIOS boot source              "
+menu "BIOS boot source"
 
 config X86_HDBOOT
 	bool "HD boot"
diff --git a/arch/x86/mach-i386/Kconfig b/arch/x86/mach-i386/Kconfig
index 11f6aa6..cb12b9c 100644
--- a/arch/x86/mach-i386/Kconfig
+++ b/arch/x86/mach-i386/Kconfig
@@ -1,5 +1,5 @@
 
-menu "Board specific settings       "
+menu "Board specific settings"
 
 if X86_BOOTLOADER
 
diff --git a/commands/Kconfig b/commands/Kconfig
index ac9b797..75ebfb8 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -12,9 +12,9 @@ config HAS_POWEROFF
 
 if COMMAND_SUPPORT
 
-menu "commands                      "
+menu "commands"
 
-menu "scripting                     "
+menu "scripting"
 
 config CMD_EDIT
 	tristate
@@ -107,7 +107,7 @@ endif
 
 config CMD_TIME
 	bool "time"
-	  help
+	help
 	  Just like the unix time command this command allows to measure the
 	  execution time of a command. Note: barebox does not use interrupts,
 	  so the system timer can overrun during the execution of the command
@@ -130,7 +130,7 @@ config CMD_GLOBAL
 
 endmenu
 
-menu "file commands                 "
+menu "file commands"
 
 config CMD_LS
 	tristate
@@ -237,7 +237,7 @@ config CMD_FILETYPE
 
 endmenu
 
-menu "console                       "
+menu "console"
 
 config CMD_CLEAR
 	tristate
@@ -257,7 +257,7 @@ config CMD_ECHO_E
 
 endmenu
 
-menu "memory                        "
+menu "memory"
 
 config CMD_LOADB
 	select CRC16
@@ -306,8 +306,8 @@ config CMD_CRC_CMP
 	prompt "compare 2 files crc"
 
 config CMD_DIGEST
-       tristate
-       select DIGEST
+	tristate
+	select DIGEST
 
 config CMD_MD5SUM
 	tristate
@@ -335,7 +335,7 @@ config CMD_SHA224SUM
 
 endmenu
 
-menu "flash                         "
+menu "flash"
 
 config CMD_FLASH
 	tristate
@@ -349,8 +349,7 @@ config CMD_UBI
 
 endmenu
 
-
-menu "booting                       "
+menu "booting"
 
 config CMD_BOOTM
 	tristate
@@ -424,8 +423,8 @@ config CMD_BOOTU
 	depends on ARM
 	prompt "bootu"
 	help
-	   compile in the 'bootu' command to start raw (uncompressed)
-	   Linux images
+	  compile in the 'bootu' command to start raw (uncompressed)
+	  Linux images
 
 config FLEXIBLE_BOOTARGS
 	bool
@@ -479,7 +478,7 @@ config CMD_OFTREE_PROBE
 
 endmenu
 
-menu "testing                       "
+menu "testing"
 
 config CMD_NANDTEST
 	tristate
@@ -500,7 +499,7 @@ config CMD_MTEST_ALTERNATIVE
 
 endmenu
 
-menu "video command                  "
+menu "video command"
 
 if VIDEO
 
@@ -659,7 +658,7 @@ config CMD_CLK
 menuconfig CMD_WD
 	bool
 	depends on WATCHDOG
-	prompt "wd command                    "
+	prompt "wd command"
 	help
 	  The 'wd' command which allows to start, stop and trigger the onboard
 	  watchdog.
diff --git a/common/Kconfig b/common/Kconfig
index d60db80..cc88175 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -61,7 +61,7 @@ config STDDEV
 config BAREBOX_UPDATE
 	bool
 
-menu "General Settings              "
+menu "General Settings"
 
 config LOCALVERSION
 	string "Local version - append to the version string"
@@ -69,7 +69,7 @@ config LOCALVERSION
 	  Append an extra string to the end of your version string.
 	  The string you set here will be appended after the contents of
 	  any files with a filename matching localversion* in your
-	  object and source tree, in that order.  Your total string can
+	  object and source tree, in that order. Your total string can
 	  be a maximum of 64 characters.
 
 config LOCALVERSION_AUTO
@@ -81,7 +81,7 @@ config LOCALVERSION_AUTO
 	  top of tree revision.
 
 	  A string of the format -gxxxxxxxx will be added to the localversion
-	  if a git-based tree is found.  The string generated by this will be
+	  if a git-based tree is found. The string generated by this will be
 	  appended after any matching localversion* files, and after the value
 	  set in CONFIG_LOCALVERSION.
 
@@ -106,7 +106,7 @@ config MEMINFO
 config ENVIRONMENT_VARIABLES
 	bool "environment variables support"
 
-menu "memory layout                 "
+menu "memory layout"
 
 config HAVE_PBL_IMAGE
 	bool
@@ -196,7 +196,7 @@ config MEMORY_LAYOUT_DEFAULT
 	bool "use default memory layout"
 	help
 	  select this option to use bareboxs standard memory layout:
-	  
+
 	  stack
 	  -----
 	  malloc heap
@@ -301,7 +301,7 @@ config MACH_DO_LOWLEVEL_INIT
 
 config PROMPT
 	string
-	prompt "barebox command prompt"
+	prompt "barebox command prompt "
 	default "barebox:"
 
 config BAUDRATE
@@ -331,33 +331,34 @@ config MAXARGS
 choice
 	prompt "Select your shell"
 
-	config SHELL_HUSH
-		bool "hush parser"
-		select ENVIRONMENT_VARIABLES
-		select COMMAND_SUPPORT
-		select PARAMETER
-		select BINFMT
-		select STDDEV
-		help
-		  Enable hush support. This is the most advanced shell available
-		  for barebox.
-
-	config SHELL_SIMPLE
-		bool "Simple parser"
-		select ENVIRONMENT_VARIABLES
-		select COMMAND_SUPPORT
-		select PARAMETER
-		select STDDEV
-		help
-		  simple shell. No if/then, no return values from commands, no loops
-
-	config SHELL_NONE
-		depends on HAVE_NOSHELL
-		bool "no shell (noninteractive build)"
-		help
-		  No shell at all. This means no shell is started and your board has
-		  to provide a run_shell() function which is started at the end of
-		  the barebox startup process.
+config SHELL_HUSH
+	bool "hush parser"
+	select ENVIRONMENT_VARIABLES
+	select COMMAND_SUPPORT
+	select PARAMETER
+	select BINFMT
+	select STDDEV
+	help
+	  Enable hush support. This is the most advanced shell available
+	  for barebox.
+
+config SHELL_SIMPLE
+	bool "Simple parser"
+	select ENVIRONMENT_VARIABLES
+	select COMMAND_SUPPORT
+	select PARAMETER
+	select STDDEV
+	help
+	  simple shell. No if/then, no return values from commands, no loops
+
+config SHELL_NONE
+	depends on HAVE_NOSHELL
+	bool "no shell (noninteractive build)"
+	help
+	  No shell at all. This means no shell is started and your board has
+	  to provide a run_shell() function which is started at the end of
+	  the barebox startup process.
+
 endchoice
 
 config GLOB
@@ -409,8 +410,8 @@ config MENU
 	prompt "Menu Framework"
 	depends on PROCESS_ESCAPE_SEQUENCE
 	help
-	   a menu framework that allow us to create list menu to simplify
-	   barebox and make it more user-frendly
+	  a menu framework that allow us to create list menu to simplify
+	  barebox and make it more user-frendly
 
 config PASSWORD
 	bool
@@ -635,7 +636,7 @@ config RESET_SOURCE
 
 endmenu
 
-menu "Debugging                     "
+menu "Debugging"
 
 config DEBUG_INFO
 	bool
diff --git a/crypto/Kconfig b/crypto/Kconfig
index a6fc1b8..4bd8dcf 100644
--- a/crypto/Kconfig
+++ b/crypto/Kconfig
@@ -8,7 +8,7 @@ config CRC7
 	bool
 
 menuconfig DIGEST
-	bool "Digest                        "
+	bool "Digest"
 
 if DIGEST
 
diff --git a/drivers/Kconfig b/drivers/Kconfig
index f6446e8..988ec9e 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -1,4 +1,4 @@
-menu "Drivers                       "
+menu "Drivers"
 
 source "drivers/serial/Kconfig"
 source "drivers/net/Kconfig"
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index fe6f5e6..2e80c3e 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -2,7 +2,7 @@ menuconfig DISK
 	select BLOCK
 	select PARTITION
 	select PARTITION_DISK
-	bool "Disk support                  "
+	bool "Disk support"
 	help
 	  Add support for disk like drives like harddisks, CDROMs, SD cards and
 	  CF cards.
diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index ec6c894..a30fa37 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -4,5 +4,5 @@ config MXS_APBH_DMA
 	tristate "MXS APBH DMA ENGINE"
 	depends on ARCH_IMX23 || ARCH_IMX28
 	help
-	Experimental!
+	  Experimental!
 endmenu
diff --git a/drivers/eeprom/Kconfig b/drivers/eeprom/Kconfig
index ce9cfe7..0e36c82 100644
--- a/drivers/eeprom/Kconfig
+++ b/drivers/eeprom/Kconfig
@@ -14,11 +14,11 @@ config EEPROM_AT24
 	help
 	  Enable this driver to get read/write support to most I2C EEPROMs,
 	  after you configure the driver to know about each EEPROM on
-	  your target board.  Use these generic chip names, instead of
+	  your target board. Use these generic chip names, instead of
 	  vendor-specific ones like at24c64 or 24lc02:
 
-	     24c00, 24c01, 24c02, spd (readonly 24c02), 24c04, 24c08,
-	     24c16, 24c32, 24c64, 24c128, 24c256, 24c512, 24c1024
+	    24c00, 24c01, 24c02, spd (readonly 24c02), 24c04, 24c08,
+	    24c16, 24c32, 24c64, 24c128, 24c256, 24c512, 24c1024
 
 	  Unless you like data loss puzzles, always be sure that any chip
 	  you configure as a 24c32 (32 kbit) or larger is NOT really a
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index e8eeb6d..89be684 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -4,7 +4,7 @@ config GPIOLIB
 
 if GPIOLIB
 
-menu "GPIO                          "
+menu "GPIO"
 
 config GPIO_BCM2835
 	bool "GPIO support for BCM2835"
diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig
index 038e2ee..0c6aec3 100644
--- a/drivers/i2c/Kconfig
+++ b/drivers/i2c/Kconfig
@@ -1,5 +1,5 @@
 menuconfig I2C
-	bool "I2C drivers                   "
+	bool "I2C drivers"
 
 if I2C
 
diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig
index 846483c..a6f1f47 100644
--- a/drivers/input/Kconfig
+++ b/drivers/input/Kconfig
@@ -13,7 +13,7 @@ config KEYBOARD_GPIO
 	  to GPIO pins of various CPUs (and some other chips).
 
 	  Say Y here if your device has buttons connected
-	  directly to such GPIO pins.  Your board-specific
+	  directly to such GPIO pins. Your board-specific
 	  setup logic must also provide a platform device,
 	  with configuration data saying which GPIOs are used.
 
@@ -26,7 +26,7 @@ config KEYBOARD_IMX_KEYPAD
 	  to the IMX keypad matrix.
 
 	  Say Y here if your device has buttons connected
-	  to the IMX keypad matrix.  Your board-specific
+	  to the IMX keypad matrix. Your board-specific
 	  setup logic must also provide a 'matrix_keymap_data' structure,
 	  defining the used keys.
 
diff --git a/drivers/mci/Kconfig b/drivers/mci/Kconfig
index 5c0ca4d..6876117 100644
--- a/drivers/mci/Kconfig
+++ b/drivers/mci/Kconfig
@@ -1,5 +1,5 @@
 menuconfig MCI
-	bool "MCI drivers                   "
+	bool "MCI drivers"
 	select DISK
 	help
 	  Add support for MCI drivers, used to handle MMC and SD cards
@@ -92,7 +92,7 @@ config MCI_SPI
 	depends on SPI
 	help
 	  Some systems access MMC/SD/SDIO cards using a SPI controller
-	  instead of using a "native" MMC/SD/SDIO controller.  This has a
+	  instead of using a "native" MMC/SD/SDIO controller. This has a
 	  disadvantage of being relatively high overhead, but a compensating
 	  advantage of working on many systems without dedicated MMC/SD/SDIO
 	  controllers.
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 699046b..606490b 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -3,7 +3,7 @@
 #
 
 menuconfig MISC_DEVICES
-	bool "Misc devices                  "
+	bool "Misc devices"
 	help
 	  Add support for misc strange devices
 
diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig
index 0a4ca31..9450f5d 100644
--- a/drivers/mtd/Kconfig
+++ b/drivers/mtd/Kconfig
@@ -1,5 +1,5 @@
 menuconfig MTD
-        bool "Memory Technology Device (MTD) support"
+	bool "Memory Technology Device (MTD) support"
 
 if MTD
 
diff --git a/drivers/mtd/devices/Kconfig b/drivers/mtd/devices/Kconfig
index 679ea80..61278a2 100644
--- a/drivers/mtd/devices/Kconfig
+++ b/drivers/mtd/devices/Kconfig
@@ -15,7 +15,7 @@ config MTD_DATAFLASH_WRITE_VERIFY
 	help
 	  This adds an extra check when data is written to the flash.
 	  It may help if you are verifying chip setup (timings etc) on
-	  your board.  There is a rare possibility that even though the
+	  your board. There is a rare possibility that even though the
 	  device thinks the write was successful, a bit could have been
 	  flipped accidentally due to device wear or something else.
 
@@ -24,9 +24,9 @@ config MTD_M25P80
 	depends on SPI
 	help
 	  This enables access to most modern SPI flash chips, used for
-	  program and data storage.   Series supported include Atmel AT26DF,
-	  Spansion S25SL, SST 25VF, ST M25P, and Winbond W25X.  Other chips
-	  are supported as well.  See the driver source for the current list,
+	  program and data storage. Series supported include Atmel AT26DF,
+	  Spansion S25SL, SST 25VF, ST M25P, and Winbond W25X. Other chips
+	  are supported as well. See the driver source for the current list,
 	  or to add other chips.
 
 	  Note that the original DataFlash chips (AT45 series, not AT26DF),
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index d96ef9e..aa3ea34 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -1,5 +1,5 @@
 menuconfig NAND
-	bool "NAND support              "
+	bool "NAND support"
 	select MTD_NAND_IDS
 	help
 	  This enables support for accessing all type of NAND flash
@@ -63,8 +63,8 @@ config NAND_OMAP_GPMC
 	tristate "NAND Flash Support for GPMC based OMAP platforms"
 	depends on OMAP_GPMC
 	help
-	 Support for NAND flash using GPMC. GPMC is a common memory
-	 interface found on Texas Instrument's OMAP platforms
+	  Support for NAND flash using GPMC. GPMC is a common memory
+	  interface found on Texas Instrument's OMAP platforms
 
 config NAND_ATMEL
 	bool
@@ -77,7 +77,7 @@ config NAND_ATMEL_PMECC
 	depends on NAND_ATMEL
 	select NAND_ECC_HW
 	help
-	 Support for PMECC present on the SoC sam9x5 and sam9n12
+	  Support for PMECC present on the SoC sam9x5 and sam9n12
 
 config NAND_S3C24XX
 	bool
diff --git a/drivers/mtd/ubi/Kconfig b/drivers/mtd/ubi/Kconfig
index 2cf474a..6df954c 100644
--- a/drivers/mtd/ubi/Kconfig
+++ b/drivers/mtd/ubi/Kconfig
@@ -1,5 +1,5 @@
 config UBI
-	bool "UBI support               "
+	bool "UBI support"
 	select PARTITION_NEED_MTD
 	select CRC32
 	help
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index b3e5a83..43d5984 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -22,7 +22,7 @@ config ARCH_HAS_FEC_IMX
 config PHYLIB
 	bool
 
-menu "Network drivers               "
+menu "Network drivers"
 	depends on NET
 
 source "drivers/net/phy/Kconfig"
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index 616b539..9250305 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -2,7 +2,7 @@
 # PHY Layer Configuration
 #
 
-menu "phylib                       "
+menu "phylib"
 
 if PHYLIB
 
diff --git a/drivers/nor/Kconfig b/drivers/nor/Kconfig
index a3c0223..c8ce24f 100644
--- a/drivers/nor/Kconfig
+++ b/drivers/nor/Kconfig
@@ -1,7 +1,7 @@
-menu "flash drivers                 "
+menu "flash drivers"
 
 menuconfig DRIVER_CFI
-	bool "CFI            "
+	bool "CFI"
 	help
 	  If you have NOR Flash devices connected to your system and wish
 	  to use them say yes here.
@@ -19,7 +19,7 @@ config DRIVER_CFI_AMD
 	bool "support AMD flash chips"
 
 config DRIVER_CFI_BANK_WIDTH_1
-	bool "Support  8-bit buswidth"
+	bool "Support 8-bit buswidth"
 	depends on DRIVER_CFI
 	default y
 	help
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 32b033f..a8be9cd 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -1,4 +1,4 @@
-menu "serial drivers                "
+menu "serial drivers"
 
 config DRIVER_SERIAL_ARM_DCC
 	depends on ARM
@@ -8,7 +8,7 @@ config SERIAL_AMBA_PL011
 	bool "ARM AMBA PL011 serial port support"
 	depends on ARM_AMBA
 	help
-	  This selects the ARM(R) AMBA(R) PrimeCell PL011 UART.  If you have
+	  This selects the ARM(R) AMBA(R) PrimeCell PL011 UART. If you have
 	  an Integrator/PP2, Integrator/CP or Versatile platform, say Y here.
 
 	  If unsure, say N.
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index b003290..10b8fea 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -1,4 +1,4 @@
-menu "SPI drivers                   "
+menu "SPI drivers"
 
 config SPI
 	bool "Enable SPI driver support"
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig
index 254b196..acdb4c6 100644
--- a/drivers/usb/Kconfig
+++ b/drivers/usb/Kconfig
@@ -1,5 +1,5 @@
 menuconfig USB
-	bool "USB support                   "
+	bool "USB support"
 
 if USB
 
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 465121c..6501d42 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -1,6 +1,6 @@
 menuconfig USB_GADGET
 	depends on USB_HAVE_GADGET_DRIVER
-	bool "USB gadget support            "
+	bool "USB gadget support"
 
 config USB_HAVE_GADGET_DRIVER
 	bool
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 4aa92c5..f09ffdf 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -1,5 +1,5 @@
 menuconfig VIDEO
-	bool "Video drivers                 "
+	bool "Video drivers"
 	help
 	  Add support for framebuffer and splash screens
 
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index ba33617..2e2900c 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -3,7 +3,7 @@ config WATCHDOG_IMX_RESET_SOURCE
 	bool
 
 menuconfig WATCHDOG
-	bool "Watchdog support              "
+	bool "Watchdog support"
 	help
 	  Many platforms support a watchdog to keep track of a working machine.
 	  This framework provides routines to handle these watchdogs.
diff --git a/fs/Kconfig b/fs/Kconfig
index 0ab69d7..c26c3c4 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -1,5 +1,5 @@
 
-menu "Filesystem support            "
+menu "Filesystem support"
 
 config FS
 	bool
diff --git a/lib/Kconfig b/lib/Kconfig
index 13ecab0..5966386 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -1,4 +1,4 @@
-menu "Library routines              "
+menu "Library routines"
 config PARAMETER
 	bool
 
@@ -30,10 +30,10 @@ config OFTREE
 	bool
 
 config BCH
-       bool
+	bool
 
 config BITREV
-       bool
+	bool
 
 config QSORT
 	bool
diff --git a/lib/gui/Kconfig b/lib/gui/Kconfig
index 8fd12fb..da71bae 100644
--- a/lib/gui/Kconfig
+++ b/lib/gui/Kconfig
@@ -1,4 +1,4 @@
-menu "Library gui routines           "
+menu "Library gui routines"
 
 config IMAGE_RENDERER
 	bool
diff --git a/net/Kconfig b/net/Kconfig
index 00fffb3..acd92ff 100644
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -1,5 +1,5 @@
 menuconfig NET
-	bool "Networking Support            "
+	bool "Networking Support"
 
 if NET
 
-- 
1.7.8.6



From robert.jarzmik at free.fr  Sat Nov 24 15:11:36 2012
From: robert.jarzmik at free.fr (Robert Jarzmik)
Date: Sat, 24 Nov 2012 21:11:36 +0100
Subject: [PATCH] xymodem.c: fix compiler warning
In-Reply-To: <1353770926-24496-1-git-send-email-antonynpavlov@gmail.com>
 (Antony Pavlov's message of "Sat, 24 Nov 2012 19:28:46 +0400")
References: <1353770926-24496-1-git-send-email-antonynpavlov@gmail.com>
Message-ID: <87lidq3gnb.fsf@free.fr>

Antony Pavlov <antonynpavlov at gmail.com> writes:

> Fixes:
>  lib/xymodem.c:558: warning: no previous prototype for ?do_load_serial_xmodem?
>  lib/xymodem.c:572: warning: no previous prototype for ?do_load_serial_ymodem?
>  lib/xymodem.c:586: warning: no previous prototype for ?do_load_serial_ymodemg?
>
> Signed-off-by: Antony Pavlov <antonynpavlov at gmail.com>
Indeed.
Acked-by: Robert Jarzmik <robert.jarzmik at free.fr>

-- 
Robert


From zzs213 at 126.com  Sun Nov 25 03:11:49 2012
From: zzs213 at 126.com (=?utf-8?B?5byg5b+g5bGx?=)
Date: Sun, 25 Nov 2012 16:11:49 +0800
Subject: [PATCH 4/4] Revert "mtd: atmel_nand: optimize read/write buffer
 functions"
In-Reply-To: <20121124084544.GY8327@game.jcrosoft.org>
References: <20121123155224.GV8327@game.jcrosoft.org>
 <1353686104-31295-1-git-send-email-plagnioj@jcrosoft.com>
 <1353686104-31295-4-git-send-email-plagnioj@jcrosoft.com>
 <20121124034241.GA19824@greatfirst.com>
 <20121124084544.GY8327@game.jcrosoft.org>
Message-ID: <20121125081149.GB19824@greatfirst.com>

> >
> > This patch resolves my problem
> I'm expecting to see your patches
>

My first patch very simple:

------------------
diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index 0477178..a111463 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -155,23 +155,6 @@ static int atmel_nand_device_ready(struct mtd_info *mtd)
 }

 /*
- * Minimal-overhead PIO for data access.
- */
-static void atmel_read_buf(struct mtd_info *mtd, u8 *buf, int len)
-{
-       struct nand_chip *chip = mtd->priv;
-
-       memcpy_fromio(buf, chip->IO_ADDR_R, len);
-}
-
-static void atmel_write_buf(struct mtd_info *mtd, const u8 *buf, int len)
-{
-       struct nand_chip *chip = mtd->priv;
-
-       memcpy_toio(chip->IO_ADDR_W, buf, len);
-}
-
-/*
  * Return number of ecc bytes per sector according to sector size and
  * correction capability
  *
@@ -1115,8 +1098,9 @@ static int __init atmel_nand_probe(struct device_d *dev)
        if (host->board->bus_width_16)          /* 16-bit bus width */
                nand_chip->options |= NAND_BUSWIDTH_16;

-       nand_chip->read_buf = atmel_read_buf;
-       nand_chip->write_buf = atmel_write_buf;
+       /* use default */
+       nand_chip->read_buf = NULL;
+       nand_chip->write_buf = NULL;

        atmel_nand_enable(host);
------------------

After seeing your patch, I suppose the flowing patch may be works.
The idea is use optimized read/write function when 2**ale >= pagesize
and 2**cle >= pagesize.

I can't test it because the ale = a7, cle = a6 on my board, but
pagesize is 2048

------------------
diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index 0477178..66cf5db 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -1115,8 +1115,8 @@ static int __init atmel_nand_probe(struct device_d *dev)
        if (host->board->bus_width_16)          /* 16-bit bus width */
                nand_chip->options |= NAND_BUSWIDTH_16;

-       nand_chip->read_buf = atmel_read_buf;
-       nand_chip->write_buf = atmel_write_buf;
+       nand_chip->read_buf = NULL;
+       nand_chip->write_buf = NULL;

        atmel_nand_enable(host);

@@ -1151,6 +1151,11 @@ static int __init atmel_nand_probe(struct device_d *dev)
                        goto err_hw_ecc;
        }

+       if((1 << pdata->ale) >= mtd->writesize && (1 << pdata->cle) >= mtd->writesize) {
+               nand_chip->read_buf = atmel_read_buf;
+               nand_chip->write_buf = atmel_write_buf;
+       }
+
        /* second phase scan */
        if (nand_scan_tail(mtd)) {
                res = -ENXIO;
------------------

-- 
Best Regards,
zzs




From plagnioj at jcrosoft.com  Sun Nov 25 14:32:08 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Sun, 25 Nov 2012 20:32:08 +0100
Subject: [PATCH 4/4] Revert "mtd: atmel_nand: optimize read/write
 buffer functions"
In-Reply-To: <20121125081149.GB19824@greatfirst.com>
References: <20121123155224.GV8327@game.jcrosoft.org>
 <1353686104-31295-1-git-send-email-plagnioj@jcrosoft.com>
 <1353686104-31295-4-git-send-email-plagnioj@jcrosoft.com>
 <20121124034241.GA19824@greatfirst.com>
 <20121124084544.GY8327@game.jcrosoft.org>
 <20121125081149.GB19824@greatfirst.com>
Message-ID: <20121125193208.GZ8327@game.jcrosoft.org>

On 16:11 Sun 25 Nov     , ??? wrote:
> > >
> > > This patch resolves my problem
> > I'm expecting to see your patches
> >
> 
> My first patch very simple:
your board patch

I'll be at the electronic market in SH tomorrow

Best Regards,
J.
> 
> ------------------
> diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
> index 0477178..a111463 100644
> --- a/drivers/mtd/nand/atmel_nand.c
> +++ b/drivers/mtd/nand/atmel_nand.c
> @@ -155,23 +155,6 @@ static int atmel_nand_device_ready(struct mtd_info *mtd)
>  }
> 
>  /*
> - * Minimal-overhead PIO for data access.
> - */
> -static void atmel_read_buf(struct mtd_info *mtd, u8 *buf, int len)
> -{
> -       struct nand_chip *chip = mtd->priv;
> -
> -       memcpy_fromio(buf, chip->IO_ADDR_R, len);
> -}
> -
> -static void atmel_write_buf(struct mtd_info *mtd, const u8 *buf, int len)
> -{
> -       struct nand_chip *chip = mtd->priv;
> -
> -       memcpy_toio(chip->IO_ADDR_W, buf, len);
> -}
> -
> -/*
>   * Return number of ecc bytes per sector according to sector size and
>   * correction capability
>   *
> @@ -1115,8 +1098,9 @@ static int __init atmel_nand_probe(struct device_d *dev)
>         if (host->board->bus_width_16)          /* 16-bit bus width */
>                 nand_chip->options |= NAND_BUSWIDTH_16;
> 
> -       nand_chip->read_buf = atmel_read_buf;
> -       nand_chip->write_buf = atmel_write_buf;
> +       /* use default */
> +       nand_chip->read_buf = NULL;
> +       nand_chip->write_buf = NULL;
> 
>         atmel_nand_enable(host);
> ------------------
> 
> After seeing your patch, I suppose the flowing patch may be works.
> The idea is use optimized read/write function when 2**ale >= pagesize
> and 2**cle >= pagesize.
> 
> I can't test it because the ale = a7, cle = a6 on my board, but
> pagesize is 2048
> 
> ------------------
> diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
> index 0477178..66cf5db 100644
> --- a/drivers/mtd/nand/atmel_nand.c
> +++ b/drivers/mtd/nand/atmel_nand.c
> @@ -1115,8 +1115,8 @@ static int __init atmel_nand_probe(struct device_d *dev)
>         if (host->board->bus_width_16)          /* 16-bit bus width */
>                 nand_chip->options |= NAND_BUSWIDTH_16;
> 
> -       nand_chip->read_buf = atmel_read_buf;
> -       nand_chip->write_buf = atmel_write_buf;
> +       nand_chip->read_buf = NULL;
> +       nand_chip->write_buf = NULL;
> 
>         atmel_nand_enable(host);
> 
> @@ -1151,6 +1151,11 @@ static int __init atmel_nand_probe(struct device_d *dev)
>                         goto err_hw_ecc;
>         }
> 
> +       if((1 << pdata->ale) >= mtd->writesize && (1 << pdata->cle) >= mtd->writesize) {
> +               nand_chip->read_buf = atmel_read_buf;
> +               nand_chip->write_buf = atmel_write_buf;
> +       }
> +
>         /* second phase scan */
>         if (nand_scan_tail(mtd)) {
>                 res = -ENXIO;
> ------------------
> 
> -- 
> Best Regards,
> zzs
> 
> 


From zzs213 at 126.com  Sun Nov 25 21:17:35 2012
From: zzs213 at 126.com (=?utf-8?B?5byg5b+g5bGx?=)
Date: Mon, 26 Nov 2012 10:17:35 +0800
Subject: [PATCH 4/4] Revert "mtd: atmel_nand: optimize read/write buffer
 functions"
In-Reply-To: <20121125193208.GZ8327@game.jcrosoft.org>
References: <20121123155224.GV8327@game.jcrosoft.org>
 <1353686104-31295-1-git-send-email-plagnioj@jcrosoft.com>
 <1353686104-31295-4-git-send-email-plagnioj@jcrosoft.com>
 <20121124034241.GA19824@greatfirst.com>
 <20121124084544.GY8327@game.jcrosoft.org>
 <20121125081149.GB19824@greatfirst.com>
 <20121125193208.GZ8327@game.jcrosoft.org>
Message-ID: <20121126021735.GC19824@greatfirst.com>

In message <20121125193208.GZ8327 at game.jcrosoft.org> Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 16:11 Sun 25 Nov     , ??? wrote:
> > > >
> > > > This patch resolves my problem
> > > I'm expecting to see your patches
> > >
> >
> > My first patch very simple:
> your board patch
>
The flowing is my board patch, sorry for some chinese comments.
But my board patch had nothing about drivers!

------------------------------------
diff --git a/Makefile b/Makefile
index 05b8be5..eedad07 100644
--- a/Makefile
+++ b/Makefile
@@ -681,10 +681,29 @@ endef
 quiet_cmd_objcopy = OBJCOPY $@
       cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@

+ifeq ($(CONFIG_GREATFIRST),y)
+MD5SUM_VARNAME=__md5sum__
+quiet_cmd_md5sum = MD5SUM $@
+      cmd_md5sum = (addr=$$($(NM) $(basename $@) | grep $(MD5SUM_VARNAME) | sed -e 's%\([0-9a-fA-F]\+\) \+.*%0x\1%'); \
+                    if [ "$$addr" = "" ]; then echo Can\'t find $(MD5SUM_VARNAME); exit 1; fi; \
+                    addr=$$(($$addr - $(TEXT_BASE))); \
+                    sum=$$(md5sum -b $@ | sed -e 's%\(.*\) \+\*$@%\1%') && \
+                    dd ibs=1 count=$$addr status=noxfer < $@ > $@.md5; \
+		    echo -n $$sum >> $@.md5; \
+		    addr=$$(($$addr + 32)); \
+		    dd ibs=1 skip=$$addr status=noxfer < $@ >> $@.md5; \
+		    mv $@.md5 $@; \
+                    echo -n $$sum > $@.md5 )
+else
+cmd_md5sum =
+endif
+
 OBJCOPYFLAGS_barebox.bin = -O binary

 barebox.bin: barebox FORCE
 	$(call if_changed,objcopy)
+	$(call cmd,md5sum)
+
 ifndef CONFIG_PBL_IMAGE
 	$(call cmd,check_file_size,$(CONFIG_BAREBOX_MAX_IMAGE_SIZE))
 endif
diff --git a/arch/arm/boards/greatfirst/com9200/Makefile b/arch/arm/boards/greatfirst/com9200/Makefile
new file mode 100644
index 0000000..eafb716
--- /dev/null
+++ b/arch/arm/boards/greatfirst/com9200/Makefile
@@ -0,0 +1,4 @@
+# EXTRA_CFLAGS += -DPROJECT_NAME="$(PROJECT_NAME)" -DPROJECT_VERSION="$(PROJECT_VERSION)"
+
+obj-$(CONFIG_MACH_SSR600T) += basic_init.o tiny_init.o
+obj-$(CONFIG_MACH_SSR600)  += basic_init.o init.o
diff --git a/arch/arm/boards/greatfirst/com9200/basic_init.c b/arch/arm/boards/greatfirst/com9200/basic_init.c
new file mode 100644
index 0000000..3b21b5f
--- /dev/null
+++ b/arch/arm/boards/greatfirst/com9200/basic_init.c
@@ -0,0 +1,55 @@
+#include <common.h>
+#include <net.h>
+#include <init.h>
+#include <environment.h>
+#include <asm/armlinux.h>
+#include <generated/mach-types.h>
+#include <partition.h>
+#include <fs.h>
+#include <fcntl.h>
+#include <io.h>
+#include <sizes.h>
+#include <asm/hardware.h>
+#include <mach/at91_pmc.h>
+#include <mach/board.h>
+#include <mach/gpio.h>
+#include <mach/io.h>
+
+
+static int mem_init(void)
+{
+	at91_add_device_sdram(64 * 1024 * 1024);
+
+	return 0;
+}
+mem_initcall(mem_init);
+
+static int console_init(void)
+{
+	at91_register_uart(0, 0);
+	return 0;
+}
+console_initcall(console_init);
+
+static struct at91_ether_platform_data ether_pdata = {
+	.flags = AT91SAM_ETHER_RMII,
+	.phy_addr = 0,
+};
+
+void init_eth_device(void)
+{
+	at91_add_device_eth(0, &ether_pdata);
+}
+
+/* ?????????????nm ????? barebox ??? */
+const char __md5sum__[33] = {0};
+
+void init_ip(void)
+{
+	setenv("eth0.ipaddr", "192.168.0.13");
+	setenv("eth0.serverip", "192.168.0.12");
+
+	/* ???? __md5sum__ */
+	printf("md5sum=%s\n", __md5sum__);
+}
+
diff --git a/arch/arm/boards/greatfirst/com9200/basic_init.h b/arch/arm/boards/greatfirst/com9200/basic_init.h
new file mode 100644
index 0000000..087f376
--- /dev/null
+++ b/arch/arm/boards/greatfirst/com9200/basic_init.h
@@ -0,0 +1,17 @@
+/* ---------------------------------------- HEADER GUARD ---------------------------------------- */
+#ifndef __BASIC_INIT__H__
+#define __BASIC_INIT__H__
+#ifdef __cplusplus
+extern "C" {
+#endif
+/* ---------------------------------------- HEADER GUARD ---------------------------------------- */
+
+void init_eth_device(void);
+void init_ip(void);
+
+/* ---------------------------------------- HEADER GUARD ---------------------------------------- */
+#ifdef __cplusplus
+}
+#endif
+#endif
+/* ---------------------------------------- HEADER GUARD ---------------------------------------- */
diff --git a/arch/arm/boards/greatfirst/com9200/config.h b/arch/arm/boards/greatfirst/com9200/config.h
new file mode 100644
index 0000000..bb66654
--- /dev/null
+++ b/arch/arm/boards/greatfirst/com9200/config.h
@@ -0,0 +1,71 @@
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+#define AT91_MAIN_CLOCK		18432000	/* 18.432 MHz crystal */
+
+#define MASTER_PLL_MUL		39
+#define MASTER_PLL_DIV		4
+
+/* clocks */
+#define CONFIG_SYS_MOR_VAL						\
+		(AT91_PMC_MOSCEN |					\
+		 (255 << 8))		/* Main Oscillator Start-up Time */
+#define CONFIG_SYS_PLLAR_VAL						\
+		(AT91_PMC_PLLA_WR_ERRATA | /* Bit 29 must be 1 when prog */ \
+		 (0x3e << 8) |		/* PLL Counter */		\
+		 (0 << 14) |		/* Divider A */			\
+		 ((MASTER_PLL_MUL - 1) << 16) | (MASTER_PLL_DIV))
+
+#define CONFIG_SYS_PLLBR_VAL	0x10483E0E /* 48.054857 MHz (divider by 2 for USB) */
+/* PCK/2 = MCK Master Clock from SLOW */
+#define	CONFIG_SYS_MCKR2_VAL1		\
+		(AT91_PMC_CSS_SLOW |	\
+		 AT91RM9200_PMC_MDIV_2) \
+
+/* PCK/3 = MCK Master Clock = 59.904000MHz from PLLA */
+#define	CONFIG_SYS_MCKR2_VAL2		\
+		(AT91_PMC_CSS_PLLA |	\
+		 AT91_PMC_PRES_1 |	\
+		 AT91RM9200_PMC_MDIV_3 |\
+		 AT91_PMC_PDIV_1)
+
+/* flash */
+#define CONFIG_SYS_EBI_CFGR_VAL	0x00000000
+#define CONFIG_SYS_SMC_CSR0_VAL							\
+		(AT91_SMC_NWS_(4) |	/* Number of Wait States */		\
+		 AT91_SMC_WSEN |	/* Wait State Enable */			\
+		 AT91_SMC_TDF_(2) |	/* Data Float Time */			\
+		 AT91_SMC_BAT |		/* Byte Access Type */			\
+		 AT91_SMC_DBW_16)	/* Data Bus Width */
+
+/* sdram */
+#define CONFIG_SYS_PIOC_ASR_VAL	0xFFFF0000 /* Configure PIOC as peripheral (D16/D31) */
+#define CONFIG_SYS_PIOC_BSR_VAL	0x00000000
+#define CONFIG_SYS_PIOC_PDR_VAL	0xFFFF0000
+#define CONFIG_SYS_EBI_CSA_VAL							\
+		(AT91_EBI_CS0A_SMC |						\
+		 AT91_EBI_CS1A_SDRAMC |						\
+		 AT91_EBI_CS3A_SMC |						\
+		 AT91_EBI_CS4A_SMC)						\
+
+/* SDRAM */
+/* SDRAMC_MR Mode register */
+/* SDRAMC_CR - Configuration register*/
+#define CONFIG_SYS_SDRC_CR_VAL							\
+		(AT91_SDRAMC_NC_9 |						\
+		 AT91_SDRAMC_NR_13 |						\
+		 AT91_SDRAMC_NB_4 |						\
+		 AT91_SDRAMC_CAS_2 |						\
+		 (1 <<  8) |		/* Write Recovery Delay */		\
+		 (12 << 12) |		/* Row Cycle Delay */			\
+		 (8 << 16) |		/* Row Precharge Delay */		\
+		 (8 << 20) |		/* Row to Column Delay */		\
+		 (1 << 24) |		/* Active to Precharge Delay */		\
+		 (2 << 28))		/* Exit Self Refresh to Active Delay */
+
+#define CONFIG_SYS_SDRC_TR_VAL	0x000002E0 /* Write refresh rate */
+
+#define BOARD_NOR_FLASH_SIZE SZ_8M
+#define TEMP_MEM_BASE 0x20100000
+#define TEMP_MEM_SIZE SZ_16M
+#endif	/* __CONFIG_H */
diff --git a/arch/arm/boards/greatfirst/com9200/env/bin/dlrun b/arch/arm/boards/greatfirst/com9200/env/bin/dlrun
new file mode 100644
index 0000000..ff6da4d
--- /dev/null
+++ b/arch/arm/boards/greatfirst/com9200/env/bin/dlrun
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+if [ $# -ge 1 ]; then
+	name="$1"
+else
+	name=zbarebox.bin
+fi
+
+cd /
+if [ -e "/dev/tempmem" ]; then
+	tftp ${global.prj.name}-${global.prj.ver}/$name /dev/tempmem && go /dev/tempmem
+else
+	tftp ${global.prj.name}-${global.prj.ver}/$name && ./$name
+fi
diff --git a/arch/arm/boards/greatfirst/com9200/env/bin/init b/arch/arm/boards/greatfirst/com9200/env/bin/init
new file mode 100644
index 0000000..5086357
--- /dev/null
+++ b/arch/arm/boards/greatfirst/com9200/env/bin/init
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+export PATH=/env/bin
+
+# automount tftp server based on $eth0.serverip
+mkdir -p /mnt/tftp
+automount /mnt/tftp 'mount -t tftp $eth0.serverip /mnt/tftp'
+
+nor_parts="256k(barebox),128k(bareboxenv),3M(kernel),-(root)"
+if [ -e /dev/nor0 -a -n "$nor_parts" ]; then
+	addpart /dev/nor0 $nor_parts
+fi
+
+# set a fancy prompt (if support is compiled in)
+PS1="\e[1;31m[barebox@\h]:\w\e[0m\n# "
diff --git a/arch/arm/boards/greatfirst/com9200/env/bin/update b/arch/arm/boards/greatfirst/com9200/env/bin/update
new file mode 100644
index 0000000..29bb990
--- /dev/null
+++ b/arch/arm/boards/greatfirst/com9200/env/bin/update
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+cd /
+target="/dev/nor0.barebox"
+if [ ! -e $target ]; then
+	echo error update $target not exist!
+	exit 1
+else
+	erase $target && tftp ${global.prj.name}-${global.prj.ver}/zbarebox.bin $target && echo Update OK
+	exit 0
+fi
+echo Update Fail
+exit 1
diff --git a/arch/arm/boards/greatfirst/com9200/init.c b/arch/arm/boards/greatfirst/com9200/init.c
new file mode 100644
index 0000000..73107bf
--- /dev/null
+++ b/arch/arm/boards/greatfirst/com9200/init.c
@@ -0,0 +1,164 @@
+#include <common.h>
+#include <net.h>
+#include <init.h>
+#include <environment.h>
+#include <asm/armlinux.h>
+#include <generated/mach-types.h>
+#include <partition.h>
+#include <fs.h>
+#include <fcntl.h>
+#include <io.h>
+#include <sizes.h>
+#include <asm/hardware.h>
+#include <mach/at91_pmc.h>
+#include <mach/board.h>
+#include <mach/gpio.h>
+#include <mach/io.h>
+
+#include <globalvar.h>
+#include <linux/stringify.h>
+#include <mach/at91rm9200_mc.h>
+
+#include "basic_init.h"
+
+static void nor_hw_init(void)
+{
+	/* ?? barebox ? flash ????????????
+	 * arch/arm/mach-at91/at91rm9200_lowlevel_init.c:reset() ???????????
+	 * boot.bin->boot-zbarebox.bin ????????????????? flash(ncs0) ???????
+	 * ??????????
+	 */
+	/* EBI Chip Select Assignment Register
+	 * ? cs0 ??????????
+	 */
+	at91_sys_write(AT91_EBI_CSA, (at91_sys_read(AT91_EBI_CSA) & ~AT91_EBI_CS0A) | AT91_EBI_CS0A_SMC);
+
+	/* EBI Configuration Register
+	 * ?? D15..0 ????
+	 */
+	at91_sys_write(AT91_EBI_CFGR, CONFIG_SYS_EBI_CFGR_VAL);
+
+	/* SMC2_CSR[0]: 16bit, 2 TDF, 4 WS */
+	at91_sys_write(AT91_SMC_CSR(0), CONFIG_SYS_SMC_CSR0_VAL);
+}
+
+static void add_nor_device(void)
+{
+	nor_hw_init();
+
+	add_cfi_flash_device(0, AT91_CHIPSELECT_0, BOARD_NOR_FLASH_SIZE, 0);
+
+/* 	if (IS_ENABLED(CONFIG_DRIVER_CFI) && cdev_by_name("nor0")) {
+ * 		devfs_add_partition("nor0", 0x00000, 0x40000, DEVFS_PARTITION_FIXED, "self");
+ * 		devfs_add_partition("nor0", 0x40000, 0x20000, DEVFS_PARTITION_FIXED, "env0");
+ * 	}
+ */
+}
+
+#ifdef CONFIG_LED_GPIO
+struct gpio_led ek_leds[] = {
+	{
+		.gpio		= AT91_PIN_PC14,
+		.active_low	= 1,
+		.led = {
+			.name = "DS2-green",
+		},
+	}, {
+		.gpio		= AT91_PIN_PC15,
+		.active_low	= 1,
+		.led = {
+			.name = "DS3-yellow",
+		},
+	}, {
+		.gpio		= AT91_PIN_PC13,
+		.active_low	= 1,
+		.led = {
+			.name = "DS4-red",
+		},
+	}, {
+		.gpio		= AT91_PIN_PC12,
+		.active_low	= 1,
+		.led = {
+			.name = "DS5-yellow",
+		},
+	},
+};
+
+static void add_led_device(void)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(ek_leds); i++) {
+		at91_set_gpio_output(ek_leds[i].gpio, ek_leds[i].active_low);
+		led_gpio_register(&ek_leds[i]);
+	}
+	led_set_trigger(LED_TRIGGER_HEARTBEAT, &ek_leds[0].led);
+}
+#else
+static void add_led_device(void) {}
+#endif
+
+static struct atmel_nand_data nand_pdata = {
+	.ale		= 7,
+	.cle		= 6,
+/*	.det_pin	= ... not connected */
+	.rdy_pin	= AT91_PIN_PC2,
+	.enable_pin	= AT91_PIN_PC0,
+#if defined(CONFIG_MTD_NAND_ATMEL_BUSWIDTH_16)
+	.bus_width_16	= 1,
+#else
+	.bus_width_16	= 0,
+#endif
+	/* on flash bad block table */
+/* 	.on_flash_bbt	= 1,
+ */
+};
+
+static void add_nand_device(void)
+{
+	at91_add_device_nand(&nand_pdata);
+}
+
+
+static int devices_init(void)
+{
+	init_eth_device();
+
+	add_led_device();
+	add_nor_device();
+	add_nand_device();
+
+	armlinux_set_bootparams((void *)(AT91_CHIPSELECT_1 + 0x100));
+	armlinux_set_architecture(MACH_TYPE_SSR600);
+
+	return 0;
+}
+device_initcall(devices_init);
+
+static int my_init_env(void)
+{
+	globalvar_add_simple("prj.name");
+	globalvar_add_simple("prj.ver");
+	globalvar_add_simple("tmpmem.base");
+	globalvar_add_simple("tmpmem.size");
+	setenv("global.prj.name", __stringify(PROJECT_NAME));
+	setenv("global.prj.ver", __stringify(PROJECT_VERSION));
+	setenv("global.tmpmem.base", __stringify(TEMP_MEM_BASE));
+	setenv("global.tmpmem.size", __stringify(TEMP_MEM_SIZE));
+
+	/* ???????? ``addpart -n /dev/mem 16M at 0x20100000(tempmem)'' ????? */
+	add_mem_device("tempmem", TEMP_MEM_BASE, TEMP_MEM_SIZE, IORESOURCE_MEM_WRITEABLE);
+
+	return 0;
+}
+late_initcall(my_init_env);
+
+/* ??? barebox ?????????????????, ????????? */
+static int late_init(void)
+{
+	init_ip();
+
+	return 0;
+}
+late_initcall(late_init);
+
diff --git a/arch/arm/boards/greatfirst/com9200/tiny_init.c b/arch/arm/boards/greatfirst/com9200/tiny_init.c
new file mode 100644
index 0000000..9cdc5d7
--- /dev/null
+++ b/arch/arm/boards/greatfirst/com9200/tiny_init.c
@@ -0,0 +1,50 @@
+#include <common.h>
+#include <net.h>
+#include <init.h>
+#include <environment.h>
+#include <asm/armlinux.h>
+#include <generated/mach-types.h>
+#include <partition.h>
+#include <fs.h>
+#include <fcntl.h>
+#include <io.h>
+#include <sizes.h>
+#include <asm/hardware.h>
+#include <mach/at91_pmc.h>
+#include <mach/board.h>
+#include <mach/gpio.h>
+#include <mach/io.h>
+
+#include <linux/stringify.h>
+#include "basic_init.h"
+
+static int devices_init(void)
+{
+	init_eth_device();
+
+	return 0;
+}
+device_initcall(devices_init);
+
+#define FILENAME "zbarebox.bin"
+#define RUNADDR "0x21000000"
+#define DL "tftp "__stringify(PROJECT_NAME)"-"__stringify(PROJECT_VERSION)"/"FILENAME
+#define CP "memcpy -s"FILENAME" 0 "RUNADDR
+#define RUN "go "RUNADDR
+/* ??? barebox ????????????????? */
+static int late_init(void)
+{
+	int ret;
+
+	init_ip();
+
+	ret = run_command(DL, 0);
+	if(!ret)
+		ret = run_command(CP, 0);
+	if(!ret)
+		ret = run_command(RUN, 0);
+
+	return 0;
+}
+late_initcall(late_init);
+
diff --git a/arch/arm/pbl/Makefile b/arch/arm/pbl/Makefile
index 2999473..ff5e682 100644
--- a/arch/arm/pbl/Makefile
+++ b/arch/arm/pbl/Makefile
@@ -12,6 +12,9 @@ targets := zbarebox.lds zbarebox zbarebox.bin zbarebox.S \
 extra-y       += piggy.gzip piggy.lzo piggy.lzma piggy.xzkern zbarebox.map

 ifeq ($(CONFIG_GREATFIRST),y)
+quiet_cmd_addmd5sum = ADDMD5SUM $@
+      cmd_addmd5sum = ( cp $@ $@.bak; cat $(objtree)/barebox.bin.md5 >> $@ )
+
 CPFILENAME = $(TFTP_ROOT_DIR)/$(PROJECT_NAME)-$(PROJECT_VERSION)/$(if $(CONFIG_TINY),boot-)$(notdir $@)
 DEFCFGNAME = $(PROJECT_NAME)$(if $(CONFIG_TINY),t)$(if $(CONFIG_BOARD_CPU),-$(CONFIG_BOARD_CPU))_defconfig
 GFPOSTPROC = \
@@ -21,11 +24,13 @@ GFPOSTPROC = \
 	   echo "  FILE-SIZE: $$actual bytes" 1>&2
 else
 GFPOSTPROC  = :
+cmd_addmd5sum =
 endif

 $(obj)/zbarebox.bin:	$(obj)/zbarebox FORCE
 	$(call if_changed,objcopy)
 	$(call cmd,check_file_size,$(CONFIG_BAREBOX_MAX_IMAGE_SIZE))
+	$(call cmd,addmd5sum)
 	@$(GFPOSTPROC)
 	$(Q)$(kecho) '  Barebox: $@ is ready'
------------------------------------

-- 
Best Regards,
zzs




From zzs213 at 126.com  Mon Nov 26 01:00:53 2012
From: zzs213 at 126.com (=?utf-8?B?5byg5b+g5bGx?=)
Date: Mon, 26 Nov 2012 14:00:53 +0800
Subject: what's the meaning of 'dyn'
Message-ID: <20121126060053.GD19824@greatfirst.com>

There is a line in defaultenv-2/base/bin/boot:

    global -r linux.bootargs.dyn.

What's then meaning of the word 'dyn'? Does it mean dynamic?

-- 
Best Regards,
zzs




From s.hauer at pengutronix.de  Mon Nov 26 02:31:00 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 26 Nov 2012 08:31:00 +0100
Subject: [PATCH 0/4] at91: some fixes
In-Reply-To: <20121123155224.GV8327@game.jcrosoft.org>
References: <20121123155224.GV8327@game.jcrosoft.org>
Message-ID: <20121126073100.GP10369@pengutronix.de>

On Fri, Nov 23, 2012 at 04:52:24PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> HI,
> 
> 	some fixe for at91
> 
> 	they are needed for at91sam9n12 support
> 
> The following changes since commit c7a729aefe13104b6f3a9f2150a9e993bb510d43:
> 
>   Merge branch 'for-next/m25p80' (2012-11-21 11:54:34 +0100)
> 
> are available in the git repository at:
> 
> 
>   git://git.jcrosoft.org/barebox.git delivery/at91_fixes

Applied, thanks

Sascha

> 
> for you to fetch changes up to 02d37b5d4598cd3ffea4730aa027c8c04ab1f58d:
> 
>   Revert "mtd: atmel_nand: optimize read/write buffer functions" (2012-11-22 02:21:14 +0800)
> 
> ----------------------------------------------------------------
> Jean-Christophe PLAGNIOL-VILLARD (4):
>       at91: fix timer rate
>       atmel_nand: fix pmecc timeout
>       at91: clock: check overclock for sam9260/9261/9263/9rl
>       Revert "mtd: atmel_nand: optimize read/write buffer functions"
> 
>  arch/arm/mach-at91/at91sam926x_time.c |    7 ++++++-
>  arch/arm/mach-at91/clock.c            |   12 ++++++++++++
>  drivers/mtd/nand/atmel_nand.c         |   33 +++++++++++++++++++++++++--------
>  drivers/mtd/nand/atmel_nand_ecc.h     |    2 +-
>  4 files changed, 44 insertions(+), 10 deletions(-)
> 
> Best Regards,
> J.
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Mon Nov 26 02:34:45 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 26 Nov 2012 08:34:45 +0100
Subject: [PATCH 0/2] at91: at91sam9n12 support
In-Reply-To: <20121123155945.GW8327@game.jcrosoft.org>
References: <20121123155945.GW8327@game.jcrosoft.org>
Message-ID: <20121126073445.GQ10369@pengutronix.de>

On Fri, Nov 23, 2012 at 04:59:45PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> Hi,
> 
> 	this patch serie add the support of the at91sam9n12 with it's
> 	reference board the n12ek
> 
> 	we do not switch to the defaultenv-2 as I need nfs boot with symlink
> 	and this is not support yet in it
> 
> 	I'll switch all my platform when we will have it
> 
> 	This patch serie depends on the at91_fixes send just before
> 
> 
> wing changes since commit 02d37b5d4598cd3ffea4730aa027c8c04ab1f58d:
> 
>   Revert "mtd: atmel_nand: optimize read/write buffer functions" (2012-11-22 02:21:14 +0800)
> 
> are available in the git repository at:
> 
>   git://git.jcrosoft.org/barebox.git delivery/at91sam9n12

Applied, thanks

Sascha

> 
> for you to fetch changes up to 96a5ef4e557a816e50e66d9f708934e68b49ea76:
> 
>   at91: add at91sam9n12ek board support (2012-11-22 02:24:59 +0800)
> 
> ----------------------------------------------------------------
> Jean-Christophe PLAGNIOL-VILLARD (2):
>       arm: at91: add at91sam9n12 support
>       at91: add at91sam9n12ek board support
> 
>  arch/arm/Makefile                                    |    1 +
>  arch/arm/boards/at91sam9n12ek/Makefile               |    1 +
>  arch/arm/boards/at91sam9n12ek/config.h               |    6 ++
>  arch/arm/boards/at91sam9n12ek/env/bin/init_board     |   50 +++++++++++++
>  arch/arm/boards/at91sam9n12ek/env/config             |   41 +++++++++++
>  arch/arm/boards/at91sam9n12ek/init.c                 |  270 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  arch/arm/configs/at91sam9n12ek_defconfig             |   87 +++++++++++++++++++++++
>  arch/arm/mach-at91/Kconfig                           |   23 ++++++
>  arch/arm/mach-at91/Makefile                          |    1 +
>  arch/arm/mach-at91/at91sam9n12.c                     |  233 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  arch/arm/mach-at91/at91sam9n12_devices.c             |  374 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  arch/arm/mach-at91/clock.c                           |   15 ++--
>  arch/arm/mach-at91/gpio.c                            |    2 +-
>  arch/arm/mach-at91/include/mach/at91sam9n12.h        |  166 ++++++++++++++++++++++++++++++++++++++++++++
>  arch/arm/mach-at91/include/mach/at91sam9n12_matrix.h |   98 ++++++++++++++++++++++++++
>  arch/arm/mach-at91/include/mach/board.h              |    1 +
>  arch/arm/mach-at91/include/mach/cpu.h                |    7 ++
>  arch/arm/mach-at91/include/mach/hardware.h           |    2 +
>  18 files changed, 1372 insertions(+), 6 deletions(-)
>  create mode 100644 arch/arm/boards/at91sam9n12ek/Makefile
>  create mode 100644 arch/arm/boards/at91sam9n12ek/config.h
>  create mode 100644 arch/arm/boards/at91sam9n12ek/env/bin/init_board
>  create mode 100644 arch/arm/boards/at91sam9n12ek/env/config
>  create mode 100644 arch/arm/boards/at91sam9n12ek/init.c
>  create mode 100644 arch/arm/configs/at91sam9n12ek_defconfig
>  create mode 100644 arch/arm/mach-at91/at91sam9n12.c
>  create mode 100644 arch/arm/mach-at91/at91sam9n12_devices.c
>  create mode 100644 arch/arm/mach-at91/include/mach/at91sam9n12.h
>  create mode 100644 arch/arm/mach-at91/include/mach/at91sam9n12_matrix.h
> 
> Best Regards,
> J.
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Mon Nov 26 02:56:51 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 26 Nov 2012 08:56:51 +0100
Subject: [PATCH] xymodem.c: fix compiler warning
In-Reply-To: <87lidq3gnb.fsf@free.fr>
References: <1353770926-24496-1-git-send-email-antonynpavlov@gmail.com>
 <87lidq3gnb.fsf@free.fr>
Message-ID: <20121126075651.GS10369@pengutronix.de>

On Sat, Nov 24, 2012 at 09:11:36PM +0100, Robert Jarzmik wrote:
> Antony Pavlov <antonynpavlov at gmail.com> writes:

Applied, thanks

Sascha

> 
> > Fixes:
> >  lib/xymodem.c:558: warning: no previous prototype for ?do_load_serial_xmodem?
> >  lib/xymodem.c:572: warning: no previous prototype for ?do_load_serial_ymodem?
> >  lib/xymodem.c:586: warning: no previous prototype for ?do_load_serial_ymodemg?
> >
> > Signed-off-by: Antony Pavlov <antonynpavlov at gmail.com>
> Indeed.
> Acked-by: Robert Jarzmik <robert.jarzmik at free.fr>
> 
> -- 
> Robert
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Mon Nov 26 03:00:30 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 26 Nov 2012 09:00:30 +0100
Subject: [PATCH 0/2] Some corrections on archosG9
In-Reply-To: <1353727464-15175-1-git-send-email-vicencb@gmail.com>
References: <1353727464-15175-1-git-send-email-vicencb@gmail.com>
Message-ID: <20121126080030.GT10369@pengutronix.de>

On Sat, Nov 24, 2012 at 04:24:22AM +0100, Vicente Bergas wrote:
> In the patch series for archosG9 there were an attempt to improve file
> transfers by reading files at once, but finally this solution was discarded.
> Today I've checked the repository and found this solution there, perhaps this
> is a misunderstanding and it's corrected here.
> Sorry for not checking before.
> 
> The other change is just the inverse: a submitted patch that was not applied.
> 
> Vicente Bergas (2):
>   uimage: fix misunderstanding in common/uimage.c
>   archosg9: improve configuration
> 
>  arch/arm/boards/archosg9/env/config       |  4 +++-
>  arch/arm/boards/archosg9/env/init/usbboot |  9 +++++----
>  arch/arm/configs/archosg9_defconfig       |  2 +-
>  common/uimage.c                           | 24 ------------------------
>  4 files changed, 9 insertions(+), 30 deletions(-)

Applied, thanks

As a side note, I still have this patch in my queue which fixes
read_file for tftp severs which do not pass the size. My tftp server at
home is one of these, I'll repost the patch once I tested it again.

Sascha


>From 1508618b3bc53abf122b9c7473f468e67b391b19 Mon Sep 17 00:00:00 2001
From: Sascha Hauer <s.hauer at pengutronix.de>
Date: Sun, 18 Mar 2012 17:59:46 +0100
Subject: [PATCH] read_file: Make it work on tftp servers which do not pass
 size

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 fs/fs.c      |   11 +++++++++++
 fs/tftp.c    |    5 ++++-
 include/fs.h |    2 ++
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/fs/fs.c b/fs/fs.c
index db4621a..871dc26 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -41,10 +41,21 @@ void *read_file(const char *filename, size_t *size)
 	int fd;
 	struct stat s;
 	void *buf = NULL;
+	const char *tmpfile = "/_read_file_tmp";
+	int ret;
 
+again:
 	if (stat(filename, &s))
 		return NULL;
 
+	if (s.st_size == FILESIZE_MAX) {
+		ret = copy_file(filename, tmpfile, 0);
+		if (ret)
+			return NULL;
+		filename = tmpfile;
+		goto again;
+	}
+
 	buf = xzalloc(s.st_size + 1);
 
 	fd = open(filename, O_RDONLY);
diff --git a/fs/tftp.c b/fs/tftp.c
index b58d6fc..13e117a 100644
--- a/fs/tftp.c
+++ b/fs/tftp.c
@@ -590,7 +590,10 @@ static int tftp_stat(struct device_d *dev, const char *filename, struct stat *s)
 		return PTR_ERR(priv);
 
 	s->st_mode = S_IFREG | S_IRWXU | S_IRWXG | S_IRWXO;
-	s->st_size = priv->filesize;
+	if (priv->filesize)
+		s->st_size = priv->filesize;
+	else
+		s->st_size = FILESIZE_MAX;
 
 	tftp_do_close(priv);
 
diff --git a/include/fs.h b/include/fs.h
index 3d5714c..b6a46bb 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -147,6 +147,8 @@ int protect(int fd, size_t count, unsigned long offset, int prot);
 int protect_file(const char *file, int prot);
 void *memmap(int fd, int flags);
 
+#define FILESIZE_MAX	((size_t)-1)
+
 #define PROT_READ	1
 #define PROT_WRITE	2
 
-- 
1.7.10.4

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Mon Nov 26 03:05:24 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 26 Nov 2012 09:05:24 +0100
Subject: [RFC 1/3] MIPS: add pre-bootloader (pbl) image support
In-Reply-To: <CAA4bVAFgwUzppRGvq1SAnSYqwOA3pXKmihdOZ=6tO=vAKuNaoQ@mail.gmail.com>
References: <1353154239-31574-1-git-send-email-antonynpavlov@gmail.com>
 <1353154239-31574-2-git-send-email-antonynpavlov@gmail.com>
 <20121120075925.GC10369@pengutronix.de>
 <CAA4bVAFgwUzppRGvq1SAnSYqwOA3pXKmihdOZ=6tO=vAKuNaoQ@mail.gmail.com>
Message-ID: <20121126080524.GU10369@pengutronix.de>

On Sat, Nov 24, 2012 at 07:45:01PM +0400, Antony Pavlov wrote:
> Sorry for delay.
> 
> On 20 November 2012 11:59, Sascha Hauer <s.hauer at pengutronix.de> wrote:
> > On Sat, Nov 17, 2012 at 04:10:37PM +0400, Antony Pavlov wrote:
> >> This patch is based on ARM pbl support and allows
> >> creating a pre-bootloader binary for compressed image.
> >>
> >> Signed-off-by: Antony Pavlov <antonynpavlov at gmail.com>
> >> ---
> >> +     .macro  ADR rd label temp
> >> +     .set    push
> >> +     .set    noreorder
> >> +     move    \temp, ra                       # preserve ra beforehand
> >> +     bal     _pc
> >> +      nop
> >
> > This file contains some whitespace damages you could cleanup along the
> > way.
> 
> If you are about this fragment
> >> +     bal     _pc
> >> +      nop
> 
> then there is no whitespace damage --- the 'nop' instruction is in the
> delay slot of the branch instruction (bal).

Ok, forget this one. I'm not familiar with Mips assembly.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Mon Nov 26 03:07:27 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 26 Nov 2012 09:07:27 +0100
Subject: [PATCH] phylib: fix compiler warning
In-Reply-To: <1353775562-2747-1-git-send-email-antonynpavlov@gmail.com>
References: <1353775562-2747-1-git-send-email-antonynpavlov@gmail.com>
Message-ID: <20121126080727.GV10369@pengutronix.de>

On Sat, Nov 24, 2012 at 08:46:02PM +0400, Antony Pavlov wrote:
> fixes:
>  drivers/net/phy/phy.c:57: warning: no previous prototype for ?phy_device_create?
> 
> Signed-off-by: Antony Pavlov <antonynpavlov at gmail.com>

Applied, thanks

Sascha

> ---
>  drivers/net/phy/phy.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index 59df742..ed185e1 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -136,7 +136,7 @@ int phy_scan_fixups(struct phy_device *phydev)
>  	return 0;
>  }
>  
> -struct phy_device *phy_device_create(struct mii_bus *bus, int addr, int phy_id)
> +static struct phy_device *phy_device_create(struct mii_bus *bus, int addr, int phy_id)
>  {
>  	struct phy_device *dev;
>  
> -- 
> 1.7.10.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Mon Nov 26 03:16:02 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 26 Nov 2012 09:16:02 +0100
Subject: [PATCH] Cleanup Kconfig files
In-Reply-To: <1353783209-16451-1-git-send-email-shc_work@mail.ru>
References: <1353783209-16451-1-git-send-email-shc_work@mail.ru>
Message-ID: <20121126081602.GW10369@pengutronix.de>

On Sat, Nov 24, 2012 at 10:53:29PM +0400, Alexander Shiyan wrote:
> This patch provides a global cleanup barebox Kconfig files. This includes
> replacing spaces to tabs, formatting in accordance format, removing
> extraneous lines and spaces. No functional changes.
> 
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index 3afd885..01fe9de 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -19,7 +19,7 @@ config ARM_LINUX
>  config HAVE_MACH_ARM_HEAD
>  	bool
>  
> -menu "System Type                   "
> +menu "System Type"

These whitespaces are present on purpose. They are there for aligning
the arrows in menus in make menuconfig. I tend to say that this is a
good change anyway, because counting the spaces to align line lengths
is something which hurts during review (and I can't remember having
done this before).

If nobody objects I'll apply it. If somebody objects, I probably say him
that he should provide a patch for Kconfig instead.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Mon Nov 26 03:52:33 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 26 Nov 2012 09:52:33 +0100
Subject: [RFC 0/3] commands: md, mw: add '-x' option (swap bytes)
In-Reply-To: <1353705059-7792-1-git-send-email-antonynpavlov@gmail.com>
References: <1353705059-7792-1-git-send-email-antonynpavlov@gmail.com>
Message-ID: <20121126085233.GA10369@pengutronix.de>

On Sat, Nov 24, 2012 at 01:10:56AM +0400, Antony Pavlov wrote:
> Most of my MIPS boards run barebox in big-endian mode, but
> sometimes I need see state of little-endian registers
> (e.g. registers of PCI-connected peripherals) and it is not
> very hande to swap bytes manually.
> 
> This patch series add to memory commands (md and mw) ability
> to swap bytes "on the fly".
> 
> [RFC 1/3] add swab (swap bytes) option to memory_display()
> [RFC 2/3] commands: md: add '-x' option (swap bytes)
> [RFC 3/3] commands: mw: add '-x' option (swap bytes)

I like it :)

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From antonynpavlov at gmail.com  Mon Nov 26 04:51:38 2012
From: antonynpavlov at gmail.com (Antony Pavlov)
Date: Mon, 26 Nov 2012 13:51:38 +0400
Subject: commands: md, mw: add the '-x' option (swap bytes)
Message-ID: <1353923501-13372-1-git-send-email-antonynpavlov@gmail.com>

Most of my MIPS boards run barebox in big-endian mode, but
sometimes I need see state of little-endian registers
(e.g. registers of PCI-connected peripherals) and it is not
very handy to swap bytes manually.

This patch series adds to memory commands md and mw the ability
to swap bytes "on the fly".

[PATCH 1/3] mem: add the swab (swap bytes) option to
[PATCH 2/3] commands: md: add the '-x' option (swap bytes)
[PATCH 3/3] commands: mw: add the '-x' option (swap bytes)


From antonynpavlov at gmail.com  Mon Nov 26 04:51:39 2012
From: antonynpavlov at gmail.com (Antony Pavlov)
Date: Mon, 26 Nov 2012 13:51:39 +0400
Subject: [PATCH 1/3] mem: add the swab (swap bytes) option to memory_display()
In-Reply-To: <1353923501-13372-1-git-send-email-antonynpavlov@gmail.com>
References: <1353923501-13372-1-git-send-email-antonynpavlov@gmail.com>
Message-ID: <1353923501-13372-2-git-send-email-antonynpavlov@gmail.com>

Signed-off-by: Antony Pavlov <antonynpavlov at gmail.com>
---
 commands/mem.c   |   17 +++++++++++++----
 commands/spi.c   |    4 ++--
 fs/tftp.c        |    2 +-
 include/common.h |    2 +-
 net/net.c        |    2 +-
 5 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/commands/mem.c b/commands/mem.c
index 6fbc7cc..a42b7ba 100644
--- a/commands/mem.c
+++ b/commands/mem.c
@@ -51,7 +51,7 @@ static char *DEVMEM = "/dev/mem";
  */
 #define DISP_LINE_LEN	16
 
-int memory_display(char *addr, loff_t offs, ulong nbytes, int size)
+int memory_display(char *addr, loff_t offs, ulong nbytes, int size, int swab)
 {
 	ulong linebytes, i;
 	u_char	*cp;
@@ -73,9 +73,17 @@ int memory_display(char *addr, loff_t offs, ulong nbytes, int size)
 
 		for (i = 0; i < linebytes; i += size) {
 			if (size == 4) {
-				count -= printf(" %08x", (*uip++ = *((uint *)addr)));
+				u32 res;
+				res = (*uip++ = *((uint *)addr));
+				if (swab)
+					res = __swab32(res);
+				count -= printf(" %08x", res);
 			} else if (size == 2) {
-				count -= printf(" %04x", (*usp++ = *((ushort *)addr)));
+				u16 res;
+				res = (*usp++ = *((ushort *)addr));
+				if (swab)
+					res = __swab16(res);
+				count -= printf(" %04x", res);
 			} else {
 				count -= printf(" %02x", (*ucp++ = *((u_char *)addr)));
 			}
@@ -195,7 +203,8 @@ static int do_mem_md(int argc, char *argv[])
 		if (!r)
 			goto out;
 
-		if ((ret = memory_display(rw_buf, start, r, mode >> O_RWSIZE_SHIFT)))
+		if ((ret = memory_display(rw_buf, start, r,
+				mode >> O_RWSIZE_SHIFT, 0)))
 			goto out;
 
 		start += r;
diff --git a/commands/spi.c b/commands/spi.c
index 899bf62..2f6b430 100644
--- a/commands/spi.c
+++ b/commands/spi.c
@@ -101,12 +101,12 @@ static int do_spi(int argc, char *argv[])
 		printf("\n");
 
 		printf("wrote %i bytes\n", count);
-		memory_display(tx_buf, 0, count, byte_per_word);
+		memory_display(tx_buf, 0, count, byte_per_word, 0);
 
 		printf("read %i bytes\n", read);
 	}
 
-	memory_display(rx_buf, 0, read, byte_per_word);
+	memory_display(rx_buf, 0, read, byte_per_word, 0);
 
 out:
 	free(rx_buf);
diff --git a/fs/tftp.c b/fs/tftp.c
index dff41e9..98cbb37 100644
--- a/fs/tftp.c
+++ b/fs/tftp.c
@@ -227,7 +227,7 @@ static void tftp_parse_oack(struct file_priv *priv, unsigned char *pkt, int len)
 
 	debug("got OACK\n");
 #ifdef DEBUG
-	memory_display(pkt, 0, len, 1);
+	memory_display(pkt, 0, len, 1, 0);
 #endif
 
 	s = pkt;
diff --git a/include/common.h b/include/common.h
index e30774a..6256879 100644
--- a/include/common.h
+++ b/include/common.h
@@ -226,7 +226,7 @@ int run_shell(void);
 #define PAGE_SIZE	4096
 #define PAGE_SHIFT	12
 
-int memory_display(char *addr, loff_t offs, ulong nbytes, int size);
+int memory_display(char *addr, loff_t offs, ulong nbytes, int size, int swab);
 
 extern const char version_string[];
 #ifdef CONFIG_BANNER
diff --git a/net/net.c b/net/net.c
index 3ac098f..639bc2d 100644
--- a/net/net.c
+++ b/net/net.c
@@ -511,7 +511,7 @@ static void net_bad_packet(unsigned char *pkt, int len)
 	 * We received a bad packet. for now just dump it.
 	 * We could add more sophisticated debugging here
 	 */
-	memory_display(pkt, 0, len, 1);
+	memory_display(pkt, 0, len, 1, 0);
 #endif
 }
 
-- 
1.7.10.4



From antonynpavlov at gmail.com  Mon Nov 26 04:51:40 2012
From: antonynpavlov at gmail.com (Antony Pavlov)
Date: Mon, 26 Nov 2012 13:51:40 +0400
Subject: [PATCH 2/3] commands: md: add the '-x' option (swap bytes)
In-Reply-To: <1353923501-13372-1-git-send-email-antonynpavlov@gmail.com>
References: <1353923501-13372-1-git-send-email-antonynpavlov@gmail.com>
Message-ID: <1353923501-13372-3-git-send-email-antonynpavlov@gmail.com>

Signed-off-by: Antony Pavlov <antonynpavlov at gmail.com>
---
 commands/mem.c |   24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/commands/mem.c b/commands/mem.c
index a42b7ba..9873e52 100644
--- a/commands/mem.c
+++ b/commands/mem.c
@@ -136,7 +136,7 @@ static int open_and_lseek(const char *filename, int mode, loff_t pos)
 }
 
 static int mem_parse_options(int argc, char *argv[], char *optstr, int *mode,
-		char **sourcefile, char **destfile)
+		char **sourcefile, char **destfile, int *swab)
 {
 	int opt;
 
@@ -157,6 +157,9 @@ static int mem_parse_options(int argc, char *argv[], char *optstr, int *mode,
 		case 'd':
 			*destfile = optarg;
 			break;
+		case 'x':
+			*swab = 1;
+			break;
 		default:
 			return -1;
 		}
@@ -173,11 +176,13 @@ static int do_mem_md(int argc, char *argv[])
 	int fd;
 	char *filename = DEVMEM;
 	int mode = O_RWSIZE_4;
+	int swab = 0;
 
 	if (argc < 2)
 		return COMMAND_ERROR_USAGE;
 
-	if (mem_parse_options(argc, argv, "bwls:", &mode, &filename, NULL) < 0)
+	if (mem_parse_options(argc, argv, "bwls:x", &mode, &filename, NULL,
+			&swab) < 0)
 		return 1;
 
 	if (optind < argc) {
@@ -204,7 +209,7 @@ static int do_mem_md(int argc, char *argv[])
 			goto out;
 
 		if ((ret = memory_display(rw_buf, start, r,
-				mode >> O_RWSIZE_SHIFT, 0)))
+				mode >> O_RWSIZE_SHIFT, swab)))
 			goto out;
 
 		start += r;
@@ -225,6 +230,7 @@ static const __maybe_unused char cmd_md_help[] =
 "  -b          output in bytes\n"
 "  -w          output in halfwords (16bit)\n"
 "  -l          output in words (32bit)\n"
+"  -x          swap bytes at output\n"
 "\n"
 "Memory regions:\n"
 "Memory regions can be specified in two different forms: start+size\n"
@@ -250,7 +256,8 @@ static int do_mem_mw(int argc, char *argv[])
 	int mode = O_RWSIZE_4;
 	loff_t adr;
 
-	if (mem_parse_options(argc, argv, "bwld:", &mode, NULL, &filename) < 0)
+	if (mem_parse_options(argc, argv, "bwld:", &mode, NULL, &filename,
+			NULL) < 0)
 		return 1;
 
 	if (optind + 1 >= argc)
@@ -318,7 +325,8 @@ static int do_mem_cmp(int argc, char *argv[])
 	int     offset = 0;
 	struct  stat statbuf;
 
-	if (mem_parse_options(argc, argv, "bwls:d:", &mode, &sourcefile, &destfile) < 0)
+	if (mem_parse_options(argc, argv, "bwls:d:", &mode, &sourcefile,
+			&destfile, NULL) < 0)
 		return 1;
 
 	if (optind + 2 > argc)
@@ -425,7 +433,8 @@ static int do_mem_cp(int argc, char *argv[])
 	struct stat statbuf;
 	int ret = 0;
 
-	if (mem_parse_options(argc, argv, "bwls:d:", &mode, &sourcefile, &destfile) < 0)
+	if (mem_parse_options(argc, argv, "bwls:d:", &mode, &sourcefile,
+			&destfile, NULL) < 0)
 		return 1;
 
 	if (optind + 2 > argc)
@@ -530,7 +539,8 @@ static int do_memset(int argc, char *argv[])
 	int     ret = 1;
 	char	*file = DEVMEM;
 
-	if (mem_parse_options(argc, argv, "bwld:", &mode, NULL, &file) < 0)
+	if (mem_parse_options(argc, argv, "bwld:", &mode, NULL, &file,
+			NULL) < 0)
 		return 1;
 
 	if (optind + 3 > argc)
-- 
1.7.10.4



From antonynpavlov at gmail.com  Mon Nov 26 04:51:41 2012
From: antonynpavlov at gmail.com (Antony Pavlov)
Date: Mon, 26 Nov 2012 13:51:41 +0400
Subject: [PATCH 3/3] commands: mw: add the '-x' option (swap bytes)
In-Reply-To: <1353923501-13372-1-git-send-email-antonynpavlov@gmail.com>
References: <1353923501-13372-1-git-send-email-antonynpavlov@gmail.com>
Message-ID: <1353923501-13372-4-git-send-email-antonynpavlov@gmail.com>

Signed-off-by: Antony Pavlov <antonynpavlov at gmail.com>
---
 commands/mem.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/commands/mem.c b/commands/mem.c
index 9873e52..51aa04d 100644
--- a/commands/mem.c
+++ b/commands/mem.c
@@ -255,9 +255,10 @@ static int do_mem_mw(int argc, char *argv[])
 	char *filename = DEVMEM;
 	int mode = O_RWSIZE_4;
 	loff_t adr;
+	int swab = 0;
 
-	if (mem_parse_options(argc, argv, "bwld:", &mode, NULL, &filename,
-			NULL) < 0)
+	if (mem_parse_options(argc, argv, "bwld:x", &mode, NULL, &filename,
+			&swab) < 0)
 		return 1;
 
 	if (optind + 1 >= argc)
@@ -280,10 +281,14 @@ static int do_mem_mw(int argc, char *argv[])
 			break;
 		case O_RWSIZE_2:
 			val16 = simple_strtoul(argv[optind], NULL, 0);
+			if (swab)
+				val16 = __swab16(val16);
 			ret = write(fd, &val16, 2);
 			break;
 		case O_RWSIZE_4:
 			val32 = simple_strtoul(argv[optind], NULL, 0);
+			if (swab)
+				val32 = __swab32(val32);
 			ret = write(fd, &val32, 4);
 			break;
 		}
-- 
1.7.10.4



From s.hauer at pengutronix.de  Mon Nov 26 05:13:26 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 26 Nov 2012 11:13:26 +0100
Subject: [PATCH 2/3] debug_ll: Add some usage comments
In-Reply-To: <1353924807-519-1-git-send-email-s.hauer@pengutronix.de>
References: <1353924807-519-1-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1353924807-519-2-git-send-email-s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 common/Kconfig     |    2 ++
 include/debug_ll.h |   16 +++++++++++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/common/Kconfig b/common/Kconfig
index d60db80..57119dc 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -667,6 +667,8 @@ config DEBUG_LL
 	prompt "low level debug messages"
 	help
 	  Enable this to get low level debug messages during barebox initialization.
+	  This requires SoC specific support. Most SoCs require the debug UART to be
+	  initialized by a debugger or first stage bootloader.
 
 endmenu
 
diff --git a/include/debug_ll.h b/include/debug_ll.h
index c5f2df4..f0034ba 100644
--- a/include/debug_ll.h
+++ b/include/debug_ll.h
@@ -1,4 +1,5 @@
-/* debug_ll.h
+/*
+ * debug_ll.h
  *
  *  written by Marc Singer
  *  12 Feb 2005
@@ -20,6 +21,14 @@
 #define   __INCLUDE_DEBUG_LL_H__
 
 #if defined (CONFIG_DEBUG_LL)
+
+/*
+ * mach/debug_ll.h should implement PUTC_LL. This can be a macro or a static
+ * inline function. Note that several SoCs expect the UART to be initialized
+ * by a debugger or a first stage bootloader. You won't see anything without
+ * this initialization. Depending on the PUTC_LL implementation the board might
+ * also hang in PUTC_LL without proper initialization.
+ */
 # include <mach/debug_ll.h>
 
 # define PUTHEX_LL(value)  ({ unsigned long v = (unsigned long) (value); \
@@ -29,6 +38,11 @@
 			     ch += (ch >= 10) ? 'a' - 10 : '0';\
 			     PUTC_LL (ch); }})
 
+/*
+ * Be careful with PUTS_LL, it only works if the binary is running at the
+ * link address which often is not the case during early startup. If in doubt
+ * don't use it.
+ */
 static __inline__ void PUTS_LL(const char * str)
 {
 	while (*str) {
-- 
1.7.10.4



From s.hauer at pengutronix.de  Mon Nov 26 05:13:27 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 26 Nov 2012 11:13:27 +0100
Subject: [PATCH 3/3] i.MX debug_ll support
In-Reply-To: <1353924807-519-1-git-send-email-s.hauer@pengutronix.de>
References: <1353924807-519-1-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1353924807-519-3-git-send-email-s.hauer@pengutronix.de>

This adds lowlevel debug functions for i.MX. As we have a great variety
of different UARTs on i.MX currently no Kconfig support for chosing the
correct one is added. Instead we expect the user to add the correct
define and issue a compiler warning if he hasn't.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/arm/Kconfig                          |    1 +
 arch/arm/mach-imx/include/mach/debug_ll.h |   46 +++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+)
 create mode 100644 arch/arm/mach-imx/include/mach/debug_ll.h

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 3afd885..cdb5081 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -57,6 +57,7 @@ config ARCH_IMX
 	select COMMON_CLK
 	select CLKDEV_LOOKUP
 	select WATCHDOG_IMX_RESET_SOURCE
+	select HAS_DEBUG_LL
 
 config ARCH_MXS
 	bool "Freescale i.MX23/28 (mxs) based"
diff --git a/arch/arm/mach-imx/include/mach/debug_ll.h b/arch/arm/mach-imx/include/mach/debug_ll.h
new file mode 100644
index 0000000..cb6dd03
--- /dev/null
+++ b/arch/arm/mach-imx/include/mach/debug_ll.h
@@ -0,0 +1,46 @@
+#ifndef __MACH_DEBUG_LL_H__
+#define __MACH_DEBUG_LL_H__
+
+#include <io.h>
+#include <config.h>
+#include <mach/imx1-regs.h>
+#include <mach/imx21-regs.h>
+#include <mach/imx25-regs.h>
+#include <mach/imx27-regs.h>
+#include <mach/imx31-regs.h>
+#include <mach/imx35-regs.h>
+#include <mach/imx51-regs.h>
+#include <mach/imx53-regs.h>
+#include <mach/imx6-regs.h>
+
+/* #define IMX_DEBUG_LL_UART_BASE MXxy_UARTx_BASE_ADDR */
+
+#ifndef IMX_DEBUG_LL_UART_BASE
+#warning define IMX_DEBUG_LL_UART_BASE properly for debug_ll
+#define IMX_DEBUG_LL_UART_BASE 0
+#endif
+
+#define URTX0		0x40		/* Transmitter Register */
+
+#define UCR1		0x80		/* Control Register 1 */
+#define UCR1_UARTEN	(1 << 0)	/* UART enabled */
+
+#define USR2		0x98		/* Status Register 2 */
+#define USR2_TXDC	(1 << 3)	/* Transmitter complete */
+
+static inline void PUTC_LL(int c)
+{
+	void __iomem *base = (void *)IMX_DEBUG_LL_UART_BASE;
+
+	if (!base)
+		return;
+
+	if (!(readl(base + UCR1) & UCR1_UARTEN))
+		return;
+
+	while (!(readl(base + USR2) & USR2_TXDC));
+
+	writel(c, base + URTX0);
+}
+
+#endif /* __MACH_DEBUG_LL_H__ */
-- 
1.7.10.4



From s.hauer at pengutronix.de  Mon Nov 26 05:13:25 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 26 Nov 2012 11:13:25 +0100
Subject: [PATCH 1/3] debug_ll: Let architectures define PUTC_LL directly
Message-ID: <1353924807-519-1-git-send-email-s.hauer@pengutronix.de>

putc already is a regular barebox function. To avoid conflicts and
confusions just let architectures define PUTC_LL directly instead
of going through this addiotional redirection.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/arm/mach-omap/include/mach/debug_ll.h      |    2 +-
 arch/arm/mach-tegra/include/mach/debug_ll.h     |    2 +-
 arch/arm/mach-versatile/include/mach/debug_ll.h |    2 +-
 arch/mips/include/debug_ll_ns16550.h            |    2 +-
 arch/mips/mach-bcm47xx/include/mach/debug_ll.h  |    2 +-
 include/debug_ll.h                              |    1 -
 6 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-omap/include/mach/debug_ll.h b/arch/arm/mach-omap/include/mach/debug_ll.h
index c1fcc9d..b2714c5 100644
--- a/arch/arm/mach-omap/include/mach/debug_ll.h
+++ b/arch/arm/mach-omap/include/mach/debug_ll.h
@@ -39,7 +39,7 @@
 #define LSR		(5 << 2)
 #define THR		(0 << 2)
 
-static inline void putc(char c)
+static inline void PUTC_LL(char c)
 {
 	/* Wait until there is space in the FIFO */
 	while ((readb(UART_BASE + LSR) & LSR_THRE) == 0);
diff --git a/arch/arm/mach-tegra/include/mach/debug_ll.h b/arch/arm/mach-tegra/include/mach/debug_ll.h
index 18024eb..290ad58 100644
--- a/arch/arm/mach-tegra/include/mach/debug_ll.h
+++ b/arch/arm/mach-tegra/include/mach/debug_ll.h
@@ -31,7 +31,7 @@
 #define lsr		(5 << DEBUG_LL_UART_RSHFT)
 #define LSR_THRE	0x20	/* Xmit holding register empty */
 
-static inline void putc(char ch)
+static inline void PUTC_LL(char ch)
 {
 	while (!(__raw_readb(DEBUG_LL_UART_ADDR + lsr) & LSR_THRE))
 		;
diff --git a/arch/arm/mach-versatile/include/mach/debug_ll.h b/arch/arm/mach-versatile/include/mach/debug_ll.h
index 20fbc7c..f91812b 100644
--- a/arch/arm/mach-versatile/include/mach/debug_ll.h
+++ b/arch/arm/mach-versatile/include/mach/debug_ll.h
@@ -19,7 +19,7 @@
 #include <linux/amba/serial.h>
 #include <io.h>
 
-static inline void putc(char c)
+static inline void PUTC_LL(char c)
 {
 	/* Wait until there is space in the FIFO */
 	while (readl(0x101F1000 + UART01x_FR) & UART01x_FR_TXFF);
diff --git a/arch/mips/include/debug_ll_ns16550.h b/arch/mips/include/debug_ll_ns16550.h
index a8b74d2..e9c7ecf 100644
--- a/arch/mips/include/debug_ll_ns16550.h
+++ b/arch/mips/include/debug_ll_ns16550.h
@@ -28,7 +28,7 @@
 
 #define LSR_THRE	0x20	/* Xmit holding register empty */
 
-static __inline__ void putc(char ch)
+static __inline__ void PUTC_LL(char ch)
 {
 	while (!(__raw_readb((u8 *)DEBUG_LL_UART_ADDR + lsr) & LSR_THRE));
 	__raw_writeb(ch, (u8 *)DEBUG_LL_UART_ADDR + rbr);
diff --git a/arch/mips/mach-bcm47xx/include/mach/debug_ll.h b/arch/mips/mach-bcm47xx/include/mach/debug_ll.h
index 4bf1817..0703bb0 100644
--- a/arch/mips/mach-bcm47xx/include/mach/debug_ll.h
+++ b/arch/mips/mach-bcm47xx/include/mach/debug_ll.h
@@ -28,7 +28,7 @@
 #define lsr		5
 #define LSR_THRE	0x20	/* Xmit holding register empty */
 
-static __inline__ void putc(char ch)
+static __inline__ void PUTC_LL(char ch)
 {
 	while (!(__raw_readb(DEBUG_LL_UART_ADDR + lsr) & LSR_THRE));
 	__raw_writeb(ch, DEBUG_LL_UART_ADDR + rbr);
diff --git a/include/debug_ll.h b/include/debug_ll.h
index c744573..c5f2df4 100644
--- a/include/debug_ll.h
+++ b/include/debug_ll.h
@@ -22,7 +22,6 @@
 #if defined (CONFIG_DEBUG_LL)
 # include <mach/debug_ll.h>
 
-#define PUTC_LL(x) putc(x)
 # define PUTHEX_LL(value)  ({ unsigned long v = (unsigned long) (value); \
 			     int i; unsigned char ch; \
 			     for (i = 8; i--; ) {\
-- 
1.7.10.4



From s.hauer at pengutronix.de  Mon Nov 26 05:16:57 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Mon, 26 Nov 2012 11:16:57 +0100
Subject: commands: md, mw: add the '-x' option (swap bytes)
In-Reply-To: <1353923501-13372-1-git-send-email-antonynpavlov@gmail.com>
References: <1353923501-13372-1-git-send-email-antonynpavlov@gmail.com>
Message-ID: <20121126101657.GF10369@pengutronix.de>

On Mon, Nov 26, 2012 at 01:51:38PM +0400, Antony Pavlov wrote:
> Most of my MIPS boards run barebox in big-endian mode, but
> sometimes I need see state of little-endian registers
> (e.g. registers of PCI-connected peripherals) and it is not
> very handy to swap bytes manually.
> 
> This patch series adds to memory commands md and mw the ability
> to swap bytes "on the fly".

Applied, thanks

Sascha

> 
> [PATCH 1/3] mem: add the swab (swap bytes) option to
> [PATCH 2/3] commands: md: add the '-x' option (swap bytes)
> [PATCH 3/3] commands: mw: add the '-x' option (swap bytes)
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From shc_work at mail.ru  Mon Nov 26 09:00:54 2012
From: shc_work at mail.ru (=?UTF-8?B?QWxleGFuZGVyIFNoaXlhbg==?=)
Date: Mon, 26 Nov 2012 18:00:54 +0400
Subject: =?UTF-8?B?UmVbMl06IFtQQVRDSF0gQ2xlYW51cCBLY29uZmlnIGZpbGVz?=
In-Reply-To: <20121126081602.GW10369@pengutronix.de>
References: <1353783209-16451-1-git-send-email-shc_work@mail.ru>
 <20121126081602.GW10369@pengutronix.de>
Message-ID: <1353938454.660390986@f209.mail.ru>

> On Sat, Nov 24, 2012 at 10:53:29PM +0400, Alexander Shiyan wrote:
> > This patch provides a global cleanup barebox Kconfig files. This includes
> > replacing spaces to tabs, formatting in accordance format, removing
> > extraneous lines and spaces. No functional changes.
> > 
> > diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> > index 3afd885..01fe9de 100644
> > --- a/arch/arm/Kconfig
> > +++ b/arch/arm/Kconfig
> > @@ -19,7 +19,7 @@ config ARM_LINUX
> >  config HAVE_MACH_ARM_HEAD
> >  	bool
> >  
> > -menu "System Type                   "
> > +menu "System Type"
> 
> These whitespaces are present on purpose. They are there for aligning
> the arrows in menus in make menuconfig. I tend to say that this is a
> good change anyway, because counting the spaces to align line lengths
> is something which hurts during review (and I can't remember having
> done this before).
> 
> If nobody objects I'll apply it. If somebody objects, I probably say him
> that he should provide a patch for Kconfig instead.

I can remade some parts if necessary since this output is produced
via cleanup program. Also, is necessary, I can remade this patch for
the "next" branch.

---

From s.hauer at pengutronix.de  Tue Nov 27 15:01:15 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Tue, 27 Nov 2012 21:01:15 +0100
Subject: [PATCH 2/4] ARM i.MX esdctl.h: Add double include protection
In-Reply-To: <1354046477-17530-1-git-send-email-s.hauer@pengutronix.de>
References: <1354046477-17530-1-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1354046477-17530-2-git-send-email-s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/arm/mach-imx/include/mach/esdctl.h |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm/mach-imx/include/mach/esdctl.h b/arch/arm/mach-imx/include/mach/esdctl.h
index 8124c87..b601ff8 100644
--- a/arch/arm/mach-imx/include/mach/esdctl.h
+++ b/arch/arm/mach-imx/include/mach/esdctl.h
@@ -1,3 +1,5 @@
+#ifndef __MACH_ESDCTL_V2_H
+#define __MACH_ESDCTL_V2_H
 
 /* SDRAM Controller registers */
 #define IMX_ESDCTL0 0x00 /* Enhanced SDRAM Control Register 0       */
@@ -124,3 +126,4 @@
 //#define ESDCFGx_tRC_14		0x0000000e	// 15 seems to not exist
 #define ESDCFGx_tRC_16			0x0000000f
 
+#endif /* __MACH_ESDCTL_V2_H */
-- 
1.7.10.4



From s.hauer at pengutronix.de  Tue Nov 27 15:01:17 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Tue, 27 Nov 2012 21:01:17 +0100
Subject: [PATCH 4/4] serial i.MX: Make locally used variables static
In-Reply-To: <1354046477-17530-1-git-send-email-s.hauer@pengutronix.de>
References: <1354046477-17530-1-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1354046477-17530-4-git-send-email-s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/serial/serial_imx.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/serial/serial_imx.c b/drivers/serial/serial_imx.c
index 694eac2..3f219ae 100644
--- a/drivers/serial/serial_imx.c
+++ b/drivers/serial/serial_imx.c
@@ -141,7 +141,7 @@ struct imx_serial_devtype_data {
 	u32 onems;
 };
 
-struct imx_serial_devtype_data imx1_data = {
+static struct imx_serial_devtype_data imx1_data = {
 	.ucr1_val = UCR1_UARTCLKEN,
 	.ucr3_val = 0,
 	.ucr4_val = UCR4_CTSTL_32 | UCR4_REF16,
@@ -149,7 +149,7 @@ struct imx_serial_devtype_data imx1_data = {
 	.onems = 0,
 };
 
-struct imx_serial_devtype_data imx21_data = {
+static struct imx_serial_devtype_data imx21_data = {
 	.ucr1_val = 0,
 	.ucr3_val = 0x700 | UCR3_RXDMUXSEL,
 	.ucr4_val = UCR4_CTSTL_32,
-- 
1.7.10.4



From s.hauer at pengutronix.de  Tue Nov 27 15:01:16 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Tue, 27 Nov 2012 21:01:16 +0100
Subject: [PATCH 3/4] i.MX27 regs remove unnecessary include
In-Reply-To: <1354046477-17530-1-git-send-email-s.hauer@pengutronix.de>
References: <1354046477-17530-1-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1354046477-17530-3-git-send-email-s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/arm/boards/phycard-i.MX27/lowlevel_init.S |    1 +
 arch/arm/mach-imx/include/mach/imx27-regs.h    |    2 --
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/arm/boards/phycard-i.MX27/lowlevel_init.S b/arch/arm/boards/phycard-i.MX27/lowlevel_init.S
index 8f0000f..38cc55c 100644
--- a/arch/arm/boards/phycard-i.MX27/lowlevel_init.S
+++ b/arch/arm/boards/phycard-i.MX27/lowlevel_init.S
@@ -7,6 +7,7 @@
 #include <config.h>
 #include <mach/imx27-regs.h>
 #include <mach/imx-pll.h>
+#include <mach/esdctl.h>
 #include <asm/barebox-arm-head.h>
 
 #define writel(val, reg) \
diff --git a/arch/arm/mach-imx/include/mach/imx27-regs.h b/arch/arm/mach-imx/include/mach/imx27-regs.h
index 90b4614..44bc1d3 100644
--- a/arch/arm/mach-imx/include/mach/imx27-regs.h
+++ b/arch/arm/mach-imx/include/mach/imx27-regs.h
@@ -124,8 +124,6 @@
 #define MX27_WBCR	0x1C	/* Well Bias Control Register */
 #define MX27_DSCR(x)	(0x1C + ((x) << 2))	/* Driving Strength Control Register 1 - 13 */
 
-#include "esdctl.h"
-
 /* PLL registers (base: MX27_CCM_BASE_ADDR) */
 #define MX27_CSCR	0x00 /* Clock Source Control Register       */
 #define MX27_MPCTL0	0x04 /* MCU PLL Control Register 0          */
-- 
1.7.10.4



From s.hauer at pengutronix.de  Tue Nov 27 15:01:14 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Tue, 27 Nov 2012 21:01:14 +0100
Subject: [PATCH 1/4] ARM i.MX bbu: Fix compiling with DEBUG enabled
Message-ID: <1354046477-17530-1-git-send-email-s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/arm/mach-imx/imx-bbu-internal.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/imx-bbu-internal.c
index 85d10cf..c34f86f 100644
--- a/arch/arm/mach-imx/imx-bbu-internal.c
+++ b/arch/arm/mach-imx/imx-bbu-internal.c
@@ -63,7 +63,7 @@ static int imx_bbu_write_device(struct imx_internal_bbu_handler *imx_handler,
 	if (imx_handler->flags & IMX_INTERNAL_FLAG_KEEP_DOSPART) {
 		void *mbr = xzalloc(512);
 
-		debug("%s: reading DOS partition table in order to keep it\n");
+		debug("%s: reading DOS partition table in order to keep it\n", __func__);
 
 		ret = read(fd, mbr, 512);
 		if (ret < 0) {
@@ -484,7 +484,7 @@ static int imx53_bbu_internal_init_dcd(struct imx_internal_bbu_handler *imx_hand
 	if ((*dcd32 & 0xff0000ff) != DCD_WR_CMD(0)) {
 		__be32 *buf;
 
-		debug("%s: dcd does not have a DCD_WR_CMD. Prepending one\n");
+		debug("%s: dcd does not have a DCD_WR_CMD. Prepending one\n", __func__);
 
 		buf = xmalloc(dcdsize + sizeof(__be32));
 
@@ -494,7 +494,7 @@ static int imx53_bbu_internal_init_dcd(struct imx_internal_bbu_handler *imx_hand
 		imx_handler->dcd = buf;
 		imx_handler->dcdsize = dcdsize + sizeof(__be32);
 	} else {
-		debug("%s: dcd already has a DCD_WR_CMD. Using original dcd data\n");
+		debug("%s: dcd already has a DCD_WR_CMD. Using original dcd data\n", __func__);
 
 		imx_handler->dcd = dcd;
 		imx_handler->dcdsize = dcdsize;
-- 
1.7.10.4



From s.hauer at pengutronix.de  Tue Nov 27 15:48:45 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Tue, 27 Nov 2012 21:48:45 +0100
Subject: [PATCH] i.MX sdram controller driver support
Message-ID: <1354049328-3534-1-git-send-email-s.hauer@pengutronix.de>

This adds a driver which reads back the SDRAM controller
configured values and registers the memory found with barebox.
This makes board code a bit easier.

Sascha

----------------------------------------------------------------
Sascha Hauer (3):
      ARM i.MX: Add driver to get sdram base and size
      ARM i.MX: register esdctl controller device
      ARM i.MX boards: use esdctl code to detect sdram size

 arch/arm/boards/ccxmx51/ccxmx51.c                 |    9 -
 arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c |    8 -
 arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c |   14 -
 arch/arm/boards/eukrea_cpuimx35/eukrea_cpuimx35.c |    8 -
 arch/arm/boards/eukrea_cpuimx51/eukrea_cpuimx51.c |    8 -
 arch/arm/boards/freescale-mx25-3-stack/3stack.c   |   18 +-
 arch/arm/boards/freescale-mx35-3-stack/3stack.c   |    9 -
 arch/arm/boards/freescale-mx51-pdk/board.c        |    8 -
 arch/arm/boards/freescale-mx53-loco/board.c       |    9 -
 arch/arm/boards/freescale-mx53-smd/board.c        |    9 -
 arch/arm/boards/guf-cupid/board.c                 |    8 -
 arch/arm/boards/guf-neso/board.c                  |    8 -
 arch/arm/boards/imx27ads/imx27ads.c               |    8 -
 arch/arm/boards/karo-tx25/board.c                 |   14 +-
 arch/arm/boards/karo-tx51/tx51.c                  |    8 -
 arch/arm/boards/karo-tx53/board.c                 |   11 -
 arch/arm/boards/pcm037/pcm037.c                   |   11 -
 arch/arm/boards/pcm038/pcm038.c                   |   14 +-
 arch/arm/boards/pcm043/pcm043.c                   |    8 -
 arch/arm/boards/phycard-i.MX27/pca100.c           |    8 -
 arch/arm/boards/scb9328/scb9328.c                 |    8 -
 arch/arm/boards/tqma53/board.c                    |   11 -
 arch/arm/mach-imx/Makefile                        |    3 +-
 arch/arm/mach-imx/esdctl.c                        |  348 +++++++++++++++++++++
 arch/arm/mach-imx/imx1.c                          |    3 +
 arch/arm/mach-imx/imx25.c                         |    1 +
 arch/arm/mach-imx/imx27.c                         |    1 +
 arch/arm/mach-imx/imx31.c                         |    1 +
 arch/arm/mach-imx/imx35.c                         |    1 +
 arch/arm/mach-imx/imx51.c                         |    1 +
 arch/arm/mach-imx/imx53.c                         |    1 +
 arch/arm/mach-imx/include/mach/esdctl.h           |    1 +
 arch/arm/mach-imx/include/mach/imx1-regs.h        |    3 +
 33 files changed, 372 insertions(+), 209 deletions(-)
 create mode 100644 arch/arm/mach-imx/esdctl.c


From s.hauer at pengutronix.de  Tue Nov 27 15:48:46 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Tue, 27 Nov 2012 21:48:46 +0100
Subject: [PATCH 1/3] ARM i.MX: Add driver to get sdram base and size
In-Reply-To: <1354049328-3534-1-git-send-email-s.hauer@pengutronix.de>
References: <1354049328-3534-1-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1354049328-3534-2-git-send-email-s.hauer@pengutronix.de>

The code initializing the SDRAM controller is not at the same
place where SDRAM is registered with barebox. To reduce the
risk of registering wrong SDRAM sizes this patch adds a
driver for the ESDCTL which reads back the configured SDRAM
size and registers the memory found with barebox.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/arm/mach-imx/Makefile                 |    3 +-
 arch/arm/mach-imx/esdctl.c                 |  348 ++++++++++++++++++++++++++++
 arch/arm/mach-imx/imx1.c                   |    2 +
 arch/arm/mach-imx/include/mach/esdctl.h    |    1 +
 arch/arm/mach-imx/include/mach/imx1-regs.h |    3 +
 5 files changed, 356 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/mach-imx/esdctl.c

diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index 259733e..6bc2b79 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_NAND_IMX) += nand.o
 obj-$(CONFIG_ARCH_IMX_EXTERNAL_BOOT_NAND) += external-nand-boot.o
 pbl-$(CONFIG_ARCH_IMX_EXTERNAL_BOOT_NAND) += external-nand-boot.o
 obj-$(CONFIG_COMMON_CLK) += clk-pllv1.o clk-pllv2.o clk-pllv3.o clk-pfd.o
-obj-y += devices.o imx.o
+obj-y += devices.o imx.o esdctl.o
 obj-y += boot.o
 obj-$(CONFIG_BAREBOX_UPDATE) += imx-bbu-internal.o
+pbl-y += esdctl.o
diff --git a/arch/arm/mach-imx/esdctl.c b/arch/arm/mach-imx/esdctl.c
new file mode 100644
index 0000000..99b7f80
--- /dev/null
+++ b/arch/arm/mach-imx/esdctl.c
@@ -0,0 +1,348 @@
+/*
+ * esdctl.c - i.MX sdram controller functions
+ *
+ * Copyright (c) 2012 Sascha Hauer <s.hauer at pengutronix.de>, Pengutronix
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <common.h>
+#include <io.h>
+#include <sizes.h>
+#include <init.h>
+#include <asm/barebox-arm.h>
+#include <asm/memory.h>
+#include <mach/esdctl.h>
+#include <mach/imx1-regs.h>
+#include <mach/imx21-regs.h>
+#include <mach/imx25-regs.h>
+#include <mach/imx27-regs.h>
+#include <mach/imx31-regs.h>
+#include <mach/imx35-regs.h>
+#include <mach/imx51-regs.h>
+#include <mach/imx53-regs.h>
+
+struct imx_esdctl_data {
+	unsigned long base0;
+	unsigned long base1;
+	void (*add_mem)(void *esdctlbase, struct imx_esdctl_data *);
+};
+
+/*
+ * v1 - found on i.MX1
+ */
+static inline unsigned long imx_v1_sdram_size(void __iomem *esdctlbase, int num)
+{
+	void __iomem *esdctl = esdctlbase + (num ? 4 : 0);
+	u32 ctlval = readl(esdctl);
+	unsigned long size;
+	int rows, cols, width = 2, banks = 4;
+
+	if (!(ctlval & ESDCTL0_SDE))
+		/* SDRAM controller disabled, so no RAM here */
+		return 0;
+
+	rows = ((ctlval >> 24) & 0x3) + 11;
+	cols = ((ctlval >> 20) & 0x3) + 8;
+
+	if (ctlval & (1 << 17))
+		width = 4;
+
+	size = (1 << cols) * (1 << rows) * banks * width;
+
+	if (size > SZ_64M)
+		size = SZ_64M;
+
+	return size;
+}
+
+/*
+ * v2 - found on i.MX25, i.MX27, i.MX31 and i.MX35
+ */
+static inline unsigned long imx_v2_sdram_size(void __iomem *esdctlbase, int num)
+{
+	void __iomem *esdctl = esdctlbase + (num ? IMX_ESDCTL1 : IMX_ESDCTL0);
+	u32 ctlval = readl(esdctl);
+	unsigned long size;
+	int rows, cols, width = 2, banks = 4;
+
+	if (!(ctlval & ESDCTL0_SDE))
+		/* SDRAM controller disabled, so no RAM here */
+		return 0;
+
+	rows = ((ctlval >> 24) & 0x7) + 11;
+	cols = ((ctlval >> 20) & 0x3) + 8;
+
+	if ((ctlval & ESDCTL0_DSIZ_MASK) == ESDCTL0_DSIZ_31_0)
+		width = 4;
+
+	size = (1 << cols) * (1 << rows) * banks * width;
+
+	if (size > SZ_256M)
+		size = SZ_256M;
+
+	return size;
+}
+
+/*
+ * v3 - found on i.MX51
+ */
+static inline unsigned long imx_v3_sdram_size(void __iomem *esdctlbase, int num)
+{
+	unsigned long size;
+
+	size = imx_v2_sdram_size(esdctlbase, num);
+
+	if (readl(esdctlbase + IMX_ESDMISC) & (1 << 6))
+		size *= 2;
+
+	if (size > SZ_256M)
+		size = SZ_256M;
+
+	return size;
+}
+
+#define IMX_ESDCTL_V4_ESDCTL	0x0
+#define IMX_ESDCTL_V4_ESDMISC	0x18
+
+#define ESDCTL_V4_ESDCTL_DSIZ		(1 << 16)
+#define ESDCTL_V4_ESDMISC_DDR_4_BANK	(1 << 5)
+#define ESDCTL_V4_ESDMISC_ONECS		(1 << 20)
+
+#define ESDCTL_V4_ESDCTL_SDE_0		(1 << 31)
+#define ESDCTL_V4_ESDCTL_SDE_1		(1 << 30)
+#define ESDCTL_V4_ESDMISC_BI		(1 << 12)
+
+/*
+ * v4 - found on i.MX53
+ */
+static inline unsigned long imx_v4_sdram_size(void __iomem *esdctlbase, int cs)
+{
+	u32 ctlval = readl(esdctlbase + IMX_ESDCTL_V4_ESDCTL);
+	u32 esdmisc = readl(esdctlbase + IMX_ESDCTL_V4_ESDMISC);
+	unsigned long size;
+	int rows, cols, width = 2, banks = 8;
+
+	if (cs == 0 && !(ctlval & ESDCTL_V4_ESDCTL_SDE_0))
+		return 0;
+	if (cs == 1 && !(ctlval & ESDCTL_V4_ESDCTL_SDE_1))
+		return 0;
+
+	/* one 2GiB cs, memory is returned for cs0 only */
+	if (cs == 1 && (esdmisc & ESDCTL_V4_ESDMISC_ONECS))
+		return 9;
+
+	rows = ((ctlval >> 24) & 0x7) + 11;
+	switch ((ctlval >> 20) & 0x7) {
+	case 0:
+		cols = 9;
+		break;
+	case 1:
+		cols = 10;
+		break;
+	case 2:
+		cols = 11;
+		break;
+	case 3:
+		cols = 8;
+		break;
+	case 4:
+		cols = 12;
+		break;
+	default:
+		cols = 0;
+		break;
+	}
+
+	if (ctlval & ESDCTL_V4_ESDCTL_DSIZ)
+		width = 4;
+
+	if (esdmisc & ESDCTL_V4_ESDMISC_DDR_4_BANK)
+		banks = 4;
+
+	size = (1 << cols) * (1 << rows) * banks * width;
+
+	/* bank interleaved, double size */
+	if (esdmisc & ESDCTL_V4_ESDMISC_BI)
+		return size * 2;
+
+	return size;
+}
+
+static void add_mem(unsigned long base0, unsigned long size0,
+		unsigned long base1, unsigned long size1)
+{
+	debug("%s: cs0 base: 0x%08x cs0 size: 0x%08x\n", __func__, base0, size0);
+	debug("%s: cs1 base: 0x%08x cs1 size: 0x%08x\n", __func__, base1, size1);
+
+	if (base0 + size0 == base1 && size1 > 0) {
+		/*
+		 * concatenate both chip selects to a single bank
+		 */
+		arm_add_mem_device("ram0", base0, size0 + size1);
+
+		return;
+	}
+
+	if (size0)
+		arm_add_mem_device("ram0", base0, size0);
+
+	if (size1)
+		arm_add_mem_device(size0 ? "ram1" : "ram0", base1, size1);
+}
+
+static void imx_esdctl_v1_add_mem(void *esdctlbase, struct imx_esdctl_data *data)
+{
+	add_mem(data->base0, imx_v1_sdram_size(esdctlbase, 0),
+			data->base1, imx_v1_sdram_size(esdctlbase, 1));
+}
+
+static void imx_esdctl_v2_add_mem(void *esdctlbase, struct imx_esdctl_data *data)
+{
+	add_mem(data->base0, imx_v2_sdram_size(esdctlbase, 0),
+			data->base1, imx_v2_sdram_size(esdctlbase, 1));
+}
+
+static void imx_esdctl_v3_add_mem(void *esdctlbase, struct imx_esdctl_data *data)
+{
+	add_mem(data->base0, imx_v3_sdram_size(esdctlbase, 0),
+			data->base1, imx_v3_sdram_size(esdctlbase, 1));
+}
+
+static void imx_esdctl_v4_add_mem(void *esdctlbase, struct imx_esdctl_data *data)
+{
+	add_mem(data->base0, imx_v4_sdram_size(esdctlbase, 0),
+			data->base1, imx_v4_sdram_size(esdctlbase, 1));
+}
+
+static __maybe_unused struct imx_esdctl_data imx1_data = {
+	.base0 = MX1_CSD0_BASE_ADDR,
+	.base1 = MX1_CSD1_BASE_ADDR,
+	.add_mem = imx_esdctl_v1_add_mem,
+};
+
+static int imx_esdctl_probe(struct device_d *dev)
+{
+	struct imx_esdctl_data *data;
+	int ret;
+	void *base;
+
+	ret = dev_get_drvdata(dev, (unsigned long *)&data);
+	if (ret)
+		return ret;
+
+	base = dev_request_mem_region(dev, 0);
+	if (!base)
+		return -ENOMEM;
+
+	data->add_mem(base, data);
+
+	return 0;
+}
+
+static __maybe_unused struct imx_esdctl_data imx25_data = {
+	.base0 = MX25_CSD0_BASE_ADDR,
+	.base1 = MX25_CSD1_BASE_ADDR,
+	.add_mem = imx_esdctl_v2_add_mem,
+};
+
+static __maybe_unused struct imx_esdctl_data imx27_data = {
+	.base0 = MX27_CSD0_BASE_ADDR,
+	.base1 = MX27_CSD1_BASE_ADDR,
+	.add_mem = imx_esdctl_v2_add_mem,
+};
+
+static __maybe_unused struct imx_esdctl_data imx31_data = {
+	.base0 = MX31_CSD0_BASE_ADDR,
+	.base1 = MX31_CSD1_BASE_ADDR,
+	.add_mem = imx_esdctl_v2_add_mem,
+};
+
+static __maybe_unused struct imx_esdctl_data imx35_data = {
+	.base0 = MX35_CSD0_BASE_ADDR,
+	.base1 = MX35_CSD1_BASE_ADDR,
+	.add_mem = imx_esdctl_v2_add_mem,
+};
+
+static __maybe_unused struct imx_esdctl_data imx51_data = {
+	.base0 = MX51_CSD0_BASE_ADDR,
+	.base1 = MX51_CSD1_BASE_ADDR,
+	.add_mem = imx_esdctl_v3_add_mem,
+};
+
+static __maybe_unused struct imx_esdctl_data imx53_data = {
+	.base0 = MX53_CSD0_BASE_ADDR,
+	.base1 = MX53_CSD1_BASE_ADDR,
+	.add_mem = imx_esdctl_v4_add_mem,
+};
+
+static struct platform_device_id imx_esdctl_ids[] = {
+#ifdef CONFIG_ARCH_IMX1
+	{
+		.name = "imx1-sdramc",
+		.driver_data = (unsigned long)&imx1_data,
+	},
+#endif
+#ifdef CONFIG_ARCH_IMX25
+	{
+		.name = "imx25-esdctl",
+		.driver_data = (unsigned long)&imx25_data,
+	},
+#endif
+#ifdef CONFIG_ARCH_IMX27
+	{
+		.name = "imx27-esdctl",
+		.driver_data = (unsigned long)&imx27_data,
+	},
+#endif
+#ifdef CONFIG_ARCH_IMX31
+	{
+		.name = "imx31-esdctl",
+		.driver_data = (unsigned long)&imx31_data,
+	},
+#endif
+#ifdef CONFIG_ARCH_IMX35
+	{
+		.name = "imx35-esdctl",
+		.driver_data = (unsigned long)&imx35_data,
+	},
+#endif
+#ifdef CONFIG_ARCH_IMX51
+	{
+		.name = "imx51-esdctl",
+		.driver_data = (unsigned long)&imx51_data,
+	},
+#endif
+#ifdef CONFIG_ARCH_IMX53
+	{
+		.name = "imx53-esdctl",
+		.driver_data = (unsigned long)&imx53_data,
+	},
+#endif
+	{
+		/* sentinel */
+	},
+};
+
+static struct driver_d imx_serial_driver = {
+	.name   = "imx-esdctl",
+	.probe  = imx_esdctl_probe,
+	.id_table = imx_esdctl_ids,
+};
+
+static int imx_esdctl_init(void)
+{
+	return platform_driver_register(&imx_serial_driver);
+}
+
+mem_initcall(imx_esdctl_init);
diff --git a/arch/arm/mach-imx/imx1.c b/arch/arm/mach-imx/imx1.c
index 18901ea..59cff28 100644
--- a/arch/arm/mach-imx/imx1.c
+++ b/arch/arm/mach-imx/imx1.c
@@ -49,6 +49,8 @@ void imx1_setup_eimcs(size_t cs, unsigned upper, unsigned lower)
 	writel(lower, MX1_EIM_BASE_ADDR + 4 + cs * 8);
 }
 
+#include <mach/esdctl.h>
+
 static int imx1_init(void)
 {
 	imx_iomuxv1_init((void *)MX1_GPIO1_BASE_ADDR);
diff --git a/arch/arm/mach-imx/include/mach/esdctl.h b/arch/arm/mach-imx/include/mach/esdctl.h
index 8124c87..1aec2a8 100644
--- a/arch/arm/mach-imx/include/mach/esdctl.h
+++ b/arch/arm/mach-imx/include/mach/esdctl.h
@@ -26,6 +26,7 @@
 #define ESDCTL0_DSIZ_31_16			(0 << 16)
 #define ESDCTL0_DSIZ_15_0			(1 << 16)
 #define ESDCTL0_DSIZ_31_0			(2 << 16)
+#define ESDCTL0_DSIZ_MASK			(3 << 16)
 #define ESDCTL0_REF1				(1 << 13)
 #define ESDCTL0_REF2				(2 << 13)
 #define ESDCTL0_REF4				(3 << 13)
diff --git a/arch/arm/mach-imx/include/mach/imx1-regs.h b/arch/arm/mach-imx/include/mach/imx1-regs.h
index df6ede5..69e57e3 100644
--- a/arch/arm/mach-imx/include/mach/imx1-regs.h
+++ b/arch/arm/mach-imx/include/mach/imx1-regs.h
@@ -4,6 +4,9 @@
 #define MX1_IO_BASE_ADDR	0x00200000
 #define MX1_IO_SIZE		SZ_1M
 
+#define MX1_CSD0_BASE_ADDR	0x08000000
+#define MX1_CSD1_BASE_ADDR	0x0c000000
+
 #define MX1_CS0_PHYS		0x10000000
 #define MX1_CS0_SIZE		0x02000000
 
-- 
1.7.10.4



From s.hauer at pengutronix.de  Tue Nov 27 15:48:47 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Tue, 27 Nov 2012 21:48:47 +0100
Subject: [PATCH 2/3] ARM i.MX: register esdctl controller device
In-Reply-To: <1354049328-3534-1-git-send-email-s.hauer@pengutronix.de>
References: <1354049328-3534-1-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1354049328-3534-3-git-send-email-s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/arm/mach-imx/imx1.c  |    1 +
 arch/arm/mach-imx/imx25.c |    1 +
 arch/arm/mach-imx/imx27.c |    1 +
 arch/arm/mach-imx/imx31.c |    1 +
 arch/arm/mach-imx/imx35.c |    1 +
 arch/arm/mach-imx/imx51.c |    1 +
 arch/arm/mach-imx/imx53.c |    1 +
 7 files changed, 7 insertions(+)

diff --git a/arch/arm/mach-imx/imx1.c b/arch/arm/mach-imx/imx1.c
index 59cff28..588ac02 100644
--- a/arch/arm/mach-imx/imx1.c
+++ b/arch/arm/mach-imx/imx1.c
@@ -63,6 +63,7 @@ static int imx1_init(void)
 	add_generic_device("imx1-gpio", 2, NULL, MX1_GPIO3_BASE_ADDR, 0x100, IORESOURCE_MEM, NULL);
 	add_generic_device("imx1-gpio", 3, NULL, MX1_GPIO4_BASE_ADDR, 0x100, IORESOURCE_MEM, NULL);
 	add_generic_device("imx1-wdt", 0, NULL, MX1_WDT_BASE_ADDR, 0x100, IORESOURCE_MEM, NULL);
+	add_generic_device("imx1-sdramc", 0, NULL, MX1_SDRAMC_BASE_ADDR, 0x100, IORESOURCE_MEM, NULL);
 
 	return 0;
 }
diff --git a/arch/arm/mach-imx/imx25.c b/arch/arm/mach-imx/imx25.c
index 3bd95c1..e2ef374 100644
--- a/arch/arm/mach-imx/imx25.c
+++ b/arch/arm/mach-imx/imx25.c
@@ -75,6 +75,7 @@ static int imx25_init(void)
 	add_generic_device("imx31-gpio", 2, NULL, MX25_GPIO3_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
 	add_generic_device("imx31-gpio", 3, NULL, MX25_GPIO4_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
 	add_generic_device("imx21-wdt", 0, NULL, MX25_WDOG_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
+	add_generic_device("imx25-esdctl", 0, NULL, MX25_ESDCTL_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
 
 	return 0;
 }
diff --git a/arch/arm/mach-imx/imx27.c b/arch/arm/mach-imx/imx27.c
index a0a510f..31117f4 100644
--- a/arch/arm/mach-imx/imx27.c
+++ b/arch/arm/mach-imx/imx27.c
@@ -117,6 +117,7 @@ static int imx27_init(void)
 	add_generic_device("imx1-gpio", 4, NULL, MX27_GPIO5_BASE_ADDR, 0x100, IORESOURCE_MEM, NULL);
 	add_generic_device("imx1-gpio", 5, NULL, MX27_GPIO6_BASE_ADDR, 0x100, IORESOURCE_MEM, NULL);
 	add_generic_device("imx21-wdt", 0, NULL, MX27_WDOG_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
+	add_generic_device("imx27-esdctl", 0, NULL, MX27_ESDCTL_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
 
 	return 0;
 }
diff --git a/arch/arm/mach-imx/imx31.c b/arch/arm/mach-imx/imx31.c
index b2f0724..52be541 100644
--- a/arch/arm/mach-imx/imx31.c
+++ b/arch/arm/mach-imx/imx31.c
@@ -38,6 +38,7 @@ static int imx31_init(void)
 	add_generic_device("imx-gpio", 1, NULL, MX31_GPIO2_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
 	add_generic_device("imx-gpio", 2, NULL, MX31_GPIO3_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
 	add_generic_device("imx21-wdt", 0, NULL, MX31_WDOG_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
+	add_generic_device("imx31-esdctl", 0, NULL, MX31_ESDCTL_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
 
 	return 0;
 }
diff --git a/arch/arm/mach-imx/imx35.c b/arch/arm/mach-imx/imx35.c
index 737eb3a..21c7e90 100644
--- a/arch/arm/mach-imx/imx35.c
+++ b/arch/arm/mach-imx/imx35.c
@@ -77,6 +77,7 @@ static int imx35_init(void)
 	add_generic_device("imx-gpio", 1, NULL, MX35_GPIO2_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
 	add_generic_device("imx-gpio", 2, NULL, MX35_GPIO3_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
 	add_generic_device("imx21-wdt", 0, NULL, MX35_WDOG_BASE_ADDR, 0x4000, IORESOURCE_MEM, NULL);
+	add_generic_device("imx35-esdctl", 0, NULL, MX35_ESDCTL_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
 
 	return 0;
 }
diff --git a/arch/arm/mach-imx/imx51.c b/arch/arm/mach-imx/imx51.c
index 4b0786b..3d0520a 100644
--- a/arch/arm/mach-imx/imx51.c
+++ b/arch/arm/mach-imx/imx51.c
@@ -69,6 +69,7 @@ static int imx51_init(void)
 	add_generic_device("imx31-gpio", 2, NULL, MX51_GPIO3_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
 	add_generic_device("imx31-gpio", 3, NULL, MX51_GPIO4_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
 	add_generic_device("imx21-wdt", 0, NULL, MX51_WDOG_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
+	add_generic_device("imx51-esdctl", 0, NULL, MX51_ESDCTL_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
 
 	return 0;
 }
diff --git a/arch/arm/mach-imx/imx53.c b/arch/arm/mach-imx/imx53.c
index e424e7d..2d6557f 100644
--- a/arch/arm/mach-imx/imx53.c
+++ b/arch/arm/mach-imx/imx53.c
@@ -69,6 +69,7 @@ static int imx53_init(void)
 	add_generic_device("imx31-gpio", 5, NULL, MX53_GPIO6_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
 	add_generic_device("imx31-gpio", 6, NULL, MX53_GPIO7_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
 	add_generic_device("imx21-wdt", 0, NULL, MX53_WDOG1_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
+	add_generic_device("imx53-esdctl", 0, NULL, MX53_ESDCTL_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
 
 	return 0;
 }
-- 
1.7.10.4



From s.hauer at pengutronix.de  Tue Nov 27 15:48:48 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Tue, 27 Nov 2012 21:48:48 +0100
Subject: [PATCH 3/3] ARM i.MX boards: use esdctl code to detect sdram size
In-Reply-To: <1354049328-3534-1-git-send-email-s.hauer@pengutronix.de>
References: <1354049328-3534-1-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1354049328-3534-4-git-send-email-s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/arm/boards/ccxmx51/ccxmx51.c                 |    9 ---------
 arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c |    8 --------
 arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c |   14 --------------
 arch/arm/boards/eukrea_cpuimx35/eukrea_cpuimx35.c |    8 --------
 arch/arm/boards/eukrea_cpuimx51/eukrea_cpuimx51.c |    8 --------
 arch/arm/boards/freescale-mx25-3-stack/3stack.c   |   18 ++----------------
 arch/arm/boards/freescale-mx35-3-stack/3stack.c   |    9 ---------
 arch/arm/boards/freescale-mx51-pdk/board.c        |    8 --------
 arch/arm/boards/freescale-mx53-loco/board.c       |    9 ---------
 arch/arm/boards/freescale-mx53-smd/board.c        |    9 ---------
 arch/arm/boards/guf-cupid/board.c                 |    8 --------
 arch/arm/boards/guf-neso/board.c                  |    8 --------
 arch/arm/boards/imx27ads/imx27ads.c               |    8 --------
 arch/arm/boards/karo-tx25/board.c                 |   14 +++-----------
 arch/arm/boards/karo-tx51/tx51.c                  |    8 --------
 arch/arm/boards/karo-tx53/board.c                 |   11 -----------
 arch/arm/boards/pcm037/pcm037.c                   |   11 -----------
 arch/arm/boards/pcm038/pcm038.c                   |   14 ++++----------
 arch/arm/boards/pcm043/pcm043.c                   |    8 --------
 arch/arm/boards/phycard-i.MX27/pca100.c           |    8 --------
 arch/arm/boards/scb9328/scb9328.c                 |    8 --------
 arch/arm/boards/tqma53/board.c                    |   11 -----------
 22 files changed, 9 insertions(+), 208 deletions(-)

diff --git a/arch/arm/boards/ccxmx51/ccxmx51.c b/arch/arm/boards/ccxmx51/ccxmx51.c
index a8d172c..b3173a4 100644
--- a/arch/arm/boards/ccxmx51/ccxmx51.c
+++ b/arch/arm/boards/ccxmx51/ccxmx51.c
@@ -197,15 +197,6 @@ static const struct spi_board_info ccxmx51_spi_board_info[] = {
 	},
 };
 
-static int ccxmx51_mem_init(void)
-{
-	/* Add minimal SDRAM first */
-	arm_add_mem_device("ram0", MX51_CSD0_BASE_ADDR, SZ_128M);
-
-	return 0;
-}
-mem_initcall(ccxmx51_mem_init);
-
 static void ccxmx51_otghost_init(void)
 {
 #define MX51_USBOTHER_REGS_OFFSET		0x800
diff --git a/arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c b/arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c
index 92e8df2..ae2363a 100644
--- a/arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c
+++ b/arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c
@@ -117,14 +117,6 @@ static struct fsl_usb2_platform_data usb_pdata = {
 	.phy_mode	= FSL_USB2_PHY_UTMI,
 };
 
-static int eukrea_cpuimx25_mem_init(void)
-{
-	arm_add_mem_device("ram0", MX25_CSD0_BASE_ADDR, 64 * 1024 * 1024);
-
-	return 0;
-}
-mem_initcall(eukrea_cpuimx25_mem_init);
-
 static iomux_v3_cfg_t eukrea_cpuimx25_pads[] = {
 	MX25_PAD_FEC_MDC__FEC_MDC,
 	MX25_PAD_FEC_MDIO__FEC_MDIO,
diff --git a/arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c b/arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c
index c89ce8a..498e9b4 100644
--- a/arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c
+++ b/arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c
@@ -46,12 +46,6 @@
 #include <mach/iomux-mx27.h>
 #include <mach/devices-imx27.h>
 
-#if defined CONFIG_EUKREA_CPUIMX27_SDRAM_256MB
-#define SDRAM0	256
-#elif defined CONFIG_EUKREA_CPUIMX27_SDRAM_128MB
-#define SDRAM0	128
-#endif
-
 static struct fec_platform_data fec_info = {
 	.xcv_type = MII100,
 	.phy_addr = 1,
@@ -86,14 +80,6 @@ static struct i2c_board_info i2c_devices[] = {
 	},
 };
 
-static int eukrea_cpuimx27_mem_init(void)
-{
-	arm_add_mem_device("ram0", 0xa0000000, SDRAM0 * 1024 * 1024);
-
-	return 0;
-}
-mem_initcall(eukrea_cpuimx27_mem_init);
-
 #ifdef CONFIG_DRIVER_VIDEO_IMX
 static struct imx_fb_videomode imxfb_mode = {
 	.mode = {
diff --git a/arch/arm/boards/eukrea_cpuimx35/eukrea_cpuimx35.c b/arch/arm/boards/eukrea_cpuimx35/eukrea_cpuimx35.c
index fdbc26a..2c96007 100644
--- a/arch/arm/boards/eukrea_cpuimx35/eukrea_cpuimx35.c
+++ b/arch/arm/boards/eukrea_cpuimx35/eukrea_cpuimx35.c
@@ -122,14 +122,6 @@ static struct fsl_usb2_platform_data usb_pdata = {
 };
 #endif
 
-static int eukrea_cpuimx35_mem_init(void)
-{
-	arm_add_mem_device("ram0", MX35_CSD0_BASE_ADDR, 128 * 1024 * 1024);
-
-	return 0;
-}
-mem_initcall(eukrea_cpuimx35_mem_init);
-
 static int eukrea_cpuimx35_mmu_init(void)
 {
 	l2x0_init((void __iomem *)0x30000000, 0x00030024, 0x00000000);
diff --git a/arch/arm/boards/eukrea_cpuimx51/eukrea_cpuimx51.c b/arch/arm/boards/eukrea_cpuimx51/eukrea_cpuimx51.c
index ab0ff81..fdbd051 100644
--- a/arch/arm/boards/eukrea_cpuimx51/eukrea_cpuimx51.c
+++ b/arch/arm/boards/eukrea_cpuimx51/eukrea_cpuimx51.c
@@ -103,14 +103,6 @@ static iomux_v3_cfg_t eukrea_cpuimx51_pads[] = {
 #define GPIO_LAN8700_RESET	(1 * 32 + 31)
 #define GPIO_LCD_BL		(2 * 32 + 4)
 
-static int eukrea_cpuimx51_mem_init(void)
-{
-	arm_add_mem_device("ram0", 0x90000000, 256 * 1024 * 1024);
-
-	return 0;
-}
-mem_initcall(eukrea_cpuimx51_mem_init);
-
 static int eukrea_cpuimx51_devices_init(void)
 {
 	imx51_add_fec(&fec_info);
diff --git a/arch/arm/boards/freescale-mx25-3-stack/3stack.c b/arch/arm/boards/freescale-mx25-3-stack/3stack.c
index 5ce2f8e..1271ad9 100644
--- a/arch/arm/boards/freescale-mx25-3-stack/3stack.c
+++ b/arch/arm/boards/freescale-mx25-3-stack/3stack.c
@@ -186,22 +186,6 @@ static int imx25_3ds_fec_init(void)
 }
 late_initcall(imx25_3ds_fec_init);
 
-static int imx25_mem_init(void)
-{
-#if defined CONFIG_FREESCALE_MX25_3STACK_SDRAM_64MB_DDR2
-#define SDRAM_SIZE	64 * 1024 * 1024
-#elif defined CONFIG_FREESCALE_MX25_3STACK_SDRAM_128MB_MDDR
-#define SDRAM_SIZE	128 * 1024 * 1024
-#else
-#error "Unsupported SDRAM type"
-#endif
-	arm_add_mem_device("ram0", MX25_CSD0_BASE_ADDR, SDRAM_SIZE);
-	add_mem_device("sram0", 0x78000000, 128 * 1024, IORESOURCE_MEM_WRITEABLE);
-
-	return 0;
-}
-mem_initcall(imx25_mem_init);
-
 static int imx25_devices_init(void)
 {
 #ifdef CONFIG_USB
@@ -215,6 +199,8 @@ static int imx25_devices_init(void)
 	imx25_iim_register_fec_ethaddr();
 	imx25_add_fec(&fec_info);
 
+	add_mem_device("sram0", 0x78000000, 128 * 1024, IORESOURCE_MEM_WRITEABLE);
+
 	if (readl(MX25_CCM_BASE_ADDR + MX25_CCM_RCSR) & (1 << 14))
 		nand_info.width = 2;
 
diff --git a/arch/arm/boards/freescale-mx35-3-stack/3stack.c b/arch/arm/boards/freescale-mx35-3-stack/3stack.c
index 7da031a..3128d4f 100644
--- a/arch/arm/boards/freescale-mx35-3-stack/3stack.c
+++ b/arch/arm/boards/freescale-mx35-3-stack/3stack.c
@@ -128,15 +128,6 @@ static void set_board_rev(int rev)
 	imx35_3ds_system_rev =  (imx35_3ds_system_rev & ~(0xF << 8)) | (rev & 0xF) << 8;
 }
 
-static int f3s_mem_init(void)
-{
-	arm_add_mem_device("ram0", MX35_CSD0_BASE_ADDR, 128 * 1024 * 1024);
-	arm_add_mem_device("ram1", MX35_CSD1_BASE_ADDR, 128 * 1024 * 1024);
-
-	return 0;
-}
-mem_initcall(f3s_mem_init);
-
 static int f3s_devices_init(void)
 {
 	uint32_t reg;
diff --git a/arch/arm/boards/freescale-mx51-pdk/board.c b/arch/arm/boards/freescale-mx51-pdk/board.c
index 9db0ed9..cb190ef 100644
--- a/arch/arm/boards/freescale-mx51-pdk/board.c
+++ b/arch/arm/boards/freescale-mx51-pdk/board.c
@@ -97,14 +97,6 @@ static iomux_v3_cfg_t f3s_pads[] = {
 	MX51_PAD_GPIO1_5__GPIO1_5,
 };
 
-static int babbage_mem_init(void)
-{
-	arm_add_mem_device("ram0", 0x90000000, 512 * 1024 * 1024);
-
-	return 0;
-}
-mem_initcall(babbage_mem_init);
-
 #define BABBAGE_ECSPI1_CS0	(3 * 32 + 24)
 static int spi_0_cs[] = {BABBAGE_ECSPI1_CS0};
 
diff --git a/arch/arm/boards/freescale-mx53-loco/board.c b/arch/arm/boards/freescale-mx53-loco/board.c
index 216d26a..38ece23 100644
--- a/arch/arm/boards/freescale-mx53-loco/board.c
+++ b/arch/arm/boards/freescale-mx53-loco/board.c
@@ -133,15 +133,6 @@ static void set_board_rev(int rev)
 	loco_system_rev =  (loco_system_rev & ~(0xF << 8)) | (rev & 0xF) << 8;
 }
 
-static int loco_mem_init(void)
-{
-	arm_add_mem_device("ram0", 0x70000000, SZ_512M);
-	arm_add_mem_device("ram1", 0xb0000000, SZ_512M);
-
-	return 0;
-}
-mem_initcall(loco_mem_init);
-
 #define LOCO_FEC_PHY_RST		IMX_GPIO_NR(7, 6)
 
 static void loco_fec_reset(void)
diff --git a/arch/arm/boards/freescale-mx53-smd/board.c b/arch/arm/boards/freescale-mx53-smd/board.c
index a5ad009..64ba7f2 100644
--- a/arch/arm/boards/freescale-mx53-smd/board.c
+++ b/arch/arm/boards/freescale-mx53-smd/board.c
@@ -98,15 +98,6 @@ static iomux_v3_cfg_t smd_pads[] = {
 	MX53_PAD_PATA_RESET_B__ESDHC3_CMD,
 };
 
-static int smd_mem_init(void)
-{
-	arm_add_mem_device("ram0", 0x70000000, SZ_512M);
-	arm_add_mem_device("ram1", 0xb0000000, SZ_512M);
-
-	return 0;
-}
-mem_initcall(smd_mem_init);
-
 #define SMD_FEC_PHY_RST		IMX_GPIO_NR(7, 6)
 
 static void smd_fec_reset(void)
diff --git a/arch/arm/boards/guf-cupid/board.c b/arch/arm/boards/guf-cupid/board.c
index 5b17326..839b415 100644
--- a/arch/arm/boards/guf-cupid/board.c
+++ b/arch/arm/boards/guf-cupid/board.c
@@ -94,14 +94,6 @@ static struct imx_ipu_fb_platform_data ipu_fb_data = {
 	.enable		= cupid_fb_enable,
 };
 
-static int cupid_mem_init(void)
-{
-	arm_add_mem_device("ram0", MX35_CSD0_BASE_ADDR, 128 * 1024 * 1024);
-
-	return 0;
-}
-mem_initcall(cupid_mem_init);
-
 static int cupid_mmu_init(void)
 {
 	l2x0_init((void __iomem *)0x30000000, 0x00030024, 0x00000000);
diff --git a/arch/arm/boards/guf-neso/board.c b/arch/arm/boards/guf-neso/board.c
index 200a2ef..086d96b 100644
--- a/arch/arm/boards/guf-neso/board.c
+++ b/arch/arm/boards/guf-neso/board.c
@@ -133,14 +133,6 @@ static void neso_usbh_init(void)
 }
 #endif
 
-static int neso_mem_init(void)
-{
-	arm_add_mem_device("ram0", 0xa0000000, 128 * 1024 * 1024);
-
-	return 0;
-}
-mem_initcall(neso_mem_init);
-
 static int neso_devices_init(void)
 {
 	int i;
diff --git a/arch/arm/boards/imx27ads/imx27ads.c b/arch/arm/boards/imx27ads/imx27ads.c
index f41b155..d07d553 100644
--- a/arch/arm/boards/imx27ads/imx27ads.c
+++ b/arch/arm/boards/imx27ads/imx27ads.c
@@ -65,14 +65,6 @@ static int imx27ads_timing_init(void)
 
 core_initcall(imx27ads_timing_init);
 
-static int mx27ads_mem_init(void)
-{
-	arm_add_mem_device("ram0", 0xa0000000, 128 * 1024 * 1024);
-
-	return 0;
-}
-mem_initcall(mx27ads_mem_init);
-
 static int mx27ads_devices_init(void)
 {
 	int i;
diff --git a/arch/arm/boards/karo-tx25/board.c b/arch/arm/boards/karo-tx25/board.c
index 1ffd890..98140b3 100644
--- a/arch/arm/boards/karo-tx25/board.c
+++ b/arch/arm/boards/karo-tx25/board.c
@@ -50,17 +50,6 @@ struct imx_nand_platform_data nand_info = {
 	.flash_bbt = 1,
 };
 
-static int tx25_mem_init(void)
-{
-	arm_add_mem_device("ram0", MX25_CSD0_BASE_ADDR, 32 * 1024 * 1024);
-	arm_add_mem_device("ram0", MX25_CSD1_BASE_ADDR, 32 * 1024 * 1024);
-	add_mem_device("ram0", 0x78000000, 128 * 1024,
-				   IORESOURCE_MEM_WRITEABLE);
-
-	return 0;
-}
-mem_initcall(tx25_mem_init);
-
 static iomux_v3_cfg_t karo_tx25_padsd_fec[] = {
 	MX25_PAD_D11__GPIO_4_9,		/* FEC PHY power on pin */
 	MX25_PAD_D13__GPIO_4_7,		/* FEC reset */
@@ -119,6 +108,9 @@ static int tx25_devices_init(void)
 	devfs_add_partition("nand0", 0x40000, 0x80000, DEVFS_PARTITION_FIXED, "env_raw");
 	dev_add_bb_dev("env_raw", "env0");
 
+	add_mem_device("sram0", 0x78000000, 128 * 1024,
+				   IORESOURCE_MEM_WRITEABLE);
+
 	armlinux_set_bootparams((void *)0x80000100);
 	armlinux_set_architecture(MACH_TYPE_TX25);
 	armlinux_set_serial(imx_uid());
diff --git a/arch/arm/boards/karo-tx51/tx51.c b/arch/arm/boards/karo-tx51/tx51.c
index dd377c1..6c2b14b 100644
--- a/arch/arm/boards/karo-tx51/tx51.c
+++ b/arch/arm/boards/karo-tx51/tx51.c
@@ -112,14 +112,6 @@ static iomux_v3_cfg_t tx51_pads[] = {
 	MX51_PAD_GPIO1_0__GPIO1_0,
 };
 
-static int tx51_mem_init(void)
-{
-	arm_add_mem_device("ram0", MX51_CSD0_BASE_ADDR, 128 * 1024 * 1024);
-
-	return 0;
-}
-mem_initcall(tx51_mem_init);
-
 static int spi_0_cs[] = {
 	IMX_GPIO_NR(4, 24),
 	IMX_GPIO_NR(4, 25),
diff --git a/arch/arm/boards/karo-tx53/board.c b/arch/arm/boards/karo-tx53/board.c
index 8f87c9c..581b6fa 100644
--- a/arch/arm/boards/karo-tx53/board.c
+++ b/arch/arm/boards/karo-tx53/board.c
@@ -99,17 +99,6 @@ static iomux_v3_cfg_t tx53_pads[] = {
 	MX53_PAD_CSI0_PIXCLK__IPU_CSI0_PIXCLK,
 };
 
-static int tx53_mem_init(void)
-{
-	if (IS_ENABLED(CONFIG_TX53_REV_1011))
-		arm_add_mem_device("ram0", 0x70000000, SZ_1G);
-	else
-		arm_add_mem_device("ram0", 0x70000000, SZ_512M);
-
-	return 0;
-}
-mem_initcall(tx53_mem_init);
-
 #define TX53_SD1_CD			IMX_GPIO_NR(3, 24)
 
 static struct esdhc_platform_data tx53_sd1_data = {
diff --git a/arch/arm/boards/pcm037/pcm037.c b/arch/arm/boards/pcm037/pcm037.c
index ff4089a..ff32e35 100644
--- a/arch/arm/boards/pcm037/pcm037.c
+++ b/arch/arm/boards/pcm037/pcm037.c
@@ -145,17 +145,6 @@ static void pcm037_usb_init(void)
 }
 #endif
 
-static int pcm037_mem_init(void)
-{
-	arm_add_mem_device("ram0", MX31_CSD0_BASE_ADDR, SDRAM0 * 1024 * 1024);
-#ifndef CONFIG_PCM037_SDRAM_BANK1_NONE
-	arm_add_mem_device("ram1", MX31_CSD1_BASE_ADDR, SDRAM1 * 1024 * 1024);
-#endif
-
-	return 0;
-}
-mem_initcall(pcm037_mem_init);
-
 static int pcm037_mmu_init(void)
 {
 	l2x0_init((void __iomem *)0x30000000, 0x00030024, 0x00000000);
diff --git a/arch/arm/boards/pcm038/pcm038.c b/arch/arm/boards/pcm038/pcm038.c
index 715d604..ea50a78 100644
--- a/arch/arm/boards/pcm038/pcm038.c
+++ b/arch/arm/boards/pcm038/pcm038.c
@@ -180,16 +180,6 @@ static int pcm038_power_init(void)
 	return 0;
 }
 
-static int pcm038_mem_init(void)
-{
-	arm_add_mem_device("ram0", 0xa0000000, 128 * 1024 * 1024);
-
-	add_mem_device("ram1", 0xc8000000, 512 * 1024, /* Can be up to 2MiB */
-				   IORESOURCE_MEM_WRITEABLE);
-	return 0;
-}
-mem_initcall(pcm038_mem_init);
-
 static int pcm038_devices_init(void)
 {
 	int i;
@@ -279,6 +269,10 @@ static int pcm038_devices_init(void)
 	/* configure SRAM on cs1 */
 	imx27_setup_weimcs(1, 0x0000d843, 0x22252521, 0x22220a00);
 
+	/* Can be up to 2MiB */
+	add_mem_device("ram1", 0xc8000000, 512 * 1024,
+				   IORESOURCE_MEM_WRITEABLE);
+
 	/* initizalize gpios */
 	for (i = 0; i < ARRAY_SIZE(mode); i++)
 		imx_gpio_mode(mode[i]);
diff --git a/arch/arm/boards/pcm043/pcm043.c b/arch/arm/boards/pcm043/pcm043.c
index abfeaf1..95da8f0 100644
--- a/arch/arm/boards/pcm043/pcm043.c
+++ b/arch/arm/boards/pcm043/pcm043.c
@@ -98,14 +98,6 @@ static struct imx_ipu_fb_platform_data ipu_fb_data = {
 	.bpp			= 16,
 };
 
-static int pcm043_mem_init(void)
-{
-	arm_add_mem_device("ram0", MX35_CSD0_BASE_ADDR, SZ_128M);
-
-	return 0;
-}
-mem_initcall(pcm043_mem_init);
-
 static int pcm043_mmu_init(void)
 {
 	l2x0_init((void __iomem *)0x30000000, 0x00030024, 0x00000000);
diff --git a/arch/arm/boards/phycard-i.MX27/pca100.c b/arch/arm/boards/phycard-i.MX27/pca100.c
index 0b66b04..1a21c8a 100644
--- a/arch/arm/boards/phycard-i.MX27/pca100.c
+++ b/arch/arm/boards/phycard-i.MX27/pca100.c
@@ -143,14 +143,6 @@ static void pca100_usb_register(void)
 }
 #endif
 
-static int pca100_mem_init(void)
-{
-	arm_add_mem_device("ram0", 0xa0000000, 128 * 1024 * 1024);
-
-	return 0;
-}
-mem_initcall(pca100_mem_init);
-
 static void pca100_usb_init(void)
 {
 	u32 reg;
diff --git a/arch/arm/boards/scb9328/scb9328.c b/arch/arm/boards/scb9328/scb9328.c
index c70852c..d91b21d 100644
--- a/arch/arm/boards/scb9328/scb9328.c
+++ b/arch/arm/boards/scb9328/scb9328.c
@@ -48,14 +48,6 @@ struct gpio_led leds[] = {
 	},
 };
 
-static int scb9328_mem_init(void)
-{
-	arm_add_mem_device("ram0", 0x08000000, 16 * 1024 * 1024);
-
-	return 0;
-}
-mem_initcall(scb9328_mem_init);
-
 static int scb9328_devices_init(void)
 {
 	int i;
diff --git a/arch/arm/boards/tqma53/board.c b/arch/arm/boards/tqma53/board.c
index 77535b5..03cb8ea 100644
--- a/arch/arm/boards/tqma53/board.c
+++ b/arch/arm/boards/tqma53/board.c
@@ -207,17 +207,6 @@ static iomux_v3_cfg_t tqma53_pads[] = {
 
 #define GPIO_FEC_NRESET	IMX_GPIO_NR(7, 6)
 
-static int tqma53_mem_init(void)
-{
-	arm_add_mem_device("ram0", 0x70000000, SZ_512M);
-#ifdef CONFIG_MACH_TQMA53_1GB_RAM
-	arm_add_mem_device("ram1", 0xb0000000, SZ_512M);
-#endif
-
-	return 0;
-}
-mem_initcall(tqma53_mem_init);
-
 #define GPIO_SD2_CD			IMX_GPIO_NR(1, 4)
 #define GPIO_SD2_WP			IMX_GPIO_NR(1, 2)
 
-- 
1.7.10.4



From s.hauer at pengutronix.de  Wed Nov 28 04:57:19 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Wed, 28 Nov 2012 10:57:19 +0100
Subject: [PATCH] clk: check for invalid clocks
Message-ID: <1354096639-13936-1-git-send-email-s.hauer@pengutronix.de>

Checking for invalid clocks on function entry allows users
to for example do a clk_set_rate(clk_lookup("myclk"), x) without
checking for validity of the result of clk_lookup first.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/clk/clk.c |   23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index bf61e5d..ea93ff8 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -43,6 +43,9 @@ int clk_enable(struct clk *clk)
 {
 	int ret;
 
+	if (IS_ERR(clk))
+		return PTR_ERR(clk);
+
 	if (!clk->enable_count) {
 		ret = clk_parent_enable(clk);
 		if (ret)
@@ -64,6 +67,9 @@ int clk_enable(struct clk *clk)
 
 void clk_disable(struct clk *clk)
 {
+	if (IS_ERR(clk))
+		return;
+
 	if (!clk->enable_count)
 		return;
 
@@ -82,6 +88,9 @@ unsigned long clk_get_rate(struct clk *clk)
 	struct clk *parent;
 	unsigned long parent_rate = 0;
 
+	if (IS_ERR(clk))
+		return 0;
+
 	parent = clk_get_parent(clk);
 	if (!IS_ERR_OR_NULL(parent))
 		parent_rate = clk_get_rate(parent);
@@ -94,6 +103,9 @@ unsigned long clk_get_rate(struct clk *clk)
 
 long clk_round_rate(struct clk *clk, unsigned long rate)
 {
+	if (IS_ERR(clk))
+		return 0;
+
 	return clk_get_rate(clk);
 }
 
@@ -102,6 +114,9 @@ int clk_set_rate(struct clk *clk, unsigned long rate)
 	struct clk *parent;
 	unsigned long parent_rate = 0;
 
+	if (IS_ERR(clk))
+		return PTR_ERR(clk);
+
 	parent = clk_get_parent(clk);
 	if (parent)
 		parent_rate = clk_get_rate(parent);
@@ -131,6 +146,11 @@ int clk_set_parent(struct clk *clk, struct clk *parent)
 {
 	int i;
 
+	if (IS_ERR(clk))
+		return PTR_ERR(clk);
+	if (IS_ERR(parent))
+		return PTR_ERR(parent);
+
 	if (!clk->num_parents)
 		return -EINVAL;
 	if (!clk->ops->set_parent)
@@ -155,6 +175,9 @@ struct clk *clk_get_parent(struct clk *clk)
 {
 	int idx;
 
+	if (IS_ERR(clk))
+		return clk;
+
 	if (!clk->num_parents)
 		return ERR_PTR(-ENODEV);
 
-- 
1.7.10.4



From s.hauer at pengutronix.de  Wed Nov 28 04:57:40 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Wed, 28 Nov 2012 10:57:40 +0100
Subject: [PATCH 2/2] ARM i.MX bbu: Allow to have no DCD
In-Reply-To: <1354096660-14174-1-git-send-email-s.hauer@pengutronix.de>
References: <1354096660-14174-1-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1354096660-14174-2-git-send-email-s.hauer@pengutronix.de>

Some boards do not have a DCD table since they initialize everything
in code, so allow to skip it and leave the corresponding pointers
empty.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/arm/mach-imx/imx-bbu-internal.c |   22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/imx-bbu-internal.c
index 4300b63..05aa5f1 100644
--- a/arch/arm/mach-imx/imx-bbu-internal.c
+++ b/arch/arm/mach-imx/imx-bbu-internal.c
@@ -357,8 +357,9 @@ static int imx_bbu_internal_v2_update(struct bbu_handler *handler, struct bbu_da
 	flash_header->header.version = IVT_VERSION;
 
 	flash_header->entry = imx_handler->app_dest + imx_pre_image_size;
-	flash_header->dcd_ptr = imx_handler->app_dest + flash_header_offset +
-		offsetof(struct imx_flash_header_v2, dcd);
+	if (imx_handler->dcdsize)
+		flash_header->dcd_ptr = imx_handler->app_dest + flash_header_offset +
+			offsetof(struct imx_flash_header_v2, dcd);
 	flash_header->boot_data_ptr = imx_handler->app_dest +
 		flash_header_offset + offsetof(struct imx_flash_header_v2, boot_data);
 	flash_header->self = imx_handler->app_dest + flash_header_offset;
@@ -366,10 +367,12 @@ static int imx_bbu_internal_v2_update(struct bbu_handler *handler, struct bbu_da
 	flash_header->boot_data.start = imx_handler->app_dest;
 	flash_header->boot_data.size = ALIGN(imx_pre_image_size + data->len, 4096);;
 
-	flash_header->dcd.header.tag = DCD_HEADER_TAG;
-	flash_header->dcd.header.length = cpu_to_be16(sizeof(struct imx_dcd) +
-			imx_handler->dcdsize);
-	flash_header->dcd.header.version = DCD_VERSION;
+	if (imx_handler->dcdsize) {
+		flash_header->dcd.header.tag = DCD_HEADER_TAG;
+		flash_header->dcd.header.length = cpu_to_be16(sizeof(struct imx_dcd) +
+				imx_handler->dcdsize);
+		flash_header->dcd.header.version = DCD_VERSION;
+	}
 
 	/* Add dcd data */
 	memcpy((void *)flash_header + sizeof(*flash_header), imx_handler->dcd, imx_handler->dcdsize);
@@ -482,6 +485,13 @@ static int imx53_bbu_internal_init_dcd(struct imx_internal_bbu_handler *imx_hand
 	uint32_t *dcd32 = dcd;
 
 	/*
+	 * For boards which do not have a dcd (i.e. they do their SDRAM
+	 * setup in C code)
+	 */
+	if (!dcd || !dcdsize)
+		return 0;
+
+	/*
 	 * The DCD data we have compiled in does not have a DCD_WR_CMD at
 	 * the beginning. Instead it is contained in struct imx_flash_header_v2.
 	 * This is necessary to generate the DCD size at compile time. If
-- 
1.7.10.4



From s.hauer at pengutronix.de  Wed Nov 28 04:57:39 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Wed, 28 Nov 2012 10:57:39 +0100
Subject: [PATCH 1/2] ARM i.MX bbu: Allow to overwrite app_dest
Message-ID: <1354096660-14174-1-git-send-email-s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/arm/boards/freescale-mx51-pdk/board.c |    2 +-
 arch/arm/boards/karo-tx53/board.c          |    5 +++--
 arch/arm/mach-imx/imx-bbu-internal.c       |   29 ++++++++++++++++++++++------
 arch/arm/mach-imx/include/mach/bbu.h       |   16 +++++++++------
 4 files changed, 37 insertions(+), 15 deletions(-)

diff --git a/arch/arm/boards/freescale-mx51-pdk/board.c b/arch/arm/boards/freescale-mx51-pdk/board.c
index cb190ef..831ed0e 100644
--- a/arch/arm/boards/freescale-mx51-pdk/board.c
+++ b/arch/arm/boards/freescale-mx51-pdk/board.c
@@ -254,7 +254,7 @@ static int f3s_devices_init(void)
 	armlinux_set_architecture(MACH_TYPE_MX51_BABBAGE);
 
 	imx51_bbu_internal_mmc_register_handler("mmc", "/dev/disk0",
-		BBU_HANDLER_FLAG_DEFAULT, dcd_entry, sizeof(dcd_entry));
+		BBU_HANDLER_FLAG_DEFAULT, dcd_entry, sizeof(dcd_entry), 0);
 
 	return 0;
 }
diff --git a/arch/arm/boards/karo-tx53/board.c b/arch/arm/boards/karo-tx53/board.c
index 581b6fa..8a69e99 100644
--- a/arch/arm/boards/karo-tx53/board.c
+++ b/arch/arm/boards/karo-tx53/board.c
@@ -218,11 +218,12 @@ static int tx53_devices_init(void)
 
 	/* rev xx30 can boot from nand or USB */
 	imx53_bbu_internal_nand_register_handler("nand-xx30",
-		BBU_HANDLER_FLAG_DEFAULT, (void *)dcd_entry_xx30, sizeof(dcd_entry_xx30), SZ_512K);
+		BBU_HANDLER_FLAG_DEFAULT, (void *)dcd_entry_xx30,
+		sizeof(dcd_entry_xx30), SZ_512K, 0);
 
 	/* rev 1011 can boot from MMC/SD, other bootsource currently unknown */
 	imx53_bbu_internal_mmc_register_handler("mmc-1011", "/dev/disk0",
-		0, (void *)dcd_entry_1011, sizeof(dcd_entry_1011));
+		0, (void *)dcd_entry_1011, sizeof(dcd_entry_1011), 0);
 
 	return 0;
 }
diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/imx-bbu-internal.c
index c34f86f..4300b63 100644
--- a/arch/arm/mach-imx/imx-bbu-internal.c
+++ b/arch/arm/mach-imx/imx-bbu-internal.c
@@ -453,7 +453,8 @@ static int __register_handler(struct imx_internal_bbu_handler *imx_handler)
  * Register a i.MX51 internal boot update handler for MMC/SD
  */
 int imx51_bbu_internal_mmc_register_handler(const char *name, char *devicefile,
-		unsigned long flags, struct imx_dcd_entry *dcd, int dcdsize)
+		unsigned long flags, struct imx_dcd_entry *dcd, int dcdsize,
+		unsigned long app_dest)
 {
 	struct imx_internal_bbu_handler *imx_handler;
 
@@ -461,7 +462,12 @@ int imx51_bbu_internal_mmc_register_handler(const char *name, char *devicefile,
 	imx_handler->dcd = dcd;
 	imx_handler->dcdsize = dcdsize;
 	imx_handler->flash_header_offset = FLASH_HEADER_OFFSET_MMC;
-	imx_handler->app_dest = 0x90000000;
+
+	if (app_dest)
+		imx_handler->app_dest = app_dest;
+	else
+		imx_handler->app_dest = 0x90000000;
+
 	imx_handler->flags = IMX_INTERNAL_FLAG_KEEP_DOSPART;
 	imx_handler->handler.handler = imx_bbu_internal_v1_update;
 
@@ -507,14 +513,20 @@ static int imx53_bbu_internal_init_dcd(struct imx_internal_bbu_handler *imx_hand
  * Register a i.MX53 internal boot update handler for MMC/SD
  */
 int imx53_bbu_internal_mmc_register_handler(const char *name, char *devicefile,
-		unsigned long flags, struct imx_dcd_v2_entry *dcd, int dcdsize)
+		unsigned long flags, struct imx_dcd_v2_entry *dcd, int dcdsize,
+		unsigned long app_dest)
 {
 	struct imx_internal_bbu_handler *imx_handler;
 
 	imx_handler = __init_handler(name, devicefile, flags);
 	imx53_bbu_internal_init_dcd(imx_handler, dcd, dcdsize);
 	imx_handler->flash_header_offset = FLASH_HEADER_OFFSET_MMC;
-	imx_handler->app_dest = 0x70000000;
+
+	if (app_dest)
+		imx_handler->app_dest = app_dest;
+	else
+		imx_handler->app_dest = 0x70000000;
+
 	imx_handler->flags = IMX_INTERNAL_FLAG_KEEP_DOSPART;
 	imx_handler->handler.handler = imx_bbu_internal_v2_update;
 
@@ -526,14 +538,19 @@ int imx53_bbu_internal_mmc_register_handler(const char *name, char *devicefile,
  */
 int imx53_bbu_internal_nand_register_handler(const char *name,
 		unsigned long flags, struct imx_dcd_v2_entry *dcd, int dcdsize,
-		int partition_size)
+		int partition_size, unsigned long app_dest)
 {
 	struct imx_internal_bbu_handler *imx_handler;
 
 	imx_handler = __init_handler(name, NULL, flags);
 	imx53_bbu_internal_init_dcd(imx_handler, dcd, dcdsize);
 	imx_handler->flash_header_offset = 0x400;
-	imx_handler->app_dest = 0x70000000;
+
+	if (app_dest)
+		imx_handler->app_dest = app_dest;
+	else
+		imx_handler->app_dest = 0x70000000;
+
 	imx_handler->handler.handler = imx_bbu_internal_v2_update;
 	imx_handler->flags = IMX_INTERNAL_FLAG_NAND;
 	imx_handler->handler.devicefile = "/dev/nand0";
diff --git a/arch/arm/mach-imx/include/mach/bbu.h b/arch/arm/mach-imx/include/mach/bbu.h
index f9ec1cc..dd3eefc 100644
--- a/arch/arm/mach-imx/include/mach/bbu.h
+++ b/arch/arm/mach-imx/include/mach/bbu.h
@@ -9,32 +9,36 @@ struct imx_dcd_v2_entry;
 #ifdef CONFIG_BAREBOX_UPDATE
 
 int imx51_bbu_internal_mmc_register_handler(const char *name, char *devicefile,
-		unsigned long flags, struct imx_dcd_entry *, int dcdsize);
+		unsigned long flags, struct imx_dcd_entry *, int dcdsize,
+		unsigned long app_dest);
 
 int imx53_bbu_internal_mmc_register_handler(const char *name, char *devicefile,
-		unsigned long flags, struct imx_dcd_v2_entry *, int dcdsize);
+		unsigned long flags, struct imx_dcd_v2_entry *, int dcdsize,
+		unsigned long app_dest);
 
 int imx53_bbu_internal_nand_register_handler(const char *name,
 		unsigned long flags, struct imx_dcd_v2_entry *, int dcdsize,
-		int partition_size);
+		int partition_size, unsigned long app_dest);
 
 #else
 
 static inline int imx51_bbu_internal_mmc_register_handler(const char *name, char *devicefile,
-		unsigned long flags, struct imx_dcd_entry *dcd, int dcdsize)
+		unsigned long flags, struct imx_dcd_entry *dcd, int dcdsize,
+		unsigned long app_dest)
 {
 	return -ENOSYS;
 }
 
 static inline int imx53_bbu_internal_mmc_register_handler(const char *name, char *devicefile,
-		unsigned long flags, struct imx_dcd_v2_entry *dcd, int dcdsize)
+		unsigned long flags, struct imx_dcd_v2_entry *dcd, int dcdsize,
+		unsigned long app_dest)
 {
 	return -ENOSYS;
 }
 
 static inline int imx53_bbu_internal_nand_register_handler(const char *name,
 		unsigned long flags, struct imx_dcd_v2_entry *dcd, int dcdsize,
-		int partition_size)
+		int partition_size, unsigned long app_dest)
 {
 	return -ENOSYS;
 }
-- 
1.7.10.4



From s.hauer at pengutronix.de  Wed Nov 28 04:59:16 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Wed, 28 Nov 2012 10:59:16 +0100
Subject: [PATCH] Add Garz+Fricke Vincell board support
Message-ID: <1354096760-14409-1-git-send-email-s.hauer@pengutronix.de>

This adds support for the i.MX53 based Garz+Fricke Vincell board.

Sascha

----------------------------------------------------------------
Sascha Hauer (4):
      ARM i.MX5: move pll setup defines to header file
      ARM i.MX: add esdctl-v4 support
      ARM i.MX: Add Garz+Fricke Vincell Board support
      ARM i.MX esdctl: Use defines from exisiting header file

 arch/arm/Makefile                                  |    1 +
 arch/arm/boards/freescale-mx53-loco/board.c        |    2 +-
 arch/arm/boards/guf-vincell/Makefile               |    3 +
 arch/arm/boards/guf-vincell/board.c                |  323 +++++++++
 arch/arm/boards/guf-vincell/config.h               |   24 +
 arch/arm/boards/guf-vincell/env/boot/nand-ubi      |   10 +
 arch/arm/boards/guf-vincell/env/init/bootargs-base |    8 +
 arch/arm/boards/guf-vincell/env/init/hostname      |    8 +
 arch/arm/boards/guf-vincell/env/init/mtdparts-nand |   11 +
 arch/arm/boards/guf-vincell/flash_header.c         |   41 ++
 arch/arm/boards/guf-vincell/lowlevel.c             |  164 +++++
 arch/arm/configs/vincell_defconfig                 |   81 +++
 arch/arm/mach-imx/Kconfig                          |    9 +
 arch/arm/mach-imx/Makefile                         |    4 +-
 arch/arm/mach-imx/esdctl-v4.c                      |  710 ++++++++++++++++++++
 arch/arm/mach-imx/esdctl.c                         |   28 +-
 arch/arm/mach-imx/imx-bbu-internal.c               |    2 +-
 arch/arm/mach-imx/imx51.c                          |    7 -
 arch/arm/mach-imx/imx53.c                          |   18 +-
 arch/arm/mach-imx/include/mach/esdctl-v4.h         |  520 ++++++++++++++
 arch/arm/mach-imx/include/mach/imx5.h              |   10 +-
 drivers/mfd/mc34704.c                              |    2 +-
 22 files changed, 1942 insertions(+), 44 deletions(-)
 create mode 100644 arch/arm/boards/guf-vincell/Makefile
 create mode 100644 arch/arm/boards/guf-vincell/board.c
 create mode 100644 arch/arm/boards/guf-vincell/config.h
 create mode 100644 arch/arm/boards/guf-vincell/env/boot/nand-ubi
 create mode 100644 arch/arm/boards/guf-vincell/env/init/bootargs-base
 create mode 100644 arch/arm/boards/guf-vincell/env/init/hostname
 create mode 100644 arch/arm/boards/guf-vincell/env/init/mtdparts-nand
 create mode 100644 arch/arm/boards/guf-vincell/flash_header.c
 create mode 100644 arch/arm/boards/guf-vincell/lowlevel.c
 create mode 100644 arch/arm/configs/vincell_defconfig
 create mode 100644 arch/arm/mach-imx/esdctl-v4.c
 create mode 100644 arch/arm/mach-imx/include/mach/esdctl-v4.h


From s.hauer at pengutronix.de  Wed Nov 28 04:59:17 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Wed, 28 Nov 2012 10:59:17 +0100
Subject: [PATCH 1/4] ARM i.MX5: move pll setup defines to header file
In-Reply-To: <1354096760-14409-1-git-send-email-s.hauer@pengutronix.de>
References: <1354096760-14409-1-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1354096760-14409-2-git-send-email-s.hauer@pengutronix.de>

The pll setup function is exported, so it makes sense to export
the convenience wrappers for specific frequencies aswell.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/arm/mach-imx/imx51.c             |    7 -------
 arch/arm/mach-imx/imx53.c             |   18 ++++++------------
 arch/arm/mach-imx/include/mach/imx5.h |   10 +++++++++-
 3 files changed, 15 insertions(+), 20 deletions(-)

diff --git a/arch/arm/mach-imx/imx51.c b/arch/arm/mach-imx/imx51.c
index 3d0520a..d235bd2 100644
--- a/arch/arm/mach-imx/imx51.c
+++ b/arch/arm/mach-imx/imx51.c
@@ -94,13 +94,6 @@ postcore_initcall(imx51_init);
  * power up.
  */
 
-#define setup_pll_800(base)	imx5_setup_pll((base), 800,  (( 8 << 4) + ((1 - 1) << 0)), ( 3 - 1),  1)
-#define setup_pll_665(base)	imx5_setup_pll((base), 665,  (( 6 << 4) + ((1 - 1) << 0)), (96 - 1), 89)
-#define setup_pll_600(base)	imx5_setup_pll((base), 600,  (( 6 << 4) + ((1 - 1) << 0)), ( 4 - 1),  1)
-#define setup_pll_400(base)	imx5_setup_pll((base), 400,  (( 8 << 4) + ((2 - 1) << 0)), ( 3 - 1),  1)
-#define setup_pll_455(base)	imx5_setup_pll((base), 455,  (( 9 << 4) + ((2 - 1) << 0)), (48 - 1), 23)
-#define setup_pll_216(base)	imx5_setup_pll((base), 216,  (( 6 << 4) + ((3 - 1) << 0)), ( 4 - 1),  3)
-
 void imx51_init_lowlevel(unsigned int cpufreq_mhz)
 {
 	void __iomem *ccm = (void __iomem *)MX51_CCM_BASE_ADDR;
diff --git a/arch/arm/mach-imx/imx53.c b/arch/arm/mach-imx/imx53.c
index 2d6557f..52fb8f7 100644
--- a/arch/arm/mach-imx/imx53.c
+++ b/arch/arm/mach-imx/imx53.c
@@ -75,12 +75,6 @@ static int imx53_init(void)
 }
 postcore_initcall(imx53_init);
 
-#define setup_pll_1000(base)	imx5_setup_pll((base), 1000, ((10 << 4) + ((1 - 1) << 0)), (12 - 1), 5)
-#define setup_pll_800(base)	imx5_setup_pll((base), 800, ((8 << 4) + ((1 - 1) << 0)), (3 - 1), 1)
-#define setup_pll_400(base)	imx5_setup_pll((base), 400, ((8 << 4) + ((2 - 1)  << 0)), (3 - 1), 1)
-#define setup_pll_455(base)	imx5_setup_pll((base), 455, ((9 << 4) + ((2 - 1)  << 0)), (48 - 1), 23)
-#define setup_pll_216(base)	imx5_setup_pll((base), 216, ((8 << 4) + ((2 - 1)  << 0)), (1 - 1), 1)
-
 void imx53_init_lowlevel(unsigned int cpufreq_mhz)
 {
 	void __iomem *ccm = (void __iomem *)MX53_CCM_BASE_ADDR;
@@ -113,11 +107,11 @@ void imx53_init_lowlevel(unsigned int cpufreq_mhz)
 	writel(0x4, ccm + MX5_CCM_CCSR);
 
 	if (cpufreq_mhz == 1000)
-		setup_pll_1000((void __iomem *)MX53_PLL1_BASE_ADDR);
+		imx5_setup_pll_1000((void __iomem *)MX53_PLL1_BASE_ADDR);
 	else
-		setup_pll_800((void __iomem *)MX53_PLL1_BASE_ADDR);
+		imx5_setup_pll_800((void __iomem *)MX53_PLL1_BASE_ADDR);
 
-	setup_pll_400((void __iomem *)MX53_PLL3_BASE_ADDR);
+	imx5_setup_pll_400((void __iomem *)MX53_PLL3_BASE_ADDR);
 
         /* Switch peripheral to PLL3 */
 	writel(0x00015154, ccm + MX5_CCM_CBCMR);
@@ -126,7 +120,7 @@ void imx53_init_lowlevel(unsigned int cpufreq_mhz)
 	/* make sure change is effective */
 	while (readl(ccm + MX5_CCM_CDHIPR));
 
-	setup_pll_400((void __iomem *)MX53_PLL2_BASE_ADDR);
+	imx5_setup_pll_400((void __iomem *)MX53_PLL2_BASE_ADDR);
 
 	/* Switch peripheral to PLL2 */
 	r = 0x00808145 |
@@ -152,8 +146,8 @@ void imx53_init_lowlevel(unsigned int cpufreq_mhz)
 	/* make sure change is effective */
 	while (readl(ccm + MX5_CCM_CDHIPR));
 
-	setup_pll_216((void __iomem *)MX53_PLL3_BASE_ADDR);
-	setup_pll_455((void __iomem *)MX53_PLL4_BASE_ADDR);
+	imx53_setup_pll_216((void __iomem *)MX53_PLL3_BASE_ADDR);
+	imx5_setup_pll_455((void __iomem *)MX53_PLL4_BASE_ADDR);
 
 	/* Set the platform clock dividers */
 	writel(0x00000124, MX53_ARM_BASE_ADDR + 0x14);
diff --git a/arch/arm/mach-imx/include/mach/imx5.h b/arch/arm/mach-imx/include/mach/imx5.h
index 4c19d28..0b1bfc6 100644
--- a/arch/arm/mach-imx/include/mach/imx5.h
+++ b/arch/arm/mach-imx/include/mach/imx5.h
@@ -3,7 +3,15 @@
 
 void imx51_init_lowlevel(unsigned int cpufreq_mhz);
 void imx53_init_lowlevel(unsigned int cpufreq_mhz);
-void imx5_setup_pll(void __iomem *base, int freq, u32 op, u32 mfd, u32 mfn);
 void imx5_init_lowlevel(void);
 
+void imx5_setup_pll(void __iomem *base, int freq, u32 op, u32 mfd, u32 mfn);
+
+#define imx5_setup_pll_1000(base)	imx5_setup_pll((base), 1000, ((10 << 4) + ((1 - 1) << 0)), (12 - 1), 5)
+#define imx5_setup_pll_800(base)	imx5_setup_pll((base),  800, (( 8 << 4) + ((1 - 1) << 0)), (3 - 1), 1)
+#define imx5_setup_pll_400(base)	imx5_setup_pll((base),  400, (( 8 << 4) + ((2 - 1) << 0)), (3 - 1), 1)
+#define imx5_setup_pll_455(base)	imx5_setup_pll((base),  455, (( 9 << 4) + ((2 - 1) << 0)), (48 - 1), 23)
+#define imx53_setup_pll_216(base)	imx5_setup_pll((base),  216, (( 8 << 4) + ((2 - 1) << 0)), (1 - 1), 1)
+#define imx51_setup_pll_216(base)	imx5_setup_pll((base),  216, (( 6 << 4) + ((3 - 1) << 0)), (4 - 1), 3)
+
 #endif /* __MACH_MX53_H */
-- 
1.7.10.4



From s.hauer at pengutronix.de  Wed Nov 28 04:59:20 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Wed, 28 Nov 2012 10:59:20 +0100
Subject: [PATCH 4/4] ARM i.MX esdctl: Use defines from exisiting header file
In-Reply-To: <1354096760-14409-1-git-send-email-s.hauer@pengutronix.de>
References: <1354096760-14409-1-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1354096760-14409-5-git-send-email-s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/arm/mach-imx/esdctl.c |   28 +++++++++-------------------
 1 file changed, 9 insertions(+), 19 deletions(-)

diff --git a/arch/arm/mach-imx/esdctl.c b/arch/arm/mach-imx/esdctl.c
index 567ecd6..4e83c7d 100644
--- a/arch/arm/mach-imx/esdctl.c
+++ b/arch/arm/mach-imx/esdctl.c
@@ -23,6 +23,7 @@
 #include <asm/barebox-arm.h>
 #include <asm/memory.h>
 #include <mach/esdctl.h>
+#include <mach/esdctl-v4.h>
 #include <mach/imx1-regs.h>
 #include <mach/imx21-regs.h>
 #include <mach/imx25-regs.h>
@@ -112,34 +113,23 @@ static inline unsigned long imx_v3_sdram_size(void __iomem *esdctlbase, int num)
 	return size;
 }
 
-#define IMX_ESDCTL_V4_ESDCTL	0x0
-#define IMX_ESDCTL_V4_ESDMISC	0x18
-
-#define ESDCTL_V4_ESDCTL_DSIZ		(1 << 16)
-#define ESDCTL_V4_ESDMISC_DDR_4_BANK	(1 << 5)
-#define ESDCTL_V4_ESDMISC_ONECS		(1 << 20)
-
-#define ESDCTL_V4_ESDCTL_SDE_0		(1 << 31)
-#define ESDCTL_V4_ESDCTL_SDE_1		(1 << 30)
-#define ESDCTL_V4_ESDMISC_BI		(1 << 12)
-
 /*
  * v4 - found on i.MX53
  */
 static inline unsigned long imx_v4_sdram_size(void __iomem *esdctlbase, int cs)
 {
-	u32 ctlval = readl(esdctlbase + IMX_ESDCTL_V4_ESDCTL);
-	u32 esdmisc = readl(esdctlbase + IMX_ESDCTL_V4_ESDMISC);
+	u32 ctlval = readl(esdctlbase + ESDCTL_V4_ESDCTL0);
+	u32 esdmisc = readl(esdctlbase + ESDCTL_V4_ESDMISC);
 	unsigned long size;
 	int rows, cols, width = 2, banks = 8;
 
-	if (cs == 0 && !(ctlval & ESDCTL_V4_ESDCTL_SDE_0))
+	if (cs == 0 && !(ctlval & ESDCTL_V4_ESDCTLx_SDE0))
 		return 0;
-	if (cs == 1 && !(ctlval & ESDCTL_V4_ESDCTL_SDE_1))
+	if (cs == 1 && !(ctlval & ESDCTL_V4_ESDCTLx_SDE1))
 		return 0;
 
 	/* one 2GiB cs, memory is returned for cs0 only */
-	if (cs == 1 && (esdmisc & ESDCTL_V4_ESDMISC_ONECS))
+	if (cs == 1 && (esdmisc & ESDCTL_V4_ESDMISC_ONE_CS))
 		return 9;
 
 	rows = ((ctlval >> 24) & 0x7) + 11;
@@ -164,16 +154,16 @@ static inline unsigned long imx_v4_sdram_size(void __iomem *esdctlbase, int cs)
 		break;
 	}
 
-	if (ctlval & ESDCTL_V4_ESDCTL_DSIZ)
+	if (ctlval & ESDCTL_V4_ESDCTLx_DSIZ_32B)
 		width = 4;
 
-	if (esdmisc & ESDCTL_V4_ESDMISC_DDR_4_BANK)
+	if (esdmisc & ESDCTL_V4_ESDMISC_BANKS_4)
 		banks = 4;
 
 	size = (1 << cols) * (1 << rows) * banks * width;
 
 	/* bank interleaved, double size */
-	if (esdmisc & ESDCTL_V4_ESDMISC_BI)
+	if (esdmisc & ESDCTL_V4_ESDMISC_BI_ON)
 		return size * 2;
 
 	return size;
-- 
1.7.10.4



From s.hauer at pengutronix.de  Wed Nov 28 04:59:19 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Wed, 28 Nov 2012 10:59:19 +0100
Subject: [PATCH 3/4] ARM i.MX: Add Garz+Fricke Vincell Board support
In-Reply-To: <1354096760-14409-1-git-send-email-s.hauer@pengutronix.de>
References: <1354096760-14409-1-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1354096760-14409-4-git-send-email-s.hauer@pengutronix.de>

This adds support for the Garz+Fricke Vincell board. This has
a i.MX53 Processor with 512MB of DDR3 RAM.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/arm/Makefile                                  |    1 +
 arch/arm/boards/freescale-mx53-loco/board.c        |    2 +-
 arch/arm/boards/guf-vincell/Makefile               |    3 +
 arch/arm/boards/guf-vincell/board.c                |  323 ++++++++++++++++++++
 arch/arm/boards/guf-vincell/config.h               |   24 ++
 arch/arm/boards/guf-vincell/env/boot/nand-ubi      |   10 +
 arch/arm/boards/guf-vincell/env/init/bootargs-base |    8 +
 arch/arm/boards/guf-vincell/env/init/hostname      |    8 +
 arch/arm/boards/guf-vincell/env/init/mtdparts-nand |   11 +
 arch/arm/boards/guf-vincell/flash_header.c         |   41 +++
 arch/arm/boards/guf-vincell/lowlevel.c             |  164 ++++++++++
 arch/arm/configs/vincell_defconfig                 |   81 +++++
 arch/arm/mach-imx/Kconfig                          |    9 +
 arch/arm/mach-imx/imx-bbu-internal.c               |    2 +-
 drivers/mfd/mc34704.c                              |    2 +-
 15 files changed, 686 insertions(+), 3 deletions(-)
 create mode 100644 arch/arm/boards/guf-vincell/Makefile
 create mode 100644 arch/arm/boards/guf-vincell/board.c
 create mode 100644 arch/arm/boards/guf-vincell/config.h
 create mode 100644 arch/arm/boards/guf-vincell/env/boot/nand-ubi
 create mode 100644 arch/arm/boards/guf-vincell/env/init/bootargs-base
 create mode 100644 arch/arm/boards/guf-vincell/env/init/hostname
 create mode 100644 arch/arm/boards/guf-vincell/env/init/mtdparts-nand
 create mode 100644 arch/arm/boards/guf-vincell/flash_header.c
 create mode 100644 arch/arm/boards/guf-vincell/lowlevel.c
 create mode 100644 arch/arm/configs/vincell_defconfig

diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 8cef771..a11fa14 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -148,6 +148,7 @@ board-$(CONFIG_MACH_CCMX51)			:= ccxmx51
 board-$(CONFIG_MACH_TINY210)			:= friendlyarm-tiny210
 board-$(CONFIG_MACH_SABRELITE)			:= freescale-mx6-sabrelite
 board-$(CONFIG_MACH_TX53)			:= karo-tx53
+board-$(CONFIG_MACH_GUF_VINCELL)		:= guf-vincell
 
 machdirs := $(patsubst %,arch/arm/mach-%/,$(machine-y))
 
diff --git a/arch/arm/boards/freescale-mx53-loco/board.c b/arch/arm/boards/freescale-mx53-loco/board.c
index 38ece23..5846725 100644
--- a/arch/arm/boards/freescale-mx53-loco/board.c
+++ b/arch/arm/boards/freescale-mx53-loco/board.c
@@ -194,7 +194,7 @@ static int loco_devices_init(void)
 	armlinux_set_architecture(MACH_TYPE_MX53_LOCO);
 
 	imx53_bbu_internal_mmc_register_handler("mmc", "/dev/disk0",
-		BBU_HANDLER_FLAG_DEFAULT, dcd_entry, sizeof(dcd_entry));
+		BBU_HANDLER_FLAG_DEFAULT, dcd_entry, sizeof(dcd_entry), 0);
 
 	return 0;
 }
diff --git a/arch/arm/boards/guf-vincell/Makefile b/arch/arm/boards/guf-vincell/Makefile
new file mode 100644
index 0000000..8f4f978
--- /dev/null
+++ b/arch/arm/boards/guf-vincell/Makefile
@@ -0,0 +1,3 @@
+obj-y += board.o
+obj-y += flash_header.o lowlevel.o
+pbl-y += flash_header.o lowlevel.o
diff --git a/arch/arm/boards/guf-vincell/board.c b/arch/arm/boards/guf-vincell/board.c
new file mode 100644
index 0000000..0270675
--- /dev/null
+++ b/arch/arm/boards/guf-vincell/board.c
@@ -0,0 +1,323 @@
+/*
+ * Copyright (C) 2007 Sascha Hauer, Pengutronix
+ * Copyright (C) 2011 Marc Kleine-Budde <mkl at pengutronix.de>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <common.h>
+#include <environment.h>
+#include <fcntl.h>
+#include <fec.h>
+#include <fs.h>
+#include <init.h>
+#include <nand.h>
+#include <net.h>
+#include <partition.h>
+#include <sizes.h>
+#include <bbu.h>
+#include <gpio.h>
+#include <io.h>
+#include <i2c/i2c.h>
+
+#include <generated/mach-types.h>
+
+#include <mach/imx53-regs.h>
+#include <mach/iomux-mx53.h>
+#include <mach/devices-imx53.h>
+#include <mach/generic.h>
+#include <mach/imx-nand.h>
+#include <mach/iim.h>
+#include <mach/imx-nand.h>
+#include <mach/bbu.h>
+#include <mach/imx-flash-header.h>
+#include <mach/imx5.h>
+
+#include <asm/armlinux.h>
+#include <asm/mmu.h>
+
+static struct fec_platform_data fec_info = {
+	.xcv_type = RMII,
+};
+
+static iomux_v3_cfg_t vincell_pads[] = {
+	MX53_PAD_DISP0_DAT23__AUDMUX_AUD4_RXD,
+	MX53_PAD_DISP0_DAT20__AUDMUX_AUD4_TXC,
+	MX53_PAD_DISP0_DAT21__AUDMUX_AUD4_TXD,
+	MX53_PAD_DISP0_DAT22__AUDMUX_AUD4_TXFS,
+	MX53_PAD_GPIO_8__CAN1_RXCAN,
+	MX53_PAD_GPIO_7__CAN1_TXCAN,
+	MX53_PAD_KEY_ROW4__CAN2_RXCAN,
+	MX53_PAD_KEY_COL4__CAN2_TXCAN,
+	MX53_PAD_GPIO_3__CCM_CLKO2,
+	MX53_PAD_KEY_COL1__ECSPI1_MISO,
+	MX53_PAD_KEY_ROW0__ECSPI1_MOSI,
+	MX53_PAD_GPIO_19__ECSPI1_RDY,
+	MX53_PAD_KEY_COL0__ECSPI1_SCLK,
+	MX53_PAD_KEY_ROW1__GPIO4_9, /* ECSPI1_SS0 */
+	MX53_PAD_KEY_COL2__GPIO4_10, /* ECSPI1_SS1 */
+	MX53_PAD_KEY_ROW2__GPIO4_11, /* ECSPI1_SS2 */
+	MX53_PAD_KEY_COL3__GPIO4_12, /* ECSPI1_SS3 */
+	MX53_PAD_CSI0_DAT10__ECSPI2_MISO,
+	MX53_PAD_EIM_CS1__ECSPI2_MOSI,
+	MX53_PAD_EIM_A25__ECSPI2_RDY,
+	MX53_PAD_DISP0_DAT19__ECSPI2_SCLK,
+	MX53_PAD_DISP0_DAT18__GPIO5_12, /* ECSPI2_SS0 */
+	MX53_PAD_EIM_DA0__EMI_NAND_WEIM_DA_0,
+	MX53_PAD_EIM_DA1__EMI_NAND_WEIM_DA_1,
+	MX53_PAD_EIM_DA2__EMI_NAND_WEIM_DA_2,
+	MX53_PAD_EIM_DA3__EMI_NAND_WEIM_DA_3,
+	MX53_PAD_EIM_DA4__EMI_NAND_WEIM_DA_4,
+	MX53_PAD_EIM_DA5__EMI_NAND_WEIM_DA_5,
+	MX53_PAD_EIM_DA6__EMI_NAND_WEIM_DA_6,
+	MX53_PAD_EIM_DA7__EMI_NAND_WEIM_DA_7,
+	MX53_PAD_EIM_DA8__EMI_NAND_WEIM_DA_8,
+	MX53_PAD_EIM_DA9__EMI_NAND_WEIM_DA_9,
+	MX53_PAD_EIM_DA10__EMI_NAND_WEIM_DA_10,
+	MX53_PAD_EIM_DA11__EMI_NAND_WEIM_DA_11,
+	MX53_PAD_EIM_DA12__EMI_NAND_WEIM_DA_12,
+	MX53_PAD_EIM_DA13__EMI_NAND_WEIM_DA_13,
+	MX53_PAD_EIM_DA14__EMI_NAND_WEIM_DA_14,
+	MX53_PAD_EIM_DA15__EMI_NAND_WEIM_DA_15,
+	MX53_PAD_NANDF_ALE__EMI_NANDF_ALE,
+	MX53_PAD_NANDF_CLE__EMI_NANDF_CLE,
+	MX53_PAD_NANDF_CS0__EMI_NANDF_CS_0,
+	MX53_PAD_NANDF_CS1__EMI_NANDF_CS_1,
+	MX53_PAD_NANDF_CS2__EMI_NANDF_CS_2,
+	MX53_PAD_NANDF_CS3__EMI_NANDF_CS_3,
+	MX53_PAD_NANDF_RB0__EMI_NANDF_RB_0,
+	MX53_PAD_NANDF_RE_B__EMI_NANDF_RE_B,
+	MX53_PAD_NANDF_WE_B__EMI_NANDF_WE_B,
+	MX53_PAD_NANDF_WP_B__EMI_NANDF_WP_B,
+	MX53_PAD_EIM_A16__EMI_WEIM_A_16,
+	MX53_PAD_EIM_A17__EMI_WEIM_A_17,
+	MX53_PAD_EIM_A18__EMI_WEIM_A_18,
+	MX53_PAD_EIM_A19__EMI_WEIM_A_19,
+	MX53_PAD_EIM_A20__EMI_WEIM_A_20,
+	MX53_PAD_EIM_CS0__EMI_WEIM_CS_0,
+	MX53_PAD_EIM_D16__EMI_WEIM_D_16,
+	MX53_PAD_EIM_D17__EMI_WEIM_D_17,
+	MX53_PAD_EIM_D18__EMI_WEIM_D_18,
+	MX53_PAD_EIM_D19__EMI_WEIM_D_19,
+	MX53_PAD_EIM_D20__EMI_WEIM_D_20,
+	MX53_PAD_EIM_D21__EMI_WEIM_D_21,
+	MX53_PAD_EIM_D22__EMI_WEIM_D_22,
+	MX53_PAD_EIM_D23__EMI_WEIM_D_23,
+	MX53_PAD_EIM_D24__EMI_WEIM_D_24,
+	MX53_PAD_EIM_D25__EMI_WEIM_D_25,
+	MX53_PAD_EIM_D26__EMI_WEIM_D_26,
+	MX53_PAD_EIM_D27__EMI_WEIM_D_27,
+	MX53_PAD_EIM_D28__EMI_WEIM_D_28,
+	MX53_PAD_EIM_D29__EMI_WEIM_D_29,
+	MX53_PAD_EIM_D30__EMI_WEIM_D_30,
+	MX53_PAD_EIM_D31__EMI_WEIM_D_31,
+	MX53_PAD_EIM_EB0__EMI_WEIM_EB_0,
+	MX53_PAD_EIM_EB1__EMI_WEIM_EB_1,
+	MX53_PAD_EIM_OE__EMI_WEIM_OE,
+	MX53_PAD_EIM_RW__EMI_WEIM_RW,
+	MX53_PAD_SD1_CLK__ESDHC1_CLK,
+	MX53_PAD_SD1_CMD__ESDHC1_CMD,
+	MX53_PAD_SD1_DATA0__ESDHC1_DAT0,
+	MX53_PAD_SD1_DATA1__ESDHC1_DAT1,
+	MX53_PAD_SD1_DATA2__ESDHC1_DAT2,
+	MX53_PAD_SD1_DATA3__ESDHC1_DAT3,
+	MX53_PAD_DI0_PIN4__ESDHC1_WP,
+	MX53_PAD_FEC_MDC__FEC_MDC,
+	MX53_PAD_FEC_MDIO__FEC_MDIO,
+	MX53_PAD_FEC_RXD0__FEC_RDATA_0,
+	MX53_PAD_FEC_RXD1__FEC_RDATA_1,
+	MX53_PAD_FEC_CRS_DV__FEC_RX_DV,
+	MX53_PAD_FEC_RX_ER__FEC_RX_ER,
+	MX53_PAD_FEC_TXD0__FEC_TDATA_0,
+	MX53_PAD_FEC_TXD1__FEC_TDATA_1,
+	MX53_PAD_FEC_REF_CLK__FEC_TX_CLK,
+	MX53_PAD_FEC_TX_EN__FEC_TX_EN,
+	MX53_PAD_SD2_CLK__GPIO1_10,
+	MX53_PAD_SD2_DATA3__GPIO1_12,
+	MX53_PAD_GPIO_2__GPIO1_2,
+	MX53_PAD_GPIO_4__GPIO1_4,
+	MX53_PAD_PATA_DATA0__GPIO2_0,
+	MX53_PAD_PATA_DATA1__GPIO2_1,
+	MX53_PAD_PATA_DATA10__GPIO2_10,
+	MX53_PAD_PATA_DATA11__GPIO2_11,
+	MX53_PAD_PATA_DATA13__GPIO2_13,
+	MX53_PAD_PATA_DATA14__GPIO2_14,
+	MX53_PAD_PATA_DATA15__GPIO2_15,
+	MX53_PAD_PATA_DATA2__GPIO2_2,
+	MX53_PAD_PATA_DATA3__GPIO2_3,
+	MX53_PAD_EIM_EB2__GPIO2_30,
+	MX53_PAD_PATA_DATA4__PATA_DATA_4,
+	MX53_PAD_PATA_DATA5__GPIO2_5,
+	MX53_PAD_PATA_DATA6__GPIO2_6,
+	MX53_PAD_PATA_DATA7__GPIO2_7,
+	MX53_PAD_PATA_DATA8__GPIO2_8,
+	MX53_PAD_PATA_DATA9__GPIO2_9,
+	MX53_PAD_GPIO_10__GPIO4_0,
+	MX53_PAD_GPIO_11__GPIO4_1,
+	MX53_PAD_GPIO_12__GPIO4_2,
+	MX53_PAD_DISP0_DAT8__GPIO4_29,
+	MX53_PAD_GPIO_13__GPIO4_3,
+	MX53_PAD_DISP0_DAT16__GPIO5_10,
+	MX53_PAD_DISP0_DAT17__GPIO5_11,
+	MX53_PAD_CSI0_PIXCLK__GPIO5_18,
+	MX53_PAD_CSI0_MCLK__GPIO5_19,
+	MX53_PAD_CSI0_DATA_EN__GPIO5_20,
+	MX53_PAD_CSI0_VSYNC__GPIO5_21,
+	MX53_PAD_CSI0_DAT4__GPIO5_22,
+	MX53_PAD_CSI0_DAT5__GPIO5_23,
+	MX53_PAD_CSI0_DAT6__GPIO5_24,
+	MX53_PAD_DISP0_DAT14__GPIO5_8,
+	MX53_PAD_DISP0_DAT15__GPIO5_9,
+	MX53_PAD_PATA_DIOW__GPIO6_17,
+	MX53_PAD_PATA_DMACK__GPIO6_18,
+	MX53_PAD_GPIO_17__GPIO7_12,
+	MX53_PAD_GPIO_18__GPIO7_13,
+	MX53_PAD_PATA_RESET_B__GPIO7_4,
+	MX53_PAD_PATA_IORDY__GPIO7_5,
+	MX53_PAD_PATA_DA_0__GPIO7_6,
+	MX53_PAD_PATA_DA_2__GPIO7_8,
+	MX53_PAD_CSI0_DAT9__I2C1_SCL,
+	MX53_PAD_CSI0_DAT8__I2C1_SDA,
+	MX53_PAD_KEY_COL3__I2C2_SCL,
+	MX53_PAD_KEY_ROW3__I2C2_SDA,
+	MX53_PAD_GPIO_5__I2C3_SCL,
+	MX53_PAD_GPIO_6__I2C3_SDA,
+	MX53_PAD_KEY_COL0__KPP_COL_0,
+	MX53_PAD_KEY_COL1__KPP_COL_1,
+	MX53_PAD_KEY_COL2__KPP_COL_2,
+	MX53_PAD_KEY_COL3__KPP_COL_3,
+	MX53_PAD_GPIO_19__KPP_COL_5,
+	MX53_PAD_GPIO_9__KPP_COL_6,
+	MX53_PAD_SD2_DATA1__KPP_COL_7,
+	MX53_PAD_KEY_ROW0__KPP_ROW_0,
+	MX53_PAD_KEY_ROW1__KPP_ROW_1,
+	MX53_PAD_KEY_ROW2__KPP_ROW_2,
+	MX53_PAD_KEY_ROW3__KPP_ROW_3,
+	MX53_PAD_SD2_CMD__KPP_ROW_5,
+	MX53_PAD_SD2_DATA2__KPP_ROW_6,
+	MX53_PAD_SD2_DATA0__KPP_ROW_7,
+	MX53_PAD_LVDS0_CLK_P__LDB_LVDS0_CLK,
+	MX53_PAD_LVDS0_TX0_P__LDB_LVDS0_TX0,
+	MX53_PAD_LVDS0_TX1_P__LDB_LVDS0_TX1,
+	MX53_PAD_LVDS0_TX2_P__LDB_LVDS0_TX2,
+	MX53_PAD_LVDS0_TX3_P__LDB_LVDS0_TX3,
+	MX53_PAD_DISP0_DAT8__PWM1_PWMO,
+	MX53_PAD_DISP0_DAT9__PWM2_PWMO,
+	MX53_PAD_PATA_INTRQ__UART2_CTS,
+	MX53_PAD_PATA_DIOR__UART2_RTS,
+	MX53_PAD_PATA_BUFFER_EN__UART2_RXD_MUX,
+	MX53_PAD_PATA_DMARQ__UART2_TXD_MUX,
+	MX53_PAD_PATA_DA_1__UART3_CTS,
+	MX53_PAD_PATA_CS_1__UART3_RXD_MUX,
+	MX53_PAD_PATA_CS_0__UART3_TXD_MUX,
+	MX53_PAD_CSI0_DAT17__UART4_CTS,
+	MX53_PAD_CSI0_DAT16__UART4_RTS,
+	MX53_PAD_CSI0_DAT13__UART4_RXD_MUX,
+	MX53_PAD_CSI0_DAT12__UART4_TXD_MUX,
+	MX53_PAD_CSI0_DAT19__UART5_CTS,
+	MX53_PAD_CSI0_DAT18__UART5_RTS,
+	MX53_PAD_CSI0_DAT15__UART5_RXD_MUX,
+	MX53_PAD_CSI0_DAT14__UART5_TXD_MUX,
+	MX53_PAD_GPIO_0__USBOH3_USBH1_PWR,
+	MX53_PAD_DISP0_DAT12__USBOH3_USBH2_CLK,
+	MX53_PAD_DISP0_DAT0__USBOH3_USBH2_DATA_0,
+	MX53_PAD_DISP0_DAT1__USBOH3_USBH2_DATA_1,
+	MX53_PAD_DISP0_DAT2__USBOH3_USBH2_DATA_2,
+	MX53_PAD_DISP0_DAT3__USBOH3_USBH2_DATA_3,
+	MX53_PAD_DISP0_DAT4__USBOH3_USBH2_DATA_4,
+	MX53_PAD_DISP0_DAT5__USBOH3_USBH2_DATA_5,
+	MX53_PAD_DISP0_DAT6__USBOH3_USBH2_DATA_6,
+	MX53_PAD_DISP0_DAT7__USBOH3_USBH2_DATA_7,
+	MX53_PAD_DI0_DISP_CLK__USBOH3_USBH2_DIR,
+	MX53_PAD_DISP0_DAT11__USBOH3_USBH2_NXT,
+	MX53_PAD_DISP0_DAT10__USBOH3_USBH2_STP,
+	MX53_PAD_GPIO_1__WDOG2_WDOG_B,
+};
+
+#define LOCO_FEC_PHY_RST		IMX_GPIO_NR(7, 6)
+
+static void vincell_fec_reset(void)
+{
+	gpio_direction_output(LOCO_FEC_PHY_RST, 0);
+	mdelay(1);
+	gpio_set_value(LOCO_FEC_PHY_RST, 1);
+}
+
+static struct imx_nand_platform_data nand_info = {
+	.width		= 1,
+	.hw_ecc		= 1,
+	.flash_bbt	= 1,
+};
+
+static struct imx_dcd_v2_entry __dcd_entry_section dcd_entry[] = {
+};
+
+static struct i2c_board_info i2c_devices[] = {
+	{
+		I2C_BOARD_INFO("da9053", 0x48),
+	},
+};
+
+#include <linux/clk.h>
+
+static int vincell_devices_init(void)
+{
+	writel(0, MX53_M4IF_BASE_ADDR + 0xc);
+
+	console_flush();
+	imx53_init_lowlevel(1000);
+	clk_set_rate(clk_lookup("nfc_podf"), 66666667);
+
+	imx53_add_nand(&nand_info);
+	imx51_iim_register_fec_ethaddr();
+	imx53_add_fec(&fec_info);
+	imx53_add_mmc0(NULL);
+	i2c_register_board_info(0, i2c_devices, ARRAY_SIZE(i2c_devices));
+	imx53_add_i2c0(NULL);
+
+	vincell_fec_reset();
+
+	armlinux_set_bootparams((void *)0x70000100);
+	armlinux_set_architecture(3297);
+
+	devfs_add_partition("nand0", SZ_1M, SZ_512K, DEVFS_PARTITION_FIXED, "self_raw");
+	dev_add_bb_dev("self_raw", "self0");
+	devfs_add_partition("nand0", SZ_1M + SZ_512K, SZ_512K, DEVFS_PARTITION_FIXED, "env_raw");
+	dev_add_bb_dev("env_raw", "env0");
+
+	imx53_bbu_internal_nand_register_handler("nand",
+		BBU_HANDLER_FLAG_DEFAULT, dcd_entry, sizeof(dcd_entry), 3 * SZ_128K, 0xf8020000);
+
+	return 0;
+}
+
+device_initcall(vincell_devices_init);
+
+static int vincell_part_init(void)
+{
+	devfs_add_partition("disk0", 0x00000, 0x40000, DEVFS_PARTITION_FIXED, "self0");
+	devfs_add_partition("disk0", 0x40000, 0x20000, DEVFS_PARTITION_FIXED, "env0");
+
+	return 0;
+}
+late_initcall(vincell_part_init);
+
+static int vincell_console_init(void)
+{
+	mxc_iomux_v3_setup_multiple_pads(vincell_pads, ARRAY_SIZE(vincell_pads));
+
+	imx53_add_uart1();
+
+	return 0;
+}
+
+console_initcall(vincell_console_init);
diff --git a/arch/arm/boards/guf-vincell/config.h b/arch/arm/boards/guf-vincell/config.h
new file mode 100644
index 0000000..b7effe5
--- /dev/null
+++ b/arch/arm/boards/guf-vincell/config.h
@@ -0,0 +1,24 @@
+/**
+ * @file
+ * @brief Global defintions for the ARM i.MX51 based babbage board
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+#endif	/* __CONFIG_H */
diff --git a/arch/arm/boards/guf-vincell/env/boot/nand-ubi b/arch/arm/boards/guf-vincell/env/boot/nand-ubi
new file mode 100644
index 0000000..a3f748e
--- /dev/null
+++ b/arch/arm/boards/guf-vincell/env/boot/nand-ubi
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+	boot-menu-add-entry "$0" "nand (UBI)"
+	exit
+fi
+
+global.bootm.image="/dev/nand0.kernel.bb"
+#global.bootm.oftree="/env/oftree"
+bootargs-root-ubi -r root -m nand0.root
diff --git a/arch/arm/boards/guf-vincell/env/init/bootargs-base b/arch/arm/boards/guf-vincell/env/init/bootargs-base
new file mode 100644
index 0000000..d869754
--- /dev/null
+++ b/arch/arm/boards/guf-vincell/env/init/bootargs-base
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+	init-menu-add-entry "$0" "Base bootargs"
+	exit
+fi
+
+global.linux.bootargs.base="console=ttymxc0,115200"
diff --git a/arch/arm/boards/guf-vincell/env/init/hostname b/arch/arm/boards/guf-vincell/env/init/hostname
new file mode 100644
index 0000000..ca2789d
--- /dev/null
+++ b/arch/arm/boards/guf-vincell/env/init/hostname
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+	init-menu-add-entry "$0" "hostname"
+	exit
+fi
+
+global.hostname=vincell
diff --git a/arch/arm/boards/guf-vincell/env/init/mtdparts-nand b/arch/arm/boards/guf-vincell/env/init/mtdparts-nand
new file mode 100644
index 0000000..84220b7
--- /dev/null
+++ b/arch/arm/boards/guf-vincell/env/init/mtdparts-nand
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+	init-menu-add-entry "$0" "NAND partitions"
+	exit
+fi
+
+mtdparts="512k(nand0.barebox)ro,128k(nand0.bareboxenv),4M(nand0.kernel),-(nand0.root)"
+kernelname="mxc_nand"
+
+mtdparts-add -b -d nand0 -k ${kernelname} -p ${mtdparts}
diff --git a/arch/arm/boards/guf-vincell/flash_header.c b/arch/arm/boards/guf-vincell/flash_header.c
new file mode 100644
index 0000000..df480d2
--- /dev/null
+++ b/arch/arm/boards/guf-vincell/flash_header.c
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2011 Marc Kleine-Budde <mkl at pengutronix.de>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <common.h>
+#include <sizes.h>
+#include <asm/byteorder.h>
+#include <asm/barebox-arm-head.h>
+#include <mach/imx-flash-header.h>
+
+void __naked __flash_header_start go(void)
+{
+	barebox_arm_head();
+}
+
+#define APP_DEST	0xf8020000
+
+struct imx_flash_header_v2 __flash_header_section flash_header = {
+	.header.tag		= IVT_HEADER_TAG,
+	.header.length		= cpu_to_be16(32),
+	.header.version		= IVT_VERSION,
+
+	.entry			= APP_DEST + 0x1000,
+	.dcd_ptr		= APP_DEST + 0x400 + offsetof(struct imx_flash_header_v2, dcd),
+	.boot_data_ptr		= APP_DEST + 0x400 + offsetof(struct imx_flash_header_v2, boot_data),
+	.self			= APP_DEST + 0x400,
+
+	.boot_data.start	= APP_DEST,
+	.boot_data.size		= DCD_BAREBOX_SIZE,
+};
diff --git a/arch/arm/boards/guf-vincell/lowlevel.c b/arch/arm/boards/guf-vincell/lowlevel.c
new file mode 100644
index 0000000..2541117
--- /dev/null
+++ b/arch/arm/boards/guf-vincell/lowlevel.c
@@ -0,0 +1,164 @@
+#include <common.h>
+#include <io.h>
+#include <init.h>
+#include <mach/imx53-regs.h>
+#include <mach/imx5.h>
+#include <mach/iomux-v3.h>
+#include <mach/esdctl-v4.h>
+#include <asm/barebox-arm.h>
+#include <asm/barebox-arm-head.h>
+#include <io.h>
+
+void blink(void)
+{
+	volatile int i;
+
+	writel(0x1, 0x53fa82a8);
+	writel(0x2, 0x53f88004);
+
+	while (1) {
+		for (i = 0; i < 1000000; i++);
+		writel(0x2, 0x53f88000);
+		for (i = 0; i < 1000000; i++);
+		writel(0x0, 0x53f88000);
+	}
+}
+
+#define IOMUX_PADCTL_DDRI_DDR (1 << 9)
+
+#define IOMUX_PADCTL_DDRDSE(x)	((x) << 19)
+#define IOMUX_PADCTL_DDRSEL(x)	((x) << 25)
+
+#define IOMUXC_SW_PAD_CTL_PAD_DRAM_DQM3		0x554
+#define IOMUXC_SW_PAD_CTL_PAD_DRAM_SDQS3	0x558
+#define IOMUXC_SW_PAD_CTL_PAD_DRAM_DQM2		0x560
+#define IOMUXC_SW_PAD_CTL_PAD_DRAM_SDODT1	0x564
+#define IOMUXC_SW_PAD_CTL_PAD_DRAM_SDQS2	0x568
+#define IOMUXC_SW_PAD_CTL_PAD_DRAM_SDCLK_1	0x570
+#define IOMUXC_SW_PAD_CTL_PAD_DRAM_CAS		0x574
+#define IOMUXC_SW_PAD_CTL_PAD_DRAM_SDCLK_0	0x578
+#define IOMUXC_SW_PAD_CTL_PAD_DRAM_SDQS0	0x57c
+#define IOMUXC_SW_PAD_CTL_PAD_DRAM_SDODT0	0x580
+#define IOMUXC_SW_PAD_CTL_PAD_DRAM_RAS		0x588
+#define IOMUXC_SW_PAD_CTL_PAD_DRAM_SDQS1	0x590
+#define IOMUXC_SW_PAD_CTL_PAD_DRAM_DQM1		0x594
+#define IOMUXC_SW_PAD_CTL_PAD_DRAM_DQM0		0x584
+#define IOMUXC_SW_PAD_CTL_GRP_ADDDS		0x6f0
+#define IOMUXC_SW_PAD_CTL_GRP_DDRMODE_CTL	0x6f4
+#define IOMUXC_SW_PAD_CTL_GRP_DDRPKE		0x6fc
+#define IOMUXC_SW_PAD_CTL_GRP_DDRHYS		0x710
+#define IOMUXC_SW_PAD_CTL_GRP_DDRMODE		0x714
+#define IOMUXC_SW_PAD_CTL_GRP_B0DS		0x718
+#define IOMUXC_SW_PAD_CTL_GRP_B1DS		0x71c
+#define IOMUXC_SW_PAD_CTL_GRP_CTLDS		0x720
+#define IOMUXC_SW_PAD_CTL_GRP_DDR_TYPE		0x724
+#define IOMUXC_SW_PAD_CTL_GRP_B2DS		0x728
+#define IOMUXC_SW_PAD_CTL_GRP_B3DS		0x72c
+
+
+static void configure_dram_iomux(void)
+{
+	void __iomem *iomux = (void *)MX53_IOMUXC_BASE_ADDR;
+	u32 r1, r2, r4, r5, r6;
+
+	/* define the INPUT mode for DRAM_D[31:0] */
+	writel(0, iomux + IOMUXC_SW_PAD_CTL_GRP_DDRMODE);
+
+	/*
+	 * define the INPUT mode for SDQS[3:0]
+	 * (Freescale's documentation suggests DDR-mode for the
+	 * control line, but their source actually uses CMOS)
+	 */
+	writel(IOMUX_PADCTL_DDRI_DDR, iomux + IOMUXC_SW_PAD_CTL_GRP_DDRMODE_CTL);
+
+	r1 = IOMUX_PADCTL_DDRDSE(5);
+	r2 = IOMUX_PADCTL_DDRDSE(5) | PAD_CTL_PUE;
+	r4 = IOMUX_PADCTL_DDRSEL(2);
+	r5 = IOMUX_PADCTL_DDRDSE(5) | PAD_CTL_PKE | PAD_CTL_PUE | IOMUX_PADCTL_DDRI_DDR | PAD_CTL_PUS_47K_UP;
+	r6 = IOMUX_PADCTL_DDRDSE(4);
+
+	/*
+	 * this will adisable the Pull/Keeper for DRAM_x pins EXCEPT,
+	 * for DRAM_SDQS[3:0] and DRAM_SDODT[1:0]
+	 */
+	writel(0, iomux + IOMUXC_SW_PAD_CTL_GRP_DDRPKE);
+
+	/* set global drive strength for all DRAM_x pins */
+	writel(r4, iomux + IOMUXC_SW_PAD_CTL_GRP_DDR_TYPE);
+
+	/* set data dqs dqm drive strength */
+	writel(r6, iomux + IOMUXC_SW_PAD_CTL_GRP_B0DS);
+	writel(r6, iomux + IOMUXC_SW_PAD_CTL_PAD_DRAM_DQM0);
+	writel(r5, iomux + IOMUXC_SW_PAD_CTL_PAD_DRAM_SDQS0);
+
+	writel(r1, iomux + IOMUXC_SW_PAD_CTL_GRP_B1DS);
+	writel(r1, iomux + IOMUXC_SW_PAD_CTL_PAD_DRAM_DQM1);
+	writel(r5, iomux + IOMUXC_SW_PAD_CTL_PAD_DRAM_SDQS1);
+
+	writel(r6, iomux + IOMUXC_SW_PAD_CTL_GRP_B2DS);
+	writel(r6, iomux + IOMUXC_SW_PAD_CTL_PAD_DRAM_DQM2);
+	writel(r5, iomux + IOMUXC_SW_PAD_CTL_PAD_DRAM_SDQS2);
+
+	writel(r1, iomux + IOMUXC_SW_PAD_CTL_GRP_B3DS);
+	writel(r1, iomux + IOMUXC_SW_PAD_CTL_PAD_DRAM_DQM3);
+	writel(r5, iomux + IOMUXC_SW_PAD_CTL_PAD_DRAM_SDQS3);
+
+	/* SDCLK pad drive strength control options */
+	writel(r1, iomux + IOMUXC_SW_PAD_CTL_PAD_DRAM_SDCLK_0);
+	writel(r1, iomux + IOMUXC_SW_PAD_CTL_PAD_DRAM_SDCLK_1);
+
+	/* Control and addr bus pad drive strength control options */
+	writel(r1, iomux + IOMUXC_SW_PAD_CTL_PAD_DRAM_RAS);
+	writel(r1, iomux + IOMUXC_SW_PAD_CTL_PAD_DRAM_CAS);
+	writel(r1, iomux + IOMUXC_SW_PAD_CTL_GRP_ADDDS);
+	writel(r1, iomux + IOMUXC_SW_PAD_CTL_GRP_CTLDS);
+	writel(r2, iomux + IOMUXC_SW_PAD_CTL_PAD_DRAM_SDODT0);
+	writel(r2, iomux + IOMUXC_SW_PAD_CTL_PAD_DRAM_SDODT1);
+
+	/*
+	 * enable hysteresis on input pins
+	 * (Freescale's documentation suggests that enable hysteresis
+	 * would be better, but their source-code doesn't)
+	 */
+	writel(PAD_CTL_HYS, iomux + IOMUXC_SW_PAD_CTL_GRP_DDRHYS);
+}
+
+void disable_watchdog(void)
+{
+	/*
+	 * configure WDOG to generate external reset on trigger
+	 * and disable power down counter
+	 */
+	writew(0x38, MX53_WDOG1_BASE_ADDR);
+	writew(0x0, MX53_WDOG1_BASE_ADDR + 8);
+	writew(0x38, MX53_WDOG2_BASE_ADDR);
+	writew(0x0, MX53_WDOG2_BASE_ADDR + 8);
+}
+
+void sdram_init(void);
+
+void __bare_init __naked reset(void)
+{
+	u32 r;
+
+	common_reset();
+
+	/* Skip SDRAM initialization if we run from RAM */
+	r = get_pc();
+	if (r > 0x70000000 && r < 0xf0000000)
+		board_init_lowlevel_return();
+
+	/* Setup a preliminary stack */
+	r = 0xf8000000 + 0x60000 - 16;
+	__asm__ __volatile__("mov sp, %0" : : "r"(r));
+
+	disable_watchdog();
+
+	configure_dram_iomux();
+
+	imx5_init_lowlevel();
+
+	imx_esdctlv4_init();
+
+	board_init_lowlevel_return();
+}
diff --git a/arch/arm/configs/vincell_defconfig b/arch/arm/configs/vincell_defconfig
new file mode 100644
index 0000000..8bc6870
--- /dev/null
+++ b/arch/arm/configs/vincell_defconfig
@@ -0,0 +1,81 @@
+CONFIG_ARCH_IMX=y
+CONFIG_ARCH_IMX53=y
+CONFIG_MACH_GUF_VINCELL=y
+CONFIG_IMX_IIM=y
+CONFIG_IMX_IIM_FUSE_BLOW=y
+CONFIG_THUMB2_BAREBOX=y
+CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y
+CONFIG_ARM_UNWIND=y
+CONFIG_PBL_IMAGE=y
+CONFIG_MMU=y
+CONFIG_TEXT_BASE=0x7fe00000
+CONFIG_MALLOC_SIZE=0x2000000
+CONFIG_MALLOC_TLSF=y
+CONFIG_KALLSYMS=y
+CONFIG_LONGHELP=y
+CONFIG_HUSH_FANCY_PROMPT=y
+CONFIG_CMDLINE_EDITING=y
+CONFIG_AUTO_COMPLETE=y
+CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y
+CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/arm/boards/guf-vincell/env"
+CONFIG_DEBUG_INFO=y
+CONFIG_DEBUG_LL=y
+CONFIG_CMD_EDIT=y
+CONFIG_CMD_SLEEP=y
+CONFIG_CMD_MSLEEP=y
+CONFIG_CMD_SAVEENV=y
+CONFIG_CMD_EXPORT=y
+CONFIG_CMD_PRINTENV=y
+CONFIG_CMD_READLINE=y
+CONFIG_CMD_TIME=y
+CONFIG_CMD_DIRNAME=y
+CONFIG_CMD_LN=y
+CONFIG_CMD_READLINK=y
+CONFIG_CMD_TFTP=y
+CONFIG_CMD_FILETYPE=y
+CONFIG_CMD_ECHO_E=y
+CONFIG_CMD_MEMINFO=y
+CONFIG_CMD_IOMEM=y
+CONFIG_CMD_CRC=y
+CONFIG_CMD_CRC_CMP=y
+CONFIG_CMD_MD5SUM=y
+CONFIG_CMD_FLASH=y
+CONFIG_CMD_BOOTM_SHOW_TYPE=y
+CONFIG_CMD_BOOTM_VERBOSE=y
+CONFIG_CMD_BOOTM_INITRD=y
+CONFIG_CMD_BOOTM_OFTREE=y
+# CONFIG_CMD_BOOTU is not set
+CONFIG_CMD_RESET=y
+CONFIG_CMD_GO=y
+CONFIG_CMD_OFTREE=y
+CONFIG_CMD_BAREBOX_UPDATE=y
+CONFIG_CMD_TIMEOUT=y
+CONFIG_CMD_PARTITION=y
+CONFIG_CMD_MAGICVAR=y
+CONFIG_CMD_MAGICVAR_HELP=y
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_UNCOMPRESS=y
+CONFIG_CMD_MIITOOL=y
+CONFIG_CMD_CLK=y
+CONFIG_NET=y
+CONFIG_NET_DHCP=y
+CONFIG_NET_NFS=y
+CONFIG_NET_PING=y
+CONFIG_NET_RESOLV=y
+CONFIG_DRIVER_NET_FEC_IMX=y
+# CONFIG_SPI is not set
+CONFIG_MTD=y
+CONFIG_MTD_RAW_DEVICE=y
+CONFIG_NAND=y
+# CONFIG_NAND_ECC_SOFT is not set
+# CONFIG_NAND_ECC_HW_SYNDROME is not set
+# CONFIG_NAND_ECC_HW_NONE is not set
+CONFIG_NAND_IMX=y
+CONFIG_MCI=y
+CONFIG_MCI_STARTUP=y
+CONFIG_MCI_IMX_ESDHC=y
+CONFIG_FS_TFTP=y
+CONFIG_FS_NFS=y
+CONFIG_FS_FAT=y
+CONFIG_FS_FAT_WRITE=y
+CONFIG_FS_FAT_LFN=y
diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index 3f4b452..2449acf 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -28,6 +28,7 @@ config ARCH_TEXT_BASE
 	default 0x97f00000 if MACH_CCMX51
 	default 0x4fc00000 if MACH_SABRELITE
 	default 0x8fe00000 if MACH_TX53
+	default 0x7fc00000 if MACH_GUF_VINCELL
 
 config BOARDINFO
 	default "Eukrea CPUIMX25" if MACH_EUKREA_CPUIMX25
@@ -55,6 +56,7 @@ config BOARDINFO
 	default "ConnectCore i.MX51" if MACH_CCMX51
 	default "Sabre Lite" if MACH_SABRELITE
 	default "Ka-Ro tx53" if MACH_TX53
+	default "Garz+Fricke Vincell" if MACH_GUF_VINCELL
 
 choice
 	prompt "Select boot mode"
@@ -468,6 +470,11 @@ config MACH_TX53
 	help
 	  Say Y here if you are using the Ka-Ro tx53 board
 
+config MACH_GUF_VINCELL
+	select HAVE_DEFAULT_ENVIRONMENT_NEW
+	select MACH_HAS_LOWLEVEL_INIT
+	bool "Garz-Fricke Vincell"
+
 endchoice
 
 if MACH_TX53
@@ -477,7 +484,9 @@ config TX53_REV_1011
 	bool "1011"
 config TX53_REV_XX30
 	bool "8030 / 1030"
+
 endchoice
+
 endif
 
 endif
diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/imx-bbu-internal.c
index 05aa5f1..cfde75d 100644
--- a/arch/arm/mach-imx/imx-bbu-internal.c
+++ b/arch/arm/mach-imx/imx-bbu-internal.c
@@ -15,7 +15,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  */
-
+#define DEBUG
 #define IMX_INTERNAL_NAND_BBU
 
 #include <common.h>
diff --git a/drivers/mfd/mc34704.c b/drivers/mfd/mc34704.c
index 276b723..54d27c8 100644
--- a/drivers/mfd/mc34704.c
+++ b/drivers/mfd/mc34704.c
@@ -25,7 +25,7 @@
 #include <i2c/i2c.h>
 #include <mfd/mc34704.h>
 
-#define DRIVERNAME		"mc34704"
+#define DRIVERNAME		"da9053"
 
 #define to_mc34704(a)		container_of(a, struct mc34704, cdev)
 
-- 
1.7.10.4



From s.hauer at pengutronix.de  Wed Nov 28 04:59:18 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Wed, 28 Nov 2012 10:59:18 +0100
Subject: [PATCH 2/4] ARM i.MX: add esdctl-v4 support
In-Reply-To: <1354096760-14409-1-git-send-email-s.hauer@pengutronix.de>
References: <1354096760-14409-1-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1354096760-14409-3-git-send-email-s.hauer@pengutronix.de>

This adds support for initializing DDR3 RAMs on the i.MX53 type
SDRAM controller. The code automatically detects size/layout of
the connected RAM, detects the bus width and which chipselects are
populated.
While I believe this code is not 100% generic, it is far too
sophisticated to stay in a single board directory. I'm sure
other boards could make use of this aswell.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/arm/mach-imx/Makefile                 |    4 +-
 arch/arm/mach-imx/esdctl-v4.c              |  710 ++++++++++++++++++++++++++++
 arch/arm/mach-imx/include/mach/esdctl-v4.h |  520 ++++++++++++++++++++
 3 files changed, 1232 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/mach-imx/esdctl-v4.c
 create mode 100644 arch/arm/mach-imx/include/mach/esdctl-v4.h

diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index 6bc2b79..104ab21 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -6,8 +6,8 @@ obj-$(CONFIG_ARCH_IMX27) += imx27.o iomux-v1.o clk-imx27.o
 obj-$(CONFIG_ARCH_IMX31) += imx31.o iomux-v2.o clk-imx31.o
 obj-$(CONFIG_ARCH_IMX35) += imx35.o iomux-v3.o clk-imx35.o
 obj-$(CONFIG_ARCH_IMX51) += imx51.o iomux-v3.o imx5.o clk-imx5.o
-obj-$(CONFIG_ARCH_IMX53) += imx53.o iomux-v3.o imx5.o clk-imx5.o
-pbl-$(CONFIG_ARCH_IMX53) += imx53.o imx5.o
+obj-$(CONFIG_ARCH_IMX53) += imx53.o iomux-v3.o imx5.o clk-imx5.o esdctl-v4.o
+pbl-$(CONFIG_ARCH_IMX53) += imx53.o imx5.o esdctl-v4.o
 obj-$(CONFIG_ARCH_IMX6) += imx6.o iomux-v3.o usb-imx6.o clk-imx6.o
 obj-$(CONFIG_IMX_IIM)	+= iim.o
 obj-$(CONFIG_NAND_IMX) += nand.o
diff --git a/arch/arm/mach-imx/esdctl-v4.c b/arch/arm/mach-imx/esdctl-v4.c
new file mode 100644
index 0000000..6441ac9
--- /dev/null
+++ b/arch/arm/mach-imx/esdctl-v4.c
@@ -0,0 +1,710 @@
+/*
+ * esdctl-v4.c - i.MX sdram controller functions for i.MX53
+ *
+ * Copyright (c) 2012 Sascha Hauer <s.hauer at pengutronix.de>, Pengutronix
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <common.h>
+#include <io.h>
+#include <mach/esdctl-v4.h>
+#include <mach/imx53-regs.h>
+#include <asm/system.h>
+
+void imx_esdctlv4_do_write_leveling(void)
+{
+	u32 val;
+	void __iomem *base = (void *)MX53_ESDCTL_BASE_ADDR;
+
+	/* switch RAMs to write-leveling mode */
+
+	val = ESDCTL_V4_DDR3_MR1_ODIC_RZQ7 | ESDCTL_V4_DDR3_MR1_RTTN_DIS |
+		ESDCTL_V4_DDR3_MR1_AL_DISABLE | ESDCTL_V4_DDR3_MR1_WL |
+		ESDCTL_V4_ESDSCR_CON_REQ | ESDCTL_V4_ESDSCR_CMD_LMR |
+		ESDCTL_V4_ESDSCR_CMD_CS0 | ESDCTL_V4_ESDSCR_WL_EN |
+		ESDCTL_V4_DDR3_REG_MR1;
+	writel(val, base + ESDCTL_V4_ESDSCR);
+
+	val = ESDCTL_V4_DDR3_MR1_ODIC_RZQ7 | ESDCTL_V4_DDR3_MR1_RTTN_DIS |
+		ESDCTL_V4_DDR3_MR1_AL_DISABLE |	ESDCTL_V4_DDR3_MR1_WL |
+		ESDCTL_V4_ESDSCR_CON_REQ | ESDCTL_V4_ESDSCR_CMD_LMR |
+		ESDCTL_V4_ESDSCR_CMD_CS1 | ESDCTL_V4_ESDSCR_WL_EN |
+		ESDCTL_V4_DDR3_REG_MR1;
+	writel(val, base + ESDCTL_V4_ESDSCR);
+
+	/* start write leveling */
+	writel(ESDCTL_V4_WLGCR_HW_WL_EN, base + ESDCTL_V4_WLGCR);
+
+	do {
+		val = readl(base + ESDCTL_V4_WLGCR);
+	} while (val & ESDCTL_V4_WLGCR_HW_WL_EN);
+
+	val &= ESDCTL_V4_WLGCR_WL_HW_ERR3 | ESDCTL_V4_WLGCR_WL_HW_ERR2 |
+		ESDCTL_V4_WLGCR_WL_HW_ERR1 | ESDCTL_V4_WLGCR_WL_HW_ERR0;
+
+	if (val)
+		hang();
+
+	/*
+	 * manual still talks about HW_WLx_CYC fields that
+	 * must be updated from HW_WLx_RES field by SW, but none
+	 * of these fields seem to exist. Closest equivalents
+	 * are WL_CYC_DELx-fields but no RES-fields can be found.
+	 */
+
+	/* configure RAMs back to normal operation */
+	val = ESDCTL_V4_DDR3_MR1_ODIC_RZQ7 | ESDCTL_V4_DDR3_MR1_RTTN_RZQ2 |
+		ESDCTL_V4_DDR3_MR1_AL_DISABLE | ESDCTL_V4_ESDSCR_CON_REQ |
+		ESDCTL_V4_ESDSCR_CMD_LMR | ESDCTL_V4_ESDSCR_CMD_CS0 |
+		ESDCTL_V4_DDR3_REG_MR1;
+	writel(val, base + ESDCTL_V4_ESDSCR);
+
+	val = ESDCTL_V4_DDR3_MR1_ODIC_RZQ7 | ESDCTL_V4_DDR3_MR1_RTTN_RZQ2 |
+		ESDCTL_V4_DDR3_MR1_AL_DISABLE | ESDCTL_V4_ESDSCR_CON_REQ |
+		ESDCTL_V4_ESDSCR_CMD_LMR | ESDCTL_V4_ESDSCR_CMD_CS1 |
+		ESDCTL_V4_DDR3_REG_MR1;
+	writel(val, base + ESDCTL_V4_ESDSCR);
+}
+
+void imx_esdctlv4_do_dqs_gating(void)
+{
+	u32 val;
+	void __iomem *base = (void *)MX53_ESDCTL_BASE_ADDR;
+
+	/* configure ESDCTL comparator to use MPR pattern */
+	writel(ESDCTL_V4_PDCMPR2_MPR_FULL_CMP | ESDCTL_V4_PDCMPR2_MPR_CMP,
+			base + ESDCTL_V4_PDCMPR2);
+
+	/* pre-charge all RAM banks */
+	writel(ESDCTL_V4_ESDSCR_CON_REQ | ESDCTL_V4_ESDSCR_CMD_CS0 |
+			ESDCTL_V4_ESDSCR_CMD_PRE_ALL, base + ESDCTL_V4_ESDSCR);
+	writel(ESDCTL_V4_ESDSCR_CON_REQ | ESDCTL_V4_ESDSCR_CMD_CS1 |
+			ESDCTL_V4_ESDSCR_CMD_PRE_ALL, base + ESDCTL_V4_ESDSCR);
+
+	/* configure RAMs to generate MPR pattern */
+	writel(ESDCTL_V4_DDR3_MR3_MPR_ENABLE | ESDCTL_V4_DDR3_MR3_MPR_PATTERN |
+			ESDCTL_V4_ESDSCR_CMD_CS0 | ESDCTL_V4_ESDSCR_CON_REQ |
+			ESDCTL_V4_ESDSCR_CMD_LMR | ESDCTL_V4_DDR3_REG_MR3,
+			base + ESDCTL_V4_ESDSCR);
+	writel(ESDCTL_V4_DDR3_MR3_MPR_ENABLE | ESDCTL_V4_DDR3_MR3_MPR_PATTERN |
+			ESDCTL_V4_ESDSCR_CMD_CS1 | ESDCTL_V4_ESDSCR_CON_REQ |
+			ESDCTL_V4_ESDSCR_CMD_LMR | ESDCTL_V4_DDR3_REG_MR3,
+			base + ESDCTL_V4_ESDSCR);
+
+	/* start HW DQS gating */
+	writel(ESDCTL_V4_ESDDGCTRL0_HW_DG_EN, base + ESDCTL_V4_DGCTRL0);
+
+	do {
+		val = readl(base + ESDCTL_V4_DGCTRL0);
+	} while (val & ESDCTL_V4_ESDDGCTRL0_HW_DG_EN);
+
+	if (val & ESDCTL_V4_ESDDGCTRL0_HW_DG_ERR)
+		hang();
+
+	/* configure RAMs back to normal operation */
+	val = ESDCTL_V4_DDR3_MR3_MPR_DISABLE | ESDCTL_V4_ESDSCR_CMD_CS0 |
+		ESDCTL_V4_ESDSCR_CON_REQ | ESDCTL_V4_ESDSCR_CMD_LMR |
+		ESDCTL_V4_DDR3_REG_MR3;
+	writel(val, base + ESDCTL_V4_ESDSCR);
+
+	val = ESDCTL_V4_DDR3_MR3_MPR_DISABLE | ESDCTL_V4_ESDSCR_CMD_CS1 |
+		ESDCTL_V4_ESDSCR_CON_REQ | ESDCTL_V4_ESDSCR_CMD_LMR |
+		ESDCTL_V4_DDR3_REG_MR3;
+	writel(val, base + ESDCTL_V4_ESDSCR);
+}
+
+void imx_esdctlv4_do_zq_calibration(void)
+{
+	u32 val;
+	void __iomem *base = (void *)MX53_ESDCTL_BASE_ADDR;
+
+	/*
+	 * configure ZQ parameters
+	 * Note: TZQ_CS is only required to be 64cy by Jedec and RAM
+	 * manufacturers and i.MX53TO1 provides a 64cy setting, but
+	 * TO2 according to official documentation not...
+	 */
+	val = ESDCTL_V4_ESDZQHWC_ZQ_PARA_EN |
+		(ESDCTL_V4_ESDZQHWC_128CYC << ESDCTL_V4_ESDZQHWC_TZQ_CS_SHIFT) |
+		(ESDCTL_V4_ESDZQHWC_256CYC << ESDCTL_V4_ESDZQHWC_TZQ_OPER_SHIFT) |
+		(ESDCTL_V4_ESDZQHWC_512CYC << ESDCTL_V4_ESDZQHWC_TZQ_INIT_SHIFT) |
+		(0 << ESDCTL_V4_ESDZQHWC_ZQ_HW_PD_RES_SHIFT) |
+		(0 << ESDCTL_V4_ESDZQHWC_ZQ_HW_PU_RES_SHIFT) |
+		(0 << ESDCTL_V4_ESDZQHWC_ZQ_HW_PER_SHIFT) |
+		ESDCTL_V4_ESDZQHWC_ZQ_MODE_BOTH_PER |
+		ESDCTL_V4_ESDZQHWC_ZQ_HW_FOR;
+
+	/* force ZQ calibration */
+	writel(val, base + ESDCTL_V4_ZQHWCTRL);
+
+	while (readl(base + ESDCTL_V4_ZQHWCTRL) & ESDCTL_V4_ESDZQHWC_ZQ_HW_FOR);
+}
+
+/*
+ * start-up a DDR3 SDRAM chip
+ */
+void imx_esdctlv4_start_ddr3_sdram(int cs)
+{
+	void __iomem *base = (void *)MX53_ESDCTL_BASE_ADDR;
+	u32 val;
+	u32 val_cs1;
+
+	if (cs)
+		val_cs1 = ESDCTL_V4_ESDSCR_CMD_CS1;
+	else
+		val_cs1 = ESDCTL_V4_ESDSCR_CMD_CS0;
+
+	/* initialize MR2 */
+	val = ESDCTL_V4_DDR3_MR2_RTTWR_OFF | ESDCTL_V4_DDR3_MR2_SRT_NORMAL |
+		ESDCTL_V4_DDR3_MR2_CWL_5 | ESDCTL_V4_DDR3_MR2_PASR_1_1 |
+		ESDCTL_V4_ESDSCR_CON_REQ | ESDCTL_V4_ESDSCR_CMD_LMR |
+		ESDCTL_V4_DDR3_REG_MR2 | val_cs1;
+	writel(val, base + ESDCTL_V4_ESDSCR);
+
+	/* initialize MR3 */
+	val =  ESDCTL_V4_DDR3_MR3_MPR_DISABLE | ESDCTL_V4_ESDSCR_CON_REQ |
+		ESDCTL_V4_ESDSCR_CMD_LMR | ESDCTL_V4_DDR3_REG_MR3 | val_cs1;
+	writel(val, base + ESDCTL_V4_ESDSCR);
+
+	/* initialize MR1 */
+	val = ESDCTL_V4_DDR3_MR1_ODIC_RZQ7 | ESDCTL_V4_DDR3_MR1_RTTN_RZQ2 |
+		ESDCTL_V4_DDR3_MR1_AL_DISABLE | ESDCTL_V4_ESDSCR_CON_REQ |
+		ESDCTL_V4_ESDSCR_CMD_LMR | ESDCTL_V4_DDR3_REG_MR1 | val_cs1;
+	writel(val, base + ESDCTL_V4_ESDSCR);
+
+	/* initialize MR0 */
+	val = ESDCTL_V4_DDR3_MR0_PPD_SLOW | ESDCTL_V4_DDR3_MR0_WR_6 |
+		ESDCTL_V4_DDR3_MR0_CL_6 | ESDCTL_V4_DDR3_MR0_BL_FIXED8 |
+		ESDCTL_V4_DDR3_MR0_RBT_NIBBLE | ESDCTL_V4_DDR3_DLL_RESET |
+		ESDCTL_V4_ESDSCR_CON_REQ | ESDCTL_V4_ESDSCR_CMD_LMR |
+		ESDCTL_V4_DDR3_REG_MR0 | val_cs1;
+
+	if (cs)
+		val = ESDCTL_V4_ESDSCR_DLL_RST1;
+	else
+		val = ESDCTL_V4_ESDSCR_DLL_RST0;
+
+	writel(val, base + ESDCTL_V4_ESDSCR);
+
+	/* perform ZQ calibration */
+	val = 0x04000000 | ESDCTL_V4_ESDSCR_CON_REQ |
+		ESDCTL_V4_ESDSCR_CMD_ZQCALIB_OLD;
+	val |= val_cs1;
+	writel(val, base + ESDCTL_V4_ESDSCR);
+}
+
+void imx_esdctlv4_do_read_delay_line_calibration(void)
+{
+	void __iomem *base = (void *)MX53_ESDCTL_BASE_ADDR;
+	u32 val;
+
+	/* configure ESDCTL comparator to use MPR pattern */
+	val = ESDCTL_V4_PDCMPR2_MPR_FULL_CMP | ESDCTL_V4_PDCMPR2_MPR_CMP;
+	writel(val, base + ESDCTL_V4_PDCMPR2);
+
+	/* pre-charge all RAM banks */
+	val = ESDCTL_V4_ESDSCR_CON_REQ | ESDCTL_V4_ESDSCR_CMD_CS0 |
+		ESDCTL_V4_ESDSCR_CMD_PRE_ALL;
+	writel(val, base + ESDCTL_V4_ESDSCR);
+
+	val = ESDCTL_V4_ESDSCR_CON_REQ | ESDCTL_V4_ESDSCR_CMD_CS1 |
+		ESDCTL_V4_ESDSCR_CMD_PRE_ALL;
+	writel(val, base + ESDCTL_V4_ESDSCR);
+
+	/* configure RAMs to generate MPR pattern */
+	val = ESDCTL_V4_DDR3_MR3_MPR_ENABLE | ESDCTL_V4_DDR3_MR3_MPR_PATTERN |
+		ESDCTL_V4_ESDSCR_CMD_CS0 | ESDCTL_V4_ESDSCR_CON_REQ |
+		ESDCTL_V4_ESDSCR_CMD_LMR | ESDCTL_V4_DDR3_REG_MR3;
+	writel(val, base + ESDCTL_V4_ESDSCR);
+
+	val = ESDCTL_V4_DDR3_MR3_MPR_ENABLE | ESDCTL_V4_DDR3_MR3_MPR_PATTERN |
+		ESDCTL_V4_ESDSCR_CMD_CS1 | ESDCTL_V4_ESDSCR_CON_REQ |
+		ESDCTL_V4_ESDSCR_CMD_LMR | ESDCTL_V4_DDR3_REG_MR3;
+	writel(val, base + ESDCTL_V4_ESDSCR);
+
+	/* start read delay-line calibration */
+	writel(ESDCTL_V4_RDDLHWCTL_HW_RDL_EN, base + ESDCTL_V4_RDDLHWCTL);
+
+	do {
+		val = readl(base + ESDCTL_V4_RDDLHWCTL);
+	} while (val & ESDCTL_V4_RDDLHWCTL_HW_RDL_EN);
+
+	val &= ESDCTL_V4_RDDLHWCTL_HW_RDL_ERR3 |
+		ESDCTL_V4_RDDLHWCTL_HW_RDL_ERR2 |
+		ESDCTL_V4_RDDLHWCTL_HW_RDL_ERR1 |
+		ESDCTL_V4_RDDLHWCTL_HW_RDL_ERR0;
+
+	if (val)
+		hang();
+
+	/* configure RAMs back to normal operation */
+	val = ESDCTL_V4_DDR3_MR3_MPR_DISABLE | ESDCTL_V4_ESDSCR_CMD_CS0 |
+		ESDCTL_V4_ESDSCR_CON_REQ | ESDCTL_V4_ESDSCR_CMD_LMR |
+		ESDCTL_V4_DDR3_REG_MR3;
+	writel(val, base + ESDCTL_V4_ESDSCR);
+
+	val = ESDCTL_V4_DDR3_MR3_MPR_DISABLE | ESDCTL_V4_ESDSCR_CMD_CS1 |
+		ESDCTL_V4_ESDSCR_CON_REQ | ESDCTL_V4_ESDSCR_CMD_LMR |
+		ESDCTL_V4_DDR3_REG_MR3;
+	writel(val, base + ESDCTL_V4_ESDSCR);
+}
+
+void imx_esdctlv4_do_write_delay_line_calibration(void)
+{
+	void __iomem *base = (void *)MX53_ESDCTL_BASE_ADDR;
+	void __iomem *adr;
+	u32 val;
+
+	/*
+	 * configure ESCTL to normal operation so we can
+	 * write the compare values
+	 */
+	writel(ESDCTL_V4_ESDSCR_CMD_NOP, base + ESDCTL_V4_ESDSCR);
+
+	/* write test-pattern to RAM */
+
+	/* ESCTL uses this address for calibration */
+	adr = (void *)MX53_CSD0_BASE_ADDR + 0x10000000;
+	writel(0, adr + 0x00);
+	writel(0, adr + 0x0c);
+	writel(0, adr + 0x10);
+	writel(0, adr + 0x1c);
+	writel(0, adr + 0x20);
+	writel(0, adr + 0x2c);
+	writel(0, adr + 0x30);
+	writel(0, adr + 0x4c);
+	writel(0xffffffff, adr + 0x04);
+	writel(0xffffffff, adr + 0x08);
+	writel(0xffffffff, adr + 0x14);
+	writel(0xffffffff, adr + 0x18);
+	writel(0xffffffff, adr + 0x24);
+	writel(0xffffffff, adr + 0x28);
+	writel(0xffffffff, adr + 0x34);
+	writel(0xffffffff, adr + 0x48);
+
+	/* pre-charge all RAM banks */
+	val = ESDCTL_V4_ESDSCR_CON_REQ | ESDCTL_V4_ESDSCR_CMD_CS0 |
+		ESDCTL_V4_ESDSCR_CMD_PRE_ALL;
+	writel(val, base + ESDCTL_V4_ESDSCR);
+
+	val = ESDCTL_V4_ESDSCR_CON_REQ | ESDCTL_V4_ESDSCR_CMD_CS1 |
+		ESDCTL_V4_ESDSCR_CMD_PRE_ALL;
+	writel(val, base + ESDCTL_V4_ESDSCR);
+
+	/* write test-pattern to ESCTL */
+	writel(0x00ffff00, base + ESDCTL_V4_PDCMPR1);
+	writel(0, base + ESDCTL_V4_PDCMPR2);
+
+	/* start write delay-line calibration */
+	writel(ESDCTL_V4_WRDLHWCTL_HW_WDL_EN, base + ESDCTL_V4_WRDLHWCTL);
+
+	do {
+		val = readl(base + ESDCTL_V4_WRDLHWCTL);
+	} while (val & ESDCTL_V4_WRDLHWCTL_HW_WDL_EN);
+
+	val &= ESDCTL_V4_WRDLHWCTL_HW_WDL_ERR3 |
+		ESDCTL_V4_WRDLHWCTL_HW_WDL_ERR2 |
+		ESDCTL_V4_WRDLHWCTL_HW_WDL_ERR1 |
+		ESDCTL_V4_WRDLHWCTL_HW_WDL_ERR0;
+
+	if (val)
+		hang();
+}
+
+#define SDRAM_COMPARE_CONST1 0x12345678
+#define SDRAM_COMPARE_CONST2 0xAAAAAAAA
+
+/*
+ * write magic values to RAM for testing purposes
+ */
+static void imx_esdctlv4_write_magic_values(void *adr)
+{
+	/*
+	 * Freescale asks for first access to be a write to properly
+	 * initialize DQS pin-state and keepers
+	 */
+	writel(SDRAM_COMPARE_CONST1, adr);
+
+	/*
+	 * write two magic constants to RAM, to test for bus-size and
+	 * row-/column-configuraion
+	 */
+	writel(SDRAM_COMPARE_CONST1, adr);
+	writel(SDRAM_COMPARE_CONST2, adr + 4);
+	dsb();
+}
+
+/*
+ * check if given DRAM addresses match expected values for row/col configuration
+ */
+static u32 check_ram_address_line(void *adr, u32 compare, u32 mask)
+{
+	u32 val;
+
+	val = readl(adr);	/* load data from RAM-address to check */
+	val &= mask;		/* mask data for our bus-size */
+
+	if (compare == val)	/* compare read data with expected value */
+		return 1;	/* if data is identical, update ESDCTL configuration */
+	else
+		return 0;
+}
+
+/*
+ * determine RAM chip-density and configure tRFC and tXS accordingly
+ */
+void imx_esdctlv4_set_tRFC_timing(void)
+{
+	void __iomem *base = (void *)MX53_ESDCTL_BASE_ADDR;
+	u32 val, trfc, r2, esdcfg;
+
+	/* determine chip-density */
+	val = readl(base + ESDCTL_V4_ESDMISC);
+	if ((val & ESDCTL_V4_ESDMISC_BANKS_MASK) == ESDCTL_V4_ESDMISC_BANKS_4)
+		r2 = 2;
+	else
+		r2 = 3;
+
+	val = readl(base + ESDCTL_V4_ESDCTL0);
+	if ((val & ESDCTL_V4_ESDCTLx_DSIZ_MASK) == ESDCTL_V4_ESDCTLx_DSIZ_32B)
+		r2 += 1;
+
+	switch (val & ESDCTL_V4_ESDCTLx_ROW_MASK) {
+		case ESDCTL_V4_ESDCTLx_ROW_11: r2 += 1; break;
+		case ESDCTL_V4_ESDCTLx_ROW_12: r2 += 2; break;
+		case ESDCTL_V4_ESDCTLx_ROW_13: r2 += 3; break;
+		case ESDCTL_V4_ESDCTLx_ROW_14: r2 += 4; break;
+		case ESDCTL_V4_ESDCTLx_ROW_15: r2 += 5; break;
+		case ESDCTL_V4_ESDCTLx_ROW_16: r2 += 6; break;
+	}
+
+	switch (val & ESDCTL_V4_ESDCTLx_COL_MASK) {
+		case ESDCTL_V4_ESDCTLx_COL_8: r2 += 8; break;
+		case ESDCTL_V4_ESDCTLx_COL_9: r2 += 9; break;
+		case ESDCTL_V4_ESDCTLx_COL_10: r2 += 10; break;
+		case ESDCTL_V4_ESDCTLx_COL_11: r2 += 11; break;
+		case ESDCTL_V4_ESDCTLx_COL_12: r2 += 12; break;
+	}
+
+	/* save current tRFC timing */
+	esdcfg = readl(base + ESDCTL_V4_ESDCFG0);
+
+	trfc = (esdcfg & ESDCTL_V4_ESDCFG0_tRFC_MASK) >> ESDCTL_V4_ESDCFG0_tRFC_SHIFT;
+
+	/* clear tRFC and tXS timings */
+	esdcfg &= ~(ESDCTL_V4_ESDCFG0_tRFC_MASK | ESDCTL_V4_ESDCFG0_tXS_MASK);
+
+	/*
+	 * determine tRFC depending on density
+	 * (the timings and density-associations are taken
+	 * from JEDEC JESD79-3E DDR3-RAM specification)
+	 */
+	if (r2 >= 16)
+		trfc = 36 - 1;
+	if (r2 >= 17)
+		trfc = 44 - 1;
+	if (r2 >= 18)
+		trfc = 64 - 1;
+	if (r2 >= 19)
+		trfc = 120 - 1;
+	if (r2 >= 20)
+		trfc = 140 - 1;
+
+	/* calculate new tRFC and tXS timings */
+	esdcfg |= (trfc << ESDCTL_V4_ESDCFG0_tRFC_SHIFT) |
+		(trfc + 4) << ESDCTL_V4_ESDCFG0_tXS_SHIFT;
+
+	writel(esdcfg, base + ESDCTL_V4_ESDCFG0);
+}
+
+/*
+ * disable chip-selects that are not equipped
+ */
+void imx_esdctlv4_detect_sdrams(void)
+{
+	void __iomem *base = (void *)MX53_ESDCTL_BASE_ADDR;
+	u32 esdctl0;
+
+	esdctl0 = readl(base + ESDCTL_V4_ESDCTL0);
+
+	writel(MX53_CSD0_BASE_ADDR, MX53_CSD0_BASE_ADDR);
+	writel(MX53_CSD1_BASE_ADDR, MX53_CSD1_BASE_ADDR);
+
+	if (readl(MX53_CSD0_BASE_ADDR) != MX53_CSD0_BASE_ADDR)
+		esdctl0 &= ~ESDCTL_V4_ESDCTLx_SDE0;
+	if (readl(MX53_CSD1_BASE_ADDR) != MX53_CSD1_BASE_ADDR)
+		esdctl0 &= ~ESDCTL_V4_ESDCTLx_SDE1;
+
+	writel(esdctl0, base + ESDCTL_V4_ESDCTL0);
+}
+
+void imx_esdctlv4_init(void)
+{
+	void __iomem *base = (void *)MX53_ESDCTL_BASE_ADDR;
+	u32 val, r1, esdctl0, mask, rows, cols;
+
+	/*
+	 * assume worst-case here: 4Gb chips. this will be optimized
+	 * further down, when we can determine the actual chip density
+	 * in imx_esdctlv4_set_tRFC_timing()
+	 */
+	val = (((140 - 1) << ESDCTL_V4_ESDCFG0_tRFC_SHIFT) |
+				  ((144 - 1) << ESDCTL_V4_ESDCFG0_tXS_SHIFT) |
+				  ((3 - 1) << ESDCTL_V4_ESDCFG0_tXP_SHIFT) |
+				  ((10 - 1) << ESDCTL_V4_ESDCFG0_tXPDLL_SHIFT) |
+				  ((20 - 1) << ESDCTL_V4_ESDCFG0_tFAW_SHIFT) |
+				  ((6 - 3) << ESDCTL_V4_ESDCFG0_tCL_SHIFT));
+	writel(val, base + ESDCTL_V4_ESDCFG0);
+
+	val = (((6 - 1) << ESDCTL_V4_ESDCFG1_tRCD_SHIFT) |
+				  ((6 - 1) << ESDCTL_V4_ESDCFG1_tRP_SHIFT) |
+				  ((21 - 1) << ESDCTL_V4_ESDCFG1_tRC_SHIFT) |
+				  ((15 - 1) << ESDCTL_V4_ESDCFG1_tRAS_SHIFT) |
+				  (1 << ESDCTL_V4_ESDCFG1_tRPA_SHIFT) |
+				  ((6 - 1) << ESDCTL_V4_ESDCFG1_tWR_SHIFT) |
+				  ((4 - 1) << ESDCTL_V4_ESDCFG1_tMRD_SHIFT) |
+				  ((5 - 2) << ESDCTL_V4_ESDCFG1_tCWL_SHIFT));
+	writel(val, base + ESDCTL_V4_ESDCFG1);
+
+	val = (((512 - 1) << ESDCTL_V4_ESDCFG2_tDLLK_SHIFT) |
+				  ((4 - 1) << ESDCTL_V4_ESDCFG2_tRTP_SHIFT) |
+				  ((4 - 1) << ESDCTL_V4_ESDCFG2_tWTR_SHIFT) |
+				  ((4 - 1) << ESDCTL_V4_ESDCFG2_tRRD_SHIFT));
+	writel(val, base + ESDCTL_V4_ESDCFG2);
+
+	/*
+	 * we don't touch the ESDRWD register as documentation claims
+	 * the power-on defaults are minimum required values and we don't
+	 * want to interfere with changes of these in new chip or
+	 * BootROM revisions.
+	 */
+
+	val = (((3 - 1) << ESDCTL_V4_ESDOTC_tAOFPD_SHIFT) |
+				  ((3 - 1) << ESDCTL_V4_ESDOTC_tAONPD_SHIFT) |
+				  ((4 - 1) << ESDCTL_V4_ESDOTC_tANPD_SHIFT) |
+				  ((4 - 1) << ESDCTL_V4_ESDOTC_tAXPD_SHIFT) |
+				  (3 << ESDCTL_V4_ESDOTC_tODTLon_SHIFT) |
+				  (3 << ESDCTL_V4_ESDOTC_tODT_idle_off_SHIFT));
+	writel(val, base + ESDCTL_V4_ESDOTC);
+
+	/* currently we only support DDR3 RAM, which always has 8 banks */
+	val = ESDCTL_V4_ESDMISC_WALAT_0 | ESDCTL_V4_ESDMISC_RALAT_2 |
+				  ESDCTL_V4_ESDMISC_MIF3_MODE_EFAM |
+				  ESDCTL_V4_ESDMISC_DDR_DDR3 |
+				  ESDCTL_V4_ESDMISC_BANKS_8;
+	writel(val, base + ESDCTL_V4_ESDMISC);
+
+	val = (((144 - 1) << ESDCTL_V4_ESDOR_tXPR_SHIFT) |
+			((13 + 1) << ESDCTL_V4_ESDOR_SDE_to_RST_SHIFT) |
+			((32 + 1) << ESDCTL_V4_ESDOR_RST_to_CKE_SHIFT));
+	writel(val, base + ESDCTL_V4_ESDOR);
+
+	/*
+	 * we assume maximum address line configuration here (32b, 16rows, 12cols,
+	 * both chips) once the RAM is initialized, we determine actual configuration
+	 */
+	val = ESDCTL_V4_ESDCTLx_SDE0 | ESDCTL_V4_ESDCTLx_SDE1 |
+			ESDCTL_V4_ESDCTLx_ROW_16 | ESDCTL_V4_ESDCTLx_COL_8 |
+			ESDCTL_V4_ESDCTLx_BL_8_8 | ESDCTL_V4_ESDCTLx_DSIZ_32B;
+	writel(val, base + ESDCTL_V4_ESDCTL0);
+
+	imx_esdctlv4_start_ddr3_sdram(0);
+	imx_esdctlv4_start_ddr3_sdram(1);
+
+	val = (ESDCTL_V4_ESDPDC_PRCT_DISABLE << ESDCTL_V4_ESDPDC_PRCT1_SHIFT) |
+		(ESDCTL_V4_ESDPDC_PRCT_DISABLE << ESDCTL_V4_ESDPDC_PRCT0_SHIFT) |
+		((3 - 1) << ESDCTL_V4_ESDPDC_tCKE_SHIFT) |
+		(ESDCTL_V4_ESDPDC_PWDT_DISABLE << ESDCTL_V4_ESDPDC_PWDT1_SHIFT) |
+		(ESDCTL_V4_ESDPDC_PWDT_DISABLE << ESDCTL_V4_ESDPDC_PWDT0_SHIFT) |
+		(5 << ESDCTL_V4_ESDPDC_tCKSRX_SHIFT) |
+		(5 << ESDCTL_V4_ESDPDC_tCKSRE_SHIFT);
+	writel(val, base + ESDCTL_V4_ESDPDC);
+
+	/* configure ODT */
+	val = (ESDCTL_V4_ESDODTC_RTT_120 << ESDCTL_V4_ESDODTC_ODT3_INT_RES_SHIFT) |
+		(ESDCTL_V4_ESDODTC_RTT_120 << ESDCTL_V4_ESDODTC_ODT2_INT_RES_SHIFT) |
+		(ESDCTL_V4_ESDODTC_RTT_120 << ESDCTL_V4_ESDODTC_ODT1_INT_RES_SHIFT) |
+		(ESDCTL_V4_ESDODTC_RTT_120 << ESDCTL_V4_ESDODTC_ODT0_INT_RES_SHIFT) |
+		ESDCTL_V4_ESDODTC_ODT_RD_PAS_EN |
+		ESDCTL_V4_ESDODTC_ODT_WR_ACT_EN |
+		ESDCTL_V4_ESDODTC_ODT_WR_PAS_EN;
+	writel(val, base + ESDCTL_V4_ODTCTRL);
+
+	/*
+	 * ensure refresh and ZQ calibration are turned off as
+	 * nothing may interfere with the first few calibrations
+	 */
+	writel(ESDCTL_V4_ESDREF_REF_SEL_MASK, base + ESDCTL_V4_ESDREF);
+
+	writel(ESDCTL_V4_ESDZQHWC_ZQ_MODE_NO_CAL, base + ESDCTL_V4_ZQHWCTRL);
+
+	/*
+	 * ensure that read/write delays are configured to
+	 * (working) 1/4 cycle default delay, proper delays
+	 * will be calibrated below.
+	 */
+	writel(0x30303030, base + ESDCTL_V4_RDDLCTL);
+	writel(0x40404040, base + ESDCTL_V4_WRDLCTL);
+
+	/* DQS Gating */
+	imx_esdctlv4_do_dqs_gating();
+
+	/* Write Leveling */
+	imx_esdctlv4_do_write_leveling();
+
+	/*
+	 * ZQ calibration (this will also enable regular
+	 * automatic ZQ calibration again)
+	 */
+	imx_esdctlv4_do_zq_calibration();
+
+	/* configure and enable refresh */
+	val = (0 << ESDCTL_V4_ESDREF_REF_CNT_SHIFT) |
+		ESDCTL_V4_ESDREF_REF_SEL_64K |
+		((2 - 1) << ESDCTL_V4_ESDREF_REFR_SHIFT);
+	writel(val, base + ESDCTL_V4_ESDREF);
+
+
+	/* Now do proper Delay Line Calibration */
+	imx_esdctlv4_do_read_delay_line_calibration();
+	imx_esdctlv4_do_write_delay_line_calibration();
+
+	/* enable regular operation of ESDCTL */
+	writel(ESDCTL_V4_ESDSCR_CMD_NOP, base + ESDCTL_V4_ESDSCR);
+
+	dsb();
+
+	/*
+	 * detect RAM configuration (Note: both CSDx must be
+	 * equipped with identical RAMs, so we only need to detect
+	 * the configuration of CSD0 and anything on CSD1)
+	 */
+	esdctl0 = readl(base + ESDCTL_V4_ESDCTL0);
+
+	imx_esdctlv4_write_magic_values((void *)MX53_CSD0_BASE_ADDR);
+
+	/* check for bus-configuration first */
+	esdctl0 &= ~ESDCTL_V4_ESDCTLx_DSIZ_MASK;
+
+	/* assume we're on a 32b bus */
+	mask = 0xffffffff;
+
+	/* data correct? */
+	if (readl(MX53_CSD0_BASE_ADDR) == SDRAM_COMPARE_CONST1) {
+		esdctl0 |= ESDCTL_V4_ESDCTLx_DSIZ_32B; /* yep, indeed 32b bus */
+		goto sdram_bussize_found;
+	}
+
+	/*
+	 * ok, last possibility is 16b bus on low data-lines, check that
+	 * (i.MX25 also suports 16b on high data-lines, but i.MX53 doesn't)
+	 */
+	if (readl(MX53_CSD0_BASE_ADDR) << 16 == SDRAM_COMPARE_CONST1 << 16) {
+		esdctl0 |= ESDCTL_V4_ESDCTLx_DSIZ_16B_LOW;
+		mask >>= 16;
+		goto sdram_bussize_found;
+	}
+
+	/* nope, no working SDRAM, leave. */
+	hang();
+
+sdram_bussize_found:
+
+	/* Now determine actual row/column configuration of the RAMs */
+
+	/* mask unused bits from our compare constant */
+	r1 = SDRAM_COMPARE_CONST1 & mask;
+	/*
+	 * So far we asssumed that we have 16 rows, check for copies of our
+	 * SDRAM_COMPARE_CONST1 due to missing row lines...
+	 */
+
+	if (check_ram_address_line((void *)MX53_CSD0_BASE_ADDR + (1 << 25), r1, mask))
+		rows = ESDCTL_V4_ESDCTLx_ROW_15;
+	if (check_ram_address_line((void *)MX53_CSD0_BASE_ADDR + (1 << 24), r1, mask))
+		rows = ESDCTL_V4_ESDCTLx_ROW_14;
+	if (check_ram_address_line((void *)MX53_CSD0_BASE_ADDR + (1 << 23), r1, mask))
+		rows = ESDCTL_V4_ESDCTLx_ROW_13;
+	if (check_ram_address_line((void *)MX53_CSD0_BASE_ADDR + (1 << 22), r1, mask))
+		rows = ESDCTL_V4_ESDCTLx_ROW_12;
+	if (check_ram_address_line((void *)MX53_CSD0_BASE_ADDR + (1 << 21), r1, mask))
+		rows = ESDCTL_V4_ESDCTLx_ROW_11;
+
+	esdctl0 &= ~ESDCTL_V4_ESDCTLx_ROW_MASK;
+	esdctl0 |= rows;
+
+	/*
+	 * To detect columns we have to switch from the (max rows, min cols)
+	 * configuration we used so far to a (min rows, max cols) configuration
+	 */
+
+	/* switch ESDCTL to configuration mode */
+	val = ESDCTL_V4_ESDSCR_CMD_NOP | ESDCTL_V4_ESDSCR_CON_REQ;
+	writel(val, base + ESDCTL_V4_ESDSCR);
+
+	/* reconfigure row-/column-lines */
+	val = readl(base + ESDCTL_V4_ESDCTL0);
+	val &= ~(ESDCTL_V4_ESDCTLx_ROW_MASK | ESDCTL_V4_ESDCTLx_COL_MASK);
+	val |= ESDCTL_V4_ESDCTLx_ROW_11 | ESDCTL_V4_ESDCTLx_COL_12;
+	writel(val, base + ESDCTL_V4_ESDCTL0);
+
+	dsb();
+
+	/* switch ESDCTL back to normal operation */
+	writel(ESDCTL_V4_ESDSCR_CMD_NOP, base + ESDCTL_V4_ESDSCR);
+
+	/*
+	 * not quite sure why, but the row-/col-reconfiguration destroys the
+	 * contents of the RAM so we have to write our magic values back
+	 * (maybe because refresh is suspended during that time)
+	 */
+	imx_esdctlv4_write_magic_values((void *)MX53_CSD0_BASE_ADDR);
+
+	/*
+	 * So far we asssumed that we have 12 columns, check for copies of our
+	 * SDRAM_COMPARE_CONST1 due to missing column lines...
+	 */
+
+	if (check_ram_address_line((void *)MX53_CSD0_BASE_ADDR + (1 << 13), r1, mask))
+		cols = ESDCTL_V4_ESDCTLx_COL_11;
+	if (check_ram_address_line((void *)MX53_CSD0_BASE_ADDR + (1 << 12), r1, mask))
+		cols = ESDCTL_V4_ESDCTLx_COL_10;
+	if (check_ram_address_line((void *)MX53_CSD0_BASE_ADDR + (1 << 11), r1, mask))
+		cols = ESDCTL_V4_ESDCTLx_COL_9;
+	if (check_ram_address_line((void *)MX53_CSD0_BASE_ADDR + (1 << 10), r1, mask))
+		cols = ESDCTL_V4_ESDCTLx_COL_8;
+
+	esdctl0 &= ~ESDCTL_V4_ESDCTLx_COL_MASK;
+	esdctl0 |= cols;
+
+	/* setup proper row-/column-configuration */
+
+	/* switch ESDCTL to configuration mode */
+	val = ESDCTL_V4_ESDSCR_CMD_NOP | ESDCTL_V4_ESDSCR_CON_REQ;
+	writel(val, base + ESDCTL_V4_ESDSCR);
+
+	/* reconfigure row-/column-lines */
+	writel(esdctl0, base + ESDCTL_V4_ESDCTL0);
+
+	/* configure densitiy dependent timing parameters */
+	imx_esdctlv4_set_tRFC_timing();
+
+	dsb();
+
+	/* switch ESDCTL back to normal operation */
+	writel(ESDCTL_V4_ESDSCR_CMD_NOP, base + ESDCTL_V4_ESDSCR);
+
+	/* see at which CSx we actually have working RAM */
+	imx_esdctlv4_detect_sdrams();
+}
diff --git a/arch/arm/mach-imx/include/mach/esdctl-v4.h b/arch/arm/mach-imx/include/mach/esdctl-v4.h
new file mode 100644
index 0000000..2e6741e
--- /dev/null
+++ b/arch/arm/mach-imx/include/mach/esdctl-v4.h
@@ -0,0 +1,520 @@
+#ifndef __MACH_ESDCTL_V4_H
+#define __MACH_ESDCTL_V4_H
+
+#define ESDCTL_V4_ESDCTL0		0x00
+#define ESDCTL_V4_ESDPDC		0x04
+#define ESDCTL_V4_ESDOTC		0x08
+#define ESDCTL_V4_ESDCFG0		0x0c
+#define ESDCTL_V4_ESDCFG1		0x10
+#define ESDCTL_V4_ESDCFG2		0x14
+#define ESDCTL_V4_ESDMISC		0x18
+#define ESDCTL_V4_ESDSCR		0x1c
+#define ESDCTL_V4_ESDREF		0x20
+#define ESDCTL_V4_ESDWCC		0x24
+#define ESDCTL_V4_ESDRCC		0x28
+#define ESDCTL_V4_ESDRWD		0x2c
+#define ESDCTL_V4_ESDOR			0x30
+#define ESDCTL_V4_ESDMRR		0x34
+#define ESDCTL_V4_ESDCFG3_LP		0x38
+#define ESDCTL_V4_ESDMR4		0x3c
+#define ESDCTL_V4_ZQHWCTRL		0x40
+#define ESDCTL_V4_ZQSWCTRL		0x44
+#define ESDCTL_V4_WLGCR			0x48
+#define ESDCTL_V4_WLDECTRL0		0x4c
+#define ESDCTL_V4_WLDECTRL1		0x50
+#define ESDCTL_V4_WLDLST		0x54
+#define ESDCTL_V4_ODTCTRL		0x58
+#define ESDCTL_V4_RDDQBY0DL		0x5c
+#define ESDCTL_V4_RDDQBY1DL		0x60
+#define ESDCTL_V4_RDDQBY2DL		0x64
+#define ESDCTL_V4_RDDQBY3DL		0x68
+#define ESDCTL_V4_WRDQBY0DL		0x6c
+#define ESDCTL_V4_WRDQBY1DL		0x70
+#define ESDCTL_V4_WRDQBY2DL		0x74
+#define ESDCTL_V4_WRDQBY3DL		0x78
+#define ESDCTL_V4_DGCTRL0		0x7c
+#define ESDCTL_V4_DGCTRL1		0x80
+#define ESDCTL_V4_DGDLST		0x84
+#define ESDCTL_V4_RDDLCTL		0x88
+#define ESDCTL_V4_RDDLST		0x8c
+#define ESDCTL_V4_WRDLCTL		0x90
+#define ESDCTL_V4_WRDLST		0x94
+#define ESDCTL_V4_SDCTRL		0x98
+#define ESDCTL_V4_ZQLP2CTL		0x9c
+#define ESDCTL_V4_RDDLHWCTL		0xa0
+#define ESDCTL_V4_WRDLHWCTL		0xa4
+#define ESDCTL_V4_RDDLHWST0		0xa8
+#define ESDCTL_V4_RDDLHWST1		0xac
+#define ESDCTL_V4_WRDLHWST0		0xb0
+#define ESDCTL_V4_WRDLHWST1		0xb4
+#define ESDCTL_V4_WLHWERR		0xb8
+#define ESDCTL_V4_DGHWST0		0xbc
+#define ESDCTL_V4_DGHWST1		0xc0
+#define ESDCTL_V4_DGHWST2		0xc4
+#define ESDCTL_V4_DGHWST3		0xc8
+#define ESDCTL_V4_PDCMPR1		0xcc
+#define ESDCTL_V4_PDCMPR2		0xd0
+#define ESDCTL_V4_SWDADR		0xd4
+#define ESDCTL_V4_SWDRDR0		0xd8
+#define ESDCTL_V4_SWDRDR1		0xdc
+#define ESDCTL_V4_SWDRDR2		0xe0
+#define ESDCTL_V4_SWDRDR3		0xe4
+#define ESDCTL_V4_SWDRDR4		0xe8
+#define ESDCTL_V4_SWDRDR5		0xec
+#define ESDCTL_V4_SWDRDR6		0xf0
+#define ESDCTL_V4_SWDRDR7		0xf4
+#define ESDCTL_V4_MUR			0xf8
+#define ESDCTL_V4_WRCADL		0xfc
+
+#define ESDCTL_V4_ESDCTLx_SDE0				0x80000000
+#define ESDCTL_V4_ESDCTLx_SDE1				0x40000000
+
+#define ESDCTL_V4_ESDCTLx_ROW_MASK			0x07000000
+#define ESDCTL_V4_ESDCTLx_ROW_11			0x00000000
+#define ESDCTL_V4_ESDCTLx_ROW_12			0x01000000
+#define ESDCTL_V4_ESDCTLx_ROW_13			0x02000000
+#define ESDCTL_V4_ESDCTLx_ROW_14			0x03000000
+#define ESDCTL_V4_ESDCTLx_ROW_15			0x04000000
+#define ESDCTL_V4_ESDCTLx_ROW_16			0x05000000
+
+#define ESDCTL_V4_ESDCTLx_COL_MASK			0x00700000
+#define ESDCTL_V4_ESDCTLx_COL_9				0x00000000
+#define ESDCTL_V4_ESDCTLx_COL_10			0x00100000
+#define ESDCTL_V4_ESDCTLx_COL_11			0x00200000
+#define ESDCTL_V4_ESDCTLx_COL_8				0x00300000
+#define ESDCTL_V4_ESDCTLx_COL_12			0x00400000
+
+#define ESDCTL_V4_ESDCTLx_BL_MASK			0x00080000
+#define ESDCTL_V4_ESDCTLx_BL_4_RES			0x00000000
+#define ESDCTL_V4_ESDCTLx_BL_8_8			0x00080000
+
+#define ESDCTL_V4_ESDCTLx_DSIZ_MASK			0x00010000
+#define ESDCTL_V4_ESDCTLx_DSIZ_16B_LOW			0x00000000
+#define ESDCTL_V4_ESDCTLx_DSIZ_32B			0x00010000
+
+#define ESDCTL_V4_ESDMISC_CS0_RDY			0x80000000
+#define ESDCTL_V4_ESDMISC_CS1_RDY			0x40000000
+#define ESDCTL_V4_ESDMISC_ONE_CS			0x00100000
+#define ESDCTL_V4_ESDMISC_ADDR_MIRROR			0x00080000
+#define ESDCTL_V4_ESDMISC_LHD				0x00040000
+#define ESDCTL_V4_ESDMISC_WALAT_SHIFT			16
+#define ESDCTL_V4_ESDMISC_WALAT_MASK			(0x3 << ESDCTL_V4_ESDMISC_WALAT_SHIFT)
+#define ESDCTL_V4_ESDMISC_WALAT_0			(0x0 << ESDCTL_V4_ESDMISC_WALAT_SHIFT)
+#define ESDCTL_V4_ESDMISC_WALAT_1			(0x1 << ESDCTL_V4_ESDMISC_WALAT_SHIFT)
+#define ESDCTL_V4_ESDMISC_WALAT_2			(0x2 << ESDCTL_V4_ESDMISC_WALAT_SHIFT)
+#define ESDCTL_V4_ESDMISC_WALAT_3			(0x3 << ESDCTL_V4_ESDMISC_WALAT_SHIFT)
+#define ESDCTL_V4_ESDMISC_BI_ON				0x00001000
+#define ESDCTL_V4_ESDMISC_MIF3_MODE_MASK		0x00000600
+#define ESDCTL_V4_ESDMISC_MIF3_MODE_DIS			0x00000000
+#define ESDCTL_V4_ESDMISC_MIF3_MODE_EF			0x00000200
+#define ESDCTL_V4_ESDMISC_MIF3_MODE_EFA			0x00000400
+#define ESDCTL_V4_ESDMISC_MIF3_MODE_EFAM		0x00000600
+#define ESDCTL_V4_ESDMISC_RALAT_SHIFT			6
+#define ESDCTL_V4_ESDMISC_RALAT_MASK			(0x7 << ESDCTL_V4_ESDMISC_RALAT_SHIFT)
+#define ESDCTL_V4_ESDMISC_RALAT_0			(0x0 << ESDCTL_V4_ESDMISC_RALAT_SHIFT)
+#define ESDCTL_V4_ESDMISC_RALAT_1			(0x1 << ESDCTL_V4_ESDMISC_RALAT_SHIFT)
+#define ESDCTL_V4_ESDMISC_RALAT_2			(0x2 << ESDCTL_V4_ESDMISC_RALAT_SHIFT)
+#define ESDCTL_V4_ESDMISC_RALAT_3			(0x3 << ESDCTL_V4_ESDMISC_RALAT_SHIFT)
+#define ESDCTL_V4_ESDMISC_RALAT_4			(0x4 << ESDCTL_V4_ESDMISC_RALAT_SHIFT)
+#define ESDCTL_V4_ESDMISC_RALAT_5			(0x5 << ESDCTL_V4_ESDMISC_RALAT_SHIFT)
+#define ESDCTL_V4_ESDMISC_RALAT_6			(0x6 << ESDCTL_V4_ESDMISC_RALAT_SHIFT)
+#define ESDCTL_V4_ESDMISC_RALAT_7			(0x7 << ESDCTL_V4_ESDMISC_RALAT_SHIFT)
+
+#define ESDCTL_V4_ESDMISC_DDR_MASK			0x00000818
+#define ESDCTL_V4_ESDMISC_DDR_DDR3			0x00000000
+#define ESDCTL_V4_ESDMISC_DDR_LPDDR2_S4			0x00000008
+#define ESDCTL_V4_ESDMISC_DDR_LPDDR2_S2			0x00000808
+#define ESDCTL_V4_ESDMISC_DDR_DDR2			0x00000010
+
+#define ESDCTL_V4_ESDMISC_BANKS_MASK			0x00000020
+#define ESDCTL_V4_ESDMISC_BANKS_4			0x00000020
+#define ESDCTL_V4_ESDMISC_BANKS_8			0x00000000
+
+#define ESDCTL_V4_ESDMISC_RST				0x00000002
+
+
+#define ESDCTL_V4_ESDRDDLCTL_RD_DL_ABS_OFFSET3_SHIFT	24
+#define ESDCTL_V4_ESDRDDLCTL_RD_DL_ABS_OFFSET2_SHIFT	16
+#define ESDCTL_V4_ESDRDDLCTL_RD_DL_ABS_OFFSET1_SHIFT	8
+#define ESDCTL_V4_ESDRDDLCTL_RD_DL_ABS_OFFSET0_SHIFT	0
+#define ESDCTL_V4_ESDRDDLCTL_RD_DL_ABS_OFFSET_MASK	0xff
+
+#define ESDCTL_V4_ESDRDDLCTL_WR_DL_ABS_OFFSET3_SHIFT	24
+#define ESDCTL_V4_ESDRDDLCTL_WR_DL_ABS_OFFSET2_SHIFT	16
+#define ESDCTL_V4_ESDRDDLCTL_WR_DL_ABS_OFFSET1_SHIFT	8
+#define ESDCTL_V4_ESDRDDLCTL_WR_DL_ABS_OFFSET0_SHIFT	0
+#define ESDCTL_V4_ESDRDDLCTL_WR_DL_ABS_OFFSET_MASK	0xff
+
+
+#define ESDCTL_V4_ESDDGCTRL0_RST_RD_FIFO		0x80000000
+#define ESDCTL_V4_ESDDGCTRL0_DG_CMP_CYC			0x40000000
+#define ESDCTL_V4_ESDDGCTRL0_DG_DIS			0x20000000
+#define ESDCTL_V4_ESDDGCTRL0_HW_DG_EN			0x10000000
+#define ESDCTL_V4_ESDDGCTRL0_DG_HC_DEL1_MASK		0x0f000000
+#define ESDCTL_V4_ESDDGCTRL0_DG_HC_DEL1_SHIFT		24
+#define ESDCTL_V4_ESDDGCTRL0_DG_EXT_UP			0x00800000
+#define ESDCTL_V4_ESDDGCTRL0_DG_DL_ABS_OFFSET1_MASK	0x007f0000
+#define ESDCTL_V4_ESDDGCTRL0_DG_DL_ABS_OFFSET1_SHIFT	16
+#define ESDCTL_V4_ESDDGCTRL0_HW_DG_ERR			0x00001000
+#define ESDCTL_V4_ESDDGCTRL0_DG_HC_DEL0_MASK		0x00000f00
+#define ESDCTL_V4_ESDDGCTRL0_DG_HC_DEL0_SHIFT		8
+#define ESDCTL_V4_ESDDGCTRL0_DG_DL_ABS_OFFSET0_MASK	0x0000007f
+#define ESDCTL_V4_ESDDGCTRL0_DG_DL_ABS_OFFSET0_SHIFT	0
+
+#define ESDCTL_V4_ESDDGCTRL1_DG_HC_DEL3_MASK		0x0f000000
+#define ESDCTL_V4_ESDDGCTRL1_DG_HC_DEL3_SHIFT		24
+#define ESDCTL_V4_ESDDGCTRL1_DG_DL_ABS_OFFSET3_MASK	0x007f0000
+#define ESDCTL_V4_ESDDGCTRL1_DG_DL_ABS_OFFSET3_SHIFT	16
+#define ESDCTL_V4_ESDDGCTRL1_DG_HC_DEL2_MASK		0x00000f00
+#define ESDCTL_V4_ESDDGCTRL1_DG_HC_DEL2_SHIFT		8
+#define ESDCTL_V4_ESDDGCTRL1_DG_DL_ABS_OFFSET2_MASK	0x0000007f
+#define ESDCTL_V4_ESDDGCTRL1_DG_DL_ABS_OFFSET2_SHIFT	0
+
+
+#define ESDCTL_V4_ESDCFG0_tRFC_SHIFT			24
+#define ESDCTL_V4_ESDCFG0_tRFC_MASK			(0xff << ESDCTL_V4_ESDCFG0_tRFC_SHIFT)
+#define ESDCTL_V4_ESDCFG0_tXS_SHIFT			16
+#define ESDCTL_V4_ESDCFG0_tXS_MASK			(0xff << ESDCTL_V4_ESDCFG0_tXS_SHIFT)
+#define ESDCTL_V4_ESDCFG0_tXP_SHIFT			13
+#define ESDCTL_V4_ESDCFG0_tXP_MASK			(0x7 << ESDCTL_V4_ESDCFG0_tXP_SHIFT)
+#define ESDCTL_V4_ESDCFG0_tXPDLL_SHIFT			9
+#define ESDCTL_V4_ESDCFG0_tXPDLL_MASK			(0xf << ESDCTL_V4_ESDCFG0_tXPDLL_SHIFT)
+#define ESDCTL_V4_ESDCFG0_tFAW_SHIFT			4
+#define ESDCTL_V4_ESDCFG0_tFAW_MASK			(0x1f << ESDCTL_V4_ESDCFG0_tFAW_SHIFT)
+#define ESDCTL_V4_ESDCFG0_tCL_SHIFT			0
+#define ESDCTL_V4_ESDCFG0_tCL_MASK			(0xf << ESDCTL_V4_ESDCFG0_tCL_SHIFT)
+
+#define ESDCTL_V4_ESDCFG1_tRCD_SHIFT			29
+#define ESDCTL_V4_ESDCFG1_tRCD_MASK			(0x7 << ESDCTL_V4_ESDCFG1_tRCD_SHIFT)
+#define ESDCTL_V4_ESDCFG1_tRP_SHIFT			26
+#define ESDCTL_V4_ESDCFG1_tRP_MASK			(0x7 << ESDCTL_V4_ESDCFG1_tRP_SHIFT)
+#define ESDCTL_V4_ESDCFG1_tRC_SHIFT			21
+#define ESDCTL_V4_ESDCFG1_tRC_MASK			(0x1f << ESDCTL_V4_ESDCFG1_tRC_SHIFT)
+#define ESDCTL_V4_ESDCFG1_tRAS_SHIFT			16
+#define ESDCTL_V4_ESDCFG1_tRAS_MASK			(0x1f << ESDCTL_V4_ESDCFG1_tRAS_SHIFT)
+#define ESDCTL_V4_ESDCFG1_tRPA_SHIFT			15
+#define ESDCTL_V4_ESDCFG1_tRPA_MASK			(0x1 << ESDCTL_V4_ESDCFG1_tRPA_SHIFT)
+#define ESDCTL_V4_ESDCFG1_tWR_SHIFT			9
+#define ESDCTL_V4_ESDCFG1_tWR_MASK			(0x7 << ESDCTL_V4_ESDCFG1_tWR_SHIFT)
+#define ESDCTL_V4_ESDCFG1_tMRD_SHIFT			5
+#define ESDCTL_V4_ESDCFG1_tMRD_MASK			(0xf << ESDCTL_V4_ESDCFG1_tMRD_SHIFT)
+#define ESDCTL_V4_ESDCFG1_tCWL_SHIFT			0
+#define ESDCTL_V4_ESDCFG1_tCWL_MASK			(0x7 << ESDCTL_V4_ESDCFG1_tCWL_SHIFT)
+
+#define ESDCTL_V4_ESDCFG2_tDLLK_SHIFT			16
+#define ESDCTL_V4_ESDCFG2_tDLLK_MASK			(0x1ff << ESDCTL_V4_ESDCFG2_tDLLK_SHIFT)
+#define ESDCTL_V4_ESDCFG2_tRTP_SHIFT			6
+#define ESDCTL_V4_ESDCFG2_tRTP_MASK			(0x7 << ESDCTL_V4_ESDCFG2_tRTP_SHIFT)
+#define ESDCTL_V4_ESDCFG2_tWTR_SHIFT			3
+#define ESDCTL_V4_ESDCFG2_tWTR_MASK			(0x7 << ESDCTL_V4_ESDCFG2_tWTR_SHIFT)
+#define ESDCTL_V4_ESDCFG2_tRRD_SHIFT			0
+#define ESDCTL_V4_ESDCFG2_tRRD_MASK			(0x7 << ESDCTL_V4_ESDCFG2_tRRD_SHIFT)
+
+#define ESDCTL_V4_ESDRWD_tDAI_SHIFT			16
+#define ESDCTL_V4_ESDRWD_tDAI_MASK			(0x1fff << ESDCTL_V4_ESDRWD_tDAI_SHIFT)
+#define ESDCTL_V4_ESDRWD_RTW_SAME_SHIFT			12
+#define ESDCTL_V4_ESDRWD_RTW_SAME_MASK			(0x7 << ESDCTL_V4_ESDRWD_RTW_SAME_SHIFT)
+#define ESDCTL_V4_ESDRWD_WTR_DIFF_SHIFT			9
+#define ESDCTL_V4_ESDRWD_WTR_DIFF_MASK			(0x7 << ESDCTL_V4_ESDRWD_WTR_DIFF_SHIFT)
+#define ESDCTL_V4_ESDRWD_WTW_DIFF_SHIFT			6
+#define ESDCTL_V4_ESDRWD_WTW_DIFF_MASK			(0x7 << ESDCTL_V4_ESDRWD_WTW_DIFF_SHIFT)
+#define ESDCTL_V4_ESDRWD_RTW_DIFF_SHIFT			3
+#define ESDCTL_V4_ESDRWD_RTW_DIFF_MASK			(0x7 << ESDCTL_V4_ESDRWD_RTW_DIFF_SHIFT)
+#define ESDCTL_V4_ESDRWD_RTR_DIFF_SHIFT			0
+#define ESDCTL_V4_ESDRWD_RTR_DIFF_MASK			(0x7 << ESDCTL_V4_ESDRWD_RTR_DIFF_SHIFT)
+
+#define ESDCTL_V4_ESDOR_tXPR_SHIFT			16
+#define ESDCTL_V4_ESDOR_tXPR_MASK			(0xff << ESDCTL_V4_ESDOR_tXPR_SHIFT)
+#define ESDCTL_V4_ESDOR_SDE_to_RST_SHIFT		8
+#define ESDCTL_V4_ESDOR_SDE_to_RST_MASK			(0x3f << ESDCTL_V4_ESDOR_SDE_to_RST_SHIFT)
+#define ESDCTL_V4_ESDOR_RST_to_CKE_SHIFT		0
+#define ESDCTL_V4_ESDOR_RST_to_CKE_MASK			(0x3f << ESDCTL_V4_ESDOR_RST_to_CKE_SHIFT)
+
+#define ESDCTL_V4_ESDOTC_tAOFPD_SHIFT			27
+#define ESDCTL_V4_ESDOTC_tAOFPD_MASK			(0x7 << ESDCTL_V4_ESDOTC_tAOFPD_SHIFT)
+#define ESDCTL_V4_ESDOTC_tAONPD_SHIFT			24
+#define ESDCTL_V4_ESDOTC_tAONPD_MASK			(0x7 << ESDCTL_V4_ESDOTC_tAONPD_SHIFT)
+#define ESDCTL_V4_ESDOTC_tANPD_SHIFT			20
+#define ESDCTL_V4_ESDOTC_tANPD_MASK			(0xf << ESDCTL_V4_ESDOTC_tANPD_SHIFT)
+#define ESDCTL_V4_ESDOTC_tAXPD_SHIFT			16
+#define ESDCTL_V4_ESDOTC_tAXPD_MASK			(0xf << ESDCTL_V4_ESDOTC_tAXPD_SHIFT)
+#define ESDCTL_V4_ESDOTC_tODTLon_SHIFT			12
+#define ESDCTL_V4_ESDOTC_tODTLon_MASK			(0x7 << ESDCTL_V4_ESDOTC_tODTLon_SHIFT)
+#define ESDCTL_V4_ESDOTC_tODT_idle_off_SHIFT		4
+#define ESDCTL_V4_ESDOTC_tODT_idle_off_MASK		(0x1f << ESDCTL_V4_ESDOTC_tODT_idle_off_SHIFT)
+
+#define ESDCTL_V4_ESDPDC_PRCT1_SHIFT			28
+#define ESDCTL_V4_ESDPDC_PRCT1_MASK			(0x7 << ESDCTL_V4_ESDPDC_PRCT1_SHIFT)
+#define ESDCTL_V4_ESDPDC_PRCT0_SHIFT			24
+#define ESDCTL_V4_ESDPDC_PRCT0_MASK			(0x7 << ESDCTL_V4_ESDPDC_PRCT0_SHIFT)
+#define ESDCTL_V4_ESDPDC_tCKE_SHIFT			16
+#define ESDCTL_V4_ESDPDC_tCKE_MASK			(0x7 << ESDCTL_V4_ESDPDC_tCKE_SHIFT)
+#define ESDCTL_V4_ESDPDC_PWDT1_SHIFT			12
+#define ESDCTL_V4_ESDPDC_PWDT1_MASK			(0xf << ESDCTL_V4_ESDPDC_PWDT1_SHIFT)
+#define ESDCTL_V4_ESDPDC_PWDT0_SHIFT			8
+#define ESDCTL_V4_ESDPDC_PWDT0_MASK			(0xf << ESDCTL_V4_ESDPDC_PWDT0_SHIFT)
+#define ESDCTL_V4_ESDPDC_SLOW_PD			0x00000080
+#define ESDCTL_V4_ESDPDC_BOTH_CS_PD			0x00000040
+#define ESDCTL_V4_ESDPDC_tCKSRX_SHIFT			3
+#define ESDCTL_V4_ESDPDC_tCKSRX_MASK			(0x7 << ESDCTL_V4_ESDPDC_tCKSRX_SHIFT)
+#define ESDCTL_V4_ESDPDC_tCKSRE_SHIFT			0
+#define ESDCTL_V4_ESDPDC_tCKSRE_MASK			(0x7 << ESDCTL_V4_ESDPDC_tCKSRE_SHIFT)
+
+#define ESDCTL_V4_ESDPDC_PRCT_DISABLE			0x0
+#define ESDCTL_V4_ESDPDC_PRCT_2				0x1
+#define ESDCTL_V4_ESDPDC_PRCT_4				0x2
+#define ESDCTL_V4_ESDPDC_PRCT_8				0x3
+#define ESDCTL_V4_ESDPDC_PRCT_16			0x4
+#define ESDCTL_V4_ESDPDC_PRCT_32			0x5
+#define ESDCTL_V4_ESDPDC_PRCT_64			0x6
+#define ESDCTL_V4_ESDPDC_PRCT_128			0x7
+
+#define ESDCTL_V4_ESDPDC_PWDT_DISABLE			0x0
+#define ESDCTL_V4_ESDPDC_PWDT_16			0x1
+#define ESDCTL_V4_ESDPDC_PWDT_32			0x2
+#define ESDCTL_V4_ESDPDC_PWDT_64			0x3
+#define ESDCTL_V4_ESDPDC_PWDT_128			0x4
+#define ESDCTL_V4_ESDPDC_PWDT_256			0x5
+#define ESDCTL_V4_ESDPDC_PWDT_512			0x6
+#define ESDCTL_V4_ESDPDC_PWDT_1024			0x7
+#define ESDCTL_V4_ESDPDC_PWDT_2048			0x8
+#define ESDCTL_V4_ESDPDC_PWDT_4096			0x9
+#define ESDCTL_V4_ESDPDC_PWDT_8192			0xa
+#define ESDCTL_V4_ESDPDC_PWDT_16384			0xb
+#define ESDCTL_V4_ESDPDC_PWDT_32768			0xc
+
+#define ESDCTL_V4_ESDREF_REF_CNT_SHIFT			16
+#define ESDCTL_V4_ESDREF_REF_CNT_MASK			(0xffff << ESDCTL_V4_ESDREF_REF_CNT_SHIFT)
+#define ESDCTL_V4_ESDREF_REF_SEL_MASK			0x0000c000
+#define ESDCTL_V4_ESDREF_REF_SEL_64K			0x00000000
+#define ESDCTL_V4_ESDREF_REF_SEL_32K			0x00001000
+#define ESDCTL_V4_ESDREF_REF_SEL_REFCNT			0x00002000
+#define ESDCTL_V4_ESDREF_REFR_SHIFT			11
+#define ESDCTL_V4_ESDREF_REFR_MASK			(0x7 << ESDCTL_V4_ESDREF_REFR_SHIFT)
+#define ESDCTL_V4_ESDREF_START_REF			0x00000001
+
+#define ESDCTL_V4_ESDZQHWC_ZQ_PARA_EN			0x04000000
+#define ESDCTL_V4_ESDZQHWC_TZQ_CS_SHIFT			23
+#define ESDCTL_V4_ESDZQHWC_TZQ_CS_MASK			(0x7 << ESDCTL_V4_ESDZQHWC_TZQ_CS_SHIFT)
+#define ESDCTL_V4_ESDZQHWC_TZQ_OPER_SHIFT		20
+#define ESDCTL_V4_ESDZQHWC_TZQ_OPER_MASK		(0x7 << ESDCTL_V4_ESDZQHWC_TZQ_OPER_SHIFT)
+#define ESDCTL_V4_ESDZQHWC_TZQ_INIT_SHIFT		17
+#define ESDCTL_V4_ESDZQHWC_TZQ_INIT_MASK		(0x7 << ESDCTL_V4_ESDZQHWC_TZQ_INIT_SHIFT)
+#define ESDCTL_V4_ESDZQHWC_ZQ_HW_FOR			0x00010000
+#define ESDCTL_V4_ESDZQHWC_ZQ_HW_PD_RES_SHIFT		11
+#define ESDCTL_V4_ESDZQHWC_ZQ_HW_PD_RES_MASK		(0x1f << ESDCTL_V4_ESDZQHWC_ZQ_HW_PD_RES_SHIFT)
+#define ESDCTL_V4_ESDZQHWC_ZQ_HW_PU_RES_SHIFT		6
+#define ESDCTL_V4_ESDZQHWC_ZQ_HW_PU_RES_MASK		(0x1f << ESDCTL_V4_ESDZQHWC_ZQ_HW_PU_RES_SHIFT)
+#define ESDCTL_V4_ESDZQHWC_ZQ_HW_PER_SHIFT		2
+#define ESDCTL_V4_ESDZQHWC_ZQ_HW_PER_MASK		(0xf << ESDCTL_V4_ESDZQHWC_ZQ_HW_PER_SHIFT)
+#define ESDCTL_V4_ESDZQHWC_ZQ_MODE_SHIFT		0
+#define ESDCTL_V4_ESDZQHWC_ZQ_MODE_MASK			(0x3 << ESDCTL_V4_ESDZQHWC_ZQ_MODE_SHIFT)
+
+#define ESDCTL_V4_ESDZQHWC_32CYC			0x0
+#define ESDCTL_V4_ESDZQHWC_64CYC			0x1
+#define ESDCTL_V4_ESDZQHWC_128CYC			0x2
+#define ESDCTL_V4_ESDZQHWC_256CYC			0x3
+#define ESDCTL_V4_ESDZQHWC_512CYC			0x4
+#define ESDCTL_V4_ESDZQHWC_1024CYC			0x5
+
+#define ESDCTL_V4_ESDZQHWC_ZQ_MODE_NO_CAL		(0x0 << ESDCTL_V4_ESDZQHWC_ZQ_MODE_SHIFT)
+#define ESDCTL_V4_ESDZQHWC_ZQ_MODE_BOTH_EXIT		(0x1 << ESDCTL_V4_ESDZQHWC_ZQ_MODE_SHIFT)
+#define ESDCTL_V4_ESDZQHWC_ZQ_MODE_EXTERNAL_PER		(0x2 << ESDCTL_V4_ESDZQHWC_ZQ_MODE_SHIFT)
+#define ESDCTL_V4_ESDZQHWC_ZQ_MODE_BOTH_PER		(0x3 << ESDCTL_V4_ESDZQHWC_ZQ_MODE_SHIFT)
+
+#define ESDCTL_V4_ESDODTC_ODT3_INT_RES_SHIFT		16
+#define ESDCTL_V4_ESDODTC_ODT3_INT_RES_MASK		(0x7 << ESDCTL_V4_ESDODTC_ODT3_INT_RES_SHIFT)
+#define ESDCTL_V4_ESDODTC_ODT2_INT_RES_SHIFT		12
+#define ESDCTL_V4_ESDODTC_ODT2_INT_RES_MASK		(0x7 << ESDCTL_V4_ESDODTC_ODT2_INT_RES_SHIFT)
+#define ESDCTL_V4_ESDODTC_ODT1_INT_RES_SHIFT		8
+#define ESDCTL_V4_ESDODTC_ODT1_INT_RES_MASK		(0x7 << ESDCTL_V4_ESDODTC_ODT1_INT_RES_SHIFT)
+#define ESDCTL_V4_ESDODTC_ODT0_INT_RES_SHIFT		4
+#define ESDCTL_V4_ESDODTC_ODT0_INT_RES_MASK		(0x7 << ESDCTL_V4_ESDODTC_ODT0_INT_RES_SHIFT)
+#define ESDCTL_V4_ESDODTC_ODT_RD_ACT_EN			0x00000008
+#define ESDCTL_V4_ESDODTC_ODT_RD_PAS_EN			0x00000004
+#define ESDCTL_V4_ESDODTC_ODT_WR_ACT_EN			0x00000002
+#define ESDCTL_V4_ESDODTC_ODT_WR_PAS_EN			0x00000001
+
+#define ESDCTL_V4_ESDODTC_RTT_DISABLE			0x0
+#define ESDCTL_V4_ESDODTC_RTT_60			0x1
+#define ESDCTL_V4_ESDODTC_RTT_120			0x2
+#define ESDCTL_V4_ESDODTC_RTT_40			0x3
+#define ESDCTL_V4_ESDODTC_RTT_20			0x4
+#define ESDCTL_V4_ESDODTC_RTT_30			0x5
+
+#define ESDCTL_V4_ESDSCR_CMD_ADDR_SHIFT			16
+#define ESDCTL_V4_ESDSCR_CMD_ADDR_MASK			(0xffff << ESDCTL_V4_ESDSCR_CMD_ADDR_SHIFT)
+#define ESDCTL_V4_ESDSCR_CON_REQ			0x00008000
+#define ESDCTL_V4_ESDSCR_CON_ACK			0x00004000
+#define ESDCTL_V4_ESDSCR_MRR_DATA_VALID			0x00000400
+#define ESDCTL_V4_ESDSCR_WL_EN				0x00000200
+#define ESDCTL_V4_ESDSCR_DLL_RST1			0x00000100
+#define ESDCTL_V4_ESDSCR_DLL_RST0			0x00000080
+#define ESDCTL_V4_ESDSCR_CMD_SHIFT			4
+#define ESDCTL_V4_ESDSCR_CMD_MASK			(0x7 << ESDCTL_V4_ESDSCR_CMD_SHIFT)
+#define ESDCTL_V4_ESDSCR_CMD_NOP			(0x0 << ESDCTL_V4_ESDSCR_CMD_SHIFT)
+#define ESDCTL_V4_ESDSCR_CMD_PRE_ALL			(0x1 << ESDCTL_V4_ESDSCR_CMD_SHIFT)
+#define ESDCTL_V4_ESDSCR_CMD_AREFRESH			(0x2 << ESDCTL_V4_ESDSCR_CMD_SHIFT)
+#define ESDCTL_V4_ESDSCR_CMD_LMR			(0x3 << ESDCTL_V4_ESDSCR_CMD_SHIFT)
+#define ESDCTL_V4_ESDSCR_CMD_ZQCALIB_OLD		(0x4 << ESDCTL_V4_ESDSCR_CMD_SHIFT)
+#define ESDCTL_V4_ESDSCR_CMD_PRE_ALL_OPEN		(0x5 << ESDCTL_V4_ESDSCR_CMD_SHIFT)
+#define ESDCTL_V4_ESDSCR_CMD_MRR			(0x6 << ESDCTL_V4_ESDSCR_CMD_SHIFT)
+#define ESDCTL_V4_ESDSCR_CMD_CS				0x00000008
+#define ESDCTL_V4_ESDSCR_CMD_CS0			0x00000000
+#define ESDCTL_V4_ESDSCR_CMD_CS1			0x00000008
+#define ESDCTL_V4_ESDSCR_CMD_BA_SHIFT			0
+#define ESDCTL_V4_ESDSCR_CMD_BA_MASK			(0x7 << ESDCTL_V4_ESDSCR_CMD_BA_SHIFT)
+
+#define ESDCTL_V4_PDCMPR2_PHY_CA_DL_SHIFT		24
+#define ESDCTL_V4_PDCMPR2_PHY_CA_DL_MASK		(0x7f << ESDCTL_V4_PDCMPR2_PHY_CA_DL_SHIFT)
+#define ESDCTL_V4_PDCMPR2_CA_DL_ABS_SHIFT		16
+#define ESDCTL_V4_PDCMPR2_CA_DL_ABS_MASK		(0x7f << ESDCTL_V4_PDCMPR2_CA_DL_ABS_SHIFT)
+#define ESDCTL_V4_PDCMPR2_RLPAT				0x4
+#define ESDCTL_V4_PDCMPR2_RLPAT_0			0x0
+#define ESDCTL_V4_PDCMPR2_RLPAT_1			0x4
+#define ESDCTL_V4_PDCMPR2_MPR_FULL_CMP			0x2
+#define ESDCTL_V4_PDCMPR2_MPR_CMP			0x1
+
+#define ESDCTL_V4_WLGCR_WL_HW_ERR3			(1 << 11)
+#define ESDCTL_V4_WLGCR_WL_HW_ERR2			(1 << 10)
+#define ESDCTL_V4_WLGCR_WL_HW_ERR1			(1 << 9)
+#define ESDCTL_V4_WLGCR_WL_HW_ERR0			(1 << 8)
+#define ESDCTL_V4_WLGCR_WL_SW_ERR3			(1 << 7)
+#define ESDCTL_V4_WLGCR_WL_SW_ERR2			(1 << 6)
+#define ESDCTL_V4_WLGCR_WL_SW_ERR1			(1 << 5)
+#define ESDCTL_V4_WLGCR_WL_SW_ERR0			(1 << 4)
+#define ESDCTL_V4_WLGCR_SW_WL_CNT_EN			(1 << 2)
+#define ESDCTL_V4_WLGCR_SW_WL_EN			(1 << 1)
+#define ESDCTL_V4_WLGCR_HW_WL_EN			(1 << 1)
+
+#define ESDCTL_V4_RDDLHWCTL_HW_RDL_CMP_CYC		(1 << 5)
+#define ESDCTL_V4_RDDLHWCTL_HW_RDL_EN			(1 << 4)
+#define ESDCTL_V4_RDDLHWCTL_HW_RDL_ERR3			(1 << 3)
+#define ESDCTL_V4_RDDLHWCTL_HW_RDL_ERR2			(1 << 2)
+#define ESDCTL_V4_RDDLHWCTL_HW_RDL_ERR1			(1 << 1)
+#define ESDCTL_V4_RDDLHWCTL_HW_RDL_ERR0			(1 << 0)
+
+#define ESDCTL_V4_WRDLHWCTL_HW_WDL_CMP_CYC		(1 << 5)
+#define ESDCTL_V4_WRDLHWCTL_HW_WDL_EN			(1 << 4)
+#define ESDCTL_V4_WRDLHWCTL_HW_WDL_ERR3			(1 << 3)
+#define ESDCTL_V4_WRDLHWCTL_HW_WDL_ERR2			(1 << 2)
+#define ESDCTL_V4_WRDLHWCTL_HW_WDL_ERR1			(1 << 1)
+#define ESDCTL_V4_WRDLHWCTL_HW_WDL_ERR0			(1 << 0)
+
+#define ESDCTL_V4_DDR3_REG_MR0				(0x0 << ESDCTL_V4_ESDSCR_CMD_BA_SHIFT)
+#define ESDCTL_V4_DDR3_REG_MR1				(0x1 << ESDCTL_V4_ESDSCR_CMD_BA_SHIFT)
+#define ESDCTL_V4_DDR3_REG_MR2				(0x2 << ESDCTL_V4_ESDSCR_CMD_BA_SHIFT)
+#define ESDCTL_V4_DDR3_REG_MR3				(0x3 << ESDCTL_V4_ESDSCR_CMD_BA_SHIFT)
+
+#define ESDCTL_V4_DDR3_MR0_PPD				(0x1000 << ESDCTL_V4_ESDSCR_CMD_ADDR_SHIFT)
+#define ESDCTL_V4_DDR3_MR0_PPD_SLOW			(0x0000 << ESDCTL_V4_ESDSCR_CMD_ADDR_SHIFT)
+#define ESDCTL_V4_DDR3_MR0_PPD_FAST			(0x1000 << ESDCTL_V4_ESDSCR_CMD_ADDR_SHIFT)
+#define ESDCTL_V4_DDR3_MR0_WR_SHIFT			(9 + ESDCTL_V4_ESDSCR_CMD_ADDR_SHIFT)
+#define ESDCTL_V4_DDR3_MR0_WR_MASK			(0x7 << ESDCTL_V4_DDR3_MR0_WR_SHIFT)
+#define ESDCTL_V4_DDR3_MR0_WR_16			(0x0 << ESDCTL_V4_DDR3_MR0_WR_SHIFT)
+#define ESDCTL_V4_DDR3_MR0_WR_5				(0x1 << ESDCTL_V4_DDR3_MR0_WR_SHIFT)
+#define ESDCTL_V4_DDR3_MR0_WR_6				(0x2 << ESDCTL_V4_DDR3_MR0_WR_SHIFT)
+#define ESDCTL_V4_DDR3_MR0_WR_7				(0x3 << ESDCTL_V4_DDR3_MR0_WR_SHIFT)
+#define ESDCTL_V4_DDR3_MR0_WR_8				(0x4 << ESDCTL_V4_DDR3_MR0_WR_SHIFT)
+#define ESDCTL_V4_DDR3_MR0_WR_10			(0x5 << ESDCTL_V4_DDR3_MR0_WR_SHIFT)
+#define ESDCTL_V4_DDR3_MR0_WR_12			(0x6 << ESDCTL_V4_DDR3_MR0_WR_SHIFT)
+#define ESDCTL_V4_DDR3_MR0_WR_14			(0x7 << ESDCTL_V4_DDR3_MR0_WR_SHIFT)
+#define ESDCTL_V4_DDR3_DLL_RESET			(0x0100 << ESDCTL_V4_ESDSCR_CMD_ADDR_SHIFT)
+#define ESDCTL_V4_DDR3_TM				(0x0080 << ESDCTL_V4_ESDSCR_CMD_ADDR_SHIFT)
+#define ESDCTL_V4_DDR3_TM_NORMAL			(0x0000 << ESDCTL_V4_ESDSCR_CMD_ADDR_SHIFT)
+#define ESDCTL_V4_DDR3_TM_TEST				(0x0080 << ESDCTL_V4_ESDSCR_CMD_ADDR_SHIFT)
+#define ESDCTL_V4_DDR3_MR0_CL_SHIFT			(2 + ESDCTL_V4_ESDSCR_CMD_ADDR_SHIFT)
+#define ESDCTL_V4_DDR3_MR0_CL_MASK			(0x74 << ESDCTL_V4_DDR3_MR0_CL_SHIFT)
+#define ESDCTL_V4_DDR3_MR0_CL_5				(0x10 << ESDCTL_V4_DDR3_MR0_CL_SHIFT)
+#define ESDCTL_V4_DDR3_MR0_CL_6				(0x20 << ESDCTL_V4_DDR3_MR0_CL_SHIFT)
+#define ESDCTL_V4_DDR3_MR0_CL_7				(0x30 << ESDCTL_V4_DDR3_MR0_CL_SHIFT)
+#define ESDCTL_V4_DDR3_MR0_CL_8				(0x40 << ESDCTL_V4_DDR3_MR0_CL_SHIFT)
+#define ESDCTL_V4_DDR3_MR0_CL_9				(0x50 << ESDCTL_V4_DDR3_MR0_CL_SHIFT)
+#define ESDCTL_V4_DDR3_MR0_CL_10			(0x60 << ESDCTL_V4_DDR3_MR0_CL_SHIFT)
+#define ESDCTL_V4_DDR3_MR0_CL_11			(0x70 << ESDCTL_V4_DDR3_MR0_CL_SHIFT)
+#define ESDCTL_V4_DDR3_MR0_CL_12			(0x04 << ESDCTL_V4_DDR3_MR0_CL_SHIFT)
+#define ESDCTL_V4_DDR3_MR0_CL_13			(0x14 << ESDCTL_V4_DDR3_MR0_CL_SHIFT)
+#define ESDCTL_V4_DDR3_MR0_CL_14			(0x24 << ESDCTL_V4_DDR3_MR0_CL_SHIFT)
+#define ESDCTL_V4_DDR3_MR0_CL_15			(0x34 << ESDCTL_V4_DDR3_MR0_CL_SHIFT)
+#define ESDCTL_V4_DDR3_MR0_CL_16			(0x44 << ESDCTL_V4_DDR3_MR0_CL_SHIFT)
+#define ESDCTL_V4_DDR3_MR0_RBT				(0x0008 << ESDCTL_V4_ESDSCR_CMD_ADDR_SHIFT)
+#define ESDCTL_V4_DDR3_MR0_RBT_NIBBLE			(0x0000 << ESDCTL_V4_ESDSCR_CMD_ADDR_SHIFT)
+#define ESDCTL_V4_DDR3_MR0_RBT_INTERL			(0x0008 << ESDCTL_V4_ESDSCR_CMD_ADDR_SHIFT)
+#define ESDCTL_V4_DDR3_MR0_BL_SHIFT			(0 + ESDCTL_V4_ESDSCR_CMD_ADDR_SHIFT)
+#define ESDCTL_V4_DDR3_MR0_BL_MASK			(0x3 << ESDCTL_V4_DDR3_MR0_BL_SHIFT)
+#define ESDCTL_V4_DDR3_MR0_BL_FIXED8			(0x0 << ESDCTL_V4_DDR3_MR0_BL_SHIFT)
+#define ESDCTL_V4_DDR3_MR0_BL_DYNAMIC			(0x1 << ESDCTL_V4_DDR3_MR0_BL_SHIFT)
+#define ESDCTL_V4_DDR3_MR0_BL_FIXED4			(0x2 << ESDCTL_V4_DDR3_MR0_BL_SHIFT)
+
+#define ESDCTL_V4_DDR3_MR1_QOFF				(0x1000 << ESDCTL_V4_ESDSCR_CMD_ADDR_SHIFT)
+#define ESDCTL_V4_DDR3_MR1_TDQS				(0x0800 << ESDCTL_V4_ESDSCR_CMD_ADDR_SHIFT)
+#define ESDCTL_V4_DDR3_MR1_WL				(0x0080 << ESDCTL_V4_ESDSCR_CMD_ADDR_SHIFT)
+#define ESDCTL_V4_DDR3_MR1_AL_SHIFT			(3 + ESDCTL_V4_ESDSCR_CMD_ADDR_SHIFT)
+#define ESDCTL_V4_DDR3_MR1_AL_MASK			(0x3 << ESDCTL_V4_DDR3_MR1_AL_SHIFT)
+#define ESDCTL_V4_DDR3_MR1_AL_DISABLE			(0x0 << ESDCTL_V4_DDR3_MR1_AL_SHIFT)
+#define ESDCTL_V4_DDR3_MR1_AL_CL1			(0x1 << ESDCTL_V4_DDR3_MR1_AL_SHIFT)
+#define ESDCTL_V4_DDR3_MR1_AL_CL2			(0x2 << ESDCTL_V4_DDR3_MR1_AL_SHIFT)
+#define ESDCTL_V4_DDR3_MR1_DLL_DISABLE			(0x0001 << ESDCTL_V4_ESDSCR_CMD_ADDR_SHIFT)
+#define ESDCTL_V4_DDR3_MR1_RTTN_MASK			(0x0244 << ESDCTL_V4_ESDSCR_CMD_ADDR_SHIFT)
+#define ESDCTL_V4_DDR3_MR1_RTTN_DIS			(0x0000 << ESDCTL_V4_ESDSCR_CMD_ADDR_SHIFT)
+#define ESDCTL_V4_DDR3_MR1_RTTN_RZQ4			(0x0004 << ESDCTL_V4_ESDSCR_CMD_ADDR_SHIFT)
+#define ESDCTL_V4_DDR3_MR1_RTTN_RZQ2			(0x0040 << ESDCTL_V4_ESDSCR_CMD_ADDR_SHIFT)
+#define ESDCTL_V4_DDR3_MR1_RTTN_RZQ6			(0x0044 << ESDCTL_V4_ESDSCR_CMD_ADDR_SHIFT)
+#define ESDCTL_V4_DDR3_MR1_RTTN_RZQ12			(0x0200 << ESDCTL_V4_ESDSCR_CMD_ADDR_SHIFT)
+#define ESDCTL_V4_DDR3_MR1_RTTN_RZQ8			(0x0204 << ESDCTL_V4_ESDSCR_CMD_ADDR_SHIFT)
+#define ESDCTL_V4_DDR3_MR1_ODIC_MASK			(0x0022 << ESDCTL_V4_ESDSCR_CMD_ADDR_SHIFT)
+#define ESDCTL_V4_DDR3_MR1_ODIC_RZQ6			(0x0000 << ESDCTL_V4_ESDSCR_CMD_ADDR_SHIFT)
+#define ESDCTL_V4_DDR3_MR1_ODIC_RZQ7			(0x0002 << ESDCTL_V4_ESDSCR_CMD_ADDR_SHIFT)
+
+#define ESDCTL_V4_DDR3_MR2_RTTWR_SHIFT			(9 + ESDCTL_V4_ESDSCR_CMD_ADDR_SHIFT)
+#define ESDCTL_V4_DDR3_MR2_RTTWR_MASK			(0x3 << ESDCTL_V4_DDR3_MR2_RTTWR_SHIFT)
+#define ESDCTL_V4_DDR3_MR2_RTTWR_OFF			(0x0 << ESDCTL_V4_DDR3_MR2_RTTWR_SHIFT)
+#define ESDCTL_V4_DDR3_MR2_RTTWR_RZQ4			(0x1 << ESDCTL_V4_DDR3_MR2_RTTWR_SHIFT)
+#define ESDCTL_V4_DDR3_MR2_RTTWR_RZQ2			(0x2 << ESDCTL_V4_DDR3_MR2_RTTWR_SHIFT)
+#define ESDCTL_V4_DDR3_MR2_SRT				(0x0080 << ESDCTL_V4_ESDSCR_CMD_ADDR_SHIFT)
+#define ESDCTL_V4_DDR3_MR2_SRT_NORMAL			(0x0000 << ESDCTL_V4_ESDSCR_CMD_ADDR_SHIFT)
+#define ESDCTL_V4_DDR3_MR2_SRT_EXTENDED			(0x0080 << ESDCTL_V4_ESDSCR_CMD_ADDR_SHIFT)
+#define ESDCTL_V4_DDR3_MR2_ASR_ENABLE			(0x0040 << ESDCTL_V4_ESDSCR_CMD_ADDR_SHIFT)
+#define ESDCTL_V4_DDR3_MR2_CWL_SHIFT			(3 + ESDCTL_V4_ESDSCR_CMD_ADDR_SHIFT)
+#define ESDCTL_V4_DDR3_MR2_CWL_MASK			(0x7 << ESDCTL_V4_DDR3_MR2_CWL_SHIFT)
+#define ESDCTL_V4_DDR3_MR2_CWL_5			(0x0 << ESDCTL_V4_DDR3_MR2_CWL_SHIFT)
+#define ESDCTL_V4_DDR3_MR2_CWL_6			(0x1 << ESDCTL_V4_DDR3_MR2_CWL_SHIFT)
+#define ESDCTL_V4_DDR3_MR2_CWL_7			(0x2 << ESDCTL_V4_DDR3_MR2_CWL_SHIFT)
+#define ESDCTL_V4_DDR3_MR2_CWL_8			(0x3 << ESDCTL_V4_DDR3_MR2_CWL_SHIFT)
+#define ESDCTL_V4_DDR3_MR2_CWL_9			(0x4 << ESDCTL_V4_DDR3_MR2_CWL_SHIFT)
+#define ESDCTL_V4_DDR3_MR2_CWL_10			(0x5 << ESDCTL_V4_DDR3_MR2_CWL_SHIFT)
+#define ESDCTL_V4_DDR3_MR2_CWL_11			(0x6 << ESDCTL_V4_DDR3_MR2_CWL_SHIFT)
+#define ESDCTL_V4_DDR3_MR2_CWL_12			(0x7 << ESDCTL_V4_DDR3_MR2_CWL_SHIFT)
+#define ESDCTL_V4_DDR3_MR2_PASR_SHIFT			(0 + ESDCTL_V4_ESDSCR_CMD_ADDR_SHIFT)
+#define ESDCTL_V4_DDR3_MR2_PASR_MASK			(0x7 << ESDCTL_V4_DDR3_MR2_PASR_SHIFT)
+#define ESDCTL_V4_DDR3_MR2_PASR_1_1			(0x0 << ESDCTL_V4_DDR3_MR2_PASR_SHIFT)
+#define ESDCTL_V4_DDR3_MR2_PASR_1_2L			(0x1 << ESDCTL_V4_DDR3_MR2_PASR_SHIFT)
+#define ESDCTL_V4_DDR3_MR2_PASR_1_4L			(0x2 << ESDCTL_V4_DDR3_MR2_PASR_SHIFT)
+#define ESDCTL_V4_DDR3_MR2_PASR_1_8L			(0x3 << ESDCTL_V4_DDR3_MR2_PASR_SHIFT)
+#define ESDCTL_V4_DDR3_MR2_PASR_3_4L			(0x4 << ESDCTL_V4_DDR3_MR2_PASR_SHIFT)
+#define ESDCTL_V4_DDR3_MR2_PASR_1_2H			(0x5 << ESDCTL_V4_DDR3_MR2_PASR_SHIFT)
+#define ESDCTL_V4_DDR3_MR2_PASR_1_4H			(0x6 << ESDCTL_V4_DDR3_MR2_PASR_SHIFT)
+#define ESDCTL_V4_DDR3_MR2_PASR_1_8H			(0x7 << ESDCTL_V4_DDR3_MR2_PASR_SHIFT)
+
+#define ESDCTL_V4_DDR3_MR3_MPR_DISABLE			(0x0000 << ESDCTL_V4_ESDSCR_CMD_ADDR_SHIFT)
+#define ESDCTL_V4_DDR3_MR3_MPR_ENABLE			(0x0004 << ESDCTL_V4_ESDSCR_CMD_ADDR_SHIFT)
+#define ESDCTL_V4_DDR3_MR3_MPR_PATTERN			(0x0000 << ESDCTL_V4_ESDSCR_CMD_ADDR_SHIFT)
+#define ESDCTL_V4_DDR3_MR3_MPR_RFU1			(0x0001 << ESDCTL_V4_ESDSCR_CMD_ADDR_SHIFT)
+#define ESDCTL_V4_DDR3_MR3_MPR_RFU2			(0x0002 << ESDCTL_V4_ESDSCR_CMD_ADDR_SHIFT)
+#define ESDCTL_V4_DDR3_MR3_MPR_RFU3			(0x0003 << ESDCTL_V4_ESDSCR_CMD_ADDR_SHIFT)
+
+#ifndef __ASSEMBLY__
+
+void imx_esdctlv4_do_write_leveling(void);
+void imx_esdctlv4_do_dqs_gating(void);
+void imx_esdctlv4_do_zq_calibration(void);
+void imx_esdctlv4_start_ddr3_sdram(int cs);
+void imx_esdctlv4_do_read_delay_line_calibration(void);
+void imx_esdctlv4_do_write_delay_line_calibration(void);
+void imx_esdctlv4_set_tRFC_timing(void);
+void imx_esdctlv4_detect_sdrams(void);
+void imx_esdctlv4_init(void);
+
+#endif
+
+#endif /* __MACH_ESDCTL_V4_H */
-- 
1.7.10.4



From eric at eukrea.com  Wed Nov 28 05:11:04 2012
From: eric at eukrea.com (Eric =?ISO-8859-1?B?QuluYXJk?=)
Date: Wed, 28 Nov 2012 11:11:04 +0100
Subject: [PATCH 3/4] ARM i.MX: Add Garz+Fricke Vincell Board support
In-Reply-To: <1354096760-14409-4-git-send-email-s.hauer@pengutronix.de>
References: <1354096760-14409-1-git-send-email-s.hauer@pengutronix.de>
 <1354096760-14409-4-git-send-email-s.hauer@pengutronix.de>
Message-ID: <20121128111104.75550da5@eb-e6520>

Hi Sascha,

Le Wed, 28 Nov 2012 10:59:19 +0100,
Sascha Hauer <s.hauer at pengutronix.de> a ?crit :
> diff --git a/arch/arm/boards/freescale-mx53-loco/board.c b/arch/arm/boards/freescale-mx53-loco/board.c
> index 38ece23..5846725 100644
> --- a/arch/arm/boards/freescale-mx53-loco/board.c
> +++ b/arch/arm/boards/freescale-mx53-loco/board.c
> @@ -194,7 +194,7 @@ static int loco_devices_init(void)
>  	armlinux_set_architecture(MACH_TYPE_MX53_LOCO);
>  
>  	imx53_bbu_internal_mmc_register_handler("mmc", "/dev/disk0",
> -		BBU_HANDLER_FLAG_DEFAULT, dcd_entry, sizeof(dcd_entry));
> +		BBU_HANDLER_FLAG_DEFAULT, dcd_entry, sizeof(dcd_entry), 0);
>  
is this change expected in this patch ?

> diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/imx-bbu-internal.c
> index 05aa5f1..cfde75d 100644
> --- a/arch/arm/mach-imx/imx-bbu-internal.c
> +++ b/arch/arm/mach-imx/imx-bbu-internal.c
> @@ -15,7 +15,7 @@
>   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>   * GNU General Public License for more details.
>   */
> -
> +#define DEBUG

same here.

>  #define IMX_INTERNAL_NAND_BBU
>  
>  #include <common.h>
> diff --git a/drivers/mfd/mc34704.c b/drivers/mfd/mc34704.c
> index 276b723..54d27c8 100644
> --- a/drivers/mfd/mc34704.c
> +++ b/drivers/mfd/mc34704.c
> @@ -25,7 +25,7 @@
>  #include <i2c/i2c.h>
>  #include <mfd/mc34704.h>
>  
> -#define DRIVERNAME		"mc34704"
> +#define DRIVERNAME		"da9053"
>  
>  #define to_mc34704(a)		container_of(a, struct mc34704, cdev)
>  
and here ;-)

Eric


From s.hauer at pengutronix.de  Wed Nov 28 05:16:22 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Wed, 28 Nov 2012 11:16:22 +0100
Subject: [PATCH] ARM i.MX53 loco: switch to new default env
Message-ID: <1354097782-22047-1-git-send-email-s.hauer@pengutronix.de>

Also, update defconfig file for this. Significant changes:

- Compile in Thumb2 mode
- Use pbl lzo compressed image

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/arm/boards/freescale-mx53-loco/env/config     |   47 --------------------
 .../freescale-mx53-loco/env/init/config-board      |    7 +++
 arch/arm/configs/freescale_mx53_loco_defconfig     |   35 +++++++++++----
 arch/arm/mach-imx/Kconfig                          |    1 +
 4 files changed, 35 insertions(+), 55 deletions(-)
 delete mode 100644 arch/arm/boards/freescale-mx53-loco/env/config
 create mode 100644 arch/arm/boards/freescale-mx53-loco/env/init/config-board

diff --git a/arch/arm/boards/freescale-mx53-loco/env/config b/arch/arm/boards/freescale-mx53-loco/env/config
deleted file mode 100644
index 2ab1268..0000000
--- a/arch/arm/boards/freescale-mx53-loco/env/config
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/bin/sh
-
-global.hostname=loco
-eth0.serverip=
-user=
-
-# use 'dhcp' to do dhcp in barebox and in kernel
-# use 'none' if you want to skip kernel ip autoconfiguration
-ip=dhcp
-global.dhcp.vendor_id=barebox-mx53-loco
-
-# or set your networking parameters here
-#eth0.ipaddr=a.b.c.d
-#eth0.netmask=a.b.c.d
-#eth0.gateway=a.b.c.d
-#eth0.serverip=a.b.c.d
-
-# can be either 'nfs', 'tftp', 'nor' or 'nand'
-kernel_loc=tftp
-# can be either 'net', 'nor', 'nand' or 'initrd'
-rootfs_loc=net
-
-# can be either 'jffs2' or 'ubifs'
-rootfs_type=ubifs
-rootfsimage=root-${global.hostname}.$rootfs_type
-
-kernelimage=zImage-${global.hostname}
-#kernelimage=uImage-${global.hostname}
-#kernelimage=Image-${global.hostname}
-#kernelimage=Image-${global.hostname}.lzo
-
-if [ -n $user ]; then
-	kernelimage="$user"-"$kernelimage"
-	nfsroot="$eth0.serverip:/home/$user/nfsroot/${global.hostname}"
-	rootfsimage="$user"-"$rootfsimage"
-else
-	nfsroot="$eth0.serverip:/path/to/nfs/root"
-fi
-
-autoboot_timeout=3
-
-bootargs="console=ttymxc0,115200"
-
-disk_parts="256k(barebox)ro,128k(bareboxenv),4M(kernel),-(root)"
-
-# set a fancy prompt (if support is compiled in)
-PS1="\e[1;32mbarebox@\e[1;31m\h:\w\e[0m "
diff --git a/arch/arm/boards/freescale-mx53-loco/env/init/config-board b/arch/arm/boards/freescale-mx53-loco/env/init/config-board
new file mode 100644
index 0000000..a6cf69d
--- /dev/null
+++ b/arch/arm/boards/freescale-mx53-loco/env/init/config-board
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+# board defaults, do not change in running system. Change /env/config
+# instead
+
+global.hostname=loco
+global.linux.bootargs.base="console=ttymxc0,115200"
diff --git a/arch/arm/configs/freescale_mx53_loco_defconfig b/arch/arm/configs/freescale_mx53_loco_defconfig
index b50b050..b61f0cf 100644
--- a/arch/arm/configs/freescale_mx53_loco_defconfig
+++ b/arch/arm/configs/freescale_mx53_loco_defconfig
@@ -2,43 +2,57 @@ CONFIG_ARCH_IMX=y
 CONFIG_ARCH_IMX53=y
 CONFIG_IMX_IIM=y
 CONFIG_IMX_IIM_FUSE_BLOW=y
-CONFIG_AEABI=y
+CONFIG_THUMB2_BAREBOX=y
+CONFIG_CMD_ARM_MMUINFO=y
 CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y
 CONFIG_ARM_UNWIND=y
+CONFIG_PBL_IMAGE=y
 CONFIG_MMU=y
 CONFIG_TEXT_BASE=0x7ff00000
 CONFIG_MALLOC_SIZE=0x2000000
 CONFIG_MALLOC_TLSF=y
 CONFIG_KALLSYMS=y
 CONFIG_LONGHELP=y
-CONFIG_GLOB=y
 CONFIG_HUSH_FANCY_PROMPT=y
 CONFIG_CMDLINE_EDITING=y
 CONFIG_AUTO_COMPLETE=y
-CONFIG_DEFAULT_ENVIRONMENT_GENERIC=y
+CONFIG_MENU=y
+CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y
 CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/arm/boards/freescale-mx53-loco/env/"
+CONFIG_RESET_SOURCE=y
 CONFIG_DEBUG_INFO=y
 CONFIG_CMD_EDIT=y
 CONFIG_CMD_SLEEP=y
+CONFIG_CMD_MSLEEP=y
 CONFIG_CMD_SAVEENV=y
 CONFIG_CMD_EXPORT=y
 CONFIG_CMD_PRINTENV=y
 CONFIG_CMD_READLINE=y
+CONFIG_CMD_MENU=y
+CONFIG_CMD_MENU_MANAGEMENT=y
 CONFIG_CMD_TIME=y
+CONFIG_CMD_DIRNAME=y
+CONFIG_CMD_LN=y
+CONFIG_CMD_READLINK=y
+CONFIG_CMD_TFTP=y
+CONFIG_CMD_FILETYPE=y
 CONFIG_CMD_ECHO_E=y
 CONFIG_CMD_MEMINFO=y
 CONFIG_CMD_IOMEM=y
-CONFIG_CMD_FLASH=y
+CONFIG_CMD_CRC=y
+CONFIG_CMD_CRC_CMP=y
+CONFIG_CMD_MD5SUM=y
 CONFIG_CMD_BOOTM_SHOW_TYPE=y
 CONFIG_CMD_BOOTM_VERBOSE=y
 CONFIG_CMD_BOOTM_INITRD=y
 CONFIG_CMD_BOOTM_OFTREE=y
 CONFIG_CMD_BOOTM_OFTREE_UIMAGE=y
 CONFIG_CMD_UIMAGE=y
-# CONFIG_CMD_BOOTZ is not set
 # CONFIG_CMD_BOOTU is not set
 CONFIG_CMD_RESET=y
 CONFIG_CMD_GO=y
+CONFIG_CMD_OFTREE=y
+CONFIG_CMD_BAREBOX_UPDATE=y
 CONFIG_CMD_TIMEOUT=y
 CONFIG_CMD_PARTITION=y
 CONFIG_CMD_MAGICVAR=y
@@ -46,18 +60,19 @@ CONFIG_CMD_MAGICVAR_HELP=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_UNCOMPRESS=y
 CONFIG_CMD_I2C=y
+CONFIG_CMD_MIITOOL=y
+CONFIG_CMD_CLK=y
+CONFIG_CMD_WD=y
 CONFIG_NET=y
 CONFIG_NET_DHCP=y
-CONFIG_NET_NFS=y
 CONFIG_NET_PING=y
-CONFIG_CMD_TFTP=y
-CONFIG_FS_TFTP=y
 CONFIG_NET_NETCONSOLE=y
 CONFIG_SMSC_PHY=y
 CONFIG_DRIVER_NET_FEC_IMX=y
 # CONFIG_SPI is not set
 CONFIG_I2C=y
 CONFIG_I2C_IMX=y
+CONFIG_DISK_ATA=y
 CONFIG_USB=y
 CONFIG_USB_EHCI=y
 CONFIG_USB_STORAGE=y
@@ -65,6 +80,10 @@ CONFIG_MCI=y
 CONFIG_MCI_STARTUP=y
 CONFIG_MCI_IMX_ESDHC=y
 CONFIG_I2C_MC34708=y
+CONFIG_WATCHDOG=y
+CONFIG_WATCHDOG_IMX=y
+CONFIG_FS_TFTP=y
+CONFIG_FS_NFS=y
 CONFIG_FS_FAT=y
 CONFIG_FS_FAT_WRITE=y
 CONFIG_FS_FAT_LFN=y
diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index 3f4b452..548b107 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -446,6 +446,7 @@ choice
 	prompt "i.MX53 Board Type"
 
 config MACH_FREESCALE_MX53_LOCO
+	select HAVE_DEFAULT_ENVIRONMENT_NEW
 	bool "Freescale i.MX53 LOCO"
 
 config MACH_FREESCALE_MX53_SMD
-- 
1.7.10.4



From s.hauer at pengutronix.de  Wed Nov 28 05:23:18 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Wed, 28 Nov 2012 11:23:18 +0100
Subject: [PATCH 3/4] ARM i.MX: Add Garz+Fricke Vincell Board support
In-Reply-To: <20121128111104.75550da5@eb-e6520>
References: <1354096760-14409-1-git-send-email-s.hauer@pengutronix.de>
 <1354096760-14409-4-git-send-email-s.hauer@pengutronix.de>
 <20121128111104.75550da5@eb-e6520>
Message-ID: <20121128102318.GN10369@pengutronix.de>

On Wed, Nov 28, 2012 at 11:11:04AM +0100, Eric B?nard wrote:
> Hi Sascha,
> 
> Le Wed, 28 Nov 2012 10:59:19 +0100,
> Sascha Hauer <s.hauer at pengutronix.de> a ?crit :
> > diff --git a/arch/arm/boards/freescale-mx53-loco/board.c b/arch/arm/boards/freescale-mx53-loco/board.c
> > index 38ece23..5846725 100644
> > --- a/arch/arm/boards/freescale-mx53-loco/board.c
> > +++ b/arch/arm/boards/freescale-mx53-loco/board.c
> > @@ -194,7 +194,7 @@ static int loco_devices_init(void)
> >  	armlinux_set_architecture(MACH_TYPE_MX53_LOCO);
> >  
> >  	imx53_bbu_internal_mmc_register_handler("mmc", "/dev/disk0",
> > -		BBU_HANDLER_FLAG_DEFAULT, dcd_entry, sizeof(dcd_entry));
> > +		BBU_HANDLER_FLAG_DEFAULT, dcd_entry, sizeof(dcd_entry), 0);
> >  
> is this change expected in this patch ?
> 
> > diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/imx-bbu-internal.c
> > index 05aa5f1..cfde75d 100644
> > --- a/arch/arm/mach-imx/imx-bbu-internal.c
> > +++ b/arch/arm/mach-imx/imx-bbu-internal.c
> > @@ -15,7 +15,7 @@
> >   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> >   * GNU General Public License for more details.
> >   */
> > -
> > +#define DEBUG
> 
> same here.
> 
> >  #define IMX_INTERNAL_NAND_BBU
> >  
> >  #include <common.h>
> > diff --git a/drivers/mfd/mc34704.c b/drivers/mfd/mc34704.c
> > index 276b723..54d27c8 100644
> > --- a/drivers/mfd/mc34704.c
> > +++ b/drivers/mfd/mc34704.c
> > @@ -25,7 +25,7 @@
> >  #include <i2c/i2c.h>
> >  #include <mfd/mc34704.h>
> >  
> > -#define DRIVERNAME		"mc34704"
> > +#define DRIVERNAME		"da9053"
> >  
> >  #define to_mc34704(a)		container_of(a, struct mc34704, cdev)
> >  
> and here ;-)

Damn ;)

Will fix.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Thu Nov 29 02:49:13 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu, 29 Nov 2012 08:49:13 +0100
Subject: [PATCH v2] ARM i.MX: Add Garz+Fricke Vincell Board support
Message-ID: <1354175353-8717-1-git-send-email-s.hauer@pengutronix.de>

This adds support for the Garz+Fricke Vincell board. This has
a i.MX53 Processor with 512MB of DDR3 RAM.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---

changes since v1:

- remove hunks which shouldn't be there as noted by Eric

 arch/arm/Makefile                                  |    1 +
 arch/arm/boards/guf-vincell/Makefile               |    3 +
 arch/arm/boards/guf-vincell/board.c                |  323 ++++++++++++++++++++
 arch/arm/boards/guf-vincell/config.h               |   24 ++
 arch/arm/boards/guf-vincell/env/boot/nand-ubi      |   10 +
 arch/arm/boards/guf-vincell/env/init/bootargs-base |    8 +
 arch/arm/boards/guf-vincell/env/init/hostname      |    8 +
 arch/arm/boards/guf-vincell/env/init/mtdparts-nand |   11 +
 arch/arm/boards/guf-vincell/flash_header.c         |   41 +++
 arch/arm/boards/guf-vincell/lowlevel.c             |  164 ++++++++++
 arch/arm/configs/vincell_defconfig                 |   82 +++++
 arch/arm/mach-imx/Kconfig                          |    9 +
 12 files changed, 684 insertions(+)
 create mode 100644 arch/arm/boards/guf-vincell/Makefile
 create mode 100644 arch/arm/boards/guf-vincell/board.c
 create mode 100644 arch/arm/boards/guf-vincell/config.h
 create mode 100644 arch/arm/boards/guf-vincell/env/boot/nand-ubi
 create mode 100644 arch/arm/boards/guf-vincell/env/init/bootargs-base
 create mode 100644 arch/arm/boards/guf-vincell/env/init/hostname
 create mode 100644 arch/arm/boards/guf-vincell/env/init/mtdparts-nand
 create mode 100644 arch/arm/boards/guf-vincell/flash_header.c
 create mode 100644 arch/arm/boards/guf-vincell/lowlevel.c
 create mode 100644 arch/arm/configs/vincell_defconfig

diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index d911ffe..3bd645f 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -149,6 +149,7 @@ board-$(CONFIG_MACH_CCMX51)			:= ccxmx51
 board-$(CONFIG_MACH_TINY210)			:= friendlyarm-tiny210
 board-$(CONFIG_MACH_SABRELITE)			:= freescale-mx6-sabrelite
 board-$(CONFIG_MACH_TX53)			:= karo-tx53
+board-$(CONFIG_MACH_GUF_VINCELL)		:= guf-vincell
 
 machdirs := $(patsubst %,arch/arm/mach-%/,$(machine-y))
 
diff --git a/arch/arm/boards/guf-vincell/Makefile b/arch/arm/boards/guf-vincell/Makefile
new file mode 100644
index 0000000..8f4f978
--- /dev/null
+++ b/arch/arm/boards/guf-vincell/Makefile
@@ -0,0 +1,3 @@
+obj-y += board.o
+obj-y += flash_header.o lowlevel.o
+pbl-y += flash_header.o lowlevel.o
diff --git a/arch/arm/boards/guf-vincell/board.c b/arch/arm/boards/guf-vincell/board.c
new file mode 100644
index 0000000..bfc0456
--- /dev/null
+++ b/arch/arm/boards/guf-vincell/board.c
@@ -0,0 +1,323 @@
+/*
+ * Copyright (C) 2007 Sascha Hauer, Pengutronix
+ * Copyright (C) 2011 Marc Kleine-Budde <mkl at pengutronix.de>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <common.h>
+#include <environment.h>
+#include <fcntl.h>
+#include <fec.h>
+#include <fs.h>
+#include <init.h>
+#include <nand.h>
+#include <net.h>
+#include <partition.h>
+#include <sizes.h>
+#include <bbu.h>
+#include <gpio.h>
+#include <io.h>
+#include <i2c/i2c.h>
+
+#include <generated/mach-types.h>
+
+#include <mach/imx53-regs.h>
+#include <mach/iomux-mx53.h>
+#include <mach/devices-imx53.h>
+#include <mach/generic.h>
+#include <mach/imx-nand.h>
+#include <mach/iim.h>
+#include <mach/imx-nand.h>
+#include <mach/bbu.h>
+#include <mach/imx-flash-header.h>
+#include <mach/imx5.h>
+
+#include <asm/armlinux.h>
+#include <asm/mmu.h>
+
+static struct fec_platform_data fec_info = {
+	.xcv_type = RMII,
+};
+
+static iomux_v3_cfg_t vincell_pads[] = {
+	MX53_PAD_DISP0_DAT23__AUDMUX_AUD4_RXD,
+	MX53_PAD_DISP0_DAT20__AUDMUX_AUD4_TXC,
+	MX53_PAD_DISP0_DAT21__AUDMUX_AUD4_TXD,
+	MX53_PAD_DISP0_DAT22__AUDMUX_AUD4_TXFS,
+	MX53_PAD_GPIO_8__CAN1_RXCAN,
+	MX53_PAD_GPIO_7__CAN1_TXCAN,
+	MX53_PAD_KEY_ROW4__CAN2_RXCAN,
+	MX53_PAD_KEY_COL4__CAN2_TXCAN,
+	MX53_PAD_GPIO_3__CCM_CLKO2,
+	MX53_PAD_KEY_COL1__ECSPI1_MISO,
+	MX53_PAD_KEY_ROW0__ECSPI1_MOSI,
+	MX53_PAD_GPIO_19__ECSPI1_RDY,
+	MX53_PAD_KEY_COL0__ECSPI1_SCLK,
+	MX53_PAD_KEY_ROW1__GPIO4_9, /* ECSPI1_SS0 */
+	MX53_PAD_KEY_COL2__GPIO4_10, /* ECSPI1_SS1 */
+	MX53_PAD_KEY_ROW2__GPIO4_11, /* ECSPI1_SS2 */
+	MX53_PAD_KEY_COL3__GPIO4_12, /* ECSPI1_SS3 */
+	MX53_PAD_CSI0_DAT10__ECSPI2_MISO,
+	MX53_PAD_EIM_CS1__ECSPI2_MOSI,
+	MX53_PAD_EIM_A25__ECSPI2_RDY,
+	MX53_PAD_DISP0_DAT19__ECSPI2_SCLK,
+	MX53_PAD_DISP0_DAT18__GPIO5_12, /* ECSPI2_SS0 */
+	MX53_PAD_EIM_DA0__EMI_NAND_WEIM_DA_0,
+	MX53_PAD_EIM_DA1__EMI_NAND_WEIM_DA_1,
+	MX53_PAD_EIM_DA2__EMI_NAND_WEIM_DA_2,
+	MX53_PAD_EIM_DA3__EMI_NAND_WEIM_DA_3,
+	MX53_PAD_EIM_DA4__EMI_NAND_WEIM_DA_4,
+	MX53_PAD_EIM_DA5__EMI_NAND_WEIM_DA_5,
+	MX53_PAD_EIM_DA6__EMI_NAND_WEIM_DA_6,
+	MX53_PAD_EIM_DA7__EMI_NAND_WEIM_DA_7,
+	MX53_PAD_EIM_DA8__EMI_NAND_WEIM_DA_8,
+	MX53_PAD_EIM_DA9__EMI_NAND_WEIM_DA_9,
+	MX53_PAD_EIM_DA10__EMI_NAND_WEIM_DA_10,
+	MX53_PAD_EIM_DA11__EMI_NAND_WEIM_DA_11,
+	MX53_PAD_EIM_DA12__EMI_NAND_WEIM_DA_12,
+	MX53_PAD_EIM_DA13__EMI_NAND_WEIM_DA_13,
+	MX53_PAD_EIM_DA14__EMI_NAND_WEIM_DA_14,
+	MX53_PAD_EIM_DA15__EMI_NAND_WEIM_DA_15,
+	MX53_PAD_NANDF_ALE__EMI_NANDF_ALE,
+	MX53_PAD_NANDF_CLE__EMI_NANDF_CLE,
+	MX53_PAD_NANDF_CS0__EMI_NANDF_CS_0,
+	MX53_PAD_NANDF_CS1__EMI_NANDF_CS_1,
+	MX53_PAD_NANDF_CS2__EMI_NANDF_CS_2,
+	MX53_PAD_NANDF_CS3__EMI_NANDF_CS_3,
+	MX53_PAD_NANDF_RB0__EMI_NANDF_RB_0,
+	MX53_PAD_NANDF_RE_B__EMI_NANDF_RE_B,
+	MX53_PAD_NANDF_WE_B__EMI_NANDF_WE_B,
+	MX53_PAD_NANDF_WP_B__EMI_NANDF_WP_B,
+	MX53_PAD_EIM_A16__EMI_WEIM_A_16,
+	MX53_PAD_EIM_A17__EMI_WEIM_A_17,
+	MX53_PAD_EIM_A18__EMI_WEIM_A_18,
+	MX53_PAD_EIM_A19__EMI_WEIM_A_19,
+	MX53_PAD_EIM_A20__EMI_WEIM_A_20,
+	MX53_PAD_EIM_CS0__EMI_WEIM_CS_0,
+	MX53_PAD_EIM_D16__EMI_WEIM_D_16,
+	MX53_PAD_EIM_D17__EMI_WEIM_D_17,
+	MX53_PAD_EIM_D18__EMI_WEIM_D_18,
+	MX53_PAD_EIM_D19__EMI_WEIM_D_19,
+	MX53_PAD_EIM_D20__EMI_WEIM_D_20,
+	MX53_PAD_EIM_D21__EMI_WEIM_D_21,
+	MX53_PAD_EIM_D22__EMI_WEIM_D_22,
+	MX53_PAD_EIM_D23__EMI_WEIM_D_23,
+	MX53_PAD_EIM_D24__EMI_WEIM_D_24,
+	MX53_PAD_EIM_D25__EMI_WEIM_D_25,
+	MX53_PAD_EIM_D26__EMI_WEIM_D_26,
+	MX53_PAD_EIM_D27__EMI_WEIM_D_27,
+	MX53_PAD_EIM_D28__EMI_WEIM_D_28,
+	MX53_PAD_EIM_D29__EMI_WEIM_D_29,
+	MX53_PAD_EIM_D30__EMI_WEIM_D_30,
+	MX53_PAD_EIM_D31__EMI_WEIM_D_31,
+	MX53_PAD_EIM_EB0__EMI_WEIM_EB_0,
+	MX53_PAD_EIM_EB1__EMI_WEIM_EB_1,
+	MX53_PAD_EIM_OE__EMI_WEIM_OE,
+	MX53_PAD_EIM_RW__EMI_WEIM_RW,
+	MX53_PAD_SD1_CLK__ESDHC1_CLK,
+	MX53_PAD_SD1_CMD__ESDHC1_CMD,
+	MX53_PAD_SD1_DATA0__ESDHC1_DAT0,
+	MX53_PAD_SD1_DATA1__ESDHC1_DAT1,
+	MX53_PAD_SD1_DATA2__ESDHC1_DAT2,
+	MX53_PAD_SD1_DATA3__ESDHC1_DAT3,
+	MX53_PAD_DI0_PIN4__ESDHC1_WP,
+	MX53_PAD_FEC_MDC__FEC_MDC,
+	MX53_PAD_FEC_MDIO__FEC_MDIO,
+	MX53_PAD_FEC_RXD0__FEC_RDATA_0,
+	MX53_PAD_FEC_RXD1__FEC_RDATA_1,
+	MX53_PAD_FEC_CRS_DV__FEC_RX_DV,
+	MX53_PAD_FEC_RX_ER__FEC_RX_ER,
+	MX53_PAD_FEC_TXD0__FEC_TDATA_0,
+	MX53_PAD_FEC_TXD1__FEC_TDATA_1,
+	MX53_PAD_FEC_REF_CLK__FEC_TX_CLK,
+	MX53_PAD_FEC_TX_EN__FEC_TX_EN,
+	MX53_PAD_SD2_CLK__GPIO1_10,
+	MX53_PAD_SD2_DATA3__GPIO1_12,
+	MX53_PAD_GPIO_2__GPIO1_2,
+	MX53_PAD_GPIO_4__GPIO1_4,
+	MX53_PAD_PATA_DATA0__GPIO2_0,
+	MX53_PAD_PATA_DATA1__GPIO2_1,
+	MX53_PAD_PATA_DATA10__GPIO2_10,
+	MX53_PAD_PATA_DATA11__GPIO2_11,
+	MX53_PAD_PATA_DATA13__GPIO2_13,
+	MX53_PAD_PATA_DATA14__GPIO2_14,
+	MX53_PAD_PATA_DATA15__GPIO2_15,
+	MX53_PAD_PATA_DATA2__GPIO2_2,
+	MX53_PAD_PATA_DATA3__GPIO2_3,
+	MX53_PAD_EIM_EB2__GPIO2_30,
+	MX53_PAD_PATA_DATA4__PATA_DATA_4,
+	MX53_PAD_PATA_DATA5__GPIO2_5,
+	MX53_PAD_PATA_DATA6__GPIO2_6,
+	MX53_PAD_PATA_DATA7__GPIO2_7,
+	MX53_PAD_PATA_DATA8__GPIO2_8,
+	MX53_PAD_PATA_DATA9__GPIO2_9,
+	MX53_PAD_GPIO_10__GPIO4_0,
+	MX53_PAD_GPIO_11__GPIO4_1,
+	MX53_PAD_GPIO_12__GPIO4_2,
+	MX53_PAD_DISP0_DAT8__GPIO4_29,
+	MX53_PAD_GPIO_13__GPIO4_3,
+	MX53_PAD_DISP0_DAT16__GPIO5_10,
+	MX53_PAD_DISP0_DAT17__GPIO5_11,
+	MX53_PAD_CSI0_PIXCLK__GPIO5_18,
+	MX53_PAD_CSI0_MCLK__GPIO5_19,
+	MX53_PAD_CSI0_DATA_EN__GPIO5_20,
+	MX53_PAD_CSI0_VSYNC__GPIO5_21,
+	MX53_PAD_CSI0_DAT4__GPIO5_22,
+	MX53_PAD_CSI0_DAT5__GPIO5_23,
+	MX53_PAD_CSI0_DAT6__GPIO5_24,
+	MX53_PAD_DISP0_DAT14__GPIO5_8,
+	MX53_PAD_DISP0_DAT15__GPIO5_9,
+	MX53_PAD_PATA_DIOW__GPIO6_17,
+	MX53_PAD_PATA_DMACK__GPIO6_18,
+	MX53_PAD_GPIO_17__GPIO7_12,
+	MX53_PAD_GPIO_18__GPIO7_13,
+	MX53_PAD_PATA_RESET_B__GPIO7_4,
+	MX53_PAD_PATA_IORDY__GPIO7_5,
+	MX53_PAD_PATA_DA_0__GPIO7_6,
+	MX53_PAD_PATA_DA_2__GPIO7_8,
+	MX53_PAD_CSI0_DAT9__I2C1_SCL,
+	MX53_PAD_CSI0_DAT8__I2C1_SDA,
+	MX53_PAD_KEY_COL3__I2C2_SCL,
+	MX53_PAD_KEY_ROW3__I2C2_SDA,
+	MX53_PAD_GPIO_5__I2C3_SCL,
+	MX53_PAD_GPIO_6__I2C3_SDA,
+	MX53_PAD_KEY_COL0__KPP_COL_0,
+	MX53_PAD_KEY_COL1__KPP_COL_1,
+	MX53_PAD_KEY_COL2__KPP_COL_2,
+	MX53_PAD_KEY_COL3__KPP_COL_3,
+	MX53_PAD_GPIO_19__KPP_COL_5,
+	MX53_PAD_GPIO_9__KPP_COL_6,
+	MX53_PAD_SD2_DATA1__KPP_COL_7,
+	MX53_PAD_KEY_ROW0__KPP_ROW_0,
+	MX53_PAD_KEY_ROW1__KPP_ROW_1,
+	MX53_PAD_KEY_ROW2__KPP_ROW_2,
+	MX53_PAD_KEY_ROW3__KPP_ROW_3,
+	MX53_PAD_SD2_CMD__KPP_ROW_5,
+	MX53_PAD_SD2_DATA2__KPP_ROW_6,
+	MX53_PAD_SD2_DATA0__KPP_ROW_7,
+	MX53_PAD_LVDS0_CLK_P__LDB_LVDS0_CLK,
+	MX53_PAD_LVDS0_TX0_P__LDB_LVDS0_TX0,
+	MX53_PAD_LVDS0_TX1_P__LDB_LVDS0_TX1,
+	MX53_PAD_LVDS0_TX2_P__LDB_LVDS0_TX2,
+	MX53_PAD_LVDS0_TX3_P__LDB_LVDS0_TX3,
+	MX53_PAD_DISP0_DAT8__PWM1_PWMO,
+	MX53_PAD_DISP0_DAT9__PWM2_PWMO,
+	MX53_PAD_PATA_INTRQ__UART2_CTS,
+	MX53_PAD_PATA_DIOR__UART2_RTS,
+	MX53_PAD_PATA_BUFFER_EN__UART2_RXD_MUX,
+	MX53_PAD_PATA_DMARQ__UART2_TXD_MUX,
+	MX53_PAD_PATA_DA_1__UART3_CTS,
+	MX53_PAD_PATA_CS_1__UART3_RXD_MUX,
+	MX53_PAD_PATA_CS_0__UART3_TXD_MUX,
+	MX53_PAD_CSI0_DAT17__UART4_CTS,
+	MX53_PAD_CSI0_DAT16__UART4_RTS,
+	MX53_PAD_CSI0_DAT13__UART4_RXD_MUX,
+	MX53_PAD_CSI0_DAT12__UART4_TXD_MUX,
+	MX53_PAD_CSI0_DAT19__UART5_CTS,
+	MX53_PAD_CSI0_DAT18__UART5_RTS,
+	MX53_PAD_CSI0_DAT15__UART5_RXD_MUX,
+	MX53_PAD_CSI0_DAT14__UART5_TXD_MUX,
+	MX53_PAD_GPIO_0__USBOH3_USBH1_PWR,
+	MX53_PAD_DISP0_DAT12__USBOH3_USBH2_CLK,
+	MX53_PAD_DISP0_DAT0__USBOH3_USBH2_DATA_0,
+	MX53_PAD_DISP0_DAT1__USBOH3_USBH2_DATA_1,
+	MX53_PAD_DISP0_DAT2__USBOH3_USBH2_DATA_2,
+	MX53_PAD_DISP0_DAT3__USBOH3_USBH2_DATA_3,
+	MX53_PAD_DISP0_DAT4__USBOH3_USBH2_DATA_4,
+	MX53_PAD_DISP0_DAT5__USBOH3_USBH2_DATA_5,
+	MX53_PAD_DISP0_DAT6__USBOH3_USBH2_DATA_6,
+	MX53_PAD_DISP0_DAT7__USBOH3_USBH2_DATA_7,
+	MX53_PAD_DI0_DISP_CLK__USBOH3_USBH2_DIR,
+	MX53_PAD_DISP0_DAT11__USBOH3_USBH2_NXT,
+	MX53_PAD_DISP0_DAT10__USBOH3_USBH2_STP,
+	MX53_PAD_GPIO_1__WDOG2_WDOG_B,
+};
+
+#define LOCO_FEC_PHY_RST		IMX_GPIO_NR(7, 6)
+
+static void vincell_fec_reset(void)
+{
+	gpio_direction_output(LOCO_FEC_PHY_RST, 0);
+	mdelay(1);
+	gpio_set_value(LOCO_FEC_PHY_RST, 1);
+}
+
+static struct imx_nand_platform_data nand_info = {
+	.width		= 1,
+	.hw_ecc		= 1,
+	.flash_bbt	= 1,
+};
+
+static struct imx_dcd_v2_entry __dcd_entry_section dcd_entry[] = {
+};
+
+static struct i2c_board_info i2c_devices[] = {
+	{
+		I2C_BOARD_INFO("da9053", 0x48),
+	},
+};
+
+#include <linux/clk.h>
+
+static int vincell_devices_init(void)
+{
+	writel(0, MX53_M4IF_BASE_ADDR + 0xc);
+
+	console_flush();
+	imx53_init_lowlevel(1000);
+	clk_set_rate(clk_lookup("nfc_podf"), 66666667);
+
+	imx53_add_nand(&nand_info);
+	imx51_iim_register_fec_ethaddr();
+	imx53_add_fec(&fec_info);
+	imx53_add_mmc0(NULL);
+	i2c_register_board_info(0, i2c_devices, ARRAY_SIZE(i2c_devices));
+	imx53_add_i2c0(NULL);
+
+	vincell_fec_reset();
+
+	armlinux_set_bootparams((void *)0x70000100);
+	armlinux_set_architecture(3297);
+
+	devfs_add_partition("nand0", SZ_1M, SZ_512K, DEVFS_PARTITION_FIXED, "self_raw");
+	dev_add_bb_dev("self_raw", "self0");
+	devfs_add_partition("nand0", SZ_1M + SZ_512K, SZ_512K, DEVFS_PARTITION_FIXED, "env_raw");
+	dev_add_bb_dev("env_raw", "env0");
+
+	imx53_bbu_internal_nand_register_handler("nand",
+		BBU_HANDLER_FLAG_DEFAULT, dcd_entry, sizeof(dcd_entry), 3 * SZ_128K, 0xf8020000);
+
+	return 0;
+}
+
+device_initcall(vincell_devices_init);
+
+static int vincell_part_init(void)
+{
+	devfs_add_partition("disk0", 0x00000, 0x80000, DEVFS_PARTITION_FIXED, "self0");
+	devfs_add_partition("disk0", 0x80000, 0x80000, DEVFS_PARTITION_FIXED, "env0");
+
+	return 0;
+}
+late_initcall(vincell_part_init);
+
+static int vincell_console_init(void)
+{
+	mxc_iomux_v3_setup_multiple_pads(vincell_pads, ARRAY_SIZE(vincell_pads));
+
+	imx53_add_uart1();
+
+	return 0;
+}
+
+console_initcall(vincell_console_init);
diff --git a/arch/arm/boards/guf-vincell/config.h b/arch/arm/boards/guf-vincell/config.h
new file mode 100644
index 0000000..b7effe5
--- /dev/null
+++ b/arch/arm/boards/guf-vincell/config.h
@@ -0,0 +1,24 @@
+/**
+ * @file
+ * @brief Global defintions for the ARM i.MX51 based babbage board
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+#endif	/* __CONFIG_H */
diff --git a/arch/arm/boards/guf-vincell/env/boot/nand-ubi b/arch/arm/boards/guf-vincell/env/boot/nand-ubi
new file mode 100644
index 0000000..a3f748e
--- /dev/null
+++ b/arch/arm/boards/guf-vincell/env/boot/nand-ubi
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+	boot-menu-add-entry "$0" "nand (UBI)"
+	exit
+fi
+
+global.bootm.image="/dev/nand0.kernel.bb"
+#global.bootm.oftree="/env/oftree"
+bootargs-root-ubi -r root -m nand0.root
diff --git a/arch/arm/boards/guf-vincell/env/init/bootargs-base b/arch/arm/boards/guf-vincell/env/init/bootargs-base
new file mode 100644
index 0000000..d869754
--- /dev/null
+++ b/arch/arm/boards/guf-vincell/env/init/bootargs-base
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+	init-menu-add-entry "$0" "Base bootargs"
+	exit
+fi
+
+global.linux.bootargs.base="console=ttymxc0,115200"
diff --git a/arch/arm/boards/guf-vincell/env/init/hostname b/arch/arm/boards/guf-vincell/env/init/hostname
new file mode 100644
index 0000000..ca2789d
--- /dev/null
+++ b/arch/arm/boards/guf-vincell/env/init/hostname
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+	init-menu-add-entry "$0" "hostname"
+	exit
+fi
+
+global.hostname=vincell
diff --git a/arch/arm/boards/guf-vincell/env/init/mtdparts-nand b/arch/arm/boards/guf-vincell/env/init/mtdparts-nand
new file mode 100644
index 0000000..4fffefc
--- /dev/null
+++ b/arch/arm/boards/guf-vincell/env/init/mtdparts-nand
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+	init-menu-add-entry "$0" "NAND partitions"
+	exit
+fi
+
+mtdparts="512k(nand0.barebox)ro,512k(nand0.bareboxenv),4M(nand0.kernel),-(nand0.root)"
+kernelname="mxc_nand"
+
+mtdparts-add -b -d nand0 -k ${kernelname} -p ${mtdparts}
diff --git a/arch/arm/boards/guf-vincell/flash_header.c b/arch/arm/boards/guf-vincell/flash_header.c
new file mode 100644
index 0000000..df480d2
--- /dev/null
+++ b/arch/arm/boards/guf-vincell/flash_header.c
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2011 Marc Kleine-Budde <mkl at pengutronix.de>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <common.h>
+#include <sizes.h>
+#include <asm/byteorder.h>
+#include <asm/barebox-arm-head.h>
+#include <mach/imx-flash-header.h>
+
+void __naked __flash_header_start go(void)
+{
+	barebox_arm_head();
+}
+
+#define APP_DEST	0xf8020000
+
+struct imx_flash_header_v2 __flash_header_section flash_header = {
+	.header.tag		= IVT_HEADER_TAG,
+	.header.length		= cpu_to_be16(32),
+	.header.version		= IVT_VERSION,
+
+	.entry			= APP_DEST + 0x1000,
+	.dcd_ptr		= APP_DEST + 0x400 + offsetof(struct imx_flash_header_v2, dcd),
+	.boot_data_ptr		= APP_DEST + 0x400 + offsetof(struct imx_flash_header_v2, boot_data),
+	.self			= APP_DEST + 0x400,
+
+	.boot_data.start	= APP_DEST,
+	.boot_data.size		= DCD_BAREBOX_SIZE,
+};
diff --git a/arch/arm/boards/guf-vincell/lowlevel.c b/arch/arm/boards/guf-vincell/lowlevel.c
new file mode 100644
index 0000000..2541117
--- /dev/null
+++ b/arch/arm/boards/guf-vincell/lowlevel.c
@@ -0,0 +1,164 @@
+#include <common.h>
+#include <io.h>
+#include <init.h>
+#include <mach/imx53-regs.h>
+#include <mach/imx5.h>
+#include <mach/iomux-v3.h>
+#include <mach/esdctl-v4.h>
+#include <asm/barebox-arm.h>
+#include <asm/barebox-arm-head.h>
+#include <io.h>
+
+void blink(void)
+{
+	volatile int i;
+
+	writel(0x1, 0x53fa82a8);
+	writel(0x2, 0x53f88004);
+
+	while (1) {
+		for (i = 0; i < 1000000; i++);
+		writel(0x2, 0x53f88000);
+		for (i = 0; i < 1000000; i++);
+		writel(0x0, 0x53f88000);
+	}
+}
+
+#define IOMUX_PADCTL_DDRI_DDR (1 << 9)
+
+#define IOMUX_PADCTL_DDRDSE(x)	((x) << 19)
+#define IOMUX_PADCTL_DDRSEL(x)	((x) << 25)
+
+#define IOMUXC_SW_PAD_CTL_PAD_DRAM_DQM3		0x554
+#define IOMUXC_SW_PAD_CTL_PAD_DRAM_SDQS3	0x558
+#define IOMUXC_SW_PAD_CTL_PAD_DRAM_DQM2		0x560
+#define IOMUXC_SW_PAD_CTL_PAD_DRAM_SDODT1	0x564
+#define IOMUXC_SW_PAD_CTL_PAD_DRAM_SDQS2	0x568
+#define IOMUXC_SW_PAD_CTL_PAD_DRAM_SDCLK_1	0x570
+#define IOMUXC_SW_PAD_CTL_PAD_DRAM_CAS		0x574
+#define IOMUXC_SW_PAD_CTL_PAD_DRAM_SDCLK_0	0x578
+#define IOMUXC_SW_PAD_CTL_PAD_DRAM_SDQS0	0x57c
+#define IOMUXC_SW_PAD_CTL_PAD_DRAM_SDODT0	0x580
+#define IOMUXC_SW_PAD_CTL_PAD_DRAM_RAS		0x588
+#define IOMUXC_SW_PAD_CTL_PAD_DRAM_SDQS1	0x590
+#define IOMUXC_SW_PAD_CTL_PAD_DRAM_DQM1		0x594
+#define IOMUXC_SW_PAD_CTL_PAD_DRAM_DQM0		0x584
+#define IOMUXC_SW_PAD_CTL_GRP_ADDDS		0x6f0
+#define IOMUXC_SW_PAD_CTL_GRP_DDRMODE_CTL	0x6f4
+#define IOMUXC_SW_PAD_CTL_GRP_DDRPKE		0x6fc
+#define IOMUXC_SW_PAD_CTL_GRP_DDRHYS		0x710
+#define IOMUXC_SW_PAD_CTL_GRP_DDRMODE		0x714
+#define IOMUXC_SW_PAD_CTL_GRP_B0DS		0x718
+#define IOMUXC_SW_PAD_CTL_GRP_B1DS		0x71c
+#define IOMUXC_SW_PAD_CTL_GRP_CTLDS		0x720
+#define IOMUXC_SW_PAD_CTL_GRP_DDR_TYPE		0x724
+#define IOMUXC_SW_PAD_CTL_GRP_B2DS		0x728
+#define IOMUXC_SW_PAD_CTL_GRP_B3DS		0x72c
+
+
+static void configure_dram_iomux(void)
+{
+	void __iomem *iomux = (void *)MX53_IOMUXC_BASE_ADDR;
+	u32 r1, r2, r4, r5, r6;
+
+	/* define the INPUT mode for DRAM_D[31:0] */
+	writel(0, iomux + IOMUXC_SW_PAD_CTL_GRP_DDRMODE);
+
+	/*
+	 * define the INPUT mode for SDQS[3:0]
+	 * (Freescale's documentation suggests DDR-mode for the
+	 * control line, but their source actually uses CMOS)
+	 */
+	writel(IOMUX_PADCTL_DDRI_DDR, iomux + IOMUXC_SW_PAD_CTL_GRP_DDRMODE_CTL);
+
+	r1 = IOMUX_PADCTL_DDRDSE(5);
+	r2 = IOMUX_PADCTL_DDRDSE(5) | PAD_CTL_PUE;
+	r4 = IOMUX_PADCTL_DDRSEL(2);
+	r5 = IOMUX_PADCTL_DDRDSE(5) | PAD_CTL_PKE | PAD_CTL_PUE | IOMUX_PADCTL_DDRI_DDR | PAD_CTL_PUS_47K_UP;
+	r6 = IOMUX_PADCTL_DDRDSE(4);
+
+	/*
+	 * this will adisable the Pull/Keeper for DRAM_x pins EXCEPT,
+	 * for DRAM_SDQS[3:0] and DRAM_SDODT[1:0]
+	 */
+	writel(0, iomux + IOMUXC_SW_PAD_CTL_GRP_DDRPKE);
+
+	/* set global drive strength for all DRAM_x pins */
+	writel(r4, iomux + IOMUXC_SW_PAD_CTL_GRP_DDR_TYPE);
+
+	/* set data dqs dqm drive strength */
+	writel(r6, iomux + IOMUXC_SW_PAD_CTL_GRP_B0DS);
+	writel(r6, iomux + IOMUXC_SW_PAD_CTL_PAD_DRAM_DQM0);
+	writel(r5, iomux + IOMUXC_SW_PAD_CTL_PAD_DRAM_SDQS0);
+
+	writel(r1, iomux + IOMUXC_SW_PAD_CTL_GRP_B1DS);
+	writel(r1, iomux + IOMUXC_SW_PAD_CTL_PAD_DRAM_DQM1);
+	writel(r5, iomux + IOMUXC_SW_PAD_CTL_PAD_DRAM_SDQS1);
+
+	writel(r6, iomux + IOMUXC_SW_PAD_CTL_GRP_B2DS);
+	writel(r6, iomux + IOMUXC_SW_PAD_CTL_PAD_DRAM_DQM2);
+	writel(r5, iomux + IOMUXC_SW_PAD_CTL_PAD_DRAM_SDQS2);
+
+	writel(r1, iomux + IOMUXC_SW_PAD_CTL_GRP_B3DS);
+	writel(r1, iomux + IOMUXC_SW_PAD_CTL_PAD_DRAM_DQM3);
+	writel(r5, iomux + IOMUXC_SW_PAD_CTL_PAD_DRAM_SDQS3);
+
+	/* SDCLK pad drive strength control options */
+	writel(r1, iomux + IOMUXC_SW_PAD_CTL_PAD_DRAM_SDCLK_0);
+	writel(r1, iomux + IOMUXC_SW_PAD_CTL_PAD_DRAM_SDCLK_1);
+
+	/* Control and addr bus pad drive strength control options */
+	writel(r1, iomux + IOMUXC_SW_PAD_CTL_PAD_DRAM_RAS);
+	writel(r1, iomux + IOMUXC_SW_PAD_CTL_PAD_DRAM_CAS);
+	writel(r1, iomux + IOMUXC_SW_PAD_CTL_GRP_ADDDS);
+	writel(r1, iomux + IOMUXC_SW_PAD_CTL_GRP_CTLDS);
+	writel(r2, iomux + IOMUXC_SW_PAD_CTL_PAD_DRAM_SDODT0);
+	writel(r2, iomux + IOMUXC_SW_PAD_CTL_PAD_DRAM_SDODT1);
+
+	/*
+	 * enable hysteresis on input pins
+	 * (Freescale's documentation suggests that enable hysteresis
+	 * would be better, but their source-code doesn't)
+	 */
+	writel(PAD_CTL_HYS, iomux + IOMUXC_SW_PAD_CTL_GRP_DDRHYS);
+}
+
+void disable_watchdog(void)
+{
+	/*
+	 * configure WDOG to generate external reset on trigger
+	 * and disable power down counter
+	 */
+	writew(0x38, MX53_WDOG1_BASE_ADDR);
+	writew(0x0, MX53_WDOG1_BASE_ADDR + 8);
+	writew(0x38, MX53_WDOG2_BASE_ADDR);
+	writew(0x0, MX53_WDOG2_BASE_ADDR + 8);
+}
+
+void sdram_init(void);
+
+void __bare_init __naked reset(void)
+{
+	u32 r;
+
+	common_reset();
+
+	/* Skip SDRAM initialization if we run from RAM */
+	r = get_pc();
+	if (r > 0x70000000 && r < 0xf0000000)
+		board_init_lowlevel_return();
+
+	/* Setup a preliminary stack */
+	r = 0xf8000000 + 0x60000 - 16;
+	__asm__ __volatile__("mov sp, %0" : : "r"(r));
+
+	disable_watchdog();
+
+	configure_dram_iomux();
+
+	imx5_init_lowlevel();
+
+	imx_esdctlv4_init();
+
+	board_init_lowlevel_return();
+}
diff --git a/arch/arm/configs/vincell_defconfig b/arch/arm/configs/vincell_defconfig
new file mode 100644
index 0000000..ac1f877
--- /dev/null
+++ b/arch/arm/configs/vincell_defconfig
@@ -0,0 +1,82 @@
+CONFIG_ARCH_IMX=y
+CONFIG_ARCH_IMX53=y
+CONFIG_MACH_GUF_VINCELL=y
+CONFIG_IMX_IIM=y
+CONFIG_IMX_IIM_FUSE_BLOW=y
+CONFIG_THUMB2_BAREBOX=y
+CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y
+CONFIG_ARM_UNWIND=y
+CONFIG_PBL_IMAGE=y
+CONFIG_MMU=y
+CONFIG_TEXT_BASE=0x7fe00000
+CONFIG_MALLOC_SIZE=0x2000000
+CONFIG_MALLOC_TLSF=y
+CONFIG_KALLSYMS=y
+CONFIG_LONGHELP=y
+CONFIG_HUSH_FANCY_PROMPT=y
+CONFIG_CMDLINE_EDITING=y
+CONFIG_AUTO_COMPLETE=y
+CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y
+CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/arm/boards/guf-vincell/env"
+CONFIG_DEBUG_INFO=y
+CONFIG_CMD_EDIT=y
+CONFIG_CMD_SLEEP=y
+CONFIG_CMD_MSLEEP=y
+CONFIG_CMD_SAVEENV=y
+CONFIG_CMD_EXPORT=y
+CONFIG_CMD_PRINTENV=y
+CONFIG_CMD_READLINE=y
+CONFIG_CMD_TIME=y
+CONFIG_CMD_DIRNAME=y
+CONFIG_CMD_LN=y
+CONFIG_CMD_READLINK=y
+CONFIG_CMD_TFTP=y
+CONFIG_CMD_FILETYPE=y
+CONFIG_CMD_ECHO_E=y
+CONFIG_CMD_MEMINFO=y
+CONFIG_CMD_IOMEM=y
+CONFIG_CMD_CRC=y
+CONFIG_CMD_CRC_CMP=y
+CONFIG_CMD_MD5SUM=y
+CONFIG_CMD_FLASH=y
+CONFIG_CMD_BOOTM_SHOW_TYPE=y
+CONFIG_CMD_BOOTM_VERBOSE=y
+CONFIG_CMD_BOOTM_INITRD=y
+CONFIG_CMD_BOOTM_OFTREE=y
+# CONFIG_CMD_BOOTU is not set
+CONFIG_CMD_RESET=y
+CONFIG_CMD_GO=y
+CONFIG_CMD_OFTREE=y
+CONFIG_CMD_BAREBOX_UPDATE=y
+CONFIG_CMD_TIMEOUT=y
+CONFIG_CMD_PARTITION=y
+CONFIG_CMD_MAGICVAR=y
+CONFIG_CMD_MAGICVAR_HELP=y
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_UNCOMPRESS=y
+CONFIG_CMD_MIITOOL=y
+CONFIG_CMD_CLK=y
+CONFIG_NET=y
+CONFIG_NET_DHCP=y
+CONFIG_NET_NFS=y
+CONFIG_NET_PING=y
+CONFIG_NET_RESOLV=y
+CONFIG_DRIVER_NET_FEC_IMX=y
+# CONFIG_SPI is not set
+CONFIG_I2C=y
+CONFIG_I2C_IMX=y
+CONFIG_MTD=y
+CONFIG_MTD_RAW_DEVICE=y
+CONFIG_NAND=y
+# CONFIG_NAND_ECC_SOFT is not set
+# CONFIG_NAND_ECC_HW_SYNDROME is not set
+# CONFIG_NAND_ECC_HW_NONE is not set
+CONFIG_NAND_IMX=y
+CONFIG_MCI=y
+CONFIG_MCI_STARTUP=y
+CONFIG_MCI_IMX_ESDHC=y
+CONFIG_FS_TFTP=y
+CONFIG_FS_NFS=y
+CONFIG_FS_FAT=y
+CONFIG_FS_FAT_WRITE=y
+CONFIG_FS_FAT_LFN=y
diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index 548b107..1bc2e24 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -28,6 +28,7 @@ config ARCH_TEXT_BASE
 	default 0x97f00000 if MACH_CCMX51
 	default 0x4fc00000 if MACH_SABRELITE
 	default 0x8fe00000 if MACH_TX53
+	default 0x7fc00000 if MACH_GUF_VINCELL
 
 config BOARDINFO
 	default "Eukrea CPUIMX25" if MACH_EUKREA_CPUIMX25
@@ -55,6 +56,7 @@ config BOARDINFO
 	default "ConnectCore i.MX51" if MACH_CCMX51
 	default "Sabre Lite" if MACH_SABRELITE
 	default "Ka-Ro tx53" if MACH_TX53
+	default "Garz+Fricke Vincell" if MACH_GUF_VINCELL
 
 choice
 	prompt "Select boot mode"
@@ -469,6 +471,11 @@ config MACH_TX53
 	help
 	  Say Y here if you are using the Ka-Ro tx53 board
 
+config MACH_GUF_VINCELL
+	select HAVE_DEFAULT_ENVIRONMENT_NEW
+	select MACH_HAS_LOWLEVEL_INIT
+	bool "Garz-Fricke Vincell"
+
 endchoice
 
 if MACH_TX53
@@ -478,7 +485,9 @@ config TX53_REV_1011
 	bool "1011"
 config TX53_REV_XX30
 	bool "8030 / 1030"
+
 endchoice
+
 endif
 
 endif
-- 
1.7.10.4



From baruch at tkos.co.il  Thu Nov 29 02:56:21 2012
From: baruch at tkos.co.il (Baruch Siach)
Date: Thu, 29 Nov 2012 09:56:21 +0200
Subject: [PATCH v2] ARM i.MX: Add Garz+Fricke Vincell Board support
In-Reply-To: <1354175353-8717-1-git-send-email-s.hauer@pengutronix.de>
References: <1354175353-8717-1-git-send-email-s.hauer@pengutronix.de>
Message-ID: <20121129075621.GC12054@sapphire.tkos.co.il>

Hi Sascha,

On Thu, Nov 29, 2012 at 08:49:13AM +0100, Sascha Hauer wrote:
> This adds support for the Garz+Fricke Vincell board. This has
> a i.MX53 Processor with 512MB of DDR3 RAM.
> 
> Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>

[...]

> +void blink(void)
> +{
> +	volatile int i;
> +
> +	writel(0x1, 0x53fa82a8);
> +	writel(0x2, 0x53f88004);
> +
> +	while (1) {
> +		for (i = 0; i < 1000000; i++);
> +		writel(0x2, 0x53f88000);
> +		for (i = 0; i < 1000000; i++);
> +		writel(0x0, 0x53f88000);
> +	}
> +}

Static? Is it a debugging aid? It's not used int this patch.

baruch

-- 
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -


From s.hauer at pengutronix.de  Thu Nov 29 13:43:34 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu, 29 Nov 2012 19:43:34 +0100
Subject: [PATCH v2] ARM i.MX: Add Garz+Fricke Vincell Board support
In-Reply-To: <20121129075621.GC12054@sapphire.tkos.co.il>
References: <1354175353-8717-1-git-send-email-s.hauer@pengutronix.de>
 <20121129075621.GC12054@sapphire.tkos.co.il>
Message-ID: <20121129184333.GR10369@pengutronix.de>

On Thu, Nov 29, 2012 at 09:56:21AM +0200, Baruch Siach wrote:
> Hi Sascha,
> 
> On Thu, Nov 29, 2012 at 08:49:13AM +0100, Sascha Hauer wrote:
> > This adds support for the Garz+Fricke Vincell board. This has
> > a i.MX53 Processor with 512MB of DDR3 RAM.
> > 
> > Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
> 
> [...]
> 
> > +void blink(void)
> > +{
> > +	volatile int i;
> > +
> > +	writel(0x1, 0x53fa82a8);
> > +	writel(0x2, 0x53f88004);
> > +
> > +	while (1) {
> > +		for (i = 0; i < 1000000; i++);
> > +		writel(0x2, 0x53f88000);
> > +		for (i = 0; i < 1000000; i++);
> > +		writel(0x0, 0x53f88000);
> > +	}
> > +}
> 
> Static? Is it a debugging aid? It's not used int this patch.

Seems I had a hard time debugging this hardware ;)

Removed before applying.

Thanks
 Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Thu Nov 29 14:00:30 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu, 29 Nov 2012 20:00:30 +0100
Subject: [PATCH] i2c: Add missing DEVICE_ID_DYNAMIC
Message-ID: <1354215630-24809-1-git-send-email-s.hauer@pengutronix.de>

Otherwise it's not possible to register multiple identical devices.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/i2c/i2c.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/i2c/i2c.c b/drivers/i2c/i2c.c
index 94f23dd..07eace9 100644
--- a/drivers/i2c/i2c.c
+++ b/drivers/i2c/i2c.c
@@ -252,6 +252,7 @@ struct i2c_client *i2c_new_device(struct i2c_adapter *adapter,
 	strcpy(client->dev.name, chip->type);
 	client->dev.type_data = client;
 	client->dev.platform_data = chip->platform_data;
+	client->dev.id = DEVICE_ID_DYNAMIC;
 	client->dev.bus = &i2c_bus;
 	client->adapter = adapter;
 	client->addr = chip->addr;
-- 
1.7.10.4



From s.hauer at pengutronix.de  Thu Nov 29 14:01:21 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu, 29 Nov 2012 20:01:21 +0100
Subject: [PATCH 1/4] barebox update: fix finding default handler
Message-ID: <1354215684-25235-1-git-send-email-s.hauer@pengutronix.de>

It was not possible to register another handler when already
a default handler is registered. Fix this.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 common/bbu.c |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/common/bbu.c b/common/bbu.c
index 92f8d2b..e31f645 100644
--- a/common/bbu.c
+++ b/common/bbu.c
@@ -71,13 +71,13 @@ int bbu_confirm(struct bbu_data *data)
 	return -EINTR;
 }
 
-static struct bbu_handler *bbu_find_handler(const char *name, unsigned long flags)
+static struct bbu_handler *bbu_find_handler(const char *name)
 {
 	struct bbu_handler *handler;
 
 	list_for_each_entry(handler, &bbu_image_handlers, list) {
 		if (!name) {
-			if (flags & BBU_HANDLER_FLAG_DEFAULT)
+			if (handler->flags & BBU_HANDLER_FLAG_DEFAULT)
 				return handler;
 			continue;
 		}
@@ -97,10 +97,13 @@ int barebox_update(struct bbu_data *data)
 	struct bbu_handler *handler;
 	int ret;
 
-	handler = bbu_find_handler(data->handler_name, data->flags);
+	handler = bbu_find_handler(data->handler_name);
 	if (!handler)
 		return -ENODEV;
 
+	if (!data->handler_name)
+		data->handler_name = handler->name;
+
 	if (!data->devicefile)
 		data->devicefile = handler->devicefile;
 
@@ -137,11 +140,11 @@ void bbu_handlers_list(void)
  */
 int bbu_register_handler(struct bbu_handler *handler)
 {
-	if (bbu_find_handler(handler->name, 0))
+	if (bbu_find_handler(handler->name))
 		return -EBUSY;
 
 	if (handler->flags & BBU_HANDLER_FLAG_DEFAULT &&
-			bbu_find_handler(NULL, BBU_HANDLER_FLAG_DEFAULT))
+			bbu_find_handler(NULL))
 		return -EBUSY;
 
 	list_add_tail(&handler->list, &bbu_image_handlers);
-- 
1.7.10.4



From s.hauer at pengutronix.de  Thu Nov 29 14:01:24 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu, 29 Nov 2012 20:01:24 +0100
Subject: [PATCH 4/4] ARM i.MX6: save boot location
In-Reply-To: <1354215684-25235-1-git-send-email-s.hauer@pengutronix.de>
References: <1354215684-25235-1-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1354215684-25235-4-git-send-email-s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/arm/mach-imx/boot.c                 |   60 ++++++++++++++++++++++++++++++
 arch/arm/mach-imx/imx6.c                 |    3 ++
 arch/arm/mach-imx/include/mach/generic.h |    1 +
 3 files changed, 64 insertions(+)

diff --git a/arch/arm/mach-imx/boot.c b/arch/arm/mach-imx/boot.c
index ae7c48b..8c7f8ee 100644
--- a/arch/arm/mach-imx/boot.c
+++ b/arch/arm/mach-imx/boot.c
@@ -218,3 +218,63 @@ int imx53_boot_save_loc(void __iomem *src_base)
 
 	return 0;
 }
+
+#define IMX6_SRC_SBMR1	0x04
+#define IMX6_SRC_SBMR2	0x1c
+
+int imx6_boot_save_loc(void __iomem *src_base)
+{
+	enum imx_bootsource src = bootsource_unknown;
+	uint32_t sbmr2 = readl(src_base + IMX6_SRC_SBMR2) >> 24;
+	uint32_t cfg1 = readl(src_base + IMX6_SRC_SBMR1) & 0xff;
+	uint32_t boot_cfg_4_2_0;
+	int boot_mode;
+
+	boot_mode = (sbmr2 >> 24) & 0x3;
+
+	switch (boot_mode) {
+	case 0: /* Fuses, fall through */
+	case 2: /* internal boot */
+		goto internal_boot;
+	case 1: /* Serial Downloader */
+		src = bootsource_serial;
+		break;
+	case 3: /* reserved */
+		break;
+	};
+
+	imx_set_bootsource(src);
+
+	return 0;
+
+internal_boot:
+
+	switch (cfg1 >> 4) {
+	case 2:
+		src = bootsource_hd;
+		break;
+	case 3:
+		boot_cfg_4_2_0 = (cfg1 >> 16) & 0x7;
+
+		if (boot_cfg_4_2_0 > 4)
+			src = bootsource_i2c;
+		else
+			src = bootsource_spi;
+		break;
+	case 4:
+	case 5:
+	case 6:
+	case 7:
+		src = bootsource_mmc;
+		break;
+	default:
+		break;
+	}
+
+	if (cfg1 & (1 << 7))
+		src = bootsource_nand;
+
+	imx_set_bootsource(src);
+
+	return 0;
+}
diff --git a/arch/arm/mach-imx/imx6.c b/arch/arm/mach-imx/imx6.c
index c9eec5a..37ee5d8 100644
--- a/arch/arm/mach-imx/imx6.c
+++ b/arch/arm/mach-imx/imx6.c
@@ -15,6 +15,7 @@
 #include <common.h>
 #include <io.h>
 #include <sizes.h>
+#include <mach/generic.h>
 #include <mach/imx6-regs.h>
 
 void imx6_init_lowlevel(void)
@@ -54,6 +55,8 @@ void imx6_init_lowlevel(void)
 
 static int imx6_init(void)
 {
+	imx6_boot_save_loc((void *)MX6_SRC_BASE_ADDR);
+
 	add_generic_device("imx-iomuxv3", 0, NULL, MX6_IOMUXC_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
 	add_generic_device("imx6-ccm", 0, NULL, MX6_CCM_BASE_ADDR, 0x4000, IORESOURCE_MEM, NULL);
 	add_generic_device("imx31-gpt", 0, NULL, 0x02098000, 0x1000, IORESOURCE_MEM, NULL);
diff --git a/arch/arm/mach-imx/include/mach/generic.h b/arch/arm/mach-imx/include/mach/generic.h
index 39bb7e3..5e600a3 100644
--- a/arch/arm/mach-imx/include/mach/generic.h
+++ b/arch/arm/mach-imx/include/mach/generic.h
@@ -20,6 +20,7 @@ int imx_25_35_boot_save_loc(unsigned int ctrl, unsigned int type);
 void imx_27_boot_save_loc(void __iomem *sysctrl_base);
 int imx51_boot_save_loc(void __iomem *src_base);
 int imx53_boot_save_loc(void __iomem *src_base);
+int imx6_boot_save_loc(void __iomem *src_base);
 
 /* There's a off-by-one betweem the gpio bank number and the gpiochip */
 /* range e.g. GPIO_1_5 is gpio 5 under linux */
-- 
1.7.10.4



From s.hauer at pengutronix.de  Thu Nov 29 14:01:23 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu, 29 Nov 2012 20:01:23 +0100
Subject: [PATCH 3/4] ARM i.MX bbu internal: Add spi/i2c support
In-Reply-To: <1354215684-25235-1-git-send-email-s.hauer@pengutronix.de>
References: <1354215684-25235-1-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1354215684-25235-3-git-send-email-s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/arm/mach-imx/imx-bbu-internal.c |   54 ++++++++++++++++++++++++++++++++++
 arch/arm/mach-imx/include/mach/bbu.h |   22 ++++++++++++++
 2 files changed, 76 insertions(+)

diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/imx-bbu-internal.c
index 029bd5b..f36081c 100644
--- a/arch/arm/mach-imx/imx-bbu-internal.c
+++ b/arch/arm/mach-imx/imx-bbu-internal.c
@@ -36,6 +36,7 @@
 
 #define IMX_INTERNAL_FLAG_NAND		(1 << 0)
 #define IMX_INTERNAL_FLAG_KEEP_DOSPART	(1 << 1)
+#define IMX_INTERNAL_FLAG_ERASE		(1 << 2)
 
 struct imx_internal_bbu_handler {
 	struct bbu_handler handler;
@@ -60,6 +61,17 @@ static int imx_bbu_write_device(struct imx_internal_bbu_handler *imx_handler,
 	if (fd < 0)
 		return fd;
 
+	if (imx_handler->flags & IMX_INTERNAL_FLAG_ERASE) {
+		debug("%s: eraseing %s from 0 to 0x%08x\n", __func__,
+				data->devicefile, image_len);
+		ret = erase(fd, image_len, 0);
+		if (ret) {
+			printf("erasing %s failed with %s\n", data->devicefile,
+					strerror(-ret));
+			goto err_close;
+		}
+	}
+
 	if (imx_handler->flags & IMX_INTERNAL_FLAG_KEEP_DOSPART) {
 		void *mbr = xzalloc(512);
 
@@ -522,6 +534,32 @@ int imx53_bbu_internal_mmc_register_handler(const char *name, char *devicefile,
 }
 
 /*
+ * Register a i.MX53 internal boot update handler for i2c/spi
+ * EEPROMs / flashes. Nearly the same as MMC/SD, but we do not need to
+ * keep a partition table. We have to erase the device beforehand though.
+ */
+int imx53_bbu_internal_spi_i2c_register_handler(const char *name, char *devicefile,
+		unsigned long flags, struct imx_dcd_v2_entry *dcd, int dcdsize,
+		unsigned long app_dest)
+{
+	struct imx_internal_bbu_handler *imx_handler;
+
+	imx_handler = __init_handler(name, devicefile, flags);
+	imx53_bbu_internal_init_dcd(imx_handler, dcd, dcdsize);
+	imx_handler->flash_header_offset = FLASH_HEADER_OFFSET_MMC;
+
+	if (app_dest)
+		imx_handler->app_dest = app_dest;
+	else
+		imx_handler->app_dest = 0x70000000;
+
+	imx_handler->flags = IMX_INTERNAL_FLAG_ERASE;
+	imx_handler->handler.handler = imx_bbu_internal_v2_update;
+
+	return __register_handler(imx_handler);
+}
+
+/*
  * Register a i.MX53 internal boot update handler for NAND
  */
 int imx53_bbu_internal_nand_register_handler(const char *name,
@@ -555,3 +593,19 @@ int imx6_bbu_internal_mmc_register_handler(const char *name, char *devicefile,
 	return imx53_bbu_internal_mmc_register_handler(name, devicefile,
 		flags, dcd, dcdsize, app_dest);
 }
+
+/*
+ * Register a i.MX53 internal boot update handler for i2c/spi
+ * EEPROMs / flashes. Nearly the same as MMC/SD, but we do not need to
+ * keep a partition table. We have to erase the device beforehand though.
+ */
+int imx6_bbu_internal_spi_i2c_register_handler(const char *name, char *devicefile,
+		unsigned long flags, struct imx_dcd_v2_entry *dcd, int dcdsize,
+		unsigned long app_dest)
+{
+	if (!app_dest)
+		app_dest = 0x10000000;
+
+	return imx53_bbu_internal_spi_i2c_register_handler(name, devicefile,
+		flags, dcd, dcdsize, app_dest);
+}
diff --git a/arch/arm/mach-imx/include/mach/bbu.h b/arch/arm/mach-imx/include/mach/bbu.h
index 249ed4a..37ebb57 100644
--- a/arch/arm/mach-imx/include/mach/bbu.h
+++ b/arch/arm/mach-imx/include/mach/bbu.h
@@ -14,6 +14,10 @@ int imx51_bbu_internal_mmc_register_handler(const char *name, char *devicefile,
 int imx53_bbu_internal_mmc_register_handler(const char *name, char *devicefile,
 		unsigned long flags, struct imx_dcd_v2_entry *, int dcdsize);
 
+int imx53_bbu_internal_spi_i2c_register_handler(const char *name, char *devicefile,
+		unsigned long flags, struct imx_dcd_v2_entry *dcd, int dcdsize,
+		unsigned long app_dest);
+
 int imx53_bbu_internal_nand_register_handler(const char *name,
 		unsigned long flags, struct imx_dcd_v2_entry *, int dcdsize,
 		int partition_size);
@@ -22,6 +26,10 @@ int imx6_bbu_internal_mmc_register_handler(const char *name, char *devicefile,
 		unsigned long flags, struct imx_dcd_v2_entry *, int dcdsize,
 		unsigned long app_dest);
 
+int imx6_bbu_internal_spi_i2c_register_handler(const char *name, char *devicefile,
+		unsigned long flags, struct imx_dcd_v2_entry *dcd, int dcdsize,
+		unsigned long app_dest);
+
 #else
 
 static inline int imx51_bbu_internal_mmc_register_handler(const char *name, char *devicefile,
@@ -36,6 +44,13 @@ static inline int imx53_bbu_internal_mmc_register_handler(const char *name, char
 	return -ENOSYS;
 }
 
+static inline int imx53_bbu_internal_spi_i2c_register_handler(const char *name, char *devicefile,
+		unsigned long flags, struct imx_dcd_v2_entry *dcd, int dcdsize,
+		unsigned long app_dest)
+{
+	return -ENOSYS;
+}
+
 static inline int imx53_bbu_internal_nand_register_handler(const char *name,
 		unsigned long flags, struct imx_dcd_v2_entry *dcd, int dcdsize,
 		int partition_size)
@@ -50,6 +65,13 @@ static inline int imx6_bbu_internal_mmc_register_handler(const char *name, char
 	return -ENOSYS;
 }
 
+static inline int imx6_bbu_internal_spi_i2c_register_handler(const char *name, char *devicefile,
+		unsigned long flags, struct imx_dcd_v2_entry *dcd, int dcdsize,
+		unsigned long app_dest)
+{
+	return -ENOSYS;
+}
+
 #endif
 
 struct dcd_table {
-- 
1.7.10.4



From s.hauer at pengutronix.de  Thu Nov 29 14:01:22 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu, 29 Nov 2012 20:01:22 +0100
Subject: [PATCH 2/4] ARM i.MX bbu: Add i.MX6 MMC handler
In-Reply-To: <1354215684-25235-1-git-send-email-s.hauer@pengutronix.de>
References: <1354215684-25235-1-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1354215684-25235-2-git-send-email-s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/arm/mach-imx/imx-bbu-internal.c |   14 ++++++++++++++
 arch/arm/mach-imx/include/mach/bbu.h |   11 +++++++++++
 2 files changed, 25 insertions(+)

diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/imx-bbu-internal.c
index c34f86f..029bd5b 100644
--- a/arch/arm/mach-imx/imx-bbu-internal.c
+++ b/arch/arm/mach-imx/imx-bbu-internal.c
@@ -541,3 +541,17 @@ int imx53_bbu_internal_nand_register_handler(const char *name,
 
 	return __register_handler(imx_handler);
 }
+
+/*
+ * Register a i.MX6 internal boot update handler for MMC/SD
+ */
+int imx6_bbu_internal_mmc_register_handler(const char *name, char *devicefile,
+		unsigned long flags, struct imx_dcd_v2_entry *dcd, int dcdsize,
+		unsigned long app_dest)
+{
+	if (!app_dest)
+		app_dest = 0x10000000;
+
+	return imx53_bbu_internal_mmc_register_handler(name, devicefile,
+		flags, dcd, dcdsize, app_dest);
+}
diff --git a/arch/arm/mach-imx/include/mach/bbu.h b/arch/arm/mach-imx/include/mach/bbu.h
index f9ec1cc..249ed4a 100644
--- a/arch/arm/mach-imx/include/mach/bbu.h
+++ b/arch/arm/mach-imx/include/mach/bbu.h
@@ -18,6 +18,10 @@ int imx53_bbu_internal_nand_register_handler(const char *name,
 		unsigned long flags, struct imx_dcd_v2_entry *, int dcdsize,
 		int partition_size);
 
+int imx6_bbu_internal_mmc_register_handler(const char *name, char *devicefile,
+		unsigned long flags, struct imx_dcd_v2_entry *, int dcdsize,
+		unsigned long app_dest);
+
 #else
 
 static inline int imx51_bbu_internal_mmc_register_handler(const char *name, char *devicefile,
@@ -39,6 +43,13 @@ static inline int imx53_bbu_internal_nand_register_handler(const char *name,
 	return -ENOSYS;
 }
 
+static inline int imx6_bbu_internal_mmc_register_handler(const char *name, char *devicefile,
+		unsigned long flags, struct imx_dcd_v2_entry *dcd, int dcdsize,
+		unsigned long app_dest)
+{
+	return -ENOSYS;
+}
+
 #endif
 
 struct dcd_table {
-- 
1.7.10.4



From s.hauer at pengutronix.de  Thu Nov 29 14:02:24 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu, 29 Nov 2012 20:02:24 +0100
Subject: [PATCH 1/5] mci: Add STUFF_BITS and use it
Message-ID: <1354215748-25394-1-git-send-email-s.hauer@pengutronix.de>

This adds the STUFF_BITS macro from the kernel to extract numbers
from the csd. This also fixes several places where the csd fields
in SD cards differ from MMC cards.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/mci/mci-core.c |   41 ++++++++++++++++++++++++++++++++++++-----
 1 file changed, 36 insertions(+), 5 deletions(-)

diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index bf2b0f8..0d601e3 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -37,6 +37,20 @@
 
 #define MAX_BUFFER_NUMBER 0xffffffff
 
+#define UNSTUFF_BITS(resp,start,size)					\
+	({								\
+		const int __size = size;				\
+		const u32 __mask = (__size < 32 ? 1 << __size : 0) - 1;	\
+		const int __off = 3 - ((start) / 32);			\
+		const int __shft = (start) & 31;			\
+		u32 __res;						\
+									\
+		__res = resp[__off] >> __shft;				\
+		if (__size + __shft > 32)				\
+			__res |= resp[__off-1] << ((32 - __shft) % 32);	\
+		__res & __mask;						\
+	})
+
 /**
  * @file
  * @brief Memory Card framework
@@ -724,7 +738,7 @@ static void mci_extract_max_tran_speed_from_csd(struct mci *mci)
  */
 static void mci_extract_block_lengths_from_csd(struct mci *mci)
 {
-	mci->read_bl_len = 1 << ((mci->csd[1] >> 16) & 0xf);
+	mci->read_bl_len = 1 << UNSTUFF_BITS(mci->csd, 80, 4);
 
 	if (IS_SD(mci))
 		mci->write_bl_len = mci->read_bl_len;	/* FIXME why? */
@@ -1165,7 +1179,10 @@ static int mci_sd_read(struct block_device *blk, void *buffer, int block,
  */
 static unsigned extract_mid(struct mci *mci)
 {
-	return mci->cid[0] >> 24;
+	if (!IS_SD(mci) && mci->version <= MMC_VERSION_1_4)
+		return UNSTUFF_BITS(mci->cid, 104, 24);
+	else
+		return UNSTUFF_BITS(mci->cid, 120, 8);
 }
 
 /**
@@ -1198,7 +1215,15 @@ static unsigned extract_prv(struct mci *mci)
  */
 static unsigned extract_psn(struct mci *mci)
 {
-	return (mci->cid[2] << 8) | (mci->cid[3] >> 24);
+	if (IS_SD(mci)) {
+		return UNSTUFF_BITS(mci->csd, 24, 32);
+	} else {
+		if (mci->version > MMC_VERSION_1_4)
+			return UNSTUFF_BITS(mci->cid, 16, 32);
+		else
+			return UNSTUFF_BITS(mci->cid, 16, 24);
+	}
+
 }
 
 /**
@@ -1209,7 +1234,10 @@ static unsigned extract_psn(struct mci *mci)
  */
 static unsigned extract_mtd_month(struct mci *mci)
 {
-	return (mci->cid[3] >> 8) & 0xf;
+	if (IS_SD(mci))
+		return UNSTUFF_BITS(mci->cid, 8, 4);
+	else
+		return UNSTUFF_BITS(mci->cid, 12, 4);
 }
 
 /**
@@ -1221,7 +1249,10 @@ static unsigned extract_mtd_month(struct mci *mci)
  */
 static unsigned extract_mtd_year(struct mci *mci)
 {
-	return ((mci->cid[3] >> 12) & 0xff) + 2000U;
+	if (IS_SD(mci))
+		return UNSTUFF_BITS(mci->cid, 12, 8) + 2000;
+	else
+		return UNSTUFF_BITS(mci->cid, 8, 4) + 1997;
 }
 
 /**
-- 
1.7.10.4



From s.hauer at pengutronix.de  Thu Nov 29 14:02:26 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu, 29 Nov 2012 20:02:26 +0100
Subject: [PATCH 3/5] mci: Allow to specify device name
In-Reply-To: <1354215748-25394-1-git-send-email-s.hauer@pengutronix.de>
References: <1354215748-25394-1-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1354215748-25394-3-git-send-email-s.hauer@pengutronix.de>

When multiple MMC/SD cards are present in the system we often
have to have persistent names to identify them during runtime.
This patch allows to overwrite the devicename which is used.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/mci/mci-core.c |   10 +++++++---
 include/mci.h          |    1 +
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 942d126..6e556a8 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -1397,9 +1397,13 @@ static int mci_card_probe(struct mci *mci)
 	mci->blk.dev = mci->mci_dev;
 	mci->blk.ops = &mci_ops;
 
-	disknum = cdev_find_free_index("disk");
+	if (host->devname) {
+		mci->blk.cdev.name = strdup(host->devname);
+	} else {
+		disknum = cdev_find_free_index("disk");
+		mci->blk.cdev.name = asprintf("disk%d", disknum);
+	}
 
-	mci->blk.cdev.name = asprintf("disk%d", disknum);
 	mci->blk.blockbits = SECTOR_SHIFT;
 	mci->blk.num_blocks = mci_calc_blk_cnt(mci->capacity, mci->blk.blockbits);
 
@@ -1409,7 +1413,7 @@ static int mci_card_probe(struct mci *mci)
 		goto on_error;
 	}
 
-	dev_info(mci->mci_dev, "registered disk%d\n", disknum);
+	dev_info(mci->mci_dev, "registered %s\n", mci->blk.cdev.name);
 
 	/* create partitions on demand */
 	rc = parse_partition_table(&mci->blk);
diff --git a/include/mci.h b/include/mci.h
index db78b9c..0041e27 100644
--- a/include/mci.h
+++ b/include/mci.h
@@ -286,6 +286,7 @@ struct mci_ios {
 /** host information */
 struct mci_host {
 	struct device_d *hw_dev;	/**< the host MCI hardware device */
+	char *devname;			/**< the devicename for the card, defaults to disk%d */
 	unsigned voltages;
 	unsigned host_caps;	/**< Host's interface capabilities, refer MMC_VDD_* */
 	unsigned f_min;		/**< host interface lower limit */
-- 
1.7.10.4



From s.hauer at pengutronix.de  Thu Nov 29 14:02:28 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu, 29 Nov 2012 20:02:28 +0100
Subject: [PATCH 5/5] mci i.MX esdhc: turn error message into debug message
In-Reply-To: <1354215748-25394-1-git-send-email-s.hauer@pengutronix.de>
References: <1354215748-25394-1-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1354215748-25394-5-git-send-email-s.hauer@pengutronix.de>

During card probe the mci core may send commands to the card
which the card doesn't understand. This is intended, so do not
print an error message here.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/mci/imx-esdhc.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mci/imx-esdhc.c b/drivers/mci/imx-esdhc.c
index eced162..dfeb509 100644
--- a/drivers/mci/imx-esdhc.c
+++ b/drivers/mci/imx-esdhc.c
@@ -279,7 +279,7 @@ esdhc_send_cmd(struct mci_host *mci, struct mci_cmd *cmd, struct mci_data *data)
 	ret = wait_on_timeout(100 * MSECOND,
 			esdhc_read32(&regs->irqstat) & IRQSTAT_CC);
 	if (ret) {
-		dev_err(host->dev, "timeout 1\n");
+		dev_dbg(host->dev, "timeout 1\n");
 		return -ETIMEDOUT;
 	}
 
-- 
1.7.10.4



From s.hauer at pengutronix.de  Thu Nov 29 14:02:27 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu, 29 Nov 2012 20:02:27 +0100
Subject: [PATCH 4/5] mci i.MX esdhc: Allow to specify devicename from
 platformdata
In-Reply-To: <1354215748-25394-1-git-send-email-s.hauer@pengutronix.de>
References: <1354215748-25394-1-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1354215748-25394-4-git-send-email-s.hauer@pengutronix.de>

For boards which need to have persistent names for the device file.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/arm/mach-imx/include/mach/esdhc.h |    1 +
 drivers/mci/imx-esdhc.c                |    3 +++
 2 files changed, 4 insertions(+)

diff --git a/arch/arm/mach-imx/include/mach/esdhc.h b/arch/arm/mach-imx/include/mach/esdhc.h
index b4c1aa9..06863c8 100644
--- a/arch/arm/mach-imx/include/mach/esdhc.h
+++ b/arch/arm/mach-imx/include/mach/esdhc.h
@@ -41,5 +41,6 @@ struct esdhc_platform_data {
 	enum wp_types wp_type;
 	enum cd_types cd_type;
 	unsigned caps;
+	char *devname;
 };
 #endif /* __ASM_ARCH_IMX_ESDHC_H */
diff --git a/drivers/mci/imx-esdhc.c b/drivers/mci/imx-esdhc.c
index dccffc6..eced162 100644
--- a/drivers/mci/imx-esdhc.c
+++ b/drivers/mci/imx-esdhc.c
@@ -552,6 +552,9 @@ static int fsl_esdhc_probe(struct device_d *dev)
 	else
 		mci->host_caps = MMC_MODE_4BIT;
 
+	if (pdata && pdata->devname)
+		mci->devname = pdata->devname;
+
 	if (caps & ESDHC_HOSTCAPBLT_HSS)
 		mci->host_caps |= MMC_MODE_HS_52MHz | MMC_MODE_HS;
 
-- 
1.7.10.4



From s.hauer at pengutronix.de  Thu Nov 29 14:02:25 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu, 29 Nov 2012 20:02:25 +0100
Subject: [PATCH 2/5] mci: Fix capacity calculation for high capacity MMC cards
In-Reply-To: <1354215748-25394-1-git-send-email-s.hauer@pengutronix.de>
References: <1354215748-25394-1-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1354215748-25394-2-git-send-email-s.hauer@pengutronix.de>

For these cards we have to calculate the size using the ext csd
sector count fields.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/mci/mci-core.c |   20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 0d601e3..942d126 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -758,14 +758,21 @@ static void mci_extract_card_capacity_from_csd(struct mci *mci)
 	uint64_t csize, cmult;
 
 	if (mci->high_capacity) {
-		csize = (mci->csd[1] & 0x3f) << 16 | (mci->csd[2] & 0xffff0000) >> 16;
-		cmult = 8;
+		if (IS_SD(mci)) {
+			csize = UNSTUFF_BITS(mci->csd, 48, 22);
+			mci->capacity = (1 + csize) << 10;
+		} else {
+			mci->capacity = mci->ext_csd[EXT_CSD_SEC_CNT] << 0 |
+				mci->ext_csd[EXT_CSD_SEC_CNT + 1] << 8 |
+				mci->ext_csd[EXT_CSD_SEC_CNT + 2] << 16 |
+				mci->ext_csd[EXT_CSD_SEC_CNT + 3] << 24;
+		}
 	} else {
-		csize = (mci->csd[1] & 0x3ff) << 2 | (mci->csd[2] & 0xc0000000) >> 30;
-		cmult = (mci->csd[2] & 0x00038000) >> 15;
+		cmult = UNSTUFF_BITS(mci->csd, 47, 3);
+		csize = UNSTUFF_BITS(mci->csd, 62, 12);
+		mci->capacity = (csize + 1) << (cmult + 2);
 	}
 
-	mci->capacity = (csize + 1) << (cmult + 2);
 	mci->capacity *= mci->read_bl_len;
 	dev_dbg(mci->mci_dev, "Capacity: %u MiB\n", (unsigned)(mci->capacity >> 20));
 }
@@ -996,7 +1003,6 @@ static int mci_startup(struct mci *mci)
 	mci_detect_version_from_csd(mci);
 	mci_extract_max_tran_speed_from_csd(mci);
 	mci_extract_block_lengths_from_csd(mci);
-	mci_extract_card_capacity_from_csd(mci);
 
 	/* sanitiy? */
 	if (mci->read_bl_len > SECTOR_SIZE) {
@@ -1032,6 +1038,8 @@ static int mci_startup(struct mci *mci)
 	if (err)
 		return err;
 
+	mci_extract_card_capacity_from_csd(mci);
+
 	/* Restrict card's capabilities by what the host can do */
 	mci->card_caps &= host->host_caps;
 
-- 
1.7.10.4



From s.hauer at pengutronix.de  Thu Nov 29 14:02:48 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu, 29 Nov 2012 20:02:48 +0100
Subject: [PATCH 2/2] mfd stmpe: fix test for features
In-Reply-To: <1354215768-25511-1-git-send-email-s.hauer@pengutronix.de>
References: <1354215768-25511-1-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1354215768-25511-2-git-send-email-s.hauer@pengutronix.de>

Use '&' to test for the bit as it was intended.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/mfd/stmpe-i2c.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mfd/stmpe-i2c.c b/drivers/mfd/stmpe-i2c.c
index 7d16842..9e4bbcc 100644
--- a/drivers/mfd/stmpe-i2c.c
+++ b/drivers/mfd/stmpe-i2c.c
@@ -132,7 +132,7 @@ static int stmpe_probe(struct device_d *dev)
 	i2c_ci->read_reg = stmpe_reg_read;
 	i2c_ci->write_reg = stmpe_reg_write;
 
-	if (pdata->blocks &= STMPE_BLOCK_GPIO)
+	if (pdata->blocks & STMPE_BLOCK_GPIO)
 		add_generic_device("stmpe-gpio", DEVICE_ID_DYNAMIC, NULL, 0, 0, IORESOURCE_MEM, i2c_ci);
 
 	devfs_create(&stmpe_dev->cdev);
-- 
1.7.10.4



From s.hauer at pengutronix.de  Thu Nov 29 14:02:47 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu, 29 Nov 2012 20:02:47 +0100
Subject: [PATCH 1/2] mfd stmpe: add index to devicename
Message-ID: <1354215768-25511-1-git-send-email-s.hauer@pengutronix.de>

Otherwise it's not possible to register multiple stmpe devices.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/mfd/stmpe-i2c.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mfd/stmpe-i2c.c b/drivers/mfd/stmpe-i2c.c
index d7c29cc..7d16842 100644
--- a/drivers/mfd/stmpe-i2c.c
+++ b/drivers/mfd/stmpe-i2c.c
@@ -118,7 +118,8 @@ static int stmpe_probe(struct device_d *dev)
 	}
 
 	stmpe_dev = xzalloc(sizeof(struct stmpe));
-	stmpe_dev->cdev.name = DRIVERNAME;
+	stmpe_dev->cdev.name = asprintf(DRIVERNAME "%d",
+			cdev_find_free_index(DRIVERNAME));
 	stmpe_dev->client = to_i2c_client(dev);
 	stmpe_dev->cdev.size = 191;		/* 191 known registers */
 	stmpe_dev->cdev.dev = dev;
-- 
1.7.10.4



From s.hauer at pengutronix.de  Thu Nov 29 14:03:06 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu, 29 Nov 2012 20:03:06 +0100
Subject: [PATCH 2/2] mtd core: call driver write function with complete buffer
In-Reply-To: <1354215786-25615-1-git-send-email-s.hauer@pengutronix.de>
References: <1354215786-25615-1-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1354215786-25615-2-git-send-email-s.hauer@pengutronix.de>

mtd->write is supposed to loop around pages internally, no need
to do this in mtd_write. This fixes a huge write performance drop
with the m25p80 driver when it was converted to a mtd driver recently.
Since mtd->writesize is 1 for this driver mtd_write ended up doing
single byte writes on the flash.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/mtd/core.c |   56 +++-------------------------------------------------
 1 file changed, 3 insertions(+), 53 deletions(-)

diff --git a/drivers/mtd/core.c b/drivers/mtd/core.c
index 8601787..b5916da 100644
--- a/drivers/mtd/core.c
+++ b/drivers/mtd/core.c
@@ -62,65 +62,15 @@ static 	ssize_t mtd_read(struct cdev *cdev, void* buf, size_t count,
 #define MTDPGALG(x) ((x) & ~(mtd->writesize - 1))
 
 #ifdef CONFIG_MTD_WRITE
-static int all_ff(const void *buf, int len)
-{
-	int i;
-	const uint8_t *p = buf;
-
-	for (i = 0; i < len; i++)
-		if (p[i] != 0xFF)
-			return 0;
-	return 1;
-}
-
 static ssize_t mtd_write(struct cdev* cdev, const void *buf, size_t _count,
 			  loff_t _offset, ulong flags)
 {
 	struct mtd_info *mtd = cdev->priv;
-	size_t retlen, now;
-	int ret = 0;
-	void *wrbuf = NULL;
-	size_t count = _count;
-	unsigned long offset = _offset;
-
-	if (NOTALIGNED(offset)) {
-		printf("offset 0x%0lx not page aligned\n", offset);
-		return -EINVAL;
-	}
-
-	dev_dbg(cdev->dev, "write: offset: 0x%08lx count: 0x%zx\n", offset, count);
-	while (count) {
-		now = count > mtd->writesize ? mtd->writesize : count;
-
-		if (NOTALIGNED(now)) {
-			dev_dbg(cdev->dev, "not aligned: %d %ld\n",
-				mtd->writesize,
-				(offset % mtd->writesize));
-			wrbuf = xmalloc(mtd->writesize);
-			memset(wrbuf, 0xff, mtd->writesize);
-			memcpy(wrbuf + (offset % mtd->writesize), buf, now);
-			if (!all_ff(wrbuf, mtd->writesize))
-				ret = mtd->write(mtd, MTDPGALG(offset),
-						  mtd->writesize, &retlen,
-						  wrbuf);
-			free(wrbuf);
-		} else {
-			if (!all_ff(buf, mtd->writesize))
-				ret = mtd->write(mtd, offset, now, &retlen,
-						  buf);
-			dev_dbg(cdev->dev,
-				"offset: 0x%08lx now: 0x%zx retlen: 0x%zx\n",
-				offset, now, retlen);
-		}
-		if (ret)
-			goto out;
+	size_t retlen;
+	int ret;
 
-		offset += now;
-		count -= now;
-		buf += now;
-	}
+	ret = mtd->write(mtd, _offset, _count, &retlen, buf);
 
-out:
 	return ret ? ret : _count;
 }
 #endif
-- 
1.7.10.4



From s.hauer at pengutronix.de  Thu Nov 29 14:03:05 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu, 29 Nov 2012 20:03:05 +0100
Subject: [PATCH 1/2] mtd oob: do not register oob device for devices without
 oob
Message-ID: <1354215786-25615-1-git-send-email-s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/mtd/mtdoob.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/mtd/mtdoob.c b/drivers/mtd/mtdoob.c
index c7bf40c..e5d8039 100644
--- a/drivers/mtd/mtdoob.c
+++ b/drivers/mtd/mtdoob.c
@@ -73,6 +73,9 @@ static int add_mtdoob_device(struct mtd_info *mtd, char *devname, void **priv)
 {
 	struct mtdoob *mtdoob;
 
+	if (mtd->oobsize == 0)
+		return 0;
+
 	mtdoob = xzalloc(sizeof(*mtdoob));
 	mtdoob->cdev.ops = &mtd_ops_oob;
 	mtdoob->cdev.size = (mtd->size / mtd->writesize) * mtd->oobsize;
-- 
1.7.10.4



From s.hauer at pengutronix.de  Thu Nov 29 14:27:26 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu, 29 Nov 2012 20:27:26 +0100
Subject: [PATCH 1/2] rm: implement -r
Message-ID: <1354217247-4870-1-git-send-email-s.hauer@pengutronix.de>

To recursively remove files and directories.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 commands/rm.c          |   28 ++++++++++++++++++++----
 include/fs.h           |    2 ++
 lib/Makefile           |    1 +
 lib/recursive_action.c |    1 -
 lib/unlink-recursive.c |   56 ++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 83 insertions(+), 5 deletions(-)
 create mode 100644 lib/unlink-recursive.c

diff --git a/commands/rm.c b/commands/rm.c
index 4e765ac..5486005 100644
--- a/commands/rm.c
+++ b/commands/rm.c
@@ -19,17 +19,36 @@
 #include <common.h>
 #include <command.h>
 #include <fs.h>
+#include <getopt.h>
 #include <errno.h>
 
 static int do_rm(int argc, char *argv[])
 {
-	int i = 1;
+	int i, opt, recursive = 0;
+
+	while ((opt = getopt(argc, argv, "r")) > 0) {
+		switch (opt) {
+		case 'r':
+			recursive = 1;
+			break;
+		default:
+			return COMMAND_ERROR_USAGE;
+		}
+	}
 
 	if (argc < 2)
 		return COMMAND_ERROR_USAGE;
 
+	i = optind;
+
 	while (i < argc) {
-		if (unlink(argv[i])) {
+		int ret;
+
+		if (recursive)
+			ret = unlink_recursive(argv[i], NULL);
+		else
+			ret = unlink(argv[i]);
+		if (ret) {
 			printf("could not remove %s: %s\n", argv[i], errno_str());
 			return 1;
 		}
@@ -40,8 +59,9 @@ static int do_rm(int argc, char *argv[])
 }
 
 static const __maybe_unused char cmd_rm_help[] =
-"Usage: rm [FILES]\n"
-"Remove files\n";
+"Usage: rm [OPTIONS] [FILES]\n"
+"Remove files\n"
+"-r  remove directories and their contents recursively\n";
 
 BAREBOX_CMD_START(rm)
 	.cmd		= do_rm,
diff --git a/include/fs.h b/include/fs.h
index 3d5714c..8ff7300 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -182,4 +182,6 @@ void automount_remove(const char *_path);
 int automount_add(const char *path, const char *cmd);
 void automount_print(void);
 
+int unlink_recursive(const char *path, char **failedpath);
+
 #endif /* __FS_H */
diff --git a/lib/Makefile b/lib/Makefile
index eb0af92..635d52e 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -36,3 +36,4 @@ obj-$(CONFIG_BITREV)	+= bitrev.o
 obj-$(CONFIG_QSORT)	+= qsort.o
 obj-y			+= gui/
 obj-$(CONFIG_XYMODEM)	+= xymodem.o
+obj-y			+= unlink-recursive.o
diff --git a/lib/recursive_action.c b/lib/recursive_action.c
index 5bc2595..345d3db 100644
--- a/lib/recursive_action.c
+++ b/lib/recursive_action.c
@@ -130,7 +130,6 @@ int recursive_action(const char *fileName,
 		return 0;
 	return 1;
 done_nak_warn:
-	printf("%s", fileName);
 	return 0;
 }
 
diff --git a/lib/unlink-recursive.c b/lib/unlink-recursive.c
new file mode 100644
index 0000000..a488553
--- /dev/null
+++ b/lib/unlink-recursive.c
@@ -0,0 +1,56 @@
+#include <common.h>
+#include <libbb.h>
+#include <fs.h>
+
+static char unlink_recursive_failedpath[PATH_MAX];
+
+struct data {
+	int error;
+};
+
+static int file_action(const char *filename, struct stat *statbuf,
+			    void *userdata, int depth)
+{
+	struct data *data = userdata;
+	int ret;
+
+	ret = unlink(filename);
+	if (ret) {
+		strcpy(unlink_recursive_failedpath, filename);
+		data->error = ret;
+	}
+
+	return ret ? 0 : 1;
+}
+
+static int dir_action(const char *dirname, struct stat *statbuf,
+			    void *userdata, int depth)
+{
+	struct data *data = userdata;
+	int ret;
+
+	ret = rmdir(dirname);
+	if (ret) {
+		strcpy(unlink_recursive_failedpath, dirname);
+		data->error = ret;
+	}
+
+	return ret ? 0 : 1;
+}
+
+int unlink_recursive(const char *path, char **failedpath)
+{
+	struct data data = {};
+	int ret;
+
+	if (failedpath)
+		*failedpath = NULL;
+
+	ret = recursive_action(path, ACTION_RECURSE | ACTION_DEPTHFIRST,
+			file_action, dir_action, &data, 0);
+
+	if (!ret && failedpath)
+		*failedpath = unlink_recursive_failedpath;
+
+	return ret ? 0 : errno;
+}
-- 
1.7.10.4



From s.hauer at pengutronix.de  Thu Nov 29 14:27:27 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Thu, 29 Nov 2012 20:27:27 +0100
Subject: [PATCH 2/2] loadenv: allow more fine grained environment loading
In-Reply-To: <1354217247-4870-1-git-send-email-s.hauer@pengutronix.de>
References: <1354217247-4870-1-git-send-email-s.hauer@pengutronix.de>
Message-ID: <1354217247-4870-2-git-send-email-s.hauer@pengutronix.de>

This implements two new options for the loadenv command:

-s: removes (scrubs) old directory contents to be able to
    create a fresh environment from for example /dev/defaultenv
-n: no overwrite. Do not overwrite existing files. This allows
    to keep parts of the old environment.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 commands/loadenv.c    |   53 +++++++++++++++++++++++++++++++++++++++++++------
 common/environment.c  |   12 +++++++++--
 common/startup.c      |    4 ++--
 include/environment.h |    7 ++++---
 scripts/bareboxenv.c  |    2 +-
 5 files changed, 64 insertions(+), 14 deletions(-)

diff --git a/commands/loadenv.c b/commands/loadenv.c
index 5bf1740..48284d7 100644
--- a/commands/loadenv.c
+++ b/commands/loadenv.c
@@ -21,27 +21,68 @@
  */
 
 #include <common.h>
+#include <getopt.h>
 #include <command.h>
 #include <environment.h>
+#include <fs.h>
 
 static int do_loadenv(int argc, char *argv[])
 {
 	char *filename, *dirname;
+	unsigned flags = 0;
+	int opt;
+	int scrub = 0;
 
-	if (argc < 3)
+	while ((opt = getopt(argc, argv, "ns")) > 0) {
+		switch (opt) {
+		case 'n':
+			flags |= ENV_FLAG_NO_OVERWRITE;
+			break;
+		case 's':
+			scrub = 1;
+			break;
+		default:
+			return COMMAND_ERROR_USAGE;
+		}
+	}
+
+	if (argc - optind < 2)
 		dirname = "/env";
 	else
-		dirname = argv[2];
-	if (argc < 2)
+		dirname = argv[optind + 1];
+
+	if (argc - optind < 1)
 		filename = default_environment_path;
 	else
-		filename = argv[1];
+		filename = argv[optind];
+
+	if (scrub) {
+		int ret;
+
+		ret = unlink_recursive(dirname, NULL);
+		if (ret) {
+			eprintf("cannot remove %s: %s\n", dirname,
+					strerror(-ret));
+			return 1;
+		}
+
+		ret = mkdir(dirname, 0);
+		if (ret) {
+			eprintf("cannot create %s: %s\n", dirname,
+					strerror(-ret));
+			return ret;
+		}
+	}
+
 	printf("loading environment from %s\n", filename);
-	return envfs_load(filename, dirname);
+
+	return envfs_load(filename, dirname, flags);
 }
 
 BAREBOX_CMD_HELP_START(loadenv)
-BAREBOX_CMD_HELP_USAGE("loadenv [ENVFS] [DIRECTORY]\n")
+BAREBOX_CMD_HELP_USAGE("loadenv OPTIONS [ENVFS] [DIRECTORY]\n")
+BAREBOX_CMD_HELP_OPT("-n", "do not overwrite existing files\n")
+BAREBOX_CMD_HELP_OPT("-s", "scrub old environment\n")
 BAREBOX_CMD_HELP_SHORT("Load environment from ENVFS into DIRECTORY (default: /dev/env0 -> /env).\n")
 BAREBOX_CMD_HELP_END
 
diff --git a/common/environment.c b/common/environment.c
index 69c4c0a..e11cd9d 100644
--- a/common/environment.c
+++ b/common/environment.c
@@ -206,7 +206,7 @@ EXPORT_SYMBOL(envfs_save);
  * Note: This function will also be used on the host! See note in the header
  * of this file.
  */
-int envfs_load(char *filename, char *dir)
+int envfs_load(char *filename, char *dir, unsigned flags)
 {
 	struct envfs_super super;
 	void *buf = NULL, *buf_free = NULL;
@@ -316,6 +316,14 @@ int envfs_load(char *filename, char *dir)
 			}
 			free(str);
 		} else {
+			struct stat s;
+
+			if (flags & ENV_FLAG_NO_OVERWRITE &&
+					!stat(str, &s)) {
+				printf("skip %s\n", str);
+				goto skip;
+			}
+
 			fd = open(str, O_WRONLY | O_CREAT | O_TRUNC, 0644);
 			free(str);
 			if (fd < 0) {
@@ -333,7 +341,7 @@ int envfs_load(char *filename, char *dir)
 			}
 			close(fd);
 		}
-
+skip:
 		buf += PAD4(inode_size);
 		size -= headerlen_full + PAD4(inode_size) +
 				sizeof(struct envfs_inode);
diff --git a/common/startup.c b/common/startup.c
index 7bb3c73..14409a2 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -108,12 +108,12 @@ void start_barebox (void)
 	debug("initcalls done\n");
 
 #ifdef CONFIG_ENV_HANDLING
-	if (envfs_load(default_environment_path, "/env")) {
+	if (envfs_load(default_environment_path, "/env", 0)) {
 #ifdef CONFIG_DEFAULT_ENVIRONMENT
 		printf("no valid environment found on %s. "
 			"Using default environment\n",
 			default_environment_path);
-		envfs_load("/dev/defaultenv", "/env");
+		envfs_load("/dev/defaultenv", "/env", 0);
 #endif
 	}
 #endif
diff --git a/include/environment.h b/include/environment.h
index 4184977..096c169 100644
--- a/include/environment.h
+++ b/include/environment.h
@@ -75,9 +75,6 @@ int env_push_context(void);
 /* defaults to /dev/env0 */
 extern char *default_environment_path;
 
-int envfs_load(char *filename, char *dirname);
-int envfs_save(char *filename, char *dirname);
-
 int export(const char *);
 
 struct stat;
@@ -86,6 +83,10 @@ int file_save_action(const char *, struct stat *, void *, int);
 
 #endif /* __BAREBOX__ */
 
+#define ENV_FLAG_NO_OVERWRITE	(1 << 0)
+int envfs_load(char *filename, char *dirname, unsigned flags);
+int envfs_save(char *filename, char *dirname);
+
 /* This part is used for the host and the target */
 struct action_data {
 	int fd;
diff --git a/scripts/bareboxenv.c b/scripts/bareboxenv.c
index 5fdc62e..707d63d 100644
--- a/scripts/bareboxenv.c
+++ b/scripts/bareboxenv.c
@@ -191,7 +191,7 @@ int main(int argc, char *argv[])
 	if (load) {
 		if (verbose)
 			printf("loading env from file %s to %s\n", filename, dirname);
-		envfs_load(filename, dirname);
+		envfs_load(filename, dirname, 0);
 	}
 	if (save) {
 		if (verbose)
-- 
1.7.10.4



From marek.belisko at gmail.com  Thu Nov 29 17:49:56 2012
From: marek.belisko at gmail.com (Belisko Marek)
Date: Thu, 29 Nov 2012 23:49:56 +0100
Subject: loading uImage from FAT partition
Message-ID: <CAAfyv341yF=MSJg+CWpJSRy1deOsaz3DHH1=WKo8VLeyYKUWjQ@mail.gmail.com>

Hi,

I'm trying to use barebox on pandaboard and change default env config to boot
from SD card (as this is mostly what user want).

I'm curious how to add boot support from SD card properly.
I'm using currently command: bootm /boot/uImage in
boot script. Is this approach correct or is there some simple way how
to make it?

Thanks,

mbe

-- 
as simple and primitive as possible
-------------------------------------------------
Marek Belisko - OPEN-NANDRA
Freelance Developer

Ruska Nova Ves 219 | Presov, 08005 Slovak Republic
Tel: +421 915 052 184
skype: marekwhite
twitter: #opennandra
web: http://open-nandra.com


From antonynpavlov at gmail.com  Thu Nov 29 21:53:53 2012
From: antonynpavlov at gmail.com (Antony Pavlov)
Date: Fri, 30 Nov 2012 06:53:53 +0400
Subject: [PATCH] MIPS: fix out-of-tree build
Message-ID: <1354244033-9664-1-git-send-email-antonynpavlov@gmail.com>

The commit

  commit d25d94bea67308e29db895d418f3f1f8153ae2ea
  Author: Antony Pavlov <antonynpavlov at gmail.com>
  Date:   Fri Jun 1 13:23:20 2012 +0400

      MIPS: make possible board-specific header files

      This patch makes possible to put a board-specific
      header file (e. g. foobar.h) to arch/mips/boards/*/include/board/.

breaks the out-of-tree build for the boards that use it (rzx50).

Reported-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
Signed-off-by: Antony Pavlov <antonynpavlov at gmail.com>
Cc: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 arch/mips/Makefile |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index 5e40de7..f32089d 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -88,14 +88,18 @@ else
 BOARD :=
 endif
 
+ifeq ($(KBUILD_SRC),)
+CPPFLAGS += -I$(BOARD)/include
+else
+CPPFLAGS += -I$(srctree)/$(BOARD)/include
+endif
+
 ifneq ($(machine-y),)
 MACH  := arch/mips/mach-$(machine-y)/
 else
 MACH  :=
 endif
 
-CPPFLAGS += -I$(BOARD)/include
-
 common-y += $(BOARD) $(MACH)
 common-y += arch/mips/lib/
 common-y += arch/mips/boot/
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Thu Nov 29 23:57:32 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri, 30 Nov 2012 05:57:32 +0100
Subject: [PATCH 3/5] mci: Allow to specify device name
In-Reply-To: <1354215748-25394-3-git-send-email-s.hauer@pengutronix.de>
References: <1354215748-25394-1-git-send-email-s.hauer@pengutronix.de>
 <1354215748-25394-3-git-send-email-s.hauer@pengutronix.de>
Message-ID: <20121130045732.GA8327@game.jcrosoft.org>

On 20:02 Thu 29 Nov     , Sascha Hauer wrote:
> When multiple MMC/SD cards are present in the system we often
> have to have persistent names to identify them during runtime.
> This patch allows to overwrite the devicename which is used.
> 
> Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
> ---
>  drivers/mci/mci-core.c |   10 +++++++---
>  include/mci.h          |    1 +
>  2 files changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
> index 942d126..6e556a8 100644
> --- a/drivers/mci/mci-core.c
> +++ b/drivers/mci/mci-core.c
> @@ -1397,9 +1397,13 @@ static int mci_card_probe(struct mci *mci)
>  	mci->blk.dev = mci->mci_dev;
>  	mci->blk.ops = &mci_ops;
>  
> -	disknum = cdev_find_free_index("disk");
> +	if (host->devname) {
> +		mci->blk.cdev.name = strdup(host->devname);
		can you use is a based name not the name
> +	} else {
> +		disknum = cdev_find_free_index("disk");
> +		mci->blk.cdev.name = asprintf("disk%d", disknum);
> +	}
>  
> -	mci->blk.cdev.name = asprintf("disk%d", disknum);
>  	mci->blk.blockbits = SECTOR_SHIFT;
>  	mci->blk.num_blocks = mci_calc_blk_cnt(mci->capacity, mci->blk.blockbits);
>  
> @@ -1409,7 +1413,7 @@ static int mci_card_probe(struct mci *mci)
>  		goto on_error;
>  	}
>  
> -	dev_info(mci->mci_dev, "registered disk%d\n", disknum);
> +	dev_info(mci->mci_dev, "registered %s\n", mci->blk.cdev.name);
>  
>  	/* create partitions on demand */
>  	rc = parse_partition_table(&mci->blk);
> diff --git a/include/mci.h b/include/mci.h
> index db78b9c..0041e27 100644
> --- a/include/mci.h
> +++ b/include/mci.h
> @@ -286,6 +286,7 @@ struct mci_ios {
>  /** host information */
>  struct mci_host {
>  	struct device_d *hw_dev;	/**< the host MCI hardware device */
> +	char *devname;			/**< the devicename for the card, defaults to disk%d */
>  	unsigned voltages;
>  	unsigned host_caps;	/**< Host's interface capabilities, refer MMC_VDD_* */
>  	unsigned f_min;		/**< host interface lower limit */
> -- 
> 1.7.10.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox


From s.hauer at pengutronix.de  Fri Nov 30 03:04:30 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Fri, 30 Nov 2012 09:04:30 +0100
Subject: loading uImage from FAT partition
In-Reply-To: <CAAfyv341yF=MSJg+CWpJSRy1deOsaz3DHH1=WKo8VLeyYKUWjQ@mail.gmail.com>
References: <CAAfyv341yF=MSJg+CWpJSRy1deOsaz3DHH1=WKo8VLeyYKUWjQ@mail.gmail.com>
Message-ID: <20121130080430.GS10369@pengutronix.de>

On Thu, Nov 29, 2012 at 11:49:56PM +0100, Belisko Marek wrote:
> Hi,
> 
> I'm trying to use barebox on pandaboard and change default env config to boot
> from SD card (as this is mostly what user want).
> 
> I'm curious how to add boot support from SD card properly.
> I'm using currently command: bootm /boot/uImage in
> boot script. Is this approach correct or is there some simple way how
> to make it?

As of current master with the panda board switched to the new
environment this would be:

boot mmc

You can adjust /env/boot/mmc to your needs beforehand.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From s.hauer at pengutronix.de  Fri Nov 30 03:06:46 2012
From: s.hauer at pengutronix.de (Sascha Hauer)
Date: Fri, 30 Nov 2012 09:06:46 +0100
Subject: [PATCH 3/5] mci: Allow to specify device name
In-Reply-To: <20121130045732.GA8327@game.jcrosoft.org>
References: <1354215748-25394-1-git-send-email-s.hauer@pengutronix.de>
 <1354215748-25394-3-git-send-email-s.hauer@pengutronix.de>
 <20121130045732.GA8327@game.jcrosoft.org>
Message-ID: <20121130080646.GU10369@pengutronix.de>

On Fri, Nov 30, 2012 at 05:57:32AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 20:02 Thu 29 Nov     , Sascha Hauer wrote:
> > When multiple MMC/SD cards are present in the system we often
> > have to have persistent names to identify them during runtime.
> > This patch allows to overwrite the devicename which is used.
> > 
> > Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
> > ---
> >  drivers/mci/mci-core.c |   10 +++++++---
> >  include/mci.h          |    1 +
> >  2 files changed, 8 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
> > index 942d126..6e556a8 100644
> > --- a/drivers/mci/mci-core.c
> > +++ b/drivers/mci/mci-core.c
> > @@ -1397,9 +1397,13 @@ static int mci_card_probe(struct mci *mci)
> >  	mci->blk.dev = mci->mci_dev;
> >  	mci->blk.ops = &mci_ops;
> >  
> > -	disknum = cdev_find_free_index("disk");
> > +	if (host->devname) {
> > +		mci->blk.cdev.name = strdup(host->devname);
> 		can you use is a based name not the name

I don't understand this. What do you mean?

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From jlu at pengutronix.de  Fri Nov 30 05:11:12 2012
From: jlu at pengutronix.de (Jan Luebbe)
Date: Fri, 30 Nov 2012 11:11:12 +0100
Subject: [PATCH] omap: gpmc: mark hex debug values as such
Message-ID: <1354270272-6626-1-git-send-email-jlu@pengutronix.de>

Also use %p for pointers.

Signed-off-by: Jan Luebbe <jlu at pengutronix.de>
---
 arch/arm/mach-omap/gpmc.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-omap/gpmc.c b/arch/arm/mach-omap/gpmc.c
index ff8b58b..73d8c44 100644
--- a/arch/arm/mach-omap/gpmc.c
+++ b/arch/arm/mach-omap/gpmc.c
@@ -50,7 +50,7 @@ void gpmc_generic_init(unsigned int cfg)
 	unsigned int reg = GPMC_REG(CONFIG7_0);
 	char x = 0;
 
-	debug("gpmccfg=%x\n", cfg);
+	debug("gpmccfg=0x%x\n", cfg);
 	/* Generic Configurations */
 	/* reset gpmc */
 	start = get_time_ns();
@@ -73,7 +73,7 @@ void gpmc_generic_init(unsigned int cfg)
 	 * But NEVER run me in XIP mode! I will Die!
 	 */
 	while (x < GPMC_NUM_CS) {
-		debug("gpmccs=%d Reg:%x <-0x0\n", x, reg);
+		debug("gpmccs=%d Reg:0x%x <-0x0\n", x, reg);
 		writel(0x0, reg);
 		reg += GPMC_CONFIG_CS_SIZE;
 		x++;
@@ -95,7 +95,7 @@ void gpmc_cs_config(char cs, struct gpmc_config *config)
 {
 	unsigned int reg = GPMC_REG(CONFIG1_0) + (cs * GPMC_CONFIG_CS_SIZE);
 	unsigned char x = 0;
-	debug("gpmccs=%x cfg=%x\n", cs, (unsigned int)config);
+	debug("gpmccs=0x%x cfg=0x%p\n", cs, config);
 
 	/* Disable the CS before reconfiguring */
 	writel(0x0, GPMC_REG(CONFIG7_0) + (cs * GPMC_CONFIG_CS_SIZE));
@@ -103,14 +103,14 @@ void gpmc_cs_config(char cs, struct gpmc_config *config)
 
 	/* Write the CFG1-6 regs */
 	while (x < 6) {
-		debug("gpmccfg=%d Reg:%x <-0x%x\n",
+		debug("gpmccfg%d Reg:0x%x <-0x%08x\n",
 				x, reg, config->cfg[x]);
 		writel(config->cfg[x], reg);
 		reg += GPMC_CONFIG_REG_OFF;
 		x++;
 	}
 	/* reg now points to CFG7 */
-	debug("gpmccfg=%d Reg:%x <-0x%x\n",
+	debug("gpmccfg%d Reg:0x%x <-0x%08x\n",
 			x, reg, (0x1 << 6) |		/* CS enable */
 		     ((config->size & 0xF) << 8) |	/* Size */
 		     ((config->base >> 24) & 0x3F));
-- 
1.7.10.4



From plagnioj at jcrosoft.com  Fri Nov 30 05:10:30 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri, 30 Nov 2012 11:10:30 +0100
Subject: [PATCH 3/5] mci: Allow to specify device name
In-Reply-To: <20121130080646.GU10369@pengutronix.de>
References: <1354215748-25394-1-git-send-email-s.hauer@pengutronix.de>
 <1354215748-25394-3-git-send-email-s.hauer@pengutronix.de>
 <20121130045732.GA8327@game.jcrosoft.org>
 <20121130080646.GU10369@pengutronix.de>
Message-ID: <20121130101030.GB8327@game.jcrosoft.org>

On 09:06 Fri 30 Nov     , Sascha Hauer wrote:
> On Fri, Nov 30, 2012 at 05:57:32AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > On 20:02 Thu 29 Nov     , Sascha Hauer wrote:
> > > When multiple MMC/SD cards are present in the system we often
> > > have to have persistent names to identify them during runtime.
> > > This patch allows to overwrite the devicename which is used.
> > > 
> > > Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
> > > ---
> > >  drivers/mci/mci-core.c |   10 +++++++---
> > >  include/mci.h          |    1 +
> > >  2 files changed, 8 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
> > > index 942d126..6e556a8 100644
> > > --- a/drivers/mci/mci-core.c
> > > +++ b/drivers/mci/mci-core.c
> > > @@ -1397,9 +1397,13 @@ static int mci_card_probe(struct mci *mci)
> > >  	mci->blk.dev = mci->mci_dev;
> > >  	mci->blk.ops = &mci_ops;
> > >  
> > > -	disknum = cdev_find_free_index("disk");
> > > +	if (host->devname) {
> > > +		mci->blk.cdev.name = strdup(host->devname);
> > 		can you use is a based name not the name
> 
> I don't understand this. What do you mean?
<name><id>

instead of disk0 mmc0 as exmaple

Best Regards,
J.
> 
> Sascha
> 
> -- 
> Pengutronix e.K.                           |                             |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


From zzs213 at 126.com  Fri Nov 30 06:00:29 2012
From: zzs213 at 126.com (=?utf-8?B?5byg5b+g5bGx?=)
Date: Fri, 30 Nov 2012 19:00:29 +0800
Subject: gunzip error when uncompress to buf
Message-ID: <20121130110029.GA7099@greatfirst.com>

On host use the flowwing cmd build a gziped file

----------------
$ gzip -c9 zbarebox.bin > xxx

$ ls zbarebox.bin xxx -l
-rw-rw-r-- 1 zzs zzs 127605 2012-11-30 17:46 xxx
-rwxrwxr-x 1 zzs zzs 136769 2012-11-30 18:44 zbarebox.bin*
----------------

Then on barebox write it to /dev/nor0.kernel

----------------
[barebox at SSR600]:/
# tftp xxx /dev/nor0.kernel
----------------


And add a barebox cmd to uncompress it:

----------------
char ptr[SZ_512K];
static int do_tx(int argc, char *argv[])
{
	int ret = 0, size = 0, fd, fd1;

	fd = open("/dev/tempmem", O_RDWR);
	if(fd < 0)
		printf("error open tempmem\n");
	fd1 = open("/dev/nor0.kernel", O_RDONLY);
	if(fd1 < 0)
		printf("error open kernel\n");
	ret = uncompress_fd_to_fd (fd1, fd, uncompress_err_stdout);
	printf("ret is %d\n", ret);

	close(fd1);
	fd1 = open("/dev/nor0.kernel", O_RDONLY);
	if(fd1 < 0)
		printf("error open kernel\n");
	ret = uncompress_fd_to_buf(fd1, ptr, uncompress_err_stdout);
	printf("ret is %d\n", ret);

	return 0;
}

BAREBOX_CMD_START(tx)
	.cmd		= do_tx,
BAREBOX_CMD_END
----------------

Compile barebox, download to board and run this command

----------------
[barebox at SSR600]:/
# tx
ret is 0
uncompression error
ret is -1
----------------

The result is:

uncompress_fd_to_fd is OK
uncompress_fd_to_buf fail and lib/decompress_inflate.c:gunzip()
output a message "uncompression error"

Anybody help me!

-- 
Best Regards,
zzs




From zzs213 at 126.com  Fri Nov 30 06:03:36 2012
From: zzs213 at 126.com (=?utf-8?B?5byg5b+g5bGx?=)
Date: Fri, 30 Nov 2012 19:03:36 +0800
Subject: Howto known uncompressed length when uncompress_fd_to_buf
Message-ID: <20121130110336.GB7099@greatfirst.com>

the function uncompress_fd_to_buf has no parameter to return
the uncompressed length, How to get the uncompressed content
length?

-- 
Best Regards,
zzs




From jbe at pengutronix.de  Fri Nov 30 06:14:04 2012
From: jbe at pengutronix.de (Juergen Beisert)
Date: Fri, 30 Nov 2012 12:14:04 +0100
Subject: [Patch] ARM/MXS/i.MX28: distinguish POR and wake-up event correctly
Message-ID: <201211301214.05014.jbe@pengutronix.de>

When the built-in RTC in the i.MX28 is programmed to wake-up the SoC, the RTC
reports two events: RST and WAKE. RST is okay in this case, because the PMIC
was really powered down. But the real event is the WAKE from the RTC and
should have precedence over the RST event. So, report the WAKE event for this
special case.

Signed-off-by: Juergen Beisert <jbe at pengutronix.de>

diff --git a/drivers/watchdog/im28wd.c b/drivers/watchdog/im28wd.c
index ca32a72..bc19369 100644
--- a/drivers/watchdog/im28wd.c
+++ b/drivers/watchdog/im28wd.c
@@ -82,6 +82,17 @@ static void __maybe_unused imx28_detect_reset_source(const struct imx28_wd *p)
 	if (reg & MXS_RTC_PERSISTENT0_EXT_RST) {
 		writel(MXS_RTC_PERSISTENT0_EXT_RST,
 			p->regs + MXS_RTC_PERSISTENT0 + MXS_RTC_CLR_ADDR);
+		/*
+		 * if the RTC has woken up the SoC, additionally the ALARM_WAKE
+		 * bit is set. This bit should have precedence, because it
+		 * reports the real event, why we are here.
+		 */
+		if (reg & MXS_RTC_PERSISTENT0_ALARM_WAKE) {
+			writel(MXS_RTC_PERSISTENT0_ALARM_WAKE,
+				p->regs + MXS_RTC_PERSISTENT0 + MXS_RTC_CLR_ADDR);
+			set_reset_source(RESET_WKE);
+			return;
+		}
 		set_reset_source(RESET_POR);
 		return;
 	}


-- 
Pengutronix e.K.                              | Juergen Beisert             |
Linux Solutions for Science and Industry      | http://www.pengutronix.de/  |


From plagnioj at jcrosoft.com  Fri Nov 30 06:38:09 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri, 30 Nov 2012 12:38:09 +0100
Subject: gunzip error when uncompress to buf
In-Reply-To: <20121130110029.GA7099@greatfirst.com>
References: <20121130110029.GA7099@greatfirst.com>
Message-ID: <20121130113809.GC8327@game.jcrosoft.org>

On 19:00 Fri 30 Nov     , ??? wrote:
> On host use the flowwing cmd build a gziped file
> 
> ----------------
> $ gzip -c9 zbarebox.bin > xxx
this is a binary with a decompressor insode you just need to flash it

Best Regards,
J.


From zzs213 at 126.com  Fri Nov 30 06:49:16 2012
From: zzs213 at 126.com (=?utf-8?B?5byg5b+g5bGx?=)
Date: Fri, 30 Nov 2012 19:49:16 +0800
Subject: gunzip error when uncompress to buf
In-Reply-To: <20121130113809.GC8327@game.jcrosoft.org>
References: <20121130110029.GA7099@greatfirst.com>
 <20121130113809.GC8327@game.jcrosoft.org>
Message-ID: <20121130114916.GC7099@greatfirst.com>

In message <20121130113809.GC8327 at game.jcrosoft.org> Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 19:00 Fri 30 Nov     , ??? wrote:
> > On host use the flowwing cmd build a gziped file
> >
> > ----------------
> > $ gzip -c9 zbarebox.bin > xxx
> this is a binary with a decompressor insode you just need to flash it
>

I known zbarebox.bin is a compressed image. I just use this file to
test uncompress_fd_to_buf.

I will compress my fpga firmware and flash it, So I need to uncompress
this image to a buf, then use it to config fpga

But uncompress_fd_to_buf works wrong!

-- 
Best Regards,
zzs




From madhava.koriginja at gmail.com  Fri Nov 30 09:00:38 2012
From: madhava.koriginja at gmail.com (Madhu koriginja)
Date: Fri, 30 Nov 2012 19:30:38 +0530
Subject: How to read a file in UBIFS file system from barebox
Message-ID: <CA+pW49qF1gN6Ty=T44MJzCXkmfwhJC0Lj72-zG+ng=mvX7VRgw@mail.gmail.com>

Hi All,
            I am using UBIFS file system. My kernel is placed in the file
system (/boot/uImage). I want to read the kernel(uImage) from UBIFS file
system at barebox to load the kernel and boot it.
Please give me some ideas how to get this functionality.

Advance thanks,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/barebox/attachments/20121130/0875bab1/attachment.html>

From plagnioj at jcrosoft.com  Fri Nov 30 09:16:18 2012
From: plagnioj at jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
Date: Fri, 30 Nov 2012 15:16:18 +0100
Subject: How to read a file in UBIFS file system from barebox
In-Reply-To: <CA+pW49qF1gN6Ty=T44MJzCXkmfwhJC0Lj72-zG+ng=mvX7VRgw@mail.gmail.com>
References: <CA+pW49qF1gN6Ty=T44MJzCXkmfwhJC0Lj72-zG+ng=mvX7VRgw@mail.gmail.com>
Message-ID: <20121130141618.GD8327@game.jcrosoft.org>

On 19:30 Fri 30 Nov     , Madhu koriginja wrote:
>    Hi All,
>                I am using UBIFS file system. My kernel is placed in the file
>    system (/boot/uImage). I want to read the kernel(uImage) from UBIFS file
>    system at barebox to load the kernel and boot it. 
>    Please give me some ideas how to get this functionality.
we do not have ubifs yet

so you can not today you need to add the ubifs first

Best Regards,
J.


From renaud.barbier at ge.com  Fri Nov 30 11:25:38 2012
From: renaud.barbier at ge.com (Renaud Barbier)
Date: Fri, 30 Nov 2012 16:25:38 +0000
Subject: How to read a file in UBIFS file system from barebox
In-Reply-To: <CA+pW49qF1gN6Ty=T44MJzCXkmfwhJC0Lj72-zG+ng=mvX7VRgw@mail.gmail.com>
References: <CA+pW49qF1gN6Ty=T44MJzCXkmfwhJC0Lj72-zG+ng=mvX7VRgw@mail.gmail.com>
Message-ID: <50B8DE02.1030209@ge.com>

On 30/11/2012 14:00, Madhu koriginja wrote:
> Hi All,
>             I am using UBIFS file system. My kernel is placed in the 
> file system (/boot/uImage). I want to read the kernel(uImage) from 
> UBIFS file system at barebox to load the kernel and boot it.
> Please give me some ideas how to get this functionality.
>
I have ported UBIFS from U-boot.
I can send patches.

zlib compression is commented out and the code is almost as is from U-boot.

> Advance thanks,
>
>
>
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/barebox/attachments/20121130/9b9b779c/attachment.html>

From franck.jullien at gmail.com  Fri Nov 30 11:44:12 2012
From: franck.jullien at gmail.com (Franck Jullien)
Date: Fri, 30 Nov 2012 17:44:12 +0100
Subject: How to read a file in UBIFS file system from barebox
In-Reply-To: <50B8DE02.1030209@ge.com>
References: <CA+pW49qF1gN6Ty=T44MJzCXkmfwhJC0Lj72-zG+ng=mvX7VRgw@mail.gmail.com>
 <50B8DE02.1030209@ge.com>
Message-ID: <CAJfOKByMy3p1c3ouVjFc+apur8kW2mqiHU8bo+Cob5cewa_J3A@mail.gmail.com>

2012/11/30 Renaud Barbier <renaud.barbier at ge.com>:
> On 30/11/2012 14:00, Madhu koriginja wrote:
>
> Hi All,
>             I am using UBIFS file system. My kernel is placed in the file
> system (/boot/uImage). I want to read the kernel(uImage) from UBIFS file
> system at barebox to load the kernel and boot it.
> Please give me some ideas how to get this functionality.
>
> I have ported UBIFS from U-boot.
> I can send patches.
>

Sure that would be great. I was thinking to port any flash fs.


