2011-08-11 18:20:31     Winbond flash driver in Linux kernel

Document created by Aaronwu Employee on Aug 27, 2013
Version 1Show Document
  • View in full screen mode

2011-08-11 18:20:31     Winbond flash driver in Linux kernel

Wojtek Skulski (UNITED STATES)

Message: 102897   

 

Hello:

 

which MTD driver should I use for Winbond SPI flash chips in Linux kernel?

 

I have one board with Numonyx flash chips, and for those I successfully use the settings from the Blackfin Wiki pages. However, the M25P64 chips are becoming hard to buy, so I started using Winbond W25Q64. Unfortunately, the settings which work with Numonyx, do not work with Winbond. Could you please suggest how to change these, or else please direct me to the relevant Wiki page.

 

The following work with M25P64, but not with W25Q64.

 

#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)

{       /*boot SPI flash*/

        /* the modalias must be the same as spi device driver name */

        .modalias = "m25p80",           /* Name of spi_driver */

        .max_speed_hz = 20000000,       /* max SCK speed in HZ */

        .bus_num = 0,                   /* Framework bus number */

        .chip_select = 2,               /* Framework chip select. */

        .platform_data = &boot_spi_flash_data,

        .controller_data = &boot_flash_chip_info,

        .mode = SPI_MODE_3,

},

QuoteReplyEditDelete

 

 

2011-08-11 23:54:31     Re: Winbond flash driver in Linux kernel

Wojtek Skulski (UNITED STATES)

Message: 102899   

 

I guess I found the source of the problem, which is the m25p80 driver in the 2009 release which I am still using. (The dreaded AX88180 driver, which actually has been released since then.) Anyway, the m25p80 sits here:

 

~/uClinux-dist/linux-2.6.x/drivers/mtd/devices/m25p80.c

 

In that file the table of Winbond chips includes the X variants, which are obsolete. It does not include the newer Q chips. The two lines of chips have different JEDEC identifiers. The W25Q64 reports JEDEC id ef4017, which is not recognized by the m25P80 driver.

 

The table of Winbond chips looks as follows. It only includes X chips. So now I will add Q chips and the problem will be gone. I remember doing it for uBoot. Now I need to repeat the trick.

 

        /* Winbond -- w25x "blocks" are 64K, "sectors" are 4KiB */

        { "w25x10", 0xef3011, 0, 64 * 1024, 2, SECT_4K, },

        { "w25x20", 0xef3012, 0, 64 * 1024, 4, SECT_4K, },

        { "w25x40", 0xef3013, 0, 64 * 1024, 8, SECT_4K, },

        { "w25x80", 0xef3014, 0, 64 * 1024, 16, SECT_4K, },

        { "w25x16", 0xef3015, 0, 64 * 1024, 32, SECT_4K, },

        { "w25x32", 0xef3016, 0, 64 * 1024, 64, SECT_4K, },

        { "w25x64", 0xef3017, 0, 64 * 1024, 128, SECT_4K, },

QuoteReplyEditDelete

 

 

2011-08-12 00:54:56     Re: Winbond flash driver in Linux kernel

Wojtek Skulski (UNITED STATES)

Message: 102900   

 

OK, I fixed the Winbond problem in the 2009 release which I am using. Here is how:

 

  STEP 1. Fixing the m25p80 driver in 2009 release.

 

  I added the following to the table of Winbond chips. I should have added the 16 MB and 32 MB chips as well, but I am not using these.

 

  /* X-series is obsolete. Q-series should be used instead.*/

  { "w25q16", 0xef4015, 0, 64 * 1024, 32, SECT_4K, },     /*2 MB*/

  { "w25q32", 0xef4016, 0, 64 * 1024, 64, SECT_4K, },     /*4 MB*/

  { "w25q64", 0xef4017, 0, 64 * 1024, 128, SECT_4K, },    /*8 MB*/

 

  This made the driver to emit the following boot message:

 

  m25p80 spi0.2: found w25q64, expected m25p64

  m25p80 spi0.3: found w25q64, expected m25p64

 

 

  STEP 2. Fixing the board file (6) to remove the wrong chip name.

 

 

I guess it is "expecting" m25p64 because this info has been given to it.

 

The concrete chip name was hardwired in two places in the board file, BOOT and FPGA:

 

static struct flash_platform_data boot_spi_flash_data = {

        .name = "m25p80",

        .parts = boot_spi_flash_partitions,

        .nr_parts = ARRAY_SIZE(boot_spi_flash_partitions),

        .type = "m25p64",

};

 

static struct flash_platform_data fpga_spi_flash_data = {

        .name = "m25p80",       /*driver name*/

        .parts = fpga_spi_flash_partitions,

        .nr_parts = ARRAY_SIZE(fpga_spi_flash_partitions),

        .type = "m25p64",     /*harwire chip typeis a bad idea*/

};

 

I commented out the chip type. I did NOT put the Winbond chip name here by hand.

I remember seeing a remark somewhere that the chip name is optional.

 

  STEP 3. SUCCESS.

  ----------------

 

  Here are boot messages:

 

  m25p80 spi0.2: w25q64 (8192 Kbytes)

  Creating 2 MTD partitions on "m25p80":

  0x00000000-0x00030000 : "bootloader(spi)"

  0x00030000-0x00800000 : "linux kernel(spi)"

  m25p80 spi0.3: w25q64 (8192 Kbytes)

  Creating 2 MTD partitions on "m25p80":

  0x00000000-0x00410000 : "FPGA_firmware(spi)"

  0x00410000-0x00800000 : "user_area(spi)"

 

Here is the /proc listing:

 

root:/>  cat /proc/mtd

dev:    size   erasesize  name

mtd0: 00030000 00001000 "bootloader(spi)"

mtd1: 007d0000 00001000 "linux kernel(spi)"

mtd2: 00410000 00001000 "FPGA_firmware(spi)"

mtd3: 003f0000 00001000 "user_area(spi)"

Attachments

    Outcomes