mtd: bcm47xxsflash: keep a reference to the BCMA
PATCH v2 1/3 mtd: bcm47xxsflash: keep a reference to the BCMA
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
@@ -61,6 +61,8 @@ static int bcm47xxsflash_bcma_probe(struct platform_device *pdev) } sflash->priv = b47s; + 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
@@ -3,7 +3,13 @@#include <linux/mtd/mtd.h> +struct bcma_drv_cc ; +struct bcm47xxsflash { +union { +struct bcma_drv_cc *bcma_cc; + }; +u32 window;u32 blocksize;u16 numblocks;
Signature · 1 line
1.7.10.4
PATCH v2 2/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
@@ -63,6 +63,15 @@ static int bcm47xxsflash_bcma_probe(struct platform_device *pdev) b47s->bcma_cc = container_of(sflash, struct bcma_drv_cc, sflash); +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
@@ -5,11 +5,18 @@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;u32 blocksize;u16 numblocks;
Signature · 1 line
1.7.10.4
PATCH v3 2/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.
---
V3: rebase after change in 0001
--- drivers/mtd/devices/bcm47xxsflash.c | 9 +++++++++ drivers/mtd/devices/bcm47xxsflash.h | 7 +++++++ 2 files changed, 16 insertions(+)
drivers/mtd/devices/bcm47xxsflash.c +9 -0
@@ -63,6 +63,15 @@ static int bcm47xxsflash_bcma_probe(struct platform_device *pdev) b47s->bcma_cc = container_of(sflash, struct bcma_drv_cc, sflash); +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
@@ -5,9 +5,16 @@struct bcma_drv_cc ; +enum bcm47xxsflash_type { +BCM47XXSFLASH_TYPE_ATMEL , +BCM47XXSFLASH_TYPE_ST , +}; +struct bcm47xxsflash {struct bcma_drv_cc *bcma_cc; +enum bcm47xxsflash_type type; +u32 window;u32 blocksize;u16 numblocks;
Signature · 1 line
1.7.10.4
PATCH 3/3 mtd: bcm47xxsflash: define opcodes
In reply to Rafał MiłeckiWe 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
@@ -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
drivers/mtd/devices/bcm47xxsflash.h line 11
Quoted 6 lines · Rafał Miłecki
struct
bcma_drv_cc;drivers/mtd/devices/bcm47xxsflash.h +4
-0+struct bcm47xxsflash { +union { +struct bcma_drv_cc *bcma_cc; + };
Why union?
Signature · 2 lines
Best Regards, Artem Bityutskiy
2013/3/6 Artem Bityutskiy <[email protected]>:
Quoted 9 lines · Rafał Miłecki
drivers/mtd/devices/bcm47xxsflash.h line 11
Quoted 6 lines
struct
bcma_drv_cc;drivers/mtd/devices/bcm47xxsflash.h +4
-0+struct bcm47xxsflash { +union { +struct bcma_drv_cc *bcma_cc; + };Why union?
It's about adding support for different buses in the future (ssb) I was describing in the other patch.
Signature · 1 line
Rafał
2013/3/6 Rafał Miłecki <[email protected]>:
Quoted 9 lines
2013/3/6 Artem Bityutskiy <[email protected]>:
Quoted 8 lines · Rafał Miłecki
Quoted 6 lines
struct
bcma_drv_cc;drivers/mtd/devices/bcm47xxsflash.h +4
-0+struct bcm47xxsflash { +union { +struct bcma_drv_cc *bcma_cc; + };
Quoted 4 lines
Quoted 1 line
Why union?
It's about adding support for different buses in the future (ssb) I was describing in the other patch.
Obvious for me, but just in case:
union {
struct bcma_drv_cc *bcma_cc;
struct ssb_chipcommon *ssb_cc;
};Signature · 1 line
Rafał
Quoted 9 lines · Rafał Miłecki
2013/3/6 Artem Bityutskiy <[email protected]>:
Quoted 8 lines · Rafał Miłecki
Quoted 6 lines
struct
bcma_drv_cc;drivers/mtd/devices/bcm47xxsflash.h +4
-0+struct bcm47xxsflash { +union { +struct bcma_drv_cc *bcma_cc; + };
Quoted 4 lines
Quoted 1 line
Why union?
It's about adding support for different buses in the future (ssb) I was describing in the other patch.
Would be a bit cleaner to add the union when you add the second field instead, or at least make sure you add the second field in this series. Otherwise how do I know if you are going to ever send a patch which justifies the union?
Signature · 2 lines
Best Regards, Artem Bityutskiy
PATCH v3 1/3 mtd: bcm47xxsflash: keep a reference to the BCMA
In reply to Rafał MiłeckiTo implement erase and write support we need to "talk" with ChipCommon BCMA core which serial flash it attached to.
---
V3: don't use "union" for now
--- drivers/mtd/devices/bcm47xxsflash.c | 2 ++ drivers/mtd/devices/bcm47xxsflash.h | 4 ++++ 2 files changed, 6 insertions(+)
drivers/mtd/devices/bcm47xxsflash.c +2 -0
@@ -61,6 +61,8 @@ static int bcm47xxsflash_bcma_probe(struct platform_device *pdev) } sflash->priv = b47s; + 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 +4 -0
@@ -3,7 +3,11 @@#include <linux/mtd/mtd.h> +struct bcma_drv_cc ; +struct bcm47xxsflash { +struct bcma_drv_cc *bcma_cc; +u32 window;u32 blocksize;u16 numblocks;
Signature · 1 line
1.7.10.4
Quoted 4 lines · Rafał Miłecki
To implement erase and write support we need to "talk" with ChipCommon BCMA core which serial flash it attached to.
Signed-off-by Rafał Miłecki <[email protected]>
Pushed the 3 to l2-mtd.git, thanks!
Signature · 2 lines
Best Regards, Artem Bityutskiy
2013/3/13 Artem Bityutskiy <[email protected]>:
Quoted 7 lines · Rafał Miłecki
Quoted 4 lines
To implement erase and write support we need to "talk" with ChipCommon BCMA core which serial flash it attached to.
Signed-off-by Rafał Miłecki <[email protected]>Pushed the 3 to l2-mtd.git, thanks!
Thank you for your help on getting this cleaned :)
Signature · 1 line
Rafał