Skip to contentSkip to conversation

mtd: SPI Flash: Support the STMicro Flash

PATCH New Tsi-Chung Liew 3 participants 6 messages Aug 22, 2008 – Aug 28, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: SPI Flash: Support the STMicro Flash

From: TsiChung Liew <[email protected]>

Add MTD SPI Flash support for M25P16, M25P20, M25P32, M25P40, M25P64, M25P80, M25P128.

---
 drivers/mtd/spi/Makefile             |    1 +
 drivers/mtd/spi/spi_flash.c          |    5 +
 drivers/mtd/spi/spi_flash_internal.h |    1 +
 drivers/mtd/spi/stmicro.c            |  355 ++++++++++++++++++++++++++++++++++
 4 files changed, 362 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mtd/spi/stmicro.c
drivers/mtd/spi/Makefile +1 -0
index af6af97..3d4f892 100644
@@ -27,6 +27,7 @@ LIB	:= $(obj)libspi_flash.a
 
 COBJS-$(CONFIG_SPI_FLASH)	+= spi_flash.o
 COBJS-$(CONFIG_SPI_FLASH_ATMEL)	+= atmel.o
+COBJS-$(CONFIG_SPI_FLASH_STMICRO)	+= stmicro.o
 
 COBJS	:= $(COBJS-y)
 SRCS	:= $(COBJS:.o=.c)
drivers/mtd/spi/spi_flash.c +5 -0
index d581cb3..d1d81af 100644
@@ -134,6 +134,11 @@ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
 		flash = spi_flash_probe_atmel(spi, idcode);
 		break;
 #endif
+#ifdef CONFIG_SPI_FLASH_STMICRO
+	case 0x20:
+		flash = spi_flash_probe_stmicro(spi, idcode);
+		break;
+#endif
 	default:
 		debug("SF: Unsupported manufacturer %02X\n", idcode[0]);
 		flash = NULL;
drivers/mtd/spi/spi_flash_internal.h +1 -0
index 1438050..e5f758e 100644
@@ -43,3 +43,4 @@ int spi_flash_read_common(struct spi_flash *flash, const u8 *cmd,
 /* Manufacturer-specific probe functions */
 struct spi_flash *spi_flash_probe_spansion(struct spi_slave *spi, u8 *idcode);
 struct spi_flash *spi_flash_probe_atmel(struct spi_slave *spi, u8 *idcode);
+struct spi_flash *spi_flash_probe_stmicro(struct spi_slave *spi, u8 *idcode);
drivers/mtd/spi/stmicro.c new file +355 -0

355 lines not on this page · raw message

Signature · 1 line
1.5.6.4
#1 lore raw

PATCH 1/1 mtd: SPI Flash: Support the STMicro Flash

Quoted 7 lines · Tsi-Chung Liew

From: TsiChung Liew <[email protected]>

Add MTD SPI Flash support for M25P16, M25P20, M25P32, M25P40, M25P64, M25P80, M25P128.

Looks good to me, except...

Quoted 41 lines
drivers/mtd/spi/stmicro.c new file +41 -0
+static const struct stmicro_spi_flash_params stmicro_spi_flash_table[] = {
+	{
+	 .idcode1 = STM_ID_M25P16,
+	 .page_size = 256,
+	 .pages_per_sector = 256,
+	 .nr_sectors = 32,
+	 .name = "M25P16",
+	 },
+	{
+	 .idcode1 = STM_ID_M25P20,
+	 .page_size = 256,
+	 .pages_per_sector = 256,
+	 .nr_sectors = 4,
+	 .name = "M25P20",
+	 },
+	{
+	 .idcode1 = STM_ID_M25P32,
+	 .page_size = 256,
+	 .pages_per_sector = 256,
+	 .nr_sectors = 64,
+	 .name = "M25P32",
+	 },
+	{
+	 .idcode1 = STM_ID_M25P40,
+	 .page_size = 256,
+	 .pages_per_sector = 256,
+	 .nr_sectors = 8,
+	 .name = "M25P40",
+	 },
+	{
+	 .idcode1 = STM_ID_M25P64,
+	 .page_size = 256,
+	 .pages_per_sector = 256,
+	 .nr_sectors = 128,
+	 .name = "M25P64",
+	 },
+	{
+	 .idcode1 = STM_ID_M25P80,
+	 .page_size = 256,
+	 .pages_per_sector = 256,
+	 .nr_sectors = 16,

drivers/mtd/spi/stmicro.c line 128

Quoted 10 lines
drivers/mtd/spi/stmicro.c new file +10 -0
+	 .name = "M25P80",
+	 },
+	{
+	 .idcode1 = STM_ID_M25P128,
+	 .page_size = 256,
+	 .pages_per_sector = 1024,
+	 .nr_sectors = 64,
+	 .name = "M25P128",
+	 },
+};

The indentation is a bit weird here. Please use tabs only.

Who will apply this, btw?

Haavard

#2 lore raw

PATCH 1/1 mtd: SPI Flash: Support the STMicro Flash

Haavard,

Quoted 3 lines

Looks good to me, except...

Quoted 1 line

+static const struct stmicro_spi_flash_params

stmicro_spi_flash_table[] = {

Quoted 44 lines
Quoted 44 lines
drivers/mtd/spi/stmicro.c new file +44 -0
+	{
+	 .idcode1 = STM_ID_M25P16,
+	 .page_size = 256,
+	 .pages_per_sector = 256,
+	 .nr_sectors = 32,
+	 .name = "M25P16",
+	 },
+	{
+	 .idcode1 = STM_ID_M25P20,
+	 .page_size = 256,
+	 .pages_per_sector = 256,
+	 .nr_sectors = 4,
+	 .name = "M25P20",
+	 },
+	{
+	 .idcode1 = STM_ID_M25P32,
+	 .page_size = 256,
+	 .pages_per_sector = 256,
+	 .nr_sectors = 64,
+	 .name = "M25P32",
+	 },
+	{
+	 .idcode1 = STM_ID_M25P40,
+	 .page_size = 256,
+	 .pages_per_sector = 256,
+	 .nr_sectors = 8,
+	 .name = "M25P40",
+	 },
+	{
+	 .idcode1 = STM_ID_M25P64,
+	 .page_size = 256,
+	 .pages_per_sector = 256,
+	 .nr_sectors = 128,
+	 .name = "M25P64",
+	 },
+	{
+	 .idcode1 = STM_ID_M25P80,
+	 .page_size = 256,
+	 .pages_per_sector = 256,
+	 .nr_sectors = 16,
+	 .name = "M25P80",
+	 },
+	{
+	 .idcode1 = STM_ID_M25P128,
Quoted 8 lines

drivers/mtd/spi/stmicro.c line 128

Quoted 6 lines
drivers/mtd/spi/stmicro.c new file +6 -0
+	 .page_size = 256,
+	 .pages_per_sector = 1024,
+	 .nr_sectors = 64,
+	 .name = "M25P128",
+	 },
+};

The indentation is a bit weird here. Please use tabs only.

The indentation is generated by "indent -npro -kr -ts8 -sob -l80 -ss -ncs "$@"".

Quoted 1 line

Who will apply this, btw?

I will apply this, if no one else do it.

Regards,
TsiChung

#3 lore raw

PATCH 1/1 mtd: SPI Flash: Support the STMicro Flash

Quoted 17 lines · On Thu, Aug 28, 2008 at 06:44:56AM -0700, Liew Tsi Chung-R5AAHP wrote:
Quoted 9 lines
Quoted 9 lines
drivers/mtd/spi/stmicro.c new file +9 -0
+	{
+	 .idcode1 = STM_ID_M25P80,
+	 .page_size = 256,
+	 .pages_per_sector = 256,
+	 .nr_sectors = 16,
+	 .name = "M25P80",
+	 },
+	{
+	 .idcode1 = STM_ID_M25P128,
Quoted 8 lines

drivers/mtd/spi/stmicro.c line 128

Quoted 6 lines
drivers/mtd/spi/stmicro.c new file +6 -0
+	 .page_size = 256,
+	 .pages_per_sector = 1024,
+	 .nr_sectors = 64,
+	 .name = "M25P128",
+	 },
+};

The indentation is a bit weird here. Please use tabs only.

Quoted 2 lines

The indentation is generated by "indent -npro -kr -ts8 -sob -l80 -ss -ncs "$@"".

Try adding "-i8". If it still spits out anything looking like the above with the options you said you used, it's broken and you should do the formatting by hand.

-Scott

#4 lore raw

PATCH 1/1 mtd: SPI Flash: Support the STMicro Flash

Scott,

I do have -i8 included. So, which one I should edit by hand? The
" }," or " .xxxx =".

Regards,
TsiChung

-----Original Message-----
From: Wood Scott-B07421
Sent: Thursday, August 28, 2008 12:01 PM
To: Liew Tsi Chung-R5AAHP
Cc: Haavard Skinnemoen; U-Boot; Rigby John-R61273; Jason McMullan
Subject: Re: [U-Boot] [PATCH] mtd: SPI Flash: Support the STMicro Flash

Quoted 17 lines · On Thu, Aug 28, 2008 at 06:44:56AM -0700, Liew Tsi Chung-R5AAHP wrote:
Quoted 9 lines
Quoted 9 lines
drivers/mtd/spi/stmicro.c new file +9 -0
+	{
+	 .idcode1 = STM_ID_M25P80,
+	 .page_size = 256,
+	 .pages_per_sector = 256,
+	 .nr_sectors = 16,
+	 .name = "M25P80",
+	 },
+	{
+	 .idcode1 = STM_ID_M25P128,
Quoted 8 lines

drivers/mtd/spi/stmicro.c line 128

Quoted 6 lines
drivers/mtd/spi/stmicro.c new file +6 -0
+	 .page_size = 256,
+	 .pages_per_sector = 1024,
+	 .nr_sectors = 64,
+	 .name = "M25P128",
+	 },
+};

The indentation is a bit weird here. Please use tabs only.

Quoted 2 lines

The indentation is generated by "indent -npro -kr -ts8 -sob -l80 -ss -ncs "$@"".

Try adding "-i8". If it still spits out anything looking like the above with the options you said you used, it's broken and you should do the formatting by hand.

-Scott

#5 lore raw

PATCH 1/1 mtd: SPI Flash: Support the STMicro Flash

Quoted 4 lines · Liew Tsi Chung-R5AAHP wrote:

Scott,

I do have -i8 included. So, which one I should edit by hand? The
" }," or " .xxxx =".

Both.

It should look like this:

struct foo bar[] = {
	{
		.aoeu = AOEU1,
		.htns = HTNS1,
	},
	{
		.aoeu = AOEU2,
		.htns = HTNS2,
	},
};

-Scott