aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2009-07-15 12:02:49 +0100
committerThomas White <taw@bitwiz.org.uk>2009-07-15 12:02:49 +0100
commit7903aad4738b38f48fb8800782b186be8dfaa024 (patch)
treea8b20157c57c9dc35f049725d38fb2ca645c816a
parentd1bb1b43b8db0926715d4bb1bbd9abcb88a4c5ee (diff)
parent5b85050a8f1e7db530f803627ba6371ca9c0ba9b (diff)
Merge branch 'drm-kms' into drm-tracking
Conflicts: drivers/mfd/glamo/glamo-cmdq.c drivers/mfd/glamo/glamo-cmdq.h drivers/mfd/glamo/glamo-drm-drv.c drivers/mfd/glamo/glamo-drm-private.h Signed-off-by: Thomas White <taw@bitwiz.org.uk>
-rw-r--r--arch/arm/configs/gta02_drm_defconfig31
-rw-r--r--drivers/gpu/drm/drm_stub.c26
-rw-r--r--drivers/mfd/glamo/Kconfig22
-rw-r--r--drivers/mfd/glamo/Makefile3
-rw-r--r--drivers/mfd/glamo/glamo-buffer.c55
-rw-r--r--drivers/mfd/glamo/glamo-buffer.h3
-rw-r--r--drivers/mfd/glamo/glamo-cmdq.c31
-rw-r--r--drivers/mfd/glamo/glamo-cmdq.h3
-rw-r--r--drivers/mfd/glamo/glamo-core.c69
-rw-r--r--drivers/mfd/glamo/glamo-core.h13
-rw-r--r--drivers/mfd/glamo/glamo-display.c916
-rw-r--r--drivers/mfd/glamo/glamo-display.h39
-rw-r--r--drivers/mfd/glamo/glamo-drm-drv.c150
-rw-r--r--drivers/mfd/glamo/glamo-drm-private.h57
-rw-r--r--drivers/mfd/glamo/glamo-fb.c2
-rw-r--r--drivers/mfd/glamo/glamo-kms-fb.c553
-rw-r--r--drivers/mfd/glamo/glamo-kms-fb.h41
-rw-r--r--drivers/video/display/jbt6k74.c17
18 files changed, 1883 insertions, 148 deletions
diff --git a/arch/arm/configs/gta02_drm_defconfig b/arch/arm/configs/gta02_drm_defconfig
index adea7d4c8cd..c6bc8933ecc 100644
--- a/arch/arm/configs/gta02_drm_defconfig
+++ b/arch/arm/configs/gta02_drm_defconfig
@@ -1,7 +1,7 @@
#
# Automatically generated make config: don't edit
# Linux kernel version: 2.6.29-rc3
-# Sun Apr 19 18:51:41 2009
+# Thu Jul 2 20:40:33 2009
#
CONFIG_ARM=y
CONFIG_HAVE_PWM=y
@@ -35,7 +35,7 @@ CONFIG_EXPERIMENTAL=y
CONFIG_BROKEN_ON_SMP=y
CONFIG_LOCK_KERNEL=y
CONFIG_INIT_ENV_ARG_LIMIT=32
-CONFIG_LOCALVERSION="-mokodev"
+CONFIG_LOCALVERSION=""
# CONFIG_LOCALVERSION_AUTO is not set
CONFIG_SWAP=y
CONFIG_SYSVIPC=y
@@ -1084,7 +1084,7 @@ CONFIG_I2C=y
CONFIG_I2C_BOARDINFO=y
CONFIG_I2C_CHARDEV=y
CONFIG_I2C_HELPER_AUTO=y
-CONFIG_I2C_ALGOBIT=m
+CONFIG_I2C_ALGOBIT=y
#
# I2C Hardware Bus support
@@ -1283,11 +1283,14 @@ CONFIG_PCF50633_ADC=y
CONFIG_PCF50633_GPIO=y
# CONFIG_MFD_PCF50606 is not set
CONFIG_MFD_GLAMO=y
-CONFIG_MFD_GLAMO_FB=y
+
+#
+# SMedia Glamo 336x/337x engine drivers
+#
+# CONFIG_MFD_GLAMO_FB is not set
CONFIG_MFD_GLAMO_SPI_GPIO=y
-CONFIG_MFD_GLAMO_SPI_FB=y
CONFIG_MFD_GLAMO_MCI=y
-CONFIG_MFD_GLAMO_DRM=m
+CONFIG_MFD_GLAMO_DRM=y
#
# Multimedia devices
@@ -1309,7 +1312,7 @@ CONFIG_DAB=y
#
# Graphics support
#
-CONFIG_DRM=m
+CONFIG_DRM=y
# CONFIG_VGASTATE is not set
CONFIG_VIDEO_OUTPUT_CONTROL=y
CONFIG_FB=y
@@ -1807,17 +1810,13 @@ CONFIG_EXT2_FS=y
# CONFIG_EXT2_FS_XIP is not set
CONFIG_EXT3_FS=y
# CONFIG_EXT3_FS_XATTR is not set
-CONFIG_EXT4_FS=y
-CONFIG_EXT4DEV_COMPAT=y
-CONFIG_EXT4_FS_XATTR=y
-# CONFIG_EXT4_FS_POSIX_ACL is not set
-CONFIG_EXT4_FS_SECURITY=y
+# CONFIG_EXT4_FS is not set
CONFIG_JBD=y
# CONFIG_JBD_DEBUG is not set
-CONFIG_JBD2=y
-# CONFIG_JBD2_DEBUG is not set
-CONFIG_FS_MBCACHE=y
-# CONFIG_REISERFS_FS is not set
+CONFIG_REISERFS_FS=m
+# CONFIG_REISERFS_CHECK is not set
+# CONFIG_REISERFS_PROC_INFO is not set
+# CONFIG_REISERFS_FS_XATTR is not set
# CONFIG_JFS_FS is not set
CONFIG_FS_POSIX_ACL=y
CONFIG_FILE_LOCKING=y
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index 5f392b7be23..93ce6cc030f 100644
--- a/drivers/gpu/drm/drm_stub.c
+++ b/drivers/gpu/drm/drm_stub.c
@@ -452,10 +452,29 @@ int drm_get_platform_dev(struct platform_device *pdev,
printk(KERN_ERR "DRM: Fill_in_dev failed.\n");
goto err_g1;
}
-
dev->platform_dev = pdev;
+
+ if (drm_core_check_feature(dev, DRIVER_MODESET)) {
+ ret = drm_get_minor(dev, &dev->control, DRM_MINOR_CONTROL);
+ if (ret)
+ goto err_g2;
+ }
+
if ((ret = drm_get_minor(dev, &dev->primary, DRM_MINOR_LEGACY)))
- goto err_g1;
+ goto err_g3;
+
+ if (dev->driver->load) {
+ ret = dev->driver->load(dev, 0);
+ if (ret)
+ goto err_g3;
+ }
+
+ /* setup the grouping for the legacy output */
+ if (drm_core_check_feature(dev, DRIVER_MODESET)) {
+ ret = drm_mode_group_init_legacy_group(dev, &dev->primary->mode_group);
+ if (ret)
+ goto err_g3;
+ }
list_add_tail(&dev->driver_item, &driver->device_list);
@@ -465,6 +484,9 @@ int drm_get_platform_dev(struct platform_device *pdev,
return 0;
+err_g3:
+ drm_put_minor(&dev->primary);
+err_g2:
err_g1:
drm_free(dev, sizeof(*dev), DRM_MEM_STUB);
return ret;
diff --git a/drivers/mfd/glamo/Kconfig b/drivers/mfd/glamo/Kconfig
index 9c5b11b8372..7db45288c38 100644
--- a/drivers/mfd/glamo/Kconfig
+++ b/drivers/mfd/glamo/Kconfig
@@ -1,12 +1,15 @@
config MFD_GLAMO
- bool "Smedia Glamo 336x/337x support"
+ bool "SMedia Glamo 336x/337x support"
help
This enables the core driver for the Smedia Glamo 336x/337x
multi-function device. It includes irq_chip demultiplex as
well as clock / power management and GPIO support.
+menu "SMedia Glamo 336x/337x engine drivers"
+ depends on MFD_GLAMO
+
config MFD_GLAMO_FB
- tristate "Smedia Glamo 336x/337x framebuffer support"
+ tristate "SMedia Glamo 336x/337x framebuffer support"
depends on FB && MFD_GLAMO
select FB_CFB_FILLRECT
select FB_CFB_COPYAREA
@@ -31,7 +34,6 @@ config MFD_GLAMO_FB_XGLAMO_WORKAROUND
If unsure, say N.
-
config MFD_GLAMO_SPI_GPIO
tristate "Glamo GPIO SPI bitbang support"
depends on MFD_GLAMO
@@ -59,10 +61,18 @@ config MFD_GLAMO_MCI
If unsure, say N.
config MFD_GLAMO_DRM
- tristate "Glamo DRM support"
+ tristate "Glamo direct rendering and kernel modesetting support"
depends on MFD_GLAMO && DRM
+ select FB_CFB_FILLRECT
+ select FB_CFB_COPYAREA
+ select FB_CFB_IMAGEBLIT
help
- Direct Rendering Manager interface for the S-Media GLAMO chip, as
- used in Openmoko neo1973 GTA-02.
+ Direct Rendering Manager interface for the S-Media Glamo chip, as
+ used in Openmoko FreeRunner (GTA02).
+
+ This DRM driver includes kernel modesetting (KMS) support. As such,
+ do not select MFD_GLAMO_FB above if you choose to enable this option.
If unsure, say N.
+
+endmenu
diff --git a/drivers/mfd/glamo/Makefile b/drivers/mfd/glamo/Makefile
index 75476de5ad7..155427c5c61 100644
--- a/drivers/mfd/glamo/Makefile
+++ b/drivers/mfd/glamo/Makefile
@@ -12,4 +12,5 @@ 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
-glamo-drm-objs := glamo-drm-drv.o glamo-cmdq.o glamo-buffer.o
+glamo-drm-objs := glamo-drm-drv.o glamo-cmdq.o glamo-buffer.o \
+ glamo-display.o glamo-kms-fb.o
diff --git a/drivers/mfd/glamo/glamo-buffer.c b/drivers/mfd/glamo/glamo-buffer.c
index 945824a1b15..c8172cce503 100644
--- a/drivers/mfd/glamo/glamo-buffer.c
+++ b/drivers/mfd/glamo/glamo-buffer.c
@@ -27,49 +27,71 @@
#include "glamo-drm-private.h"
-int glamo_ioctl_gem_create(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
+struct drm_gem_object *glamo_gem_object_alloc(struct drm_device *dev, int size,
+ int alignment)
{
- struct drm_glamo_gem_create *args = data;
struct drm_gem_object *obj;
struct glamodrm_handle *gdrm;
struct drm_glamo_gem_object *gobj;
- int handle, ret;
gdrm = dev->dev_private;
- args->size = roundup(args->size, PAGE_SIZE);
+ size = roundup(size, PAGE_SIZE);
- obj = drm_gem_object_alloc(dev, args->size);
- if (obj == NULL) return -ENOMEM;
+ obj = drm_gem_object_alloc(dev, size);
+ if (obj == NULL) return NULL;
+ /* See glamodrm_gem_init_object() below */
gobj = obj->driver_private;
/* Allocate memory for this object in VRAM */
- gobj->block = drm_mm_search_free(gdrm->mmgr, args->size,
- args->alignment, 1);
+ gobj->block = drm_mm_search_free(gdrm->mmgr, size, alignment, 1);
if (!gobj->block) {
- ret = -ENOMEM;
goto fail;
}
- gobj->block = drm_mm_get_block(gobj->block, args->size,
- args->alignment);
+ gobj->block = drm_mm_get_block(gobj->block, size, alignment);
if (!gobj->block) {
- ret = -ENOMEM;
goto fail;
}
+ return obj;
+
+fail:
+ mutex_lock(&dev->struct_mutex);
+ drm_gem_object_unreference(obj);
+ mutex_unlock(&dev->struct_mutex);
+ printk(KERN_INFO "[glamo-drm] Failed to allocate object\n");
+
+ return NULL;
+}
+
+
+int glamo_ioctl_gem_create(struct drm_device *dev, void *data,
+ struct drm_file *file_priv)
+{
+ struct drm_glamo_gem_create *args = data;
+ struct drm_gem_object *obj;
+ struct drm_glamo_gem_object *gobj;
+ int handle, ret;
+
+ /* Create an object */
+ obj = glamo_gem_object_alloc(dev, args->size, args->alignment);
+ if ( obj == NULL ) return -ENOMEM;
+
+ /* Create a handle for it */
ret = drm_gem_handle_create(file_priv, obj, &handle);
mutex_lock(&dev->struct_mutex);
drm_gem_object_handle_unreference(obj);
mutex_unlock(&dev->struct_mutex);
-
if (ret) goto fail;
-
+
+ /* Watchpoint */
+ gobj = obj->driver_private;
printk(KERN_INFO "[glamo-drm] GEM object %i: %li bytes at 0x%lx\n",
handle, gobj->block->size, gobj->block->start);
+
+ /* Return */
args->handle = handle;
-
return 0;
fail:
@@ -77,7 +99,6 @@ fail:
drm_gem_object_unreference(obj);
mutex_unlock(&dev->struct_mutex);
printk(KERN_INFO "[glamo-drm] Failed to allocate object\n");
-
return ret;
}
diff --git a/drivers/mfd/glamo/glamo-buffer.h b/drivers/mfd/glamo/glamo-buffer.h
index 7d87e428d79..41f18fd7989 100644
--- a/drivers/mfd/glamo/glamo-buffer.h
+++ b/drivers/mfd/glamo/glamo-buffer.h
@@ -36,6 +36,9 @@ extern int glamodrm_gem_init_object(struct drm_gem_object *obj);
extern void glamodrm_gem_free_object(struct drm_gem_object *obj);
+extern struct drm_gem_object *glamo_gem_object_alloc(struct drm_device *dev,
+ int size, int alignment);
+
extern int glamo_ioctl_gem_create(struct drm_device *dev, void *data,
struct drm_file *file_priv);
diff --git a/drivers/mfd/glamo/glamo-cmdq.c b/drivers/mfd/glamo/glamo-cmdq.c
index 32fad98be8a..f2a124a6e18 100644
--- a/drivers/mfd/glamo/glamo-cmdq.c
+++ b/drivers/mfd/glamo/glamo-cmdq.c
@@ -89,7 +89,7 @@ static u32 glamo_get_write(struct glamodrm_handle *gdrm)
return ring_write;
}
-#if 0
+#if 0
/* hopefully we will never need that again */
@@ -219,9 +219,9 @@ static int glamo_add_to_ring(struct glamodrm_handle *gdrm, u16 *addr,
down(&gdrm->add_to_ring);
- printk( KERN_INFO "[glamo-drm] IOCTL2 CMDQ at: %d-%d, CMDQ CTRL: %d, CMDQ STATUS: %d\n",
+ printk( KERN_INFO "[glamo-drm] IOCTL2 CMDQ at: %d-%d, CMDQ CTRL: %d, CMDQ STATUS: %d\n",
glamo_get_read(gdrm), glamo_get_write(gdrm),
- reg_read(gdrm, GLAMO_REG_CMDQ_CONTROL),
+ reg_read(gdrm, GLAMO_REG_CMDQ_CONTROL),
reg_read(gdrm, GLAMO_REG_CMDQ_STATUS) );
@@ -292,7 +292,7 @@ static int glamo_do_relocation(struct glamodrm_handle *gdrm,
goto fail;
}
- addr = GLAMO_OFFSET_WORK + gobj->block->start;
+ addr = GLAMO_OFFSET_FB + gobj->block->start;
addr_low = addr & 0xffff;
addr_high = (addr >> 16) & 0x7f;
printk(KERN_INFO "Addr low 0x%x, high 0x%x\n",
@@ -329,9 +329,9 @@ int glamo_ioctl_cmdbuf(struct drm_device *dev, void *data,
gdrm = dev->dev_private;
- printk( KERN_INFO "[glamo-drm] IOCTL CMDQ at: %d-%d, CMDQ CTRL: %d, CMDQ STATUS: %d\n",
+ printk( KERN_INFO "[glamo-drm] IOCTL CMDQ at: %d-%d, CMDQ CTRL: %d, CMDQ STATUS: %d\n",
glamo_get_read(gdrm), glamo_get_write(gdrm),
- reg_read(gdrm, GLAMO_REG_CMDQ_CONTROL),
+ reg_read(gdrm, GLAMO_REG_CMDQ_CONTROL),
reg_read(gdrm, GLAMO_REG_CMDQ_STATUS) );
@@ -390,7 +390,7 @@ int glamo_cmdq_init(struct glamodrm_handle *gdrm)
}
glamo_engine_enable(gdrm->glamo_core, GLAMO_ENGINE_CMDQ);
- glamo_engine_reset(gdrm->glamo_core, GLAMO_ENGINE_CMDQ);
+ glamo_engine_reset(gdrm->glamo_core, GLAMO_ENGINE_CMDQ);
/* Set up command queue location */
reg_write(gdrm, GLAMO_REG_CMDQ_BASE_ADDRL,
@@ -407,15 +407,28 @@ int glamo_cmdq_init(struct glamodrm_handle *gdrm)
5 << 8 | /* no interrupt */
8 << 4); /* HQ threshold */
- printk( KERN_INFO "[glamo-drm] INIT CMDQ at: %d-%d, CMDQ CTRL: %d, CMDQ STATUS: %d\n",
+ printk( KERN_INFO "[glamo-drm] INIT CMDQ at: %d-%d, CMDQ CTRL: %d, CMDQ STATUS: %d\n",
glamo_get_read(gdrm), glamo_get_write(gdrm),
- reg_read(gdrm, GLAMO_REG_CMDQ_CONTROL),
+ reg_read(gdrm, GLAMO_REG_CMDQ_CONTROL),
reg_read(gdrm, GLAMO_REG_CMDQ_STATUS) );
return 0;
}
+
int glamo_cmdq_shutdown(struct glamodrm_handle *gdrm)
{
return 0;
}
+
+
+void glamo_cmdq_suspend(struct glamodrm_handle *gdrm)
+{
+ /* Placeholder... */
+}
+
+
+void glamo_cmdq_resume(struct glamodrm_handle *gdrm)
+{
+ glamo_cmdq_init(gdrm);
+}
diff --git a/drivers/mfd/glamo/glamo-cmdq.h b/drivers/mfd/glamo/glamo-cmdq.h
index e72fea9bec5..35c8bea1dcb 100644
--- a/drivers/mfd/glamo/glamo-cmdq.h
+++ b/drivers/mfd/glamo/glamo-cmdq.h
@@ -36,6 +36,7 @@ extern int glamo_ioctl_cmdbuf(struct drm_device *dev, void *data,
extern int glamo_cmdq_init(struct glamodrm_handle *gdrm);
extern int glamo_cmdq_shutdown(struct glamodrm_handle *gdrm);
-
+extern void glamo_cmdq_suspend(struct glamodrm_handle *gdrm);
+extern void glamo_cmdq_resume(struct glamodrm_handle *gdrm);
#endif /* __GLAMO_CMDQ_H */
diff --git a/drivers/mfd/glamo/glamo-core.c b/drivers/mfd/glamo/glamo-core.c
index a485e34f748..d8ebf400180 100644
--- a/drivers/mfd/glamo/glamo-core.c
+++ b/drivers/mfd/glamo/glamo-core.c
@@ -175,59 +175,43 @@ static inline void glamo_vmem_read(struct glamo_core *glamo, u_int16_t *buf,
/***********************************************************************
* resources of sibling devices
***********************************************************************/
-static struct resource glamo_cmdq_resources[] = {
+static struct resource glamo_graphics_resources[] = {
{
.name = "glamo-cmdq-regs",
.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,
- }, {
.name = "glamo-command-queue",
.start = GLAMO_MEM_BASE + GLAMO_OFFSET_CMDQ,
.end = GLAMO_MEM_BASE + GLAMO_OFFSET_CMDQ +
GLAMO_CMDQ_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),
-};
-
-static struct platform_device glamo_spigpio_dev = {
- .name = "glamo-spi-gpio",
-};
-
-static struct resource glamo_fb_resources[] = {
- /* FIXME: those need to be incremented by parent base */
- {
- .name = "glamo-fb-regs",
- .start = GLAMO_REGOFS_LCD,
- .end = GLAMO_REGOFS_MMC - 1,
- .flags = IORESOURCE_MEM,
}, {
.name = "glamo-fb-mem",
.start = GLAMO_MEM_BASE + GLAMO_OFFSET_FB,
.end = GLAMO_MEM_BASE + GLAMO_OFFSET_FB +
GLAMO_FB_SIZE - 1,
.flags = IORESOURCE_MEM,
- },
+ }, {
+ .name = "glamo-fb-regs",
+ .start = GLAMO_REGOFS_LCD,
+ .end = GLAMO_REGOFS_MMC - 1,
+ .flags = IORESOURCE_MEM,
+ }
};
-static struct platform_device glamo_fb_dev = {
- .name = "glamo-fb",
- .resource = glamo_fb_resources,
- .num_resources = ARRAY_SIZE(glamo_fb_resources),
+static struct platform_device glamo_graphics_dev = {
+ .name = "glamo-fb",
+ .resource = glamo_graphics_resources,
+ .num_resources = ARRAY_SIZE(glamo_graphics_resources),
};
+static struct platform_device glamo_spigpio_dev = {
+ .name = "glamo-spi-gpio",
+};
+
+
static struct resource glamo_mmc_resources[] = {
{
/* FIXME: those need to be incremented by parent base */
@@ -1259,18 +1243,11 @@ static int __init glamo_probe(struct platform_device *pdev)
glamo->pdata->glamo = glamo;
/* 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);
-
- /* 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);
+ glamo_graphics_dev.dev.parent = &pdev->dev;
+ glamo_graphics_dev.dev.platform_data = glamo->pdata;
+ mangle_mem_resources(glamo_graphics_dev.resource,
+ glamo_graphics_dev.num_resources, glamo->mem);
+ platform_device_register(&glamo_graphics_dev);
/* GPIO */
glamo->pdata->spigpio_info->glamo = glamo;
@@ -1331,8 +1308,10 @@ static int glamo_remove(struct platform_device *pdev)
}
platform_set_drvdata(pdev, NULL);
- platform_device_unregister(&glamo_fb_dev);
platform_device_unregister(glamo->pdata->mmc_dev);
+ /* FIXME: Don't we need to unregister these as well?
+ * platform_device_unregister(glamo->pdata->graphics_dev);
+ * platform_device_unregister(glamo->pdata->gpio_dev); */
iounmap(glamo->base);
release_mem_region(glamo->mem->start, GLAMO_REGOFS_VIDCAP);
glamo_handle = NULL;
diff --git a/drivers/mfd/glamo/glamo-core.h b/drivers/mfd/glamo/glamo-core.h
index 63390492141..4808ad72bb4 100644
--- a/drivers/mfd/glamo/glamo-core.h
+++ b/drivers/mfd/glamo/glamo-core.h
@@ -7,18 +7,19 @@
* sure we have sufficient memory for other functions of the chip */
/* FIXME: this should be autodetected */
#define GLAMO_INTERNAL_RAM_SIZE 0x800000
-/* 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 \
+#define GLAMO_FB_SIZE (GLAMO_INTERNAL_RAM_SIZE \
- GLAMO_CURSOR_SIZE \
- GLAMO_MMC_BUFFER_SIZE \
- GLAMO_CMDQ_SIZE)
+/* A 640x480, 16bpp, double-buffered framebuffer */
+#if (GLAMO_FB_SIZE < (640 * 480 * 4)) /* == 0x12c000 */
+#error Not enough Glamo VRAM for framebuffer!
+#endif
/* 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
@@ -26,12 +27,10 @@
* 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_FB (0x000000)
#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-display.c b/drivers/mfd/glamo/glamo-display.c
new file mode 100644
index 00000000000..93f056dce43
--- /dev/null
+++ b/drivers/mfd/glamo/glamo-display.c
@@ -0,0 +1,916 @@
+/*
+ * SMedia Glamo 336x/337x display
+ *
+ * Copyright (C) 2008-2009 Thomas White <taw@bitwiz.org.uk>
+ *
+ * Based on glamo-fb.c (C) 2007-2008 by Openmoko, Inc.
+ * Author: Harald Welte <laforge@openmoko.org>
+ * 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
+ *
+ *
+ * Based on intel_display.c and intel_crt.c from drivers/gpu/drm/i915
+ * to which the following licence applies:
+ *
+ * Copyright © 2006-2007 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Eric Anholt <eric@anholt.net>
+ *
+ */
+
+#define DEBUG 1
+
+#include <drm/drmP.h>
+#include <drm/glamo_drm.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_crtc.h>
+
+#include "glamo-core.h"
+#include "glamo-drm-private.h"
+#include "glamo-regs.h"
+#include "glamo-kms-fb.h"
+#include <linux/glamofb.h>
+
+
+#define GLAMO_LCD_WIDTH_MASK 0x03FF
+#define GLAMO_LCD_HEIGHT_MASK 0x03FF
+#define GLAMO_LCD_PITCH_MASK 0x07FE
+#define GLAMO_LCD_HV_TOTAL_MASK 0x03FF
+#define GLAMO_LCD_HV_RETR_START_MASK 0x03FF
+#define GLAMO_LCD_HV_RETR_END_MASK 0x03FF
+#define GLAMO_LCD_HV_RETR_DISP_START_MASK 0x03FF
+#define GLAMO_LCD_HV_RETR_DISP_END_MASK 0x03FF
+
+
+struct glamofb_par {
+ struct drm_device *dev;
+ struct drm_display_mode *our_mode;
+ struct glamo_framebuffer *glamo_fb;
+ int crtc_count;
+ /* crtc currently bound to this */
+ uint32_t crtc_ids[2];
+};
+
+
+static int reg_read_lcd(struct glamodrm_handle *gdrm, u_int16_t reg)
+{
+ int i = 0;
+
+ for (i = 0; i != 2; i++)
+ nop();
+
+ return ioread16(gdrm->lcd_base + reg);
+}
+
+
+static void reg_write_lcd(struct glamodrm_handle *gdrm,
+ u_int16_t reg, u_int16_t val)
+{
+ int i = 0;
+
+ for (i = 0; i != 2; i++)
+ nop();
+
+ iowrite16(val, gdrm->lcd_base + reg);
+}
+
+
+static void reg_set_bit_mask_lcd(struct glamodrm_handle *gdrm,
+ u_int16_t reg, u_int16_t mask,
+ u_int16_t val)
+{
+ u_int16_t tmp;
+
+ val &= mask;
+
+ tmp = reg_read_lcd(gdrm, reg);
+ tmp &= ~mask;
+ tmp |= val;
+ reg_write_lcd(gdrm, reg, tmp);
+}
+
+
+/* Note that this has nothing at all to do with the engine command queue
+ * in glamo-cmdq.c */
+static inline int glamo_lcd_cmdq_empty(struct glamodrm_handle *gdrm)
+{
+ /* DGCMdQempty -- 1 == command queue is empty */
+ return reg_read_lcd(gdrm, GLAMO_REG_LCD_STATUS1) & (1 << 15);
+}
+
+
+/* call holding gfb->lock_cmd when locking, until you unlock */
+int glamo_lcd_cmd_mode(struct glamodrm_handle *gdrm, int on)
+{
+ int timeout = 2000000;
+
+ if (gdrm->glamo_core->suspending) {
+ dev_err(&gdrm->glamo_core->pdev->dev,
+ "IGNORING glamofb_cmd_mode while"
+ " suspended\n");
+ return -EBUSY;
+ }
+
+ dev_dbg(gdrm->dev, "glamofb_cmd_mode(on=%d)\n", on);
+ if (on) {
+
+ while ((!glamo_lcd_cmdq_empty(gdrm)) && (timeout--))
+ /* yield() */;
+ if (timeout < 0) {
+ printk(KERN_ERR "*************"
+ " LCD command queue never got empty "
+ "*************\n");
+ return -EIO;
+ }
+
+ /* display the entire frame then switch to command */
+ reg_write_lcd(gdrm, GLAMO_REG_LCD_COMMAND1,
+ GLAMO_LCD_CMD_TYPE_DISP |
+ GLAMO_LCD_CMD_DATA_FIRE_VSYNC);
+
+ /* wait until lcd idle */
+ timeout = 2000000;
+ while ((!reg_read_lcd(gdrm, GLAMO_REG_LCD_STATUS2) & (1 << 12))
+ && (timeout--))
+ /* yield() */;
+ if (timeout < 0) {
+ printk(KERN_ERR"*************"
+ " LCD never idle "
+ "*************\n");
+ return -EIO;
+ }
+
+ mdelay(100);
+
+ } else {
+ /* RGB interface needs vsync/hsync */
+ int mode;
+ mode = reg_read_lcd(gdrm, GLAMO_REG_LCD_MODE3);
+ if ( mode & GLAMO_LCD_MODE3_RGB)
+ reg_write_lcd(gdrm, GLAMO_REG_LCD_COMMAND1,
+ GLAMO_LCD_CMD_TYPE_DISP |
+ GLAMO_LCD_CMD_DATA_DISP_SYNC);
+
+ reg_write_lcd(gdrm, GLAMO_REG_LCD_COMMAND1,
+ GLAMO_LCD_CMD_TYPE_DISP |
+ GLAMO_LCD_CMD_DATA_DISP_FIRE);
+ }
+
+ return 0;
+}
+
+
+static struct glamo_script lcd_init_script[] = {
+ { GLAMO_REG_LCD_MODE1, 0x0020 },
+ /* no display rotation, no hardware cursor, no dither, no gamma,
+ * no retrace flip, vsync low-active, hsync low active,
+ * no TVCLK, no partial display, hw dest color from fb,
+ * no partial display mode, LCD1, software flip, */
+ { GLAMO_REG_LCD_MODE2, 0x9020 },
+ /* video flip, no ptr, no ptr, dhclk off,
+ * normal mode, no cpuif,
+ * res, serial msb first, single fb, no fr ctrl,
+ * cpu if bits all zero, no crc
+ * 0000 0000 0010 0000 */
+ { GLAMO_REG_LCD_MODE3, 0x0b40 },
+ /* src data rgb565, res, 18bit rgb666
+ * 000 01 011 0100 0000 */
+ { GLAMO_REG_LCD_POLARITY, 0x440c },
+ /* DE high active, no cpu/lcd if, cs0 force low, a0 low active,
+ * np cpu if, 9bit serial data, sclk rising edge latch data
+ * 01 00 0 100 0 000 01 0 0 */
+ /* The following values assume 640*480@16bpp */
+ { GLAMO_REG_LCD_A_BASE1, 0x0000 }, /* display A base address 15:0 */
+ { GLAMO_REG_LCD_A_BASE2, 0x0000 }, /* display A base address 22:16 */
+ { GLAMO_REG_LCD_B_BASE1, 0x6000 }, /* display B base address 15:0 */
+ { GLAMO_REG_LCD_B_BASE2, 0x0009 }, /* display B base address 22:16 */
+ { GLAMO_REG_LCD_CURSOR_BASE1, 0xC000 }, /* cursor base address 15:0 */
+ { GLAMO_REG_LCD_CURSOR_BASE2, 0x0012 }, /* cursor base address 22:16 */
+ { GLAMO_REG_LCD_COMMAND2, 0x0000 }, /* display page A */
+};
+
+
+static int glamo_run_lcd_script(struct glamodrm_handle *gdrm,
+ struct glamo_script *script, int len)
+{
+ int i;
+
+ for (i = 0; i < len; i++) {
+ struct glamo_script *line = &script[i];
+
+ if (line->reg == 0xffff)
+ return 0;
+ else if (line->reg == 0xfffe)
+ msleep(line->val);
+ else
+ reg_write_lcd(gdrm, script[i].reg, script[i].val);
+ }
+
+ return 0;
+}
+
+
+#if 0
+static void notify_blank(struct drm_crtc *crtc, int mode)
+{
+ struct fb_event event;
+
+ event.info = info;
+ event.data = &blank_mode;
+ fb_notifier_call_chain(FB_EVENT_CONBLANK, &event);
+}
+#endif
+
+
+extern void jbt6k74_action(int val);
+
+
+/* Power on/off */
+static void glamo_crtc_dpms(struct drm_crtc *crtc, int mode)
+{
+ struct glamodrm_handle *gdrm;
+ struct glamo_crtc *glamo_crtc = to_glamo_crtc(crtc);
+
+ printk(KERN_CRIT "glamo_crtc_dpms(%u)\n", mode);
+ gdrm = glamo_crtc->gdrm;
+
+ switch (mode) {
+ case DRM_MODE_DPMS_OFF:
+ /* LCM need notification before pixel clock is stopped */
+ jbt6k74_action(0);
+
+ /* disable the pixel clock */
+ glamo_engine_clkreg_set(gdrm->glamo_core, GLAMO_ENGINE_LCD,
+ GLAMO_CLOCK_LCD_EN_DCLK, 0);
+ glamo_crtc->blank_mode = mode;
+ break;
+ case DRM_MODE_DPMS_ON:
+ /* enable the pixel clock if off */
+ if (glamo_crtc->blank_mode == DRM_MODE_DPMS_OFF)
+ glamo_engine_clkreg_set(gdrm->glamo_core,
+ GLAMO_ENGINE_LCD,
+ GLAMO_CLOCK_LCD_EN_DCLK,
+ GLAMO_CLOCK_LCD_EN_DCLK);
+ jbt6k74_action(1);
+ glamo_crtc->blank_mode = mode;
+ break;
+ }
+}
+
+
+static bool glamo_crtc_mode_fixup(struct drm_crtc *crtc,
+ struct drm_display_mode *mode,
+ struct drm_display_mode *adjusted_mode)
+{
+ printk(KERN_CRIT "glamo_crtc_mode_fixup\n");
+ return true;
+}
+
+
+static void glamo_crtc_mode_set(struct drm_crtc *crtc,
+ struct drm_display_mode *mode,
+ struct drm_display_mode *adjusted_mode,
+ int x, int y,
+ struct drm_framebuffer *old_fb)
+{
+ struct glamodrm_handle *gdrm;
+ struct glamo_crtc *gcrtc;
+ int retr_start, retr_end, disp_start, disp_end;
+ int ps;
+
+ printk(KERN_CRIT "glamo_crtc_mode_set\n");
+
+ /* Dig out our handle */
+ gcrtc = to_glamo_crtc(crtc);
+ gdrm = gcrtc->gdrm; /* Here it is! */
+
+ glamo_lcd_cmd_mode(gdrm, 1);
+ ps = mode->clock / 1000; /* Hz -> kHz */
+ ps = 1000000000UL / ps; /* kHz -> ps */
+ printk(KERN_INFO "[glamo-drm] Reclocking LCD engine to %i ps\n", ps);
+ glamo_engine_reclock(gdrm->glamo_core, GLAMO_ENGINE_LCD, ps);
+ gdrm->saved_clock = ps;
+
+ reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_WIDTH,
+ GLAMO_LCD_WIDTH_MASK, mode->hdisplay);
+ reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_HEIGHT,
+ GLAMO_LCD_HEIGHT_MASK, mode->vdisplay);
+ reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_PITCH,
+ GLAMO_LCD_PITCH_MASK, mode->hdisplay*2);
+
+ /* Convert "X modeline timings" into "Glamo timings" */
+ retr_start = 0;
+ retr_end = retr_start + mode->hsync_end - mode->hsync_start;
+ disp_start = mode->htotal - mode->hsync_start;
+ disp_end = disp_start + mode->hdisplay;
+ reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_HORIZ_TOTAL,
+ GLAMO_LCD_HV_TOTAL_MASK, mode->htotal);
+ reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_HORIZ_RETR_START,
+ GLAMO_LCD_HV_RETR_START_MASK, retr_start);
+ reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_HORIZ_RETR_END,
+ GLAMO_LCD_HV_RETR_END_MASK, retr_end);
+ reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_HORIZ_DISP_START,
+ GLAMO_LCD_HV_RETR_DISP_START_MASK, disp_start);
+ reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_HORIZ_DISP_END,
+ GLAMO_LCD_HV_RETR_DISP_END_MASK, disp_end);
+
+ /* The same in the vertical direction */
+ retr_start = 0;
+ retr_end = retr_start + mode->vsync_end - mode->vsync_start;
+ disp_start = mode->vtotal - mode->vsync_start;
+ disp_end = disp_start + mode->vdisplay;
+ reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_VERT_TOTAL,
+ GLAMO_LCD_HV_TOTAL_MASK, mode->vtotal);
+ reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_VERT_RETR_START,
+ GLAMO_LCD_HV_RETR_START_MASK, retr_start);
+ reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_VERT_RETR_END,
+ GLAMO_LCD_HV_RETR_END_MASK, retr_end);
+ reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_VERT_DISP_START,
+ GLAMO_LCD_HV_RETR_DISP_START_MASK, disp_start);
+ reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_VERT_DISP_END,
+ GLAMO_LCD_HV_RETR_DISP_END_MASK, disp_end);
+
+ glamo_lcd_cmd_mode(gdrm, 0);
+}
+
+
+static void glamo_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
+ struct drm_framebuffer *old_fb)
+{
+ printk(KERN_CRIT "glamo_crtc_mode_set_base\n");
+}
+
+
+static void glamo_crtc_prepare(struct drm_crtc *crtc)
+{
+ printk(KERN_CRIT "glamo_crtc_prepare\n");
+}
+
+
+static void glamo_crtc_commit(struct drm_crtc *crtc)
+{
+ printk(KERN_CRIT "glamo_crtc_commit\n");
+}
+
+
+static int glamo_crtc_cursor_set(struct drm_crtc *crtc,
+ struct drm_file *file_priv,
+ uint32_t handle,
+ uint32_t width, uint32_t height)
+{
+ printk(KERN_CRIT "glamo_crtc_cursor_set\n");
+ return 0;
+}
+
+
+static int glamo_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
+{
+ printk(KERN_CRIT "glamo_crtc_cursor_move\n");
+ return 0;
+}
+
+
+static void glamo_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+ u16 *blue, uint32_t size)
+{
+ printk(KERN_CRIT "glamo_crtc_gamma_set\n");
+}
+
+
+static void glamo_crtc_destroy(struct drm_crtc *crtc)
+{
+ struct glamo_crtc *glamo_crtc = to_glamo_crtc(crtc);
+ printk(KERN_CRIT "glamo_crtc_destroy\n");
+ drm_crtc_cleanup(crtc);
+ kfree(glamo_crtc);
+}
+
+
+static enum drm_connector_status
+glamo_connector_detect(struct drm_connector *connector)
+{
+ /* One hopes it hasn't been de-soldered... */
+ printk(KERN_CRIT "glamo_connector_detect\n");
+ return connector_status_connected;
+}
+
+
+static void glamo_connector_destroy(struct drm_connector *connector)
+{
+ printk(KERN_CRIT "glamo_connector_destroy\n");
+ drm_sysfs_connector_remove(connector);
+ drm_connector_cleanup(connector);
+ kfree(connector);
+}
+
+
+static int glamo_connector_get_modes(struct drm_connector *connector)
+{
+ struct drm_display_mode *mode;
+ struct glamofb_platform_data *mach_info;
+ struct glamo_output *goutput = to_glamo_output(connector);
+ struct glamodrm_handle *gdrm = goutput->gdrm;
+
+ /* Dig out the record which will tell us about the hardware */
+ mach_info = gdrm->glamo_core->pdev->dev.platform_data;
+
+ printk(KERN_CRIT "glamo_connector_get_modes\n");
+
+ mode = drm_mode_create(connector->dev);
+ if (!mode)
+ return 0;
+ /* Fill in 'mode' here */
+ mode->type = DRM_MODE_TYPE_DEFAULT | DRM_MODE_TYPE_PREFERRED;
+
+ /* Convert framebuffer timings into KMS timings */
+ mode->clock = 1000000000UL / mach_info->pixclock; /* ps -> kHz */
+ mode->clock *= 1000; /* kHz -> Hz */
+ mode->hdisplay = mach_info->xres.defval;
+ mode->hsync_start = mach_info->right_margin + mode->hdisplay;
+ mode->hsync_end = mode->hsync_start + mach_info->hsync_len;
+ mode->htotal = mode->hsync_end + mach_info->left_margin;
+ mode->hskew = 0;
+
+ mode->vdisplay = mach_info->yres.defval;
+ mode->vsync_start = mach_info->lower_margin + mode->vdisplay;
+ mode->vsync_end = mode->vsync_start + mach_info->vsync_len;
+ mode->vtotal = mode->vsync_end + mach_info->upper_margin;
+ mode->vscan = 0;
+
+ mode->width_mm = mach_info->width;
+ mode->height_mm = mach_info->height;
+
+ printk(KERN_CRIT "Modeline \"%ix%i\" %i %i %i %i %i %i %i %i %i\n",
+ mode->hdisplay, mode->vdisplay, mode->clock,
+ mode->hdisplay, mode->hsync_start, mode->hsync_end, mode->htotal,
+ mode->vdisplay, mode->vsync_start, mode->vsync_end, mode->vtotal);
+
+ drm_mode_set_name(mode);
+ drm_mode_probed_add(connector, mode);
+
+ return 1; /* one mode, for now */
+}
+
+
+static int glamo_connector_set_property(struct drm_connector *connector,
+ struct drm_property *property,
+ uint64_t value)
+{
+ printk(KERN_CRIT "glamo_connector_set_property\n");
+ return 0;
+}
+
+
+static int glamo_connector_mode_valid(struct drm_connector *connector,
+ struct drm_display_mode *mode)
+{
+ printk(KERN_CRIT "glamo_connector_mode_valid\n");
+ if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
+ return MODE_NO_DBLESCAN;
+
+ return MODE_OK;
+}
+
+
+struct drm_encoder *
+glamo_connector_best_encoder(struct drm_connector *connector)
+{
+ struct glamo_output *glamo_output = to_glamo_output(connector);
+ printk(KERN_CRIT "glamo_connector_best_encoder\n");
+ return &glamo_output->enc;
+}
+
+
+static void glamo_encoder_dpms(struct drm_encoder *encoder, int mode)
+{
+ printk(KERN_CRIT "glamo_encoder_dpms\n");
+}
+
+
+static bool glamo_encoder_mode_fixup(struct drm_encoder *encoder,
+ struct drm_display_mode *mode,
+ struct drm_display_mode *adjusted_mode)
+{
+ printk(KERN_CRIT "glamo_encoder_mode_fixup\n");
+ return true;
+}
+
+
+void glamo_encoder_prepare(struct drm_encoder *encoder)
+{
+ printk(KERN_CRIT "glamo_encoder_prepare\n");
+}
+
+
+void glamo_encoder_commit(struct drm_encoder *encoder)
+{
+ printk(KERN_CRIT "glamo_encoder_commit\n");
+}
+
+
+static void glamo_encoder_mode_set(struct drm_encoder *encoder,
+ struct drm_display_mode *mode,
+ struct drm_display_mode *adjusted_mode)
+{
+ printk(KERN_CRIT "glamo_encoder_mode_set\n");
+}
+
+
+static void glamo_encoder_destroy(struct drm_encoder *encoder)
+{
+ printk(KERN_CRIT "glamo_encoder_destroy\n");
+ drm_encoder_cleanup(encoder);
+}
+
+
+static void glamo_framebuffer_destroy(struct drm_framebuffer *fb)
+{
+ struct glamo_framebuffer *glamo_fb = to_glamo_framebuffer(fb);
+ struct drm_device *dev = fb->dev;
+ printk(KERN_CRIT "glamo_user_framebuffer_destroy\n");
+
+ drm_framebuffer_cleanup(fb);
+ mutex_lock(&dev->struct_mutex);
+ drm_gem_object_unreference(glamo_fb->obj);
+ mutex_unlock(&dev->struct_mutex);
+
+ kfree(glamo_fb);
+}
+
+static int glamo_framebuffer_create_handle(struct drm_framebuffer *fb,
+ struct drm_file *file_priv,
+ unsigned int *handle)
+{
+ struct glamo_framebuffer *glamo_fb = to_glamo_framebuffer(fb);
+ struct drm_gem_object *object = glamo_fb->obj;
+ printk(KERN_CRIT "glamo_user_framebuffer_create_handle\n");
+
+ return drm_gem_handle_create(file_priv, object, handle);
+}
+
+
+static const struct drm_framebuffer_funcs glamo_fb_funcs = {
+ .destroy = glamo_framebuffer_destroy,
+ .create_handle = glamo_framebuffer_create_handle,
+};
+
+
+int glamo_framebuffer_create(struct drm_device *dev,
+ struct drm_mode_fb_cmd *mode_cmd,
+ struct drm_framebuffer **fb,
+ struct drm_gem_object *obj)
+{
+ struct glamo_framebuffer *glamo_fb;
+ int ret;
+
+ printk(KERN_CRIT "glamo_framebuffer_create\n");
+ glamo_fb = kzalloc(sizeof(*glamo_fb), GFP_KERNEL);
+ if (!glamo_fb)
+ return -ENOMEM;
+
+ ret = drm_framebuffer_init(dev, &glamo_fb->base, &glamo_fb_funcs);
+ if (ret) {
+ DRM_ERROR("framebuffer init failed %d\n", ret);
+ return ret;
+ }
+
+ drm_helper_mode_fill_fb_struct(&glamo_fb->base, mode_cmd);
+
+ glamo_fb->obj = obj;
+
+ *fb = &glamo_fb->base;
+
+ return 0;
+}
+
+
+static struct drm_framebuffer *
+glamo_user_framebuffer_create(struct drm_device *dev,
+ struct drm_file *filp,
+ struct drm_mode_fb_cmd *mode_cmd)
+{
+ struct drm_gem_object *obj;
+ struct drm_framebuffer *fb;
+ int ret;
+ printk(KERN_CRIT "glamo_user_framebuffer_create\n");
+
+ obj = drm_gem_object_lookup(dev, filp, mode_cmd->handle);
+ if (!obj)
+ return NULL;
+
+ ret = glamo_framebuffer_create(dev, mode_cmd, &fb, obj);
+ if (ret) {
+ drm_gem_object_unreference(obj);
+ return NULL;
+ }
+
+ return fb;
+}
+
+
+int glamo_fbchanged(struct drm_device *dev)
+{
+ printk(KERN_CRIT "glamo_fb_changed\n");
+ return 0;
+}
+
+
+/* CRTC functions */
+static const struct drm_crtc_funcs glamo_crtc_funcs = {
+ .cursor_set = glamo_crtc_cursor_set,
+ .cursor_move = glamo_crtc_cursor_move,
+ .gamma_set = glamo_crtc_gamma_set,
+ .set_config = drm_crtc_helper_set_config,
+ .destroy = glamo_crtc_destroy,
+};
+
+
+/* CRTC helper functions */
+static const struct drm_crtc_helper_funcs glamo_crtc_helper_funcs = {
+ .dpms = glamo_crtc_dpms,
+ .mode_fixup = glamo_crtc_mode_fixup,
+ .mode_set = glamo_crtc_mode_set,
+ .mode_set_base = glamo_crtc_mode_set_base,
+ .prepare = glamo_crtc_prepare,
+ .commit = glamo_crtc_commit,
+};
+
+
+/* Connector functions */
+static const struct drm_connector_funcs glamo_connector_funcs = {
+ .detect = glamo_connector_detect,
+ .fill_modes = drm_helper_probe_single_connector_modes,
+ .destroy = glamo_connector_destroy,
+ .set_property = glamo_connector_set_property,
+};
+
+
+/* Connector helper functions */
+static const struct drm_connector_helper_funcs glamo_connector_helper_funcs = {
+ .mode_valid = glamo_connector_mode_valid,
+ .get_modes = glamo_connector_get_modes,
+ .best_encoder = glamo_connector_best_encoder,
+};
+
+
+/* Encoder functions */
+static const struct drm_encoder_funcs glamo_encoder_funcs = {
+ .destroy = glamo_encoder_destroy,
+};
+
+
+/* Encoder helper functions */
+static const struct drm_encoder_helper_funcs glamo_encoder_helper_funcs = {
+ .dpms = glamo_encoder_dpms,
+ .mode_fixup = glamo_encoder_mode_fixup,
+ .prepare = glamo_encoder_prepare,
+ .commit = glamo_encoder_commit,
+ .mode_set = glamo_encoder_mode_set,
+};
+
+
+/* Mode functions */
+static const struct drm_mode_config_funcs glamo_mode_funcs = {
+ .fb_create = glamo_user_framebuffer_create,
+ .fb_changed = glamo_fbchanged
+};
+
+
+static struct drm_mode_set kernelfb_mode;
+
+
+/* Restore's the kernel's fbcon mode, used for panic path */
+void glamo_display_restore(void)
+{
+ drm_crtc_helper_set_config(&kernelfb_mode);
+}
+
+
+static int glamo_display_panic(struct notifier_block *n, unsigned long ununsed,
+ void *panic_str)
+{
+ DRM_ERROR("panic occurred, switching back to text console\n");
+
+ glamo_display_restore();
+ return 0;
+}
+
+
+static struct notifier_block paniced = {
+ .notifier_call = glamo_display_panic,
+};
+
+
+int glamo_display_init(struct drm_device *dev)
+{
+ struct glamodrm_handle *gdrm;
+ struct glamo_crtc *glamo_crtc;
+ struct glamo_output *glamo_output;
+ struct drm_connector *connector;
+ struct glamo_framebuffer *glamo_fb;
+ struct fb_info *info;
+ struct glamofb_par *par;
+ struct drm_mode_set *modeset;
+
+ gdrm = dev->dev_private;
+
+ printk(KERN_CRIT "glamo_display_init\n");
+
+ glamo_engine_enable(gdrm->glamo_core, GLAMO_ENGINE_LCD);
+ glamo_engine_reset(gdrm->glamo_core, GLAMO_ENGINE_LCD);
+
+ drm_mode_config_init(dev);
+
+ dev->mode_config.min_width = 0;
+ dev->mode_config.min_height = 0;
+
+ dev->mode_config.funcs = (void *)&glamo_mode_funcs;
+
+ /* Initialise our CRTC object.
+ * Only one connector per CRTC. We know this: it's kind of soldered. */
+ glamo_crtc = kzalloc(sizeof(struct glamo_crtc)
+ + sizeof(struct drm_connector *), GFP_KERNEL);
+ if (glamo_crtc == NULL) return 1;
+ glamo_crtc->gdrm = gdrm;
+ glamo_crtc->blank_mode = DRM_MODE_DPMS_OFF;
+ drm_crtc_init(dev, &glamo_crtc->base, &glamo_crtc_funcs);
+ drm_crtc_helper_add(&glamo_crtc->base, &glamo_crtc_helper_funcs);
+
+ glamo_crtc->mode_set.crtc = &glamo_crtc->base;
+ glamo_crtc->mode_set.connectors =
+ (struct drm_connector **)(glamo_crtc + 1);
+ glamo_crtc->mode_set.num_connectors = 0;
+
+ /* Create our "output" object: consists of an output and an encoder */
+ glamo_output = kzalloc(sizeof(struct glamo_output), GFP_KERNEL);
+ if (glamo_output == NULL) return 1;
+ connector = &glamo_output->base;
+ glamo_output->gdrm = gdrm;
+
+ /* Initialise the connector */
+ drm_connector_init(dev, connector, &glamo_connector_funcs,
+ DRM_MODE_CONNECTOR_Unknown);
+ drm_sysfs_connector_add(connector);
+ connector->interlace_allowed = 0;
+ connector->doublescan_allowed = 0;
+
+ /* Initialise the encoder */
+ drm_encoder_init(dev, &glamo_output->enc, &glamo_encoder_funcs,
+ DRM_MODE_ENCODER_DAC);
+ glamo_output->enc.possible_crtcs = 1 << 0;
+ drm_mode_connector_attach_encoder(&glamo_output->base,
+ &glamo_output->enc);
+
+ drm_encoder_helper_add(&glamo_output->enc, &glamo_encoder_helper_funcs);
+ drm_connector_helper_add(connector, &glamo_connector_helper_funcs);
+
+ drm_helper_initial_config(dev, false);
+
+ /* Initial setup of the LCD controller */
+ glamo_run_lcd_script(gdrm, lcd_init_script,
+ ARRAY_SIZE(lcd_init_script));
+
+ if (list_empty(&dev->mode_config.fb_kernel_list)) {
+ int ret;
+ ret = glamofb_create(dev, 480, 640, 480, 640, &glamo_fb);
+ if (ret) return -EINVAL;
+ }
+
+ info = glamo_fb->base.fbdev;
+ par = info->par;
+
+ modeset = &glamo_crtc->mode_set;
+ modeset->fb = &glamo_fb->base;
+ modeset->connectors[0] = connector;
+
+ par->crtc_ids[0] = glamo_crtc->base.base.id;
+
+ modeset->num_connectors = 1;
+ modeset->mode = modeset->crtc->desired_mode;
+
+ par->crtc_count = 1;
+
+ if (register_framebuffer(info) < 0)
+ return -EINVAL;
+
+ printk(KERN_INFO "[glamo-drm] fb%d: %s frame buffer device\n",
+ info->node, info->fix.id);
+
+ /* Switch back to kernel console on panic */
+ kernelfb_mode = *modeset;
+ atomic_notifier_chain_register(&panic_notifier_list, &paniced);
+ printk(KERN_INFO "[glamo-drm] registered panic notifier\n");
+
+ return 0;
+}
+
+
+void glamo_display_suspend(struct glamodrm_handle *gdrm)
+{
+ jbt6k74_action(0);
+
+ gdrm->saved_width = reg_read_lcd(gdrm, GLAMO_REG_LCD_WIDTH);
+ gdrm->saved_height = reg_read_lcd(gdrm, GLAMO_REG_LCD_HEIGHT);
+ gdrm->saved_pitch = reg_read_lcd(gdrm, GLAMO_REG_LCD_PITCH);
+ gdrm->saved_htotal = reg_read_lcd(gdrm, GLAMO_REG_LCD_HORIZ_TOTAL);
+ gdrm->saved_hrtrst = reg_read_lcd(gdrm, GLAMO_REG_LCD_HORIZ_RETR_START);
+ gdrm->saved_hrtren = reg_read_lcd(gdrm, GLAMO_REG_LCD_HORIZ_RETR_END);
+ gdrm->saved_hdspst = reg_read_lcd(gdrm, GLAMO_REG_LCD_HORIZ_DISP_START);
+ gdrm->saved_hdspen = reg_read_lcd(gdrm, GLAMO_REG_LCD_HORIZ_DISP_END);
+ gdrm->saved_vtotal = reg_read_lcd(gdrm, GLAMO_REG_LCD_VERT_TOTAL);
+ gdrm->saved_vrtrst = reg_read_lcd(gdrm, GLAMO_REG_LCD_VERT_RETR_START);
+ gdrm->saved_vrtren = reg_read_lcd(gdrm, GLAMO_REG_LCD_VERT_RETR_END);
+ gdrm->saved_vdspst = reg_read_lcd(gdrm, GLAMO_REG_LCD_VERT_DISP_START);
+ gdrm->saved_vdspen = reg_read_lcd(gdrm, GLAMO_REG_LCD_VERT_DISP_END);
+}
+
+
+void glamo_display_resume(struct glamodrm_handle *gdrm)
+{
+ /* Reinitialise the LCD controller */
+ jbt6k74_action(0);
+ mdelay(5);
+
+ glamo_engine_enable(gdrm->glamo_core, GLAMO_ENGINE_LCD);
+ glamo_engine_reset(gdrm->glamo_core, GLAMO_ENGINE_LCD);
+ glamo_run_lcd_script(gdrm, lcd_init_script,
+ ARRAY_SIZE(lcd_init_script));
+
+ /* Enable pixel clock */
+ glamo_engine_clkreg_set(gdrm->glamo_core,
+ GLAMO_ENGINE_LCD,
+ GLAMO_CLOCK_LCD_EN_DCLK,
+ GLAMO_CLOCK_LCD_EN_DCLK);
+
+ /* Restore timings */
+ glamo_lcd_cmd_mode(gdrm, 1);
+ glamo_engine_reclock(gdrm->glamo_core, GLAMO_ENGINE_LCD,
+ gdrm->saved_clock);
+ reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_WIDTH, GLAMO_LCD_WIDTH_MASK,
+ gdrm->saved_width);
+ reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_HEIGHT, GLAMO_LCD_HEIGHT_MASK,
+ gdrm->saved_height);
+ reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_PITCH, GLAMO_LCD_PITCH_MASK,
+ gdrm->saved_pitch);
+ reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_HORIZ_TOTAL,
+ GLAMO_LCD_HV_TOTAL_MASK, gdrm->saved_htotal);
+ reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_HORIZ_RETR_START,
+ GLAMO_LCD_HV_RETR_START_MASK, gdrm->saved_hrtrst);
+ reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_HORIZ_RETR_END,
+ GLAMO_LCD_HV_RETR_END_MASK, gdrm->saved_hrtren);
+ reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_HORIZ_DISP_START,
+ GLAMO_LCD_HV_RETR_DISP_START_MASK,
+ gdrm->saved_hdspst);
+ reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_HORIZ_DISP_END,
+ GLAMO_LCD_HV_RETR_DISP_END_MASK,
+ gdrm->saved_hdspen);
+ reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_VERT_TOTAL,
+ GLAMO_LCD_HV_TOTAL_MASK, gdrm->saved_vtotal);
+ reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_VERT_RETR_START,
+ GLAMO_LCD_HV_RETR_START_MASK, gdrm->saved_vrtrst);
+ reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_VERT_RETR_END,
+ GLAMO_LCD_HV_RETR_END_MASK, gdrm->saved_vrtren);
+ reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_VERT_DISP_START,
+ GLAMO_LCD_HV_RETR_DISP_START_MASK,
+ gdrm->saved_vdspst);
+ reg_set_bit_mask_lcd(gdrm, GLAMO_REG_LCD_VERT_DISP_END,
+ GLAMO_LCD_HV_RETR_DISP_END_MASK,
+ gdrm->saved_vdspen);
+ glamo_lcd_cmd_mode(gdrm, 0);
+
+ jbt6k74_action(1);
+}
diff --git a/drivers/mfd/glamo/glamo-display.h b/drivers/mfd/glamo/glamo-display.h
new file mode 100644
index 00000000000..d6f21bcb0c0
--- /dev/null
+++ b/drivers/mfd/glamo/glamo-display.h
@@ -0,0 +1,39 @@
+/* Smedia Glamo 336x/337x Display
+ *
+ * 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
+ */
+
+#ifndef __GLAMO_DISPLAY_H
+#define __GLAMO_DISPLAY_H
+
+#include <drm/drmP.h>
+#include "glamo-drm-private.h"
+
+extern int glamo_display_init(struct drm_device *dev);
+
+extern int glamo_framebuffer_create(struct drm_device *dev,
+ struct drm_mode_fb_cmd *mode_cmd,
+ struct drm_framebuffer **fb,
+ struct drm_gem_object *obj);
+
+extern void glamo_display_suspend(struct glamodrm_handle *gdrm);
+extern void glamo_display_resume(struct glamodrm_handle *gdrm);
+
+#endif /* __GLAMO_DISPLAY_H */
diff --git a/drivers/mfd/glamo/glamo-drm-drv.c b/drivers/mfd/glamo/glamo-drm-drv.c
index 856622d9e76..9725968a196 100644
--- a/drivers/mfd/glamo/glamo-drm-drv.c
+++ b/drivers/mfd/glamo/glamo-drm-drv.c
@@ -1,4 +1,4 @@
-/* Smedia Glamo 336x/337x driver
+/* Smedia Glamo 336x/337x Graphics Driver
*
* Copyright (C) 2009 Openmoko, Inc. Jorge Luis Zapata <turran@openmoko.com>
* Copyright (C) 2008-2009 Thomas White <taw@bitwiz.org.uk>
@@ -27,16 +27,19 @@
#include <linux/platform_device.h>
#include <drm/drmP.h>
#include <drm/glamo_drm.h>
+#include <linux/glamofb.h>
#include "glamo-core.h"
#include "glamo-cmdq.h"
#include "glamo-buffer.h"
#include "glamo-drm-private.h"
+#include "glamo-display.h"
+#include "glamo-kms-fb.h"
#define DRIVER_AUTHOR "Openmoko, Inc."
#define DRIVER_NAME "glamo-drm"
#define DRIVER_DESC "SMedia Glamo 3362"
-#define DRIVER_DATE "20090426"
+#define DRIVER_DATE "20090614"
#define RESSIZE(ressource) (((ressource)->end - (ressource)->start)+1)
@@ -127,13 +130,42 @@ static void glamodrm_master_destroy(struct drm_device *dev,
}
+static int glamodrm_load(struct drm_device *dev, unsigned long flags)
+{
+ struct glamodrm_handle *gdrm;
+ gdrm = dev->dev_private;
+
+ glamo_buffer_init(gdrm);
+ glamo_cmdq_init(gdrm);
+ glamo_display_init(dev);
+
+ return 0;
+}
+
+
+static int glamodrm_unload(struct drm_device *dev)
+{
+ struct glamodrm_handle *gdrm;
+
+ gdrm = dev->dev_private;
+
+ glamo_engine_disable(gdrm->glamo_core, GLAMO_ENGINE_2D);
+ glamo_engine_disable(gdrm->glamo_core, GLAMO_ENGINE_3D);
+ glamo_buffer_final(gdrm);
+
+ return 0;
+}
+
+
static struct vm_operations_struct glamodrm_gem_vm_ops = {
.fault = glamodrm_gem_fault,
};
static struct drm_driver glamodrm_drm_driver = {
- .driver_features = DRIVER_IS_PLATFORM | DRIVER_GEM,
+ .driver_features = DRIVER_IS_PLATFORM | DRIVER_GEM | DRIVER_MODESET,
.firstopen = glamodrm_firstopen,
+ .load = glamodrm_load,
+ .unload = glamodrm_unload,
.open = glamodrm_open,
.preclose = glamodrm_preclose,
.postclose = glamodrm_postclose,
@@ -169,14 +201,17 @@ static int glamodrm_probe(struct platform_device *pdev)
{
int rc;
struct glamodrm_handle *gdrm;
+ struct glamofb_platform_data *mach_info;
- printk(KERN_INFO "[glamo-drm] SMedia Glamo Direct Rendering Support\n");
+ printk(KERN_CRIT "[glamo-drm] SMedia Glamo Direct Rendering Support\n");
gdrm = kmalloc(sizeof(*gdrm), GFP_KERNEL);
if ( !gdrm )
return -ENOMEM;
platform_set_drvdata(pdev, gdrm);
- gdrm->glamo_core = pdev->dev.platform_data;
+ mach_info = pdev->dev.platform_data;
+ gdrm->glamo_core = mach_info->glamo;
+ gdrm->dev = &pdev->dev;
/* Find the command queue registers */
gdrm->reg = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -199,33 +234,8 @@ static int glamodrm_probe(struct platform_device *pdev)
goto out_release_regs;
}
- /* Find the working VRAM */
- gdrm->vram = platform_get_resource(pdev, IORESOURCE_MEM, 1);
- if ( !gdrm->vram ) {
- dev_err(&pdev->dev, "Unable to find work VRAM.\n");
- rc = -ENOENT;
- goto out_unmap_regs;
- }
- gdrm->vram = request_mem_region(gdrm->vram->start,
- RESSIZE(gdrm->vram), pdev->name);
- if ( !gdrm->vram ) {
- dev_err(&pdev->dev, "failed to request VRAM region\n");
- rc = -ENOENT;
- goto out_unmap_regs;
- }
- gdrm->vram_base = ioremap(gdrm->vram->start, RESSIZE(gdrm->vram));
- if ( !gdrm->vram_base ) {
- dev_err(&pdev->dev, "failed to ioremap() VRAM\n");
- rc = -ENOENT;
- goto out_release_vram;
- }
-
- gdrm->vram_size = GLAMO_WORK_SIZE;
- printk(KERN_INFO "[glamo-drm] %lli bytes of Glamo RAM to work with\n",
- (long long int)gdrm->vram_size);
-
/* Find the command queue itself */
- gdrm->cmdq = platform_get_resource(pdev, IORESOURCE_MEM, 2);
+ gdrm->cmdq = platform_get_resource(pdev, IORESOURCE_MEM, 1);
if ( !gdrm->cmdq ) {
dev_err(&pdev->dev, "Unable to find command queue.\n");
rc = -ENOENT;
@@ -245,18 +255,66 @@ static int glamodrm_probe(struct platform_device *pdev)
goto out_release_cmdq;
}
+ /* Find the VRAM */
+ gdrm->vram = platform_get_resource(pdev, IORESOURCE_MEM, 2);
+ if ( !gdrm->vram ) {
+ dev_err(&pdev->dev, "Unable to find VRAM.\n");
+ rc = -ENOENT;
+ goto out_unmap_regs;
+ }
+ gdrm->vram = request_mem_region(gdrm->vram->start,
+ RESSIZE(gdrm->vram), pdev->name);
+ if ( !gdrm->vram ) {
+ dev_err(&pdev->dev, "failed to request VRAM region\n");
+ rc = -ENOENT;
+ goto out_unmap_regs;
+ }
+// gdrm->vram_base = ioremap(gdrm->vram->start, RESSIZE(gdrm->vram));
+// if ( !gdrm->vram_base ) {
+// dev_err(&pdev->dev, "failed to ioremap() VRAM\n");
+// rc = -ENOENT;
+// goto out_release_vram;
+// }
+
+ /* Find the LCD controller */
+ gdrm->lcd_regs = platform_get_resource(pdev, IORESOURCE_MEM, 3);
+ if ( !gdrm->lcd_regs ) {
+ dev_err(&pdev->dev, "Unable to find LCD registers.\n");
+ rc = -ENOENT;
+ goto out_unmap_cmdq;
+ }
+ gdrm->lcd_regs = request_mem_region(gdrm->lcd_regs->start,
+ RESSIZE(gdrm->lcd_regs),
+ pdev->name);
+ if ( !gdrm->lcd_regs ) {
+ dev_err(&pdev->dev, "failed to request VRAM region\n");
+ rc = -ENOENT;
+ goto out_release_lcd;
+ }
+ gdrm->lcd_base = ioremap(gdrm->lcd_regs->start, RESSIZE(gdrm->lcd_regs));
+ if ( !gdrm->lcd_base ) {
+ dev_err(&pdev->dev, "failed to ioremap() VRAM\n");
+ rc = -ENOENT;
+ goto out_release_lcd;
+ }
+
+ gdrm->vram_size = GLAMO_FB_SIZE;
+ printk(KERN_INFO "[glamo-drm] %lli bytes of VRAM\n",
+ (long long int)gdrm->vram_size);
+
/* Initialise DRM */
drm_platform_init(&glamodrm_drm_driver, pdev, (void *)gdrm);
- glamo_buffer_init(gdrm);
- glamo_cmdq_init(gdrm);
-
return 0;
+out_release_lcd:
+ release_mem_region(gdrm->lcd_regs->start, RESSIZE(gdrm->lcd_regs));
+out_unmap_cmdq:
+ iounmap(gdrm->cmdq_base);
out_release_cmdq:
release_mem_region(gdrm->cmdq->start, RESSIZE(gdrm->cmdq));
out_unmap_vram:
- iounmap(gdrm->vram_base);
+// iounmap(gdrm->vram_base);
out_release_vram:
release_mem_region(gdrm->vram->start, RESSIZE(gdrm->vram));
out_unmap_regs:
@@ -273,13 +331,10 @@ out_free:
static int glamodrm_remove(struct platform_device *pdev)
{
struct glamodrm_handle *gdrm = 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);
glamo_buffer_final(gdrm);
glamo_cmdq_shutdown(gdrm);
+
drm_exit(&glamodrm_drm_driver);
platform_set_drvdata(pdev, NULL);
@@ -289,7 +344,7 @@ static int glamodrm_remove(struct platform_device *pdev)
release_mem_region(gdrm->reg->start, RESSIZE(gdrm->reg));
/* Release VRAM */
- iounmap(gdrm->vram_base);
+// iounmap(gdrm->vram_base);
release_mem_region(gdrm->vram->start, RESSIZE(gdrm->vram));
/* Release command queue */
@@ -304,7 +359,14 @@ static int glamodrm_remove(struct platform_device *pdev)
static int glamodrm_suspend(struct platform_device *pdev, pm_message_t state)
{
+ struct glamodrm_handle *gdrm = platform_get_drvdata(pdev);
+
+ glamo_kmsfb_suspend(gdrm);
+ glamo_display_suspend(gdrm);
+ glamo_cmdq_suspend(gdrm);
+
/* glamo_core.c will suspend the engines for us */
+
return 0;
}
@@ -312,7 +374,11 @@ static int glamodrm_suspend(struct platform_device *pdev, pm_message_t state)
static int glamodrm_resume(struct platform_device *pdev)
{
struct glamodrm_handle *gdrm = platform_get_drvdata(pdev);
- glamo_cmdq_init(gdrm);
+
+ glamo_cmdq_resume(gdrm);
+ glamo_display_resume(gdrm);
+ glamo_kmsfb_resume(gdrm);
+
return 0;
}
@@ -323,7 +389,7 @@ static struct platform_driver glamodrm_driver = {
.suspend = glamodrm_suspend,
.resume = glamodrm_resume,
.driver = {
- .name = "glamo-cmdq",
+ .name = "glamo-fb",
.owner = THIS_MODULE,
},
};
diff --git a/drivers/mfd/glamo/glamo-drm-private.h b/drivers/mfd/glamo/glamo-drm-private.h
index 4cc5877e118..3f01f1fd6a1 100644
--- a/drivers/mfd/glamo/glamo-drm-private.h
+++ b/drivers/mfd/glamo/glamo-drm-private.h
@@ -35,13 +35,22 @@
#include "glamo-core.h"
+/* Memory to allocate for the framebuffer.
+ * The rest is reserved for the DRM memory manager */
+#define GLAMO_FRAMEBUFFER_ALLOCATION (4*1024*1024)
+
+
struct glamodrm_handle {
/* This device */
struct device *dev;
+
/* The parent device handle */
struct glamo_core *glamo_core;
+ /* Framebuffer handle for the console (i.e. /dev/fb0) */
+ struct fb_info *fb;
+
/* Command queue registers */
struct resource *reg;
char __iomem *reg_base;
@@ -54,6 +63,10 @@ struct glamodrm_handle {
struct resource *cmdq;
char __iomem *cmdq_base;
+ /* LCD controller registers */
+ struct resource *lcd_regs;
+ char __iomem *lcd_base;
+
ssize_t vram_size;
/* Memory management */
@@ -61,8 +74,25 @@ struct glamodrm_handle {
/* semaphore against concurrent ioctl */
struct semaphore add_to_ring;
+
+ /* Saved state */
+ u_int16_t saved_clock;
+ u_int16_t saved_width;
+ u_int16_t saved_height;
+ u_int16_t saved_pitch;
+ u_int16_t saved_htotal;
+ u_int16_t saved_hrtrst;
+ u_int16_t saved_hrtren;
+ u_int16_t saved_hdspst;
+ u_int16_t saved_hdspen;
+ u_int16_t saved_vtotal;
+ u_int16_t saved_vrtrst;
+ u_int16_t saved_vrtren;
+ u_int16_t saved_vdspst;
+ u_int16_t saved_vdspen;
};
+
/* Private data. This is where we keep our memory management bits */
struct drm_glamo_gem_object {
struct drm_gem_object *obj; /* The GEM object this refers to */
@@ -70,5 +100,32 @@ struct drm_glamo_gem_object {
};
+struct glamo_crtc {
+ struct drm_crtc base;
+ struct glamodrm_handle *gdrm;
+ /* a mode_set for fbdev users on this crtc */
+ struct drm_mode_set mode_set;
+ int blank_mode;
+};
+
+
+struct glamo_framebuffer {
+ struct drm_framebuffer base;
+ struct drm_gem_object *obj;
+};
+
+
+struct glamo_output {
+ struct drm_connector base;
+ struct drm_encoder enc;
+ struct glamodrm_handle *gdrm;
+};
+
+
+#define to_glamo_crtc(x) container_of(x, struct glamo_crtc, base)
+#define to_glamo_output(x) container_of(x, struct glamo_output, base)
+#define enc_to_glamo_output(x) container_of(x, struct glamo_output, enc)
+#define to_glamo_framebuffer(x) container_of(x, struct glamo_framebuffer, base)
+
#endif /* __GLAMO_DRMPRIV_H */
diff --git a/drivers/mfd/glamo/glamo-fb.c b/drivers/mfd/glamo/glamo-fb.c
index 589b924b6bf..95d40d25cf7 100644
--- a/drivers/mfd/glamo/glamo-fb.c
+++ b/drivers/mfd/glamo/glamo-fb.c
@@ -995,8 +995,6 @@ 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-kms-fb.c b/drivers/mfd/glamo/glamo-kms-fb.c
new file mode 100644
index 00000000000..4d3e8977d47
--- /dev/null
+++ b/drivers/mfd/glamo/glamo-kms-fb.c
@@ -0,0 +1,553 @@
+/*
+ * SMedia Glamo 336x/337x KMS Framebuffer
+ *
+ * Copyright (C) 2009 Thomas White <taw@bitwiz.org.uk>
+ *
+ * Based on glamo-fb.c (C) 2007-2008 by Openmoko, Inc.
+ * Author: Harald Welte <laforge@openmoko.org>
+ * 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
+ *
+ *
+ * Based on intel_fb.c from drivers/gpu/drm/i915
+ * to which the following licence applies:
+ *
+ * Copyright © 2006-2007 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Eric Anholt <eric@anholt.net>
+ *
+ */
+
+
+#include <drm/drmP.h>
+#include <drm/glamo_drm.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_crtc.h>
+
+#include "glamo-core.h"
+#include "glamo-drm-private.h"
+#include "glamo-regs.h"
+#include "glamo-display.h"
+#include "glamo-buffer.h"
+
+
+struct glamofb_par {
+ struct drm_device *dev;
+ struct drm_display_mode *our_mode;
+ struct glamo_framebuffer *glamo_fb;
+ int crtc_count;
+ /* crtc currently bound to this */
+ uint32_t crtc_ids[2];
+};
+
+
+static int reg_read(struct glamodrm_handle *gdrm, u_int16_t reg)
+{
+ int i = 0;
+
+ for (i = 0; i != 2; i++)
+ nop();
+
+ return ioread16(gdrm->lcd_base + reg);
+}
+
+
+static int glamofb_setcolreg(unsigned regno, unsigned red, unsigned green,
+ unsigned blue, unsigned transp,
+ struct fb_info *info)
+{
+ struct glamofb_par *par = info->par;
+ struct drm_device *dev = par->dev;
+ struct drm_crtc *crtc;
+ int i;
+
+ list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
+ struct glamo_crtc *glamo_crtc = to_glamo_crtc(crtc);
+ struct drm_mode_set *modeset = &glamo_crtc->mode_set;
+ struct drm_framebuffer *fb = modeset->fb;
+
+ for (i = 0; i < par->crtc_count; i++)
+ if (crtc->base.id == par->crtc_ids[i])
+ break;
+
+ if (i == par->crtc_count)
+ continue;
+
+
+ if (regno > 255)
+ return 1;
+
+ if (regno < 16) {
+ switch (fb->depth) {
+ case 15:
+ fb->pseudo_palette[regno] = ((red & 0xf800) >> 1) |
+ ((green & 0xf800) >> 6) |
+ ((blue & 0xf800) >> 11);
+ break;
+ case 16:
+ fb->pseudo_palette[regno] = (red & 0xf800) |
+ ((green & 0xfc00) >> 5) |
+ ((blue & 0xf800) >> 11);
+ break;
+ case 24:
+ case 32:
+ fb->pseudo_palette[regno] = ((red & 0xff00) << 8) |
+ (green & 0xff00) |
+ ((blue & 0xff00) >> 8);
+ break;
+ }
+ }
+ }
+ return 0;
+}
+
+static int glamofb_check_var(struct fb_var_screeninfo *var,
+ struct fb_info *info)
+{
+ struct glamofb_par *par = info->par;
+ struct glamo_framebuffer *glamo_fb = par->glamo_fb;
+ struct drm_framebuffer *fb = &glamo_fb->base;
+ int depth;
+
+ /* Need to resize the fb object !!! */
+ if (var->xres > fb->width || var->yres > fb->height) {
+ DRM_ERROR("Cannot resize framebuffer object (%dx%d > %dx%d)\n",
+ var->xres,var->yres,fb->width,fb->height);
+ DRM_ERROR("Need resizing code.\n");
+ return -EINVAL;
+ }
+
+ switch (var->bits_per_pixel) {
+ case 16:
+ depth = (var->green.length == 6) ? 16 : 15;
+ break;
+ case 32:
+ depth = (var->transp.length > 0) ? 32 : 24;
+ break;
+ default:
+ depth = var->bits_per_pixel;
+ break;
+ }
+
+ switch (depth) {
+ case 16:
+ var->red.offset = 11;
+ var->green.offset = 5;
+ var->blue.offset = 0;
+ var->red.length = 5;
+ var->green.length = 6;
+ var->blue.length = 5;
+ var->transp.length = 0;
+ var->transp.offset = 0;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+/* this will let fbcon do the mode init */
+/* FIXME: take mode config lock? */
+static int glamofb_set_par(struct fb_info *info)
+{
+ struct glamofb_par *par = info->par;
+ struct drm_device *dev = par->dev;
+ struct fb_var_screeninfo *var = &info->var;
+ int i;
+
+ printk(KERN_CRIT "glamofb_set_par\n");
+
+ DRM_DEBUG("%d %d\n", var->xres, var->pixclock);
+
+ if (var->pixclock != -1) {
+
+ DRM_ERROR("PIXEL CLOCK SET\n");
+ return -EINVAL;
+ } else {
+ struct drm_crtc *crtc;
+ int ret;
+
+ list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
+ struct glamo_crtc *glamo_crtc = to_glamo_crtc(crtc);
+
+ for (i = 0; i < par->crtc_count; i++)
+ if (crtc->base.id == par->crtc_ids[i])
+ break;
+
+ if (i == par->crtc_count)
+ continue;
+
+ if (crtc->fb == glamo_crtc->mode_set.fb) {
+ mutex_lock(&dev->mode_config.mutex);
+ ret = crtc->funcs->set_config(&glamo_crtc->mode_set);
+ mutex_unlock(&dev->mode_config.mutex);
+ if (ret)
+ return ret;
+ }
+ }
+ return 0;
+ }
+}
+
+static int glamofb_pan_display(struct fb_var_screeninfo *var,
+ struct fb_info *info)
+{
+ struct glamofb_par *par = info->par;
+ struct drm_device *dev = par->dev;
+ struct drm_mode_set *modeset;
+ struct drm_crtc *crtc;
+ struct glamo_crtc *glamo_crtc;
+ int ret = 0;
+ int i;
+
+ printk(KERN_CRIT "glamofb_pan_display (%i,%i)\n", var->xoffset, var->yoffset);
+
+ list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
+ for (i = 0; i < par->crtc_count; i++)
+ if (crtc->base.id == par->crtc_ids[i])
+ break;
+
+ if (i == par->crtc_count)
+ continue;
+
+ glamo_crtc = to_glamo_crtc(crtc);
+ modeset = &glamo_crtc->mode_set;
+
+ modeset->x = var->xoffset;
+ modeset->y = var->yoffset;
+
+ if (modeset->num_connectors) {
+ mutex_lock(&dev->mode_config.mutex);
+ ret = crtc->funcs->set_config(modeset);
+ mutex_unlock(&dev->mode_config.mutex);
+ if (!ret) {
+ info->var.xoffset = var->xoffset;
+ info->var.yoffset = var->yoffset;
+ }
+ }
+ }
+
+ return ret;
+}
+
+static void glamofb_on(struct fb_info *info)
+{
+ struct glamofb_par *par = info->par;
+ struct drm_device *dev = par->dev;
+ struct drm_crtc *crtc;
+ struct drm_encoder *encoder;
+ int i;
+
+ /*
+ * For each CRTC in this fb, find all associated encoders
+ * and turn them off, then turn off the CRTC.
+ */
+ list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
+ struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
+
+ for (i = 0; i < par->crtc_count; i++)
+ if (crtc->base.id == par->crtc_ids[i])
+ break;
+
+ crtc_funcs->dpms(crtc, DRM_MODE_DPMS_ON);
+
+ /* Found a CRTC on this fb, now find encoders */
+ list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
+ if (encoder->crtc == crtc) {
+ struct drm_encoder_helper_funcs *encoder_funcs;
+ encoder_funcs = encoder->helper_private;
+ encoder_funcs->dpms(encoder, DRM_MODE_DPMS_ON);
+ }
+ }
+ }
+}
+
+static void glamofb_off(struct fb_info *info, int dpms_mode)
+{
+ struct glamofb_par *par = info->par;
+ struct drm_device *dev = par->dev;
+ struct drm_crtc *crtc;
+ struct drm_encoder *encoder;
+ int i;
+
+ /*
+ * For each CRTC in this fb, find all associated encoders
+ * and turn them off, then turn off the CRTC.
+ */
+ list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
+ struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
+
+ for (i = 0; i < par->crtc_count; i++)
+ if (crtc->base.id == par->crtc_ids[i])
+ break;
+
+ /* Found a CRTC on this fb, now find encoders */
+ list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
+ if (encoder->crtc == crtc) {
+ struct drm_encoder_helper_funcs *encoder_funcs;
+ encoder_funcs = encoder->helper_private;
+ encoder_funcs->dpms(encoder, dpms_mode);
+ }
+ }
+ if (dpms_mode == DRM_MODE_DPMS_OFF)
+ crtc_funcs->dpms(crtc, dpms_mode);
+ }
+}
+
+static int glamofb_blank(int blank, struct fb_info *info)
+{
+ switch (blank) {
+ case FB_BLANK_UNBLANK:
+ glamofb_on(info);
+ break;
+ case FB_BLANK_NORMAL:
+ glamofb_off(info, DRM_MODE_DPMS_STANDBY);
+ break;
+ case FB_BLANK_HSYNC_SUSPEND:
+ glamofb_off(info, DRM_MODE_DPMS_STANDBY);
+ break;
+ case FB_BLANK_VSYNC_SUSPEND:
+ glamofb_off(info, DRM_MODE_DPMS_SUSPEND);
+ break;
+ case FB_BLANK_POWERDOWN:
+ glamofb_off(info, DRM_MODE_DPMS_OFF);
+ break;
+ }
+ return 0;
+}
+
+static struct fb_ops glamofb_ops = {
+ .owner = THIS_MODULE,
+ .fb_check_var = glamofb_check_var,
+ .fb_set_par = glamofb_set_par,
+ .fb_setcolreg = glamofb_setcolreg,
+ .fb_fillrect = cfb_fillrect,
+ .fb_copyarea = cfb_copyarea,
+ .fb_imageblit = cfb_imageblit,
+ .fb_pan_display = glamofb_pan_display,
+ .fb_blank = glamofb_blank,
+};
+
+
+#define RESSIZE(ressource) (((ressource)->end - (ressource)->start)+1)
+
+
+/* Here, we create a GEM object of the correct size, and then turn it into
+ * /dev/fbX so that the kernel can put a console on it. */
+int glamofb_create(struct drm_device *dev, uint32_t fb_width,
+ uint32_t fb_height, uint32_t surface_width,
+ uint32_t surface_height,
+ struct glamo_framebuffer **glamo_fb_p)
+{
+ struct fb_info *info;
+ struct glamofb_par *par;
+ struct drm_framebuffer *fb;
+ struct glamo_framebuffer *glamo_fb;
+ struct drm_mode_fb_cmd mode_cmd;
+ struct drm_gem_object *fbo = NULL;
+ struct drm_glamo_gem_object *obj_priv;
+ struct device *device = &dev->platform_dev->dev;
+ struct glamodrm_handle *gdrm;
+ int size, ret;
+
+ gdrm = dev->dev_private;
+
+ mode_cmd.width = surface_width;
+ mode_cmd.height = surface_height;
+
+ mode_cmd.bpp = 16;
+ mode_cmd.pitch = ALIGN(mode_cmd.width * ((mode_cmd.bpp + 1) / 8), 64);
+ mode_cmd.depth = 16;
+
+ size = mode_cmd.pitch * mode_cmd.height;
+ size = ALIGN(size, PAGE_SIZE);
+ if ( size > GLAMO_FRAMEBUFFER_ALLOCATION ) {
+ printk(KERN_ERR "[glamo-drm] Not enough memory for fb\n");
+ ret = -ENOMEM;
+ goto out;
+ }
+ fbo = glamo_gem_object_alloc(dev, GLAMO_FRAMEBUFFER_ALLOCATION, 2);
+ if (!fbo) {
+ printk(KERN_ERR "[glamo-drm] Failed to allocate framebuffer\n");
+ ret = -ENOMEM;
+ goto out;
+ }
+ obj_priv = fbo->driver_private;
+
+ mutex_lock(&dev->struct_mutex);
+
+ ret = glamo_framebuffer_create(dev, &mode_cmd, &fb, fbo);
+ if (ret) {
+ DRM_ERROR("failed to allocate fb.\n");
+ goto out_unref;
+ }
+
+ list_add(&fb->filp_head, &dev->mode_config.fb_kernel_list);
+
+ glamo_fb = to_glamo_framebuffer(fb);
+ *glamo_fb_p = glamo_fb;
+
+ info = framebuffer_alloc(sizeof(struct glamofb_par), device);
+ if (!info) {
+ ret = -ENOMEM;
+ goto out_unref;
+ }
+
+ par = info->par;
+
+ strcpy(info->fix.id, "glamodrmfb");
+ info->fix.type = FB_TYPE_PACKED_PIXELS;
+ info->fix.visual = FB_VISUAL_TRUECOLOR;
+ info->fix.type_aux = 0;
+ info->fix.xpanstep = 1; /* doing it in hw */
+ info->fix.ypanstep = 1; /* doing it in hw */
+ info->fix.ywrapstep = 0;
+ info->fix.accel = FB_ACCEL_GLAMO;
+ info->fix.type_aux = 0;
+ info->flags = FBINFO_DEFAULT;
+
+ info->fbops = &glamofb_ops;
+
+ info->fix.line_length = fb->pitch;
+ info->fix.smem_start = dev->mode_config.fb_base
+ + (unsigned long) gdrm->vram->start;
+ info->fix.smem_len = size;
+
+ info->flags = FBINFO_DEFAULT;
+
+ info->screen_base = ioremap(gdrm->vram->start, RESSIZE(gdrm->vram));
+ if (!info->screen_base) {
+ printk(KERN_ERR "[glamo-drm] Couldn't map framebuffer!\n");
+ ret = -ENOSPC;
+ goto out_unref;
+ }
+ info->screen_size = size;
+
+ info->pseudo_palette = fb->pseudo_palette;
+ info->var.xres_virtual = fb->width;
+ info->var.yres_virtual = fb->height;
+ info->var.bits_per_pixel = fb->bits_per_pixel;
+ info->var.xoffset = 0;
+ info->var.yoffset = 0;
+ info->var.activate = FB_ACTIVATE_NOW;
+ info->var.height = -1;
+ info->var.width = -1;
+ info->var.xres = fb_width;
+ info->var.yres = fb_height;
+
+ info->fix.mmio_start = 0;
+ info->fix.mmio_len = 0;
+
+ info->pixmap.size = 64*1024;
+ info->pixmap.buf_align = 8;
+ info->pixmap.access_align = 32;
+ info->pixmap.flags = FB_PIXMAP_SYSTEM;
+ info->pixmap.scan_align = 1;
+
+ switch (fb->depth) {
+ case 16:
+ switch (reg_read(gdrm, GLAMO_REG_LCD_MODE3) & 0xc000) { /* FIXME */
+ case GLAMO_LCD_SRC_RGB565:
+ info->var.red.offset = 11;
+ info->var.green.offset = 5;
+ info->var.blue.offset = 0;
+ info->var.red.length = 5;
+ info->var.green.length = 6;
+ info->var.blue.length = 5;
+ info->var.transp.length = 0;
+ break;
+ case GLAMO_LCD_SRC_ARGB1555:
+ info->var.transp.offset = 15;
+ info->var.red.offset = 10;
+ info->var.green.offset = 5;
+ info->var.blue.offset = 0;
+ info->var.transp.length = 1;
+ info->var.red.length = 5;
+ info->var.green.length = 5;
+ info->var.blue.length = 5;
+ break;
+ case GLAMO_LCD_SRC_ARGB4444:
+ info->var.transp.offset = 12;
+ info->var.red.offset = 8;
+ info->var.green.offset = 4;
+ info->var.blue.offset = 0;
+ info->var.transp.length = 4;
+ info->var.red.length = 4;
+ info->var.green.length = 4;
+ info->var.blue.length = 4;
+ break;
+ }
+ break;
+ case 24:
+ case 32:
+ default:
+ /* The Smedia Glamo doesn't support anything but 16bit color */
+ printk(KERN_ERR "[glamo-drm] Only 16bpp is supported.\n");
+ return -EINVAL;
+ }
+
+ fb->fbdev = info;
+ par->glamo_fb = glamo_fb;
+ par->dev = dev;
+ gdrm->fb = info;
+
+ info->var.pixclock = -1;
+
+ printk(KERN_INFO "[glamo-drm] Allocated %dx%d fb: bo %p\n",
+ glamo_fb->base.width, glamo_fb->base.height, fbo);
+ mutex_unlock(&dev->struct_mutex);
+ return 0;
+
+out_unref:
+ drm_gem_object_unreference(fbo);
+ mutex_unlock(&dev->struct_mutex);
+out:
+ return ret;
+}
+
+
+void glamo_kmsfb_suspend(struct glamodrm_handle *gdrm)
+{
+ fb_set_suspend(gdrm->fb, 1);
+}
+
+
+void glamo_kmsfb_resume(struct glamodrm_handle *gdrm)
+{
+ fb_set_suspend(gdrm->fb, 0);
+}
diff --git a/drivers/mfd/glamo/glamo-kms-fb.h b/drivers/mfd/glamo/glamo-kms-fb.h
new file mode 100644
index 00000000000..9ae597bd366
--- /dev/null
+++ b/drivers/mfd/glamo/glamo-kms-fb.h
@@ -0,0 +1,41 @@
+/*
+ * SMedia Glamo 336x/337x KMS framebuffer
+ *
+ * Copyright (C) 2009 Thomas White <taw@bitwiz.org.uk>
+ *
+ * Based on glamo-fb.c (C) 2007-2008 by Openmoko, Inc.
+ * Author: Harald Welte <laforge@openmoko.org>
+ * 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
+ *
+ */
+
+#ifndef __GLAMO_KMS_FB_H
+#define __GLAMO_KMS_FB_H
+
+#include <drm/drmP.h>
+#include "glamo-drm-private.h"
+
+extern int glamofb_create(struct drm_device *dev, uint32_t fb_width,
+ uint32_t fb_height, uint32_t surface_width,
+ uint32_t surface_height,
+ struct glamo_framebuffer **glamo_fb_p);
+
+extern void glamo_kmsfb_suspend(struct glamodrm_handle *gdrm);
+extern void glamo_kmsfb_resume(struct glamodrm_handle *gdrm);
+
+#endif /* __GLAMO_KMS_FB_H */
diff --git a/drivers/video/display/jbt6k74.c b/drivers/video/display/jbt6k74.c
index 5d7a6519de9..fba69b52f17 100644
--- a/drivers/video/display/jbt6k74.c
+++ b/drivers/video/display/jbt6k74.c
@@ -622,6 +622,21 @@ static int fb_notifier_callback(struct notifier_block *self,
return 0;
}
+struct jbt_info *jbt_global;
+void jbt6k74_action(int val)
+{
+ if ( !jbt_global ) {
+ printk(KERN_CRIT "JBT not initialised!!!\n");
+ return;
+ }
+ if ( val == 0 ) {
+ jbt6k74_enter_state(jbt_global, JBT_STATE_SLEEP);
+ } else {
+ jbt6k74_enter_state(jbt_global, jbt_global->normal_state);
+ }
+}
+EXPORT_SYMBOL_GPL(jbt6k74_action);
+
/* linux device model infrastructure */
static int __devinit jbt_probe(struct spi_device *spi)
@@ -646,6 +661,8 @@ static int __devinit jbt_probe(struct spi_device *spi)
if (!jbt)
return -ENOMEM;
+ jbt_global = jbt;
+
jbt->spi_dev = spi;
jbt->normal_state = JBT_STATE_NORMAL;
jbt->state = JBT_STATE_DEEP_STANDBY;