summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAparna Das <aparnad@nvidia.com>2017-08-04 20:36:25 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2017-10-24 04:26:35 -0400
commit8dda6e08a0e2999562d613e6dbe3b0c90b4a11a0 (patch)
treec09dc39a73f6ec1b77b7feb3c86bd0236c493e23
parentffecc2c6dbceec9535a6012278bebae0fd556a22 (diff)
video: tegra: host: read reg resources by name
Implement capability to get host1x reg resources from device tree by name instead of index since index for a resource can vary between native and virtualized configurations. Jira EVLR-1571 Change-Id: I0e287e5f41af307f3503220243e6cfcd60d29d5e Signed-off-by: Aparna Das <aparnad@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1533437 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
-rw-r--r--drivers/video/tegra/host/host1x/host1x.c39
-rw-r--r--drivers/video/tegra/host/host1x/host1x.h4
-rw-r--r--include/linux/nvhost.h3
3 files changed, 43 insertions, 3 deletions
diff --git a/drivers/video/tegra/host/host1x/host1x.c b/drivers/video/tegra/host/host1x/host1x.c
index 4a3320aa0..6373c59db 100644
--- a/drivers/video/tegra/host/host1x/host1x.c
+++ b/drivers/video/tegra/host/host1x/host1x.c
@@ -954,6 +954,40 @@ struct nvhost_syncpt *nvhost_get_syncpt_owner_struct(u32 id,
954 return &host->syncpt; 954 return &host->syncpt;
955} 955}
956 956
957static int nvhost_device_get_host1x_resources_byname(struct nvhost_master *host)
958{
959 int i;
960 void __iomem *regs = NULL;
961 struct platform_device *dev = host->dev;
962 struct nvhost_device_data *pdata = platform_get_drvdata(dev);
963 int ret;
964
965 for (i = 0; i < host->info.nb_resources; ++i) {
966 struct resource *r = NULL;
967
968 r = platform_get_resource_byname(dev, IORESOURCE_MEM,
969 host->info.resources[i]);
970 /* Get next resource without failing if current resource is not
971 * present. Resources vary with configurations.
972 */
973 if (!r)
974 continue;
975
976 regs = devm_ioremap_resource(&dev->dev, r);
977 if (IS_ERR(regs)) {
978 ret = PTR_ERR(regs);
979 goto fail;
980 }
981
982 pdata->aperture[i] = regs;
983 }
984
985 return 0;
986fail:
987 dev_err(&dev->dev, "failed to get register memory\n");
988 return -ENXIO;
989}
990
957static int nvhost_probe(struct platform_device *dev) 991static int nvhost_probe(struct platform_device *dev)
958{ 992{
959 struct nvhost_master *host; 993 struct nvhost_master *host;
@@ -1047,7 +1081,10 @@ static int nvhost_probe(struct platform_device *dev)
1047 } 1081 }
1048 1082
1049 if (!pdata->virtual_dev) { 1083 if (!pdata->virtual_dev) {
1050 err = nvhost_device_get_resources(dev); 1084 if (host->info.nb_resources)
1085 err = nvhost_device_get_host1x_resources_byname(host);
1086 else
1087 err = nvhost_device_get_resources(dev);
1051 if (err) { 1088 if (err) {
1052 dev_err(&dev->dev, "failed to get resources\n"); 1089 dev_err(&dev->dev, "failed to get resources\n");
1053 goto fail; 1090 goto fail;
diff --git a/drivers/video/tegra/host/host1x/host1x.h b/drivers/video/tegra/host/host1x/host1x.h
index 1989c416b..a0e8eacda 100644
--- a/drivers/video/tegra/host/host1x/host1x.h
+++ b/drivers/video/tegra/host/host1x/host1x.h
@@ -82,6 +82,10 @@ struct host1x_device_info {
82 bool vmserver_owns_engines; 82 bool vmserver_owns_engines;
83 /* true if hw supports remote syncpoint interrupts */ 83 /* true if hw supports remote syncpoint interrupts */
84 bool use_cross_vm_interrupts; 84 bool use_cross_vm_interrupts;
85 /* host1x: reg resources */
86 char *resources[NVHOST_MODULE_MAX_IORESOURCE_MEM];
87 /* host1x: number of resources */
88 int nb_resources;
85}; 89};
86 90
87struct nvhost_vm_firmware_area { 91struct nvhost_vm_firmware_area {
diff --git a/include/linux/nvhost.h b/include/linux/nvhost.h
index a8185c7d8..20793c850 100644
--- a/include/linux/nvhost.h
+++ b/include/linux/nvhost.h
@@ -56,8 +56,7 @@ struct sync_pt;
56#define NVHOST_MODULE_MAX_SYNCPTS 16 56#define NVHOST_MODULE_MAX_SYNCPTS 16
57#define NVHOST_MODULE_MAX_WAITBASES 3 57#define NVHOST_MODULE_MAX_WAITBASES 3
58#define NVHOST_MODULE_MAX_MODMUTEXES 5 58#define NVHOST_MODULE_MAX_MODMUTEXES 5
59#define NVHOST_MODULE_MAX_IORESOURCE_MEM 3 59#define NVHOST_MODULE_MAX_IORESOURCE_MEM 4
60#define NVHOST_MODULE_MAX_IORESOURCE_MEM 3
61#define NVHOST_NAME_SIZE 24 60#define NVHOST_NAME_SIZE 24
62#define NVSYNCPT_INVALID (-1) 61#define NVSYNCPT_INVALID (-1)
63#define NVHOST_MODULE_MAX_FREQS 8 62#define NVHOST_MODULE_MAX_FREQS 8