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