summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/clk/clk_prog.c
diff options
context:
space:
mode:
authorVijayakumar <vsubbu@nvidia.com>2016-09-16 09:26:22 -0400
committerDeepak Nibade <dnibade@nvidia.com>2016-12-27 04:56:50 -0500
commitc7fbd76e7101b7dedc8c0f04437288d1d6b78adc (patch)
tree6d1ab41af52a481ddeb148307a69113582569edd /drivers/gpu/nvgpu/clk/clk_prog.c
parent3c351f5bb2d04c1f70c72f3f2fd758bbb340877c (diff)
gpu: nvgpu: create function to program coreclk
JIRA DNVGPU-123 now a function can be called with GPC2CLK value It will take care calculating slave clock values and calling VF inject to program clock Made programming of boot clock code to use this newly created function. Change-Id: I74de7e9d98e379e94175ed2d9745ce3ab6c70691 Signed-off-by: Vijayakumar <vsubbu@nvidia.com> Reviewed-on: http://git-master/r/1221976 GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com> Reviewed-on: http://git-master/r/1235056
Diffstat (limited to 'drivers/gpu/nvgpu/clk/clk_prog.c')
-rw-r--r--drivers/gpu/nvgpu/clk/clk_prog.c55
1 files changed, 53 insertions, 2 deletions
diff --git a/drivers/gpu/nvgpu/clk/clk_prog.c b/drivers/gpu/nvgpu/clk/clk_prog.c
index cb9a0e8d..9fdd8b25 100644
--- a/drivers/gpu/nvgpu/clk/clk_prog.c
+++ b/drivers/gpu/nvgpu/clk/clk_prog.c
@@ -31,6 +31,7 @@ static u32 devinit_get_clk_prog_table(struct gk20a *g,
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; 33static get_fpoints getfpoints_prog_1x_master;
34static get_slaveclk getslaveclk_prog_1x_master;
34 35
35static u32 _clk_progs_pmudatainit(struct gk20a *g, 36static u32 _clk_progs_pmudatainit(struct gk20a *g,
36 struct boardobjgrp *pboardobjgrp, 37 struct boardobjgrp *pboardobjgrp,
@@ -611,6 +612,9 @@ static u32 clk_prog_construct_1x_master(struct gk20a *g,
611 pclkprog->getfpoints = 612 pclkprog->getfpoints =
612 getfpoints_prog_1x_master; 613 getfpoints_prog_1x_master;
613 614
615 pclkprog->getslaveclk =
616 getslaveclk_prog_1x_master;
617
614 pclkprog->p_vf_entries = (struct ctrl_clk_clk_prog_1x_master_vf_entry *) 618 pclkprog->p_vf_entries = (struct ctrl_clk_clk_prog_1x_master_vf_entry *)
615 kzalloc(vfsize, GFP_KERNEL); 619 kzalloc(vfsize, GFP_KERNEL);
616 620
@@ -851,7 +855,7 @@ static u32 vflookup_prog_1x_master
851 u8 rail 855 u8 rail
852) 856)
853{ 857{
854 u8 j; 858 int j;
855 struct ctrl_clk_clk_prog_1x_master_vf_entry 859 struct ctrl_clk_clk_prog_1x_master_vf_entry
856 *pvfentry; 860 *pvfentry;
857 struct clk_vf_point *pvfpoint; 861 struct clk_vf_point *pvfpoint;
@@ -860,7 +864,7 @@ static u32 vflookup_prog_1x_master
860 u16 clkmhz; 864 u16 clkmhz;
861 u32 voltuv; 865 u32 voltuv;
862 u8 slaveentrycount; 866 u8 slaveentrycount;
863 u8 i; 867 int i;
864 struct ctrl_clk_clk_prog_1x_master_ratio_slave_entry *pslaveents; 868 struct ctrl_clk_clk_prog_1x_master_ratio_slave_entry *pslaveents;
865 869
866 if ((*pclkmhz != 0) && (*pvoltuv != 0)) 870 if ((*pclkmhz != 0) && (*pvoltuv != 0))
@@ -1045,3 +1049,50 @@ done:
1045 *pfpointscount = fpointscount; 1049 *pfpointscount = fpointscount;
1046 return 0; 1050 return 0;
1047} 1051}
1052
1053static int getslaveclk_prog_1x_master(struct gk20a *g,
1054 struct clk_pmupstate *pclk,
1055 struct clk_prog_1x_master *p1xmaster,
1056 u8 slave_clk_domain,
1057 u16 *pclkmhz,
1058 u16 masterclkmhz
1059)
1060{
1061 struct clk_progs *pclkprogobjs;
1062 struct clk_prog_1x_master_ratio *p1xmasterratio;
1063 u8 slaveentrycount;
1064 u8 i;
1065 struct ctrl_clk_clk_prog_1x_master_ratio_slave_entry *pslaveents;
1066
1067 if (pclkmhz == NULL)
1068 return -EINVAL;
1069
1070 if (masterclkmhz == 0)
1071 return -EINVAL;
1072
1073 *pclkmhz = 0;
1074 pclkprogobjs = &(pclk->clk_progobjs);
1075
1076 slaveentrycount = pclkprogobjs->slave_entry_count;
1077
1078 if (p1xmaster->super.super.super.implements(g,
1079 &p1xmaster->super.super.super,
1080 CTRL_CLK_CLK_PROG_TYPE_1X_MASTER_RATIO)) {
1081 p1xmasterratio =
1082 (struct clk_prog_1x_master_ratio *)p1xmaster;
1083 pslaveents = p1xmasterratio->p_slave_entries;
1084 for (i = 0; i < slaveentrycount; i++) {
1085 if (pslaveents->clk_dom_idx ==
1086 slave_clk_domain)
1087 break;
1088 pslaveents++;
1089 }
1090 if (i == slaveentrycount)
1091 return -EINVAL;
1092 *pclkmhz = (masterclkmhz * pslaveents->ratio)/100;
1093 } else {
1094 /* only support ratio for now */
1095 return -EINVAL;
1096 }
1097 return 0;
1098}