| 1 |
/* linux/arch/arm/mach-msm/board-htcraphael-panel.c |
| 2 |
** Based on board-trout-panel.c by: Brian Swetland <swetland@google.com> |
| 3 |
*/ |
| 4 |
|
| 5 |
#include <linux/kernel.h> |
| 6 |
#include <linux/init.h> |
| 7 |
#include <linux/platform_device.h> |
| 8 |
#include <linux/delay.h> |
| 9 |
#include <linux/leds.h> |
| 10 |
#include <linux/clk.h> |
| 11 |
#include <linux/err.h> |
| 12 |
#include <linux/microp-klt.h> |
| 13 |
|
| 14 |
#include <asm/io.h> |
| 15 |
#include <asm/gpio.h> |
| 16 |
#include <asm/mach-types.h> |
| 17 |
|
| 18 |
#include <mach/msm_fb.h> |
| 19 |
#include <mach/msm_iomap.h> |
| 20 |
#include <mach/vreg.h> |
| 21 |
|
| 22 |
#include "board-htcraphael.h" |
| 23 |
#include "proc_comm_wince.h" |
| 24 |
#include "devices.h" |
| 25 |
|
| 26 |
//static struct clk *gp_clk; |
| 27 |
|
| 28 |
#define MDDI_CLIENT_CORE_BASE 0x108000 |
| 29 |
#define LCD_CONTROL_BLOCK_BASE 0x110000 |
| 30 |
#define SPI_BLOCK_BASE 0x120000 |
| 31 |
#define I2C_BLOCK_BASE 0x130000 |
| 32 |
#define PWM_BLOCK_BASE 0x140000 |
| 33 |
#define GPIO_BLOCK_BASE 0x150000 |
| 34 |
#define SYSTEM_BLOCK1_BASE 0x160000 |
| 35 |
#define SYSTEM_BLOCK2_BASE 0x170000 |
| 36 |
|
| 37 |
#define PWM0OFF (PWM_BLOCK_BASE|0x1C) |
| 38 |
|
| 39 |
#define MDDICAP0 (MDDI_CLIENT_CORE_BASE|0x00) |
| 40 |
#define MDDICAP1 (MDDI_CLIENT_CORE_BASE|0x04) |
| 41 |
#define MDDICAP2 (MDDI_CLIENT_CORE_BASE|0x08) |
| 42 |
#define MDDICAP3 (MDDI_CLIENT_CORE_BASE|0x0C) |
| 43 |
#define MDCAPCHG (MDDI_CLIENT_CORE_BASE|0x10) |
| 44 |
#define MDCRCERC (MDDI_CLIENT_CORE_BASE|0x14) |
| 45 |
#define TTBUSSEL (MDDI_CLIENT_CORE_BASE|0x18) |
| 46 |
#define DPSET0 (MDDI_CLIENT_CORE_BASE|0x1C) |
| 47 |
#define DPSET1 (MDDI_CLIENT_CORE_BASE|0x20) |
| 48 |
#define DPSUS (MDDI_CLIENT_CORE_BASE|0x24) |
| 49 |
#define DPRUN (MDDI_CLIENT_CORE_BASE|0x28) |
| 50 |
#define SYSCKENA (MDDI_CLIENT_CORE_BASE|0x2C) |
| 51 |
#define TESTMODE (MDDI_CLIENT_CORE_BASE|0x30) |
| 52 |
#define FIFOMONI (MDDI_CLIENT_CORE_BASE|0x34) |
| 53 |
#define INTMONI (MDDI_CLIENT_CORE_BASE|0x38) |
| 54 |
#define MDIOBIST (MDDI_CLIENT_CORE_BASE|0x3C) |
| 55 |
#define MDIOPSET (MDDI_CLIENT_CORE_BASE|0x40) |
| 56 |
#define BITMAP0 (MDDI_CLIENT_CORE_BASE|0x44) |
| 57 |
#define BITMAP1 (MDDI_CLIENT_CORE_BASE|0x48) |
| 58 |
#define BITMAP2 (MDDI_CLIENT_CORE_BASE|0x4C) |
| 59 |
#define BITMAP3 (MDDI_CLIENT_CORE_BASE|0x50) |
| 60 |
#define BITMAP4 (MDDI_CLIENT_CORE_BASE|0x54) |
| 61 |
|
| 62 |
#define SRST (LCD_CONTROL_BLOCK_BASE|0x00) |
| 63 |
#define PORT_ENB (LCD_CONTROL_BLOCK_BASE|0x04) |
| 64 |
#define START (LCD_CONTROL_BLOCK_BASE|0x08) |
| 65 |
#define PORT (LCD_CONTROL_BLOCK_BASE|0x0C) |
| 66 |
#define CMN (LCD_CONTROL_BLOCK_BASE|0x10) |
| 67 |
#define GAMMA (LCD_CONTROL_BLOCK_BASE|0x14) |
| 68 |
#define INTFLG (LCD_CONTROL_BLOCK_BASE|0x18) |
| 69 |
#define INTMSK (LCD_CONTROL_BLOCK_BASE|0x1C) |
| 70 |
#define MPLFBUF (LCD_CONTROL_BLOCK_BASE|0x20) |
| 71 |
#define HDE_LEFT (LCD_CONTROL_BLOCK_BASE|0x24) |
| 72 |
#define VDE_TOP (LCD_CONTROL_BLOCK_BASE|0x28) |
| 73 |
#define PXL (LCD_CONTROL_BLOCK_BASE|0x30) |
| 74 |
#define HCYCLE (LCD_CONTROL_BLOCK_BASE|0x34) |
| 75 |
#define HSW (LCD_CONTROL_BLOCK_BASE|0x38) |
| 76 |
#define HDE_START (LCD_CONTROL_BLOCK_BASE|0x3C) |
| 77 |
#define HDE_SIZE (LCD_CONTROL_BLOCK_BASE|0x40) |
| 78 |
#define VCYCLE (LCD_CONTROL_BLOCK_BASE|0x44) |
| 79 |
#define VSW (LCD_CONTROL_BLOCK_BASE|0x48) |
| 80 |
#define VDE_START (LCD_CONTROL_BLOCK_BASE|0x4C) |
| 81 |
#define VDE_SIZE (LCD_CONTROL_BLOCK_BASE|0x50) |
| 82 |
#define WAKEUP (LCD_CONTROL_BLOCK_BASE|0x54) |
| 83 |
#define WSYN_DLY (LCD_CONTROL_BLOCK_BASE|0x58) |
| 84 |
#define REGENB (LCD_CONTROL_BLOCK_BASE|0x5C) |
| 85 |
#define VSYNIF (LCD_CONTROL_BLOCK_BASE|0x60) |
| 86 |
#define WRSTB (LCD_CONTROL_BLOCK_BASE|0x64) |
| 87 |
#define RDSTB (LCD_CONTROL_BLOCK_BASE|0x68) |
| 88 |
#define ASY_DATA (LCD_CONTROL_BLOCK_BASE|0x6C) |
| 89 |
#define ASY_DATB (LCD_CONTROL_BLOCK_BASE|0x70) |
| 90 |
#define ASY_DATC (LCD_CONTROL_BLOCK_BASE|0x74) |
| 91 |
#define ASY_DATD (LCD_CONTROL_BLOCK_BASE|0x78) |
| 92 |
#define ASY_DATE (LCD_CONTROL_BLOCK_BASE|0x7C) |
| 93 |
#define ASY_DATF (LCD_CONTROL_BLOCK_BASE|0x80) |
| 94 |
#define ASY_DATG (LCD_CONTROL_BLOCK_BASE|0x84) |
| 95 |
#define ASY_DATH (LCD_CONTROL_BLOCK_BASE|0x88) |
| 96 |
#define ASY_CMDSET (LCD_CONTROL_BLOCK_BASE|0x8C) |
| 97 |
|
| 98 |
#define SSICTL (SPI_BLOCK_BASE|0x00) |
| 99 |
#define SSITIME (SPI_BLOCK_BASE|0x04) |
| 100 |
#define SSITX (SPI_BLOCK_BASE|0x08) |
| 101 |
#define SSIRX (SPI_BLOCK_BASE|0x0C) |
| 102 |
#define SSIINTC (SPI_BLOCK_BASE|0x10) |
| 103 |
#define SSIINTS (SPI_BLOCK_BASE|0x14) |
| 104 |
#define SSIDBG1 (SPI_BLOCK_BASE|0x18) |
| 105 |
#define SSIDBG2 (SPI_BLOCK_BASE|0x1C) |
| 106 |
#define SSIID (SPI_BLOCK_BASE|0x20) |
| 107 |
|
| 108 |
#define WKREQ (SYSTEM_BLOCK1_BASE|0x00) |
| 109 |
#define CLKENB (SYSTEM_BLOCK1_BASE|0x04) |
| 110 |
#define DRAMPWR (SYSTEM_BLOCK1_BASE|0x08) |
| 111 |
#define INTMASK (SYSTEM_BLOCK1_BASE|0x0C) |
| 112 |
#define GPIOSEL (SYSTEM_BLOCK2_BASE|0x00) |
| 113 |
|
| 114 |
#define GPIODATA (GPIO_BLOCK_BASE|0x00) |
| 115 |
#define GPIODIR (GPIO_BLOCK_BASE|0x04) |
| 116 |
#define GPIOIS (GPIO_BLOCK_BASE|0x08) |
| 117 |
#define GPIOIBE (GPIO_BLOCK_BASE|0x0C) |
| 118 |
#define GPIOIEV (GPIO_BLOCK_BASE|0x10) |
| 119 |
#define GPIOIE (GPIO_BLOCK_BASE|0x14) |
| 120 |
#define GPIORIS (GPIO_BLOCK_BASE|0x18) |
| 121 |
#define GPIOMIS (GPIO_BLOCK_BASE|0x1C) |
| 122 |
#define GPIOIC (GPIO_BLOCK_BASE|0x20) |
| 123 |
#define GPIOOMS (GPIO_BLOCK_BASE|0x24) |
| 124 |
#define GPIOPC (GPIO_BLOCK_BASE|0x28) |
| 125 |
#define GPIOID (GPIO_BLOCK_BASE|0x30) |
| 126 |
|
| 127 |
#define SPI_WRITE(reg, val) \ |
| 128 |
{ SSITX, 0x00010000 | (((reg) & 0xff) << 8) | ((val) & 0xff) }, \ |
| 129 |
{ 0, 5 }, |
| 130 |
|
| 131 |
#define SPI_WRITE1(reg) \ |
| 132 |
{ SSITX, (reg) & 0xff }, \ |
| 133 |
{ 0, 5 }, |
| 134 |
|
| 135 |
#define SPI_WRITE16(reg, val) \ |
| 136 |
{ SSICTL, 0x170 }, \ |
| 137 |
{ SSITX, 0x00080000 | 0x10 }, \ |
| 138 |
{ SSITX, 0x00010000 | (reg) & 0xffff) }, \ |
| 139 |
{ SSICTL, 0x172 }, \ |
| 140 |
{ SSICTL, 0x170 }, \ |
| 141 |
{ SSITX, 0x00080000 | 0x12 }, \ |
| 142 |
{ SSITX, 0x00010000 | (val) & 0xffff) }, \ |
| 143 |
{ SSICTL, 0x172 }, |
| 144 |
|
| 145 |
struct mddi_table { |
| 146 |
uint32_t reg; |
| 147 |
uint32_t value; |
| 148 |
}; |
| 149 |
|
| 150 |
static struct mddi_table mddi_lcm_init_table[] = { |
| 151 |
{0x0010801c,0x4bec0066},{1,50}, |
| 152 |
{0x00108020,0x00000113}, |
| 153 |
{0x00108024,0x00000000}, |
| 154 |
{0x00108028,0x00000001},{1,100}, |
| 155 |
{0x0010802c,0x00000001}, |
| 156 |
{0x00160004,0x0000a1ef}, |
| 157 |
{0x00170000,0x00000000},{1,50}, |
| 158 |
{0x00160000,0x00000000}, |
| 159 |
{0x00150000,0x03cf0000}, |
| 160 |
{0x00150004,0x000003cf}, |
| 161 |
{0x00150028,0x00000000},{1,50}, |
| 162 |
{0x00160008,0x00000001}, |
| 163 |
{0x00140008,0x00000060}, |
| 164 |
{0x00140000,0x00001388},{1,60}, |
| 165 |
{0x0014001c,0x00000001}, |
| 166 |
{0x00140028,0x00000060}, |
| 167 |
{0x00140020,0x00001388}, |
| 168 |
{0x0014001c,0x00000001}, |
| 169 |
{0x00140028,0x00000060}, |
| 170 |
{0x00140020,0x00001388}, |
| 171 |
{0x0014003c,0x00000001}, |
| 172 |
{0x00140008,0x000000e0}, |
| 173 |
{0x00140028,0x000000e0}, |
| 174 |
{0x00140068,0x00000003}, |
| 175 |
{0x00108044,0x028001e0}, |
| 176 |
{0x00108048,0x01e000f0}, |
| 177 |
{0x0010804c,0x01e000f0}, |
| 178 |
{0x00108050,0x01e000f0}, |
| 179 |
{0x00108054,0x00dc00b0}, |
| 180 |
{0x00160004,0x0000a1eb}, |
| 181 |
{0x00110004,0x00000001}, |
| 182 |
{0x0011000c,0x00000008}, |
| 183 |
{0x00110030,0x00000001}, |
| 184 |
{0x00110020,0x00000000}, |
| 185 |
{0x00110034,0x000000f9}, |
| 186 |
{0x00110038,0x00000002}, |
| 187 |
{0x0011003c,0x00000007}, |
| 188 |
{0x00110040,0x000000ef}, |
| 189 |
{0x00110044,0x000002ff}, |
| 190 |
{0x00110048,0x00000005}, |
| 191 |
{0x0011004c,0x00000009}, |
| 192 |
{0x00110050,0x0000027f}, |
| 193 |
{0x00110008,0x00000001}, |
| 194 |
{0x00150000,0x00040004}, |
| 195 |
}; |
| 196 |
|
| 197 |
static struct mddi_table mddi_hitachi_panel_init_table[] = { |
| 198 |
#if 0 |
| 199 |
{ DPSET0, 0x09e90046 }, |
| 200 |
{ DPSET1, 0x00000118 }, |
| 201 |
{ DPSUS, 0x00000000 }, |
| 202 |
{ DPRUN, 0x00000001 }, |
| 203 |
{ 1, 14 }, /* msleep 14 */ |
| 204 |
{ SYSCKENA, 0x00000001 }, |
| 205 |
//{ CLKENB, 0x000000EF }, |
| 206 |
{ CLKENB, 0x0000A1EF }, /* # SYS.CLKENB # Enable clocks for each module (without DCLK , i2cCLK) */ |
| 207 |
//{ CLKENB, 0x000025CB }, /* Clock enable register */ |
| 208 |
|
| 209 |
{ GPIODATA, 0x02000200 }, /* # GPI .GPIODATA # GPIO2(RESET_LCD_N) set to 0 , GPIO3(eDRAM_Power) set to 0 */ |
| 210 |
{ GPIODIR, 0x000030D }, /* 24D # GPI .GPIODIR # Select direction of GPIO port (0,2,3,6,9 output) */ |
| 211 |
{ GPIOSEL, 0/*0x00000173*/}, /* # SYS.GPIOSEL # GPIO port multiplexing control */ |
| 212 |
{ GPIOPC, 0x03C300C0 }, /* # GPI .GPIOPC # GPIO2,3 PD cut */ |
| 213 |
{ WKREQ, 0x00000000 }, /* # SYS.WKREQ # Wake-up request event is VSYNC alignment */ |
| 214 |
|
| 215 |
{ GPIOIBE, 0x000003FF }, |
| 216 |
{ GPIOIS, 0x00000000 }, |
| 217 |
{ GPIOIC, 0x000003FF }, |
| 218 |
{ GPIOIE, 0x00000000 }, |
| 219 |
|
| 220 |
{ GPIODATA, 0x00040004 }, /* # GPI .GPIODATA # eDRAM VD supply */ |
| 221 |
{ 1, 1 }, /* msleep 1 */ |
| 222 |
{ GPIODATA, 0x02040004 }, /* # GPI .GPIODATA # eDRAM VD supply */ |
| 223 |
{ DRAMPWR, 0x00000001 }, /* eDRAM power */ |
| 224 |
#endif |
| 225 |
}; |
| 226 |
|
| 227 |
static struct mddi_table mddi_toshiba_init_table[] = { |
| 228 |
#if 0 |
| 229 |
{ DPSET0, 0x09e90046 }, |
| 230 |
{ DPSET1, 0x00000118 }, |
| 231 |
{ DPSUS, 0x00000000 }, |
| 232 |
{ DPRUN, 0x00000001 }, |
| 233 |
{ 1, 14 }, /* msleep 14 */ |
| 234 |
{ SYSCKENA, 0x00000001 }, |
| 235 |
//{ CLKENB, 0x000000EF }, |
| 236 |
{ CLKENB, 0x0000A1EF }, /* # SYS.CLKENB # Enable clocks for each module (without DCLK , i2cCLK) */ |
| 237 |
//{ CLKENB, 0x000025CB }, /* Clock enable register */ |
| 238 |
|
| 239 |
{ GPIODATA, 0x02000200 }, /* # GPI .GPIODATA # GPIO2(RESET_LCD_N) set to 0 , GPIO3(eDRAM_Power) set to 0 */ |
| 240 |
{ GPIODIR, 0x000030D }, /* 24D # GPI .GPIODIR # Select direction of GPIO port (0,2,3,6,9 output) */ |
| 241 |
{ GPIOSEL, 0/*0x00000173*/}, /* # SYS.GPIOSEL # GPIO port multiplexing control */ |
| 242 |
{ GPIOPC, 0x03C300C0 }, /* # GPI .GPIOPC # GPIO2,3 PD cut */ |
| 243 |
{ WKREQ, 0x00000000 }, /* # SYS.WKREQ # Wake-up request event is VSYNC alignment */ |
| 244 |
|
| 245 |
{ GPIOIBE, 0x000003FF }, |
| 246 |
{ GPIOIS, 0x00000000 }, |
| 247 |
{ GPIOIC, 0x000003FF }, |
| 248 |
{ GPIOIE, 0x00000000 }, |
| 249 |
|
| 250 |
{ GPIODATA, 0x00040004 }, /* # GPI .GPIODATA # eDRAM VD supply */ |
| 251 |
{ 1, 1 }, /* msleep 1 */ |
| 252 |
{ GPIODATA, 0x02040004 }, /* # GPI .GPIODATA # eDRAM VD supply */ |
| 253 |
{ DRAMPWR, 0x00000001 }, /* eDRAM power */ |
| 254 |
#endif |
| 255 |
}; |
| 256 |
|
| 257 |
static struct mddi_table mddi_toshiba_panel_init_table[] = { |
| 258 |
{ SRST, 0x00000003 }, /* FIFO/LCDC not reset */ |
| 259 |
{ PORT_ENB, 0x00000001 }, /* Enable sync. Port */ |
| 260 |
{ START, 0x00000000 }, /* To stop operation */ |
| 261 |
//{ START, 0x00000001 }, /* To start operation */ |
| 262 |
{ PORT, 0x00000004 }, /* Polarity of VS/HS/DE. */ |
| 263 |
{ CMN, 0x00000000 }, |
| 264 |
{ GAMMA, 0x00000000 }, /* No Gamma correction */ |
| 265 |
{ INTFLG, 0x00000000 }, /* VSYNC interrupt flag clear/status */ |
| 266 |
{ INTMSK, 0x00000000 }, /* VSYNC interrupt mask is off. */ |
| 267 |
{ MPLFBUF, 0x00000000 }, /* Select frame buffer's base address. */ |
| 268 |
{ HDE_LEFT, 0x00000000 }, /* The value of HDE_LEFT. */ |
| 269 |
{ VDE_TOP, 0x00000000 }, /* The value of VDE_TPO. */ |
| 270 |
{ PXL, 0x00000001 }, /* 1. RGB666 */ |
| 271 |
/* 2. Data is valid from 1st frame of beginning. */ |
| 272 |
{ HDE_START, 0x00000006 }, /* HDE_START= 14 PCLK */ |
| 273 |
{ HDE_SIZE, 0x0000009F }, /* HDE_SIZE=320 PCLK */ |
| 274 |
{ HSW, 0x00000004 }, /* HSW= 10 PCLK */ |
| 275 |
{ VSW, 0x00000001 }, /* VSW=2 HCYCLE */ |
| 276 |
{ VDE_START, 0x00000003 }, /* VDE_START=4 HCYCLE */ |
| 277 |
{ VDE_SIZE, 0x000001DF }, /* VDE_SIZE=480 HCYCLE */ |
| 278 |
{ WAKEUP, 0x000001e2 }, /* Wakeup position in VSYNC mode. */ |
| 279 |
{ WSYN_DLY, 0x00000000 }, /* Wakeup position in VSIN mode. */ |
| 280 |
{ REGENB, 0x00000001 }, /* Set 1 to enable to change the value of registers. */ |
| 281 |
{ CLKENB, 0x000025CB }, /* Clock enable register */ |
| 282 |
|
| 283 |
{ SSICTL, 0x00000170 }, /* SSI control register */ |
| 284 |
{ SSITIME, 0x00000250 }, /* SSI timing control register */ |
| 285 |
{ SSICTL, 0x00000172 }, /* SSI control register */ |
| 286 |
}; |
| 287 |
|
| 288 |
static struct mddi_table mddi_epson_init_table[] = { |
| 289 |
{ SRST, 0x00000003 }, /* FIFO/LCDC not reset */ |
| 290 |
{ PORT_ENB, 0x00000001 }, /* Enable sync. Port */ |
| 291 |
{ START, 0x00000000 }, /* To stop operation */ |
| 292 |
#if 0 |
| 293 |
//{ START, 0x00000001 }, /* To start operation */ |
| 294 |
{ PORT, 0x00000004 }, /* Polarity of VS/HS/DE. */ |
| 295 |
{ CMN, 0x00000000 }, |
| 296 |
{ GAMMA, 0x00000000 }, /* No Gamma correction */ |
| 297 |
{ INTFLG, 0x00000000 }, /* VSYNC interrupt flag clear/status */ |
| 298 |
{ INTMSK, 0x00000000 }, /* VSYNC interrupt mask is off. */ |
| 299 |
{ MPLFBUF, 0x00000000 }, /* Select frame buffer's base address. */ |
| 300 |
{ HDE_LEFT, 0x00000000 }, /* The value of HDE_LEFT. */ |
| 301 |
{ VDE_TOP, 0x00000000 }, /* The value of VDE_TPO. */ |
| 302 |
{ PXL, 0x00000001 }, /* 1. RGB666 */ |
| 303 |
/* 2. Data is valid from 1st frame of beginning. */ |
| 304 |
{ HDE_START, 0x00000006 }, /* HDE_START= 14 PCLK */ |
| 305 |
{ HDE_SIZE, 0x0000009F }, /* HDE_SIZE=320 PCLK */ |
| 306 |
{ HSW, 0x00000004 }, /* HSW= 10 PCLK */ |
| 307 |
{ VSW, 0x00000001 }, /* VSW=2 HCYCLE */ |
| 308 |
{ VDE_START, 0x00000003 }, /* VDE_START=4 HCYCLE */ |
| 309 |
{ VDE_SIZE, 0x000001DF }, /* VDE_SIZE=480 HCYCLE */ |
| 310 |
{ WAKEUP, 0x000001e2 }, /* Wakeup position in VSYNC mode. */ |
| 311 |
{ WSYN_DLY, 0x00000000 }, /* Wakeup position in VSIN mode. */ |
| 312 |
{ REGENB, 0x00000001 }, /* Set 1 to enable to change the value of registers. */ |
| 313 |
{ CLKENB, 0x000025CB }, /* Clock enable register */ |
| 314 |
#endif |
| 315 |
{ SSICTL, 0x00000170 }, /* SSI control register */ |
| 316 |
{ SSITIME, 0x00000250 }, /* SSI timing control register */ |
| 317 |
{ SSICTL, 0x00000172 }, /* SSI control register */ |
| 318 |
}; |
| 319 |
|
| 320 |
static struct mddi_table mddi_epson_deinit_table[] = { |
| 321 |
{ 1, 5 }, /* usleep 5 */ |
| 322 |
}; |
| 323 |
|
| 324 |
static struct mddi_table mddi_sharp_init_table[] = { |
| 325 |
{ VCYCLE, 0x000001eb }, |
| 326 |
{ HCYCLE, 0x000000ae }, |
| 327 |
{ REGENB, 0x00000001 }, /* Set 1 to enable to change the value of registers. */ |
| 328 |
{ GPIODATA, 0x00040000 }, /* GPIO2 low */ |
| 329 |
{ GPIODIR, 0x00000004 }, /* GPIO2 out */ |
| 330 |
{ 1, 1 }, /* msleep 1 */ |
| 331 |
{ GPIODATA, 0x00040004 }, /* GPIO2 high */ |
| 332 |
{ 1, 10 }, /* msleep 10 */ |
| 333 |
SPI_WRITE(0x5f, 0x01) |
| 334 |
SPI_WRITE1(0x11) |
| 335 |
{ 1, 200 }, /* msleep 200 */ |
| 336 |
SPI_WRITE1(0x29) |
| 337 |
SPI_WRITE1(0xde) |
| 338 |
{ START, 0x00000001 }, /* To start operation */ |
| 339 |
}; |
| 340 |
|
| 341 |
static struct mddi_table mddi_sharp_deinit_table[] = { |
| 342 |
{ 1, 200 }, /* msleep 200 */ |
| 343 |
SPI_WRITE(0x10, 0x1) |
| 344 |
{ 1, 100 }, /* msleep 100 */ |
| 345 |
{ GPIODATA, 0x00040004 }, /* GPIO2 high */ |
| 346 |
{ GPIODIR, 0x00000004 }, /* GPIO2 out */ |
| 347 |
{ GPIODATA, 0x00040000 }, /* GPIO2 low */ |
| 348 |
{ 1, 10 }, /* msleep 10 */ |
| 349 |
}; |
| 350 |
|
| 351 |
static struct mddi_table mddi_tpo_init_table[] = { |
| 352 |
{ VCYCLE, 0x000001e5 }, |
| 353 |
{ HCYCLE, 0x000000ac }, |
| 354 |
{ REGENB, 0x00000001 }, /* Set 1 to enable to change the value of registers. */ |
| 355 |
{ 0, 20 }, /* udelay 20 */ |
| 356 |
{ GPIODATA, 0x00000004 }, /* GPIO2 high */ |
| 357 |
{ GPIODIR, 0x00000004 }, /* GPIO2 out */ |
| 358 |
{ 0, 20 }, /* udelay 20 */ |
| 359 |
|
| 360 |
SPI_WRITE(0x08, 0x01) |
| 361 |
{ 0, 500 }, /* udelay 500 */ |
| 362 |
SPI_WRITE(0x08, 0x00) |
| 363 |
SPI_WRITE(0x02, 0x00) |
| 364 |
SPI_WRITE(0x03, 0x04) |
| 365 |
SPI_WRITE(0x04, 0x0e) |
| 366 |
SPI_WRITE(0x09, 0x02) |
| 367 |
SPI_WRITE(0x0b, 0x08) |
| 368 |
SPI_WRITE(0x0c, 0x53) |
| 369 |
SPI_WRITE(0x0d, 0x01) |
| 370 |
SPI_WRITE(0x0e, 0xe0) |
| 371 |
SPI_WRITE(0x0f, 0x01) |
| 372 |
SPI_WRITE(0x10, 0x58) |
| 373 |
SPI_WRITE(0x20, 0x1e) |
| 374 |
SPI_WRITE(0x21, 0x0a) |
| 375 |
SPI_WRITE(0x22, 0x0a) |
| 376 |
SPI_WRITE(0x23, 0x1e) |
| 377 |
SPI_WRITE(0x25, 0x32) |
| 378 |
SPI_WRITE(0x26, 0x00) |
| 379 |
SPI_WRITE(0x27, 0xac) |
| 380 |
SPI_WRITE(0x29, 0x06) |
| 381 |
SPI_WRITE(0x2a, 0xa4) |
| 382 |
SPI_WRITE(0x2b, 0x45) |
| 383 |
SPI_WRITE(0x2c, 0x45) |
| 384 |
SPI_WRITE(0x2d, 0x15) |
| 385 |
SPI_WRITE(0x2e, 0x5a) |
| 386 |
SPI_WRITE(0x2f, 0xff) |
| 387 |
SPI_WRITE(0x30, 0x6b) |
| 388 |
SPI_WRITE(0x31, 0x0d) |
| 389 |
SPI_WRITE(0x32, 0x48) |
| 390 |
SPI_WRITE(0x33, 0x82) |
| 391 |
SPI_WRITE(0x34, 0xbd) |
| 392 |
SPI_WRITE(0x35, 0xe7) |
| 393 |
SPI_WRITE(0x36, 0x18) |
| 394 |
SPI_WRITE(0x37, 0x94) |
| 395 |
SPI_WRITE(0x38, 0x01) |
| 396 |
SPI_WRITE(0x39, 0x5d) |
| 397 |
SPI_WRITE(0x3a, 0xae) |
| 398 |
SPI_WRITE(0x3b, 0xff) |
| 399 |
SPI_WRITE(0x07, 0x09) |
| 400 |
{ 0, 10 }, /* udelay 10 */ |
| 401 |
{ START, 0x00000001 }, /* To start operation */ |
| 402 |
}; |
| 403 |
|
| 404 |
static struct mddi_table mddi_tpo_deinit_table[] = { |
| 405 |
SPI_WRITE(0x07, 0x19) |
| 406 |
{ START, 0x00000000 }, /* To stop operation */ |
| 407 |
{ GPIODATA, 0x00040004 }, /* GPIO2 high */ |
| 408 |
{ GPIODIR, 0x00000004 }, /* GPIO2 out */ |
| 409 |
{ GPIODATA, 0x00040000 }, /* GPIO2 low */ |
| 410 |
{ 0, 5 }, /* usleep 5 */ |
| 411 |
}; |
| 412 |
|
| 413 |
|
| 414 |
#define GPIOSEL_VWAKEINT (1U << 0) |
| 415 |
#define INTMASK_VWAKEOUT (1U << 0) |
| 416 |
|
| 417 |
static void htcraphael_process_mddi_table(struct msm_mddi_client_data *client_data, |
| 418 |
struct mddi_table *table, size_t count) |
| 419 |
{ |
| 420 |
int i; |
| 421 |
for(i = 0; i < count; i++) { |
| 422 |
uint32_t reg = table[i].reg; |
| 423 |
uint32_t value = table[i].value; |
| 424 |
|
| 425 |
if (reg == 0) |
| 426 |
udelay(value); |
| 427 |
else if (reg == 1) |
| 428 |
msleep(value); |
| 429 |
else |
| 430 |
client_data->remote_write(client_data, value, reg); |
| 431 |
} |
| 432 |
} |
| 433 |
|
| 434 |
//static struct vreg *vreg_mddi_1v5; |
| 435 |
//static struct vreg *vreg_lcm_2v85; |
| 436 |
|
| 437 |
static void htcraphael_mddi_power_client(struct msm_mddi_client_data *client_data, |
| 438 |
int on) |
| 439 |
{ |
| 440 |
struct msm_dex_command dex; |
| 441 |
int i; |
| 442 |
|
| 443 |
printk("htcraphael_mddi_power_client(%d)\n", on); |
| 444 |
// printk("XC=%x\n", i=readl(MSM_SHARED_RAM_BASE + 0xfc048)); |
| 445 |
|
| 446 |
|
| 447 |
if(on) { |
| 448 |
/* |
| 449 |
gpio_set_value(RAPH100_LCD_PWR1, 1); |
| 450 |
dex.cmd=PCOM_PMIC_REG_ON; |
| 451 |
dex.has_data=1; |
| 452 |
dex.data=0x800; |
| 453 |
msm_proc_comm_wince(&dex,0); |
| 454 |
mdelay(50); |
| 455 |
dex.data=0x2000; |
| 456 |
msm_proc_comm_wince(&dex,0); |
| 457 |
mdelay(50); |
| 458 |
// msm_gpio_set_function(DEX_GPIO_CFG(RAPH100_LCD_PWR2,0,GPIO_OUTPUT,GPIO_NO_PULL,GPIO_2MA,1)); |
| 459 |
gpio_set_value(RAPH100_LCD_PWR2,1); |
| 460 |
mdelay(50); |
| 461 |
*/ |
| 462 |
} else { |
| 463 |
/* |
| 464 |
gpio_set_value(RAPH100_LCD_PWR2, 0); |
| 465 |
mdelay(1); |
| 466 |
dex.cmd=PCOM_PMIC_REG_OFF; |
| 467 |
dex.has_data=1; |
| 468 |
dex.data=0x2000; |
| 469 |
msm_proc_comm_wince(&dex,0); |
| 470 |
mdelay(5); // delay time >5ms and <10ms |
| 471 |
dex.data=0x800; |
| 472 |
msm_proc_comm_wince(&dex,0); |
| 473 |
mdelay(3); |
| 474 |
gpio_set_value(RAPH100_LCD_PWR1, 0); |
| 475 |
mdelay(10); |
| 476 |
*/ |
| 477 |
} |
| 478 |
|
| 479 |
|
| 480 |
} |
| 481 |
|
| 482 |
static int htcraphael_mddi_epson_client_init( |
| 483 |
struct msm_mddi_bridge_platform_data *bridge_data, |
| 484 |
struct msm_mddi_client_data *client_data) |
| 485 |
{ |
| 486 |
int panel_id; |
| 487 |
|
| 488 |
client_data->auto_hibernate(client_data, 0); |
| 489 |
// htcraphael_process_mddi_table(client_data, mddi_epson_init_table, |
| 490 |
// ARRAY_SIZE(mddi_epson_init_table)); |
| 491 |
client_data->auto_hibernate(client_data, 1); |
| 492 |
#if 0 |
| 493 |
panel_id = (client_data->remote_read(client_data, GPIODATA) >> 4) & 3; |
| 494 |
if (panel_id > 1) { |
| 495 |
printk("unknown panel id (0x%08x) at mddi_enable\n", panel_id); |
| 496 |
return -1; |
| 497 |
} |
| 498 |
#endif |
| 499 |
return 0; |
| 500 |
} |
| 501 |
|
| 502 |
static int htcraphael_mddi_epson_client_uninit( |
| 503 |
struct msm_mddi_bridge_platform_data *bridge_data, |
| 504 |
struct msm_mddi_client_data *client_data) |
| 505 |
{ |
| 506 |
return 0; |
| 507 |
} |
| 508 |
|
| 509 |
static int htcraphael_mddi_toshiba_client_init( |
| 510 |
struct msm_mddi_bridge_platform_data *bridge_data, |
| 511 |
struct msm_mddi_client_data *client_data) |
| 512 |
{ |
| 513 |
int panel_id, gpio_val; |
| 514 |
char *panels[]={"Hitachi","Sharp","Toppoly","Toppoly2"}; |
| 515 |
|
| 516 |
client_data->auto_hibernate(client_data, 0); |
| 517 |
// htcraphael_process_mddi_table(client_data, mddi_lcm_init_table, |
| 518 |
// ARRAY_SIZE(mddi_lcm_init_table)); |
| 519 |
client_data->auto_hibernate(client_data, 1); |
| 520 |
|
| 521 |
gpio_val = client_data->remote_read(client_data, GPIODATA); |
| 522 |
panel_id=0; |
| 523 |
|
| 524 |
if ( (gpio_val & 0x10) != 0 ) panel_id++; |
| 525 |
if ( (gpio_val & 4) != 0 ) panel_id+=2; |
| 526 |
|
| 527 |
printk("toshiba GPIODATA=0x%08x panel_id=%d at toshiba_mddi_enable\n", gpio_val, panel_id); |
| 528 |
|
| 529 |
printk("found panel_id=%d at toshiba_mddi_enable, panel=%s\n", panel_id,panels[panel_id]); |
| 530 |
|
| 531 |
return 0; |
| 532 |
} |
| 533 |
|
| 534 |
static int htcraphael_mddi_toshiba_client_uninit( |
| 535 |
struct msm_mddi_bridge_platform_data *bridge_data, |
| 536 |
struct msm_mddi_client_data *client_data) |
| 537 |
{ |
| 538 |
return 0; |
| 539 |
} |
| 540 |
|
| 541 |
static int htcraphael_mddi_panel_unblank( |
| 542 |
struct msm_mddi_bridge_platform_data *bridge_data, |
| 543 |
struct msm_mddi_client_data *client_data) |
| 544 |
{ |
| 545 |
|
| 546 |
int panel_id, ret = 0; |
| 547 |
|
| 548 |
client_data->auto_hibernate(client_data, 0); |
| 549 |
// htcraphael_process_mddi_table(client_data, mddi_lcm_init_table, |
| 550 |
// ARRAY_SIZE(mddi_toshiba_panel_init_table)); |
| 551 |
panel_id = (client_data->remote_read(client_data, GPIODATA) >> 4) & 3; |
| 552 |
switch(panel_id) { |
| 553 |
case 0: |
| 554 |
printk("init sharp panel\n"); |
| 555 |
// htcraphael_process_mddi_table(client_data, |
| 556 |
// mddi_sharp_init_table, |
| 557 |
// ARRAY_SIZE(mddi_sharp_init_table)); |
| 558 |
break; |
| 559 |
case 1: |
| 560 |
printk("init tpo panel\n"); |
| 561 |
// htcraphael_process_mddi_table(client_data, |
| 562 |
// mddi_tpo_init_table, |
| 563 |
// ARRAY_SIZE(mddi_tpo_init_table)); |
| 564 |
break; |
| 565 |
case 3: |
| 566 |
printk("init hitachi panel\n"); |
| 567 |
// htcraphael_process_mddi_table(client_data, |
| 568 |
// mddi_epson_init_table, |
| 569 |
// ARRAY_SIZE(mddi_epson_init_table)); |
| 570 |
break; |
| 571 |
default: |
| 572 |
printk("unknown panel_id: %d\n", panel_id); |
| 573 |
ret = -1; |
| 574 |
}; |
| 575 |
//XXX: client_data->auto_hibernate(client_data, 1); |
| 576 |
// client_data->remote_write(client_data, GPIOSEL_VWAKEINT, GPIOSEL); |
| 577 |
// client_data->remote_write(client_data, INTMASK_VWAKEOUT, INTMASK); |
| 578 |
micropklt_panel_resume(); |
| 579 |
return ret; |
| 580 |
|
| 581 |
} |
| 582 |
|
| 583 |
static int htcraphael_mddi_panel_blank( |
| 584 |
struct msm_mddi_bridge_platform_data *bridge_data, |
| 585 |
struct msm_mddi_client_data *client_data) |
| 586 |
{ |
| 587 |
int panel_id, ret = 0; |
| 588 |
|
| 589 |
panel_id = (client_data->remote_read(client_data, GPIODATA) >> 4) & 3; |
| 590 |
client_data->auto_hibernate(client_data, 0); |
| 591 |
switch(panel_id) { |
| 592 |
case 0: |
| 593 |
printk("deinit sharp panel\n"); |
| 594 |
// htcraphael_process_mddi_table(client_data, |
| 595 |
// mddi_sharp_deinit_table, |
| 596 |
// ARRAY_SIZE(mddi_sharp_deinit_table)); |
| 597 |
break; |
| 598 |
case 1: |
| 599 |
printk("deinit tpo panel\n"); |
| 600 |
// htcraphael_process_mddi_table(client_data, |
| 601 |
// mddi_tpo_deinit_table, |
| 602 |
// ARRAY_SIZE(mddi_tpo_deinit_table)); |
| 603 |
break; |
| 604 |
case 3: |
| 605 |
printk("deinit epson panel\n"); |
| 606 |
// htcraphael_process_mddi_table(client_data, |
| 607 |
// mddi_epson_deinit_table, |
| 608 |
// ARRAY_SIZE(mddi_epson_deinit_table)); |
| 609 |
break; |
| 610 |
default: |
| 611 |
printk("unknown panel_id: %d\n", panel_id); |
| 612 |
ret = -1; |
| 613 |
}; |
| 614 |
client_data->auto_hibernate(client_data, 1); |
| 615 |
|
| 616 |
// client_data->remote_write(client_data, 0, SYSCLKENA); |
| 617 |
// client_data->remote_write(client_data, 1, DPSUS); |
| 618 |
micropklt_panel_suspend(); |
| 619 |
return ret; |
| 620 |
} |
| 621 |
|
| 622 |
extern struct resource resources_msm_fb[]; |
| 623 |
|
| 624 |
static struct msm_mddi_bridge_platform_data toshiba_client_data = { |
| 625 |
.init = htcraphael_mddi_toshiba_client_init, |
| 626 |
.uninit = htcraphael_mddi_toshiba_client_uninit, |
| 627 |
.blank = htcraphael_mddi_panel_blank, |
| 628 |
.unblank = htcraphael_mddi_panel_unblank, |
| 629 |
.fb_data = { |
| 630 |
.xres = 480, |
| 631 |
.yres = 640, |
| 632 |
.output_format = 0, |
| 633 |
}, |
| 634 |
}; |
| 635 |
|
| 636 |
static struct msm_mddi_bridge_platform_data epson_client_data = { |
| 637 |
.init = htcraphael_mddi_epson_client_init, |
| 638 |
.uninit = htcraphael_mddi_epson_client_uninit, |
| 639 |
.blank = htcraphael_mddi_panel_blank, |
| 640 |
.unblank = htcraphael_mddi_panel_unblank, |
| 641 |
.fb_data = { |
| 642 |
.xres = 480, |
| 643 |
.yres = 640, |
| 644 |
.output_format = 0, |
| 645 |
}, |
| 646 |
}; |
| 647 |
|
| 648 |
static struct msm_mddi_platform_data mddi_pdata = { |
| 649 |
.vsync_irq = MSM_GPIO_TO_INT(RAPH100_LCD_VSYNC), |
| 650 |
.clk_rate = 122880000, |
| 651 |
.power_client = htcraphael_mddi_power_client, |
| 652 |
.fb_resource = resources_msm_fb, |
| 653 |
.num_clients = 2, |
| 654 |
.client_platform_data = { |
| 655 |
{ |
| 656 |
.product_id = (0xd263 << 16 | 0), |
| 657 |
.name = "mddi_c_d263_0000", |
| 658 |
.id = 0, |
| 659 |
.client_data = &toshiba_client_data, |
| 660 |
.clk_rate = 0, |
| 661 |
}, |
| 662 |
{ |
| 663 |
.product_id = (0x4ca3 << 16 | 0), |
| 664 |
.name = "S1D13774", |
| 665 |
.id = 0, |
| 666 |
.client_data = &epson_client_data, |
| 667 |
.clk_rate = 0, |
| 668 |
}, |
| 669 |
}, |
| 670 |
}; |
| 671 |
|
| 672 |
int __init htcraphael_init_panel(void) |
| 673 |
{ |
| 674 |
int rc; |
| 675 |
|
| 676 |
printk(KERN_INFO "%s: Initializing panel\n", __func__); |
| 677 |
|
| 678 |
if (!machine_is_htcraphael() && !machine_is_htcraphael_cdma() && !machine_is_htcraphael_cdma500() /*&& !machine_is_htcdiamond()*/ && !machine_is_htcdiamond_cdma()) { |
| 679 |
printk(KERN_INFO "%s: disabling raphael panel\n", __func__); |
| 680 |
return 0; |
| 681 |
} |
| 682 |
|
| 683 |
/* vreg_mddi_1v5 = vreg_get(0, "gp2"); |
| 684 |
if (IS_ERR(vreg_mddi_1v5)) |
| 685 |
return PTR_ERR(vreg_mddi_1v5); |
| 686 |
vreg_lcm_2v85 = vreg_get(0, "gp4"); |
| 687 |
if (IS_ERR(vreg_lcm_2v85)) |
| 688 |
return PTR_ERR(vreg_lcm_2v85); |
| 689 |
|
| 690 |
gp_clk = clk_get(NULL, "gp_clk"); |
| 691 |
if (IS_ERR(gp_clk)) { |
| 692 |
printk(KERN_ERR "%s: could not get gp clock\n", __func__); |
| 693 |
gp_clk = NULL; |
| 694 |
} |
| 695 |
rc = clk_set_rate(gp_clk, 19200000); |
| 696 |
if (rc) |
| 697 |
{ |
| 698 |
printk(KERN_ERR "%s: set clock rate failed\n", __func__); |
| 699 |
} |
| 700 |
*/ |
| 701 |
|
| 702 |
rc = gpio_request(RAPH100_LCD_VSYNC, "vsync"); |
| 703 |
if (rc) |
| 704 |
return rc; |
| 705 |
rc = gpio_direction_input(RAPH100_LCD_VSYNC); |
| 706 |
if (rc) |
| 707 |
return rc; |
| 708 |
|
| 709 |
rc = platform_device_register(&msm_device_mdp); |
| 710 |
if (rc) |
| 711 |
return rc; |
| 712 |
msm_device_mddi0.dev.platform_data = &mddi_pdata; |
| 713 |
|
| 714 |
/* TODO: implement speed via clk_rate */ |
| 715 |
writel(0xa0c, MSM_CLK_CTL_BASE + 0x8c); |
| 716 |
|
| 717 |
return platform_device_register(&msm_device_mddi0); |
| 718 |
} |
| 719 |
|
| 720 |
device_initcall(htcraphael_init_panel); |