linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] mtd: spi-nor: add ACPI support for non-JEDEC SPI-NOR
@ 2021-01-26 14:37 Flavio Suligoi
  2021-05-31  7:44 ` Michael Walle
  0 siblings, 1 reply; 3+ messages in thread
From: Flavio Suligoi @ 2021-01-26 14:37 UTC (permalink / raw)
  To: Tudor Ambarus, Miquel Raynal, Richard Weinberger, Vignesh Raghavendra
  Cc: linux-mtd, linux-kernel, Flavio Suligoi

In a x86 machine, an additional device can be described
inside the BIOS ACPI tables.
For example, an I2C GPIO expander, a LED, etc.,
can be successfully declared in ACPI, so that the related
device driver can start automatically at the boot.

But for the SPI NOR devices, the ACPI description works
for JEDEC-compatible devices only.

For example, an Everspin MR25H40 MRAM device (non-JEDEC
compatible), declared using the following table,
does not work:

    Scope (\_SB.SPI1)
    {
        Device (NVR0)
        {
            Name (_HID, "PRP0001")
            Name (_DDN, "Everspin MR25H40 MRAM")
            Name (_CRS, ResourceTemplate () {
                SpiSerialBus (
                1,                      // Chip select
                PolarityLow,            // Chip select is active low
                FourWireMode,           // Full duplex
                8,                      // Bits per word is 8 (byte)
                ControllerInitiated,    // Don't care
                10000000,               // 10 MHz
                ClockPolarityLow,       // SPI mode 0 ClockPolarityLow
                ClockPhaseFirst,        // SPI mode 0 ClockPhaseFirst
                "\\_SB.SPI1",           // SPI host controller
                0,                      // Must be 0
                ResourceConsumer,
                ,
                )
            })

            Name (_DSD, Package () {
                ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
                Package () {
                    Package () {"compatible", "mr25h40"},
                }
            })
        }
    }

To enable the detection of a non-JEDEC device described
in a BIOS ACPI table, it is necessary to add its id name
in the spi_nor_of_table structure.
With this change, all the SPI NOR devices (JEDEC and
non-JEDEC) can be detected by the kernel (and the above
example of ACPI table finally works).

Signed-off-by: Flavio Suligoi <f.suligoi@asem.it>
---
 drivers/mtd/spi-nor/core.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index 6ae7d4c2d2b6..b6fb8b15c439 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -3755,6 +3755,19 @@ static const struct of_device_id spi_nor_of_table[] = {
 	 * JEDEC READ ID opcode (0x9F). Use this, if possible.
 	 */
 	{ .compatible = "jedec,spi-nor" },
+	{ .compatible = "m25p05-nonjedec" },
+	{ .compatible = "m25p10-nonjedec" },
+	{ .compatible = "m25p20-nonjedec" },
+	{ .compatible = "m25p40-nonjedec" },
+	{ .compatible = "m25p80-nonjedec" },
+	{ .compatible = "m25p16-nonjedec" },
+	{ .compatible = "m25p32-nonjedec" },
+	{ .compatible = "m25p64-nonjedec" },
+	{ .compatible = "m25p128-nonjedec" },
+	{ .compatible = "mr25h128" },
+	{ .compatible = "mr25h256" },
+	{ .compatible = "mr25h10" },
+	{ .compatible = "mr25h40" },
 	{ /* sentinel */ },
 };
 MODULE_DEVICE_TABLE(of, spi_nor_of_table);
-- 
2.25.1


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

* Re: [PATCH v1] mtd: spi-nor: add ACPI support for non-JEDEC SPI-NOR
  2021-01-26 14:37 [PATCH v1] mtd: spi-nor: add ACPI support for non-JEDEC SPI-NOR Flavio Suligoi
@ 2021-05-31  7:44 ` Michael Walle
  2021-06-01  9:52   ` Flavio Suligoi
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Walle @ 2021-05-31  7:44 UTC (permalink / raw)
  To: f.suligoi
  Cc: linux-kernel, linux-mtd, miquel.raynal, richard, tudor.ambarus,
	vigneshr, michael, Pratyush Yadav

Hi,

> In a x86 machine, an additional device can be described
> inside the BIOS ACPI tables.
> For example, an I2C GPIO expander, a LED, etc.,
> can be successfully declared in ACPI, so that the related
> device driver can start automatically at the boot.
> 
> But for the SPI NOR devices, the ACPI description works
> for JEDEC-compatible devices only.
> 
> For example, an Everspin MR25H40 MRAM device (non-JEDEC
> compatible), declared using the following table,
> does not work:
> 
>     Scope (\_SB.SPI1)
>     {
>         Device (NVR0)
>         {
>             Name (_HID, "PRP0001")
>             Name (_DDN, "Everspin MR25H40 MRAM")
>             Name (_CRS, ResourceTemplate () {
>                 SpiSerialBus (
>                 1,                      // Chip select
>                 PolarityLow,            // Chip select is active low
>                 FourWireMode,           // Full duplex
>                 8,                      // Bits per word is 8 (byte)
>                 ControllerInitiated,    // Don't care
>                 10000000,               // 10 MHz
>                 ClockPolarityLow,       // SPI mode 0 ClockPolarityLow
>                 ClockPhaseFirst,        // SPI mode 0 ClockPhaseFirst
>                 "\\_SB.SPI1",           // SPI host controller
>                 0,                      // Must be 0
>                 ResourceConsumer,
>                 ,
>                 )
>             })
> 
>             Name (_DSD, Package () {
>                 ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
>                 Package () {
>                     Package () {"compatible", "mr25h40"},
>                 }
>             })
>         }
>     }

This isn't the correct compatible string, according to the devicetree
binding [1], there is no compatible = "mr25h40" binding. The correct entry
would be
 compatible = "everspin,mr25h40", "jedec,spi-nor";

I'm not familiar with ACPI and don't know wether you can specify a list,
nor am I convinced that it will work then. But it should be worth a try.

[1] Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml

> 
> To enable the detection of a non-JEDEC device described
> in a BIOS ACPI table, it is necessary to add its id name
> in the spi_nor_of_table structure.
> With this change, all the SPI NOR devices (JEDEC and
> non-JEDEC) can be detected by the kernel (and the above
> example of ACPI table finally works).
> 
> Signed-off-by: Flavio Suligoi <f.suligoi@asem.it>
> ---
>  drivers/mtd/spi-nor/core.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
> index 6ae7d4c2d2b6..b6fb8b15c439 100644
> --- a/drivers/mtd/spi-nor/core.c
> +++ b/drivers/mtd/spi-nor/core.c
> @@ -3755,6 +3755,19 @@ static const struct of_device_id spi_nor_of_table[] = {
>  	 * JEDEC READ ID opcode (0x9F). Use this, if possible.
>  	 */
>  	{ .compatible = "jedec,spi-nor" },
> +	{ .compatible = "m25p05-nonjedec" },
> +	{ .compatible = "m25p10-nonjedec" },
> +	{ .compatible = "m25p20-nonjedec" },
> +	{ .compatible = "m25p40-nonjedec" },
> +	{ .compatible = "m25p80-nonjedec" },
> +	{ .compatible = "m25p16-nonjedec" },
> +	{ .compatible = "m25p32-nonjedec" },
> +	{ .compatible = "m25p64-nonjedec" },
> +	{ .compatible = "m25p128-nonjedec" },
> +	{ .compatible = "mr25h128" },
> +	{ .compatible = "mr25h256" },
> +	{ .compatible = "mr25h10" },
> +	{ .compatible = "mr25h40" },
>  	{ /* sentinel */ },
>  };
>  MODULE_DEVICE_TABLE(of, spi_nor_of_table);
> -- 
> 2.25.1

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

* RE: [PATCH v1] mtd: spi-nor: add ACPI support for non-JEDEC SPI-NOR
  2021-05-31  7:44 ` Michael Walle
@ 2021-06-01  9:52   ` Flavio Suligoi
  0 siblings, 0 replies; 3+ messages in thread
From: Flavio Suligoi @ 2021-06-01  9:52 UTC (permalink / raw)
  To: Michael Walle
  Cc: linux-kernel, linux-mtd, miquel.raynal, richard, tudor.ambarus,
	vigneshr, Pratyush Yadav

Hi Michael,

...
> 
> > In a x86 machine, an additional device can be described
> > inside the BIOS ACPI tables.
> > For example, an I2C GPIO expander, a LED, etc.,
> > can be successfully declared in ACPI, so that the related
> > device driver can start automatically at the boot.
> >
> > But for the SPI NOR devices, the ACPI description works
> > for JEDEC-compatible devices only.
> >
> > For example, an Everspin MR25H40 MRAM device (non-JEDEC
> > compatible), declared using the following table,
> > does not work:
> >
> >     Scope (\_SB.SPI1)
> >     {
> >         Device (NVR0)
> >         {
> >             Name (_HID, "PRP0001")
> >             Name (_DDN, "Everspin MR25H40 MRAM")
> >             Name (_CRS, ResourceTemplate () {
> >                 SpiSerialBus (
> >                 1,                      // Chip select
> >                 PolarityLow,            // Chip select is active low
> >                 FourWireMode,           // Full duplex
> >                 8,                      // Bits per word is 8 (byte)
> >                 ControllerInitiated,    // Don't care
> >                 10000000,               // 10 MHz
> >                 ClockPolarityLow,       // SPI mode 0 ClockPolarityLow
> >                 ClockPhaseFirst,        // SPI mode 0 ClockPhaseFirst
> >                 "\\_SB.SPI1",           // SPI host controller
> >                 0,                      // Must be 0
> >                 ResourceConsumer,
> >                 ,
> >                 )
> >             })
> >
> >             Name (_DSD, Package () {
> >                 ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
> >                 Package () {
> >                     Package () {"compatible", "mr25h40"},
> >                 }
> >             })
> >         }
> >     }
> 
> This isn't the correct compatible string, according to the devicetree
> binding [1], there is no compatible = "mr25h40" binding. The correct entry
> would be
>  compatible = "everspin,mr25h40", "jedec,spi-nor";
> 
> I'm not familiar with ACPI and don't know wether you can specify a list,
> nor am I convinced that it will work then. But it should be worth a try.

It works on our board with our custom BIOS.
I'm currently use this patch for the kernel of our x86 machines.
And that's is the only way I've found to describe the mr25h40 MRAM
presence in our BIOS.
Obviously, it works because of the above ACPI description is built-in
inside the custom BIOS of our boards.
Note that the mr25h40 is NOT jedec compatible.

> 
> [1] Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml
> 
> >
> > To enable the detection of a non-JEDEC device described
> > in a BIOS ACPI table, it is necessary to add its id name
> > in the spi_nor_of_table structure.
> > With this change, all the SPI NOR devices (JEDEC and
> > non-JEDEC) can be detected by the kernel (and the above
> > example of ACPI table finally works).
> >
> > Signed-off-by: Flavio Suligoi <f.suligoi@asem.it>
> > ---
> >  drivers/mtd/spi-nor/core.c | 13 +++++++++++++
> >  1 file changed, 13 insertions(+)
> >
> > diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
> > index 6ae7d4c2d2b6..b6fb8b15c439 100644
> > --- a/drivers/mtd/spi-nor/core.c
> > +++ b/drivers/mtd/spi-nor/core.c
> > @@ -3755,6 +3755,19 @@ static const struct of_device_id
> spi_nor_of_table[] = {
> >  	 * JEDEC READ ID opcode (0x9F). Use this, if possible.
> >  	 */
> >  	{ .compatible = "jedec,spi-nor" },
> > +	{ .compatible = "m25p05-nonjedec" },
> > +	{ .compatible = "m25p10-nonjedec" },
> > +	{ .compatible = "m25p20-nonjedec" },
> > +	{ .compatible = "m25p40-nonjedec" },
> > +	{ .compatible = "m25p80-nonjedec" },
> > +	{ .compatible = "m25p16-nonjedec" },
> > +	{ .compatible = "m25p32-nonjedec" },
> > +	{ .compatible = "m25p64-nonjedec" },
> > +	{ .compatible = "m25p128-nonjedec" },
> > +	{ .compatible = "mr25h128" },
> > +	{ .compatible = "mr25h256" },
> > +	{ .compatible = "mr25h10" },
> > +	{ .compatible = "mr25h40" },
> >  	{ /* sentinel */ },
> >  };
> >  MODULE_DEVICE_TABLE(of, spi_nor_of_table);
> > --
> > 2.25.1

Thank you very much for your suggestions,
Flavio

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

end of thread, other threads:[~2021-06-01  9:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-26 14:37 [PATCH v1] mtd: spi-nor: add ACPI support for non-JEDEC SPI-NOR Flavio Suligoi
2021-05-31  7:44 ` Michael Walle
2021-06-01  9:52   ` Flavio Suligoi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).