diff mbox series

mtd:spi-nor:Add support for xtx flash

Message ID 20230601102238.948177-1-bruce_suen@163.com
State Changes Requested
Delegated to: Michael Walle
Headers show
Series mtd:spi-nor:Add support for xtx flash | expand

Commit Message

Bruce Suen June 1, 2023, 10:22 a.m. UTC
Dear Maintainers,

This patch add support for XTX spi nor flash.
Dadasheet Link:
http://www.xtxtech.com/download/?AId=449
http://www.xtxtech.com/download/?AId=267
http://www.xtxtech.com/download/?AId=426
http://www.xtxtech.com/download/?AId=445
http://www.xtxtech.com/download/?AId=274

Signed-off-by: Bruce Suen <bruce_suen@163.com>
---
 drivers/mtd/spi-nor/Makefile |  1 +
 drivers/mtd/spi-nor/core.c   |  1 +
 drivers/mtd/spi-nor/core.h   |  1 +
 drivers/mtd/spi-nor/xtx.c    | 43 ++++++++++++++++++++++++++++++++++++
 4 files changed, 46 insertions(+)
 create mode 100644 drivers/mtd/spi-nor/xtx.c

Comments

Michael Walle June 13, 2023, 7:38 a.m. UTC | #1
Hi,

> Dear Maintainers,
> 
> This patch add support for XTX spi nor flash.
> Dadasheet Link:
> http://www.xtxtech.com/download/?AId=449
> http://www.xtxtech.com/download/?AId=267
> http://www.xtxtech.com/download/?AId=426
> http://www.xtxtech.com/download/?AId=445
> http://www.xtxtech.com/download/?AId=274

Link: tags

> Signed-off-by: Bruce Suen <bruce_suen@163.com>

XTX parts seem to have SFDP tables and they should work out of the box
without any patches with the generic spi nor driver [1].

-michael

[1] 
https://elixir.bootlin.com/linux/v6.4-rc6/source/drivers/mtd/spi-nor/core.c#L2019
Bruce Suen June 15, 2023, 1:55 a.m. UTC | #2
Hi,

Thanks, I got it.

I wonder what I should do if some parts need special bugfix ?

On 6/13/23 03:38, Michael Walle wrote:
> Hi,
>
>> Dear Maintainers,
>>
>> This patch add support for XTX spi nor flash.
>> Dadasheet Link:
>> http://www.xtxtech.com/download/?AId=449
>> http://www.xtxtech.com/download/?AId=267
>> http://www.xtxtech.com/download/?AId=426
>> http://www.xtxtech.com/download/?AId=445
>> http://www.xtxtech.com/download/?AId=274
>
> Link: tags
>
>> Signed-off-by: Bruce Suen <bruce_suen@163.com>
>
> XTX parts seem to have SFDP tables and they should work out of the box
> without any patches with the generic spi nor driver [1].
>
> -michael
>
> [1] 
> https://elixir.bootlin.com/linux/v6.4-rc6/source/drivers/mtd/spi-nor/core.c#L2019
Michael Walle June 15, 2023, 5:48 a.m. UTC | #3
Am 2023-06-15 03:55, schrieb Bruce Suen:
> Hi,
> 
> Thanks, I got it.
> 
> I wonder what I should do if some parts need special bugfix ?

In this case, you'll add an entry like you did below and register
some fixups. But keep in mind that you won't use NO_SFDP_FLAGS() in
this case, because you already have that via the SFDP tables.

-michael
diff mbox series

Patch

diff --git a/drivers/mtd/spi-nor/Makefile b/drivers/mtd/spi-nor/Makefile
index e347b435a038..8992c592a896 100644
--- a/drivers/mtd/spi-nor/Makefile
+++ b/drivers/mtd/spi-nor/Makefile
@@ -17,6 +17,7 @@  spi-nor-objs			+= sst.o
 spi-nor-objs			+= winbond.o
 spi-nor-objs			+= xilinx.o
 spi-nor-objs			+= xmc.o
+spi-nor-objs			+= xtx.o
 spi-nor-$(CONFIG_DEBUG_FS)	+= debugfs.o
 obj-$(CONFIG_MTD_SPI_NOR)	+= spi-nor.o
 
diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index 143ca3c9b477..0a26b7d1fe5d 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -2014,6 +2014,7 @@  static const struct spi_nor_manufacturer *manufacturers[] = {
 	&spi_nor_winbond,
 	&spi_nor_xilinx,
 	&spi_nor_xmc,
+	&spi_nor_xtx,
 };
 
 static const struct flash_info spi_nor_generic_flash = {
diff --git a/drivers/mtd/spi-nor/core.h b/drivers/mtd/spi-nor/core.h
index fd61c4793a10..9f6c564be622 100644
--- a/drivers/mtd/spi-nor/core.h
+++ b/drivers/mtd/spi-nor/core.h
@@ -644,6 +644,7 @@  extern const struct spi_nor_manufacturer spi_nor_sst;
 extern const struct spi_nor_manufacturer spi_nor_winbond;
 extern const struct spi_nor_manufacturer spi_nor_xilinx;
 extern const struct spi_nor_manufacturer spi_nor_xmc;
+extern const struct spi_nor_manufacturer spi_nor_xtx;
 
 extern const struct attribute_group *spi_nor_sysfs_groups[];
 
diff --git a/drivers/mtd/spi-nor/xtx.c b/drivers/mtd/spi-nor/xtx.c
new file mode 100644
index 000000000000..2e52fcfd1068
--- /dev/null
+++ b/drivers/mtd/spi-nor/xtx.c
@@ -0,0 +1,43 @@ 
+// 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 xtx_nor_parts[] = {
+	/* XTX (XTX Technology Inc.) */
+	{ "XT25F64", INFO(0x0B4017, 0, 64 * 1024, 128)
+		NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ |
+			      SPI_NOR_QUAD_READ) },
+	{ "XT25Q64", INFO(0x0B6017, 0, 64 * 1024, 128)
+		NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ |
+			      SPI_NOR_QUAD_READ) },
+	{ "XT25F128", INFO(0x0B4018, 0, 64 * 1024, 256)
+		NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ |
+			      SPI_NOR_QUAD_READ) },
+	{ "XT25Q128", INFO(0x0B6018, 0, 64 * 1024, 256)
+		NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ |
+			      SPI_NOR_QUAD_READ) },
+	{ "XT25F256", INFO(0x0B4019, 0, 64 * 1024, 512)
+		NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ |
+			      SPI_NOR_QUAD_READ) },
+	{ "XT25Q256", INFO(0x0B6019, 0, 64 * 1024, 512)
+		NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ |
+			      SPI_NOR_QUAD_READ) },
+	{ "XT25Q512", INFO(0x0B651A, 0, 64 * 1024, 1024)
+		NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ |
+			      SPI_NOR_QUAD_READ) },
+	{ "XT25Q1G", INFO(0x0B651B, 0, 64 * 1024, 2048)
+		NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ |
+			      SPI_NOR_QUAD_READ) },
+};
+
+const struct spi_nor_manufacturer spi_nor_xtx = {
+	.name = "xtx",
+	.parts = xtx_nor_parts,
+	.nparts = ARRAY_SIZE(xtx_nor_parts),
+};