Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008-2009 MontaVista Software Inc. |
| 3 | * Copyright (C) 2008-2009 Texas Instruments Inc |
| 4 | * |
| 5 | * Based on the LCD driver for TI Avalanche processors written by |
| 6 | * Ajay Singh and Shalom Hai. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option)any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 21 | */ |
| 22 | #include <linux/module.h> |
| 23 | #include <linux/kernel.h> |
| 24 | #include <linux/fb.h> |
| 25 | #include <linux/dma-mapping.h> |
| 26 | #include <linux/device.h> |
| 27 | #include <linux/platform_device.h> |
| 28 | #include <linux/uaccess.h> |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 29 | #include <linux/interrupt.h> |
| 30 | #include <linux/clk.h> |
Chaithrika U S | e04e548 | 2009-12-15 16:46:29 -0800 | [diff] [blame] | 31 | #include <linux/cpufreq.h> |
Chaithrika U S | 1d3c6c7 | 2009-12-15 16:46:39 -0800 | [diff] [blame] | 32 | #include <linux/console.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 33 | #include <linux/slab.h> |
Aditya Nellutla | 3b9cc4e | 2012-05-23 11:36:31 +0530 | [diff] [blame] | 34 | #include <linux/lcm.h> |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 35 | #include <video/da8xx-fb.h> |
Manjunathappa, Prakash | 12fa835 | 2012-02-09 11:54:06 +0530 | [diff] [blame] | 36 | #include <asm/div64.h> |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 37 | |
| 38 | #define DRIVER_NAME "da8xx_lcdc" |
| 39 | |
Manjunathappa, Prakash | c6daf05 | 2011-07-05 15:51:20 +0530 | [diff] [blame] | 40 | #define LCD_VERSION_1 1 |
| 41 | #define LCD_VERSION_2 2 |
| 42 | |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 43 | /* LCD Status Register */ |
Martin Ambrose | 1f9c3e1 | 2010-05-24 14:34:01 -0700 | [diff] [blame] | 44 | #define LCD_END_OF_FRAME1 BIT(9) |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 45 | #define LCD_END_OF_FRAME0 BIT(8) |
Martin Ambrose | 1f9c3e1 | 2010-05-24 14:34:01 -0700 | [diff] [blame] | 46 | #define LCD_PL_LOAD_DONE BIT(6) |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 47 | #define LCD_FIFO_UNDERFLOW BIT(5) |
| 48 | #define LCD_SYNC_LOST BIT(2) |
| 49 | |
| 50 | /* LCD DMA Control Register */ |
| 51 | #define LCD_DMA_BURST_SIZE(x) ((x) << 4) |
| 52 | #define LCD_DMA_BURST_1 0x0 |
| 53 | #define LCD_DMA_BURST_2 0x1 |
| 54 | #define LCD_DMA_BURST_4 0x2 |
| 55 | #define LCD_DMA_BURST_8 0x3 |
| 56 | #define LCD_DMA_BURST_16 0x4 |
Manjunathappa, Prakash | c6daf05 | 2011-07-05 15:51:20 +0530 | [diff] [blame] | 57 | #define LCD_V1_END_OF_FRAME_INT_ENA BIT(2) |
| 58 | #define LCD_V2_END_OF_FRAME0_INT_ENA BIT(8) |
| 59 | #define LCD_V2_END_OF_FRAME1_INT_ENA BIT(9) |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 60 | #define LCD_DUAL_FRAME_BUFFER_ENABLE BIT(0) |
| 61 | |
| 62 | /* LCD Control Register */ |
| 63 | #define LCD_CLK_DIVISOR(x) ((x) << 8) |
| 64 | #define LCD_RASTER_MODE 0x01 |
| 65 | |
| 66 | /* LCD Raster Control Register */ |
| 67 | #define LCD_PALETTE_LOAD_MODE(x) ((x) << 20) |
| 68 | #define PALETTE_AND_DATA 0x00 |
| 69 | #define PALETTE_ONLY 0x01 |
Martin Ambrose | 1f9c3e1 | 2010-05-24 14:34:01 -0700 | [diff] [blame] | 70 | #define DATA_ONLY 0x02 |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 71 | |
| 72 | #define LCD_MONO_8BIT_MODE BIT(9) |
| 73 | #define LCD_RASTER_ORDER BIT(8) |
| 74 | #define LCD_TFT_MODE BIT(7) |
Manjunathappa, Prakash | c6daf05 | 2011-07-05 15:51:20 +0530 | [diff] [blame] | 75 | #define LCD_V1_UNDERFLOW_INT_ENA BIT(6) |
| 76 | #define LCD_V2_UNDERFLOW_INT_ENA BIT(5) |
| 77 | #define LCD_V1_PL_INT_ENA BIT(4) |
| 78 | #define LCD_V2_PL_INT_ENA BIT(6) |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 79 | #define LCD_MONOCHROME_MODE BIT(1) |
| 80 | #define LCD_RASTER_ENABLE BIT(0) |
| 81 | #define LCD_TFT_ALT_ENABLE BIT(23) |
| 82 | #define LCD_STN_565_ENABLE BIT(24) |
Manjunathappa, Prakash | c6daf05 | 2011-07-05 15:51:20 +0530 | [diff] [blame] | 83 | #define LCD_V2_DMA_CLK_EN BIT(2) |
| 84 | #define LCD_V2_LIDD_CLK_EN BIT(1) |
| 85 | #define LCD_V2_CORE_CLK_EN BIT(0) |
| 86 | #define LCD_V2_LPP_B10 26 |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 87 | |
| 88 | /* LCD Raster Timing 2 Register */ |
| 89 | #define LCD_AC_BIAS_TRANSITIONS_PER_INT(x) ((x) << 16) |
| 90 | #define LCD_AC_BIAS_FREQUENCY(x) ((x) << 8) |
| 91 | #define LCD_SYNC_CTRL BIT(25) |
| 92 | #define LCD_SYNC_EDGE BIT(24) |
| 93 | #define LCD_INVERT_PIXEL_CLOCK BIT(22) |
| 94 | #define LCD_INVERT_LINE_CLOCK BIT(21) |
| 95 | #define LCD_INVERT_FRAME_CLOCK BIT(20) |
| 96 | |
| 97 | /* LCD Block */ |
Manjunathappa, Prakash | c6daf05 | 2011-07-05 15:51:20 +0530 | [diff] [blame] | 98 | #define LCD_PID_REG 0x0 |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 99 | #define LCD_CTRL_REG 0x4 |
| 100 | #define LCD_STAT_REG 0x8 |
| 101 | #define LCD_RASTER_CTRL_REG 0x28 |
| 102 | #define LCD_RASTER_TIMING_0_REG 0x2C |
| 103 | #define LCD_RASTER_TIMING_1_REG 0x30 |
| 104 | #define LCD_RASTER_TIMING_2_REG 0x34 |
| 105 | #define LCD_DMA_CTRL_REG 0x40 |
| 106 | #define LCD_DMA_FRM_BUF_BASE_ADDR_0_REG 0x44 |
| 107 | #define LCD_DMA_FRM_BUF_CEILING_ADDR_0_REG 0x48 |
Martin Ambrose | 1f9c3e1 | 2010-05-24 14:34:01 -0700 | [diff] [blame] | 108 | #define LCD_DMA_FRM_BUF_BASE_ADDR_1_REG 0x4C |
| 109 | #define LCD_DMA_FRM_BUF_CEILING_ADDR_1_REG 0x50 |
| 110 | |
Manjunathappa, Prakash | c6daf05 | 2011-07-05 15:51:20 +0530 | [diff] [blame] | 111 | /* Interrupt Registers available only in Version 2 */ |
| 112 | #define LCD_RAW_STAT_REG 0x58 |
| 113 | #define LCD_MASKED_STAT_REG 0x5c |
| 114 | #define LCD_INT_ENABLE_SET_REG 0x60 |
| 115 | #define LCD_INT_ENABLE_CLR_REG 0x64 |
| 116 | #define LCD_END_OF_INT_IND_REG 0x68 |
| 117 | |
| 118 | /* Clock registers available only on Version 2 */ |
| 119 | #define LCD_CLK_ENABLE_REG 0x6c |
| 120 | #define LCD_CLK_RESET_REG 0x70 |
Manjunathappa, Prakash | 74a0efd | 2011-11-15 17:32:23 +0530 | [diff] [blame] | 121 | #define LCD_CLK_MAIN_RESET BIT(3) |
Manjunathappa, Prakash | c6daf05 | 2011-07-05 15:51:20 +0530 | [diff] [blame] | 122 | |
Martin Ambrose | 1f9c3e1 | 2010-05-24 14:34:01 -0700 | [diff] [blame] | 123 | #define LCD_NUM_BUFFERS 2 |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 124 | |
| 125 | #define WSI_TIMEOUT 50 |
| 126 | #define PALETTE_SIZE 256 |
| 127 | #define LEFT_MARGIN 64 |
| 128 | #define RIGHT_MARGIN 64 |
| 129 | #define UPPER_MARGIN 32 |
| 130 | #define LOWER_MARGIN 32 |
| 131 | |
| 132 | static resource_size_t da8xx_fb_reg_base; |
| 133 | static struct resource *lcdc_regs; |
Manjunathappa, Prakash | c6daf05 | 2011-07-05 15:51:20 +0530 | [diff] [blame] | 134 | static unsigned int lcd_revision; |
| 135 | static irq_handler_t lcdc_irq_handler; |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 136 | |
| 137 | static inline unsigned int lcdc_read(unsigned int addr) |
| 138 | { |
| 139 | return (unsigned int)__raw_readl(da8xx_fb_reg_base + (addr)); |
| 140 | } |
| 141 | |
| 142 | static inline void lcdc_write(unsigned int val, unsigned int addr) |
| 143 | { |
| 144 | __raw_writel(val, da8xx_fb_reg_base + (addr)); |
| 145 | } |
| 146 | |
| 147 | struct da8xx_fb_par { |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 148 | resource_size_t p_palette_base; |
| 149 | unsigned char *v_palette_base; |
Martin Ambrose | 1f9c3e1 | 2010-05-24 14:34:01 -0700 | [diff] [blame] | 150 | dma_addr_t vram_phys; |
| 151 | unsigned long vram_size; |
| 152 | void *vram_virt; |
| 153 | unsigned int dma_start; |
| 154 | unsigned int dma_end; |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 155 | struct clk *lcdc_clk; |
| 156 | int irq; |
| 157 | unsigned short pseudo_palette[16]; |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 158 | unsigned int palette_sz; |
Chaithrika U S | 8097b17 | 2009-12-15 16:46:29 -0800 | [diff] [blame] | 159 | unsigned int pxl_clk; |
Chaithrika U S | 3611380 | 2009-12-15 16:46:38 -0800 | [diff] [blame] | 160 | int blank; |
Martin Ambrose | 1f9c3e1 | 2010-05-24 14:34:01 -0700 | [diff] [blame] | 161 | wait_queue_head_t vsync_wait; |
| 162 | int vsync_flag; |
| 163 | int vsync_timeout; |
Chaithrika U S | e04e548 | 2009-12-15 16:46:29 -0800 | [diff] [blame] | 164 | #ifdef CONFIG_CPU_FREQ |
| 165 | struct notifier_block freq_transition; |
Manjunathappa, Prakash | f820917 | 2012-01-03 18:10:51 +0530 | [diff] [blame] | 166 | unsigned int lcd_fck_rate; |
Chaithrika U S | e04e548 | 2009-12-15 16:46:29 -0800 | [diff] [blame] | 167 | #endif |
Chaithrika U S | 3611380 | 2009-12-15 16:46:38 -0800 | [diff] [blame] | 168 | void (*panel_power_ctrl)(int); |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 169 | }; |
| 170 | |
| 171 | /* Variable Screen Information */ |
| 172 | static struct fb_var_screeninfo da8xx_fb_var __devinitdata = { |
| 173 | .xoffset = 0, |
| 174 | .yoffset = 0, |
| 175 | .transp = {0, 0, 0}, |
| 176 | .nonstd = 0, |
| 177 | .activate = 0, |
| 178 | .height = -1, |
| 179 | .width = -1, |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 180 | .accel_flags = 0, |
| 181 | .left_margin = LEFT_MARGIN, |
| 182 | .right_margin = RIGHT_MARGIN, |
| 183 | .upper_margin = UPPER_MARGIN, |
| 184 | .lower_margin = LOWER_MARGIN, |
| 185 | .sync = 0, |
| 186 | .vmode = FB_VMODE_NONINTERLACED |
| 187 | }; |
| 188 | |
| 189 | static struct fb_fix_screeninfo da8xx_fb_fix __devinitdata = { |
| 190 | .id = "DA8xx FB Drv", |
| 191 | .type = FB_TYPE_PACKED_PIXELS, |
| 192 | .type_aux = 0, |
| 193 | .visual = FB_VISUAL_PSEUDOCOLOR, |
Martin Ambrose | 1f9c3e1 | 2010-05-24 14:34:01 -0700 | [diff] [blame] | 194 | .xpanstep = 0, |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 195 | .ypanstep = 1, |
Martin Ambrose | 1f9c3e1 | 2010-05-24 14:34:01 -0700 | [diff] [blame] | 196 | .ywrapstep = 0, |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 197 | .accel = FB_ACCEL_NONE |
| 198 | }; |
| 199 | |
| 200 | struct da8xx_panel { |
| 201 | const char name[25]; /* Full name <vendor>_<model> */ |
| 202 | unsigned short width; |
| 203 | unsigned short height; |
| 204 | int hfp; /* Horizontal front porch */ |
| 205 | int hbp; /* Horizontal back porch */ |
| 206 | int hsw; /* Horizontal Sync Pulse Width */ |
| 207 | int vfp; /* Vertical front porch */ |
| 208 | int vbp; /* Vertical back porch */ |
| 209 | int vsw; /* Vertical Sync Pulse Width */ |
Chaithrika U S | 8097b17 | 2009-12-15 16:46:29 -0800 | [diff] [blame] | 210 | unsigned int pxl_clk; /* Pixel clock */ |
Sudhakar Rajashekhara | 2f93e8f | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 211 | unsigned char invert_pxl_clk; /* Invert Pixel clock */ |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 212 | }; |
| 213 | |
| 214 | static struct da8xx_panel known_lcd_panels[] = { |
| 215 | /* Sharp LCD035Q3DG01 */ |
| 216 | [0] = { |
| 217 | .name = "Sharp_LCD035Q3DG01", |
| 218 | .width = 320, |
| 219 | .height = 240, |
| 220 | .hfp = 8, |
| 221 | .hbp = 6, |
| 222 | .hsw = 0, |
| 223 | .vfp = 2, |
| 224 | .vbp = 2, |
| 225 | .vsw = 0, |
Chaithrika U S | 8097b17 | 2009-12-15 16:46:29 -0800 | [diff] [blame] | 226 | .pxl_clk = 4608000, |
Sudhakar Rajashekhara | 2f93e8f | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 227 | .invert_pxl_clk = 1, |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 228 | }, |
| 229 | /* Sharp LK043T1DG01 */ |
| 230 | [1] = { |
| 231 | .name = "Sharp_LK043T1DG01", |
| 232 | .width = 480, |
| 233 | .height = 272, |
| 234 | .hfp = 2, |
| 235 | .hbp = 2, |
| 236 | .hsw = 41, |
| 237 | .vfp = 2, |
| 238 | .vbp = 2, |
| 239 | .vsw = 10, |
Chaithrika U S | 8097b17 | 2009-12-15 16:46:29 -0800 | [diff] [blame] | 240 | .pxl_clk = 7833600, |
Sudhakar Rajashekhara | 2f93e8f | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 241 | .invert_pxl_clk = 0, |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 242 | }, |
Anatolij Gustschin | f413070 | 2012-03-13 14:13:57 +0100 | [diff] [blame] | 243 | [2] = { |
| 244 | /* Hitachi SP10Q010 */ |
| 245 | .name = "SP10Q010", |
| 246 | .width = 320, |
| 247 | .height = 240, |
| 248 | .hfp = 10, |
| 249 | .hbp = 10, |
| 250 | .hsw = 10, |
| 251 | .vfp = 10, |
| 252 | .vbp = 10, |
| 253 | .vsw = 10, |
| 254 | .pxl_clk = 7833600, |
| 255 | .invert_pxl_clk = 0, |
| 256 | }, |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 257 | }; |
| 258 | |
Chaithrika U S | 3611380 | 2009-12-15 16:46:38 -0800 | [diff] [blame] | 259 | /* Enable the Raster Engine of the LCD Controller */ |
| 260 | static inline void lcd_enable_raster(void) |
| 261 | { |
| 262 | u32 reg; |
| 263 | |
Manjunathappa, Prakash | 74a0efd | 2011-11-15 17:32:23 +0530 | [diff] [blame] | 264 | /* Bring LCDC out of reset */ |
| 265 | if (lcd_revision == LCD_VERSION_2) |
| 266 | lcdc_write(0, LCD_CLK_RESET_REG); |
| 267 | |
Chaithrika U S | 3611380 | 2009-12-15 16:46:38 -0800 | [diff] [blame] | 268 | reg = lcdc_read(LCD_RASTER_CTRL_REG); |
| 269 | if (!(reg & LCD_RASTER_ENABLE)) |
| 270 | lcdc_write(reg | LCD_RASTER_ENABLE, LCD_RASTER_CTRL_REG); |
| 271 | } |
| 272 | |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 273 | /* Disable the Raster Engine of the LCD Controller */ |
Chaithrika U S | 3611380 | 2009-12-15 16:46:38 -0800 | [diff] [blame] | 274 | static inline void lcd_disable_raster(void) |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 275 | { |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 276 | u32 reg; |
| 277 | |
| 278 | reg = lcdc_read(LCD_RASTER_CTRL_REG); |
Sudhakar Rajashekhara | 2f93e8f | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 279 | if (reg & LCD_RASTER_ENABLE) |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 280 | lcdc_write(reg & ~LCD_RASTER_ENABLE, LCD_RASTER_CTRL_REG); |
Manjunathappa, Prakash | 74a0efd | 2011-11-15 17:32:23 +0530 | [diff] [blame] | 281 | |
| 282 | if (lcd_revision == LCD_VERSION_2) |
| 283 | /* Write 1 to reset LCDC */ |
| 284 | lcdc_write(LCD_CLK_MAIN_RESET, LCD_CLK_RESET_REG); |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 285 | } |
| 286 | |
| 287 | static void lcd_blit(int load_mode, struct da8xx_fb_par *par) |
| 288 | { |
Martin Ambrose | 1f9c3e1 | 2010-05-24 14:34:01 -0700 | [diff] [blame] | 289 | u32 start; |
| 290 | u32 end; |
| 291 | u32 reg_ras; |
| 292 | u32 reg_dma; |
Manjunathappa, Prakash | c6daf05 | 2011-07-05 15:51:20 +0530 | [diff] [blame] | 293 | u32 reg_int; |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 294 | |
Martin Ambrose | 1f9c3e1 | 2010-05-24 14:34:01 -0700 | [diff] [blame] | 295 | /* init reg to clear PLM (loading mode) fields */ |
| 296 | reg_ras = lcdc_read(LCD_RASTER_CTRL_REG); |
| 297 | reg_ras &= ~(3 << 20); |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 298 | |
Martin Ambrose | 1f9c3e1 | 2010-05-24 14:34:01 -0700 | [diff] [blame] | 299 | reg_dma = lcdc_read(LCD_DMA_CTRL_REG); |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 300 | |
Martin Ambrose | 1f9c3e1 | 2010-05-24 14:34:01 -0700 | [diff] [blame] | 301 | if (load_mode == LOAD_DATA) { |
| 302 | start = par->dma_start; |
| 303 | end = par->dma_end; |
| 304 | |
| 305 | reg_ras |= LCD_PALETTE_LOAD_MODE(DATA_ONLY); |
Manjunathappa, Prakash | c6daf05 | 2011-07-05 15:51:20 +0530 | [diff] [blame] | 306 | if (lcd_revision == LCD_VERSION_1) { |
| 307 | reg_dma |= LCD_V1_END_OF_FRAME_INT_ENA; |
| 308 | } else { |
| 309 | reg_int = lcdc_read(LCD_INT_ENABLE_SET_REG) | |
| 310 | LCD_V2_END_OF_FRAME0_INT_ENA | |
| 311 | LCD_V2_END_OF_FRAME1_INT_ENA; |
| 312 | lcdc_write(reg_int, LCD_INT_ENABLE_SET_REG); |
| 313 | } |
Martin Ambrose | 1f9c3e1 | 2010-05-24 14:34:01 -0700 | [diff] [blame] | 314 | reg_dma |= LCD_DUAL_FRAME_BUFFER_ENABLE; |
| 315 | |
| 316 | lcdc_write(start, LCD_DMA_FRM_BUF_BASE_ADDR_0_REG); |
| 317 | lcdc_write(end, LCD_DMA_FRM_BUF_CEILING_ADDR_0_REG); |
| 318 | lcdc_write(start, LCD_DMA_FRM_BUF_BASE_ADDR_1_REG); |
| 319 | lcdc_write(end, LCD_DMA_FRM_BUF_CEILING_ADDR_1_REG); |
| 320 | } else if (load_mode == LOAD_PALETTE) { |
| 321 | start = par->p_palette_base; |
| 322 | end = start + par->palette_sz - 1; |
| 323 | |
| 324 | reg_ras |= LCD_PALETTE_LOAD_MODE(PALETTE_ONLY); |
Manjunathappa, Prakash | c6daf05 | 2011-07-05 15:51:20 +0530 | [diff] [blame] | 325 | |
| 326 | if (lcd_revision == LCD_VERSION_1) { |
| 327 | reg_ras |= LCD_V1_PL_INT_ENA; |
| 328 | } else { |
| 329 | reg_int = lcdc_read(LCD_INT_ENABLE_SET_REG) | |
| 330 | LCD_V2_PL_INT_ENA; |
| 331 | lcdc_write(reg_int, LCD_INT_ENABLE_SET_REG); |
| 332 | } |
Martin Ambrose | 1f9c3e1 | 2010-05-24 14:34:01 -0700 | [diff] [blame] | 333 | |
| 334 | lcdc_write(start, LCD_DMA_FRM_BUF_BASE_ADDR_0_REG); |
| 335 | lcdc_write(end, LCD_DMA_FRM_BUF_CEILING_ADDR_0_REG); |
| 336 | } |
| 337 | |
| 338 | lcdc_write(reg_dma, LCD_DMA_CTRL_REG); |
| 339 | lcdc_write(reg_ras, LCD_RASTER_CTRL_REG); |
| 340 | |
| 341 | /* |
| 342 | * The Raster enable bit must be set after all other control fields are |
| 343 | * set. |
| 344 | */ |
| 345 | lcd_enable_raster(); |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 346 | } |
| 347 | |
| 348 | /* Configure the Burst Size of DMA */ |
| 349 | static int lcd_cfg_dma(int burst_size) |
| 350 | { |
| 351 | u32 reg; |
| 352 | |
| 353 | reg = lcdc_read(LCD_DMA_CTRL_REG) & 0x00000001; |
| 354 | switch (burst_size) { |
| 355 | case 1: |
| 356 | reg |= LCD_DMA_BURST_SIZE(LCD_DMA_BURST_1); |
| 357 | break; |
| 358 | case 2: |
| 359 | reg |= LCD_DMA_BURST_SIZE(LCD_DMA_BURST_2); |
| 360 | break; |
| 361 | case 4: |
| 362 | reg |= LCD_DMA_BURST_SIZE(LCD_DMA_BURST_4); |
| 363 | break; |
| 364 | case 8: |
| 365 | reg |= LCD_DMA_BURST_SIZE(LCD_DMA_BURST_8); |
| 366 | break; |
| 367 | case 16: |
| 368 | reg |= LCD_DMA_BURST_SIZE(LCD_DMA_BURST_16); |
| 369 | break; |
| 370 | default: |
| 371 | return -EINVAL; |
| 372 | } |
Sudhakar Rajashekhara | 2f93e8f | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 373 | lcdc_write(reg, LCD_DMA_CTRL_REG); |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 374 | |
| 375 | return 0; |
| 376 | } |
| 377 | |
| 378 | static void lcd_cfg_ac_bias(int period, int transitions_per_int) |
| 379 | { |
| 380 | u32 reg; |
| 381 | |
| 382 | /* Set the AC Bias Period and Number of Transisitons per Interrupt */ |
| 383 | reg = lcdc_read(LCD_RASTER_TIMING_2_REG) & 0xFFF00000; |
| 384 | reg |= LCD_AC_BIAS_FREQUENCY(period) | |
| 385 | LCD_AC_BIAS_TRANSITIONS_PER_INT(transitions_per_int); |
| 386 | lcdc_write(reg, LCD_RASTER_TIMING_2_REG); |
| 387 | } |
| 388 | |
| 389 | static void lcd_cfg_horizontal_sync(int back_porch, int pulse_width, |
| 390 | int front_porch) |
| 391 | { |
| 392 | u32 reg; |
| 393 | |
| 394 | reg = lcdc_read(LCD_RASTER_TIMING_0_REG) & 0xf; |
| 395 | reg |= ((back_porch & 0xff) << 24) |
| 396 | | ((front_porch & 0xff) << 16) |
| 397 | | ((pulse_width & 0x3f) << 10); |
| 398 | lcdc_write(reg, LCD_RASTER_TIMING_0_REG); |
| 399 | } |
| 400 | |
| 401 | static void lcd_cfg_vertical_sync(int back_porch, int pulse_width, |
| 402 | int front_porch) |
| 403 | { |
| 404 | u32 reg; |
| 405 | |
| 406 | reg = lcdc_read(LCD_RASTER_TIMING_1_REG) & 0x3ff; |
| 407 | reg |= ((back_porch & 0xff) << 24) |
| 408 | | ((front_porch & 0xff) << 16) |
| 409 | | ((pulse_width & 0x3f) << 10); |
| 410 | lcdc_write(reg, LCD_RASTER_TIMING_1_REG); |
| 411 | } |
| 412 | |
| 413 | static int lcd_cfg_display(const struct lcd_ctrl_config *cfg) |
| 414 | { |
| 415 | u32 reg; |
Manjunathappa, Prakash | c6daf05 | 2011-07-05 15:51:20 +0530 | [diff] [blame] | 416 | u32 reg_int; |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 417 | |
| 418 | reg = lcdc_read(LCD_RASTER_CTRL_REG) & ~(LCD_TFT_MODE | |
| 419 | LCD_MONO_8BIT_MODE | |
| 420 | LCD_MONOCHROME_MODE); |
| 421 | |
| 422 | switch (cfg->p_disp_panel->panel_shade) { |
| 423 | case MONOCHROME: |
| 424 | reg |= LCD_MONOCHROME_MODE; |
| 425 | if (cfg->mono_8bit_mode) |
| 426 | reg |= LCD_MONO_8BIT_MODE; |
| 427 | break; |
| 428 | case COLOR_ACTIVE: |
| 429 | reg |= LCD_TFT_MODE; |
| 430 | if (cfg->tft_alt_mode) |
| 431 | reg |= LCD_TFT_ALT_ENABLE; |
| 432 | break; |
| 433 | |
| 434 | case COLOR_PASSIVE: |
| 435 | if (cfg->stn_565_mode) |
| 436 | reg |= LCD_STN_565_ENABLE; |
| 437 | break; |
| 438 | |
| 439 | default: |
| 440 | return -EINVAL; |
| 441 | } |
| 442 | |
| 443 | /* enable additional interrupts here */ |
Manjunathappa, Prakash | c6daf05 | 2011-07-05 15:51:20 +0530 | [diff] [blame] | 444 | if (lcd_revision == LCD_VERSION_1) { |
| 445 | reg |= LCD_V1_UNDERFLOW_INT_ENA; |
| 446 | } else { |
| 447 | reg_int = lcdc_read(LCD_INT_ENABLE_SET_REG) | |
| 448 | LCD_V2_UNDERFLOW_INT_ENA; |
| 449 | lcdc_write(reg_int, LCD_INT_ENABLE_SET_REG); |
| 450 | } |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 451 | |
| 452 | lcdc_write(reg, LCD_RASTER_CTRL_REG); |
| 453 | |
| 454 | reg = lcdc_read(LCD_RASTER_TIMING_2_REG); |
| 455 | |
| 456 | if (cfg->sync_ctrl) |
| 457 | reg |= LCD_SYNC_CTRL; |
| 458 | else |
| 459 | reg &= ~LCD_SYNC_CTRL; |
| 460 | |
| 461 | if (cfg->sync_edge) |
| 462 | reg |= LCD_SYNC_EDGE; |
| 463 | else |
| 464 | reg &= ~LCD_SYNC_EDGE; |
| 465 | |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 466 | if (cfg->invert_line_clock) |
| 467 | reg |= LCD_INVERT_LINE_CLOCK; |
| 468 | else |
| 469 | reg &= ~LCD_INVERT_LINE_CLOCK; |
| 470 | |
| 471 | if (cfg->invert_frm_clock) |
| 472 | reg |= LCD_INVERT_FRAME_CLOCK; |
| 473 | else |
| 474 | reg &= ~LCD_INVERT_FRAME_CLOCK; |
| 475 | |
| 476 | lcdc_write(reg, LCD_RASTER_TIMING_2_REG); |
| 477 | |
| 478 | return 0; |
| 479 | } |
| 480 | |
| 481 | static int lcd_cfg_frame_buffer(struct da8xx_fb_par *par, u32 width, u32 height, |
| 482 | u32 bpp, u32 raster_order) |
| 483 | { |
Martin Ambrose | 1f9c3e1 | 2010-05-24 14:34:01 -0700 | [diff] [blame] | 484 | u32 reg; |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 485 | |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 486 | /* Set the Panel Width */ |
| 487 | /* Pixels per line = (PPL + 1)*16 */ |
Manjunathappa, Prakash | 4d74080 | 2011-07-18 09:58:53 +0530 | [diff] [blame] | 488 | if (lcd_revision == LCD_VERSION_1) { |
| 489 | /* |
| 490 | * 0x3F in bits 4..9 gives max horizontal resolution = 1024 |
| 491 | * pixels. |
| 492 | */ |
| 493 | width &= 0x3f0; |
| 494 | } else { |
| 495 | /* |
| 496 | * 0x7F in bits 4..10 gives max horizontal resolution = 2048 |
| 497 | * pixels. |
| 498 | */ |
| 499 | width &= 0x7f0; |
| 500 | } |
| 501 | |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 502 | reg = lcdc_read(LCD_RASTER_TIMING_0_REG); |
| 503 | reg &= 0xfffffc00; |
Manjunathappa, Prakash | 4d74080 | 2011-07-18 09:58:53 +0530 | [diff] [blame] | 504 | if (lcd_revision == LCD_VERSION_1) { |
| 505 | reg |= ((width >> 4) - 1) << 4; |
| 506 | } else { |
| 507 | width = (width >> 4) - 1; |
| 508 | reg |= ((width & 0x3f) << 4) | ((width & 0x40) >> 3); |
| 509 | } |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 510 | lcdc_write(reg, LCD_RASTER_TIMING_0_REG); |
| 511 | |
| 512 | /* Set the Panel Height */ |
Manjunathappa, Prakash | 4d74080 | 2011-07-18 09:58:53 +0530 | [diff] [blame] | 513 | /* Set bits 9:0 of Lines Per Pixel */ |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 514 | reg = lcdc_read(LCD_RASTER_TIMING_1_REG); |
| 515 | reg = ((height - 1) & 0x3ff) | (reg & 0xfffffc00); |
| 516 | lcdc_write(reg, LCD_RASTER_TIMING_1_REG); |
| 517 | |
Manjunathappa, Prakash | 4d74080 | 2011-07-18 09:58:53 +0530 | [diff] [blame] | 518 | /* Set bit 10 of Lines Per Pixel */ |
| 519 | if (lcd_revision == LCD_VERSION_2) { |
| 520 | reg = lcdc_read(LCD_RASTER_TIMING_2_REG); |
| 521 | reg |= ((height - 1) & 0x400) << 16; |
| 522 | lcdc_write(reg, LCD_RASTER_TIMING_2_REG); |
| 523 | } |
| 524 | |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 525 | /* Set the Raster Order of the Frame Buffer */ |
| 526 | reg = lcdc_read(LCD_RASTER_CTRL_REG) & ~(1 << 8); |
| 527 | if (raster_order) |
| 528 | reg |= LCD_RASTER_ORDER; |
| 529 | lcdc_write(reg, LCD_RASTER_CTRL_REG); |
| 530 | |
| 531 | switch (bpp) { |
| 532 | case 1: |
| 533 | case 2: |
| 534 | case 4: |
| 535 | case 16: |
| 536 | par->palette_sz = 16 * 2; |
| 537 | break; |
| 538 | |
| 539 | case 8: |
| 540 | par->palette_sz = 256 * 2; |
| 541 | break; |
| 542 | |
| 543 | default: |
| 544 | return -EINVAL; |
| 545 | } |
| 546 | |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 547 | return 0; |
| 548 | } |
| 549 | |
| 550 | static int fb_setcolreg(unsigned regno, unsigned red, unsigned green, |
| 551 | unsigned blue, unsigned transp, |
| 552 | struct fb_info *info) |
| 553 | { |
| 554 | struct da8xx_fb_par *par = info->par; |
Martin Ambrose | 1f9c3e1 | 2010-05-24 14:34:01 -0700 | [diff] [blame] | 555 | unsigned short *palette = (unsigned short *) par->v_palette_base; |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 556 | u_short pal; |
Martin Ambrose | 1f9c3e1 | 2010-05-24 14:34:01 -0700 | [diff] [blame] | 557 | int update_hw = 0; |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 558 | |
| 559 | if (regno > 255) |
| 560 | return 1; |
| 561 | |
| 562 | if (info->fix.visual == FB_VISUAL_DIRECTCOLOR) |
| 563 | return 1; |
| 564 | |
Anatolij Gustschin | f413070 | 2012-03-13 14:13:57 +0100 | [diff] [blame] | 565 | if (info->var.bits_per_pixel == 4) { |
| 566 | if (regno > 15) |
| 567 | return 1; |
| 568 | |
| 569 | if (info->var.grayscale) { |
| 570 | pal = regno; |
| 571 | } else { |
| 572 | red >>= 4; |
| 573 | green >>= 8; |
| 574 | blue >>= 12; |
| 575 | |
| 576 | pal = (red & 0x0f00); |
| 577 | pal |= (green & 0x00f0); |
| 578 | pal |= (blue & 0x000f); |
| 579 | } |
| 580 | if (regno == 0) |
| 581 | pal |= 0x2000; |
| 582 | palette[regno] = pal; |
| 583 | |
| 584 | } else if (info->var.bits_per_pixel == 8) { |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 585 | red >>= 4; |
| 586 | green >>= 8; |
| 587 | blue >>= 12; |
| 588 | |
| 589 | pal = (red & 0x0f00); |
| 590 | pal |= (green & 0x00f0); |
| 591 | pal |= (blue & 0x000f); |
| 592 | |
Martin Ambrose | 1f9c3e1 | 2010-05-24 14:34:01 -0700 | [diff] [blame] | 593 | if (palette[regno] != pal) { |
| 594 | update_hw = 1; |
| 595 | palette[regno] = pal; |
| 596 | } |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 597 | } else if ((info->var.bits_per_pixel == 16) && regno < 16) { |
| 598 | red >>= (16 - info->var.red.length); |
| 599 | red <<= info->var.red.offset; |
| 600 | |
| 601 | green >>= (16 - info->var.green.length); |
| 602 | green <<= info->var.green.offset; |
| 603 | |
| 604 | blue >>= (16 - info->var.blue.length); |
| 605 | blue <<= info->var.blue.offset; |
| 606 | |
| 607 | par->pseudo_palette[regno] = red | green | blue; |
| 608 | |
Martin Ambrose | 1f9c3e1 | 2010-05-24 14:34:01 -0700 | [diff] [blame] | 609 | if (palette[0] != 0x4000) { |
| 610 | update_hw = 1; |
| 611 | palette[0] = 0x4000; |
| 612 | } |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 613 | } |
| 614 | |
Martin Ambrose | 1f9c3e1 | 2010-05-24 14:34:01 -0700 | [diff] [blame] | 615 | /* Update the palette in the h/w as needed. */ |
| 616 | if (update_hw) |
| 617 | lcd_blit(LOAD_PALETTE, par); |
| 618 | |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 619 | return 0; |
| 620 | } |
| 621 | |
Sudhakar Rajashekhara | 2f93e8f | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 622 | static void lcd_reset(struct da8xx_fb_par *par) |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 623 | { |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 624 | /* Disable the Raster if previously Enabled */ |
Chaithrika U S | 3611380 | 2009-12-15 16:46:38 -0800 | [diff] [blame] | 625 | lcd_disable_raster(); |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 626 | |
| 627 | /* DMA has to be disabled */ |
| 628 | lcdc_write(0, LCD_DMA_CTRL_REG); |
| 629 | lcdc_write(0, LCD_RASTER_CTRL_REG); |
Manjunathappa, Prakash | c6daf05 | 2011-07-05 15:51:20 +0530 | [diff] [blame] | 630 | |
Manjunathappa, Prakash | 74a0efd | 2011-11-15 17:32:23 +0530 | [diff] [blame] | 631 | if (lcd_revision == LCD_VERSION_2) { |
Manjunathappa, Prakash | c6daf05 | 2011-07-05 15:51:20 +0530 | [diff] [blame] | 632 | lcdc_write(0, LCD_INT_ENABLE_SET_REG); |
Manjunathappa, Prakash | 74a0efd | 2011-11-15 17:32:23 +0530 | [diff] [blame] | 633 | /* Write 1 to reset */ |
| 634 | lcdc_write(LCD_CLK_MAIN_RESET, LCD_CLK_RESET_REG); |
| 635 | lcdc_write(0, LCD_CLK_RESET_REG); |
| 636 | } |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 637 | } |
| 638 | |
Chaithrika U S | 8097b17 | 2009-12-15 16:46:29 -0800 | [diff] [blame] | 639 | static void lcd_calc_clk_divider(struct da8xx_fb_par *par) |
| 640 | { |
| 641 | unsigned int lcd_clk, div; |
| 642 | |
| 643 | lcd_clk = clk_get_rate(par->lcdc_clk); |
| 644 | div = lcd_clk / par->pxl_clk; |
| 645 | |
| 646 | /* Configure the LCD clock divisor. */ |
| 647 | lcdc_write(LCD_CLK_DIVISOR(div) | |
| 648 | (LCD_RASTER_MODE & 0x1), LCD_CTRL_REG); |
Manjunathappa, Prakash | c6daf05 | 2011-07-05 15:51:20 +0530 | [diff] [blame] | 649 | |
| 650 | if (lcd_revision == LCD_VERSION_2) |
| 651 | lcdc_write(LCD_V2_DMA_CLK_EN | LCD_V2_LIDD_CLK_EN | |
| 652 | LCD_V2_CORE_CLK_EN, LCD_CLK_ENABLE_REG); |
| 653 | |
Chaithrika U S | 8097b17 | 2009-12-15 16:46:29 -0800 | [diff] [blame] | 654 | } |
| 655 | |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 656 | static int lcd_init(struct da8xx_fb_par *par, const struct lcd_ctrl_config *cfg, |
| 657 | struct da8xx_panel *panel) |
| 658 | { |
| 659 | u32 bpp; |
| 660 | int ret = 0; |
| 661 | |
Sudhakar Rajashekhara | 2f93e8f | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 662 | lcd_reset(par); |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 663 | |
Chaithrika U S | 8097b17 | 2009-12-15 16:46:29 -0800 | [diff] [blame] | 664 | /* Calculate the divider */ |
| 665 | lcd_calc_clk_divider(par); |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 666 | |
Sudhakar Rajashekhara | 2f93e8f | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 667 | if (panel->invert_pxl_clk) |
| 668 | lcdc_write((lcdc_read(LCD_RASTER_TIMING_2_REG) | |
| 669 | LCD_INVERT_PIXEL_CLOCK), LCD_RASTER_TIMING_2_REG); |
| 670 | else |
| 671 | lcdc_write((lcdc_read(LCD_RASTER_TIMING_2_REG) & |
| 672 | ~LCD_INVERT_PIXEL_CLOCK), LCD_RASTER_TIMING_2_REG); |
| 673 | |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 674 | /* Configure the DMA burst size. */ |
| 675 | ret = lcd_cfg_dma(cfg->dma_burst_sz); |
| 676 | if (ret < 0) |
| 677 | return ret; |
| 678 | |
| 679 | /* Configure the AC bias properties. */ |
| 680 | lcd_cfg_ac_bias(cfg->ac_bias, cfg->ac_bias_intrpt); |
| 681 | |
| 682 | /* Configure the vertical and horizontal sync properties. */ |
| 683 | lcd_cfg_vertical_sync(panel->vbp, panel->vsw, panel->vfp); |
| 684 | lcd_cfg_horizontal_sync(panel->hbp, panel->hsw, panel->hfp); |
| 685 | |
| 686 | /* Configure for disply */ |
| 687 | ret = lcd_cfg_display(cfg); |
| 688 | if (ret < 0) |
| 689 | return ret; |
| 690 | |
| 691 | if (QVGA != cfg->p_disp_panel->panel_type) |
| 692 | return -EINVAL; |
| 693 | |
| 694 | if (cfg->bpp <= cfg->p_disp_panel->max_bpp && |
| 695 | cfg->bpp >= cfg->p_disp_panel->min_bpp) |
| 696 | bpp = cfg->bpp; |
| 697 | else |
| 698 | bpp = cfg->p_disp_panel->max_bpp; |
| 699 | if (bpp == 12) |
| 700 | bpp = 16; |
| 701 | ret = lcd_cfg_frame_buffer(par, (unsigned int)panel->width, |
| 702 | (unsigned int)panel->height, bpp, |
| 703 | cfg->raster_order); |
| 704 | if (ret < 0) |
| 705 | return ret; |
| 706 | |
| 707 | /* Configure FDD */ |
| 708 | lcdc_write((lcdc_read(LCD_RASTER_CTRL_REG) & 0xfff00fff) | |
| 709 | (cfg->fdd << 12), LCD_RASTER_CTRL_REG); |
| 710 | |
| 711 | return 0; |
| 712 | } |
| 713 | |
Manjunathappa, Prakash | c6daf05 | 2011-07-05 15:51:20 +0530 | [diff] [blame] | 714 | /* IRQ handler for version 2 of LCDC */ |
| 715 | static irqreturn_t lcdc_irq_handler_rev02(int irq, void *arg) |
| 716 | { |
| 717 | struct da8xx_fb_par *par = arg; |
| 718 | u32 stat = lcdc_read(LCD_MASKED_STAT_REG); |
Manjunathappa, Prakash | c6daf05 | 2011-07-05 15:51:20 +0530 | [diff] [blame] | 719 | |
| 720 | if ((stat & LCD_SYNC_LOST) && (stat & LCD_FIFO_UNDERFLOW)) { |
| 721 | lcd_disable_raster(); |
| 722 | lcdc_write(stat, LCD_MASKED_STAT_REG); |
| 723 | lcd_enable_raster(); |
| 724 | } else if (stat & LCD_PL_LOAD_DONE) { |
| 725 | /* |
| 726 | * Must disable raster before changing state of any control bit. |
| 727 | * And also must be disabled before clearing the PL loading |
| 728 | * interrupt via the following write to the status register. If |
| 729 | * this is done after then one gets multiple PL done interrupts. |
| 730 | */ |
| 731 | lcd_disable_raster(); |
| 732 | |
| 733 | lcdc_write(stat, LCD_MASKED_STAT_REG); |
| 734 | |
Manjunathappa, Prakash | 8a81dcc | 2012-07-18 20:51:11 +0530 | [diff] [blame^] | 735 | /* Disable PL completion interrupt */ |
| 736 | lcdc_write(LCD_V2_PL_INT_ENA, LCD_INT_ENABLE_CLR_REG); |
Manjunathappa, Prakash | c6daf05 | 2011-07-05 15:51:20 +0530 | [diff] [blame] | 737 | |
| 738 | /* Setup and start data loading mode */ |
| 739 | lcd_blit(LOAD_DATA, par); |
| 740 | } else { |
| 741 | lcdc_write(stat, LCD_MASKED_STAT_REG); |
| 742 | |
| 743 | if (stat & LCD_END_OF_FRAME0) { |
| 744 | lcdc_write(par->dma_start, |
| 745 | LCD_DMA_FRM_BUF_BASE_ADDR_0_REG); |
| 746 | lcdc_write(par->dma_end, |
| 747 | LCD_DMA_FRM_BUF_CEILING_ADDR_0_REG); |
| 748 | par->vsync_flag = 1; |
| 749 | wake_up_interruptible(&par->vsync_wait); |
| 750 | } |
| 751 | |
| 752 | if (stat & LCD_END_OF_FRAME1) { |
| 753 | lcdc_write(par->dma_start, |
| 754 | LCD_DMA_FRM_BUF_BASE_ADDR_1_REG); |
| 755 | lcdc_write(par->dma_end, |
| 756 | LCD_DMA_FRM_BUF_CEILING_ADDR_1_REG); |
| 757 | par->vsync_flag = 1; |
| 758 | wake_up_interruptible(&par->vsync_wait); |
| 759 | } |
| 760 | } |
| 761 | |
| 762 | lcdc_write(0, LCD_END_OF_INT_IND_REG); |
| 763 | return IRQ_HANDLED; |
| 764 | } |
| 765 | |
| 766 | /* IRQ handler for version 1 LCDC */ |
| 767 | static irqreturn_t lcdc_irq_handler_rev01(int irq, void *arg) |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 768 | { |
Martin Ambrose | 1f9c3e1 | 2010-05-24 14:34:01 -0700 | [diff] [blame] | 769 | struct da8xx_fb_par *par = arg; |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 770 | u32 stat = lcdc_read(LCD_STAT_REG); |
Martin Ambrose | 1f9c3e1 | 2010-05-24 14:34:01 -0700 | [diff] [blame] | 771 | u32 reg_ras; |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 772 | |
| 773 | if ((stat & LCD_SYNC_LOST) && (stat & LCD_FIFO_UNDERFLOW)) { |
Chaithrika U S | 3611380 | 2009-12-15 16:46:38 -0800 | [diff] [blame] | 774 | lcd_disable_raster(); |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 775 | lcdc_write(stat, LCD_STAT_REG); |
Chaithrika U S | 3611380 | 2009-12-15 16:46:38 -0800 | [diff] [blame] | 776 | lcd_enable_raster(); |
Martin Ambrose | 1f9c3e1 | 2010-05-24 14:34:01 -0700 | [diff] [blame] | 777 | } else if (stat & LCD_PL_LOAD_DONE) { |
| 778 | /* |
| 779 | * Must disable raster before changing state of any control bit. |
| 780 | * And also must be disabled before clearing the PL loading |
| 781 | * interrupt via the following write to the status register. If |
| 782 | * this is done after then one gets multiple PL done interrupts. |
| 783 | */ |
| 784 | lcd_disable_raster(); |
| 785 | |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 786 | lcdc_write(stat, LCD_STAT_REG); |
| 787 | |
Martin Ambrose | 1f9c3e1 | 2010-05-24 14:34:01 -0700 | [diff] [blame] | 788 | /* Disable PL completion inerrupt */ |
| 789 | reg_ras = lcdc_read(LCD_RASTER_CTRL_REG); |
Manjunathappa, Prakash | c6daf05 | 2011-07-05 15:51:20 +0530 | [diff] [blame] | 790 | reg_ras &= ~LCD_V1_PL_INT_ENA; |
Martin Ambrose | 1f9c3e1 | 2010-05-24 14:34:01 -0700 | [diff] [blame] | 791 | lcdc_write(reg_ras, LCD_RASTER_CTRL_REG); |
| 792 | |
| 793 | /* Setup and start data loading mode */ |
| 794 | lcd_blit(LOAD_DATA, par); |
| 795 | } else { |
| 796 | lcdc_write(stat, LCD_STAT_REG); |
| 797 | |
| 798 | if (stat & LCD_END_OF_FRAME0) { |
| 799 | lcdc_write(par->dma_start, |
| 800 | LCD_DMA_FRM_BUF_BASE_ADDR_0_REG); |
| 801 | lcdc_write(par->dma_end, |
| 802 | LCD_DMA_FRM_BUF_CEILING_ADDR_0_REG); |
| 803 | par->vsync_flag = 1; |
| 804 | wake_up_interruptible(&par->vsync_wait); |
| 805 | } |
| 806 | |
| 807 | if (stat & LCD_END_OF_FRAME1) { |
| 808 | lcdc_write(par->dma_start, |
| 809 | LCD_DMA_FRM_BUF_BASE_ADDR_1_REG); |
| 810 | lcdc_write(par->dma_end, |
| 811 | LCD_DMA_FRM_BUF_CEILING_ADDR_1_REG); |
| 812 | par->vsync_flag = 1; |
| 813 | wake_up_interruptible(&par->vsync_wait); |
| 814 | } |
| 815 | } |
| 816 | |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 817 | return IRQ_HANDLED; |
| 818 | } |
| 819 | |
| 820 | static int fb_check_var(struct fb_var_screeninfo *var, |
| 821 | struct fb_info *info) |
| 822 | { |
| 823 | int err = 0; |
| 824 | |
| 825 | switch (var->bits_per_pixel) { |
| 826 | case 1: |
| 827 | case 8: |
| 828 | var->red.offset = 0; |
| 829 | var->red.length = 8; |
| 830 | var->green.offset = 0; |
| 831 | var->green.length = 8; |
| 832 | var->blue.offset = 0; |
| 833 | var->blue.length = 8; |
| 834 | var->transp.offset = 0; |
| 835 | var->transp.length = 0; |
Anatolij Gustschin | f413070 | 2012-03-13 14:13:57 +0100 | [diff] [blame] | 836 | var->nonstd = 0; |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 837 | break; |
| 838 | case 4: |
| 839 | var->red.offset = 0; |
| 840 | var->red.length = 4; |
| 841 | var->green.offset = 0; |
| 842 | var->green.length = 4; |
| 843 | var->blue.offset = 0; |
| 844 | var->blue.length = 4; |
| 845 | var->transp.offset = 0; |
| 846 | var->transp.length = 0; |
Anatolij Gustschin | f413070 | 2012-03-13 14:13:57 +0100 | [diff] [blame] | 847 | var->nonstd = FB_NONSTD_REV_PIX_IN_B; |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 848 | break; |
| 849 | case 16: /* RGB 565 */ |
Sudhakar Rajashekhara | 3510b8f | 2009-12-01 13:17:43 -0800 | [diff] [blame] | 850 | var->red.offset = 11; |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 851 | var->red.length = 5; |
| 852 | var->green.offset = 5; |
| 853 | var->green.length = 6; |
Sudhakar Rajashekhara | 3510b8f | 2009-12-01 13:17:43 -0800 | [diff] [blame] | 854 | var->blue.offset = 0; |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 855 | var->blue.length = 5; |
| 856 | var->transp.offset = 0; |
| 857 | var->transp.length = 0; |
Anatolij Gustschin | f413070 | 2012-03-13 14:13:57 +0100 | [diff] [blame] | 858 | var->nonstd = 0; |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 859 | break; |
| 860 | default: |
| 861 | err = -EINVAL; |
| 862 | } |
| 863 | |
| 864 | var->red.msb_right = 0; |
| 865 | var->green.msb_right = 0; |
| 866 | var->blue.msb_right = 0; |
| 867 | var->transp.msb_right = 0; |
| 868 | return err; |
| 869 | } |
| 870 | |
Chaithrika U S | e04e548 | 2009-12-15 16:46:29 -0800 | [diff] [blame] | 871 | #ifdef CONFIG_CPU_FREQ |
| 872 | static int lcd_da8xx_cpufreq_transition(struct notifier_block *nb, |
| 873 | unsigned long val, void *data) |
| 874 | { |
| 875 | struct da8xx_fb_par *par; |
Chaithrika U S | e04e548 | 2009-12-15 16:46:29 -0800 | [diff] [blame] | 876 | |
| 877 | par = container_of(nb, struct da8xx_fb_par, freq_transition); |
Manjunathappa, Prakash | f820917 | 2012-01-03 18:10:51 +0530 | [diff] [blame] | 878 | if (val == CPUFREQ_POSTCHANGE) { |
| 879 | if (par->lcd_fck_rate != clk_get_rate(par->lcdc_clk)) { |
| 880 | par->lcd_fck_rate = clk_get_rate(par->lcdc_clk); |
| 881 | lcd_disable_raster(); |
| 882 | lcd_calc_clk_divider(par); |
| 883 | lcd_enable_raster(); |
| 884 | } |
Chaithrika U S | e04e548 | 2009-12-15 16:46:29 -0800 | [diff] [blame] | 885 | } |
| 886 | |
| 887 | return 0; |
| 888 | } |
| 889 | |
| 890 | static inline int lcd_da8xx_cpufreq_register(struct da8xx_fb_par *par) |
| 891 | { |
| 892 | par->freq_transition.notifier_call = lcd_da8xx_cpufreq_transition; |
| 893 | |
| 894 | return cpufreq_register_notifier(&par->freq_transition, |
| 895 | CPUFREQ_TRANSITION_NOTIFIER); |
| 896 | } |
| 897 | |
| 898 | static inline void lcd_da8xx_cpufreq_deregister(struct da8xx_fb_par *par) |
| 899 | { |
| 900 | cpufreq_unregister_notifier(&par->freq_transition, |
| 901 | CPUFREQ_TRANSITION_NOTIFIER); |
| 902 | } |
| 903 | #endif |
| 904 | |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 905 | static int __devexit fb_remove(struct platform_device *dev) |
| 906 | { |
| 907 | struct fb_info *info = dev_get_drvdata(&dev->dev); |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 908 | |
| 909 | if (info) { |
| 910 | struct da8xx_fb_par *par = info->par; |
| 911 | |
Chaithrika U S | e04e548 | 2009-12-15 16:46:29 -0800 | [diff] [blame] | 912 | #ifdef CONFIG_CPU_FREQ |
| 913 | lcd_da8xx_cpufreq_deregister(par); |
| 914 | #endif |
Chaithrika U S | 3611380 | 2009-12-15 16:46:38 -0800 | [diff] [blame] | 915 | if (par->panel_power_ctrl) |
| 916 | par->panel_power_ctrl(0); |
| 917 | |
| 918 | lcd_disable_raster(); |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 919 | lcdc_write(0, LCD_RASTER_CTRL_REG); |
| 920 | |
| 921 | /* disable DMA */ |
| 922 | lcdc_write(0, LCD_DMA_CTRL_REG); |
| 923 | |
| 924 | unregister_framebuffer(info); |
| 925 | fb_dealloc_cmap(&info->cmap); |
Martin Ambrose | 1f9c3e1 | 2010-05-24 14:34:01 -0700 | [diff] [blame] | 926 | dma_free_coherent(NULL, PALETTE_SIZE, par->v_palette_base, |
| 927 | par->p_palette_base); |
| 928 | dma_free_coherent(NULL, par->vram_size, par->vram_virt, |
| 929 | par->vram_phys); |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 930 | free_irq(par->irq, par); |
| 931 | clk_disable(par->lcdc_clk); |
| 932 | clk_put(par->lcdc_clk); |
| 933 | framebuffer_release(info); |
| 934 | iounmap((void __iomem *)da8xx_fb_reg_base); |
| 935 | release_mem_region(lcdc_regs->start, resource_size(lcdc_regs)); |
| 936 | |
| 937 | } |
Sudhakar Rajashekhara | 2f93e8f | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 938 | return 0; |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 939 | } |
| 940 | |
Martin Ambrose | 1f9c3e1 | 2010-05-24 14:34:01 -0700 | [diff] [blame] | 941 | /* |
| 942 | * Function to wait for vertical sync which for this LCD peripheral |
| 943 | * translates into waiting for the current raster frame to complete. |
| 944 | */ |
| 945 | static int fb_wait_for_vsync(struct fb_info *info) |
| 946 | { |
| 947 | struct da8xx_fb_par *par = info->par; |
| 948 | int ret; |
| 949 | |
| 950 | /* |
| 951 | * Set flag to 0 and wait for isr to set to 1. It would seem there is a |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 952 | * race condition here where the ISR could have occurred just before or |
Martin Ambrose | 1f9c3e1 | 2010-05-24 14:34:01 -0700 | [diff] [blame] | 953 | * just after this set. But since we are just coarsely waiting for |
| 954 | * a frame to complete then that's OK. i.e. if the frame completed |
| 955 | * just before this code executed then we have to wait another full |
| 956 | * frame time but there is no way to avoid such a situation. On the |
| 957 | * other hand if the frame completed just after then we don't need |
| 958 | * to wait long at all. Either way we are guaranteed to return to the |
| 959 | * user immediately after a frame completion which is all that is |
| 960 | * required. |
| 961 | */ |
| 962 | par->vsync_flag = 0; |
| 963 | ret = wait_event_interruptible_timeout(par->vsync_wait, |
| 964 | par->vsync_flag != 0, |
| 965 | par->vsync_timeout); |
| 966 | if (ret < 0) |
| 967 | return ret; |
| 968 | if (ret == 0) |
| 969 | return -ETIMEDOUT; |
| 970 | |
| 971 | return 0; |
| 972 | } |
| 973 | |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 974 | static int fb_ioctl(struct fb_info *info, unsigned int cmd, |
| 975 | unsigned long arg) |
| 976 | { |
| 977 | struct lcd_sync_arg sync_arg; |
| 978 | |
| 979 | switch (cmd) { |
| 980 | case FBIOGET_CONTRAST: |
| 981 | case FBIOPUT_CONTRAST: |
| 982 | case FBIGET_BRIGHTNESS: |
| 983 | case FBIPUT_BRIGHTNESS: |
| 984 | case FBIGET_COLOR: |
| 985 | case FBIPUT_COLOR: |
Sudhakar Rajashekhara | 2f93e8f | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 986 | return -ENOTTY; |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 987 | case FBIPUT_HSYNC: |
| 988 | if (copy_from_user(&sync_arg, (char *)arg, |
| 989 | sizeof(struct lcd_sync_arg))) |
Sudhakar Rajashekhara | 2f93e8f | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 990 | return -EFAULT; |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 991 | lcd_cfg_horizontal_sync(sync_arg.back_porch, |
| 992 | sync_arg.pulse_width, |
| 993 | sync_arg.front_porch); |
| 994 | break; |
| 995 | case FBIPUT_VSYNC: |
| 996 | if (copy_from_user(&sync_arg, (char *)arg, |
| 997 | sizeof(struct lcd_sync_arg))) |
Sudhakar Rajashekhara | 2f93e8f | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 998 | return -EFAULT; |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 999 | lcd_cfg_vertical_sync(sync_arg.back_porch, |
| 1000 | sync_arg.pulse_width, |
| 1001 | sync_arg.front_porch); |
| 1002 | break; |
Martin Ambrose | 1f9c3e1 | 2010-05-24 14:34:01 -0700 | [diff] [blame] | 1003 | case FBIO_WAITFORVSYNC: |
| 1004 | return fb_wait_for_vsync(info); |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 1005 | default: |
| 1006 | return -EINVAL; |
| 1007 | } |
| 1008 | return 0; |
| 1009 | } |
| 1010 | |
Chaithrika U S | 312d971 | 2009-12-15 16:46:39 -0800 | [diff] [blame] | 1011 | static int cfb_blank(int blank, struct fb_info *info) |
| 1012 | { |
| 1013 | struct da8xx_fb_par *par = info->par; |
| 1014 | int ret = 0; |
| 1015 | |
| 1016 | if (par->blank == blank) |
| 1017 | return 0; |
| 1018 | |
| 1019 | par->blank = blank; |
| 1020 | switch (blank) { |
| 1021 | case FB_BLANK_UNBLANK: |
| 1022 | if (par->panel_power_ctrl) |
| 1023 | par->panel_power_ctrl(1); |
| 1024 | |
| 1025 | lcd_enable_raster(); |
| 1026 | break; |
Yegor Yefremov | 99a647d | 2012-07-06 16:01:28 +0200 | [diff] [blame] | 1027 | case FB_BLANK_NORMAL: |
| 1028 | case FB_BLANK_VSYNC_SUSPEND: |
| 1029 | case FB_BLANK_HSYNC_SUSPEND: |
Chaithrika U S | 312d971 | 2009-12-15 16:46:39 -0800 | [diff] [blame] | 1030 | case FB_BLANK_POWERDOWN: |
| 1031 | if (par->panel_power_ctrl) |
| 1032 | par->panel_power_ctrl(0); |
| 1033 | |
| 1034 | lcd_disable_raster(); |
| 1035 | break; |
| 1036 | default: |
| 1037 | ret = -EINVAL; |
| 1038 | } |
| 1039 | |
| 1040 | return ret; |
| 1041 | } |
| 1042 | |
Martin Ambrose | 1f9c3e1 | 2010-05-24 14:34:01 -0700 | [diff] [blame] | 1043 | /* |
| 1044 | * Set new x,y offsets in the virtual display for the visible area and switch |
| 1045 | * to the new mode. |
| 1046 | */ |
| 1047 | static int da8xx_pan_display(struct fb_var_screeninfo *var, |
| 1048 | struct fb_info *fbi) |
| 1049 | { |
| 1050 | int ret = 0; |
| 1051 | struct fb_var_screeninfo new_var; |
| 1052 | struct da8xx_fb_par *par = fbi->par; |
| 1053 | struct fb_fix_screeninfo *fix = &fbi->fix; |
| 1054 | unsigned int end; |
| 1055 | unsigned int start; |
| 1056 | |
| 1057 | if (var->xoffset != fbi->var.xoffset || |
| 1058 | var->yoffset != fbi->var.yoffset) { |
| 1059 | memcpy(&new_var, &fbi->var, sizeof(new_var)); |
| 1060 | new_var.xoffset = var->xoffset; |
| 1061 | new_var.yoffset = var->yoffset; |
| 1062 | if (fb_check_var(&new_var, fbi)) |
| 1063 | ret = -EINVAL; |
| 1064 | else { |
| 1065 | memcpy(&fbi->var, &new_var, sizeof(new_var)); |
| 1066 | |
| 1067 | start = fix->smem_start + |
| 1068 | new_var.yoffset * fix->line_length + |
Laurent Pinchart | e6c4d3d | 2011-06-14 09:24:45 +0000 | [diff] [blame] | 1069 | new_var.xoffset * fbi->var.bits_per_pixel / 8; |
| 1070 | end = start + fbi->var.yres * fix->line_length - 1; |
Martin Ambrose | 1f9c3e1 | 2010-05-24 14:34:01 -0700 | [diff] [blame] | 1071 | par->dma_start = start; |
| 1072 | par->dma_end = end; |
| 1073 | } |
| 1074 | } |
| 1075 | |
| 1076 | return ret; |
| 1077 | } |
| 1078 | |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 1079 | static struct fb_ops da8xx_fb_ops = { |
| 1080 | .owner = THIS_MODULE, |
| 1081 | .fb_check_var = fb_check_var, |
| 1082 | .fb_setcolreg = fb_setcolreg, |
Martin Ambrose | 1f9c3e1 | 2010-05-24 14:34:01 -0700 | [diff] [blame] | 1083 | .fb_pan_display = da8xx_pan_display, |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 1084 | .fb_ioctl = fb_ioctl, |
| 1085 | .fb_fillrect = cfb_fillrect, |
| 1086 | .fb_copyarea = cfb_copyarea, |
| 1087 | .fb_imageblit = cfb_imageblit, |
Chaithrika U S | 312d971 | 2009-12-15 16:46:39 -0800 | [diff] [blame] | 1088 | .fb_blank = cfb_blank, |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 1089 | }; |
| 1090 | |
Manjunathappa, Prakash | 12fa835 | 2012-02-09 11:54:06 +0530 | [diff] [blame] | 1091 | /* Calculate and return pixel clock period in pico seconds */ |
| 1092 | static unsigned int da8xxfb_pixel_clk_period(struct da8xx_fb_par *par) |
| 1093 | { |
| 1094 | unsigned int lcd_clk, div; |
| 1095 | unsigned int configured_pix_clk; |
| 1096 | unsigned long long pix_clk_period_picosec = 1000000000000ULL; |
| 1097 | |
| 1098 | lcd_clk = clk_get_rate(par->lcdc_clk); |
| 1099 | div = lcd_clk / par->pxl_clk; |
| 1100 | configured_pix_clk = (lcd_clk / div); |
| 1101 | |
| 1102 | do_div(pix_clk_period_picosec, configured_pix_clk); |
| 1103 | |
| 1104 | return pix_clk_period_picosec; |
| 1105 | } |
| 1106 | |
axel lin | 1db41e0 | 2011-02-22 01:52:42 +0000 | [diff] [blame] | 1107 | static int __devinit fb_probe(struct platform_device *device) |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 1108 | { |
| 1109 | struct da8xx_lcdc_platform_data *fb_pdata = |
| 1110 | device->dev.platform_data; |
| 1111 | struct lcd_ctrl_config *lcd_cfg; |
| 1112 | struct da8xx_panel *lcdc_info; |
| 1113 | struct fb_info *da8xx_fb_info; |
| 1114 | struct clk *fb_clk = NULL; |
| 1115 | struct da8xx_fb_par *par; |
| 1116 | resource_size_t len; |
| 1117 | int ret, i; |
Aditya Nellutla | 3b9cc4e | 2012-05-23 11:36:31 +0530 | [diff] [blame] | 1118 | unsigned long ulcm; |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 1119 | |
| 1120 | if (fb_pdata == NULL) { |
| 1121 | dev_err(&device->dev, "Can not get platform data\n"); |
| 1122 | return -ENOENT; |
| 1123 | } |
| 1124 | |
| 1125 | lcdc_regs = platform_get_resource(device, IORESOURCE_MEM, 0); |
| 1126 | if (!lcdc_regs) { |
| 1127 | dev_err(&device->dev, |
| 1128 | "Can not get memory resource for LCD controller\n"); |
| 1129 | return -ENOENT; |
| 1130 | } |
| 1131 | |
| 1132 | len = resource_size(lcdc_regs); |
| 1133 | |
| 1134 | lcdc_regs = request_mem_region(lcdc_regs->start, len, lcdc_regs->name); |
| 1135 | if (!lcdc_regs) |
| 1136 | return -EBUSY; |
| 1137 | |
| 1138 | da8xx_fb_reg_base = (resource_size_t)ioremap(lcdc_regs->start, len); |
| 1139 | if (!da8xx_fb_reg_base) { |
| 1140 | ret = -EBUSY; |
| 1141 | goto err_request_mem; |
| 1142 | } |
| 1143 | |
| 1144 | fb_clk = clk_get(&device->dev, NULL); |
| 1145 | if (IS_ERR(fb_clk)) { |
| 1146 | dev_err(&device->dev, "Can not get device clock\n"); |
| 1147 | ret = -ENODEV; |
| 1148 | goto err_ioremap; |
| 1149 | } |
| 1150 | ret = clk_enable(fb_clk); |
| 1151 | if (ret) |
| 1152 | goto err_clk_put; |
| 1153 | |
Manjunathappa, Prakash | c6daf05 | 2011-07-05 15:51:20 +0530 | [diff] [blame] | 1154 | /* Determine LCD IP Version */ |
| 1155 | switch (lcdc_read(LCD_PID_REG)) { |
| 1156 | case 0x4C100102: |
| 1157 | lcd_revision = LCD_VERSION_1; |
| 1158 | break; |
| 1159 | case 0x4F200800: |
| 1160 | lcd_revision = LCD_VERSION_2; |
| 1161 | break; |
| 1162 | default: |
| 1163 | dev_warn(&device->dev, "Unknown PID Reg value 0x%x, " |
| 1164 | "defaulting to LCD revision 1\n", |
| 1165 | lcdc_read(LCD_PID_REG)); |
| 1166 | lcd_revision = LCD_VERSION_1; |
| 1167 | break; |
| 1168 | } |
| 1169 | |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 1170 | for (i = 0, lcdc_info = known_lcd_panels; |
| 1171 | i < ARRAY_SIZE(known_lcd_panels); |
| 1172 | i++, lcdc_info++) { |
| 1173 | if (strcmp(fb_pdata->type, lcdc_info->name) == 0) |
| 1174 | break; |
| 1175 | } |
| 1176 | |
| 1177 | if (i == ARRAY_SIZE(known_lcd_panels)) { |
| 1178 | dev_err(&device->dev, "GLCD: No valid panel found\n"); |
Roel Kluin | dd04a6b | 2009-11-17 14:06:15 -0800 | [diff] [blame] | 1179 | ret = -ENODEV; |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 1180 | goto err_clk_disable; |
| 1181 | } else |
| 1182 | dev_info(&device->dev, "GLCD: Found %s panel\n", |
| 1183 | fb_pdata->type); |
| 1184 | |
| 1185 | lcd_cfg = (struct lcd_ctrl_config *)fb_pdata->controller_data; |
| 1186 | |
| 1187 | da8xx_fb_info = framebuffer_alloc(sizeof(struct da8xx_fb_par), |
| 1188 | &device->dev); |
| 1189 | if (!da8xx_fb_info) { |
| 1190 | dev_dbg(&device->dev, "Memory allocation failed for fb_info\n"); |
| 1191 | ret = -ENOMEM; |
| 1192 | goto err_clk_disable; |
| 1193 | } |
| 1194 | |
| 1195 | par = da8xx_fb_info->par; |
Chaithrika U S | 8097b17 | 2009-12-15 16:46:29 -0800 | [diff] [blame] | 1196 | par->lcdc_clk = fb_clk; |
Manjunathappa, Prakash | f820917 | 2012-01-03 18:10:51 +0530 | [diff] [blame] | 1197 | #ifdef CONFIG_CPU_FREQ |
| 1198 | par->lcd_fck_rate = clk_get_rate(fb_clk); |
| 1199 | #endif |
Chaithrika U S | 8097b17 | 2009-12-15 16:46:29 -0800 | [diff] [blame] | 1200 | par->pxl_clk = lcdc_info->pxl_clk; |
Chaithrika U S | 3611380 | 2009-12-15 16:46:38 -0800 | [diff] [blame] | 1201 | if (fb_pdata->panel_power_ctrl) { |
| 1202 | par->panel_power_ctrl = fb_pdata->panel_power_ctrl; |
| 1203 | par->panel_power_ctrl(1); |
| 1204 | } |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 1205 | |
| 1206 | if (lcd_init(par, lcd_cfg, lcdc_info) < 0) { |
| 1207 | dev_err(&device->dev, "lcd_init failed\n"); |
| 1208 | ret = -EFAULT; |
| 1209 | goto err_release_fb; |
| 1210 | } |
| 1211 | |
| 1212 | /* allocate frame buffer */ |
Martin Ambrose | 1f9c3e1 | 2010-05-24 14:34:01 -0700 | [diff] [blame] | 1213 | par->vram_size = lcdc_info->width * lcdc_info->height * lcd_cfg->bpp; |
Aditya Nellutla | 3b9cc4e | 2012-05-23 11:36:31 +0530 | [diff] [blame] | 1214 | ulcm = lcm((lcdc_info->width * lcd_cfg->bpp)/8, PAGE_SIZE); |
| 1215 | par->vram_size = roundup(par->vram_size/8, ulcm); |
Martin Ambrose | 1f9c3e1 | 2010-05-24 14:34:01 -0700 | [diff] [blame] | 1216 | par->vram_size = par->vram_size * LCD_NUM_BUFFERS; |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 1217 | |
Martin Ambrose | 1f9c3e1 | 2010-05-24 14:34:01 -0700 | [diff] [blame] | 1218 | par->vram_virt = dma_alloc_coherent(NULL, |
| 1219 | par->vram_size, |
| 1220 | (resource_size_t *) &par->vram_phys, |
| 1221 | GFP_KERNEL | GFP_DMA); |
| 1222 | if (!par->vram_virt) { |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 1223 | dev_err(&device->dev, |
| 1224 | "GLCD: kmalloc for frame buffer failed\n"); |
| 1225 | ret = -EINVAL; |
| 1226 | goto err_release_fb; |
| 1227 | } |
| 1228 | |
Martin Ambrose | 1f9c3e1 | 2010-05-24 14:34:01 -0700 | [diff] [blame] | 1229 | da8xx_fb_info->screen_base = (char __iomem *) par->vram_virt; |
| 1230 | da8xx_fb_fix.smem_start = par->vram_phys; |
| 1231 | da8xx_fb_fix.smem_len = par->vram_size; |
| 1232 | da8xx_fb_fix.line_length = (lcdc_info->width * lcd_cfg->bpp) / 8; |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 1233 | |
Martin Ambrose | 1f9c3e1 | 2010-05-24 14:34:01 -0700 | [diff] [blame] | 1234 | par->dma_start = par->vram_phys; |
| 1235 | par->dma_end = par->dma_start + lcdc_info->height * |
| 1236 | da8xx_fb_fix.line_length - 1; |
| 1237 | |
| 1238 | /* allocate palette buffer */ |
| 1239 | par->v_palette_base = dma_alloc_coherent(NULL, |
| 1240 | PALETTE_SIZE, |
| 1241 | (resource_size_t *) |
| 1242 | &par->p_palette_base, |
| 1243 | GFP_KERNEL | GFP_DMA); |
| 1244 | if (!par->v_palette_base) { |
| 1245 | dev_err(&device->dev, |
| 1246 | "GLCD: kmalloc for palette buffer failed\n"); |
| 1247 | ret = -EINVAL; |
| 1248 | goto err_release_fb_mem; |
| 1249 | } |
| 1250 | memset(par->v_palette_base, 0, PALETTE_SIZE); |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 1251 | |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 1252 | par->irq = platform_get_irq(device, 0); |
| 1253 | if (par->irq < 0) { |
| 1254 | ret = -ENOENT; |
Martin Ambrose | 1f9c3e1 | 2010-05-24 14:34:01 -0700 | [diff] [blame] | 1255 | goto err_release_pl_mem; |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 1256 | } |
| 1257 | |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 1258 | /* Initialize par */ |
| 1259 | da8xx_fb_info->var.bits_per_pixel = lcd_cfg->bpp; |
| 1260 | |
| 1261 | da8xx_fb_var.xres = lcdc_info->width; |
| 1262 | da8xx_fb_var.xres_virtual = lcdc_info->width; |
| 1263 | |
Martin Ambrose | 1f9c3e1 | 2010-05-24 14:34:01 -0700 | [diff] [blame] | 1264 | da8xx_fb_var.yres = lcdc_info->height; |
| 1265 | da8xx_fb_var.yres_virtual = lcdc_info->height * LCD_NUM_BUFFERS; |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 1266 | |
| 1267 | da8xx_fb_var.grayscale = |
| 1268 | lcd_cfg->p_disp_panel->panel_shade == MONOCHROME ? 1 : 0; |
| 1269 | da8xx_fb_var.bits_per_pixel = lcd_cfg->bpp; |
| 1270 | |
| 1271 | da8xx_fb_var.hsync_len = lcdc_info->hsw; |
| 1272 | da8xx_fb_var.vsync_len = lcdc_info->vsw; |
Anatolij Gustschin | 084e104 | 2012-03-13 14:13:04 +0100 | [diff] [blame] | 1273 | da8xx_fb_var.right_margin = lcdc_info->hfp; |
| 1274 | da8xx_fb_var.left_margin = lcdc_info->hbp; |
| 1275 | da8xx_fb_var.lower_margin = lcdc_info->vfp; |
| 1276 | da8xx_fb_var.upper_margin = lcdc_info->vbp; |
Manjunathappa, Prakash | 12fa835 | 2012-02-09 11:54:06 +0530 | [diff] [blame] | 1277 | da8xx_fb_var.pixclock = da8xxfb_pixel_clk_period(par); |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 1278 | |
| 1279 | /* Initialize fbinfo */ |
| 1280 | da8xx_fb_info->flags = FBINFO_FLAG_DEFAULT; |
| 1281 | da8xx_fb_info->fix = da8xx_fb_fix; |
| 1282 | da8xx_fb_info->var = da8xx_fb_var; |
| 1283 | da8xx_fb_info->fbops = &da8xx_fb_ops; |
| 1284 | da8xx_fb_info->pseudo_palette = par->pseudo_palette; |
Sudhakar Rajashekhara | 3510b8f | 2009-12-01 13:17:43 -0800 | [diff] [blame] | 1285 | da8xx_fb_info->fix.visual = (da8xx_fb_info->var.bits_per_pixel <= 8) ? |
| 1286 | FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR; |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 1287 | |
| 1288 | ret = fb_alloc_cmap(&da8xx_fb_info->cmap, PALETTE_SIZE, 0); |
| 1289 | if (ret) |
Caglar Akyuz | 93c176f | 2010-11-30 20:04:14 +0000 | [diff] [blame] | 1290 | goto err_release_pl_mem; |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 1291 | da8xx_fb_info->cmap.len = par->palette_sz; |
| 1292 | |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 1293 | /* initialize var_screeninfo */ |
| 1294 | da8xx_fb_var.activate = FB_ACTIVATE_FORCE; |
| 1295 | fb_set_var(da8xx_fb_info, &da8xx_fb_var); |
| 1296 | |
| 1297 | dev_set_drvdata(&device->dev, da8xx_fb_info); |
Martin Ambrose | 1f9c3e1 | 2010-05-24 14:34:01 -0700 | [diff] [blame] | 1298 | |
| 1299 | /* initialize the vsync wait queue */ |
| 1300 | init_waitqueue_head(&par->vsync_wait); |
| 1301 | par->vsync_timeout = HZ / 5; |
| 1302 | |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 1303 | /* Register the Frame Buffer */ |
| 1304 | if (register_framebuffer(da8xx_fb_info) < 0) { |
| 1305 | dev_err(&device->dev, |
| 1306 | "GLCD: Frame Buffer Registration Failed!\n"); |
| 1307 | ret = -EINVAL; |
| 1308 | goto err_dealloc_cmap; |
| 1309 | } |
| 1310 | |
Chaithrika U S | e04e548 | 2009-12-15 16:46:29 -0800 | [diff] [blame] | 1311 | #ifdef CONFIG_CPU_FREQ |
| 1312 | ret = lcd_da8xx_cpufreq_register(par); |
| 1313 | if (ret) { |
| 1314 | dev_err(&device->dev, "failed to register cpufreq\n"); |
| 1315 | goto err_cpu_freq; |
| 1316 | } |
| 1317 | #endif |
Caglar Akyuz | 93c176f | 2010-11-30 20:04:14 +0000 | [diff] [blame] | 1318 | |
Manjunathappa, Prakash | c6daf05 | 2011-07-05 15:51:20 +0530 | [diff] [blame] | 1319 | if (lcd_revision == LCD_VERSION_1) |
| 1320 | lcdc_irq_handler = lcdc_irq_handler_rev01; |
| 1321 | else |
| 1322 | lcdc_irq_handler = lcdc_irq_handler_rev02; |
| 1323 | |
| 1324 | ret = request_irq(par->irq, lcdc_irq_handler, 0, |
| 1325 | DRIVER_NAME, par); |
Caglar Akyuz | 93c176f | 2010-11-30 20:04:14 +0000 | [diff] [blame] | 1326 | if (ret) |
| 1327 | goto irq_freq; |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 1328 | return 0; |
| 1329 | |
Caglar Akyuz | 93c176f | 2010-11-30 20:04:14 +0000 | [diff] [blame] | 1330 | irq_freq: |
Chaithrika U S | e04e548 | 2009-12-15 16:46:29 -0800 | [diff] [blame] | 1331 | #ifdef CONFIG_CPU_FREQ |
axel lin | 360c202 | 2011-01-20 03:50:51 +0000 | [diff] [blame] | 1332 | lcd_da8xx_cpufreq_deregister(par); |
Chaithrika U S | e04e548 | 2009-12-15 16:46:29 -0800 | [diff] [blame] | 1333 | err_cpu_freq: |
Manjunathappa, Prakash | 3a84409 | 2012-02-09 10:34:38 +0530 | [diff] [blame] | 1334 | #endif |
Chaithrika U S | e04e548 | 2009-12-15 16:46:29 -0800 | [diff] [blame] | 1335 | unregister_framebuffer(da8xx_fb_info); |
Chaithrika U S | e04e548 | 2009-12-15 16:46:29 -0800 | [diff] [blame] | 1336 | |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 1337 | err_dealloc_cmap: |
| 1338 | fb_dealloc_cmap(&da8xx_fb_info->cmap); |
| 1339 | |
Martin Ambrose | 1f9c3e1 | 2010-05-24 14:34:01 -0700 | [diff] [blame] | 1340 | err_release_pl_mem: |
| 1341 | dma_free_coherent(NULL, PALETTE_SIZE, par->v_palette_base, |
| 1342 | par->p_palette_base); |
| 1343 | |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 1344 | err_release_fb_mem: |
Martin Ambrose | 1f9c3e1 | 2010-05-24 14:34:01 -0700 | [diff] [blame] | 1345 | dma_free_coherent(NULL, par->vram_size, par->vram_virt, par->vram_phys); |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 1346 | |
| 1347 | err_release_fb: |
| 1348 | framebuffer_release(da8xx_fb_info); |
| 1349 | |
| 1350 | err_clk_disable: |
| 1351 | clk_disable(fb_clk); |
| 1352 | |
| 1353 | err_clk_put: |
| 1354 | clk_put(fb_clk); |
| 1355 | |
| 1356 | err_ioremap: |
| 1357 | iounmap((void __iomem *)da8xx_fb_reg_base); |
| 1358 | |
| 1359 | err_request_mem: |
| 1360 | release_mem_region(lcdc_regs->start, len); |
| 1361 | |
| 1362 | return ret; |
| 1363 | } |
| 1364 | |
| 1365 | #ifdef CONFIG_PM |
| 1366 | static int fb_suspend(struct platform_device *dev, pm_message_t state) |
| 1367 | { |
Chaithrika U S | 1d3c6c7 | 2009-12-15 16:46:39 -0800 | [diff] [blame] | 1368 | struct fb_info *info = platform_get_drvdata(dev); |
| 1369 | struct da8xx_fb_par *par = info->par; |
| 1370 | |
Torben Hohn | ac751ef | 2011-01-25 15:07:35 -0800 | [diff] [blame] | 1371 | console_lock(); |
Chaithrika U S | 1d3c6c7 | 2009-12-15 16:46:39 -0800 | [diff] [blame] | 1372 | if (par->panel_power_ctrl) |
| 1373 | par->panel_power_ctrl(0); |
| 1374 | |
| 1375 | fb_set_suspend(info, 1); |
| 1376 | lcd_disable_raster(); |
| 1377 | clk_disable(par->lcdc_clk); |
Torben Hohn | ac751ef | 2011-01-25 15:07:35 -0800 | [diff] [blame] | 1378 | console_unlock(); |
Chaithrika U S | 1d3c6c7 | 2009-12-15 16:46:39 -0800 | [diff] [blame] | 1379 | |
| 1380 | return 0; |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 1381 | } |
| 1382 | static int fb_resume(struct platform_device *dev) |
| 1383 | { |
Chaithrika U S | 1d3c6c7 | 2009-12-15 16:46:39 -0800 | [diff] [blame] | 1384 | struct fb_info *info = platform_get_drvdata(dev); |
| 1385 | struct da8xx_fb_par *par = info->par; |
| 1386 | |
Torben Hohn | ac751ef | 2011-01-25 15:07:35 -0800 | [diff] [blame] | 1387 | console_lock(); |
Chaithrika U S | 1d3c6c7 | 2009-12-15 16:46:39 -0800 | [diff] [blame] | 1388 | if (par->panel_power_ctrl) |
| 1389 | par->panel_power_ctrl(1); |
| 1390 | |
| 1391 | clk_enable(par->lcdc_clk); |
| 1392 | lcd_enable_raster(); |
| 1393 | fb_set_suspend(info, 0); |
Torben Hohn | ac751ef | 2011-01-25 15:07:35 -0800 | [diff] [blame] | 1394 | console_unlock(); |
Chaithrika U S | 1d3c6c7 | 2009-12-15 16:46:39 -0800 | [diff] [blame] | 1395 | |
| 1396 | return 0; |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 1397 | } |
| 1398 | #else |
| 1399 | #define fb_suspend NULL |
| 1400 | #define fb_resume NULL |
| 1401 | #endif |
| 1402 | |
| 1403 | static struct platform_driver da8xx_fb_driver = { |
| 1404 | .probe = fb_probe, |
axel lin | 1db41e0 | 2011-02-22 01:52:42 +0000 | [diff] [blame] | 1405 | .remove = __devexit_p(fb_remove), |
Sudhakar Rajashekhara | 4ed824d | 2009-09-22 16:47:06 -0700 | [diff] [blame] | 1406 | .suspend = fb_suspend, |
| 1407 | .resume = fb_resume, |
| 1408 | .driver = { |
| 1409 | .name = DRIVER_NAME, |
| 1410 | .owner = THIS_MODULE, |
| 1411 | }, |
| 1412 | }; |
| 1413 | |
| 1414 | static int __init da8xx_fb_init(void) |
| 1415 | { |
| 1416 | return platform_driver_register(&da8xx_fb_driver); |
| 1417 | } |
| 1418 | |
| 1419 | static void __exit da8xx_fb_cleanup(void) |
| 1420 | { |
| 1421 | platform_driver_unregister(&da8xx_fb_driver); |
| 1422 | } |
| 1423 | |
| 1424 | module_init(da8xx_fb_init); |
| 1425 | module_exit(da8xx_fb_cleanup); |
| 1426 | |
| 1427 | MODULE_DESCRIPTION("Framebuffer driver for TI da8xx/omap-l1xx"); |
| 1428 | MODULE_AUTHOR("Texas Instruments"); |
| 1429 | MODULE_LICENSE("GPL"); |