diff mbox series

[v5,6/6] mtd: spi-nor: add support for Macronix Octal flash

Message ID 20231117083853.33329-7-jaimeliao.tw@gmail.com
State Changes Requested
Delegated to: Michael Walle
Headers show
Series Add octal DTR support for Macronix flash | expand

Commit Message

liao jaime Nov. 17, 2023, 8:38 a.m. UTC
From: JaimeLiao <jaimeliao@mxic.com.tw>

Adding Macronix Octal flash for Octal DTR support.

The octaflash series can be divided into the following types:

MX25 series : Serial NOR Flash.
MX66 series : Serial NOR Flash with stacked die.(Size larger than 1Gb)
LM/UM series : Up to 250MHz clock frequency with both DTR/STR operation.
LW/UW series : Support simultaneous Read-while-Write operation in multiple
               bank architecture. Read-while-write feature which means read
               data one bank while another bank is programing or erasing.

MX25LM : 3.0V Octal I/O
 -https://www.mxic.com.tw/Lists/Datasheet/Attachments/8729/MX25LM51245G,%203V,%20512Mb,%20v1.1.pdf

MX25UM : 1.8V Octal I/O
 -https://www.mxic.com.tw/Lists/Datasheet/Attachments/8967/MX25UM51245G,%201.8V,%20512Mb,%20v1.5.pdf

MX66LM : 3.0V Octal I/O with stacked die
 -https://www.mxic.com.tw/Lists/Datasheet/Attachments/8748/MX66LM1G45G,%203V,%201Gb,%20v1.1.pdf

MX66UM : 1.8V Octal I/O with stacked die
 -https://www.mxic.com.tw/Lists/Datasheet/Attachments/8711/MX66UM1G45G,%201.8V,%201Gb,%20v1.1.pdf

MX25LW : 3.0V Octal I/O with Read-while-Write
MX25UW : 1.8V Octal I/O with Read-while-Write
MX66LW : 3.0V Octal I/O with Read-while-Write and stack die
MX66UW : 1.8V Octal I/O with Read-while-Write and stack die

As below are the SFDP table dump.

zynq> cat jedec_id
c28339
zynq> cat manufacturer
macronix
zynq> cat partname
mx25um25345g
zynq> xxd -p sfdp
53464450080104fd00070114400000ff8701011c900000ff0a0001080001
00ff05000105200100ff84000102340100ff0000000000000000ffffffff
ffffffffe5208affffffff0f00ff00ff00ff00ffeeffffffffff00ffffff
00ff0c2010d800ff00ff87690100821200d2cc02673830b030b0f4bdd55c
000000ff101000200000000000007c234800000000008888000000000000
00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8
727103b80000000090a3188200c069960000000000000000727100987271
00b8727100990000000072710098727100f872710099727100f900000000
00000000011501d0727106d8000086500000060100000000020001030002
00000000060100000000000072060002000000eec0697272717100d8f7f6
040900001445988043060f0021dcffff
zynq> md5sum sfdp
950e623745a002e1747008592e6dbdf9  sfdp
zynq> mtd_debug info /dev/mtd0
mtd.type = MTD_NORFLASH
mtd.flags = MTD_CAP_NORFLASH
mtd.size = 33554432 (32M)
mtd.erasesize = 4096 (4K)
mtd.writesize = 1
mtd.oobsize = 0
regions = 0

zynq> cat jedec_id
c28039
zynq> cat manufacturer
macronix
zynq> cat partname
mx25um25645g
zynq> xxd -p sfdp
53464450080104fd00070114400000ff8701011c900000ff0a0001080001
00ff05000105200100ff84000102340100ff0000000000000000ffffffff
ffffffffe5208affffffff0f00ff00ff00ff00ffeeffffffffff00ffffff
00ff0c2010d800ff00ff87790100841200d2cc02673830b030b0f4bdd55c
000000ff101000200000000000007ca34800000000008888000000000000
00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8
727103b80000000090a3188200c069960000000000000000727100987271
00b8727100990000000072710098727100f872710099727100f900000000
00000000011501d0727106d8000086500000060100000000020001030002
00000000060100000000000072060002000000eec0697272717100d8f7f6
000a000014359c8043060f0021dcffff
zynq> md5sum sfdp
d652779f17770dc833cd96262cb2a620  sfdp
zynq> mtd_debug info /dev/mtd0
mtd.type = MTD_NORFLASH
mtd.flags = MTD_CAP_NORFLASH
mtd.size = 33554432 (32M)
mtd.erasesize = 4096 (4K)
mtd.writesize = 1
mtd.oobsize = 0
regions = 0

zynq> cat jedec_id
c28539
zynq> cat manufacturer
macronix
zynq> cat partname
mx25lm25645g
zynq> xxd -p sfdp
53464450080104fd00070114400000ff8701011c900000ff0a0001080001
00ff05000105200100ff84000102340100ff0000000000000000ffffffff
ffffffffe5208affffffff0f00ff00ff00ff00ffeeffffffffff00ffffff
00ff0c2010d800ff00ff87690100821200d2cc02673830b030b0f4bdd55c
000000ff101000200000000000007ca34800000000006666000000000000
00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8
727103b80000000090a3188200c069960000000000000000727100987271
00b8727100990000000072710098727100f872710099727100f900000000
00000000011501d0727106d8000086500000060100000000020001030002
00000000060100000000000072060002000000eec0697272717100d8f7f6
0000000014351c0043060f0021dcffff
zynq> md5sum sfdp
ec258f831ac737454c7eb9f6a8a4495a  sfdp
zynq> mtd_debug info /dev/mtd0
mtd.type = MTD_NORFLASH
mtd.flags = MTD_CAP_NORFLASH
mtd.size = 33554432 (32M)
mtd.erasesize = 4096 (4K)
mtd.writesize = 1
mtd.oobsize = 0
regions = 0

zynq> cat jedec_id
c2803a
zynq> cat manufacturer
macronix
zynq> cat partname
mx25um51245g
zynq> xxd -p sfdp
53464450080104fd00070114400000ff8701011c900000ff0a0001080001
00ff05000105200100ff84000102340100ff0000000000000000ffffffff
ffffffffe5208affffffff1f00ff00ff00ff00ffeeffffffffff00ffffff
00ff0c2010d800ff00ff8b7901008f1200e2cc04674630b030b0f4bdd55c
000000ff101000200000000000007ca34800000000008888000000000000
00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8
727103b80000000090a3188200c069960000000000000000727100987271
00b8727100990000000072710098727100f872710099727100f900000000
00000000011501d0727106d8000086500000060100000000020001030002
00000000060100000000000072060002000000eec0697272717100d8f7f6
000a000014359c8043060f0021dcffff
zynq> md5sum sfdp
75d81c1eb2fd2767634f1d0dfbb3be35  sfdp
zynq> mtd_debug info /dev/mtd0
mtd.type = MTD_NORFLASH
mtd.flags = MTD_CAP_NORFLASH
mtd.size = 67108864 (64M)
mtd.erasesize = 4096 (4K)
mtd.writesize = 1
mtd.oobsize = 0
regions = 0

zynq> cat jedec_id
c2853a
zynq> cat manufacturer
macronix
zynq> cat partname
mx25lm51245g
zynq> xxd -p sfdp
53464450080104fd00070114400000ff8701011c900000ff0a0001080001
00ff05000105200100ff84000102340100ff0000000000000000ffffffff
ffffffffe5208affffffff1f00ff00ff00ff00ffeeffffffffff00ffffff
00ff0c2010d800ff00ff897901008d1200e2cc02674430b030b0f4bdd55c
000000ff101000200000000000007ca34800000000006666000000000000
00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8
727103b80000000090a3188200c069960000000000000000727100987271
00b8727100990000000072710098727100f872710099727100f900000000
00000000011501d0727106d8000086500000060100000000020001030002
00000000060100000000000072060002000000eec0697272717100d8f7f6
0000000014351c0043060f0021dcffff
zynq> md5sum sfdp
214868617d74e6bfb2c45444d5d6fff0  sfdp
zynq> mtd_debug info /dev/mtd0
mtd.type = MTD_NORFLASH
mtd.flags = MTD_CAP_NORFLASH
mtd.size = 67108864 (64M)
mtd.erasesize = 4096 (4K)
mtd.writesize = 1
mtd.oobsize = 0
regions = 0

zynq> cat jedec_id
c2803b
zynq> cat manufacturer
macronix
zynq> cat partname
mx66um1g45g
zynq> xxd -p sfdp
53464450080104fd00070114400000ff8701011c900000ff0a0001080001
00ff05000105200100ff84000102340100ff0000000000000000ffffffff
ffffffffe5208affffffff3f00ff00ff00ff00ffeeffffffffff00ffffff
00ff0c2010d800ff00ff897901008d1200e2cc02674430b030b0f4bdd55c
000000ff101000200000000000007ca34800000000008888000000000000
00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8
727103b80000000090a3188200c069960000000000000000727100987271
00b8727100990000000072710098727100f872710099727100f900000000
00000000011501d0727106d8000086500000060100000000020001030002
00000000060100000000000072060002000000eec0697272717100d8f7f6
000a000014359c8043060f0021dcffff
zynq> md5sum sfdp
eea09d64679e64f627402b39a177e356  sfdp
zynq> mtd_debug info /dev/mtd0
mtd.type = MTD_NORFLASH
mtd.flags = MTD_CAP_NORFLASH
mtd.size = 134217728 (128M)
mtd.erasesize = 4096 (4K)
mtd.writesize = 1
mtd.oobsize = 0
regions = 0

zynq> cat jedec_id
c2853b
zynq> cat manufacturer
macronix
zynq> cat partname
mx66lm1g45g
zynq> xxd -p sfdp
53464450080104fd00070114400000ff8701011c900000ff0a0001080001
00ff05000105200100ff84000102340100ff0000000000000000ffffffff
ffffffffe5208affffffff3f00ff00ff00ff00ffeeffffffffff00ffffff
00ff0c2010d800ff00ff87690100821200e2cc02673830b030b0f4bdd55c
000000ff101000200000000000007ca34800000000006666000000000000
00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8
727103b80000000090a3188200c069960000000000000000727100987271
00b8727100990000000072710098727100f872710099727100f900000000
00000000011501d0727106d8000086500000060100000000020001030002
00000000060100000000000072060002000000eec0697272717100d8f7f6
0000000014351c0043060f0021dcffff
zynq> md5sum sfdp
7b46113b529d58a6335531a10f14a76e  sfdp
zynq> mtd_debug info /dev/mtd0
mtd.type = MTD_NORFLASH
mtd.flags = MTD_CAP_NORFLASH
mtd.size = 134217728 (128M)
mtd.erasesize = 4096 (4K)
mtd.writesize = 1
mtd.oobsize = 0
regions = 0

Signed-off-by: JaimeLiao <jaimeliao@mxic.com.tw>
---
 drivers/mtd/spi-nor/macronix.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

Comments

Michael Walle Nov. 17, 2023, 8:57 a.m. UTC | #1
Hi,

> diff --git a/drivers/mtd/spi-nor/macronix.c 
> b/drivers/mtd/spi-nor/macronix.c
> index 48e570c04ad9..2115a25b21ce 100644
> --- a/drivers/mtd/spi-nor/macronix.c
> +++ b/drivers/mtd/spi-nor/macronix.c
> @@ -260,6 +260,27 @@ static const struct flash_info 
> macronix_nor_parts[] = {
>  		.name = "mx66uw2g345gx0",
>  		.n_banks = 4,
>  		.flags = SPI_NOR_RWW,
> +	}, {
> +		.id = SNOR_ID(0xc2, 0x83, 0x39),
> +		.name = "mx25um25345g",
> +	}, {
> +		.id = SNOR_ID(0xc2, 0x80, 0x39),
> +		.name = "mx25um25645g",
> +	}, {
> +		.id = SNOR_ID(0xc2, 0x85, 0x39),
> +		.name = "mx25lm25645g",
> +	}, {
> +		.id = SNOR_ID(0xc2, 0x80, 0x3a),
> +		.name = "mx25um51245g",
> +	}, {
> +		.id = SNOR_ID(0xc2, 0x85, 0x3a),
> +		.name = "mx25lm51245g",
> +	}, {
> +		.id = SNOR_ID(0xc2, 0x80, 0x3b),
> +		.name = "mx66um1g45g",
> +	}, {
> +		.id = SNOR_ID(0xc2, 0x85, 0x3b),
> +		.name = "mx66lm1g45g",

You need this because of the manufacturer fixup, correct? I'd like to
avoid these "empty" entries if possible. The name is useless to the 
kernel
and sometimes incorrect. Therefore, at least drop it and just list the
IDs.

Tudor, Pratyush, what do you think about calling the vendor fixups
by just looking at the JEDEC manufacturer ID *iff* there is no
entry in the flashdb? As a fallback so to speak. That would also
help for the chip erase topic, because I'd presume the chip erase
op is the same among the flashes of one vendor. So there could be
a vendor fixup, to set the chip erase op.

-michael
Tudor Ambarus Nov. 17, 2023, 9:05 a.m. UTC | #2
On 11/17/23 08:57, Michael Walle wrote:
> Hi,
> 
>> diff --git a/drivers/mtd/spi-nor/macronix.c
>> b/drivers/mtd/spi-nor/macronix.c
>> index 48e570c04ad9..2115a25b21ce 100644
>> --- a/drivers/mtd/spi-nor/macronix.c
>> +++ b/drivers/mtd/spi-nor/macronix.c
>> @@ -260,6 +260,27 @@ static const struct flash_info
>> macronix_nor_parts[] = {
>>          .name = "mx66uw2g345gx0",
>>          .n_banks = 4,
>>          .flags = SPI_NOR_RWW,
>> +    }, {
>> +        .id = SNOR_ID(0xc2, 0x83, 0x39),
>> +        .name = "mx25um25345g",
>> +    }, {
>> +        .id = SNOR_ID(0xc2, 0x80, 0x39),
>> +        .name = "mx25um25645g",
>> +    }, {
>> +        .id = SNOR_ID(0xc2, 0x85, 0x39),
>> +        .name = "mx25lm25645g",
>> +    }, {
>> +        .id = SNOR_ID(0xc2, 0x80, 0x3a),
>> +        .name = "mx25um51245g",
>> +    }, {
>> +        .id = SNOR_ID(0xc2, 0x85, 0x3a),
>> +        .name = "mx25lm51245g",
>> +    }, {
>> +        .id = SNOR_ID(0xc2, 0x80, 0x3b),
>> +        .name = "mx66um1g45g",
>> +    }, {
>> +        .id = SNOR_ID(0xc2, 0x85, 0x3b),
>> +        .name = "mx66lm1g45g",
> 
> You need this because of the manufacturer fixup, correct? I'd like to
> avoid these "empty" entries if possible. The name is useless to the kernel
> and sometimes incorrect. Therefore, at least drop it and just list the
> IDs.
> 

I agree.

> Tudor, Pratyush, what do you think about calling the vendor fixups
> by just looking at the JEDEC manufacturer ID *iff* there is no
> entry in the flashdb? As a fallback so to speak. That would also
> help for the chip erase topic, because I'd presume the chip erase
> op is the same among the flashes of one vendor. So there could be
> a vendor fixup, to set the chip erase op.
> 

sounds good!
Tudor Ambarus Nov. 17, 2023, 9:23 a.m. UTC | #3
On 11/17/23 08:38, Jaime Liao wrote:
> Adding Macronix Octal flash for Octal DTR support.

Do all these flashes swap bytes on a 16bit boundary?
Do all these flashes correctly set BFPT_DWORD18_BYTE_ORDER_SWAPPED?

same questions on the previous patch.
Michael Walle Nov. 21, 2023, 8:51 a.m. UTC | #4
Hi Jaime,

[please keep the CC list in replies].

>> and sometimes incorrect. Therefore, at least drop it and just list the
>> IDs.
> Could I know patch 6/6 only or patch 5/6 should remove name as well?

I'd say yes. Tudor? Pratyush? New flash additions without names?

As, mentioned last time, for OF we might introduce an of_compatible
(thats then ABI) - or - we can use the numeric ID in the device tree,
as it's already used for PHY IDs or PCI IDs.

Jaime, could you try to use

/* Apply vendor fixups */
{ .id = SNOR_ID(0xc2) }

-michael
Tudor Ambarus Nov. 21, 2023, 9:09 a.m. UTC | #5
On 11/21/23 08:51, Michael Walle wrote:
> Hi Jaime,
> 
> [please keep the CC list in replies].
> 
>>> and sometimes incorrect. Therefore, at least drop it and just list the
>>> IDs.
>> Could I know patch 6/6 only or patch 5/6 should remove name as well?
> 
> I'd say yes. Tudor? Pratyush? New flash additions without names?

Why do you need a flash addition in the first place? Haven't we agreed
that we'll apply the vendor fixup based on the manufacturer ID?

Anyway, flash additions without names is fine by me.

Cheers,
ta
> 
> As, mentioned last time, for OF we might introduce an of_compatible
> (thats then ABI) - or - we can use the numeric ID in the device tree,
> as it's already used for PHY IDs or PCI IDs.
> 
> Jaime, could you try to use
> 
> /* Apply vendor fixups */
> { .id = SNOR_ID(0xc2) }
> 
> -michael
liao jaime Nov. 22, 2023, 3:15 a.m. UTC | #6
Hi

>
>
>
> On 11/21/23 08:51, Michael Walle wrote:
> > Hi Jaime,
> >
> > [please keep the CC list in replies].
> >
> >>> and sometimes incorrect. Therefore, at least drop it and just list the
> >>> IDs.
> >> Could I know patch 6/6 only or patch 5/6 should remove name as well?
> >
> > I'd say yes. Tudor? Pratyush? New flash additions without names?
>
> Why do you need a flash addition in the first place? Haven't we agreed
> that we'll apply the vendor fixup based on the manufacturer ID?
>
> Anyway, flash additions without names is fine by me.
>
> Cheers,
> ta
> >
> > As, mentioned last time, for OF we might introduce an of_compatible
> > (thats then ABI) - or - we can use the numeric ID in the device tree,
> > as it's already used for PHY IDs or PCI IDs.
> >
> > Jaime, could you try to use
> >
> > /* Apply vendor fixups */
> > { .id = SNOR_ID(0xc2) }
I have validate some flash without "name" and looks good.
But I got some log with (null) like below:

SPI-NOR SPI0.0: (null) (32768 Kbytes)

and

zynq> cat jedec_id
c2943c
zynq> cat manufacturer
macronix
zynq> cat partname
(null)

Is this result acceptable to everyone?

> >
> > -michael

Thanks
Jaime
Michael Walle Nov. 22, 2023, 10:16 a.m. UTC | #7
Hi,

>> >>> and sometimes incorrect. Therefore, at least drop it and just list the
>> >>> IDs.
>> >> Could I know patch 6/6 only or patch 5/6 should remove name as well?
>> >
>> > I'd say yes. Tudor? Pratyush? New flash additions without names?
>> 
>> Why do you need a flash addition in the first place? Haven't we agreed
>> that we'll apply the vendor fixup based on the manufacturer ID?
>> 
>> Anyway, flash additions without names is fine by me.
>> 
>> Cheers,
>> ta
>> >
>> > As, mentioned last time, for OF we might introduce an of_compatible
>> > (thats then ABI) - or - we can use the numeric ID in the device tree,
>> > as it's already used for PHY IDs or PCI IDs.
>> >
>> > Jaime, could you try to use
>> >
>> > /* Apply vendor fixups */
>> > { .id = SNOR_ID(0xc2) }
> I have validate some flash without "name" and looks good.

Great :)

> But I got some log with (null) like below:
> 
> SPI-NOR SPI0.0: (null) (32768 Kbytes)

dev_info(dev, "%s (%lld Kbytes)\n", info->name ?: "",
          (long long)mtd->size >> 10);

Maybe we should print the vendor and the name and
both are optional? I don't have a strong opinion here
as long as it's not "(null)" because that looks like
a bug.

> and
> 
> zynq> cat jedec_id
> c2943c
> zynq> cat manufacturer
> macronix
> zynq> cat partname
> (null)

There is spi_nor_sysfs_is_visible() you can hide this property the
same was as the manufacturer property is hidden.

Also, please update
Documentation/ABI/testing/sysfs-bus-spi-devices-spi-nor in this case:

  The attribute is optional. User space shouldn't rely on it to
  be present or even correct. Instead, user space should read the
  jedec_id attribute.


-michael
diff mbox series

Patch

diff --git a/drivers/mtd/spi-nor/macronix.c b/drivers/mtd/spi-nor/macronix.c
index 48e570c04ad9..2115a25b21ce 100644
--- a/drivers/mtd/spi-nor/macronix.c
+++ b/drivers/mtd/spi-nor/macronix.c
@@ -260,6 +260,27 @@  static const struct flash_info macronix_nor_parts[] = {
 		.name = "mx66uw2g345gx0",
 		.n_banks = 4,
 		.flags = SPI_NOR_RWW,
+	}, {
+		.id = SNOR_ID(0xc2, 0x83, 0x39),
+		.name = "mx25um25345g",
+	}, {
+		.id = SNOR_ID(0xc2, 0x80, 0x39),
+		.name = "mx25um25645g",
+	}, {
+		.id = SNOR_ID(0xc2, 0x85, 0x39),
+		.name = "mx25lm25645g",
+	}, {
+		.id = SNOR_ID(0xc2, 0x80, 0x3a),
+		.name = "mx25um51245g",
+	}, {
+		.id = SNOR_ID(0xc2, 0x85, 0x3a),
+		.name = "mx25lm51245g",
+	}, {
+		.id = SNOR_ID(0xc2, 0x80, 0x3b),
+		.name = "mx66um1g45g",
+	}, {
+		.id = SNOR_ID(0xc2, 0x85, 0x3b),
+		.name = "mx66lm1g45g",
 	}
 };