Re: [PATCH 1/1] smc911x: fix typo pn check if the device is ready before using it

2012-09-10 Thread Sascha Hauer
On Fri, Sep 07, 2012 at 04:11:39PM +0200, Jean-Christophe PLAGNIOL-VILLARD 
wrote:
 the check need to be inverted
 
 Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com

Applied, thanks

Sascha

 ---
  drivers/net/smc911x.c |2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
 index 3ccb0ef..bc1e001 100644
 --- a/drivers/net/smc911x.c
 +++ b/drivers/net/smc911x.c
 @@ -456,7 +456,7 @@ static int smc911x_probe(struct device_d *dev)
* poll the READY bit in PMT_CTRL. Any other access to the device is
* forbidden while this bit isn't set. Try for 100ms
*/
 - ret = wait_on_timeout(100 * MSECOND, smc911x_reg_read(priv, PMT_CTRL)  
 PMT_CTRL_READY);
 + ret = wait_on_timeout(100 * MSECOND, !smc911x_reg_read(priv, PMT_CTRL) 
  PMT_CTRL_READY);
   if (!ret) {
   dev_err(dev, Device not READY in 100ms aborting\n);
   return -ENODEV;
 -- 
 1.7.10.4
 
 
 ___
 barebox mailing list
 barebox@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- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH v2 1/1] boards: Add support for imx233-olinuxino board

2012-09-10 Thread Sascha Hauer
On Sun, Sep 09, 2012 at 05:36:01PM -0400, Fadil Berisha wrote:
 imx23-olinuxino is a board designed by Olimex.
 
 It has the following features:
 
 - Freescale iMX233 ARM926J processor at 454MHz
 -64 MB RAM
 -SD-card connector
 -TV PAL/NTSC video output
 -2 USB High Speed Hosts
 -Ethernet 100 Mbit
 -Stereo Audio Input
 -Stereo Headphones Audio Output
 
 More information at:
 http://www.olimex.com/dev/imx233-olinuxino-maxi.html
 
 Signed-off-by: Fadil Berisha f.kol...@gmail.com

Applied, thanks

Sascha

 ---
  arch/arm/Makefile  |1 +
  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/configs/imx233-olinuxino_defconfig|   63 +
  arch/arm/mach-mxs/Kconfig  |7 +
  9 files changed, 436 insertions(+)
  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/configs/imx233-olinuxino_defconfig
 
 diff --git a/arch/arm/Makefile b/arch/arm/Makefile
 index 8e660be..2adfd12 100644
 --- a/arch/arm/Makefile
 +++ b/arch/arm/Makefile
 @@ -92,6 +92,7 @@ board-$(CONFIG_MACH_FREESCALE_MX25_3STACK)  := 
 freescale-mx25-3-stack
  board-$(CONFIG_MACH_FREESCALE_MX35_3STACK)   := freescale-mx35-3-stack
  board-$(CONFIG_MACH_IMX21ADS):= imx21ads
  board-$(CONFIG_MACH_IMX27ADS):= imx27ads
 +board-$(CONFIG_MACH_IMX233_OLINUXINO):= imx233-olinuxino
  board-$(CONFIG_MACH_MIOA701) := mioa701
  board-$(CONFIG_MACH_MMCCPU)  := mmccpu
  board-$(CONFIG_MACH_NOMADIK_8815NHK) := nhk8815
 diff --git a/arch/arm/boards/imx233-olinuxino/Makefile 
 b/arch/arm/boards/imx233-olinuxino/Makefile
 new file mode 100644
 index 000..6d71450
 --- /dev/null
 +++ b/arch/arm/boards/imx233-olinuxino/Makefile
 @@ -0,0 +1 @@
 +obj-y = imx23-olinuxino.o
 diff --git a/arch/arm/boards/imx233-olinuxino/config.h 
 b/arch/arm/boards/imx233-olinuxino/config.h
 new file mode 100644
 index 000..87d9e2f
 --- /dev/null
 +++ b/arch/arm/boards/imx233-olinuxino/config.h
 @@ -0,0 +1,21 @@
 +/*
 + * 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/imx233-olinuxino/env/bin/boot 
 b/arch/arm/boards/imx233-olinuxino/env/bin/boot
 new file mode 100644
 index 000..60dd93f
 --- /dev/null
 +++ b/arch/arm/boards/imx233-olinuxino/env/bin/boot
 @@ -0,0 +1,32 @@
 +#!/bin/sh
 +
 +. /env/config
 +
 +if [ x$1 = xdisk ]; then
 + rootfs_loc=disk
 + kernel_loc=disk
 +elif [ x$1 = xnet ]; then
 + rootfs_loc=net
 + kernel_loc=net
 +fi
 +
 +if [ x$ip = xdhcp ]; then
 + bootargs=$bootargs ip=dhcp
 +elif [ x$ip = xnone ]; then
 + bootargs=$bootargs ip=none
 +else
 + bootargs=$bootargs ip=$eth0.ipaddr::$eth0.gateway:$eth0.netmask:::
 +fi
 +
 +if [ x$rootfs_loc = xdisk ]; then
 + bootargs=$bootargs noinitrd rootfstype=$rootfs_type 
 root=/dev/$rootfs_part
 +elif [ x$rootfs_loc = xnet ]; then
 + bootargs=$bootargs root=/dev/nfs nfsroot=$nfsroot,v3,tcp noinitrd
 +elif [ x$rootfs_loc = xinitrd ]; then
 + bootargs=$bootargs root=/dev/ram0 rdinit=/sbin/init
 +fi
 +
 +
 +bootm -o $oftree_loc/imx23-olinuxino.dtb /dev/$kernel_part
 +
 +echo Booting failed. Correct setup of 'kernel_part'?
 diff --git a/arch/arm/boards/imx233-olinuxino/env/bin/init 
 b/arch/arm/boards/imx233-olinuxino/env/bin/init
 new file mode 100644
 index 000..3ed68f7
 --- /dev/null
 +++ b/arch/arm/boards/imx233-olinuxino/env/bin/init
 @@ -0,0 +1,15 @@
 +#!/bin/sh
 +
 +PATH=/env/bin
 +export PATH
 +
 +. /env/config
 

Re: [PATCH] mtd: nand: Add K9LBG08U0D chip to flash ids

2012-09-10 Thread Sascha Hauer
On Fri, Sep 07, 2012 at 01:46:20PM +0300, Alex Gershgorin wrote:
 Signed-off-by: Alex Gershgorin al...@meprolight.com

Applied, thanks

Sascha

 ---
  drivers/mtd/nand/nand_ids.c |3 +++
  1 files changed, 3 insertions(+), 0 deletions(-)
 
 diff --git a/drivers/mtd/nand/nand_ids.c b/drivers/mtd/nand/nand_ids.c
 index cb53fc6..469e8dd 100644
 --- a/drivers/mtd/nand/nand_ids.c
 +++ b/drivers/mtd/nand/nand_ids.c
 @@ -118,6 +118,9 @@ struct nand_flash_dev nand_flash_ids[] = {
   {__NANDSTR(NAND 2GiB 1,8V 16-bit),0xB5, 0, 2048, 0, LP_OPTIONS16},
   {__NANDSTR(NAND 2GiB 3,3V 16-bit),0xC5, 0, 2048, 0, LP_OPTIONS16},
  
 + /* 32 Gigabit */
 + {__NANDSTR(NAND 4GiB 3,3V 8-bit), 0xD7, 0, 4096, 0, LP_OPTIONS},
 +
   /*
* Renesas AND 1 Gigabit. Those chips do not support extended id and
* have a strange page/block layout !  The chosen minimum erasesize is
 -- 
 1.7.1
 
 

-- 
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- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 1/3 v2] net: introduce phylib

2012-09-10 Thread Sascha Hauer
On Sun, Sep 09, 2012 at 05:44:00PM +0200, Jean-Christophe PLAGNIOL-VILLARD 
wrote:
 Adapt phylib from linux
 
 switch all the driver to it
 
 This will allow to have
  - phy drivers
  - to only connect the phy at then opening of the device
  - if the phy is not ready fail on open
 
 Same behaviour as in linux and will allow to share code and simplify porting.
 

[...]

 +
 +void mii_unregister(struct mii_device *mdev)
 +{
 + unregister_device(mdev-dev);
 +}
 +
 +static int miidev_init(void)
 +{
 + register_driver(miidev_drv);
 + return 0;
 +}
 +
 +device_initcall(miidev_init);
 +

Nit: Blank line at EOF

 @@ -0,0 +1,36 @@
 +/*
 + * Copyright (c) 2009 Jean-Christophe PLAGNIOL-VILLARD 
 plagn...@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 phydev.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);

Maybe this should be an earlier initcall? The network devices are mostly
at device_initcalls. Does it work when the ethernet device gets probed
before the phy?

 +
 +struct bus_type phy_bustype;
 +static int genphy_config_init(struct phy_device *phydev);
 +
 +struct phy_device *phy_device_create(struct mii_device *bus, int addr, int 
 phy_id)
 +{
 + struct phy_device *dev;
 +
 + /* We allocate the device, and initialize the
 +  * default values */
 + dev = kzalloc(sizeof(*dev), GFP_KERNEL);
 +
 + if (NULL == dev)
 + return (struct phy_device*) PTR_ERR((void*)-ENOMEM);
 +
 + dev-speed = 0;
 + dev-duplex = -1;
 + dev-pause = dev-asym_pause = 0;
 + dev-link = 1;
 + dev-autoneg = AUTONEG_ENABLE;
 +
 + dev-addr = addr;
 + dev-phy_id = phy_id;
 +
 + dev-bus = bus;
 + dev-dev.parent = bus-parent;
 + dev-dev.bus = phy_bustype;
 +
 + strcpy(dev-dev.name, phy);
 + dev-dev.id = DEVICE_ID_DYNAMIC;
 +
 + return dev;
 +}
 +/**
 + * get_phy_id - reads the specified addr for its ID.
 + * @bus: the target MII bus
 + * @addr: PHY address on the MII bus
 + * @phy_id: where to store the ID retrieved.
 + *
 + * Description: Reads the ID registers of the PHY at @addr on the
 + *   @bus, stores it in @phy_id and returns zero on success.
 + */
 +int get_phy_id(struct mii_device *bus, int addr, u32 *phy_id)
 +{
 + int phy_reg;
 +
 + /* Grab the bits from PHYIR1, and put them
 +  * in the upper half */
 + phy_reg = bus-read(bus, addr, MII_PHYSID1);
 +
 + if (phy_reg  0)
 + return -EIO;
 +
 + *phy_id = (phy_reg  0x)  16;
 +
 + /* Grab the bits from PHYIR2, and put them in the lower half */
 + phy_reg = bus-read(bus, addr, MII_PHYSID2);
 +
 + if (phy_reg  0)
 + return -EIO;
 +
 + *phy_id |= (phy_reg  0x);
 +
 + return 0;
 +}
 +
 +/**
 + * get_phy_device - reads the specified PHY device and returns its 
 @phy_device struct
 + * @bus: the target MII bus
 + * @addr: PHY address on the MII bus
 + *
 + * Description: Reads the ID registers of the PHY at @addr on the
 + *   @bus, then allocates and returns the phy_device to represent it.
 + */
 +struct phy_device *get_phy_device(struct mii_device *bus, int addr)
 +{
 + struct phy_device *dev = NULL;
 + u32 phy_id = 0;
 + int r;
 +
 + r = get_phy_id(bus, addr, phy_id);
 + if (r)
 + return ERR_PTR(r);
 +
 + /* If the phy_id is mostly Fs, there is no device there */
 + if ((phy_id  0x1fff) == 0x1fff)
 + return ERR_PTR(-EIO);
 +
 + dev = phy_device_create(bus, addr, phy_id);
 +
 + return dev;
 +}
 +
 +/* Automatically gets and returns the PHY device */
 +int phy_device_connect(struct mii_device *bus, int addr,
 + void (*adjust_link) (struct mii_device *miidev))
 +{
 + struct phy_driver* drv;
 + struct phy_device* dev = NULL;
 + unsigned int i;
 + int ret = -EINVAL;
 +
 + if (!bus-phydev) {
 + if (addr = 0) {
 + dev = get_phy_device(bus, addr);
 + if (IS_ERR(dev)) {

Re: [PATCH 1/3] Introduce ARM AMBA bus

2012-09-10 Thread Sascha Hauer
On Sat, Sep 01, 2012 at 02:36:28PM +0200, Jean-Christophe PLAGNIOL-VILLARD 
wrote:
 This will allow to detect the amba device and use the right driver for it at
 runtime.
 
 The code is base on linux 3.5.
 
 +
 +int amba_driver_register(struct amba_driver *drv)
 +{
 + drv-drv.bus = amba_bustype;
 +#define SETFN(fn)if (drv-fn) drv-drv.fn = amba_##fn
 + SETFN(probe);
 + SETFN(remove);

Can we please drop this SETFN and just open code it? Being able to grep
for amba_probe and finding its users is quite convenient. No, I don't
care that in Linux it's also done like this.

 +struct amba_device *amba_device_alloc(const char *name, int id, 
 resource_size_t base,
 + size_t size)
 +{
 + struct amba_device *dev;
 +
 + dev = xzalloc(sizeof(*dev));
 + if (dev) {

xzalloc always returns a valid pointer.

 + strcpy(dev-dev.name, name);
 + dev-dev.id = id;
 + dev-res.start = base;
 + dev-res.end = base + size - 1;
 + dev-res.flags = IORESOURCE_MEM;
 + }
 +
 + return dev;
 +}
 +
 +/**
 + * struct amba_id - identifies a device on an AMBA bus
 + * @id: The significant bits if the hardware device ID
 + * @mask: Bitmask specifying which bits of the id field are significant when
 + *   matching.  A driver binds to a device when ((hardware device ID)  mask)
 + *   == id.
 + * @data: Private data used by the driver.
 + */
 +struct amba_id {
 + unsigned intid;
 + unsigned intmask;
 +#ifndef __KERNEL__
 + kernel_ulong_t  data;
 +#else
 + void*data;
 +#endif

Drop this ifdef.

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- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH] [RFC] fec: fix calculation of mii bus speed on mxs

2012-09-10 Thread Sascha Hauer
Hi Uwe,

On Thu, Sep 06, 2012 at 03:50:01PM +0200, Uwe Kleine-König wrote:
 According to a comment in Linux' fec driver, i.MX28 uses the same
 formula for determination of the frequency divider as i.MX6, that is
 (different from the i.MX28 manual):
 
   parent clock / ((MII_SPEED + 1) * 2)
 
 instead of
 
   parent clock / (MII_SPEED * 2)
 
 on the older i.MX SoCs. Fix the calculation accordingly.
 
 Signed-off-by: Uwe Kleine-König u.kleine-koe...@pengutronix.de
 --
 But note that this doesn't fix accessing the phy on my machine. The
 calculated value is 9 (with and without this patch btw) but accessing
 the phy only gets reliable with a value of =20 or alternatively don't
 set the SPEED value before reading and writing a mii register but only
 on probe.
 
 The Freescale kernel 2.6.35_10.12.01 does the following instead (in
 fec_switch.c):
 
   fep-phy_speed = DIV_ROUND_UP(clk_get_rate(fep-clk), 500)  1;
 #ifdef CONFIG_ARCH_MXS
   /* Can't get phy(8720) ID when set to 2.5M on MX28, lower it */
   fep-phy_speed = 2;
 #endif
 
 which would result in 40 (and is unaware of the changed formula).
 
 I didn't have an opportunity to check the signals with an oszilloscope, but
 intend to fetch that later.
 ---
  drivers/net/fec_imx.c |   48 ++--
  1 file changed, 38 insertions(+), 10 deletions(-)
 
 diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c
 index 599a9b4..969c903 100644
 --- a/drivers/net/fec_imx.c
 +++ b/drivers/net/fec_imx.c
 @@ -47,6 +47,41 @@ struct fec_frame {
   uint8_t head[16];   /* MAC header(6 + 6 + 2) + 2(aligned) */
  };
  
 +static void fec_miidev_setspeed(struct fec_priv *fec)
 +{
 + u32 mii_speed;
 +
 + mii_speed = DIV_ROUND_UP(imx_get_fecclk(), 500);
 +
 +#ifdef CONFIG_ARCH_MXS
 + /*
 +  * Compared to the other imx socs imx28 and imx6 have an additional +1
 +  * in the formula for MII_SPEED. In MCIMX28RM Rev.1, 2010 this is not
 +  * documented though.
 +  */
 + mii_speed -= 1;
 +#endif

Please use a if (cpu_is_mx28()) instead. While we are at it we should
also do this for i.MX6 and add a cpu_is_mx6() 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- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 1/3] fec: restart autoneg at open instead of init

2012-09-10 Thread Sascha Hauer
Hi Eric,

Regarding the phy issue I have the following plan:

- for -next I think Jean-Christophes phylib will be ready to merge.
  Hopefully it will for for you then again. I think this patch is
  not necessary anymore then.
- for -master I intend to take the miidev: fix 1G wrong detection
  patch which should solve your problem for the next release.

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- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 1/3] fec: restart autoneg at open instead of init

2012-09-10 Thread Eric Bénard
Hi Sascha,

Le Mon, 10 Sep 2012 09:43:36 +0200,
Sascha Hauer s.ha...@pengutronix.de a écrit :
 Regarding the phy issue I have the following plan:
 
 - for -next I think Jean-Christophes phylib will be ready to merge.
   Hopefully it will for for you then again. I think this patch is
   not necessary anymore then.
 - for -master I intend to take the miidev: fix 1G wrong detection
   patch which should solve your problem for the next release.
 
OK, I'll give a try to -next when I find some time.

Eric

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 1/3] ARM lowlevel: Update function documentation

2012-09-10 Thread Sascha Hauer
Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
---
 arch/arm/cpu/start-pbl.c   |3 +++
 arch/arm/cpu/start-reset.c |3 +++
 arch/arm/cpu/start.c   |5 -
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/arch/arm/cpu/start-pbl.c b/arch/arm/cpu/start-pbl.c
index 932a3da..09a1940 100644
--- a/arch/arm/cpu/start-pbl.c
+++ b/arch/arm/cpu/start-pbl.c
@@ -36,6 +36,9 @@
 unsigned long free_mem_ptr;
 unsigned long free_mem_end_ptr;
 
+/*
+ * First instructions in the pbl image
+ */
 void __naked __section(.text_head_entry) pbl_start(void)
 {
barebox_arm_head();
diff --git a/arch/arm/cpu/start-reset.c b/arch/arm/cpu/start-reset.c
index e0df676..fcfdce6 100644
--- a/arch/arm/cpu/start-reset.c
+++ b/arch/arm/cpu/start-reset.c
@@ -29,6 +29,9 @@
 /*
  * The actual reset vector. This code is position independent and usually
  * does not run at the address it's linked at.
+ *
+ * This is either executed in the pbl image (if enabled) or in the regular
+ * image.
  */
 void __naked __bare_init reset(void)
 {
diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c
index 07e7dfe..e43ff9c 100644
--- a/arch/arm/cpu/start.c
+++ b/arch/arm/cpu/start.c
@@ -30,7 +30,7 @@
 
 #ifdef CONFIG_PBL_IMAGE
 /*
- * First function in the pbl image. We get here from
+ * First function in the uncompressed image. We get here from
  * the pbl.
  */
 void __naked __section(.text_entry) start(void)
@@ -47,6 +47,9 @@ void __naked __section(.text_entry) start(void)
 }
 #else
 
+/*
+ * First function in the image without pbl support
+ */
 void __naked __section(.text_entry) start(void)
 {
barebox_arm_head();
-- 
1.7.10.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2] ARM lowlevel

2012-09-10 Thread Sascha Hauer
Changes since v1:

- Make runtime offset function work in thumb2 mode
- Remove accidently prototype changing of board_init_lowlevel_return()


Sascha Hauer (3):
  ARM lowlevel: Update function documentation
  ARM: Add assembler function to get runtime offset
  ARM lowlevel: Use get_runtime_offset

 arch/arm/cpu/start-pbl.c   |   15 ++-
 arch/arm/cpu/start-reset.c |3 +++
 arch/arm/cpu/start.c   |   17 +++--
 arch/arm/include/asm/barebox-arm.h |2 +-
 arch/arm/lib/Makefile  |2 ++
 arch/arm/lib/barebox.lds.S |2 --
 arch/arm/lib/runtime-offset.S  |   17 +
 arch/arm/pbl/zbarebox.lds.S|2 --
 8 files changed, 36 insertions(+), 24 deletions(-)
 create mode 100644 arch/arm/lib/runtime-offset.S

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 3/3] ARM lowlevel: Use get_runtime_offset

2012-09-10 Thread Sascha Hauer
The current approach to get the offset between link and runtime address
is fragile. It requires a big fat comment to put no code above it and it
requires an extra linker section. Instead use a small assembler function.

Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
---
 arch/arm/cpu/start-pbl.c   |   12 +++-
 arch/arm/cpu/start.c   |   12 +++-
 arch/arm/include/asm/barebox-arm.h |1 -
 arch/arm/lib/barebox.lds.S |2 --
 arch/arm/pbl/zbarebox.lds.S|2 --
 5 files changed, 6 insertions(+), 23 deletions(-)

diff --git a/arch/arm/cpu/start-pbl.c b/arch/arm/cpu/start-pbl.c
index 09a1940..5a6b99b 100644
--- a/arch/arm/cpu/start-pbl.c
+++ b/arch/arm/cpu/start-pbl.c
@@ -152,23 +152,17 @@ static void barebox_uncompress(void *compressed_start, 
unsigned int len)
  * Board code can jump here by either returning from board_init_lowlevel
  * or by calling this function directly.
  */
-void __naked __section(.text_ll_return) board_init_lowlevel_return(void)
+void __naked board_init_lowlevel_return(void)
 {
-   uint32_t r, addr, offset;
+   uint32_t r, offset;
uint32_t pg_start, pg_end, pg_len;
 
-   /*
-* Get runtime address of this function. Do not
-* put any code above this.
-*/
-   __asm__ __volatile__(1: adr %0, 1b:=r(addr));
-
/* Setup the stack */
r = STACK_BASE + STACK_SIZE - 16;
__asm__ __volatile__(mov sp, %0 : : r(r));
 
/* Get offset between linked address and runtime address */
-   offset = (uint32_t)__ll_return - addr;
+   offset = get_runtime_offset();
 
pg_start = (uint32_t)input_data - offset;
pg_end = (uint32_t)input_data_end - offset;
diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c
index e43ff9c..1c6a7dd 100644
--- a/arch/arm/cpu/start.c
+++ b/arch/arm/cpu/start.c
@@ -59,22 +59,16 @@ void __naked __section(.text_entry) start(void)
  * Board code can jump here by either returning from board_init_lowlevel
  * or by calling this function directly.
  */
-void __naked __section(.text_ll_return) board_init_lowlevel_return(void)
+void __naked board_init_lowlevel_return(void)
 {
-   uint32_t r, addr, offset;
-
-   /*
-* Get runtime address of this function. Do not
-* put any code above this.
-*/
-   __asm__ __volatile__(1: adr %0, 1b:=r(addr));
+   uint32_t r, offset;
 
/* Setup the stack */
r = STACK_BASE + STACK_SIZE - 16;
__asm__ __volatile__(mov sp, %0 : : r(r));
 
/* Get offset between linked address and runtime address */
-   offset = (uint32_t)__ll_return - addr;
+   offset = get_runtime_offset();
 
/* relocate to link address if necessary */
if (offset)
diff --git a/arch/arm/include/asm/barebox-arm.h 
b/arch/arm/include/asm/barebox-arm.h
index 3639365..a71f420 100644
--- a/arch/arm/include/asm/barebox-arm.h
+++ b/arch/arm/include/asm/barebox-arm.h
@@ -37,7 +37,6 @@ int   board_init(void);
 intdram_init (void);
 
 extern char __exceptions_start[], __exceptions_stop[];
-extern char __ll_return[];
 
 void board_init_lowlevel(void);
 void board_init_lowlevel_return(void);
diff --git a/arch/arm/lib/barebox.lds.S b/arch/arm/lib/barebox.lds.S
index a69013f..40af705 100644
--- a/arch/arm/lib/barebox.lds.S
+++ b/arch/arm/lib/barebox.lds.S
@@ -40,8 +40,6 @@ SECTIONS
_stext = .;
_text = .;
*(.text_entry*)
-   __ll_return = .;
-   *(.text_ll_return*)
__bare_init_start = .;
*(.text_bare_init*)
__bare_init_end = .;
diff --git a/arch/arm/pbl/zbarebox.lds.S b/arch/arm/pbl/zbarebox.lds.S
index 2dca278..37af4e9 100644
--- a/arch/arm/pbl/zbarebox.lds.S
+++ b/arch/arm/pbl/zbarebox.lds.S
@@ -39,8 +39,6 @@ SECTIONS
_stext = .;
_text = .;
*(.text_head_entry*)
-   __ll_return = .;
-   *(.text_ll_return*)
__bare_init_start = .;
*(.text_bare_init*)
__bare_init_end = .;
-- 
1.7.10.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 1/1] uncompress: drop wrong BUG(uncompress_size)

2012-09-10 Thread Sascha Hauer
On Wed, Sep 05, 2012 at 04:59:45PM +0200, Jean-Christophe PLAGNIOL-VILLARD 
wrote:
 As uncompress_size is a static and will set if call uncompress_size multiple
 time.
 
 Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com

Applied, thanks

Sascha

 ---
  lib/uncompress.c |2 --
  1 file changed, 2 deletions(-)
 
 diff --git a/lib/uncompress.c b/lib/uncompress.c
 index cdfebe9..3cf98dd 100644
 --- a/lib/uncompress.c
 +++ b/lib/uncompress.c
 @@ -80,8 +80,6 @@ int uncompress(unsigned char *inbuf, int len,
   int ret;
   char *err;
  
 - BUG_ON(uncompress_size);
 -
   if (inbuf) {
   ft = file_detect_type(inbuf);
   uncompress_buf = NULL;
 -- 
 1.7.10.4
 
 
 ___
 barebox mailing list
 barebox@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- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 1/2] drivers/nor/m25p80: add MTD support

2012-09-10 Thread Jan Luebbe
This has been tested by using UBI with a N25Q128 connected to
a TI McSPI controller.

Signed-off-by: Jan Luebbe j...@pengutronix.de
---
 drivers/nor/m25p80.c |   71 ++
 drivers/nor/m25p80.h |2 +-
 2 files changed, 72 insertions(+), 1 deletion(-)

diff --git a/drivers/nor/m25p80.c b/drivers/nor/m25p80.c
index 61f2195..8775fa9 100644
--- a/drivers/nor/m25p80.c
+++ b/drivers/nor/m25p80.c
@@ -697,6 +697,74 @@ static struct file_operations m25p80_ops = {
.lseek  = dev_lseek_default,
 };
 
+static int m25p_mtd_read(struct mtd_info *mtd, loff_t from, size_t len,
+   size_t *retlen, u_char *buf)
+{
+   struct m25p *flash = container_of(mtd, struct m25p, mtd);
+   ssize_t ret;
+
+   ret = flash-cdev.ops-read(flash-cdev, buf, len, from, 0);
+   if (ret  0) {
+   *retlen = 0;
+   return ret;
+   }
+
+   *retlen = ret;
+   return 0;
+}
+
+static int m25p_mtd_write(struct mtd_info *mtd, loff_t to, size_t len,
+   size_t *retlen, const u_char *buf)
+{
+   struct m25p *flash = container_of(mtd, struct m25p, mtd);
+   ssize_t ret;
+
+   ret = flash-cdev.ops-write(flash-cdev, buf, len, to, 0);
+   if (ret  0) {
+   *retlen = 0;
+   return ret;
+   }
+
+   *retlen = ret;
+   return 0;
+}
+
+static int m25p_mtd_erase(struct mtd_info *mtd, struct erase_info *instr)
+{
+   struct m25p *flash = container_of(mtd, struct m25p, mtd);
+   ssize_t ret;
+
+   ret = flash-cdev.ops-erase(flash-cdev, instr-len, instr-addr);
+
+   if (ret) {
+   instr-state = MTD_ERASE_FAILED;
+   return -EIO;
+   }
+
+   instr-state = MTD_ERASE_DONE;
+   mtd_erase_callback(instr);
+
+   return 0;
+}
+
+static void m25p_init_mtd(struct m25p *flash)
+{
+   struct mtd_info *mtd = flash-mtd;
+
+   mtd-read = m25p_mtd_read;
+   mtd-write = m25p_mtd_write;
+   mtd-erase = m25p_mtd_erase;
+   mtd-size = flash-size;
+   mtd-name = flash-cdev.name;
+   mtd-erasesize = flash-erasesize;
+   mtd-writesize = 1;
+   mtd-subpage_sft = 0;
+   mtd-eraseregions = NULL;
+   mtd-numeraseregions = 0;
+   mtd-flags = MTD_CAP_NORFLASH;
+   flash-cdev.mtd = mtd;
+}
+
 /*
  * board specific setup should have ensured the SPI clock used here
  * matches what the READ command supports, at least until this driver
@@ -828,6 +896,9 @@ static int m25p_probe(struct device_d *dev)
 
dev_info(dev, %s (%lld Kbytes)\n, id-name, (long long)flash-size  
10);
 
+   if (IS_ENABLED(CONFIG_PARTITION_NEED_MTD))
+   m25p_init_mtd(flash);
+
devfs_create(flash-cdev);
 
return 0;
diff --git a/drivers/nor/m25p80.h b/drivers/nor/m25p80.h
index 34bf2e2..957900e 100644
--- a/drivers/nor/m25p80.h
+++ b/drivers/nor/m25p80.h
@@ -46,7 +46,7 @@ struct spi_device_id {
 struct m25p {
struct spi_device   *spi;
struct flash_info   *info;
-   struct mtd_info mtd;
+   struct mtd_info mtd;
struct cdev cdev;
char*name;
u32 erasesize;
-- 
1.7.10.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] arm: mxs: add proper resource length

2012-09-10 Thread Wolfram Sang
For some reason, the mxs-boards missed some length paramters when adding
devices. This made reading from ocotp crash in the current version.
Provide missing lenghts, use a consistent format and fix the length for
the LCDIF.

Signed-off-by: Wolfram Sang w.s...@pengutronix.de
---
 arch/arm/boards/freescale-mx28-evk/mx28-evk.c |   10 +-
 arch/arm/boards/karo-tx28/tx28-stk5.c |   10 +-
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/arm/boards/freescale-mx28-evk/mx28-evk.c 
b/arch/arm/boards/freescale-mx28-evk/mx28-evk.c
index 1283e17..7cd61f9 100644
--- a/arch/arm/boards/freescale-mx28-evk/mx28-evk.c
+++ b/arch/arm/boards/freescale-mx28-evk/mx28-evk.c
@@ -224,19 +224,19 @@ static int mx28_evk_devices_init(void)
armlinux_set_bootparams((void *)IMX_MEMORY_BASE + 0x100);
armlinux_set_architecture(MACH_TYPE_MX28EVK);
 
-   add_generic_device(mxs_mci, 0, NULL, IMX_SSP0_BASE, 0,
+   add_generic_device(mxs_mci, 0, NULL, IMX_SSP0_BASE, 0x2000,
   IORESOURCE_MEM, mci_pdata);
 
-   add_generic_device(stmfb, 0, NULL, IMX_FB_BASE, 4096,
+   add_generic_device(stmfb, 0, NULL, IMX_FB_BASE, 0x2000,
   IORESOURCE_MEM, mx28_evk_fb_pdata);
 
-   add_generic_device(ocotp, 0, NULL, IMX_OCOTP_BASE, 0,
+   add_generic_device(ocotp, 0, NULL, IMX_OCOTP_BASE, 0x2000,
IORESOURCE_MEM, NULL);
mx28_evk_get_ethaddr(); /* must be after registering ocotp */
 
imx_enable_enetclk();
mx28_evk_fec_reset();
-   add_generic_device(fec_imx, 0, NULL, IMX_FEC0_BASE, 0,
+   add_generic_device(fec_imx, 0, NULL, IMX_FEC0_BASE, 0x4000,
   IORESOURCE_MEM, fec_info);
 
return 0;
@@ -245,7 +245,7 @@ device_initcall(mx28_evk_devices_init);
 
 static int mx28_evk_console_init(void)
 {
-   add_generic_device(stm_serial, 0, NULL, IMX_DBGUART_BASE, 8192,
+   add_generic_device(stm_serial, 0, NULL, IMX_DBGUART_BASE, 0x2000,
   IORESOURCE_MEM, NULL);
 
return 0;
diff --git a/arch/arm/boards/karo-tx28/tx28-stk5.c 
b/arch/arm/boards/karo-tx28/tx28-stk5.c
index 04fdbc3..5985ee5 100644
--- a/arch/arm/boards/karo-tx28/tx28-stk5.c
+++ b/arch/arm/boards/karo-tx28/tx28-stk5.c
@@ -376,7 +376,7 @@ void base_board_init(void)
/* run the SSP unit clock at 100 MHz */
imx_set_sspclk(0, 1, 1);
 
-   add_generic_device(mxs_mci, 0, NULL, IMX_SSP0_BASE, 0,
+   add_generic_device(mxs_mci, 0, NULL, IMX_SSP0_BASE, 0x2000,
   IORESOURCE_MEM, mci_pdata);
 
if (tx28_fb_pdata.fixed_screen  (void *)_end) {
@@ -384,16 +384,16 @@ void base_board_init(void)
tx28_fb_pdata.fixed_screen = NULL;
}
 
-   add_generic_device(stmfb, 0, NULL, IMX_FB_BASE, 4096,
+   add_generic_device(stmfb, 0, NULL, IMX_FB_BASE, 0x2000,
   IORESOURCE_MEM, tx28_fb_pdata);
 
-   add_generic_device(ocotp, 0, NULL, IMX_OCOTP_BASE, 0,
+   add_generic_device(ocotp, 0, NULL, IMX_OCOTP_BASE, 0x2000,
   IORESOURCE_MEM, NULL);
 
tx28_get_ethaddr();
 
imx_enable_enetclk();
-   add_generic_device(fec_imx, 0, NULL, IMX_FEC0_BASE, 0,
+   add_generic_device(fec_imx, 0, NULL, IMX_FEC0_BASE, 0x4000,
   IORESOURCE_MEM, fec_info);
 
ret = register_persistent_environment();
@@ -404,7 +404,7 @@ void base_board_init(void)
 
 static int tx28kit_console_init(void)
 {
-   add_generic_device(stm_serial, 0, NULL, IMX_DBGUART_BASE, 8192,
+   add_generic_device(stm_serial, 0, NULL, IMX_DBGUART_BASE, 0x2000,
   IORESOURCE_MEM, NULL);

return 0;
-- 
1.7.10.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH] arm: mxs: add proper resource length

2012-09-10 Thread Uwe Kleine-König
On Mon, Sep 10, 2012 at 11:31:07AM +0200, Wolfram Sang wrote:
 For some reason, the mxs-boards missed some length paramters when adding
 devices. This made reading from ocotp crash in the current version.
 Provide missing lenghts, use a consistent format and fix the length for
s/lenghts/length/

I hit the same problem, but for me it was the fec that failed first :-)

Acked-by: Uwe Kleine-König u.kleine-koe...@pengutronix.de

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] omap: add SPI as a boot mode for xload

2012-09-10 Thread Jan Luebbe
Signed-off-by: Jan Luebbe j...@pengutronix.de
---
 arch/arm/mach-omap/include/mach/xload.h |1 +
 arch/arm/mach-omap/xload.c  |   40 +++
 2 files changed, 41 insertions(+)

diff --git a/arch/arm/mach-omap/include/mach/xload.h 
b/arch/arm/mach-omap/include/mach/xload.h
index 26f1b68..9b44388 100644
--- a/arch/arm/mach-omap/include/mach/xload.h
+++ b/arch/arm/mach-omap/include/mach/xload.h
@@ -8,6 +8,7 @@ enum omap_boot_src {
OMAP_BOOTSRC_UNKNOWN,
OMAP_BOOTSRC_MMC1,
OMAP_BOOTSRC_NAND,
+   OMAP_BOOTSRC_SPI1,
 };
 
 enum omap_boot_src omap3_bootsrc(void);
diff --git a/arch/arm/mach-omap/xload.c b/arch/arm/mach-omap/xload.c
index 0afeea9..31c2e37 100644
--- a/arch/arm/mach-omap/xload.c
+++ b/arch/arm/mach-omap/xload.c
@@ -103,6 +103,42 @@ void *omap_xload_boot_mmc(void)
return buf;
 }
 
+void *omap_xload_boot_spi(int offset)
+{
+   int ret;
+   int size;
+   void *to, *header;
+   struct cdev *cdev;
+
+   devfs_add_partition(m25p0, offset, SZ_1M, DEVFS_PARTITION_FIXED, x);
+
+   header = read_image_head(x);
+   if (header == NULL)
+   return NULL;
+
+   size = get_image_size(header);
+   if (!size) {
+   printf(failed to get image size\n);
+   return NULL;
+   }
+
+   to = xmalloc(size);
+
+   cdev = cdev_open(x, O_RDONLY);
+   if (!cdev) {
+   printf(failed to open spi flash\n);
+   return NULL;
+   }
+
+   ret = cdev_read(cdev, to, size, 0, 0);
+   if (ret != size) {
+   printf(failed to read from spi flash\n);
+   return NULL;
+   }
+
+   return to;
+}
+
 enum omap_boot_src omap_bootsrc(void)
 {
 #if defined(CONFIG_ARCH_OMAP3)
@@ -131,6 +167,10 @@ int run_shell(void)
printf(booting from NAND\n);
func = omap_xload_boot_nand(SZ_128K);
break;
+   case OMAP_BOOTSRC_SPI1:
+   printf(booting from SPI1\n);
+   func = omap_xload_boot_spi(SZ_128K);
+   break;
}
 
if (!func) {
-- 
1.7.10.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH] omap: add SPI as a boot mode for xload

2012-09-10 Thread Jan Lübbe
Note that this applies on top of Jan Weitzel's 'xload: get barebox size
from barebox_arm_head'.
-- 
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- |


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


RE: [PATCH] video imx-ipu-fb: add clear screen

2012-09-10 Thread Alex Gershgorin
Hi Sascha,

 On Fri, Sep 07, 2012 at 01:46:39PM +0300, Alex Gershgorin wrote:
 This patch clear screen before usage

 Signed-off-by: Alex Gershgorin al...@meprolight.com
 ---
  drivers/video/imx-ipu-fb.c |4 
  1 files changed, 4 insertions(+), 0 deletions(-)

 diff --git a/drivers/video/imx-ipu-fb.c b/drivers/video/imx-ipu-fb.c
 index 8039de0..d46cced 100644
 --- a/drivers/video/imx-ipu-fb.c
 +++ b/drivers/video/imx-ipu-fb.c
 @@ -1012,6 +1012,10 @@ static int imxfb_probe(struct device_d *dev)
  (info-bits_per_pixel  3));
   if (!fbi-info.screen_base)
   return -ENOMEM;
 +
 + /* Clear the screen */
 + memset((char *)fbi-info.screen_base, 0,
 + info-xres * info-yres * (info-bits_per_pixel  3));

  Not clearing the screen is intentional. Normally the fb drivers do not
  enable the framebuffer until explicitely requested via fb0.enable=1. The
  environment normally is supposed to set a picture on the screen and
  enable it afterwards.
  That said, we can clear the screen as with MMU enabled this probably
  does not take long time. But then it should be done in the fb core.

Thanks for your explanation.
In my case, I displayed picture on the screen, of course as you said I added to 
init script   
fb0.enable = 1
bmp / env / logo.bmp
it was easy.

The problem is that I have a screen with resolution 800x600, but picture that I 
displayed on the my screen is much smaller,
resulting in a picture is displayed fine, but on the sides I get garbage. 
This patch fixes this issue, of course it is not the only way to solve this 
issue.

Regards,
Alex
___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH] omap: add SPI as a boot mode for xload

2012-09-10 Thread Baruch Siach
Hi Jan,

On Mon, Sep 10, 2012 at 11:50:24AM +0200, Jan Luebbe wrote:
 Signed-off-by: Jan Luebbe j...@pengutronix.de
 ---
  arch/arm/mach-omap/include/mach/xload.h |1 +
  arch/arm/mach-omap/xload.c  |   40 
 +++
  2 files changed, 41 insertions(+)

[snip]

 +void *omap_xload_boot_spi(int offset)

static?

baruch

-- 
 http://baruch.siach.name/blog/  ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] fsl TSEC: register map boundary

2012-09-10 Thread Renaud Barbier
The end boundary of each registers set may overlap with the start
of the next register set. Subtract 1 to the end boundary.

Signed-off-by: Renaud Barbier renaud.barb...@ge.com
---
 arch/ppc/mach-mpc85xx/eth-devices.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/ppc/mach-mpc85xx/eth-devices.c 
b/arch/ppc/mach-mpc85xx/eth-devices.c
index 02a3722..c6e8f36 100644
--- a/arch/ppc/mach-mpc85xx/eth-devices.c
+++ b/arch/ppc/mach-mpc85xx/eth-devices.c
@@ -32,15 +32,15 @@ int fsl_eth_init(int num, struct gfar_info_struct *gf)
res = xzalloc(3 * sizeof(struct resource));
/* TSEC interface registers */
res[0].start = GFAR_BASE_ADDR + ((num - 1) * 0x1000);
-   res[0].end = res[0].start + 0x1000;
+   res[0].end = res[0].start + 0x1000 - 1;
res[0].flags = IORESOURCE_MEM;
/* External PHY access always through eTSEC1 */
res[1].start = MDIO_BASE_ADDR;
-   res[1].end = res[1].start + 0x1000;
+   res[1].end = res[1].start + 0x1000 - 1;
res[1].flags = IORESOURCE_MEM;
/* Access to TBI/RTBI interface. */
res[2].start = MDIO_BASE_ADDR + ((num - 1) * 0x1000);
-   res[2].end = res[2].start + 0x1000;
+   res[2].end = res[2].start + 0x1000 - 1;
res[2].flags = IORESOURCE_MEM;
 
add_generic_device_res(gfar, DEVICE_ID_DYNAMIC, res, 3, gf);
-- 
1.7.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] smsc911x: Check platformdata pointer

2012-09-10 Thread Jan Weitzel
If pdata is NULL smc911x_probe will crash. Checking the zero initialized
priv-shift results in default configuration if pdata is not set.

Signed-off-by: Jan Weitzel j.weit...@phytec.de
---
 drivers/net/smc911x.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index bc1e001..f697608 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -435,7 +435,7 @@ static int smc911x_probe(struct device_d *dev)
priv-shift = pdata-shift;
 
if (is_32bit) {
-   if (pdata-shift) {
+   if (priv-shift) {
priv-reg_read = __smc911x_reg_readl_shift;
priv-reg_write = __smc911x_reg_writel_shift;
} else {
@@ -443,7 +443,7 @@ static int smc911x_probe(struct device_d *dev)
priv-reg_write = __smc911x_reg_writel;
}
} else {
-   if (pdata-shift) {
+   if (priv-shift) {
priv-reg_read = __smc911x_reg_readw_shift;
priv-reg_write = __smc911x_reg_writew_shift;
} else {
-- 
1.7.0.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 1/2] drivers/nor/m25p80: add MTD support

2012-09-10 Thread Sascha Hauer
On Mon, Sep 10, 2012 at 10:55:46AM +0200, Jan Luebbe wrote:
 This has been tested by using UBI with a N25Q128 connected to
 a TI McSPI controller.
 
 Signed-off-by: Jan Luebbe j...@pengutronix.de

Applied, thanks

Sascha

 ---
  drivers/nor/m25p80.c |   71 
 ++
  drivers/nor/m25p80.h |2 +-
  2 files changed, 72 insertions(+), 1 deletion(-)
 
 diff --git a/drivers/nor/m25p80.c b/drivers/nor/m25p80.c
 index 61f2195..8775fa9 100644
 --- a/drivers/nor/m25p80.c
 +++ b/drivers/nor/m25p80.c
 @@ -697,6 +697,74 @@ static struct file_operations m25p80_ops = {
   .lseek  = dev_lseek_default,
  };
  
 +static int m25p_mtd_read(struct mtd_info *mtd, loff_t from, size_t len,
 + size_t *retlen, u_char *buf)
 +{
 + struct m25p *flash = container_of(mtd, struct m25p, mtd);
 + ssize_t ret;
 +
 + ret = flash-cdev.ops-read(flash-cdev, buf, len, from, 0);
 + if (ret  0) {
 + *retlen = 0;
 + return ret;
 + }
 +
 + *retlen = ret;
 + return 0;
 +}
 +
 +static int m25p_mtd_write(struct mtd_info *mtd, loff_t to, size_t len,
 + size_t *retlen, const u_char *buf)
 +{
 + struct m25p *flash = container_of(mtd, struct m25p, mtd);
 + ssize_t ret;
 +
 + ret = flash-cdev.ops-write(flash-cdev, buf, len, to, 0);
 + if (ret  0) {
 + *retlen = 0;
 + return ret;
 + }
 +
 + *retlen = ret;
 + return 0;
 +}
 +
 +static int m25p_mtd_erase(struct mtd_info *mtd, struct erase_info *instr)
 +{
 + struct m25p *flash = container_of(mtd, struct m25p, mtd);
 + ssize_t ret;
 +
 + ret = flash-cdev.ops-erase(flash-cdev, instr-len, instr-addr);
 +
 + if (ret) {
 + instr-state = MTD_ERASE_FAILED;
 + return -EIO;
 + }
 +
 + instr-state = MTD_ERASE_DONE;
 + mtd_erase_callback(instr);
 +
 + return 0;
 +}
 +
 +static void m25p_init_mtd(struct m25p *flash)
 +{
 + struct mtd_info *mtd = flash-mtd;
 +
 + mtd-read = m25p_mtd_read;
 + mtd-write = m25p_mtd_write;
 + mtd-erase = m25p_mtd_erase;
 + mtd-size = flash-size;
 + mtd-name = flash-cdev.name;
 + mtd-erasesize = flash-erasesize;
 + mtd-writesize = 1;
 + mtd-subpage_sft = 0;
 + mtd-eraseregions = NULL;
 + mtd-numeraseregions = 0;
 + mtd-flags = MTD_CAP_NORFLASH;
 + flash-cdev.mtd = mtd;
 +}
 +
  /*
   * board specific setup should have ensured the SPI clock used here
   * matches what the READ command supports, at least until this driver
 @@ -828,6 +896,9 @@ static int m25p_probe(struct device_d *dev)
  
   dev_info(dev, %s (%lld Kbytes)\n, id-name, (long long)flash-size  
 10);
  
 + if (IS_ENABLED(CONFIG_PARTITION_NEED_MTD))
 + m25p_init_mtd(flash);
 +
   devfs_create(flash-cdev);
  
   return 0;
 diff --git a/drivers/nor/m25p80.h b/drivers/nor/m25p80.h
 index 34bf2e2..957900e 100644
 --- a/drivers/nor/m25p80.h
 +++ b/drivers/nor/m25p80.h
 @@ -46,7 +46,7 @@ struct spi_device_id {
  struct m25p {
   struct spi_device   *spi;
   struct flash_info   *info;
 - struct mtd_info mtd;
 + struct mtd_info mtd;
   struct cdev cdev;
   char*name;
   u32 erasesize;
 -- 
 1.7.10.4
 
 
 ___
 barebox mailing list
 barebox@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- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH] smsc911x: Check platformdata pointer

2012-09-10 Thread Sascha Hauer
On Mon, Sep 10, 2012 at 01:33:29PM +0200, Jan Weitzel wrote:
 If pdata is NULL smc911x_probe will crash. Checking the zero initialized
 priv-shift results in default configuration if pdata is not set.
 
 Signed-off-by: Jan Weitzel j.weit...@phytec.de

Applied, thanks

Sascha

 ---
  drivers/net/smc911x.c |4 ++--
  1 files changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
 index bc1e001..f697608 100644
 --- a/drivers/net/smc911x.c
 +++ b/drivers/net/smc911x.c
 @@ -435,7 +435,7 @@ static int smc911x_probe(struct device_d *dev)
   priv-shift = pdata-shift;
  
   if (is_32bit) {
 - if (pdata-shift) {
 + if (priv-shift) {
   priv-reg_read = __smc911x_reg_readl_shift;
   priv-reg_write = __smc911x_reg_writel_shift;
   } else {
 @@ -443,7 +443,7 @@ static int smc911x_probe(struct device_d *dev)
   priv-reg_write = __smc911x_reg_writel;
   }
   } else {
 - if (pdata-shift) {
 + if (priv-shift) {
   priv-reg_read = __smc911x_reg_readw_shift;
   priv-reg_write = __smc911x_reg_writew_shift;
   } else {
 -- 
 1.7.0.4
 
 
 ___
 barebox mailing list
 barebox@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- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 0/3 v2] AMBA Bus support

2012-09-10 Thread Jean-Christophe PLAGNIOL-VILLARD
Hi,

v2: upadte comment

this first patch series add the AMBA Bus support and is a preperation
for the adding of the ST-E ux500 support

please pull
The following changes since commit 298d15571da8d1cb71e7fd87cc53cad3b2bf1d12:

  i.MX51: unbreak FEC iomux (2012-09-07 10:28:17 +0200)

are available in the git repository at:

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

for you to fetch changes up to 75a0136ccae3899aee91f1d8d38274c426f99175:

  amba-pl011: add st specific init (2012-09-11 12:48:34 +0800)


arm: Introduce ARM AMBA bus

This allow to detect the amba device and use the right driver for it at
runtime.

With pl011 amba support (ARM  ST Variant)

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com


Jean-Christophe PLAGNIOL-VILLARD (3):
  Introduce ARM AMBA bus
  amba-pl011: switch to amba bus
  amba-pl011: add st specific init

 arch/arm/mach-nomadik/8815.c   |9 +++
 arch/arm/mach-versatile/core.c |7 --
 drivers/Makefile   |1 +
 drivers/amba/Makefile  |2 ++
 drivers/amba/bus.c |  210 
+
 drivers/serial/amba-pl011.c|   74 
+++--
 include/linux/amba/bus.h   |  153 
+
 include/linux/amba/serial.h|   29 +++
 8 files changed, 467 insertions(+), 18 deletions(-)
 create mode 100644 drivers/amba/Makefile
 create mode 100644 drivers/amba/bus.c
 create mode 100644 include/linux/amba/bus.h

Best Regards,
J.

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 3/3] amba-pl011: add st specific init

2012-09-10 Thread Jean-Christophe PLAGNIOL-VILLARD
This is need on the new IP for ux500

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 drivers/serial/amba-pl011.c |   40 ++--
 include/linux/amba/serial.h |   29 +
 2 files changed, 67 insertions(+), 2 deletions(-)

diff --git a/drivers/serial/amba-pl011.c b/drivers/serial/amba-pl011.c
index 77f8c8a..b62dc9f 100644
--- a/drivers/serial/amba-pl011.c
+++ b/drivers/serial/amba-pl011.c
@@ -45,6 +45,23 @@ struct amba_uart_port {
struct console_device   uart;   /* uart */
struct clk  *clk;   /* uart clock */
u32 uartclk;
+   struct vendor_data  *vendor;
+};
+
+/* There is by now at least one vendor with differing details, so handle it */
+struct vendor_data {
+   unsigned intlcrh_tx;
+   unsigned intlcrh_rx;
+};
+
+static struct vendor_data vendor_arm = {
+   .lcrh_tx= UART011_LCRH,
+   .lcrh_rx= UART011_LCRH,
+};
+
+static struct vendor_data vendor_st = {
+   .lcrh_tx= ST_UART011_LCRH_TX,
+   .lcrh_rx= ST_UART011_LCRH_RX,
 };
 
 static inline struct amba_uart_port *
@@ -117,6 +134,23 @@ static int pl011_tstc(struct console_device *cdev)
return !(readl(uart-base + UART01x_FR)  UART01x_FR_RXFE);
 }
 
+static void pl011_rlcr(struct amba_uart_port *uart, u32 lcr)
+{
+   struct vendor_data  *vendor = uart-vendor;
+
+   writew(lcr, uart-base + vendor-lcrh_rx);
+   if (vendor-lcrh_tx != vendor-lcrh_rx) {
+   int i;
+   /*
+* Wait 10 PCLKs before writing LCRH_TX register,
+* to get this delay write read only register 10 times
+*/
+   for (i = 0; i  10; ++i)
+   writew(0xff, uart-base + UART011_MIS);
+   writew(lcr, uart-base +  vendor-lcrh_tx);
+   }
+}
+
 int pl011_init_port (struct console_device *cdev)
 {
struct amba_uart_port *uart = to_amba_uart_port(cdev);
@@ -140,8 +174,7 @@ int pl011_init_port (struct console_device *cdev)
/*
 ** Set the UART to be 8 bits, 1 stop bit, no parity, fifo enabled.
 */
-   writel((UART01x_LCRH_WLEN_8 | UART01x_LCRH_FEN),
-  uart-base + UART011_LCRH);
+   pl011_rlcr(uart, UART01x_LCRH_WLEN_8 | UART01x_LCRH_FEN);
 
/*
 ** Finally, enable the UART
@@ -160,6 +193,7 @@ static int pl011_probe(struct amba_device *dev, const 
struct amba_id *id)
uart = xzalloc(sizeof(struct amba_uart_port));
uart-clk = clk_get(dev-dev, NULL);
uart-base = amba_get_mem_region(dev);
+   uart-vendor = (void*)id-data;
 
if (IS_ERR(uart-clk))
return PTR_ERR(uart-clk);
@@ -185,10 +219,12 @@ static struct amba_id pl011_ids[] = {
{
.id = 0x00041011,
.mask   = 0x000f,
+   .data   = vendor_arm,
},
{
.id = 0x00380802,
.mask   = 0x00ff,
+   .data   = vendor_st,
},
{ 0, 0 },
 };
diff --git a/include/linux/amba/serial.h b/include/linux/amba/serial.h
index f4d7bf8..6670f1f 100644
--- a/include/linux/amba/serial.h
+++ b/include/linux/amba/serial.h
@@ -32,16 +32,20 @@
 #define UART01x_RSR0x04/* Receive status register (Read). */
 #define UART01x_ECR0x04/* Error clear register (Write). */
 #define UART010_LCRH   0x08/* Line control register, high byte. */
+#define ST_UART011_DMAWM   0x08/* DMA watermark configure register. */
 #define UART010_LCRM   0x0C/* Line control register, middle byte. 
*/
+#define ST_UART011_TIMEOUT 0x0C/* Timeout period register. */
 #define UART010_LCRL   0x10/* Line control register, low byte. */
 #define UART010_CR 0x14/* Control register. */
 #define UART01x_FR 0x18/* Flag register (Read only). */
 #define UART010_IIR0x1C/* Interrupt indentification register 
(Read). */
 #define UART010_ICR0x1C/* Interrupt clear register (Write). */
+#define ST_UART011_LCRH_RX 0x1C/* Rx line control register. */
 #define UART01x_ILPR   0x20/* IrDA low power counter register. */
 #define UART011_IBRD   0x24/* Integer baud rate divisor register. 
*/
 #define UART011_FBRD   0x28/* Fractional baud rate divisor 
register. */
 #define UART011_LCRH   0x2c/* Line control register. */
+#define ST_UART011_LCRH_TX 0x2c/* Tx Line control register. */
 #define UART011_CR 0x30/* Control register. */
 #define UART011_IFLS   0x34/* Interrupt fifo level select. */
 #define UART011_IMSC   0x38/* Interrupt mask. */
@@ -49,6 +53,15 @@
 #define UART011_MIS0x40/* Masked interrupt status. */
 

[PATCH 1/3] Introduce ARM AMBA bus

2012-09-10 Thread Jean-Christophe PLAGNIOL-VILLARD
This will allow to detect the amba device and use the right driver for it at
runtime.

The code is base on linux 3.5.

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 drivers/Makefile |1 +
 drivers/amba/Makefile|2 +
 drivers/amba/bus.c   |  210 ++
 include/linux/amba/bus.h |  153 +
 4 files changed, 366 insertions(+)
 create mode 100644 drivers/amba/Makefile
 create mode 100644 drivers/amba/bus.c
 create mode 100644 include/linux/amba/bus.h

diff --git a/drivers/Makefile b/drivers/Makefile
index 28a5cb8..0b44e90 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -1,4 +1,5 @@
 obj-y  += base/
+obj-$(CONFIG_ARM_AMBA) += amba/
 obj-y  += net/
 obj-y  += serial/
 obj-y  += mtd/
diff --git a/drivers/amba/Makefile b/drivers/amba/Makefile
new file mode 100644
index 000..a4a511b
--- /dev/null
+++ b/drivers/amba/Makefile
@@ -0,0 +1,2 @@
+
+obj-y += bus.o
diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
new file mode 100644
index 000..383c77e
--- /dev/null
+++ b/drivers/amba/bus.c
@@ -0,0 +1,210 @@
+/*
+ * Copyright (C) 2003 Deep Blue Solutions Ltd, All Rights Reserved.
+ * Copyright (c) 2012 Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
+ *
+ * Under GPLv2.
+ */
+#include common.h
+#include driver.h
+#include linux/clk.h
+#include linux/amba/bus.h
+#include io.h
+
+#define to_amba_driver(d)  container_of(d, struct amba_driver, drv)
+
+static const struct amba_id *
+amba_lookup(const struct amba_id *table, struct amba_device *dev)
+{
+   int ret = 0;
+
+   while (table-mask) {
+   ret = (dev-periphid  table-mask) == table-id;
+   if (ret)
+   break;
+   table++;
+   }
+
+   return ret ? table : NULL;
+}
+
+static int amba_match(struct device_d *dev, struct driver_d *drv)
+{
+   struct amba_device *pcdev = to_amba_device(dev);
+
+   struct amba_driver *pcdrv = to_amba_driver(drv);
+
+   return amba_lookup(pcdrv-id_table, pcdev) == NULL;
+}
+
+static int amba_get_enable_pclk(struct amba_device *pcdev)
+{
+   struct clk *pclk = clk_get(pcdev-dev, apb_pclk);
+   int ret;
+
+   pcdev-pclk = pclk;
+
+   if (IS_ERR(pclk))
+   return PTR_ERR(pclk);
+
+   ret = clk_enable(pclk);
+   if (ret) {
+   clk_put(pclk);
+   }
+
+   return ret;
+}
+
+static int amba_probe(struct device_d *dev)
+{
+   struct amba_device *pcdev = to_amba_device(dev);
+   struct amba_driver *pcdrv = to_amba_driver(dev-driver);
+   const struct amba_id *id = amba_lookup(pcdrv-id_table, pcdev);
+
+   return pcdrv-probe(pcdev, id);
+}
+
+static void amba_remove(struct device_d *dev)
+{
+   struct amba_device *pcdev = to_amba_device(dev);
+   struct amba_driver *drv = to_amba_driver(dev-driver);
+
+   drv-remove(pcdev);
+}
+
+struct bus_type amba_bustype = {
+   .name = amba,
+   .match = amba_match,
+   .probe = amba_probe,
+   .remove = amba_remove,
+};
+
+int amba_driver_register(struct amba_driver *drv)
+{
+   drv-drv.bus = amba_bustype;
+
+   if (drv-probe)
+   drv-drv.probe = amba_probe;
+   if (drv-remove)
+   drv-drv.remove = amba_remove;
+
+   return register_driver(drv-drv);
+}
+
+/**
+ * amba_device_add - add a previously allocated AMBA device structure
+ * @dev: AMBA device allocated by amba_device_alloc
+ * @parent: resource parent for this devices resources
+ *
+ * Claim the resource, and read the device cell ID if not already
+ * initialized.  Register the AMBA device with the Linux device
+ * manager.
+ */
+int amba_device_add(struct amba_device *dev)
+{
+   u32 size;
+   void __iomem *tmp;
+   int i, ret;
+   struct resource *res = NULL;
+
+   dev-dev.bus = amba_bustype;
+
+   /*
+* Dynamically calculate the size of the resource
+* and use this for iomap
+*/
+   size = resource_size(dev-res);
+   res = request_iomem_region(amba, dev-res.start, dev-res.end);
+   if (!res)
+   return -ENOMEM;
+   dev-base = tmp = (void __force __iomem *)res-start;
+   if (!tmp) {
+   ret = -ENOMEM;
+   goto err_release;
+   }
+
+   /* Hard-coded primecell ID instead of plug-n-play */
+   if (dev-periphid != 0)
+   goto skip_probe;
+
+   ret = amba_get_enable_pclk(dev);
+   if (ret == 0) {
+   u32 pid, cid;
+
+   /*
+* Read pid and cid based on size of resource
+* they are located at end of region
+*/
+   for (pid = 0, i = 0; i  4; i++)
+   pid |= (readl(tmp + size - 0x20 + 4 * i)  255) 
+   (i * 8);
+   for (cid = 0, i = 0; i  4; i++)
+   cid |= (readl(tmp + size - 

[PATCH 2/3] amba-pl011: switch to amba bus

2012-09-10 Thread Jean-Christophe PLAGNIOL-VILLARD
switch as the same time the nomadik and versatile arch that use the driver.

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 arch/arm/mach-nomadik/8815.c   |9 +
 arch/arm/mach-versatile/core.c |7 +--
 drivers/serial/amba-pl011.c|   34 --
 3 files changed, 34 insertions(+), 16 deletions(-)

diff --git a/arch/arm/mach-nomadik/8815.c b/arch/arm/mach-nomadik/8815.c
index e385598..aecd9e0 100644
--- a/arch/arm/mach-nomadik/8815.c
+++ b/arch/arm/mach-nomadik/8815.c
@@ -25,6 +25,7 @@
 #include mach/hardware.h
 #include asm/armlinux.h
 #include generated/mach-types.h
+#include linux/amba/bus.h
 
 #include clock.h
 
@@ -32,12 +33,15 @@ static struct clk st8815_clk_48 = {
.rate = 48 * 1000 * 1000,
 };
 
+static struct clk st8815_dummy;
+
 void st8815_add_device_sdram(u32 size)
 {
arm_add_mem_device(ram0, 0x, size);
 }
 
 static struct clk_lookup clocks_lookups[] = {
+   CLKDEV_CON_ID(apb_pclk, st8815_dummy),
CLKDEV_DEV_ID(uart-pl0110, st8815_clk_48),
CLKDEV_DEV_ID(uart-pl0111, st8815_clk_48),
 };
@@ -53,7 +57,6 @@ postcore_initcall(st8815_clkdev_init);
 void st8815_register_uart(unsigned id)
 {
resource_size_t start;
-   struct device_d *dev;
 
switch (id) {
case 0:
@@ -63,7 +66,5 @@ void st8815_register_uart(unsigned id)
start = NOMADIK_UART1_BASE;
break;
}
-   dev = add_generic_device(uart-pl011, id, NULL, start, 4096,
-  IORESOURCE_MEM, NULL);
-   nmdk_clk_create(st8815_clk_48, dev_name(dev));
+   amba_apb_device_add(NULL, uart-pl011, id, start, 4096, NULL, 0);
 }
diff --git a/arch/arm/mach-versatile/core.c b/arch/arm/mach-versatile/core.c
index bdf48f9..86cc755 100644
--- a/arch/arm/mach-versatile/core.c
+++ b/arch/arm/mach-versatile/core.c
@@ -34,6 +34,7 @@
 #include linux/clkdev.h
 #include linux/clk.h
 #include linux/err.h
+#include linux/amba/bus.h
 
 #include io.h
 #include asm/hardware/arm_timer.h
@@ -51,6 +52,8 @@ struct clk {
unsigned long rate;
 };
 
+static struct clk ref_clk_dummy;
+
 static struct clk ref_clk_24 = {
.rate = 2400,
 };
@@ -145,6 +148,7 @@ static int vpb_clocksource_init(void)
 core_initcall(vpb_clocksource_init);
 
 static struct clk_lookup clocks_lookups[] = {
+   CLKDEV_CON_ID(apb_pclk, ref_clk_dummy),
CLKDEV_DEV_ID(uart-pl0110, ref_clk_24),
CLKDEV_DEV_ID(uart-pl0111, ref_clk_24),
CLKDEV_DEV_ID(uart-pl0112, ref_clk_24),
@@ -179,8 +183,7 @@ void versatile_register_uart(unsigned id)
default:
return;
}
-   add_generic_device(uart-pl011, id, NULL, start, 4096,
-  IORESOURCE_MEM, NULL);
+   amba_apb_device_add(NULL, uart-pl011, id, start, 4096, NULL, 0);
 }
 
 void __noreturn reset_cpu (unsigned long ignored)
diff --git a/drivers/serial/amba-pl011.c b/drivers/serial/amba-pl011.c
index f8c55c4..77f8c8a 100644
--- a/drivers/serial/amba-pl011.c
+++ b/drivers/serial/amba-pl011.c
@@ -35,6 +35,7 @@
 #include linux/amba/serial.h
 #include linux/clk.h
 #include linux/err.h
+#include linux/amba/bus.h
 
 /*
  * We wrap our port structure around the generic console_device.
@@ -118,11 +119,8 @@ static int pl011_tstc(struct console_device *cdev)
 
 int pl011_init_port (struct console_device *cdev)
 {
-   struct device_d *dev = cdev-dev;
struct amba_uart_port *uart = to_amba_uart_port(cdev);
 
-   uart-base = dev_request_mem_region(dev, 0);
-
/*
 ** First, disable everything.
 */
@@ -154,19 +152,20 @@ int pl011_init_port (struct console_device *cdev)
return 0;
 }
 
-static int pl011_probe(struct device_d *dev)
+static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
 {
struct amba_uart_port *uart;
struct console_device *cdev;
 
uart = xzalloc(sizeof(struct amba_uart_port));
-   uart-clk = clk_get(dev, NULL);
+   uart-clk = clk_get(dev-dev, NULL);
+   uart-base = amba_get_mem_region(dev);
 
if (IS_ERR(uart-clk))
return PTR_ERR(uart-clk);
 
cdev = uart-uart;
-   cdev-dev = dev;
+   cdev-dev = dev-dev;
cdev-f_caps = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR;
cdev-tstc = pl011_tstc;
cdev-putc = pl011_putc;
@@ -182,14 +181,29 @@ static int pl011_probe(struct device_d *dev)
return 0;
 }
 
-static struct driver_d pl011_driver = {
-   .name = uart-pl011,
-   .probe = pl011_probe,
+static struct amba_id pl011_ids[] = {
+   {
+   .id = 0x00041011,
+   .mask   = 0x000f,
+   },
+   {
+   .id = 0x00380802,
+   .mask   = 0x00ff,
+   },
+   { 0, 0 },
+};
+
+struct amba_driver pl011_driver = {
+   .drv = {
+   .name = uart-pl011,
+   },
+   .probe  = pl011_probe,
+   .id_table   

[PATCH 1/1] genenv: fix files copy

2012-09-10 Thread Jean-Christophe PLAGNIOL-VILLARD
we may specify file in the defconfig

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 scripts/genenv |6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/scripts/genenv b/scripts/genenv
index c84af0c..ff7972b 100755
--- a/scripts/genenv
+++ b/scripts/genenv
@@ -11,7 +11,11 @@ shift 2
 tempdir=$(mktemp -d tmp.XX)
 
 for i in $*; do
-   cp -r $i/* $tempdir
+   if [ -d $i ]; then
+   cp -r $i/* $tempdir
+   else
+   cp -a $i $tempdir
+   fi
 done
 
 find $tempdir -name '.svn' -o -name '*~' | xargs --no-run-if-empty rm -r
-- 
1.7.10.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 1/3] sandbox-unaligned: better usement of ifdef

2012-09-10 Thread Alexander Aring
GCC versions below 4.6 don't set __BYTE_ORDER__
with __ORDER_LITTLE_ENDIAN__. So it's better to use
__BYTE_ORDER and __LITTLE_ENDIAN instead.

Signed-off-by: Alexander Aring alex.ar...@gmail.com
---
 arch/sandbox/include/asm/unaligned.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/sandbox/include/asm/unaligned.h 
b/arch/sandbox/include/asm/unaligned.h
index 07c1ae4..d02da6e 100644
--- a/arch/sandbox/include/asm/unaligned.h
+++ b/arch/sandbox/include/asm/unaligned.h
@@ -8,7 +8,7 @@
 #include linux/unaligned/access_ok.h
 #include linux/unaligned/generic.h
 
-#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+#if __BYTE_ORDER == __LITTLE_ENDIAN
 #define get_unaligned __get_unaligned_le
 #define put_unaligned __put_unaligned_le
 #else
-- 
1.7.12


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 2/3] sandbox: fix posix_types

2012-09-10 Thread Alexander Aring
Fix setting of size_t ssize_t and ptrdiff_t for 32 bit and
64 bit systems.

Signed-off-by: Alexander Aring alex.ar...@gmail.com
---
 arch/sandbox/include/asm/posix_types.h | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/arch/sandbox/include/asm/posix_types.h 
b/arch/sandbox/include/asm/posix_types.h
index 4345141..6985b8e 100644
--- a/arch/sandbox/include/asm/posix_types.h
+++ b/arch/sandbox/include/asm/posix_types.h
@@ -15,9 +15,23 @@ typedef int  __kernel_pid_t;
 typedef unsigned short __kernel_ipc_pid_t;
 typedef unsigned short __kernel_uid_t;
 typedef unsigned short __kernel_gid_t;
+/*
+ * Most 32 bit architectures use unsigned int size_t,
+ * and all 64 bit architectures use unsigned long size_t.
+ *
+ * TODO: It's not clean to use __x86_64__ here. It's better
+ * to check on __BITS_PER_LONG here. But this is wrong set in
+ * arch/sandbox/include/asm/types.h.
+ */
+#ifdef __x86_64__
 typedef unsigned long  __kernel_size_t;
 typedef long   __kernel_ssize_t;
+typedef long   __kernel_ptrdiff_t;
+#else
+typedef unsigned int   __kernel_size_t;
+typedef int__kernel_ssize_t;
 typedef int__kernel_ptrdiff_t;
+#endif
 typedef long   __kernel_time_t;
 typedef long   __kernel_suseconds_t;
 typedef long   __kernel_clock_t;
-- 
1.7.12


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 3/3] sandbox: add missed case statement

2012-09-10 Thread Alexander Aring
Add missed case statement to ignore 'i' parameter
in first getopt loop.

Signed-off-by: Alexander Aring alex.ar...@gmail.com
---
 arch/sandbox/os/common.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c
index e296574..d2aea38 100644
--- a/arch/sandbox/os/common.c
+++ b/arch/sandbox/os/common.c
@@ -306,6 +306,8 @@ int main(int argc, char *argv[])
case 'm':
malloc_size = strtoul(optarg, NULL, 0);
break;
+   case 'i':
+   break;
case 'e':
sprintf(str, env%d, envno);
ret = add_image(optarg, str);
@@ -343,7 +345,11 @@ int main(int argc, char *argv[])
}
mem_malloc_init(ram, ram + malloc_size - 1);
 
-   /* reset getopt */
+   /*
+* Reset getopt.
+* We need to run a second getopt to count -i parameters.
+* This is for /dev/fd# devices.
+*/
optind = 1;
 
while (1) {
-- 
1.7.12


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 1/3] commands: add testing menu

2012-09-10 Thread Alexander Aring
Add command menu for testing utilities.

Signed-off-by: Alexander Aring alex.ar...@gmail.com
---
 commands/Kconfig | 4 
 1 file changed, 4 insertions(+)

diff --git a/commands/Kconfig b/commands/Kconfig
index f2756cc..8f3a15a 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -472,6 +472,10 @@ config CMD_OFTREE
 
 endmenu
 
+menu testing   
+
+endmenu
+
 config CMD_TIMEOUT
tristate
prompt timeout
-- 
1.7.12


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 2/3] commands: move nandtest to testing

2012-09-10 Thread Alexander Aring
Move nadntest in commands menu.

Signed-off-by: Alexander Aring alex.ar...@gmail.com
---
 commands/Kconfig | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/commands/Kconfig b/commands/Kconfig
index 8f3a15a..2ee8643 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -192,14 +192,6 @@ config CMD_NAND
depends on NAND
prompt nand
 
-config CMD_NANDTEST
-   tristate
-   depends on NAND
-   depends on PARTITION
-   depends on NAND_ECC_HW || NAND_ECC_SOFT
-   select PARTITION_NEED_MTD
-   prompt nandtest
-
 config CMD_AUTOMOUNT
tristate
select FS_AUTOMOUNT
@@ -474,6 +466,14 @@ endmenu
 
 menu testing   
 
+config CMD_NANDTEST
+   tristate
+   depends on NAND
+   depends on PARTITION
+   depends on NAND_ECC_HW || NAND_ECC_SOFT
+   select PARTITION_NEED_MTD
+   prompt nandtest
+
 endmenu
 
 config CMD_TIMEOUT
-- 
1.7.12


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] fs: fs.c fix cast

2012-09-10 Thread Alexander Aring
Fix casting on min argument, to avoid warnings on 64bit build.

Signed-off-by: Alexander Aring alex.ar...@gmail.com
---
 fs/fs.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/fs/fs.c b/fs/fs.c
index 38917bf..db4621a 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -1525,7 +1525,9 @@ ssize_t mem_read(struct cdev *cdev, void *buf, size_t 
count, loff_t offset, ulon
return -1;
dev = cdev-dev;
 
-   size = min((loff_t)count, resource_size(dev-resource[0]) - offset);
+   size = min((resource_size_t)count,
+   resource_size(dev-resource[0]) -
+   (resource_size_t)offset);
memcpy_sz(buf, dev_get_mem_region(dev, 0) + offset, size, flags  
O_RWSIZE_MASK);
return size;
 }
@@ -1540,7 +1542,9 @@ ssize_t mem_write(struct cdev *cdev, const void *buf, 
size_t count, loff_t offse
return -1;
dev = cdev-dev;
 
-   size = min((loff_t)count, resource_size(dev-resource[0]) - offset);
+   size = min((resource_size_t)count,
+   resource_size(dev-resource[0]) -
+   (resource_size_t)offset);
memcpy_sz(dev_get_mem_region(dev, 0) + offset, buf, size, flags  
O_RWSIZE_MASK);
return size;
 }
-- 
1.7.12


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 1/2] libbb: remove vi tabwidth setting

2012-09-10 Thread Alexander Aring
Remove vi tabwidth and tabstop setting.

Signed-off-by: Alexander Aring alex.ar...@gmail.com
---
 lib/libbb.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/lib/libbb.c b/lib/libbb.c
index 9a0a60b..e0d7481 100644
--- a/lib/libbb.c
+++ b/lib/libbb.c
@@ -1,4 +1,3 @@
-/* vi: set sw=8 ts=8: */
 /*
  * Utility routines.
  *
-- 
1.7.12


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 2/2] complete: abstract path complete

2012-09-10 Thread Alexander Aring
Rewritten path complete, to use it maybe
in another functions.

Signed-off-by: Alexander Aring alex.ar...@gmail.com
---
 common/complete.c | 73 +--
 include/libbb.h   |  2 ++
 lib/libbb.c   | 64 +++-
 3 files changed, 82 insertions(+), 57 deletions(-)

diff --git a/common/complete.c b/common/complete.c
index 6a871ef..a06c070 100644
--- a/common/complete.c
+++ b/common/complete.c
@@ -25,6 +25,8 @@
 #include libgen.h
 #include command.h
 #include environment.h
+#include errno.h
+#include libbb.h
 
 static int file_complete(struct string_list *sl, char *instr, int exec)
 {
@@ -70,65 +72,24 @@ out:
return 0;
 }
 
-static int path_command_complete(struct string_list *sl, char *instr)
+static int path_command_complete(char *name, void *priv)
 {
-   struct stat s;
-   DIR *dir;
-   struct dirent *d;
-   char tmp[PATH_MAX];
-   char *path, *p, *n;
-
-   p = path = strdup(getenv(PATH));
-
-   if (!path)
-   return -1;
-
-   while (p) {
-   n = strchr(p, ':');
-   if (n)
-   *n++ = '\0';
-   if (*p == '\0') {
-   p = n;
-   continue;
-   }
-   dir = opendir(p);
+   struct string_list *sl = priv;
+   char *filename;
 
-   /* We need to check all PATH dirs, so if one failed,
-* try next */
-   if (!dir) {
-   p = n;
-   continue;
-   }
+   filename = strrchr(name, '/') + 1;
+   if (!filename)
+   return -EINVAL;
 
-   while ((d = readdir(dir))) {
-   if (!strcmp(d-d_name, .) ||
-   !strcmp(d-d_name, ..))
-   continue;
+   strcat(filename,  );
 
-   if (!strncmp(instr, d-d_name, strlen(instr))) {
-   strcpy(tmp, d-d_name);
-   if (!stat(tmp, s) 
-   S_ISDIR(s.st_mode))
-   continue;
-   else
-   strcat(tmp,  );
-
-   /* This function is called
-* after command_complete,
-* so we check if a double
-* entry exist */
-   if (string_list_contains
-   (sl, tmp) == 0) {
-   string_list_add_sorted(sl, tmp);
-   }
-   }
-   }
-
-   closedir(dir);
-   p = n;
-   }
-
-   free(path);
+   /* This function is called
+* after command_complete,
+* so we check if a double
+* entry exist */
+   if (!string_list_contains
+   (sl, filename))
+   string_list_add_sorted(sl, filename);
 
return 0;
 }
@@ -334,7 +295,7 @@ int complete(char *instr, char **outstr)
instr = t;
} else {
command_complete(sl, instr);
-   path_command_complete(sl, instr);
+   find_execable_like(path_command_complete, instr, sl);
env_param_complete(sl, instr, 0);
}
if (*instr == '$')
diff --git a/include/libbb.h b/include/libbb.h
index 47b2e08..0ef702b 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -11,6 +11,8 @@ char *concat_subpath_file(const char *path, const char *f);
 int execable_file(const char *name);
 char *find_execable(const char *filename);
 char* last_char_is(const char *s, int c);
+int find_execable_like(int found(char *name, void *priv),
+   const char *likelyname, void *priv);
 
 enum {
ACTION_RECURSE = (1  0),
diff --git a/lib/libbb.c b/lib/libbb.c
index e0d7481..daf77c7 100644
--- a/lib/libbb.c
+++ b/lib/libbb.c
@@ -14,6 +14,7 @@
 #include xfuncs.h
 #include malloc.h
 #include environment.h
+#include errno.h
 
 /* concatenate path and file name to new allocation buffer,
  * not adding '/' if path name already has '/'
@@ -60,7 +61,6 @@ int execable_file(const char *name)
 }
 EXPORT_SYMBOL(execable_file);
 
-
 /* search $PATH for an executable file;
  * return allocated string containing full path if found;
  * return NULL otherwise;
@@ -89,6 +89,68 @@ char *find_execable(const char *filename)
 }
 EXPORT_SYMBOL(find_execable);
 
+/* search $PATH for an executable file which is
+ * like the filename specified in likelyname;
+ * A likelyname on match will call the found function;
+ * Caller need to duplicate the name string in
+ * found functionpointer, if he want to save it;
+ * return