aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorJorge Zapata <turran@openmoko.com>2009-02-19 16:42:54 +0100
committerThomas White <taw@bitwiz.org.uk>2009-03-26 21:34:10 +0000
commit22a1cc6ef8c82c485136be49eeca90777e8ac85c (patch)
tree0342597686a6bad6bf6ef9fcfa3c54fc4622abe5 /drivers
parente1179bc8e2bfa379e178e1f206b4687df71755f1 (diff)
Import part of Thomas White DRM tree:
Handle new memory layout. The "not-needed" memory should not be taken by the framebuffer driver. Use that for the DRM driver. Add the cmdq platform device Set aside 4k for hardware cursor, reject cursors that don't fit.
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mfd/glamo/glamo-core.c34
-rw-r--r--drivers/mfd/glamo/glamo-core.h34
-rw-r--r--drivers/mfd/glamo/glamo-fb.c8
3 files changed, 62 insertions, 14 deletions
diff --git a/drivers/mfd/glamo/glamo-core.c b/drivers/mfd/glamo/glamo-core.c
index 28dc1f309ac..506e7e6ab41 100644
--- a/drivers/mfd/glamo/glamo-core.c
+++ b/drivers/mfd/glamo/glamo-core.c
@@ -175,6 +175,25 @@ static inline void glamo_vmem_read(struct glamo_core *glamo, u_int16_t *buf,
/***********************************************************************
* resources of sibling devices
***********************************************************************/
+static struct resource glamo_cmdq_resources[] = {
+ {
+ .start = GLAMO_REGOFS_CMDQUEUE,
+ .end = GLAMO_REGOFS_RISC - 1,
+ .flags = IORESOURCE_MEM,
+ }, {
+ .name = "glamo-work-mem",
+ .start = GLAMO_MEM_BASE + GLAMO_OFFSET_WORK,
+ .end = GLAMO_MEM_BASE + GLAMO_OFFSET_WORK +
+ GLAMO_WORK_SIZE - 1,
+ .flags = IORESOURCE_MEM,
+ },
+};
+
+static struct platform_device glamo_cmdq_dev = {
+ .name = "glamo-cmdq",
+ .resource = glamo_cmdq_resources,
+ .num_resources = ARRAY_SIZE(glamo_cmdq_resources),
+};
#if 0
static struct resource glamo_core_resources[] = {
@@ -277,8 +296,9 @@ static struct resource glamo_fb_resources[] = {
.flags = IORESOURCE_MEM,
}, {
.name = "glamo-fb-mem",
- .start = GLAMO_OFFSET_FB,
- .end = GLAMO_OFFSET_FB + GLAMO_FB_SIZE - 1,
+ .start = GLAMO_MEM_BASE + GLAMO_OFFSET_FB,
+ .end = GLAMO_MEM_BASE + GLAMO_OFFSET_FB +
+ GLAMO_FB_SIZE - 1,
.flags = IORESOURCE_MEM,
},
};
@@ -300,9 +320,9 @@ static struct resource glamo_mmc_resources[] = {
.end = IRQ_GLAMO_MMC,
.flags = IORESOURCE_IRQ,
}, { /* our data buffer for MMC transfers */
- .start = GLAMO_OFFSET_FB + GLAMO_FB_SIZE,
- .end = GLAMO_OFFSET_FB + GLAMO_FB_SIZE +
- GLAMO_MMC_BUFFER_SIZE - 1,
+ .start = GLAMO_MEM_BASE + GLAMO_OFFSET_MMC,
+ .end = GLAMO_MEM_BASE + GLAMO_OFFSET_MMC +
+ GLAMO_MMC_BUFFER_SIZE - 1,
.flags = IORESOURCE_MEM
},
};
@@ -1308,6 +1328,10 @@ static int __init glamo_probe(struct platform_device *pdev)
glamo->pdata->glamo_irq_is_wired;
/* start creating the siblings */
+ glamo_cmdq_dev.dev.parent = &pdev->dev;
+ mangle_mem_resources(glamo_cmdq_dev.resource,
+ glamo_cmdq_dev.num_resources, glamo->mem);
+ platform_device_register(&glamo_cmdq_dev);
glamo_2d_dev.dev.parent = &pdev->dev;
mangle_mem_resources(glamo_2d_dev.resource,
diff --git a/drivers/mfd/glamo/glamo-core.h b/drivers/mfd/glamo/glamo-core.h
index 8e09564bc3f..f7062cddf70 100644
--- a/drivers/mfd/glamo/glamo-core.h
+++ b/drivers/mfd/glamo/glamo-core.h
@@ -3,18 +3,34 @@
#include <asm/system.h>
-/* for the time being, we put the on-screen framebuffer into the lowest
- * VRAM space. This should make the code easily compatible with the various
- * 2MB/4MB/8MB variants of the Smedia chips */
-#define GLAMO_OFFSET_VRAM 0x800000
-#define GLAMO_OFFSET_FB (GLAMO_OFFSET_VRAM)
-
/* we only allocate the minimum possible size for the framebuffer to make
* sure we have sufficient memory for other functions of the chip */
-//#define GLAMO_FB_SIZE (640*480*4) /* == 0x12c000 */
+/* FIXME: this should be autodetected */
#define GLAMO_INTERNAL_RAM_SIZE 0x800000
-#define GLAMO_MMC_BUFFER_SIZE (64 * 1024)
-#define GLAMO_FB_SIZE (GLAMO_INTERNAL_RAM_SIZE - GLAMO_MMC_BUFFER_SIZE)
+#define GLAMO_MMC_BUFFER_SIZE (64 * 1024) /* 64k MMC buffer */
+/* A 640x480, 16bpp, double-buffered framebuffer */
+#define GLAMO_FB_SIZE (640 * 480 * 4) /* == 0x12c000 */
+#define GLAMO_CMDQ_SIZE (128 * 1024) /* 128k ring buffer */
+/* Arbitrarily determined amount for the hardware cursor */
+#define GLAMO_CURSOR_SIZE (4096)
+/* Remaining memory will be used for 2D and 3D graphics */
+#define GLAMO_WORK_SIZE (GLAMO_INTERNAL_RAM_SIZE - GLAMO_FB_SIZE \
+ - GLAMO_CURSOR_SIZE \
+ - GLAMO_MMC_BUFFER_SIZE \
+ - GLAMO_CMDQ_SIZE)
+
+/* for the time being, we put the on-screen framebuffer into the lowest
+ * VRAM space. This should make the code easily compatible with the various
+ * 2MB/4MB/8MB variants of the Smedia chips
+ * glamo-fb.c assumes FB comes first, followed by cursor, so DON'T MOVE THEM
+ * (see glamo_regs[] in glamo-fb.c for more information) */
+#define GLAMO_MEM_BASE (0x800000)
+#define GLAMO_OFFSET_VRAM (0x000000)
+#define GLAMO_OFFSET_FB (GLAMO_OFFSET_VRAM)
+#define GLAMO_OFFSET_CURSOR (GLAMO_OFFSET_FB + GLAMO_FB_SIZE)
+#define GLAMO_OFFSET_MMC (GLAMO_OFFSET_CURSOR + GLAMO_CURSOR_SIZE)
+#define GLAMO_OFFSET_CMDQ (GLAMO_OFFSET_MMC + GLAMO_MMC_BUFFER_SIZE)
+#define GLAMO_OFFSET_WORK (GLAMO_OFFSET_CMDQ + GLAMO_CMDQ_SIZE)
struct glamo_core {
int irq;
diff --git a/drivers/mfd/glamo/glamo-fb.c b/drivers/mfd/glamo/glamo-fb.c
index 4eb81a508e5..77725a370e9 100644
--- a/drivers/mfd/glamo/glamo-fb.c
+++ b/drivers/mfd/glamo/glamo-fb.c
@@ -595,6 +595,12 @@ static int glamofb_cursor(struct fb_info *info, struct fb_cursor *cursor)
struct glamofb_handle *glamo = info->par;
unsigned long flags;
+ /* Reject if the cursor is too big to fit in the memory allocated in
+ * glamo-core.h */
+
+ if ((cursor->image.width * cursor->image.height) > GLAMO_CURSOR_SIZE )
+ return -EINVAL;
+
spin_lock_irqsave(&glamo->lock_cmd, flags);
reg_write(glamo, GLAMO_REG_LCD_CURSOR_X_SIZE,
@@ -847,6 +853,8 @@ static int __init glamofb_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "failed to request mmio region\n");
goto out_free;
}
+ if (mach_info->fb_mem_size != RESSIZE(glamofb->fb_res))
+ dev_warn(&pdev->dev, "different vram sizes\n");
glamofb->fb_res = request_mem_region(glamofb->fb_res->start,
mach_info->fb_mem_size,