From: Angus Clark <angus.clark@st.com>
To: Huang Shijie <b32955@freescale.com>
Cc: marex@denx.de, Angus CLARK <angus.clark@st.com>,
broonie@linaro.org, dwmw2@infradead.org,
Linus Walleij <linus.walleij@linaro.org>,
linux-spi@vger.kernel.org, linux-mtd@lists.infradead.org,
pekon@ti.com, sourav.poddar@ti.com,
Brian Norris <computersforpeace@gmail.com>,
Lee Jones <lee.jones@linaro.org>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 0/4] mtd: spi-nor: add a new framework for SPI NOR
Date: Mon, 2 Dec 2013 11:19:23 +0000 [thread overview]
Message-ID: <529C6CBB.4000008@st.com> (raw)
In-Reply-To: <529C5BBF.6000604@freescale.com>
Hi Huang Shijie
On 12/02/2013 10:06 AM, Huang Shijie wrote:
> Hi Angus:
> thanks for the long suggestion. it's very useful.
>
> Let's push the spi nor framework.:)
[...]
>>
>> /**
>> * struct spi_nor_xfer_cfg - Structure for defining a Serial Flash
>> transfer
>> * @wren: command for "Write Enable", or 0x00 for not required
> why this wren is needed?
Issuing WREN is needed for certain sequences of operations. I guess your
question relates to why have I included it as part of the 'spi_nor_xfer_cfg'
structure, when it could be controlled from the spi_nor layer with a separate
spi_nor_xfer.
Well, firstly, I am aware of at least one H/W controller that can be optimised
to issue the WREN command as part of a longer erase or write sequence, thereby
avoiding the overheads of issuing a separate spi_nor_xfer.
However, the main reason was to try and come up with a generic representation
for a typical Serial Flash transfer, capturing, where possible, the semantics of
the intended operation, just in case that information can be used by the
underlying H/W in some way. In this instance, the WREN cycles just represents
another part of the transfer, in the same way as the command, address, mode, and
dummy cycles.
>> * @cmd: command for operation
>> * @cmd_pins: number of pins to send @cmd (1, 2, 4)
>> * @addr: address for operation
>> * @addr_pins: number of pins to send @addr (1, 2, 4)
>> * @addr_width: number of address bytes (3,4, or 0 for address
>> not required)
> this field has been in the spi_nor{} , it should be a fixed value.
> so i think we do not need this argument.
The aim of the 'spi_nor_xfer_cfg' is to provide an interface between the spi-nor
layer and the underlying H/W driver. In some cases, the H/W may need to know
the address width (e.g. issuing a new command sequence, with an incremented
address, following an arbitration stall). You could argue that the H/W driver
should be able query the spi_nor structure, or perhaps store the addr_width
field during an initialisation process, but I feel having it as part of the
'spi_nor_xfer_cfg' provides a cleaner interface between the two layers.
>> * @mode: mode data
>> * @mode_pins: number of pins to send @mode (1, 2, 4)
>> * @mode_cycles: number of mode cycles (0 for mode not required)
>> * @dummy_cycles: number of dummy cycles (0 for dummy not required)
>> */
>> struct spi_nor_xfer_cfg {
>> uint8_t wren;
>> uint8_t cmd;
>> int cmd_pins;
>> uint32_t addr;
>> int addr_pins;
>> int addr_width;
>> uint32_t mode;
>> int mode_pins;
>> int mode_cycles;
>> int dummy_cycles;
>> };
>>
>> We could then build up layers of functionality, based on two
>> fundamental primitives:
>>
>> int (*read_xfer)(struct spi_nor_info *info,
>> struct spi_nor_xfer_cfg *cfg,
>> uint8_t *buf, size_t len);
>>
>> int (*write_xfer)(struct spi_nor_info *info,
>> struct spi_nor_xfer_cfg *cfg,
>> uint8_t *buf, size_t len);
>>
>> Default implementations for standard operations could follow:
>>
>> int (*read_reg)(struct spi_nor_info *info,
>> uint8_t cmd, uint8_t *reg, int len);
>> int (*write_reg)(struct spi_nor_info *info,
>> uint8_t cmd, uint8_t *reg, int len,
>> int wren, int wtr);
>>
>> int (*readid)(struct spi_nor_info *info, uint8_t *readid);
>> int (*wait_till_ready)(struct spi_nor_info *info);
>
> currently, we poll the status register.
> why this hook is needed?
The default implementation would do just as you suggest, and I would expect most
H/W drivers to use the default implementation. However, some H/W Controllers
can automate the polling of status registers, so having a hook allows the driver
override the default behaviour.
>> int (*read)(struct spi_nor_info *info, uint8_t buf, off_t offs,
>> size_t len);
>> int (*write)(struct spi_nor_info *info, off_t offs, size_t len);
>> int (*erase_sector)(struct spi_nor_info *info, off_t offs);
> I also confused at this hook.
>
> if we need erase_sector, do we still need the erase_chip()?
Serial Flash devices support various "Erase Sector" commands, and an "Erase
Chip" command. The erase_sector() and erase_chip() hooks would just form the
appropriate command sequences (e.g. Erase Chip does not require address cycles).
I have to admit, the circumstances that provoke an erase_chip() are rather
limited. As far as I can see, the MTD tool 'mtd_debug' is the only component
that can lead to an Erase Chip operation, and even then, only when the device is
not partitioned. However, m25p80 supports Erase Chip, so I thought I would
maintain that support here.
As I said before, my proposal was just some initial ramblings of my mind, and I
am definitely open to discussion and other suggestions.
To be honest, I am just glad that someone is taking a look at this area.
However, whether or not is it possible to come up with something that solves all
our problems remains to be seen. It might turn out that the various H/W
Controllers are just too different to fit into a single unified framework.
Cheers,
Angus
WARNING: multiple messages have this Message-ID (diff)
From: angus.clark@st.com (Angus Clark)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 0/4] mtd: spi-nor: add a new framework for SPI NOR
Date: Mon, 2 Dec 2013 11:19:23 +0000 [thread overview]
Message-ID: <529C6CBB.4000008@st.com> (raw)
In-Reply-To: <529C5BBF.6000604@freescale.com>
Hi Huang Shijie
On 12/02/2013 10:06 AM, Huang Shijie wrote:
> Hi Angus:
> thanks for the long suggestion. it's very useful.
>
> Let's push the spi nor framework.:)
[...]
>>
>> /**
>> * struct spi_nor_xfer_cfg - Structure for defining a Serial Flash
>> transfer
>> * @wren: command for "Write Enable", or 0x00 for not required
> why this wren is needed?
Issuing WREN is needed for certain sequences of operations. I guess your
question relates to why have I included it as part of the 'spi_nor_xfer_cfg'
structure, when it could be controlled from the spi_nor layer with a separate
spi_nor_xfer.
Well, firstly, I am aware of at least one H/W controller that can be optimised
to issue the WREN command as part of a longer erase or write sequence, thereby
avoiding the overheads of issuing a separate spi_nor_xfer.
However, the main reason was to try and come up with a generic representation
for a typical Serial Flash transfer, capturing, where possible, the semantics of
the intended operation, just in case that information can be used by the
underlying H/W in some way. In this instance, the WREN cycles just represents
another part of the transfer, in the same way as the command, address, mode, and
dummy cycles.
>> * @cmd: command for operation
>> * @cmd_pins: number of pins to send @cmd (1, 2, 4)
>> * @addr: address for operation
>> * @addr_pins: number of pins to send @addr (1, 2, 4)
>> * @addr_width: number of address bytes (3,4, or 0 for address
>> not required)
> this field has been in the spi_nor{} , it should be a fixed value.
> so i think we do not need this argument.
The aim of the 'spi_nor_xfer_cfg' is to provide an interface between the spi-nor
layer and the underlying H/W driver. In some cases, the H/W may need to know
the address width (e.g. issuing a new command sequence, with an incremented
address, following an arbitration stall). You could argue that the H/W driver
should be able query the spi_nor structure, or perhaps store the addr_width
field during an initialisation process, but I feel having it as part of the
'spi_nor_xfer_cfg' provides a cleaner interface between the two layers.
>> * @mode: mode data
>> * @mode_pins: number of pins to send @mode (1, 2, 4)
>> * @mode_cycles: number of mode cycles (0 for mode not required)
>> * @dummy_cycles: number of dummy cycles (0 for dummy not required)
>> */
>> struct spi_nor_xfer_cfg {
>> uint8_t wren;
>> uint8_t cmd;
>> int cmd_pins;
>> uint32_t addr;
>> int addr_pins;
>> int addr_width;
>> uint32_t mode;
>> int mode_pins;
>> int mode_cycles;
>> int dummy_cycles;
>> };
>>
>> We could then build up layers of functionality, based on two
>> fundamental primitives:
>>
>> int (*read_xfer)(struct spi_nor_info *info,
>> struct spi_nor_xfer_cfg *cfg,
>> uint8_t *buf, size_t len);
>>
>> int (*write_xfer)(struct spi_nor_info *info,
>> struct spi_nor_xfer_cfg *cfg,
>> uint8_t *buf, size_t len);
>>
>> Default implementations for standard operations could follow:
>>
>> int (*read_reg)(struct spi_nor_info *info,
>> uint8_t cmd, uint8_t *reg, int len);
>> int (*write_reg)(struct spi_nor_info *info,
>> uint8_t cmd, uint8_t *reg, int len,
>> int wren, int wtr);
>>
>> int (*readid)(struct spi_nor_info *info, uint8_t *readid);
>> int (*wait_till_ready)(struct spi_nor_info *info);
>
> currently, we poll the status register.
> why this hook is needed?
The default implementation would do just as you suggest, and I would expect most
H/W drivers to use the default implementation. However, some H/W Controllers
can automate the polling of status registers, so having a hook allows the driver
override the default behaviour.
>> int (*read)(struct spi_nor_info *info, uint8_t buf, off_t offs,
>> size_t len);
>> int (*write)(struct spi_nor_info *info, off_t offs, size_t len);
>> int (*erase_sector)(struct spi_nor_info *info, off_t offs);
> I also confused at this hook.
>
> if we need erase_sector, do we still need the erase_chip()?
Serial Flash devices support various "Erase Sector" commands, and an "Erase
Chip" command. The erase_sector() and erase_chip() hooks would just form the
appropriate command sequences (e.g. Erase Chip does not require address cycles).
I have to admit, the circumstances that provoke an erase_chip() are rather
limited. As far as I can see, the MTD tool 'mtd_debug' is the only component
that can lead to an Erase Chip operation, and even then, only when the device is
not partitioned. However, m25p80 supports Erase Chip, so I thought I would
maintain that support here.
As I said before, my proposal was just some initial ramblings of my mind, and I
am definitely open to discussion and other suggestions.
To be honest, I am just glad that someone is taking a look at this area.
However, whether or not is it possible to come up with something that solves all
our problems remains to be seen. It might turn out that the various H/W
Controllers are just too different to fit into a single unified framework.
Cheers,
Angus
next prev parent reply other threads:[~2013-12-02 11:19 UTC|newest]
Thread overview: 157+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-26 6:32 [PATCH 0/4] mtd: spi-nor: add a new framework for SPI NOR Huang Shijie
2013-11-26 6:32 ` Huang Shijie
2013-11-26 6:32 ` [PATCH 1/4] mtd: spi-nor: move the SPI NOR commands to a new header file Huang Shijie
2013-11-26 6:32 ` Huang Shijie
2013-11-26 7:42 ` Gupta, Pekon
2013-11-26 7:42 ` Gupta, Pekon
2013-11-26 8:53 ` Huang Shijie
2013-11-26 8:53 ` Huang Shijie
2013-11-26 14:48 ` Angus Clark
2013-11-26 14:48 ` Angus Clark
2013-11-26 6:32 ` [PATCH 2/4] mtd: spi-nor: add a new data structrue spi_nor{} Huang Shijie
2013-11-26 6:32 ` Huang Shijie
2013-11-26 11:42 ` Gupta, Pekon
2013-11-26 11:42 ` Gupta, Pekon
2013-11-27 4:35 ` Huang Shijie
2013-11-27 4:35 ` Huang Shijie
2013-11-27 9:32 ` Marek Vasut
2013-11-27 9:32 ` Marek Vasut
2013-11-27 10:24 ` Huang Shijie
2013-11-27 10:24 ` Huang Shijie
2013-11-27 10:27 ` Marek Vasut
2013-11-27 10:27 ` Marek Vasut
2013-11-26 6:32 ` [PATCH 3/4] mtd: spi-nor: add the framework for SPI NOR Huang Shijie
2013-11-26 6:32 ` Huang Shijie
2013-11-26 10:03 ` Gupta, Pekon
2013-11-26 10:03 ` Gupta, Pekon
2013-11-27 9:39 ` Marek Vasut
2013-11-27 9:39 ` Marek Vasut
2013-11-26 6:32 ` [PATCH 4/4] mtd: m25p80: use the new spi-nor APIs Huang Shijie
2013-11-26 6:32 ` Huang Shijie
2013-11-26 12:57 ` [PATCH 0/4] mtd: spi-nor: add a new framework for SPI NOR Angus Clark
2013-11-26 12:57 ` Angus Clark
2013-11-27 4:32 ` Brian Norris
2013-11-27 4:32 ` Brian Norris
2013-11-27 4:32 ` Brian Norris
2013-11-27 4:39 ` Huang Shijie
2013-11-27 4:39 ` Huang Shijie
2013-11-27 4:39 ` Huang Shijie
2013-11-29 14:52 ` Angus Clark
2013-11-29 14:52 ` Angus Clark
2013-11-29 14:52 ` Angus Clark
2013-12-02 10:06 ` Huang Shijie
2013-12-02 10:06 ` Huang Shijie
2013-12-02 10:06 ` Huang Shijie
2013-12-02 11:01 ` Gupta, Pekon
2013-12-02 11:01 ` Gupta, Pekon
2013-12-02 11:01 ` Gupta, Pekon
2013-12-02 11:19 ` Angus Clark [this message]
2013-12-02 11:19 ` Angus Clark
2013-12-03 6:20 ` Huang Shijie
2013-12-03 6:20 ` Huang Shijie
2013-12-03 6:20 ` Huang Shijie
2013-12-03 8:23 ` Lee Jones
2013-12-03 8:23 ` Lee Jones
2013-12-03 8:23 ` Lee Jones
2013-12-10 8:25 ` Brian Norris
2013-12-10 8:25 ` Brian Norris
2013-12-10 8:25 ` Brian Norris
2013-12-10 10:00 ` Lee Jones
2013-12-10 10:00 ` Lee Jones
2013-12-10 10:00 ` Lee Jones
2013-12-03 0:32 ` Marek Vasut
2013-12-03 0:32 ` Marek Vasut
2013-12-03 0:32 ` Marek Vasut
2013-12-03 10:36 ` Huang Shijie
2013-12-03 10:36 ` Huang Shijie
2013-12-03 10:36 ` Huang Shijie
2013-12-03 14:51 ` David Woodhouse
2013-12-03 14:51 ` David Woodhouse
2013-12-03 14:51 ` David Woodhouse
2013-12-04 18:44 ` Brian Norris
2013-12-04 18:44 ` Brian Norris
2013-12-04 18:44 ` Brian Norris
2013-12-05 7:12 ` Huang Shijie
2013-12-05 7:12 ` Huang Shijie
2013-12-05 7:12 ` Huang Shijie
2013-12-05 8:11 ` Brian Norris
2013-12-05 8:11 ` Brian Norris
2013-12-05 8:11 ` Brian Norris
2013-12-05 7:59 ` Huang Shijie
2013-12-05 7:59 ` Huang Shijie
2013-12-05 7:59 ` Huang Shijie
2013-12-05 9:20 ` Brian Norris
2013-12-05 9:20 ` Brian Norris
2013-12-05 9:20 ` Brian Norris
2013-12-06 3:07 ` Huang Shijie
2013-12-06 3:07 ` Huang Shijie
2013-12-06 3:07 ` Huang Shijie
2013-12-05 14:35 ` Angus Clark
2013-12-05 14:35 ` Angus Clark
2013-12-05 14:35 ` Angus Clark
2013-12-06 8:18 ` Huang Shijie
2013-12-06 8:18 ` Huang Shijie
2013-12-06 8:18 ` Huang Shijie
2013-12-10 9:08 ` Brian Norris
2013-12-10 9:08 ` Brian Norris
2013-12-10 9:08 ` Brian Norris
2013-12-04 2:46 ` Huang Shijie
2013-12-04 2:46 ` Huang Shijie
2013-12-04 2:46 ` Huang Shijie
2013-12-04 6:58 ` Angus Clark
2013-12-04 6:58 ` Angus Clark
2013-12-04 6:58 ` Angus Clark
2013-12-04 7:19 ` Gupta, Pekon
2013-12-04 7:19 ` Gupta, Pekon
2013-12-04 7:19 ` Gupta, Pekon
2013-12-04 8:21 ` Angus Clark
2013-12-04 8:21 ` Angus Clark
2013-12-04 8:21 ` Angus Clark
2013-12-04 15:36 ` Marek Vasut
2013-12-04 15:36 ` Marek Vasut
2013-12-04 15:36 ` Marek Vasut
2013-12-05 2:42 ` Huang Shijie
2013-12-05 2:42 ` Huang Shijie
2013-12-05 2:42 ` Huang Shijie
2013-12-05 5:43 ` Gupta, Pekon
2013-12-05 5:43 ` Gupta, Pekon
2013-12-05 5:43 ` Gupta, Pekon
2013-12-05 7:33 ` Huang Shijie
2013-12-05 7:33 ` Huang Shijie
2013-12-05 7:33 ` Huang Shijie
2013-11-27 9:27 ` Marek Vasut
2013-11-27 9:27 ` Marek Vasut
2013-11-27 9:47 ` Sourav Poddar
2013-11-27 9:47 ` Sourav Poddar
2013-11-27 10:06 ` Marek Vasut
2013-11-27 10:06 ` Marek Vasut
2013-11-27 10:56 ` Sourav Poddar
2013-11-27 10:56 ` Sourav Poddar
2013-12-02 23:59 ` Marek Vasut
2013-12-02 23:59 ` Marek Vasut
2013-12-03 10:01 ` Sourav Poddar
2013-12-03 10:01 ` Sourav Poddar
2013-12-03 13:42 ` Marek Vasut
2013-12-03 13:42 ` Marek Vasut
2013-12-03 13:50 ` Sourav Poddar
2013-12-03 13:50 ` Sourav Poddar
2013-12-03 14:19 ` Marek Vasut
2013-12-03 14:19 ` Marek Vasut
2013-12-03 14:31 ` Sourav Poddar
2013-12-03 14:31 ` Sourav Poddar
2013-12-03 15:09 ` Marek Vasut
2013-12-03 15:09 ` Marek Vasut
2013-12-03 15:16 ` Sourav Poddar
2013-12-03 15:16 ` Sourav Poddar
2013-12-03 15:35 ` Marek Vasut
2013-12-03 15:35 ` Marek Vasut
2013-12-03 15:23 ` David Woodhouse
2013-12-03 15:23 ` David Woodhouse
2013-12-03 18:28 ` Brian Norris
2013-12-03 18:28 ` Brian Norris
2013-12-03 23:41 ` Marek Vasut
2013-12-03 23:41 ` Marek Vasut
2013-11-27 10:19 ` Huang Shijie
2013-11-27 10:19 ` Huang Shijie
2013-12-03 0:00 ` Marek Vasut
2013-12-03 0:00 ` Marek Vasut
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=529C6CBB.4000008@st.com \
--to=angus.clark@st.com \
--cc=b32955@freescale.com \
--cc=broonie@linaro.org \
--cc=computersforpeace@gmail.com \
--cc=dwmw2@infradead.org \
--cc=lee.jones@linaro.org \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-mtd@lists.infradead.org \
--cc=linux-spi@vger.kernel.org \
--cc=marex@denx.de \
--cc=pekon@ti.com \
--cc=sourav.poddar@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.