Channagoud Kadabi | de6bab0 | 2015-01-21 10:39:46 -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 <stdint.h> |
| 30 | #include <debug.h> |
| 31 | #include <reg.h> |
| 32 | #include <mmc.h> |
| 33 | #include <clock.h> |
| 34 | #include <platform/timer.h> |
| 35 | #include <platform/clock.h> |
| 36 | #include <platform/iomap.h> |
| 37 | #include <pm8x41.h> |
Channagoud Kadabi | 33686bb | 2015-06-29 11:59:46 -0700 | [diff] [blame] | 38 | #include <rpm-smd.h> |
| 39 | #include <regulator.h> |
| 40 | |
| 41 | #define RPM_CE_CLK_TYPE 0x6563 |
| 42 | #define CE1_CLK_ID 0x0 |
| 43 | #define RPM_SMD_KEY_RATE 0x007A484B |
| 44 | |
| 45 | uint32_t CE1_CLK[][8]= |
| 46 | { |
| 47 | { |
| 48 | RPM_CE_CLK_TYPE, CE1_CLK_ID, |
| 49 | KEY_SOFTWARE_ENABLE, 4, GENERIC_DISABLE, |
| 50 | RPM_SMD_KEY_RATE, 4, 0, |
| 51 | }, |
| 52 | { |
| 53 | RPM_CE_CLK_TYPE, CE1_CLK_ID, |
| 54 | KEY_SOFTWARE_ENABLE, 4, GENERIC_ENABLE, |
| 55 | RPM_SMD_KEY_RATE, 4, 176128, /* clk rate in KHZ */ |
| 56 | }, |
| 57 | }; |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 58 | |
| 59 | void clock_init_mmc(uint32_t interface) |
| 60 | { |
| 61 | char clk_name[64]; |
| 62 | int ret; |
| 63 | |
| 64 | snprintf(clk_name, sizeof(clk_name), "sdc%u_iface_clk", interface); |
| 65 | |
| 66 | /* enable interface clock */ |
| 67 | ret = clk_get_set_enable(clk_name, 0, true); |
| 68 | if(ret) |
| 69 | { |
| 70 | dprintf(CRITICAL, "failed to set sdc%u_iface_clk ret = %d\n", interface, ret); |
| 71 | ASSERT(0); |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | /* Configure MMC clock */ |
| 76 | void clock_config_mmc(uint32_t interface, uint32_t freq) |
| 77 | { |
| 78 | int ret = 0; |
| 79 | char clk_name[64]; |
| 80 | |
| 81 | snprintf(clk_name, sizeof(clk_name), "sdc%u_core_clk", interface); |
| 82 | |
| 83 | if(freq == MMC_CLK_400KHZ) |
| 84 | { |
| 85 | ret = clk_get_set_enable(clk_name, 400000, true); |
| 86 | } |
| 87 | else if(freq == MMC_CLK_50MHZ) |
| 88 | { |
| 89 | ret = clk_get_set_enable(clk_name, 50000000, true); |
| 90 | } |
| 91 | else if(freq == MMC_CLK_96MHZ) |
| 92 | { |
Channagoud Kadabi | 99d2370 | 2015-02-02 20:52:17 -0800 | [diff] [blame] | 93 | ret = clk_get_set_enable(clk_name, 96000000, true); |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 94 | } |
| 95 | else if(freq == MMC_CLK_192MHZ) |
| 96 | { |
| 97 | ret = clk_get_set_enable(clk_name, 192000000, true); |
| 98 | } |
Channagoud Kadabi | 99d2370 | 2015-02-02 20:52:17 -0800 | [diff] [blame] | 99 | else if(freq == MMC_CLK_400MHZ) |
| 100 | { |
| 101 | ret = clk_get_set_enable(clk_name, 384000000, 1); |
| 102 | } |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 103 | else |
| 104 | { |
| 105 | dprintf(CRITICAL, "sdc frequency (%u) is not supported\n", freq); |
| 106 | ASSERT(0); |
| 107 | } |
| 108 | |
| 109 | if(ret) |
| 110 | { |
| 111 | dprintf(CRITICAL, "failed to set sdc%u_core_clk ret = %d\n", interface, ret); |
| 112 | ASSERT(0); |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | /* Configure UART clock based on the UART block id*/ |
| 117 | void clock_config_uart_dm(uint8_t id) |
| 118 | { |
| 119 | int ret; |
| 120 | char iclk[64]; |
| 121 | char cclk[64]; |
| 122 | |
| 123 | snprintf(iclk, sizeof(iclk), "uart%u_iface_clk", id); |
| 124 | snprintf(cclk, sizeof(cclk), "uart%u_core_clk", id); |
| 125 | |
| 126 | ret = clk_get_set_enable(iclk, 0, true); |
| 127 | if(ret) |
| 128 | { |
| 129 | dprintf(CRITICAL, "failed to set uart%u_iface_clk ret = %d\n", id, ret); |
| 130 | ASSERT(0); |
| 131 | } |
| 132 | |
| 133 | ret = clk_get_set_enable(cclk, 7372800, true); |
| 134 | if(ret) |
| 135 | { |
| 136 | dprintf(CRITICAL, "failed to set uart%u_core_clk ret = %d\n", id, ret); |
| 137 | ASSERT(0); |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | /* Function to asynchronously reset CE (Crypto Engine). |
| 142 | * Function assumes that all the CE clocks are off. |
| 143 | */ |
| 144 | static void ce_async_reset(uint8_t instance) |
| 145 | { |
Channagoud Kadabi | 037c8b8 | 2015-02-05 12:09:32 -0800 | [diff] [blame] | 146 | if (instance == 1) |
| 147 | { |
| 148 | /* Start the block reset for CE */ |
| 149 | writel(1, GCC_CE1_BCR); |
| 150 | udelay(2); |
| 151 | /* Take CE block out of reset */ |
| 152 | writel(0, GCC_CE1_BCR); |
| 153 | udelay(2); |
| 154 | } |
| 155 | else |
| 156 | { |
| 157 | dprintf(CRITICAL, "Unsupported CE instance: %u\n", instance); |
| 158 | ASSERT(0); |
| 159 | } |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 160 | } |
| 161 | |
| 162 | void clock_ce_enable(uint8_t instance) |
| 163 | { |
Channagoud Kadabi | 33686bb | 2015-06-29 11:59:46 -0700 | [diff] [blame] | 164 | if (instance == 1) |
| 165 | rpm_send_data(&CE1_CLK[GENERIC_ENABLE][0], 24, RPM_REQUEST_TYPE); |
| 166 | else |
| 167 | { |
| 168 | dprintf(CRITICAL, "Unsupported CE instance: %u\n", instance); |
| 169 | ASSERT(0); |
| 170 | } |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 171 | } |
| 172 | |
| 173 | void clock_ce_disable(uint8_t instance) |
| 174 | { |
Channagoud Kadabi | 33686bb | 2015-06-29 11:59:46 -0700 | [diff] [blame] | 175 | if (instance == 1) |
| 176 | rpm_send_data(&CE1_CLK[GENERIC_DISABLE][0], 24, RPM_REQUEST_TYPE); |
| 177 | else |
| 178 | { |
| 179 | dprintf(CRITICAL, "Unsupported CE instance: %u\n", instance); |
| 180 | ASSERT(0); |
| 181 | } |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 182 | } |
| 183 | |
| 184 | void clock_config_ce(uint8_t instance) |
| 185 | { |
| 186 | /* Need to enable the clock before disabling since the clk_disable() |
| 187 | * has a check to default to nop when the clk_enable() is not called |
| 188 | * on that particular clock. |
| 189 | */ |
| 190 | clock_ce_enable(instance); |
| 191 | |
| 192 | clock_ce_disable(instance); |
| 193 | |
| 194 | ce_async_reset(instance); |
| 195 | |
| 196 | clock_ce_enable(instance); |
| 197 | |
| 198 | } |
| 199 | |
| 200 | void clock_usb30_gdsc_enable(void) |
| 201 | { |
| 202 | uint32_t reg = readl(GCC_USB30_GDSCR); |
| 203 | |
| 204 | reg &= ~(0x1); |
| 205 | |
| 206 | writel(reg, GCC_USB30_GDSCR); |
| 207 | } |
| 208 | |
| 209 | /* enables usb30 clocks */ |
| 210 | void clock_usb30_init(void) |
| 211 | { |
| 212 | int ret; |
| 213 | |
| 214 | ret = clk_get_set_enable("usb30_iface_clk", 0, true); |
| 215 | if(ret) |
| 216 | { |
| 217 | dprintf(CRITICAL, "failed to set usb30_iface_clk. ret = %d\n", ret); |
| 218 | ASSERT(0); |
| 219 | } |
| 220 | |
| 221 | clock_usb30_gdsc_enable(); |
| 222 | |
Channagoud Kadabi | df233d2 | 2015-02-11 11:56:48 -0800 | [diff] [blame] | 223 | ret = clk_get_set_enable("usb30_master_clk", 150000000, true); |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 224 | if(ret) |
| 225 | { |
| 226 | dprintf(CRITICAL, "failed to set usb30_master_clk. ret = %d\n", ret); |
| 227 | ASSERT(0); |
| 228 | } |
| 229 | |
Channagoud Kadabi | df233d2 | 2015-02-11 11:56:48 -0800 | [diff] [blame] | 230 | ret = clk_get_set_enable("gcc_aggre2_usb3_axi_clk", 150000000, true); |
| 231 | if (ret) |
| 232 | { |
| 233 | dprintf(CRITICAL, "failed to set aggre2_usb3_axi_clk, ret = %d\n", ret); |
| 234 | ASSERT(0); |
| 235 | } |
| 236 | |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 237 | ret = clk_get_set_enable("usb30_phy_aux_clk", 1200000, true); |
| 238 | if(ret) |
| 239 | { |
| 240 | dprintf(CRITICAL, "failed to set usb30_phy_aux_clk. ret = %d\n", ret); |
| 241 | ASSERT(0); |
| 242 | } |
| 243 | |
| 244 | ret = clk_get_set_enable("usb30_mock_utmi_clk", 60000000, true); |
| 245 | if(ret) |
| 246 | { |
| 247 | dprintf(CRITICAL, "failed to set usb30_mock_utmi_clk ret = %d\n", ret); |
| 248 | ASSERT(0); |
| 249 | } |
| 250 | |
| 251 | ret = clk_get_set_enable("usb30_sleep_clk", 0, true); |
| 252 | if(ret) |
| 253 | { |
| 254 | dprintf(CRITICAL, "failed to set usb30_sleep_clk ret = %d\n", ret); |
| 255 | ASSERT(0); |
| 256 | } |
| 257 | |
| 258 | ret = clk_get_set_enable("usb_phy_cfg_ahb2phy_clk", 0, true); |
| 259 | if(ret) |
| 260 | { |
| 261 | dprintf(CRITICAL, "failed to enable usb_phy_cfg_ahb2phy_clk = %d\n", ret); |
| 262 | ASSERT(0); |
| 263 | } |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 264 | } |
| 265 | |
| 266 | void clock_bumpup_pipe3_clk() |
| 267 | { |
| 268 | int ret = 0; |
| 269 | |
| 270 | ret = clk_get_set_enable("usb30_pipe_clk", 0, true); |
| 271 | if(ret) |
| 272 | { |
| 273 | dprintf(CRITICAL, "failed to set usb30_pipe_clk. ret = %d\n", ret); |
| 274 | ASSERT(0); |
| 275 | } |
| 276 | |
| 277 | return; |
| 278 | } |
| 279 | |
| 280 | void clock_reset_usb_phy() |
| 281 | { |
| 282 | int ret; |
| 283 | |
| 284 | struct clk *phy_reset_clk = NULL; |
| 285 | struct clk *pipe_reset_clk = NULL; |
Channagoud Kadabi | a42fb7d | 2015-06-24 12:50:01 -0700 | [diff] [blame] | 286 | struct clk *master_clk = NULL; |
| 287 | |
| 288 | master_clk = clk_get("usb30_master_clk"); |
| 289 | ASSERT(master_clk); |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 290 | |
| 291 | /* Look if phy com clock is present */ |
| 292 | phy_reset_clk = clk_get("usb30_phy_reset"); |
| 293 | ASSERT(phy_reset_clk); |
| 294 | |
| 295 | pipe_reset_clk = clk_get("usb30_pipe_clk"); |
| 296 | ASSERT(pipe_reset_clk); |
| 297 | |
| 298 | /* ASSERT */ |
Channagoud Kadabi | a42fb7d | 2015-06-24 12:50:01 -0700 | [diff] [blame] | 299 | ret = clk_reset(master_clk, CLK_RESET_ASSERT); |
| 300 | if (ret) |
| 301 | { |
| 302 | dprintf(CRITICAL, "Failed to assert usb30_master_reset clk\n"); |
| 303 | return; |
| 304 | } |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 305 | ret = clk_reset(phy_reset_clk, CLK_RESET_ASSERT); |
| 306 | |
| 307 | if (ret) |
| 308 | { |
| 309 | dprintf(CRITICAL, "Failed to assert usb30_phy_reset clk\n"); |
Channagoud Kadabi | a42fb7d | 2015-06-24 12:50:01 -0700 | [diff] [blame] | 310 | goto deassert_master_clk; |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 311 | } |
| 312 | |
| 313 | ret = clk_reset(pipe_reset_clk, CLK_RESET_ASSERT); |
| 314 | if (ret) |
| 315 | { |
| 316 | dprintf(CRITICAL, "Failed to assert usb30_pipe_clk\n"); |
| 317 | goto deassert_phy_clk; |
| 318 | } |
| 319 | |
| 320 | udelay(100); |
| 321 | |
| 322 | /* DEASSERT */ |
| 323 | ret = clk_reset(pipe_reset_clk, CLK_RESET_DEASSERT); |
| 324 | if (ret) |
| 325 | { |
| 326 | dprintf(CRITICAL, "Failed to deassert usb_pipe_clk\n"); |
| 327 | return; |
| 328 | } |
| 329 | |
| 330 | deassert_phy_clk: |
| 331 | |
| 332 | ret = clk_reset(phy_reset_clk, CLK_RESET_DEASSERT); |
| 333 | if (ret) |
| 334 | { |
| 335 | dprintf(CRITICAL, "Failed to deassert usb30_phy_com_reset clk\n"); |
| 336 | return; |
| 337 | } |
Channagoud Kadabi | a42fb7d | 2015-06-24 12:50:01 -0700 | [diff] [blame] | 338 | deassert_master_clk: |
| 339 | |
| 340 | ret = clk_reset(master_clk, CLK_RESET_DEASSERT); |
| 341 | if (ret) |
| 342 | { |
| 343 | dprintf(CRITICAL, "Failed to deassert usb30_master clk\n"); |
| 344 | return; |
| 345 | } |
| 346 | |
Channagoud Kadabi | ed60a8b | 2014-06-27 15:35:09 -0700 | [diff] [blame] | 347 | } |
Dhaval Patel | 0f3cbeb | 2015-03-17 11:52:12 -0700 | [diff] [blame] | 348 | |
| 349 | void mmss_gdsc_enable() |
| 350 | { |
| 351 | uint32_t reg = 0; |
| 352 | |
| 353 | reg = readl(MMAGIC_BIMC_GDSCR); |
| 354 | if (!(reg & GDSC_POWER_ON_BIT)) { |
| 355 | reg &= ~(BIT(0) | GDSC_EN_FEW_WAIT_MASK); |
| 356 | reg |= GDSC_EN_FEW_WAIT_256_MASK; |
| 357 | writel(reg, MMAGIC_BIMC_GDSCR); |
| 358 | while(!(readl(MMAGIC_BIMC_GDSCR) & (GDSC_POWER_ON_BIT))); |
| 359 | } else { |
| 360 | dprintf(SPEW, "MMAGIC BIMC GDSC already enabled\n"); |
| 361 | } |
| 362 | |
| 363 | reg = readl(MMAGIC_MDSS_GDSCR); |
| 364 | if (!(reg & GDSC_POWER_ON_BIT)) { |
| 365 | reg &= ~(BIT(0) | GDSC_EN_FEW_WAIT_MASK); |
| 366 | reg |= GDSC_EN_FEW_WAIT_256_MASK; |
| 367 | writel(reg, MMAGIC_MDSS_GDSCR); |
| 368 | while(!(readl(MMAGIC_MDSS_GDSCR) & (GDSC_POWER_ON_BIT))); |
| 369 | } else { |
| 370 | dprintf(SPEW, "MMAGIC MDSS GDSC already enabled\n"); |
| 371 | } |
| 372 | |
| 373 | reg = readl(MDSS_GDSCR); |
| 374 | if (!(reg & GDSC_POWER_ON_BIT)) { |
| 375 | reg &= ~(BIT(0) | GDSC_EN_FEW_WAIT_MASK); |
| 376 | reg |= GDSC_EN_FEW_WAIT_256_MASK; |
| 377 | writel(reg, MDSS_GDSCR); |
| 378 | while(!(readl(MDSS_GDSCR) & (GDSC_POWER_ON_BIT))); |
| 379 | } else { |
| 380 | dprintf(SPEW, "MDSS GDSC already enabled\n"); |
| 381 | } |
| 382 | } |
| 383 | |
| 384 | void mmss_gdsc_disable() |
| 385 | { |
| 386 | uint32_t reg = 0; |
| 387 | |
| 388 | reg = readl(MDSS_GDSCR); |
| 389 | reg |= BIT(0); |
| 390 | writel(reg, MDSS_GDSCR); |
| 391 | while(readl(MDSS_GDSCR) & (GDSC_POWER_ON_BIT)); |
| 392 | |
| 393 | reg = readl(MMAGIC_MDSS_GDSCR); |
| 394 | reg |= BIT(0); |
| 395 | writel(reg, MMAGIC_MDSS_GDSCR); |
| 396 | while(readl(MMAGIC_MDSS_GDSCR) & (GDSC_POWER_ON_BIT)); |
| 397 | |
| 398 | reg = readl(MMAGIC_BIMC_GDSCR); |
| 399 | reg |= BIT(0); |
| 400 | writel(reg, MMAGIC_BIMC_GDSCR); |
| 401 | while(readl(MMAGIC_BIMC_GDSCR) & (GDSC_POWER_ON_BIT)); |
| 402 | } |
| 403 | |
| 404 | void video_gdsc_enable() |
| 405 | { |
| 406 | uint32_t reg = 0; |
| 407 | |
| 408 | reg = readl(MMAGIC_VIDEO_GDSCR); |
| 409 | if (!(reg & GDSC_POWER_ON_BIT)) { |
| 410 | reg &= ~(BIT(0) | GDSC_EN_FEW_WAIT_MASK); |
| 411 | reg |= GDSC_EN_FEW_WAIT_256_MASK; |
| 412 | writel(reg, MMAGIC_VIDEO_GDSCR); |
| 413 | while(!(readl(MMAGIC_VIDEO_GDSCR) & (GDSC_POWER_ON_BIT))); |
| 414 | } else { |
| 415 | dprintf(SPEW, "VIDEO BIMC GDSC already enabled\n"); |
| 416 | } |
| 417 | |
| 418 | reg = readl(VIDEO_GDSCR); |
| 419 | if (!(reg & GDSC_POWER_ON_BIT)) { |
| 420 | reg &= ~(BIT(0) | GDSC_EN_FEW_WAIT_MASK); |
| 421 | reg |= GDSC_EN_FEW_WAIT_256_MASK; |
| 422 | writel(reg, VIDEO_GDSCR); |
| 423 | while(!(readl(VIDEO_GDSCR) & (GDSC_POWER_ON_BIT))); |
| 424 | } else { |
| 425 | dprintf(SPEW, "VIDEO GDSC already enabled\n"); |
| 426 | } |
| 427 | } |
| 428 | |
| 429 | void video_gdsc_disable() |
| 430 | { |
| 431 | uint32_t reg = 0; |
| 432 | |
| 433 | reg = readl(VIDEO_GDSCR); |
| 434 | reg |= BIT(0); |
| 435 | writel(reg, VIDEO_GDSCR); |
| 436 | while(readl(VIDEO_GDSCR) & (GDSC_POWER_ON_BIT)); |
| 437 | |
| 438 | reg = readl(MMAGIC_VIDEO_GDSCR); |
| 439 | reg |= BIT(0); |
| 440 | writel(reg, MMAGIC_VIDEO_GDSCR); |
| 441 | while(readl(MMAGIC_VIDEO_GDSCR) & (GDSC_POWER_ON_BIT)); |
| 442 | } |
| 443 | |
| 444 | /* Configure MDP clock */ |
| 445 | void mdp_clock_enable(void) |
| 446 | { |
| 447 | int ret; |
| 448 | |
| 449 | ret = clk_get_set_enable("mmss_mmagic_ahb_clk", 19200000, 1); |
| 450 | if(ret) |
| 451 | { |
| 452 | dprintf(CRITICAL, "failed to set mmagic_ahb_clk ret = %d\n", ret); |
| 453 | ASSERT(0); |
| 454 | } |
| 455 | |
| 456 | ret = clk_get_set_enable("smmu_mdp_ahb_clk", 0, 1); |
| 457 | if(ret) |
| 458 | { |
| 459 | dprintf(CRITICAL, "failed to set smmu_mdp_ahb_clk ret = %d\n", ret); |
| 460 | ASSERT(0); |
| 461 | } |
| 462 | |
| 463 | ret = clk_get_set_enable("mdp_ahb_clk", 0, 1); |
| 464 | if(ret) |
| 465 | { |
| 466 | dprintf(CRITICAL, "failed to set mdp_ahb_clk ret = %d\n", ret); |
| 467 | ASSERT(0); |
| 468 | } |
| 469 | |
| 470 | ret = clk_get_set_enable("mdss_mdp_clk", 320000000, 1); |
| 471 | if(ret) |
| 472 | { |
| 473 | dprintf(CRITICAL, "failed to set mdp_clk_src ret = %d\n", ret); |
| 474 | ASSERT(0); |
| 475 | } |
| 476 | |
| 477 | ret = clk_get_set_enable("mdss_vsync_clk", 0, 1); |
| 478 | if(ret) |
| 479 | { |
| 480 | dprintf(CRITICAL, "failed to set mdss vsync clk ret = %d\n", ret); |
| 481 | ASSERT(0); |
| 482 | } |
| 483 | |
| 484 | } |
| 485 | |
| 486 | void mdp_clock_disable() |
| 487 | { |
| 488 | clk_disable(clk_get("mdss_vsync_clk")); |
| 489 | clk_disable(clk_get("mdss_mdp_clk")); |
| 490 | clk_disable(clk_get("mdp_ahb_clk")); |
| 491 | clk_disable(clk_get("smmu_mdp_ahb_clk")); |
| 492 | clk_disable(clk_get("mmss_mmagic_ahb_clk")); |
| 493 | } |
| 494 | |
| 495 | void mmss_bus_clock_enable(void) |
| 496 | { |
| 497 | int ret; |
| 498 | ret = clk_get_set_enable("mmss_mmagic_axi_clk", 320000000, 1); |
| 499 | if(ret) |
| 500 | { |
| 501 | dprintf(CRITICAL, "failed to set mmss_mmagic_axi_clk ret = %d\n", ret); |
| 502 | ASSERT(0); |
| 503 | } |
| 504 | |
| 505 | ret = clk_get_set_enable("mmagic_bimc_axi_clk", 320000000, 1); |
| 506 | if(ret) |
| 507 | { |
| 508 | dprintf(CRITICAL, "failed to set mmss_s0_axi_clk ret = %d\n", ret); |
| 509 | ASSERT(0); |
| 510 | } |
| 511 | |
| 512 | ret = clk_get_set_enable("mmss_s0_axi_clk", 320000000, 1); |
| 513 | if(ret) |
| 514 | { |
| 515 | dprintf(CRITICAL, "failed to set mmss_s0_axi_clk ret = %d\n", ret); |
| 516 | ASSERT(0); |
| 517 | } |
| 518 | |
| 519 | ret = clk_get_set_enable("mmagic_mdss_axi_clk", 320000000, 1); |
| 520 | if(ret) |
| 521 | { |
| 522 | dprintf(CRITICAL, "failed to set mmss_mmagic_axi_clk ret = %d\n", ret); |
| 523 | ASSERT(0); |
| 524 | } |
| 525 | |
| 526 | ret = clk_get_set_enable("smmu_mdp_axi_clk", 320000000, 1); |
| 527 | if(ret) |
| 528 | { |
| 529 | dprintf(CRITICAL, "failed to set smmu_mdp_axi_clk ret = %d\n", ret); |
| 530 | ASSERT(0); |
| 531 | } |
| 532 | |
| 533 | ret = clk_get_set_enable("mdss_axi_clk", 320000000, 1); |
| 534 | if(ret) |
| 535 | { |
| 536 | dprintf(CRITICAL, "failed to set mdss_axi_clk ret = %d\n", ret); |
| 537 | ASSERT(0); |
| 538 | } |
| 539 | } |
| 540 | |
| 541 | void mmss_bus_clock_disable(void) |
| 542 | { |
| 543 | clk_disable(clk_get("mdss_axi_clk")); |
| 544 | clk_disable(clk_get("smmu_mdp_axi_clk")); |
| 545 | clk_disable(clk_get("mmagic_mdss_axi_clk")); |
| 546 | clk_disable(clk_get("mmss_s0_axi_clk")); |
| 547 | clk_disable(clk_get("mmagic_bimc_axi_clk")); |
| 548 | clk_disable(clk_get("mmss_mmagic_axi_clk")); |
| 549 | } |
| 550 | |
Aravind Venkateswaran | 9586be6 | 2015-05-20 00:51:06 -0700 | [diff] [blame] | 551 | void mmss_dsi_clock_enable(uint32_t cfg_rcgr, uint32_t flags) |
Dhaval Patel | 0f3cbeb | 2015-03-17 11:52:12 -0700 | [diff] [blame] | 552 | { |
| 553 | int ret; |
| 554 | |
| 555 | if (flags & MMSS_DSI_CLKS_FLAG_DSI0) { |
| 556 | /* Enable DSI0 branch clocks */ |
| 557 | |
Aravind Venkateswaran | 9586be6 | 2015-05-20 00:51:06 -0700 | [diff] [blame] | 558 | writel(cfg_rcgr, DSI_BYTE0_CFG_RCGR); |
Dhaval Patel | 0f3cbeb | 2015-03-17 11:52:12 -0700 | [diff] [blame] | 559 | writel(0x1, DSI_BYTE0_CMD_RCGR); |
| 560 | writel(0x1, DSI_BYTE0_CBCR); |
| 561 | |
Aravind Venkateswaran | 9586be6 | 2015-05-20 00:51:06 -0700 | [diff] [blame] | 562 | writel(cfg_rcgr, DSI_PIXEL0_CFG_RCGR); |
Dhaval Patel | 0f3cbeb | 2015-03-17 11:52:12 -0700 | [diff] [blame] | 563 | writel(0x1, DSI_PIXEL0_CMD_RCGR); |
| 564 | writel(0x1, DSI_PIXEL0_CBCR); |
| 565 | |
| 566 | ret = clk_get_set_enable("mdss_esc0_clk", 0, 1); |
| 567 | if(ret) |
| 568 | { |
| 569 | dprintf(CRITICAL, "failed to set esc0_clk ret = %d\n", ret); |
| 570 | ASSERT(0); |
| 571 | } |
| 572 | } |
| 573 | |
| 574 | if (flags & MMSS_DSI_CLKS_FLAG_DSI1) { |
| 575 | /* Enable DSI1 branch clocks */ |
Aravind Venkateswaran | 9586be6 | 2015-05-20 00:51:06 -0700 | [diff] [blame] | 576 | writel(cfg_rcgr, DSI_BYTE1_CFG_RCGR); |
Dhaval Patel | 0f3cbeb | 2015-03-17 11:52:12 -0700 | [diff] [blame] | 577 | writel(0x1, DSI_BYTE1_CMD_RCGR); |
| 578 | writel(0x1, DSI_BYTE1_CBCR); |
| 579 | |
Aravind Venkateswaran | 9586be6 | 2015-05-20 00:51:06 -0700 | [diff] [blame] | 580 | writel(cfg_rcgr, DSI_PIXEL1_CFG_RCGR); |
Dhaval Patel | 0f3cbeb | 2015-03-17 11:52:12 -0700 | [diff] [blame] | 581 | writel(0x1, DSI_PIXEL1_CMD_RCGR); |
| 582 | writel(0x1, DSI_PIXEL1_CBCR); |
| 583 | |
| 584 | ret = clk_get_set_enable("mdss_esc1_clk", 0, 1); |
| 585 | if(ret) |
| 586 | { |
| 587 | dprintf(CRITICAL, "failed to set esc1_clk ret = %d\n", ret); |
| 588 | ASSERT(0); |
| 589 | } |
| 590 | } |
| 591 | } |
| 592 | |
| 593 | void mmss_dsi_clock_disable(uint32_t flags) |
| 594 | { |
| 595 | if (flags & MMSS_DSI_CLKS_FLAG_DSI0) { |
| 596 | clk_disable(clk_get("mdss_esc0_clk")); |
| 597 | writel(0x0, DSI_BYTE0_CBCR); |
| 598 | writel(0x0, DSI_PIXEL0_CBCR); |
| 599 | } |
| 600 | |
| 601 | if (flags & MMSS_DSI_CLKS_FLAG_DSI1) { |
| 602 | clk_disable(clk_get("mdss_esc1_clk")); |
| 603 | writel(0x0, DSI_BYTE1_CBCR); |
| 604 | writel(0x0, DSI_PIXEL1_CBCR); |
| 605 | } |
| 606 | } |