| 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 | 3c82e22 | 2009-07-24 19:44:06 -0600 | [diff] [blame] | 5 | * Copyright (C) 2007-2009 Nokia Corporation | 
| Paul Walmsley | 02e19a9 | 2008-03-18 15:09:51 +0200 | [diff] [blame] | 6 | * | 
|  | 7 | * Written by Paul Walmsley | 
| Paul Walmsley | 542313c | 2008-07-03 12:24:45 +0300 | [diff] [blame] | 8 | * Testing and integration fixes by 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 | 
|  | 11 | * Richard Woodruff, Tony Lindgren, Tuukka Tikkanen, Karthik Dasu | 
|  | 12 | * | 
|  | 13 | * This program is free software; you can redistribute it and/or modify | 
|  | 14 | * it under the terms of the GNU General Public License version 2 as | 
|  | 15 | * published by the Free Software Foundation. | 
|  | 16 | */ | 
|  | 17 | #undef DEBUG | 
|  | 18 |  | 
|  | 19 | #include <linux/module.h> | 
|  | 20 | #include <linux/kernel.h> | 
|  | 21 | #include <linux/device.h> | 
|  | 22 | #include <linux/list.h> | 
|  | 23 | #include <linux/errno.h> | 
|  | 24 | #include <linux/delay.h> | 
|  | 25 | #include <linux/clk.h> | 
|  | 26 | #include <linux/io.h> | 
| Paul Walmsley | 542313c | 2008-07-03 12:24:45 +0300 | [diff] [blame] | 27 | #include <linux/limits.h> | 
| Russell King | fbd3bdb | 2008-09-06 12:13:59 +0100 | [diff] [blame] | 28 | #include <linux/bitops.h> | 
| Paul Walmsley | 02e19a9 | 2008-03-18 15:09:51 +0200 | [diff] [blame] | 29 |  | 
| Tony Lindgren | ce491cf | 2009-10-20 09:40:47 -0700 | [diff] [blame] | 30 | #include <plat/cpu.h> | 
|  | 31 | #include <plat/clock.h> | 
|  | 32 | #include <plat/sram.h> | 
| Paul Walmsley | 82e9bd5 | 2009-12-08 16:18:47 -0700 | [diff] [blame] | 33 | #include <plat/sdrc.h> | 
| Paul Walmsley | 02e19a9 | 2008-03-18 15:09:51 +0200 | [diff] [blame] | 34 | #include <asm/div64.h> | 
| Russell King | 44dc9d0 | 2009-01-19 15:51:11 +0000 | [diff] [blame] | 35 | #include <asm/clkdev.h> | 
| Paul Walmsley | 02e19a9 | 2008-03-18 15:09:51 +0200 | [diff] [blame] | 36 |  | 
| Paul Walmsley | 02e19a9 | 2008-03-18 15:09:51 +0200 | [diff] [blame] | 37 | #include "clock.h" | 
| Paul Walmsley | 82e9bd5 | 2009-12-08 16:18:47 -0700 | [diff] [blame] | 38 | #include "clock34xx.h" | 
|  | 39 | #include "sdrc.h" | 
| Paul Walmsley | 02e19a9 | 2008-03-18 15:09:51 +0200 | [diff] [blame] | 40 | #include "prm.h" | 
|  | 41 | #include "prm-regbits-34xx.h" | 
|  | 42 | #include "cm.h" | 
|  | 43 | #include "cm-regbits-34xx.h" | 
|  | 44 |  | 
| Paul Walmsley | c9812d0 | 2009-06-19 19:08:26 -0600 | [diff] [blame] | 45 | #define CYCLES_PER_MHZ			1000000 | 
|  | 46 |  | 
| Rajendra Nayak | 7a66a39 | 2009-10-05 13:31:44 -0700 | [diff] [blame] | 47 | /* | 
|  | 48 | * DPLL5_FREQ_FOR_USBHOST: USBHOST and USBTLL are the only clocks | 
|  | 49 | * that are sourced by DPLL5, and both of these require this clock | 
|  | 50 | * to be at 120 MHz for proper operation. | 
|  | 51 | */ | 
|  | 52 | #define DPLL5_FREQ_FOR_USBHOST		120000000 | 
|  | 53 |  | 
| Paul Walmsley | 82e9bd5 | 2009-12-08 16:18:47 -0700 | [diff] [blame] | 54 | /* needed by omap3_core_dpll_m2_set_rate() */ | 
|  | 55 | struct clk *sdrc_ick_p, *arm_fck_p; | 
|  | 56 |  | 
| Paul Walmsley | 02e19a9 | 2008-03-18 15:09:51 +0200 | [diff] [blame] | 57 | /** | 
| Paul Walmsley | 3c82e22 | 2009-07-24 19:44:06 -0600 | [diff] [blame] | 58 | * omap3430es2_clk_ssi_find_idlest - return CM_IDLEST info for SSI | 
|  | 59 | * @clk: struct clk * being enabled | 
|  | 60 | * @idlest_reg: void __iomem ** to store CM_IDLEST reg address into | 
|  | 61 | * @idlest_bit: pointer to a u8 to store the CM_IDLEST bit shift into | 
|  | 62 | * | 
|  | 63 | * The OMAP3430ES2 SSI target CM_IDLEST bit is at a different shift | 
|  | 64 | * from the CM_{I,F}CLKEN bit.  Pass back the correct info via | 
|  | 65 | * @idlest_reg and @idlest_bit.  No return value. | 
|  | 66 | */ | 
|  | 67 | static void omap3430es2_clk_ssi_find_idlest(struct clk *clk, | 
|  | 68 | void __iomem **idlest_reg, | 
|  | 69 | u8 *idlest_bit) | 
|  | 70 | { | 
|  | 71 | u32 r; | 
|  | 72 |  | 
|  | 73 | r = (((__force u32)clk->enable_reg & ~0xf0) | 0x20); | 
|  | 74 | *idlest_reg = (__force void __iomem *)r; | 
|  | 75 | *idlest_bit = OMAP3430ES2_ST_SSI_IDLE_SHIFT; | 
|  | 76 | } | 
|  | 77 |  | 
| Paul Walmsley | 82e9bd5 | 2009-12-08 16:18:47 -0700 | [diff] [blame] | 78 | const struct clkops clkops_omap3430es2_ssi_wait = { | 
|  | 79 | .enable		= omap2_dflt_clk_enable, | 
|  | 80 | .disable	= omap2_dflt_clk_disable, | 
|  | 81 | .find_idlest	= omap3430es2_clk_ssi_find_idlest, | 
|  | 82 | .find_companion = omap2_clk_dflt_find_companion, | 
|  | 83 | }; | 
|  | 84 |  | 
| Paul Walmsley | 3c82e22 | 2009-07-24 19:44:06 -0600 | [diff] [blame] | 85 | /** | 
|  | 86 | * omap3430es2_clk_dss_usbhost_find_idlest - CM_IDLEST info for DSS, USBHOST | 
|  | 87 | * @clk: struct clk * being enabled | 
|  | 88 | * @idlest_reg: void __iomem ** to store CM_IDLEST reg address into | 
|  | 89 | * @idlest_bit: pointer to a u8 to store the CM_IDLEST bit shift into | 
|  | 90 | * | 
|  | 91 | * Some OMAP modules on OMAP3 ES2+ chips have both initiator and | 
|  | 92 | * target IDLEST bits.  For our purposes, we are concerned with the | 
|  | 93 | * target IDLEST bits, which exist at a different bit position than | 
|  | 94 | * the *CLKEN bit position for these modules (DSS and USBHOST) (The | 
|  | 95 | * default find_idlest code assumes that they are at the same | 
|  | 96 | * position.)  No return value. | 
|  | 97 | */ | 
|  | 98 | static void omap3430es2_clk_dss_usbhost_find_idlest(struct clk *clk, | 
|  | 99 | void __iomem **idlest_reg, | 
|  | 100 | u8 *idlest_bit) | 
|  | 101 | { | 
|  | 102 | u32 r; | 
|  | 103 |  | 
|  | 104 | r = (((__force u32)clk->enable_reg & ~0xf0) | 0x20); | 
|  | 105 | *idlest_reg = (__force void __iomem *)r; | 
|  | 106 | /* USBHOST_IDLE has same shift */ | 
|  | 107 | *idlest_bit = OMAP3430ES2_ST_DSS_IDLE_SHIFT; | 
|  | 108 | } | 
|  | 109 |  | 
| Paul Walmsley | 82e9bd5 | 2009-12-08 16:18:47 -0700 | [diff] [blame] | 110 | const struct clkops clkops_omap3430es2_dss_usbhost_wait = { | 
|  | 111 | .enable		= omap2_dflt_clk_enable, | 
|  | 112 | .disable	= omap2_dflt_clk_disable, | 
|  | 113 | .find_idlest	= omap3430es2_clk_dss_usbhost_find_idlest, | 
|  | 114 | .find_companion = omap2_clk_dflt_find_companion, | 
|  | 115 | }; | 
|  | 116 |  | 
| Paul Walmsley | 3c82e22 | 2009-07-24 19:44:06 -0600 | [diff] [blame] | 117 | /** | 
|  | 118 | * omap3430es2_clk_hsotgusb_find_idlest - return CM_IDLEST info for HSOTGUSB | 
|  | 119 | * @clk: struct clk * being enabled | 
|  | 120 | * @idlest_reg: void __iomem ** to store CM_IDLEST reg address into | 
|  | 121 | * @idlest_bit: pointer to a u8 to store the CM_IDLEST bit shift into | 
|  | 122 | * | 
|  | 123 | * The OMAP3430ES2 HSOTGUSB target CM_IDLEST bit is at a different | 
|  | 124 | * shift from the CM_{I,F}CLKEN bit.  Pass back the correct info via | 
|  | 125 | * @idlest_reg and @idlest_bit.  No return value. | 
|  | 126 | */ | 
|  | 127 | static void omap3430es2_clk_hsotgusb_find_idlest(struct clk *clk, | 
|  | 128 | void __iomem **idlest_reg, | 
|  | 129 | u8 *idlest_bit) | 
|  | 130 | { | 
|  | 131 | u32 r; | 
|  | 132 |  | 
|  | 133 | r = (((__force u32)clk->enable_reg & ~0xf0) | 0x20); | 
|  | 134 | *idlest_reg = (__force void __iomem *)r; | 
|  | 135 | *idlest_bit = OMAP3430ES2_ST_HSOTGUSB_IDLE_SHIFT; | 
|  | 136 | } | 
|  | 137 |  | 
| Paul Walmsley | 82e9bd5 | 2009-12-08 16:18:47 -0700 | [diff] [blame] | 138 | const struct clkops clkops_omap3430es2_hsotgusb_wait = { | 
|  | 139 | .enable		= omap2_dflt_clk_enable, | 
|  | 140 | .disable	= omap2_dflt_clk_disable, | 
|  | 141 | .find_idlest	= omap3430es2_clk_hsotgusb_find_idlest, | 
|  | 142 | .find_companion = omap2_clk_dflt_find_companion, | 
|  | 143 | }; | 
|  | 144 |  | 
| Paul Walmsley | 82e9bd5 | 2009-12-08 16:18:47 -0700 | [diff] [blame] | 145 | const struct clkops clkops_noncore_dpll_ops = { | 
|  | 146 | .enable		= omap3_noncore_dpll_enable, | 
|  | 147 | .disable	= omap3_noncore_dpll_disable, | 
|  | 148 | }; | 
| Paul Walmsley | 16c90f0 | 2009-01-27 19:12:47 -0700 | [diff] [blame] | 149 |  | 
| Paul Walmsley | 82e9bd5 | 2009-12-08 16:18:47 -0700 | [diff] [blame] | 150 | int omap3_dpll4_set_rate(struct clk *clk, unsigned long rate) | 
| Paul Walmsley | 16c90f0 | 2009-01-27 19:12:47 -0700 | [diff] [blame] | 151 | { | 
|  | 152 | /* | 
|  | 153 | * According to the 12-5 CDP code from TI, "Limitation 2.5" | 
|  | 154 | * on 3430ES1 prevents us from changing DPLL multipliers or dividers | 
|  | 155 | * on DPLL4. | 
|  | 156 | */ | 
|  | 157 | if (omap_rev() == OMAP3430_REV_ES1_0) { | 
|  | 158 | printk(KERN_ERR "clock: DPLL4 cannot change rate due to " | 
|  | 159 | "silicon 'Limitation 2.5' on 3430ES1.\n"); | 
|  | 160 | return -EINVAL; | 
|  | 161 | } | 
|  | 162 | return omap3_noncore_dpll_set_rate(clk, rate); | 
|  | 163 | } | 
|  | 164 |  | 
| Paul Walmsley | 0eafd47 | 2009-01-28 12:27:42 -0700 | [diff] [blame] | 165 |  | 
|  | 166 | /* | 
|  | 167 | * CORE DPLL (DPLL3) rate programming functions | 
|  | 168 | * | 
|  | 169 | * These call into SRAM code to do the actual CM writes, since the SDRAM | 
|  | 170 | * is clocked from DPLL3. | 
|  | 171 | */ | 
|  | 172 |  | 
|  | 173 | /** | 
|  | 174 | * omap3_core_dpll_m2_set_rate - set CORE DPLL M2 divider | 
|  | 175 | * @clk: struct clk * of DPLL to set | 
|  | 176 | * @rate: rounded target rate | 
|  | 177 | * | 
|  | 178 | * Program the DPLL M2 divider with the rounded target rate.  Returns | 
|  | 179 | * -EINVAL upon error, or 0 upon success. | 
|  | 180 | */ | 
| Paul Walmsley | 82e9bd5 | 2009-12-08 16:18:47 -0700 | [diff] [blame] | 181 | int omap3_core_dpll_m2_set_rate(struct clk *clk, unsigned long rate) | 
| Paul Walmsley | 0eafd47 | 2009-01-28 12:27:42 -0700 | [diff] [blame] | 182 | { | 
|  | 183 | u32 new_div = 0; | 
| Paul Walmsley | 4519c2b | 2009-05-12 17:26:32 -0600 | [diff] [blame] | 184 | u32 unlock_dll = 0; | 
| Paul Walmsley | c9812d0 | 2009-06-19 19:08:26 -0600 | [diff] [blame] | 185 | u32 c; | 
| Paul Walmsley | 82e9bd5 | 2009-12-08 16:18:47 -0700 | [diff] [blame] | 186 | unsigned long validrate, sdrcrate, _mpurate; | 
| Jean Pihet | 58cda88 | 2009-07-24 19:43:25 -0600 | [diff] [blame] | 187 | struct omap_sdrc_params *sdrc_cs0; | 
|  | 188 | struct omap_sdrc_params *sdrc_cs1; | 
|  | 189 | int ret; | 
| Paul Walmsley | 0eafd47 | 2009-01-28 12:27:42 -0700 | [diff] [blame] | 190 |  | 
|  | 191 | if (!clk || !rate) | 
|  | 192 | return -EINVAL; | 
|  | 193 |  | 
| Paul Walmsley | 0eafd47 | 2009-01-28 12:27:42 -0700 | [diff] [blame] | 194 | validrate = omap2_clksel_round_rate_div(clk, rate, &new_div); | 
|  | 195 | if (validrate != rate) | 
|  | 196 | return -EINVAL; | 
|  | 197 |  | 
| Paul Walmsley | 82e9bd5 | 2009-12-08 16:18:47 -0700 | [diff] [blame] | 198 | sdrcrate = sdrc_ick_p->rate; | 
| Paul Walmsley | 0eafd47 | 2009-01-28 12:27:42 -0700 | [diff] [blame] | 199 | if (rate > clk->rate) | 
| Tero Kristo | 3afec633 | 2009-06-19 19:08:29 -0600 | [diff] [blame] | 200 | sdrcrate <<= ((rate / clk->rate) >> 1); | 
| Paul Walmsley | 0eafd47 | 2009-01-28 12:27:42 -0700 | [diff] [blame] | 201 | else | 
| Tero Kristo | 3afec633 | 2009-06-19 19:08:29 -0600 | [diff] [blame] | 202 | sdrcrate >>= ((clk->rate / rate) >> 1); | 
| Paul Walmsley | 0eafd47 | 2009-01-28 12:27:42 -0700 | [diff] [blame] | 203 |  | 
| Jean Pihet | 58cda88 | 2009-07-24 19:43:25 -0600 | [diff] [blame] | 204 | ret = omap2_sdrc_get_params(sdrcrate, &sdrc_cs0, &sdrc_cs1); | 
|  | 205 | if (ret) | 
| Paul Walmsley | 0eafd47 | 2009-01-28 12:27:42 -0700 | [diff] [blame] | 206 | return -EINVAL; | 
|  | 207 |  | 
| Paul Walmsley | 4519c2b | 2009-05-12 17:26:32 -0600 | [diff] [blame] | 208 | if (sdrcrate < MIN_SDRC_DLL_LOCK_FREQ) { | 
|  | 209 | pr_debug("clock: will unlock SDRC DLL\n"); | 
|  | 210 | unlock_dll = 1; | 
|  | 211 | } | 
|  | 212 |  | 
| Paul Walmsley | c9812d0 | 2009-06-19 19:08:26 -0600 | [diff] [blame] | 213 | /* | 
|  | 214 | * XXX This only needs to be done when the CPU frequency changes | 
|  | 215 | */ | 
| Paul Walmsley | 82e9bd5 | 2009-12-08 16:18:47 -0700 | [diff] [blame] | 216 | _mpurate = arm_fck_p->rate / CYCLES_PER_MHZ; | 
|  | 217 | c = (_mpurate << SDRC_MPURATE_SCALE) >> SDRC_MPURATE_BASE_SHIFT; | 
| Paul Walmsley | c9812d0 | 2009-06-19 19:08:26 -0600 | [diff] [blame] | 218 | c += 1;  /* for safety */ | 
|  | 219 | c *= SDRC_MPURATE_LOOPS; | 
|  | 220 | c >>= SDRC_MPURATE_SCALE; | 
|  | 221 | if (c == 0) | 
|  | 222 | c = 1; | 
|  | 223 |  | 
| Paul Walmsley | b7aee4b | 2009-05-12 17:27:10 -0600 | [diff] [blame] | 224 | pr_debug("clock: changing CORE DPLL rate from %lu to %lu\n", clk->rate, | 
|  | 225 | validrate); | 
| Jean Pihet | 58cda88 | 2009-07-24 19:43:25 -0600 | [diff] [blame] | 226 | pr_debug("clock: SDRC CS0 timing params used:" | 
|  | 227 | " RFR %08x CTRLA %08x CTRLB %08x MR %08x\n", | 
|  | 228 | sdrc_cs0->rfr_ctrl, sdrc_cs0->actim_ctrla, | 
|  | 229 | sdrc_cs0->actim_ctrlb, sdrc_cs0->mr); | 
|  | 230 | if (sdrc_cs1) | 
|  | 231 | pr_debug("clock: SDRC CS1 timing params used: " | 
|  | 232 | " RFR %08x CTRLA %08x CTRLB %08x MR %08x\n", | 
|  | 233 | sdrc_cs1->rfr_ctrl, sdrc_cs1->actim_ctrla, | 
|  | 234 | sdrc_cs1->actim_ctrlb, sdrc_cs1->mr); | 
| Paul Walmsley | 0eafd47 | 2009-01-28 12:27:42 -0700 | [diff] [blame] | 235 |  | 
| Jean Pihet | 58cda88 | 2009-07-24 19:43:25 -0600 | [diff] [blame] | 236 | if (sdrc_cs1) | 
|  | 237 | omap3_configure_core_dpll( | 
|  | 238 | new_div, unlock_dll, c, rate > clk->rate, | 
|  | 239 | sdrc_cs0->rfr_ctrl, sdrc_cs0->actim_ctrla, | 
|  | 240 | sdrc_cs0->actim_ctrlb, sdrc_cs0->mr, | 
|  | 241 | sdrc_cs1->rfr_ctrl, sdrc_cs1->actim_ctrla, | 
|  | 242 | sdrc_cs1->actim_ctrlb, sdrc_cs1->mr); | 
|  | 243 | else | 
|  | 244 | omap3_configure_core_dpll( | 
|  | 245 | new_div, unlock_dll, c, rate > clk->rate, | 
|  | 246 | sdrc_cs0->rfr_ctrl, sdrc_cs0->actim_ctrla, | 
|  | 247 | sdrc_cs0->actim_ctrlb, sdrc_cs0->mr, | 
|  | 248 | 0, 0, 0, 0); | 
| Paul Walmsley | 0eafd47 | 2009-01-28 12:27:42 -0700 | [diff] [blame] | 249 |  | 
| Paul Walmsley | 0eafd47 | 2009-01-28 12:27:42 -0700 | [diff] [blame] | 250 | return 0; | 
|  | 251 | } | 
|  | 252 |  | 
| Paul Walmsley | 542313c | 2008-07-03 12:24:45 +0300 | [diff] [blame] | 253 | /* Common clock code */ | 
|  | 254 |  | 
| Paul Walmsley | 02e19a9 | 2008-03-18 15:09:51 +0200 | [diff] [blame] | 255 | /* | 
|  | 256 | * As it is structured now, this will prevent an OMAP2/3 multiboot | 
|  | 257 | * kernel from compiling.  This will need further attention. | 
|  | 258 | */ | 
|  | 259 | #if defined(CONFIG_ARCH_OMAP3) | 
|  | 260 |  | 
| Paul Walmsley | 82e9bd5 | 2009-12-08 16:18:47 -0700 | [diff] [blame] | 261 | struct clk_functions omap2_clk_functions = { | 
| Paul Walmsley | 02e19a9 | 2008-03-18 15:09:51 +0200 | [diff] [blame] | 262 | .clk_enable		= omap2_clk_enable, | 
|  | 263 | .clk_disable		= omap2_clk_disable, | 
|  | 264 | .clk_round_rate		= omap2_clk_round_rate, | 
|  | 265 | .clk_set_rate		= omap2_clk_set_rate, | 
|  | 266 | .clk_set_parent		= omap2_clk_set_parent, | 
|  | 267 | .clk_disable_unused	= omap2_clk_disable_unused, | 
|  | 268 | }; | 
|  | 269 |  | 
|  | 270 | /* | 
|  | 271 | * Set clocks for bypass mode for reboot to work. | 
|  | 272 | */ | 
|  | 273 | void omap2_clk_prepare_for_reboot(void) | 
|  | 274 | { | 
|  | 275 | /* REVISIT: Not ready for 343x */ | 
|  | 276 | #if 0 | 
|  | 277 | u32 rate; | 
|  | 278 |  | 
|  | 279 | if (vclk == NULL || sclk == NULL) | 
|  | 280 | return; | 
|  | 281 |  | 
|  | 282 | rate = clk_get_rate(sclk); | 
|  | 283 | clk_set_rate(vclk, rate); | 
|  | 284 | #endif | 
|  | 285 | } | 
|  | 286 |  | 
| Paul Walmsley | 82e9bd5 | 2009-12-08 16:18:47 -0700 | [diff] [blame] | 287 | void omap3_clk_lock_dpll5(void) | 
| Rajendra Nayak | 7a66a39 | 2009-10-05 13:31:44 -0700 | [diff] [blame] | 288 | { | 
|  | 289 | struct clk *dpll5_clk; | 
|  | 290 | struct clk *dpll5_m2_clk; | 
|  | 291 |  | 
|  | 292 | dpll5_clk = clk_get(NULL, "dpll5_ck"); | 
|  | 293 | clk_set_rate(dpll5_clk, DPLL5_FREQ_FOR_USBHOST); | 
|  | 294 | clk_enable(dpll5_clk); | 
|  | 295 |  | 
|  | 296 | /* Enable autoidle to allow it to enter low power bypass */ | 
|  | 297 | omap3_dpll_allow_idle(dpll5_clk); | 
|  | 298 |  | 
|  | 299 | /* Program dpll5_m2_clk divider for no division */ | 
|  | 300 | dpll5_m2_clk = clk_get(NULL, "dpll5_m2_ck"); | 
|  | 301 | clk_enable(dpll5_m2_clk); | 
|  | 302 | clk_set_rate(dpll5_m2_clk, DPLL5_FREQ_FOR_USBHOST); | 
|  | 303 |  | 
|  | 304 | clk_disable(dpll5_m2_clk); | 
|  | 305 | clk_disable(dpll5_clk); | 
|  | 306 | return; | 
|  | 307 | } | 
|  | 308 |  | 
| Paul Walmsley | 02e19a9 | 2008-03-18 15:09:51 +0200 | [diff] [blame] | 309 | /* REVISIT: Move this init stuff out into clock.c */ | 
|  | 310 |  | 
|  | 311 | /* | 
|  | 312 | * Switch the MPU rate if specified on cmdline. | 
|  | 313 | * We cannot do this early until cmdline is parsed. | 
|  | 314 | */ | 
|  | 315 | static int __init omap2_clk_arch_init(void) | 
|  | 316 | { | 
| Paul Walmsley | 82e9bd5 | 2009-12-08 16:18:47 -0700 | [diff] [blame] | 317 | struct clk *osc_sys_ck, *dpll1_ck, *arm_fck, *core_ck; | 
|  | 318 | unsigned long osc_sys_rate; | 
|  | 319 |  | 
| Paul Walmsley | 02e19a9 | 2008-03-18 15:09:51 +0200 | [diff] [blame] | 320 | if (!mpurate) | 
|  | 321 | return -EINVAL; | 
|  | 322 |  | 
| Paul Walmsley | 82e9bd5 | 2009-12-08 16:18:47 -0700 | [diff] [blame] | 323 | /* XXX test these for success */ | 
|  | 324 | dpll1_ck = clk_get(NULL, "dpll1_ck"); | 
|  | 325 | arm_fck = clk_get(NULL, "arm_fck"); | 
|  | 326 | core_ck = clk_get(NULL, "core_ck"); | 
|  | 327 | osc_sys_ck = clk_get(NULL, "osc_sys_ck"); | 
|  | 328 |  | 
| Paul Walmsley | 02e19a9 | 2008-03-18 15:09:51 +0200 | [diff] [blame] | 329 | /* REVISIT: not yet ready for 343x */ | 
| Paul Walmsley | 82e9bd5 | 2009-12-08 16:18:47 -0700 | [diff] [blame] | 330 | if (clk_set_rate(dpll1_ck, mpurate)) | 
| Sanjeev Premi | 11b6638 | 2009-09-03 20:13:58 +0300 | [diff] [blame] | 331 | printk(KERN_ERR "*** Unable to set MPU rate\n"); | 
| Paul Walmsley | 02e19a9 | 2008-03-18 15:09:51 +0200 | [diff] [blame] | 332 |  | 
|  | 333 | recalculate_root_clocks(); | 
|  | 334 |  | 
| Paul Walmsley | 82e9bd5 | 2009-12-08 16:18:47 -0700 | [diff] [blame] | 335 | osc_sys_rate = clk_get_rate(osc_sys_ck); | 
|  | 336 |  | 
|  | 337 | pr_info("Switched to new clocking rate (Crystal/Core/MPU): " | 
|  | 338 | "%ld.%01ld/%ld/%ld MHz\n", | 
|  | 339 | (osc_sys_rate / 1000000), | 
|  | 340 | ((osc_sys_rate / 100000) % 10), | 
|  | 341 | (clk_get_rate(core_ck) / 1000000), | 
|  | 342 | (clk_get_rate(arm_fck) / 1000000)); | 
| Sanjeev Premi | 11b6638 | 2009-09-03 20:13:58 +0300 | [diff] [blame] | 343 |  | 
|  | 344 | calibrate_delay(); | 
| Paul Walmsley | 02e19a9 | 2008-03-18 15:09:51 +0200 | [diff] [blame] | 345 |  | 
|  | 346 | return 0; | 
|  | 347 | } | 
|  | 348 | arch_initcall(omap2_clk_arch_init); | 
|  | 349 |  | 
| Paul Walmsley | 02e19a9 | 2008-03-18 15:09:51 +0200 | [diff] [blame] | 350 |  | 
|  | 351 | #endif | 
| Paul Walmsley | 82e9bd5 | 2009-12-08 16:18:47 -0700 | [diff] [blame] | 352 |  | 
|  | 353 |  |