From 53465def649b813987ca0d4a7ced744305204b82 Mon Sep 17 00:00:00 2001 From: Terje Bergstrom Date: Thu, 9 Feb 2017 08:17:47 -0800 Subject: gpu: nvgpu: Generalize BIOS code Most of BIOS parsing code is not specific to any particular GPU. Move most of the code to generic files, and leave only chip specific parts dealing with microcontroller boot into chip specific files. As most of the parsing is generic, they do not need to be called via HALs so remove the HALs and change the calls into direct function calls. All definitions meant to be used outside BIOS code itself are now in Change-Id: Id48e94c74511d6e95645e90e5bba5c12ef8da45d Signed-off-by: Terje Bergstrom Reviewed-on: http://git-master/r/1302222 GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/clk/clk_domain.c | 9 +++------ drivers/gpu/nvgpu/clk/clk_fll.c | 9 +++------ drivers/gpu/nvgpu/clk/clk_freq_controller.c | 19 +++++++------------ drivers/gpu/nvgpu/clk/clk_mclk.c | 21 +++++++-------------- drivers/gpu/nvgpu/clk/clk_prog.c | 10 +++------- drivers/gpu/nvgpu/clk/clk_vf_point.c | 2 -- drivers/gpu/nvgpu/clk/clk_vin.c | 10 +++------- 7 files changed, 26 insertions(+), 54 deletions(-) (limited to 'drivers/gpu/nvgpu/clk') diff --git a/drivers/gpu/nvgpu/clk/clk_domain.c b/drivers/gpu/nvgpu/clk/clk_domain.c index b53d3708..2a614f55 100644 --- a/drivers/gpu/nvgpu/clk/clk_domain.c +++ b/drivers/gpu/nvgpu/clk/clk_domain.c @@ -11,14 +11,14 @@ * more details. */ +#include + #include "gk20a/gk20a.h" #include "clk.h" #include "clk_fll.h" #include "clk_domain.h" -#include "include/bios.h" #include "boardobj/boardobjgrp.h" #include "boardobj/boardobjgrp_e32.h" -#include "gm206/bios_gm206.h" #include "ctrl/ctrlclk.h" #include "ctrl/ctrlvolt.h" #include "gk20a/pmu_gk20a.h" @@ -261,10 +261,7 @@ static u32 devinit_get_clocks_table(struct gk20a *g, gk20a_dbg_info(""); - if (!g->ops.bios.get_perf_table_ptrs) - return -EINVAL; - - clocks_table_ptr = (u8 *)g->ops.bios.get_perf_table_ptrs(g, + clocks_table_ptr = (u8 *)nvgpu_bios_get_perf_table_ptrs(g, g->bios.clock_token, CLOCKS_TABLE); if (clocks_table_ptr == NULL) { status = -EINVAL; diff --git a/drivers/gpu/nvgpu/clk/clk_fll.c b/drivers/gpu/nvgpu/clk/clk_fll.c index 91cd0e20..7694e720 100644 --- a/drivers/gpu/nvgpu/clk/clk_fll.c +++ b/drivers/gpu/nvgpu/clk/clk_fll.c @@ -11,13 +11,13 @@ * more details. */ +#include + #include "gk20a/gk20a.h" #include "clk.h" #include "clk_fll.h" -#include "include/bios.h" #include "boardobj/boardobjgrp.h" #include "boardobj/boardobjgrp_e32.h" -#include "gm206/bios_gm206.h" #include "ctrl/ctrlclk.h" #include "ctrl/ctrlvolt.h" #include "gk20a/pmu_gk20a.h" @@ -234,10 +234,7 @@ static u32 devinit_get_fll_device_table(struct gk20a *g, gk20a_dbg_info(""); - if (!g->ops.bios.get_perf_table_ptrs) - return -EINVAL; - - fll_table_ptr = (u8 *)g->ops.bios.get_perf_table_ptrs(g, + fll_table_ptr = (u8 *)nvgpu_bios_get_perf_table_ptrs(g, g->bios.clock_token, FLL_TABLE); if (fll_table_ptr == NULL) { status = -1; diff --git a/drivers/gpu/nvgpu/clk/clk_freq_controller.c b/drivers/gpu/nvgpu/clk/clk_freq_controller.c index 6fa2db5a..4b47d978 100644 --- a/drivers/gpu/nvgpu/clk/clk_freq_controller.c +++ b/drivers/gpu/nvgpu/clk/clk_freq_controller.c @@ -11,15 +11,15 @@ * more details. */ +#include + #include "gk20a/gk20a.h" #include "clk.h" #include "clk_fll.h" #include "clk_domain.h" #include "clk_freq_controller.h" -#include "include/bios.h" #include "boardobj/boardobjgrp.h" #include "boardobj/boardobjgrp_e32.h" -#include "gm206/bios_gm206.h" #include "ctrl/ctrlclk.h" #include "ctrl/ctrlvolt.h" #include "gk20a/pmu_gk20a.h" @@ -185,16 +185,11 @@ static u32 clk_get_freq_controller_table(struct gk20a *g, }; } freq_controller_data; - if (g->ops.bios.get_perf_table_ptrs) { - pfreq_controller_table_ptr = - (u8 *)g->ops.bios.get_perf_table_ptrs(g, - g->bios.clock_token, - FREQUENCY_CONTROLLER_TABLE); - if (pfreq_controller_table_ptr == NULL) { - status = -EINVAL; - goto done; - } - } else { + pfreq_controller_table_ptr = + (u8 *)nvgpu_bios_get_perf_table_ptrs(g, + g->bios.clock_token, + FREQUENCY_CONTROLLER_TABLE); + if (pfreq_controller_table_ptr == NULL) { status = -EINVAL; goto done; } diff --git a/drivers/gpu/nvgpu/clk/clk_mclk.c b/drivers/gpu/nvgpu/clk/clk_mclk.c index 479fbb0e..815f55ba 100644 --- a/drivers/gpu/nvgpu/clk/clk_mclk.c +++ b/drivers/gpu/nvgpu/clk/clk_mclk.c @@ -13,12 +13,10 @@ #include +#include + #include "gk20a/gk20a.h" #include "gk20a/pmu_gk20a.h" -#include -#include "gm206/bios_gm206.h" - -#include "include/bios.h" #include #include @@ -2022,12 +2020,7 @@ static int mclk_get_memclk_table(struct gk20a *g) gk20a_dbg_info(""); - if (!(g->ops.bios.get_perf_table_ptrs && - g->ops.bios.execute_script)) { - goto done; - } - - mem_table_ptr = (u8 *)g->ops.bios.get_perf_table_ptrs(g, + mem_table_ptr = (u8 *)nvgpu_bios_get_perf_table_ptrs(g, g->bios.perf_token, MEMORY_CLOCK_TABLE); if (mem_table_ptr == NULL) { @@ -2067,7 +2060,7 @@ static int mclk_get_memclk_table(struct gk20a *g) script_index = BIOS_GET_FIELD(memclock_base_entry.flags1, VBIOS_MEMORY_CLOCK_BASE_ENTRY_11_FLAGS1_SCRIPT_INDEX); - script_ptr = gm206_bios_read_u32(g, + script_ptr = nvgpu_bios_read_u32(g, memclock_table_header.script_list_ptr + script_index * sizeof(u32)); @@ -2107,7 +2100,7 @@ static int mclk_get_memclk_table(struct gk20a *g) fb_fbpa_fbio_delay_priv_m(), fb_fbpa_fbio_delay_priv_f(shadow_idx))); - status = g->ops.bios.execute_script(g, script_ptr); + status = nvgpu_bios_execute_script(g, script_ptr); if (status < 0) { gk20a_writel(g, fb_fbpa_fbio_delay_r(), old_fbio_delay); @@ -2121,7 +2114,7 @@ static int mclk_get_memclk_table(struct gk20a *g) cmd_script_index = BIOS_GET_FIELD(memclock_base_entry.flags2, VBIOS_MEMORY_CLOCK_BASE_ENTRY_12_FLAGS2_CMD_SCRIPT_INDEX); - cmd_script_ptr = gm206_bios_read_u32(g, + cmd_script_ptr = nvgpu_bios_read_u32(g, memclock_table_header.cmd_script_list_ptr + cmd_script_index * sizeof(u32)); @@ -2159,7 +2152,7 @@ static int mclk_get_memclk_table(struct gk20a *g) fb_fbpa_fbio_cmd_delay_cmd_priv_f( cmd_idx))); - status = g->ops.bios.execute_script(g, cmd_script_ptr); + status = nvgpu_bios_execute_script(g, cmd_script_ptr); if (status < 0) { gk20a_writel(g, fb_fbpa_fbio_cmd_delay_r(), old_fbio_cmd_delay); diff --git a/drivers/gpu/nvgpu/clk/clk_prog.c b/drivers/gpu/nvgpu/clk/clk_prog.c index 38654b66..b4f6a464 100644 --- a/drivers/gpu/nvgpu/clk/clk_prog.c +++ b/drivers/gpu/nvgpu/clk/clk_prog.c @@ -11,11 +11,12 @@ * more details. */ +#include + #include "gk20a/gk20a.h" #include "clk.h" #include "clk_prog.h" #include "clk_vf_point.h" -#include "include/bios.h" #include "boardobj/boardobjgrp.h" #include "boardobj/boardobjgrp_e32.h" #include "gm206/bios_gm206.h" @@ -180,12 +181,7 @@ static u32 devinit_get_clk_prog_table(struct gk20a *g, gk20a_dbg_info(""); - if (!g->ops.bios.get_perf_table_ptrs) { - status = -EINVAL; - goto done; - } - - clkprogs_tbl_ptr = (u8 *)g->ops.bios.get_perf_table_ptrs(g, + clkprogs_tbl_ptr = (u8 *)nvgpu_bios_get_perf_table_ptrs(g, g->bios.clock_token, CLOCK_PROGRAMMING_TABLE); if (clkprogs_tbl_ptr == NULL) { status = -EINVAL; diff --git a/drivers/gpu/nvgpu/clk/clk_vf_point.c b/drivers/gpu/nvgpu/clk/clk_vf_point.c index 58eeb6c2..f4019f9d 100644 --- a/drivers/gpu/nvgpu/clk/clk_vf_point.c +++ b/drivers/gpu/nvgpu/clk/clk_vf_point.c @@ -14,10 +14,8 @@ #include "gk20a/gk20a.h" #include "clk.h" #include "clk_vf_point.h" -#include "include/bios.h" #include "boardobj/boardobjgrp.h" #include "boardobj/boardobjgrp_e32.h" -#include "gm206/bios_gm206.h" #include "ctrl/ctrlclk.h" #include "ctrl/ctrlvolt.h" #include "gk20a/pmu_gk20a.h" diff --git a/drivers/gpu/nvgpu/clk/clk_vin.c b/drivers/gpu/nvgpu/clk/clk_vin.c index 13358335..af388671 100644 --- a/drivers/gpu/nvgpu/clk/clk_vin.c +++ b/drivers/gpu/nvgpu/clk/clk_vin.c @@ -11,9 +11,9 @@ * more details. */ -#include "gk20a/gk20a.h" +#include -#include "include/bios.h" +#include "gk20a/gk20a.h" #include "boardobj/boardobjgrp.h" #include "boardobj/boardobjgrp_e32.h" @@ -28,7 +28,6 @@ #include "clk.h" #include "clk_vin.h" - #include static u32 devinit_get_vin_device_table(struct gk20a *g, @@ -349,10 +348,7 @@ static u32 devinit_get_vin_device_table(struct gk20a *g, gk20a_dbg_info(""); - if (!g->ops.bios.get_perf_table_ptrs) - return -EINVAL; - - vin_table_ptr = (u8 *)g->ops.bios.get_perf_table_ptrs(g, + vin_table_ptr = (u8 *)nvgpu_bios_get_perf_table_ptrs(g, g->bios.clock_token, VIN_TABLE); if (vin_table_ptr == NULL) { status = -1; -- cgit v1.2.2