msm_nand.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. /* drivers/mtd/devices/msm_nand.h
  2. *
  3. * Copyright (c) 2008-2011, The Linux Foundation. All rights reserved.
  4. * Copyright (C) 2007 Google, Inc.
  5. *
  6. * This software is licensed under the terms of the GNU General Public
  7. * License version 2, as published by the Free Software Foundation, and
  8. * may be copied, distributed, and modified under those terms.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. */
  16. #ifndef __DRIVERS_MTD_DEVICES_MSM_NAND_H
  17. #define __DRIVERS_MTD_DEVICES_MSM_NAND_H
  18. #include <mach/msm_iomap.h>
  19. extern unsigned long msm_nand_phys;
  20. extern unsigned long msm_nandc01_phys;
  21. extern unsigned long msm_nandc10_phys;
  22. extern unsigned long msm_nandc11_phys;
  23. extern unsigned long ebi2_register_base;
  24. #define NC01(X) ((X) + msm_nandc01_phys - msm_nand_phys)
  25. #define NC10(X) ((X) + msm_nandc10_phys - msm_nand_phys)
  26. #define NC11(X) ((X) + msm_nandc11_phys - msm_nand_phys)
  27. #define MSM_NAND_REG(off) (msm_nand_phys + (off))
  28. #define MSM_NAND_FLASH_CMD MSM_NAND_REG(0x0000)
  29. #define MSM_NAND_ADDR0 MSM_NAND_REG(0x0004)
  30. #define MSM_NAND_ADDR1 MSM_NAND_REG(0x0008)
  31. #define MSM_NAND_FLASH_CHIP_SELECT MSM_NAND_REG(0x000C)
  32. #define MSM_NAND_EXEC_CMD MSM_NAND_REG(0x0010)
  33. #define MSM_NAND_FLASH_STATUS MSM_NAND_REG(0x0014)
  34. #define MSM_NAND_BUFFER_STATUS MSM_NAND_REG(0x0018)
  35. #define MSM_NAND_SFLASHC_STATUS MSM_NAND_REG(0x001C)
  36. #define MSM_NAND_DEV0_CFG0 MSM_NAND_REG(0x0020)
  37. #define MSM_NAND_DEV0_CFG1 MSM_NAND_REG(0x0024)
  38. #define MSM_NAND_DEV0_ECC_CFG MSM_NAND_REG(0x0028)
  39. #define MSM_NAND_DEV1_ECC_CFG MSM_NAND_REG(0x002C)
  40. #define MSM_NAND_DEV1_CFG0 MSM_NAND_REG(0x0030)
  41. #define MSM_NAND_DEV1_CFG1 MSM_NAND_REG(0x0034)
  42. #define MSM_NAND_SFLASHC_CMD MSM_NAND_REG(0x0038)
  43. #define MSM_NAND_SFLASHC_EXEC_CMD MSM_NAND_REG(0x003C)
  44. #define MSM_NAND_READ_ID MSM_NAND_REG(0x0040)
  45. #define MSM_NAND_READ_STATUS MSM_NAND_REG(0x0044)
  46. #define MSM_NAND_CONFIG_DATA MSM_NAND_REG(0x0050)
  47. #define MSM_NAND_CONFIG MSM_NAND_REG(0x0054)
  48. #define MSM_NAND_CONFIG_MODE MSM_NAND_REG(0x0058)
  49. #define MSM_NAND_CONFIG_STATUS MSM_NAND_REG(0x0060)
  50. #define MSM_NAND_MACRO1_REG MSM_NAND_REG(0x0064)
  51. #define MSM_NAND_XFR_STEP1 MSM_NAND_REG(0x0070)
  52. #define MSM_NAND_XFR_STEP2 MSM_NAND_REG(0x0074)
  53. #define MSM_NAND_XFR_STEP3 MSM_NAND_REG(0x0078)
  54. #define MSM_NAND_XFR_STEP4 MSM_NAND_REG(0x007C)
  55. #define MSM_NAND_XFR_STEP5 MSM_NAND_REG(0x0080)
  56. #define MSM_NAND_XFR_STEP6 MSM_NAND_REG(0x0084)
  57. #define MSM_NAND_XFR_STEP7 MSM_NAND_REG(0x0088)
  58. #define MSM_NAND_GENP_REG0 MSM_NAND_REG(0x0090)
  59. #define MSM_NAND_GENP_REG1 MSM_NAND_REG(0x0094)
  60. #define MSM_NAND_GENP_REG2 MSM_NAND_REG(0x0098)
  61. #define MSM_NAND_GENP_REG3 MSM_NAND_REG(0x009C)
  62. #define MSM_NAND_DEV_CMD0 MSM_NAND_REG(0x00A0)
  63. #define MSM_NAND_DEV_CMD1 MSM_NAND_REG(0x00A4)
  64. #define MSM_NAND_DEV_CMD2 MSM_NAND_REG(0x00A8)
  65. #define MSM_NAND_DEV_CMD_VLD MSM_NAND_REG(0x00AC)
  66. #define MSM_NAND_EBI2_MISR_SIG_REG MSM_NAND_REG(0x00B0)
  67. #define MSM_NAND_ADDR2 MSM_NAND_REG(0x00C0)
  68. #define MSM_NAND_ADDR3 MSM_NAND_REG(0x00C4)
  69. #define MSM_NAND_ADDR4 MSM_NAND_REG(0x00C8)
  70. #define MSM_NAND_ADDR5 MSM_NAND_REG(0x00CC)
  71. #define MSM_NAND_DEV_CMD3 MSM_NAND_REG(0x00D0)
  72. #define MSM_NAND_DEV_CMD4 MSM_NAND_REG(0x00D4)
  73. #define MSM_NAND_DEV_CMD5 MSM_NAND_REG(0x00D8)
  74. #define MSM_NAND_DEV_CMD6 MSM_NAND_REG(0x00DC)
  75. #define MSM_NAND_SFLASHC_BURST_CFG MSM_NAND_REG(0x00E0)
  76. #define MSM_NAND_ADDR6 MSM_NAND_REG(0x00E4)
  77. #define MSM_NAND_EBI2_ECC_BUF_CFG MSM_NAND_REG(0x00F0)
  78. #define MSM_NAND_HW_INFO MSM_NAND_REG(0x00FC)
  79. #define MSM_NAND_FLASH_BUFFER MSM_NAND_REG(0x0100)
  80. /* device commands */
  81. #define MSM_NAND_CMD_SOFT_RESET 0x01
  82. #define MSM_NAND_CMD_PAGE_READ 0x32
  83. #define MSM_NAND_CMD_PAGE_READ_ECC 0x33
  84. #define MSM_NAND_CMD_PAGE_READ_ALL 0x34
  85. #define MSM_NAND_CMD_SEQ_PAGE_READ 0x15
  86. #define MSM_NAND_CMD_PRG_PAGE 0x36
  87. #define MSM_NAND_CMD_PRG_PAGE_ECC 0x37
  88. #define MSM_NAND_CMD_PRG_PAGE_ALL 0x39
  89. #define MSM_NAND_CMD_BLOCK_ERASE 0x3A
  90. #define MSM_NAND_CMD_FETCH_ID 0x0B
  91. #define MSM_NAND_CMD_STATUS 0x0C
  92. #define MSM_NAND_CMD_RESET 0x0D
  93. /* Sflash Commands */
  94. #define MSM_NAND_SFCMD_DATXS 0x0
  95. #define MSM_NAND_SFCMD_CMDXS 0x1
  96. #define MSM_NAND_SFCMD_BURST 0x0
  97. #define MSM_NAND_SFCMD_ASYNC 0x1
  98. #define MSM_NAND_SFCMD_ABORT 0x1
  99. #define MSM_NAND_SFCMD_REGRD 0x2
  100. #define MSM_NAND_SFCMD_REGWR 0x3
  101. #define MSM_NAND_SFCMD_INTLO 0x4
  102. #define MSM_NAND_SFCMD_INTHI 0x5
  103. #define MSM_NAND_SFCMD_DATRD 0x6
  104. #define MSM_NAND_SFCMD_DATWR 0x7
  105. #define SFLASH_PREPCMD(numxfr, offval, delval, trnstp, mode, opcode) \
  106. ((numxfr<<20)|(offval<<12)|(delval<<6)|(trnstp<<5)|(mode<<4)|opcode)
  107. #define SFLASH_BCFG 0x20100327
  108. /* Onenand addresses */
  109. #define ONENAND_MANUFACTURER_ID 0xF000
  110. #define ONENAND_DEVICE_ID 0xF001
  111. #define ONENAND_VERSION_ID 0xF002
  112. #define ONENAND_DATA_BUFFER_SIZE 0xF003
  113. #define ONENAND_BOOT_BUFFER_SIZE 0xF004
  114. #define ONENAND_AMOUNT_OF_BUFFERS 0xF005
  115. #define ONENAND_TECHNOLOGY 0xF006
  116. #define ONENAND_START_ADDRESS_1 0xF100
  117. #define ONENAND_START_ADDRESS_2 0xF101
  118. #define ONENAND_START_ADDRESS_3 0xF102
  119. #define ONENAND_START_ADDRESS_4 0xF103
  120. #define ONENAND_START_ADDRESS_5 0xF104
  121. #define ONENAND_START_ADDRESS_6 0xF105
  122. #define ONENAND_START_ADDRESS_7 0xF106
  123. #define ONENAND_START_ADDRESS_8 0xF107
  124. #define ONENAND_START_BUFFER 0xF200
  125. #define ONENAND_COMMAND 0xF220
  126. #define ONENAND_SYSTEM_CONFIG_1 0xF221
  127. #define ONENAND_SYSTEM_CONFIG_2 0xF222
  128. #define ONENAND_CONTROLLER_STATUS 0xF240
  129. #define ONENAND_INTERRUPT_STATUS 0xF241
  130. #define ONENAND_START_BLOCK_ADDRESS 0xF24C
  131. #define ONENAND_WRITE_PROT_STATUS 0xF24E
  132. #define ONENAND_ECC_STATUS 0xFF00
  133. #define ONENAND_ECC_ERRPOS_MAIN0 0xFF01
  134. #define ONENAND_ECC_ERRPOS_SPARE0 0xFF02
  135. #define ONENAND_ECC_ERRPOS_MAIN1 0xFF03
  136. #define ONENAND_ECC_ERRPOS_SPARE1 0xFF04
  137. #define ONENAND_ECC_ERRPOS_MAIN2 0xFF05
  138. #define ONENAND_ECC_ERRPOS_SPARE2 0xFF06
  139. #define ONENAND_ECC_ERRPOS_MAIN3 0xFF07
  140. #define ONENAND_ECC_ERRPOS_SPARE3 0xFF08
  141. /* Onenand commands */
  142. #define ONENAND_WP_US (1 << 2)
  143. #define ONENAND_WP_LS (1 << 1)
  144. #define ONENAND_CMDLOAD 0x0000
  145. #define ONENAND_CMDLOADSPARE 0x0013
  146. #define ONENAND_CMDPROG 0x0080
  147. #define ONENAND_CMDPROGSPARE 0x001A
  148. #define ONENAND_CMDERAS 0x0094
  149. #define ONENAND_CMD_UNLOCK 0x0023
  150. #define ONENAND_CMD_LOCK 0x002A
  151. #define ONENAND_SYSCFG1_ECCENA(mode) (0x40E0 | (mode ? 0 : 0x8002))
  152. #define ONENAND_SYSCFG1_ECCDIS(mode) (0x41E0 | (mode ? 0 : 0x8002))
  153. #define ONENAND_CLRINTR 0x0000
  154. #define ONENAND_STARTADDR1_RES 0x07FF
  155. #define ONENAND_STARTADDR3_RES 0x07FF
  156. #define DATARAM0_0 0x8
  157. #define DEVICE_FLASHCORE_0 (0 << 15)
  158. #define DEVICE_FLASHCORE_1 (1 << 15)
  159. #define DEVICE_BUFFERRAM_0 (0 << 15)
  160. #define DEVICE_BUFFERRAM_1 (1 << 15)
  161. #define ONENAND_DEVICE_IS_DDP (1 << 3)
  162. #define CLEAN_DATA_16 0xFFFF
  163. #define CLEAN_DATA_32 0xFFFFFFFF
  164. #define EBI2_REG(off) (ebi2_register_base + (off))
  165. #define EBI2_CHIP_SELECT_CFG0 EBI2_REG(0x0000)
  166. #define EBI2_CFG_REG EBI2_REG(0x0004)
  167. #define EBI2_NAND_ADM_MUX EBI2_REG(0x005C)
  168. extern struct flash_platform_data msm_nand_data;
  169. #endif