From 30de7ab4f72d8ea4bf98bbad25f43083e982283a Mon Sep 17 00:00:00 2001 From: Peter Boonstoppel Date: Tue, 25 Oct 2016 12:59:01 -0700 Subject: gpu: nvgpu: Support new fuse driver for gm20b Tegra fuse driver no longer supported on k4.4 Bug 200233943 Change-Id: I31b58d947436a51ff57b16f7903e9ef8daaf66fc Signed-off-by: Peter Boonstoppel Reviewed-on: http://git-master/r/1242480 GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom --- drivers/gpu/nvgpu/gm20b/clk_gm20b.c | 49 +++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'drivers/gpu/nvgpu/gm20b/clk_gm20b.c') diff --git a/drivers/gpu/nvgpu/gm20b/clk_gm20b.c b/drivers/gpu/nvgpu/gm20b/clk_gm20b.c index 54406008..8b70930a 100644 --- a/drivers/gpu/nvgpu/gm20b/clk_gm20b.c +++ b/drivers/gpu/nvgpu/gm20b/clk_gm20b.c @@ -22,7 +22,11 @@ #include #include #include +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)) +#include +#else #include +#endif #include "gk20a/gk20a.h" #include "hw_trim_gm20b.h" @@ -240,6 +244,51 @@ found_match: /* GPCPLL NA/DVFS mode methods */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)) +#define FUSE_RESERVED_CALIB 0x204 + +static inline int fuse_get_gpcpll_adc_rev(u32 val) +{ + return (val >> 30) & 0x3; +} + +static inline int fuse_get_gpcpll_adc_slope_uv(u32 val) +{ + /* Integer part in mV * 1000 + fractional part in uV */ + return ((val >> 24) & 0x3f) * 1000 + ((val >> 14) & 0x3ff); +} + +static inline int fuse_get_gpcpll_adc_intercept_uv(u32 val) +{ + /* Integer part in mV * 1000 + fractional part in 100uV */ + return ((val >> 4) & 0x3ff) * 1000 + ((val >> 0) & 0xf) * 100; +} + +static int tegra_fuse_calib_gpcpll_get_adc(int *slope_uv, int *intercept_uv) +{ + u32 val; + int ret; + + ret = tegra_fuse_readl(FUSE_RESERVED_CALIB, &val); + if (ret) + return ret; + + if (!fuse_get_gpcpll_adc_rev(val)) + return -EINVAL; + + *slope_uv = fuse_get_gpcpll_adc_slope_uv(val); + *intercept_uv = fuse_get_gpcpll_adc_intercept_uv(val); + return 0; +} + +#ifdef CONFIG_TEGRA_USE_NA_GPCPLL +static bool tegra_fuse_can_use_na_gpcpll(void) +{ + return tegra_sku_info.gpu_speedo_id; +} +#endif +#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)) */ + /* * Read ADC characteristic parmeters from fuses. * Determine clibration settings. -- cgit v1.2.2