diff options
Diffstat (limited to 'drivers/gpu/nvgpu/clk/clk_prog.c')
-rw-r--r-- | drivers/gpu/nvgpu/clk/clk_prog.c | 55 |
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, | |||
31 | static vf_flatten vfflatten_prog_1x_master; | 31 | static vf_flatten vfflatten_prog_1x_master; |
32 | static vf_lookup vflookup_prog_1x_master; | 32 | static vf_lookup vflookup_prog_1x_master; |
33 | static get_fpoints getfpoints_prog_1x_master; | 33 | static get_fpoints getfpoints_prog_1x_master; |
34 | static get_slaveclk getslaveclk_prog_1x_master; | ||
34 | 35 | ||
35 | static u32 _clk_progs_pmudatainit(struct gk20a *g, | 36 | static 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 | |||
1053 | static 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 | } | ||