Skip to content

Commit b88730a

Browse files
saschahauerBoris Brezillon
authored andcommitted
mtd: nand: Add function to convert ONFI mode to data_interface
onfi_init_data_interface() initializes a data interface with values from a given ONFI mode. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
1 parent b1dd3ca commit b88730a

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

‎drivers/mtd/nand/nand_timings.c‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,3 +269,32 @@ const struct nand_sdr_timings *onfi_async_timing_mode_to_sdr_timings(int mode)
269269
return &onfi_sdr_timings[mode].timings.sdr;
270270
}
271271
EXPORT_SYMBOL(onfi_async_timing_mode_to_sdr_timings);
272+
273+
/**
274+
* onfi_init_data_interface - [NAND Interface] Initialize a data interface from
275+
* given ONFI mode
276+
* @iface: The data interface to be initialized
277+
* @mode: The ONFI timing mode
278+
*/
279+
int onfi_init_data_interface(struct nand_chip *chip,
280+
struct nand_data_interface *iface,
281+
enum nand_data_interface_type type,
282+
int timing_mode)
283+
{
284+
if (type != NAND_SDR_IFACE)
285+
return -EINVAL;
286+
287+
if (timing_mode < 0 || timing_mode >= ARRAY_SIZE(onfi_sdr_timings))
288+
return -EINVAL;
289+
290+
*iface = onfi_sdr_timings[timing_mode];
291+
292+
/*
293+
* TODO: initialize timings that cannot be deduced from timing mode:
294+
* tR, tPROG, tCCS, ...
295+
* These information are part of the ONFI parameter page.
296+
*/
297+
298+
return 0;
299+
}
300+
EXPORT_SYMBOL(onfi_init_data_interface);

‎include/linux/mtd/nand.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,11 @@ static inline int onfi_get_sync_timing_mode(struct nand_chip *chip)
11121112
return le16_to_cpu(chip->onfi_params.src_sync_timing_mode);
11131113
}
11141114

1115+
int onfi_init_data_interface(struct nand_chip *chip,
1116+
struct nand_data_interface *iface,
1117+
enum nand_data_interface_type type,
1118+
int timing_mode);
1119+
11151120
/*
11161121
* Check if it is a SLC nand.
11171122
* The !nand_is_slc() can be used to check the MLC/TLC nand chips.

0 commit comments

Comments
 (0)