Changeset 193da9d6 in mainline
- Timestamp:
- 2011-09-19T14:15:55Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7a05ced0
- Parents:
- 34a0d17
- Location:
- uspace/drv/bus/usb/usbhub
- Files:
-
- 6 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbhub/port_status.h
r34a0d17 r193da9d6 1 1 /* 2 2 * Copyright (c) 2010 Matus Dekanek 3 * Copyright (c) 2011 Jan Vesely 3 4 * All rights reserved. 4 5 * … … 36 37 #include <sys/types.h> 37 38 #include <usb/dev/request.h> 38 #include "usbhub_private.h"39 39 40 40 /** -
uspace/drv/bus/usb/usbhub/ports.c
r34a0d17 r193da9d6 44 44 #include "ports.h" 45 45 #include "usbhub.h" 46 #include "u sbhub_private.h"46 #include "utils.h" 47 47 #include "port_status.h" 48 48 -
uspace/drv/bus/usb/usbhub/ports.h
r34a0d17 r193da9d6 62 62 * @param port Port to be initialized. 63 63 */ 64 static inline void usb_hub_port_init(usb_hub_port_t *port) { 64 static inline void usb_hub_port_init(usb_hub_port_t *port) 65 { 66 assert(port); 65 67 port->attached_device.address = -1; 66 68 port->attached_device.handle = 0; -
uspace/drv/bus/usb/usbhub/usbhub.c
r34a0d17 r193da9d6 38 38 #include <str_error.h> 39 39 #include <inttypes.h> 40 41 #include <usb_iface.h> 40 #include <stdio.h> 41 42 #include <usb/usb.h> 43 #include <usb/dev/pipes.h> 44 #include <usb/classes/classes.h> 42 45 #include <usb/ddfiface.h> 43 46 #include <usb/descriptor.h> … … 46 49 #include <usb/classes/hub.h> 47 50 #include <usb/dev/poll.h> 48 #include < stdio.h>51 #include <usb_iface.h> 49 52 50 53 #include "usbhub.h" 51 #include "u sbhub_private.h"54 #include "utils.h" 52 55 #include "port_status.h" 53 #include <usb/usb.h>54 #include <usb/dev/pipes.h>55 #include <usb/classes/classes.h>56 56 57 57 #define HUB_FNC_NAME "hub" 58 58 59 static int usb_set_first_configuration(usb_device_t *usb_device); 59 60 static usb_hub_info_t * usb_hub_info_create(usb_device_t *usb_dev); 60 61 static int usb_hub_process_hub_specific_info(usb_hub_info_t *hub_info); 61 static int usb_hub_set_configuration(usb_hub_info_t *hub_info);62 62 static int usb_process_hub_over_current(usb_hub_info_t *hub_info, 63 63 usb_hub_status_t status); … … 85 85 int usb_hub_add_device(usb_device_t *usb_dev) 86 86 { 87 if (!usb_dev) return EINVAL; 87 assert(usb_dev); 88 /* Create driver soft-state structure */ 88 89 usb_hub_info_t *hub_info = usb_hub_info_create(usb_dev); 89 90 //create hc connection 90 if (hub_info == NULL) { 91 usb_log_error("Failed to create hun driver structure.\n"); 92 return ENOMEM; 93 } 94 95 /* Create hc connection */ 91 96 usb_log_debug("Initializing USB wire abstraction.\n"); 92 97 int opResult = usb_hc_connection_initialize_from_device( … … 99 104 } 100 105 101 / /set hub configuration102 opResult = usb_ hub_set_configuration(hub_info);106 /* Set hub's first configuration. (There should be only one) */ 107 opResult = usb_set_first_configuration(usb_dev); 103 108 if (opResult != EOK) { 104 109 usb_log_error("Could not set hub configuration: %s\n", … … 233 238 * information. If there are non-removable devices, start initializing them. 234 239 * This function is hub-specific and should be run only after the hub is 235 * configured using usb_ hub_set_configuration function.240 * configured using usb_set_first_configuration function. 236 241 * @param hub_info hub representation 237 242 * @return error code … … 239 244 int usb_hub_process_hub_specific_info(usb_hub_info_t *hub_info) 240 245 { 246 assert(hub_info); 241 247 // get hub descriptor 242 248 usb_log_debug("Retrieving descriptor\n"); … … 267 273 hub_info->port_count = descriptor.ports_count; 268 274 275 // TODO Why +1 ? 269 276 hub_info->ports = 270 277 malloc(sizeof(usb_hub_port_t) * (hub_info->port_count + 1)); … … 304 311 305 312 } else { 306 usb_log_debug("Power not switched, not going to bepowered\n");313 usb_log_debug("Power not switched, ports always powered\n"); 307 314 } 308 315 return EOK; … … 310 317 311 318 /** 312 * Set configuration of hub319 * Set configuration of and USB device 313 320 * 314 321 * Check whether there is at least one configuration and sets the first one. 315 322 * This function should be run prior to running any hub-specific action. 316 * @param hub_info hubrepresentation323 * @param usb_device usb device representation 317 324 * @return error code 318 325 */ 319 static int usb_ hub_set_configuration(usb_hub_info_t *hub_info)326 static int usb_set_first_configuration(usb_device_t *usb_device) 320 327 { 321 //device descriptor322 const usb_standard_device_descriptor_t *std_descriptor323 = &hub_info->usb_device->descriptors.device;324 usb_log_debug("Hub has %d configurations\n",325 std_descriptor->configuration_count);326 327 if ( std_descriptor->configuration_count < 1) {328 assert(usb_device); 329 /* Get number of possible configurations from device descriptor */ 330 const size_t configuration_count = 331 usb_device->descriptors.device.configuration_count; 332 usb_log_debug("Hub has %d configurations.\n", configuration_count); 333 334 if (configuration_count < 1) { 328 335 usb_log_error("There are no configurations available\n"); 329 336 return EINVAL; 330 337 } 331 338 339 // TODO: Make sure that there is enough data and the cast is correct 332 340 usb_standard_configuration_descriptor_t *config_descriptor 333 341 = (usb_standard_configuration_descriptor_t *) 334 hub_info->usb_device->descriptors.configuration; 335 336 /* Set configuration. */ 337 int opResult = usb_request_set_configuration( 338 &hub_info->usb_device->ctrl_pipe, 339 config_descriptor->configuration_number); 340 342 usb_device->descriptors.configuration; 343 344 /* Set configuration. Use the configuration that was in 345 * usb_device->descriptors.configuration */ 346 const int opResult = usb_request_set_configuration( 347 &usb_device->ctrl_pipe, config_descriptor->configuration_number); 341 348 if (opResult != EOK) { 342 349 usb_log_error("Failed to set hub configuration: %s.\n", -
uspace/drv/bus/usb/usbhub/usbhub.h
r34a0d17 r193da9d6 56 56 size_t port_count; 57 57 58 /** attached device handles, for each port one */58 /** Attached device handles, for each port one */ 59 59 usb_hub_port_t *ports; 60 60 61 61 fibril_mutex_t port_mutex; 62 62 63 /** connection to hcd */63 /** Connection to hcd */ 64 64 usb_hc_connection_t connection; 65 65 -
uspace/drv/bus/usb/usbhub/utils.c
r34a0d17 r193da9d6 42 42 43 43 #include "usbhub.h" 44 #include "usbhub_private.h" 45 #include "port_status.h" 44 #include "utils.h" 46 45 47 46 -
uspace/drv/bus/usb/usbhub/utils.h
r34a0d17 r193da9d6 1 1 /* 2 2 * Copyright (c) 2010 Matus Dekanek 3 * Copyright (c) 2011 Jan Vesely 3 4 * All rights reserved. 4 5 * … … 34 35 */ 35 36 36 #ifndef USBHUB_PRIVATE_H 37 #define USBHUB_PRIVATE_H 38 39 #include "usbhub.h" 37 #ifndef USBHUB_UTILS_H 38 #define USBHUB_UTILS_H 40 39 41 40 #include <adt/list.h> … … 48 47 #include <usb/debug.h> 49 48 #include <usb/dev/request.h> 49 50 #include "usbhub.h" 50 51 51 52 //************ … … 166 167 } 167 168 168 169 169 void * usb_create_serialized_hub_descriptor(usb_hub_descriptor_t *descriptor); 170 170 … … 175 175 void *serialized_descriptor, size_t size, usb_hub_descriptor_t *descriptor); 176 176 177 178 #endif /* USBHUB_PRIVATE_H */ 179 177 #endif 180 178 /** 181 179 * @}
Note:
See TracChangeset
for help on using the changeset viewer.