From: Boris Brezillon <boris.brezillon@collabora.com>
To: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Cc: Vignesh Raghavendra <vigneshr@ti.com>,
Tudor Ambarus <tudor.ambarus@microchip.com>,
Richard Weinberger <richard@nod.at>, Sekhar Nori <nsekhar@ti.com>,
"open list:MEMORY TECHNOLOGY..." <linux-mtd@lists.infradead.org>,
Miquel Raynal <miquel.raynal@bootlin.com>
Subject: Re: [PATCH 0/5] mtd: rawnand: davinci: Convert to exec_op()
Date: Sat, 9 May 2020 16:13:25 +0200 [thread overview]
Message-ID: <20200509161325.46dcb266@collabora.com> (raw)
In-Reply-To: <CAMpxmJXmPcwo6uomrrwbcFe9gkhxvYVw0Y6o1n5uSGBwPKd5_A@mail.gmail.com>
On Mon, 4 May 2020 18:34:55 +0200
Bartosz Golaszewski <bgolaszewski@baylibre.com> wrote:
> pt., 1 maj 2020 o 12:07 Boris Brezillon
> <boris.brezillon@collabora.com> napisał(a):
> >
> > 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 Davinci NAND controller driver to
> > exec_op(), plus a bunch of minor improvements done along the way.
> >
> > Regards,
> >
> > Boris
> >
> > Boris Brezillon (5):
> > mtd: rawnand: davinci: Inherit from nand_controller
> > mtd: rawnand: davinci: Stop using nand_chip.legacy.IO_ADDR_{R,W}
> > mtd: rawnand: davinci: Implement exec_op()
> > mtd: rawnand: davinci: Get rid of the legacy interface implementation
> > mtd: rawnand: davinci: Change the {read,write}_buf prototypes
> >
> > drivers/mtd/nand/raw/davinci_nand.c | 161 +++++++++++++++-------------
> > 1 file changed, 85 insertions(+), 76 deletions(-)
> >
> > --
> > 2.25.3
> >
>
> Hi Boris,
>
> Thanks for doing this. Unfortunately this breaks NAND on da850-lcdk
> with the following error message:
>
> nand: No NAND device found
I had a second look and the below diff should fix the detection (you
can also find those changes in my exec-op-conversion branch [1]).
[1]https://github.com/bbrezillon/linux/tree/nand/exec-op-conversion
--->8---
diff --git a/drivers/mtd/nand/raw/davinci_nand.c b/drivers/mtd/nand/raw/davinci_nand.c
index 296047884c6a..0eeb30c7fc4e 100644
--- a/drivers/mtd/nand/raw/davinci_nand.c
+++ b/drivers/mtd/nand/raw/davinci_nand.c
@@ -678,6 +678,33 @@ static int davinci_nand_attach_chip(struct nand_chip *chip)
return ret;
}
+static void nand_davinci_data_in(struct davinci_nand_info *info, void *buf,
+ unsigned int len, bool force_8bit)
+{
+ u32 alignment = ((uintptr_t)buf | len) & 3;
+
+ if (force_8bit || (alignment & 1))
+ ioread8_rep(info->current_cs, buf, len);
+ else if (alignment & 3)
+ ioread16_rep(info->current_cs, buf, len >> 1);
+ else
+ ioread32_rep(info->current_cs, buf, len >> 2);
+}
+
+static void nand_davinci_data_out(struct davinci_nand_info *info,
+ const void *buf, unsigned int len,
+ bool force_8bit)
+{
+ u32 alignment = ((uintptr_t)buf | len) & 3;
+
+ if (force_8bit || (alignment & 1))
+ iowrite8_rep(info->current_cs, buf, len);
+ else if (alignment & 3)
+ iowrite16_rep(info->current_cs, buf, len >> 1);
+ else
+ iowrite32_rep(info->current_cs, buf, len >> 2);
+}
+
static int davinci_nand_exec_instr(struct davinci_nand_info *info,
const struct nand_op_instr *instr)
{
@@ -699,13 +726,15 @@ static int davinci_nand_exec_instr(struct davinci_nand_info *info,
break;
case NAND_OP_DATA_IN_INSTR:
- nand_davinci_read_buf(&info->chip, instr->ctx.data.buf.in,
- instr->ctx.data.len);
+ nand_davinci_data_in(info, instr->ctx.data.buf.in,
+ instr->ctx.data.len,
+ instr->ctx.data.force_8bit);
break;
case NAND_OP_DATA_OUT_INSTR:
- nand_davinci_write_buf(&info->chip, instr->ctx.data.buf.out,
- instr->ctx.data.len);
+ nand_davinci_data_out(info, instr->ctx.data.buf.out,
+ instr->ctx.data.len,
+ instr->ctx.data.force_8bit);
break;
case NAND_OP_WAITRDY_INSTR:
@@ -731,20 +760,21 @@ static int davinci_nand_exec_op(struct nand_chip *chip,
{
struct davinci_nand_info *info = to_davinci_nand(nand_to_mtd(chip));
unsigned int i;
- int ret;
if (check_only)
- return true;
+ return 0;
info->current_cs = info->vaddr + (op->cs * info->mask_chipsel);
for (i = 0; i < op->ninstrs; i++) {
+ int ret;
+
ret = davinci_nand_exec_instr(info, &op->instrs[i]);
if (ret)
- break;
+ return ret;
}
- return ret;
+ return 0;
}
static const struct nand_controller_ops davinci_nand_controller_ops = {
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2020-05-09 14:13 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-01 10:07 [PATCH 0/5] mtd: rawnand: davinci: Convert to exec_op() Boris Brezillon
2020-05-01 10:07 ` [PATCH 1/5] mtd: rawnand: davinci: Inherit from nand_controller Boris Brezillon
2020-05-10 21:35 ` Miquel Raynal
2020-05-01 10:07 ` [PATCH 2/5] mtd: rawnand: davinci: Stop using nand_chip.legacy.IO_ADDR_{R, W} Boris Brezillon
2020-05-10 21:37 ` [PATCH 2/5] mtd: rawnand: davinci: Stop using nand_chip.legacy.IO_ADDR_{R,W} Miquel Raynal
2020-05-01 10:07 ` [PATCH 3/5] mtd: rawnand: davinci: Implement exec_op() Boris Brezillon
2020-05-01 10:07 ` [PATCH 4/5] mtd: rawnand: davinci: Get rid of the legacy interface implementation Boris Brezillon
2020-05-10 21:38 ` Miquel Raynal
2020-05-01 10:07 ` [PATCH 5/5] mtd: rawnand: davinci: Change the {read, write}_buf prototypes Boris Brezillon
2020-05-10 21:39 ` [PATCH 5/5] mtd: rawnand: davinci: Change the {read,write}_buf prototypes Miquel Raynal
2020-05-04 16:34 ` [PATCH 0/5] mtd: rawnand: davinci: Convert to exec_op() Bartosz Golaszewski
2020-05-04 20:06 ` Boris Brezillon
2020-05-09 14:13 ` Boris Brezillon [this message]
2020-05-12 8:40 ` Bartosz Golaszewski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200509161325.46dcb266@collabora.com \
--to=boris.brezillon@collabora.com \
--cc=bgolaszewski@baylibre.com \
--cc=linux-mtd@lists.infradead.org \
--cc=miquel.raynal@bootlin.com \
--cc=nsekhar@ti.com \
--cc=richard@nod.at \
--cc=tudor.ambarus@microchip.com \
--cc=vigneshr@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.