Skip to contentSkip to conversation

bcm47xxnflash: read support for BCM4706

PATCH In review Rafał Miłecki 2 participants 12 messages Nov 12, 2012 – Nov 22, 2012

Subsystems (3)
lore
Share & tools
lore

Rafał Miłecki

author maintainer
#0 lore raw

v2 cover bcm47xxnflash: read support for BCM4706

I believe I've made "verify" tool working in my system and fixed all warning/errors reported by it.

Rafał Miłecki (6):
bcma: export PLL reading function
mtd: prepare place for BCMA NAND flash driver(s)
mtd: bcm47xxnflash: init NAND on BCM4706
mtd: bcm47xxnflash: support for NAND_CMD_READID command
mtd: bcm47xxnflash: implement reading
mtd: bcm47xxnflash: enable BCM4706 driver

 drivers/bcma/driver_chipcommon_pmu.c           |    3 +-
 drivers/mtd/nand/Kconfig                       |    9 +
 drivers/mtd/nand/Makefile                      |    1 +
 drivers/mtd/nand/bcm47xxnflash/Makefile        |    4 +
 drivers/mtd/nand/bcm47xxnflash/bcm47xxnflash.h |   22 ++
 drivers/mtd/nand/bcm47xxnflash/main.c          |  108 ++++++++
 drivers/mtd/nand/bcm47xxnflash/ops_bcm4706.c   |  316 ++++++++++++++++++++++++
 include/linux/bcma/bcma.h                      |    1 +
 8 files changed, 463 insertions(+), 1 deletions(-)
 create mode 100644 drivers/mtd/nand/bcm47xxnflash/Makefile
 create mode 100644 drivers/mtd/nand/bcm47xxnflash/bcm47xxnflash.h
 create mode 100644 drivers/mtd/nand/bcm47xxnflash/main.c
 create mode 100644 drivers/mtd/nand/bcm47xxnflash/ops_bcm4706.c
Signature · 1 line
1.7.7
author maintainer
#1 lore raw

PATCH v2 1/6 bcma: export PLL reading function

This is required by NAND flash driver for initializing wait counters.

---
 drivers/bcma/driver_chipcommon_pmu.c |    3 ++-
 include/linux/bcma/bcma.h            |    1 +
 2 files changed, 3 insertions(+), 1 deletions(-)
drivers/bcma/driver_chipcommon_pmu.c +2 -1
index 201faf1..657f235 100644
@@ -13,12 +13,13 @@
 #include <linux/export.h>
 #include <linux/bcma/bcma.h>
 
-static u32 bcma_chipco_pll_read(struct bcma_drv_cc *cc, u32 offset)
+u32 bcma_chipco_pll_read(struct bcma_drv_cc *cc, u32 offset)
 {
 	bcma_cc_write32(cc, BCMA_CC_PLLCTL_ADDR, offset);
 	bcma_cc_read32(cc, BCMA_CC_PLLCTL_ADDR);
 	return bcma_cc_read32(cc, BCMA_CC_PLLCTL_DATA);
 }
+EXPORT_SYMBOL_GPL(bcma_chipco_pll_read);
 
 void bcma_chipco_pll_write(struct bcma_drv_cc *cc, u32 offset, u32 value)
 {
include/linux/bcma/bcma.h +1 -0
index 4180eb7..4fb6bd7 100644
@@ -345,6 +345,7 @@ extern void bcma_core_set_clockmode(struct bcma_device *core,
 				    enum bcma_clkmode clkmode);
 extern void bcma_core_pll_ctl(struct bcma_device *core, u32 req, u32 status,
 			      bool on);
+extern u32 bcma_chipco_pll_read(struct bcma_drv_cc *cc, u32 offset);
 #define BCMA_DMA_TRANSLATION_MASK	0xC0000000
 #define  BCMA_DMA_TRANSLATION_NONE	0x00000000
 #define  BCMA_DMA_TRANSLATION_DMA32_CMT	0x40000000 /* Client Mode Translation for 32-bit DMA */
Signature · 1 line
1.7.7
author maintainer
#2 lore raw

PATCH v2 2/6 mtd: prepare place for BCMA NAND flash driver(s)

In reply to Rafał Miłecki

BCMA bus can contain NAND flash memory, it's registered in system as platform device. This adds required hooks and place for controler specific drivers.

---
There is the only warning reported to this patchset:

checkpatch.pl results for patch "[PATCH 2/6] mtd: prepare place for BCMA NAND flash driver(s)"

WARNING:STATIC_CONST_CHAR_ARRAY: static const char * array should probably be static const char * const #114: FILE: drivers/mtd/nand/bcm47xxnflash/main.c:24:
+static const char *probes[] = { "bcm47xxpart", NULL };

total: 0 errors, 1 warnings, 146 lines checked

AFAIK the code is correct, all the parsers I've checked have the same definition of probes.

---
 drivers/mtd/nand/Kconfig                       |    9 ++
 drivers/mtd/nand/Makefile                      |    1 +
 drivers/mtd/nand/bcm47xxnflash/Makefile        |    3 +
 drivers/mtd/nand/bcm47xxnflash/bcm47xxnflash.h |   14 +++
 drivers/mtd/nand/bcm47xxnflash/main.c          |  108 ++++++++++++++++++++++++
 5 files changed, 135 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mtd/nand/bcm47xxnflash/Makefile
 create mode 100644 drivers/mtd/nand/bcm47xxnflash/bcm47xxnflash.h
 create mode 100644 drivers/mtd/nand/bcm47xxnflash/main.c
drivers/mtd/nand/Kconfig +9 -0
index a803d9b..3314e92 100644
@@ -460,6 +460,15 @@ config MTD_NAND_GPMI_NAND
 	 block, such as SD card. So pay attention to it when you enable
 	 the GPMI.
 
+config MTD_NAND_BCM47XXNFLASH
+	tristate "R/O support for NAND flash on BCMA bus"
+	depends on BCMA_NFLASH
+	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 read mode for BCM4706 is
+	  implemented.
+
 config MTD_NAND_PLATFORM
 	tristate "Support for generic platform NAND driver"
 	depends on HAS_IOMEM
drivers/mtd/nand/Makefile +1 -0
index 44fca05..3c3f215 100644
@@ -54,5 +54,6 @@ obj-$(CONFIG_MTD_NAND_RICOH)		+= r852.o
 obj-$(CONFIG_MTD_NAND_JZ4740)		+= jz4740_nand.o
 obj-$(CONFIG_MTD_NAND_GPMI_NAND)	+= gpmi-nand/
 obj-$(CONFIG_MTD_NAND_XWAY)		+= xway_nand.o
+obj-$(CONFIG_MTD_NAND_BCM47XXNFLASH)	+= bcm47xxnflash/
 
 nand-objs := nand_base.o nand_bbt.o
drivers/mtd/nand/bcm47xxnflash/Makefile new file +3 -0
new file mode 100644
index 0000000..1d0693a
@@ -0,0 +1,3 @@
+bcm47xxnflash-y				+= main.o
+
+obj-$(CONFIG_MTD_NAND_BCM47XXNFLASH)	+= bcm47xxnflash.o
drivers/mtd/nand/bcm47xxnflash/bcm47xxnflash.h new file +14 -0
new file mode 100644
index 0000000..2e8864a
@@ -0,0 +1,14 @@
+#ifndef __BCM47XXNFLASH_H
+#define __BCM47XXNFLASH_H
+
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/nand.h>
+
+struct bcm47xxnflash {
+	struct bcma_drv_cc *cc;
+
+	struct nand_chip nand_chip;
+	struct mtd_info mtd;
+};
+
+#endif /* BCM47XXNFLASH */
drivers/mtd/nand/bcm47xxnflash/main.c new file +108 -0

108 lines not on this page · raw message

Signature · 1 line
1.7.7
author maintainer
#3 lore raw

PATCH v2 3/6 mtd: bcm47xxnflash: init NAND on BCM4706

In reply to Rafał Miłecki
---
 drivers/mtd/nand/bcm47xxnflash/Makefile      |    1 +
 drivers/mtd/nand/bcm47xxnflash/ops_bcm4706.c |  109 ++++++++++++++++++++++++++
 2 files changed, 110 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mtd/nand/bcm47xxnflash/ops_bcm4706.c
drivers/mtd/nand/bcm47xxnflash/Makefile +1 -0
index 1d0693a..4f688f9 100644
@@ -1,3 +1,4 @@
 bcm47xxnflash-y				+= main.o
+bcm47xxnflash-				+= ops_bcm4706.o
 
 obj-$(CONFIG_MTD_NAND_BCM47XXNFLASH)	+= bcm47xxnflash.o
drivers/mtd/nand/bcm47xxnflash/ops_bcm4706.c new file +109 -0

109 lines not on this page · raw message

Signature · 1 line
1.7.7
author maintainer
#4 lore raw

PATCH v2 4/6 mtd: bcm47xxnflash: support for NAND_CMD_READID command

In reply to Rafał Miłecki
---
 drivers/mtd/nand/bcm47xxnflash/bcm47xxnflash.h |    5 +
 drivers/mtd/nand/bcm47xxnflash/ops_bcm4706.c   |  101 ++++++++++++++++++++++++
 2 files changed, 106 insertions(+), 0 deletions(-)
drivers/mtd/nand/bcm47xxnflash/bcm47xxnflash.h +5 -0
index 2e8864a..cc71400 100644
@@ -9,6 +9,11 @@ struct bcm47xxnflash {
 
 	struct nand_chip nand_chip;
 	struct mtd_info mtd;
+
+	unsigned curr_command;
+	int curr_column;
+
+	u8 id_data[8];
 };
 
 #endif /* BCM47XXNFLASH */
drivers/mtd/nand/bcm47xxnflash/ops_bcm4706.c +101 -0

125 lines not on this page · raw message

Signature · 1 line
1.7.7
author maintainer
#5 lore raw

PATCH v2 5/6 mtd: bcm47xxnflash: implement reading

In reply to Rafał Miłecki
---
 drivers/mtd/nand/bcm47xxnflash/bcm47xxnflash.h |    1 +
 drivers/mtd/nand/bcm47xxnflash/ops_bcm4706.c   |  106 ++++++++++++++++++++++++
 2 files changed, 107 insertions(+), 0 deletions(-)
drivers/mtd/nand/bcm47xxnflash/bcm47xxnflash.h +1 -0
index cc71400..264aec4 100644
@@ -11,6 +11,7 @@ struct bcm47xxnflash {
 	struct mtd_info mtd;
 
 	unsigned curr_command;
+	int curr_page_addr;
 	int curr_column;
 
 	u8 id_data[8];
drivers/mtd/nand/bcm47xxnflash/ops_bcm4706.c +106 -0

154 lines not on this page · raw message

Signature · 1 line
1.7.7
author maintainer
#6 lore raw

PATCH v2 6/6 mtd: bcm47xxnflash: enable BCM4706 driver

In reply to Rafał Miłecki
---
 drivers/mtd/nand/bcm47xxnflash/Makefile        |    2 +-
 drivers/mtd/nand/bcm47xxnflash/bcm47xxnflash.h |    2 ++
 drivers/mtd/nand/bcm47xxnflash/main.c          |    4 ++--
 3 files changed, 5 insertions(+), 3 deletions(-)
drivers/mtd/nand/bcm47xxnflash/Makefile +1 -1
index 4f688f9..f05b119 100644
@@ -1,4 +1,4 @@
 bcm47xxnflash-y				+= main.o
-bcm47xxnflash-				+= ops_bcm4706.o
+bcm47xxnflash-y				+= ops_bcm4706.o
 
 obj-$(CONFIG_MTD_NAND_BCM47XXNFLASH)	+= bcm47xxnflash.o
drivers/mtd/nand/bcm47xxnflash/bcm47xxnflash.h +2 -0
index 264aec4..0bdb2ce 100644
@@ -17,4 +17,6 @@ struct bcm47xxnflash {
 	u8 id_data[8];
 };
 
+int bcm47xxnflash_ops_bcm4706_init(struct bcm47xxnflash *b47n);
+
 #endif /* BCM47XXNFLASH */
drivers/mtd/nand/bcm47xxnflash/main.c +2 -2
index fc9139d..2b8b05b 100644
@@ -40,8 +40,8 @@ static int bcm47xxnflash_probe(struct platform_device *pdev)
 	b47n->mtd.priv = &b47n->nand_chip; /* Required */
 	b47n->cc = container_of(nflash, struct bcma_drv_cc, nflash);
 
-	if (0) {
-		/* TODO: init device */
+	if (b47n->cc->core->bus->chipinfo.id == BCMA_CHIP_ID_BCM4706) {
+		err = bcm47xxnflash_ops_bcm4706_init(b47n);
 	} else {
 		pr_err("Device not supported\n");
 		err = -ENOTSUPP;
Signature · 1 line
1.7.7
#7 lore raw
In reply to Rafał Miłecki
Quoted 2 lines · Rafał Miłecki

I believe I've made "verify" tool working in my system and fixed all warning/errors reported by it.

Please, send me a configuration which I can use to compile-test this stuff.

Signature · 2 lines
Best Regards,
Artem Bityutskiy
author maintainer
#8 lore raw

2012/11/21 Artem Bityutskiy <[email protected]>:

Quoted 6 lines · Rafał Miłecki
Quoted 2 lines

I believe I've made "verify" tool working in my system and fixed all warning/errors reported by it.

Please, send me a configuration which I can use to compile-test this stuff.

I think this is the .config user by OpenWRT building system. It has CONFIG_MTD_NAND_BCM47XXNFLASH=y
so looks sane.

Unfortunately it's not a minimal config possible, that allows testing bcm47xxnflash. Are you OK with that?

Signature · 1 line
Rafał
#9 lore raw
Quoted 8 lines · Rafał Miłecki

2012/11/21 Artem Bityutskiy <[email protected]>:

Quoted 6 lines · Rafał Miłecki
Quoted 2 lines

I believe I've made "verify" tool working in my system and fixed all warning/errors reported by it.

Please, send me a configuration which I can use to compile-test this stuff.

Quoted 6 lines

I think this is the .config user by OpenWRT building system. It has CONFIG_MTD_NAND_BCM47XXNFLASH=y
so looks sane.

Unfortunately it's not a minimal config possible, that allows testing bcm47xxnflash. Are you OK with that?

Thanks. I've actually instead modified my own mips-bcm47xx_defconfig from the 'maintaining.git' project, so it has CONFIG_MTD_NAND_BCM47XXNFLASH=m now.

Signature · 2 lines
Best Regards,
Artem Bityutskiy
author maintainer
#10 lore raw

2012/11/22 Artem Bityutskiy <[email protected]>:

Quoted 13 lines · Rafał Miłecki
Quoted 12 lines

2012/11/21 Artem Bityutskiy <[email protected]>:

Quoted 6 lines · Rafał Miłecki
Quoted 2 lines

I believe I've made "verify" tool working in my system and fixed all warning/errors reported by it.

Please, send me a configuration which I can use to compile-test this stuff.

I think this is the .config user by OpenWRT building system. It has CONFIG_MTD_NAND_BCM47XXNFLASH=y
so looks sane.

Quoted 6 lines
Quoted 2 lines

Unfortunately it's not a minimal config possible, that allows testing bcm47xxnflash. Are you OK with that?

Thanks. I've actually instead modified my own mips-bcm47xx_defconfig from the 'maintaining.git' project, so it has CONFIG_MTD_NAND_BCM47XXNFLASH=m now.

Good idea, thanks :) I'll just use your config in the future for testing changes.

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

I believe I've made "verify" tool working in my system and fixed all warning/errors reported by it.

Looks good to me, thanks, pushed to l2-mtd.git.

Signature · 2 lines
Best Regards,
Artem Bityutskiy