public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: "Rafał Miłecki" <zajec5@gmail.com>
To: linux-mtd@lists.infradead.org
Cc: "Hauke Mehrtens" <hauke@hauke-m.de>, "Rafał Miłecki" <zajec5@gmail.com>
Subject: [RFC 3/3] mtd: bcm47xxnflash: prepare for adding BCMA driver
Date: Sun, 23 Feb 2014 12:34:26 +0100	[thread overview]
Message-ID: <1393155266-7610-1-git-send-email-zajec5@gmail.com> (raw)

---
 drivers/mtd/nand/Kconfig              |  7 +++++
 drivers/mtd/nand/bcm47xxnflash/main.c | 56 +++++++++++++++++++++++++++++++++--
 2 files changed, 60 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index a3e8ad2..fecde1e 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -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
diff --git a/drivers/mtd/nand/bcm47xxnflash/main.c b/drivers/mtd/nand/bcm47xxnflash/main.c
index c9d9b3f..aebe2d5 100644
--- a/drivers/mtd/nand/bcm47xxnflash/main.c
+++ b/drivers/mtd/nand/bcm47xxnflash/main.c
@@ -80,6 +80,36 @@ static struct platform_driver bcm47xxnflash_driver = {
 #endif
 
 /**************************************************
+ * BCMA
+ **************************************************/
+
+#if IS_ENABLED(CONFIG_MTD_NAND_BCM47XXNFLASH_BCMA)
+static const struct bcma_device_id bcm47xxnflash_bcma_tbl[] = {
+	BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_NAND, BCMA_ANY_REV, BCMA_ANY_CLASS),
+	BCMA_CORETABLE_END
+};
+MODULE_DEVICE_TABLE(bcma, bcm47xxnflash_bcma_tbl);
+
+static int bcm47xxnflash_bcma_probe(struct bcma_device *core)
+{
+	pr_info("Device ID: 0x%08X\n", bcma_read32(core, 0x194));
+
+	return -ENOTSUPP;
+}
+
+static void bcm47xxnflash_bcma_remove(struct bcma_device *core)
+{
+}
+
+static struct bcma_driver bcm47xxnflash_bcma_driver = {
+	.name		= KBUILD_MODNAME,
+	.id_table	= bcm47xxnflash_bcma_tbl,
+	.probe		= bcm47xxnflash_bcma_probe,
+	.remove		= bcm47xxnflash_bcma_remove,
+};
+#endif
+
+/**************************************************
  * Init & exit
  **************************************************/
 
@@ -89,16 +119,36 @@ static int __init bcm47xxnflash_init(void)
 
 #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);
+	if (err) {
+		pr_err("Failed to register platform driver: %d\n", err);
+		return err;
+	}
+#endif
+
+#if IS_ENABLED(CONFIG_MTD_NAND_BCM47XXNFLASH_BCMA)
+	err = bcma_driver_register(&bcm47xxnflash_bcma_driver);
+	if (err) {
+		pr_err("Failed to register bcma driver: %d\n", err);
+		goto err_plat_unregister;
+	}
 #endif
 
+	return 0;
+
+#if IS_ENABLED(CONFIG_MTD_NAND_BCM47XXNFLASH_BCMA)
+err_plat_unregister:
+#endif
+#if IS_ENABLED(CONFIG_MTD_NAND_BCM47XXNFLASH_PLATFORM)
+	platform_driver_unregister(&bcm47xxnflash_driver);
+#endif
 	return err;
 }
 
 static void __exit bcm47xxnflash_exit(void)
 {
+#if IS_ENABLED(CONFIG_MTD_NAND_BCM47XXNFLASH_BCMA)
+	bcma_driver_unregister(&bcm47xxnflash_bcma_driver);
+#endif
 #if IS_ENABLED(CONFIG_MTD_NAND_BCM47XXNFLASH_PLATFORM)
 	platform_driver_unregister(&bcm47xxnflash_driver);
 #endif
-- 
1.8.4.5

             reply	other threads:[~2014-02-23 11:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-23 11:34 Rafał Miłecki [this message]
  -- strict thread matches above, loose matches on Subject: below --
2014-02-23 11:26 [RFC 0/3] mtd: bcm47xxnflash: adding support for new NANDs Rafał Miłecki
2014-02-23 11:26 ` [RFC 3/3] mtd: bcm47xxnflash: prepare for adding BCMA driver Rafał Miłecki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1393155266-7610-1-git-send-email-zajec5@gmail.com \
    --to=zajec5@gmail.com \
    --cc=hauke@hauke-m.de \
    --cc=linux-mtd@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox