blob: 9ac9de6bb97066ddd4d086faf1d0d3a097a191f9 [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>
Sriram917336312010-05-10 14:29:16 -070024#include <linux/can/platform/ti_hecc.h>
Sriram56881d22010-05-10 14:29:17 -070025#include <linux/davinci_emac.h>
Ranjith Lohithakshanc6253272009-11-18 18:41:09 -080026
27#include <mach/hardware.h>
Vaibhav Hiremathe3d4d0a2010-02-15 10:03:35 -080028#include <mach/am35xx.h>
Ranjith Lohithakshanc6253272009-11-18 18:41:09 -080029#include <asm/mach-types.h>
30#include <asm/mach/arch.h>
31#include <asm/mach/map.h>
32
33#include <plat/board.h>
34#include <plat/common.h>
Sriram56881d22010-05-10 14:29:17 -070035#include <plat/control.h>
Ranjith Lohithakshanc6253272009-11-18 18:41:09 -080036#include <plat/usb.h>
Vaibhav Hiremathc3d33322010-01-13 17:17:10 +053037#include <plat/display.h>
Ranjith Lohithakshanc6253272009-11-18 18:41:09 -080038
Tony Lindgrenca5742b2009-12-11 16:16:32 -080039#include "mux.h"
40
Sriram56881d22010-05-10 14:29:17 -070041#define AM35XX_EVM_PHY_MASK (0xF)
42#define AM35XX_EVM_MDIO_FREQUENCY (1000000)
43
44static struct emac_platform_data am3517_evm_emac_pdata = {
45 .phy_mask = AM35XX_EVM_PHY_MASK,
46 .mdio_max_freq = AM35XX_EVM_MDIO_FREQUENCY,
47 .rmii_en = 1,
48};
49
50static struct resource am3517_emac_resources[] = {
51 {
52 .start = AM35XX_IPSS_EMAC_BASE,
53 .end = AM35XX_IPSS_EMAC_BASE + 0x3FFFF,
54 .flags = IORESOURCE_MEM,
55 },
56 {
57 .start = INT_35XX_EMAC_C0_RXTHRESH_IRQ,
58 .end = INT_35XX_EMAC_C0_RXTHRESH_IRQ,
59 .flags = IORESOURCE_IRQ,
60 },
61 {
62 .start = INT_35XX_EMAC_C0_RX_PULSE_IRQ,
63 .end = INT_35XX_EMAC_C0_RX_PULSE_IRQ,
64 .flags = IORESOURCE_IRQ,
65 },
66 {
67 .start = INT_35XX_EMAC_C0_TX_PULSE_IRQ,
68 .end = INT_35XX_EMAC_C0_TX_PULSE_IRQ,
69 .flags = IORESOURCE_IRQ,
70 },
71 {
72 .start = INT_35XX_EMAC_C0_MISC_PULSE_IRQ,
73 .end = INT_35XX_EMAC_C0_MISC_PULSE_IRQ,
74 .flags = IORESOURCE_IRQ,
75 },
76};
77
78static struct platform_device am3517_emac_device = {
79 .name = "davinci_emac",
80 .id = -1,
81 .num_resources = ARRAY_SIZE(am3517_emac_resources),
82 .resource = am3517_emac_resources,
83};
84
85static void am3517_enable_ethernet_int(void)
86{
87 u32 regval;
88
89 regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
90 regval = (regval | AM35XX_CPGMAC_C0_RX_PULSE_CLR |
91 AM35XX_CPGMAC_C0_TX_PULSE_CLR |
92 AM35XX_CPGMAC_C0_MISC_PULSE_CLR |
93 AM35XX_CPGMAC_C0_RX_THRESH_CLR);
94 omap_ctrl_writel(regval, AM35XX_CONTROL_LVL_INTR_CLEAR);
95 regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
96}
97
98static void am3517_disable_ethernet_int(void)
99{
100 u32 regval;
101
102 regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
103 regval = (regval | AM35XX_CPGMAC_C0_RX_PULSE_CLR |
104 AM35XX_CPGMAC_C0_TX_PULSE_CLR);
105 omap_ctrl_writel(regval, AM35XX_CONTROL_LVL_INTR_CLEAR);
106 regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
107}
108
109void am3517_evm_ethernet_init(struct emac_platform_data *pdata)
110{
111 unsigned int regval;
112
113 pdata->ctrl_reg_offset = AM35XX_EMAC_CNTRL_OFFSET;
114 pdata->ctrl_mod_reg_offset = AM35XX_EMAC_CNTRL_MOD_OFFSET;
115 pdata->ctrl_ram_offset = AM35XX_EMAC_CNTRL_RAM_OFFSET;
116 pdata->mdio_reg_offset = AM35XX_EMAC_MDIO_OFFSET;
117 pdata->ctrl_ram_size = AM35XX_EMAC_CNTRL_RAM_SIZE;
118 pdata->version = EMAC_VERSION_2;
119 pdata->hw_ram_addr = AM35XX_EMAC_HW_RAM_ADDR;
120 pdata->interrupt_enable = am3517_enable_ethernet_int;
121 pdata->interrupt_disable = am3517_disable_ethernet_int;
122 am3517_emac_device.dev.platform_data = pdata;
123 platform_device_register(&am3517_emac_device);
124
125 regval = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET);
126 regval = regval & (~(AM35XX_CPGMACSS_SW_RST));
127 omap_ctrl_writel(regval, AM35XX_CONTROL_IP_SW_RESET);
128 regval = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET);
129
130 return ;
131}
132
133
134
Vaibhav Hiremathc3d33322010-01-13 17:17:10 +0530135#define LCD_PANEL_PWR 176
136#define LCD_PANEL_BKLIGHT_PWR 182
137#define LCD_PANEL_PWM 181
138
stanley.miaob91da662010-05-13 12:39:29 +0000139static struct i2c_board_info __initdata am3517evm_i2c1_boardinfo[] = {
Vaibhav Hiremathf2afbbb2010-02-13 11:47:56 +0000140 {
141 I2C_BOARD_INFO("s35390a", 0x30),
142 .type = "s35390a",
143 },
144};
145
146/*
147 * RTC - S35390A
148 */
149#define GPIO_RTCS35390A_IRQ 55
150
151static void __init am3517_evm_rtc_init(void)
152{
153 int r;
154
155 omap_mux_init_gpio(GPIO_RTCS35390A_IRQ, OMAP_PIN_INPUT_PULLUP);
156 r = gpio_request(GPIO_RTCS35390A_IRQ, "rtcs35390a-irq");
157 if (r < 0) {
158 printk(KERN_WARNING "failed to request GPIO#%d\n",
159 GPIO_RTCS35390A_IRQ);
160 return;
161 }
162 r = gpio_direction_input(GPIO_RTCS35390A_IRQ);
163 if (r < 0) {
164 printk(KERN_WARNING "GPIO#%d cannot be configured as input\n",
165 GPIO_RTCS35390A_IRQ);
166 gpio_free(GPIO_RTCS35390A_IRQ);
167 return;
168 }
stanley.miaob91da662010-05-13 12:39:29 +0000169 am3517evm_i2c1_boardinfo[0].irq = gpio_to_irq(GPIO_RTCS35390A_IRQ);
Vaibhav Hiremathf2afbbb2010-02-13 11:47:56 +0000170}
171
Vaibhav Hiremath5d4292a2010-02-13 11:47:57 +0000172/*
173 * I2C GPIO Expander - TCA6416
174 */
175
176/* Mounted on Base-Board */
177static struct pca953x_platform_data am3517evm_gpio_expander_info_0 = {
178 .gpio_base = OMAP_MAX_GPIO_LINES,
179};
stanley.miaob91da662010-05-13 12:39:29 +0000180static struct i2c_board_info __initdata am3517evm_i2c2_boardinfo[] = {
Vaibhav Hiremath5d4292a2010-02-13 11:47:57 +0000181 {
182 I2C_BOARD_INFO("tca6416", 0x21),
183 .platform_data = &am3517evm_gpio_expander_info_0,
184 },
185};
186
187/* Mounted on UI Card */
188static struct pca953x_platform_data am3517evm_ui_gpio_expander_info_1 = {
189 .gpio_base = OMAP_MAX_GPIO_LINES + 16,
190};
191static struct pca953x_platform_data am3517evm_ui_gpio_expander_info_2 = {
192 .gpio_base = OMAP_MAX_GPIO_LINES + 32,
193};
stanley.miaob91da662010-05-13 12:39:29 +0000194static struct i2c_board_info __initdata am3517evm_i2c3_boardinfo[] = {
Vaibhav Hiremath5d4292a2010-02-13 11:47:57 +0000195 {
196 I2C_BOARD_INFO("tca6416", 0x20),
197 .platform_data = &am3517evm_ui_gpio_expander_info_1,
198 },
199 {
200 I2C_BOARD_INFO("tca6416", 0x21),
201 .platform_data = &am3517evm_ui_gpio_expander_info_2,
202 },
203};
204
Vaibhav Hiremath1f738dc2010-02-17 14:09:28 -0800205static int __init am3517_evm_i2c_init(void)
206{
207 omap_register_i2c_bus(1, 400, NULL, 0);
stanley.miaob91da662010-05-13 12:39:29 +0000208 omap_register_i2c_bus(2, 400, am3517evm_i2c2_boardinfo,
209 ARRAY_SIZE(am3517evm_i2c2_boardinfo));
210 omap_register_i2c_bus(3, 400, am3517evm_i2c3_boardinfo,
211 ARRAY_SIZE(am3517evm_i2c3_boardinfo));
Vaibhav Hiremath1f738dc2010-02-17 14:09:28 -0800212
213 return 0;
214}
215
Vaibhav Hiremathc3d33322010-01-13 17:17:10 +0530216static int lcd_enabled;
217static int dvi_enabled;
218
Ajay Kumar Guptade997712010-05-10 14:29:19 -0700219#if defined(CONFIG_PANEL_SHARP_LQ043T1DG01) || \
220 defined(CONFIG_PANEL_SHARP_LQ043T1DG01_MODULE)
Vaibhav Hiremathc3d33322010-01-13 17:17:10 +0530221static void __init am3517_evm_display_init(void)
222{
223 int r;
224
225 omap_mux_init_gpio(LCD_PANEL_PWR, OMAP_PIN_INPUT_PULLUP);
226 omap_mux_init_gpio(LCD_PANEL_BKLIGHT_PWR, OMAP_PIN_INPUT_PULLDOWN);
227 omap_mux_init_gpio(LCD_PANEL_PWM, OMAP_PIN_INPUT_PULLDOWN);
228 /*
229 * Enable GPIO 182 = LCD Backlight Power
230 */
231 r = gpio_request(LCD_PANEL_BKLIGHT_PWR, "lcd_backlight_pwr");
232 if (r) {
233 printk(KERN_ERR "failed to get lcd_backlight_pwr\n");
234 return;
235 }
236 gpio_direction_output(LCD_PANEL_BKLIGHT_PWR, 1);
237 /*
238 * Enable GPIO 181 = LCD Panel PWM
239 */
240 r = gpio_request(LCD_PANEL_PWM, "lcd_pwm");
241 if (r) {
242 printk(KERN_ERR "failed to get lcd_pwm\n");
243 goto err_1;
244 }
245 gpio_direction_output(LCD_PANEL_PWM, 1);
246 /*
247 * Enable GPIO 176 = LCD Panel Power enable pin
248 */
249 r = gpio_request(LCD_PANEL_PWR, "lcd_panel_pwr");
250 if (r) {
251 printk(KERN_ERR "failed to get lcd_panel_pwr\n");
252 goto err_2;
253 }
254 gpio_direction_output(LCD_PANEL_PWR, 1);
255
256 printk(KERN_INFO "Display initialized successfully\n");
257 return;
258
259err_2:
260 gpio_free(LCD_PANEL_PWM);
261err_1:
262 gpio_free(LCD_PANEL_BKLIGHT_PWR);
263}
Ajay Kumar Guptade997712010-05-10 14:29:19 -0700264#else
265static void __init am3517_evm_display_init(void) {}
266#endif
Vaibhav Hiremathc3d33322010-01-13 17:17:10 +0530267
268static int am3517_evm_panel_enable_lcd(struct omap_dss_device *dssdev)
269{
270 if (dvi_enabled) {
271 printk(KERN_ERR "cannot enable LCD, DVI is enabled\n");
272 return -EINVAL;
273 }
274 gpio_set_value(LCD_PANEL_PWR, 1);
275 lcd_enabled = 1;
276
277 return 0;
278}
279
280static void am3517_evm_panel_disable_lcd(struct omap_dss_device *dssdev)
281{
282 gpio_set_value(LCD_PANEL_PWR, 0);
283 lcd_enabled = 0;
284}
285
286static struct omap_dss_device am3517_evm_lcd_device = {
287 .type = OMAP_DISPLAY_TYPE_DPI,
288 .name = "lcd",
289 .driver_name = "sharp_lq_panel",
290 .phy.dpi.data_lines = 16,
291 .platform_enable = am3517_evm_panel_enable_lcd,
292 .platform_disable = am3517_evm_panel_disable_lcd,
293};
294
295static int am3517_evm_panel_enable_tv(struct omap_dss_device *dssdev)
296{
297 return 0;
298}
299
300static void am3517_evm_panel_disable_tv(struct omap_dss_device *dssdev)
301{
302}
303
304static struct omap_dss_device am3517_evm_tv_device = {
305 .type = OMAP_DISPLAY_TYPE_VENC,
306 .name = "tv",
307 .driver_name = "venc",
308 .phy.venc.type = OMAP_DSS_VENC_TYPE_SVIDEO,
309 .platform_enable = am3517_evm_panel_enable_tv,
310 .platform_disable = am3517_evm_panel_disable_tv,
311};
312
313static int am3517_evm_panel_enable_dvi(struct omap_dss_device *dssdev)
314{
315 if (lcd_enabled) {
316 printk(KERN_ERR "cannot enable DVI, LCD is enabled\n");
317 return -EINVAL;
318 }
319 dvi_enabled = 1;
320
321 return 0;
322}
323
324static void am3517_evm_panel_disable_dvi(struct omap_dss_device *dssdev)
325{
326 dvi_enabled = 0;
327}
328
329static struct omap_dss_device am3517_evm_dvi_device = {
330 .type = OMAP_DISPLAY_TYPE_DPI,
331 .name = "dvi",
332 .driver_name = "generic_panel",
333 .phy.dpi.data_lines = 24,
334 .platform_enable = am3517_evm_panel_enable_dvi,
335 .platform_disable = am3517_evm_panel_disable_dvi,
336};
337
338static struct omap_dss_device *am3517_evm_dss_devices[] = {
339 &am3517_evm_lcd_device,
340 &am3517_evm_tv_device,
341 &am3517_evm_dvi_device,
342};
343
344static struct omap_dss_board_info am3517_evm_dss_data = {
345 .num_devices = ARRAY_SIZE(am3517_evm_dss_devices),
346 .devices = am3517_evm_dss_devices,
347 .default_device = &am3517_evm_lcd_device,
348};
349
350struct platform_device am3517_evm_dss_device = {
351 .name = "omapdss",
352 .id = -1,
353 .dev = {
354 .platform_data = &am3517_evm_dss_data,
355 },
356};
357
Ranjith Lohithakshanc6253272009-11-18 18:41:09 -0800358/*
359 * Board initialization
360 */
361static struct omap_board_config_kernel am3517_evm_config[] __initdata = {
362};
363
364static struct platform_device *am3517_evm_devices[] __initdata = {
Vaibhav Hiremathc3d33322010-01-13 17:17:10 +0530365 &am3517_evm_dss_device,
Ranjith Lohithakshanc6253272009-11-18 18:41:09 -0800366};
367
368static void __init am3517_evm_init_irq(void)
369{
370 omap_board_config = am3517_evm_config;
371 omap_board_config_size = ARRAY_SIZE(am3517_evm_config);
372
373 omap2_init_common_hw(NULL, NULL);
374 omap_init_irq();
375 omap_gpio_init();
376}
377
Ajay Kumar Gupta3a0d30b2010-10-19 10:08:11 +0300378static struct omap_musb_board_data musb_board_data = {
379 .interface_type = MUSB_INTERFACE_ULPI,
380 .mode = MUSB_OTG,
381 .power = 500,
382};
383
384static __init void am3517_evm_musb_init(void)
385{
386 u32 devconf2;
387
388 /*
389 * Set up USB clock/mode in the DEVCONF2 register.
390 */
391 devconf2 = omap_ctrl_readl(AM35XX_CONTROL_DEVCONF2);
392
393 /* USB2.0 PHY reference clock is 13 MHz */
394 devconf2 &= ~(CONF2_REFFREQ | CONF2_OTGMODE | CONF2_PHY_GPIOMODE);
395 devconf2 |= CONF2_REFFREQ_13MHZ | CONF2_SESENDEN | CONF2_VBDTCTEN
396 | CONF2_DATPOL;
397
398 omap_ctrl_writel(devconf2, AM35XX_CONTROL_DEVCONF2);
399
400 usb_musb_init(&musb_board_data);
401}
402
Felipe Balbi6f69a182010-03-04 09:45:53 +0200403static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
Ranjith Lohithakshanc6253272009-11-18 18:41:09 -0800404 .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
Ajay Kumar Guptade997712010-05-10 14:29:19 -0700405#if defined(CONFIG_PANEL_SHARP_LQ043T1DG01) || \
406 defined(CONFIG_PANEL_SHARP_LQ043T1DG01_MODULE)
407 .port_mode[1] = EHCI_HCD_OMAP_MODE_UNKNOWN,
408#else
Ranjith Lohithakshanc6253272009-11-18 18:41:09 -0800409 .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY,
Ajay Kumar Guptade997712010-05-10 14:29:19 -0700410#endif
Ranjith Lohithakshanc6253272009-11-18 18:41:09 -0800411 .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
412
413 .phy_reset = true,
414 .reset_gpio_port[0] = 57,
415 .reset_gpio_port[1] = -EINVAL,
416 .reset_gpio_port[2] = -EINVAL
417};
418
Tony Lindgrenca5742b2009-12-11 16:16:32 -0800419#ifdef CONFIG_OMAP_MUX
420static struct omap_board_mux board_mux[] __initdata = {
Ajay Kumar Gupta3a0d30b2010-10-19 10:08:11 +0300421 /* USB OTG DRVVBUS offset = 0x212 */
422 OMAP3_MUX(SAD2D_MCAD23, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLDOWN),
Tony Lindgrenca5742b2009-12-11 16:16:32 -0800423 { .reg_offset = OMAP_MUX_TERMINATOR },
424};
425#else
426#define board_mux NULL
427#endif
428
Sriram917336312010-05-10 14:29:16 -0700429
430static struct resource am3517_hecc_resources[] = {
431 {
432 .start = AM35XX_IPSS_HECC_BASE,
433 .end = AM35XX_IPSS_HECC_BASE + 0x3FFF,
434 .flags = IORESOURCE_MEM,
435 },
436 {
437 .start = INT_35XX_HECC0_IRQ,
438 .end = INT_35XX_HECC0_IRQ,
439 .flags = IORESOURCE_IRQ,
440 },
441};
442
443static struct platform_device am3517_hecc_device = {
444 .name = "ti_hecc",
445 .id = -1,
446 .num_resources = ARRAY_SIZE(am3517_hecc_resources),
447 .resource = am3517_hecc_resources,
448};
449
450static struct ti_hecc_platform_data am3517_evm_hecc_pdata = {
451 .scc_hecc_offset = AM35XX_HECC_SCC_HECC_OFFSET,
452 .scc_ram_offset = AM35XX_HECC_SCC_RAM_OFFSET,
453 .hecc_ram_offset = AM35XX_HECC_RAM_OFFSET,
454 .mbx_offset = AM35XX_HECC_MBOX_OFFSET,
455 .int_line = AM35XX_HECC_INT_LINE,
456 .version = AM35XX_HECC_VERSION,
457};
458
459static void am3517_evm_hecc_init(struct ti_hecc_platform_data *pdata)
460{
461 am3517_hecc_device.dev.platform_data = pdata;
462 platform_device_register(&am3517_hecc_device);
463}
464
Ranjith Lohithakshanc6253272009-11-18 18:41:09 -0800465static void __init am3517_evm_init(void)
466{
Tony Lindgrenca5742b2009-12-11 16:16:32 -0800467 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
stanley.miao5241b6b2010-04-20 06:33:29 +0000468
469 am3517_evm_i2c_init();
Ranjith Lohithakshanc6253272009-11-18 18:41:09 -0800470 platform_add_devices(am3517_evm_devices,
471 ARRAY_SIZE(am3517_evm_devices));
472
473 omap_serial_init();
Ajay Kumar Guptafec3eeb2010-02-22 10:21:12 +0000474
475 /* Configure GPIO for EHCI port */
476 omap_mux_init_gpio(57, OMAP_PIN_OUTPUT);
Ranjith Lohithakshanc6253272009-11-18 18:41:09 -0800477 usb_ehci_init(&ehci_pdata);
Sriram917336312010-05-10 14:29:16 -0700478 am3517_evm_hecc_init(&am3517_evm_hecc_pdata);
Vaibhav Hiremathc3d33322010-01-13 17:17:10 +0530479 /* DSS */
480 am3517_evm_display_init();
Vaibhav Hiremathf2afbbb2010-02-13 11:47:56 +0000481
482 /* RTC - S35390A */
483 am3517_evm_rtc_init();
484
stanley.miaob91da662010-05-13 12:39:29 +0000485 i2c_register_board_info(1, am3517evm_i2c1_boardinfo,
486 ARRAY_SIZE(am3517evm_i2c1_boardinfo));
Sriram56881d22010-05-10 14:29:17 -0700487 /*Ethernet*/
488 am3517_evm_ethernet_init(&am3517_evm_emac_pdata);
Ajay Kumar Gupta3a0d30b2010-10-19 10:08:11 +0300489
490 /* MUSB */
491 am3517_evm_musb_init();
Ranjith Lohithakshanc6253272009-11-18 18:41:09 -0800492}
493
Ranjith Lohithakshanc6253272009-11-18 18:41:09 -0800494MACHINE_START(OMAP3517EVM, "OMAP3517/AM3517 EVM")
495 .phys_io = 0x48000000,
496 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
497 .boot_params = 0x80000100,
Mike Rapoport869fef42010-08-04 14:43:18 +0300498 .map_io = omap3_map_io,
Russell King71ee7da2010-05-23 10:18:16 +0100499 .reserve = omap_reserve,
Ranjith Lohithakshanc6253272009-11-18 18:41:09 -0800500 .init_irq = am3517_evm_init_irq,
501 .init_machine = am3517_evm_init,
502 .timer = &omap_timer,
503MACHINE_END