summaryrefslogtreecommitdiff
path: root/target/linux/ar71xx/patches-3.2/401-mtd-physmap-add-lock-unlock.patch
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2012-01-22 22:38:19 +0000
committerGabor Juhos <juhosg@openwrt.org>2012-01-22 22:38:19 +0000
commitaf015f956c35717909247a5732f6862d3de1476f (patch)
treec72d67ef23e35b8dd3e8177c4811773ed6eed759 /target/linux/ar71xx/patches-3.2/401-mtd-physmap-add-lock-unlock.patch
parent386cbfe45bc521baa889a8c261b2c77e69fc956f (diff)
downloadmtk-20170518-af015f956c35717909247a5732f6862d3de1476f.zip
mtk-20170518-af015f956c35717909247a5732f6862d3de1476f.tar.gz
mtk-20170518-af015f956c35717909247a5732f6862d3de1476f.tar.bz2
ar71xx: add initial support for 3.2
Tested on the following boards: ALFA AP96 TL-MR3220 v1 TL-WR1043ND v1 TL-WR2543ND v1 TL-WR703N v1 TL-WR741ND v1 TL-WR741ND v4 WNDR3700 v1 WZR-HP-G300NH SVN-Revision: 29868
Diffstat (limited to 'target/linux/ar71xx/patches-3.2/401-mtd-physmap-add-lock-unlock.patch')
-rw-r--r--target/linux/ar71xx/patches-3.2/401-mtd-physmap-add-lock-unlock.patch94
1 files changed, 94 insertions, 0 deletions
diff --git a/target/linux/ar71xx/patches-3.2/401-mtd-physmap-add-lock-unlock.patch b/target/linux/ar71xx/patches-3.2/401-mtd-physmap-add-lock-unlock.patch
new file mode 100644
index 0000000..61c3384
--- /dev/null
+++ b/target/linux/ar71xx/patches-3.2/401-mtd-physmap-add-lock-unlock.patch
@@ -0,0 +1,94 @@
+--- a/drivers/mtd/maps/physmap.c
++++ b/drivers/mtd/maps/physmap.c
+@@ -29,6 +29,66 @@ struct physmap_flash_info {
+ struct map_info map[MAX_RESOURCES];
+ };
+
++static struct platform_device *physmap_map2pdev(struct map_info *map)
++{
++ return (struct platform_device *) map->map_priv_1;
++}
++
++static void physmap_lock(struct map_info *map)
++{
++ struct platform_device *pdev;
++ struct physmap_flash_data *physmap_data;
++
++ pdev = physmap_map2pdev(map);
++ physmap_data = pdev->dev.platform_data;
++ physmap_data->lock(pdev);
++}
++
++static void physmap_unlock(struct map_info *map)
++{
++ struct platform_device *pdev;
++ struct physmap_flash_data *physmap_data;
++
++ pdev = physmap_map2pdev(map);
++ physmap_data = pdev->dev.platform_data;
++ physmap_data->unlock(pdev);
++}
++
++static map_word physmap_flash_read_lock(struct map_info *map, unsigned long ofs)
++{
++ map_word ret;
++
++ physmap_lock(map);
++ ret = inline_map_read(map, ofs);
++ physmap_unlock(map);
++
++ return ret;
++}
++
++static void physmap_flash_write_lock(struct map_info *map, map_word d,
++ unsigned long ofs)
++{
++ physmap_lock(map);
++ inline_map_write(map, d, ofs);
++ physmap_unlock(map);
++}
++
++static void physmap_flash_copy_from_lock(struct map_info *map, void *to,
++ unsigned long from, ssize_t len)
++{
++ physmap_lock(map);
++ inline_map_copy_from(map, to, from, len);
++ physmap_unlock(map);
++}
++
++static void physmap_flash_copy_to_lock(struct map_info *map, unsigned long to,
++ const void *from, ssize_t len)
++{
++ physmap_lock(map);
++ inline_map_copy_to(map, to, from, len);
++ physmap_unlock(map);
++}
++
+ static int physmap_flash_remove(struct platform_device *dev)
+ {
+ struct physmap_flash_info *info;
+@@ -140,6 +200,13 @@ static int physmap_flash_probe(struct pl
+
+ simple_map_init(&info->map[i]);
+
++ if (physmap_data->lock && physmap_data->unlock) {
++ info->map[i].read = physmap_flash_read_lock;
++ info->map[i].write = physmap_flash_write_lock;
++ info->map[i].copy_from = physmap_flash_copy_from_lock;
++ info->map[i].copy_to = physmap_flash_copy_to_lock;
++ }
++
+ probe_type = rom_probe_types;
+ if (physmap_data->probe_type == NULL) {
+ for (; info->mtd[i] == NULL && *probe_type != NULL; probe_type++)
+--- a/include/linux/mtd/physmap.h
++++ b/include/linux/mtd/physmap.h
+@@ -26,6 +26,8 @@ struct physmap_flash_data {
+ unsigned int width;
+ int (*init)(struct platform_device *);
+ void (*exit)(struct platform_device *);
++ void (*lock)(struct platform_device *);
++ void (*unlock)(struct platform_device *);
+ void (*set_vpp)(struct platform_device *, int);
+ unsigned int nr_parts;
+ unsigned int pfow_base;