From d224ca20089a9f05bd72d83990c190ad0c1e73c8 Mon Sep 17 00:00:00 2001 From: Arto Merilainen Date: Fri, 11 Apr 2014 17:46:07 +0300 Subject: gpu: nvgpu: Get host1x device from DTS Currently the gpu driver assumes that the GPU is a child of host1x. This is an invalid assumption and therefore we need to get the host1x device from device tree based on nvidia,host1x property. Bug 1311528 Bug 1434573 Change-Id: I097e39369aaa15ab6652cd23f353f88f7c2b9c48 Signed-off-by: Arto Merilainen Reviewed-on: http://git-master/r/395664 Reviewed-by: Terje Bergstrom Tested-by: Terje Bergstrom --- drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.c | 4 ++-- drivers/gpu/nvgpu/gk20a/debug_gk20a.c | 3 +-- drivers/gpu/nvgpu/gk20a/gk20a.h | 1 + drivers/gpu/nvgpu/gk20a/platform_gk20a_tegra.c | 24 +++++++++++++++++++++++- 4 files changed, 27 insertions(+), 5 deletions(-) (limited to 'drivers/gpu/nvgpu') diff --git a/drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.c b/drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.c index 8122d213..55ee5181 100644 --- a/drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.c @@ -343,8 +343,8 @@ gk20a_channel_syncpt_create(struct channel_gk20a *c) return NULL; sp->c = c; - sp->host1x_pdev = to_platform_device(c->g->dev->dev.parent); - sp->id = nvhost_get_syncpt_host_managed(c->g->dev, c->hw_chid); + sp->host1x_pdev = c->g->host1x_dev; + sp->id = nvhost_get_syncpt_host_managed(sp->host1x_pdev, c->hw_chid); sp->ops.wait_cpu = gk20a_channel_syncpt_wait_cpu; sp->ops.is_expired = gk20a_channel_syncpt_is_expired; diff --git a/drivers/gpu/nvgpu/gk20a/debug_gk20a.c b/drivers/gpu/nvgpu/gk20a/debug_gk20a.c index 3f1f4f0a..f5e0b73d 100644 --- a/drivers/gpu/nvgpu/gk20a/debug_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/debug_gk20a.c @@ -147,8 +147,7 @@ static void gk20a_debug_show_channel(struct gk20a *g, gk20a_debug_output(o, "%s on syncpt %u (%s) val %u\n", (status == 3 || status == 8) ? "Waiting" : "Waited", pbdma_syncpointb_syncpt_index_v(syncpointb), - nvhost_syncpt_get_name( - to_platform_device(g->dev->dev.parent), + nvhost_syncpt_get_name(g->host1x_dev, pbdma_syncpointb_syncpt_index_v(syncpointb)), pbdma_syncpointa_payload_v(syncpointa)); diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h index b8de8744..fc488a28 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/gk20a.h @@ -209,6 +209,7 @@ struct gpu_ops { struct gk20a { struct platform_device *dev; + struct platform_device *host1x_dev; struct resource *reg_mem; void __iomem *regs; diff --git a/drivers/gpu/nvgpu/gk20a/platform_gk20a_tegra.c b/drivers/gpu/nvgpu/gk20a/platform_gk20a_tegra.c index 05aec1a7..7af801f8 100644 --- a/drivers/gpu/nvgpu/gk20a/platform_gk20a_tegra.c +++ b/drivers/gpu/nvgpu/gk20a/platform_gk20a_tegra.c @@ -15,6 +15,7 @@ * more details. */ +#include #include #include #include @@ -403,12 +404,33 @@ static void gk20a_tegra_debug_dump(struct platform_device *pdev) { struct gk20a_platform *platform = gk20a_get_platform(pdev); struct gk20a *g = platform->g; - nvhost_debug_dump_device(g->dev); + nvhost_debug_dump_device(g->host1x_dev); } static int gk20a_tegra_probe(struct platform_device *dev) { struct gk20a_platform *platform = gk20a_get_platform(dev); + struct device_node *np = dev->dev.of_node; + const __be32 *host1x_ptr; + struct platform_device *host1x_pdev = NULL; + + 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->dev, "host1x device not available"); + return -EPROBE_DEFER; + } + + } else { + host1x_pdev = to_platform_device(dev->dev.parent); + dev_warn(&dev->dev, "host1x reference not found. assuming host1x to be parent"); + } + + platform->g->host1x_dev = host1x_pdev; if (tegra_get_chipid() == TEGRA_CHIPID_TEGRA13) { t132_gk20a_tegra_platform.g = platform->g; -- cgit v1.2.2