* [PATCH 0/6] mtd: bcm47xx: some fixes for the flash drivers
@ 2013-01-24 16:39 Hauke Mehrtens
2013-01-24 16:39 ` [PATCH 1/6] mtd: bcm47xxsflash: write number of written bytes Hauke Mehrtens
` (6 more replies)
0 siblings, 7 replies; 10+ messages in thread
From: Hauke Mehrtens @ 2013-01-24 16:39 UTC (permalink / raw)
To: dwmw2; +Cc: Hauke Mehrtens, zajec5, linux-mtd
These patches are fixing some problems which I saw in my tests with
some devices and these flash drivers.
Hauke Mehrtens (6):
mtd: bcm47xxsflash: write number of written bytes
mtd: bcm47xxsflash: register this as normal driver
mtd: bcm47xxnflash: fix message
mtd: bcm47xxnflash: register this as normal driver
mtd: bcm47xxpart: add support for other erase sizes
mtd: bcm47xxpart: improve probing of nvram partition
drivers/mtd/bcm47xxpart.c | 27 +++++++++++++++++----------
drivers/mtd/devices/bcm47xxsflash.c | 4 +++-
drivers/mtd/nand/bcm47xxnflash/main.c | 9 +++------
3 files changed, 23 insertions(+), 17 deletions(-)
--
1.7.10.4
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/6] mtd: bcm47xxsflash: write number of written bytes
2013-01-24 16:39 [PATCH 0/6] mtd: bcm47xx: some fixes for the flash drivers Hauke Mehrtens
@ 2013-01-24 16:39 ` Hauke Mehrtens
2013-01-24 16:39 ` [PATCH 2/6] mtd: bcm47xxsflash: register this as normal driver Hauke Mehrtens
` (5 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Hauke Mehrtens @ 2013-01-24 16:39 UTC (permalink / raw)
To: dwmw2; +Cc: Hauke Mehrtens, zajec5, linux-mtd
The callback assumes the number of read bytes is written to retlen.
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
drivers/mtd/devices/bcm47xxsflash.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/mtd/devices/bcm47xxsflash.c b/drivers/mtd/devices/bcm47xxsflash.c
index 8fe1a09..61a45cb 100644
--- a/drivers/mtd/devices/bcm47xxsflash.c
+++ b/drivers/mtd/devices/bcm47xxsflash.c
@@ -23,6 +23,7 @@ static int bcm47xxsflash_read(struct mtd_info *mtd, loff_t from, size_t len,
memcpy_fromio(buf, (void __iomem *)KSEG0ADDR(b47s->window + from),
len);
+ *retlen = len;
return len;
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/6] mtd: bcm47xxsflash: register this as normal driver
2013-01-24 16:39 [PATCH 0/6] mtd: bcm47xx: some fixes for the flash drivers Hauke Mehrtens
2013-01-24 16:39 ` [PATCH 1/6] mtd: bcm47xxsflash: write number of written bytes Hauke Mehrtens
@ 2013-01-24 16:39 ` Hauke Mehrtens
2013-01-24 16:39 ` [PATCH 3/6] mtd: bcm47xxnflash: fix message Hauke Mehrtens
` (4 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Hauke Mehrtens @ 2013-01-24 16:39 UTC (permalink / raw)
To: dwmw2; +Cc: Hauke Mehrtens, zajec5, linux-mtd
When platform_driver_probe() is used and no device is registered for
this driver -ENODEV is returned and and error message is shown. Not all
BCM47xx SoC have a serial flash chip controller and chip and for them
an error message was shown.
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
drivers/mtd/devices/bcm47xxsflash.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/mtd/devices/bcm47xxsflash.c b/drivers/mtd/devices/bcm47xxsflash.c
index 61a45cb..729ca5f 100644
--- a/drivers/mtd/devices/bcm47xxsflash.c
+++ b/drivers/mtd/devices/bcm47xxsflash.c
@@ -89,6 +89,7 @@ static int bcm47xxsflash_remove(struct platform_device *pdev)
}
static struct platform_driver bcma_sflash_driver = {
+ .probe = bcm47xxsflash_probe,
.remove = bcm47xxsflash_remove,
.driver = {
.name = "bcma_sflash",
@@ -100,7 +101,7 @@ static int __init bcm47xxsflash_init(void)
{
int err;
- err = platform_driver_probe(&bcma_sflash_driver, bcm47xxsflash_probe);
+ err = platform_driver_register(&bcma_sflash_driver);
if (err)
pr_err("Failed to register BCMA serial flash driver: %d\n",
err);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/6] mtd: bcm47xxnflash: fix message
2013-01-24 16:39 [PATCH 0/6] mtd: bcm47xx: some fixes for the flash drivers Hauke Mehrtens
2013-01-24 16:39 ` [PATCH 1/6] mtd: bcm47xxsflash: write number of written bytes Hauke Mehrtens
2013-01-24 16:39 ` [PATCH 2/6] mtd: bcm47xxsflash: register this as normal driver Hauke Mehrtens
@ 2013-01-24 16:39 ` Hauke Mehrtens
2013-01-25 12:21 ` Rafał Miłecki
2013-01-24 16:39 ` [PATCH 4/6] mtd: bcm47xxnflash: register this as normal driver Hauke Mehrtens
` (3 subsequent siblings)
6 siblings, 1 reply; 10+ messages in thread
From: Hauke Mehrtens @ 2013-01-24 16:39 UTC (permalink / raw)
To: dwmw2; +Cc: Hauke Mehrtens, zajec5, linux-mtd
This is not a serial flash driver, but a nand flash driver
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
drivers/mtd/nand/bcm47xxnflash/main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mtd/nand/bcm47xxnflash/main.c b/drivers/mtd/nand/bcm47xxnflash/main.c
index 8363a9a..616b56a 100644
--- a/drivers/mtd/nand/bcm47xxnflash/main.c
+++ b/drivers/mtd/nand/bcm47xxnflash/main.c
@@ -94,7 +94,7 @@ static int __init bcm47xxnflash_init(void)
*/
err = platform_driver_probe(&bcm47xxnflash_driver, bcm47xxnflash_probe);
if (err)
- pr_err("Failed to register serial flash driver: %d\n", err);
+ pr_err("Failed to register bcm47xx nand flash driver: %d\n", err);
return err;
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 4/6] mtd: bcm47xxnflash: register this as normal driver
2013-01-24 16:39 [PATCH 0/6] mtd: bcm47xx: some fixes for the flash drivers Hauke Mehrtens
` (2 preceding siblings ...)
2013-01-24 16:39 ` [PATCH 3/6] mtd: bcm47xxnflash: fix message Hauke Mehrtens
@ 2013-01-24 16:39 ` Hauke Mehrtens
2013-01-24 16:39 ` [PATCH 5/6] mtd: bcm47xxpart: add support for other erase sizes Hauke Mehrtens
` (2 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Hauke Mehrtens @ 2013-01-24 16:39 UTC (permalink / raw)
To: dwmw2; +Cc: Hauke Mehrtens, zajec5, linux-mtd
When platform_driver_probe() is used and no device is registered for
this driver -ENODEV is returned and and error message is shown. Not all
BCM47xx SoC have a nand flash chip controller and chip and for them an
error message was shown.
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
drivers/mtd/nand/bcm47xxnflash/main.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/mtd/nand/bcm47xxnflash/main.c b/drivers/mtd/nand/bcm47xxnflash/main.c
index 616b56a..f674979 100644
--- a/drivers/mtd/nand/bcm47xxnflash/main.c
+++ b/drivers/mtd/nand/bcm47xxnflash/main.c
@@ -77,6 +77,7 @@ static int bcm47xxnflash_remove(struct platform_device *pdev)
}
static struct platform_driver bcm47xxnflash_driver = {
+ .probe = bcm47xxnflash_probe,
.remove = bcm47xxnflash_remove,
.driver = {
.name = "bcma_nflash",
@@ -88,11 +89,7 @@ static int __init bcm47xxnflash_init(void)
{
int err;
- /*
- * Platform device "bcma_nflash" exists on SoCs and is registered very
- * early, it won't be added during runtime (use platform_driver_probe).
- */
- err = platform_driver_probe(&bcm47xxnflash_driver, bcm47xxnflash_probe);
+ err = platform_driver_register(&bcm47xxnflash_driver);
if (err)
pr_err("Failed to register bcm47xx nand flash driver: %d\n", err);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 5/6] mtd: bcm47xxpart: add support for other erase sizes
2013-01-24 16:39 [PATCH 0/6] mtd: bcm47xx: some fixes for the flash drivers Hauke Mehrtens
` (3 preceding siblings ...)
2013-01-24 16:39 ` [PATCH 4/6] mtd: bcm47xxnflash: register this as normal driver Hauke Mehrtens
@ 2013-01-24 16:39 ` Hauke Mehrtens
2013-01-24 16:39 ` [PATCH 6/6] mtd: bcm47xxpart: improve probing of nvram partition Hauke Mehrtens
2013-02-04 8:32 ` [PATCH 0/6] mtd: bcm47xx: some fixes for the flash drivers Artem Bityutskiy
6 siblings, 0 replies; 10+ messages in thread
From: Hauke Mehrtens @ 2013-01-24 16:39 UTC (permalink / raw)
To: dwmw2; +Cc: Hauke Mehrtens, zajec5, linux-mtd
To make the partitions writable they should aligned to erase sizes of
the flash. If the erase size is small use 0x10000.
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
drivers/mtd/bcm47xxpart.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/mtd/bcm47xxpart.c b/drivers/mtd/bcm47xxpart.c
index 3411bc2..986ab6e 100644
--- a/drivers/mtd/bcm47xxpart.c
+++ b/drivers/mtd/bcm47xxpart.c
@@ -59,11 +59,14 @@ static int bcm47xxpart_parse(struct mtd_info *master,
uint32_t *buf;
size_t bytes_read;
uint32_t offset;
- uint32_t blocksize = 0x10000;
+ uint32_t blocksize = master->erasesize;
struct trx_header *trx;
int trx_part = -1;
int last_trx_part = -1;
+ if (blocksize <= 0x10000)
+ blocksize = 0x10000;
+
/* Alloc */
parts = kzalloc(sizeof(struct mtd_partition) * BCM47XXPART_MAX_PARTS,
GFP_KERNEL);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 6/6] mtd: bcm47xxpart: improve probing of nvram partition
2013-01-24 16:39 [PATCH 0/6] mtd: bcm47xx: some fixes for the flash drivers Hauke Mehrtens
` (4 preceding siblings ...)
2013-01-24 16:39 ` [PATCH 5/6] mtd: bcm47xxpart: add support for other erase sizes Hauke Mehrtens
@ 2013-01-24 16:39 ` Hauke Mehrtens
2013-01-24 18:03 ` [PATCH v2 " Hauke Mehrtens
2013-02-04 8:32 ` [PATCH 0/6] mtd: bcm47xx: some fixes for the flash drivers Artem Bityutskiy
6 siblings, 1 reply; 10+ messages in thread
From: Hauke Mehrtens @ 2013-01-24 16:39 UTC (permalink / raw)
To: dwmw2; +Cc: Hauke Mehrtens, zajec5, linux-mtd
The nvram in the nvram partition does not start at the beginning of the
partition on every device. Sometimes they are stating in the middle of
a partition or the first 0x1000 bytes are free.
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
drivers/mtd/bcm47xxpart.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/drivers/mtd/bcm47xxpart.c b/drivers/mtd/bcm47xxpart.c
index 986ab6e..e2f3c8f 100644
--- a/drivers/mtd/bcm47xxpart.c
+++ b/drivers/mtd/bcm47xxpart.c
@@ -19,12 +19,6 @@
/* 10 parts were found on sflash on Netgear WNDR4500 */
#define BCM47XXPART_MAX_PARTS 12
-/*
- * Amount of bytes we read when analyzing each block of flash memory.
- * Set it big enough to allow detecting partition and reading important data.
- */
-#define BCM47XXPART_BYTES_TO_READ 0x404
-
/* Magics */
#define BOARD_DATA_MAGIC 0x5246504D /* MPFR */
#define POT_MAGIC1 0x54544f50 /* POTT */
@@ -63,14 +57,17 @@ static int bcm47xxpart_parse(struct mtd_info *master,
struct trx_header *trx;
int trx_part = -1;
int last_trx_part = -1;
+ int max_bytes_to_read = 8004;
if (blocksize <= 0x10000)
blocksize = 0x10000;
+ if (blocksize == 0x20000)
+ max_bytes_to_read = 0x18004;
/* Alloc */
parts = kzalloc(sizeof(struct mtd_partition) * BCM47XXPART_MAX_PARTS,
GFP_KERNEL);
- buf = kzalloc(BCM47XXPART_BYTES_TO_READ, GFP_KERNEL);
+ buf = kzalloc(max_bytes_to_read, GFP_KERNEL);
/* Parse block by block looking for magics */
for (offset = 0; offset <= master->size - blocksize;
@@ -85,7 +82,7 @@ static int bcm47xxpart_parse(struct mtd_info *master,
}
/* Read beginning of the block */
- if (mtd_read(master, offset, BCM47XXPART_BYTES_TO_READ,
+ if (mtd_read(master, offset, max_bytes_to_read,
&bytes_read, (uint8_t *)buf) < 0) {
pr_err("mtd_read error while parsing (offset: 0x%X)!\n",
offset);
@@ -100,9 +97,16 @@ static int bcm47xxpart_parse(struct mtd_info *master,
}
/* Standard NVRAM */
- if (buf[0x000 / 4] == NVRAM_HEADER) {
+ if (buf[0x000 / 4] == NVRAM_HEADER ||
+ buf[0x1000 / 4] == NVRAM_HEADER ||
+ buf[0x8000 / 4] == NVRAM_HEADER ||
+ (blocksize == 0x20000 && (
+ buf[0x10000 / 4] == NVRAM_HEADER ||
+ buf[0x11000 / 4] == NVRAM_HEADER ||
+ buf[0x18000 / 4] == NVRAM_HEADER))) {
bcm47xxpart_add_part(&parts[curr_part++], "nvram",
offset, 0);
+ offset = rounddown(offset, blocksize);
continue;
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 6/6] mtd: bcm47xxpart: improve probing of nvram partition
2013-01-24 16:39 ` [PATCH 6/6] mtd: bcm47xxpart: improve probing of nvram partition Hauke Mehrtens
@ 2013-01-24 18:03 ` Hauke Mehrtens
0 siblings, 0 replies; 10+ messages in thread
From: Hauke Mehrtens @ 2013-01-24 18:03 UTC (permalink / raw)
To: dwmw2; +Cc: Hauke Mehrtens, zajec5, linux-mtd
The nvram in the nvram partition does not start at the beginning of the
partition on every device. Sometimes they are stating in the middle of
a partition or the first 0x1000 bytes are free.
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
v2:
* 0x8004 assigned to max_bytes_to_read should be a hex value.
drivers/mtd/bcm47xxpart.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/drivers/mtd/bcm47xxpart.c b/drivers/mtd/bcm47xxpart.c
index 986ab6e..9bcec8f 100644
--- a/drivers/mtd/bcm47xxpart.c
+++ b/drivers/mtd/bcm47xxpart.c
@@ -19,12 +19,6 @@
/* 10 parts were found on sflash on Netgear WNDR4500 */
#define BCM47XXPART_MAX_PARTS 12
-/*
- * Amount of bytes we read when analyzing each block of flash memory.
- * Set it big enough to allow detecting partition and reading important data.
- */
-#define BCM47XXPART_BYTES_TO_READ 0x404
-
/* Magics */
#define BOARD_DATA_MAGIC 0x5246504D /* MPFR */
#define POT_MAGIC1 0x54544f50 /* POTT */
@@ -63,14 +57,17 @@ static int bcm47xxpart_parse(struct mtd_info *master,
struct trx_header *trx;
int trx_part = -1;
int last_trx_part = -1;
+ int max_bytes_to_read = 0x8004;
if (blocksize <= 0x10000)
blocksize = 0x10000;
+ if (blocksize == 0x20000)
+ max_bytes_to_read = 0x18004;
/* Alloc */
parts = kzalloc(sizeof(struct mtd_partition) * BCM47XXPART_MAX_PARTS,
GFP_KERNEL);
- buf = kzalloc(BCM47XXPART_BYTES_TO_READ, GFP_KERNEL);
+ buf = kzalloc(max_bytes_to_read, GFP_KERNEL);
/* Parse block by block looking for magics */
for (offset = 0; offset <= master->size - blocksize;
@@ -85,7 +82,7 @@ static int bcm47xxpart_parse(struct mtd_info *master,
}
/* Read beginning of the block */
- if (mtd_read(master, offset, BCM47XXPART_BYTES_TO_READ,
+ if (mtd_read(master, offset, max_bytes_to_read,
&bytes_read, (uint8_t *)buf) < 0) {
pr_err("mtd_read error while parsing (offset: 0x%X)!\n",
offset);
@@ -100,9 +97,16 @@ static int bcm47xxpart_parse(struct mtd_info *master,
}
/* Standard NVRAM */
- if (buf[0x000 / 4] == NVRAM_HEADER) {
+ if (buf[0x000 / 4] == NVRAM_HEADER ||
+ buf[0x1000 / 4] == NVRAM_HEADER ||
+ buf[0x8000 / 4] == NVRAM_HEADER ||
+ (blocksize == 0x20000 && (
+ buf[0x10000 / 4] == NVRAM_HEADER ||
+ buf[0x11000 / 4] == NVRAM_HEADER ||
+ buf[0x18000 / 4] == NVRAM_HEADER))) {
bcm47xxpart_add_part(&parts[curr_part++], "nvram",
offset, 0);
+ offset = rounddown(offset, blocksize);
continue;
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 3/6] mtd: bcm47xxnflash: fix message
2013-01-24 16:39 ` [PATCH 3/6] mtd: bcm47xxnflash: fix message Hauke Mehrtens
@ 2013-01-25 12:21 ` Rafał Miłecki
0 siblings, 0 replies; 10+ messages in thread
From: Rafał Miłecki @ 2013-01-25 12:21 UTC (permalink / raw)
To: Hauke Mehrtens; +Cc: linux-mtd, dwmw2
2013/1/24 Hauke Mehrtens <hauke@hauke-m.de>:
> This is not a serial flash driver, but a nand flash driver
>
> Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
> ---
> drivers/mtd/nand/bcm47xxnflash/main.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mtd/nand/bcm47xxnflash/main.c b/drivers/mtd/nand/bcm47xxnflash/main.c
> index 8363a9a..616b56a 100644
> --- a/drivers/mtd/nand/bcm47xxnflash/main.c
> +++ b/drivers/mtd/nand/bcm47xxnflash/main.c
> @@ -94,7 +94,7 @@ static int __init bcm47xxnflash_init(void)
> */
> err = platform_driver_probe(&bcm47xxnflash_driver, bcm47xxnflash_probe);
> if (err)
> - pr_err("Failed to register serial flash driver: %d\n", err);
> + pr_err("Failed to register bcm47xx nand flash driver: %d\n", err);
WARNING:LONG_LINE: line over 80 characters
--
Rafał
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/6] mtd: bcm47xx: some fixes for the flash drivers
2013-01-24 16:39 [PATCH 0/6] mtd: bcm47xx: some fixes for the flash drivers Hauke Mehrtens
` (5 preceding siblings ...)
2013-01-24 16:39 ` [PATCH 6/6] mtd: bcm47xxpart: improve probing of nvram partition Hauke Mehrtens
@ 2013-02-04 8:32 ` Artem Bityutskiy
6 siblings, 0 replies; 10+ messages in thread
From: Artem Bityutskiy @ 2013-02-04 8:32 UTC (permalink / raw)
To: Hauke Mehrtens; +Cc: linux-mtd, zajec5, dwmw2
[-- Attachment #1: Type: text/plain, Size: 244 bytes --]
On Thu, 2013-01-24 at 17:39 +0100, Hauke Mehrtens wrote:
> These patches are fixing some problems which I saw in my tests with
> some devices and these flash drivers.
Pushed to l2-mtd.git, thanks!
--
Best Regards,
Artem Bityutskiy
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2013-02-04 8:30 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-24 16:39 [PATCH 0/6] mtd: bcm47xx: some fixes for the flash drivers Hauke Mehrtens
2013-01-24 16:39 ` [PATCH 1/6] mtd: bcm47xxsflash: write number of written bytes Hauke Mehrtens
2013-01-24 16:39 ` [PATCH 2/6] mtd: bcm47xxsflash: register this as normal driver Hauke Mehrtens
2013-01-24 16:39 ` [PATCH 3/6] mtd: bcm47xxnflash: fix message Hauke Mehrtens
2013-01-25 12:21 ` Rafał Miłecki
2013-01-24 16:39 ` [PATCH 4/6] mtd: bcm47xxnflash: register this as normal driver Hauke Mehrtens
2013-01-24 16:39 ` [PATCH 5/6] mtd: bcm47xxpart: add support for other erase sizes Hauke Mehrtens
2013-01-24 16:39 ` [PATCH 6/6] mtd: bcm47xxpart: improve probing of nvram partition Hauke Mehrtens
2013-01-24 18:03 ` [PATCH v2 " Hauke Mehrtens
2013-02-04 8:32 ` [PATCH 0/6] mtd: bcm47xx: some fixes for the flash drivers Artem Bityutskiy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox