mddi_toshiba_vga.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /* Copyright (c) 2009-2010, 2012 The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. */
  13. #include "msm_fb.h"
  14. #include "mddihost.h"
  15. #include "mddihosti.h"
  16. #include "mddi_toshiba.h"
  17. static uint32 read_client_reg(uint32 addr)
  18. {
  19. uint32 val;
  20. mddi_queue_register_read(addr, &val, TRUE, 0);
  21. return val;
  22. }
  23. static uint32 toshiba_lcd_gpio_read(void)
  24. {
  25. uint32 val;
  26. write_client_reg(GPIODIR, 0x0000000C, TRUE);
  27. write_client_reg(GPIOSEL, 0x00000000, TRUE);
  28. write_client_reg(GPIOSEL, 0x00000000, TRUE);
  29. write_client_reg(GPIOPC, 0x03CF00C0, TRUE);
  30. val = read_client_reg(GPIODATA) & 0x2C0;
  31. return val;
  32. }
  33. static u32 mddi_toshiba_panel_detect(void)
  34. {
  35. mddi_host_type host_idx = MDDI_HOST_PRIM;
  36. uint32 lcd_gpio;
  37. u32 mddi_toshiba_lcd = LCD_TOSHIBA_2P4_VGA;
  38. /* Toshiba display requires larger drive_lo value */
  39. mddi_host_reg_out(DRIVE_LO, 0x0050);
  40. lcd_gpio = toshiba_lcd_gpio_read();
  41. switch (lcd_gpio) {
  42. case 0x0080:
  43. mddi_toshiba_lcd = LCD_SHARP_2P4_VGA;
  44. break;
  45. case 0x00C0:
  46. default:
  47. mddi_toshiba_lcd = LCD_TOSHIBA_2P4_VGA;
  48. break;
  49. }
  50. return mddi_toshiba_lcd;
  51. }
  52. static int __init mddi_toshiba_vga_init(void)
  53. {
  54. int ret;
  55. struct msm_panel_info pinfo;
  56. u32 panel;
  57. #ifdef CONFIG_FB_MSM_MDDI_AUTO_DETECT
  58. u32 id;
  59. ret = msm_fb_detect_client("mddi_toshiba_vga");
  60. if (ret == -ENODEV)
  61. return 0;
  62. if (ret) {
  63. id = mddi_get_client_id();
  64. if ((id >> 16) != 0xD263)
  65. return 0;
  66. }
  67. #endif
  68. panel = mddi_toshiba_panel_detect();
  69. pinfo.xres = 480;
  70. pinfo.yres = 640;
  71. pinfo.type = MDDI_PANEL;
  72. pinfo.pdest = DISPLAY_1;
  73. pinfo.mddi.vdopkt = MDDI_DEFAULT_PRIM_PIX_ATTR;
  74. pinfo.wait_cycle = 0;
  75. pinfo.bpp = 18;
  76. pinfo.lcd.vsync_enable = TRUE;
  77. pinfo.mddi.is_type1 = TRUE;
  78. pinfo.lcd.refx100 = 6118;
  79. pinfo.lcd.v_back_porch = 6;
  80. pinfo.lcd.v_front_porch = 0;
  81. pinfo.lcd.v_pulse_width = 0;
  82. pinfo.lcd.hw_vsync_mode = FALSE;
  83. pinfo.lcd.vsync_notifier_period = (1 * HZ);
  84. pinfo.bl_max = 99;
  85. pinfo.bl_min = 1;
  86. pinfo.clk_rate = 122880000;
  87. pinfo.clk_min = 120000000;
  88. pinfo.clk_max = 200000000;
  89. pinfo.fb_num = 2;
  90. ret = mddi_toshiba_device_register(&pinfo, TOSHIBA_VGA_PRIM, panel);
  91. if (ret) {
  92. printk(KERN_ERR "%s: failed to register device!\n", __func__);
  93. return ret;
  94. }
  95. pinfo.xres = 176;
  96. pinfo.yres = 220;
  97. MSM_FB_SINGLE_MODE_PANEL(&pinfo);
  98. pinfo.type = MDDI_PANEL;
  99. pinfo.pdest = DISPLAY_2;
  100. pinfo.mddi.vdopkt = 0x400;
  101. pinfo.wait_cycle = 0;
  102. pinfo.bpp = 18;
  103. pinfo.clk_rate = 122880000;
  104. pinfo.clk_min = 120000000;
  105. pinfo.clk_max = 200000000;
  106. pinfo.fb_num = 2;
  107. ret = mddi_toshiba_device_register(&pinfo, TOSHIBA_VGA_SECD, panel);
  108. if (ret)
  109. printk(KERN_WARNING
  110. "%s: failed to register device!\n", __func__);
  111. return ret;
  112. }
  113. module_init(mddi_toshiba_vga_init);