diff mbox series

[RFC] mtd: spi-nor: Add Renesas AT25QL128A serial nor flash

Message ID 20220501185512.51158-1-biju.das.jz@bp.renesas.com
State Changes Requested
Delegated to: Pratyush Yadav
Headers show
Series [RFC] mtd: spi-nor: Add Renesas AT25QL128A serial nor flash | expand

Commit Message

Biju Das May 1, 2022, 6:55 p.m. UTC
Add support for Renesas AT25QL128A serial nor flash.
Details of flash chip can be found here [1]

[1] https://www.dialog-semiconductor.com/sites/default/files/2022-04/DS-AT25QL128A-129F-022022.pdf

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
Hi All,
 AT25QL128A serial nor flash is connected to RZ/G2UL SMARC EVK.
But with the current mtd support in mainline, I get the below error
[    3.928906] spi-nor spi1.0: unrecognized JEDEC id bytes: 1f 42 18 1f 42 18
[    3.937312] spi-nor: probe of spi1.0 failed with error -2

Then, I created a patch and the issue gone, It can detect the flash
[    3.937168] spi-nor spi1.0: at25ql128a (16384 Kbytes)
[    3.942902] 2 fixed-partitions partitions found on MTD device spi1.0
[    3.949459] Creating 2 MTD partitions on "spi1.0":
[    3.957540] 0x000000000000-0x000000200000 : "boot"
[    3.973740] 0x000000200000-0x000001000000 : "user"


Able to do read/write/format the partition with this patch.
So please provide your feedback on this patch.

&sbc {
	pinctrl-0 = <&qspi0_pins>;
	pinctrl-names = "default";
	status = "okay";

	flash@0 {
		compatible = "jedec,spi-nor";
		reg = <0>;
		spi-max-frequency = <50000000>;
		spi-tx-bus-width = <1>;
		spi-rx-bus-width = <4>;

		spi-cpol;
		spi-cpha;
		m25p,fast-read;

		partitions {
			compatible = "fixed-partitions";
			#address-cells = <1>;
			#size-cells = <1>;

			boot@0 {
				reg = <0x00000000 0x200000>;
				read-only;
			};
			user@200000 {
				reg = <0x200000 0xE00000>;
			};
		};
	};
};
---
 drivers/mtd/spi-nor/Makefile  |  1 +
 drivers/mtd/spi-nor/core.c    |  1 +
 drivers/mtd/spi-nor/core.h    |  1 +
 drivers/mtd/spi-nor/renesas.c | 57 +++++++++++++++++++++++++++++++++++
 4 files changed, 60 insertions(+)
 create mode 100644 drivers/mtd/spi-nor/renesas.c

Comments

Michael Walle May 2, 2022, 11:29 a.m. UTC | #1
>  drivers/mtd/spi-nor/Makefile  |  1 +
>  drivers/mtd/spi-nor/core.c    |  1 +
>  drivers/mtd/spi-nor/core.h    |  1 +
>  drivers/mtd/spi-nor/renesas.c | 57 +++++++++++++++++++++++++++++++++++

Please put the flash in atmel.c. There are all the Atmel/Adesto/now Renesas
flashes.

> +static const struct flash_info renesas_nor_parts[] = {
> +	{ "at25ql128a", INFO(0x1f4218, 0, 64 * 1024, 256)
> +		NO_SFDP_FLAGS(SECT_4K | SPI_NOR_QUAD_READ) },
> +};

I suppose this flash supports SFDP. Therefore,
	{ "at25ql128a", PARSE_SFDP },
should be enough.

I see that the 0x1f42xx IDs are also used for the at25sl series.
Could you shed some light to what the differences are? Are they
compatible, do we have to distiguish between them?

Last, for a new flash submission we require a SFDP dump. See [1].

[1] https://lore.kernel.org/linux-mtd/4304e19f3399a0a6e856119d01ccabe0@walle.cc/

> +static void renesas_nor_default_init(struct spi_nor *nor)
> +{
> +	nor->flags |= SNOR_F_HAS_LOCK;

Did you test locking?

-michael
Michael Walle May 2, 2022, 11:49 a.m. UTC | #2
Am 2022-05-02 13:29, schrieb Michael Walle:
>>  drivers/mtd/spi-nor/Makefile  |  1 +
>>  drivers/mtd/spi-nor/core.c    |  1 +
>>  drivers/mtd/spi-nor/core.h    |  1 +
>>  drivers/mtd/spi-nor/renesas.c | 57 
>> +++++++++++++++++++++++++++++++++++
> 
> Please put the flash in atmel.c. There are all the Atmel/Adesto/now 
> Renesas
> flashes.
> 
>> +static const struct flash_info renesas_nor_parts[] = {
>> +	{ "at25ql128a", INFO(0x1f4218, 0, 64 * 1024, 256)
>> +		NO_SFDP_FLAGS(SECT_4K | SPI_NOR_QUAD_READ) },
>> +};
> 
> I suppose this flash supports SFDP. Therefore,
> 	{ "at25ql128a", PARSE_SFDP },

The id is missing. Sorry. Seems like we need a new macro.

#define SNOR_ID3(_jedec_id) \
     .id = { \
         ((_jedec_id) >> 16) & 0xff, \
          ((_jedec_id) >> 8) & 0xff, \
           (_jedec_id) & 0xff, \
     } \
     .id_len = 3,

Then it would be
	{ "at25ql128a", SNOR_ID3(0x1f4218) PARSE_SFDP },

Now we'll get bitten by that missing comma (or the additional
comma in the defines).. I'd love to see that one removed, so
we can have the usual declarations:
	{ "at25ql128a", SNOR_ID3(0x1f4218), PARSE_SFDP },

Also it might make sense to have the PARSE_SFDP in the
SNOR_ID3() macro, because without SFDP, that macro cannot
be used. Tudor, Pratyush, what do you think about:

#define SNOR_ID3(_jedec_id) \
     .id = { \
         ((_jedec_id) >> 16) & 0xff, \
          ((_jedec_id) >> 8) & 0xff, \
           (_jedec_id) & 0xff, \
     } \
     .id_len = 3, \
     .parse_sfdp = true


-michael
Biju Das May 2, 2022, 12:57 p.m. UTC | #3
Hi Michael Walle,

Thanks for the feedback.

> Subject: Re: [RFC] mtd: spi-nor: Add Renesas AT25QL128A serial nor flash
> 
> >  drivers/mtd/spi-nor/Makefile  |  1 +
> >  drivers/mtd/spi-nor/core.c    |  1 +
> >  drivers/mtd/spi-nor/core.h    |  1 +
> >  drivers/mtd/spi-nor/renesas.c | 57
> > +++++++++++++++++++++++++++++++++++
> 
> Please put the flash in atmel.c. There are all the Atmel/Adesto/now
> Renesas flashes.

OK.

> 
> > +static const struct flash_info renesas_nor_parts[] = {
> > +	{ "at25ql128a", INFO(0x1f4218, 0, 64 * 1024, 256)
> > +		NO_SFDP_FLAGS(SECT_4K | SPI_NOR_QUAD_READ) }, };
> 
> I suppose this flash supports SFDP. Therefore,
> 	{ "at25ql128a", PARSE_SFDP },
> should be enough.

OK. I see some changes related to this in your next mail.

> 
> I see that the 0x1f42xx IDs are also used for the at25sl series.
> Could you shed some light to what the differences are? Are they
> compatible, do we have to distiguish between them?
> 
> Last, for a new flash submission we require a SFDP dump. See [1].
> 
> [1]

Please find the output, I did n't have xxd installed on my rootFS, so used hexdump.

root@smarc-rzg2ul:~# hexdump /sys/devices/platform/soc/10060000.spi/rpc-if-spi/spi_master/spi1/spi1.0/spi-nor/sfdp
0000000 4653 5044 0106 ff01 0600 1001 0030 ff00
0000010 001f 0201 0080 0100 ffff ffff ffff ffff
0000020 ffff ffff ffff ffff ffff ffff ffff ffff
0000030 20e5 fff1 ffff 07ff eb44 6b08 3b08 bb80
0000040 fffe ffff ffff ff00 ffff eb42 200c 520f
0000050 d810 ff00 6233 00d5 2984 ce01 a1ec 3d07
0000060 757a 757a a2f7 5cd5 f619 ff1c 10e8 80c0
0000070 ffff ffff ffff ffff ffff ffff ffff ffff
0000080 1650 1950 0000 ffff
0000088
root@smarc-rzg2ul:~# md5sum /sys/devices/platform/soc/10060000.spi/rpc-if-spi/spi_master/spi1/spi1.0/spi-nor/sfdp
23e3ec56b5b8f986d0488ba4727239dd  /sys/devices/platform/soc/10060000.spi/rpc-if-spi/spi_master/spi1/spi1.0/spi-nor/sfdp

root@smarc-rzg2ul:~# cat /sys/devices/platform/soc/10060000.spi/rpc-if-spi/spi_master/spi1/spi1.0/spi-nor/jedec_id
1f4218
root@smarc-rzg2ul:~# cat /sys/devices/platform/soc/10060000.spi/rpc-if-spi/spi_master/spi1/spi1.0/spi-nor/partname
at25ql128a
root@smarc-rzg2ul:~# cat /sys/devices/platform/soc/10060000.spi/rpc-if-spi/spi_master/spi1/spi1.0/spi-nor/manufacturer
renesas
root@smarc-rzg2ul:~#


> 
> > +static void renesas_nor_default_init(struct spi_nor *nor) {
> > +	nor->flags |= SNOR_F_HAS_LOCK;
> 
> Did you test locking?

No, I haven't tested locking. Will remove it.

Cheers,
Biju
Biju Das May 2, 2022, 1:10 p.m. UTC | #4
> Subject: RE: [RFC] mtd: spi-nor: Add Renesas AT25QL128A serial nor flash
> 
> Hi Michael Walle,
> 
> Thanks for the feedback.
> 
> > Subject: Re: [RFC] mtd: spi-nor: Add Renesas AT25QL128A serial nor
> > flash
> >
> > >  drivers/mtd/spi-nor/Makefile  |  1 +
> > >  drivers/mtd/spi-nor/core.c    |  1 +
> > >  drivers/mtd/spi-nor/core.h    |  1 +
> > >  drivers/mtd/spi-nor/renesas.c | 57
> > > +++++++++++++++++++++++++++++++++++
> >
> > Please put the flash in atmel.c. There are all the Atmel/Adesto/now
> > Renesas flashes.
> 
> OK.
> 
> >
> > > +static const struct flash_info renesas_nor_parts[] = {
> > > +	{ "at25ql128a", INFO(0x1f4218, 0, 64 * 1024, 256)
> > > +		NO_SFDP_FLAGS(SECT_4K | SPI_NOR_QUAD_READ) }, };
> >
> > I suppose this flash supports SFDP. Therefore,
> > 	{ "at25ql128a", PARSE_SFDP },
> > should be enough.
> 
> OK. I see some changes related to this in your next mail.
> 
> >
> > I see that the 0x1f42xx IDs are also used for the at25sl series.
> > Could you shed some light to what the differences are? Are they
> > compatible, do we have to distiguish between them?
> >
> > Last, for a new flash submission we require a SFDP dump. See [1].
> >
> > [1]
> 

Please find xxd output.

biju@biju-VirtualBox:/tftpboot/RZ-G2UL$  xxd -p sfdp 
53464450060101ff00060110300000ff1f00010280000001ffffffffffff
ffffffffffffffffffffffffffffffffffffe520f1ffffffff0744eb086b
083b80bbfeffffffffff00ffffff42eb0c200f5210d800ff3362d5008429
01ceeca1073d7a757a75f7a2d55c19f61cffe810c080ffffffffffffffff
ffffffffffffffff501650190000ffff

> Please find the output, I did n't have xxd installed on my rootFS, so used
> hexdump.
> 
> root@smarc-rzg2ul:~# hexdump /sys/devices/platform/soc/10060000.spi/rpc-
> if-spi/spi_master/spi1/spi1.0/spi-nor/sfdp
> 0000000 4653 5044 0106 ff01 0600 1001 0030 ff00
> 0000010 001f 0201 0080 0100 ffff ffff ffff ffff
> 0000020 ffff ffff ffff ffff ffff ffff ffff ffff
> 0000030 20e5 fff1 ffff 07ff eb44 6b08 3b08 bb80
> 0000040 fffe ffff ffff ff00 ffff eb42 200c 520f
> 0000050 d810 ff00 6233 00d5 2984 ce01 a1ec 3d07
> 0000060 757a 757a a2f7 5cd5 f619 ff1c 10e8 80c0
> 0000070 ffff ffff ffff ffff ffff ffff ffff ffff
> 0000080 1650 1950 0000 ffff
> 0000088
> root@smarc-rzg2ul:~# md5sum /sys/devices/platform/soc/10060000.spi/rpc-if-
> spi/spi_master/spi1/spi1.0/spi-nor/sfdp
> 23e3ec56b5b8f986d0488ba4727239dd
> /sys/devices/platform/soc/10060000.spi/rpc-if-
> spi/spi_master/spi1/spi1.0/spi-nor/sfdp
> 
> root@smarc-rzg2ul:~# cat /sys/devices/platform/soc/10060000.spi/rpc-if-
> spi/spi_master/spi1/spi1.0/spi-nor/jedec_id
> 1f4218
> root@smarc-rzg2ul:~# cat /sys/devices/platform/soc/10060000.spi/rpc-if-
> spi/spi_master/spi1/spi1.0/spi-nor/partname
> at25ql128a
> root@smarc-rzg2ul:~# cat /sys/devices/platform/soc/10060000.spi/rpc-if-
> spi/spi_master/spi1/spi1.0/spi-nor/manufacturer
> renesas
> root@smarc-rzg2ul:~#
> 
> 
> >
> > > +static void renesas_nor_default_init(struct spi_nor *nor) {
> > > +	nor->flags |= SNOR_F_HAS_LOCK;
> >
> > Did you test locking?
> 
> No, I haven't tested locking. Will remove it.
> 
> Cheers,
> Biju
Biju Das May 2, 2022, 6:48 p.m. UTC | #5
> -----Original Message-----
> From: Biju Das
> Sent: 02 May 2022 14:10
> To: Biju Das <biju.das.jz@bp.renesas.com>; Michael Walle
> <michael@walle.cc>
> Cc: Chris Paterson <Chris.Paterson2@renesas.com>; biju.das@bp.renesas.com;
> geert+renesas@glider.be; linux-mtd@lists.infradead.org; linux-renesas-
> soc@vger.kernel.org; miquel.raynal@bootlin.com; p.yadav@ti.com; Prabhakar
> Mahadev Lad <prabhakar.mahadev-lad.rj@bp.renesas.com>; richard@nod.at;
> tudor.ambarus@microchip.com; vigneshr@ti.com
> Subject: RE: [RFC] mtd: spi-nor: Add Renesas AT25QL128A serial nor flash
> 
> > Subject: RE: [RFC] mtd: spi-nor: Add Renesas AT25QL128A serial nor
> > flash
> >
> > Hi Michael Walle,
> >
> > Thanks for the feedback.
> >
> > > Subject: Re: [RFC] mtd: spi-nor: Add Renesas AT25QL128A serial nor
> > > flash
> > >
> > > >  drivers/mtd/spi-nor/Makefile  |  1 +
> > > >  drivers/mtd/spi-nor/core.c    |  1 +
> > > >  drivers/mtd/spi-nor/core.h    |  1 +
> > > >  drivers/mtd/spi-nor/renesas.c | 57
> > > > +++++++++++++++++++++++++++++++++++
> > >
> > > Please put the flash in atmel.c. There are all the Atmel/Adesto/now
> > > Renesas flashes.
> >
> > OK.
> >
> > >
> > > > +static const struct flash_info renesas_nor_parts[] = {
> > > > +	{ "at25ql128a", INFO(0x1f4218, 0, 64 * 1024, 256)
> > > > +		NO_SFDP_FLAGS(SECT_4K | SPI_NOR_QUAD_READ) }, };
> > >
> > > I suppose this flash supports SFDP. Therefore,
> > > 	{ "at25ql128a", PARSE_SFDP },
> > > should be enough.
> >
> > OK. I see some changes related to this in your next mail.
> >
> > >
> > > I see that the 0x1f42xx IDs are also used for the at25sl series.
> > > Could you shed some light to what the differences are? Are they
> > > compatible, do we have to distiguish between them?

For AT25QL128A flash,

0x1F:- Manufaturer
0x42:- Memory Type
0x18:- Capacity

I guess, if there is any at25sl128 flash chip, then the Capacity will be same for both the flash.

Cheers,
Biju


> > >
> > > Last, for a new flash submission we require a SFDP dump. See [1].
> > >
> > > [1]
> >
> 
> Please find xxd output.
> 
> biju@biju-VirtualBox:/tftpboot/RZ-G2UL$  xxd -p sfdp
> 53464450060101ff00060110300000ff1f00010280000001ffffffffffff
> ffffffffffffffffffffffffffffffffffffe520f1ffffffff0744eb086b
> 083b80bbfeffffffffff00ffffff42eb0c200f5210d800ff3362d5008429
> 01ceeca1073d7a757a75f7a2d55c19f61cffe810c080ffffffffffffffff
> ffffffffffffffff501650190000ffff
> 
> > Please find the output, I did n't have xxd installed on my rootFS, so
> > used hexdump.
> >
> > root@smarc-rzg2ul:~# hexdump
> > /sys/devices/platform/soc/10060000.spi/rpc-
> > if-spi/spi_master/spi1/spi1.0/spi-nor/sfdp
> > 0000000 4653 5044 0106 ff01 0600 1001 0030 ff00
> > 0000010 001f 0201 0080 0100 ffff ffff ffff ffff
> > 0000020 ffff ffff ffff ffff ffff ffff ffff ffff
> > 0000030 20e5 fff1 ffff 07ff eb44 6b08 3b08 bb80
> > 0000040 fffe ffff ffff ff00 ffff eb42 200c 520f
> > 0000050 d810 ff00 6233 00d5 2984 ce01 a1ec 3d07
> > 0000060 757a 757a a2f7 5cd5 f619 ff1c 10e8 80c0
> > 0000070 ffff ffff ffff ffff ffff ffff ffff ffff
> > 0000080 1650 1950 0000 ffff
> > 0000088
> > root@smarc-rzg2ul:~# md5sum
> > /sys/devices/platform/soc/10060000.spi/rpc-if-
> > spi/spi_master/spi1/spi1.0/spi-nor/sfdp
> > 23e3ec56b5b8f986d0488ba4727239dd
> > /sys/devices/platform/soc/10060000.spi/rpc-if-
> > spi/spi_master/spi1/spi1.0/spi-nor/sfdp
> >
> > root@smarc-rzg2ul:~# cat
> > /sys/devices/platform/soc/10060000.spi/rpc-if-
> > spi/spi_master/spi1/spi1.0/spi-nor/jedec_id
> > 1f4218
> > root@smarc-rzg2ul:~# cat
> > /sys/devices/platform/soc/10060000.spi/rpc-if-
> > spi/spi_master/spi1/spi1.0/spi-nor/partname
> > at25ql128a
> > root@smarc-rzg2ul:~# cat
> > /sys/devices/platform/soc/10060000.spi/rpc-if-
> > spi/spi_master/spi1/spi1.0/spi-nor/manufacturer
> > renesas
> > root@smarc-rzg2ul:~#
> >
> >
> > >
> > > > +static void renesas_nor_default_init(struct spi_nor *nor) {
> > > > +	nor->flags |= SNOR_F_HAS_LOCK;
> > >
> > > Did you test locking?
> >
> > No, I haven't tested locking. Will remove it.
> >
> > Cheers,
> > Biju
Biju Das May 3, 2022, 6:12 a.m. UTC | #6
Hi Michael Walle,

> > Subject: RE: [RFC] mtd: spi-nor: Add Renesas AT25QL128A serial nor
> > flash
> >
> > > Subject: RE: [RFC] mtd: spi-nor: Add Renesas AT25QL128A serial nor
> > > flash
> > >
> > > Hi Michael Walle,
> > >
> > > Thanks for the feedback.
> > >
> > > > Subject: Re: [RFC] mtd: spi-nor: Add Renesas AT25QL128A serial nor
> > > > flash
> > > >
> > > > >  drivers/mtd/spi-nor/Makefile  |  1 +
> > > > >  drivers/mtd/spi-nor/core.c    |  1 +
> > > > >  drivers/mtd/spi-nor/core.h    |  1 +
> > > > >  drivers/mtd/spi-nor/renesas.c | 57
> > > > > +++++++++++++++++++++++++++++++++++
> > > >
> > > > Please put the flash in atmel.c. There are all the
> > > > Atmel/Adesto/now Renesas flashes.
> > >
> > > OK.
> > >
> > > >
> > > > > +static const struct flash_info renesas_nor_parts[] = {
> > > > > +	{ "at25ql128a", INFO(0x1f4218, 0, 64 * 1024, 256)
> > > > > +		NO_SFDP_FLAGS(SECT_4K | SPI_NOR_QUAD_READ) }, };
> > > >
> > > > I suppose this flash supports SFDP. Therefore,
> > > > 	{ "at25ql128a", PARSE_SFDP },
> > > > should be enough.
> > >
> > > OK. I see some changes related to this in your next mail.
> > >
> > > >
> > > > I see that the 0x1f42xx IDs are also used for the at25sl series.
> > > > Could you shed some light to what the differences are? Are they
> > > > compatible, do we have to distiguish between them?
> 
> For AT25QL128A flash,
> 
> 0x1F:- Manufaturer
> 0x42:- Memory Type
> 0x18:- Capacity
> 
> I guess, if there is any at25sl128 flash chip, then the Capacity will be
> same for both the flash.

I don't have the md5sum value for at25sl128 flash chip. I believe these values will be different for at25sl128
And AT25QL128A.

Probably we could use md5sum value, if at all we need to distinguish them for at25sl128 if JEDECID is same??

Cheers,
Biju

> 
> Cheers,
> Biju
> 
> 
> > > >
> > > > Last, for a new flash submission we require a SFDP dump. See [1].
> > > >
> > > > [1]
> > >
> >
> > Please find xxd output.
> >
> > biju@biju-VirtualBox:/tftpboot/RZ-G2UL$  xxd -p sfdp
> > 53464450060101ff00060110300000ff1f00010280000001ffffffffffff
> > ffffffffffffffffffffffffffffffffffffe520f1ffffffff0744eb086b
> > 083b80bbfeffffffffff00ffffff42eb0c200f5210d800ff3362d5008429
> > 01ceeca1073d7a757a75f7a2d55c19f61cffe810c080ffffffffffffffff
> > ffffffffffffffff501650190000ffff
> >
> > > Please find the output, I did n't have xxd installed on my rootFS,
> > > so used hexdump.
> > >
> > > root@smarc-rzg2ul:~# hexdump
> > > /sys/devices/platform/soc/10060000.spi/rpc-
> > > if-spi/spi_master/spi1/spi1.0/spi-nor/sfdp
> > > 0000000 4653 5044 0106 ff01 0600 1001 0030 ff00
> > > 0000010 001f 0201 0080 0100 ffff ffff ffff ffff
> > > 0000020 ffff ffff ffff ffff ffff ffff ffff ffff
> > > 0000030 20e5 fff1 ffff 07ff eb44 6b08 3b08 bb80
> > > 0000040 fffe ffff ffff ff00 ffff eb42 200c 520f
> > > 0000050 d810 ff00 6233 00d5 2984 ce01 a1ec 3d07
> > > 0000060 757a 757a a2f7 5cd5 f619 ff1c 10e8 80c0
> > > 0000070 ffff ffff ffff ffff ffff ffff ffff ffff
> > > 0000080 1650 1950 0000 ffff
> > > 0000088
> > > root@smarc-rzg2ul:~# md5sum
> > > /sys/devices/platform/soc/10060000.spi/rpc-if-
> > > spi/spi_master/spi1/spi1.0/spi-nor/sfdp
> > > 23e3ec56b5b8f986d0488ba4727239dd
> > > /sys/devices/platform/soc/10060000.spi/rpc-if-
> > > spi/spi_master/spi1/spi1.0/spi-nor/sfdp
> > >
> > > root@smarc-rzg2ul:~# cat
> > > /sys/devices/platform/soc/10060000.spi/rpc-if-
> > > spi/spi_master/spi1/spi1.0/spi-nor/jedec_id
> > > 1f4218
> > > root@smarc-rzg2ul:~# cat
> > > /sys/devices/platform/soc/10060000.spi/rpc-if-
> > > spi/spi_master/spi1/spi1.0/spi-nor/partname
> > > at25ql128a
> > > root@smarc-rzg2ul:~# cat
> > > /sys/devices/platform/soc/10060000.spi/rpc-if-
> > > spi/spi_master/spi1/spi1.0/spi-nor/manufacturer
> > > renesas
> > > root@smarc-rzg2ul:~#
> > >
> > >
> > > >
> > > > > +static void renesas_nor_default_init(struct spi_nor *nor) {
> > > > > +	nor->flags |= SNOR_F_HAS_LOCK;
> > > >
> > > > Did you test locking?
> > >
> > > No, I haven't tested locking. Will remove it.
> > >
> > > Cheers,
> > > Biju
diff mbox series

Patch

diff --git a/drivers/mtd/spi-nor/Makefile b/drivers/mtd/spi-nor/Makefile
index 6b904e439372..2c2fce8e6132 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			+= renesas.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 b4f141ad9c9c..ba9f222da00b 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -1621,6 +1621,7 @@  static const struct spi_nor_manufacturer *manufacturers[] = {
 	&spi_nor_issi,
 	&spi_nor_macronix,
 	&spi_nor_micron,
+	&spi_nor_renesas,
 	&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 b7fd760e3b47..3d2e39329079 100644
--- a/drivers/mtd/spi-nor/core.h
+++ b/drivers/mtd/spi-nor/core.h
@@ -511,6 +511,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_renesas;
 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/renesas.c b/drivers/mtd/spi-nor/renesas.c
new file mode 100644
index 000000000000..091542c8c088
--- /dev/null
+++ b/drivers/mtd/spi-nor/renesas.c
@@ -0,0 +1,57 @@ 
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2005, Intec Automation Inc.
+ * Copyright (C) 2014, Freescale Semiconductor, Inc.
+ */
+
+#include <linux/mtd/spi-nor.h>
+
+#include "core.h"
+
+static const struct flash_info renesas_nor_parts[] = {
+	{ "at25ql128a", INFO(0x1f4218, 0, 64 * 1024, 256)
+		NO_SFDP_FLAGS(SECT_4K | SPI_NOR_QUAD_READ) },
+};
+
+/**
+ * renesas_nor_set_4byte_addr_mode() - Set 4-byte address mode for Renesas
+ * flashes.
+ * @nor:	pointer to 'struct spi_nor'.
+ * @enable:	true to enter the 4-byte address mode, false to exit the 4-byte
+ *		address mode.
+ *
+ * Return: 0 on success, -errno otherwise.
+ */
+static int renesas_nor_set_4byte_addr_mode(struct spi_nor *nor, bool enable)
+{
+	int ret;
+
+	ret = spi_nor_write_enable(nor);
+	if (ret)
+		return ret;
+
+	ret = spi_nor_set_4byte_addr_mode(nor, enable);
+	if (ret)
+		return ret;
+
+	return spi_nor_write_disable(nor);
+}
+
+static void renesas_nor_default_init(struct spi_nor *nor)
+{
+	nor->flags |= SNOR_F_HAS_LOCK;
+	nor->flags &= ~SNOR_F_HAS_16BIT_SR;
+	nor->params->quad_enable = NULL;
+	nor->params->set_4byte_addr_mode = renesas_nor_set_4byte_addr_mode;
+}
+
+static const struct spi_nor_fixups renesas_nor_fixups = {
+	.default_init = renesas_nor_default_init,
+};
+
+const struct spi_nor_manufacturer spi_nor_renesas = {
+	.name = "renesas",
+	.parts = renesas_nor_parts,
+	.nparts = ARRAY_SIZE(renesas_nor_parts),
+	.fixups = &renesas_nor_fixups,
+};