2 * linux/arch/arm/mach-omap2/board-am3517evm.c
4 * Copyright (C) 2009 Texas Instruments Incorporated
5 * Author: Ranjith Lohithakshan <ranjithl@ti.com>
7 * Based on mach-omap2/board-omap3evm.c
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.
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.
19 #include <linux/kernel.h>
20 #include <linux/init.h>
21 #include <linux/platform_device.h>
22 #include <linux/gpio.h>
23 #include <linux/i2c/pca953x.h>
24 #include <linux/can/platform/ti_hecc.h>
25 #include <linux/davinci_emac.h>
27 #include <mach/hardware.h>
28 #include <mach/am35xx.h>
29 #include <asm/mach-types.h>
30 #include <asm/mach/arch.h>
31 #include <asm/mach/map.h>
33 #include <plat/board.h>
34 #include <plat/common.h>
36 #include <plat/display.h>
41 #define AM35XX_EVM_PHY_MASK (0xF)
42 #define AM35XX_EVM_MDIO_FREQUENCY (1000000)
44 static struct emac_platform_data am3517_evm_emac_pdata = {
45 .phy_mask = AM35XX_EVM_PHY_MASK,
46 .mdio_max_freq = AM35XX_EVM_MDIO_FREQUENCY,
50 static struct resource am3517_emac_resources[] = {
52 .start = AM35XX_IPSS_EMAC_BASE,
53 .end = AM35XX_IPSS_EMAC_BASE + 0x3FFFF,
54 .flags = IORESOURCE_MEM,
57 .start = INT_35XX_EMAC_C0_RXTHRESH_IRQ,
58 .end = INT_35XX_EMAC_C0_RXTHRESH_IRQ,
59 .flags = IORESOURCE_IRQ,
62 .start = INT_35XX_EMAC_C0_RX_PULSE_IRQ,
63 .end = INT_35XX_EMAC_C0_RX_PULSE_IRQ,
64 .flags = IORESOURCE_IRQ,
67 .start = INT_35XX_EMAC_C0_TX_PULSE_IRQ,
68 .end = INT_35XX_EMAC_C0_TX_PULSE_IRQ,
69 .flags = IORESOURCE_IRQ,
72 .start = INT_35XX_EMAC_C0_MISC_PULSE_IRQ,
73 .end = INT_35XX_EMAC_C0_MISC_PULSE_IRQ,
74 .flags = IORESOURCE_IRQ,
78 static struct platform_device am3517_emac_device = {
79 .name = "davinci_emac",
81 .num_resources = ARRAY_SIZE(am3517_emac_resources),
82 .resource = am3517_emac_resources,
85 static void am3517_enable_ethernet_int(void)
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);
98 static void am3517_disable_ethernet_int(void)
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);
109 static void am3517_evm_ethernet_init(struct emac_platform_data *pdata)
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);
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);
135 #define LCD_PANEL_PWR 176
136 #define LCD_PANEL_BKLIGHT_PWR 182
137 #define LCD_PANEL_PWM 181
139 static struct i2c_board_info __initdata am3517evm_i2c1_boardinfo[] = {
141 I2C_BOARD_INFO("s35390a", 0x30),
148 #define GPIO_RTCS35390A_IRQ 55
150 static void __init am3517_evm_rtc_init(void)
154 omap_mux_init_gpio(GPIO_RTCS35390A_IRQ, OMAP_PIN_INPUT_PULLUP);
155 r = gpio_request(GPIO_RTCS35390A_IRQ, "rtcs35390a-irq");
157 printk(KERN_WARNING "failed to request GPIO#%d\n",
158 GPIO_RTCS35390A_IRQ);
161 r = gpio_direction_input(GPIO_RTCS35390A_IRQ);
163 printk(KERN_WARNING "GPIO#%d cannot be configured as input\n",
164 GPIO_RTCS35390A_IRQ);
165 gpio_free(GPIO_RTCS35390A_IRQ);
168 am3517evm_i2c1_boardinfo[0].irq = gpio_to_irq(GPIO_RTCS35390A_IRQ);
172 * I2C GPIO Expander - TCA6416
175 /* Mounted on Base-Board */
176 static struct pca953x_platform_data am3517evm_gpio_expander_info_0 = {
177 .gpio_base = OMAP_MAX_GPIO_LINES,
179 static struct i2c_board_info __initdata am3517evm_i2c2_boardinfo[] = {
181 I2C_BOARD_INFO("tca6416", 0x21),
182 .platform_data = &am3517evm_gpio_expander_info_0,
186 /* Mounted on UI Card */
187 static struct pca953x_platform_data am3517evm_ui_gpio_expander_info_1 = {
188 .gpio_base = OMAP_MAX_GPIO_LINES + 16,
190 static struct pca953x_platform_data am3517evm_ui_gpio_expander_info_2 = {
191 .gpio_base = OMAP_MAX_GPIO_LINES + 32,
193 static struct i2c_board_info __initdata am3517evm_i2c3_boardinfo[] = {
195 I2C_BOARD_INFO("tca6416", 0x20),
196 .platform_data = &am3517evm_ui_gpio_expander_info_1,
199 I2C_BOARD_INFO("tca6416", 0x21),
200 .platform_data = &am3517evm_ui_gpio_expander_info_2,
204 static int __init am3517_evm_i2c_init(void)
206 omap_register_i2c_bus(1, 400, NULL, 0);
207 omap_register_i2c_bus(2, 400, am3517evm_i2c2_boardinfo,
208 ARRAY_SIZE(am3517evm_i2c2_boardinfo));
209 omap_register_i2c_bus(3, 400, am3517evm_i2c3_boardinfo,
210 ARRAY_SIZE(am3517evm_i2c3_boardinfo));
215 static int lcd_enabled;
216 static int dvi_enabled;
218 #if defined(CONFIG_PANEL_SHARP_LQ043T1DG01) || \
219 defined(CONFIG_PANEL_SHARP_LQ043T1DG01_MODULE)
220 static void __init am3517_evm_display_init(void)
224 omap_mux_init_gpio(LCD_PANEL_PWR, OMAP_PIN_INPUT_PULLUP);
225 omap_mux_init_gpio(LCD_PANEL_BKLIGHT_PWR, OMAP_PIN_INPUT_PULLDOWN);
226 omap_mux_init_gpio(LCD_PANEL_PWM, OMAP_PIN_INPUT_PULLDOWN);
228 * Enable GPIO 182 = LCD Backlight Power
230 r = gpio_request(LCD_PANEL_BKLIGHT_PWR, "lcd_backlight_pwr");
232 printk(KERN_ERR "failed to get lcd_backlight_pwr\n");
235 gpio_direction_output(LCD_PANEL_BKLIGHT_PWR, 1);
237 * Enable GPIO 181 = LCD Panel PWM
239 r = gpio_request(LCD_PANEL_PWM, "lcd_pwm");
241 printk(KERN_ERR "failed to get lcd_pwm\n");
244 gpio_direction_output(LCD_PANEL_PWM, 1);
246 * Enable GPIO 176 = LCD Panel Power enable pin
248 r = gpio_request(LCD_PANEL_PWR, "lcd_panel_pwr");
250 printk(KERN_ERR "failed to get lcd_panel_pwr\n");
253 gpio_direction_output(LCD_PANEL_PWR, 1);
255 printk(KERN_INFO "Display initialized successfully\n");
259 gpio_free(LCD_PANEL_PWM);
261 gpio_free(LCD_PANEL_BKLIGHT_PWR);
264 static void __init am3517_evm_display_init(void) {}
267 static int am3517_evm_panel_enable_lcd(struct omap_dss_device *dssdev)
270 printk(KERN_ERR "cannot enable LCD, DVI is enabled\n");
273 gpio_set_value(LCD_PANEL_PWR, 1);
279 static void am3517_evm_panel_disable_lcd(struct omap_dss_device *dssdev)
281 gpio_set_value(LCD_PANEL_PWR, 0);
285 static struct omap_dss_device am3517_evm_lcd_device = {
286 .type = OMAP_DISPLAY_TYPE_DPI,
288 .driver_name = "sharp_lq_panel",
289 .phy.dpi.data_lines = 16,
290 .platform_enable = am3517_evm_panel_enable_lcd,
291 .platform_disable = am3517_evm_panel_disable_lcd,
294 static int am3517_evm_panel_enable_tv(struct omap_dss_device *dssdev)
299 static void am3517_evm_panel_disable_tv(struct omap_dss_device *dssdev)
303 static struct omap_dss_device am3517_evm_tv_device = {
304 .type = OMAP_DISPLAY_TYPE_VENC,
306 .driver_name = "venc",
307 .phy.venc.type = OMAP_DSS_VENC_TYPE_SVIDEO,
308 .platform_enable = am3517_evm_panel_enable_tv,
309 .platform_disable = am3517_evm_panel_disable_tv,
312 static int am3517_evm_panel_enable_dvi(struct omap_dss_device *dssdev)
315 printk(KERN_ERR "cannot enable DVI, LCD is enabled\n");
323 static void am3517_evm_panel_disable_dvi(struct omap_dss_device *dssdev)
328 static struct omap_dss_device am3517_evm_dvi_device = {
329 .type = OMAP_DISPLAY_TYPE_DPI,
331 .driver_name = "generic_panel",
332 .phy.dpi.data_lines = 24,
333 .platform_enable = am3517_evm_panel_enable_dvi,
334 .platform_disable = am3517_evm_panel_disable_dvi,
337 static struct omap_dss_device *am3517_evm_dss_devices[] = {
338 &am3517_evm_lcd_device,
339 &am3517_evm_tv_device,
340 &am3517_evm_dvi_device,
343 static struct omap_dss_board_info am3517_evm_dss_data = {
344 .num_devices = ARRAY_SIZE(am3517_evm_dss_devices),
345 .devices = am3517_evm_dss_devices,
346 .default_device = &am3517_evm_lcd_device,
349 static struct platform_device am3517_evm_dss_device = {
353 .platform_data = &am3517_evm_dss_data,
358 * Board initialization
360 static struct omap_board_config_kernel am3517_evm_config[] __initdata = {
363 static struct platform_device *am3517_evm_devices[] __initdata = {
364 &am3517_evm_dss_device,
367 static void __init am3517_evm_init_irq(void)
369 omap_board_config = am3517_evm_config;
370 omap_board_config_size = ARRAY_SIZE(am3517_evm_config);
372 omap2_init_common_hw(NULL, NULL);
377 static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
378 .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
379 #if defined(CONFIG_PANEL_SHARP_LQ043T1DG01) || \
380 defined(CONFIG_PANEL_SHARP_LQ043T1DG01_MODULE)
381 .port_mode[1] = EHCI_HCD_OMAP_MODE_UNKNOWN,
383 .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY,
385 .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
388 .reset_gpio_port[0] = 57,
389 .reset_gpio_port[1] = -EINVAL,
390 .reset_gpio_port[2] = -EINVAL
393 #ifdef CONFIG_OMAP_MUX
394 static struct omap_board_mux board_mux[] __initdata = {
395 { .reg_offset = OMAP_MUX_TERMINATOR },
398 #define board_mux NULL
402 static struct resource am3517_hecc_resources[] = {
404 .start = AM35XX_IPSS_HECC_BASE,
405 .end = AM35XX_IPSS_HECC_BASE + 0x3FFF,
406 .flags = IORESOURCE_MEM,
409 .start = INT_35XX_HECC0_IRQ,
410 .end = INT_35XX_HECC0_IRQ,
411 .flags = IORESOURCE_IRQ,
415 static struct platform_device am3517_hecc_device = {
418 .num_resources = ARRAY_SIZE(am3517_hecc_resources),
419 .resource = am3517_hecc_resources,
422 static struct ti_hecc_platform_data am3517_evm_hecc_pdata = {
423 .scc_hecc_offset = AM35XX_HECC_SCC_HECC_OFFSET,
424 .scc_ram_offset = AM35XX_HECC_SCC_RAM_OFFSET,
425 .hecc_ram_offset = AM35XX_HECC_RAM_OFFSET,
426 .mbx_offset = AM35XX_HECC_MBOX_OFFSET,
427 .int_line = AM35XX_HECC_INT_LINE,
428 .version = AM35XX_HECC_VERSION,
431 static void am3517_evm_hecc_init(struct ti_hecc_platform_data *pdata)
433 am3517_hecc_device.dev.platform_data = pdata;
434 platform_device_register(&am3517_hecc_device);
437 static void __init am3517_evm_init(void)
439 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
441 am3517_evm_i2c_init();
442 platform_add_devices(am3517_evm_devices,
443 ARRAY_SIZE(am3517_evm_devices));
447 /* Configure GPIO for EHCI port */
448 omap_mux_init_gpio(57, OMAP_PIN_OUTPUT);
449 usb_ehci_init(&ehci_pdata);
450 am3517_evm_hecc_init(&am3517_evm_hecc_pdata);
452 am3517_evm_display_init();
455 am3517_evm_rtc_init();
457 i2c_register_board_info(1, am3517evm_i2c1_boardinfo,
458 ARRAY_SIZE(am3517evm_i2c1_boardinfo));
460 am3517_evm_ethernet_init(&am3517_evm_emac_pdata);
463 MACHINE_START(OMAP3517EVM, "OMAP3517/AM3517 EVM")
464 .phys_io = 0x48000000,
465 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
466 .boot_params = 0x80000100,
467 .map_io = omap3_map_io,
468 .reserve = omap_reserve,
469 .init_irq = am3517_evm_init_irq,
470 .init_machine = am3517_evm_init,
471 .timer = &omap_timer,