clockdomains3xxx_data.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * OMAP3xxx clockdomains
  4. *
  5. * Copyright (C) 2008-2011 Texas Instruments, Inc.
  6. * Copyright (C) 2008-2010 Nokia Corporation
  7. *
  8. * Paul Walmsley, Jouni Högander
  9. *
  10. * This file contains clockdomains and clockdomain wakeup/sleep
  11. * dependencies for the OMAP3xxx chips. Some notes:
  12. *
  13. * A useful validation rule for struct clockdomain: Any clockdomain
  14. * referenced by a wkdep_srcs or sleepdep_srcs array must have a
  15. * dep_bit assigned. So wkdep_srcs/sleepdep_srcs are really just
  16. * software-controllable dependencies. Non-software-controllable
  17. * dependencies do exist, but they are not encoded below (yet).
  18. *
  19. * The overly-specific dep_bit names are due to a bit name collision
  20. * with CM_FCLKEN_{DSP,IVA2}. The DSP/IVA2 PM_WKDEP and CM_SLEEPDEP shift
  21. * value are the same for all powerdomains: 2
  22. *
  23. * XXX should dep_bit be a mask, so we can test to see if it is 0 as a
  24. * sanity check?
  25. * XXX encode hardware fixed wakeup dependencies -- esp. for 3430 CORE
  26. */
  27. /*
  28. * To-Do List
  29. * -> Port the Sleep/Wakeup dependencies for the domains
  30. * from the Power domain framework
  31. */
  32. #include <linux/kernel.h>
  33. #include <linux/io.h>
  34. #include "soc.h"
  35. #include "clockdomain.h"
  36. #include "prm2xxx_3xxx.h"
  37. #include "cm2xxx_3xxx.h"
  38. #include "cm-regbits-34xx.h"
  39. #include "prm-regbits-34xx.h"
  40. /*
  41. * Clockdomain dependencies for wkdeps/sleepdeps
  42. *
  43. * XXX Hardware dependencies (e.g., dependencies that cannot be
  44. * changed in software) are not included here yet, but should be.
  45. */
  46. /* OMAP3-specific possible dependencies */
  47. /*
  48. * 3430ES1 PM_WKDEP_GFX: adds IVA2, removes CORE
  49. * 3430ES2 PM_WKDEP_SGX: adds IVA2, removes CORE
  50. */
  51. static struct clkdm_dep gfx_sgx_3xxx_wkdeps[] = {
  52. { .clkdm_name = "iva2_clkdm" },
  53. { .clkdm_name = "mpu_clkdm" },
  54. { .clkdm_name = "wkup_clkdm" },
  55. { NULL },
  56. };
  57. static struct clkdm_dep gfx_sgx_am35x_wkdeps[] = {
  58. { .clkdm_name = "mpu_clkdm" },
  59. { .clkdm_name = "wkup_clkdm" },
  60. { NULL },
  61. };
  62. /* 3430: PM_WKDEP_PER: CORE, IVA2, MPU, WKUP */
  63. static struct clkdm_dep per_wkdeps[] = {
  64. { .clkdm_name = "core_l3_clkdm" },
  65. { .clkdm_name = "core_l4_clkdm" },
  66. { .clkdm_name = "iva2_clkdm" },
  67. { .clkdm_name = "mpu_clkdm" },
  68. { .clkdm_name = "wkup_clkdm" },
  69. { NULL },
  70. };
  71. static struct clkdm_dep per_am35x_wkdeps[] = {
  72. { .clkdm_name = "core_l3_clkdm" },
  73. { .clkdm_name = "core_l4_clkdm" },
  74. { .clkdm_name = "mpu_clkdm" },
  75. { .clkdm_name = "wkup_clkdm" },
  76. { NULL },
  77. };
  78. /* 3430ES2: PM_WKDEP_USBHOST: CORE, IVA2, MPU, WKUP */
  79. static struct clkdm_dep usbhost_wkdeps[] = {
  80. { .clkdm_name = "core_l3_clkdm" },
  81. { .clkdm_name = "core_l4_clkdm" },
  82. { .clkdm_name = "iva2_clkdm" },
  83. { .clkdm_name = "mpu_clkdm" },
  84. { .clkdm_name = "wkup_clkdm" },
  85. { NULL },
  86. };
  87. static struct clkdm_dep usbhost_am35x_wkdeps[] = {
  88. { .clkdm_name = "core_l3_clkdm" },
  89. { .clkdm_name = "core_l4_clkdm" },
  90. { .clkdm_name = "mpu_clkdm" },
  91. { .clkdm_name = "wkup_clkdm" },
  92. { NULL },
  93. };
  94. /* 3430 PM_WKDEP_MPU: CORE, IVA2, DSS, PER */
  95. static struct clkdm_dep mpu_3xxx_wkdeps[] = {
  96. { .clkdm_name = "core_l3_clkdm" },
  97. { .clkdm_name = "core_l4_clkdm" },
  98. { .clkdm_name = "iva2_clkdm" },
  99. { .clkdm_name = "dss_clkdm" },
  100. { .clkdm_name = "per_clkdm" },
  101. { NULL },
  102. };
  103. static struct clkdm_dep mpu_am35x_wkdeps[] = {
  104. { .clkdm_name = "core_l3_clkdm" },
  105. { .clkdm_name = "core_l4_clkdm" },
  106. { .clkdm_name = "dss_clkdm" },
  107. { .clkdm_name = "per_clkdm" },
  108. { NULL },
  109. };
  110. /* 3430 PM_WKDEP_IVA2: CORE, MPU, WKUP, DSS, PER */
  111. static struct clkdm_dep iva2_wkdeps[] = {
  112. { .clkdm_name = "core_l3_clkdm" },
  113. { .clkdm_name = "core_l4_clkdm" },
  114. { .clkdm_name = "mpu_clkdm" },
  115. { .clkdm_name = "wkup_clkdm" },
  116. { .clkdm_name = "dss_clkdm" },
  117. { .clkdm_name = "per_clkdm" },
  118. { NULL },
  119. };
  120. /* 3430 PM_WKDEP_CAM: IVA2, MPU, WKUP */
  121. static struct clkdm_dep cam_wkdeps[] = {
  122. { .clkdm_name = "iva2_clkdm" },
  123. { .clkdm_name = "mpu_clkdm" },
  124. { .clkdm_name = "wkup_clkdm" },
  125. { NULL },
  126. };
  127. /* 3430 PM_WKDEP_DSS: IVA2, MPU, WKUP */
  128. static struct clkdm_dep dss_wkdeps[] = {
  129. { .clkdm_name = "iva2_clkdm" },
  130. { .clkdm_name = "mpu_clkdm" },
  131. { .clkdm_name = "wkup_clkdm" },
  132. { NULL },
  133. };
  134. static struct clkdm_dep dss_am35x_wkdeps[] = {
  135. { .clkdm_name = "mpu_clkdm" },
  136. { .clkdm_name = "wkup_clkdm" },
  137. { NULL },
  138. };
  139. /* 3430: PM_WKDEP_NEON: MPU */
  140. static struct clkdm_dep neon_wkdeps[] = {
  141. { .clkdm_name = "mpu_clkdm" },
  142. { NULL },
  143. };
  144. /* Sleep dependency source arrays for OMAP3-specific clkdms */
  145. /* 3430: CM_SLEEPDEP_DSS: MPU, IVA */
  146. static struct clkdm_dep dss_sleepdeps[] = {
  147. { .clkdm_name = "mpu_clkdm" },
  148. { .clkdm_name = "iva2_clkdm" },
  149. { NULL },
  150. };
  151. static struct clkdm_dep dss_am35x_sleepdeps[] = {
  152. { .clkdm_name = "mpu_clkdm" },
  153. { NULL },
  154. };
  155. /* 3430: CM_SLEEPDEP_PER: MPU, IVA */
  156. static struct clkdm_dep per_sleepdeps[] = {
  157. { .clkdm_name = "mpu_clkdm" },
  158. { .clkdm_name = "iva2_clkdm" },
  159. { NULL },
  160. };
  161. static struct clkdm_dep per_am35x_sleepdeps[] = {
  162. { .clkdm_name = "mpu_clkdm" },
  163. { NULL },
  164. };
  165. /* 3430ES2: CM_SLEEPDEP_USBHOST: MPU, IVA */
  166. static struct clkdm_dep usbhost_sleepdeps[] = {
  167. { .clkdm_name = "mpu_clkdm" },
  168. { .clkdm_name = "iva2_clkdm" },
  169. { NULL },
  170. };
  171. static struct clkdm_dep usbhost_am35x_sleepdeps[] = {
  172. { .clkdm_name = "mpu_clkdm" },
  173. { NULL },
  174. };
  175. /* 3430: CM_SLEEPDEP_CAM: MPU */
  176. static struct clkdm_dep cam_sleepdeps[] = {
  177. { .clkdm_name = "mpu_clkdm" },
  178. { NULL },
  179. };
  180. /*
  181. * 3430ES1: CM_SLEEPDEP_GFX: MPU
  182. * 3430ES2: CM_SLEEPDEP_SGX: MPU
  183. * These can share data since they will never be present simultaneously
  184. * on the same device.
  185. */
  186. static struct clkdm_dep gfx_sgx_sleepdeps[] = {
  187. { .clkdm_name = "mpu_clkdm" },
  188. { NULL },
  189. };
  190. /*
  191. * OMAP3 clockdomains
  192. */
  193. static struct clockdomain mpu_3xxx_clkdm = {
  194. .name = "mpu_clkdm",
  195. .pwrdm = { .name = "mpu_pwrdm" },
  196. .flags = CLKDM_CAN_HWSUP | CLKDM_CAN_FORCE_WAKEUP,
  197. .dep_bit = OMAP3430_EN_MPU_SHIFT,
  198. .wkdep_srcs = mpu_3xxx_wkdeps,
  199. .clktrctrl_mask = OMAP3430_CLKTRCTRL_MPU_MASK,
  200. };
  201. static struct clockdomain mpu_am35x_clkdm = {
  202. .name = "mpu_clkdm",
  203. .pwrdm = { .name = "mpu_pwrdm" },
  204. .flags = CLKDM_CAN_HWSUP | CLKDM_CAN_FORCE_WAKEUP,
  205. .dep_bit = OMAP3430_EN_MPU_SHIFT,
  206. .wkdep_srcs = mpu_am35x_wkdeps,
  207. .clktrctrl_mask = OMAP3430_CLKTRCTRL_MPU_MASK,
  208. };
  209. static struct clockdomain neon_clkdm = {
  210. .name = "neon_clkdm",
  211. .pwrdm = { .name = "neon_pwrdm" },
  212. .flags = CLKDM_CAN_HWSUP_SWSUP,
  213. .wkdep_srcs = neon_wkdeps,
  214. .clktrctrl_mask = OMAP3430_CLKTRCTRL_NEON_MASK,
  215. };
  216. static struct clockdomain iva2_clkdm = {
  217. .name = "iva2_clkdm",
  218. .pwrdm = { .name = "iva2_pwrdm" },
  219. .flags = CLKDM_CAN_SWSUP,
  220. .dep_bit = OMAP3430_PM_WKDEP_MPU_EN_IVA2_SHIFT,
  221. .wkdep_srcs = iva2_wkdeps,
  222. .clktrctrl_mask = OMAP3430_CLKTRCTRL_IVA2_MASK,
  223. };
  224. static struct clockdomain gfx_3430es1_clkdm = {
  225. .name = "gfx_clkdm",
  226. .pwrdm = { .name = "gfx_pwrdm" },
  227. .flags = CLKDM_CAN_HWSUP_SWSUP,
  228. .wkdep_srcs = gfx_sgx_3xxx_wkdeps,
  229. .sleepdep_srcs = gfx_sgx_sleepdeps,
  230. .clktrctrl_mask = OMAP3430ES1_CLKTRCTRL_GFX_MASK,
  231. };
  232. static struct clockdomain sgx_clkdm = {
  233. .name = "sgx_clkdm",
  234. .pwrdm = { .name = "sgx_pwrdm" },
  235. .flags = CLKDM_CAN_HWSUP_SWSUP,
  236. .wkdep_srcs = gfx_sgx_3xxx_wkdeps,
  237. .sleepdep_srcs = gfx_sgx_sleepdeps,
  238. .clktrctrl_mask = OMAP3430ES2_CLKTRCTRL_SGX_MASK,
  239. };
  240. static struct clockdomain sgx_am35x_clkdm = {
  241. .name = "sgx_clkdm",
  242. .pwrdm = { .name = "sgx_pwrdm" },
  243. .flags = CLKDM_CAN_HWSUP_SWSUP,
  244. .wkdep_srcs = gfx_sgx_am35x_wkdeps,
  245. .sleepdep_srcs = gfx_sgx_sleepdeps,
  246. .clktrctrl_mask = OMAP3430ES2_CLKTRCTRL_SGX_MASK,
  247. };
  248. /*
  249. * The die-to-die clockdomain was documented in the 34xx ES1 TRM, but
  250. * then that information was removed from the 34xx ES2+ TRM. It is
  251. * unclear whether the core is still there, but the clockdomain logic
  252. * is there, and must be programmed to an appropriate state if the
  253. * CORE clockdomain is to become inactive.
  254. */
  255. static struct clockdomain d2d_clkdm = {
  256. .name = "d2d_clkdm",
  257. .pwrdm = { .name = "core_pwrdm" },
  258. .flags = CLKDM_CAN_HWSUP_SWSUP,
  259. .clktrctrl_mask = OMAP3430ES1_CLKTRCTRL_D2D_MASK,
  260. };
  261. /*
  262. * XXX add usecounting for clkdm dependencies, otherwise the presence
  263. * of a single dep bit for core_l3_3xxx_clkdm and core_l4_3xxx_clkdm
  264. * could cause trouble
  265. */
  266. static struct clockdomain core_l3_3xxx_clkdm = {
  267. .name = "core_l3_clkdm",
  268. .pwrdm = { .name = "core_pwrdm" },
  269. .flags = CLKDM_CAN_HWSUP,
  270. .dep_bit = OMAP3430_EN_CORE_SHIFT,
  271. .clktrctrl_mask = OMAP3430_CLKTRCTRL_L3_MASK,
  272. };
  273. /*
  274. * XXX add usecounting for clkdm dependencies, otherwise the presence
  275. * of a single dep bit for core_l3_3xxx_clkdm and core_l4_3xxx_clkdm
  276. * could cause trouble
  277. */
  278. static struct clockdomain core_l4_3xxx_clkdm = {
  279. .name = "core_l4_clkdm",
  280. .pwrdm = { .name = "core_pwrdm" },
  281. .flags = CLKDM_CAN_HWSUP,
  282. .dep_bit = OMAP3430_EN_CORE_SHIFT,
  283. .clktrctrl_mask = OMAP3430_CLKTRCTRL_L4_MASK,
  284. };
  285. /* Another case of bit name collisions between several registers: EN_DSS */
  286. static struct clockdomain dss_3xxx_clkdm = {
  287. .name = "dss_clkdm",
  288. .pwrdm = { .name = "dss_pwrdm" },
  289. .flags = CLKDM_CAN_HWSUP_SWSUP,
  290. .dep_bit = OMAP3430_PM_WKDEP_MPU_EN_DSS_SHIFT,
  291. .wkdep_srcs = dss_wkdeps,
  292. .sleepdep_srcs = dss_sleepdeps,
  293. .clktrctrl_mask = OMAP3430_CLKTRCTRL_DSS_MASK,
  294. };
  295. static struct clockdomain dss_am35x_clkdm = {
  296. .name = "dss_clkdm",
  297. .pwrdm = { .name = "dss_pwrdm" },
  298. .flags = CLKDM_CAN_HWSUP_SWSUP,
  299. .dep_bit = OMAP3430_PM_WKDEP_MPU_EN_DSS_SHIFT,
  300. .wkdep_srcs = dss_am35x_wkdeps,
  301. .sleepdep_srcs = dss_am35x_sleepdeps,
  302. .clktrctrl_mask = OMAP3430_CLKTRCTRL_DSS_MASK,
  303. };
  304. static struct clockdomain cam_clkdm = {
  305. .name = "cam_clkdm",
  306. .pwrdm = { .name = "cam_pwrdm" },
  307. .flags = CLKDM_CAN_HWSUP_SWSUP,
  308. .wkdep_srcs = cam_wkdeps,
  309. .sleepdep_srcs = cam_sleepdeps,
  310. .clktrctrl_mask = OMAP3430_CLKTRCTRL_CAM_MASK,
  311. };
  312. static struct clockdomain usbhost_clkdm = {
  313. .name = "usbhost_clkdm",
  314. .pwrdm = { .name = "usbhost_pwrdm" },
  315. .flags = CLKDM_CAN_HWSUP_SWSUP,
  316. .wkdep_srcs = usbhost_wkdeps,
  317. .sleepdep_srcs = usbhost_sleepdeps,
  318. .clktrctrl_mask = OMAP3430ES2_CLKTRCTRL_USBHOST_MASK,
  319. };
  320. static struct clockdomain usbhost_am35x_clkdm = {
  321. .name = "usbhost_clkdm",
  322. .pwrdm = { .name = "core_pwrdm" },
  323. .flags = CLKDM_CAN_HWSUP_SWSUP,
  324. .wkdep_srcs = usbhost_am35x_wkdeps,
  325. .sleepdep_srcs = usbhost_am35x_sleepdeps,
  326. .clktrctrl_mask = OMAP3430ES2_CLKTRCTRL_USBHOST_MASK,
  327. };
  328. static struct clockdomain per_clkdm = {
  329. .name = "per_clkdm",
  330. .pwrdm = { .name = "per_pwrdm" },
  331. .flags = CLKDM_CAN_HWSUP_SWSUP,
  332. .dep_bit = OMAP3430_EN_PER_SHIFT,
  333. .wkdep_srcs = per_wkdeps,
  334. .sleepdep_srcs = per_sleepdeps,
  335. .clktrctrl_mask = OMAP3430_CLKTRCTRL_PER_MASK,
  336. };
  337. static struct clockdomain per_am35x_clkdm = {
  338. .name = "per_clkdm",
  339. .pwrdm = { .name = "per_pwrdm" },
  340. .flags = CLKDM_CAN_HWSUP_SWSUP,
  341. .dep_bit = OMAP3430_EN_PER_SHIFT,
  342. .wkdep_srcs = per_am35x_wkdeps,
  343. .sleepdep_srcs = per_am35x_sleepdeps,
  344. .clktrctrl_mask = OMAP3430_CLKTRCTRL_PER_MASK,
  345. };
  346. static struct clockdomain emu_clkdm = {
  347. .name = "emu_clkdm",
  348. .pwrdm = { .name = "emu_pwrdm" },
  349. .flags = (CLKDM_CAN_ENABLE_AUTO | CLKDM_CAN_SWSUP |
  350. CLKDM_MISSING_IDLE_REPORTING),
  351. .clktrctrl_mask = OMAP3430_CLKTRCTRL_EMU_MASK,
  352. };
  353. static struct clockdomain dpll1_clkdm = {
  354. .name = "dpll1_clkdm",
  355. .pwrdm = { .name = "dpll1_pwrdm" },
  356. };
  357. static struct clockdomain dpll2_clkdm = {
  358. .name = "dpll2_clkdm",
  359. .pwrdm = { .name = "dpll2_pwrdm" },
  360. };
  361. static struct clockdomain dpll3_clkdm = {
  362. .name = "dpll3_clkdm",
  363. .pwrdm = { .name = "dpll3_pwrdm" },
  364. };
  365. static struct clockdomain dpll4_clkdm = {
  366. .name = "dpll4_clkdm",
  367. .pwrdm = { .name = "dpll4_pwrdm" },
  368. };
  369. static struct clockdomain dpll5_clkdm = {
  370. .name = "dpll5_clkdm",
  371. .pwrdm = { .name = "dpll5_pwrdm" },
  372. };
  373. /*
  374. * Clockdomain hwsup dependencies
  375. */
  376. static struct clkdm_autodep clkdm_autodeps[] = {
  377. {
  378. .clkdm = { .name = "mpu_clkdm" },
  379. },
  380. {
  381. .clkdm = { .name = "iva2_clkdm" },
  382. },
  383. {
  384. .clkdm = { .name = NULL },
  385. }
  386. };
  387. static struct clkdm_autodep clkdm_am35x_autodeps[] = {
  388. {
  389. .clkdm = { .name = "mpu_clkdm" },
  390. },
  391. {
  392. .clkdm = { .name = NULL },
  393. }
  394. };
  395. /*
  396. *
  397. */
  398. static struct clockdomain *clockdomains_common[] __initdata = {
  399. &wkup_common_clkdm,
  400. &neon_clkdm,
  401. &core_l3_3xxx_clkdm,
  402. &core_l4_3xxx_clkdm,
  403. &emu_clkdm,
  404. &dpll1_clkdm,
  405. &dpll3_clkdm,
  406. &dpll4_clkdm,
  407. NULL
  408. };
  409. static struct clockdomain *clockdomains_omap3430[] __initdata = {
  410. &mpu_3xxx_clkdm,
  411. &iva2_clkdm,
  412. &d2d_clkdm,
  413. &dss_3xxx_clkdm,
  414. &cam_clkdm,
  415. &per_clkdm,
  416. &dpll2_clkdm,
  417. NULL
  418. };
  419. static struct clockdomain *clockdomains_omap3430es1[] __initdata = {
  420. &gfx_3430es1_clkdm,
  421. NULL,
  422. };
  423. static struct clockdomain *clockdomains_omap3430es2plus[] __initdata = {
  424. &sgx_clkdm,
  425. &dpll5_clkdm,
  426. &usbhost_clkdm,
  427. NULL,
  428. };
  429. static struct clockdomain *clockdomains_am35x[] __initdata = {
  430. &mpu_am35x_clkdm,
  431. &sgx_am35x_clkdm,
  432. &dss_am35x_clkdm,
  433. &per_am35x_clkdm,
  434. &usbhost_am35x_clkdm,
  435. &dpll5_clkdm,
  436. NULL
  437. };
  438. void __init omap3xxx_clockdomains_init(void)
  439. {
  440. struct clockdomain **sc;
  441. unsigned int rev;
  442. if (!cpu_is_omap34xx())
  443. return;
  444. clkdm_register_platform_funcs(&omap3_clkdm_operations);
  445. clkdm_register_clkdms(clockdomains_common);
  446. rev = omap_rev();
  447. if (rev == AM35XX_REV_ES1_0 || rev == AM35XX_REV_ES1_1) {
  448. clkdm_register_clkdms(clockdomains_am35x);
  449. clkdm_register_autodeps(clkdm_am35x_autodeps);
  450. } else {
  451. clkdm_register_clkdms(clockdomains_omap3430);
  452. sc = (rev == OMAP3430_REV_ES1_0) ?
  453. clockdomains_omap3430es1 : clockdomains_omap3430es2plus;
  454. clkdm_register_clkdms(sc);
  455. clkdm_register_autodeps(clkdm_autodeps);
  456. }
  457. clkdm_complete_init();
  458. }