Channagoud Kadabi | ecea369 | 2014-02-04 17:05:13 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved. |
Deepa Dinamani | 554b062 | 2013-05-16 15:00:30 -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 <stdint.h> |
| 30 | #include <debug.h> |
| 31 | #include <reg.h> |
| 32 | #include <mmc.h> |
| 33 | #include <clock.h> |
Channagoud Kadabi | ecea369 | 2014-02-04 17:05:13 -0800 | [diff] [blame] | 34 | #include <pm8x41.h> |
Deepa Dinamani | 554b062 | 2013-05-16 15:00:30 -0700 | [diff] [blame] | 35 | #include <platform/clock.h> |
Sundarajan Srinivasan | 09374ed | 2013-06-18 13:29:32 -0700 | [diff] [blame] | 36 | #include <platform/iomap.h> |
Deepa Dinamani | 554b062 | 2013-05-16 15:00:30 -0700 | [diff] [blame] | 37 | |
| 38 | void hsusb_clock_init(void) |
| 39 | { |
Sundarajan Srinivasan | 09374ed | 2013-06-18 13:29:32 -0700 | [diff] [blame] | 40 | int ret; |
| 41 | struct clk *iclk, *cclk; |
| 42 | |
| 43 | ret = clk_get_set_enable("usb_iface_clk", 0, 1); |
| 44 | if(ret) |
| 45 | { |
| 46 | dprintf(CRITICAL, "failed to set usb_iface_clk ret = %d\n", ret); |
| 47 | ASSERT(0); |
| 48 | } |
| 49 | |
| 50 | ret = clk_get_set_enable("usb_core_clk", 75000000, 1); |
| 51 | if(ret) |
| 52 | { |
| 53 | dprintf(CRITICAL, "failed to set usb_core_clk ret = %d\n", ret); |
| 54 | ASSERT(0); |
| 55 | } |
| 56 | |
| 57 | /* Wait for the clocks to be stable since we are disabling soon after. */ |
| 58 | mdelay(1); |
| 59 | |
| 60 | iclk = clk_get("usb_iface_clk"); |
| 61 | cclk = clk_get("usb_core_clk"); |
| 62 | |
| 63 | clk_disable(iclk); |
| 64 | clk_disable(cclk); |
| 65 | |
| 66 | /* Wait for the clock disable to complete. */ |
| 67 | mdelay(1); |
| 68 | |
| 69 | /* Start the block reset for usb */ |
| 70 | writel(1, USB_HS_BCR); |
| 71 | |
| 72 | /* Wait for reset to complete. */ |
| 73 | mdelay(1); |
| 74 | |
| 75 | /* Take usb block out of reset */ |
| 76 | writel(0, USB_HS_BCR); |
| 77 | |
| 78 | /* Wait for the block to be brought out of reset. */ |
| 79 | mdelay(1); |
| 80 | |
| 81 | ret = clk_enable(iclk); |
| 82 | |
| 83 | if(ret) |
| 84 | { |
| 85 | dprintf(CRITICAL, "failed to set usb_iface_clk after async ret = %d\n", ret); |
| 86 | ASSERT(0); |
| 87 | } |
| 88 | |
| 89 | ret = clk_enable(cclk); |
| 90 | |
| 91 | if(ret) |
| 92 | { |
| 93 | dprintf(CRITICAL, "failed to set usb_iface_clk after async ret = %d\n", ret); |
| 94 | ASSERT(0); |
| 95 | } |
| 96 | |
Deepa Dinamani | 554b062 | 2013-05-16 15:00:30 -0700 | [diff] [blame] | 97 | } |
| 98 | |
| 99 | void clock_init_mmc(uint32_t interface) |
| 100 | { |
Sundarajan Srinivasan | 09374ed | 2013-06-18 13:29:32 -0700 | [diff] [blame] | 101 | char clk_name[64]; |
| 102 | int ret; |
| 103 | |
| 104 | snprintf(clk_name, 64, "sdc%u_iface_clk", interface); |
| 105 | |
| 106 | /* enable interface clock */ |
| 107 | ret = clk_get_set_enable(clk_name, 0, 1); |
| 108 | if(ret) |
| 109 | { |
| 110 | dprintf(CRITICAL, "failed to set sdc%u_iface_clk ret = %d\n", interface, ret); |
| 111 | ASSERT(0); |
| 112 | } |
Deepa Dinamani | 554b062 | 2013-05-16 15:00:30 -0700 | [diff] [blame] | 113 | } |
| 114 | |
| 115 | /* Configure MMC clock */ |
| 116 | void clock_config_mmc(uint32_t interface, uint32_t freq) |
| 117 | { |
Sundarajan Srinivasan | 09374ed | 2013-06-18 13:29:32 -0700 | [diff] [blame] | 118 | int ret; |
| 119 | uint32_t reg; |
| 120 | char clk_name[64]; |
| 121 | |
| 122 | snprintf(clk_name, 64, "sdc%u_core_clk", interface); |
| 123 | |
Sundarajan Srinivasan | 09374ed | 2013-06-18 13:29:32 -0700 | [diff] [blame] | 124 | if(freq == MMC_CLK_400KHZ) |
| 125 | { |
| 126 | ret = clk_get_set_enable(clk_name, 400000, 1); |
| 127 | } |
Channagoud Kadabi | 908353c | 2013-09-23 11:38:48 -0700 | [diff] [blame] | 128 | else if(freq == MMC_CLK_25MHZ) |
| 129 | { |
| 130 | ret = clk_get_set_enable(clk_name, 25000000, 1); |
| 131 | } |
Sundarajan Srinivasan | 09374ed | 2013-06-18 13:29:32 -0700 | [diff] [blame] | 132 | else if(freq == MMC_CLK_50MHZ) |
| 133 | { |
| 134 | ret = clk_get_set_enable(clk_name, 50000000, 1); |
| 135 | } |
| 136 | else if(freq == MMC_CLK_96MHZ) |
| 137 | { |
| 138 | ret = clk_get_set_enable(clk_name, 100000000, 1); |
| 139 | } |
Channagoud Kadabi | de9b2d3 | 2013-11-08 13:24:47 -0800 | [diff] [blame] | 140 | else if(freq == MMC_CLK_192MHZ) |
Sundarajan Srinivasan | 09374ed | 2013-06-18 13:29:32 -0700 | [diff] [blame] | 141 | { |
Channagoud Kadabi | 908353c | 2013-09-23 11:38:48 -0700 | [diff] [blame] | 142 | ret = clk_get_set_enable(clk_name, 192000000, 1); |
| 143 | } |
Channagoud Kadabi | de9b2d3 | 2013-11-08 13:24:47 -0800 | [diff] [blame] | 144 | else if(freq == MMC_CLK_200MHZ) |
| 145 | { |
| 146 | ret = clk_get_set_enable(clk_name, 200000000, 1); |
| 147 | } |
Channagoud Kadabi | 908353c | 2013-09-23 11:38:48 -0700 | [diff] [blame] | 148 | else if(freq == MMC_CLK_400MHZ) |
| 149 | { |
| 150 | ret = clk_get_set_enable(clk_name, 384000000, 1); |
Sundarajan Srinivasan | 09374ed | 2013-06-18 13:29:32 -0700 | [diff] [blame] | 151 | } |
| 152 | else |
| 153 | { |
| 154 | dprintf(CRITICAL, "sdc frequency (%u) is not supported\n", freq); |
| 155 | ASSERT(0); |
| 156 | } |
| 157 | |
| 158 | |
| 159 | if(ret) |
| 160 | { |
| 161 | dprintf(CRITICAL, "failed to set sdc%u_core_clk ret = %d\n", interface, ret); |
| 162 | ASSERT(0); |
| 163 | } |
| 164 | |
Deepa Dinamani | 554b062 | 2013-05-16 15:00:30 -0700 | [diff] [blame] | 165 | } |
| 166 | |
Channagoud Kadabi | 908353c | 2013-09-23 11:38:48 -0700 | [diff] [blame] | 167 | /* Configure clocks for SDCC Calibration circuit */ |
| 168 | void clock_config_cdc(uint32_t interface) |
| 169 | { |
| 170 | int ret = 0; |
| 171 | char clk_name[64]; |
| 172 | |
| 173 | snprintf(clk_name, sizeof(clk_name), "gcc_sdcc%u_cdccal_sleep_clk", interface); |
| 174 | |
| 175 | ret = clk_get_set_enable(clk_name, 0 , 1); |
| 176 | if (ret) |
| 177 | { |
| 178 | dprintf(CRITICAL, "Failed to enable clock: %s\n", clk_name); |
| 179 | ASSERT(0); |
| 180 | } |
| 181 | |
| 182 | snprintf(clk_name, sizeof(clk_name), "gcc_sdcc%u_cdccal_ff_clk", interface); |
| 183 | ret = clk_get_set_enable(clk_name, 0 , 1); |
| 184 | if (ret) |
| 185 | { |
| 186 | dprintf(CRITICAL, "Failed to enable clock: %s\n", clk_name); |
| 187 | ASSERT(0); |
| 188 | } |
| 189 | } |
| 190 | |
Deepa Dinamani | 554b062 | 2013-05-16 15:00:30 -0700 | [diff] [blame] | 191 | /* Configure UART clock based on the UART block id*/ |
| 192 | void clock_config_uart_dm(uint8_t id) |
| 193 | { |
Sundarajan Srinivasan | 09374ed | 2013-06-18 13:29:32 -0700 | [diff] [blame] | 194 | int ret; |
| 195 | char iclk[64]; |
| 196 | char cclk[64]; |
| 197 | |
| 198 | snprintf(iclk, 64, "uart%u_iface_clk", id); |
| 199 | snprintf(cclk, 64, "uart%u_core_clk", id); |
| 200 | |
| 201 | ret = clk_get_set_enable(iclk, 0, 1); |
| 202 | if(ret) |
| 203 | { |
| 204 | dprintf(CRITICAL, "failed to set uart%u_iface_clk ret = %d\n", id, ret); |
| 205 | ASSERT(0); |
| 206 | } |
| 207 | |
| 208 | ret = clk_get_set_enable(cclk, 7372800, 1); |
| 209 | if(ret) |
| 210 | { |
| 211 | dprintf(CRITICAL, "failed to set uart%u_core_clk ret = %d\n", id, ret); |
| 212 | ASSERT(0); |
| 213 | } |
Deepa Dinamani | 554b062 | 2013-05-16 15:00:30 -0700 | [diff] [blame] | 214 | } |
| 215 | |
| 216 | /* Function to asynchronously reset CE (Crypto Engine). |
| 217 | * Function assumes that all the CE clocks are off. |
| 218 | */ |
| 219 | static void ce_async_reset(uint8_t instance) |
| 220 | { |
Sundarajan Srinivasan | 21263d6 | 2013-11-19 11:49:38 -0800 | [diff] [blame] | 221 | if (instance == 1) |
| 222 | { |
| 223 | /* Start the block reset for CE */ |
| 224 | writel(1, GCC_CE1_BCR); |
| 225 | |
| 226 | udelay(2); |
| 227 | |
| 228 | /* Take CE block out of reset */ |
| 229 | writel(0, GCC_CE1_BCR); |
| 230 | |
| 231 | udelay(2); |
| 232 | } |
| 233 | else if (instance == 2) |
| 234 | { |
| 235 | /* Start the block reset for CE */ |
| 236 | writel(1, GCC_CE2_BCR); |
| 237 | |
| 238 | udelay(2); |
| 239 | |
| 240 | /* Take CE block out of reset */ |
| 241 | writel(0, GCC_CE2_BCR); |
| 242 | |
| 243 | udelay(2); |
| 244 | } |
| 245 | else |
| 246 | { |
| 247 | dprintf(CRITICAL, "CE instance not supported instance = %d", instance); |
| 248 | ASSERT(0); |
| 249 | } |
Deepa Dinamani | 554b062 | 2013-05-16 15:00:30 -0700 | [diff] [blame] | 250 | } |
| 251 | |
| 252 | void clock_ce_enable(uint8_t instance) |
| 253 | { |
Sundarajan Srinivasan | 21263d6 | 2013-11-19 11:49:38 -0800 | [diff] [blame] | 254 | int ret; |
| 255 | char clk_name[64]; |
| 256 | |
| 257 | snprintf(clk_name, sizeof(clk_name), "ce%u_src_clk", instance); |
| 258 | ret = clk_get_set_enable(clk_name, 100000000, 1); |
| 259 | if(ret) |
| 260 | { |
| 261 | dprintf(CRITICAL, "failed to set %s ret = %d\n", clk_name, ret); |
| 262 | ASSERT(0); |
| 263 | } |
| 264 | |
| 265 | snprintf(clk_name, sizeof(clk_name), "ce%u_core_clk", instance); |
| 266 | ret = clk_get_set_enable(clk_name, 0, 1); |
| 267 | if(ret) |
| 268 | { |
| 269 | dprintf(CRITICAL, "failed to set %s ret = %d\n", clk_name, ret); |
| 270 | ASSERT(0); |
| 271 | } |
| 272 | |
| 273 | snprintf(clk_name, sizeof(clk_name), "ce%u_ahb_clk", instance); |
| 274 | ret = clk_get_set_enable(clk_name, 0, 1); |
| 275 | if(ret) |
| 276 | { |
| 277 | dprintf(CRITICAL, "failed to set %s ret = %d\n", clk_name, ret); |
| 278 | ASSERT(0); |
| 279 | } |
| 280 | |
| 281 | snprintf(clk_name, sizeof(clk_name), "ce%u_axi_clk", instance); |
| 282 | ret = clk_get_set_enable(clk_name, 0, 1); |
| 283 | if(ret) |
| 284 | { |
| 285 | dprintf(CRITICAL, "failed to set %s ret = %d\n", clk_name, ret); |
| 286 | ASSERT(0); |
| 287 | } |
| 288 | |
| 289 | /* Wait for 48 * #pipes cycles. |
| 290 | * This is necessary as immediately after an access control reset (boot up) |
| 291 | * or a debug re-enable, the Crypto core sequentially clears its internal |
| 292 | * pipe key storage memory. If pipe key initialization writes are attempted |
| 293 | * during this time, they may be overwritten by the internal clearing logic. |
| 294 | */ |
| 295 | udelay(1); |
Deepa Dinamani | 554b062 | 2013-05-16 15:00:30 -0700 | [diff] [blame] | 296 | } |
| 297 | |
| 298 | void clock_ce_disable(uint8_t instance) |
| 299 | { |
Sundarajan Srinivasan | 21263d6 | 2013-11-19 11:49:38 -0800 | [diff] [blame] | 300 | struct clk *ahb_clk; |
| 301 | struct clk *cclk; |
| 302 | struct clk *axi_clk; |
| 303 | struct clk *src_clk; |
| 304 | char clk_name[64]; |
| 305 | |
| 306 | snprintf(clk_name, sizeof(clk_name), "ce%u_src_clk", instance); |
| 307 | src_clk = clk_get(clk_name); |
| 308 | |
| 309 | snprintf(clk_name, sizeof(clk_name), "ce%u_ahb_clk", instance); |
| 310 | ahb_clk = clk_get(clk_name); |
| 311 | |
| 312 | snprintf(clk_name, sizeof(clk_name), "ce%u_axi_clk", instance); |
| 313 | axi_clk = clk_get(clk_name); |
| 314 | |
| 315 | snprintf(clk_name, sizeof(clk_name), "ce%u_core_clk", instance); |
| 316 | cclk = clk_get(clk_name); |
| 317 | |
| 318 | clk_disable(ahb_clk); |
| 319 | clk_disable(axi_clk); |
| 320 | clk_disable(cclk); |
| 321 | clk_disable(src_clk); |
| 322 | |
| 323 | /* Some delay for the clocks to stabalize. */ |
| 324 | udelay(1); |
Deepa Dinamani | 554b062 | 2013-05-16 15:00:30 -0700 | [diff] [blame] | 325 | } |
| 326 | |
| 327 | void clock_config_ce(uint8_t instance) |
| 328 | { |
| 329 | /* Need to enable the clock before disabling since the clk_disable() |
| 330 | * has a check to default to nop when the clk_enable() is not called |
| 331 | * on that particular clock. |
| 332 | */ |
| 333 | clock_ce_enable(instance); |
| 334 | |
| 335 | clock_ce_disable(instance); |
| 336 | |
| 337 | ce_async_reset(instance); |
| 338 | |
| 339 | clock_ce_enable(instance); |
| 340 | |
| 341 | } |
Amol Jadi | 0a4c9b4 | 2013-10-11 14:22:11 -0700 | [diff] [blame] | 342 | |
| 343 | void clock_usb30_gdsc_enable(void) |
| 344 | { |
| 345 | uint32_t reg = readl(GCC_USB30_GDSCR); |
| 346 | |
| 347 | reg &= ~(0x1); |
| 348 | |
| 349 | writel(reg, GCC_USB30_GDSCR); |
| 350 | } |
| 351 | |
| 352 | /* enables usb30 interface and master clocks */ |
| 353 | void clock_usb30_init(void) |
| 354 | { |
| 355 | int ret; |
| 356 | |
| 357 | /* interface clock */ |
| 358 | ret = clk_get_set_enable("usb30_iface_clk", 0, 1); |
| 359 | if(ret) |
| 360 | { |
| 361 | dprintf(CRITICAL, "failed to set usb30_iface_clk. ret = %d\n", ret); |
| 362 | ASSERT(0); |
| 363 | } |
| 364 | |
| 365 | clock_usb30_gdsc_enable(); |
| 366 | |
| 367 | /* master clock */ |
| 368 | ret = clk_get_set_enable("usb30_master_clk", 125000000, 1); |
| 369 | if(ret) |
| 370 | { |
| 371 | dprintf(CRITICAL, "failed to set usb30_master_clk. ret = %d\n", ret); |
| 372 | ASSERT(0); |
| 373 | } |
Channagoud Kadabi | ecea369 | 2014-02-04 17:05:13 -0800 | [diff] [blame] | 374 | |
| 375 | /* Enable pmic diff clock */ |
| 376 | pm8x41_diff_clock_ctrl(1); |
Amol Jadi | 0a4c9b4 | 2013-10-11 14:22:11 -0700 | [diff] [blame] | 377 | } |
Dhaval Patel | 4a87d52 | 2013-10-18 19:02:37 -0700 | [diff] [blame] | 378 | |
| 379 | void mdp_gdsc_ctrl(uint8_t enable) |
| 380 | { |
| 381 | uint32_t reg = 0; |
| 382 | reg = readl(MDP_GDSCR); |
| 383 | if (enable) { |
| 384 | if (!(reg & GDSC_POWER_ON_BIT)) { |
| 385 | reg &= ~(BIT(0) | GDSC_EN_FEW_WAIT_MASK); |
| 386 | reg |= GDSC_EN_FEW_WAIT_256_MASK; |
| 387 | writel(reg, MDP_GDSCR); |
| 388 | while(!(readl(MDP_GDSCR) & (GDSC_POWER_ON_BIT))); |
| 389 | } else { |
| 390 | dprintf(INFO, "MDP GDSC already enabled\n"); |
| 391 | } |
| 392 | } else { |
| 393 | reg |= BIT(0); |
| 394 | writel(reg, MDP_GDSCR); |
| 395 | while(readl(MDP_GDSCR) & (GDSC_POWER_ON_BIT)); |
| 396 | } |
| 397 | } |
| 398 | |
| 399 | /* Configure MDP clock */ |
| 400 | void mdp_clock_enable(void) |
| 401 | { |
| 402 | int ret; |
| 403 | |
| 404 | /* Set MDP clock to 240MHz */ |
| 405 | ret = clk_get_set_enable("mdp_ahb_clk", 0, 1); |
| 406 | if(ret) |
| 407 | { |
| 408 | dprintf(CRITICAL, "failed to set mdp_ahb_clk ret = %d\n", ret); |
| 409 | ASSERT(0); |
| 410 | } |
| 411 | |
| 412 | ret = clk_get_set_enable("mdss_mdp_clk_src", 240000000, 1); |
| 413 | if(ret) |
| 414 | { |
| 415 | dprintf(CRITICAL, "failed to set mdp_clk_src ret = %d\n", ret); |
| 416 | ASSERT(0); |
| 417 | } |
| 418 | |
| 419 | ret = clk_get_set_enable("mdss_vsync_clk", 0, 1); |
| 420 | if(ret) |
| 421 | { |
| 422 | dprintf(CRITICAL, "failed to set mdss vsync clk ret = %d\n", ret); |
| 423 | ASSERT(0); |
| 424 | } |
| 425 | |
| 426 | ret = clk_get_set_enable("mdss_mdp_clk", 0, 1); |
| 427 | if(ret) |
| 428 | { |
| 429 | dprintf(CRITICAL, "failed to set mdp_clk ret = %d\n", ret); |
| 430 | ASSERT(0); |
| 431 | } |
| 432 | |
| 433 | ret = clk_get_set_enable("mdss_mdp_lut_clk", 0, 1); |
| 434 | if(ret) |
| 435 | { |
| 436 | dprintf(CRITICAL, "failed to set lut_mdp clk ret = %d\n", ret); |
| 437 | ASSERT(0); |
| 438 | } |
| 439 | } |
| 440 | |
| 441 | void mdp_clock_disable() |
| 442 | { |
| 443 | clk_disable(clk_get("mdss_vsync_clk")); |
| 444 | clk_disable(clk_get("mdss_mdp_clk")); |
| 445 | clk_disable(clk_get("mdss_mdp_lut_clk")); |
| 446 | clk_disable(clk_get("mdss_mdp_clk_src")); |
| 447 | clk_disable(clk_get("mdp_ahb_clk")); |
| 448 | |
| 449 | } |
| 450 | |
| 451 | void mmss_bus_clock_enable(void) |
| 452 | { |
| 453 | int ret; |
| 454 | /* Configure MMSSNOC AXI clock */ |
| 455 | ret = clk_get_set_enable("mmss_mmssnoc_axi_clk", 100000000, 1); |
| 456 | if(ret) |
| 457 | { |
| 458 | dprintf(CRITICAL, "failed to set mmssnoc_axi_clk ret = %d\n", ret); |
| 459 | ASSERT(0); |
| 460 | } |
| 461 | |
| 462 | /* Configure S0 AXI clock */ |
| 463 | ret = clk_get_set_enable("mmss_s0_axi_clk", 100000000, 1); |
| 464 | if(ret) |
| 465 | { |
| 466 | dprintf(CRITICAL, "failed to set mmss_s0_axi_clk ret = %d\n", ret); |
| 467 | ASSERT(0); |
| 468 | } |
| 469 | |
| 470 | /* Configure AXI clock */ |
| 471 | ret = clk_get_set_enable("mdss_axi_clk", 100000000, 1); |
| 472 | if(ret) |
| 473 | { |
| 474 | dprintf(CRITICAL, "failed to set mdss_axi_clk ret = %d\n", ret); |
| 475 | ASSERT(0); |
| 476 | } |
| 477 | } |
| 478 | |
| 479 | void mmss_bus_clock_disable(void) |
| 480 | { |
| 481 | /* Disable MDSS AXI clock */ |
| 482 | clk_disable(clk_get("mdss_axi_clk")); |
| 483 | |
| 484 | /* Disable MMSSNOC S0AXI clock */ |
| 485 | clk_disable(clk_get("mmss_s0_axi_clk")); |
| 486 | |
| 487 | /* Disable MMSSNOC AXI clock */ |
| 488 | clk_disable(clk_get("mmss_mmssnoc_axi_clk")); |
| 489 | } |
| 490 | |
| 491 | void mmss_dsi_clock_enable(uint32_t dsi_pixel0_cfg_rcgr, uint32_t dual_dsi, |
| 492 | uint8_t pclk0_m, uint8_t pclk0_n, uint8_t pclk0_d) |
| 493 | { |
| 494 | int ret; |
| 495 | |
| 496 | /* Configure Byte clock -autopll- This will not change because |
| 497 | byte clock does not need any divider*/ |
| 498 | writel(0x100, DSI_BYTE0_CFG_RCGR); |
| 499 | writel(0x1, DSI_BYTE0_CMD_RCGR); |
| 500 | writel(0x1, DSI_BYTE0_CBCR); |
| 501 | |
| 502 | /* Configure Pixel clock */ |
| 503 | writel(dsi_pixel0_cfg_rcgr, DSI_PIXEL0_CFG_RCGR); |
| 504 | writel(0x1, DSI_PIXEL0_CMD_RCGR); |
| 505 | writel(0x1, DSI_PIXEL0_CBCR); |
| 506 | |
| 507 | writel(pclk0_m, DSI_PIXEL0_M); |
| 508 | writel(pclk0_n, DSI_PIXEL0_N); |
| 509 | writel(pclk0_d, DSI_PIXEL0_D); |
| 510 | |
| 511 | /* Configure ESC clock */ |
| 512 | ret = clk_get_set_enable("mdss_esc0_clk", 0, 1); |
| 513 | if(ret) |
| 514 | { |
| 515 | dprintf(CRITICAL, "failed to set esc0_clk ret = %d\n", ret); |
| 516 | ASSERT(0); |
| 517 | } |
| 518 | |
| 519 | if (dual_dsi) { |
| 520 | /* Configure Byte 1 clock */ |
| 521 | writel(0x100, DSI_BYTE1_CFG_RCGR); |
| 522 | writel(0x1, DSI_BYTE1_CMD_RCGR); |
| 523 | writel(0x1, DSI_BYTE1_CBCR); |
| 524 | |
| 525 | /* Configure Pixel clock */ |
| 526 | writel(dsi_pixel0_cfg_rcgr, DSI_PIXEL1_CFG_RCGR); |
| 527 | writel(0x1, DSI_PIXEL1_CMD_RCGR); |
| 528 | writel(0x1, DSI_PIXEL1_CBCR); |
| 529 | |
Dhaval Patel | 3980fc0 | 2013-10-25 12:16:52 -0700 | [diff] [blame] | 530 | writel(pclk0_m, DSI_PIXEL1_M); |
| 531 | writel(pclk0_n, DSI_PIXEL1_N); |
| 532 | writel(pclk0_d, DSI_PIXEL1_D); |
Dhaval Patel | 4a87d52 | 2013-10-18 19:02:37 -0700 | [diff] [blame] | 533 | |
| 534 | /* Configure ESC clock */ |
| 535 | ret = clk_get_set_enable("mdss_esc1_clk", 0, 1); |
| 536 | if(ret) |
| 537 | { |
| 538 | dprintf(CRITICAL, "failed to set esc1_clk ret = %d\n", ret); |
| 539 | ASSERT(0); |
| 540 | } |
| 541 | } |
| 542 | } |
| 543 | |
| 544 | void mmss_dsi_clock_disable(uint32_t dual_dsi) |
| 545 | { |
| 546 | /* Disable ESC clock */ |
| 547 | clk_disable(clk_get("mdss_esc0_clk")); |
| 548 | writel(0x0, DSI_BYTE0_CBCR); |
| 549 | writel(0x0, DSI_PIXEL0_CBCR); |
| 550 | |
| 551 | if (dual_dsi) { |
| 552 | /* Disable ESC clock */ |
| 553 | clk_disable(clk_get("mdss_esc1_clk")); |
| 554 | writel(0x0, DSI_BYTE1_CBCR); |
| 555 | writel(0x0, DSI_PIXEL1_CBCR); |
| 556 | } |
| 557 | } |
Kuogee Hsieh | acc3194 | 2014-06-17 15:12:10 -0700 | [diff] [blame] | 558 | |
Ajay Singh Parmar | fa6450d | 2014-07-23 23:06:29 -0700 | [diff] [blame] | 559 | void hdmi_clk_enable(void) |
| 560 | { |
| 561 | int ret; |
| 562 | |
| 563 | /* Configure hdmi ahb clock */ |
| 564 | ret = clk_get_set_enable("hdmi_ahb_clk", 0, 1); |
| 565 | if(ret) { |
| 566 | dprintf(CRITICAL, "failed to set hdmi_ahb_clk ret = %d\n", ret); |
| 567 | ASSERT(0); |
| 568 | } |
| 569 | |
| 570 | /* Configure hdmi core clock */ |
| 571 | ret = clk_get_set_enable("hdmi_core_clk", 19200000, 1); |
| 572 | if(ret) { |
| 573 | dprintf(CRITICAL, "failed to set hdmi_core_clk ret = %d\n", ret); |
| 574 | ASSERT(0); |
| 575 | } |
| 576 | |
| 577 | /* Configure hdmi pixel clock */ |
| 578 | ret = clk_get_set_enable("hdmi_extp_clk", 148500000, 1); |
| 579 | if(ret) { |
| 580 | dprintf(CRITICAL, "failed to set hdmi_extp_clk ret = %d\n", ret); |
| 581 | ASSERT(0); |
| 582 | } |
| 583 | } |
| 584 | |
| 585 | void hdmi_clk_disable(void) |
| 586 | { |
| 587 | clk_disable(clk_get("hdmi_extp_clk")); |
| 588 | clk_disable(clk_get("hdmi_core_clk")); |
| 589 | clk_disable(clk_get("hdmi_ahb_clk")); |
| 590 | } |
| 591 | |
Kuogee Hsieh | acc3194 | 2014-06-17 15:12:10 -0700 | [diff] [blame] | 592 | void edp_clk_enable(void) |
| 593 | { |
| 594 | int ret; |
| 595 | |
| 596 | /* Configure MMSSNOC AXI clock */ |
| 597 | ret = clk_get_set_enable("mmss_mmssnoc_axi_clk", 100000000, 1); |
| 598 | if(ret) { |
| 599 | dprintf(CRITICAL, "failed to set mmssnoc_axi_clk ret = %d\n", ret); |
| 600 | ASSERT(0); |
| 601 | } |
| 602 | |
| 603 | /* Configure MMSSNOC AXI clock */ |
| 604 | ret = clk_get_set_enable("mmss_s0_axi_clk", 100000000, 1); |
| 605 | if(ret) { |
| 606 | dprintf(CRITICAL, "failed to set mmss_s0_axi_clk ret = %d\n", ret); |
| 607 | ASSERT(0); |
| 608 | } |
| 609 | |
| 610 | /* Configure AXI clock */ |
| 611 | ret = clk_get_set_enable("mdss_axi_clk", 100000000, 1); |
| 612 | if(ret) { |
| 613 | dprintf(CRITICAL, "failed to set mdss_axi_clk ret = %d\n", ret); |
| 614 | ASSERT(0); |
| 615 | } |
| 616 | |
| 617 | ret = clk_get_set_enable("edp_pixel_clk", 138500000, 1); |
| 618 | if (ret) { |
| 619 | dprintf(CRITICAL, "failed to set edp_pixel_clk ret = %d\n", |
| 620 | ret); |
| 621 | ASSERT(0); |
| 622 | } |
| 623 | |
| 624 | ret = clk_get_set_enable("edp_link_clk", 270000000, 1); |
| 625 | if (ret) { |
| 626 | dprintf(CRITICAL, "failed to set edp_link_clk ret = %d\n", ret); |
| 627 | ASSERT(0); |
| 628 | } |
| 629 | |
| 630 | ret = clk_get_set_enable("edp_aux_clk", 19200000, 1); |
| 631 | if (ret) { |
| 632 | dprintf(CRITICAL, "failed to set edp_aux_clk ret = %d\n", ret); |
| 633 | ASSERT(0); |
| 634 | } |
| 635 | } |
| 636 | |
| 637 | void edp_clk_disable(void) |
| 638 | { |
| 639 | |
| 640 | writel(0x0, MDSS_EDPPIXEL_CBCR); |
| 641 | writel(0x0, MDSS_EDPLINK_CBCR); |
| 642 | clk_disable(clk_get("edp_pixel_clk")); |
| 643 | clk_disable(clk_get("edp_link_clk")); |
| 644 | clk_disable(clk_get("edp_aux_clk")); |
| 645 | } |
| 646 | |