| 1 |
/* linux/arch/arm/mach-msm/board-trout-mddi.c |
| 2 |
** Author: 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/backlight.h> |
| 10 |
#include <linux/clk.h> |
| 11 |
#include <linux/err.h> |
| 12 |
|
| 13 |
#include <asm/io.h> |
| 14 |
#include <asm/gpio.h> |
| 15 |
#include <asm/mach-types.h> |
| 16 |
|
| 17 |
#include <mach/msm_fb.h> |
| 18 |
#include <mach/vreg.h> |
| 19 |
#include <mach/htc_pwrsink.h> |
| 20 |
|
| 21 |
#include "board-trout.h" |
| 22 |
#include "proc_comm.h" |
| 23 |
#include "devices.h" |
| 24 |
|
| 25 |
#define TROUT_DEFAULT_BACKLIGHT_BRIGHTNESS 127 |
| 26 |
|
| 27 |
static struct clk *gp_clk; |
| 28 |
static int trout_backlight_off; |
| 29 |
static int trout_backlight_resume_level = TROUT_DEFAULT_BACKLIGHT_BRIGHTNESS; |
| 30 |
static int trout_new_backlight = 1; |
| 31 |
static uint8_t trout_backlight_last_level = 33; |
| 32 |
static DEFINE_MUTEX(trout_backlight_lock); |
| 33 |
|
| 34 |
static void trout_set_backlight_level(uint8_t level) |
| 35 |
{ |
| 36 |
unsigned percent = ((int)level * 100) / 255; |
| 37 |
|
| 38 |
if (trout_new_backlight) { |
| 39 |
unsigned long flags; |
| 40 |
int i = 0; |
| 41 |
level = (int)level * 34 / 256; |
| 42 |
|
| 43 |
if (trout_backlight_last_level == level) |
| 44 |
return; |
| 45 |
|
| 46 |
if (level == 0) { |
| 47 |
gpio_set_value(27, 0); |
| 48 |
msleep(2); |
| 49 |
} else { |
| 50 |
local_irq_save(flags); |
| 51 |
if (trout_backlight_last_level == 0) { |
| 52 |
gpio_set_value(27, 1); |
| 53 |
udelay(40); |
| 54 |
trout_backlight_last_level = 33; |
| 55 |
} |
| 56 |
i = (trout_backlight_last_level - level + 33) % 33; |
| 57 |
while (i-- > 0) { |
| 58 |
gpio_set_value(27, 0); |
| 59 |
udelay(1); |
| 60 |
gpio_set_value(27, 1); |
| 61 |
udelay(1); |
| 62 |
} |
| 63 |
local_irq_restore(flags); |
| 64 |
} |
| 65 |
trout_backlight_last_level = level; |
| 66 |
} |
| 67 |
else { |
| 68 |
if(level) { |
| 69 |
clk_enable(gp_clk); |
| 70 |
writel((1U << 16) | (~level & 0xffff), |
| 71 |
MSM_CLK_CTL_BASE + 0x58); |
| 72 |
/* Going directly to a 100% duty cycle does not |
| 73 |
* seem to work */ |
| 74 |
if(level == 255) { |
| 75 |
writel((~127 << 16) | 0xb20, |
| 76 |
MSM_CLK_CTL_BASE + 0x5c); |
| 77 |
udelay(1); |
| 78 |
} |
| 79 |
writel((~127 << 16) | 0xb58, MSM_CLK_CTL_BASE + 0x5c); |
| 80 |
} |
| 81 |
else { |
| 82 |
writel(0x0, MSM_CLK_CTL_BASE + 0x5c); |
| 83 |
clk_disable(gp_clk); |
| 84 |
} |
| 85 |
} |
| 86 |
htc_pwrsink_set(PWRSINK_BACKLIGHT, percent); |
| 87 |
} |
| 88 |
|
| 89 |
#define MDDI_CLIENT_CORE_BASE 0x108000 |
| 90 |
#define LCD_CONTROL_BLOCK_BASE 0x110000 |
| 91 |
#define SPI_BLOCK_BASE 0x120000 |
| 92 |
#define I2C_BLOCK_BASE 0x130000 |
| 93 |
#define PWM_BLOCK_BASE 0x140000 |
| 94 |
#define GPIO_BLOCK_BASE 0x150000 |
| 95 |
#define SYSTEM_BLOCK1_BASE 0x160000 |
| 96 |
#define SYSTEM_BLOCK2_BASE 0x170000 |
| 97 |
|
| 98 |
|
| 99 |
#define DPSUS (MDDI_CLIENT_CORE_BASE|0x24) |
| 100 |
#define SYSCLKENA (MDDI_CLIENT_CORE_BASE|0x2C) |
| 101 |
#define PWM0OFF (PWM_BLOCK_BASE|0x1C) |
| 102 |
|
| 103 |
#define V_VDDE2E_VDD2_GPIO 0 |
| 104 |
#define MDDI_RST_N 82 |
| 105 |
|
| 106 |
#define MDDICAP0 (MDDI_CLIENT_CORE_BASE|0x00) |
| 107 |
#define MDDICAP1 (MDDI_CLIENT_CORE_BASE|0x04) |
| 108 |
#define MDDICAP2 (MDDI_CLIENT_CORE_BASE|0x08) |
| 109 |
#define MDDICAP3 (MDDI_CLIENT_CORE_BASE|0x0C) |
| 110 |
#define MDCAPCHG (MDDI_CLIENT_CORE_BASE|0x10) |
| 111 |
#define MDCRCERC (MDDI_CLIENT_CORE_BASE|0x14) |
| 112 |
#define TTBUSSEL (MDDI_CLIENT_CORE_BASE|0x18) |
| 113 |
#define DPSET0 (MDDI_CLIENT_CORE_BASE|0x1C) |
| 114 |
#define DPSET1 (MDDI_CLIENT_CORE_BASE|0x20) |
| 115 |
#define DPSUS (MDDI_CLIENT_CORE_BASE|0x24) |
| 116 |
#define DPRUN (MDDI_CLIENT_CORE_BASE|0x28) |
| 117 |
#define SYSCKENA (MDDI_CLIENT_CORE_BASE|0x2C) |
| 118 |
#define TESTMODE (MDDI_CLIENT_CORE_BASE|0x30) |
| 119 |
#define FIFOMONI (MDDI_CLIENT_CORE_BASE|0x34) |
| 120 |
#define INTMONI (MDDI_CLIENT_CORE_BASE|0x38) |
| 121 |
#define MDIOBIST (MDDI_CLIENT_CORE_BASE|0x3C) |
| 122 |
#define MDIOPSET (MDDI_CLIENT_CORE_BASE|0x40) |
| 123 |
#define BITMAP0 (MDDI_CLIENT_CORE_BASE|0x44) |
| 124 |
#define BITMAP1 (MDDI_CLIENT_CORE_BASE|0x48) |
| 125 |
#define BITMAP2 (MDDI_CLIENT_CORE_BASE|0x4C) |
| 126 |
#define BITMAP3 (MDDI_CLIENT_CORE_BASE|0x50) |
| 127 |
#define BITMAP4 (MDDI_CLIENT_CORE_BASE|0x54) |
| 128 |
|
| 129 |
#define SRST (LCD_CONTROL_BLOCK_BASE|0x00) |
| 130 |
#define PORT_ENB (LCD_CONTROL_BLOCK_BASE|0x04) |
| 131 |
#define START (LCD_CONTROL_BLOCK_BASE|0x08) |
| 132 |
#define PORT (LCD_CONTROL_BLOCK_BASE|0x0C) |
| 133 |
#define CMN (LCD_CONTROL_BLOCK_BASE|0x10) |
| 134 |
#define GAMMA (LCD_CONTROL_BLOCK_BASE|0x14) |
| 135 |
#define INTFLG (LCD_CONTROL_BLOCK_BASE|0x18) |
| 136 |
#define INTMSK (LCD_CONTROL_BLOCK_BASE|0x1C) |
| 137 |
#define MPLFBUF (LCD_CONTROL_BLOCK_BASE|0x20) |
| 138 |
#define HDE_LEFT (LCD_CONTROL_BLOCK_BASE|0x24) |
| 139 |
#define VDE_TOP (LCD_CONTROL_BLOCK_BASE|0x28) |
| 140 |
#define PXL (LCD_CONTROL_BLOCK_BASE|0x30) |
| 141 |
#define HCYCLE (LCD_CONTROL_BLOCK_BASE|0x34) |
| 142 |
#define HSW (LCD_CONTROL_BLOCK_BASE|0x38) |
| 143 |
#define HDE_START (LCD_CONTROL_BLOCK_BASE|0x3C) |
| 144 |
#define HDE_SIZE (LCD_CONTROL_BLOCK_BASE|0x40) |
| 145 |
#define VCYCLE (LCD_CONTROL_BLOCK_BASE|0x44) |
| 146 |
#define VSW (LCD_CONTROL_BLOCK_BASE|0x48) |
| 147 |
#define VDE_START (LCD_CONTROL_BLOCK_BASE|0x4C) |
| 148 |
#define VDE_SIZE (LCD_CONTROL_BLOCK_BASE|0x50) |
| 149 |
#define WAKEUP (LCD_CONTROL_BLOCK_BASE|0x54) |
| 150 |
#define WSYN_DLY (LCD_CONTROL_BLOCK_BASE|0x58) |
| 151 |
#define REGENB (LCD_CONTROL_BLOCK_BASE|0x5C) |
| 152 |
#define VSYNIF (LCD_CONTROL_BLOCK_BASE|0x60) |
| 153 |
#define WRSTB (LCD_CONTROL_BLOCK_BASE|0x64) |
| 154 |
#define RDSTB (LCD_CONTROL_BLOCK_BASE|0x68) |
| 155 |
#define ASY_DATA (LCD_CONTROL_BLOCK_BASE|0x6C) |
| 156 |
#define ASY_DATB (LCD_CONTROL_BLOCK_BASE|0x70) |
| 157 |
#define ASY_DATC (LCD_CONTROL_BLOCK_BASE|0x74) |
| 158 |
#define ASY_DATD (LCD_CONTROL_BLOCK_BASE|0x78) |
| 159 |
#define ASY_DATE (LCD_CONTROL_BLOCK_BASE|0x7C) |
| 160 |
#define ASY_DATF (LCD_CONTROL_BLOCK_BASE|0x80) |
| 161 |
#define ASY_DATG (LCD_CONTROL_BLOCK_BASE|0x84) |
| 162 |
#define ASY_DATH (LCD_CONTROL_BLOCK_BASE|0x88) |
| 163 |
#define ASY_CMDSET (LCD_CONTROL_BLOCK_BASE|0x8C) |
| 164 |
|
| 165 |
#define SSICTL (SPI_BLOCK_BASE|0x00) |
| 166 |
#define SSITIME (SPI_BLOCK_BASE|0x04) |
| 167 |
#define SSITX (SPI_BLOCK_BASE|0x08) |
| 168 |
#define SSIRX (SPI_BLOCK_BASE|0x0C) |
| 169 |
#define SSIINTC (SPI_BLOCK_BASE|0x10) |
| 170 |
#define SSIINTS (SPI_BLOCK_BASE|0x14) |
| 171 |
#define SSIDBG1 (SPI_BLOCK_BASE|0x18) |
| 172 |
#define SSIDBG2 (SPI_BLOCK_BASE|0x1C) |
| 173 |
#define SSIID (SPI_BLOCK_BASE|0x20) |
| 174 |
|
| 175 |
#define WKREQ (SYSTEM_BLOCK1_BASE|0x00) |
| 176 |
#define CLKENB (SYSTEM_BLOCK1_BASE|0x04) |
| 177 |
#define DRAMPWR (SYSTEM_BLOCK1_BASE|0x08) |
| 178 |
#define INTMASK (SYSTEM_BLOCK1_BASE|0x0C) |
| 179 |
#define GPIOSEL (SYSTEM_BLOCK2_BASE|0x00) |
| 180 |
|
| 181 |
#define GPIODATA (GPIO_BLOCK_BASE|0x00) |
| 182 |
#define GPIODIR (GPIO_BLOCK_BASE|0x04) |
| 183 |
#define GPIOIS (GPIO_BLOCK_BASE|0x08) |
| 184 |
#define GPIOIBE (GPIO_BLOCK_BASE|0x0C) |
| 185 |
#define GPIOIEV (GPIO_BLOCK_BASE|0x10) |
| 186 |
#define GPIOIE (GPIO_BLOCK_BASE|0x14) |
| 187 |
#define GPIORIS (GPIO_BLOCK_BASE|0x18) |
| 188 |
#define GPIOMIS (GPIO_BLOCK_BASE|0x1C) |
| 189 |
#define GPIOIC (GPIO_BLOCK_BASE|0x20) |
| 190 |
#define GPIOOMS (GPIO_BLOCK_BASE|0x24) |
| 191 |
#define GPIOPC (GPIO_BLOCK_BASE|0x28) |
| 192 |
#define GPIOID (GPIO_BLOCK_BASE|0x30) |
| 193 |
|
| 194 |
#define SPI_WRITE(reg, val) \ |
| 195 |
{ SSITX, 0x00010000 | (((reg) & 0xff) << 8) | ((val) & 0xff) }, \ |
| 196 |
{ 0, 5 }, |
| 197 |
|
| 198 |
#define SPI_WRITE1(reg) \ |
| 199 |
{ SSITX, (reg) & 0xff }, \ |
| 200 |
{ 0, 5 }, |
| 201 |
|
| 202 |
struct mddi_table { |
| 203 |
uint32_t reg; |
| 204 |
uint32_t value; |
| 205 |
}; |
| 206 |
static struct mddi_table mddi_toshiba_init_table[] = { |
| 207 |
{ DPSET0, 0x09e90046 }, |
| 208 |
{ DPSET1, 0x00000118 }, |
| 209 |
{ DPSUS, 0x00000000 }, |
| 210 |
{ DPRUN, 0x00000001 }, |
| 211 |
{ 1, 14 }, /* msleep 14 */ |
| 212 |
{ SYSCKENA, 0x00000001 }, |
| 213 |
//{ CLKENB, 0x000000EF }, |
| 214 |
{ CLKENB, 0x0000A1EF }, /* # SYS.CLKENB # Enable clocks for each module (without DCLK , i2cCLK) */ |
| 215 |
//{ CLKENB, 0x000025CB }, /* Clock enable register */ |
| 216 |
|
| 217 |
{ GPIODATA, 0x02000200 }, /* # GPI .GPIODATA # GPIO2(RESET_LCD_N) set to 0 , GPIO3(eDRAM_Power) set to 0 */ |
| 218 |
{ GPIODIR, 0x000030D }, /* 24D # GPI .GPIODIR # Select direction of GPIO port (0,2,3,6,9 output) */ |
| 219 |
{ GPIOSEL, 0/*0x00000173*/}, /* # SYS.GPIOSEL # GPIO port multiplexing control */ |
| 220 |
{ GPIOPC, 0x03C300C0 }, /* # GPI .GPIOPC # GPIO2,3 PD cut */ |
| 221 |
{ WKREQ, 0x00000000 }, /* # SYS.WKREQ # Wake-up request event is VSYNC alignment */ |
| 222 |
|
| 223 |
{ GPIOIBE, 0x000003FF }, |
| 224 |
{ GPIOIS, 0x00000000 }, |
| 225 |
{ GPIOIC, 0x000003FF }, |
| 226 |
{ GPIOIE, 0x00000000 }, |
| 227 |
|
| 228 |
{ GPIODATA, 0x00040004 }, /* # GPI .GPIODATA # eDRAM VD supply */ |
| 229 |
{ 1, 1 }, /* msleep 1 */ |
| 230 |
{ GPIODATA, 0x02040004 }, /* # GPI .GPIODATA # eDRAM VD supply */ |
| 231 |
{ DRAMPWR, 0x00000001 }, /* eDRAM power */ |
| 232 |
}; |
| 233 |
|
| 234 |
static struct mddi_table mddi_toshiba_panel_init_table[] = { |
| 235 |
{ SRST, 0x00000003 }, /* FIFO/LCDC not reset */ |
| 236 |
{ PORT_ENB, 0x00000001 }, /* Enable sync. Port */ |
| 237 |
{ START, 0x00000000 }, /* To stop operation */ |
| 238 |
//{ START, 0x00000001 }, /* To start operation */ |
| 239 |
{ PORT, 0x00000004 }, /* Polarity of VS/HS/DE. */ |
| 240 |
{ CMN, 0x00000000 }, |
| 241 |
{ GAMMA, 0x00000000 }, /* No Gamma correction */ |
| 242 |
{ INTFLG, 0x00000000 }, /* VSYNC interrupt flag clear/status */ |
| 243 |
{ INTMSK, 0x00000000 }, /* VSYNC interrupt mask is off. */ |
| 244 |
{ MPLFBUF, 0x00000000 }, /* Select frame buffer's base address. */ |
| 245 |
{ HDE_LEFT, 0x00000000 }, /* The value of HDE_LEFT. */ |
| 246 |
{ VDE_TOP, 0x00000000 }, /* The value of VDE_TPO. */ |
| 247 |
{ PXL, 0x00000001 }, /* 1. RGB666 */ |
| 248 |
/* 2. Data is valid from 1st frame of beginning. */ |
| 249 |
{ HDE_START, 0x00000006 }, /* HDE_START= 14 PCLK */ |
| 250 |
{ HDE_SIZE, 0x0000009F }, /* HDE_SIZE=320 PCLK */ |
| 251 |
{ HSW, 0x00000004 }, /* HSW= 10 PCLK */ |
| 252 |
{ VSW, 0x00000001 }, /* VSW=2 HCYCLE */ |
| 253 |
{ VDE_START, 0x00000003 }, /* VDE_START=4 HCYCLE */ |
| 254 |
{ VDE_SIZE, 0x000001DF }, /* VDE_SIZE=480 HCYCLE */ |
| 255 |
{ WAKEUP, 0x000001e2 }, /* Wakeup position in VSYNC mode. */ |
| 256 |
{ WSYN_DLY, 0x00000000 }, /* Wakeup position in VSIN mode. */ |
| 257 |
{ REGENB, 0x00000001 }, /* Set 1 to enable to change the value of registers. */ |
| 258 |
{ CLKENB, 0x000025CB }, /* Clock enable register */ |
| 259 |
|
| 260 |
{ SSICTL, 0x00000170 }, /* SSI control register */ |
| 261 |
{ SSITIME, 0x00000250 }, /* SSI timing control register */ |
| 262 |
{ SSICTL, 0x00000172 }, /* SSI control register */ |
| 263 |
}; |
| 264 |
|
| 265 |
|
| 266 |
static struct mddi_table mddi_sharp_init_table[] = { |
| 267 |
{ VCYCLE, 0x000001eb }, |
| 268 |
{ HCYCLE, 0x000000ae }, |
| 269 |
{ REGENB, 0x00000001 }, /* Set 1 to enable to change the value of registers. */ |
| 270 |
{ GPIODATA, 0x00040000 }, /* GPIO2 low */ |
| 271 |
{ GPIODIR, 0x00000004 }, /* GPIO2 out */ |
| 272 |
{ 1, 1 }, /* msleep 1 */ |
| 273 |
{ GPIODATA, 0x00040004 }, /* GPIO2 high */ |
| 274 |
{ 1, 10 }, /* msleep 10 */ |
| 275 |
SPI_WRITE(0x5f, 0x01) |
| 276 |
SPI_WRITE1(0x11) |
| 277 |
{ 1, 200 }, /* msleep 200 */ |
| 278 |
SPI_WRITE1(0x29) |
| 279 |
SPI_WRITE1(0xde) |
| 280 |
{ START, 0x00000001 }, /* To start operation */ |
| 281 |
}; |
| 282 |
|
| 283 |
static struct mddi_table mddi_sharp_deinit_table[] = { |
| 284 |
{ 1, 200 }, /* msleep 200 */ |
| 285 |
SPI_WRITE(0x10, 0x1) |
| 286 |
{ 1, 100 }, /* msleep 100 */ |
| 287 |
{ GPIODATA, 0x00040004 }, /* GPIO2 high */ |
| 288 |
{ GPIODIR, 0x00000004 }, /* GPIO2 out */ |
| 289 |
{ GPIODATA, 0x00040000 }, /* GPIO2 low */ |
| 290 |
{ 1, 10 }, /* msleep 10 */ |
| 291 |
}; |
| 292 |
|
| 293 |
static struct mddi_table mddi_tpo_init_table[] = { |
| 294 |
{ VCYCLE, 0x000001e5 }, |
| 295 |
{ HCYCLE, 0x000000ac }, |
| 296 |
{ REGENB, 0x00000001 }, /* Set 1 to enable to change the value of registers. */ |
| 297 |
{ 0, 20 }, /* udelay 20 */ |
| 298 |
{ GPIODATA, 0x00000004 }, /* GPIO2 high */ |
| 299 |
{ GPIODIR, 0x00000004 }, /* GPIO2 out */ |
| 300 |
{ 0, 20 }, /* udelay 20 */ |
| 301 |
|
| 302 |
SPI_WRITE(0x08, 0x01) |
| 303 |
{ 0, 500 }, /* udelay 500 */ |
| 304 |
SPI_WRITE(0x08, 0x00) |
| 305 |
SPI_WRITE(0x02, 0x00) |
| 306 |
SPI_WRITE(0x03, 0x04) |
| 307 |
SPI_WRITE(0x04, 0x0e) |
| 308 |
SPI_WRITE(0x09, 0x02) |
| 309 |
SPI_WRITE(0x0b, 0x08) |
| 310 |
SPI_WRITE(0x0c, 0x53) |
| 311 |
SPI_WRITE(0x0d, 0x01) |
| 312 |
SPI_WRITE(0x0e, 0xe0) |
| 313 |
SPI_WRITE(0x0f, 0x01) |
| 314 |
SPI_WRITE(0x10, 0x58) |
| 315 |
SPI_WRITE(0x20, 0x1e) |
| 316 |
SPI_WRITE(0x21, 0x0a) |
| 317 |
SPI_WRITE(0x22, 0x0a) |
| 318 |
SPI_WRITE(0x23, 0x1e) |
| 319 |
SPI_WRITE(0x25, 0x32) |
| 320 |
SPI_WRITE(0x26, 0x00) |
| 321 |
SPI_WRITE(0x27, 0xac) |
| 322 |
SPI_WRITE(0x29, 0x06) |
| 323 |
SPI_WRITE(0x2a, 0xa4) |
| 324 |
SPI_WRITE(0x2b, 0x45) |
| 325 |
SPI_WRITE(0x2c, 0x45) |
| 326 |
SPI_WRITE(0x2d, 0x15) |
| 327 |
SPI_WRITE(0x2e, 0x5a) |
| 328 |
SPI_WRITE(0x2f, 0xff) |
| 329 |
SPI_WRITE(0x30, 0x6b) |
| 330 |
SPI_WRITE(0x31, 0x0d) |
| 331 |
SPI_WRITE(0x32, 0x48) |
| 332 |
SPI_WRITE(0x33, 0x82) |
| 333 |
SPI_WRITE(0x34, 0xbd) |
| 334 |
SPI_WRITE(0x35, 0xe7) |
| 335 |
SPI_WRITE(0x36, 0x18) |
| 336 |
SPI_WRITE(0x37, 0x94) |
| 337 |
SPI_WRITE(0x38, 0x01) |
| 338 |
SPI_WRITE(0x39, 0x5d) |
| 339 |
SPI_WRITE(0x3a, 0xae) |
| 340 |
SPI_WRITE(0x3b, 0xff) |
| 341 |
SPI_WRITE(0x07, 0x09) |
| 342 |
{ 0, 10 }, /* udelay 10 */ |
| 343 |
{ START, 0x00000001 }, /* To start operation */ |
| 344 |
}; |
| 345 |
|
| 346 |
static struct mddi_table mddi_tpo_deinit_table[] = { |
| 347 |
SPI_WRITE(0x07, 0x19) |
| 348 |
{ START, 0x00000000 }, /* To stop operation */ |
| 349 |
{ GPIODATA, 0x00040004 }, /* GPIO2 high */ |
| 350 |
{ GPIODIR, 0x00000004 }, /* GPIO2 out */ |
| 351 |
{ GPIODATA, 0x00040000 }, /* GPIO2 low */ |
| 352 |
{ 0, 5 }, /* usleep 5 */ |
| 353 |
}; |
| 354 |
|
| 355 |
|
| 356 |
#define GPIOSEL_VWAKEINT (1U << 0) |
| 357 |
#define INTMASK_VWAKEOUT (1U << 0) |
| 358 |
|
| 359 |
static void trout_process_mddi_table(struct msm_mddi_client_data *client_data, |
| 360 |
struct mddi_table *table, size_t count) |
| 361 |
{ |
| 362 |
int i; |
| 363 |
for(i = 0; i < count; i++) { |
| 364 |
uint32_t reg = table[i].reg; |
| 365 |
uint32_t value = table[i].value; |
| 366 |
|
| 367 |
if (reg == 0) |
| 368 |
udelay(value); |
| 369 |
else if (reg == 1) |
| 370 |
msleep(value); |
| 371 |
else |
| 372 |
client_data->remote_write(client_data, value, reg); |
| 373 |
} |
| 374 |
} |
| 375 |
|
| 376 |
static struct vreg *vreg_mddi_1v5; |
| 377 |
static struct vreg *vreg_lcm_2v85; |
| 378 |
|
| 379 |
static void trout_mddi_power_client(struct msm_mddi_client_data *client_data, |
| 380 |
int on) |
| 381 |
{ |
| 382 |
unsigned id, on_off; |
| 383 |
if(on) { |
| 384 |
on_off = 0; |
| 385 |
id = PM_VREG_PDOWN_MDDI_ID; |
| 386 |
msm_proc_comm(PCOM_VREG_PULLDOWN, &on_off, &id); |
| 387 |
vreg_enable(vreg_mddi_1v5); |
| 388 |
mdelay(5); // delay time >5ms and <10ms |
| 389 |
gpio_set_value(V_VDDE2E_VDD2_GPIO, 1); |
| 390 |
gpio_set_value(TROUT_GPIO_MDDI_32K_EN, 1); |
| 391 |
msleep(3); |
| 392 |
id = PM_VREG_PDOWN_AUX_ID; |
| 393 |
msm_proc_comm(PCOM_VREG_PULLDOWN, &on_off, &id); |
| 394 |
vreg_enable(vreg_lcm_2v85); |
| 395 |
msleep(3); |
| 396 |
gpio_set_value(MDDI_RST_N, 1); |
| 397 |
msleep(10); |
| 398 |
} else { |
| 399 |
gpio_set_value(TROUT_GPIO_MDDI_32K_EN, 0); |
| 400 |
gpio_set_value(MDDI_RST_N, 0); |
| 401 |
msleep(10); |
| 402 |
vreg_disable(vreg_lcm_2v85); |
| 403 |
on_off = 1; |
| 404 |
id = PM_VREG_PDOWN_AUX_ID; |
| 405 |
msm_proc_comm(PCOM_VREG_PULLDOWN, &on_off, &id); |
| 406 |
msleep(5); |
| 407 |
gpio_set_value(V_VDDE2E_VDD2_GPIO, 0); |
| 408 |
msleep(200); |
| 409 |
vreg_disable(vreg_mddi_1v5); |
| 410 |
id = PM_VREG_PDOWN_MDDI_ID; |
| 411 |
msm_proc_comm(PCOM_VREG_PULLDOWN, &on_off, &id); |
| 412 |
} |
| 413 |
} |
| 414 |
|
| 415 |
static int trout_mddi_toshiba_client_init( |
| 416 |
struct msm_mddi_bridge_platform_data *bridge_data, |
| 417 |
struct msm_mddi_client_data *client_data) |
| 418 |
{ |
| 419 |
int panel_id; |
| 420 |
|
| 421 |
client_data->auto_hibernate(client_data, 0); |
| 422 |
trout_process_mddi_table(client_data, mddi_toshiba_init_table, |
| 423 |
ARRAY_SIZE(mddi_toshiba_init_table)); |
| 424 |
client_data->auto_hibernate(client_data, 1); |
| 425 |
panel_id = (client_data->remote_read(client_data, GPIODATA) >> 4) & 3; |
| 426 |
if (panel_id > 1) { |
| 427 |
printk("unknown panel id at mddi_enable\n"); |
| 428 |
return -1; |
| 429 |
} |
| 430 |
return 0; |
| 431 |
} |
| 432 |
|
| 433 |
static int trout_mddi_toshiba_client_uninit( |
| 434 |
struct msm_mddi_bridge_platform_data *bridge_data, |
| 435 |
struct msm_mddi_client_data *client_data) |
| 436 |
{ |
| 437 |
return 0; |
| 438 |
} |
| 439 |
|
| 440 |
static int trout_mddi_panel_unblank( |
| 441 |
struct msm_mddi_bridge_platform_data *bridge_data, |
| 442 |
struct msm_mddi_client_data *client_data) |
| 443 |
{ |
| 444 |
|
| 445 |
int panel_id, ret = 0; |
| 446 |
|
| 447 |
trout_set_backlight_level(0); |
| 448 |
client_data->auto_hibernate(client_data, 0); |
| 449 |
trout_process_mddi_table(client_data, mddi_toshiba_panel_init_table, |
| 450 |
ARRAY_SIZE(mddi_toshiba_panel_init_table)); |
| 451 |
panel_id = (client_data->remote_read(client_data, GPIODATA) >> 4) & 3; |
| 452 |
switch(panel_id) { |
| 453 |
case 0: |
| 454 |
printk("init sharp panel\n"); |
| 455 |
trout_process_mddi_table(client_data, |
| 456 |
mddi_sharp_init_table, |
| 457 |
ARRAY_SIZE(mddi_sharp_init_table)); |
| 458 |
break; |
| 459 |
case 1: |
| 460 |
printk("init tpo panel\n"); |
| 461 |
trout_process_mddi_table(client_data, |
| 462 |
mddi_tpo_init_table, |
| 463 |
ARRAY_SIZE(mddi_tpo_init_table)); |
| 464 |
break; |
| 465 |
default: |
| 466 |
printk("unknown panel_id: %d\n", panel_id); |
| 467 |
ret = -1; |
| 468 |
}; |
| 469 |
mutex_lock(&trout_backlight_lock); |
| 470 |
trout_set_backlight_level(trout_backlight_resume_level); |
| 471 |
trout_backlight_off = 0; |
| 472 |
mutex_unlock(&trout_backlight_lock); |
| 473 |
client_data->auto_hibernate(client_data, 1); |
| 474 |
client_data->remote_write(client_data, GPIOSEL_VWAKEINT, GPIOSEL); |
| 475 |
client_data->remote_write(client_data, INTMASK_VWAKEOUT, INTMASK); |
| 476 |
return ret; |
| 477 |
|
| 478 |
} |
| 479 |
|
| 480 |
static int trout_mddi_panel_blank( |
| 481 |
struct msm_mddi_bridge_platform_data *bridge_data, |
| 482 |
struct msm_mddi_client_data *client_data) |
| 483 |
{ |
| 484 |
int panel_id, ret = 0; |
| 485 |
|
| 486 |
panel_id = (client_data->remote_read(client_data, GPIODATA) >> 4) & 3; |
| 487 |
client_data->auto_hibernate(client_data, 0); |
| 488 |
switch(panel_id) { |
| 489 |
case 0: |
| 490 |
printk("deinit sharp panel\n"); |
| 491 |
trout_process_mddi_table(client_data, |
| 492 |
mddi_sharp_deinit_table, |
| 493 |
ARRAY_SIZE(mddi_sharp_deinit_table)); |
| 494 |
break; |
| 495 |
case 1: |
| 496 |
printk("deinit tpo panel\n"); |
| 497 |
trout_process_mddi_table(client_data, |
| 498 |
mddi_tpo_deinit_table, |
| 499 |
ARRAY_SIZE(mddi_tpo_deinit_table)); |
| 500 |
break; |
| 501 |
default: |
| 502 |
printk("unknown panel_id: %d\n", panel_id); |
| 503 |
ret = -1; |
| 504 |
}; |
| 505 |
client_data->auto_hibernate(client_data, 1); |
| 506 |
mutex_lock(&trout_backlight_lock); |
| 507 |
trout_set_backlight_level(0); |
| 508 |
trout_backlight_off = 1; |
| 509 |
mutex_unlock(&trout_backlight_lock); |
| 510 |
client_data->remote_write(client_data, 0, SYSCLKENA); |
| 511 |
client_data->remote_write(client_data, 1, DPSUS); |
| 512 |
return ret; |
| 513 |
} |
| 514 |
|
| 515 |
static int trout_brightness_set(struct backlight_device *bd) |
| 516 |
{ |
| 517 |
int intensity; |
| 518 |
mutex_lock(&trout_backlight_lock); |
| 519 |
intensity = bd->props.brightness; |
| 520 |
|
| 521 |
/* remember last backlight level as requested by user */ |
| 522 |
trout_backlight_resume_level = intensity; |
| 523 |
|
| 524 |
if(!trout_backlight_off) |
| 525 |
trout_set_backlight_level(intensity); |
| 526 |
mutex_unlock(&trout_backlight_lock); |
| 527 |
return 0; |
| 528 |
} |
| 529 |
|
| 530 |
static int trout_backlight_get_brightness(struct backlight_device *bd){ |
| 531 |
return bd->props.brightness; |
| 532 |
} |
| 533 |
|
| 534 |
static struct backlight_ops trout_backlight_ops = { |
| 535 |
.options = BL_CORE_SUSPENDRESUME, |
| 536 |
.update_status = trout_brightness_set, |
| 537 |
.get_brightness = trout_backlight_get_brightness, |
| 538 |
}; |
| 539 |
|
| 540 |
static int trout_backlight_probe(struct platform_device *pdev) |
| 541 |
{ |
| 542 |
struct backlight_device *bd; |
| 543 |
bd = backlight_device_register("trout-backlight", &pdev->dev, NULL, &trout_backlight_ops); |
| 544 |
bd->props.max_brightness = TROUT_DEFAULT_BACKLIGHT_BRIGHTNESS; |
| 545 |
bd->props.brightness = TROUT_DEFAULT_BACKLIGHT_BRIGHTNESS; |
| 546 |
trout_brightness_set(bd); |
| 547 |
return 0; |
| 548 |
} |
| 549 |
|
| 550 |
static int trout_backlight_remove(struct platform_device *pdev) |
| 551 |
{ |
| 552 |
struct backlight_device *bl = platform_get_drvdata(pdev); |
| 553 |
backlight_device_unregister(bl); |
| 554 |
return 0; |
| 555 |
} |
| 556 |
|
| 557 |
static struct platform_driver trout_backlight_driver = { |
| 558 |
.probe = trout_backlight_probe, |
| 559 |
.remove = trout_backlight_remove, |
| 560 |
.driver = { |
| 561 |
.name = "trout-backlight", |
| 562 |
.owner = THIS_MODULE, |
| 563 |
}, |
| 564 |
}; |
| 565 |
|
| 566 |
static struct resource resources_msm_fb[] = { |
| 567 |
{ |
| 568 |
.start = MSM_FB_BASE, |
| 569 |
.end = MSM_FB_BASE + MSM_FB_SIZE, |
| 570 |
.flags = IORESOURCE_MEM, |
| 571 |
}, |
| 572 |
}; |
| 573 |
|
| 574 |
struct msm_mddi_bridge_platform_data toshiba_client_data = { |
| 575 |
.init = trout_mddi_toshiba_client_init, |
| 576 |
.uninit = trout_mddi_toshiba_client_uninit, |
| 577 |
.blank = trout_mddi_panel_blank, |
| 578 |
.unblank = trout_mddi_panel_unblank, |
| 579 |
.fb_data = { |
| 580 |
.xres = 320, |
| 581 |
.yres = 480, |
| 582 |
.width = 45, |
| 583 |
.height = 67, |
| 584 |
.output_format = 0, |
| 585 |
}, |
| 586 |
}; |
| 587 |
|
| 588 |
static struct msm_mddi_platform_data mddi_pdata = { |
| 589 |
.clk_rate = 122880000, |
| 590 |
.power_client = trout_mddi_power_client, |
| 591 |
.fb_resource = resources_msm_fb, |
| 592 |
.num_clients = 1, |
| 593 |
.client_platform_data = { |
| 594 |
{ |
| 595 |
.product_id = (0xd263 << 16 | 0), |
| 596 |
.name = "mddi_c_d263_0000", |
| 597 |
//.name = "mddi_c_dummy", |
| 598 |
.id = 0, |
| 599 |
.client_data = &toshiba_client_data, |
| 600 |
//.client_data = &toshiba_client_data.fb_data, |
| 601 |
.clk_rate = 0, |
| 602 |
}, |
| 603 |
}, |
| 604 |
}; |
| 605 |
|
| 606 |
static struct platform_device trout_backlight = { |
| 607 |
.name = "trout-backlight", |
| 608 |
}; |
| 609 |
|
| 610 |
int __init trout_init_panel(void) |
| 611 |
{ |
| 612 |
int rc; |
| 613 |
|
| 614 |
if (!machine_is_trout()) |
| 615 |
return 0; |
| 616 |
vreg_mddi_1v5 = vreg_get(0, "gp2"); |
| 617 |
if (IS_ERR(vreg_mddi_1v5)) |
| 618 |
return PTR_ERR(vreg_mddi_1v5); |
| 619 |
vreg_lcm_2v85 = vreg_get(0, "gp4"); |
| 620 |
if (IS_ERR(vreg_lcm_2v85)) |
| 621 |
return PTR_ERR(vreg_lcm_2v85); |
| 622 |
|
| 623 |
trout_new_backlight = system_rev >= 5; |
| 624 |
if (trout_new_backlight) { |
| 625 |
uint32_t config = PCOM_GPIO_CFG(27, 0, GPIO_OUTPUT, |
| 626 |
GPIO_NO_PULL, GPIO_8MA); |
| 627 |
msm_proc_comm(PCOM_RPC_GPIO_TLMM_CONFIG_EX, &config, 0); |
| 628 |
} |
| 629 |
else { |
| 630 |
uint32_t config = PCOM_GPIO_CFG(27, 1, GPIO_OUTPUT, |
| 631 |
GPIO_NO_PULL, GPIO_8MA); |
| 632 |
msm_proc_comm(PCOM_RPC_GPIO_TLMM_CONFIG_EX, &config, 0); |
| 633 |
|
| 634 |
gp_clk = clk_get(NULL, "gp_clk"); |
| 635 |
if (IS_ERR(gp_clk)) { |
| 636 |
printk(KERN_ERR "trout_init_panel: could not get gp" |
| 637 |
"clock\n"); |
| 638 |
gp_clk = NULL; |
| 639 |
} |
| 640 |
rc = clk_set_rate(gp_clk, 19200000); |
| 641 |
if (rc) |
| 642 |
printk(KERN_ERR "trout_init_panel: set clock rate " |
| 643 |
"failed\n"); |
| 644 |
} |
| 645 |
|
| 646 |
rc = platform_device_register(&msm_device_mdp); |
| 647 |
if (rc) |
| 648 |
return rc; |
| 649 |
msm_device_mddi0.dev.platform_data = &mddi_pdata; |
| 650 |
rc = platform_device_register(&msm_device_mddi0); |
| 651 |
if (rc) |
| 652 |
return rc; |
| 653 |
platform_device_register(&trout_backlight); |
| 654 |
return platform_driver_register(&trout_backlight_driver); |
| 655 |
} |
| 656 |
|
| 657 |
device_initcall(trout_init_panel); |