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 | ec34fcc | 2010-09-21 16:03:12 +0000 | [diff] [blame^] | 32 | #include <linux/mtd/mtd.h> |
| 33 | #include <linux/mtd/nand.h> |
| 34 | #include <linux/mtd/partitions.h> |
Igor Grinberg | d04b620 | 2010-09-21 16:03:09 +0000 | [diff] [blame] | 35 | |
| 36 | #include <asm/mach-types.h> |
| 37 | #include <asm/mach/arch.h> |
| 38 | #include <asm/mach/map.h> |
| 39 | |
| 40 | #include <plat/board.h> |
| 41 | #include <plat/common.h> |
| 42 | #include <plat/control.h> |
Igor Grinberg | 525d75b | 2010-09-21 16:03:11 +0000 | [diff] [blame] | 43 | #include <plat/usb.h> |
Igor Grinberg | ec34fcc | 2010-09-21 16:03:12 +0000 | [diff] [blame^] | 44 | #include <plat/nand.h> |
| 45 | #include <plat/gpmc.h> |
Igor Grinberg | d04b620 | 2010-09-21 16:03:09 +0000 | [diff] [blame] | 46 | |
| 47 | #include "mux.h" |
| 48 | |
| 49 | #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE) |
| 50 | static struct gpio_led cm_t3517_leds[] = { |
| 51 | [0] = { |
| 52 | .gpio = 186, |
| 53 | .name = "cm-t3517:green", |
| 54 | .default_trigger = "heartbeat", |
| 55 | .active_low = 0, |
| 56 | }, |
| 57 | }; |
| 58 | |
| 59 | static struct gpio_led_platform_data cm_t3517_led_pdata = { |
| 60 | .num_leds = ARRAY_SIZE(cm_t3517_leds), |
| 61 | .leds = cm_t3517_leds, |
| 62 | }; |
| 63 | |
| 64 | static struct platform_device cm_t3517_led_device = { |
| 65 | .name = "leds-gpio", |
| 66 | .id = -1, |
| 67 | .dev = { |
| 68 | .platform_data = &cm_t3517_led_pdata, |
| 69 | }, |
| 70 | }; |
| 71 | |
| 72 | static void __init cm_t3517_init_leds(void) |
| 73 | { |
| 74 | platform_device_register(&cm_t3517_led_device); |
| 75 | } |
| 76 | #else |
| 77 | static inline void cm_t3517_init_leds(void) {} |
| 78 | #endif |
| 79 | |
Igor Grinberg | 46893a5 | 2010-09-21 16:03:10 +0000 | [diff] [blame] | 80 | #if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE) |
| 81 | #define RTC_IO_GPIO (153) |
| 82 | #define RTC_WR_GPIO (154) |
| 83 | #define RTC_RD_GPIO (160) |
| 84 | #define RTC_CS_GPIO (163) |
| 85 | |
| 86 | struct v3020_platform_data cm_t3517_v3020_pdata = { |
| 87 | .use_gpio = 1, |
| 88 | .gpio_cs = RTC_CS_GPIO, |
| 89 | .gpio_wr = RTC_WR_GPIO, |
| 90 | .gpio_rd = RTC_RD_GPIO, |
| 91 | .gpio_io = RTC_IO_GPIO, |
| 92 | }; |
| 93 | |
| 94 | static struct platform_device cm_t3517_rtc_device = { |
| 95 | .name = "v3020", |
| 96 | .id = -1, |
| 97 | .dev = { |
| 98 | .platform_data = &cm_t3517_v3020_pdata, |
| 99 | } |
| 100 | }; |
| 101 | |
| 102 | static void __init cm_t3517_init_rtc(void) |
| 103 | { |
| 104 | platform_device_register(&cm_t3517_rtc_device); |
| 105 | } |
| 106 | #else |
| 107 | static inline void cm_t3517_init_rtc(void) {} |
| 108 | #endif |
Igor Grinberg | d04b620 | 2010-09-21 16:03:09 +0000 | [diff] [blame] | 109 | |
Igor Grinberg | 525d75b | 2010-09-21 16:03:11 +0000 | [diff] [blame] | 110 | #if defined(CONFIG_USB_EHCI_HCD) || defined(CONFIG_USB_EHCI_HCD_MODULE) |
| 111 | #define HSUSB1_RESET_GPIO (146) |
| 112 | #define HSUSB2_RESET_GPIO (147) |
| 113 | #define USB_HUB_RESET_GPIO (152) |
| 114 | |
| 115 | static struct ehci_hcd_omap_platform_data cm_t3517_ehci_pdata __initdata = { |
| 116 | .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY, |
| 117 | .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY, |
| 118 | .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN, |
| 119 | |
| 120 | .phy_reset = true, |
| 121 | .reset_gpio_port[0] = HSUSB1_RESET_GPIO, |
| 122 | .reset_gpio_port[1] = HSUSB2_RESET_GPIO, |
| 123 | .reset_gpio_port[2] = -EINVAL, |
| 124 | }; |
| 125 | |
| 126 | static int cm_t3517_init_usbh(void) |
| 127 | { |
| 128 | int err; |
| 129 | |
| 130 | err = gpio_request(USB_HUB_RESET_GPIO, "usb hub rst"); |
| 131 | if (err) { |
| 132 | pr_err("CM-T3517: usb hub rst gpio request failed: %d\n", err); |
| 133 | } else { |
| 134 | gpio_direction_output(USB_HUB_RESET_GPIO, 0); |
| 135 | udelay(10); |
| 136 | gpio_set_value(USB_HUB_RESET_GPIO, 1); |
| 137 | msleep(1); |
| 138 | } |
| 139 | |
| 140 | usb_ehci_init(&cm_t3517_ehci_pdata); |
| 141 | |
| 142 | return 0; |
| 143 | } |
| 144 | #else |
| 145 | static inline int cm_t3517_init_usbh(void) |
| 146 | { |
| 147 | return 0; |
| 148 | } |
| 149 | #endif |
| 150 | |
Igor Grinberg | ec34fcc | 2010-09-21 16:03:12 +0000 | [diff] [blame^] | 151 | #if defined(CONFIG_MTD_NAND_OMAP2) || defined(CONFIG_MTD_NAND_OMAP2_MODULE) |
| 152 | #define NAND_BLOCK_SIZE SZ_128K |
| 153 | |
| 154 | static struct mtd_partition cm_t3517_nand_partitions[] = { |
| 155 | { |
| 156 | .name = "xloader", |
| 157 | .offset = 0, /* Offset = 0x00000 */ |
| 158 | .size = 4 * NAND_BLOCK_SIZE, |
| 159 | .mask_flags = MTD_WRITEABLE |
| 160 | }, |
| 161 | { |
| 162 | .name = "uboot", |
| 163 | .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */ |
| 164 | .size = 15 * NAND_BLOCK_SIZE, |
| 165 | }, |
| 166 | { |
| 167 | .name = "uboot environment", |
| 168 | .offset = MTDPART_OFS_APPEND, /* Offset = 0x260000 */ |
| 169 | .size = 2 * NAND_BLOCK_SIZE, |
| 170 | }, |
| 171 | { |
| 172 | .name = "linux", |
| 173 | .offset = MTDPART_OFS_APPEND, /* Offset = 0x280000 */ |
| 174 | .size = 32 * NAND_BLOCK_SIZE, |
| 175 | }, |
| 176 | { |
| 177 | .name = "rootfs", |
| 178 | .offset = MTDPART_OFS_APPEND, /* Offset = 0x680000 */ |
| 179 | .size = MTDPART_SIZ_FULL, |
| 180 | }, |
| 181 | }; |
| 182 | |
| 183 | static struct omap_nand_platform_data cm_t3517_nand_data = { |
| 184 | .parts = cm_t3517_nand_partitions, |
| 185 | .nr_parts = ARRAY_SIZE(cm_t3517_nand_partitions), |
| 186 | .dma_channel = -1, /* disable DMA in OMAP NAND driver */ |
| 187 | .cs = 0, |
| 188 | }; |
| 189 | |
| 190 | static void __init cm_t3517_init_nand(void) |
| 191 | { |
| 192 | if (gpmc_nand_init(&cm_t3517_nand_data) < 0) |
| 193 | pr_err("CM-T3517: NAND initialization failed\n"); |
| 194 | } |
| 195 | #else |
| 196 | static inline void cm_t3517_init_nand(void) {} |
| 197 | #endif |
| 198 | |
Igor Grinberg | d04b620 | 2010-09-21 16:03:09 +0000 | [diff] [blame] | 199 | static struct omap_board_config_kernel cm_t3517_config[] __initdata = { |
| 200 | }; |
| 201 | |
| 202 | static void __init cm_t3517_init_irq(void) |
| 203 | { |
| 204 | omap_board_config = cm_t3517_config; |
| 205 | omap_board_config_size = ARRAY_SIZE(cm_t3517_config); |
| 206 | |
| 207 | omap2_init_common_hw(NULL, NULL); |
| 208 | omap_init_irq(); |
| 209 | omap_gpio_init(); |
| 210 | } |
| 211 | |
| 212 | static struct omap_board_mux board_mux[] __initdata = { |
| 213 | /* GPIO186 - Green LED */ |
| 214 | OMAP3_MUX(SYS_CLKOUT2, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT), |
Igor Grinberg | 46893a5 | 2010-09-21 16:03:10 +0000 | [diff] [blame] | 215 | /* RTC GPIOs: IO, WR#, RD#, CS# */ |
| 216 | OMAP3_MUX(MCBSP4_DR, OMAP_MUX_MODE4 | OMAP_PIN_INPUT), |
| 217 | OMAP3_MUX(MCBSP4_DX, OMAP_MUX_MODE4 | OMAP_PIN_INPUT), |
| 218 | OMAP3_MUX(MCBSP_CLKS, OMAP_MUX_MODE4 | OMAP_PIN_INPUT), |
| 219 | OMAP3_MUX(UART3_CTS_RCTX, OMAP_MUX_MODE4 | OMAP_PIN_INPUT), |
Igor Grinberg | 525d75b | 2010-09-21 16:03:11 +0000 | [diff] [blame] | 220 | /* HSUSB1 RESET */ |
| 221 | OMAP3_MUX(UART2_TX, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT), |
| 222 | /* HSUSB2 RESET */ |
| 223 | OMAP3_MUX(UART2_RX, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT), |
| 224 | /* CM-T3517 USB HUB nRESET */ |
| 225 | OMAP3_MUX(MCBSP4_CLKX, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT), |
Igor Grinberg | d04b620 | 2010-09-21 16:03:09 +0000 | [diff] [blame] | 226 | |
| 227 | { .reg_offset = OMAP_MUX_TERMINATOR }, |
| 228 | }; |
| 229 | |
| 230 | static void __init cm_t3517_init(void) |
| 231 | { |
| 232 | omap3_mux_init(board_mux, OMAP_PACKAGE_CBB); |
| 233 | omap_serial_init(); |
| 234 | cm_t3517_init_leds(); |
Igor Grinberg | ec34fcc | 2010-09-21 16:03:12 +0000 | [diff] [blame^] | 235 | cm_t3517_init_nand(); |
Igor Grinberg | 46893a5 | 2010-09-21 16:03:10 +0000 | [diff] [blame] | 236 | cm_t3517_init_rtc(); |
Igor Grinberg | 525d75b | 2010-09-21 16:03:11 +0000 | [diff] [blame] | 237 | cm_t3517_init_usbh(); |
Igor Grinberg | d04b620 | 2010-09-21 16:03:09 +0000 | [diff] [blame] | 238 | } |
| 239 | |
| 240 | MACHINE_START(CM_T3517, "Compulab CM-T3517") |
| 241 | .phys_io = 0x48000000, |
| 242 | .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc, |
| 243 | .boot_params = 0x80000100, |
| 244 | .map_io = omap3_map_io, |
| 245 | .reserve = omap_reserve, |
| 246 | .init_irq = cm_t3517_init_irq, |
| 247 | .init_machine = cm_t3517_init, |
| 248 | .timer = &omap_timer, |
| 249 | MACHINE_END |