Paul Walmsley | 530e544 | 2011-02-25 15:39:28 -0700 | [diff] [blame] | 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> |
Mike Turquette | 32cc002 | 2012-11-10 16:58:41 -0700 | [diff] [blame] | 14 | #ifdef CONFIG_COMMON_CLK |
| 15 | #include <linux/clk-provider.h> |
| 16 | #else |
Paul Walmsley | 530e544 | 2011-02-25 15:39:28 -0700 | [diff] [blame] | 17 | #include <linux/clk.h> |
Mike Turquette | 32cc002 | 2012-11-10 16:58:41 -0700 | [diff] [blame] | 18 | #endif |
Paul Walmsley | 530e544 | 2011-02-25 15:39:28 -0700 | [diff] [blame] | 19 | #include <linux/io.h> |
| 20 | |
Paul Walmsley | 530e544 | 2011-02-25 15:39:28 -0700 | [diff] [blame] | 21 | |
| 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 Nayak | b4777a2 | 2012-04-27 15:53:48 +0530 | [diff] [blame^] | 30 | #ifdef CONFIG_COMMON_CLK |
| 31 | void omap2_clkt_iclk_allow_idle(struct clk_hw_omap *clk) |
| 32 | #else |
Paul Walmsley | 530e544 | 2011-02-25 15:39:28 -0700 | [diff] [blame] | 33 | void omap2_clkt_iclk_allow_idle(struct clk *clk) |
Rajendra Nayak | b4777a2 | 2012-04-27 15:53:48 +0530 | [diff] [blame^] | 34 | #endif |
Paul Walmsley | 530e544 | 2011-02-25 15:39:28 -0700 | [diff] [blame] | 35 | { |
| 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 Nayak | b4777a2 | 2012-04-27 15:53:48 +0530 | [diff] [blame^] | 46 | #ifdef CONFIG_COMMON_CLK |
| 47 | void omap2_clkt_iclk_deny_idle(struct clk_hw_omap *clk) |
| 48 | #else |
Paul Walmsley | 530e544 | 2011-02-25 15:39:28 -0700 | [diff] [blame] | 49 | void omap2_clkt_iclk_deny_idle(struct clk *clk) |
Rajendra Nayak | b4777a2 | 2012-04-27 15:53:48 +0530 | [diff] [blame^] | 50 | #endif |
Paul Walmsley | 530e544 | 2011-02-25 15:39:28 -0700 | [diff] [blame] | 51 | { |
| 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 Turquette | 32cc002 | 2012-11-10 16:58:41 -0700 | [diff] [blame] | 63 | #ifdef CONFIG_COMMON_CLK |
Rajendra Nayak | b4777a2 | 2012-04-27 15:53:48 +0530 | [diff] [blame^] | 64 | const 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 Turquette | 32cc002 | 2012-11-10 16:58:41 -0700 | [diff] [blame] | 69 | const 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 Walmsley | 530e544 | 2011-02-25 15:39:28 -0700 | [diff] [blame] | 76 | const 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 | |
| 85 | const 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 | |
| 92 | const 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 Walmsley | e892b25 | 2011-02-25 15:39:29 -0700 | [diff] [blame] | 97 | const 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 Turquette | 32cc002 | 2012-11-10 16:58:41 -0700 | [diff] [blame] | 105 | #endif |