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