16a0e4ec7bcc6e80d2a32a4c0b83a32c904aadc05Ben Dooks/* linux/drivers/video/s3c2410fb.c 26a0e4ec7bcc6e80d2a32a4c0b83a32c904aadc05Ben Dooks * Copyright (c) 2004,2005 Arnaud Patard 36a0e4ec7bcc6e80d2a32a4c0b83a32c904aadc05Ben Dooks * Copyright (c) 2004-2008 Ben Dooks 46a0e4ec7bcc6e80d2a32a4c0b83a32c904aadc05Ben Dooks * 56a0e4ec7bcc6e80d2a32a4c0b83a32c904aadc05Ben Dooks * S3C2410 LCD Framebuffer Driver 620fd5767689124a920c1deb9c380304e082f026cArnaud Patard * 720fd5767689124a920c1deb9c380304e082f026cArnaud Patard * This file is subject to the terms and conditions of the GNU General Public 820fd5767689124a920c1deb9c380304e082f026cArnaud Patard * License. See the file COPYING in the main directory of this archive for 920fd5767689124a920c1deb9c380304e082f026cArnaud Patard * more details. 1020fd5767689124a920c1deb9c380304e082f026cArnaud Patard * 116a0e4ec7bcc6e80d2a32a4c0b83a32c904aadc05Ben Dooks * Driver based on skeletonfb.c, sa1100fb.c and others. 126a0e4ec7bcc6e80d2a32a4c0b83a32c904aadc05Ben Dooks*/ 1320fd5767689124a920c1deb9c380304e082f026cArnaud Patard 1481c1655811e941af24c212c0ac5c27931f91af3bSachin Kamat#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 1581c1655811e941af24c212c0ac5c27931f91af3bSachin Kamat 1620fd5767689124a920c1deb9c380304e082f026cArnaud Patard#include <linux/module.h> 1720fd5767689124a920c1deb9c380304e082f026cArnaud Patard#include <linux/kernel.h> 180b2e9cb42cd0b5b0c95a776e30c9ecdff16587eaJamie Iles#include <linux/err.h> 1920fd5767689124a920c1deb9c380304e082f026cArnaud Patard#include <linux/errno.h> 2020fd5767689124a920c1deb9c380304e082f026cArnaud Patard#include <linux/string.h> 2120fd5767689124a920c1deb9c380304e082f026cArnaud Patard#include <linux/mm.h> 2220fd5767689124a920c1deb9c380304e082f026cArnaud Patard#include <linux/slab.h> 2320fd5767689124a920c1deb9c380304e082f026cArnaud Patard#include <linux/delay.h> 2420fd5767689124a920c1deb9c380304e082f026cArnaud Patard#include <linux/fb.h> 2520fd5767689124a920c1deb9c380304e082f026cArnaud Patard#include <linux/init.h> 2620fd5767689124a920c1deb9c380304e082f026cArnaud Patard#include <linux/dma-mapping.h> 2720fd5767689124a920c1deb9c380304e082f026cArnaud Patard#include <linux/interrupt.h> 28d052d1beff706920e82c5d55006b08e256b5df09Russell King#include <linux/platform_device.h> 29f8ce25476d5f12ffa29b885e49c38cd95053437eRussell King#include <linux/clk.h> 300dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks#include <linux/cpufreq.h> 31f940b88d3a57594289455ea99a93a8ddc5c4af06Jingoo Han#include <linux/io.h> 3220fd5767689124a920c1deb9c380304e082f026cArnaud Patard 3320fd5767689124a920c1deb9c380304e082f026cArnaud Patard#include <asm/div64.h> 3420fd5767689124a920c1deb9c380304e082f026cArnaud Patard 3520fd5767689124a920c1deb9c380304e082f026cArnaud Patard#include <asm/mach/map.h> 36a09e64fbc0094e3073dbb09c3b4bfe4ab669244bRussell King#include <mach/regs-lcd.h> 37a09e64fbc0094e3073dbb09c3b4bfe4ab669244bRussell King#include <mach/regs-gpio.h> 38a09e64fbc0094e3073dbb09c3b4bfe4ab669244bRussell King#include <mach/fb.h> 3920fd5767689124a920c1deb9c380304e082f026cArnaud Patard 4020fd5767689124a920c1deb9c380304e082f026cArnaud Patard#ifdef CONFIG_PM 4120fd5767689124a920c1deb9c380304e082f026cArnaud Patard#include <linux/pm.h> 4220fd5767689124a920c1deb9c380304e082f026cArnaud Patard#endif 4320fd5767689124a920c1deb9c380304e082f026cArnaud Patard 4420fd5767689124a920c1deb9c380304e082f026cArnaud Patard#include "s3c2410fb.h" 4520fd5767689124a920c1deb9c380304e082f026cArnaud Patard 4620fd5767689124a920c1deb9c380304e082f026cArnaud Patard/* Debugging stuff */ 4720fd5767689124a920c1deb9c380304e082f026cArnaud Patard#ifdef CONFIG_FB_S3C2410_DEBUG 48b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Heltstatic int debug = 1; 4920fd5767689124a920c1deb9c380304e082f026cArnaud Patard#else 50f940b88d3a57594289455ea99a93a8ddc5c4af06Jingoo Hanstatic int debug; 5120fd5767689124a920c1deb9c380304e082f026cArnaud Patard#endif 5220fd5767689124a920c1deb9c380304e082f026cArnaud Patard 5381c1655811e941af24c212c0ac5c27931f91af3bSachin Kamat#define dprintk(msg...) \ 5481c1655811e941af24c212c0ac5c27931f91af3bSachin Kamatdo { \ 5581c1655811e941af24c212c0ac5c27931f91af3bSachin Kamat if (debug) \ 5681c1655811e941af24c212c0ac5c27931f91af3bSachin Kamat pr_debug(msg); \ 5781c1655811e941af24c212c0ac5c27931f91af3bSachin Kamat} while (0) 5820fd5767689124a920c1deb9c380304e082f026cArnaud Patard 5920fd5767689124a920c1deb9c380304e082f026cArnaud Patard/* useful functions */ 6020fd5767689124a920c1deb9c380304e082f026cArnaud Patard 61f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooksstatic int is_s3c2412(struct s3c2410fb_info *fbi) 62f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks{ 63f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks return (fbi->drv_type == DRV_S3C2412); 64f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks} 65f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks 6620fd5767689124a920c1deb9c380304e082f026cArnaud Patard/* s3c2410fb_set_lcdaddr 6720fd5767689124a920c1deb9c380304e082f026cArnaud Patard * 6820fd5767689124a920c1deb9c380304e082f026cArnaud Patard * initialise lcd controller address pointers 69b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt */ 70110c1fa75463c4f327e9fc491e9a27e938800d96Krzysztof Heltstatic void s3c2410fb_set_lcdaddr(struct fb_info *info) 7120fd5767689124a920c1deb9c380304e082f026cArnaud Patard{ 7220fd5767689124a920c1deb9c380304e082f026cArnaud Patard unsigned long saddr1, saddr2, saddr3; 737ee0fe41c3c4670ccea8ea180d178d2de3a46445Krzysztof Helt struct s3c2410fb_info *fbi = info->par; 747ee0fe41c3c4670ccea8ea180d178d2de3a46445Krzysztof Helt void __iomem *regs = fbi->io; 7520fd5767689124a920c1deb9c380304e082f026cArnaud Patard 76110c1fa75463c4f327e9fc491e9a27e938800d96Krzysztof Helt saddr1 = info->fix.smem_start >> 1; 77110c1fa75463c4f327e9fc491e9a27e938800d96Krzysztof Helt saddr2 = info->fix.smem_start; 789fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt saddr2 += info->fix.line_length * info->var.yres; 79b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt saddr2 >>= 1; 8020fd5767689124a920c1deb9c380304e082f026cArnaud Patard 81b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt saddr3 = S3C2410_OFFSIZE(0) | 829fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt S3C2410_PAGEWIDTH((info->fix.line_length / 2) & 0x3ff); 8320fd5767689124a920c1deb9c380304e082f026cArnaud Patard 8420fd5767689124a920c1deb9c380304e082f026cArnaud Patard dprintk("LCDSADDR1 = 0x%08lx\n", saddr1); 8520fd5767689124a920c1deb9c380304e082f026cArnaud Patard dprintk("LCDSADDR2 = 0x%08lx\n", saddr2); 8620fd5767689124a920c1deb9c380304e082f026cArnaud Patard dprintk("LCDSADDR3 = 0x%08lx\n", saddr3); 8720fd5767689124a920c1deb9c380304e082f026cArnaud Patard 887ee0fe41c3c4670ccea8ea180d178d2de3a46445Krzysztof Helt writel(saddr1, regs + S3C2410_LCDSADDR1); 897ee0fe41c3c4670ccea8ea180d178d2de3a46445Krzysztof Helt writel(saddr2, regs + S3C2410_LCDSADDR2); 907ee0fe41c3c4670ccea8ea180d178d2de3a46445Krzysztof Helt writel(saddr3, regs + S3C2410_LCDSADDR3); 9120fd5767689124a920c1deb9c380304e082f026cArnaud Patard} 9220fd5767689124a920c1deb9c380304e082f026cArnaud Patard 9320fd5767689124a920c1deb9c380304e082f026cArnaud Patard/* s3c2410fb_calc_pixclk() 9420fd5767689124a920c1deb9c380304e082f026cArnaud Patard * 9520fd5767689124a920c1deb9c380304e082f026cArnaud Patard * calculate divisor for clk->pixclk 96b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt */ 9720fd5767689124a920c1deb9c380304e082f026cArnaud Patardstatic unsigned int s3c2410fb_calc_pixclk(struct s3c2410fb_info *fbi, 9820fd5767689124a920c1deb9c380304e082f026cArnaud Patard unsigned long pixclk) 9920fd5767689124a920c1deb9c380304e082f026cArnaud Patard{ 1000dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks unsigned long clk = fbi->clk_rate; 10120fd5767689124a920c1deb9c380304e082f026cArnaud Patard unsigned long long div; 10220fd5767689124a920c1deb9c380304e082f026cArnaud Patard 1039fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt /* pixclk is in picoseconds, our clock is in Hz 10420fd5767689124a920c1deb9c380304e082f026cArnaud Patard * 10520fd5767689124a920c1deb9c380304e082f026cArnaud Patard * Hz -> picoseconds is / 10^-12 10620fd5767689124a920c1deb9c380304e082f026cArnaud Patard */ 10720fd5767689124a920c1deb9c380304e082f026cArnaud Patard 10820fd5767689124a920c1deb9c380304e082f026cArnaud Patard div = (unsigned long long)clk * pixclk; 1099fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt div >>= 12; /* div / 2^12 */ 1109fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt do_div(div, 625 * 625UL * 625); /* div / 5^12 */ 11120fd5767689124a920c1deb9c380304e082f026cArnaud Patard 11220fd5767689124a920c1deb9c380304e082f026cArnaud Patard dprintk("pixclk %ld, divisor is %ld\n", pixclk, (long)div); 11320fd5767689124a920c1deb9c380304e082f026cArnaud Patard return div; 11420fd5767689124a920c1deb9c380304e082f026cArnaud Patard} 11520fd5767689124a920c1deb9c380304e082f026cArnaud Patard 11620fd5767689124a920c1deb9c380304e082f026cArnaud Patard/* 11720fd5767689124a920c1deb9c380304e082f026cArnaud Patard * s3c2410fb_check_var(): 11820fd5767689124a920c1deb9c380304e082f026cArnaud Patard * Get the video params out of 'var'. If a value doesn't fit, round it up, 11920fd5767689124a920c1deb9c380304e082f026cArnaud Patard * if it's too big, return -EINVAL. 12020fd5767689124a920c1deb9c380304e082f026cArnaud Patard * 12120fd5767689124a920c1deb9c380304e082f026cArnaud Patard */ 12220fd5767689124a920c1deb9c380304e082f026cArnaud Patardstatic int s3c2410fb_check_var(struct fb_var_screeninfo *var, 12320fd5767689124a920c1deb9c380304e082f026cArnaud Patard struct fb_info *info) 12420fd5767689124a920c1deb9c380304e082f026cArnaud Patard{ 12520fd5767689124a920c1deb9c380304e082f026cArnaud Patard struct s3c2410fb_info *fbi = info->par; 1261df86cdaee3acc9b7e72855870eccaecbff336e6Jingoo Han struct s3c2410fb_mach_info *mach_info = dev_get_platdata(fbi->dev); 12709fe75f6f934597f765748342ca6fb378ee7ecdbKrzysztof Helt struct s3c2410fb_display *display = NULL; 128e7076389f48128b00dd3f33767fb60bd3f5a06a8Krzysztof Helt struct s3c2410fb_display *default_display = mach_info->displays + 129e7076389f48128b00dd3f33767fb60bd3f5a06a8Krzysztof Helt mach_info->default_display; 130e7076389f48128b00dd3f33767fb60bd3f5a06a8Krzysztof Helt int type = default_display->type; 13109fe75f6f934597f765748342ca6fb378ee7ecdbKrzysztof Helt unsigned i; 13220fd5767689124a920c1deb9c380304e082f026cArnaud Patard 13320fd5767689124a920c1deb9c380304e082f026cArnaud Patard dprintk("check_var(var=%p, info=%p)\n", var, info); 13420fd5767689124a920c1deb9c380304e082f026cArnaud Patard 13520fd5767689124a920c1deb9c380304e082f026cArnaud Patard /* validate x/y resolution */ 136e7076389f48128b00dd3f33767fb60bd3f5a06a8Krzysztof Helt /* choose default mode if possible */ 137e7076389f48128b00dd3f33767fb60bd3f5a06a8Krzysztof Helt if (var->yres == default_display->yres && 138e7076389f48128b00dd3f33767fb60bd3f5a06a8Krzysztof Helt var->xres == default_display->xres && 139e7076389f48128b00dd3f33767fb60bd3f5a06a8Krzysztof Helt var->bits_per_pixel == default_display->bpp) 140e7076389f48128b00dd3f33767fb60bd3f5a06a8Krzysztof Helt display = default_display; 141e7076389f48128b00dd3f33767fb60bd3f5a06a8Krzysztof Helt else 142e7076389f48128b00dd3f33767fb60bd3f5a06a8Krzysztof Helt for (i = 0; i < mach_info->num_displays; i++) 143e7076389f48128b00dd3f33767fb60bd3f5a06a8Krzysztof Helt if (type == mach_info->displays[i].type && 144e7076389f48128b00dd3f33767fb60bd3f5a06a8Krzysztof Helt var->yres == mach_info->displays[i].yres && 145e7076389f48128b00dd3f33767fb60bd3f5a06a8Krzysztof Helt var->xres == mach_info->displays[i].xres && 146e7076389f48128b00dd3f33767fb60bd3f5a06a8Krzysztof Helt var->bits_per_pixel == mach_info->displays[i].bpp) { 147e7076389f48128b00dd3f33767fb60bd3f5a06a8Krzysztof Helt display = mach_info->displays + i; 148e7076389f48128b00dd3f33767fb60bd3f5a06a8Krzysztof Helt break; 149e7076389f48128b00dd3f33767fb60bd3f5a06a8Krzysztof Helt } 15020fd5767689124a920c1deb9c380304e082f026cArnaud Patard 15109fe75f6f934597f765748342ca6fb378ee7ecdbKrzysztof Helt if (!display) { 15209fe75f6f934597f765748342ca6fb378ee7ecdbKrzysztof Helt dprintk("wrong resolution or depth %dx%d at %d bpp\n", 15309fe75f6f934597f765748342ca6fb378ee7ecdbKrzysztof Helt var->xres, var->yres, var->bits_per_pixel); 15409fe75f6f934597f765748342ca6fb378ee7ecdbKrzysztof Helt return -EINVAL; 15509fe75f6f934597f765748342ca6fb378ee7ecdbKrzysztof Helt } 15620fd5767689124a920c1deb9c380304e082f026cArnaud Patard 1579939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt /* it is always the size as the display */ 1589939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt var->xres_virtual = display->xres; 1599939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt var->yres_virtual = display->yres; 1609fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt var->height = display->height; 1619fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt var->width = display->width; 1629939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt 1639939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt /* copy lcd settings */ 16469816699fa019145dd163949d65a07093af73b67Krzysztof Helt var->pixclock = display->pixclock; 1659939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt var->left_margin = display->left_margin; 1669939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt var->right_margin = display->right_margin; 1679fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt var->upper_margin = display->upper_margin; 1689fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt var->lower_margin = display->lower_margin; 1699fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt var->vsync_len = display->vsync_len; 1709fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt var->hsync_len = display->hsync_len; 1719fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt 1729fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt fbi->regs.lcdcon5 = display->lcdcon5; 1739fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt /* set display type */ 17436f31a7084b8d20ced37afe92238c18ba769cdf3Krzysztof Helt fbi->regs.lcdcon1 = display->type; 1759939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt 176b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt var->transp.offset = 0; 177b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt var->transp.length = 0; 17820fd5767689124a920c1deb9c380304e082f026cArnaud Patard /* set r/g/b positions */ 179357b819dda03e642f9c2d737596ad6cdc0022c00Arnaud Patard switch (var->bits_per_pixel) { 180b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt case 1: 181b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt case 2: 182b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt case 4: 183b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt var->red.offset = 0; 184b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt var->red.length = var->bits_per_pixel; 185b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt var->green = var->red; 186b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt var->blue = var->red; 187b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt break; 188b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt case 8: 18909fe75f6f934597f765748342ca6fb378ee7ecdbKrzysztof Helt if (display->type != S3C2410_LCDCON1_TFT) { 190b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt /* 8 bpp 332 */ 191b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt var->red.length = 3; 192b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt var->red.offset = 5; 193b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt var->green.length = 3; 194b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt var->green.offset = 2; 195b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt var->blue.length = 2; 196357b819dda03e642f9c2d737596ad6cdc0022c00Arnaud Patard var->blue.offset = 0; 197b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt } else { 198b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt var->red.offset = 0; 199357b819dda03e642f9c2d737596ad6cdc0022c00Arnaud Patard var->red.length = 8; 200b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt var->green = var->red; 201b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt var->blue = var->red; 202b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt } 203b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt break; 204b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt case 12: 205b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt /* 12 bpp 444 */ 206b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt var->red.length = 4; 207b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt var->red.offset = 8; 208b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt var->green.length = 4; 209b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt var->green.offset = 4; 210b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt var->blue.length = 4; 211b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt var->blue.offset = 0; 212b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt break; 213b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt 214b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt default: 215b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt case 16: 216f28ef573ad09596b771b67c276bbc5f49281fa9dKrzysztof Helt if (display->lcdcon5 & S3C2410_LCDCON5_FRM565) { 217b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt /* 16 bpp, 565 format */ 218b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt var->red.offset = 11; 219b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt var->green.offset = 5; 220357b819dda03e642f9c2d737596ad6cdc0022c00Arnaud Patard var->blue.offset = 0; 221b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt var->red.length = 5; 222b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt var->green.length = 6; 223b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt var->blue.length = 5; 224b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt } else { 225b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt /* 16 bpp, 5551 format */ 226b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt var->red.offset = 11; 227b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt var->green.offset = 6; 228b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt var->blue.offset = 1; 229b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt var->red.length = 5; 230b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt var->green.length = 5; 231b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt var->blue.length = 5; 232b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt } 233b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt break; 23493613b9fbea6e636d3af51c71fc1b9b2e7d4fb0cKrzysztof Helt case 32: 23593613b9fbea6e636d3af51c71fc1b9b2e7d4fb0cKrzysztof Helt /* 24 bpp 888 and 8 dummy */ 236b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt var->red.length = 8; 237b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt var->red.offset = 16; 238b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt var->green.length = 8; 239b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt var->green.offset = 8; 240b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt var->blue.length = 8; 241b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt var->blue.offset = 0; 242b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt break; 243357b819dda03e642f9c2d737596ad6cdc0022c00Arnaud Patard } 24420fd5767689124a920c1deb9c380304e082f026cArnaud Patard return 0; 24520fd5767689124a920c1deb9c380304e082f026cArnaud Patard} 24620fd5767689124a920c1deb9c380304e082f026cArnaud Patard 2479939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt/* s3c2410fb_calculate_stn_lcd_regs 24820fd5767689124a920c1deb9c380304e082f026cArnaud Patard * 2499939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt * calculate register values from var settings 250b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt */ 2519939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Heltstatic void s3c2410fb_calculate_stn_lcd_regs(const struct fb_info *info, 2529939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt struct s3c2410fb_hw *regs) 25320fd5767689124a920c1deb9c380304e082f026cArnaud Patard{ 2549939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt const struct s3c2410fb_info *fbi = info->par; 2559939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt const struct fb_var_screeninfo *var = &info->var; 2569939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt int type = regs->lcdcon1 & ~S3C2410_LCDCON1_TFT; 2579939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt int hs = var->xres >> 2; 2589939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt unsigned wdly = (var->left_margin >> 4) - 1; 25993d11f5a15020a514e522e678b2b3e7a1bc01f86Krzysztof Helt unsigned wlh = (var->hsync_len >> 4) - 1; 26020fd5767689124a920c1deb9c380304e082f026cArnaud Patard 2619939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt if (type != S3C2410_LCDCON1_STN4) 2629939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt hs >>= 1; 263357b819dda03e642f9c2d737596ad6cdc0022c00Arnaud Patard 2649939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt switch (var->bits_per_pixel) { 2659939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt case 1: 2669939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt regs->lcdcon1 |= S3C2410_LCDCON1_STN1BPP; 2679939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt break; 2689939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt case 2: 2699939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt regs->lcdcon1 |= S3C2410_LCDCON1_STN2GREY; 2709939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt break; 2719939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt case 4: 2729939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt regs->lcdcon1 |= S3C2410_LCDCON1_STN4GREY; 2739939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt break; 2749939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt case 8: 2759939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt regs->lcdcon1 |= S3C2410_LCDCON1_STN8BPP; 2769939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt hs *= 3; 2779939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt break; 2789939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt case 12: 2799939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt regs->lcdcon1 |= S3C2410_LCDCON1_STN12BPP; 2809939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt hs *= 3; 2819939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt break; 28220fd5767689124a920c1deb9c380304e082f026cArnaud Patard 2839939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt default: 2849939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt /* invalid pixel depth */ 2859939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt dev_err(fbi->dev, "invalid bpp %d\n", 2869939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt var->bits_per_pixel); 2879939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt } 2889939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt /* update X/Y info */ 2899939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt dprintk("setting horz: lft=%d, rt=%d, sync=%d\n", 2909939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt var->left_margin, var->right_margin, var->hsync_len); 29120fd5767689124a920c1deb9c380304e082f026cArnaud Patard 2923c9ffd0501157b38599b5bb7711366913f633f88Krzysztof Helt regs->lcdcon2 = S3C2410_LCDCON2_LINEVAL(var->yres - 1); 29320fd5767689124a920c1deb9c380304e082f026cArnaud Patard 2949939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt if (wdly > 3) 2959939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt wdly = 3; 29620fd5767689124a920c1deb9c380304e082f026cArnaud Patard 29793d11f5a15020a514e522e678b2b3e7a1bc01f86Krzysztof Helt if (wlh > 3) 29893d11f5a15020a514e522e678b2b3e7a1bc01f86Krzysztof Helt wlh = 3; 29993d11f5a15020a514e522e678b2b3e7a1bc01f86Krzysztof Helt 3009939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt regs->lcdcon3 = S3C2410_LCDCON3_WDLY(wdly) | 3019939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt S3C2410_LCDCON3_LINEBLANK(var->right_margin / 8) | 3029939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt S3C2410_LCDCON3_HOZVAL(hs - 1); 30393d11f5a15020a514e522e678b2b3e7a1bc01f86Krzysztof Helt 304e92e739514baed2be83cfb269db003c73dd885c2Krzysztof Helt regs->lcdcon4 = S3C2410_LCDCON4_WLH(wlh); 3059939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt} 30620fd5767689124a920c1deb9c380304e082f026cArnaud Patard 3079939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt/* s3c2410fb_calculate_tft_lcd_regs 3089939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt * 3099939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt * calculate register values from var settings 3109939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt */ 3119939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Heltstatic void s3c2410fb_calculate_tft_lcd_regs(const struct fb_info *info, 3129939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt struct s3c2410fb_hw *regs) 3139939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt{ 3149939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt const struct s3c2410fb_info *fbi = info->par; 3159939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt const struct fb_var_screeninfo *var = &info->var; 31620fd5767689124a920c1deb9c380304e082f026cArnaud Patard 3179939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt switch (var->bits_per_pixel) { 3189939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt case 1: 3199939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt regs->lcdcon1 |= S3C2410_LCDCON1_TFT1BPP; 3209939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt break; 3219939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt case 2: 3229939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt regs->lcdcon1 |= S3C2410_LCDCON1_TFT2BPP; 323b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt break; 3249939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt case 4: 3259939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt regs->lcdcon1 |= S3C2410_LCDCON1_TFT4BPP; 326b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt break; 3279939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt case 8: 3289939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt regs->lcdcon1 |= S3C2410_LCDCON1_TFT8BPP; 32993613b9fbea6e636d3af51c71fc1b9b2e7d4fb0cKrzysztof Helt regs->lcdcon5 |= S3C2410_LCDCON5_BSWP | 33093613b9fbea6e636d3af51c71fc1b9b2e7d4fb0cKrzysztof Helt S3C2410_LCDCON5_FRM565; 33193613b9fbea6e636d3af51c71fc1b9b2e7d4fb0cKrzysztof Helt regs->lcdcon5 &= ~S3C2410_LCDCON5_HWSWP; 3329939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt break; 3339939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt case 16: 3349939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt regs->lcdcon1 |= S3C2410_LCDCON1_TFT16BPP; 33593613b9fbea6e636d3af51c71fc1b9b2e7d4fb0cKrzysztof Helt regs->lcdcon5 &= ~S3C2410_LCDCON5_BSWP; 33693613b9fbea6e636d3af51c71fc1b9b2e7d4fb0cKrzysztof Helt regs->lcdcon5 |= S3C2410_LCDCON5_HWSWP; 33793613b9fbea6e636d3af51c71fc1b9b2e7d4fb0cKrzysztof Helt break; 33893613b9fbea6e636d3af51c71fc1b9b2e7d4fb0cKrzysztof Helt case 32: 33993613b9fbea6e636d3af51c71fc1b9b2e7d4fb0cKrzysztof Helt regs->lcdcon1 |= S3C2410_LCDCON1_TFT24BPP; 34093613b9fbea6e636d3af51c71fc1b9b2e7d4fb0cKrzysztof Helt regs->lcdcon5 &= ~(S3C2410_LCDCON5_BSWP | 34193613b9fbea6e636d3af51c71fc1b9b2e7d4fb0cKrzysztof Helt S3C2410_LCDCON5_HWSWP | 34293613b9fbea6e636d3af51c71fc1b9b2e7d4fb0cKrzysztof Helt S3C2410_LCDCON5_BPP24BL); 343b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt break; 3449939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt default: 3459939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt /* invalid pixel depth */ 3469939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt dev_err(fbi->dev, "invalid bpp %d\n", 3479939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt var->bits_per_pixel); 348357b819dda03e642f9c2d737596ad6cdc0022c00Arnaud Patard } 3499939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt /* update X/Y info */ 3509939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt dprintk("setting vert: up=%d, low=%d, sync=%d\n", 3519939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt var->upper_margin, var->lower_margin, var->vsync_len); 352357b819dda03e642f9c2d737596ad6cdc0022c00Arnaud Patard 3539939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt dprintk("setting horz: lft=%d, rt=%d, sync=%d\n", 3549939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt var->left_margin, var->right_margin, var->hsync_len); 355357b819dda03e642f9c2d737596ad6cdc0022c00Arnaud Patard 35693d11f5a15020a514e522e678b2b3e7a1bc01f86Krzysztof Helt regs->lcdcon2 = S3C2410_LCDCON2_LINEVAL(var->yres - 1) | 35793d11f5a15020a514e522e678b2b3e7a1bc01f86Krzysztof Helt S3C2410_LCDCON2_VBPD(var->upper_margin - 1) | 35893d11f5a15020a514e522e678b2b3e7a1bc01f86Krzysztof Helt S3C2410_LCDCON2_VFPD(var->lower_margin - 1) | 35993d11f5a15020a514e522e678b2b3e7a1bc01f86Krzysztof Helt S3C2410_LCDCON2_VSPW(var->vsync_len - 1); 3609939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt 3619939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt regs->lcdcon3 = S3C2410_LCDCON3_HBPD(var->right_margin - 1) | 3629939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt S3C2410_LCDCON3_HFPD(var->left_margin - 1) | 3639939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt S3C2410_LCDCON3_HOZVAL(var->xres - 1); 36493d11f5a15020a514e522e678b2b3e7a1bc01f86Krzysztof Helt 365e92e739514baed2be83cfb269db003c73dd885c2Krzysztof Helt regs->lcdcon4 = S3C2410_LCDCON4_HSPW(var->hsync_len - 1); 3669939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt} 3679939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt 3689939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt/* s3c2410fb_activate_var 3699939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt * 3709939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt * activate (set) the controller from the given framebuffer 3719939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt * information 3729939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt */ 3739939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Heltstatic void s3c2410fb_activate_var(struct fb_info *info) 3749939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt{ 3759939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt struct s3c2410fb_info *fbi = info->par; 3767ee0fe41c3c4670ccea8ea180d178d2de3a46445Krzysztof Helt void __iomem *regs = fbi->io; 3779fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt int type = fbi->regs.lcdcon1 & S3C2410_LCDCON1_TFT; 3789939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt struct fb_var_screeninfo *var = &info->var; 379360fa58828784f307c3977d5ff4c8e400f074a56Ben Dooks int clkdiv; 380360fa58828784f307c3977d5ff4c8e400f074a56Ben Dooks 381360fa58828784f307c3977d5ff4c8e400f074a56Ben Dooks clkdiv = DIV_ROUND_UP(s3c2410fb_calc_pixclk(fbi, var->pixclock), 2); 3829939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt 3835ae121705bed9ea7425daef4d7d29038f7312f3fHarvey Harrison dprintk("%s: var->xres = %d\n", __func__, var->xres); 3845ae121705bed9ea7425daef4d7d29038f7312f3fHarvey Harrison dprintk("%s: var->yres = %d\n", __func__, var->yres); 3855ae121705bed9ea7425daef4d7d29038f7312f3fHarvey Harrison dprintk("%s: var->bpp = %d\n", __func__, var->bits_per_pixel); 38620fd5767689124a920c1deb9c380304e082f026cArnaud Patard 38769816699fa019145dd163949d65a07093af73b67Krzysztof Helt if (type == S3C2410_LCDCON1_TFT) { 3889939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt s3c2410fb_calculate_tft_lcd_regs(info, &fbi->regs); 38969816699fa019145dd163949d65a07093af73b67Krzysztof Helt --clkdiv; 39069816699fa019145dd163949d65a07093af73b67Krzysztof Helt if (clkdiv < 0) 39169816699fa019145dd163949d65a07093af73b67Krzysztof Helt clkdiv = 0; 39269816699fa019145dd163949d65a07093af73b67Krzysztof Helt } else { 3939939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt s3c2410fb_calculate_stn_lcd_regs(info, &fbi->regs); 39469816699fa019145dd163949d65a07093af73b67Krzysztof Helt if (clkdiv < 2) 39569816699fa019145dd163949d65a07093af73b67Krzysztof Helt clkdiv = 2; 39669816699fa019145dd163949d65a07093af73b67Krzysztof Helt } 39769816699fa019145dd163949d65a07093af73b67Krzysztof Helt 39869816699fa019145dd163949d65a07093af73b67Krzysztof Helt fbi->regs.lcdcon1 |= S3C2410_LCDCON1_CLKVAL(clkdiv); 3999939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt 40020fd5767689124a920c1deb9c380304e082f026cArnaud Patard /* write new registers */ 40120fd5767689124a920c1deb9c380304e082f026cArnaud Patard 40220fd5767689124a920c1deb9c380304e082f026cArnaud Patard dprintk("new register set:\n"); 40320fd5767689124a920c1deb9c380304e082f026cArnaud Patard dprintk("lcdcon[1] = 0x%08lx\n", fbi->regs.lcdcon1); 40420fd5767689124a920c1deb9c380304e082f026cArnaud Patard dprintk("lcdcon[2] = 0x%08lx\n", fbi->regs.lcdcon2); 40520fd5767689124a920c1deb9c380304e082f026cArnaud Patard dprintk("lcdcon[3] = 0x%08lx\n", fbi->regs.lcdcon3); 40620fd5767689124a920c1deb9c380304e082f026cArnaud Patard dprintk("lcdcon[4] = 0x%08lx\n", fbi->regs.lcdcon4); 40720fd5767689124a920c1deb9c380304e082f026cArnaud Patard dprintk("lcdcon[5] = 0x%08lx\n", fbi->regs.lcdcon5); 40820fd5767689124a920c1deb9c380304e082f026cArnaud Patard 4097ee0fe41c3c4670ccea8ea180d178d2de3a46445Krzysztof Helt writel(fbi->regs.lcdcon1 & ~S3C2410_LCDCON1_ENVID, 4107ee0fe41c3c4670ccea8ea180d178d2de3a46445Krzysztof Helt regs + S3C2410_LCDCON1); 4117ee0fe41c3c4670ccea8ea180d178d2de3a46445Krzysztof Helt writel(fbi->regs.lcdcon2, regs + S3C2410_LCDCON2); 4127ee0fe41c3c4670ccea8ea180d178d2de3a46445Krzysztof Helt writel(fbi->regs.lcdcon3, regs + S3C2410_LCDCON3); 4137ee0fe41c3c4670ccea8ea180d178d2de3a46445Krzysztof Helt writel(fbi->regs.lcdcon4, regs + S3C2410_LCDCON4); 4147ee0fe41c3c4670ccea8ea180d178d2de3a46445Krzysztof Helt writel(fbi->regs.lcdcon5, regs + S3C2410_LCDCON5); 41520fd5767689124a920c1deb9c380304e082f026cArnaud Patard 41620fd5767689124a920c1deb9c380304e082f026cArnaud Patard /* set lcd address pointers */ 417110c1fa75463c4f327e9fc491e9a27e938800d96Krzysztof Helt s3c2410fb_set_lcdaddr(info); 41820fd5767689124a920c1deb9c380304e082f026cArnaud Patard 4199fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt fbi->regs.lcdcon1 |= S3C2410_LCDCON1_ENVID, 4207ee0fe41c3c4670ccea8ea180d178d2de3a46445Krzysztof Helt writel(fbi->regs.lcdcon1, regs + S3C2410_LCDCON1); 42120fd5767689124a920c1deb9c380304e082f026cArnaud Patard} 42220fd5767689124a920c1deb9c380304e082f026cArnaud Patard 42320fd5767689124a920c1deb9c380304e082f026cArnaud Patard/* 424b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt * s3c2410fb_set_par - Alters the hardware state. 42520fd5767689124a920c1deb9c380304e082f026cArnaud Patard * @info: frame buffer structure that represents a single frame buffer 42620fd5767689124a920c1deb9c380304e082f026cArnaud Patard * 42720fd5767689124a920c1deb9c380304e082f026cArnaud Patard */ 42820fd5767689124a920c1deb9c380304e082f026cArnaud Patardstatic int s3c2410fb_set_par(struct fb_info *info) 42920fd5767689124a920c1deb9c380304e082f026cArnaud Patard{ 43020fd5767689124a920c1deb9c380304e082f026cArnaud Patard struct fb_var_screeninfo *var = &info->var; 43120fd5767689124a920c1deb9c380304e082f026cArnaud Patard 432b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt switch (var->bits_per_pixel) { 43393613b9fbea6e636d3af51c71fc1b9b2e7d4fb0cKrzysztof Helt case 32: 434b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt case 16: 43593613b9fbea6e636d3af51c71fc1b9b2e7d4fb0cKrzysztof Helt case 12: 436b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt info->fix.visual = FB_VISUAL_TRUECOLOR; 437b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt break; 438b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt case 1: 439b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt info->fix.visual = FB_VISUAL_MONO01; 440b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt break; 441b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt default: 442b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt info->fix.visual = FB_VISUAL_PSEUDOCOLOR; 443b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt break; 444357b819dda03e642f9c2d737596ad6cdc0022c00Arnaud Patard } 44520fd5767689124a920c1deb9c380304e082f026cArnaud Patard 446a10336043b8193ec603ad54bb79cdcd26bbf94b3Stefan Schmidt info->fix.line_length = (var->xres_virtual * var->bits_per_pixel) / 8; 44720fd5767689124a920c1deb9c380304e082f026cArnaud Patard 44820fd5767689124a920c1deb9c380304e082f026cArnaud Patard /* activate this new configuration */ 44920fd5767689124a920c1deb9c380304e082f026cArnaud Patard 4509939a481cd66a109e4ad09328df1bd0540e0aa84Krzysztof Helt s3c2410fb_activate_var(info); 45120fd5767689124a920c1deb9c380304e082f026cArnaud Patard return 0; 45220fd5767689124a920c1deb9c380304e082f026cArnaud Patard} 45320fd5767689124a920c1deb9c380304e082f026cArnaud Patard 45420fd5767689124a920c1deb9c380304e082f026cArnaud Patardstatic void schedule_palette_update(struct s3c2410fb_info *fbi, 45520fd5767689124a920c1deb9c380304e082f026cArnaud Patard unsigned int regno, unsigned int val) 45620fd5767689124a920c1deb9c380304e082f026cArnaud Patard{ 45720fd5767689124a920c1deb9c380304e082f026cArnaud Patard unsigned long flags; 45820fd5767689124a920c1deb9c380304e082f026cArnaud Patard unsigned long irqen; 459f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks void __iomem *irq_base = fbi->irq_base; 46020fd5767689124a920c1deb9c380304e082f026cArnaud Patard 46120fd5767689124a920c1deb9c380304e082f026cArnaud Patard local_irq_save(flags); 46220fd5767689124a920c1deb9c380304e082f026cArnaud Patard 46320fd5767689124a920c1deb9c380304e082f026cArnaud Patard fbi->palette_buffer[regno] = val; 46420fd5767689124a920c1deb9c380304e082f026cArnaud Patard 46520fd5767689124a920c1deb9c380304e082f026cArnaud Patard if (!fbi->palette_ready) { 46620fd5767689124a920c1deb9c380304e082f026cArnaud Patard fbi->palette_ready = 1; 46720fd5767689124a920c1deb9c380304e082f026cArnaud Patard 46820fd5767689124a920c1deb9c380304e082f026cArnaud Patard /* enable IRQ */ 469f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks irqen = readl(irq_base + S3C24XX_LCDINTMSK); 47020fd5767689124a920c1deb9c380304e082f026cArnaud Patard irqen &= ~S3C2410_LCDINT_FRSYNC; 471f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks writel(irqen, irq_base + S3C24XX_LCDINTMSK); 47220fd5767689124a920c1deb9c380304e082f026cArnaud Patard } 47320fd5767689124a920c1deb9c380304e082f026cArnaud Patard 47420fd5767689124a920c1deb9c380304e082f026cArnaud Patard local_irq_restore(flags); 47520fd5767689124a920c1deb9c380304e082f026cArnaud Patard} 47620fd5767689124a920c1deb9c380304e082f026cArnaud Patard 47720fd5767689124a920c1deb9c380304e082f026cArnaud Patard/* from pxafb.c */ 478b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Heltstatic inline unsigned int chan_to_field(unsigned int chan, 479b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt struct fb_bitfield *bf) 48020fd5767689124a920c1deb9c380304e082f026cArnaud Patard{ 48120fd5767689124a920c1deb9c380304e082f026cArnaud Patard chan &= 0xffff; 48220fd5767689124a920c1deb9c380304e082f026cArnaud Patard chan >>= 16 - bf->length; 48320fd5767689124a920c1deb9c380304e082f026cArnaud Patard return chan << bf->offset; 48420fd5767689124a920c1deb9c380304e082f026cArnaud Patard} 48520fd5767689124a920c1deb9c380304e082f026cArnaud Patard 48620fd5767689124a920c1deb9c380304e082f026cArnaud Patardstatic int s3c2410fb_setcolreg(unsigned regno, 48720fd5767689124a920c1deb9c380304e082f026cArnaud Patard unsigned red, unsigned green, unsigned blue, 48820fd5767689124a920c1deb9c380304e082f026cArnaud Patard unsigned transp, struct fb_info *info) 48920fd5767689124a920c1deb9c380304e082f026cArnaud Patard{ 49020fd5767689124a920c1deb9c380304e082f026cArnaud Patard struct s3c2410fb_info *fbi = info->par; 4917ee0fe41c3c4670ccea8ea180d178d2de3a46445Krzysztof Helt void __iomem *regs = fbi->io; 49220fd5767689124a920c1deb9c380304e082f026cArnaud Patard unsigned int val; 49320fd5767689124a920c1deb9c380304e082f026cArnaud Patard 494b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt /* dprintk("setcol: regno=%d, rgb=%d,%d,%d\n", 495b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt regno, red, green, blue); */ 49620fd5767689124a920c1deb9c380304e082f026cArnaud Patard 497b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt switch (info->fix.visual) { 49820fd5767689124a920c1deb9c380304e082f026cArnaud Patard case FB_VISUAL_TRUECOLOR: 499b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt /* true-colour, use pseudo-palette */ 50020fd5767689124a920c1deb9c380304e082f026cArnaud Patard 50120fd5767689124a920c1deb9c380304e082f026cArnaud Patard if (regno < 16) { 502b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt u32 *pal = info->pseudo_palette; 50320fd5767689124a920c1deb9c380304e082f026cArnaud Patard 504b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt val = chan_to_field(red, &info->var.red); 505b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt val |= chan_to_field(green, &info->var.green); 506b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt val |= chan_to_field(blue, &info->var.blue); 50720fd5767689124a920c1deb9c380304e082f026cArnaud Patard 50820fd5767689124a920c1deb9c380304e082f026cArnaud Patard pal[regno] = val; 50920fd5767689124a920c1deb9c380304e082f026cArnaud Patard } 51020fd5767689124a920c1deb9c380304e082f026cArnaud Patard break; 51120fd5767689124a920c1deb9c380304e082f026cArnaud Patard 51220fd5767689124a920c1deb9c380304e082f026cArnaud Patard case FB_VISUAL_PSEUDOCOLOR: 51320fd5767689124a920c1deb9c380304e082f026cArnaud Patard if (regno < 256) { 51420fd5767689124a920c1deb9c380304e082f026cArnaud Patard /* currently assume RGB 5-6-5 mode */ 51520fd5767689124a920c1deb9c380304e082f026cArnaud Patard 5169fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt val = (red >> 0) & 0xf800; 5179fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt val |= (green >> 5) & 0x07e0; 5189fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt val |= (blue >> 11) & 0x001f; 51920fd5767689124a920c1deb9c380304e082f026cArnaud Patard 5207ee0fe41c3c4670ccea8ea180d178d2de3a46445Krzysztof Helt writel(val, regs + S3C2410_TFTPAL(regno)); 52120fd5767689124a920c1deb9c380304e082f026cArnaud Patard schedule_palette_update(fbi, regno, val); 52220fd5767689124a920c1deb9c380304e082f026cArnaud Patard } 52320fd5767689124a920c1deb9c380304e082f026cArnaud Patard 52420fd5767689124a920c1deb9c380304e082f026cArnaud Patard break; 52520fd5767689124a920c1deb9c380304e082f026cArnaud Patard 52620fd5767689124a920c1deb9c380304e082f026cArnaud Patard default: 527b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt return 1; /* unknown type */ 52820fd5767689124a920c1deb9c380304e082f026cArnaud Patard } 52920fd5767689124a920c1deb9c380304e082f026cArnaud Patard 53020fd5767689124a920c1deb9c380304e082f026cArnaud Patard return 0; 53120fd5767689124a920c1deb9c380304e082f026cArnaud Patard} 53220fd5767689124a920c1deb9c380304e082f026cArnaud Patard 533673b4600e3b3cc6689025e6a6fc6909b6e53dd5eBen Dooks/* s3c2410fb_lcd_enable 534673b4600e3b3cc6689025e6a6fc6909b6e53dd5eBen Dooks * 535673b4600e3b3cc6689025e6a6fc6909b6e53dd5eBen Dooks * shutdown the lcd controller 536673b4600e3b3cc6689025e6a6fc6909b6e53dd5eBen Dooks */ 537673b4600e3b3cc6689025e6a6fc6909b6e53dd5eBen Dooksstatic void s3c2410fb_lcd_enable(struct s3c2410fb_info *fbi, int enable) 538673b4600e3b3cc6689025e6a6fc6909b6e53dd5eBen Dooks{ 539673b4600e3b3cc6689025e6a6fc6909b6e53dd5eBen Dooks unsigned long flags; 540673b4600e3b3cc6689025e6a6fc6909b6e53dd5eBen Dooks 541673b4600e3b3cc6689025e6a6fc6909b6e53dd5eBen Dooks local_irq_save(flags); 542673b4600e3b3cc6689025e6a6fc6909b6e53dd5eBen Dooks 543673b4600e3b3cc6689025e6a6fc6909b6e53dd5eBen Dooks if (enable) 544673b4600e3b3cc6689025e6a6fc6909b6e53dd5eBen Dooks fbi->regs.lcdcon1 |= S3C2410_LCDCON1_ENVID; 545673b4600e3b3cc6689025e6a6fc6909b6e53dd5eBen Dooks else 546673b4600e3b3cc6689025e6a6fc6909b6e53dd5eBen Dooks fbi->regs.lcdcon1 &= ~S3C2410_LCDCON1_ENVID; 547673b4600e3b3cc6689025e6a6fc6909b6e53dd5eBen Dooks 548673b4600e3b3cc6689025e6a6fc6909b6e53dd5eBen Dooks writel(fbi->regs.lcdcon1, fbi->io + S3C2410_LCDCON1); 549673b4600e3b3cc6689025e6a6fc6909b6e53dd5eBen Dooks 550673b4600e3b3cc6689025e6a6fc6909b6e53dd5eBen Dooks local_irq_restore(flags); 551673b4600e3b3cc6689025e6a6fc6909b6e53dd5eBen Dooks} 552673b4600e3b3cc6689025e6a6fc6909b6e53dd5eBen Dooks 553673b4600e3b3cc6689025e6a6fc6909b6e53dd5eBen Dooks 554b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt/* 55520fd5767689124a920c1deb9c380304e082f026cArnaud Patard * s3c2410fb_blank 55620fd5767689124a920c1deb9c380304e082f026cArnaud Patard * @blank_mode: the blank mode we want. 55720fd5767689124a920c1deb9c380304e082f026cArnaud Patard * @info: frame buffer structure that represents a single frame buffer 55820fd5767689124a920c1deb9c380304e082f026cArnaud Patard * 55920fd5767689124a920c1deb9c380304e082f026cArnaud Patard * Blank the screen if blank_mode != 0, else unblank. Return 0 if 56020fd5767689124a920c1deb9c380304e082f026cArnaud Patard * blanking succeeded, != 0 if un-/blanking failed due to e.g. a 56120fd5767689124a920c1deb9c380304e082f026cArnaud Patard * video mode which doesn't support it. Implements VESA suspend 56220fd5767689124a920c1deb9c380304e082f026cArnaud Patard * and powerdown modes on hardware that supports disabling hsync/vsync: 56320fd5767689124a920c1deb9c380304e082f026cArnaud Patard * 56420fd5767689124a920c1deb9c380304e082f026cArnaud Patard * Returns negative errno on error, or zero on success. 56520fd5767689124a920c1deb9c380304e082f026cArnaud Patard * 56620fd5767689124a920c1deb9c380304e082f026cArnaud Patard */ 56720fd5767689124a920c1deb9c380304e082f026cArnaud Patardstatic int s3c2410fb_blank(int blank_mode, struct fb_info *info) 56820fd5767689124a920c1deb9c380304e082f026cArnaud Patard{ 5697ee0fe41c3c4670ccea8ea180d178d2de3a46445Krzysztof Helt struct s3c2410fb_info *fbi = info->par; 570f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks void __iomem *tpal_reg = fbi->io; 5717ee0fe41c3c4670ccea8ea180d178d2de3a46445Krzysztof Helt 57220fd5767689124a920c1deb9c380304e082f026cArnaud Patard dprintk("blank(mode=%d, info=%p)\n", blank_mode, info); 57320fd5767689124a920c1deb9c380304e082f026cArnaud Patard 574f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks tpal_reg += is_s3c2412(fbi) ? S3C2412_TPAL : S3C2410_TPAL; 575f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks 576f940b88d3a57594289455ea99a93a8ddc5c4af06Jingoo Han if (blank_mode == FB_BLANK_POWERDOWN) 577673b4600e3b3cc6689025e6a6fc6909b6e53dd5eBen Dooks s3c2410fb_lcd_enable(fbi, 0); 578f940b88d3a57594289455ea99a93a8ddc5c4af06Jingoo Han else 579673b4600e3b3cc6689025e6a6fc6909b6e53dd5eBen Dooks s3c2410fb_lcd_enable(fbi, 1); 580673b4600e3b3cc6689025e6a6fc6909b6e53dd5eBen Dooks 58120fd5767689124a920c1deb9c380304e082f026cArnaud Patard if (blank_mode == FB_BLANK_UNBLANK) 582f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks writel(0x0, tpal_reg); 58320fd5767689124a920c1deb9c380304e082f026cArnaud Patard else { 58420fd5767689124a920c1deb9c380304e082f026cArnaud Patard dprintk("setting TPAL to output 0x000000\n"); 585f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks writel(S3C2410_TPAL_EN, tpal_reg); 58620fd5767689124a920c1deb9c380304e082f026cArnaud Patard } 58720fd5767689124a920c1deb9c380304e082f026cArnaud Patard 58820fd5767689124a920c1deb9c380304e082f026cArnaud Patard return 0; 58920fd5767689124a920c1deb9c380304e082f026cArnaud Patard} 59020fd5767689124a920c1deb9c380304e082f026cArnaud Patard 591b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Heltstatic int s3c2410fb_debug_show(struct device *dev, 592b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt struct device_attribute *attr, char *buf) 59320fd5767689124a920c1deb9c380304e082f026cArnaud Patard{ 59420fd5767689124a920c1deb9c380304e082f026cArnaud Patard return snprintf(buf, PAGE_SIZE, "%s\n", debug ? "on" : "off"); 59520fd5767689124a920c1deb9c380304e082f026cArnaud Patard} 5969fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt 597b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Heltstatic int s3c2410fb_debug_store(struct device *dev, 598b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt struct device_attribute *attr, 599b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt const char *buf, size_t len) 60020fd5767689124a920c1deb9c380304e082f026cArnaud Patard{ 60120fd5767689124a920c1deb9c380304e082f026cArnaud Patard if (len < 1) 60220fd5767689124a920c1deb9c380304e082f026cArnaud Patard return -EINVAL; 60320fd5767689124a920c1deb9c380304e082f026cArnaud Patard 604c4dd08694b8f078900c8e0c86e369b667a5101c5Rasmus Villemoes if (strncasecmp(buf, "on", 2) == 0 || 605c4dd08694b8f078900c8e0c86e369b667a5101c5Rasmus Villemoes strncasecmp(buf, "1", 1) == 0) { 60620fd5767689124a920c1deb9c380304e082f026cArnaud Patard debug = 1; 60781c1655811e941af24c212c0ac5c27931f91af3bSachin Kamat dev_dbg(dev, "s3c2410fb: Debug On"); 608c4dd08694b8f078900c8e0c86e369b667a5101c5Rasmus Villemoes } else if (strncasecmp(buf, "off", 3) == 0 || 609c4dd08694b8f078900c8e0c86e369b667a5101c5Rasmus Villemoes strncasecmp(buf, "0", 1) == 0) { 61020fd5767689124a920c1deb9c380304e082f026cArnaud Patard debug = 0; 61181c1655811e941af24c212c0ac5c27931f91af3bSachin Kamat dev_dbg(dev, "s3c2410fb: Debug Off"); 61220fd5767689124a920c1deb9c380304e082f026cArnaud Patard } else { 61320fd5767689124a920c1deb9c380304e082f026cArnaud Patard return -EINVAL; 61420fd5767689124a920c1deb9c380304e082f026cArnaud Patard } 61520fd5767689124a920c1deb9c380304e082f026cArnaud Patard 61620fd5767689124a920c1deb9c380304e082f026cArnaud Patard return len; 61720fd5767689124a920c1deb9c380304e082f026cArnaud Patard} 61820fd5767689124a920c1deb9c380304e082f026cArnaud Patard 61982867936b00a8b73d38796577a66357024cd22fcRusty Russellstatic DEVICE_ATTR(debug, 0664, s3c2410fb_debug_show, s3c2410fb_debug_store); 62020fd5767689124a920c1deb9c380304e082f026cArnaud Patard 62120fd5767689124a920c1deb9c380304e082f026cArnaud Patardstatic struct fb_ops s3c2410fb_ops = { 62220fd5767689124a920c1deb9c380304e082f026cArnaud Patard .owner = THIS_MODULE, 62320fd5767689124a920c1deb9c380304e082f026cArnaud Patard .fb_check_var = s3c2410fb_check_var, 62420fd5767689124a920c1deb9c380304e082f026cArnaud Patard .fb_set_par = s3c2410fb_set_par, 62520fd5767689124a920c1deb9c380304e082f026cArnaud Patard .fb_blank = s3c2410fb_blank, 62620fd5767689124a920c1deb9c380304e082f026cArnaud Patard .fb_setcolreg = s3c2410fb_setcolreg, 62720fd5767689124a920c1deb9c380304e082f026cArnaud Patard .fb_fillrect = cfb_fillrect, 62820fd5767689124a920c1deb9c380304e082f026cArnaud Patard .fb_copyarea = cfb_copyarea, 62920fd5767689124a920c1deb9c380304e082f026cArnaud Patard .fb_imageblit = cfb_imageblit, 63020fd5767689124a920c1deb9c380304e082f026cArnaud Patard}; 63120fd5767689124a920c1deb9c380304e082f026cArnaud Patard 63220fd5767689124a920c1deb9c380304e082f026cArnaud Patard/* 63320fd5767689124a920c1deb9c380304e082f026cArnaud Patard * s3c2410fb_map_video_memory(): 63420fd5767689124a920c1deb9c380304e082f026cArnaud Patard * Allocates the DRAM memory for the frame buffer. This buffer is 63520fd5767689124a920c1deb9c380304e082f026cArnaud Patard * remapped into a non-cached, non-buffered, memory region to 63620fd5767689124a920c1deb9c380304e082f026cArnaud Patard * allow palette and pixel writes to occur without flushing the 63720fd5767689124a920c1deb9c380304e082f026cArnaud Patard * cache. Once this area is remapped, all virtual memory 63820fd5767689124a920c1deb9c380304e082f026cArnaud Patard * access to the video memory should occur at the new region. 63920fd5767689124a920c1deb9c380304e082f026cArnaud Patard */ 64048c68c4f1b542444f175a9e136febcecf3e704d8Greg Kroah-Hartmanstatic int s3c2410fb_map_video_memory(struct fb_info *info) 64120fd5767689124a920c1deb9c380304e082f026cArnaud Patard{ 642110c1fa75463c4f327e9fc491e9a27e938800d96Krzysztof Helt struct s3c2410fb_info *fbi = info->par; 6439fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt dma_addr_t map_dma; 6449fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt unsigned map_size = PAGE_ALIGN(info->fix.smem_len); 645110c1fa75463c4f327e9fc491e9a27e938800d96Krzysztof Helt 64638a02f560752a8a003baffafac9fde5f7bfdcdf8Ben Dooks dprintk("map_video_memory(fbi=%p) map_size %u\n", fbi, map_size); 64720fd5767689124a920c1deb9c380304e082f026cArnaud Patard 6489fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt info->screen_base = dma_alloc_writecombine(fbi->dev, map_size, 6499fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt &map_dma, GFP_KERNEL); 65020fd5767689124a920c1deb9c380304e082f026cArnaud Patard 6519fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt if (info->screen_base) { 65220fd5767689124a920c1deb9c380304e082f026cArnaud Patard /* prevent initial garbage on screen */ 65320fd5767689124a920c1deb9c380304e082f026cArnaud Patard dprintk("map_video_memory: clear %p:%08x\n", 6549fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt info->screen_base, map_size); 655c0d40335353e1c89c9c885e5af4d0be0f1a50483Ben Dooks memset(info->screen_base, 0x00, map_size); 65620fd5767689124a920c1deb9c380304e082f026cArnaud Patard 6579fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt info->fix.smem_start = map_dma; 65820fd5767689124a920c1deb9c380304e082f026cArnaud Patard 6599fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt dprintk("map_video_memory: dma=%08lx cpu=%p size=%08x\n", 6609fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt info->fix.smem_start, info->screen_base, map_size); 66120fd5767689124a920c1deb9c380304e082f026cArnaud Patard } 66220fd5767689124a920c1deb9c380304e082f026cArnaud Patard 6639fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt return info->screen_base ? 0 : -ENOMEM; 66420fd5767689124a920c1deb9c380304e082f026cArnaud Patard} 66520fd5767689124a920c1deb9c380304e082f026cArnaud Patard 6669fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Heltstatic inline void s3c2410fb_unmap_video_memory(struct fb_info *info) 66720fd5767689124a920c1deb9c380304e082f026cArnaud Patard{ 6689fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt struct s3c2410fb_info *fbi = info->par; 6699fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt 6709fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt dma_free_writecombine(fbi->dev, PAGE_ALIGN(info->fix.smem_len), 6719fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt info->screen_base, info->fix.smem_start); 67220fd5767689124a920c1deb9c380304e082f026cArnaud Patard} 67320fd5767689124a920c1deb9c380304e082f026cArnaud Patard 67420fd5767689124a920c1deb9c380304e082f026cArnaud Patardstatic inline void modify_gpio(void __iomem *reg, 67520fd5767689124a920c1deb9c380304e082f026cArnaud Patard unsigned long set, unsigned long mask) 67620fd5767689124a920c1deb9c380304e082f026cArnaud Patard{ 67720fd5767689124a920c1deb9c380304e082f026cArnaud Patard unsigned long tmp; 67820fd5767689124a920c1deb9c380304e082f026cArnaud Patard 67920fd5767689124a920c1deb9c380304e082f026cArnaud Patard tmp = readl(reg) & ~mask; 68020fd5767689124a920c1deb9c380304e082f026cArnaud Patard writel(tmp | set, reg); 68120fd5767689124a920c1deb9c380304e082f026cArnaud Patard} 68220fd5767689124a920c1deb9c380304e082f026cArnaud Patard 68320fd5767689124a920c1deb9c380304e082f026cArnaud Patard/* 68420fd5767689124a920c1deb9c380304e082f026cArnaud Patard * s3c2410fb_init_registers - Initialise all LCD-related registers 68520fd5767689124a920c1deb9c380304e082f026cArnaud Patard */ 686110c1fa75463c4f327e9fc491e9a27e938800d96Krzysztof Heltstatic int s3c2410fb_init_registers(struct fb_info *info) 68720fd5767689124a920c1deb9c380304e082f026cArnaud Patard{ 688110c1fa75463c4f327e9fc491e9a27e938800d96Krzysztof Helt struct s3c2410fb_info *fbi = info->par; 6891df86cdaee3acc9b7e72855870eccaecbff336e6Jingoo Han struct s3c2410fb_mach_info *mach_info = dev_get_platdata(fbi->dev); 69020fd5767689124a920c1deb9c380304e082f026cArnaud Patard unsigned long flags; 691aff39a852eb20ee6709327d1db7610fa9bec3531Ben Dooks void __iomem *regs = fbi->io; 692f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks void __iomem *tpal; 693f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks void __iomem *lpcsel; 694f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks 695f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks if (is_s3c2412(fbi)) { 696f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks tpal = regs + S3C2412_TPAL; 697f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks lpcsel = regs + S3C2412_TCONSEL; 698f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks } else { 699f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks tpal = regs + S3C2410_TPAL; 700f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks lpcsel = regs + S3C2410_LPCSEL; 701f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks } 70220fd5767689124a920c1deb9c380304e082f026cArnaud Patard 70320fd5767689124a920c1deb9c380304e082f026cArnaud Patard /* Initialise LCD with values from haret */ 70420fd5767689124a920c1deb9c380304e082f026cArnaud Patard 70520fd5767689124a920c1deb9c380304e082f026cArnaud Patard local_irq_save(flags); 70620fd5767689124a920c1deb9c380304e082f026cArnaud Patard 70720fd5767689124a920c1deb9c380304e082f026cArnaud Patard /* modify the gpio(s) with interrupts set (bjd) */ 70820fd5767689124a920c1deb9c380304e082f026cArnaud Patard 70920fd5767689124a920c1deb9c380304e082f026cArnaud Patard modify_gpio(S3C2410_GPCUP, mach_info->gpcup, mach_info->gpcup_mask); 71020fd5767689124a920c1deb9c380304e082f026cArnaud Patard modify_gpio(S3C2410_GPCCON, mach_info->gpccon, mach_info->gpccon_mask); 71120fd5767689124a920c1deb9c380304e082f026cArnaud Patard modify_gpio(S3C2410_GPDUP, mach_info->gpdup, mach_info->gpdup_mask); 71220fd5767689124a920c1deb9c380304e082f026cArnaud Patard modify_gpio(S3C2410_GPDCON, mach_info->gpdcon, mach_info->gpdcon_mask); 71320fd5767689124a920c1deb9c380304e082f026cArnaud Patard 71420fd5767689124a920c1deb9c380304e082f026cArnaud Patard local_irq_restore(flags); 71520fd5767689124a920c1deb9c380304e082f026cArnaud Patard 71620fd5767689124a920c1deb9c380304e082f026cArnaud Patard dprintk("LPCSEL = 0x%08lx\n", mach_info->lpcsel); 717f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks writel(mach_info->lpcsel, lpcsel); 71820fd5767689124a920c1deb9c380304e082f026cArnaud Patard 719f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks dprintk("replacing TPAL %08x\n", readl(tpal)); 72020fd5767689124a920c1deb9c380304e082f026cArnaud Patard 72120fd5767689124a920c1deb9c380304e082f026cArnaud Patard /* ensure temporary palette disabled */ 722f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks writel(0x00, tpal); 72320fd5767689124a920c1deb9c380304e082f026cArnaud Patard 72420fd5767689124a920c1deb9c380304e082f026cArnaud Patard return 0; 72520fd5767689124a920c1deb9c380304e082f026cArnaud Patard} 72620fd5767689124a920c1deb9c380304e082f026cArnaud Patard 72720fd5767689124a920c1deb9c380304e082f026cArnaud Patardstatic void s3c2410fb_write_palette(struct s3c2410fb_info *fbi) 72820fd5767689124a920c1deb9c380304e082f026cArnaud Patard{ 72920fd5767689124a920c1deb9c380304e082f026cArnaud Patard unsigned int i; 730aff39a852eb20ee6709327d1db7610fa9bec3531Ben Dooks void __iomem *regs = fbi->io; 73120fd5767689124a920c1deb9c380304e082f026cArnaud Patard 73220fd5767689124a920c1deb9c380304e082f026cArnaud Patard fbi->palette_ready = 0; 73320fd5767689124a920c1deb9c380304e082f026cArnaud Patard 73420fd5767689124a920c1deb9c380304e082f026cArnaud Patard for (i = 0; i < 256; i++) { 735b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt unsigned long ent = fbi->palette_buffer[i]; 736b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt if (ent == PALETTE_BUFF_CLEAR) 73720fd5767689124a920c1deb9c380304e082f026cArnaud Patard continue; 73820fd5767689124a920c1deb9c380304e082f026cArnaud Patard 739aff39a852eb20ee6709327d1db7610fa9bec3531Ben Dooks writel(ent, regs + S3C2410_TFTPAL(i)); 74020fd5767689124a920c1deb9c380304e082f026cArnaud Patard 74120fd5767689124a920c1deb9c380304e082f026cArnaud Patard /* it seems the only way to know exactly 74220fd5767689124a920c1deb9c380304e082f026cArnaud Patard * if the palette wrote ok, is to check 74320fd5767689124a920c1deb9c380304e082f026cArnaud Patard * to see if the value verifies ok 74420fd5767689124a920c1deb9c380304e082f026cArnaud Patard */ 74520fd5767689124a920c1deb9c380304e082f026cArnaud Patard 746aff39a852eb20ee6709327d1db7610fa9bec3531Ben Dooks if (readw(regs + S3C2410_TFTPAL(i)) == ent) 74720fd5767689124a920c1deb9c380304e082f026cArnaud Patard fbi->palette_buffer[i] = PALETTE_BUFF_CLEAR; 74820fd5767689124a920c1deb9c380304e082f026cArnaud Patard else 74920fd5767689124a920c1deb9c380304e082f026cArnaud Patard fbi->palette_ready = 1; /* retry */ 75020fd5767689124a920c1deb9c380304e082f026cArnaud Patard } 75120fd5767689124a920c1deb9c380304e082f026cArnaud Patard} 75220fd5767689124a920c1deb9c380304e082f026cArnaud Patard 7537d12e780e003f93433d49ce78cfedf4b4c52adc5David Howellsstatic irqreturn_t s3c2410fb_irq(int irq, void *dev_id) 75420fd5767689124a920c1deb9c380304e082f026cArnaud Patard{ 75520fd5767689124a920c1deb9c380304e082f026cArnaud Patard struct s3c2410fb_info *fbi = dev_id; 756f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks void __iomem *irq_base = fbi->irq_base; 757f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks unsigned long lcdirq = readl(irq_base + S3C24XX_LCDINTPND); 75820fd5767689124a920c1deb9c380304e082f026cArnaud Patard 75920fd5767689124a920c1deb9c380304e082f026cArnaud Patard if (lcdirq & S3C2410_LCDINT_FRSYNC) { 76020fd5767689124a920c1deb9c380304e082f026cArnaud Patard if (fbi->palette_ready) 76120fd5767689124a920c1deb9c380304e082f026cArnaud Patard s3c2410fb_write_palette(fbi); 76220fd5767689124a920c1deb9c380304e082f026cArnaud Patard 763f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks writel(S3C2410_LCDINT_FRSYNC, irq_base + S3C24XX_LCDINTPND); 764f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks writel(S3C2410_LCDINT_FRSYNC, irq_base + S3C24XX_LCDSRCPND); 76520fd5767689124a920c1deb9c380304e082f026cArnaud Patard } 76620fd5767689124a920c1deb9c380304e082f026cArnaud Patard 76720fd5767689124a920c1deb9c380304e082f026cArnaud Patard return IRQ_HANDLED; 76820fd5767689124a920c1deb9c380304e082f026cArnaud Patard} 76920fd5767689124a920c1deb9c380304e082f026cArnaud Patard 7700dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks#ifdef CONFIG_CPU_FREQ 7710dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks 7720dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooksstatic int s3c2410fb_cpufreq_transition(struct notifier_block *nb, 7730dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks unsigned long val, void *data) 7740dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks{ 7750dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks struct s3c2410fb_info *info; 7760dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks struct fb_info *fbinfo; 7770dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks long delta_f; 7780dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks 7790dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks info = container_of(nb, struct s3c2410fb_info, freq_transition); 7800dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks fbinfo = platform_get_drvdata(to_platform_device(info->dev)); 7810dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks 7820dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks /* work out change, <0 for speed-up */ 7830dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks delta_f = info->clk_rate - clk_get_rate(info->clk); 7840dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks 7850dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks if ((val == CPUFREQ_POSTCHANGE && delta_f > 0) || 7860dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks (val == CPUFREQ_PRECHANGE && delta_f < 0)) { 7870dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks info->clk_rate = clk_get_rate(info->clk); 7880dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks s3c2410fb_activate_var(fbinfo); 7890dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks } 7900dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks 7910dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks return 0; 7920dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks} 7930dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks 7940dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooksstatic inline int s3c2410fb_cpufreq_register(struct s3c2410fb_info *info) 7950dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks{ 7960dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks info->freq_transition.notifier_call = s3c2410fb_cpufreq_transition; 7970dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks 7980dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks return cpufreq_register_notifier(&info->freq_transition, 7990dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks CPUFREQ_TRANSITION_NOTIFIER); 8000dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks} 8010dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks 8020dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooksstatic inline void s3c2410fb_cpufreq_deregister(struct s3c2410fb_info *info) 8030dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks{ 8040dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks cpufreq_unregister_notifier(&info->freq_transition, 8050dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks CPUFREQ_TRANSITION_NOTIFIER); 8060dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks} 8070dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks 8080dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks#else 8090dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooksstatic inline int s3c2410fb_cpufreq_register(struct s3c2410fb_info *info) 8100dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks{ 8110dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks return 0; 8120dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks} 8130dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks 8140dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooksstatic inline void s3c2410fb_cpufreq_deregister(struct s3c2410fb_info *info) 8150dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks{ 8160dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks} 8170dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks#endif 8180dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks 8190dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks 820f940b88d3a57594289455ea99a93a8ddc5c4af06Jingoo Hanstatic const char driver_name[] = "s3c2410fb"; 82120fd5767689124a920c1deb9c380304e082f026cArnaud Patard 82248c68c4f1b542444f175a9e136febcecf3e704d8Greg Kroah-Hartmanstatic int s3c24xxfb_probe(struct platform_device *pdev, 82348c68c4f1b542444f175a9e136febcecf3e704d8Greg Kroah-Hartman enum s3c_drv_type drv_type) 82420fd5767689124a920c1deb9c380304e082f026cArnaud Patard{ 82520fd5767689124a920c1deb9c380304e082f026cArnaud Patard struct s3c2410fb_info *info; 82609fe75f6f934597f765748342ca6fb378ee7ecdbKrzysztof Helt struct s3c2410fb_display *display; 827b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt struct fb_info *fbinfo; 8289fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt struct s3c2410fb_mach_info *mach_info; 829aff39a852eb20ee6709327d1db7610fa9bec3531Ben Dooks struct resource *res; 83020fd5767689124a920c1deb9c380304e082f026cArnaud Patard int ret; 83120fd5767689124a920c1deb9c380304e082f026cArnaud Patard int irq; 83220fd5767689124a920c1deb9c380304e082f026cArnaud Patard int i; 833aff39a852eb20ee6709327d1db7610fa9bec3531Ben Dooks int size; 8346931a764e1cff26c59be23fbde94cd51fe96bf42Arnaud Patard u32 lcdcon1; 83520fd5767689124a920c1deb9c380304e082f026cArnaud Patard 8361df86cdaee3acc9b7e72855870eccaecbff336e6Jingoo Han mach_info = dev_get_platdata(&pdev->dev); 83720fd5767689124a920c1deb9c380304e082f026cArnaud Patard if (mach_info == NULL) { 838b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt dev_err(&pdev->dev, 839b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt "no platform data for lcd, cannot attach\n"); 84020fd5767689124a920c1deb9c380304e082f026cArnaud Patard return -EINVAL; 84120fd5767689124a920c1deb9c380304e082f026cArnaud Patard } 84220fd5767689124a920c1deb9c380304e082f026cArnaud Patard 843e8973637bd49de225130f9c04ceb388d48969d98Ben Dooks if (mach_info->default_display >= mach_info->num_displays) { 844e8973637bd49de225130f9c04ceb388d48969d98Ben Dooks dev_err(&pdev->dev, "default is %d but only %d displays\n", 845e8973637bd49de225130f9c04ceb388d48969d98Ben Dooks mach_info->default_display, mach_info->num_displays); 846e8973637bd49de225130f9c04ceb388d48969d98Ben Dooks return -EINVAL; 847e8973637bd49de225130f9c04ceb388d48969d98Ben Dooks } 848e8973637bd49de225130f9c04ceb388d48969d98Ben Dooks 84909fe75f6f934597f765748342ca6fb378ee7ecdbKrzysztof Helt display = mach_info->displays + mach_info->default_display; 85020fd5767689124a920c1deb9c380304e082f026cArnaud Patard 85120fd5767689124a920c1deb9c380304e082f026cArnaud Patard irq = platform_get_irq(pdev, 0); 85220fd5767689124a920c1deb9c380304e082f026cArnaud Patard if (irq < 0) { 8533ae5eaec1d2d9c0cf53745352e7d4b152810ba24Russell King dev_err(&pdev->dev, "no irq for device\n"); 85420fd5767689124a920c1deb9c380304e082f026cArnaud Patard return -ENOENT; 85520fd5767689124a920c1deb9c380304e082f026cArnaud Patard } 85620fd5767689124a920c1deb9c380304e082f026cArnaud Patard 8573ae5eaec1d2d9c0cf53745352e7d4b152810ba24Russell King fbinfo = framebuffer_alloc(sizeof(struct s3c2410fb_info), &pdev->dev); 858b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt if (!fbinfo) 85920fd5767689124a920c1deb9c380304e082f026cArnaud Patard return -ENOMEM; 86020fd5767689124a920c1deb9c380304e082f026cArnaud Patard 8619fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt platform_set_drvdata(pdev, fbinfo); 8629fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt 86320fd5767689124a920c1deb9c380304e082f026cArnaud Patard info = fbinfo->par; 8640187f221e96e3436d552c0c7143f183eb82fb658Ben Dooks info->dev = &pdev->dev; 865f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks info->drv_type = drv_type; 8660187f221e96e3436d552c0c7143f183eb82fb658Ben Dooks 867aff39a852eb20ee6709327d1db7610fa9bec3531Ben Dooks res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 868aff39a852eb20ee6709327d1db7610fa9bec3531Ben Dooks if (res == NULL) { 869b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt dev_err(&pdev->dev, "failed to get memory registers\n"); 870aff39a852eb20ee6709327d1db7610fa9bec3531Ben Dooks ret = -ENXIO; 871aff39a852eb20ee6709327d1db7610fa9bec3531Ben Dooks goto dealloc_fb; 872aff39a852eb20ee6709327d1db7610fa9bec3531Ben Dooks } 873aff39a852eb20ee6709327d1db7610fa9bec3531Ben Dooks 87408f3153861e3ce8ff28fa82efe50cfb744afee7eJulia Lawall size = resource_size(res); 875aff39a852eb20ee6709327d1db7610fa9bec3531Ben Dooks info->mem = request_mem_region(res->start, size, pdev->name); 876aff39a852eb20ee6709327d1db7610fa9bec3531Ben Dooks if (info->mem == NULL) { 877aff39a852eb20ee6709327d1db7610fa9bec3531Ben Dooks dev_err(&pdev->dev, "failed to get memory region\n"); 878aff39a852eb20ee6709327d1db7610fa9bec3531Ben Dooks ret = -ENOENT; 879aff39a852eb20ee6709327d1db7610fa9bec3531Ben Dooks goto dealloc_fb; 880aff39a852eb20ee6709327d1db7610fa9bec3531Ben Dooks } 881aff39a852eb20ee6709327d1db7610fa9bec3531Ben Dooks 882aff39a852eb20ee6709327d1db7610fa9bec3531Ben Dooks info->io = ioremap(res->start, size); 883aff39a852eb20ee6709327d1db7610fa9bec3531Ben Dooks if (info->io == NULL) { 884aff39a852eb20ee6709327d1db7610fa9bec3531Ben Dooks dev_err(&pdev->dev, "ioremap() of registers failed\n"); 885aff39a852eb20ee6709327d1db7610fa9bec3531Ben Dooks ret = -ENXIO; 886aff39a852eb20ee6709327d1db7610fa9bec3531Ben Dooks goto release_mem; 887aff39a852eb20ee6709327d1db7610fa9bec3531Ben Dooks } 888aff39a852eb20ee6709327d1db7610fa9bec3531Ben Dooks 889f940b88d3a57594289455ea99a93a8ddc5c4af06Jingoo Han if (drv_type == DRV_S3C2412) 890f940b88d3a57594289455ea99a93a8ddc5c4af06Jingoo Han info->irq_base = info->io + S3C2412_LCDINTBASE; 891f940b88d3a57594289455ea99a93a8ddc5c4af06Jingoo Han else 892f940b88d3a57594289455ea99a93a8ddc5c4af06Jingoo Han info->irq_base = info->io + S3C2410_LCDINTBASE; 893f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks 89420fd5767689124a920c1deb9c380304e082f026cArnaud Patard dprintk("devinit\n"); 89520fd5767689124a920c1deb9c380304e082f026cArnaud Patard 89620fd5767689124a920c1deb9c380304e082f026cArnaud Patard strcpy(fbinfo->fix.id, driver_name); 89720fd5767689124a920c1deb9c380304e082f026cArnaud Patard 8989fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt /* Stop the video */ 899aff39a852eb20ee6709327d1db7610fa9bec3531Ben Dooks lcdcon1 = readl(info->io + S3C2410_LCDCON1); 900aff39a852eb20ee6709327d1db7610fa9bec3531Ben Dooks writel(lcdcon1 & ~S3C2410_LCDCON1_ENVID, info->io + S3C2410_LCDCON1); 9016931a764e1cff26c59be23fbde94cd51fe96bf42Arnaud Patard 90220fd5767689124a920c1deb9c380304e082f026cArnaud Patard fbinfo->fix.type = FB_TYPE_PACKED_PIXELS; 90320fd5767689124a920c1deb9c380304e082f026cArnaud Patard fbinfo->fix.type_aux = 0; 90420fd5767689124a920c1deb9c380304e082f026cArnaud Patard fbinfo->fix.xpanstep = 0; 90520fd5767689124a920c1deb9c380304e082f026cArnaud Patard fbinfo->fix.ypanstep = 0; 90620fd5767689124a920c1deb9c380304e082f026cArnaud Patard fbinfo->fix.ywrapstep = 0; 90720fd5767689124a920c1deb9c380304e082f026cArnaud Patard fbinfo->fix.accel = FB_ACCEL_NONE; 90820fd5767689124a920c1deb9c380304e082f026cArnaud Patard 90920fd5767689124a920c1deb9c380304e082f026cArnaud Patard fbinfo->var.nonstd = 0; 91020fd5767689124a920c1deb9c380304e082f026cArnaud Patard fbinfo->var.activate = FB_ACTIVATE_NOW; 91120fd5767689124a920c1deb9c380304e082f026cArnaud Patard fbinfo->var.accel_flags = 0; 91220fd5767689124a920c1deb9c380304e082f026cArnaud Patard fbinfo->var.vmode = FB_VMODE_NONINTERLACED; 91320fd5767689124a920c1deb9c380304e082f026cArnaud Patard 91420fd5767689124a920c1deb9c380304e082f026cArnaud Patard fbinfo->fbops = &s3c2410fb_ops; 91520fd5767689124a920c1deb9c380304e082f026cArnaud Patard fbinfo->flags = FBINFO_FLAG_DEFAULT; 91620fd5767689124a920c1deb9c380304e082f026cArnaud Patard fbinfo->pseudo_palette = &info->pseudo_pal; 91720fd5767689124a920c1deb9c380304e082f026cArnaud Patard 91820fd5767689124a920c1deb9c380304e082f026cArnaud Patard for (i = 0; i < 256; i++) 91920fd5767689124a920c1deb9c380304e082f026cArnaud Patard info->palette_buffer[i] = PALETTE_BUFF_CLEAR; 92020fd5767689124a920c1deb9c380304e082f026cArnaud Patard 921f8798ccbefc0e4ef7438c080b7ba0410738c8cfaYong Zhang ret = request_irq(irq, s3c2410fb_irq, 0, pdev->name, info); 92220fd5767689124a920c1deb9c380304e082f026cArnaud Patard if (ret) { 9233ae5eaec1d2d9c0cf53745352e7d4b152810ba24Russell King dev_err(&pdev->dev, "cannot get irq %d - err %d\n", irq, ret); 92420fd5767689124a920c1deb9c380304e082f026cArnaud Patard ret = -EBUSY; 925aff39a852eb20ee6709327d1db7610fa9bec3531Ben Dooks goto release_regs; 92620fd5767689124a920c1deb9c380304e082f026cArnaud Patard } 92720fd5767689124a920c1deb9c380304e082f026cArnaud Patard 92820fd5767689124a920c1deb9c380304e082f026cArnaud Patard info->clk = clk_get(NULL, "lcd"); 9290b2e9cb42cd0b5b0c95a776e30c9ecdff16587eaJamie Iles if (IS_ERR(info->clk)) { 93081c1655811e941af24c212c0ac5c27931f91af3bSachin Kamat dev_err(&pdev->dev, "failed to get lcd clock source\n"); 9310b2e9cb42cd0b5b0c95a776e30c9ecdff16587eaJamie Iles ret = PTR_ERR(info->clk); 93220fd5767689124a920c1deb9c380304e082f026cArnaud Patard goto release_irq; 93320fd5767689124a920c1deb9c380304e082f026cArnaud Patard } 93420fd5767689124a920c1deb9c380304e082f026cArnaud Patard 9351add0353070af00f48d78382ade7b5cfc4b8076eVasily Khoruzhick clk_prepare_enable(info->clk); 93620fd5767689124a920c1deb9c380304e082f026cArnaud Patard dprintk("got and enabled clock\n"); 93720fd5767689124a920c1deb9c380304e082f026cArnaud Patard 93842affc2de4d96634ba05b4e99313028e878a004cJingoo Han usleep_range(1000, 1100); 93920fd5767689124a920c1deb9c380304e082f026cArnaud Patard 9400dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks info->clk_rate = clk_get_rate(info->clk); 9410dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks 9429fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt /* find maximum required memory size for display */ 9439fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt for (i = 0; i < mach_info->num_displays; i++) { 9449fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt unsigned long smem_len = mach_info->displays[i].xres; 9459fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt 9469fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt smem_len *= mach_info->displays[i].yres; 9479fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt smem_len *= mach_info->displays[i].bpp; 9489fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt smem_len >>= 3; 9499fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt if (fbinfo->fix.smem_len < smem_len) 9509fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt fbinfo->fix.smem_len = smem_len; 9519fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt } 9529fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt 95320fd5767689124a920c1deb9c380304e082f026cArnaud Patard /* Initialize video memory */ 954110c1fa75463c4f327e9fc491e9a27e938800d96Krzysztof Helt ret = s3c2410fb_map_video_memory(fbinfo); 95520fd5767689124a920c1deb9c380304e082f026cArnaud Patard if (ret) { 95681c1655811e941af24c212c0ac5c27931f91af3bSachin Kamat dev_err(&pdev->dev, "Failed to allocate video RAM: %d\n", ret); 95720fd5767689124a920c1deb9c380304e082f026cArnaud Patard ret = -ENOMEM; 95820fd5767689124a920c1deb9c380304e082f026cArnaud Patard goto release_clock; 95920fd5767689124a920c1deb9c380304e082f026cArnaud Patard } 960aff39a852eb20ee6709327d1db7610fa9bec3531Ben Dooks 96120fd5767689124a920c1deb9c380304e082f026cArnaud Patard dprintk("got video memory\n"); 96220fd5767689124a920c1deb9c380304e082f026cArnaud Patard 9639fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt fbinfo->var.xres = display->xres; 9649fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt fbinfo->var.yres = display->yres; 9659fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt fbinfo->var.bits_per_pixel = display->bpp; 9669fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt 967110c1fa75463c4f327e9fc491e9a27e938800d96Krzysztof Helt s3c2410fb_init_registers(fbinfo); 96820fd5767689124a920c1deb9c380304e082f026cArnaud Patard 969b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt s3c2410fb_check_var(&fbinfo->var, fbinfo); 97020fd5767689124a920c1deb9c380304e082f026cArnaud Patard 9710dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks ret = s3c2410fb_cpufreq_register(info); 9720dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks if (ret < 0) { 9730dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks dev_err(&pdev->dev, "Failed to register cpufreq\n"); 9740dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks goto free_video_memory; 9750dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks } 9760dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks 97720fd5767689124a920c1deb9c380304e082f026cArnaud Patard ret = register_framebuffer(fbinfo); 97820fd5767689124a920c1deb9c380304e082f026cArnaud Patard if (ret < 0) { 97981c1655811e941af24c212c0ac5c27931f91af3bSachin Kamat dev_err(&pdev->dev, "Failed to register framebuffer device: %d\n", 980b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt ret); 9810dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks goto free_cpufreq; 98220fd5767689124a920c1deb9c380304e082f026cArnaud Patard } 98320fd5767689124a920c1deb9c380304e082f026cArnaud Patard 98420fd5767689124a920c1deb9c380304e082f026cArnaud Patard /* create device files */ 985d585dfe840c93ea800afc124333b6ac04722d359Ben Dooks ret = device_create_file(&pdev->dev, &dev_attr_debug); 986f940b88d3a57594289455ea99a93a8ddc5c4af06Jingoo Han if (ret) 98781c1655811e941af24c212c0ac5c27931f91af3bSachin Kamat dev_err(&pdev->dev, "failed to add debug attribute\n"); 98820fd5767689124a920c1deb9c380304e082f026cArnaud Patard 98981c1655811e941af24c212c0ac5c27931f91af3bSachin Kamat dev_info(&pdev->dev, "fb%d: %s frame buffer device\n", 99020fd5767689124a920c1deb9c380304e082f026cArnaud Patard fbinfo->node, fbinfo->fix.id); 99120fd5767689124a920c1deb9c380304e082f026cArnaud Patard 99220fd5767689124a920c1deb9c380304e082f026cArnaud Patard return 0; 99320fd5767689124a920c1deb9c380304e082f026cArnaud Patard 9940dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks free_cpufreq: 9950dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks s3c2410fb_cpufreq_deregister(info); 99620fd5767689124a920c1deb9c380304e082f026cArnaud Patardfree_video_memory: 9979fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt s3c2410fb_unmap_video_memory(fbinfo); 99820fd5767689124a920c1deb9c380304e082f026cArnaud Patardrelease_clock: 9991add0353070af00f48d78382ade7b5cfc4b8076eVasily Khoruzhick clk_disable_unprepare(info->clk); 100020fd5767689124a920c1deb9c380304e082f026cArnaud Patard clk_put(info->clk); 100120fd5767689124a920c1deb9c380304e082f026cArnaud Patardrelease_irq: 1002b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt free_irq(irq, info); 1003aff39a852eb20ee6709327d1db7610fa9bec3531Ben Dooksrelease_regs: 1004aff39a852eb20ee6709327d1db7610fa9bec3531Ben Dooks iounmap(info->io); 100520fd5767689124a920c1deb9c380304e082f026cArnaud Patardrelease_mem: 100608f3153861e3ce8ff28fa82efe50cfb744afee7eJulia Lawall release_mem_region(res->start, size); 100720fd5767689124a920c1deb9c380304e082f026cArnaud Patarddealloc_fb: 100820fd5767689124a920c1deb9c380304e082f026cArnaud Patard framebuffer_release(fbinfo); 100920fd5767689124a920c1deb9c380304e082f026cArnaud Patard return ret; 101020fd5767689124a920c1deb9c380304e082f026cArnaud Patard} 101120fd5767689124a920c1deb9c380304e082f026cArnaud Patard 101248c68c4f1b542444f175a9e136febcecf3e704d8Greg Kroah-Hartmanstatic int s3c2410fb_probe(struct platform_device *pdev) 1013f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks{ 1014f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks return s3c24xxfb_probe(pdev, DRV_S3C2410); 1015f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks} 1016f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks 101748c68c4f1b542444f175a9e136febcecf3e704d8Greg Kroah-Hartmanstatic int s3c2412fb_probe(struct platform_device *pdev) 1018f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks{ 1019f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks return s3c24xxfb_probe(pdev, DRV_S3C2412); 1020f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks} 1021f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks 102220fd5767689124a920c1deb9c380304e082f026cArnaud Patard 102320fd5767689124a920c1deb9c380304e082f026cArnaud Patard/* 102420fd5767689124a920c1deb9c380304e082f026cArnaud Patard * Cleanup 102520fd5767689124a920c1deb9c380304e082f026cArnaud Patard */ 102648c68c4f1b542444f175a9e136febcecf3e704d8Greg Kroah-Hartmanstatic int s3c2410fb_remove(struct platform_device *pdev) 102720fd5767689124a920c1deb9c380304e082f026cArnaud Patard{ 1028b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt struct fb_info *fbinfo = platform_get_drvdata(pdev); 102920fd5767689124a920c1deb9c380304e082f026cArnaud Patard struct s3c2410fb_info *info = fbinfo->par; 103020fd5767689124a920c1deb9c380304e082f026cArnaud Patard int irq; 103120fd5767689124a920c1deb9c380304e082f026cArnaud Patard 10329fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt unregister_framebuffer(fbinfo); 10330dac6ecdc056b83ac66e5b5c923fb73268f4332dBen Dooks s3c2410fb_cpufreq_deregister(info); 10349fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt 1035673b4600e3b3cc6689025e6a6fc6909b6e53dd5eBen Dooks s3c2410fb_lcd_enable(info, 0); 103642affc2de4d96634ba05b4e99313028e878a004cJingoo Han usleep_range(1000, 1100); 103720fd5767689124a920c1deb9c380304e082f026cArnaud Patard 10389fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt s3c2410fb_unmap_video_memory(fbinfo); 103920fd5767689124a920c1deb9c380304e082f026cArnaud Patard 1040b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt if (info->clk) { 10411add0353070af00f48d78382ade7b5cfc4b8076eVasily Khoruzhick clk_disable_unprepare(info->clk); 1042b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt clk_put(info->clk); 1043b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt info->clk = NULL; 104420fd5767689124a920c1deb9c380304e082f026cArnaud Patard } 104520fd5767689124a920c1deb9c380304e082f026cArnaud Patard 104620fd5767689124a920c1deb9c380304e082f026cArnaud Patard irq = platform_get_irq(pdev, 0); 1047b0831941d59a80896c9b2a63a13ea063e31054a5Krzysztof Helt free_irq(irq, info); 1048aff39a852eb20ee6709327d1db7610fa9bec3531Ben Dooks 10499fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt iounmap(info->io); 10509fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt 105108f3153861e3ce8ff28fa82efe50cfb744afee7eJulia Lawall release_mem_region(info->mem->start, resource_size(info->mem)); 10529fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt 10539fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Helt framebuffer_release(fbinfo); 105420fd5767689124a920c1deb9c380304e082f026cArnaud Patard 105520fd5767689124a920c1deb9c380304e082f026cArnaud Patard return 0; 105620fd5767689124a920c1deb9c380304e082f026cArnaud Patard} 105720fd5767689124a920c1deb9c380304e082f026cArnaud Patard 105820fd5767689124a920c1deb9c380304e082f026cArnaud Patard#ifdef CONFIG_PM 105920fd5767689124a920c1deb9c380304e082f026cArnaud Patard 106020fd5767689124a920c1deb9c380304e082f026cArnaud Patard/* suspend and resume support for the lcd controller */ 10613ae5eaec1d2d9c0cf53745352e7d4b152810ba24Russell Kingstatic int s3c2410fb_suspend(struct platform_device *dev, pm_message_t state) 106220fd5767689124a920c1deb9c380304e082f026cArnaud Patard{ 10633ae5eaec1d2d9c0cf53745352e7d4b152810ba24Russell King struct fb_info *fbinfo = platform_get_drvdata(dev); 106420fd5767689124a920c1deb9c380304e082f026cArnaud Patard struct s3c2410fb_info *info = fbinfo->par; 106520fd5767689124a920c1deb9c380304e082f026cArnaud Patard 1066673b4600e3b3cc6689025e6a6fc6909b6e53dd5eBen Dooks s3c2410fb_lcd_enable(info, 0); 106720fd5767689124a920c1deb9c380304e082f026cArnaud Patard 10689480e307cd88ef09ec9294c7d97ebec18e6d2221Russell King /* sleep before disabling the clock, we need to ensure 10699480e307cd88ef09ec9294c7d97ebec18e6d2221Russell King * the LCD DMA engine is not going to get back on the bus 10709480e307cd88ef09ec9294c7d97ebec18e6d2221Russell King * before the clock goes off again (bjd) */ 107120fd5767689124a920c1deb9c380304e082f026cArnaud Patard 107242affc2de4d96634ba05b4e99313028e878a004cJingoo Han usleep_range(1000, 1100); 10731add0353070af00f48d78382ade7b5cfc4b8076eVasily Khoruzhick clk_disable_unprepare(info->clk); 107420fd5767689124a920c1deb9c380304e082f026cArnaud Patard 107520fd5767689124a920c1deb9c380304e082f026cArnaud Patard return 0; 107620fd5767689124a920c1deb9c380304e082f026cArnaud Patard} 107720fd5767689124a920c1deb9c380304e082f026cArnaud Patard 10783ae5eaec1d2d9c0cf53745352e7d4b152810ba24Russell Kingstatic int s3c2410fb_resume(struct platform_device *dev) 107920fd5767689124a920c1deb9c380304e082f026cArnaud Patard{ 10803ae5eaec1d2d9c0cf53745352e7d4b152810ba24Russell King struct fb_info *fbinfo = platform_get_drvdata(dev); 108120fd5767689124a920c1deb9c380304e082f026cArnaud Patard struct s3c2410fb_info *info = fbinfo->par; 108220fd5767689124a920c1deb9c380304e082f026cArnaud Patard 10831add0353070af00f48d78382ade7b5cfc4b8076eVasily Khoruzhick clk_prepare_enable(info->clk); 108442affc2de4d96634ba05b4e99313028e878a004cJingoo Han usleep_range(1000, 1100); 108520fd5767689124a920c1deb9c380304e082f026cArnaud Patard 1086f0466441492dc17d0749ef0cce9831fc7e4a7a5dKrzysztof Helt s3c2410fb_init_registers(fbinfo); 108720fd5767689124a920c1deb9c380304e082f026cArnaud Patard 108860f793de891ea06fa870546336a88df543ec56aeDaniel Silverstone /* re-activate our display after resume */ 108960f793de891ea06fa870546336a88df543ec56aeDaniel Silverstone s3c2410fb_activate_var(fbinfo); 109060f793de891ea06fa870546336a88df543ec56aeDaniel Silverstone s3c2410fb_blank(FB_BLANK_UNBLANK, fbinfo); 109160f793de891ea06fa870546336a88df543ec56aeDaniel Silverstone 109220fd5767689124a920c1deb9c380304e082f026cArnaud Patard return 0; 109320fd5767689124a920c1deb9c380304e082f026cArnaud Patard} 109420fd5767689124a920c1deb9c380304e082f026cArnaud Patard 109520fd5767689124a920c1deb9c380304e082f026cArnaud Patard#else 109620fd5767689124a920c1deb9c380304e082f026cArnaud Patard#define s3c2410fb_suspend NULL 109720fd5767689124a920c1deb9c380304e082f026cArnaud Patard#define s3c2410fb_resume NULL 109820fd5767689124a920c1deb9c380304e082f026cArnaud Patard#endif 109920fd5767689124a920c1deb9c380304e082f026cArnaud Patard 11003ae5eaec1d2d9c0cf53745352e7d4b152810ba24Russell Kingstatic struct platform_driver s3c2410fb_driver = { 110120fd5767689124a920c1deb9c380304e082f026cArnaud Patard .probe = s3c2410fb_probe, 110248c68c4f1b542444f175a9e136febcecf3e704d8Greg Kroah-Hartman .remove = s3c2410fb_remove, 110320fd5767689124a920c1deb9c380304e082f026cArnaud Patard .suspend = s3c2410fb_suspend, 110420fd5767689124a920c1deb9c380304e082f026cArnaud Patard .resume = s3c2410fb_resume, 11053ae5eaec1d2d9c0cf53745352e7d4b152810ba24Russell King .driver = { 11063ae5eaec1d2d9c0cf53745352e7d4b152810ba24Russell King .name = "s3c2410-lcd", 11073ae5eaec1d2d9c0cf53745352e7d4b152810ba24Russell King .owner = THIS_MODULE, 11083ae5eaec1d2d9c0cf53745352e7d4b152810ba24Russell King }, 110920fd5767689124a920c1deb9c380304e082f026cArnaud Patard}; 111020fd5767689124a920c1deb9c380304e082f026cArnaud Patard 1111f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooksstatic struct platform_driver s3c2412fb_driver = { 1112f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks .probe = s3c2412fb_probe, 111348c68c4f1b542444f175a9e136febcecf3e704d8Greg Kroah-Hartman .remove = s3c2410fb_remove, 1114f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks .suspend = s3c2410fb_suspend, 1115f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks .resume = s3c2410fb_resume, 1116f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks .driver = { 1117f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks .name = "s3c2412-lcd", 1118f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks .owner = THIS_MODULE, 1119f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks }, 1120f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks}; 1121f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks 11229fa7bc016a688630386378c205f9ee0f7b2cc834Krzysztof Heltint __init s3c2410fb_init(void) 112320fd5767689124a920c1deb9c380304e082f026cArnaud Patard{ 1124f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks int ret = platform_driver_register(&s3c2410fb_driver); 1125f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks 1126f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks if (ret == 0) 1127a419aef8b858a2bdb98df60336063d28df4b272fJoe Perches ret = platform_driver_register(&s3c2412fb_driver); 1128f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks 1129f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks return ret; 113020fd5767689124a920c1deb9c380304e082f026cArnaud Patard} 113120fd5767689124a920c1deb9c380304e082f026cArnaud Patard 113220fd5767689124a920c1deb9c380304e082f026cArnaud Patardstatic void __exit s3c2410fb_cleanup(void) 113320fd5767689124a920c1deb9c380304e082f026cArnaud Patard{ 11343ae5eaec1d2d9c0cf53745352e7d4b152810ba24Russell King platform_driver_unregister(&s3c2410fb_driver); 1135f62e770b25bdc24e18c9191fe2ca3e159036bd79Ben Dooks platform_driver_unregister(&s3c2412fb_driver); 113620fd5767689124a920c1deb9c380304e082f026cArnaud Patard} 113720fd5767689124a920c1deb9c380304e082f026cArnaud Patard 113820fd5767689124a920c1deb9c380304e082f026cArnaud Patardmodule_init(s3c2410fb_init); 113920fd5767689124a920c1deb9c380304e082f026cArnaud Patardmodule_exit(s3c2410fb_cleanup); 114020fd5767689124a920c1deb9c380304e082f026cArnaud Patard 114142affc2de4d96634ba05b4e99313028e878a004cJingoo HanMODULE_AUTHOR("Arnaud Patard <arnaud.patard@rtp-net.org>"); 114242affc2de4d96634ba05b4e99313028e878a004cJingoo HanMODULE_AUTHOR("Ben Dooks <ben-linux@fluff.org>"); 114320fd5767689124a920c1deb9c380304e082f026cArnaud PatardMODULE_DESCRIPTION("Framebuffer driver for the s3c2410"); 114420fd5767689124a920c1deb9c380304e082f026cArnaud PatardMODULE_LICENSE("GPL"); 1145ee29420aca6ca6fbb3e72ee8a980b2600911b864Ben DooksMODULE_ALIAS("platform:s3c2410-lcd"); 1146ee29420aca6ca6fbb3e72ee8a980b2600911b864Ben DooksMODULE_ALIAS("platform:s3c2412-lcd"); 1147