blob: 6ca0075026ff348c20b494adf405b09b2a457678 [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>
Vaibhav Hiremath5d4292a2010-02-13 11:47:57 +000023#include <linux/i2c/pca953x.h>
Sriram91733632010-05-10 14:29:16 -070024#include <linux/can/platform/ti_hecc.h>
Ranjith Lohithakshanc6253272009-11-18 18:41:09 -080025
26#include <mach/hardware.h>
Vaibhav Hiremathe3d4d0a2010-02-15 10:03:35 -080027#include <mach/am35xx.h>
Ranjith Lohithakshanc6253272009-11-18 18:41:09 -080028#include <asm/mach-types.h>
29#include <asm/mach/arch.h>
30#include <asm/mach/map.h>
31
32#include <plat/board.h>
33#include <plat/common.h>
34#include <plat/usb.h>
Vaibhav Hiremathc3d33322010-01-13 17:17:10 +053035#include <plat/display.h>
Ranjith Lohithakshanc6253272009-11-18 18:41:09 -080036
Tony Lindgrenca5742b2009-12-11 16:16:32 -080037#include "mux.h"
38
Vaibhav Hiremathc3d33322010-01-13 17:17:10 +053039#define LCD_PANEL_PWR 176
40#define LCD_PANEL_BKLIGHT_PWR 182
41#define LCD_PANEL_PWM 181
42
Vaibhav Hiremathf2afbbb2010-02-13 11:47:56 +000043static struct i2c_board_info __initdata am3517evm_i2c_boardinfo[] = {
44 {
45 I2C_BOARD_INFO("s35390a", 0x30),
46 .type = "s35390a",
47 },
48};
49
50/*
51 * RTC - S35390A
52 */
53#define GPIO_RTCS35390A_IRQ 55
54
55static void __init am3517_evm_rtc_init(void)
56{
57 int r;
58
59 omap_mux_init_gpio(GPIO_RTCS35390A_IRQ, OMAP_PIN_INPUT_PULLUP);
60 r = gpio_request(GPIO_RTCS35390A_IRQ, "rtcs35390a-irq");
61 if (r < 0) {
62 printk(KERN_WARNING "failed to request GPIO#%d\n",
63 GPIO_RTCS35390A_IRQ);
64 return;
65 }
66 r = gpio_direction_input(GPIO_RTCS35390A_IRQ);
67 if (r < 0) {
68 printk(KERN_WARNING "GPIO#%d cannot be configured as input\n",
69 GPIO_RTCS35390A_IRQ);
70 gpio_free(GPIO_RTCS35390A_IRQ);
71 return;
72 }
73 am3517evm_i2c_boardinfo[0].irq = gpio_to_irq(GPIO_RTCS35390A_IRQ);
74}
75
Vaibhav Hiremath5d4292a2010-02-13 11:47:57 +000076/*
77 * I2C GPIO Expander - TCA6416
78 */
79
80/* Mounted on Base-Board */
81static struct pca953x_platform_data am3517evm_gpio_expander_info_0 = {
82 .gpio_base = OMAP_MAX_GPIO_LINES,
83};
Sriram7b97f3e2010-02-25 10:45:49 +000084static struct i2c_board_info __initdata am3517evm_tca6416_info_0[] = {
Vaibhav Hiremath5d4292a2010-02-13 11:47:57 +000085 {
86 I2C_BOARD_INFO("tca6416", 0x21),
87 .platform_data = &am3517evm_gpio_expander_info_0,
88 },
89};
90
91/* Mounted on UI Card */
92static struct pca953x_platform_data am3517evm_ui_gpio_expander_info_1 = {
93 .gpio_base = OMAP_MAX_GPIO_LINES + 16,
94};
95static struct pca953x_platform_data am3517evm_ui_gpio_expander_info_2 = {
96 .gpio_base = OMAP_MAX_GPIO_LINES + 32,
97};
Sriram7b97f3e2010-02-25 10:45:49 +000098static struct i2c_board_info __initdata am3517evm_ui_tca6416_info[] = {
Vaibhav Hiremath5d4292a2010-02-13 11:47:57 +000099 {
100 I2C_BOARD_INFO("tca6416", 0x20),
101 .platform_data = &am3517evm_ui_gpio_expander_info_1,
102 },
103 {
104 I2C_BOARD_INFO("tca6416", 0x21),
105 .platform_data = &am3517evm_ui_gpio_expander_info_2,
106 },
107};
108
Vaibhav Hiremath1f738dc2010-02-17 14:09:28 -0800109static int __init am3517_evm_i2c_init(void)
110{
111 omap_register_i2c_bus(1, 400, NULL, 0);
Sriram7b97f3e2010-02-25 10:45:49 +0000112 omap_register_i2c_bus(2, 400, am3517evm_tca6416_info_0,
113 ARRAY_SIZE(am3517evm_tca6416_info_0));
114 omap_register_i2c_bus(3, 400, am3517evm_ui_tca6416_info,
115 ARRAY_SIZE(am3517evm_ui_tca6416_info));
Vaibhav Hiremath1f738dc2010-02-17 14:09:28 -0800116
117 return 0;
118}
119
Vaibhav Hiremathc3d33322010-01-13 17:17:10 +0530120static int lcd_enabled;
121static int dvi_enabled;
122
123static void __init am3517_evm_display_init(void)
124{
125 int r;
126
127 omap_mux_init_gpio(LCD_PANEL_PWR, OMAP_PIN_INPUT_PULLUP);
128 omap_mux_init_gpio(LCD_PANEL_BKLIGHT_PWR, OMAP_PIN_INPUT_PULLDOWN);
129 omap_mux_init_gpio(LCD_PANEL_PWM, OMAP_PIN_INPUT_PULLDOWN);
130 /*
131 * Enable GPIO 182 = LCD Backlight Power
132 */
133 r = gpio_request(LCD_PANEL_BKLIGHT_PWR, "lcd_backlight_pwr");
134 if (r) {
135 printk(KERN_ERR "failed to get lcd_backlight_pwr\n");
136 return;
137 }
138 gpio_direction_output(LCD_PANEL_BKLIGHT_PWR, 1);
139 /*
140 * Enable GPIO 181 = LCD Panel PWM
141 */
142 r = gpio_request(LCD_PANEL_PWM, "lcd_pwm");
143 if (r) {
144 printk(KERN_ERR "failed to get lcd_pwm\n");
145 goto err_1;
146 }
147 gpio_direction_output(LCD_PANEL_PWM, 1);
148 /*
149 * Enable GPIO 176 = LCD Panel Power enable pin
150 */
151 r = gpio_request(LCD_PANEL_PWR, "lcd_panel_pwr");
152 if (r) {
153 printk(KERN_ERR "failed to get lcd_panel_pwr\n");
154 goto err_2;
155 }
156 gpio_direction_output(LCD_PANEL_PWR, 1);
157
158 printk(KERN_INFO "Display initialized successfully\n");
159 return;
160
161err_2:
162 gpio_free(LCD_PANEL_PWM);
163err_1:
164 gpio_free(LCD_PANEL_BKLIGHT_PWR);
165}
166
167static int am3517_evm_panel_enable_lcd(struct omap_dss_device *dssdev)
168{
169 if (dvi_enabled) {
170 printk(KERN_ERR "cannot enable LCD, DVI is enabled\n");
171 return -EINVAL;
172 }
173 gpio_set_value(LCD_PANEL_PWR, 1);
174 lcd_enabled = 1;
175
176 return 0;
177}
178
179static void am3517_evm_panel_disable_lcd(struct omap_dss_device *dssdev)
180{
181 gpio_set_value(LCD_PANEL_PWR, 0);
182 lcd_enabled = 0;
183}
184
185static struct omap_dss_device am3517_evm_lcd_device = {
186 .type = OMAP_DISPLAY_TYPE_DPI,
187 .name = "lcd",
188 .driver_name = "sharp_lq_panel",
189 .phy.dpi.data_lines = 16,
190 .platform_enable = am3517_evm_panel_enable_lcd,
191 .platform_disable = am3517_evm_panel_disable_lcd,
192};
193
194static int am3517_evm_panel_enable_tv(struct omap_dss_device *dssdev)
195{
196 return 0;
197}
198
199static void am3517_evm_panel_disable_tv(struct omap_dss_device *dssdev)
200{
201}
202
203static struct omap_dss_device am3517_evm_tv_device = {
204 .type = OMAP_DISPLAY_TYPE_VENC,
205 .name = "tv",
206 .driver_name = "venc",
207 .phy.venc.type = OMAP_DSS_VENC_TYPE_SVIDEO,
208 .platform_enable = am3517_evm_panel_enable_tv,
209 .platform_disable = am3517_evm_panel_disable_tv,
210};
211
212static int am3517_evm_panel_enable_dvi(struct omap_dss_device *dssdev)
213{
214 if (lcd_enabled) {
215 printk(KERN_ERR "cannot enable DVI, LCD is enabled\n");
216 return -EINVAL;
217 }
218 dvi_enabled = 1;
219
220 return 0;
221}
222
223static void am3517_evm_panel_disable_dvi(struct omap_dss_device *dssdev)
224{
225 dvi_enabled = 0;
226}
227
228static struct omap_dss_device am3517_evm_dvi_device = {
229 .type = OMAP_DISPLAY_TYPE_DPI,
230 .name = "dvi",
231 .driver_name = "generic_panel",
232 .phy.dpi.data_lines = 24,
233 .platform_enable = am3517_evm_panel_enable_dvi,
234 .platform_disable = am3517_evm_panel_disable_dvi,
235};
236
237static struct omap_dss_device *am3517_evm_dss_devices[] = {
238 &am3517_evm_lcd_device,
239 &am3517_evm_tv_device,
240 &am3517_evm_dvi_device,
241};
242
243static struct omap_dss_board_info am3517_evm_dss_data = {
244 .num_devices = ARRAY_SIZE(am3517_evm_dss_devices),
245 .devices = am3517_evm_dss_devices,
246 .default_device = &am3517_evm_lcd_device,
247};
248
249struct platform_device am3517_evm_dss_device = {
250 .name = "omapdss",
251 .id = -1,
252 .dev = {
253 .platform_data = &am3517_evm_dss_data,
254 },
255};
256
Ranjith Lohithakshanc6253272009-11-18 18:41:09 -0800257/*
258 * Board initialization
259 */
260static struct omap_board_config_kernel am3517_evm_config[] __initdata = {
261};
262
263static struct platform_device *am3517_evm_devices[] __initdata = {
Vaibhav Hiremathc3d33322010-01-13 17:17:10 +0530264 &am3517_evm_dss_device,
Ranjith Lohithakshanc6253272009-11-18 18:41:09 -0800265};
266
267static void __init am3517_evm_init_irq(void)
268{
269 omap_board_config = am3517_evm_config;
270 omap_board_config_size = ARRAY_SIZE(am3517_evm_config);
271
272 omap2_init_common_hw(NULL, NULL);
273 omap_init_irq();
274 omap_gpio_init();
275}
276
Felipe Balbi6f69a182010-03-04 09:45:53 +0200277static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
Ranjith Lohithakshanc6253272009-11-18 18:41:09 -0800278 .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
279 .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY,
280 .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
281
282 .phy_reset = true,
283 .reset_gpio_port[0] = 57,
284 .reset_gpio_port[1] = -EINVAL,
285 .reset_gpio_port[2] = -EINVAL
286};
287
Tony Lindgrenca5742b2009-12-11 16:16:32 -0800288#ifdef CONFIG_OMAP_MUX
289static struct omap_board_mux board_mux[] __initdata = {
290 { .reg_offset = OMAP_MUX_TERMINATOR },
291};
292#else
293#define board_mux NULL
294#endif
295
Sriram91733632010-05-10 14:29:16 -0700296
297static struct resource am3517_hecc_resources[] = {
298 {
299 .start = AM35XX_IPSS_HECC_BASE,
300 .end = AM35XX_IPSS_HECC_BASE + 0x3FFF,
301 .flags = IORESOURCE_MEM,
302 },
303 {
304 .start = INT_35XX_HECC0_IRQ,
305 .end = INT_35XX_HECC0_IRQ,
306 .flags = IORESOURCE_IRQ,
307 },
308};
309
310static struct platform_device am3517_hecc_device = {
311 .name = "ti_hecc",
312 .id = -1,
313 .num_resources = ARRAY_SIZE(am3517_hecc_resources),
314 .resource = am3517_hecc_resources,
315};
316
317static struct ti_hecc_platform_data am3517_evm_hecc_pdata = {
318 .scc_hecc_offset = AM35XX_HECC_SCC_HECC_OFFSET,
319 .scc_ram_offset = AM35XX_HECC_SCC_RAM_OFFSET,
320 .hecc_ram_offset = AM35XX_HECC_RAM_OFFSET,
321 .mbx_offset = AM35XX_HECC_MBOX_OFFSET,
322 .int_line = AM35XX_HECC_INT_LINE,
323 .version = AM35XX_HECC_VERSION,
324};
325
326static void am3517_evm_hecc_init(struct ti_hecc_platform_data *pdata)
327{
328 am3517_hecc_device.dev.platform_data = pdata;
329 platform_device_register(&am3517_hecc_device);
330}
331
Ranjith Lohithakshanc6253272009-11-18 18:41:09 -0800332static void __init am3517_evm_init(void)
333{
Tony Lindgrenca5742b2009-12-11 16:16:32 -0800334 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
stanley.miao5241b6b2010-04-20 06:33:29 +0000335
336 am3517_evm_i2c_init();
Ranjith Lohithakshanc6253272009-11-18 18:41:09 -0800337 platform_add_devices(am3517_evm_devices,
338 ARRAY_SIZE(am3517_evm_devices));
339
340 omap_serial_init();
Ajay Kumar Guptafec3eeb2010-02-22 10:21:12 +0000341
342 /* Configure GPIO for EHCI port */
343 omap_mux_init_gpio(57, OMAP_PIN_OUTPUT);
Ranjith Lohithakshanc6253272009-11-18 18:41:09 -0800344 usb_ehci_init(&ehci_pdata);
Sriram91733632010-05-10 14:29:16 -0700345 am3517_evm_hecc_init(&am3517_evm_hecc_pdata);
Vaibhav Hiremathc3d33322010-01-13 17:17:10 +0530346 /* DSS */
347 am3517_evm_display_init();
Vaibhav Hiremathf2afbbb2010-02-13 11:47:56 +0000348
349 /* RTC - S35390A */
350 am3517_evm_rtc_init();
351
352 i2c_register_board_info(1, am3517evm_i2c_boardinfo,
353 ARRAY_SIZE(am3517evm_i2c_boardinfo));
Ranjith Lohithakshanc6253272009-11-18 18:41:09 -0800354}
355
356static void __init am3517_evm_map_io(void)
357{
358 omap2_set_globals_343x();
Tony Lindgren6fbd55d2010-02-12 12:26:47 -0800359 omap34xx_map_common_io();
Ranjith Lohithakshanc6253272009-11-18 18:41:09 -0800360}
361
362MACHINE_START(OMAP3517EVM, "OMAP3517/AM3517 EVM")
363 .phys_io = 0x48000000,
364 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
365 .boot_params = 0x80000100,
366 .map_io = am3517_evm_map_io,
367 .init_irq = am3517_evm_init_irq,
368 .init_machine = am3517_evm_init,
369 .timer = &omap_timer,
370MACHINE_END