Changeset 7813516 in mainline
- Timestamp:
- 2014-01-01T01:19:10Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7191992
- Parents:
- d1df381
- Location:
- uspace/drv/bus/usb
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ehci/ehci.c
rd1df381 r7813516 94 94 return ret; 95 95 } 96 addr_range_t regs = hw_res.mem_ranges.ranges[0];97 96 98 97 /* Initialize generic HCD driver */ … … 127 126 128 127 /* Initialize EHCI HC */ 129 ret = hc_init(hc, & regs, interrupts);128 ret = hc_init(hc, &hw_res, interrupts); 130 129 hw_res_list_parsed_clean(&hw_res); 131 130 if (ret != EOK) { -
uspace/drv/bus/usb/ehci/hc.c
rd1df381 r7813516 157 157 * @return Error code 158 158 */ 159 int hc_init(hc_t *instance, addr_range_t *regs, bool interrupts) 160 { 161 assert(instance); 162 163 int ret = pio_enable_range(regs, (void **) &instance->caps); 159 int hc_init(hc_t *instance, const hw_res_list_parsed_t *hw_res, bool interrupts) 160 { 161 assert(instance); 162 assert(hw_res); 163 if (hw_res->mem_ranges.count != 1 || 164 hw_res->mem_ranges.ranges[0].size < 165 (sizeof(ehci_caps_regs_t) + sizeof(ehci_regs_t))) 166 return EINVAL; 167 168 int ret = pio_enable_range(&hw_res->mem_ranges.ranges[0], 169 (void **)&instance->caps); 164 170 if (ret != EOK) { 165 171 usb_log_error("Failed to gain access to device registers: %s.\n", … … 167 173 return ret; 168 174 } 175 usb_log_debug("Device registers at %" PRIx64 " (%zuB) accessible.\n", 176 hw_res->mem_ranges.ranges[0].address.absolute, 177 hw_res->mem_ranges.ranges[0].size); 169 178 instance->registers = 170 179 (void*)instance->caps + EHCI_RD8(instance->caps->caplength); … … 194 203 return EOK; 195 204 } 205 206 /** Safely dispose host controller internal structures 207 * 208 * @param[in] instance Host controller structure to use. 209 */ 210 void hc_fini(hc_t *instance) 211 { 212 assert(instance); 213 /* TODO: implement*/ 214 }; 196 215 197 216 void hc_enqueue_endpoint(hc_t *instance, const endpoint_t *ep) -
uspace/drv/bus/usb/ehci/hc.h
rd1df381 r7813516 76 76 int hc_gen_irq_code(irq_code_t *code, const hw_res_list_parsed_t *hw_res); 77 77 int hc_register_hub(hc_t *instance, ddf_fun_t *hub_fun); 78 int hc_init(hc_t *instance, addr_range_t *regs, bool interrupts); 79 80 /** Safely dispose host controller internal structures 81 * 82 * @param[in] instance Host controller structure to use. 83 */ 84 static inline void hc_fini(hc_t *instance) { /* TODO: implement*/ }; 78 int hc_init(hc_t *instance, const hw_res_list_parsed_t *hw_res, bool interrupts); 79 void hc_fini(hc_t *instance); 85 80 86 81 void hc_enqueue_endpoint(hc_t *instance, const endpoint_t *ep); -
uspace/drv/bus/usb/ohci/hc.c
rd1df381 r7813516 148 148 * 149 149 * @param[in] instance Memory place for the structure. 150 * @param[in] regs Device's I/O registers range.150 * @param[in] regs Device's resources 151 151 * @param[in] interrupts True if w interrupts should be used 152 152 * @return Error code 153 153 */ 154 int hc_init(hc_t *instance, addr_range_t *regs, bool interrupts) 155 { 156 assert(instance); 157 158 int ret = pio_enable_range(regs, (void **) &instance->registers); 154 int hc_init(hc_t *instance, const hw_res_list_parsed_t *hw_res, bool interrupts) 155 { 156 assert(instance); 157 assert(hw_res); 158 if (hw_res->mem_ranges.count != 1 || 159 hw_res->mem_ranges.ranges[0].size < sizeof(ohci_regs_t)) 160 return EINVAL; 161 162 int ret = pio_enable_range(&hw_res->mem_ranges.ranges[0], 163 (void **) &instance->registers); 159 164 if (ret != EOK) { 160 usb_log_error("Failed to gain access to deviceregisters: %s.\n",165 usb_log_error("Failed to gain access to registers: %s.\n", 161 166 str_error(ret)); 162 167 return ret; 163 168 } 169 usb_log_debug("Device registers at %" PRIx64 " (%zuB) accessible.\n", 170 hw_res->mem_ranges.ranges[0].address.absolute, 171 hw_res->mem_ranges.ranges[0].size); 164 172 165 173 list_initialize(&instance->pending_batches); … … 186 194 return EOK; 187 195 } 196 197 /** Safely dispose host controller internal structures 198 * 199 * @param[in] instance Host controller structure to use. 200 */ 201 void hc_fini(hc_t *instance) 202 { 203 assert(instance); 204 /* TODO: implement*/ 205 }; 188 206 189 207 void hc_enqueue_endpoint(hc_t *instance, const endpoint_t *ep) -
uspace/drv/bus/usb/ohci/hc.h
rd1df381 r7813516 77 77 int hc_gen_irq_code(irq_code_t *code, const hw_res_list_parsed_t *hw_res); 78 78 int hc_register_hub(hc_t *instance, ddf_fun_t *hub_fun); 79 int hc_init(hc_t *instance, addr_range_t *regs, bool interrupts); 80 81 /** Safely dispose host controller internal structures 82 * 83 * @param[in] instance Host controller structure to use. 84 */ 85 static inline void hc_fini(hc_t *instance) { /* TODO: implement*/ }; 79 int hc_init(hc_t *instance, const hw_res_list_parsed_t *hw_res, bool interrupts); 80 void hc_fini(hc_t *instance); 86 81 87 82 void hc_enqueue_endpoint(hc_t *instance, const endpoint_t *ep); -
uspace/drv/bus/usb/ohci/ohci.c
rd1df381 r7813516 87 87 hw_res_list_parsed_t hw_res; 88 88 int ret = hcd_ddf_get_registers(device, &hw_res); 89 if (ret != EOK || 90 hw_res.irqs.count != 1 || hw_res.mem_ranges.count != 1) { 89 if (ret != EOK) { 91 90 usb_log_error("Failed to get register memory addresses " 92 91 "for %" PRIun ": %s.\n", ddf_dev_get_handle(device), … … 94 93 return ret; 95 94 } 96 addr_range_t regs = hw_res.mem_ranges.ranges[0];97 95 98 96 /* Initialize generic HCD driver */ … … 127 125 128 126 /* Initialize OHCI HC */ 129 ret = hc_init(hc, & regs, interrupts);127 ret = hc_init(hc, &hw_res, interrupts); 130 128 hw_res_list_parsed_clean(&hw_res); 131 129 if (ret != EOK) { -
uspace/drv/bus/usb/uhci/hc.c
rd1df381 r7813516 212 212 * interrupt fibrils. 213 213 */ 214 int hc_init(hc_t *instance, addr_range_t *regs, bool interrupts) 215 { 216 assert(instance); 217 assert(regs); 218 assert(regs->size >= sizeof(uhci_regs_t)); 214 int hc_init(hc_t *instance, const hw_res_list_parsed_t *hw_res, bool interrupts) 215 { 216 assert(instance); 217 assert(hw_res); 218 if (hw_res->io_ranges.count != 1 || 219 hw_res->io_ranges.ranges[0].size < sizeof(uhci_regs_t)) 220 return EINVAL; 219 221 220 222 instance->hw_interrupts = interrupts; … … 222 224 223 225 /* allow access to hc control registers */ 224 uhci_regs_t *io;225 int ret = pio_enable_range(regs, (void **) &io);226 int ret = pio_enable_range(&hw_res->io_ranges.ranges[0], 227 (void **) &instance->registers); 226 228 if (ret != EOK) { 227 usb_log_error("Failed to gain access to registers at %p: %s.\n",228 io,str_error(ret));229 usb_log_error("Failed to gain access to registers: %s.\n", 230 str_error(ret)); 229 231 return ret; 230 232 } 231 instance->registers = io; 232 233 usb_log_debug(234 "Device registers at %p (%zuB) accessible.\n", io, regs->size);233 234 usb_log_debug("Device registers at %" PRIx64 " (%zuB) accessible.\n", 235 hw_res->io_ranges.ranges[0].address.absolute, 236 hw_res->io_ranges.ranges[0].size); 235 237 236 238 ret = hc_init_mem_structures(instance); … … 253 255 254 256 return EOK; 257 } 258 259 /** Safely dispose host controller internal structures 260 * 261 * @param[in] instance Host controller structure to use. 262 */ 263 void hc_fini(hc_t *instance) 264 { 265 assert(instance); 266 //TODO Implement 255 267 } 256 268 -
uspace/drv/bus/usb/uhci/hc.h
rd1df381 r7813516 129 129 int hc_gen_irq_code(irq_code_t *code, const hw_res_list_parsed_t *hw_res); 130 130 void hc_interrupt(hc_t *instance, uint16_t status); 131 int hc_init(hc_t *instance, addr_range_t *regs, bool interupts); 131 int hc_init(hc_t *instance, const hw_res_list_parsed_t *hw_res, bool interupts); 132 void hc_fini(hc_t *instance); 132 133 int hc_schedule(hcd_t *hcd, usb_transfer_batch_t *batch); 133 134 134 /** Safely dispose host controller internal structures135 *136 * @param[in] instance Host controller structure to use.137 */138 static inline void hc_fini(hc_t *instance) {} /* TODO: implement*/139 135 #endif 140 136 -
uspace/drv/bus/usb/uhci/uhci.c
rd1df381 r7813516 89 89 hw_res_list_parsed_t hw_res; 90 90 int ret = hcd_ddf_get_registers(device, &hw_res); 91 if (ret != EOK || 92 hw_res.irqs.count != 1 || hw_res.io_ranges.count != 1) { 91 if (ret != EOK) { 93 92 usb_log_error("Failed to get register memory addresses " 94 93 "for %" PRIun ": %s.\n", ddf_dev_get_handle(device), … … 96 95 return ret; 97 96 } 98 addr_range_t regs = hw_res.io_ranges.ranges[0];99 97 100 98 ret = hcd_ddf_setup_hc(device, USB_SPEED_FULL, … … 125 123 } 126 124 127 ret = hc_init(hc, & regs, interrupts);125 ret = hc_init(hc, &hw_res, interrupts); 128 126 hw_res_list_parsed_clean(&hw_res); 129 127 if (ret != EOK) { 130 128 usb_log_error("Failed to init uhci_hcd: %s.\n", str_error(ret)); 131 129 goto irq_unregister; 132 // TODO This is unfortunate, we have neither legacy nor real USB133 130 } 134 131
Note:
See TracChangeset
for help on using the changeset viewer.