From: Jang JeongHoon Date: Wed, 30 May 2018 06:09:56 +0000 (+0900) Subject: [9610] soc: samsung: cal-if: Added cal_dll_get[set]_rate API X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=cb1858ef1e50f59705ea551a16c548ceebd2dac5;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git [9610] soc: samsung: cal-if: Added cal_dll_get[set]_rate API Change-Id: I80bce1751e9aad5cc0134781116c44b4debe7512 Signed-off-by: Jang JeongHoon --- diff --git a/drivers/soc/samsung/cal-if/exynos9610/cal_data.c b/drivers/soc/samsung/cal-if/exynos9610/cal_data.c index da2eeac5b420..591f6245c287 100644 --- a/drivers/soc/samsung/cal-if/exynos9610/cal_data.c +++ b/drivers/soc/samsung/cal-if/exynos9610/cal_data.c @@ -194,6 +194,47 @@ int cal_dll_apm_enable(void) return 0; } +int cal_dll_set_rate(unsigned int rate) +{ + u32 timeout = 0; + u32 n_dco = 0; + + if (!dll_apm_base || !sysreg_apm_base) + return -EINVAL; + + n_dco = (rate / (2 * 32768)) - 1; + + /* DLL_APM_N_DCO settings */ + __raw_writel(n_dco, dll_apm_base + 0x4); + + /* Wait for DLL lock */ + while (1) { + if (__raw_readl(sysreg_apm_base + 0x0444) & 0x1) + break; + timeout++; + usleep_range(10, 11); + if (timeout > 1000) { + pr_err("%s, timed out during dll locking\n", __func__); + return -ETIMEDOUT; + } + } + + return 0; +} + +unsigned int cal_dll_get_rate(void) +{ + u32 n_dco = 0, rate = 0; + + if (!dll_apm_base) + return -EINVAL; + + n_dco = __raw_readl(dll_apm_base + 0x4) & 0x3fff; + rate = (n_dco + 1) * (2 * 32768); + + return rate; +} + int cal_dll_apm_disable(void) { u32 reg = 0;