blob: af99faf2cced4743a31dcef30cdf37c01dc6834c [file] [log] [blame]
Ranjith Lohithakshanc6253272009-11-18 18:41:09 -08001/*
2 * linux/arch/arm/mach-omap2/board-am3517evm.c
3 *
4 * Copyright (C) 2009 Texas Instruments Incorporated
5 * Author: Ranjith Lohithakshan <ranjithl@ti.com>
6 *
7 * Based on mach-omap2/board-omap3evm.c
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation version 2.
12 *
13 * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind,
14 * whether express or implied; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 */
18
19#include <linux/kernel.h>
20#include <linux/init.h>
21#include <linux/platform_device.h>
22#include <linux/gpio.h>
23
24#include <mach/hardware.h>
Vaibhav Hiremathe3d4d0a2010-02-15 10:03:35 -080025#include <mach/am35xx.h>
Ranjith Lohithakshanc6253272009-11-18 18:41:09 -080026#include <asm/mach-types.h>
27#include <asm/mach/arch.h>
28#include <asm/mach/map.h>
29
30#include <plat/board.h>
31#include <plat/common.h>
32#include <plat/usb.h>
Vaibhav Hiremathc3d33322010-01-13 17:17:10 +053033#include <plat/display.h>
Ranjith Lohithakshanc6253272009-11-18 18:41:09 -080034
Tony Lindgrenca5742b2009-12-11 16:16:32 -080035#include "mux.h"
36
Vaibhav Hiremathc3d33322010-01-13 17:17:10 +053037#define LCD_PANEL_PWR 176
38#define LCD_PANEL_BKLIGHT_PWR 182
39#define LCD_PANEL_PWM 181
40
Vaibhav Hiremath1f738dc2010-02-17 14:09:28 -080041static int __init am3517_evm_i2c_init(void)
42{
43 omap_register_i2c_bus(1, 400, NULL, 0);
44 omap_register_i2c_bus(2, 400, NULL, 0);
45 omap_register_i2c_bus(3, 400, NULL, 0);
46
47 return 0;
48}
49
Vaibhav Hiremathc3d33322010-01-13 17:17:10 +053050static int lcd_enabled;
51static int dvi_enabled;
52
53static void __init am3517_evm_display_init(void)
54{
55 int r;
56
57 omap_mux_init_gpio(LCD_PANEL_PWR, OMAP_PIN_INPUT_PULLUP);
58 omap_mux_init_gpio(LCD_PANEL_BKLIGHT_PWR, OMAP_PIN_INPUT_PULLDOWN);
59 omap_mux_init_gpio(LCD_PANEL_PWM, OMAP_PIN_INPUT_PULLDOWN);
60 /*
61 * Enable GPIO 182 = LCD Backlight Power
62 */
63 r = gpio_request(LCD_PANEL_BKLIGHT_PWR, "lcd_backlight_pwr");
64 if (r) {
65 printk(KERN_ERR "failed to get lcd_backlight_pwr\n");
66 return;
67 }
68 gpio_direction_output(LCD_PANEL_BKLIGHT_PWR, 1);
69 /*
70 * Enable GPIO 181 = LCD Panel PWM
71 */
72 r = gpio_request(LCD_PANEL_PWM, "lcd_pwm");
73 if (r) {
74 printk(KERN_ERR "failed to get lcd_pwm\n");
75 goto err_1;
76 }
77 gpio_direction_output(LCD_PANEL_PWM, 1);
78 /*
79 * Enable GPIO 176 = LCD Panel Power enable pin
80 */
81 r = gpio_request(LCD_PANEL_PWR, "lcd_panel_pwr");
82 if (r) {
83 printk(KERN_ERR "failed to get lcd_panel_pwr\n");
84 goto err_2;
85 }
86 gpio_direction_output(LCD_PANEL_PWR, 1);
87
88 printk(KERN_INFO "Display initialized successfully\n");
89 return;
90
91err_2:
92 gpio_free(LCD_PANEL_PWM);
93err_1:
94 gpio_free(LCD_PANEL_BKLIGHT_PWR);
95}
96
97static int am3517_evm_panel_enable_lcd(struct omap_dss_device *dssdev)
98{
99 if (dvi_enabled) {
100 printk(KERN_ERR "cannot enable LCD, DVI is enabled\n");
101 return -EINVAL;
102 }
103 gpio_set_value(LCD_PANEL_PWR, 1);
104 lcd_enabled = 1;
105
106 return 0;
107}
108
109static void am3517_evm_panel_disable_lcd(struct omap_dss_device *dssdev)
110{
111 gpio_set_value(LCD_PANEL_PWR, 0);
112 lcd_enabled = 0;
113}
114
115static struct omap_dss_device am3517_evm_lcd_device = {
116 .type = OMAP_DISPLAY_TYPE_DPI,
117 .name = "lcd",
118 .driver_name = "sharp_lq_panel",
119 .phy.dpi.data_lines = 16,
120 .platform_enable = am3517_evm_panel_enable_lcd,
121 .platform_disable = am3517_evm_panel_disable_lcd,
122};
123
124static int am3517_evm_panel_enable_tv(struct omap_dss_device *dssdev)
125{
126 return 0;
127}
128
129static void am3517_evm_panel_disable_tv(struct omap_dss_device *dssdev)
130{
131}
132
133static struct omap_dss_device am3517_evm_tv_device = {
134 .type = OMAP_DISPLAY_TYPE_VENC,
135 .name = "tv",
136 .driver_name = "venc",
137 .phy.venc.type = OMAP_DSS_VENC_TYPE_SVIDEO,
138 .platform_enable = am3517_evm_panel_enable_tv,
139 .platform_disable = am3517_evm_panel_disable_tv,
140};
141
142static int am3517_evm_panel_enable_dvi(struct omap_dss_device *dssdev)
143{
144 if (lcd_enabled) {
145 printk(KERN_ERR "cannot enable DVI, LCD is enabled\n");
146 return -EINVAL;
147 }
148 dvi_enabled = 1;
149
150 return 0;
151}
152
153static void am3517_evm_panel_disable_dvi(struct omap_dss_device *dssdev)
154{
155 dvi_enabled = 0;
156}
157
158static struct omap_dss_device am3517_evm_dvi_device = {
159 .type = OMAP_DISPLAY_TYPE_DPI,
160 .name = "dvi",
161 .driver_name = "generic_panel",
162 .phy.dpi.data_lines = 24,
163 .platform_enable = am3517_evm_panel_enable_dvi,
164 .platform_disable = am3517_evm_panel_disable_dvi,
165};
166
167static struct omap_dss_device *am3517_evm_dss_devices[] = {
168 &am3517_evm_lcd_device,
169 &am3517_evm_tv_device,
170 &am3517_evm_dvi_device,
171};
172
173static struct omap_dss_board_info am3517_evm_dss_data = {
174 .num_devices = ARRAY_SIZE(am3517_evm_dss_devices),
175 .devices = am3517_evm_dss_devices,
176 .default_device = &am3517_evm_lcd_device,
177};
178
179struct platform_device am3517_evm_dss_device = {
180 .name = "omapdss",
181 .id = -1,
182 .dev = {
183 .platform_data = &am3517_evm_dss_data,
184 },
185};
186
Ranjith Lohithakshanc6253272009-11-18 18:41:09 -0800187/*
188 * Board initialization
189 */
190static struct omap_board_config_kernel am3517_evm_config[] __initdata = {
191};
192
193static struct platform_device *am3517_evm_devices[] __initdata = {
Vaibhav Hiremathc3d33322010-01-13 17:17:10 +0530194 &am3517_evm_dss_device,
Ranjith Lohithakshanc6253272009-11-18 18:41:09 -0800195};
196
197static void __init am3517_evm_init_irq(void)
198{
199 omap_board_config = am3517_evm_config;
200 omap_board_config_size = ARRAY_SIZE(am3517_evm_config);
201
202 omap2_init_common_hw(NULL, NULL);
203 omap_init_irq();
204 omap_gpio_init();
205}
206
207static struct ehci_hcd_omap_platform_data ehci_pdata __initdata = {
208 .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
209 .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY,
210 .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
211
212 .phy_reset = true,
213 .reset_gpio_port[0] = 57,
214 .reset_gpio_port[1] = -EINVAL,
215 .reset_gpio_port[2] = -EINVAL
216};
217
Tony Lindgrenca5742b2009-12-11 16:16:32 -0800218#ifdef CONFIG_OMAP_MUX
219static struct omap_board_mux board_mux[] __initdata = {
220 { .reg_offset = OMAP_MUX_TERMINATOR },
221};
222#else
223#define board_mux NULL
224#endif
225
Ranjith Lohithakshanc6253272009-11-18 18:41:09 -0800226static void __init am3517_evm_init(void)
227{
Vaibhav Hiremath1f738dc2010-02-17 14:09:28 -0800228 am3517_evm_i2c_init();
229
Tony Lindgrenca5742b2009-12-11 16:16:32 -0800230 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
Ranjith Lohithakshanc6253272009-11-18 18:41:09 -0800231 platform_add_devices(am3517_evm_devices,
232 ARRAY_SIZE(am3517_evm_devices));
233
234 omap_serial_init();
235 usb_ehci_init(&ehci_pdata);
Vaibhav Hiremathc3d33322010-01-13 17:17:10 +0530236 /* DSS */
237 am3517_evm_display_init();
Ranjith Lohithakshanc6253272009-11-18 18:41:09 -0800238}
239
240static void __init am3517_evm_map_io(void)
241{
242 omap2_set_globals_343x();
Tony Lindgren6fbd55d2010-02-12 12:26:47 -0800243 omap34xx_map_common_io();
Ranjith Lohithakshanc6253272009-11-18 18:41:09 -0800244}
245
246MACHINE_START(OMAP3517EVM, "OMAP3517/AM3517 EVM")
247 .phys_io = 0x48000000,
248 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
249 .boot_params = 0x80000100,
250 .map_io = am3517_evm_map_io,
251 .init_irq = am3517_evm_init_irq,
252 .init_machine = am3517_evm_init,
253 .timer = &omap_timer,
254MACHINE_END