All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v6 1/2] mtd: fsl-quadspi: Distinguish the mtd device names
@ 2018-01-18 14:28 Fabio Estevam
  2018-01-18 14:28 ` [PATCH v6 2/2] dt-bindings: fsl-quadspi: Add the example of two SPI NOR Fabio Estevam
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Fabio Estevam @ 2018-01-18 14:28 UTC (permalink / raw)
  To: boris.brezillon; +Cc: linux-mtd, han.xu, david.wolfe, Fabio Estevam

Currently on a imx6sx-sdb board, which has two SPI NOR chips connected
to QSPI2 the following output from /proc/mtd is seen:

# cat /proc/mtd 
dev:    size   erasesize  name
mtd0: 01000000 00010000 "21e4000.qspi"
mtd1: 01000000 00010000 "21e4000.qspi"

Attempts to partition them on the kernel command line result in both
chips with identical (and identically named) partitions, which is
an inconvenient behavior.

Assign a different mtd->name for each mtd device to avoid this problem.

After this change the output from /proc/mtd becomes:

# cat /proc/mtd 
dev:    size   erasesize  name
mtd0: 01000000 00010000 "21e4000.qspi-0"
mtd1: 01000000 00010000 "21e4000.qspi-1"

In order to keep mtdparts compatibility keep the mtd->name
unchanged when a single SPI NOR is present.

Reported-by: David Wolfe <david.wolfe@nxp.com>
Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
---
Changes since v5:
- Preserve the label value, if any. (Boris)

 drivers/mtd/spi-nor/fsl-quadspi.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/mtd/spi-nor/fsl-quadspi.c b/drivers/mtd/spi-nor/fsl-quadspi.c
index 2901c7b..1038842 100644
--- a/drivers/mtd/spi-nor/fsl-quadspi.c
+++ b/drivers/mtd/spi-nor/fsl-quadspi.c
@@ -1051,6 +1051,24 @@ static int fsl_qspi_probe(struct platform_device *pdev)
 		spi_nor_set_flash_node(nor, np);
 		nor->priv = q;
 
+		if (q->nor_num > 1 && !mtd->name) {
+			int spiflash_idx;
+
+			ret = of_property_read_u32(np, "reg", &spiflash_idx);
+			if (!ret) {
+				mtd->name = devm_kasprintf(dev, GFP_KERNEL,
+							   "%s-%d",
+							   dev_name(dev),
+							   spiflash_idx);
+				if (!mtd->name) {
+					ret = -ENOMEM;
+					goto mutex_failed;
+				}
+			} else {
+				dev_warn(dev, "reg property is missing\n");
+			}
+		}
+
 		/* fill the hooks */
 		nor->read_reg = fsl_qspi_read_reg;
 		nor->write_reg = fsl_qspi_write_reg;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v6 2/2] dt-bindings: fsl-quadspi: Add the example of two SPI NOR
  2018-01-18 14:28 [PATCH v6 1/2] mtd: fsl-quadspi: Distinguish the mtd device names Fabio Estevam
@ 2018-01-18 14:28 ` Fabio Estevam
  2018-01-18 17:24   ` Han Xu
  2018-01-18 17:23 ` [PATCH v6 1/2] mtd: fsl-quadspi: Distinguish the mtd device names Han Xu
  2018-01-25 10:20 ` Fabio Estevam
  2 siblings, 1 reply; 7+ messages in thread
From: Fabio Estevam @ 2018-01-18 14:28 UTC (permalink / raw)
  To: boris.brezillon; +Cc: linux-mtd, han.xu, david.wolfe, Fabio Estevam

Improve the bindings example by adding an example of how to represent
two SPI NOR devices.

Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
---
Changes since v5:
- None

 .../devicetree/bindings/mtd/fsl-quadspi.txt        | 24 ++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/Documentation/devicetree/bindings/mtd/fsl-quadspi.txt b/Documentation/devicetree/bindings/mtd/fsl-quadspi.txt
index 63d4d626..483e9cf 100644
--- a/Documentation/devicetree/bindings/mtd/fsl-quadspi.txt
+++ b/Documentation/devicetree/bindings/mtd/fsl-quadspi.txt
@@ -39,3 +39,27 @@ qspi0: quadspi@40044000 {
 		....
 	};
 };
+
+Example showing the usage of two SPI NOR devices:
+
+&qspi2 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_qspi2>;
+	status = "okay";
+
+	flash0: n25q256a@0 {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		compatible = "micron,n25q256a", "jedec,spi-nor";
+		spi-max-frequency = <29000000>;
+		reg = <0>;
+	};
+
+	flash1: n25q256a@1 {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		compatible = "micron,n25q256a", "jedec,spi-nor";
+		spi-max-frequency = <29000000>;
+		reg = <1>;
+	};
+};
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v6 1/2] mtd: fsl-quadspi: Distinguish the mtd device names
  2018-01-18 14:28 [PATCH v6 1/2] mtd: fsl-quadspi: Distinguish the mtd device names Fabio Estevam
  2018-01-18 14:28 ` [PATCH v6 2/2] dt-bindings: fsl-quadspi: Add the example of two SPI NOR Fabio Estevam
@ 2018-01-18 17:23 ` Han Xu
  2018-01-25 10:20 ` Fabio Estevam
  2 siblings, 0 replies; 7+ messages in thread
From: Han Xu @ 2018-01-18 17:23 UTC (permalink / raw)
  To: Fabio Estevam, boris.brezillon; +Cc: linux-mtd, David Wolfe


________________________________________
From: Fabio Estevam <fabio.estevam@nxp.com>
Sent: Thursday, January 18, 2018 8:28 AM
To: boris.brezillon@free-electrons.com
Cc: linux-mtd@lists.infradead.org; Han Xu; David Wolfe; Fabio Estevam
Subject: [PATCH v6 1/2] mtd: fsl-quadspi: Distinguish the mtd device names

Currently on a imx6sx-sdb board, which has two SPI NOR chips connected
to QSPI2 the following output from /proc/mtd is seen:

# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 01000000 00010000 "21e4000.qspi"
mtd1: 01000000 00010000 "21e4000.qspi"

Attempts to partition them on the kernel command line result in both
chips with identical (and identically named) partitions, which is
an inconvenient behavior.

Assign a different mtd->name for each mtd device to avoid this problem.

After this change the output from /proc/mtd becomes:

# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 01000000 00010000 "21e4000.qspi-0"
mtd1: 01000000 00010000 "21e4000.qspi-1"

In order to keep mtdparts compatibility keep the mtd->name
unchanged when a single SPI NOR is present.

Reported-by: David Wolfe <david.wolfe@nxp.com>
Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
---
Changes since v5:
- Preserve the label value, if any. (Boris)

 drivers/mtd/spi-nor/fsl-quadspi.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/mtd/spi-nor/fsl-quadspi.c b/drivers/mtd/spi-nor/fsl-quadspi.c
index 2901c7b..1038842 100644
--- a/drivers/mtd/spi-nor/fsl-quadspi.c
+++ b/drivers/mtd/spi-nor/fsl-quadspi.c
@@ -1051,6 +1051,24 @@ static int fsl_qspi_probe(struct platform_device *pdev)
                spi_nor_set_flash_node(nor, np);
                nor->priv = q;

+               if (q->nor_num > 1 && !mtd->name) {
+                       int spiflash_idx;
+
+                       ret = of_property_read_u32(np, "reg", &spiflash_idx);
+                       if (!ret) {
+                               mtd->name = devm_kasprintf(dev, GFP_KERNEL,
+                                                          "%s-%d",
+                                                          dev_name(dev),
+                                                          spiflash_idx);
+                               if (!mtd->name) {
+                                       ret = -ENOMEM;
+                                       goto mutex_failed;
+                               }
+                       } else {
+                               dev_warn(dev, "reg property is missing\n");
+                       }
+               }
+
                /* fill the hooks */
                nor->read_reg = fsl_qspi_read_reg;
                nor->write_reg = fsl_qspi_write_reg;
--
2.7.4

Acked-by: Han Xu <han.xu@nxp.com>

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v6 2/2] dt-bindings: fsl-quadspi: Add the example of two SPI NOR
  2018-01-18 14:28 ` [PATCH v6 2/2] dt-bindings: fsl-quadspi: Add the example of two SPI NOR Fabio Estevam
@ 2018-01-18 17:24   ` Han Xu
  0 siblings, 0 replies; 7+ messages in thread
From: Han Xu @ 2018-01-18 17:24 UTC (permalink / raw)
  To: Fabio Estevam, boris.brezillon; +Cc: linux-mtd, David Wolfe


________________________________________
From: Fabio Estevam <fabio.estevam@nxp.com>
Sent: Thursday, January 18, 2018 8:28 AM
To: boris.brezillon@free-electrons.com
Cc: linux-mtd@lists.infradead.org; Han Xu; David Wolfe; Fabio Estevam
Subject: [PATCH v6 2/2] dt-bindings: fsl-quadspi: Add the example of two SPI NOR

Improve the bindings example by adding an example of how to represent
two SPI NOR devices.

Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
---
Changes since v5:
- None

 .../devicetree/bindings/mtd/fsl-quadspi.txt        | 24 ++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/Documentation/devicetree/bindings/mtd/fsl-quadspi.txt b/Documentation/devicetree/bindings/mtd/fsl-quadspi.txt
index 63d4d626..483e9cf 100644
--- a/Documentation/devicetree/bindings/mtd/fsl-quadspi.txt
+++ b/Documentation/devicetree/bindings/mtd/fsl-quadspi.txt
@@ -39,3 +39,27 @@ qspi0: quadspi@40044000 {
                ....
        };
 };
+
+Example showing the usage of two SPI NOR devices:
+
+&qspi2 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_qspi2>;
+       status = "okay";
+
+       flash0: n25q256a@0 {
+               #address-cells = <1>;
+               #size-cells = <1>;
+               compatible = "micron,n25q256a", "jedec,spi-nor";
+               spi-max-frequency = <29000000>;
+               reg = <0>;
+       };
+
+       flash1: n25q256a@1 {
+               #address-cells = <1>;
+               #size-cells = <1>;
+               compatible = "micron,n25q256a", "jedec,spi-nor";
+               spi-max-frequency = <29000000>;
+               reg = <1>;
+       };
+};
--
2.7.4

Acked-by: Han Xu <han.xu@nxp.com>

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v6 1/2] mtd: fsl-quadspi: Distinguish the mtd device names
  2018-01-18 14:28 [PATCH v6 1/2] mtd: fsl-quadspi: Distinguish the mtd device names Fabio Estevam
  2018-01-18 14:28 ` [PATCH v6 2/2] dt-bindings: fsl-quadspi: Add the example of two SPI NOR Fabio Estevam
  2018-01-18 17:23 ` [PATCH v6 1/2] mtd: fsl-quadspi: Distinguish the mtd device names Han Xu
@ 2018-01-25 10:20 ` Fabio Estevam
  2018-01-25 10:33   ` Boris Brezillon
  2 siblings, 1 reply; 7+ messages in thread
From: Fabio Estevam @ 2018-01-25 10:20 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: Boris Brezillon, Han Xu, linux-mtd, David Wolfe

Hi Boris,

On Thu, Jan 18, 2018 at 12:28 PM, Fabio Estevam <fabio.estevam@nxp.com> wrote:
> Currently on a imx6sx-sdb board, which has two SPI NOR chips connected
> to QSPI2 the following output from /proc/mtd is seen:
>
> # cat /proc/mtd
> dev:    size   erasesize  name
> mtd0: 01000000 00010000 "21e4000.qspi"
> mtd1: 01000000 00010000 "21e4000.qspi"
>
> Attempts to partition them on the kernel command line result in both
> chips with identical (and identically named) partitions, which is
> an inconvenient behavior.
>
> Assign a different mtd->name for each mtd device to avoid this problem.
>
> After this change the output from /proc/mtd becomes:
>
> # cat /proc/mtd
> dev:    size   erasesize  name
> mtd0: 01000000 00010000 "21e4000.qspi-0"
> mtd1: 01000000 00010000 "21e4000.qspi-1"
>
> In order to keep mtdparts compatibility keep the mtd->name
> unchanged when a single SPI NOR is present.
>
> Reported-by: David Wolfe <david.wolfe@nxp.com>
> Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
> Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> ---
> Changes since v5:
> - Preserve the label value, if any. (Boris)

Do you plan to apply this one for 4.17?

Thanks

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v6 1/2] mtd: fsl-quadspi: Distinguish the mtd device names
  2018-01-25 10:20 ` Fabio Estevam
@ 2018-01-25 10:33   ` Boris Brezillon
  2018-01-25 10:40     ` Fabio Estevam
  0 siblings, 1 reply; 7+ messages in thread
From: Boris Brezillon @ 2018-01-25 10:33 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: Fabio Estevam, Han Xu, linux-mtd, David Wolfe

On Thu, 25 Jan 2018 08:20:59 -0200
Fabio Estevam <festevam@gmail.com> wrote:

> Hi Boris,
> 
> On Thu, Jan 18, 2018 at 12:28 PM, Fabio Estevam <fabio.estevam@nxp.com> wrote:
> > Currently on a imx6sx-sdb board, which has two SPI NOR chips connected
> > to QSPI2 the following output from /proc/mtd is seen:
> >
> > # cat /proc/mtd
> > dev:    size   erasesize  name
> > mtd0: 01000000 00010000 "21e4000.qspi"
> > mtd1: 01000000 00010000 "21e4000.qspi"
> >
> > Attempts to partition them on the kernel command line result in both
> > chips with identical (and identically named) partitions, which is
> > an inconvenient behavior.
> >
> > Assign a different mtd->name for each mtd device to avoid this problem.
> >
> > After this change the output from /proc/mtd becomes:
> >
> > # cat /proc/mtd
> > dev:    size   erasesize  name
> > mtd0: 01000000 00010000 "21e4000.qspi-0"
> > mtd1: 01000000 00010000 "21e4000.qspi-1"
> >
> > In order to keep mtdparts compatibility keep the mtd->name
> > unchanged when a single SPI NOR is present.
> >
> > Reported-by: David Wolfe <david.wolfe@nxp.com>
> > Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
> > Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> > ---
> > Changes since v5:
> > - Preserve the label value, if any. (Boris)  
> 
> Do you plan to apply this one for 4.17?

I'm not applying spi-nor patches, and Cyrille already sent me his PR
for 4.16. So yes, I'd say it will be queued for 4.17. Is this a problem?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v6 1/2] mtd: fsl-quadspi: Distinguish the mtd device names
  2018-01-25 10:33   ` Boris Brezillon
@ 2018-01-25 10:40     ` Fabio Estevam
  0 siblings, 0 replies; 7+ messages in thread
From: Fabio Estevam @ 2018-01-25 10:40 UTC (permalink / raw)
  To: Boris Brezillon, cyrille.pitchen
  Cc: Fabio Estevam, Han Xu, linux-mtd, David Wolfe

Hi Boris,

On Thu, Jan 25, 2018 at 8:33 AM, Boris Brezillon
<boris.brezillon@free-electrons.com> wrote:

> I'm not applying spi-nor patches, and Cyrille already sent me his PR
> for 4.16. So yes, I'd say it will be queued for 4.17. Is this a problem?

No problem. Thanks for the clarification.

Cyrille, I missed to add you on Cc on v6. Should I resend it with you on Cc?

Thanks

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-01-25 10:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-18 14:28 [PATCH v6 1/2] mtd: fsl-quadspi: Distinguish the mtd device names Fabio Estevam
2018-01-18 14:28 ` [PATCH v6 2/2] dt-bindings: fsl-quadspi: Add the example of two SPI NOR Fabio Estevam
2018-01-18 17:24   ` Han Xu
2018-01-18 17:23 ` [PATCH v6 1/2] mtd: fsl-quadspi: Distinguish the mtd device names Han Xu
2018-01-25 10:20 ` Fabio Estevam
2018-01-25 10:33   ` Boris Brezillon
2018-01-25 10:40     ` Fabio Estevam

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.