2022-06-03 15:49:05

by Tom Fitzhenry

[permalink] [raw]
Subject: [PATCH v2] mtd: spi-nor: siliconkaiser: add support for sk25lp128

Add support for the siliconkaiser sk25lp128 chip.

This is the flash chip used in the PinePhone Pro[0], found by physical
inspection of the board.[1]

I cannot find a datasheet, but this chip supports SFDP.

This patch depends on SNOR_ID3().[2]

Tested done: checked that the Pinephone Pro boots when a ROM is written to
/dev/mtdblock0.

$ xxd -p /sys/bus/spi/devices/spi0.0/spi-nor/sfdp
53464450060101ff00060110300000ff9d05010380000002ffffffffffff
ffffffffffffffffffffffffffffffffffffe520f9ffffffff0744eb086b
083b80bbfeffffffffff00ffffff44eb0c200f5210d800ff234ac90082d8
11c7cccd68467a757a75f7a2d55c4a422cfff030c080ffffffffffffffff
ffffffffffffffff501950169cf9c0648fecffff
$ md5sum /sys/bus/spi/devices/spi0.0/spi-nor/sfdp
de4d6be54e479d60859b0ca8a0ee9216
/sys/bus/spi/devices/spi0.0/spi-nor/sfdp
$ cat /sys/bus/spi/devices/spi0.0/spi-nor/jedec_id
257018
$ cat /sys/bus/spi/devices/spi0.0/spi-nor/partname
sk25lp128
$ cat /sys/bus/spi/devices/spi0.0/spi-nor/manufacturer
siliconkaiser

0. https://wiki.pine64.org/wiki/PinePhone_Pro#Specifications
1. Thanks to https://github.com/Biktorgj for finding that.
2. https://lore.kernel.org/all/[email protected]/

Link: https://lore.kernel.org/all/[email protected]/
Signed-off-by: Tom Fitzhenry <[email protected]>
---
drivers/mtd/spi-nor/Makefile | 1 +
drivers/mtd/spi-nor/core.c | 1 +
drivers/mtd/spi-nor/core.h | 1 +
drivers/mtd/spi-nor/siliconkaiser.c | 15 +++++++++++++++
4 files changed, 18 insertions(+)
create mode 100644 drivers/mtd/spi-nor/siliconkaiser.c

diff --git a/drivers/mtd/spi-nor/Makefile b/drivers/mtd/spi-nor/Makefile
index e347b435a038..314ac7773369 100644
--- a/drivers/mtd/spi-nor/Makefile
+++ b/drivers/mtd/spi-nor/Makefile
@@ -12,6 +12,7 @@ spi-nor-objs += intel.o
spi-nor-objs += issi.o
spi-nor-objs += macronix.o
spi-nor-objs += micron-st.o
+spi-nor-objs += siliconkaiser.o
spi-nor-objs += spansion.o
spi-nor-objs += sst.o
spi-nor-objs += winbond.o
diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index fdde80d9f388..e542d3009915 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -1624,6 +1624,7 @@ static const struct spi_nor_manufacturer *manufacturers[] = {
&spi_nor_issi,
&spi_nor_macronix,
&spi_nor_micron,
+ &spi_nor_siliconkaiser,
&spi_nor_st,
&spi_nor_spansion,
&spi_nor_sst,
diff --git a/drivers/mtd/spi-nor/core.h b/drivers/mtd/spi-nor/core.h
index 87183cff3251..8997099f6c5e 100644
--- a/drivers/mtd/spi-nor/core.h
+++ b/drivers/mtd/spi-nor/core.h
@@ -625,6 +625,7 @@ extern const struct spi_nor_manufacturer spi_nor_intel;
extern const struct spi_nor_manufacturer spi_nor_issi;
extern const struct spi_nor_manufacturer spi_nor_macronix;
extern const struct spi_nor_manufacturer spi_nor_micron;
+extern const struct spi_nor_manufacturer spi_nor_siliconkaiser;
extern const struct spi_nor_manufacturer spi_nor_st;
extern const struct spi_nor_manufacturer spi_nor_spansion;
extern const struct spi_nor_manufacturer spi_nor_sst;
diff --git a/drivers/mtd/spi-nor/siliconkaiser.c b/drivers/mtd/spi-nor/siliconkaiser.c
new file mode 100644
index 000000000000..c3ca157244b8
--- /dev/null
+++ b/drivers/mtd/spi-nor/siliconkaiser.c
@@ -0,0 +1,15 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include <linux/mtd/spi-nor.h>
+
+#include "core.h"
+
+static const struct flash_info siliconkaiser_nor_parts[] = {
+ { "sk25lp128", SNOR_ID3(0x257018) },
+};
+
+const struct spi_nor_manufacturer spi_nor_siliconkaiser = {
+ .name = "siliconkaiser",
+ .parts = siliconkaiser_nor_parts,
+ .nparts = ARRAY_SIZE(siliconkaiser_nor_parts),
+};
--
2.36.0


2022-07-21 08:10:24

by Tudor Ambarus

[permalink] [raw]
Subject: Re: [PATCH v2] mtd: spi-nor: siliconkaiser: add support for sk25lp128

On 6/3/22 17:16, Tom Fitzhenry wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
>
> Add support for the siliconkaiser sk25lp128 chip.
>
> This is the flash chip used in the PinePhone Pro[0], found by physical
> inspection of the board.[1]
>
> I cannot find a datasheet, but this chip supports SFDP.
>
> This patch depends on SNOR_ID3().[2]
>
> Tested done: checked that the Pinephone Pro boots when a ROM is written to
> /dev/mtdblock0.
>
> $ xxd -p /sys/bus/spi/devices/spi0.0/spi-nor/sfdp
> 53464450060101ff00060110300000ff9d05010380000002ffffffffffff
> ffffffffffffffffffffffffffffffffffffe520f9ffffffff0744eb086b
> 083b80bbfeffffffffff00ffffff44eb0c200f5210d800ff234ac90082d8
> 11c7cccd68467a757a75f7a2d55c4a422cfff030c080ffffffffffffffff
> ffffffffffffffff501950169cf9c0648fecffff
> $ md5sum /sys/bus/spi/devices/spi0.0/spi-nor/sfdp
> de4d6be54e479d60859b0ca8a0ee9216
> /sys/bus/spi/devices/spi0.0/spi-nor/sfdp
> $ cat /sys/bus/spi/devices/spi0.0/spi-nor/jedec_id
> 257018
> $ cat /sys/bus/spi/devices/spi0.0/spi-nor/partname
> sk25lp128
> $ cat /sys/bus/spi/devices/spi0.0/spi-nor/manufacturer
> siliconkaiser
>
> 0. https://wiki.pine64.org/wiki/PinePhone_Pro#Specifications
> 1. Thanks to https://github.com/Biktorgj for finding that.
> 2. https://lore.kernel.org/all/[email protected]/
>
> Link: https://lore.kernel.org/all/[email protected]/
> Signed-off-by: Tom Fitzhenry <[email protected]>
> ---
> drivers/mtd/spi-nor/Makefile | 1 +
> drivers/mtd/spi-nor/core.c | 1 +
> drivers/mtd/spi-nor/core.h | 1 +
> drivers/mtd/spi-nor/siliconkaiser.c | 15 +++++++++++++++
> 4 files changed, 18 insertions(+)
> create mode 100644 drivers/mtd/spi-nor/siliconkaiser.c
>
> diff --git a/drivers/mtd/spi-nor/Makefile b/drivers/mtd/spi-nor/Makefile
> index e347b435a038..314ac7773369 100644
> --- a/drivers/mtd/spi-nor/Makefile
> +++ b/drivers/mtd/spi-nor/Makefile
> @@ -12,6 +12,7 @@ spi-nor-objs += intel.o
> spi-nor-objs += issi.o
> spi-nor-objs += macronix.o
> spi-nor-objs += micron-st.o
> +spi-nor-objs += siliconkaiser.o
> spi-nor-objs += spansion.o
> spi-nor-objs += sst.o
> spi-nor-objs += winbond.o
> diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
> index fdde80d9f388..e542d3009915 100644
> --- a/drivers/mtd/spi-nor/core.c
> +++ b/drivers/mtd/spi-nor/core.c
> @@ -1624,6 +1624,7 @@ static const struct spi_nor_manufacturer *manufacturers[] = {
> &spi_nor_issi,
> &spi_nor_macronix,
> &spi_nor_micron,
> + &spi_nor_siliconkaiser,
> &spi_nor_st,
> &spi_nor_spansion,
> &spi_nor_sst,
> diff --git a/drivers/mtd/spi-nor/core.h b/drivers/mtd/spi-nor/core.h
> index 87183cff3251..8997099f6c5e 100644
> --- a/drivers/mtd/spi-nor/core.h
> +++ b/drivers/mtd/spi-nor/core.h
> @@ -625,6 +625,7 @@ extern const struct spi_nor_manufacturer spi_nor_intel;
> extern const struct spi_nor_manufacturer spi_nor_issi;
> extern const struct spi_nor_manufacturer spi_nor_macronix;
> extern const struct spi_nor_manufacturer spi_nor_micron;
> +extern const struct spi_nor_manufacturer spi_nor_siliconkaiser;
> extern const struct spi_nor_manufacturer spi_nor_st;
> extern const struct spi_nor_manufacturer spi_nor_spansion;
> extern const struct spi_nor_manufacturer spi_nor_sst;
> diff --git a/drivers/mtd/spi-nor/siliconkaiser.c b/drivers/mtd/spi-nor/siliconkaiser.c
> new file mode 100644
> index 000000000000..c3ca157244b8
> --- /dev/null
> +++ b/drivers/mtd/spi-nor/siliconkaiser.c
> @@ -0,0 +1,15 @@
> +// SPDX-License-Identifier: GPL-2.0
> +
> +#include <linux/mtd/spi-nor.h>
> +
> +#include "core.h"
> +
> +static const struct flash_info siliconkaiser_nor_parts[] = {
> + { "sk25lp128", SNOR_ID3(0x257018) },

Does this flash implement the manufacturer ID continuation codes?
Can you read more bytes of manufacturer ID and dump them?

This manufacturer ID collides with Tristar manufacturer ID from bank 1.
Check JEP106 standard please.
If the flash does not define the continuation codes, we'll need to
add this flash in a ID collisions driver.

ta

> +};
> +
> +const struct spi_nor_manufacturer spi_nor_siliconkaiser = {
> + .name = "siliconkaiser",
> + .parts = siliconkaiser_nor_parts,
> + .nparts = ARRAY_SIZE(siliconkaiser_nor_parts),
> +};
> --
> 2.36.0
>

2022-08-06 15:57:35

by Tom Fitzhenry

[permalink] [raw]
Subject: Re: [PATCH v2] mtd: spi-nor: siliconkaiser: add support for sk25lp128

On 21/7/22 18:08, [email protected] wrote:
> Does this flash implement the manufacturer ID continuation codes?
> Can you read more bytes of manufacturer ID and dump them?

I'm not sure how to do this, but from what I can gather, flash chips
that implement manufacturer ID continuation codes return >3 bytes in
response to RDID. Is this correct?

To do this, in tools/spi/spidex_fdx.c I set buf[0] = 0x9F, and then
executed this with a large recvbuf:

$ sudo ./a.out -m 6 /dev/spidev0.0
/dev/spidev0.0: spi mode 0x0, 8 bits per word, 10000000 Hz max
response( 6, 7): 25 70 18 25 70 18

It looks like the 3-byte response has cycled, suggesting this flash chip
does not implement continuation codes.

> If the flash does not define the continuation codes, we'll need to
> add this flash in a ID collisions driver.

I will do this in v3.

2022-08-07 16:02:40

by Tudor Ambarus

[permalink] [raw]
Subject: Re: [PATCH v2] mtd: spi-nor: siliconkaiser: add support for sk25lp128

On 8/6/22 18:22, Tom Fitzhenry wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
>
> On 21/7/22 18:08, [email protected] wrote:
>> Does this flash implement the manufacturer ID continuation codes?
>> Can you read more bytes of manufacturer ID and dump them?
>
> I'm not sure how to do this, but from what I can gather, flash chips
> that implement manufacturer ID continuation codes return >3 bytes in
> response to RDID. Is this correct?
>
> To do this, in tools/spi/spidex_fdx.c I set buf[0] = 0x9F, and then
> executed this with a large recvbuf:
>
> $ sudo ./a.out -m 6 /dev/spidev0.0
> /dev/spidev0.0: spi mode 0x0, 8 bits per word, 10000000 Hz max
> response( 6,  7):  25 70 18 25 70 18

indeed it seems there are no continuation codes.
>
> It looks like the 3-byte response has cycled, suggesting this flash chip
> does not implement continuation codes.
>
>> If the flash does not define the continuation codes, we'll need to
>> add this flash in a ID collisions driver.
>
> I will do this in v3.

Not yet, please. Looks like your flash does not need some special handling,
you used just the SNOR_ID3. If so, then you won't need a flash entry at all,
we can init the flash solely by parsing SFDP. See:
https://lore.kernel.org/linux-mtd/[email protected]/

--
Cheers,
ta