Igor Grinberg | d04b620 | 2010-09-21 16:03:09 +0000 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/mach-omap2/board-cm-t3517.c |
| 3 | * |
| 4 | * Support for the CompuLab CM-T3517 modules |
| 5 | * |
| 6 | * Copyright (C) 2010 CompuLab, Ltd. |
| 7 | * Author: Igor Grinberg <grinberg@compulab.co.il> |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or |
| 10 | * modify it under the terms of the GNU General Public License |
| 11 | * version 2 as published by the Free Software Foundation. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, but |
| 14 | * WITHOUT ANY WARRANTY; 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 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA |
| 21 | * 02110-1301 USA |
| 22 | * |
| 23 | */ |
| 24 | |
| 25 | #include <linux/kernel.h> |
| 26 | #include <linux/init.h> |
| 27 | #include <linux/platform_device.h> |
Igor Grinberg | 525d75b | 2010-09-21 16:03:11 +0000 | [diff] [blame^] | 28 | #include <linux/delay.h> |
Igor Grinberg | d04b620 | 2010-09-21 16:03:09 +0000 | [diff] [blame] | 29 | #include <linux/gpio.h> |
| 30 | #include <linux/leds.h> |
Igor Grinberg | 46893a5 | 2010-09-21 16:03:10 +0000 | [diff] [blame] | 31 | #include <linux/rtc-v3020.h> |
Igor Grinberg | d04b620 | 2010-09-21 16:03:09 +0000 | [diff] [blame] | 32 | |
| 33 | #include <asm/mach-types.h> |
| 34 | #include <asm/mach/arch.h> |
| 35 | #include <asm/mach/map.h> |
| 36 | |
| 37 | #include <plat/board.h> |
| 38 | #include <plat/common.h> |
| 39 | #include <plat/control.h> |
Igor Grinberg | 525d75b | 2010-09-21 16:03:11 +0000 | [diff] [blame^] | 40 | #include <plat/usb.h> |
Igor Grinberg | d04b620 | 2010-09-21 16:03:09 +0000 | [diff] [blame] | 41 | |
| 42 | #include "mux.h" |
| 43 | |
| 44 | #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE) |
| 45 | static struct gpio_led cm_t3517_leds[] = { |
| 46 | [0] = { |
| 47 | .gpio = 186, |
| 48 | .name = "cm-t3517:green", |
| 49 | .default_trigger = "heartbeat", |
| 50 | .active_low = 0, |
| 51 | }, |
| 52 | }; |
| 53 | |
| 54 | static struct gpio_led_platform_data cm_t3517_led_pdata = { |
| 55 | .num_leds = ARRAY_SIZE(cm_t3517_leds), |
| 56 | .leds = cm_t3517_leds, |
| 57 | }; |
| 58 | |
| 59 | static struct platform_device cm_t3517_led_device = { |
| 60 | .name = "leds-gpio", |
| 61 | .id = -1, |
| 62 | .dev = { |
| 63 | .platform_data = &cm_t3517_led_pdata, |
| 64 | }, |
| 65 | }; |
| 66 | |
| 67 | static void __init cm_t3517_init_leds(void) |
| 68 | { |
| 69 | platform_device_register(&cm_t3517_led_device); |
| 70 | } |
| 71 | #else |
| 72 | static inline void cm_t3517_init_leds(void) {} |
| 73 | #endif |
| 74 | |
Igor Grinberg | 46893a5 | 2010-09-21 16:03:10 +0000 | [diff] [blame] | 75 | #if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE) |
| 76 | #define RTC_IO_GPIO (153) |
| 77 | #define RTC_WR_GPIO (154) |
| 78 | #define RTC_RD_GPIO (160) |
| 79 | #define RTC_CS_GPIO (163) |
| 80 | |
| 81 | struct v3020_platform_data cm_t3517_v3020_pdata = { |
| 82 | .use_gpio = 1, |
| 83 | .gpio_cs = RTC_CS_GPIO, |
| 84 | .gpio_wr = RTC_WR_GPIO, |
| 85 | .gpio_rd = RTC_RD_GPIO, |
| 86 | .gpio_io = RTC_IO_GPIO, |
| 87 | }; |
| 88 | |
| 89 | static struct platform_device cm_t3517_rtc_device = { |
| 90 | .name = "v3020", |
| 91 | .id = -1, |
| 92 | .dev = { |
| 93 | .platform_data = &cm_t3517_v3020_pdata, |
| 94 | } |
| 95 | }; |
| 96 | |
| 97 | static void __init cm_t3517_init_rtc(void) |
| 98 | { |
| 99 | platform_device_register(&cm_t3517_rtc_device); |
| 100 | } |
| 101 | #else |
| 102 | static inline void cm_t3517_init_rtc(void) {} |
| 103 | #endif |
Igor Grinberg | d04b620 | 2010-09-21 16:03:09 +0000 | [diff] [blame] | 104 | |
Igor Grinberg | 525d75b | 2010-09-21 16:03:11 +0000 | [diff] [blame^] | 105 | #if defined(CONFIG_USB_EHCI_HCD) || defined(CONFIG_USB_EHCI_HCD_MODULE) |
| 106 | #define HSUSB1_RESET_GPIO (146) |
| 107 | #define HSUSB2_RESET_GPIO (147) |
| 108 | #define USB_HUB_RESET_GPIO (152) |
| 109 | |
| 110 | static struct ehci_hcd_omap_platform_data cm_t3517_ehci_pdata __initdata = { |
| 111 | .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY, |
| 112 | .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY, |
| 113 | .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN, |
| 114 | |
| 115 | .phy_reset = true, |
| 116 | .reset_gpio_port[0] = HSUSB1_RESET_GPIO, |
| 117 | .reset_gpio_port[1] = HSUSB2_RESET_GPIO, |
| 118 | .reset_gpio_port[2] = -EINVAL, |
| 119 | }; |
| 120 | |
| 121 | static int cm_t3517_init_usbh(void) |
| 122 | { |
| 123 | int err; |
| 124 | |
| 125 | err = gpio_request(USB_HUB_RESET_GPIO, "usb hub rst"); |
| 126 | if (err) { |
| 127 | pr_err("CM-T3517: usb hub rst gpio request failed: %d\n", err); |
| 128 | } else { |
| 129 | gpio_direction_output(USB_HUB_RESET_GPIO, 0); |
| 130 | udelay(10); |
| 131 | gpio_set_value(USB_HUB_RESET_GPIO, 1); |
| 132 | msleep(1); |
| 133 | } |
| 134 | |
| 135 | usb_ehci_init(&cm_t3517_ehci_pdata); |
| 136 | |
| 137 | return 0; |
| 138 | } |
| 139 | #else |
| 140 | static inline int cm_t3517_init_usbh(void) |
| 141 | { |
| 142 | return 0; |
| 143 | } |
| 144 | #endif |
| 145 | |
Igor Grinberg | d04b620 | 2010-09-21 16:03:09 +0000 | [diff] [blame] | 146 | static struct omap_board_config_kernel cm_t3517_config[] __initdata = { |
| 147 | }; |
| 148 | |
| 149 | static void __init cm_t3517_init_irq(void) |
| 150 | { |
| 151 | omap_board_config = cm_t3517_config; |
| 152 | omap_board_config_size = ARRAY_SIZE(cm_t3517_config); |
| 153 | |
| 154 | omap2_init_common_hw(NULL, NULL); |
| 155 | omap_init_irq(); |
| 156 | omap_gpio_init(); |
| 157 | } |
| 158 | |
| 159 | static struct omap_board_mux board_mux[] __initdata = { |
| 160 | /* GPIO186 - Green LED */ |
| 161 | OMAP3_MUX(SYS_CLKOUT2, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT), |
Igor Grinberg | 46893a5 | 2010-09-21 16:03:10 +0000 | [diff] [blame] | 162 | /* RTC GPIOs: IO, WR#, RD#, CS# */ |
| 163 | OMAP3_MUX(MCBSP4_DR, OMAP_MUX_MODE4 | OMAP_PIN_INPUT), |
| 164 | OMAP3_MUX(MCBSP4_DX, OMAP_MUX_MODE4 | OMAP_PIN_INPUT), |
| 165 | OMAP3_MUX(MCBSP_CLKS, OMAP_MUX_MODE4 | OMAP_PIN_INPUT), |
| 166 | OMAP3_MUX(UART3_CTS_RCTX, OMAP_MUX_MODE4 | OMAP_PIN_INPUT), |
Igor Grinberg | 525d75b | 2010-09-21 16:03:11 +0000 | [diff] [blame^] | 167 | /* HSUSB1 RESET */ |
| 168 | OMAP3_MUX(UART2_TX, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT), |
| 169 | /* HSUSB2 RESET */ |
| 170 | OMAP3_MUX(UART2_RX, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT), |
| 171 | /* CM-T3517 USB HUB nRESET */ |
| 172 | OMAP3_MUX(MCBSP4_CLKX, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT), |
Igor Grinberg | d04b620 | 2010-09-21 16:03:09 +0000 | [diff] [blame] | 173 | |
| 174 | { .reg_offset = OMAP_MUX_TERMINATOR }, |
| 175 | }; |
| 176 | |
| 177 | static void __init cm_t3517_init(void) |
| 178 | { |
| 179 | omap3_mux_init(board_mux, OMAP_PACKAGE_CBB); |
| 180 | omap_serial_init(); |
| 181 | cm_t3517_init_leds(); |
Igor Grinberg | 46893a5 | 2010-09-21 16:03:10 +0000 | [diff] [blame] | 182 | cm_t3517_init_rtc(); |
Igor Grinberg | 525d75b | 2010-09-21 16:03:11 +0000 | [diff] [blame^] | 183 | cm_t3517_init_usbh(); |
Igor Grinberg | d04b620 | 2010-09-21 16:03:09 +0000 | [diff] [blame] | 184 | } |
| 185 | |
| 186 | MACHINE_START(CM_T3517, "Compulab CM-T3517") |
| 187 | .phys_io = 0x48000000, |
| 188 | .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc, |
| 189 | .boot_params = 0x80000100, |
| 190 | .map_io = omap3_map_io, |
| 191 | .reserve = omap_reserve, |
| 192 | .init_irq = cm_t3517_init_irq, |
| 193 | .init_machine = cm_t3517_init, |
| 194 | .timer = &omap_timer, |
| 195 | MACHINE_END |