/kernel/2.6.32_froyo_photon_nightly/arch/arm/mach-bcmring/include/mach/csp/cap_inline.h

http://photon-android.googlecode.com/ · C++ Header · 409 lines · 308 code · 35 blank · 66 comment · 103 complexity · c46a2b11f796d8c331d0ec7cada60360 MD5 · raw file

  1. /*****************************************************************************
  2. * Copyright 2009 Broadcom Corporation. All rights reserved.
  3. *
  4. * Unless you and Broadcom execute a separate written software license
  5. * agreement governing use of this software, this software is licensed to you
  6. * under the terms of the GNU General Public License version 2, available at
  7. * http://www.broadcom.com/licenses/GPLv2.php (the "GPL").
  8. *
  9. * Notwithstanding the above, under no circumstances may you combine this
  10. * software in any way with any other Broadcom software provided under a
  11. * license other than the GPL, without Broadcom's express prior written
  12. * consent.
  13. *****************************************************************************/
  14. #ifndef CAP_INLINE_H
  15. #define CAP_INLINE_H
  16. /* ---- Include Files ---------------------------------------------------- */
  17. #include <mach/csp/cap.h>
  18. #include <cfg_global.h>
  19. /* ---- Public Constants and Types --------------------------------------- */
  20. #define CAP_CONFIG0_VPM_DIS 0x00000001
  21. #define CAP_CONFIG0_ETH_PHY0_DIS 0x00000002
  22. #define CAP_CONFIG0_ETH_PHY1_DIS 0x00000004
  23. #define CAP_CONFIG0_ETH_GMII0_DIS 0x00000008
  24. #define CAP_CONFIG0_ETH_GMII1_DIS 0x00000010
  25. #define CAP_CONFIG0_ETH_SGMII0_DIS 0x00000020
  26. #define CAP_CONFIG0_ETH_SGMII1_DIS 0x00000040
  27. #define CAP_CONFIG0_USB0_DIS 0x00000080
  28. #define CAP_CONFIG0_USB1_DIS 0x00000100
  29. #define CAP_CONFIG0_TSC_DIS 0x00000200
  30. #define CAP_CONFIG0_EHSS0_DIS 0x00000400
  31. #define CAP_CONFIG0_EHSS1_DIS 0x00000800
  32. #define CAP_CONFIG0_SDIO0_DIS 0x00001000
  33. #define CAP_CONFIG0_SDIO1_DIS 0x00002000
  34. #define CAP_CONFIG0_UARTB_DIS 0x00004000
  35. #define CAP_CONFIG0_KEYPAD_DIS 0x00008000
  36. #define CAP_CONFIG0_CLCD_DIS 0x00010000
  37. #define CAP_CONFIG0_GE_DIS 0x00020000
  38. #define CAP_CONFIG0_LEDM_DIS 0x00040000
  39. #define CAP_CONFIG0_BBL_DIS 0x00080000
  40. #define CAP_CONFIG0_VDEC_DIS 0x00100000
  41. #define CAP_CONFIG0_PIF_DIS 0x00200000
  42. #define CAP_CONFIG0_RESERVED1_DIS 0x00400000
  43. #define CAP_CONFIG0_RESERVED2_DIS 0x00800000
  44. #define CAP_CONFIG1_APMA_DIS 0x00000001
  45. #define CAP_CONFIG1_APMB_DIS 0x00000002
  46. #define CAP_CONFIG1_APMC_DIS 0x00000004
  47. #define CAP_CONFIG1_CLCD_RES_MASK 0x00000600
  48. #define CAP_CONFIG1_CLCD_RES_SHIFT 9
  49. #define CAP_CONFIG1_CLCD_RES_WVGA (CAP_LCD_WVGA << CAP_CONFIG1_CLCD_RES_SHIFT)
  50. #define CAP_CONFIG1_CLCD_RES_VGA (CAP_LCD_VGA << CAP_CONFIG1_CLCD_RES_SHIFT)
  51. #define CAP_CONFIG1_CLCD_RES_WQVGA (CAP_LCD_WQVGA << CAP_CONFIG1_CLCD_RES_SHIFT)
  52. #define CAP_CONFIG1_CLCD_RES_QVGA (CAP_LCD_QVGA << CAP_CONFIG1_CLCD_RES_SHIFT)
  53. #define CAP_CONFIG2_SPU_DIS 0x00000010
  54. #define CAP_CONFIG2_PKA_DIS 0x00000020
  55. #define CAP_CONFIG2_RNG_DIS 0x00000080
  56. #if (CFG_GLOBAL_CHIP == BCM11107)
  57. #define capConfig0 0
  58. #define capConfig1 CAP_CONFIG1_CLCD_RES_WVGA
  59. #define capConfig2 0
  60. #define CAP_APM_MAX_NUM_CHANS 3
  61. #elif (CFG_GLOBAL_CHIP == FPGA11107)
  62. #define capConfig0 0
  63. #define capConfig1 CAP_CONFIG1_CLCD_RES_WVGA
  64. #define capConfig2 0
  65. #define CAP_APM_MAX_NUM_CHANS 3
  66. #elif (CFG_GLOBAL_CHIP == BCM11109)
  67. #define capConfig0 (CAP_CONFIG0_USB1_DIS | CAP_CONFIG0_EHSS1_DIS | CAP_CONFIG0_SDIO1_DIS | CAP_CONFIG0_GE_DIS | CAP_CONFIG0_BBL_DIS | CAP_CONFIG0_VDEC_DIS)
  68. #define capConfig1 (CAP_CONFIG1_APMC_DIS | CAP_CONFIG1_CLCD_RES_WQVGA)
  69. #define capConfig2 (CAP_CONFIG2_SPU_DIS | CAP_CONFIG2_PKA_DIS)
  70. #define CAP_APM_MAX_NUM_CHANS 2
  71. #elif (CFG_GLOBAL_CHIP == BCM11170)
  72. #define capConfig0 (CAP_CONFIG0_ETH_GMII0_DIS | CAP_CONFIG0_ETH_GMII1_DIS | CAP_CONFIG0_USB0_DIS | CAP_CONFIG0_USB1_DIS | CAP_CONFIG0_TSC_DIS | CAP_CONFIG0_EHSS1_DIS | CAP_CONFIG0_SDIO0_DIS | CAP_CONFIG0_SDIO1_DIS | CAP_CONFIG0_UARTB_DIS | CAP_CONFIG0_CLCD_DIS | CAP_CONFIG0_GE_DIS | CAP_CONFIG0_BBL_DIS | CAP_CONFIG0_VDEC_DIS)
  73. #define capConfig1 (CAP_CONFIG1_APMC_DIS | CAP_CONFIG1_CLCD_RES_WQVGA)
  74. #define capConfig2 (CAP_CONFIG2_SPU_DIS | CAP_CONFIG2_PKA_DIS)
  75. #define CAP_APM_MAX_NUM_CHANS 2
  76. #elif (CFG_GLOBAL_CHIP == BCM11110)
  77. #define capConfig0 (CAP_CONFIG0_USB1_DIS | CAP_CONFIG0_TSC_DIS | CAP_CONFIG0_EHSS1_DIS | CAP_CONFIG0_SDIO0_DIS | CAP_CONFIG0_SDIO1_DIS | CAP_CONFIG0_UARTB_DIS | CAP_CONFIG0_GE_DIS | CAP_CONFIG0_BBL_DIS | CAP_CONFIG0_VDEC_DIS)
  78. #define capConfig1 CAP_CONFIG1_APMC_DIS
  79. #define capConfig2 (CAP_CONFIG2_SPU_DIS | CAP_CONFIG2_PKA_DIS)
  80. #define CAP_APM_MAX_NUM_CHANS 2
  81. #elif (CFG_GLOBAL_CHIP == BCM11211)
  82. #define capConfig0 (CAP_CONFIG0_ETH_PHY0_DIS | CAP_CONFIG0_ETH_GMII0_DIS | CAP_CONFIG0_ETH_GMII1_DIS | CAP_CONFIG0_ETH_SGMII0_DIS | CAP_CONFIG0_ETH_SGMII1_DIS | CAP_CONFIG0_CLCD_DIS)
  83. #define capConfig1 CAP_CONFIG1_APMC_DIS
  84. #define capConfig2 0
  85. #define CAP_APM_MAX_NUM_CHANS 2
  86. #else
  87. #error CFG_GLOBAL_CHIP type capabilities not defined
  88. #endif
  89. #if ((CFG_GLOBAL_CHIP == BCM11107) || (CFG_GLOBAL_CHIP == FPGA11107))
  90. #define CAP_HW_CFG_ARM_CLK_HZ 500000000
  91. #elif ((CFG_GLOBAL_CHIP == BCM11109) || (CFG_GLOBAL_CHIP == BCM11170) || (CFG_GLOBAL_CHIP == BCM11110))
  92. #define CAP_HW_CFG_ARM_CLK_HZ 300000000
  93. #elif (CFG_GLOBAL_CHIP == BCM11211)
  94. #define CAP_HW_CFG_ARM_CLK_HZ 666666666
  95. #else
  96. #error CFG_GLOBAL_CHIP type capabilities not defined
  97. #endif
  98. #if ((CFG_GLOBAL_CHIP == BCM11107) || (CFG_GLOBAL_CHIP == BCM11211) || (CFG_GLOBAL_CHIP == FPGA11107))
  99. #define CAP_HW_CFG_VPM_CLK_HZ 333333333
  100. #elif ((CFG_GLOBAL_CHIP == BCM11109) || (CFG_GLOBAL_CHIP == BCM11170) || (CFG_GLOBAL_CHIP == BCM11110))
  101. #define CAP_HW_CFG_VPM_CLK_HZ 200000000
  102. #else
  103. #error CFG_GLOBAL_CHIP type capabilities not defined
  104. #endif
  105. /* ---- Public Variable Externs ------------------------------------------ */
  106. /* ---- Public Function Prototypes --------------------------------------- */
  107. /****************************************************************************
  108. * cap_isPresent -
  109. *
  110. * PURPOSE:
  111. * Determines if the chip has a certain capability present
  112. *
  113. * PARAMETERS:
  114. * capability - type of capability to determine if present
  115. *
  116. * RETURNS:
  117. * CAP_PRESENT or CAP_NOT_PRESENT
  118. ****************************************************************************/
  119. static inline CAP_RC_T cap_isPresent(CAP_CAPABILITY_T capability, int index)
  120. {
  121. CAP_RC_T returnVal = CAP_NOT_PRESENT;
  122. switch (capability) {
  123. case CAP_VPM:
  124. {
  125. if (!(capConfig0 & CAP_CONFIG0_VPM_DIS)) {
  126. returnVal = CAP_PRESENT;
  127. }
  128. }
  129. break;
  130. case CAP_ETH_PHY:
  131. {
  132. if ((index == 0)
  133. && (!(capConfig0 & CAP_CONFIG0_ETH_PHY0_DIS))) {
  134. returnVal = CAP_PRESENT;
  135. }
  136. if ((index == 1)
  137. && (!(capConfig0 & CAP_CONFIG0_ETH_PHY1_DIS))) {
  138. returnVal = CAP_PRESENT;
  139. }
  140. }
  141. break;
  142. case CAP_ETH_GMII:
  143. {
  144. if ((index == 0)
  145. && (!(capConfig0 & CAP_CONFIG0_ETH_GMII0_DIS))) {
  146. returnVal = CAP_PRESENT;
  147. }
  148. if ((index == 1)
  149. && (!(capConfig0 & CAP_CONFIG0_ETH_GMII1_DIS))) {
  150. returnVal = CAP_PRESENT;
  151. }
  152. }
  153. break;
  154. case CAP_ETH_SGMII:
  155. {
  156. if ((index == 0)
  157. && (!(capConfig0 & CAP_CONFIG0_ETH_SGMII0_DIS))) {
  158. returnVal = CAP_PRESENT;
  159. }
  160. if ((index == 1)
  161. && (!(capConfig0 & CAP_CONFIG0_ETH_SGMII1_DIS))) {
  162. returnVal = CAP_PRESENT;
  163. }
  164. }
  165. break;
  166. case CAP_USB:
  167. {
  168. if ((index == 0)
  169. && (!(capConfig0 & CAP_CONFIG0_USB0_DIS))) {
  170. returnVal = CAP_PRESENT;
  171. }
  172. if ((index == 1)
  173. && (!(capConfig0 & CAP_CONFIG0_USB1_DIS))) {
  174. returnVal = CAP_PRESENT;
  175. }
  176. }
  177. break;
  178. case CAP_TSC:
  179. {
  180. if (!(capConfig0 & CAP_CONFIG0_TSC_DIS)) {
  181. returnVal = CAP_PRESENT;
  182. }
  183. }
  184. break;
  185. case CAP_EHSS:
  186. {
  187. if ((index == 0)
  188. && (!(capConfig0 & CAP_CONFIG0_EHSS0_DIS))) {
  189. returnVal = CAP_PRESENT;
  190. }
  191. if ((index == 1)
  192. && (!(capConfig0 & CAP_CONFIG0_EHSS1_DIS))) {
  193. returnVal = CAP_PRESENT;
  194. }
  195. }
  196. break;
  197. case CAP_SDIO:
  198. {
  199. if ((index == 0)
  200. && (!(capConfig0 & CAP_CONFIG0_SDIO0_DIS))) {
  201. returnVal = CAP_PRESENT;
  202. }
  203. if ((index == 1)
  204. && (!(capConfig0 & CAP_CONFIG0_SDIO1_DIS))) {
  205. returnVal = CAP_PRESENT;
  206. }
  207. }
  208. break;
  209. case CAP_UARTB:
  210. {
  211. if (!(capConfig0 & CAP_CONFIG0_UARTB_DIS)) {
  212. returnVal = CAP_PRESENT;
  213. }
  214. }
  215. break;
  216. case CAP_KEYPAD:
  217. {
  218. if (!(capConfig0 & CAP_CONFIG0_KEYPAD_DIS)) {
  219. returnVal = CAP_PRESENT;
  220. }
  221. }
  222. break;
  223. case CAP_CLCD:
  224. {
  225. if (!(capConfig0 & CAP_CONFIG0_CLCD_DIS)) {
  226. returnVal = CAP_PRESENT;
  227. }
  228. }
  229. break;
  230. case CAP_GE:
  231. {
  232. if (!(capConfig0 & CAP_CONFIG0_GE_DIS)) {
  233. returnVal = CAP_PRESENT;
  234. }
  235. }
  236. break;
  237. case CAP_LEDM:
  238. {
  239. if (!(capConfig0 & CAP_CONFIG0_LEDM_DIS)) {
  240. returnVal = CAP_PRESENT;
  241. }
  242. }
  243. break;
  244. case CAP_BBL:
  245. {
  246. if (!(capConfig0 & CAP_CONFIG0_BBL_DIS)) {
  247. returnVal = CAP_PRESENT;
  248. }
  249. }
  250. break;
  251. case CAP_VDEC:
  252. {
  253. if (!(capConfig0 & CAP_CONFIG0_VDEC_DIS)) {
  254. returnVal = CAP_PRESENT;
  255. }
  256. }
  257. break;
  258. case CAP_PIF:
  259. {
  260. if (!(capConfig0 & CAP_CONFIG0_PIF_DIS)) {
  261. returnVal = CAP_PRESENT;
  262. }
  263. }
  264. break;
  265. case CAP_APM:
  266. {
  267. if ((index == 0)
  268. && (!(capConfig1 & CAP_CONFIG1_APMA_DIS))) {
  269. returnVal = CAP_PRESENT;
  270. }
  271. if ((index == 1)
  272. && (!(capConfig1 & CAP_CONFIG1_APMB_DIS))) {
  273. returnVal = CAP_PRESENT;
  274. }
  275. if ((index == 2)
  276. && (!(capConfig1 & CAP_CONFIG1_APMC_DIS))) {
  277. returnVal = CAP_PRESENT;
  278. }
  279. }
  280. break;
  281. case CAP_SPU:
  282. {
  283. if (!(capConfig2 & CAP_CONFIG2_SPU_DIS)) {
  284. returnVal = CAP_PRESENT;
  285. }
  286. }
  287. break;
  288. case CAP_PKA:
  289. {
  290. if (!(capConfig2 & CAP_CONFIG2_PKA_DIS)) {
  291. returnVal = CAP_PRESENT;
  292. }
  293. }
  294. break;
  295. case CAP_RNG:
  296. {
  297. if (!(capConfig2 & CAP_CONFIG2_RNG_DIS)) {
  298. returnVal = CAP_PRESENT;
  299. }
  300. }
  301. break;
  302. default:
  303. {
  304. }
  305. break;
  306. }
  307. return returnVal;
  308. }
  309. /****************************************************************************
  310. * cap_getMaxArmSpeedHz -
  311. *
  312. * PURPOSE:
  313. * Determines the maximum speed of the ARM CPU
  314. *
  315. * PARAMETERS:
  316. * none
  317. *
  318. * RETURNS:
  319. * clock speed in Hz that the ARM processor is able to run at
  320. ****************************************************************************/
  321. static inline uint32_t cap_getMaxArmSpeedHz(void)
  322. {
  323. #if ((CFG_GLOBAL_CHIP == BCM11107) || (CFG_GLOBAL_CHIP == FPGA11107))
  324. return 500000000;
  325. #elif ((CFG_GLOBAL_CHIP == BCM11109) || (CFG_GLOBAL_CHIP == BCM11170) || (CFG_GLOBAL_CHIP == BCM11110))
  326. return 300000000;
  327. #elif (CFG_GLOBAL_CHIP == BCM11211)
  328. return 666666666;
  329. #else
  330. #error CFG_GLOBAL_CHIP type capabilities not defined
  331. #endif
  332. }
  333. /****************************************************************************
  334. * cap_getMaxVpmSpeedHz -
  335. *
  336. * PURPOSE:
  337. * Determines the maximum speed of the VPM
  338. *
  339. * PARAMETERS:
  340. * none
  341. *
  342. * RETURNS:
  343. * clock speed in Hz that the VPM is able to run at
  344. ****************************************************************************/
  345. static inline uint32_t cap_getMaxVpmSpeedHz(void)
  346. {
  347. #if ((CFG_GLOBAL_CHIP == BCM11107) || (CFG_GLOBAL_CHIP == BCM11211) || (CFG_GLOBAL_CHIP == FPGA11107))
  348. return 333333333;
  349. #elif ((CFG_GLOBAL_CHIP == BCM11109) || (CFG_GLOBAL_CHIP == BCM11170) || (CFG_GLOBAL_CHIP == BCM11110))
  350. return 200000000;
  351. #else
  352. #error CFG_GLOBAL_CHIP type capabilities not defined
  353. #endif
  354. }
  355. /****************************************************************************
  356. * cap_getMaxLcdRes -
  357. *
  358. * PURPOSE:
  359. * Determines the maximum LCD resolution capabilities
  360. *
  361. * PARAMETERS:
  362. * none
  363. *
  364. * RETURNS:
  365. * CAP_LCD_WVGA, CAP_LCD_VGA, CAP_LCD_WQVGA or CAP_LCD_QVGA
  366. *
  367. ****************************************************************************/
  368. static inline CAP_LCD_RES_T cap_getMaxLcdRes(void)
  369. {
  370. return (CAP_LCD_RES_T)
  371. ((capConfig1 & CAP_CONFIG1_CLCD_RES_MASK) >>
  372. CAP_CONFIG1_CLCD_RES_SHIFT);
  373. }
  374. #endif