libpayload: Remove bitfield use from EHCI data structures
We agreed that bitfields are a Bad Idea[tm]. Change-Id: If4c4cb748af340e2721b89fea8e035da0632971f Signed-off-by: Patrick Georgi <patrick.georgi@secunet.com> Reviewed-on: http://review.coreboot.org/480 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org> Reviewed-by: Peter Stuge <peter@stuge.se>
This commit is contained in:
committed by
Peter Stuge
parent
b0b4a52b70
commit
8fa2787a0d
@@ -54,19 +54,14 @@ static void
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -74,16 +69,15 @@ static void
|
||||
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;
|
||||
}
|
||||
@@ -91,21 +85,17 @@ ehci_rh_scanport (usbdev_t *dev, int port)
|
||||
/* 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;
|
||||
}
|
||||
@@ -113,9 +103,7 @@ ehci_rh_scanport (usbdev_t *dev, int port)
|
||||
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
|
||||
@@ -123,7 +111,7 @@ ehci_rh_report_port_changes (usbdev_t *dev)
|
||||
{
|
||||
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;
|
||||
@@ -143,14 +131,13 @@ ehci_rh_init (usbdev_t *dev)
|
||||
{
|
||||
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);
|
||||
@@ -159,9 +146,7 @@ ehci_rh_init (usbdev_t *dev)
|
||||
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;
|
||||
|
Reference in New Issue
Block a user