arm: omap4: usb: explicitly configure MUSB pads
[deliverable/linux.git] / arch / arm / mach-omap2 / usb-musb.c
CommitLineData
18cb7aca
FB
1/*
2 * linux/arch/arm/mach-omap2/usb-musb.c
3 *
4 * This file will contain the board specific details for the
5 * MENTOR USB OTG controller on OMAP3430
6 *
7 * Copyright (C) 2007-2008 Texas Instruments
8 * Copyright (C) 2008 Nokia Corporation
9 * Author: Vikram Pandita
10 *
11 * Generalization by:
12 * Felipe Balbi <felipe.balbi@nokia.com>
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License version 2 as
16 * published by the Free Software Foundation.
17 */
18
19#include <linux/types.h>
20#include <linux/errno.h>
21#include <linux/delay.h>
22#include <linux/platform_device.h>
23#include <linux/clk.h>
24#include <linux/dma-mapping.h>
25#include <linux/io.h>
26
27#include <linux/usb/musb.h>
28
29#include <mach/hardware.h>
30#include <mach/irqs.h>
3a0d30bc 31#include <mach/am35xx.h>
ce491cf8 32#include <plat/usb.h>
2aae4221 33#include "mux.h"
18cb7aca 34
7c925546 35#if defined(CONFIG_USB_MUSB_OMAP2PLUS) || defined (CONFIG_USB_MUSB_AM35X)
94a3ef6f 36
18cb7aca
FB
37static struct resource musb_resources[] = {
38 [0] = { /* start and end set dynamically */
39 .flags = IORESOURCE_MEM,
40 },
41 [1] = { /* general IRQ */
42 .start = INT_243X_HS_USB_MC,
43 .flags = IORESOURCE_IRQ,
fcf173e4 44 .name = "mc",
18cb7aca
FB
45 },
46 [2] = { /* DMA IRQ */
47 .start = INT_243X_HS_USB_DMA,
48 .flags = IORESOURCE_IRQ,
fcf173e4 49 .name = "dma",
18cb7aca
FB
50 },
51};
52
18cb7aca
FB
53static struct musb_hdrc_config musb_config = {
54 .multipoint = 1,
55 .dyn_fifo = 1,
18cb7aca 56 .num_eps = 16,
18cb7aca 57 .ram_bits = 12,
18cb7aca
FB
58};
59
60static struct musb_hdrc_platform_data musb_plat = {
61#ifdef CONFIG_USB_MUSB_OTG
62 .mode = MUSB_OTG,
63#elif defined(CONFIG_USB_MUSB_HDRC_HCD)
64 .mode = MUSB_HOST,
65#elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
66 .mode = MUSB_PERIPHERAL,
67#endif
68 /* .clock is set dynamically */
18cb7aca
FB
69 .config = &musb_config,
70
71 /* REVISIT charge pump on TWL4030 can supply up to
72 * 100 mA ... but this value is board-specific, like
73 * "mode", and should be passed to usb_musb_init().
74 */
75 .power = 50, /* up to 100 mA */
76};
77
e930438c 78static u64 musb_dmamask = DMA_BIT_MASK(32);
18cb7aca
FB
79
80static struct platform_device musb_device = {
dc09886b 81 .name = "musb-omap2430",
18cb7aca
FB
82 .id = -1,
83 .dev = {
84 .dma_mask = &musb_dmamask,
e930438c 85 .coherent_dma_mask = DMA_BIT_MASK(32),
18cb7aca
FB
86 .platform_data = &musb_plat,
87 },
88 .num_resources = ARRAY_SIZE(musb_resources),
89 .resource = musb_resources,
90};
91
2aae4221
AG
92static void usb_musb_mux_init(struct omap_musb_board_data *board_data)
93{
94 switch (board_data->interface_type) {
95 case MUSB_INTERFACE_UTMI:
96 omap_mux_init_signal("usba0_otg_dp", OMAP_PIN_INPUT);
97 omap_mux_init_signal("usba0_otg_dm", OMAP_PIN_INPUT);
98 break;
99 case MUSB_INTERFACE_ULPI:
100 omap_mux_init_signal("usba0_ulpiphy_clk",
101 OMAP_PIN_INPUT_PULLDOWN);
102 omap_mux_init_signal("usba0_ulpiphy_stp",
103 OMAP_PIN_INPUT_PULLDOWN);
104 omap_mux_init_signal("usba0_ulpiphy_dir",
105 OMAP_PIN_INPUT_PULLDOWN);
106 omap_mux_init_signal("usba0_ulpiphy_nxt",
107 OMAP_PIN_INPUT_PULLDOWN);
108 omap_mux_init_signal("usba0_ulpiphy_dat0",
109 OMAP_PIN_INPUT_PULLDOWN);
110 omap_mux_init_signal("usba0_ulpiphy_dat1",
111 OMAP_PIN_INPUT_PULLDOWN);
112 omap_mux_init_signal("usba0_ulpiphy_dat2",
113 OMAP_PIN_INPUT_PULLDOWN);
114 omap_mux_init_signal("usba0_ulpiphy_dat3",
115 OMAP_PIN_INPUT_PULLDOWN);
116 omap_mux_init_signal("usba0_ulpiphy_dat4",
117 OMAP_PIN_INPUT_PULLDOWN);
118 omap_mux_init_signal("usba0_ulpiphy_dat5",
119 OMAP_PIN_INPUT_PULLDOWN);
120 omap_mux_init_signal("usba0_ulpiphy_dat6",
121 OMAP_PIN_INPUT_PULLDOWN);
122 omap_mux_init_signal("usba0_ulpiphy_dat7",
123 OMAP_PIN_INPUT_PULLDOWN);
124 break;
125 default:
126 break;
127 }
128}
884b8369 129void __init usb_musb_init(struct omap_musb_board_data *board_data)
18cb7aca 130{
bce06683 131 if (cpu_is_omap243x()) {
18cb7aca 132 musb_resources[0].start = OMAP243X_HS_BASE;
3a0d30bc 133 } else if (cpu_is_omap3517() || cpu_is_omap3505()) {
ce40c576 134 musb_device.name = "musb-am35x";
3a0d30bc
AKG
135 musb_resources[0].start = AM35XX_IPSS_USBOTGSS_BASE;
136 musb_resources[1].start = INT_35XX_USBOTG_IRQ;
bce06683 137 } else if (cpu_is_omap34xx()) {
18cb7aca 138 musb_resources[0].start = OMAP34XX_HSUSB_OTG_BASE;
bce06683
MM
139 } else if (cpu_is_omap44xx()) {
140 musb_resources[0].start = OMAP44XX_HSUSB_OTG_BASE;
5772ca7d
SS
141 musb_resources[1].start = OMAP44XX_IRQ_HS_USB_MC_N;
142 musb_resources[2].start = OMAP44XX_IRQ_HS_USB_DMA_N;
2aae4221
AG
143
144 usb_musb_mux_init(board_data);
bce06683 145 }
f9828552 146 musb_resources[0].end = musb_resources[0].start + SZ_4K - 1;
18cb7aca
FB
147
148 /*
149 * REVISIT: This line can be removed once all the platforms using
150 * musb_core.c have been converted to use use clkdev.
151 */
152 musb_plat.clock = "ick";
884b8369
MM
153 musb_plat.board_data = board_data;
154 musb_plat.power = board_data->power >> 1;
155 musb_plat.mode = board_data->mode;
58815fa3 156 musb_plat.extvbus = board_data->extvbus;
18cb7aca 157
bdfa3511 158 if (platform_device_register(&musb_device) < 0)
18cb7aca 159 printk(KERN_ERR "Unable to register HS-USB (MUSB) device\n");
94a3ef6f
PDS
160}
161
162#else
884b8369 163void __init usb_musb_init(struct omap_musb_board_data *board_data)
94a3ef6f 164{
18cb7aca 165}
94a3ef6f 166#endif /* CONFIG_USB_MUSB_SOC */
This page took 0.139256 seconds and 5 git commands to generate.