From 0ad7f1d9aa18d959abf3cba6ca4e532fc9246a31 Mon Sep 17 00:00:00 2001 From: Deepak Nibade Date: Thu, 25 May 2017 17:41:38 +0530 Subject: gpu: nvgpu: use nvgpu specific nvhost APIs Remove use of linux specifix header files and and use nvgpu specific header file instead This is needed to remove all Linux dependencies from nvgpu driver Replace all nvhost_*() calls by nvgpu_nvhost_*() calls from new nvgpu library Remove platform device pointer host1x_dev from struct gk20a and add struct nvgpu_nvhost_dev instead Jira NVGPU-29 Change-Id: Ia7af70602cfc16f9ccc380752538c05a9cbb8a67 Signed-off-by: Deepak Nibade Reviewed-on: http://git-master/r/1489726 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: svccoveritychecker GVS: Gerrit_Virtual_Submit Reviewed-by: Bharat Nihalani --- .../gpu/nvgpu/tegra/linux/platform_gk20a_tegra.c | 44 ++++++++-------------- .../gpu/nvgpu/tegra/linux/platform_gp10b_tegra.c | 31 ++++++--------- 2 files changed, 27 insertions(+), 48 deletions(-) (limited to 'drivers/gpu/nvgpu/tegra') diff --git a/drivers/gpu/nvgpu/tegra/linux/platform_gk20a_tegra.c b/drivers/gpu/nvgpu/tegra/linux/platform_gk20a_tegra.c index 8a83f7d0..f55ea6d2 100644 --- a/drivers/gpu/nvgpu/tegra/linux/platform_gk20a_tegra.c +++ b/drivers/gpu/nvgpu/tegra/linux/platform_gk20a_tegra.c @@ -15,9 +15,6 @@ #include #include -#ifdef CONFIG_TEGRA_GK20A_NVHOST -#include -#endif #include #include #include @@ -48,6 +45,7 @@ #include #include #include +#include #include @@ -721,8 +719,8 @@ void gk20a_tegra_debug_dump(struct device *dev) struct gk20a_platform *platform = gk20a_get_platform(dev); struct gk20a *g = platform->g; - if (g->host1x_dev) - nvhost_debug_dump_device(g->host1x_dev); + if (g->nvhost_dev) + nvgpu_nvhost_debug_dump_device(g->nvhost_dev); #endif } @@ -732,8 +730,8 @@ int gk20a_tegra_busy(struct device *dev) struct gk20a_platform *platform = gk20a_get_platform(dev); struct gk20a *g = platform->g; - if (g->host1x_dev) - return nvhost_module_busy_ext(g->host1x_dev); + if (g->nvhost_dev) + return nvgpu_nvhost_module_busy_ext(g->nvhost_dev); #endif return 0; } @@ -744,8 +742,8 @@ void gk20a_tegra_idle(struct device *dev) struct gk20a_platform *platform = gk20a_get_platform(dev); struct gk20a *g = platform->g; - if (g->host1x_dev) - nvhost_module_idle_ext(g->host1x_dev); + if (g->nvhost_dev) + nvgpu_nvhost_module_idle_ext(g->nvhost_dev); #endif } @@ -864,8 +862,6 @@ static int gk20a_tegra_probe(struct device *dev) { struct gk20a_platform *platform = dev_get_drvdata(dev); struct device_node *np = dev->of_node; - const __be32 *host1x_ptr; - struct platform_device *host1x_pdev = NULL; bool joint_xpu_rail = false; int ret; @@ -887,23 +883,11 @@ static int gk20a_tegra_probe(struct device *dev) } #endif - host1x_ptr = of_get_property(np, "nvidia,host1x", NULL); - if (host1x_ptr) { - struct device_node *host1x_node = - of_find_node_by_phandle(be32_to_cpup(host1x_ptr)); - - host1x_pdev = of_find_device_by_node(host1x_node); - if (!host1x_pdev) { - dev_warn(dev, "host1x device not available"); - return -EPROBE_DEFER; - } - - } else { - host1x_pdev = to_platform_device(dev->parent); - dev_warn(dev, "host1x reference not found. assuming host1x to be parent"); - } - - platform->g->host1x_dev = host1x_pdev; +#ifdef CONFIG_TEGRA_GK20A_NVHOST + ret = nvgpu_get_nvhost_dev(platform->g); + if (ret) + return ret; +#endif #ifdef CONFIG_OF joint_xpu_rail = of_property_read_bool(of_chosen, @@ -967,6 +951,10 @@ static int gk20a_tegra_remove(struct device *dev) /* deinitialise tegra specific scaling quirks */ gk20a_tegra_scale_exit(dev); +#ifdef CONFIG_TEGRA_GK20A_NVHOST + nvgpu_free_nvhost_dev(get_gk20a(dev)); +#endif + return 0; } diff --git a/drivers/gpu/nvgpu/tegra/linux/platform_gp10b_tegra.c b/drivers/gpu/nvgpu/tegra/linux/platform_gp10b_tegra.c index 8b530fac..235473d3 100644 --- a/drivers/gpu/nvgpu/tegra/linux/platform_gp10b_tegra.c +++ b/drivers/gpu/nvgpu/tegra/linux/platform_gp10b_tegra.c @@ -14,7 +14,6 @@ */ #include -#include #include #include #include @@ -30,6 +29,7 @@ #include #include #include +#include #include "clk.h" @@ -130,26 +130,14 @@ static void gp10b_tegra_scale_exit(struct device *dev) static int gp10b_tegra_probe(struct device *dev) { struct gk20a_platform *platform = dev_get_drvdata(dev); - struct gk20a *g = platform->g; - struct device_node *np = dev->of_node; - struct device_node *host1x_node; - struct platform_device *host1x_pdev; - const __be32 *host1x_ptr; - - host1x_ptr = of_get_property(np, "nvidia,host1x", NULL); - if (!host1x_ptr) { - nvgpu_err(g, "host1x device not available"); - return -ENOSYS; - } +#ifdef CONFIG_TEGRA_GK20A_NVHOST + int ret; - host1x_node = of_find_node_by_phandle(be32_to_cpup(host1x_ptr)); - host1x_pdev = of_find_device_by_node(host1x_node); - if (!host1x_pdev) { - nvgpu_err(g, "host1x device not available"); - return -ENOSYS; - } + ret = nvgpu_get_nvhost_dev(platform->g); + if (ret) + return ret; +#endif - platform->g->host1x_dev = host1x_pdev; platform->bypass_smmu = !device_is_iommuable(dev); platform->disable_bigpage = platform->bypass_smmu; @@ -190,8 +178,11 @@ int gp10b_tegra_remove(struct device *dev) /* deinitialise tegra specific scaling quirks */ gp10b_tegra_scale_exit(dev); - return 0; +#ifdef CONFIG_TEGRA_GK20A_NVHOST + nvgpu_free_nvhost_dev(get_gk20a(dev)); +#endif + return 0; } static bool gp10b_tegra_is_railgated(struct device *dev) -- cgit v1.2.2