static int gpu_clock_on(struct exynos_context *platform) { int ret = 0; if (!platform) return -ENODEV; #ifdef CONFIG_PM_RUNTIME if (platform->exynos_pm_domain) mutex_lock(&platform->exynos_pm_domain->access_lock); #endif /* CONFIG_PM_RUNTIME */ if (!gpu_is_power_on()) { GPU_LOG(DVFS_WARNING, DUMMY, 0u, 0u, "%s: can't set clock on in power off status\n", __func__); ret = -1; goto err_return; } if (platform->clk_g3d_status == 1) { ret = 0; goto err_return; } #if 0 if (!gpu_is_clock_on()) { if (aclk_g3d) { (void) clk_prepare_enable(aclk_g3d); GPU_LOG(DVFS_DEBUG, LSI_CLOCK_ON, 0u, 0u, "clock is enabled\n"); } } #ifdef GPU_DYNAMIC_CLK_GATING gpu_dcg_enable(platform); #endif /* GPU_DYNAMIC_CLK_GATING */ #endif platform->clk_g3d_status = 1; err_return: #ifdef CONFIG_PM_RUNTIME if (platform->exynos_pm_domain) mutex_unlock(&platform->exynos_pm_domain->access_lock); #endif /* CONFIG_PM_RUNTIME */ return ret; }
static int gpu_set_clock_to_osc(struct exynos_context *platform) { int ret = 0; #ifdef CONFIG_MALI_RT_PM if (platform->exynos_pm_domain) mutex_lock(&platform->exynos_pm_domain->access_lock); #endif /* CONFIG_MALI_RT_PM */ if (!gpu_is_power_on()) { ret = -1; GPU_LOG(DVFS_INFO, DUMMY, 0u, 0u, "%s: can't control clock in the power-off state!\n", __func__); goto err; } if (!gpu_is_clock_on()) { ret = -1; GPU_LOG(DVFS_INFO, DUMMY, 0u, 0u, "%s: can't control clock in the clock-off state!\n", __func__); goto err; } /* change the mux to osc */ ret = clk_set_parent(mout_g3d_pll, fin_pll); if (ret < 0) { GPU_LOG(DVFS_ERROR, DUMMY, 0u, 0u, "%s: failed to clk_set_parent [mout_g3d_pll]\n", __func__); goto err; } GPU_LOG(DVFS_DEBUG, LSI_CLOCK_VALUE, platform->cur_clock, gpu_get_cur_clock(platform), "clock set to soc: %d (%d)\n", gpu_get_cur_clock(platform), platform->cur_clock); err: #ifdef CONFIG_MALI_RT_PM if (platform->exynos_pm_domain) mutex_unlock(&platform->exynos_pm_domain->access_lock); #endif /* CONFIG_MALI_RT_PM */ return ret; }
static int gpu_set_clock(struct exynos_context *platform, int clk) { long g3d_rate_prev = -1; unsigned long g3d_rate = clk * MHZ; int ret = 0; if (aclk_g3d == 0) return -1; #ifdef CONFIG_MALI_RT_PM if (platform->exynos_pm_domain) mutex_lock(&platform->exynos_pm_domain->access_lock); #endif /* CONFIG_MALI_RT_PM */ if (!gpu_is_power_on()) { ret = -1; GPU_LOG(DVFS_INFO, DUMMY, 0u, 0u, "%s: can't set clock in the power-off state!\n", __func__); goto err; } if (!gpu_is_clock_on()) { ret = -1; GPU_LOG(DVFS_INFO, DUMMY, 0u, 0u, "%s: can't set clock in the clock-off state! %d\n", __func__, __raw_readl(EXYNOS5430_ENABLE_ACLK_G3D)); goto err; } g3d_rate_prev = clk_get_rate(aclk_g3d); /* if changed the VPLL rate, set rate for VPLL and wait for lock time */ if (g3d_rate != g3d_rate_prev) { /*change here for future stable clock changing*/ ret = clk_set_parent(mout_g3d_pll, fin_pll); if (ret < 0) { GPU_LOG(DVFS_ERROR, DUMMY, 0u, 0u, "%s: failed to clk_set_parent [mout_g3d_pll]\n", __func__); goto err; } if (g3d_rate_prev != GPU_OSC_CLK) sec_debug_aux_log(SEC_DEBUG_AUXLOG_CPU_BUS_CLOCK_CHANGE, "[GPU] %7d <= %7d", g3d_rate / 1000, g3d_rate_prev / 1000); /*change g3d pll*/ ret = clk_set_rate(fout_g3d_pll, g3d_rate); if (ret < 0) { GPU_LOG(DVFS_ERROR, DUMMY, 0u, 0u, "%s: failed to clk_set_rate [fout_g3d_pll]\n", __func__); goto err; } /*restore parent*/ ret = clk_set_parent(mout_g3d_pll, fout_g3d_pll); if (ret < 0) { GPU_LOG(DVFS_ERROR, DUMMY, 0u, 0u, "%s: failed to clk_set_parent [mout_g3d_pll]\n", __func__); goto err; } } platform->cur_clock = gpu_get_cur_clock(platform); if (platform->cur_clock != clk_get_rate(fout_g3d_pll)/MHZ) GPU_LOG(DVFS_ERROR, DUMMY, 0u, 0u, "clock value is wrong (aclk_g3d: %d, fout_g3d_pll: %d)\n", platform->cur_clock, (int) clk_get_rate(fout_g3d_pll)/MHZ); if (g3d_rate != g3d_rate_prev) GPU_LOG(DVFS_DEBUG, LSI_CLOCK_VALUE, g3d_rate/MHZ, platform->cur_clock, "clock set: %d, clock get: %d\n", (int) g3d_rate/MHZ, platform->cur_clock); err: #ifdef CONFIG_MALI_RT_PM if (platform->exynos_pm_domain) mutex_unlock(&platform->exynos_pm_domain->access_lock); #endif /* CONFIG_MALI_RT_PM */ return ret; }
static int gpu_set_clock(struct exynos_context *platform, int clk) { long g3d_rate_prev = -1; unsigned long g3d_rate = clk * MHZ; int ret = 0; #if 0 if (aclk_g3d == 0) return -1; #endif #ifdef CONFIG_PM_RUNTIME if (platform->exynos_pm_domain) mutex_lock(&platform->exynos_pm_domain->access_lock); #endif /* CONFIG_PM_RUNTIME */ if (!gpu_is_power_on()) { ret = -1; GPU_LOG(DVFS_INFO, DUMMY, 0u, 0u, "%s: can't set clock in the power-off state!\n", __func__); goto err; } if (!gpu_is_clock_on()) { ret = -1; GPU_LOG(DVFS_INFO, DUMMY, 0u, 0u, "%s: can't set clock in the clock-off state!\n", __func__); goto err; } #if 0 g3d_rate_prev = clk_get_rate(fout_g3d_pll); /* if changed the VPLL rate, set rate for VPLL and wait for lock time */ if (g3d_rate != g3d_rate_prev) { ret = gpu_set_maximum_outstanding_req(L2CONFIG_MO_1BY8); if (ret < 0) GPU_LOG(DVFS_ERROR, DUMMY, 0u, 0u, "%s: failed to set MO (%d)\n", __func__, ret); /*change here for future stable clock changing*/ ret = clk_set_parent(mout_g3d_pll, fin_pll); if (ret < 0) { GPU_LOG(DVFS_ERROR, DUMMY, 0u, 0u, "%s: failed to clk_set_parent [mout_g3d_pll]\n", __func__); goto err; } /*change g3d pll*/ ret = clk_set_rate(fout_g3d_pll, g3d_rate); if (ret < 0) { GPU_LOG(DVFS_ERROR, DUMMY, 0u, 0u, "%s: failed to clk_set_rate [fout_g3d_pll]\n", __func__); goto err; } /*restore parent*/ ret = clk_set_parent(mout_g3d_pll, fout_g3d_pll); if (ret < 0) { GPU_LOG(DVFS_ERROR, DUMMY, 0u, 0u, "%s: failed to clk_set_parent [mout_g3d_pll]\n", __func__); goto err; } #ifdef CONFIG_SOC_EXYNOS5433_REV_0 /*restore parent*/ ret = clk_set_parent(mout_aclk_g3d, aclk_g3d); if (ret < 0) { GPU_LOG(DVFS_ERROR, DUMMY, 0u, 0u, "%s: failed to clk_set_parent [mout_ack_g3d]\n", __func__); goto err; } #endif /* CONFIG_SOC_EXYNOS5433_REV_0 */ ret = gpu_set_maximum_outstanding_req(L2CONFIG_MO_NO_RESTRICT); if (ret < 0) GPU_LOG(DVFS_ERROR, DUMMY, 0u, 0u, "%s: failed to restore MO (%d)\n", __func__, ret); g3d_rate_prev = g3d_rate; } #endif platform->cur_clock = gpu_get_cur_clock(platform); GPU_LOG(DVFS_DEBUG, LSI_CLOCK_VALUE, 0u, g3d_rate/MHZ, "clock set: %ld\n", g3d_rate/MHZ); GPU_LOG(DVFS_DEBUG, LSI_CLOCK_VALUE, 0u, platform->cur_clock, "clock get: %d\n", platform->cur_clock); err: #ifdef CONFIG_PM_RUNTIME if (platform->exynos_pm_domain) mutex_unlock(&platform->exynos_pm_domain->access_lock); #endif /* CONFIG_PM_RUNTIME */ return ret; }