yuezonghe | 824eb0c | 2024-06-27 02:32:26 -0700 | [diff] [blame^] | 1 | /***********************************************************************
|
| 2 | * Copyright (C) 2015, ZTE Corporation.
|
| 3 | *
|
| 4 | * File Name: leadt15ds26fb.h
|
| 5 | * File Mark:
|
| 6 | * Description: Adapted to LCM MODEL - LEAD T15DS26.
|
| 7 | * Others: This LCM MODEL uses SPI-4. And this 4-lines-spi uses CS, CLK, D/CX and SDI. Do not using SDO, but instead of D/CX.
|
| 8 | * Version: V1.0
|
| 9 | * Author: YinWenguan
|
| 10 | * Date: 2015-6-19
|
| 11 | *
|
| 12 | * History 1:
|
| 13 | * Date: 2016-4-21
|
| 14 | * Version:
|
| 15 | * Author: MaXuelong
|
| 16 | * Modification: transplant it from 7510(uc) to 7520v2(linux)
|
| 17 | *
|
| 18 | ***********************************************************************/
|
| 19 | #include <linux/module.h>
|
| 20 | #include <linux/kernel.h>
|
| 21 | #include <linux/errno.h>
|
| 22 | #include <linux/string.h>
|
| 23 | #include <linux/mm.h>
|
| 24 | #include <linux/fb.h>
|
| 25 | #include <linux/init.h>
|
| 26 | #include <linux/interrupt.h>
|
| 27 | #include <linux/ctype.h>
|
| 28 | #include <linux/dma-mapping.h>
|
| 29 | #include <linux/platform_device.h>
|
| 30 | #include <linux/slab.h>
|
| 31 | #include <linux/gpio.h>
|
| 32 | #include <linux/delay.h>
|
| 33 | #include <linux/uaccess.h>
|
| 34 | #include <linux/vmalloc.h>
|
| 35 | #include <linux/spi/spi.h>
|
| 36 | #include <linux/wakelock.h>
|
| 37 | #include <mach/gpio.h>
|
| 38 | #include <mach/clk.h>
|
| 39 | #include <mach/gpio_def.h>
|
| 40 | #include <mach/gpio_cfg.h>
|
| 41 | #include <mach/peri_cfg.h>
|
| 42 | #include <linux/video/zx29_lcd.h>
|
| 43 | #include <linux/mfd/zx234290.h>
|
| 44 | #include <linux/irq.h>
|
| 45 | #include <mach/pcu.h>
|
| 46 | #include <linux/jiffies.h>
|
| 47 | #include <linux/atomic.h>
|
| 48 | #include <linux/soc/zte/pm/drv_idle.h>
|
| 49 |
|
| 50 | #include <linux/slab.h>
|
| 51 | #include <linux/debugfs.h>
|
| 52 | #include <asm/uaccess.h>
|
| 53 | #include <linux/reboot.h>
|
| 54 | /*************************************************************************
|
| 55 | * Macro
|
| 56 | *************************************************************************/
|
| 57 | #define LCD_PRINFO(fmt,arg...) no_printk(KERN_INFO "##%s, line:%d" fmt,__FUNCTION__,__LINE__,##arg)
|
| 58 | #define LCD_PRERR(fmt,arg...) printk(KERN_ERR "##%s, line:%d" fmt,__FUNCTION__,__LINE__,##arg)
|
| 59 |
|
| 60 |
|
| 61 | /* LCM manufacturer ID */
|
| 62 | #define LCM_LEAD_ID 0x7C
|
| 63 | #define LCM_ST7789V_ID 0x85
|
| 64 | #define LCM_ST7789V_VERSION 0x8552 //240*240
|
| 65 | #define LCM_GC930X_ID 0x00
|
| 66 | #define LCM_GC930X_VERSION 0x9306 //240*320
|
| 67 | #define LCM_ILI9342C_ID 0xE3
|
| 68 |
|
| 69 | #define LCD_WIDTH 128
|
| 70 | #define LCD_HEIGHT 160
|
| 71 | #define LCD_BITS_PER_PIXEL 16
|
| 72 | #define LCD_GRAM_SIZE (LCD_WIDTH * LCD_HEIGHT * 2)
|
| 73 |
|
| 74 | /* rotate display */
|
| 75 | //#define LCD_ROTATE_180 /* need rotating 180C */
|
| 76 | #define LCD_XS 0x00
|
| 77 | #define LCD_XE 0x81
|
| 78 | #ifdef LCD_ROTATE_180
|
| 79 | #define LCD_MXMYRGB 0x1C
|
| 80 | #define LCD_YS 0x00
|
| 81 | #define LCD_YE 0x80
|
| 82 | #else
|
| 83 | #define LCD_MXMYRGB 0xC8
|
| 84 | #define LCD_YS 0x00
|
| 85 | #define LCD_YE 0x82
|
| 86 | #endif/*LCD_ROTATE_180*/
|
| 87 | #ifdef CONFIG_ARCH_ZX297520V3_FWP
|
| 88 | #define LCD_PAGE_HEIGHT 8
|
| 89 | #define LCD_PAGE_NUM 8
|
| 90 |
|
| 91 | #define START_PAGE 0xB0
|
| 92 | #define START_HIGH_BIT 0x10
|
| 93 | #define START_LOW_BIT 0x00
|
| 94 | #define START_LOW_PY 1
|
| 95 | #endif
|
| 96 | /* LOAD-BY-TRACE flag storing address.
|
| 97 | 1. In normal start-up procedure, BOOTLOADER will clear all IRAM space. So the value of this address will be ZERO.
|
| 98 | 2. In LOAD-BY-TRACE procedure, *.cmm script file have already set this address's content to 1. */
|
| 99 | #define LCD_LOADBYTRACEFLAG_ADDR (0x8201c804)
|
| 100 |
|
| 101 | #define RS_L gpio_set_value(PIN_SPI_DCX, GPIO_LOW)
|
| 102 | #define RS_H gpio_set_value(PIN_SPI_DCX, GPIO_HIGH)
|
| 103 |
|
| 104 | /* read/write register's value */
|
| 105 | #define LCD_REG_READ(REG) (*((volatile unsigned int*)(REG)))
|
| 106 | #define LCD_REG_WRITE(REG,value) (*((volatile unsigned int*)(REG)) = value)
|
| 107 |
|
| 108 | /* ioctrl command */
|
| 109 | #define LEADT15DS26_SET_SLEEPMODE _IOW('L', 1, unsigned int) /* enter or exit sleep-mode */
|
| 110 | #define LEADT15DS26_SET_BACKLIGHT _IOW('L', 2, unsigned int) /* turn on or off backlight */
|
| 111 | #define LEADT15DS26_SET_BRIGHTNESS _IOW('L', 3, unsigned int) /* set brightness value */
|
| 112 | #define LEADT15DS26_FILLRECT _IOW('L', 4, unsigned int) /* fill rect region */
|
| 113 |
|
| 114 | enum _lcm_operation_flag{
|
| 115 | LCD_LCM_DATA = 0x0,
|
| 116 | LCD_LCM_CMD = 0x1,
|
| 117 | LCD_LCM_SLEEP = 0x2,
|
| 118 | };
|
| 119 |
|
| 120 | struct lcd_lcm_arg{
|
| 121 | enum _lcm_operation_flag flag; /* 0 data 1cmd 3sleep */
|
| 122 | int arg; /*write data/cmd id/sleep time*/
|
| 123 | };
|
| 124 |
|
| 125 | #ifdef CONFIG_FB_LCD_TE_ON
|
| 126 | static unsigned int g_sLcd_GpioSyn = 0;
|
| 127 | static struct semaphore gLcd_SyncSema;
|
| 128 | volatile bool g_LcdSema_Flag = false;
|
| 129 | volatile atomic_t g_Lcd_Fmark_count = {0};
|
| 130 | volatile unsigned int g_Lcd_tick_count = 0;
|
| 131 | #endif
|
| 132 |
|
| 133 | struct lcd_lcm_arg lcd_lcm_ili9342c[]=
|
| 134 | {
|
| 135 | {1,0xC8}, {0,0x03}, {0,0xFF}, {0,0x93}, {0,0x42},
|
| 136 | {1,0xE0}, {0,0xD0}, {0,0x00}, {0,0x03}, {0,0x09}, {0,0x13},
|
| 137 | {0,0x1C}, {0,0x3A}, {0,0x55}, {0,0x48}, {0,0x18}, {0,0x12},
|
| 138 | {0,0x0E}, {0,0x19}, {0,0x1E},
|
| 139 | {1,0xE1}, {0,0xD0}, {0,0x00}, {0,0x03}, {0,0x09}, {0,0x05},
|
| 140 | {0,0x25}, {0,0x3A}, {0,0x55}, {0,0x50}, {0,0x3D}, {0,0x1C},
|
| 141 | {0,0x1D}, {0,0x1D}, {0,0x1E},
|
| 142 |
|
| 143 | {1,0xB1}, {0,0x01}, {0,0x1B},
|
| 144 | {1,0xB4}, {0,0x01}, {0,0x02},
|
| 145 | {1,0xB6}, {0,0x02}, {0,0x0A}, {0,0xE0},
|
| 146 |
|
| 147 | {1,0x36}, {0,0x01}, {0,0x08},
|
| 148 | {1,0x3A}, {0,0x01}, {0,0x55},
|
| 149 |
|
| 150 | {1,0xC0}, {0,0x02}, {0,0x0F}, {0,0x0F},
|
| 151 | {1,0xC1}, {0,0x01}, {0,0x00},
|
| 152 | {1,0xC5}, {0,0x01}, {0,0xCC},
|
| 153 | {1,0x20}, {0,0x00},
|
| 154 | {1,0x11}, {0,0x00},
|
| 155 | {2, 120},
|
| 156 | {1,0x29}, {0,0x00}
|
| 157 | };
|
| 158 | struct lcd_lcm_arg lcd_lcm_st7789v[]=
|
| 159 | {
|
| 160 | {1, 0x11},
|
| 161 | {2, 120},
|
| 162 |
|
| 163 | {1,0x36}, {0,0x00}, //0x0 -> 0x8
|
| 164 | {1,0x3A}, {0,0x55},
|
| 165 |
|
| 166 | {1,0xB2}, {0,0x0C}, {0,0x0C}, {0,0x00}, {0,0x33},{0,0x33},
|
| 167 | {1,0xB7}, {0,0x22},
|
| 168 |
|
| 169 | {1,0xBB}, {0,0x3C},
|
| 170 | {1,0xC2}, {0,0x01},
|
| 171 | {1,0xC3}, {0,0x19},
|
| 172 | {1,0xC4}, {0,0x20},
|
| 173 | {1,0xC6}, {0,0x0F},
|
| 174 | {1,0xD0}, {0,0xA4}, {0,0xA1},
|
| 175 | {1,0xD6}, {0,0xA1},
|
| 176 | {1,0xE0}, {0,0x70}, {0,0x04}, {0,0x08}, {0,0x09}, {0,0x09},
|
| 177 | {0,0x05}, {0,0x2A}, {0,0x33}, {0,0x41}, {0,0x07}, {0,0x13},
|
| 178 | {0,0x13}, {0,0x29}, {0,0x2F},
|
| 179 | {1,0xE1}, {0,0x70}, {0,0x03}, {0,0x09}, {0,0x0A}, {0,0x09},
|
| 180 | {0,0x06}, {0,0x2B}, {0,0x34}, {0,0x41}, {0,0x07}, {0,0x12},
|
| 181 | {0,0x14}, {0,0x28}, {0,0x2E},
|
| 182 | {1,0x21},
|
| 183 | {1,0x29},
|
| 184 | {1,0x2C}
|
| 185 | };
|
| 186 |
|
| 187 | struct lcd_lcm_arg lcd_lcm_success[]=
|
| 188 | {
|
| 189 | {1,0x11},
|
| 190 | {2, 150},
|
| 191 | {1,0x26}, {0,0x4},
|
| 192 | {1,0xB1}, {0,0x0B}, {0,0x14},
|
| 193 | {1,0xC0}, {0,0x10}, {0,0x00},
|
| 194 | {1,0xC1}, {0,0x05},
|
| 195 | {1,0xC5}, {0,0x46}, {0,0x40},
|
| 196 | {1,0xC7}, {0,0xBD},
|
| 197 | {1,0xEC}, {0,0x0C},
|
| 198 | {1,0x3a}, {0,0x05},
|
| 199 | {1,0x2A}, {0,0x00}, {0,0x00}, {0,0x00}, {0,0x7F},
|
| 200 | {1,0x2B}, {0,0x00}, {0,0x00}, {0,0x00},{0,0x9F},
|
| 201 | {1,0x36}, {0,LCD_MXMYRGB},
|
| 202 | {1,0xB7}, {0,0x00},
|
| 203 | {1,0xf2}, {0,0x1},
|
| 204 | {1,0xE0}, {0,0x3F}, {0,0x29}, {0,0x26}, {0,0x26}, {0,0x26},
|
| 205 | {0,0x0C}, {0,0x51}, {0,0xB8}, {0,0x39}, {0,0x17}, {0,0x00},
|
| 206 | {0,0x00}, {0,0x00}, {0,0x00}, {0,0x00},
|
| 207 | {1,0xE1}, {0,0x00}, {0,0x16}, {0,0x19}, {0,0x19}, {0,0x19},
|
| 208 | {0,0x13}, {0,0x2E}, {0,0x47}, {0,0x46}, {0,0x08}, {0,0x3F},
|
| 209 | {0,0x3F}, {0,0x3F}, {0,0x3F}, {0,0x3F},
|
| 210 | {1,0x29},
|
| 211 | {1,0x2C},
|
| 212 | };
|
| 213 |
|
| 214 | struct lcd_lcm_arg lcd_lcm_lead[]=
|
| 215 | {
|
| 216 | {1,0x11},
|
| 217 | {2, 120},
|
| 218 | {1,0xB1}, {0,0x00}, {0,0x08}, {0,0x05},
|
| 219 | {1,0xB2}, {0,0x00}, {0,0x08}, {0,0x05},
|
| 220 | {1,0xB3}, {0,0x00}, {0,0x08}, {0,0x05}, {0,0x00},{0,0x08}, {0,0x05},
|
| 221 | {1,0xB4}, {0,0x00},
|
| 222 | {1,0xC0}, {0,0xA2}, {0,0x02}, {0,0x84},
|
| 223 | {1,0xC1}, {0,0xC5},
|
| 224 | {1,0xC2}, {0,0x0A}, {0,0x00},
|
| 225 | {1,0xC3}, {0,0x8A}, {0,0x2A},
|
| 226 | {1,0xC4}, {0,0x8A}, {0,0xEE},
|
| 227 | {1,0xC5}, {0,0x0E},
|
| 228 | {1,0x36}, {0,LCD_MXMYRGB},
|
| 229 | {1,0xB7}, {0,0x00},
|
| 230 | {1,0xf2}, {0,0x1},
|
| 231 | {1,0xE0}, {0,0x12}, {0,0x18}, {0,0x10}, {0,0x18}, {0,0x33},
|
| 232 | {0,0x2c}, {0,0x25}, {0,0x28}, {0,0x28}, {0,0x27}, {0,0x00},
|
| 233 | {0,0x00}, {0,0x00}, {0,0x00}, {0,0x00},
|
| 234 | {1,0xE1}, {0,0x12}, {0,0x18}, {0,0x10}, {0,0x18}, {0,0x2d},
|
| 235 | {0,0x28}, {0,0x23}, {0,0x28}, {0,0x28}, {0,0x26}, {0,0x2f},
|
| 236 | {0,0x3b}, {0,0x00}, {0,0x03}, {0,0x03}, {0,0x10},
|
| 237 | {1,0x2A}, {0,0x00}, {0,LCD_XS}, {0,0x00}, {0,LCD_XE},
|
| 238 | {1,0x2B}, {0,0x00}, {0,LCD_YS}, {0,0x00},{0,LCD_YE},
|
| 239 | {1,0x3A}, {0,0x05},
|
| 240 | {1,0x29},
|
| 241 | {1,0x2C},
|
| 242 | {2,200}
|
| 243 | };
|
| 244 | /**************************************************************************
|
| 245 | * Types
|
| 246 | **************************************************************************/
|
| 247 | /* D/CX */
|
| 248 | typedef enum
|
| 249 | {
|
| 250 | LCD_DCX_CMD = 0, /* command - low level£¬0 */
|
| 251 | LCD_DCX_DATA, /* data(parameter also as data) - high level£¬1 */
|
| 252 |
|
| 253 | MAX_LCD_DCX_TYPE
|
| 254 | } T_ZDrvLcd_DcxType; // transmission byte type
|
| 255 |
|
| 256 | /* lcd mode */
|
| 257 | typedef enum
|
| 258 | {
|
| 259 | LCD_NORMAL, /* normal mode */
|
| 260 | LCD_SLEEP, /* sleep mode */
|
| 261 |
|
| 262 | MAX_LCD_MODE
|
| 263 | } T_ZDrvLcd_Mode;
|
| 264 |
|
| 265 | /* lead fb parameter */
|
| 266 | struct leadt15ds26fb_par {
|
| 267 | struct spi_device *spi;
|
| 268 | struct fb_info *info;
|
| 269 | struct mutex io_lock;
|
| 270 | struct wake_lock wlock_write;
|
| 271 | struct wake_lock wlock_ioctl;
|
| 272 | struct wake_lock wlock_backlight;
|
| 273 | unsigned int lcd_id;
|
| 274 | unsigned short driver_version;
|
| 275 | bool lcd_backlight;
|
| 276 | unsigned int lcd_brightness;
|
| 277 | T_ZDrvLcd_Mode lcd_sleep_mode;
|
| 278 | int irq_num;
|
| 279 | };
|
| 280 |
|
| 281 | /**************************************************************************
|
| 282 | * Global Variable
|
| 283 | **************************************************************************/
|
| 284 | /* current LCM ID. Actually it is be read from controller. */
|
| 285 | struct leadt15ds26fb_par g_leadt15ds26fb_par;
|
| 286 |
|
| 287 | /* to save current status */
|
| 288 | volatile static T_ZDrvLcd_DcxType g_sLcd_DcxType = LCD_DCX_CMD; /* current D/CX pin status */
|
| 289 | //volatile static T_ZDrvLcd_Mode g_sLcd_Mode = LCD_NORMAL;
|
| 290 | //volatile static bool g_sLcd_Backlight = 0; /* 0 - off; 1 - on */
|
| 291 | //volatile static unsigned int g_sLcd_Brightness = 255; /* [0,255]: 0 - darkest; 255 - brightest */
|
| 292 |
|
| 293 | /* determine SPI type: actrul or simulated */
|
| 294 | static bool use_actual_spi = true;
|
| 295 | struct notifier_block pmu_reinit_notifier;
|
| 296 | static unsigned int last_level = 0;
|
| 297 |
|
| 298 | /**************************************************************************
|
| 299 | * Function Implementation
|
| 300 | **************************************************************************/
|
| 301 |
|
| 302 | /*cs low: config spi pad gpio function, pull down cs pad. cs high: pull up cs, and restore spi function*/
|
| 303 | extern void spi_gpio_3wire_cs(unsigned char level);
|
| 304 | extern void spi_gpio_3wire_write8(unsigned char reg);
|
| 305 | extern unsigned char spi_gpio_3wire_read8(void);
|
| 306 |
|
| 307 |
|
| 308 | void write_st(__u8 rs, __u8 para)
|
| 309 | {
|
| 310 | /* ¸ù¾Ý·¢ËÍÀàÐÍÑ¡ÔñÀ¸ß»òÀµÍRSÒý½Å */
|
| 311 |
|
| 312 | if (rs)
|
| 313 | {RS_H;}
|
| 314 | else
|
| 315 | {RS_L;}
|
| 316 |
|
| 317 | spi_gpio_3wire_cs(GPIO_LOW);
|
| 318 | spi_gpio_3wire_write8(para);
|
| 319 | spi_gpio_3wire_cs(GPIO_HIGH);
|
| 320 | }
|
| 321 |
|
| 322 | __u8 read_st(__u8 reg)
|
| 323 | {
|
| 324 | __u8 i;
|
| 325 | volatile __u8 tmp;
|
| 326 |
|
| 327 | /* ÏÈ·¢ËͶÁÃüÁî */
|
| 328 | spi_gpio_3wire_cs(GPIO_LOW);
|
| 329 | RS_L;
|
| 330 | spi_gpio_3wire_write8(reg);
|
| 331 | /* Çл»GPIO·½Ïò£¬Öðλ½ÓÊÕ */
|
| 332 | RS_H;
|
| 333 | tmp = spi_gpio_3wire_read8();
|
| 334 | spi_gpio_3wire_cs(GPIO_HIGH);
|
| 335 |
|
| 336 | return tmp;
|
| 337 | }
|
| 338 |
|
| 339 | /*******************************************************************************
|
| 340 | * Function: leadt15ds26fb_delayms
|
| 341 | * Description: used to delay.
|
| 342 | * Parameters:
|
| 343 | * (IN)
|
| 344 | * ms: millisecond
|
| 345 | * (OUT):
|
| 346 | * None.
|
| 347 | * Returns:
|
| 348 | *
|
| 349 | *
|
| 350 | * Others:
|
| 351 | ********************************************************************************/
|
| 352 | static inline void leadt15ds26fb_delayms(unsigned int ms)
|
| 353 | {
|
| 354 | mdelay(ms);
|
| 355 | }
|
| 356 |
|
| 357 | /**************************************************************************
|
| 358 | * Function: leadt15ds26fb_spi_config_dcx
|
| 359 | * Description: used to configure D/CX pin. thus, this interface is just for SPI-4.
|
| 360 | * Parameters:
|
| 361 | * (IN)
|
| 362 | * type command or parameter/data
|
| 363 | * (OUT)
|
| 364 | * None.
|
| 365 | * Returns:
|
| 366 | * 0: successed.
|
| 367 | * < 0: others error code. For more details, please refer to the source code.
|
| 368 | * Others:
|
| 369 | * - SPI-3's data packet contains a control bit D/CX and a transmission byte.
|
| 370 | * - SPI-4's data packet contains just transmission byte and
|
| 371 | * control bit D/CX is transferred by the D/CX pin.
|
| 372 | **************************************************************************/
|
| 373 | static int leadt15ds26fb_spi_config_dcx(struct spi_device *spi, T_ZDrvLcd_DcxType type)
|
| 374 | {
|
| 375 | int ret = 0;
|
| 376 | struct zx29_lcd_platform_data *pdata = (struct zx29_lcd_platform_data *)spi->dev.platform_data;
|
| 377 |
|
| 378 | //LCD_PRINFO("lead sLcd_GpioDCX=%d\n", pdata->spi_dcx_gpio);
|
| 379 | gpio_set_value(pdata->spi_dcx_gpio, (type == LCD_DCX_DATA) ? GPIO_HIGH : GPIO_LOW);
|
| 380 | g_sLcd_DcxType = type;
|
| 381 |
|
| 382 | return ret;
|
| 383 | }
|
| 384 |
|
| 385 | /**************************************************************************
|
| 386 | * Function: leadt15ds26fb_spi_write_cmd
|
| 387 | * Description: used to send command-code to the LCD device IC.
|
| 388 | * Parameters:
|
| 389 | * (IN)
|
| 390 | * cmd command
|
| 391 | * (OUT)
|
| 392 | * None.
|
| 393 | * Returns:
|
| 394 | * It returns zero on success, else a negative error code.
|
| 395 | * Others:
|
| 396 | * - SPI-3's data packet contains a control bit D/CX and a transmission byte.
|
| 397 | * - SPI-4's data packet contains just transmission byte and
|
| 398 | * control bit D/CX is transferred by the D/CX pin.
|
| 399 | **************************************************************************/
|
| 400 | static int leadt15ds26fb_spi_write_cmd(struct spi_device *spi, unsigned char cmd)
|
| 401 | {
|
| 402 | int ret = 0;
|
| 403 | unsigned char buf[1] = {cmd};
|
| 404 |
|
| 405 | if (use_actual_spi){
|
| 406 | /* adjust D/CX level: high - command */
|
| 407 | ret += leadt15ds26fb_spi_config_dcx(spi, LCD_DCX_CMD);
|
| 408 |
|
| 409 | /* then send 8bits cmd to SPI device */
|
| 410 | ret += spi_write(spi, buf, 1);
|
| 411 | }
|
| 412 | else{
|
| 413 | write_st(LCD_DCX_CMD, cmd);
|
| 414 | }
|
| 415 |
|
| 416 | return ret;
|
| 417 | }
|
| 418 |
|
| 419 | /**************************************************************************
|
| 420 | * Function: leadt15ds26fb_spi_write_data/leadt15ds26fb_spi_write_datablock
|
| 421 | * Description: used to send parameter/data to the LCD device IC.
|
| 422 | * Parameters:
|
| 423 | * (IN)
|
| 424 | * data parameter or RAM data.
|
| 425 | * (OUT)
|
| 426 | * None.
|
| 427 | * Returns:
|
| 428 | * 0: successed.
|
| 429 | * < 0: others error code. For more details, please refer to the source code.
|
| 430 | * Others:
|
| 431 | * - SPI-3's data packet contains a control bit D/CX and a transmission byte.
|
| 432 | * - SPI-4's data packet contains just transmission byte and
|
| 433 | * control bit D/CX is transferred by the D/CX pin.
|
| 434 | **************************************************************************/
|
| 435 | static int leadt15ds26fb_spi_write_data(struct spi_device *spi, unsigned char data)
|
| 436 | {
|
| 437 | int ret = 0;
|
| 438 | unsigned char buf[1] = {data};
|
| 439 |
|
| 440 | if (use_actual_spi){
|
| 441 | /* reduce D/CX change frequency */
|
| 442 | if (LCD_DCX_DATA != g_sLcd_DcxType){
|
| 443 | ret += leadt15ds26fb_spi_config_dcx(spi, LCD_DCX_DATA);
|
| 444 | }
|
| 445 | /* then send 8bits data to SPI device */
|
| 446 | ret += spi_write(spi, buf, 1);
|
| 447 | }
|
| 448 | else{
|
| 449 | write_st(LCD_DCX_DATA, data);
|
| 450 | }
|
| 451 |
|
| 452 | return ret;
|
| 453 | }
|
| 454 |
|
| 455 | static int leadt15ds26fb_spi_write_datablock(struct spi_device *spi, unsigned char* buf, unsigned int size)
|
| 456 | {
|
| 457 | int ret = 0;
|
| 458 | unsigned int i = 0;
|
| 459 |
|
| 460 | if (use_actual_spi){
|
| 461 | /* reduce D/CX change frequency */
|
| 462 | if (LCD_DCX_DATA != g_sLcd_DcxType){
|
| 463 | ret += leadt15ds26fb_spi_config_dcx(spi, LCD_DCX_DATA);
|
| 464 | }
|
| 465 |
|
| 466 | /* then write data block to SPI device */
|
| 467 | ret += spi_write(spi, buf, size);
|
| 468 | }
|
| 469 | else{
|
| 470 | for (i = 0; i < size; i++)
|
| 471 | write_st(LCD_DCX_DATA, buf[i]);
|
| 472 | }
|
| 473 |
|
| 474 | return ret;
|
| 475 | }
|
| 476 |
|
| 477 | /**************************************************************************
|
| 478 | * Function: leadt15ds26fb_reset
|
| 479 | * Description: used to reset the LCD device opened previously.
|
| 480 | * Parameters:
|
| 481 | * (IN)
|
| 482 | * None.
|
| 483 | * (OUT)
|
| 484 | * None.
|
| 485 | * Returns:
|
| 486 | * None.
|
| 487 | * Others:
|
| 488 | * None.
|
| 489 | **************************************************************************/
|
| 490 | static int leadt15ds26fb_reset(struct fb_info *info)
|
| 491 | {
|
| 492 | struct leadt15ds26fb_par *par = (struct leadt15ds26fb_par *)(info->par);
|
| 493 | struct zx29_lcd_platform_data *pdata = (struct zx29_lcd_platform_data *)par->spi->dev.platform_data;
|
| 494 | int ret = 0;
|
| 495 |
|
| 496 | gpio_set_value(pdata->lcd_rst_gpio, GPIO_HIGH);
|
| 497 | leadt15ds26fb_delayms(10);
|
| 498 |
|
| 499 | gpio_set_value(pdata->lcd_rst_gpio, GPIO_LOW);
|
| 500 | leadt15ds26fb_delayms(10);
|
| 501 |
|
| 502 | gpio_set_value(pdata->lcd_rst_gpio, GPIO_HIGH);
|
| 503 | leadt15ds26fb_delayms(120);
|
| 504 |
|
| 505 | return ret;
|
| 506 | }
|
| 507 |
|
| 508 | /**************************************************************************
|
| 509 | * Function: leadt15ds26fb_init_gpio
|
| 510 | * Description: used to initialize GPIO usage.
|
| 511 | * Parameters:
|
| 512 | * (IN)
|
| 513 | *
|
| 514 | * (OUT)
|
| 515 | *
|
| 516 | * Returns:
|
| 517 | * 0: successed.
|
| 518 | * < 0: others error code. For more details, please refer to the source code.
|
| 519 | * Others:
|
| 520 | **************************************************************************/
|
| 521 | static int leadt15ds26fb_init_gpio(struct fb_info *info)
|
| 522 | {
|
| 523 | int ret = 0;
|
| 524 | struct leadt15ds26fb_par *par = (struct leadt15ds26fb_par *)(info->par);
|
| 525 | struct zx29_lcd_platform_data *pdata = (struct zx29_lcd_platform_data *)par->spi->dev.platform_data;
|
| 526 | #ifndef CONFIG_LCD_BLG_SINK
|
| 527 | /* backlight */
|
| 528 | ret = gpio_request(pdata->lcd_blg_gpio,"lcd_blgen");
|
| 529 | if(ret < 0)
|
| 530 | LCD_PRINFO("request lcd_blgen failed\n");
|
| 531 | zx29_gpio_function_sel(pdata->lcd_blg_gpio, pdata->lcd_blg_gpio_fun_sel);
|
| 532 | zx29_gpio_set_direction(pdata->lcd_blg_gpio, GPIO_OUT);
|
| 533 | #endif
|
| 534 | /* reset */
|
| 535 | ret = gpio_request(pdata->lcd_rst_gpio,"lcd_reset");
|
| 536 | if(ret < 0)
|
| 537 | LCD_PRINFO("request lcd_reset failed\n");
|
| 538 | zx29_gpio_function_sel(pdata->lcd_rst_gpio, pdata->lcd_rst_gpio_fun_sel);
|
| 539 | zx29_gpio_set_direction(pdata->lcd_rst_gpio, GPIO_OUT);
|
| 540 |
|
| 541 | //ret = gpio_request(pdata->spi_dcx_gpio,"spi_dcx");
|
| 542 | //if(ret < 0)
|
| 543 | //LCD_PRINFO("request lcd_reset failed\n");
|
| 544 | zx29_gpio_function_sel(pdata->spi_dcx_gpio, pdata->spi_dcx_gpio_fun_sel);
|
| 545 | zx29_gpio_set_direction(pdata->spi_dcx_gpio, GPIO_OUT);
|
| 546 |
|
| 547 | #ifdef CONFIG_FB_LCD_TE_ON
|
| 548 | ret = gpio_request(PIN_LCD_TE, "lcd_syn");
|
| 549 | if(ret < 0)
|
| 550 | LCD_PRINFO("request lcd_syn failed\n");
|
| 551 | par->irq_num = gpio_to_irq(PIN_LCD_TE);
|
| 552 | zx29_gpio_config(PIN_LCD_TE, GPIO_TE_FUNC_SEL);
|
| 553 | zx29_gpio_set_inttype(PIN_LCD_TE, IRQ_TYPE_EDGE_RISING);
|
| 554 | zx29_gpio_pd_pu_set(PIN_LCD_TE, IO_CFG_PULL_DOWN);
|
| 555 | pcu_clr_irq_pending(par->irq_num);
|
| 556 | #endif
|
| 557 |
|
| 558 | return ret;
|
| 559 | }
|
| 560 |
|
| 561 | #if 0
|
| 562 | /**************************************************************************
|
| 563 | * Function: leadt15ds26fb_init_backlight
|
| 564 | * Description: used to initialize backlight usage.
|
| 565 | * Parameters:
|
| 566 | * (IN)
|
| 567 | *
|
| 568 | * (OUT)
|
| 569 | *
|
| 570 | * Returns:
|
| 571 | * 0: successed.
|
| 572 | * < 0: others error code. For more details, please refer to the source code.
|
| 573 | * Others:7510 control blg use blg controller.but 7520 not
|
| 574 | **************************************************************************/
|
| 575 | static int leadt15ds26fb_init_backlight(struct fb_info *info)
|
| 576 | {
|
| 577 | struct leadt15ds26fb_par *par = (struct leadt15ds26fb_par *)(info->par);
|
| 578 | struct zx29_lcd_platform_data *pdata = (struct zx29_lcd_platform_data *)par->spi->dev.platform_data;
|
| 579 | //#ifdef CONFIG_RECOVERY_SYSTEM
|
| 580 | //#else
|
| 581 | gpio_set_value(pdata->lcd_blg_gpio,GPIO_HIGH);
|
| 582 | //#endif
|
| 583 | return 0;
|
| 584 | }
|
| 585 | #endif
|
| 586 |
|
| 587 | #ifdef CONFIG_FB_LCD_TE_ON
|
| 588 |
|
| 589 | static irqreturn_t LcdSync_irq_handler(int irq, void *dev_id)
|
| 590 | {
|
| 591 | //printk("LcdSync_irq_handler irq=%d.\n", irq);
|
| 592 | disable_irq_nosync(irq);
|
| 593 | pcu_clr_irq_pending(irq);
|
| 594 |
|
| 595 | return IRQ_WAKE_THREAD;
|
| 596 | }
|
| 597 |
|
| 598 | /**************************************************************************
|
| 599 | * Function: LcdSync_Isr
|
| 600 | * Description: put lcd sync sema.
|
| 601 | * Parameters:
|
| 602 | * (IN)
|
| 603 | * None.
|
| 604 | * (OUT)
|
| 605 | * None.
|
| 606 | * Returns:
|
| 607 | * 0: successed.
|
| 608 | * < 0: others error code. For more details, please refer to the source code.
|
| 609 | * Others:
|
| 610 | * None.
|
| 611 | **************************************************************************/
|
| 612 | static irqreturn_t LcdSync_Isr(int irq, void *data)
|
| 613 | {
|
| 614 |
|
| 615 | if((g_Lcd_Fmark_count.counter++) > 0xff)
|
| 616 | {
|
| 617 | g_Lcd_Fmark_count.counter = 10;
|
| 618 | }
|
| 619 | //printk("LcdSync_Isr irq=%d.\n", irq);
|
| 620 | if(g_LcdSema_Flag == true)
|
| 621 | {
|
| 622 | up(&gLcd_SyncSema);
|
| 623 | g_Lcd_tick_count = jiffies;//zOss_GetTickCount();
|
| 624 | g_LcdSema_Flag = false;
|
| 625 | }
|
| 626 |
|
| 627 | enable_irq(irq);
|
| 628 |
|
| 629 | return IRQ_HANDLED;
|
| 630 | }
|
| 631 | #endif
|
| 632 |
|
| 633 | /**************************************************************************
|
| 634 | * Function: leadt15ds26fb_init_lcm
|
| 635 | * Description: used to initialize lead(ST7735S)
|
| 636 | * Parameters:
|
| 637 | * (IN)
|
| 638 | * None.
|
| 639 | * (OUT)
|
| 640 | * None.
|
| 641 | * Returns:
|
| 642 | * 0: successed.
|
| 643 | * < 0: others error code. For more details, please refer to the source code.
|
| 644 | * Others:
|
| 645 | * None.
|
| 646 | **************************************************************************/
|
| 647 | static int leadt15ds26fb_init_lcm(struct fb_info *info)
|
| 648 | {
|
| 649 | int ret = 0;
|
| 650 | int i = 0;
|
| 651 | int arg_count = 0;
|
| 652 | unsigned int uiRow, uiCol;
|
| 653 | struct leadt15ds26fb_par *par = (struct leadt15ds26fb_par *)(info->par);
|
| 654 |
|
| 655 | /* hardware reset */
|
| 656 | ret |= leadt15ds26fb_reset(info);
|
| 657 |
|
| 658 | /* read lcd module's manufacturer ID */
|
| 659 | //par->lcd_id= read_st(0xda);
|
| 660 | LCD_PRINFO("[LCD]leadt15ds26fb_init_lcm lcd_id = 0x%x.\n",par->lcd_id);
|
| 661 | switch(par->lcd_id){
|
| 662 |
|
| 663 | case LCM_LEAD_ID:/* LCM: lead T15DDS26 */
|
| 664 | arg_count = sizeof(lcd_lcm_lead)/sizeof(struct lcd_lcm_arg);
|
| 665 | for(i = 0; i< arg_count; i++){
|
| 666 | if(lcd_lcm_lead[i].flag == LCD_LCM_CMD)
|
| 667 | ret |= leadt15ds26fb_spi_write_cmd(par->spi, lcd_lcm_lead[i].arg);
|
| 668 | else if(lcd_lcm_lead[i].flag == LCD_LCM_DATA)
|
| 669 | ret = leadt15ds26fb_spi_write_data(par->spi, lcd_lcm_lead[i].arg);
|
| 670 | else if(lcd_lcm_lead[i].flag == LCD_LCM_SLEEP)
|
| 671 | leadt15ds26fb_delayms(lcd_lcm_lead[i].arg);
|
| 672 | else
|
| 673 | return -1;
|
| 674 | }
|
| 675 | break;
|
| 676 |
|
| 677 | case LCM_ST7789V_ID:/* LCM: st7789 */
|
| 678 | arg_count = sizeof(lcd_lcm_st7789v)/sizeof(struct lcd_lcm_arg);
|
| 679 | for(i = 0; i< arg_count; i++){
|
| 680 | if(lcd_lcm_st7789v[i].flag == LCD_LCM_CMD)
|
| 681 | ret |= leadt15ds26fb_spi_write_cmd(par->spi, lcd_lcm_st7789v[i].arg);
|
| 682 | else if(lcd_lcm_st7789v[i].flag == LCD_LCM_DATA)
|
| 683 | ret = leadt15ds26fb_spi_write_data(par->spi, lcd_lcm_st7789v[i].arg);
|
| 684 | else if(lcd_lcm_st7789v[i].flag == LCD_LCM_SLEEP)
|
| 685 | leadt15ds26fb_delayms(lcd_lcm_st7789v[i].arg);
|
| 686 | else
|
| 687 | return -1;
|
| 688 | }
|
| 689 | break;
|
| 690 |
|
| 691 | case LCM_ILI9342C_ID:/* LCM: ILI9342C */
|
| 692 | arg_count = sizeof(lcd_lcm_ili9342c)/sizeof(struct lcd_lcm_arg);
|
| 693 | for(i = 0; i< arg_count; i++){
|
| 694 | if(lcd_lcm_ili9342c[i].flag == LCD_LCM_CMD)
|
| 695 | ret |= leadt15ds26fb_spi_write_cmd(par->spi, lcd_lcm_ili9342c[i].arg);
|
| 696 | else if(lcd_lcm_ili9342c[i].flag == LCD_LCM_DATA)
|
| 697 | ret = leadt15ds26fb_spi_write_data(par->spi, lcd_lcm_ili9342c[i].arg);
|
| 698 | else if(lcd_lcm_ili9342c[i].flag == LCD_LCM_SLEEP)
|
| 699 | leadt15ds26fb_delayms(lcd_lcm_ili9342c[i].arg);
|
| 700 | else
|
| 701 | return -1;
|
| 702 | }
|
| 703 | break;
|
| 704 | default:/* LCM: success S93521A */
|
| 705 | arg_count = sizeof(lcd_lcm_success)/sizeof(struct lcd_lcm_arg);
|
| 706 | for(i = 0; i< arg_count; i++){
|
| 707 | if(lcd_lcm_success[i].flag == LCD_LCM_CMD)
|
| 708 | ret |= leadt15ds26fb_spi_write_cmd(par->spi, lcd_lcm_success[i].arg);
|
| 709 | else if(lcd_lcm_success[i].flag == LCD_LCM_DATA)
|
| 710 | ret |= leadt15ds26fb_spi_write_data(par->spi, lcd_lcm_success[i].arg);
|
| 711 | else if(lcd_lcm_success[i].flag == LCD_LCM_SLEEP)
|
| 712 | leadt15ds26fb_delayms(lcd_lcm_success[i].arg);
|
| 713 | else
|
| 714 | return -1;
|
| 715 | }
|
| 716 | break;
|
| 717 | }
|
| 718 |
|
| 719 | if(LCM_ST7789V_ID == par->lcd_id)
|
| 720 | {
|
| 721 | ret |= leadt15ds26fb_spi_write_cmd(par->spi, 0x36);
|
| 722 | ret |= leadt15ds26fb_spi_write_data(par->spi, info->var.colorspace);
|
| 723 | }
|
| 724 |
|
| 725 | if(ret !=0)
|
| 726 | LCD_PRINFO("[LCD][LEAD] lcd lcm init module,arg_count = %d.\n",arg_count);
|
| 727 |
|
| 728 | /* to black */
|
| 729 | for (uiRow = 0; uiRow < info->var.xres; uiRow++)
|
| 730 | {
|
| 731 | for (uiCol = 0; uiCol < info->var.yres; uiCol++)
|
| 732 | {
|
| 733 | ret |= leadt15ds26fb_spi_write_data(par->spi, 0x00);
|
| 734 | ret |= leadt15ds26fb_spi_write_data(par->spi, 0x00);
|
| 735 | }
|
| 736 | }
|
| 737 |
|
| 738 | LCD_PRINFO("[LCD][LEAD]init lcd module.\n");
|
| 739 |
|
| 740 | return ret;
|
| 741 | }
|
| 742 |
|
| 743 | /**************************************************************************
|
| 744 | * Function: Lcd_EnterSleepMode
|
| 745 | * Description: used to let the LCD device into sleep mode.
|
| 746 | * Parameters:
|
| 747 | * (IN)
|
| 748 | * bIn enter or exit sleep mode
|
| 749 | * (OUT)
|
| 750 | * None.
|
| 751 | * Returns:
|
| 752 | * 0: successed.
|
| 753 | * < 0: others error code. For more details, please refer to the source code.
|
| 754 | * Others:
|
| 755 | * None.
|
| 756 | **************************************************************************/
|
| 757 | static int leadt15ds26fb_set_sleep(struct fb_info *info, bool enable )
|
| 758 | {
|
| 759 | int ret = 0;
|
| 760 | struct leadt15ds26fb_par *par = (struct leadt15ds26fb_par *)(info->par);
|
| 761 |
|
| 762 | /* exit sleep-mode */
|
| 763 | if ((!enable) && (LCD_SLEEP== par->lcd_sleep_mode)){
|
| 764 | ret = leadt15ds26fb_spi_write_cmd(par->spi, 0x11);
|
| 765 | leadt15ds26fb_delayms(120); // leave 120ms
|
| 766 | par->lcd_sleep_mode = LCD_NORMAL;
|
| 767 | LCD_PRINFO("[LCD][LEAD]sleep out.\n");
|
| 768 | }
|
| 769 | /* enter sleep-mode */
|
| 770 | else if(enable && (LCD_NORMAL == par->lcd_sleep_mode)){
|
| 771 | ret = leadt15ds26fb_spi_write_cmd(par->spi, 0x10);
|
| 772 | leadt15ds26fb_delayms(120); // leave 120ms
|
| 773 | par->lcd_sleep_mode = LCD_SLEEP;
|
| 774 | LCD_PRINFO("[LCD][LEAD]sleep in.\n");
|
| 775 | }
|
| 776 |
|
| 777 | return ret;
|
| 778 | }
|
| 779 |
|
| 780 | /**************************************************************************
|
| 781 | * Function: leadt15ds26fb_set_backlight
|
| 782 | * Description: used to turn on/off the LCD device's backlight.
|
| 783 | * Parameters:
|
| 784 | * (IN)
|
| 785 | * None.
|
| 786 | * (OUT)
|
| 787 | * None.
|
| 788 | * Returns:
|
| 789 | * 0: successed.
|
| 790 | * < 0: others error code. For more details, please refer to the source code.
|
| 791 | * Others:
|
| 792 | * None.
|
| 793 | **************************************************************************/
|
| 794 | static int leadt15ds26fb_set_backlight(struct fb_info *info, bool enable)
|
| 795 | {
|
| 796 | struct leadt15ds26fb_par *par = (struct leadt15ds26fb_par *)(info->par);
|
| 797 | struct zx29_lcd_platform_data *pdata = (struct zx29_lcd_platform_data *)par->spi->dev.platform_data;
|
| 798 | int ret = 0;
|
| 799 | if (enable){
|
| 800 | /* turn on backlight */
|
| 801 | zx_cpuidle_set_busy(IDLE_FLAG_LCD);
|
| 802 |
|
| 803 | #ifdef CONFIG_LCD_BLG_SINK
|
| 804 | ret = zx234297_set_sink(ZX234297_SINK1,1,SINK_CURRENT_5MA);
|
| 805 | if(ret < 0)
|
| 806 | LCD_PRERR("[LCD][LEAD] backlight on error!\n");
|
| 807 | #else
|
| 808 | gpio_set_value(pdata->lcd_blg_gpio,GPIO_HIGH);
|
| 809 | #endif
|
| 810 | #ifdef CONFIG_PM_WAKELOCKS
|
| 811 | /* when backlight is on, prevent system into sleep */
|
| 812 | wake_lock(&(par->wlock_backlight));
|
| 813 | #endif
|
| 814 | if( LCD_SLEEP == par->lcd_sleep_mode){
|
| 815 | LCD_PRINFO("[LCD][LEAD] backlight on but the lcd in sleep mode!!!!\n");
|
| 816 | }
|
| 817 | }
|
| 818 | else{
|
| 819 | /* turn off backlight */
|
| 820 | zx_cpuidle_set_free(IDLE_FLAG_LCD);
|
| 821 | #ifdef CONFIG_LCD_BLG_SINK
|
| 822 | ret = zx234297_set_sink(ZX234297_SINK1,0,SINK_CURRENT_5MA);
|
| 823 | if(ret < 0)
|
| 824 | LCD_PRERR("[LCD][LEAD] backlight off error!\n");
|
| 825 | #else
|
| 826 | gpio_set_value(pdata->lcd_blg_gpio,GPIO_LOW);
|
| 827 | #endif
|
| 828 | last_level = 0;
|
| 829 | #ifdef CONFIG_PM_WAKELOCKS
|
| 830 | /* when backlight is off, allow system into sleep */
|
| 831 | wake_unlock(&(par->wlock_backlight));
|
| 832 | #endif
|
| 833 | }
|
| 834 |
|
| 835 | par->lcd_backlight= enable;
|
| 836 | LCD_PRINFO("[LCD][LEAD]backlight %s.\n", enable ? "on" : "off");
|
| 837 | return 0;
|
| 838 | }
|
| 839 |
|
| 840 |
|
| 841 | //add for reset.c
|
| 842 | void leadt15ds26fb_setbacklight_before_reset(bool enable)
|
| 843 | {
|
| 844 | struct leadt15ds26fb_par *par = (struct leadt15ds26fb_par *)(g_leadt15ds26fb_par.info->par);
|
| 845 | struct zx29_lcd_platform_data *pdata = (struct zx29_lcd_platform_data *)par->spi->dev.platform_data;
|
| 846 | int ret = 0;
|
| 847 | #ifdef CONFIG_LCD_BLG_SINK
|
| 848 | ret = zx234297_set_sink(ZX234297_SINK1,enable,SINK_CURRENT_5MA);
|
| 849 | if(ret < 0)
|
| 850 | LCD_PRERR("error.\n");
|
| 851 | #else
|
| 852 | //leadt15ds26fb_set_backlight(g_leadt15ds26fb_par.info, enable);
|
| 853 | if (enable)
|
| 854 | gpio_set_value(pdata->lcd_blg_gpio,GPIO_HIGH);
|
| 855 | else
|
| 856 | gpio_set_value(pdata->lcd_blg_gpio,GPIO_LOW);
|
| 857 | #endif
|
| 858 | LCD_PRINFO(" %s.\n", enable ? "on" : "off");
|
| 859 |
|
| 860 | }
|
| 861 | /*************************************************************************
|
| 862 | * Name:leadt15ds26fb_set_brightness
|
| 863 | * Description:
|
| 864 | * Note:not realize in the function
|
| 865 | **************************************************************************/
|
| 866 | SINT32 set_backlight(struct fb_info *info, int level)
|
| 867 | {
|
| 868 | unsigned int i = 0;
|
| 869 | unsigned int j = 0;
|
| 870 | unsigned int real_level = 0;
|
| 871 | int ret = 0;
|
| 872 |
|
| 873 | struct leadt15ds26fb_par *par = (struct leadt15ds26fb_par *)(info->par);
|
| 874 | struct zx29_lcd_platform_data *pdata = (struct zx29_lcd_platform_data *)par->spi->dev.platform_data;
|
| 875 |
|
| 876 | if (level > 255 || level < 0)
|
| 877 | {
|
| 878 | return -1;
|
| 879 | }
|
| 880 | else if (200 < level && level <= 250)
|
| 881 | {
|
| 882 | real_level = 5;
|
| 883 | }
|
| 884 | else if (150 < level && level <= 200)
|
| 885 | {
|
| 886 | real_level = 7;
|
| 887 | }
|
| 888 | else if (100 < level && level <= 150)
|
| 889 | {
|
| 890 | real_level = 9;
|
| 891 | }
|
| 892 | else if (50 < level && level <= 100)
|
| 893 | {
|
| 894 | real_level = 11;
|
| 895 | }
|
| 896 | else if (25 < level && level <= 50)
|
| 897 | {
|
| 898 | real_level = 13;
|
| 899 | }
|
| 900 | else if (0 < level && level <= 25)
|
| 901 | {
|
| 902 | real_level = 15;
|
| 903 | }
|
| 904 | //real_level = level/16 - 2;
|
| 905 |
|
| 906 | //real_level = 16 - real_level; // 15 12 9 6 3
|
| 907 |
|
| 908 | LCD_PRINFO("lcd:pulse to set is %d\n",real_level);
|
| 909 |
|
| 910 | //turn light on
|
| 911 | if (real_level > last_level)
|
| 912 | {
|
| 913 | j = real_level -last_level;
|
| 914 | }
|
| 915 | //turn light off
|
| 916 | else if (real_level < last_level)
|
| 917 | {
|
| 918 | j = real_level + 16 - last_level;
|
| 919 | }
|
| 920 |
|
| 921 | for(i =0 ; i < j;i++ )
|
| 922 | {
|
| 923 |
|
| 924 | #ifdef CONFIG_LCD_BLG_SINK
|
| 925 | ret += zx234297_set_sink(ZX234297_SINK1,0,SINK_CURRENT_5MA);
|
| 926 | udelay(15);
|
| 927 | ret += zx234297_set_sink(ZX234297_SINK1,1,SINK_CURRENT_5MA);
|
| 928 | udelay(15);
|
| 929 | if(ret < 0)
|
| 930 | LCD_PRERR("error\n");
|
| 931 | #else
|
| 932 | gpio_set_value(pdata->lcd_blg_gpio, GPIO_LOW);
|
| 933 | udelay(15);
|
| 934 | gpio_set_value(pdata->lcd_blg_gpio, GPIO_HIGH);
|
| 935 | udelay(15); //us
|
| 936 | #endif
|
| 937 | }
|
| 938 | last_level = (last_level + j)%16;
|
| 939 | return 0;
|
| 940 | }
|
| 941 | static int leadt15ds26fb_set_brightness(struct fb_info *info, unsigned int level)
|
| 942 | {
|
| 943 | int ret = 0;
|
| 944 | struct leadt15ds26fb_par *par = (struct leadt15ds26fb_par *)(info->par);
|
| 945 |
|
| 946 | if (level > 255)
|
| 947 | {
|
| 948 | return -EINVAL;
|
| 949 | }
|
| 950 | ret = set_backlight(info, level);
|
| 951 | //LCD_REG_WRITE(BLG_LIGHT_LEVEL_ADDR, level);
|
| 952 |
|
| 953 | LCD_PRINFO("[LCD][LEAD]leadt15ds26fb_set_brightness level %d.\n",level);
|
| 954 | par->lcd_brightness= level;
|
| 955 |
|
| 956 | return ret;
|
| 957 | }
|
| 958 |
|
| 959 | /**************************************************************************
|
| 960 | * Function: leadt15ds26fb_set_ram_address
|
| 961 | * Description: used to set specified start point of DISPLAY RAM for updating laterly
|
| 962 | * Parameters:
|
| 963 | * (IN)
|
| 964 | * uiLeft left postion
|
| 965 | * uiTop top postion
|
| 966 | * uiRight left postion
|
| 967 | * uiBottom bottom postion
|
| 968 | * (OUT)
|
| 969 | * None.
|
| 970 | * Returns:
|
| 971 | * 0: successed.
|
| 972 | * < 0: others error code. For more details, please refer to the source code.
|
| 973 | * Others:
|
| 974 | * None.
|
| 975 | **************************************************************************/
|
| 976 | static int leadt15ds26fb_set_ram_address(struct fb_info *info, unsigned short uiLeft, unsigned short uiTop, unsigned short uiRight, unsigned short uiBottom)
|
| 977 | {
|
| 978 | int ret = 0;
|
| 979 | struct leadt15ds26fb_par *par = (struct leadt15ds26fb_par *)(info->par);
|
| 980 |
|
| 981 | ret |= leadt15ds26fb_spi_write_cmd(par->spi, 0x2A);
|
| 982 | ret |= leadt15ds26fb_spi_write_data(par->spi, 0x00);
|
| 983 | ret |= leadt15ds26fb_spi_write_data(par->spi, uiLeft % (info->var.xres) + info->var.xoffset);
|
| 984 | ret |= leadt15ds26fb_spi_write_data(par->spi, (uiRight>>8));
|
| 985 | ret |= leadt15ds26fb_spi_write_data(par->spi, (uiRight&0xff)); // new
|
| 986 |
|
| 987 | ret |= leadt15ds26fb_spi_write_cmd(par->spi, 0x2B);
|
| 988 | ret |= leadt15ds26fb_spi_write_data(par->spi, 0x00);
|
| 989 | ret |= leadt15ds26fb_spi_write_data(par->spi, uiTop % (info->var.yres) + info->var.yoffset);
|
| 990 | ret |= leadt15ds26fb_spi_write_data(par->spi, (uiBottom>>8));
|
| 991 | ret |= leadt15ds26fb_spi_write_data(par->spi, (uiBottom&0xff));
|
| 992 |
|
| 993 | return ret;
|
| 994 | }
|
| 995 |
|
| 996 | /**************************************************************************
|
| 997 | * Function: leadt15ds26fb_mmap
|
| 998 | * Description: used to remap framebuffer's address to user space.
|
| 999 | * Parameters:
|
| 1000 | * (IN)
|
| 1001 | *
|
| 1002 | * uiLeft left postion
|
| 1003 | * uiTop top postion
|
| 1004 | * uiWidth rectangle width
|
| 1005 | * uiHeight rectangle height
|
| 1006 | * (OUT)
|
| 1007 | * None.
|
| 1008 | * Returns:
|
| 1009 | * 0: successed.
|
| 1010 | * < 0: others error code. For more details, please refer to the source code.
|
| 1011 | * Others:
|
| 1012 | * Most drivers don't need their own mmap function.
|
| 1013 | **************************************************************************/
|
| 1014 | static int leadt15ds26fb_mmap(struct fb_info *info, struct vm_area_struct *vma)
|
| 1015 | {
|
| 1016 | /* this is uClinux (no MMU) specific code */
|
| 1017 | vma->vm_flags |= VM_DONTEXPAND; // | VM_DONTDUMP;
|
| 1018 | vma->vm_start = info->screen_base;
|
| 1019 |
|
| 1020 | return 0;
|
| 1021 | }
|
| 1022 |
|
| 1023 | #ifdef CONFIG_ARCH_ZX297520V3_FWP
|
| 1024 |
|
| 1025 | int lcd_SetRamAddr(struct fb_info *info, unsigned short uiCol, unsigned short uiPage)
|
| 1026 | {
|
| 1027 | int ret = 0;
|
| 1028 | struct leadt15ds26fb_par *par = (struct leadt15ds26fb_par *)(info->par);
|
| 1029 |
|
| 1030 | /*set column address*/
|
| 1031 | ret |= leadt15ds26fb_spi_write_cmd(par->spi, START_HIGH_BIT |((uiCol>>4) & 0x0F)); // ¸ß4λ
|
| 1032 | ret |= leadt15ds26fb_spi_write_cmd(par->spi, (START_LOW_BIT | (uiCol & 0x0F))+START_LOW_PY); // µÍ4λ
|
| 1033 |
|
| 1034 | /*set page address*/
|
| 1035 | ret |= leadt15ds26fb_spi_write_cmd(par->spi, START_PAGE | (uiPage & 0x0F));
|
| 1036 |
|
| 1037 | return ret;
|
| 1038 | }
|
| 1039 |
|
| 1040 | int lcd_WritePixel(struct fb_info *info, unsigned short rgb565, unsigned short uiRow, unsigned short uiCol)
|
| 1041 | {
|
| 1042 | int ret = 0;
|
| 1043 | unsigned short page_index = uiRow / LCD_PAGE_HEIGHT;
|
| 1044 | unsigned short ram_offset = page_index * LCD_WIDTH + uiCol;
|
| 1045 | unsigned short bit_shift = uiRow % LCD_PAGE_HEIGHT;
|
| 1046 |
|
| 1047 | if (rgb565 != 0 )
|
| 1048 | *(info->screen_base + info->fix.smem_len + ram_offset) &= ~(0x01 << bit_shift);
|
| 1049 | else
|
| 1050 | *(info->screen_base + info->fix.smem_len + ram_offset) |= (0x01 << bit_shift);
|
| 1051 |
|
| 1052 | return ret;
|
| 1053 | }
|
| 1054 |
|
| 1055 |
|
| 1056 | #endif
|
| 1057 |
|
| 1058 | /**************************************************************************
|
| 1059 | * Function: leadt15ds26fb_write
|
| 1060 | * Description: used to update a specified rectangle area of the LCD device opened previously.
|
| 1061 | * Parameters:
|
| 1062 | * (IN)
|
| 1063 | * pBuf data buffer
|
| 1064 | * uiLeft left postion
|
| 1065 | * uiTop top postion
|
| 1066 | * uiWidth rectangle width
|
| 1067 | * uiHeight rectangle height
|
| 1068 | * (OUT)
|
| 1069 | * None.
|
| 1070 | * Returns:
|
| 1071 | * 0: successed.
|
| 1072 | * < 0: others error code. For more details, please refer to the source code.
|
| 1073 | * Others:
|
| 1074 | * None.
|
| 1075 | **************************************************************************/
|
| 1076 | static ssize_t leadt15ds26fb_write(struct fb_info *info, const char __user *buf, size_t count, loff_t *ppos)
|
| 1077 | {
|
| 1078 | int ret = 0;
|
| 1079 | struct leadt15ds26fb_par *par = (struct leadt15ds26fb_par *)(info->par);
|
| 1080 | unsigned long screen_pos = *ppos;
|
| 1081 | unsigned char __iomem *dst;
|
| 1082 | unsigned int block_nr;
|
| 1083 | unsigned int nr;
|
| 1084 | unsigned short row, col, pixel_value;
|
| 1085 | unsigned short cur_page;
|
| 1086 |
|
| 1087 | if (!count || !buf)
|
| 1088 | return -EINVAL;
|
| 1089 |
|
| 1090 | if (screen_pos > (info->fix.smem_len))
|
| 1091 | return -EFBIG;
|
| 1092 |
|
| 1093 | /* if LCD is in sleep-mode, return directly. */
|
| 1094 | if(LCD_SLEEP == par->lcd_sleep_mode){
|
| 1095 | return 0;
|
| 1096 | }
|
| 1097 |
|
| 1098 | /* in case of reentry. */
|
| 1099 | mutex_lock(&(par->io_lock));
|
| 1100 |
|
| 1101 | if (count + screen_pos > (info->fix.smem_len))
|
| 1102 | count = (info->fix.smem_len) - screen_pos;
|
| 1103 |
|
| 1104 | dst = (void __force *) (info->screen_base + screen_pos);
|
| 1105 | #if 0
|
| 1106 | //dst = info->screen_base;
|
| 1107 | memcpy(dst, buf, count);
|
| 1108 | //#else
|
| 1109 | if (copy_from_user(dst, buf, count)){
|
| 1110 | mutex_unlock(&(par->io_lock));
|
| 1111 | return -EFAULT;
|
| 1112 | }
|
| 1113 | #endif
|
| 1114 |
|
| 1115 | #ifdef CONFIG_FB_LCD_TE_ON
|
| 1116 | again:
|
| 1117 |
|
| 1118 | /*detect TE sync irq times more than 3, the HW be regard as the LCD with TE.*/
|
| 1119 | if (atomic_read(&g_Lcd_Fmark_count) > 3)
|
| 1120 | {
|
| 1121 | g_LcdSema_Flag = true;
|
| 1122 | if(0 != down_timeout(&gLcd_SyncSema, msecs_to_jiffies(100)))
|
| 1123 | {
|
| 1124 | /*timeout 100ms, regard as no TE LCD.*/
|
| 1125 | atomic_set(&g_Lcd_Fmark_count,0);
|
| 1126 | }
|
| 1127 | else
|
| 1128 | {
|
| 1129 | /*wait for the next TE sync, if the wait time too long*/
|
| 1130 | if(jiffies_to_msecs(jiffies - g_Lcd_tick_count) > 2)
|
| 1131 | goto again;
|
| 1132 | }
|
| 1133 | }
|
| 1134 | #endif
|
| 1135 |
|
| 1136 | #ifdef CONFIG_PM_WAKELOCKS
|
| 1137 | wake_lock(&(par->wlock_write)); /* prevant system into sleep for protecting DMA transmission. */
|
| 1138 | #endif
|
| 1139 |
|
| 1140 | #ifdef CONFIG_ARCH_ZX297520V3_FWP
|
| 1141 |
|
| 1142 | for (row = 0; row <info->var.yres; row++)
|
| 1143 | {
|
| 1144 | for (col = 0; col < info->var.xres; col++)
|
| 1145 | {
|
| 1146 | pixel_value = *( (unsigned short *)info->screen_base + (row * info->var.xres + col));//screen_base
|
| 1147 |
|
| 1148 | lcd_WritePixel(info, pixel_value, row , col );
|
| 1149 | }
|
| 1150 | }
|
| 1151 |
|
| 1152 | //zOss_Printf(SUBMDL_TEST, PRINT_LEVEL_NORMAL, "lcd_UpdateRect CONVERT tick = %d\n", zOss_GetTickCount);
|
| 1153 |
|
| 1154 | /* ÆÁС£¬Êý¾ÝÁ¿²»´ó£¬Õû¸öRAM·¢³öÈ¥£¬Ã¿´ÎÒ»¸öpage */
|
| 1155 |
|
| 1156 | for ( cur_page =0; cur_page < LCD_PAGE_NUM; cur_page++ )
|
| 1157 | {
|
| 1158 | ret |= lcd_SetRamAddr(info, info->var.yoffset, cur_page );
|
| 1159 | ret |= leadt15ds26fb_spi_write_datablock(par->spi, (info->fix.smem_start + info->fix.smem_len + cur_page* info->var.xres), info->var.xres);
|
| 1160 | }
|
| 1161 |
|
| 1162 |
|
| 1163 | #else
|
| 1164 | ret |= leadt15ds26fb_set_ram_address(info, 0, 0, info->var.xres + info->var.xoffset - 1, info->var.yres + info->var.yoffset - 1); /* specifies new start-position */
|
| 1165 | ret |= leadt15ds26fb_spi_write_cmd(par->spi, 0x2C); /* send ram-write command and display data */
|
| 1166 |
|
| 1167 | block_nr = info->fix.smem_len / 65535 + 1;
|
| 1168 | #ifdef CONFIG_ARCH_ZX297520V3_MIFI
|
| 1169 | #else
|
| 1170 | par->spi->bits_per_word = 32;
|
| 1171 | spi_setup(par->spi);
|
| 1172 | #endif
|
| 1173 | for(nr = 0; nr < block_nr; nr++)
|
| 1174 | {
|
| 1175 | ret |= leadt15ds26fb_spi_write_datablock(par->spi, info->fix.smem_start + (info->fix.smem_len / block_nr * nr),(info->fix.smem_len) / block_nr);
|
| 1176 | }
|
| 1177 | #ifdef CONFIG_ARCH_ZX297520V3_MIFI
|
| 1178 | #else
|
| 1179 | par->spi->bits_per_word = 8;
|
| 1180 | spi_setup(par->spi);
|
| 1181 | #endif
|
| 1182 | #endif
|
| 1183 |
|
| 1184 | #ifdef CONFIG_PM_WAKELOCKS
|
| 1185 | wake_unlock(&(par->wlock_write));
|
| 1186 | #endif
|
| 1187 |
|
| 1188 | mutex_unlock(&(par->io_lock));
|
| 1189 | //LCD_PRINFO("[LCD][LEAD]leadt15ds26fb_write out\n");
|
| 1190 | return count;
|
| 1191 | }
|
| 1192 |
|
| 1193 | static void leadt15ds26fb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
|
| 1194 | {
|
| 1195 | int ret = 0;
|
| 1196 | struct leadt15ds26fb_par *par = (struct leadt15ds26fb_par *)(info->par);
|
| 1197 | unsigned int block_nr;
|
| 1198 | unsigned int nr;
|
| 1199 |
|
| 1200 | /* if LCD is in sleep-mode, return directly. */
|
| 1201 | if(LCD_SLEEP == par->lcd_sleep_mode || rect == NULL || rect->width == 0 || rect->height == 0){
|
| 1202 | return ;
|
| 1203 | }
|
| 1204 |
|
| 1205 | #ifdef CONFIG_FB_LCD_TE_ON
|
| 1206 | again:
|
| 1207 |
|
| 1208 | /*detect TE sync irq times more than 3, the HW be regard as the LCD with TE.*/
|
| 1209 | if (atomic_read(&g_Lcd_Fmark_count) > 3)
|
| 1210 | {
|
| 1211 | g_LcdSema_Flag = true;
|
| 1212 | if(0 != down_timeout(&gLcd_SyncSema, msecs_to_jiffies(100)))
|
| 1213 | {
|
| 1214 | /*timeout 100ms, regard as no TE LCD.*/
|
| 1215 | atomic_set(&g_Lcd_Fmark_count,0);
|
| 1216 | }
|
| 1217 | else
|
| 1218 | {
|
| 1219 | /*wait for the next TE sync, if the wait time too long*/
|
| 1220 | if(jiffies_to_msecs(jiffies - g_Lcd_tick_count) > 2)
|
| 1221 | goto again;
|
| 1222 | }
|
| 1223 | }
|
| 1224 | #endif
|
| 1225 |
|
| 1226 | #ifdef CONFIG_PM_WAKELOCKS
|
| 1227 | wake_lock(&(par->wlock_write)); /* prevant system into sleep for protecting DMA transmission. */
|
| 1228 | #endif
|
| 1229 |
|
| 1230 | ret |= leadt15ds26fb_set_ram_address(info, rect->dx, rect->dy, /*rect->dx + */info->var.xres - 1, rect->dy + rect->height - 1); /* specifies new start-position */
|
| 1231 | ret |= leadt15ds26fb_spi_write_cmd(par->spi, 0x2C); /* send ram-write command and display data */
|
| 1232 |
|
| 1233 | block_nr = (rect->width * rect->height *2) / 65504 + 1;
|
| 1234 | #ifdef CONFIG_ARCH_ZX297520V3_MIFI
|
| 1235 | #else
|
| 1236 | par->spi->bits_per_word = 32;
|
| 1237 | spi_setup(par->spi);
|
| 1238 | #endif
|
| 1239 | for(nr = 0; nr < block_nr; nr++)
|
| 1240 | {
|
| 1241 | ret |= leadt15ds26fb_spi_write_datablock(par->spi, info->fix.smem_start + (rect->width * rect->height * 2) / block_nr * nr, (rect->width * rect->height * 2) / block_nr);
|
| 1242 | }
|
| 1243 |
|
| 1244 | #ifdef CONFIG_ARCH_ZX297520V3_MIFI
|
| 1245 | #else
|
| 1246 | par->spi->bits_per_word = 8;
|
| 1247 | spi_setup(par->spi);
|
| 1248 | #endif
|
| 1249 |
|
| 1250 | #ifdef CONFIG_PM_WAKELOCKS
|
| 1251 | wake_unlock(&(par->wlock_write));
|
| 1252 | #endif
|
| 1253 |
|
| 1254 | //LCD_PRINFO("[LCD][LEAD]leadt15ds26fb_fillrect out\n");
|
| 1255 | }
|
| 1256 | static int leadt15ds26fb_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg)
|
| 1257 | {
|
| 1258 | unsigned char ioctl_arg;
|
| 1259 | struct fb_fillrect disp_rect = {0};
|
| 1260 | struct leadt15ds26fb_par * par = (struct leadt15ds26fb_par *)(info->par);
|
| 1261 |
|
| 1262 | mutex_lock(&(par->io_lock));
|
| 1263 |
|
| 1264 | #ifdef CONFIG_PM_WAKELOCKS
|
| 1265 | wake_lock(&(par->wlock_ioctl)); /* prevant system into sleep for protecting DMA transmission. */
|
| 1266 | #endif
|
| 1267 |
|
| 1268 | LCD_PRINFO("[LCD][LEAD]leadt15ds26fb_ioctl enter cmd=%d\n",cmd);
|
| 1269 | switch (cmd)
|
| 1270 | {
|
| 1271 | case LEADT15DS26_SET_SLEEPMODE:
|
| 1272 | {
|
| 1273 | if (copy_from_user(&ioctl_arg, (char *)arg, sizeof(unsigned char)))
|
| 1274 | {
|
| 1275 | #ifdef CONFIG_PM_WAKELOCKS
|
| 1276 | wake_unlock(&(par->wlock_ioctl));
|
| 1277 | #endif
|
| 1278 | mutex_unlock(&(par->io_lock));
|
| 1279 | return -EFAULT;
|
| 1280 | }
|
| 1281 | leadt15ds26fb_set_sleep(info, (bool)ioctl_arg);
|
| 1282 | break;
|
| 1283 | }
|
| 1284 | case LEADT15DS26_SET_BACKLIGHT:
|
| 1285 | {
|
| 1286 | if (copy_from_user(&ioctl_arg, (char *)arg, sizeof(unsigned char)))
|
| 1287 | {
|
| 1288 | #ifdef CONFIG_PM_WAKELOCKS
|
| 1289 | wake_unlock(&(par->wlock_ioctl));
|
| 1290 | #endif
|
| 1291 | mutex_unlock(&(par->io_lock));
|
| 1292 | return -EFAULT;
|
| 1293 | }
|
| 1294 | leadt15ds26fb_set_backlight(info, (bool)ioctl_arg);
|
| 1295 | break;
|
| 1296 | }
|
| 1297 | case LEADT15DS26_SET_BRIGHTNESS:
|
| 1298 | {
|
| 1299 | if (copy_from_user(&ioctl_arg, (char *)arg, sizeof(unsigned char)))
|
| 1300 | {
|
| 1301 | #ifdef CONFIG_PM_WAKELOCKS
|
| 1302 | wake_unlock(&(par->wlock_ioctl));
|
| 1303 | #endif
|
| 1304 | mutex_unlock(&(par->io_lock));
|
| 1305 | return -EFAULT;
|
| 1306 | }
|
| 1307 | leadt15ds26fb_set_brightness(info, ioctl_arg);
|
| 1308 | break;
|
| 1309 | }
|
| 1310 | case LEADT15DS26_FILLRECT:
|
| 1311 | {
|
| 1312 | if (copy_from_user(&disp_rect, (struct fb_fillrect *)arg, sizeof(struct fb_fillrect)))
|
| 1313 | {
|
| 1314 | #ifdef CONFIG_PM_WAKELOCKS
|
| 1315 | wake_unlock(&(par->wlock_ioctl));
|
| 1316 | #endif
|
| 1317 | mutex_unlock(&(par->io_lock));
|
| 1318 | return -EFAULT;
|
| 1319 | }
|
| 1320 |
|
| 1321 | if(disp_rect.dx >=320 &&disp_rect.dy >= 320 && disp_rect.color > 0 && disp_rect.rop > 0)
|
| 1322 | {
|
| 1323 | return -EFAULT;
|
| 1324 | }
|
| 1325 |
|
| 1326 | if(disp_rect.width <= 320 && disp_rect.height <=320)
|
| 1327 | {
|
| 1328 | leadt15ds26fb_fillrect(info, &disp_rect);
|
| 1329 | }
|
| 1330 |
|
| 1331 | break;
|
| 1332 | }
|
| 1333 | default:
|
| 1334 | #ifdef CONFIG_PM_WAKELOCKS
|
| 1335 | wake_unlock(&(par->wlock_ioctl));
|
| 1336 | #endif
|
| 1337 | mutex_unlock(&(par->io_lock));
|
| 1338 | return -EINVAL;
|
| 1339 | }
|
| 1340 |
|
| 1341 | #ifdef CONFIG_PM_WAKELOCKS
|
| 1342 | wake_unlock(&(par->wlock_ioctl));
|
| 1343 | #endif
|
| 1344 |
|
| 1345 | mutex_unlock(&(par->io_lock));
|
| 1346 | return 0;
|
| 1347 | }
|
| 1348 |
|
| 1349 | static struct fb_ops leadt15ds26fb_ops = {
|
| 1350 | .owner = THIS_MODULE,
|
| 1351 | .fb_read = fb_sys_read, /* useless, so link to default read function */
|
| 1352 | .fb_write = leadt15ds26fb_write,
|
| 1353 | .fb_ioctl = leadt15ds26fb_ioctl,
|
| 1354 | //.fb_fillrect = leadt15ds26fb_fillrect,
|
| 1355 | //.fb_mmap = leadt15ds26fb_mmap,
|
| 1356 | };
|
| 1357 |
|
| 1358 | static u64 leadt15ds26fb_dmamask = DMA_BIT_MASK(32);
|
| 1359 |
|
| 1360 |
|
| 1361 | int lcd_pmu_notifier_call(struct notifier_block * nb, unsigned long val, void * v)
|
| 1362 | {
|
| 1363 | //struct leadt15ds26fb_par * par = (struct leadt15ds26fb_par *)(g_leadt15ds26fb_par.info->par);
|
| 1364 | struct leadt15ds26fb_par * par = &g_leadt15ds26fb_par;
|
| 1365 | bool backlight_status = par->lcd_backlight;
|
| 1366 |
|
| 1367 | LCD_PRINFO("[LCD][LEAD]in, val=%ld\n",val);
|
| 1368 | mutex_lock(&(par->io_lock));
|
| 1369 | #ifdef CONFIG_PM_WAKELOCKS
|
| 1370 | wake_lock(&(par->wlock_write)); /* prevant system into sleep for protecting DMA transmission. */
|
| 1371 | #endif
|
| 1372 |
|
| 1373 | leadt15ds26fb_set_backlight(par->info,0);//off
|
| 1374 | leadt15ds26fb_init_lcm(par->info);
|
| 1375 | leadt15ds26fb_set_backlight(par->info, backlight_status);//off
|
| 1376 |
|
| 1377 | #ifdef CONFIG_PM_WAKELOCKS
|
| 1378 | wake_unlock(&(par->wlock_write));
|
| 1379 | #endif
|
| 1380 | mutex_unlock(&(par->io_lock));
|
| 1381 | LCD_PRINFO(" [LCD][LEAD]END~~\n");
|
| 1382 | return 0;
|
| 1383 | }
|
| 1384 |
|
| 1385 | int lcd_reboot_event(struct notifier_block *this, unsigned long event, void *ptr)
|
| 1386 | {
|
| 1387 | void *base;
|
| 1388 |
|
| 1389 | leadt15ds26fb_setbacklight_before_reset(0);
|
| 1390 |
|
| 1391 | return NOTIFY_DONE;
|
| 1392 | }
|
| 1393 |
|
| 1394 | static struct notifier_block zx29_lcd_reboot_notifier = {
|
| 1395 | .notifier_call = lcd_reboot_event
|
| 1396 | };
|
| 1397 |
|
| 1398 | #ifdef CONFIG_DEBUG_FS
|
| 1399 | static ssize_t debugfs_lcd_write(struct file *file, const char __user *buf,size_t nbytes, loff_t *ppos)
|
| 1400 | {
|
| 1401 | unsigned long val1, val2;
|
| 1402 | u8 reg, value;
|
| 1403 | int ret;
|
| 1404 | void *kern_buf;
|
| 1405 | struct seq_file *s = file->private_data;
|
| 1406 | struct leadt15ds26fb_par *lcd_par = s->private;
|
| 1407 |
|
| 1408 | kern_buf = kzalloc(nbytes, GFP_KERNEL);
|
| 1409 |
|
| 1410 | if (!kern_buf) {
|
| 1411 | printk(KERN_INFO "[LCD][LEAD]: Failed to allocate buffer\n");
|
| 1412 | return -ENOMEM;
|
| 1413 | }
|
| 1414 |
|
| 1415 | if (copy_from_user(kern_buf, (void __user *)buf, nbytes)) {
|
| 1416 | kfree(kern_buf);
|
| 1417 | return -ENOMEM;
|
| 1418 | }
|
| 1419 | //printk(KERN_INFO "%s input str=%s,nbytes=%d \n", __func__, kern_buf,nbytes);
|
| 1420 |
|
| 1421 | int error = 0;
|
| 1422 |
|
| 1423 | LCD_PRINFO("[LCD][LEAD]leadfb_store enter\n");
|
| 1424 |
|
| 1425 | if (!lcd_par->info){
|
| 1426 | //zx_fb_prn("g_leadt15ds26fb_par.info=NULL\n");
|
| 1427 | kfree(kern_buf);
|
| 1428 | LCD_PRINFO("[LCD][LEAD]g_leadt15ds26fb_par.info=NULL\n");
|
| 1429 | return 0;
|
| 1430 | }
|
| 1431 |
|
| 1432 | if (0 == strncmp(kern_buf, "reinit", 6)){
|
| 1433 | leadt15ds26fb_init_lcm(lcd_par->info);
|
| 1434 | }
|
| 1435 | else if (0 == strncmp(kern_buf, "update", 6)){
|
| 1436 | struct leadt15ds26fb_par *par = (struct leadt15ds26fb_par *)(lcd_par->info->par);
|
| 1437 | extern unsigned char bmp_128_128_specify[];
|
| 1438 | /* specifies new start-position */
|
| 1439 | leadt15ds26fb_set_ram_address(lcd_par->info, 0, 0, (lcd_par->info->var.xres) - 1, (lcd_par->info->var.yres)- 1);
|
| 1440 | /* send ram-write command and display data */
|
| 1441 | leadt15ds26fb_spi_write_cmd(par->spi, 0x2C);
|
| 1442 | memcpy(lcd_par->info->screen_base,bmp_128_128_specify,128*128*2);
|
| 1443 | leadt15ds26fb_spi_write_datablock(par->spi, lcd_par->info->fix.smem_start, lcd_par->info->fix.smem_len);
|
| 1444 | }
|
| 1445 | else if (0 == strncmp(kern_buf, "sleepin", 7)){
|
| 1446 | leadt15ds26fb_set_sleep(lcd_par->info, true);
|
| 1447 | }
|
| 1448 | else if (0 == strncmp(kern_buf, "sleepout", 8)){
|
| 1449 | leadt15ds26fb_set_sleep(lcd_par->info, false);
|
| 1450 | }
|
| 1451 | else if (0 == strncmp(kern_buf, "blgon", 5)){
|
| 1452 | leadt15ds26fb_set_backlight(lcd_par->info, true);
|
| 1453 | }
|
| 1454 | else if (0 == strncmp(kern_buf, "blgoff", 6)){
|
| 1455 | leadt15ds26fb_set_backlight(lcd_par->info, false);
|
| 1456 | }
|
| 1457 | else if (0 == strncmp(kern_buf, "brn", 3)){
|
| 1458 | leadt15ds26fb_set_brightness(lcd_par->info, 10);
|
| 1459 | msleep(1000);
|
| 1460 | leadt15ds26fb_set_brightness(lcd_par->info, 128);
|
| 1461 | msleep(1000);
|
| 1462 | leadt15ds26fb_set_brightness(lcd_par->info, 255);
|
| 1463 | }
|
| 1464 | else if (0 == strncmp(kern_buf, "simspion", 8)){
|
| 1465 | use_actual_spi = false;
|
| 1466 | }
|
| 1467 | else if (0 == strncmp(kern_buf, "simspioff", 9)){
|
| 1468 | use_actual_spi = true;
|
| 1469 | }
|
| 1470 | else if (0 == strncmp(kern_buf, "parinfo", 7)){
|
| 1471 | LCD_PRINFO("g_leadt15ds26fb_par.spi = 0x%08x; g_leadt15ds26fb_par.info = 0x%08x\n", lcd_par->spi, lcd_par->info);
|
| 1472 | }
|
| 1473 | else{
|
| 1474 | LCD_PRINFO("undefined cmd\n");
|
| 1475 | }
|
| 1476 |
|
| 1477 | LCD_PRINFO("leadfb_store() done!\n");
|
| 1478 | kfree(kern_buf);
|
| 1479 | return error ? error : nbytes;
|
| 1480 | }
|
| 1481 |
|
| 1482 | static int debugfs_lcd_show(struct seq_file *s, void *v)
|
| 1483 | {
|
| 1484 | seq_printf(s, "%s lcd_id = 0x%x,\n", __func__, g_leadt15ds26fb_par.lcd_id);
|
| 1485 | seq_printf(s, "%s sleep mode %s,\n", __func__, g_leadt15ds26fb_par.lcd_sleep_mode == LCD_SLEEP ? "sleep":"normal");
|
| 1486 | seq_printf(s, "%s g_sLcd_Backlight %s,\n", __func__, g_leadt15ds26fb_par.lcd_backlight? "on" : "off");
|
| 1487 |
|
| 1488 | return 0;
|
| 1489 | }
|
| 1490 |
|
| 1491 | #define DEBUGFS_FILE_ENTRY(name) \
|
| 1492 | static int debugfs_##name##_open(struct inode *inode, struct file *file) \
|
| 1493 | {\
|
| 1494 | return single_open(file, debugfs_##name##_show, inode->i_private); \
|
| 1495 | }\
|
| 1496 | \
|
| 1497 | static const struct file_operations debugfs_##name##_fops = { \
|
| 1498 | .owner= THIS_MODULE, \
|
| 1499 | .open= debugfs_##name##_open, \
|
| 1500 | .write=debugfs_##name##_write, \
|
| 1501 | .read= seq_read, \
|
| 1502 | .llseek= seq_lseek, \
|
| 1503 | .release= single_release, \
|
| 1504 | }
|
| 1505 |
|
| 1506 | DEBUGFS_FILE_ENTRY(lcd);
|
| 1507 |
|
| 1508 | static struct dentry *g_lcd_root;
|
| 1509 |
|
| 1510 | static void debugfs_lcd_init(struct leadt15ds26fb_par *lcd_par)
|
| 1511 | {
|
| 1512 | struct dentry *root;
|
| 1513 | struct dentry *node;
|
| 1514 | int i;
|
| 1515 |
|
| 1516 | if(!lcd_par)
|
| 1517 | return;
|
| 1518 |
|
| 1519 | //create root
|
| 1520 | root = debugfs_create_dir("lcd_zx29", NULL);
|
| 1521 | if (!root) {
|
| 1522 | dev_err(&(lcd_par->spi->dev), "debugfs_create_dir err=%d\n", IS_ERR(root));
|
| 1523 | goto err;
|
| 1524 | }
|
| 1525 |
|
| 1526 | //print regs;
|
| 1527 | node = debugfs_create_file("lcd_lead", S_IRUGO | S_IWUGO, root, lcd_par, &debugfs_lcd_fops);
|
| 1528 | if (!node){
|
| 1529 | dev_err(&(lcd_par->spi->dev), "debugfs_create_dir err=%d\n", IS_ERR(node));
|
| 1530 | goto err;
|
| 1531 | }
|
| 1532 |
|
| 1533 | g_lcd_root = (void *)root;
|
| 1534 | return;
|
| 1535 | err:
|
| 1536 | dev_err(&(lcd_par->spi->dev), "debugfs_spi_init err\n");
|
| 1537 | }
|
| 1538 |
|
| 1539 | #endif
|
| 1540 |
|
| 1541 | /* É豸̽²âº¯Êý */
|
| 1542 | static int leadt15ds26fb_probe(struct spi_device *spi, const struct spi_device_id *id)
|
| 1543 | {
|
| 1544 | int ret = 0;
|
| 1545 | struct fb_info *fbi;
|
| 1546 | dma_addr_t handle;
|
| 1547 | void *base;
|
| 1548 |
|
| 1549 | LCD_PRINFO("[LCD][LEAD]leadt15ds26fb_probe in.\n");
|
| 1550 |
|
| 1551 | fbi = framebuffer_alloc(0, &spi->dev); //framebuffer_alloc(sizeof(struct leadt15ds26fb_par), &spi->dev);
|
| 1552 | if (!fbi){
|
| 1553 | LCD_PRERR("[LCD][LEAD]Couldn't allocate the framebuffer.\n");
|
| 1554 | return -ENOMEM;
|
| 1555 | }
|
| 1556 |
|
| 1557 | fbi->par = &g_leadt15ds26fb_par;
|
| 1558 | fbi->fbops= &leadt15ds26fb_ops;
|
| 1559 |
|
| 1560 | g_leadt15ds26fb_par.spi = spi;
|
| 1561 |
|
| 1562 | mutex_init(&g_leadt15ds26fb_par.io_lock);
|
| 1563 | wake_lock_init(&g_leadt15ds26fb_par.wlock_write, WAKE_LOCK_SUSPEND, "lead_wake_lock_write");
|
| 1564 | wake_lock_init(&g_leadt15ds26fb_par.wlock_ioctl, WAKE_LOCK_SUSPEND, "lead_wake_lock_ioctl");
|
| 1565 | wake_lock_init(&g_leadt15ds26fb_par.wlock_backlight, WAKE_LOCK_SUSPEND, "lead_wake_lock_backlight");
|
| 1566 |
|
| 1567 | ret = leadt15ds26fb_init_gpio(fbi);
|
| 1568 |
|
| 1569 | g_leadt15ds26fb_par.lcd_id = read_st(0xda);
|
| 1570 | g_leadt15ds26fb_par.driver_version = read_st(0xdb) << 8 + read_st(0xdc);
|
| 1571 |
|
| 1572 | if(LCM_LEAD_ID == g_leadt15ds26fb_par.lcd_id)
|
| 1573 | {
|
| 1574 | #ifdef CONFIG_ARCH_ZX297520V3_PHONE
|
| 1575 | fbi->var.xres = 128;
|
| 1576 | fbi->var.yres = 160;
|
| 1577 | fbi->var.xoffset= 0x00;
|
| 1578 | fbi->var.yoffset= 0x00;
|
| 1579 | #ifdef LCD_ROTATE_180
|
| 1580 | fbi->var.colorspace = 0x14;
|
| 1581 | #else
|
| 1582 | fbi->var.colorspace = 0xC4;
|
| 1583 | #endif
|
| 1584 | fbi->var.bits_per_pixel = 16;
|
| 1585 | #elif (defined CONFIG_FB_LCM_LEAD_128_128_F231E||defined CONFIG_LCD_BLG_SINK)
|
| 1586 | fbi->var.xres = 128;
|
| 1587 | fbi->var.yres = 128;
|
| 1588 | fbi->var.xoffset= 0;
|
| 1589 | fbi->var.yoffset= 32;
|
| 1590 | fbi->var.bits_per_pixel = 16;
|
| 1591 | fbi->var.colorspace = 0xC8;
|
| 1592 | #else
|
| 1593 | fbi->var.xres = 128;
|
| 1594 | fbi->var.yres = 128;
|
| 1595 | fbi->var.xoffset= 0x02;
|
| 1596 | #ifdef LCD_ROTATE_180
|
| 1597 | fbi->var.yoffset= 0x01;
|
| 1598 | fbi->var.colorspace = 0x1C;
|
| 1599 | #else
|
| 1600 | fbi->var.yoffset = 0x03;
|
| 1601 | fbi->var.colorspace = 0xC8;
|
| 1602 | #endif
|
| 1603 | fbi->var.bits_per_pixel = 16;
|
| 1604 | spi->max_speed_hz = 26000000;
|
| 1605 | #endif
|
| 1606 | }
|
| 1607 | else if(LCM_ST7789V_ID == g_leadt15ds26fb_par.lcd_id)
|
| 1608 | {
|
| 1609 | #ifdef CONFIG_ARCH_ZX297520V3_PHONE
|
| 1610 | fbi->var.xres = 240;
|
| 1611 | fbi->var.yres = 320;
|
| 1612 | fbi->var.xoffset= 0;
|
| 1613 | fbi->var.yoffset= 0;
|
| 1614 | fbi->var.bits_per_pixel = 16;
|
| 1615 | fbi->var.colorspace = 0x00;
|
| 1616 | #else
|
| 1617 | fbi->var.xres = 240;
|
| 1618 | fbi->var.yres = 240;
|
| 1619 | fbi->var.xoffset= 0;
|
| 1620 | fbi->var.yoffset= 0;
|
| 1621 | #ifdef CONFIG_FB_LCM_ST7789V_Z2
|
| 1622 | fbi->var.yoffset= 40;
|
| 1623 | #endif
|
| 1624 | fbi->var.bits_per_pixel = 16;
|
| 1625 | fbi->var.colorspace = 0x00;
|
| 1626 | #endif
|
| 1627 | }
|
| 1628 | else if(LCM_ILI9342C_ID == g_leadt15ds26fb_par.lcd_id)
|
| 1629 | {
|
| 1630 | fbi->var.xres = 320;
|
| 1631 | fbi->var.yres = 240;
|
| 1632 | fbi->var.xoffset= 0;
|
| 1633 | fbi->var.yoffset= 0;
|
| 1634 | fbi->var.bits_per_pixel = 16;
|
| 1635 | fbi->var.colorspace = 0;
|
| 1636 | }
|
| 1637 | #ifdef CONFIG_ARCH_ZX297520V3_PHONE
|
| 1638 | else if(LCM_GC930X_ID == g_leadt15ds26fb_par.lcd_id)
|
| 1639 | {
|
| 1640 | fbi->var.xres = 240;
|
| 1641 | fbi->var.yres = 320;
|
| 1642 | fbi->var.xoffset= 0;
|
| 1643 | fbi->var.yoffset= 0;
|
| 1644 | fbi->var.bits_per_pixel = 16;
|
| 1645 | #ifdef LCD_ROTATE_180
|
| 1646 | fbi->var.colorspace = 0x1C;
|
| 1647 | #else
|
| 1648 | fbi->var.colorspace = 0xC8;
|
| 1649 | #endif
|
| 1650 | }
|
| 1651 | #endif
|
| 1652 | else
|
| 1653 | {
|
| 1654 | #ifdef CONFIG_ARCH_ZX297520V3_FWP
|
| 1655 | fbi->var.xres = 128;
|
| 1656 | fbi->var.yres = 64;
|
| 1657 | fbi->var.xoffset= 0;
|
| 1658 | fbi->var.yoffset= 0;
|
| 1659 | fbi->var.bits_per_pixel = 16;
|
| 1660 | #else
|
| 1661 | fbi->var.xres = 128;
|
| 1662 | fbi->var.yres = 160;
|
| 1663 | fbi->var.xoffset= 0;
|
| 1664 | fbi->var.yoffset= 0;
|
| 1665 | fbi->var.bits_per_pixel = 16;
|
| 1666 | #ifdef LCD_ROTATE_180
|
| 1667 | fbi->var.colorspace = 0x1C;
|
| 1668 | #else
|
| 1669 | fbi->var.colorspace = 0xC8;
|
| 1670 | #endif
|
| 1671 | #endif
|
| 1672 | }
|
| 1673 |
|
| 1674 | fbi->var.red.length = 5;
|
| 1675 | fbi->var.green.length = 6;
|
| 1676 | fbi->var.blue.length = 5;
|
| 1677 |
|
| 1678 | fbi->fix.smem_len = fbi->var.xres * fbi->var.yres * fbi->var.bits_per_pixel / 8;
|
| 1679 |
|
| 1680 | LCD_PRINFO("[LCD][LEAD]leadt15ds26fb_probe in.lcd_id(0x%x),driver_version(0x%x)\n",g_leadt15ds26fb_par.lcd_id,g_leadt15ds26fb_par.driver_version);
|
| 1681 |
|
| 1682 | spi->dev.dma_mask = &leadt15ds26fb_dmamask;
|
| 1683 | spi->dev.coherent_dma_mask = leadt15ds26fb_dmamask;
|
| 1684 | #ifdef CONFIG_ARCH_ZX297520V3_FWP
|
| 1685 | base = dma_alloc_coherent(&(spi->dev), fbi->fix.smem_len + fbi->var.xres * LCD_PAGE_NUM, &handle,
|
| 1686 | GFP_KERNEL);
|
| 1687 | if (base == NULL) {
|
| 1688 | printk(KERN_ERR "leadfb: unable to allocate screen "
|
| 1689 | "memory\n");
|
| 1690 | framebuffer_release(fbi);
|
| 1691 | return -ENOMEM;
|
| 1692 | }
|
| 1693 | memset(base, 0x00, fbi->fix.smem_len + fbi->var.xres * LCD_PAGE_NUM);
|
| 1694 |
|
| 1695 | #else
|
| 1696 | base = dma_alloc_coherent(&(spi->dev), fbi->fix.smem_len, &handle,
|
| 1697 | GFP_KERNEL);
|
| 1698 | if (base == NULL) {
|
| 1699 | printk(KERN_ERR "leadfb: unable to allocate screen "
|
| 1700 | "memory\n");
|
| 1701 | framebuffer_release(fbi);
|
| 1702 | return -ENOMEM;
|
| 1703 | }
|
| 1704 | #endif
|
| 1705 |
|
| 1706 | fbi->screen_base = base;
|
| 1707 | fbi->fix.smem_start = handle;
|
| 1708 |
|
| 1709 | g_leadt15ds26fb_par.lcd_sleep_mode = LCD_NORMAL;
|
| 1710 | g_leadt15ds26fb_par.lcd_backlight =0;
|
| 1711 | g_leadt15ds26fb_par.info = fbi;
|
| 1712 | g_leadt15ds26fb_par.info->par = &g_leadt15ds26fb_par;
|
| 1713 |
|
| 1714 | ret = register_framebuffer(fbi);
|
| 1715 | if (ret){
|
| 1716 | LCD_PRERR("[LCD][LEAD]Couldn't register the framebuffer.\n");
|
| 1717 | }
|
| 1718 |
|
| 1719 | #if 0
|
| 1720 | /* The LCM have been initialized in bootloader stage. So no necessary to init it again. */
|
| 1721 | ret |= leadt15ds26fb_init_lcm(fbi);
|
| 1722 | #endif
|
| 1723 | register_reboot_notifier(&zx29_lcd_reboot_notifier);
|
| 1724 |
|
| 1725 | pmu_reinit_notifier.notifier_call = lcd_pmu_notifier_call;
|
| 1726 | zx234290_register_client(&pmu_reinit_notifier);
|
| 1727 |
|
| 1728 | #if 0
|
| 1729 | /* just for test */
|
| 1730 | {
|
| 1731 | extern unsigned char bmp_128_128_caliberate[];
|
| 1732 | int ppos = 0;
|
| 1733 | memcpy(base,bmp_128_128_caliberate,128*128*2);
|
| 1734 | leadt15ds26fb_write(g_leadt15ds26fb_par.info, base, 128*128*2, &ppos);
|
| 1735 | }
|
| 1736 | #endif
|
| 1737 |
|
| 1738 | #ifdef CONFIG_FB_LCD_TE_ON
|
| 1739 | sema_init(&gLcd_SyncSema, 0);
|
| 1740 | ret = request_threaded_irq(((struct leadt15ds26fb_par *)fbi->par)->irq_num, LcdSync_irq_handler, LcdSync_Isr, IRQF_ONESHOT,
|
| 1741 | "lcdsync", &spi->dev);
|
| 1742 |
|
| 1743 | if (ret){
|
| 1744 | LCD_PRERR("[LCD][LEAD]request_threaded_irq failed.\n");
|
| 1745 | }
|
| 1746 | #endif
|
| 1747 |
|
| 1748 | #if defined(CONFIG_DEBUG_FS)
|
| 1749 | debugfs_lcd_init(&g_leadt15ds26fb_par);
|
| 1750 | #endif
|
| 1751 |
|
| 1752 | return 0;
|
| 1753 | }
|
| 1754 |
|
| 1755 | static int leadt15ds26fb_remove(struct spi_device *spi)
|
| 1756 | {
|
| 1757 | struct fb_info *fbi = spi_get_drvdata(spi);
|
| 1758 | //struct leadt15ds26fb_par *par = fbi->par;
|
| 1759 |
|
| 1760 | if(!fbi)
|
| 1761 | return -EINVAL;
|
| 1762 | unregister_framebuffer(fbi);
|
| 1763 | dma_free_coherent(&(spi->dev), fbi->fix.smem_len, (void *)fbi->screen_base, (dma_addr_t)fbi->fix.smem_start);
|
| 1764 | framebuffer_release(fbi);
|
| 1765 | #if defined(CONFIG_DEBUG_FS)
|
| 1766 | if(g_lcd_root){
|
| 1767 | printk(KERN_INFO "lcd_exit:debugfs_remove_recursive \n");
|
| 1768 | debugfs_remove_recursive(g_lcd_root);
|
| 1769 | }
|
| 1770 | #endif
|
| 1771 |
|
| 1772 | return 0;
|
| 1773 | }
|
| 1774 |
|
| 1775 | static const struct spi_device_id leadt15ds26fb_id[] = {
|
| 1776 | {"lead_t15ds26", 0 },
|
| 1777 | { }
|
| 1778 | };
|
| 1779 |
|
| 1780 | MODULE_DEVICE_TABLE(spi, leadt15ds26fb_id);
|
| 1781 |
|
| 1782 | static struct spi_driver leadt15ds26_spi_driver = {
|
| 1783 | .driver = {
|
| 1784 | .name = "lead_t15ds26",
|
| 1785 | .owner = THIS_MODULE,
|
| 1786 | },
|
| 1787 | .probe = leadt15ds26fb_probe,
|
| 1788 | .remove = leadt15ds26fb_remove,
|
| 1789 | .id_table = leadt15ds26fb_id,
|
| 1790 | };
|
| 1791 |
|
| 1792 | static int __init leadt15ds26_spi_init(void)
|
| 1793 | {
|
| 1794 | int ret;
|
| 1795 |
|
| 1796 | ret = spi_register_driver(&leadt15ds26_spi_driver);
|
| 1797 | if (ret != 0){
|
| 1798 | LCD_PRERR("[LCD][LEAD]Failed to register leadt15ds26_spi_driver : %d\n", ret);
|
| 1799 | }
|
| 1800 |
|
| 1801 | LCD_PRINFO("[LCD][LEAD]spi_register_driver - leadt15ds26_spi.\n");
|
| 1802 |
|
| 1803 | return ret;
|
| 1804 | }
|
| 1805 |
|
| 1806 | static void __exit leadt15ds26_spi_exit(void)
|
| 1807 | {
|
| 1808 | spi_unregister_driver(&leadt15ds26_spi_driver);
|
| 1809 | }
|
| 1810 |
|
| 1811 | module_init(leadt15ds26_spi_init);
|
| 1812 | module_exit(leadt15ds26_spi_exit);
|