[PATCH] mtd mtdraw: Fix partial page read

2012-09-15 Thread Sascha Hauer
When reading parts of a page we have to limit the maximum bytes copied
the the remaining bytes of a page.

Signed-off-by: Sascha Hauer 
Cc: Robert Jarzmik 
---
 drivers/mtd/mtdraw.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mtd/mtdraw.c b/drivers/mtd/mtdraw.c
index d28ae07..29f6a8c 100644
--- a/drivers/mtd/mtdraw.c
+++ b/drivers/mtd/mtdraw.c
@@ -129,6 +129,7 @@ static ssize_t mtdraw_read(struct cdev *cdev, void *buf, 
size_t count,
 
while (ret > 0 && count > 0) {
toread = min_t(int, count, mtd->writesize + mtd->oobsize);
+   toread = min_t(int, toread, mtd->writesize + mtd->oobsize - 
skip);
ret = mtdraw_read_unaligned(mtd, buf, toread,
skip, numpage++ * mtd->writesize);
buf += ret;
-- 
1.7.10.4


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


Re: [for master PATCH 2/2] calao: at91 qil/tny/usb auto detect the phy addr

2012-09-15 Thread Jean-Christophe PLAGNIOL-VILLARD
Hi Sacha,

after applying the phylib we need this path on calao hw

Best Regards,
J.
On 17:48 Tue 14 Aug , Jean-Christophe PLAGNIOL-VILLARD wrote:
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD 
> ---
>  arch/arm/boards/qil-a9260/init.c |2 +-
>  arch/arm/boards/tny-a926x/init.c |2 +-
>  arch/arm/boards/usb-a926x/init.c |2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm/boards/qil-a9260/init.c 
> b/arch/arm/boards/qil-a9260/init.c
> index ee204fb..92aea97 100644
> --- a/arch/arm/boards/qil-a9260/init.c
> +++ b/arch/arm/boards/qil-a9260/init.c
> @@ -80,7 +80,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,
> - .phy_addr   = 0,
> + .phy_addr   = -1,
>  };
>  
>  static void qil_a9260_phy_reset(void)
> diff --git a/arch/arm/boards/tny-a926x/init.c 
> b/arch/arm/boards/tny-a926x/init.c
> index d58132a..556e633 100644
> --- a/arch/arm/boards/tny-a926x/init.c
> +++ b/arch/arm/boards/tny-a926x/init.c
> @@ -118,7 +118,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,
> - .phy_addr   = 0,
> + .phy_addr   = -1,
>  };
>  
>  static void __init ek_add_device_macb(void)
> diff --git a/arch/arm/boards/usb-a926x/init.c 
> b/arch/arm/boards/usb-a926x/init.c
> index 52444e1..7b19fa4 100644
> --- a/arch/arm/boards/usb-a926x/init.c
> +++ b/arch/arm/boards/usb-a926x/init.c
> @@ -122,7 +122,7 @@ static void usb_a9260_add_device_nand(void) {}
>  #if defined(CONFIG_DRIVER_NET_MACB)
>  static struct at91_ether_platform_data macb_pdata = {
>   .flags  = AT91SAM_ETHER_RMII,
> - .phy_addr   = 0,
> + .phy_addr   = -1,
>  };
>  
>  static void usb_a9260_phy_reset(void)
> -- 
> 1.7.10.4
> 

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


[PATCH 1/1] defconfig: substitute '-' to '_' in defconfig name so MAKEALL can work

2012-09-15 Thread Jean-Christophe PLAGNIOL-VILLARD
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD 
---
 .../{freescale-mx6-arm2_defconfig => freescale_mx6_arm2_defconfig} |0
 ...scale-mx6-sabrelite_defconfig => freescale_mx6_sabrelite_defconfig} |0
 .../configs/{imx233-olinuxino_defconfig => imx233_olinuxino_defconfig} |0
 arch/mips/configs/{dlink-dir-320_defconfig => dlink_dir_320_defconfig} |0
 arch/mips/configs/{qemu-malta_defconfig => qemu_malta_defconfig}   |0
 5 files changed, 0 insertions(+), 0 deletions(-)
 rename arch/arm/configs/{freescale-mx6-arm2_defconfig => 
freescale_mx6_arm2_defconfig} (100%)
 rename arch/arm/configs/{freescale-mx6-sabrelite_defconfig => 
freescale_mx6_sabrelite_defconfig} (100%)
 rename arch/arm/configs/{imx233-olinuxino_defconfig => 
imx233_olinuxino_defconfig} (100%)
 rename arch/mips/configs/{dlink-dir-320_defconfig => dlink_dir_320_defconfig} 
(100%)
 rename arch/mips/configs/{qemu-malta_defconfig => qemu_malta_defconfig} (100%)

diff --git a/arch/arm/configs/freescale-mx6-arm2_defconfig 
b/arch/arm/configs/freescale_mx6_arm2_defconfig
similarity index 100%
rename from arch/arm/configs/freescale-mx6-arm2_defconfig
rename to arch/arm/configs/freescale_mx6_arm2_defconfig
diff --git a/arch/arm/configs/freescale-mx6-sabrelite_defconfig 
b/arch/arm/configs/freescale_mx6_sabrelite_defconfig
similarity index 100%
rename from arch/arm/configs/freescale-mx6-sabrelite_defconfig
rename to arch/arm/configs/freescale_mx6_sabrelite_defconfig
diff --git a/arch/arm/configs/imx233-olinuxino_defconfig 
b/arch/arm/configs/imx233_olinuxino_defconfig
similarity index 100%
rename from arch/arm/configs/imx233-olinuxino_defconfig
rename to arch/arm/configs/imx233_olinuxino_defconfig
diff --git a/arch/mips/configs/dlink-dir-320_defconfig 
b/arch/mips/configs/dlink_dir_320_defconfig
similarity index 100%
rename from arch/mips/configs/dlink-dir-320_defconfig
rename to arch/mips/configs/dlink_dir_320_defconfig
diff --git a/arch/mips/configs/qemu-malta_defconfig 
b/arch/mips/configs/qemu_malta_defconfig
similarity index 100%
rename from arch/mips/configs/qemu-malta_defconfig
rename to arch/mips/configs/qemu_malta_defconfig
-- 
1.7.10.4


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


[PATCH 1/2] ARM i.MX6: add usb function prototypes

2012-09-15 Thread Steffen Trumtrar
Add missing prototypes to mach/usb.h

Signed-off-by: Steffen Trumtrar 
---
 arch/arm/mach-imx/include/mach/usb.h |3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm/mach-imx/include/mach/usb.h 
b/arch/arm/mach-imx/include/mach/usb.h
index 5d6670d..d953bf0 100644
--- a/arch/arm/mach-imx/include/mach/usb.h
+++ b/arch/arm/mach-imx/include/mach/usb.h
@@ -11,4 +11,7 @@
 #define MX35_H1_USBTE_BIT  (1 << 4)
 #define MXC_EHCI_INTERFACE_SINGLE_UNI  (2 << 0)
 
+
+int imx6_usb_phy1_disable_oc(void);
+int imx6_usb_phy1_enable(void);
 #endif /* __MACH_USB_H_*/
-- 
1.7.10.4


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


[PATCH 2/2] ARM i.MX6: fix usb_ehci warnings for sabrelite

2012-09-15 Thread Steffen Trumtrar
This fixes the following warnings:

arch/arm/boards/freescale-mx6-sabrelite/board.c: In function 
'sabrelite_ehci_init':
arch/arm/boards/freescale-mx6-sabrelite/board.c:265:2: warning: implicit 
declaration of function 'imx6_usb_phy1_disable_oc' 
[-Wimplicit-function-declaration]
arch/arm/boards/freescale-mx6-sabrelite/board.c:266:2: warning: implicit 
declaration of function 'imx6_usb_phy1_enable' [-Wimplicit-function-declaration]

Signed-off-by: Steffen Trumtrar 

---
 arch/arm/boards/freescale-mx6-sabrelite/board.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/boards/freescale-mx6-sabrelite/board.c 
b/arch/arm/boards/freescale-mx6-sabrelite/board.c
index 1ac401e..c5bcf8b 100644
--- a/arch/arm/boards/freescale-mx6-sabrelite/board.c
+++ b/arch/arm/boards/freescale-mx6-sabrelite/board.c
@@ -40,6 +40,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define SABRELITE_SD3_WP   IMX_GPIO_NR(7, 1)
 #define SABRELITE_SD3_CD   IMX_GPIO_NR(7, 0)
-- 
1.7.10.4


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


Re: [RFC, PATCH] barebox-update command support

2012-09-15 Thread Sascha Hauer
On Fri, Sep 14, 2012 at 02:36:20PM +0200, Jan Weitzel wrote:
> Am Freitag, den 14.09.2012, 09:45 +0200 schrieb Sascha Hauer:
> > Hi All,
> > 
> > The following adds barebox-update command support. This command is
> > supposed to provide a dedicated command for updating barebox.
> On OMAP we have MLO and barebox. Should we use the command only for MLO?
> The barebox didn't need special handling. Whats about kernel image and
> rootfs?

For Omap I am not sure. Making it bootable indeed requires two images,
so of these should be handled here. I don't know though how this could
be handled in a generic command.

Kernel and rootfs is another story, this shouldn't be handled here.
This command is thought to be for the potentially dangerous barebox
update where you only have a single try. Also, flashing kernel or rootfs
is not really SoC or board specific.

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] Add barebox update infrastructure

2012-09-15 Thread Sascha Hauer
On Fri, Sep 14, 2012 at 02:15:46PM +0200, Jan Weitzel wrote:
> > +
> > +BAREBOX_CMD_HELP_START(barebox_update)
> > +BAREBOX_CMD_HELP_USAGE("barebox_update [OPTIONS ]\n")
> image is mandatory

Ok, fixed. 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- |

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


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

2012-09-15 Thread Sascha Hauer
On Fri, Sep 14, 2012 at 09:57:04AM +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.
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD 
> ---

Had to squash the following in to fix compile breakage on i.MX6 boards.

Overall it seems there is enough room for cleanup still. We used to have
a struct mii_device which was a combination of a mii_bus and a
phy_device. Now we have a dedicated phy_device, but struct mii_device
still has a single phy and a single cdev. I think we should move the
struct cdev to struct phy_device and make the struct phy_device member
of struct mii_device a list of phy_devices. Anyway, this can be done
later.

For now I merged this series with the below changes.

Sascha


diff --git a/arch/arm/boards/freescale-mx6-arm2/board.c 
b/arch/arm/boards/freescale-mx6-arm2/board.c
index e4a9a49..7b08106 100644
--- a/arch/arm/boards/freescale-mx6-arm2/board.c
+++ b/arch/arm/boards/freescale-mx6-arm2/board.c
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -112,7 +113,9 @@ static struct fec_platform_data fec_info = {
 static int mx6_rgmii_rework(void)
 {
struct mii_device *mdev;
+   struct phy_device *pdev;
u16 val;
+   int ret;
 
mdev = mii_open("phy0");
if (!mdev) {
@@ -120,26 +123,35 @@ static int mx6_rgmii_rework(void)
return -ENODEV;
}
 
+   pdev = mdev->phydev;
+   if (!pdev) {
+   printf("phy0 has no phydev\n");
+   ret = -ENODEV;
+   goto out;
+   }
+
/* To enable AR8031 ouput a 125MHz clk from CLK_25M */
-   mii_write(mdev, mdev->address, 0xd, 0x7);
-   mii_write(mdev, mdev->address, 0xe, 0x8016);
-   mii_write(mdev, mdev->address, 0xd, 0x4007);
+   phy_write(pdev, 0xd, 0x7);
+   phy_write(pdev, 0xe, 0x8016);
+   phy_write(pdev, 0xd, 0x4007);
 
-   val = mii_read(mdev, mdev->address, 0xe);
+   val = phy_read(pdev, 0xe);
val &= 0xffe3;
val |= 0x18;
-   mii_write(mdev, mdev->address, 0xe, val);
+   phy_write(pdev, 0xe, val);
 
/* introduce tx clock delay */
-   mii_write(mdev, mdev->address, 0x1d, 0x5);
+   phy_write(pdev, 0x1d, 0x5);
 
-   val = mii_read(mdev, mdev->address, 0x1e);
+   val = phy_read(pdev, 0x1e);
val |= 0x0100;
-   mii_write(mdev, mdev->address, 0x1e, val);
+   phy_write(pdev, 0x1e, val);
 
+   ret = 0;
+out:
mii_close(mdev);
 
-   return 0;
+   return ret;
 }
 
 static int arm2_devices_init(void)
diff --git a/arch/arm/boards/freescale-mx6-sabrelite/board.c 
b/arch/arm/boards/freescale-mx6-sabrelite/board.c
index 1ac401e..aded4ec 100644
--- a/arch/arm/boards/freescale-mx6-sabrelite/board.c
+++ b/arch/arm/boards/freescale-mx6-sabrelite/board.c
@@ -40,6 +40,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define SABRELITE_SD3_WP   IMX_GPIO_NR(7, 1)
 #define SABRELITE_SD3_CD   IMX_GPIO_NR(7, 0)
@@ -143,6 +144,8 @@ static struct fec_platform_data fec_info = {
 int mx6_rgmii_rework(void)
 {
struct mii_device *mdev;
+   struct phy_device *pdev;
+   int ret;
 
mdev = mii_open("phy0");
if (!mdev) {
@@ -150,21 +153,30 @@ int mx6_rgmii_rework(void)
return -ENODEV;
}
 
-   mii_write(mdev, mdev->address, 0x09, 0x0f00);
+   pdev = mdev->phydev;
+   if (!pdev) {
+   printf("phy0 has no phydev\n");
+   ret = -ENODEV;
+   goto out;
+   }
+
+   phy_write(pdev, 0x09, 0x0f00);
 
/* do same as linux kernel */
/* min rx data delay */
-   mii_write(mdev, mdev->address, 0x0b, 0x8105);
-   mii_write(mdev, mdev->address, 0x0c, 0x);
+   phy_write(pdev, 0x0b, 0x8105);
+   phy_write(pdev, 0x0c, 0x);
 
/* max rx/tx clock delay, min rx/tx control delay */
-   mii_write(mdev, mdev->address, 0x0b, 0x8104);
-   mii_write(mdev, mdev->address, 0x0c, 0xf0f0);
-   mii_write(mdev, mdev->address, 0x0b, 0x104);
+   phy_write(pdev, 0x0b, 0x8104);
+   phy_write(pdev, 0x0c, 0xf0f0);
+   phy_write(pdev, 0x0b, 0x104);
 
+   ret = 0;
+out:
mii_close(mdev);
 
-   return 0;
+   return ret;
 }
 
 static int sabrelite_ksz9021rn_setup(void)

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

[PATCH] mtd: nand: extend NAND flash detection to new MLC chips

2012-09-15 Thread Marcus Folkesson
Some of the newer MLC devices have a 6-byte ID sequence in which
several field definitions differ from older chips in a manner that is
not backward compatible.

This method is already used in the Linux Kernel.

Signed-off-by: Marcus Folkesson 
---
 drivers/mtd/nand/nand_base.c |   97 +
 drivers/mtd/nand/nand_ids.c  |   38 +++--
 2 files changed, 112 insertions(+), 23 deletions(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 37e57b3..fe9a6e7 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -1137,7 +1137,7 @@ static struct nand_flash_dev *nand_get_flash_type(struct 
mtd_info *mtd,
 {
struct nand_flash_dev *type = NULL;
int i, dev_id, maf_idx;
-   int tmp_id, tmp_manf;
+   int id_data[8];
int ret;
 
/* Select the device */
@@ -1166,13 +1166,13 @@ static struct nand_flash_dev 
*nand_get_flash_type(struct mtd_info *mtd,
 
/* Read manufacturer and device IDs */
 
-   tmp_manf = chip->read_byte(mtd);
-   tmp_id = chip->read_byte(mtd);
+   id_data[0] = chip->read_byte(mtd);
+   id_data[1] = chip->read_byte(mtd);
 
-   if (tmp_manf != *maf_id || tmp_id != dev_id) {
+   if (id_data[0] != *maf_id || id_data[1] != dev_id) {
printk(KERN_ERR "%s: second ID read did not match "
   "%02x,%02x against %02x,%02x\n", __func__,
-  *maf_id, dev_id, tmp_manf, tmp_id);
+  *maf_id, dev_id, id_data[0], id_data[1]);
return ERR_PTR(-ENODEV);
}
 
@@ -1196,29 +1196,75 @@ static struct nand_flash_dev 
*nand_get_flash_type(struct mtd_info *mtd,
}
}
 
+   chip->cmdfunc(mtd, NAND_CMD_READID, 0x00, -1);
+
+   /* Read entire ID string */
+
+   for (i = 0; i < 8; i++)
+   id_data[i] = chip->read_byte(mtd);
+
if (!mtd->name)
mtd->name = type->name;
 
chip->chipsize = type->chipsize << 20;
 
-   /* Newer devices have all the information in additional id bytes */
if (!type->pagesize) {
int extid;
/* The 3rd id byte holds MLC / multichip data */
-   chip->cellinfo = chip->read_byte(mtd);
+   chip->cellinfo = id_data[2];
/* The 4th id byte is the important one */
-   extid = chip->read_byte(mtd);
-   /* Calc pagesize */
-   mtd->writesize = 1024 << (extid & 0x3);
-   extid >>= 2;
-   /* Calc oobsize */
-   mtd->oobsize = (8 << (extid & 0x01)) * (mtd->writesize >> 9);
-   extid >>= 2;
-   /* Calc blocksize. Blocksize is multiples of 64KiB */
-   mtd->erasesize = (64 * 1024) << (extid & 0x03);
-   extid >>= 2;
-   /* Get buswidth information */
-   busw = (extid & 0x01) ? NAND_BUSWIDTH_16 : 0;
+   extid = id_data[3];
+
+   /*
+* Field definitions are in the following datasheets:
+* Old style (4,5 byte ID): Samsung K9GAG08U0M (p.32)
+* New style   (6 byte ID): Samsung K9GBG08U0M (p.40)
+*
+* Check for wraparound + Samsung ID + nonzero 6th byte
+* to decide what to do.
+*/
+   if (id_data[0] == id_data[6] && id_data[1] == id_data[7] &&
+   id_data[0] == NAND_MFR_SAMSUNG &&
+   (chip->cellinfo & NAND_CI_CELLTYPE_MSK) &&
+   id_data[5] != 0x00) {
+   /* Calc pagesize */
+   mtd->writesize = 2048 << (extid & 0x03);
+   extid >>= 2;
+   /* Calc oobsize */
+   switch (extid & 0x03) {
+   case 1:
+   mtd->oobsize = 128;
+   break;
+   case 2:
+   mtd->oobsize = 218;
+   break;
+   case 3:
+   mtd->oobsize = 400;
+   break;
+   default:
+   mtd->oobsize = 436;
+   break;
+   }
+   extid >>= 2;
+   /* Calc blocksize */
+   mtd->erasesize = (128 * 1024) <<
+   (((extid >> 1) & 0x04) | (extid & 0x03));
+   busw = 0;
+   } else {
+   /* Calc pagesize */
+   mtd->writesize = 1024 << (extid & 0x03);
+   extid >>= 2;
+   /* Calc oobsize */
+   mtd->oobsize = (8 << (extid & 0x01)) *
+   (mtd-