Skip to content

Commit 26d014f

Browse files
committed
mtd: rawnand: Add the ->choose_interface_config() hook
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@bootlin.com> Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com> Link: https://lore.kernel.org/linux-mtd/20200529111322.7184-23-miquel.raynal@bootlin.com
1 parent b5b39f6 commit 26d014f

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

‎drivers/mtd/nand/raw/nand_base.c‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,18 +1066,23 @@ int nand_choose_best_sdr_timings(struct nand_chip *chip,
10661066
* @chip: The NAND chip
10671067
*
10681068
* Find the best data interface and NAND timings supported by the chip
1069-
* and the driver.
1070-
* First tries to retrieve supported timing modes from ONFI information,
1071-
* and if the NAND chip does not support ONFI, relies on the
1072-
* ->onfi_timing_mode_default specified in the nand_ids table. After this
1073-
* function nand_chip->interface_ is initialized with the best timing mode
1074-
* available.
1069+
* and the driver. Eventually let the NAND manufacturer driver propose his own
1070+
* set of timings.
1071+
*
1072+
* After this function nand_chip->interface_config is initialized with the best
1073+
* timing mode available.
1074+
*
1075+
* Returns 0 for success or negative error code otherwise.
10751076
*/
10761077
static int nand_choose_interface_config(struct nand_chip *chip)
10771078
{
10781079
if (!nand_controller_can_setup_interface(chip))
10791080
return 0;
10801081

1082+
if (chip->ops.choose_interface_config)
1083+
return chip->ops.choose_interface_config(chip,
1084+
&chip->interface_config);
1085+
10811086
return nand_choose_best_sdr_timings(chip, &chip->interface_config,
10821087
NULL);
10831088
}

‎include/linux/mtd/rawnand.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,13 +1033,16 @@ struct nand_legacy {
10331033
* @lock_area: Lock operation
10341034
* @unlock_area: Unlock operation
10351035
* @setup_read_retry: Set the read-retry mode (mostly needed for MLC NANDs)
1036+
* @choose_interface_config: Choose the best interface configuration
10361037
*/
10371038
struct nand_chip_ops {
10381039
int (*suspend)(struct nand_chip *chip);
10391040
void (*resume)(struct nand_chip *chip);
10401041
int (*lock_area)(struct nand_chip *chip, loff_t ofs, uint64_t len);
10411042
int (*unlock_area)(struct nand_chip *chip, loff_t ofs, uint64_t len);
10421043
int (*setup_read_retry)(struct nand_chip *chip, int retry_mode);
1044+
int (*choose_interface_config)(struct nand_chip *chip,
1045+
struct nand_interface_config *iface);
10431046
};
10441047

10451048
/**

0 commit comments

Comments
 (0)