fsl_ifc.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835
  1. /* Freescale Integrated Flash Controller
  2. *
  3. * Copyright 2011 Freescale Semiconductor, Inc
  4. *
  5. * Author: Dipen Dudhat <dipen.dudhat@freescale.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (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, MA 02111-1307 USA
  20. */
  21. #ifndef __ASM_FSL_IFC_H
  22. #define __ASM_FSL_IFC_H
  23. #include <linux/compiler.h>
  24. #include <linux/types.h>
  25. #include <linux/io.h>
  26. #include <linux/of_platform.h>
  27. #include <linux/interrupt.h>
  28. #define FSL_IFC_BANK_COUNT 4
  29. /*
  30. * CSPR - Chip Select Property Register
  31. */
  32. #define CSPR_BA 0xFFFF0000
  33. #define CSPR_BA_SHIFT 16
  34. #define CSPR_PORT_SIZE 0x00000180
  35. #define CSPR_PORT_SIZE_SHIFT 7
  36. /* Port Size 8 bit */
  37. #define CSPR_PORT_SIZE_8 0x00000080
  38. /* Port Size 16 bit */
  39. #define CSPR_PORT_SIZE_16 0x00000100
  40. /* Port Size 32 bit */
  41. #define CSPR_PORT_SIZE_32 0x00000180
  42. /* Write Protect */
  43. #define CSPR_WP 0x00000040
  44. #define CSPR_WP_SHIFT 6
  45. /* Machine Select */
  46. #define CSPR_MSEL 0x00000006
  47. #define CSPR_MSEL_SHIFT 1
  48. /* NOR */
  49. #define CSPR_MSEL_NOR 0x00000000
  50. /* NAND */
  51. #define CSPR_MSEL_NAND 0x00000002
  52. /* GPCM */
  53. #define CSPR_MSEL_GPCM 0x00000004
  54. /* Bank Valid */
  55. #define CSPR_V 0x00000001
  56. #define CSPR_V_SHIFT 0
  57. /*
  58. * Address Mask Register
  59. */
  60. #define IFC_AMASK_MASK 0xFFFF0000
  61. #define IFC_AMASK_SHIFT 16
  62. #define IFC_AMASK(n) (IFC_AMASK_MASK << \
  63. (__ilog2(n) - IFC_AMASK_SHIFT))
  64. /*
  65. * Chip Select Option Register IFC_NAND Machine
  66. */
  67. /* Enable ECC Encoder */
  68. #define CSOR_NAND_ECC_ENC_EN 0x80000000
  69. #define CSOR_NAND_ECC_MODE_MASK 0x30000000
  70. /* 4 bit correction per 520 Byte sector */
  71. #define CSOR_NAND_ECC_MODE_4 0x00000000
  72. /* 8 bit correction per 528 Byte sector */
  73. #define CSOR_NAND_ECC_MODE_8 0x10000000
  74. /* Enable ECC Decoder */
  75. #define CSOR_NAND_ECC_DEC_EN 0x04000000
  76. /* Row Address Length */
  77. #define CSOR_NAND_RAL_MASK 0x01800000
  78. #define CSOR_NAND_RAL_SHIFT 20
  79. #define CSOR_NAND_RAL_1 0x00000000
  80. #define CSOR_NAND_RAL_2 0x00800000
  81. #define CSOR_NAND_RAL_3 0x01000000
  82. #define CSOR_NAND_RAL_4 0x01800000
  83. /* Page Size 512b, 2k, 4k */
  84. #define CSOR_NAND_PGS_MASK 0x00180000
  85. #define CSOR_NAND_PGS_SHIFT 16
  86. #define CSOR_NAND_PGS_512 0x00000000
  87. #define CSOR_NAND_PGS_2K 0x00080000
  88. #define CSOR_NAND_PGS_4K 0x00100000
  89. /* Spare region Size */
  90. #define CSOR_NAND_SPRZ_MASK 0x0000E000
  91. #define CSOR_NAND_SPRZ_SHIFT 13
  92. #define CSOR_NAND_SPRZ_16 0x00000000
  93. #define CSOR_NAND_SPRZ_64 0x00002000
  94. #define CSOR_NAND_SPRZ_128 0x00004000
  95. #define CSOR_NAND_SPRZ_210 0x00006000
  96. #define CSOR_NAND_SPRZ_218 0x00008000
  97. #define CSOR_NAND_SPRZ_224 0x0000A000
  98. /* Pages Per Block */
  99. #define CSOR_NAND_PB_MASK 0x00000700
  100. #define CSOR_NAND_PB_SHIFT 8
  101. #define CSOR_NAND_PB(n) ((__ilog2(n) - 5) << CSOR_NAND_PB_SHIFT)
  102. /* Time for Read Enable High to Output High Impedance */
  103. #define CSOR_NAND_TRHZ_MASK 0x0000001C
  104. #define CSOR_NAND_TRHZ_SHIFT 2
  105. #define CSOR_NAND_TRHZ_20 0x00000000
  106. #define CSOR_NAND_TRHZ_40 0x00000004
  107. #define CSOR_NAND_TRHZ_60 0x00000008
  108. #define CSOR_NAND_TRHZ_80 0x0000000C
  109. #define CSOR_NAND_TRHZ_100 0x00000010
  110. /* Buffer control disable */
  111. #define CSOR_NAND_BCTLD 0x00000001
  112. /*
  113. * Chip Select Option Register - NOR Flash Mode
  114. */
  115. /* Enable Address shift Mode */
  116. #define CSOR_NOR_ADM_SHFT_MODE_EN 0x80000000
  117. /* Page Read Enable from NOR device */
  118. #define CSOR_NOR_PGRD_EN 0x10000000
  119. /* AVD Toggle Enable during Burst Program */
  120. #define CSOR_NOR_AVD_TGL_PGM_EN 0x01000000
  121. /* Address Data Multiplexing Shift */
  122. #define CSOR_NOR_ADM_MASK 0x0003E000
  123. #define CSOR_NOR_ADM_SHIFT_SHIFT 13
  124. #define CSOR_NOR_ADM_SHIFT(n) ((n) << CSOR_NOR_ADM_SHIFT_SHIFT)
  125. /* Type of the NOR device hooked */
  126. #define CSOR_NOR_NOR_MODE_AYSNC_NOR 0x00000000
  127. #define CSOR_NOR_NOR_MODE_AVD_NOR 0x00000020
  128. /* Time for Read Enable High to Output High Impedance */
  129. #define CSOR_NOR_TRHZ_MASK 0x0000001C
  130. #define CSOR_NOR_TRHZ_SHIFT 2
  131. #define CSOR_NOR_TRHZ_20 0x00000000
  132. #define CSOR_NOR_TRHZ_40 0x00000004
  133. #define CSOR_NOR_TRHZ_60 0x00000008
  134. #define CSOR_NOR_TRHZ_80 0x0000000C
  135. #define CSOR_NOR_TRHZ_100 0x00000010
  136. /* Buffer control disable */
  137. #define CSOR_NOR_BCTLD 0x00000001
  138. /*
  139. * Chip Select Option Register - GPCM Mode
  140. */
  141. /* GPCM Mode - Normal */
  142. #define CSOR_GPCM_GPMODE_NORMAL 0x00000000
  143. /* GPCM Mode - GenericASIC */
  144. #define CSOR_GPCM_GPMODE_ASIC 0x80000000
  145. /* Parity Mode odd/even */
  146. #define CSOR_GPCM_PARITY_EVEN 0x40000000
  147. /* Parity Checking enable/disable */
  148. #define CSOR_GPCM_PAR_EN 0x20000000
  149. /* GPCM Timeout Count */
  150. #define CSOR_GPCM_GPTO_MASK 0x0F000000
  151. #define CSOR_GPCM_GPTO_SHIFT 24
  152. #define CSOR_GPCM_GPTO(n) ((__ilog2(n) - 8) << CSOR_GPCM_GPTO_SHIFT)
  153. /* GPCM External Access Termination mode for read access */
  154. #define CSOR_GPCM_RGETA_EXT 0x00080000
  155. /* GPCM External Access Termination mode for write access */
  156. #define CSOR_GPCM_WGETA_EXT 0x00040000
  157. /* Address Data Multiplexing Shift */
  158. #define CSOR_GPCM_ADM_MASK 0x0003E000
  159. #define CSOR_GPCM_ADM_SHIFT_SHIFT 13
  160. #define CSOR_GPCM_ADM_SHIFT(n) ((n) << CSOR_GPCM_ADM_SHIFT_SHIFT)
  161. /* Generic ASIC Parity error indication delay */
  162. #define CSOR_GPCM_GAPERRD_MASK 0x00000180
  163. #define CSOR_GPCM_GAPERRD_SHIFT 7
  164. #define CSOR_GPCM_GAPERRD(n) (((n) - 1) << CSOR_GPCM_GAPERRD_SHIFT)
  165. /* Time for Read Enable High to Output High Impedance */
  166. #define CSOR_GPCM_TRHZ_MASK 0x0000001C
  167. #define CSOR_GPCM_TRHZ_20 0x00000000
  168. #define CSOR_GPCM_TRHZ_40 0x00000004
  169. #define CSOR_GPCM_TRHZ_60 0x00000008
  170. #define CSOR_GPCM_TRHZ_80 0x0000000C
  171. #define CSOR_GPCM_TRHZ_100 0x00000010
  172. /* Buffer control disable */
  173. #define CSOR_GPCM_BCTLD 0x00000001
  174. /*
  175. * Ready Busy Status Register (RB_STAT)
  176. */
  177. /* CSn is READY */
  178. #define IFC_RB_STAT_READY_CS0 0x80000000
  179. #define IFC_RB_STAT_READY_CS1 0x40000000
  180. #define IFC_RB_STAT_READY_CS2 0x20000000
  181. #define IFC_RB_STAT_READY_CS3 0x10000000
  182. /*
  183. * General Control Register (GCR)
  184. */
  185. #define IFC_GCR_MASK 0x8000F800
  186. /* reset all IFC hardware */
  187. #define IFC_GCR_SOFT_RST_ALL 0x80000000
  188. /* Turnaroud Time of external buffer */
  189. #define IFC_GCR_TBCTL_TRN_TIME 0x0000F800
  190. #define IFC_GCR_TBCTL_TRN_TIME_SHIFT 11
  191. /*
  192. * Common Event and Error Status Register (CM_EVTER_STAT)
  193. */
  194. /* Chip select error */
  195. #define IFC_CM_EVTER_STAT_CSER 0x80000000
  196. /*
  197. * Common Event and Error Enable Register (CM_EVTER_EN)
  198. */
  199. /* Chip select error checking enable */
  200. #define IFC_CM_EVTER_EN_CSEREN 0x80000000
  201. /*
  202. * Common Event and Error Interrupt Enable Register (CM_EVTER_INTR_EN)
  203. */
  204. /* Chip select error interrupt enable */
  205. #define IFC_CM_EVTER_INTR_EN_CSERIREN 0x80000000
  206. /*
  207. * Common Transfer Error Attribute Register-0 (CM_ERATTR0)
  208. */
  209. /* transaction type of error Read/Write */
  210. #define IFC_CM_ERATTR0_ERTYP_READ 0x80000000
  211. #define IFC_CM_ERATTR0_ERAID 0x0FF00000
  212. #define IFC_CM_ERATTR0_ERAID_SHIFT 20
  213. #define IFC_CM_ERATTR0_ESRCID 0x0000FF00
  214. #define IFC_CM_ERATTR0_ESRCID_SHIFT 8
  215. /*
  216. * Clock Control Register (CCR)
  217. */
  218. #define IFC_CCR_MASK 0x0F0F8800
  219. /* Clock division ratio */
  220. #define IFC_CCR_CLK_DIV_MASK 0x0F000000
  221. #define IFC_CCR_CLK_DIV_SHIFT 24
  222. #define IFC_CCR_CLK_DIV(n) ((n-1) << IFC_CCR_CLK_DIV_SHIFT)
  223. /* IFC Clock Delay */
  224. #define IFC_CCR_CLK_DLY_MASK 0x000F0000
  225. #define IFC_CCR_CLK_DLY_SHIFT 16
  226. #define IFC_CCR_CLK_DLY(n) ((n) << IFC_CCR_CLK_DLY_SHIFT)
  227. /* Invert IFC clock before sending out */
  228. #define IFC_CCR_INV_CLK_EN 0x00008000
  229. /* Fedback IFC Clock */
  230. #define IFC_CCR_FB_IFC_CLK_SEL 0x00000800
  231. /*
  232. * Clock Status Register (CSR)
  233. */
  234. /* Clk is stable */
  235. #define IFC_CSR_CLK_STAT_STABLE 0x80000000
  236. /*
  237. * IFC_NAND Machine Specific Registers
  238. */
  239. /*
  240. * NAND Configuration Register (NCFGR)
  241. */
  242. /* Auto Boot Mode */
  243. #define IFC_NAND_NCFGR_BOOT 0x80000000
  244. /* Addressing Mode-ROW0+n/COL0 */
  245. #define IFC_NAND_NCFGR_ADDR_MODE_RC0 0x00000000
  246. /* Addressing Mode-ROW0+n/COL0+n */
  247. #define IFC_NAND_NCFGR_ADDR_MODE_RC1 0x00400000
  248. /* Number of loop iterations of FIR sequences for multi page operations */
  249. #define IFC_NAND_NCFGR_NUM_LOOP_MASK 0x0000F000
  250. #define IFC_NAND_NCFGR_NUM_LOOP_SHIFT 12
  251. #define IFC_NAND_NCFGR_NUM_LOOP(n) ((n) << IFC_NAND_NCFGR_NUM_LOOP_SHIFT)
  252. /* Number of wait cycles */
  253. #define IFC_NAND_NCFGR_NUM_WAIT_MASK 0x000000FF
  254. #define IFC_NAND_NCFGR_NUM_WAIT_SHIFT 0
  255. /*
  256. * NAND Flash Command Registers (NAND_FCR0/NAND_FCR1)
  257. */
  258. /* General purpose FCM flash command bytes CMD0-CMD7 */
  259. #define IFC_NAND_FCR0_CMD0 0xFF000000
  260. #define IFC_NAND_FCR0_CMD0_SHIFT 24
  261. #define IFC_NAND_FCR0_CMD1 0x00FF0000
  262. #define IFC_NAND_FCR0_CMD1_SHIFT 16
  263. #define IFC_NAND_FCR0_CMD2 0x0000FF00
  264. #define IFC_NAND_FCR0_CMD2_SHIFT 8
  265. #define IFC_NAND_FCR0_CMD3 0x000000FF
  266. #define IFC_NAND_FCR0_CMD3_SHIFT 0
  267. #define IFC_NAND_FCR1_CMD4 0xFF000000
  268. #define IFC_NAND_FCR1_CMD4_SHIFT 24
  269. #define IFC_NAND_FCR1_CMD5 0x00FF0000
  270. #define IFC_NAND_FCR1_CMD5_SHIFT 16
  271. #define IFC_NAND_FCR1_CMD6 0x0000FF00
  272. #define IFC_NAND_FCR1_CMD6_SHIFT 8
  273. #define IFC_NAND_FCR1_CMD7 0x000000FF
  274. #define IFC_NAND_FCR1_CMD7_SHIFT 0
  275. /*
  276. * Flash ROW and COL Address Register (ROWn, COLn)
  277. */
  278. /* Main/spare region locator */
  279. #define IFC_NAND_COL_MS 0x80000000
  280. /* Column Address */
  281. #define IFC_NAND_COL_CA_MASK 0x00000FFF
  282. /*
  283. * NAND Flash Byte Count Register (NAND_BC)
  284. */
  285. /* Byte Count for read/Write */
  286. #define IFC_NAND_BC 0x000001FF
  287. /*
  288. * NAND Flash Instruction Registers (NAND_FIR0/NAND_FIR1/NAND_FIR2)
  289. */
  290. /* NAND Machine specific opcodes OP0-OP14*/
  291. #define IFC_NAND_FIR0_OP0 0xFC000000
  292. #define IFC_NAND_FIR0_OP0_SHIFT 26
  293. #define IFC_NAND_FIR0_OP1 0x03F00000
  294. #define IFC_NAND_FIR0_OP1_SHIFT 20
  295. #define IFC_NAND_FIR0_OP2 0x000FC000
  296. #define IFC_NAND_FIR0_OP2_SHIFT 14
  297. #define IFC_NAND_FIR0_OP3 0x00003F00
  298. #define IFC_NAND_FIR0_OP3_SHIFT 8
  299. #define IFC_NAND_FIR0_OP4 0x000000FC
  300. #define IFC_NAND_FIR0_OP4_SHIFT 2
  301. #define IFC_NAND_FIR1_OP5 0xFC000000
  302. #define IFC_NAND_FIR1_OP5_SHIFT 26
  303. #define IFC_NAND_FIR1_OP6 0x03F00000
  304. #define IFC_NAND_FIR1_OP6_SHIFT 20
  305. #define IFC_NAND_FIR1_OP7 0x000FC000
  306. #define IFC_NAND_FIR1_OP7_SHIFT 14
  307. #define IFC_NAND_FIR1_OP8 0x00003F00
  308. #define IFC_NAND_FIR1_OP8_SHIFT 8
  309. #define IFC_NAND_FIR1_OP9 0x000000FC
  310. #define IFC_NAND_FIR1_OP9_SHIFT 2
  311. #define IFC_NAND_FIR2_OP10 0xFC000000
  312. #define IFC_NAND_FIR2_OP10_SHIFT 26
  313. #define IFC_NAND_FIR2_OP11 0x03F00000
  314. #define IFC_NAND_FIR2_OP11_SHIFT 20
  315. #define IFC_NAND_FIR2_OP12 0x000FC000
  316. #define IFC_NAND_FIR2_OP12_SHIFT 14
  317. #define IFC_NAND_FIR2_OP13 0x00003F00
  318. #define IFC_NAND_FIR2_OP13_SHIFT 8
  319. #define IFC_NAND_FIR2_OP14 0x000000FC
  320. #define IFC_NAND_FIR2_OP14_SHIFT 2
  321. /*
  322. * Instruction opcodes to be programmed
  323. * in FIR registers- 6bits
  324. */
  325. enum ifc_nand_fir_opcodes {
  326. IFC_FIR_OP_NOP,
  327. IFC_FIR_OP_CA0,
  328. IFC_FIR_OP_CA1,
  329. IFC_FIR_OP_CA2,
  330. IFC_FIR_OP_CA3,
  331. IFC_FIR_OP_RA0,
  332. IFC_FIR_OP_RA1,
  333. IFC_FIR_OP_RA2,
  334. IFC_FIR_OP_RA3,
  335. IFC_FIR_OP_CMD0,
  336. IFC_FIR_OP_CMD1,
  337. IFC_FIR_OP_CMD2,
  338. IFC_FIR_OP_CMD3,
  339. IFC_FIR_OP_CMD4,
  340. IFC_FIR_OP_CMD5,
  341. IFC_FIR_OP_CMD6,
  342. IFC_FIR_OP_CMD7,
  343. IFC_FIR_OP_CW0,
  344. IFC_FIR_OP_CW1,
  345. IFC_FIR_OP_CW2,
  346. IFC_FIR_OP_CW3,
  347. IFC_FIR_OP_CW4,
  348. IFC_FIR_OP_CW5,
  349. IFC_FIR_OP_CW6,
  350. IFC_FIR_OP_CW7,
  351. IFC_FIR_OP_WBCD,
  352. IFC_FIR_OP_RBCD,
  353. IFC_FIR_OP_BTRD,
  354. IFC_FIR_OP_RDSTAT,
  355. IFC_FIR_OP_NWAIT,
  356. IFC_FIR_OP_WFR,
  357. IFC_FIR_OP_SBRD,
  358. IFC_FIR_OP_UA,
  359. IFC_FIR_OP_RB,
  360. };
  361. /*
  362. * NAND Chip Select Register (NAND_CSEL)
  363. */
  364. #define IFC_NAND_CSEL 0x0C000000
  365. #define IFC_NAND_CSEL_SHIFT 26
  366. #define IFC_NAND_CSEL_CS0 0x00000000
  367. #define IFC_NAND_CSEL_CS1 0x04000000
  368. #define IFC_NAND_CSEL_CS2 0x08000000
  369. #define IFC_NAND_CSEL_CS3 0x0C000000
  370. /*
  371. * NAND Operation Sequence Start (NANDSEQ_STRT)
  372. */
  373. /* NAND Flash Operation Start */
  374. #define IFC_NAND_SEQ_STRT_FIR_STRT 0x80000000
  375. /* Automatic Erase */
  376. #define IFC_NAND_SEQ_STRT_AUTO_ERS 0x00800000
  377. /* Automatic Program */
  378. #define IFC_NAND_SEQ_STRT_AUTO_PGM 0x00100000
  379. /* Automatic Copyback */
  380. #define IFC_NAND_SEQ_STRT_AUTO_CPB 0x00020000
  381. /* Automatic Read Operation */
  382. #define IFC_NAND_SEQ_STRT_AUTO_RD 0x00004000
  383. /* Automatic Status Read */
  384. #define IFC_NAND_SEQ_STRT_AUTO_STAT_RD 0x00000800
  385. /*
  386. * NAND Event and Error Status Register (NAND_EVTER_STAT)
  387. */
  388. /* Operation Complete */
  389. #define IFC_NAND_EVTER_STAT_OPC 0x80000000
  390. /* Flash Timeout Error */
  391. #define IFC_NAND_EVTER_STAT_FTOER 0x08000000
  392. /* Write Protect Error */
  393. #define IFC_NAND_EVTER_STAT_WPER 0x04000000
  394. /* ECC Error */
  395. #define IFC_NAND_EVTER_STAT_ECCER 0x02000000
  396. /* RCW Load Done */
  397. #define IFC_NAND_EVTER_STAT_RCW_DN 0x00008000
  398. /* Boot Loadr Done */
  399. #define IFC_NAND_EVTER_STAT_BOOT_DN 0x00004000
  400. /* Bad Block Indicator search select */
  401. #define IFC_NAND_EVTER_STAT_BBI_SRCH_SE 0x00000800
  402. /*
  403. * NAND Flash Page Read Completion Event Status Register
  404. * (PGRDCMPL_EVT_STAT)
  405. */
  406. #define PGRDCMPL_EVT_STAT_MASK 0xFFFF0000
  407. /* Small Page 0-15 Done */
  408. #define PGRDCMPL_EVT_STAT_SECTION_SP(n) (1 << (31 - (n)))
  409. /* Large Page(2K) 0-3 Done */
  410. #define PGRDCMPL_EVT_STAT_LP_2K(n) (0xF << (28 - (n)*4))
  411. /* Large Page(4K) 0-1 Done */
  412. #define PGRDCMPL_EVT_STAT_LP_4K(n) (0xFF << (24 - (n)*8))
  413. /*
  414. * NAND Event and Error Enable Register (NAND_EVTER_EN)
  415. */
  416. /* Operation complete event enable */
  417. #define IFC_NAND_EVTER_EN_OPC_EN 0x80000000
  418. /* Page read complete event enable */
  419. #define IFC_NAND_EVTER_EN_PGRDCMPL_EN 0x20000000
  420. /* Flash Timeout error enable */
  421. #define IFC_NAND_EVTER_EN_FTOER_EN 0x08000000
  422. /* Write Protect error enable */
  423. #define IFC_NAND_EVTER_EN_WPER_EN 0x04000000
  424. /* ECC error logging enable */
  425. #define IFC_NAND_EVTER_EN_ECCER_EN 0x02000000
  426. /*
  427. * NAND Event and Error Interrupt Enable Register (NAND_EVTER_INTR_EN)
  428. */
  429. /* Enable interrupt for operation complete */
  430. #define IFC_NAND_EVTER_INTR_OPCIR_EN 0x80000000
  431. /* Enable interrupt for Page read complete */
  432. #define IFC_NAND_EVTER_INTR_PGRDCMPLIR_EN 0x20000000
  433. /* Enable interrupt for Flash timeout error */
  434. #define IFC_NAND_EVTER_INTR_FTOERIR_EN 0x08000000
  435. /* Enable interrupt for Write protect error */
  436. #define IFC_NAND_EVTER_INTR_WPERIR_EN 0x04000000
  437. /* Enable interrupt for ECC error*/
  438. #define IFC_NAND_EVTER_INTR_ECCERIR_EN 0x02000000
  439. /*
  440. * NAND Transfer Error Attribute Register-0 (NAND_ERATTR0)
  441. */
  442. #define IFC_NAND_ERATTR0_MASK 0x0C080000
  443. /* Error on CS0-3 for NAND */
  444. #define IFC_NAND_ERATTR0_ERCS_CS0 0x00000000
  445. #define IFC_NAND_ERATTR0_ERCS_CS1 0x04000000
  446. #define IFC_NAND_ERATTR0_ERCS_CS2 0x08000000
  447. #define IFC_NAND_ERATTR0_ERCS_CS3 0x0C000000
  448. /* Transaction type of error Read/Write */
  449. #define IFC_NAND_ERATTR0_ERTTYPE_READ 0x00080000
  450. /*
  451. * NAND Flash Status Register (NAND_FSR)
  452. */
  453. /* First byte of data read from read status op */
  454. #define IFC_NAND_NFSR_RS0 0xFF000000
  455. /* Second byte of data read from read status op */
  456. #define IFC_NAND_NFSR_RS1 0x00FF0000
  457. /*
  458. * ECC Error Status Registers (ECCSTAT0-ECCSTAT3)
  459. */
  460. /* Number of ECC errors on sector n (n = 0-15) */
  461. #define IFC_NAND_ECCSTAT0_ERRCNT_SECTOR0_MASK 0x0F000000
  462. #define IFC_NAND_ECCSTAT0_ERRCNT_SECTOR0_SHIFT 24
  463. #define IFC_NAND_ECCSTAT0_ERRCNT_SECTOR1_MASK 0x000F0000
  464. #define IFC_NAND_ECCSTAT0_ERRCNT_SECTOR1_SHIFT 16
  465. #define IFC_NAND_ECCSTAT0_ERRCNT_SECTOR2_MASK 0x00000F00
  466. #define IFC_NAND_ECCSTAT0_ERRCNT_SECTOR2_SHIFT 8
  467. #define IFC_NAND_ECCSTAT0_ERRCNT_SECTOR3_MASK 0x0000000F
  468. #define IFC_NAND_ECCSTAT0_ERRCNT_SECTOR3_SHIFT 0
  469. #define IFC_NAND_ECCSTAT1_ERRCNT_SECTOR4_MASK 0x0F000000
  470. #define IFC_NAND_ECCSTAT1_ERRCNT_SECTOR4_SHIFT 24
  471. #define IFC_NAND_ECCSTAT1_ERRCNT_SECTOR5_MASK 0x000F0000
  472. #define IFC_NAND_ECCSTAT1_ERRCNT_SECTOR5_SHIFT 16
  473. #define IFC_NAND_ECCSTAT1_ERRCNT_SECTOR6_MASK 0x00000F00
  474. #define IFC_NAND_ECCSTAT1_ERRCNT_SECTOR6_SHIFT 8
  475. #define IFC_NAND_ECCSTAT1_ERRCNT_SECTOR7_MASK 0x0000000F
  476. #define IFC_NAND_ECCSTAT1_ERRCNT_SECTOR7_SHIFT 0
  477. #define IFC_NAND_ECCSTAT2_ERRCNT_SECTOR8_MASK 0x0F000000
  478. #define IFC_NAND_ECCSTAT2_ERRCNT_SECTOR8_SHIFT 24
  479. #define IFC_NAND_ECCSTAT2_ERRCNT_SECTOR9_MASK 0x000F0000
  480. #define IFC_NAND_ECCSTAT2_ERRCNT_SECTOR9_SHIFT 16
  481. #define IFC_NAND_ECCSTAT2_ERRCNT_SECTOR10_MASK 0x00000F00
  482. #define IFC_NAND_ECCSTAT2_ERRCNT_SECTOR10_SHIFT 8
  483. #define IFC_NAND_ECCSTAT2_ERRCNT_SECTOR11_MASK 0x0000000F
  484. #define IFC_NAND_ECCSTAT2_ERRCNT_SECTOR11_SHIFT 0
  485. #define IFC_NAND_ECCSTAT3_ERRCNT_SECTOR12_MASK 0x0F000000
  486. #define IFC_NAND_ECCSTAT3_ERRCNT_SECTOR12_SHIFT 24
  487. #define IFC_NAND_ECCSTAT3_ERRCNT_SECTOR13_MASK 0x000F0000
  488. #define IFC_NAND_ECCSTAT3_ERRCNT_SECTOR13_SHIFT 16
  489. #define IFC_NAND_ECCSTAT3_ERRCNT_SECTOR14_MASK 0x00000F00
  490. #define IFC_NAND_ECCSTAT3_ERRCNT_SECTOR14_SHIFT 8
  491. #define IFC_NAND_ECCSTAT3_ERRCNT_SECTOR15_MASK 0x0000000F
  492. #define IFC_NAND_ECCSTAT3_ERRCNT_SECTOR15_SHIFT 0
  493. /*
  494. * NAND Control Register (NANDCR)
  495. */
  496. #define IFC_NAND_NCR_FTOCNT_MASK 0x1E000000
  497. #define IFC_NAND_NCR_FTOCNT_SHIFT 25
  498. #define IFC_NAND_NCR_FTOCNT(n) ((_ilog2(n) - 8) << IFC_NAND_NCR_FTOCNT_SHIFT)
  499. /*
  500. * NAND_AUTOBOOT_TRGR
  501. */
  502. /* Trigger RCW load */
  503. #define IFC_NAND_AUTOBOOT_TRGR_RCW_LD 0x80000000
  504. /* Trigget Auto Boot */
  505. #define IFC_NAND_AUTOBOOT_TRGR_BOOT_LD 0x20000000
  506. /*
  507. * NAND_MDR
  508. */
  509. /* 1st read data byte when opcode SBRD */
  510. #define IFC_NAND_MDR_RDATA0 0xFF000000
  511. /* 2nd read data byte when opcode SBRD */
  512. #define IFC_NAND_MDR_RDATA1 0x00FF0000
  513. /*
  514. * NOR Machine Specific Registers
  515. */
  516. /*
  517. * NOR Event and Error Status Register (NOR_EVTER_STAT)
  518. */
  519. /* NOR Command Sequence Operation Complete */
  520. #define IFC_NOR_EVTER_STAT_OPC_NOR 0x80000000
  521. /* Write Protect Error */
  522. #define IFC_NOR_EVTER_STAT_WPER 0x04000000
  523. /* Command Sequence Timeout Error */
  524. #define IFC_NOR_EVTER_STAT_STOER 0x01000000
  525. /*
  526. * NOR Event and Error Enable Register (NOR_EVTER_EN)
  527. */
  528. /* NOR Command Seq complete event enable */
  529. #define IFC_NOR_EVTER_EN_OPCEN_NOR 0x80000000
  530. /* Write Protect Error Checking Enable */
  531. #define IFC_NOR_EVTER_EN_WPEREN 0x04000000
  532. /* Timeout Error Enable */
  533. #define IFC_NOR_EVTER_EN_STOEREN 0x01000000
  534. /*
  535. * NOR Event and Error Interrupt Enable Register (NOR_EVTER_INTR_EN)
  536. */
  537. /* Enable interrupt for OPC complete */
  538. #define IFC_NOR_EVTER_INTR_OPCEN_NOR 0x80000000
  539. /* Enable interrupt for write protect error */
  540. #define IFC_NOR_EVTER_INTR_WPEREN 0x04000000
  541. /* Enable interrupt for timeout error */
  542. #define IFC_NOR_EVTER_INTR_STOEREN 0x01000000
  543. /*
  544. * NOR Transfer Error Attribute Register-0 (NOR_ERATTR0)
  545. */
  546. /* Source ID for error transaction */
  547. #define IFC_NOR_ERATTR0_ERSRCID 0xFF000000
  548. /* AXI ID for error transation */
  549. #define IFC_NOR_ERATTR0_ERAID 0x000FF000
  550. /* Chip select corresponds to NOR error */
  551. #define IFC_NOR_ERATTR0_ERCS_CS0 0x00000000
  552. #define IFC_NOR_ERATTR0_ERCS_CS1 0x00000010
  553. #define IFC_NOR_ERATTR0_ERCS_CS2 0x00000020
  554. #define IFC_NOR_ERATTR0_ERCS_CS3 0x00000030
  555. /* Type of transaction read/write */
  556. #define IFC_NOR_ERATTR0_ERTYPE_READ 0x00000001
  557. /*
  558. * NOR Transfer Error Attribute Register-2 (NOR_ERATTR2)
  559. */
  560. #define IFC_NOR_ERATTR2_ER_NUM_PHASE_EXP 0x000F0000
  561. #define IFC_NOR_ERATTR2_ER_NUM_PHASE_PER 0x00000F00
  562. /*
  563. * NOR Control Register (NORCR)
  564. */
  565. #define IFC_NORCR_MASK 0x0F0F0000
  566. /* No. of Address/Data Phase */
  567. #define IFC_NORCR_NUM_PHASE_MASK 0x0F000000
  568. #define IFC_NORCR_NUM_PHASE_SHIFT 24
  569. #define IFC_NORCR_NUM_PHASE(n) ((n-1) << IFC_NORCR_NUM_PHASE_SHIFT)
  570. /* Sequence Timeout Count */
  571. #define IFC_NORCR_STOCNT_MASK 0x000F0000
  572. #define IFC_NORCR_STOCNT_SHIFT 16
  573. #define IFC_NORCR_STOCNT(n) ((__ilog2(n) - 8) << IFC_NORCR_STOCNT_SHIFT)
  574. /*
  575. * GPCM Machine specific registers
  576. */
  577. /*
  578. * GPCM Event and Error Status Register (GPCM_EVTER_STAT)
  579. */
  580. /* Timeout error */
  581. #define IFC_GPCM_EVTER_STAT_TOER 0x04000000
  582. /* Parity error */
  583. #define IFC_GPCM_EVTER_STAT_PER 0x01000000
  584. /*
  585. * GPCM Event and Error Enable Register (GPCM_EVTER_EN)
  586. */
  587. /* Timeout error enable */
  588. #define IFC_GPCM_EVTER_EN_TOER_EN 0x04000000
  589. /* Parity error enable */
  590. #define IFC_GPCM_EVTER_EN_PER_EN 0x01000000
  591. /*
  592. * GPCM Event and Error Interrupt Enable Register (GPCM_EVTER_INTR_EN)
  593. */
  594. /* Enable Interrupt for timeout error */
  595. #define IFC_GPCM_EEIER_TOERIR_EN 0x04000000
  596. /* Enable Interrupt for Parity error */
  597. #define IFC_GPCM_EEIER_PERIR_EN 0x01000000
  598. /*
  599. * GPCM Transfer Error Attribute Register-0 (GPCM_ERATTR0)
  600. */
  601. /* Source ID for error transaction */
  602. #define IFC_GPCM_ERATTR0_ERSRCID 0xFF000000
  603. /* AXI ID for error transaction */
  604. #define IFC_GPCM_ERATTR0_ERAID 0x000FF000
  605. /* Chip select corresponds to GPCM error */
  606. #define IFC_GPCM_ERATTR0_ERCS_CS0 0x00000000
  607. #define IFC_GPCM_ERATTR0_ERCS_CS1 0x00000040
  608. #define IFC_GPCM_ERATTR0_ERCS_CS2 0x00000080
  609. #define IFC_GPCM_ERATTR0_ERCS_CS3 0x000000C0
  610. /* Type of transaction read/Write */
  611. #define IFC_GPCM_ERATTR0_ERTYPE_READ 0x00000001
  612. /*
  613. * GPCM Transfer Error Attribute Register-2 (GPCM_ERATTR2)
  614. */
  615. /* On which beat of address/data parity error is observed */
  616. #define IFC_GPCM_ERATTR2_PERR_BEAT 0x00000C00
  617. /* Parity Error on byte */
  618. #define IFC_GPCM_ERATTR2_PERR_BYTE 0x000000F0
  619. /* Parity Error reported in addr or data phase */
  620. #define IFC_GPCM_ERATTR2_PERR_DATA_PHASE 0x00000001
  621. /*
  622. * GPCM Status Register (GPCM_STAT)
  623. */
  624. #define IFC_GPCM_STAT_BSY 0x80000000 /* GPCM is busy */
  625. /*
  626. * IFC Controller NAND Machine registers
  627. */
  628. struct fsl_ifc_nand {
  629. __be32 ncfgr;
  630. u32 res1[0x4];
  631. __be32 nand_fcr0;
  632. __be32 nand_fcr1;
  633. u32 res2[0x8];
  634. __be32 row0;
  635. u32 res3;
  636. __be32 col0;
  637. u32 res4;
  638. __be32 row1;
  639. u32 res5;
  640. __be32 col1;
  641. u32 res6;
  642. __be32 row2;
  643. u32 res7;
  644. __be32 col2;
  645. u32 res8;
  646. __be32 row3;
  647. u32 res9;
  648. __be32 col3;
  649. u32 res10[0x24];
  650. __be32 nand_fbcr;
  651. u32 res11;
  652. __be32 nand_fir0;
  653. __be32 nand_fir1;
  654. __be32 nand_fir2;
  655. u32 res12[0x10];
  656. __be32 nand_csel;
  657. u32 res13;
  658. __be32 nandseq_strt;
  659. u32 res14;
  660. __be32 nand_evter_stat;
  661. u32 res15;
  662. __be32 pgrdcmpl_evt_stat;
  663. u32 res16[0x2];
  664. __be32 nand_evter_en;
  665. u32 res17[0x2];
  666. __be32 nand_evter_intr_en;
  667. u32 res18[0x2];
  668. __be32 nand_erattr0;
  669. __be32 nand_erattr1;
  670. u32 res19[0x10];
  671. __be32 nand_fsr;
  672. u32 res20;
  673. __be32 nand_eccstat[4];
  674. u32 res21[0x20];
  675. __be32 nanndcr;
  676. u32 res22[0x2];
  677. __be32 nand_autoboot_trgr;
  678. u32 res23;
  679. __be32 nand_mdr;
  680. u32 res24[0x5C];
  681. };
  682. /*
  683. * IFC controller NOR Machine registers
  684. */
  685. struct fsl_ifc_nor {
  686. __be32 nor_evter_stat;
  687. u32 res1[0x2];
  688. __be32 nor_evter_en;
  689. u32 res2[0x2];
  690. __be32 nor_evter_intr_en;
  691. u32 res3[0x2];
  692. __be32 nor_erattr0;
  693. __be32 nor_erattr1;
  694. __be32 nor_erattr2;
  695. u32 res4[0x4];
  696. __be32 norcr;
  697. u32 res5[0xEF];
  698. };
  699. /*
  700. * IFC controller GPCM Machine registers
  701. */
  702. struct fsl_ifc_gpcm {
  703. __be32 gpcm_evter_stat;
  704. u32 res1[0x2];
  705. __be32 gpcm_evter_en;
  706. u32 res2[0x2];
  707. __be32 gpcm_evter_intr_en;
  708. u32 res3[0x2];
  709. __be32 gpcm_erattr0;
  710. __be32 gpcm_erattr1;
  711. __be32 gpcm_erattr2;
  712. __be32 gpcm_stat;
  713. u32 res4[0x1F3];
  714. };
  715. /*
  716. * IFC Controller Registers
  717. */
  718. struct fsl_ifc_regs {
  719. __be32 ifc_rev;
  720. u32 res1[0x3];
  721. struct {
  722. __be32 cspr;
  723. u32 res2[0x2];
  724. } cspr_cs[FSL_IFC_BANK_COUNT];
  725. u32 res3[0x18];
  726. struct {
  727. __be32 amask;
  728. u32 res4[0x2];
  729. } amask_cs[FSL_IFC_BANK_COUNT];
  730. u32 res5[0x18];
  731. struct {
  732. __be32 csor;
  733. u32 res6[0x2];
  734. } csor_cs[FSL_IFC_BANK_COUNT];
  735. u32 res7[0x18];
  736. struct {
  737. __be32 ftim[4];
  738. u32 res8[0x8];
  739. } ftim_cs[FSL_IFC_BANK_COUNT];
  740. u32 res9[0x60];
  741. __be32 rb_stat;
  742. u32 res10[0x2];
  743. __be32 ifc_gcr;
  744. u32 res11[0x2];
  745. __be32 cm_evter_stat;
  746. u32 res12[0x2];
  747. __be32 cm_evter_en;
  748. u32 res13[0x2];
  749. __be32 cm_evter_intr_en;
  750. u32 res14[0x2];
  751. __be32 cm_erattr0;
  752. __be32 cm_erattr1;
  753. u32 res15[0x2];
  754. __be32 ifc_ccr;
  755. __be32 ifc_csr;
  756. u32 res16[0x2EB];
  757. struct fsl_ifc_nand ifc_nand;
  758. struct fsl_ifc_nor ifc_nor;
  759. struct fsl_ifc_gpcm ifc_gpcm;
  760. };
  761. extern unsigned int convert_ifc_address(phys_addr_t addr_base);
  762. extern int fsl_ifc_find(phys_addr_t addr_base);
  763. /* overview of the fsl ifc controller */
  764. struct fsl_ifc_ctrl {
  765. /* device info */
  766. struct device *dev;
  767. struct fsl_ifc_regs __iomem *regs;
  768. int irq;
  769. int nand_irq;
  770. spinlock_t lock;
  771. void *nand;
  772. u32 nand_stat;
  773. wait_queue_head_t nand_wait;
  774. };
  775. extern struct fsl_ifc_ctrl *fsl_ifc_ctrl_dev;
  776. #endif /* __ASM_FSL_IFC_H */