Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify it |
| 5 | * under the terms and conditions of the GNU General Public License, |
| 6 | * version 2, as published by the Free Software Foundation. |
| 7 | * |
| 8 | * This program is distributed in the hope it will be useful, but WITHOUT |
| 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 11 | * more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License |
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | */ |
| 16 | |
| 17 | #include <linux/io.h> |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 18 | #include <linux/clk-provider.h> |
| 19 | #include <linux/clkdev.h> |
| 20 | #include <linux/of.h> |
| 21 | #include <linux/of_address.h> |
| 22 | #include <linux/clk/tegra.h> |
Joseph Lo | 4a2e327 | 2013-01-15 22:10:48 +0000 | [diff] [blame] | 23 | #include <linux/delay.h> |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 24 | #include <dt-bindings/clock/tegra20-car.h> |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 25 | |
| 26 | #include "clk.h" |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 27 | #include "clk-id.h" |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 28 | |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 29 | #define OSC_CTRL 0x50 |
| 30 | #define OSC_CTRL_OSC_FREQ_MASK (3<<30) |
| 31 | #define OSC_CTRL_OSC_FREQ_13MHZ (0<<30) |
| 32 | #define OSC_CTRL_OSC_FREQ_19_2MHZ (1<<30) |
| 33 | #define OSC_CTRL_OSC_FREQ_12MHZ (2<<30) |
| 34 | #define OSC_CTRL_OSC_FREQ_26MHZ (3<<30) |
| 35 | #define OSC_CTRL_MASK (0x3f2 | OSC_CTRL_OSC_FREQ_MASK) |
| 36 | |
| 37 | #define OSC_CTRL_PLL_REF_DIV_MASK (3<<28) |
| 38 | #define OSC_CTRL_PLL_REF_DIV_1 (0<<28) |
| 39 | #define OSC_CTRL_PLL_REF_DIV_2 (1<<28) |
| 40 | #define OSC_CTRL_PLL_REF_DIV_4 (2<<28) |
| 41 | |
| 42 | #define OSC_FREQ_DET 0x58 |
| 43 | #define OSC_FREQ_DET_TRIG (1<<31) |
| 44 | |
| 45 | #define OSC_FREQ_DET_STATUS 0x5c |
| 46 | #define OSC_FREQ_DET_BUSY (1<<31) |
| 47 | #define OSC_FREQ_DET_CNT_MASK 0xFFFF |
| 48 | |
Peter De Schrijver | d5ff89a | 2013-08-22 18:44:06 +0300 | [diff] [blame] | 49 | #define TEGRA20_CLK_PERIPH_BANKS 3 |
| 50 | |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 51 | #define PLLS_BASE 0xf0 |
| 52 | #define PLLS_MISC 0xf4 |
| 53 | #define PLLC_BASE 0x80 |
| 54 | #define PLLC_MISC 0x8c |
| 55 | #define PLLM_BASE 0x90 |
| 56 | #define PLLM_MISC 0x9c |
| 57 | #define PLLP_BASE 0xa0 |
| 58 | #define PLLP_MISC 0xac |
| 59 | #define PLLA_BASE 0xb0 |
| 60 | #define PLLA_MISC 0xbc |
| 61 | #define PLLU_BASE 0xc0 |
| 62 | #define PLLU_MISC 0xcc |
| 63 | #define PLLD_BASE 0xd0 |
| 64 | #define PLLD_MISC 0xdc |
| 65 | #define PLLX_BASE 0xe0 |
| 66 | #define PLLX_MISC 0xe4 |
| 67 | #define PLLE_BASE 0xe8 |
| 68 | #define PLLE_MISC 0xec |
| 69 | |
Peter De Schrijver | 3e72771 | 2013-04-03 17:40:40 +0300 | [diff] [blame] | 70 | #define PLL_BASE_LOCK BIT(27) |
| 71 | #define PLLE_MISC_LOCK BIT(11) |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 72 | |
| 73 | #define PLL_MISC_LOCK_ENABLE 18 |
| 74 | #define PLLDU_MISC_LOCK_ENABLE 22 |
| 75 | #define PLLE_MISC_LOCK_ENABLE 9 |
| 76 | |
| 77 | #define PLLC_OUT 0x84 |
| 78 | #define PLLM_OUT 0x94 |
| 79 | #define PLLP_OUTA 0xa4 |
| 80 | #define PLLP_OUTB 0xa8 |
| 81 | #define PLLA_OUT 0xb4 |
| 82 | |
| 83 | #define CCLK_BURST_POLICY 0x20 |
| 84 | #define SUPER_CCLK_DIVIDER 0x24 |
| 85 | #define SCLK_BURST_POLICY 0x28 |
| 86 | #define SUPER_SCLK_DIVIDER 0x2c |
| 87 | #define CLK_SYSTEM_RATE 0x30 |
| 88 | |
Joseph Lo | 4a2e327 | 2013-01-15 22:10:48 +0000 | [diff] [blame] | 89 | #define CCLK_BURST_POLICY_SHIFT 28 |
| 90 | #define CCLK_RUN_POLICY_SHIFT 4 |
| 91 | #define CCLK_IDLE_POLICY_SHIFT 0 |
| 92 | #define CCLK_IDLE_POLICY 1 |
| 93 | #define CCLK_RUN_POLICY 2 |
| 94 | #define CCLK_BURST_POLICY_PLLX 8 |
| 95 | |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 96 | #define CLK_SOURCE_I2S1 0x100 |
| 97 | #define CLK_SOURCE_I2S2 0x104 |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 98 | #define CLK_SOURCE_PWM 0x110 |
| 99 | #define CLK_SOURCE_SPI 0x114 |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 100 | #define CLK_SOURCE_XIO 0x120 |
| 101 | #define CLK_SOURCE_TWC 0x12c |
| 102 | #define CLK_SOURCE_IDE 0x144 |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 103 | #define CLK_SOURCE_HDMI 0x18c |
| 104 | #define CLK_SOURCE_DISP1 0x138 |
| 105 | #define CLK_SOURCE_DISP2 0x13c |
| 106 | #define CLK_SOURCE_CSITE 0x1d4 |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 107 | #define CLK_SOURCE_I2C1 0x124 |
| 108 | #define CLK_SOURCE_I2C2 0x198 |
| 109 | #define CLK_SOURCE_I2C3 0x1b8 |
| 110 | #define CLK_SOURCE_DVC 0x128 |
| 111 | #define CLK_SOURCE_UARTA 0x178 |
| 112 | #define CLK_SOURCE_UARTB 0x17c |
| 113 | #define CLK_SOURCE_UARTC 0x1a0 |
| 114 | #define CLK_SOURCE_UARTD 0x1c0 |
| 115 | #define CLK_SOURCE_UARTE 0x1c4 |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 116 | #define CLK_SOURCE_EMC 0x19c |
| 117 | |
| 118 | #define AUDIO_SYNC_CLK 0x38 |
| 119 | |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 120 | /* Tegra CPU clock and reset control regs */ |
| 121 | #define TEGRA_CLK_RST_CONTROLLER_CLK_CPU_CMPLX 0x4c |
| 122 | #define TEGRA_CLK_RST_CONTROLLER_RST_CPU_CMPLX_SET 0x340 |
| 123 | #define TEGRA_CLK_RST_CONTROLLER_RST_CPU_CMPLX_CLR 0x344 |
| 124 | |
| 125 | #define CPU_CLOCK(cpu) (0x1 << (8 + cpu)) |
| 126 | #define CPU_RESET(cpu) (0x1111ul << (cpu)) |
| 127 | |
Joseph Lo | 4a2e327 | 2013-01-15 22:10:48 +0000 | [diff] [blame] | 128 | #ifdef CONFIG_PM_SLEEP |
| 129 | static struct cpu_clk_suspend_context { |
| 130 | u32 pllx_misc; |
| 131 | u32 pllx_base; |
| 132 | |
| 133 | u32 cpu_burst; |
| 134 | u32 clk_csite_src; |
| 135 | u32 cclk_divider; |
| 136 | } tegra20_cpu_clk_sctx; |
| 137 | #endif |
| 138 | |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 139 | static void __iomem *clk_base; |
| 140 | static void __iomem *pmc_base; |
| 141 | |
Thierry Reding | 4f4f85f | 2014-07-29 10:17:53 +0200 | [diff] [blame] | 142 | static DEFINE_SPINLOCK(emc_lock); |
| 143 | |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 144 | #define TEGRA_INIT_DATA_MUX(_name, _parents, _offset, \ |
Peter De Schrijver | d5ff89a | 2013-08-22 18:44:06 +0300 | [diff] [blame] | 145 | _clk_num, _gate_flags, _clk_id) \ |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 146 | TEGRA_INIT_DATA(_name, NULL, NULL, _parents, _offset, \ |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 147 | 30, 2, 0, 0, 8, 1, TEGRA_DIVIDER_ROUND_UP, \ |
Peter De Schrijver | 343a607 | 2013-09-02 15:22:02 +0300 | [diff] [blame] | 148 | _clk_num, \ |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 149 | _gate_flags, _clk_id) |
| 150 | |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 151 | #define TEGRA_INIT_DATA_DIV16(_name, _parents, _offset, \ |
Peter De Schrijver | d5ff89a | 2013-08-22 18:44:06 +0300 | [diff] [blame] | 152 | _clk_num, _gate_flags, _clk_id) \ |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 153 | TEGRA_INIT_DATA(_name, NULL, NULL, _parents, _offset, \ |
Peter De Schrijver | d5ff89a | 2013-08-22 18:44:06 +0300 | [diff] [blame] | 154 | 30, 2, 0, 0, 16, 0, TEGRA_DIVIDER_ROUND_UP, \ |
Peter De Schrijver | 343a607 | 2013-09-02 15:22:02 +0300 | [diff] [blame] | 155 | _clk_num, _gate_flags, \ |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 156 | _clk_id) |
| 157 | |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 158 | #define TEGRA_INIT_DATA_NODIV(_name, _parents, _offset, \ |
Peter De Schrijver | d5ff89a | 2013-08-22 18:44:06 +0300 | [diff] [blame] | 159 | _mux_shift, _mux_width, _clk_num, \ |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 160 | _gate_flags, _clk_id) \ |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 161 | TEGRA_INIT_DATA(_name, NULL, NULL, _parents, _offset, \ |
Peter De Schrijver | d5ff89a | 2013-08-22 18:44:06 +0300 | [diff] [blame] | 162 | _mux_shift, _mux_width, 0, 0, 0, 0, 0, \ |
Peter De Schrijver | 343a607 | 2013-09-02 15:22:02 +0300 | [diff] [blame] | 163 | _clk_num, _gate_flags, \ |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 164 | _clk_id) |
| 165 | |
Peter De Schrijver | 343a607 | 2013-09-02 15:22:02 +0300 | [diff] [blame] | 166 | static struct clk **clks; |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 167 | |
| 168 | static struct tegra_clk_pll_freq_table pll_c_freq_table[] = { |
Rhyland Klein | 86c679a | 2015-06-18 17:28:34 -0400 | [diff] [blame] | 169 | { 12000000, 600000000, 600, 12, 1, 8 }, |
| 170 | { 13000000, 600000000, 600, 13, 1, 8 }, |
| 171 | { 19200000, 600000000, 500, 16, 1, 6 }, |
| 172 | { 26000000, 600000000, 600, 26, 1, 8 }, |
Thierry Reding | 8d99704 | 2015-11-18 14:10:02 +0100 | [diff] [blame] | 173 | { 0, 0, 0, 0, 0, 0 }, |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 174 | }; |
| 175 | |
| 176 | static struct tegra_clk_pll_freq_table pll_m_freq_table[] = { |
Rhyland Klein | 86c679a | 2015-06-18 17:28:34 -0400 | [diff] [blame] | 177 | { 12000000, 666000000, 666, 12, 1, 8 }, |
| 178 | { 13000000, 666000000, 666, 13, 1, 8 }, |
| 179 | { 19200000, 666000000, 555, 16, 1, 8 }, |
| 180 | { 26000000, 666000000, 666, 26, 1, 8 }, |
| 181 | { 12000000, 600000000, 600, 12, 1, 8 }, |
| 182 | { 13000000, 600000000, 600, 13, 1, 8 }, |
| 183 | { 19200000, 600000000, 375, 12, 1, 6 }, |
| 184 | { 26000000, 600000000, 600, 26, 1, 8 }, |
Thierry Reding | 8d99704 | 2015-11-18 14:10:02 +0100 | [diff] [blame] | 185 | { 0, 0, 0, 0, 0, 0 }, |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 186 | }; |
| 187 | |
| 188 | static struct tegra_clk_pll_freq_table pll_p_freq_table[] = { |
Rhyland Klein | 86c679a | 2015-06-18 17:28:34 -0400 | [diff] [blame] | 189 | { 12000000, 216000000, 432, 12, 2, 8 }, |
| 190 | { 13000000, 216000000, 432, 13, 2, 8 }, |
| 191 | { 19200000, 216000000, 90, 4, 2, 1 }, |
| 192 | { 26000000, 216000000, 432, 26, 2, 8 }, |
| 193 | { 12000000, 432000000, 432, 12, 1, 8 }, |
| 194 | { 13000000, 432000000, 432, 13, 1, 8 }, |
| 195 | { 19200000, 432000000, 90, 4, 1, 1 }, |
| 196 | { 26000000, 432000000, 432, 26, 1, 8 }, |
Thierry Reding | 8d99704 | 2015-11-18 14:10:02 +0100 | [diff] [blame] | 197 | { 0, 0, 0, 0, 0, 0 }, |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 198 | }; |
| 199 | |
| 200 | static struct tegra_clk_pll_freq_table pll_a_freq_table[] = { |
Rhyland Klein | 86c679a | 2015-06-18 17:28:34 -0400 | [diff] [blame] | 201 | { 28800000, 56448000, 49, 25, 1, 1 }, |
| 202 | { 28800000, 73728000, 64, 25, 1, 1 }, |
| 203 | { 28800000, 24000000, 5, 6, 1, 1 }, |
Thierry Reding | 8d99704 | 2015-11-18 14:10:02 +0100 | [diff] [blame] | 204 | { 0, 0, 0, 0, 0, 0 }, |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 205 | }; |
| 206 | |
| 207 | static struct tegra_clk_pll_freq_table pll_d_freq_table[] = { |
Rhyland Klein | 86c679a | 2015-06-18 17:28:34 -0400 | [diff] [blame] | 208 | { 12000000, 216000000, 216, 12, 1, 4 }, |
| 209 | { 13000000, 216000000, 216, 13, 1, 4 }, |
| 210 | { 19200000, 216000000, 135, 12, 1, 3 }, |
| 211 | { 26000000, 216000000, 216, 26, 1, 4 }, |
| 212 | { 12000000, 594000000, 594, 12, 1, 8 }, |
| 213 | { 13000000, 594000000, 594, 13, 1, 8 }, |
| 214 | { 19200000, 594000000, 495, 16, 1, 8 }, |
| 215 | { 26000000, 594000000, 594, 26, 1, 8 }, |
| 216 | { 12000000, 1000000000, 1000, 12, 1, 12 }, |
| 217 | { 13000000, 1000000000, 1000, 13, 1, 12 }, |
| 218 | { 19200000, 1000000000, 625, 12, 1, 8 }, |
| 219 | { 26000000, 1000000000, 1000, 26, 1, 12 }, |
Thierry Reding | 8d99704 | 2015-11-18 14:10:02 +0100 | [diff] [blame] | 220 | { 0, 0, 0, 0, 0, 0 }, |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 221 | }; |
| 222 | |
| 223 | static struct tegra_clk_pll_freq_table pll_u_freq_table[] = { |
Rhyland Klein | 86c679a | 2015-06-18 17:28:34 -0400 | [diff] [blame] | 224 | { 12000000, 480000000, 960, 12, 1, 0 }, |
| 225 | { 13000000, 480000000, 960, 13, 1, 0 }, |
| 226 | { 19200000, 480000000, 200, 4, 1, 0 }, |
| 227 | { 26000000, 480000000, 960, 26, 1, 0 }, |
Thierry Reding | 8d99704 | 2015-11-18 14:10:02 +0100 | [diff] [blame] | 228 | { 0, 0, 0, 0, 0, 0 }, |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 229 | }; |
| 230 | |
| 231 | static struct tegra_clk_pll_freq_table pll_x_freq_table[] = { |
| 232 | /* 1 GHz */ |
Rhyland Klein | 86c679a | 2015-06-18 17:28:34 -0400 | [diff] [blame] | 233 | { 12000000, 1000000000, 1000, 12, 1, 12 }, |
| 234 | { 13000000, 1000000000, 1000, 13, 1, 12 }, |
| 235 | { 19200000, 1000000000, 625, 12, 1, 8 }, |
| 236 | { 26000000, 1000000000, 1000, 26, 1, 12 }, |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 237 | /* 912 MHz */ |
Rhyland Klein | 86c679a | 2015-06-18 17:28:34 -0400 | [diff] [blame] | 238 | { 12000000, 912000000, 912, 12, 1, 12 }, |
| 239 | { 13000000, 912000000, 912, 13, 1, 12 }, |
| 240 | { 19200000, 912000000, 760, 16, 1, 8 }, |
| 241 | { 26000000, 912000000, 912, 26, 1, 12 }, |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 242 | /* 816 MHz */ |
Rhyland Klein | 86c679a | 2015-06-18 17:28:34 -0400 | [diff] [blame] | 243 | { 12000000, 816000000, 816, 12, 1, 12 }, |
| 244 | { 13000000, 816000000, 816, 13, 1, 12 }, |
| 245 | { 19200000, 816000000, 680, 16, 1, 8 }, |
| 246 | { 26000000, 816000000, 816, 26, 1, 12 }, |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 247 | /* 760 MHz */ |
Rhyland Klein | 86c679a | 2015-06-18 17:28:34 -0400 | [diff] [blame] | 248 | { 12000000, 760000000, 760, 12, 1, 12 }, |
| 249 | { 13000000, 760000000, 760, 13, 1, 12 }, |
| 250 | { 19200000, 760000000, 950, 24, 1, 8 }, |
| 251 | { 26000000, 760000000, 760, 26, 1, 12 }, |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 252 | /* 750 MHz */ |
Rhyland Klein | 86c679a | 2015-06-18 17:28:34 -0400 | [diff] [blame] | 253 | { 12000000, 750000000, 750, 12, 1, 12 }, |
| 254 | { 13000000, 750000000, 750, 13, 1, 12 }, |
| 255 | { 19200000, 750000000, 625, 16, 1, 8 }, |
| 256 | { 26000000, 750000000, 750, 26, 1, 12 }, |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 257 | /* 608 MHz */ |
Rhyland Klein | 86c679a | 2015-06-18 17:28:34 -0400 | [diff] [blame] | 258 | { 12000000, 608000000, 608, 12, 1, 12 }, |
| 259 | { 13000000, 608000000, 608, 13, 1, 12 }, |
| 260 | { 19200000, 608000000, 380, 12, 1, 8 }, |
| 261 | { 26000000, 608000000, 608, 26, 1, 12 }, |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 262 | /* 456 MHz */ |
Rhyland Klein | 86c679a | 2015-06-18 17:28:34 -0400 | [diff] [blame] | 263 | { 12000000, 456000000, 456, 12, 1, 12 }, |
| 264 | { 13000000, 456000000, 456, 13, 1, 12 }, |
| 265 | { 19200000, 456000000, 380, 16, 1, 8 }, |
| 266 | { 26000000, 456000000, 456, 26, 1, 12 }, |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 267 | /* 312 MHz */ |
Rhyland Klein | 86c679a | 2015-06-18 17:28:34 -0400 | [diff] [blame] | 268 | { 12000000, 312000000, 312, 12, 1, 12 }, |
| 269 | { 13000000, 312000000, 312, 13, 1, 12 }, |
| 270 | { 19200000, 312000000, 260, 16, 1, 8 }, |
| 271 | { 26000000, 312000000, 312, 26, 1, 12 }, |
Thierry Reding | 8d99704 | 2015-11-18 14:10:02 +0100 | [diff] [blame] | 272 | { 0, 0, 0, 0, 0, 0 }, |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 273 | }; |
| 274 | |
Rhyland Klein | 86c679a | 2015-06-18 17:28:34 -0400 | [diff] [blame] | 275 | static const struct pdiv_map plle_p[] = { |
| 276 | { .pdiv = 1, .hw_val = 1 }, |
| 277 | { .pdiv = 0, .hw_val = 0 }, |
| 278 | }; |
| 279 | |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 280 | static struct tegra_clk_pll_freq_table pll_e_freq_table[] = { |
Rhyland Klein | 86c679a | 2015-06-18 17:28:34 -0400 | [diff] [blame] | 281 | { 12000000, 100000000, 200, 24, 1, 0 }, |
Thierry Reding | 8d99704 | 2015-11-18 14:10:02 +0100 | [diff] [blame] | 282 | { 0, 0, 0, 0, 0, 0 }, |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 283 | }; |
| 284 | |
| 285 | /* PLL parameters */ |
| 286 | static struct tegra_clk_pll_params pll_c_params = { |
| 287 | .input_min = 2000000, |
| 288 | .input_max = 31000000, |
| 289 | .cf_min = 1000000, |
| 290 | .cf_max = 6000000, |
| 291 | .vco_min = 20000000, |
| 292 | .vco_max = 1400000000, |
| 293 | .base_reg = PLLC_BASE, |
| 294 | .misc_reg = PLLC_MISC, |
Peter De Schrijver | 3e72771 | 2013-04-03 17:40:40 +0300 | [diff] [blame] | 295 | .lock_mask = PLL_BASE_LOCK, |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 296 | .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE, |
| 297 | .lock_delay = 300, |
Peter De Schrijver | ebe142b | 2013-10-04 17:28:34 +0300 | [diff] [blame] | 298 | .freq_table = pll_c_freq_table, |
Rhyland Klein | 3706b43 | 2015-06-18 17:28:23 -0400 | [diff] [blame] | 299 | .flags = TEGRA_PLL_HAS_CPCON | TEGRA_PLL_HAS_LOCK_ENABLE, |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 300 | }; |
| 301 | |
| 302 | static struct tegra_clk_pll_params pll_m_params = { |
| 303 | .input_min = 2000000, |
| 304 | .input_max = 31000000, |
| 305 | .cf_min = 1000000, |
| 306 | .cf_max = 6000000, |
| 307 | .vco_min = 20000000, |
| 308 | .vco_max = 1200000000, |
| 309 | .base_reg = PLLM_BASE, |
| 310 | .misc_reg = PLLM_MISC, |
Peter De Schrijver | 3e72771 | 2013-04-03 17:40:40 +0300 | [diff] [blame] | 311 | .lock_mask = PLL_BASE_LOCK, |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 312 | .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE, |
| 313 | .lock_delay = 300, |
Peter De Schrijver | ebe142b | 2013-10-04 17:28:34 +0300 | [diff] [blame] | 314 | .freq_table = pll_m_freq_table, |
Rhyland Klein | 3706b43 | 2015-06-18 17:28:23 -0400 | [diff] [blame] | 315 | .flags = TEGRA_PLL_HAS_CPCON | TEGRA_PLL_HAS_LOCK_ENABLE, |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 316 | }; |
| 317 | |
| 318 | static struct tegra_clk_pll_params pll_p_params = { |
| 319 | .input_min = 2000000, |
| 320 | .input_max = 31000000, |
| 321 | .cf_min = 1000000, |
| 322 | .cf_max = 6000000, |
| 323 | .vco_min = 20000000, |
| 324 | .vco_max = 1400000000, |
| 325 | .base_reg = PLLP_BASE, |
| 326 | .misc_reg = PLLP_MISC, |
Peter De Schrijver | 3e72771 | 2013-04-03 17:40:40 +0300 | [diff] [blame] | 327 | .lock_mask = PLL_BASE_LOCK, |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 328 | .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE, |
| 329 | .lock_delay = 300, |
Peter De Schrijver | ebe142b | 2013-10-04 17:28:34 +0300 | [diff] [blame] | 330 | .freq_table = pll_p_freq_table, |
Rhyland Klein | 3706b43 | 2015-06-18 17:28:23 -0400 | [diff] [blame] | 331 | .flags = TEGRA_PLL_FIXED | TEGRA_PLL_HAS_CPCON | |
| 332 | TEGRA_PLL_HAS_LOCK_ENABLE, |
Peter De Schrijver | ebe142b | 2013-10-04 17:28:34 +0300 | [diff] [blame] | 333 | .fixed_rate = 216000000, |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 334 | }; |
| 335 | |
| 336 | static struct tegra_clk_pll_params pll_a_params = { |
| 337 | .input_min = 2000000, |
| 338 | .input_max = 31000000, |
| 339 | .cf_min = 1000000, |
| 340 | .cf_max = 6000000, |
| 341 | .vco_min = 20000000, |
| 342 | .vco_max = 1400000000, |
| 343 | .base_reg = PLLA_BASE, |
| 344 | .misc_reg = PLLA_MISC, |
Peter De Schrijver | 3e72771 | 2013-04-03 17:40:40 +0300 | [diff] [blame] | 345 | .lock_mask = PLL_BASE_LOCK, |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 346 | .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE, |
| 347 | .lock_delay = 300, |
Peter De Schrijver | ebe142b | 2013-10-04 17:28:34 +0300 | [diff] [blame] | 348 | .freq_table = pll_a_freq_table, |
Rhyland Klein | 3706b43 | 2015-06-18 17:28:23 -0400 | [diff] [blame] | 349 | .flags = TEGRA_PLL_HAS_CPCON | TEGRA_PLL_HAS_LOCK_ENABLE, |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 350 | }; |
| 351 | |
| 352 | static struct tegra_clk_pll_params pll_d_params = { |
| 353 | .input_min = 2000000, |
| 354 | .input_max = 40000000, |
| 355 | .cf_min = 1000000, |
| 356 | .cf_max = 6000000, |
| 357 | .vco_min = 40000000, |
| 358 | .vco_max = 1000000000, |
| 359 | .base_reg = PLLD_BASE, |
| 360 | .misc_reg = PLLD_MISC, |
Peter De Schrijver | 3e72771 | 2013-04-03 17:40:40 +0300 | [diff] [blame] | 361 | .lock_mask = PLL_BASE_LOCK, |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 362 | .lock_enable_bit_idx = PLLDU_MISC_LOCK_ENABLE, |
| 363 | .lock_delay = 1000, |
Peter De Schrijver | ebe142b | 2013-10-04 17:28:34 +0300 | [diff] [blame] | 364 | .freq_table = pll_d_freq_table, |
Rhyland Klein | 3706b43 | 2015-06-18 17:28:23 -0400 | [diff] [blame] | 365 | .flags = TEGRA_PLL_HAS_CPCON | TEGRA_PLL_HAS_LOCK_ENABLE, |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 366 | }; |
| 367 | |
Thierry Reding | 385f9ad | 2015-11-19 16:34:06 +0100 | [diff] [blame] | 368 | static const struct pdiv_map pllu_p[] = { |
Peter De Schrijver | 0b6525a | 2013-04-03 17:40:39 +0300 | [diff] [blame] | 369 | { .pdiv = 1, .hw_val = 1 }, |
| 370 | { .pdiv = 2, .hw_val = 0 }, |
| 371 | { .pdiv = 0, .hw_val = 0 }, |
| 372 | }; |
| 373 | |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 374 | static struct tegra_clk_pll_params pll_u_params = { |
| 375 | .input_min = 2000000, |
| 376 | .input_max = 40000000, |
| 377 | .cf_min = 1000000, |
| 378 | .cf_max = 6000000, |
| 379 | .vco_min = 48000000, |
| 380 | .vco_max = 960000000, |
| 381 | .base_reg = PLLU_BASE, |
| 382 | .misc_reg = PLLU_MISC, |
Peter De Schrijver | 3e72771 | 2013-04-03 17:40:40 +0300 | [diff] [blame] | 383 | .lock_mask = PLL_BASE_LOCK, |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 384 | .lock_enable_bit_idx = PLLDU_MISC_LOCK_ENABLE, |
| 385 | .lock_delay = 1000, |
Peter De Schrijver | 0b6525a | 2013-04-03 17:40:39 +0300 | [diff] [blame] | 386 | .pdiv_tohw = pllu_p, |
Peter De Schrijver | ebe142b | 2013-10-04 17:28:34 +0300 | [diff] [blame] | 387 | .freq_table = pll_u_freq_table, |
Rhyland Klein | 3706b43 | 2015-06-18 17:28:23 -0400 | [diff] [blame] | 388 | .flags = TEGRA_PLLU | TEGRA_PLL_HAS_CPCON | TEGRA_PLL_HAS_LOCK_ENABLE, |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 389 | }; |
| 390 | |
| 391 | static struct tegra_clk_pll_params pll_x_params = { |
| 392 | .input_min = 2000000, |
| 393 | .input_max = 31000000, |
| 394 | .cf_min = 1000000, |
| 395 | .cf_max = 6000000, |
| 396 | .vco_min = 20000000, |
| 397 | .vco_max = 1200000000, |
| 398 | .base_reg = PLLX_BASE, |
| 399 | .misc_reg = PLLX_MISC, |
Peter De Schrijver | 3e72771 | 2013-04-03 17:40:40 +0300 | [diff] [blame] | 400 | .lock_mask = PLL_BASE_LOCK, |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 401 | .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE, |
| 402 | .lock_delay = 300, |
Peter De Schrijver | ebe142b | 2013-10-04 17:28:34 +0300 | [diff] [blame] | 403 | .freq_table = pll_x_freq_table, |
Rhyland Klein | 3706b43 | 2015-06-18 17:28:23 -0400 | [diff] [blame] | 404 | .flags = TEGRA_PLL_HAS_CPCON | TEGRA_PLL_HAS_LOCK_ENABLE, |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 405 | }; |
| 406 | |
| 407 | static struct tegra_clk_pll_params pll_e_params = { |
| 408 | .input_min = 12000000, |
| 409 | .input_max = 12000000, |
| 410 | .cf_min = 0, |
| 411 | .cf_max = 0, |
| 412 | .vco_min = 0, |
| 413 | .vco_max = 0, |
| 414 | .base_reg = PLLE_BASE, |
| 415 | .misc_reg = PLLE_MISC, |
Peter De Schrijver | 3e72771 | 2013-04-03 17:40:40 +0300 | [diff] [blame] | 416 | .lock_mask = PLLE_MISC_LOCK, |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 417 | .lock_enable_bit_idx = PLLE_MISC_LOCK_ENABLE, |
| 418 | .lock_delay = 0, |
Rhyland Klein | 86c679a | 2015-06-18 17:28:34 -0400 | [diff] [blame] | 419 | .pdiv_tohw = plle_p, |
Peter De Schrijver | ebe142b | 2013-10-04 17:28:34 +0300 | [diff] [blame] | 420 | .freq_table = pll_e_freq_table, |
Rhyland Klein | 3706b43 | 2015-06-18 17:28:23 -0400 | [diff] [blame] | 421 | .flags = TEGRA_PLL_FIXED | TEGRA_PLL_LOCK_MISC | |
| 422 | TEGRA_PLL_HAS_LOCK_ENABLE, |
Peter De Schrijver | ebe142b | 2013-10-04 17:28:34 +0300 | [diff] [blame] | 423 | .fixed_rate = 100000000, |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 424 | }; |
| 425 | |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 426 | static struct tegra_devclk devclks[] __initdata = { |
| 427 | { .con_id = "pll_c", .dt_id = TEGRA20_CLK_PLL_C }, |
| 428 | { .con_id = "pll_c_out1", .dt_id = TEGRA20_CLK_PLL_C_OUT1 }, |
| 429 | { .con_id = "pll_p", .dt_id = TEGRA20_CLK_PLL_P }, |
| 430 | { .con_id = "pll_p_out1", .dt_id = TEGRA20_CLK_PLL_P_OUT1 }, |
| 431 | { .con_id = "pll_p_out2", .dt_id = TEGRA20_CLK_PLL_P_OUT2 }, |
| 432 | { .con_id = "pll_p_out3", .dt_id = TEGRA20_CLK_PLL_P_OUT3 }, |
| 433 | { .con_id = "pll_p_out4", .dt_id = TEGRA20_CLK_PLL_P_OUT4 }, |
| 434 | { .con_id = "pll_m", .dt_id = TEGRA20_CLK_PLL_M }, |
| 435 | { .con_id = "pll_m_out1", .dt_id = TEGRA20_CLK_PLL_M_OUT1 }, |
| 436 | { .con_id = "pll_x", .dt_id = TEGRA20_CLK_PLL_X }, |
| 437 | { .con_id = "pll_u", .dt_id = TEGRA20_CLK_PLL_U }, |
| 438 | { .con_id = "pll_d", .dt_id = TEGRA20_CLK_PLL_D }, |
| 439 | { .con_id = "pll_d_out0", .dt_id = TEGRA20_CLK_PLL_D_OUT0 }, |
| 440 | { .con_id = "pll_a", .dt_id = TEGRA20_CLK_PLL_A }, |
| 441 | { .con_id = "pll_a_out0", .dt_id = TEGRA20_CLK_PLL_A_OUT0 }, |
| 442 | { .con_id = "pll_e", .dt_id = TEGRA20_CLK_PLL_E }, |
| 443 | { .con_id = "cclk", .dt_id = TEGRA20_CLK_CCLK }, |
| 444 | { .con_id = "sclk", .dt_id = TEGRA20_CLK_SCLK }, |
| 445 | { .con_id = "hclk", .dt_id = TEGRA20_CLK_HCLK }, |
| 446 | { .con_id = "pclk", .dt_id = TEGRA20_CLK_PCLK }, |
Alexandre Courbot | 5ab5d40 | 2013-11-21 03:38:10 +0100 | [diff] [blame] | 447 | { .con_id = "fuse", .dt_id = TEGRA20_CLK_FUSE }, |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 448 | { .con_id = "twd", .dt_id = TEGRA20_CLK_TWD }, |
| 449 | { .con_id = "audio", .dt_id = TEGRA20_CLK_AUDIO }, |
| 450 | { .con_id = "audio_2x", .dt_id = TEGRA20_CLK_AUDIO_2X }, |
| 451 | { .dev_id = "tegra20-ac97", .dt_id = TEGRA20_CLK_AC97 }, |
| 452 | { .dev_id = "tegra-apbdma", .dt_id = TEGRA20_CLK_APBDMA }, |
| 453 | { .dev_id = "rtc-tegra", .dt_id = TEGRA20_CLK_RTC }, |
| 454 | { .dev_id = "timer", .dt_id = TEGRA20_CLK_TIMER }, |
| 455 | { .dev_id = "tegra-kbc", .dt_id = TEGRA20_CLK_KBC }, |
| 456 | { .con_id = "csus", .dev_id = "tegra_camera", .dt_id = TEGRA20_CLK_CSUS }, |
| 457 | { .con_id = "vcp", .dev_id = "tegra-avp", .dt_id = TEGRA20_CLK_VCP }, |
| 458 | { .con_id = "bsea", .dev_id = "tegra-avp", .dt_id = TEGRA20_CLK_BSEA }, |
| 459 | { .con_id = "bsev", .dev_id = "tegra-aes", .dt_id = TEGRA20_CLK_BSEV }, |
| 460 | { .con_id = "emc", .dt_id = TEGRA20_CLK_EMC }, |
| 461 | { .dev_id = "fsl-tegra-udc", .dt_id = TEGRA20_CLK_USBD }, |
| 462 | { .dev_id = "tegra-ehci.1", .dt_id = TEGRA20_CLK_USB2 }, |
| 463 | { .dev_id = "tegra-ehci.2", .dt_id = TEGRA20_CLK_USB3 }, |
| 464 | { .dev_id = "dsi", .dt_id = TEGRA20_CLK_DSI }, |
| 465 | { .con_id = "csi", .dev_id = "tegra_camera", .dt_id = TEGRA20_CLK_CSI }, |
| 466 | { .con_id = "isp", .dev_id = "tegra_camera", .dt_id = TEGRA20_CLK_ISP }, |
| 467 | { .con_id = "pex", .dt_id = TEGRA20_CLK_PEX }, |
| 468 | { .con_id = "afi", .dt_id = TEGRA20_CLK_AFI }, |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 469 | { .con_id = "cdev1", .dt_id = TEGRA20_CLK_CDEV1 }, |
| 470 | { .con_id = "cdev2", .dt_id = TEGRA20_CLK_CDEV2 }, |
| 471 | { .con_id = "clk_32k", .dt_id = TEGRA20_CLK_CLK_32K }, |
| 472 | { .con_id = "blink", .dt_id = TEGRA20_CLK_BLINK }, |
| 473 | { .con_id = "clk_m", .dt_id = TEGRA20_CLK_CLK_M }, |
| 474 | { .con_id = "pll_ref", .dt_id = TEGRA20_CLK_PLL_REF }, |
| 475 | { .dev_id = "tegra20-i2s.0", .dt_id = TEGRA20_CLK_I2S1 }, |
| 476 | { .dev_id = "tegra20-i2s.1", .dt_id = TEGRA20_CLK_I2S2 }, |
| 477 | { .con_id = "spdif_out", .dev_id = "tegra20-spdif", .dt_id = TEGRA20_CLK_SPDIF_OUT }, |
| 478 | { .con_id = "spdif_in", .dev_id = "tegra20-spdif", .dt_id = TEGRA20_CLK_SPDIF_IN }, |
| 479 | { .dev_id = "spi_tegra.0", .dt_id = TEGRA20_CLK_SBC1 }, |
| 480 | { .dev_id = "spi_tegra.1", .dt_id = TEGRA20_CLK_SBC2 }, |
| 481 | { .dev_id = "spi_tegra.2", .dt_id = TEGRA20_CLK_SBC3 }, |
| 482 | { .dev_id = "spi_tegra.3", .dt_id = TEGRA20_CLK_SBC4 }, |
| 483 | { .dev_id = "spi", .dt_id = TEGRA20_CLK_SPI }, |
| 484 | { .dev_id = "xio", .dt_id = TEGRA20_CLK_XIO }, |
| 485 | { .dev_id = "twc", .dt_id = TEGRA20_CLK_TWC }, |
| 486 | { .dev_id = "ide", .dt_id = TEGRA20_CLK_IDE }, |
| 487 | { .dev_id = "tegra_nand", .dt_id = TEGRA20_CLK_NDFLASH }, |
| 488 | { .dev_id = "vfir", .dt_id = TEGRA20_CLK_VFIR }, |
| 489 | { .dev_id = "csite", .dt_id = TEGRA20_CLK_CSITE }, |
| 490 | { .dev_id = "la", .dt_id = TEGRA20_CLK_LA }, |
| 491 | { .dev_id = "tegra_w1", .dt_id = TEGRA20_CLK_OWR }, |
| 492 | { .dev_id = "mipi", .dt_id = TEGRA20_CLK_MIPI }, |
| 493 | { .dev_id = "vde", .dt_id = TEGRA20_CLK_VDE }, |
| 494 | { .con_id = "vi", .dev_id = "tegra_camera", .dt_id = TEGRA20_CLK_VI }, |
| 495 | { .dev_id = "epp", .dt_id = TEGRA20_CLK_EPP }, |
| 496 | { .dev_id = "mpe", .dt_id = TEGRA20_CLK_MPE }, |
| 497 | { .dev_id = "host1x", .dt_id = TEGRA20_CLK_HOST1X }, |
| 498 | { .dev_id = "3d", .dt_id = TEGRA20_CLK_GR3D }, |
| 499 | { .dev_id = "2d", .dt_id = TEGRA20_CLK_GR2D }, |
| 500 | { .dev_id = "tegra-nor", .dt_id = TEGRA20_CLK_NOR }, |
| 501 | { .dev_id = "sdhci-tegra.0", .dt_id = TEGRA20_CLK_SDMMC1 }, |
| 502 | { .dev_id = "sdhci-tegra.1", .dt_id = TEGRA20_CLK_SDMMC2 }, |
| 503 | { .dev_id = "sdhci-tegra.2", .dt_id = TEGRA20_CLK_SDMMC3 }, |
| 504 | { .dev_id = "sdhci-tegra.3", .dt_id = TEGRA20_CLK_SDMMC4 }, |
| 505 | { .dev_id = "cve", .dt_id = TEGRA20_CLK_CVE }, |
| 506 | { .dev_id = "tvo", .dt_id = TEGRA20_CLK_TVO }, |
| 507 | { .dev_id = "tvdac", .dt_id = TEGRA20_CLK_TVDAC }, |
| 508 | { .con_id = "vi_sensor", .dev_id = "tegra_camera", .dt_id = TEGRA20_CLK_VI_SENSOR }, |
| 509 | { .dev_id = "hdmi", .dt_id = TEGRA20_CLK_HDMI }, |
| 510 | { .con_id = "div-clk", .dev_id = "tegra-i2c.0", .dt_id = TEGRA20_CLK_I2C1 }, |
| 511 | { .con_id = "div-clk", .dev_id = "tegra-i2c.1", .dt_id = TEGRA20_CLK_I2C2 }, |
| 512 | { .con_id = "div-clk", .dev_id = "tegra-i2c.2", .dt_id = TEGRA20_CLK_I2C3 }, |
| 513 | { .con_id = "div-clk", .dev_id = "tegra-i2c.3", .dt_id = TEGRA20_CLK_DVC }, |
| 514 | { .dev_id = "tegra-pwm", .dt_id = TEGRA20_CLK_PWM }, |
| 515 | { .dev_id = "tegra_uart.0", .dt_id = TEGRA20_CLK_UARTA }, |
| 516 | { .dev_id = "tegra_uart.1", .dt_id = TEGRA20_CLK_UARTB }, |
| 517 | { .dev_id = "tegra_uart.2", .dt_id = TEGRA20_CLK_UARTC }, |
| 518 | { .dev_id = "tegra_uart.3", .dt_id = TEGRA20_CLK_UARTD }, |
| 519 | { .dev_id = "tegra_uart.4", .dt_id = TEGRA20_CLK_UARTE }, |
| 520 | { .dev_id = "tegradc.0", .dt_id = TEGRA20_CLK_DISP1 }, |
| 521 | { .dev_id = "tegradc.1", .dt_id = TEGRA20_CLK_DISP2 }, |
| 522 | }; |
| 523 | |
| 524 | static struct tegra_clk tegra20_clks[tegra_clk_max] __initdata = { |
Dmitry Osipenko | 899f809 | 2017-10-04 02:02:38 +0300 | [diff] [blame] | 525 | [tegra_clk_ahbdma] = { .dt_id = TEGRA20_CLK_AHBDMA, .present = true }, |
Dmitry Osipenko | 5a6b184 | 2017-10-04 02:02:40 +0300 | [diff] [blame] | 526 | [tegra_clk_apbdma] = { .dt_id = TEGRA20_CLK_APBDMA, .present = true }, |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 527 | [tegra_clk_spdif_out] = { .dt_id = TEGRA20_CLK_SPDIF_OUT, .present = true }, |
| 528 | [tegra_clk_spdif_in] = { .dt_id = TEGRA20_CLK_SPDIF_IN, .present = true }, |
| 529 | [tegra_clk_sdmmc1] = { .dt_id = TEGRA20_CLK_SDMMC1, .present = true }, |
| 530 | [tegra_clk_sdmmc2] = { .dt_id = TEGRA20_CLK_SDMMC2, .present = true }, |
| 531 | [tegra_clk_sdmmc3] = { .dt_id = TEGRA20_CLK_SDMMC3, .present = true }, |
| 532 | [tegra_clk_sdmmc4] = { .dt_id = TEGRA20_CLK_SDMMC4, .present = true }, |
| 533 | [tegra_clk_la] = { .dt_id = TEGRA20_CLK_LA, .present = true }, |
| 534 | [tegra_clk_csite] = { .dt_id = TEGRA20_CLK_CSITE, .present = true }, |
| 535 | [tegra_clk_vfir] = { .dt_id = TEGRA20_CLK_VFIR, .present = true }, |
| 536 | [tegra_clk_mipi] = { .dt_id = TEGRA20_CLK_MIPI, .present = true }, |
| 537 | [tegra_clk_nor] = { .dt_id = TEGRA20_CLK_NOR, .present = true }, |
| 538 | [tegra_clk_rtc] = { .dt_id = TEGRA20_CLK_RTC, .present = true }, |
| 539 | [tegra_clk_timer] = { .dt_id = TEGRA20_CLK_TIMER, .present = true }, |
| 540 | [tegra_clk_kbc] = { .dt_id = TEGRA20_CLK_KBC, .present = true }, |
| 541 | [tegra_clk_csus] = { .dt_id = TEGRA20_CLK_CSUS, .present = true }, |
| 542 | [tegra_clk_vcp] = { .dt_id = TEGRA20_CLK_VCP, .present = true }, |
| 543 | [tegra_clk_bsea] = { .dt_id = TEGRA20_CLK_BSEA, .present = true }, |
| 544 | [tegra_clk_bsev] = { .dt_id = TEGRA20_CLK_BSEV, .present = true }, |
| 545 | [tegra_clk_usbd] = { .dt_id = TEGRA20_CLK_USBD, .present = true }, |
| 546 | [tegra_clk_usb2] = { .dt_id = TEGRA20_CLK_USB2, .present = true }, |
| 547 | [tegra_clk_usb3] = { .dt_id = TEGRA20_CLK_USB3, .present = true }, |
| 548 | [tegra_clk_csi] = { .dt_id = TEGRA20_CLK_CSI, .present = true }, |
| 549 | [tegra_clk_isp] = { .dt_id = TEGRA20_CLK_ISP, .present = true }, |
| 550 | [tegra_clk_clk_32k] = { .dt_id = TEGRA20_CLK_CLK_32K, .present = true }, |
| 551 | [tegra_clk_blink] = { .dt_id = TEGRA20_CLK_BLINK, .present = true }, |
| 552 | [tegra_clk_hclk] = { .dt_id = TEGRA20_CLK_HCLK, .present = true }, |
| 553 | [tegra_clk_pclk] = { .dt_id = TEGRA20_CLK_PCLK, .present = true }, |
| 554 | [tegra_clk_pll_p_out1] = { .dt_id = TEGRA20_CLK_PLL_P_OUT1, .present = true }, |
| 555 | [tegra_clk_pll_p_out2] = { .dt_id = TEGRA20_CLK_PLL_P_OUT2, .present = true }, |
| 556 | [tegra_clk_pll_p_out3] = { .dt_id = TEGRA20_CLK_PLL_P_OUT3, .present = true }, |
| 557 | [tegra_clk_pll_p_out4] = { .dt_id = TEGRA20_CLK_PLL_P_OUT4, .present = true }, |
| 558 | [tegra_clk_pll_p] = { .dt_id = TEGRA20_CLK_PLL_P, .present = true }, |
| 559 | [tegra_clk_owr] = { .dt_id = TEGRA20_CLK_OWR, .present = true }, |
| 560 | [tegra_clk_sbc1] = { .dt_id = TEGRA20_CLK_SBC1, .present = true }, |
| 561 | [tegra_clk_sbc2] = { .dt_id = TEGRA20_CLK_SBC2, .present = true }, |
| 562 | [tegra_clk_sbc3] = { .dt_id = TEGRA20_CLK_SBC3, .present = true }, |
| 563 | [tegra_clk_sbc4] = { .dt_id = TEGRA20_CLK_SBC4, .present = true }, |
| 564 | [tegra_clk_vde] = { .dt_id = TEGRA20_CLK_VDE, .present = true }, |
| 565 | [tegra_clk_vi] = { .dt_id = TEGRA20_CLK_VI, .present = true }, |
| 566 | [tegra_clk_epp] = { .dt_id = TEGRA20_CLK_EPP, .present = true }, |
| 567 | [tegra_clk_mpe] = { .dt_id = TEGRA20_CLK_MPE, .present = true }, |
| 568 | [tegra_clk_host1x] = { .dt_id = TEGRA20_CLK_HOST1X, .present = true }, |
| 569 | [tegra_clk_gr2d] = { .dt_id = TEGRA20_CLK_GR2D, .present = true }, |
| 570 | [tegra_clk_gr3d] = { .dt_id = TEGRA20_CLK_GR3D, .present = true }, |
| 571 | [tegra_clk_ndflash] = { .dt_id = TEGRA20_CLK_NDFLASH, .present = true }, |
| 572 | [tegra_clk_cve] = { .dt_id = TEGRA20_CLK_CVE, .present = true }, |
| 573 | [tegra_clk_tvo] = { .dt_id = TEGRA20_CLK_TVO, .present = true }, |
| 574 | [tegra_clk_tvdac] = { .dt_id = TEGRA20_CLK_TVDAC, .present = true }, |
| 575 | [tegra_clk_vi_sensor] = { .dt_id = TEGRA20_CLK_VI_SENSOR, .present = true }, |
| 576 | [tegra_clk_afi] = { .dt_id = TEGRA20_CLK_AFI, .present = true }, |
Peter De Schrijver | cb6448a | 2013-12-19 16:18:20 +0200 | [diff] [blame] | 577 | [tegra_clk_fuse] = { .dt_id = TEGRA20_CLK_FUSE, .present = true }, |
| 578 | [tegra_clk_kfuse] = { .dt_id = TEGRA20_CLK_KFUSE, .present = true }, |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 579 | }; |
| 580 | |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 581 | static unsigned long tegra20_clk_measure_input_freq(void) |
| 582 | { |
| 583 | u32 osc_ctrl = readl_relaxed(clk_base + OSC_CTRL); |
| 584 | u32 auto_clk_control = osc_ctrl & OSC_CTRL_OSC_FREQ_MASK; |
| 585 | u32 pll_ref_div = osc_ctrl & OSC_CTRL_PLL_REF_DIV_MASK; |
| 586 | unsigned long input_freq; |
| 587 | |
| 588 | switch (auto_clk_control) { |
| 589 | case OSC_CTRL_OSC_FREQ_12MHZ: |
| 590 | BUG_ON(pll_ref_div != OSC_CTRL_PLL_REF_DIV_1); |
| 591 | input_freq = 12000000; |
| 592 | break; |
| 593 | case OSC_CTRL_OSC_FREQ_13MHZ: |
| 594 | BUG_ON(pll_ref_div != OSC_CTRL_PLL_REF_DIV_1); |
| 595 | input_freq = 13000000; |
| 596 | break; |
| 597 | case OSC_CTRL_OSC_FREQ_19_2MHZ: |
| 598 | BUG_ON(pll_ref_div != OSC_CTRL_PLL_REF_DIV_1); |
| 599 | input_freq = 19200000; |
| 600 | break; |
| 601 | case OSC_CTRL_OSC_FREQ_26MHZ: |
| 602 | BUG_ON(pll_ref_div != OSC_CTRL_PLL_REF_DIV_1); |
| 603 | input_freq = 26000000; |
| 604 | break; |
| 605 | default: |
| 606 | pr_err("Unexpected clock autodetect value %d", |
| 607 | auto_clk_control); |
| 608 | BUG(); |
| 609 | return 0; |
| 610 | } |
| 611 | |
| 612 | return input_freq; |
| 613 | } |
| 614 | |
| 615 | static unsigned int tegra20_get_pll_ref_div(void) |
| 616 | { |
| 617 | u32 pll_ref_div = readl_relaxed(clk_base + OSC_CTRL) & |
| 618 | OSC_CTRL_PLL_REF_DIV_MASK; |
| 619 | |
| 620 | switch (pll_ref_div) { |
| 621 | case OSC_CTRL_PLL_REF_DIV_1: |
| 622 | return 1; |
| 623 | case OSC_CTRL_PLL_REF_DIV_2: |
| 624 | return 2; |
| 625 | case OSC_CTRL_PLL_REF_DIV_4: |
| 626 | return 4; |
| 627 | default: |
Masanari Iida | c01e015 | 2016-04-20 00:27:33 +0900 | [diff] [blame] | 628 | pr_err("Invalid pll ref divider %d\n", pll_ref_div); |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 629 | BUG(); |
| 630 | } |
| 631 | return 0; |
| 632 | } |
| 633 | |
| 634 | static void tegra20_pll_init(void) |
| 635 | { |
| 636 | struct clk *clk; |
| 637 | |
| 638 | /* PLLC */ |
| 639 | clk = tegra_clk_register_pll("pll_c", "pll_ref", clk_base, NULL, 0, |
Peter De Schrijver | ebe142b | 2013-10-04 17:28:34 +0300 | [diff] [blame] | 640 | &pll_c_params, NULL); |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 641 | clks[TEGRA20_CLK_PLL_C] = clk; |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 642 | |
| 643 | /* PLLC_OUT1 */ |
| 644 | clk = tegra_clk_register_divider("pll_c_out1_div", "pll_c", |
| 645 | clk_base + PLLC_OUT, 0, TEGRA_DIVIDER_ROUND_UP, |
| 646 | 8, 8, 1, NULL); |
| 647 | clk = tegra_clk_register_pll_out("pll_c_out1", "pll_c_out1_div", |
| 648 | clk_base + PLLC_OUT, 1, 0, CLK_SET_RATE_PARENT, |
| 649 | 0, NULL); |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 650 | clks[TEGRA20_CLK_PLL_C_OUT1] = clk; |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 651 | |
| 652 | /* PLLM */ |
| 653 | clk = tegra_clk_register_pll("pll_m", "pll_ref", clk_base, NULL, |
Peter De Schrijver | ebe142b | 2013-10-04 17:28:34 +0300 | [diff] [blame] | 654 | CLK_IGNORE_UNUSED | CLK_SET_RATE_GATE, |
| 655 | &pll_m_params, NULL); |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 656 | clks[TEGRA20_CLK_PLL_M] = clk; |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 657 | |
| 658 | /* PLLM_OUT1 */ |
| 659 | clk = tegra_clk_register_divider("pll_m_out1_div", "pll_m", |
| 660 | clk_base + PLLM_OUT, 0, TEGRA_DIVIDER_ROUND_UP, |
| 661 | 8, 8, 1, NULL); |
| 662 | clk = tegra_clk_register_pll_out("pll_m_out1", "pll_m_out1_div", |
| 663 | clk_base + PLLM_OUT, 1, 0, CLK_IGNORE_UNUSED | |
| 664 | CLK_SET_RATE_PARENT, 0, NULL); |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 665 | clks[TEGRA20_CLK_PLL_M_OUT1] = clk; |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 666 | |
| 667 | /* PLLX */ |
| 668 | clk = tegra_clk_register_pll("pll_x", "pll_ref", clk_base, NULL, 0, |
Peter De Schrijver | ebe142b | 2013-10-04 17:28:34 +0300 | [diff] [blame] | 669 | &pll_x_params, NULL); |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 670 | clks[TEGRA20_CLK_PLL_X] = clk; |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 671 | |
| 672 | /* PLLU */ |
| 673 | clk = tegra_clk_register_pll("pll_u", "pll_ref", clk_base, NULL, 0, |
Peter De Schrijver | ebe142b | 2013-10-04 17:28:34 +0300 | [diff] [blame] | 674 | &pll_u_params, NULL); |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 675 | clks[TEGRA20_CLK_PLL_U] = clk; |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 676 | |
| 677 | /* PLLD */ |
| 678 | clk = tegra_clk_register_pll("pll_d", "pll_ref", clk_base, NULL, 0, |
Peter De Schrijver | ebe142b | 2013-10-04 17:28:34 +0300 | [diff] [blame] | 679 | &pll_d_params, NULL); |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 680 | clks[TEGRA20_CLK_PLL_D] = clk; |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 681 | |
| 682 | /* PLLD_OUT0 */ |
| 683 | clk = clk_register_fixed_factor(NULL, "pll_d_out0", "pll_d", |
| 684 | CLK_SET_RATE_PARENT, 1, 2); |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 685 | clks[TEGRA20_CLK_PLL_D_OUT0] = clk; |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 686 | |
| 687 | /* PLLA */ |
| 688 | clk = tegra_clk_register_pll("pll_a", "pll_p_out1", clk_base, NULL, 0, |
Peter De Schrijver | ebe142b | 2013-10-04 17:28:34 +0300 | [diff] [blame] | 689 | &pll_a_params, NULL); |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 690 | clks[TEGRA20_CLK_PLL_A] = clk; |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 691 | |
| 692 | /* PLLA_OUT0 */ |
| 693 | clk = tegra_clk_register_divider("pll_a_out0_div", "pll_a", |
| 694 | clk_base + PLLA_OUT, 0, TEGRA_DIVIDER_ROUND_UP, |
| 695 | 8, 8, 1, NULL); |
| 696 | clk = tegra_clk_register_pll_out("pll_a_out0", "pll_a_out0_div", |
| 697 | clk_base + PLLA_OUT, 1, 0, CLK_IGNORE_UNUSED | |
| 698 | CLK_SET_RATE_PARENT, 0, NULL); |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 699 | clks[TEGRA20_CLK_PLL_A_OUT0] = clk; |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 700 | |
| 701 | /* PLLE */ |
Thierry Reding | 0f1bc12 | 2013-03-14 16:27:05 +0100 | [diff] [blame] | 702 | clk = tegra_clk_register_plle("pll_e", "pll_ref", clk_base, pmc_base, |
Peter De Schrijver | ebe142b | 2013-10-04 17:28:34 +0300 | [diff] [blame] | 703 | 0, &pll_e_params, NULL); |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 704 | clks[TEGRA20_CLK_PLL_E] = clk; |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 705 | } |
| 706 | |
| 707 | static const char *cclk_parents[] = { "clk_m", "pll_c", "clk_32k", "pll_m", |
Peter De Schrijver | bf161d2 | 2013-02-08 14:44:09 +0200 | [diff] [blame] | 708 | "pll_p", "pll_p_out4", |
| 709 | "pll_p_out3", "clk_d", "pll_x" }; |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 710 | static const char *sclk_parents[] = { "clk_m", "pll_c_out1", "pll_p_out4", |
| 711 | "pll_p_out3", "pll_p_out2", "clk_d", |
| 712 | "clk_32k", "pll_m_out1" }; |
| 713 | |
| 714 | static void tegra20_super_clk_init(void) |
| 715 | { |
| 716 | struct clk *clk; |
| 717 | |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 718 | /* CCLK */ |
| 719 | clk = tegra_clk_register_super_mux("cclk", cclk_parents, |
| 720 | ARRAY_SIZE(cclk_parents), CLK_SET_RATE_PARENT, |
| 721 | clk_base + CCLK_BURST_POLICY, 0, 4, 0, 0, NULL); |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 722 | clks[TEGRA20_CLK_CCLK] = clk; |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 723 | |
| 724 | /* SCLK */ |
| 725 | clk = tegra_clk_register_super_mux("sclk", sclk_parents, |
| 726 | ARRAY_SIZE(sclk_parents), CLK_SET_RATE_PARENT, |
| 727 | clk_base + SCLK_BURST_POLICY, 0, 4, 0, 0, NULL); |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 728 | clks[TEGRA20_CLK_SCLK] = clk; |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 729 | |
| 730 | /* twd */ |
| 731 | clk = clk_register_fixed_factor(NULL, "twd", "cclk", 0, 1, 4); |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 732 | clks[TEGRA20_CLK_TWD] = clk; |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 733 | } |
| 734 | |
Thierry Reding | 8d99704 | 2015-11-18 14:10:02 +0100 | [diff] [blame] | 735 | static const char *audio_parents[] = { "spdif_in", "i2s1", "i2s2", "unused", |
| 736 | "pll_a_out0", "unused", "unused", |
| 737 | "unused" }; |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 738 | |
| 739 | static void __init tegra20_audio_clk_init(void) |
| 740 | { |
| 741 | struct clk *clk; |
| 742 | |
| 743 | /* audio */ |
| 744 | clk = clk_register_mux(NULL, "audio_mux", audio_parents, |
James Hogan | 819c1de | 2013-07-29 12:25:01 +0100 | [diff] [blame] | 745 | ARRAY_SIZE(audio_parents), |
| 746 | CLK_SET_RATE_NO_REPARENT, |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 747 | clk_base + AUDIO_SYNC_CLK, 0, 3, 0, NULL); |
| 748 | clk = clk_register_gate(NULL, "audio", "audio_mux", 0, |
| 749 | clk_base + AUDIO_SYNC_CLK, 4, |
| 750 | CLK_GATE_SET_TO_DISABLE, NULL); |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 751 | clks[TEGRA20_CLK_AUDIO] = clk; |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 752 | |
| 753 | /* audio_2x */ |
| 754 | clk = clk_register_fixed_factor(NULL, "audio_doubler", "audio", |
| 755 | CLK_SET_RATE_PARENT, 2, 1); |
| 756 | clk = tegra_clk_register_periph_gate("audio_2x", "audio_doubler", |
| 757 | TEGRA_PERIPH_NO_RESET, clk_base, |
Peter De Schrijver | d5ff89a | 2013-08-22 18:44:06 +0300 | [diff] [blame] | 758 | CLK_SET_RATE_PARENT, 89, |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 759 | periph_clk_enb_refcnt); |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 760 | clks[TEGRA20_CLK_AUDIO_2X] = clk; |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 761 | } |
| 762 | |
Thierry Reding | 8d99704 | 2015-11-18 14:10:02 +0100 | [diff] [blame] | 763 | static const char *i2s1_parents[] = { "pll_a_out0", "audio_2x", "pll_p", |
| 764 | "clk_m" }; |
| 765 | static const char *i2s2_parents[] = { "pll_a_out0", "audio_2x", "pll_p", |
| 766 | "clk_m" }; |
| 767 | static const char *pwm_parents[] = { "pll_p", "pll_c", "audio", "clk_m", |
| 768 | "clk_32k" }; |
| 769 | static const char *mux_pllpcm_clkm[] = { "pll_p", "pll_c", "pll_m", "clk_m" }; |
| 770 | static const char *mux_pllpdc_clkm[] = { "pll_p", "pll_d_out0", "pll_c", |
| 771 | "clk_m" }; |
| 772 | static const char *mux_pllmcp_clkm[] = { "pll_m", "pll_c", "pll_p", "clk_m" }; |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 773 | |
| 774 | static struct tegra_periph_init_data tegra_periph_clk_list[] = { |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 775 | TEGRA_INIT_DATA_MUX("i2s1", i2s1_parents, CLK_SOURCE_I2S1, 11, TEGRA_PERIPH_ON_APB, TEGRA20_CLK_I2S1), |
| 776 | TEGRA_INIT_DATA_MUX("i2s2", i2s2_parents, CLK_SOURCE_I2S2, 18, TEGRA_PERIPH_ON_APB, TEGRA20_CLK_I2S2), |
| 777 | TEGRA_INIT_DATA_MUX("spi", mux_pllpcm_clkm, CLK_SOURCE_SPI, 43, TEGRA_PERIPH_ON_APB, TEGRA20_CLK_SPI), |
| 778 | TEGRA_INIT_DATA_MUX("xio", mux_pllpcm_clkm, CLK_SOURCE_XIO, 45, 0, TEGRA20_CLK_XIO), |
| 779 | TEGRA_INIT_DATA_MUX("twc", mux_pllpcm_clkm, CLK_SOURCE_TWC, 16, TEGRA_PERIPH_ON_APB, TEGRA20_CLK_TWC), |
| 780 | TEGRA_INIT_DATA_MUX("ide", mux_pllpcm_clkm, CLK_SOURCE_XIO, 25, 0, TEGRA20_CLK_IDE), |
| 781 | TEGRA_INIT_DATA_DIV16("dvc", mux_pllpcm_clkm, CLK_SOURCE_DVC, 47, TEGRA_PERIPH_ON_APB, TEGRA20_CLK_DVC), |
| 782 | TEGRA_INIT_DATA_DIV16("i2c1", mux_pllpcm_clkm, CLK_SOURCE_I2C1, 12, TEGRA_PERIPH_ON_APB, TEGRA20_CLK_I2C1), |
| 783 | TEGRA_INIT_DATA_DIV16("i2c2", mux_pllpcm_clkm, CLK_SOURCE_I2C2, 54, TEGRA_PERIPH_ON_APB, TEGRA20_CLK_I2C2), |
| 784 | TEGRA_INIT_DATA_DIV16("i2c3", mux_pllpcm_clkm, CLK_SOURCE_I2C3, 67, TEGRA_PERIPH_ON_APB, TEGRA20_CLK_I2C3), |
| 785 | TEGRA_INIT_DATA_MUX("hdmi", mux_pllpdc_clkm, CLK_SOURCE_HDMI, 51, 0, TEGRA20_CLK_HDMI), |
| 786 | TEGRA_INIT_DATA("pwm", NULL, NULL, pwm_parents, CLK_SOURCE_PWM, 28, 3, 0, 0, 8, 1, 0, 17, TEGRA_PERIPH_ON_APB, TEGRA20_CLK_PWM), |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 787 | }; |
| 788 | |
| 789 | static struct tegra_periph_init_data tegra_periph_nodiv_clk_list[] = { |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 790 | TEGRA_INIT_DATA_NODIV("uarta", mux_pllpcm_clkm, CLK_SOURCE_UARTA, 30, 2, 6, TEGRA_PERIPH_ON_APB, TEGRA20_CLK_UARTA), |
| 791 | TEGRA_INIT_DATA_NODIV("uartb", mux_pllpcm_clkm, CLK_SOURCE_UARTB, 30, 2, 7, TEGRA_PERIPH_ON_APB, TEGRA20_CLK_UARTB), |
| 792 | TEGRA_INIT_DATA_NODIV("uartc", mux_pllpcm_clkm, CLK_SOURCE_UARTC, 30, 2, 55, TEGRA_PERIPH_ON_APB, TEGRA20_CLK_UARTC), |
| 793 | TEGRA_INIT_DATA_NODIV("uartd", mux_pllpcm_clkm, CLK_SOURCE_UARTD, 30, 2, 65, TEGRA_PERIPH_ON_APB, TEGRA20_CLK_UARTD), |
| 794 | TEGRA_INIT_DATA_NODIV("uarte", mux_pllpcm_clkm, CLK_SOURCE_UARTE, 30, 2, 66, TEGRA_PERIPH_ON_APB, TEGRA20_CLK_UARTE), |
| 795 | TEGRA_INIT_DATA_NODIV("disp1", mux_pllpdc_clkm, CLK_SOURCE_DISP1, 30, 2, 27, 0, TEGRA20_CLK_DISP1), |
| 796 | TEGRA_INIT_DATA_NODIV("disp2", mux_pllpdc_clkm, CLK_SOURCE_DISP2, 30, 2, 26, 0, TEGRA20_CLK_DISP2), |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 797 | }; |
| 798 | |
| 799 | static void __init tegra20_periph_clk_init(void) |
| 800 | { |
| 801 | struct tegra_periph_init_data *data; |
| 802 | struct clk *clk; |
Thierry Reding | e52d7c0 | 2015-11-18 14:04:20 +0100 | [diff] [blame] | 803 | unsigned int i; |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 804 | |
Lucas Stach | 6ec3240 | 2013-05-06 15:11:11 -0600 | [diff] [blame] | 805 | /* ac97 */ |
| 806 | clk = tegra_clk_register_periph_gate("ac97", "pll_a_out0", |
| 807 | TEGRA_PERIPH_ON_APB, |
Peter De Schrijver | d5ff89a | 2013-08-22 18:44:06 +0300 | [diff] [blame] | 808 | clk_base, 0, 3, periph_clk_enb_refcnt); |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 809 | clks[TEGRA20_CLK_AC97] = clk; |
Lucas Stach | 6ec3240 | 2013-05-06 15:11:11 -0600 | [diff] [blame] | 810 | |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 811 | /* emc */ |
| 812 | clk = clk_register_mux(NULL, "emc_mux", mux_pllmcp_clkm, |
James Hogan | 819c1de | 2013-07-29 12:25:01 +0100 | [diff] [blame] | 813 | ARRAY_SIZE(mux_pllmcp_clkm), |
| 814 | CLK_SET_RATE_NO_REPARENT, |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 815 | clk_base + CLK_SOURCE_EMC, |
Thierry Reding | 4f4f85f | 2014-07-29 10:17:53 +0200 | [diff] [blame] | 816 | 30, 2, 0, &emc_lock); |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 817 | clk = tegra_clk_register_periph_gate("emc", "emc_mux", 0, clk_base, 0, |
Peter De Schrijver | d5ff89a | 2013-08-22 18:44:06 +0300 | [diff] [blame] | 818 | 57, periph_clk_enb_refcnt); |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 819 | clks[TEGRA20_CLK_EMC] = clk; |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 820 | |
Thierry Reding | 4f4f85f | 2014-07-29 10:17:53 +0200 | [diff] [blame] | 821 | clk = tegra_clk_register_mc("mc", "emc_mux", clk_base + CLK_SOURCE_EMC, |
| 822 | &emc_lock); |
| 823 | clks[TEGRA20_CLK_MC] = clk; |
| 824 | |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 825 | /* dsi */ |
| 826 | clk = tegra_clk_register_periph_gate("dsi", "pll_d", 0, clk_base, 0, |
Peter De Schrijver | d5ff89a | 2013-08-22 18:44:06 +0300 | [diff] [blame] | 827 | 48, periph_clk_enb_refcnt); |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 828 | clk_register_clkdev(clk, NULL, "dsi"); |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 829 | clks[TEGRA20_CLK_DSI] = clk; |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 830 | |
| 831 | /* pex */ |
| 832 | clk = tegra_clk_register_periph_gate("pex", "clk_m", 0, clk_base, 0, 70, |
Peter De Schrijver | d5ff89a | 2013-08-22 18:44:06 +0300 | [diff] [blame] | 833 | periph_clk_enb_refcnt); |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 834 | clks[TEGRA20_CLK_PEX] = clk; |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 835 | |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 836 | /* cdev1 */ |
Stephen Boyd | f6da46a | 2016-03-01 11:00:02 -0800 | [diff] [blame] | 837 | clk = clk_register_fixed_rate(NULL, "cdev1_fixed", NULL, 0, 26000000); |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 838 | clk = tegra_clk_register_periph_gate("cdev1", "cdev1_fixed", 0, |
Peter De Schrijver | d5ff89a | 2013-08-22 18:44:06 +0300 | [diff] [blame] | 839 | clk_base, 0, 94, periph_clk_enb_refcnt); |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 840 | clks[TEGRA20_CLK_CDEV1] = clk; |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 841 | |
| 842 | /* cdev2 */ |
Stephen Boyd | f6da46a | 2016-03-01 11:00:02 -0800 | [diff] [blame] | 843 | clk = clk_register_fixed_rate(NULL, "cdev2_fixed", NULL, 0, 26000000); |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 844 | clk = tegra_clk_register_periph_gate("cdev2", "cdev2_fixed", 0, |
Peter De Schrijver | d5ff89a | 2013-08-22 18:44:06 +0300 | [diff] [blame] | 845 | clk_base, 0, 93, periph_clk_enb_refcnt); |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 846 | clks[TEGRA20_CLK_CDEV2] = clk; |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 847 | |
| 848 | for (i = 0; i < ARRAY_SIZE(tegra_periph_clk_list); i++) { |
| 849 | data = &tegra_periph_clk_list[i]; |
Thierry Reding | 1d7e2c8 | 2017-08-30 12:19:08 +0200 | [diff] [blame] | 850 | clk = tegra_clk_register_periph_data(clk_base, data); |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 851 | clks[data->clk_id] = clk; |
| 852 | } |
| 853 | |
| 854 | for (i = 0; i < ARRAY_SIZE(tegra_periph_nodiv_clk_list); i++) { |
| 855 | data = &tegra_periph_nodiv_clk_list[i]; |
| 856 | clk = tegra_clk_register_periph_nodiv(data->name, |
Peter De Schrijver | 76ebc13 | 2013-09-04 17:04:19 +0300 | [diff] [blame] | 857 | data->p.parent_names, |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 858 | data->num_parents, &data->periph, |
| 859 | clk_base, data->offset); |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 860 | clks[data->clk_id] = clk; |
| 861 | } |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 862 | |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 863 | tegra_periph_clk_init(clk_base, pmc_base, tegra20_clks, &pll_p_params); |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 864 | } |
| 865 | |
| 866 | static void __init tegra20_osc_clk_init(void) |
| 867 | { |
| 868 | struct clk *clk; |
| 869 | unsigned long input_freq; |
| 870 | unsigned int pll_ref_div; |
| 871 | |
| 872 | input_freq = tegra20_clk_measure_input_freq(); |
| 873 | |
| 874 | /* clk_m */ |
Stephen Boyd | f6da46a | 2016-03-01 11:00:02 -0800 | [diff] [blame] | 875 | clk = clk_register_fixed_rate(NULL, "clk_m", NULL, CLK_IGNORE_UNUSED, |
| 876 | input_freq); |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 877 | clks[TEGRA20_CLK_CLK_M] = clk; |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 878 | |
| 879 | /* pll_ref */ |
| 880 | pll_ref_div = tegra20_get_pll_ref_div(); |
| 881 | clk = clk_register_fixed_factor(NULL, "pll_ref", "clk_m", |
| 882 | CLK_SET_RATE_PARENT, 1, pll_ref_div); |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 883 | clks[TEGRA20_CLK_PLL_REF] = clk; |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 884 | } |
| 885 | |
| 886 | /* Tegra20 CPU clock and reset control functions */ |
| 887 | static void tegra20_wait_cpu_in_reset(u32 cpu) |
| 888 | { |
| 889 | unsigned int reg; |
| 890 | |
| 891 | do { |
| 892 | reg = readl(clk_base + |
| 893 | TEGRA_CLK_RST_CONTROLLER_RST_CPU_CMPLX_SET); |
| 894 | cpu_relax(); |
| 895 | } while (!(reg & (1 << cpu))); /* check CPU been reset or not */ |
| 896 | |
| 897 | return; |
| 898 | } |
| 899 | |
| 900 | static void tegra20_put_cpu_in_reset(u32 cpu) |
| 901 | { |
| 902 | writel(CPU_RESET(cpu), |
| 903 | clk_base + TEGRA_CLK_RST_CONTROLLER_RST_CPU_CMPLX_SET); |
| 904 | dmb(); |
| 905 | } |
| 906 | |
| 907 | static void tegra20_cpu_out_of_reset(u32 cpu) |
| 908 | { |
| 909 | writel(CPU_RESET(cpu), |
| 910 | clk_base + TEGRA_CLK_RST_CONTROLLER_RST_CPU_CMPLX_CLR); |
| 911 | wmb(); |
| 912 | } |
| 913 | |
| 914 | static void tegra20_enable_cpu_clock(u32 cpu) |
| 915 | { |
| 916 | unsigned int reg; |
| 917 | |
| 918 | reg = readl(clk_base + TEGRA_CLK_RST_CONTROLLER_CLK_CPU_CMPLX); |
| 919 | writel(reg & ~CPU_CLOCK(cpu), |
| 920 | clk_base + TEGRA_CLK_RST_CONTROLLER_CLK_CPU_CMPLX); |
| 921 | barrier(); |
| 922 | reg = readl(clk_base + TEGRA_CLK_RST_CONTROLLER_CLK_CPU_CMPLX); |
| 923 | } |
| 924 | |
| 925 | static void tegra20_disable_cpu_clock(u32 cpu) |
| 926 | { |
| 927 | unsigned int reg; |
| 928 | |
| 929 | reg = readl(clk_base + TEGRA_CLK_RST_CONTROLLER_CLK_CPU_CMPLX); |
| 930 | writel(reg | CPU_CLOCK(cpu), |
| 931 | clk_base + TEGRA_CLK_RST_CONTROLLER_CLK_CPU_CMPLX); |
| 932 | } |
| 933 | |
Joseph Lo | 4a2e327 | 2013-01-15 22:10:48 +0000 | [diff] [blame] | 934 | #ifdef CONFIG_PM_SLEEP |
| 935 | static bool tegra20_cpu_rail_off_ready(void) |
| 936 | { |
| 937 | unsigned int cpu_rst_status; |
| 938 | |
| 939 | cpu_rst_status = readl(clk_base + |
| 940 | TEGRA_CLK_RST_CONTROLLER_RST_CPU_CMPLX_SET); |
| 941 | |
| 942 | return !!(cpu_rst_status & 0x2); |
| 943 | } |
| 944 | |
| 945 | static void tegra20_cpu_clock_suspend(void) |
| 946 | { |
| 947 | /* switch coresite to clk_m, save off original source */ |
| 948 | tegra20_cpu_clk_sctx.clk_csite_src = |
| 949 | readl(clk_base + CLK_SOURCE_CSITE); |
| 950 | writel(3<<30, clk_base + CLK_SOURCE_CSITE); |
| 951 | |
| 952 | tegra20_cpu_clk_sctx.cpu_burst = |
| 953 | readl(clk_base + CCLK_BURST_POLICY); |
| 954 | tegra20_cpu_clk_sctx.pllx_base = |
| 955 | readl(clk_base + PLLX_BASE); |
| 956 | tegra20_cpu_clk_sctx.pllx_misc = |
| 957 | readl(clk_base + PLLX_MISC); |
| 958 | tegra20_cpu_clk_sctx.cclk_divider = |
| 959 | readl(clk_base + SUPER_CCLK_DIVIDER); |
| 960 | } |
| 961 | |
| 962 | static void tegra20_cpu_clock_resume(void) |
| 963 | { |
| 964 | unsigned int reg, policy; |
| 965 | |
| 966 | /* Is CPU complex already running on PLLX? */ |
| 967 | reg = readl(clk_base + CCLK_BURST_POLICY); |
| 968 | policy = (reg >> CCLK_BURST_POLICY_SHIFT) & 0xF; |
| 969 | |
| 970 | if (policy == CCLK_IDLE_POLICY) |
| 971 | reg = (reg >> CCLK_IDLE_POLICY_SHIFT) & 0xF; |
| 972 | else if (policy == CCLK_RUN_POLICY) |
| 973 | reg = (reg >> CCLK_RUN_POLICY_SHIFT) & 0xF; |
| 974 | else |
| 975 | BUG(); |
| 976 | |
| 977 | if (reg != CCLK_BURST_POLICY_PLLX) { |
| 978 | /* restore PLLX settings if CPU is on different PLL */ |
| 979 | writel(tegra20_cpu_clk_sctx.pllx_misc, |
| 980 | clk_base + PLLX_MISC); |
| 981 | writel(tegra20_cpu_clk_sctx.pllx_base, |
| 982 | clk_base + PLLX_BASE); |
| 983 | |
| 984 | /* wait for PLL stabilization if PLLX was enabled */ |
| 985 | if (tegra20_cpu_clk_sctx.pllx_base & (1 << 30)) |
| 986 | udelay(300); |
| 987 | } |
| 988 | |
| 989 | /* |
| 990 | * Restore original burst policy setting for calls resulting from CPU |
| 991 | * LP2 in idle or system suspend. |
| 992 | */ |
| 993 | writel(tegra20_cpu_clk_sctx.cclk_divider, |
| 994 | clk_base + SUPER_CCLK_DIVIDER); |
| 995 | writel(tegra20_cpu_clk_sctx.cpu_burst, |
| 996 | clk_base + CCLK_BURST_POLICY); |
| 997 | |
| 998 | writel(tegra20_cpu_clk_sctx.clk_csite_src, |
| 999 | clk_base + CLK_SOURCE_CSITE); |
| 1000 | } |
| 1001 | #endif |
| 1002 | |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 1003 | static struct tegra_cpu_car_ops tegra20_cpu_car_ops = { |
| 1004 | .wait_for_reset = tegra20_wait_cpu_in_reset, |
| 1005 | .put_in_reset = tegra20_put_cpu_in_reset, |
| 1006 | .out_of_reset = tegra20_cpu_out_of_reset, |
| 1007 | .enable_clock = tegra20_enable_cpu_clock, |
| 1008 | .disable_clock = tegra20_disable_cpu_clock, |
Joseph Lo | 4a2e327 | 2013-01-15 22:10:48 +0000 | [diff] [blame] | 1009 | #ifdef CONFIG_PM_SLEEP |
| 1010 | .rail_off_ready = tegra20_cpu_rail_off_ready, |
| 1011 | .suspend = tegra20_cpu_clock_suspend, |
| 1012 | .resume = tegra20_cpu_clock_resume, |
| 1013 | #endif |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 1014 | }; |
| 1015 | |
Sachin Kamat | a0be7a9 | 2013-08-08 09:55:48 +0530 | [diff] [blame] | 1016 | static struct tegra_clk_init_table init_table[] __initdata = { |
Thierry Reding | 8d99704 | 2015-11-18 14:10:02 +0100 | [diff] [blame] | 1017 | { TEGRA20_CLK_PLL_P, TEGRA20_CLK_CLK_MAX, 216000000, 1 }, |
| 1018 | { TEGRA20_CLK_PLL_P_OUT1, TEGRA20_CLK_CLK_MAX, 28800000, 1 }, |
| 1019 | { TEGRA20_CLK_PLL_P_OUT2, TEGRA20_CLK_CLK_MAX, 48000000, 1 }, |
| 1020 | { TEGRA20_CLK_PLL_P_OUT3, TEGRA20_CLK_CLK_MAX, 72000000, 1 }, |
| 1021 | { TEGRA20_CLK_PLL_P_OUT4, TEGRA20_CLK_CLK_MAX, 24000000, 1 }, |
| 1022 | { TEGRA20_CLK_PLL_C, TEGRA20_CLK_CLK_MAX, 600000000, 1 }, |
Dmitry Osipenko | d80a32f | 2017-10-04 02:02:41 +0300 | [diff] [blame] | 1023 | { TEGRA20_CLK_PLL_C_OUT1, TEGRA20_CLK_CLK_MAX, 216000000, 1 }, |
Thierry Reding | 8d99704 | 2015-11-18 14:10:02 +0100 | [diff] [blame] | 1024 | { TEGRA20_CLK_SCLK, TEGRA20_CLK_PLL_C_OUT1, 0, 1 }, |
| 1025 | { TEGRA20_CLK_HCLK, TEGRA20_CLK_CLK_MAX, 0, 1 }, |
| 1026 | { TEGRA20_CLK_PCLK, TEGRA20_CLK_CLK_MAX, 60000000, 1 }, |
| 1027 | { TEGRA20_CLK_CSITE, TEGRA20_CLK_CLK_MAX, 0, 1 }, |
| 1028 | { TEGRA20_CLK_EMC, TEGRA20_CLK_CLK_MAX, 0, 1 }, |
| 1029 | { TEGRA20_CLK_CCLK, TEGRA20_CLK_CLK_MAX, 0, 1 }, |
| 1030 | { TEGRA20_CLK_UARTA, TEGRA20_CLK_PLL_P, 0, 0 }, |
| 1031 | { TEGRA20_CLK_UARTB, TEGRA20_CLK_PLL_P, 0, 0 }, |
| 1032 | { TEGRA20_CLK_UARTC, TEGRA20_CLK_PLL_P, 0, 0 }, |
| 1033 | { TEGRA20_CLK_UARTD, TEGRA20_CLK_PLL_P, 0, 0 }, |
| 1034 | { TEGRA20_CLK_UARTE, TEGRA20_CLK_PLL_P, 0, 0 }, |
| 1035 | { TEGRA20_CLK_PLL_A, TEGRA20_CLK_CLK_MAX, 56448000, 1 }, |
| 1036 | { TEGRA20_CLK_PLL_A_OUT0, TEGRA20_CLK_CLK_MAX, 11289600, 1 }, |
| 1037 | { TEGRA20_CLK_CDEV1, TEGRA20_CLK_CLK_MAX, 0, 1 }, |
| 1038 | { TEGRA20_CLK_BLINK, TEGRA20_CLK_CLK_MAX, 32768, 1 }, |
| 1039 | { TEGRA20_CLK_I2S1, TEGRA20_CLK_PLL_A_OUT0, 11289600, 0 }, |
| 1040 | { TEGRA20_CLK_I2S2, TEGRA20_CLK_PLL_A_OUT0, 11289600, 0 }, |
| 1041 | { TEGRA20_CLK_SDMMC1, TEGRA20_CLK_PLL_P, 48000000, 0 }, |
| 1042 | { TEGRA20_CLK_SDMMC3, TEGRA20_CLK_PLL_P, 48000000, 0 }, |
| 1043 | { TEGRA20_CLK_SDMMC4, TEGRA20_CLK_PLL_P, 48000000, 0 }, |
| 1044 | { TEGRA20_CLK_SPI, TEGRA20_CLK_PLL_P, 20000000, 0 }, |
| 1045 | { TEGRA20_CLK_SBC1, TEGRA20_CLK_PLL_P, 100000000, 0 }, |
| 1046 | { TEGRA20_CLK_SBC2, TEGRA20_CLK_PLL_P, 100000000, 0 }, |
| 1047 | { TEGRA20_CLK_SBC3, TEGRA20_CLK_PLL_P, 100000000, 0 }, |
| 1048 | { TEGRA20_CLK_SBC4, TEGRA20_CLK_PLL_P, 100000000, 0 }, |
| 1049 | { TEGRA20_CLK_HOST1X, TEGRA20_CLK_PLL_C, 150000000, 0 }, |
| 1050 | { TEGRA20_CLK_DISP1, TEGRA20_CLK_PLL_P, 600000000, 0 }, |
| 1051 | { TEGRA20_CLK_DISP2, TEGRA20_CLK_PLL_P, 600000000, 0 }, |
| 1052 | { TEGRA20_CLK_GR2D, TEGRA20_CLK_PLL_C, 300000000, 0 }, |
| 1053 | { TEGRA20_CLK_GR3D, TEGRA20_CLK_PLL_C, 300000000, 0 }, |
| 1054 | /* must be the last entry */ |
| 1055 | { TEGRA20_CLK_CLK_MAX, TEGRA20_CLK_CLK_MAX, 0, 0 }, |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 1056 | }; |
| 1057 | |
Stephen Warren | 441f199 | 2013-03-25 13:22:24 -0600 | [diff] [blame] | 1058 | static void __init tegra20_clock_apply_init_table(void) |
| 1059 | { |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 1060 | tegra_init_from_table(init_table, clks, TEGRA20_CLK_CLK_MAX); |
Stephen Warren | 441f199 | 2013-03-25 13:22:24 -0600 | [diff] [blame] | 1061 | } |
| 1062 | |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 1063 | /* |
| 1064 | * Some clocks may be used by different drivers depending on the board |
| 1065 | * configuration. List those here to register them twice in the clock lookup |
| 1066 | * table under two names. |
| 1067 | */ |
| 1068 | static struct tegra_clk_duplicate tegra_clk_duplicates[] = { |
Thierry Reding | 8d99704 | 2015-11-18 14:10:02 +0100 | [diff] [blame] | 1069 | TEGRA_CLK_DUPLICATE(TEGRA20_CLK_USBD, "utmip-pad", NULL), |
| 1070 | TEGRA_CLK_DUPLICATE(TEGRA20_CLK_USBD, "tegra-ehci.0", NULL), |
| 1071 | TEGRA_CLK_DUPLICATE(TEGRA20_CLK_USBD, "tegra-otg", NULL), |
| 1072 | TEGRA_CLK_DUPLICATE(TEGRA20_CLK_CCLK, NULL, "cpu"), |
| 1073 | /* must be the last entry */ |
| 1074 | TEGRA_CLK_DUPLICATE(TEGRA20_CLK_CLK_MAX, NULL, NULL), |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 1075 | }; |
| 1076 | |
| 1077 | static const struct of_device_id pmc_match[] __initconst = { |
| 1078 | { .compatible = "nvidia,tegra20-pmc" }, |
Thierry Reding | e52d7c0 | 2015-11-18 14:04:20 +0100 | [diff] [blame] | 1079 | { }, |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 1080 | }; |
| 1081 | |
Prashant Gaikwad | 061cec9 | 2013-05-27 13:10:09 +0530 | [diff] [blame] | 1082 | static void __init tegra20_clock_init(struct device_node *np) |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 1083 | { |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 1084 | struct device_node *node; |
| 1085 | |
| 1086 | clk_base = of_iomap(np, 0); |
| 1087 | if (!clk_base) { |
| 1088 | pr_err("Can't map CAR registers\n"); |
| 1089 | BUG(); |
| 1090 | } |
| 1091 | |
| 1092 | node = of_find_matching_node(NULL, pmc_match); |
| 1093 | if (!node) { |
| 1094 | pr_err("Failed to find pmc node\n"); |
| 1095 | BUG(); |
| 1096 | } |
| 1097 | |
| 1098 | pmc_base = of_iomap(node, 0); |
| 1099 | if (!pmc_base) { |
| 1100 | pr_err("Can't map pmc registers\n"); |
| 1101 | BUG(); |
| 1102 | } |
| 1103 | |
Stephen Warren | 6d5b988 | 2013-11-05 17:33:17 -0700 | [diff] [blame] | 1104 | clks = tegra_clk_init(clk_base, TEGRA20_CLK_CLK_MAX, |
| 1105 | TEGRA20_CLK_PERIPH_BANKS); |
Peter De Schrijver | 343a607 | 2013-09-02 15:22:02 +0300 | [diff] [blame] | 1106 | if (!clks) |
Peter De Schrijver | d5ff89a | 2013-08-22 18:44:06 +0300 | [diff] [blame] | 1107 | return; |
| 1108 | |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 1109 | tegra20_osc_clk_init(); |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 1110 | tegra_fixed_clk_init(tegra20_clks); |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 1111 | tegra20_pll_init(); |
| 1112 | tegra20_super_clk_init(); |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 1113 | tegra_super_clk_gen4_init(clk_base, pmc_base, tegra20_clks, NULL); |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 1114 | tegra20_periph_clk_init(); |
| 1115 | tegra20_audio_clk_init(); |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 1116 | tegra_pmc_clk_init(pmc_base, tegra20_clks); |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 1117 | |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 1118 | tegra_init_dup_clks(tegra_clk_duplicates, clks, TEGRA20_CLK_CLK_MAX); |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 1119 | |
Peter De Schrijver | 343a607 | 2013-09-02 15:22:02 +0300 | [diff] [blame] | 1120 | tegra_add_of_provider(np); |
Peter De Schrijver | 540fc26 | 2013-10-07 14:49:10 +0300 | [diff] [blame] | 1121 | tegra_register_devclks(devclks, ARRAY_SIZE(devclks)); |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 1122 | |
Stephen Warren | 441f199 | 2013-03-25 13:22:24 -0600 | [diff] [blame] | 1123 | tegra_clk_apply_init_table = tegra20_clock_apply_init_table; |
Prashant Gaikwad | 37c26a9 | 2013-01-11 13:16:24 +0530 | [diff] [blame] | 1124 | |
| 1125 | tegra_cpu_car_ops = &tegra20_cpu_car_ops; |
| 1126 | } |
Prashant Gaikwad | 061cec9 | 2013-05-27 13:10:09 +0530 | [diff] [blame] | 1127 | CLK_OF_DECLARE(tegra20, "nvidia,tegra20-car", tegra20_clock_init); |