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