dbx500-prcmu.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  1. /*
  2. * Copyright (C) ST Ericsson SA 2011
  3. *
  4. * License Terms: GNU General Public License v2
  5. *
  6. * STE Ux500 PRCMU API
  7. */
  8. #ifndef __MACH_PRCMU_H
  9. #define __MACH_PRCMU_H
  10. #include <linux/interrupt.h>
  11. #include <linux/notifier.h>
  12. #include <asm/mach-types.h>
  13. /* PRCMU Wakeup defines */
  14. enum prcmu_wakeup_index {
  15. PRCMU_WAKEUP_INDEX_RTC,
  16. PRCMU_WAKEUP_INDEX_RTT0,
  17. PRCMU_WAKEUP_INDEX_RTT1,
  18. PRCMU_WAKEUP_INDEX_HSI0,
  19. PRCMU_WAKEUP_INDEX_HSI1,
  20. PRCMU_WAKEUP_INDEX_USB,
  21. PRCMU_WAKEUP_INDEX_ABB,
  22. PRCMU_WAKEUP_INDEX_ABB_FIFO,
  23. PRCMU_WAKEUP_INDEX_ARM,
  24. PRCMU_WAKEUP_INDEX_CD_IRQ,
  25. NUM_PRCMU_WAKEUP_INDICES
  26. };
  27. #define PRCMU_WAKEUP(_name) (BIT(PRCMU_WAKEUP_INDEX_##_name))
  28. /* EPOD (power domain) IDs */
  29. /*
  30. * DB8500 EPODs
  31. * - EPOD_ID_SVAMMDSP: power domain for SVA MMDSP
  32. * - EPOD_ID_SVAPIPE: power domain for SVA pipe
  33. * - EPOD_ID_SIAMMDSP: power domain for SIA MMDSP
  34. * - EPOD_ID_SIAPIPE: power domain for SIA pipe
  35. * - EPOD_ID_SGA: power domain for SGA
  36. * - EPOD_ID_B2R2_MCDE: power domain for B2R2 and MCDE
  37. * - EPOD_ID_ESRAM12: power domain for ESRAM 1 and 2
  38. * - EPOD_ID_ESRAM34: power domain for ESRAM 3 and 4
  39. * - NUM_EPOD_ID: number of power domains
  40. *
  41. * TODO: These should be prefixed.
  42. */
  43. #define EPOD_ID_SVAMMDSP 0
  44. #define EPOD_ID_SVAPIPE 1
  45. #define EPOD_ID_SIAMMDSP 2
  46. #define EPOD_ID_SIAPIPE 3
  47. #define EPOD_ID_SGA 4
  48. #define EPOD_ID_B2R2_MCDE 5
  49. #define EPOD_ID_ESRAM12 6
  50. #define EPOD_ID_ESRAM34 7
  51. #define NUM_EPOD_ID 8
  52. /*
  53. * DB5500 EPODs
  54. */
  55. #define DB5500_EPOD_ID_BASE 0x0100
  56. #define DB5500_EPOD_ID_SGA (DB5500_EPOD_ID_BASE + 0)
  57. #define DB5500_EPOD_ID_HVA (DB5500_EPOD_ID_BASE + 1)
  58. #define DB5500_EPOD_ID_SIA (DB5500_EPOD_ID_BASE + 2)
  59. #define DB5500_EPOD_ID_DISP (DB5500_EPOD_ID_BASE + 3)
  60. #define DB5500_EPOD_ID_ESRAM12 (DB5500_EPOD_ID_BASE + 6)
  61. #define DB5500_NUM_EPOD_ID 7
  62. /*
  63. * state definition for EPOD (power domain)
  64. * - EPOD_STATE_NO_CHANGE: The EPOD should remain unchanged
  65. * - EPOD_STATE_OFF: The EPOD is switched off
  66. * - EPOD_STATE_RAMRET: The EPOD is switched off with its internal RAM in
  67. * retention
  68. * - EPOD_STATE_ON_CLK_OFF: The EPOD is switched on, clock is still off
  69. * - EPOD_STATE_ON: Same as above, but with clock enabled
  70. */
  71. #define EPOD_STATE_NO_CHANGE 0x00
  72. #define EPOD_STATE_OFF 0x01
  73. #define EPOD_STATE_RAMRET 0x02
  74. #define EPOD_STATE_ON_CLK_OFF 0x03
  75. #define EPOD_STATE_ON 0x04
  76. /*
  77. * CLKOUT sources
  78. */
  79. #define PRCMU_CLKSRC_CLK38M 0x00
  80. #define PRCMU_CLKSRC_ACLK 0x01
  81. #define PRCMU_CLKSRC_SYSCLK 0x02
  82. #define PRCMU_CLKSRC_LCDCLK 0x03
  83. #define PRCMU_CLKSRC_SDMMCCLK 0x04
  84. #define PRCMU_CLKSRC_TVCLK 0x05
  85. #define PRCMU_CLKSRC_TIMCLK 0x06
  86. #define PRCMU_CLKSRC_CLK009 0x07
  87. /* These are only valid for CLKOUT1: */
  88. #define PRCMU_CLKSRC_SIAMMDSPCLK 0x40
  89. #define PRCMU_CLKSRC_I2CCLK 0x41
  90. #define PRCMU_CLKSRC_MSP02CLK 0x42
  91. #define PRCMU_CLKSRC_ARMPLL_OBSCLK 0x43
  92. #define PRCMU_CLKSRC_HSIRXCLK 0x44
  93. #define PRCMU_CLKSRC_HSITXCLK 0x45
  94. #define PRCMU_CLKSRC_ARMCLKFIX 0x46
  95. #define PRCMU_CLKSRC_HDMICLK 0x47
  96. /*
  97. * Clock identifiers.
  98. */
  99. enum prcmu_clock {
  100. PRCMU_SGACLK,
  101. PRCMU_UARTCLK,
  102. PRCMU_MSP02CLK,
  103. PRCMU_MSP1CLK,
  104. PRCMU_I2CCLK,
  105. PRCMU_SDMMCCLK,
  106. PRCMU_SLIMCLK,
  107. PRCMU_PER1CLK,
  108. PRCMU_PER2CLK,
  109. PRCMU_PER3CLK,
  110. PRCMU_PER5CLK,
  111. PRCMU_PER6CLK,
  112. PRCMU_PER7CLK,
  113. PRCMU_LCDCLK,
  114. PRCMU_BMLCLK,
  115. PRCMU_HSITXCLK,
  116. PRCMU_HSIRXCLK,
  117. PRCMU_HDMICLK,
  118. PRCMU_APEATCLK,
  119. PRCMU_APETRACECLK,
  120. PRCMU_MCDECLK,
  121. PRCMU_IPI2CCLK,
  122. PRCMU_DSIALTCLK,
  123. PRCMU_DMACLK,
  124. PRCMU_B2R2CLK,
  125. PRCMU_TVCLK,
  126. PRCMU_SSPCLK,
  127. PRCMU_RNGCLK,
  128. PRCMU_UICCCLK,
  129. PRCMU_PWMCLK,
  130. PRCMU_IRDACLK,
  131. PRCMU_IRRCCLK,
  132. PRCMU_SIACLK,
  133. PRCMU_SVACLK,
  134. PRCMU_NUM_REG_CLOCKS,
  135. PRCMU_SYSCLK = PRCMU_NUM_REG_CLOCKS,
  136. PRCMU_TIMCLK,
  137. PRCMU_PLLSOC0,
  138. PRCMU_PLLSOC1,
  139. PRCMU_PLLDDR,
  140. };
  141. /**
  142. * enum ape_opp - APE OPP states definition
  143. * @APE_OPP_INIT:
  144. * @APE_NO_CHANGE: The APE operating point is unchanged
  145. * @APE_100_OPP: The new APE operating point is ape100opp
  146. * @APE_50_OPP: 50%
  147. */
  148. enum ape_opp {
  149. APE_OPP_INIT = 0x00,
  150. APE_NO_CHANGE = 0x01,
  151. APE_100_OPP = 0x02,
  152. APE_50_OPP = 0x03
  153. };
  154. /**
  155. * enum arm_opp - ARM OPP states definition
  156. * @ARM_OPP_INIT:
  157. * @ARM_NO_CHANGE: The ARM operating point is unchanged
  158. * @ARM_100_OPP: The new ARM operating point is arm100opp
  159. * @ARM_50_OPP: The new ARM operating point is arm50opp
  160. * @ARM_MAX_OPP: Operating point is "max" (more than 100)
  161. * @ARM_MAX_FREQ100OPP: Set max opp if available, else 100
  162. * @ARM_EXTCLK: The new ARM operating point is armExtClk
  163. */
  164. enum arm_opp {
  165. ARM_OPP_INIT = 0x00,
  166. ARM_NO_CHANGE = 0x01,
  167. ARM_100_OPP = 0x02,
  168. ARM_50_OPP = 0x03,
  169. ARM_MAX_OPP = 0x04,
  170. ARM_MAX_FREQ100OPP = 0x05,
  171. ARM_EXTCLK = 0x07
  172. };
  173. /**
  174. * enum ddr_opp - DDR OPP states definition
  175. * @DDR_100_OPP: The new DDR operating point is ddr100opp
  176. * @DDR_50_OPP: The new DDR operating point is ddr50opp
  177. * @DDR_25_OPP: The new DDR operating point is ddr25opp
  178. */
  179. enum ddr_opp {
  180. DDR_100_OPP = 0x00,
  181. DDR_50_OPP = 0x01,
  182. DDR_25_OPP = 0x02,
  183. };
  184. /*
  185. * Definitions for controlling ESRAM0 in deep sleep.
  186. */
  187. #define ESRAM0_DEEP_SLEEP_STATE_OFF 1
  188. #define ESRAM0_DEEP_SLEEP_STATE_RET 2
  189. /**
  190. * enum ddr_pwrst - DDR power states definition
  191. * @DDR_PWR_STATE_UNCHANGED: SDRAM and DDR controller state is unchanged
  192. * @DDR_PWR_STATE_ON:
  193. * @DDR_PWR_STATE_OFFLOWLAT:
  194. * @DDR_PWR_STATE_OFFHIGHLAT:
  195. */
  196. enum ddr_pwrst {
  197. DDR_PWR_STATE_UNCHANGED = 0x00,
  198. DDR_PWR_STATE_ON = 0x01,
  199. DDR_PWR_STATE_OFFLOWLAT = 0x02,
  200. DDR_PWR_STATE_OFFHIGHLAT = 0x03
  201. };
  202. #include <linux/mfd/db8500-prcmu.h>
  203. #include <linux/mfd/db5500-prcmu.h>
  204. #if defined(CONFIG_UX500_SOC_DB8500) || defined(CONFIG_UX500_SOC_DB5500)
  205. static inline void __init prcmu_early_init(void)
  206. {
  207. if (machine_is_u5500())
  208. return db5500_prcmu_early_init();
  209. else
  210. return db8500_prcmu_early_init();
  211. }
  212. static inline int prcmu_set_power_state(u8 state, bool keep_ulp_clk,
  213. bool keep_ap_pll)
  214. {
  215. if (machine_is_u5500())
  216. return db5500_prcmu_set_power_state(state, keep_ulp_clk,
  217. keep_ap_pll);
  218. else
  219. return db8500_prcmu_set_power_state(state, keep_ulp_clk,
  220. keep_ap_pll);
  221. }
  222. static inline int prcmu_set_epod(u16 epod_id, u8 epod_state)
  223. {
  224. if (machine_is_u5500())
  225. return -EINVAL;
  226. else
  227. return db8500_prcmu_set_epod(epod_id, epod_state);
  228. }
  229. static inline void prcmu_enable_wakeups(u32 wakeups)
  230. {
  231. if (machine_is_u5500())
  232. db5500_prcmu_enable_wakeups(wakeups);
  233. else
  234. db8500_prcmu_enable_wakeups(wakeups);
  235. }
  236. static inline void prcmu_disable_wakeups(void)
  237. {
  238. prcmu_enable_wakeups(0);
  239. }
  240. static inline void prcmu_config_abb_event_readout(u32 abb_events)
  241. {
  242. if (machine_is_u5500())
  243. db5500_prcmu_config_abb_event_readout(abb_events);
  244. else
  245. db8500_prcmu_config_abb_event_readout(abb_events);
  246. }
  247. static inline void prcmu_get_abb_event_buffer(void __iomem **buf)
  248. {
  249. if (machine_is_u5500())
  250. db5500_prcmu_get_abb_event_buffer(buf);
  251. else
  252. db8500_prcmu_get_abb_event_buffer(buf);
  253. }
  254. int prcmu_abb_read(u8 slave, u8 reg, u8 *value, u8 size);
  255. int prcmu_abb_write(u8 slave, u8 reg, u8 *value, u8 size);
  256. int prcmu_config_clkout(u8 clkout, u8 source, u8 div);
  257. static inline int prcmu_request_clock(u8 clock, bool enable)
  258. {
  259. if (machine_is_u5500())
  260. return db5500_prcmu_request_clock(clock, enable);
  261. else
  262. return db8500_prcmu_request_clock(clock, enable);
  263. }
  264. int prcmu_set_ape_opp(u8 opp);
  265. int prcmu_get_ape_opp(void);
  266. int prcmu_set_ddr_opp(u8 opp);
  267. int prcmu_get_ddr_opp(void);
  268. static inline int prcmu_set_arm_opp(u8 opp)
  269. {
  270. if (machine_is_u5500())
  271. return -EINVAL;
  272. else
  273. return db8500_prcmu_set_arm_opp(opp);
  274. }
  275. static inline int prcmu_get_arm_opp(void)
  276. {
  277. if (machine_is_u5500())
  278. return -EINVAL;
  279. else
  280. return db8500_prcmu_get_arm_opp();
  281. }
  282. static inline void prcmu_system_reset(u16 reset_code)
  283. {
  284. if (machine_is_u5500())
  285. return db5500_prcmu_system_reset(reset_code);
  286. else
  287. return db8500_prcmu_system_reset(reset_code);
  288. }
  289. static inline u16 prcmu_get_reset_code(void)
  290. {
  291. if (machine_is_u5500())
  292. return db5500_prcmu_get_reset_code();
  293. else
  294. return db8500_prcmu_get_reset_code();
  295. }
  296. void prcmu_ac_wake_req(void);
  297. void prcmu_ac_sleep_req(void);
  298. void prcmu_modem_reset(void);
  299. static inline bool prcmu_is_ac_wake_requested(void)
  300. {
  301. if (machine_is_u5500())
  302. return db5500_prcmu_is_ac_wake_requested();
  303. else
  304. return db8500_prcmu_is_ac_wake_requested();
  305. }
  306. static inline int prcmu_set_display_clocks(void)
  307. {
  308. if (machine_is_u5500())
  309. return db5500_prcmu_set_display_clocks();
  310. else
  311. return db8500_prcmu_set_display_clocks();
  312. }
  313. static inline int prcmu_disable_dsipll(void)
  314. {
  315. if (machine_is_u5500())
  316. return db5500_prcmu_disable_dsipll();
  317. else
  318. return db8500_prcmu_disable_dsipll();
  319. }
  320. static inline int prcmu_enable_dsipll(void)
  321. {
  322. if (machine_is_u5500())
  323. return db5500_prcmu_enable_dsipll();
  324. else
  325. return db8500_prcmu_enable_dsipll();
  326. }
  327. static inline int prcmu_config_esram0_deep_sleep(u8 state)
  328. {
  329. if (machine_is_u5500())
  330. return -EINVAL;
  331. else
  332. return db8500_prcmu_config_esram0_deep_sleep(state);
  333. }
  334. #else
  335. static inline void __init prcmu_early_init(void) {}
  336. static inline int prcmu_set_power_state(u8 state, bool keep_ulp_clk,
  337. bool keep_ap_pll)
  338. {
  339. return 0;
  340. }
  341. static inline int prcmu_set_epod(u16 epod_id, u8 epod_state)
  342. {
  343. return 0;
  344. }
  345. static inline void prcmu_enable_wakeups(u32 wakeups) {}
  346. static inline void prcmu_disable_wakeups(void) {}
  347. static inline int prcmu_abb_read(u8 slave, u8 reg, u8 *value, u8 size)
  348. {
  349. return -ENOSYS;
  350. }
  351. static inline int prcmu_abb_write(u8 slave, u8 reg, u8 *value, u8 size)
  352. {
  353. return -ENOSYS;
  354. }
  355. static inline int prcmu_config_clkout(u8 clkout, u8 source, u8 div)
  356. {
  357. return 0;
  358. }
  359. static inline int prcmu_request_clock(u8 clock, bool enable)
  360. {
  361. return 0;
  362. }
  363. static inline int prcmu_set_ape_opp(u8 opp)
  364. {
  365. return 0;
  366. }
  367. static inline int prcmu_get_ape_opp(void)
  368. {
  369. return APE_100_OPP;
  370. }
  371. static inline int prcmu_set_arm_opp(u8 opp)
  372. {
  373. return 0;
  374. }
  375. static inline int prcmu_get_arm_opp(void)
  376. {
  377. return ARM_100_OPP;
  378. }
  379. static inline int prcmu_set_ddr_opp(u8 opp)
  380. {
  381. return 0;
  382. }
  383. static inline int prcmu_get_ddr_opp(void)
  384. {
  385. return DDR_100_OPP;
  386. }
  387. static inline void prcmu_system_reset(u16 reset_code) {}
  388. static inline u16 prcmu_get_reset_code(void)
  389. {
  390. return 0;
  391. }
  392. static inline void prcmu_ac_wake_req(void) {}
  393. static inline void prcmu_ac_sleep_req(void) {}
  394. static inline void prcmu_modem_reset(void) {}
  395. static inline bool prcmu_is_ac_wake_requested(void)
  396. {
  397. return false;
  398. }
  399. static inline int prcmu_set_display_clocks(void)
  400. {
  401. return 0;
  402. }
  403. static inline int prcmu_disable_dsipll(void)
  404. {
  405. return 0;
  406. }
  407. static inline int prcmu_enable_dsipll(void)
  408. {
  409. return 0;
  410. }
  411. static inline int prcmu_config_esram0_deep_sleep(u8 state)
  412. {
  413. return 0;
  414. }
  415. static inline void prcmu_config_abb_event_readout(u32 abb_events) {}
  416. static inline void prcmu_get_abb_event_buffer(void __iomem **buf)
  417. {
  418. *buf = NULL;
  419. }
  420. #endif
  421. /* PRCMU QoS APE OPP class */
  422. #define PRCMU_QOS_APE_OPP 1
  423. #define PRCMU_QOS_DDR_OPP 2
  424. #define PRCMU_QOS_DEFAULT_VALUE -1
  425. #ifdef CONFIG_UX500_PRCMU_QOS_POWER
  426. unsigned long prcmu_qos_get_cpufreq_opp_delay(void);
  427. void prcmu_qos_set_cpufreq_opp_delay(unsigned long);
  428. void prcmu_qos_force_opp(int, s32);
  429. int prcmu_qos_requirement(int pm_qos_class);
  430. int prcmu_qos_add_requirement(int pm_qos_class, char *name, s32 value);
  431. int prcmu_qos_update_requirement(int pm_qos_class, char *name, s32 new_value);
  432. void prcmu_qos_remove_requirement(int pm_qos_class, char *name);
  433. int prcmu_qos_add_notifier(int prcmu_qos_class,
  434. struct notifier_block *notifier);
  435. int prcmu_qos_remove_notifier(int prcmu_qos_class,
  436. struct notifier_block *notifier);
  437. #else
  438. static inline unsigned long prcmu_qos_get_cpufreq_opp_delay(void)
  439. {
  440. return 0;
  441. }
  442. static inline void prcmu_qos_set_cpufreq_opp_delay(unsigned long n) {}
  443. static inline void prcmu_qos_force_opp(int prcmu_qos_class, s32 i) {}
  444. static inline int prcmu_qos_requirement(int prcmu_qos_class)
  445. {
  446. return 0;
  447. }
  448. static inline int prcmu_qos_add_requirement(int prcmu_qos_class,
  449. char *name, s32 value)
  450. {
  451. return 0;
  452. }
  453. static inline int prcmu_qos_update_requirement(int prcmu_qos_class,
  454. char *name, s32 new_value)
  455. {
  456. return 0;
  457. }
  458. static inline void prcmu_qos_remove_requirement(int prcmu_qos_class, char *name)
  459. {
  460. }
  461. static inline int prcmu_qos_add_notifier(int prcmu_qos_class,
  462. struct notifier_block *notifier)
  463. {
  464. return 0;
  465. }
  466. static inline int prcmu_qos_remove_notifier(int prcmu_qos_class,
  467. struct notifier_block *notifier)
  468. {
  469. return 0;
  470. }
  471. #endif
  472. #endif /* __MACH_PRCMU_H */