Jim Lin | 312693c | 2012-07-29 20:53:29 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * (C) Copyright 2011 NVIDIA Corporation <www.nvidia.com> |
| 3 | * |
| 4 | * See file CREDITS for list of people who contributed to this |
| 5 | * project. |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License as |
| 9 | * published by the Free Software Foundation; either version 2 of |
| 10 | * the License, or (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 20 | * MA 02111-1307 USA |
| 21 | */ |
| 22 | |
| 23 | /* register offset */ |
| 24 | #define COMMAND_0 0x00 |
| 25 | #define CMD_GO (1 << 31) |
| 26 | #define CMD_CLE (1 << 30) |
| 27 | #define CMD_ALE (1 << 29) |
| 28 | #define CMD_PIO (1 << 28) |
| 29 | #define CMD_TX (1 << 27) |
| 30 | #define CMD_RX (1 << 26) |
| 31 | #define CMD_SEC_CMD (1 << 25) |
| 32 | #define CMD_AFT_DAT_MASK (1 << 24) |
| 33 | #define CMD_AFT_DAT_DISABLE 0 |
| 34 | #define CMD_AFT_DAT_ENABLE (1 << 24) |
| 35 | #define CMD_TRANS_SIZE_SHIFT 20 |
| 36 | #define CMD_TRANS_SIZE_PAGE 8 |
| 37 | #define CMD_A_VALID (1 << 19) |
| 38 | #define CMD_B_VALID (1 << 18) |
| 39 | #define CMD_RD_STATUS_CHK (1 << 17) |
| 40 | #define CMD_R_BSY_CHK (1 << 16) |
| 41 | #define CMD_CE7 (1 << 15) |
| 42 | #define CMD_CE6 (1 << 14) |
| 43 | #define CMD_CE5 (1 << 13) |
| 44 | #define CMD_CE4 (1 << 12) |
| 45 | #define CMD_CE3 (1 << 11) |
| 46 | #define CMD_CE2 (1 << 10) |
| 47 | #define CMD_CE1 (1 << 9) |
| 48 | #define CMD_CE0 (1 << 8) |
| 49 | #define CMD_CLE_BYTE_SIZE_SHIFT 4 |
| 50 | enum { |
| 51 | CMD_CLE_BYTES1 = 0, |
| 52 | CMD_CLE_BYTES2, |
| 53 | CMD_CLE_BYTES3, |
| 54 | CMD_CLE_BYTES4, |
| 55 | }; |
| 56 | #define CMD_ALE_BYTE_SIZE_SHIFT 0 |
| 57 | enum { |
| 58 | CMD_ALE_BYTES1 = 0, |
| 59 | CMD_ALE_BYTES2, |
| 60 | CMD_ALE_BYTES3, |
| 61 | CMD_ALE_BYTES4, |
| 62 | CMD_ALE_BYTES5, |
| 63 | CMD_ALE_BYTES6, |
| 64 | CMD_ALE_BYTES7, |
| 65 | CMD_ALE_BYTES8 |
| 66 | }; |
| 67 | |
| 68 | #define STATUS_0 0x04 |
| 69 | #define STATUS_RBSY0 (1 << 8) |
| 70 | |
| 71 | #define ISR_0 0x08 |
| 72 | #define ISR_IS_CMD_DONE (1 << 5) |
| 73 | #define ISR_IS_ECC_ERR (1 << 4) |
| 74 | |
| 75 | #define IER_0 0x0C |
| 76 | |
| 77 | #define CFG_0 0x10 |
| 78 | #define CFG_HW_ECC_MASK (1 << 31) |
| 79 | #define CFG_HW_ECC_DISABLE 0 |
| 80 | #define CFG_HW_ECC_ENABLE (1 << 31) |
| 81 | #define CFG_HW_ECC_SEL_MASK (1 << 30) |
| 82 | #define CFG_HW_ECC_SEL_HAMMING 0 |
| 83 | #define CFG_HW_ECC_SEL_RS (1 << 30) |
| 84 | #define CFG_HW_ECC_CORRECTION_MASK (1 << 29) |
| 85 | #define CFG_HW_ECC_CORRECTION_DISABLE 0 |
| 86 | #define CFG_HW_ECC_CORRECTION_ENABLE (1 << 29) |
| 87 | #define CFG_PIPELINE_EN_MASK (1 << 28) |
| 88 | #define CFG_PIPELINE_EN_DISABLE 0 |
| 89 | #define CFG_PIPELINE_EN_ENABLE (1 << 28) |
| 90 | #define CFG_ECC_EN_TAG_MASK (1 << 27) |
| 91 | #define CFG_ECC_EN_TAG_DISABLE 0 |
| 92 | #define CFG_ECC_EN_TAG_ENABLE (1 << 27) |
| 93 | #define CFG_TVALUE_MASK (3 << 24) |
| 94 | enum { |
| 95 | CFG_TVAL4 = 0 << 24, |
| 96 | CFG_TVAL6 = 1 << 24, |
| 97 | CFG_TVAL8 = 2 << 24 |
| 98 | }; |
| 99 | #define CFG_SKIP_SPARE_MASK (1 << 23) |
| 100 | #define CFG_SKIP_SPARE_DISABLE 0 |
| 101 | #define CFG_SKIP_SPARE_ENABLE (1 << 23) |
| 102 | #define CFG_COM_BSY_MASK (1 << 22) |
| 103 | #define CFG_COM_BSY_DISABLE 0 |
| 104 | #define CFG_COM_BSY_ENABLE (1 << 22) |
| 105 | #define CFG_BUS_WIDTH_MASK (1 << 21) |
| 106 | #define CFG_BUS_WIDTH_8BIT 0 |
| 107 | #define CFG_BUS_WIDTH_16BIT (1 << 21) |
| 108 | #define CFG_LPDDR1_MODE_MASK (1 << 20) |
| 109 | #define CFG_LPDDR1_MODE_DISABLE 0 |
| 110 | #define CFG_LPDDR1_MODE_ENABLE (1 << 20) |
| 111 | #define CFG_EDO_MODE_MASK (1 << 19) |
| 112 | #define CFG_EDO_MODE_DISABLE 0 |
| 113 | #define CFG_EDO_MODE_ENABLE (1 << 19) |
| 114 | #define CFG_PAGE_SIZE_SEL_MASK (7 << 16) |
| 115 | enum { |
| 116 | CFG_PAGE_SIZE_256 = 0 << 16, |
| 117 | CFG_PAGE_SIZE_512 = 1 << 16, |
| 118 | CFG_PAGE_SIZE_1024 = 2 << 16, |
| 119 | CFG_PAGE_SIZE_2048 = 3 << 16, |
| 120 | CFG_PAGE_SIZE_4096 = 4 << 16 |
| 121 | }; |
| 122 | #define CFG_SKIP_SPARE_SEL_MASK (3 << 14) |
| 123 | enum { |
| 124 | CFG_SKIP_SPARE_SEL_4 = 0 << 14, |
| 125 | CFG_SKIP_SPARE_SEL_8 = 1 << 14, |
| 126 | CFG_SKIP_SPARE_SEL_12 = 2 << 14, |
| 127 | CFG_SKIP_SPARE_SEL_16 = 3 << 14 |
| 128 | }; |
| 129 | #define CFG_TAG_BYTE_SIZE_MASK 0x1FF |
| 130 | |
| 131 | #define TIMING_0 0x14 |
| 132 | #define TIMING_TRP_RESP_CNT_SHIFT 28 |
| 133 | #define TIMING_TRP_RESP_CNT_MASK (0xf << TIMING_TRP_RESP_CNT_SHIFT) |
| 134 | #define TIMING_TWB_CNT_SHIFT 24 |
| 135 | #define TIMING_TWB_CNT_MASK (0xf << TIMING_TWB_CNT_SHIFT) |
| 136 | #define TIMING_TCR_TAR_TRR_CNT_SHIFT 20 |
| 137 | #define TIMING_TCR_TAR_TRR_CNT_MASK (0xf << TIMING_TCR_TAR_TRR_CNT_SHIFT) |
| 138 | #define TIMING_TWHR_CNT_SHIFT 16 |
| 139 | #define TIMING_TWHR_CNT_MASK (0xf << TIMING_TWHR_CNT_SHIFT) |
| 140 | #define TIMING_TCS_CNT_SHIFT 14 |
| 141 | #define TIMING_TCS_CNT_MASK (3 << TIMING_TCS_CNT_SHIFT) |
| 142 | #define TIMING_TWH_CNT_SHIFT 12 |
| 143 | #define TIMING_TWH_CNT_MASK (3 << TIMING_TWH_CNT_SHIFT) |
| 144 | #define TIMING_TWP_CNT_SHIFT 8 |
| 145 | #define TIMING_TWP_CNT_MASK (0xf << TIMING_TWP_CNT_SHIFT) |
| 146 | #define TIMING_TRH_CNT_SHIFT 4 |
| 147 | #define TIMING_TRH_CNT_MASK (3 << TIMING_TRH_CNT_SHIFT) |
| 148 | #define TIMING_TRP_CNT_SHIFT 0 |
| 149 | #define TIMING_TRP_CNT_MASK (0xf << TIMING_TRP_CNT_SHIFT) |
| 150 | |
| 151 | #define RESP_0 0x18 |
| 152 | |
| 153 | #define TIMING2_0 0x1C |
| 154 | #define TIMING2_TADL_CNT_SHIFT 0 |
| 155 | #define TIMING2_TADL_CNT_MASK (0xf << TIMING2_TADL_CNT_SHIFT) |
| 156 | |
| 157 | #define CMD_REG1_0 0x20 |
| 158 | #define CMD_REG2_0 0x24 |
| 159 | #define ADDR_REG1_0 0x28 |
| 160 | #define ADDR_REG2_0 0x2C |
| 161 | |
| 162 | #define DMA_MST_CTRL_0 0x30 |
| 163 | #define DMA_MST_CTRL_GO_MASK (1 << 31) |
| 164 | #define DMA_MST_CTRL_GO_DISABLE 0 |
| 165 | #define DMA_MST_CTRL_GO_ENABLE (1 << 31) |
| 166 | #define DMA_MST_CTRL_DIR_MASK (1 << 30) |
| 167 | #define DMA_MST_CTRL_DIR_READ 0 |
| 168 | #define DMA_MST_CTRL_DIR_WRITE (1 << 30) |
| 169 | #define DMA_MST_CTRL_PERF_EN_MASK (1 << 29) |
| 170 | #define DMA_MST_CTRL_PERF_EN_DISABLE 0 |
| 171 | #define DMA_MST_CTRL_PERF_EN_ENABLE (1 << 29) |
| 172 | #define DMA_MST_CTRL_REUSE_BUFFER_MASK (1 << 27) |
| 173 | #define DMA_MST_CTRL_REUSE_BUFFER_DISABLE 0 |
| 174 | #define DMA_MST_CTRL_REUSE_BUFFER_ENABLE (1 << 27) |
| 175 | #define DMA_MST_CTRL_BURST_SIZE_SHIFT 24 |
| 176 | #define DMA_MST_CTRL_BURST_SIZE_MASK (7 << DMA_MST_CTRL_BURST_SIZE_SHIFT) |
| 177 | enum { |
| 178 | DMA_MST_CTRL_BURST_1WORDS = 2 << DMA_MST_CTRL_BURST_SIZE_SHIFT, |
| 179 | DMA_MST_CTRL_BURST_4WORDS = 3 << DMA_MST_CTRL_BURST_SIZE_SHIFT, |
| 180 | DMA_MST_CTRL_BURST_8WORDS = 4 << DMA_MST_CTRL_BURST_SIZE_SHIFT, |
| 181 | DMA_MST_CTRL_BURST_16WORDS = 5 << DMA_MST_CTRL_BURST_SIZE_SHIFT |
| 182 | }; |
| 183 | #define DMA_MST_CTRL_IS_DMA_DONE (1 << 20) |
| 184 | #define DMA_MST_CTRL_EN_A_MASK (1 << 2) |
| 185 | #define DMA_MST_CTRL_EN_A_DISABLE 0 |
| 186 | #define DMA_MST_CTRL_EN_A_ENABLE (1 << 2) |
| 187 | #define DMA_MST_CTRL_EN_B_MASK (1 << 1) |
| 188 | #define DMA_MST_CTRL_EN_B_DISABLE 0 |
| 189 | #define DMA_MST_CTRL_EN_B_ENABLE (1 << 1) |
| 190 | |
| 191 | #define DMA_CFG_A_0 0x34 |
| 192 | #define DMA_CFG_B_0 0x38 |
| 193 | #define FIFO_CTRL_0 0x3C |
| 194 | #define DATA_BLOCK_PTR_0 0x40 |
| 195 | #define TAG_PTR_0 0x44 |
| 196 | #define ECC_PTR_0 0x48 |
| 197 | |
| 198 | #define DEC_STATUS_0 0x4C |
| 199 | #define DEC_STATUS_A_ECC_FAIL (1 << 1) |
| 200 | #define DEC_STATUS_B_ECC_FAIL (1 << 0) |
| 201 | |
| 202 | #define BCH_CONFIG_0 0xCC |
| 203 | #define BCH_CONFIG_BCH_TVALUE_SHIFT 4 |
| 204 | #define BCH_CONFIG_BCH_TVALUE_MASK (3 << BCH_CONFIG_BCH_TVALUE_SHIFT) |
| 205 | enum { |
| 206 | BCH_CONFIG_BCH_TVAL4 = 0 << BCH_CONFIG_BCH_TVALUE_SHIFT, |
| 207 | BCH_CONFIG_BCH_TVAL8 = 1 << BCH_CONFIG_BCH_TVALUE_SHIFT, |
| 208 | BCH_CONFIG_BCH_TVAL14 = 2 << BCH_CONFIG_BCH_TVALUE_SHIFT, |
| 209 | BCH_CONFIG_BCH_TVAL16 = 3 << BCH_CONFIG_BCH_TVALUE_SHIFT |
| 210 | }; |
| 211 | #define BCH_CONFIG_BCH_ECC_MASK (1 << 0) |
| 212 | #define BCH_CONFIG_BCH_ECC_DISABLE 0 |
| 213 | #define BCH_CONFIG_BCH_ECC_ENABLE (1 << 0) |
| 214 | |
| 215 | #define BCH_DEC_RESULT_0 0xD0 |
| 216 | #define BCH_DEC_RESULT_CORRFAIL_ERR_MASK (1 << 8) |
| 217 | #define BCH_DEC_RESULT_PAGE_COUNT_MASK 0xFF |
| 218 | |
| 219 | #define BCH_DEC_STATUS_BUF_0 0xD4 |
| 220 | #define BCH_DEC_STATUS_FAIL_SEC_FLAG_MASK 0xFF000000 |
| 221 | #define BCH_DEC_STATUS_CORR_SEC_FLAG_MASK 0x00FF0000 |
| 222 | #define BCH_DEC_STATUS_FAIL_TAG_MASK (1 << 14) |
| 223 | #define BCH_DEC_STATUS_CORR_TAG_MASK (1 << 13) |
| 224 | #define BCH_DEC_STATUS_MAX_CORR_CNT_MASK (0x1f << 8) |
| 225 | #define BCH_DEC_STATUS_PAGE_NUMBER_MASK 0xFF |
| 226 | |
| 227 | #define LP_OPTIONS (NAND_NO_READRDY | NAND_NO_AUTOINCR) |
| 228 | |
| 229 | struct nand_ctlr { |
| 230 | u32 command; /* offset 00h */ |
| 231 | u32 status; /* offset 04h */ |
| 232 | u32 isr; /* offset 08h */ |
| 233 | u32 ier; /* offset 0Ch */ |
| 234 | u32 config; /* offset 10h */ |
| 235 | u32 timing; /* offset 14h */ |
| 236 | u32 resp; /* offset 18h */ |
| 237 | u32 timing2; /* offset 1Ch */ |
| 238 | u32 cmd_reg1; /* offset 20h */ |
| 239 | u32 cmd_reg2; /* offset 24h */ |
| 240 | u32 addr_reg1; /* offset 28h */ |
| 241 | u32 addr_reg2; /* offset 2Ch */ |
| 242 | u32 dma_mst_ctrl; /* offset 30h */ |
| 243 | u32 dma_cfg_a; /* offset 34h */ |
| 244 | u32 dma_cfg_b; /* offset 38h */ |
| 245 | u32 fifo_ctrl; /* offset 3Ch */ |
| 246 | u32 data_block_ptr; /* offset 40h */ |
| 247 | u32 tag_ptr; /* offset 44h */ |
| 248 | u32 resv1; /* offset 48h */ |
| 249 | u32 dec_status; /* offset 4Ch */ |
| 250 | u32 hwstatus_cmd; /* offset 50h */ |
| 251 | u32 hwstatus_mask; /* offset 54h */ |
| 252 | u32 resv2[29]; |
| 253 | u32 bch_config; /* offset CCh */ |
| 254 | u32 bch_dec_result; /* offset D0h */ |
| 255 | u32 bch_dec_status_buf; |
| 256 | /* offset D4h */ |
| 257 | }; |