Paul Walmsley | 02e19a9 | 2008-03-18 15:09:51 +0200 | [diff] [blame] | 1 | /* |
| 2 | * OMAP3-specific clock framework functions |
| 3 | * |
Paul Walmsley | 542313c | 2008-07-03 12:24:45 +0300 | [diff] [blame] | 4 | * Copyright (C) 2007-2008 Texas Instruments, Inc. |
Paul Walmsley | ec538e3 | 2011-02-25 15:39:30 -0700 | [diff] [blame] | 5 | * Copyright (C) 2007-2011 Nokia Corporation |
Paul Walmsley | 02e19a9 | 2008-03-18 15:09:51 +0200 | [diff] [blame] | 6 | * |
Paul Walmsley | da4d290 | 2010-01-26 20:13:10 -0700 | [diff] [blame] | 7 | * Paul Walmsley |
| 8 | * Jouni Högander |
Paul Walmsley | 02e19a9 | 2008-03-18 15:09:51 +0200 | [diff] [blame] | 9 | * |
| 10 | * Parts of this code are based on code written by |
Paul Walmsley | 657ebfa | 2010-02-22 22:09:20 -0700 | [diff] [blame] | 11 | * Richard Woodruff, Tony Lindgren, Tuukka Tikkanen, Karthik Dasu, |
| 12 | * Russell King |
Paul Walmsley | 02e19a9 | 2008-03-18 15:09:51 +0200 | [diff] [blame] | 13 | * |
| 14 | * This program is free software; you can redistribute it and/or modify |
| 15 | * it under the terms of the GNU General Public License version 2 as |
| 16 | * published by the Free Software Foundation. |
| 17 | */ |
| 18 | #undef DEBUG |
| 19 | |
Paul Walmsley | 02e19a9 | 2008-03-18 15:09:51 +0200 | [diff] [blame] | 20 | #include <linux/kernel.h> |
Paul Walmsley | 02e19a9 | 2008-03-18 15:09:51 +0200 | [diff] [blame] | 21 | #include <linux/clk.h> |
| 22 | #include <linux/io.h> |
| 23 | |
Paul Walmsley | 02e19a9 | 2008-03-18 15:09:51 +0200 | [diff] [blame] | 24 | #include "clock.h" |
Paul Walmsley | 82e9bd5 | 2009-12-08 16:18:47 -0700 | [diff] [blame] | 25 | #include "clock34xx.h" |
Paul Walmsley | ff4ae5d | 2012-10-21 01:01:11 -0600 | [diff] [blame] | 26 | #include "cm3xxx.h" |
Paul Walmsley | 02e19a9 | 2008-03-18 15:09:51 +0200 | [diff] [blame] | 27 | #include "cm-regbits-34xx.h" |
| 28 | |
Paul Walmsley | 02e19a9 | 2008-03-18 15:09:51 +0200 | [diff] [blame] | 29 | /** |
Paul Walmsley | 3c82e22 | 2009-07-24 19:44:06 -0600 | [diff] [blame] | 30 | * omap3430es2_clk_ssi_find_idlest - return CM_IDLEST info for SSI |
| 31 | * @clk: struct clk * being enabled |
| 32 | * @idlest_reg: void __iomem ** to store CM_IDLEST reg address into |
| 33 | * @idlest_bit: pointer to a u8 to store the CM_IDLEST bit shift into |
Ranjith Lohithakshan | 419cc97 | 2010-02-24 12:05:54 -0700 | [diff] [blame] | 34 | * @idlest_val: pointer to a u8 to store the CM_IDLEST indicator |
Paul Walmsley | 3c82e22 | 2009-07-24 19:44:06 -0600 | [diff] [blame] | 35 | * |
| 36 | * The OMAP3430ES2 SSI target CM_IDLEST bit is at a different shift |
| 37 | * from the CM_{I,F}CLKEN bit. Pass back the correct info via |
| 38 | * @idlest_reg and @idlest_bit. No return value. |
| 39 | */ |
Rajendra Nayak | b4777a2 | 2012-04-27 15:53:48 +0530 | [diff] [blame^] | 40 | #ifdef CONFIG_COMMON_CLK |
| 41 | static void omap3430es2_clk_ssi_find_idlest(struct clk_hw_omap *clk, |
| 42 | #else |
Paul Walmsley | 3c82e22 | 2009-07-24 19:44:06 -0600 | [diff] [blame] | 43 | static void omap3430es2_clk_ssi_find_idlest(struct clk *clk, |
Rajendra Nayak | b4777a2 | 2012-04-27 15:53:48 +0530 | [diff] [blame^] | 44 | #endif |
Paul Walmsley | 3c82e22 | 2009-07-24 19:44:06 -0600 | [diff] [blame] | 45 | void __iomem **idlest_reg, |
Ranjith Lohithakshan | 419cc97 | 2010-02-24 12:05:54 -0700 | [diff] [blame] | 46 | u8 *idlest_bit, |
| 47 | u8 *idlest_val) |
Paul Walmsley | 3c82e22 | 2009-07-24 19:44:06 -0600 | [diff] [blame] | 48 | { |
| 49 | u32 r; |
| 50 | |
| 51 | r = (((__force u32)clk->enable_reg & ~0xf0) | 0x20); |
| 52 | *idlest_reg = (__force void __iomem *)r; |
| 53 | *idlest_bit = OMAP3430ES2_ST_SSI_IDLE_SHIFT; |
Ranjith Lohithakshan | 419cc97 | 2010-02-24 12:05:54 -0700 | [diff] [blame] | 54 | *idlest_val = OMAP34XX_CM_IDLEST_VAL; |
Paul Walmsley | 3c82e22 | 2009-07-24 19:44:06 -0600 | [diff] [blame] | 55 | } |
Rajendra Nayak | b4777a2 | 2012-04-27 15:53:48 +0530 | [diff] [blame^] | 56 | #ifdef CONFIG_COMMON_CLK |
| 57 | const struct clk_hw_omap_ops clkhwops_omap3430es2_ssi_wait = { |
| 58 | .find_idlest = omap3430es2_clk_ssi_find_idlest, |
| 59 | .find_companion = omap2_clk_dflt_find_companion, |
| 60 | }; |
Paul Walmsley | 3c82e22 | 2009-07-24 19:44:06 -0600 | [diff] [blame] | 61 | |
Rajendra Nayak | b4777a2 | 2012-04-27 15:53:48 +0530 | [diff] [blame^] | 62 | const struct clk_hw_omap_ops clkhwops_omap3430es2_iclk_ssi_wait = { |
| 63 | .allow_idle = omap2_clkt_iclk_allow_idle, |
| 64 | .deny_idle = omap2_clkt_iclk_deny_idle, |
| 65 | .find_idlest = omap3430es2_clk_ssi_find_idlest, |
| 66 | .find_companion = omap2_clk_dflt_find_companion, |
| 67 | }; |
| 68 | #else |
Paul Walmsley | 82e9bd5 | 2009-12-08 16:18:47 -0700 | [diff] [blame] | 69 | const struct clkops clkops_omap3430es2_ssi_wait = { |
| 70 | .enable = omap2_dflt_clk_enable, |
| 71 | .disable = omap2_dflt_clk_disable, |
| 72 | .find_idlest = omap3430es2_clk_ssi_find_idlest, |
| 73 | .find_companion = omap2_clk_dflt_find_companion, |
| 74 | }; |
| 75 | |
Paul Walmsley | ec538e3 | 2011-02-25 15:39:30 -0700 | [diff] [blame] | 76 | const struct clkops clkops_omap3430es2_iclk_ssi_wait = { |
| 77 | .enable = omap2_dflt_clk_enable, |
| 78 | .disable = omap2_dflt_clk_disable, |
| 79 | .find_idlest = omap3430es2_clk_ssi_find_idlest, |
| 80 | .find_companion = omap2_clk_dflt_find_companion, |
| 81 | .allow_idle = omap2_clkt_iclk_allow_idle, |
| 82 | .deny_idle = omap2_clkt_iclk_deny_idle, |
| 83 | }; |
Rajendra Nayak | b4777a2 | 2012-04-27 15:53:48 +0530 | [diff] [blame^] | 84 | #endif |
Paul Walmsley | ec538e3 | 2011-02-25 15:39:30 -0700 | [diff] [blame] | 85 | |
Paul Walmsley | 3c82e22 | 2009-07-24 19:44:06 -0600 | [diff] [blame] | 86 | /** |
| 87 | * omap3430es2_clk_dss_usbhost_find_idlest - CM_IDLEST info for DSS, USBHOST |
| 88 | * @clk: struct clk * being enabled |
| 89 | * @idlest_reg: void __iomem ** to store CM_IDLEST reg address into |
| 90 | * @idlest_bit: pointer to a u8 to store the CM_IDLEST bit shift into |
Ranjith Lohithakshan | 419cc97 | 2010-02-24 12:05:54 -0700 | [diff] [blame] | 91 | * @idlest_val: pointer to a u8 to store the CM_IDLEST indicator |
Paul Walmsley | 3c82e22 | 2009-07-24 19:44:06 -0600 | [diff] [blame] | 92 | * |
| 93 | * Some OMAP modules on OMAP3 ES2+ chips have both initiator and |
| 94 | * target IDLEST bits. For our purposes, we are concerned with the |
| 95 | * target IDLEST bits, which exist at a different bit position than |
| 96 | * the *CLKEN bit position for these modules (DSS and USBHOST) (The |
| 97 | * default find_idlest code assumes that they are at the same |
| 98 | * position.) No return value. |
| 99 | */ |
Rajendra Nayak | b4777a2 | 2012-04-27 15:53:48 +0530 | [diff] [blame^] | 100 | #ifdef CONFIG_COMMON_CLK |
| 101 | static void omap3430es2_clk_dss_usbhost_find_idlest(struct clk_hw_omap *clk, |
| 102 | #else |
Paul Walmsley | 3c82e22 | 2009-07-24 19:44:06 -0600 | [diff] [blame] | 103 | static void omap3430es2_clk_dss_usbhost_find_idlest(struct clk *clk, |
Rajendra Nayak | b4777a2 | 2012-04-27 15:53:48 +0530 | [diff] [blame^] | 104 | #endif |
Paul Walmsley | 3c82e22 | 2009-07-24 19:44:06 -0600 | [diff] [blame] | 105 | void __iomem **idlest_reg, |
Ranjith Lohithakshan | 419cc97 | 2010-02-24 12:05:54 -0700 | [diff] [blame] | 106 | u8 *idlest_bit, |
| 107 | u8 *idlest_val) |
Paul Walmsley | 3c82e22 | 2009-07-24 19:44:06 -0600 | [diff] [blame] | 108 | { |
| 109 | u32 r; |
| 110 | |
| 111 | r = (((__force u32)clk->enable_reg & ~0xf0) | 0x20); |
| 112 | *idlest_reg = (__force void __iomem *)r; |
| 113 | /* USBHOST_IDLE has same shift */ |
| 114 | *idlest_bit = OMAP3430ES2_ST_DSS_IDLE_SHIFT; |
Ranjith Lohithakshan | 419cc97 | 2010-02-24 12:05:54 -0700 | [diff] [blame] | 115 | *idlest_val = OMAP34XX_CM_IDLEST_VAL; |
Paul Walmsley | 3c82e22 | 2009-07-24 19:44:06 -0600 | [diff] [blame] | 116 | } |
Rajendra Nayak | b4777a2 | 2012-04-27 15:53:48 +0530 | [diff] [blame^] | 117 | #ifdef CONFIG_COMMON_CLK |
| 118 | const struct clk_hw_omap_ops clkhwops_omap3430es2_dss_usbhost_wait = { |
| 119 | .find_idlest = omap3430es2_clk_dss_usbhost_find_idlest, |
| 120 | .find_companion = omap2_clk_dflt_find_companion, |
| 121 | }; |
Paul Walmsley | 3c82e22 | 2009-07-24 19:44:06 -0600 | [diff] [blame] | 122 | |
Rajendra Nayak | b4777a2 | 2012-04-27 15:53:48 +0530 | [diff] [blame^] | 123 | const struct clk_hw_omap_ops clkhwops_omap3430es2_iclk_dss_usbhost_wait = { |
| 124 | .allow_idle = omap2_clkt_iclk_allow_idle, |
| 125 | .deny_idle = omap2_clkt_iclk_deny_idle, |
| 126 | .find_idlest = omap3430es2_clk_dss_usbhost_find_idlest, |
| 127 | .find_companion = omap2_clk_dflt_find_companion, |
| 128 | }; |
| 129 | #else |
Paul Walmsley | 82e9bd5 | 2009-12-08 16:18:47 -0700 | [diff] [blame] | 130 | const struct clkops clkops_omap3430es2_dss_usbhost_wait = { |
| 131 | .enable = omap2_dflt_clk_enable, |
| 132 | .disable = omap2_dflt_clk_disable, |
| 133 | .find_idlest = omap3430es2_clk_dss_usbhost_find_idlest, |
| 134 | .find_companion = omap2_clk_dflt_find_companion, |
| 135 | }; |
| 136 | |
Paul Walmsley | ec538e3 | 2011-02-25 15:39:30 -0700 | [diff] [blame] | 137 | const struct clkops clkops_omap3430es2_iclk_dss_usbhost_wait = { |
| 138 | .enable = omap2_dflt_clk_enable, |
| 139 | .disable = omap2_dflt_clk_disable, |
| 140 | .find_idlest = omap3430es2_clk_dss_usbhost_find_idlest, |
| 141 | .find_companion = omap2_clk_dflt_find_companion, |
| 142 | .allow_idle = omap2_clkt_iclk_allow_idle, |
| 143 | .deny_idle = omap2_clkt_iclk_deny_idle, |
| 144 | }; |
Rajendra Nayak | b4777a2 | 2012-04-27 15:53:48 +0530 | [diff] [blame^] | 145 | #endif |
Paul Walmsley | ec538e3 | 2011-02-25 15:39:30 -0700 | [diff] [blame] | 146 | |
Paul Walmsley | 3c82e22 | 2009-07-24 19:44:06 -0600 | [diff] [blame] | 147 | /** |
| 148 | * omap3430es2_clk_hsotgusb_find_idlest - return CM_IDLEST info for HSOTGUSB |
| 149 | * @clk: struct clk * being enabled |
| 150 | * @idlest_reg: void __iomem ** to store CM_IDLEST reg address into |
| 151 | * @idlest_bit: pointer to a u8 to store the CM_IDLEST bit shift into |
Ranjith Lohithakshan | 419cc97 | 2010-02-24 12:05:54 -0700 | [diff] [blame] | 152 | * @idlest_val: pointer to a u8 to store the CM_IDLEST indicator |
Paul Walmsley | 3c82e22 | 2009-07-24 19:44:06 -0600 | [diff] [blame] | 153 | * |
| 154 | * The OMAP3430ES2 HSOTGUSB target CM_IDLEST bit is at a different |
| 155 | * shift from the CM_{I,F}CLKEN bit. Pass back the correct info via |
| 156 | * @idlest_reg and @idlest_bit. No return value. |
| 157 | */ |
Rajendra Nayak | b4777a2 | 2012-04-27 15:53:48 +0530 | [diff] [blame^] | 158 | #ifdef CONFIG_COMMON_CLK |
| 159 | static void omap3430es2_clk_hsotgusb_find_idlest(struct clk_hw_omap *clk, |
| 160 | #else |
Paul Walmsley | 3c82e22 | 2009-07-24 19:44:06 -0600 | [diff] [blame] | 161 | static void omap3430es2_clk_hsotgusb_find_idlest(struct clk *clk, |
Rajendra Nayak | b4777a2 | 2012-04-27 15:53:48 +0530 | [diff] [blame^] | 162 | #endif |
Paul Walmsley | 3c82e22 | 2009-07-24 19:44:06 -0600 | [diff] [blame] | 163 | void __iomem **idlest_reg, |
Ranjith Lohithakshan | 419cc97 | 2010-02-24 12:05:54 -0700 | [diff] [blame] | 164 | u8 *idlest_bit, |
| 165 | u8 *idlest_val) |
Paul Walmsley | 3c82e22 | 2009-07-24 19:44:06 -0600 | [diff] [blame] | 166 | { |
| 167 | u32 r; |
| 168 | |
| 169 | r = (((__force u32)clk->enable_reg & ~0xf0) | 0x20); |
| 170 | *idlest_reg = (__force void __iomem *)r; |
| 171 | *idlest_bit = OMAP3430ES2_ST_HSOTGUSB_IDLE_SHIFT; |
Ranjith Lohithakshan | 419cc97 | 2010-02-24 12:05:54 -0700 | [diff] [blame] | 172 | *idlest_val = OMAP34XX_CM_IDLEST_VAL; |
Paul Walmsley | 3c82e22 | 2009-07-24 19:44:06 -0600 | [diff] [blame] | 173 | } |
Rajendra Nayak | b4777a2 | 2012-04-27 15:53:48 +0530 | [diff] [blame^] | 174 | #ifdef CONFIG_COMMON_CLK |
| 175 | const struct clk_hw_omap_ops clkhwops_omap3430es2_iclk_hsotgusb_wait = { |
| 176 | .allow_idle = omap2_clkt_iclk_allow_idle, |
| 177 | .deny_idle = omap2_clkt_iclk_deny_idle, |
| 178 | .find_idlest = omap3430es2_clk_hsotgusb_find_idlest, |
| 179 | .find_companion = omap2_clk_dflt_find_companion, |
| 180 | }; |
Paul Walmsley | 3c82e22 | 2009-07-24 19:44:06 -0600 | [diff] [blame] | 181 | |
Rajendra Nayak | b4777a2 | 2012-04-27 15:53:48 +0530 | [diff] [blame^] | 182 | const struct clk_hw_omap_ops clkhwops_omap3430es2_hsotgusb_wait = { |
| 183 | .find_idlest = omap3430es2_clk_hsotgusb_find_idlest, |
| 184 | .find_companion = omap2_clk_dflt_find_companion, |
| 185 | }; |
| 186 | #else |
Paul Walmsley | 82e9bd5 | 2009-12-08 16:18:47 -0700 | [diff] [blame] | 187 | const struct clkops clkops_omap3430es2_hsotgusb_wait = { |
| 188 | .enable = omap2_dflt_clk_enable, |
| 189 | .disable = omap2_dflt_clk_disable, |
| 190 | .find_idlest = omap3430es2_clk_hsotgusb_find_idlest, |
| 191 | .find_companion = omap2_clk_dflt_find_companion, |
| 192 | }; |
Paul Walmsley | ec538e3 | 2011-02-25 15:39:30 -0700 | [diff] [blame] | 193 | |
| 194 | const struct clkops clkops_omap3430es2_iclk_hsotgusb_wait = { |
| 195 | .enable = omap2_dflt_clk_enable, |
| 196 | .disable = omap2_dflt_clk_disable, |
| 197 | .find_idlest = omap3430es2_clk_hsotgusb_find_idlest, |
| 198 | .find_companion = omap2_clk_dflt_find_companion, |
| 199 | .allow_idle = omap2_clkt_iclk_allow_idle, |
| 200 | .deny_idle = omap2_clkt_iclk_deny_idle, |
| 201 | }; |
Rajendra Nayak | b4777a2 | 2012-04-27 15:53:48 +0530 | [diff] [blame^] | 202 | #endif |