summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLucas Stach <l.stach@pengutronix.de>2013-09-16 14:33:54 +0200
committerLucas Stach <l.stach@pengutronix.de>2013-09-17 08:45:22 +0200
commit0956d33399fc884b083b575477397bffc32b6d95 (patch)
tree4d4a6f4d34b17a1f3382b45d99ee3ff2af58d3f2
parent3d5da20a404c5b45e5eca435b028165e70e01105 (diff)
downloadlinux-0956d33399fc884b083b575477397bffc32b6d95.tar.gz
WIP: move MMIO register mapping into adreno_gpu
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
-rw-r--r--drivers/gpu/drm/msm/adreno/adreno_gpu.c39
-rw-r--r--drivers/gpu/drm/msm/adreno/adreno_gpu.h6
-rw-r--r--drivers/gpu/drm/msm/msm_gpu.c7
-rw-r--r--drivers/gpu/drm/msm/msm_gpu.h1
4 files changed, 43 insertions, 10 deletions
diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
index 5e10446..1083894 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
@@ -313,6 +313,39 @@ static inline bool _rev_match(uint8_t entry, uint8_t id)
return (entry == ANY_ID) || (entry == id);
}
+static void __iomem *adreno_ioremap(struct platform_device *pdev,
+ const char *name, const char *dbgname)
+{
+ struct resource *res;
+ unsigned long size;
+ void __iomem *ptr;
+
+ if (name)
+ res = platform_get_resource_byname(pdev, IORESOURCE_MEM, name);
+ else
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+
+ if (!res) {
+ dev_err(&pdev->dev, "failed to get memory resource: %s\n", name);
+ return ERR_PTR(-EINVAL);
+ }
+
+ size = resource_size(res);
+
+ ptr = devm_ioremap_nocache(&pdev->dev, res->start, size);
+ if (!ptr) {
+ dev_err(&pdev->dev, "failed to ioremap: %s\n", name);
+ return ERR_PTR(-ENOMEM);
+ }
+
+ if (IS_ENABLED(CONFIG_DRM_MSM_REGISTER_LOGGING) &&
+ unlikely(adreno_reglog))
+ printk(KERN_DEBUG "IO:region %s %08x %08lx\n", dbgname,
+ (u32)ptr, size);
+
+ return ptr;
+}
+
int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev,
struct adreno_gpu *gpu, const struct adreno_gpu_funcs *funcs,
struct adreno_gem *gem, struct workqueue_struct *wq,
@@ -366,6 +399,12 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev,
return ret;
}
+ /* Map registers: */
+ gpu->mmio = adreno_ioremap(pdev, "kgsl_3d0_reg_memory",
+ adreno_get_name(gpu));
+ if (IS_ERR(gpu->mmio))
+ return PTR_ERR(gpu->mmio);
+
ret = msm_gpu_init(drm, pdev, &gpu->base, funcs,
"kgsl_3d0_reg_memory", "kgsl_3d0_irq",
RB_SIZE);
diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.h b/drivers/gpu/drm/msm/adreno/adreno_gpu.h
index dc0e4ad..38edd4f 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_gpu.h
+++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.h
@@ -61,6 +61,8 @@ struct adreno_gpu {
/* firmware: */
const struct firmware *pm4, *pfp;
+ void __iomem *mmio;
+
/* ringbuffer rptr/wptr: */
// TODO should this be in adreno_ringbuffer? I think it would be
// different for z180..
@@ -133,7 +135,7 @@ void adreno_gpu_cleanup(struct adreno_gpu *gpu);
static inline void gpu_write(struct adreno_gpu *gpu, u32 reg, u32 data)
{
- void __iomem *addr = gpu->base.mmio + (reg << 2);
+ void __iomem *addr = gpu->mmio + (reg << 2);
if (IS_ENABLED(CONFIG_DRM_MSM_REGISTER_LOGGING) &&
unlikely(adreno_reglog))
@@ -144,7 +146,7 @@ static inline void gpu_write(struct adreno_gpu *gpu, u32 reg, u32 data)
static inline u32 gpu_read(struct adreno_gpu *gpu, u32 reg)
{
- void __iomem *addr = gpu->base.mmio + (reg << 2);
+ void __iomem *addr = gpu->mmio + (reg << 2);
u32 val = readl(addr);
if (IS_ENABLED(CONFIG_DRM_MSM_REGISTER_LOGGING) &&
diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c
index a186465..67d0427 100644
--- a/drivers/gpu/drm/msm/msm_gpu.c
+++ b/drivers/gpu/drm/msm/msm_gpu.c
@@ -309,13 +309,6 @@ int msm_gpu_init(struct drm_device *drm, struct platform_device *pdev,
BUG_ON(ARRAY_SIZE(clk_names) != ARRAY_SIZE(gpu->grp_clks));
- /* Map registers: */
- gpu->mmio = msm_ioremap(pdev, ioname, adreno_get_name(gpu->gpu));
- if (IS_ERR(gpu->mmio)) {
- ret = PTR_ERR(gpu->mmio);
- goto fail;
- }
-
/* Get Interrupt: */
gpu->irq = platform_get_irq_byname(pdev, irqname);
if (gpu->irq < 0) {
diff --git a/drivers/gpu/drm/msm/msm_gpu.h b/drivers/gpu/drm/msm/msm_gpu.h
index 124b38d..cc0f800 100644
--- a/drivers/gpu/drm/msm/msm_gpu.h
+++ b/drivers/gpu/drm/msm/msm_gpu.h
@@ -49,7 +49,6 @@ struct msm_gpu {
/* worker for handling active-list retiring: */
struct work_struct retire_work;
- void __iomem *mmio;
int irq;
struct iommu_domain *iommu;