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