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