add mtd dataflash support
Subsystems (2)
cover add mtd dataflash support
HI,
the following patch serie add the dataflash support and use it on Calao USB-A9263
I'll add later the support on Atmel Reference Board
The following changes since commit 461e7d7aefb128a63b84687ba7e361473ada91c6:
mtd-core: add writesize in MEMGETINFO ioctl (2012-10-13 14:30:50 +0200)
are available in the git repository at:
git://git.jcrosoft.org/barebox.git delivery/calao
for you to fetch changes up to cc1c399fbad7c8e818d7030777317703ced86c1c:
usb-a9263: add spi dataflash support (2012-10-14 20:13:00 +0800)
----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (3):
import include/linux/math64.h
mtd: add dataflash support
usb-a9263: add spi dataflash support
arch/arm/boards/usb-a926x/init.c | 21 +++ arch/arm/configs/usb_a9263_128mib_defconfig | 3 +- arch/arm/configs/usb_a9263_defconfig | 3 +- drivers/mtd/devices/Kconfig | 18 ++ drivers/mtd/devices/Makefile | 1 + drivers/mtd/devices/mtd_dataflash.c | 882 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/math64.h | 121 +++++++++++++ include/spi/flash.h | 2 +- 8 files changed, 1048 insertions(+), 3 deletions(-) create mode 100644 drivers/mtd/devices/mtd_dataflash.c create mode 100644 include/linux/math64.h
Best Regards,
J.
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
PATCH 1/3 import include/linux/math64.h
need by mtd_dataflash
--- include/linux/math64.h | 121 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 include/linux/math64.h
include/linux/math64.h new file +121 -0
@@ -0,0 +1,121 @@ +#ifndef _LINUX_MATH64_H +#define _LINUX_MATH64_H + +#include <linux/types.h> +#include <asm-generic/div64.h> + +#if BITS_PER_LONG ==64 + +#define div64_long (x,y) div64_s64((x),(y)) + +/** +* div_u64_rem - unsigned 64bit divide with 32bit divisor with remainder +* +* This is commonly provided by 32bit archs to provide an optimized 64bit +* divide. +*/ +static inline u64 div_u64_rem (u64 dividend,u32 divisor,u32 *remainder) +{ + *remainder = dividend % divisor; +return dividend / divisor; +} + +/** +* div_s64_rem - signed 64bit divide with 32bit divisor with remainder +*/ +static inline s64 div_s64_rem (s64 dividend,s32 divisor,s32 *remainder) +{ + *remainder = dividend % divisor; +return dividend / divisor; +} + +/** +* div64_u64 - unsigned 64bit divide with 64bit divisor +*/ +static inline u64 div64_u64 (u64 dividend,u64 divisor) +{ +return dividend / divisor; +} + +/** +* div64_s64 - signed 64bit divide with 64bit divisor +*/ +static inline s64 div64_s64 (s64 dividend,s64 divisor) +{ +return dividend / divisor; +} + +#elif BITS_PER_LONG ==32 + +#define div64_long (x,y) div_s64((x),(y)) + +#ifndef div_u64_rem +static inline u64 div_u64_rem (u64 dividend,u32 divisor,u32 *remainder) +{ + *remainder =do_div (dividend, divisor); +return dividend; +} +#endif + +#ifndef div_s64_rem +extern s64 div_s64_rem (s64 dividend,s32 divisor,s32 *remainder); +#endif + +#ifndef div64_u64 +extern u64 div64_u64 (u64 dividend,u64 divisor); +#endif + +#ifndef div64_s64 +extern s64 div64_s64 (s64 dividend,s64 divisor); +#endif + +#endif /* BITS_PER_LONG */ + +/** +* div_u64 - unsigned 64bit divide with 32bit divisor +* +* This is the most common 64bit divide and should be used if possible, +* as many 32bit archs can optimize this variant better than a full 64bit +* divide. +*/ +#ifndef div_u64 +static inline u64 div_u64 (u64 dividend,u32 divisor) +{ +u32 remainder; +return div_u64_rem (dividend, divisor, &remainder); +} +#endif + +/** +* div_s64 - signed 64bit divide with 32bit divisor +*/ +#ifndef div_s64 +static inline s64 div_s64 (s64 dividend,s32 divisor) +{ +s32 remainder; +return div_s64_rem (dividend, divisor, &remainder); +} +#endif + +u32 iter_div_u64_rem (u64 dividend,u32 divisor,u64 *remainder); + +static __always_inline u32 +__iter_div_u64_rem (u64 dividend,u32 divisor,u64 *remainder) +{ +u32 ret =0 ; + +while (dividend >= divisor) { +/* The following asm() prevents the compiler from +optimising this loop into a modulo operation. */ + asm("" :"+rm" (dividend)); + + dividend -= divisor; + ret++; + } + + *remainder = dividend; + +return ret; +} + +#endif /* _LINUX_MATH64_H */
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 3/3 usb-a9263: add spi dataflash support
--- arch/arm/boards/usb-a926x/init.c | 21 +++++++++++++++++++++ arch/arm/configs/usb_a9263_128mib_defconfig | 3 ++- arch/arm/configs/usb_a9263_defconfig | 3 ++- 3 files changed, 25 insertions(+), 2 deletions(-)
arch/arm/boards/usb-a926x/init.c +21 -0
@@ -39,6 +39,7 @@#include <mach/at91_rstc.h> #include <gpio_keys.h> #include <readkey.h> +#include <spi/spi.h> static void usb_a9260_set_board_type (void ) {
@@ -148,6 +149,25 @@ static void usb_a9260_phy_reset(void) AT91_RSTC_URSTEN); } +static const struct spi_board_info usb_a9263_spi_devices[] = { + { + .name ="mtd_dataflash" , + .chip_select =0 , + .max_speed_hz =15 *1000 *1000 , + .bus_num =0 , + } +}; + +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 defined(CONFIG_MCI_ATMEL )static struct atmel_mci_platform_data __initdata usb_a9260_mci_data = { .bus_width = 4,
@@ -314,6 +334,7 @@ static int usb_a9260_devices_init(void)usb_a9260_phy_reset ();at91_add_device_eth (0 , &macb_pdata);usb_a9260_add_device_mci (); +usb_a9260_add_spi ();at91_add_device_usbh_ohci (&ek_usbh_data);ek_add_device_udc ();ek_add_led ();
arch/arm/configs/usb_a9263_128mib_defconfig +2 -1
@@ -64,9 +64,10 @@ 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_MTD_DATAFLASH=y CONFIG_NAND=y # CONFIG_NAND_ECC_HW is not set # CONFIG_NAND_ECC_HW_SYNDROME is not set
arch/arm/configs/usb_a9263_defconfig +2 -1
@@ -63,9 +63,10 @@ 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_MTD_DATAFLASH=y CONFIG_NAND=y # CONFIG_NAND_ECC_HW is not set # CONFIG_NAND_ECC_HW_SYNDROME is not set
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 2/3 mtd: add dataflash support
In reply to Jean-Christophe PLAGNIOL-VILLARDfrom linux 3.6
--- drivers/mtd/devices/Kconfig | 18 + drivers/mtd/devices/Makefile | 1 + drivers/mtd/devices/mtd_dataflash.c | 882 +++++++++++++++++++++++++++++++++++ include/spi/flash.h | 2 +- 4 files changed, 902 insertions(+), 1 deletion(-) create mode 100644 drivers/mtd/devices/mtd_dataflash.c
drivers/mtd/devices/Kconfig +18 -0
@@ -1,6 +1,24 @@ menu "Self contained MTD devices" depends on MTD!=n +config MTD_DATAFLASH + tristate "Support for AT45xxx DataFlash" + depends on SPI + help + This enables access to AT45xxx DataFlash chips, using SPI. + Sometimes DataFlash chips are packaged inside MMC-format + cards; at this writing, the MMC stack won't handle those. + +config MTD_DATAFLASH_WRITE_VERIFY + bool "Verify DataFlash page writes" + depends on MTD_DATAFLASH + 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 + device thinks the write was successful, a bit could have been + flipped accidentally due to device wear or something else. + config MTD_DOCG3 bool "M-Systems Disk-On-Chip G3" select BCH
drivers/mtd/devices/Makefile +1 -0
@@ -2,4 +2,5 @@ # Makefile for the self containted memory technology device drivers. # +obj-$(CONFIG_MTD_DATAFLASH) += mtd_dataflash.o obj-$(CONFIG_MTD_DOCG3) += docg3.o
drivers/mtd/devices/mtd_dataflash.c new file +882 -0
882 lines not on this page · raw message
include/spi/flash.h +1 -1
@@ -19,7 +19,7 @@ struct mtd_partition;* rarely powers of two; and partitions should be sector-aligned. */ struct flash_platform_data { -const char *name; +char *name;struct mtd_partition *parts;unsigned int nr_parts;char *type;
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 2/3] mtd: add dataflash support
Quoted 27 lines · Jean-Christophe PLAGNIOL-VILLARD
from linux 3.6
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>--- drivers/mtd/devices/Kconfig | 18 + drivers/mtd/devices/Makefile | 1 + drivers/mtd/devices/mtd_dataflash.c | 882 +++++++++++++++++++++++++++++++++++ include/spi/flash.h | 2 +- 4 files changed, 902 insertions(+), 1 deletion(-) create mode 100644 drivers/mtd/devices/mtd_dataflash.cdrivers/mtd/devices/Kconfig +8
-0@@ -1,6 +1,24 @@ menu "Self contained MTD devices" depends on MTD!=n +config MTD_DATAFLASH + tristate "Support for AT45xxx DataFlash" + depends on SPI + help + This enables access to AT45xxx DataFlash chips, using SPI. + Sometimes DataFlash chips are packaged inside MMC-format + cards; at this writing, the MMC stack won't handle those. +
drivers/mtd/devices/Kconfig line 21
Quoted 10 lines
drivers/mtd/devices/Kconfig +10
-0+config MTD_DATAFLASH_WRITE_VERIFY + bool "Verify DataFlash page writes" + depends on MTD_DATAFLASH + 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 + device thinks the write was successful, a bit could have been + flipped accidentally due to device wear or something else. +
What about MTD_DATAFLASH_OTP?
Sascha
Signature · 9 lines
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 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 2/3] mtd: add dataflash support
Quoted 32 lines · Sascha Hauer
Quoted 31 lines · Jean-Christophe PLAGNIOL-VILLARD
from linux 3.6
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>--- drivers/mtd/devices/Kconfig | 18 + drivers/mtd/devices/Makefile | 1 + drivers/mtd/devices/mtd_dataflash.c | 882 +++++++++++++++++++++++++++++++++++ include/spi/flash.h | 2 +- 4 files changed, 902 insertions(+), 1 deletion(-) create mode 100644 drivers/mtd/devices/mtd_dataflash.cdrivers/mtd/devices/Kconfig +12
-0@@ -1,6 +1,24 @@ menu "Self contained MTD devices" depends on MTD!=n +config MTD_DATAFLASH + tristate "Support for AT45xxx DataFlash" + depends on SPI + help + This enables access to AT45xxx DataFlash chips, using SPI. + Sometimes DataFlash chips are packaged inside MMC-format + cards; at this writing, the MMC stack won't handle those. + +config MTD_DATAFLASH_WRITE_VERIFY + bool "Verify DataFlash page writes" + depends on MTD_DATAFLASH + help
Quoted 8 lines
drivers/mtd/devices/Kconfig line 21
Quoted 6 lines
drivers/mtd/devices/Kconfig +6
-0+ 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 + device thinks the write was successful, a bit could have been + flipped accidentally due to device wear or something else. +What about
MTD_DATAFLASH_OTP?
the DATAFLASH_OTP need the MTD to have the OTP support
which we do not have yet
do I did not add it
Best Regards,
J.
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Quoted 7 lines · Jean-Christophe PLAGNIOL-VILLARD
HI,
the following patch serie add the dataflash support and use it on Calao USB-A9263
I'll add later the support on Atmel Reference Board
Quoted 7 lines
The following changes since commit
461e7d7aefb128a63b84687ba7e361473ada91c6:mtd-core: add writesize in MEMGETINFO ioctl (2012-10-13 14:30:50 +0200)
are available in the git repository at:
git://git.jcrosoft.org/barebox.gitdelivery/calao
Pulled, thanks
Sascha
Quoted 31 lines
for you to fetch changes up to
cc1c399fbad7c8e818d7030777317703ced86c1c:usb-a9263: add spi dataflash support (2012-10-14 20:13:00 +0800)
----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (3):
importinclude/linux/math64.h
mtd: add dataflash support
usb-a9263: add spi dataflash supportarch/arm/boards/usb-a926x/init.c | 21 +++ arch/arm/configs/usb_a9263_128mib_defconfig | 3 +- arch/arm/configs/usb_a9263_defconfig | 3 +- drivers/mtd/devices/Kconfig | 18 ++ drivers/mtd/devices/Makefile | 1 + drivers/mtd/devices/mtd_dataflash.c | 882 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/math64.h | 121 +++++++++++++ include/spi/flash.h | 2 +- 8 files changed, 1048 insertions(+), 3 deletions(-) create mode 100644 drivers/mtd/devices/mtd_dataflash.c create mode 100644 include/linux/math64.hBest Regards,
J._______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
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 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox