hw_flash_ctrl.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. /******************************************************************************
  2. * Filename: hw_flash_ctrl.h
  3. * Revised: $Date: 2013-04-30 17:13:44 +0200 (Tue, 30 Apr 2013) $
  4. * Revision: $Revision: 9943 $
  5. *
  6. * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
  7. *
  8. *
  9. * Redistribution and use in source and binary forms, with or without
  10. * modification, are permitted provided that the following conditions
  11. * are met:
  12. *
  13. * Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions and the following disclaimer.
  15. *
  16. * Redistributions in binary form must reproduce the above copyright
  17. * notice, this list of conditions and the following disclaimer in the
  18. * documentation and/or other materials provided with the distribution.
  19. *
  20. * Neither the name of Texas Instruments Incorporated nor the names of
  21. * its contributors may be used to endorse or promote products derived
  22. * from this software without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  25. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  26. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  27. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  28. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  29. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  30. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  31. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  32. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  33. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  34. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  35. *
  36. ******************************************************************************/
  37. #ifndef __HW_FLASH_CTRL_H__
  38. #define __HW_FLASH_CTRL_H__
  39. //*****************************************************************************
  40. //
  41. // The following are defines for the FLASH_CTRL register offsets.
  42. //
  43. //*****************************************************************************
  44. #define FLASH_CTRL_FCTL 0x400D3008 // Flash control This register
  45. // provides control and monitoring
  46. // functions for the flash module.
  47. #define FLASH_CTRL_FADDR 0x400D300C // Flash address The register sets
  48. // the address to be written in
  49. // flash memory. See the bitfield
  50. // descriptions for formatting
  51. // information.
  52. #define FLASH_CTRL_FWDATA 0x400D3010 // Flash data This register
  53. // contains the 32-bits of data to
  54. // be written to the flash location
  55. // selected in FADDR.
  56. #define FLASH_CTRL_DIECFG0 0x400D3014 // These settings are a function
  57. // of the FLASH information page
  58. // bit settings, which are
  59. // programmed during production
  60. // test, and are subject for
  61. // specific configuration for
  62. // multiple device flavors of
  63. // cc2538.
  64. #define FLASH_CTRL_DIECFG1 0x400D3018 // These settings are a function
  65. // of the FLASH information page
  66. // bit settings, which are
  67. // programmed during production
  68. // test, and are subject for
  69. // specific configuration for
  70. // multiple device flavors of
  71. // cc2538.
  72. #define FLASH_CTRL_DIECFG2 0x400D301C // These settings are a function
  73. // of the FLASH information page
  74. // bit settings, which are
  75. // programmed during production
  76. // test, and are subject for
  77. // specific configuration for
  78. // multiple device flavors of
  79. // cc2538. The DIE_*_REVISION
  80. // registers are an exeception to
  81. // this, as they are hardwired and
  82. // are not part of the FLASH
  83. // information page.
  84. //*****************************************************************************
  85. //
  86. // The following are defines for the bit fields in the
  87. // FLASH_CTRL_FCTL register.
  88. //
  89. //*****************************************************************************
  90. #define FLASH_CTRL_FCTL_UPPER_PAGE_ACCESS \
  91. 0x00000200 // Lock bit for lock bit page 0:
  92. // Neither write nor erase not
  93. // allowed 1: Both write and erase
  94. // allowed
  95. #define FLASH_CTRL_FCTL_UPPER_PAGE_ACCESS_M \
  96. 0x00000200
  97. #define FLASH_CTRL_FCTL_UPPER_PAGE_ACCESS_S 9
  98. #define FLASH_CTRL_FCTL_SEL_INFO_PAGE \
  99. 0x00000100 // Flash erase or write operation
  100. // on APB bus must assert this when
  101. // accessing the information page
  102. #define FLASH_CTRL_FCTL_SEL_INFO_PAGE_M \
  103. 0x00000100
  104. #define FLASH_CTRL_FCTL_SEL_INFO_PAGE_S 8
  105. #define FLASH_CTRL_FCTL_BUSY 0x00000080 // Set when the WRITE or ERASE bit
  106. // is set; that is, when the flash
  107. // controller is busy
  108. #define FLASH_CTRL_FCTL_BUSY_M 0x00000080
  109. #define FLASH_CTRL_FCTL_BUSY_S 7
  110. #define FLASH_CTRL_FCTL_FULL 0x00000040 // Write buffer full The CPU can
  111. // write to FWDATA when this bit is
  112. // 0 and WRITE is 1. This bit is
  113. // cleared when BUSY is cleared.
  114. #define FLASH_CTRL_FCTL_FULL_M 0x00000040
  115. #define FLASH_CTRL_FCTL_FULL_S 6
  116. #define FLASH_CTRL_FCTL_ABORT 0x00000020 // Abort status This bit is set to
  117. // 1 when a write sequence or page
  118. // erase is aborted. An operation
  119. // is aborted when the accessed
  120. // page is locked. Cleared when a
  121. // write or page erase is started.
  122. // If a write operation times out
  123. // (because the FWDATA register is
  124. // not written fast enough), the
  125. // ABORT bit is not set even if the
  126. // page is locked. If a page erase
  127. // and a write operation are
  128. // started simultaneously, the
  129. // ABORT bit reflects the status of
  130. // the last write operation. For
  131. // example, if the page is locked
  132. // and the write times out, the
  133. // ABORT bit is not set because
  134. // only the write operation times
  135. // out.
  136. #define FLASH_CTRL_FCTL_ABORT_M 0x00000020
  137. #define FLASH_CTRL_FCTL_ABORT_S 5
  138. #define FLASH_CTRL_FCTL_CM_M 0x0000000C // Cache Mode Disabling the cache
  139. // increases the power consumption
  140. // and reduces performance.
  141. // Prefetching improves performance
  142. // at the expense of a potential
  143. // increase in power consumption.
  144. // Real-time mode provides
  145. // predictable flash read access
  146. // time, the execution time is
  147. // equal to cache disabled mode,
  148. // but the power consumption is
  149. // lower. 00: Cache disabled 01:
  150. // Cache enabled 10: Cache enabled,
  151. // with prefetch 11: Real-time mode
  152. // Note: The read value always
  153. // represents the current cache
  154. // mode. Writing a new cache mode
  155. // starts a cache mode change
  156. // request that does not take
  157. // effect until the controller is
  158. // ready. Writes to this register
  159. // are ignored if there is a
  160. // current cache change request in
  161. // progress.
  162. #define FLASH_CTRL_FCTL_CM_S 2
  163. #define FLASH_CTRL_FCTL_WRITE 0x00000002 // Write bit Start a write
  164. // sequence by setting this bit to
  165. // 1. Cleared by hardware when the
  166. // operation completes. Writes to
  167. // this bit are ignored when
  168. // FCTL.BUSY is 1. If FCTL.ERASE is
  169. // set simultaneously with this
  170. // bit, the erase operation is
  171. // started first, then the write is
  172. // started.
  173. #define FLASH_CTRL_FCTL_WRITE_M 0x00000002
  174. #define FLASH_CTRL_FCTL_WRITE_S 1
  175. #define FLASH_CTRL_FCTL_ERASE 0x00000001 // Erase bit Start an erase
  176. // operation by setting this bit to
  177. // 1. Cleared by hardware when the
  178. // operation completes. Writes to
  179. // this bit are ignored when
  180. // FCTL.BUSY is 1. If FCTL.WRITE is
  181. // set simultaneously with this
  182. // bit, the erase operation is
  183. // started first, then the write is
  184. // started.
  185. #define FLASH_CTRL_FCTL_ERASE_M 0x00000001
  186. #define FLASH_CTRL_FCTL_ERASE_S 0
  187. //*****************************************************************************
  188. //
  189. // The following are defines for the bit fields in the
  190. // FLASH_CTRL_FADDR register.
  191. //
  192. //*****************************************************************************
  193. #define FLASH_CTRL_FADDR_FADDR_M \
  194. 0x0001FFFF // Bit number [16:9] selects one
  195. // of 256 pages for page erase. Bit
  196. // number [8:7] selects one of the
  197. // 4 row in a given page Bit number
  198. // [6:1] selects one of the 64-bit
  199. // wide locations in a give row.
  200. // Bit number [0] will select
  201. // upper/lower 32-bits in a given
  202. // 64-bit location - 64Kbytes -->
  203. // Bits [16:14] will always be 0. -
  204. // 128Kbytes --> Bits [16:15] will
  205. // always be 0. - 256Kbytes --> Bit
  206. // [16] will always be 0. -
  207. // 384/512Kbytes --> All bits
  208. // written and valid. Writes to
  209. // this register will be ignored
  210. // when any of FCTL.WRITE and
  211. // FCTL.ERASE is set. FADDR should
  212. // be written with byte addressable
  213. // location of the Flash to be
  214. // programmed. Read back value
  215. // always reflects a 32-bit aligned
  216. // address. When the register is
  217. // read back, the value that was
  218. // written to FADDR gets right
  219. // shift by 2 to indicate 32-bit
  220. // aligned address. In other words
  221. // lower 2 bits are discarded while
  222. // reading back the register. Out
  223. // of range address results in roll
  224. // over. There is no status signal
  225. // generated by flash controller to
  226. // indicate this. Firmware is
  227. // responsible to managing the
  228. // addresses correctly.
  229. #define FLASH_CTRL_FADDR_FADDR_S 0
  230. //*****************************************************************************
  231. //
  232. // The following are defines for the bit fields in the
  233. // FLASH_CTRL_FWDATA register.
  234. //
  235. //*****************************************************************************
  236. #define FLASH_CTRL_FWDATA_FWDATA_M \
  237. 0xFFFFFFFF // 32-bit flash write data Writes
  238. // to this register are accepted
  239. // only during a flash write
  240. // sequence; that is, writes to
  241. // this register after having
  242. // written 1 to the FCTL.WRITE bit.
  243. // New 32-bit data is written only
  244. // if FCTL.FULL = 0.
  245. #define FLASH_CTRL_FWDATA_FWDATA_S 0
  246. //*****************************************************************************
  247. //
  248. // The following are defines for the bit fields in the
  249. // FLASH_CTRL_DIECFG0 register.
  250. //
  251. //*****************************************************************************
  252. #define FLASH_CTRL_DIECFG0_CHIPID_M \
  253. 0xFFFF0000 // Register copy of configuration
  254. // bits Three clock cycles after
  255. // reset is released, this bit
  256. // field is equal to the field with
  257. // the same name in the information
  258. // page.
  259. #define FLASH_CTRL_DIECFG0_CHIPID_S 16
  260. #define FLASH_CTRL_DIECFG0_CLK_SEL_GATE_EN_N \
  261. 0x00000400 // Register copy of configuration
  262. // bits Three clock cycles after
  263. // reset is released, this bit is
  264. // equal to the field with the same
  265. // name in the information page.
  266. #define FLASH_CTRL_DIECFG0_CLK_SEL_GATE_EN_N_M \
  267. 0x00000400
  268. #define FLASH_CTRL_DIECFG0_CLK_SEL_GATE_EN_N_S 10
  269. #define FLASH_CTRL_DIECFG0_SRAM_SIZE_M \
  270. 0x00000380 // Register copy of configuration
  271. // bits Three clock cycles after
  272. // reset is released, this bit
  273. // field is equal to the field with
  274. // the same name in the information
  275. // page.
  276. #define FLASH_CTRL_DIECFG0_SRAM_SIZE_S 7
  277. #define FLASH_CTRL_DIECFG0_FLASH_SIZE_M \
  278. 0x00000070 // Register copy of configuration
  279. // bits Three clock cycles after
  280. // reset is released, this bit
  281. // field is equal to the field with
  282. // the same name in the information
  283. // page.
  284. #define FLASH_CTRL_DIECFG0_FLASH_SIZE_S 4
  285. #define FLASH_CTRL_DIECFG0_USB_ENABLE \
  286. 0x00000008 // Register copy of configuration
  287. // bits Three clock cycles after
  288. // reset is released, this bit is
  289. // equal to the field with the same
  290. // name in the information page.
  291. #define FLASH_CTRL_DIECFG0_USB_ENABLE_M \
  292. 0x00000008
  293. #define FLASH_CTRL_DIECFG0_USB_ENABLE_S 3
  294. #define FLASH_CTRL_DIECFG0_MASS_ERASE_ENABLE \
  295. 0x00000004 // Register copy of configuration
  296. // bits Three clock cycles after
  297. // reset is released, this bit is
  298. // equal to the field with the same
  299. // name in the information page.
  300. #define FLASH_CTRL_DIECFG0_MASS_ERASE_ENABLE_M \
  301. 0x00000004
  302. #define FLASH_CTRL_DIECFG0_MASS_ERASE_ENABLE_S 2
  303. #define FLASH_CTRL_DIECFG0_LOCK_FWT_N \
  304. 0x00000002 // Register copy of configuration
  305. // bits Three clock cycles after
  306. // reset is released, this bit is
  307. // equal to the field with the same
  308. // name in the information page.
  309. #define FLASH_CTRL_DIECFG0_LOCK_FWT_N_M \
  310. 0x00000002
  311. #define FLASH_CTRL_DIECFG0_LOCK_FWT_N_S 1
  312. #define FLASH_CTRL_DIECFG0_LOCK_IP_N \
  313. 0x00000001 // Register copy of configuration
  314. // bits Three clock cycles after
  315. // reset is released, this bit is
  316. // equal to the field with the same
  317. // name in the information page.
  318. #define FLASH_CTRL_DIECFG0_LOCK_IP_N_M \
  319. 0x00000001
  320. #define FLASH_CTRL_DIECFG0_LOCK_IP_N_S 0
  321. //*****************************************************************************
  322. //
  323. // The following are defines for the bit fields in the
  324. // FLASH_CTRL_DIECFG1 register.
  325. //
  326. //*****************************************************************************
  327. #define FLASH_CTRL_DIECFG1_I2C_EN \
  328. 0x01000000 // 1: I2C is enabled. 0: I2C is
  329. // permanently disabled.
  330. #define FLASH_CTRL_DIECFG1_I2C_EN_M \
  331. 0x01000000
  332. #define FLASH_CTRL_DIECFG1_I2C_EN_S 24
  333. #define FLASH_CTRL_DIECFG1_UART1_EN \
  334. 0x00020000 // 1: UART1 is enabled. 0: UART1
  335. // is permanently disabled.
  336. #define FLASH_CTRL_DIECFG1_UART1_EN_M \
  337. 0x00020000
  338. #define FLASH_CTRL_DIECFG1_UART1_EN_S 17
  339. #define FLASH_CTRL_DIECFG1_UART0_EN \
  340. 0x00010000 // 1: UART0 is enabled. 0: UART0
  341. // is permanently disabled.
  342. #define FLASH_CTRL_DIECFG1_UART0_EN_M \
  343. 0x00010000
  344. #define FLASH_CTRL_DIECFG1_UART0_EN_S 16
  345. #define FLASH_CTRL_DIECFG1_SSI1_EN \
  346. 0x00000200 // 1: SSI1 is enabled. 0: SSI1 is
  347. // permanently disabled.
  348. #define FLASH_CTRL_DIECFG1_SSI1_EN_M \
  349. 0x00000200
  350. #define FLASH_CTRL_DIECFG1_SSI1_EN_S 9
  351. #define FLASH_CTRL_DIECFG1_SSI0_EN \
  352. 0x00000100 // 1: SSI0 is enabled. 0: SSI0 is
  353. // permanently disabled.
  354. #define FLASH_CTRL_DIECFG1_SSI0_EN_M \
  355. 0x00000100
  356. #define FLASH_CTRL_DIECFG1_SSI0_EN_S 8
  357. #define FLASH_CTRL_DIECFG1_GPTM3_EN \
  358. 0x00000008 // 1: GPTM3 is enabled. 0: GPTM3
  359. // is permanently disabled.
  360. #define FLASH_CTRL_DIECFG1_GPTM3_EN_M \
  361. 0x00000008
  362. #define FLASH_CTRL_DIECFG1_GPTM3_EN_S 3
  363. #define FLASH_CTRL_DIECFG1_GPTM2_EN \
  364. 0x00000004 // 1: GPTM2 is enabled. 0: GPTM2
  365. // is permanently disabled.
  366. #define FLASH_CTRL_DIECFG1_GPTM2_EN_M \
  367. 0x00000004
  368. #define FLASH_CTRL_DIECFG1_GPTM2_EN_S 2
  369. #define FLASH_CTRL_DIECFG1_GPTM1_EN \
  370. 0x00000002 // 1: GPTM1 is enabled. 0: GPTM1
  371. // is permanently disabled.
  372. #define FLASH_CTRL_DIECFG1_GPTM1_EN_M \
  373. 0x00000002
  374. #define FLASH_CTRL_DIECFG1_GPTM1_EN_S 1
  375. #define FLASH_CTRL_DIECFG1_GPTM0_EN \
  376. 0x00000001 // 1: GPTM0 is enabled. 0: GPTM0
  377. // is permanently disabled.
  378. #define FLASH_CTRL_DIECFG1_GPTM0_EN_M \
  379. 0x00000001
  380. #define FLASH_CTRL_DIECFG1_GPTM0_EN_S 0
  381. //*****************************************************************************
  382. //
  383. // The following are defines for the bit fields in the
  384. // FLASH_CTRL_DIECFG2 register.
  385. //
  386. //*****************************************************************************
  387. #define FLASH_CTRL_DIECFG2_DIE_MAJOR_REVISION_M \
  388. 0x0000F000 // Indicates the major revision
  389. // (all layer change) number for
  390. // the cc2538 0x0 - PG1.0 0x2 -
  391. // PG2.0
  392. #define FLASH_CTRL_DIECFG2_DIE_MAJOR_REVISION_S 12
  393. #define FLASH_CTRL_DIECFG2_DIE_MINOR_REVISION_M \
  394. 0x00000F00 // Indicates the minor revision
  395. // (metla layer only) number for
  396. // the cc2538 0x0 - PG1.0 or PG2.0
  397. #define FLASH_CTRL_DIECFG2_DIE_MINOR_REVISION_S 8
  398. #define FLASH_CTRL_DIECFG2_RF_CORE_EN \
  399. 0x00000004 // 1: RF_CORE is enabled. 0:
  400. // RF_CORE is permanently disabled.
  401. #define FLASH_CTRL_DIECFG2_RF_CORE_EN_M \
  402. 0x00000004
  403. #define FLASH_CTRL_DIECFG2_RF_CORE_EN_S 2
  404. #define FLASH_CTRL_DIECFG2_AES_EN \
  405. 0x00000002 // 1: AES is enabled. 0: AES is
  406. // permanently disabled.
  407. #define FLASH_CTRL_DIECFG2_AES_EN_M \
  408. 0x00000002
  409. #define FLASH_CTRL_DIECFG2_AES_EN_S 1
  410. #define FLASH_CTRL_DIECFG2_PKA_EN \
  411. 0x00000001 // 1: PKA is enabled. 0: PKA is
  412. // permanently disabled.
  413. #define FLASH_CTRL_DIECFG2_PKA_EN_M \
  414. 0x00000001
  415. #define FLASH_CTRL_DIECFG2_PKA_EN_S 0
  416. #endif // __HW_FLASH_CTRL_H__