dbx500-prcmu.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) ST Ericsson SA 2011
  4. *
  5. * STE Ux500 PRCMU API
  6. */
  7. #ifndef __MACH_PRCMU_H
  8. #define __MACH_PRCMU_H
  9. #include <linux/interrupt.h>
  10. #include <linux/notifier.h>
  11. #include <linux/err.h>
  12. #include <dt-bindings/mfd/dbx500-prcmu.h> /* For clock identifiers */
  13. /* Offset for the firmware version within the TCPM */
  14. #define DB8500_PRCMU_FW_VERSION_OFFSET 0xA4
  15. #define DBX540_PRCMU_FW_VERSION_OFFSET 0xA8
  16. /* PRCMU Wakeup defines */
  17. enum prcmu_wakeup_index {
  18. PRCMU_WAKEUP_INDEX_RTC,
  19. PRCMU_WAKEUP_INDEX_RTT0,
  20. PRCMU_WAKEUP_INDEX_RTT1,
  21. PRCMU_WAKEUP_INDEX_HSI0,
  22. PRCMU_WAKEUP_INDEX_HSI1,
  23. PRCMU_WAKEUP_INDEX_USB,
  24. PRCMU_WAKEUP_INDEX_ABB,
  25. PRCMU_WAKEUP_INDEX_ABB_FIFO,
  26. PRCMU_WAKEUP_INDEX_ARM,
  27. PRCMU_WAKEUP_INDEX_CD_IRQ,
  28. NUM_PRCMU_WAKEUP_INDICES
  29. };
  30. #define PRCMU_WAKEUP(_name) (BIT(PRCMU_WAKEUP_INDEX_##_name))
  31. /* EPOD (power domain) IDs */
  32. /*
  33. * DB8500 EPODs
  34. * - EPOD_ID_SVAMMDSP: power domain for SVA MMDSP
  35. * - EPOD_ID_SVAPIPE: power domain for SVA pipe
  36. * - EPOD_ID_SIAMMDSP: power domain for SIA MMDSP
  37. * - EPOD_ID_SIAPIPE: power domain for SIA pipe
  38. * - EPOD_ID_SGA: power domain for SGA
  39. * - EPOD_ID_B2R2_MCDE: power domain for B2R2 and MCDE
  40. * - EPOD_ID_ESRAM12: power domain for ESRAM 1 and 2
  41. * - EPOD_ID_ESRAM34: power domain for ESRAM 3 and 4
  42. * - NUM_EPOD_ID: number of power domains
  43. *
  44. * TODO: These should be prefixed.
  45. */
  46. #define EPOD_ID_SVAMMDSP 0
  47. #define EPOD_ID_SVAPIPE 1
  48. #define EPOD_ID_SIAMMDSP 2
  49. #define EPOD_ID_SIAPIPE 3
  50. #define EPOD_ID_SGA 4
  51. #define EPOD_ID_B2R2_MCDE 5
  52. #define EPOD_ID_ESRAM12 6
  53. #define EPOD_ID_ESRAM34 7
  54. #define NUM_EPOD_ID 8
  55. /*
  56. * state definition for EPOD (power domain)
  57. * - EPOD_STATE_NO_CHANGE: The EPOD should remain unchanged
  58. * - EPOD_STATE_OFF: The EPOD is switched off
  59. * - EPOD_STATE_RAMRET: The EPOD is switched off with its internal RAM in
  60. * retention
  61. * - EPOD_STATE_ON_CLK_OFF: The EPOD is switched on, clock is still off
  62. * - EPOD_STATE_ON: Same as above, but with clock enabled
  63. */
  64. #define EPOD_STATE_NO_CHANGE 0x00
  65. #define EPOD_STATE_OFF 0x01
  66. #define EPOD_STATE_RAMRET 0x02
  67. #define EPOD_STATE_ON_CLK_OFF 0x03
  68. #define EPOD_STATE_ON 0x04
  69. /*
  70. * CLKOUT sources
  71. */
  72. #define PRCMU_CLKSRC_CLK38M 0x00
  73. #define PRCMU_CLKSRC_ACLK 0x01
  74. #define PRCMU_CLKSRC_SYSCLK 0x02
  75. #define PRCMU_CLKSRC_LCDCLK 0x03
  76. #define PRCMU_CLKSRC_SDMMCCLK 0x04
  77. #define PRCMU_CLKSRC_TVCLK 0x05
  78. #define PRCMU_CLKSRC_TIMCLK 0x06
  79. #define PRCMU_CLKSRC_CLK009 0x07
  80. /* These are only valid for CLKOUT1: */
  81. #define PRCMU_CLKSRC_SIAMMDSPCLK 0x40
  82. #define PRCMU_CLKSRC_I2CCLK 0x41
  83. #define PRCMU_CLKSRC_MSP02CLK 0x42
  84. #define PRCMU_CLKSRC_ARMPLL_OBSCLK 0x43
  85. #define PRCMU_CLKSRC_HSIRXCLK 0x44
  86. #define PRCMU_CLKSRC_HSITXCLK 0x45
  87. #define PRCMU_CLKSRC_ARMCLKFIX 0x46
  88. #define PRCMU_CLKSRC_HDMICLK 0x47
  89. /**
  90. * enum prcmu_wdog_id - PRCMU watchdog IDs
  91. * @PRCMU_WDOG_ALL: use all timers
  92. * @PRCMU_WDOG_CPU1: use first CPU timer only
  93. * @PRCMU_WDOG_CPU2: use second CPU timer conly
  94. */
  95. enum prcmu_wdog_id {
  96. PRCMU_WDOG_ALL = 0x00,
  97. PRCMU_WDOG_CPU1 = 0x01,
  98. PRCMU_WDOG_CPU2 = 0x02,
  99. };
  100. /**
  101. * enum ape_opp - APE OPP states definition
  102. * @APE_OPP_INIT:
  103. * @APE_NO_CHANGE: The APE operating point is unchanged
  104. * @APE_100_OPP: The new APE operating point is ape100opp
  105. * @APE_50_OPP: 50%
  106. * @APE_50_PARTLY_25_OPP: 50%, except some clocks at 25%.
  107. */
  108. enum ape_opp {
  109. APE_OPP_INIT = 0x00,
  110. APE_NO_CHANGE = 0x01,
  111. APE_100_OPP = 0x02,
  112. APE_50_OPP = 0x03,
  113. APE_50_PARTLY_25_OPP = 0xFF,
  114. };
  115. /**
  116. * enum arm_opp - ARM OPP states definition
  117. * @ARM_OPP_INIT:
  118. * @ARM_NO_CHANGE: The ARM operating point is unchanged
  119. * @ARM_100_OPP: The new ARM operating point is arm100opp
  120. * @ARM_50_OPP: The new ARM operating point is arm50opp
  121. * @ARM_MAX_OPP: Operating point is "max" (more than 100)
  122. * @ARM_MAX_FREQ100OPP: Set max opp if available, else 100
  123. * @ARM_EXTCLK: The new ARM operating point is armExtClk
  124. */
  125. enum arm_opp {
  126. ARM_OPP_INIT = 0x00,
  127. ARM_NO_CHANGE = 0x01,
  128. ARM_100_OPP = 0x02,
  129. ARM_50_OPP = 0x03,
  130. ARM_MAX_OPP = 0x04,
  131. ARM_MAX_FREQ100OPP = 0x05,
  132. ARM_EXTCLK = 0x07
  133. };
  134. /**
  135. * enum ddr_opp - DDR OPP states definition
  136. * @DDR_100_OPP: The new DDR operating point is ddr100opp
  137. * @DDR_50_OPP: The new DDR operating point is ddr50opp
  138. * @DDR_25_OPP: The new DDR operating point is ddr25opp
  139. */
  140. enum ddr_opp {
  141. DDR_100_OPP = 0x00,
  142. DDR_50_OPP = 0x01,
  143. DDR_25_OPP = 0x02,
  144. };
  145. /*
  146. * Definitions for controlling ESRAM0 in deep sleep.
  147. */
  148. #define ESRAM0_DEEP_SLEEP_STATE_OFF 1
  149. #define ESRAM0_DEEP_SLEEP_STATE_RET 2
  150. /**
  151. * enum ddr_pwrst - DDR power states definition
  152. * @DDR_PWR_STATE_UNCHANGED: SDRAM and DDR controller state is unchanged
  153. * @DDR_PWR_STATE_ON:
  154. * @DDR_PWR_STATE_OFFLOWLAT:
  155. * @DDR_PWR_STATE_OFFHIGHLAT:
  156. */
  157. enum ddr_pwrst {
  158. DDR_PWR_STATE_UNCHANGED = 0x00,
  159. DDR_PWR_STATE_ON = 0x01,
  160. DDR_PWR_STATE_OFFLOWLAT = 0x02,
  161. DDR_PWR_STATE_OFFHIGHLAT = 0x03
  162. };
  163. #define DB8500_PRCMU_LEGACY_OFFSET 0xDD4
  164. #define PRCMU_FW_PROJECT_U8500 2
  165. #define PRCMU_FW_PROJECT_U8400 3
  166. #define PRCMU_FW_PROJECT_U9500 4 /* Customer specific */
  167. #define PRCMU_FW_PROJECT_U8500_MBB 5
  168. #define PRCMU_FW_PROJECT_U8500_C1 6
  169. #define PRCMU_FW_PROJECT_U8500_C2 7
  170. #define PRCMU_FW_PROJECT_U8500_C3 8
  171. #define PRCMU_FW_PROJECT_U8500_C4 9
  172. #define PRCMU_FW_PROJECT_U9500_MBL 10
  173. #define PRCMU_FW_PROJECT_U8500_SSG1 11 /* Samsung specific */
  174. #define PRCMU_FW_PROJECT_U8500_MBL2 12 /* Customer specific */
  175. #define PRCMU_FW_PROJECT_U8520 13
  176. #define PRCMU_FW_PROJECT_U8420 14
  177. #define PRCMU_FW_PROJECT_U8500_SSG2 15 /* Samsung specific */
  178. #define PRCMU_FW_PROJECT_U8420_SYSCLK 17
  179. #define PRCMU_FW_PROJECT_A9420 20
  180. /* [32..63] 9540 and derivatives */
  181. #define PRCMU_FW_PROJECT_U9540 32
  182. /* [64..95] 8540 and derivatives */
  183. #define PRCMU_FW_PROJECT_L8540 64
  184. /* [96..126] 8580 and derivatives */
  185. #define PRCMU_FW_PROJECT_L8580 96
  186. #define PRCMU_FW_PROJECT_NAME_LEN 20
  187. struct prcmu_fw_version {
  188. u32 project; /* Notice, project shifted with 8 on ux540 */
  189. u8 api_version;
  190. u8 func_version;
  191. u8 errata;
  192. char project_name[PRCMU_FW_PROJECT_NAME_LEN];
  193. };
  194. #include <linux/mfd/db8500-prcmu.h>
  195. #if defined(CONFIG_UX500_SOC_DB8500)
  196. static inline void prcmu_early_init(void)
  197. {
  198. return db8500_prcmu_early_init();
  199. }
  200. static inline int prcmu_set_power_state(u8 state, bool keep_ulp_clk,
  201. bool keep_ap_pll)
  202. {
  203. return db8500_prcmu_set_power_state(state, keep_ulp_clk,
  204. keep_ap_pll);
  205. }
  206. static inline u8 prcmu_get_power_state_result(void)
  207. {
  208. return db8500_prcmu_get_power_state_result();
  209. }
  210. static inline int prcmu_set_epod(u16 epod_id, u8 epod_state)
  211. {
  212. return db8500_prcmu_set_epod(epod_id, epod_state);
  213. }
  214. static inline void prcmu_enable_wakeups(u32 wakeups)
  215. {
  216. db8500_prcmu_enable_wakeups(wakeups);
  217. }
  218. static inline void prcmu_disable_wakeups(void)
  219. {
  220. prcmu_enable_wakeups(0);
  221. }
  222. static inline void prcmu_config_abb_event_readout(u32 abb_events)
  223. {
  224. db8500_prcmu_config_abb_event_readout(abb_events);
  225. }
  226. static inline void prcmu_get_abb_event_buffer(void __iomem **buf)
  227. {
  228. db8500_prcmu_get_abb_event_buffer(buf);
  229. }
  230. int prcmu_abb_read(u8 slave, u8 reg, u8 *value, u8 size);
  231. int prcmu_abb_write(u8 slave, u8 reg, u8 *value, u8 size);
  232. int prcmu_abb_write_masked(u8 slave, u8 reg, u8 *value, u8 *mask, u8 size);
  233. int prcmu_config_clkout(u8 clkout, u8 source, u8 div);
  234. static inline int prcmu_request_clock(u8 clock, bool enable)
  235. {
  236. return db8500_prcmu_request_clock(clock, enable);
  237. }
  238. unsigned long prcmu_clock_rate(u8 clock);
  239. long prcmu_round_clock_rate(u8 clock, unsigned long rate);
  240. int prcmu_set_clock_rate(u8 clock, unsigned long rate);
  241. static inline int prcmu_get_ddr_opp(void)
  242. {
  243. return db8500_prcmu_get_ddr_opp();
  244. }
  245. static inline int prcmu_set_arm_opp(u8 opp)
  246. {
  247. return db8500_prcmu_set_arm_opp(opp);
  248. }
  249. static inline int prcmu_get_arm_opp(void)
  250. {
  251. return db8500_prcmu_get_arm_opp();
  252. }
  253. static inline int prcmu_set_ape_opp(u8 opp)
  254. {
  255. return db8500_prcmu_set_ape_opp(opp);
  256. }
  257. static inline int prcmu_get_ape_opp(void)
  258. {
  259. return db8500_prcmu_get_ape_opp();
  260. }
  261. static inline int prcmu_request_ape_opp_100_voltage(bool enable)
  262. {
  263. return db8500_prcmu_request_ape_opp_100_voltage(enable);
  264. }
  265. static inline void prcmu_system_reset(u16 reset_code)
  266. {
  267. return db8500_prcmu_system_reset(reset_code);
  268. }
  269. static inline u16 prcmu_get_reset_code(void)
  270. {
  271. return db8500_prcmu_get_reset_code();
  272. }
  273. int prcmu_ac_wake_req(void);
  274. void prcmu_ac_sleep_req(void);
  275. static inline void prcmu_modem_reset(void)
  276. {
  277. return db8500_prcmu_modem_reset();
  278. }
  279. static inline bool prcmu_is_ac_wake_requested(void)
  280. {
  281. return db8500_prcmu_is_ac_wake_requested();
  282. }
  283. static inline int prcmu_config_esram0_deep_sleep(u8 state)
  284. {
  285. return db8500_prcmu_config_esram0_deep_sleep(state);
  286. }
  287. static inline int prcmu_config_hotdog(u8 threshold)
  288. {
  289. return db8500_prcmu_config_hotdog(threshold);
  290. }
  291. static inline int prcmu_config_hotmon(u8 low, u8 high)
  292. {
  293. return db8500_prcmu_config_hotmon(low, high);
  294. }
  295. static inline int prcmu_start_temp_sense(u16 cycles32k)
  296. {
  297. return db8500_prcmu_start_temp_sense(cycles32k);
  298. }
  299. static inline int prcmu_stop_temp_sense(void)
  300. {
  301. return db8500_prcmu_stop_temp_sense();
  302. }
  303. static inline u32 prcmu_read(unsigned int reg)
  304. {
  305. return db8500_prcmu_read(reg);
  306. }
  307. static inline void prcmu_write(unsigned int reg, u32 value)
  308. {
  309. db8500_prcmu_write(reg, value);
  310. }
  311. static inline void prcmu_write_masked(unsigned int reg, u32 mask, u32 value)
  312. {
  313. db8500_prcmu_write_masked(reg, mask, value);
  314. }
  315. static inline int prcmu_enable_a9wdog(u8 id)
  316. {
  317. return db8500_prcmu_enable_a9wdog(id);
  318. }
  319. static inline int prcmu_disable_a9wdog(u8 id)
  320. {
  321. return db8500_prcmu_disable_a9wdog(id);
  322. }
  323. static inline int prcmu_kick_a9wdog(u8 id)
  324. {
  325. return db8500_prcmu_kick_a9wdog(id);
  326. }
  327. static inline int prcmu_load_a9wdog(u8 id, u32 timeout)
  328. {
  329. return db8500_prcmu_load_a9wdog(id, timeout);
  330. }
  331. static inline int prcmu_config_a9wdog(u8 num, bool sleep_auto_off)
  332. {
  333. return db8500_prcmu_config_a9wdog(num, sleep_auto_off);
  334. }
  335. #else
  336. static inline void prcmu_early_init(void) {}
  337. static inline int prcmu_set_power_state(u8 state, bool keep_ulp_clk,
  338. bool keep_ap_pll)
  339. {
  340. return 0;
  341. }
  342. static inline int prcmu_set_epod(u16 epod_id, u8 epod_state)
  343. {
  344. return 0;
  345. }
  346. static inline void prcmu_enable_wakeups(u32 wakeups) {}
  347. static inline void prcmu_disable_wakeups(void) {}
  348. static inline int prcmu_abb_read(u8 slave, u8 reg, u8 *value, u8 size)
  349. {
  350. return -ENOSYS;
  351. }
  352. static inline int prcmu_abb_write(u8 slave, u8 reg, u8 *value, u8 size)
  353. {
  354. return -ENOSYS;
  355. }
  356. static inline int prcmu_abb_write_masked(u8 slave, u8 reg, u8 *value, u8 *mask,
  357. u8 size)
  358. {
  359. return -ENOSYS;
  360. }
  361. static inline int prcmu_config_clkout(u8 clkout, u8 source, u8 div)
  362. {
  363. return 0;
  364. }
  365. static inline int prcmu_request_clock(u8 clock, bool enable)
  366. {
  367. return 0;
  368. }
  369. static inline long prcmu_round_clock_rate(u8 clock, unsigned long rate)
  370. {
  371. return 0;
  372. }
  373. static inline int prcmu_set_clock_rate(u8 clock, unsigned long rate)
  374. {
  375. return 0;
  376. }
  377. static inline unsigned long prcmu_clock_rate(u8 clock)
  378. {
  379. return 0;
  380. }
  381. static inline int prcmu_set_ape_opp(u8 opp)
  382. {
  383. return 0;
  384. }
  385. static inline int prcmu_get_ape_opp(void)
  386. {
  387. return APE_100_OPP;
  388. }
  389. static inline int prcmu_request_ape_opp_100_voltage(bool enable)
  390. {
  391. return 0;
  392. }
  393. static inline int prcmu_set_arm_opp(u8 opp)
  394. {
  395. return 0;
  396. }
  397. static inline int prcmu_get_arm_opp(void)
  398. {
  399. return ARM_100_OPP;
  400. }
  401. static inline int prcmu_get_ddr_opp(void)
  402. {
  403. return DDR_100_OPP;
  404. }
  405. static inline void prcmu_system_reset(u16 reset_code) {}
  406. static inline u16 prcmu_get_reset_code(void)
  407. {
  408. return 0;
  409. }
  410. static inline int prcmu_ac_wake_req(void)
  411. {
  412. return 0;
  413. }
  414. static inline void prcmu_ac_sleep_req(void) {}
  415. static inline void prcmu_modem_reset(void) {}
  416. static inline bool prcmu_is_ac_wake_requested(void)
  417. {
  418. return false;
  419. }
  420. static inline int prcmu_config_esram0_deep_sleep(u8 state)
  421. {
  422. return 0;
  423. }
  424. static inline void prcmu_config_abb_event_readout(u32 abb_events) {}
  425. static inline void prcmu_get_abb_event_buffer(void __iomem **buf)
  426. {
  427. *buf = NULL;
  428. }
  429. static inline int prcmu_config_hotdog(u8 threshold)
  430. {
  431. return 0;
  432. }
  433. static inline int prcmu_config_hotmon(u8 low, u8 high)
  434. {
  435. return 0;
  436. }
  437. static inline int prcmu_start_temp_sense(u16 cycles32k)
  438. {
  439. return 0;
  440. }
  441. static inline int prcmu_stop_temp_sense(void)
  442. {
  443. return 0;
  444. }
  445. static inline u32 prcmu_read(unsigned int reg)
  446. {
  447. return 0;
  448. }
  449. static inline void prcmu_write(unsigned int reg, u32 value) {}
  450. static inline void prcmu_write_masked(unsigned int reg, u32 mask, u32 value) {}
  451. #endif
  452. static inline void prcmu_set(unsigned int reg, u32 bits)
  453. {
  454. prcmu_write_masked(reg, bits, bits);
  455. }
  456. static inline void prcmu_clear(unsigned int reg, u32 bits)
  457. {
  458. prcmu_write_masked(reg, bits, 0);
  459. }
  460. /* PRCMU QoS APE OPP class */
  461. #define PRCMU_QOS_APE_OPP 1
  462. #define PRCMU_QOS_DDR_OPP 2
  463. #define PRCMU_QOS_ARM_OPP 3
  464. #define PRCMU_QOS_DEFAULT_VALUE -1
  465. static inline unsigned long prcmu_qos_get_cpufreq_opp_delay(void)
  466. {
  467. return 0;
  468. }
  469. static inline int prcmu_qos_requirement(int prcmu_qos_class)
  470. {
  471. return 0;
  472. }
  473. static inline int prcmu_qos_add_requirement(int prcmu_qos_class,
  474. char *name, s32 value)
  475. {
  476. return 0;
  477. }
  478. static inline int prcmu_qos_update_requirement(int prcmu_qos_class,
  479. char *name, s32 new_value)
  480. {
  481. return 0;
  482. }
  483. static inline void prcmu_qos_remove_requirement(int prcmu_qos_class, char *name)
  484. {
  485. }
  486. static inline int prcmu_qos_add_notifier(int prcmu_qos_class,
  487. struct notifier_block *notifier)
  488. {
  489. return 0;
  490. }
  491. static inline int prcmu_qos_remove_notifier(int prcmu_qos_class,
  492. struct notifier_block *notifier)
  493. {
  494. return 0;
  495. }
  496. #endif /* __MACH_PRCMU_H */