Changes in uspace/drv/uhci-rhd/port.c [87157982:1ae51ae] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci-rhd/port.c
r87157982 r1ae51ae 34 34 #include <errno.h> 35 35 #include <str_error.h> 36 #include <fibril_synch.h> 36 37 37 38 #include <usb/usb.h> /* usb_address_t */ … … 45 46 #include "port_status.h" 46 47 47 static int uhci_port_new_device(uhci_port_t *port );48 static int uhci_port_new_device(uhci_port_t *port, uint16_t status); 48 49 static int uhci_port_remove_device(uhci_port_t *port); 49 50 static int uhci_port_set_enabled(uhci_port_t *port, bool enabled); 50 51 static int uhci_port_check(void *port); 52 static int new_device_enable_port(int portno, void *arg); 51 53 52 54 int uhci_port_init( 53 55 uhci_port_t *port, port_status_t *address, unsigned number, 54 unsigned usec, ddf_dev_t *rh , int parent_phone)56 unsigned usec, ddf_dev_t *rh) 55 57 { 56 58 assert(port); … … 90 92 uhci_port_t *port_instance = port; 91 93 assert(port_instance); 94 port_status_write(port_instance->address, 0); 95 96 uint64_t count = 0; 92 97 93 98 while (1) { 99 async_usleep(port_instance->wait_period_usec); 100 94 101 /* read register value */ 95 102 port_status_t port_status = … … 97 104 98 105 /* debug print */ 99 usb_log_debug("Port %d status at %p: 0x%04x.\n", 100 port_instance->number, port_instance->address, port_status); 101 print_port_status(port_status); 102 103 if (port_status & STATUS_CONNECTED_CHANGED) { 106 static fibril_mutex_t dbg_mtx = FIBRIL_MUTEX_INITIALIZER(dbg_mtx); 107 fibril_mutex_lock(&dbg_mtx); 108 usb_log_debug("Port %d status at %p: 0x%04x. === %llu\n", 109 port_instance->number, port_instance->address, port_status, count++); 110 // print_port_status(port_status); 111 fibril_mutex_unlock(&dbg_mtx); 112 113 if ((port_status & STATUS_CONNECTED_CHANGED) != 0) { 114 usb_log_debug("Change detected on port %d: %x.\n", 115 port_instance->number, port_status); 116 117 104 118 int rc = usb_hc_connection_open( 105 119 &port_instance->hc_connection); 106 120 if (rc != EOK) { 107 121 usb_log_error("Failed to connect to HC."); 108 goto next; 109 } 110 111 if (port_status & STATUS_CONNECTED) { 122 continue; 123 } 124 125 /* remove any old device */ 126 if (port_instance->attached_device) { 127 usb_log_debug("Removing device on port %d.\n", 128 port_instance->number); 129 uhci_port_remove_device(port_instance); 130 } 131 132 if ((port_status & STATUS_CONNECTED) != 0) { 112 133 /* new device */ 113 uhci_port_new_device(port_instance );134 uhci_port_new_device(port_instance, port_status); 114 135 } else { 115 uhci_port_remove_device(port_instance); 136 /* ack changes by writing one to WC bits */ 137 port_status_write(port_instance->address, port_status); 138 usb_log_debug("Change status ack on port %d.\n", 139 port_instance->number); 116 140 } 117 141 … … 120 144 if (rc != EOK) { 121 145 usb_log_error("Failed to disconnect from HC."); 122 goto next;123 146 } 124 147 } 125 next:126 async_usleep(port_instance->wait_period_usec);127 148 } 128 149 return EOK; … … 147 168 async_usleep(100000); 148 169 149 /* Enable the port. */150 uhci_port_set_enabled(port, true);151 170 152 171 /* The hub maintains the reset signal to that port for 10 ms … … 169 188 } 170 189 171 return EOK; 172 } 173 174 /*----------------------------------------------------------------------------*/ 175 static int uhci_port_new_device(uhci_port_t *port) 190 /* Enable the port. */ 191 uhci_port_set_enabled(port, true); 192 193 return EOK; 194 } 195 196 /*----------------------------------------------------------------------------*/ 197 static int uhci_port_new_device(uhci_port_t *port, uint16_t status) 176 198 { 177 199 assert(port); … … 182 204 usb_address_t dev_addr; 183 205 int rc = usb_hc_new_device_wrapper(port->rh, &port->hc_connection, 184 USB_SPEED_FULL,206 ((status & STATUS_LOW_SPEED) != 0) ? USB_SPEED_LOW : USB_SPEED_FULL, 185 207 new_device_enable_port, port->number, port, 186 208 &dev_addr, &port->attached_device, NULL, NULL, NULL); 209 187 210 if (rc != EOK) { 188 211 usb_log_error("Failed adding new device on port %u: %s.\n",
Note:
See TracChangeset
for help on using the changeset viewer.