From b5acc421ee159c932e9e95adaa6d89a0c2141b38 Mon Sep 17 00:00:00 2001 From: Kevin Huang Date: Wed, 26 Mar 2014 11:49:04 -0700 Subject: video: tegra: host: flexible to select fw per chip Decouple the firmware selection of different gpu architecture. Change-Id: I62bf6b3bc51a8606c5973e475988cd5987a65a1a Signed-off-by: Kevin Huang Reviewed-on: http://git-master/r/389793 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom --- drivers/gpu/nvgpu/gk20a/gk20a.h | 4 ++++ drivers/gpu/nvgpu/gk20a/gr_ctx_gk20a.c | 41 +++++++++++++++++++++++----------- drivers/gpu/nvgpu/gk20a/gr_ctx_gk20a.h | 7 ++++-- drivers/gpu/nvgpu/gk20a/hal_gk20a.c | 2 ++ 4 files changed, 39 insertions(+), 15 deletions(-) (limited to 'drivers') diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h index a9081a9d..c19b2bf8 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/gk20a.h @@ -191,6 +191,10 @@ struct gpu_ops { void *(*get_pmu_seq_out_a_ptr)( struct pmu_sequence *seq); } pmu_ver; + struct { + int (*get_netlist_name)(int index, char *name); + bool (*is_fw_defined)(void); + } gr_ctx; }; struct gk20a { diff --git a/drivers/gpu/nvgpu/gk20a/gr_ctx_gk20a.c b/drivers/gpu/nvgpu/gk20a/gr_ctx_gk20a.c index 59404f1d..478bc073 100644 --- a/drivers/gpu/nvgpu/gk20a/gr_ctx_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/gr_ctx_gk20a.c @@ -96,6 +96,15 @@ static int gr_gk20a_get_netlist_name(int index, char *name) return -1; } +bool gr_gk20a_is_firmware_defined(void) +{ +#ifdef GK20A_NETLIST_IMAGE_FW_NAME + return true; +#else + return false; +#endif +} + static int gr_gk20a_init_ctx_vars_fw(struct gk20a *g, struct gr_gk20a *gr) { struct device *d = dev_from_gk20a(g); @@ -107,21 +116,21 @@ static int gr_gk20a_init_ctx_vars_fw(struct gk20a *g, struct gr_gk20a *gr) gk20a_dbg_fn(""); -#ifdef GK20A_NETLIST_IMAGE_FW_NAME - net = NETLIST_FINAL; - max = 0; - major_v_hw = ~0; - g->gr.ctx_vars.dynamic = false; -#else - net = NETLIST_SLOT_A; - max = MAX_NETLIST; - major_v_hw = gk20a_readl(g, gr_fecs_ctx_state_store_major_rev_id_r()); - g->gr.ctx_vars.dynamic = true; -#endif + if (g->ops.gr_ctx.is_fw_defined()) { + net = NETLIST_FINAL; + max = 0; + major_v_hw = ~0; + g->gr.ctx_vars.dynamic = false; + } else { + net = NETLIST_SLOT_A; + max = MAX_NETLIST; + major_v_hw = gk20a_readl(g, + gr_fecs_ctx_state_store_major_rev_id_r()); + g->gr.ctx_vars.dynamic = true; + } for (; net < max; net++) { - - if (gr_gk20a_get_netlist_name(net, name) != 0) { + if (g->ops.gr_ctx.get_netlist_name(net, name) != 0) { gk20a_warn(d, "invalid netlist index %d", net); continue; } @@ -331,3 +340,9 @@ int gr_gk20a_init_ctx_vars(struct gk20a *g, struct gr_gk20a *gr) else return gr_gk20a_init_ctx_vars_fw(g, gr); } + +void gk20a_init_gr_ctx(struct gpu_ops *gops) +{ + gops->gr_ctx.get_netlist_name = gr_gk20a_get_netlist_name; + gops->gr_ctx.is_fw_defined = gr_gk20a_is_firmware_defined; +} diff --git a/drivers/gpu/nvgpu/gk20a/gr_ctx_gk20a.h b/drivers/gpu/nvgpu/gk20a/gr_ctx_gk20a.h index 909a166a..6844ee69 100644 --- a/drivers/gpu/nvgpu/gk20a/gr_ctx_gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/gr_ctx_gk20a.h @@ -1,7 +1,7 @@ /* * GK20A Graphics Context * - * Copyright (c) 2011-2013, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2011-2014, NVIDIA CORPORATION. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -18,10 +18,10 @@ #ifndef __GR_CTX_GK20A_H__ #define __GR_CTX_GK20A_H__ - /* production netlist, one and only one from below */ /*#undef GK20A_NETLIST_IMAGE_FW_NAME*/ #define GK20A_NETLIST_IMAGE_FW_NAME GK20A_NETLIST_IMAGE_B + /* emulation netlists, match majorV with HW */ #define GK20A_NETLIST_IMAGE_A "NETA_img.bin" #define GK20A_NETLIST_IMAGE_B "NETB_img.bin" @@ -146,4 +146,7 @@ struct gr_ucode_gk20a { int gr_gk20a_init_ctx_vars(struct gk20a *g, struct gr_gk20a *gr); int gr_gk20a_init_ctx_vars_sim(struct gk20a *g, struct gr_gk20a *gr); +struct gpu_ops; +void gk20a_init_gr_ctx(struct gpu_ops *gops); + #endif /*__GR_CTX_GK20A_H__*/ diff --git a/drivers/gpu/nvgpu/gk20a/hal_gk20a.c b/drivers/gpu/nvgpu/gk20a/hal_gk20a.c index b3e9b0e6..f8a997e2 100644 --- a/drivers/gpu/nvgpu/gk20a/hal_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/hal_gk20a.c @@ -21,6 +21,7 @@ #include "gk20a.h" #include "gk20a_gating_reglist.h" #include "channel_gk20a.h" +#include "gr_ctx_gk20a.h" struct gpu_ops gk20a_ops = { .clock_gating = { @@ -44,6 +45,7 @@ int gk20a_init_hal(struct gpu_ops *gops) gk20a_init_gr(gops); gk20a_init_fb(gops); gk20a_init_fifo(gops); + gk20a_init_gr_ctx(gops); gops->name = "gk20a"; return 0; -- cgit v1.2.2