Changeset e4d7363 in mainline for uspace/drv/bus/usb/ehci
- Timestamp:
- 2017-06-22T21:34:39Z (9 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 91ca111
- Parents:
- cb89430
- Location:
- uspace/drv/bus/usb/ehci
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ehci/hc.c
rcb89430 re4d7363 89 89 }; 90 90 91 static void hc_start(hc_t *instance);92 91 static int hc_init_memory(hc_t *instance); 93 92 … … 98 97 * @return Error code. 99 98 */ 100 int ehci_hc_gen_irq_code(irq_code_t *code, const hw_res_list_parsed_t *hw_res)99 int ehci_hc_gen_irq_code(irq_code_t *code, hcd_t *hcd, const hw_res_list_parsed_t *hw_res) 101 100 { 102 101 assert(code); 103 102 assert(hw_res); 103 104 hc_t *instance = hcd_get_driver_data(hcd); 104 105 105 106 if (hw_res->irqs.count != 1 || hw_res->mem_ranges.count != 1) … … 128 129 129 130 memcpy(code->cmds, ehci_irq_commands, sizeof(ehci_irq_commands)); 130 ehci_caps_regs_t *caps = NULL; 131 132 int ret = pio_enable_range(®s, (void**)&caps); 133 if (ret != EOK) { 134 free(code->ranges); 135 free(code->cmds); 136 return ret; 137 } 138 139 ehci_regs_t *registers = 140 (ehci_regs_t *)(RNGABSPTR(regs) + EHCI_RD8(caps->caplength)); 141 code->cmds[0].addr = (void *) ®isters->usbsts; 142 code->cmds[3].addr = (void *) ®isters->usbsts; 131 132 code->cmds[0].addr = (void *) &instance->registers->usbsts; 133 code->cmds[3].addr = (void *) &instance->registers->usbsts; 143 134 EHCI_WR(code->cmds[1].value, EHCI_USED_INTERRUPTS); 144 135 … … 156 147 * @return Error code 157 148 */ 158 int hc_init(hc_t *instance, const hw_res_list_parsed_t *hw_res , bool interrupts)149 int hc_init(hc_t *instance, const hw_res_list_parsed_t *hw_res) 159 150 { 160 151 assert(instance); … … 172 163 return ret; 173 164 } 165 174 166 usb_log_info("HC(%p): Device registers at %"PRIx64" (%zuB) accessible.", 175 167 instance, hw_res->mem_ranges.ranges[0].address.absolute, … … 195 187 ehci_rh_init( 196 188 &instance->rh, instance->caps, instance->registers, "ehci rh"); 197 usb_log_debug("HC(%p): Starting HW.", instance);198 hc_start(instance);199 189 200 190 return EOK; … … 368 358 * @param[in] instance EHCI hc driver structure. 369 359 */ 370 void hc_start(hc_t *instance) 371 { 372 assert(instance); 360 int hc_start(hc_t *instance, bool interrupts) 361 { 362 assert(instance); 363 usb_log_debug("HC(%p): Starting HW.", instance); 364 373 365 /* Turn off the HC if it's running, Reseting a running device is 374 366 * undefined */ … … 435 427 EHCI_WR(instance->registers->usbsts, EHCI_RD(instance->registers->usbsts)); 436 428 EHCI_WR(instance->registers->usbintr, EHCI_USED_INTERRUPTS); 429 430 return EOK; 437 431 } 438 432 -
uspace/drv/bus/usb/ehci/hc.h
rcb89430 re4d7363 82 82 } hc_t; 83 83 84 int hc_init(hc_t *instance, const hw_res_list_parsed_t *hw_res, bool interrupts); 84 int hc_init(hc_t *instance, const hw_res_list_parsed_t *hw_res); 85 int hc_start(hc_t *instance, bool interrupts); 85 86 void hc_fini(hc_t *instance); 86 87 … … 88 89 void hc_dequeue_endpoint(hc_t *instance, const endpoint_t *ep); 89 90 90 int ehci_hc_gen_irq_code(irq_code_t *code, const hw_res_list_parsed_t *hw_res);91 int ehci_hc_gen_irq_code(irq_code_t *code, hcd_t *hcd, const hw_res_list_parsed_t *hw_res); 91 92 92 93 void ehci_hc_interrupt(hcd_t *hcd, uint32_t status); -
uspace/drv/bus/usb/ehci/main.c
rcb89430 re4d7363 52 52 #define NAME "ehci" 53 53 54 static int ehci_driver_init(hcd_t *, const hw_res_list_parsed_t *, bool); 54 static int ehci_driver_init(hcd_t *, const hw_res_list_parsed_t *); 55 static int ehci_driver_claim(hcd_t *, ddf_dev_t *); 56 static int ehci_driver_start(hcd_t *, bool); 55 57 static void ehci_driver_fini(hcd_t *); 56 58 57 59 static const ddf_hc_driver_t ehci_hc_driver = { 58 .claim = disable_legacy,59 60 .hc_speed = USB_SPEED_HIGH, 61 .name = "EHCI-PCI", 62 .init = ehci_driver_init, 60 63 .irq_code_gen = ehci_hc_gen_irq_code, 61 .init = ehci_driver_init, 64 .claim = ehci_driver_claim, 65 .start = ehci_driver_start, 62 66 .fini = ehci_driver_fini, 63 .name = "EHCI-PCI",64 67 .ops = { 65 68 .schedule = ehci_hc_schedule, … … 72 75 73 76 74 static int ehci_driver_init(hcd_t *hcd, const hw_res_list_parsed_t *res, 75 bool irq) 77 static int ehci_driver_init(hcd_t *hcd, const hw_res_list_parsed_t *res) 76 78 { 77 79 assert(hcd); … … 82 84 return ENOMEM; 83 85 84 const int ret = hc_init(instance, res , irq);86 const int ret = hc_init(instance, res); 85 87 if (ret == EOK) { 86 88 hcd_set_implementation(hcd, instance, &ehci_hc_driver.ops); … … 89 91 } 90 92 return ret; 93 } 94 95 static int ehci_driver_claim(hcd_t *hcd, ddf_dev_t *dev) 96 { 97 hc_t *instance = hcd_get_driver_data(hcd); 98 assert(instance); 99 100 return disable_legacy(instance, dev); 101 } 102 103 static int ehci_driver_start(hcd_t *hcd, bool irq) { 104 hc_t *instance = hcd_get_driver_data(hcd); 105 assert(instance); 106 107 return hc_start(instance, irq); 91 108 } 92 109 -
uspace/drv/bus/usb/ehci/res.c
rcb89430 re4d7363 172 172 } 173 173 174 int disable_legacy( ddf_dev_t *device)174 int disable_legacy(hc_t *hc, ddf_dev_t *device) 175 175 { 176 176 assert(device); … … 183 183 usb_log_debug("Disabling EHCI legacy support.\n"); 184 184 185 hw_res_list_parsed_t res; 186 hw_res_list_parsed_init(&res); 187 int ret = hw_res_get_list_parsed(parent_sess, &res, 0); 188 if (ret != EOK) { 189 usb_log_error("Failed to get resource list: %s\n", 190 str_error(ret)); 191 goto clean; 192 } 193 194 if (res.mem_ranges.count < 1) { 195 usb_log_error("Incorrect mem range count: %zu", 196 res.mem_ranges.count); 197 ret = EINVAL; 198 goto clean; 199 } 200 201 /* Map EHCI registers */ 202 void *regs = NULL; 203 ret = pio_enable_range(&res.mem_ranges.ranges[0], ®s); 204 if (ret != EOK) { 205 usb_log_error("Failed to map registers %p: %s.\n", 206 RNGABSPTR(res.mem_ranges.ranges[0]), str_error(ret)); 207 goto clean; 208 } 209 210 usb_log_debug("Registers mapped at: %p.\n", regs); 211 212 ehci_caps_regs_t *ehci_caps = regs; 213 214 const uint32_t hcc_params = EHCI_RD(ehci_caps->hccparams); 185 186 const uint32_t hcc_params = EHCI_RD(hc->caps->hccparams); 215 187 usb_log_debug2("Value of hcc params register: %x.\n", hcc_params); 216 188 … … 221 193 usb_log_debug2("Value of EECP: %x.\n", eecp); 222 194 223 ret = disable_extended_caps(parent_sess, eecp);195 int ret = disable_extended_caps(parent_sess, eecp); 224 196 if (ret != EOK) { 225 197 usb_log_error("Failed to disable extended capabilities: %s.\n", … … 228 200 } 229 201 clean: 230 //TODO unmap registers231 hw_res_list_parsed_clean(&res);232 202 async_hangup(parent_sess); 233 203 return ret; -
uspace/drv/bus/usb/ehci/res.h
rcb89430 re4d7363 39 39 #include <device/hw_res_parsed.h> 40 40 41 extern int disable_legacy(ddf_dev_t *); 41 #include "hc.h" 42 43 extern int disable_legacy(hc_t *, ddf_dev_t *); 42 44 43 45 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
