hw_camera.h 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  1. //*****************************************************************************
  2. //
  3. // Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
  4. //
  5. //
  6. // Redistribution and use in source and binary forms, with or without
  7. // modification, are permitted provided that the following conditions
  8. // are met:
  9. //
  10. // Redistributions of source code must retain the above copyright
  11. // notice, this list of conditions and the following disclaimer.
  12. //
  13. // Redistributions in binary form must reproduce the above copyright
  14. // notice, this list of conditions and the following disclaimer in the
  15. // documentation and/or other materials provided with the
  16. // distribution.
  17. //
  18. // Neither the name of Texas Instruments Incorporated nor the names of
  19. // its contributors may be used to endorse or promote products derived
  20. // from this software without specific prior written permission.
  21. //
  22. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  23. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  24. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  25. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  26. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  27. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  28. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  29. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  30. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  31. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  32. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33. //
  34. //*****************************************************************************
  35. #ifndef __HW_CAMERA_H__
  36. #define __HW_CAMERA_H__
  37. //*****************************************************************************
  38. //
  39. // The following are defines for the CAMERA register offsets.
  40. //
  41. //*****************************************************************************
  42. #define CAMERA_O_CC_REVISION 0x00000000 // This register contains the IP
  43. // revision code ( Parallel Mode)
  44. #define CAMERA_O_CC_SYSCONFIG 0x00000010 // This register controls the
  45. // various parameters of the OCP
  46. // interface (CCP and Parallel Mode)
  47. #define CAMERA_O_CC_SYSSTATUS 0x00000014 // This register provides status
  48. // information about the module
  49. // excluding the interrupt status
  50. // information (CCP and Parallel
  51. // Mode)
  52. #define CAMERA_O_CC_IRQSTATUS 0x00000018 // The interrupt status regroups
  53. // all the status of the module
  54. // internal events that can generate
  55. // an interrupt (CCP & Parallel
  56. // Mode)
  57. #define CAMERA_O_CC_IRQENABLE 0x0000001C // The interrupt enable register
  58. // allows to enable/disable the
  59. // module internal sources of
  60. // interrupt on an event-by-event
  61. // basis (CCP & Parallel Mode)
  62. #define CAMERA_O_CC_CTRL 0x00000040 // This register controls the
  63. // various parameters of the Camera
  64. // Core block (CCP & Parallel Mode)
  65. #define CAMERA_O_CC_CTRL_DMA 0x00000044 // This register controls the DMA
  66. // interface of the Camera Core
  67. // block (CCP & Parallel Mode)
  68. #define CAMERA_O_CC_CTRL_XCLK 0x00000048 // This register control the value
  69. // of the clock divisor used to
  70. // generate the external clock
  71. // (Parallel Mode)
  72. #define CAMERA_O_CC_FIFO_DATA 0x0000004C // This register allows to write to
  73. // the FIFO and read from the FIFO
  74. // (CCP & Parallel Mode)
  75. #define CAMERA_O_CC_TEST 0x00000050 // This register shows the status
  76. // of some important variables of
  77. // the camera core module (CCP &
  78. // Parallel Mode)
  79. #define CAMERA_O_CC_GEN_PAR 0x00000054 // This register shows the values
  80. // of the generic parameters of the
  81. // module
  82. //******************************************************************************
  83. //
  84. // The following are defines for the bit fields in the
  85. // CAMERA_O_CC_REVISION register.
  86. //
  87. //******************************************************************************
  88. #define CAMERA_CC_REVISION_REV_M \
  89. 0x000000FF // IP revision [7:4] Major revision
  90. // [3:0] Minor revision Examples:
  91. // 0x10 for 1.0 0x21 for 2.1
  92. #define CAMERA_CC_REVISION_REV_S 0
  93. //******************************************************************************
  94. //
  95. // The following are defines for the bit fields in the
  96. // CAMERA_O_CC_SYSCONFIG register.
  97. //
  98. //******************************************************************************
  99. #define CAMERA_CC_SYSCONFIG_S_IDLE_MODE_M \
  100. 0x00000018 // Slave interface power management
  101. // req/ack control """00""
  102. // Force-idle. An idle request is
  103. // acknoledged unconditionally"
  104. // """01"" No-idle. An idle request
  105. // is never acknowledged" """10""
  106. // reserved (Smart-idle not
  107. // implemented)"
  108. #define CAMERA_CC_SYSCONFIG_S_IDLE_MODE_S 3
  109. #define CAMERA_CC_SYSCONFIG_SOFT_RESET \
  110. 0x00000002 // Software reset. Set this bit to
  111. // 1 to trigger a module reset. The
  112. // bit is automatically reset by the
  113. // hardware. During reset it always
  114. // returns 0. 0 Normal mode 1 The
  115. // module is reset
  116. #define CAMERA_CC_SYSCONFIG_AUTO_IDLE \
  117. 0x00000001 // Internal OCP clock gating
  118. // strategy 0 OCP clock is
  119. // free-running 1 Automatic OCP
  120. // clock gating strategy is applied
  121. // based on the OCP interface
  122. // activity
  123. //******************************************************************************
  124. //
  125. // The following are defines for the bit fields in the
  126. // CAMERA_O_CC_SYSSTATUS register.
  127. //
  128. //******************************************************************************
  129. #define CAMERA_CC_SYSSTATUS_RESET_DONE2 \
  130. 0x00000001 // Internal Reset Monitoring 0
  131. // Internal module reset is on-going
  132. // 1 Reset completed
  133. //******************************************************************************
  134. //
  135. // The following are defines for the bit fields in the
  136. // CAMERA_O_CC_IRQSTATUS register.
  137. //
  138. //******************************************************************************
  139. #define CAMERA_CC_IRQSTATUS_FS_IRQ \
  140. 0x00080000 // Frame Start has occurred 0 Event
  141. // false "1 Event is true
  142. // (""pending"")" 0 Event status bit
  143. // unchanged 1 Event status bit is
  144. // reset
  145. #define CAMERA_CC_IRQSTATUS_LE_IRQ \
  146. 0x00040000 // Line End has occurred 0 Event
  147. // false "1 Event is true
  148. // (""pending"")" 0 Event status bit
  149. // unchanged 1 Event status bit is
  150. // reset
  151. #define CAMERA_CC_IRQSTATUS_LS_IRQ \
  152. 0x00020000 // Line Start has occurred 0 Event
  153. // false "1 Event is true
  154. // (""pending"")" 0 Event status bit
  155. // unchanged 1 Event status bit is
  156. // reset
  157. #define CAMERA_CC_IRQSTATUS_FE_IRQ \
  158. 0x00010000 // Frame End has occurred 0 Event
  159. // false "1 Event is true
  160. // (""pending"")" 0 Event status bit
  161. // unchanged 1 Event status bit is
  162. // reset
  163. #define CAMERA_CC_IRQSTATUS_FSP_ERR_IRQ \
  164. 0x00000800 // FSP code error 0 Event false "1
  165. // Event is true (""pending"")" 0
  166. // Event status bit unchanged 1
  167. // Event status bit is reset
  168. #define CAMERA_CC_IRQSTATUS_FW_ERR_IRQ \
  169. 0x00000400 // Frame Height Error 0 Event false
  170. // "1 Event is true (""pending"")" 0
  171. // Event status bit unchanged 1
  172. // Event status bit is reset
  173. #define CAMERA_CC_IRQSTATUS_FSC_ERR_IRQ \
  174. 0x00000200 // False Synchronization Code 0
  175. // Event false "1 Event is true
  176. // (""pending"")" 0 Event status bit
  177. // unchanged 1 Event status bit is
  178. // reset
  179. #define CAMERA_CC_IRQSTATUS_SSC_ERR_IRQ \
  180. 0x00000100 // Shifted Synchronization Code 0
  181. // Event false "1 Event is true
  182. // (""pending"")" 0 Event status bit
  183. // unchanged 1 Event status bit is
  184. // reset
  185. #define CAMERA_CC_IRQSTATUS_FIFO_NONEMPTY_IRQ \
  186. 0x00000010 // FIFO is not empty 0 Event false
  187. // "1 Event is true (""pending"")" 0
  188. // Event status bit unchanged 1
  189. // Event status bit is reset
  190. #define CAMERA_CC_IRQSTATUS_FIFO_FULL_IRQ \
  191. 0x00000008 // FIFO is full 0 Event false "1
  192. // Event is true (""pending"")" 0
  193. // Event status bit unchanged 1
  194. // Event status bit is reset
  195. #define CAMERA_CC_IRQSTATUS_FIFO_THR_IRQ \
  196. 0x00000004 // FIFO threshold has been reached
  197. // 0 Event false "1 Event is true
  198. // (""pending"")" 0 Event status bit
  199. // unchanged 1 Event status bit is
  200. // reset
  201. #define CAMERA_CC_IRQSTATUS_FIFO_OF_IRQ \
  202. 0x00000002 // FIFO overflow has occurred 0
  203. // Event false "1 Event is true
  204. // (""pending"")" 0 Event status bit
  205. // unchanged 1 Event status bit is
  206. // reset
  207. #define CAMERA_CC_IRQSTATUS_FIFO_UF_IRQ \
  208. 0x00000001 // FIFO underflow has occurred 0
  209. // Event false "1 Event is true
  210. // (""pending"")" 0 Event status bit
  211. // unchanged 1 Event status bit is
  212. // reset
  213. //******************************************************************************
  214. //
  215. // The following are defines for the bit fields in the
  216. // CAMERA_O_CC_IRQENABLE register.
  217. //
  218. //******************************************************************************
  219. #define CAMERA_CC_IRQENABLE_FS_IRQ_EN \
  220. 0x00080000 // Frame Start Interrupt Enable 0
  221. // Event is masked 1 Event generates
  222. // an interrupt when it occurs
  223. #define CAMERA_CC_IRQENABLE_LE_IRQ_EN \
  224. 0x00040000 // Line End Interrupt Enable 0
  225. // Event is masked 1 Event generates
  226. // an interrupt when it occurs
  227. #define CAMERA_CC_IRQENABLE_LS_IRQ_EN \
  228. 0x00020000 // Line Start Interrupt Enable 0
  229. // Event is masked 1 Event generates
  230. // an interrupt when it occurs
  231. #define CAMERA_CC_IRQENABLE_FE_IRQ_EN \
  232. 0x00010000 // Frame End Interrupt Enable 0
  233. // Event is masked 1 Event generates
  234. // an interrupt when it occurs
  235. #define CAMERA_CC_IRQENABLE_FSP_IRQ_EN \
  236. 0x00000800 // FSP code Interrupt Enable 0
  237. // Event is masked 1 Event generates
  238. // an interrupt when it occurs
  239. #define CAMERA_CC_IRQENABLE_FW_ERR_IRQ_EN \
  240. 0x00000400 // Frame Height Error Interrupt
  241. // Enable 0 Event is masked 1 Event
  242. // generates an interrupt when it
  243. // occurs
  244. #define CAMERA_CC_IRQENABLE_FSC_ERR_IRQ_EN \
  245. 0x00000200 // False Synchronization Code
  246. // Interrupt Enable 0 Event is
  247. // masked 1 Event generates an
  248. // interrupt when it occurs
  249. #define CAMERA_CC_IRQENABLE_SSC_ERR_IRQ_EN \
  250. 0x00000100 // False Synchronization Code
  251. // Interrupt Enable 0 Event is
  252. // masked 1 Event generates an
  253. // interrupt when it occurs
  254. #define CAMERA_CC_IRQENABLE_FIFO_NONEMPTY_IRQ_EN \
  255. 0x00000010 // FIFO Threshold Interrupt Enable
  256. // 0 Event is masked 1 Event
  257. // generates an interrupt when it
  258. // occurs
  259. #define CAMERA_CC_IRQENABLE_FIFO_FULL_IRQ_EN \
  260. 0x00000008 // FIFO Threshold Interrupt Enable
  261. // 0 Event is masked 1 Event
  262. // generates an interrupt when it
  263. // occurs
  264. #define CAMERA_CC_IRQENABLE_FIFO_THR_IRQ_EN \
  265. 0x00000004 // FIFO Threshold Interrupt Enable
  266. // 0 Event is masked 1 Event
  267. // generates an interrupt when it
  268. // occurs
  269. #define CAMERA_CC_IRQENABLE_FIFO_OF_IRQ_EN \
  270. 0x00000002 // FIFO Overflow Interrupt Enable 0
  271. // Event is masked 1 Event generates
  272. // an interrupt when it occurs
  273. #define CAMERA_CC_IRQENABLE_FIFO_UF_IRQ_EN \
  274. 0x00000001 // FIFO Underflow Interrupt Enable
  275. // 0 Event is masked 1 Event
  276. // generates an interrupt when it
  277. // occurs
  278. //******************************************************************************
  279. //
  280. // The following are defines for the bit fields in the CAMERA_O_CC_CTRL register.
  281. //
  282. //******************************************************************************
  283. #define CAMERA_CC_CTRL_CC_IF_SYNCHRO \
  284. 0x00080000 // Synchronize all camera sensor
  285. // inputs This must be set during
  286. // the configuration phase before
  287. // CC_EN set to '1'. This can be
  288. // used in very high frequency to
  289. // avoid dependancy to the IO
  290. // timings. 0 No synchro (most of
  291. // applications) 1 Synchro enabled
  292. // (should never be required)
  293. #define CAMERA_CC_CTRL_CC_RST 0x00040000 // Resets all the internal finite
  294. // states machines of the camera
  295. // core module - by writing a 1 to
  296. // this bit. must be applied when
  297. // CC_EN = 0 Reads returns 0
  298. #define CAMERA_CC_CTRL_CC_FRAME_TRIG \
  299. 0x00020000 // Set the modality in which CC_EN
  300. // works when a disabling of the
  301. // sensor camera core is wanted "If
  302. // CC_FRAME_TRIG = 1 by writing
  303. // ""0"" to CC_EN" the module is
  304. // disabled at the end of the frame
  305. // "If CC_FRAME_TRIG = 0 by writing
  306. // ""0"" to CC_EN" the module is
  307. // disabled immediately
  308. #define CAMERA_CC_CTRL_CC_EN 0x00010000 // Enables the sensor interface of
  309. // the camera core module "By
  310. // writing ""1"" to this field the
  311. // module is enabled." "By writing
  312. // ""0"" to this field the module is
  313. // disabled at" the end of the frame
  314. // if CC_FRAM_TRIG =1 and is
  315. // disabled immediately if
  316. // CC_FRAM_TRIG = 0
  317. #define CAMERA_CC_CTRL_NOBT_SYNCHRO \
  318. 0x00002000 // Enables to start at the
  319. // beginning of the frame or not in
  320. // NoBT 0 Acquisition starts when
  321. // Vertical synchro is high 1
  322. // Acquisition starts when Vertical
  323. // synchro goes from low to high
  324. // (beginning of the frame) -
  325. // Recommended.
  326. #define CAMERA_CC_CTRL_BT_CORRECT \
  327. 0x00001000 // Enables the correction within
  328. // the sync codes in BT mode 0
  329. // correction is not enabled 1
  330. // correction is enabled
  331. #define CAMERA_CC_CTRL_PAR_ORDERCAM \
  332. 0x00000800 // Enables swap between image-data
  333. // in parallel mode 0 swap is not
  334. // enabled 1 swap is enabled
  335. #define CAMERA_CC_CTRL_PAR_CLK_POL \
  336. 0x00000400 // Inverts the clock coming from
  337. // the sensor in parallel mode 0
  338. // clock not inverted - data sampled
  339. // on rising edge 1 clock inverted -
  340. // data sampled on falling edge
  341. #define CAMERA_CC_CTRL_NOBT_HS_POL \
  342. 0x00000200 // Sets the polarity of the
  343. // synchronization signals in NOBT
  344. // parallel mode 0 CAM_P_HS is
  345. // active high 1 CAM_P_HS is active
  346. // low
  347. #define CAMERA_CC_CTRL_NOBT_VS_POL \
  348. 0x00000100 // Sets the polarity of the
  349. // synchronization signals in NOBT
  350. // parallel mode 0 CAM_P_VS is
  351. // active high 1 CAM_P_VS is active
  352. // low
  353. #define CAMERA_CC_CTRL_PAR_MODE_M \
  354. 0x0000000E // Sets the Protocol Mode of the
  355. // Camera Core module in parallel
  356. // mode (when CCP_MODE = 0) """000""
  357. // Parallel NOBT 8-bit" """001""
  358. // Parallel NOBT 10-bit" """010""
  359. // Parallel NOBT 12-bit" """011""
  360. // reserved" """100"" Parallet BT
  361. // 8-bit" """101"" Parallel BT
  362. // 10-bit" """110"" reserved"
  363. // """111"" FIFO test mode. Refer to
  364. // Table 12 - FIFO Write and Read
  365. // access"
  366. #define CAMERA_CC_CTRL_PAR_MODE_S 1
  367. #define CAMERA_CC_CTRL_CCP_MODE 0x00000001 // Set the Camera Core in CCP mode
  368. // 0 CCP mode disabled 1 CCP mode
  369. // enabled
  370. //******************************************************************************
  371. //
  372. // The following are defines for the bit fields in the
  373. // CAMERA_O_CC_CTRL_DMA register.
  374. //
  375. //******************************************************************************
  376. #define CAMERA_CC_CTRL_DMA_DMA_EN \
  377. 0x00000100 // Sets the number of dma request
  378. // lines 0 DMA interface disabled
  379. // The DMA request line stays
  380. // inactive 1 DMA interface enabled
  381. // The DMA request line is
  382. // operational
  383. #define CAMERA_CC_CTRL_DMA_FIFO_THRESHOLD_M \
  384. 0x0000007F // Sets the threshold of the FIFO
  385. // the assertion of the dmarequest
  386. // line takes place when the
  387. // threshold is reached.
  388. // """0000000"" threshold set to 1"
  389. // """0000001"" threshold set to 2"
  390. // … """1111111"" threshold set to
  391. // 128"
  392. #define CAMERA_CC_CTRL_DMA_FIFO_THRESHOLD_S 0
  393. //******************************************************************************
  394. //
  395. // The following are defines for the bit fields in the
  396. // CAMERA_O_CC_CTRL_XCLK register.
  397. //
  398. //******************************************************************************
  399. #define CAMERA_CC_CTRL_XCLK_XCLK_DIV_M \
  400. 0x0000001F // Sets the clock divisor value for
  401. // CAM_XCLK generation. based on
  402. // CAM_MCK (value of CAM_MCLK is
  403. // 96MHz) """00000"" CAM_XCLK Stable
  404. // Low Level" Divider not enabled
  405. // """00001"" CAM_XCLK Stable High
  406. // Level" Divider not enabled from 2
  407. // to 30 CAM_XCLK = CAM_MCLK /
  408. // XCLK_DIV """11111"" Bypass -
  409. // CAM_XCLK = CAM_MCLK"
  410. #define CAMERA_CC_CTRL_XCLK_XCLK_DIV_S 0
  411. //******************************************************************************
  412. //
  413. // The following are defines for the bit fields in the
  414. // CAMERA_O_CC_FIFO_DATA register.
  415. //
  416. //******************************************************************************
  417. #define CAMERA_CC_FIFO_DATA_FIFO_DATA_M \
  418. 0xFFFFFFFF // Writes the 32-bit word into the
  419. // FIFO Reads the 32-bit word from
  420. // the FIFO
  421. #define CAMERA_CC_FIFO_DATA_FIFO_DATA_S 0
  422. //******************************************************************************
  423. //
  424. // The following are defines for the bit fields in the CAMERA_O_CC_TEST register.
  425. //
  426. //******************************************************************************
  427. #define CAMERA_CC_TEST_FIFO_RD_POINTER_M \
  428. 0xFF000000 // FIFO READ Pointer This field
  429. // shows the value of the FIFO read
  430. // pointer Expected value ranges
  431. // from 0 to 127
  432. #define CAMERA_CC_TEST_FIFO_RD_POINTER_S 24
  433. #define CAMERA_CC_TEST_FIFO_WR_POINTER_M \
  434. 0x00FF0000 // FIFO WRITE pointer This field
  435. // shows the value of the FIFO write
  436. // pointer Expected value ranges
  437. // from 0 to 127
  438. #define CAMERA_CC_TEST_FIFO_WR_POINTER_S 16
  439. #define CAMERA_CC_TEST_FIFO_LEVEL_M \
  440. 0x0000FF00 // FIFO level (how many 32-bit
  441. // words the FIFO contains) This
  442. // field shows the value of the FIFO
  443. // level and can assume values from
  444. // 0 to 128
  445. #define CAMERA_CC_TEST_FIFO_LEVEL_S 8
  446. #define CAMERA_CC_TEST_FIFO_LEVEL_PEAK_M \
  447. 0x000000FF // FIFO level peak This field shows
  448. // the max value of the FIFO level
  449. // and can assume values from 0 to
  450. // 128
  451. #define CAMERA_CC_TEST_FIFO_LEVEL_PEAK_S 0
  452. //******************************************************************************
  453. //
  454. // The following are defines for the bit fields in the
  455. // CAMERA_O_CC_GEN_PAR register.
  456. //
  457. //******************************************************************************
  458. #define CAMERA_CC_GEN_PAR_CC_FIFO_DEPTH_M \
  459. 0x00000007 // Camera Core FIFO DEPTH generic
  460. // parameter
  461. #define CAMERA_CC_GEN_PAR_CC_FIFO_DEPTH_S 0
  462. #endif // __HW_CAMERA_H__