Lines Matching +full:otg +full:- +full:switch
1 // SPDX-License-Identifier: GPL-2.0
3 * MUSB OTG driver virtual root hub support
6 * Copyright (C) 2005-2006 by Texas Instruments
7 * Copyright (C) 2006-2007 Nokia Corporation
29 spin_lock_irqsave(&musb->lock, flags); in musb_host_finish_resume()
31 power = musb_readb(musb->mregs, MUSB_POWER); in musb_host_finish_resume()
34 musb_writeb(musb->mregs, MUSB_POWER, power); in musb_host_finish_resume()
41 musb->is_active = 1; in musb_host_finish_resume()
42 musb->port1_status &= ~(USB_PORT_STAT_SUSPEND | MUSB_PORT_STAT_RESUME); in musb_host_finish_resume()
43 musb->port1_status |= USB_PORT_STAT_C_SUSPEND << 16; in musb_host_finish_resume()
44 usb_hcd_poll_rh_status(musb->hcd); in musb_host_finish_resume()
48 spin_unlock_irqrestore(&musb->lock, flags); in musb_host_finish_resume()
54 void __iomem *mbase = musb->mregs; in musb_port_suspend()
69 return -EBUSY; in musb_port_suspend()
79 if (retries-- < 1) in musb_port_suspend()
86 musb->port1_status |= USB_PORT_STAT_SUSPEND; in musb_port_suspend()
87 switch (musb_get_state(musb)) { in musb_port_suspend()
90 musb->is_active = musb->xceiv && in musb_port_suspend()
91 musb->xceiv->otg->host->b_hnp_enable; in musb_port_suspend()
92 if (musb->is_active) in musb_port_suspend()
93 mod_timer(&musb->otg_timer, jiffies in musb_port_suspend()
100 musb->is_active = musb->xceiv && in musb_port_suspend()
101 musb->xceiv->otg->host->b_hnp_enable; in musb_port_suspend()
115 musb->port1_status |= MUSB_PORT_STAT_RESUME; in musb_port_suspend()
116 schedule_delayed_work(&musb->finish_resume_work, in musb_port_suspend()
125 void __iomem *mbase = musb->mregs; in musb_port_reset()
129 musb->port1_status &= ~USB_PORT_STAT_RESET; in musb_port_reset()
149 long remain = (unsigned long) musb->rh_timer - jiffies; in musb_port_reset()
151 if (musb->rh_timer > 0 && remain > 0) { in musb_port_reset()
154 &musb->deassert_reset_work, remain); in musb_port_reset()
162 schedule_delayed_work(&musb->deassert_reset_work, in musb_port_reset()
171 musb->port1_status |= USB_PORT_STAT_RESET; in musb_port_reset()
172 musb->port1_status &= ~USB_PORT_STAT_ENABLE; in musb_port_reset()
173 schedule_delayed_work(&musb->deassert_reset_work, in musb_port_reset()
184 musb_dbg(musb, "high-speed device connected"); in musb_port_reset()
185 musb->port1_status |= USB_PORT_STAT_HIGH_SPEED; in musb_port_reset()
188 musb->port1_status &= ~USB_PORT_STAT_RESET; in musb_port_reset()
189 musb->port1_status |= USB_PORT_STAT_ENABLE in musb_port_reset()
192 usb_hcd_poll_rh_status(musb->hcd); in musb_port_reset()
194 musb->vbuserr_retry = VBUSERR_RETRY_COUNT; in musb_port_reset()
200 musb->port1_status = USB_PORT_STAT_POWER in musb_root_disconnect()
203 usb_hcd_poll_rh_status(musb->hcd); in musb_root_disconnect()
204 musb->is_active = 0; in musb_root_disconnect()
206 switch (musb_get_state(musb)) { in musb_root_disconnect()
208 if (musb->xceiv && musb->xceiv->otg->host->b_hnp_enable) { in musb_root_disconnect()
210 musb->g.is_a_peripheral = 1; in musb_root_disconnect()
216 musb->is_active = 0; in musb_root_disconnect()
229 /*---------------------------------------------------------------------*/
231 /* Caller may or may not hold musb->lock */
238 if (musb->port1_status & 0xffff0000) { in musb_hub_status_data()
248 * In host-only mode we start a connection right away. In OTG mode in musb_has_gadget()
256 return musb->port_mode == MUSB_HOST; in musb_has_gadget()
274 spin_lock_irqsave(&musb->lock, flags); in musb_hub_control()
277 spin_unlock_irqrestore(&musb->lock, flags); in musb_hub_control()
278 return -ESHUTDOWN; in musb_hub_control()
285 switch (typeReq) { in musb_hub_control()
288 switch (wValue) { in musb_hub_control()
300 switch (wValue) { in musb_hub_control()
307 if (!hcd->self.is_b_host) in musb_hub_control()
320 musb->port1_status &= ~(1 << wValue); in musb_hub_control()
326 desc->bDescLength = 9; in musb_hub_control()
327 desc->bDescriptorType = USB_DT_HUB; in musb_hub_control()
328 desc->bNbrPorts = 1; in musb_hub_control()
329 desc->wHubCharacteristics = cpu_to_le16( in musb_hub_control()
330 HUB_CHAR_INDV_PORT_LPSM /* per-port power switching */ in musb_hub_control()
333 desc->bPwrOn2PwrGood = 5; /* msec/2 */ in musb_hub_control()
334 desc->bHubContrCurrent = 0; in musb_hub_control()
337 desc->u.hs.DeviceRemovable[0] = 0x02; /* port 1 */ in musb_hub_control()
338 desc->u.hs.DeviceRemovable[1] = 0xff; in musb_hub_control()
349 put_unaligned(cpu_to_le32(musb->port1_status in musb_hub_control()
354 musb_dbg(musb, "port status %08x", musb->port1_status); in musb_hub_control()
360 switch (wValue) { in musb_hub_control()
364 * magic side effects from incompletely-described in musb_hub_control()
369 * initialization logic, e.g. for OTG, or change any in musb_hub_control()
370 * logic relating to VBUS power-up. in musb_hub_control()
372 if (!hcd->self.is_b_host && musb_has_gadget(musb)) in musb_hub_control()
386 switch (wIndex) { in musb_hub_control()
409 musb_writeb(musb->mregs, MUSB_DEVCTL, in musb_hub_control()
419 musb_writeb(musb->mregs, MUSB_TESTMODE, temp); in musb_hub_control()
425 musb->port1_status |= 1 << wValue; in musb_hub_control()
431 retval = -EPIPE; in musb_hub_control()
433 spin_unlock_irqrestore(&musb->lock, flags); in musb_hub_control()