summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/clk/clk_prog.c
diff options
context:
space:
mode:
authorVijayakumar <vsubbu@nvidia.com>2016-09-12 13:06:33 -0400
committerDeepak Nibade <dnibade@nvidia.com>2016-12-27 04:56:50 -0500
commit3c351f5bb2d04c1f70c72f3f2fd758bbb340877c (patch)
treecdaaf5547d6a2663111ba3dadb60d723f5833683 /drivers/gpu/nvgpu/clk/clk_prog.c
parent1b1090512020369df18dbe36336ac5a85d2cd693 (diff)
gpu: nvgpu: add function to retrieve clk points
JIRA DNVGPU-123 Function will copy possible clock points for a given master clock domain to pointer passed. pointer with NULL value and count of zero can be passed to query number of clock points for a given domain so that memory can be allocated and function called again to fill clock points Change-Id: Iec6206f23789980036be99793599e934bd221035 Reviewed-on: http://git-master/r/1218912 (cherry picked from commit 9219697bff1e12deb605325055a02a7b387996e9) Signed-off-by: Vijayakumar <vsubbu@nvidia.com> Reviewed-on: http://git-master/r/1235055 Reviewed-by: Thomas Fleury <tfleury@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/clk/clk_prog.c')
-rw-r--r--drivers/gpu/nvgpu/clk/clk_prog.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/clk/clk_prog.c b/drivers/gpu/nvgpu/clk/clk_prog.c
index 5e4700a0..cb9a0e8d 100644
--- a/drivers/gpu/nvgpu/clk/clk_prog.c
+++ b/drivers/gpu/nvgpu/clk/clk_prog.c
@@ -30,6 +30,7 @@ static u32 devinit_get_clk_prog_table(struct gk20a *g,
30 struct clk_progs *pprogobjs); 30 struct clk_progs *pprogobjs);
31static vf_flatten vfflatten_prog_1x_master; 31static vf_flatten vfflatten_prog_1x_master;
32static vf_lookup vflookup_prog_1x_master; 32static vf_lookup vflookup_prog_1x_master;
33static get_fpoints getfpoints_prog_1x_master;
33 34
34static u32 _clk_progs_pmudatainit(struct gk20a *g, 35static u32 _clk_progs_pmudatainit(struct gk20a *g,
35 struct boardobjgrp *pboardobjgrp, 36 struct boardobjgrp *pboardobjgrp,
@@ -607,6 +608,9 @@ static u32 clk_prog_construct_1x_master(struct gk20a *g,
607 pclkprog->vflookup = 608 pclkprog->vflookup =
608 vflookup_prog_1x_master; 609 vflookup_prog_1x_master;
609 610
611 pclkprog->getfpoints =
612 getfpoints_prog_1x_master;
613
610 pclkprog->p_vf_entries = (struct ctrl_clk_clk_prog_1x_master_vf_entry *) 614 pclkprog->p_vf_entries = (struct ctrl_clk_clk_prog_1x_master_vf_entry *)
611 kzalloc(vfsize, GFP_KERNEL); 615 kzalloc(vfsize, GFP_KERNEL);
612 616
@@ -984,3 +988,60 @@ static u32 vflookup_prog_1x_master
984 return -EINVAL; 988 return -EINVAL;
985 return 0; 989 return 0;
986} 990}
991
992static u32 getfpoints_prog_1x_master
993(
994 struct gk20a *g,
995 struct clk_pmupstate *pclk,
996 struct clk_prog_1x_master *p1xmaster,
997 u32 *pfpointscount,
998 u16 **ppfreqpointsinmhz,
999 u8 rail
1000)
1001{
1002
1003 struct ctrl_clk_clk_prog_1x_master_vf_entry
1004 *pvfentry;
1005 struct clk_vf_point *pvfpoint;
1006 struct clk_progs *pclkprogobjs;
1007 u8 j;
1008 u32 fpointscount = 0;
1009
1010 if (pfpointscount == NULL)
1011 return -EINVAL;
1012
1013 pclkprogobjs = &(pclk->clk_progobjs);
1014
1015 if (pclkprogobjs->vf_entry_count >
1016 CTRL_CLK_CLK_PROG_1X_MASTER_VF_ENTRY_MAX_ENTRIES)
1017 return -EINVAL;
1018
1019 if (rail >= pclkprogobjs->vf_entry_count)
1020 return -EINVAL;
1021
1022 pvfentry = p1xmaster->p_vf_entries;
1023
1024 pvfentry = (struct ctrl_clk_clk_prog_1x_master_vf_entry *)(
1025 (u8 *)pvfentry +
1026 (sizeof(struct ctrl_clk_clk_prog_1x_master_vf_entry) *
1027 (rail+1)));
1028
1029 fpointscount = pvfentry->vf_point_idx_last -
1030 pvfentry->vf_point_idx_first + 1;
1031
1032 /* if pointer for freq data is NULL simply return count */
1033 if (*ppfreqpointsinmhz == NULL)
1034 goto done;
1035
1036 if (fpointscount > *pfpointscount)
1037 return -ENOMEM;
1038 for (j = pvfentry->vf_point_idx_first;
1039 j <= pvfentry->vf_point_idx_last; j++) {
1040 pvfpoint = CLK_CLK_VF_POINT_GET(pclk, j);
1041 **ppfreqpointsinmhz = clkvfpointfreqmhzget(g, pvfpoint);
1042 (*ppfreqpointsinmhz)++;
1043 }
1044done:
1045 *pfpointscount = fpointscount;
1046 return 0;
1047}