blob: fe2446ded5ad61806433470f9ff98f057b900991 [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 Hiremathf2afbbb2010-02-13 11:47:56 +000041static struct i2c_board_info __initdata am3517evm_i2c_boardinfo[] = {
42 {
43 I2C_BOARD_INFO("s35390a", 0x30),
44 .type = "s35390a",
45 },
46};
47
48/*
49 * RTC - S35390A
50 */
51#define GPIO_RTCS35390A_IRQ 55
52
53static void __init am3517_evm_rtc_init(void)
54{
55 int r;
56
57 omap_mux_init_gpio(GPIO_RTCS35390A_IRQ, OMAP_PIN_INPUT_PULLUP);
58 r = gpio_request(GPIO_RTCS35390A_IRQ, "rtcs35390a-irq");
59 if (r < 0) {
60 printk(KERN_WARNING "failed to request GPIO#%d\n",
61 GPIO_RTCS35390A_IRQ);
62 return;
63 }
64 r = gpio_direction_input(GPIO_RTCS35390A_IRQ);
65 if (r < 0) {
66 printk(KERN_WARNING "GPIO#%d cannot be configured as input\n",
67 GPIO_RTCS35390A_IRQ);
68 gpio_free(GPIO_RTCS35390A_IRQ);
69 return;
70 }
71 am3517evm_i2c_boardinfo[0].irq = gpio_to_irq(GPIO_RTCS35390A_IRQ);
72}
73
Vaibhav Hiremath1f738dc2010-02-17 14:09:28 -080074static int __init am3517_evm_i2c_init(void)
75{
76 omap_register_i2c_bus(1, 400, NULL, 0);
77 omap_register_i2c_bus(2, 400, NULL, 0);
78 omap_register_i2c_bus(3, 400, NULL, 0);
79
80 return 0;
81}
82
Vaibhav Hiremathc3d33322010-01-13 17:17:10 +053083static int lcd_enabled;
84static int dvi_enabled;
85
86static void __init am3517_evm_display_init(void)
87{
88 int r;
89
90 omap_mux_init_gpio(LCD_PANEL_PWR, OMAP_PIN_INPUT_PULLUP);
91 omap_mux_init_gpio(LCD_PANEL_BKLIGHT_PWR, OMAP_PIN_INPUT_PULLDOWN);
92 omap_mux_init_gpio(LCD_PANEL_PWM, OMAP_PIN_INPUT_PULLDOWN);
93 /*
94 * Enable GPIO 182 = LCD Backlight Power
95 */
96 r = gpio_request(LCD_PANEL_BKLIGHT_PWR, "lcd_backlight_pwr");
97 if (r) {
98 printk(KERN_ERR "failed to get lcd_backlight_pwr\n");
99 return;
100 }
101 gpio_direction_output(LCD_PANEL_BKLIGHT_PWR, 1);
102 /*
103 * Enable GPIO 181 = LCD Panel PWM
104 */
105 r = gpio_request(LCD_PANEL_PWM, "lcd_pwm");
106 if (r) {
107 printk(KERN_ERR "failed to get lcd_pwm\n");
108 goto err_1;
109 }
110 gpio_direction_output(LCD_PANEL_PWM, 1);
111 /*
112 * Enable GPIO 176 = LCD Panel Power enable pin
113 */
114 r = gpio_request(LCD_PANEL_PWR, "lcd_panel_pwr");
115 if (r) {
116 printk(KERN_ERR "failed to get lcd_panel_pwr\n");
117 goto err_2;
118 }
119 gpio_direction_output(LCD_PANEL_PWR, 1);
120
121 printk(KERN_INFO "Display initialized successfully\n");
122 return;
123
124err_2:
125 gpio_free(LCD_PANEL_PWM);
126err_1:
127 gpio_free(LCD_PANEL_BKLIGHT_PWR);
128}
129
130static int am3517_evm_panel_enable_lcd(struct omap_dss_device *dssdev)
131{
132 if (dvi_enabled) {
133 printk(KERN_ERR "cannot enable LCD, DVI is enabled\n");
134 return -EINVAL;
135 }
136 gpio_set_value(LCD_PANEL_PWR, 1);
137 lcd_enabled = 1;
138
139 return 0;
140}
141
142static void am3517_evm_panel_disable_lcd(struct omap_dss_device *dssdev)
143{
144 gpio_set_value(LCD_PANEL_PWR, 0);
145 lcd_enabled = 0;
146}
147
148static struct omap_dss_device am3517_evm_lcd_device = {
149 .type = OMAP_DISPLAY_TYPE_DPI,
150 .name = "lcd",
151 .driver_name = "sharp_lq_panel",
152 .phy.dpi.data_lines = 16,
153 .platform_enable = am3517_evm_panel_enable_lcd,
154 .platform_disable = am3517_evm_panel_disable_lcd,
155};
156
157static int am3517_evm_panel_enable_tv(struct omap_dss_device *dssdev)
158{
159 return 0;
160}
161
162static void am3517_evm_panel_disable_tv(struct omap_dss_device *dssdev)
163{
164}
165
166static struct omap_dss_device am3517_evm_tv_device = {
167 .type = OMAP_DISPLAY_TYPE_VENC,
168 .name = "tv",
169 .driver_name = "venc",
170 .phy.venc.type = OMAP_DSS_VENC_TYPE_SVIDEO,
171 .platform_enable = am3517_evm_panel_enable_tv,
172 .platform_disable = am3517_evm_panel_disable_tv,
173};
174
175static int am3517_evm_panel_enable_dvi(struct omap_dss_device *dssdev)
176{
177 if (lcd_enabled) {
178 printk(KERN_ERR "cannot enable DVI, LCD is enabled\n");
179 return -EINVAL;
180 }
181 dvi_enabled = 1;
182
183 return 0;
184}
185
186static void am3517_evm_panel_disable_dvi(struct omap_dss_device *dssdev)
187{
188 dvi_enabled = 0;
189}
190
191static struct omap_dss_device am3517_evm_dvi_device = {
192 .type = OMAP_DISPLAY_TYPE_DPI,
193 .name = "dvi",
194 .driver_name = "generic_panel",
195 .phy.dpi.data_lines = 24,
196 .platform_enable = am3517_evm_panel_enable_dvi,
197 .platform_disable = am3517_evm_panel_disable_dvi,
198};
199
200static struct omap_dss_device *am3517_evm_dss_devices[] = {
201 &am3517_evm_lcd_device,
202 &am3517_evm_tv_device,
203 &am3517_evm_dvi_device,
204};
205
206static struct omap_dss_board_info am3517_evm_dss_data = {
207 .num_devices = ARRAY_SIZE(am3517_evm_dss_devices),
208 .devices = am3517_evm_dss_devices,
209 .default_device = &am3517_evm_lcd_device,
210};
211
212struct platform_device am3517_evm_dss_device = {
213 .name = "omapdss",
214 .id = -1,
215 .dev = {
216 .platform_data = &am3517_evm_dss_data,
217 },
218};
219
Ranjith Lohithakshanc6253272009-11-18 18:41:09 -0800220/*
221 * Board initialization
222 */
223static struct omap_board_config_kernel am3517_evm_config[] __initdata = {
224};
225
226static struct platform_device *am3517_evm_devices[] __initdata = {
Vaibhav Hiremathc3d33322010-01-13 17:17:10 +0530227 &am3517_evm_dss_device,
Ranjith Lohithakshanc6253272009-11-18 18:41:09 -0800228};
229
230static void __init am3517_evm_init_irq(void)
231{
232 omap_board_config = am3517_evm_config;
233 omap_board_config_size = ARRAY_SIZE(am3517_evm_config);
234
235 omap2_init_common_hw(NULL, NULL);
236 omap_init_irq();
237 omap_gpio_init();
238}
239
240static struct ehci_hcd_omap_platform_data ehci_pdata __initdata = {
241 .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
242 .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY,
243 .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
244
245 .phy_reset = true,
246 .reset_gpio_port[0] = 57,
247 .reset_gpio_port[1] = -EINVAL,
248 .reset_gpio_port[2] = -EINVAL
249};
250
Tony Lindgrenca5742b2009-12-11 16:16:32 -0800251#ifdef CONFIG_OMAP_MUX
252static struct omap_board_mux board_mux[] __initdata = {
253 { .reg_offset = OMAP_MUX_TERMINATOR },
254};
255#else
256#define board_mux NULL
257#endif
258
Ranjith Lohithakshanc6253272009-11-18 18:41:09 -0800259static void __init am3517_evm_init(void)
260{
Vaibhav Hiremath1f738dc2010-02-17 14:09:28 -0800261 am3517_evm_i2c_init();
262
Tony Lindgrenca5742b2009-12-11 16:16:32 -0800263 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
Ranjith Lohithakshanc6253272009-11-18 18:41:09 -0800264 platform_add_devices(am3517_evm_devices,
265 ARRAY_SIZE(am3517_evm_devices));
266
267 omap_serial_init();
268 usb_ehci_init(&ehci_pdata);
Vaibhav Hiremathc3d33322010-01-13 17:17:10 +0530269 /* DSS */
270 am3517_evm_display_init();
Vaibhav Hiremathf2afbbb2010-02-13 11:47:56 +0000271
272 /* RTC - S35390A */
273 am3517_evm_rtc_init();
274
275 i2c_register_board_info(1, am3517evm_i2c_boardinfo,
276 ARRAY_SIZE(am3517evm_i2c_boardinfo));
Ranjith Lohithakshanc6253272009-11-18 18:41:09 -0800277}
278
279static void __init am3517_evm_map_io(void)
280{
281 omap2_set_globals_343x();
Tony Lindgren6fbd55d2010-02-12 12:26:47 -0800282 omap34xx_map_common_io();
Ranjith Lohithakshanc6253272009-11-18 18:41:09 -0800283}
284
285MACHINE_START(OMAP3517EVM, "OMAP3517/AM3517 EVM")
286 .phys_io = 0x48000000,
287 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
288 .boot_params = 0x80000100,
289 .map_io = am3517_evm_map_io,
290 .init_irq = am3517_evm_init_irq,
291 .init_machine = am3517_evm_init,
292 .timer = &omap_timer,
293MACHINE_END