Changeset aff1880 in mainline
- Timestamp:
- 2011-09-23T12:59:35Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6c5abf9
- Parents:
- 48a31be
- Location:
- uspace/drv/bus/usb/usbhub
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbhub/port_status.h
r48a31be raff1880 31 31 */ 32 32 33 #ifndef HUB_ PORT_STATUS_H34 #define HUB_ PORT_STATUS_H33 #ifndef HUB_STATUS_H 34 #define HUB_STATUS_H 35 35 36 36 #include <bool.h> … … 89 89 (1 << (16 + USB_HUB_FEATURE_C_HUB_LOCAL_POWER)) 90 90 91 /**92 * set the device request to be a port feature enable request93 * @param request94 * @param port95 * @param feature_selector96 */97 static inline void usb_hub_set_enable_port_feature_request(98 usb_device_request_setup_packet_t *request, uint16_t port,99 uint16_t feature_selector) {100 request->index = port;101 request->request_type = USB_HUB_REQ_TYPE_SET_PORT_FEATURE;102 request->request = USB_HUB_REQUEST_SET_FEATURE;103 request->value = feature_selector;104 request->length = 0;105 }106 107 /**108 * set the device request to be a port feature clear request109 * @param request110 * @param port111 * @param feature_selector112 */113 static inline void usb_hub_set_disable_port_feature_request(114 usb_device_request_setup_packet_t *request, uint16_t port,115 uint16_t feature_selector116 ) {117 request->index = port;118 request->request_type = USB_HUB_REQ_TYPE_SET_PORT_FEATURE;119 request->request = USB_HUB_REQUEST_CLEAR_FEATURE;120 request->value = feature_selector;121 request->length = 0;122 }123 124 /**125 * set the device request to be a port disable request126 * @param request127 * @param port128 */129 static inline void usb_hub_set_reset_port_request(130 usb_device_request_setup_packet_t *request, uint16_t port131 ) {132 request->index = port;133 request->request_type = USB_HUB_REQ_TYPE_SET_PORT_FEATURE;134 request->request = USB_HUB_REQUEST_SET_FEATURE;135 request->value = USB_HUB_FEATURE_PORT_RESET;136 request->length = 0;137 }138 139 /**140 * get i`th bit of port status141 *142 * @param status143 * @param idx144 * @return145 */146 static inline bool usb_port_is_status(usb_port_status_t status, int idx) {147 return (status & (1 << idx)) != 0;148 }149 91 150 92 /** … … 154 96 * @return speed of usb device (for more see usb specification) 155 97 */ 156 static inline usb_speed_t usb_port_speed(usb_port_status_t status) { 98 static inline usb_speed_t usb_port_speed(usb_port_status_t status) 99 { 157 100 if ((status & USB_HUB_PORT_STATUS_LOW_SPEED) != 0) 158 101 return USB_SPEED_LOW; … … 162 105 } 163 106 164 165 166 #endif /* HUB_PORT_STATUS_H */ 107 #endif /* HUB_STATUS_H */ 167 108 /** 168 109 * @} -
uspace/drv/bus/usb/usbhub/ports.c
r48a31be raff1880 55 55 56 56 static void usb_hub_removed_device(usb_hub_info_t *hub, size_t port); 57 static void usb_hub_port_reset_completed( usb_hub_info_t *hub,58 uint16_t port, uint32_t status);57 static void usb_hub_port_reset_completed(const usb_hub_info_t *hub, 58 size_t port, usb_port_status_t status); 59 59 static int get_port_status(usb_pipe_t *ctrl_pipe, size_t port, 60 60 usb_port_status_t *status); … … 63 63 static int create_add_device_fibril(usb_hub_info_t *hub, size_t port, 64 64 usb_speed_t speed); 65 66 /** 67 * Clear feature on hub port. 68 * 69 * @param hc Host controller telephone 70 * @param address Hub address 71 * @param port_index Port 72 * @param feature Feature selector 73 * @return Operation result 74 */ 75 int usb_hub_clear_port_feature(usb_pipe_t *pipe, 76 int port_index, usb_hub_class_feature_t feature) 77 { 78 usb_device_request_setup_packet_t clear_request = { 79 .request_type = USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE, 80 .request = USB_DEVREQ_CLEAR_FEATURE, 81 .value = feature, 82 .index = port_index, 83 .length = 0, 84 }; 85 return usb_pipe_control_write(pipe, &clear_request, 86 sizeof(clear_request), NULL, 0); 87 } 88 /*----------------------------------------------------------------------------*/ 89 /** 90 * Clear feature on hub port. 91 * 92 * @param hc Host controller telephone 93 * @param address Hub address 94 * @param port_index Port 95 * @param feature Feature selector 96 * @return Operation result 97 */ 98 int usb_hub_set_port_feature(usb_pipe_t *pipe, 99 int port_index, usb_hub_class_feature_t feature) 100 { 101 102 usb_device_request_setup_packet_t clear_request = { 103 .request_type = USB_HUB_REQ_TYPE_SET_PORT_FEATURE, 104 .request = USB_DEVREQ_SET_FEATURE, 105 .index = port_index, 106 .value = feature, 107 .length = 0, 108 }; 109 return usb_pipe_control_write(pipe, &clear_request, 110 sizeof(clear_request), NULL, 0); 111 } 65 112 66 113 /** … … 160 207 static void usb_hub_removed_device(usb_hub_info_t *hub, size_t port) 161 208 { 162 163 209 /** \TODO remove device from device manager - not yet implemented in 164 210 * devide manager 165 211 */ 166 167 //close address168 169 212 usb_hub_port_t *the_port = hub->ports + port; 170 213 … … 204 247 * @param status 205 248 */ 206 static void usb_hub_port_reset_completed(usb_hub_info_t *hub, 207 uint16_t port, uint32_t status) 208 { 209 usb_log_debug("Port %zu reset complete.\n", (size_t) port); 210 if (usb_port_is_status(status, USB_HUB_FEATURE_PORT_ENABLE)) { 211 /* Finalize device adding. */ 212 usb_hub_port_t *the_port = hub->ports + port; 213 fibril_mutex_lock(&the_port->reset_mutex); 214 the_port->reset_completed = true; 215 the_port->reset_okay = true; 216 fibril_condvar_broadcast(&the_port->reset_cv); 217 fibril_mutex_unlock(&the_port->reset_mutex); 249 static void usb_hub_port_reset_completed(const usb_hub_info_t *hub, 250 size_t port, usb_port_status_t status) 251 { 252 usb_hub_port_t *the_port = hub->ports + port; 253 fibril_mutex_lock(&the_port->reset_mutex); 254 /* Finalize device adding. */ 255 the_port->reset_completed = true; 256 the_port->reset_okay = (status & USB_HUB_PORT_STATUS_ENABLED) != 0; 257 258 if (the_port->reset_okay) { 259 usb_log_debug("Port %zu reset complete.\n", port); 218 260 } else { 219 261 usb_log_warning( 220 "Port %zu reset complete but port not enabled.\n", 221 (size_t) port); 222 } 262 "Port %zu reset complete but port not enabled.\n", port); 263 } 264 fibril_condvar_broadcast(&the_port->reset_cv); 265 fibril_mutex_unlock(&the_port->reset_mutex); 266 223 267 /* Clear the port reset change. */ 224 268 int rc = usb_hub_clear_port_feature(hub->control_pipe, … … 229 273 } 230 274 } 231 275 /*----------------------------------------------------------------------------*/ 232 276 /** Retrieve port status. 233 277 * … … 285 329 assert(hub); 286 330 usb_hub_port_t *my_port = hub->ports + port_no; 287 288 usb_device_request_setup_packet_t request; 289 usb_hub_set_reset_port_request(&request, port_no); 290 291 const int rc = usb_pipe_control_write(hub->control_pipe, 292 &request, sizeof (request), NULL, 0); 331 const int rc = usb_hub_set_port_feature(hub->control_pipe, 332 port_no, USB_HUB_FEATURE_PORT_RESET); 293 333 if (rc != EOK) { 294 334 usb_log_warning("Port reset failed: %s.\n", str_error(rc)); -
uspace/drv/bus/usb/usbhub/ports.h
r48a31be raff1880 38 38 #include <usb/dev/driver.h> 39 39 #include <usb/dev/hub.h> 40 #include <usb/classes/hub.h> 40 41 41 42 typedef struct usb_hub_info_t usb_hub_info_t; … … 73 74 74 75 void usb_hub_process_port_interrupt(usb_hub_info_t *hub, size_t port); 75 76 int usb_hub_clear_port_feature(usb_pipe_t *pipe, 77 int port_index, usb_hub_class_feature_t feature); 78 int usb_hub_set_port_feature(usb_pipe_t *pipe, 79 int port_index, usb_hub_class_feature_t feature); 76 80 77 81 -
uspace/drv/bus/usb/usbhub/utils.h
r48a31be raff1880 50 50 #include "usbhub.h" 51 51 52 /**53 * Clear feature on hub port.54 *55 * @param hc Host controller telephone56 * @param address Hub address57 * @param port_index Port58 * @param feature Feature selector59 * @return Operation result60 */61 static inline int usb_hub_clear_port_feature(usb_pipe_t *pipe,62 int port_index, usb_hub_class_feature_t feature)63 {64 65 usb_device_request_setup_packet_t clear_request = {66 .request_type = USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE,67 .request = USB_DEVREQ_CLEAR_FEATURE,68 .length = 0,69 .index = port_index70 };71 clear_request.value = feature;72 return usb_pipe_control_write(pipe, &clear_request,73 sizeof (clear_request), NULL, 0);74 }75 76 /**77 * Clear feature on hub port.78 *79 * @param hc Host controller telephone80 * @param address Hub address81 * @param port_index Port82 * @param feature Feature selector83 * @return Operation result84 */85 static inline int usb_hub_set_port_feature(usb_pipe_t *pipe,86 int port_index, usb_hub_class_feature_t feature)87 {88 89 usb_device_request_setup_packet_t clear_request = {90 .request_type = USB_HUB_REQ_TYPE_SET_PORT_FEATURE,91 .request = USB_DEVREQ_SET_FEATURE,92 .length = 0,93 .index = port_index94 };95 clear_request.value = feature;96 return usb_pipe_control_write(pipe, &clear_request,97 sizeof (clear_request), NULL, 0);98 }99 52 100 53 void * usb_create_serialized_hub_descriptor(usb_hub_descriptor_t *descriptor);
Note:
See TracChangeset
for help on using the changeset viewer.