2 * Copyright (C) 2014 Free Electrons
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>
15 #include "internals.h"
17 #define ONFI_DYN_TIMING_MAX U16_MAX
19 static const struct nand_data_interface onfi_sdr_timings[] = {
22 .type = NAND_SDR_IFACE,
53 .tRST_max = 250000000000ULL,
64 .type = NAND_SDR_IFACE,
95 .tRST_max = 500000000,
106 .type = NAND_SDR_IFACE,
125 .tFEAT_max = 1000000,
136 .tRST_max = 500000000,
148 .type = NAND_SDR_IFACE,
167 .tFEAT_max = 1000000,
179 .tRST_max = 500000000,
190 .type = NAND_SDR_IFACE,
209 .tFEAT_max = 1000000,
221 .tRST_max = 500000000,
232 .type = NAND_SDR_IFACE,
251 .tFEAT_max = 1000000,
263 .tRST_max = 500000000,
275 * onfi_fill_data_interface - [NAND Interface] Initialize a data interface from
277 * @mode: The ONFI timing mode
279 int onfi_fill_data_interface(struct nand_chip *chip,
280 enum nand_data_interface_type type,
283 struct nand_data_interface *iface = &chip->data_interface;
284 struct onfi_params *onfi = chip->parameters.onfi;
286 if (type != NAND_SDR_IFACE)
289 if (timing_mode < 0 || timing_mode >= ARRAY_SIZE(onfi_sdr_timings))
292 *iface = onfi_sdr_timings[timing_mode];
295 * Initialize timings that cannot be deduced from timing mode:
296 * tPROG, tBERS, tR and tCCS.
297 * These information are part of the ONFI parameter page.
300 struct nand_sdr_timings *timings = &iface->timings.sdr;
302 /* microseconds -> picoseconds */
303 timings->tPROG_max = 1000000ULL * onfi->tPROG;
304 timings->tBERS_max = 1000000ULL * onfi->tBERS;
305 timings->tR_max = 1000000ULL * onfi->tR;
307 /* nanoseconds -> picoseconds */
308 timings->tCCS_min = 1000UL * onfi->tCCS;
310 struct nand_sdr_timings *timings = &iface->timings.sdr;
312 * For non-ONFI chips we use the highest possible value for
313 * tPROG and tBERS. tR and tCCS will take the default values
314 * precised in the ONFI specification for timing mode 0,
315 * respectively 200us and 500ns.
318 /* microseconds -> picoseconds */
319 timings->tPROG_max = 1000000ULL * ONFI_DYN_TIMING_MAX;
320 timings->tBERS_max = 1000000ULL * ONFI_DYN_TIMING_MAX;
321 timings->tR_max = 1000000ULL * 200000000ULL;
323 /* nanoseconds -> picoseconds */
324 timings->tCCS_min = 1000UL * 500000;