From ba387d3d7e81072641e0134c1c1d4fcf890f1b70 Mon Sep 17 00:00:00 2001 From: Hoang Pham Date: Mon, 14 Jul 2014 10:42:35 -0700 Subject: gpu: Split clk_ops for GK20A and GM20B Split clk_ops for GK20A and GM20B into different files Bug 1450787 Change-Id: I34d16c54ac40c70854e80588475434c9e50b51a5 Signed-off-by: Hoang Pham Reviewed-on: http://git-master/r/437771 Reviewed-by: Yu-Huan Hsu --- drivers/gpu/nvgpu/gk20a/clk_gk20a.c | 5 +++++ drivers/gpu/nvgpu/gk20a/gk20a.c | 10 ++++++---- drivers/gpu/nvgpu/gk20a/gk20a.h | 5 +++++ drivers/gpu/nvgpu/gk20a/hal_gk20a.c | 2 ++ drivers/gpu/nvgpu/gm20b/Makefile | 1 + drivers/gpu/nvgpu/gm20b/clk_gm20b.c | 34 ++++++++++++++++++++++++++++++++++ drivers/gpu/nvgpu/gm20b/clk_gm20b.h | 26 ++++++++++++++++++++++++++ drivers/gpu/nvgpu/gm20b/hal_gm20b.c | 2 ++ 8 files changed, 81 insertions(+), 4 deletions(-) create mode 100644 drivers/gpu/nvgpu/gm20b/clk_gm20b.c create mode 100644 drivers/gpu/nvgpu/gm20b/clk_gm20b.h (limited to 'drivers') diff --git a/drivers/gpu/nvgpu/gk20a/clk_gk20a.c b/drivers/gpu/nvgpu/gk20a/clk_gk20a.c index 33d81bd4..40eb06b6 100644 --- a/drivers/gpu/nvgpu/gk20a/clk_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/clk_gk20a.c @@ -705,6 +705,11 @@ int gk20a_init_clk_support(struct gk20a *g) return err; } +void gk20a_init_clk_ops(struct gpu_ops *gops) +{ + gops->clk.init_clk_support = gk20a_init_clk_support; +} + unsigned long gk20a_clk_get_rate(struct gk20a *g) { struct clk_gk20a *clk = &g->clk; diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.c b/drivers/gpu/nvgpu/gk20a/gk20a.c index c69df460..e70cc0de 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/gk20a.c @@ -901,10 +901,12 @@ static int gk20a_pm_finalize_poweron(struct device *dev) during boot but it also significantly slows down gk20a init on simulation and emulation. We should remove SOB after graphics power saving features (blcg/slcg) are enabled. For now, do it here. */ - err = gk20a_init_clk_support(g); - if (err) { - gk20a_err(dev, "failed to init gk20a clk"); - goto done; + if (g->ops.clk.init_clk_support) { + err = g->ops.clk.init_clk_support(g); + if (err) { + gk20a_err(dev, "failed to init gk20a clk"); + goto done; + } } /* enable pri timeout only on silicon */ diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h index 774e4e85..0b91420b 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/gk20a.h @@ -230,6 +230,9 @@ struct gpu_ops { int (*prepare_ucode)(struct gk20a *g); int (*pmu_setup_hw_and_bootstrap)(struct gk20a *g); } pmu; + struct { + int (*init_clk_support)(struct gk20a *g); + } clk; }; struct gk20a { @@ -495,6 +498,8 @@ static inline void gk20a_mem_wr32(void *ptr, int w, u32 data) ((u32 *)ptr)[w] = data; } +void gk20a_init_clk_ops(struct gpu_ops *gops); + /* register accessors */ int gk20a_lockout_registers(struct gk20a *g); int gk20a_restore_registers(struct gk20a *g); diff --git a/drivers/gpu/nvgpu/gk20a/hal_gk20a.c b/drivers/gpu/nvgpu/gk20a/hal_gk20a.c index ad0a3dc7..3dae9450 100644 --- a/drivers/gpu/nvgpu/gk20a/hal_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/hal_gk20a.c @@ -24,6 +24,7 @@ #include "gr_ctx_gk20a.h" #include "mm_gk20a.h" #include "pmu_gk20a.h" +#include "clk_gk20a.h" struct gpu_ops gk20a_ops = { .clock_gating = { @@ -50,6 +51,7 @@ int gk20a_init_hal(struct gpu_ops *gops) gk20a_init_gr_ctx(gops); gk20a_init_mm(gops); gk20a_init_pmu_ops(gops); + gk20a_init_clk_ops(gops); gops->name = "gk20a"; return 0; diff --git a/drivers/gpu/nvgpu/gm20b/Makefile b/drivers/gpu/nvgpu/gm20b/Makefile index 20328e9e..d11e20fa 100644 --- a/drivers/gpu/nvgpu/gm20b/Makefile +++ b/drivers/gpu/nvgpu/gm20b/Makefile @@ -13,4 +13,5 @@ obj-$(CONFIG_GK20A) = \ gm20b_gating_reglist.o \ acr_gm20b.o \ pmu_gm20b.o \ + clk_gm20b.o \ mm_gm20b.o diff --git a/drivers/gpu/nvgpu/gm20b/clk_gm20b.c b/drivers/gpu/nvgpu/gm20b/clk_gm20b.c new file mode 100644 index 00000000..848e4682 --- /dev/null +++ b/drivers/gpu/nvgpu/gm20b/clk_gm20b.c @@ -0,0 +1,34 @@ +/* + * GM20B Clocks + * + * Copyright (c) 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, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include /* for mdelay */ +#include +#include +#include +#include + +#include "gk20a/gk20a.h" +#include "gk20a/hw_trim_gk20a.h" +#include "gk20a/hw_timer_gk20a.h" + +void gm20b_init_clk_ops(struct gpu_ops *gops) +{ + gops->clk.init_clk_support = gk20a_init_clk_support; +} + diff --git a/drivers/gpu/nvgpu/gm20b/clk_gm20b.h b/drivers/gpu/nvgpu/gm20b/clk_gm20b.h new file mode 100644 index 00000000..cac5708c --- /dev/null +++ b/drivers/gpu/nvgpu/gm20b/clk_gm20b.h @@ -0,0 +1,26 @@ +/* + * GM20B Graphics + * + * Copyright (c) 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, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + */ +#ifndef _NVHOST_CLK_GM20B_H_ +#define _NVHOST_CLK_GM20B_H_ + +#include + +void gm20b_init_clk_ops(struct gpu_ops *gops); + +#endif /* _NVHOST_CLK_GM20B_H_ */ diff --git a/drivers/gpu/nvgpu/gm20b/hal_gm20b.c b/drivers/gpu/nvgpu/gm20b/hal_gm20b.c index 0d6b0447..5e8fc0ae 100644 --- a/drivers/gpu/nvgpu/gm20b/hal_gm20b.c +++ b/drivers/gpu/nvgpu/gm20b/hal_gm20b.c @@ -26,6 +26,7 @@ #include "gr_ctx_gm20b.h" #include "mm_gm20b.h" #include "pmu_gm20b.h" +#include "clk_gm20b.h" struct gpu_ops gm20b_ops = { .clock_gating = { @@ -53,6 +54,7 @@ int gm20b_init_hal(struct gpu_ops *gops) gm20b_init_gr_ctx(gops); gm20b_init_mm(gops); gm20b_init_pmu_ops(gops); + gm20b_init_clk_ops(gops); gops->name = "gm20b"; return 0; -- cgit v1.2.2