Channagoud Kadabi | 99d2370 | 2015-02-02 20:52:17 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2014-2015, The Linux Foundation. All rights reserved. |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 2 | * |
| 3 | * Redistribution and use in source and binary forms, with or without |
| 4 | * modification, are permitted provided that the following conditions are |
| 5 | * met: |
| 6 | * * Redistributions of source code must retain the above copyright |
| 7 | * notice, this list of conditions and the following disclaimer. |
| 8 | * * Redistributions in binary form must reproduce the above |
| 9 | * copyright notice, this list of conditions and the following |
| 10 | * disclaimer in the documentation and/or other materials provided |
| 11 | * with the distribution. |
| 12 | * * Neither the name of The Linux Foundation nor the names of its |
| 13 | * contributors may be used to endorse or promote products derived |
| 14 | * from this software without specific prior written permission. |
| 15 | * |
| 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED |
| 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT |
| 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS |
| 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
| 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | */ |
| 28 | |
| 29 | #include <assert.h> |
| 30 | #include <reg.h> |
| 31 | #include <err.h> |
| 32 | #include <clock.h> |
| 33 | #include <clock_pll.h> |
Channagoud Kadabi | dd7cb38 | 2015-03-23 23:30:25 -0700 | [diff] [blame] | 34 | #include <clock_alpha_pll.h> |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 35 | #include <clock_lib2.h> |
| 36 | #include <platform/clock.h> |
| 37 | #include <platform/iomap.h> |
| 38 | |
| 39 | |
| 40 | /* Mux source select values */ |
| 41 | #define cxo_source_val 0 |
| 42 | #define gpll0_source_val 1 |
| 43 | #define gpll4_source_val 5 |
| 44 | #define cxo_mm_source_val 0 |
| 45 | #define mmpll0_mm_source_val 1 |
| 46 | #define mmpll1_mm_source_val 2 |
| 47 | #define mmpll3_mm_source_val 3 |
| 48 | #define gpll0_mm_source_val 5 |
| 49 | |
| 50 | struct clk_freq_tbl rcg_dummy_freq = F_END; |
| 51 | |
| 52 | |
| 53 | /* Clock Operations */ |
| 54 | static struct clk_ops clk_ops_rst = |
| 55 | { |
| 56 | .reset = clock_lib2_reset_clk_reset, |
| 57 | }; |
| 58 | |
| 59 | static struct clk_ops clk_ops_branch = |
| 60 | { |
| 61 | .enable = clock_lib2_branch_clk_enable, |
| 62 | .disable = clock_lib2_branch_clk_disable, |
| 63 | .set_rate = clock_lib2_branch_set_rate, |
| 64 | .reset = clock_lib2_branch_clk_reset, |
| 65 | }; |
| 66 | |
| 67 | static struct clk_ops clk_ops_rcg_mnd = |
| 68 | { |
| 69 | .enable = clock_lib2_rcg_enable, |
| 70 | .set_rate = clock_lib2_rcg_set_rate, |
| 71 | }; |
| 72 | |
| 73 | static struct clk_ops clk_ops_rcg = |
| 74 | { |
| 75 | .enable = clock_lib2_rcg_enable, |
| 76 | .set_rate = clock_lib2_rcg_set_rate, |
| 77 | }; |
| 78 | |
| 79 | static struct clk_ops clk_ops_cxo = |
| 80 | { |
| 81 | .enable = cxo_clk_enable, |
| 82 | .disable = cxo_clk_disable, |
| 83 | }; |
| 84 | |
| 85 | static struct clk_ops clk_ops_pll_vote = |
| 86 | { |
| 87 | .enable = pll_vote_clk_enable, |
| 88 | .disable = pll_vote_clk_disable, |
| 89 | .auto_off = pll_vote_clk_disable, |
| 90 | .is_enabled = pll_vote_clk_is_enabled, |
| 91 | }; |
| 92 | |
| 93 | static struct clk_ops clk_ops_vote = |
| 94 | { |
| 95 | .enable = clock_lib2_vote_clk_enable, |
| 96 | .disable = clock_lib2_vote_clk_disable, |
| 97 | }; |
| 98 | |
Channagoud Kadabi | dd7cb38 | 2015-03-23 23:30:25 -0700 | [diff] [blame] | 99 | static struct clk_ops clk_ops_fixed_alpha_pll = |
| 100 | { |
| 101 | .enable = alpha_pll_enable, |
| 102 | .disable = alpha_pll_disable, |
| 103 | }; |
| 104 | |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 105 | /* Clock Sources */ |
| 106 | static struct fixed_clk cxo_clk_src = |
| 107 | { |
| 108 | .c = { |
| 109 | .rate = 19200000, |
| 110 | .dbg_name = "cxo_clk_src", |
| 111 | .ops = &clk_ops_cxo, |
| 112 | }, |
| 113 | }; |
| 114 | |
| 115 | static struct pll_vote_clk gpll0_clk_src = |
| 116 | { |
| 117 | .en_reg = (void *) APCS_GPLL_ENA_VOTE, |
| 118 | .en_mask = BIT(0), |
| 119 | .status_reg = (void *) GPLL0_MODE, |
| 120 | .status_mask = BIT(30), |
| 121 | .parent = &cxo_clk_src.c, |
| 122 | |
| 123 | .c = { |
| 124 | .rate = 600000000, |
| 125 | .dbg_name = "gpll0_clk_src", |
| 126 | .ops = &clk_ops_pll_vote, |
| 127 | }, |
| 128 | }; |
| 129 | |
| 130 | static struct pll_vote_clk gpll4_clk_src = |
| 131 | { |
| 132 | .en_reg = (void *) APCS_GPLL_ENA_VOTE, |
| 133 | .en_mask = BIT(4), |
| 134 | .status_reg = (void *) GPLL4_MODE, |
| 135 | .status_mask = BIT(30), |
| 136 | .parent = &cxo_clk_src.c, |
| 137 | |
| 138 | .c = { |
| 139 | .rate = 1600000000, |
| 140 | .dbg_name = "gpll4_clk_src", |
| 141 | .ops = &clk_ops_pll_vote, |
| 142 | }, |
| 143 | }; |
| 144 | |
Dhaval Patel | 0f3cbeb | 2015-03-17 11:52:12 -0700 | [diff] [blame] | 145 | static struct alpha_pll_masks pll_masks_p = { |
| 146 | .lock_mask = BIT(31), |
| 147 | .active_mask = BIT(30), |
| 148 | .vco_mask = BM(21, 20) >> 20, |
| 149 | .vco_shift = 20, |
| 150 | .alpha_en_mask = BIT(24), |
| 151 | .output_mask = 0xf, |
| 152 | }; |
| 153 | |
| 154 | static struct alpha_pll_vco_tbl mmpll_p_vco[] = { |
| 155 | VCO(3, 250000000, 500000000), |
| 156 | VCO(2, 500000000, 1000000000), |
| 157 | VCO(1, 1000000000, 1500000000), |
| 158 | VCO(0, 1500000000, 2000000000), |
| 159 | }; |
| 160 | |
| 161 | static struct alpha_pll_clk mmpll0_clk_src = { |
| 162 | .masks = &pll_masks_p, |
| 163 | .base = (uint32_t )MSM_MMSS_CLK_CTL_BASE, |
| 164 | .offset = 0x0, |
| 165 | .vco_tbl = mmpll_p_vco, |
| 166 | .vco_num = ARRAY_SIZE(mmpll_p_vco), |
| 167 | .fsm_reg_offset = 0x0100, |
| 168 | .fsm_en_mask = BIT(0), |
| 169 | .enable_config = 0x1, |
| 170 | .parent = &cxo_clk_src.c, |
| 171 | .inited = false, |
| 172 | .c = { |
| 173 | .rate = 800000000, |
| 174 | .dbg_name = "mmpll0_clk_src", |
| 175 | .ops = &clk_ops_fixed_alpha_pll, |
| 176 | }, |
| 177 | }; |
| 178 | |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 179 | /* UART Clocks */ |
| 180 | static struct clk_freq_tbl ftbl_gcc_blsp1_2_uart1_6_apps_clk[] = |
| 181 | { |
| 182 | F( 3686400, gpll0, 1, 96, 15625), |
| 183 | F( 7372800, gpll0, 1, 192, 15625), |
| 184 | F(14745600, gpll0, 1, 384, 15625), |
| 185 | F(16000000, gpll0, 5, 2, 15), |
| 186 | F(19200000, cxo, 1, 0, 0), |
| 187 | F(24000000, gpll0, 5, 1, 5), |
| 188 | F(32000000, gpll0, 1, 4, 75), |
| 189 | F(40000000, gpll0, 15, 0, 0), |
| 190 | F(46400000, gpll0, 1, 29, 375), |
| 191 | F(48000000, gpll0, 12.5, 0, 0), |
| 192 | F(51200000, gpll0, 1, 32, 375), |
| 193 | F(56000000, gpll0, 1, 7, 75), |
| 194 | F(58982400, gpll0, 1, 1536, 15625), |
| 195 | F(60000000, gpll0, 10, 0, 0), |
| 196 | F(63160000, gpll0, 9.5, 0, 0), |
| 197 | F_END |
| 198 | }; |
| 199 | |
Channagoud Kadabi | 35503c4 | 2014-11-14 16:22:43 -0800 | [diff] [blame] | 200 | static struct rcg_clk blsp2_uart2_apps_clk_src = |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 201 | { |
Channagoud Kadabi | 35503c4 | 2014-11-14 16:22:43 -0800 | [diff] [blame] | 202 | .cmd_reg = (uint32_t *) BLSP2_UART2_APPS_CMD_RCGR, |
| 203 | .cfg_reg = (uint32_t *) BLSP2_UART2_APPS_CFG_RCGR, |
| 204 | .m_reg = (uint32_t *) BLSP2_UART2_APPS_M, |
| 205 | .n_reg = (uint32_t *) BLSP2_UART2_APPS_N, |
| 206 | .d_reg = (uint32_t *) BLSP2_UART2_APPS_D, |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 207 | |
| 208 | .set_rate = clock_lib2_rcg_set_rate_mnd, |
| 209 | .freq_tbl = ftbl_gcc_blsp1_2_uart1_6_apps_clk, |
| 210 | .current_freq = &rcg_dummy_freq, |
| 211 | |
| 212 | .c = { |
Channagoud Kadabi | 35503c4 | 2014-11-14 16:22:43 -0800 | [diff] [blame] | 213 | .dbg_name = "blsp2_uart2_apps_clk", |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 214 | .ops = &clk_ops_rcg_mnd, |
| 215 | }, |
| 216 | }; |
| 217 | |
Channagoud Kadabi | 35503c4 | 2014-11-14 16:22:43 -0800 | [diff] [blame] | 218 | static struct branch_clk gcc_blsp2_uart2_apps_clk = |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 219 | { |
Channagoud Kadabi | 35503c4 | 2014-11-14 16:22:43 -0800 | [diff] [blame] | 220 | .cbcr_reg = (uint32_t *) BLSP2_UART2_APPS_CBCR, |
| 221 | .parent = &blsp2_uart2_apps_clk_src.c, |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 222 | |
| 223 | .c = { |
Channagoud Kadabi | 35503c4 | 2014-11-14 16:22:43 -0800 | [diff] [blame] | 224 | .dbg_name = "gcc_blsp2_uart2_apps_clk", |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 225 | .ops = &clk_ops_branch, |
| 226 | }, |
| 227 | }; |
| 228 | |
Channagoud Kadabi | 99d2370 | 2015-02-02 20:52:17 -0800 | [diff] [blame] | 229 | static struct vote_clk gcc_blsp2_ahb_clk = { |
| 230 | .cbcr_reg = (uint32_t *) BLSP2_AHB_CBCR, |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 231 | .vote_reg = (uint32_t *) APCS_CLOCK_BRANCH_ENA_VOTE, |
Channagoud Kadabi | 99d2370 | 2015-02-02 20:52:17 -0800 | [diff] [blame] | 232 | .en_mask = BIT(15), |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 233 | |
| 234 | .c = { |
Channagoud Kadabi | 99d2370 | 2015-02-02 20:52:17 -0800 | [diff] [blame] | 235 | .dbg_name = "gcc_blsp2_ahb_clk", |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 236 | .ops = &clk_ops_vote, |
| 237 | }, |
| 238 | }; |
| 239 | |
Siddharth Zaveri | 1cf08b9 | 2015-12-02 17:09:14 -0500 | [diff] [blame] | 240 | static struct clk_freq_tbl ftbl_gcc_blsp1_qup2_i2c_apps_clk_src[] = { |
| 241 | F( 96000, cxo, 10, 1, 2), |
| 242 | F( 4800000, cxo, 4, 0, 0), |
| 243 | F( 9600000, cxo, 2, 0, 0), |
| 244 | F( 16000000, gpll0, 10, 1, 5), |
| 245 | F( 19200000, gpll0, 1, 0, 0), |
| 246 | F( 25000000, gpll0, 16, 1, 2), |
| 247 | F( 50000000, gpll0, 16, 0, 0), |
| 248 | F_END |
| 249 | }; |
| 250 | |
| 251 | static struct rcg_clk gcc_blsp2_qup2_i2c_apps_clk_src = { |
| 252 | .cmd_reg = (uint32_t *) GCC_BLSP2_QUP2_CMD_RCGR, |
| 253 | .cfg_reg = (uint32_t *) GCC_BLSP2_QUP2_CFG_RCGR, |
| 254 | .set_rate = clock_lib2_rcg_set_rate_hid, |
| 255 | .freq_tbl = ftbl_gcc_blsp1_qup2_i2c_apps_clk_src, |
| 256 | .current_freq = &rcg_dummy_freq, |
| 257 | |
| 258 | .c = { |
| 259 | .dbg_name = "gcc_blsp2_qup2_i2c_apps_clk_src", |
| 260 | .ops = &clk_ops_rcg, |
| 261 | }, |
| 262 | }; |
| 263 | |
| 264 | static struct branch_clk gcc_blsp2_qup2_i2c_apps_clk = { |
| 265 | .cbcr_reg = (uint32_t *) GCC_BLSP2_QUP2_APPS_CBCR, |
| 266 | .parent = &gcc_blsp2_qup2_i2c_apps_clk_src.c, |
| 267 | |
| 268 | .c = { |
| 269 | .dbg_name = "gcc_blsp2_qup2_i2c_apps_clk", |
| 270 | .ops = &clk_ops_branch, |
| 271 | }, |
| 272 | }; |
| 273 | |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 274 | /* SDCC Clocks */ |
| 275 | static struct clk_freq_tbl ftbl_gcc_sdcc1_4_apps_clk[] = |
| 276 | { |
| 277 | F( 144000, cxo, 16, 3, 25), |
| 278 | F( 400000, cxo, 12, 1, 4), |
| 279 | F( 20000000, gpll0, 15, 1, 2), |
| 280 | F( 25000000, gpll0, 12, 1, 2), |
| 281 | F( 50000000, gpll0, 12, 0, 0), |
Channagoud Kadabi | 99d2370 | 2015-02-02 20:52:17 -0800 | [diff] [blame] | 282 | F( 96000000, gpll4, 4, 0, 0), |
| 283 | F(192000000, gpll4, 2, 0, 0), |
| 284 | F(384000000, gpll4, 1, 0, 0), |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 285 | F_END |
| 286 | }; |
| 287 | |
| 288 | static struct rcg_clk sdcc1_apps_clk_src = |
| 289 | { |
| 290 | .cmd_reg = (uint32_t *) SDCC1_CMD_RCGR, |
| 291 | .cfg_reg = (uint32_t *) SDCC1_CFG_RCGR, |
| 292 | .m_reg = (uint32_t *) SDCC1_M, |
| 293 | .n_reg = (uint32_t *) SDCC1_N, |
| 294 | .d_reg = (uint32_t *) SDCC1_D, |
| 295 | |
| 296 | .set_rate = clock_lib2_rcg_set_rate_mnd, |
| 297 | .freq_tbl = ftbl_gcc_sdcc1_4_apps_clk, |
| 298 | .current_freq = &rcg_dummy_freq, |
| 299 | |
| 300 | .c = { |
| 301 | .dbg_name = "sdc1_clk", |
| 302 | .ops = &clk_ops_rcg_mnd, |
| 303 | }, |
| 304 | }; |
| 305 | |
| 306 | static struct branch_clk gcc_sdcc1_apps_clk = |
| 307 | { |
| 308 | .cbcr_reg = (uint32_t *) SDCC1_APPS_CBCR, |
| 309 | .parent = &sdcc1_apps_clk_src.c, |
| 310 | |
| 311 | .c = { |
| 312 | .dbg_name = "gcc_sdcc1_apps_clk", |
| 313 | .ops = &clk_ops_branch, |
| 314 | }, |
| 315 | }; |
| 316 | |
| 317 | static struct branch_clk gcc_sdcc1_ahb_clk = |
| 318 | { |
| 319 | .cbcr_reg = (uint32_t *) SDCC1_AHB_CBCR, |
| 320 | .has_sibling = 1, |
| 321 | |
| 322 | .c = { |
| 323 | .dbg_name = "gcc_sdcc1_ahb_clk", |
| 324 | .ops = &clk_ops_branch, |
| 325 | }, |
| 326 | }; |
| 327 | |
| 328 | static struct branch_clk gcc_sys_noc_usb30_axi_clk = { |
| 329 | .cbcr_reg = (uint32_t *) SYS_NOC_USB3_AXI_CBCR, |
| 330 | .has_sibling = 1, |
| 331 | |
| 332 | .c = { |
| 333 | .dbg_name = "sys_noc_usb30_axi_clk", |
| 334 | .ops = &clk_ops_branch, |
| 335 | }, |
| 336 | }; |
| 337 | |
| 338 | static struct clk_freq_tbl ftbl_gcc_usb30_master_clk[] = { |
Channagoud Kadabi | df233d2 | 2015-02-11 11:56:48 -0800 | [diff] [blame] | 339 | F( 19200000, cxo, 1, 0, 0), |
| 340 | F( 120000000, gpll0, 5, 0, 0), |
Channagoud Kadabi | 99d2370 | 2015-02-02 20:52:17 -0800 | [diff] [blame] | 341 | F( 150000000, gpll0, 4, 0, 0), |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 342 | F_END |
| 343 | }; |
| 344 | |
| 345 | static struct rcg_clk usb30_master_clk_src = { |
| 346 | .cmd_reg = (uint32_t *) USB30_MASTER_CMD_RCGR, |
| 347 | .cfg_reg = (uint32_t *) USB30_MASTER_CFG_RCGR, |
| 348 | .m_reg = (uint32_t *) USB30_MASTER_M, |
| 349 | .n_reg = (uint32_t *) USB30_MASTER_N, |
| 350 | .d_reg = (uint32_t *) USB30_MASTER_D, |
| 351 | |
| 352 | .set_rate = clock_lib2_rcg_set_rate_mnd, |
| 353 | .freq_tbl = ftbl_gcc_usb30_master_clk, |
| 354 | .current_freq = &rcg_dummy_freq, |
| 355 | |
| 356 | .c = { |
| 357 | .dbg_name = "usb30_master_clk_src", |
| 358 | .ops = &clk_ops_rcg, |
| 359 | }, |
| 360 | }; |
| 361 | |
| 362 | static struct branch_clk gcc_usb30_master_clk = { |
| 363 | .cbcr_reg = (uint32_t *) USB30_MASTER_CBCR, |
| 364 | .bcr_reg = (uint32_t *) USB_30_BCR, |
| 365 | .parent = &usb30_master_clk_src.c, |
| 366 | |
| 367 | .c = { |
| 368 | .dbg_name = "usb30_master_clk", |
| 369 | .ops = &clk_ops_branch, |
| 370 | }, |
| 371 | }; |
| 372 | |
Channagoud Kadabi | df233d2 | 2015-02-11 11:56:48 -0800 | [diff] [blame] | 373 | static struct branch_clk gcc_aggre2_usb3_axi_clk = { |
| 374 | .cbcr_reg = (uint32_t *) GCC_AGGRE2_USB3_AXI_CBCR, |
| 375 | .parent = &usb30_master_clk_src.c, |
| 376 | |
| 377 | .c = { |
| 378 | .dbg_name = "gcc_aggre2_usb3_axi_clk", |
| 379 | .ops = &clk_ops_branch, |
| 380 | }, |
| 381 | }; |
| 382 | |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 383 | static struct clk_freq_tbl ftbl_gcc_usb30_mock_utmi_clk_src[] = { |
| 384 | F( 60000000, gpll0, 10, 0, 0), |
| 385 | F_END |
| 386 | }; |
| 387 | |
| 388 | static struct rcg_clk usb30_mock_utmi_clk_src = { |
| 389 | .cmd_reg = (uint32_t *) USB30_MOCK_UTMI_CMD_RCGR, |
| 390 | .cfg_reg = (uint32_t *) USB30_MOCK_UTMI_CFG_RCGR, |
| 391 | .set_rate = clock_lib2_rcg_set_rate_hid, |
| 392 | .freq_tbl = ftbl_gcc_usb30_mock_utmi_clk_src, |
| 393 | .current_freq = &rcg_dummy_freq, |
| 394 | |
| 395 | .c = { |
| 396 | .dbg_name = "usb30_mock_utmi_clk_src", |
| 397 | .ops = &clk_ops_rcg, |
| 398 | }, |
| 399 | }; |
| 400 | |
| 401 | static struct branch_clk gcc_usb30_mock_utmi_clk = { |
| 402 | .cbcr_reg = (uint32_t *) USB30_MOCK_UTMI_CBCR, |
| 403 | .has_sibling = 0, |
| 404 | .parent = &usb30_mock_utmi_clk_src.c, |
| 405 | |
| 406 | .c = { |
| 407 | .dbg_name = "usb30_mock_utmi_clk", |
| 408 | .ops = &clk_ops_branch, |
| 409 | }, |
| 410 | }; |
| 411 | |
| 412 | static struct branch_clk gcc_usb30_sleep_clk = { |
| 413 | .cbcr_reg = (uint32_t *) USB30_SLEEP_CBCR, |
| 414 | .has_sibling = 1, |
| 415 | |
| 416 | .c = { |
| 417 | .dbg_name = "usb30_sleep_clk", |
| 418 | .ops = &clk_ops_branch, |
| 419 | }, |
| 420 | }; |
| 421 | |
| 422 | static struct clk_freq_tbl ftbl_gcc_usb30_phy_aux_clk_src[] = { |
| 423 | F( 1200000, cxo, 16, 0, 0), |
| 424 | F_END |
| 425 | }; |
| 426 | |
| 427 | static struct rcg_clk usb30_phy_aux_clk_src = { |
| 428 | .cmd_reg = (uint32_t *) USB30_PHY_AUX_CMD_RCGR, |
| 429 | .cfg_reg = (uint32_t *) USB30_PHY_AUX_CFG_RCGR, |
| 430 | .set_rate = clock_lib2_rcg_set_rate_hid, |
| 431 | .freq_tbl = ftbl_gcc_usb30_phy_aux_clk_src, |
| 432 | .current_freq = &rcg_dummy_freq, |
| 433 | |
| 434 | .c = { |
| 435 | .dbg_name = "usb30_phy_aux_clk_src", |
| 436 | .ops = &clk_ops_rcg, |
| 437 | }, |
| 438 | }; |
| 439 | |
| 440 | static struct branch_clk gcc_usb30_phy_aux_clk = { |
| 441 | .cbcr_reg = (uint32_t *)USB30_PHY_AUX_CBCR, |
| 442 | .has_sibling = 0, |
| 443 | .parent = &usb30_phy_aux_clk_src.c, |
| 444 | |
| 445 | .c = { |
| 446 | .dbg_name = "usb30_phy_aux_clk", |
| 447 | .ops = &clk_ops_branch, |
| 448 | }, |
| 449 | }; |
| 450 | |
| 451 | static struct branch_clk gcc_usb30_pipe_clk = { |
| 452 | .bcr_reg = (uint32_t *) USB30PHY_PHY_BCR, |
| 453 | .cbcr_reg = (uint32_t *) USB30_PHY_PIPE_CBCR, |
| 454 | .has_sibling = 1, |
| 455 | |
| 456 | .c = { |
| 457 | .dbg_name = "usb30_pipe_clk", |
| 458 | .ops = &clk_ops_branch, |
| 459 | }, |
| 460 | }; |
| 461 | |
| 462 | static struct reset_clk gcc_usb30_phy_reset = { |
| 463 | .bcr_reg = (uint32_t )USB30_PHY_BCR, |
| 464 | |
| 465 | .c = { |
| 466 | .dbg_name = "usb30_phy_reset", |
| 467 | .ops = &clk_ops_rst, |
| 468 | }, |
| 469 | }; |
| 470 | |
| 471 | static struct branch_clk gcc_usb_phy_cfg_ahb2phy_clk = { |
| 472 | .cbcr_reg = (uint32_t *)USB_PHY_CFG_AHB2PHY_CBCR, |
| 473 | .has_sibling = 1, |
| 474 | |
| 475 | .c = { |
| 476 | .dbg_name = "usb_phy_cfg_ahb2phy_clk", |
| 477 | .ops = &clk_ops_branch, |
| 478 | }, |
| 479 | }; |
| 480 | |
Dhaval Patel | 0f3cbeb | 2015-03-17 11:52:12 -0700 | [diff] [blame] | 481 | /* Display clocks */ |
| 482 | static struct clk_freq_tbl ftbl_mdss_esc0_1_clk[] = { |
| 483 | F_MM(19200000, cxo, 1, 0, 0), |
| 484 | F_END |
| 485 | }; |
| 486 | |
| 487 | static struct clk_freq_tbl ftbl_mdss_esc1_1_clk[] = { |
| 488 | F_MM(19200000, cxo, 1, 0, 0), |
| 489 | F_END |
| 490 | }; |
| 491 | |
| 492 | static struct clk_freq_tbl ftbl_axi_clk_src[] = { |
| 493 | F_MM( 171430000, gpll0, 3.5, 0, 0), |
| 494 | F_MM( 200000000, gpll0, 3, 0, 0), |
| 495 | F_MM( 320000000, mmpll0, 2.5, 0, 0), |
| 496 | F_END |
| 497 | }; |
| 498 | |
| 499 | static struct clk_freq_tbl ftbl_mdp_clk_src[] = { |
| 500 | F_MM( 85714286, gpll0, 7, 0, 0), |
| 501 | F_MM( 100000000, gpll0, 6, 0, 0), |
| 502 | F_MM( 150000000, gpll0, 4, 0, 0), |
| 503 | F_MM( 171428571, gpll0, 3.5, 0, 0), |
| 504 | F_MM( 320000000, mmpll0, 2.5, 0, 0), |
| 505 | F_END |
| 506 | }; |
| 507 | |
| 508 | static struct clk_freq_tbl ftbl_ahb_clk_src[] = { |
| 509 | F_MM( 19200000, cxo, 1, 0, 0), |
| 510 | F_END |
| 511 | }; |
| 512 | |
| 513 | static struct rcg_clk ahb_clk_src = { |
| 514 | .cmd_reg = (uint32_t *)MMSS_AHB_CMD_RCGR, |
| 515 | .cfg_reg = (uint32_t *)MMSS_AHB_CFG_RCGR, |
| 516 | .set_rate = clock_lib2_rcg_set_rate_hid, |
| 517 | .freq_tbl = ftbl_ahb_clk_src, |
| 518 | .c = { |
| 519 | .dbg_name = "ahb_clk_src", |
| 520 | .ops = &clk_ops_rcg, |
| 521 | }, |
| 522 | }; |
| 523 | |
| 524 | static struct rcg_clk dsi_esc0_clk_src = { |
| 525 | .cmd_reg = (uint32_t *) DSI_ESC0_CMD_RCGR, |
| 526 | .cfg_reg = (uint32_t *) DSI_ESC0_CFG_RCGR, |
| 527 | .set_rate = clock_lib2_rcg_set_rate_hid, |
| 528 | .freq_tbl = ftbl_mdss_esc0_1_clk, |
| 529 | |
| 530 | .c = { |
| 531 | .dbg_name = "dsi_esc0_clk_src", |
| 532 | .ops = &clk_ops_rcg, |
| 533 | }, |
| 534 | }; |
| 535 | |
| 536 | static struct rcg_clk dsi_esc1_clk_src = { |
| 537 | .cmd_reg = (uint32_t *) DSI_ESC1_CMD_RCGR, |
| 538 | .cfg_reg = (uint32_t *) DSI_ESC1_CFG_RCGR, |
| 539 | .set_rate = clock_lib2_rcg_set_rate_hid, |
| 540 | .freq_tbl = ftbl_mdss_esc1_1_clk, |
| 541 | |
| 542 | .c = { |
| 543 | .dbg_name = "dsi_esc1_clk_src", |
| 544 | .ops = &clk_ops_rcg, |
| 545 | }, |
| 546 | }; |
| 547 | |
| 548 | static struct clk_freq_tbl ftbl_mdss_vsync_clk[] = { |
| 549 | F_MM(19200000, cxo, 1, 0, 0), |
| 550 | F_END |
| 551 | }; |
| 552 | |
| 553 | static struct rcg_clk vsync_clk_src = { |
| 554 | .cmd_reg = (uint32_t *) VSYNC_CMD_RCGR, |
| 555 | .cfg_reg = (uint32_t *) VSYNC_CFG_RCGR, |
| 556 | .set_rate = clock_lib2_rcg_set_rate_hid, |
| 557 | .freq_tbl = ftbl_mdss_vsync_clk, |
| 558 | |
| 559 | .c = { |
| 560 | .dbg_name = "vsync_clk_src", |
| 561 | .ops = &clk_ops_rcg, |
| 562 | }, |
| 563 | }; |
| 564 | |
| 565 | static struct rcg_clk axi_clk_src = { |
| 566 | .cmd_reg = (uint32_t *) AXI_CMD_RCGR, |
| 567 | .cfg_reg = (uint32_t *) AXI_CFG_RCGR, |
| 568 | .set_rate = clock_lib2_rcg_set_rate_hid, |
| 569 | .freq_tbl = ftbl_axi_clk_src, |
| 570 | |
| 571 | .c = { |
| 572 | .dbg_name = "axi_clk_src", |
| 573 | .ops = &clk_ops_rcg, |
| 574 | }, |
| 575 | }; |
| 576 | |
| 577 | static struct branch_clk mdss_esc0_clk = { |
| 578 | .cbcr_reg = (uint32_t *) DSI_ESC0_CBCR, |
| 579 | .parent = &dsi_esc0_clk_src.c, |
| 580 | .has_sibling = 0, |
| 581 | |
| 582 | .c = { |
| 583 | .dbg_name = "mdss_esc0_clk", |
| 584 | .ops = &clk_ops_branch, |
| 585 | }, |
| 586 | }; |
| 587 | |
| 588 | static struct branch_clk mdss_esc1_clk = { |
| 589 | .cbcr_reg = (uint32_t *) DSI_ESC1_CBCR, |
| 590 | .parent = &dsi_esc1_clk_src.c, |
| 591 | .has_sibling = 0, |
| 592 | |
| 593 | .c = { |
| 594 | .dbg_name = "mdss_esc1_clk", |
| 595 | .ops = &clk_ops_branch, |
| 596 | }, |
| 597 | }; |
| 598 | |
| 599 | static struct branch_clk mdss_axi_clk = { |
| 600 | .cbcr_reg = (uint32_t *) MDSS_AXI_CBCR, |
| 601 | .parent = &axi_clk_src.c, |
| 602 | .has_sibling = 0, |
| 603 | |
| 604 | .c = { |
| 605 | .dbg_name = "mdss_axi_clk", |
| 606 | .ops = &clk_ops_branch, |
| 607 | }, |
| 608 | }; |
| 609 | |
| 610 | static struct branch_clk smmu_mdp_axi_clk = { |
| 611 | .cbcr_reg = (uint32_t *) SMMU_MDP_AXI_CBCR, |
| 612 | .parent = &axi_clk_src.c, |
| 613 | .has_sibling = 0, |
| 614 | |
| 615 | .c = { |
| 616 | .dbg_name = "smmu_mdp_axi_clk", |
| 617 | .ops = &clk_ops_branch, |
| 618 | }, |
| 619 | }; |
| 620 | |
| 621 | static struct branch_clk mmss_mmagic_axi_clk = { |
| 622 | .cbcr_reg = (uint32_t *) MMSS_MMAGIC_AXI_CBCR, |
| 623 | .parent = &axi_clk_src.c, |
| 624 | .has_sibling = 0, |
| 625 | .c = { |
| 626 | .dbg_name = "mmss_mmagic_axi_clk", |
| 627 | .ops = &clk_ops_branch, |
| 628 | }, |
| 629 | }; |
| 630 | |
| 631 | static struct branch_clk mmagic_mdss_axi_clk = { |
| 632 | .cbcr_reg = (uint32_t *) MMAGIC_MDSS_AXI_CBCR, |
| 633 | .parent = &axi_clk_src.c, |
| 634 | .has_sibling = 0, |
| 635 | .c = { |
| 636 | .dbg_name = "mmagic_mdss_axi_clk", |
| 637 | .ops = &clk_ops_branch, |
| 638 | }, |
| 639 | }; |
| 640 | |
| 641 | static struct branch_clk mmagic_bimc_axi_clk = { |
| 642 | .cbcr_reg = (uint32_t *) MMAGIC_BIMC_AXI_CBCR, |
| 643 | .parent = &axi_clk_src.c, |
| 644 | .has_sibling = 0, |
| 645 | .c = { |
| 646 | .dbg_name = "mmagic_bimc_axi_clk", |
| 647 | .ops = &clk_ops_branch, |
| 648 | }, |
| 649 | }; |
| 650 | |
| 651 | static struct branch_clk mmss_s0_axi_clk = { |
| 652 | .cbcr_reg = (uint32_t *) MMSS_S0_AXI_CBCR, |
| 653 | .parent = &axi_clk_src.c, |
| 654 | .has_sibling = 0, |
| 655 | |
| 656 | .c = { |
| 657 | .dbg_name = "mmss_s0_axi_clk", |
| 658 | .ops = &clk_ops_branch, |
| 659 | }, |
| 660 | }; |
| 661 | |
| 662 | static struct branch_clk mdp_ahb_clk = { |
| 663 | .cbcr_reg = (uint32_t *) MDSS_AHB_CBCR, |
| 664 | .has_sibling = 1, |
| 665 | .parent = &ahb_clk_src.c, |
| 666 | |
| 667 | .c = { |
| 668 | .dbg_name = "mdp_ahb_clk", |
| 669 | .ops = &clk_ops_branch, |
| 670 | }, |
| 671 | }; |
| 672 | |
| 673 | static struct branch_clk mmss_mmagic_ahb_clk = { |
| 674 | .cbcr_reg = (uint32_t *) MMSS_MMAGIC_AHB_CBCR, |
| 675 | .has_sibling = 0, |
| 676 | .parent = &ahb_clk_src.c, |
| 677 | .no_halt_check_on_disable = true, |
| 678 | |
| 679 | .c = { |
| 680 | .dbg_name = "mmss_mmagic_ahb_clk", |
| 681 | .ops = &clk_ops_branch, |
| 682 | }, |
| 683 | }; |
| 684 | |
| 685 | static struct branch_clk smmu_mdp_ahb_clk = { |
| 686 | .cbcr_reg = (uint32_t *) SMMU_MDP_AHB_CBCR, |
| 687 | .has_sibling = 1, |
| 688 | .parent = &ahb_clk_src.c, |
| 689 | |
| 690 | .c = { |
| 691 | .dbg_name = "smmu_mdp_ahb_clk", |
| 692 | .ops = &clk_ops_branch, |
| 693 | }, |
| 694 | }; |
| 695 | |
| 696 | static struct rcg_clk mdss_mdp_clk_src = { |
| 697 | .cmd_reg = (uint32_t *) MDP_CMD_RCGR, |
| 698 | .cfg_reg = (uint32_t *) MDP_CFG_RCGR, |
| 699 | .set_rate = clock_lib2_rcg_set_rate_hid, |
| 700 | .freq_tbl = ftbl_mdp_clk_src, |
| 701 | .current_freq = &rcg_dummy_freq, |
| 702 | |
| 703 | .c = { |
| 704 | .dbg_name = "mdss_mdp_clk_src", |
| 705 | .ops = &clk_ops_rcg, |
| 706 | }, |
| 707 | }; |
| 708 | |
| 709 | static struct branch_clk mdss_mdp_clk = { |
| 710 | .cbcr_reg = (uint32_t *) MDP_CBCR, |
| 711 | .parent = &mdss_mdp_clk_src.c, |
| 712 | .has_sibling = 0, |
| 713 | |
| 714 | .c = { |
| 715 | .dbg_name = "mdss_mdp_clk", |
| 716 | .ops = &clk_ops_branch, |
| 717 | }, |
| 718 | }; |
| 719 | |
| 720 | static struct branch_clk mdss_vsync_clk = { |
| 721 | .cbcr_reg = (uint32_t *) MDSS_VSYNC_CBCR, |
| 722 | .parent = &vsync_clk_src.c, |
| 723 | .has_sibling = 0, |
| 724 | |
| 725 | .c = { |
| 726 | .dbg_name = "mdss_vsync_clk", |
| 727 | .ops = &clk_ops_branch, |
| 728 | }, |
| 729 | }; |
| 730 | |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 731 | |
| 732 | /* Clock lookup table */ |
Channagoud Kadabi | 0ffa786 | 2015-03-19 11:58:28 -0700 | [diff] [blame] | 733 | static struct clk_lookup msm_msm8996_clocks[] = |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 734 | { |
| 735 | CLK_LOOKUP("sdc1_iface_clk", gcc_sdcc1_ahb_clk.c), |
| 736 | CLK_LOOKUP("sdc1_core_clk", gcc_sdcc1_apps_clk.c), |
| 737 | |
Channagoud Kadabi | 99d2370 | 2015-02-02 20:52:17 -0800 | [diff] [blame] | 738 | CLK_LOOKUP("uart8_iface_clk", gcc_blsp2_ahb_clk.c), |
Channagoud Kadabi | 35503c4 | 2014-11-14 16:22:43 -0800 | [diff] [blame] | 739 | CLK_LOOKUP("uart8_core_clk", gcc_blsp2_uart2_apps_clk.c), |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 740 | |
| 741 | /* USB30 clocks */ |
| 742 | CLK_LOOKUP("usb30_master_clk", gcc_usb30_master_clk.c), |
Channagoud Kadabi | df233d2 | 2015-02-11 11:56:48 -0800 | [diff] [blame] | 743 | CLK_LOOKUP("gcc_aggre2_usb3_axi_clk", gcc_aggre2_usb3_axi_clk.c), |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 744 | CLK_LOOKUP("usb30_iface_clk", gcc_sys_noc_usb30_axi_clk.c), |
| 745 | CLK_LOOKUP("usb30_mock_utmi_clk", gcc_usb30_mock_utmi_clk.c), |
| 746 | CLK_LOOKUP("usb30_sleep_clk", gcc_usb30_sleep_clk.c), |
| 747 | CLK_LOOKUP("usb30_phy_aux_clk", gcc_usb30_phy_aux_clk.c), |
| 748 | CLK_LOOKUP("usb30_pipe_clk", gcc_usb30_pipe_clk.c), |
| 749 | CLK_LOOKUP("usb30_phy_reset", gcc_usb30_phy_reset.c), |
| 750 | |
| 751 | CLK_LOOKUP("usb_phy_cfg_ahb2phy_clk", gcc_usb_phy_cfg_ahb2phy_clk.c), |
Dhaval Patel | 0f3cbeb | 2015-03-17 11:52:12 -0700 | [diff] [blame] | 752 | |
| 753 | /* mdss clocks */ |
| 754 | CLK_LOOKUP("mdss_mdp_clk", mdss_mdp_clk.c), |
| 755 | CLK_LOOKUP("mdss_vsync_clk", mdss_vsync_clk.c), |
| 756 | CLK_LOOKUP("mdss_mdp_clk", mdss_mdp_clk.c), |
| 757 | CLK_LOOKUP("mdss_esc0_clk", mdss_esc0_clk.c), |
| 758 | CLK_LOOKUP("mdss_esc1_clk", mdss_esc1_clk.c), |
| 759 | CLK_LOOKUP("mmss_s0_axi_clk", mmss_s0_axi_clk.c), |
| 760 | CLK_LOOKUP("mmss_mmagic_axi_clk", mmss_mmagic_axi_clk.c), |
| 761 | CLK_LOOKUP("mmagic_mdss_axi_clk", mmagic_mdss_axi_clk.c), |
| 762 | CLK_LOOKUP("mmagic_bimc_axi_clk", mmagic_bimc_axi_clk.c), |
| 763 | CLK_LOOKUP("smmu_mdp_axi_clk", smmu_mdp_axi_clk.c), |
| 764 | CLK_LOOKUP("mdss_axi_clk", mdss_axi_clk.c), |
| 765 | CLK_LOOKUP("mmss_mmagic_ahb_clk", mmss_mmagic_ahb_clk.c), |
| 766 | CLK_LOOKUP("smmu_mdp_ahb_clk", smmu_mdp_ahb_clk.c), |
| 767 | CLK_LOOKUP("mdp_ahb_clk", mdp_ahb_clk.c), |
Siddharth Zaveri | 1cf08b9 | 2015-12-02 17:09:14 -0500 | [diff] [blame] | 768 | |
| 769 | /* BLSP CLOCKS */ |
| 770 | CLK_LOOKUP("blsp2_qup2_ahb_iface_clk", gcc_blsp2_ahb_clk.c), |
| 771 | CLK_LOOKUP("gcc_blsp2_qup2_i2c_apps_clk_src", |
| 772 | gcc_blsp2_qup2_i2c_apps_clk_src.c), |
| 773 | CLK_LOOKUP("gcc_blsp2_qup2_i2c_apps_clk", |
| 774 | gcc_blsp2_qup2_i2c_apps_clk.c), |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 775 | }; |
| 776 | |
| 777 | void platform_clock_init(void) |
| 778 | { |
Channagoud Kadabi | 0ffa786 | 2015-03-19 11:58:28 -0700 | [diff] [blame] | 779 | clk_init(msm_msm8996_clocks, ARRAY_SIZE(msm_msm8996_clocks)); |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 780 | } |