board-zoom-display.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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 <video/omapdss.h>
  18. #include <mach/board-zoom.h>
  19. #define LCD_PANEL_RESET_GPIO_PROD 96
  20. #define LCD_PANEL_RESET_GPIO_PILOT 55
  21. #define LCD_PANEL_QVGA_GPIO 56
  22. static struct gpio zoom_lcd_gpios[] __initdata = {
  23. { -EINVAL, GPIOF_OUT_INIT_HIGH, "lcd reset" },
  24. { LCD_PANEL_QVGA_GPIO, GPIOF_OUT_INIT_HIGH, "lcd qvga" },
  25. };
  26. static void __init zoom_lcd_panel_init(void)
  27. {
  28. zoom_lcd_gpios[0].gpio = (omap_rev() > OMAP3430_REV_ES3_0) ?
  29. LCD_PANEL_RESET_GPIO_PROD :
  30. LCD_PANEL_RESET_GPIO_PILOT;
  31. if (gpio_request_array(zoom_lcd_gpios, ARRAY_SIZE(zoom_lcd_gpios)))
  32. pr_err("%s: Failed to get LCD GPIOs.\n", __func__);
  33. }
  34. static int zoom_panel_enable_lcd(struct omap_dss_device *dssdev)
  35. {
  36. return 0;
  37. }
  38. static void zoom_panel_disable_lcd(struct omap_dss_device *dssdev)
  39. {
  40. }
  41. /*
  42. * PWMA/B register offsets (TWL4030_MODULE_PWMA)
  43. */
  44. #define TWL_INTBR_PMBR1 0xD
  45. #define TWL_INTBR_GPBR1 0xC
  46. #define TWL_LED_PWMON 0x0
  47. #define TWL_LED_PWMOFF 0x1
  48. static int zoom_set_bl_intensity(struct omap_dss_device *dssdev, int level)
  49. {
  50. #ifdef CONFIG_TWL4030_CORE
  51. unsigned char c;
  52. u8 mux_pwm, enb_pwm;
  53. if (level > 100)
  54. return -1;
  55. twl_i2c_read_u8(TWL4030_MODULE_INTBR, &mux_pwm, TWL_INTBR_PMBR1);
  56. twl_i2c_read_u8(TWL4030_MODULE_INTBR, &enb_pwm, TWL_INTBR_GPBR1);
  57. if (level == 0) {
  58. /* disable pwm1 output and clock */
  59. enb_pwm = enb_pwm & 0xF5;
  60. /* change pwm1 pin to gpio pin */
  61. mux_pwm = mux_pwm & 0xCF;
  62. twl_i2c_write_u8(TWL4030_MODULE_INTBR,
  63. enb_pwm, TWL_INTBR_GPBR1);
  64. twl_i2c_write_u8(TWL4030_MODULE_INTBR,
  65. mux_pwm, TWL_INTBR_PMBR1);
  66. return 0;
  67. }
  68. if (!((enb_pwm & 0xA) && (mux_pwm & 0x30))) {
  69. /* change gpio pin to pwm1 pin */
  70. mux_pwm = mux_pwm | 0x30;
  71. /* enable pwm1 output and clock*/
  72. enb_pwm = enb_pwm | 0x0A;
  73. twl_i2c_write_u8(TWL4030_MODULE_INTBR,
  74. mux_pwm, TWL_INTBR_PMBR1);
  75. twl_i2c_write_u8(TWL4030_MODULE_INTBR,
  76. enb_pwm, TWL_INTBR_GPBR1);
  77. }
  78. c = ((50 * (100 - level)) / 100) + 1;
  79. twl_i2c_write_u8(TWL4030_MODULE_PWM1, 0x7F, TWL_LED_PWMOFF);
  80. twl_i2c_write_u8(TWL4030_MODULE_PWM1, c, TWL_LED_PWMON);
  81. #else
  82. pr_warn("Backlight not enabled\n");
  83. #endif
  84. return 0;
  85. }
  86. static struct omap_dss_device zoom_lcd_device = {
  87. .name = "lcd",
  88. .driver_name = "NEC_8048_panel",
  89. .type = OMAP_DISPLAY_TYPE_DPI,
  90. .phy.dpi.data_lines = 24,
  91. .platform_enable = zoom_panel_enable_lcd,
  92. .platform_disable = zoom_panel_disable_lcd,
  93. .max_backlight_level = 100,
  94. .set_backlight = zoom_set_bl_intensity,
  95. };
  96. static struct omap_dss_device *zoom_dss_devices[] = {
  97. &zoom_lcd_device,
  98. };
  99. static struct omap_dss_board_info zoom_dss_data = {
  100. .num_devices = ARRAY_SIZE(zoom_dss_devices),
  101. .devices = zoom_dss_devices,
  102. .default_device = &zoom_lcd_device,
  103. };
  104. static struct omap2_mcspi_device_config dss_lcd_mcspi_config = {
  105. .turbo_mode = 1,
  106. };
  107. static struct spi_board_info nec_8048_spi_board_info[] __initdata = {
  108. [0] = {
  109. .modalias = "nec_8048_spi",
  110. .bus_num = 1,
  111. .chip_select = 2,
  112. .max_speed_hz = 375000,
  113. .controller_data = &dss_lcd_mcspi_config,
  114. },
  115. };
  116. void __init zoom_display_init(void)
  117. {
  118. omap_display_init(&zoom_dss_data);
  119. spi_register_board_info(nec_8048_spi_board_info,
  120. ARRAY_SIZE(nec_8048_spi_board_info));
  121. zoom_lcd_panel_init();
  122. }