History

Merge tag 'arm-multiplatform-5.19-3' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc

Pull yet more ARM multiplatform updates from Arnd Bergmann: "This is the third and final bit of the multiplatform conversion for ARMv5, finishing off OMAP1. One patch enables the common-clk interface, and the other ones does the Kconfig change. These were waiting on a few dependencies to trickle in for common-clk, and the last one of those was in the USB tree" * tag 'arm-multiplatform-5.19-3' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc: ARM: omap1: enable multiplatform ARM: OMAP1: clock: Convert to CCF

Linus Torvalds committed 4 years ago

Commit 9af13082 parents c6f2f3e 703644012 files · +584 −897Browse files

Unified · Split

12 files
  1. arch/arm/Kconfig +0 −13
  2. arch/arm/configs/omap1_defconfig +3 −0
  3. arch/arm/mach-omap1/Kconfig +16 −0
  4. arch/arm/mach-omap1/clock.c +300 −393
  5. arch/arm/mach-omap1/clock.h +49 −90
  6. arch/arm/mach-omap1/clock_data.c +209 −274
  7. arch/arm/mach-omap1/hardware.h +1 −1
  8. arch/arm/mach-omap1/include/mach/uncompress.h +0 −117
  9. arch/arm/mach-omap1/io.c +0 −7
  10. arch/arm/mach-omap1/serial.c +1 −2
  11. arch/arm/mach-omap1/serial.h +0 −0
  12. arch/arm/mach-omap1/time.c +5 −0
arch/arm/Kconfig+0−13
@@ -396,19 +396,6 @@ config ARCH_SA1100 · 395 unmodified lines
396396 help
397397 Support for StrongARM 11x0 based boards.
398398
399−config ARCH_OMAP1
400− bool "TI OMAP1"
401− depends on CPU_LITTLE_ENDIAN
402− select CLKSRC_MMIO
403− select FORCE_PCI if PCCARD
404− select GENERIC_IRQ_CHIP
405− select GPIOLIB
406− select HAVE_LEGACY_CLK
407− select IRQ_DOMAIN
408− select SPARSE_IRQ
409− help
410− Support for older TI OMAP1 (omap7xx, omap15xx or omap16xx)
411−
412399 endchoice
413400
414401 menu "Multiple platform selection"
arch/arm/configs/omap1_defconfig+3−0
@@ -17,6 +17,9 @@ CONFIG_MODULES=y · 16 unmodified lines
1717 CONFIG_MODULE_UNLOAD=y
1818 CONFIG_MODULE_FORCE_UNLOAD=y
1919 # CONFIG_BLK_DEV_BSG is not set
20+CONFIG_ARCH_MULTI_V4T=y
21+CONFIG_ARCH_MULTI_V5=y
22+# CONFIG_ARCH_MULTI_V7 is not set
2023 CONFIG_ARCH_OMAP=y
2124 CONFIG_ARCH_OMAP1=y
2225 CONFIG_OMAP_RESET_CLOCKS=y
arch/arm/mach-omap1/Kconfig+16−0
@@ -1,4 +1,16 @@
11 # SPDX-License-Identifier: GPL-2.0-only
2+menuconfig ARCH_OMAP1
3+ bool "TI OMAP1"
4+ depends on ARCH_MULTI_V4T || ARCH_MULTI_V5
5+ depends on CPU_LITTLE_ENDIAN
6+ select ARCH_HAS_HOLES_MEMORYMODEL
7+ select ARCH_OMAP
8+ select CLKSRC_MMIO
9+ select FORCE_PCI if PCCARD
10+ select GPIOLIB
11+ help
12+ Support for older TI OMAP1 (omap7xx, omap15xx or omap16xx)
13+
214 if ARCH_OMAP1
315
416 menu "TI OMAP1 specific features"
@@ -6,23 +18,27 @@ menu "TI OMAP1 specific features" · 1 unmodified line
618 comment "OMAP Core Type"
719
820 config ARCH_OMAP730
21+ depends on ARCH_MULTI_V5
922 bool "OMAP730 Based System"
1023 select ARCH_OMAP_OTG
1124 select CPU_ARM926T
1225 select OMAP_MPU_TIMER
1326
1427 config ARCH_OMAP850
28+ depends on ARCH_MULTI_V5
1529 bool "OMAP850 Based System"
1630 select ARCH_OMAP_OTG
1731 select CPU_ARM926T
1832
1933 config ARCH_OMAP15XX
34+ depends on ARCH_MULTI_V4T
2035 default y
2136 bool "OMAP15xx Based System"
2237 select CPU_ARM925T
2338 select OMAP_MPU_TIMER
2439
2540 config ARCH_OMAP16XX
41+ depends on ARCH_MULTI_V5
2642 bool "OMAP16xx Based System"
2743 select ARCH_OMAP_OTG
2844 select CPU_ARM926T
arch/arm/mach-omap1/clock.c+300−393
@@ -16,7 +16,9 @@ · 15 unmodified lines
1616 #include <linux/io.h>
1717 #include <linux/clk.h>
1818 #include <linux/clkdev.h>
19+#include <linux/clk-provider.h>
1920 #include <linux/soc/ti/omap1-io.h>
21+#include <linux/spinlock.h>
2022
2123 #include <asm/mach-types.h>
2224
@@ -28,33 +30,37 @@ · 5 unmodified lines
2830 #include "sram.h"
2931
3032 __u32 arm_idlect1_mask;
31−struct clk *api_ck_p, *ck_dpll1_p, *ck_ref_p;
33+/* provide direct internal access (not via clk API) to some clocks */
34+struct omap1_clk *api_ck_p, *ck_dpll1_p, *ck_ref_p;
3235
33−static LIST_HEAD(clocks);
34−static DEFINE_MUTEX(clocks_mutex);
35−static DEFINE_SPINLOCK(clockfw_lock);
36+/* protect registeres shared among clk_enable/disable() and clk_set_rate() operations */
37+static DEFINE_SPINLOCK(arm_ckctl_lock);
38+static DEFINE_SPINLOCK(arm_idlect2_lock);
39+static DEFINE_SPINLOCK(mod_conf_ctrl_0_lock);
40+static DEFINE_SPINLOCK(mod_conf_ctrl_1_lock);
41+static DEFINE_SPINLOCK(swd_clk_div_ctrl_sel_lock);
3642
3743 /*
3844 * Omap1 specific clock functions
3945 */
4046
41−unsigned long omap1_uart_recalc(struct clk *clk)
47+unsigned long omap1_uart_recalc(struct omap1_clk *clk, unsigned long p_rate)
4248 {
4349 unsigned int val = __raw_readl(clk->enable_reg);
4450 return val & 1 << clk->enable_bit ? 48000000 : 12000000;
4551 }
4652
47−unsigned long omap1_sossi_recalc(struct clk *clk)
53+unsigned long omap1_sossi_recalc(struct omap1_clk *clk, unsigned long p_rate)
4854 {
4955 u32 div = omap_readl(MOD_CONF_CTRL_1);
5056
5157 div = (div >> 17) & 0x7;
5258 div++;
5359
54− return clk->parent->rate / div;
60+ return p_rate / div;
5561 }
5662
57−static void omap1_clk_allow_idle(struct clk *clk)
63+static void omap1_clk_allow_idle(struct omap1_clk *clk)
5864 {
5965 struct arm_idlect1_clk * iclk = (struct arm_idlect1_clk *)clk;
6066
@@ -65,7 +71,7 @@ static void omap1_clk_allow_idle(struct clk *clk) · 4 unmodified lines
6571 arm_idlect1_mask |= 1 << iclk->idlect_shift;
6672 }
6773
68−static void omap1_clk_deny_idle(struct clk *clk)
74+static void omap1_clk_deny_idle(struct omap1_clk *clk)
6975 {
7076 struct arm_idlect1_clk * iclk = (struct arm_idlect1_clk *)clk;
7177
@@ -129,7 +135,7 @@ static __u16 verify_ckctl_value(__u16 newval) · 57 unmodified lines
129135 return newval;
130136 }
131137
132−static int calc_dsor_exp(struct clk *clk, unsigned long rate)
138+static int calc_dsor_exp(unsigned long rate, unsigned long realrate)
133139 {
134140 /* Note: If target frequency is too low, this function will return 4,
135141 * which is invalid value. Caller must check for this value and act
@@ -142,15 +148,11 @@ static int calc_dsor_exp(struct clk *clk, unsigned long rate) · 6 unmodified lines
142148 * DSP_CK >= TC_CK
143149 * DSPMMU_CK >= TC_CK
144150 */
145− unsigned long realrate;
146− struct clk * parent;
147151 unsigned dsor_exp;
148152
149− parent = clk->parent;
150− if (unlikely(parent == NULL))
153+ if (unlikely(realrate == 0))
151154 return -EIO;
152155
153− realrate = parent->rate;
154156 for (dsor_exp=0; dsor_exp<4; dsor_exp++) {
155157 if (realrate <= rate)
156158 break;
@@ -161,16 +163,50 @@ static int calc_dsor_exp(struct clk *clk, unsigned long rate) · 4 unmodified lines
161163 return dsor_exp;
162164 }
163165
164−unsigned long omap1_ckctl_recalc(struct clk *clk)
166+unsigned long omap1_ckctl_recalc(struct omap1_clk *clk, unsigned long p_rate)
165167 {
166168 /* Calculate divisor encoded as 2-bit exponent */
167169 int dsor = 1 << (3 & (omap_readw(ARM_CKCTL) >> clk->rate_offset));
168170
169− return clk->parent->rate / dsor;
171+ /* update locally maintained rate, required by arm_ck for omap1_show_rates() */
172+ clk->rate = p_rate / dsor;
173+ return clk->rate;
170174 }
171175
172−unsigned long omap1_ckctl_recalc_dsp_domain(struct clk *clk)
176+static int omap1_clk_is_enabled(struct clk_hw *hw)
173177 {
178+ struct omap1_clk *clk = to_omap1_clk(hw);
179+ bool api_ck_was_enabled = true;
180+ __u32 regval32;
181+ int ret;
182+
183+ if (!clk->ops) /* no gate -- always enabled */
184+ return 1;
185+
186+ if (clk->ops == &clkops_dspck) {
187+ api_ck_was_enabled = omap1_clk_is_enabled(&api_ck_p->hw);
188+ if (!api_ck_was_enabled)
189+ if (api_ck_p->ops->enable(api_ck_p) < 0)
190+ return 0;
191+ }
192+
193+ if (clk->flags & ENABLE_REG_32BIT)
194+ regval32 = __raw_readl(clk->enable_reg);
195+ else
196+ regval32 = __raw_readw(clk->enable_reg);
197+
198+ ret = regval32 & (1 << clk->enable_bit);
199+
200+ if (!api_ck_was_enabled)
201+ api_ck_p->ops->disable(api_ck_p);
202+
203+ return ret;
204+}
205+
206+
207+unsigned long omap1_ckctl_recalc_dsp_domain(struct omap1_clk *clk, unsigned long p_rate)
208+{
209+ bool api_ck_was_enabled;
174210 int dsor;
175211
176212 /* Calculate divisor encoded as 2-bit exponent
@@ -180,15 +216,18 @@ unsigned long omap1_ckctl_recalc_dsp_domain(struct clk *clk) · 3 unmodified lines
180216 * Note that DSP_CKCTL virt addr = phys addr, so
181217 * we must use __raw_readw() instead of omap_readw().
182218 */
183− omap1_clk_enable(api_ck_p);
219+ api_ck_was_enabled = omap1_clk_is_enabled(&api_ck_p->hw);
220+ if (!api_ck_was_enabled)
221+ api_ck_p->ops->enable(api_ck_p);
184222 dsor = 1 << (3 & (__raw_readw(DSP_CKCTL) >> clk->rate_offset));
185− omap1_clk_disable(api_ck_p);
223+ if (!api_ck_was_enabled)
224+ api_ck_p->ops->disable(api_ck_p);
186225
187− return clk->parent->rate / dsor;
226+ return p_rate / dsor;
188227 }
189228
190229 /* MPU virtual clock functions */
191−int omap1_select_table_rate(struct clk *clk, unsigned long rate)
230+int omap1_select_table_rate(struct omap1_clk *clk, unsigned long rate, unsigned long p_rate)
192231 {
193232 /* Find the highest supported frequency <= rate and switch to it */
194233 struct mpu_rate * ptr;
@@ -223,12 +262,12 @@ int omap1_select_table_rate(struct clk *clk, unsigned long rate) · 28 unmodified lines
223262 return 0;
224263 }
225264
226−int omap1_clk_set_rate_dsp_domain(struct clk *clk, unsigned long rate)
265+int omap1_clk_set_rate_dsp_domain(struct omap1_clk *clk, unsigned long rate, unsigned long p_rate)
227266 {
228267 int dsor_exp;
229268 u16 regval;
230269
231− dsor_exp = calc_dsor_exp(clk, rate);
270+ dsor_exp = calc_dsor_exp(rate, p_rate);
232271 if (dsor_exp > 3)
233272 dsor_exp = -EINVAL;
234273 if (dsor_exp < 0)
@@ -238,42 +277,51 @@ int omap1_clk_set_rate_dsp_domain(struct clk *clk, unsigned long rate) · 3 unmodified lines
238277 regval &= ~(3 << clk->rate_offset);
239278 regval |= dsor_exp << clk->rate_offset;
240279 __raw_writew(regval, DSP_CKCTL);
241− clk->rate = clk->parent->rate / (1 << dsor_exp);
280+ clk->rate = p_rate / (1 << dsor_exp);
242281
243282 return 0;
244283 }
245284
246−long omap1_clk_round_rate_ckctl_arm(struct clk *clk, unsigned long rate)
285+long omap1_clk_round_rate_ckctl_arm(struct omap1_clk *clk, unsigned long rate,
286+ unsigned long *p_rate)
247287 {
248− int dsor_exp = calc_dsor_exp(clk, rate);
288+ int dsor_exp = calc_dsor_exp(rate, *p_rate);
289+
249290 if (dsor_exp < 0)
250291 return dsor_exp;
251292 if (dsor_exp > 3)
252293 dsor_exp = 3;
253− return clk->parent->rate / (1 << dsor_exp);
294+ return *p_rate / (1 << dsor_exp);
254295 }
255296
256−int omap1_clk_set_rate_ckctl_arm(struct clk *clk, unsigned long rate)
297+int omap1_clk_set_rate_ckctl_arm(struct omap1_clk *clk, unsigned long rate, unsigned long p_rate)
257298 {
299+ unsigned long flags;
258300 int dsor_exp;
259301 u16 regval;
260302
261− dsor_exp = calc_dsor_exp(clk, rate);
303+ dsor_exp = calc_dsor_exp(rate, p_rate);
262304 if (dsor_exp > 3)
263305 dsor_exp = -EINVAL;
264306 if (dsor_exp < 0)
265307 return dsor_exp;
266308
309+ /* protect ARM_CKCTL register from concurrent access via clk_enable/disable() */
310+ spin_lock_irqsave(&arm_ckctl_lock, flags);
311+
267312 regval = omap_readw(ARM_CKCTL);
268313 regval &= ~(3 << clk->rate_offset);
269314 regval |= dsor_exp << clk->rate_offset;
270315 regval = verify_ckctl_value(regval);
271316 omap_writew(regval, ARM_CKCTL);
272− clk->rate = clk->parent->rate / (1 << dsor_exp);
317+ clk->rate = p_rate / (1 << dsor_exp);
318+
319+ spin_unlock_irqrestore(&arm_ckctl_lock, flags);
320+
273321 return 0;
274322 }
275323
276−long omap1_round_to_table_rate(struct clk *clk, unsigned long rate)
324+long omap1_round_to_table_rate(struct omap1_clk *clk, unsigned long rate, unsigned long *p_rate)
277325 {
278326 /* Find the highest supported frequency <= rate */
279327 struct mpu_rate * ptr;
@@ -324,26 +372,40 @@ static unsigned calc_ext_dsor(unsigned long rate) · 44 unmodified lines
324372 }
325373
326374 /* XXX Only needed on 1510 */
327−int omap1_set_uart_rate(struct clk *clk, unsigned long rate)
375+long omap1_round_uart_rate(struct omap1_clk *clk, unsigned long rate, unsigned long *p_rate)
328376 {
377+ return rate > 24000000 ? 48000000 : 12000000;
378+}
379+
380+int omap1_set_uart_rate(struct omap1_clk *clk, unsigned long rate, unsigned long p_rate)
381+{
382+ unsigned long flags;
329383 unsigned int val;
330384
331− val = __raw_readl(clk->enable_reg);
332385 if (rate == 12000000)
333− val &= ~(1 << clk->enable_bit);
386+ val = 0;
334387 else if (rate == 48000000)
335− val |= (1 << clk->enable_bit);
388+ val = 1 << clk->enable_bit;
336389 else
337390 return -EINVAL;
391+
392+ /* protect MOD_CONF_CTRL_0 register from concurrent access via clk_enable/disable() */
393+ spin_lock_irqsave(&mod_conf_ctrl_0_lock, flags);
394+
395+ val |= __raw_readl(clk->enable_reg) & ~(1 << clk->enable_bit);
338396 __raw_writel(val, clk->enable_reg);
397+
398+ spin_unlock_irqrestore(&mod_conf_ctrl_0_lock, flags);
399+
339400 clk->rate = rate;
340401
341402 return 0;
342403 }
343404
344405 /* External clock (MCLK & BCLK) functions */
345−int omap1_set_ext_clk_rate(struct clk *clk, unsigned long rate)
406+int omap1_set_ext_clk_rate(struct omap1_clk *clk, unsigned long rate, unsigned long p_rate)
346407 {
408+ unsigned long flags;
347409 unsigned dsor;
348410 __u16 ratio_bits;
349411
@@ -354,25 +416,53 @@ int omap1_set_ext_clk_rate(struct clk *clk, unsigned long rate) · 4 unmodified lines
354416 else
355417 ratio_bits = (dsor - 2) << 2;
356418
419+ /* protect SWD_CLK_DIV_CTRL_SEL register from concurrent access via clk_enable/disable() */
420+ spin_lock_irqsave(&swd_clk_div_ctrl_sel_lock, flags);
421+
357422 ratio_bits |= __raw_readw(clk->enable_reg) & ~0xfd;
358423 __raw_writew(ratio_bits, clk->enable_reg);
359424
425+ spin_unlock_irqrestore(&swd_clk_div_ctrl_sel_lock, flags);
426+
360427 return 0;
361428 }
362429
363−int omap1_set_sossi_rate(struct clk *clk, unsigned long rate)
430+static int calc_div_sossi(unsigned long rate, unsigned long p_rate)
364431 {
365− u32 l;
366432 int div;
367− unsigned long p_rate;
368433
369− p_rate = clk->parent->rate;
370434 /* Round towards slower frequency */
371435 div = (p_rate + rate - 1) / rate;
372− div--;
436+
437+ return --div;
438+}
439+
440+long omap1_round_sossi_rate(struct omap1_clk *clk, unsigned long rate, unsigned long *p_rate)
441+{
442+ int div;
443+
444+ div = calc_div_sossi(rate, *p_rate);
445+ if (div < 0)
446+ div = 0;
447+ else if (div > 7)
448+ div = 7;
449+
450+ return *p_rate / (div + 1);
451+}
452+
453+int omap1_set_sossi_rate(struct omap1_clk *clk, unsigned long rate, unsigned long p_rate)
454+{
455+ unsigned long flags;
456+ u32 l;
457+ int div;
458+
459+ div = calc_div_sossi(rate, p_rate);
373460 if (div < 0 || div > 7)
374461 return -EINVAL;
375462
463+ /* protect MOD_CONF_CTRL_1 register from concurrent access via clk_enable/disable() */
464+ spin_lock_irqsave(&mod_conf_ctrl_1_lock, flags);
465+
376466 l = omap_readl(MOD_CONF_CTRL_1);
377467 l &= ~(7 << 17);
378468 l |= div << 17;
@@ -380,15 +470,17 @@ int omap1_set_sossi_rate(struct clk *clk, unsigned long rate) · 1 unmodified line
380470
381471 clk->rate = p_rate / (div + 1);
382472
473+ spin_unlock_irqrestore(&mod_conf_ctrl_1_lock, flags);
474+
383475 return 0;
384476 }
385477
386−long omap1_round_ext_clk_rate(struct clk *clk, unsigned long rate)
478+long omap1_round_ext_clk_rate(struct omap1_clk *clk, unsigned long rate, unsigned long *p_rate)
387479 {
388480 return 96000000 / calc_ext_dsor(rate);
389481 }
390482
391−void omap1_init_ext_clk(struct clk *clk)
483+int omap1_init_ext_clk(struct omap1_clk *clk)
392484 {
393485 unsigned dsor;
394486 __u16 ratio_bits;
@@ -404,59 +496,59 @@ void omap1_init_ext_clk(struct clk *clk) · 9 unmodified lines
404496 dsor = ratio_bits + 2;
405497
406498 clk-> rate = 96000000 / dsor;
499+
500+ return 0;
407501 }
408502
409−int omap1_clk_enable(struct clk *clk)
503+static int omap1_clk_enable(struct clk_hw *hw)
410504 {
505+ struct omap1_clk *clk = to_omap1_clk(hw), *parent = to_omap1_clk(clk_hw_get_parent(hw));
411506 int ret = 0;
412507
413− if (clk->usecount++ == 0) {
414− if (clk->parent) {
415− ret = omap1_clk_enable(clk->parent);
416− if (ret)
417− goto err;
418−
419− if (clk->flags & CLOCK_NO_IDLE_PARENT)
420− omap1_clk_deny_idle(clk->parent);
421− }
508+ if (parent && clk->flags & CLOCK_NO_IDLE_PARENT)
509+ omap1_clk_deny_idle(parent);
422510
511+ if (clk->ops && !(WARN_ON(!clk->ops->enable)))
423512 ret = clk->ops->enable(clk);
424− if (ret) {
425− if (clk->parent)
426− omap1_clk_disable(clk->parent);
427− goto err;
428− }
429− }
430− return ret;
431513
432−err:
433− clk->usecount--;
434514 return ret;
435515 }
436516
437−void omap1_clk_disable(struct clk *clk)
517+static void omap1_clk_disable(struct clk_hw *hw)
438518 {
439− if (clk->usecount > 0 && !(--clk->usecount)) {
519+ struct omap1_clk *clk = to_omap1_clk(hw), *parent = to_omap1_clk(clk_hw_get_parent(hw));
520+
521+ if (clk->ops && !(WARN_ON(!clk->ops->disable)))
440522 clk->ops->disable(clk);
441− if (likely(clk->parent)) {
442− omap1_clk_disable(clk->parent);
443− if (clk->flags & CLOCK_NO_IDLE_PARENT)
444− omap1_clk_allow_idle(clk->parent);
445− }
446− }
523+
524+ if (likely(parent) && clk->flags & CLOCK_NO_IDLE_PARENT)
525+ omap1_clk_allow_idle(parent);
447526 }
448527
449−static int omap1_clk_enable_generic(struct clk *clk)
528+static int omap1_clk_enable_generic(struct omap1_clk *clk)
450529 {
530+ unsigned long flags;
451531 __u16 regval16;
452532 __u32 regval32;
453533
454534 if (unlikely(clk->enable_reg == NULL)) {
455535 printk(KERN_ERR "clock.c: Enable for %s without enable code\n",
456− clk->name);
536+ clk_hw_get_name(&clk->hw));
457537 return -EINVAL;
458538 }
459539
540+ /* protect clk->enable_reg from concurrent access via clk_set_rate() */
541+ if (clk->enable_reg == OMAP1_IO_ADDRESS(ARM_CKCTL))
542+ spin_lock_irqsave(&arm_ckctl_lock, flags);
543+ else if (clk->enable_reg == OMAP1_IO_ADDRESS(ARM_IDLECT2))
544+ spin_lock_irqsave(&arm_idlect2_lock, flags);
545+ else if (clk->enable_reg == OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0))
546+ spin_lock_irqsave(&mod_conf_ctrl_0_lock, flags);
547+ else if (clk->enable_reg == OMAP1_IO_ADDRESS(MOD_CONF_CTRL_1))
548+ spin_lock_irqsave(&mod_conf_ctrl_1_lock, flags);
549+ else if (clk->enable_reg == OMAP1_IO_ADDRESS(SWD_CLK_DIV_CTRL_SEL))
550+ spin_lock_irqsave(&swd_clk_div_ctrl_sel_lock, flags);
551+
460552 if (clk->flags & ENABLE_REG_32BIT) {
461553 regval32 = __raw_readl(clk->enable_reg);
462554 regval32 |= (1 << clk->enable_bit);
@@ -467,17 +559,41 @@ static int omap1_clk_enable_generic(struct clk *clk) · 4 unmodified lines
467559 __raw_writew(regval16, clk->enable_reg);
468560 }
469561
562+ if (clk->enable_reg == OMAP1_IO_ADDRESS(ARM_CKCTL))
563+ spin_unlock_irqrestore(&arm_ckctl_lock, flags);
564+ else if (clk->enable_reg == OMAP1_IO_ADDRESS(ARM_IDLECT2))
565+ spin_unlock_irqrestore(&arm_idlect2_lock, flags);
566+ else if (clk->enable_reg == OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0))
567+ spin_unlock_irqrestore(&mod_conf_ctrl_0_lock, flags);
568+ else if (clk->enable_reg == OMAP1_IO_ADDRESS(MOD_CONF_CTRL_1))
569+ spin_unlock_irqrestore(&mod_conf_ctrl_1_lock, flags);
570+ else if (clk->enable_reg == OMAP1_IO_ADDRESS(SWD_CLK_DIV_CTRL_SEL))
571+ spin_unlock_irqrestore(&swd_clk_div_ctrl_sel_lock, flags);
572+
470573 return 0;
471574 }
472575
473−static void omap1_clk_disable_generic(struct clk *clk)
576+static void omap1_clk_disable_generic(struct omap1_clk *clk)
474577 {
578+ unsigned long flags;
475579 __u16 regval16;
476580 __u32 regval32;
477581
478582 if (clk->enable_reg == NULL)
479583 return;
480584
585+ /* protect clk->enable_reg from concurrent access via clk_set_rate() */
586+ if (clk->enable_reg == OMAP1_IO_ADDRESS(ARM_CKCTL))
587+ spin_lock_irqsave(&arm_ckctl_lock, flags);
588+ else if (clk->enable_reg == OMAP1_IO_ADDRESS(ARM_IDLECT2))
589+ spin_lock_irqsave(&arm_idlect2_lock, flags);
590+ else if (clk->enable_reg == OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0))
591+ spin_lock_irqsave(&mod_conf_ctrl_0_lock, flags);
592+ else if (clk->enable_reg == OMAP1_IO_ADDRESS(MOD_CONF_CTRL_1))
593+ spin_lock_irqsave(&mod_conf_ctrl_1_lock, flags);
594+ else if (clk->enable_reg == OMAP1_IO_ADDRESS(SWD_CLK_DIV_CTRL_SEL))
595+ spin_lock_irqsave(&swd_clk_div_ctrl_sel_lock, flags);
596+
481597 if (clk->flags & ENABLE_REG_32BIT) {
482598 regval32 = __raw_readl(clk->enable_reg);
483599 regval32 &= ~(1 << clk->enable_bit);
@@ -487,6 +603,17 @@ static void omap1_clk_disable_generic(struct clk *clk) · 3 unmodified lines
487603 regval16 &= ~(1 << clk->enable_bit);
488604 __raw_writew(regval16, clk->enable_reg);
489605 }
606+
607+ if (clk->enable_reg == OMAP1_IO_ADDRESS(ARM_CKCTL))
608+ spin_unlock_irqrestore(&arm_ckctl_lock, flags);
609+ else if (clk->enable_reg == OMAP1_IO_ADDRESS(ARM_IDLECT2))
610+ spin_unlock_irqrestore(&arm_idlect2_lock, flags);
611+ else if (clk->enable_reg == OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0))
612+ spin_unlock_irqrestore(&mod_conf_ctrl_0_lock, flags);
613+ else if (clk->enable_reg == OMAP1_IO_ADDRESS(MOD_CONF_CTRL_1))
614+ spin_unlock_irqrestore(&mod_conf_ctrl_1_lock, flags);
615+ else if (clk->enable_reg == OMAP1_IO_ADDRESS(SWD_CLK_DIV_CTRL_SEL))
616+ spin_unlock_irqrestore(&swd_clk_div_ctrl_sel_lock, flags);
490617 }
491618
492619 const struct clkops clkops_generic = {
@@ -494,25 +621,38 @@ const struct clkops clkops_generic = { · 1 unmodified line
494621 .disable = omap1_clk_disable_generic,
495622 };
496623
497−static int omap1_clk_enable_dsp_domain(struct clk *clk)
624+static int omap1_clk_enable_dsp_domain(struct omap1_clk *clk)
498625 {
499− int retval;
626+ bool api_ck_was_enabled;
627+ int retval = 0;
628+
629+ api_ck_was_enabled = omap1_clk_is_enabled(&api_ck_p->hw);
630+ if (!api_ck_was_enabled)
631+ retval = api_ck_p->ops->enable(api_ck_p);
500632
501− retval = omap1_clk_enable(api_ck_p);
502633 if (!retval) {
503634 retval = omap1_clk_enable_generic(clk);
504− omap1_clk_disable(api_ck_p);
635+
636+ if (!api_ck_was_enabled)
637+ api_ck_p->ops->disable(api_ck_p);
505638 }
506639
507640 return retval;
508641 }
509642
510−static void omap1_clk_disable_dsp_domain(struct clk *clk)
643+static void omap1_clk_disable_dsp_domain(struct omap1_clk *clk)
511644 {
512− if (omap1_clk_enable(api_ck_p) == 0) {
513− omap1_clk_disable_generic(clk);
514− omap1_clk_disable(api_ck_p);
515− }
645+ bool api_ck_was_enabled;
646+
647+ api_ck_was_enabled = omap1_clk_is_enabled(&api_ck_p->hw);
648+ if (!api_ck_was_enabled)
649+ if (api_ck_p->ops->enable(api_ck_p) < 0)
650+ return;
651+
652+ omap1_clk_disable_generic(clk);
653+
654+ if (!api_ck_was_enabled)
655+ api_ck_p->ops->disable(api_ck_p);
516656 }
517657
518658 const struct clkops clkops_dspck = {
@@ -521,7 +661,7 @@ const struct clkops clkops_dspck = { · 2 unmodified lines
521661 };
522662
523663 /* XXX SYSC register handling does not belong in the clock framework */
524−static int omap1_clk_enable_uart_functional_16xx(struct clk *clk)
664+static int omap1_clk_enable_uart_functional_16xx(struct omap1_clk *clk)
525665 {
526666 int ret;
527667 struct uart_clk *uclk;
@@ -538,7 +678,7 @@ static int omap1_clk_enable_uart_functional_16xx(struct clk *clk) · 10 unmodified lines
538678 }
539679
540680 /* XXX SYSC register handling does not belong in the clock framework */
541−static void omap1_clk_disable_uart_functional_16xx(struct clk *clk)
681+static void omap1_clk_disable_uart_functional_16xx(struct omap1_clk *clk)
542682 {
543683 struct uart_clk *uclk;
544684
@@ -555,20 +695,33 @@ const struct clkops clkops_uart_16xx = { · 10 unmodified lines
555695 .disable = omap1_clk_disable_uart_functional_16xx,
556696 };
557697
558−long omap1_clk_round_rate(struct clk *clk, unsigned long rate)
698+static unsigned long omap1_clk_recalc_rate(struct clk_hw *hw, unsigned long p_rate)
559699 {
560− if (clk->round_rate != NULL)
561− return clk->round_rate(clk, rate);
700+ struct omap1_clk *clk = to_omap1_clk(hw);
701+
702+ if (clk->recalc)
703+ return clk->recalc(clk, p_rate);
562704
563705 return clk->rate;
564706 }
565707
566−int omap1_clk_set_rate(struct clk *clk, unsigned long rate)
708+static long omap1_clk_round_rate(struct clk_hw *hw, unsigned long rate, unsigned long *p_rate)
709+{
710+ struct omap1_clk *clk = to_omap1_clk(hw);
711+
712+ if (clk->round_rate != NULL)
713+ return clk->round_rate(clk, rate, p_rate);
714+
715+ return omap1_clk_recalc_rate(hw, *p_rate);
716+}
717+
718+static int omap1_clk_set_rate(struct clk_hw *hw, unsigned long rate, unsigned long p_rate)
567719 {
720+ struct omap1_clk *clk = to_omap1_clk(hw);
568721 int ret = -EINVAL;
569722
570723 if (clk->set_rate)
571− ret = clk->set_rate(clk, rate);
724+ ret = clk->set_rate(clk, rate, p_rate);
572725 return ret;
573726 }
574727
@@ -576,243 +729,105 @@ int omap1_clk_set_rate(struct clk *clk, unsigned long rate) · 1 unmodified line
576729 * Omap1 clock reset and init functions
577730 */
578731
732+static int omap1_clk_init_op(struct clk_hw *hw)
733+{
734+ struct omap1_clk *clk = to_omap1_clk(hw);
735+
736+ if (clk->init)
737+ return clk->init(clk);
738+
739+ return 0;
740+}
741+
579742 #ifdef CONFIG_OMAP_RESET_CLOCKS
580743
581−void omap1_clk_disable_unused(struct clk *clk)
744+static void omap1_clk_disable_unused(struct clk_hw *hw)
582745 {
583− __u32 regval32;
746+ struct omap1_clk *clk = to_omap1_clk(hw);
747+ const char *name = clk_hw_get_name(hw);
584748
585749 /* Clocks in the DSP domain need api_ck. Just assume bootloader
586750 * has not enabled any DSP clocks */
587751 if (clk->enable_reg == DSP_IDLECT2) {
588− pr_info("Skipping reset check for DSP domain clock \"%s\"\n",
589− clk->name);
752+ pr_info("Skipping reset check for DSP domain clock \"%s\"\n", name);
590753 return;
591754 }
592755
593− /* Is the clock already disabled? */
594− if (clk->flags & ENABLE_REG_32BIT)
595− regval32 = __raw_readl(clk->enable_reg);
596− else
597− regval32 = __raw_readw(clk->enable_reg);
598−
599− if ((regval32 & (1 << clk->enable_bit)) == 0)
600− return;
601−
602− printk(KERN_INFO "Disabling unused clock \"%s\"... ", clk->name);
603− clk->ops->disable(clk);
756+ pr_info("Disabling unused clock \"%s\"... ", name);
757+ omap1_clk_disable(hw);
604758 printk(" done\n");
605759 }
606760
607761 #endif
608762
763+const struct clk_ops omap1_clk_gate_ops = {
764+ .enable = omap1_clk_enable,
765+ .disable = omap1_clk_disable,
766+ .is_enabled = omap1_clk_is_enabled,
767+#ifdef CONFIG_OMAP_RESET_CLOCKS
768+ .disable_unused = omap1_clk_disable_unused,
769+#endif
770+};
609771
610−int clk_enable(struct clk *clk)
611−{
612− unsigned long flags;
613− int ret;
614−
615− if (IS_ERR_OR_NULL(clk))
616− return -EINVAL;
617−
618− spin_lock_irqsave(&clockfw_lock, flags);
619− ret = omap1_clk_enable(clk);
620− spin_unlock_irqrestore(&clockfw_lock, flags);
621−
622− return ret;
623−}
624−EXPORT_SYMBOL(clk_enable);
625−
626−void clk_disable(struct clk *clk)
627−{
628− unsigned long flags;
629−
630− if (IS_ERR_OR_NULL(clk))
631− return;
632−
633− spin_lock_irqsave(&clockfw_lock, flags);
634− if (clk->usecount == 0) {
635− pr_err("Trying disable clock %s with 0 usecount\n",
636− clk->name);
637− WARN_ON(1);
638− goto out;
639− }
640−
641− omap1_clk_disable(clk);
642−
643−out:
644− spin_unlock_irqrestore(&clockfw_lock, flags);
645−}
646−EXPORT_SYMBOL(clk_disable);
647−
648−unsigned long clk_get_rate(struct clk *clk)
649−{
650− unsigned long flags;
651− unsigned long ret;
652−
653− if (IS_ERR_OR_NULL(clk))
654− return 0;
655−
656− spin_lock_irqsave(&clockfw_lock, flags);
657− ret = clk->rate;
658− spin_unlock_irqrestore(&clockfw_lock, flags);
659−
660− return ret;
661−}
662−EXPORT_SYMBOL(clk_get_rate);
663−
664−/*
665− * Optional clock functions defined in include/linux/clk.h
666− */
667−
668−long clk_round_rate(struct clk *clk, unsigned long rate)
669−{
670− unsigned long flags;
671− long ret;
672−
673− if (IS_ERR_OR_NULL(clk))
674− return 0;
675−
676− spin_lock_irqsave(&clockfw_lock, flags);
677− ret = omap1_clk_round_rate(clk, rate);
678− spin_unlock_irqrestore(&clockfw_lock, flags);
679−
680− return ret;
681−}
682−EXPORT_SYMBOL(clk_round_rate);
683−
684−int clk_set_rate(struct clk *clk, unsigned long rate)
685−{
686− unsigned long flags;
687− int ret = -EINVAL;
688−
689− if (IS_ERR_OR_NULL(clk))
690− return ret;
691−
692− spin_lock_irqsave(&clockfw_lock, flags);
693− ret = omap1_clk_set_rate(clk, rate);
694− if (ret == 0)
695− propagate_rate(clk);
696− spin_unlock_irqrestore(&clockfw_lock, flags);
697−
698− return ret;
699−}
700−EXPORT_SYMBOL(clk_set_rate);
701−
702−int clk_set_parent(struct clk *clk, struct clk *parent)
703−{
704− WARN_ONCE(1, "clk_set_parent() not implemented for OMAP1\n");
705−
706− return -EINVAL;
707−}
708−EXPORT_SYMBOL(clk_set_parent);
772+const struct clk_ops omap1_clk_rate_ops = {
773+ .recalc_rate = omap1_clk_recalc_rate,
774+ .round_rate = omap1_clk_round_rate,
775+ .set_rate = omap1_clk_set_rate,
776+ .init = omap1_clk_init_op,
777+};
709778
710−struct clk *clk_get_parent(struct clk *clk)
711−{
712− return clk->parent;
713−}
714−EXPORT_SYMBOL(clk_get_parent);
779+const struct clk_ops omap1_clk_full_ops = {
780+ .enable = omap1_clk_enable,
781+ .disable = omap1_clk_disable,
782+ .is_enabled = omap1_clk_is_enabled,
783+#ifdef CONFIG_OMAP_RESET_CLOCKS
784+ .disable_unused = omap1_clk_disable_unused,
785+#endif
786+ .recalc_rate = omap1_clk_recalc_rate,
787+ .round_rate = omap1_clk_round_rate,
788+ .set_rate = omap1_clk_set_rate,
789+ .init = omap1_clk_init_op,
790+};
715791
716792 /*
717793 * OMAP specific clock functions shared between omap1 and omap2
718794 */
719795
720796 /* Used for clocks that always have same value as the parent clock */
721−unsigned long followparent_recalc(struct clk *clk)
797+unsigned long followparent_recalc(struct omap1_clk *clk, unsigned long p_rate)
722798 {
723− return clk->parent->rate;
799+ return p_rate;
724800 }
725801
726802 /*
727803 * Used for clocks that have the same value as the parent clock,
728804 * divided by some factor
729805 */
730−unsigned long omap_fixed_divisor_recalc(struct clk *clk)
806+unsigned long omap_fixed_divisor_recalc(struct omap1_clk *clk, unsigned long p_rate)
731807 {
732808 WARN_ON(!clk->fixed_div);
733809
734− return clk->parent->rate / clk->fixed_div;
810+ return p_rate / clk->fixed_div;
735811 }
736812
737813 /* Propagate rate to children */
738−void propagate_rate(struct clk *tclk)
814+void propagate_rate(struct omap1_clk *tclk)
739815 {
740816 struct clk *clkp;
741817
742− list_for_each_entry(clkp, &tclk->children, sibling) {
743− if (clkp->recalc)
744− clkp->rate = clkp->recalc(clkp);
745− propagate_rate(clkp);
746− }
747−}
748−
749−static LIST_HEAD(root_clks);
750−
751−/**
752− * clk_preinit - initialize any fields in the struct clk before clk init
753− * @clk: struct clk * to initialize
754− *
755− * Initialize any struct clk fields needed before normal clk initialization
756− * can run. No return value.
757− */
758−void clk_preinit(struct clk *clk)
759−{
760− INIT_LIST_HEAD(&clk->children);
761−}
762−
763−int clk_register(struct clk *clk)
764−{
765− if (IS_ERR_OR_NULL(clk))
766− return -EINVAL;
767−
768− /*
769− * trap out already registered clocks
770− */
771− if (clk->node.next || clk->node.prev)
772− return 0;
773−
774− mutex_lock(&clocks_mutex);
775− if (clk->parent)
776− list_add(&clk->sibling, &clk->parent->children);
777− else
778− list_add(&clk->sibling, &root_clks);
779−
780− list_add(&clk->node, &clocks);
781− if (clk->init)
782− clk->init(clk);
783− mutex_unlock(&clocks_mutex);
784−
785− return 0;
786−}
787−EXPORT_SYMBOL(clk_register);
788−
789−void clk_unregister(struct clk *clk)
790−{
791− if (IS_ERR_OR_NULL(clk))
818+ /* depend on CCF ability to recalculate new rates across whole clock subtree */
819+ if (WARN_ON(!(clk_hw_get_flags(&tclk->hw) & CLK_GET_RATE_NOCACHE)))
792820 return;
793821
794− mutex_lock(&clocks_mutex);
795− list_del(&clk->sibling);
796− list_del(&clk->node);
797− mutex_unlock(&clocks_mutex);
798−}
799−EXPORT_SYMBOL(clk_unregister);
800−
801−/*
802− * Low level helpers
803− */
804−static int clkll_enable_null(struct clk *clk)
805−{
806− return 0;
807−}
822+ clkp = clk_get_sys(NULL, clk_hw_get_name(&tclk->hw));
823+ if (WARN_ON(!clkp))
824+ return;
808825
809−static void clkll_disable_null(struct clk *clk)
810−{
826+ clk_get_rate(clkp);
827+ clk_put(clkp);
811828 }
812829
813−const struct clkops clkops_null = {
814− .enable = clkll_enable_null,
815− .disable = clkll_disable_null,
830+const struct clk_ops omap1_clk_null_ops = {
816831 };
817832
818833 /*
@@ -820,114 +835,6 @@ const struct clkops clkops_null = { · 1 unmodified line
820835 *
821836 * Used for clock aliases that are needed on some OMAPs, but not others
822837 */
823−struct clk dummy_ck = {
824− .name = "dummy",
825− .ops = &clkops_null,
838+struct omap1_clk dummy_ck __refdata = {
839+ .hw.init = CLK_HW_INIT_NO_PARENT("dummy", &omap1_clk_null_ops, 0),
826840 };
827−
828−/*
829− *
830− */
831−
832−#ifdef CONFIG_OMAP_RESET_CLOCKS
833−/*
834− * Disable any unused clocks left on by the bootloader
835− */
836−static int __init clk_disable_unused(void)
837−{
838− struct clk *ck;
839− unsigned long flags;
840−
841− pr_info("clock: disabling unused clocks to save power\n");
842−
843− spin_lock_irqsave(&clockfw_lock, flags);
844− list_for_each_entry(ck, &clocks, node) {
845− if (ck->ops == &clkops_null)
846− continue;
847−
848− if (ck->usecount > 0 || !ck->enable_reg)
849− continue;
850−
851− omap1_clk_disable_unused(ck);
852− }
853− spin_unlock_irqrestore(&clockfw_lock, flags);
854−
855− return 0;
856−}
857−late_initcall(clk_disable_unused);
858−#endif
859−
860−#if defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS)
861−/*
862− * debugfs support to trace clock tree hierarchy and attributes
863− */
864−
865−#include <linux/debugfs.h>
866−#include <linux/seq_file.h>
867−
868−static struct dentry *clk_debugfs_root;
869−
870−static int debug_clock_show(struct seq_file *s, void *unused)
871−{
872− struct clk *c;
873− struct clk *pa;
874−
875− mutex_lock(&clocks_mutex);
876− seq_printf(s, "%-30s %-30s %-10s %s\n",
877− "clock-name", "parent-name", "rate", "use-count");
878−
879− list_for_each_entry(c, &clocks, node) {
880− pa = c->parent;
881− seq_printf(s, "%-30s %-30s %-10lu %d\n",
882− c->name, pa ? pa->name : "none", c->rate,
883− c->usecount);
884− }
885− mutex_unlock(&clocks_mutex);
886−
887− return 0;
888−}
889−
890−DEFINE_SHOW_ATTRIBUTE(debug_clock);
891−
892−static void clk_debugfs_register_one(struct clk *c)
893−{
894− struct dentry *d;
895− struct clk *pa = c->parent;
896−
897− d = debugfs_create_dir(c->name, pa ? pa->dent : clk_debugfs_root);
898− c->dent = d;
899−
900− debugfs_create_u8("usecount", S_IRUGO, c->dent, &c->usecount);
901− debugfs_create_ulong("rate", S_IRUGO, c->dent, &c->rate);
902− debugfs_create_x8("flags", S_IRUGO, c->dent, &c->flags);
903−}
904−
905−static void clk_debugfs_register(struct clk *c)
906−{
907− struct clk *pa = c->parent;
908−
909− if (pa && !pa->dent)
910− clk_debugfs_register(pa);
911−
912− if (!c->dent)
913− clk_debugfs_register_one(c);
914−}
915−
916−static int __init clk_debugfs_init(void)
917−{
918− struct clk *c;
919− struct dentry *d;
920−
921− d = debugfs_create_dir("clock", NULL);
922− clk_debugfs_root = d;
923−
924− list_for_each_entry(c, &clocks, node)
925− clk_debugfs_register(c);
926−
927− debugfs_create_file("summary", S_IRUGO, d, NULL, &debug_clock_fops);
928−
929− return 0;
930−}
931−late_initcall(clk_debugfs_init);
932−
933−#endif /* defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS) */
arch/arm/mach-omap1/clock.h+49−90
@@ -11,12 +11,11 @@ · 10 unmodified lines
1111 #define __ARCH_ARM_MACH_OMAP1_CLOCK_H
1212
1313 #include <linux/clk.h>
14−#include <linux/list.h>
15−
1614 #include <linux/clkdev.h>
15+#include <linux/clk-provider.h>
1716
1817 struct module;
19−struct clk;
18+struct omap1_clk;
2019
2120 struct omap_clk {
2221 u16 cpu;
@@ -29,7 +28,7 @@ struct omap_clk { · 6 unmodified lines
2928 .lk = { \
3029 .dev_id = dev, \
3130 .con_id = con, \
32− .clk = ck, \
31+ .clk_hw = ck, \
3332 }, \
3433 }
3534
@@ -40,10 +39,6 @@ struct omap_clk { · 4 unmodified lines
4039 #define CK_16XX (1 << 3) /* 16xx, 17xx, 5912 */
4140 #define CK_1710 (1 << 4) /* 1710 extra for rate selection */
4241
43−
44−/* Temporary, needed during the common clock framework conversion */
45−#define __clk_get_name(clk) (clk->name)
46−
4742 /**
4843 * struct clkops - some clock function pointers
4944 * @enable: fn ptr that enables the current clock in hardware
@@ -51,8 +46,8 @@ struct omap_clk { · 1 unmodified line
5146 * @allow_idle: fn ptr that enables autoidle for the current clock in hardware
5247 */
5348 struct clkops {
54− int (*enable)(struct clk *);
55− void (*disable)(struct clk *);
49+ int (*enable)(struct omap1_clk *clk);
50+ void (*disable)(struct omap1_clk *clk);
5651 };
5752
5853 /*
@@ -65,13 +60,9 @@ struct clkops { · 6 unmodified lines
6560 #define CLOCK_NO_IDLE_PARENT (1 << 2)
6661
6762 /**
68− * struct clk - OMAP struct clk
69− * @node: list_head connecting this clock into the full clock list
63+ * struct omap1_clk - OMAP1 struct clk
64+ * @hw: struct clk_hw for common clock framework integration
7065 * @ops: struct clkops * for this clock
71− * @name: the name of the clock in the hardware (used in hwmod data and debug)
72− * @parent: pointer to this clock's parent struct clk
73− * @children: list_head connecting to the child clks' @sibling list_heads
74− * @sibling: list_head connecting this clk to its parent clk's @children
7566 * @rate: current clock rate
7667 * @enable_reg: register to write to enable the clock (see @enable_bit)
7768 * @recalc: fn ptr that returns the clock's current rate
@@ -79,102 +70,65 @@ struct clkops { · 1 unmodified line
7970 * @round_rate: fn ptr that can round the clock's current rate
8071 * @init: fn ptr to do clock-specific initialization
8172 * @enable_bit: bitshift to write to enable/disable the clock (see @enable_reg)
82− * @usecount: number of users that have requested this clock to be enabled
8373 * @fixed_div: when > 0, this clock's rate is its parent's rate / @fixed_div
8474 * @flags: see "struct clk.flags possibilities" above
8575 * @rate_offset: bitshift for rate selection bitfield (OMAP1 only)
86− *
87− * XXX @rate_offset should probably be removed and OMAP1
88− * clock code converted to use clksel.
89− *
90− * XXX @usecount is poorly named. It should be "enable_count" or
91− * something similar. "users" in the description refers to kernel
92− * code (core code or drivers) that have called clk_enable() and not
93− * yet called clk_disable(); the usecount of parent clocks is also
94− * incremented by the clock code when clk_enable() is called on child
95− * clocks and decremented by the clock code when clk_disable() is
96− * called on child clocks.
97− *
98− * XXX @usecount, @children, @sibling should be marked for
99− * internal use only.
100− *
101− * @children and @sibling are used to optimize parent-to-child clock
102− * tree traversals. (child-to-parent traversals use @parent.)
103− *
104− * XXX The notion of the clock's current rate probably needs to be
105− * separated from the clock's target rate.
10676 */
107−struct clk {
108− struct list_head node;
77+struct omap1_clk {
78+ struct clk_hw hw;
10979 const struct clkops *ops;
110− const char *name;
111− struct clk *parent;
112− struct list_head children;
113− struct list_head sibling; /* node for children */
11480 unsigned long rate;
11581 void __iomem *enable_reg;
116− unsigned long (*recalc)(struct clk *);
117− int (*set_rate)(struct clk *, unsigned long);
118− long (*round_rate)(struct clk *, unsigned long);
119− void (*init)(struct clk *);
82+ unsigned long (*recalc)(struct omap1_clk *clk, unsigned long rate);
83+ int (*set_rate)(struct omap1_clk *clk, unsigned long rate,
84+ unsigned long p_rate);
85+ long (*round_rate)(struct omap1_clk *clk, unsigned long rate,
86+ unsigned long *p_rate);
87+ int (*init)(struct omap1_clk *clk);
12088 u8 enable_bit;
121− s8 usecount;
12289 u8 fixed_div;
12390 u8 flags;
12491 u8 rate_offset;
125−#if defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS)
126− struct dentry *dent; /* For visible tree hierarchy */
127−#endif
12892 };
93+#define to_omap1_clk(_hw) container_of(_hw, struct omap1_clk, hw)
12994
130−extern void clk_preinit(struct clk *clk);
131−extern int clk_register(struct clk *clk);
132−extern void clk_unregister(struct clk *clk);
133−extern void propagate_rate(struct clk *clk);
134−extern unsigned long followparent_recalc(struct clk *clk);
135−unsigned long omap_fixed_divisor_recalc(struct clk *clk);
95+void propagate_rate(struct omap1_clk *clk);
96+unsigned long followparent_recalc(struct omap1_clk *clk, unsigned long p_rate);
97+unsigned long omap_fixed_divisor_recalc(struct omap1_clk *clk, unsigned long p_rate);
13698
137−extern const struct clkops clkops_null;
138−
139−extern struct clk dummy_ck;
99+extern struct omap1_clk dummy_ck;
140100
141101 int omap1_clk_init(void);
142102 void omap1_clk_late_init(void);
143−extern int omap1_clk_enable(struct clk *clk);
144−extern void omap1_clk_disable(struct clk *clk);
145−extern long omap1_clk_round_rate(struct clk *clk, unsigned long rate);
146−extern int omap1_clk_set_rate(struct clk *clk, unsigned long rate);
147−extern unsigned long omap1_ckctl_recalc(struct clk *clk);
148−extern int omap1_set_sossi_rate(struct clk *clk, unsigned long rate);
149−extern unsigned long omap1_sossi_recalc(struct clk *clk);
150−extern unsigned long omap1_ckctl_recalc_dsp_domain(struct clk *clk);
151−extern int omap1_clk_set_rate_dsp_domain(struct clk *clk, unsigned long rate);
152−extern int omap1_set_uart_rate(struct clk *clk, unsigned long rate);
153−extern unsigned long omap1_uart_recalc(struct clk *clk);
154−extern int omap1_set_ext_clk_rate(struct clk *clk, unsigned long rate);
155−extern long omap1_round_ext_clk_rate(struct clk *clk, unsigned long rate);
156−extern void omap1_init_ext_clk(struct clk *clk);
157−extern int omap1_select_table_rate(struct clk *clk, unsigned long rate);
158−extern long omap1_round_to_table_rate(struct clk *clk, unsigned long rate);
159−extern int omap1_clk_set_rate_ckctl_arm(struct clk *clk, unsigned long rate);
160−extern long omap1_clk_round_rate_ckctl_arm(struct clk *clk, unsigned long rate);
161−
162−#ifdef CONFIG_OMAP_RESET_CLOCKS
163−extern void omap1_clk_disable_unused(struct clk *clk);
164−#else
165−#define omap1_clk_disable_unused NULL
166−#endif
103+unsigned long omap1_ckctl_recalc(struct omap1_clk *clk, unsigned long p_rate);
104+long omap1_round_sossi_rate(struct omap1_clk *clk, unsigned long rate, unsigned long *p_rate);
105+int omap1_set_sossi_rate(struct omap1_clk *clk, unsigned long rate, unsigned long p_rate);
106+unsigned long omap1_sossi_recalc(struct omap1_clk *clk, unsigned long p_rate);
107+unsigned long omap1_ckctl_recalc_dsp_domain(struct omap1_clk *clk, unsigned long p_rate);
108+int omap1_clk_set_rate_dsp_domain(struct omap1_clk *clk, unsigned long rate,
109+ unsigned long p_rate);
110+long omap1_round_uart_rate(struct omap1_clk *clk, unsigned long rate, unsigned long *p_rate);
111+int omap1_set_uart_rate(struct omap1_clk *clk, unsigned long rate, unsigned long p_rate);
112+unsigned long omap1_uart_recalc(struct omap1_clk *clk, unsigned long p_rate);
113+int omap1_set_ext_clk_rate(struct omap1_clk *clk, unsigned long rate, unsigned long p_rate);
114+long omap1_round_ext_clk_rate(struct omap1_clk *clk, unsigned long rate, unsigned long *p_rate);
115+int omap1_init_ext_clk(struct omap1_clk *clk);
116+int omap1_select_table_rate(struct omap1_clk *clk, unsigned long rate, unsigned long p_rate);
117+long omap1_round_to_table_rate(struct omap1_clk *clk, unsigned long rate, unsigned long *p_rate);
118+int omap1_clk_set_rate_ckctl_arm(struct omap1_clk *clk, unsigned long rate, unsigned long p_rate);
119+long omap1_clk_round_rate_ckctl_arm(struct omap1_clk *clk, unsigned long rate,
120+ unsigned long *p_rate);
167121
168122 struct uart_clk {
169− struct clk clk;
170− unsigned long sysc_addr;
123+ struct omap1_clk clk;
124+ unsigned long sysc_addr;
171125 };
172126
173127 /* Provide a method for preventing idling some ARM IDLECT clocks */
174128 struct arm_idlect1_clk {
175− struct clk clk;
176− unsigned long no_idle_count;
177− __u8 idlect_shift;
129+ struct omap1_clk clk;
130+ unsigned long no_idle_count;
131+ __u8 idlect_shift;
178132 };
179133
180134 /* ARM_CKCTL bit shifts */
@@ -224,7 +178,7 @@ struct arm_idlect1_clk { · 43 unmodified lines
224178 #define SOFT_REQ_REG2 0xfffe0880
225179
226180 extern __u32 arm_idlect1_mask;
227−extern struct clk *api_ck_p, *ck_dpll1_p, *ck_ref_p;
181+extern struct omap1_clk *api_ck_p, *ck_dpll1_p, *ck_ref_p;
228182
229183 extern const struct clkops clkops_dspck;
230184 extern const struct clkops clkops_uart_16xx;
@@ -233,4 +187,9 @@ extern const struct clkops clkops_generic; · 2 unmodified lines
233187 /* used for passing SoC type to omap1_{select,round_to}_table_rate() */
234188 extern u32 cpu_mask;
235189
190+extern const struct clk_ops omap1_clk_null_ops;
191+extern const struct clk_ops omap1_clk_gate_ops;
192+extern const struct clk_ops omap1_clk_rate_ops;
193+extern const struct clk_ops omap1_clk_full_ops;
194+
236195 #endif
arch/arm/mach-omap1/clock_data.c+209−274
@@ -14,6 +14,8 @@ · 13 unmodified lines
1414 #include <linux/kernel.h>
1515 #include <linux/io.h>
1616 #include <linux/clk.h>
17+#include <linux/clkdev.h>
18+#include <linux/clk-provider.h>
1719 #include <linux/cpufreq.h>
1820 #include <linux/delay.h>
1921 #include <linux/soc/ti/omap1-io.h>
@@ -71,16 +73,18 @@ · 51 unmodified lines
7173 * Omap1 clocks
7274 */
7375
74−static struct clk ck_ref = {
75− .name = "ck_ref",
76− .ops = &clkops_null,
76+static struct omap1_clk ck_ref = {
77+ .hw.init = CLK_HW_INIT_NO_PARENT("ck_ref", &omap1_clk_rate_ops, 0),
7778 .rate = 12000000,
7879 };
7980
80−static struct clk ck_dpll1 = {
81− .name = "ck_dpll1",
82− .ops = &clkops_null,
83− .parent = &ck_ref,
81+static struct omap1_clk ck_dpll1 = {
82+ .hw.init = CLK_HW_INIT("ck_dpll1", "ck_ref", &omap1_clk_rate_ops,
83+ /*
84+ * force recursive refresh of rates of the clock
85+ * and its children when clk_get_rate() is called
86+ */
87+ CLK_GET_RATE_NOCACHE),
8488 };
8589
8690 /*
@@ -89,32 +93,28 @@ static struct clk ck_dpll1 = { · 2 unmodified lines
8993 */
9094 static struct arm_idlect1_clk ck_dpll1out = {
9195 .clk = {
92− .name = "ck_dpll1out",
96+ .hw.init = CLK_HW_INIT("ck_dpll1out", "ck_dpll1", &omap1_clk_gate_ops, 0),
9397 .ops = &clkops_generic,
94− .parent = &ck_dpll1,
9598 .flags = CLOCK_IDLE_CONTROL | ENABLE_REG_32BIT,
9699 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
97100 .enable_bit = EN_CKOUT_ARM,
98− .recalc = &followparent_recalc,
99101 },
100102 .idlect_shift = IDL_CLKOUT_ARM_SHIFT,
101103 };
102104
103−static struct clk sossi_ck = {
104− .name = "ck_sossi",
105+static struct omap1_clk sossi_ck = {
106+ .hw.init = CLK_HW_INIT("ck_sossi", "ck_dpll1out", &omap1_clk_full_ops, 0),
105107 .ops = &clkops_generic,
106− .parent = &ck_dpll1out.clk,
107108 .flags = CLOCK_NO_IDLE_PARENT | ENABLE_REG_32BIT,
108109 .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_1),
109110 .enable_bit = CONF_MOD_SOSSI_CLK_EN_R,
110111 .recalc = &omap1_sossi_recalc,
112+ .round_rate = &omap1_round_sossi_rate,
111113 .set_rate = &omap1_set_sossi_rate,
112114 };
113115
114−static struct clk arm_ck = {
115− .name = "arm_ck",
116− .ops = &clkops_null,
117− .parent = &ck_dpll1,
116+static struct omap1_clk arm_ck = {
117+ .hw.init = CLK_HW_INIT("arm_ck", "ck_dpll1", &omap1_clk_rate_ops, 0),
118118 .rate_offset = CKCTL_ARMDIV_OFFSET,
119119 .recalc = &omap1_ckctl_recalc,
120120 .round_rate = omap1_clk_round_rate_ckctl_arm,
@@ -123,9 +123,9 @@ static struct clk arm_ck = { · 2 unmodified lines
123123
124124 static struct arm_idlect1_clk armper_ck = {
125125 .clk = {
126− .name = "armper_ck",
126+ .hw.init = CLK_HW_INIT("armper_ck", "ck_dpll1", &omap1_clk_full_ops,
127+ CLK_IS_CRITICAL),
127128 .ops = &clkops_generic,
128− .parent = &ck_dpll1,
129129 .flags = CLOCK_IDLE_CONTROL,
130130 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
131131 .enable_bit = EN_PERCK,
@@ -141,46 +141,41 @@ static struct arm_idlect1_clk armper_ck = { · 9 unmodified lines
141141 * FIXME: This clock seems to be necessary but no-one has asked for its
142142 * activation. [ GPIO code for 1510 ]
143143 */
144−static struct clk arm_gpio_ck = {
145− .name = "ick",
144+static struct omap1_clk arm_gpio_ck = {
145+ .hw.init = CLK_HW_INIT("ick", "ck_dpll1", &omap1_clk_gate_ops, CLK_IS_CRITICAL),
146146 .ops = &clkops_generic,
147− .parent = &ck_dpll1,
148147 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
149148 .enable_bit = EN_GPIOCK,
150− .recalc = &followparent_recalc,
151149 };
152150
153151 static struct arm_idlect1_clk armxor_ck = {
154152 .clk = {
155− .name = "armxor_ck",
153+ .hw.init = CLK_HW_INIT("armxor_ck", "ck_ref", &omap1_clk_gate_ops,
154+ CLK_IS_CRITICAL),
156155 .ops = &clkops_generic,
157− .parent = &ck_ref,
158156 .flags = CLOCK_IDLE_CONTROL,
159157 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
160158 .enable_bit = EN_XORPCK,
161− .recalc = &followparent_recalc,
162159 },
163160 .idlect_shift = IDLXORP_ARM_SHIFT,
164161 };
165162
166163 static struct arm_idlect1_clk armtim_ck = {
167164 .clk = {
168− .name = "armtim_ck",
165+ .hw.init = CLK_HW_INIT("armtim_ck", "ck_ref", &omap1_clk_gate_ops,
166+ CLK_IS_CRITICAL),
169167 .ops = &clkops_generic,
170− .parent = &ck_ref,
171168 .flags = CLOCK_IDLE_CONTROL,
172169 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
173170 .enable_bit = EN_TIMCK,
174− .recalc = &followparent_recalc,
175171 },
176172 .idlect_shift = IDLTIM_ARM_SHIFT,
177173 };
178174
179175 static struct arm_idlect1_clk armwdt_ck = {
180176 .clk = {
181− .name = "armwdt_ck",
177+ .hw.init = CLK_HW_INIT("armwdt_ck", "ck_ref", &omap1_clk_full_ops, 0),
182178 .ops = &clkops_generic,
183− .parent = &ck_ref,
184179 .flags = CLOCK_IDLE_CONTROL,
185180 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
186181 .enable_bit = EN_WDTCK,
@@ -190,11 +185,8 @@ static struct arm_idlect1_clk armwdt_ck = { · 3 unmodified lines
190185 .idlect_shift = IDLWDT_ARM_SHIFT,
191186 };
192187
193−static struct clk arminth_ck16xx = {
194− .name = "arminth_ck",
195− .ops = &clkops_null,
196− .parent = &arm_ck,
197− .recalc = &followparent_recalc,
188+static struct omap1_clk arminth_ck16xx = {
189+ .hw.init = CLK_HW_INIT("arminth_ck", "arm_ck", &omap1_clk_null_ops, 0),
198190 /* Note: On 16xx the frequency can be divided by 2 by programming
199191 * ARM_CKCTL:ARM_INTHCK_SEL(14) to 1
200192 *
@@ -202,10 +194,9 @@ static struct clk arminth_ck16xx = { · 1 unmodified line
202194 */
203195 };
204196
205−static struct clk dsp_ck = {
206− .name = "dsp_ck",
197+static struct omap1_clk dsp_ck = {
198+ .hw.init = CLK_HW_INIT("dsp_ck", "ck_dpll1", &omap1_clk_full_ops, 0),
207199 .ops = &clkops_generic,
208− .parent = &ck_dpll1,
209200 .enable_reg = OMAP1_IO_ADDRESS(ARM_CKCTL),
210201 .enable_bit = EN_DSPCK,
211202 .rate_offset = CKCTL_DSPDIV_OFFSET,
@@ -214,20 +205,17 @@ static struct clk dsp_ck = { · 2 unmodified lines
214205 .set_rate = omap1_clk_set_rate_ckctl_arm,
215206 };
216207
217−static struct clk dspmmu_ck = {
218− .name = "dspmmu_ck",
219− .ops = &clkops_null,
220− .parent = &ck_dpll1,
208+static struct omap1_clk dspmmu_ck = {
209+ .hw.init = CLK_HW_INIT("dspmmu_ck", "ck_dpll1", &omap1_clk_rate_ops, 0),
221210 .rate_offset = CKCTL_DSPMMUDIV_OFFSET,
222211 .recalc = &omap1_ckctl_recalc,
223212 .round_rate = omap1_clk_round_rate_ckctl_arm,
224213 .set_rate = omap1_clk_set_rate_ckctl_arm,
225214 };
226215
227−static struct clk dspper_ck = {
228− .name = "dspper_ck",
216+static struct omap1_clk dspper_ck = {
217+ .hw.init = CLK_HW_INIT("dspper_ck", "ck_dpll1", &omap1_clk_full_ops, 0),
229218 .ops = &clkops_dspck,
230− .parent = &ck_dpll1,
231219 .enable_reg = DSP_IDLECT2,
232220 .enable_bit = EN_PERCK,
233221 .rate_offset = CKCTL_PERDIV_OFFSET,
@@ -236,29 +224,23 @@ static struct clk dspper_ck = { · 2 unmodified lines
236224 .set_rate = &omap1_clk_set_rate_dsp_domain,
237225 };
238226
239−static struct clk dspxor_ck = {
240− .name = "dspxor_ck",
227+static struct omap1_clk dspxor_ck = {
228+ .hw.init = CLK_HW_INIT("dspxor_ck", "ck_ref", &omap1_clk_gate_ops, 0),
241229 .ops = &clkops_dspck,
242− .parent = &ck_ref,
243230 .enable_reg = DSP_IDLECT2,
244231 .enable_bit = EN_XORPCK,
245− .recalc = &followparent_recalc,
246232 };
247233
248−static struct clk dsptim_ck = {
249− .name = "dsptim_ck",
234+static struct omap1_clk dsptim_ck = {
235+ .hw.init = CLK_HW_INIT("dsptim_ck", "ck_ref", &omap1_clk_gate_ops, 0),
250236 .ops = &clkops_dspck,
251− .parent = &ck_ref,
252237 .enable_reg = DSP_IDLECT2,
253238 .enable_bit = EN_DSPTIMCK,
254− .recalc = &followparent_recalc,
255239 };
256240
257241 static struct arm_idlect1_clk tc_ck = {
258242 .clk = {
259− .name = "tc_ck",
260− .ops = &clkops_null,
261− .parent = &ck_dpll1,
243+ .hw.init = CLK_HW_INIT("tc_ck", "ck_dpll1", &omap1_clk_rate_ops, 0),
262244 .flags = CLOCK_IDLE_CONTROL,
263245 .rate_offset = CKCTL_TCDIV_OFFSET,
264246 .recalc = &omap1_ckctl_recalc,
@@ -268,116 +250,88 @@ static struct arm_idlect1_clk tc_ck = { · 3 unmodified lines
268250 .idlect_shift = IDLIF_ARM_SHIFT,
269251 };
270252
271−static struct clk arminth_ck1510 = {
272− .name = "arminth_ck",
273− .ops = &clkops_null,
274− .parent = &tc_ck.clk,
275− .recalc = &followparent_recalc,
253+static struct omap1_clk arminth_ck1510 = {
254+ .hw.init = CLK_HW_INIT("arminth_ck", "tc_ck", &omap1_clk_null_ops, 0),
276255 /* Note: On 1510 the frequency follows TC_CK
277256 *
278257 * 16xx version is in MPU clocks.
279258 */
280259 };
281260
282−static struct clk tipb_ck = {
261+static struct omap1_clk tipb_ck = {
283262 /* No-idle controlled by "tc_ck" */
284− .name = "tipb_ck",
285− .ops = &clkops_null,
286− .parent = &tc_ck.clk,
287− .recalc = &followparent_recalc,
263+ .hw.init = CLK_HW_INIT("tipb_ck", "tc_ck", &omap1_clk_null_ops, 0),
288264 };
289265
290−static struct clk l3_ocpi_ck = {
266+static struct omap1_clk l3_ocpi_ck = {
291267 /* No-idle controlled by "tc_ck" */
292− .name = "l3_ocpi_ck",
268+ .hw.init = CLK_HW_INIT("l3_ocpi_ck", "tc_ck", &omap1_clk_gate_ops, 0),
293269 .ops = &clkops_generic,
294− .parent = &tc_ck.clk,
295270 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT3),
296271 .enable_bit = EN_OCPI_CK,
297− .recalc = &followparent_recalc,
298272 };
299273
300−static struct clk tc1_ck = {
301− .name = "tc1_ck",
274+static struct omap1_clk tc1_ck = {
275+ .hw.init = CLK_HW_INIT("tc1_ck", "tc_ck", &omap1_clk_gate_ops, 0),
302276 .ops = &clkops_generic,
303− .parent = &tc_ck.clk,
304277 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT3),
305278 .enable_bit = EN_TC1_CK,
306− .recalc = &followparent_recalc,
307279 };
308280
309281 /*
310282 * FIXME: This clock seems to be necessary but no-one has asked for its
311283 * activation. [ pm.c (SRAM), CCP, Camera ]
312284 */
313−static struct clk tc2_ck = {
314− .name = "tc2_ck",
285+
286+static struct omap1_clk tc2_ck = {
287+ .hw.init = CLK_HW_INIT("tc2_ck", "tc_ck", &omap1_clk_gate_ops, CLK_IS_CRITICAL),
315288 .ops = &clkops_generic,
316− .parent = &tc_ck.clk,
317289 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT3),
318290 .enable_bit = EN_TC2_CK,
319− .recalc = &followparent_recalc,
320291 };
321292
322−static struct clk dma_ck = {
293+static struct omap1_clk dma_ck = {
323294 /* No-idle controlled by "tc_ck" */
324− .name = "dma_ck",
325− .ops = &clkops_null,
326− .parent = &tc_ck.clk,
327− .recalc = &followparent_recalc,
295+ .hw.init = CLK_HW_INIT("dma_ck", "tc_ck", &omap1_clk_null_ops, 0),
328296 };
329297
330−static struct clk dma_lcdfree_ck = {
331− .name = "dma_lcdfree_ck",
332− .ops = &clkops_null,
333− .parent = &tc_ck.clk,
334− .recalc = &followparent_recalc,
298+static struct omap1_clk dma_lcdfree_ck = {
299+ .hw.init = CLK_HW_INIT("dma_lcdfree_ck", "tc_ck", &omap1_clk_null_ops, 0),
335300 };
336301
337302 static struct arm_idlect1_clk api_ck = {
338303 .clk = {
339− .name = "api_ck",
304+ .hw.init = CLK_HW_INIT("api_ck", "tc_ck", &omap1_clk_gate_ops, 0),
340305 .ops = &clkops_generic,
341− .parent = &tc_ck.clk,
342306 .flags = CLOCK_IDLE_CONTROL,
343307 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
344308 .enable_bit = EN_APICK,
345− .recalc = &followparent_recalc,
346309 },
347310 .idlect_shift = IDLAPI_ARM_SHIFT,
348311 };
349312
350313 static struct arm_idlect1_clk lb_ck = {
351314 .clk = {
352− .name = "lb_ck",
315+ .hw.init = CLK_HW_INIT("lb_ck", "tc_ck", &omap1_clk_gate_ops, 0),
353316 .ops = &clkops_generic,
354− .parent = &tc_ck.clk,
355317 .flags = CLOCK_IDLE_CONTROL,
356318 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
357319 .enable_bit = EN_LBCK,
358− .recalc = &followparent_recalc,
359320 },
360321 .idlect_shift = IDLLB_ARM_SHIFT,
361322 };
362323
363−static struct clk rhea1_ck = {
364− .name = "rhea1_ck",
365− .ops = &clkops_null,
366− .parent = &tc_ck.clk,
367− .recalc = &followparent_recalc,
324+static struct omap1_clk rhea1_ck = {
325+ .hw.init = CLK_HW_INIT("rhea1_ck", "tc_ck", &omap1_clk_null_ops, 0),
368326 };
369327
370−static struct clk rhea2_ck = {
371− .name = "rhea2_ck",
372− .ops = &clkops_null,
373− .parent = &tc_ck.clk,
374− .recalc = &followparent_recalc,
328+static struct omap1_clk rhea2_ck = {
329+ .hw.init = CLK_HW_INIT("rhea2_ck", "tc_ck", &omap1_clk_null_ops, 0),
375330 };
376331
377−static struct clk lcd_ck_16xx = {
378− .name = "lcd_ck",
332+static struct omap1_clk lcd_ck_16xx = {
333+ .hw.init = CLK_HW_INIT("lcd_ck", "ck_dpll1", &omap1_clk_full_ops, 0),
379334 .ops = &clkops_generic,
380− .parent = &ck_dpll1,
381335 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
382336 .enable_bit = EN_LCDCK,
383337 .rate_offset = CKCTL_LCDDIV_OFFSET,
@@ -388,9 +342,8 @@ static struct clk lcd_ck_16xx = { · 4 unmodified lines
388342
389343 static struct arm_idlect1_clk lcd_ck_1510 = {
390344 .clk = {
391− .name = "lcd_ck",
345+ .hw.init = CLK_HW_INIT("lcd_ck", "ck_dpll1", &omap1_clk_full_ops, 0),
392346 .ops = &clkops_generic,
393− .parent = &ck_dpll1,
394347 .flags = CLOCK_IDLE_CONTROL,
395348 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
396349 .enable_bit = EN_LCDCK,
@@ -402,37 +355,35 @@ static struct arm_idlect1_clk lcd_ck_1510 = { · 5 unmodified lines
402355 .idlect_shift = OMAP1510_IDLLCD_ARM_SHIFT,
403356 };
404357
358+
405359 /*
406360 * XXX The enable_bit here is misused - it simply switches between 12MHz
407− * and 48MHz. Reimplement with clksel.
361+ * and 48MHz. Reimplement with clk_mux.
408362 *
409363 * XXX does this need SYSC register handling?
410364 */
411−static struct clk uart1_1510 = {
412− .name = "uart1_ck",
413− .ops = &clkops_null,
365+static struct omap1_clk uart1_1510 = {
414366 /* Direct from ULPD, no real parent */
415− .parent = &armper_ck.clk,
416− .rate = 12000000,
367+ .hw.init = CLK_HW_INIT("uart1_ck", "armper_ck", &omap1_clk_full_ops, 0),
417368 .flags = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
418369 .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
419370 .enable_bit = CONF_MOD_UART1_CLK_MODE_R,
371+ .round_rate = &omap1_round_uart_rate,
420372 .set_rate = &omap1_set_uart_rate,
421373 .recalc = &omap1_uart_recalc,
422374 };
423375
424376 /*
425377 * XXX The enable_bit here is misused - it simply switches between 12MHz
426− * and 48MHz. Reimplement with clksel.
378+ * and 48MHz. Reimplement with clk_mux.
427379 *
428380 * XXX SYSC register handling does not belong in the clock framework
429381 */
430382 static struct uart_clk uart1_16xx = {
431383 .clk = {
432− .name = "uart1_ck",
433384 .ops = &clkops_uart_16xx,
434385 /* Direct from ULPD, no real parent */
435− .parent = &armper_ck.clk,
386+ .hw.init = CLK_HW_INIT("uart1_ck", "armper_ck", &omap1_clk_full_ops, 0),
436387 .rate = 48000000,
437388 .flags = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
438389 .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
@@ -443,54 +394,49 @@ static struct uart_clk uart1_16xx = { · 4 unmodified lines
443394
444395 /*
445396 * XXX The enable_bit here is misused - it simply switches between 12MHz
446− * and 48MHz. Reimplement with clksel.
397+ * and 48MHz. Reimplement with clk_mux.
447398 *
448399 * XXX does this need SYSC register handling?
449400 */
450−static struct clk uart2_ck = {
451− .name = "uart2_ck",
452− .ops = &clkops_null,
401+static struct omap1_clk uart2_ck = {
453402 /* Direct from ULPD, no real parent */
454− .parent = &armper_ck.clk,
455− .rate = 12000000,
403+ .hw.init = CLK_HW_INIT("uart2_ck", "armper_ck", &omap1_clk_full_ops, 0),
456404 .flags = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
457405 .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
458406 .enable_bit = CONF_MOD_UART2_CLK_MODE_R,
407+ .round_rate = &omap1_round_uart_rate,
459408 .set_rate = &omap1_set_uart_rate,
460409 .recalc = &omap1_uart_recalc,
461410 };
462411
463412 /*
464413 * XXX The enable_bit here is misused - it simply switches between 12MHz
465− * and 48MHz. Reimplement with clksel.
414+ * and 48MHz. Reimplement with clk_mux.
466415 *
467416 * XXX does this need SYSC register handling?
468417 */
469−static struct clk uart3_1510 = {
470− .name = "uart3_ck",
471− .ops = &clkops_null,
418+static struct omap1_clk uart3_1510 = {
472419 /* Direct from ULPD, no real parent */
473− .parent = &armper_ck.clk,
474− .rate = 12000000,
420+ .hw.init = CLK_HW_INIT("uart3_ck", "armper_ck", &omap1_clk_full_ops, 0),
475421 .flags = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
476422 .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
477423 .enable_bit = CONF_MOD_UART3_CLK_MODE_R,
424+ .round_rate = &omap1_round_uart_rate,
478425 .set_rate = &omap1_set_uart_rate,
479426 .recalc = &omap1_uart_recalc,
480427 };
481428
482429 /*
483430 * XXX The enable_bit here is misused - it simply switches between 12MHz
484− * and 48MHz. Reimplement with clksel.
431+ * and 48MHz. Reimplement with clk_mux.
485432 *
486433 * XXX SYSC register handling does not belong in the clock framework
487434 */
488435 static struct uart_clk uart3_16xx = {
489436 .clk = {
490− .name = "uart3_ck",
491437 .ops = &clkops_uart_16xx,
492438 /* Direct from ULPD, no real parent */
493− .parent = &armper_ck.clk,
439+ .hw.init = CLK_HW_INIT("uart3_ck", "armper_ck", &omap1_clk_full_ops, 0),
494440 .rate = 48000000,
495441 .flags = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
496442 .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
@@ -499,30 +445,30 @@ static struct uart_clk uart3_16xx = { · 2 unmodified lines
499445 .sysc_addr = 0xfffb9854,
500446 };
501447
502−static struct clk usb_clko = { /* 6 MHz output on W4_USB_CLKO */
503− .name = "usb_clko",
448+static struct omap1_clk usb_clko = { /* 6 MHz output on W4_USB_CLKO */
504449 .ops = &clkops_generic,
505450 /* Direct from ULPD, no parent */
451+ .hw.init = CLK_HW_INIT_NO_PARENT("usb_clko", &omap1_clk_full_ops, 0),
506452 .rate = 6000000,
507453 .flags = ENABLE_REG_32BIT,
508454 .enable_reg = OMAP1_IO_ADDRESS(ULPD_CLOCK_CTRL),
509455 .enable_bit = USB_MCLK_EN_BIT,
510456 };
511457
512−static struct clk usb_hhc_ck1510 = {
513− .name = "usb_hhc_ck",
458+static struct omap1_clk usb_hhc_ck1510 = {
514459 .ops = &clkops_generic,
515460 /* Direct from ULPD, no parent */
461+ .hw.init = CLK_HW_INIT_NO_PARENT("usb_hhc_ck", &omap1_clk_full_ops, 0),
516462 .rate = 48000000, /* Actually 2 clocks, 12MHz and 48MHz */
517463 .flags = ENABLE_REG_32BIT,
518464 .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
519465 .enable_bit = USB_HOST_HHC_UHOST_EN,
520466 };
521467
522−static struct clk usb_hhc_ck16xx = {
523− .name = "usb_hhc_ck",
468+static struct omap1_clk usb_hhc_ck16xx = {
524469 .ops = &clkops_generic,
525470 /* Direct from ULPD, no parent */
471+ .hw.init = CLK_HW_INIT_NO_PARENT("usb_hhc_ck", &omap1_clk_full_ops, 0),
526472 .rate = 48000000,
527473 /* OTG_SYSCON_2.OTG_PADEN == 0 (not 1510-compatible) */
528474 .flags = ENABLE_REG_32BIT,
@@ -530,46 +476,46 @@ static struct clk usb_hhc_ck16xx = { · 1 unmodified line
530476 .enable_bit = OTG_SYSCON_2_UHOST_EN_SHIFT
531477 };
532478
533−static struct clk usb_dc_ck = {
534− .name = "usb_dc_ck",
479+static struct omap1_clk usb_dc_ck = {
535480 .ops = &clkops_generic,
536481 /* Direct from ULPD, no parent */
482+ .hw.init = CLK_HW_INIT_NO_PARENT("usb_dc_ck", &omap1_clk_full_ops, 0),
537483 .rate = 48000000,
538484 .enable_reg = OMAP1_IO_ADDRESS(SOFT_REQ_REG),
539485 .enable_bit = SOFT_USB_OTG_DPLL_REQ_SHIFT,
540486 };
541487
542−static struct clk uart1_7xx = {
543− .name = "uart1_ck",
488+static struct omap1_clk uart1_7xx = {
544489 .ops = &clkops_generic,
545490 /* Direct from ULPD, no parent */
491+ .hw.init = CLK_HW_INIT_NO_PARENT("uart1_ck", &omap1_clk_full_ops, 0),
546492 .rate = 12000000,
547493 .enable_reg = OMAP1_IO_ADDRESS(SOFT_REQ_REG),
548494 .enable_bit = 9,
549495 };
550496
551−static struct clk uart2_7xx = {
552− .name = "uart2_ck",
497+static struct omap1_clk uart2_7xx = {
553498 .ops = &clkops_generic,
554499 /* Direct from ULPD, no parent */
500+ .hw.init = CLK_HW_INIT_NO_PARENT("uart2_ck", &omap1_clk_full_ops, 0),
555501 .rate = 12000000,
556502 .enable_reg = OMAP1_IO_ADDRESS(SOFT_REQ_REG),
557503 .enable_bit = 11,
558504 };
559505
560−static struct clk mclk_1510 = {
561− .name = "mclk",
506+static struct omap1_clk mclk_1510 = {
562507 .ops = &clkops_generic,
563508 /* Direct from ULPD, no parent. May be enabled by ext hardware. */
509+ .hw.init = CLK_HW_INIT_NO_PARENT("mclk", &omap1_clk_full_ops, 0),
564510 .rate = 12000000,
565511 .enable_reg = OMAP1_IO_ADDRESS(SOFT_REQ_REG),
566512 .enable_bit = SOFT_COM_MCKO_REQ_SHIFT,
567513 };
568514
569−static struct clk mclk_16xx = {
570− .name = "mclk",
515+static struct omap1_clk mclk_16xx = {
571516 .ops = &clkops_generic,
572517 /* Direct from ULPD, no parent. May be enabled by ext hardware. */
518+ .hw.init = CLK_HW_INIT_NO_PARENT("mclk", &omap1_clk_full_ops, 0),
573519 .enable_reg = OMAP1_IO_ADDRESS(COM_CLK_DIV_CTRL_SEL),
574520 .enable_bit = COM_ULPD_PLL_CLK_REQ,
575521 .set_rate = &omap1_set_ext_clk_rate,
@@ -577,17 +523,16 @@ static struct clk mclk_16xx = { · 1 unmodified line
577523 .init = &omap1_init_ext_clk,
578524 };
579525
580−static struct clk bclk_1510 = {
581− .name = "bclk",
582− .ops = &clkops_generic,
526+static struct omap1_clk bclk_1510 = {
583527 /* Direct from ULPD, no parent. May be enabled by ext hardware. */
528+ .hw.init = CLK_HW_INIT_NO_PARENT("bclk", &omap1_clk_rate_ops, 0),
584529 .rate = 12000000,
585530 };
586531
587−static struct clk bclk_16xx = {
588− .name = "bclk",
532+static struct omap1_clk bclk_16xx = {
589533 .ops = &clkops_generic,
590534 /* Direct from ULPD, no parent. May be enabled by ext hardware. */
535+ .hw.init = CLK_HW_INIT_NO_PARENT("bclk", &omap1_clk_full_ops, 0),
591536 .enable_reg = OMAP1_IO_ADDRESS(SWD_CLK_DIV_CTRL_SEL),
592537 .enable_bit = SWD_ULPD_PLL_CLK_REQ,
593538 .set_rate = &omap1_set_ext_clk_rate,
@@ -595,11 +540,10 @@ static struct clk bclk_16xx = { · 1 unmodified line
595540 .init = &omap1_init_ext_clk,
596541 };
597542
598−static struct clk mmc1_ck = {
599− .name = "mmc1_ck",
543+static struct omap1_clk mmc1_ck = {
600544 .ops = &clkops_generic,
601545 /* Functional clock is direct from ULPD, interface clock is ARMPER */
602− .parent = &armper_ck.clk,
546+ .hw.init = CLK_HW_INIT("mmc1_ck", "armper_ck", &omap1_clk_full_ops, 0),
603547 .rate = 48000000,
604548 .flags = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
605549 .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
@@ -610,32 +554,29 @@ static struct clk mmc1_ck = { · 4 unmodified lines
610554 * XXX MOD_CONF_CTRL_0 bit 20 is defined in the 1510 TRM as
611555 * CONF_MOD_MCBSP3_AUXON ??
612556 */
613−static struct clk mmc2_ck = {
614− .name = "mmc2_ck",
557+static struct omap1_clk mmc2_ck = {
615558 .ops = &clkops_generic,
616559 /* Functional clock is direct from ULPD, interface clock is ARMPER */
617− .parent = &armper_ck.clk,
560+ .hw.init = CLK_HW_INIT("mmc2_ck", "armper_ck", &omap1_clk_full_ops, 0),
618561 .rate = 48000000,
619562 .flags = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
620563 .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
621564 .enable_bit = 20,
622565 };
623566
624−static struct clk mmc3_ck = {
625− .name = "mmc3_ck",
567+static struct omap1_clk mmc3_ck = {
626568 .ops = &clkops_generic,
627569 /* Functional clock is direct from ULPD, interface clock is ARMPER */
628− .parent = &armper_ck.clk,
570+ .hw.init = CLK_HW_INIT("mmc3_ck", "armper_ck", &omap1_clk_full_ops, 0),
629571 .rate = 48000000,
630572 .flags = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
631573 .enable_reg = OMAP1_IO_ADDRESS(SOFT_REQ_REG),
632574 .enable_bit = SOFT_MMC_DPLL_REQ_SHIFT,
633575 };
634576
635−static struct clk virtual_ck_mpu = {
636− .name = "mpu",
637− .ops = &clkops_null,
638− .parent = &arm_ck, /* Is smarter alias for */
577+static struct omap1_clk virtual_ck_mpu = {
578+ /* Is smarter alias for arm_ck */
579+ .hw.init = CLK_HW_INIT("mpu", "arm_ck", &omap1_clk_rate_ops, 0),
639580 .recalc = &followparent_recalc,
640581 .set_rate = &omap1_select_table_rate,
641582 .round_rate = &omap1_round_to_table_rate,
@@ -643,20 +584,14 @@ static struct clk virtual_ck_mpu = { · 1 unmodified line
643584
644585 /* virtual functional clock domain for I2C. Just for making sure that ARMXOR_CK
645586 remains active during MPU idle whenever this is enabled */
646−static struct clk i2c_fck = {
647− .name = "i2c_fck",
648− .ops = &clkops_null,
587+static struct omap1_clk i2c_fck = {
588+ .hw.init = CLK_HW_INIT("i2c_fck", "armxor_ck", &omap1_clk_gate_ops, 0),
649589 .flags = CLOCK_NO_IDLE_PARENT,
650− .parent = &armxor_ck.clk,
651− .recalc = &followparent_recalc,
652590 };
653591
654−static struct clk i2c_ick = {
655− .name = "i2c_ick",
656− .ops = &clkops_null,
592+static struct omap1_clk i2c_ick = {
593+ .hw.init = CLK_HW_INIT("i2c_ick", "armper_ck", &omap1_clk_gate_ops, 0),
657594 .flags = CLOCK_NO_IDLE_PARENT,
658− .parent = &armper_ck.clk,
659− .recalc = &followparent_recalc,
660595 };
661596
662597 /*
@@ -665,81 +600,81 @@ static struct clk i2c_ick = { · 2 unmodified lines
665600
666601 static struct omap_clk omap_clks[] = {
667602 /* non-ULPD clocks */
668− CLK(NULL, "ck_ref", &ck_ref, CK_16XX | CK_1510 | CK_310 | CK_7XX),
669− CLK(NULL, "ck_dpll1", &ck_dpll1, CK_16XX | CK_1510 | CK_310 | CK_7XX),
603+ CLK(NULL, "ck_ref", &ck_ref.hw, CK_16XX | CK_1510 | CK_310 | CK_7XX),
604+ CLK(NULL, "ck_dpll1", &ck_dpll1.hw, CK_16XX | CK_1510 | CK_310 | CK_7XX),
670605 /* CK_GEN1 clocks */
671− CLK(NULL, "ck_dpll1out", &ck_dpll1out.clk, CK_16XX),
672− CLK(NULL, "ck_sossi", &sossi_ck, CK_16XX),
673− CLK(NULL, "arm_ck", &arm_ck, CK_16XX | CK_1510 | CK_310),
674− CLK(NULL, "armper_ck", &armper_ck.clk, CK_16XX | CK_1510 | CK_310),
675− CLK("omap_gpio.0", "ick", &arm_gpio_ck, CK_1510 | CK_310),
676− CLK(NULL, "armxor_ck", &armxor_ck.clk, CK_16XX | CK_1510 | CK_310 | CK_7XX),
677− CLK(NULL, "armtim_ck", &armtim_ck.clk, CK_16XX | CK_1510 | CK_310),
678− CLK("omap_wdt", "fck", &armwdt_ck.clk, CK_16XX | CK_1510 | CK_310),
679− CLK("omap_wdt", "ick", &armper_ck.clk, CK_16XX),
680− CLK("omap_wdt", "ick", &dummy_ck, CK_1510 | CK_310),
681− CLK(NULL, "arminth_ck", &arminth_ck1510, CK_1510 | CK_310),
682− CLK(NULL, "arminth_ck", &arminth_ck16xx, CK_16XX),
606+ CLK(NULL, "ck_dpll1out", &ck_dpll1out.clk.hw, CK_16XX),
607+ CLK(NULL, "ck_sossi", &sossi_ck.hw, CK_16XX),
608+ CLK(NULL, "arm_ck", &arm_ck.hw, CK_16XX | CK_1510 | CK_310),
609+ CLK(NULL, "armper_ck", &armper_ck.clk.hw, CK_16XX | CK_1510 | CK_310),
610+ CLK("omap_gpio.0", "ick", &arm_gpio_ck.hw, CK_1510 | CK_310),
611+ CLK(NULL, "armxor_ck", &armxor_ck.clk.hw, CK_16XX | CK_1510 | CK_310 | CK_7XX),
612+ CLK(NULL, "armtim_ck", &armtim_ck.clk.hw, CK_16XX | CK_1510 | CK_310),
613+ CLK("omap_wdt", "fck", &armwdt_ck.clk.hw, CK_16XX | CK_1510 | CK_310),
614+ CLK("omap_wdt", "ick", &armper_ck.clk.hw, CK_16XX),
615+ CLK("omap_wdt", "ick", &dummy_ck.hw, CK_1510 | CK_310),
616+ CLK(NULL, "arminth_ck", &arminth_ck1510.hw, CK_1510 | CK_310),
617+ CLK(NULL, "arminth_ck", &arminth_ck16xx.hw, CK_16XX),
683618 /* CK_GEN2 clocks */
684− CLK(NULL, "dsp_ck", &dsp_ck, CK_16XX | CK_1510 | CK_310),
685− CLK(NULL, "dspmmu_ck", &dspmmu_ck, CK_16XX | CK_1510 | CK_310),
686− CLK(NULL, "dspper_ck", &dspper_ck, CK_16XX | CK_1510 | CK_310),
687− CLK(NULL, "dspxor_ck", &dspxor_ck, CK_16XX | CK_1510 | CK_310),
688− CLK(NULL, "dsptim_ck", &dsptim_ck, CK_16XX | CK_1510 | CK_310),
619+ CLK(NULL, "dsp_ck", &dsp_ck.hw, CK_16XX | CK_1510 | CK_310),
620+ CLK(NULL, "dspmmu_ck", &dspmmu_ck.hw, CK_16XX | CK_1510 | CK_310),
621+ CLK(NULL, "dspper_ck", &dspper_ck.hw, CK_16XX | CK_1510 | CK_310),
622+ CLK(NULL, "dspxor_ck", &dspxor_ck.hw, CK_16XX | CK_1510 | CK_310),
623+ CLK(NULL, "dsptim_ck", &dsptim_ck.hw, CK_16XX | CK_1510 | CK_310),
689624 /* CK_GEN3 clocks */
690− CLK(NULL, "tc_ck", &tc_ck.clk, CK_16XX | CK_1510 | CK_310 | CK_7XX),
691− CLK(NULL, "tipb_ck", &tipb_ck, CK_1510 | CK_310),
692− CLK(NULL, "l3_ocpi_ck", &l3_ocpi_ck, CK_16XX | CK_7XX),
693− CLK(NULL, "tc1_ck", &tc1_ck, CK_16XX),
694− CLK(NULL, "tc2_ck", &tc2_ck, CK_16XX),
695− CLK(NULL, "dma_ck", &dma_ck, CK_16XX | CK_1510 | CK_310),
696− CLK(NULL, "dma_lcdfree_ck", &dma_lcdfree_ck, CK_16XX),
697− CLK(NULL, "api_ck", &api_ck.clk, CK_16XX | CK_1510 | CK_310 | CK_7XX),
698− CLK(NULL, "lb_ck", &lb_ck.clk, CK_1510 | CK_310),
699− CLK(NULL, "rhea1_ck", &rhea1_ck, CK_16XX),
700− CLK(NULL, "rhea2_ck", &rhea2_ck, CK_16XX),
701− CLK(NULL, "lcd_ck", &lcd_ck_16xx, CK_16XX | CK_7XX),
702− CLK(NULL, "lcd_ck", &lcd_ck_1510.clk, CK_1510 | CK_310),
625+ CLK(NULL, "tc_ck", &tc_ck.clk.hw, CK_16XX | CK_1510 | CK_310 | CK_7XX),
626+ CLK(NULL, "tipb_ck", &tipb_ck.hw, CK_1510 | CK_310),
627+ CLK(NULL, "l3_ocpi_ck", &l3_ocpi_ck.hw, CK_16XX | CK_7XX),
628+ CLK(NULL, "tc1_ck", &tc1_ck.hw, CK_16XX),
629+ CLK(NULL, "tc2_ck", &tc2_ck.hw, CK_16XX),
630+ CLK(NULL, "dma_ck", &dma_ck.hw, CK_16XX | CK_1510 | CK_310),
631+ CLK(NULL, "dma_lcdfree_ck", &dma_lcdfree_ck.hw, CK_16XX),
632+ CLK(NULL, "api_ck", &api_ck.clk.hw, CK_16XX | CK_1510 | CK_310 | CK_7XX),
633+ CLK(NULL, "lb_ck", &lb_ck.clk.hw, CK_1510 | CK_310),
634+ CLK(NULL, "rhea1_ck", &rhea1_ck.hw, CK_16XX),
635+ CLK(NULL, "rhea2_ck", &rhea2_ck.hw, CK_16XX),
636+ CLK(NULL, "lcd_ck", &lcd_ck_16xx.hw, CK_16XX | CK_7XX),
637+ CLK(NULL, "lcd_ck", &lcd_ck_1510.clk.hw, CK_1510 | CK_310),
703638 /* ULPD clocks */
704− CLK(NULL, "uart1_ck", &uart1_1510, CK_1510 | CK_310),
705− CLK(NULL, "uart1_ck", &uart1_16xx.clk, CK_16XX),
706− CLK(NULL, "uart1_ck", &uart1_7xx, CK_7XX),
707− CLK(NULL, "uart2_ck", &uart2_ck, CK_16XX | CK_1510 | CK_310),
708− CLK(NULL, "uart2_ck", &uart2_7xx, CK_7XX),
709− CLK(NULL, "uart3_ck", &uart3_1510, CK_1510 | CK_310),
710− CLK(NULL, "uart3_ck", &uart3_16xx.clk, CK_16XX),
711− CLK(NULL, "usb_clko", &usb_clko, CK_16XX | CK_1510 | CK_310),
712− CLK(NULL, "usb_hhc_ck", &usb_hhc_ck1510, CK_1510 | CK_310),
713− CLK(NULL, "usb_hhc_ck", &usb_hhc_ck16xx, CK_16XX),
714− CLK(NULL, "usb_dc_ck", &usb_dc_ck, CK_16XX | CK_7XX),
715− CLK(NULL, "mclk", &mclk_1510, CK_1510 | CK_310),
716− CLK(NULL, "mclk", &mclk_16xx, CK_16XX),
717− CLK(NULL, "bclk", &bclk_1510, CK_1510 | CK_310),
718− CLK(NULL, "bclk", &bclk_16xx, CK_16XX),
719− CLK("mmci-omap.0", "fck", &mmc1_ck, CK_16XX | CK_1510 | CK_310),
720− CLK("mmci-omap.0", "fck", &mmc3_ck, CK_7XX),
721− CLK("mmci-omap.0", "ick", &armper_ck.clk, CK_16XX | CK_1510 | CK_310 | CK_7XX),
722− CLK("mmci-omap.1", "fck", &mmc2_ck, CK_16XX),
723− CLK("mmci-omap.1", "ick", &armper_ck.clk, CK_16XX),
639+ CLK(NULL, "uart1_ck", &uart1_1510.hw, CK_1510 | CK_310),
640+ CLK(NULL, "uart1_ck", &uart1_16xx.clk.hw, CK_16XX),
641+ CLK(NULL, "uart1_ck", &uart1_7xx.hw, CK_7XX),
642+ CLK(NULL, "uart2_ck", &uart2_ck.hw, CK_16XX | CK_1510 | CK_310),
643+ CLK(NULL, "uart2_ck", &uart2_7xx.hw, CK_7XX),
644+ CLK(NULL, "uart3_ck", &uart3_1510.hw, CK_1510 | CK_310),
645+ CLK(NULL, "uart3_ck", &uart3_16xx.clk.hw, CK_16XX),
646+ CLK(NULL, "usb_clko", &usb_clko.hw, CK_16XX | CK_1510 | CK_310),
647+ CLK(NULL, "usb_hhc_ck", &usb_hhc_ck1510.hw, CK_1510 | CK_310),
648+ CLK(NULL, "usb_hhc_ck", &usb_hhc_ck16xx.hw, CK_16XX),
649+ CLK(NULL, "usb_dc_ck", &usb_dc_ck.hw, CK_16XX | CK_7XX),
650+ CLK(NULL, "mclk", &mclk_1510.hw, CK_1510 | CK_310),
651+ CLK(NULL, "mclk", &mclk_16xx.hw, CK_16XX),
652+ CLK(NULL, "bclk", &bclk_1510.hw, CK_1510 | CK_310),
653+ CLK(NULL, "bclk", &bclk_16xx.hw, CK_16XX),
654+ CLK("mmci-omap.0", "fck", &mmc1_ck.hw, CK_16XX | CK_1510 | CK_310),
655+ CLK("mmci-omap.0", "fck", &mmc3_ck.hw, CK_7XX),
656+ CLK("mmci-omap.0", "ick", &armper_ck.clk.hw, CK_16XX | CK_1510 | CK_310 | CK_7XX),
657+ CLK("mmci-omap.1", "fck", &mmc2_ck.hw, CK_16XX),
658+ CLK("mmci-omap.1", "ick", &armper_ck.clk.hw, CK_16XX),
724659 /* Virtual clocks */
725− CLK(NULL, "mpu", &virtual_ck_mpu, CK_16XX | CK_1510 | CK_310),
726− CLK("omap_i2c.1", "fck", &i2c_fck, CK_16XX | CK_1510 | CK_310 | CK_7XX),
727− CLK("omap_i2c.1", "ick", &i2c_ick, CK_16XX),
728− CLK("omap_i2c.1", "ick", &dummy_ck, CK_1510 | CK_310 | CK_7XX),
729− CLK("omap1_spi100k.1", "fck", &dummy_ck, CK_7XX),
730− CLK("omap1_spi100k.1", "ick", &dummy_ck, CK_7XX),
731− CLK("omap1_spi100k.2", "fck", &dummy_ck, CK_7XX),
732− CLK("omap1_spi100k.2", "ick", &dummy_ck, CK_7XX),
733− CLK("omap_uwire", "fck", &armxor_ck.clk, CK_16XX | CK_1510 | CK_310),
734− CLK("omap-mcbsp.1", "ick", &dspper_ck, CK_16XX),
735− CLK("omap-mcbsp.1", "ick", &dummy_ck, CK_1510 | CK_310),
736− CLK("omap-mcbsp.2", "ick", &armper_ck.clk, CK_16XX),
737− CLK("omap-mcbsp.2", "ick", &dummy_ck, CK_1510 | CK_310),
738− CLK("omap-mcbsp.3", "ick", &dspper_ck, CK_16XX),
739− CLK("omap-mcbsp.3", "ick", &dummy_ck, CK_1510 | CK_310),
740− CLK("omap-mcbsp.1", "fck", &dspxor_ck, CK_16XX | CK_1510 | CK_310),
741− CLK("omap-mcbsp.2", "fck", &armper_ck.clk, CK_16XX | CK_1510 | CK_310),
742− CLK("omap-mcbsp.3", "fck", &dspxor_ck, CK_16XX | CK_1510 | CK_310),
660+ CLK(NULL, "mpu", &virtual_ck_mpu.hw, CK_16XX | CK_1510 | CK_310),
661+ CLK("omap_i2c.1", "fck", &i2c_fck.hw, CK_16XX | CK_1510 | CK_310 | CK_7XX),
662+ CLK("omap_i2c.1", "ick", &i2c_ick.hw, CK_16XX),
663+ CLK("omap_i2c.1", "ick", &dummy_ck.hw, CK_1510 | CK_310 | CK_7XX),
664+ CLK("omap1_spi100k.1", "fck", &dummy_ck.hw, CK_7XX),
665+ CLK("omap1_spi100k.1", "ick", &dummy_ck.hw, CK_7XX),
666+ CLK("omap1_spi100k.2", "fck", &dummy_ck.hw, CK_7XX),
667+ CLK("omap1_spi100k.2", "ick", &dummy_ck.hw, CK_7XX),
668+ CLK("omap_uwire", "fck", &armxor_ck.clk.hw, CK_16XX | CK_1510 | CK_310),
669+ CLK("omap-mcbsp.1", "ick", &dspper_ck.hw, CK_16XX),
670+ CLK("omap-mcbsp.1", "ick", &dummy_ck.hw, CK_1510 | CK_310),
671+ CLK("omap-mcbsp.2", "ick", &armper_ck.clk.hw, CK_16XX),
672+ CLK("omap-mcbsp.2", "ick", &dummy_ck.hw, CK_1510 | CK_310),
673+ CLK("omap-mcbsp.3", "ick", &dspper_ck.hw, CK_16XX),
674+ CLK("omap-mcbsp.3", "ick", &dummy_ck.hw, CK_1510 | CK_310),
675+ CLK("omap-mcbsp.1", "fck", &dspxor_ck.hw, CK_16XX | CK_1510 | CK_310),
676+ CLK("omap-mcbsp.2", "fck", &armper_ck.clk.hw, CK_16XX | CK_1510 | CK_310),
677+ CLK("omap-mcbsp.3", "fck", &dspxor_ck.hw, CK_16XX | CK_1510 | CK_310),
743678 };
744679
745680 /*
@@ -778,9 +713,6 @@ int __init omap1_clk_init(void) · 32 unmodified lines
778713 /* By default all idlect1 clocks are allowed to idle */
779714 arm_idlect1_mask = ~0;
780715
781− for (c = omap_clks; c < omap_clks + ARRAY_SIZE(omap_clks); c++)
782− clk_preinit(c->lk.clk);
783−
784716 cpu_mask = 0;
785717 if (cpu_is_omap1710())
786718 cpu_mask |= CK_1710;
@@ -793,16 +725,10 @@ int __init omap1_clk_init(void) · 6 unmodified lines
793725 if (cpu_is_omap310())
794726 cpu_mask |= CK_310;
795727
796− for (c = omap_clks; c < omap_clks + ARRAY_SIZE(omap_clks); c++)
797− if (c->cpu & cpu_mask) {
798− clkdev_add(&c->lk);
799− clk_register(c->lk.clk);
800− }
801−
802728 /* Pointers to these clocks are needed by code in clock.c */
803− api_ck_p = clk_get(NULL, "api_ck");
804− ck_dpll1_p = clk_get(NULL, "ck_dpll1");
805− ck_ref_p = clk_get(NULL, "ck_ref");
729+ api_ck_p = &api_ck.clk;
730+ ck_dpll1_p = &ck_dpll1;
731+ ck_ref_p = &ck_ref;
806732
807733 if (cpu_is_omap7xx())
808734 ck_ref.rate = 13000000;
@@ -844,10 +770,7 @@ int __init omap1_clk_init(void) · 35 unmodified lines
844770 }
845771 }
846772 }
847− propagate_rate(&ck_dpll1);
848− /* Cache rates for clocks connected to ck_ref (not dpll1) */
849− propagate_rate(&ck_ref);
850− omap1_show_rates();
773+
851774 if (machine_is_omap_perseus2() || machine_is_omap_fsample()) {
852775 /* Select slicer output as OMAP input clock */
853776 omap_writew(omap_readw(OMAP7XX_PCC_UPLD_CTRL) & ~0x1,
@@ -879,16 +802,28 @@ int __init omap1_clk_init(void) · 25 unmodified lines
879802 */
880803 omap_writew(0x0000, ARM_IDLECT2); /* Turn LCD clock off also */
881804
882− /*
883− * Only enable those clocks we will need, let the drivers
884− * enable other clocks as necessary
885− */
886− clk_enable(&armper_ck.clk);
887− clk_enable(&armxor_ck.clk);
888− clk_enable(&armtim_ck.clk); /* This should be done by timer code */
805+ for (c = omap_clks; c < omap_clks + ARRAY_SIZE(omap_clks); c++) {
806+ if (!(c->cpu & cpu_mask))
807+ continue;
808+
809+ if (c->lk.clk_hw->init) { /* NULL if provider already registered */
810+ const struct clk_init_data *init = c->lk.clk_hw->init;
811+ const char *name = c->lk.clk_hw->init->name;
812+ int err;
813+
814+ err = clk_hw_register(NULL, c->lk.clk_hw);
815+ if (err < 0) {
816+ pr_err("failed to register clock \"%s\"! (%d)\n", name, err);
817+ /* may be tried again, restore init data */
818+ c->lk.clk_hw->init = init;
819+ continue;
820+ }
821+ }
822+
823+ clk_hw_register_clkdev(c->lk.clk_hw, c->lk.con_id, c->lk.dev_id);
824+ }
889825
890− if (cpu_is_omap15xx())
891− clk_enable(&arm_gpio_ck);
826+ omap1_show_rates();
892827
893828 return 0;
894829 }
@@ -900,7 +835,7 @@ void __init omap1_clk_late_init(void) · 5 unmodified lines
900835 unsigned long rate = ck_dpll1.rate;
901836
902837 /* Find the highest supported frequency and enable it */
903− if (omap1_select_table_rate(&virtual_ck_mpu, ~0)) {
838+ if (omap1_select_table_rate(&virtual_ck_mpu, ~0, arm_ck.rate)) {
904839 pr_err("System frequencies not set, using default. Check your config.\n");
905840 /*
906841 * Reprogramming the DPLL is tricky, it must be done from SRAM.
arch/arm/mach-omap1/hardware.h+1−1
@@ -64,7 +64,7 @@ static inline u32 omap_cs3_phys(void) · 63 unmodified lines
6464 #define OMAP1_IO_OFFSET 0x00f00000 /* Virtual IO = 0xff0b0000 */
6565 #define OMAP1_IO_ADDRESS(pa) IOMEM((pa) - OMAP1_IO_OFFSET)
6666
67−#include <mach/serial.h>
67+#include "serial.h"
6868
6969 /*
7070 * ---------------------------------------------------------------------------
arch/arm/mach-omap1/include/mach/uncompress.h+0−117
@@ -1,117 +0,0 @@
1−/*
2− * arch/arm/plat-omap/include/mach/uncompress.h
3− *
4− * Serial port stubs for kernel decompress status messages
5− *
6− * Initially based on:
7− * linux-2.4.15-rmk1-dsplinux1.6/arch/arm/plat-omap/include/mach1510/uncompress.h
8− * Copyright (C) 2000 RidgeRun, Inc.
9− * Author: Greg Lonnon <glonnon@ridgerun.com>
10− *
11− * Rewritten by:
12− * Author: <source@mvista.com>
13− * 2004 (c) MontaVista Software, Inc.
14− *
15− * This file is licensed under the terms of the GNU General Public License
16− * version 2. This program is licensed "as is" without any warranty of any
17− * kind, whether express or implied.
18− */
19−
20−#include <linux/types.h>
21−#include <linux/serial_reg.h>
22−
23−#include <asm/memory.h>
24−#include <asm/mach-types.h>
25−
26−#include "serial.h"
27−
28−#define MDR1_MODE_MASK 0x07
29−
30−volatile u8 *uart_base;
31−int uart_shift;
32−
33−/*
34− * Store the DEBUG_LL uart number into memory.
35− * See also debug-macro.S, and serial.c for related code.
36− */
37−static void set_omap_uart_info(unsigned char port)
38−{
39− /*
40− * Get address of some.bss variable and round it down
41− * a la CONFIG_AUTO_ZRELADDR.
42− */
43− u32 ram_start = (u32)&uart_shift & 0xf8000000;
44− u32 *uart_info = (u32 *)(ram_start + OMAP_UART_INFO_OFS);
45− *uart_info = port;
46−}
47−
48−static inline void putc(int c)
49−{
50− if (!uart_base)
51− return;
52−
53− /* Check for UART 16x mode */
54− if ((uart_base[UART_OMAP_MDR1 << uart_shift] & MDR1_MODE_MASK) != 0)
55− return;
56−
57− while (!(uart_base[UART_LSR << uart_shift] & UART_LSR_THRE))
58− barrier();
59− uart_base[UART_TX << uart_shift] = c;
60−}
61−
62−static inline void flush(void)
63−{
64−}
65−
66−/*
67− * Macros to configure UART1 and debug UART
68− */
69−#define _DEBUG_LL_ENTRY(mach, dbg_uart, dbg_shft, dbg_id) \
70− if (machine_is_##mach()) { \
71− uart_base = (volatile u8 *)(dbg_uart); \
72− uart_shift = (dbg_shft); \
73− port = (dbg_id); \
74− set_omap_uart_info(port); \
75− break; \
76− }
77−
78−#define DEBUG_LL_OMAP7XX(p, mach) \
79− _DEBUG_LL_ENTRY(mach, OMAP1_UART##p##_BASE, OMAP7XX_PORT_SHIFT, \
80− OMAP1UART##p)
81−
82−#define DEBUG_LL_OMAP1(p, mach) \
83− _DEBUG_LL_ENTRY(mach, OMAP1_UART##p##_BASE, OMAP_PORT_SHIFT, \
84− OMAP1UART##p)
85−
86−static inline void arch_decomp_setup(void)
87−{
88− int port = 0;
89−
90− /*
91− * Initialize the port based on the machine ID from the bootloader.
92− * Note that we're using macros here instead of switch statement
93− * as machine_is functions are optimized out for the boards that
94− * are not selected.
95− */
96− do {
97− /* omap7xx/8xx based boards using UART1 with shift 0 */
98− DEBUG_LL_OMAP7XX(1, herald);
99− DEBUG_LL_OMAP7XX(1, omap_perseus2);
100−
101− /* omap15xx/16xx based boards using UART1 */
102− DEBUG_LL_OMAP1(1, ams_delta);
103− DEBUG_LL_OMAP1(1, nokia770);
104− DEBUG_LL_OMAP1(1, omap_h2);
105− DEBUG_LL_OMAP1(1, omap_h3);
106− DEBUG_LL_OMAP1(1, omap_innovator);
107− DEBUG_LL_OMAP1(1, omap_osk);
108− DEBUG_LL_OMAP1(1, omap_palmte);
109− DEBUG_LL_OMAP1(1, omap_palmz71);
110−
111− /* omap15xx/16xx based boards using UART2 */
112− DEBUG_LL_OMAP1(2, omap_palmtt);
113−
114− /* omap15xx/16xx based boards using UART3 */
115− DEBUG_LL_OMAP1(3, sx1);
116− } while (0);
117−}
arch/arm/mach-omap1/io.c+0−7
@@ -15,10 +15,8 @@ · 14 unmodified lines
1515 #include <asm/mach/map.h>
1616
1717 #include "tc.h"
18−#include "mux.h"
1918 #include "iomap.h"
2019 #include "common.h"
21−#include "clock.h"
2220
2321 /*
2422 * The machine specific code may provide the extra mapping besides the
@@ -125,11 +123,6 @@ void __init omap1_init_early(void) · 100 unmodified lines
125123 */
126124 omap_writew(0x0, MPU_PUBLIC_TIPB_CNTL);
127125 omap_writew(0x0, MPU_PRIVATE_TIPB_CNTL);
128−
129− /* Must init clocks early to assure that timer interrupt works
130− */
131− omap1_clk_init();
132− omap1_mux_init();
133126 }
134127
135128 void __init omap1_init_late(void)
arch/arm/mach-omap1/serial.c+1−2
@@ -19,8 +19,7 @@ · 18 unmodified lines
1919
2020 #include <asm/mach-types.h>
2121
22−#include <mach/serial.h>
23−
22+#include "serial.h"
2423 #include "mux.h"
2524 #include "pm.h"
2625 #include "soc.h"
arch/arm/mach-omap1/serial.hrenamed from arch/arm/mach-omap1/include/mach/serial.h+0−0

File renamed without changes.

arch/arm/mach-omap1/time.c+5−0
@@ -51,8 +51,10 @@ · 50 unmodified lines
5151 #include <asm/mach/time.h>
5252
5353 #include "hardware.h"
54+#include "mux.h"
5455 #include "iomap.h"
5556 #include "common.h"
57+#include "clock.h"
5658
5759 #ifdef CONFIG_OMAP_MPU_TIMER
5860
@@ -224,6 +226,9 @@ static inline void omap_mpu_timer_init(void) · 165 unmodified lines
224226 */
225227 void __init omap1_timer_init(void)
226228 {
229+ omap1_clk_init();
230+ omap1_mux_init();
231+
227232 if (omap_32k_timer_init() != 0)
228233 omap_mpu_timer_init();
229234 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t