2 * arch/arm/mach-tegra/board-ventana-panel.c
4 * Copyright (c) 2010, NVIDIA Corporation.
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.
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
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.
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 <mach/nvhost.h>
29 #include <mach/nvmap.h>
30 #include <mach/irqs.h>
31 #include <mach/iomap.h>
36 #include "gpio-names.h"
38 #define ventana_bl_enb TEGRA_GPIO_PD4
39 #define ventana_lvds_shutdown TEGRA_GPIO_PB2
40 #define ventana_hdmi_hpd TEGRA_GPIO_PN7
41 #define ventana_hdmi_enb TEGRA_GPIO_PV5
43 static int ventana_backlight_init(struct device *dev) {
46 ret = gpio_request(ventana_bl_enb, "backlight_enb");
50 ret = gpio_direction_output(ventana_bl_enb, 1);
52 gpio_free(ventana_bl_enb);
54 tegra_gpio_enable(ventana_bl_enb);
59 static void ventana_backlight_exit(struct device *dev) {
60 gpio_set_value(ventana_bl_enb, 0);
61 gpio_free(ventana_bl_enb);
62 tegra_gpio_disable(ventana_bl_enb);
65 static int ventana_backlight_notify(struct device *unused, int brightness)
67 gpio_set_value(ventana_bl_enb, !!brightness);
71 static struct platform_pwm_backlight_data ventana_backlight_data = {
73 .max_brightness = 255,
74 .dft_brightness = 224,
75 .pwm_period_ns = 5000000,
76 .init = ventana_backlight_init,
77 .exit = ventana_backlight_exit,
78 .notify = ventana_backlight_notify,
81 static struct platform_device ventana_backlight_device = {
82 .name = "pwm-backlight",
85 .platform_data = &ventana_backlight_data,
89 static int ventana_panel_enable(void)
91 static struct regulator *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));
99 regulator_enable(reg);
102 gpio_set_value(ventana_lvds_shutdown, 1);
106 static int ventana_panel_disable(void)
108 gpio_set_value(ventana_lvds_shutdown, 0);
112 static int ventana_hdmi_enable(void)
114 gpio_set_value(ventana_hdmi_enb, 1);
118 static int ventana_hdmi_disable(void)
120 gpio_set_value(ventana_hdmi_enb, 0);
124 static struct resource ventana_disp1_resources[] = {
127 .start = INT_DISPLAY_GENERAL,
128 .end = INT_DISPLAY_GENERAL,
129 .flags = IORESOURCE_IRQ,
133 .start = TEGRA_DISPLAY_BASE,
134 .end = TEGRA_DISPLAY_BASE + TEGRA_DISPLAY_SIZE-1,
135 .flags = IORESOURCE_MEM,
140 .end = 0x18414000 - 1, /* enough for 1080P 16bpp */
141 .flags = IORESOURCE_MEM,
145 static struct resource ventana_disp2_resources[] = {
148 .start = INT_DISPLAY_B_GENERAL,
149 .end = INT_DISPLAY_B_GENERAL,
150 .flags = IORESOURCE_IRQ,
154 .start = TEGRA_DISPLAY2_BASE,
155 .end = TEGRA_DISPLAY2_BASE + TEGRA_DISPLAY2_SIZE - 1,
156 .flags = IORESOURCE_MEM,
160 .flags = IORESOURCE_MEM,
162 .end = 0x18BFD000 - 1,
166 .start = TEGRA_HDMI_BASE,
167 .end = TEGRA_HDMI_BASE + TEGRA_HDMI_SIZE - 1,
168 .flags = IORESOURCE_MEM,
172 static struct tegra_dc_mode ventana_panel_modes[] = {
188 static struct tegra_fb_data ventana_fb_data = {
192 .bits_per_pixel = 16,
195 static struct tegra_fb_data ventana_hdmi_fb_data = {
199 .bits_per_pixel = 16,
202 static struct tegra_dc_out ventana_disp1_out = {
203 .type = TEGRA_DC_OUT_RGB,
205 .align = TEGRA_DC_ALIGN_MSB,
206 .order = TEGRA_DC_ORDER_RED_BLUE,
208 .modes = ventana_panel_modes,
209 .n_modes = ARRAY_SIZE(ventana_panel_modes),
211 .enable = ventana_panel_enable,
212 .disable = ventana_panel_disable,
215 static struct tegra_dc_out ventana_disp2_out = {
216 .type = TEGRA_DC_OUT_HDMI,
217 .flags = TEGRA_DC_OUT_HOTPLUG_HIGH,
220 .hotplug_gpio = ventana_hdmi_hpd,
222 .align = TEGRA_DC_ALIGN_MSB,
223 .order = TEGRA_DC_ORDER_RED_BLUE,
225 .enable = ventana_hdmi_enable,
226 .disable = ventana_hdmi_disable,
229 static struct tegra_dc_platform_data ventana_disp1_pdata = {
230 .flags = TEGRA_DC_FLAG_ENABLED,
231 .default_out = &ventana_disp1_out,
232 .fb = &ventana_fb_data,
235 static struct tegra_dc_platform_data ventana_disp2_pdata = {
236 .flags = TEGRA_DC_FLAG_ENABLED,
237 .default_out = &ventana_disp2_out,
238 .fb = &ventana_hdmi_fb_data,
241 static struct nvhost_device ventana_disp1_device = {
244 .resource = ventana_disp1_resources,
245 .num_resources = ARRAY_SIZE(ventana_disp1_resources),
247 .platform_data = &ventana_disp1_pdata,
251 static struct nvhost_device ventana_disp2_device = {
254 .resource = ventana_disp2_resources,
255 .num_resources = ARRAY_SIZE(ventana_disp2_resources),
257 .platform_data = &ventana_disp2_pdata,
261 static struct nvmap_platform_carveout ventana_carveouts[] = {
264 .usage_mask = NVMAP_HEAP_CARVEOUT_IRAM,
265 .base = TEGRA_IRAM_BASE,
266 .size = TEGRA_IRAM_SIZE,
267 .buddy_size = 0, /* no buddy allocation for IRAM */
271 .usage_mask = NVMAP_HEAP_CARVEOUT_GENERIC,
273 .size = SZ_128M - 0xC00000,
274 .buddy_size = SZ_32K,
278 static struct nvmap_platform_data ventana_nvmap_data = {
279 .carveouts = ventana_carveouts,
280 .nr_carveouts = ARRAY_SIZE(ventana_carveouts),
283 static struct platform_device ventana_nvmap_device = {
284 .name = "tegra-nvmap",
287 .platform_data = &ventana_nvmap_data,
291 static struct platform_device *ventana_gfx_devices[] __initdata = {
292 &ventana_nvmap_device,
293 &tegra_grhost_device,
295 &ventana_backlight_device,
298 int __init ventana_panel_init(void)
302 gpio_request(ventana_lvds_shutdown, "lvds_shdn");
303 gpio_direction_output(ventana_lvds_shutdown, 1);
304 tegra_gpio_enable(ventana_lvds_shutdown);
306 gpio_request(ventana_hdmi_enb, "hdmi_5v_en");
307 gpio_direction_output(ventana_hdmi_enb, 0);
308 tegra_gpio_enable(ventana_hdmi_enb);
310 gpio_request(ventana_hdmi_hpd, "hdmi_hpd");
311 gpio_direction_input(ventana_hdmi_hpd);
312 tegra_gpio_enable(ventana_hdmi_hpd);
314 err = platform_add_devices(ventana_gfx_devices,
315 ARRAY_SIZE(ventana_gfx_devices));
318 err = nvhost_device_register(&ventana_disp1_device);
321 err = nvhost_device_register(&ventana_disp2_device);