1 --- kernel-power-2.6.28.orig/arch/arm/mach-omap2/usb-musb.c
2 +++ kernel-power-2.6.28/arch/arm/mach-omap2/usb-musb.c
4 .config = &musb_config,
6 /* REVISIT charge pump on TWL4030 can supply up to
7 - * 100 mA ... but this value is board-specific, like
8 + * 200 mA ... but this value is board-specific, like
9 * "mode", and should be passed to usb_musb_init().
11 + * Since the power can come from a Y-cable, let the user
12 + * decide on power constraints and not limit anything here.
14 - .power = 50, /* up to 100 mA */
15 + .power = 0, /* use default of 500 mA */
18 static u64 musb_dmamask = DMA_32BIT_MASK;
19 --- kernel-power-2.6.28.orig/drivers/usb/core/otg_whitelist.h
20 +++ kernel-power-2.6.28/drivers/usb/core/otg_whitelist.h
23 static inline int is_targeted(struct usb_device *d)
30 --- kernel-power-2.6.28.orig/drivers/usb/musb/musb_core.c
31 +++ kernel-power-2.6.28/drivers/usb/musb/musb_core.c
33 * change it unless you really know what you're doing
36 + DBG(4, "Some asshole called musb_charger_detect!");
38 switch(musb->xceiv->state) {
39 case OTG_STATE_B_IDLE:
40 /* we always reset transceiver */
45 - DBG(4, "%cX ep%d fifo %p count %d buf %p\n",
46 + DBG_nonverb(4, "%cX ep%d fifo %p count %d buf %p\n",
47 'T', hw_ep->epnum, fifo, len, src);
49 /* we can't assume unaligned reads work */
52 void __iomem *fifo = hw_ep->fifo;
54 - DBG(4, "%cX ep%d fifo %p count %d buf %p\n",
55 + DBG_nonverb(4, "%cX ep%d fifo %p count %d buf %p\n",
56 'R', hw_ep->epnum, fifo, len, dst);
58 /* we can't assume unaligned writes work */
60 void __iomem *mbase = musb->mregs;
63 - DBG(3, "<== Power=%02x, DevCtl=%02x, int_usb=0x%x\n", power, devctl,
65 + DBG(3, "<== State=%s Power=%02x, DevCtl=%02x, int_usb=0x%x\n",
66 + otg_state_string(musb), power, devctl, int_usb);
68 /* in host mode, the peripheral may issue remote wakeup.
69 * in peripheral mode, the host may resume the link.
70 @@ -2028,12 +2030,16 @@
73 mutex_lock(&musb->mutex);
74 - if (sysfs_streq(buf, "host"))
75 - status = musb_platform_set_mode(musb, MUSB_HOST);
76 + if (sysfs_streq(buf, "hostl"))
77 + status = musb_platform_set_mode(musb, MUSB_HOST, 0);
78 + else if (sysfs_streq(buf, "hostf"))
79 + status = musb_platform_set_mode(musb, MUSB_HOST, 1);
80 + else if (sysfs_streq(buf, "hosth"))
81 + status = musb_platform_set_mode(musb, MUSB_HOST, 2);
82 else if (sysfs_streq(buf, "peripheral"))
83 - status = musb_platform_set_mode(musb, MUSB_PERIPHERAL);
84 + status = musb_platform_set_mode(musb, MUSB_PERIPHERAL, 0);
85 else if (sysfs_streq(buf, "otg"))
86 - status = musb_platform_set_mode(musb, MUSB_OTG);
87 + status = musb_platform_set_mode(musb, MUSB_OTG, 0);
90 mutex_unlock(&musb->mutex);
91 --- kernel-power-2.6.28.orig/drivers/usb/musb/musb_core.h
92 +++ kernel-power-2.6.28/drivers/usb/musb/musb_core.h
94 #include "../core/hcd.h"
95 #include "musb_host.h"
97 +/* This is the version of forced hostmode userspace<->kernelspace API.
98 + * Do not update to the build date, bump only on API changes */
99 +#define MUSB_VERSION_HOSTMODE "20101110"
101 #ifdef CONFIG_USB_MUSB_OTG
105 extern void musb_hnp_stop(struct musb *musb);
107 -extern int musb_platform_set_mode(struct musb *musb, u8 musb_mode);
108 +extern int musb_platform_set_mode(struct musb *musb, u8 musb_mode, u8 hostspeed);
110 #if defined(CONFIG_USB_TUSB6010) || defined(CONFIG_BLACKFIN) || \
111 defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP34XX)
112 --- kernel-power-2.6.28.orig/drivers/usb/musb/musb_debug.h
113 +++ kernel-power-2.6.28/drivers/usb/musb/musb_debug.h
116 #ifdef CONFIG_USB_MUSB_DEBUG
118 +#define xprintk_verb(level, facility, format, args...) do { \
119 + if (_dbg_level(level)) { \
120 + u8 testmode, devctl, power/*, otg_ctrl, func_ctrl, isp_debug*/; \
121 + testmode = musb_readb(musb->mregs, MUSB_TESTMODE); \
122 + devctl = musb_readb(musb->mregs, MUSB_DEVCTL); \
123 + power = musb_readb(musb->mregs, MUSB_POWER); \
124 + /*otg_ctrl = musb_ulpi_readb(musb->mregs, ISP1704_OTG_CTRL); \
125 + func_ctrl = musb_ulpi_readb(musb->mregs, ISP1704_FUNC_CTRL); \
126 + isp_debug = musb_ulpi_readb(musb->mregs, ISP1704_DEBUG); */ \
127 + printk(facility "State=%s Testmode=%02x Power=%02x, DevCtl=%02x\n", \
128 + otg_state_string(musb), testmode, power, devctl/*, otg_ctrl, func_ctrl, isp_debug*/); \
129 + printk(facility "%-20s %4d: " format , \
130 + __func__, __LINE__ , ## args); \
133 #define xprintk(level, facility, format, args...) do { \
134 if (_dbg_level(level)) { \
135 printk(facility "%-20s %4d: " format , \
138 return musb_debug >= l;
140 -#define DBG(level, fmt, args...) xprintk(level, KERN_DEBUG, fmt, ## args)
141 +#define DBG(level, fmt, args...) xprintk_verb(level, KERN_DEBUG, fmt, ## args)
142 +#define DBG_nonverb(level, fmt, args...) xprintk(level, KERN_DEBUG, fmt, ## args)
144 #define DBG(level, fmt, args...) do {} while(0)
145 #endif /* CONFIG_USB_MUSB_DEBUG */
146 --- kernel-power-2.6.28.orig/drivers/usb/musb/musb_gadget.c
147 +++ kernel-power-2.6.28/drivers/usb/musb/musb_gadget.c
148 @@ -816,12 +816,12 @@
152 + musb_ep = to_musb_ep(ep);
153 + musb = musb_ep->musb;
154 DBG(1, "===> enabling %s\n", ep->name);
156 - musb_ep = to_musb_ep(ep);
157 hw_ep = musb_ep->hw_ep;
159 - musb = musb_ep->musb;
161 epnum = musb_ep->current_epnum;
166 musb_ep = to_musb_ep(ep);
167 - DBG(4, "disabling %s\n", musb_ep->name);
168 musb = musb_ep->musb;
169 + DBG(4, "disabling %s\n", musb_ep->name);
170 epnum = musb_ep->current_epnum;
171 epio = musb->endpoints[epnum].regs;
173 --- kernel-power-2.6.28.orig/drivers/usb/musb/musb_host.c
174 +++ kernel-power-2.6.28/drivers/usb/musb/musb_host.c
176 csr = musb_readw(epio, MUSB_TXCSR);
177 while (csr & MUSB_TXCSR_FIFONOTEMPTY) {
179 - DBG(3, "Host TX FIFONOTEMPTY csr: %02x\n", csr);
180 + DBG_nonverb(3, "Host TX FIFONOTEMPTY csr: %02x\n", csr);
182 csr |= MUSB_TXCSR_FLUSHFIFO;
183 musb_writew(epio, MUSB_TXCSR, csr);
184 @@ -2036,7 +2036,7 @@
185 dma = is_in ? ep->rx_channel : ep->tx_channel;
187 status = ep->musb->dma_controller->channel_abort(dma);
188 - DBG(status ? 1 : 3,
189 + DBG_nonverb(status ? 1 : 3,
190 "abort %cX%d DMA for urb %p --> %d\n",
191 is_in ? 'R' : 'T', ep->epnum,
193 --- kernel-power-2.6.28.orig/drivers/usb/musb/musb_procfs.c
194 +++ kernel-power-2.6.28/drivers/usb/musb/musb_procfs.c
196 #elif defined(CONFIG_USB_MUSB_HDRC_HCD)
199 - ", debug=%d [eps=%d]\n",
200 + ", debug=%d [eps=%d]"
201 + ", version_hostmode=" MUSB_VERSION_HOSTMODE "\n",
206 reg = musb_readb(mbase, MUSB_DEVCTL);
207 reg |= MUSB_DEVCTL_SESSION;
208 musb_writeb(mbase, MUSB_DEVCTL, reg);
210 + /* Pretend there's a session request */
211 + musb->ep0_stage = MUSB_EP0_START;
212 + musb->xceiv->state = OTG_STATE_A_IDLE;
213 + MUSB_HST_MODE(musb);
214 + musb_set_vbus(musb, 1);
216 + /* Connect request */
218 + struct usb_hcd *hcd = musb_to_hcd(musb);
221 + musb->is_active = 1;
222 + set_bit(HCD_FLAG_SAW_IRQ, &hcd->flags);
224 + musb->ep0_stage = MUSB_EP0_START;
226 +#ifdef CONFIG_USB_MUSB_OTG
227 + /* flush endpoints when transitioning from Device Mode */
228 + if (is_peripheral_active(musb)) {
229 + /* REVISIT HNP; just force disconnect */
231 + musb_writew(mbase, MUSB_INTRTXE, musb->epmask);
232 + musb_writew(mbase, MUSB_INTRRXE, musb->epmask & 0xfffe);
233 + musb_writeb(mbase, MUSB_INTRUSBE, 0xf7);
235 + musb->port1_status &= ~(USB_PORT_STAT_LOW_SPEED
236 + |USB_PORT_STAT_HIGH_SPEED
237 + |USB_PORT_STAT_ENABLE
239 + musb->port1_status |= USB_PORT_STAT_CONNECTION
240 + |(USB_PORT_STAT_C_CONNECTION << 16);
242 + line = musb_ulpi_readb(mbase, ISP1704_DEBUG);
243 + testmode = musb_readb(mbase, MUSB_TESTMODE);
246 + case 1: /* pullup indicates a full/high-speed device */
247 + if (!(testmode & (MUSB_TEST_FORCE_FS | MUSB_TEST_FORCE_HS)))
248 + pr_err("Forced hostmode error: a full/high-speed device attached but low-speed mode selected\n");
250 + case 2: /* pullup indicates a low-speed device */
251 + if (testmode & (MUSB_TEST_FORCE_FS | MUSB_TEST_FORCE_HS))
252 + pr_err("Forced hostmode error: a low-speed device attached but full/high-speed mode selected\n");
255 + pr_err("Forced hostmode error: no device attached\n");
258 + if (!(testmode & (MUSB_TEST_FORCE_FS | MUSB_TEST_FORCE_HS)))
259 + musb->port1_status |= USB_PORT_STAT_LOW_SPEED;
261 + if (hcd->status_urb)
262 + usb_hcd_poll_rh_status(hcd);
264 + usb_hcd_resume_root_hub(hcd);
266 + MUSB_HST_MODE(musb);
268 + /* indicate new connection to OTG machine */
269 + switch (musb->xceiv->state) {
271 + musb->xceiv->state = OTG_STATE_A_HOST;
272 + hcd->self.is_b_host = 0;
275 + DBG(1, "CONNECT (%s) devctl %02x\n",
276 + otg_state_string(musb), devctl);
281 --- kernel-power-2.6.28.orig/drivers/usb/musb/musb_regs.h
282 +++ kernel-power-2.6.28/drivers/usb/musb/musb_regs.h
284 while (!(musb_readb(addr, ULPI_REG_CONTROL) & ULPI_REG_CMPLT)) {
287 - DBG(3, "ULPI read timed out\n");
288 + DBG_nonverb(3, "ULPI read timed out\n");
293 while(!(musb_readb(addr, ULPI_REG_CONTROL) & ULPI_REG_CMPLT)) {
296 - DBG(3, "ULPI write timed out\n");
297 + DBG_nonverb(3, "ULPI write timed out\n");
301 --- kernel-power-2.6.28.orig/drivers/usb/musb/musbhsdma.c
302 +++ kernel-power-2.6.28/drivers/usb/musb/musbhsdma.c
304 u8 bchannel = musb_channel->idx;
307 - DBG(4, "%p, pkt_sz %d, addr 0x%x, len %d, mode %d\n",
308 + DBG_nonverb(4, "%p, pkt_sz %d, addr 0x%x, len %d, mode %d\n",
309 channel, packet_sz, dma_addr, len, mode);
314 struct musb_dma_channel *musb_channel = channel->private_data;
316 - DBG(2, "ep%d-%s pkt_sz %d, dma_addr 0x%x length %d, mode %d\n",
317 + DBG_nonverb(2, "ep%d-%s pkt_sz %d, dma_addr 0x%x length %d, mode %d\n",
319 musb_channel->transmit ? "Tx" : "Rx",
320 packet_sz, dma_addr, len, mode);
321 --- kernel-power-2.6.28.orig/drivers/usb/musb/omap2430.c
322 +++ kernel-power-2.6.28/drivers/usb/musb/omap2430.c
325 spin_lock_irqsave(&musb->lock, flags);
327 + DBG(3, "%s\n", otg_state_string(musb));
329 devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
331 switch (musb->xceiv->state) {
332 @@ -211,15 +213,12 @@
334 static int musb_platform_resume(struct musb *musb);
336 -int musb_platform_set_mode(struct musb *musb, u8 musb_mode)
337 +int musb_platform_set_mode(struct musb *musb, u8 musb_mode, u8 hostspeed)
340 struct usb_bus *host;
341 u8 devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
343 - devctl |= MUSB_DEVCTL_SESSION;
344 - musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
347 #ifdef CONFIG_USB_MUSB_HDRC_HCD
349 @@ -227,10 +226,36 @@
350 host = hcd_to_bus(hcd);
352 otg_set_host(musb->xceiv, host);
354 + if (machine_is_nokia_rx51()) {
357 + musb_platform_resume(musb);
359 + devctl |= MUSB_DEVCTL_SESSION;
360 + musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
362 + testmode = MUSB_TEST_FORCE_HOST;
363 + if (hostspeed == 1)
364 + testmode |= MUSB_TEST_FORCE_FS;
365 + else if (hostspeed == 2)
366 + testmode |= MUSB_TEST_FORCE_HS;
367 + musb_writeb(musb->mregs, MUSB_TESTMODE, testmode);
371 #ifdef CONFIG_USB_GADGET_MUSB_HDRC
372 case MUSB_PERIPHERAL:
373 + if (machine_is_nokia_rx51()) {
374 + musb_platform_resume(musb);
375 + musb_set_vbus(musb, 0);
377 + devctl &= ~MUSB_DEVCTL_SESSION;
378 + musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
380 + musb_writeb(musb->mregs, MUSB_TESTMODE, 0);
383 otg_set_peripheral(musb->xceiv, &musb->g);
386 --- kernel-power-2.6.28.orig/drivers/usb/otg/twl4030-usb.c
387 +++ kernel-power-2.6.28/drivers/usb/otg/twl4030-usb.c
390 spin_lock_irq(&twl->lock);
391 twl->linkstat = linkstat;
393 if (linkstat == USB_LINK_ID) {
394 twl->otg.default_a = true;
395 twl->otg.state = OTG_STATE_A_IDLE;
397 twl->otg.default_a = false;
398 twl->otg.state = OTG_STATE_B_IDLE;
401 spin_unlock_irq(&twl->lock);
404 --- kernel-power-2.6.28.orig/drivers/usb/musb/musb_virthub.c
405 +++ kernel-power-2.6.28/drivers/usb/musb/musb_virthub.c
408 static void musb_port_reset(struct musb *musb, bool do_reset)
411 + u8 power, testmode;
412 void __iomem *mbase = musb->mregs;
414 #ifdef CONFIG_USB_MUSB_OTG
415 @@ -162,10 +162,16 @@
417 musb->ignore_disconnect = false;
419 + testmode = musb_readb(mbase, MUSB_TESTMODE);
420 power = musb_readb(mbase, MUSB_POWER);
421 if (power & MUSB_POWER_HSMODE) {
422 DBG(4, "high-speed device connected\n");
423 musb->port1_status |= USB_PORT_STAT_HIGH_SPEED;
424 + if (!(testmode & MUSB_TEST_FORCE_HS))
425 + pr_err("Forced hostmode error: a high-speed device attached but not high-speed mode selected\n");
427 + if (testmode & MUSB_TEST_FORCE_HS)
428 + pr_err("Forced hostmode error: a full/low-speed device attached but high-speed mode selected\n");
431 musb->port1_status &= ~USB_PORT_STAT_RESET;