1 /*
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>
14 #include <linux/clk.h>
15 #include <linux/io.h>
16 
17 #include <plat/clock.h>
18 #include <plat/prcm.h>
19 
20 #include "clock.h"
21 #include "clock2xxx.h"
22 #include "cm2xxx_3xxx.h"
23 #include "cm-regbits-24xx.h"
24 
25 /* Private functions */
26 
27 /* XXX */
omap2_clkt_iclk_allow_idle(struct clk * clk)28 void omap2_clkt_iclk_allow_idle(struct clk *clk)
29 {
30 	u32 v, r;
31 
32 	r = ((__force u32)clk->enable_reg ^ (CM_AUTOIDLE ^ CM_ICLKEN));
33 
34 	v = __raw_readl((__force void __iomem *)r);
35 	v |= (1 << clk->enable_bit);
36 	__raw_writel(v, (__force void __iomem *)r);
37 }
38 
39 /* XXX */
omap2_clkt_iclk_deny_idle(struct clk * clk)40 void omap2_clkt_iclk_deny_idle(struct clk *clk)
41 {
42 	u32 v, r;
43 
44 	r = ((__force u32)clk->enable_reg ^ (CM_AUTOIDLE ^ CM_ICLKEN));
45 
46 	v = __raw_readl((__force void __iomem *)r);
47 	v &= ~(1 << clk->enable_bit);
48 	__raw_writel(v, (__force void __iomem *)r);
49 }
50 
51 /* Public data */
52 
53 const struct clkops clkops_omap2_iclk_dflt_wait = {
54 	.enable		= omap2_dflt_clk_enable,
55 	.disable	= omap2_dflt_clk_disable,
56 	.find_companion	= omap2_clk_dflt_find_companion,
57 	.find_idlest	= omap2_clk_dflt_find_idlest,
58 	.allow_idle	= omap2_clkt_iclk_allow_idle,
59 	.deny_idle	= omap2_clkt_iclk_deny_idle,
60 };
61 
62 const struct clkops clkops_omap2_iclk_dflt = {
63 	.enable		= omap2_dflt_clk_enable,
64 	.disable	= omap2_dflt_clk_disable,
65 	.allow_idle	= omap2_clkt_iclk_allow_idle,
66 	.deny_idle	= omap2_clkt_iclk_deny_idle,
67 };
68 
69 const struct clkops clkops_omap2_iclk_idle_only = {
70 	.allow_idle	= omap2_clkt_iclk_allow_idle,
71 	.deny_idle	= omap2_clkt_iclk_deny_idle,
72 };
73 
74 const struct clkops clkops_omap2_mdmclk_dflt_wait = {
75 	.enable		= omap2_dflt_clk_enable,
76 	.disable	= omap2_dflt_clk_disable,
77 	.find_companion	= omap2_clk_dflt_find_companion,
78 	.find_idlest	= omap2_clk_dflt_find_idlest,
79 	.allow_idle	= omap2_clkt_iclk_allow_idle,
80 	.deny_idle	= omap2_clkt_iclk_deny_idle,
81 };
82 
83