linux/include/linux/mtd/onfi.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0 */
   2/*
   3 * Copyright © 2000-2010 David Woodhouse <dwmw2@infradead.org>
   4 *                       Steven J. Hill <sjhill@realitydiluted.com>
   5 *                       Thomas Gleixner <tglx@linutronix.de>
   6 *
   7 * Contains all ONFI related definitions
   8 */
   9
  10#ifndef __LINUX_MTD_ONFI_H
  11#define __LINUX_MTD_ONFI_H
  12
  13#include <linux/types.h>
  14
  15/* ONFI version bits */
  16#define ONFI_VERSION_1_0                BIT(1)
  17#define ONFI_VERSION_2_0                BIT(2)
  18#define ONFI_VERSION_2_1                BIT(3)
  19#define ONFI_VERSION_2_2                BIT(4)
  20#define ONFI_VERSION_2_3                BIT(5)
  21#define ONFI_VERSION_3_0                BIT(6)
  22#define ONFI_VERSION_3_1                BIT(7)
  23#define ONFI_VERSION_3_2                BIT(8)
  24#define ONFI_VERSION_4_0                BIT(9)
  25
  26/* ONFI features */
  27#define ONFI_FEATURE_16_BIT_BUS         (1 << 0)
  28#define ONFI_FEATURE_EXT_PARAM_PAGE     (1 << 7)
  29
  30/* ONFI timing mode, used in both asynchronous and synchronous mode */
  31#define ONFI_TIMING_MODE_0              (1 << 0)
  32#define ONFI_TIMING_MODE_1              (1 << 1)
  33#define ONFI_TIMING_MODE_2              (1 << 2)
  34#define ONFI_TIMING_MODE_3              (1 << 3)
  35#define ONFI_TIMING_MODE_4              (1 << 4)
  36#define ONFI_TIMING_MODE_5              (1 << 5)
  37#define ONFI_TIMING_MODE_UNKNOWN        (1 << 6)
  38
  39/* ONFI feature number/address */
  40#define ONFI_FEATURE_NUMBER             256
  41#define ONFI_FEATURE_ADDR_TIMING_MODE   0x1
  42
  43/* Vendor-specific feature address (Micron) */
  44#define ONFI_FEATURE_ADDR_READ_RETRY    0x89
  45#define ONFI_FEATURE_ON_DIE_ECC         0x90
  46#define   ONFI_FEATURE_ON_DIE_ECC_EN    BIT(3)
  47
  48/* ONFI subfeature parameters length */
  49#define ONFI_SUBFEATURE_PARAM_LEN       4
  50
  51/* ONFI optional commands SET/GET FEATURES supported? */
  52#define ONFI_OPT_CMD_SET_GET_FEATURES   (1 << 2)
  53
  54struct nand_onfi_params {
  55        /* rev info and features block */
  56        /* 'O' 'N' 'F' 'I'  */
  57        u8 sig[4];
  58        __le16 revision;
  59        __le16 features;
  60        __le16 opt_cmd;
  61        u8 reserved0[2];
  62        __le16 ext_param_page_length; /* since ONFI 2.1 */
  63        u8 num_of_param_pages;        /* since ONFI 2.1 */
  64        u8 reserved1[17];
  65
  66        /* manufacturer information block */
  67        char manufacturer[12];
  68        char model[20];
  69        u8 jedec_id;
  70        __le16 date_code;
  71        u8 reserved2[13];
  72
  73        /* memory organization block */
  74        __le32 byte_per_page;
  75        __le16 spare_bytes_per_page;
  76        __le32 data_bytes_per_ppage;
  77        __le16 spare_bytes_per_ppage;
  78        __le32 pages_per_block;
  79        __le32 blocks_per_lun;
  80        u8 lun_count;
  81        u8 addr_cycles;
  82        u8 bits_per_cell;
  83        __le16 bb_per_lun;
  84        __le16 block_endurance;
  85        u8 guaranteed_good_blocks;
  86        __le16 guaranteed_block_endurance;
  87        u8 programs_per_page;
  88        u8 ppage_attr;
  89        u8 ecc_bits;
  90        u8 interleaved_bits;
  91        u8 interleaved_ops;
  92        u8 reserved3[13];
  93
  94        /* electrical parameter block */
  95        u8 io_pin_capacitance_max;
  96        __le16 async_timing_mode;
  97        __le16 program_cache_timing_mode;
  98        __le16 t_prog;
  99        __le16 t_bers;
 100        __le16 t_r;
 101        __le16 t_ccs;
 102        __le16 src_sync_timing_mode;
 103        u8 src_ssync_features;
 104        __le16 clk_pin_capacitance_typ;
 105        __le16 io_pin_capacitance_typ;
 106        __le16 input_pin_capacitance_typ;
 107        u8 input_pin_capacitance_max;
 108        u8 driver_strength_support;
 109        __le16 t_int_r;
 110        __le16 t_adl;
 111        u8 reserved4[8];
 112
 113        /* vendor */
 114        __le16 vendor_revision;
 115        u8 vendor[88];
 116
 117        __le16 crc;
 118} __packed;
 119
 120#define ONFI_CRC_BASE   0x4F4E
 121
 122/* Extended ECC information Block Definition (since ONFI 2.1) */
 123struct onfi_ext_ecc_info {
 124        u8 ecc_bits;
 125        u8 codeword_size;
 126        __le16 bb_per_lun;
 127        __le16 block_endurance;
 128        u8 reserved[2];
 129} __packed;
 130
 131#define ONFI_SECTION_TYPE_0     0       /* Unused section. */
 132#define ONFI_SECTION_TYPE_1     1       /* for additional sections. */
 133#define ONFI_SECTION_TYPE_2     2       /* for ECC information. */
 134struct onfi_ext_section {
 135        u8 type;
 136        u8 length;
 137} __packed;
 138
 139#define ONFI_EXT_SECTION_MAX 8
 140
 141/* Extended Parameter Page Definition (since ONFI 2.1) */
 142struct onfi_ext_param_page {
 143        __le16 crc;
 144        u8 sig[4];             /* 'E' 'P' 'P' 'S' */
 145        u8 reserved0[10];
 146        struct onfi_ext_section sections[ONFI_EXT_SECTION_MAX];
 147
 148        /*
 149         * The actual size of the Extended Parameter Page is in
 150         * @ext_param_page_length of nand_onfi_params{}.
 151         * The following are the variable length sections.
 152         * So we do not add any fields below. Please see the ONFI spec.
 153         */
 154} __packed;
 155
 156/**
 157 * struct onfi_params - ONFI specific parameters that will be reused
 158 * @version: ONFI version (BCD encoded), 0 if ONFI is not supported
 159 * @tPROG: Page program time
 160 * @tBERS: Block erase time
 161 * @tR: Page read time
 162 * @tCCS: Change column setup time
 163 * @async_timing_mode: Supported asynchronous timing mode
 164 * @vendor_revision: Vendor specific revision number
 165 * @vendor: Vendor specific data
 166 * @jedec_id: jedec id of the flash
 167 */
 168struct onfi_params {
 169        int version;
 170        u16 tPROG;
 171        u16 tBERS;
 172        u16 tR;
 173        u16 tCCS;
 174        u16 async_timing_mode;
 175        u16 src_sync_timing_mode;
 176        u16 vendor_revision;
 177        u8 vendor[88];
 178        u8 jedec_id;
 179};
 180
 181#endif /* __LINUX_MTD_ONFI_H */
 182