15 static const __u8 root_hub_hub_des[] =
28 #define UHCI_RH_MAXCHILD 7
31 #define WZ_BITS (USBPORTSC_RES2 | USBPORTSC_RES3 | USBPORTSC_RES4)
34 #define RWC_BITS (USBPORTSC_OCC | USBPORTSC_PEC | USBPORTSC_CSC)
37 #define SUSPEND_BITS (USBPORTSC_SUSP | USBPORTSC_RD)
42 static int any_ports_active(
struct uhci_hcd *uhci)
55 static inline int get_hub_status_data(
struct uhci_hcd *uhci,
char *
buf)
71 if ((uhci_readw(uhci,
USBPORTSC1 + port * 2) & mask) ||
73 *buf |= (1 << (port + 1));
78 #define OK(x) len = (x); break
80 #define CLR_RH_PORTSTAT(x) \
81 status = uhci_readw(uhci, port_addr); \
82 status &= ~(RWC_BITS|WZ_BITS); \
84 status |= RWC_BITS & (x); \
85 uhci_writew(uhci, status, port_addr)
87 #define SET_RH_PORTSTAT(x) \
88 status = uhci_readw(uhci, port_addr); \
90 status &= ~(RWC_BITS|WZ_BITS); \
91 uhci_writew(uhci, status, port_addr)
96 static void uhci_finish_suspend(
struct uhci_hcd *uhci,
int port,
112 for (i = 0; i < 10; ++
i) {
113 if (!(uhci_readw(uhci, port_addr) & SUSPEND_BITS))
128 for (i = 10; i < 250; i += 10) {
136 static void uhci_check_ports(
struct uhci_hcd *uhci)
144 status = uhci_readw(uhci, port_addr);
153 wait_for_HP(uhci, port_addr);
177 uhci_finish_suspend(uhci, port, port_addr);
183 static int uhci_hub_status_data(
struct usb_hcd *hcd,
char *buf)
185 struct uhci_hcd *uhci = hcd_to_uhci(hcd);
191 uhci_scan_schedule(uhci);
192 if (!HCD_HW_ACCESSIBLE(hcd) || uhci->
dead)
194 uhci_check_ports(uhci);
196 status = get_hub_status_data(uhci, buf);
203 usb_hcd_resume_root_hub(hcd);
215 if (!any_ports_active(uhci)) {
223 if (any_ports_active(uhci))
234 spin_unlock_irqrestore(&uhci->
lock, flags);
239 static int uhci_hub_control(
struct usb_hcd *hcd,
u16 typeReq,
u16 wValue,
242 struct uhci_hcd *uhci = hcd_to_uhci(hcd);
244 unsigned int port = wIndex - 1;
249 if (!HCD_HW_ACCESSIBLE(hcd) || uhci->
dead)
262 uhci_check_ports(uhci);
263 status = uhci_readw(uhci, port_addr);
273 wPortChange = lstatus = 0;
299 if (status & USBPORTSC_PR)
306 wIndex, status, lstatus);
312 case ClearHubFeature:
333 uhci_finish_suspend(uhci, port, port_addr);
345 case ClearPortFeature:
354 uhci_finish_suspend(uhci, port, port_addr);
363 uhci_finish_suspend(uhci, port, port_addr);
372 if (!(uhci_readw(uhci, port_addr) &
374 uhci_finish_suspend(uhci, port,
401 case GetHubDescriptor:
402 len =
min_t(
unsigned int,
sizeof(root_hub_hub_des), wLength);
403 memcpy(buf, root_hub_hub_des, len);
411 spin_unlock_irqrestore(&uhci->
lock, flags);