add wm831x special operation and modify lcd and touch screen for A22
authorluowei <lw@rock-chips.com>
Wed, 6 Apr 2011 02:23:09 +0000 (10:23 +0800)
committerluowei <lw@rock-chips.com>
Wed, 6 Apr 2011 02:23:41 +0000 (10:23 +0800)
arch/arm/mach-rk29/board-rk29-a22.c
arch/arm/mach-rk29/include/mach/board.h
drivers/input/touchscreen/ili2102_ts.c
drivers/mfd/Kconfig
drivers/mfd/Makefile
drivers/mfd/wm831x-spi-a22.c [new file with mode: 0755]
drivers/rtc/rtc-test.c
drivers/video/display/screen/lcd_ili9803_cpt4_3.c

index aa4f45f6509985bc59f1a4a4f0844044fe2e765a..7f695933e789b9e8cc83f9c3fd9f6c68b371e68b 100755 (executable)
@@ -139,9 +139,9 @@ struct rk29_nand_platform_data rk29_nand_data = {
 * author: zyw@rock-chips.com
 *****************************************************************************************/
 #define FB_ID                       0
-#define FB_DISPLAY_ON_PIN           RK29_PIN6_PD0
-#define FB_LCD_STANDBY_PIN          RK29_PIN6_PD1
-#define FB_LCD_CABC_EN_PIN          RK29_PIN6_PD2
+#define FB_DISPLAY_ON_PIN           INVALID_GPIO//RK29_PIN6_PD0
+#define FB_LCD_STANDBY_PIN          INVALID_GPIO//RK29_PIN6_PD1
+#define FB_LCD_CABC_EN_PIN          INVALID_GPIO//RK29_PIN6_PD2
 #define FB_MCU_FMK_PIN              INVALID_GPIO
 
 #define FB_DISPLAY_ON_VALUE         GPIO_HIGH
@@ -151,18 +151,30 @@ struct rk29_nand_platform_data rk29_nand_data = {
 static int rk29_lcd_io_init(void)
 {
        int ret = 0;
-       rk29_mux_api_set(GPIO2C7_SPI1RXD_NAME, GPIO2H_GPIO2C6); 
-       rk29_mux_api_set(GPIO2C5_SPI1CSN0_NAME, GPIO2H_GPIO2C5); 
-       rk29_mux_api_set(GPIO2C4_SPI1CLK_NAME, GPIO2H_GPIO2C4);         
+       //printk("rk29_lcd_io_init\n");
+       //ret = gpio_request(LCD_RXD_PIN, NULL);
+       ret = gpio_request(LCD_TXD_PIN, NULL);
+       ret = gpio_request(LCD_CLK_PIN, NULL);
+       ret = gpio_request(LCD_CS_PIN, NULL);
+       //rk29_mux_api_set(GPIO2C7_SPI1RXD_NAME,GPIO2H_GPIO2C7);
+       rk29_mux_api_set(GPIO2C6_SPI1TXD_NAME,GPIO2H_GPIO2C6);
+       rk29_mux_api_set(GPIO2C5_SPI1CSN0_NAME,GPIO2H_GPIO2C5);
+       rk29_mux_api_set(GPIO2C4_SPI1CLK_NAME,GPIO2H_GPIO2C4);
        return ret;
 }
 
 static int rk29_lcd_io_deinit(void)
 {
        int ret = 0;
-       rk29_mux_api_set(GPIO2C7_SPI1RXD_NAME, GPIO2H_SPI1_TXD); 
-       rk29_mux_api_set(GPIO2C5_SPI1CSN0_NAME, GPIO2H_SPI1_CSN0); 
-       rk29_mux_api_set(GPIO2C4_SPI1CLK_NAME, GPIO2H_SPI1_CLK); 
+       //printk("rk29_lcd_io_deinit\n");
+       gpio_free(LCD_CS_PIN);
+       gpio_free(LCD_CLK_PIN);
+       gpio_free(LCD_TXD_PIN);
+       //gpio_free(LCD_RXD_PIN);
+       //rk29_mux_api_set(GPIO2C7_SPI1RXD_NAME,GPIO2H_SPI1_RXD);
+       rk29_mux_api_set(GPIO2C6_SPI1TXD_NAME,GPIO2H_SPI1_TXD);
+       rk29_mux_api_set(GPIO2C5_SPI1CSN0_NAME,GPIO2H_SPI1_CSN0);
+       rk29_mux_api_set(GPIO2C4_SPI1CLK_NAME,GPIO2H_SPI1_CLK);
        return ret;
 }
 
@@ -687,6 +699,9 @@ static struct regulator_consumer_supply dcdc1_consumers[] = {
 static struct regulator_consumer_supply dcdc2_consumers[] = {
        {
                .supply = "dcdc2",
+       },
+       {
+               .supply = "vcore",
        }
 };
 static struct regulator_consumer_supply dcdc3_consumers[] = {
@@ -2706,14 +2721,14 @@ static struct spi_board_info board_spi_devices[] = {
        },
 #endif
 
-#if defined(CONFIG_MFD_WM831X_SPI)
+#if defined(CONFIG_MFD_WM831X_SPI_A22)
        {
                .modalias       = "wm8310",
                .chip_select    = 1,
-               .max_speed_hz   = 12*1000*1000,
+               .max_speed_hz   = 2*1000*1000,
                .bus_num        = 1,
                .irq            = RK29_PIN4_PD0,
-               .platform_data = &wm831x_platdata,
+               //.platform_data = &wm831x_platdata,
        },
 #endif
 
index 1b773db16b0a83aefbdee28be2f3134ff4b41472..8a111c602baac6265a6f131d376725aee89af655 100755 (executable)
@@ -247,7 +247,7 @@ int board_boot_mode(void);
 #ifdef CONFIG_USB_GADGET
 int board_usb_detect_init(unsigned gpio, unsigned long flags);
 #else
-static int inline board_usb_detect_init(unsigned, unsigned long) { return 0; }
+static int inline board_usb_detect_init(unsigned gpio, unsigned long flags) { return 0; }
 #endif
 
 /* for wakeup Android */
index 3cdedbdbf1d21192f49968d31a7916694c26836c..2ed32620ab48e14a70ca735ed529fbb191bfedce 100755 (executable)
 #include "ili2102_ts.h"
 
 
-#if 1
+#if 0
        #define DBG(msg...)     printk(msg);
 #else
        #define DBG(msg...)
 #endif
 
-#define TOUCH_NUMBER 2
+#define TOUCH_NUMBER 1
 
 static int touch_state[TOUCH_NUMBER] = {TOUCH_UP,TOUCH_UP};
 
@@ -115,7 +115,7 @@ static void ili2102_ts_work_func(struct work_struct *work)
        unsigned int x, y;
        struct i2c_msg msg[2];
        uint8_t start_reg;
-       uint32_t buf[4];
+       uint8_t buf[9];//uint32_t buf[4];
        struct ili2102_ts_data *ts = container_of(work, struct ili2102_ts_data, work);
 
        DBG("ili2102_ts_work_func\n");
@@ -130,8 +130,8 @@ static void ili2102_ts_work_func(struct work_struct *work)
 
        msg[1].addr = ts->client->addr;
        msg[1].flags = I2C_M_RD;
-       msg[1].len = 4 * TOUCH_NUMBER;
-       msg[1].buf = (u8*)&buf[0];
+       msg[1].len = 9; 
+       msg[1].buf = buf;//msg[1].buf = (u8*)&buf[0];
 
        ret = i2c_transfer(ts->client->adapter, msg, 2);
     
@@ -140,46 +140,46 @@ static void ili2102_ts_work_func(struct work_struct *work)
        printk("ili2102_ts_work_func:i2c_transfer fail =%d\n",ret);
        }
 
-       for(i=0; i<TOUCH_NUMBER; i++)
+       if((buf[0] & 0x03) == 0)
        {
-               if(buf[i] == 0xffffffff || buf[i] == 0)
-               {
-                       if (touch_state[i] == TOUCH_DOWN)
-                       {
-                               DBG("ili2102_ts_work_func:buf[%d]=%d\n",i,buf[i]);
-                               input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0); //Finger Size
-                               input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, 0); //Touch Size
-                               input_mt_sync(ts->input_dev);
-                               syn_flag = 1;
-                               touch_state[i] = TOUCH_UP;
-                       }
-
+               if (touch_state[i] == TOUCH_DOWN)
+               {
+                       DBG("ili2102_ts_work_func:buf[%d]=%d\n",i,buf[i]);
+                       input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0); //Finger Size
+                       input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, 0); //Touch Size
+                       input_mt_sync(ts->input_dev);
+                       syn_flag = 1;
+                       touch_state[i] = TOUCH_UP;
                }
-               else
+
+       }
+       else
+       {
+
+               for(i=0; i<TOUCH_NUMBER; i++)
                {
-                       #if 0
-                       x = ((buf[i] & 0xff) << 8) | ((buf[i] & 0xff00) >> 8);
-                       y = ((buf[i] & 0xff0000) >> 8) | ((buf[i] & 0xff000000) >> 24);
-                       #else
-                       x = (buf[i] & 0xff00)  | (buf[i] & 0xff);
-                       y = ((buf[i] & 0xff000000) >> 16) | ((buf[i] & 0xff0000) >> 16);
-                       #endif
-
-                       if (ts->swap_xy)
-                       swap(x, y);
-
-                       if (verify_coord(ts,&x,&y))
-                       goto out;
+                       if((buf[0]>>i)&0x01)
+                       {
+                               x = buf[1+(i<<2)] | (buf[2+(i<<2)] << 8);
+                               y = buf[3+(i<<2)] | (buf[4+(i<<2)] << 8);
                                
-                       DBG("buf[%d]=%x X = %d, Y = %d\n", i, buf[i], x, y);
 
-                       input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, 1); //Finger Size
-                       input_report_abs(ts->input_dev, ABS_MT_POSITION_X, x);
-                       input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, y);
-                       input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, 5); //Touch Size
-                       input_mt_sync(ts->input_dev);
-                       syn_flag = 1;
-                       touch_state[i] = TOUCH_DOWN;
+                               if (ts->swap_xy)
+                               swap(x, y);
+
+                               if (verify_coord(ts,&x,&y))
+                               goto out;
+                                       
+                               printk("buf[%d]=%x X = %d, Y = %d\n", i, buf[i], x, y);
+
+                               input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, 1); //Finger Size
+                               input_report_abs(ts->input_dev, ABS_MT_POSITION_X, x);
+                               input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, y);
+                               input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, 5); //Touch Size
+                               input_mt_sync(ts->input_dev);
+                               syn_flag = 1;
+                               touch_state[i] = TOUCH_DOWN;
+                       }
                }
        }
        
index 8bc5dcc200b20be01755fad12667da6578956a91..0e7a073d4472508ac42aad9dc5d44a9f50b13f4d 100755 (executable)
@@ -219,6 +219,18 @@ config MFD_WM831X_SPI
          when controlled using SPI.  This driver provides common support
          for accessing the device, additional drivers must be enabled in
          order to use the functionality of the device.
+
+config MFD_WM831X_SPI_A22
+       bool "Support Wolfson Microelectronics WM831x/2x PMICs with SPI for A22"
+       #select MFD_CORE
+       #select MFD_WM831X
+       depends on SPI_MASTER && GENERIC_HARDIRQS
+       help
+         Support for the Wolfson Microelecronics WM831x and WM832x PMICs
+         when controlled using SPI.  This driver provides common support
+         for accessing the device, additional drivers must be enabled in
+         order to use the functionality of the device.
+         
 config MFD_WM8350
        tristate
 
index d26a4631ec3c5d57c835fe934e98cce66cd3d0fc..a3768e455e9dc0fe1ee0aebb62c90f657b6e3726 100755 (executable)
@@ -19,6 +19,7 @@ wm831x-objs                   := wm831x-core.o wm831x-irq.o wm831x-otp.o
 obj-$(CONFIG_MFD_WM831X)       += wm831x.o
 obj-$(CONFIG_MFD_WM831X_I2C)   += wm831x-i2c.o
 obj-$(CONFIG_MFD_WM831X_SPI)   += wm831x-spi.o
+obj-$(CONFIG_MFD_WM831X_SPI_A22)       += wm831x-spi-a22.o
 wm8350-objs                    := wm8350-core.o wm8350-regmap.o wm8350-gpio.o
 obj-$(CONFIG_MFD_WM8350)       += wm8350.o
 obj-$(CONFIG_MFD_WM8350_I2C)   += wm8350-i2c.o
diff --git a/drivers/mfd/wm831x-spi-a22.c b/drivers/mfd/wm831x-spi-a22.c
new file mode 100755 (executable)
index 0000000..9e7d9cc
--- /dev/null
@@ -0,0 +1,845 @@
+/*
+ * wm831x-spi.c  --  SPI access for Wolfson WM831x PMICs
+ *
+ * Copyright 2009,2010 Wolfson Microelectronics PLC.
+ *
+ * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
+ *
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/spi/spi.h>
+#include <linux/gpio.h>
+#include <linux/input.h>
+#include <linux/platform_device.h>
+
+#include <linux/mfd/wm831x/core.h>
+#include <linux/mfd/wm831x/pdata.h>
+#include <linux/mfd/wm831x/irq.h>
+#include <linux/mfd/wm831x/auxadc.h>
+#include <linux/mfd/wm831x/otp.h>
+#include <linux/mfd/wm831x/regulator.h>
+#include <linux/mfd/wm831x/pmu.h>
+
+
+
+/* DC-DC*/
+#define WM831X_BUCKV_MAX_SELECTOR 0x68
+#define WM831X_BUCKP_MAX_SELECTOR 0x66
+
+#define WM831X_DCDC_MODE_FAST    0
+#define WM831X_DCDC_MODE_NORMAL  1
+#define WM831X_DCDC_MODE_IDLE    2
+#define WM831X_DCDC_MODE_STANDBY 3
+
+//#define WM831X_DCDC_MAX_NAME 6
+
+/* Register offsets in control block */
+#define WM831X_DCDC_CONTROL_1     0
+#define WM831X_DCDC_CONTROL_2     1
+#define WM831X_DCDC_ON_CONFIG     2
+#define WM831X_DCDC_SLEEP_CONTROL 3
+#define WM831X_DCDC_DVS_CONTROL   4
+
+/* LDO*/
+#define WM831X_LDO_CONTROL       0
+#define WM831X_LDO_ON_CONTROL    1
+#define WM831X_LDO_SLEEP_CONTROL 2
+
+#define WM831X_ALIVE_LDO_ON_CONTROL    0
+#define WM831X_ALIVE_LDO_SLEEP_CONTROL 1
+
+static int wm831x_spi_read_device(struct wm831x *wm831x, unsigned short reg,
+                                 int bytes, void *dest)
+{
+       u16 tx_val;
+       u16 *d = dest;
+       int r, ret;
+
+       /* Go register at a time */
+       for (r = reg; r < reg + (bytes / 2); r++) {
+               tx_val = cpu_to_be16(r | 0x8000);
+
+               ret = spi_write_then_read(wm831x->control_data,
+                                         (u8 *)&tx_val, 2, (u8 *)d, 2);
+               if (ret != 0)
+                       return ret;
+
+               //*d = be16_to_cpu(*d);
+
+               d++;
+       }
+
+       return 0;
+}
+
+static int wm831x_spi_write_device(struct wm831x *wm831x, unsigned short reg,
+                                  int bytes, void *src)
+{
+       struct spi_device *spi = wm831x->control_data;
+       u16 *s = src;
+       u16 data[2];
+       int ret, r;
+
+       /* Go register at a time */
+       for (r = reg; r < reg + (bytes / 2); r++) {
+               data[0] = cpu_to_be16(r);
+               data[1] = *s++;
+               //printk("%s:reg=0x%x,data=0x%x\n",__FUNCTION__,be16_to_cpu(data[0]),be16_to_cpu(data[1]));
+               ret = spi_write(spi, (char *)&data, sizeof(data));
+               if (ret != 0)
+                       return ret;
+       }
+
+       return 0;
+}
+
+
+int wm831x_isinkv_values[WM831X_ISINK_MAX_ISEL + 1] = {
+       2,
+       2,
+       3,
+       3,
+       4,
+       5,
+       6,
+       7,
+       8,
+       10,
+       11,
+       13,
+       16,
+       19,
+       23,
+       27,
+       32,
+       38,
+       45,
+       54,
+       64,
+       76,
+       91,
+       108,
+       128,
+       152,
+       181,
+       215,
+       256,
+       304,
+       362,
+       431,
+       512,
+       609,
+       724,
+       861,
+       1024,
+       1218,
+       1448,
+       1722,
+       2048,
+       2435,
+       2896,
+       3444,
+       4096,
+       4871,
+       5793,
+       6889,
+       8192,
+       9742,
+       11585,
+       13777,
+       16384,
+       19484,
+       23170,
+       27554,
+};
+EXPORT_SYMBOL_GPL(wm831x_isinkv_values);
+
+static int wm831x_reg_locked(struct wm831x *wm831x, unsigned short reg)
+{
+       if (!wm831x->locked)
+               return 0;
+
+       switch (reg) {
+       case WM831X_WATCHDOG:
+       case WM831X_DC4_CONTROL:
+       case WM831X_ON_PIN_CONTROL:
+       case WM831X_BACKUP_CHARGER_CONTROL:
+       case WM831X_CHARGER_CONTROL_1:
+       case WM831X_CHARGER_CONTROL_2:
+               return 1;
+
+       default:
+               return 0;
+       }
+}
+
+/**
+ * wm831x_reg_unlock: Unlock user keyed registers
+ *
+ * The WM831x has a user key preventing writes to particularly
+ * critical registers.  This function locks those registers,
+ * allowing writes to them.
+ */
+void wm831x_reg_lock(struct wm831x *wm831x)
+{
+       int ret;
+
+       ret = wm831x_reg_write(wm831x, WM831X_SECURITY_KEY, 0);
+       if (ret == 0) {
+               dev_vdbg(wm831x->dev, "Registers locked\n");
+
+               mutex_lock(&wm831x->io_lock);
+               WARN_ON(wm831x->locked);
+               wm831x->locked = 1;
+               mutex_unlock(&wm831x->io_lock);
+       } else {
+               dev_err(wm831x->dev, "Failed to lock registers: %d\n", ret);
+       }
+
+}
+EXPORT_SYMBOL_GPL(wm831x_reg_lock);
+
+/**
+ * wm831x_reg_unlock: Unlock user keyed registers
+ *
+ * The WM831x has a user key preventing writes to particularly
+ * critical registers.  This function locks those registers,
+ * preventing spurious writes.
+ */
+int wm831x_reg_unlock(struct wm831x *wm831x)
+{
+       int ret;
+
+       /* 0x9716 is the value required to unlock the registers */
+       ret = wm831x_reg_write(wm831x, WM831X_SECURITY_KEY, 0x9716);
+       if (ret == 0) {
+               dev_vdbg(wm831x->dev, "Registers unlocked\n");
+
+               mutex_lock(&wm831x->io_lock);
+               WARN_ON(!wm831x->locked);
+               wm831x->locked = 0;
+               mutex_unlock(&wm831x->io_lock);
+       }
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(wm831x_reg_unlock);
+
+static int wm831x_read(struct wm831x *wm831x, unsigned short reg,
+                      int bytes, void *dest)
+{
+       int ret, i;
+       u16 *buf = dest;
+
+       BUG_ON(bytes % 2);
+       BUG_ON(bytes <= 0);
+
+       ret = wm831x->read_dev(wm831x, reg, bytes, dest);
+       if (ret < 0)
+               return ret;
+
+       for (i = 0; i < bytes / 2; i++) {
+               buf[i] = be16_to_cpu(buf[i]);
+
+               dev_vdbg(wm831x->dev, "Read %04x from R%d(0x%x)\n",
+                        buf[i], reg + i, reg + i);
+       }
+
+       return 0;
+}
+
+/**
+ * wm831x_reg_read: Read a single WM831x register.
+ *
+ * @wm831x: Device to read from.
+ * @reg: Register to read.
+ */
+int wm831x_reg_read(struct wm831x *wm831x, unsigned short reg)
+{
+       unsigned short val;
+       int ret;
+
+       mutex_lock(&wm831x->io_lock);
+
+       ret = wm831x_read(wm831x, reg, 2, &val);
+
+       mutex_unlock(&wm831x->io_lock);
+
+       if (ret < 0)
+               return ret;
+       else
+               return val;
+}
+EXPORT_SYMBOL_GPL(wm831x_reg_read);
+
+/**
+ * wm831x_bulk_read: Read multiple WM831x registers
+ *
+ * @wm831x: Device to read from
+ * @reg: First register
+ * @count: Number of registers
+ * @buf: Buffer to fill.
+ */
+int wm831x_bulk_read(struct wm831x *wm831x, unsigned short reg,
+                    int count, u16 *buf)
+{
+       int ret;
+
+       mutex_lock(&wm831x->io_lock);
+
+       ret = wm831x_read(wm831x, reg, count * 2, buf);
+
+       mutex_unlock(&wm831x->io_lock);
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(wm831x_bulk_read);
+
+static int wm831x_write(struct wm831x *wm831x, unsigned short reg,
+                       int bytes, void *src)
+{
+       u16 *buf = src;
+       int i;
+
+       BUG_ON(bytes % 2);
+       BUG_ON(bytes <= 0);
+
+       for (i = 0; i < bytes / 2; i++) {
+               if (wm831x_reg_locked(wm831x, reg))
+                       return -EPERM;
+
+               dev_vdbg(wm831x->dev, "Write %04x to R%d(0x%x)\n",
+                        buf[i], reg + i, reg + i);
+
+               buf[i] = cpu_to_be16(buf[i]);
+       }
+
+       return wm831x->write_dev(wm831x, reg, bytes, src);
+}
+
+/**
+ * wm831x_reg_write: Write a single WM831x register.
+ *
+ * @wm831x: Device to write to.
+ * @reg: Register to write to.
+ * @val: Value to write.
+ */
+int wm831x_reg_write(struct wm831x *wm831x, unsigned short reg,
+                    unsigned short val)
+{
+       int ret;
+
+       mutex_lock(&wm831x->io_lock);
+
+       ret = wm831x_write(wm831x, reg, 2, &val);
+
+       mutex_unlock(&wm831x->io_lock);
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(wm831x_reg_write);
+
+
+static int wm831x_init(struct wm831x *wm831x)
+{
+
+/*wm831x_pre_init*/
+       wm831x_reg_write(wm831x, WM831X_POWER_STATE, 0x8804);   //900ma
+       
+/*wm831x_irq_init:irq=252,180 mask irq*/
+       wm831x_reg_write(wm831x, 0x4019, 0xffff);       
+       wm831x_reg_write(wm831x, 0x401a, 0xffff);       
+       wm831x_reg_write(wm831x, 0x401b, 0xffff);       
+       wm831x_reg_write(wm831x, 0x401c, 0xffff);       
+       wm831x_reg_write(wm831x, 0x401d, 0xffff);       
+       wm831x_reg_write(wm831x, 0x4018, 0xffff);//wm831x_reg_write(wm831x, 0x4018, 0x0);       
+       wm831x_reg_write(wm831x, 0x4019, 0xffff);       
+
+/*regulator: DCDC1: 600 <--> 1800 mV */
+       //wm831x_reg_write(wm831x, 0x401c, 0xfffe);
+       //wm831x_reg_write(wm831x, 0x401c, 0xfefe);
+
+/*regulator: DCDC2: 600 <--> 1800 mV*/ 
+       //wm831x_reg_write(wm831x, 0x401c, 0xfefc);
+       //wm831x_reg_write(wm831x, 0x401c, 0xfcfc);
+
+/* regulator: DCDC3: 850 <--> 3400 mV */
+       //wm831x_reg_write(wm831x, 0x401c, 0xfcf8);
+
+/*regulator: DCDC4: 0 <--> 30000 mV */
+       //wm831x_reg_write(wm831x, 0x401c, 0xfcf0);
+
+/*wm831x_isink_enable*/
+       wm831x_reg_write(wm831x, 0x404e, 0x8500);
+       wm831x_reg_write(wm831x, 0x404e, 0xc500);
+
+/*wm831x_isink_probe:line=203,irq=220*/
+       //wm831x_reg_write(wm831x, 0x401a, 0xffbf);
+       //wm831x_reg_write(wm831x, 0x401a, 0xff3f);
+
+
+/*regulator: LDO1: 900 <--> 3300 mV */
+       //wm831x_reg_write(wm831x, 0x401b, 0xfffe);
+
+/*regulator: LDO2: 900 <--> 3300 mV*/ 
+       //wm831x_reg_write(wm831x, 0x401b, 0xfffc);
+
+/*regulator: LDO3: 900 <--> 3300 mV */
+       //wm831x_reg_write(wm831x, 0x401b, 0xfff8);
+
+/*regulator: LDO4: 900 <--> 3300 mV */
+       //wm831x_reg_write(wm831x, 0x401b, 0xfff0);
+
+/* regulator: LDO5: 900 <--> 3300 mV */
+       //wm831x_reg_write(wm831x, 0x401b, 0xffe0);
+
+/*regulator: LDO6: 900 <--> 3300 mV */
+       //wm831x_reg_write(wm831x, 0x401b, 0xffc0);
+
+/*regulator: LDO7: 1000 <--> 3500 mV */
+       //wm831x_reg_write(wm831x, 0x401b, 0xff80);
+
+/*regulator: LDO8: 1000 <--> 3500 mV */
+       //wm831x_reg_write(wm831x, 0x401b, 0xff00);
+
+/*regulator: LDO9: 1000 <--> 3500 mV */
+       //wm831x_reg_write(wm831x, 0x401b, 0xfe00);
+
+/*regulator: LDO10: 1000 <--> 3500 mV */
+       //wm831x_reg_write(wm831x, 0x401b, 0xfc00);
+
+/*regulator: LDO11: 1200 <--> 1550 mV */
+       wm831x_reg_write(wm831x, 0x4008, 0x9716);
+       wm831x_reg_write(wm831x, 0x4006, 0x8463);
+
+/*wm831x_post_init set dcdc3=3000000mV end*/
+       wm831x_reg_write(wm831x, 0x4051, 0xfa49);
+       wm831x_reg_write(wm831x, 0x4062, 0x2156);
+       
+
+/*wm831x_post_init set ldo10=3000000mV end*/
+       wm831x_reg_write(wm831x, 0x4084, 0x201a);
+
+/*wm831x_post_init set dcdc2=1300000mV end8*/
+       wm831x_reg_write(wm831x, 0x405d, 0x4140);
+
+/* wm831x_post_init set dcdc1=1800000mV end*/
+       wm831x_reg_write(wm831x, 0x4058, 0x6168);
+
+/*wm831x_post_init set ldo1=1800000mV end*/
+       wm831x_reg_write(wm831x, 0x4069, 0x6010);
+
+/*wm831x_post_init set ldo4=2500000mV end*/
+       wm831x_reg_write(wm831x, 0x4072, 0x8017);
+
+/*wm831x_post_init set ldo7=3300000mV end*/
+       wm831x_reg_write(wm831x, 0x407b, 0xa01d);
+
+/*wm831x_post_init set dcdc4=-22mV end*/
+       wm831x_reg_write(wm831x, 0x4050, 0xf);
+
+/*wm831x_post_init set ldo2=3000000mV end*/
+       wm831x_reg_write(wm831x, 0x406c, 0x1c);
+       wm831x_reg_write(wm831x, 0x4051, 0x24b);
+
+/*wm831x_post_init set ldo3=1800000mV end*/
+       wm831x_reg_write(wm831x, 0x406f, 0x10);
+       wm831x_reg_write(wm831x, 0x4051, 0x24f);
+
+/*wm831x_post_init set ldo5=3000000mV end*/
+       wm831x_reg_write(wm831x, 0x4075, 0x1c);
+       wm831x_reg_write(wm831x, 0x4051, 0x25f);
+
+/*wm831x_post_init set ldo6=2800000mV end*/
+       wm831x_reg_write(wm831x, 0x4078, 0x1a);
+       wm831x_reg_write(wm831x, 0x4051, 0x27f);
+
+/*wm831x_post_init set ldo8=1200000mV end*/
+       wm831x_reg_write(wm831x, 0x407e, 0x4);
+       wm831x_reg_write(wm831x, 0x4051, 0x2ff);
+
+/*wm831x_post_init set ldo9=3000000mV end*/
+       wm831x_reg_write(wm831x, 0x4081, 0x1a);
+       wm831x_reg_write(wm831x, 0x4051, 0x3ff);
+
+       wm831x_reg_write(wm831x, 0x4008, 0x0);
+
+       wm831x_reg_write(wm831x, 0x4008, 0x9716);
+       wm831x_reg_write(wm831x, 0x4064, 0x104);
+       wm831x_reg_write(wm831x, 0x4008, 0x0);
+       wm831x_reg_write(wm831x, 0x4050, 0x7);
+
+/* backlight brightness=255*/
+       wm831x_reg_write(wm831x, 0x404e, 0xc500);
+       wm831x_reg_write(wm831x, 0x4050, 0xf);
+       wm831x_reg_write(wm831x, 0x404e, 0xc535);
+       wm831x_reg_write(wm831x, 0x404e, 0xc535);
+
+
+/*wm831x-rtc wm831x-rtc: rtc core: registered wm831x as rtc0*/
+       //wm831x_reg_write(wm831x, 0x4019, 0xeef7);
+       //wm831x_reg_write(wm831x, 0x4019, 0xeef3);
+       
+/*wm831x_power_probe:wm831x_power initialized*/
+       wm831x_reg_write(wm831x, 0x4008, 0x9716);
+       wm831x_reg_write(wm831x, 0x404b, 0x8812);
+
+       wm831x_reg_write(wm831x, 0x4008, 0x0);
+       wm831x_reg_write(wm831x, 0x4008, 0x9716);
+       wm831x_reg_write(wm831x, 0x4048, 0x9c21);
+
+       wm831x_reg_write(wm831x, 0x4048, 0x9c21);
+
+       wm831x_reg_write(wm831x, 0x4049, 0x44ff);
+       wm831x_reg_write(wm831x, 0x4001, 0x57);
+       wm831x_reg_write(wm831x, 0x4008, 0x0);  
+       //wm831x_reg_write(wm831x, 0x4019, 0x6ef3);
+       //wm831x_reg_write(wm831x, 0x4019, 0x2ef3);     
+       
+/*device-mapper: uevent: version 1.0.3*/
+       wm831x_reg_write(wm831x, 0x402e, 0x8000);
+       wm831x_reg_write(wm831x, 0x4014, 0x8);
+       wm831x_reg_write(wm831x, 0x402f, 0x400);
+       wm831x_reg_write(wm831x, 0x402e, 0xc000);
+
+/*gpu: power on... done!*/
+       wm831x_reg_write(wm831x, 0x402e, 0x0);
+       wm831x_reg_write(wm831x, 0x4011, 0x2100);
+       wm831x_reg_write(wm831x, 0x402e, 0x8000);
+       wm831x_reg_write(wm831x, 0x402f, 0x200);
+       wm831x_reg_write(wm831x, 0x402e, 0xc000);
+
+
+/*wm831x_isink_is_enabled:line=85*/
+/*wm831x-rtc wm831x-rtc: setting system clock to 1970-01-02 04:18:35 UTC (101915)*/
+       wm831x_reg_write(wm831x, 0x402e, 0x0);
+       wm831x_reg_write(wm831x, 0x4011, 0x100);
+
+       wm831x_reg_write(wm831x, 0x402e, 0x8000);
+       wm831x_reg_write(wm831x, 0x402f, 0x100);
+       wm831x_reg_write(wm831x, 0x402e, 0xc000);
+       wm831x_reg_write(wm831x, 0x4011, 0x100);
+       wm831x_reg_write(wm831x, 0x402e, 0x0);
+
+       printk("%s\n",__FUNCTION__);
+       
+}
+
+
+struct wm831x_on {
+       struct input_dev *dev;
+       struct delayed_work work;
+       struct wm831x *wm831x;
+       struct wake_lock        wm831x_on_wake;
+};
+
+static struct wm831x_on *g_wm831x_on;
+
+void rk29_send_wakeup_key(void)
+{
+     
+       if(!g_wm831x_on)
+       {
+               printk("%s:addr err!\n",__FUNCTION__);
+               return;
+       }
+        input_report_key(g_wm831x_on->dev, KEY_POWER, 1);
+        input_sync(g_wm831x_on->dev);
+        input_report_key(g_wm831x_on->dev, KEY_POWER, 0);
+        input_sync(g_wm831x_on->dev);
+       //printk("%s\n", __FUNCTION__);
+}
+
+
+static void wm831x_irq_worker(struct work_struct *work)
+{
+       struct wm831x *wm831x = container_of(work, struct wm831x, irq_work);    
+       
+       wm831x_reg_write(wm831x, WM831X_INTERRUPT_STATUS_1, 0xffff);//clear all intterupt
+       rk29_send_wakeup_key();
+       //enable_irq(wm831x->irq);      
+       wake_unlock(&wm831x->irq_wake);
+       printk("%s\n",__FUNCTION__);
+}
+
+static irqreturn_t wm831x_irq_thread(int irq, void *data)
+{
+       struct wm831x *wm831x = data;
+
+       //disable_irq_nosync(irq);
+       wake_lock(&wm831x->irq_wake);
+       queue_work(wm831x->irq_wq, &wm831x->irq_work);
+
+       return IRQ_HANDLED;
+}
+
+static struct platform_driver wm831x_on_driver = {
+       .driver         = {
+               .name   = "wm831x-on",
+       },
+};
+
+static struct platform_device wm831x_on_device = {
+       .name           = "wm831x-on",
+       .id             = -1,
+       .dev = {
+               .driver = &wm831x_on_driver.driver,
+       }
+       
+};
+
+static inline void wm831x_on_init(void)
+{
+       if (platform_driver_register(&wm831x_on_driver) == 0)
+       (void) platform_device_register(&wm831x_on_device);
+}
+
+
+static int __devinit wm831x_spi_probe(struct spi_device *spi)
+{
+       struct wm831x *wm831x;
+       enum wm831x_parent type;
+       int ret,gpio,irq;
+       
+       /* Currently SPI support for ID tables is unmerged, we're faking it */
+       if (strcmp(spi->modalias, "wm8310") == 0)
+               type = WM8310;
+       else if (strcmp(spi->modalias, "wm8311") == 0)
+               type = WM8311;
+       else if (strcmp(spi->modalias, "wm8312") == 0)
+               type = WM8312;
+       else if (strcmp(spi->modalias, "wm8320") == 0)
+               type = WM8320;
+       else if (strcmp(spi->modalias, "wm8321") == 0)
+               type = WM8321;
+       else if (strcmp(spi->modalias, "wm8325") == 0)
+               type = WM8325;
+       else {
+               dev_err(&spi->dev, "Unknown device type\n");
+               return -EINVAL;
+       }
+
+       wm831x = kzalloc(sizeof(struct wm831x), GFP_KERNEL);
+       if (wm831x == NULL)
+               return -ENOMEM;
+
+       spi->bits_per_word = 16;
+       spi->mode = SPI_MODE_0;
+
+       gpio = spi->irq;
+       ret = gpio_request(gpio, "wm831x");
+       if (ret) {
+               printk( "failed to request rk gpio irq for wm831x \n");
+               return ret;
+       }
+       gpio_pull_updown(gpio, GPIOPullUp);
+       if (ret) {
+           printk("failed to pull up gpio irq for wm831x \n");
+               return ret;
+       }       
+       irq = gpio_to_irq(gpio);
+
+       dev_set_drvdata(&spi->dev, wm831x);
+       wm831x->dev = &spi->dev;
+       wm831x->control_data = spi;
+       wm831x->read_dev = wm831x_spi_read_device;
+       wm831x->write_dev = wm831x_spi_write_device;
+
+       mutex_init(&wm831x->io_lock);
+       
+       wm831x_init(wm831x);
+       //wm831x_device_init(wm831x, type, irq);
+       
+       dev_set_drvdata(wm831x->dev, wm831x);
+       wm831x_on_init();
+
+       g_wm831x_on = kzalloc(sizeof(struct wm831x_on), GFP_KERNEL);
+       if (!g_wm831x_on) {
+               printk( "Can't allocate data\n");
+               return -ENOMEM;
+       }
+       
+       g_wm831x_on->wm831x = wm831x;
+       g_wm831x_on->dev = input_allocate_device();
+       if (!g_wm831x_on->dev) {
+               //dev_err(&wm831x->dev, "Can't allocate input dev\n");
+               return  -ENOMEM;
+       }
+
+       g_wm831x_on->dev->evbit[0] = BIT_MASK(EV_KEY);
+       g_wm831x_on->dev->keybit[BIT_WORD(KEY_POWER)] = BIT_MASK(KEY_POWER);
+       g_wm831x_on->dev->name = "wm831x_on";
+       g_wm831x_on->dev->phys = "wm831x_on/input0";
+#if 0
+       g_wm831x_on->dev->dev.parent = &wm831x_on_device.dev;
+       dev_err(&wm831x_on_device.dev, "%s\n", __FUNCTION__);
+       ret = input_register_device(g_wm831x_on->dev);
+       if (ret) {
+               printk( "Can't register input device: %d\n");
+               return  -ENOMEM;
+       }
+       
+#endif
+       
+       wm831x->irq_wq = create_singlethread_workqueue("wm831x-irq");
+       if (!wm831x->irq_wq) {
+               dev_err(wm831x->dev, "Failed to allocate IRQ worker\n");
+               return -ESRCH;
+       }
+       
+       INIT_WORK(&wm831x->irq_work, wm831x_irq_worker);
+       wake_lock_init(&wm831x->irq_wake, WAKE_LOCK_SUSPEND, "wm831x_irq_wake");
+
+       ret = request_threaded_irq(irq, wm831x_irq_thread, NULL, 
+                                IRQF_TRIGGER_FALLING,
+                                  "wm831x", wm831x);
+       if (ret != 0) {
+               dev_err(wm831x->dev, "Failed to request IRQ %d: %d\n",
+                       wm831x->irq, ret);
+               return ret;
+       }
+
+       enable_irq_wake(irq); // so wm831x irq can wake up system
+       /* only support on intterupt */
+       wm831x_reg_write(wm831x, WM831X_SYSTEM_INTERRUPTS_MASK, 0xefff);
+       wm831x_reg_write(wm831x, WM831X_INTERRUPT_STATUS_1_MASK, 0xefff);
+
+       return 0;
+       //return wm831x_device_init(wm831x, type, irq);
+}
+
+static int __devexit wm831x_spi_remove(struct spi_device *spi)
+{
+       struct wm831x *wm831x = dev_get_drvdata(&spi->dev);
+
+       //wm831x_device_exit(wm831x);
+
+       return 0;
+}
+
+static int wm831x_spi_suspend(struct spi_device *spi, pm_message_t m)
+{
+       struct wm831x *wm831x = dev_get_drvdata(&spi->dev);
+       return 0;
+       //return wm831x_device_suspend(wm831x);
+}
+
+static struct spi_driver wm8310_spi_driver = {
+       .driver = {
+               .name   = "wm8310",
+               .bus    = &spi_bus_type,
+               .owner  = THIS_MODULE,
+       },
+       .probe          = wm831x_spi_probe,
+       .remove         = __devexit_p(wm831x_spi_remove),
+       .suspend        = wm831x_spi_suspend,
+};
+
+static struct spi_driver wm8311_spi_driver = {
+       .driver = {
+               .name   = "wm8311",
+               .bus    = &spi_bus_type,
+               .owner  = THIS_MODULE,
+       },
+       .probe          = wm831x_spi_probe,
+       .remove         = __devexit_p(wm831x_spi_remove),
+       .suspend        = wm831x_spi_suspend,
+};
+
+static struct spi_driver wm8312_spi_driver = {
+       .driver = {
+               .name   = "wm8312",
+               .bus    = &spi_bus_type,
+               .owner  = THIS_MODULE,
+       },
+       .probe          = wm831x_spi_probe,
+       .remove         = __devexit_p(wm831x_spi_remove),
+       .suspend        = wm831x_spi_suspend,
+};
+
+static struct spi_driver wm8320_spi_driver = {
+       .driver = {
+               .name   = "wm8320",
+               .bus    = &spi_bus_type,
+               .owner  = THIS_MODULE,
+       },
+       .probe          = wm831x_spi_probe,
+       .remove         = __devexit_p(wm831x_spi_remove),
+       .suspend        = wm831x_spi_suspend,
+};
+
+static struct spi_driver wm8321_spi_driver = {
+       .driver = {
+               .name   = "wm8321",
+               .bus    = &spi_bus_type,
+               .owner  = THIS_MODULE,
+       },
+       .probe          = wm831x_spi_probe,
+       .remove         = __devexit_p(wm831x_spi_remove),
+       .suspend        = wm831x_spi_suspend,
+};
+
+static struct spi_driver wm8325_spi_driver = {
+       .driver = {
+               .name   = "wm8325",
+               .bus    = &spi_bus_type,
+               .owner  = THIS_MODULE,
+       },
+       .probe          = wm831x_spi_probe,
+       .remove         = __devexit_p(wm831x_spi_remove),
+       .suspend        = wm831x_spi_suspend,
+};
+
+static int __init wm831x_spi_init(void)
+{
+       int ret;
+
+       ret = spi_register_driver(&wm8310_spi_driver);
+       if (ret != 0)
+               pr_err("Failed to register WM8310 SPI driver: %d\n", ret);
+
+       ret = spi_register_driver(&wm8311_spi_driver);
+       if (ret != 0)
+               pr_err("Failed to register WM8311 SPI driver: %d\n", ret);
+
+       ret = spi_register_driver(&wm8312_spi_driver);
+       if (ret != 0)
+               pr_err("Failed to register WM8312 SPI driver: %d\n", ret);
+
+       ret = spi_register_driver(&wm8320_spi_driver);
+       if (ret != 0)
+               pr_err("Failed to register WM8320 SPI driver: %d\n", ret);
+
+       ret = spi_register_driver(&wm8321_spi_driver);
+       if (ret != 0)
+               pr_err("Failed to register WM8321 SPI driver: %d\n", ret);
+
+       ret = spi_register_driver(&wm8325_spi_driver);
+       if (ret != 0)
+               pr_err("Failed to register WM8325 SPI driver: %d\n", ret);
+
+       return 0;
+}
+subsys_initcall(wm831x_spi_init);
+
+static void __exit wm831x_spi_exit(void)
+{
+       spi_unregister_driver(&wm8325_spi_driver);
+       spi_unregister_driver(&wm8321_spi_driver);
+       spi_unregister_driver(&wm8320_spi_driver);
+       spi_unregister_driver(&wm8312_spi_driver);
+       spi_unregister_driver(&wm8311_spi_driver);
+       spi_unregister_driver(&wm8310_spi_driver);
+}
+module_exit(wm831x_spi_exit);
+
+MODULE_DESCRIPTION("SPI support for WM831x/2x AudioPlus PMICs");
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Mark Brown");
index 51725f7755b08ca8ec7dbc221d4d9e8d03bbde52..1cbd16fb6d27880e730435f8b51092a3d606cf54 100644 (file)
@@ -30,7 +30,9 @@ static int test_rtc_set_alarm(struct device *dev,
 static int test_rtc_read_time(struct device *dev,
        struct rtc_time *tm)
 {
-       rtc_time_to_tm(get_seconds(), tm);
+       unsigned long time = 0xffffff;
+       rtc_time_to_tm(time, tm);
+       //rtc_time_to_tm(get_seconds(), tm);
        return 0;
 }
 
index b974a2614c539f3d84da31dffa7b60cb6faaf997..1a39d29d04349b23140b687c69d85441cd88b8aa 100755 (executable)
@@ -8,19 +8,23 @@
 \r
 /* Base */\r
 #define OUT_TYPE               SCREEN_RGB\r
-#define OUT_FACE               OUT_P888\r
-#define OUT_CLK                        26      //***27\r
+#define OUT_FACE               OUT_P666\r
+#define OUT_CLK                26*1000*1000    //***27\r
+#define LCDC_ACLK       150000000     //29 lcdc axi DMA Ƶ��           //rk29\r
 \r
 /* Timing */\r
-#define H_PW                   16 //8Ç°ÏûÓ°\r
-#define H_BP                   24//6\r
+#define H_PW                   4 //8Ç°ÏûÓ°\r
+#define H_BP                   8//6\r
 #define H_VD                   480//320        //***800 \r
-#define H_FP                   16//60\r
+#define H_FP                   8//60\r
 \r
-#define V_PW                   2//12\r
-#define V_BP                   2// 4\r
+#define V_PW                   4//12\r
+#define V_BP                   8// 4\r
 #define V_VD                   800//480        //***480\r
-#define V_FP                   4//40\r
+#define V_FP                   8//40\r
+\r
+#define LCD_WIDTH       800    //need modify   //rk29\r
+#define LCD_HEIGHT      480\r
 \r
 /* Other */\r
 #define DCLK_POL               1//0 \r
@@ -46,7 +50,7 @@ int standby(u8 enable);
 \r
 \r
 #define DRVDelayUs(i)   udelay(i*4)\r
-\r
+#if 0\r
 void spi_screenreg_cmd(u8 Addr)\r
 {\r
  u32 i;\r
@@ -118,20 +122,24 @@ void spi_screenreg_param(u8 Param)
         TXD_CLR();\r
         DRVDelayUs(10);\r
 }\r
+#endif\r
 \r
 void set_lcd_info(struct rk29fb_screen *screen, struct rk29lcd_info *lcd_info )\r
 {\r
        //printk("lcd_hx8357 set_lcd_info \n"); \r
-    /* screen type & face */\r
-    screen->type = OUT_TYPE;\r
-    screen->face = OUT_FACE;\r
\r
-    /* Screen size */\r
-    screen->x_res = H_VD;\r
-    screen->y_res = V_VD;\r
+       /* screen type & face */\r
+       screen->type = OUT_TYPE;\r
+       screen->face = OUT_FACE;\r
 \r
-    /* Timing */\r
-    screen->pixclock = OUT_CLK;\r
+       /* Screen size */\r
+       screen->x_res = H_VD;\r
+       screen->y_res = V_VD;\r
+       screen->width = LCD_WIDTH;    //rk29\r
+       screen->height = LCD_HEIGHT;  //rk29\r
+\r
+       /* Timing */\r
+       screen->lcdc_aclk = LCDC_ACLK;  //rk29\r
+       screen->pixclock = OUT_CLK;\r
        screen->left_margin = H_BP;             /*>2*/ \r
        screen->right_margin = H_FP;    /*>2*/ \r
        screen->hsync_len = H_PW;               /*>2*/ //***all > 326, 4<PW+BP<15, \r
@@ -146,142 +154,1281 @@ void set_lcd_info(struct rk29fb_screen *screen, struct rk29lcd_info *lcd_info )
        screen->pin_dclk = DCLK_POL;\r
 \r
        /* Swap rule */\r
-    screen->swap_rb = SWAP_RB;\r
-    screen->swap_rg = 0;\r
-    screen->swap_gb = 0;\r
-    screen->swap_delta = 0;\r
-    screen->swap_dumy = 0;\r
-\r
-    /* Operation function*/\r
-    screen->init = init;\r
-    screen->standby = standby;\r
-    if(lcd_info)\r
-        gLcd_info = lcd_info;\r
+       screen->swap_rb = 0;\r
+       screen->swap_rg = 0;\r
+       screen->swap_gb = 0;\r
+       screen->swap_delta = 0;\r
+       screen->swap_dumy = 0;\r
+\r
+       /* Operation function*/\r
+       screen->init = init;\r
+       screen->standby = standby;\r
+       if(lcd_info)\r
+       gLcd_info = lcd_info;\r
+}\r
+\r
+#define PIN_BL_SET          RK29_PIN6_PD2\r
+void set_backlight(int brightness)\r
+{\r
+#if 0\r
+       if(gLcd_info)\r
+        gLcd_info->io_init();\r
+\r
+       printk("lcd_ili9803:set_backlight = %d\r\n", brightness);\r
+       if (brightness < 0)\r
+       {\r
+               brightness = 0;\r
+       }\r
+       if (brightness > 4)\r
+       {\r
+               brightness = 4;\r
+       }\r
+       spi_screenreg_cmd(0x51);\r
+       spi_screenreg_param(brightness<<5);\r
+               \r
+        if(gLcd_info)\r
+        gLcd_info->io_deinit();\r
+\r
+#endif\r
+\r
+       gpio_request(PIN_BL_SET, NULL);\r
+       if(brightness > 0)\r
+        gpio_direction_output(PIN_BL_SET,GPIO_HIGH);\r
+       else\r
+       gpio_direction_output(PIN_BL_SET,GPIO_LOW);     \r
+\r
+}\r
+\r
+void WriteCommand( int  Command)\r
+{\r
+       unsigned char i,count1, count2,count3,count4;\r
+       count1= Command>>8;\r
+       count2= Command;\r
+       count3=0x20;//00100000   //дÃüÁî¸ßλ\r
+       count4=0x00;//00000000   //дÃüÁîµÍλ======¾ßÌåÇë¿´ICµÄDatasheet\r
+       CS_CLR();\r
+       for(i=0;i<8;i++)\r
+       {\r
+               CLK_CLR();\r
+               if (count3 & 0x80) TXD_SET();\r
+               else             TXD_CLR();\r
+               CLK_SET();\r
+               count3<<=1;\r
+       }\r
+\r
+       for(i=0;i<8;i++)\r
+       {\r
+               CLK_CLR();\r
+               if (count1 & 0x80) TXD_SET();\r
+               else             TXD_CLR();\r
+               CLK_SET();\r
+               count1<<=1;\r
+       }\r
+\r
+       for(i=0;i<8;i++)\r
+       {\r
+               CLK_CLR();\r
+               if (count4 & 0x80) TXD_SET();\r
+               else             TXD_CLR();\r
+               CLK_SET();\r
+               count4<<=1;\r
+       }\r
+       \r
+       for(i=0;i<8;i++)\r
+       {\r
+               CLK_CLR();\r
+               if (count2 & 0x80) TXD_SET();\r
+               else             TXD_CLR();\r
+               CLK_SET();\r
+               count2<<=1;\r
+       }\r
+\r
+       CS_SET();\r
+\r
+}\r
+\r
+\r
+\r
+void WriteParameter(char DH)\r
+{\r
+       unsigned char i, count1, count2,count3,count4;\r
+       count1=DH>>8;\r
+       count2=DH;\r
+       count3=0x60;//дÊý¾Ý¸ßλ\r
+       count4=0x40;//дÊý¾ÝµÍλ\r
+\r
+       CS_CLR();\r
+       /*\r
+       TXD_CLR();  CLK_CLR(); CLK_SET();  //WRITE\r
+       TXD_SET(); CLK_CLR(); CLK_SET();  //DATA\r
+       TXD_SET(); CLK_CLR(); CLK_SET(); //HIGH BYTE\r
+       TXD_CLR(); CLK_CLR(); CLK_SET();\r
+       TXD_CLR(); CLK_CLR(); CLK_SET();\r
+       TXD_CLR(); CLK_CLR(); CLK_SET();\r
+       TXD_CLR(); CLK_CLR(); CLK_SET();\r
+       TXD_CLR(); CLK_CLR(); CLK_SET();\r
+       */\r
+       /*\r
+       //ÒòΪÊý¾ÝµÄ¸ßλ»ù±¾ÊDz»Óõģ¬¿ÉÒÔ²»´«¸ßλ£¬Ö±½Ó´«µÍλ\r
+       for(i=0;i<8;i++)\r
+       {\r
+       CLK_CLR();\r
+       if (count3 & 0x80) TXD_SET();\r
+       else             TXD_CLR();\r
+       CLK_SET();\r
+       count3<<=1;\r
+       }\r
+\r
+       for(i=0;i<8;i++)\r
+       {\r
+       CLK_CLR();\r
+       if (count1 & 0x80) TXD_SET();\r
+       else             TXD_CLR();\r
+       CLK_SET();\r
+       count1<<=1;\r
+       }\r
+       */\r
+\r
+\r
+       for(i=0;i<8;i++)\r
+       {\r
+               CLK_CLR();\r
+               if (count4 & 0x80) TXD_SET();\r
+               else             TXD_CLR();\r
+               CLK_SET();\r
+               count4<<=1;\r
+       }\r
+\r
+       for(i=0;i<8;i++)\r
+       {\r
+               CLK_CLR();\r
+               if (count2 & 0x80) TXD_SET();\r
+               else             TXD_CLR();\r
+               CLK_SET();\r
+               count2<<=1;\r
+       }\r
+\r
+       CS_SET();\r
+\r
 }\r
 \r
+\r
+void init_nt35510(void)\r
+{\r
+       WriteCommand(0X1100); \r
+       mdelay(120);\r
+\r
+       WriteCommand(0X1300); \r
+\r
+       WriteCommand(0XF000); \r
+       WriteParameter(0x55);\r
+\r
+       WriteCommand(0XF001); \r
+       WriteParameter(0xAA);\r
+\r
+       WriteCommand(0XF002); \r
+       WriteParameter(0x52);\r
+\r
+       WriteCommand(0XF003); \r
+       WriteParameter(0x08);\r
+\r
+       WriteCommand(0XF004); \r
+       WriteParameter(0x01);\r
+\r
+       //Gamma setting Red\r
+       WriteCommand(0XD100);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD101);\r
+       WriteParameter(0x20);\r
+\r
+       WriteCommand(0XD102);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD103);\r
+       WriteParameter(0x2B);\r
+\r
+       WriteCommand(0XD104);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD105);\r
+       WriteParameter(0x3C);\r
+\r
+       WriteCommand(0XD106);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD107);\r
+       WriteParameter(0x56);\r
+\r
+       WriteCommand(0XD108);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD109);\r
+       WriteParameter(0x68);\r
+\r
+       WriteCommand(0XD10a);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD10b);\r
+       WriteParameter(0x87);\r
+\r
+       WriteCommand(0XD10c);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD10d);\r
+       WriteParameter(0x9E);\r
+\r
+       WriteCommand(0XD10e);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD10f);\r
+       WriteParameter(0xC6);\r
+\r
+       WriteCommand(0XD110);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD111);\r
+       WriteParameter(0xE4);\r
+\r
+       WriteCommand(0XD112);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD113);\r
+       WriteParameter(0x12);\r
+\r
+       WriteCommand(0XD114);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD115);\r
+       WriteParameter(0x37);\r
+\r
+       WriteCommand(0XD116);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD117);\r
+       WriteParameter(0x75);\r
+\r
+       WriteCommand(0XD118);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD119);\r
+       WriteParameter(0xA5);\r
+\r
+       WriteCommand(0XD11a);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD11b);\r
+       WriteParameter(0xA6);\r
+\r
+       WriteCommand(0XD11c);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD11d);\r
+       WriteParameter(0xD0);\r
+\r
+       WriteCommand(0XD11e);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD11f);\r
+       WriteParameter(0xF5);\r
+\r
+       WriteCommand(0XD120);\r
+       WriteParameter(0x02);\r
+\r
+       WriteCommand(0XD121);\r
+       WriteParameter(0x0A);\r
+\r
+       WriteCommand(0XD122);\r
+       WriteParameter(0x02);\r
+\r
+       WriteCommand(0XD123);\r
+       WriteParameter(0x26);\r
+\r
+       WriteCommand(0XD124);\r
+       WriteParameter(0x02);\r
+\r
+       WriteCommand(0XD125);\r
+       WriteParameter(0x3B);\r
+\r
+       WriteCommand(0XD126);\r
+       WriteParameter(0x02);\r
+\r
+       WriteCommand(0XD127);\r
+       WriteParameter(0x6B);\r
+\r
+       WriteCommand(0XD128);\r
+       WriteParameter(0x02);\r
+\r
+       WriteCommand(0XD129);\r
+       WriteParameter(0x99);\r
+\r
+       WriteCommand(0XD12a);\r
+       WriteParameter(0x02);\r
+\r
+       WriteCommand(0XD12b);\r
+       WriteParameter(0xDD);\r
+\r
+       WriteCommand(0XD12C);\r
+       WriteParameter(0x03);\r
+\r
+       WriteCommand(0XD12D);\r
+       WriteParameter(0x10);\r
+\r
+       WriteCommand(0XD12E);\r
+       WriteParameter(0x03);\r
+\r
+       WriteCommand(0XD12F);\r
+       WriteParameter(0x26);\r
+\r
+       WriteCommand(0XD130);\r
+       WriteParameter(0x03);\r
+\r
+       WriteCommand(0XD131);\r
+       WriteParameter(0x32);\r
+\r
+       WriteCommand(0XD132);\r
+       WriteParameter(0x03);\r
+\r
+       WriteCommand(0XD133);\r
+       WriteParameter(0x9A);\r
+\r
+       //Gamma setting Green\r
+       WriteCommand(0XD200);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD201);\r
+       WriteParameter(0xa0);\r
+\r
+       WriteCommand(0XD202);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD203);\r
+       WriteParameter(0xa9);\r
+\r
+       WriteCommand(0XD204);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD205);\r
+       WriteParameter(0xb5);\r
+\r
+       WriteCommand(0XD206);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD207);\r
+       WriteParameter(0xbf);\r
+\r
+       WriteCommand(0XD208);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD209);\r
+       WriteParameter(0xc9);\r
+\r
+       WriteCommand(0XD20a);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD20b);\r
+       WriteParameter(0xdc);\r
+\r
+       WriteCommand(0XD20c);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD20d);\r
+       WriteParameter(0xEE);\r
+\r
+       WriteCommand(0XD20e);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD20f);\r
+       WriteParameter(0x0A);\r
+\r
+       WriteCommand(0XD210);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD211);\r
+       WriteParameter(0x21);\r
+\r
+       WriteCommand(0XD212);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD213);\r
+       WriteParameter(0x48);\r
+\r
+       WriteCommand(0XD214);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD215);\r
+       WriteParameter(0x67);\r
+\r
+       WriteCommand(0XD216);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD217);\r
+       WriteParameter(0x97);\r
+\r
+       WriteCommand(0XD218);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD219);\r
+       WriteParameter(0xBE);\r
+\r
+       WriteCommand(0XD21a);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD21b);\r
+       WriteParameter(0xC0);\r
+\r
+       WriteCommand(0XD21c);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD21d);\r
+       WriteParameter(0xE1);\r
+\r
+       WriteCommand(0XD21e);\r
+       WriteParameter(0x02);\r
+\r
+       WriteCommand(0XD21f);\r
+       WriteParameter(0x04);\r
+\r
+       WriteCommand(0XD220);\r
+       WriteParameter(0x02);\r
+\r
+       WriteCommand(0XD221);\r
+       WriteParameter(0x17);\r
+\r
+       WriteCommand(0XD222);\r
+       WriteParameter(0x02);\r
+\r
+       WriteCommand(0XD223);\r
+       WriteParameter(0x36);\r
+\r
+       WriteCommand(0XD224);\r
+       WriteParameter(0x02);\r
+\r
+       WriteCommand(0XD225);\r
+       WriteParameter(0x50);\r
+\r
+       WriteCommand(0XD226);\r
+       WriteParameter(0x02);\r
+\r
+       WriteCommand(0XD227);\r
+       WriteParameter(0x7E);\r
+\r
+       WriteCommand(0XD228);\r
+       WriteParameter(0x02);\r
+\r
+       WriteCommand(0XD229);\r
+       WriteParameter(0xAC);\r
+\r
+       WriteCommand(0XD22a);\r
+       WriteParameter(0x02);\r
+\r
+       WriteCommand(0XD22b);\r
+       WriteParameter(0xF1);\r
+\r
+       WriteCommand(0XD22C);\r
+       WriteParameter(0x03);\r
+\r
+       WriteCommand(0XD22D);\r
+       WriteParameter(0x20);\r
+\r
+       WriteCommand(0XD22E);\r
+       WriteParameter(0x03);\r
+\r
+       WriteCommand(0XD22F);\r
+       WriteParameter(0x38);\r
+\r
+       WriteCommand(0XD230);\r
+       WriteParameter(0x03);\r
+\r
+       WriteCommand(0XD231);\r
+       WriteParameter(0x43);\r
+\r
+       WriteCommand(0XD232);\r
+       WriteParameter(0x03);\r
+\r
+       WriteCommand(0XD233);\r
+       WriteParameter(0x9A);\r
+\r
+\r
+       //Gamma setting Blue\r
+       WriteCommand(0XD300);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD301);\r
+       WriteParameter(0x50);\r
+\r
+       WriteCommand(0XD302);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD303);\r
+       WriteParameter(0x53);\r
+\r
+       WriteCommand(0XD304);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD305);\r
+       WriteParameter(0x73);\r
+\r
+       WriteCommand(0XD306);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD307);\r
+       WriteParameter(0x89);\r
+\r
+       WriteCommand(0XD308);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD309);\r
+       WriteParameter(0x9f);\r
+\r
+       WriteCommand(0XD30a);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD30b);\r
+       WriteParameter(0xc1);\r
+\r
+       WriteCommand(0XD30c);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD30d);\r
+       WriteParameter(0xda);\r
+\r
+       WriteCommand(0XD30e);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD30f);\r
+       WriteParameter(0x02);\r
+\r
+       WriteCommand(0XD310);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD311);\r
+       WriteParameter(0x23);\r
+\r
+       WriteCommand(0XD312);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD313);\r
+       WriteParameter(0x50);\r
+\r
+       WriteCommand(0XD314);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD315);\r
+       WriteParameter(0x6f);\r
+\r
+       WriteCommand(0XD316);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD317);\r
+       WriteParameter(0x9f);\r
+\r
+       WriteCommand(0XD318);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD319);\r
+       WriteParameter(0xc5);\r
+\r
+       WriteCommand(0XD31a);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD31b);\r
+       WriteParameter(0xC6);\r
+\r
+       WriteCommand(0XD31c);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD31d);\r
+       WriteParameter(0xE3);\r
+\r
+       WriteCommand(0XD31e);\r
+       WriteParameter(0x02);\r
+\r
+       WriteCommand(0XD31f);\r
+       WriteParameter(0x08);\r
+\r
+       WriteCommand(0XD320);\r
+       WriteParameter(0x02);\r
+\r
+       WriteCommand(0XD321);\r
+       WriteParameter(0x16);\r
+\r
+       WriteCommand(0XD322);\r
+       WriteParameter(0x02);\r
+\r
+       WriteCommand(0XD323);\r
+       WriteParameter(0x2b);\r
+\r
+       WriteCommand(0XD324);\r
+       WriteParameter(0x02);\r
+\r
+       WriteCommand(0XD325);\r
+       WriteParameter(0x4d);\r
+\r
+       WriteCommand(0XD326);\r
+       WriteParameter(0x02);\r
+\r
+       WriteCommand(0XD327);\r
+       WriteParameter(0x6f);\r
+\r
+       WriteCommand(0XD328);\r
+       WriteParameter(0x02);\r
+\r
+       WriteCommand(0XD329);\r
+       WriteParameter(0x8C);\r
+\r
+       WriteCommand(0XD32a);\r
+       WriteParameter(0x02);\r
+\r
+       WriteCommand(0XD32b);\r
+       WriteParameter(0xd6);\r
+\r
+       WriteCommand(0XD32C);\r
+       WriteParameter(0x03);\r
+\r
+       WriteCommand(0XD32D);\r
+       WriteParameter(0x12);\r
+\r
+       WriteCommand(0XD32E);\r
+       WriteParameter(0x03);\r
+\r
+       WriteCommand(0XD32F);\r
+       WriteParameter(0x28);\r
+\r
+       WriteCommand(0XD330);\r
+       WriteParameter(0x03);\r
+\r
+       WriteCommand(0XD331);\r
+       WriteParameter(0x3e);\r
+\r
+       WriteCommand(0XD332);\r
+       WriteParameter(0x03);\r
+\r
+       WriteCommand(0XD333);\r
+       WriteParameter(0x9A);\r
+\r
+       //Gamma setting Red\r
+       WriteCommand(0XD400);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD401);\r
+       WriteParameter(0x20);\r
+\r
+       WriteCommand(0XD402);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD403);\r
+       WriteParameter(0x2b);\r
+\r
+       WriteCommand(0XD404);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD405);\r
+       WriteParameter(0x3c);\r
+\r
+       WriteCommand(0XD406);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD407);\r
+       WriteParameter(0x56);\r
+\r
+       WriteCommand(0XD408);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD409);\r
+       WriteParameter(0x68);\r
+\r
+       WriteCommand(0XD40a);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD40b);\r
+       WriteParameter(0x87);\r
+\r
+       WriteCommand(0XD40c);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD40d);\r
+       WriteParameter(0x9e);\r
+\r
+       WriteCommand(0XD40e);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD40f);\r
+       WriteParameter(0xc6);\r
+\r
+       WriteCommand(0XD410);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD411);\r
+       WriteParameter(0xe4);\r
+\r
+       WriteCommand(0XD412);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD413);\r
+       WriteParameter(0x12);\r
+\r
+       WriteCommand(0XD414);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD415);\r
+       WriteParameter(0x37);\r
+\r
+       WriteCommand(0XD416);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD417);\r
+       WriteParameter(0x75);\r
+\r
+       WriteCommand(0XD418);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD419);\r
+       WriteParameter(0xa5);\r
+\r
+       WriteCommand(0XD41a);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD41b);\r
+       WriteParameter(0xa6);\r
+\r
+       WriteCommand(0XD41c);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD41d);\r
+       WriteParameter(0xd0);\r
+\r
+       WriteCommand(0XD41e);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD41f);\r
+       WriteParameter(0xf5);\r
+\r
+       WriteCommand(0XD420);\r
+       WriteParameter(0x02);\r
+\r
+       WriteCommand(0XD421);\r
+       WriteParameter(0x0a);\r
+\r
+       WriteCommand(0XD422);\r
+       WriteParameter(0x02);\r
+\r
+       WriteCommand(0XD423);\r
+       WriteParameter(0x26);\r
+\r
+       WriteCommand(0XD424);\r
+       WriteParameter(0x02);\r
+\r
+       WriteCommand(0XD425);\r
+       WriteParameter(0x3b);\r
+\r
+       WriteCommand(0XD426);\r
+       WriteParameter(0x02);\r
+\r
+       WriteCommand(0XD427);\r
+       WriteParameter(0x6b);\r
+\r
+       WriteCommand(0XD428);\r
+       WriteParameter(0x02);\r
+\r
+       WriteCommand(0XD429);\r
+       WriteParameter(0x99);\r
+\r
+       WriteCommand(0XD42a);\r
+       WriteParameter(0x02);\r
+\r
+       WriteCommand(0XD42b);\r
+       WriteParameter(0xdd);\r
+\r
+       WriteCommand(0XD42C);\r
+       WriteParameter(0x03);\r
+\r
+       WriteCommand(0XD42D);\r
+       WriteParameter(0x10);\r
+\r
+       WriteCommand(0XD42E);\r
+       WriteParameter(0x03);\r
+\r
+       WriteCommand(0XD42F);\r
+       WriteParameter(0x26);\r
+\r
+       WriteCommand(0XD430);\r
+       WriteParameter(0x03);\r
+\r
+       WriteCommand(0XD431);\r
+       WriteParameter(0x32);\r
+\r
+       WriteCommand(0XD432);\r
+       WriteParameter(0x03);\r
+\r
+       WriteCommand(0XD433);\r
+       WriteParameter(0x9A);\r
+\r
+       //Gamma setting Green\r
+       WriteCommand(0XD500);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD501);\r
+       WriteParameter(0xa0);\r
+\r
+       WriteCommand(0XD502);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD503);\r
+       WriteParameter(0xa9);\r
+\r
+       WriteCommand(0XD504);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD505);\r
+       WriteParameter(0xb5);\r
+\r
+       WriteCommand(0XD506);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD507);\r
+       WriteParameter(0xbf);\r
+\r
+       WriteCommand(0XD508);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD509);\r
+       WriteParameter(0xc9);\r
+\r
+       WriteCommand(0XD50a);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD50b);\r
+       WriteParameter(0xdc);\r
+\r
+       WriteCommand(0XD50c);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD50d);\r
+       WriteParameter(0xee);\r
+\r
+       WriteCommand(0XD50e);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD50f);\r
+       WriteParameter(0x0a);\r
+\r
+       WriteCommand(0XD510);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD511);\r
+       WriteParameter(0x21);\r
+\r
+       WriteCommand(0XD512);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD513);\r
+       WriteParameter(0x48);\r
+\r
+       WriteCommand(0XD514);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD515);\r
+       WriteParameter(0x67);\r
+\r
+       WriteCommand(0XD516);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD517);\r
+       WriteParameter(0x97);\r
+\r
+       WriteCommand(0XD518);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD519);\r
+       WriteParameter(0xbe);\r
+\r
+       WriteCommand(0XD51a);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD51b);\r
+       WriteParameter(0xc0);\r
+\r
+       WriteCommand(0XD51c);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD51d);\r
+       WriteParameter(0xe1);\r
+\r
+       WriteCommand(0XD51e);\r
+       WriteParameter(0x02);\r
+\r
+       WriteCommand(0XD51f);\r
+       WriteParameter(0x04);\r
+\r
+       WriteCommand(0XD520);\r
+       WriteParameter(0x02);\r
+\r
+       WriteCommand(0XD521);\r
+       WriteParameter(0x17);\r
+\r
+       WriteCommand(0XD522);\r
+       WriteParameter(0x02);\r
+\r
+       WriteCommand(0XD523);\r
+       WriteParameter(0x36);\r
+\r
+       WriteCommand(0XD524);\r
+       WriteParameter(0x02);\r
+\r
+       WriteCommand(0XD525);\r
+       WriteParameter(0x50);\r
+\r
+       WriteCommand(0XD526);\r
+       WriteParameter(0x02);\r
+\r
+       WriteCommand(0XD527);\r
+       WriteParameter(0x7e);\r
+\r
+       WriteCommand(0XD528);\r
+       WriteParameter(0x02);\r
+\r
+       WriteCommand(0XD529);\r
+       WriteParameter(0xac);\r
+\r
+       WriteCommand(0XD52a);\r
+       WriteParameter(0x02);\r
+\r
+       WriteCommand(0XD52b);\r
+       WriteParameter(0xf1);\r
+\r
+       WriteCommand(0XD52C);\r
+       WriteParameter(0x03);\r
+\r
+       WriteCommand(0XD52D);\r
+       WriteParameter(0x20);\r
+\r
+       WriteCommand(0XD52E);\r
+       WriteParameter(0x03);\r
+\r
+       WriteCommand(0XD52F);\r
+       WriteParameter(0x38);\r
+\r
+       WriteCommand(0XD530);\r
+       WriteParameter(0x03);\r
+\r
+       WriteCommand(0XD531);\r
+       WriteParameter(0x43);\r
+\r
+       WriteCommand(0XD532);\r
+       WriteParameter(0x03);\r
+\r
+       WriteCommand(0XD533);\r
+       WriteParameter(0x9A);\r
+\r
+       //Gamma setting Blue\r
+       WriteCommand(0XD600);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD601);\r
+       WriteParameter(0x50);\r
+\r
+       WriteCommand(0XD602);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD603);\r
+       WriteParameter(0x53);\r
+\r
+       WriteCommand(0XD604);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD605);\r
+       WriteParameter(0x73);\r
+\r
+       WriteCommand(0XD606);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD607);\r
+       WriteParameter(0x89);\r
+\r
+       WriteCommand(0XD608);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD609);\r
+       WriteParameter(0x9f);\r
+\r
+       WriteCommand(0XD60a);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD60b);\r
+       WriteParameter(0xc1);\r
+\r
+       WriteCommand(0XD60c);\r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XD60d);\r
+       WriteParameter(0xda);\r
+\r
+       WriteCommand(0XD60e);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD60f);\r
+       WriteParameter(0x02);\r
+\r
+       WriteCommand(0XD610);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD611);\r
+       WriteParameter(0x23);\r
+\r
+       WriteCommand(0XD612);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD613);\r
+       WriteParameter(0x50);\r
+\r
+       WriteCommand(0XD614);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD615);\r
+       WriteParameter(0x6f);\r
+\r
+       WriteCommand(0XD616);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD617);\r
+       WriteParameter(0x9f);\r
+\r
+       WriteCommand(0XD618);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD619);\r
+       WriteParameter(0xc5);\r
+\r
+       WriteCommand(0XD61a);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD61b);\r
+       WriteParameter(0xc6);\r
+\r
+       WriteCommand(0XD61c);\r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XD61d);\r
+       WriteParameter(0xe3);\r
+\r
+       WriteCommand(0XD61e);\r
+       WriteParameter(0x02);\r
+\r
+       WriteCommand(0XD61f);\r
+       WriteParameter(0x08);\r
+\r
+       WriteCommand(0XD620);\r
+       WriteParameter(0x02);\r
+\r
+       WriteCommand(0XD621);\r
+       WriteParameter(0x16);\r
+\r
+       WriteCommand(0XD622);\r
+       WriteParameter(0x02);\r
+\r
+       WriteCommand(0XD623);\r
+       WriteParameter(0x2b);\r
+\r
+       WriteCommand(0XD624);\r
+       WriteParameter(0x02);\r
+\r
+       WriteCommand(0XD625);\r
+       WriteParameter(0x4d);\r
+\r
+       WriteCommand(0XD626);\r
+       WriteParameter(0x02);\r
+\r
+       WriteCommand(0XD627);\r
+       WriteParameter(0x6f);\r
+\r
+       WriteCommand(0XD628);\r
+       WriteParameter(0x02);\r
+\r
+       WriteCommand(0XD629);\r
+       WriteParameter(0x8c);\r
+\r
+       WriteCommand(0XD62a);\r
+       WriteParameter(0x02);\r
+\r
+       WriteCommand(0XD62b);\r
+       WriteParameter(0xd6);\r
+\r
+       WriteCommand(0XD62C);\r
+       WriteParameter(0x03);\r
+\r
+       WriteCommand(0XD62D);\r
+       WriteParameter(0x12);\r
+\r
+       WriteCommand(0XD62E);\r
+       WriteParameter(0x03);\r
+\r
+       WriteCommand(0XD62F);\r
+       WriteParameter(0x28);\r
+\r
+       WriteCommand(0XD630);\r
+       WriteParameter(0x03);\r
+\r
+       WriteCommand(0XD631);\r
+       WriteParameter(0x3e);\r
+\r
+       WriteCommand(0XD632);\r
+       WriteParameter(0x03);\r
+\r
+       WriteCommand(0XD633);\r
+       WriteParameter(0x9A);\r
+\r
+       WriteCommand(0XBA00); \r
+       WriteParameter(0x14);\r
+\r
+       WriteCommand(0XBA01); \r
+       WriteParameter(0x14);\r
+\r
+       WriteCommand(0XBA02); \r
+       WriteParameter(0x14);\r
+\r
+       WriteCommand(0XBF00); \r
+       WriteParameter(0x01);\r
+\r
+       WriteCommand(0XB300); \r
+       WriteParameter(0x07);\r
+\r
+       WriteCommand(0XB301); \r
+       WriteParameter(0x07);\r
+\r
+       WriteCommand(0XB302); \r
+       WriteParameter(0x07);\r
+\r
+       WriteCommand(0XB900); \r
+       WriteParameter(0x25);\r
+\r
+       WriteCommand(0XB901); \r
+       WriteParameter(0x25);\r
+\r
+       WriteCommand(0XB902); \r
+       WriteParameter(0x25);\r
+\r
+\r
+\r
+       WriteCommand(0XBC01); \r
+       WriteParameter(0xA0);\r
+\r
+       WriteCommand(0XBC02); \r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XBD01); \r
+       WriteParameter(0xA0);\r
+\r
+       WriteCommand(0XBD02); \r
+       WriteParameter(0x00);\r
+\r
+\r
+       WriteCommand(0XF000); \r
+       WriteParameter(0x55);\r
+\r
+       WriteCommand(0XF001); \r
+       WriteParameter(0xAA);\r
+\r
+       WriteCommand(0XF002); \r
+       WriteParameter(0x52);\r
+\r
+       WriteCommand(0XF003); \r
+       WriteParameter(0x08);\r
+\r
+       WriteCommand(0XF004); \r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0XB100); \r
+       WriteParameter(0xCC);\r
+\r
+       WriteCommand(0XBC00); \r
+       WriteParameter(0x05);\r
+\r
+       WriteCommand(0XBC01); \r
+       WriteParameter(0x05);\r
+\r
+       WriteCommand(0XBC02); \r
+       WriteParameter(0x05);\r
+\r
+\r
+       WriteCommand(0XBD02); \r
+       WriteParameter(0x07);\r
+       WriteCommand(0XBD03); \r
+       WriteParameter(0x31);\r
+\r
+       WriteCommand(0XBE02); \r
+       WriteParameter(0x07);\r
+       WriteCommand(0XBE03); \r
+       WriteParameter(0x31);\r
+\r
+       WriteCommand(0XBF02); \r
+       WriteParameter(0x07);\r
+       WriteCommand(0XBF03); \r
+       WriteParameter(0x31);\r
+\r
+       WriteCommand(0XFF00); \r
+       WriteParameter(0xAA);\r
+       WriteCommand(0XFF01); \r
+       WriteParameter(0x55);\r
+       WriteCommand(0XFF02); \r
+       WriteParameter(0x25);\r
+       WriteCommand(0XFF03); \r
+       WriteParameter(0x01);\r
+\r
+\r
+       WriteCommand(0X3500); \r
+       WriteParameter(0x00);\r
+\r
+       WriteCommand(0X3a00); \r
+       WriteParameter(0x60);//WriteParameter(0x66);\r
+\r
+       WriteCommand(0X3600); \r
+       WriteParameter(0x00);//R<->B\r
+\r
+       WriteCommand(0X2000); //\r
+\r
+       WriteCommand(0X1100); \r
+       mdelay(120);\r
+\r
+       WriteCommand(0X2900); \r
+\r
+       mdelay(100);\r
+       WriteCommand(0X2C00); \r
+}\r
+\r
+\r
+\r
 int init(void)\r
 { \r
        volatile u32 data;\r
+       int i;\r
+       printk("lcd init...\n");\r
+       /* reset lcd to start init lcd */\r
+       gpio_request(RK29_PIN6_PC6, NULL);\r
+       gpio_direction_output(RK29_PIN6_PC6, 1);\r
+       gpio_direction_output(RK29_PIN6_PC6, 0);\r
+       mdelay(5);\r
+       gpio_set_value(RK29_PIN6_PC6, 1);\r
+       mdelay(50);\r
+       gpio_free(RK29_PIN6_PC6);\r
 \r
        if(gLcd_info)\r
        gLcd_info->io_init();\r
+       init_nt35510();\r
 \r
-       printk("lcd init...\n");\r
-       spi_screenreg_cmd(0xB1);\r
-       spi_screenreg_param(0x00);\r
-       spi_screenreg_cmd(0xB2);\r
-       spi_screenreg_param(0x10);\r
-       spi_screenreg_param(0xC7);\r
-       spi_screenreg_cmd(0xB3);\r
-       spi_screenreg_param(0x00);\r
-       spi_screenreg_cmd(0xB4);\r
-       spi_screenreg_param(0x00);\r
-       spi_screenreg_cmd(0xB9);\r
-       spi_screenreg_param(0x00);\r
-       spi_screenreg_cmd(0xC3);\r
-       spi_screenreg_param(0x07);\r
-       spi_screenreg_cmd(0xB2);\r
-       spi_screenreg_param(0x04);\r
-       spi_screenreg_param(0x0B);\r
-       spi_screenreg_param(0x0B);\r
-       spi_screenreg_param(0x00);\r
-       spi_screenreg_param(0x07);\r
-       spi_screenreg_param(0x04);\r
-       spi_screenreg_cmd(0xC5);\r
-       spi_screenreg_param(0x6E);\r
-       spi_screenreg_cmd(0xC2);\r
-       spi_screenreg_param(0x20);\r
-       spi_screenreg_param(0x00);\r
-       spi_screenreg_param(0x10);\r
-       mdelay(20);//20ms\r
-    \r
-       spi_screenreg_cmd(0xC8);\r
-       spi_screenreg_param(0xA3);\r
-       spi_screenreg_cmd(0xC9);\r
-       spi_screenreg_param(0x32);\r
-       spi_screenreg_param(0x06);\r
-       spi_screenreg_cmd(0xD7);\r
-       spi_screenreg_param(0x03);\r
-       spi_screenreg_param(0x00);\r
-       spi_screenreg_param(0x0F);\r
-       spi_screenreg_param(0x0F);\r
-       spi_screenreg_cmd(0xCF);\r
-       spi_screenreg_param(0x00);\r
-       spi_screenreg_param(0x08);\r
-       spi_screenreg_cmd(0xB6);\r
-       spi_screenreg_param(0x20);\r
-       spi_screenreg_param(0xC2);\r
-       spi_screenreg_param(0xFF);\r
-       spi_screenreg_param(0x04);\r
-       spi_screenreg_cmd(0xEA);\r
-       spi_screenreg_param(0x00);\r
-       spi_screenreg_cmd(0x2A);\r
-       spi_screenreg_param(0x00);\r
-       spi_screenreg_param(0x00);\r
-       spi_screenreg_param(0x01);\r
-       spi_screenreg_param(0xDF);\r
-       spi_screenreg_cmd(0x2B);\r
-       spi_screenreg_param(0x00);\r
-       spi_screenreg_param(0x00);\r
-       spi_screenreg_param(0x03);\r
-       spi_screenreg_param(0xEF);\r
-       spi_screenreg_cmd(0xB0);\r
-       spi_screenreg_param(0x01);\r
-       spi_screenreg_cmd(0x0C);\r
-       spi_screenreg_param(0x50);\r
-       spi_screenreg_cmd(0x36);\r
-       spi_screenreg_param(0x48);\r
-       spi_screenreg_cmd(0x3A);\r
-       spi_screenreg_param(0x66);\r
-       spi_screenreg_cmd(0xE0);\r
-       spi_screenreg_param(0x05);\r
-       spi_screenreg_param(0x07);\r
-       spi_screenreg_param(0x0B);\r
-       spi_screenreg_param(0x14);\r
-       spi_screenreg_param(0x11);\r
-       spi_screenreg_param(0x14);\r
-       spi_screenreg_param(0x0A);\r
-       spi_screenreg_param(0x07);\r
-       spi_screenreg_param(0x04);\r
-       spi_screenreg_param(0x0B);\r
-       spi_screenreg_param(0x02);\r
-       spi_screenreg_param(0x00);\r
-       spi_screenreg_param(0x04);\r
-       spi_screenreg_param(0x33);\r
-       spi_screenreg_param(0x36);\r
-       spi_screenreg_param(0x1F);\r
-       spi_screenreg_cmd(0xE1);\r
-       spi_screenreg_param(0x1F);\r
-       spi_screenreg_param(0x36);\r
-       spi_screenreg_param(0x33);\r
-       spi_screenreg_param(0x04);\r
-       spi_screenreg_param(0x00);\r
-       spi_screenreg_param(0x02);\r
-       spi_screenreg_param(0x0B);\r
-       spi_screenreg_param(0x04);\r
-       spi_screenreg_param(0x07);\r
-       spi_screenreg_param(0x0A);\r
-       spi_screenreg_param(0x14);\r
-       spi_screenreg_param(0x11);\r
-       spi_screenreg_param(0x14);\r
-       spi_screenreg_param(0x0B);\r
-       spi_screenreg_param(0x07);\r
-       spi_screenreg_param(0x05);\r
-       spi_screenreg_cmd(0x11);\r
-       mdelay(70);\r
-       spi_screenreg_cmd(0x29);\r
-       mdelay(10);\r
-       spi_screenreg_cmd(0x2C);\r
        if(gLcd_info)\r
        gLcd_info->io_deinit();\r
 \r
+       set_backlight(255);\r
+\r
     return 0;\r
 }\r
 \r
 int standby(u8 enable) //***enable =1 means suspend, 0 means resume \r
 {\r
        int i;\r
-#if 1  \r
+       set_backlight(0);\r
+#if 0\r
     if(gLcd_info)\r
         gLcd_info->io_init();\r
 \r
@@ -307,26 +1454,4 @@ int standby(u8 enable)    //***enable =1 means suspend, 0 means resume
     return 0;\r
 }\r
 \r
-void set_backlight(int brightness)\r
-{\r
-#if 1\r
-       if(gLcd_info)\r
-        gLcd_info->io_init();\r
-\r
-       printk("lcd_ili9803:set_backlight = %d\r\n", brightness);\r
-       if (brightness < 0)\r
-       {\r
-               brightness = 0;\r
-       }\r
-       if (brightness > 4)\r
-       {\r
-               brightness = 4;\r
-       }\r
-       spi_screenreg_cmd(0x51);\r
-       spi_screenreg_param(brightness<<5);\r
-               \r
-        if(gLcd_info)\r
-        gLcd_info->io_deinit();\r
 \r
-#endif\r
-}\r