1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2014 Free Electrons
5 * Author: Boris BREZILLON <boris.brezillon@free-electrons.com>
7 #include <linux/kernel.h>
9 #include <linux/export.h>
11 #include "internals.h"
13 #define ONFI_DYN_TIMING_MAX U16_MAX
15 static const struct nand_data_interface onfi_sdr_timings
[] = {
18 .type
= NAND_SDR_IFACE
,
49 .tRST_max
= 250000000000ULL,
60 .type
= NAND_SDR_IFACE
,
91 .tRST_max
= 500000000,
102 .type
= NAND_SDR_IFACE
,
121 .tFEAT_max
= 1000000,
132 .tRST_max
= 500000000,
144 .type
= NAND_SDR_IFACE
,
163 .tFEAT_max
= 1000000,
175 .tRST_max
= 500000000,
186 .type
= NAND_SDR_IFACE
,
205 .tFEAT_max
= 1000000,
217 .tRST_max
= 500000000,
228 .type
= NAND_SDR_IFACE
,
247 .tFEAT_max
= 1000000,
259 .tRST_max
= 500000000,
271 * onfi_fill_data_interface - [NAND Interface] Initialize a data interface from
273 * @mode: The ONFI timing mode
275 int onfi_fill_data_interface(struct nand_chip
*chip
,
276 enum nand_data_interface_type type
,
279 struct nand_data_interface
*iface
= &chip
->data_interface
;
280 struct onfi_params
*onfi
= chip
->parameters
.onfi
;
282 if (type
!= NAND_SDR_IFACE
)
285 if (timing_mode
< 0 || timing_mode
>= ARRAY_SIZE(onfi_sdr_timings
))
288 *iface
= onfi_sdr_timings
[timing_mode
];
291 * Initialize timings that cannot be deduced from timing mode:
292 * tPROG, tBERS, tR and tCCS.
293 * These information are part of the ONFI parameter page.
296 struct nand_sdr_timings
*timings
= &iface
->timings
.sdr
;
298 /* microseconds -> picoseconds */
299 timings
->tPROG_max
= 1000000ULL * onfi
->tPROG
;
300 timings
->tBERS_max
= 1000000ULL * onfi
->tBERS
;
301 timings
->tR_max
= 1000000ULL * onfi
->tR
;
303 /* nanoseconds -> picoseconds */
304 timings
->tCCS_min
= 1000UL * onfi
->tCCS
;
306 struct nand_sdr_timings
*timings
= &iface
->timings
.sdr
;
308 * For non-ONFI chips we use the highest possible value for
309 * tPROG and tBERS. tR and tCCS will take the default values
310 * precised in the ONFI specification for timing mode 0,
311 * respectively 200us and 500ns.
314 /* microseconds -> picoseconds */
315 timings
->tPROG_max
= 1000000ULL * ONFI_DYN_TIMING_MAX
;
316 timings
->tBERS_max
= 1000000ULL * ONFI_DYN_TIMING_MAX
;
317 timings
->tR_max
= 1000000ULL * 200000000ULL;
319 /* nanoseconds -> picoseconds */
320 timings
->tCCS_min
= 1000UL * 500000;