blob: 3b661ba73fc2d91c0019d3eb980e2cb410d041e3 [file] [log] [blame]
Paul Walmsley530e5442011-02-25 15:39:28 -07001/*
2 * OMAP2/3 interface clock control
3 *
4 * Copyright (C) 2011 Nokia Corporation
5 * Paul Walmsley
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11#undef DEBUG
12
13#include <linux/kernel.h>
Mike Turquette32cc0022012-11-10 16:58:41 -070014#ifdef CONFIG_COMMON_CLK
15#include <linux/clk-provider.h>
16#else
Paul Walmsley530e5442011-02-25 15:39:28 -070017#include <linux/clk.h>
Mike Turquette32cc0022012-11-10 16:58:41 -070018#endif
Paul Walmsley530e5442011-02-25 15:39:28 -070019#include <linux/io.h>
20
Paul Walmsley530e5442011-02-25 15:39:28 -070021
22#include "clock.h"
23#include "clock2xxx.h"
24#include "cm2xxx_3xxx.h"
25#include "cm-regbits-24xx.h"
26
27/* Private functions */
28
29/* XXX */
30void omap2_clkt_iclk_allow_idle(struct clk *clk)
31{
32 u32 v, r;
33
34 r = ((__force u32)clk->enable_reg ^ (CM_AUTOIDLE ^ CM_ICLKEN));
35
36 v = __raw_readl((__force void __iomem *)r);
37 v |= (1 << clk->enable_bit);
38 __raw_writel(v, (__force void __iomem *)r);
39}
40
41/* XXX */
42void omap2_clkt_iclk_deny_idle(struct clk *clk)
43{
44 u32 v, r;
45
46 r = ((__force u32)clk->enable_reg ^ (CM_AUTOIDLE ^ CM_ICLKEN));
47
48 v = __raw_readl((__force void __iomem *)r);
49 v &= ~(1 << clk->enable_bit);
50 __raw_writel(v, (__force void __iomem *)r);
51}
52
53/* Public data */
54
Mike Turquette32cc0022012-11-10 16:58:41 -070055#ifdef CONFIG_COMMON_CLK
56const struct clk_hw_omap_ops clkhwops_iclk_wait = {
57 .allow_idle = omap2_clkt_iclk_allow_idle,
58 .deny_idle = omap2_clkt_iclk_deny_idle,
59 .find_idlest = omap2_clk_dflt_find_idlest,
60 .find_companion = omap2_clk_dflt_find_companion,
61};
62#else
Paul Walmsley530e5442011-02-25 15:39:28 -070063const struct clkops clkops_omap2_iclk_dflt_wait = {
64 .enable = omap2_dflt_clk_enable,
65 .disable = omap2_dflt_clk_disable,
66 .find_companion = omap2_clk_dflt_find_companion,
67 .find_idlest = omap2_clk_dflt_find_idlest,
68 .allow_idle = omap2_clkt_iclk_allow_idle,
69 .deny_idle = omap2_clkt_iclk_deny_idle,
70};
71
72const struct clkops clkops_omap2_iclk_dflt = {
73 .enable = omap2_dflt_clk_enable,
74 .disable = omap2_dflt_clk_disable,
75 .allow_idle = omap2_clkt_iclk_allow_idle,
76 .deny_idle = omap2_clkt_iclk_deny_idle,
77};
78
79const struct clkops clkops_omap2_iclk_idle_only = {
80 .allow_idle = omap2_clkt_iclk_allow_idle,
81 .deny_idle = omap2_clkt_iclk_deny_idle,
82};
83
Paul Walmsleye892b252011-02-25 15:39:29 -070084const struct clkops clkops_omap2_mdmclk_dflt_wait = {
85 .enable = omap2_dflt_clk_enable,
86 .disable = omap2_dflt_clk_disable,
87 .find_companion = omap2_clk_dflt_find_companion,
88 .find_idlest = omap2_clk_dflt_find_idlest,
89 .allow_idle = omap2_clkt_iclk_allow_idle,
90 .deny_idle = omap2_clkt_iclk_deny_idle,
91};
Mike Turquette32cc0022012-11-10 16:58:41 -070092#endif