board-zoom-display.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /*
  2. * Copyright (C) 2010 Texas Instruments Inc.
  3. *
  4. * Modified from mach-omap2/board-zoom-peripherals.c
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/init.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/gpio.h>
  14. #include <linux/i2c/twl.h>
  15. #include <linux/spi/spi.h>
  16. #include <plat/mcspi.h>
  17. #include <plat/display.h>
  18. #define LCD_PANEL_RESET_GPIO_PROD 96
  19. #define LCD_PANEL_RESET_GPIO_PILOT 55
  20. #define LCD_PANEL_QVGA_GPIO 56
  21. static void zoom_lcd_panel_init(void)
  22. {
  23. int ret;
  24. unsigned char lcd_panel_reset_gpio;
  25. lcd_panel_reset_gpio = (omap_rev() > OMAP3430_REV_ES3_0) ?
  26. LCD_PANEL_RESET_GPIO_PROD :
  27. LCD_PANEL_RESET_GPIO_PILOT;
  28. ret = gpio_request(lcd_panel_reset_gpio, "lcd reset");
  29. if (ret) {
  30. pr_err("Failed to get LCD reset GPIO (gpio%d).\n",
  31. lcd_panel_reset_gpio);
  32. return;
  33. }
  34. gpio_direction_output(lcd_panel_reset_gpio, 1);
  35. ret = gpio_request(LCD_PANEL_QVGA_GPIO, "lcd qvga");
  36. if (ret) {
  37. pr_err("Failed to get LCD_PANEL_QVGA_GPIO (gpio%d).\n",
  38. LCD_PANEL_QVGA_GPIO);
  39. goto err0;
  40. }
  41. gpio_direction_output(LCD_PANEL_QVGA_GPIO, 1);
  42. return;
  43. err0:
  44. gpio_free(lcd_panel_reset_gpio);
  45. }
  46. static int zoom_panel_enable_lcd(struct omap_dss_device *dssdev)
  47. {
  48. return 0;
  49. }
  50. static void zoom_panel_disable_lcd(struct omap_dss_device *dssdev)
  51. {
  52. }
  53. /*
  54. * PWMA/B register offsets (TWL4030_MODULE_PWMA)
  55. */
  56. #define TWL_INTBR_PMBR1 0xD
  57. #define TWL_INTBR_GPBR1 0xC
  58. #define TWL_LED_PWMON 0x0
  59. #define TWL_LED_PWMOFF 0x1
  60. static int zoom_set_bl_intensity(struct omap_dss_device *dssdev, int level)
  61. {
  62. unsigned char c;
  63. u8 mux_pwm, enb_pwm;
  64. if (level > 100)
  65. return -1;
  66. twl_i2c_read_u8(TWL4030_MODULE_INTBR, &mux_pwm, TWL_INTBR_PMBR1);
  67. twl_i2c_read_u8(TWL4030_MODULE_INTBR, &enb_pwm, TWL_INTBR_GPBR1);
  68. if (level == 0) {
  69. /* disable pwm1 output and clock */
  70. enb_pwm = enb_pwm & 0xF5;
  71. /* change pwm1 pin to gpio pin */
  72. mux_pwm = mux_pwm & 0xCF;
  73. twl_i2c_write_u8(TWL4030_MODULE_INTBR,
  74. enb_pwm, TWL_INTBR_GPBR1);
  75. twl_i2c_write_u8(TWL4030_MODULE_INTBR,
  76. mux_pwm, TWL_INTBR_PMBR1);
  77. return 0;
  78. }
  79. if (!((enb_pwm & 0xA) && (mux_pwm & 0x30))) {
  80. /* change gpio pin to pwm1 pin */
  81. mux_pwm = mux_pwm | 0x30;
  82. /* enable pwm1 output and clock*/
  83. enb_pwm = enb_pwm | 0x0A;
  84. twl_i2c_write_u8(TWL4030_MODULE_INTBR,
  85. mux_pwm, TWL_INTBR_PMBR1);
  86. twl_i2c_write_u8(TWL4030_MODULE_INTBR,
  87. enb_pwm, TWL_INTBR_GPBR1);
  88. }
  89. c = ((50 * (100 - level)) / 100) + 1;
  90. twl_i2c_write_u8(TWL4030_MODULE_PWM1, 0x7F, TWL_LED_PWMOFF);
  91. twl_i2c_write_u8(TWL4030_MODULE_PWM1, c, TWL_LED_PWMON);
  92. return 0;
  93. }
  94. static struct omap_dss_device zoom_lcd_device = {
  95. .name = "lcd",
  96. .driver_name = "NEC_8048_panel",
  97. .type = OMAP_DISPLAY_TYPE_DPI,
  98. .phy.dpi.data_lines = 24,
  99. .platform_enable = zoom_panel_enable_lcd,
  100. .platform_disable = zoom_panel_disable_lcd,
  101. .max_backlight_level = 100,
  102. .set_backlight = zoom_set_bl_intensity,
  103. };
  104. static struct omap_dss_device *zoom_dss_devices[] = {
  105. &zoom_lcd_device,
  106. };
  107. static struct omap_dss_board_info zoom_dss_data = {
  108. .num_devices = ARRAY_SIZE(zoom_dss_devices),
  109. .devices = zoom_dss_devices,
  110. .default_device = &zoom_lcd_device,
  111. };
  112. static struct platform_device zoom_dss_device = {
  113. .name = "omapdss",
  114. .id = -1,
  115. .dev = {
  116. .platform_data = &zoom_dss_data,
  117. },
  118. };
  119. static struct omap2_mcspi_device_config dss_lcd_mcspi_config = {
  120. .turbo_mode = 1,
  121. .single_channel = 1, /* 0: slave, 1: master */
  122. };
  123. static struct spi_board_info nec_8048_spi_board_info[] __initdata = {
  124. [0] = {
  125. .modalias = "nec_8048_spi",
  126. .bus_num = 1,
  127. .chip_select = 2,
  128. .max_speed_hz = 375000,
  129. .controller_data = &dss_lcd_mcspi_config,
  130. },
  131. };
  132. static struct platform_device *zoom_display_devices[] __initdata = {
  133. &zoom_dss_device,
  134. };
  135. void __init zoom_display_init(void)
  136. {
  137. platform_add_devices(zoom_display_devices,
  138. ARRAY_SIZE(zoom_display_devices));
  139. spi_register_board_info(nec_8048_spi_board_info,
  140. ARRAY_SIZE(nec_8048_spi_board_info));
  141. zoom_lcd_panel_init();
  142. }