diff options
Diffstat (limited to 'payloads/libpayload/drivers/usb/uhci_rh.c')
-rw-r--r-- | payloads/libpayload/drivers/usb/uhci_rh.c | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/payloads/libpayload/drivers/usb/uhci_rh.c b/payloads/libpayload/drivers/usb/uhci_rh.c index d3337597c1..e7f0da7666 100644 --- a/payloads/libpayload/drivers/usb/uhci_rh.c +++ b/payloads/libpayload/drivers/usb/uhci_rh.c @@ -39,7 +39,7 @@ typedef struct { #define RH_INST(dev) ((rh_inst_t*)(dev)->data) static void -uhci_rh_enable_port (usbdev_t *dev, int port) +uhci_rh_enable_port(usbdev_t *dev, int port) { u16 value; hci_t *controller = dev->controller; @@ -57,10 +57,10 @@ uhci_rh_enable_port (usbdev_t *dev, int port) uhci_reg_write16(controller, port, uhci_reg_read16(controller, port) | 1 << 9); /* reset */ - mdelay (30); // >10ms + mdelay(30); // >10ms uhci_reg_write16(controller, port, uhci_reg_read16(controller, port) & ~(1 << 9)); - mdelay (1); // >5.3us per spec, <3ms because some devices make trouble + mdelay(1); // >5.3us per spec, <3ms because some devices make trouble uhci_reg_write16(controller, port, uhci_reg_read16(controller, port) | 1 << 2); /* enable */ @@ -68,7 +68,7 @@ uhci_rh_enable_port (usbdev_t *dev, int port) /* TOTEST: how long to wait? 100ms for now */ int timeout = 200; /* time out after 200 * 500us == 100ms */ do { - value = uhci_reg_read16 (controller, port); + value = uhci_reg_read16(controller, port); udelay(500); timeout--; } while (((value & (1 << 2)) == 0) && (value & 0x01) && timeout); if (!timeout) @@ -77,7 +77,7 @@ uhci_rh_enable_port (usbdev_t *dev, int port) /* disable root hub */ static void -uhci_rh_disable_port (usbdev_t *dev, int port) +uhci_rh_disable_port(usbdev_t *dev, int port) { hci_t *controller = dev->controller; if (port == 1) @@ -95,7 +95,7 @@ uhci_rh_disable_port (usbdev_t *dev, int port) /* TOTEST: how long to wait? 100ms for now */ int timeout = 200; /* time out after 200 * 500us == 100ms */ do { - value = uhci_reg_read16 (controller, port); + value = uhci_reg_read16(controller, port); udelay(500); timeout--; } while (((value & (1 << 2)) != 0) && timeout); if (!timeout) @@ -103,7 +103,7 @@ uhci_rh_disable_port (usbdev_t *dev, int port) } static void -uhci_rh_scanport (usbdev_t *dev, int port) +uhci_rh_scanport(usbdev_t *dev, int port) { int portsc, offset; if (port == 1) { @@ -116,42 +116,42 @@ uhci_rh_scanport (usbdev_t *dev, int port) usb_debug("Invalid port %d\n", port); return; } - int devno = RH_INST (dev)->port[offset]; + int devno = RH_INST(dev)->port[offset]; if ((devno != -1) && (dev->controller->devices[devno] != 0)) { usb_detach_device(dev->controller, devno); - RH_INST (dev)->port[offset] = -1; + RH_INST(dev)->port[offset] = -1; } uhci_reg_write16(dev->controller, portsc, uhci_reg_read16(dev->controller, portsc) | (1 << 3) | (1 << 2)); // clear port state change, enable port mdelay(100); // wait for signal to stabilize - if ((uhci_reg_read16 (dev->controller, portsc) & 1) != 0) { + if ((uhci_reg_read16(dev->controller, portsc) & 1) != 0) { // device attached - uhci_rh_disable_port (dev, port); - uhci_rh_enable_port (dev, port); + uhci_rh_disable_port(dev, port); + uhci_rh_enable_port(dev, port); - usb_speed speed = ((uhci_reg_read16 (dev->controller, portsc) >> 8) & 1); + usb_speed speed = ((uhci_reg_read16(dev->controller, portsc) >> 8) & 1); - RH_INST (dev)->port[offset] = usb_attach_device(dev->controller, dev->address, portsc, speed); + RH_INST(dev)->port[offset] = usb_attach_device(dev->controller, dev->address, portsc, speed); } } static int -uhci_rh_report_port_changes (usbdev_t *dev) +uhci_rh_report_port_changes(usbdev_t *dev) { u16 stored, real; - stored = (RH_INST (dev)->port[0] == -1); - real = ((uhci_reg_read16 (dev->controller, PORTSC1) & 1) == 0); + stored = (RH_INST(dev)->port[0] == -1); + real = ((uhci_reg_read16(dev->controller, PORTSC1) & 1) == 0); if (stored != real) { usb_debug("change on port 1\n"); return 1; } - stored = (RH_INST (dev)->port[1] == -1); - real = ((uhci_reg_read16 (dev->controller, PORTSC2) & 1) == 0); + stored = (RH_INST(dev)->port[1] == -1); + real = ((uhci_reg_read16(dev->controller, PORTSC2) & 1) == 0); if (stored != real) { usb_debug("change on port 2\n"); return 2; @@ -159,11 +159,11 @@ uhci_rh_report_port_changes (usbdev_t *dev) // maybe detach+attach happened between two scans? - if ((uhci_reg_read16 (dev->controller, PORTSC1) & 2) > 0) { + if ((uhci_reg_read16(dev->controller, PORTSC1) & 2) > 0) { usb_debug("possibly re-attached on port 1\n"); return 1; } - if ((uhci_reg_read16 (dev->controller, PORTSC2) & 2) > 0) { + if ((uhci_reg_read16(dev->controller, PORTSC2) & 2) > 0) { usb_debug("possibly re-attached on port 2\n"); return 2; } @@ -173,35 +173,35 @@ uhci_rh_report_port_changes (usbdev_t *dev) } static void -uhci_rh_destroy (usbdev_t *dev) +uhci_rh_destroy(usbdev_t *dev) { - usb_detach_device (dev->controller, 1); - usb_detach_device (dev->controller, 2); - uhci_rh_disable_port (dev, 1); - uhci_rh_disable_port (dev, 2); - free (RH_INST (dev)); + usb_detach_device(dev->controller, 1); + usb_detach_device(dev->controller, 2); + uhci_rh_disable_port(dev, 1); + uhci_rh_disable_port(dev, 2); + free(RH_INST(dev)); } static void -uhci_rh_poll (usbdev_t *dev) +uhci_rh_poll(usbdev_t *dev) { int port; - while ((port = uhci_rh_report_port_changes (dev)) != -1) - uhci_rh_scanport (dev, port); + while ((port = uhci_rh_report_port_changes(dev)) != -1) + uhci_rh_scanport(dev, port); } void -uhci_rh_init (usbdev_t *dev) +uhci_rh_init(usbdev_t *dev) { dev->destroy = uhci_rh_destroy; dev->poll = uhci_rh_poll; - uhci_rh_enable_port (dev, 1); - uhci_rh_enable_port (dev, 2); - dev->data = xmalloc (sizeof (rh_inst_t)); + uhci_rh_enable_port(dev, 1); + uhci_rh_enable_port(dev, 2); + dev->data = xmalloc(sizeof(rh_inst_t)); - RH_INST (dev)->port[0] = -1; - RH_INST (dev)->port[1] = -1; + RH_INST(dev)->port[0] = -1; + RH_INST(dev)->port[1] = -1; /* we can set them here because a root hub _really_ shouldn't appear elsewhere */ |