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

Rafał Miłecki zajec5 at gmail.com
Sun Feb 23 06:26:58 EST 2014


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(-)

diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index a5bb738..a3e8ad2 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -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"
diff --git a/drivers/mtd/nand/bcm47xxnflash/Makefile b/drivers/mtd/nand/bcm47xxnflash/Makefile
index f05b119..4e755f0 100644
--- a/drivers/mtd/nand/bcm47xxnflash/Makefile
+++ b/drivers/mtd/nand/bcm47xxnflash/Makefile
@@ -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
diff --git a/drivers/mtd/nand/bcm47xxnflash/main.c b/drivers/mtd/nand/bcm47xxnflash/main.c
index 52611ef..c9d9b3f 100644
--- a/drivers/mtd/nand/bcm47xxnflash/main.c
+++ b/drivers/mtd/nand/bcm47xxnflash/main.c
@@ -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);
-- 
1.8.4.5




More information about the linux-mtd mailing list