2005-09-09 13:10:07 -07:00
|
|
|
|
/*
|
|
|
|
|
* linux/drivers/video/s3c2410fb.c
|
|
|
|
|
* Copyright (c) Arnaud Patard, Ben Dooks
|
|
|
|
|
*
|
|
|
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
|
|
|
* License. See the file COPYING in the main directory of this archive for
|
|
|
|
|
* more details.
|
|
|
|
|
*
|
|
|
|
|
* S3C2410 LCD Controller Frame Buffer Driver
|
|
|
|
|
* based on skeletonfb.c, sa1100fb.c and others
|
|
|
|
|
*
|
|
|
|
|
* ChangeLog
|
|
|
|
|
* 2005-04-07: Arnaud Patard <arnaud.patard@rtp-net.org>
|
|
|
|
|
* - u32 state -> pm_message_t state
|
|
|
|
|
* - S3C2410_{VA,SZ}_LCD -> S3C24XX
|
|
|
|
|
*
|
|
|
|
|
* 2005-03-15: Arnaud Patard <arnaud.patard@rtp-net.org>
|
|
|
|
|
* - Removed the ioctl
|
|
|
|
|
* - use readl/writel instead of __raw_writel/__raw_readl
|
|
|
|
|
*
|
|
|
|
|
* 2004-12-04: Arnaud Patard <arnaud.patard@rtp-net.org>
|
|
|
|
|
* - Added the possibility to set on or off the
|
|
|
|
|
* debugging mesaages
|
|
|
|
|
* - Replaced 0 and 1 by on or off when reading the
|
|
|
|
|
* /sys files
|
|
|
|
|
*
|
|
|
|
|
* 2005-03-23: Ben Dooks <ben-linux@fluff.org>
|
|
|
|
|
* - added non 16bpp modes
|
|
|
|
|
* - updated platform information for range of x/y/bpp
|
|
|
|
|
* - add code to ensure palette is written correctly
|
|
|
|
|
* - add pixel clock divisor control
|
|
|
|
|
*
|
|
|
|
|
* 2004-11-11: Arnaud Patard <arnaud.patard@rtp-net.org>
|
2007-10-16 01:28:54 -07:00
|
|
|
|
* - Removed the use of currcon as it no more exist
|
|
|
|
|
* - Added LCD power sysfs interface
|
2005-09-09 13:10:07 -07:00
|
|
|
|
*
|
|
|
|
|
* 2004-11-03: Ben Dooks <ben-linux@fluff.org>
|
|
|
|
|
* - minor cleanups
|
|
|
|
|
* - add suspend/resume support
|
|
|
|
|
* - s3c2410fb_setcolreg() not valid in >8bpp modes
|
|
|
|
|
* - removed last CONFIG_FB_S3C2410_FIXED
|
|
|
|
|
* - ensure lcd controller stopped before cleanup
|
|
|
|
|
* - added sysfs interface for backlight power
|
|
|
|
|
* - added mask for gpio configuration
|
|
|
|
|
* - ensured IRQs disabled during GPIO configuration
|
|
|
|
|
* - disable TPAL before enabling video
|
|
|
|
|
*
|
|
|
|
|
* 2004-09-20: Arnaud Patard <arnaud.patard@rtp-net.org>
|
|
|
|
|
* - Suppress command line options
|
|
|
|
|
*
|
|
|
|
|
* 2004-09-15: Arnaud Patard <arnaud.patard@rtp-net.org>
|
2007-10-16 01:28:54 -07:00
|
|
|
|
* - code cleanup
|
2005-09-09 13:10:07 -07:00
|
|
|
|
*
|
|
|
|
|
* 2004-09-07: Arnaud Patard <arnaud.patard@rtp-net.org>
|
2007-10-16 01:28:54 -07:00
|
|
|
|
* - Renamed from h1940fb.c to s3c2410fb.c
|
|
|
|
|
* - Add support for different devices
|
|
|
|
|
* - Backlight support
|
2005-09-09 13:10:07 -07:00
|
|
|
|
*
|
|
|
|
|
* 2004-09-05: Herbert P<EFBFBD>tzl <herbert@13thfloor.at>
|
|
|
|
|
* - added clock (de-)allocation code
|
|
|
|
|
* - added fixem fbmem option
|
|
|
|
|
*
|
|
|
|
|
* 2004-07-27: Arnaud Patard <arnaud.patard@rtp-net.org>
|
|
|
|
|
* - code cleanup
|
|
|
|
|
* - added a forgotten return in h1940fb_init
|
|
|
|
|
*
|
|
|
|
|
* 2004-07-19: Herbert P<EFBFBD>tzl <herbert@13thfloor.at>
|
|
|
|
|
* - code cleanup and extended debugging
|
|
|
|
|
*
|
|
|
|
|
* 2004-07-15: Arnaud Patard <arnaud.patard@rtp-net.org>
|
|
|
|
|
* - First version
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
|
#include <linux/errno.h>
|
|
|
|
|
#include <linux/string.h>
|
|
|
|
|
#include <linux/mm.h>
|
|
|
|
|
#include <linux/slab.h>
|
|
|
|
|
#include <linux/delay.h>
|
|
|
|
|
#include <linux/fb.h>
|
|
|
|
|
#include <linux/init.h>
|
|
|
|
|
#include <linux/dma-mapping.h>
|
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
|
#include <linux/workqueue.h>
|
|
|
|
|
#include <linux/wait.h>
|
2005-10-29 11:07:23 -07:00
|
|
|
|
#include <linux/platform_device.h>
|
2006-01-07 09:15:52 -07:00
|
|
|
|
#include <linux/clk.h>
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
|
|
|
|
#include <asm/io.h>
|
|
|
|
|
#include <asm/uaccess.h>
|
|
|
|
|
#include <asm/div64.h>
|
|
|
|
|
|
|
|
|
|
#include <asm/mach/map.h>
|
|
|
|
|
#include <asm/arch/regs-lcd.h>
|
|
|
|
|
#include <asm/arch/regs-gpio.h>
|
|
|
|
|
#include <asm/arch/fb.h>
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_PM
|
|
|
|
|
#include <linux/pm.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include "s3c2410fb.h"
|
|
|
|
|
|
|
|
|
|
static struct s3c2410fb_mach_info *mach_info;
|
|
|
|
|
|
|
|
|
|
/* Debugging stuff */
|
|
|
|
|
#ifdef CONFIG_FB_S3C2410_DEBUG
|
2007-10-16 01:28:54 -07:00
|
|
|
|
static int debug = 1;
|
2005-09-09 13:10:07 -07:00
|
|
|
|
#else
|
2007-10-16 01:28:54 -07:00
|
|
|
|
static int debug = 0;
|
2005-09-09 13:10:07 -07:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#define dprintk(msg...) if (debug) { printk(KERN_DEBUG "s3c2410fb: " msg); }
|
|
|
|
|
|
|
|
|
|
/* useful functions */
|
|
|
|
|
|
|
|
|
|
/* s3c2410fb_set_lcdaddr
|
|
|
|
|
*
|
|
|
|
|
* initialise lcd controller address pointers
|
2007-10-16 01:28:54 -07:00
|
|
|
|
*/
|
2007-10-16 01:28:55 -07:00
|
|
|
|
static void s3c2410fb_set_lcdaddr(struct fb_info *info)
|
2005-09-09 13:10:07 -07:00
|
|
|
|
{
|
|
|
|
|
unsigned long saddr1, saddr2, saddr3;
|
2007-10-16 01:28:55 -07:00
|
|
|
|
int line_length = info->var.xres * info->var.bits_per_pixel;
|
2007-10-16 01:29:01 -07:00
|
|
|
|
struct s3c2410fb_info *fbi = info->par;
|
|
|
|
|
void __iomem *regs = fbi->io;
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
2007-10-16 01:28:55 -07:00
|
|
|
|
saddr1 = info->fix.smem_start >> 1;
|
|
|
|
|
saddr2 = info->fix.smem_start;
|
|
|
|
|
saddr2 += (line_length * info->var.yres) / 8;
|
2007-10-16 01:28:54 -07:00
|
|
|
|
saddr2 >>= 1;
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
2007-10-16 01:28:54 -07:00
|
|
|
|
saddr3 = S3C2410_OFFSIZE(0) |
|
|
|
|
|
S3C2410_PAGEWIDTH((line_length / 16) & 0x3ff);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
|
|
|
|
dprintk("LCDSADDR1 = 0x%08lx\n", saddr1);
|
|
|
|
|
dprintk("LCDSADDR2 = 0x%08lx\n", saddr2);
|
|
|
|
|
dprintk("LCDSADDR3 = 0x%08lx\n", saddr3);
|
|
|
|
|
|
2007-10-16 01:29:01 -07:00
|
|
|
|
writel(saddr1, regs + S3C2410_LCDSADDR1);
|
|
|
|
|
writel(saddr2, regs + S3C2410_LCDSADDR2);
|
|
|
|
|
writel(saddr3, regs + S3C2410_LCDSADDR3);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* s3c2410fb_calc_pixclk()
|
|
|
|
|
*
|
|
|
|
|
* calculate divisor for clk->pixclk
|
2007-10-16 01:28:54 -07:00
|
|
|
|
*/
|
2005-09-09 13:10:07 -07:00
|
|
|
|
static unsigned int s3c2410fb_calc_pixclk(struct s3c2410fb_info *fbi,
|
|
|
|
|
unsigned long pixclk)
|
|
|
|
|
{
|
|
|
|
|
unsigned long clk = clk_get_rate(fbi->clk);
|
|
|
|
|
unsigned long long div;
|
|
|
|
|
|
|
|
|
|
/* pixclk is in picoseoncds, our clock is in Hz
|
|
|
|
|
*
|
|
|
|
|
* Hz -> picoseconds is / 10^-12
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
div = (unsigned long long)clk * pixclk;
|
2007-10-16 01:28:54 -07:00
|
|
|
|
do_div(div, 1000000UL);
|
|
|
|
|
do_div(div, 1000000UL);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
|
|
|
|
dprintk("pixclk %ld, divisor is %ld\n", pixclk, (long)div);
|
|
|
|
|
return div;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* s3c2410fb_check_var():
|
|
|
|
|
* Get the video params out of 'var'. If a value doesn't fit, round it up,
|
|
|
|
|
* if it's too big, return -EINVAL.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
static int s3c2410fb_check_var(struct fb_var_screeninfo *var,
|
|
|
|
|
struct fb_info *info)
|
|
|
|
|
{
|
|
|
|
|
struct s3c2410fb_info *fbi = info->par;
|
2007-10-16 01:28:56 -07:00
|
|
|
|
struct s3c2410fb_mach_info *mach_info = fbi->mach_info;
|
|
|
|
|
struct s3c2410fb_display *display = NULL;
|
|
|
|
|
unsigned i;
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
|
|
|
|
dprintk("check_var(var=%p, info=%p)\n", var, info);
|
|
|
|
|
|
|
|
|
|
/* validate x/y resolution */
|
|
|
|
|
|
2007-10-16 01:28:56 -07:00
|
|
|
|
for (i = 0; i < mach_info->num_displays; i++)
|
|
|
|
|
if (var->yres == mach_info->displays[i].yres &&
|
|
|
|
|
var->xres == mach_info->displays[i].xres &&
|
|
|
|
|
var->bits_per_pixel == mach_info->displays[i].bpp) {
|
|
|
|
|
display = mach_info->displays + i;
|
|
|
|
|
fbi->current_display = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
2007-10-16 01:28:56 -07:00
|
|
|
|
if (!display) {
|
|
|
|
|
dprintk("wrong resolution or depth %dx%d at %d bpp\n",
|
|
|
|
|
var->xres, var->yres, var->bits_per_pixel);
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
}
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
2007-10-16 01:28:57 -07:00
|
|
|
|
/* it is always the size as the display */
|
|
|
|
|
var->xres_virtual = display->xres;
|
|
|
|
|
var->yres_virtual = display->yres;
|
|
|
|
|
|
|
|
|
|
/* copy lcd settings */
|
|
|
|
|
var->left_margin = display->left_margin;
|
|
|
|
|
var->right_margin = display->right_margin;
|
|
|
|
|
|
2007-10-16 01:28:54 -07:00
|
|
|
|
var->transp.offset = 0;
|
|
|
|
|
var->transp.length = 0;
|
2005-09-09 13:10:07 -07:00
|
|
|
|
/* set r/g/b positions */
|
2006-12-08 03:40:23 -07:00
|
|
|
|
switch (var->bits_per_pixel) {
|
2007-10-16 01:28:54 -07:00
|
|
|
|
case 1:
|
|
|
|
|
case 2:
|
|
|
|
|
case 4:
|
|
|
|
|
var->red.offset = 0;
|
|
|
|
|
var->red.length = var->bits_per_pixel;
|
|
|
|
|
var->green = var->red;
|
|
|
|
|
var->blue = var->red;
|
|
|
|
|
break;
|
|
|
|
|
case 8:
|
2007-10-16 01:28:56 -07:00
|
|
|
|
if (display->type != S3C2410_LCDCON1_TFT) {
|
2007-10-16 01:28:54 -07:00
|
|
|
|
/* 8 bpp 332 */
|
|
|
|
|
var->red.length = 3;
|
|
|
|
|
var->red.offset = 5;
|
|
|
|
|
var->green.length = 3;
|
|
|
|
|
var->green.offset = 2;
|
|
|
|
|
var->blue.length = 2;
|
2006-12-08 03:40:23 -07:00
|
|
|
|
var->blue.offset = 0;
|
2007-10-16 01:28:54 -07:00
|
|
|
|
} else {
|
|
|
|
|
var->red.offset = 0;
|
2006-12-08 03:40:23 -07:00
|
|
|
|
var->red.length = 8;
|
2007-10-16 01:28:54 -07:00
|
|
|
|
var->green = var->red;
|
|
|
|
|
var->blue = var->red;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 12:
|
|
|
|
|
/* 12 bpp 444 */
|
|
|
|
|
var->red.length = 4;
|
|
|
|
|
var->red.offset = 8;
|
|
|
|
|
var->green.length = 4;
|
|
|
|
|
var->green.offset = 4;
|
|
|
|
|
var->blue.length = 4;
|
|
|
|
|
var->blue.offset = 0;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
case 16:
|
2007-10-16 01:28:58 -07:00
|
|
|
|
if (display->lcdcon5 & S3C2410_LCDCON5_FRM565) {
|
2007-10-16 01:28:54 -07:00
|
|
|
|
/* 16 bpp, 565 format */
|
|
|
|
|
var->red.offset = 11;
|
|
|
|
|
var->green.offset = 5;
|
2006-12-08 03:40:23 -07:00
|
|
|
|
var->blue.offset = 0;
|
2007-10-16 01:28:54 -07:00
|
|
|
|
var->red.length = 5;
|
|
|
|
|
var->green.length = 6;
|
|
|
|
|
var->blue.length = 5;
|
|
|
|
|
} else {
|
|
|
|
|
/* 16 bpp, 5551 format */
|
|
|
|
|
var->red.offset = 11;
|
|
|
|
|
var->green.offset = 6;
|
|
|
|
|
var->blue.offset = 1;
|
|
|
|
|
var->red.length = 5;
|
|
|
|
|
var->green.length = 5;
|
|
|
|
|
var->blue.length = 5;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2007-10-16 01:29:02 -07:00
|
|
|
|
case 32:
|
|
|
|
|
/* 24 bpp 888 and 8 dummy */
|
2007-10-16 01:28:54 -07:00
|
|
|
|
var->red.length = 8;
|
|
|
|
|
var->red.offset = 16;
|
|
|
|
|
var->green.length = 8;
|
|
|
|
|
var->green.offset = 8;
|
|
|
|
|
var->blue.length = 8;
|
|
|
|
|
var->blue.offset = 0;
|
|
|
|
|
break;
|
2006-12-08 03:40:23 -07:00
|
|
|
|
}
|
2005-09-09 13:10:07 -07:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2007-10-16 01:28:57 -07:00
|
|
|
|
/* s3c2410fb_calculate_stn_lcd_regs
|
2005-09-09 13:10:07 -07:00
|
|
|
|
*
|
2007-10-16 01:28:57 -07:00
|
|
|
|
* calculate register values from var settings
|
2007-10-16 01:28:54 -07:00
|
|
|
|
*/
|
2007-10-16 01:28:57 -07:00
|
|
|
|
static void s3c2410fb_calculate_stn_lcd_regs(const struct fb_info *info,
|
|
|
|
|
struct s3c2410fb_hw *regs)
|
2005-09-09 13:10:07 -07:00
|
|
|
|
{
|
2007-10-16 01:28:57 -07:00
|
|
|
|
const struct s3c2410fb_info *fbi = info->par;
|
|
|
|
|
const struct fb_var_screeninfo *var = &info->var;
|
|
|
|
|
int type = regs->lcdcon1 & ~S3C2410_LCDCON1_TFT;
|
|
|
|
|
int hs = var->xres >> 2;
|
|
|
|
|
unsigned wdly = (var->left_margin >> 4) - 1;
|
2007-10-16 01:29:00 -07:00
|
|
|
|
unsigned wlh = (var->hsync_len >> 4) - 1;
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
|
|
|
|
dprintk("%s: var->xres = %d\n", __FUNCTION__, var->xres);
|
|
|
|
|
dprintk("%s: var->yres = %d\n", __FUNCTION__, var->yres);
|
|
|
|
|
dprintk("%s: var->bpp = %d\n", __FUNCTION__, var->bits_per_pixel);
|
|
|
|
|
|
2007-10-16 01:28:57 -07:00
|
|
|
|
if (type != S3C2410_LCDCON1_STN4)
|
|
|
|
|
hs >>= 1;
|
2006-12-08 03:40:23 -07:00
|
|
|
|
|
2007-10-16 01:28:57 -07:00
|
|
|
|
regs->lcdcon1 &= ~S3C2410_LCDCON1_MODEMASK;
|
2006-12-08 03:40:23 -07:00
|
|
|
|
|
2007-10-16 01:28:57 -07:00
|
|
|
|
switch (var->bits_per_pixel) {
|
|
|
|
|
case 1:
|
|
|
|
|
regs->lcdcon1 |= S3C2410_LCDCON1_STN1BPP;
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
regs->lcdcon1 |= S3C2410_LCDCON1_STN2GREY;
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
regs->lcdcon1 |= S3C2410_LCDCON1_STN4GREY;
|
|
|
|
|
break;
|
|
|
|
|
case 8:
|
|
|
|
|
regs->lcdcon1 |= S3C2410_LCDCON1_STN8BPP;
|
|
|
|
|
hs *= 3;
|
|
|
|
|
break;
|
|
|
|
|
case 12:
|
|
|
|
|
regs->lcdcon1 |= S3C2410_LCDCON1_STN12BPP;
|
|
|
|
|
hs *= 3;
|
|
|
|
|
break;
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
2007-10-16 01:28:57 -07:00
|
|
|
|
default:
|
|
|
|
|
/* invalid pixel depth */
|
|
|
|
|
dev_err(fbi->dev, "invalid bpp %d\n",
|
|
|
|
|
var->bits_per_pixel);
|
|
|
|
|
}
|
|
|
|
|
/* update X/Y info */
|
|
|
|
|
dprintk("setting horz: lft=%d, rt=%d, sync=%d\n",
|
|
|
|
|
var->left_margin, var->right_margin, var->hsync_len);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
2007-10-16 01:28:59 -07:00
|
|
|
|
regs->lcdcon2 = S3C2410_LCDCON2_LINEVAL(var->yres - 1);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
2007-10-16 01:28:57 -07:00
|
|
|
|
if (wdly > 3)
|
|
|
|
|
wdly = 3;
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
2007-10-16 01:29:00 -07:00
|
|
|
|
if (wlh > 3)
|
|
|
|
|
wlh = 3;
|
|
|
|
|
|
2007-10-16 01:28:57 -07:00
|
|
|
|
regs->lcdcon3 = S3C2410_LCDCON3_WDLY(wdly) |
|
|
|
|
|
S3C2410_LCDCON3_LINEBLANK(var->right_margin / 8) |
|
|
|
|
|
S3C2410_LCDCON3_HOZVAL(hs - 1);
|
2007-10-16 01:29:00 -07:00
|
|
|
|
|
2007-10-16 01:29:01 -07:00
|
|
|
|
regs->lcdcon4 = S3C2410_LCDCON4_WLH(wlh);
|
2007-10-16 01:28:57 -07:00
|
|
|
|
}
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
2007-10-16 01:28:57 -07:00
|
|
|
|
/* s3c2410fb_calculate_tft_lcd_regs
|
|
|
|
|
*
|
|
|
|
|
* calculate register values from var settings
|
|
|
|
|
*/
|
|
|
|
|
static void s3c2410fb_calculate_tft_lcd_regs(const struct fb_info *info,
|
|
|
|
|
struct s3c2410fb_hw *regs)
|
|
|
|
|
{
|
|
|
|
|
const struct s3c2410fb_info *fbi = info->par;
|
|
|
|
|
const struct fb_var_screeninfo *var = &info->var;
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
2007-10-16 01:28:57 -07:00
|
|
|
|
dprintk("%s: var->xres = %d\n", __FUNCTION__, var->xres);
|
|
|
|
|
dprintk("%s: var->yres = %d\n", __FUNCTION__, var->yres);
|
|
|
|
|
dprintk("%s: var->bpp = %d\n", __FUNCTION__, var->bits_per_pixel);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
2007-10-16 01:28:57 -07:00
|
|
|
|
regs->lcdcon1 &= ~S3C2410_LCDCON1_MODEMASK;
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
2007-10-16 01:28:57 -07:00
|
|
|
|
switch (var->bits_per_pixel) {
|
|
|
|
|
case 1:
|
|
|
|
|
regs->lcdcon1 |= S3C2410_LCDCON1_TFT1BPP;
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
regs->lcdcon1 |= S3C2410_LCDCON1_TFT2BPP;
|
2007-10-16 01:28:54 -07:00
|
|
|
|
break;
|
2007-10-16 01:28:57 -07:00
|
|
|
|
case 4:
|
|
|
|
|
regs->lcdcon1 |= S3C2410_LCDCON1_TFT4BPP;
|
2007-10-16 01:28:54 -07:00
|
|
|
|
break;
|
2007-10-16 01:28:57 -07:00
|
|
|
|
case 8:
|
|
|
|
|
regs->lcdcon1 |= S3C2410_LCDCON1_TFT8BPP;
|
2007-10-16 01:29:02 -07:00
|
|
|
|
regs->lcdcon5 |= S3C2410_LCDCON5_BSWP |
|
|
|
|
|
S3C2410_LCDCON5_FRM565;
|
|
|
|
|
regs->lcdcon5 &= ~S3C2410_LCDCON5_HWSWP;
|
2007-10-16 01:28:57 -07:00
|
|
|
|
break;
|
|
|
|
|
case 16:
|
|
|
|
|
regs->lcdcon1 |= S3C2410_LCDCON1_TFT16BPP;
|
2007-10-16 01:29:02 -07:00
|
|
|
|
regs->lcdcon5 &= ~S3C2410_LCDCON5_BSWP;
|
|
|
|
|
regs->lcdcon5 |= S3C2410_LCDCON5_HWSWP;
|
|
|
|
|
break;
|
|
|
|
|
case 32:
|
|
|
|
|
regs->lcdcon1 |= S3C2410_LCDCON1_TFT24BPP;
|
|
|
|
|
regs->lcdcon5 &= ~(S3C2410_LCDCON5_BSWP |
|
|
|
|
|
S3C2410_LCDCON5_HWSWP |
|
|
|
|
|
S3C2410_LCDCON5_BPP24BL);
|
2007-10-16 01:28:54 -07:00
|
|
|
|
break;
|
2007-10-16 01:28:57 -07:00
|
|
|
|
default:
|
|
|
|
|
/* invalid pixel depth */
|
|
|
|
|
dev_err(fbi->dev, "invalid bpp %d\n",
|
|
|
|
|
var->bits_per_pixel);
|
2006-12-08 03:40:23 -07:00
|
|
|
|
}
|
2007-10-16 01:28:57 -07:00
|
|
|
|
/* update X/Y info */
|
|
|
|
|
dprintk("setting vert: up=%d, low=%d, sync=%d\n",
|
|
|
|
|
var->upper_margin, var->lower_margin, var->vsync_len);
|
2006-12-08 03:40:23 -07:00
|
|
|
|
|
2007-10-16 01:28:57 -07:00
|
|
|
|
dprintk("setting horz: lft=%d, rt=%d, sync=%d\n",
|
|
|
|
|
var->left_margin, var->right_margin, var->hsync_len);
|
2006-12-08 03:40:23 -07:00
|
|
|
|
|
2007-10-16 01:29:00 -07:00
|
|
|
|
regs->lcdcon2 = S3C2410_LCDCON2_LINEVAL(var->yres - 1) |
|
|
|
|
|
S3C2410_LCDCON2_VBPD(var->upper_margin - 1) |
|
|
|
|
|
S3C2410_LCDCON2_VFPD(var->lower_margin - 1) |
|
|
|
|
|
S3C2410_LCDCON2_VSPW(var->vsync_len - 1);
|
2007-10-16 01:28:57 -07:00
|
|
|
|
|
|
|
|
|
regs->lcdcon3 = S3C2410_LCDCON3_HBPD(var->right_margin - 1) |
|
|
|
|
|
S3C2410_LCDCON3_HFPD(var->left_margin - 1) |
|
|
|
|
|
S3C2410_LCDCON3_HOZVAL(var->xres - 1);
|
2007-10-16 01:29:00 -07:00
|
|
|
|
|
2007-10-16 01:29:01 -07:00
|
|
|
|
regs->lcdcon4 = S3C2410_LCDCON4_HSPW(var->hsync_len - 1);
|
2007-10-16 01:28:57 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* s3c2410fb_activate_var
|
|
|
|
|
*
|
|
|
|
|
* activate (set) the controller from the given framebuffer
|
|
|
|
|
* information
|
|
|
|
|
*/
|
|
|
|
|
static void s3c2410fb_activate_var(struct fb_info *info)
|
|
|
|
|
{
|
|
|
|
|
struct s3c2410fb_info *fbi = info->par;
|
2007-10-16 01:29:01 -07:00
|
|
|
|
void __iomem *regs = fbi->io;
|
2007-10-16 01:28:57 -07:00
|
|
|
|
struct fb_var_screeninfo *var = &info->var;
|
|
|
|
|
struct s3c2410fb_mach_info *mach_info = fbi->mach_info;
|
|
|
|
|
struct s3c2410fb_display *display = mach_info->displays +
|
|
|
|
|
fbi->current_display;
|
|
|
|
|
|
|
|
|
|
/* set display type */
|
|
|
|
|
fbi->regs.lcdcon1 &= ~S3C2410_LCDCON1_TFT;
|
|
|
|
|
fbi->regs.lcdcon1 |= display->type;
|
|
|
|
|
|
2005-09-09 13:10:07 -07:00
|
|
|
|
if (var->pixclock > 0) {
|
|
|
|
|
int clkdiv = s3c2410fb_calc_pixclk(fbi, var->pixclock);
|
|
|
|
|
|
2007-10-16 01:28:56 -07:00
|
|
|
|
if (display->type == S3C2410_LCDCON1_TFT) {
|
2007-10-16 01:28:54 -07:00
|
|
|
|
clkdiv = (clkdiv / 2) - 1;
|
2006-12-08 03:40:23 -07:00
|
|
|
|
if (clkdiv < 0)
|
|
|
|
|
clkdiv = 0;
|
2007-10-16 01:28:54 -07:00
|
|
|
|
} else {
|
2006-12-08 03:40:23 -07:00
|
|
|
|
clkdiv = (clkdiv / 2);
|
|
|
|
|
if (clkdiv < 2)
|
|
|
|
|
clkdiv = 2;
|
|
|
|
|
}
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
|
|
|
|
fbi->regs.lcdcon1 &= ~S3C2410_LCDCON1_CLKVAL(0x3ff);
|
|
|
|
|
fbi->regs.lcdcon1 |= S3C2410_LCDCON1_CLKVAL(clkdiv);
|
|
|
|
|
}
|
|
|
|
|
|
2007-10-16 01:28:57 -07:00
|
|
|
|
if (display->type == S3C2410_LCDCON1_TFT)
|
|
|
|
|
s3c2410fb_calculate_tft_lcd_regs(info, &fbi->regs);
|
|
|
|
|
else
|
|
|
|
|
s3c2410fb_calculate_stn_lcd_regs(info, &fbi->regs);
|
|
|
|
|
|
2005-09-09 13:10:07 -07:00
|
|
|
|
/* write new registers */
|
|
|
|
|
|
|
|
|
|
dprintk("new register set:\n");
|
|
|
|
|
dprintk("lcdcon[1] = 0x%08lx\n", fbi->regs.lcdcon1);
|
|
|
|
|
dprintk("lcdcon[2] = 0x%08lx\n", fbi->regs.lcdcon2);
|
|
|
|
|
dprintk("lcdcon[3] = 0x%08lx\n", fbi->regs.lcdcon3);
|
|
|
|
|
dprintk("lcdcon[4] = 0x%08lx\n", fbi->regs.lcdcon4);
|
|
|
|
|
dprintk("lcdcon[5] = 0x%08lx\n", fbi->regs.lcdcon5);
|
|
|
|
|
|
2007-10-16 01:29:01 -07:00
|
|
|
|
writel(fbi->regs.lcdcon1 & ~S3C2410_LCDCON1_ENVID,
|
|
|
|
|
regs + S3C2410_LCDCON1);
|
|
|
|
|
writel(fbi->regs.lcdcon2, regs + S3C2410_LCDCON2);
|
|
|
|
|
writel(fbi->regs.lcdcon3, regs + S3C2410_LCDCON3);
|
|
|
|
|
writel(fbi->regs.lcdcon4, regs + S3C2410_LCDCON4);
|
|
|
|
|
writel(fbi->regs.lcdcon5, regs + S3C2410_LCDCON5);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
|
|
|
|
/* set lcd address pointers */
|
2007-10-16 01:28:55 -07:00
|
|
|
|
s3c2410fb_set_lcdaddr(info);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
2007-10-16 01:29:01 -07:00
|
|
|
|
writel(fbi->regs.lcdcon1, regs + S3C2410_LCDCON1);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
2007-10-16 01:28:54 -07:00
|
|
|
|
* s3c2410fb_set_par - Alters the hardware state.
|
2005-09-09 13:10:07 -07:00
|
|
|
|
* @info: frame buffer structure that represents a single frame buffer
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
static int s3c2410fb_set_par(struct fb_info *info)
|
|
|
|
|
{
|
|
|
|
|
struct fb_var_screeninfo *var = &info->var;
|
|
|
|
|
|
2007-10-16 01:28:54 -07:00
|
|
|
|
switch (var->bits_per_pixel) {
|
2007-10-16 01:29:02 -07:00
|
|
|
|
case 32:
|
2007-10-16 01:28:54 -07:00
|
|
|
|
case 16:
|
2007-10-16 01:29:02 -07:00
|
|
|
|
case 12:
|
2007-10-16 01:28:54 -07:00
|
|
|
|
info->fix.visual = FB_VISUAL_TRUECOLOR;
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
info->fix.visual = FB_VISUAL_MONO01;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
|
|
|
|
|
break;
|
2006-12-08 03:40:23 -07:00
|
|
|
|
}
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
2007-10-16 01:28:54 -07:00
|
|
|
|
info->fix.line_length = (var->width * var->bits_per_pixel) / 8;
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
|
|
|
|
/* activate this new configuration */
|
|
|
|
|
|
2007-10-16 01:28:57 -07:00
|
|
|
|
s3c2410fb_activate_var(info);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void schedule_palette_update(struct s3c2410fb_info *fbi,
|
|
|
|
|
unsigned int regno, unsigned int val)
|
|
|
|
|
{
|
|
|
|
|
unsigned long flags;
|
|
|
|
|
unsigned long irqen;
|
2007-07-31 00:37:37 -07:00
|
|
|
|
void __iomem *regs = fbi->io;
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
|
|
|
|
local_irq_save(flags);
|
|
|
|
|
|
|
|
|
|
fbi->palette_buffer[regno] = val;
|
|
|
|
|
|
|
|
|
|
if (!fbi->palette_ready) {
|
|
|
|
|
fbi->palette_ready = 1;
|
|
|
|
|
|
|
|
|
|
/* enable IRQ */
|
2007-07-31 00:37:37 -07:00
|
|
|
|
irqen = readl(regs + S3C2410_LCDINTMSK);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
irqen &= ~S3C2410_LCDINT_FRSYNC;
|
2007-07-31 00:37:37 -07:00
|
|
|
|
writel(irqen, regs + S3C2410_LCDINTMSK);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
local_irq_restore(flags);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* from pxafb.c */
|
2007-10-16 01:28:54 -07:00
|
|
|
|
static inline unsigned int chan_to_field(unsigned int chan,
|
|
|
|
|
struct fb_bitfield *bf)
|
2005-09-09 13:10:07 -07:00
|
|
|
|
{
|
|
|
|
|
chan &= 0xffff;
|
|
|
|
|
chan >>= 16 - bf->length;
|
|
|
|
|
return chan << bf->offset;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int s3c2410fb_setcolreg(unsigned regno,
|
|
|
|
|
unsigned red, unsigned green, unsigned blue,
|
|
|
|
|
unsigned transp, struct fb_info *info)
|
|
|
|
|
{
|
|
|
|
|
struct s3c2410fb_info *fbi = info->par;
|
2007-10-16 01:29:01 -07:00
|
|
|
|
void __iomem *regs = fbi->io;
|
2005-09-09 13:10:07 -07:00
|
|
|
|
unsigned int val;
|
|
|
|
|
|
2007-10-16 01:28:54 -07:00
|
|
|
|
/* dprintk("setcol: regno=%d, rgb=%d,%d,%d\n",
|
|
|
|
|
regno, red, green, blue); */
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
2007-10-16 01:28:54 -07:00
|
|
|
|
switch (info->fix.visual) {
|
2005-09-09 13:10:07 -07:00
|
|
|
|
case FB_VISUAL_TRUECOLOR:
|
2007-10-16 01:28:54 -07:00
|
|
|
|
/* true-colour, use pseudo-palette */
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
|
|
|
|
if (regno < 16) {
|
2007-10-16 01:28:54 -07:00
|
|
|
|
u32 *pal = info->pseudo_palette;
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
2007-10-16 01:28:54 -07:00
|
|
|
|
val = chan_to_field(red, &info->var.red);
|
|
|
|
|
val |= chan_to_field(green, &info->var.green);
|
|
|
|
|
val |= chan_to_field(blue, &info->var.blue);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
|
|
|
|
pal[regno] = val;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case FB_VISUAL_PSEUDOCOLOR:
|
|
|
|
|
if (regno < 256) {
|
|
|
|
|
/* currently assume RGB 5-6-5 mode */
|
|
|
|
|
|
|
|
|
|
val = ((red >> 0) & 0xf800);
|
|
|
|
|
val |= ((green >> 5) & 0x07e0);
|
|
|
|
|
val |= ((blue >> 11) & 0x001f);
|
|
|
|
|
|
2007-10-16 01:29:01 -07:00
|
|
|
|
writel(val, regs + S3C2410_TFTPAL(regno));
|
2005-09-09 13:10:07 -07:00
|
|
|
|
schedule_palette_update(fbi, regno, val);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
2007-10-16 01:28:54 -07:00
|
|
|
|
return 1; /* unknown type */
|
2005-09-09 13:10:07 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2007-10-16 01:28:54 -07:00
|
|
|
|
/*
|
2005-09-09 13:10:07 -07:00
|
|
|
|
* s3c2410fb_blank
|
|
|
|
|
* @blank_mode: the blank mode we want.
|
|
|
|
|
* @info: frame buffer structure that represents a single frame buffer
|
|
|
|
|
*
|
|
|
|
|
* Blank the screen if blank_mode != 0, else unblank. Return 0 if
|
|
|
|
|
* blanking succeeded, != 0 if un-/blanking failed due to e.g. a
|
|
|
|
|
* video mode which doesn't support it. Implements VESA suspend
|
|
|
|
|
* and powerdown modes on hardware that supports disabling hsync/vsync:
|
|
|
|
|
* blank_mode == 2: suspend vsync
|
|
|
|
|
* blank_mode == 3: suspend hsync
|
|
|
|
|
* blank_mode == 4: powerdown
|
|
|
|
|
*
|
|
|
|
|
* Returns negative errno on error, or zero on success.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
static int s3c2410fb_blank(int blank_mode, struct fb_info *info)
|
|
|
|
|
{
|
2007-10-16 01:29:01 -07:00
|
|
|
|
struct s3c2410fb_info *fbi = info->par;
|
|
|
|
|
void __iomem *regs = fbi->io;
|
|
|
|
|
|
2005-09-09 13:10:07 -07:00
|
|
|
|
dprintk("blank(mode=%d, info=%p)\n", blank_mode, info);
|
|
|
|
|
|
|
|
|
|
if (mach_info == NULL)
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
|
|
if (blank_mode == FB_BLANK_UNBLANK)
|
2007-10-16 01:29:01 -07:00
|
|
|
|
writel(0x0, regs + S3C2410_TPAL);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
else {
|
|
|
|
|
dprintk("setting TPAL to output 0x000000\n");
|
2007-10-16 01:29:01 -07:00
|
|
|
|
writel(S3C2410_TPAL_EN, regs + S3C2410_TPAL);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2007-10-16 01:28:54 -07:00
|
|
|
|
static int s3c2410fb_debug_show(struct device *dev,
|
|
|
|
|
struct device_attribute *attr, char *buf)
|
2005-09-09 13:10:07 -07:00
|
|
|
|
{
|
|
|
|
|
return snprintf(buf, PAGE_SIZE, "%s\n", debug ? "on" : "off");
|
|
|
|
|
}
|
2007-10-16 01:28:54 -07:00
|
|
|
|
static int s3c2410fb_debug_store(struct device *dev,
|
|
|
|
|
struct device_attribute *attr,
|
|
|
|
|
const char *buf, size_t len)
|
2005-09-09 13:10:07 -07:00
|
|
|
|
{
|
|
|
|
|
if (mach_info == NULL)
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
|
|
if (len < 1)
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
|
|
if (strnicmp(buf, "on", 2) == 0 ||
|
|
|
|
|
strnicmp(buf, "1", 1) == 0) {
|
|
|
|
|
debug = 1;
|
|
|
|
|
printk(KERN_DEBUG "s3c2410fb: Debug On");
|
|
|
|
|
} else if (strnicmp(buf, "off", 3) == 0 ||
|
|
|
|
|
strnicmp(buf, "0", 1) == 0) {
|
|
|
|
|
debug = 0;
|
|
|
|
|
printk(KERN_DEBUG "s3c2410fb: Debug Off");
|
|
|
|
|
} else {
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return len;
|
|
|
|
|
}
|
|
|
|
|
|
2007-10-16 01:28:54 -07:00
|
|
|
|
static DEVICE_ATTR(debug, 0666, s3c2410fb_debug_show, s3c2410fb_debug_store);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
|
|
|
|
static struct fb_ops s3c2410fb_ops = {
|
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
|
.fb_check_var = s3c2410fb_check_var,
|
|
|
|
|
.fb_set_par = s3c2410fb_set_par,
|
|
|
|
|
.fb_blank = s3c2410fb_blank,
|
|
|
|
|
.fb_setcolreg = s3c2410fb_setcolreg,
|
|
|
|
|
.fb_fillrect = cfb_fillrect,
|
|
|
|
|
.fb_copyarea = cfb_copyarea,
|
|
|
|
|
.fb_imageblit = cfb_imageblit,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* s3c2410fb_map_video_memory():
|
|
|
|
|
* Allocates the DRAM memory for the frame buffer. This buffer is
|
|
|
|
|
* remapped into a non-cached, non-buffered, memory region to
|
|
|
|
|
* allow palette and pixel writes to occur without flushing the
|
|
|
|
|
* cache. Once this area is remapped, all virtual memory
|
|
|
|
|
* access to the video memory should occur at the new region.
|
|
|
|
|
*/
|
2007-10-16 01:28:55 -07:00
|
|
|
|
static int __init s3c2410fb_map_video_memory(struct fb_info *info)
|
2005-09-09 13:10:07 -07:00
|
|
|
|
{
|
2007-10-16 01:28:55 -07:00
|
|
|
|
struct s3c2410fb_info *fbi = info->par;
|
|
|
|
|
|
2005-09-09 13:10:07 -07:00
|
|
|
|
dprintk("map_video_memory(fbi=%p)\n", fbi);
|
|
|
|
|
|
2007-10-16 01:28:55 -07:00
|
|
|
|
fbi->map_size = PAGE_ALIGN(info->fix.smem_len + PAGE_SIZE);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
fbi->map_cpu = dma_alloc_writecombine(fbi->dev, fbi->map_size,
|
|
|
|
|
&fbi->map_dma, GFP_KERNEL);
|
|
|
|
|
|
2007-10-16 01:28:55 -07:00
|
|
|
|
fbi->map_size = info->fix.smem_len;
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
|
|
|
|
if (fbi->map_cpu) {
|
|
|
|
|
/* prevent initial garbage on screen */
|
|
|
|
|
dprintk("map_video_memory: clear %p:%08x\n",
|
|
|
|
|
fbi->map_cpu, fbi->map_size);
|
|
|
|
|
memset(fbi->map_cpu, 0xf0, fbi->map_size);
|
|
|
|
|
|
|
|
|
|
fbi->screen_dma = fbi->map_dma;
|
2007-10-16 01:28:55 -07:00
|
|
|
|
info->screen_base = fbi->map_cpu;
|
|
|
|
|
info->fix.smem_start = fbi->screen_dma;
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
|
|
|
|
dprintk("map_video_memory: dma=%08x cpu=%p size=%08x\n",
|
2007-10-16 01:28:55 -07:00
|
|
|
|
fbi->map_dma, fbi->map_cpu, info->fix.smem_len);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return fbi->map_cpu ? 0 : -ENOMEM;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void s3c2410fb_unmap_video_memory(struct s3c2410fb_info *fbi)
|
|
|
|
|
{
|
2007-10-16 01:28:54 -07:00
|
|
|
|
dma_free_writecombine(fbi->dev, fbi->map_size, fbi->map_cpu,
|
|
|
|
|
fbi->map_dma);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void modify_gpio(void __iomem *reg,
|
|
|
|
|
unsigned long set, unsigned long mask)
|
|
|
|
|
{
|
|
|
|
|
unsigned long tmp;
|
|
|
|
|
|
|
|
|
|
tmp = readl(reg) & ~mask;
|
|
|
|
|
writel(tmp | set, reg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* s3c2410fb_init_registers - Initialise all LCD-related registers
|
|
|
|
|
*/
|
2007-10-16 01:28:55 -07:00
|
|
|
|
static int s3c2410fb_init_registers(struct fb_info *info)
|
2005-09-09 13:10:07 -07:00
|
|
|
|
{
|
2007-10-16 01:28:55 -07:00
|
|
|
|
struct s3c2410fb_info *fbi = info->par;
|
2005-09-09 13:10:07 -07:00
|
|
|
|
unsigned long flags;
|
2007-07-31 00:37:37 -07:00
|
|
|
|
void __iomem *regs = fbi->io;
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
|
|
|
|
/* Initialise LCD with values from haret */
|
|
|
|
|
|
|
|
|
|
local_irq_save(flags);
|
|
|
|
|
|
|
|
|
|
/* modify the gpio(s) with interrupts set (bjd) */
|
|
|
|
|
|
|
|
|
|
modify_gpio(S3C2410_GPCUP, mach_info->gpcup, mach_info->gpcup_mask);
|
|
|
|
|
modify_gpio(S3C2410_GPCCON, mach_info->gpccon, mach_info->gpccon_mask);
|
|
|
|
|
modify_gpio(S3C2410_GPDUP, mach_info->gpdup, mach_info->gpdup_mask);
|
|
|
|
|
modify_gpio(S3C2410_GPDCON, mach_info->gpdcon, mach_info->gpdcon_mask);
|
|
|
|
|
|
|
|
|
|
local_irq_restore(flags);
|
|
|
|
|
|
2007-07-31 00:37:37 -07:00
|
|
|
|
writel(fbi->regs.lcdcon1, regs + S3C2410_LCDCON1);
|
|
|
|
|
writel(fbi->regs.lcdcon2, regs + S3C2410_LCDCON2);
|
|
|
|
|
writel(fbi->regs.lcdcon3, regs + S3C2410_LCDCON3);
|
|
|
|
|
writel(fbi->regs.lcdcon4, regs + S3C2410_LCDCON4);
|
|
|
|
|
writel(fbi->regs.lcdcon5, regs + S3C2410_LCDCON5);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
2007-10-16 01:28:55 -07:00
|
|
|
|
s3c2410fb_set_lcdaddr(info);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
|
|
|
|
dprintk("LPCSEL = 0x%08lx\n", mach_info->lpcsel);
|
2007-07-31 00:37:37 -07:00
|
|
|
|
writel(mach_info->lpcsel, regs + S3C2410_LPCSEL);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
2007-07-31 00:37:37 -07:00
|
|
|
|
dprintk("replacing TPAL %08x\n", readl(regs + S3C2410_TPAL));
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
|
|
|
|
/* ensure temporary palette disabled */
|
2007-07-31 00:37:37 -07:00
|
|
|
|
writel(0x00, regs + S3C2410_TPAL);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
|
|
|
|
/* Enable video by setting the ENVID bit to 1 */
|
|
|
|
|
fbi->regs.lcdcon1 |= S3C2410_LCDCON1_ENVID;
|
2007-07-31 00:37:37 -07:00
|
|
|
|
writel(fbi->regs.lcdcon1, regs + S3C2410_LCDCON1);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void s3c2410fb_write_palette(struct s3c2410fb_info *fbi)
|
|
|
|
|
{
|
|
|
|
|
unsigned int i;
|
2007-07-31 00:37:37 -07:00
|
|
|
|
void __iomem *regs = fbi->io;
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
|
|
|
|
fbi->palette_ready = 0;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < 256; i++) {
|
2007-10-16 01:28:54 -07:00
|
|
|
|
unsigned long ent = fbi->palette_buffer[i];
|
|
|
|
|
if (ent == PALETTE_BUFF_CLEAR)
|
2005-09-09 13:10:07 -07:00
|
|
|
|
continue;
|
|
|
|
|
|
2007-07-31 00:37:37 -07:00
|
|
|
|
writel(ent, regs + S3C2410_TFTPAL(i));
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
|
|
|
|
/* it seems the only way to know exactly
|
|
|
|
|
* if the palette wrote ok, is to check
|
|
|
|
|
* to see if the value verifies ok
|
|
|
|
|
*/
|
|
|
|
|
|
2007-07-31 00:37:37 -07:00
|
|
|
|
if (readw(regs + S3C2410_TFTPAL(i)) == ent)
|
2005-09-09 13:10:07 -07:00
|
|
|
|
fbi->palette_buffer[i] = PALETTE_BUFF_CLEAR;
|
|
|
|
|
else
|
|
|
|
|
fbi->palette_ready = 1; /* retry */
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 06:55:46 -07:00
|
|
|
|
static irqreturn_t s3c2410fb_irq(int irq, void *dev_id)
|
2005-09-09 13:10:07 -07:00
|
|
|
|
{
|
|
|
|
|
struct s3c2410fb_info *fbi = dev_id;
|
2007-07-31 00:37:37 -07:00
|
|
|
|
void __iomem *regs = fbi->io;
|
|
|
|
|
unsigned long lcdirq = readl(regs + S3C2410_LCDINTPND);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
|
|
|
|
if (lcdirq & S3C2410_LCDINT_FRSYNC) {
|
|
|
|
|
if (fbi->palette_ready)
|
|
|
|
|
s3c2410fb_write_palette(fbi);
|
|
|
|
|
|
2007-07-31 00:37:37 -07:00
|
|
|
|
writel(S3C2410_LCDINT_FRSYNC, regs + S3C2410_LCDINTPND);
|
|
|
|
|
writel(S3C2410_LCDINT_FRSYNC, regs + S3C2410_LCDSRCPND);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
|
}
|
|
|
|
|
|
2007-10-16 01:28:54 -07:00
|
|
|
|
static char driver_name[] = "s3c2410fb";
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
2006-01-09 21:53:41 -07:00
|
|
|
|
static int __init s3c2410fb_probe(struct platform_device *pdev)
|
2005-09-09 13:10:07 -07:00
|
|
|
|
{
|
|
|
|
|
struct s3c2410fb_info *info;
|
2007-10-16 01:28:56 -07:00
|
|
|
|
struct s3c2410fb_display *display;
|
2007-10-16 01:28:54 -07:00
|
|
|
|
struct fb_info *fbinfo;
|
2007-07-31 00:37:37 -07:00
|
|
|
|
struct resource *res;
|
2005-09-09 13:10:07 -07:00
|
|
|
|
int ret;
|
|
|
|
|
int irq;
|
|
|
|
|
int i;
|
2007-07-31 00:37:37 -07:00
|
|
|
|
int size;
|
2006-06-26 00:26:45 -07:00
|
|
|
|
u32 lcdcon1;
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
2005-11-09 15:32:44 -07:00
|
|
|
|
mach_info = pdev->dev.platform_data;
|
2005-09-09 13:10:07 -07:00
|
|
|
|
if (mach_info == NULL) {
|
2007-10-16 01:28:54 -07:00
|
|
|
|
dev_err(&pdev->dev,
|
|
|
|
|
"no platform data for lcd, cannot attach\n");
|
2005-09-09 13:10:07 -07:00
|
|
|
|
return -EINVAL;
|
|
|
|
|
}
|
|
|
|
|
|
2007-10-16 01:28:56 -07:00
|
|
|
|
display = mach_info->displays + mach_info->default_display;
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
|
|
|
|
irq = platform_get_irq(pdev, 0);
|
|
|
|
|
if (irq < 0) {
|
2005-11-09 15:32:44 -07:00
|
|
|
|
dev_err(&pdev->dev, "no irq for device\n");
|
2005-09-09 13:10:07 -07:00
|
|
|
|
return -ENOENT;
|
|
|
|
|
}
|
|
|
|
|
|
2005-11-09 15:32:44 -07:00
|
|
|
|
fbinfo = framebuffer_alloc(sizeof(struct s3c2410fb_info), &pdev->dev);
|
2007-10-16 01:28:54 -07:00
|
|
|
|
if (!fbinfo)
|
2005-09-09 13:10:07 -07:00
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
|
|
info = fbinfo->par;
|
2007-02-16 02:28:42 -07:00
|
|
|
|
info->dev = &pdev->dev;
|
|
|
|
|
|
2007-07-31 00:37:37 -07:00
|
|
|
|
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
|
|
|
|
if (res == NULL) {
|
2007-10-16 01:28:54 -07:00
|
|
|
|
dev_err(&pdev->dev, "failed to get memory registers\n");
|
2007-07-31 00:37:37 -07:00
|
|
|
|
ret = -ENXIO;
|
|
|
|
|
goto dealloc_fb;
|
|
|
|
|
}
|
|
|
|
|
|
2007-10-16 01:28:54 -07:00
|
|
|
|
size = (res->end - res->start) + 1;
|
2007-07-31 00:37:37 -07:00
|
|
|
|
info->mem = request_mem_region(res->start, size, pdev->name);
|
|
|
|
|
if (info->mem == NULL) {
|
|
|
|
|
dev_err(&pdev->dev, "failed to get memory region\n");
|
|
|
|
|
ret = -ENOENT;
|
|
|
|
|
goto dealloc_fb;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
info->io = ioremap(res->start, size);
|
|
|
|
|
if (info->io == NULL) {
|
|
|
|
|
dev_err(&pdev->dev, "ioremap() of registers failed\n");
|
|
|
|
|
ret = -ENXIO;
|
|
|
|
|
goto release_mem;
|
|
|
|
|
}
|
|
|
|
|
|
2005-11-09 15:32:44 -07:00
|
|
|
|
platform_set_drvdata(pdev, fbinfo);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
|
|
|
|
dprintk("devinit\n");
|
|
|
|
|
|
|
|
|
|
strcpy(fbinfo->fix.id, driver_name);
|
|
|
|
|
|
2007-10-16 01:28:58 -07:00
|
|
|
|
info->regs.lcdcon1 = display->lcdcon1;
|
|
|
|
|
info->regs.lcdcon5 = display->lcdcon5;
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
2006-06-26 00:26:45 -07:00
|
|
|
|
/* Stop the video and unset ENVID if set */
|
|
|
|
|
info->regs.lcdcon1 &= ~S3C2410_LCDCON1_ENVID;
|
2007-07-31 00:37:37 -07:00
|
|
|
|
lcdcon1 = readl(info->io + S3C2410_LCDCON1);
|
|
|
|
|
writel(lcdcon1 & ~S3C2410_LCDCON1_ENVID, info->io + S3C2410_LCDCON1);
|
2006-06-26 00:26:45 -07:00
|
|
|
|
|
2005-11-09 15:32:44 -07:00
|
|
|
|
info->mach_info = pdev->dev.platform_data;
|
2007-10-16 01:28:56 -07:00
|
|
|
|
info->current_display = mach_info->default_display;
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
|
|
|
|
fbinfo->fix.type = FB_TYPE_PACKED_PIXELS;
|
|
|
|
|
fbinfo->fix.type_aux = 0;
|
|
|
|
|
fbinfo->fix.xpanstep = 0;
|
|
|
|
|
fbinfo->fix.ypanstep = 0;
|
|
|
|
|
fbinfo->fix.ywrapstep = 0;
|
|
|
|
|
fbinfo->fix.accel = FB_ACCEL_NONE;
|
|
|
|
|
|
|
|
|
|
fbinfo->var.nonstd = 0;
|
|
|
|
|
fbinfo->var.activate = FB_ACTIVATE_NOW;
|
2007-10-16 01:28:56 -07:00
|
|
|
|
fbinfo->var.height = display->height;
|
|
|
|
|
fbinfo->var.width = display->width;
|
2005-09-09 13:10:07 -07:00
|
|
|
|
fbinfo->var.accel_flags = 0;
|
|
|
|
|
fbinfo->var.vmode = FB_VMODE_NONINTERLACED;
|
|
|
|
|
|
|
|
|
|
fbinfo->fbops = &s3c2410fb_ops;
|
|
|
|
|
fbinfo->flags = FBINFO_FLAG_DEFAULT;
|
|
|
|
|
fbinfo->pseudo_palette = &info->pseudo_pal;
|
|
|
|
|
|
2007-10-16 01:28:56 -07:00
|
|
|
|
fbinfo->var.xres = display->xres;
|
|
|
|
|
fbinfo->var.xres_virtual = display->xres;
|
|
|
|
|
fbinfo->var.yres = display->yres;
|
|
|
|
|
fbinfo->var.yres_virtual = display->yres;
|
|
|
|
|
fbinfo->var.bits_per_pixel = display->bpp;
|
2007-10-16 01:28:57 -07:00
|
|
|
|
fbinfo->var.left_margin = display->left_margin;
|
|
|
|
|
fbinfo->var.right_margin = display->right_margin;
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
2007-10-16 01:28:59 -07:00
|
|
|
|
fbinfo->var.upper_margin = display->upper_margin;
|
|
|
|
|
fbinfo->var.lower_margin = display->lower_margin;
|
2007-10-16 01:29:00 -07:00
|
|
|
|
fbinfo->var.vsync_len = display->vsync_len;
|
|
|
|
|
fbinfo->var.hsync_len = display->hsync_len;
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
|
|
|
|
fbinfo->var.red.offset = 11;
|
|
|
|
|
fbinfo->var.green.offset = 5;
|
|
|
|
|
fbinfo->var.blue.offset = 0;
|
|
|
|
|
fbinfo->var.transp.offset = 0;
|
|
|
|
|
fbinfo->var.red.length = 5;
|
|
|
|
|
fbinfo->var.green.length = 6;
|
|
|
|
|
fbinfo->var.blue.length = 5;
|
|
|
|
|
fbinfo->var.transp.length = 0;
|
2007-10-16 01:28:56 -07:00
|
|
|
|
|
|
|
|
|
/* find maximum required memory size for display */
|
|
|
|
|
for (i = 0; i < mach_info->num_displays; i++) {
|
|
|
|
|
unsigned long smem_len = mach_info->displays[i].xres;
|
|
|
|
|
|
|
|
|
|
smem_len *= mach_info->displays[i].yres;
|
|
|
|
|
smem_len *= mach_info->displays[i].bpp;
|
|
|
|
|
smem_len >>= 3;
|
|
|
|
|
if (fbinfo->fix.smem_len < smem_len)
|
|
|
|
|
fbinfo->fix.smem_len = smem_len;
|
|
|
|
|
}
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
|
|
|
|
for (i = 0; i < 256; i++)
|
|
|
|
|
info->palette_buffer[i] = PALETTE_BUFF_CLEAR;
|
|
|
|
|
|
2006-07-01 19:29:45 -07:00
|
|
|
|
ret = request_irq(irq, s3c2410fb_irq, IRQF_DISABLED, pdev->name, info);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
if (ret) {
|
2005-11-09 15:32:44 -07:00
|
|
|
|
dev_err(&pdev->dev, "cannot get irq %d - err %d\n", irq, ret);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
ret = -EBUSY;
|
2007-07-31 00:37:37 -07:00
|
|
|
|
goto release_regs;
|
2005-09-09 13:10:07 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
info->clk = clk_get(NULL, "lcd");
|
|
|
|
|
if (!info->clk || IS_ERR(info->clk)) {
|
|
|
|
|
printk(KERN_ERR "failed to get lcd clock source\n");
|
|
|
|
|
ret = -ENOENT;
|
|
|
|
|
goto release_irq;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
clk_enable(info->clk);
|
|
|
|
|
dprintk("got and enabled clock\n");
|
|
|
|
|
|
|
|
|
|
msleep(1);
|
|
|
|
|
|
|
|
|
|
/* Initialize video memory */
|
2007-10-16 01:28:55 -07:00
|
|
|
|
ret = s3c2410fb_map_video_memory(fbinfo);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
if (ret) {
|
2007-10-16 01:28:54 -07:00
|
|
|
|
printk(KERN_ERR "Failed to allocate video RAM: %d\n", ret);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
ret = -ENOMEM;
|
|
|
|
|
goto release_clock;
|
|
|
|
|
}
|
2007-07-31 00:37:37 -07:00
|
|
|
|
|
2005-09-09 13:10:07 -07:00
|
|
|
|
dprintk("got video memory\n");
|
|
|
|
|
|
2007-10-16 01:28:55 -07:00
|
|
|
|
s3c2410fb_init_registers(fbinfo);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
2007-10-16 01:28:54 -07:00
|
|
|
|
s3c2410fb_check_var(&fbinfo->var, fbinfo);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
|
|
|
|
ret = register_framebuffer(fbinfo);
|
|
|
|
|
if (ret < 0) {
|
2007-10-16 01:28:54 -07:00
|
|
|
|
printk(KERN_ERR "Failed to register framebuffer device: %d\n",
|
|
|
|
|
ret);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
goto free_video_memory;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* create device files */
|
2005-11-09 15:32:44 -07:00
|
|
|
|
device_create_file(&pdev->dev, &dev_attr_debug);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
|
|
|
|
printk(KERN_INFO "fb%d: %s frame buffer device\n",
|
|
|
|
|
fbinfo->node, fbinfo->fix.id);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
free_video_memory:
|
|
|
|
|
s3c2410fb_unmap_video_memory(info);
|
|
|
|
|
release_clock:
|
|
|
|
|
clk_disable(info->clk);
|
|
|
|
|
clk_put(info->clk);
|
|
|
|
|
release_irq:
|
2007-10-16 01:28:54 -07:00
|
|
|
|
free_irq(irq, info);
|
2007-07-31 00:37:37 -07:00
|
|
|
|
release_regs:
|
|
|
|
|
iounmap(info->io);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
release_mem:
|
2007-07-31 00:37:37 -07:00
|
|
|
|
release_resource(info->mem);
|
|
|
|
|
kfree(info->mem);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
dealloc_fb:
|
|
|
|
|
framebuffer_release(fbinfo);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* s3c2410fb_stop_lcd
|
|
|
|
|
*
|
|
|
|
|
* shutdown the lcd controller
|
2007-10-16 01:28:54 -07:00
|
|
|
|
*/
|
2006-06-26 00:26:45 -07:00
|
|
|
|
static void s3c2410fb_stop_lcd(struct s3c2410fb_info *fbi)
|
2005-09-09 13:10:07 -07:00
|
|
|
|
{
|
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
|
|
local_irq_save(flags);
|
|
|
|
|
|
2006-06-26 00:26:45 -07:00
|
|
|
|
fbi->regs.lcdcon1 &= ~S3C2410_LCDCON1_ENVID;
|
2007-07-31 00:37:37 -07:00
|
|
|
|
writel(fbi->regs.lcdcon1, fbi->io + S3C2410_LCDCON1);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
|
|
|
|
local_irq_restore(flags);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Cleanup
|
|
|
|
|
*/
|
2005-11-09 15:32:44 -07:00
|
|
|
|
static int s3c2410fb_remove(struct platform_device *pdev)
|
2005-09-09 13:10:07 -07:00
|
|
|
|
{
|
2007-10-16 01:28:54 -07:00
|
|
|
|
struct fb_info *fbinfo = platform_get_drvdata(pdev);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
struct s3c2410fb_info *info = fbinfo->par;
|
|
|
|
|
int irq;
|
|
|
|
|
|
2006-06-26 00:26:45 -07:00
|
|
|
|
s3c2410fb_stop_lcd(info);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
msleep(1);
|
|
|
|
|
|
|
|
|
|
s3c2410fb_unmap_video_memory(info);
|
|
|
|
|
|
2007-10-16 01:28:54 -07:00
|
|
|
|
if (info->clk) {
|
|
|
|
|
clk_disable(info->clk);
|
|
|
|
|
clk_put(info->clk);
|
|
|
|
|
info->clk = NULL;
|
2005-09-09 13:10:07 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
irq = platform_get_irq(pdev, 0);
|
2007-10-16 01:28:54 -07:00
|
|
|
|
free_irq(irq, info);
|
2007-07-31 00:37:37 -07:00
|
|
|
|
|
|
|
|
|
release_resource(info->mem);
|
|
|
|
|
kfree(info->mem);
|
|
|
|
|
iounmap(info->io);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
unregister_framebuffer(fbinfo);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_PM
|
|
|
|
|
|
|
|
|
|
/* suspend and resume support for the lcd controller */
|
2005-11-09 15:32:44 -07:00
|
|
|
|
static int s3c2410fb_suspend(struct platform_device *dev, pm_message_t state)
|
2005-09-09 13:10:07 -07:00
|
|
|
|
{
|
2005-11-09 15:32:44 -07:00
|
|
|
|
struct fb_info *fbinfo = platform_get_drvdata(dev);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
struct s3c2410fb_info *info = fbinfo->par;
|
|
|
|
|
|
2006-06-26 00:26:45 -07:00
|
|
|
|
s3c2410fb_stop_lcd(info);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
2005-10-28 09:52:56 -07:00
|
|
|
|
/* sleep before disabling the clock, we need to ensure
|
|
|
|
|
* the LCD DMA engine is not going to get back on the bus
|
|
|
|
|
* before the clock goes off again (bjd) */
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
2005-10-28 09:52:56 -07:00
|
|
|
|
msleep(1);
|
|
|
|
|
clk_disable(info->clk);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2005-11-09 15:32:44 -07:00
|
|
|
|
static int s3c2410fb_resume(struct platform_device *dev)
|
2005-09-09 13:10:07 -07:00
|
|
|
|
{
|
2005-11-09 15:32:44 -07:00
|
|
|
|
struct fb_info *fbinfo = platform_get_drvdata(dev);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
struct s3c2410fb_info *info = fbinfo->par;
|
|
|
|
|
|
2005-10-28 09:52:56 -07:00
|
|
|
|
clk_enable(info->clk);
|
|
|
|
|
msleep(1);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
2005-10-28 09:52:56 -07:00
|
|
|
|
s3c2410fb_init_registers(info);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
#define s3c2410fb_suspend NULL
|
|
|
|
|
#define s3c2410fb_resume NULL
|
|
|
|
|
#endif
|
|
|
|
|
|
2005-11-09 15:32:44 -07:00
|
|
|
|
static struct platform_driver s3c2410fb_driver = {
|
2005-09-09 13:10:07 -07:00
|
|
|
|
.probe = s3c2410fb_probe,
|
2005-11-09 15:32:44 -07:00
|
|
|
|
.remove = s3c2410fb_remove,
|
2005-09-09 13:10:07 -07:00
|
|
|
|
.suspend = s3c2410fb_suspend,
|
|
|
|
|
.resume = s3c2410fb_resume,
|
2005-11-09 15:32:44 -07:00
|
|
|
|
.driver = {
|
|
|
|
|
.name = "s3c2410-lcd",
|
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
|
},
|
2005-09-09 13:10:07 -07:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
int __devinit s3c2410fb_init(void)
|
|
|
|
|
{
|
2005-11-09 15:32:44 -07:00
|
|
|
|
return platform_driver_register(&s3c2410fb_driver);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void __exit s3c2410fb_cleanup(void)
|
|
|
|
|
{
|
2005-11-09 15:32:44 -07:00
|
|
|
|
platform_driver_unregister(&s3c2410fb_driver);
|
2005-09-09 13:10:07 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module_init(s3c2410fb_init);
|
|
|
|
|
module_exit(s3c2410fb_cleanup);
|
|
|
|
|
|
2007-10-16 01:28:54 -07:00
|
|
|
|
MODULE_AUTHOR("Arnaud Patard <arnaud.patard@rtp-net.org>, "
|
|
|
|
|
"Ben Dooks <ben-linux@fluff.org>");
|
2005-09-09 13:10:07 -07:00
|
|
|
|
MODULE_DESCRIPTION("Framebuffer driver for the s3c2410");
|
|
|
|
|
MODULE_LICENSE("GPL");
|