Ranjith Lohithakshan | c625327 | 2009-11-18 18:41:09 -0800 | [diff] [blame] | 1 | /* |
| 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 Hiremath | 5d4292a | 2010-02-13 11:47:57 +0000 | [diff] [blame] | 23 | #include <linux/i2c/pca953x.h> |
Sriram | 9173363 | 2010-05-10 14:29:16 -0700 | [diff] [blame^] | 24 | #include <linux/can/platform/ti_hecc.h> |
Ranjith Lohithakshan | c625327 | 2009-11-18 18:41:09 -0800 | [diff] [blame] | 25 | |
| 26 | #include <mach/hardware.h> |
Vaibhav Hiremath | e3d4d0a | 2010-02-15 10:03:35 -0800 | [diff] [blame] | 27 | #include <mach/am35xx.h> |
Ranjith Lohithakshan | c625327 | 2009-11-18 18:41:09 -0800 | [diff] [blame] | 28 | #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 Hiremath | c3d3332 | 2010-01-13 17:17:10 +0530 | [diff] [blame] | 35 | #include <plat/display.h> |
Ranjith Lohithakshan | c625327 | 2009-11-18 18:41:09 -0800 | [diff] [blame] | 36 | |
Tony Lindgren | ca5742b | 2009-12-11 16:16:32 -0800 | [diff] [blame] | 37 | #include "mux.h" |
| 38 | |
Vaibhav Hiremath | c3d3332 | 2010-01-13 17:17:10 +0530 | [diff] [blame] | 39 | #define LCD_PANEL_PWR 176 |
| 40 | #define LCD_PANEL_BKLIGHT_PWR 182 |
| 41 | #define LCD_PANEL_PWM 181 |
| 42 | |
Vaibhav Hiremath | f2afbbb | 2010-02-13 11:47:56 +0000 | [diff] [blame] | 43 | static 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 | |
| 55 | static 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 Hiremath | 5d4292a | 2010-02-13 11:47:57 +0000 | [diff] [blame] | 76 | /* |
| 77 | * I2C GPIO Expander - TCA6416 |
| 78 | */ |
| 79 | |
| 80 | /* Mounted on Base-Board */ |
| 81 | static struct pca953x_platform_data am3517evm_gpio_expander_info_0 = { |
| 82 | .gpio_base = OMAP_MAX_GPIO_LINES, |
| 83 | }; |
Sriram | 7b97f3e | 2010-02-25 10:45:49 +0000 | [diff] [blame] | 84 | static struct i2c_board_info __initdata am3517evm_tca6416_info_0[] = { |
Vaibhav Hiremath | 5d4292a | 2010-02-13 11:47:57 +0000 | [diff] [blame] | 85 | { |
| 86 | I2C_BOARD_INFO("tca6416", 0x21), |
| 87 | .platform_data = &am3517evm_gpio_expander_info_0, |
| 88 | }, |
| 89 | }; |
| 90 | |
| 91 | /* Mounted on UI Card */ |
| 92 | static struct pca953x_platform_data am3517evm_ui_gpio_expander_info_1 = { |
| 93 | .gpio_base = OMAP_MAX_GPIO_LINES + 16, |
| 94 | }; |
| 95 | static struct pca953x_platform_data am3517evm_ui_gpio_expander_info_2 = { |
| 96 | .gpio_base = OMAP_MAX_GPIO_LINES + 32, |
| 97 | }; |
Sriram | 7b97f3e | 2010-02-25 10:45:49 +0000 | [diff] [blame] | 98 | static struct i2c_board_info __initdata am3517evm_ui_tca6416_info[] = { |
Vaibhav Hiremath | 5d4292a | 2010-02-13 11:47:57 +0000 | [diff] [blame] | 99 | { |
| 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 Hiremath | 1f738dc | 2010-02-17 14:09:28 -0800 | [diff] [blame] | 109 | static int __init am3517_evm_i2c_init(void) |
| 110 | { |
| 111 | omap_register_i2c_bus(1, 400, NULL, 0); |
Sriram | 7b97f3e | 2010-02-25 10:45:49 +0000 | [diff] [blame] | 112 | 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 Hiremath | 1f738dc | 2010-02-17 14:09:28 -0800 | [diff] [blame] | 116 | |
| 117 | return 0; |
| 118 | } |
| 119 | |
Vaibhav Hiremath | c3d3332 | 2010-01-13 17:17:10 +0530 | [diff] [blame] | 120 | static int lcd_enabled; |
| 121 | static int dvi_enabled; |
| 122 | |
| 123 | static 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 | |
| 161 | err_2: |
| 162 | gpio_free(LCD_PANEL_PWM); |
| 163 | err_1: |
| 164 | gpio_free(LCD_PANEL_BKLIGHT_PWR); |
| 165 | } |
| 166 | |
| 167 | static 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 | |
| 179 | static 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 | |
| 185 | static 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 | |
| 194 | static int am3517_evm_panel_enable_tv(struct omap_dss_device *dssdev) |
| 195 | { |
| 196 | return 0; |
| 197 | } |
| 198 | |
| 199 | static void am3517_evm_panel_disable_tv(struct omap_dss_device *dssdev) |
| 200 | { |
| 201 | } |
| 202 | |
| 203 | static 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 | |
| 212 | static 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 | |
| 223 | static void am3517_evm_panel_disable_dvi(struct omap_dss_device *dssdev) |
| 224 | { |
| 225 | dvi_enabled = 0; |
| 226 | } |
| 227 | |
| 228 | static 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 | |
| 237 | static 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 | |
| 243 | static 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 | |
| 249 | struct 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 Lohithakshan | c625327 | 2009-11-18 18:41:09 -0800 | [diff] [blame] | 257 | /* |
| 258 | * Board initialization |
| 259 | */ |
| 260 | static struct omap_board_config_kernel am3517_evm_config[] __initdata = { |
| 261 | }; |
| 262 | |
| 263 | static struct platform_device *am3517_evm_devices[] __initdata = { |
Vaibhav Hiremath | c3d3332 | 2010-01-13 17:17:10 +0530 | [diff] [blame] | 264 | &am3517_evm_dss_device, |
Ranjith Lohithakshan | c625327 | 2009-11-18 18:41:09 -0800 | [diff] [blame] | 265 | }; |
| 266 | |
| 267 | static 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 Balbi | 6f69a18 | 2010-03-04 09:45:53 +0200 | [diff] [blame] | 277 | static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = { |
Ranjith Lohithakshan | c625327 | 2009-11-18 18:41:09 -0800 | [diff] [blame] | 278 | .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 Lindgren | ca5742b | 2009-12-11 16:16:32 -0800 | [diff] [blame] | 288 | #ifdef CONFIG_OMAP_MUX |
| 289 | static struct omap_board_mux board_mux[] __initdata = { |
| 290 | { .reg_offset = OMAP_MUX_TERMINATOR }, |
| 291 | }; |
| 292 | #else |
| 293 | #define board_mux NULL |
| 294 | #endif |
| 295 | |
Sriram | 9173363 | 2010-05-10 14:29:16 -0700 | [diff] [blame^] | 296 | |
| 297 | static 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 | |
| 310 | static 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 | |
| 317 | static 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 | |
| 326 | static 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 Lohithakshan | c625327 | 2009-11-18 18:41:09 -0800 | [diff] [blame] | 332 | static void __init am3517_evm_init(void) |
| 333 | { |
Tony Lindgren | ca5742b | 2009-12-11 16:16:32 -0800 | [diff] [blame] | 334 | omap3_mux_init(board_mux, OMAP_PACKAGE_CBB); |
stanley.miao | 5241b6b | 2010-04-20 06:33:29 +0000 | [diff] [blame] | 335 | |
| 336 | am3517_evm_i2c_init(); |
Ranjith Lohithakshan | c625327 | 2009-11-18 18:41:09 -0800 | [diff] [blame] | 337 | platform_add_devices(am3517_evm_devices, |
| 338 | ARRAY_SIZE(am3517_evm_devices)); |
| 339 | |
| 340 | omap_serial_init(); |
Ajay Kumar Gupta | fec3eeb | 2010-02-22 10:21:12 +0000 | [diff] [blame] | 341 | |
| 342 | /* Configure GPIO for EHCI port */ |
| 343 | omap_mux_init_gpio(57, OMAP_PIN_OUTPUT); |
Ranjith Lohithakshan | c625327 | 2009-11-18 18:41:09 -0800 | [diff] [blame] | 344 | usb_ehci_init(&ehci_pdata); |
Sriram | 9173363 | 2010-05-10 14:29:16 -0700 | [diff] [blame^] | 345 | am3517_evm_hecc_init(&am3517_evm_hecc_pdata); |
Vaibhav Hiremath | c3d3332 | 2010-01-13 17:17:10 +0530 | [diff] [blame] | 346 | /* DSS */ |
| 347 | am3517_evm_display_init(); |
Vaibhav Hiremath | f2afbbb | 2010-02-13 11:47:56 +0000 | [diff] [blame] | 348 | |
| 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 Lohithakshan | c625327 | 2009-11-18 18:41:09 -0800 | [diff] [blame] | 354 | } |
| 355 | |
| 356 | static void __init am3517_evm_map_io(void) |
| 357 | { |
| 358 | omap2_set_globals_343x(); |
Tony Lindgren | 6fbd55d | 2010-02-12 12:26:47 -0800 | [diff] [blame] | 359 | omap34xx_map_common_io(); |
Ranjith Lohithakshan | c625327 | 2009-11-18 18:41:09 -0800 | [diff] [blame] | 360 | } |
| 361 | |
| 362 | MACHINE_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, |
| 370 | MACHINE_END |