clockdomains3xxx_data.c 13 KB

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