generic NAND driver for TS-72[56]0 and TS-7800
Subsystems (8)
Alexander Clouter
maintainerHi,
Really just a request for comments on an alternative driver I have put together that works on the TS-72[56]0 (currently covered by the ts7250.c driver) and the TS-7800 that I submitted to the ARM mailing list the other week[1].
The NAND on the TS boards is more or less identical except for:
* the partitioning layout
* the io memory port addresses
* the TS-7800 supports DMA and HW ECC
So to tackle this I did the following:
1. moved the paritioning handling to become a runtime decision and to come from a function called lurking in the platform code
2. IO addresses get passed in the platform_device struct
3. [coming soon] to enable (if on a TS-78xx) the DMA HW ECC code; you can see how I'm adding the hooks, it's just the code currently does not work properly yet ;)
For those familiar with the ts7250.c code, you will notice my ts7xxx.c code is rather similar...unsurprisingly it's what I deried it from.
Comments, flames, and explanations on how to properly do all this MTD malarkey welcomed. I already chatted to the ts7250.c author who no longer uses the board and he said I should just go right ahead and post my patch here. I own and have obviously tested this on the TS-7800 and got some Joe Public's on the TS-7000 mailing list with TS-7[56]0's to test it too[2] for me.
Cheers
Alex
N.B. worth noting that the parition layout in the current ts7250.c driver is
wrong. My patch sets it corrrectly to what it should be.
[1] http://marc.info/?l=linux-arm-kernel&m=121280018602505&w=2
[2] http://tech.groups.yahoo.com/group/ts-7000/message/11616?var=0&l=1
Signature · 10 lines
_________________________________________
/ Walking on water wasn't built in a day. \
| |
\ -- Jack Kerouac /
-----------------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||arch/arm/mach-ep93xx/ts72xx.c +82 -0
@@ -17,6 +17,8 @@#include <linux/interrupt.h> #include <linux/ioport.h> #include <linux/mtd/physmap.h> +#include <linux/mtd/nand.h> +#include <linux/mtd/ts7xxx.h> #include <linux/platform_device.h> #include <linux/m48t86.h> #include <asm/io.h>
@@ -131,6 +133,84 @@ static struct platform_device ts72xx_flash = { .resource = &ts72xx_flash_resource, }; +/***************************************************************************** +* NAND Flash +****************************************************************************/ +static struct mtd_partition ts72xx_nand_parts32[] = { + { + .name ="TS-BOOTROM" , + .offset =0 , + .size =SZ_128K , + .mask_flags =MTD_WRITEABLE , + }, { + .name ="Linux" , + .offset =MTDPART_OFS_APPEND , + .size =29 *SZ_1M , + }, { + .name ="RedBoot" , + .offset =MTDPART_OFS_APPEND , + .size =MTDPART_SIZ_FULL , + } +}; + +static struct mtd_partition ts72xx_nand_parts128[] = { + { + .name ="TS-BOOTROM" , + .offset =0 , + .size =SZ_128K , + .mask_flags =MTD_WRITEABLE , + }, { + .name ="Linux" , + .offset =MTDPART_OFS_APPEND , + .size =125 *SZ_1M , + }, { + .name ="RedBoot" , + .offset =MTDPART_OFS_APPEND , + .size =MTDPART_SIZ_FULL , + } +}; + +static struct ts7xxx_nand_data ts72xx_nand_data = { + .partitions =NULL , + .nr_partitions =0 , + + .ioports = { + .ctrl = (void *__iomem )TS72XX_NAND_CONTROL_VIRT_BASE , + .data = (void *__iomem )TS72XX_NAND_DATA_VIRT_BASE , + + .busy = (void *__iomem )TS72XX_NAND_BUSY_VIRT_BASE , + }, +}; + +static struct ts7xxx_nand_data *ts72xx_nand (unsigned int size) +{ +/* +* The TS-72[56]0's come with either 32MiB or 128MiB of NAND +*/ +if (size ==32 *SZ_1M ) { + ts72xx_nand_data.partitions = ts72xx_nand_parts32; + ts72xx_nand_data.nr_partitions + =ARRAY_SIZE (ts72xx_nand_parts32); + }else if (size ==128 *SZ_1M ) { + ts72xx_nand_data.partitions = ts72xx_nand_parts128; + ts72xx_nand_data.nr_partitions + =ARRAY_SIZE (ts72xx_nand_parts128); + } + +return &ts72xx_nand_data; +}; + +static struct platform_device ts72xx_nand_flash = { + .name ="ts7xxx_nand" , + .id =-1 , + .dev = { + .platform_data = &ts72xx_nand, + }, + .num_resources =0 , +}; + +/****************************************************************************/ +static unsigned char ts72xx_rtc_readbyte (unsigned long addr) {__raw_writeb (addr,TS72XX_RTC_INDEX_VIRT_BASE );
@@ -188,6 +268,8 @@ static void __init ts72xx_init_machine(void)ep93xx_init_devices ();if (board_is_ts7200 ())platform_device_register (&ts72xx_flash); +if (!board_is_ts7200 ()) +platform_device_register (&ts72xx_nand_flash);platform_device_register (&ts72xx_rtc_device); memcpy(ts72xx_eth_data.dev_addr,
arch/arm/mach-orion5x/ts78xx-setup.c +72 -0
96 lines not on this page · raw message
drivers/mtd/nand/Kconfig +6 -0
@@ -81,6 +81,12 @@ config MTD_NAND_TS7250 help Support for NAND flash on Technologic Systems TS-7250 platform. +config MTD_NAND_TS7XXX + tristate "NAND Flash device on TS-7xxx boards" + depends on MACH_TS72XX || MACH_TS78XX + help + Support for NAND flash on Technologic Systems TS-7xxx platforms. + config MTD_NAND_IDS tristate
drivers/mtd/nand/Makefile +1 -0
@@ -21,6 +21,7 @@ obj-$(CONFIG_MTD_NAND_H1900) += h1910.o obj-$(CONFIG_MTD_NAND_RTC_FROM4) += rtc_from4.o obj-$(CONFIG_MTD_NAND_SHARPSL) += sharpsl.o obj-$(CONFIG_MTD_NAND_TS7250) += ts7250.o +obj-$(CONFIG_MTD_NAND_TS7XXX) += ts7xxx.o obj-$(CONFIG_MTD_NAND_NANDSIM) += nandsim.o obj-$(CONFIG_MTD_NAND_CS553X) += cs553x_nand.o obj-$(CONFIG_MTD_NAND_NDFC) += ndfc.o
drivers/mtd/nand/ts7xxx.c new file +268 -0
268 lines not on this page · raw message
include/linux/mtd/ts7xxx.h new file +36 -0
@@ -0,0 +1,36 @@ +/* +* linux/include/linux/mtd/ts7xxx.h +* +* Copyright (c) 2008 Alexander Clouter <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#include <linux/mtd/partitions.h> + +/* +* io ports listing +*/ +struct ts7xxx_ioports { +void __iomem *ctrl; +void __iomem *data; + +void __iomem *busy; + +void __iomem *dma; +void __iomem *hcdr; +}; + +/* +* struct ts7xxx_nand_data - chip level device structure +* @nr_partitions: number of partitions pointed to by partitions (or zero) +* @partitions: mtd partition list +*/ +struct ts7xxx_nand_data { +int nr_partitions; +struct mtd_partition *partitions; + +struct ts7xxx_ioports ioports; +};