Skip to contentSkip to conversation

mtd: bcm47xxsflash: store info about flash type

PATCH In review Rafał Miłecki 2 participants 5 messages Feb 20, 2013 – Mar 6, 2013 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 mtd: bcm47xxsflash: store info about flash type

It's going to be needed for erase and write operations, they differ between Atmel and ST flashes.

---
 drivers/mtd/devices/bcm47xxsflash.c |    9 +++++++++
 drivers/mtd/devices/bcm47xxsflash.h |    7 +++++++
 2 files changed, 16 insertions(+)
drivers/mtd/devices/bcm47xxsflash.c +9 -0
index 9526628..155a7ea 100644
@@ -61,6 +61,15 @@ static int bcm47xxsflash_bcma_probe(struct platform_device *pdev)
 	}
 	sflash->priv = b47s;
 
+	switch (b47s->bcma_cc->capabilities & BCMA_CC_CAP_FLASHT) {
+	case BCMA_CC_FLASHT_STSER:
+		b47s->type = BCM47XXSFLASH_TYPE_ST;
+		break;
+	case BCMA_CC_FLASHT_ATSER:
+		b47s->type = BCM47XXSFLASH_TYPE_ATMEL;
+		break;
+	}
+
 	b47s->window = sflash->window;
 	b47s->blocksize = sflash->blocksize;
 	b47s->numblocks = sflash->numblocks;
drivers/mtd/devices/bcm47xxsflash.h +7 -0
index ebf6f71..7d5654b 100644
@@ -3,7 +3,14 @@
 
 #include <linux/mtd/mtd.h>
 
+enum bcm47xxsflash_type {
+	BCM47XXSFLASH_TYPE_ATMEL,
+	BCM47XXSFLASH_TYPE_ST,
+};
+
 struct bcm47xxsflash {
+	enum bcm47xxsflash_type type;
+
 	u32 window;
 	u32 blocksize;
 	u16 numblocks;
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH 2/3 mtd: bcm47xxsflash: keep a reference to the BCMA ChipCommon

To implement erase and write support we need to "talk" with ChipCommon BCMA core which serial flash it attached to.

---
 drivers/mtd/devices/bcm47xxsflash.c |    2 ++
 drivers/mtd/devices/bcm47xxsflash.h |    6 ++++++
 2 files changed, 8 insertions(+)
drivers/mtd/devices/bcm47xxsflash.c +2 -0
index 155a7ea..e04e2c5 100644
@@ -70,6 +70,8 @@ static int bcm47xxsflash_bcma_probe(struct platform_device *pdev)
 		break;
 	}
 
+	b47s->bcma_cc = container_of(sflash, struct bcma_drv_cc, sflash);
+
 	b47s->window = sflash->window;
 	b47s->blocksize = sflash->blocksize;
 	b47s->numblocks = sflash->numblocks;
drivers/mtd/devices/bcm47xxsflash.h +6 -0
index 7d5654b..1574ea8 100644
@@ -3,12 +3,18 @@
 
 #include <linux/mtd/mtd.h>
 
+struct bcma_drv_cc;
+
 enum bcm47xxsflash_type {
 	BCM47XXSFLASH_TYPE_ATMEL,
 	BCM47XXSFLASH_TYPE_ST,
 };
 
 struct bcm47xxsflash {
+	union {
+		struct bcma_drv_cc *bcma_cc;
+	};
+
 	enum bcm47xxsflash_type type;
 
 	u32 window;
Signature · 1 line
1.7.10.4
#2 lore raw

PATCH 3/3 mtd: bcm47xxsflash: define opcodes

In reply to Rafał Miłecki

We need them to add erase/write support. This may duplicate some defines with bcma and/or ssb code, but it makes more sense to keep that in bcm47xxsflash which is supposed to work with both buses. Duplicated defines will be removed from ssb/bcma.

---
 drivers/mtd/devices/bcm47xxsflash.h |   48 +++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)
drivers/mtd/devices/bcm47xxsflash.h +48 -0
index 1574ea8..3faffcc 100644
@@ -3,6 +3,54 @@
 
 #include <linux/mtd/mtd.h>
 
+/* Used for ST flashes only. */
+#define OPCODE_ST_WREN		0x0006		/* Write Enable */
+#define OPCODE_ST_WRDIS		0x0004		/* Write Disable */
+#define OPCODE_ST_RDSR		0x0105		/* Read Status Register */
+#define OPCODE_ST_WRSR		0x0101		/* Write Status Register */
+#define OPCODE_ST_READ		0x0303		/* Read Data Bytes */
+#define OPCODE_ST_PP		0x0302		/* Page Program */
+#define OPCODE_ST_SE		0x02d8		/* Sector Erase */
+#define OPCODE_ST_BE		0x00c7		/* Bulk Erase */
+#define OPCODE_ST_DP		0x00b9		/* Deep Power-down */
+#define OPCODE_ST_RES		0x03ab		/* Read Electronic Signature */
+#define OPCODE_ST_CSA		0x1000		/* Keep chip select asserted */
+#define OPCODE_ST_SSE		0x0220		/* Sub-sector Erase */
+
+/* Used for Atmel flashes only. */
+#define OPCODE_AT_READ				0x07e8
+#define OPCODE_AT_PAGE_READ			0x07d2
+#define OPCODE_AT_STATUS			0x01d7
+#define OPCODE_AT_BUF1_WRITE			0x0384
+#define OPCODE_AT_BUF2_WRITE			0x0387
+#define OPCODE_AT_BUF1_ERASE_PROGRAM		0x0283
+#define OPCODE_AT_BUF2_ERASE_PROGRAM		0x0286
+#define OPCODE_AT_BUF1_PROGRAM			0x0288
+#define OPCODE_AT_BUF2_PROGRAM			0x0289
+#define OPCODE_AT_PAGE_ERASE			0x0281
+#define OPCODE_AT_BLOCK_ERASE			0x0250
+#define OPCODE_AT_BUF1_WRITE_ERASE_PROGRAM	0x0382
+#define OPCODE_AT_BUF2_WRITE_ERASE_PROGRAM	0x0385
+#define OPCODE_AT_BUF1_LOAD			0x0253
+#define OPCODE_AT_BUF2_LOAD			0x0255
+#define OPCODE_AT_BUF1_COMPARE			0x0260
+#define OPCODE_AT_BUF2_COMPARE			0x0261
+#define OPCODE_AT_BUF1_REPROGRAM		0x0258
+#define OPCODE_AT_BUF2_REPROGRAM		0x0259
+
+/* Status register bits for ST flashes */
+#define SR_ST_WIP		0x01		/* Write In Progress */
+#define SR_ST_WEL		0x02		/* Write Enable Latch */
+#define SR_ST_BP_MASK		0x1c		/* Block Protect */
+#define SR_ST_BP_SHIFT		2
+#define SR_ST_SRWD		0x80		/* Status Register Write Disable */
+
+/* Status register bits for Atmel flashes */
+#define SR_AT_READY		0x80
+#define SR_AT_MISMATCH		0x40
+#define SR_AT_ID_MASK		0x38
+#define SR_AT_ID_SHIFT		3
+
 struct bcma_drv_cc;
 
 enum bcm47xxsflash_type {
Signature · 1 line
1.7.10.4
#3 lore raw
In reply to Rafał Miłecki
Quoted 4 lines · Rafał Miłecki

It's going to be needed for erase and write operations, they differ between Atmel and ST flashes.

Aiaiai!

--------------------------------------------------------------------------------

Bisectability test results for configuration "mips-bcm47xx_defconfig,mips,mips-linux-"

Failed to build the following commit for configuration "mips-bcm47xx_defconfig"":

ab61426 mtd: bcm47xxsflash: store info about flash type

drivers/mtd/devices/bcm47xxsflash.c: In function 'bcm47xxsflash_bcma_probe':
drivers/mtd/devices/bcm47xxsflash.c:64:14: error: 'struct bcm47xxsflash' has no member named 'bcma_cc' make[4]: *** [drivers/mtd/devices/bcm47xxsflash.o] Error 1

--------------------------------------------------------------------------------

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

2013/3/6 Artem Bityutskiy <[email protected]>:

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

It's going to be needed for erase and write operations, they differ between Atmel and ST flashes.

Aiaiai!

--------------------------------------------------------------------------------

Bisectability test results for configuration "mips-bcm47xx_defconfig,mips,mips-linux-"

Quoted 8 lines

Failed to build the following commit for configuration "mips-bcm47xx_defconfig"":

ab61426 mtd: bcm47xxsflash: store info about flash type

drivers/mtd/devices/bcm47xxsflash.c: In function 'bcm47xxsflash_bcma_probe':
drivers/mtd/devices/bcm47xxsflash.c:64:14: error: 'struct bcm47xxsflash' has no member named 'bcma_cc' make[4]: *** [drivers/mtd/devices/bcm47xxsflash.o] Error 1

For some unknown reason it seems I haven't noticed anything above

Quoted 1 line

Successfully built configuration "mips-bcm47xx_defconfig,mips,mips-linux-", no issues

:/ Sorry

Signature · 1 line
Rafał