summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gm20b/clk_gm20b.c
diff options
context:
space:
mode:
authorAlex Frid <afrid@nvidia.com>2015-04-14 20:59:47 -0400
committerIshan Mittal <imittal@nvidia.com>2015-05-18 01:49:48 -0400
commit1767c779514c9bb10321e39dc8af47cab760bc2b (patch)
treef85c38dc400e65ee10967944dbb587fa2294549f /drivers/gpu/nvgpu/gm20b/clk_gm20b.c
parent603e28fbdc7ff42a21a3c10425dd21818c98e855 (diff)
gpu: nvgpu: Add GPU voltage debug access
- Added GPU voltage debug print to the initial locking of GPCPLL under bypass (available only when GPCPLL is in NA mode). - Added /sys/kernel/debug/gpu.0/voltage debugfs node to read voltage through GPCPLL (available only when GPCPLL is in NA mode). Change-Id: I6643ad4d1b228ec4cbc4ff5e8716cce3ef9dccfc Signed-off-by: Alex Frid <afrid@nvidia.com> Reviewed-on: http://git-master/r/731572 Reviewed-by: Seshendra Gadagottu <sgadagottu@nvidia.com> Tested-by: Seshendra Gadagottu <sgadagottu@nvidia.com> Reviewed-by: Yu-Huan Hsu <yhsu@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gm20b/clk_gm20b.c')
-rw-r--r--drivers/gpu/nvgpu/gm20b/clk_gm20b.c43
1 files changed, 42 insertions, 1 deletions
diff --git a/drivers/gpu/nvgpu/gm20b/clk_gm20b.c b/drivers/gpu/nvgpu/gm20b/clk_gm20b.c
index 9f1068ee..d0a39bc6 100644
--- a/drivers/gpu/nvgpu/gm20b/clk_gm20b.c
+++ b/drivers/gpu/nvgpu/gm20b/clk_gm20b.c
@@ -36,6 +36,7 @@
36 36
37#define DFS_DET_RANGE 6 /* -2^6 ... 2^6-1 */ 37#define DFS_DET_RANGE 6 /* -2^6 ... 2^6-1 */
38#define SDM_DIN_RANGE 12 /* -2^12 ... 2^12-1 */ 38#define SDM_DIN_RANGE 12 /* -2^12 ... 2^12-1 */
39#define DFS_TESTOUT_DET BIT(0)
39#define DFS_EXT_CAL_EN BIT(9) 40#define DFS_EXT_CAL_EN BIT(9)
40#define DFS_EXT_STROBE BIT(16) 41#define DFS_EXT_STROBE BIT(16)
41 42
@@ -377,7 +378,8 @@ static void clk_set_dfs_ext_cal(struct gk20a *g, u32 dfs_det_cal)
377 udelay(1); 378 udelay(1);
378 if (~trim_sys_gpcpll_dvfs1_dfs_ctrl_v(data) & DFS_EXT_CAL_EN) { 379 if (~trim_sys_gpcpll_dvfs1_dfs_ctrl_v(data) & DFS_EXT_CAL_EN) {
379 data = set_field(data, trim_sys_gpcpll_dvfs1_dfs_ctrl_m(), 380 data = set_field(data, trim_sys_gpcpll_dvfs1_dfs_ctrl_m(),
380 trim_sys_gpcpll_dvfs1_dfs_ctrl_f(DFS_EXT_CAL_EN)); 381 trim_sys_gpcpll_dvfs1_dfs_ctrl_f(
382 DFS_EXT_CAL_EN | DFS_TESTOUT_DET));
381 gk20a_writel(g, trim_sys_gpcpll_dvfs1_r(), data); 383 gk20a_writel(g, trim_sys_gpcpll_dvfs1_r(), data);
382 } 384 }
383} 385}
@@ -709,6 +711,12 @@ static int clk_lock_gpc_pll_under_bypass(struct gk20a *g, struct pll *gpll)
709 if (gpll->mode == GPC_PLL_MODE_DVFS) { 711 if (gpll->mode == GPC_PLL_MODE_DVFS) {
710 gk20a_readl(g, trim_sys_gpcpll_cfg_r()); 712 gk20a_readl(g, trim_sys_gpcpll_cfg_r());
711 udelay(g->clk.na_pll_delay); 713 udelay(g->clk.na_pll_delay);
714 gk20a_dbg_clk("NA config_pll under bypass: %u (%u) kHz %d mV",
715 gpll->freq, gpll->freq / 2,
716 (trim_sys_gpcpll_cfg3_dfs_testout_v(
717 gk20a_readl(g, trim_sys_gpcpll_cfg3_r()))
718 * gpc_pll_params.uvdet_slope
719 + gpc_pll_params.uvdet_offs) / 1000);
712 goto pll_locked; 720 goto pll_locked;
713 } 721 }
714 722
@@ -1598,6 +1606,34 @@ static int monitor_get(void *data, u64 *val)
1598} 1606}
1599DEFINE_SIMPLE_ATTRIBUTE(monitor_fops, monitor_get, NULL, "%llu\n"); 1607DEFINE_SIMPLE_ATTRIBUTE(monitor_fops, monitor_get, NULL, "%llu\n");
1600 1608
1609static int voltage_get(void *data, u64 *val)
1610{
1611 struct gk20a *g = (struct gk20a *)data;
1612 struct clk_gk20a *clk = &g->clk;
1613 u32 det_out;
1614 int err;
1615
1616 if (clk->gpc_pll.mode != GPC_PLL_MODE_DVFS)
1617 return -ENOSYS;
1618
1619 err = gk20a_busy(g->dev);
1620 if (err)
1621 return err;
1622
1623 mutex_lock(&g->clk.clk_mutex);
1624
1625 det_out = gk20a_readl(g, trim_sys_gpcpll_cfg3_r());
1626 det_out = trim_sys_gpcpll_cfg3_dfs_testout_v(det_out);
1627 *val = (det_out * gpc_pll_params.uvdet_slope +
1628 gpc_pll_params.uvdet_offs) / 1000;
1629
1630 mutex_unlock(&g->clk.clk_mutex);
1631
1632 gk20a_idle(g->dev);
1633 return 0;
1634}
1635DEFINE_SIMPLE_ATTRIBUTE(voltage_fops, voltage_get, NULL, "%llu\n");
1636
1601static int pll_param_show(struct seq_file *s, void *data) 1637static int pll_param_show(struct seq_file *s, void *data)
1602{ 1638{
1603 seq_printf(s, "ADC offs = %d uV, ADC slope = %d uV, VCO ctrl = 0x%x\n", 1639 seq_printf(s, "ADC offs = %d uV, ADC slope = %d uV, VCO ctrl = 0x%x\n",
@@ -1644,6 +1680,11 @@ static int clk_gm20b_debugfs_init(struct gk20a *g)
1644 goto err_out; 1680 goto err_out;
1645 1681
1646 d = debugfs_create_file( 1682 d = debugfs_create_file(
1683 "voltage", S_IRUGO, platform->debugfs, g, &voltage_fops);
1684 if (!d)
1685 goto err_out;
1686
1687 d = debugfs_create_file(
1647 "pll_param", S_IRUGO, platform->debugfs, g, &pll_param_fops); 1688 "pll_param", S_IRUGO, platform->debugfs, g, &pll_param_fops);
1648 if (!d) 1689 if (!d)
1649 goto err_out; 1690 goto err_out;