Paul Walmsley | 543d937 | 2008-03-18 10:22:06 +0200 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/mach-omap2/clock.c |
| 3 | * |
Tony Lindgren | a16e970 | 2008-03-18 11:56:39 +0200 | [diff] [blame] | 4 | * Copyright (C) 2005-2008 Texas Instruments, Inc. |
Paul Walmsley | 8c34974 | 2010-02-22 22:09:24 -0700 | [diff] [blame] | 5 | * Copyright (C) 2004-2010 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 | * |
Paul Walmsley | 543d937 | 2008-03-18 10:22:06 +0200 | [diff] [blame] | 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 | #undef DEBUG |
| 16 | |
Paul Walmsley | 543d937 | 2008-03-18 10:22:06 +0200 | [diff] [blame] | 17 | #include <linux/kernel.h> |
Paul Walmsley | 1fe9be8 | 2012-09-27 10:33:33 -0600 | [diff] [blame] | 18 | #include <linux/export.h> |
Paul Walmsley | 543d937 | 2008-03-18 10:22:06 +0200 | [diff] [blame] | 19 | #include <linux/list.h> |
| 20 | #include <linux/errno.h> |
Paul Walmsley | 4d30e82 | 2010-02-22 22:09:36 -0700 | [diff] [blame] | 21 | #include <linux/err.h> |
| 22 | #include <linux/delay.h> |
Stephen Boyd | f5b00f6 | 2015-06-22 17:05:21 -0700 | [diff] [blame] | 23 | #include <linux/clk.h> |
Mike Turquette | 32cc002 | 2012-11-10 16:58:41 -0700 | [diff] [blame] | 24 | #include <linux/clk-provider.h> |
Russell King | fced80c | 2008-09-06 12:10:45 +0100 | [diff] [blame] | 25 | #include <linux/io.h> |
Russell King | fbd3bdb | 2008-09-06 12:13:59 +0100 | [diff] [blame] | 26 | #include <linux/bitops.h> |
Tero Kristo | 9f029b1 | 2014-10-22 15:15:36 +0300 | [diff] [blame] | 27 | #include <linux/of_address.h> |
Jean Pihet | 5e7c58d | 2011-03-03 11:25:43 +0100 | [diff] [blame] | 28 | #include <asm/cpu.h> |
Tony Lindgren | dbc0416 | 2012-08-31 10:59:07 -0700 | [diff] [blame] | 29 | |
Tony Lindgren | dbc0416 | 2012-08-31 10:59:07 -0700 | [diff] [blame] | 30 | #include <trace/events/power.h> |
| 31 | |
| 32 | #include "soc.h" |
| 33 | #include "clockdomain.h" |
Paul Walmsley | 543d937 | 2008-03-18 10:22:06 +0200 | [diff] [blame] | 34 | #include "clock.h" |
Paul Walmsley | c4ceedc | 2012-10-29 20:56:29 -0600 | [diff] [blame] | 35 | #include "cm.h" |
Paul Walmsley | ff4ae5d | 2012-10-21 01:01:11 -0600 | [diff] [blame] | 36 | #include "cm2xxx.h" |
| 37 | #include "cm3xxx.h" |
Paul Walmsley | 543d937 | 2008-03-18 10:22:06 +0200 | [diff] [blame] | 38 | #include "cm-regbits-24xx.h" |
| 39 | #include "cm-regbits-34xx.h" |
Paul Walmsley | c4ceedc | 2012-10-29 20:56:29 -0600 | [diff] [blame] | 40 | #include "common.h" |
| 41 | |
Afzal Mohammed | 9954119 | 2011-12-13 10:46:43 -0800 | [diff] [blame] | 42 | u16 cpu_mask; |
Paul Walmsley | 543d937 | 2008-03-18 10:22:06 +0200 | [diff] [blame] | 43 | |
Tero Kristo | a24886e | 2014-07-02 11:47:40 +0300 | [diff] [blame] | 44 | /* DPLL valid Fint frequency band limits - from 34xx TRM Section 4.7.6.2 */ |
| 45 | #define OMAP3430_DPLL_FINT_BAND1_MIN 750000 |
| 46 | #define OMAP3430_DPLL_FINT_BAND1_MAX 2100000 |
| 47 | #define OMAP3430_DPLL_FINT_BAND2_MIN 7500000 |
| 48 | #define OMAP3430_DPLL_FINT_BAND2_MAX 21000000 |
| 49 | |
| 50 | /* |
| 51 | * DPLL valid Fint frequency range for OMAP36xx and OMAP4xxx. |
| 52 | * From device data manual section 4.3 "DPLL and DLL Specifications". |
| 53 | */ |
| 54 | #define OMAP3PLUS_DPLL_FINT_MIN 32000 |
| 55 | #define OMAP3PLUS_DPLL_FINT_MAX 52000000 |
| 56 | |
Tero Kristo | 6c0afb5 | 2017-02-09 11:24:37 +0200 | [diff] [blame] | 57 | struct ti_clk_ll_ops omap_clk_ll_ops = { |
Tero Kristo | 9a356d6 | 2015-03-03 11:14:31 +0200 | [diff] [blame] | 58 | .clkdm_clk_enable = clkdm_clk_enable, |
| 59 | .clkdm_clk_disable = clkdm_clk_disable, |
Tero Kristo | b6f27b2 | 2016-09-30 14:10:11 +0300 | [diff] [blame] | 60 | .clkdm_lookup = clkdm_lookup, |
Tero Kristo | 192383d | 2015-03-03 13:47:08 +0200 | [diff] [blame] | 61 | .cm_wait_module_ready = omap_cm_wait_module_ready, |
| 62 | .cm_split_idlest_reg = cm_split_idlest_reg, |
Tero Kristo | 9f029b1 | 2014-10-22 15:15:36 +0300 | [diff] [blame] | 63 | }; |
Tero Kristo | 3ada6b10 | 2013-10-22 11:47:08 +0300 | [diff] [blame] | 64 | |
Tero Kristo | 9f029b1 | 2014-10-22 15:15:36 +0300 | [diff] [blame] | 65 | /** |
Tero Kristo | e9e6308 | 2015-04-27 21:55:42 +0300 | [diff] [blame] | 66 | * omap2_clk_setup_ll_ops - setup clock driver low-level ops |
| 67 | * |
| 68 | * Sets up clock driver low-level platform ops. These are needed |
| 69 | * for register accesses and various other misc platform operations. |
| 70 | * Returns 0 on success, -EBUSY if low level ops have been registered |
| 71 | * already. |
| 72 | */ |
| 73 | int __init omap2_clk_setup_ll_ops(void) |
| 74 | { |
| 75 | return ti_clk_setup_ll_ops(&omap_clk_ll_ops); |
| 76 | } |
| 77 | |
Mike Turquette | 32cc002 | 2012-11-10 16:58:41 -0700 | [diff] [blame] | 78 | /* |
Paul Walmsley | 30962d9 | 2010-02-22 22:09:38 -0700 | [diff] [blame] | 79 | * OMAP2+ specific clock functions |
| 80 | */ |
Paul Walmsley | 543d937 | 2008-03-18 10:22:06 +0200 | [diff] [blame] | 81 | |
Tero Kristo | 8111e01 | 2014-07-02 11:47:39 +0300 | [diff] [blame] | 82 | /** |
| 83 | * ti_clk_init_features - init clock features struct for the SoC |
| 84 | * |
| 85 | * Initializes the clock features struct based on the SoC type. |
| 86 | */ |
| 87 | void __init ti_clk_init_features(void) |
| 88 | { |
Tero Kristo | f3b19aa | 2015-02-27 17:54:14 +0200 | [diff] [blame] | 89 | struct ti_clk_features features = { 0 }; |
Tero Kristo | a24886e | 2014-07-02 11:47:40 +0300 | [diff] [blame] | 90 | /* Fint setup for DPLLs */ |
| 91 | if (cpu_is_omap3430()) { |
Tero Kristo | f3b19aa | 2015-02-27 17:54:14 +0200 | [diff] [blame] | 92 | features.fint_min = OMAP3430_DPLL_FINT_BAND1_MIN; |
| 93 | features.fint_max = OMAP3430_DPLL_FINT_BAND2_MAX; |
| 94 | features.fint_band1_max = OMAP3430_DPLL_FINT_BAND1_MAX; |
| 95 | features.fint_band2_min = OMAP3430_DPLL_FINT_BAND2_MIN; |
Tero Kristo | a24886e | 2014-07-02 11:47:40 +0300 | [diff] [blame] | 96 | } else { |
Tero Kristo | f3b19aa | 2015-02-27 17:54:14 +0200 | [diff] [blame] | 97 | features.fint_min = OMAP3PLUS_DPLL_FINT_MIN; |
| 98 | features.fint_max = OMAP3PLUS_DPLL_FINT_MAX; |
Tero Kristo | a24886e | 2014-07-02 11:47:40 +0300 | [diff] [blame] | 99 | } |
Tero Kristo | 512d91c | 2014-07-02 11:47:42 +0300 | [diff] [blame] | 100 | |
| 101 | /* Bypass value setup for DPLLs */ |
| 102 | if (cpu_is_omap24xx()) { |
Tero Kristo | f3b19aa | 2015-02-27 17:54:14 +0200 | [diff] [blame] | 103 | features.dpll_bypass_vals |= |
Tero Kristo | 512d91c | 2014-07-02 11:47:42 +0300 | [diff] [blame] | 104 | (1 << OMAP2XXX_EN_DPLL_LPBYPASS) | |
| 105 | (1 << OMAP2XXX_EN_DPLL_FRBYPASS); |
| 106 | } else if (cpu_is_omap34xx()) { |
Tero Kristo | f3b19aa | 2015-02-27 17:54:14 +0200 | [diff] [blame] | 107 | features.dpll_bypass_vals |= |
Tero Kristo | 512d91c | 2014-07-02 11:47:42 +0300 | [diff] [blame] | 108 | (1 << OMAP3XXX_EN_DPLL_LPBYPASS) | |
| 109 | (1 << OMAP3XXX_EN_DPLL_FRBYPASS); |
| 110 | } else if (soc_is_am33xx() || cpu_is_omap44xx() || soc_is_am43xx() || |
| 111 | soc_is_omap54xx() || soc_is_dra7xx()) { |
Tero Kristo | f3b19aa | 2015-02-27 17:54:14 +0200 | [diff] [blame] | 112 | features.dpll_bypass_vals |= |
Tero Kristo | 512d91c | 2014-07-02 11:47:42 +0300 | [diff] [blame] | 113 | (1 << OMAP4XXX_EN_DPLL_LPBYPASS) | |
| 114 | (1 << OMAP4XXX_EN_DPLL_FRBYPASS) | |
| 115 | (1 << OMAP4XXX_EN_DPLL_MNBYPASS); |
| 116 | } |
Tero Kristo | 2337c5b | 2014-07-02 11:47:43 +0300 | [diff] [blame] | 117 | |
| 118 | /* Jitter correction only available on OMAP343X */ |
| 119 | if (cpu_is_omap343x()) |
Tero Kristo | f3b19aa | 2015-02-27 17:54:14 +0200 | [diff] [blame] | 120 | features.flags |= TI_CLK_DPLL_HAS_FREQSEL; |
Tero Kristo | 066edb2 | 2014-07-02 11:47:44 +0300 | [diff] [blame] | 121 | |
| 122 | /* Idlest value for interface clocks. |
| 123 | * 24xx uses 0 to indicate not ready, and 1 to indicate ready. |
| 124 | * 34xx reverses this, just to keep us on our toes |
| 125 | * AM35xx uses both, depending on the module. |
| 126 | */ |
| 127 | if (cpu_is_omap24xx()) |
Tero Kristo | f3b19aa | 2015-02-27 17:54:14 +0200 | [diff] [blame] | 128 | features.cm_idlest_val = OMAP24XX_CM_IDLEST_VAL; |
Tero Kristo | 066edb2 | 2014-07-02 11:47:44 +0300 | [diff] [blame] | 129 | else if (cpu_is_omap34xx()) |
Tero Kristo | f3b19aa | 2015-02-27 17:54:14 +0200 | [diff] [blame] | 130 | features.cm_idlest_val = OMAP34XX_CM_IDLEST_VAL; |
Tero Kristo | f0d2f68 | 2014-10-03 16:57:10 +0300 | [diff] [blame] | 131 | |
| 132 | /* On OMAP3430 ES1.0, DPLL4 can't be re-programmed */ |
| 133 | if (omap_rev() == OMAP3430_REV_ES1_0) |
Tero Kristo | f3b19aa | 2015-02-27 17:54:14 +0200 | [diff] [blame] | 134 | features.flags |= TI_CLK_DPLL4_DENY_REPROGRAM; |
| 135 | |
Tero Kristo | 07ff73a | 2015-11-30 16:43:25 +0200 | [diff] [blame] | 136 | /* Errata I810 for omap5 / dra7 */ |
| 137 | if (soc_is_omap54xx() || soc_is_dra7xx()) |
| 138 | features.flags |= TI_CLK_ERRATA_I810; |
| 139 | |
Tero Kristo | f3b19aa | 2015-02-27 17:54:14 +0200 | [diff] [blame] | 140 | ti_clk_setup_features(&features); |
Tero Kristo | 8111e01 | 2014-07-02 11:47:39 +0300 | [diff] [blame] | 141 | } |