2011-06-18 10:09:35     MTD partitions on two SPI flash chips

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

2011-06-18 10:09:35     MTD partitions on two SPI flash chips

Wojtek Skulski (UNITED STATES)

Message: 101432   

 

Hi:

 

I have two SPI flash chips on my BF561 board. The SPI boot flash is connected to SEL=2. It is partitioned the usual way between uBoot and kernel. The other SPI fflash is connected to SEL=3. The lower half stores FPGA firmware. The upper half is free. I want to put JFFS2 there. So I want to establish four MTD partitions: two in one chip, and two in the other chip.

 

Reading the page about partitions (Wiki pointer below), I only see examples how to partition a single chip. There seems to be no member in "struct mtd_partition" telling the MTD to use two different chips. Is it at all possible? If yes, then how?

 

  docs.blackfin.uclinux.org/doku.php?id=linux-kernel:mtd&s[]=jffs2

QuoteReplyEditDelete

 

 

2011-06-18 13:07:54     Re: MTD partitions on two SPI flash chips

Mike Frysinger (UNITED STATES)

Message: 101433   

 

duplicate all the structures.  there is no relationship between the two spi flashes.

QuoteReplyEditDelete

 

 

2011-06-19 18:22:10     Re: MTD partitions on two SPI flash chips

Wojtek Skulski (UNITED STATES)

Message: 101458   

 

Mike:

 

thank you for the guidance. I am almost done with duplicating the SPI flash structures to enable MTD to partition two SPI flashes. I have one question, though. I am confused by the following two structures: bfin5xx_spi_master and spi_board_info. The "chip select" member is in both places. However, there is only one instance of bfin5xx_spi_master, while I have two SPI chips connected to SPISEL 2 and 3. Which "chip select" should I put into bfin5xx_spi_master?

 

Reading the header file ~/uClinux-dist/linux-2.6.x/arch/blackfin/include/asm/bfin5xx_spi.h was of little help because comments at the end of that file do not explain what the bfin5xx_spi_master is doing or how to use it.

 

static struct bfin5xx_spi_master bfin_spi0_info = {

 

        .num_chipselect = ???,    /* <-- which one should I use here? */

 

        .enable_dma = 1,  /* master has the ability to do dma transfer */

        .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},

};

 

 

The spi_board_info is not problematic because here I duplicated the structures. Therefore I do have the places to use SPISEL =2 or 3 in two different instances.

 

static struct spi_board_info bfin_spi_board_info[] __initdata = {

 

#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,

},

{       /*FPGA 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 = 3,               /* Framework chip select. */

        .platform_data = &fpga_spi_flash_data,

        .controller_data = &fpga_flash_chip_info,

        .mode = SPI_MODE_3,

},

#endif  /* SPI flash chips */

QuoteReplyEditDelete

 

 

2011-06-19 18:41:26     Re: MTD partitions on two SPI flash chips

Mike Frysinger (UNITED STATES)

Message: 101459   

 

num_chipselect does not mean what you think it means.  but that shouldnt matter as you shouldnt be touching that.

 

you need one set of resource structures per spi bus master, and one set of resources per spi slave client.

 

the spi_master struct is only for declaring spi bus masters, and the BF561 only has one.

QuoteReplyEditDelete

 

 

2011-06-20 08:31:56     Re: MTD partitions on two SPI flash chips

Wojtek Skulski (UNITED STATES)

Message: 101475    Mike:

by "not touching" the bus master do you mean that I should not declare

that structure at all? I copied from the BF533/blackstamp.c where it was

declared. BF533 also has one bus master. I thought that it made sense

in blackstamp.c that it was declared, so I copied it.

 

Please advise.

 

BTW, what does num_chipselect mean for my future reference?

QuoteReplyEditDelete

 

 

2011-06-20 08:52:19     Re: MTD partitions on two SPI flash chips

Mike Frysinger (UNITED STATES)

Message: 101477   

 

you need one spi bus master struct per spi bus master device you want to utilize.  i meant you shouldnt be touching it in terms of duplicating things since you already have one, and your processor only has one spi bus master.

 

num_chipselect is "the number of chipselects this spi bus master supports".

QuoteReplyEditDelete

 

 

2011-06-20 09:13:36     Re: MTD partitions on two SPI flash chips

Wojtek Skulski (UNITED STATES)

Message: 101478    Mike:

thank you for the advice. Now it is more clear. Concerning num_chipselect,

the number of hardware-assisted chipselects is 8. What happens if I want

to use regular GPIOs, as described on your Wiki? E.g., I use all 8 SPISEL

channels, and then want to use three more GPIO-mapped ones? Should I

increase num_chipselect to 8+3, or keep it at 8 and do some other

wizardry?

QuoteReplyEditDelete

 

 

2011-06-20 10:39:43     Re: MTD partitions on two SPI flash chips

Mike Frysinger (UNITED STATES)

Message: 101484   

 

arch/blackfin/mach-bf537/boards/stamp.c:        .num_chipselect = MAX_CTRL_CS + MAX_BLACKFIN_GPIOS,

QuoteReplyEditDelete

 

 

2011-06-20 10:54:50     Re: MTD partitions on two SPI flash chips

Wojtek Skulski (UNITED STATES)

Message: 101485    Mike:

thank you.

 

Wojtek

QuoteReplyEditDelete

 

 

2011-06-20 22:52:02     Re: MTD partitions on two SPI flash chips

Wojtek Skulski (UNITED STATES)

Message: 101500   

 

Mike:

 

it looks like success. Thank you very much for help.

 

  root:/home> cat /proc/mtd

  dev:    size   erasesize  name

  mtd0: 00030000 00010000 "bootloader(spi)"

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

  mtd2: 00410000 00010000 "FPGA_firmware(spi)"

  mtd3: 003f0000 00010000 "user_area(spi)"

Attachments

    Outcomes