Skip to content

Commit

Permalink
kernel: add support for Boya BY25Q128AS SPI flash
Browse files Browse the repository at this point in the history
This is a 16 MiB SPI NOR flash found in the Creality WB-01.

Signed-off-by: George Brooke <figgyc@figgyc.uk>
  • Loading branch information
figgyc committed Jun 6, 2021
1 parent 04a2609 commit bb9f277
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
From: George Brooke <figgyc@figgyc.uk>
Date: Sun, 07 Feb 2021 12:30:34 +0000
Subject: [PATCH] mtd: spi-nor: boya: add support for boya by25q128as

Adds support for the Boya Microelectronics BY25Q128AS 128 Mbit flash.
I tested this on the Creality WB-01 embedded device which uses this,
although that was with OpenWrt which is still using 5.4 so I had to
do a bit of porting work. Don't see how that would make much of a
difference though.

Signed-off-by: George Brooke <figgyc@figgyc.uk>
---
drivers/mtd/spi-nor/Makefile | 1 +
drivers/mtd/spi-nor/boya.c | 23 +++++++++++++++++++++++
drivers/mtd/spi-nor/core.c | 1 +
drivers/mtd/spi-nor/core.h | 1 +
4 files changed, 26 insertions(+)
create mode 100644 drivers/mtd/spi-nor/boya.c

diff --git a/drivers/mtd/spi-nor/Makefile b/drivers/mtd/spi-nor/Makefile
index 653923896205..7d1551fbfbaa 100644
--- a/drivers/mtd/spi-nor/Makefile
+++ b/drivers/mtd/spi-nor/Makefile
@@ -2,6 +2,7 @@

spi-nor-objs := core.o sfdp.o
spi-nor-objs += atmel.o
+spi-nor-objs += boya.o
spi-nor-objs += catalyst.o
spi-nor-objs += eon.o
spi-nor-objs += esmt.o
diff --git a/drivers/mtd/spi-nor/boya.c b/drivers/mtd/spi-nor/boya.c
new file mode 100644
index 000000000000..014b0087048a
--- /dev/null
+++ b/drivers/mtd/spi-nor/boya.c
@@ -0,0 +1,23 @@
+// 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 boya_parts[] = {
+ /* Boya */
+ { "by25q128as", INFO(0x684018, 0, 64 * 1024, 256,
+ SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ |
+ SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB)
+ },
+};
+
+const struct spi_nor_manufacturer spi_nor_boya = {
+ .name = "boya",
+ .parts = boya_parts,
+ .nparts = ARRAY_SIZE(boya_parts),
+};
diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index 20df44b753da..4d0d003e9c3f 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -2160,6 +2160,7 @@ int spi_nor_sr2_bit7_quad_enable(struct spi_nor *nor)

static const struct spi_nor_manufacturer *manufacturers[] = {
&spi_nor_atmel,
+ &spi_nor_boya,
&spi_nor_catalyst,
&spi_nor_eon,
&spi_nor_esmt,
diff --git a/drivers/mtd/spi-nor/core.h b/drivers/mtd/spi-nor/core.h
index d631ee299de3..d5ed5217228b 100644
--- a/drivers/mtd/spi-nor/core.h
+++ b/drivers/mtd/spi-nor/core.h
@@ -409,6 +409,7 @@ struct spi_nor_manufacturer {

/* Manufacturer drivers. */
extern const struct spi_nor_manufacturer spi_nor_atmel;
+extern const struct spi_nor_manufacturer spi_nor_boya;
extern const struct spi_nor_manufacturer spi_nor_catalyst;
extern const struct spi_nor_manufacturer spi_nor_eon;
extern const struct spi_nor_manufacturer spi_nor_esmt;
--
2.30.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
From: George Brooke <figgyc@figgyc.uk>
Subject: [PATCH] mtd: spi-nor: add support for Boya BY25Q128AS

Adds support for Boya Microelectronics (BoyaMicro) BY25Q128AS 128 MiB flash.
Tested on Creality WB-01 embedded device which uses this chip.

Signed-off-by: George Brooke <figgyc@figgyc.uk>
---
drivers/mtd/spi-nor/spi-nor.c | 4 ++++
1 file changed, 6 insertions(+)

--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -2171,6 +2171,12 @@ static const struct flash_info spi_nor_i

{ "at45db081d", INFO(0x1f2500, 0, 64 * 1024, 16, SECT_4K) },

+ /* Boya */
+ { "by25q128as", INFO(0x684018, 0, 64 * 1024, 256,
+ SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ |
+ SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB)
+ },
+
/* EON -- en25xxx */
{ "en25f32", INFO(0x1c3116, 0, 64 * 1024, 64, SECT_4K) },
{ "en25p32", INFO(0x1c2016, 0, 64 * 1024, 64, 0) },

0 comments on commit bb9f277

Please sign in to comment.