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 | #include <linux/clk-provider.h> |
Paul Walmsley | 530e544 | 2011-02-25 15:39:28 -0700 | [diff] [blame] | 15 | #include <linux/io.h> |
| 16 | |
Paul Walmsley | 530e544 | 2011-02-25 15:39:28 -0700 | [diff] [blame] | 17 | #include "clock.h" |
Tero Kristo | acd052b | 2014-07-02 11:47:47 +0300 | [diff] [blame] | 18 | |
| 19 | /* Register offsets */ |
| 20 | #define CM_AUTOIDLE 0x30 |
| 21 | #define CM_ICLKEN 0x10 |
Paul Walmsley | 530e544 | 2011-02-25 15:39:28 -0700 | [diff] [blame] | 22 | |
| 23 | /* Private functions */ |
| 24 | |
| 25 | /* XXX */ |
Rajendra Nayak | b4777a2 | 2012-04-27 15:53:48 +0530 | [diff] [blame] | 26 | void omap2_clkt_iclk_allow_idle(struct clk_hw_omap *clk) |
Paul Walmsley | 530e544 | 2011-02-25 15:39:28 -0700 | [diff] [blame] | 27 | { |
Tero Kristo | 519ab8b | 2013-10-22 11:49:58 +0300 | [diff] [blame] | 28 | u32 v; |
| 29 | void __iomem *r; |
Paul Walmsley | 530e544 | 2011-02-25 15:39:28 -0700 | [diff] [blame] | 30 | |
Tero Kristo | 519ab8b | 2013-10-22 11:49:58 +0300 | [diff] [blame] | 31 | r = (__force void __iomem *) |
| 32 | ((__force u32)clk->enable_reg ^ (CM_AUTOIDLE ^ CM_ICLKEN)); |
Paul Walmsley | 530e544 | 2011-02-25 15:39:28 -0700 | [diff] [blame] | 33 | |
Tero Kristo | 519ab8b | 2013-10-22 11:49:58 +0300 | [diff] [blame] | 34 | v = omap2_clk_readl(clk, r); |
Paul Walmsley | 530e544 | 2011-02-25 15:39:28 -0700 | [diff] [blame] | 35 | v |= (1 << clk->enable_bit); |
Tero Kristo | 519ab8b | 2013-10-22 11:49:58 +0300 | [diff] [blame] | 36 | omap2_clk_writel(v, clk, r); |
Paul Walmsley | 530e544 | 2011-02-25 15:39:28 -0700 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | /* XXX */ |
Rajendra Nayak | b4777a2 | 2012-04-27 15:53:48 +0530 | [diff] [blame] | 40 | void omap2_clkt_iclk_deny_idle(struct clk_hw_omap *clk) |
Paul Walmsley | 530e544 | 2011-02-25 15:39:28 -0700 | [diff] [blame] | 41 | { |
Tero Kristo | 519ab8b | 2013-10-22 11:49:58 +0300 | [diff] [blame] | 42 | u32 v; |
| 43 | void __iomem *r; |
Paul Walmsley | 530e544 | 2011-02-25 15:39:28 -0700 | [diff] [blame] | 44 | |
Tero Kristo | 519ab8b | 2013-10-22 11:49:58 +0300 | [diff] [blame] | 45 | r = (__force void __iomem *) |
| 46 | ((__force u32)clk->enable_reg ^ (CM_AUTOIDLE ^ CM_ICLKEN)); |
Paul Walmsley | 530e544 | 2011-02-25 15:39:28 -0700 | [diff] [blame] | 47 | |
Tero Kristo | 519ab8b | 2013-10-22 11:49:58 +0300 | [diff] [blame] | 48 | v = omap2_clk_readl(clk, r); |
Paul Walmsley | 530e544 | 2011-02-25 15:39:28 -0700 | [diff] [blame] | 49 | v &= ~(1 << clk->enable_bit); |
Tero Kristo | 519ab8b | 2013-10-22 11:49:58 +0300 | [diff] [blame] | 50 | omap2_clk_writel(v, clk, r); |
Paul Walmsley | 530e544 | 2011-02-25 15:39:28 -0700 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | /* Public data */ |
| 54 | |
Rajendra Nayak | b4777a2 | 2012-04-27 15:53:48 +0530 | [diff] [blame] | 55 | const struct clk_hw_omap_ops clkhwops_iclk = { |
| 56 | .allow_idle = omap2_clkt_iclk_allow_idle, |
| 57 | .deny_idle = omap2_clkt_iclk_deny_idle, |
| 58 | }; |
| 59 | |
Mike Turquette | 32cc002 | 2012-11-10 16:58:41 -0700 | [diff] [blame] | 60 | const struct clk_hw_omap_ops clkhwops_iclk_wait = { |
| 61 | .allow_idle = omap2_clkt_iclk_allow_idle, |
| 62 | .deny_idle = omap2_clkt_iclk_deny_idle, |
| 63 | .find_idlest = omap2_clk_dflt_find_idlest, |
| 64 | .find_companion = omap2_clk_dflt_find_companion, |
| 65 | }; |
Paul Walmsley | 530e544 | 2011-02-25 15:39:28 -0700 | [diff] [blame] | 66 | |
Paul Walmsley | 530e544 | 2011-02-25 15:39:28 -0700 | [diff] [blame] | 67 | |
Paul Walmsley | 530e544 | 2011-02-25 15:39:28 -0700 | [diff] [blame] | 68 | |