mirror of https://lore.kernel.org/linux-amlogic/
 help / color / mirror / Atom feed
* [PATCH v1 0/2] use NAND core API for Meson controller
@ 2023-07-05 10:43 Arseniy Krasnov
  2023-07-05 10:43 ` [PATCH v1 1/2] mtd: rawnand: export 'nand_exit_status_op()' Arseniy Krasnov
  2023-07-05 10:43 ` [PATCH v1 2/2] mtd: rawnand: meson: use NAND core API to check status Arseniy Krasnov
  0 siblings, 2 replies; 5+ messages in thread
From: Arseniy Krasnov @ 2023-07-05 10:43 UTC (permalink / raw)
  To: Liang Yang, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, Neil Armstrong, Kevin Hilman, Jerome Brunet,
	Martin Blumenstingl, Michał Kępień,
	Arseniy Krasnov, Adam Borowski, JaimeLiao, ChenXiaoSong,
	Andy Shevchenko
  Cc: oxffffaa, kernel, linux-mtd, linux-arm-kernel, linux-amlogic,
	linux-kernel

During waiting for command completion this driver sends NAND_CMD_STATUS
and then NAND_CMD_READ0 to leave status checking mode. Instead of direct
accesses to the registers of the controller to send these commands, this
patchset uses currently implemented and exported NAND API for the same
purposes. First patch is preparation: we need to export function 
'nand_exit_status_op()' for modules. Second patch uses these functions
in the Meson driver.

Arseniy Krasnov (2):
  mtd: rawnand: export 'nand_exit_status_op()'
  mtd: rawnand: meson: use NAND core API to check status

 drivers/mtd/nand/raw/meson_nand.c | 26 ++++++++++++--------------
 drivers/mtd/nand/raw/nand_base.c  |  1 +
 include/linux/mtd/rawnand.h       |  1 +
 3 files changed, 14 insertions(+), 14 deletions(-)

-- 
2.35.0


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

* [PATCH v1 1/2] mtd: rawnand: export 'nand_exit_status_op()'
  2023-07-05 10:43 [PATCH v1 0/2] use NAND core API for Meson controller Arseniy Krasnov
@ 2023-07-05 10:43 ` Arseniy Krasnov
  2023-07-13  7:58   ` Miquel Raynal
  2023-07-05 10:43 ` [PATCH v1 2/2] mtd: rawnand: meson: use NAND core API to check status Arseniy Krasnov
  1 sibling, 1 reply; 5+ messages in thread
From: Arseniy Krasnov @ 2023-07-05 10:43 UTC (permalink / raw)
  To: Liang Yang, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, Neil Armstrong, Kevin Hilman, Jerome Brunet,
	Martin Blumenstingl, JaimeLiao, Michał Kępień,
	Andy Shevchenko, Arseniy Krasnov, ChenXiaoSong, Adam Borowski
  Cc: oxffffaa, kernel, linux-mtd, linux-arm-kernel, linux-amlogic,
	linux-kernel

Export this function to work in pair with 'nand_status_op()' which is
already exported.

Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru>
---
 drivers/mtd/nand/raw/nand_base.c | 1 +
 include/linux/mtd/rawnand.h      | 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
index a6af521832aa..d4b55155aeae 100644
--- a/drivers/mtd/nand/raw/nand_base.c
+++ b/drivers/mtd/nand/raw/nand_base.c
@@ -1885,6 +1885,7 @@ int nand_exit_status_op(struct nand_chip *chip)
 
 	return 0;
 }
+EXPORT_SYMBOL_GPL(nand_exit_status_op);
 
 /**
  * nand_erase_op - Do an erase operation
diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h
index 5159d692f9ce..90a141ba2a5a 100644
--- a/include/linux/mtd/rawnand.h
+++ b/include/linux/mtd/rawnand.h
@@ -1540,6 +1540,7 @@ int nand_reset_op(struct nand_chip *chip);
 int nand_readid_op(struct nand_chip *chip, u8 addr, void *buf,
 		   unsigned int len);
 int nand_status_op(struct nand_chip *chip, u8 *status);
+int nand_exit_status_op(struct nand_chip *chip);
 int nand_erase_op(struct nand_chip *chip, unsigned int eraseblock);
 int nand_read_page_op(struct nand_chip *chip, unsigned int page,
 		      unsigned int offset_in_page, void *buf, unsigned int len);
-- 
2.35.0


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

* [PATCH v1 2/2] mtd: rawnand: meson: use NAND core API to check status
  2023-07-05 10:43 [PATCH v1 0/2] use NAND core API for Meson controller Arseniy Krasnov
  2023-07-05 10:43 ` [PATCH v1 1/2] mtd: rawnand: export 'nand_exit_status_op()' Arseniy Krasnov
@ 2023-07-05 10:43 ` Arseniy Krasnov
  2023-07-13  7:58   ` Miquel Raynal
  1 sibling, 1 reply; 5+ messages in thread
From: Arseniy Krasnov @ 2023-07-05 10:43 UTC (permalink / raw)
  To: Liang Yang, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, Neil Armstrong, Kevin Hilman, Jerome Brunet,
	Martin Blumenstingl, Adam Borowski, ChenXiaoSong, JaimeLiao,
	Andy Shevchenko, Michał Kępień
  Cc: oxffffaa, kernel, Arseniy Krasnov, linux-mtd, linux-arm-kernel,
	linux-amlogic, linux-kernel

NAND core API already has functions to send NAND_CMD_STATUS and leave
status checking mode by sending NAND_CMD_READ0, so use both of them
instead of direct access to the controller registers.

Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru>
---
 drivers/mtd/nand/raw/meson_nand.c | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/drivers/mtd/nand/raw/meson_nand.c b/drivers/mtd/nand/raw/meson_nand.c
index c7213f03a773..54e7fdbf0706 100644
--- a/drivers/mtd/nand/raw/meson_nand.c
+++ b/drivers/mtd/nand/raw/meson_nand.c
@@ -422,9 +422,10 @@ static void meson_nfc_set_data_oob(struct nand_chip *nand,
 	}
 }
 
-static int meson_nfc_wait_no_rb_pin(struct meson_nfc *nfc, int timeout_ms,
+static int meson_nfc_wait_no_rb_pin(struct nand_chip *nand, int timeout_ms,
 				    bool need_cmd_read0)
 {
+	struct meson_nfc *nfc = nand_get_controller_data(nand);
 	u32 cmd, cfg;
 
 	meson_nfc_cmd_idle(nfc, nfc->timing.twb);
@@ -436,8 +437,7 @@ static int meson_nfc_wait_no_rb_pin(struct meson_nfc *nfc, int timeout_ms,
 	writel(cfg, nfc->reg_base + NFC_REG_CFG);
 
 	reinit_completion(&nfc->completion);
-	cmd = nfc->param.chip_select | NFC_CMD_CLE | NAND_CMD_STATUS;
-	writel(cmd, nfc->reg_base + NFC_REG_CMD);
+	nand_status_op(nand, NULL);
 
 	/* use the max erase time as the maximum clock for waiting R/B */
 	cmd = NFC_CMD_RB | NFC_CMD_RB_INT_NO_PIN | nfc->timing.tbers_max;
@@ -447,12 +447,8 @@ static int meson_nfc_wait_no_rb_pin(struct meson_nfc *nfc, int timeout_ms,
 					 msecs_to_jiffies(timeout_ms)))
 		return -ETIMEDOUT;
 
-	if (need_cmd_read0) {
-		cmd = nfc->param.chip_select | NFC_CMD_CLE | NAND_CMD_READ0;
-		writel(cmd, nfc->reg_base + NFC_REG_CMD);
-		meson_nfc_drain_cmd(nfc);
-		meson_nfc_wait_cmd_finish(nfc, CMD_FIFO_EMPTY_TIMEOUT);
-	}
+	if (need_cmd_read0)
+		nand_exit_status_op(nand);
 
 	return 0;
 }
@@ -485,9 +481,11 @@ static int meson_nfc_wait_rb_pin(struct meson_nfc *nfc, int timeout_ms)
 	return ret;
 }
 
-static int meson_nfc_queue_rb(struct meson_nfc *nfc, int timeout_ms,
+static int meson_nfc_queue_rb(struct nand_chip *nand, int timeout_ms,
 			      bool need_cmd_read0)
 {
+	struct meson_nfc *nfc = nand_get_controller_data(nand);
+
 	if (nfc->no_rb_pin) {
 		/* This mode is used when there is no wired R/B pin.
 		 * It works like 'nand_soft_waitrdy()', but instead of
@@ -499,7 +497,7 @@ static int meson_nfc_queue_rb(struct meson_nfc *nfc, int timeout_ms,
 		 * needed (for all cases except page programming - this
 		 * is reason of 'need_cmd_read0' flag).
 		 */
-		return meson_nfc_wait_no_rb_pin(nfc, timeout_ms,
+		return meson_nfc_wait_no_rb_pin(nand, timeout_ms,
 						need_cmd_read0);
 	} else {
 		return meson_nfc_wait_rb_pin(nfc, timeout_ms);
@@ -709,7 +707,7 @@ static int meson_nfc_rw_cmd_prepare_and_execute(struct nand_chip *nand,
 	if (in) {
 		nfc->cmdfifo.rw.cmd1 = cs | NFC_CMD_CLE | NAND_CMD_READSTART;
 		writel(nfc->cmdfifo.rw.cmd1, nfc->reg_base + NFC_REG_CMD);
-		meson_nfc_queue_rb(nfc, PSEC_TO_MSEC(sdr->tR_max), true);
+		meson_nfc_queue_rb(nand, PSEC_TO_MSEC(sdr->tR_max), true);
 	} else {
 		meson_nfc_cmd_idle(nfc, nfc->timing.tadl);
 	}
@@ -755,7 +753,7 @@ static int meson_nfc_write_page_sub(struct nand_chip *nand,
 
 	cmd = nfc->param.chip_select | NFC_CMD_CLE | NAND_CMD_PAGEPROG;
 	writel(cmd, nfc->reg_base + NFC_REG_CMD);
-	meson_nfc_queue_rb(nfc, PSEC_TO_MSEC(sdr->tPROG_max), false);
+	meson_nfc_queue_rb(nand, PSEC_TO_MSEC(sdr->tPROG_max), false);
 
 	meson_nfc_dma_buffer_release(nand, data_len, info_len, DMA_TO_DEVICE);
 
@@ -1071,7 +1069,7 @@ static int meson_nfc_exec_op(struct nand_chip *nand,
 			break;
 
 		case NAND_OP_WAITRDY_INSTR:
-			meson_nfc_queue_rb(nfc, instr->ctx.waitrdy.timeout_ms,
+			meson_nfc_queue_rb(nand, instr->ctx.waitrdy.timeout_ms,
 					   true);
 			if (instr->delay_ns)
 				meson_nfc_cmd_idle(nfc, delay_idle);
-- 
2.35.0


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

* Re: [PATCH v1 2/2] mtd: rawnand: meson: use NAND core API to check status
  2023-07-05 10:43 ` [PATCH v1 2/2] mtd: rawnand: meson: use NAND core API to check status Arseniy Krasnov
@ 2023-07-13  7:58   ` Miquel Raynal
  0 siblings, 0 replies; 5+ messages in thread
From: Miquel Raynal @ 2023-07-13  7:58 UTC (permalink / raw)
  To: Arseniy Krasnov, Liang Yang, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, Neil Armstrong, Kevin Hilman, Jerome Brunet,
	Martin Blumenstingl, Adam Borowski, ChenXiaoSong, JaimeLiao,
	Andy Shevchenko, Michał Kępień
  Cc: oxffffaa, kernel, linux-mtd, linux-arm-kernel, linux-amlogic,
	linux-kernel

On Wed, 2023-07-05 at 10:43:58 UTC, Arseniy Krasnov wrote:
> NAND core API already has functions to send NAND_CMD_STATUS and leave
> status checking mode by sending NAND_CMD_READ0, so use both of them
> instead of direct access to the controller registers.
> 
> Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru>

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

Miquel

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

* Re: [PATCH v1 1/2] mtd: rawnand: export 'nand_exit_status_op()'
  2023-07-05 10:43 ` [PATCH v1 1/2] mtd: rawnand: export 'nand_exit_status_op()' Arseniy Krasnov
@ 2023-07-13  7:58   ` Miquel Raynal
  0 siblings, 0 replies; 5+ messages in thread
From: Miquel Raynal @ 2023-07-13  7:58 UTC (permalink / raw)
  To: Arseniy Krasnov, Liang Yang, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, Neil Armstrong, Kevin Hilman, Jerome Brunet,
	Martin Blumenstingl, JaimeLiao, Michał Kępień,
	Andy Shevchenko, ChenXiaoSong, Adam Borowski
  Cc: oxffffaa, kernel, linux-mtd, linux-arm-kernel, linux-amlogic,
	linux-kernel

On Wed, 2023-07-05 at 10:43:57 UTC, Arseniy Krasnov wrote:
> Export this function to work in pair with 'nand_status_op()' which is
> already exported.
> 
> Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru>

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

Miquel

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

end of thread, other threads:[~2023-07-13  7:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-05 10:43 [PATCH v1 0/2] use NAND core API for Meson controller Arseniy Krasnov
2023-07-05 10:43 ` [PATCH v1 1/2] mtd: rawnand: export 'nand_exit_status_op()' Arseniy Krasnov
2023-07-13  7:58   ` Miquel Raynal
2023-07-05 10:43 ` [PATCH v1 2/2] mtd: rawnand: meson: use NAND core API to check status Arseniy Krasnov
2023-07-13  7:58   ` Miquel Raynal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®