Changeset a720ff6 in mainline for uspace/drv/bus/usb/uhci/root_hub.c
- Timestamp:
- 2012-12-20T15:42:35Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 53332b5b
- Parents:
- d09791e6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/uhci/root_hub.c
rd09791e6 ra720ff6 36 36 #include <str_error.h> 37 37 #include <stdio.h> 38 #include <ops/hw_res.h> 38 39 40 #include <usb_iface.h> 39 41 #include <usb/debug.h> 40 42 41 43 #include "root_hub.h" 44 /** DDF support structure for uhci_rhd driver, provides I/O resources */ 45 typedef struct { 46 /** List of resources available to the root hub. */ 47 hw_resource_list_t resource_list; 48 /** The only resource in the RH resource list */ 49 hw_resource_t io_regs; 42 50 51 devman_handle_t hc_handle; 52 } rh_t; 53 54 /** Gets handle of the respective hc. 55 * 56 * @param[in] fun DDF function of uhci device. 57 * @param[out] handle Host cotnroller handle. 58 * @return Error code. 59 */ 60 static int usb_iface_get_hc_handle(ddf_fun_t *fun, devman_handle_t *handle) 61 { 62 assert(fun); 63 rh_t *rh = ddf_fun_data_get(fun); 64 65 if (handle != NULL) 66 *handle = rh->hc_handle; 67 return EOK; 68 } 69 70 /** USB interface implementation used by RH */ 71 static usb_iface_t usb_iface = { 72 .get_hc_handle = usb_iface_get_hc_handle, 73 }; 74 75 /** Get root hub hw resources (I/O registers). 76 * 77 * @param[in] fun Root hub function. 78 * @return Pointer to the resource list used by the root hub. 79 */ 80 static hw_resource_list_t *get_resource_list(ddf_fun_t *fun) 81 { 82 assert(fun); 83 rh_t *rh = ddf_fun_data_get(fun); 84 assert(rh); 85 return &rh->resource_list; 86 } 87 88 /** Interface to provide the root hub driver with hw info */ 89 static hw_res_ops_t hw_res_iface = { 90 .get_resource_list = get_resource_list, 91 .enable_interrupt = NULL, 92 }; 93 94 /** RH function support for uhci_rhd */ 95 static ddf_dev_ops_t rh_ops = { 96 .interfaces[USB_DEV_IFACE] = &usb_iface, 97 .interfaces[HW_RES_DEV_IFACE] = &hw_res_iface 98 }; 43 99 /** Root hub initialization 44 100 * @param[in] instance RH structure to initialize … … 48 104 * @return Error code. 49 105 */ 50 int rh_init(rh_t *instance, ddf_fun_t *fun, uintptr_t reg_addr, size_t reg_size) 106 int rh_init(ddf_dev_t *device, uintptr_t reg_addr, size_t reg_size, 107 devman_handle_t handle) 51 108 { 52 assert(instance); 53 assert(fun); 109 assert(device); 110 111 ddf_fun_t *fun = ddf_fun_create(device, fun_inner, "uhci_rh"); 112 if (!fun) { 113 usb_log_error("Failed to create UHCI RH function.\n"); 114 return ENOMEM; 115 } 116 ddf_fun_set_ops(fun, &rh_ops); 117 118 rh_t *instance = ddf_fun_data_alloc(fun, sizeof(rh_t)); 54 119 55 120 /* Initialize resource structure */ … … 62 127 instance->io_regs.res.io_range.endianness = LITTLE_ENDIAN; 63 128 64 const int ret = ddf_fun_add_match_id(fun, "usb&uhci&root-hub", 100); 129 instance->hc_handle = handle; 130 131 int ret = ddf_fun_add_match_id(fun, "usb&uhci&root-hub", 100); 65 132 if (ret != EOK) { 66 133 usb_log_error("Failed to add root hub match id: %s\n", 67 134 str_error(ret)); 135 ddf_fun_destroy(fun); 68 136 } 137 138 ret = ddf_fun_bind(fun); 139 if (ret != EOK) { 140 usb_log_error("Failed to bind root function: %s\n", 141 str_error(ret)); 142 ddf_fun_destroy(fun); 143 } 144 145 usb_log_fatal("RH ready, hc handle: %"PRIun"\n", handle); 69 146 return ret; 70 147 }
Note:
See TracChangeset
for help on using the changeset viewer.