All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Cercueil <paul@crapouillou.net>
To: Boris Brezillon <boris.brezillon@collabora.com>
Cc: Vignesh Raghavendra <vigneshr@ti.com>,
	Tudor Ambarus <tudor.ambarus@microchip.com>,
	Richard Weinberger <richard@nod.at>,
	Harvey Hunt <harveyhuntnexus@gmail.com>,
	linux-mtd@lists.infradead.org,
	Miquel Raynal <miquel.raynal@bootlin.com>
Subject: Re: [PATCH] mtd: rawnand: ingenic: Convert the driver to exec_op()
Date: Tue, 19 May 2020 17:04:37 +0200	[thread overview]
Message-ID: <P73LAQ.QZS4PIAER4ZK@crapouillou.net> (raw)
In-Reply-To: <20200518213555.38e3a570@collabora.com>



Le lun. 18 mai 2020 à 21:35, Boris Brezillon 
<boris.brezillon@collabora.com> a écrit :
> On Mon, 18 May 2020 21:24:22 +0200
> Boris Brezillon <boris.brezillon@collabora.com> wrote:
> 
>>  On Mon, 18 May 2020 19:50:04 +0200
>>  Paul Cercueil <paul@crapouillou.net> wrote:
>> 
>>  > Hi Boris,
>>  >
>>  > Le lun. 18 mai 2020 à 18:56, Boris Brezillon
>>  > <boris.brezillon@collabora.com> a écrit :
>>  > > Let's convert the driver to exec_op() to have one less driver 
>> relying
>>  > > on the legacy interface.
>>  >
>>  > Great work, thanks for that.
>>  >
>>  > However it does not work :( nand_scan() returns error -145.
>> 
>>  Looks like the R/B signal is inverted. Can you try with the
>>  following diff applied?
> 
> I checked the DT, and the GPIO is indeed declared GPIO_ACTIVE_LOW,
> which explain why the test is inverted. Because of DT ABI stability it
> might not be an option to change that, but the signal should actually 
> be
> declared GPIO_ACTIVE_HIGH.

It depends what you consider what is the active state, is it when 
"busy" or "ready"? ;)

I can fix it in the devicetree, and the driver would return 
(gpiod_get_value_cansleep(gpiod) ^ gpiod_is_active_low(gpiod)) for 
compatibility with the old devicetree.

Cheers,

-Paul

>> 
>>  --->8---
>>  diff --git a/drivers/mtd/nand/raw/ingenic/ingenic_nand_drv.c 
>> b/drivers/mtd/nand/raw/ingenic/ingenic_nand_drv.c
>>  index dcecd54af20b..9206792629a8 100644
>>  --- a/drivers/mtd/nand/raw/ingenic/ingenic_nand_drv.c
>>  +++ b/drivers/mtd/nand/raw/ingenic/ingenic_nand_drv.c
>>  @@ -249,6 +249,26 @@ static int ingenic_nand_attach_chip(struct 
>> nand_chip *chip)
>>          return 0;
>>   }
>> 
>>  +static int ingenic_nand_gpio_waitrdy(struct gpio_desc *gpiod,
>>  +                                    unsigned long timeout_ms)
>>  +{
>>  +       /*
>>  +        * Wait until R/B pin indicates chip is ready or timeout 
>> occurs.
>>  +        * +1 below is necessary because if we are now in the last 
>> fraction
>>  +        * of jiffy and msecs_to_jiffies is 1 then we will wait 
>> only that
>>  +        * small jiffy fraction - possibly leading to false timeout.
>>  +       */
>>  +       timeout_ms = jiffies + msecs_to_jiffies(timeout_ms) + 1;
>>  +       do {
>>  +               if (!gpiod_get_value_cansleep(gpiod))
>>  +                       return 0;
>>  +
>>  +               cond_resched();
>>  +       } while (time_before(jiffies, timeout_ms));
>>  +
>>  +       return !gpiod_get_value_cansleep(gpiod) ? 0 : -ETIMEDOUT;
>>  +};
>>  +
>>   static int ingenic_nand_exec_instr(struct nand_chip *chip,
>>                                     struct ingenic_nand_cs *cs,
>>                                     const struct nand_op_instr 
>> *instr)
>>  @@ -294,8 +314,8 @@ static int ingenic_nand_exec_instr(struct 
>> nand_chip *chip,
>>                          return nand_soft_waitrdy(chip,
>>                                                   
>> instr->ctx.waitrdy.timeout_ms);
>> 
>>  -               return nand_gpio_waitrdy(chip, nand->busy_gpio,
>>  -                                        
>> instr->ctx.waitrdy.timeout_ms);
>>  +               return ingenic_nand_gpio_waitrdy(nand->busy_gpio,
>>  +                                                
>> instr->ctx.waitrdy.timeout_ms);
>>          default:
>>                  break;
>>          }
>>  @@ -322,6 +342,9 @@ static int ingenic_nand_exec_op(struct 
>> nand_chip *chip,
>>                  ret = ingenic_nand_exec_instr(chip, cs, 
>> &op->instrs[i]);
>>                  if (ret)
>>                          break;
>>  +
>>  +               if (op->instrs[i].delay_ns)
>>  +                       ndelay(op->instrs[i].delay_ns);
>>          }
>>          jz4780_nemc_assert(nfc->dev, cs->bank, false);
>> 
> 



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

  reply	other threads:[~2020-05-19 15:05 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-18 16:56 [PATCH] mtd: rawnand: ingenic: Convert the driver to exec_op() Boris Brezillon
2020-05-18 17:50 ` Paul Cercueil
2020-05-18 19:24   ` Boris Brezillon
2020-05-18 19:35     ` Boris Brezillon
2020-05-19 15:04       ` Paul Cercueil [this message]
2020-05-19 17:28         ` Boris Brezillon
2020-05-19 21:12           ` Paul Cercueil
2020-05-19 23:13             ` Boris Brezillon
2020-05-19 14:52     ` Paul Cercueil
2020-05-19 15:01       ` Boris Brezillon
2020-05-19 15:10         ` Paul Cercueil
2020-05-19 17:35           ` Boris Brezillon
2020-05-19 21:15             ` Paul Cercueil

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=P73LAQ.QZS4PIAER4ZK@crapouillou.net \
    --to=paul@crapouillou.net \
    --cc=boris.brezillon@collabora.com \
    --cc=harveyhuntnexus@gmail.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=miquel.raynal@bootlin.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.