On Fri, 29 May 2020 13:13:16 +0200 Miquel Raynal <miquel.raynal@xxxxxxxxxxx> wrote: > This hook can be overloaded by NAND manufacturer drivers to propose > alternative timings when not following the main standards. In this > case, the manufacturer drivers is responsible for choosing the best > interface configuration that fits both the controller and chip > capabilities. > > Signed-off-by: Miquel Raynal <miquel.raynal@xxxxxxxxxxx> Reviewed-by: Boris Brezillon <boris.brezillon@xxxxxxxxxxxxx> > --- > drivers/mtd/nand/raw/nand_base.c | 18 +++++++++++------- > include/linux/mtd/rawnand.h | 3 +++ > 2 files changed, 14 insertions(+), 7 deletions(-) > > diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c > index 956a66fdccb8..2f4eba1a1082 100644 > --- a/drivers/mtd/nand/raw/nand_base.c > +++ b/drivers/mtd/nand/raw/nand_base.c > @@ -1049,7 +1049,6 @@ int nand_choose_best_sdr_timings(struct nand_chip *chip, > } > } > > - Still this unrelated blank line removal :-). > for (mode = best_mode; mode >= 0; mode--) { > onfi_fill_interface_config(chip, iface, NAND_SDR_IFACE, mode); > > @@ -1067,18 +1066,23 @@ int nand_choose_best_sdr_timings(struct nand_chip *chip, > * @chip: The NAND chip > * > * Find the best data interface and NAND timings supported by the chip > - * and the driver. > - * First tries to retrieve supported timing modes from ONFI information, > - * and if the NAND chip does not support ONFI, relies on the > - * ->onfi_timing_mode_default specified in the nand_ids table. After this > - * function nand_chip->interface_ is initialized with the best timing mode > - * available. > + * and the driver. Eventually let the NAND manufacturer driver propose his own > + * set of timings. > + * > + * After this function nand_chip->interface_config is initialized with the best > + * timing mode available. > + * > + * Returns 0 for success or negative error code otherwise. > */ > static int nand_choose_interface_config(struct nand_chip *chip) > { > if (!nand_controller_can_setup_interface(chip)) > return 0; > > + if (chip->ops.choose_interface_config) > + return chip->ops.choose_interface_config(chip, > + &chip->interface_config); > + > return nand_choose_best_sdr_timings(chip, &chip->interface_config, > NULL); > } > diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h > index 2ca56eef0f07..316a02189da1 100644 > --- a/include/linux/mtd/rawnand.h > +++ b/include/linux/mtd/rawnand.h > @@ -1033,6 +1033,7 @@ struct nand_legacy { > * @lock_area: Lock operation > * @unlock_area: Unlock operation > * @setup_read_retry: Set the read-retry mode (mostly needed for MLC NANDs) > + * @choose_interface_config: Choose the best interface configuration > */ > struct nand_chip_ops { > int (*suspend)(struct nand_chip *chip); > @@ -1040,6 +1041,8 @@ struct nand_chip_ops { > int (*lock_area)(struct nand_chip *chip, loff_t ofs, uint64_t len); > int (*unlock_area)(struct nand_chip *chip, loff_t ofs, uint64_t len); > int (*setup_read_retry)(struct nand_chip *chip, int retry_mode); > + int (*choose_interface_config)(struct nand_chip *chip, > + struct nand_interface_config *iface); > }; > > /** ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/