video: tegra: host: Add multiple IO regions
Terje Bergstrom [Wed, 9 Jan 2013 09:33:56 +0000 (11:33 +0200)]
Some units have multiple IO regions. Make the apertures be an array
instead of pointer to a single region.

Change-Id: I15601e094d55a7177bf4336fc74fea367856b584
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-on: http://git-master/r/189893
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Arto Merilainen <amerilainen@nvidia.com>
Reviewed-by: Juha Tukkinen <jtukkinen@nvidia.com>

drivers/video/tegra/host/bus_client.c
drivers/video/tegra/host/dev.c
include/linux/nvhost.h

index 2574d16..0f765c8 100644 (file)
@@ -69,7 +69,7 @@ int nvhost_read_module_regs(struct platform_device *ndev,
                        u32 offset, int count, u32 *values)
 {
        struct nvhost_device_data *pdata = platform_get_drvdata(ndev);
-       void __iomem *p = pdata->aperture + offset;
+       void __iomem *p = pdata->aperture[0] + offset;
        int err;
 
        /* verify offset */
@@ -95,7 +95,7 @@ int nvhost_write_module_regs(struct platform_device *ndev,
        int err;
        struct nvhost_device_data *pdata = platform_get_drvdata(ndev);
 
-       p = pdata->aperture + offset;
+       p = pdata->aperture[0] + offset;
 
        /* verify offset */
        err = validate_reg(ndev, offset, count);
@@ -913,19 +913,24 @@ int nvhost_client_device_suspend(struct platform_device *dev)
 
 int nvhost_client_device_get_resources(struct platform_device *dev)
 {
-       struct resource *r = NULL;
+       int i;
        void __iomem *regs = NULL;
        struct nvhost_device_data *pdata = platform_get_drvdata(dev);
 
-       r = platform_get_resource(dev, IORESOURCE_MEM, 0);
-       if (!r)
-               goto fail;
+       for (i = 0; i < dev->num_resources; i++) {
+               struct resource *r = NULL;
 
-       regs = devm_request_and_ioremap(&dev->dev, r);
-       if (!regs)
-               goto fail;
+               r = platform_get_resource(dev, IORESOURCE_MEM, i);
+               /* We've run out of mem resources */
+               if (!r)
+                       break;
 
-       pdata->aperture = regs;
+               regs = devm_request_and_ioremap(&dev->dev, r);
+               if (!regs)
+                       goto fail;
+
+               pdata->aperture[i] = regs;
+       }
 
        return 0;
 
index bed54e0..0ce2017 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Tegra Graphics Host Driver Entrypoint
  *
- * Copyright (c) 2010-2012, NVIDIA Corporation.
+ * Copyright (c) 2010-2013, NVIDIA Corporation.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
@@ -130,14 +130,14 @@ void nvhost_set_register_sets(unsigned int r)
 void nvhost_device_writel(struct platform_device *dev, u32 r, u32 v)
 {
        struct nvhost_device_data *pdata = platform_get_drvdata(dev);
-       writel(v, pdata->aperture + r);
+       writel(v, pdata->aperture[0] + r);
 }
 EXPORT_SYMBOL_GPL(nvhost_device_writel);
 
 u32 nvhost_device_readl(struct platform_device *dev, u32 r)
 {
        struct nvhost_device_data *pdata = platform_get_drvdata(dev);
-       return readl(pdata->aperture + r);
+       return readl(pdata->aperture[0] + r);
 }
 EXPORT_SYMBOL_GPL(nvhost_device_readl);
 
index 59c075a..71934b4 100644 (file)
@@ -37,6 +37,7 @@ struct nvhost_device_power_attr;
 #define NVHOST_MODULE_MAX_SYNCPTS              8
 #define NVHOST_MODULE_MAX_WAITBASES            3
 #define NVHOST_MODULE_MAX_MODMUTEXES           5
+#define NVHOST_MODULE_MAX_IORESOURCE_MEM       3
 #define NVHOST_MODULE_NO_POWERGATE_IDS         .powergate_ids = {-1, -1}
 #define NVHOST_DEFAULT_CLOCKGATE_DELAY         .clockgate_delay = 25
 #define NVHOST_NAME_SIZE                       24
@@ -89,7 +90,7 @@ struct nvhost_device_data {
        int             version;        /* ip version number of device */
        int             id;             /* Separates clients of same hw */
        int             index;          /* Hardware channel number */
-       void __iomem    *aperture;      /* Iomem mapped to kernel */
+       void __iomem    *aperture[NVHOST_MODULE_MAX_IORESOURCE_MEM];
 
        u32             syncpts[NVHOST_MODULE_MAX_SYNCPTS];
        u32             waitbases[NVHOST_MODULE_MAX_WAITBASES];