1*b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0
2a5ffef6aSPaul Walmsley /*
3a5ffef6aSPaul Walmsley * OMAP2xxx clockdomains
4a5ffef6aSPaul Walmsley *
5a5ffef6aSPaul Walmsley * Copyright (C) 2008-2009 Texas Instruments, Inc.
6a5ffef6aSPaul Walmsley * Copyright (C) 2008-2010 Nokia Corporation
7a5ffef6aSPaul Walmsley *
8a5ffef6aSPaul Walmsley * Paul Walmsley, Jouni Högander
9a5ffef6aSPaul Walmsley *
10a5ffef6aSPaul Walmsley * This file contains clockdomains and clockdomain wakeup dependencies
11a5ffef6aSPaul Walmsley * for OMAP2xxx chips. Some notes:
12a5ffef6aSPaul Walmsley *
13a5ffef6aSPaul Walmsley * A useful validation rule for struct clockdomain: Any clockdomain
14a5ffef6aSPaul Walmsley * referenced by a wkdep_srcs must have a dep_bit assigned. So
15a5ffef6aSPaul Walmsley * wkdep_srcs are really just software-controllable dependencies.
16a5ffef6aSPaul Walmsley * Non-software-controllable dependencies do exist, but they are not
17a5ffef6aSPaul Walmsley * encoded below (yet).
18a5ffef6aSPaul Walmsley *
19a5ffef6aSPaul Walmsley * 24xx does not support programmable sleep dependencies (SLEEPDEP)
20a5ffef6aSPaul Walmsley *
21a5ffef6aSPaul Walmsley * The overly-specific dep_bit names are due to a bit name collision
22a5ffef6aSPaul Walmsley * with CM_FCLKEN_{DSP,IVA2}. The DSP/IVA2 PM_WKDEP and CM_SLEEPDEP shift
23a5ffef6aSPaul Walmsley * value are the same for all powerdomains: 2
24a5ffef6aSPaul Walmsley *
25a5ffef6aSPaul Walmsley * XXX should dep_bit be a mask, so we can test to see if it is 0 as a
26a5ffef6aSPaul Walmsley * sanity check?
27a5ffef6aSPaul Walmsley * XXX encode hardware fixed wakeup dependencies -- esp. for 3430 CORE
28a5ffef6aSPaul Walmsley */
29a5ffef6aSPaul Walmsley
30a5ffef6aSPaul Walmsley /*
31a5ffef6aSPaul Walmsley * To-Do List
32a5ffef6aSPaul Walmsley * -> Port the Sleep/Wakeup dependencies for the domains
33a5ffef6aSPaul Walmsley * from the Power domain framework
34a5ffef6aSPaul Walmsley */
35a5ffef6aSPaul Walmsley
36a5ffef6aSPaul Walmsley #include <linux/kernel.h>
37a5ffef6aSPaul Walmsley #include <linux/io.h>
38a5ffef6aSPaul Walmsley
39e4c060dbSTony Lindgren #include "soc.h"
40a5ffef6aSPaul Walmsley #include "clockdomain.h"
41a5ffef6aSPaul Walmsley #include "prm2xxx_3xxx.h"
42a5ffef6aSPaul Walmsley #include "cm2xxx_3xxx.h"
43a5ffef6aSPaul Walmsley #include "cm-regbits-24xx.h"
44a5ffef6aSPaul Walmsley #include "prm-regbits-24xx.h"
45a5ffef6aSPaul Walmsley
46a5ffef6aSPaul Walmsley /*
47a5ffef6aSPaul Walmsley * Clockdomain dependencies for wkdeps
48a5ffef6aSPaul Walmsley *
49a5ffef6aSPaul Walmsley * XXX Hardware dependencies (e.g., dependencies that cannot be
50a5ffef6aSPaul Walmsley * changed in software) are not included here yet, but should be.
51a5ffef6aSPaul Walmsley */
52a5ffef6aSPaul Walmsley
53a5ffef6aSPaul Walmsley /* Wakeup dependency source arrays */
54a5ffef6aSPaul Walmsley
55a5ffef6aSPaul Walmsley /* 2430-specific possible wakeup dependencies */
56a5ffef6aSPaul Walmsley
57a5ffef6aSPaul Walmsley /* 2430 PM_WKDEP_CORE: DSP, GFX, MPU, WKUP, MDM */
58a5ffef6aSPaul Walmsley static struct clkdm_dep core_2430_wkdeps[] = {
59a5ffef6aSPaul Walmsley { .clkdm_name = "dsp_clkdm" },
60a5ffef6aSPaul Walmsley { .clkdm_name = "gfx_clkdm" },
61a5ffef6aSPaul Walmsley { .clkdm_name = "mpu_clkdm" },
62a5ffef6aSPaul Walmsley { .clkdm_name = "wkup_clkdm" },
63a5ffef6aSPaul Walmsley { .clkdm_name = "mdm_clkdm" },
64a5ffef6aSPaul Walmsley { NULL },
65a5ffef6aSPaul Walmsley };
66a5ffef6aSPaul Walmsley
67a5ffef6aSPaul Walmsley /* 2430 PM_WKDEP_MPU: CORE, DSP, WKUP, MDM */
68a5ffef6aSPaul Walmsley static struct clkdm_dep mpu_2430_wkdeps[] = {
69a5ffef6aSPaul Walmsley { .clkdm_name = "core_l3_clkdm" },
70a5ffef6aSPaul Walmsley { .clkdm_name = "core_l4_clkdm" },
71a5ffef6aSPaul Walmsley { .clkdm_name = "dsp_clkdm" },
72a5ffef6aSPaul Walmsley { .clkdm_name = "wkup_clkdm" },
73a5ffef6aSPaul Walmsley { .clkdm_name = "mdm_clkdm" },
74a5ffef6aSPaul Walmsley { NULL },
75a5ffef6aSPaul Walmsley };
76a5ffef6aSPaul Walmsley
77a5ffef6aSPaul Walmsley /* 2430 PM_WKDEP_MDM: CORE, MPU, WKUP */
78a5ffef6aSPaul Walmsley static struct clkdm_dep mdm_2430_wkdeps[] = {
79a5ffef6aSPaul Walmsley { .clkdm_name = "core_l3_clkdm" },
80a5ffef6aSPaul Walmsley { .clkdm_name = "core_l4_clkdm" },
81a5ffef6aSPaul Walmsley { .clkdm_name = "mpu_clkdm" },
82a5ffef6aSPaul Walmsley { .clkdm_name = "wkup_clkdm" },
83a5ffef6aSPaul Walmsley { NULL },
84a5ffef6aSPaul Walmsley };
85a5ffef6aSPaul Walmsley
86a5ffef6aSPaul Walmsley /*
87a5ffef6aSPaul Walmsley * 2430-only clockdomains
88a5ffef6aSPaul Walmsley */
89a5ffef6aSPaul Walmsley
90a5ffef6aSPaul Walmsley static struct clockdomain mpu_2430_clkdm = {
91a5ffef6aSPaul Walmsley .name = "mpu_clkdm",
92a5ffef6aSPaul Walmsley .pwrdm = { .name = "mpu_pwrdm" },
93a5ffef6aSPaul Walmsley .flags = CLKDM_CAN_HWSUP_SWSUP,
94a5ffef6aSPaul Walmsley .wkdep_srcs = mpu_2430_wkdeps,
95a5ffef6aSPaul Walmsley .clktrctrl_mask = OMAP24XX_AUTOSTATE_MPU_MASK,
96a5ffef6aSPaul Walmsley };
97a5ffef6aSPaul Walmsley
98a5ffef6aSPaul Walmsley /* Another case of bit name collisions between several registers: EN_MDM */
99a5ffef6aSPaul Walmsley static struct clockdomain mdm_clkdm = {
100a5ffef6aSPaul Walmsley .name = "mdm_clkdm",
101a5ffef6aSPaul Walmsley .pwrdm = { .name = "mdm_pwrdm" },
102a5ffef6aSPaul Walmsley .flags = CLKDM_CAN_HWSUP_SWSUP,
103a5ffef6aSPaul Walmsley .dep_bit = OMAP2430_PM_WKDEP_MPU_EN_MDM_SHIFT,
104a5ffef6aSPaul Walmsley .wkdep_srcs = mdm_2430_wkdeps,
105a5ffef6aSPaul Walmsley .clktrctrl_mask = OMAP2430_AUTOSTATE_MDM_MASK,
106a5ffef6aSPaul Walmsley };
107a5ffef6aSPaul Walmsley
108a5ffef6aSPaul Walmsley static struct clockdomain dsp_2430_clkdm = {
109a5ffef6aSPaul Walmsley .name = "dsp_clkdm",
110a5ffef6aSPaul Walmsley .pwrdm = { .name = "dsp_pwrdm" },
111a5ffef6aSPaul Walmsley .flags = CLKDM_CAN_HWSUP_SWSUP,
112a5ffef6aSPaul Walmsley .dep_bit = OMAP24XX_PM_WKDEP_MPU_EN_DSP_SHIFT,
113a5ffef6aSPaul Walmsley .wkdep_srcs = dsp_24xx_wkdeps,
114a5ffef6aSPaul Walmsley .clktrctrl_mask = OMAP24XX_AUTOSTATE_DSP_MASK,
115a5ffef6aSPaul Walmsley };
116a5ffef6aSPaul Walmsley
117a5ffef6aSPaul Walmsley static struct clockdomain gfx_2430_clkdm = {
118a5ffef6aSPaul Walmsley .name = "gfx_clkdm",
119a5ffef6aSPaul Walmsley .pwrdm = { .name = "gfx_pwrdm" },
120a5ffef6aSPaul Walmsley .flags = CLKDM_CAN_HWSUP_SWSUP,
121a5ffef6aSPaul Walmsley .wkdep_srcs = gfx_24xx_wkdeps,
122a5ffef6aSPaul Walmsley .clktrctrl_mask = OMAP24XX_AUTOSTATE_GFX_MASK,
123a5ffef6aSPaul Walmsley };
124a5ffef6aSPaul Walmsley
125a5ffef6aSPaul Walmsley /*
126a5ffef6aSPaul Walmsley * XXX add usecounting for clkdm dependencies, otherwise the presence
127a5ffef6aSPaul Walmsley * of a single dep bit for core_l3_24xx_clkdm and core_l4_24xx_clkdm
128a5ffef6aSPaul Walmsley * could cause trouble
129a5ffef6aSPaul Walmsley */
130a5ffef6aSPaul Walmsley static struct clockdomain core_l3_2430_clkdm = {
131a5ffef6aSPaul Walmsley .name = "core_l3_clkdm",
132a5ffef6aSPaul Walmsley .pwrdm = { .name = "core_pwrdm" },
133a5ffef6aSPaul Walmsley .flags = CLKDM_CAN_HWSUP,
134a5ffef6aSPaul Walmsley .dep_bit = OMAP24XX_EN_CORE_SHIFT,
135a5ffef6aSPaul Walmsley .wkdep_srcs = core_2430_wkdeps,
136a5ffef6aSPaul Walmsley .clktrctrl_mask = OMAP24XX_AUTOSTATE_L3_MASK,
137a5ffef6aSPaul Walmsley };
138a5ffef6aSPaul Walmsley
139a5ffef6aSPaul Walmsley /*
140a5ffef6aSPaul Walmsley * XXX add usecounting for clkdm dependencies, otherwise the presence
141a5ffef6aSPaul Walmsley * of a single dep bit for core_l3_24xx_clkdm and core_l4_24xx_clkdm
142a5ffef6aSPaul Walmsley * could cause trouble
143a5ffef6aSPaul Walmsley */
144a5ffef6aSPaul Walmsley static struct clockdomain core_l4_2430_clkdm = {
145a5ffef6aSPaul Walmsley .name = "core_l4_clkdm",
146a5ffef6aSPaul Walmsley .pwrdm = { .name = "core_pwrdm" },
147a5ffef6aSPaul Walmsley .flags = CLKDM_CAN_HWSUP,
148a5ffef6aSPaul Walmsley .dep_bit = OMAP24XX_EN_CORE_SHIFT,
149a5ffef6aSPaul Walmsley .wkdep_srcs = core_2430_wkdeps,
150a5ffef6aSPaul Walmsley .clktrctrl_mask = OMAP24XX_AUTOSTATE_L4_MASK,
151a5ffef6aSPaul Walmsley };
152a5ffef6aSPaul Walmsley
153a5ffef6aSPaul Walmsley static struct clockdomain dss_2430_clkdm = {
154a5ffef6aSPaul Walmsley .name = "dss_clkdm",
155a5ffef6aSPaul Walmsley .pwrdm = { .name = "core_pwrdm" },
156a5ffef6aSPaul Walmsley .flags = CLKDM_CAN_HWSUP,
157a5ffef6aSPaul Walmsley .clktrctrl_mask = OMAP24XX_AUTOSTATE_DSS_MASK,
158a5ffef6aSPaul Walmsley };
159a5ffef6aSPaul Walmsley
160a5ffef6aSPaul Walmsley static struct clockdomain *clockdomains_omap243x[] __initdata = {
161a5ffef6aSPaul Walmsley &wkup_common_clkdm,
162a5ffef6aSPaul Walmsley &mpu_2430_clkdm,
163a5ffef6aSPaul Walmsley &mdm_clkdm,
164a5ffef6aSPaul Walmsley &dsp_2430_clkdm,
165a5ffef6aSPaul Walmsley &gfx_2430_clkdm,
166a5ffef6aSPaul Walmsley &core_l3_2430_clkdm,
167a5ffef6aSPaul Walmsley &core_l4_2430_clkdm,
168a5ffef6aSPaul Walmsley &dss_2430_clkdm,
169a5ffef6aSPaul Walmsley NULL,
170a5ffef6aSPaul Walmsley };
171a5ffef6aSPaul Walmsley
omap243x_clockdomains_init(void)172a5ffef6aSPaul Walmsley void __init omap243x_clockdomains_init(void)
173a5ffef6aSPaul Walmsley {
174a5ffef6aSPaul Walmsley if (!cpu_is_omap243x())
175a5ffef6aSPaul Walmsley return;
176a5ffef6aSPaul Walmsley
177a5ffef6aSPaul Walmsley clkdm_register_platform_funcs(&omap2_clkdm_operations);
178a5ffef6aSPaul Walmsley clkdm_register_clkdms(clockdomains_omap243x);
179a5ffef6aSPaul Walmsley clkdm_complete_init();
180a5ffef6aSPaul Walmsley }
181a5ffef6aSPaul Walmsley
182