]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - arch/arm/mach-davinci/board-omapl138-hawk.c
HID: usbhid: Add HID_QUIRK_NOGET for Aten CS-1758 KVM switch
[mirror_ubuntu-artful-kernel.git] / arch / arm / mach-davinci / board-omapl138-hawk.c
1 /*
2 * Hawkboard.org based on TI's OMAP-L138 Platform
3 *
4 * Initial code: Syed Mohammed Khasim
5 *
6 * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com
7 *
8 * This file is licensed under the terms of the GNU General Public License
9 * version 2. This program is licensed "as is" without any warranty of
10 * any kind, whether express or implied.
11 */
12 #include <linux/kernel.h>
13 #include <linux/init.h>
14 #include <linux/console.h>
15 #include <linux/gpio.h>
16 #include <linux/gpio/machine.h>
17 #include <linux/platform_data/gpio-davinci.h>
18 #include <linux/regulator/machine.h>
19
20 #include <asm/mach-types.h>
21 #include <asm/mach/arch.h>
22
23 #include <mach/common.h>
24 #include "cp_intc.h"
25 #include <mach/da8xx.h>
26 #include <mach/mux.h>
27
28 #define HAWKBOARD_PHY_ID "davinci_mdio-0:07"
29
30 #define DA850_USB1_VBUS_PIN GPIO_TO_PIN(2, 4)
31 #define DA850_USB1_OC_PIN GPIO_TO_PIN(6, 13)
32
33 static short omapl138_hawk_mii_pins[] __initdata = {
34 DA850_MII_TXEN, DA850_MII_TXCLK, DA850_MII_COL, DA850_MII_TXD_3,
35 DA850_MII_TXD_2, DA850_MII_TXD_1, DA850_MII_TXD_0, DA850_MII_RXER,
36 DA850_MII_CRS, DA850_MII_RXCLK, DA850_MII_RXDV, DA850_MII_RXD_3,
37 DA850_MII_RXD_2, DA850_MII_RXD_1, DA850_MII_RXD_0, DA850_MDIO_CLK,
38 DA850_MDIO_D,
39 -1
40 };
41
42 static __init void omapl138_hawk_config_emac(void)
43 {
44 void __iomem *cfgchip3 = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG);
45 int ret;
46 u32 val;
47 struct davinci_soc_info *soc_info = &davinci_soc_info;
48
49 val = __raw_readl(cfgchip3);
50 val &= ~BIT(8);
51 ret = davinci_cfg_reg_list(omapl138_hawk_mii_pins);
52 if (ret) {
53 pr_warn("%s: CPGMAC/MII mux setup failed: %d\n", __func__, ret);
54 return;
55 }
56
57 /* configure the CFGCHIP3 register for MII */
58 __raw_writel(val, cfgchip3);
59 pr_info("EMAC: MII PHY configured\n");
60
61 soc_info->emac_pdata->phy_id = HAWKBOARD_PHY_ID;
62
63 ret = da8xx_register_emac();
64 if (ret)
65 pr_warn("%s: EMAC registration failed: %d\n", __func__, ret);
66 }
67
68 /*
69 * The following EDMA channels/slots are not being used by drivers (for
70 * example: Timer, GPIO, UART events etc) on da850/omap-l138 EVM/Hawkboard,
71 * hence they are being reserved for codecs on the DSP side.
72 */
73 static const s16 da850_dma0_rsv_chans[][2] = {
74 /* (offset, number) */
75 { 8, 6},
76 {24, 4},
77 {30, 2},
78 {-1, -1}
79 };
80
81 static const s16 da850_dma0_rsv_slots[][2] = {
82 /* (offset, number) */
83 { 8, 6},
84 {24, 4},
85 {30, 50},
86 {-1, -1}
87 };
88
89 static const s16 da850_dma1_rsv_chans[][2] = {
90 /* (offset, number) */
91 { 0, 28},
92 {30, 2},
93 {-1, -1}
94 };
95
96 static const s16 da850_dma1_rsv_slots[][2] = {
97 /* (offset, number) */
98 { 0, 28},
99 {30, 90},
100 {-1, -1}
101 };
102
103 static struct edma_rsv_info da850_edma_cc0_rsv = {
104 .rsv_chans = da850_dma0_rsv_chans,
105 .rsv_slots = da850_dma0_rsv_slots,
106 };
107
108 static struct edma_rsv_info da850_edma_cc1_rsv = {
109 .rsv_chans = da850_dma1_rsv_chans,
110 .rsv_slots = da850_dma1_rsv_slots,
111 };
112
113 static struct edma_rsv_info *da850_edma_rsv[2] = {
114 &da850_edma_cc0_rsv,
115 &da850_edma_cc1_rsv,
116 };
117
118 static const short hawk_mmcsd0_pins[] = {
119 DA850_MMCSD0_DAT_0, DA850_MMCSD0_DAT_1, DA850_MMCSD0_DAT_2,
120 DA850_MMCSD0_DAT_3, DA850_MMCSD0_CLK, DA850_MMCSD0_CMD,
121 DA850_GPIO3_12, DA850_GPIO3_13,
122 -1
123 };
124
125 static struct gpiod_lookup_table mmc_gpios_table = {
126 .dev_id = "da830-mmc.0",
127 .table = {
128 /* CD: gpio3_12: gpio60: chip 1 contains gpio range 32-63*/
129 GPIO_LOOKUP("davinci_gpio.1", 28, "cd", GPIO_ACTIVE_LOW),
130 GPIO_LOOKUP("davinci_gpio.1", 29, "wp", GPIO_ACTIVE_LOW),
131 },
132 };
133
134 static struct davinci_mmc_config da850_mmc_config = {
135 .wires = 4,
136 .max_freq = 50000000,
137 .caps = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
138 };
139
140 static __init void omapl138_hawk_mmc_init(void)
141 {
142 int ret;
143
144 ret = davinci_cfg_reg_list(hawk_mmcsd0_pins);
145 if (ret) {
146 pr_warn("%s: MMC/SD0 mux setup failed: %d\n", __func__, ret);
147 return;
148 }
149
150 gpiod_add_lookup_table(&mmc_gpios_table);
151
152 ret = da8xx_register_mmcsd0(&da850_mmc_config);
153 if (ret) {
154 pr_warn("%s: MMC/SD0 registration failed: %d\n", __func__, ret);
155 goto mmc_setup_mmcsd_fail;
156 }
157
158 return;
159
160 mmc_setup_mmcsd_fail:
161 gpiod_remove_lookup_table(&mmc_gpios_table);
162 }
163
164 static irqreturn_t omapl138_hawk_usb_ocic_irq(int irq, void *dev_id);
165 static da8xx_ocic_handler_t hawk_usb_ocic_handler;
166
167 static const short da850_hawk_usb11_pins[] = {
168 DA850_GPIO2_4, DA850_GPIO6_13,
169 -1
170 };
171
172 static int hawk_usb_set_power(unsigned port, int on)
173 {
174 gpio_set_value(DA850_USB1_VBUS_PIN, on);
175 return 0;
176 }
177
178 static int hawk_usb_get_power(unsigned port)
179 {
180 return gpio_get_value(DA850_USB1_VBUS_PIN);
181 }
182
183 static int hawk_usb_get_oci(unsigned port)
184 {
185 return !gpio_get_value(DA850_USB1_OC_PIN);
186 }
187
188 static int hawk_usb_ocic_notify(da8xx_ocic_handler_t handler)
189 {
190 int irq = gpio_to_irq(DA850_USB1_OC_PIN);
191 int error = 0;
192
193 if (handler != NULL) {
194 hawk_usb_ocic_handler = handler;
195
196 error = request_irq(irq, omapl138_hawk_usb_ocic_irq,
197 IRQF_TRIGGER_RISING |
198 IRQF_TRIGGER_FALLING,
199 "OHCI over-current indicator", NULL);
200 if (error)
201 pr_err("%s: could not request IRQ to watch "
202 "over-current indicator changes\n", __func__);
203 } else {
204 free_irq(irq, NULL);
205 }
206 return error;
207 }
208
209 static struct da8xx_ohci_root_hub omapl138_hawk_usb11_pdata = {
210 .set_power = hawk_usb_set_power,
211 .get_power = hawk_usb_get_power,
212 .get_oci = hawk_usb_get_oci,
213 .ocic_notify = hawk_usb_ocic_notify,
214 /* TPS2087 switch @ 5V */
215 .potpgt = (3 + 1) / 2, /* 3 ms max */
216 };
217
218 static irqreturn_t omapl138_hawk_usb_ocic_irq(int irq, void *dev_id)
219 {
220 hawk_usb_ocic_handler(&omapl138_hawk_usb11_pdata, 1);
221 return IRQ_HANDLED;
222 }
223
224 static __init void omapl138_hawk_usb_init(void)
225 {
226 int ret;
227
228 ret = davinci_cfg_reg_list(da850_hawk_usb11_pins);
229 if (ret) {
230 pr_warn("%s: USB 1.1 PinMux setup failed: %d\n", __func__, ret);
231 return;
232 }
233
234 ret = da8xx_register_usb20_phy_clk(false);
235 if (ret)
236 pr_warn("%s: USB 2.0 PHY CLK registration failed: %d\n",
237 __func__, ret);
238
239 ret = da8xx_register_usb11_phy_clk(false);
240 if (ret)
241 pr_warn("%s: USB 1.1 PHY CLK registration failed: %d\n",
242 __func__, ret);
243
244 ret = da8xx_register_usb_phy();
245 if (ret)
246 pr_warn("%s: USB PHY registration failed: %d\n",
247 __func__, ret);
248
249 ret = gpio_request_one(DA850_USB1_VBUS_PIN,
250 GPIOF_DIR_OUT, "USB1 VBUS");
251 if (ret < 0) {
252 pr_err("%s: failed to request GPIO for USB 1.1 port "
253 "power control: %d\n", __func__, ret);
254 return;
255 }
256
257 ret = gpio_request_one(DA850_USB1_OC_PIN,
258 GPIOF_DIR_IN, "USB1 OC");
259 if (ret < 0) {
260 pr_err("%s: failed to request GPIO for USB 1.1 port "
261 "over-current indicator: %d\n", __func__, ret);
262 goto usb11_setup_oc_fail;
263 }
264
265 ret = da8xx_register_usb11(&omapl138_hawk_usb11_pdata);
266 if (ret) {
267 pr_warn("%s: USB 1.1 registration failed: %d\n", __func__, ret);
268 goto usb11_setup_fail;
269 }
270
271 return;
272
273 usb11_setup_fail:
274 gpio_free(DA850_USB1_OC_PIN);
275 usb11_setup_oc_fail:
276 gpio_free(DA850_USB1_VBUS_PIN);
277 }
278
279 static __init void omapl138_hawk_init(void)
280 {
281 int ret;
282
283 ret = da8xx_register_cfgchip();
284 if (ret)
285 pr_warn("%s: CFGCHIP registration failed: %d\n", __func__, ret);
286
287 ret = da850_register_gpio();
288 if (ret)
289 pr_warn("%s: GPIO init failed: %d\n", __func__, ret);
290
291 davinci_serial_init(da8xx_serial_device);
292
293 omapl138_hawk_config_emac();
294
295 ret = da850_register_edma(da850_edma_rsv);
296 if (ret)
297 pr_warn("%s: EDMA registration failed: %d\n", __func__, ret);
298
299 omapl138_hawk_mmc_init();
300
301 omapl138_hawk_usb_init();
302
303 ret = da8xx_register_watchdog();
304 if (ret)
305 pr_warn("%s: watchdog registration failed: %d\n",
306 __func__, ret);
307
308 ret = da8xx_register_rproc();
309 if (ret)
310 pr_warn("%s: dsp/rproc registration failed: %d\n",
311 __func__, ret);
312
313 regulator_has_full_constraints();
314 }
315
316 #ifdef CONFIG_SERIAL_8250_CONSOLE
317 static int __init omapl138_hawk_console_init(void)
318 {
319 if (!machine_is_omapl138_hawkboard())
320 return 0;
321
322 return add_preferred_console("ttyS", 2, "115200");
323 }
324 console_initcall(omapl138_hawk_console_init);
325 #endif
326
327 static void __init omapl138_hawk_map_io(void)
328 {
329 da850_init();
330 }
331
332 MACHINE_START(OMAPL138_HAWKBOARD, "AM18x/OMAP-L138 Hawkboard")
333 .atag_offset = 0x100,
334 .map_io = omapl138_hawk_map_io,
335 .init_irq = cp_intc_init,
336 .init_time = davinci_timer_init,
337 .init_machine = omapl138_hawk_init,
338 .init_late = davinci_init_late,
339 .dma_zone_size = SZ_128M,
340 .restart = da8xx_restart,
341 .reserve = da8xx_rproc_reserve_cma,
342 MACHINE_END