Changeset 1f5c1e61 in mainline
- Timestamp:
- 2011-02-04T12:37:31Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1669a73
- Parents:
- 5944244
- Location:
- uspace/drv/uhci-rhd
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci-rhd/main.c
r5944244 r1f5c1e61 102 102 int main(int argc, char *argv[]) 103 103 { 104 usb_log_enable(USB_LOG_LEVEL_ INFO, NAME);104 usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME); 105 105 return driver_main(&uhci_rh_driver); 106 106 } -
uspace/drv/uhci-rhd/port.c
r5944244 r1f5c1e61 48 48 int uhci_port_init( 49 49 uhci_port_t *port, port_status_t *address, unsigned number, 50 unsigned usec, device_t *rh )50 unsigned usec, device_t *rh, int parent_phone) 51 51 { 52 52 assert(port); … … 56 56 port->attached_device = 0; 57 57 port->rh = rh; 58 port->hc_phone = rh->parent_phone;58 port->hc_phone = parent_phone; 59 59 60 60 port->checker = fibril_create(uhci_port_check, port); … … 71 71 void uhci_port_fini(uhci_port_t *port) 72 72 { 73 // TODO: destroy fibril 74 // TODO: hangup phone 73 75 // fibril_teardown(port->checker); 74 76 return; … … 77 79 int uhci_port_check(void *port) 78 80 { 79 async_usleep( 1000000 );80 81 uhci_port_t *port_instance = port; 81 82 assert(port_instance); … … 114 115 usb_log_info("Adding new device on port %d.\n", port->number); 115 116 117 /* get address of the future device */ 118 const usb_address_t usb_address = usb_drv_request_address(port->hc_phone); 119 120 if (usb_address <= 0) { 121 usb_log_error("Recieved invalid address(%d).\n", usb_address); 122 return usb_address; 123 } 124 usb_log_debug("Sucessfully obtained address %d for port %d.\n", 125 usb_address, port->number); 116 126 117 127 /* get default address */ 118 128 int ret = usb_drv_reserve_default_address(port->hc_phone); 119 129 if (ret != EOK) { 120 usb_log_error("Failed to reserve default address.\n"); 130 usb_log_error("Failed to reserve default address on port %d.\n", 131 port->number); 132 int ret2 = 133 usb_drv_release_address(port->hc_phone, usb_address); 134 if (ret2 != EOK) { 135 usb_log_fatal("Failed to return requested address on port %d.\n", 136 port->number); 137 return ret2; 138 } 139 usb_log_debug("Successfully returned reserved address on port %d.\n", 140 port->number); 121 141 return ret; 122 142 } 123 124 const usb_address_t usb_address = usb_drv_request_address(port->hc_phone); 125 126 if (usb_address <= 0) { 127 usb_log_error("Recieved invalid address(%d).\n", usb_address); 128 return usb_address; 129 } 143 usb_log_debug("Sucessfully obtained default address for port %d.\n", 144 port->number); 145 130 146 /* 131 147 * the host then waits for at least 100 ms to allow completion of … … 140 156 * (See Section 11.5.1.5) 141 157 */ 142 port_status_t port_status = 143 port_status_read(port->address); 144 port_status |= STATUS_IN_RESET; 145 port_status_write(port->address, port_status); 146 async_usleep(10000); 147 port_status = 148 port_status_read(port->address); 149 port_status &= ~STATUS_IN_RESET; 150 port_status_write(port->address, port_status); 158 { 159 usb_log_debug("Reset Signal start on port %d.\n", 160 port->number); 161 port_status_t port_status = 162 port_status_read(port->address); 163 port_status |= STATUS_IN_RESET; 164 port_status_write(port->address, port_status); 165 async_usleep(10000); 166 port_status = 167 port_status_read(port->address); 168 port_status &= ~STATUS_IN_RESET; 169 port_status_write(port->address, port_status); 170 usb_log_debug("Reset Signal stop on port %d.\n", 171 port->number); 172 } 151 173 152 174 /* assign address to device */ 153 175 ret = usb_drv_req_set_address(port->hc_phone, 0, usb_address); 154 155 176 156 177 if (ret != EOK) { /* address assigning went wrong */ … … 159 180 int release = usb_drv_release_default_address(port->hc_phone); 160 181 if (release != EOK) { 161 usb_log_error("Failed to release default address.\n"); 182 usb_log_error("Failed to release default address on port %d.\n", 183 port->number); 162 184 return release; 163 185 } 186 usb_log_debug("Sucessfully released default address on port %d.\n", 187 port->number); 164 188 return ret; 165 189 } 190 usb_log_debug("Sucessfully assigned address %d for port %d.\n", 191 usb_address, port->number); 166 192 167 193 /* release default address */ 168 194 ret = usb_drv_release_default_address(port->hc_phone); 169 195 if (ret != EOK) { 170 usb_log_error("Failed to release default address.\n"); 196 usb_log_error("Failed to release default address on port %d.\n", 197 port->number); 171 198 return ret; 172 199 } 200 usb_log_debug("Sucessfully released default address on port %d.\n", 201 port->number); 173 202 174 203 /* communicate and possibly report to devman */ … … 195 224 usb_log_error("Don't know how to remove device %#x.\n", 196 225 (unsigned int)port->attached_device); 197 uhci_port_set_enabled(port, false);226 // uhci_port_set_enabled(port, false); 198 227 return EOK; 199 228 } -
uspace/drv/uhci-rhd/port.h
r5944244 r1f5c1e61 54 54 int uhci_port_init( 55 55 uhci_port_t *port, port_status_t *address, unsigned number, 56 unsigned usec, device_t *rh );56 unsigned usec, device_t *rh, int parent_phone); 57 57 58 58 void uhci_port_fini(uhci_port_t *port); -
uspace/drv/uhci-rhd/port_status.c
r5944244 r1f5c1e61 64 64 unsigned i = 0; 65 65 for (;i < sizeof(flags)/sizeof(struct flag_name); ++i) { 66 usb_log_debug ("\t%s status: %s.\n", flags[i].name,66 usb_log_debug2("\t%s status: %s.\n", flags[i].name, 67 67 value & flags[i].flag ? "YES" : "NO"); 68 68 } -
uspace/drv/uhci-rhd/root_hub.c
r5944244 r1f5c1e61 53 53 } 54 54 55 /* connect to the parent device (HC) */56 rh->parent_phone = devman_device_connect(8, 0);57 //usb_drv_hc_connect(rh, instance->hc_handle, 0);58 if (rh->parent_phone < 0) {59 usb_log_error("Failed to connect to the HC device.\n");60 return rh->parent_phone;61 }62 63 55 /* allow access to root hub registers */ 64 56 assert(sizeof(port_status_t) * UHCI_ROOT_HUB_PORT_COUNT == size); … … 75 67 unsigned i = 0; 76 68 for (; i < UHCI_ROOT_HUB_PORT_COUNT; ++i) { 69 /* connect to the parent device (HC) */ 70 int parent_phone = devman_device_connect(instance->hc_handle, 0); 71 //usb_drv_hc_connect(rh, instance->hc_handle, 0); 72 if (parent_phone < 0) { 73 usb_log_error("Failed to connect to the HC device port %d.\n", i); 74 return parent_phone; 75 } 77 76 /* mind pointer arithmetics */ 78 77 int ret = uhci_port_init( 79 &instance->ports[i], regs + i, i, ROOT_HUB_WAIT_USEC, rh );78 &instance->ports[i], regs + i, i, ROOT_HUB_WAIT_USEC, rh, parent_phone); 80 79 if (ret != EOK) { 81 80 unsigned j = 0;
Note:
See TracChangeset
for help on using the changeset viewer.