From 116d99d9f45c30d3b1c80b54fed8bf406aa590f7 Mon Sep 17 00:00:00 2001 From: Matthieu Crapet Date: Sat, 19 Jun 2010 16:56:48 +0200 Subject: [PATCH 14/18] ts7200_nor_flash Deal with 8mb or 16mb NOR Flash (TS-7200 only) --- drivers/mtd/maps/Kconfig | 15 +++++ drivers/mtd/maps/Makefile | 1 + drivers/mtd/maps/ts7200_flash.c | 116 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 132 insertions(+), 0 deletions(-) create mode 100644 drivers/mtd/maps/ts7200_flash.c diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig index aa2807d..5d12903 100644 --- a/drivers/mtd/maps/Kconfig +++ b/drivers/mtd/maps/Kconfig @@ -422,6 +422,21 @@ config MTD_H720X This enables access to the flash chips on the Hynix evaluation boards. If you have such a board, say 'Y'. +config MTD_TS7200_NOR + tristate "CFI Flash device mapped on TS-7200" + depends on MTD_CFI && MACH_TS72XX + help + This provides a map driver for the on-board flash of the Technologic + System's TS-7200 board. The 8MB (or 16MB) flash is splitted into 3 partitions + which are accessed as separate MTD devices. + +config MTD_TS7200_NOR_SIZE + int "Flash size (8 or 16mb)" + depends on MTD_TS7200_NOR + default "8" + help + Enter the NOR Flash size of your TS-7200 board. Can be 8 or 16. + # This needs CFI or JEDEC, depending on the cards found. config MTD_PCI tristate "PCI MTD driver" diff --git a/drivers/mtd/maps/Makefile b/drivers/mtd/maps/Makefile index bb035cd..775c2e7 100644 --- a/drivers/mtd/maps/Makefile +++ b/drivers/mtd/maps/Makefile @@ -56,6 +56,7 @@ obj-$(CONFIG_MTD_DMV182) += dmv182.o obj-$(CONFIG_MTD_PLATRAM) += plat-ram.o obj-$(CONFIG_MTD_INTEL_VR_NOR) += intel_vr_nor.o obj-$(CONFIG_MTD_BFIN_ASYNC) += bfin-async-flash.o +obj-$(CONFIG_MTD_TS7200_NOR) += ts7200_flash.o obj-$(CONFIG_MTD_RBTX4939) += rbtx4939-flash.o obj-$(CONFIG_MTD_VMU) += vmu-flash.o obj-$(CONFIG_MTD_GPIO_ADDR) += gpio-addr-flash.o diff --git a/drivers/mtd/maps/ts7200_flash.c b/drivers/mtd/maps/ts7200_flash.c new file mode 100644 index 0000000..94fb4f4 --- /dev/null +++ b/drivers/mtd/maps/ts7200_flash.c @@ -0,0 +1,116 @@ +/* + * ts7200_flash.c - mapping for TS-7200 SBCs (8mb NOR flash) + * No platform_device resource is used here. All is hardcoded. + * + * (c) Copyright 2006-2010 Matthieu Crapet + * Based on ts5500_flash.c by Sean Young + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +static struct mtd_info *mymtd; + +static struct map_info ts7200nor_map = { + .name = "Full TS-7200 NOR flash", + .size = 0, /* filled in later */ + .bankwidth = 2, + .phys = EP93XX_CS6_PHYS_BASE, +}; + +/* + * MTD partitioning stuff + */ +#ifdef CONFIG_MTD_PARTITIONS + +#define TS7200_BOOTROM_PART_SIZE (SZ_128K) +#define TS7200_REDBOOT_PART_SIZE (15*SZ_128K) + +static struct mtd_partition ts7200_nor_parts[] = +{ + { + .name = "TS-BOOTROM", + .offset = 0, + .size = TS7200_BOOTROM_PART_SIZE, + .mask_flags = MTD_WRITEABLE, /* force read-only */ + }, + { + .name = "RootFS", + .offset = MTDPART_OFS_APPEND, + .size = 0, /* filled in later */ + }, + { + .name = "Redboot", + .offset = MTDPART_OFS_APPEND, + .size = MTDPART_SIZ_FULL, /* up to the end */ + } +}; +#endif + +static int __init ts7200_nor_init(void) +{ + if (CONFIG_MTD_TS7200_NOR_SIZE <= 8) + ts7200nor_map.size = SZ_8M; + else + ts7200nor_map.size = SZ_16M; + + printk(KERN_NOTICE "TS-7200 flash mapping: %ldmo at 0x%x\n", + ts7200nor_map.size / SZ_1M, ts7200nor_map.phys); + + ts7200nor_map.virt = ioremap(ts7200nor_map.phys, ts7200nor_map.size - 1); + if (!ts7200nor_map.virt) { + printk("ts7200_flash: failed to ioremap\n"); + return -EIO; + } + + simple_map_init(&ts7200nor_map); + mymtd = do_map_probe("cfi_probe", &ts7200nor_map); + if (mymtd) { + mymtd->owner = THIS_MODULE; + add_mtd_device(mymtd); + #ifdef CONFIG_MTD_PARTITIONS + ts7200_nor_parts[1].size = ts7200nor_map.size - TS7200_REDBOOT_PART_SIZE; + return add_mtd_partitions(mymtd, ts7200_nor_parts, ARRAY_SIZE(ts7200_nor_parts)); + #else + return 0; + #endif + } + + iounmap(ts7200nor_map.virt); + return -ENXIO; +} + +static void __exit ts7200_nor_exit(void) +{ + if (mymtd) { + del_mtd_device(mymtd); + map_destroy(mymtd); + mymtd = NULL; + } + if (ts7200nor_map.virt) { + iounmap(ts7200nor_map.virt); + ts7200nor_map.virt = 0; + } +} + +module_init(ts7200_nor_init); +module_exit(ts7200_nor_exit); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Matthieu Crapet "); +MODULE_DESCRIPTION("MTD map driver for TS-7200 board"); +MODULE_VERSION("0.1"); -- 1.7.1