linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] mtd: rawnand: cs553x: Convert to exec_op()
@ 2020-05-01  9:06 Boris Brezillon
  2020-05-01  9:06 ` [PATCH 1/4] mtd: rawnand: cs553x: Declare controllers instead of NAND chips Boris Brezillon
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Boris Brezillon @ 2020-05-01  9:06 UTC (permalink / raw)
  To: Miquel Raynal, linux-mtd
  Cc: Vignesh Raghavendra, Tudor Ambarus, Richard Weinberger,
	linux-geode, Boris Brezillon, Andres Salomon

Hello,

A bit of context to explain the motivation behind those conversions
I've been sending for the last couple of weeks. The raw NAND subsystem
carries a lot of history which makes any rework not only painful, but
also subject to regressions which we only detect when someone dares to
update its kernel on one of those ancient HW. While carrying drivers
for old HW is not a problem per se, carrying ancient and unmaintained
drivers that are not converted to new APIs is a maintenance burden,
hence this massive conversion attempt I'm conducting here.

So here is a series converting the CS553X NAND controller driver to
exec_op(), plus a bunch of minor improvements done along the way.
I hope I'll find someone to test those changes, but if there's no one
still using NAND on GEODE or no interest in keeping it supported in
recent kernel versions, we should definitely consider removing the
driver instead.

Regards,

Boris

Boris Brezillon (4):
  mtd: rawnand: cs553x: Declare controllers instead of NAND chips
  mtd: rawnand: cs553x: Stop using chip->legacy.IO_ADDR_{R,W}
  mtd: rawnand: cs553x: Implement exec_op()
  mtd: rawnand: cs553x: Get rid of the legacy interface implementation

 drivers/mtd/nand/raw/cs553x_nand.c | 194 ++++++++++++++++++++---------
 1 file changed, 134 insertions(+), 60 deletions(-)

-- 
2.25.3


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 1/4] mtd: rawnand: cs553x: Declare controllers instead of NAND chips
  2020-05-01  9:06 [PATCH 0/4] mtd: rawnand: cs553x: Convert to exec_op() Boris Brezillon
@ 2020-05-01  9:06 ` Boris Brezillon
  2020-05-08 10:13   ` Miquel Raynal
  2020-05-10 20:04   ` Miquel Raynal
  2020-05-01  9:06 ` [PATCH 2/4] mtd: rawnand: cs553x: Stop using chip->legacy.IO_ADDR_{R, W} Boris Brezillon
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 14+ messages in thread
From: Boris Brezillon @ 2020-05-01  9:06 UTC (permalink / raw)
  To: Miquel Raynal, linux-mtd
  Cc: Vignesh Raghavendra, Tudor Ambarus, Richard Weinberger,
	linux-geode, Boris Brezillon, Andres Salomon

The CS553x companion chip embeds 4 NAND controllers. Declare them as
NAND controllers instead of NAND chips. That's done in preparation
of the transition to exec_op().

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
---
 drivers/mtd/nand/raw/cs553x_nand.c | 33 ++++++++++++++++++++----------
 1 file changed, 22 insertions(+), 11 deletions(-)

diff --git a/drivers/mtd/nand/raw/cs553x_nand.c b/drivers/mtd/nand/raw/cs553x_nand.c
index e2322cee3229..970de727679f 100644
--- a/drivers/mtd/nand/raw/cs553x_nand.c
+++ b/drivers/mtd/nand/raw/cs553x_nand.c
@@ -89,6 +89,11 @@
 #define CS_NAND_ECC_CLRECC	(1<<1)
 #define CS_NAND_ECC_ENECC	(1<<0)
 
+struct cs553x_nand_controller {
+	struct nand_controller base;
+	struct nand_chip chip;
+};
+
 static void cs553x_read_buf(struct nand_chip *this, u_char *buf, int len)
 {
 	while (unlikely(len > 0x800)) {
@@ -166,10 +171,11 @@ static int cs_calculate_ecc(struct nand_chip *this, const u_char *dat,
 	return 0;
 }
 
-static struct mtd_info *cs553x_mtd[4];
+static struct cs553x_nand_controller *controllers[4];
 
 static int __init cs553x_init_one(int cs, int mmio, unsigned long adr)
 {
+	struct cs553x_nand_controller *controller;
 	int err = 0;
 	struct nand_chip *this;
 	struct mtd_info *new_mtd;
@@ -183,12 +189,15 @@ static int __init cs553x_init_one(int cs, int mmio, unsigned long adr)
 	}
 
 	/* Allocate memory for MTD device structure and private data */
-	this = kzalloc(sizeof(struct nand_chip), GFP_KERNEL);
-	if (!this) {
+	controller = kzalloc(sizeof(*controller), GFP_KERNEL);
+	if (!controller) {
 		err = -ENOMEM;
 		goto out;
 	}
 
+	this = &controller->chip;
+	nand_controller_init(&controller->base);
+	this->controller = &controller->base;
 	new_mtd = nand_to_mtd(this);
 
 	/* Link the private data with the MTD structure */
@@ -232,7 +241,7 @@ static int __init cs553x_init_one(int cs, int mmio, unsigned long adr)
 	if (err)
 		goto out_free;
 
-	cs553x_mtd[cs] = new_mtd;
+	controllers[cs] = controller;
 	goto out;
 
 out_free:
@@ -240,7 +249,7 @@ static int __init cs553x_init_one(int cs, int mmio, unsigned long adr)
 out_ior:
 	iounmap(this->legacy.IO_ADDR_R);
 out_mtd:
-	kfree(this);
+	kfree(controller);
 out:
 	return err;
 }
@@ -295,9 +304,10 @@ static int __init cs553x_init(void)
 	/* Register all devices together here. This means we can easily hack it to
 	   do mtdconcat etc. if we want to. */
 	for (i = 0; i < NR_CS553X_CONTROLLERS; i++) {
-		if (cs553x_mtd[i]) {
+		if (controllers[i]) {
 			/* If any devices registered, return success. Else the last error. */
-			mtd_device_register(cs553x_mtd[i], NULL, 0);
+			mtd_device_register(nand_to_mtd(&controllers[i]->chip),
+					    NULL, 0);
 			err = 0;
 		}
 	}
@@ -312,9 +322,10 @@ static void __exit cs553x_cleanup(void)
 	int i;
 
 	for (i = 0; i < NR_CS553X_CONTROLLERS; i++) {
-		struct mtd_info *mtd = cs553x_mtd[i];
-		struct nand_chip *this;
 		void __iomem *mmio_base;
+		struct cs553x_nand_controller *controller = controllers[i];
+		struct nand_chip *this = &controller->chip;
+		struct mtd_info *mtd = nand_to_mtd(this);
 
 		if (!mtd)
 			continue;
@@ -325,13 +336,13 @@ static void __exit cs553x_cleanup(void)
 		/* Release resources, unregister device */
 		nand_release(this);
 		kfree(mtd->name);
-		cs553x_mtd[i] = NULL;
+		controllers[i] = NULL;
 
 		/* unmap physical address */
 		iounmap(mmio_base);
 
 		/* Free the MTD device structure */
-		kfree(this);
+		kfree(controller);
 	}
 }
 
-- 
2.25.3


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 2/4] mtd: rawnand: cs553x: Stop using chip->legacy.IO_ADDR_{R, W}
  2020-05-01  9:06 [PATCH 0/4] mtd: rawnand: cs553x: Convert to exec_op() Boris Brezillon
  2020-05-01  9:06 ` [PATCH 1/4] mtd: rawnand: cs553x: Declare controllers instead of NAND chips Boris Brezillon
@ 2020-05-01  9:06 ` Boris Brezillon
  2020-05-08 10:18   ` [PATCH 2/4] mtd: rawnand: cs553x: Stop using chip->legacy.IO_ADDR_{R,W} Miquel Raynal
                     ` (2 more replies)
  2020-05-01  9:06 ` [PATCH 3/4] mtd: rawnand: cs553x: Implement exec_op() Boris Brezillon
  2020-05-01  9:06 ` [PATCH 4/4] mtd: rawnand: cs553x: Get rid of the legacy interface implementation Boris Brezillon
  3 siblings, 3 replies; 14+ messages in thread
From: Boris Brezillon @ 2020-05-01  9:06 UTC (permalink / raw)
  To: Miquel Raynal, linux-mtd
  Cc: Vignesh Raghavendra, Tudor Ambarus, Richard Weinberger,
	linux-geode, Boris Brezillon, Andres Salomon

Now that we have our own controller struct we can keep the MMIO pointer
in there and use instead of using the chip->legacy.IO_ADDR_{R,W} fields.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
---
 drivers/mtd/nand/raw/cs553x_nand.c | 57 ++++++++++++++++++------------
 1 file changed, 34 insertions(+), 23 deletions(-)

diff --git a/drivers/mtd/nand/raw/cs553x_nand.c b/drivers/mtd/nand/raw/cs553x_nand.c
index 970de727679f..84cf87f02bd3 100644
--- a/drivers/mtd/nand/raw/cs553x_nand.c
+++ b/drivers/mtd/nand/raw/cs553x_nand.c
@@ -92,51 +92,66 @@
 struct cs553x_nand_controller {
 	struct nand_controller base;
 	struct nand_chip chip;
+	void __iomem *mmio;
 };
 
+static struct cs553x_nand_controller *
+to_cs553x(struct nand_controller *controller)
+{
+	return container_of(controller, struct cs553x_nand_controller, base);
+}
+
 static void cs553x_read_buf(struct nand_chip *this, u_char *buf, int len)
 {
+	struct cs553x_nand_controller *cs553x = to_cs553x(this->controller);
+
 	while (unlikely(len > 0x800)) {
-		memcpy_fromio(buf, this->legacy.IO_ADDR_R, 0x800);
+		memcpy_fromio(buf, cs553x->mmio, 0x800);
 		buf += 0x800;
 		len -= 0x800;
 	}
-	memcpy_fromio(buf, this->legacy.IO_ADDR_R, len);
+	memcpy_fromio(buf, cs553x->mmio, len);
 }
 
 static void cs553x_write_buf(struct nand_chip *this, const u_char *buf, int len)
 {
+	struct cs553x_nand_controller *cs553x = to_cs553x(this->controller);
+
 	while (unlikely(len > 0x800)) {
-		memcpy_toio(this->legacy.IO_ADDR_R, buf, 0x800);
+		memcpy_toio(cs553x->mmio, buf, 0x800);
 		buf += 0x800;
 		len -= 0x800;
 	}
-	memcpy_toio(this->legacy.IO_ADDR_R, buf, len);
+	memcpy_toio(cs553x->mmio, buf, len);
 }
 
 static unsigned char cs553x_read_byte(struct nand_chip *this)
 {
-	return readb(this->legacy.IO_ADDR_R);
+	struct cs553x_nand_controller *cs553x = to_cs553x(this->controller);
+
+	return readb(cs553x->mmio);
 }
 
 static void cs553x_write_byte(struct nand_chip *this, u_char byte)
 {
+	struct cs553x_nand_controller *cs553x = to_cs553x(this->controller);
 	int i = 100000;
 
-	while (i && readb(this->legacy.IO_ADDR_R + MM_NAND_STS) & CS_NAND_CTLR_BUSY) {
+	while (i && readb(cs553x->mmio + MM_NAND_STS) & CS_NAND_CTLR_BUSY) {
 		udelay(1);
 		i--;
 	}
-	writeb(byte, this->legacy.IO_ADDR_W + 0x801);
+	writeb(byte, cs553x->mmio + 0x801);
 }
 
 static void cs553x_hwcontrol(struct nand_chip *this, int cmd,
 			     unsigned int ctrl)
 {
-	void __iomem *mmio_base = this->legacy.IO_ADDR_R;
+	struct cs553x_nand_controller *cs553x = to_cs553x(this->controller);
+
 	if (ctrl & NAND_CTRL_CHANGE) {
 		unsigned char ctl = (ctrl & ~NAND_CTRL_CHANGE ) ^ 0x01;
-		writeb(ctl, mmio_base + MM_NAND_CTL);
+		writeb(ctl, cs553x->mmio + MM_NAND_CTL);
 	}
 	if (cmd != NAND_CMD_NONE)
 		cs553x_write_byte(this, cmd);
@@ -144,26 +159,26 @@ static void cs553x_hwcontrol(struct nand_chip *this, int cmd,
 
 static int cs553x_device_ready(struct nand_chip *this)
 {
-	void __iomem *mmio_base = this->legacy.IO_ADDR_R;
-	unsigned char foo = readb(mmio_base + MM_NAND_STS);
+	struct cs553x_nand_controller *cs553x = to_cs553x(this->controller);
+	unsigned char foo = readb(cs553x->mmio + MM_NAND_STS);
 
 	return (foo & CS_NAND_STS_FLASH_RDY) && !(foo & CS_NAND_CTLR_BUSY);
 }
 
 static void cs_enable_hwecc(struct nand_chip *this, int mode)
 {
-	void __iomem *mmio_base = this->legacy.IO_ADDR_R;
+	struct cs553x_nand_controller *cs553x = to_cs553x(this->controller);
 
-	writeb(0x07, mmio_base + MM_NAND_ECC_CTL);
+	writeb(0x07, cs553x->mmio + MM_NAND_ECC_CTL);
 }
 
 static int cs_calculate_ecc(struct nand_chip *this, const u_char *dat,
 			    u_char *ecc_code)
 {
+	struct cs553x_nand_controller *cs553x = to_cs553x(this->controller);
 	uint32_t ecc;
-	void __iomem *mmio_base = this->legacy.IO_ADDR_R;
 
-	ecc = readl(mmio_base + MM_NAND_STS);
+	ecc = readl(cs553x->mmio + MM_NAND_STS);
 
 	ecc_code[1] = ecc >> 8;
 	ecc_code[0] = ecc >> 16;
@@ -204,8 +219,8 @@ static int __init cs553x_init_one(int cs, int mmio, unsigned long adr)
 	new_mtd->owner = THIS_MODULE;
 
 	/* map physical address */
-	this->legacy.IO_ADDR_R = this->legacy.IO_ADDR_W = ioremap(adr, 4096);
-	if (!this->legacy.IO_ADDR_R) {
+	controller->mmio = ioremap(adr, 4096);
+	if (!controller->mmio) {
 		pr_warn("ioremap cs553x NAND @0x%08lx failed\n", adr);
 		err = -EIO;
 		goto out_mtd;
@@ -247,7 +262,7 @@ static int __init cs553x_init_one(int cs, int mmio, unsigned long adr)
 out_free:
 	kfree(new_mtd->name);
 out_ior:
-	iounmap(this->legacy.IO_ADDR_R);
+	iounmap(controller->mmio);
 out_mtd:
 	kfree(controller);
 out:
@@ -322,7 +337,6 @@ static void __exit cs553x_cleanup(void)
 	int i;
 
 	for (i = 0; i < NR_CS553X_CONTROLLERS; i++) {
-		void __iomem *mmio_base;
 		struct cs553x_nand_controller *controller = controllers[i];
 		struct nand_chip *this = &controller->chip;
 		struct mtd_info *mtd = nand_to_mtd(this);
@@ -330,16 +344,13 @@ static void __exit cs553x_cleanup(void)
 		if (!mtd)
 			continue;
 
-		this = mtd_to_nand(mtd);
-		mmio_base = this->legacy.IO_ADDR_R;
-
 		/* Release resources, unregister device */
 		nand_release(this);
 		kfree(mtd->name);
 		controllers[i] = NULL;
 
 		/* unmap physical address */
-		iounmap(mmio_base);
+		iounmap(controller->mmio);
 
 		/* Free the MTD device structure */
 		kfree(controller);
-- 
2.25.3


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 3/4] mtd: rawnand: cs553x: Implement exec_op()
  2020-05-01  9:06 [PATCH 0/4] mtd: rawnand: cs553x: Convert to exec_op() Boris Brezillon
  2020-05-01  9:06 ` [PATCH 1/4] mtd: rawnand: cs553x: Declare controllers instead of NAND chips Boris Brezillon
  2020-05-01  9:06 ` [PATCH 2/4] mtd: rawnand: cs553x: Stop using chip->legacy.IO_ADDR_{R, W} Boris Brezillon
@ 2020-05-01  9:06 ` Boris Brezillon
  2020-05-08 10:22   ` Miquel Raynal
  2020-05-10 20:04   ` Miquel Raynal
  2020-05-01  9:06 ` [PATCH 4/4] mtd: rawnand: cs553x: Get rid of the legacy interface implementation Boris Brezillon
  3 siblings, 2 replies; 14+ messages in thread
From: Boris Brezillon @ 2020-05-01  9:06 UTC (permalink / raw)
  To: Miquel Raynal, linux-mtd
  Cc: Vignesh Raghavendra, Tudor Ambarus, Richard Weinberger,
	linux-geode, Boris Brezillon, Andres Salomon

So we can later get rid of the legacy hooks.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
---
 drivers/mtd/nand/raw/cs553x_nand.c | 126 ++++++++++++++++++++++++++++-
 1 file changed, 125 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/raw/cs553x_nand.c b/drivers/mtd/nand/raw/cs553x_nand.c
index 84cf87f02bd3..3596edc6b777 100644
--- a/drivers/mtd/nand/raw/cs553x_nand.c
+++ b/drivers/mtd/nand/raw/cs553x_nand.c
@@ -21,9 +21,9 @@
 #include <linux/mtd/rawnand.h>
 #include <linux/mtd/nand_ecc.h>
 #include <linux/mtd/partitions.h>
+#include <linux/iopoll.h>
 
 #include <asm/msr.h>
-#include <asm/io.h>
 
 #define NR_CS553X_CONTROLLERS	4
 
@@ -165,6 +165,125 @@ static int cs553x_device_ready(struct nand_chip *this)
 	return (foo & CS_NAND_STS_FLASH_RDY) && !(foo & CS_NAND_CTLR_BUSY);
 }
 
+static int cs553x_write_ctrl_byte(struct cs553x_nand_controller *cs553x,
+				  u32 ctl, u8 data)
+{
+	u8 status;
+	int ret;
+
+	writeb(ctl, cs553x->mmio + MM_NAND_CTL);
+	writeb(data, cs553x->mmio + MM_NAND_IO);
+	ret = readb_poll_timeout_atomic(cs553x->mmio + MM_NAND_STS, status,
+					!(status & CS_NAND_CTLR_BUSY), 1,
+					100000);
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
+static void cs553x_data_in(struct cs553x_nand_controller *cs553x, void *buf,
+			   unsigned int len)
+{
+	writeb(0, cs553x->mmio + MM_NAND_CTL);
+	while (unlikely(len > 0x800)) {
+		memcpy_fromio(buf, cs553x->mmio, 0x800);
+		buf += 0x800;
+		len -= 0x800;
+	}
+	memcpy_fromio(buf, cs553x->mmio, len);
+}
+
+static void cs553x_data_out(struct cs553x_nand_controller *cs553x,
+			    const void *buf, unsigned int len)
+{
+	writeb(0, cs553x->mmio + MM_NAND_CTL);
+	while (unlikely(len > 0x800)) {
+		memcpy_toio(cs553x->mmio, buf, 0x800);
+		buf += 0x800;
+		len -= 0x800;
+	}
+	memcpy_toio(cs553x->mmio, buf, len);
+}
+
+static int cs553x_wait_ready(struct cs553x_nand_controller *cs553x,
+			     unsigned int timeout_ms)
+{
+	u8 mask = CS_NAND_CTLR_BUSY | CS_NAND_STS_FLASH_RDY;
+	u8 status;
+
+	return readb_poll_timeout(cs553x->mmio + MM_NAND_STS, status,
+				  (status & mask) == CS_NAND_STS_FLASH_RDY, 100,
+				  timeout_ms * 1000);
+}
+
+static int cs553x_exec_instr(struct cs553x_nand_controller *cs553x,
+			     const struct nand_op_instr *instr)
+{
+	unsigned int i;
+	int ret = 0;
+
+	switch (instr->type) {
+	case NAND_OP_CMD_INSTR:
+		ret = cs553x_write_ctrl_byte(cs553x, CS_NAND_CTL_CLE,
+					     instr->ctx.cmd.opcode);
+		break;
+
+	case NAND_OP_ADDR_INSTR:
+		for (i = 0; i < instr->ctx.addr.naddrs; i++) {
+			ret = cs553x_write_ctrl_byte(cs553x, CS_NAND_CTL_ALE,
+						     instr->ctx.addr.addrs[i]);
+			if (ret)
+				break;
+		}
+		break;
+
+	case NAND_OP_DATA_IN_INSTR:
+		cs553x_data_in(cs553x, instr->ctx.data.buf.in,
+			       instr->ctx.data.len);
+		break;
+
+	case NAND_OP_DATA_OUT_INSTR:
+		cs553x_data_out(cs553x, instr->ctx.data.buf.out,
+				instr->ctx.data.len);
+		break;
+
+	case NAND_OP_WAITRDY_INSTR:
+		ret = cs553x_wait_ready(cs553x, instr->ctx.waitrdy.timeout_ms);
+		break;
+	}
+
+	if (instr->delay_ns)
+		ndelay(instr->delay_ns);
+
+	return ret;
+}
+
+static int cs553x_exec_op(struct nand_chip *this,
+			  const struct nand_operation *op,
+			  bool check_only)
+{
+	struct cs553x_nand_controller *cs553x = to_cs553x(this->controller);
+	unsigned int i;
+	int ret;
+
+	if (check_only)
+		return true;
+
+	/* De-assert the CE pin */
+	writeb(0, cs553x->mmio + MM_NAND_CTL);
+	for (i = 0; i < op->ninstrs; i++) {
+		ret = cs553x_exec_instr(cs553x, &op->instrs[i]);
+		if (ret)
+			break;
+	}
+
+	/* Re-assert the CE pin. */
+	writeb(CS_NAND_CTL_CE, cs553x->mmio + MM_NAND_CTL);
+
+	return ret;
+}
+
 static void cs_enable_hwecc(struct nand_chip *this, int mode)
 {
 	struct cs553x_nand_controller *cs553x = to_cs553x(this->controller);
@@ -188,6 +307,10 @@ static int cs_calculate_ecc(struct nand_chip *this, const u_char *dat,
 
 static struct cs553x_nand_controller *controllers[4];
 
+static const struct nand_controller_ops cs553x_nand_controller_ops = {
+	.exec_op = cs553x_exec_op,
+};
+
 static int __init cs553x_init_one(int cs, int mmio, unsigned long adr)
 {
 	struct cs553x_nand_controller *controller;
@@ -212,6 +335,7 @@ static int __init cs553x_init_one(int cs, int mmio, unsigned long adr)
 
 	this = &controller->chip;
 	nand_controller_init(&controller->base);
+	controller->base.ops = &cs553x_nand_controller_ops;
 	this->controller = &controller->base;
 	new_mtd = nand_to_mtd(this);
 
-- 
2.25.3


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 4/4] mtd: rawnand: cs553x: Get rid of the legacy interface implementation
  2020-05-01  9:06 [PATCH 0/4] mtd: rawnand: cs553x: Convert to exec_op() Boris Brezillon
                   ` (2 preceding siblings ...)
  2020-05-01  9:06 ` [PATCH 3/4] mtd: rawnand: cs553x: Implement exec_op() Boris Brezillon
@ 2020-05-01  9:06 ` Boris Brezillon
  2020-05-08 10:20   ` Miquel Raynal
  2020-05-10 20:04   ` Miquel Raynal
  3 siblings, 2 replies; 14+ messages in thread
From: Boris Brezillon @ 2020-05-01  9:06 UTC (permalink / raw)
  To: Miquel Raynal, linux-mtd
  Cc: Vignesh Raghavendra, Tudor Ambarus, Richard Weinberger,
	linux-geode, Boris Brezillon, Andres Salomon

Now that exec_op() is implemented we no longer need to implement the
legacy hooks.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
---
 drivers/mtd/nand/raw/cs553x_nand.c | 72 ------------------------------
 1 file changed, 72 deletions(-)

diff --git a/drivers/mtd/nand/raw/cs553x_nand.c b/drivers/mtd/nand/raw/cs553x_nand.c
index 3596edc6b777..df5e24a2bbd7 100644
--- a/drivers/mtd/nand/raw/cs553x_nand.c
+++ b/drivers/mtd/nand/raw/cs553x_nand.c
@@ -101,70 +101,6 @@ to_cs553x(struct nand_controller *controller)
 	return container_of(controller, struct cs553x_nand_controller, base);
 }
 
-static void cs553x_read_buf(struct nand_chip *this, u_char *buf, int len)
-{
-	struct cs553x_nand_controller *cs553x = to_cs553x(this->controller);
-
-	while (unlikely(len > 0x800)) {
-		memcpy_fromio(buf, cs553x->mmio, 0x800);
-		buf += 0x800;
-		len -= 0x800;
-	}
-	memcpy_fromio(buf, cs553x->mmio, len);
-}
-
-static void cs553x_write_buf(struct nand_chip *this, const u_char *buf, int len)
-{
-	struct cs553x_nand_controller *cs553x = to_cs553x(this->controller);
-
-	while (unlikely(len > 0x800)) {
-		memcpy_toio(cs553x->mmio, buf, 0x800);
-		buf += 0x800;
-		len -= 0x800;
-	}
-	memcpy_toio(cs553x->mmio, buf, len);
-}
-
-static unsigned char cs553x_read_byte(struct nand_chip *this)
-{
-	struct cs553x_nand_controller *cs553x = to_cs553x(this->controller);
-
-	return readb(cs553x->mmio);
-}
-
-static void cs553x_write_byte(struct nand_chip *this, u_char byte)
-{
-	struct cs553x_nand_controller *cs553x = to_cs553x(this->controller);
-	int i = 100000;
-
-	while (i && readb(cs553x->mmio + MM_NAND_STS) & CS_NAND_CTLR_BUSY) {
-		udelay(1);
-		i--;
-	}
-	writeb(byte, cs553x->mmio + 0x801);
-}
-
-static void cs553x_hwcontrol(struct nand_chip *this, int cmd,
-			     unsigned int ctrl)
-{
-	struct cs553x_nand_controller *cs553x = to_cs553x(this->controller);
-
-	if (ctrl & NAND_CTRL_CHANGE) {
-		unsigned char ctl = (ctrl & ~NAND_CTRL_CHANGE ) ^ 0x01;
-		writeb(ctl, cs553x->mmio + MM_NAND_CTL);
-	}
-	if (cmd != NAND_CMD_NONE)
-		cs553x_write_byte(this, cmd);
-}
-
-static int cs553x_device_ready(struct nand_chip *this)
-{
-	struct cs553x_nand_controller *cs553x = to_cs553x(this->controller);
-	unsigned char foo = readb(cs553x->mmio + MM_NAND_STS);
-
-	return (foo & CS_NAND_STS_FLASH_RDY) && !(foo & CS_NAND_CTLR_BUSY);
-}
-
 static int cs553x_write_ctrl_byte(struct cs553x_nand_controller *cs553x,
 				  u32 ctl, u8 data)
 {
@@ -350,14 +286,6 @@ static int __init cs553x_init_one(int cs, int mmio, unsigned long adr)
 		goto out_mtd;
 	}
 
-	this->legacy.cmd_ctrl = cs553x_hwcontrol;
-	this->legacy.dev_ready = cs553x_device_ready;
-	this->legacy.read_byte = cs553x_read_byte;
-	this->legacy.read_buf = cs553x_read_buf;
-	this->legacy.write_buf = cs553x_write_buf;
-
-	this->legacy.chip_delay = 0;
-
 	this->ecc.mode = NAND_ECC_HW;
 	this->ecc.size = 256;
 	this->ecc.bytes = 3;
-- 
2.25.3


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/4] mtd: rawnand: cs553x: Declare controllers instead of NAND chips
  2020-05-01  9:06 ` [PATCH 1/4] mtd: rawnand: cs553x: Declare controllers instead of NAND chips Boris Brezillon
@ 2020-05-08 10:13   ` Miquel Raynal
  2020-05-10 20:04   ` Miquel Raynal
  1 sibling, 0 replies; 14+ messages in thread
From: Miquel Raynal @ 2020-05-08 10:13 UTC (permalink / raw)
  To: Boris Brezillon
  Cc: Vignesh Raghavendra, Tudor Ambarus, Richard Weinberger,
	linux-geode, linux-mtd, Andres Salomon

Hi Boris,

Boris Brezillon <boris.brezillon@collabora.com> wrote on Fri,  1 May
2020 11:06:47 +0200:

> The CS553x companion chip embeds 4 NAND controllers. Declare them as
> NAND controllers instead of NAND chips. That's done in preparation
> of the transition to exec_op().
> 
> Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
> ---

Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/4] mtd: rawnand: cs553x: Stop using chip->legacy.IO_ADDR_{R,W}
  2020-05-01  9:06 ` [PATCH 2/4] mtd: rawnand: cs553x: Stop using chip->legacy.IO_ADDR_{R, W} Boris Brezillon
@ 2020-05-08 10:18   ` Miquel Raynal
  2020-05-08 10:19   ` Miquel Raynal
  2020-05-10 20:04   ` [PATCH 2/4] mtd: rawnand: cs553x: Stop using chip->legacy.IO_ADDR_{R, W} Miquel Raynal
  2 siblings, 0 replies; 14+ messages in thread
From: Miquel Raynal @ 2020-05-08 10:18 UTC (permalink / raw)
  To: Boris Brezillon
  Cc: Vignesh Raghavendra, Tudor Ambarus, Richard Weinberger,
	linux-geode, linux-mtd, Andres Salomon

Hi Boris,

Boris Brezillon <boris.brezillon@collabora.com> wrote on Fri,  1 May
2020 11:06:48 +0200:

> Now that we have our own controller struct we can keep the MMIO pointer
> in there and use instead of using the chip->legacy.IO_ADDR_{R,W} fields.
> 
> Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
> ---
>  drivers/mtd/nand/raw/cs553x_nand.c | 57 ++++++++++++++++++------------
>  1 file changed, 34 insertions(+), 23 deletions(-)
> 

Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/4] mtd: rawnand: cs553x: Stop using chip->legacy.IO_ADDR_{R,W}
  2020-05-01  9:06 ` [PATCH 2/4] mtd: rawnand: cs553x: Stop using chip->legacy.IO_ADDR_{R, W} Boris Brezillon
  2020-05-08 10:18   ` [PATCH 2/4] mtd: rawnand: cs553x: Stop using chip->legacy.IO_ADDR_{R,W} Miquel Raynal
@ 2020-05-08 10:19   ` Miquel Raynal
  2020-05-10 20:04   ` [PATCH 2/4] mtd: rawnand: cs553x: Stop using chip->legacy.IO_ADDR_{R, W} Miquel Raynal
  2 siblings, 0 replies; 14+ messages in thread
From: Miquel Raynal @ 2020-05-08 10:19 UTC (permalink / raw)
  To: Boris Brezillon
  Cc: Vignesh Raghavendra, Tudor Ambarus, Richard Weinberger,
	linux-geode, linux-mtd, Andres Salomon


Boris Brezillon <boris.brezillon@collabora.com> wrote on Fri,  1 May
2020 11:06:48 +0200:

> Now that we have our own controller struct we can keep the MMIO pointer
> in there and use instead of using the chip->legacy.IO_ADDR_{R,W} fields.

                  it

(don't send a v2 just for this)


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 4/4] mtd: rawnand: cs553x: Get rid of the legacy interface implementation
  2020-05-01  9:06 ` [PATCH 4/4] mtd: rawnand: cs553x: Get rid of the legacy interface implementation Boris Brezillon
@ 2020-05-08 10:20   ` Miquel Raynal
  2020-05-10 20:04   ` Miquel Raynal
  1 sibling, 0 replies; 14+ messages in thread
From: Miquel Raynal @ 2020-05-08 10:20 UTC (permalink / raw)
  To: Boris Brezillon
  Cc: Vignesh Raghavendra, Tudor Ambarus, Richard Weinberger,
	linux-geode, linux-mtd, Andres Salomon


Boris Brezillon <boris.brezillon@collabora.com> wrote on Fri,  1 May
2020 11:06:50 +0200:

> Now that exec_op() is implemented we no longer need to implement the
> legacy hooks.
> 
> Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
> ---

Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/4] mtd: rawnand: cs553x: Implement exec_op()
  2020-05-01  9:06 ` [PATCH 3/4] mtd: rawnand: cs553x: Implement exec_op() Boris Brezillon
@ 2020-05-08 10:22   ` Miquel Raynal
  2020-05-10 20:04   ` Miquel Raynal
  1 sibling, 0 replies; 14+ messages in thread
From: Miquel Raynal @ 2020-05-08 10:22 UTC (permalink / raw)
  To: Boris Brezillon
  Cc: Vignesh Raghavendra, Tudor Ambarus, Richard Weinberger,
	linux-geode, linux-mtd, Andres Salomon


Boris Brezillon <boris.brezillon@collabora.com> wrote on Fri,  1 May
2020 11:06:49 +0200:

> So we can later get rid of the legacy hooks.
> 
> Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
> ---
>  drivers/mtd/nand/raw/cs553x_nand.c | 126 ++++++++++++++++++++++++++++-
>  1 file changed, 125 insertions(+), 1 deletion(-)
>

Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 4/4] mtd: rawnand: cs553x: Get rid of the legacy interface implementation
  2020-05-01  9:06 ` [PATCH 4/4] mtd: rawnand: cs553x: Get rid of the legacy interface implementation Boris Brezillon
  2020-05-08 10:20   ` Miquel Raynal
@ 2020-05-10 20:04   ` Miquel Raynal
  1 sibling, 0 replies; 14+ messages in thread
From: Miquel Raynal @ 2020-05-10 20:04 UTC (permalink / raw)
  To: Boris Brezillon, Miquel Raynal, linux-mtd
  Cc: Richard Weinberger, Andres Salomon, Vignesh Raghavendra,
	linux-geode, Tudor Ambarus

On Fri, 2020-05-01 at 09:06:50 UTC, Boris Brezillon wrote:
> Now that exec_op() is implemented we no longer need to implement the
> legacy hooks.
> 
> Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/4] mtd: rawnand: cs553x: Implement exec_op()
  2020-05-01  9:06 ` [PATCH 3/4] mtd: rawnand: cs553x: Implement exec_op() Boris Brezillon
  2020-05-08 10:22   ` Miquel Raynal
@ 2020-05-10 20:04   ` Miquel Raynal
  1 sibling, 0 replies; 14+ messages in thread
From: Miquel Raynal @ 2020-05-10 20:04 UTC (permalink / raw)
  To: Boris Brezillon, Miquel Raynal, linux-mtd
  Cc: Richard Weinberger, Andres Salomon, Vignesh Raghavendra,
	linux-geode, Tudor Ambarus

On Fri, 2020-05-01 at 09:06:49 UTC, Boris Brezillon wrote:
> So we can later get rid of the legacy hooks.
> 
> Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/4] mtd: rawnand: cs553x: Stop using chip->legacy.IO_ADDR_{R, W}
  2020-05-01  9:06 ` [PATCH 2/4] mtd: rawnand: cs553x: Stop using chip->legacy.IO_ADDR_{R, W} Boris Brezillon
  2020-05-08 10:18   ` [PATCH 2/4] mtd: rawnand: cs553x: Stop using chip->legacy.IO_ADDR_{R,W} Miquel Raynal
  2020-05-08 10:19   ` Miquel Raynal
@ 2020-05-10 20:04   ` Miquel Raynal
  2 siblings, 0 replies; 14+ messages in thread
From: Miquel Raynal @ 2020-05-10 20:04 UTC (permalink / raw)
  To: Boris Brezillon, Miquel Raynal, linux-mtd
  Cc: Richard Weinberger, Andres Salomon, Vignesh Raghavendra,
	linux-geode, Tudor Ambarus

On Fri, 2020-05-01 at 09:06:48 UTC, Boris Brezillon wrote:
> Now that we have our own controller struct we can keep the MMIO pointer
> in there and use instead of using the chip->legacy.IO_ADDR_{R,W} fields.
> 
> Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/4] mtd: rawnand: cs553x: Declare controllers instead of NAND chips
  2020-05-01  9:06 ` [PATCH 1/4] mtd: rawnand: cs553x: Declare controllers instead of NAND chips Boris Brezillon
  2020-05-08 10:13   ` Miquel Raynal
@ 2020-05-10 20:04   ` Miquel Raynal
  1 sibling, 0 replies; 14+ messages in thread
From: Miquel Raynal @ 2020-05-10 20:04 UTC (permalink / raw)
  To: Boris Brezillon, Miquel Raynal, linux-mtd
  Cc: Richard Weinberger, Andres Salomon, Vignesh Raghavendra,
	linux-geode, Tudor Ambarus

On Fri, 2020-05-01 at 09:06:47 UTC, Boris Brezillon wrote:
> The CS553x companion chip embeds 4 NAND controllers. Declare them as
> NAND controllers instead of NAND chips. That's done in preparation
> of the transition to exec_op().
> 
> Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2020-05-10 20:09 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-01  9:06 [PATCH 0/4] mtd: rawnand: cs553x: Convert to exec_op() Boris Brezillon
2020-05-01  9:06 ` [PATCH 1/4] mtd: rawnand: cs553x: Declare controllers instead of NAND chips Boris Brezillon
2020-05-08 10:13   ` Miquel Raynal
2020-05-10 20:04   ` Miquel Raynal
2020-05-01  9:06 ` [PATCH 2/4] mtd: rawnand: cs553x: Stop using chip->legacy.IO_ADDR_{R, W} Boris Brezillon
2020-05-08 10:18   ` [PATCH 2/4] mtd: rawnand: cs553x: Stop using chip->legacy.IO_ADDR_{R,W} Miquel Raynal
2020-05-08 10:19   ` Miquel Raynal
2020-05-10 20:04   ` [PATCH 2/4] mtd: rawnand: cs553x: Stop using chip->legacy.IO_ADDR_{R, W} Miquel Raynal
2020-05-01  9:06 ` [PATCH 3/4] mtd: rawnand: cs553x: Implement exec_op() Boris Brezillon
2020-05-08 10:22   ` Miquel Raynal
2020-05-10 20:04   ` Miquel Raynal
2020-05-01  9:06 ` [PATCH 4/4] mtd: rawnand: cs553x: Get rid of the legacy interface implementation Boris Brezillon
2020-05-08 10:20   ` Miquel Raynal
2020-05-10 20:04   ` Miquel Raynal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).