aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-shmobile/board-ag5evm.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-shmobile/board-ag5evm.c')
-rw-r--r--arch/arm/mach-shmobile/board-ag5evm.c198
1 files changed, 106 insertions, 92 deletions
diff --git a/arch/arm/mach-shmobile/board-ag5evm.c b/arch/arm/mach-shmobile/board-ag5evm.c
index 25eb88a923e6..032d10817e79 100644
--- a/arch/arm/mach-shmobile/board-ag5evm.c
+++ b/arch/arm/mach-shmobile/board-ag5evm.c
@@ -213,95 +213,6 @@ static struct platform_device irda_device = {
213 .num_resources = ARRAY_SIZE(irda_resources), 213 .num_resources = ARRAY_SIZE(irda_resources),
214}; 214};
215 215
216static unsigned char lcd_backlight_seq[3][2] = {
217 { 0x04, 0x07 },
218 { 0x23, 0x80 },
219 { 0x03, 0x01 },
220};
221
222static void lcd_backlight_on(void)
223{
224 struct i2c_adapter *a;
225 struct i2c_msg msg;
226 int k;
227
228 a = i2c_get_adapter(1);
229 for (k = 0; a && k < 3; k++) {
230 msg.addr = 0x6d;
231 msg.buf = &lcd_backlight_seq[k][0];
232 msg.len = 2;
233 msg.flags = 0;
234 if (i2c_transfer(a, &msg, 1) != 1)
235 break;
236 }
237}
238
239static void lcd_backlight_reset(void)
240{
241 gpio_set_value(GPIO_PORT235, 0);
242 mdelay(24);
243 gpio_set_value(GPIO_PORT235, 1);
244}
245
246/* LCDC0 */
247static const struct fb_videomode lcdc0_modes[] = {
248 {
249 .name = "R63302(QHD)",
250 .xres = 544,
251 .yres = 961,
252 .left_margin = 72,
253 .right_margin = 600,
254 .hsync_len = 16,
255 .upper_margin = 8,
256 .lower_margin = 8,
257 .vsync_len = 2,
258 .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_HOR_HIGH_ACT,
259 },
260};
261
262static struct sh_mobile_lcdc_info lcdc0_info = {
263 .clock_source = LCDC_CLK_PERIPHERAL,
264 .ch[0] = {
265 .chan = LCDC_CHAN_MAINLCD,
266 .interface_type = RGB24,
267 .clock_divider = 1,
268 .flags = LCDC_FLAGS_DWPOL,
269 .fourcc = V4L2_PIX_FMT_RGB565,
270 .lcd_modes = lcdc0_modes,
271 .num_modes = ARRAY_SIZE(lcdc0_modes),
272 .panel_cfg = {
273 .width = 44,
274 .height = 79,
275 .display_on = lcd_backlight_on,
276 .display_off = lcd_backlight_reset,
277 },
278 }
279};
280
281static struct resource lcdc0_resources[] = {
282 [0] = {
283 .name = "LCDC0",
284 .start = 0xfe940000, /* P4-only space */
285 .end = 0xfe943fff,
286 .flags = IORESOURCE_MEM,
287 },
288 [1] = {
289 .start = intcs_evt2irq(0x580),
290 .flags = IORESOURCE_IRQ,
291 },
292};
293
294static struct platform_device lcdc0_device = {
295 .name = "sh_mobile_lcdc_fb",
296 .num_resources = ARRAY_SIZE(lcdc0_resources),
297 .resource = lcdc0_resources,
298 .id = 0,
299 .dev = {
300 .platform_data = &lcdc0_info,
301 .coherent_dma_mask = ~0,
302 },
303};
304
305/* MIPI-DSI */ 216/* MIPI-DSI */
306static struct resource mipidsi0_resources[] = { 217static struct resource mipidsi0_resources[] = {
307 [0] = { 218 [0] = {
@@ -358,7 +269,7 @@ sh_mipi_set_dot_clock_pck_err:
358 269
359static struct sh_mipi_dsi_info mipidsi0_info = { 270static struct sh_mipi_dsi_info mipidsi0_info = {
360 .data_format = MIPI_RGB888, 271 .data_format = MIPI_RGB888,
361 .lcd_chan = &lcdc0_info.ch[0], 272 .channel = LCDC_CHAN_MAINLCD,
362 .lane = 2, 273 .lane = 2,
363 .vsynw_offset = 20, 274 .vsynw_offset = 20,
364 .clksrc = 1, 275 .clksrc = 1,
@@ -378,6 +289,109 @@ static struct platform_device mipidsi0_device = {
378 }, 289 },
379}; 290};
380 291
292static unsigned char lcd_backlight_seq[3][2] = {
293 { 0x04, 0x07 },
294 { 0x23, 0x80 },
295 { 0x03, 0x01 },
296};
297
298static int lcd_backlight_set_brightness(int brightness)
299{
300 struct i2c_adapter *adap;
301 struct i2c_msg msg;
302 unsigned int i;
303 int ret;
304
305 if (brightness == 0) {
306 /* Reset the chip */
307 gpio_set_value(GPIO_PORT235, 0);
308 mdelay(24);
309 gpio_set_value(GPIO_PORT235, 1);
310 return 0;
311 }
312
313 adap = i2c_get_adapter(1);
314 if (adap == NULL)
315 return -ENODEV;
316
317 for (i = 0; i < ARRAY_SIZE(lcd_backlight_seq); i++) {
318 msg.addr = 0x6d;
319 msg.buf = &lcd_backlight_seq[i][0];
320 msg.len = 2;
321 msg.flags = 0;
322
323 ret = i2c_transfer(adap, &msg, 1);
324 if (ret < 0)
325 break;
326 }
327
328 i2c_put_adapter(adap);
329 return ret < 0 ? ret : 0;
330}
331
332/* LCDC0 */
333static const struct fb_videomode lcdc0_modes[] = {
334 {
335 .name = "R63302(QHD)",
336 .xres = 544,
337 .yres = 961,
338 .left_margin = 72,
339 .right_margin = 600,
340 .hsync_len = 16,
341 .upper_margin = 8,
342 .lower_margin = 8,
343 .vsync_len = 2,
344 .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_HOR_HIGH_ACT,
345 },
346};
347
348static struct sh_mobile_lcdc_info lcdc0_info = {
349 .clock_source = LCDC_CLK_PERIPHERAL,
350 .ch[0] = {
351 .chan = LCDC_CHAN_MAINLCD,
352 .interface_type = RGB24,
353 .clock_divider = 1,
354 .flags = LCDC_FLAGS_DWPOL,
355 .fourcc = V4L2_PIX_FMT_RGB565,
356 .lcd_modes = lcdc0_modes,
357 .num_modes = ARRAY_SIZE(lcdc0_modes),
358 .panel_cfg = {
359 .width = 44,
360 .height = 79,
361 },
362 .bl_info = {
363 .name = "sh_mobile_lcdc_bl",
364 .max_brightness = 1,
365 .set_brightness = lcd_backlight_set_brightness,
366 },
367 .tx_dev = &mipidsi0_device,
368 }
369};
370
371static struct resource lcdc0_resources[] = {
372 [0] = {
373 .name = "LCDC0",
374 .start = 0xfe940000, /* P4-only space */
375 .end = 0xfe943fff,
376 .flags = IORESOURCE_MEM,
377 },
378 [1] = {
379 .start = intcs_evt2irq(0x580),
380 .flags = IORESOURCE_IRQ,
381 },
382};
383
384static struct platform_device lcdc0_device = {
385 .name = "sh_mobile_lcdc_fb",
386 .num_resources = ARRAY_SIZE(lcdc0_resources),
387 .resource = lcdc0_resources,
388 .id = 0,
389 .dev = {
390 .platform_data = &lcdc0_info,
391 .coherent_dma_mask = ~0,
392 },
393};
394
381/* Fixed 2.8V regulators to be used by SDHI0 */ 395/* Fixed 2.8V regulators to be used by SDHI0 */
382static struct regulator_consumer_supply fixed2v8_power_consumers[] = 396static struct regulator_consumer_supply fixed2v8_power_consumers[] =
383{ 397{
@@ -531,8 +545,8 @@ static struct platform_device *ag5evm_devices[] __initdata = {
531 &fsi_device, 545 &fsi_device,
532 &mmc_device, 546 &mmc_device,
533 &irda_device, 547 &irda_device,
534 &lcdc0_device,
535 &mipidsi0_device, 548 &mipidsi0_device,
549 &lcdc0_device,
536 &sdhi0_device, 550 &sdhi0_device,
537 &sdhi1_device, 551 &sdhi1_device,
538}; 552};
@@ -621,7 +635,7 @@ static void __init ag5evm_init(void)
621 /* LCD backlight controller */ 635 /* LCD backlight controller */
622 gpio_request(GPIO_PORT235, NULL); /* RESET */ 636 gpio_request(GPIO_PORT235, NULL); /* RESET */
623 gpio_direction_output(GPIO_PORT235, 0); 637 gpio_direction_output(GPIO_PORT235, 0);
624 lcd_backlight_reset(); 638 lcd_backlight_set_brightness(0);
625 639
626 /* enable SDHI0 on CN15 [SD I/F] */ 640 /* enable SDHI0 on CN15 [SD I/F] */
627 gpio_request(GPIO_FN_SDHIWP0, NULL); 641 gpio_request(GPIO_FN_SDHIWP0, NULL);