aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-tegra/board-aruba-panel.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-tegra/board-aruba-panel.c')
-rw-r--r--arch/arm/mach-tegra/board-aruba-panel.c256
1 files changed, 256 insertions, 0 deletions
diff --git a/arch/arm/mach-tegra/board-aruba-panel.c b/arch/arm/mach-tegra/board-aruba-panel.c
new file mode 100644
index 00000000000..b014326fc91
--- /dev/null
+++ b/arch/arm/mach-tegra/board-aruba-panel.c
@@ -0,0 +1,256 @@
1/*
2 * arch/arm/mach-tegra/board-aruba-panel.c
3 *
4 * Copyright (c) 2010-2012, NVIDIA Corporation.
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 as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 */
20
21#include <linux/delay.h>
22#include <linux/gpio.h>
23#include <linux/regulator/consumer.h>
24#include <linux/resource.h>
25#include <asm/mach-types.h>
26#include <linux/platform_device.h>
27#include <linux/pwm_backlight.h>
28#include <linux/nvhost.h>
29#include <mach/nvmap.h>
30#include <mach/irqs.h>
31#include <mach/iomap.h>
32#include <mach/dc.h>
33#include <mach/fb.h>
34
35#include "board.h"
36#include "devices.h"
37#include "gpio-names.h"
38
39#define aruba_lvds_shutdown TEGRA_GPIO_PB2
40#define aruba_bl_enb TEGRA_GPIO_PW1
41
42static int aruba_backlight_init(struct device *dev) {
43 int ret;
44
45 ret = gpio_request(aruba_bl_enb, "backlight_enb");
46 if (ret < 0)
47 return ret;
48
49 ret = gpio_direction_output(aruba_bl_enb, 1);
50 if (ret < 0)
51 gpio_free(aruba_bl_enb);
52 else
53 tegra_gpio_enable(aruba_bl_enb);
54
55 return ret;
56};
57
58static void aruba_backlight_exit(struct device *dev) {
59 gpio_set_value(aruba_bl_enb, 0);
60 gpio_free(aruba_bl_enb);
61 tegra_gpio_disable(aruba_bl_enb);
62}
63
64static int aruba_backlight_notify(struct device *unused, int brightness)
65{
66 gpio_set_value(aruba_bl_enb, !!brightness);
67 return brightness;
68}
69
70static struct platform_pwm_backlight_data aruba_backlight_data = {
71 .pwm_id = 2,
72 .max_brightness = 255,
73 .dft_brightness = 224,
74 .pwm_period_ns = 5000000,
75 .init = aruba_backlight_init,
76 .exit = aruba_backlight_exit,
77 .notify = aruba_backlight_notify,
78};
79
80static struct platform_device aruba_backlight_device = {
81 .name = "pwm-backlight",
82 .id = -1,
83 .dev = {
84 .platform_data = &aruba_backlight_data,
85 },
86};
87
88#ifdef CONFIG_TEGRA_DC
89static int aruba_panel_enable(void)
90{
91 static struct regulator *reg = NULL;
92
93 if (reg == NULL) {
94 reg = regulator_get(NULL, "avdd_lvds");
95 if (WARN_ON(IS_ERR(reg)))
96 pr_err("%s: couldn't get regulator avdd_lvds: %ld\n",
97 __func__, PTR_ERR(reg));
98 else
99 regulator_enable(reg);
100 }
101
102 gpio_set_value(aruba_lvds_shutdown, 1);
103 return 0;
104}
105
106static int aruba_panel_disable(void)
107{
108 gpio_set_value(aruba_lvds_shutdown, 0);
109 return 0;
110}
111
112static struct resource aruba_disp1_resources[] = {
113 {
114 .name = "irq",
115 .start = INT_DISPLAY_GENERAL,
116 .end = INT_DISPLAY_GENERAL,
117 .flags = IORESOURCE_IRQ,
118 },
119 {
120 .name = "regs",
121 .start = TEGRA_DISPLAY_BASE,
122 .end = TEGRA_DISPLAY_BASE + TEGRA_DISPLAY_SIZE-1,
123 .flags = IORESOURCE_MEM,
124 },
125 {
126 .name = "fbmem",
127 .start = 0, /* Filled in by aruba_panel_init() */
128 .end = 0, /* Filled in by aruba_panel_init() */
129 .flags = IORESOURCE_MEM,
130 },
131};
132
133static struct tegra_dc_mode aruba_panel_modes[] = {
134 {
135 .pclk = 18000000,
136 .h_ref_to_sync = 8,
137 .v_ref_to_sync = 2,
138 .h_sync_width = 4,
139 .v_sync_width = 1,
140 .h_back_porch = 20,
141 .v_back_porch = 7,
142 .h_active = 480,
143 .v_active = 640,
144 .h_front_porch = 8,
145 .v_front_porch = 8,
146 },
147};
148
149static struct tegra_fb_data aruba_fb_data = {
150 .win = 0,
151 .xres = 480,
152 .yres = 640,
153 .bits_per_pixel = 16,
154};
155
156static struct tegra_dc_out aruba_disp1_out = {
157 .type = TEGRA_DC_OUT_RGB,
158
159 .align = TEGRA_DC_ALIGN_MSB,
160 .order = TEGRA_DC_ORDER_RED_BLUE,
161
162 .modes = aruba_panel_modes,
163 .n_modes = ARRAY_SIZE(aruba_panel_modes),
164
165 .enable = aruba_panel_enable,
166 .disable = aruba_panel_disable,
167};
168
169static struct tegra_dc_platform_data aruba_disp1_pdata = {
170 .flags = TEGRA_DC_FLAG_ENABLED,
171 .default_out = &aruba_disp1_out,
172 .fb = &aruba_fb_data,
173};
174
175static struct nvhost_device aruba_disp1_device = {
176 .name = "tegradc",
177 .id = 0,
178 .resource = aruba_disp1_resources,
179 .num_resources = ARRAY_SIZE(aruba_disp1_resources),
180 .dev = {
181 .platform_data = &aruba_disp1_pdata,
182 },
183};
184#endif
185
186#if defined(CONFIG_TEGRA_NVMAP)
187static struct nvmap_platform_carveout aruba_carveouts[] = {
188 [0] = NVMAP_HEAP_CARVEOUT_IRAM_INIT,
189 [1] = {
190 .name = "generic-0",
191 .usage_mask = NVMAP_HEAP_CARVEOUT_GENERIC,
192 .base = 0, /* Filled in by aruba_panel_init() */
193 .size = 0, /* Filled in by aruba_panel_init() */
194 .buddy_size = SZ_32K,
195 },
196};
197
198static struct nvmap_platform_data aruba_nvmap_data = {
199 .carveouts = aruba_carveouts,
200 .nr_carveouts = ARRAY_SIZE(aruba_carveouts),
201};
202
203static struct platform_device aruba_nvmap_device = {
204 .name = "tegra-nvmap",
205 .id = -1,
206 .dev = {
207 .platform_data = &aruba_nvmap_data,
208 },
209};
210#endif
211
212static struct platform_device *aruba_gfx_devices[] __initdata = {
213#if defined(CONFIG_TEGRA_NVMAP)
214 &aruba_nvmap_device,
215#endif
216 &tegra_pwfm2_device,
217 &aruba_backlight_device,
218};
219
220int __init aruba_panel_init(void)
221{
222 int err;
223 struct resource __maybe_unused *res;
224
225#if defined(CONFIG_TEGRA_NVMAP)
226 aruba_carveouts[1].base = tegra_carveout_start;
227 aruba_carveouts[1].size = tegra_carveout_size;
228#endif
229
230#ifdef CONFIG_TEGRA_GRHOST
231 err = nvhost_device_register(&tegra_grhost_device);
232 if (err)
233 return err;
234#endif
235
236 err = platform_add_devices(aruba_gfx_devices,
237 ARRAY_SIZE(aruba_gfx_devices));
238
239#if defined(CONFIG_TEGRA_GRHOST) && defined(CONFIG_TEGRA_DC)
240 res = nvhost_get_resource_byname(&aruba_disp1_device,
241 IORESOURCE_MEM, "fbmem");
242 res->start = tegra_fb_start;
243 res->end = tegra_fb_start + tegra_fb_size - 1;
244#endif
245
246 /* Copy the bootloader fb to the fb. */
247 tegra_move_framebuffer(tegra_fb_start, tegra_bootloader_fb_start,
248 min(tegra_fb_size, tegra_bootloader_fb_size));
249
250#if defined(CONFIG_TEGRA_GRHOST) && defined(CONFIG_TEGRA_DC)
251 if (!err)
252 err = nvhost_device_register(&aruba_disp1_device);
253#endif
254
255 return err;
256}