Message ID | 20200710065816.60312-2-ley.foon.tan@intel.com |
---|---|
State | Superseded |
Headers | show |
Series | [v2,1/2] mtd: nand: raw: denali: Assert reset before deassert | expand |
On Fri, Jul 10, 2020 at 3:58 PM Ley Foon Tan <ley.foon.tan at intel.com> wrote: > > Fixed delay 200us is not working in certain platforms. Change to > poll for reset completion status to have more reliable reset process. > > Controller will set the rst_comp bit in intr_status register after > controller has completed its reset and initialization process. > > Tested-by: Masahiro Yamada <yamada.masahiro at socionext.com> > Signed-off-by: Radu Bacrau <radu.bacrau at intel.com> > Signed-off-by: Ley Foon Tan <ley.foon.tan at intel.com> > > --- > v2: > - Added "Tested-by" in commit message. > - Restore "bootstrap process" in comment. > --- > drivers/mtd/nand/raw/denali.c | 11 +++++++++++ > drivers/mtd/nand/raw/denali.h | 1 + > drivers/mtd/nand/raw/denali_dt.c | 11 ++++++++--- > 3 files changed, 20 insertions(+), 3 deletions(-) > > diff --git a/drivers/mtd/nand/raw/denali.c b/drivers/mtd/nand/raw/denali.c > index 15e90291de09..ab91db85467d 100644 > --- a/drivers/mtd/nand/raw/denali.c > +++ b/drivers/mtd/nand/raw/denali.c > @@ -1220,6 +1220,17 @@ static int denali_multidev_fixup(struct denali_nand_info *denali) > return 0; > } > > +int denali_wait_reset_complete(struct denali_nand_info *denali) > +{ > + u32 irq_status; > + > + irq_status = denali_wait_for_irq(denali, INTR__RST_COMP); > + if (!(irq_status & INTR__RST_COMP)) > + return -EIO; > + > + return 0; > +} > + > int denali_init(struct denali_nand_info *denali) > { > struct nand_chip *chip = &denali->nand; > diff --git a/drivers/mtd/nand/raw/denali.h b/drivers/mtd/nand/raw/denali.h > index 019deda094e5..6cd02b2e26ee 100644 > --- a/drivers/mtd/nand/raw/denali.h > +++ b/drivers/mtd/nand/raw/denali.h > @@ -321,6 +321,7 @@ struct denali_nand_info { > #define DENALI_CAP_DMA_64BIT BIT(1) > > int denali_calc_ecc_bytes(int step_size, int strength); > +int denali_wait_reset_complete(struct denali_nand_info *denali); > int denali_init(struct denali_nand_info *denali); > > #endif /* __DENALI_H__ */ > diff --git a/drivers/mtd/nand/raw/denali_dt.c b/drivers/mtd/nand/raw/denali_dt.c > index 75ad15b0758c..c22b05940df6 100644 > --- a/drivers/mtd/nand/raw/denali_dt.c > +++ b/drivers/mtd/nand/raw/denali_dt.c > @@ -154,10 +154,15 @@ static int denali_dt_probe(struct udevice *dev) > > /* > * When the reset is deasserted, the initialization sequence is > - * kicked (bootstrap process). The driver must wait until it is > - * finished. Otherwise, it will result in unpredictable behavior. > + * kicked (bootstrap proccess). The driver must wait until it Again, you are touching this comment line with no good reason. "proccess" is a typo. I fixed it up and applied. Thanks. > + * is finished. Otherwise, it will result in unpredictable > + * behavior. > */ > - udelay(200); > + ret = denali_wait_reset_complete(denali); > + if (ret) { > + dev_err(denali->dev, "reset not completed.\n"); > + return ret; > + } > } > > return denali_init(denali); > -- > 2.19.0 >
> -----Original Message----- > From: Masahiro Yamada <masahiroy at kernel.org> > Sent: Friday, July 10, 2020 9:08 PM > To: Tan, Ley Foon <ley.foon.tan at intel.com> > Cc: U-Boot Mailing List <u-boot at lists.denx.de>; Simon Glass > <sjg at chromium.org>; See, Chin Liang <chin.liang.see at intel.com>; Bacrau, > Radu <radu.bacrau at intel.com>; Marek Vasut <marex at denx.de> > Subject: Re: [PATCH v2 2/2] mtd: nand: raw: denali: Wait for reset > completion status > > On Fri, Jul 10, 2020 at 3:58 PM Ley Foon Tan <ley.foon.tan at intel.com> > wrote: > > > > Fixed delay 200us is not working in certain platforms. Change to poll > > for reset completion status to have more reliable reset process. > > > > Controller will set the rst_comp bit in intr_status register after > > controller has completed its reset and initialization process. > > > > Tested-by: Masahiro Yamada <yamada.masahiro at socionext.com> > > Signed-off-by: Radu Bacrau <radu.bacrau at intel.com> > > Signed-off-by: Ley Foon Tan <ley.foon.tan at intel.com> > > > > --- > > v2: > > - Added "Tested-by" in commit message. > > - Restore "bootstrap process" in comment. > > --- > > drivers/mtd/nand/raw/denali.c | 11 +++++++++++ > > drivers/mtd/nand/raw/denali.h | 1 + > > drivers/mtd/nand/raw/denali_dt.c | 11 ++++++++--- > > 3 files changed, 20 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/mtd/nand/raw/denali.c > > b/drivers/mtd/nand/raw/denali.c index 15e90291de09..ab91db85467d > > 100644 > > --- a/drivers/mtd/nand/raw/denali.c > > +++ b/drivers/mtd/nand/raw/denali.c > > @@ -1220,6 +1220,17 @@ static int denali_multidev_fixup(struct > denali_nand_info *denali) > > return 0; > > } > > > > +int denali_wait_reset_complete(struct denali_nand_info *denali) { > > + u32 irq_status; > > + > > + irq_status = denali_wait_for_irq(denali, INTR__RST_COMP); > > + if (!(irq_status & INTR__RST_COMP)) > > + return -EIO; > > + > > + return 0; > > +} > > + > > int denali_init(struct denali_nand_info *denali) { > > struct nand_chip *chip = &denali->nand; diff --git > > a/drivers/mtd/nand/raw/denali.h b/drivers/mtd/nand/raw/denali.h index > > 019deda094e5..6cd02b2e26ee 100644 > > --- a/drivers/mtd/nand/raw/denali.h > > +++ b/drivers/mtd/nand/raw/denali.h > > @@ -321,6 +321,7 @@ struct denali_nand_info { > > #define DENALI_CAP_DMA_64BIT BIT(1) > > > > int denali_calc_ecc_bytes(int step_size, int strength); > > +int denali_wait_reset_complete(struct denali_nand_info *denali); > > int denali_init(struct denali_nand_info *denali); > > > > #endif /* __DENALI_H__ */ > > diff --git a/drivers/mtd/nand/raw/denali_dt.c > > b/drivers/mtd/nand/raw/denali_dt.c > > index 75ad15b0758c..c22b05940df6 100644 > > --- a/drivers/mtd/nand/raw/denali_dt.c > > +++ b/drivers/mtd/nand/raw/denali_dt.c > > @@ -154,10 +154,15 @@ static int denali_dt_probe(struct udevice *dev) > > > > /* > > * When the reset is deasserted, the initialization sequence is > > - * kicked (bootstrap process). The driver must wait until it is > > - * finished. Otherwise, it will result in unpredictable behavior. > > + * kicked (bootstrap proccess). The driver must wait > > + until it > > > Again, you are touching this comment line with no good reason. > "proccess" is a typo. > > > I fixed it up and applied. > Thanks. Thanks. Regards Ley Foon
diff --git a/drivers/mtd/nand/raw/denali.c b/drivers/mtd/nand/raw/denali.c index 15e90291de09..ab91db85467d 100644 --- a/drivers/mtd/nand/raw/denali.c +++ b/drivers/mtd/nand/raw/denali.c @@ -1220,6 +1220,17 @@ static int denali_multidev_fixup(struct denali_nand_info *denali) return 0; } +int denali_wait_reset_complete(struct denali_nand_info *denali) +{ + u32 irq_status; + + irq_status = denali_wait_for_irq(denali, INTR__RST_COMP); + if (!(irq_status & INTR__RST_COMP)) + return -EIO; + + return 0; +} + int denali_init(struct denali_nand_info *denali) { struct nand_chip *chip = &denali->nand; diff --git a/drivers/mtd/nand/raw/denali.h b/drivers/mtd/nand/raw/denali.h index 019deda094e5..6cd02b2e26ee 100644 --- a/drivers/mtd/nand/raw/denali.h +++ b/drivers/mtd/nand/raw/denali.h @@ -321,6 +321,7 @@ struct denali_nand_info { #define DENALI_CAP_DMA_64BIT BIT(1) int denali_calc_ecc_bytes(int step_size, int strength); +int denali_wait_reset_complete(struct denali_nand_info *denali); int denali_init(struct denali_nand_info *denali); #endif /* __DENALI_H__ */ diff --git a/drivers/mtd/nand/raw/denali_dt.c b/drivers/mtd/nand/raw/denali_dt.c index 75ad15b0758c..c22b05940df6 100644 --- a/drivers/mtd/nand/raw/denali_dt.c +++ b/drivers/mtd/nand/raw/denali_dt.c @@ -154,10 +154,15 @@ static int denali_dt_probe(struct udevice *dev) /* * When the reset is deasserted, the initialization sequence is - * kicked (bootstrap process). The driver must wait until it is - * finished. Otherwise, it will result in unpredictable behavior. + * kicked (bootstrap proccess). The driver must wait until it + * is finished. Otherwise, it will result in unpredictable + * behavior. */ - udelay(200); + ret = denali_wait_reset_complete(denali); + if (ret) { + dev_err(denali->dev, "reset not completed.\n"); + return ret; + } } return denali_init(denali);