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> |
Ranjith Lohithakshan | c625327 | 2009-11-18 18:41:09 -0800 | [diff] [blame] | 24 | |
| 25 | #include <mach/hardware.h> |
Vaibhav Hiremath | e3d4d0a | 2010-02-15 10:03:35 -0800 | [diff] [blame] | 26 | #include <mach/am35xx.h> |
Ranjith Lohithakshan | c625327 | 2009-11-18 18:41:09 -0800 | [diff] [blame] | 27 | #include <asm/mach-types.h> |
| 28 | #include <asm/mach/arch.h> |
| 29 | #include <asm/mach/map.h> |
| 30 | |
| 31 | #include <plat/board.h> |
| 32 | #include <plat/common.h> |
| 33 | #include <plat/usb.h> |
Vaibhav Hiremath | c3d3332 | 2010-01-13 17:17:10 +0530 | [diff] [blame] | 34 | #include <plat/display.h> |
Ranjith Lohithakshan | c625327 | 2009-11-18 18:41:09 -0800 | [diff] [blame] | 35 | |
Tony Lindgren | ca5742b | 2009-12-11 16:16:32 -0800 | [diff] [blame] | 36 | #include "mux.h" |
| 37 | |
Vaibhav Hiremath | c3d3332 | 2010-01-13 17:17:10 +0530 | [diff] [blame] | 38 | #define LCD_PANEL_PWR 176 |
| 39 | #define LCD_PANEL_BKLIGHT_PWR 182 |
| 40 | #define LCD_PANEL_PWM 181 |
| 41 | |
Vaibhav Hiremath | f2afbbb | 2010-02-13 11:47:56 +0000 | [diff] [blame] | 42 | static struct i2c_board_info __initdata am3517evm_i2c_boardinfo[] = { |
| 43 | { |
| 44 | I2C_BOARD_INFO("s35390a", 0x30), |
| 45 | .type = "s35390a", |
| 46 | }, |
| 47 | }; |
| 48 | |
| 49 | /* |
| 50 | * RTC - S35390A |
| 51 | */ |
| 52 | #define GPIO_RTCS35390A_IRQ 55 |
| 53 | |
| 54 | static void __init am3517_evm_rtc_init(void) |
| 55 | { |
| 56 | int r; |
| 57 | |
| 58 | omap_mux_init_gpio(GPIO_RTCS35390A_IRQ, OMAP_PIN_INPUT_PULLUP); |
| 59 | r = gpio_request(GPIO_RTCS35390A_IRQ, "rtcs35390a-irq"); |
| 60 | if (r < 0) { |
| 61 | printk(KERN_WARNING "failed to request GPIO#%d\n", |
| 62 | GPIO_RTCS35390A_IRQ); |
| 63 | return; |
| 64 | } |
| 65 | r = gpio_direction_input(GPIO_RTCS35390A_IRQ); |
| 66 | if (r < 0) { |
| 67 | printk(KERN_WARNING "GPIO#%d cannot be configured as input\n", |
| 68 | GPIO_RTCS35390A_IRQ); |
| 69 | gpio_free(GPIO_RTCS35390A_IRQ); |
| 70 | return; |
| 71 | } |
| 72 | am3517evm_i2c_boardinfo[0].irq = gpio_to_irq(GPIO_RTCS35390A_IRQ); |
| 73 | } |
| 74 | |
Vaibhav Hiremath | 5d4292a | 2010-02-13 11:47:57 +0000 | [diff] [blame^] | 75 | /* |
| 76 | * I2C GPIO Expander - TCA6416 |
| 77 | */ |
| 78 | |
| 79 | /* Mounted on Base-Board */ |
| 80 | static struct pca953x_platform_data am3517evm_gpio_expander_info_0 = { |
| 81 | .gpio_base = OMAP_MAX_GPIO_LINES, |
| 82 | }; |
| 83 | static struct i2c_board_info __initdata am3517evm_tca6516_info_0[] = { |
| 84 | { |
| 85 | I2C_BOARD_INFO("tca6416", 0x21), |
| 86 | .platform_data = &am3517evm_gpio_expander_info_0, |
| 87 | }, |
| 88 | }; |
| 89 | |
| 90 | /* Mounted on UI Card */ |
| 91 | static struct pca953x_platform_data am3517evm_ui_gpio_expander_info_1 = { |
| 92 | .gpio_base = OMAP_MAX_GPIO_LINES + 16, |
| 93 | }; |
| 94 | static struct pca953x_platform_data am3517evm_ui_gpio_expander_info_2 = { |
| 95 | .gpio_base = OMAP_MAX_GPIO_LINES + 32, |
| 96 | }; |
| 97 | static struct i2c_board_info __initdata am3517evm_ui_tca6516_info[] = { |
| 98 | { |
| 99 | I2C_BOARD_INFO("tca6416", 0x20), |
| 100 | .platform_data = &am3517evm_ui_gpio_expander_info_1, |
| 101 | }, |
| 102 | { |
| 103 | I2C_BOARD_INFO("tca6416", 0x21), |
| 104 | .platform_data = &am3517evm_ui_gpio_expander_info_2, |
| 105 | }, |
| 106 | }; |
| 107 | |
Vaibhav Hiremath | 1f738dc | 2010-02-17 14:09:28 -0800 | [diff] [blame] | 108 | static int __init am3517_evm_i2c_init(void) |
| 109 | { |
| 110 | omap_register_i2c_bus(1, 400, NULL, 0); |
Vaibhav Hiremath | 5d4292a | 2010-02-13 11:47:57 +0000 | [diff] [blame^] | 111 | omap_register_i2c_bus(2, 400, am3517evm_tca6516_info_0, |
| 112 | ARRAY_SIZE(am3517evm_tca6516_info_0)); |
| 113 | omap_register_i2c_bus(3, 400, am3517evm_ui_tca6516_info, |
| 114 | ARRAY_SIZE(am3517evm_ui_tca6516_info)); |
Vaibhav Hiremath | 1f738dc | 2010-02-17 14:09:28 -0800 | [diff] [blame] | 115 | |
| 116 | return 0; |
| 117 | } |
| 118 | |
Vaibhav Hiremath | c3d3332 | 2010-01-13 17:17:10 +0530 | [diff] [blame] | 119 | static int lcd_enabled; |
| 120 | static int dvi_enabled; |
| 121 | |
| 122 | static void __init am3517_evm_display_init(void) |
| 123 | { |
| 124 | int r; |
| 125 | |
| 126 | omap_mux_init_gpio(LCD_PANEL_PWR, OMAP_PIN_INPUT_PULLUP); |
| 127 | omap_mux_init_gpio(LCD_PANEL_BKLIGHT_PWR, OMAP_PIN_INPUT_PULLDOWN); |
| 128 | omap_mux_init_gpio(LCD_PANEL_PWM, OMAP_PIN_INPUT_PULLDOWN); |
| 129 | /* |
| 130 | * Enable GPIO 182 = LCD Backlight Power |
| 131 | */ |
| 132 | r = gpio_request(LCD_PANEL_BKLIGHT_PWR, "lcd_backlight_pwr"); |
| 133 | if (r) { |
| 134 | printk(KERN_ERR "failed to get lcd_backlight_pwr\n"); |
| 135 | return; |
| 136 | } |
| 137 | gpio_direction_output(LCD_PANEL_BKLIGHT_PWR, 1); |
| 138 | /* |
| 139 | * Enable GPIO 181 = LCD Panel PWM |
| 140 | */ |
| 141 | r = gpio_request(LCD_PANEL_PWM, "lcd_pwm"); |
| 142 | if (r) { |
| 143 | printk(KERN_ERR "failed to get lcd_pwm\n"); |
| 144 | goto err_1; |
| 145 | } |
| 146 | gpio_direction_output(LCD_PANEL_PWM, 1); |
| 147 | /* |
| 148 | * Enable GPIO 176 = LCD Panel Power enable pin |
| 149 | */ |
| 150 | r = gpio_request(LCD_PANEL_PWR, "lcd_panel_pwr"); |
| 151 | if (r) { |
| 152 | printk(KERN_ERR "failed to get lcd_panel_pwr\n"); |
| 153 | goto err_2; |
| 154 | } |
| 155 | gpio_direction_output(LCD_PANEL_PWR, 1); |
| 156 | |
| 157 | printk(KERN_INFO "Display initialized successfully\n"); |
| 158 | return; |
| 159 | |
| 160 | err_2: |
| 161 | gpio_free(LCD_PANEL_PWM); |
| 162 | err_1: |
| 163 | gpio_free(LCD_PANEL_BKLIGHT_PWR); |
| 164 | } |
| 165 | |
| 166 | static int am3517_evm_panel_enable_lcd(struct omap_dss_device *dssdev) |
| 167 | { |
| 168 | if (dvi_enabled) { |
| 169 | printk(KERN_ERR "cannot enable LCD, DVI is enabled\n"); |
| 170 | return -EINVAL; |
| 171 | } |
| 172 | gpio_set_value(LCD_PANEL_PWR, 1); |
| 173 | lcd_enabled = 1; |
| 174 | |
| 175 | return 0; |
| 176 | } |
| 177 | |
| 178 | static void am3517_evm_panel_disable_lcd(struct omap_dss_device *dssdev) |
| 179 | { |
| 180 | gpio_set_value(LCD_PANEL_PWR, 0); |
| 181 | lcd_enabled = 0; |
| 182 | } |
| 183 | |
| 184 | static struct omap_dss_device am3517_evm_lcd_device = { |
| 185 | .type = OMAP_DISPLAY_TYPE_DPI, |
| 186 | .name = "lcd", |
| 187 | .driver_name = "sharp_lq_panel", |
| 188 | .phy.dpi.data_lines = 16, |
| 189 | .platform_enable = am3517_evm_panel_enable_lcd, |
| 190 | .platform_disable = am3517_evm_panel_disable_lcd, |
| 191 | }; |
| 192 | |
| 193 | static int am3517_evm_panel_enable_tv(struct omap_dss_device *dssdev) |
| 194 | { |
| 195 | return 0; |
| 196 | } |
| 197 | |
| 198 | static void am3517_evm_panel_disable_tv(struct omap_dss_device *dssdev) |
| 199 | { |
| 200 | } |
| 201 | |
| 202 | static struct omap_dss_device am3517_evm_tv_device = { |
| 203 | .type = OMAP_DISPLAY_TYPE_VENC, |
| 204 | .name = "tv", |
| 205 | .driver_name = "venc", |
| 206 | .phy.venc.type = OMAP_DSS_VENC_TYPE_SVIDEO, |
| 207 | .platform_enable = am3517_evm_panel_enable_tv, |
| 208 | .platform_disable = am3517_evm_panel_disable_tv, |
| 209 | }; |
| 210 | |
| 211 | static int am3517_evm_panel_enable_dvi(struct omap_dss_device *dssdev) |
| 212 | { |
| 213 | if (lcd_enabled) { |
| 214 | printk(KERN_ERR "cannot enable DVI, LCD is enabled\n"); |
| 215 | return -EINVAL; |
| 216 | } |
| 217 | dvi_enabled = 1; |
| 218 | |
| 219 | return 0; |
| 220 | } |
| 221 | |
| 222 | static void am3517_evm_panel_disable_dvi(struct omap_dss_device *dssdev) |
| 223 | { |
| 224 | dvi_enabled = 0; |
| 225 | } |
| 226 | |
| 227 | static struct omap_dss_device am3517_evm_dvi_device = { |
| 228 | .type = OMAP_DISPLAY_TYPE_DPI, |
| 229 | .name = "dvi", |
| 230 | .driver_name = "generic_panel", |
| 231 | .phy.dpi.data_lines = 24, |
| 232 | .platform_enable = am3517_evm_panel_enable_dvi, |
| 233 | .platform_disable = am3517_evm_panel_disable_dvi, |
| 234 | }; |
| 235 | |
| 236 | static struct omap_dss_device *am3517_evm_dss_devices[] = { |
| 237 | &am3517_evm_lcd_device, |
| 238 | &am3517_evm_tv_device, |
| 239 | &am3517_evm_dvi_device, |
| 240 | }; |
| 241 | |
| 242 | static struct omap_dss_board_info am3517_evm_dss_data = { |
| 243 | .num_devices = ARRAY_SIZE(am3517_evm_dss_devices), |
| 244 | .devices = am3517_evm_dss_devices, |
| 245 | .default_device = &am3517_evm_lcd_device, |
| 246 | }; |
| 247 | |
| 248 | struct platform_device am3517_evm_dss_device = { |
| 249 | .name = "omapdss", |
| 250 | .id = -1, |
| 251 | .dev = { |
| 252 | .platform_data = &am3517_evm_dss_data, |
| 253 | }, |
| 254 | }; |
| 255 | |
Ranjith Lohithakshan | c625327 | 2009-11-18 18:41:09 -0800 | [diff] [blame] | 256 | /* |
| 257 | * Board initialization |
| 258 | */ |
| 259 | static struct omap_board_config_kernel am3517_evm_config[] __initdata = { |
| 260 | }; |
| 261 | |
| 262 | static struct platform_device *am3517_evm_devices[] __initdata = { |
Vaibhav Hiremath | c3d3332 | 2010-01-13 17:17:10 +0530 | [diff] [blame] | 263 | &am3517_evm_dss_device, |
Ranjith Lohithakshan | c625327 | 2009-11-18 18:41:09 -0800 | [diff] [blame] | 264 | }; |
| 265 | |
| 266 | static void __init am3517_evm_init_irq(void) |
| 267 | { |
| 268 | omap_board_config = am3517_evm_config; |
| 269 | omap_board_config_size = ARRAY_SIZE(am3517_evm_config); |
| 270 | |
| 271 | omap2_init_common_hw(NULL, NULL); |
| 272 | omap_init_irq(); |
| 273 | omap_gpio_init(); |
| 274 | } |
| 275 | |
| 276 | static struct ehci_hcd_omap_platform_data ehci_pdata __initdata = { |
| 277 | .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY, |
| 278 | .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY, |
| 279 | .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN, |
| 280 | |
| 281 | .phy_reset = true, |
| 282 | .reset_gpio_port[0] = 57, |
| 283 | .reset_gpio_port[1] = -EINVAL, |
| 284 | .reset_gpio_port[2] = -EINVAL |
| 285 | }; |
| 286 | |
Tony Lindgren | ca5742b | 2009-12-11 16:16:32 -0800 | [diff] [blame] | 287 | #ifdef CONFIG_OMAP_MUX |
| 288 | static struct omap_board_mux board_mux[] __initdata = { |
| 289 | { .reg_offset = OMAP_MUX_TERMINATOR }, |
| 290 | }; |
| 291 | #else |
| 292 | #define board_mux NULL |
| 293 | #endif |
| 294 | |
Ranjith Lohithakshan | c625327 | 2009-11-18 18:41:09 -0800 | [diff] [blame] | 295 | static void __init am3517_evm_init(void) |
| 296 | { |
Vaibhav Hiremath | 1f738dc | 2010-02-17 14:09:28 -0800 | [diff] [blame] | 297 | am3517_evm_i2c_init(); |
| 298 | |
Tony Lindgren | ca5742b | 2009-12-11 16:16:32 -0800 | [diff] [blame] | 299 | omap3_mux_init(board_mux, OMAP_PACKAGE_CBB); |
Ranjith Lohithakshan | c625327 | 2009-11-18 18:41:09 -0800 | [diff] [blame] | 300 | platform_add_devices(am3517_evm_devices, |
| 301 | ARRAY_SIZE(am3517_evm_devices)); |
| 302 | |
| 303 | omap_serial_init(); |
| 304 | usb_ehci_init(&ehci_pdata); |
Vaibhav Hiremath | c3d3332 | 2010-01-13 17:17:10 +0530 | [diff] [blame] | 305 | /* DSS */ |
| 306 | am3517_evm_display_init(); |
Vaibhav Hiremath | f2afbbb | 2010-02-13 11:47:56 +0000 | [diff] [blame] | 307 | |
| 308 | /* RTC - S35390A */ |
| 309 | am3517_evm_rtc_init(); |
| 310 | |
| 311 | i2c_register_board_info(1, am3517evm_i2c_boardinfo, |
| 312 | ARRAY_SIZE(am3517evm_i2c_boardinfo)); |
Ranjith Lohithakshan | c625327 | 2009-11-18 18:41:09 -0800 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | static void __init am3517_evm_map_io(void) |
| 316 | { |
| 317 | omap2_set_globals_343x(); |
Tony Lindgren | 6fbd55d | 2010-02-12 12:26:47 -0800 | [diff] [blame] | 318 | omap34xx_map_common_io(); |
Ranjith Lohithakshan | c625327 | 2009-11-18 18:41:09 -0800 | [diff] [blame] | 319 | } |
| 320 | |
| 321 | MACHINE_START(OMAP3517EVM, "OMAP3517/AM3517 EVM") |
| 322 | .phys_io = 0x48000000, |
| 323 | .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc, |
| 324 | .boot_params = 0x80000100, |
| 325 | .map_io = am3517_evm_map_io, |
| 326 | .init_irq = am3517_evm_init_irq, |
| 327 | .init_machine = am3517_evm_init, |
| 328 | .timer = &omap_timer, |
| 329 | MACHINE_END |