Commit | Line | Data |
---|---|---|
577145f4 VP |
1 | /* |
2 | * Copyright (C) 2009 Texas Instruments Inc. | |
3 | * Mikkel Christensen <mlc@ti.com> | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or modify | |
6 | * it under the terms of the GNU General Public License version 2 as | |
7 | * published by the Free Software Foundation. | |
8 | */ | |
9 | ||
10 | #include <linux/kernel.h> | |
11 | #include <linux/init.h> | |
12 | #include <linux/gpio.h> | |
13 | #include <linux/serial_8250.h> | |
14 | #include <linux/smsc911x.h> | |
c426df87 | 15 | #include <linux/interrupt.h> |
577145f4 | 16 | |
5b3689f4 RD |
17 | #include <linux/regulator/fixed.h> |
18 | #include <linux/regulator/machine.h> | |
19 | ||
ce491cf8 | 20 | #include <plat/gpmc.h> |
21b42731 | 21 | #include <plat/gpmc-smsc911x.h> |
7d7e1eba | 22 | #include <plat/serial.h> |
577145f4 | 23 | |
04aeae77 MK |
24 | #include <mach/board-zoom.h> |
25 | ||
62d0b336 | 26 | #define ZOOM_SMSC911X_CS 7 |
27 | #define ZOOM_SMSC911X_GPIO 158 | |
28 | #define ZOOM_QUADUART_CS 3 | |
29 | #define ZOOM_QUADUART_GPIO 102 | |
4e964252 | 30 | #define ZOOM_QUADUART_RST_GPIO 152 |
577145f4 VP |
31 | #define QUART_CLK 1843200 |
32 | #define DEBUG_BASE 0x08000000 | |
62d0b336 | 33 | #define ZOOM_ETHR_START DEBUG_BASE |
577145f4 | 34 | |
21b42731 MR |
35 | static struct omap_smsc911x_platform_data zoom_smsc911x_cfg = { |
36 | .cs = ZOOM_SMSC911X_CS, | |
37 | .gpio_irq = ZOOM_SMSC911X_GPIO, | |
38 | .gpio_reset = -EINVAL, | |
577145f4 | 39 | .flags = SMSC911X_USE_32BIT, |
577145f4 VP |
40 | }; |
41 | ||
62d0b336 | 42 | static inline void __init zoom_init_smsc911x(void) |
577145f4 | 43 | { |
21b42731 | 44 | gpmc_smsc911x_init(&zoom_smsc911x_cfg); |
577145f4 VP |
45 | } |
46 | ||
47 | static struct plat_serial8250_port serial_platform_data[] = { | |
48 | { | |
a4f57b81 | 49 | .mapbase = ZOOM_UART_BASE, |
577145f4 | 50 | .flags = UPF_BOOT_AUTOCONF|UPF_IOREMAP|UPF_SHARE_IRQ, |
c426df87 | 51 | .irqflags = IRQF_SHARED | IRQF_TRIGGER_RISING, |
577145f4 VP |
52 | .iotype = UPIO_MEM, |
53 | .regshift = 1, | |
54 | .uartclk = QUART_CLK, | |
55 | }, { | |
56 | .flags = 0 | |
57 | } | |
58 | }; | |
59 | ||
62d0b336 | 60 | static struct platform_device zoom_debugboard_serial_device = { |
577145f4 | 61 | .name = "serial8250", |
fcbcea93 | 62 | .id = PLAT8250_DEV_PLATFORM, |
577145f4 VP |
63 | .dev = { |
64 | .platform_data = serial_platform_data, | |
65 | }, | |
66 | }; | |
67 | ||
62d0b336 | 68 | static inline void __init zoom_init_quaduart(void) |
577145f4 VP |
69 | { |
70 | int quart_cs; | |
71 | unsigned long cs_mem_base; | |
72 | int quart_gpio = 0; | |
73 | ||
4e964252 C |
74 | if (gpio_request_one(ZOOM_QUADUART_RST_GPIO, |
75 | GPIOF_OUT_INIT_LOW, | |
76 | "TL16CP754C GPIO") < 0) { | |
77 | pr_err("Failed to request GPIO%d for TL16CP754C\n", | |
78 | ZOOM_QUADUART_RST_GPIO); | |
79 | return; | |
80 | } | |
81 | ||
62d0b336 | 82 | quart_cs = ZOOM_QUADUART_CS; |
577145f4 VP |
83 | |
84 | if (gpmc_cs_request(quart_cs, SZ_1M, &cs_mem_base) < 0) { | |
85 | printk(KERN_ERR "Failed to request GPMC mem" | |
86 | "for Quad UART(TL16CP754C)\n"); | |
87 | return; | |
88 | } | |
89 | ||
62d0b336 | 90 | quart_gpio = ZOOM_QUADUART_GPIO; |
577145f4 | 91 | |
bc593f5d | 92 | if (gpio_request_one(quart_gpio, GPIOF_IN, "TL16CP754C GPIO") < 0) |
577145f4 VP |
93 | printk(KERN_ERR "Failed to request GPIO%d for TL16CP754C\n", |
94 | quart_gpio); | |
46a0a540 TKD |
95 | |
96 | serial_platform_data[0].irq = gpio_to_irq(102); | |
577145f4 VP |
97 | } |
98 | ||
62d0b336 | 99 | static inline int omap_zoom_debugboard_detect(void) |
577145f4 VP |
100 | { |
101 | int debug_board_detect = 0; | |
2fcc81a3 | 102 | int ret = 1; |
577145f4 | 103 | |
62d0b336 | 104 | debug_board_detect = ZOOM_SMSC911X_GPIO; |
577145f4 | 105 | |
bc593f5d IG |
106 | if (gpio_request_one(debug_board_detect, GPIOF_IN, |
107 | "Zoom debug board detect") < 0) { | |
62d0b336 | 108 | printk(KERN_ERR "Failed to request GPIO%d for Zoom debug" |
577145f4 VP |
109 | "board detect\n", debug_board_detect); |
110 | return 0; | |
111 | } | |
577145f4 VP |
112 | |
113 | if (!gpio_get_value(debug_board_detect)) { | |
2fcc81a3 | 114 | ret = 0; |
577145f4 | 115 | } |
2fcc81a3 VP |
116 | gpio_free(debug_board_detect); |
117 | return ret; | |
577145f4 VP |
118 | } |
119 | ||
62d0b336 | 120 | static struct platform_device *zoom_devices[] __initdata = { |
62d0b336 | 121 | &zoom_debugboard_serial_device, |
577145f4 VP |
122 | }; |
123 | ||
5b3689f4 RD |
124 | static struct regulator_consumer_supply dummy_supplies[] = { |
125 | REGULATOR_SUPPLY("vddvario", "smsc911x.0"), | |
126 | REGULATOR_SUPPLY("vdd33a", "smsc911x.0"), | |
127 | }; | |
128 | ||
62d0b336 | 129 | int __init zoom_debugboard_init(void) |
577145f4 | 130 | { |
62d0b336 | 131 | if (!omap_zoom_debugboard_detect()) |
577145f4 VP |
132 | return 0; |
133 | ||
5b3689f4 | 134 | regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies)); |
62d0b336 | 135 | zoom_init_smsc911x(); |
136 | zoom_init_quaduart(); | |
137 | return platform_add_devices(zoom_devices, ARRAY_SIZE(zoom_devices)); | |
577145f4 | 138 | } |