2 * Copyright (C) 2014 Free Electrons
4 * Author: Boris BREZILLON <boris.brezillon@free-electrons.com>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
12 #include <linux/kernel.h>
13 #include <linux/mtd/nand.h>
15 static const struct nand_data_interface onfi_sdr_timings[] = {
18 .type = NAND_SDR_IFACE,
47 .tRST_max = 250000000000ULL,
58 .type = NAND_SDR_IFACE,
87 .tRST_max = 500000000,
98 .type = NAND_SDR_IFACE,
115 .tFEAT_max = 1000000,
126 .tRST_max = 500000000,
138 .type = NAND_SDR_IFACE,
155 .tFEAT_max = 1000000,
167 .tRST_max = 500000000,
178 .type = NAND_SDR_IFACE,
195 .tFEAT_max = 1000000,
207 .tRST_max = 500000000,
218 .type = NAND_SDR_IFACE,
235 .tFEAT_max = 1000000,
247 .tRST_max = 500000000,
259 * onfi_async_timing_mode_to_sdr_timings - [NAND Interface] Retrieve NAND
260 * timings according to the given ONFI timing mode
261 * @mode: ONFI timing mode
263 const struct nand_sdr_timings *onfi_async_timing_mode_to_sdr_timings(int mode)
265 if (mode < 0 || mode >= ARRAY_SIZE(onfi_sdr_timings))
266 return ERR_PTR(-EINVAL);
268 return &onfi_sdr_timings[mode].timings.sdr;
270 EXPORT_SYMBOL(onfi_async_timing_mode_to_sdr_timings);
273 * onfi_init_data_interface - [NAND Interface] Initialize a data interface from
275 * @iface: The data interface to be initialized
276 * @mode: The ONFI timing mode
278 int onfi_init_data_interface(struct nand_chip *chip,
279 struct nand_data_interface *iface,
280 enum nand_data_interface_type type,
283 if (type != NAND_SDR_IFACE)
286 if (timing_mode < 0 || timing_mode >= ARRAY_SIZE(onfi_sdr_timings))
289 *iface = onfi_sdr_timings[timing_mode];
292 * TODO: initialize timings that cannot be deduced from timing mode:
293 * tR, tPROG, tCCS, ...
294 * These information are part of the ONFI parameter page.
299 EXPORT_SYMBOL(onfi_init_data_interface);
302 * nand_get_default_data_interface - [NAND Interface] Retrieve NAND
303 * data interface for mode 0. This is used as default timing after
306 const struct nand_data_interface *nand_get_default_data_interface(void)
308 return &onfi_sdr_timings[0];
310 EXPORT_SYMBOL(nand_get_default_data_interface);