public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH V2 1/3] mtd: bcm47xxsflash: keep a reference to the BCMA
@ 2013-03-06 11:01 Rafał Miłecki
  2013-03-06 11:01 ` [PATCH V2 2/3] mtd: bcm47xxsflash: store info about flash type Rafał Miłecki
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Rafał Miłecki @ 2013-03-06 11:01 UTC (permalink / raw)
  To: linux-mtd, Artem Bityutskiy, David Woodhouse
  Cc: Hauke Mehrtens, 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 <zajec5@gmail.com>
---
 drivers/mtd/devices/bcm47xxsflash.c |    2 ++
 drivers/mtd/devices/bcm47xxsflash.h |    6 ++++++
 2 files changed, 8 insertions(+)

diff --git a/drivers/mtd/devices/bcm47xxsflash.c b/drivers/mtd/devices/bcm47xxsflash.c
index 9526628..b22df6d 100644
--- a/drivers/mtd/devices/bcm47xxsflash.c
+++ b/drivers/mtd/devices/bcm47xxsflash.c
@@ -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;
diff --git a/drivers/mtd/devices/bcm47xxsflash.h b/drivers/mtd/devices/bcm47xxsflash.h
index ebf6f71..9b79723 100644
--- a/drivers/mtd/devices/bcm47xxsflash.h
+++ b/drivers/mtd/devices/bcm47xxsflash.h
@@ -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;
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH V2 2/3] mtd: bcm47xxsflash: store info about flash type
  2013-03-06 11:01 [PATCH V2 1/3] mtd: bcm47xxsflash: keep a reference to the BCMA Rafał Miłecki
@ 2013-03-06 11:01 ` Rafał Miłecki
  2013-03-06 11:34   ` [PATCH V3 " Rafał Miłecki
  2013-03-06 11:01 ` [PATCH 3/3] mtd: bcm47xxsflash: define opcodes Rafał Miłecki
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Rafał Miłecki @ 2013-03-06 11:01 UTC (permalink / raw)
  To: linux-mtd, Artem Bityutskiy, David Woodhouse
  Cc: Hauke Mehrtens, Rafał Miłecki

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

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
---
 drivers/mtd/devices/bcm47xxsflash.c |    9 +++++++++
 drivers/mtd/devices/bcm47xxsflash.h |    7 +++++++
 2 files changed, 16 insertions(+)

diff --git a/drivers/mtd/devices/bcm47xxsflash.c b/drivers/mtd/devices/bcm47xxsflash.c
index b22df6d..2f9e629 100644
--- a/drivers/mtd/devices/bcm47xxsflash.c
+++ b/drivers/mtd/devices/bcm47xxsflash.c
@@ -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;
diff --git a/drivers/mtd/devices/bcm47xxsflash.h b/drivers/mtd/devices/bcm47xxsflash.h
index 9b79723..1574ea8 100644
--- a/drivers/mtd/devices/bcm47xxsflash.h
+++ b/drivers/mtd/devices/bcm47xxsflash.h
@@ -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;
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 3/3] mtd: bcm47xxsflash: define opcodes
  2013-03-06 11:01 [PATCH V2 1/3] mtd: bcm47xxsflash: keep a reference to the BCMA Rafał Miłecki
  2013-03-06 11:01 ` [PATCH V2 2/3] mtd: bcm47xxsflash: store info about flash type Rafał Miłecki
@ 2013-03-06 11:01 ` Rafał Miłecki
  2013-03-06 11:07 ` [PATCH V2 1/3] mtd: bcm47xxsflash: keep a reference to the BCMA Artem Bityutskiy
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Rafał Miłecki @ 2013-03-06 11:01 UTC (permalink / raw)
  To: linux-mtd, Artem Bityutskiy, David Woodhouse
  Cc: Hauke Mehrtens, 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.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
---
 drivers/mtd/devices/bcm47xxsflash.h |   48 +++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/drivers/mtd/devices/bcm47xxsflash.h b/drivers/mtd/devices/bcm47xxsflash.h
index 1574ea8..3faffcc 100644
--- a/drivers/mtd/devices/bcm47xxsflash.h
+++ b/drivers/mtd/devices/bcm47xxsflash.h
@@ -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 {
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH V2 1/3] mtd: bcm47xxsflash: keep a reference to the BCMA
  2013-03-06 11:01 [PATCH V2 1/3] mtd: bcm47xxsflash: keep a reference to the BCMA Rafał Miłecki
  2013-03-06 11:01 ` [PATCH V2 2/3] mtd: bcm47xxsflash: store info about flash type Rafał Miłecki
  2013-03-06 11:01 ` [PATCH 3/3] mtd: bcm47xxsflash: define opcodes Rafał Miłecki
@ 2013-03-06 11:07 ` Artem Bityutskiy
  2013-03-06 11:08   ` Rafał Miłecki
  2013-03-06 11:33 ` [PATCH V3 " Rafał Miłecki
  2013-03-13 10:58 ` [PATCH V2 " Artem Bityutskiy
  4 siblings, 1 reply; 11+ messages in thread
From: Artem Bityutskiy @ 2013-03-06 11:07 UTC (permalink / raw)
  To: Rafał Miłecki; +Cc: Hauke Mehrtens, linux-mtd, David Woodhouse

On Wed, 2013-03-06 at 12:01 +0100, Rafał Miłecki wrote:
> struct bcma_drv_cc;
> +
>  struct bcm47xxsflash {
> +	union {
> +		struct bcma_drv_cc *bcma_cc;
> +	};

Why union?

-- 
Best Regards,
Artem Bityutskiy

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH V2 1/3] mtd: bcm47xxsflash: keep a reference to the BCMA
  2013-03-06 11:07 ` [PATCH V2 1/3] mtd: bcm47xxsflash: keep a reference to the BCMA Artem Bityutskiy
@ 2013-03-06 11:08   ` Rafał Miłecki
  2013-03-06 11:10     ` Rafał Miłecki
  2013-03-06 11:13     ` Artem Bityutskiy
  0 siblings, 2 replies; 11+ messages in thread
From: Rafał Miłecki @ 2013-03-06 11:08 UTC (permalink / raw)
  To: dedekind1; +Cc: Hauke Mehrtens, linux-mtd, David Woodhouse

2013/3/6 Artem Bityutskiy <dedekind1@gmail.com>:
> On Wed, 2013-03-06 at 12:01 +0100, Rafał Miłecki wrote:
>> struct bcma_drv_cc;
>> +
>>  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.

-- 
Rafał

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH V2 1/3] mtd: bcm47xxsflash: keep a reference to the BCMA
  2013-03-06 11:08   ` Rafał Miłecki
@ 2013-03-06 11:10     ` Rafał Miłecki
  2013-03-06 11:13     ` Artem Bityutskiy
  1 sibling, 0 replies; 11+ messages in thread
From: Rafał Miłecki @ 2013-03-06 11:10 UTC (permalink / raw)
  To: dedekind1; +Cc: Hauke Mehrtens, linux-mtd, David Woodhouse

2013/3/6 Rafał Miłecki <zajec5@gmail.com>:
> 2013/3/6 Artem Bityutskiy <dedekind1@gmail.com>:
>> On Wed, 2013-03-06 at 12:01 +0100, Rafał Miłecki wrote:
>>> struct bcma_drv_cc;
>>> +
>>>  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.

Obvious for me, but just in case:

union {
	struct bcma_drv_cc *bcma_cc;
	struct ssb_chipcommon *ssb_cc;
};

-- 
Rafał

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH V2 1/3] mtd: bcm47xxsflash: keep a reference to the BCMA
  2013-03-06 11:08   ` Rafał Miłecki
  2013-03-06 11:10     ` Rafał Miłecki
@ 2013-03-06 11:13     ` Artem Bityutskiy
  1 sibling, 0 replies; 11+ messages in thread
From: Artem Bityutskiy @ 2013-03-06 11:13 UTC (permalink / raw)
  To: Rafał Miłecki; +Cc: Hauke Mehrtens, linux-mtd, David Woodhouse

On Wed, 2013-03-06 at 12:08 +0100, Rafał Miłecki wrote:
> 2013/3/6 Artem Bityutskiy <dedekind1@gmail.com>:
> > On Wed, 2013-03-06 at 12:01 +0100, Rafał Miłecki wrote:
> >> struct bcma_drv_cc;
> >> +
> >>  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.

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?

-- 
Best Regards,
Artem Bityutskiy

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH V3 1/3] mtd: bcm47xxsflash: keep a reference to the BCMA
  2013-03-06 11:01 [PATCH V2 1/3] mtd: bcm47xxsflash: keep a reference to the BCMA Rafał Miłecki
                   ` (2 preceding siblings ...)
  2013-03-06 11:07 ` [PATCH V2 1/3] mtd: bcm47xxsflash: keep a reference to the BCMA Artem Bityutskiy
@ 2013-03-06 11:33 ` Rafał Miłecki
  2013-03-13 10:58 ` [PATCH V2 " Artem Bityutskiy
  4 siblings, 0 replies; 11+ messages in thread
From: Rafał Miłecki @ 2013-03-06 11:33 UTC (permalink / raw)
  To: linux-mtd, Artem Bityutskiy, David Woodhouse
  Cc: Hauke Mehrtens, 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 <zajec5@gmail.com>
---
V3: don't use "union" for now
---
 drivers/mtd/devices/bcm47xxsflash.c |    2 ++
 drivers/mtd/devices/bcm47xxsflash.h |    4 ++++
 2 files changed, 6 insertions(+)

diff --git a/drivers/mtd/devices/bcm47xxsflash.c b/drivers/mtd/devices/bcm47xxsflash.c
index 9526628..b22df6d 100644
--- a/drivers/mtd/devices/bcm47xxsflash.c
+++ b/drivers/mtd/devices/bcm47xxsflash.c
@@ -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;
diff --git a/drivers/mtd/devices/bcm47xxsflash.h b/drivers/mtd/devices/bcm47xxsflash.h
index ebf6f71..e37285e 100644
--- a/drivers/mtd/devices/bcm47xxsflash.h
+++ b/drivers/mtd/devices/bcm47xxsflash.h
@@ -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;
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH V3 2/3] mtd: bcm47xxsflash: store info about flash type
  2013-03-06 11:01 ` [PATCH V2 2/3] mtd: bcm47xxsflash: store info about flash type Rafał Miłecki
@ 2013-03-06 11:34   ` Rafał Miłecki
  0 siblings, 0 replies; 11+ messages in thread
From: Rafał Miłecki @ 2013-03-06 11:34 UTC (permalink / raw)
  To: linux-mtd, Artem Bityutskiy, David Woodhouse
  Cc: Hauke Mehrtens, Rafał Miłecki

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

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
---
V3: rebase after change in 0001
---
 drivers/mtd/devices/bcm47xxsflash.c |    9 +++++++++
 drivers/mtd/devices/bcm47xxsflash.h |    7 +++++++
 2 files changed, 16 insertions(+)

diff --git a/drivers/mtd/devices/bcm47xxsflash.c b/drivers/mtd/devices/bcm47xxsflash.c
index b22df6d..2f9e629 100644
--- a/drivers/mtd/devices/bcm47xxsflash.c
+++ b/drivers/mtd/devices/bcm47xxsflash.c
@@ -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;
diff --git a/drivers/mtd/devices/bcm47xxsflash.h b/drivers/mtd/devices/bcm47xxsflash.h
index e37285e..4498529 100644
--- a/drivers/mtd/devices/bcm47xxsflash.h
+++ b/drivers/mtd/devices/bcm47xxsflash.h
@@ -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;
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH V2 1/3] mtd: bcm47xxsflash: keep a reference to the BCMA
  2013-03-06 11:01 [PATCH V2 1/3] mtd: bcm47xxsflash: keep a reference to the BCMA Rafał Miłecki
                   ` (3 preceding siblings ...)
  2013-03-06 11:33 ` [PATCH V3 " Rafał Miłecki
@ 2013-03-13 10:58 ` Artem Bityutskiy
  2013-03-13 11:04   ` Rafał Miłecki
  4 siblings, 1 reply; 11+ messages in thread
From: Artem Bityutskiy @ 2013-03-13 10:58 UTC (permalink / raw)
  To: Rafał Miłecki; +Cc: Hauke Mehrtens, linux-mtd, David Woodhouse

On Wed, 2013-03-06 at 12:01 +0100, Rafał Miłecki wrote:
> 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 <zajec5@gmail.com>

Pushed the 3 to l2-mtd.git, thanks!

-- 
Best Regards,
Artem Bityutskiy

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH V2 1/3] mtd: bcm47xxsflash: keep a reference to the BCMA
  2013-03-13 10:58 ` [PATCH V2 " Artem Bityutskiy
@ 2013-03-13 11:04   ` Rafał Miłecki
  0 siblings, 0 replies; 11+ messages in thread
From: Rafał Miłecki @ 2013-03-13 11:04 UTC (permalink / raw)
  To: dedekind1; +Cc: Hauke Mehrtens, linux-mtd, David Woodhouse

2013/3/13 Artem Bityutskiy <dedekind1@gmail.com>:
> On Wed, 2013-03-06 at 12:01 +0100, Rafał Miłecki wrote:
>> 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 <zajec5@gmail.com>
>
> Pushed the 3 to l2-mtd.git, thanks!

Thank you for your help on getting this cleaned :)

-- 
Rafał

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2013-03-13 11:04 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-06 11:01 [PATCH V2 1/3] mtd: bcm47xxsflash: keep a reference to the BCMA Rafał Miłecki
2013-03-06 11:01 ` [PATCH V2 2/3] mtd: bcm47xxsflash: store info about flash type Rafał Miłecki
2013-03-06 11:34   ` [PATCH V3 " Rafał Miłecki
2013-03-06 11:01 ` [PATCH 3/3] mtd: bcm47xxsflash: define opcodes Rafał Miłecki
2013-03-06 11:07 ` [PATCH V2 1/3] mtd: bcm47xxsflash: keep a reference to the BCMA Artem Bityutskiy
2013-03-06 11:08   ` Rafał Miłecki
2013-03-06 11:10     ` Rafał Miłecki
2013-03-06 11:13     ` Artem Bityutskiy
2013-03-06 11:33 ` [PATCH V3 " Rafał Miłecki
2013-03-13 10:58 ` [PATCH V2 " Artem Bityutskiy
2013-03-13 11:04   ` Rafał Miłecki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox