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 | |
| 41 | static int lcd_enabled; |
| 42 | static int dvi_enabled; |
| 43 | |
| 44 | static void __init am3517_evm_display_init(void) |
| 45 | { |
| 46 | int r; |
| 47 | |
| 48 | omap_mux_init_gpio(LCD_PANEL_PWR, OMAP_PIN_INPUT_PULLUP); |
| 49 | omap_mux_init_gpio(LCD_PANEL_BKLIGHT_PWR, OMAP_PIN_INPUT_PULLDOWN); |
| 50 | omap_mux_init_gpio(LCD_PANEL_PWM, OMAP_PIN_INPUT_PULLDOWN); |
| 51 | /* |
| 52 | * Enable GPIO 182 = LCD Backlight Power |
| 53 | */ |
| 54 | r = gpio_request(LCD_PANEL_BKLIGHT_PWR, "lcd_backlight_pwr"); |
| 55 | if (r) { |
| 56 | printk(KERN_ERR "failed to get lcd_backlight_pwr\n"); |
| 57 | return; |
| 58 | } |
| 59 | gpio_direction_output(LCD_PANEL_BKLIGHT_PWR, 1); |
| 60 | /* |
| 61 | * Enable GPIO 181 = LCD Panel PWM |
| 62 | */ |
| 63 | r = gpio_request(LCD_PANEL_PWM, "lcd_pwm"); |
| 64 | if (r) { |
| 65 | printk(KERN_ERR "failed to get lcd_pwm\n"); |
| 66 | goto err_1; |
| 67 | } |
| 68 | gpio_direction_output(LCD_PANEL_PWM, 1); |
| 69 | /* |
| 70 | * Enable GPIO 176 = LCD Panel Power enable pin |
| 71 | */ |
| 72 | r = gpio_request(LCD_PANEL_PWR, "lcd_panel_pwr"); |
| 73 | if (r) { |
| 74 | printk(KERN_ERR "failed to get lcd_panel_pwr\n"); |
| 75 | goto err_2; |
| 76 | } |
| 77 | gpio_direction_output(LCD_PANEL_PWR, 1); |
| 78 | |
| 79 | printk(KERN_INFO "Display initialized successfully\n"); |
| 80 | return; |
| 81 | |
| 82 | err_2: |
| 83 | gpio_free(LCD_PANEL_PWM); |
| 84 | err_1: |
| 85 | gpio_free(LCD_PANEL_BKLIGHT_PWR); |
| 86 | } |
| 87 | |
| 88 | static int am3517_evm_panel_enable_lcd(struct omap_dss_device *dssdev) |
| 89 | { |
| 90 | if (dvi_enabled) { |
| 91 | printk(KERN_ERR "cannot enable LCD, DVI is enabled\n"); |
| 92 | return -EINVAL; |
| 93 | } |
| 94 | gpio_set_value(LCD_PANEL_PWR, 1); |
| 95 | lcd_enabled = 1; |
| 96 | |
| 97 | return 0; |
| 98 | } |
| 99 | |
| 100 | static void am3517_evm_panel_disable_lcd(struct omap_dss_device *dssdev) |
| 101 | { |
| 102 | gpio_set_value(LCD_PANEL_PWR, 0); |
| 103 | lcd_enabled = 0; |
| 104 | } |
| 105 | |
| 106 | static struct omap_dss_device am3517_evm_lcd_device = { |
| 107 | .type = OMAP_DISPLAY_TYPE_DPI, |
| 108 | .name = "lcd", |
| 109 | .driver_name = "sharp_lq_panel", |
| 110 | .phy.dpi.data_lines = 16, |
| 111 | .platform_enable = am3517_evm_panel_enable_lcd, |
| 112 | .platform_disable = am3517_evm_panel_disable_lcd, |
| 113 | }; |
| 114 | |
| 115 | static int am3517_evm_panel_enable_tv(struct omap_dss_device *dssdev) |
| 116 | { |
| 117 | return 0; |
| 118 | } |
| 119 | |
| 120 | static void am3517_evm_panel_disable_tv(struct omap_dss_device *dssdev) |
| 121 | { |
| 122 | } |
| 123 | |
| 124 | static struct omap_dss_device am3517_evm_tv_device = { |
| 125 | .type = OMAP_DISPLAY_TYPE_VENC, |
| 126 | .name = "tv", |
| 127 | .driver_name = "venc", |
| 128 | .phy.venc.type = OMAP_DSS_VENC_TYPE_SVIDEO, |
| 129 | .platform_enable = am3517_evm_panel_enable_tv, |
| 130 | .platform_disable = am3517_evm_panel_disable_tv, |
| 131 | }; |
| 132 | |
| 133 | static int am3517_evm_panel_enable_dvi(struct omap_dss_device *dssdev) |
| 134 | { |
| 135 | if (lcd_enabled) { |
| 136 | printk(KERN_ERR "cannot enable DVI, LCD is enabled\n"); |
| 137 | return -EINVAL; |
| 138 | } |
| 139 | dvi_enabled = 1; |
| 140 | |
| 141 | return 0; |
| 142 | } |
| 143 | |
| 144 | static void am3517_evm_panel_disable_dvi(struct omap_dss_device *dssdev) |
| 145 | { |
| 146 | dvi_enabled = 0; |
| 147 | } |
| 148 | |
| 149 | static struct omap_dss_device am3517_evm_dvi_device = { |
| 150 | .type = OMAP_DISPLAY_TYPE_DPI, |
| 151 | .name = "dvi", |
| 152 | .driver_name = "generic_panel", |
| 153 | .phy.dpi.data_lines = 24, |
| 154 | .platform_enable = am3517_evm_panel_enable_dvi, |
| 155 | .platform_disable = am3517_evm_panel_disable_dvi, |
| 156 | }; |
| 157 | |
| 158 | static struct omap_dss_device *am3517_evm_dss_devices[] = { |
| 159 | &am3517_evm_lcd_device, |
| 160 | &am3517_evm_tv_device, |
| 161 | &am3517_evm_dvi_device, |
| 162 | }; |
| 163 | |
| 164 | static struct omap_dss_board_info am3517_evm_dss_data = { |
| 165 | .num_devices = ARRAY_SIZE(am3517_evm_dss_devices), |
| 166 | .devices = am3517_evm_dss_devices, |
| 167 | .default_device = &am3517_evm_lcd_device, |
| 168 | }; |
| 169 | |
| 170 | struct platform_device am3517_evm_dss_device = { |
| 171 | .name = "omapdss", |
| 172 | .id = -1, |
| 173 | .dev = { |
| 174 | .platform_data = &am3517_evm_dss_data, |
| 175 | }, |
| 176 | }; |
| 177 | |
Ranjith Lohithakshan | c625327 | 2009-11-18 18:41:09 -0800 | [diff] [blame] | 178 | /* |
| 179 | * Board initialization |
| 180 | */ |
| 181 | static struct omap_board_config_kernel am3517_evm_config[] __initdata = { |
| 182 | }; |
| 183 | |
| 184 | static struct platform_device *am3517_evm_devices[] __initdata = { |
Vaibhav Hiremath | c3d3332 | 2010-01-13 17:17:10 +0530 | [diff] [blame] | 185 | &am3517_evm_dss_device, |
Ranjith Lohithakshan | c625327 | 2009-11-18 18:41:09 -0800 | [diff] [blame] | 186 | }; |
| 187 | |
| 188 | static void __init am3517_evm_init_irq(void) |
| 189 | { |
| 190 | omap_board_config = am3517_evm_config; |
| 191 | omap_board_config_size = ARRAY_SIZE(am3517_evm_config); |
| 192 | |
| 193 | omap2_init_common_hw(NULL, NULL); |
| 194 | omap_init_irq(); |
| 195 | omap_gpio_init(); |
| 196 | } |
| 197 | |
| 198 | static struct ehci_hcd_omap_platform_data ehci_pdata __initdata = { |
| 199 | .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY, |
| 200 | .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY, |
| 201 | .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN, |
| 202 | |
| 203 | .phy_reset = true, |
| 204 | .reset_gpio_port[0] = 57, |
| 205 | .reset_gpio_port[1] = -EINVAL, |
| 206 | .reset_gpio_port[2] = -EINVAL |
| 207 | }; |
| 208 | |
Tony Lindgren | ca5742b | 2009-12-11 16:16:32 -0800 | [diff] [blame] | 209 | #ifdef CONFIG_OMAP_MUX |
| 210 | static struct omap_board_mux board_mux[] __initdata = { |
| 211 | { .reg_offset = OMAP_MUX_TERMINATOR }, |
| 212 | }; |
| 213 | #else |
| 214 | #define board_mux NULL |
| 215 | #endif |
| 216 | |
Ranjith Lohithakshan | c625327 | 2009-11-18 18:41:09 -0800 | [diff] [blame] | 217 | static void __init am3517_evm_init(void) |
| 218 | { |
Tony Lindgren | ca5742b | 2009-12-11 16:16:32 -0800 | [diff] [blame] | 219 | omap3_mux_init(board_mux, OMAP_PACKAGE_CBB); |
Ranjith Lohithakshan | c625327 | 2009-11-18 18:41:09 -0800 | [diff] [blame] | 220 | platform_add_devices(am3517_evm_devices, |
| 221 | ARRAY_SIZE(am3517_evm_devices)); |
| 222 | |
| 223 | omap_serial_init(); |
| 224 | usb_ehci_init(&ehci_pdata); |
Vaibhav Hiremath | c3d3332 | 2010-01-13 17:17:10 +0530 | [diff] [blame] | 225 | /* DSS */ |
| 226 | am3517_evm_display_init(); |
Ranjith Lohithakshan | c625327 | 2009-11-18 18:41:09 -0800 | [diff] [blame] | 227 | } |
| 228 | |
| 229 | static void __init am3517_evm_map_io(void) |
| 230 | { |
| 231 | omap2_set_globals_343x(); |
Tony Lindgren | 6fbd55d | 2010-02-12 12:26:47 -0800 | [diff] [blame] | 232 | omap34xx_map_common_io(); |
Ranjith Lohithakshan | c625327 | 2009-11-18 18:41:09 -0800 | [diff] [blame] | 233 | } |
| 234 | |
| 235 | MACHINE_START(OMAP3517EVM, "OMAP3517/AM3517 EVM") |
| 236 | .phys_io = 0x48000000, |
| 237 | .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc, |
| 238 | .boot_params = 0x80000100, |
| 239 | .map_io = am3517_evm_map_io, |
| 240 | .init_irq = am3517_evm_init_irq, |
| 241 | .init_machine = am3517_evm_init, |
| 242 | .timer = &omap_timer, |
| 243 | MACHINE_END |