aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/mach-omap1/flash.c20
-rw-r--r--arch/arm/mach-s3c2410/nor-simtec.c3
-rw-r--r--drivers/mtd/maps/physmap.c22
3 files changed, 26 insertions, 19 deletions
diff --git a/arch/arm/mach-omap1/flash.c b/arch/arm/mach-omap1/flash.c
index 1749cb37dda..4665bfcd2ce 100644
--- a/arch/arm/mach-omap1/flash.c
+++ b/arch/arm/mach-omap1/flash.c
@@ -15,20 +15,12 @@
15 15
16void omap1_set_vpp(struct platform_device *pdev, int enable) 16void omap1_set_vpp(struct platform_device *pdev, int enable)
17{ 17{
18 static int count;
19 u32 l; 18 u32 l;
20 19
21 if (enable) { 20 l = omap_readl(EMIFS_CONFIG);
22 if (count++ == 0) { 21 if (enable)
23 l = omap_readl(EMIFS_CONFIG); 22 l |= OMAP_EMIFS_CONFIG_WP;
24 l |= OMAP_EMIFS_CONFIG_WP; 23 else
25 omap_writel(l, EMIFS_CONFIG); 24 l &= ~OMAP_EMIFS_CONFIG_WP;
26 } 25 omap_writel(l, EMIFS_CONFIG);
27 } else {
28 if (count && (--count == 0)) {
29 l = omap_readl(EMIFS_CONFIG);
30 l &= ~OMAP_EMIFS_CONFIG_WP;
31 omap_writel(l, EMIFS_CONFIG);
32 }
33 }
34} 26}
diff --git a/arch/arm/mach-s3c2410/nor-simtec.c b/arch/arm/mach-s3c2410/nor-simtec.c
index ad9f750f1e5..605aaccd097 100644
--- a/arch/arm/mach-s3c2410/nor-simtec.c
+++ b/arch/arm/mach-s3c2410/nor-simtec.c
@@ -35,9 +35,7 @@
35static void simtec_nor_vpp(struct platform_device *pdev, int vpp) 35static void simtec_nor_vpp(struct platform_device *pdev, int vpp)
36{ 36{
37 unsigned int val; 37 unsigned int val;
38 unsigned long flags;
39 38
40 local_irq_save(flags);
41 val = __raw_readb(BAST_VA_CTRL3); 39 val = __raw_readb(BAST_VA_CTRL3);
42 40
43 printk(KERN_DEBUG "%s(%d)\n", __func__, vpp); 41 printk(KERN_DEBUG "%s(%d)\n", __func__, vpp);
@@ -48,7 +46,6 @@ static void simtec_nor_vpp(struct platform_device *pdev, int vpp)
48 val &= ~BAST_CPLD_CTRL3_ROMWEN; 46 val &= ~BAST_CPLD_CTRL3_ROMWEN;
49 47
50 __raw_writeb(val, BAST_VA_CTRL3); 48 __raw_writeb(val, BAST_VA_CTRL3);
51 local_irq_restore(flags);
52} 49}
53 50
54static struct physmap_flash_data simtec_nor_pdata = { 51static struct physmap_flash_data simtec_nor_pdata = {
diff --git a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c
index abc562653b3..7e9233c503a 100644
--- a/drivers/mtd/maps/physmap.c
+++ b/drivers/mtd/maps/physmap.c
@@ -27,6 +27,8 @@ struct physmap_flash_info {
27 struct mtd_info *mtd[MAX_RESOURCES]; 27 struct mtd_info *mtd[MAX_RESOURCES];
28 struct mtd_info *cmtd; 28 struct mtd_info *cmtd;
29 struct map_info map[MAX_RESOURCES]; 29 struct map_info map[MAX_RESOURCES];
30 spinlock_t vpp_lock;
31 int vpp_refcnt;
30}; 32};
31 33
32static int physmap_flash_remove(struct platform_device *dev) 34static int physmap_flash_remove(struct platform_device *dev)
@@ -63,12 +65,26 @@ static void physmap_set_vpp(struct map_info *map, int state)
63{ 65{
64 struct platform_device *pdev; 66 struct platform_device *pdev;
65 struct physmap_flash_data *physmap_data; 67 struct physmap_flash_data *physmap_data;
68 struct physmap_flash_info *info;
69 unsigned long flags;
66 70
67 pdev = (struct platform_device *)map->map_priv_1; 71 pdev = (struct platform_device *)map->map_priv_1;
68 physmap_data = pdev->dev.platform_data; 72 physmap_data = pdev->dev.platform_data;
69 73
70 if (physmap_data->set_vpp) 74 if (!physmap_data->set_vpp)
71 physmap_data->set_vpp(pdev, state); 75 return;
76
77 info = platform_get_drvdata(pdev);
78
79 spin_lock_irqsave(&info->vpp_lock, flags);
80 if (state) {
81 if (++info->vpp_refcnt == 1) /* first nested 'on' */
82 physmap_data->set_vpp(pdev, 1);
83 } else {
84 if (--info->vpp_refcnt == 0) /* last nested 'off' */
85 physmap_data->set_vpp(pdev, 0);
86 }
87 spin_unlock_irqrestore(&info->vpp_lock, flags);
72} 88}
73 89
74static const char *rom_probe_types[] = { 90static const char *rom_probe_types[] = {
@@ -172,6 +188,8 @@ static int physmap_flash_probe(struct platform_device *dev)
172 if (err) 188 if (err)
173 goto err_out; 189 goto err_out;
174 190
191 spin_lock_init(&info->vpp_lock);
192
175 part_types = physmap_data->part_probe_types ? : part_probe_types; 193 part_types = physmap_data->part_probe_types ? : part_probe_types;
176 194
177 mtd_device_parse_register(info->cmtd, part_types, 0, 195 mtd_device_parse_register(info->cmtd, part_types, 0,