Changeset 8d40181 in mainline
- Timestamp:
- 2013-09-21T03:25:31Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ea69749f
- Parents:
- c898236
- Location:
- uspace/drv/bus/usb
- Files:
-
- 2 deleted
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ehci/main.c
rc898236 r8d40181 67 67 { 68 68 assert(device); 69 70 addr_range_t reg_range; 71 int irq = 0; 72 73 int ret = get_my_registers(device, ®_range, &irq); 74 if (ret != EOK) { 75 usb_log_error("Failed to get memory addresses for %" PRIun 76 ": %s.\n", ddf_dev_get_handle(device), str_error(ret)); 69 hw_res_list_parsed_t hw_res; 70 int ret = hcd_ddf_get_registers(device, &hw_res); 71 if (ret != EOK || 72 hw_res.irqs.count != 1 || hw_res.mem_ranges.count != 1) { 73 usb_log_error("Failed to get register memory addresses " 74 "for %" PRIun ": %s.\n", ddf_dev_get_handle(device), 75 str_error(ret)); 77 76 return ret; 78 77 } 78 addr_range_t regs = hw_res.mem_ranges.ranges[0]; 79 const int irq = hw_res.irqs.irqs[0]; 80 hw_res_list_parsed_clean(&hw_res); 79 81 80 82 usb_log_info("Memory mapped regs at %p (size %zu), IRQ %d.\n", 81 RNGABSPTR(reg _range), RNGSZ(reg_range), irq);83 RNGABSPTR(regs), RNGSZ(regs), irq); 82 84 83 ret = disable_legacy(device, ® _range);85 ret = disable_legacy(device, ®s); 84 86 if (ret != EOK) { 85 87 usb_log_error("Failed to disable legacy USB: %s.\n", -
uspace/drv/bus/usb/ehci/res.c
rc898236 r8d40181 66 66 #define DEFAULT_WAIT 1000 67 67 #define WAIT_STEP 10 68 69 70 /** Get address of registers and IRQ for given device.71 *72 * @param[in] dev Device asking for the addresses.73 * @param[out] mem_regs_p Pointer to the register range.74 * @param[out] irq_no IRQ assigned to the device.75 * @return Error code.76 */77 int get_my_registers(ddf_dev_t *dev,78 addr_range_t *mem_regs_p, int *irq_no)79 {80 assert(dev);81 82 async_sess_t *parent_sess = devman_parent_device_connect(83 EXCHANGE_SERIALIZE, ddf_dev_get_handle(dev), IPC_FLAG_BLOCKING);84 if (!parent_sess)85 return ENOMEM;86 87 hw_res_list_parsed_t hw_res;88 hw_res_list_parsed_init(&hw_res);89 const int ret = hw_res_get_list_parsed(parent_sess, &hw_res, 0);90 async_hangup(parent_sess);91 if (ret != EOK) {92 return ret;93 }94 95 if (hw_res.irqs.count != 1 || hw_res.mem_ranges.count != 1) {96 hw_res_list_parsed_clean(&hw_res);97 return ENOENT;98 }99 100 if (mem_regs_p)101 *mem_regs_p = hw_res.mem_ranges.ranges[0];102 if (irq_no)103 *irq_no = hw_res.irqs.irqs[0];104 105 hw_res_list_parsed_clean(&hw_res);106 return EOK;107 }108 68 109 69 /** Implements BIOS hands-off routine as described in EHCI spec -
uspace/drv/bus/usb/ehci/res.h
rc898236 r8d40181 39 39 #include <device/hw_res_parsed.h> 40 40 41 int get_my_registers(ddf_dev_t *, addr_range_t *, int *);42 int enable_interrupts(ddf_dev_t *);43 41 int disable_legacy(ddf_dev_t *, addr_range_t *); 44 42 -
uspace/drv/bus/usb/ohci/Makefile
rc898236 r8d40181 52 52 ohci_endpoint.c \ 53 53 ohci_rh.c \ 54 res.c \55 54 hw_struct/endpoint_descriptor.c \ 56 55 hw_struct/transfer_descriptor.c -
uspace/drv/bus/usb/ohci/ohci.c
rc898236 r8d40181 43 43 44 44 #include "ohci.h" 45 #include "res.h"46 45 #include "hc.h" 47 48 46 49 47 … … 80 78 int device_setup_ohci(ddf_dev_t *device) 81 79 { 82 83 addr_range_t regs; 84 int irq = 0; 85 86 int ret = get_my_registers(device, ®s, &irq); 87 if (ret != EOK) { 80 hw_res_list_parsed_t hw_res; 81 int ret = hcd_ddf_get_registers(device, &hw_res); 82 if (ret != EOK || 83 hw_res.irqs.count != 1 || hw_res.mem_ranges.count != 1) { 88 84 usb_log_error("Failed to get register memory addresses " 89 85 "for %" PRIun ": %s.\n", ddf_dev_get_handle(device), … … 91 87 return ret; 92 88 } 89 addr_range_t regs = hw_res.mem_ranges.ranges[0]; 90 const int irq = hw_res.irqs.irqs[0]; 91 hw_res_list_parsed_clean(&hw_res); 92 93 93 94 94 usb_log_debug("Memory mapped regs at %p (size %zu), IRQ %d.\n", -
uspace/drv/bus/usb/uhci/res.c
rc898236 r8d40181 43 43 #include "res.h" 44 44 45 /** Get I/O address of registers and IRQ for given device.46 *47 * @param[in] dev Device asking for the addresses.48 * @param[out] io_regs_p Pointer to register I/O range.49 * @param[out] irq_no IRQ assigned to the device.50 * @return Error code.51 */52 int get_my_registers(ddf_dev_t *dev, addr_range_t *io_regs_p, int *irq_no)53 {54 assert(dev);55 56 async_sess_t *parent_sess =57 devman_parent_device_connect(EXCHANGE_SERIALIZE,58 ddf_dev_get_handle(dev), IPC_FLAG_BLOCKING);59 if (!parent_sess)60 return ENOMEM;61 62 hw_res_list_parsed_t hw_res;63 hw_res_list_parsed_init(&hw_res);64 const int ret = hw_res_get_list_parsed(parent_sess, &hw_res, 0);65 async_hangup(parent_sess);66 if (ret != EOK) {67 return ret;68 }69 70 /* We want one irq and one io range. */71 if (hw_res.irqs.count != 1 || hw_res.io_ranges.count != 1) {72 hw_res_list_parsed_clean(&hw_res);73 return EINVAL;74 }75 76 if (io_regs_p)77 *io_regs_p = hw_res.io_ranges.ranges[0];78 if (irq_no)79 *irq_no = hw_res.irqs.irqs[0];80 81 hw_res_list_parsed_clean(&hw_res);82 return EOK;83 }84 85 45 /** Call the PCI driver with a request to clear legacy support register 86 46 * -
uspace/drv/bus/usb/uhci/res.h
rc898236 r8d40181 39 39 #include <device/hw_res_parsed.h> 40 40 41 int get_my_registers(ddf_dev_t *, addr_range_t *, int *);42 int enable_interrupts(ddf_dev_t *);43 41 int disable_legacy(ddf_dev_t *); 44 42 -
uspace/drv/bus/usb/uhci/uhci.c
rc898236 r8d40181 77 77 int device_setup_uhci(ddf_dev_t *device) 78 78 { 79 if (!device) 80 return EBADMEM; 79 assert(device); 81 80 82 addr_range_t regs;83 int irq = 0;84 85 int ret = get_my_registers(device, ®s, &irq);86 if (ret != EOK) {87 usb_log_error("Failed to get I/O addresses for %" PRIun ": %s.\n",88 ddf_dev_get_handle(device),str_error(ret));81 hw_res_list_parsed_t hw_res; 82 int ret = hcd_ddf_get_registers(device, &hw_res); 83 if (ret != EOK || 84 hw_res.irqs.count != 1 || hw_res.io_ranges.count != 1) { 85 usb_log_error("Failed to get register memory addresses " 86 "for %" PRIun ": %s.\n", ddf_dev_get_handle(device), 87 str_error(ret)); 89 88 return ret; 90 89 } 90 addr_range_t regs = hw_res.io_ranges.ranges[0]; 91 const int irq = hw_res.irqs.irqs[0]; 92 hw_res_list_parsed_clean(&hw_res); 93 91 94 usb_log_debug("I/O regs at %p (size %zu), IRQ %d.\n", 92 95 RNGABSPTR(regs), RNGSZ(regs), irq);
Note:
See TracChangeset
for help on using the changeset viewer.