static int admhc_get_port_status(struct admhcd *ahcd, unsigned port, char *buf) { struct usb_port_status *ps = (struct usb_port_status *)buf; u32 t = admhc_read_portstatus(ahcd, port); u16 status, change; status = 0; status |= (t & ADMHC_PS_CCS) ? USB_PORT_STAT_CONNECTION : 0; status |= (t & ADMHC_PS_PES) ? USB_PORT_STAT_ENABLE : 0; status |= (t & ADMHC_PS_PSS) ? USB_PORT_STAT_SUSPEND : 0; status |= (t & ADMHC_PS_POCI) ? USB_PORT_STAT_OVERCURRENT : 0; status |= (t & ADMHC_PS_PRS) ? USB_PORT_STAT_RESET : 0; status |= (t & ADMHC_PS_PPS) ? USB_PORT_STAT_POWER : 0; status |= (t & ADMHC_PS_LSDA) ? USB_PORT_STAT_LOW_SPEED : 0; change = 0; change |= (t & ADMHC_PS_CSC) ? USB_PORT_STAT_C_CONNECTION : 0; change |= (t & ADMHC_PS_PESC) ? USB_PORT_STAT_C_ENABLE : 0; change |= (t & ADMHC_PS_PSSC) ? USB_PORT_STAT_C_SUSPEND : 0; change |= (t & ADMHC_PS_OCIC) ? USB_PORT_STAT_C_OVERCURRENT : 0; change |= (t & ADMHC_PS_PRSC) ? USB_PORT_STAT_C_RESET : 0; ps->wPortStatus = (__force __u16)cpu_to_hc16(ahcd, status); ps->wPortChange = (__force __u16)cpu_to_hc16(ahcd, change); return 0; }
static void ohci_hub_descriptor ( struct ohci_hcd *ohci, struct usb_hub_descriptor *desc ) { u32 rh = roothub_a (ohci); u16 temp; desc->bDescriptorType = 0x29; desc->bPwrOn2PwrGood = (rh & RH_A_POTPGT) >> 24; desc->bHubContrCurrent = 0; desc->bNbrPorts = ohci->num_ports; temp = 1 + (ohci->num_ports / 8); desc->bDescLength = 7 + 2 * temp; temp = 0; if (rh & RH_A_NPS) /* no power switching? */ temp |= 0x0002; if (rh & RH_A_PSM) /* per-port power switching? */ temp |= 0x0001; if (rh & RH_A_NOCP) /* no overcurrent reporting? */ temp |= 0x0010; else if (rh & RH_A_OCPM) /* per-port overcurrent reporting? */ temp |= 0x0008; desc->wHubCharacteristics = (__force __u16)cpu_to_hc16(ohci, temp); /* two bitmaps: ports removable, and usb 1.0 legacy PortPwrCtrlMask */ rh = roothub_b (ohci); memset(desc->bitmap, 0xff, sizeof(desc->bitmap)); desc->bitmap [0] = rh & RH_B_DR; if (ohci->num_ports > 7) { desc->bitmap [1] = (rh & RH_B_DR) >> 8; desc->bitmap [2] = 0xff; } else
static int admhc_get_hub_descriptor(struct admhcd *ahcd, char *buf) { struct usb_hub_descriptor *desc = (struct usb_hub_descriptor *)buf; u32 rh = admhc_read_rhdesc(ahcd); u16 temp; desc->bDescriptorType = USB_DT_HUB; /* Hub-descriptor */ desc->bPwrOn2PwrGood = ADMHC_POTPGT/2; /* use default value */ desc->bHubContrCurrent = 0x00; /* 0mA */ desc->bNbrPorts = ahcd->num_ports; temp = 1 + (ahcd->num_ports / 8); desc->bDescLength = USB_DT_HUB_NONVAR_SIZE + 2 * temp; /* FIXME */ temp = 0; if (rh & ADMHC_RH_NPS) /* no power switching? */ temp |= 0x0002; if (rh & ADMHC_RH_PSM) /* per-port power switching? */ temp |= 0x0001; if (rh & ADMHC_RH_NOCP) /* no overcurrent reporting? */ temp |= 0x0010; else if (rh & ADMHC_RH_OCPM) /* per-port overcurrent reporting? */ temp |= 0x0008; desc->wHubCharacteristics = (__force __u16)cpu_to_hc16(ahcd, temp); /* ports removable, and usb 1.0 legacy PortPwrCtrlMask */ desc->u.hs.DeviceRemovable[0] = 0; desc->u.hs.DeviceRemovable[0] = ~0; return 0; }
static int admhc_get_hub_status(struct admhcd *ahcd, char *buf) { struct usb_hub_status *hs = (struct usb_hub_status *)buf; u32 t = admhc_read_rhdesc(ahcd); u16 status, change; status = 0; status |= (t & ADMHC_RH_LPS) ? HUB_STATUS_LOCAL_POWER : 0; status |= (t & ADMHC_RH_OCI) ? HUB_STATUS_OVERCURRENT : 0; change = 0; change |= (t & ADMHC_RH_LPSC) ? HUB_CHANGE_LOCAL_POWER : 0; change |= (t & ADMHC_RH_OCIC) ? HUB_CHANGE_OVERCURRENT : 0; hs->wHubStatus = (__force __u16)cpu_to_hc16(ahcd, status); hs->wHubChange = (__force __u16)cpu_to_hc16(ahcd, change); return 0; }