blob: c1fef3122cfbb80626da44fe1cfdede836b70ffd [file] [log] [blame]
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -07001/*
2 * Copyright (c) 2007, Google Inc.
3 * All rights reserved.
4 *
Duy Truongf3ac7b32013-02-13 01:07:28 -08005 * Copyright (c) 2009-2011, The Linux Foundation. All rights reserved.
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -07006 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
Duy Truongf3ac7b32013-02-13 01:07:28 -080016 * * Neither the name of The Linux Foundation nor
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -070017 * the names of its contributors may be used to endorse or promote
18 * products derived from this software without specific prior written
19 * permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
28 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 */
34
35#include <debug.h>
36#include <dev/gpio.h>
37#include <kernel/thread.h>
Subbaraman Narayanamurthy2a8fd542010-10-27 15:45:18 -070038#include "gpio_hw.h"
Wentao Xu97df7fd2011-01-19 15:01:17 -050039#include "panel.h"
40#include <platform/machtype.h>
41#include <dev/lcdc.h>
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -070042
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -070043static int display_common_power(int);
44
45#if DISPLAY_TYPE_MDDI
46#include <mddi.h>
47
48#define MDDI_CLIENT_CORE_BASE 0x108000
49#define LCD_CONTROL_BLOCK_BASE 0x110000
50#define SPI_BLOCK_BASE 0x120000
51#define I2C_BLOCK_BASE 0x130000
52#define PWM_BLOCK_BASE 0x140000
53#define GPIO_BLOCK_BASE 0x150000
54#define SYSTEM_BLOCK1_BASE 0x160000
55#define SYSTEM_BLOCK2_BASE 0x170000
56
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -070057#define MDDICAP0 (MDDI_CLIENT_CORE_BASE|0x00)
58#define MDDICAP1 (MDDI_CLIENT_CORE_BASE|0x04)
59#define MDDICAP2 (MDDI_CLIENT_CORE_BASE|0x08)
60#define MDDICAP3 (MDDI_CLIENT_CORE_BASE|0x0C)
61#define MDCAPCHG (MDDI_CLIENT_CORE_BASE|0x10)
62#define MDCRCERC (MDDI_CLIENT_CORE_BASE|0x14)
63#define TTBUSSEL (MDDI_CLIENT_CORE_BASE|0x18)
64#define DPSET0 (MDDI_CLIENT_CORE_BASE|0x1C)
65#define DPSET1 (MDDI_CLIENT_CORE_BASE|0x20)
66#define DPSUS (MDDI_CLIENT_CORE_BASE|0x24)
67#define DPRUN (MDDI_CLIENT_CORE_BASE|0x28)
68#define SYSCKENA (MDDI_CLIENT_CORE_BASE|0x2C)
69#define TESTMODE (MDDI_CLIENT_CORE_BASE|0x30)
70#define FIFOMONI (MDDI_CLIENT_CORE_BASE|0x34)
71#define INTMONI (MDDI_CLIENT_CORE_BASE|0x38)
72#define MDIOBIST (MDDI_CLIENT_CORE_BASE|0x3C)
73#define MDIOPSET (MDDI_CLIENT_CORE_BASE|0x40)
74#define BITMAP0 (MDDI_CLIENT_CORE_BASE|0x44)
75#define BITMAP1 (MDDI_CLIENT_CORE_BASE|0x48)
76#define BITMAP2 (MDDI_CLIENT_CORE_BASE|0x4C)
77#define BITMAP3 (MDDI_CLIENT_CORE_BASE|0x50)
78#define BITMAP4 (MDDI_CLIENT_CORE_BASE|0x54)
79
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -070080#define SRST (LCD_CONTROL_BLOCK_BASE|0x00)
81#define PORT_ENB (LCD_CONTROL_BLOCK_BASE|0x04)
82#define START (LCD_CONTROL_BLOCK_BASE|0x08)
83#define PORT (LCD_CONTROL_BLOCK_BASE|0x0C)
84#define CMN (LCD_CONTROL_BLOCK_BASE|0x10)
85#define GAMMA (LCD_CONTROL_BLOCK_BASE|0x14)
86#define INTFLG (LCD_CONTROL_BLOCK_BASE|0x18)
87#define INTMSK (LCD_CONTROL_BLOCK_BASE|0x1C)
88#define MPLFBUF (LCD_CONTROL_BLOCK_BASE|0x20)
89#define HDE_LEFT (LCD_CONTROL_BLOCK_BASE|0x24)
90#define VDE_TOP (LCD_CONTROL_BLOCK_BASE|0x28)
91
92#define PXL (LCD_CONTROL_BLOCK_BASE|0x30)
93#define HCYCLE (LCD_CONTROL_BLOCK_BASE|0x34)
94#define HSW (LCD_CONTROL_BLOCK_BASE|0x38)
95#define HDE_START (LCD_CONTROL_BLOCK_BASE|0x3C)
96#define HDE_SIZE (LCD_CONTROL_BLOCK_BASE|0x40)
97#define VCYCLE (LCD_CONTROL_BLOCK_BASE|0x44)
98#define VSW (LCD_CONTROL_BLOCK_BASE|0x48)
99#define VDE_START (LCD_CONTROL_BLOCK_BASE|0x4C)
100#define VDE_SIZE (LCD_CONTROL_BLOCK_BASE|0x50)
101#define WAKEUP (LCD_CONTROL_BLOCK_BASE|0x54)
102#define WSYN_DLY (LCD_CONTROL_BLOCK_BASE|0x58)
103#define REGENB (LCD_CONTROL_BLOCK_BASE|0x5C)
104#define VSYNIF (LCD_CONTROL_BLOCK_BASE|0x60)
105#define WRSTB (LCD_CONTROL_BLOCK_BASE|0x64)
106#define RDSTB (LCD_CONTROL_BLOCK_BASE|0x68)
107#define ASY_DATA (LCD_CONTROL_BLOCK_BASE|0x6C)
108#define ASY_DATB (LCD_CONTROL_BLOCK_BASE|0x70)
109#define ASY_DATC (LCD_CONTROL_BLOCK_BASE|0x74)
110#define ASY_DATD (LCD_CONTROL_BLOCK_BASE|0x78)
111#define ASY_DATE (LCD_CONTROL_BLOCK_BASE|0x7C)
112#define ASY_DATF (LCD_CONTROL_BLOCK_BASE|0x80)
113#define ASY_DATG (LCD_CONTROL_BLOCK_BASE|0x84)
114#define ASY_DATH (LCD_CONTROL_BLOCK_BASE|0x88)
115#define ASY_CMDSET (LCD_CONTROL_BLOCK_BASE|0x8C)
116
117#define MONI (LCD_CONTROL_BLOCK_BASE|0xB0)
118
119#define Current (LCD_CONTROL_BLOCK_BASE|0xC0)
120#define LCD (LCD_CONTROL_BLOCK_BASE|0xC4)
121#define COMMAND (LCD_CONTROL_BLOCK_BASE|0xC8)
122
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700123#define SSICTL (SPI_BLOCK_BASE|0x00)
124#define SSITIME (SPI_BLOCK_BASE|0x04)
125#define SSITX (SPI_BLOCK_BASE|0x08)
126#define SSIRX (SPI_BLOCK_BASE|0x0C)
127#define SSIINTC (SPI_BLOCK_BASE|0x10)
128#define SSIINTS (SPI_BLOCK_BASE|0x14)
129#define SSIDBG1 (SPI_BLOCK_BASE|0x18)
130#define SSIDBG2 (SPI_BLOCK_BASE|0x1C)
131#define SSIID (SPI_BLOCK_BASE|0x20)
132
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700133#define I2CSETUP (I2C_BLOCK_BASE|0x00)
134#define I2CCTRL (I2C_BLOCK_BASE|0x04)
135
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700136#define TIMER0LOAD (PWM_BLOCK_BASE|0x00)
137#define TIMER0VALUE (PWM_BLOCK_BASE|0x04)
138#define TIMER0CONTROL (PWM_BLOCK_BASE|0x08)
139#define TIMER0INTCLR (PWM_BLOCK_BASE|0x0C)
140#define TIMER0RIS (PWM_BLOCK_BASE|0x10)
141#define TIMER0MIS (PWM_BLOCK_BASE|0x14)
142#define TIMER0BGLOAD (PWM_BLOCK_BASE|0x18)
143#define PWM0OFF (PWM_BLOCK_BASE|0x1C)
144#define TIMER1LOAD (PWM_BLOCK_BASE|0x20)
145#define TIMER1VALUE (PWM_BLOCK_BASE|0x24)
146#define TIMER1CONTROL (PWM_BLOCK_BASE|0x28)
147#define TIMER1INTCLR (PWM_BLOCK_BASE|0x2C)
148#define TIMER1RIS (PWM_BLOCK_BASE|0x30)
149#define TIMER1MIS (PWM_BLOCK_BASE|0x34)
150#define TIMER1BGLOAD (PWM_BLOCK_BASE|0x38)
151#define PWM1OFF (PWM_BLOCK_BASE|0x3C)
152#define TIMERITCR (PWM_BLOCK_BASE|0x60)
153#define TIMERITOP (PWM_BLOCK_BASE|0x64)
154#define PWMCR (PWM_BLOCK_BASE|0x68)
155#define PWMID (PWM_BLOCK_BASE|0x6C)
156#define PWMMON (PWM_BLOCK_BASE|0x70)
157
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700158#define GPIODATA (GPIO_BLOCK_BASE|0x00)
159#define GPIODIR (GPIO_BLOCK_BASE|0x04)
160#define GPIOIS (GPIO_BLOCK_BASE|0x08)
161#define GPIOIBE (GPIO_BLOCK_BASE|0x0C)
162#define GPIOIEV (GPIO_BLOCK_BASE|0x10)
163#define GPIOIE (GPIO_BLOCK_BASE|0x14)
164#define GPIORIS (GPIO_BLOCK_BASE|0x18)
165#define GPIOMIS (GPIO_BLOCK_BASE|0x1C)
166#define GPIOIC (GPIO_BLOCK_BASE|0x20)
167#define GPIOOMS (GPIO_BLOCK_BASE|0x24)
168#define GPIOPC (GPIO_BLOCK_BASE|0x28)
169
170#define GPIOID (GPIO_BLOCK_BASE|0x30)
171
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700172#define WKREQ (SYSTEM_BLOCK1_BASE|0x00)
173#define CLKENB (SYSTEM_BLOCK1_BASE|0x04)
174#define DRAMPWR (SYSTEM_BLOCK1_BASE|0x08)
175#define INTMASK (SYSTEM_BLOCK1_BASE|0x0C)
176#define CNT_DIS (SYSTEM_BLOCK1_BASE|0x10)
177#define GPIOSEL (SYSTEM_BLOCK2_BASE|0x00)
178
179struct init_table {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800180 unsigned int reg;
181 unsigned int val;
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700182};
183
184static struct init_table toshiba_480x800_init_table[] = {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800185 {DPSET0, 0x4BEC0066}, // # MDC.DPSET0 # Setup DPLL parameters
186 {DPSET1, 0x00000113}, // # MDC.DPSET1
187 {DPSUS, 0x00000000}, // # MDC.DPSUS # Set DPLL oscillation enable
188 {DPRUN, 0x00000001}, // # MDC.DPRUN # Release reset signal for DPLL
189 {0, 15}, // wait_ms(15);
190 {SYSCKENA, 0x00000001}, // # MDC.SYSCKENA # Enable system clock output
191 {CLKENB, 0x000000E9}, // # SYS.CLKENB # Enable clocks for each module (without DCLK , i2cCLK)
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700192
Ajay Dudanib01e5062011-12-03 23:23:42 -0800193 {GPIO_BLOCK_BASE, 0x03FF0000}, // # GPI .GPIODATA # GPIO2(RESET_LCD_N) set to 0 , GPIO3(eDRAM_Power) set to 0
194 {GPIODIR, 0x0000024D}, // # GPI .GPIODIR # Select direction of GPIO port (0,2,3,6,9 output)
195 {SYSTEM_BLOCK2_BASE, 0x00000173}, // # SYS.GPIOSEL # GPIO port multiplexing control
196 {GPIOPC, 0x03C300C0}, // # GPI .GPIOPC # GPIO2,3 PD cut
197 {SYSTEM_BLOCK1_BASE, 0x00000000}, // # SYS.WKREQ # Wake-up request event is VSYNC alignment
198 {GPIOIS, 0x00000000}, // # GPI .GPIOIS # Set interrupt sense of GPIO
199 {GPIOIEV, 0x00000001}, // # GPI .GPIOIEV # Set interrupt event of GPIO
200 {GPIOIC, 0x000003FF}, // # GPI .GPIOIC # GPIO interrupt clear
201 {GPIO_BLOCK_BASE, 0x00040004}, // # GPI .GPIODATA # Release LCDD reset
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700202
Ajay Dudanib01e5062011-12-03 23:23:42 -0800203 {GPIO_BLOCK_BASE, 0x00080008}, // # GPI .GPIODATA # eDRAM VD supply
204 {DRAMPWR, 0x00000001}, // # SYS.DRAMPWR # eDRAM power up
205 {CLKENB, 0x000000EB}, // # enable eDRAM clock
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700206
Ajay Dudanib01e5062011-12-03 23:23:42 -0800207 {PWMCR, 0x00000000}, // # PWM.PWMCR # PWM output enable
208 {0, 1}, // wait_ms(1);
209 {SPI_BLOCK_BASE, 0x00060399}, // # SPI .SSICTL # SPI operation mode setting
210 {SSITIME, 0x00000100}, // # SPI .SSITIME # SPI serial interface timing setting
211 {CNT_DIS, 0x00000002}, // # SPI .SSITIME # SPI serial interface timing setting
212 {SPI_BLOCK_BASE, 0x0006039B}, // # SPI .SSICTL # Set SPI active mode
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700213
Ajay Dudanib01e5062011-12-03 23:23:42 -0800214 {SSITX, 0x00000000}, // # SPI.SSITX # Release from Deep Stanby mode
215 {0, 7}, // wait_ms(2);
216 {SSITX, 0x00000000}, // # SPI.SSITX
217 {0, 7}, // wait_ms(2);
218 {SSITX, 0x00000000}, // # SPI.SSITX
219 {0, 7}, // wait_ms(2);
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700220
Ajay Dudanib01e5062011-12-03 23:23:42 -0800221 {SSITX, 0x000800BA}, // # SPI.SSITX *NOTE 1 # Command setting of SPI block
222 {SSITX, 0x00000111}, // # Display mode setup(1) : Normaly Black
223 {SSITX, 0x00080036}, // # Command setting of SPI block
224 {SSITX, 0x00000100}, // # Memory access control
225 {0, 2}, // wait_ms(2); // # Wait SPI fifo empty
226 {SSITX, 0x0008003A}, // # Command setting of SPI block
227 {SSITX, 0x00000160}, // # Display mode setup(2)
228 {SSITX, 0x000800B1}, // # Command setting of SPI block
229 {SSITX, 0x0000015D}, // # RGB Interface data format
230 {0, 2}, // wait_ms(2); // # Wait SPI fifo empty
231 {SSITX, 0x000800B2}, // # Command setting of SPI block
232 {SSITX, 0x00000133}, // # Drivnig method
233 {SSITX, 0x000800B3}, // # Command setting of SPI block
234 {SSITX, 0x00000122}, // # Booster operation setup
235 {0, 2}, // wait_ms(2); // # Wait SPI fifo empty
236 {SSITX, 0x000800B4}, // # Command setting of SPI block
237 {SSITX, 0x00000102}, // # OP-amp capability/System clock freq. division setup
238 {SSITX, 0x000800B5}, // # Command setting of SPI block
239 {SSITX, 0x0000011E}, // # VCS Voltage adjustment (1C->1F for Rev 2)
240 {0, 2}, // wait_ms(2); // # Wait SPI fifo empty
241 {SSITX, 0x000800B6}, // # Command setting of SPI block
242 {SSITX, 0x00000127}, // # VCOM Voltage adjustment
243 {SSITX, 0x000800B7}, // # Command setting of SPI block
244 {SSITX, 0x00000103}, // # Configure an external display signal
245 {0, 2}, // wait_ms(2); // # Wait SPI fifo empty
246 {SSITX, 0x000800B9}, // # Command setting of SPI block
247 {SSITX, 0x00000124}, // # DCCK/DCEV timing setup
248 {SSITX, 0x000800BD}, // # Command setting of SPI block
249 {SSITX, 0x000001A1}, // # ASW signal control
250 {0, 2}, // wait_ms(2); // # Wait SPI fifo empty
251 {SSITX, 0x000800BB}, // # Command setting of SPI block
252 {SSITX, 0x00000100}, // # Dummy display (white/black) count setup for QUAD Data operation
253 {SSITX, 0x000800BF}, // # Command setting of SPI block
254 {SSITX, 0x00000101}, // # Dummy display (white/black) count setup for QUAD Data operation
255 {0, 2}, // wait_ms(2); // # Wait SPI fifo empty
256 {SSITX, 0x000800BE}, // # Command setting of SPI block
257 {SSITX, 0x00000100}, // # wait_ms(-out FR count setup (A)
258 {SSITX, 0x000800C0}, // # Command setting of SPI block
259 {SSITX, 0x00000111}, // # wait_ms(-out FR count setup (A)
260 {0, 2}, // wait_ms(2); // # Wait SPI fifo empty
261 {SSITX, 0x000800C1}, // # Command setting of SPI block
262 {SSITX, 0x00000111}, // # wait_ms(-out FR count setup (B)
263 {SSITX, 0x000800C2}, // # Command setting of SPI block
264 {SSITX, 0x00000111}, // # wait_ms(-out FR count setup (C)
265 {0, 2}, // wait_ms(2); // # Wait SPI fifo empty
266 {SSITX, 0x000800C3}, // # Command setting of SPI block
267 {SSITX, 0x00080132}, // # wait_ms(-in line clock count setup (D)
268 {SSITX, 0x00000132}, //
269 {0, 2}, // wait_ms(2); // # Wait SPI fifo empty
270 {SSITX, 0x000800C4}, // # Command setting of SPI block
271 {SSITX, 0x00080132}, // # Seep-in line clock count setup (E)
272 {SSITX, 0x00000132}, //
273 {0, 2}, // wait_ms(2); // # Wait SPI fifo empty
274 {SSITX, 0x000800C5}, // # Command setting of SPI block
275 {SSITX, 0x00080132}, // # wait_ms(-in line clock count setup (F)
276 {SSITX, 0x00000132}, //
277 {0, 2}, // wait_ms(2); // # Wait SPI fifo empty
278 {SSITX, 0x000800C6}, // # Command setting of SPI block
279 {SSITX, 0x00080132}, // # wait_ms(-in line clock setup (G)
280 {SSITX, 0x00000132}, //
281 {0, 2}, // wait_ms(2); // # Wait SPI fifo empty
282 {SSITX, 0x000800C7}, // # Command setting of SPI block
283 {SSITX, 0x00080164}, // # Gamma 1 fine tuning (1)
284 {SSITX, 0x00000145}, //
285 {0, 2}, // wait_ms(2); // # Wait SPI fifo empty
286 {SSITX, 0x000800C8}, // # Command setting of SPI block
287 {SSITX, 0x00000144}, // # Gamma 1 fine tuning (2)
288 {SSITX, 0x000800C9}, // # Command setting of SPI block
289 {SSITX, 0x00000152}, // # Gamma 1 inclination adjustment
290 {0, 2}, // wait_ms(2); // # Wait SPI fifo empty
291 {SSITX, 0x000800CA}, // # Command setting of SPI block
292 {SSITX, 0x00000100}, // # Gamma 1 blue offset adjustment
293 {0, 2}, // wait_ms(2); // # Wait SPI fifo empty
294 {SSITX, 0x000800EC}, // # Command setting of SPI block
295 {SSITX, 0x00080102}, // # Total number of horizontal clock cycles (1) [PCLK Sync. VGA setting]
296 {SSITX, 0x00000118}, //
297 {0, 2}, // wait_ms(2); // # Wait SPI fifo empty
298 {SSITX, 0x000800CF}, // # Command setting of SPI block
299 {SSITX, 0x00000101}, // # Blanking period control (1) [PCLK Sync. Table1 for VGA]
300 {0, 2}, // wait_ms(2); // # Wait SPI fifo empty
301 {SSITX, 0x000800D0}, // # Command setting of SPI block
302 {SSITX, 0x00080110}, // # Blanking period control (2) [PCLK Sync. Table1 for VGA]
303 {SSITX, 0x00000104}, //
304 {0, 2}, // wait_ms(2); // # Wait SPI fifo empty
305 {SSITX, 0x000800D1}, // # Command setting of SPI block
306 {SSITX, 0x00000101}, // # CKV timing control on/off [PCLK Sync. Table1 for VGA]
307 {0, 2}, // wait_ms(2); // # Wait SPI fifo empty
308 {SSITX, 0x000800D2}, // # Command setting of SPI block
309 {SSITX, 0x00080100}, // # CKV1,2 timing control [PCLK Sync. Table1 for VGA]
310 {SSITX, 0x00000128}, //
311 {0, 2}, // wait_ms(2); // # Wait SPI fifo empty
312 {SSITX, 0x000800D3}, // # Command setting of SPI block
313 {SSITX, 0x00080100}, // # OEV timing control [PCLK Sync. Table1 for VGA]
314 {SSITX, 0x00000128}, //
315 {0, 2}, // wait_ms(2); // # Wait SPI fifo empty
316 {SSITX, 0x000800D4}, // # Command setting of SPI block
317 {SSITX, 0x00080126}, // # ASW timing control (1) [PCLK Sync. Table1 for VGA]
318 {SSITX, 0x000001A4}, //
319 {0, 1}, // wait_ms(1); // # Wait SPI fifo empty
320 {SSITX, 0x000800D5}, // # Command setting of SPI block
321 {SSITX, 0x00000120}, // # ASW timing control (2) [PCLK Sync. Table1 for VGA]
322 {0, 2}, // wait_ms(2); // # Wait SPI fifo empty
323 {SSITX, 0x000800EF}, // # Command setting of SPI block
324 {SSITX, 0x00080132}, // # Total number of horizontal clock cycles (2) [PCLK Sync. Table1 for QVGA ]
325 {SSITX, 0x00000100}, //
326 {0, 2}, // wait_ms(2); // # Wait SPI fifo empty
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700327
Ajay Dudanib01e5062011-12-03 23:23:42 -0800328 {BITMAP0, 0x032001E0}, // MDC.BITMAP0 ); // Setup of PITCH size to Frame buffer1
329 {BITMAP1, 0x032001E0}, // MDC.BITMAP1 ); // Setup of PITCH size to Frame buffer1
330 {BITMAP2, 0x014000F0}, // MDC.BITMAP3 ); // Setup of PITCH size to Frame buffer2
331 {BITMAP3, 0x014000F0}, // MDC.BITMAP4 ); // Setup of PITCH size to Frame buffer3
332 {BITMAP4, 0x014000F0}, // MDC.BITMAP5 ); // Setup of PITCH size to Frame buffer4
333 {CLKENB, 0x000001EB}, // SYS.CLKENB ); // DCLK supply
334 {PORT_ENB, 0x00000001}, // LCD.PORT_ENB ); // Synchronous port enable
335 {PORT, 0x00000004}, // LCD.PORT ); // Polarity of DE is set to high active
336 {PXL, 0x00000002}, // LCD.PXL ); // ACTMODE 2 set (1st frame black data output)
337 {MPLFBUF, 0x00000000}, // LCD.MPLFBUF ); // Select the reading buffer
338 {HCYCLE, 0x0000010B}, // LCD.HCYCLE ); // Setup to VGA size
339 {HSW, 0x00000003}, // LCD.HSW
340 {HDE_START, 0x00000007}, // LCD.HDE_START
341 {HDE_SIZE, 0x000000EF}, // LCD.HDE_SIZE
342 {VCYCLE, 0x00000325}, // LCD.VCYCLE
343 {VSW, 0x00000001}, // LCD.VSW
344 {VDE_START, 0x00000003}, // LCD.VDE_START
345 {VDE_SIZE, 0x0000031F}, // LCD.VDE_SIZE
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700346
Ajay Dudanib01e5062011-12-03 23:23:42 -0800347 {START, 0x00000001}, // LCD.START ); // LCDC - Pixel data transfer start
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700348
Ajay Dudanib01e5062011-12-03 23:23:42 -0800349 {0, 10}, // wait_ms( 10 );
350 {SSITX, 0x000800BC}, // SPI.SSITX ); // Command setting of SPI block
351 {SSITX, 0x00000180}, // Display data setup
352 {SSITX, 0x0008003B}, // Command setting of SPI block
353 {SSITX, 0x00000100}, // Quad Data configuration - VGA
354 {0, 1}, // wait_ms( 1 ); // Wait SPI fifo empty
355 {SSITX, 0x000800B0}, // Command setting of SPI block
356 {SSITX, 0x00000116}, // Power supply ON/OFF control
357 {0, 1}, // wait_ms( 1 ); // Wait SPI fifo empty
358 {SSITX, 0x000800B8}, // Command setting of SPI block
359 {SSITX, 0x000801FF}, // Output control
360 {SSITX, 0x000001F5},
361 {0, 1}, // wait_ms( 1); // Wait SPI fifo empty
362 {SSITX, 0x00000011}, // wait_ms(-out (Command only)
363 {0, 5}, // wait_ms( 1); // Wait SPI fifo empty
364 {SSITX, 0x00000029}, // Display on (Command only)
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700365
Ajay Dudanib01e5062011-12-03 23:23:42 -0800366 //{ SYSTEM_BLOCK1_BASE, 0x00000002 }, // # wakeREQ -> GPIO
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700367
Ajay Dudanib01e5062011-12-03 23:23:42 -0800368 {0, 0}
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700369};
370
371void mddi_panel_poweron(void)
372{
Ajay Dudanib01e5062011-12-03 23:23:42 -0800373 display_common_power(1);
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700374}
375
376static void _panel_init(struct init_table *init_table)
377{
378 unsigned n;
379
380 dprintf(INFO, "panel_init()\n");
381
382 n = 0;
383 while (init_table[n].reg != 0 || init_table[n].val != 0) {
384 if (init_table[n].reg != 0)
385 mddi_remote_write(init_table[n].val, init_table[n].reg);
386 else
387 mdelay(init_table[n].val);
388 n++;
389 }
390
391 dprintf(INFO, "panel_init() done\n");
392}
393
394void panel_init(struct mddi_client_caps *client_caps)
395{
Ajay Dudanib01e5062011-12-03 23:23:42 -0800396 switch (client_caps->manufacturer_name) {
397 case 0xd263: // Toshiba
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700398 dprintf(INFO, "Found Toshiba panel\n");
399 _panel_init(toshiba_480x800_init_table);
400 break;
Ajay Dudanib01e5062011-12-03 23:23:42 -0800401 case 0x4474: //??
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700402 if (client_caps->product_code == 0xc065)
403 dprintf(INFO, "Found WVGA panel\n");
404 break;
405 }
406}
Ajay Dudanib01e5062011-12-03 23:23:42 -0800407#endif //mddi
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700408
409void panel_poweron(void)
410{
411#if DISPLAY_TYPE_LCDC
Ajay Dudanib01e5062011-12-03 23:23:42 -0800412 if (board_machtype() == LINUX_MACHTYPE_7x30_FLUID) {
Wentao Xu97df7fd2011-01-19 15:01:17 -0500413 sharp_lcdc_on();
Ajay Dudanib01e5062011-12-03 23:23:42 -0800414 } else {
Wentao Xu97df7fd2011-01-19 15:01:17 -0500415 panel_backlight(1);
416 lcdc_on();
417 }
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700418#endif
419}
420
421void panel_backlight(int on)
422{
Ajay Dudanib01e5062011-12-03 23:23:42 -0800423 unsigned char reg_data = 0xA0;
424 if (on)
425 pmic_write(0x132, reg_data);
426 else
427 pmic_write(0x132, 0);
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700428}
429
430static unsigned wega_reset_gpio =
431GPIO_CFG(180, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA);
432
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700433static int display_common_power(int on)
434{
Ajay Dudanib01e5062011-12-03 23:23:42 -0800435 int rc = 0, flag_on = !!on;
436 static int display_common_power_save_on;
437 unsigned int vreg_ldo12, vreg_ldo15, vreg_ldo20, vreg_ldo16, vreg_ldo8;
438 if (display_common_power_save_on == flag_on)
439 return 0;
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700440
Ajay Dudanib01e5062011-12-03 23:23:42 -0800441 display_common_power_save_on = flag_on;
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700442
Ajay Dudanib01e5062011-12-03 23:23:42 -0800443 if (on) {
444 /* reset Toshiba WeGA chip -- toggle reset pin -- gpio_180 */
445 rc = gpio_tlmm_config(wega_reset_gpio, GPIO_ENABLE);
446 if (rc) {
447 return rc;
448 }
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700449
Ajay Dudanib01e5062011-12-03 23:23:42 -0800450 gpio_set(180, 0); /* bring reset line low to hold reset */
451 }
452 // Set power for WEGA chip.
453 // Set LD020 to 1.5V
454 pmic_write(LDO20_CNTRL, 0x00 | LDO_LOCAL_EN_BMSK);
455 mdelay(5);
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700456
Ajay Dudanib01e5062011-12-03 23:23:42 -0800457 // Set LD012 to 1.8V
458 pmic_write(LDO12_CNTRL, 0x06 | LDO_LOCAL_EN_BMSK);
459 mdelay(5);
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700460
Ajay Dudanib01e5062011-12-03 23:23:42 -0800461 // Set LD016 to 2.6V
462 pmic_write(LDO16_CNTRL, 0x16 | LDO_LOCAL_EN_BMSK);
463 mdelay(5);
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700464
Ajay Dudanib01e5062011-12-03 23:23:42 -0800465 // Set LD015 to 3.0V
466 pmic_write(LDO15_CNTRL, 0x1E | LDO_LOCAL_EN_BMSK);
467 mdelay(5);
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700468
Ajay Dudanib01e5062011-12-03 23:23:42 -0800469 gpio_set(180, 1); /* bring reset line high */
470 mdelay(10); /* 10 msec before IO can be accessed */
471 if (rc) {
472 return rc;
473 }
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700474
Ajay Dudanib01e5062011-12-03 23:23:42 -0800475 return rc;
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700476}
477
478#if DISPLAY_TYPE_LCDC
479static struct msm_gpio lcd_panel_gpios[] = {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800480 {GPIO_CFG(45, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA), "spi_clk"},
481 {GPIO_CFG(46, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA), "spi_cs0"},
482 {GPIO_CFG(47, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA), "spi_mosi"},
483 {GPIO_CFG(48, 0, GPIO_INPUT, GPIO_NO_PULL, GPIO_2MA), "spi_miso"}
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700484};
485
486int lcdc_toshiba_panel_power(int on)
487{
Ajay Dudanib01e5062011-12-03 23:23:42 -0800488 int rc, i;
489 struct msm_gpio *gp;
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700490
Ajay Dudanib01e5062011-12-03 23:23:42 -0800491 rc = display_common_power(on);
492 if (rc < 0) {
493 return rc;
494 }
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700495
Ajay Dudanib01e5062011-12-03 23:23:42 -0800496 if (on) {
497 rc = platform_gpios_enable(lcd_panel_gpios,
498 ARRAY_SIZE(lcd_panel_gpios));
499 if (rc) {
500 return rc;
501 }
502 } else { /* off */
503 gp = lcd_panel_gpios;
504 for (i = 0; i < ARRAY_SIZE(lcd_panel_gpios); i++) {
505 /* ouput low */
506 gpio_set(GPIO_PIN(gp->gpio_cfg), 0);
507 gp++;
508 }
509 }
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700510
Ajay Dudanib01e5062011-12-03 23:23:42 -0800511 return rc;
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700512}
513
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700514static void toshiba_spi_write_byte(char dc, unsigned char data)
515{
Ajay Dudanib01e5062011-12-03 23:23:42 -0800516 unsigned bit;
517 int bnum;
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700518
Ajay Dudanib01e5062011-12-03 23:23:42 -0800519 gpio_set(SPI_SCLK, 0); /* clk low */
520 /* dc: 0 for command, 1 for parameter */
521 gpio_set(SPI_MOSI, dc);
522 mdelay(1); /* at least 20 ns */
523 gpio_set(SPI_SCLK, 1); /* clk high */
524 mdelay(1); /* at least 20 ns */
525 bnum = 8; /* 8 data bits */
526 bit = 0x80;
527 while (bnum) {
528 gpio_set(SPI_SCLK, 0); /* clk low */
529 if (data & bit)
530 gpio_set(SPI_MOSI, 1);
531 else
532 gpio_set(SPI_MOSI, 0);
533 mdelay(1);
534 gpio_set(SPI_SCLK, 1); /* clk high */
535 mdelay(1);
536 bit >>= 1;
537 bnum--;
538 }
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700539}
540
Ajay Dudanib01e5062011-12-03 23:23:42 -0800541static int toshiba_spi_write(char cmd, unsigned data, int num)
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700542{
Ajay Dudanib01e5062011-12-03 23:23:42 -0800543 char *bp;
544 gpio_set(SPI_CS, 1); /* cs high */
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700545
Ajay Dudanib01e5062011-12-03 23:23:42 -0800546 /* command byte first */
547 toshiba_spi_write_byte(0, cmd);
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700548
Ajay Dudanib01e5062011-12-03 23:23:42 -0800549 /* followed by parameter bytes */
550 if (num) {
551 bp = (char *)&data;;
552 bp += (num - 1);
553 while (num) {
554 toshiba_spi_write_byte(1, *bp);
555 num--;
556 bp--;
557 }
558 }
559 gpio_set(SPI_CS, 0); /* cs low */
560 mdelay(1);
561 return 0;
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700562}
563
Ajay Dudanib01e5062011-12-03 23:23:42 -0800564void lcdc_disp_on(void)
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700565{
Ajay Dudanib01e5062011-12-03 23:23:42 -0800566 gpio_set(SPI_CS, 0); /* low */
567 gpio_set(SPI_SCLK, 1); /* high */
568 gpio_set(SPI_MOSI, 0);
569 gpio_set(SPI_MISO, 0);
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700570
Ajay Dudanib01e5062011-12-03 23:23:42 -0800571 if (1) {
572 toshiba_spi_write(0, 0, 0);
573 mdelay(7);
574 toshiba_spi_write(0, 0, 0);
575 mdelay(7);
576 toshiba_spi_write(0, 0, 0);
577 mdelay(7);
578 toshiba_spi_write(0xba, 0x11, 1);
579 toshiba_spi_write(0x36, 0x00, 1);
580 mdelay(1);
581 toshiba_spi_write(0x3a, 0x60, 1);
582 toshiba_spi_write(0xb1, 0x5d, 1);
583 mdelay(1);
584 toshiba_spi_write(0xb2, 0x33, 1);
585 toshiba_spi_write(0xb3, 0x22, 1);
586 mdelay(1);
587 toshiba_spi_write(0xb4, 0x02, 1);
588 toshiba_spi_write(0xb5, 0x1e, 1); /* vcs -- adjust brightness */
589 mdelay(1);
590 toshiba_spi_write(0xb6, 0x27, 1);
591 toshiba_spi_write(0xb7, 0x03, 1);
592 mdelay(1);
593 toshiba_spi_write(0xb9, 0x24, 1);
594 toshiba_spi_write(0xbd, 0xa1, 1);
595 mdelay(1);
596 toshiba_spi_write(0xbb, 0x00, 1);
597 toshiba_spi_write(0xbf, 0x01, 1);
598 mdelay(1);
599 toshiba_spi_write(0xbe, 0x00, 1);
600 toshiba_spi_write(0xc0, 0x11, 1);
601 mdelay(1);
602 toshiba_spi_write(0xc1, 0x11, 1);
603 toshiba_spi_write(0xc2, 0x11, 1);
604 mdelay(1);
605 toshiba_spi_write(0xc3, 0x3232, 2);
606 mdelay(1);
607 toshiba_spi_write(0xc4, 0x3232, 2);
608 mdelay(1);
609 toshiba_spi_write(0xc5, 0x3232, 2);
610 mdelay(1);
611 toshiba_spi_write(0xc6, 0x3232, 2);
612 mdelay(1);
613 toshiba_spi_write(0xc7, 0x6445, 2);
614 mdelay(1);
615 toshiba_spi_write(0xc8, 0x44, 1);
616 toshiba_spi_write(0xc9, 0x52, 1);
617 mdelay(1);
618 toshiba_spi_write(0xca, 0x00, 1);
619 mdelay(1);
620 toshiba_spi_write(0xec, 0x02a4, 2); /* 0x02a4 */
621 mdelay(1);
622 toshiba_spi_write(0xcf, 0x01, 1);
623 mdelay(1);
624 toshiba_spi_write(0xd0, 0xc003, 2); /* c003 */
625 mdelay(1);
626 toshiba_spi_write(0xd1, 0x01, 1);
627 mdelay(1);
628 toshiba_spi_write(0xd2, 0x0028, 2);
629 mdelay(1);
630 toshiba_spi_write(0xd3, 0x0028, 2);
631 mdelay(1);
632 toshiba_spi_write(0xd4, 0x26a4, 2);
633 mdelay(1);
634 toshiba_spi_write(0xd5, 0x20, 1);
635 mdelay(1);
636 toshiba_spi_write(0xef, 0x3200, 2);
637 mdelay(32);
638 toshiba_spi_write(0xbc, 0x80, 1); /* wvga pass through */
639 toshiba_spi_write(0x3b, 0x00, 1);
640 mdelay(1);
641 toshiba_spi_write(0xb0, 0x16, 1);
642 mdelay(1);
643 toshiba_spi_write(0xb8, 0xfff5, 2);
644 mdelay(1);
645 toshiba_spi_write(0x11, 0, 0);
646 mdelay(5);
647 toshiba_spi_write(0x29, 0, 0);
648 mdelay(5);
649 }
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700650}
651
652void lcdc_on(void)
653{
Ajay Dudanib01e5062011-12-03 23:23:42 -0800654 lcdc_toshiba_panel_power(1);
655 lcdc_disp_on();
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700656}
657
Wentao Xu97df7fd2011-01-19 15:01:17 -0500658struct lcdc_timing_parameters *get_lcd_timing(void)
659{
Ajay Dudanib01e5062011-12-03 23:23:42 -0800660 if (board_machtype() == LINUX_MACHTYPE_7x30_FLUID) {
Wentao Xu97df7fd2011-01-19 15:01:17 -0500661 return sharp_timing_param();
Ajay Dudanib01e5062011-12-03 23:23:42 -0800662 } else {
Wentao Xu97df7fd2011-01-19 15:01:17 -0500663 return DEFAULT_LCD_TIMING;
664 }
665}
666
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700667#endif