diff options
author | Aaron Sierra <asierra@xes-inc.com> | 2014-09-25 13:20:24 -0400 |
---|---|---|
committer | Brian Norris <computersforpeace@gmail.com> | 2015-01-10 02:24:27 -0500 |
commit | 6958024ad5cdd78deae4da47a8722b06317dff45 (patch) | |
tree | 14e081920d299eab8c7fa7ece0f67aefd60c37df /drivers/mtd/chips | |
parent | 3fc1cf5f0af4b625adff03c610f188fa8bc89911 (diff) |
mtd: map_rom: Support UBI on ROM
UBI needs to know the physical erase block size, even on read-only
devices, since it defines the on-device layout. Use a device-tree
provided value to support previously written UBI on read-only NOR.
UBI also needs a non-zero writebufsize, so we set it to one.
Note: This was implemented because hardware write-protected CFI
NOR cannot be probed for the physical erase block size.
Signed-off-by: Joe Schultz <jschultz@xes-inc.ccom>
Signed-off-by: Aaron Sierra <asierra@xes-inc.ccom>
[Brian: removed unneeded #ifdef, note 'optional' erase-size property]
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Diffstat (limited to 'drivers/mtd/chips')
-rw-r--r-- | drivers/mtd/chips/map_rom.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/drivers/mtd/chips/map_rom.c b/drivers/mtd/chips/map_rom.c index 47a43cf7e5c6..e67f73ab44c9 100644 --- a/drivers/mtd/chips/map_rom.c +++ b/drivers/mtd/chips/map_rom.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/errno.h> | 11 | #include <linux/errno.h> |
12 | #include <linux/slab.h> | 12 | #include <linux/slab.h> |
13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
14 | #include <linux/of.h> | ||
14 | #include <linux/mtd/mtd.h> | 15 | #include <linux/mtd/mtd.h> |
15 | #include <linux/mtd/map.h> | 16 | #include <linux/mtd/map.h> |
16 | 17 | ||
@@ -28,6 +29,15 @@ static struct mtd_chip_driver maprom_chipdrv = { | |||
28 | .module = THIS_MODULE | 29 | .module = THIS_MODULE |
29 | }; | 30 | }; |
30 | 31 | ||
32 | static unsigned int default_erasesize(struct map_info *map) | ||
33 | { | ||
34 | const __be32 *erase_size = NULL; | ||
35 | |||
36 | erase_size = of_get_property(map->device_node, "erase-size", NULL); | ||
37 | |||
38 | return !erase_size ? map->size : be32_to_cpu(*erase_size); | ||
39 | } | ||
40 | |||
31 | static struct mtd_info *map_rom_probe(struct map_info *map) | 41 | static struct mtd_info *map_rom_probe(struct map_info *map) |
32 | { | 42 | { |
33 | struct mtd_info *mtd; | 43 | struct mtd_info *mtd; |
@@ -47,8 +57,9 @@ static struct mtd_info *map_rom_probe(struct map_info *map) | |||
47 | mtd->_sync = maprom_nop; | 57 | mtd->_sync = maprom_nop; |
48 | mtd->_erase = maprom_erase; | 58 | mtd->_erase = maprom_erase; |
49 | mtd->flags = MTD_CAP_ROM; | 59 | mtd->flags = MTD_CAP_ROM; |
50 | mtd->erasesize = map->size; | 60 | mtd->erasesize = default_erasesize(map); |
51 | mtd->writesize = 1; | 61 | mtd->writesize = 1; |
62 | mtd->writebufsize = 1; | ||
52 | 63 | ||
53 | __module_get(THIS_MODULE); | 64 | __module_get(THIS_MODULE); |
54 | return mtd; | 65 | return mtd; |