Skip to contentSkip to conversation

Switch ARM platforms from integrator-flash to physmap

PATCH Superseded Marc Zyngier 6 participants 23 messages May 16, 2011 – May 24, 2011

Subsystems (8)

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v5 cover Switch ARM platforms from integrator-flash to physmap

As the integrator-flash driver is mostly a duplicate of physmap, move all users of this driver to physmap and get rid of the then unused driver.

Also change the set_vpp() method in physmap to pass the platform_device instead of the map_info. This allows for a substantial cleanup in drivers/mtd/maps/pismo.c

This patch set has been ok'ed by RMK, who is willing to take it through his tree. This requires an ACK from the MTD maintainers. David Woodhouse cc-ed on the whole patch set in case he'd prefer to merge it via his MTD tree.

Chanes since v4:
- Changed set_vpp() method in physmap
- Rebased against v2.6.39-rc7

Changes since v3:
- Dropped patch for aaec2000 platform (removed from tree)
- Rebased against next-20110317

Changes since v2:
- Add integrator-flash's init()/exit() methods in order to control write access to the various onboard programmable components, as per RMK request.
- Rebased against 2.6.38-rc2

Changes since initial revision:
- Rebased against linux-next (20110107). It should apply cleanly on top of Linus' tree, except for a small conflict in the last patch of the serie.

Marc Zyngier (8):
MTD: Add integrator-flash feature to physmap
ARM: Realview: Use physmap driver instead of integrator-flash
ARM: Versatile: Use physmap driver instead of integrator-flash
ARM: VExpress: Use physmap driver instead of integrator-flash
ARM: Integrator/AP: Use physmap driver instead of integrator-flash
ARM: Integrator/CP: Use physmap driver instead of integrator-flash
MTD: Remove integrator-flash
MTD: physmap: let set_vpp() pass a platform_device instead of a
map_info

 arch/arm/configs/realview-smp_defconfig   |    2 +-
 arch/arm/configs/realview_defconfig       |    2 +-
 arch/arm/configs/versatile_defconfig      |    2 +-
 arch/arm/mach-at91/board-at572d940hf_ek.c |    4 -
 arch/arm/mach-integrator/integrator_ap.c  |   13 +-
 arch/arm/mach-integrator/integrator_cp.c  |   13 +-
 arch/arm/mach-omap1/flash.c               |    2 +-
 arch/arm/mach-pxa/hx4700.c                |    2 +-
 arch/arm/mach-pxa/magician.c              |    2 +-
 arch/arm/mach-realview/core.c             |   31 +---
 arch/arm/mach-s3c2410/nor-simtec.c        |    2 +-
 arch/arm/mach-versatile/core.c            |   31 +---
 arch/arm/mach-vexpress/v2m.c              |   22 +--
 arch/arm/plat-omap/include/plat/flash.h   |    2 +-
 drivers/mtd/Kconfig                       |    3 +-
 drivers/mtd/maps/Makefile                 |    1 -
 drivers/mtd/maps/integrator-flash.c       |  309 -----------------------------
 drivers/mtd/maps/physmap.c                |   31 +++-
 drivers/mtd/maps/pismo.c                  |   40 +----
 include/linux/mtd/physmap.h               |    4 +-
 20 files changed, 68 insertions(+), 450 deletions(-)
 delete mode 100644 drivers/mtd/maps/integrator-flash.c
#1 lore raw

PATCH v5 1/8 MTD: Add integrator-flash feature to physmap

In the process of moving platforms away from integrator-flash (aka armflash), add to physmap the few features that make armflash unique:

- optionnal probing for the AFS partition type
- init() and exit() methods, used by Integrator to control write access to the various onboard programmable components

---
 drivers/mtd/maps/physmap.c  |   16 +++++++++++++++-
 include/linux/mtd/physmap.h |    2 ++
 2 files changed, 17 insertions(+), 1 deletions(-)
drivers/mtd/maps/physmap.c +15 -1
index 7522df4..49676b7 100644
@@ -67,6 +67,10 @@ static int physmap_flash_remove(struct platform_device *dev)
 		if (info->mtd[i] != NULL)
 			map_destroy(info->mtd[i]);
 	}
+
+	if (physmap_data->exit)
+		physmap_data->exit(dev);
+
 	return 0;
 }
 
@@ -77,7 +81,11 @@ static const char *rom_probe_types[] = {
 					"map_rom",
 					NULL };
 #ifdef CONFIG_MTD_PARTITIONS
-static const char *part_probe_types[] = { "cmdlinepart", "RedBoot", NULL };
+static const char *part_probe_types[] = { "cmdlinepart", "RedBoot",
+#ifdef CONFIG_MTD_AFS_PARTS
+					  "afs",
+#endif
+					  NULL };
 #endif
 
 static int physmap_flash_probe(struct platform_device *dev)
@@ -100,6 +108,12 @@ static int physmap_flash_probe(struct platform_device *dev)
 		goto err_out;
 	}
 
+	if (physmap_data->init) {
+		err = physmap_data->init(dev);
+		if (err)
+			goto err_out;
+	}
+
 	platform_set_drvdata(dev, info);
 
 	for (i = 0; i < dev->num_resources; i++) {
include/linux/mtd/physmap.h +2 -0
index bcfd9f7..d37cca0 100644
@@ -22,6 +22,8 @@ struct map_info;
 
 struct physmap_flash_data {
 	unsigned int		width;
+	int			(*init)(struct platform_device *);
+	void			(*exit)(struct platform_device *);
 	void			(*set_vpp)(struct map_info *, int);
 	unsigned int		nr_parts;
 	unsigned int		pfow_base;
Signature · 1 line
1.7.0.4
#2 lore raw

PATCH v5 1/8 MTD: Add integrator-flash feature to physmap

Hi,

drivers/mtd/maps/physmap.c static const char *rom_probe_types[] = { · line 88

Quoted 7 lines · Marc Zyngier

#ifdef CONFIG_MTD_PARTITIONS

drivers/mtd/maps/physmap.c +5 -1
-static const char *part_probe_types[] = { "cmdlinepart", "RedBoot", NULL };
+static const char *part_probe_types[] = { "cmdlinepart", "RedBoot",
+#ifdef CONFIG_MTD_AFS_PARTS
+					  "afs",
+#endif
+					  NULL };

We want to kill CONFIG_MTD_PARTITIONS:

http://www.linux-mtd.infradead.org/doc/general.html#L_partitions_ban

and Jamie Iles is doing this ATM. The reason for this is that MTD partitions are used always everywhere anyway, and current amount of ifdefs is scary.

I see this CONFIG_MTD_AFS_PARTS you add and I do not think it is the right way to go. I cannot tell you now what would be exactly the right way, but something which does not require ifdef, something where drivers do not contain any information about partition types like "afs" or "cmdlinepart" or whatever, something where partition types are registered within an infrastructure and most of the stuff is hidden from the drivers.

I think we should ban stuff like the above as well and force people to create saner MTD partitions support.

Sorry if this sounds like an attack, it is not. I just think that we carry crap for too long and should start forcing people to clean it up by not accepting changes :-)

Signature · 2 lines
Best Regards,
Artem Bityutskiy (????? ????????)
#3 lore raw

PATCH v5 1/8 MTD: Add integrator-flash feature to physmap

Quoted 3 lines · Artem Bityutskiy

Sorry if this sounds like an attack, it is not. I just think that we carry crap for too long and should start forcing people to clean it up by not accepting changes :-)

Sorry, I forgot to note that I do not insist that you have to re-work MTD partitions support - you already do a very good thing by killing a redundant driver, and delaying this would be counter-productive. But I anyway wanted to express my thoughts.

Signature · 2 lines
Best Regards,
Artem Bityutskiy (????? ????????)
#4 lore raw

PATCH v5 1/8 MTD: Add integrator-flash feature to physmap

Quoted 9 lines · Artem Bityutskiy
Quoted 3 lines · Artem Bityutskiy

Sorry if this sounds like an attack, it is not. I just think that we carry crap for too long and should start forcing people to clean it up by not accepting changes :-)

Sorry, I forgot to note that I do not insist that you have to re-work MTD partitions support - you already do a very good thing by killing a redundant driver, and delaying this would be counter-productive. But I anyway wanted to express my thoughts.

So, what's happening with this patch set? I'd like to have an ack from the MTD people for the set.

#5 lore raw

PATCH v5 1/8 MTD: Add integrator-flash feature to physmap

Quoted 6 lines · Russell King - ARM Linux
Quoted 5 lines · Artem Bityutskiy
Quoted 3 lines · Artem Bityutskiy

Sorry if this sounds like an attack, it is not. I just think that we carry crap for too long and should start forcing people to clean it up by not accepting changes :-)

Quoted 7 lines
Quoted 4 lines

Sorry, I forgot to note that I do not insist that you have to re-work MTD partitions support - you already do a very good thing by killing a redundant driver, and delaying this would be counter-productive. But I anyway wanted to express my thoughts.

So, what's happening with this patch set? I'd like to have an ack from the MTD people for the set.

David should answer, but from my POW the patches are OK. The "#ifdef CONFIG_MTD_AFS_PARTS" is ugly. I think it can be just killed, it just needs an additional patch to silence the kernel (completely untested, Marc, could you please check it?):

#6 lore raw

PATCH v5 1/8 MTD: Add integrator-flash feature to physmap

Quoted 1 line · Artem Bityutskiy

from my POW

Sorry, I've just been told that I should use the correct form - POV, not POW :-)

Signature · 2 lines
Best Regards,
Artem Bityutskiy (????? ????????)
#7 lore raw

PATCH v5 1/8 MTD: Add integrator-flash feature to physmap

In reply to Artem Bityutskiy
Quoted 12 lines · Artem Bityutskiy
Quoted 11 lines · Russell King - ARM Linux
Quoted 9 lines · Artem Bityutskiy
Quoted 3 lines · Artem Bityutskiy

Sorry if this sounds like an attack, it is not. I just think that we carry crap for too long and should start forcing people to clean it up by not accepting changes :-)

Sorry, I forgot to note that I do not insist that you have to re-work MTD partitions support - you already do a very good thing by killing a redundant driver, and delaying this would be counter-productive. But I anyway wanted to express my thoughts.

Quoted 7 lines
Quoted 2 lines

So, what's happening with this patch set? I'd like to have an ack from the MTD people for the set.

David should answer, but from my POW the patches are OK. The "#ifdef CONFIG_MTD_AFS_PARTS" is ugly. I think it can be just killed, it just needs an additional patch to silence the kernel (completely untested, Marc, could you please check it?):

Looks OK to me, as long as people don't miss the information (could make the "where's my partition gone?" question harder to answer...).

As this change is orthogonal to mine, I suggest this change goes via the MTD tree, independently from this patch set. I post a v6 later today (without the #ifdef-ery).

Cheers,

	M.
Signature · 1 line
Reality is an implementation detail.
#8 lore raw

PATCH v5 1/8 MTD: Add integrator-flash feature to physmap

Quoted 3 lines · Marc Zyngier

As this change is orthogonal to mine, I suggest this change goes via the MTD tree, independently from this patch set. I post a v6 later today (without the #ifdef-ery).

Fine with me, thanks.

Signature · 2 lines
Best Regards,
Artem Bityutskiy (????? ????????)
#9 lore raw

PATCH v5 1/8 MTD: Add integrator-flash feature to physmap

In reply to Marc Zyngier
Quoted 16 lines · Marc Zyngier
Quoted 15 lines · Artem Bityutskiy
Quoted 13 lines · Russell King - ARM Linux
Quoted 9 lines · Artem Bityutskiy
Quoted 3 lines · Artem Bityutskiy

Sorry if this sounds like an attack, it is not. I just think that we carry crap for too long and should start forcing people to clean it up by not accepting changes :-)

Sorry, I forgot to note that I do not insist that you have to re-work MTD partitions support - you already do a very good thing by killing a redundant driver, and delaying this would be counter-productive. But I anyway wanted to express my thoughts.

So, what's happening with this patch set? I'd like to have an ack from the MTD people for the set.

Quoted 7 lines
Quoted 4 lines

David should answer, but from my POW the patches are OK. The "#ifdef CONFIG_MTD_AFS_PARTS" is ugly. I think it can be just killed, it just needs an additional patch to silence the kernel (completely untested, Marc, could you please check it?):

Looks OK to me, as long as people don't miss the information (could make the "where's my partition gone?" question harder to answer...).

I've pushed my patch to my l2-mtd-2.6.git tree, if dwmw2 accepts it it'll go upstream.

Signature · 2 lines
Best Regards,
Artem Bityutskiy (????? ????????)
#10 lore raw

PATCH v5 1/8 MTD: Add integrator-flash feature to physmap

Quoted 22 lines · Artem Bityutskiy
Quoted 21 lines · Marc Zyngier
Quoted 19 lines · Artem Bityutskiy
Quoted 6 lines · Russell King - ARM Linux
Quoted 5 lines · Artem Bityutskiy
Quoted 3 lines · Artem Bityutskiy

Sorry if this sounds like an attack, it is not. I just think that we carry crap for too long and should start forcing people to clean it up by not accepting changes :-)

Quoted 7 lines
Quoted 4 lines

Sorry, I forgot to note that I do not insist that you have to re-work MTD partitions support - you already do a very good thing by killing a redundant driver, and delaying this would be counter-productive. But I anyway wanted to express my thoughts.

So, what's happening with this patch set? I'd like to have an ack from the MTD people for the set.

David should answer, but from my POW the patches are OK. The "#ifdef CONFIG_MTD_AFS_PARTS" is ugly. I think it can be just killed, it just needs an additional patch to silence the kernel (completely untested, Marc, could you please check it?):

Quoted 5 lines
Quoted 2 lines

Looks OK to me, as long as people don't miss the information (could make the "where's my partition gone?" question harder to answer...).

I've pushed my patch to my l2-mtd-2.6.git tree, if dwmw2 accepts it it'll go upstream.

I've also committed them to my tree too.

#11 lore raw

PATCH v5 1/8 MTD: Add integrator-flash feature to physmap

In reply to Marc Zyngier

include/linux/mtd/physmap.h struct map_info; · line 29

Quoted 11 lines · Marc Zyngier
include/linux/mtd/physmap.h +2 -0
@@ -22,6 +22,8 @@ struct map_info;
 
 ?struct physmap_flash_data {
 ? ? ? ?unsigned int ? ? ? ? ? ?width;
+ ? ? ? int ? ? ? ? ? ? ? ? ? ? (*init)(struct platform_device *);
+ ? ? ? void ? ? ? ? ? ? ? ? ? ?(*exit)(struct platform_device *);
 ? ? ? ?void ? ? ? ? ? ? ? ? ? ?(*set_vpp)(struct map_info *, int);
 ? ? ? ?unsigned int ? ? ? ? ? ?nr_parts;
 ? ? ? ?unsigned int ? ? ? ? ? ?pfow_base;

you use the platform_device structure but never include any header for it. please add "struct platform_device;" to the top of this file after the #includes.

include/linux/mtd/physmap.h:25: warning: ?struct platform_device? declared inside parameter list include/linux/mtd/physmap.h:25: warning: its scope is only this definition or declaration, which is probably not what you want include/linux/mtd/physmap.h:26: warning: ?struct platform_device? declared inside parameter list include/linux/mtd/physmap.h:27: warning: ?struct platform_device? declared inside parameter list
-mike

#12 lore raw

PATCH v5 2/8 ARM: Realview: Use physmap driver instead of integrator-flash

In reply to Marc Zyngier

Tested on a PB11-MPCore.

---
 arch/arm/configs/realview-smp_defconfig |    2 +-
 arch/arm/configs/realview_defconfig     |    2 +-
 arch/arm/mach-realview/core.c           |   31 ++++---------------------------
 3 files changed, 6 insertions(+), 29 deletions(-)
arch/arm/configs/realview-smp_defconfig +1 -1
index 5ca7a61..abe61bf 100644
@@ -38,7 +38,7 @@ CONFIG_MTD_BLOCK=y
 CONFIG_MTD_CFI=y
 CONFIG_MTD_CFI_INTELEXT=y
 CONFIG_MTD_CFI_AMDSTD=y
-CONFIG_MTD_ARM_INTEGRATOR=y
+CONFIG_MTD_PHYSMAP=y
 CONFIG_ARM_CHARLCD=y
 CONFIG_NETDEVICES=y
 CONFIG_SMSC_PHY=y
arch/arm/configs/realview_defconfig +1 -1
index fcaa603..7079cbe 100644
@@ -37,7 +37,7 @@ CONFIG_MTD_BLOCK=y
 CONFIG_MTD_CFI=y
 CONFIG_MTD_CFI_INTELEXT=y
 CONFIG_MTD_CFI_AMDSTD=y
-CONFIG_MTD_ARM_INTEGRATOR=y
+CONFIG_MTD_PHYSMAP=y
 CONFIG_ARM_CHARLCD=y
 CONFIG_NETDEVICES=y
 CONFIG_SMSC_PHY=y
arch/arm/mach-realview/core.c +4 -27
index 75dbc87..d3f1dde 100644
@@ -31,6 +31,7 @@
 #include <linux/amba/mmci.h>
 #include <linux/gfp.h>
 #include <linux/clkdev.h>
+#include <linux/mtd/physmap.h>
 
 #include <asm/system.h>
 #include <mach/hardware.h>
@@ -41,7 +42,6 @@
 #include <asm/hardware/icst.h>
 
 #include <asm/mach/arch.h>
-#include <asm/mach/flash.h>
 #include <asm/mach/irq.h>
 #include <asm/mach/map.h>
 
@@ -77,27 +77,7 @@ void __init realview_adjust_zones(unsigned long *size, unsigned long *hole)
 
 #define REALVIEW_FLASHCTRL    (__io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_FLASH_OFFSET)
 
-static int realview_flash_init(void)
-{
-	u32 val;
-
-	val = __raw_readl(REALVIEW_FLASHCTRL);
-	val &= ~REALVIEW_FLASHPROG_FLVPPEN;
-	__raw_writel(val, REALVIEW_FLASHCTRL);
-
-	return 0;
-}
-
-static void realview_flash_exit(void)
-{
-	u32 val;
-
-	val = __raw_readl(REALVIEW_FLASHCTRL);
-	val &= ~REALVIEW_FLASHPROG_FLVPPEN;
-	__raw_writel(val, REALVIEW_FLASHCTRL);
-}
-
-static void realview_flash_set_vpp(int on)
+static void realview_flash_set_vpp(struct map_info *map, int on)
 {
 	u32 val;
 
@@ -109,16 +89,13 @@ static void realview_flash_set_vpp(int on)
 	__raw_writel(val, REALVIEW_FLASHCTRL);
 }
 
-static struct flash_platform_data realview_flash_data = {
-	.map_name		= "cfi_probe",
+static struct physmap_flash_data realview_flash_data = {
 	.width			= 4,
-	.init			= realview_flash_init,
-	.exit			= realview_flash_exit,
 	.set_vpp		= realview_flash_set_vpp,
 };
 
 struct platform_device realview_flash_device = {
-	.name			= "armflash",
+	.name			= "physmap-flash",
 	.id			= 0,
 	.dev			= {
 		.platform_data	= &realview_flash_data,
Signature · 1 line
1.7.0.4
#13 lore raw

PATCH v5 3/8 ARM: Versatile: Use physmap driver instead of integrator-flash

In reply to Marc Zyngier
---
 arch/arm/configs/versatile_defconfig |    2 +-
 arch/arm/mach-versatile/core.c       |   31 ++++---------------------------
 2 files changed, 5 insertions(+), 28 deletions(-)
arch/arm/configs/versatile_defconfig +1 -1
index 0ce710f..cdd4d2b 100644
@@ -32,7 +32,7 @@ CONFIG_MTD_BLOCK=y
 CONFIG_MTD_CFI=y
 CONFIG_MTD_CFI_ADV_OPTIONS=y
 CONFIG_MTD_CFI_INTELEXT=y
-CONFIG_MTD_ARM_INTEGRATOR=y
+CONFIG_MTD_PHYSMAP=y
 CONFIG_BLK_DEV_RAM=y
 CONFIG_EEPROM_LEGACY=m
 CONFIG_NETDEVICES=y
arch/arm/mach-versatile/core.c +4 -27
index eb7ffa0..06f406a 100644
@@ -32,6 +32,7 @@
 #include <linux/io.h>
 #include <linux/gfp.h>
 #include <linux/clkdev.h>
+#include <linux/mtd/physmap.h>
 
 #include <asm/system.h>
 #include <asm/irq.h>
@@ -42,7 +43,6 @@
 #include <asm/mach-types.h>
 
 #include <asm/mach/arch.h>
-#include <asm/mach/flash.h>
 #include <asm/mach/irq.h>
 #include <asm/mach/time.h>
 #include <asm/mach/map.h>
@@ -190,27 +190,7 @@ void __init versatile_map_io(void)
 
 #define VERSATILE_FLASHCTRL    (__io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_FLASH_OFFSET)
 
-static int versatile_flash_init(void)
-{
-	u32 val;
-
-	val = __raw_readl(VERSATILE_FLASHCTRL);
-	val &= ~VERSATILE_FLASHPROG_FLVPPEN;
-	__raw_writel(val, VERSATILE_FLASHCTRL);
-
-	return 0;
-}
-
-static void versatile_flash_exit(void)
-{
-	u32 val;
-
-	val = __raw_readl(VERSATILE_FLASHCTRL);
-	val &= ~VERSATILE_FLASHPROG_FLVPPEN;
-	__raw_writel(val, VERSATILE_FLASHCTRL);
-}
-
-static void versatile_flash_set_vpp(int on)
+static void versatile_flash_set_vpp(struct map_info *map, int on)
 {
 	u32 val;
 
@@ -222,11 +202,8 @@ static void versatile_flash_set_vpp(int on)
 	__raw_writel(val, VERSATILE_FLASHCTRL);
 }
 
-static struct flash_platform_data versatile_flash_data = {
-	.map_name		= "cfi_probe",
+static struct physmap_flash_data versatile_flash_data = {
 	.width			= 4,
-	.init			= versatile_flash_init,
-	.exit			= versatile_flash_exit,
 	.set_vpp		= versatile_flash_set_vpp,
 };
 
@@ -237,7 +214,7 @@ static struct resource versatile_flash_resource = {
 };
 
 static struct platform_device versatile_flash_device = {
-	.name			= "armflash",
+	.name			= "physmap-flash",
 	.id			= 0,
 	.dev			= {
 		.platform_data	= &versatile_flash_data,
Signature · 1 line
1.7.0.4
#14 lore raw

PATCH v5 4/8 ARM: VExpress: Use physmap driver instead of integrator-flash

In reply to Marc Zyngier
---
 arch/arm/mach-vexpress/v2m.c |   22 ++++------------------
 1 files changed, 4 insertions(+), 18 deletions(-)
arch/arm/mach-vexpress/v2m.c +4 -18
index ba46e8e..e326815 100644
@@ -13,11 +13,11 @@
 #include <linux/sysdev.h>
 #include <linux/usb/isp1760.h>
 #include <linux/clkdev.h>
+#include <linux/mtd/physmap.h>
 
 #include <asm/mach-types.h>
 #include <asm/sizes.h>
 #include <asm/mach/arch.h>
-#include <asm/mach/flash.h>
 #include <asm/mach/map.h>
 #include <asm/mach/time.h>
 #include <asm/hardware/arm_timer.h>
@@ -206,27 +206,13 @@ static struct platform_device v2m_usb_device = {
 	.dev.platform_data = &v2m_usb_config,
 };
 
-static int v2m_flash_init(void)
-{
-	writel(0, MMIO_P2V(V2M_SYS_FLASH));
-	return 0;
-}
-
-static void v2m_flash_exit(void)
-{
-	writel(0, MMIO_P2V(V2M_SYS_FLASH));
-}
-
-static void v2m_flash_set_vpp(int on)
+static void v2m_flash_set_vpp(struct map_info *map, int on)
 {
 	writel(on != 0, MMIO_P2V(V2M_SYS_FLASH));
 }
 
-static struct flash_platform_data v2m_flash_data = {
-	.map_name	= "cfi_probe",
+static struct physmap_flash_data v2m_flash_data = {
 	.width		= 4,
-	.init		= v2m_flash_init,
-	.exit		= v2m_flash_exit,
 	.set_vpp	= v2m_flash_set_vpp,
 };
 
@@ -243,7 +229,7 @@ static struct resource v2m_flash_resources[] = {
 };
 
 static struct platform_device v2m_flash_device = {
-	.name		= "armflash",
+	.name		= "physmap-flash",
 	.id		= -1,
 	.resource	= v2m_flash_resources,
 	.num_resources	= ARRAY_SIZE(v2m_flash_resources),
Signature · 1 line
1.7.0.4
#15 lore raw

PATCH v5 5/8 ARM: Integrator/AP: Use physmap driver instead of integrator-flash

In reply to Marc Zyngier
---
 arch/arm/mach-integrator/integrator_ap.c |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)
arch/arm/mach-integrator/integrator_ap.c +6 -7
index 980803f..11bd49e 100644
@@ -31,6 +31,7 @@
 #include <linux/clockchips.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
+#include <linux/mtd/physmap.h>
 
 #include <mach/hardware.h>
 #include <mach/platform.h>
@@ -43,7 +44,6 @@
 #include <mach/lm.h>
 
 #include <asm/mach/arch.h>
-#include <asm/mach/flash.h>
 #include <asm/mach/irq.h>
 #include <asm/mach/map.h>
 #include <asm/mach/time.h>
@@ -230,7 +230,7 @@ device_initcall(irq_init_sysfs);
 #define EBI_CSR1 (VA_EBI_BASE + INTEGRATOR_EBI_CSR1_OFFSET)
 #define EBI_LOCK (VA_EBI_BASE + INTEGRATOR_EBI_LOCK_OFFSET)
 
-static int ap_flash_init(void)
+static int ap_flash_init(struct platform_device *dev)
 {
 	u32 tmp;
 
@@ -247,7 +247,7 @@ static int ap_flash_init(void)
 	return 0;
 }
 
-static void ap_flash_exit(void)
+static void ap_flash_exit(struct platform_device *dev)
 {
 	u32 tmp;
 
@@ -263,15 +263,14 @@ static void ap_flash_exit(void)
 	}
 }
 
-static void ap_flash_set_vpp(int on)
+static void ap_flash_set_vpp(struct map_info *map, int on)
 {
 	void __iomem *reg = on ? SC_CTRLS : SC_CTRLC;
 
 	writel(INTEGRATOR_SC_CTRL_nFLVPPEN, reg);
 }
 
-static struct flash_platform_data ap_flash_data = {
-	.map_name	= "cfi_probe",
+static struct physmap_flash_data ap_flash_data = {
 	.width		= 4,
 	.init		= ap_flash_init,
 	.exit		= ap_flash_exit,
@@ -285,7 +284,7 @@ static struct resource cfi_flash_resource = {
 };
 
 static struct platform_device cfi_flash_device = {
-	.name		= "armflash",
+	.name		= "physmap-flash",
 	.id		= 0,
 	.dev		= {
 		.platform_data	= &ap_flash_data,
Signature · 1 line
1.7.0.4
#16 lore raw

PATCH v5 6/8 ARM: Integrator/CP: Use physmap driver instead of integrator-flash

In reply to Marc Zyngier

Tested with an ARM-1136 core tile.

---
 arch/arm/mach-integrator/integrator_cp.c |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)
arch/arm/mach-integrator/integrator_cp.c +6 -7
index 9e3ce26..ec9628f 100644
@@ -22,6 +22,7 @@
 #include <linux/io.h>
 #include <linux/gfp.h>
 #include <linux/clkdev.h>
+#include <linux/mtd/physmap.h>
 
 #include <mach/hardware.h>
 #include <mach/platform.h>
@@ -35,7 +36,6 @@
 #include <mach/lm.h>
 
 #include <asm/mach/arch.h>
-#include <asm/mach/flash.h>
 #include <asm/mach/irq.h>
 #include <asm/mach/map.h>
 #include <asm/mach/time.h>
@@ -239,7 +239,7 @@ static struct clk_lookup cp_lookups[] = {
 /*
  * Flash handling.
  */
-static int intcp_flash_init(void)
+static int intcp_flash_init(struct platform_device *dev)
 {
 	u32 val;
 
@@ -250,7 +250,7 @@ static int intcp_flash_init(void)
 	return 0;
 }
 
-static void intcp_flash_exit(void)
+static void intcp_flash_exit(struct platform_device *dev)
 {
 	u32 val;
 
@@ -259,7 +259,7 @@ static void intcp_flash_exit(void)
 	writel(val, INTCP_VA_CTRL_BASE + INTCP_FLASHPROG);
 }
 
-static void intcp_flash_set_vpp(int on)
+static void intcp_flash_set_vpp(struct map_info *map, int on)
 {
 	u32 val;
 
@@ -271,8 +271,7 @@ static void intcp_flash_set_vpp(int on)
 	writel(val, INTCP_VA_CTRL_BASE + INTCP_FLASHPROG);
 }
 
-static struct flash_platform_data intcp_flash_data = {
-	.map_name	= "cfi_probe",
+static struct physmap_flash_data intcp_flash_data = {
 	.width		= 4,
 	.init		= intcp_flash_init,
 	.exit		= intcp_flash_exit,
@@ -286,7 +285,7 @@ static struct resource intcp_flash_resource = {
 };
 
 static struct platform_device intcp_flash_device = {
-	.name		= "armflash",
+	.name		= "physmap-flash",
 	.id		= 0,
 	.dev		= {
 		.platform_data	= &intcp_flash_data,
Signature · 1 line
1.7.0.4
#17 lore raw

PATCH v5 7/8 MTD: Remove integrator-flash

In reply to Marc Zyngier

As there is now no in-tree user of integrator-flash, remove it completely.

---
 drivers/mtd/Kconfig                 |    3 +-
 drivers/mtd/maps/Makefile           |    1 -
 drivers/mtd/maps/integrator-flash.c |  309 -----------------------------------
 3 files changed, 1 insertions(+), 312 deletions(-)
 delete mode 100644 drivers/mtd/maps/integrator-flash.c
drivers/mtd/Kconfig +1 -2
index b4567c3..bc50d5e 100644
@@ -148,8 +148,7 @@ config MTD_AFS_PARTS
 
 	  You will still need the parsing functions to be called by the driver
 	  for your particular device. It won't happen automatically. The
-	  'armflash' map driver (CONFIG_MTD_ARM_INTEGRATOR) does this, for
-	  example.
+	  'physmap' map driver (CONFIG_MTD_PHYSMAP) does this, for example.
 
 config MTD_OF_PARTS
 	def_bool y
drivers/mtd/maps/Makefile +0 -1
index 08533bd..5b5fa31 100644
@@ -8,7 +8,6 @@ endif
 
 # Chip mappings
 obj-$(CONFIG_MTD_CDB89712)	+= cdb89712.o
-obj-$(CONFIG_MTD_ARM_INTEGRATOR)+= integrator-flash.o
 obj-$(CONFIG_MTD_CFI_FLAGADM)	+= cfi_flagadm.o
 obj-$(CONFIG_MTD_DC21285)	+= dc21285.o
 obj-$(CONFIG_MTD_DILNETPC)	+= dilnetpc.o
drivers/mtd/maps/integrator-flash.c deleted +0 -309

309 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#18 lore raw

PATCH v5 8/8 MTD: physmap: let set_vpp() pass a platform_device instead of a map_info

In reply to Marc Zyngier

The set_vpp() method provided by physmap passes a map_info back to the platform code, which has little relevance as far as the platform is concerned (this parameter is completely unused).

Instead, pass the platform_device, which can be used in the pismo driver to retrieve some important information in a nicer way, instead of the hack that was in place.

The empty set_vpp function in board-at572d940hf_ek.c is removed, as it serves no real purpose.

Cc Andrew Victor <[email protected]>
Cc Nicolas Ferre <[email protected]>
Cc Jean-Christophe Plagniol-Villard <[email protected]>
Cc Russell King <[email protected]>
Cc Philipp Zabel <[email protected]>
Cc Eric Miao <[email protected]>
Cc Ben Dooks <[email protected]>
Cc David Woodhouse <[email protected]>
---
 arch/arm/mach-at91/board-at572d940hf_ek.c |    4 ---
 arch/arm/mach-integrator/integrator_ap.c  |    2 +-
 arch/arm/mach-integrator/integrator_cp.c  |    2 +-
 arch/arm/mach-omap1/flash.c               |    2 +-
 arch/arm/mach-pxa/hx4700.c                |    2 +-
 arch/arm/mach-pxa/magician.c              |    2 +-
 arch/arm/mach-realview/core.c             |    2 +-
 arch/arm/mach-s3c2410/nor-simtec.c        |    2 +-
 arch/arm/mach-versatile/core.c            |    2 +-
 arch/arm/mach-vexpress/v2m.c              |    2 +-
 arch/arm/plat-omap/include/plat/flash.h   |    2 +-
 drivers/mtd/maps/physmap.c                |   15 ++++++++++-
 drivers/mtd/maps/pismo.c                  |   40 ++--------------------------
 include/linux/mtd/physmap.h               |    2 +-
 14 files changed, 28 insertions(+), 53 deletions(-)
arch/arm/mach-at91/board-at572d940hf_ek.c +0 -4
index 3929f1c..c139799 100644
@@ -134,14 +134,10 @@ static struct mtd_partition eb_nor_partitions[] = {
 	},
 };
 
-static void nor_flash_set_vpp(struct map_info* mi, int i) {
-};
-
 static struct physmap_flash_data nor_flash_data = {
 	.width		= 4,
 	.parts		= eb_nor_partitions,
 	.nr_parts	= ARRAY_SIZE(eb_nor_partitions),
-	.set_vpp	= nor_flash_set_vpp,
 };
 
 static struct resource nor_flash_resources[] = {
arch/arm/mach-integrator/integrator_ap.c +1 -1
index 11bd49e..2aa98ee 100644
@@ -263,7 +263,7 @@ static void ap_flash_exit(struct platform_device *dev)
 	}
 }
 
-static void ap_flash_set_vpp(struct map_info *map, int on)
+static void ap_flash_set_vpp(struct platform_device *pdev, int on)
 {
 	void __iomem *reg = on ? SC_CTRLS : SC_CTRLC;
 
arch/arm/mach-integrator/integrator_cp.c +1 -1
index ec9628f..b676b41 100644
@@ -259,7 +259,7 @@ static void intcp_flash_exit(struct platform_device *dev)
 	writel(val, INTCP_VA_CTRL_BASE + INTCP_FLASHPROG);
 }
 
-static void intcp_flash_set_vpp(struct map_info *map, int on)
+static void intcp_flash_set_vpp(struct platform_device *pdev, int on)
 {
 	u32 val;
 
arch/arm/mach-omap1/flash.c +1 -1
index acd1616..1749cb3 100644
@@ -13,7 +13,7 @@
 #include <plat/tc.h>
 #include <plat/flash.h>
 
-void omap1_set_vpp(struct map_info *map, int enable)
+void omap1_set_vpp(struct platform_device *pdev, int enable)
 {
 	static int count;
 	u32 l;
arch/arm/mach-pxa/hx4700.c +1 -1
index 9cdcca5..f941a49 100644
@@ -735,7 +735,7 @@ static struct platform_device bq24022 = {
  * StrataFlash
  */
 
-static void hx4700_set_vpp(struct map_info *map, int vpp)
+static void hx4700_set_vpp(struct platform_device *pdev, int vpp)
 {
 	gpio_set_value(GPIO91_HX4700_FLASH_VPEN, vpp);
 }
arch/arm/mach-pxa/magician.c +1 -1
index 9984ef7..e192057 100644
@@ -662,7 +662,7 @@ static struct pxaohci_platform_data magician_ohci_info = {
  * StrataFlash
  */
 
-static void magician_set_vpp(struct map_info *map, int vpp)
+static void magician_set_vpp(struct platform_device *pdev, int vpp)
 {
 	gpio_set_value(EGPIO_MAGICIAN_FLASH_VPP, vpp);
 }
arch/arm/mach-realview/core.c +1 -1
index d3f1dde..c8ec088 100644
@@ -77,7 +77,7 @@ void __init realview_adjust_zones(unsigned long *size, unsigned long *hole)
 
 #define REALVIEW_FLASHCTRL    (__io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_FLASH_OFFSET)
 
-static void realview_flash_set_vpp(struct map_info *map, int on)
+static void realview_flash_set_vpp(struct platform_device *pdev, int on)
 {
 	u32 val;
 
arch/arm/mach-s3c2410/nor-simtec.c +1 -1
index 598d130..ad9f750 100644
@@ -32,7 +32,7 @@
 
 #include "nor-simtec.h"
 
-static void simtec_nor_vpp(struct map_info *map, int vpp)
+static void simtec_nor_vpp(struct platform_device *pdev, int vpp)
 {
 	unsigned int val;
 	unsigned long flags;
arch/arm/mach-versatile/core.c +1 -1
index 06f406a..335d825 100644
@@ -190,7 +190,7 @@ void __init versatile_map_io(void)
 
 #define VERSATILE_FLASHCTRL    (__io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_FLASH_OFFSET)
 
-static void versatile_flash_set_vpp(struct map_info *map, int on)
+static void versatile_flash_set_vpp(struct platform_device *pdev, int on)
 {
 	u32 val;
 
arch/arm/mach-vexpress/v2m.c +1 -1
index e326815..f860314 100644
@@ -206,7 +206,7 @@ static struct platform_device v2m_usb_device = {
 	.dev.platform_data = &v2m_usb_config,
 };
 
-static void v2m_flash_set_vpp(struct map_info *map, int on)
+static void v2m_flash_set_vpp(struct platform_device *pdev, int on)
 {
 	writel(on != 0, MMIO_P2V(V2M_SYS_FLASH));
 }
arch/arm/plat-omap/include/plat/flash.h +1 -1
index 3e63270..3083195 100644
@@ -11,6 +11,6 @@
 
 #include <linux/mtd/map.h>
 
-extern void omap1_set_vpp(struct map_info *map, int enable);
+extern void omap1_set_vpp(struct platform_device *pdev, int enable);
 
 #endif
drivers/mtd/maps/physmap.c +14 -1
index 49676b7..89fe8be 100644
@@ -74,6 +74,18 @@ static int physmap_flash_remove(struct platform_device *dev)
 	return 0;
 }
 
+static void physmap_set_vpp(struct map_info *map, int state)
+{
+	struct platform_device *pdev;
+	struct physmap_flash_data *physmap_data;
+
+	pdev = (struct platform_device *)map->map_priv_1;
+	physmap_data = pdev->dev.platform_data;
+
+	if (physmap_data->set_vpp)
+		physmap_data->set_vpp(pdev, state);
+}
+
 static const char *rom_probe_types[] = {
 					"cfi_probe",
 					"jedec_probe",
@@ -134,8 +146,9 @@ static int physmap_flash_probe(struct platform_device *dev)
 		info->map[i].phys = dev->resource[i].start;
 		info->map[i].size = resource_size(&dev->resource[i]);
 		info->map[i].bankwidth = physmap_data->width;
-		info->map[i].set_vpp = physmap_data->set_vpp;
+		info->map[i].set_vpp = physmap_set_vpp;
 		info->map[i].pfow_base = physmap_data->pfow_base;
+		info->map[i].map_priv_1 = (unsigned long)dev;
 
 		info->map[i].virt = devm_ioremap(&dev->dev, info->map[i].phys,
 						 info->map[i].size);
drivers/mtd/maps/pismo.c +3 -37
index f4ce273..65bd1cd 100644
@@ -50,39 +50,13 @@ struct pismo_data {
 	struct platform_device	*dev[PISMO_NUM_CS];
 };
 
-/* FIXME: set_vpp could do with a better calling convention */
-static struct pismo_data *vpp_pismo;
-static DEFINE_MUTEX(pismo_mutex);
-
-static int pismo_setvpp_probe_fix(struct pismo_data *pismo)
+static void pismo_set_vpp(struct platform_device *pdev, int on)
 {
-	mutex_lock(&pismo_mutex);
-	if (vpp_pismo) {
-		mutex_unlock(&pismo_mutex);
-		kfree(pismo);
-		return -EBUSY;
-	}
-	vpp_pismo = pismo;
-	mutex_unlock(&pismo_mutex);
-	return 0;
-}
-
-static void pismo_setvpp_remove_fix(struct pismo_data *pismo)
-{
-	mutex_lock(&pismo_mutex);
-	if (vpp_pismo == pismo)
-		vpp_pismo = NULL;
-	mutex_unlock(&pismo_mutex);
-}
-
-static void pismo_set_vpp(struct map_info *map, int on)
-{
-	struct pismo_data *pismo = vpp_pismo;
+	struct i2c_client *client = to_i2c_client(pdev->dev.parent);
+	struct pismo_data *pismo = i2c_get_clientdata(client);
 
 	pismo->vpp(pismo->vpp_data, on);
 }
-/* end of hack */
-
 
 static unsigned int __devinit pismo_width_to_bytes(unsigned int width)
 {
@@ -231,9 +205,6 @@ static int __devexit pismo_remove(struct i2c_client *client)
 	for (i = 0; i < ARRAY_SIZE(pismo->dev); i++)
 		platform_device_unregister(pismo->dev[i]);
 
-	/* FIXME: set_vpp needs saner arguments */
-	pismo_setvpp_remove_fix(pismo);
-
 	kfree(pismo);
 
 	return 0;
@@ -257,11 +228,6 @@ static int __devinit pismo_probe(struct i2c_client *client,
 	if (!pismo)
 		return -ENOMEM;
 
-	/* FIXME: set_vpp needs saner arguments */
-	ret = pismo_setvpp_probe_fix(pismo);
-	if (ret)
-		return ret;
-
 	pismo->client = client;
 	if (pdata) {
 		pismo->vpp = pdata->set_vpp;
include/linux/mtd/physmap.h +1 -1
index d37cca0..49b9590 100644
@@ -24,7 +24,7 @@ struct physmap_flash_data {
 	unsigned int		width;
 	int			(*init)(struct platform_device *);
 	void			(*exit)(struct platform_device *);
-	void			(*set_vpp)(struct map_info *, int);
+	void			(*set_vpp)(struct platform_device *, int);
 	unsigned int		nr_parts;
 	unsigned int		pfow_base;
 	char                    *probe_type;
Signature · 1 line
1.7.0.4
#19 lore raw

PATCH v5 8/8 MTD: physmap: let set_vpp() pass a platform_device instead of a map_info

Quoted 7 lines · Marc Zyngier

The set_vpp() method provided by physmap passes a map_info back to the platform code, which has little relevance as far as the platform is concerned (this parameter is completely unused).

Instead, pass the platform_device, which can be used in the pismo driver to retrieve some important information in a nicer way, instead of the hack that was in place.

Not really sure if a 'struct device' would be more generic here, though this case is simply a 'struct platform_device'.

Quoted 299 lines

The empty set_vpp function in board-at572d940hf_ek.c is removed, as it serves no real purpose.

Cc Andrew Victor <[email protected]>
Cc Nicolas Ferre <[email protected]>
Cc Jean-Christophe Plagniol-Villard <[email protected]>
Cc Russell King <[email protected]>
Cc Philipp Zabel <[email protected]>
Cc Eric Miao <[email protected]>
Cc Ben Dooks <[email protected]>
Cc David Woodhouse <[email protected]>

---

?arch/arm/mach-at91/board-at572d940hf_ek.c | ? ?4 ---
?arch/arm/mach-integrator/integrator_ap.c ?| ? ?2 +-
?arch/arm/mach-integrator/integrator_cp.c ?| ? ?2 +-
?arch/arm/mach-omap1/flash.c ? ? ? ? ? ? ? | ? ?2 +-
?arch/arm/mach-pxa/hx4700.c ? ? ? ? ? ? ? ?| ? ?2 +-
?arch/arm/mach-pxa/magician.c ? ? ? ? ? ? ?| ? ?2 +-
?arch/arm/mach-realview/core.c ? ? ? ? ? ? | ? ?2 +-
?arch/arm/mach-s3c2410/nor-simtec.c ? ? ? ?| ? ?2 +-
?arch/arm/mach-versatile/core.c ? ? ? ? ? ?| ? ?2 +-
?arch/arm/mach-vexpress/v2m.c ? ? ? ? ? ? ?| ? ?2 +-
?arch/arm/plat-omap/include/plat/flash.h ? | ? ?2 +-
?drivers/mtd/maps/physmap.c ? ? ? ? ? ? ? ?| ? 15 ++++++++++-
?drivers/mtd/maps/pismo.c ? ? ? ? ? ? ? ? ?| ? 40 ++--------------------------
?include/linux/mtd/physmap.h ? ? ? ? ? ? ? | ? ?2 +-

?14 files changed, 28 insertions(+), 53 deletions(-)

arch/arm/mach-at91/board-at572d940hf_ek.c +0 -4
index 3929f1c..c139799 100644
@@ -134,14 +134,10 @@ static struct mtd_partition eb_nor_partitions[] = {
 ? ? ? ?},
 ?};
 
-static void nor_flash_set_vpp(struct map_info* mi, int i) {
-};
-
 ?static struct physmap_flash_data nor_flash_data = {
 ? ? ? ?.width ? ? ? ? ?= 4,
 ? ? ? ?.parts ? ? ? ? ?= eb_nor_partitions,
 ? ? ? ?.nr_parts ? ? ? = ARRAY_SIZE(eb_nor_partitions),
- ? ? ? .set_vpp ? ? ? ?= nor_flash_set_vpp,
 ?};
 
 ?static struct resource nor_flash_resources[] = {
arch/arm/mach-integrator/integrator_ap.c +1 -1
index 11bd49e..2aa98ee 100644
@@ -263,7 +263,7 @@ static void ap_flash_exit(struct platform_device *dev)
 ? ? ? ?}
 ?}
 
-static void ap_flash_set_vpp(struct map_info *map, int on)
+static void ap_flash_set_vpp(struct platform_device *pdev, int on)
 ?{
 ? ? ? ?void __iomem *reg = on ? SC_CTRLS : SC_CTRLC;
 
arch/arm/mach-integrator/integrator_cp.c +1 -1
index ec9628f..b676b41 100644
@@ -259,7 +259,7 @@ static void intcp_flash_exit(struct platform_device *dev)
 ? ? ? ?writel(val, INTCP_VA_CTRL_BASE + INTCP_FLASHPROG);
 ?}
 
-static void intcp_flash_set_vpp(struct map_info *map, int on)
+static void intcp_flash_set_vpp(struct platform_device *pdev, int on)
 ?{
 ? ? ? ?u32 val;
 
arch/arm/mach-omap1/flash.c +0 -0
index acd1616..1749cb3 100644
@@ -13,7 +13,7 @@

?#include <plat/tc.h>
?#include <plat/flash.h>

arch/arm/mach-omap1/flash.c +1 -1
-void omap1_set_vpp(struct map_info *map, int enable)
+void omap1_set_vpp(struct platform_device *pdev, int enable)

?{
? ? ? ?static int count;
? ? ? ?u32 l;

arch/arm/mach-pxa/hx4700.c +0 -0
index 9cdcca5..f941a49 100644
@@ -735,7 +735,7 @@ static struct platform_device bq24022 = {

?* StrataFlash
?*/

arch/arm/mach-pxa/hx4700.c +1 -1
-static void hx4700_set_vpp(struct map_info *map, int vpp)
+static void hx4700_set_vpp(struct platform_device *pdev, int vpp)

?{
? ? ? ?gpio_set_value(GPIO91_HX4700_FLASH_VPEN, vpp); ?}

arch/arm/mach-pxa/magician.c +0 -0
index 9984ef7..e192057 100644
@@ -662,7 +662,7 @@ static struct pxaohci_platform_data magician_ohci_info = {

?* StrataFlash
?*/

arch/arm/mach-pxa/magician.c +1 -1
-static void magician_set_vpp(struct map_info *map, int vpp)
+static void magician_set_vpp(struct platform_device *pdev, int vpp)

?{
? ? ? ?gpio_set_value(EGPIO_MAGICIAN_FLASH_VPP, vpp); ?}

arch/arm/mach-realview/core.c +1 -1
index d3f1dde..c8ec088 100644
@@ -77,7 +77,7 @@ void __init realview_adjust_zones(unsigned long *size, unsigned long *hole)
 
 ?#define REALVIEW_FLASHCTRL ? ?(__io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_FLASH_OFFSET)
 
-static void realview_flash_set_vpp(struct map_info *map, int on)
+static void realview_flash_set_vpp(struct platform_device *pdev, int on)
 ?{
 ? ? ? ?u32 val;
 
arch/arm/mach-s3c2410/nor-simtec.c +0 -0
index 598d130..ad9f750 100644
@@ -32,7 +32,7 @@
 

?#include "nor-simtec.h"

arch/arm/mach-s3c2410/nor-simtec.c +1 -1
-static void simtec_nor_vpp(struct map_info *map, int vpp)
+static void simtec_nor_vpp(struct platform_device *pdev, int vpp)

?{
? ? ? ?unsigned int val;
? ? ? ?unsigned long flags;

arch/arm/mach-versatile/core.c +1 -1
index 06f406a..335d825 100644
@@ -190,7 +190,7 @@ void __init versatile_map_io(void)
 
 ?#define VERSATILE_FLASHCTRL ? ?(__io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_FLASH_OFFSET)
 
-static void versatile_flash_set_vpp(struct map_info *map, int on)
+static void versatile_flash_set_vpp(struct platform_device *pdev, int on)
 ?{
 ? ? ? ?u32 val;
 
arch/arm/mach-vexpress/v2m.c +1 -1
index e326815..f860314 100644
@@ -206,7 +206,7 @@ static struct platform_device v2m_usb_device = {
 ? ? ? ?.dev.platform_data = &v2m_usb_config,
 ?};
 
-static void v2m_flash_set_vpp(struct map_info *map, int on)
+static void v2m_flash_set_vpp(struct platform_device *pdev, int on)
 ?{
 ? ? ? ?writel(on != 0, MMIO_P2V(V2M_SYS_FLASH));
 ?}
arch/arm/plat-omap/include/plat/flash.h +0 -0
index 3e63270..3083195 100644
@@ -11,6 +11,6 @@
 

?#include <linux/mtd/map.h>

arch/arm/plat-omap/include/plat/flash.h +1 -1
-extern void omap1_set_vpp(struct map_info *map, int enable);
+extern void omap1_set_vpp(struct platform_device *pdev, int enable);

?#endif

drivers/mtd/maps/physmap.c +14 -1
index 49676b7..89fe8be 100644
@@ -74,6 +74,18 @@ static int physmap_flash_remove(struct platform_device *dev)
 ? ? ? ?return 0;
 ?}
 
+static void physmap_set_vpp(struct map_info *map, int state)
+{
+ ? ? ? struct platform_device *pdev;
+ ? ? ? struct physmap_flash_data *physmap_data;
+
+ ? ? ? pdev = (struct platform_device *)map->map_priv_1;
+ ? ? ? physmap_data = pdev->dev.platform_data;
+
+ ? ? ? if (physmap_data->set_vpp)
+ ? ? ? ? ? ? ? physmap_data->set_vpp(pdev, state);
+}
+
 ?static const char *rom_probe_types[] = {
 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?"cfi_probe",
 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?"jedec_probe",
@@ -134,8 +146,9 @@ static int physmap_flash_probe(struct platform_device *dev)
 ? ? ? ? ? ? ? ?info->map[i].phys = dev->resource[i].start;
 ? ? ? ? ? ? ? ?info->map[i].size = resource_size(&dev->resource[i]);
 ? ? ? ? ? ? ? ?info->map[i].bankwidth = physmap_data->width;
- ? ? ? ? ? ? ? info->map[i].set_vpp = physmap_data->set_vpp;
+ ? ? ? ? ? ? ? info->map[i].set_vpp = physmap_set_vpp;
 ? ? ? ? ? ? ? ?info->map[i].pfow_base = physmap_data->pfow_base;
+ ? ? ? ? ? ? ? info->map[i].map_priv_1 = (unsigned long)dev;
 
 ? ? ? ? ? ? ? ?info->map[i].virt = devm_ioremap(&dev->dev, info->map[i].phys,
 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? info->map[i].size);
drivers/mtd/maps/pismo.c +3 -37
index f4ce273..65bd1cd 100644
@@ -50,39 +50,13 @@ struct pismo_data {
 ? ? ? ?struct platform_device ?*dev[PISMO_NUM_CS];
 ?};
 
-/* FIXME: set_vpp could do with a better calling convention */
-static struct pismo_data *vpp_pismo;
-static DEFINE_MUTEX(pismo_mutex);
-
-static int pismo_setvpp_probe_fix(struct pismo_data *pismo)
+static void pismo_set_vpp(struct platform_device *pdev, int on)
 ?{
- ? ? ? mutex_lock(&pismo_mutex);
- ? ? ? if (vpp_pismo) {
- ? ? ? ? ? ? ? mutex_unlock(&pismo_mutex);
- ? ? ? ? ? ? ? kfree(pismo);
- ? ? ? ? ? ? ? return -EBUSY;
- ? ? ? }
- ? ? ? vpp_pismo = pismo;
- ? ? ? mutex_unlock(&pismo_mutex);
- ? ? ? return 0;
-}
-
-static void pismo_setvpp_remove_fix(struct pismo_data *pismo)
-{
- ? ? ? mutex_lock(&pismo_mutex);
- ? ? ? if (vpp_pismo == pismo)
- ? ? ? ? ? ? ? vpp_pismo = NULL;
- ? ? ? mutex_unlock(&pismo_mutex);
-}
-
-static void pismo_set_vpp(struct map_info *map, int on)
-{
- ? ? ? struct pismo_data *pismo = vpp_pismo;
+ ? ? ? struct i2c_client *client = to_i2c_client(pdev->dev.parent);
+ ? ? ? struct pismo_data *pismo = i2c_get_clientdata(client);
 
 ? ? ? ?pismo->vpp(pismo->vpp_data, on);
 ?}
-/* end of hack */
-
 
 ?static unsigned int __devinit pismo_width_to_bytes(unsigned int width)
 ?{
@@ -231,9 +205,6 @@ static int __devexit pismo_remove(struct i2c_client *client)
 ? ? ? ?for (i = 0; i < ARRAY_SIZE(pismo->dev); i++)
 ? ? ? ? ? ? ? ?platform_device_unregister(pismo->dev[i]);
 
- ? ? ? /* FIXME: set_vpp needs saner arguments */
- ? ? ? pismo_setvpp_remove_fix(pismo);
-
 ? ? ? ?kfree(pismo);
 
 ? ? ? ?return 0;
@@ -257,11 +228,6 @@ static int __devinit pismo_probe(struct i2c_client *client,
 ? ? ? ?if (!pismo)
 ? ? ? ? ? ? ? ?return -ENOMEM;
 
- ? ? ? /* FIXME: set_vpp needs saner arguments */
- ? ? ? ret = pismo_setvpp_probe_fix(pismo);
- ? ? ? if (ret)
- ? ? ? ? ? ? ? return ret;
-
 ? ? ? ?pismo->client = client;
 ? ? ? ?if (pdata) {
 ? ? ? ? ? ? ? ?pismo->vpp = pdata->set_vpp;
include/linux/mtd/physmap.h +1 -2
index d37cca0..49b9590 100644
@@ -24,7 +24,7 @@ struct physmap_flash_data {
 ? ? ? ?unsigned int ? ? ? ? ? ?width;
 ? ? ? ?int ? ? ? ? ? ? ? ? ? ? (*init)(struct platform_device *);
 ? ? ? ?void ? ? ? ? ? ? ? ? ? ?(*exit)(struct platform_device *);
- ? ? ? void ? ? ? ? ? ? ? ? ? ?(*set_vpp)(struct map_info *, int);
+ ? ? ? void ? ? ? ? ? ? ? ? ? ?(*set_vpp)(struct platform_device *, int);
 ? ? ? ?unsigned int ? ? ? ? ? ?nr_parts;
 ? ? ? ?unsigned int ? ? ? ? ? ?pfow_base;
 ? ? ? ?char ? ? ? ? ? ? ? ? ? ?*probe_type;
--

1.7.0.4

#20 lore raw

PATCH v5 8/8 MTD: physmap: let set_vpp() pass a platform_device instead of a map_info

Quoted 11 lines · Eric Miao
Quoted 7 lines · Marc Zyngier

The set_vpp() method provided by physmap passes a map_info back to the platform code, which has little relevance as far as the platform is concerned (this parameter is completely unused).

Instead, pass the platform_device, which can be used in the pismo driver to retrieve some important information in a nicer way, instead of the hack that was in place.

Not really sure if a 'struct device' would be more generic here, though this case is simply a 'struct platform_device'.

While I agree that 'struct device' is more generic, physmap only knows about platform_devices. Should another device type be added to physmap, this would make sense. But at the moment I'd like to limit the code churn to what is strictly necessary.

Cheers,

	M.
Signature · 1 line
Reality is an implementation detail.
#21 lore raw

PATCH v5 8/8 MTD: physmap: let set_vpp() pass a platform_device instead of a map_info

In reply to Eric Miao
Quoted 11 lines · Eric Miao
Quoted 7 lines · Marc Zyngier

The set_vpp() method provided by physmap passes a map_info back to the platform code, which has little relevance as far as the platform is concerned (this parameter is completely unused).

Instead, pass the platform_device, which can be used in the pismo driver to retrieve some important information in a nicer way, instead of the hack that was in place.

Not really sure if a 'struct device' would be more generic here, though this case is simply a 'struct platform_device'.

As it's a platform device driver (at the moment), passing the platform device seems logical.

If it becomes an DT based device driver, then we need some other way of describing the set_vpp etc functionality as we can't describe function pointers in DT (the same problem goes for a lot of platform device drivers.)

#22 lore raw

PATCH v5 8/8 MTD: physmap: let set_vpp() pass a platform_device instead of a map_info

In reply to Marc Zyngier
Quoted 20 lines · Marc Zyngier

The set_vpp() method provided by physmap passes a map_info back to the platform code, which has little relevance as far as the platform is concerned (this parameter is completely unused).

Instead, pass the platform_device, which can be used in the pismo driver to retrieve some important information in a nicer way, instead of the hack that was in place.

The empty set_vpp function in board-at572d940hf_ek.c is removed, as it serves no real purpose.

Cc Andrew Victor <[email protected]>
Cc Nicolas Ferre <[email protected]>
Cc Jean-Christophe Plagniol-Villard <[email protected]>
Cc Russell King <[email protected]>
Cc Philipp Zabel <[email protected]>
Cc Eric Miao <[email protected]>
Cc Ben Dooks <[email protected]>
Cc David Woodhouse <[email protected]>
Quoted 2 lines
---
 arch/arm/mach-at91/board-at572d940hf_ek.c |    4 ---

I'll send a patch to drop the soc and board

Best Regards,
J.

Quoted 282 lines
 arch/arm/mach-integrator/integrator_ap.c  |    2 +-
 arch/arm/mach-integrator/integrator_cp.c  |    2 +-
 arch/arm/mach-omap1/flash.c               |    2 +-
 arch/arm/mach-pxa/hx4700.c                |    2 +-
 arch/arm/mach-pxa/magician.c              |    2 +-
 arch/arm/mach-realview/core.c             |    2 +-
 arch/arm/mach-s3c2410/nor-simtec.c        |    2 +-
 arch/arm/mach-versatile/core.c            |    2 +-
 arch/arm/mach-vexpress/v2m.c              |    2 +-
 arch/arm/plat-omap/include/plat/flash.h   |    2 +-
 drivers/mtd/maps/physmap.c                |   15 ++++++++++-
 drivers/mtd/maps/pismo.c                  |   40 ++--------------------------
 include/linux/mtd/physmap.h               |    2 +-
 14 files changed, 28 insertions(+), 53 deletions(-)
arch/arm/mach-at91/board-at572d940hf_ek.c +0 -4
index 3929f1c..c139799 100644
@@ -134,14 +134,10 @@ static struct mtd_partition eb_nor_partitions[] = {
 	},
 };
 
-static void nor_flash_set_vpp(struct map_info* mi, int i) {
-};
-
 static struct physmap_flash_data nor_flash_data = {
 	.width		= 4,
 	.parts		= eb_nor_partitions,
 	.nr_parts	= ARRAY_SIZE(eb_nor_partitions),
-	.set_vpp	= nor_flash_set_vpp,
 };
 
 static struct resource nor_flash_resources[] = {
arch/arm/mach-integrator/integrator_ap.c +1 -1
index 11bd49e..2aa98ee 100644
@@ -263,7 +263,7 @@ static void ap_flash_exit(struct platform_device *dev)
 	}
 }
 
-static void ap_flash_set_vpp(struct map_info *map, int on)
+static void ap_flash_set_vpp(struct platform_device *pdev, int on)
 {
 	void __iomem *reg = on ? SC_CTRLS : SC_CTRLC;
 
arch/arm/mach-integrator/integrator_cp.c +1 -1
index ec9628f..b676b41 100644
@@ -259,7 +259,7 @@ static void intcp_flash_exit(struct platform_device *dev)
 	writel(val, INTCP_VA_CTRL_BASE + INTCP_FLASHPROG);
 }
 
-static void intcp_flash_set_vpp(struct map_info *map, int on)
+static void intcp_flash_set_vpp(struct platform_device *pdev, int on)
 {
 	u32 val;
 
arch/arm/mach-omap1/flash.c +1 -1
index acd1616..1749cb3 100644
@@ -13,7 +13,7 @@
 #include <plat/tc.h>
 #include <plat/flash.h>
 
-void omap1_set_vpp(struct map_info *map, int enable)
+void omap1_set_vpp(struct platform_device *pdev, int enable)
 {
 	static int count;
 	u32 l;
arch/arm/mach-pxa/hx4700.c +1 -1
index 9cdcca5..f941a49 100644
@@ -735,7 +735,7 @@ static struct platform_device bq24022 = {
  * StrataFlash
  */
 
-static void hx4700_set_vpp(struct map_info *map, int vpp)
+static void hx4700_set_vpp(struct platform_device *pdev, int vpp)
 {
 	gpio_set_value(GPIO91_HX4700_FLASH_VPEN, vpp);
 }
arch/arm/mach-pxa/magician.c +1 -1
index 9984ef7..e192057 100644
@@ -662,7 +662,7 @@ static struct pxaohci_platform_data magician_ohci_info = {
  * StrataFlash
  */
 
-static void magician_set_vpp(struct map_info *map, int vpp)
+static void magician_set_vpp(struct platform_device *pdev, int vpp)
 {
 	gpio_set_value(EGPIO_MAGICIAN_FLASH_VPP, vpp);
 }
arch/arm/mach-realview/core.c +1 -1
index d3f1dde..c8ec088 100644
@@ -77,7 +77,7 @@ void __init realview_adjust_zones(unsigned long *size, unsigned long *hole)
 
 #define REALVIEW_FLASHCTRL    (__io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_FLASH_OFFSET)
 
-static void realview_flash_set_vpp(struct map_info *map, int on)
+static void realview_flash_set_vpp(struct platform_device *pdev, int on)
 {
 	u32 val;
 
arch/arm/mach-s3c2410/nor-simtec.c +1 -1
index 598d130..ad9f750 100644
@@ -32,7 +32,7 @@
 
 #include "nor-simtec.h"
 
-static void simtec_nor_vpp(struct map_info *map, int vpp)
+static void simtec_nor_vpp(struct platform_device *pdev, int vpp)
 {
 	unsigned int val;
 	unsigned long flags;
arch/arm/mach-versatile/core.c +1 -1
index 06f406a..335d825 100644
@@ -190,7 +190,7 @@ void __init versatile_map_io(void)
 
 #define VERSATILE_FLASHCTRL    (__io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_FLASH_OFFSET)
 
-static void versatile_flash_set_vpp(struct map_info *map, int on)
+static void versatile_flash_set_vpp(struct platform_device *pdev, int on)
 {
 	u32 val;
 
arch/arm/mach-vexpress/v2m.c +1 -1
index e326815..f860314 100644
@@ -206,7 +206,7 @@ static struct platform_device v2m_usb_device = {
 	.dev.platform_data = &v2m_usb_config,
 };
 
-static void v2m_flash_set_vpp(struct map_info *map, int on)
+static void v2m_flash_set_vpp(struct platform_device *pdev, int on)
 {
 	writel(on != 0, MMIO_P2V(V2M_SYS_FLASH));
 }
arch/arm/plat-omap/include/plat/flash.h +1 -1
index 3e63270..3083195 100644
@@ -11,6 +11,6 @@
 
 #include <linux/mtd/map.h>
 
-extern void omap1_set_vpp(struct map_info *map, int enable);
+extern void omap1_set_vpp(struct platform_device *pdev, int enable);
 
 #endif
drivers/mtd/maps/physmap.c +14 -1
index 49676b7..89fe8be 100644
@@ -74,6 +74,18 @@ static int physmap_flash_remove(struct platform_device *dev)
 	return 0;
 }
 
+static void physmap_set_vpp(struct map_info *map, int state)
+{
+	struct platform_device *pdev;
+	struct physmap_flash_data *physmap_data;
+
+	pdev = (struct platform_device *)map->map_priv_1;
+	physmap_data = pdev->dev.platform_data;
+
+	if (physmap_data->set_vpp)
+		physmap_data->set_vpp(pdev, state);
+}
+
 static const char *rom_probe_types[] = {
 					"cfi_probe",
 					"jedec_probe",
@@ -134,8 +146,9 @@ static int physmap_flash_probe(struct platform_device *dev)
 		info->map[i].phys = dev->resource[i].start;
 		info->map[i].size = resource_size(&dev->resource[i]);
 		info->map[i].bankwidth = physmap_data->width;
-		info->map[i].set_vpp = physmap_data->set_vpp;
+		info->map[i].set_vpp = physmap_set_vpp;
 		info->map[i].pfow_base = physmap_data->pfow_base;
+		info->map[i].map_priv_1 = (unsigned long)dev;
 
 		info->map[i].virt = devm_ioremap(&dev->dev, info->map[i].phys,
 						 info->map[i].size);
drivers/mtd/maps/pismo.c +3 -37
index f4ce273..65bd1cd 100644
@@ -50,39 +50,13 @@ struct pismo_data {
 	struct platform_device	*dev[PISMO_NUM_CS];
 };
 
-/* FIXME: set_vpp could do with a better calling convention */
-static struct pismo_data *vpp_pismo;
-static DEFINE_MUTEX(pismo_mutex);
-
-static int pismo_setvpp_probe_fix(struct pismo_data *pismo)
+static void pismo_set_vpp(struct platform_device *pdev, int on)
 {
-	mutex_lock(&pismo_mutex);
-	if (vpp_pismo) {
-		mutex_unlock(&pismo_mutex);
-		kfree(pismo);
-		return -EBUSY;
-	}
-	vpp_pismo = pismo;
-	mutex_unlock(&pismo_mutex);
-	return 0;
-}
-
-static void pismo_setvpp_remove_fix(struct pismo_data *pismo)
-{
-	mutex_lock(&pismo_mutex);
-	if (vpp_pismo == pismo)
-		vpp_pismo = NULL;
-	mutex_unlock(&pismo_mutex);
-}
-
-static void pismo_set_vpp(struct map_info *map, int on)
-{
-	struct pismo_data *pismo = vpp_pismo;
+	struct i2c_client *client = to_i2c_client(pdev->dev.parent);
+	struct pismo_data *pismo = i2c_get_clientdata(client);
 
 	pismo->vpp(pismo->vpp_data, on);
 }
-/* end of hack */
-
 
 static unsigned int __devinit pismo_width_to_bytes(unsigned int width)
 {
@@ -231,9 +205,6 @@ static int __devexit pismo_remove(struct i2c_client *client)
 	for (i = 0; i < ARRAY_SIZE(pismo->dev); i++)
 		platform_device_unregister(pismo->dev[i]);
 
-	/* FIXME: set_vpp needs saner arguments */
-	pismo_setvpp_remove_fix(pismo);
-
 	kfree(pismo);
 
 	return 0;
@@ -257,11 +228,6 @@ static int __devinit pismo_probe(struct i2c_client *client,
 	if (!pismo)
 		return -ENOMEM;
 
-	/* FIXME: set_vpp needs saner arguments */
-	ret = pismo_setvpp_probe_fix(pismo);
-	if (ret)
-		return ret;
-
 	pismo->client = client;
 	if (pdata) {
 		pismo->vpp = pdata->set_vpp;
include/linux/mtd/physmap.h +1 -1
index d37cca0..49b9590 100644
@@ -24,7 +24,7 @@ struct physmap_flash_data {
 	unsigned int		width;
 	int			(*init)(struct platform_device *);
 	void			(*exit)(struct platform_device *);
-	void			(*set_vpp)(struct map_info *, int);
+	void			(*set_vpp)(struct platform_device *, int);
 	unsigned int		nr_parts;
 	unsigned int		pfow_base;
 	char                    *probe_type;
Signature · 1 line
1.7.0.4