diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-01-24 13:31:34 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-01-24 13:31:34 -0500 |
| commit | b8be634e01b400fa2528848ad0cd6a5580a15bc4 (patch) | |
| tree | f36da264249540727a60e13a54d1d44c8821b48d | |
| parent | 298a4c3a57fed38df365a6807728d1930a72c728 (diff) | |
| parent | f5e2bae0aad03164ffc7ce9dfeee6608e2c87dba (diff) | |
Merge git://git.infradead.org/~dwmw2/mtd-2.6.33
* git://git.infradead.org/~dwmw2/mtd-2.6.33:
mtd: tests: fix read, speed and stress tests on NOR flash
mtd: Really add ARM pismo support
kmsg_dump: Dump on crash_kexec as well
| -rw-r--r-- | drivers/mtd/maps/Kconfig | 17 | ||||
| -rw-r--r-- | drivers/mtd/maps/pismo.c | 320 | ||||
| -rw-r--r-- | drivers/mtd/mtdoops.c | 2 | ||||
| -rw-r--r-- | drivers/mtd/tests/mtd_readtest.c | 6 | ||||
| -rw-r--r-- | drivers/mtd/tests/mtd_speedtest.c | 7 | ||||
| -rw-r--r-- | drivers/mtd/tests/mtd_stresstest.c | 6 | ||||
| -rw-r--r-- | include/linux/kmsg_dump.h | 1 | ||||
| -rw-r--r-- | include/linux/mtd/pismo.h | 17 | ||||
| -rw-r--r-- | kernel/kexec.c | 4 | ||||
| -rw-r--r-- | kernel/panic.c | 3 | ||||
| -rw-r--r-- | kernel/printk.c | 1 |
11 files changed, 379 insertions, 5 deletions
diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig index 4c364d44ad59..2de0cc823d60 100644 --- a/drivers/mtd/maps/Kconfig +++ b/drivers/mtd/maps/Kconfig | |||
| @@ -549,4 +549,21 @@ config MTD_VMU | |||
| 549 | To build this as a module select M here, the module will be called | 549 | To build this as a module select M here, the module will be called |
| 550 | vmu-flash. | 550 | vmu-flash. |
| 551 | 551 | ||
| 552 | config MTD_PISMO | ||
| 553 | tristate "MTD discovery driver for PISMO modules" | ||
| 554 | depends on I2C | ||
| 555 | depends on ARCH_VERSATILE | ||
| 556 | help | ||
| 557 | This driver allows for discovery of PISMO modules - see | ||
| 558 | <http://www.pismoworld.org/>. These are small modules containing | ||
| 559 | up to five memory devices (eg, SRAM, flash, DOC) described by an | ||
| 560 | I2C EEPROM. | ||
| 561 | |||
| 562 | This driver does not create any MTD maps itself; instead it | ||
| 563 | creates MTD physmap and MTD SRAM platform devices. If you | ||
| 564 | enable this option, you should consider enabling MTD_PHYSMAP | ||
| 565 | and/or MTD_PLATRAM according to the devices on your module. | ||
| 566 | |||
| 567 | When built as a module, it will be called pismo.ko | ||
| 568 | |||
| 552 | endmenu | 569 | endmenu |
diff --git a/drivers/mtd/maps/pismo.c b/drivers/mtd/maps/pismo.c new file mode 100644 index 000000000000..c48cad271f5d --- /dev/null +++ b/drivers/mtd/maps/pismo.c | |||
| @@ -0,0 +1,320 @@ | |||
| 1 | /* | ||
| 2 | * PISMO memory driver - http://www.pismoworld.org/ | ||
| 3 | * | ||
| 4 | * For ARM Realview and Versatile platforms | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2 of the License. | ||
| 9 | */ | ||
| 10 | #include <linux/init.h> | ||
| 11 | #include <linux/module.h> | ||
| 12 | #include <linux/i2c.h> | ||
| 13 | #include <linux/platform_device.h> | ||
| 14 | #include <linux/spinlock.h> | ||
| 15 | #include <linux/mutex.h> | ||
| 16 | #include <linux/mtd/physmap.h> | ||
| 17 | #include <linux/mtd/plat-ram.h> | ||
| 18 | #include <linux/mtd/pismo.h> | ||
| 19 | |||
| 20 | #define PISMO_NUM_CS 5 | ||
| 21 | |||
| 22 | struct pismo_cs_block { | ||
| 23 | u8 type; | ||
| 24 | u8 width; | ||
| 25 | __le16 access; | ||
| 26 | __le32 size; | ||
| 27 | u32 reserved[2]; | ||
| 28 | char device[32]; | ||
| 29 | } __packed; | ||
| 30 | |||
| 31 | struct pismo_eeprom { | ||
| 32 | struct pismo_cs_block cs[PISMO_NUM_CS]; | ||
| 33 | char board[15]; | ||
| 34 | u8 sum; | ||
| 35 | } __packed; | ||
| 36 | |||
| 37 | struct pismo_mem { | ||
| 38 | phys_addr_t base; | ||
| 39 | u32 size; | ||
| 40 | u16 access; | ||
| 41 | u8 width; | ||
| 42 | u8 type; | ||
| 43 | }; | ||
| 44 | |||
| 45 | struct pismo_data { | ||
| 46 | struct i2c_client *client; | ||
| 47 | void (*vpp)(void *, int); | ||
| 48 | void *vpp_data; | ||
| 49 | struct platform_device *dev[PISMO_NUM_CS]; | ||
| 50 | }; | ||
| 51 | |||
| 52 | /* FIXME: set_vpp could do with a better calling convention */ | ||
| 53 | static struct pismo_data *vpp_pismo; | ||
| 54 | static DEFINE_MUTEX(pismo_mutex); | ||
| 55 | |||
| 56 | static int pismo_setvpp_probe_fix(struct pismo_data *pismo) | ||
| 57 | { | ||
| 58 | mutex_lock(&pismo_mutex); | ||
| 59 | if (vpp_pismo) { | ||
| 60 | mutex_unlock(&pismo_mutex); | ||
| 61 | kfree(pismo); | ||
| 62 | return -EBUSY; | ||
| 63 | } | ||
| 64 | vpp_pismo = pismo; | ||
| 65 | mutex_unlock(&pismo_mutex); | ||
| 66 | return 0; | ||
| 67 | } | ||
| 68 | |||
| 69 | static void pismo_setvpp_remove_fix(struct pismo_data *pismo) | ||
| 70 | { | ||
| 71 | mutex_lock(&pismo_mutex); | ||
| 72 | if (vpp_pismo == pismo) | ||
| 73 | vpp_pismo = NULL; | ||
| 74 | mutex_unlock(&pismo_mutex); | ||
| 75 | } | ||
| 76 | |||
| 77 | static void pismo_set_vpp(struct map_info *map, int on) | ||
| 78 | { | ||
| 79 | struct pismo_data *pismo = vpp_pismo; | ||
| 80 | |||
| 81 | pismo->vpp(pismo->vpp_data, on); | ||
| 82 | } | ||
| 83 | /* end of hack */ | ||
| 84 | |||
| 85 | |||
| 86 | static unsigned int __devinit pismo_width_to_bytes(unsigned int width) | ||
| 87 | { | ||
| 88 | width &= 15; | ||
| 89 | if (width > 2) | ||
| 90 | return 0; | ||
| 91 | return 1 << width; | ||
| 92 | } | ||
| 93 | |||
| 94 | static int __devinit pismo_eeprom_read(struct i2c_client *client, void *buf, | ||
| 95 | u8 addr, size_t size) | ||
| 96 | { | ||
| 97 | int ret; | ||
| 98 | struct i2c_msg msg[] = { | ||
| 99 | { | ||
| 100 | .addr = client->addr, | ||
| 101 | .len = sizeof(addr), | ||
| 102 | .buf = &addr, | ||
| 103 | }, { | ||
| 104 | .addr = client->addr, | ||
| 105 | .flags = I2C_M_RD, | ||
| 106 | .len = size, | ||
| 107 | .buf = buf, | ||
| 108 | }, | ||
| 109 | }; | ||
| 110 | |||
| 111 | ret = i2c_transfer(client->adapter, msg, ARRAY_SIZE(msg)); | ||
| 112 | |||
| 113 | return ret == ARRAY_SIZE(msg) ? size : -EIO; | ||
| 114 | } | ||
| 115 | |||
| 116 | static int __devinit pismo_add_device(struct pismo_data *pismo, int i, | ||
| 117 | struct pismo_mem *region, const char *name, void *pdata, size_t psize) | ||
| 118 | { | ||
| 119 | struct platform_device *dev; | ||
| 120 | struct resource res = { }; | ||
| 121 | phys_addr_t base = region.base; | ||
| 122 | int ret; | ||
| 123 | |||
| 124 | if (base == ~0) | ||
| 125 | return -ENXIO; | ||
| 126 | |||
| 127 | res.start = base; | ||
| 128 | res.end = base + region->size - 1; | ||
| 129 | res.flags = IORESOURCE_MEM; | ||
| 130 | |||
| 131 | dev = platform_device_alloc(name, i); | ||
| 132 | if (!dev) | ||
| 133 | return -ENOMEM; | ||
| 134 | dev->dev.parent = &pismo->client->dev; | ||
| 135 | |||
| 136 | do { | ||
| 137 | ret = platform_device_add_resources(dev, &res, 1); | ||
| 138 | if (ret) | ||
| 139 | break; | ||
| 140 | |||
| 141 | ret = platform_device_add_data(dev, pdata, psize); | ||
| 142 | if (ret) | ||
| 143 | break; | ||
| 144 | |||
| 145 | ret = platform_device_add(dev); | ||
| 146 | if (ret) | ||
| 147 | break; | ||
| 148 | |||
| 149 | pismo->dev[i] = dev; | ||
| 150 | return 0; | ||
| 151 | } while (0); | ||
| 152 | |||
| 153 | platform_device_put(dev); | ||
| 154 | return ret; | ||
| 155 | } | ||
| 156 | |||
| 157 | static int __devinit pismo_add_nor(struct pismo_data *pismo, int i, | ||
| 158 | struct pismo_mem *region) | ||
| 159 | { | ||
| 160 | struct physmap_flash_data data = { | ||
| 161 | .width = region->wid | ||
