From 69112def97ffb3a2fa848913cfd40eda1d9cf0a9 Mon Sep 17 00:00:00 2001
From: Ondrej Jirman <megi@xff.cz>
Date: Tue, 1 Aug 2023 14:56:33 +0200
Subject: [PATCH 457/463] mtd: spi-nor: Add Alliance memory support

- 128MBit flash: as25f1128mq

Signed-off-by: Ondrej Jirman <megi@xff.cz>
---
 drivers/mtd/spi-nor/Makefile   |  1 +
 drivers/mtd/spi-nor/alliance.c | 24 ++++++++++++++++++++++++
 drivers/mtd/spi-nor/core.c     |  1 +
 drivers/mtd/spi-nor/core.h     |  1 +
 4 files changed, 27 insertions(+)
 create mode 100644 drivers/mtd/spi-nor/alliance.c

diff --git a/drivers/mtd/spi-nor/Makefile b/drivers/mtd/spi-nor/Makefile
index 5dd9c35f6b6f8..9988769203194 100644
--- a/drivers/mtd/spi-nor/Makefile
+++ b/drivers/mtd/spi-nor/Makefile
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 
 spi-nor-objs			:= core.o sfdp.o swp.o otp.o sysfs.o
+spi-nor-objs			+= alliance.o
 spi-nor-objs			+= atmel.o
 spi-nor-objs			+= eon.o
 spi-nor-objs			+= esmt.o
diff --git a/drivers/mtd/spi-nor/alliance.c b/drivers/mtd/spi-nor/alliance.c
new file mode 100644
index 0000000000000..f3f03d458a5c9
--- /dev/null
+++ b/drivers/mtd/spi-nor/alliance.c
@@ -0,0 +1,24 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2023, Ondrej Jirman <megi@xff.cz>
+ */
+
+#include <linux/mtd/spi-nor.h>
+
+#include "core.h"
+
+static const struct flash_info alliance_nor_parts[] = {
+	{
+		.id = SNOR_ID(0x52, 0x42, 0x18),
+		.name = "as25f1128mq",
+		.size = SZ_16M,
+		.flags = SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB,
+		.no_sfdp_flags = SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ,
+	},
+};
+
+const struct spi_nor_manufacturer spi_nor_alliance = {
+	.name = "alliance",
+	.parts = alliance_nor_parts,
+	.nparts = ARRAY_SIZE(alliance_nor_parts),
+};
diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index e0c4efc424f49..7adf39c3920b1 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -1963,6 +1963,7 @@ int spi_nor_sr2_bit7_quad_enable(struct spi_nor *nor)
 }
 
 static const struct spi_nor_manufacturer *manufacturers[] = {
+	&spi_nor_alliance,
 	&spi_nor_atmel,
 	&spi_nor_eon,
 	&spi_nor_esmt,
diff --git a/drivers/mtd/spi-nor/core.h b/drivers/mtd/spi-nor/core.h
index 1516b6d0dc37a..34bb375880e4c 100644
--- a/drivers/mtd/spi-nor/core.h
+++ b/drivers/mtd/spi-nor/core.h
@@ -579,6 +579,7 @@ struct sfdp {
 };
 
 /* Manufacturer drivers. */
+extern const struct spi_nor_manufacturer spi_nor_alliance;
 extern const struct spi_nor_manufacturer spi_nor_atmel;
 extern const struct spi_nor_manufacturer spi_nor_eon;
 extern const struct spi_nor_manufacturer spi_nor_esmt;
-- 
2.46.0

