ehci_rh_hand_over_port (usbdev_t *dev, int port)
{
volatile portsc_t *p = &(RH_INST(dev)->ports[port]);
- volatile portsc_t tmp;
debug("giving up port %x, it's USB1\n", port+1);
/* Lowspeed device. Hand over to companion */
- tmp = *p;
- tmp.port_owner = 1;
- *p = tmp;
- do {} while (!p->conn_status_change);
+ *p |= P_PORT_OWNER;
+ do {} while (!(*p & P_CONN_STATUS_CHANGE));
/* RW/C register, so clear it by writing 1 */
- tmp = *p;
- tmp.conn_status_change = 1;
- *p = tmp;
+ *p |= P_CONN_STATUS_CHANGE;
return;
}
ehci_rh_scanport (usbdev_t *dev, int port)
{
volatile portsc_t *p = &(RH_INST(dev)->ports[port]);
- volatile portsc_t tmp;
if (RH_INST(dev)->devices[port]!=-1) {
debug("Unregister device at port %x\n", port+1);
usb_detach_device(dev->controller, RH_INST(dev)->devices[port]);
RH_INST(dev)->devices[port]=-1;
}
/* device connected, handle */
- if (p->current_conn_status) {
+ if (*p & P_CURR_CONN_STATUS) {
mdelay(100);
- if (p->line_status == 0x1) {
+ if ((*p & P_LINE_STATUS) == P_LINE_STATUS_LOWSPEED) {
ehci_rh_hand_over_port(dev, port);
return;
}
/* Deassert enable, assert reset. These must change
* atomically.
*/
- tmp = *p;
- tmp.port_enable = 0;
- tmp.port_reset = 1;
- *p = tmp;
+ *p = (*p & ~P_PORT_ENABLE) | P_PORT_RESET;
/* Wait a bit while reset is active. */
mdelay(50);
/* Deassert reset. */
- tmp.port_reset = 0;
- *p = tmp;
+ *p &= ~P_PORT_RESET;
/* Wait for flag change to finish. The controller might take a while */
- while (p->port_reset) ;
- if (!p->port_enable) {
+ while (*p & P_PORT_RESET) ;
+ if (!(*p & P_PORT_ENABLE)) {
ehci_rh_hand_over_port(dev, port);
return;
}
RH_INST(dev)->devices[port] = usb_attach_device(dev->controller, dev->address, port, 2);
}
/* RW/C register, so clear it by writing 1 */
- tmp = *p;
- tmp.conn_status_change = 1;
- *p = tmp;
+ *p |= P_CONN_STATUS_CHANGE;
}
static int
{
int i;
for (i=0; i<RH_INST(dev)->n_ports; i++) {
- if (RH_INST(dev)->ports[i].conn_status_change)
+ if (RH_INST(dev)->ports[i] & P_CONN_STATUS_CHANGE)
return i;
}
return -1;
{
int i;
volatile portsc_t *p;
- volatile portsc_t tmp;
dev->destroy = ehci_rh_destroy;
dev->poll = ehci_rh_poll;
dev->data = malloc(sizeof(rh_inst_t));
- RH_INST(dev)->n_ports = EHCI_INST(dev->controller)->capabilities->n_ports;
+ RH_INST(dev)->n_ports = EHCI_INST(dev->controller)->capabilities->hcsparams & HCS_NPORTS_MASK;
RH_INST(dev)->ports = EHCI_INST(dev->controller)->operation->portsc;
debug("root hub has %x ports\n", RH_INST(dev)->n_ports);
for (i=0; i < RH_INST(dev)->n_ports; i++) {
p = &(RH_INST(dev)->ports[i]);
RH_INST(dev)->devices[i] = -1;
- tmp = *p;
- tmp.pp = 1;
- *p = tmp;
+ *p |= P_PP;
}
dev->address = 0;