Changeset 972e8a9 in mainline
- Timestamp:
- 2014-01-02T20:48:33Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4942d63
- Parents:
- da06e92
- Location:
- uspace/drv/bus/usb/ehci
- Files:
-
- 2 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ehci/Makefile
rda06e92 r972e8a9 45 45 46 46 SOURCES = \ 47 ehci.c \48 47 ehci_rh.c \ 49 48 hc.c \ -
uspace/drv/bus/usb/ehci/main.c
rda06e92 r972e8a9 44 44 45 45 #include "res.h" 46 #include " ehci.h"46 #include "hc.h" 47 47 48 48 #define NAME "ehci" 49 // TODO: This should be merged to hc_interrupt 50 static void ehci_interrupt(hcd_t *hcd, uint32_t status) 51 { 52 assert(hcd); 53 if (hcd->driver.data) 54 hc_interrupt(hcd->driver.data, status); 55 } 56 57 static int ehci_driver_init(hcd_t *hcd, const hw_res_list_parsed_t *res, bool irq) 58 { 59 assert(hcd); 60 assert(hcd->driver.data == NULL); 61 62 hc_t *instance = malloc(sizeof(hc_t)); 63 if (!instance) 64 return ENOMEM; 65 66 const int ret = hc_init(instance, res, irq); 67 if (ret == EOK) 68 hcd_set_implementation(hcd, instance, hc_schedule, 69 NULL, NULL, ehci_interrupt); 70 return ret; 71 } 72 73 static void ehci_driver_fini(hcd_t *hcd) 74 { 75 assert(hcd); 76 if (hcd->driver.data) 77 hc_fini(hcd->driver.data); 78 79 free(hcd->driver.data); 80 hcd_set_implementation(hcd, NULL, NULL, NULL, NULL, NULL); 81 } 49 82 50 83 static int ehci_dev_add(ddf_dev_t *device); … … 67 100 static int ehci_dev_add(ddf_dev_t *device) 68 101 { 102 usb_log_debug("ehci_dev_add() called\n"); 69 103 assert(device); 70 hw_res_list_parsed_t hw_res; 71 int ret = hcd_ddf_get_registers(device, &hw_res); 72 if (ret != EOK || 73 hw_res.irqs.count != 1 || hw_res.mem_ranges.count != 1) { 74 usb_log_error("Failed to get register memory addresses " 75 "for %" PRIun ": %s.\n", ddf_dev_get_handle(device), 104 105 const int ret = ddf_hcd_device_setup_all(device, USB_SPEED_HIGH, 106 BANDWIDTH_AVAILABLE_USB20, bandwidth_count_usb11, 107 ddf_hcd_gen_irq_handler, hc_gen_irq_code, 108 ehci_driver_init, ehci_driver_fini); 109 if (ret != EOK) { 110 usb_log_error("Failed to initialize EHCI driver: %s.\n", 76 111 str_error(ret)); 77 return ret;78 112 } 79 addr_range_t regs = hw_res.mem_ranges.ranges[0]; 80 const int irq = hw_res.irqs.irqs[0]; 81 hw_res_list_parsed_clean(&hw_res); 82 83 usb_log_info("Memory mapped regs at %p (size %zu), IRQ %d.\n", 84 RNGABSPTR(regs), RNGSZ(regs), irq); 85 86 ret = disable_legacy(device, ®s); 87 if (ret != EOK) { 88 usb_log_error("Failed to disable legacy USB: %s.\n", 89 str_error(ret)); 90 return ret; 91 } 92 93 /* High Speed, no bandwidth */ 94 ret = device_setup_ehci(device); 95 if (ret != EOK) { 96 usb_log_error("Failed to init ehci driver: %s\n", 97 str_error(ret)); 98 return ret; 99 } 100 101 usb_log_info("Controlling new EHCI device `%s' (handle %" PRIun ").\n", 102 ddf_dev_get_name(device), ddf_dev_get_handle(device)); 113 usb_log_info("Controlling new EHCI device '%s'.\n", 114 ddf_dev_get_name(device)); 103 115 104 116 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.