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.
11 #include <linux/kernel.h>
12 #include <linux/err.h>
13 #include <linux/export.h>
14 #include <linux/mtd/nand.h>
16 static const struct nand_data_interface onfi_sdr_timings
[] = {
19 .type
= NAND_SDR_IFACE
,
48 .tRST_max
= 250000000000ULL,
59 .type
= NAND_SDR_IFACE
,
88 .tRST_max
= 500000000,
99 .type
= NAND_SDR_IFACE
,
116 .tFEAT_max
= 1000000,
127 .tRST_max
= 500000000,
139 .type
= NAND_SDR_IFACE
,
156 .tFEAT_max
= 1000000,
168 .tRST_max
= 500000000,
179 .type
= NAND_SDR_IFACE
,
196 .tFEAT_max
= 1000000,
208 .tRST_max
= 500000000,
219 .type
= NAND_SDR_IFACE
,
236 .tFEAT_max
= 1000000,
248 .tRST_max
= 500000000,
260 * onfi_async_timing_mode_to_sdr_timings - [NAND Interface] Retrieve NAND
261 * timings according to the given ONFI timing mode
262 * @mode: ONFI timing mode
264 const struct nand_sdr_timings
*onfi_async_timing_mode_to_sdr_timings(int mode
)
266 if (mode
< 0 || mode
>= ARRAY_SIZE(onfi_sdr_timings
))
267 return ERR_PTR(-EINVAL
);
269 return &onfi_sdr_timings
[mode
].timings
.sdr
;
271 EXPORT_SYMBOL(onfi_async_timing_mode_to_sdr_timings
);
274 * onfi_init_data_interface - [NAND Interface] Initialize a data interface from
276 * @iface: The data interface to be initialized
277 * @mode: The ONFI timing mode
279 int onfi_init_data_interface(struct nand_chip
*chip
,
280 struct nand_data_interface
*iface
,
281 enum nand_data_interface_type type
,
284 if (type
!= NAND_SDR_IFACE
)
287 if (timing_mode
< 0 || timing_mode
>= ARRAY_SIZE(onfi_sdr_timings
))
290 *iface
= onfi_sdr_timings
[timing_mode
];
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.
300 EXPORT_SYMBOL(onfi_init_data_interface
);
303 * nand_get_default_data_interface - [NAND Interface] Retrieve NAND
304 * data interface for mode 0. This is used as default timing after
307 const struct nand_data_interface
*nand_get_default_data_interface(void)
309 return &onfi_sdr_timings
[0];
311 EXPORT_SYMBOL(nand_get_default_data_interface
);