/arch/arm/mach-msm/board-9615-display.c

https://github.com/AICP/kernel_google_msm · C · 169 lines · 129 code · 27 blank · 13 comment · 10 complexity · 8dc35489fd7001cb4454e8d4aa02f53b MD5 · raw file

  1. /* Copyright (c) 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 <linux/init.h>
  14. #include <linux/ioport.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/bootmem.h>
  17. #include <linux/msm_ion.h>
  18. #include <asm/mach-types.h>
  19. #include <mach/msm_memtypes.h>
  20. #include <mach/board.h>
  21. #include <mach/gpio.h>
  22. #include <mach/gpiomux.h>
  23. #include <mach/ion.h>
  24. #include <mach/msm_bus_board.h>
  25. #include "devices.h"
  26. #include "board-9615.h"
  27. /* prim = 240 x 320 x 4(bpp) x 2(pages) */
  28. #define MSM_FB_PRIM_BUF_SIZE roundup(240 * 320 * 4 * 2, 0x10000)
  29. #define MSM_FB_SIZE roundup(MSM_FB_PRIM_BUF_SIZE, 4096)
  30. #define GPIO_PIN_EBI2_LCD_A_D 21
  31. #define GPIO_PIN_EBI2_LCD_CS 22
  32. #define GPIO_PIN_EBI2_LCD_RS 24
  33. #ifdef CONFIG_FB_MSM
  34. static struct resource msm_fb_resources[] = {
  35. {
  36. .flags = IORESOURCE_MEM,
  37. }
  38. };
  39. static int msm_fb_detect_panel(const char *name)
  40. {
  41. return 0;
  42. }
  43. static struct msm_fb_platform_data msm_fb_pdata = {
  44. .detect_client = msm_fb_detect_panel,
  45. };
  46. static struct platform_device msm_fb_device = {
  47. .name = "msm_fb",
  48. .id = 0,
  49. .num_resources = ARRAY_SIZE(msm_fb_resources),
  50. .resource = msm_fb_resources,
  51. .dev.platform_data = &msm_fb_pdata,
  52. };
  53. void __init mdm9615_allocate_fb_region(void)
  54. {
  55. void *addr;
  56. unsigned long size;
  57. size = MSM_FB_SIZE;
  58. addr = alloc_bootmem_align(size, 0x1000);
  59. msm_fb_resources[0].start = __pa(addr);
  60. msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
  61. pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
  62. size, addr, __pa(addr));
  63. }
  64. static bool ebi2_power_init;
  65. static int ebi2_panel_power(int on)
  66. {
  67. static struct regulator *panel_power;
  68. int rc;
  69. pr_debug("%s: on=%d\n", __func__, on);
  70. if (!ebi2_power_init) {
  71. panel_power = regulator_get(&msm_ebi2_lcdc_device.dev,
  72. "VDDI2");
  73. if (IS_ERR_OR_NULL(panel_power)) {
  74. pr_err("could not get L14, rc = %ld\n",
  75. PTR_ERR(panel_power));
  76. return -ENODEV;
  77. }
  78. rc = regulator_set_voltage(panel_power, 2800000, 3800000);
  79. if (rc) {
  80. pr_err("set_voltage L14 failed, rc=%d\n", rc);
  81. return -EINVAL;
  82. }
  83. ebi2_power_init = true;
  84. }
  85. if (on) {
  86. rc = regulator_enable(panel_power);
  87. if (rc) {
  88. pr_err("enable L14 failed, rc=%d\n", rc);
  89. return -ENODEV;
  90. }
  91. rc = gpio_request(GPIO_PIN_EBI2_LCD_A_D, "disp_a_d");
  92. if (rc) {
  93. pr_err("request gpio EBI2_LCD_A_D failed, rc=%d\n", rc);
  94. goto error1;
  95. }
  96. rc = gpio_request(GPIO_PIN_EBI2_LCD_CS, "disp_cs");
  97. if (rc) {
  98. pr_err("request gpio EBI2_LCD_CS failed, rc=%d\n", rc);
  99. goto error2;
  100. }
  101. rc = gpio_request(GPIO_PIN_EBI2_LCD_RS, "disp_rs");
  102. if (rc) {
  103. pr_err("request gpio EBI2_LCD_RS failed, rc=%d\n", rc);
  104. goto error3;
  105. }
  106. } else {
  107. gpio_free(GPIO_PIN_EBI2_LCD_RS);
  108. gpio_free(GPIO_PIN_EBI2_LCD_CS);
  109. gpio_free(GPIO_PIN_EBI2_LCD_A_D);
  110. rc = regulator_disable(panel_power);
  111. if (rc) {
  112. pr_err("disable L14 failed, rc=%d\n", rc);
  113. return -ENODEV;
  114. }
  115. }
  116. return 0;
  117. error3:
  118. gpio_free(GPIO_PIN_EBI2_LCD_CS);
  119. error2:
  120. gpio_free(GPIO_PIN_EBI2_LCD_A_D);
  121. error1:
  122. regulator_disable(panel_power);
  123. return rc;
  124. }
  125. static struct lcdc_platform_data ebi2_lcdc_pdata = {
  126. .lcdc_power_save = ebi2_panel_power,
  127. };
  128. static struct lvds_panel_platform_data ebi2_epson_s1d_pdata;
  129. static struct platform_device ebi2_epson_s1d_panel_device = {
  130. .name = "ebi2_epson_s1d_qvga",
  131. .id = 0,
  132. .dev = {
  133. .platform_data = &ebi2_epson_s1d_pdata,
  134. }
  135. };
  136. void __init mdm9615_init_fb(void)
  137. {
  138. platform_device_register(&msm_fb_device);
  139. platform_device_register(&ebi2_epson_s1d_panel_device);
  140. msm_fb_register_device("ebi2_lcd", &ebi2_lcdc_pdata);
  141. }
  142. #endif