Changes in / [15d3b54:c69209d] in mainline
- Location:
- uspace
- Files:
-
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/doc/doxygroups.h
r15d3b54 rc69209d 253 253 * @defgroup drvusbuhci UHCI driver 254 254 * @ingroup usb 255 * @brief Drivers for USB UHCI host controller and root hub. 256 */ 257 258 /** 259 * @defgroup drvusbuhcirh UHCI root hub driver 260 * @ingroup drvusbuhci 261 * @brief Driver for UHCI complaint root hub. 262 */ 263 264 /** 265 * @defgroup drvusbuhcirh UHCI host controller driver 266 * @ingroup drvusbuhci 267 * @brief Driver for UHCI complaint USB host controller. 255 * @brief Driver for USB host controller UHCI. 268 256 */ 269 257 -
uspace/drv/ehci-hcd/main.c
r15d3b54 rc69209d 27 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 28 */ 29 /** @addtogroup drvusbehci29 /** @addtogroup usbdrvehci 30 30 * @{ 31 31 */ -
uspace/drv/uhci-hcd/batch.c
r15d3b54 rc69209d 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 /** @addtogroup drvusbuhcihc28 /** @addtogroup usb 29 29 * @{ 30 30 */ 31 31 /** @file 32 * @brief UHCI driver USB transaction structure32 * @brief UHCI driver 33 33 */ 34 34 #include <errno.h> … … 44 44 45 45 #define DEFAULT_ERROR_COUNT 3 46 47 static int batch_schedule(batch_t *instance); 46 48 47 49 static void batch_control(batch_t *instance, … … 52 54 static void batch_call_in_and_dispose(batch_t *instance); 53 55 static void batch_call_out_and_dispose(batch_t *instance); 54 55 56 /** Allocate memory and initialize internal data structure. 56 static void batch_dispose(batch_t *instance); 57 58 59 /** Allocates memory and initializes internal data structures. 57 60 * 58 61 * @param[in] fun DDF function to pass to callback. … … 69 72 * @param[in] arg additional parameter to func_in or func_out 70 73 * @param[in] manager Pointer to toggle management structure. 71 * @return Valid pointer if all substructures were successfully created, 72 * NULL otherwise. 73 * 74 * Determines the number of needed packets (TDs). Prepares a transport buffer 75 * (that is accessible by the hardware). Initializes parameters needed for the 76 * transaction and callback. 74 * @return False, if there is an active TD, true otherwise. 77 75 */ 78 76 batch_t * batch_get(ddf_fun_t *fun, usb_target_t target, … … 153 151 } 154 152 /*----------------------------------------------------------------------------*/ 155 /** Check batch TDs for activity.153 /** Checks batch TDs for activity. 156 154 * 157 155 * @param[in] instance Batch structure to use. 158 156 * @return False, if there is an active TD, true otherwise. 159 *160 * Walk all TDs. Stop with false if there is an active one (it is to be161 * processed). Stop with true if an error is found. Return true if the last TS162 * is reached.163 157 */ 164 158 bool batch_is_complete(batch_t *instance) … … 199 193 * 200 194 * @param[in] instance Batch structure to use. 201 *202 * Uses genercir control function with pids OUT and IN.203 195 */ 204 196 void batch_control_write(batch_t *instance) 205 197 { 206 198 assert(instance); 207 /* We are data out, we are supposed to provide data */199 /* we are data out, we are supposed to provide data */ 208 200 memcpy(instance->transport_buffer, instance->buffer, 209 201 instance->buffer_size); … … 211 203 instance->next_step = batch_call_out_and_dispose; 212 204 usb_log_debug("Batch(%p) CONTROL WRITE initialized.\n", instance); 205 batch_schedule(instance); 213 206 } 214 207 /*----------------------------------------------------------------------------*/ … … 216 209 * 217 210 * @param[in] instance Batch structure to use. 218 *219 * Uses generic control with pids IN and OUT.220 211 */ 221 212 void batch_control_read(batch_t *instance) … … 225 216 instance->next_step = batch_call_in_and_dispose; 226 217 usb_log_debug("Batch(%p) CONTROL READ initialized.\n", instance); 227 } 228 /*----------------------------------------------------------------------------*/ 229 /** Prepare interrupt in transaction. 230 * 231 * @param[in] instance Batch structure to use. 232 * 233 * Data transaction with PID_IN. 218 batch_schedule(instance); 219 } 220 /*----------------------------------------------------------------------------*/ 221 /** Prepares interrupt in transaction. 222 * 223 * @param[in] instance Batch structure to use. 234 224 */ 235 225 void batch_interrupt_in(batch_t *instance) … … 239 229 instance->next_step = batch_call_in_and_dispose; 240 230 usb_log_debug("Batch(%p) INTERRUPT IN initialized.\n", instance); 241 } 242 /*----------------------------------------------------------------------------*/ 243 /** Prepare interrupt out transaction. 244 * 245 * @param[in] instance Batch structure to use. 246 * 247 * Data transaction with PID_OUT. 231 batch_schedule(instance); 232 } 233 /*----------------------------------------------------------------------------*/ 234 /** Prepares interrupt out transaction. 235 * 236 * @param[in] instance Batch structure to use. 248 237 */ 249 238 void batch_interrupt_out(batch_t *instance) 250 239 { 251 240 assert(instance); 252 /* We are data out, we are supposed to provide data */241 /* we are data out, we are supposed to provide data */ 253 242 memcpy(instance->transport_buffer, instance->buffer, instance->buffer_size); 254 243 batch_data(instance, USB_PID_OUT); 255 244 instance->next_step = batch_call_out_and_dispose; 256 245 usb_log_debug("Batch(%p) INTERRUPT OUT initialized.\n", instance); 257 } 258 /*----------------------------------------------------------------------------*/ 259 /** Prepare bulk in transaction. 260 * 261 * @param[in] instance Batch structure to use. 262 * 263 * Data transaction with PID_IN. 246 batch_schedule(instance); 247 } 248 /*----------------------------------------------------------------------------*/ 249 /** Prepares bulk in transaction. 250 * 251 * @param[in] instance Batch structure to use. 264 252 */ 265 253 void batch_bulk_in(batch_t *instance) … … 269 257 instance->next_step = batch_call_in_and_dispose; 270 258 usb_log_debug("Batch(%p) BULK IN initialized.\n", instance); 271 } 272 /*----------------------------------------------------------------------------*/ 273 /** Prepare bulk out transaction. 274 * 275 * @param[in] instance Batch structure to use. 276 * 277 * Data transaction with PID_OUT. 259 batch_schedule(instance); 260 } 261 /*----------------------------------------------------------------------------*/ 262 /** Prepares bulk out transaction. 263 * 264 * @param[in] instance Batch structure to use. 278 265 */ 279 266 void batch_bulk_out(batch_t *instance) 280 267 { 281 268 assert(instance); 282 /* We are data out, we are supposed to provide data */283 269 memcpy(instance->transport_buffer, instance->buffer, instance->buffer_size); 284 270 batch_data(instance, USB_PID_OUT); 285 271 instance->next_step = batch_call_out_and_dispose; 286 272 usb_log_debug("Batch(%p) BULK OUT initialized.\n", instance); 287 } 288 /*----------------------------------------------------------------------------*/ 289 /** Prepare generic data transaction 273 batch_schedule(instance); 274 } 275 /*----------------------------------------------------------------------------*/ 276 /** Prepares generic data transaction 290 277 * 291 278 * @param[in] instance Batch structure to use. 292 279 * @param[in] pid to use for data packets. 293 *294 * Packets with alternating toggle bit and supplied pid value.295 * The last packet is marked with IOC flag.296 280 */ 297 281 void batch_data(batch_t *instance, usb_packet_id pid) … … 334 318 } 335 319 /*----------------------------------------------------------------------------*/ 336 /** Prepare generic control transaction320 /** Prepares generic control transaction 337 321 * 338 322 * @param[in] instance Batch structure to use. 339 323 * @param[in] data_stage to use for data packets. 340 324 * @param[in] status_stage to use for data packets. 341 *342 * Setup stage with toggle 0 and USB_PID_SETUP.343 * Data stage with alternating toggle and pid supplied by parameter.344 * Status stage with toggle 1 and pid supplied by parameter.345 * The last packet is marked with IOC.346 325 */ 347 326 void batch_control(batch_t *instance, … … 392 371 } 393 372 /*----------------------------------------------------------------------------*/ 394 /** Prepare data, get error status and call callback in. 395 * 396 * @param[in] instance Batch structure to use. 397 * Copies data from transport buffer, and calls callback with appropriate 398 * parameters. 373 /** Prepares data, gets error status and calls callback in. 374 * 375 * @param[in] instance Batch structure to use. 399 376 */ 400 377 void batch_call_in(batch_t *instance) … … 403 380 assert(instance->callback_in); 404 381 405 /* We are data in, we need data */382 /* we are data in, we need data */ 406 383 memcpy(instance->buffer, instance->transport_buffer, 407 384 instance->buffer_size); … … 416 393 } 417 394 /*----------------------------------------------------------------------------*/ 418 /** Get error status and callcallback out.395 /** Gets error status and calls callback out. 419 396 * 420 397 * @param[in] instance Batch structure to use. … … 432 409 } 433 410 /*----------------------------------------------------------------------------*/ 434 /** Helper function calls callback and correctly disposes of batch structure.411 /** Prepares data, gets error status, calls callback in and dispose. 435 412 * 436 413 * @param[in] instance Batch structure to use. … … 443 420 } 444 421 /*----------------------------------------------------------------------------*/ 445 /** Helper function calls callback and correctly disposes of batch structure.422 /** Gets error status, calls callback out and dispose. 446 423 * 447 424 * @param[in] instance Batch structure to use. … … 454 431 } 455 432 /*----------------------------------------------------------------------------*/ 456 /** Correctly dispose all used data structures.433 /** Correctly disposes all used data structures. 457 434 * 458 435 * @param[in] instance Batch structure to use. … … 469 446 free(instance); 470 447 } 448 /*----------------------------------------------------------------------------*/ 449 int batch_schedule(batch_t *instance) 450 { 451 assert(instance); 452 uhci_hc_t *hc = fun_to_uhci_hc(instance->fun); 453 assert(hc); 454 return uhci_hc_schedule(hc, instance); 455 } 471 456 /** 472 457 * @} -
uspace/drv/uhci-hcd/batch.h
r15d3b54 rc69209d 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 /** @addtogroup drvusbuhcihc28 /** @addtogroup usb 29 29 * @{ 30 30 */ 31 31 /** @file 32 * @brief UHCI driver USB transaction structure32 * @brief UHCI driver 33 33 */ 34 34 #ifndef DRV_UHCI_BATCH_H … … 78 78 ); 79 79 80 void batch_dispose(batch_t *instance);81 82 80 bool batch_is_complete(batch_t *instance); 83 81 -
uspace/drv/uhci-hcd/iface.c
r15d3b54 rc69209d 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 /** @addtogroup drvusbuhcihc28 /** @addtogroup usb 29 29 * @{ 30 30 */ 31 31 /** @file 32 * @brief UHCI driver hc interface implementation32 * @brief UHCI driver 33 33 */ 34 34 #include <ddf/driver.h> … … 161 161 return ENOMEM; 162 162 batch_interrupt_out(batch); 163 const int ret = uhci_hc_schedule(hc, batch);164 if (ret != EOK) {165 batch_dispose(batch);166 return ret;167 }168 163 return EOK; 169 164 } … … 197 192 return ENOMEM; 198 193 batch_interrupt_in(batch); 199 const int ret = uhci_hc_schedule(hc, batch);200 if (ret != EOK) {201 batch_dispose(batch);202 return ret;203 }204 194 return EOK; 205 195 } … … 234 224 return ENOMEM; 235 225 batch_bulk_out(batch); 236 const int ret = uhci_hc_schedule(hc, batch);237 if (ret != EOK) {238 batch_dispose(batch);239 return ret;240 }241 226 return EOK; 242 227 } … … 270 255 return ENOMEM; 271 256 batch_bulk_in(batch); 272 const int ret = uhci_hc_schedule(hc, batch);273 if (ret != EOK) {274 batch_dispose(batch);275 return ret;276 }277 257 return EOK; 278 258 } … … 313 293 device_keeper_reset_if_need(&hc->device_manager, target, setup_data); 314 294 batch_control_write(batch); 315 const int ret = uhci_hc_schedule(hc, batch);316 if (ret != EOK) {317 batch_dispose(batch);318 return ret;319 }320 295 return EOK; 321 296 } … … 352 327 return ENOMEM; 353 328 batch_control_read(batch); 354 const int ret = uhci_hc_schedule(hc, batch);355 if (ret != EOK) {356 batch_dispose(batch);357 return ret;358 }359 329 return EOK; 360 330 } -
uspace/drv/uhci-hcd/iface.h
r15d3b54 rc69209d 27 27 */ 28 28 29 /** @addtogroup drvusbuhcihc29 /** @addtogroup usb 30 30 * @{ 31 31 */ 32 32 /** @file 33 * @brief UHCI driver iface33 * @brief UHCI driver 34 34 */ 35 35 #ifndef DRV_UHCI_IFACE_H -
uspace/drv/uhci-hcd/main.c
r15d3b54 rc69209d 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 /** @addtogroup drvusbuhcihc28 /** @addtogroup usb 29 29 * @{ 30 30 */ 31 31 /** @file 32 * @brief UHCI driver initialization32 * @brief UHCI driver 33 33 */ 34 34 #include <ddf/driver.h> … … 55 55 }; 56 56 /*----------------------------------------------------------------------------*/ 57 /** Initialize a new ddf driver instance for uhci hc and hub.57 /** Initializes a new ddf driver instance for uhci hc and hub. 58 58 * 59 59 * @param[in] device DDF instance of the device to initialize. 60 60 * @return Error code. 61 * 62 * Gets and initialies hardware resources, disables any legacy support, 63 * and reports root hub device. 61 64 */ 62 65 int uhci_add_device(ddf_dev_t *device) … … 79 82 } 80 83 /*----------------------------------------------------------------------------*/ 81 /** Initialize global driver structures (NONE).84 /** Initializes global driver structures (NONE). 82 85 * 83 86 * @param[in] argc Nmber of arguments in argv vector (ignored). … … 89 92 int main(int argc, char *argv[]) 90 93 { 91 sleep(3); /* TODO: remove in final version */94 sleep(3); 92 95 usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME); 93 96 -
uspace/drv/uhci-hcd/pci.c
r15d3b54 rc69209d 27 27 */ 28 28 /** 29 * @addtogroup drvusbuhci hc29 * @addtogroup drvusbuhci 30 30 * @{ 31 31 */ … … 117 117 } 118 118 /*----------------------------------------------------------------------------*/ 119 /** Call the PCI driver with a request to enable interrupts119 /** Calls the PCI driver with a request to enable interrupts 120 120 * 121 121 * @param[in] device Device asking for interrupts … … 131 131 } 132 132 /*----------------------------------------------------------------------------*/ 133 /** Call the PCI driver with a request to clear legacy support register133 /** Calls the PCI driver with a request to clear legacy support register 134 134 * 135 135 * @param[in] device Device asking to disable interrupts -
uspace/drv/uhci-hcd/pci.h
r15d3b54 rc69209d 27 27 */ 28 28 29 /** @addtogroup drvusbuhci hc29 /** @addtogroup drvusbuhci 30 30 * @{ 31 31 */ 32 32 /** @file 33 * @brief UHCI driver PCI helper functions33 * @brief UHCI driver 34 34 */ 35 35 #ifndef DRV_UHCI_PCI_H -
uspace/drv/uhci-hcd/transfer_list.c
r15d3b54 rc69209d 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 /** @addtogroup drvusbuhcihc28 /** @addtogroup usb 29 29 * @{ 30 30 */ 31 31 /** @file 32 * @brief UHCI driver transfer list implementation32 * @brief UHCI driver 33 33 */ 34 34 #include <errno.h> 35 35 36 #include <usb/debug.h> 36 37 … … 40 41 transfer_list_t *instance, batch_t *batch); 41 42 /*----------------------------------------------------------------------------*/ 42 /** Initialize transfer list structures.43 /** Initializes transfer list structures. 43 44 * 44 45 * @param[in] instance Memory place to use. 45 * @param[in] name Name of t he new list.46 * @param[in] name Name of te new list. 46 47 * @return Error code 47 48 * … … 65 66 } 66 67 /*----------------------------------------------------------------------------*/ 67 /** Set the next list in transfer listchain.68 /** Set the next list in chain. 68 69 * 69 70 * @param[in] instance List to lead. … … 71 72 * @return Error code 72 73 * 73 * Does not check whether th is replaces an existing list.74 * Does not check whether there was a next list already. 74 75 */ 75 76 void transfer_list_set_next(transfer_list_t *instance, transfer_list_t *next) … … 79 80 if (!instance->queue_head) 80 81 return; 81 /* Set both next and element to point to the same QH */82 /* set both next and element to point to the same QH */ 82 83 qh_set_next_qh(instance->queue_head, next->queue_head_pa); 83 84 qh_set_element_qh(instance->queue_head, next->queue_head_pa); 84 85 } 85 86 /*----------------------------------------------------------------------------*/ 86 /** Submit transfer batch to thelist and queue.87 /** Submits a new transfer batch to list and queue. 87 88 * 88 89 * @param[in] instance List to use. 89 90 * @param[in] batch Transfer batch to submit. 90 91 * @return Error code 91 *92 * The batch is added to the end of the list and queue.93 92 */ 94 93 void transfer_list_add_batch(transfer_list_t *instance, batch_t *batch) … … 107 106 fibril_mutex_lock(&instance->guard); 108 107 109 /* Add to the hardware queue. */110 108 if (list_empty(&instance->batch_list)) { 111 109 /* There is nothing scheduled */ … … 119 117 qh_set_next_qh(last->qh, pa); 120 118 } 121 /* Add to the driver list */122 119 list_append(&batch->link, &instance->batch_list); 123 120 … … 129 126 } 130 127 /*----------------------------------------------------------------------------*/ 131 /** Remove a transfer batch from the list and queue.128 /** Removes a transfer batch from the list and queue. 132 129 * 133 130 * @param[in] instance List to use. … … 147 144 148 145 const char * pos = NULL; 149 /* Remove from the hardware queue */150 146 if (batch->link.prev == &instance->batch_list) { 151 147 /* I'm the first one here */ … … 158 154 pos = "NOT FIRST"; 159 155 } 160 /* Remove from the driver list */161 156 list_remove(&batch->link); 162 157 usb_log_debug("Batch(%p) removed (%s) from %s, next element %x.\n", … … 164 159 } 165 160 /*----------------------------------------------------------------------------*/ 166 /** Check list for finished batches.161 /** Checks list for finished batches. 167 162 * 168 163 * @param[in] instance List to use. 169 164 * @return Error code 170 *171 * Creates a local list of finished batches and calls next_step on each and172 * every one. This is safer because next_step may theoretically access173 * this transfer list leading to the deadlock if its done inline.174 165 */ 175 166 void transfer_list_remove_finished(transfer_list_t *instance) … … 186 177 187 178 if (batch_is_complete(batch)) { 188 /* Save for post-processing */189 179 transfer_list_remove_batch(instance, batch); 190 180 list_append(current, &done); -
uspace/drv/uhci-hcd/transfer_list.h
r15d3b54 rc69209d 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 /** @addtogroup drvusbuhcihc28 /** @addtogroup usb 29 29 * @{ 30 30 */ 31 31 /** @file 32 * @brief UHCI driver transfer list structure32 * @brief UHCI driver 33 33 */ 34 34 #ifndef DRV_UHCI_TRANSFER_LIST_H … … 50 50 } transfer_list_t; 51 51 52 /** Dispose transfer list structures. 53 * 54 * @param[in] instance Memory place to use. 55 * 56 * Frees memory for internal qh_t structure. 57 */ 52 int transfer_list_init(transfer_list_t *instance, const char *name); 53 54 void transfer_list_set_next(transfer_list_t *instance, transfer_list_t *next); 55 58 56 static inline void transfer_list_fini(transfer_list_t *instance) 59 57 { … … 61 59 free32(instance->queue_head); 62 60 } 63 64 int transfer_list_init(transfer_list_t *instance, const char *name);65 66 void transfer_list_set_next(transfer_list_t *instance, transfer_list_t *next);67 68 61 void transfer_list_remove_finished(transfer_list_t *instance); 69 62 -
uspace/drv/uhci-hcd/uhci.c
r15d3b54 rc69209d 60 60 } 61 61 /*----------------------------------------------------------------------------*/ 62 /** Get address of the device identified by handle.63 *64 * @param[in] dev DDF instance of the device to use.65 * @param[in] iid (Unused).66 * @param[in] call Pointer to the call that represents interrupt.67 */68 62 static int usb_iface_get_address( 69 63 ddf_fun_t *fun, devman_handle_t handle, usb_address_t *address) … … 112 106 }; 113 107 /*----------------------------------------------------------------------------*/ 114 /** Get root hub hw resources (I/O registers).108 /** Gets root hub hw resources. 115 109 * 116 110 * @param[in] fun Root hub function. … … 133 127 }; 134 128 /*----------------------------------------------------------------------------*/ 135 /** Initialize hc and rh ddf structures and their respective drivers.136 *137 * @param[in] instance UHCI structure to use.138 * @param[in] device DDF instance of the device to use.139 *140 * This function does all the preparatory work for hc and rh drivers:141 * - gets device hw resources142 * - disables UHCI legacy support143 * - asks for interrupt144 * - registers interrupt handler145 */146 129 int uhci_init(uhci_t *instance, ddf_dev_t *device) 147 130 { … … 174 157 "Failed(%d) to disable legacy USB: %s.\n", ret, str_error(ret)); 175 158 176 bool interrupts = false; 159 #if 0 177 160 ret = pci_enable_interrupts(device); 178 161 if (ret != EOK) { … … 180 163 "Failed(%d) to enable interrupts, fall back to polling.\n", 181 164 ret); 182 } else {183 usb_log_debug("Hw interrupts enabled.\n");184 interrupts = true;185 165 } 166 #endif 186 167 187 168 instance->hc_fun = ddf_fun_create(device, fun_exposed, "uhci-hc"); 188 169 ret = (instance->hc_fun == NULL) ? ENOMEM : EOK; 189 CHECK_RET_DEST_FUN_RETURN(ret, 190 "Failed(%d) to create HC function.\n", ret); 191 192 ret = uhci_hc_init(&instance->hc, instance->hc_fun, 193 (void*)io_reg_base, io_reg_size, interrupts); 170 CHECK_RET_DEST_FUN_RETURN(ret, "Failed(%d) to create HC function.\n", ret); 171 172 ret = uhci_hc_init( 173 &instance->hc, instance->hc_fun, (void*)io_reg_base, io_reg_size); 194 174 CHECK_RET_DEST_FUN_RETURN(ret, "Failed(%d) to init uhci-hcd.\n", ret); 195 175 instance->hc_fun->ops = &uhci_hc_ops; … … 237 217 #undef CHECK_RET_FINI_RETURN 238 218 } 219 239 220 /** 240 221 * @} -
uspace/drv/uhci-hcd/uhci.h
r15d3b54 rc69209d 31 31 */ 32 32 /** @file 33 * @brief UHCI driver main structure for both host controller and root-hub.33 * @brief UHCI driver 34 34 */ 35 35 #ifndef DRV_UHCI_UHCI_H -
uspace/drv/uhci-hcd/uhci_hc.c
r15d3b54 rc69209d 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 /** @addtogroup drvusbuhcihc28 /** @addtogroup usb 29 29 * @{ 30 30 */ 31 31 /** @file 32 * @brief UHCI Host controller driver routines32 * @brief UHCI driver 33 33 */ 34 34 #include <errno.h> … … 59 59 } 60 60 }; 61 62 /** Gets USB address of the calling device. 63 * 64 * @param[in] fun UHCI hc function. 65 * @param[in] handle Handle of the device seeking address. 66 * @param[out] address Place to store found address. 67 * @return Error code. 68 */ 61 69 /*----------------------------------------------------------------------------*/ 62 70 static int uhci_hc_init_transfer_lists(uhci_hc_t *instance); … … 70 78 bool low_speed, usb_transfer_type_t transfer, size_t size); 71 79 /*----------------------------------------------------------------------------*/ 72 /** Initialize UHCI hcd driver structure80 /** Initializes UHCI hcd driver structure 73 81 * 74 82 * @param[in] instance Memory place to initialize. … … 78 86 * @return Error code. 79 87 * @note Should be called only once on any structure. 80 * 81 * Initializes memory structures, starts up hw, and launches debugger and 82 * interrupt fibrils. 83 */ 84 int uhci_hc_init(uhci_hc_t *instance, ddf_fun_t *fun, 85 void *regs, size_t reg_size, bool interrupts) 88 */ 89 int uhci_hc_init(uhci_hc_t *instance, ddf_fun_t *fun, void *regs, size_t reg_size) 86 90 { 87 91 assert(reg_size >= sizeof(regs_t)); … … 96 100 } else (void) 0 97 101 98 instance->hw_interrupts = interrupts;99 102 /* Setup UHCI function. */ 100 103 instance->ddf_instance = fun; … … 115 118 116 119 uhci_hc_init_hw(instance); 117 if (!interrupts) { 118 instance->cleaner = 119 fibril_create(uhci_hc_interrupt_emulator, instance); 120 fibril_add_ready(instance->cleaner); 121 } 120 instance->cleaner = 121 fibril_create(uhci_hc_interrupt_emulator, instance); 122 fibril_add_ready(instance->cleaner); 122 123 123 124 instance->debug_checker = fibril_create(uhci_hc_debug_checker, instance); … … 129 130 } 130 131 /*----------------------------------------------------------------------------*/ 131 /** Initialize UHCI hchw resources.132 /** Initializes UHCI hcd hw resources. 132 133 * 133 134 * @param[in] instance UHCI structure to use. 134 * For magic values see UHCI Design Guide135 135 */ 136 136 void uhci_hc_init_hw(uhci_hc_t *instance) … … 153 153 pio_write_32(®isters->flbaseadd, pa); 154 154 155 if (instance->hw_interrupts) { 156 /* Enable all interrupts, but resume interrupt */ 157 pio_write_16(&instance->registers->usbintr, 158 UHCI_INTR_CRC | UHCI_INTR_COMPLETE | UHCI_INTR_SHORT_PACKET); 159 } 155 /* Enable all interrupts, but resume interrupt */ 156 // pio_write_16(&instance->registers->usbintr, 157 // UHCI_INTR_CRC | UHCI_INTR_COMPLETE | UHCI_INTR_SHORT_PACKET); 160 158 161 159 uint16_t status = pio_read_16(®isters->usbcmd); … … 168 166 } 169 167 /*----------------------------------------------------------------------------*/ 170 /** Initialize UHCI hcmemory structures.168 /** Initializes UHCI hcd memory structures. 171 169 * 172 170 * @param[in] instance UHCI structure to use. 173 171 * @return Error code 174 172 * @note Should be called only once on any structure. 175 *176 * Structures:177 * - interrupt code (I/O addressses are customized per instance)178 * - transfer lists (queue heads need to be accessible by the hw)179 * - frame list page (needs to be one UHCI hw accessible 4K page)180 173 */ 181 174 int uhci_hc_init_mem_structures(uhci_hc_t *instance) … … 236 229 } 237 230 /*----------------------------------------------------------------------------*/ 238 /** Initialize UHCI hctransfer lists.231 /** Initializes UHCI hcd transfer lists. 239 232 * 240 233 * @param[in] instance UHCI structure to use. 241 234 * @return Error code 242 235 * @note Should be called only once on any structure. 243 *244 * Initializes transfer lists and sets them in one chain to support proper245 * USB scheduling. Sets pointer table for quick access.246 236 */ 247 237 int uhci_hc_init_transfer_lists(uhci_hc_t *instance) … … 303 293 } 304 294 /*----------------------------------------------------------------------------*/ 305 /** Schedule batch for execution.295 /** Schedules batch for execution. 306 296 * 307 297 * @param[in] instance UHCI structure to use. 308 298 * @param[in] batch Transfer batch to schedule. 309 299 * @return Error code 310 *311 * Checks for bandwidth availability and appends the batch to the proper queue.312 300 */ 313 301 int uhci_hc_schedule(uhci_hc_t *instance, batch_t *batch) … … 324 312 return ENOTSUP; 325 313 } 326 /* TODO: check available bandwi dth here */314 /* TODO: check available bandwith here */ 327 315 328 316 transfer_list_t *list = … … 334 322 } 335 323 /*----------------------------------------------------------------------------*/ 336 /** Take action based on the interrupt cause.324 /** Takes action based on the interrupt cause. 337 325 * 338 326 * @param[in] instance UHCI structure to use. 339 * @param[in] status Value of the status register at the time of interrupt. 340 * 341 * Interrupt might indicate: 342 * - transaction completed, either by triggering IOC, SPD, or an error 343 * - some kind of device error 344 * - resume from suspend state (not implemented) 327 * @param[in] status Value of the stsatus regiser at the time of interrupt. 345 328 */ 346 329 void uhci_hc_interrupt(uhci_hc_t *instance, uint16_t status) … … 359 342 /** Polling function, emulates interrupts. 360 343 * 361 * @param[in] arg UHCI hcstructure to use.362 * @return EOK (should never return)344 * @param[in] arg UHCI structure to use. 345 * @return EOK 363 346 */ 364 347 int uhci_hc_interrupt_emulator(void* arg) … … 383 366 * 384 367 * @param[in] arg UHCI structure to use. 385 * @return EOK (should never return)368 * @return EOK 386 369 */ 387 370 int uhci_hc_debug_checker(void *arg) … … 447 430 } 448 431 /*----------------------------------------------------------------------------*/ 449 /** Check transfer packets, for USB validity432 /** Checks transfer packets, for USB validity 450 433 * 451 434 * @param[in] low_speed Transfer speed. 452 435 * @param[in] transfer Transer type 453 436 * @param[in] size Maximum size of used packets 454 * @return True if transaction is allowed by USB specs, false otherwise437 * @return EOK 455 438 */ 456 439 bool allowed_usb_packet( -
uspace/drv/uhci-hcd/uhci_hc.h
r15d3b54 rc69209d 27 27 */ 28 28 29 /** @addtogroup drvusbuhci hc29 /** @addtogroup drvusbuhci 30 30 * @{ 31 31 */ 32 32 /** @file 33 * @brief UHCI host controller driver structure33 * @brief UHCI driver 34 34 */ 35 35 #ifndef DRV_UHCI_UHCI_HC_H … … 99 99 fid_t cleaner; 100 100 fid_t debug_checker; 101 bool hw_interrupts;102 101 103 102 ddf_fun_t *ddf_instance; 104 103 } uhci_hc_t; 105 104 106 int uhci_hc_init(uhci_hc_t *instance, ddf_fun_t *fun, 107 void *regs, size_t reg_size, bool interupts); 105 /* init uhci specifics in device.driver_data */ 106 int uhci_hc_init(uhci_hc_t *instance, ddf_fun_t *fun, void *regs, size_t reg_size); 107 108 static inline void uhci_hc_fini(uhci_hc_t *instance) { /* TODO: implement*/ }; 108 109 109 110 int uhci_hc_schedule(uhci_hc_t *instance, batch_t *batch); … … 111 112 void uhci_hc_interrupt(uhci_hc_t *instance, uint16_t status); 112 113 113 /** Safely dispose host controller internal structures114 *115 * @param[in] instance Host controller structure to use.116 */117 static inline void uhci_hc_fini(uhci_hc_t *instance) { /* TODO: implement*/ };118 119 /** Get and cast pointer to the driver data120 *121 * @param[in] fun DDF function pointer122 * @return cast pointer to driver_data123 */124 114 static inline uhci_hc_t * fun_to_uhci_hc(ddf_fun_t *fun) 125 115 { return (uhci_hc_t*)fun->driver_data; } -
uspace/drv/uhci-hcd/uhci_rh.c
r15d3b54 rc69209d 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 /** @addtogroup drvusbuhci28 /** @addtogroup usb 29 29 * @{ 30 30 */ … … 42 42 #include "uhci_hc.h" 43 43 44 /** Root hub initialization 45 * @param[in] instance RH structure to initialize 46 * @param[in] fun DDF function representing UHCI root hub 47 * @param[in] reg_addr Address of root hub status and control registers. 48 * @param[in] reg_size Size of accessible address space. 49 * @return Error code. 50 */ 44 /*----------------------------------------------------------------------------*/ 51 45 int uhci_rh_init( 52 46 uhci_rh_t *instance, ddf_fun_t *fun, uintptr_t reg_addr, size_t reg_size) … … 74 68 instance->io_regs.type = IO_RANGE; 75 69 instance->io_regs.res.io_range.address = reg_addr; 70 // ((uintptr_t)hc->registers) + 0x10; // see UHCI design guide 76 71 instance->io_regs.res.io_range.size = reg_size; 77 72 instance->io_regs.res.io_range.endianness = LITTLE_ENDIAN; -
uspace/drv/uhci-hcd/uhci_struct/link_pointer.h
r15d3b54 rc69209d 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 /** @addtogroup drvusbuhcihc28 /** @addtogroup usb 29 29 * @{ 30 30 */ -
uspace/drv/uhci-hcd/uhci_struct/queue_head.h
r15d3b54 rc69209d 1 1 2 /* 2 3 * Copyright (c) 2010 Jan Vesely … … 26 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 28 */ 28 /** @addtogroup drv usbuhcihc29 /** @addtogroup usb 29 30 * @{ 30 31 */ … … 46 47 } __attribute__((packed)) qh_t; 47 48 /*----------------------------------------------------------------------------*/ 48 /** Initialize queue head structure49 *50 * @param[in] instance qh_t structure to initialize.51 *52 * Sets both pointer to terminal NULL.53 */54 49 static inline void qh_init(qh_t *instance) 55 50 { … … 60 55 } 61 56 /*----------------------------------------------------------------------------*/ 62 /** Set queue head next pointer63 *64 * @param[in] instance qh_t structure to use.65 * @param[in] pa Physical address of the next queue head.66 *67 * Adds proper flag. If the pointer is NULL or terminal, sets next to terminal68 * NULL.69 */70 57 static inline void qh_set_next_qh(qh_t *instance, uint32_t pa) 71 58 { 72 /* Address is valid and not terminal */59 /* address is valid and not terminal */ 73 60 if (pa && ((pa & LINK_POINTER_TERMINATE_FLAG) == 0)) { 74 61 instance->next = (pa & LINK_POINTER_ADDRESS_MASK) … … 79 66 } 80 67 /*----------------------------------------------------------------------------*/ 81 /** Set queue head element pointer82 *83 * @param[in] instance qh_t structure to initialize.84 * @param[in] pa Physical address of the next queue head.85 *86 * Adds proper flag. If the pointer is NULL or terminal, sets element87 * to terminal NULL.88 */89 68 static inline void qh_set_element_qh(qh_t *instance, uint32_t pa) 90 69 { 91 /* Address is valid and not terminal */70 /* address is valid and not terminal */ 92 71 if (pa && ((pa & LINK_POINTER_TERMINATE_FLAG) == 0)) { 93 72 instance->element = (pa & LINK_POINTER_ADDRESS_MASK) … … 98 77 } 99 78 /*----------------------------------------------------------------------------*/ 100 /** Set queue head element pointer101 *102 * @param[in] instance qh_t structure to initialize.103 * @param[in] pa Physical address of the TD structure.104 *105 * Adds proper flag. If the pointer is NULL or terminal, sets element106 * to terminal NULL.107 */108 79 static inline void qh_set_element_td(qh_t *instance, uint32_t pa) 109 80 { -
uspace/drv/uhci-hcd/uhci_struct/transfer_descriptor.c
r15d3b54 rc69209d 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 /** @addtogroup drvusbuhcihc28 /** @addtogroup usb 29 29 * @{ 30 30 */ … … 38 38 #include "utils/malloc32.h" 39 39 40 /** Initialize Transfer Descriptor40 /** Initializes Transfer Descriptor 41 41 * 42 42 * @param[in] instance Memory place to initialize. … … 106 106 } 107 107 /*----------------------------------------------------------------------------*/ 108 /** Convert TD status into standard error code108 /** Converts TD status into standard error code 109 109 * 110 110 * @param[in] instance TD structure to use. -
uspace/drv/uhci-hcd/uhci_struct/transfer_descriptor.h
r15d3b54 rc69209d 1 1 /* 2 * Copyright (c) 201 1Jan Vesely2 * Copyright (c) 2010 Jan Vesely 3 3 * All rights reserved. 4 4 * … … 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 /** @addtogroup drvusbuhcihc28 /** @addtogroup usb 29 29 * @{ 30 30 */ … … 108 108 } 109 109 /*----------------------------------------------------------------------------*/ 110 /** Check whether less than max data were recieved and packet is marked as SPD.110 /** Checks whether less than max data were recieved and packet is marked as SPD. 111 111 * 112 112 * @param[in] instance TD structure to use. -
uspace/drv/uhci-hcd/utils/device_keeper.c
r15d3b54 rc69209d 27 27 */ 28 28 29 /** @addtogroup drvusbuhci hc29 /** @addtogroup drvusbuhci 30 30 * @{ 31 31 */ … … 40 40 41 41 /*----------------------------------------------------------------------------*/ 42 /** Initialize device keeper structure.42 /** Initializes device keeper structure. 43 43 * 44 44 * @param[in] instance Memory place to initialize. 45 *46 * Set all values to false/0.47 45 */ 48 46 void device_keeper_init(device_keeper_t *instance) … … 60 58 } 61 59 /*----------------------------------------------------------------------------*/ 62 /** Attempt to obtain address 0, blocks.60 /** Attempts to obtain address 0, blocks. 63 61 * 64 62 * @param[in] instance Device keeper structure to use. … … 78 76 } 79 77 /*----------------------------------------------------------------------------*/ 80 /** Attempt to obtain address 0, blocks.78 /** Attempts to obtain address 0, blocks. 81 79 * 82 80 * @param[in] instance Device keeper structure to use. … … 92 90 } 93 91 /*----------------------------------------------------------------------------*/ 94 /** Check setup packetdata for signs of toggle reset.92 /** Checks setup data for signs of toggle reset. 95 93 * 96 94 * @param[in] instance Device keeper structure to use. 97 95 * @param[in] target Device to receive setup packet. 98 96 * @param[in] data Setup packet data. 99 *100 * Really ugly one.101 97 */ 102 98 void device_keeper_reset_if_need( … … 109 105 || !instance->devices[target.address].occupied) { 110 106 fibril_mutex_unlock(&instance->guard); 111 usb_log_error("Invalid data when checking for toggle reset.\n");112 107 return; 113 108 } … … 135 130 } 136 131 /*----------------------------------------------------------------------------*/ 137 /** Get current value of endpoint toggle.132 /** Gets current value of endpoint toggle. 138 133 * 139 134 * @param[in] instance Device keeper structure to use. … … 149 144 || target.address >= USB_ADDRESS_COUNT || target.address < 0 150 145 || !instance->devices[target.address].occupied) { 151 usb_log_error("Invalid data when asking for toggle value.\n");152 146 ret = EINVAL; 153 147 } else { 154 ret = (instance->devices[target.address].toggle_status 148 ret = 149 (instance->devices[target.address].toggle_status 155 150 >> target.endpoint) & 1; 156 151 } … … 159 154 } 160 155 /*----------------------------------------------------------------------------*/ 161 /** Set current value of endpoint toggle.156 /** Sets current value of endpoint toggle. 162 157 * 163 158 * @param[in] instance Device keeper structure to use. 164 159 * @param[in] target Device and endpoint used. 165 * @param[in] toggle Toggle value.160 * @param[in] toggle Current toggle value. 166 161 * @return Error code. 167 162 */ … … 175 170 || target.address >= USB_ADDRESS_COUNT || target.address < 0 176 171 || !instance->devices[target.address].occupied) { 177 usb_log_error("Invalid data when setting toggle value.\n");178 172 ret = EINVAL; 179 173 } else { … … 189 183 } 190 184 /*----------------------------------------------------------------------------*/ 191 /** Get a free USB address185 /** Gets a free USB address 192 186 * 193 187 * @param[in] instance Device keeper structure to use. … … 222 216 } 223 217 /*----------------------------------------------------------------------------*/ 224 /** Bind USB address to devman handle.218 /** Binds USB address to devman handle. 225 219 * 226 220 * @param[in] instance Device keeper structure to use. … … 240 234 } 241 235 /*----------------------------------------------------------------------------*/ 242 /** Release used USB address.236 /** Releases used USB address. 243 237 * 244 238 * @param[in] instance Device keeper structure to use. … … 257 251 } 258 252 /*----------------------------------------------------------------------------*/ 259 /** Find USB address associated with the device253 /** Finds USB address associated with the device 260 254 * 261 255 * @param[in] instance Device keeper structure to use. … … 280 274 } 281 275 /*----------------------------------------------------------------------------*/ 282 /** Get speed associated with the address276 /** Gets speed associated with the address 283 277 * 284 278 * @param[in] instance Device keeper structure to use. -
uspace/drv/uhci-hcd/utils/device_keeper.h
r15d3b54 rc69209d 27 27 */ 28 28 29 /** @addtogroup drvusbuhci hc29 /** @addtogroup drvusbuhci 30 30 * @{ 31 31 */ -
uspace/drv/uhci-hcd/utils/malloc32.h
r15d3b54 rc69209d 43 43 #define UHCI_REQUIRED_PAGE_SIZE 4096 44 44 45 /** Get physical address translation46 *47 * @param[in] addr Virtual address to translate48 * @return Physical address if exists, NULL otherwise.49 */50 45 static inline uintptr_t addr_to_phys(void *addr) 51 46 { … … 53 48 int ret = as_get_physical_mapping(addr, &result); 54 49 55 if (ret != EOK) 56 return 0; 50 assert(ret == 0); 57 51 return (result | ((uintptr_t)addr & 0xfff)); 58 52 } 59 /*----------------------------------------------------------------------------*/ 60 /** Physical mallocator simulator 61 * 62 * @param[in] size Size of the required memory space 63 * @return Address of the alligned and big enough memory place, NULL on failure. 64 */ 53 65 54 static inline void * malloc32(size_t size) 66 55 { return memalign(UHCI_STRCUTURES_ALIGNMENT, size); } 67 /*----------------------------------------------------------------------------*/ 68 /** Physical mallocator simulator 69 * 70 * @param[in] addr Address of the place allocated by malloc32 71 */ 72 static inline void free32(void *addr) 73 { if (addr) free(addr); } 74 /*----------------------------------------------------------------------------*/ 75 /** Create 4KB page mapping 76 * 77 * @return Address of the mapped page, NULL on failure. 78 */ 79 static inline void * get_page(void) 56 57 static inline void * get_page() 80 58 { 81 59 void * free_address = as_get_mappable_page(UHCI_REQUIRED_PAGE_SIZE); 82 60 assert(free_address); 83 61 if (free_address == 0) 84 return NULL;62 return 0; 85 63 void* ret = 86 64 as_area_create(free_address, UHCI_REQUIRED_PAGE_SIZE, 87 65 AS_AREA_READ | AS_AREA_WRITE); 88 66 if (ret != free_address) 89 return NULL;67 return 0; 90 68 return ret; 91 69 } 70 71 static inline void free32(void *addr) 72 { if (addr) free(addr); } 92 73 93 74 #endif -
uspace/drv/uhci-rhd/main.c
r15d3b54 rc69209d 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 /** @addtogroup drvusbuhcirh28 /** @addtogroup usb 29 29 * @{ 30 30 */ 31 31 /** @file 32 * @brief UHCI root hub initialization routines32 * @brief UHCI driver 33 33 */ 34 34 #include <ddf/driver.h> … … 40 40 #include <usb/debug.h> 41 41 42 43 42 44 #include "root_hub.h" 43 45 … … 45 47 static int hc_get_my_registers(ddf_dev_t *dev, 46 48 uintptr_t *io_reg_address, size_t *io_reg_size); 47 #if 048 49 /*----------------------------------------------------------------------------*/ 49 50 static int usb_iface_get_hc_handle(ddf_fun_t *fun, devman_handle_t *handle) … … 66 67 .interfaces[USB_DEV_IFACE] = &uhci_rh_usb_iface, 67 68 }; 68 #endif69 69 /*----------------------------------------------------------------------------*/ 70 /** Initialize a new ddf driver instance of UHCI root hub.70 /** Initializes a new ddf driver instance of UHCI root hub. 71 71 * 72 72 * @param[in] device DDF instance of the device to initialize. … … 81 81 82 82 //device->ops = &uhci_rh_ops; 83 (void) uhci_rh_ops; 84 85 uhci_root_hub_t *rh = malloc(sizeof(uhci_root_hub_t)); 86 if (!rh) { 87 usb_log_error("Failed to allocate memory for driver instance.\n"); 88 return ENOMEM; 89 } 90 83 91 uintptr_t io_regs = 0; 84 92 size_t io_size = 0; 85 93 86 94 int ret = hc_get_my_registers(device, &io_regs, &io_size); 87 if (ret != EOK) { 88 usb_log_error("Failed(%d) to get registers from parent hc.", 89 ret); 90 } 91 usb_log_info("I/O regs at %#X (size %zu).\n", io_regs, io_size); 95 assert(ret == EOK); 92 96 93 uhci_root_hub_t *rh = malloc(sizeof(uhci_root_hub_t)); 94 if (!rh) { 95 usb_log_error("Failed to allocate driver instance.\n"); 96 return ENOMEM; 97 } 98 97 /* TODO: verify values from hc */ 98 usb_log_info("I/O regs at 0x%X (size %zu).\n", io_regs, io_size); 99 99 ret = uhci_root_hub_init(rh, (void*)io_regs, io_size, device); 100 100 if (ret != EOK) { … … 119 119 }; 120 120 /*----------------------------------------------------------------------------*/ 121 /** Initialize global driver structures (NONE).121 /** Initializes global driver structures (NONE). 122 122 * 123 123 * @param[in] argc Nmber of arguments in argv vector (ignored). -
uspace/drv/uhci-rhd/port.c
r15d3b54 rc69209d 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 /** @addtogroup drvusbuhcirh28 /** @addtogroup usb 29 29 * @{ 30 30 */ 31 31 /** @file 32 * @brief UHCI root hub port routines 33 */ 34 #include <libarch/ddi.h> /* pio_read and pio_write */ 32 * @brief UHCI driver 33 */ 35 34 #include <errno.h> 36 35 #include <str_error.h> … … 38 37 39 38 #include <usb/usb.h> /* usb_address_t */ 39 #include <usb/usbdevice.h> 40 40 #include <usb/hub.h> 41 #include <usb/request.h> 41 42 #include <usb/debug.h> 43 #include <usb/recognise.h> 42 44 43 45 #include "port.h" … … 48 50 static int uhci_port_check(void *port); 49 51 static int uhci_port_reset_enable(int portno, void *arg); 50 static void uhci_port_print_status( 51 uhci_port_t *port, const port_status_t value); 52 53 /** Register reading helper function. 54 * 55 * @param[in] port Structure to use. 56 * @return Error code. (Always EOK) 57 */ 58 static inline port_status_t uhci_port_read_status(uhci_port_t *port) 59 { 60 assert(port); 61 return pio_read_16(port->address); 62 } 63 /*----------------------------------------------------------------------------*/ 64 /** Register writing helper function. 65 * 66 * @param[in] port Structure to use. 67 * @param[in] value New register value. 68 * @return Error code. (Always EOK) 69 */ 70 static inline void uhci_port_write_status( 71 uhci_port_t *port, port_status_t value) 72 { 73 assert(port); 74 pio_write_16(port->address, value); 75 } 76 77 /*----------------------------------------------------------------------------*/ 78 /** Initialize UHCI root hub port instance. 52 /*----------------------------------------------------------------------------*/ 53 /** Initializes UHCI root hub port instance. 79 54 * 80 55 * @param[in] port Memory structure to use. … … 85 60 * @return Error code. 86 61 * 87 * Creates and starts the polling fibril.62 * Starts the polling fibril. 88 63 */ 89 64 int uhci_port_init(uhci_port_t *port, … … 111 86 port->checker = fibril_create(uhci_port_check, port); 112 87 if (port->checker == 0) { 113 usb_log_error(" %s: failed to create pollingfibril.",114 port-> id_string);88 usb_log_error("Port(%p - %d): failed to launch root hub fibril.", 89 port->address, port->number); 115 90 return ENOMEM; 116 91 } 117 92 118 93 fibril_add_ready(port->checker); 119 usb_log_debug(" %s: Started polling fibril(%x).\n",120 port-> id_string, port->checker);121 return EOK; 122 } 123 /*----------------------------------------------------------------------------*/ 124 /** CleanupUHCI root hub port instance.94 usb_log_debug("Port(%p - %d): Added fibril. %x\n", 95 port->address, port->number, port->checker); 96 return EOK; 97 } 98 /*----------------------------------------------------------------------------*/ 99 /** Finishes UHCI root hub port instance. 125 100 * 126 101 * @param[in] port Memory structure to use. … … 130 105 void uhci_port_fini(uhci_port_t *port) 131 106 { 132 assert(port);133 free(port->id_string);134 107 /* TODO: Kill fibril here */ 135 108 return; … … 138 111 /** Periodically checks port status and reports new devices. 139 112 * 140 * @param[in] port Portstructure to use.113 * @param[in] port Memory structure to use. 141 114 * @return Error code. 142 115 */ … … 149 122 async_usleep(instance->wait_period_usec); 150 123 151 /* Read register value */124 /* read register value */ 152 125 port_status_t port_status = uhci_port_read_status(instance); 153 126 154 /* Print the value if it's interesting */127 /* print the value if it's interesting */ 155 128 if (port_status & ~STATUS_ALWAYS_ONE) 156 129 uhci_port_print_status(instance, port_status); … … 204 177 * @param arg Pointer to uhci_port_t of port with the new device. 205 178 * @return Error code. 206 *207 * Resets and enables the ub port.208 179 */ 209 180 int uhci_port_reset_enable(int portno, void *arg) … … 243 214 } 244 215 /*----------------------------------------------------------------------------*/ 245 /** Initialize and reportconnected device.246 * 247 * @param[in] port Portstructure to use.216 /** Initializes and reports connected device. 217 * 218 * @param[in] port Memory structure to use. 248 219 * @param[in] speed Detected speed. 249 220 * @return Error code. … … 276 247 } 277 248 /*----------------------------------------------------------------------------*/ 278 /** Remove device. 279 * 280 * @param[in] port Memory structure to use. 281 * @return Error code. 282 * 283 * Does not work, DDF does not support device removal. 284 * Does not even free used USB address (it would be dangerous if tis driver 285 * is still running). 249 /** Removes device. 250 * 251 * @param[in] port Memory structure to use. 252 * @return Error code. 253 * 254 * Does not work DDF does not support device removal. 286 255 */ 287 256 int uhci_port_remove_device(uhci_port_t *port) … … 292 261 } 293 262 /*----------------------------------------------------------------------------*/ 294 /** Enable or disable root hub port. 295 * 296 * @param[in] port Port structure to use. 297 * @param[in] enabled Port status to set. 263 /** Enables and disables port. 264 * 265 * @param[in] port Memory structure to use. 298 266 * @return Error code. (Always EOK) 299 267 */ … … 320 288 } 321 289 /*----------------------------------------------------------------------------*/ 322 /** Print the port status value in a human friendly way323 *324 * @param[in] port Port structure to use.325 * @param[in] value Port register value to print.326 * @return Error code. (Always EOK)327 */328 void uhci_port_print_status(uhci_port_t *port, const port_status_t value)329 {330 assert(port);331 usb_log_debug2("%s Port status(%#x):%s%s%s%s%s%s%s%s%s%s%s.\n",332 port->id_string, value,333 (value & STATUS_SUSPEND) ? " SUSPENDED," : "",334 (value & STATUS_RESUME) ? " IN RESUME," : "",335 (value & STATUS_IN_RESET) ? " IN RESET," : "",336 (value & STATUS_LINE_D_MINUS) ? " VD-," : "",337 (value & STATUS_LINE_D_PLUS) ? " VD+," : "",338 (value & STATUS_LOW_SPEED) ? " LOWSPEED," : "",339 (value & STATUS_ENABLED_CHANGED) ? " ENABLED-CHANGE," : "",340 (value & STATUS_ENABLED) ? " ENABLED," : "",341 (value & STATUS_CONNECTED_CHANGED) ? " CONNECTED-CHANGE," : "",342 (value & STATUS_CONNECTED) ? " CONNECTED," : "",343 (value & STATUS_ALWAYS_ONE) ? " ALWAYS ONE" : " ERROR: NO ALWAYS ONE"344 );345 }346 290 /** 347 291 * @} -
uspace/drv/uhci-rhd/port.h
r15d3b54 rc69209d 1 1 /* 2 * Copyright (c) 201 1Jan Vesely2 * Copyright (c) 2010 Jan Vesely 3 3 * All rights reserved. 4 4 * … … 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 /** @addtogroup drvusbuhcirh28 /** @addtogroup usb 29 29 * @{ 30 30 */ 31 31 /** @file 32 * @brief UHCI root hub port routines32 * @brief UHCI port driver 33 33 */ 34 34 #ifndef DRV_UHCI_PORT_H 35 35 #define DRV_UHCI_PORT_H 36 36 37 #include <assert.h> 37 38 #include <stdint.h> 38 #include <fibril.h>39 39 #include <ddf/driver.h> 40 #include <usb/usbdevice.h> /* usb_hc_connection_t */ 40 #include <libarch/ddi.h> /* pio_read and pio_write */ 41 #include <usb/usbdevice.h> 41 42 42 43 typedef uint16_t port_status_t; 44 43 45 #define STATUS_CONNECTED (1 << 0) 44 46 #define STATUS_CONNECTED_CHANGED (1 << 1) … … 72 74 void uhci_port_fini(uhci_port_t *port); 73 75 76 static inline port_status_t uhci_port_read_status(uhci_port_t *port) 77 { 78 assert(port); 79 return pio_read_16(port->address); 80 } 81 82 static inline void uhci_port_write_status( 83 uhci_port_t *port, port_status_t value) 84 { 85 assert(port); 86 pio_write_16(port->address, value); 87 } 88 89 static inline void uhci_port_print_status( 90 uhci_port_t *port, const port_status_t value) 91 { 92 assert(port); 93 usb_log_debug2("%s Port status(%#x):%s%s%s%s%s%s%s%s%s%s%s.\n", 94 port->id_string, value, 95 (value & STATUS_SUSPEND) ? " SUSPENDED," : "", 96 (value & STATUS_RESUME) ? " IN RESUME," : "", 97 (value & STATUS_IN_RESET) ? " IN RESET," : "", 98 (value & STATUS_LINE_D_MINUS) ? " VD-," : "", 99 (value & STATUS_LINE_D_PLUS) ? " VD+," : "", 100 (value & STATUS_LOW_SPEED) ? " LOWSPEED," : "", 101 (value & STATUS_ENABLED_CHANGED) ? " ENABLED-CHANGE," : "", 102 (value & STATUS_ENABLED) ? " ENABLED," : "", 103 (value & STATUS_CONNECTED_CHANGED) ? " CONNECTED-CHANGE," : "", 104 (value & STATUS_CONNECTED) ? " CONNECTED," : "", 105 (value & STATUS_ALWAYS_ONE) ? " ALWAYS ONE" : " ERROR: NO ALWAYS ONE" 106 ); 107 } 74 108 #endif 75 109 /** -
uspace/drv/uhci-rhd/root_hub.c
r15d3b54 rc69209d 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 /** @addtogroup drvusbuhcirh28 /** @addtogroup usb 29 29 * @{ 30 30 */ 31 31 /** @file 32 * @brief UHCI root hubdriver32 * @brief UHCI driver 33 33 */ 34 34 #include <errno.h> 35 #include <stdint.h> 35 36 #include <ddi.h> 37 #include <devman.h> 36 38 #include <usb/debug.h> 37 39 38 40 #include "root_hub.h" 39 41 40 /** Initialize UHCI root hub instance.42 /** Initializes UHCI root hub instance. 41 43 * 42 44 * @param[in] instance Driver memory structure to use. 43 45 * @param[in] addr Address of I/O registers. 44 46 * @param[in] size Size of available I/O space. 45 * @param[in] rh Pointer to ddf instance ofthe root hub driver.47 * @param[in] rh Pointer to ddf instance fo the root hub driver. 46 48 * @return Error code. 47 49 */ … … 59 61 if (ret < 0) { 60 62 usb_log_error( 61 "Failed(%d) to gain access to port registers at %p\n", 62 ret, regs); 63 "Failed to gain access to port registers at %p\n", regs); 63 64 return ret; 64 65 } 65 66 66 /* Initialize root hub ports */67 /* add fibrils for periodic port checks */ 67 68 unsigned i = 0; 68 69 for (; i < UHCI_ROOT_HUB_PORT_COUNT; ++i) { … … 81 82 } 82 83 /*----------------------------------------------------------------------------*/ 83 /** CleanupUHCI root hub instance.84 /** Finishes UHCI root hub instance. 84 85 * 85 * @param[in] instance Root hubstructure to use.86 * @param[in] instance Driver memory structure to use. 86 87 * @return Error code. 87 88 */ -
uspace/drv/uhci-rhd/root_hub.h
r15d3b54 rc69209d 1 1 /* 2 * Copyright (c) 201 1Jan Vesely2 * Copyright (c) 2010 Jan Vesely 3 3 * All rights reserved. 4 4 * … … 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 /** @addtogroup drvusbuhcirh28 /** @addtogroup usb 29 29 * @{ 30 30 */ … … 35 35 #define DRV_UHCI_ROOT_HUB_H 36 36 37 #include <fibril.h> 37 38 #include <ddf/driver.h> 38 39
Note:
See TracChangeset
for help on using the changeset viewer.