]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-omap2/usb-musb.c
Merge current mainline tree into linux-omap tree
[linux-2.6-omap-h63xx.git] / arch / arm / mach-omap2 / usb-musb.c
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
26 #include <asm/io.h>
27
28 #include <linux/usb/musb.h>
29
30 #include <mach/hardware.h>
31 #include <mach/irqs.h>
32 #include <mach/pm.h>
33 #include <mach/mux.h>
34 #include <mach/usb.h>
35
36 #ifdef CONFIG_USB_MUSB_SOC
37 static struct resource musb_resources[] = {
38         [0] = {
39                 .start  = cpu_is_omap34xx()
40                         ? OMAP34XX_HSUSB_OTG_BASE
41                         : OMAP243X_HS_BASE,
42                 .end    = cpu_is_omap34xx()
43                         ? OMAP34XX_HSUSB_OTG_BASE + SZ_8K - 1
44                         : OMAP243X_HS_BASE + SZ_8K - 1,
45                 .flags  = IORESOURCE_MEM,
46         },
47         [1] = { /* general IRQ */
48                 .start  = INT_243X_HS_USB_MC,
49                 .flags  = IORESOURCE_IRQ,
50         },
51         [2] = { /* DMA IRQ */
52                 .start  = INT_243X_HS_USB_DMA,
53                 .flags  = IORESOURCE_IRQ,
54         },
55 };
56
57 static int clk_on;
58
59 static int musb_set_clock(struct clk *clk, int state)
60 {
61         if (state) {
62                 if (clk_on > 0)
63                         return -ENODEV;
64
65                 clk_enable(clk);
66                 clk_on = 1;
67         } else {
68                 if (clk_on == 0)
69                         return -ENODEV;
70
71                 clk_disable(clk);
72                 clk_on = 0;
73         }
74
75         return 0;
76 }
77
78 static struct musb_hdrc_eps_bits musb_eps[] = {
79         {       "ep1_tx", 10,   },
80         {       "ep1_rx", 10,   },
81         {       "ep2_tx", 9,    },
82         {       "ep2_rx", 9,    },
83         {       "ep3_tx", 3,    },
84         {       "ep3_rx", 3,    },
85         {       "ep4_tx", 3,    },
86         {       "ep4_rx", 3,    },
87         {       "ep5_tx", 3,    },
88         {       "ep5_rx", 3,    },
89         {       "ep6_tx", 3,    },
90         {       "ep6_rx", 3,    },
91         {       "ep7_tx", 3,    },
92         {       "ep7_rx", 3,    },
93         {       "ep8_tx", 2,    },
94         {       "ep8_rx", 2,    },
95         {       "ep9_tx", 2,    },
96         {       "ep9_rx", 2,    },
97         {       "ep10_tx", 2,   },
98         {       "ep10_rx", 2,   },
99         {       "ep11_tx", 2,   },
100         {       "ep11_rx", 2,   },
101         {       "ep12_tx", 2,   },
102         {       "ep12_rx", 2,   },
103         {       "ep13_tx", 2,   },
104         {       "ep13_rx", 2,   },
105         {       "ep14_tx", 2,   },
106         {       "ep14_rx", 2,   },
107         {       "ep15_tx", 2,   },
108         {       "ep15_rx", 2,   },
109 };
110
111 static struct musb_hdrc_config musb_config = {
112         .multipoint     = 1,
113         .dyn_fifo       = 1,
114         .soft_con       = 1,
115         .dma            = 1,
116         .num_eps        = 16,
117         .dma_channels   = 7,
118         .dma_req_chan   = (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3),
119         .ram_bits       = 12,
120         .eps_bits       = musb_eps,
121 };
122
123 static struct musb_hdrc_platform_data musb_plat = {
124 #ifdef CONFIG_USB_MUSB_OTG
125         .mode           = MUSB_OTG,
126 #elif defined(CONFIG_USB_MUSB_HDRC_HCD)
127         .mode           = MUSB_HOST,
128 #elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
129         .mode           = MUSB_PERIPHERAL,
130 #endif
131         .clock          = cpu_is_omap34xx()
132                         ? "hsotgusb_ick"
133                         : "usbhs_ick",
134         .set_clock      = musb_set_clock,
135         .config         = &musb_config,
136
137         /* REVISIT charge pump on TWL4030 can supply up to
138          * 100 mA ... but this value is board-specific, like
139          * "mode", and should be passed to usb_musb_init().
140          */
141         .power          = 50,                   /* up to 100 mA */
142 };
143
144 static u64 musb_dmamask = DMA_32BIT_MASK;
145
146 static struct platform_device musb_device = {
147         .name           = "musb_hdrc",
148         .id             = -1,
149         .dev = {
150                 .dma_mask               = &musb_dmamask,
151                 .coherent_dma_mask      = DMA_32BIT_MASK,
152                 .platform_data          = &musb_plat,
153         },
154         .num_resources  = ARRAY_SIZE(musb_resources),
155         .resource       = musb_resources,
156 };
157 #endif
158
159
160 void __init usb_musb_init(void)
161 {
162 #ifdef CONFIG_USB_MUSB_SOC
163         if (platform_device_register(&musb_device) < 0) {
164                 printk(KERN_ERR "Unable to register HS-USB (MUSB) device\n");
165                 return;
166         }
167 #endif
168 }
169