[U-Boot] [PATCH] sf: Macronix additional chips supported

new chips supported:- MX25L1605D, MX25L3205D, MX25L6405D, MX25L12855E out of which MX25L6405D and MX25L12855E tested on Kirkwood platforms
Modified the Macronix flash support to use 2 bytes of device id instead of 1 This was required to support MX25L12855E
Contributor: Piyush Shah spiyush@marvell.com
Signed-off-by: Prafulla Wadaskar prafulla@marvell.com --- drivers/mtd/spi/macronix.c | 63 ++++++++++++++++++++++++++++++++++++------- 1 files changed, 52 insertions(+), 11 deletions(-)
diff --git a/drivers/mtd/spi/macronix.c b/drivers/mtd/spi/macronix.c index 9464c84..e6f87fb 100644 --- a/drivers/mtd/spi/macronix.c +++ b/drivers/mtd/spi/macronix.c @@ -49,17 +49,21 @@ #define CMD_MX25XX_DP 0xb9 /* Deep Power-down */ #define CMD_MX25XX_RES 0xab /* Release from DP, and Read Signature */
-#define MXIC_ID_MX2516 0x15 -#define MXIC_ID_MX2520 0x12 -#define MXIC_ID_MX2532 0x16 -#define MXIC_ID_MX2540 0x13 -#define MXIC_ID_MX2564 0x17 -#define MXIC_ID_MX2580 0x14 -#define MXIC_ID_MX25128 0x18 - +#define MXIC_ID_MD_MX251605D 0x15 /* MD : Memory Density */ +#define MXIC_ID_MT_MX251605D 0x20 /* MT : Memory Type */ +#define MXIC_ID_MD_MX253205D 0x16 /* MD : Memory Density */ +#define MXIC_ID_MT_MX253205D 0x20 /* MT : Memory Type */ +#define MXIC_ID_MD_MX256405D 0x17 /* MD : Memory Density */ +#define MXIC_ID_MT_MX256405D 0x20 /* MT : Memory Type */ +#define MXIC_ID_MD_MX2512805D 0x18 /* MD : Memory Density */ +#define MXIC_ID_MT_MX2512805D 0x20 /* MT : Memory Type */ +#define MXIC_ID_MD_MX2512855E 0x18 /* MD : Memory Density */ +#define MXIC_ID_MT_MX2512855E 0x26 /* MT : Memory Type */ + #define MACRONIX_SR_WIP (1 << 0) /* Write-in-Progress */
struct macronix_spi_flash_params { + u8 idcode0; u8 idcode1; u16 page_size; u16 pages_per_sector; @@ -81,13 +85,50 @@ static inline struct macronix_spi_flash *to_macronix_spi_flash(struct spi_flash
static const struct macronix_spi_flash_params macronix_spi_flash_table[] = { { - .idcode1 = MXIC_ID_MX25128, + .idcode0 = MXIC_ID_MT_MX251605D, + .idcode1 = MXIC_ID_MD_MX251605D, + .page_size = 256, + .pages_per_sector = 16, + .sectors_per_block = 16, + .nr_blocks = 32, + .name = "MX25L1605D", + }, + { + .idcode0 = MXIC_ID_MT_MX253205D, + .idcode1 = MXIC_ID_MD_MX253205D, + .page_size = 256, + .pages_per_sector = 16, + .sectors_per_block = 16, + .nr_blocks = 64, + .name = "MX25L3205D", + }, + { + .idcode0 = MXIC_ID_MT_MX256405D, + .idcode1 = MXIC_ID_MD_MX256405D, + .page_size = 256, + .pages_per_sector = 16, + .sectors_per_block = 16, + .nr_blocks = 128, + .name = "MX25L6405D", + }, + { + .idcode0 = MXIC_ID_MT_MX2512805, + .idcode1 = MXIC_ID_MD_MX2512805, .page_size = 256, .pages_per_sector = 16, .sectors_per_block = 16, .nr_blocks = 256, .name = "MX25L12805D", }, + { + .idcode0 = MXIC_ID_MT_MX2512855E, + .idcode1 = MXIC_ID_MD_MX2512855E, + .page_size = 256, + .pages_per_sector = 16, + .sectors_per_block = 16, + .nr_blocks = 256, + .name = "MX25L12855E", + }, };
static int macronix_wait_ready(struct spi_flash *flash, unsigned long timeout) @@ -280,12 +321,12 @@ struct spi_flash *spi_flash_probe_macronix(struct spi_slave *spi, u8 *idcode)
for (i = 0; i < ARRAY_SIZE(macronix_spi_flash_table); i++) { params = ¯onix_spi_flash_table[i]; - if (params->idcode1 == idcode[2]) + if (params->idcode1 == idcode[2] && params->idcode0 == idcode[1]) break; }
if (i == ARRAY_SIZE(macronix_spi_flash_table)) { - debug("SF: Unsupported Macronix ID %02x\n", idcode[1]); + debug("SF: Unsupported Macronix ID %02x%02x\n", idcode[1],idcode[2]); return NULL; }

-----Original Message----- From: Prafulla Wadaskar [mailto:prafulla@marvell.com] Sent: Wednesday, July 01, 2009 9:46 PM To: u-boot@lists.denx.de Cc: Nicolas Pitre; Manas Saksena; Lennert Buijtenhek; Prabhanjan Sarnaik; Ronen Shitrit; Ashish Karkare; Prafulla Wadaskar Subject: [PATCH] sf: Macronix additional chips supported
new chips supported:- MX25L1605D, MX25L3205D, MX25L6405D, MX25L12855E out of which MX25L6405D and MX25L12855E tested on Kirkwood platforms
Hi Mike, Just FYI
Regards.. Prafulla . .

new chips supported:- MX25L1605D, MX25L3205D, MX25L6405D, MX25L12855E out of which MX25L6405D and MX25L12855E tested on Kirkwood platforms
Modified the Macronix flash support to use 2 bytes of device id instead of 1 This was required to support MX25L12855E
Contributor: Piyush Shah spiyush@marvell.com
Signed-off-by: Prafulla Wadaskar prafulla@marvell.com --- Change log:- v2: white space removed for clean patch apply build error fixed tested for new added chip MX25L6405D
drivers/mtd/spi/macronix.c | 61 ++++++++++++++++++++++++++++++++++++------- 1 files changed, 51 insertions(+), 10 deletions(-)
diff --git a/drivers/mtd/spi/macronix.c b/drivers/mtd/spi/macronix.c index 9464c84..d165277 100644 --- a/drivers/mtd/spi/macronix.c +++ b/drivers/mtd/spi/macronix.c @@ -49,17 +49,21 @@ #define CMD_MX25XX_DP 0xb9 /* Deep Power-down */ #define CMD_MX25XX_RES 0xab /* Release from DP, and Read Signature */
-#define MXIC_ID_MX2516 0x15 -#define MXIC_ID_MX2520 0x12 -#define MXIC_ID_MX2532 0x16 -#define MXIC_ID_MX2540 0x13 -#define MXIC_ID_MX2564 0x17 -#define MXIC_ID_MX2580 0x14 -#define MXIC_ID_MX25128 0x18 +#define MXIC_ID_MD_MX251605D 0x15 /* MD : Memory Density */ +#define MXIC_ID_MT_MX251605D 0x20 /* MT : Memory Type */ +#define MXIC_ID_MD_MX253205D 0x16 /* MD : Memory Density */ +#define MXIC_ID_MT_MX253205D 0x20 /* MT : Memory Type */ +#define MXIC_ID_MD_MX256405D 0x17 /* MD : Memory Density */ +#define MXIC_ID_MT_MX256405D 0x20 /* MT : Memory Type */ +#define MXIC_ID_MD_MX2512805D 0x18 /* MD : Memory Density */ +#define MXIC_ID_MT_MX2512805D 0x20 /* MT : Memory Type */ +#define MXIC_ID_MD_MX2512855E 0x18 /* MD : Memory Density */ +#define MXIC_ID_MT_MX2512855E 0x26 /* MT : Memory Type */
#define MACRONIX_SR_WIP (1 << 0) /* Write-in-Progress */
struct macronix_spi_flash_params { + u8 idcode0; u8 idcode1; u16 page_size; u16 pages_per_sector; @@ -81,13 +85,50 @@ static inline struct macronix_spi_flash *to_macronix_spi_flash(struct spi_flash
static const struct macronix_spi_flash_params macronix_spi_flash_table[] = { { - .idcode1 = MXIC_ID_MX25128, + .idcode0 = MXIC_ID_MT_MX251605D, + .idcode1 = MXIC_ID_MD_MX251605D, + .page_size = 256, + .pages_per_sector = 16, + .sectors_per_block = 16, + .nr_blocks = 32, + .name = "MX25L1605D", + }, + { + .idcode0 = MXIC_ID_MT_MX253205D, + .idcode1 = MXIC_ID_MD_MX253205D, + .page_size = 256, + .pages_per_sector = 16, + .sectors_per_block = 16, + .nr_blocks = 64, + .name = "MX25L3205D", + }, + { + .idcode0 = MXIC_ID_MT_MX256405D, + .idcode1 = MXIC_ID_MD_MX256405D, + .page_size = 256, + .pages_per_sector = 16, + .sectors_per_block = 16, + .nr_blocks = 128, + .name = "MX25L6405D", + }, + { + .idcode0 = MXIC_ID_MT_MX2512805D, + .idcode1 = MXIC_ID_MD_MX2512805D, .page_size = 256, .pages_per_sector = 16, .sectors_per_block = 16, .nr_blocks = 256, .name = "MX25L12805D", }, + { + .idcode0 = MXIC_ID_MT_MX2512855E, + .idcode1 = MXIC_ID_MD_MX2512855E, + .page_size = 256, + .pages_per_sector = 16, + .sectors_per_block = 16, + .nr_blocks = 256, + .name = "MX25L12855E", + }, };
static int macronix_wait_ready(struct spi_flash *flash, unsigned long timeout) @@ -280,12 +321,12 @@ struct spi_flash *spi_flash_probe_macronix(struct spi_slave *spi, u8 *idcode)
for (i = 0; i < ARRAY_SIZE(macronix_spi_flash_table); i++) { params = ¯onix_spi_flash_table[i]; - if (params->idcode1 == idcode[2]) + if (params->idcode1 == idcode[2] && params->idcode0 == idcode[1]) break; }
if (i == ARRAY_SIZE(macronix_spi_flash_table)) { - debug("SF: Unsupported Macronix ID %02x\n", idcode[1]); + debug("SF: Unsupported Macronix ID %02x%02x\n", idcode[1],idcode[2]); return NULL; }

On Friday 03 July 2009 13:28:01 Prafulla Wadaskar wrote:
new chips supported:- MX25L1605D, MX25L3205D, MX25L6405D, MX25L12855E out of which MX25L6405D and MX25L12855E tested on Kirkwood platforms
Modified the Macronix flash support to use 2 bytes of device id instead of 1 This was required to support MX25L12855E
Contributor: Piyush Shah spiyush@marvell.com
a contributor really should be a signed-off-by
--- a/drivers/mtd/spi/macronix.c +++ b/drivers/mtd/spi/macronix.c @@ -49,17 +49,21 @@ #define CMD_MX25XX_DP 0xb9 /* Deep Power-down */ #define CMD_MX25XX_RES 0xab /* Release from DP, and Read Signature */
-#define MXIC_ID_MX2516 0x15 -#define MXIC_ID_MX2520 0x12 -#define MXIC_ID_MX2532 0x16 -#define MXIC_ID_MX2540 0x13 -#define MXIC_ID_MX2564 0x17 -#define MXIC_ID_MX2580 0x14 -#define MXIC_ID_MX25128 0x18 +#define MXIC_ID_MD_MX251605D 0x15 /* MD : Memory Density */ +#define MXIC_ID_MT_MX251605D 0x20 /* MT : Memory Type */ +#define MXIC_ID_MD_MX253205D 0x16 /* MD : Memory Density */ +#define MXIC_ID_MT_MX253205D 0x20 /* MT : Memory Type */ +#define MXIC_ID_MD_MX256405D 0x17 /* MD : Memory Density */ +#define MXIC_ID_MT_MX256405D 0x20 /* MT : Memory Type */ +#define MXIC_ID_MD_MX2512805D 0x18 /* MD : Memory Density */ +#define MXIC_ID_MT_MX2512805D 0x20 /* MT : Memory Type */ +#define MXIC_ID_MD_MX2512855E 0x18 /* MD : Memory Density */ +#define MXIC_ID_MT_MX2512855E 0x26 /* MT : Memory Type */
#define MACRONIX_SR_WIP (1 << 0) /* Write-in-Progress */
struct macronix_spi_flash_params {
- u8 idcode0; u8 idcode1; u16 page_size; u16 pages_per_sector;
@@ -81,13 +85,50 @@ static inline struct macronix_spi_flash *to_macronix_spi_flash(struct spi_flash
static const struct macronix_spi_flash_params macronix_spi_flash_table[] = { {
.idcode1 = MXIC_ID_MX25128,
.idcode0 = MXIC_ID_MT_MX251605D,
.idcode1 = MXIC_ID_MD_MX251605D,
.page_size = 256,
.pages_per_sector = 16,
.sectors_per_block = 16,
.nr_blocks = 32,
.name = "MX25L1605D",
- },
- {
.idcode0 = MXIC_ID_MT_MX253205D,
.idcode1 = MXIC_ID_MD_MX253205D,
.page_size = 256,
.pages_per_sector = 16,
.sectors_per_block = 16,
.nr_blocks = 64,
.name = "MX25L3205D",
- },
- {
.idcode0 = MXIC_ID_MT_MX256405D,
.idcode1 = MXIC_ID_MD_MX256405D,
.page_size = 256,
.pages_per_sector = 16,
.sectors_per_block = 16,
.nr_blocks = 128,
.name = "MX25L6405D",
- },
- {
.idcode0 = MXIC_ID_MT_MX2512805D,
.page_size = 256, .pages_per_sector = 16, .sectors_per_block = 16, .nr_blocks = 256, .name = "MX25L12805D", },.idcode1 = MXIC_ID_MD_MX2512805D,
- {
.idcode0 = MXIC_ID_MT_MX2512855E,
.idcode1 = MXIC_ID_MD_MX2512855E,
.page_size = 256,
.pages_per_sector = 16,
.sectors_per_block = 16,
.nr_blocks = 256,
.name = "MX25L12855E",
- },
};
can you compare the code size to see if combining the id's in a u16 is better than comparing multiple u8's ?
and creating a dedicated list of defines for the id's isnt really necessary. using them inline in the structure itself is fine.
for (i = 0; i < ARRAY_SIZE(macronix_spi_flash_table); i++) { params = ¯onix_spi_flash_table[i];
if (params->idcode1 == idcode[2])
if (params->idcode1 == idcode[2] && params->idcode0 ==
idcode[1]) break; }
if (i == ARRAY_SIZE(macronix_spi_flash_table)) {
debug("SF: Unsupported Macronix ID %02x\n", idcode[1]);
debug("SF: Unsupported Macronix ID %02x%02x\n",
idcode[1],idcode[2]); return NULL; }
Change log:- v2: white space removed for clean patch apply build error fixed
looks like you broke whitespace in this version. you changed these if statements to use leading spaces, not tabs. -mike

-----Original Message----- From: Mike Frysinger [mailto:vapier@gentoo.org] Sent: Friday, July 03, 2009 11:31 PM To: u-boot@lists.denx.de Cc: Prafulla Wadaskar; Manas Saksena; Ronen Shitrit; Nicolas Pitre; Ashish Karkare; Prabhanjan Sarnaik; Lennert Buijtenhek Subject: Re: [U-Boot] [PATCH v2] sf: Macronix additional chips supported
On Friday 03 July 2009 13:28:01 Prafulla Wadaskar wrote:
new chips supported:- MX25L1605D, MX25L3205D, MX25L6405D, MX25L12855E out of which MX25L6405D and MX25L12855E tested on Kirkwood platforms
Modified the Macronix flash support to use 2 bytes of device id instead of 1 This was required to support MX25L12855E
Contributor: Piyush Shah spiyush@marvell.com
a contributor really should be a signed-off-by
I will correct this
<snip>
- {
.idcode0 = MXIC_ID_MT_MX2512855E,
.idcode1 = MXIC_ID_MD_MX2512855E,
.page_size = 256,
.pages_per_sector = 16,
.sectors_per_block = 16,
.nr_blocks = 256,
.name = "MX25L12855E",
- },
};
can you compare the code size to see if combining the id's in a u16 is better than comparing multiple u8's ?
At this moment we can save 28bytes with above suggestions, but Mx25L12805D and MX25L12855E have different memory types (0x20, 0x26 resp), and they have different protection algorithm features which I was trying to expose through "protect" command interface in my next patch, then we will need this abstraction. So I wish to keep this. What do you think?
and creating a dedicated list of defines for the id's isnt really necessary. using them inline in the structure itself is fine.
This is taken care...
Change log:- v2: white space removed for clean patch apply build error fixed
looks like you broke whitespace in this version. you changed these if statements to use leading spaces, not tabs.
:-)
Regards.. Prafulla . .

On Monday 06 July 2009 02:26:20 Prafulla Wadaskar wrote:
From: Mike Frysinger [mailto:vapier@gentoo.org]
On Friday 03 July 2009 13:28:01 Prafulla Wadaskar wrote:
- {
.idcode0 = MXIC_ID_MT_MX2512855E,
.idcode1 = MXIC_ID_MD_MX2512855E,
.page_size = 256,
.pages_per_sector = 16,
.sectors_per_block = 16,
.nr_blocks = 256,
.name = "MX25L12855E",
- },
};
can you compare the code size to see if combining the id's in a u16 is better than comparing multiple u8's ?
At this moment we can save 28bytes with above suggestions, but Mx25L12805D and MX25L12855E have different memory types (0x20, 0x26 resp), and they have different protection algorithm features which I was trying to expose through "protect" command interface in my next patch, then we will need this abstraction. So I wish to keep this. What do you think?
i was referring to also the .text differences, not just the .data. so with a u16, the structure would look like: {... .id = 0x1826, .name = "MX25L12855E", ...},{... .id = 0x1820, .name = "MX25L12805D", ...},
and the probe would look something like: u16 id = idcode[0] | (idcode[1] << 8); ... if (params->id == id) ...
i dont think this would prevent you from doing protection detection on the 0x18 family as you could create a new define: #define MX_PROT_FAMILY_FOO 0x18
and then in the probe code do: if (idcode[1] == MX_PROT_FAMILY_FOO)
i dont think the u8 -> u16 conversion would cause problems here would it ? -mike

new chips supported:- MX25L1605D, MX25L3205D, MX25L6405D, MX25L12855E out of which MX25L6405D and MX25L12855E tested on Kirkwood platforms
Modified the Macronix flash support to use 2 bytes of device id instead of 1 This was required to support MX25L12855E
Signed-off-by: Piyush Shah spiyush@marvell.com Signed-off-by: Prafulla Wadaskar prafulla@marvell.com --- Change log:- v2: leading spaces removed for clean patch apply build error fixed tested for new added chip MX25L6405D
v3: updated contributors info ids combined to u16 ids list of defines removed, used values in the struct
drivers/mtd/spi/macronix.c | 49 +++++++++++++++++++++++++++++++++---------- 1 files changed, 37 insertions(+), 12 deletions(-)
diff --git a/drivers/mtd/spi/macronix.c b/drivers/mtd/spi/macronix.c index 9464c84..1522eb1 100644 --- a/drivers/mtd/spi/macronix.c +++ b/drivers/mtd/spi/macronix.c @@ -49,18 +49,10 @@ #define CMD_MX25XX_DP 0xb9 /* Deep Power-down */ #define CMD_MX25XX_RES 0xab /* Release from DP, and Read Signature */
-#define MXIC_ID_MX2516 0x15 -#define MXIC_ID_MX2520 0x12 -#define MXIC_ID_MX2532 0x16 -#define MXIC_ID_MX2540 0x13 -#define MXIC_ID_MX2564 0x17 -#define MXIC_ID_MX2580 0x14 -#define MXIC_ID_MX25128 0x18 - #define MACRONIX_SR_WIP (1 << 0) /* Write-in-Progress */
struct macronix_spi_flash_params { - u8 idcode1; + u16 idcode; u16 page_size; u16 pages_per_sector; u16 sectors_per_block; @@ -81,13 +73,45 @@ static inline struct macronix_spi_flash *to_macronix_spi_flash(struct spi_flash
static const struct macronix_spi_flash_params macronix_spi_flash_table[] = { { - .idcode1 = MXIC_ID_MX25128, + .idcode = 0x2015, + .page_size = 256, + .pages_per_sector = 16, + .sectors_per_block = 16, + .nr_blocks = 32, + .name = "MX25L1605D", + }, + { + .idcode = 0x2016, + .page_size = 256, + .pages_per_sector = 16, + .sectors_per_block = 16, + .nr_blocks = 64, + .name = "MX25L3205D", + }, + { + .idcode = 0x2017, + .page_size = 256, + .pages_per_sector = 16, + .sectors_per_block = 16, + .nr_blocks = 128, + .name = "MX25L6405D", + }, + { + .idcode = 0x2018, .page_size = 256, .pages_per_sector = 16, .sectors_per_block = 16, .nr_blocks = 256, .name = "MX25L12805D", }, + { + .idcode = 0x2618, + .page_size = 256, + .pages_per_sector = 16, + .sectors_per_block = 16, + .nr_blocks = 256, + .name = "MX25L12855E", + }, };
static int macronix_wait_ready(struct spi_flash *flash, unsigned long timeout) @@ -277,15 +301,16 @@ struct spi_flash *spi_flash_probe_macronix(struct spi_slave *spi, u8 *idcode) const struct macronix_spi_flash_params *params; struct macronix_spi_flash *mcx; unsigned int i; + u16 id = (u16 *) *idcode;
for (i = 0; i < ARRAY_SIZE(macronix_spi_flash_table); i++) { params = ¯onix_spi_flash_table[i]; - if (params->idcode1 == idcode[2]) + if (params->idcode == id) break; }
if (i == ARRAY_SIZE(macronix_spi_flash_table)) { - debug("SF: Unsupported Macronix ID %02x\n", idcode[1]); + debug("SF: Unsupported Macronix ID %04x\n", id); return NULL; }

On Monday 06 July 2009 07:41:52 Prafulla Wadaskar wrote:
- u16 id = (u16 *) *idcode;
sorry, this wont fly on systems that cannot do unaligned accesses. i dont know the status of the get_unaligned() type macros in u-boot, but it'll probably be easier to just do: idcode[0] | idcode[1] << 8;
if (params->idcode1 == idcode[2])
if (params->idcode == id)
debug("SF: Unsupported Macronix ID %02x\n", idcode[1]);
debug("SF: Unsupported Macronix ID %04x\n", id);
you've still got busted whitespace here :/ -mike
participants (2)
-
Mike Frysinger
-
Prafulla Wadaskar