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