Lines Matching +full:usb +full:- +full:switch
1 // SPDX-License-Identifier: GPL-2.0+
3 * Freescale QUICC Engine USB Host Controller Driver
7 * Jerry Huang <Chang-Ming.Huang@freescale.com>
20 #include <linux/usb.h>
21 #include <linux/usb/hcd.h>
29 USB_DT_HUB, /* bDescriptorType;hub-descriptor */
32 0x00, /* per-port power, no overcurrent */
41 struct gpio_desc *gpiod = fhci->gpiods[gpio_nr]; in fhci_gpio_set_value()
53 fhci_dbg(fhci, "-> %s: %d\n", __func__, status); in fhci_config_transceiver()
55 switch (status) { in fhci_config_transceiver()
74 fhci_dbg(fhci, "<- %s: %d\n", __func__, status); in fhci_config_transceiver()
77 /* disable the USB port by clearing the EN bit in the USBMOD register */
80 struct fhci_usb *usb = (struct fhci_usb *)fhci->usb_lld; in fhci_port_disable() local
83 fhci_dbg(fhci, "-> %s\n", __func__); in fhci_port_disable()
87 fhci_flush_all_transmissions(usb); in fhci_port_disable()
89 fhci_usb_disable_interrupt((struct fhci_usb *)fhci->usb_lld); in fhci_port_disable()
90 port_status = usb->port_status; in fhci_port_disable()
91 usb->port_status = FHCI_PORT_DISABLED; in fhci_port_disable()
94 usb->saved_msk |= USB_E_IDLE_MASK; in fhci_port_disable()
95 out_be16(&usb->fhci->regs->usb_usbmr, usb->saved_msk); in fhci_port_disable()
100 usb->vroot_hub->port.wPortStatus &= ~USB_PORT_STAT_ENABLE; in fhci_port_disable()
101 usb->vroot_hub->port.wPortChange |= USB_PORT_STAT_C_ENABLE; in fhci_port_disable()
102 fhci_usb_enable_interrupt((struct fhci_usb *)fhci->usb_lld); in fhci_port_disable()
104 fhci_dbg(fhci, "<- %s\n", __func__); in fhci_port_disable()
107 /* enable the USB port by setting the EN bit in the USBMOD register */
110 struct fhci_usb *usb = (struct fhci_usb *)lld; in fhci_port_enable() local
111 struct fhci_hcd *fhci = usb->fhci; in fhci_port_enable()
113 fhci_dbg(fhci, "-> %s\n", __func__); in fhci_port_enable()
115 fhci_config_transceiver(fhci, usb->port_status); in fhci_port_enable()
117 if ((usb->port_status != FHCI_PORT_FULL) && in fhci_port_enable()
118 (usb->port_status != FHCI_PORT_LOW)) in fhci_port_enable()
121 usb->vroot_hub->port.wPortStatus |= USB_PORT_STAT_ENABLE; in fhci_port_enable()
122 usb->vroot_hub->port.wPortChange |= USB_PORT_STAT_C_ENABLE; in fhci_port_enable()
124 fhci_dbg(fhci, "<- %s\n", __func__); in fhci_port_enable()
129 fhci_dbg(fhci, "-> %s\n", __func__); in fhci_io_port_generate_reset()
131 gpiod_direction_output(fhci->gpiods[GPIO_USBOE], 0); in fhci_io_port_generate_reset()
132 gpiod_direction_output(fhci->gpiods[GPIO_USBTP], 0); in fhci_io_port_generate_reset()
133 gpiod_direction_output(fhci->gpiods[GPIO_USBTN], 0); in fhci_io_port_generate_reset()
137 qe_pin_set_dedicated(fhci->pins[PIN_USBOE]); in fhci_io_port_generate_reset()
138 qe_pin_set_dedicated(fhci->pins[PIN_USBTP]); in fhci_io_port_generate_reset()
139 qe_pin_set_dedicated(fhci->pins[PIN_USBTN]); in fhci_io_port_generate_reset()
141 fhci_dbg(fhci, "<- %s\n", __func__); in fhci_io_port_generate_reset()
147 struct fhci_usb *usb = (struct fhci_usb *)lld; in fhci_port_reset() local
148 struct fhci_hcd *fhci = usb->fhci; in fhci_port_reset()
152 fhci_dbg(fhci, "-> %s\n", __func__); in fhci_port_reset()
155 /* disable the USB controller */ in fhci_port_reset()
156 mode = in_8(&fhci->regs->usb_usmod); in fhci_port_reset()
157 out_8(&fhci->regs->usb_usmod, mode & (~USB_MODE_EN)); in fhci_port_reset()
160 mask = in_be16(&fhci->regs->usb_usbmr); in fhci_port_reset()
161 out_be16(&fhci->regs->usb_usbmr, mask & (~USB_E_IDLE_MASK)); in fhci_port_reset()
166 out_be16(&fhci->regs->usb_usbmr, mask); in fhci_port_reset()
168 /* enable the USB controller */ in fhci_port_reset()
169 mode = in_8(&fhci->regs->usb_usmod); in fhci_port_reset()
170 out_8(&fhci->regs->usb_usmod, mode | USB_MODE_EN); in fhci_port_reset()
173 fhci_dbg(fhci, "<- %s\n", __func__); in fhci_port_reset()
182 fhci_dbg(fhci, "-> %s\n", __func__); in fhci_hub_status_data()
184 spin_lock_irqsave(&fhci->lock, flags); in fhci_hub_status_data()
186 if (fhci->vroot_hub->port.wPortChange & (USB_PORT_STAT_C_CONNECTION | in fhci_hub_status_data()
191 fhci_dbg(fhci, "-- %s\n", __func__); in fhci_hub_status_data()
194 spin_unlock_irqrestore(&fhci->lock, flags); in fhci_hub_status_data()
196 fhci_dbg(fhci, "<- %s\n", __func__); in fhci_hub_status_data()
210 spin_lock_irqsave(&fhci->lock, flags); in fhci_hub_control()
212 fhci_dbg(fhci, "-> %s\n", __func__); in fhci_hub_control()
214 switch (typeReq) { in fhci_hub_control()
216 switch (wValue) { in fhci_hub_control()
225 fhci->vroot_hub->feature &= (1 << wValue); in fhci_hub_control()
227 switch (wValue) { in fhci_hub_control()
229 fhci->vroot_hub->port.wPortStatus &= in fhci_hub_control()
234 fhci->vroot_hub->port.wPortChange &= in fhci_hub_control()
238 fhci->vroot_hub->port.wPortStatus &= in fhci_hub_control()
243 fhci->vroot_hub->port.wPortChange &= in fhci_hub_control()
247 fhci->vroot_hub->port.wPortStatus &= in fhci_hub_control()
252 fhci->vroot_hub->port.wPortChange &= in fhci_hub_control()
256 fhci->vroot_hub->port.wPortChange &= in fhci_hub_control()
260 fhci->vroot_hub->port.wPortChange &= in fhci_hub_control()
272 hub_status->wHubStatus = in fhci_hub_control()
273 cpu_to_le16(fhci->vroot_hub->hub.wHubStatus); in fhci_hub_control()
274 hub_status->wHubChange = in fhci_hub_control()
275 cpu_to_le16(fhci->vroot_hub->hub.wHubChange); in fhci_hub_control()
279 port_status->wPortStatus = in fhci_hub_control()
280 cpu_to_le16(fhci->vroot_hub->port.wPortStatus); in fhci_hub_control()
281 port_status->wPortChange = in fhci_hub_control()
282 cpu_to_le16(fhci->vroot_hub->port.wPortChange); in fhci_hub_control()
285 switch (wValue) { in fhci_hub_control()
294 fhci->vroot_hub->feature |= (1 << wValue); in fhci_hub_control()
296 switch (wValue) { in fhci_hub_control()
298 fhci->vroot_hub->port.wPortStatus |= in fhci_hub_control()
300 fhci_port_enable(fhci->usb_lld); in fhci_hub_control()
303 fhci->vroot_hub->port.wPortStatus |= in fhci_hub_control()
308 fhci->vroot_hub->port.wPortStatus |= in fhci_hub_control()
310 fhci_port_reset(fhci->usb_lld); in fhci_hub_control()
311 fhci->vroot_hub->port.wPortStatus |= in fhci_hub_control()
313 fhci->vroot_hub->port.wPortStatus &= in fhci_hub_control()
317 fhci->vroot_hub->port.wPortStatus |= in fhci_hub_control()
327 retval = -EPIPE; in fhci_hub_control()
330 fhci_dbg(fhci, "<- %s\n", __func__); in fhci_hub_control()
332 spin_unlock_irqrestore(&fhci->lock, flags); in fhci_hub_control()