Paul Walmsley | 543d937 | 2008-03-18 10:22:06 +0200 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/mach-omap2/clock.h |
| 3 | * |
Paul Walmsley | d8a9445 | 2009-12-08 16:21:29 -0700 | [diff] [blame] | 4 | * Copyright (C) 2005-2009 Texas Instruments, Inc. |
Paul Walmsley | 530e544 | 2011-02-25 15:39:28 -0700 | [diff] [blame] | 5 | * Copyright (C) 2004-2011 Nokia Corporation |
Tony Lindgren | a16e970 | 2008-03-18 11:56:39 +0200 | [diff] [blame] | 6 | * |
| 7 | * Contacts: |
Paul Walmsley | 543d937 | 2008-03-18 10:22:06 +0200 | [diff] [blame] | 8 | * Richard Woodruff <r-woodruff2@ti.com> |
Paul Walmsley | 543d937 | 2008-03-18 10:22:06 +0200 | [diff] [blame] | 9 | * Paul Walmsley |
| 10 | * |
| 11 | * This program is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU General Public License version 2 as |
| 13 | * published by the Free Software Foundation. |
| 14 | */ |
| 15 | |
| 16 | #ifndef __ARCH_ARM_MACH_OMAP2_CLOCK_H |
| 17 | #define __ARCH_ARM_MACH_OMAP2_CLOCK_H |
| 18 | |
Paul Walmsley | 12706c5 | 2011-07-10 05:57:06 -0600 | [diff] [blame] | 19 | #include <linux/kernel.h> |
Paul Walmsley | a135eaa | 2012-09-27 10:33:34 -0600 | [diff] [blame] | 20 | #include <linux/list.h> |
Paul Walmsley | 12706c5 | 2011-07-10 05:57:06 -0600 | [diff] [blame] | 21 | |
Paul Walmsley | e10dd62 | 2012-09-27 10:33:35 -0600 | [diff] [blame] | 22 | #include <linux/clkdev.h> |
| 23 | |
| 24 | struct omap_clk { |
| 25 | u16 cpu; |
| 26 | struct clk_lookup lk; |
| 27 | }; |
| 28 | |
| 29 | #define CLK(dev, con, ck, cp) \ |
| 30 | { \ |
| 31 | .cpu = cp, \ |
| 32 | .lk = { \ |
| 33 | .dev_id = dev, \ |
| 34 | .con_id = con, \ |
| 35 | .clk = ck, \ |
| 36 | }, \ |
| 37 | } |
| 38 | |
| 39 | /* Platform flags for the clkdev-OMAP integration code */ |
| 40 | #define CK_242X (1 << 0) |
| 41 | #define CK_243X (1 << 1) /* 243x, 253x */ |
| 42 | #define CK_3430ES1 (1 << 2) /* 34xxES1 only */ |
| 43 | #define CK_3430ES2PLUS (1 << 3) /* 34xxES2, ES3, non-Sitara 35xx only */ |
| 44 | #define CK_AM35XX (1 << 4) /* Sitara AM35xx */ |
| 45 | #define CK_36XX (1 << 5) /* 36xx/37xx-specific clocks */ |
| 46 | #define CK_443X (1 << 6) |
| 47 | #define CK_TI816X (1 << 7) |
| 48 | #define CK_446X (1 << 8) |
| 49 | #define CK_AM33XX (1 << 9) /* AM33xx specific clocks */ |
| 50 | |
| 51 | |
| 52 | #define CK_34XX (CK_3430ES1 | CK_3430ES2PLUS) |
| 53 | #define CK_3XXX (CK_34XX | CK_AM35XX | CK_36XX) |
| 54 | |
Rajendra Nayak | b5a2366 | 2012-11-10 16:58:40 -0700 | [diff] [blame] | 55 | #ifdef CONFIG_COMMON_CLK |
| 56 | #include <linux/clk-provider.h> |
| 57 | |
| 58 | struct clockdomain; |
| 59 | #define to_clk_hw_omap(_hw) container_of(_hw, struct clk_hw_omap, hw) |
| 60 | |
| 61 | #else |
| 62 | |
Paul Walmsley | a135eaa | 2012-09-27 10:33:34 -0600 | [diff] [blame] | 63 | struct module; |
| 64 | struct clk; |
| 65 | struct clockdomain; |
| 66 | |
| 67 | /* Temporary, needed during the common clock framework conversion */ |
| 68 | #define __clk_get_name(clk) (clk->name) |
| 69 | #define __clk_get_parent(clk) (clk->parent) |
| 70 | #define __clk_get_rate(clk) (clk->rate) |
| 71 | |
| 72 | /** |
| 73 | * struct clkops - some clock function pointers |
| 74 | * @enable: fn ptr that enables the current clock in hardware |
| 75 | * @disable: fn ptr that enables the current clock in hardware |
| 76 | * @find_idlest: function returning the IDLEST register for the clock's IP blk |
| 77 | * @find_companion: function returning the "companion" clk reg for the clock |
| 78 | * @allow_idle: fn ptr that enables autoidle for the current clock in hardware |
| 79 | * @deny_idle: fn ptr that disables autoidle for the current clock in hardware |
| 80 | * |
| 81 | * A "companion" clk is an accompanying clock to the one being queried |
| 82 | * that must be enabled for the IP module connected to the clock to |
| 83 | * become accessible by the hardware. Neither @find_idlest nor |
| 84 | * @find_companion should be needed; that information is IP |
| 85 | * block-specific; the hwmod code has been created to handle this, but |
| 86 | * until hwmod data is ready and drivers have been converted to use PM |
| 87 | * runtime calls in place of clk_enable()/clk_disable(), @find_idlest and |
| 88 | * @find_companion must, unfortunately, remain. |
| 89 | */ |
| 90 | struct clkops { |
| 91 | int (*enable)(struct clk *); |
| 92 | void (*disable)(struct clk *); |
| 93 | void (*find_idlest)(struct clk *, void __iomem **, |
| 94 | u8 *, u8 *); |
| 95 | void (*find_companion)(struct clk *, void __iomem **, |
| 96 | u8 *); |
| 97 | void (*allow_idle)(struct clk *); |
| 98 | void (*deny_idle)(struct clk *); |
| 99 | }; |
Rajendra Nayak | b5a2366 | 2012-11-10 16:58:40 -0700 | [diff] [blame] | 100 | #endif |
Paul Walmsley | a135eaa | 2012-09-27 10:33:34 -0600 | [diff] [blame] | 101 | |
| 102 | /* struct clksel_rate.flags possibilities */ |
| 103 | #define RATE_IN_242X (1 << 0) |
| 104 | #define RATE_IN_243X (1 << 1) |
| 105 | #define RATE_IN_3430ES1 (1 << 2) /* 3430ES1 rates only */ |
| 106 | #define RATE_IN_3430ES2PLUS (1 << 3) /* 3430 ES >= 2 rates only */ |
| 107 | #define RATE_IN_36XX (1 << 4) |
| 108 | #define RATE_IN_4430 (1 << 5) |
| 109 | #define RATE_IN_TI816X (1 << 6) |
| 110 | #define RATE_IN_4460 (1 << 7) |
| 111 | #define RATE_IN_AM33XX (1 << 8) |
| 112 | #define RATE_IN_TI814X (1 << 9) |
| 113 | |
| 114 | #define RATE_IN_24XX (RATE_IN_242X | RATE_IN_243X) |
| 115 | #define RATE_IN_34XX (RATE_IN_3430ES1 | RATE_IN_3430ES2PLUS) |
| 116 | #define RATE_IN_3XXX (RATE_IN_34XX | RATE_IN_36XX) |
| 117 | #define RATE_IN_44XX (RATE_IN_4430 | RATE_IN_4460) |
| 118 | |
| 119 | /* RATE_IN_3430ES2PLUS_36XX includes 34xx/35xx with ES >=2, and all 36xx/37xx */ |
| 120 | #define RATE_IN_3430ES2PLUS_36XX (RATE_IN_3430ES2PLUS | RATE_IN_36XX) |
| 121 | |
| 122 | |
| 123 | /** |
| 124 | * struct clksel_rate - register bitfield values corresponding to clk divisors |
| 125 | * @val: register bitfield value (shifted to bit 0) |
| 126 | * @div: clock divisor corresponding to @val |
| 127 | * @flags: (see "struct clksel_rate.flags possibilities" above) |
| 128 | * |
| 129 | * @val should match the value of a read from struct clk.clksel_reg |
| 130 | * AND'ed with struct clk.clksel_mask, shifted right to bit 0. |
| 131 | * |
| 132 | * @div is the divisor that should be applied to the parent clock's rate |
| 133 | * to produce the current clock's rate. |
| 134 | */ |
| 135 | struct clksel_rate { |
| 136 | u32 val; |
| 137 | u8 div; |
| 138 | u16 flags; |
| 139 | }; |
| 140 | |
| 141 | /** |
| 142 | * struct clksel - available parent clocks, and a pointer to their divisors |
| 143 | * @parent: struct clk * to a possible parent clock |
| 144 | * @rates: available divisors for this parent clock |
| 145 | * |
| 146 | * A struct clksel is always associated with one or more struct clks |
| 147 | * and one or more struct clksel_rates. |
| 148 | */ |
| 149 | struct clksel { |
| 150 | struct clk *parent; |
| 151 | const struct clksel_rate *rates; |
| 152 | }; |
| 153 | |
| 154 | /** |
| 155 | * struct dpll_data - DPLL registers and integration data |
| 156 | * @mult_div1_reg: register containing the DPLL M and N bitfields |
| 157 | * @mult_mask: mask of the DPLL M bitfield in @mult_div1_reg |
| 158 | * @div1_mask: mask of the DPLL N bitfield in @mult_div1_reg |
| 159 | * @clk_bypass: struct clk pointer to the clock's bypass clock input |
| 160 | * @clk_ref: struct clk pointer to the clock's reference clock input |
| 161 | * @control_reg: register containing the DPLL mode bitfield |
| 162 | * @enable_mask: mask of the DPLL mode bitfield in @control_reg |
| 163 | * @last_rounded_rate: cache of the last rate result of omap2_dpll_round_rate() |
| 164 | * @last_rounded_m: cache of the last M result of omap2_dpll_round_rate() |
| 165 | * @max_multiplier: maximum valid non-bypass multiplier value (actual) |
| 166 | * @last_rounded_n: cache of the last N result of omap2_dpll_round_rate() |
| 167 | * @min_divider: minimum valid non-bypass divider value (actual) |
| 168 | * @max_divider: maximum valid non-bypass divider value (actual) |
| 169 | * @modes: possible values of @enable_mask |
| 170 | * @autoidle_reg: register containing the DPLL autoidle mode bitfield |
| 171 | * @idlest_reg: register containing the DPLL idle status bitfield |
| 172 | * @autoidle_mask: mask of the DPLL autoidle mode bitfield in @autoidle_reg |
| 173 | * @freqsel_mask: mask of the DPLL jitter correction bitfield in @control_reg |
| 174 | * @idlest_mask: mask of the DPLL idle status bitfield in @idlest_reg |
| 175 | * @auto_recal_bit: bitshift of the driftguard enable bit in @control_reg |
| 176 | * @recal_en_bit: bitshift of the PRM_IRQENABLE_* bit for recalibration IRQs |
| 177 | * @recal_st_bit: bitshift of the PRM_IRQSTATUS_* bit for recalibration IRQs |
| 178 | * @flags: DPLL type/features (see below) |
| 179 | * |
| 180 | * Possible values for @flags: |
| 181 | * DPLL_J_TYPE: "J-type DPLL" (only some 36xx, 4xxx DPLLs) |
| 182 | * |
| 183 | * @freqsel_mask is only used on the OMAP34xx family and AM35xx. |
| 184 | * |
| 185 | * XXX Some DPLLs have multiple bypass inputs, so it's not technically |
| 186 | * correct to only have one @clk_bypass pointer. |
| 187 | * |
| 188 | * XXX The runtime-variable fields (@last_rounded_rate, @last_rounded_m, |
| 189 | * @last_rounded_n) should be separated from the runtime-fixed fields |
| 190 | * and placed into a different structure, so that the runtime-fixed data |
| 191 | * can be placed into read-only space. |
| 192 | */ |
| 193 | struct dpll_data { |
| 194 | void __iomem *mult_div1_reg; |
| 195 | u32 mult_mask; |
| 196 | u32 div1_mask; |
| 197 | struct clk *clk_bypass; |
| 198 | struct clk *clk_ref; |
| 199 | void __iomem *control_reg; |
| 200 | u32 enable_mask; |
| 201 | unsigned long last_rounded_rate; |
| 202 | u16 last_rounded_m; |
| 203 | u16 max_multiplier; |
| 204 | u8 last_rounded_n; |
| 205 | u8 min_divider; |
| 206 | u16 max_divider; |
| 207 | u8 modes; |
| 208 | void __iomem *autoidle_reg; |
| 209 | void __iomem *idlest_reg; |
| 210 | u32 autoidle_mask; |
| 211 | u32 freqsel_mask; |
| 212 | u32 idlest_mask; |
| 213 | u32 dco_mask; |
| 214 | u32 sddiv_mask; |
| 215 | u8 auto_recal_bit; |
| 216 | u8 recal_en_bit; |
| 217 | u8 recal_st_bit; |
| 218 | u8 flags; |
| 219 | }; |
| 220 | |
| 221 | /* |
| 222 | * struct clk.flags possibilities |
| 223 | * |
| 224 | * XXX document the rest of the clock flags here |
| 225 | * |
| 226 | * CLOCK_CLKOUTX2: (OMAP4 only) DPLL CLKOUT and CLKOUTX2 GATE_CTRL |
| 227 | * bits share the same register. This flag allows the |
| 228 | * omap4_dpllmx*() code to determine which GATE_CTRL bit field |
| 229 | * should be used. This is a temporary solution - a better approach |
| 230 | * would be to associate clock type-specific data with the clock, |
| 231 | * similar to the struct dpll_data approach. |
| 232 | */ |
| 233 | #define ENABLE_REG_32BIT (1 << 0) /* Use 32-bit access */ |
| 234 | #define CLOCK_IDLE_CONTROL (1 << 1) |
| 235 | #define CLOCK_NO_IDLE_PARENT (1 << 2) |
| 236 | #define ENABLE_ON_INIT (1 << 3) /* Enable upon framework init */ |
| 237 | #define INVERT_ENABLE (1 << 4) /* 0 enables, 1 disables */ |
| 238 | #define CLOCK_CLKOUTX2 (1 << 5) |
| 239 | |
Rajendra Nayak | b5a2366 | 2012-11-10 16:58:40 -0700 | [diff] [blame] | 240 | #ifdef CONFIG_COMMON_CLK |
| 241 | /** |
| 242 | * struct clk_hw_omap - OMAP struct clk |
| 243 | * @node: list_head connecting this clock into the full clock list |
| 244 | * @enable_reg: register to write to enable the clock (see @enable_bit) |
| 245 | * @enable_bit: bitshift to write to enable/disable the clock (see @enable_reg) |
| 246 | * @flags: see "struct clk.flags possibilities" above |
| 247 | * @clksel_reg: for clksel clks, register va containing src/divisor select |
| 248 | * @clksel_mask: bitmask in @clksel_reg for the src/divisor selector |
| 249 | * @clksel: for clksel clks, pointer to struct clksel for this clock |
| 250 | * @dpll_data: for DPLLs, pointer to struct dpll_data for this clock |
| 251 | * @clkdm_name: clockdomain name that this clock is contained in |
| 252 | * @clkdm: pointer to struct clockdomain, resolved from @clkdm_name at runtime |
| 253 | * @rate_offset: bitshift for rate selection bitfield (OMAP1 only) |
| 254 | * @src_offset: bitshift for source selection bitfield (OMAP1 only) |
| 255 | * |
| 256 | * XXX @rate_offset, @src_offset should probably be removed and OMAP1 |
| 257 | * clock code converted to use clksel. |
| 258 | * |
| 259 | */ |
| 260 | |
| 261 | struct clk_hw_omap_ops; |
| 262 | |
| 263 | struct clk_hw_omap { |
| 264 | struct clk_hw hw; |
| 265 | struct list_head node; |
| 266 | unsigned long fixed_rate; |
| 267 | u8 fixed_div; |
| 268 | void __iomem *enable_reg; |
| 269 | u8 enable_bit; |
| 270 | u8 flags; |
| 271 | void __iomem *clksel_reg; |
| 272 | u32 clksel_mask; |
| 273 | const struct clksel *clksel; |
| 274 | struct dpll_data *dpll_data; |
| 275 | const char *clkdm_name; |
| 276 | struct clockdomain *clkdm; |
| 277 | const struct clk_hw_omap_ops *ops; |
| 278 | }; |
| 279 | |
| 280 | struct clk_hw_omap_ops { |
| 281 | void (*find_idlest)(struct clk_hw_omap *oclk, |
| 282 | void __iomem **idlest_reg, |
| 283 | u8 *idlest_bit, u8 *idlest_val); |
| 284 | void (*find_companion)(struct clk_hw_omap *oclk, |
| 285 | void __iomem **other_reg, |
| 286 | u8 *other_bit); |
| 287 | void (*allow_idle)(struct clk_hw_omap *oclk); |
| 288 | void (*deny_idle)(struct clk_hw_omap *oclk); |
| 289 | }; |
| 290 | |
| 291 | unsigned long omap_fixed_divisor_recalc(struct clk_hw *hw, |
| 292 | unsigned long parent_rate); |
| 293 | #else |
Paul Walmsley | a135eaa | 2012-09-27 10:33:34 -0600 | [diff] [blame] | 294 | /** |
| 295 | * struct clk - OMAP struct clk |
| 296 | * @node: list_head connecting this clock into the full clock list |
| 297 | * @ops: struct clkops * for this clock |
| 298 | * @name: the name of the clock in the hardware (used in hwmod data and debug) |
| 299 | * @parent: pointer to this clock's parent struct clk |
| 300 | * @children: list_head connecting to the child clks' @sibling list_heads |
| 301 | * @sibling: list_head connecting this clk to its parent clk's @children |
| 302 | * @rate: current clock rate |
| 303 | * @enable_reg: register to write to enable the clock (see @enable_bit) |
| 304 | * @recalc: fn ptr that returns the clock's current rate |
| 305 | * @set_rate: fn ptr that can change the clock's current rate |
| 306 | * @round_rate: fn ptr that can round the clock's current rate |
| 307 | * @init: fn ptr to do clock-specific initialization |
| 308 | * @enable_bit: bitshift to write to enable/disable the clock (see @enable_reg) |
| 309 | * @usecount: number of users that have requested this clock to be enabled |
| 310 | * @fixed_div: when > 0, this clock's rate is its parent's rate / @fixed_div |
| 311 | * @flags: see "struct clk.flags possibilities" above |
| 312 | * @clksel_reg: for clksel clks, register va containing src/divisor select |
| 313 | * @clksel_mask: bitmask in @clksel_reg for the src/divisor selector |
| 314 | * @clksel: for clksel clks, pointer to struct clksel for this clock |
| 315 | * @dpll_data: for DPLLs, pointer to struct dpll_data for this clock |
| 316 | * @clkdm_name: clockdomain name that this clock is contained in |
| 317 | * @clkdm: pointer to struct clockdomain, resolved from @clkdm_name at runtime |
| 318 | * @rate_offset: bitshift for rate selection bitfield (OMAP1 only) |
| 319 | * @src_offset: bitshift for source selection bitfield (OMAP1 only) |
| 320 | * |
| 321 | * XXX @rate_offset, @src_offset should probably be removed and OMAP1 |
| 322 | * clock code converted to use clksel. |
| 323 | * |
| 324 | * XXX @usecount is poorly named. It should be "enable_count" or |
| 325 | * something similar. "users" in the description refers to kernel |
| 326 | * code (core code or drivers) that have called clk_enable() and not |
| 327 | * yet called clk_disable(); the usecount of parent clocks is also |
| 328 | * incremented by the clock code when clk_enable() is called on child |
| 329 | * clocks and decremented by the clock code when clk_disable() is |
| 330 | * called on child clocks. |
| 331 | * |
| 332 | * XXX @clkdm, @usecount, @children, @sibling should be marked for |
| 333 | * internal use only. |
| 334 | * |
| 335 | * @children and @sibling are used to optimize parent-to-child clock |
| 336 | * tree traversals. (child-to-parent traversals use @parent.) |
| 337 | * |
| 338 | * XXX The notion of the clock's current rate probably needs to be |
| 339 | * separated from the clock's target rate. |
| 340 | */ |
| 341 | struct clk { |
| 342 | struct list_head node; |
| 343 | const struct clkops *ops; |
| 344 | const char *name; |
| 345 | struct clk *parent; |
| 346 | struct list_head children; |
| 347 | struct list_head sibling; /* node for children */ |
| 348 | unsigned long rate; |
| 349 | void __iomem *enable_reg; |
| 350 | unsigned long (*recalc)(struct clk *); |
| 351 | int (*set_rate)(struct clk *, unsigned long); |
| 352 | long (*round_rate)(struct clk *, unsigned long); |
| 353 | void (*init)(struct clk *); |
| 354 | u8 enable_bit; |
| 355 | s8 usecount; |
| 356 | u8 fixed_div; |
| 357 | u8 flags; |
| 358 | void __iomem *clksel_reg; |
| 359 | u32 clksel_mask; |
| 360 | const struct clksel *clksel; |
| 361 | struct dpll_data *dpll_data; |
| 362 | const char *clkdm_name; |
| 363 | struct clockdomain *clkdm; |
| 364 | #if defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS) |
| 365 | struct dentry *dent; /* For visible tree hierarchy */ |
| 366 | #endif |
| 367 | }; |
| 368 | |
| 369 | struct clk_functions { |
| 370 | int (*clk_enable)(struct clk *clk); |
| 371 | void (*clk_disable)(struct clk *clk); |
| 372 | long (*clk_round_rate)(struct clk *clk, unsigned long rate); |
| 373 | int (*clk_set_rate)(struct clk *clk, unsigned long rate); |
| 374 | int (*clk_set_parent)(struct clk *clk, struct clk *parent); |
| 375 | void (*clk_allow_idle)(struct clk *clk); |
| 376 | void (*clk_deny_idle)(struct clk *clk); |
| 377 | void (*clk_disable_unused)(struct clk *clk); |
| 378 | }; |
| 379 | |
| 380 | extern int mpurate; |
| 381 | |
| 382 | extern int clk_init(struct clk_functions *custom_clocks); |
| 383 | extern void clk_preinit(struct clk *clk); |
| 384 | extern int clk_register(struct clk *clk); |
| 385 | extern void clk_reparent(struct clk *child, struct clk *parent); |
| 386 | extern void clk_unregister(struct clk *clk); |
| 387 | extern void propagate_rate(struct clk *clk); |
| 388 | extern void recalculate_root_clocks(void); |
| 389 | extern unsigned long followparent_recalc(struct clk *clk); |
| 390 | extern void clk_enable_init_clocks(void); |
| 391 | unsigned long omap_fixed_divisor_recalc(struct clk *clk); |
| 392 | extern struct clk *omap_clk_get_by_name(const char *name); |
| 393 | extern int omap_clk_enable_autoidle_all(void); |
| 394 | extern int omap_clk_disable_autoidle_all(void); |
| 395 | |
| 396 | extern const struct clkops clkops_null; |
| 397 | |
| 398 | extern struct clk dummy_ck; |
| 399 | |
Mike Turquette | 32cc002 | 2012-11-10 16:58:41 -0700 | [diff] [blame] | 400 | #endif /* CONFIG_COMMON_CLK */ |
Paul Walmsley | 543d937 | 2008-03-18 10:22:06 +0200 | [diff] [blame] | 401 | |
Russell King | c0bf313 | 2009-02-19 13:29:22 +0000 | [diff] [blame] | 402 | /* CM_CLKSEL2_PLL.CORE_CLK_SRC bits (2XXX) */ |
| 403 | #define CORE_CLK_SRC_32K 0x0 |
| 404 | #define CORE_CLK_SRC_DPLL 0x1 |
| 405 | #define CORE_CLK_SRC_DPLL_X2 0x2 |
| 406 | |
| 407 | /* OMAP2xxx CM_CLKEN_PLL.EN_DPLL bits - for omap2_get_dpll_rate() */ |
| 408 | #define OMAP2XXX_EN_DPLL_LPBYPASS 0x1 |
| 409 | #define OMAP2XXX_EN_DPLL_FRBYPASS 0x2 |
| 410 | #define OMAP2XXX_EN_DPLL_LOCKED 0x3 |
| 411 | |
| 412 | /* OMAP3xxx CM_CLKEN_PLL*.EN_*_DPLL bits - for omap2_get_dpll_rate() */ |
| 413 | #define OMAP3XXX_EN_DPLL_LPBYPASS 0x5 |
| 414 | #define OMAP3XXX_EN_DPLL_FRBYPASS 0x6 |
| 415 | #define OMAP3XXX_EN_DPLL_LOCKED 0x7 |
| 416 | |
Rajendra Nayak | 16975a7 | 2009-12-08 18:47:16 -0700 | [diff] [blame] | 417 | /* OMAP4xxx CM_CLKMODE_DPLL*.EN_*_DPLL bits - for omap2_get_dpll_rate() */ |
| 418 | #define OMAP4XXX_EN_DPLL_MNBYPASS 0x4 |
| 419 | #define OMAP4XXX_EN_DPLL_LPBYPASS 0x5 |
| 420 | #define OMAP4XXX_EN_DPLL_FRBYPASS 0x6 |
| 421 | #define OMAP4XXX_EN_DPLL_LOCKED 0x7 |
| 422 | |
Rajendra Nayak | a1391d2 | 2009-12-08 18:47:16 -0700 | [diff] [blame] | 423 | /* CM_CLKEN_PLL*.EN* bit values - not all are available for every DPLL */ |
| 424 | #define DPLL_LOW_POWER_STOP 0x1 |
| 425 | #define DPLL_LOW_POWER_BYPASS 0x5 |
| 426 | #define DPLL_LOCKED 0x7 |
| 427 | |
Richard Woodruff | 358965d | 2010-02-22 22:09:08 -0700 | [diff] [blame] | 428 | /* DPLL Type and DCO Selection Flags */ |
| 429 | #define DPLL_J_TYPE 0x1 |
Richard Woodruff | 358965d | 2010-02-22 22:09:08 -0700 | [diff] [blame] | 430 | |
Mike Turquette | 32cc002 | 2012-11-10 16:58:41 -0700 | [diff] [blame] | 431 | #ifndef CONFIG_COMMON_CLK |
Paul Walmsley | 543d937 | 2008-03-18 10:22:06 +0200 | [diff] [blame] | 432 | int omap2_clk_enable(struct clk *clk); |
| 433 | void omap2_clk_disable(struct clk *clk); |
| 434 | long omap2_clk_round_rate(struct clk *clk, unsigned long rate); |
| 435 | int omap2_clk_set_rate(struct clk *clk, unsigned long rate); |
| 436 | int omap2_clk_set_parent(struct clk *clk, struct clk *new_parent); |
Mike Turquette | 32cc002 | 2012-11-10 16:58:41 -0700 | [diff] [blame] | 437 | #endif /* CONFIG_COMMON_CLK */ |
| 438 | |
| 439 | #ifdef CONFIG_COMMON_CLK |
| 440 | long omap2_dpll_round_rate(struct clk_hw *hw, unsigned long target_rate, |
| 441 | unsigned long *parent_rate); |
| 442 | unsigned long omap3_dpll_recalc(struct clk_hw *hw, unsigned long parent_rate); |
| 443 | int omap3_noncore_dpll_enable(struct clk_hw *hw); |
| 444 | void omap3_noncore_dpll_disable(struct clk_hw *hw); |
| 445 | int omap3_noncore_dpll_set_rate(struct clk_hw *hw, unsigned long rate, |
| 446 | unsigned long parent_rate); |
| 447 | u32 omap3_dpll_autoidle_read(struct clk_hw_omap *clk); |
| 448 | void omap3_dpll_allow_idle(struct clk_hw_omap *clk); |
| 449 | void omap3_dpll_deny_idle(struct clk_hw_omap *clk); |
| 450 | unsigned long omap3_clkoutx2_recalc(struct clk_hw *hw, |
| 451 | unsigned long parent_rate); |
| 452 | int omap4_dpllmx_gatectrl_read(struct clk_hw_omap *clk); |
| 453 | void omap4_dpllmx_allow_gatectrl(struct clk_hw_omap *clk); |
| 454 | void omap4_dpllmx_deny_gatectrl(struct clk_hw_omap *clk); |
| 455 | unsigned long omap4_dpll_regm4xen_recalc(struct clk_hw *hw, |
| 456 | unsigned long parent_rate); |
| 457 | long omap4_dpll_regm4xen_round_rate(struct clk_hw *hw, |
| 458 | unsigned long target_rate, |
| 459 | unsigned long *parent_rate); |
| 460 | #else |
Paul Walmsley | 88b8ba9 | 2008-07-03 12:24:46 +0300 | [diff] [blame] | 461 | long omap2_dpll_round_rate(struct clk *clk, unsigned long target_rate); |
Rajendra Nayak | a1391d2 | 2009-12-08 18:47:16 -0700 | [diff] [blame] | 462 | unsigned long omap3_dpll_recalc(struct clk *clk); |
| 463 | unsigned long omap3_clkoutx2_recalc(struct clk *clk); |
| 464 | void omap3_dpll_allow_idle(struct clk *clk); |
| 465 | void omap3_dpll_deny_idle(struct clk *clk); |
| 466 | u32 omap3_dpll_autoidle_read(struct clk *clk); |
| 467 | int omap3_noncore_dpll_set_rate(struct clk *clk, unsigned long rate); |
| 468 | int omap3_noncore_dpll_enable(struct clk *clk); |
| 469 | void omap3_noncore_dpll_disable(struct clk *clk); |
Rajendra Nayak | 97f6789 | 2011-02-25 15:49:01 -0700 | [diff] [blame] | 470 | int omap4_dpllmx_gatectrl_read(struct clk *clk); |
| 471 | void omap4_dpllmx_allow_gatectrl(struct clk *clk); |
| 472 | void omap4_dpllmx_deny_gatectrl(struct clk *clk); |
Mike Turquette | a1900f2 | 2011-10-07 00:52:58 -0600 | [diff] [blame] | 473 | long omap4_dpll_regm4xen_round_rate(struct clk *clk, unsigned long target_rate); |
| 474 | unsigned long omap4_dpll_regm4xen_recalc(struct clk *clk); |
Mike Turquette | 32cc002 | 2012-11-10 16:58:41 -0700 | [diff] [blame] | 475 | #endif |
Paul Walmsley | 543d937 | 2008-03-18 10:22:06 +0200 | [diff] [blame] | 476 | |
| 477 | #ifdef CONFIG_OMAP_RESET_CLOCKS |
| 478 | void omap2_clk_disable_unused(struct clk *clk); |
| 479 | #else |
| 480 | #define omap2_clk_disable_unused NULL |
| 481 | #endif |
Mike Turquette | 32cc002 | 2012-11-10 16:58:41 -0700 | [diff] [blame] | 482 | #ifdef CONFIG_COMMON_CLK |
| 483 | void omap2_init_clk_clkdm(struct clk_hw *clk); |
| 484 | #else |
Paul Walmsley | 333943b | 2008-08-19 11:08:45 +0300 | [diff] [blame] | 485 | void omap2_init_clk_clkdm(struct clk *clk); |
Mike Turquette | 32cc002 | 2012-11-10 16:58:41 -0700 | [diff] [blame] | 486 | #endif |
Paul Walmsley | 12706c5 | 2011-07-10 05:57:06 -0600 | [diff] [blame] | 487 | void __init omap2_clk_disable_clkdm_control(void); |
Paul Walmsley | 435699d | 2010-05-18 18:40:24 -0600 | [diff] [blame] | 488 | |
| 489 | /* clkt_clksel.c public functions */ |
Mike Turquette | 32cc002 | 2012-11-10 16:58:41 -0700 | [diff] [blame] | 490 | #ifdef CONFIG_COMMON_CLK |
| 491 | u32 omap2_clksel_round_rate_div(struct clk_hw_omap *clk, |
| 492 | unsigned long target_rate, |
| 493 | u32 *new_div); |
| 494 | u8 omap2_clksel_find_parent_index(struct clk_hw *hw); |
| 495 | unsigned long omap2_clksel_recalc(struct clk_hw *hw, unsigned long parent_rate); |
| 496 | long omap2_clksel_round_rate(struct clk_hw *hw, unsigned long target_rate, |
| 497 | unsigned long *parent_rate); |
| 498 | int omap2_clksel_set_rate(struct clk_hw *hw, unsigned long rate, |
| 499 | unsigned long parent_rate); |
| 500 | int omap2_clksel_set_parent(struct clk_hw *hw, u8 field_val); |
| 501 | #else |
Paul Walmsley | 543d937 | 2008-03-18 10:22:06 +0200 | [diff] [blame] | 502 | u32 omap2_clksel_round_rate_div(struct clk *clk, unsigned long target_rate, |
| 503 | u32 *new_div); |
Paul Walmsley | 435699d | 2010-05-18 18:40:24 -0600 | [diff] [blame] | 504 | void omap2_init_clksel_parent(struct clk *clk); |
| 505 | unsigned long omap2_clksel_recalc(struct clk *clk); |
Paul Walmsley | 543d937 | 2008-03-18 10:22:06 +0200 | [diff] [blame] | 506 | long omap2_clksel_round_rate(struct clk *clk, unsigned long target_rate); |
| 507 | int omap2_clksel_set_rate(struct clk *clk, unsigned long rate); |
Paul Walmsley | df791b3 | 2010-01-26 20:13:04 -0700 | [diff] [blame] | 508 | int omap2_clksel_set_parent(struct clk *clk, struct clk *new_parent); |
Mike Turquette | 32cc002 | 2012-11-10 16:58:41 -0700 | [diff] [blame] | 509 | #endif |
Paul Walmsley | 435699d | 2010-05-18 18:40:24 -0600 | [diff] [blame] | 510 | |
Paul Walmsley | 530e544 | 2011-02-25 15:39:28 -0700 | [diff] [blame] | 511 | /* clkt_iclk.c public functions */ |
Rajendra Nayak | b4777a2 | 2012-04-27 15:53:48 +0530 | [diff] [blame] | 512 | #ifdef CONFIG_COMMON_CLK |
| 513 | extern void omap2_clkt_iclk_allow_idle(struct clk_hw_omap *clk); |
| 514 | extern void omap2_clkt_iclk_deny_idle(struct clk_hw_omap *clk); |
| 515 | #else |
Paul Walmsley | 530e544 | 2011-02-25 15:39:28 -0700 | [diff] [blame] | 516 | extern void omap2_clkt_iclk_allow_idle(struct clk *clk); |
| 517 | extern void omap2_clkt_iclk_deny_idle(struct clk *clk); |
Rajendra Nayak | b4777a2 | 2012-04-27 15:53:48 +0530 | [diff] [blame] | 518 | #endif |
Paul Walmsley | 530e544 | 2011-02-25 15:39:28 -0700 | [diff] [blame] | 519 | |
Mike Turquette | 32cc002 | 2012-11-10 16:58:41 -0700 | [diff] [blame] | 520 | #ifdef CONFIG_COMMON_CLK |
| 521 | u8 omap2_init_dpll_parent(struct clk_hw *hw); |
| 522 | unsigned long omap2_get_dpll_rate(struct clk_hw_omap *clk); |
| 523 | #else |
Paul Walmsley | 543d937 | 2008-03-18 10:22:06 +0200 | [diff] [blame] | 524 | u32 omap2_get_dpll_rate(struct clk *clk); |
Rajendra Nayak | 911bd73 | 2009-12-08 18:47:17 -0700 | [diff] [blame] | 525 | void omap2_init_dpll_parent(struct clk *clk); |
Mike Turquette | 32cc002 | 2012-11-10 16:58:41 -0700 | [diff] [blame] | 526 | #endif |
Paul Walmsley | 435699d | 2010-05-18 18:40:24 -0600 | [diff] [blame] | 527 | |
Mike Turquette | 32cc002 | 2012-11-10 16:58:41 -0700 | [diff] [blame] | 528 | #ifdef CONFIG_COMMON_CLK |
| 529 | int omap2_dflt_clk_enable(struct clk_hw *hw); |
| 530 | void omap2_dflt_clk_disable(struct clk_hw *hw); |
| 531 | int omap2_dflt_clk_is_enabled(struct clk_hw *hw); |
| 532 | void omap2_clk_dflt_find_companion(struct clk_hw_omap *clk, |
| 533 | void __iomem **other_reg, |
| 534 | u8 *other_bit); |
| 535 | void omap2_clk_dflt_find_idlest(struct clk_hw_omap *clk, |
| 536 | void __iomem **idlest_reg, |
| 537 | u8 *idlest_bit, u8 *idlest_val); |
Rajendra Nayak | 23fb8ba | 2012-06-01 14:02:49 +0530 | [diff] [blame^] | 538 | void omap2_init_clk_hw_omap_clocks(struct clk *clk); |
| 539 | int omap2_clk_enable_autoidle_all(void); |
| 540 | int omap2_clk_disable_autoidle_all(void); |
Mike Turquette | 32cc002 | 2012-11-10 16:58:41 -0700 | [diff] [blame] | 541 | #else |
Paul Walmsley | 72350b2 | 2009-07-24 19:44:03 -0600 | [diff] [blame] | 542 | int omap2_dflt_clk_enable(struct clk *clk); |
| 543 | void omap2_dflt_clk_disable(struct clk *clk); |
| 544 | void omap2_clk_dflt_find_companion(struct clk *clk, void __iomem **other_reg, |
| 545 | u8 *other_bit); |
| 546 | void omap2_clk_dflt_find_idlest(struct clk *clk, void __iomem **idlest_reg, |
Ranjith Lohithakshan | 419cc97 | 2010-02-24 12:05:54 -0700 | [diff] [blame] | 547 | u8 *idlest_bit, u8 *idlest_val); |
Mike Turquette | 32cc002 | 2012-11-10 16:58:41 -0700 | [diff] [blame] | 548 | #endif |
Paul Walmsley | 4d30e82 | 2010-02-22 22:09:36 -0700 | [diff] [blame] | 549 | int omap2_clk_switch_mpurate_at_boot(const char *mpurate_ck_name); |
| 550 | void omap2_clk_print_new_rates(const char *hfclkin_ck_name, |
| 551 | const char *core_ck_name, |
| 552 | const char *mpu_ck_name); |
Paul Walmsley | 543d937 | 2008-03-18 10:22:06 +0200 | [diff] [blame] | 553 | |
Afzal Mohammed | 9954119 | 2011-12-13 10:46:43 -0800 | [diff] [blame] | 554 | extern u16 cpu_mask; |
Paul Walmsley | d8a9445 | 2009-12-08 16:21:29 -0700 | [diff] [blame] | 555 | |
Russell King | b36ee72 | 2008-11-04 17:59:52 +0000 | [diff] [blame] | 556 | extern const struct clkops clkops_omap2_dflt_wait; |
Santosh Shilimkar | 7c43d54 | 2010-02-22 22:09:40 -0700 | [diff] [blame] | 557 | extern const struct clkops clkops_dummy; |
Russell King | bc51da4 | 2008-11-04 18:59:32 +0000 | [diff] [blame] | 558 | extern const struct clkops clkops_omap2_dflt; |
Russell King | b36ee72 | 2008-11-04 17:59:52 +0000 | [diff] [blame] | 559 | |
Paul Walmsley | 82e9bd5 | 2009-12-08 16:18:47 -0700 | [diff] [blame] | 560 | extern struct clk_functions omap2_clk_functions; |
| 561 | |
Paul Walmsley | d8a9445 | 2009-12-08 16:21:29 -0700 | [diff] [blame] | 562 | extern const struct clksel_rate gpt_32k_rates[]; |
| 563 | extern const struct clksel_rate gpt_sys_rates[]; |
| 564 | extern const struct clksel_rate gfx_l3_rates[]; |
Paul Walmsley | 2241139 | 2011-02-25 15:52:04 -0700 | [diff] [blame] | 565 | extern const struct clksel_rate dsp_ick_rates[]; |
Paul Walmsley | 543d937 | 2008-03-18 10:22:06 +0200 | [diff] [blame] | 566 | |
Mike Turquette | 32cc002 | 2012-11-10 16:58:41 -0700 | [diff] [blame] | 567 | #ifdef CONFIG_COMMON_CLK |
| 568 | extern const struct clk_hw_omap_ops clkhwops_omap3_dpll; |
| 569 | extern const struct clk_hw_omap_ops clkhwops_iclk_wait; |
| 570 | extern const struct clk_hw_omap_ops clkhwops_wait; |
| 571 | extern const struct clk_hw_omap_ops clkhwops_omap4_dpllmx; |
Rajendra Nayak | b4777a2 | 2012-04-27 15:53:48 +0530 | [diff] [blame] | 572 | extern const struct clk_hw_omap_ops clkhwops_iclk; |
| 573 | extern const struct clk_hw_omap_ops clkhwops_omap3430es2_ssi_wait; |
| 574 | extern const struct clk_hw_omap_ops clkhwops_omap3430es2_iclk_ssi_wait; |
| 575 | extern const struct clk_hw_omap_ops clkhwops_omap3430es2_dss_usbhost_wait; |
| 576 | extern const struct clk_hw_omap_ops clkhwops_omap3430es2_iclk_dss_usbhost_wait; |
| 577 | extern const struct clk_hw_omap_ops clkhwops_omap3430es2_iclk_hsotgusb_wait; |
| 578 | extern const struct clk_hw_omap_ops clkhwops_omap3430es2_hsotgusb_wait; |
| 579 | extern const struct clk_hw_omap_ops clkhwops_am35xx_ipss_module_wait; |
| 580 | extern const struct clk_hw_omap_ops clkhwops_am35xx_ipss_wait; |
| 581 | extern const struct clk_hw_omap_ops clkhwops_apll54; |
| 582 | extern const struct clk_hw_omap_ops clkhwops_apll96; |
| 583 | extern const struct clk_hw_omap_ops clkhwops_omap2xxx_dpll; |
| 584 | extern const struct clk_hw_omap_ops clkhwops_omap2430_i2chs_wait; |
| 585 | #else |
Paul Walmsley | 530e544 | 2011-02-25 15:39:28 -0700 | [diff] [blame] | 586 | extern const struct clkops clkops_omap2_iclk_dflt_wait; |
| 587 | extern const struct clkops clkops_omap2_iclk_dflt; |
| 588 | extern const struct clkops clkops_omap2_iclk_idle_only; |
Paul Walmsley | e892b25 | 2011-02-25 15:39:29 -0700 | [diff] [blame] | 589 | extern const struct clkops clkops_omap2_mdmclk_dflt_wait; |
Paul Walmsley | 0fd0c21 | 2011-02-25 15:49:53 -0700 | [diff] [blame] | 590 | extern const struct clkops clkops_omap2xxx_dpll_ops; |
Paul Walmsley | 657ebfa | 2010-02-22 22:09:20 -0700 | [diff] [blame] | 591 | extern const struct clkops clkops_omap3_noncore_dpll_ops; |
Rajendra Nayak | 6c6f5a7 | 2011-02-25 15:49:00 -0700 | [diff] [blame] | 592 | extern const struct clkops clkops_omap3_core_dpll_ops; |
Rajendra Nayak | 70db8a6 | 2011-02-25 15:49:02 -0700 | [diff] [blame] | 593 | extern const struct clkops clkops_omap4_dpllmx_ops; |
Rajendra Nayak | b4777a2 | 2012-04-27 15:53:48 +0530 | [diff] [blame] | 594 | #endif /* CONFIG_COMMON_CLK */ |
Paul Walmsley | 657ebfa | 2010-02-22 22:09:20 -0700 | [diff] [blame] | 595 | |
Paul Walmsley | 571efa0 | 2012-05-29 15:26:40 +0530 | [diff] [blame] | 596 | /* clksel_rate blocks shared between OMAP44xx and AM33xx */ |
| 597 | extern const struct clksel_rate div_1_0_rates[]; |
| 598 | extern const struct clksel_rate div_1_1_rates[]; |
| 599 | extern const struct clksel_rate div_1_2_rates[]; |
| 600 | extern const struct clksel_rate div_1_3_rates[]; |
| 601 | extern const struct clksel_rate div_1_4_rates[]; |
| 602 | extern const struct clksel_rate div31_1to31_rates[]; |
| 603 | |
Mike Turquette | 32cc002 | 2012-11-10 16:58:41 -0700 | [diff] [blame] | 604 | #ifndef CONFIG_COMMON_CLK |
Paul Walmsley | 571efa0 | 2012-05-29 15:26:40 +0530 | [diff] [blame] | 605 | /* clocks shared between various OMAP SoCs */ |
| 606 | extern struct clk virt_19200000_ck; |
| 607 | extern struct clk virt_26000000_ck; |
Mike Turquette | 32cc002 | 2012-11-10 16:58:41 -0700 | [diff] [blame] | 608 | #endif |
Paul Walmsley | 571efa0 | 2012-05-29 15:26:40 +0530 | [diff] [blame] | 609 | |
Vaibhav Hiremath | e30384a | 2012-05-29 15:26:41 +0530 | [diff] [blame] | 610 | extern int am33xx_clk_init(void); |
| 611 | |
Mike Turquette | 32cc002 | 2012-11-10 16:58:41 -0700 | [diff] [blame] | 612 | #ifdef CONFIG_COMMON_CLK |
| 613 | extern int omap2_clkops_enable_clkdm(struct clk_hw *hw); |
| 614 | extern void omap2_clkops_disable_clkdm(struct clk_hw *hw); |
| 615 | #endif |
| 616 | |
Paul Walmsley | 543d937 | 2008-03-18 10:22:06 +0200 | [diff] [blame] | 617 | #endif |