blob: 650c8c77a573792d87d28b73bd93a814aaf62761 [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 */
Rajendra Nayakb4777a22012-04-27 15:53:48 +053030#ifdef CONFIG_COMMON_CLK
31void omap2_clkt_iclk_allow_idle(struct clk_hw_omap *clk)
32#else
Paul Walmsley530e5442011-02-25 15:39:28 -070033void omap2_clkt_iclk_allow_idle(struct clk *clk)
Rajendra Nayakb4777a22012-04-27 15:53:48 +053034#endif
Paul Walmsley530e5442011-02-25 15:39:28 -070035{
36 u32 v, r;
37
38 r = ((__force u32)clk->enable_reg ^ (CM_AUTOIDLE ^ CM_ICLKEN));
39
40 v = __raw_readl((__force void __iomem *)r);
41 v |= (1 << clk->enable_bit);
42 __raw_writel(v, (__force void __iomem *)r);
43}
44
45/* XXX */
Rajendra Nayakb4777a22012-04-27 15:53:48 +053046#ifdef CONFIG_COMMON_CLK
47void omap2_clkt_iclk_deny_idle(struct clk_hw_omap *clk)
48#else
Paul Walmsley530e5442011-02-25 15:39:28 -070049void omap2_clkt_iclk_deny_idle(struct clk *clk)
Rajendra Nayakb4777a22012-04-27 15:53:48 +053050#endif
Paul Walmsley530e5442011-02-25 15:39:28 -070051{
52 u32 v, r;
53
54 r = ((__force u32)clk->enable_reg ^ (CM_AUTOIDLE ^ CM_ICLKEN));
55
56 v = __raw_readl((__force void __iomem *)r);
57 v &= ~(1 << clk->enable_bit);
58 __raw_writel(v, (__force void __iomem *)r);
59}
60
61/* Public data */
62
Mike Turquette32cc0022012-11-10 16:58:41 -070063#ifdef CONFIG_COMMON_CLK
Rajendra Nayakb4777a22012-04-27 15:53:48 +053064const struct clk_hw_omap_ops clkhwops_iclk = {
65 .allow_idle = omap2_clkt_iclk_allow_idle,
66 .deny_idle = omap2_clkt_iclk_deny_idle,
67};
68
Mike Turquette32cc0022012-11-10 16:58:41 -070069const struct clk_hw_omap_ops clkhwops_iclk_wait = {
70 .allow_idle = omap2_clkt_iclk_allow_idle,
71 .deny_idle = omap2_clkt_iclk_deny_idle,
72 .find_idlest = omap2_clk_dflt_find_idlest,
73 .find_companion = omap2_clk_dflt_find_companion,
74};
75#else
Paul Walmsley530e5442011-02-25 15:39:28 -070076const struct clkops clkops_omap2_iclk_dflt_wait = {
77 .enable = omap2_dflt_clk_enable,
78 .disable = omap2_dflt_clk_disable,
79 .find_companion = omap2_clk_dflt_find_companion,
80 .find_idlest = omap2_clk_dflt_find_idlest,
81 .allow_idle = omap2_clkt_iclk_allow_idle,
82 .deny_idle = omap2_clkt_iclk_deny_idle,
83};
84
85const struct clkops clkops_omap2_iclk_dflt = {
86 .enable = omap2_dflt_clk_enable,
87 .disable = omap2_dflt_clk_disable,
88 .allow_idle = omap2_clkt_iclk_allow_idle,
89 .deny_idle = omap2_clkt_iclk_deny_idle,
90};
91
92const struct clkops clkops_omap2_iclk_idle_only = {
93 .allow_idle = omap2_clkt_iclk_allow_idle,
94 .deny_idle = omap2_clkt_iclk_deny_idle,
95};
96
Paul Walmsleye892b252011-02-25 15:39:29 -070097const struct clkops clkops_omap2_mdmclk_dflt_wait = {
98 .enable = omap2_dflt_clk_enable,
99 .disable = omap2_dflt_clk_disable,
100 .find_companion = omap2_clk_dflt_find_companion,
101 .find_idlest = omap2_clk_dflt_find_idlest,
102 .allow_idle = omap2_clkt_iclk_allow_idle,
103 .deny_idle = omap2_clkt_iclk_deny_idle,
104};
Mike Turquette32cc0022012-11-10 16:58:41 -0700105#endif