Changeset e646c61 in mainline
- Timestamp:
- 2013-01-06T13:19:45Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- be554d9
- Parents:
- 5c058b6e
- Location:
- uspace/drv/bus/usb/uhci
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/uhci/hc.c
r5c058b6e re646c61 243 243 (void)hc_debug_checker; 244 244 245 uhci_rh_init(&instance->rh, &instance->registers->ports[0]);245 uhci_rh_init(&instance->rh, instance->registers->ports, "uhci"); 246 246 247 247 return EOK; -
uspace/drv/bus/usb/uhci/uhci_rh.c
r5c058b6e re646c61 62 62 static usbvirt_device_ops_t ops; 63 63 64 int uhci_rh_init(uhci_rh_t *instance, ioport16_t *ports )64 int uhci_rh_init(uhci_rh_t *instance, ioport16_t *ports, const char *name) 65 65 { 66 66 assert(instance); … … 69 69 instance->reset_changed[0] = false; 70 70 instance->reset_changed[1] = false; 71 return virthub_base_init(&instance->base, "uhci_rh", &ops, instance,71 return virthub_base_init(&instance->base, name, &ops, instance, 72 72 NULL, &hub_descriptor.header); 73 73 } … … 139 139 } while (0) 140 140 141 #define RH_DEBUG(d, port, msg, ...) \ 142 if ((int)port >= 0) \ 143 usb_log_debug("%s: rh-%d: " msg, d->name, port, ##__VA_ARGS__); \ 144 else \ 145 usb_log_debug("%s: rh: " msg, d->name, ##__VA_ARGS__) \ 146 141 147 static int req_get_port_state(usbvirt_device_t *device, 142 148 const usb_device_request_setup_packet_t *setup_packet, … … 152 158 data[0] = ((value & STATUS_LINE_D_MINUS) ? 1 : 0) 153 159 | ((value & STATUS_LINE_D_PLUS) ? 2 : 0); 160 RH_DEBUG(device, port, "Bus state %" PRIx8 "(source %" PRIx16")\n", 161 data[0], value); 154 162 *act_size = 1; 155 163 return EOK; … … 184 192 ((hub->reset_changed[port] ? 1 : 0) << USB_HUB_FEATURE_C_PORT_RESET) 185 193 ); 194 RH_DEBUG(device, port, "Port status %" PRIx32 " (source %" PRIx16 195 "%s)\n", uint32_usb2host(status), val, 196 hub->reset_changed[port] ? "-reset" : ""); 186 197 memcpy(data, &status, sizeof(status)); 187 198 *act_size = sizeof(status);; … … 197 208 TEST_SIZE_INIT(0, port, hub); 198 209 const unsigned feature = uint16_usb2host(setup_packet->value); 199 const uint16_t status = pio_read_16(hub->ports[port]) & ~STATUS_WC_BITS; 210 const uint16_t status = pio_read_16(hub->ports[port]); 211 const uint16_t val = status & (~STATUS_WC_BITS); 200 212 switch (feature) { 201 213 case USB_HUB_FEATURE_PORT_ENABLE: 202 pio_write_16(hub->ports[port], status & ~STATUS_ENABLED); 214 RH_DEBUG(device, port, "Clear port enable (status %" PRIx16 ")\n", 215 status); 216 pio_write_16(hub->ports[port], val & ~STATUS_ENABLED); 203 217 break; 204 218 case USB_HUB_FEATURE_PORT_SUSPEND: 205 pio_write_16(hub->ports[port], status & ~STATUS_SUSPEND); 219 RH_DEBUG(device, port, "Clear port suspend (status %" PRIx16 ")\n", 220 status); 221 pio_write_16(hub->ports[port], val & ~STATUS_SUSPEND); 206 222 // TODO we should do resume magic 207 223 usb_log_warning("Resume is not implemented on port %u\n", port); 208 224 break; 209 225 case USB_HUB_FEATURE_PORT_POWER: 226 RH_DEBUG(device, port, "Clear port power (status %" PRIx16 ")\n", 227 status); 210 228 /* We are always powered */ 211 229 usb_log_warning("Tried to power off port %u\n", port); 212 230 break; 213 231 case USB_HUB_FEATURE_C_PORT_CONNECTION: 214 pio_write_16(hub->ports[port], status | STATUS_CONNECTED_CHANGED); 232 RH_DEBUG(device, port, "Clear port conn change (status %" PRIx16 233 ")\n", status); 234 pio_write_16(hub->ports[port], val | STATUS_CONNECTED_CHANGED); 215 235 break; 216 236 case USB_HUB_FEATURE_C_PORT_RESET: 217 hub->reset_changed[port] = 0; 237 RH_DEBUG(device, port, "Clear port reset change (status %" PRIx16 238 ")\n", status); 239 hub->reset_changed[port] = false; 218 240 break; 219 241 case USB_HUB_FEATURE_C_PORT_ENABLE: 242 RH_DEBUG(device, port, "Clear port enable change (status %" PRIx16 243 ")\n", status); 220 244 pio_write_16(hub->ports[port], status | STATUS_ENABLED_CHANGED); 221 245 break; 222 246 case USB_HUB_FEATURE_C_PORT_SUSPEND: 247 RH_DEBUG(device, port, "Clear port suspend change (status %" PRIx16 248 ")\n", status); 223 249 //TODO 224 250 return ENOTSUP; 225 251 case USB_HUB_FEATURE_C_PORT_OVER_CURRENT: 252 RH_DEBUG(device, port, "Clear port OC change (status %" PRIx16 253 ")\n", status); 226 254 /* UHCI Does not report over current */ 227 255 break; 228 256 default: 257 RH_DEBUG(device, port, "Clear unknown feature %d (status %" PRIx16 258 ")\n", feature, status); 259 usb_log_warning("Clearing feature %d is unsupported\n", 260 feature); 229 261 return ESTALL; 230 262 } … … 243 275 switch (feature) { 244 276 case USB_HUB_FEATURE_PORT_RESET: 277 RH_DEBUG(device, port, "Set port reset before (status %" PRIx16 278 ")\n", status); 245 279 uhci_port_reset_enable(hub->ports[port]); 246 280 hub->reset_changed[port] = true; 281 RH_DEBUG(device, port, "Set port reset after (status %" PRIx16 282 ")\n", pio_read_16(hub->ports[port])); 247 283 break; 248 284 case USB_HUB_FEATURE_PORT_SUSPEND: 285 RH_DEBUG(device, port, "Set port suspend (status %" PRIx16 286 ")\n", status); 249 287 pio_write_16(hub->ports[port], 250 288 (status & ~STATUS_WC_BITS) | STATUS_SUSPEND); … … 252 290 break; 253 291 case USB_HUB_FEATURE_PORT_POWER: 292 RH_DEBUG(device, port, "Set port power (status %" PRIx16 293 ")\n", status); 254 294 /* We are always powered */ 255 295 usb_log_warning("Tried to power port %u\n", port); … … 258 298 case USB_HUB_FEATURE_C_PORT_SUSPEND: 259 299 case USB_HUB_FEATURE_C_PORT_OVER_CURRENT: 300 RH_DEBUG(device, port, "Set port change flag (status %" PRIx16 301 ")\n", status); 260 302 /* These are voluntary and don't have to be set 261 303 * there is no way we could do it on UHCI anyway */ 262 304 break; 263 305 default: 306 RH_DEBUG(device, port, "Set unknown feature %d (status %" PRIx16 307 ")\n", feature, status); 308 usb_log_warning("Setting feature %d is unsupported\n", 309 feature); 264 310 return ESTALL; 265 311 } … … 343 389 }; 344 390 345 static int req_status_change_handler(usbvirt_device_t *dev ,391 static int req_status_change_handler(usbvirt_device_t *device, 346 392 usb_endpoint_t endpoint, usb_transfer_type_t tr_type, 347 393 void *buffer, size_t buffer_size, size_t *actual_size) … … 349 395 if (buffer_size < 1) 350 396 return ESTALL; 351 uhci_rh_t *hub = virthub_get_data(dev );397 uhci_rh_t *hub = virthub_get_data(device); 352 398 assert(hub); 353 399 400 const uint16_t status_a = pio_read_16(hub->ports[0]); 401 const uint16_t status_b = pio_read_16(hub->ports[1]); 354 402 const uint8_t status = 355 ((((pio_read_16(hub->ports[0]) & STATUS_CHANGE_BITS) != 0) 356 || hub->reset_changed[0]) ? 0x2 : 0) | 357 ((((pio_read_16(hub->ports[1]) & STATUS_CHANGE_BITS) != 0) 358 || hub->reset_changed[1]) ? 0x4 : 0); 403 ((((status_a & STATUS_CHANGE_BITS) != 0) || hub->reset_changed[0]) ? 404 0x2 : 0) | 405 ((((status_b & STATUS_CHANGE_BITS) != 0) || hub->reset_changed[1]) ? 406 0x4 : 0); 407 408 RH_DEBUG(device, -1, "Event mask %" PRIx8 409 " (status_a %" PRIx16 "%s)," 410 " (status_b %" PRIx16 "%s)\n", status, 411 status_a, hub->reset_changed[0] ? "-reset" : "", 412 status_b, hub->reset_changed[1] ? "-reset" : "" ); 359 413 ((uint8_t *)buffer)[0] = status; 360 414 *actual_size = 1; -
uspace/drv/bus/usb/uhci/uhci_rh.h
r5c058b6e re646c61 49 49 } uhci_rh_t; 50 50 51 int uhci_rh_init(uhci_rh_t *instance, ioport16_t *ports );51 int uhci_rh_init(uhci_rh_t *instance, ioport16_t *ports, const char *name); 52 52 int uhci_rh_schedule(uhci_rh_t *instance, usb_transfer_batch_t *batch); 53 53 static inline usb_address_t uhci_rh_get_address(uhci_rh_t *instance)
Note:
See TracChangeset
for help on using the changeset viewer.