diff options
Diffstat (limited to 'drivers/mfd/glamo')
-rw-r--r-- | drivers/mfd/glamo/Kconfig | 9 | ||||
-rw-r--r-- | drivers/mfd/glamo/Makefile | 1 | ||||
-rw-r--r-- | drivers/mfd/glamo/glamo-core.c | 140 | ||||
-rw-r--r-- | drivers/mfd/glamo/glamo-core.h | 35 | ||||
-rw-r--r-- | drivers/mfd/glamo/glamo-drm.c | 355 | ||||
-rw-r--r-- | drivers/mfd/glamo/glamo-fb.c | 8 | ||||
-rw-r--r-- | drivers/mfd/glamo/glamo-mci.c | 8 |
7 files changed, 433 insertions, 123 deletions
diff --git a/drivers/mfd/glamo/Kconfig b/drivers/mfd/glamo/Kconfig index 60d29c92ef1..eaa415df890 100644 --- a/drivers/mfd/glamo/Kconfig +++ b/drivers/mfd/glamo/Kconfig @@ -55,3 +55,12 @@ config MFD_GLAMO_MCI neo1973 GTA-02. If unsure, say N. + +config MFD_GLAMO_DRM + tristate "Glamo DRM support" + depends on MFD_GLAMO && DRM + help + Direct Rendering Manager interface for the S-Media GLAMO chip, as + used in Openmoko neo1973 GTA-02. + + If unsure, say N. diff --git a/drivers/mfd/glamo/Makefile b/drivers/mfd/glamo/Makefile index dc64d50fa13..0e951ccf200 100644 --- a/drivers/mfd/glamo/Makefile +++ b/drivers/mfd/glamo/Makefile @@ -9,4 +9,5 @@ obj-$(CONFIG_MFD_GLAMO_SPI_GPIO) += glamo-spi-gpio.o obj-$(CONFIG_MFD_GLAMO_FB) += glamo-fb.o obj-$(CONFIG_MFD_GLAMO_SPI_FB) += glamo-lcm-spi.o obj-$(CONFIG_MFD_GLAMO_MCI) += glamo-mci.o +obj-$(CONFIG_MFD_GLAMO_DRM) += glamo-drm.o diff --git a/drivers/mfd/glamo/glamo-core.c b/drivers/mfd/glamo/glamo-core.c index 28dc1f309ac..5a8fda2404c 100644 --- a/drivers/mfd/glamo/glamo-core.c +++ b/drivers/mfd/glamo/glamo-core.c @@ -175,93 +175,24 @@ static inline void glamo_vmem_read(struct glamo_core *glamo, u_int16_t *buf, /*********************************************************************** * resources of sibling devices ***********************************************************************/ - -#if 0 -static struct resource glamo_core_resources[] = { +static struct resource glamo_cmdq_resources[] = { { - .start = GLAMO_REGOFS_GENERIC, - .end = GLAMO_REGOFS_GENERIC + 0x400, - .flags = IORESOURCE_MEM, + .start = GLAMO_REGOFS_CMDQUEUE, + .end = GLAMO_REGOFS_RISC - 1, + .flags = IORESOURCE_MEM, }, { - .start = 0, - .end = 0, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device glamo_core_dev = { - .name = "glamo-core", - .resource = &glamo_core_resources, - .num_resources = ARRAY_SIZE(glamo_core_resources), -}; -#endif - -static struct resource glamo_jpeg_resources[] = { - { - .start = GLAMO_REGOFS_JPEG, - .end = GLAMO_REGOFS_MPEG - 1, - .flags = IORESOURCE_MEM, - }, { - .start = IRQ_GLAMO_JPEG, - .end = IRQ_GLAMO_JPEG, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device glamo_jpeg_dev = { - .name = "glamo-jpeg", - .resource = glamo_jpeg_resources, - .num_resources = ARRAY_SIZE(glamo_jpeg_resources), -}; - -static struct resource glamo_mpeg_resources[] = { - { - .start = GLAMO_REGOFS_MPEG, - .end = GLAMO_REGOFS_LCD - 1, - .flags = IORESOURCE_MEM, - }, { - .start = IRQ_GLAMO_MPEG, - .end = IRQ_GLAMO_MPEG, - .flags = IORESOURCE_IRQ, + .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_mpeg_dev = { - .name = "glamo-mpeg", - .resource = glamo_mpeg_resources, - .num_resources = ARRAY_SIZE(glamo_mpeg_resources), -}; - -static struct resource glamo_2d_resources[] = { - { - .start = GLAMO_REGOFS_2D, - .end = GLAMO_REGOFS_3D - 1, - .flags = IORESOURCE_MEM, - }, { - .start = IRQ_GLAMO_2D, - .end = IRQ_GLAMO_2D, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device glamo_2d_dev = { - .name = "glamo-2d", - .resource = glamo_2d_resources, - .num_resources = ARRAY_SIZE(glamo_2d_resources), -}; - -static struct resource glamo_3d_resources[] = { - { - .start = GLAMO_REGOFS_3D, - .end = GLAMO_REGOFS_END - 1, - .flags = IORESOURCE_MEM, - }, -}; - -static struct platform_device glamo_3d_dev = { - .name = "glamo-3d", - .resource = glamo_3d_resources, - .num_resources = ARRAY_SIZE(glamo_3d_resources), +static struct platform_device glamo_cmdq_dev = { + .name = "glamo-cmdq", + .resource = glamo_cmdq_resources, + .num_resources = ARRAY_SIZE(glamo_cmdq_resources), }; static struct platform_device glamo_spigpio_dev = { @@ -277,8 +208,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 +232,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,52 +1240,40 @@ static int __init glamo_probe(struct platform_device *pdev) glamo->pdata->glamo_irq_is_wired; /* start creating the siblings */ + glamo->pdata->glamo = glamo; - glamo_2d_dev.dev.parent = &pdev->dev; - mangle_mem_resources(glamo_2d_dev.resource, - glamo_2d_dev.num_resources, glamo->mem); - platform_device_register(&glamo_2d_dev); - - glamo_3d_dev.dev.parent = &pdev->dev; - mangle_mem_resources(glamo_3d_dev.resource, - glamo_3d_dev.num_resources, glamo->mem); - platform_device_register(&glamo_3d_dev); - - glamo_jpeg_dev.dev.parent = &pdev->dev; - mangle_mem_resources(glamo_jpeg_dev.resource, - glamo_jpeg_dev.num_resources, glamo->mem); - platform_device_register(&glamo_jpeg_dev); - - glamo_mpeg_dev.dev.parent = &pdev->dev; - mangle_mem_resources(glamo_mpeg_dev.resource, - glamo_mpeg_dev.num_resources, glamo->mem); - platform_device_register(&glamo_mpeg_dev); + /* Command queue device (for DRM) */ + glamo_cmdq_dev.dev.parent = &pdev->dev; + glamo_cmdq_dev.dev.platform_data = glamo; + mangle_mem_resources(glamo_cmdq_dev.resource, + glamo_cmdq_dev.num_resources, glamo->mem); + platform_device_register(&glamo_cmdq_dev); - glamo->pdata->glamo = glamo; + /* Frambuffer device */ glamo_fb_dev.dev.parent = &pdev->dev; glamo_fb_dev.dev.platform_data = glamo->pdata; mangle_mem_resources(glamo_fb_dev.resource, glamo_fb_dev.num_resources, glamo->mem); platform_device_register(&glamo_fb_dev); + /* GPIO */ glamo->pdata->spigpio_info->glamo = glamo; glamo_spigpio_dev.dev.parent = &pdev->dev; glamo_spigpio_dev.dev.platform_data = glamo->pdata->spigpio_info; platform_device_register(&glamo_spigpio_dev); + /* MMC */ glamo_mmc_dev = glamo->pdata->mmc_dev; glamo_mmc_dev->name = "glamo-mci"; glamo_mmc_dev->dev.parent = &pdev->dev; glamo_mmc_dev->resource = glamo_mmc_resources; glamo_mmc_dev->num_resources = ARRAY_SIZE(glamo_mmc_resources); - - /* we need it later to give to the engine enable and disable */ glamo_mci_def_pdata.pglamo = glamo; mangle_mem_resources(glamo_mmc_dev->resource, glamo_mmc_dev->num_resources, glamo->mem); platform_device_register(glamo_mmc_dev); - /* only request the generic, hostbus and memory controller MMIO */ + /* Only request the generic, hostbus and memory controller MMIO */ glamo->mem = request_mem_region(glamo->mem->start, GLAMO_REGOFS_VIDCAP, "glamo-core"); if (!glamo->mem) { diff --git a/drivers/mfd/glamo/glamo-core.h b/drivers/mfd/glamo/glamo-core.h index 8e09564bc3f..8ab0491c064 100644 --- a/drivers/mfd/glamo/glamo-core.h +++ b/drivers/mfd/glamo/glamo-core.h @@ -3,18 +3,35 @@ #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) +/* A 640x480, 16bpp, double-buffered framebuffer */ +#define GLAMO_FB_SIZE (640 * 480 * 4) /* == 0x12c000 */ +/* Arbitrarily determined amount for the hardware cursor */ +#define GLAMO_CURSOR_SIZE (4096) +#define GLAMO_MMC_BUFFER_SIZE (64 * 1024) /* 64k MMC buffer */ +#define GLAMO_CMDQ_SIZE (128 * 1024) /* 128k ring buffer */ +/* 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-drm.c b/drivers/mfd/glamo/glamo-drm.c new file mode 100644 index 00000000000..18a321c6119 --- /dev/null +++ b/drivers/mfd/glamo/glamo-drm.c @@ -0,0 +1,355 @@ +/* Smedia Glamo 336x/337x driver + * + * Copyright (C) 2009 Openmoko, Inc. Jorge Luis Zapata <turran@openmoko.com> + * Copyright (C) 2008-2009 Thomas White <taw@bitwiz.org.uk> + * + * All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + + +#include <linux/module.h> +#include <linux/platform_device.h> +#include <drm/drmP.h> +#include <drm/glamo_drm.h> + +#include "glamo-core.h" + +#define DRIVER_AUTHOR "Openmoko, Inc." +#define DRIVER_NAME "glamo-drm" +#define DRIVER_DESC "SMedia Glamo 3362" +#define DRIVER_DATE "20090217" + +#define RESSIZE(ressource) (((ressource)->end - (ressource)->start)+1) + +static int glamo_ioctl_cmdbuf(struct drm_device *dev, void *data, + struct drm_file *file_priv) +{ + printk(KERN_INFO "glamo_ioctl_cmdbuf\n"); + return 0; +} + +static int glamo_ioctl_swap(struct drm_device *dev, void *data, + struct drm_file *file_priv) +{ + printk(KERN_INFO "glamo_ioctl_swap\n"); + return 0; +} + +static int glamo_ioctl_gem_info(struct drm_device *dev, void *data, + struct drm_file *file_priv) +{ + printk(KERN_INFO "glamo_ioctl_gem_info\n"); + return 0; +} + +static int glamo_ioctl_gem_create(struct drm_device *dev, void *data, + struct drm_file *file_priv) +{ + printk(KERN_INFO "glamo_ioctl_gem_create\n"); + return 0; +} + +static int glamo_ioctl_gem_mmap(struct drm_device *dev, void *data, + struct drm_file *file_priv) +{ + printk(KERN_INFO "glamo_ioctl_gem_mmap\n"); + return 0; +} + +static int glamo_ioctl_gem_pin(struct drm_device *dev, void *data, + struct drm_file *file_priv) +{ + printk(KERN_INFO "glamo_ioctl_gem_pin\n"); + return 0; +} + +static int glamo_ioctl_gem_unpin(struct drm_device *dev, void *data, + struct drm_file *file_priv) +{ + printk(KERN_INFO "glamo_ioctl_gem_unpin\n"); + return 0; +} + +static int glamo_ioctl_gem_pread(struct drm_device *dev, void *data, + struct drm_file *file_priv) +{ + printk(KERN_INFO "glamo_ioctl_gem_pread\n"); + return 0; +} + +static int glamo_ioctl_gem_pwrite(struct drm_device *dev, void *data, + struct drm_file *file_priv) +{ + printk(KERN_INFO "glamo_ioctl_gem_pwrite\n"); + return 0; +} + +static int glamo_ioctl_gem_wait_rendering(struct drm_device *dev, void *data, + struct drm_file *file_priv) +{ + printk(KERN_INFO "glamo_ioctl_gem_wait_rendering\n"); + return 0; +} + +struct drm_ioctl_desc glamo_ioctls[] = { + DRM_IOCTL_DEF(DRM_GLAMO_CMDBUF, glamo_ioctl_cmdbuf, DRM_AUTH), + DRM_IOCTL_DEF(DRM_GLAMO_SWAP, glamo_ioctl_swap, DRM_AUTH), + DRM_IOCTL_DEF(DRM_GLAMO_GEM_INFO, glamo_ioctl_gem_info, DRM_AUTH), + DRM_IOCTL_DEF(DRM_GLAMO_GEM_CREATE, glamo_ioctl_gem_create, DRM_AUTH), + DRM_IOCTL_DEF(DRM_GLAMO_GEM_MMAP, glamo_ioctl_gem_mmap, DRM_AUTH), + DRM_IOCTL_DEF(DRM_GLAMO_GEM_PIN, glamo_ioctl_gem_pin, DRM_AUTH), + DRM_IOCTL_DEF(DRM_GLAMO_GEM_UNPIN, glamo_ioctl_gem_unpin, DRM_AUTH), + DRM_IOCTL_DEF(DRM_GLAMO_GEM_PREAD, glamo_ioctl_gem_pread, DRM_AUTH), + DRM_IOCTL_DEF(DRM_GLAMO_GEM_PWRITE, glamo_ioctl_gem_pwrite, DRM_AUTH), + DRM_IOCTL_DEF(DRM_GLAMO_GEM_WAIT_RENDERING, glamo_ioctl_gem_wait_rendering, DRM_AUTH), +}; + +struct glamodrm_handle { + + /* This device */ + struct device *dev; + /* The parent device handle */ + struct glamo_core *glamo_core; + + /* MMIO region */ + struct resource *reg; + char __iomem *base; + + /* VRAM region */ + struct resource *vram; + char __iomem *vram_base; + + ssize_t vram_size; +}; + +static int glamo_command(struct drm_device *dev, void *data, + struct drm_file *file_priv) +{ + return 0; +} + +int glamodrm_firstopen(struct drm_device *dev) +{ + DRM_DEBUG("\n"); + return 0; +} + +int glamodrm_open(struct drm_device *dev, struct drm_file *fh) +{ + DRM_DEBUG("\n"); + return 0; +} + +void glamodrm_preclose(struct drm_device *dev, struct drm_file *fh) +{ + DRM_DEBUG("\n"); +} + +void glamodrm_postclose(struct drm_device *dev, struct drm_file *fh) +{ + DRM_DEBUG("\n"); +} + +void glamodrm_lastclose(struct drm_device *dev) +{ + DRM_DEBUG("\n"); +} + +static int glamodrm_master_create(struct drm_device *dev, struct drm_master *master) +{ + DRM_DEBUG("\n"); + + return 0; +} + +static void glamodrm_master_destroy(struct drm_device *dev, struct drm_master *master) +{ + DRM_DEBUG("\n"); +} + +static struct drm_driver glamodrm_drm_driver = { + .driver_features = DRIVER_IS_PLATFORM, + .firstopen = glamodrm_firstopen, + .open = glamodrm_open, + .preclose = glamodrm_preclose, + .postclose = glamodrm_postclose, + .lastclose = glamodrm_lastclose, + .reclaim_buffers = drm_core_reclaim_buffers, + .get_map_ofs = drm_core_get_map_ofs, + .get_reg_ofs = drm_core_get_reg_ofs, + .master_create = glamodrm_master_create, + .master_destroy = glamodrm_master_destroy, + /* TODO GEM interface + .gem_init_object = glamodrm_gem_init_object, + .gem_free_object = glamodrm_gem_free_object, + .gem_vm_ops = &glamodrm_gem_vm_ops, + */ + .fops = { + .owner = THIS_MODULE, + .open = drm_open, + .release = drm_release, + .ioctl = drm_ioctl, + .mmap = drm_mmap, + .poll = drm_poll, + .fasync = drm_fasync, + }, + .major = 0, + .minor = 1, + .patchlevel = 0, + .name = DRIVER_NAME, + .desc = DRIVER_DESC, + .date = DRIVER_DATE, +}; + + +static int glamodrm_probe(struct platform_device *pdev) +{ + int rc; + struct glamodrm_handle *glamodrm; + + printk(KERN_INFO "[glamo-drm] SMedia Glamo Direct Rendering Support\n"); + + glamodrm = kmalloc(sizeof(*glamodrm), GFP_KERNEL); + if ( !glamodrm ) + return -ENOMEM; + platform_set_drvdata(pdev, glamodrm); + glamodrm->glamo_core = pdev->dev.platform_data; + + /* Find the command queue registers */ + glamodrm->reg = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if ( !glamodrm->reg ) { + dev_err(&pdev->dev, "Unable to find cmdq registers.\n"); + rc = -ENOENT; + goto out_free; + } + glamodrm->reg = request_mem_region(glamodrm->reg->start, + RESSIZE(glamodrm->reg), pdev->name); + if ( !glamodrm->reg ) { + dev_err(&pdev->dev, "failed to request MMIO region\n"); + rc = -ENOENT; + goto out_free; + } + glamodrm->base = ioremap(glamodrm->reg->start, RESSIZE(glamodrm->reg)); + if ( !glamodrm->base ) { + dev_err(&pdev->dev, "failed to ioremap() MMIO memory\n"); + rc = -ENOENT; + goto out_release_regs; + } + + /* Find the working VRAM */ + glamodrm->vram = platform_get_resource(pdev, IORESOURCE_MEM, 1); + if ( !glamodrm->vram ) { + dev_err(&pdev->dev, "Unable to find work VRAM.\n"); + rc = -ENOENT; + goto out_unmap_regs; + } + glamodrm->vram = request_mem_region(glamodrm->vram->start, + RESSIZE(glamodrm->vram), pdev->name); + if ( !glamodrm->vram ) { + dev_err(&pdev->dev, "failed to request VRAM region\n"); + rc = -ENOENT; + goto out_unmap_regs; + } + glamodrm->vram_base = ioremap(glamodrm->vram->start, + RESSIZE(glamodrm->vram)); + if ( !glamodrm->vram_base ) { + dev_err(&pdev->dev, "failed to ioremap() MMIO memory\n"); + rc = -ENOENT; + goto out_release_vram; + } + + glamodrm->vram_size = GLAMO_WORK_SIZE; + printk(KERN_INFO "[glamo-drm] %lli bytes of Glamo RAM to work with\n", + (long long int)glamodrm->vram_size); + + /* Initialise DRM */ + drm_platform_init(&glamodrm_drm_driver, pdev); + + /* Enable 2D and 3D */ + glamo_engine_enable(glamodrm->glamo_core, GLAMO_ENGINE_3D); + glamo_engine_reset(glamodrm->glamo_core, GLAMO_ENGINE_3D); + msleep(5); + glamo_engine_enable(glamodrm->glamo_core, GLAMO_ENGINE_2D); + glamo_engine_reset(glamodrm->glamo_core, GLAMO_ENGINE_2D); + msleep(5); + + return 0; + +out_release_vram: + release_mem_region(glamodrm->vram->start, RESSIZE(glamodrm->vram)); +out_unmap_regs: + iounmap(glamodrm->base); +out_release_regs: + release_mem_region(glamodrm->reg->start, RESSIZE(glamodrm->reg)); +out_free: + kfree(glamodrm); + pdev->dev.driver_data = NULL; + return rc; +} + + +static int glamodrm_remove(struct platform_device *pdev) +{ + struct glamodrm_handle *glamodrm = platform_get_drvdata(pdev); + struct glamo_core *glamocore = pdev->dev.platform_data; + + glamo_engine_disable(glamocore, GLAMO_ENGINE_2D); + glamo_engine_disable(glamocore, GLAMO_ENGINE_3D); + + drm_exit(&glamodrm_drm_driver); + + platform_set_drvdata(pdev, NULL); + + /* Release registers */ + iounmap(glamodrm->base); + release_mem_region(glamodrm->reg->start, RESSIZE(glamodrm->reg)); + + /* Release VRAM */ + iounmap(glamodrm->vram_base); + release_mem_region(glamodrm->vram->start, RESSIZE(glamodrm->vram)); + + kfree(glamodrm); + + return 0; +} + +static struct platform_driver glamodrm_driver = { + .probe = glamodrm_probe, + .remove = glamodrm_remove, + .driver = { + .name = "glamo-cmdq", + .owner = THIS_MODULE, + }, +}; + +static int __devinit glamodrm_init(void) +{ + return platform_driver_register(&glamodrm_driver); +} + +static void __exit glamodrm_exit(void) +{ + platform_driver_unregister(&glamodrm_driver); +} + +module_init(glamodrm_init); +module_exit(glamodrm_exit); + +MODULE_AUTHOR(DRIVER_AUTHOR); +MODULE_DESCRIPTION(DRIVER_DESC); +MODULE_LICENSE("GPL"); diff --git a/drivers/mfd/glamo/glamo-fb.c b/drivers/mfd/glamo/glamo-fb.c index 1ebb87d1276..589b924b6bf 100644 --- a/drivers/mfd/glamo/glamo-fb.c +++ b/drivers/mfd/glamo/glamo-fb.c @@ -734,6 +734,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, @@ -989,6 +995,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, diff --git a/drivers/mfd/glamo/glamo-mci.c b/drivers/mfd/glamo/glamo-mci.c index bc3ed66d43c..b9442091d02 100644 --- a/drivers/mfd/glamo/glamo-mci.c +++ b/drivers/mfd/glamo/glamo-mci.c @@ -573,15 +573,15 @@ static int glamo_mci_prepare_pio(struct glamo_mci_host *host, * Read is halfway up the buffer and write is at the start */ if (data->flags & MMC_DATA_READ) { - writew((u16)(GLAMO_FB_SIZE + (RESSIZE(host->mem_data) / 2)), + writew((u16)(GLAMO_OFFSET_MMC + (RESSIZE(host->mem_data) / 2)), host->base + GLAMO_REG_MMC_WDATADS1); - writew((u16)((GLAMO_FB_SIZE + + writew((u16)((GLAMO_OFFSET_MMC + (RESSIZE(host->mem_data) / 2)) >> 16), host->base + GLAMO_REG_MMC_WDATADS2); } else { - writew((u16)GLAMO_FB_SIZE, host->base + + writew((u16)GLAMO_OFFSET_MMC, host->base + GLAMO_REG_MMC_RDATADS1); - writew((u16)(GLAMO_FB_SIZE >> 16), host->base + + writew((u16)(GLAMO_OFFSET_MMC >> 16), host->base + GLAMO_REG_MMC_RDATADS2); } |