From: Marek Vasut <marex@denx.de>
To: linux-mtd@lists.infradead.org
Cc: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>,
devicetree-discuss@lists.ozlabs.org, robherring2@gmail.com,
David Woodhouse <david.woodhouse@intel.com>,
dedekind1@gmail.com
Subject: Re: [PATCH V5] mtd: m25p80: Make fast read configurable via DT
Date: Mon, 17 Sep 2012 16:10:28 +0200 [thread overview]
Message-ID: <201209171610.28410.marex@denx.de> (raw)
In-Reply-To: <1345923416-9293-1-git-send-email-marex@denx.de>
Bump, do you think we can get this into 3.7 please?
> Add DT property "m25p,fast-read" that signalises the particular
> chip supports "fast read" opcode.
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
> Cc: David Woodhouse <david.woodhouse@intel.com>
> ---
> Documentation/devicetree/bindings/mtd/m25p80.txt | 29 ++++++++++++++++++
> drivers/mtd/devices/m25p80.c | 34
> +++++++++++++--------- 2 files changed, 50 insertions(+), 13 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/mtd/m25p80.txt
>
> V2: Add documentation for the DT property.
> V3: Use of_property_get_bool() instead of of_find_property().
> V4: Adjust the documentation's "compatible:" section, make it not
> Linux-specific, but keep the reference to Linux's list of
> supported devices. Also, use the default name, spansion,m25p80
> in the example.
> V5: Enclose of_property_read_bool() into CONFIG_OF for systems that do not
> use OF / Device Tree .
>
> diff --git a/Documentation/devicetree/bindings/mtd/m25p80.txt
> b/Documentation/devicetree/bindings/mtd/m25p80.txt new file mode 100644
> index 0000000..701bb58
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mtd/m25p80.txt
> @@ -0,0 +1,29 @@
> +* MTD SPI driver for ST M25Pxx (and similar) serial flash chips
> +
> +Required properties:
> +- #address-cells, #size-cells : Must be present if the device has
> sub-nodes + representing partitions.
> +- compatible : Should be the manufacturer and the name of the chip. Bear
> in mind + the DT binding is not Linux-only, but in case of
> Linux, see the + "m25p_ids" table in
> drivers/mtd/devices/m25p80.c for the list of + supported
> chips.
> +- reg : Chip-Select number
> +- spi-max-frequency : Maximum frequency of the SPI bus the chip can
> operate at +
> +Optional properties:
> +- m25p,fast-read : Use the "fast read" opcode to read data from the chip
> instead + of the usual "read" opcode. This opcode isn
> not supported by + all chips and support for it can not
> be detected at runtime. + Refer to your chips' datasheet
> to check if this is supported + by your chip.
> +
> +Example:
> +
> + flash: m25p80@0 {
> + #address-cells = <1>;
> + #size-cells = <1>;
> + compatible = "spansion,m25p80";
> + reg = <0>;
> + spi-max-frequency = <40000000>;
> + m25p,fast-read;
> + };
> diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
> index d16f75c..c433051 100644
> --- a/drivers/mtd/devices/m25p80.c
> +++ b/drivers/mtd/devices/m25p80.c
> @@ -73,14 +73,6 @@
> #define MAX_READY_WAIT_JIFFIES (40 * HZ) /* M25P16 specs 40s max
chip
> erase */ #define MAX_CMD_SIZE 5
>
> -#ifdef CONFIG_M25PXX_USE_FAST_READ
> -#define OPCODE_READ OPCODE_FAST_READ
> -#define FAST_READ_DUMMY_BYTE 1
> -#else
> -#define OPCODE_READ OPCODE_NORM_READ
> -#define FAST_READ_DUMMY_BYTE 0
> -#endif
> -
> #define JEDEC_MFR(_jedec_id) ((_jedec_id) >> 16)
>
> /*************************************************************************
> ***/ @@ -93,6 +85,7 @@ struct m25p {
> u16 addr_width;
> u8 erase_opcode;
> u8 *command;
> + bool fast_read;
> };
>
> static inline struct m25p *mtd_to_m25p(struct mtd_info *mtd)
> @@ -342,6 +335,7 @@ static int m25p80_read(struct mtd_info *mtd, loff_t
> from, size_t len, struct m25p *flash = mtd_to_m25p(mtd);
> struct spi_transfer t[2];
> struct spi_message m;
> + uint8_t opcode;
>
> pr_debug("%s: %s from 0x%08x, len %zd\n", dev_name(&flash->spi->dev),
> __func__, (u32)from, len);
> @@ -354,7 +348,7 @@ static int m25p80_read(struct mtd_info *mtd, loff_t
> from, size_t len, * Should add 1 byte DUMMY_BYTE.
> */
> t[0].tx_buf = flash->command;
> - t[0].len = m25p_cmdsz(flash) + FAST_READ_DUMMY_BYTE;
> + t[0].len = m25p_cmdsz(flash) + (flash->fast_read ? 1 : 0);
> spi_message_add_tail(&t[0], &m);
>
> t[1].rx_buf = buf;
> @@ -376,12 +370,14 @@ static int m25p80_read(struct mtd_info *mtd, loff_t
> from, size_t len, */
>
> /* Set up the write data buffer. */
> - flash->command[0] = OPCODE_READ;
> + opcode = flash->fast_read ? OPCODE_FAST_READ : OPCODE_NORM_READ;
> + flash->command[0] = opcode;
> m25p_addr2cmd(flash, from, flash->command);
>
> spi_sync(flash->spi, &m);
>
> - *retlen = m.actual_length - m25p_cmdsz(flash) - FAST_READ_DUMMY_BYTE;
> + *retlen = m.actual_length - m25p_cmdsz(flash) -
> + (flash->fast_read ? 1 : 0);
>
> mutex_unlock(&flash->lock);
>
> @@ -804,9 +800,10 @@ static int __devinit m25p_probe(struct spi_device
> *spi) struct flash_info *info;
> unsigned i;
> struct mtd_part_parser_data ppdata;
> + struct device_node *np = spi->dev.of_node;
>
> #ifdef CONFIG_MTD_OF_PARTS
> - if (!of_device_is_available(spi->dev.of_node))
> + if (!of_device_is_available(np))
> return -ENODEV;
> #endif
>
> @@ -858,7 +855,8 @@ static int __devinit m25p_probe(struct spi_device *spi)
> flash = kzalloc(sizeof *flash, GFP_KERNEL);
> if (!flash)
> return -ENOMEM;
> - flash->command = kmalloc(MAX_CMD_SIZE + FAST_READ_DUMMY_BYTE,
> GFP_KERNEL); + flash->command = kmalloc(MAX_CMD_SIZE + (flash-
>fast_read ?
> 1 : 0), + GFP_KERNEL);
> if (!flash->command) {
> kfree(flash);
> return -ENOMEM;
> @@ -915,6 +913,16 @@ static int __devinit m25p_probe(struct spi_device
> *spi) flash->page_size = info->page_size;
> flash->mtd.writebufsize = flash->page_size;
>
> + flash->fast_read = false;
> +#ifdef CONFIG_OF
> + if (np && of_property_read_bool(np, "m25p,fast-read"))
> + flash->fast_read = true;
> +#endif
> +
> +#ifdef CONFIG_M25PXX_USE_FAST_READ
> + flash->fast_read = true;
> +#endif
> +
> if (info->addr_width)
> flash->addr_width = info->addr_width;
> else {
WARNING: multiple messages have this Message-ID (diff)
From: Marek Vasut <marex-ynQEQJNshbs@public.gmane.org>
To: linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Cc: Artem Bityutskiy
<artem.bityutskiy-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
David Woodhouse
<david.woodhouse-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
dedekind1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Subject: Re: [PATCH V5] mtd: m25p80: Make fast read configurable via DT
Date: Mon, 17 Sep 2012 16:10:28 +0200 [thread overview]
Message-ID: <201209171610.28410.marex@denx.de> (raw)
In-Reply-To: <1345923416-9293-1-git-send-email-marex-ynQEQJNshbs@public.gmane.org>
Bump, do you think we can get this into 3.7 please?
> Add DT property "m25p,fast-read" that signalises the particular
> chip supports "fast read" opcode.
>
> Signed-off-by: Marek Vasut <marex-ynQEQJNshbs@public.gmane.org>
> Cc: Artem Bityutskiy <artem.bityutskiy-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
> Cc: David Woodhouse <david.woodhouse-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> ---
> Documentation/devicetree/bindings/mtd/m25p80.txt | 29 ++++++++++++++++++
> drivers/mtd/devices/m25p80.c | 34
> +++++++++++++--------- 2 files changed, 50 insertions(+), 13 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/mtd/m25p80.txt
>
> V2: Add documentation for the DT property.
> V3: Use of_property_get_bool() instead of of_find_property().
> V4: Adjust the documentation's "compatible:" section, make it not
> Linux-specific, but keep the reference to Linux's list of
> supported devices. Also, use the default name, spansion,m25p80
> in the example.
> V5: Enclose of_property_read_bool() into CONFIG_OF for systems that do not
> use OF / Device Tree .
>
> diff --git a/Documentation/devicetree/bindings/mtd/m25p80.txt
> b/Documentation/devicetree/bindings/mtd/m25p80.txt new file mode 100644
> index 0000000..701bb58
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mtd/m25p80.txt
> @@ -0,0 +1,29 @@
> +* MTD SPI driver for ST M25Pxx (and similar) serial flash chips
> +
> +Required properties:
> +- #address-cells, #size-cells : Must be present if the device has
> sub-nodes + representing partitions.
> +- compatible : Should be the manufacturer and the name of the chip. Bear
> in mind + the DT binding is not Linux-only, but in case of
> Linux, see the + "m25p_ids" table in
> drivers/mtd/devices/m25p80.c for the list of + supported
> chips.
> +- reg : Chip-Select number
> +- spi-max-frequency : Maximum frequency of the SPI bus the chip can
> operate at +
> +Optional properties:
> +- m25p,fast-read : Use the "fast read" opcode to read data from the chip
> instead + of the usual "read" opcode. This opcode isn
> not supported by + all chips and support for it can not
> be detected at runtime. + Refer to your chips' datasheet
> to check if this is supported + by your chip.
> +
> +Example:
> +
> + flash: m25p80@0 {
> + #address-cells = <1>;
> + #size-cells = <1>;
> + compatible = "spansion,m25p80";
> + reg = <0>;
> + spi-max-frequency = <40000000>;
> + m25p,fast-read;
> + };
> diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
> index d16f75c..c433051 100644
> --- a/drivers/mtd/devices/m25p80.c
> +++ b/drivers/mtd/devices/m25p80.c
> @@ -73,14 +73,6 @@
> #define MAX_READY_WAIT_JIFFIES (40 * HZ) /* M25P16 specs 40s max
chip
> erase */ #define MAX_CMD_SIZE 5
>
> -#ifdef CONFIG_M25PXX_USE_FAST_READ
> -#define OPCODE_READ OPCODE_FAST_READ
> -#define FAST_READ_DUMMY_BYTE 1
> -#else
> -#define OPCODE_READ OPCODE_NORM_READ
> -#define FAST_READ_DUMMY_BYTE 0
> -#endif
> -
> #define JEDEC_MFR(_jedec_id) ((_jedec_id) >> 16)
>
> /*************************************************************************
> ***/ @@ -93,6 +85,7 @@ struct m25p {
> u16 addr_width;
> u8 erase_opcode;
> u8 *command;
> + bool fast_read;
> };
>
> static inline struct m25p *mtd_to_m25p(struct mtd_info *mtd)
> @@ -342,6 +335,7 @@ static int m25p80_read(struct mtd_info *mtd, loff_t
> from, size_t len, struct m25p *flash = mtd_to_m25p(mtd);
> struct spi_transfer t[2];
> struct spi_message m;
> + uint8_t opcode;
>
> pr_debug("%s: %s from 0x%08x, len %zd\n", dev_name(&flash->spi->dev),
> __func__, (u32)from, len);
> @@ -354,7 +348,7 @@ static int m25p80_read(struct mtd_info *mtd, loff_t
> from, size_t len, * Should add 1 byte DUMMY_BYTE.
> */
> t[0].tx_buf = flash->command;
> - t[0].len = m25p_cmdsz(flash) + FAST_READ_DUMMY_BYTE;
> + t[0].len = m25p_cmdsz(flash) + (flash->fast_read ? 1 : 0);
> spi_message_add_tail(&t[0], &m);
>
> t[1].rx_buf = buf;
> @@ -376,12 +370,14 @@ static int m25p80_read(struct mtd_info *mtd, loff_t
> from, size_t len, */
>
> /* Set up the write data buffer. */
> - flash->command[0] = OPCODE_READ;
> + opcode = flash->fast_read ? OPCODE_FAST_READ : OPCODE_NORM_READ;
> + flash->command[0] = opcode;
> m25p_addr2cmd(flash, from, flash->command);
>
> spi_sync(flash->spi, &m);
>
> - *retlen = m.actual_length - m25p_cmdsz(flash) - FAST_READ_DUMMY_BYTE;
> + *retlen = m.actual_length - m25p_cmdsz(flash) -
> + (flash->fast_read ? 1 : 0);
>
> mutex_unlock(&flash->lock);
>
> @@ -804,9 +800,10 @@ static int __devinit m25p_probe(struct spi_device
> *spi) struct flash_info *info;
> unsigned i;
> struct mtd_part_parser_data ppdata;
> + struct device_node *np = spi->dev.of_node;
>
> #ifdef CONFIG_MTD_OF_PARTS
> - if (!of_device_is_available(spi->dev.of_node))
> + if (!of_device_is_available(np))
> return -ENODEV;
> #endif
>
> @@ -858,7 +855,8 @@ static int __devinit m25p_probe(struct spi_device *spi)
> flash = kzalloc(sizeof *flash, GFP_KERNEL);
> if (!flash)
> return -ENOMEM;
> - flash->command = kmalloc(MAX_CMD_SIZE + FAST_READ_DUMMY_BYTE,
> GFP_KERNEL); + flash->command = kmalloc(MAX_CMD_SIZE + (flash-
>fast_read ?
> 1 : 0), + GFP_KERNEL);
> if (!flash->command) {
> kfree(flash);
> return -ENOMEM;
> @@ -915,6 +913,16 @@ static int __devinit m25p_probe(struct spi_device
> *spi) flash->page_size = info->page_size;
> flash->mtd.writebufsize = flash->page_size;
>
> + flash->fast_read = false;
> +#ifdef CONFIG_OF
> + if (np && of_property_read_bool(np, "m25p,fast-read"))
> + flash->fast_read = true;
> +#endif
> +
> +#ifdef CONFIG_M25PXX_USE_FAST_READ
> + flash->fast_read = true;
> +#endif
> +
> if (info->addr_width)
> flash->addr_width = info->addr_width;
> else {
next prev parent reply other threads:[~2012-09-17 14:10 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-25 19:36 [PATCH V5] mtd: m25p80: Make fast read configurable via DT Marek Vasut
2012-08-25 19:36 ` Marek Vasut
2012-08-25 20:22 ` Kevin Cernekee
2012-08-25 20:22 ` Kevin Cernekee
2012-08-25 20:40 ` Marek Vasut
2012-08-25 20:40 ` Marek Vasut
2012-08-25 22:06 ` Kevin Cernekee
2012-08-25 22:06 ` Kevin Cernekee
2012-08-26 9:11 ` Marek Vasut
2012-08-26 9:11 ` Marek Vasut
2012-09-04 0:04 ` Marek Vasut
2012-09-04 0:04 ` Marek Vasut
2012-09-17 14:10 ` Marek Vasut [this message]
2012-09-17 14:10 ` Marek Vasut
2012-09-21 13:19 ` Artem Bityutskiy
2012-09-21 13:19 ` Artem Bityutskiy
2012-09-24 1:30 ` Marek Vasut
2012-09-24 1:30 ` 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=201209171610.28410.marex@denx.de \
--to=marex@denx.de \
--cc=artem.bityutskiy@linux.intel.com \
--cc=david.woodhouse@intel.com \
--cc=dedekind1@gmail.com \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=linux-mtd@lists.infradead.org \
--cc=robherring2@gmail.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.