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 */
25 #include <linux/kernel.h>
26 #include <linux/init.h>
27 #include <linux/platform_device.h>
28 #include <linux/delay.h>
29 #include <linux/gpio.h>
30 #include <linux/leds.h>
31 #include <linux/rtc-v3020.h>
32 #include <linux/mtd/mtd.h>
33 #include <linux/mtd/nand.h>
34 #include <linux/mtd/partitions.h>
35 #include <linux/can/platform/ti_hecc.h>
36 #include <linux/regulator/machine.h>
37 #include <linux/regulator/fixed.h>
38 #include <linux/usb/phy.h>
40 #include <asm/mach-types.h>
41 #include <asm/mach/arch.h>
42 #include <asm/mach/map.h>
44 #include "common.h"
45 #include <linux/platform_data/mtd-nand-omap2.h>
46 #include "gpmc.h"
48 #include "am35xx.h"
50 #include "mux.h"
51 #include "control.h"
52 #include "common-board-devices.h"
53 #include "am35xx-emac.h"
54 #include "gpmc-nand.h"
56 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
57 static struct gpio_led cm_t3517_leds[] = {
58 [0] = {
59 .gpio = 186,
60 .name = "cm-t3517:green",
61 .default_trigger = "heartbeat",
62 .active_low = 0,
63 },
64 };
66 static struct gpio_led_platform_data cm_t3517_led_pdata = {
67 .num_leds = ARRAY_SIZE(cm_t3517_leds),
68 .leds = cm_t3517_leds,
69 };
71 static struct platform_device cm_t3517_led_device = {
72 .name = "leds-gpio",
73 .id = -1,
74 .dev = {
75 .platform_data = &cm_t3517_led_pdata,
76 },
77 };
79 static void __init cm_t3517_init_leds(void)
80 {
81 platform_device_register(&cm_t3517_led_device);
82 }
83 #else
84 static inline void cm_t3517_init_leds(void) {}
85 #endif
87 #if defined(CONFIG_CAN_TI_HECC) || defined(CONFIG_CAN_TI_HECC_MODULE)
88 static struct resource cm_t3517_hecc_resources[] = {
89 {
90 .start = AM35XX_IPSS_HECC_BASE,
91 .end = AM35XX_IPSS_HECC_BASE + SZ_16K - 1,
92 .flags = IORESOURCE_MEM,
93 },
94 {
95 .start = 24 + OMAP_INTC_START,
96 .flags = IORESOURCE_IRQ,
97 },
98 };
100 static struct ti_hecc_platform_data cm_t3517_hecc_pdata = {
101 .scc_hecc_offset = AM35XX_HECC_SCC_HECC_OFFSET,
102 .scc_ram_offset = AM35XX_HECC_SCC_RAM_OFFSET,
103 .hecc_ram_offset = AM35XX_HECC_RAM_OFFSET,
104 .mbx_offset = AM35XX_HECC_MBOX_OFFSET,
105 .int_line = AM35XX_HECC_INT_LINE,
106 .version = AM35XX_HECC_VERSION,
107 };
109 static struct platform_device cm_t3517_hecc_device = {
110 .name = "ti_hecc",
111 .id = 1,
112 .num_resources = ARRAY_SIZE(cm_t3517_hecc_resources),
113 .resource = cm_t3517_hecc_resources,
114 .dev = {
115 .platform_data = &cm_t3517_hecc_pdata,
116 },
117 };
119 static void cm_t3517_init_hecc(void)
120 {
121 platform_device_register(&cm_t3517_hecc_device);
122 }
123 #else
124 static inline void cm_t3517_init_hecc(void) {}
125 #endif
127 #if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE)
128 #define RTC_IO_GPIO (153)
129 #define RTC_WR_GPIO (154)
130 #define RTC_RD_GPIO (53)
131 #define RTC_CS_GPIO (163)
132 #define RTC_CS_EN_GPIO (160)
134 struct v3020_platform_data cm_t3517_v3020_pdata = {
135 .use_gpio = 1,
136 .gpio_cs = RTC_CS_GPIO,
137 .gpio_wr = RTC_WR_GPIO,
138 .gpio_rd = RTC_RD_GPIO,
139 .gpio_io = RTC_IO_GPIO,
140 };
142 static struct platform_device cm_t3517_rtc_device = {
143 .name = "v3020",
144 .id = -1,
145 .dev = {
146 .platform_data = &cm_t3517_v3020_pdata,
147 }
148 };
150 static void __init cm_t3517_init_rtc(void)
151 {
152 int err;
154 err = gpio_request_one(RTC_CS_EN_GPIO, GPIOF_OUT_INIT_HIGH,
155 "rtc cs en");
156 if (err) {
157 pr_err("CM-T3517: rtc cs en gpio request failed: %d\n", err);
158 return;
159 }
161 platform_device_register(&cm_t3517_rtc_device);
162 }
163 #else
164 static inline void cm_t3517_init_rtc(void) {}
165 #endif
167 #if defined(CONFIG_USB_EHCI_HCD) || defined(CONFIG_USB_EHCI_HCD_MODULE)
168 #define HSUSB1_RESET_GPIO (146)
169 #define HSUSB2_RESET_GPIO (147)
170 #define USB_HUB_RESET_GPIO (152)
172 /* PHY device on HS USB Port 1 i.e. nop_usb_xceiv.1 */
173 static struct platform_device hsusb1_phy_device = {
174 .name = "nop_usb_xceiv",
175 .id = 1,
176 };
178 /* Regulator for HS USB Port 1 PHY reset */
179 static struct regulator_consumer_supply hsusb1_reset_supplies[] = {
180 /* Link PHY device to reset supply so it gets used in the PHY driver */
181 REGULATOR_SUPPLY("reset", "nop_usb_xceiv.1"),
182 };
184 static struct regulator_init_data hsusb1_reset_data = {
185 .constraints = {
186 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
187 },
188 .consumer_supplies = hsusb1_reset_supplies,
189 .num_consumer_supplies = ARRAY_SIZE(hsusb1_reset_supplies),
190 };
192 static struct fixed_voltage_config hsusb1_reset_config = {
193 .supply_name = "hsusb1_reset",
194 .microvolts = 3300000,
195 .gpio = HSUSB1_RESET_GPIO,
196 .startup_delay = 70000, /* 70msec */
197 .enable_high = 1,
198 .enabled_at_boot = 0, /* keep in RESET */
199 .init_data = &hsusb1_reset_data,
200 };
202 static struct platform_device hsusb1_reset_device = {
203 .name = "reg-fixed-voltage",
204 .id = PLATFORM_DEVID_AUTO,
205 .dev = {
206 .platform_data = &hsusb1_reset_config,
207 },
208 };
210 /* PHY device on HS USB Port 2 i.e. nop_usb_xceiv.2 */
211 static struct platform_device hsusb2_phy_device = {
212 .name = "nop_usb_xceiv",
213 .id = 2,
214 };
216 /* Regulator for HS USB Port 2 PHY reset */
217 static struct regulator_consumer_supply hsusb2_reset_supplies[] = {
218 /* Link PHY device to reset supply so it gets used in the PHY driver */
219 REGULATOR_SUPPLY("reset", "nop_usb_xceiv.2"),
220 };
222 static struct regulator_init_data hsusb2_reset_data = {
223 .constraints = {
224 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
225 },
226 .consumer_supplies = hsusb2_reset_supplies,
227 .num_consumer_supplies = ARRAY_SIZE(hsusb2_reset_supplies),
228 };
230 static struct fixed_voltage_config hsusb2_reset_config = {
231 .supply_name = "hsusb2_reset",
232 .microvolts = 3300000,
233 .gpio = HSUSB2_RESET_GPIO,
234 .startup_delay = 70000, /* 70msec */
235 .enable_high = 1,
236 .enabled_at_boot = 0, /* keep in RESET */
237 .init_data = &hsusb2_reset_data,
238 };
240 static struct platform_device hsusb2_reset_device = {
241 .name = "reg-fixed-voltage",
242 .id = PLATFORM_DEVID_AUTO,
243 .dev = {
244 .platform_data = &hsusb2_reset_config,
245 },
246 };
248 static struct usbhs_omap_platform_data cm_t3517_ehci_pdata __initdata = {
249 .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
250 .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
251 };
253 static struct platform_device *usbhs_devices[] = {
254 &hsusb1_phy_device,
255 &hsusb1_reset_device,
256 &hsusb2_phy_device,
257 &hsusb2_reset_device,
258 };
260 static int __init cm_t3517_init_usbh(void)
261 {
262 int err;
264 err = gpio_request_one(USB_HUB_RESET_GPIO, GPIOF_OUT_INIT_LOW,
265 "usb hub rst");
266 if (err) {
267 pr_err("CM-T3517: usb hub rst gpio request failed: %d\n", err);
268 } else {
269 udelay(10);
270 gpio_set_value(USB_HUB_RESET_GPIO, 1);
271 msleep(1);
272 }
274 platform_add_devices(usbhs_devices, ARRAY_SIZE(usbhs_devices));
276 /* PHY on HSUSB Port 1 i.e. index 0 */
277 usb_bind_phy("ehci-omap.0", 0, "nop_usb_xceiv.1");
278 /* PHY on HSUSB Port 2 i.e. index 1 */
279 usb_bind_phy("ehci-omap.0", 1, "nop_usb_xceiv.2");
281 usbhs_init(&cm_t3517_ehci_pdata);
283 return 0;
284 }
285 #else
286 static inline int cm_t3517_init_usbh(void)
287 {
288 return 0;
289 }
290 #endif
292 #if defined(CONFIG_MTD_NAND_OMAP2) || defined(CONFIG_MTD_NAND_OMAP2_MODULE)
293 static struct mtd_partition cm_t3517_nand_partitions[] = {
294 {
295 .name = "xloader",
296 .offset = 0, /* Offset = 0x00000 */
297 .size = 4 * NAND_BLOCK_SIZE,
298 .mask_flags = MTD_WRITEABLE
299 },
300 {
301 .name = "uboot",
302 .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
303 .size = 15 * NAND_BLOCK_SIZE,
304 },
305 {
306 .name = "uboot environment",
307 .offset = MTDPART_OFS_APPEND, /* Offset = 0x260000 */
308 .size = 2 * NAND_BLOCK_SIZE,
309 },
310 {
311 .name = "linux",
312 .offset = MTDPART_OFS_APPEND, /* Offset = 0x2A0000 */
313 .size = 32 * NAND_BLOCK_SIZE,
314 },
315 {
316 .name = "rootfs",
317 .offset = MTDPART_OFS_APPEND, /* Offset = 0x6A0000 */
318 .size = MTDPART_SIZ_FULL,
319 },
320 };
322 static struct omap_nand_platform_data cm_t3517_nand_data = {
323 .parts = cm_t3517_nand_partitions,
324 .nr_parts = ARRAY_SIZE(cm_t3517_nand_partitions),
325 .cs = 0,
326 };
328 static void __init cm_t3517_init_nand(void)
329 {
330 if (gpmc_nand_init(&cm_t3517_nand_data, NULL) < 0)
331 pr_err("CM-T3517: NAND initialization failed\n");
332 }
333 #else
334 static inline void cm_t3517_init_nand(void) {}
335 #endif
337 #ifdef CONFIG_OMAP_MUX
338 static struct omap_board_mux board_mux[] __initdata = {
339 /* GPIO186 - Green LED */
340 OMAP3_MUX(SYS_CLKOUT2, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),
342 /* RTC GPIOs: */
343 /* IO - GPIO153 */
344 OMAP3_MUX(MCBSP4_DR, OMAP_MUX_MODE4 | OMAP_PIN_INPUT),
345 /* WR# - GPIO154 */
346 OMAP3_MUX(MCBSP4_DX, OMAP_MUX_MODE4 | OMAP_PIN_INPUT),
347 /* RD# - GPIO53 */
348 OMAP3_MUX(GPMC_NCS2, OMAP_MUX_MODE4 | OMAP_PIN_INPUT),
349 /* CS# - GPIO163 */
350 OMAP3_MUX(UART3_CTS_RCTX, OMAP_MUX_MODE4 | OMAP_PIN_INPUT),
351 /* CS EN - GPIO160 */
352 OMAP3_MUX(MCBSP_CLKS, OMAP_MUX_MODE4 | OMAP_PIN_INPUT),
354 /* HSUSB1 RESET */
355 OMAP3_MUX(UART2_TX, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),
356 /* HSUSB2 RESET */
357 OMAP3_MUX(UART2_RX, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),
358 /* CM-T3517 USB HUB nRESET */
359 OMAP3_MUX(MCBSP4_CLKX, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),
361 { .reg_offset = OMAP_MUX_TERMINATOR },
362 };
363 #endif
365 static void __init cm_t3517_init(void)
366 {
367 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
368 omap_serial_init();
369 omap_sdrc_init(NULL, NULL);
370 cm_t3517_init_leds();
371 cm_t3517_init_nand();
372 cm_t3517_init_rtc();
373 cm_t3517_init_usbh();
374 cm_t3517_init_hecc();
375 am35xx_emac_init(AM35XX_DEFAULT_MDIO_FREQUENCY, 1);
376 }
378 MACHINE_START(CM_T3517, "Compulab CM-T3517")
379 .atag_offset = 0x100,
380 .reserve = omap_reserve,
381 .map_io = omap3_map_io,
382 .init_early = am35xx_init_early,
383 .init_irq = omap3_init_irq,
384 .handle_irq = omap3_intc_handle_irq,
385 .init_machine = cm_t3517_init,
386 .init_late = am35xx_init_late,
387 .timer = &omap3_gp_timer,
388 .restart = omap3xxx_restart,
389 MACHINE_END