Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * BRIEF MODULE DESCRIPTION |
| 3 | * Au1100 LCD Driver. |
| 4 | * |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 5 | * Rewritten for 2.6 by Embedded Alley Solutions |
| 6 | * <source@embeddedalley.com>, based on submissions by |
| 7 | * Karl Lessard <klessard@sunrisetelecom.com> |
| 8 | * <c.pellegrin@exadron.com> |
| 9 | * |
Rodolfo Giometti | f77f50c | 2006-06-26 00:26:49 -0700 | [diff] [blame] | 10 | * PM support added by Rodolfo Giometti <giometti@linux.it> |
Rodolfo Giometti | ca27ac4 | 2006-10-03 01:14:36 -0700 | [diff] [blame] | 11 | * Cursor enable/disable by Rodolfo Giometti <giometti@linux.it> |
Rodolfo Giometti | f77f50c | 2006-06-26 00:26:49 -0700 | [diff] [blame] | 12 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | * Copyright 2002 MontaVista Software |
| 14 | * Author: MontaVista Software, Inc. |
| 15 | * ppopov@mvista.com or source@mvista.com |
| 16 | * |
| 17 | * Copyright 2002 Alchemy Semiconductor |
| 18 | * Author: Alchemy Semiconductor |
| 19 | * |
| 20 | * Based on: |
| 21 | * linux/drivers/video/skeletonfb.c -- Skeleton for a frame buffer device |
| 22 | * Created 28 Dec 1997 by Geert Uytterhoeven |
| 23 | * |
| 24 | * This program is free software; you can redistribute it and/or modify it |
| 25 | * under the terms of the GNU General Public License as published by the |
| 26 | * Free Software Foundation; either version 2 of the License, or (at your |
| 27 | * option) any later version. |
| 28 | * |
| 29 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED |
| 30 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 31 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN |
| 32 | * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 33 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 34 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
| 35 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
| 36 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 37 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 38 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 39 | * |
| 40 | * You should have received a copy of the GNU General Public License along |
| 41 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 42 | * 675 Mass Ave, Cambridge, MA 02139, USA. |
| 43 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | #include <linux/module.h> |
| 45 | #include <linux/kernel.h> |
| 46 | #include <linux/errno.h> |
| 47 | #include <linux/string.h> |
| 48 | #include <linux/mm.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | #include <linux/fb.h> |
| 50 | #include <linux/init.h> |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 51 | #include <linux/interrupt.h> |
| 52 | #include <linux/ctype.h> |
| 53 | #include <linux/dma-mapping.h> |
Freddy Spierenburg | cacfc8c | 2006-02-24 13:04:17 -0800 | [diff] [blame] | 54 | #include <linux/platform_device.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 55 | #include <linux/slab.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 57 | #include <asm/mach-au1x00/au1000.h> |
| 58 | |
| 59 | #define DEBUG 0 |
| 60 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | #include "au1100fb.h" |
| 62 | |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 63 | #define DRIVER_NAME "au1100fb" |
| 64 | #define DRIVER_DESC "LCD controller driver for AU1100 processors" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 66 | #define to_au1100fb_device(_info) \ |
| 67 | (_info ? container_of(_info, struct au1100fb_device, info) : NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 69 | /* Bitfields format supported by the controller. Note that the order of formats |
| 70 | * SHOULD be the same as in the LCD_CONTROL_SBPPF field, so we can retrieve the |
| 71 | * right pixel format by doing rgb_bitfields[LCD_CONTROL_SBPPF_XXX >> LCD_CONTROL_SBPPF] |
| 72 | */ |
| 73 | struct fb_bitfield rgb_bitfields[][4] = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | { |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 75 | /* Red, Green, Blue, Transp */ |
| 76 | { { 10, 6, 0 }, { 5, 5, 0 }, { 0, 5, 0 }, { 0, 0, 0 } }, |
| 77 | { { 11, 5, 0 }, { 5, 6, 0 }, { 0, 5, 0 }, { 0, 0, 0 } }, |
| 78 | { { 11, 5, 0 }, { 6, 5, 0 }, { 0, 6, 0 }, { 0, 0, 0 } }, |
| 79 | { { 10, 5, 0 }, { 5, 5, 0 }, { 0, 5, 0 }, { 15, 1, 0 } }, |
| 80 | { { 11, 5, 0 }, { 6, 5, 0 }, { 1, 5, 0 }, { 0, 1, 0 } }, |
| 81 | |
| 82 | /* The last is used to describe 12bpp format */ |
| 83 | { { 8, 4, 0 }, { 4, 4, 0 }, { 0, 4, 0 }, { 0, 0, 0 } }, |
| 84 | }; |
| 85 | |
Ralf Baechle | 362992b | 2010-07-26 19:08:15 +0100 | [diff] [blame] | 86 | static struct fb_fix_screeninfo au1100fb_fix __devinitdata = { |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 87 | .id = "AU1100 FB", |
| 88 | .xpanstep = 1, |
| 89 | .ypanstep = 1, |
| 90 | .type = FB_TYPE_PACKED_PIXELS, |
| 91 | .accel = FB_ACCEL_NONE, |
| 92 | }; |
| 93 | |
Ralf Baechle | 362992b | 2010-07-26 19:08:15 +0100 | [diff] [blame] | 94 | static struct fb_var_screeninfo au1100fb_var __devinitdata = { |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 95 | .activate = FB_ACTIVATE_NOW, |
| 96 | .height = -1, |
| 97 | .width = -1, |
| 98 | .vmode = FB_VMODE_NONINTERLACED, |
| 99 | }; |
| 100 | |
Yoichi Yuasa | 8e92f21 | 2007-08-22 14:02:03 -0700 | [diff] [blame] | 101 | /* fb_blank |
| 102 | * Blank the screen. Depending on the mode, the screen will be |
| 103 | * activated with the backlight color, or desactivated |
| 104 | */ |
| 105 | static int au1100fb_fb_blank(int blank_mode, struct fb_info *fbi) |
| 106 | { |
| 107 | struct au1100fb_device *fbdev = to_au1100fb_device(fbi); |
| 108 | |
| 109 | print_dbg("fb_blank %d %p", blank_mode, fbi); |
| 110 | |
| 111 | switch (blank_mode) { |
| 112 | |
| 113 | case VESA_NO_BLANKING: |
| 114 | /* Turn on panel */ |
| 115 | fbdev->regs->lcd_control |= LCD_CONTROL_GO; |
| 116 | #ifdef CONFIG_MIPS_PB1100 |
Manuel Lauss | d121c3f | 2011-09-30 20:49:43 +0200 | [diff] [blame] | 117 | if (fbdev->panel_idx == 1) { |
Yoichi Yuasa | 8e92f21 | 2007-08-22 14:02:03 -0700 | [diff] [blame] | 118 | au_writew(au_readw(PB1100_G_CONTROL) |
| 119 | | (PB1100_G_CONTROL_BL | PB1100_G_CONTROL_VDD), |
| 120 | PB1100_G_CONTROL); |
| 121 | } |
| 122 | #endif |
| 123 | au_sync(); |
| 124 | break; |
| 125 | |
| 126 | case VESA_VSYNC_SUSPEND: |
| 127 | case VESA_HSYNC_SUSPEND: |
| 128 | case VESA_POWERDOWN: |
| 129 | /* Turn off panel */ |
| 130 | fbdev->regs->lcd_control &= ~LCD_CONTROL_GO; |
| 131 | #ifdef CONFIG_MIPS_PB1100 |
Manuel Lauss | d121c3f | 2011-09-30 20:49:43 +0200 | [diff] [blame] | 132 | if (fbdev->panel_idx == 1) { |
Yoichi Yuasa | 8e92f21 | 2007-08-22 14:02:03 -0700 | [diff] [blame] | 133 | au_writew(au_readw(PB1100_G_CONTROL) |
| 134 | & ~(PB1100_G_CONTROL_BL | PB1100_G_CONTROL_VDD), |
| 135 | PB1100_G_CONTROL); |
| 136 | } |
| 137 | #endif |
| 138 | au_sync(); |
| 139 | break; |
| 140 | default: |
| 141 | break; |
| 142 | |
| 143 | } |
| 144 | return 0; |
| 145 | } |
| 146 | |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 147 | /* |
| 148 | * Set hardware with var settings. This will enable the controller with a specific |
| 149 | * mode, normally validated with the fb_check_var method |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 150 | */ |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 151 | int au1100fb_setmode(struct au1100fb_device *fbdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | { |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 153 | struct fb_info *info = &fbdev->info; |
| 154 | u32 words; |
| 155 | int index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 157 | if (!fbdev) |
| 158 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 160 | /* Update var-dependent FB info */ |
| 161 | if (panel_is_active(fbdev->panel) || panel_is_color(fbdev->panel)) { |
| 162 | if (info->var.bits_per_pixel <= 8) { |
| 163 | /* palettized */ |
| 164 | info->var.red.offset = 0; |
| 165 | info->var.red.length = info->var.bits_per_pixel; |
| 166 | info->var.red.msb_right = 0; |
| 167 | |
| 168 | info->var.green.offset = 0; |
| 169 | info->var.green.length = info->var.bits_per_pixel; |
| 170 | info->var.green.msb_right = 0; |
| 171 | |
| 172 | info->var.blue.offset = 0; |
| 173 | info->var.blue.length = info->var.bits_per_pixel; |
| 174 | info->var.blue.msb_right = 0; |
| 175 | |
| 176 | info->var.transp.offset = 0; |
| 177 | info->var.transp.length = 0; |
| 178 | info->var.transp.msb_right = 0; |
| 179 | |
| 180 | info->fix.visual = FB_VISUAL_PSEUDOCOLOR; |
| 181 | info->fix.line_length = info->var.xres_virtual / |
| 182 | (8/info->var.bits_per_pixel); |
| 183 | } else { |
| 184 | /* non-palettized */ |
| 185 | index = (fbdev->panel->control_base & LCD_CONTROL_SBPPF_MASK) >> LCD_CONTROL_SBPPF_BIT; |
| 186 | info->var.red = rgb_bitfields[index][0]; |
| 187 | info->var.green = rgb_bitfields[index][1]; |
| 188 | info->var.blue = rgb_bitfields[index][2]; |
| 189 | info->var.transp = rgb_bitfields[index][3]; |
| 190 | |
| 191 | info->fix.visual = FB_VISUAL_TRUECOLOR; |
| 192 | info->fix.line_length = info->var.xres_virtual << 1; /* depth=16 */ |
Rodolfo Giometti | bb39e41 | 2006-08-05 12:14:22 -0700 | [diff] [blame] | 193 | } |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 194 | } else { |
| 195 | /* mono */ |
| 196 | info->fix.visual = FB_VISUAL_MONO10; |
| 197 | info->fix.line_length = info->var.xres_virtual / 8; |
| 198 | } |
| 199 | |
| 200 | info->screen_size = info->fix.line_length * info->var.yres_virtual; |
Rodolfo Giometti | fd2d543 | 2006-08-05 12:14:19 -0700 | [diff] [blame] | 201 | info->var.rotate = ((fbdev->panel->control_base&LCD_CONTROL_SM_MASK) \ |
| 202 | >> LCD_CONTROL_SM_BIT) * 90; |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 203 | |
| 204 | /* Determine BPP mode and format */ |
Rodolfo Giometti | fd2d543 | 2006-08-05 12:14:19 -0700 | [diff] [blame] | 205 | fbdev->regs->lcd_control = fbdev->panel->control_base; |
Rodolfo Giometti | bb39e41 | 2006-08-05 12:14:22 -0700 | [diff] [blame] | 206 | fbdev->regs->lcd_horztiming = fbdev->panel->horztiming; |
| 207 | fbdev->regs->lcd_verttiming = fbdev->panel->verttiming; |
| 208 | fbdev->regs->lcd_clkcontrol = fbdev->panel->clkcontrol_base; |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 209 | fbdev->regs->lcd_intenable = 0; |
| 210 | fbdev->regs->lcd_intstatus = 0; |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 211 | fbdev->regs->lcd_dmaaddr0 = LCD_DMA_SA_N(fbdev->fb_phys); |
| 212 | |
| 213 | if (panel_is_dual(fbdev->panel)) { |
| 214 | /* Second panel display seconf half of screen if possible, |
| 215 | * otherwise display the same as the first panel */ |
| 216 | if (info->var.yres_virtual >= (info->var.yres << 1)) { |
| 217 | fbdev->regs->lcd_dmaaddr1 = LCD_DMA_SA_N(fbdev->fb_phys + |
| 218 | (info->fix.line_length * |
| 219 | (info->var.yres_virtual >> 1))); |
| 220 | } else { |
| 221 | fbdev->regs->lcd_dmaaddr1 = LCD_DMA_SA_N(fbdev->fb_phys); |
| 222 | } |
| 223 | } |
| 224 | |
| 225 | words = info->fix.line_length / sizeof(u32); |
| 226 | if (!info->var.rotate || (info->var.rotate == 180)) { |
| 227 | words *= info->var.yres_virtual; |
| 228 | if (info->var.rotate /* 180 */) { |
| 229 | words -= (words % 8); /* should be divisable by 8 */ |
| 230 | } |
| 231 | } |
| 232 | fbdev->regs->lcd_words = LCD_WRD_WRDS_N(words); |
| 233 | |
| 234 | fbdev->regs->lcd_pwmdiv = 0; |
| 235 | fbdev->regs->lcd_pwmhi = 0; |
| 236 | |
| 237 | /* Resume controller */ |
| 238 | fbdev->regs->lcd_control |= LCD_CONTROL_GO; |
Rodolfo Giometti | bb39e41 | 2006-08-05 12:14:22 -0700 | [diff] [blame] | 239 | mdelay(10); |
| 240 | au1100fb_fb_blank(VESA_NO_BLANKING, info); |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 241 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | return 0; |
| 243 | } |
| 244 | |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 245 | /* fb_setcolreg |
| 246 | * Set color in LCD palette. |
| 247 | */ |
| 248 | int au1100fb_fb_setcolreg(unsigned regno, unsigned red, unsigned green, unsigned blue, unsigned transp, struct fb_info *fbi) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 249 | { |
Rodolfo Giometti | c05b7f3 | 2006-05-30 21:26:57 -0700 | [diff] [blame] | 250 | struct au1100fb_device *fbdev; |
| 251 | u32 *palette; |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 252 | u32 value; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | |
Rodolfo Giometti | c05b7f3 | 2006-05-30 21:26:57 -0700 | [diff] [blame] | 254 | fbdev = to_au1100fb_device(fbi); |
| 255 | palette = fbdev->regs->lcd_pallettebase; |
| 256 | |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 257 | if (regno > (AU1100_LCD_NBR_PALETTE_ENTRIES - 1)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 | return -EINVAL; |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 259 | |
| 260 | if (fbi->var.grayscale) { |
| 261 | /* Convert color to grayscale */ |
| 262 | red = green = blue = |
| 263 | (19595 * red + 38470 * green + 7471 * blue) >> 16; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | } |
| 265 | |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 266 | if (fbi->fix.visual == FB_VISUAL_TRUECOLOR) { |
| 267 | /* Place color in the pseudopalette */ |
| 268 | if (regno > 16) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | return -EINVAL; |
| 270 | |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 271 | palette = (u32*)fbi->pseudo_palette; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 273 | red >>= (16 - fbi->var.red.length); |
| 274 | green >>= (16 - fbi->var.green.length); |
| 275 | blue >>= (16 - fbi->var.blue.length); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 277 | value = (red << fbi->var.red.offset) | |
| 278 | (green << fbi->var.green.offset)| |
| 279 | (blue << fbi->var.blue.offset); |
| 280 | value &= 0xFFFF; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 282 | } else if (panel_is_active(fbdev->panel)) { |
| 283 | /* COLOR TFT PALLETTIZED (use RGB 565) */ |
| 284 | value = (red & 0xF800)|((green >> 5) & 0x07E0)|((blue >> 11) & 0x001F); |
| 285 | value &= 0xFFFF; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 286 | |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 287 | } else if (panel_is_color(fbdev->panel)) { |
| 288 | /* COLOR STN MODE */ |
| 289 | value = (((panel_swap_rgb(fbdev->panel) ? blue : red) >> 12) & 0x000F) | |
| 290 | ((green >> 8) & 0x00F0) | |
| 291 | (((panel_swap_rgb(fbdev->panel) ? red : blue) >> 4) & 0x0F00); |
| 292 | value &= 0xFFF; |
| 293 | } else { |
| 294 | /* MONOCHROME MODE */ |
| 295 | value = (green >> 12) & 0x000F; |
| 296 | value &= 0xF; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | } |
| 298 | |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 299 | palette[regno] = value; |
| 300 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | return 0; |
| 302 | } |
| 303 | |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 304 | /* fb_pan_display |
| 305 | * Pan display in x and/or y as specified |
| 306 | */ |
| 307 | int au1100fb_fb_pan_display(struct fb_var_screeninfo *var, struct fb_info *fbi) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | { |
Rodolfo Giometti | c05b7f3 | 2006-05-30 21:26:57 -0700 | [diff] [blame] | 309 | struct au1100fb_device *fbdev; |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 310 | int dy; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | |
Rodolfo Giometti | c05b7f3 | 2006-05-30 21:26:57 -0700 | [diff] [blame] | 312 | fbdev = to_au1100fb_device(fbi); |
| 313 | |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 314 | print_dbg("fb_pan_display %p %p", var, fbi); |
| 315 | |
| 316 | if (!var || !fbdev) { |
| 317 | return -EINVAL; |
| 318 | } |
| 319 | |
| 320 | if (var->xoffset - fbi->var.xoffset) { |
| 321 | /* No support for X panning for now! */ |
| 322 | return -EINVAL; |
| 323 | } |
| 324 | |
| 325 | print_dbg("fb_pan_display 2 %p %p", var, fbi); |
| 326 | dy = var->yoffset - fbi->var.yoffset; |
| 327 | if (dy) { |
| 328 | |
| 329 | u32 dmaaddr; |
| 330 | |
| 331 | print_dbg("Panning screen of %d lines", dy); |
| 332 | |
| 333 | dmaaddr = fbdev->regs->lcd_dmaaddr0; |
| 334 | dmaaddr += (fbi->fix.line_length * dy); |
| 335 | |
| 336 | /* TODO: Wait for current frame to finished */ |
| 337 | fbdev->regs->lcd_dmaaddr0 = LCD_DMA_SA_N(dmaaddr); |
| 338 | |
| 339 | if (panel_is_dual(fbdev->panel)) { |
| 340 | dmaaddr = fbdev->regs->lcd_dmaaddr1; |
| 341 | dmaaddr += (fbi->fix.line_length * dy); |
| 342 | fbdev->regs->lcd_dmaaddr0 = LCD_DMA_SA_N(dmaaddr); |
| 343 | } |
| 344 | } |
| 345 | print_dbg("fb_pan_display 3 %p %p", var, fbi); |
| 346 | |
| 347 | return 0; |
| 348 | } |
| 349 | |
| 350 | /* fb_rotate |
| 351 | * Rotate the display of this angle. This doesn't seems to be used by the core, |
| 352 | * but as our hardware supports it, so why not implementing it... |
| 353 | */ |
| 354 | void au1100fb_fb_rotate(struct fb_info *fbi, int angle) |
| 355 | { |
| 356 | struct au1100fb_device *fbdev = to_au1100fb_device(fbi); |
| 357 | |
| 358 | print_dbg("fb_rotate %p %d", fbi, angle); |
| 359 | |
| 360 | if (fbdev && (angle > 0) && !(angle % 90)) { |
| 361 | |
| 362 | fbdev->regs->lcd_control &= ~LCD_CONTROL_GO; |
| 363 | |
| 364 | fbdev->regs->lcd_control &= ~(LCD_CONTROL_SM_MASK); |
| 365 | fbdev->regs->lcd_control |= ((angle/90) << LCD_CONTROL_SM_BIT); |
| 366 | |
| 367 | fbdev->regs->lcd_control |= LCD_CONTROL_GO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 368 | } |
| 369 | } |
| 370 | |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 371 | /* fb_mmap |
| 372 | * Map video memory in user space. We don't use the generic fb_mmap method mainly |
| 373 | * to allow the use of the TLB streaming flag (CCA=6) |
| 374 | */ |
Christoph Hellwig | 216d526 | 2006-01-14 13:21:25 -0800 | [diff] [blame] | 375 | int au1100fb_fb_mmap(struct fb_info *fbi, struct vm_area_struct *vma) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 376 | { |
Rodolfo Giometti | c05b7f3 | 2006-05-30 21:26:57 -0700 | [diff] [blame] | 377 | struct au1100fb_device *fbdev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 378 | unsigned int len; |
| 379 | unsigned long start=0, off; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 380 | |
Rodolfo Giometti | c05b7f3 | 2006-05-30 21:26:57 -0700 | [diff] [blame] | 381 | fbdev = to_au1100fb_device(fbi); |
| 382 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 383 | if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT)) { |
| 384 | return -EINVAL; |
| 385 | } |
| 386 | |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 387 | start = fbdev->fb_phys & PAGE_MASK; |
| 388 | len = PAGE_ALIGN((start & ~PAGE_MASK) + fbdev->fb_len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | |
| 390 | off = vma->vm_pgoff << PAGE_SHIFT; |
| 391 | |
| 392 | if ((vma->vm_end - vma->vm_start + off) > len) { |
| 393 | return -EINVAL; |
| 394 | } |
| 395 | |
| 396 | off += start; |
| 397 | vma->vm_pgoff = off >> PAGE_SHIFT; |
| 398 | |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 399 | vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 400 | pgprot_val(vma->vm_page_prot) |= (6 << 9); //CCA=6 |
| 401 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 402 | vma->vm_flags |= VM_IO; |
| 403 | |
Freddy Spierenburg | cacfc8c | 2006-02-24 13:04:17 -0800 | [diff] [blame] | 404 | if (io_remap_pfn_range(vma, vma->vm_start, off >> PAGE_SHIFT, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 405 | vma->vm_end - vma->vm_start, |
| 406 | vma->vm_page_prot)) { |
| 407 | return -EAGAIN; |
| 408 | } |
| 409 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 410 | return 0; |
| 411 | } |
| 412 | |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 413 | static struct fb_ops au1100fb_ops = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 414 | { |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 415 | .owner = THIS_MODULE, |
| 416 | .fb_setcolreg = au1100fb_fb_setcolreg, |
| 417 | .fb_blank = au1100fb_fb_blank, |
| 418 | .fb_pan_display = au1100fb_fb_pan_display, |
| 419 | .fb_fillrect = cfb_fillrect, |
| 420 | .fb_copyarea = cfb_copyarea, |
| 421 | .fb_imageblit = cfb_imageblit, |
| 422 | .fb_rotate = au1100fb_fb_rotate, |
| 423 | .fb_mmap = au1100fb_fb_mmap, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | }; |
| 425 | |
| 426 | |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 427 | /*-------------------------------------------------------------------------*/ |
| 428 | |
Manuel Lauss | d121c3f | 2011-09-30 20:49:43 +0200 | [diff] [blame] | 429 | static int au1100fb_setup(struct au1100fb_device *fbdev) |
| 430 | { |
| 431 | char *this_opt, *options; |
| 432 | int num_panels = ARRAY_SIZE(known_lcd_panels); |
| 433 | |
| 434 | if (num_panels <= 0) { |
| 435 | print_err("No LCD panels supported by driver!"); |
| 436 | return -ENODEV; |
| 437 | } |
| 438 | |
| 439 | if (fb_get_options(DRIVER_NAME, &options)) |
| 440 | return -ENODEV; |
| 441 | if (!options) |
| 442 | return -ENODEV; |
| 443 | |
| 444 | while ((this_opt = strsep(&options, ",")) != NULL) { |
| 445 | /* Panel option */ |
| 446 | if (!strncmp(this_opt, "panel:", 6)) { |
| 447 | int i; |
| 448 | this_opt += 6; |
| 449 | for (i = 0; i < num_panels; i++) { |
| 450 | if (!strncmp(this_opt, known_lcd_panels[i].name, |
| 451 | strlen(this_opt))) { |
| 452 | fbdev->panel = &known_lcd_panels[i]; |
| 453 | fbdev->panel_idx = i; |
| 454 | break; |
| 455 | } |
| 456 | } |
| 457 | if (i >= num_panels) { |
| 458 | print_warn("Panel '%s' not supported!", this_opt); |
| 459 | return -ENODEV; |
| 460 | } |
| 461 | } |
| 462 | /* Unsupported option */ |
| 463 | else |
| 464 | print_warn("Unsupported option \"%s\"", this_opt); |
| 465 | } |
| 466 | |
| 467 | print_info("Panel=%s", fbdev->panel->name); |
| 468 | |
| 469 | return 0; |
| 470 | } |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 471 | |
Ralf Baechle | 362992b | 2010-07-26 19:08:15 +0100 | [diff] [blame] | 472 | static int __devinit au1100fb_drv_probe(struct platform_device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 473 | { |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 474 | struct au1100fb_device *fbdev = NULL; |
| 475 | struct resource *regs_res; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 476 | unsigned long page; |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 477 | u32 sys_clksrc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 478 | |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 479 | /* Allocate new device private */ |
Manuel Lauss | d121c3f | 2011-09-30 20:49:43 +0200 | [diff] [blame] | 480 | fbdev = kzalloc(sizeof(struct au1100fb_device), GFP_KERNEL); |
| 481 | if (!fbdev) { |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 482 | print_err("fail to allocate device private record"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 483 | return -ENOMEM; |
| 484 | } |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 485 | |
Manuel Lauss | d121c3f | 2011-09-30 20:49:43 +0200 | [diff] [blame] | 486 | if (au1100fb_setup(fbdev)) |
| 487 | goto failed; |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 488 | |
Ming Lei | 7a192ec | 2009-02-06 23:40:12 +0800 | [diff] [blame] | 489 | platform_set_drvdata(dev, (void *)fbdev); |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 490 | |
| 491 | /* Allocate region for our registers and map them */ |
Manuel Lauss | d121c3f | 2011-09-30 20:49:43 +0200 | [diff] [blame] | 492 | regs_res = platform_get_resource(dev, IORESOURCE_MEM, 0); |
| 493 | if (!regs_res) { |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 494 | print_err("fail to retrieve registers resource"); |
| 495 | return -EFAULT; |
| 496 | } |
| 497 | |
| 498 | au1100fb_fix.mmio_start = regs_res->start; |
Joe Perches | 28f65c1 | 2011-06-09 09:13:32 -0700 | [diff] [blame] | 499 | au1100fb_fix.mmio_len = resource_size(regs_res); |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 500 | |
| 501 | if (!request_mem_region(au1100fb_fix.mmio_start, au1100fb_fix.mmio_len, |
| 502 | DRIVER_NAME)) { |
Rodolfo Giometti | c05b7f3 | 2006-05-30 21:26:57 -0700 | [diff] [blame] | 503 | print_err("fail to lock memory region at 0x%08lx", |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 504 | au1100fb_fix.mmio_start); |
| 505 | return -EBUSY; |
| 506 | } |
| 507 | |
| 508 | fbdev->regs = (struct au1100fb_regs*)KSEG1ADDR(au1100fb_fix.mmio_start); |
| 509 | |
| 510 | print_dbg("Register memory map at %p", fbdev->regs); |
| 511 | print_dbg("phys=0x%08x, size=%d", fbdev->regs_phys, fbdev->regs_len); |
| 512 | |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 513 | /* Allocate the framebuffer to the maximum screen size * nbr of video buffers */ |
| 514 | fbdev->fb_len = fbdev->panel->xres * fbdev->panel->yres * |
| 515 | (fbdev->panel->bpp >> 3) * AU1100FB_NBR_VIDEO_BUFFERS; |
| 516 | |
Manuel Lauss | d121c3f | 2011-09-30 20:49:43 +0200 | [diff] [blame] | 517 | fbdev->fb_mem = dma_alloc_coherent(&dev->dev, PAGE_ALIGN(fbdev->fb_len), |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 518 | &fbdev->fb_phys, GFP_KERNEL); |
| 519 | if (!fbdev->fb_mem) { |
| 520 | print_err("fail to allocate frambuffer (size: %dK))", |
| 521 | fbdev->fb_len / 1024); |
| 522 | return -ENOMEM; |
| 523 | } |
| 524 | |
| 525 | au1100fb_fix.smem_start = fbdev->fb_phys; |
| 526 | au1100fb_fix.smem_len = fbdev->fb_len; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 527 | |
| 528 | /* |
| 529 | * Set page reserved so that mmap will work. This is necessary |
| 530 | * since we'll be remapping normal memory. |
| 531 | */ |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 532 | for (page = (unsigned long)fbdev->fb_mem; |
| 533 | page < PAGE_ALIGN((unsigned long)fbdev->fb_mem + fbdev->fb_len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 534 | page += PAGE_SIZE) { |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 535 | #if CONFIG_DMA_NONCOHERENT |
Manuel Lauss | d121c3f | 2011-09-30 20:49:43 +0200 | [diff] [blame] | 536 | SetPageReserved(virt_to_page(CAC_ADDR((void *)page))); |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 537 | #else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 538 | SetPageReserved(virt_to_page(page)); |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 539 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 540 | } |
| 541 | |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 542 | print_dbg("Framebuffer memory map at %p", fbdev->fb_mem); |
| 543 | print_dbg("phys=0x%08x, size=%dK", fbdev->fb_phys, fbdev->fb_len / 1024); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 544 | |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 545 | /* Setup LCD clock to AUX (48 MHz) */ |
| 546 | sys_clksrc = au_readl(SYS_CLKSRC) & ~(SYS_CS_ML_MASK | SYS_CS_DL | SYS_CS_CL); |
| 547 | au_writel((sys_clksrc | (1 << SYS_CS_ML_BIT)), SYS_CLKSRC); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 548 | |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 549 | /* load the panel info into the var struct */ |
| 550 | au1100fb_var.bits_per_pixel = fbdev->panel->bpp; |
| 551 | au1100fb_var.xres = fbdev->panel->xres; |
| 552 | au1100fb_var.xres_virtual = au1100fb_var.xres; |
| 553 | au1100fb_var.yres = fbdev->panel->yres; |
| 554 | au1100fb_var.yres_virtual = au1100fb_var.yres; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 555 | |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 556 | fbdev->info.screen_base = fbdev->fb_mem; |
| 557 | fbdev->info.fbops = &au1100fb_ops; |
| 558 | fbdev->info.fix = au1100fb_fix; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 559 | |
Jiri Slaby | f5610b9 | 2007-02-12 00:55:12 -0800 | [diff] [blame] | 560 | if (!(fbdev->info.pseudo_palette = kzalloc(sizeof(u32) * 16, GFP_KERNEL))) { |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 561 | return -ENOMEM; |
| 562 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 563 | |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 564 | if (fb_alloc_cmap(&fbdev->info.cmap, AU1100_LCD_NBR_PALETTE_ENTRIES, 0) < 0) { |
| 565 | print_err("Fail to allocate colormap (%d entries)", |
| 566 | AU1100_LCD_NBR_PALETTE_ENTRIES); |
| 567 | kfree(fbdev->info.pseudo_palette); |
| 568 | return -EFAULT; |
| 569 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 570 | |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 571 | fbdev->info.var = au1100fb_var; |
| 572 | |
| 573 | /* Set h/w registers */ |
| 574 | au1100fb_setmode(fbdev); |
| 575 | |
| 576 | /* Register new framebuffer */ |
| 577 | if (register_framebuffer(&fbdev->info) < 0) { |
| 578 | print_err("cannot register new framebuffer"); |
| 579 | goto failed; |
| 580 | } |
| 581 | |
| 582 | return 0; |
| 583 | |
| 584 | failed: |
| 585 | if (fbdev->regs) { |
| 586 | release_mem_region(fbdev->regs_phys, fbdev->regs_len); |
| 587 | } |
| 588 | if (fbdev->fb_mem) { |
Manuel Lauss | d121c3f | 2011-09-30 20:49:43 +0200 | [diff] [blame] | 589 | dma_free_noncoherent(&dev->dev, fbdev->fb_len, fbdev->fb_mem, |
| 590 | fbdev->fb_phys); |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 591 | } |
| 592 | if (fbdev->info.cmap.len != 0) { |
| 593 | fb_dealloc_cmap(&fbdev->info.cmap); |
| 594 | } |
| 595 | kfree(fbdev); |
Ming Lei | 7a192ec | 2009-02-06 23:40:12 +0800 | [diff] [blame] | 596 | platform_set_drvdata(dev, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 597 | |
| 598 | return 0; |
| 599 | } |
| 600 | |
Ming Lei | 7a192ec | 2009-02-06 23:40:12 +0800 | [diff] [blame] | 601 | int au1100fb_drv_remove(struct platform_device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 602 | { |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 603 | struct au1100fb_device *fbdev = NULL; |
| 604 | |
| 605 | if (!dev) |
| 606 | return -ENODEV; |
| 607 | |
Ming Lei | 7a192ec | 2009-02-06 23:40:12 +0800 | [diff] [blame] | 608 | fbdev = (struct au1100fb_device *) platform_get_drvdata(dev); |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 609 | |
| 610 | #if !defined(CONFIG_FRAMEBUFFER_CONSOLE) && defined(CONFIG_LOGO) |
| 611 | au1100fb_fb_blank(VESA_POWERDOWN, &fbdev->info); |
| 612 | #endif |
| 613 | fbdev->regs->lcd_control &= ~LCD_CONTROL_GO; |
| 614 | |
| 615 | /* Clean up all probe data */ |
| 616 | unregister_framebuffer(&fbdev->info); |
| 617 | |
| 618 | release_mem_region(fbdev->regs_phys, fbdev->regs_len); |
| 619 | |
Manuel Lauss | d121c3f | 2011-09-30 20:49:43 +0200 | [diff] [blame] | 620 | dma_free_coherent(&dev->dev, PAGE_ALIGN(fbdev->fb_len), fbdev->fb_mem, |
| 621 | fbdev->fb_phys); |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 622 | |
| 623 | fb_dealloc_cmap(&fbdev->info.cmap); |
| 624 | kfree(fbdev->info.pseudo_palette); |
| 625 | kfree((void*)fbdev); |
| 626 | |
| 627 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 628 | } |
| 629 | |
Rodolfo Giometti | f77f50c | 2006-06-26 00:26:49 -0700 | [diff] [blame] | 630 | #ifdef CONFIG_PM |
| 631 | static u32 sys_clksrc; |
| 632 | static struct au1100fb_regs fbregs; |
| 633 | |
Ming Lei | 7a192ec | 2009-02-06 23:40:12 +0800 | [diff] [blame] | 634 | int au1100fb_drv_suspend(struct platform_device *dev, pm_message_t state) |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 635 | { |
Ming Lei | 7a192ec | 2009-02-06 23:40:12 +0800 | [diff] [blame] | 636 | struct au1100fb_device *fbdev = platform_get_drvdata(dev); |
Rodolfo Giometti | f77f50c | 2006-06-26 00:26:49 -0700 | [diff] [blame] | 637 | |
| 638 | if (!fbdev) |
| 639 | return 0; |
| 640 | |
| 641 | /* Save the clock source state */ |
| 642 | sys_clksrc = au_readl(SYS_CLKSRC); |
| 643 | |
| 644 | /* Blank the LCD */ |
| 645 | au1100fb_fb_blank(VESA_POWERDOWN, &fbdev->info); |
| 646 | |
| 647 | /* Stop LCD clocking */ |
| 648 | au_writel(sys_clksrc & ~SYS_CS_ML_MASK, SYS_CLKSRC); |
| 649 | |
| 650 | memcpy(&fbregs, fbdev->regs, sizeof(struct au1100fb_regs)); |
| 651 | |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 652 | return 0; |
| 653 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 654 | |
Ming Lei | 7a192ec | 2009-02-06 23:40:12 +0800 | [diff] [blame] | 655 | int au1100fb_drv_resume(struct platform_device *dev) |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 656 | { |
Ming Lei | 7a192ec | 2009-02-06 23:40:12 +0800 | [diff] [blame] | 657 | struct au1100fb_device *fbdev = platform_get_drvdata(dev); |
Rodolfo Giometti | f77f50c | 2006-06-26 00:26:49 -0700 | [diff] [blame] | 658 | |
| 659 | if (!fbdev) |
| 660 | return 0; |
| 661 | |
| 662 | memcpy(fbdev->regs, &fbregs, sizeof(struct au1100fb_regs)); |
| 663 | |
| 664 | /* Restart LCD clocking */ |
| 665 | au_writel(sys_clksrc, SYS_CLKSRC); |
| 666 | |
| 667 | /* Unblank the LCD */ |
| 668 | au1100fb_fb_blank(VESA_NO_BLANKING, &fbdev->info); |
| 669 | |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 670 | return 0; |
| 671 | } |
Rodolfo Giometti | f77f50c | 2006-06-26 00:26:49 -0700 | [diff] [blame] | 672 | #else |
| 673 | #define au1100fb_drv_suspend NULL |
| 674 | #define au1100fb_drv_resume NULL |
| 675 | #endif |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 676 | |
Ming Lei | 7a192ec | 2009-02-06 23:40:12 +0800 | [diff] [blame] | 677 | static struct platform_driver au1100fb_driver = { |
| 678 | .driver = { |
| 679 | .name = "au1100-lcd", |
| 680 | .owner = THIS_MODULE, |
| 681 | }, |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 682 | .probe = au1100fb_drv_probe, |
| 683 | .remove = au1100fb_drv_remove, |
| 684 | .suspend = au1100fb_drv_suspend, |
| 685 | .resume = au1100fb_drv_resume, |
| 686 | }; |
| 687 | |
Manuel Lauss | d121c3f | 2011-09-30 20:49:43 +0200 | [diff] [blame] | 688 | static int __init au1100fb_load(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 689 | { |
Ming Lei | 7a192ec | 2009-02-06 23:40:12 +0800 | [diff] [blame] | 690 | return platform_driver_register(&au1100fb_driver); |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 691 | } |
| 692 | |
Manuel Lauss | d121c3f | 2011-09-30 20:49:43 +0200 | [diff] [blame] | 693 | static void __exit au1100fb_unload(void) |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 694 | { |
Ming Lei | 7a192ec | 2009-02-06 23:40:12 +0800 | [diff] [blame] | 695 | platform_driver_unregister(&au1100fb_driver); |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 696 | } |
| 697 | |
Manuel Lauss | d121c3f | 2011-09-30 20:49:43 +0200 | [diff] [blame] | 698 | module_init(au1100fb_load); |
| 699 | module_exit(au1100fb_unload); |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 700 | |
| 701 | MODULE_DESCRIPTION(DRIVER_DESC); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 702 | MODULE_LICENSE("GPL"); |