Skip to contentSkip to conversation

mtd: bcm47xxnflash: adding support for new NANDs

RFC In review Rafał Miłecki 3 participants 6 messages Feb 23, 2014 – Feb 26, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover mtd: bcm47xxnflash: adding support for new NANDs

New Broadcom SoCs have NAND flashes attached & programmed in a totally different way. Instead of accessing them with help of ChipCommon core, they can be used directly.

To support them we can extend bcm47xxnflash in the way this patches implements. However almost nothing in the code will be shared between support for old and new devices.

How should we proceed? Implement it that way anyway? Or maybe writing a separated driver (bcm53xxnflash?) would be a better idea?

Rafał Miłecki (3):
Revert "mtd: bcm47xxnflash: Use module_platform_driver"
mtd: bcm47xxnflash: add separated config for platform driver
mtd: bcm47xxnflash: prepare for adding BCMA driver

 drivers/mtd/nand/Kconfig                | 25 ++++++++---
 drivers/mtd/nand/bcm47xxnflash/Makefile |  2 +-
 drivers/mtd/nand/bcm47xxnflash/main.c   | 80 ++++++++++++++++++++++++++++++++-
 3 files changed, 100 insertions(+), 7 deletions(-)
Signature · 1 line
1.8.4.5
#1 lore raw

RFC 1/3 Revert "mtd: bcm47xxnflash: Use module_platform_driver"

This reverts commit 994bbd0e91c0dfa4dcda9097b0716607aeec5470.

We're going to add support for more NAND flashes and the new ones are not registered as platform devices. So we need our own init function.

---
 drivers/mtd/nand/bcm47xxnflash/main.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/mtd/nand/bcm47xxnflash/main.c +19 -1
index 1074459..52611ef 100644
@@ -77,4 +77,22 @@ static struct platform_driver bcm47xxnflash_driver = {
 	},
 };
 
-module_platform_driver(bcm47xxnflash_driver);
+static int __init bcm47xxnflash_init(void)
+{
+	int err;
+
+	err = platform_driver_register(&bcm47xxnflash_driver);
+	if (err)
+		pr_err("Failed to register bcm47xx nand flash driver: %d\n",
+		       err);
+
+	return err;
+}
+
+static void __exit bcm47xxnflash_exit(void)
+{
+	platform_driver_unregister(&bcm47xxnflash_driver);
+}
+
+module_init(bcm47xxnflash_init);
+module_exit(bcm47xxnflash_exit);
Signature · 1 line
1.8.4.5
#2 lore raw

RFC 2/3 mtd: bcm47xxnflash: add separated config for platform driver

In reply to Rafał Miłecki

Adding support for new NANDs requires registering as BCMA driver, so we will need separated configs.

---
 drivers/mtd/nand/Kconfig                | 18 +++++++++++++-----
 drivers/mtd/nand/bcm47xxnflash/Makefile |  2 +-
 drivers/mtd/nand/bcm47xxnflash/main.c   | 12 +++++++++++-
 3 files changed, 25 insertions(+), 7 deletions(-)
drivers/mtd/nand/Kconfig +13 -5
index a5bb738..a3e8ad2 100644
@@ -390,12 +390,20 @@ config MTD_NAND_GPMI_NAND
 	 the GPMI.
 
 config MTD_NAND_BCM47XXNFLASH
-	tristate "Support for NAND flash on BCM4706 BCMA bus"
-	depends on BCMA_NFLASH
+	tristate "Support for NAND flash memories on BCMA bus"
+	depends on BCMA
 	help
-	  BCMA bus can have various flash memories attached, they are
-	  registered by bcma as platform devices. This enables driver for
-	  NAND flash memories. For now only BCM4706 is supported.
+	  BCMA bus can have various flash memories attached including
+	  NAND type. Depending on SoC version they can be attached to
+	  the ChipCommon core or available as separated device.
+
+config MTD_NAND_BCM47XXNFLASH_PLATFORM
+	bool "NAND attached to the ChipCommon core"
+	depends on MTD_NAND_BCM47XXNFLASH && BCMA_NFLASH
+	help
+	  Such flashes were probably used on MIPS based SoCs only. The
+	  most common was BCM4706, but it rarely could be also found on
+	  BCM5357.
 
 config MTD_NAND_PLATFORM
 	tristate "Support for generic platform NAND driver"
drivers/mtd/nand/bcm47xxnflash/Makefile +1 -1
index f05b119..4e755f0 100644
@@ -1,4 +1,4 @@
 bcm47xxnflash-y				+= main.o
-bcm47xxnflash-y				+= ops_bcm4706.o
+bcm47xxnflash-$(CONFIG_MTD_NAND_BCM47XXNFLASH_PLATFORM)	+= ops_bcm4706.o
 
 obj-$(CONFIG_MTD_NAND_BCM47XXNFLASH)	+= bcm47xxnflash.o
drivers/mtd/nand/bcm47xxnflash/main.c +11 -1
index 52611ef..c9d9b3f 100644
@@ -21,6 +21,7 @@ MODULE_DESCRIPTION("NAND flash driver for BCMA bus");
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Rafał Miłecki");
 
+#if IS_ENABLED(CONFIG_MTD_NAND_BCM47XXNFLASH_PLATFORM)
 static const char *probes[] = { "bcm47xxpart", NULL };
 
 static int bcm47xxnflash_probe(struct platform_device *pdev)
@@ -76,22 +77,31 @@ static struct platform_driver bcm47xxnflash_driver = {
 		.owner = THIS_MODULE,
 	},
 };
+#endif
+
+/**************************************************
+ * Init & exit
+ **************************************************/
 
 static int __init bcm47xxnflash_init(void)
 {
-	int err;
+	int err = 0;
 
+#if IS_ENABLED(CONFIG_MTD_NAND_BCM47XXNFLASH_PLATFORM)
 	err = platform_driver_register(&bcm47xxnflash_driver);
 	if (err)
 		pr_err("Failed to register bcm47xx nand flash driver: %d\n",
 		       err);
+#endif
 
 	return err;
 }
 
 static void __exit bcm47xxnflash_exit(void)
 {
+#if IS_ENABLED(CONFIG_MTD_NAND_BCM47XXNFLASH_PLATFORM)
 	platform_driver_unregister(&bcm47xxnflash_driver);
+#endif
 }
 
 module_init(bcm47xxnflash_init);
Signature · 1 line
1.8.4.5
#3 lore raw

RFC 3/3 mtd: bcm47xxnflash: prepare for adding BCMA driver

In reply to Rafał Miłecki
---
 drivers/mtd/nand/Kconfig              |  7 +++++
 drivers/mtd/nand/bcm47xxnflash/main.c | 56 +++++++++++++++++++++++++++++++++--
 2 files changed, 60 insertions(+), 3 deletions(-)
drivers/mtd/nand/Kconfig +7 -0
index a3e8ad2..fecde1e 100644
@@ -405,6 +405,13 @@ config MTD_NAND_BCM47XXNFLASH_PLATFORM
 	  most common was BCM4706, but it rarely could be also found on
 	  BCM5357.
 
+config MTD_NAND_BCM47XXNFLASH_BCMA
+	bool "NAND attached to BCMA as standalone core"
+	depends on MTD_NAND_BCM47XXNFLASH && BROKEN
+	help
+	  New SoCs (most probably only these ARM based) have NAND
+	  flash as separated bus core.
+
 config MTD_NAND_PLATFORM
 	tristate "Support for generic platform NAND driver"
 	depends on HAS_IOMEM
drivers/mtd/nand/bcm47xxnflash/main.c +53 -3

75 lines not on this page · raw message

Signature · 1 line
1.8.4.5
#4 lore raw
In reply to Rafał Miłecki
Quoted 11 lines · Rafał Miłecki

New Broadcom SoCs have NAND flashes attached & programmed in a totally different way. Instead of accessing them with help of ChipCommon core, they can be used directly.

To support them we can extend bcm47xxnflash in the way this patches implements. However almost nothing in the code will be shared between support for old and new devices.

How should we proceed? Implement it that way anyway? Or maybe writing a separated driver (bcm53xxnflash?) would be a better idea?

Hi,

if this controller is completely different I would suggest writing a new driver for that controller. Extending the existing driver would make if just more complex.

Hauke

#5 lore raw

Hi Rafal,

Quoted 9 lines · Hauke Mehrtens
Quoted 8 lines · Rafał Miłecki

New Broadcom SoCs have NAND flashes attached & programmed in a totally different way. Instead of accessing them with help of ChipCommon core, they can be used directly.

To support them we can extend bcm47xxnflash in the way this patches implements. However almost nothing in the code will be shared between support for old and new devices.

Quoted 6 lines
Quoted 2 lines

How should we proceed? Implement it that way anyway? Or maybe writing a separated driver (bcm53xxnflash?) would be a better idea?

if this controller is completely different I would suggest writing a new driver for that controller. Extending the existing driver would make if just more complex.

Judging by your (mostly non-functional) patch:

[WIP][FYI] mtd: bcm53xxnflash: add driver for NAND on new BCMA SoCs

it looks like your hardware is very similar to a line of NAND controllers that I support at Broadcom. I'm planning to upstream the driver eventually, and it is much more mature than what you have there. Perhaps you can wait to integrate with it?

The main difference between my driver and what I see you doing for 53xx is that you require the bcma_* accessors, whereas my platforms just perform direct memory-mapped register access.

Brian