Changes in uspace/drv/bus/usb/uhci/pci.c [266976f:5203e256] in mainline
- File:
-
- 1 edited
-
uspace/drv/bus/usb/uhci/pci.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/uhci/pci.c
r266976f r5203e256 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 28 29 /** 29 30 * @addtogroup drvusbuhcihc … … 38 39 #include <assert.h> 39 40 #include <devman.h> 40 #include <device/hw_res _parsed.h>41 #include <device/hw_res.h> 41 42 42 43 #include <usb/debug.h> … … 60 61 assert(io_reg_size); 61 62 assert(irq_no); 62 63 63 64 async_sess_t *parent_sess = 64 65 devman_parent_device_connect(EXCHANGE_SERIALIZE, dev->handle, … … 66 67 if (!parent_sess) 67 68 return ENOMEM; 68 69 hw_res_list_parsed_t hw_res; 70 hw_res_list_parsed_init(&hw_res); 71 const int ret = hw_res_get_list_parsed(parent_sess, &hw_res, 0); 69 70 hw_resource_list_t hw_resources; 71 int rc = hw_res_get_resource_list(parent_sess, &hw_resources); 72 if (rc != EOK) { 73 async_hangup(parent_sess); 74 return rc; 75 } 76 77 uintptr_t io_address = 0; 78 size_t io_size = 0; 79 bool io_found = false; 80 81 int irq = 0; 82 bool irq_found = false; 83 84 size_t i; 85 for (i = 0; i < hw_resources.count; i++) { 86 const hw_resource_t *res = &hw_resources.resources[i]; 87 switch (res->type) { 88 case INTERRUPT: 89 irq = res->res.interrupt.irq; 90 irq_found = true; 91 usb_log_debug2("Found interrupt: %d.\n", irq); 92 break; 93 case IO_RANGE: 94 io_address = res->res.io_range.address; 95 io_size = res->res.io_range.size; 96 usb_log_debug2("Found io: %" PRIx64" %zu.\n", 97 res->res.io_range.address, res->res.io_range.size); 98 io_found = true; 99 break; 100 default: 101 break; 102 } 103 } 104 72 105 async_hangup(parent_sess); 73 if (ret != EOK) { 74 return ret; 75 } 76 77 /* We want one irq and one io range. */ 78 if (hw_res.irqs.count != 1 || hw_res.io_ranges.count != 1) { 79 hw_res_list_parsed_clean(&hw_res); 80 return EINVAL; 81 } 82 83 if (io_reg_address) 84 *io_reg_address = hw_res.io_ranges.ranges[0].address; 85 if (io_reg_size) 86 *io_reg_size = hw_res.io_ranges.ranges[0].size; 87 if (irq_no) 88 *irq_no = hw_res.irqs.irqs[0]; 89 90 hw_res_list_parsed_clean(&hw_res); 106 107 if (!io_found || !irq_found) 108 return ENOENT; 109 110 *io_reg_address = io_address; 111 *io_reg_size = io_size; 112 *irq_no = irq; 113 91 114 return EOK; 92 115 } 93 /*----------------------------------------------------------------------------*/ 116 94 117 /** Call the PCI driver with a request to enable interrupts 95 118 * … … 104 127 if (!parent_sess) 105 128 return ENOMEM; 106 129 107 130 const bool enabled = hw_res_enable_interrupt(parent_sess); 108 131 async_hangup(parent_sess); 109 132 110 133 return enabled ? EOK : EIO; 111 134 } 112 /*----------------------------------------------------------------------------*/ 135 113 136 /** Call the PCI driver with a request to clear legacy support register 114 137 * … … 119 142 { 120 143 assert(device); 121 144 122 145 async_sess_t *parent_sess = 123 146 devman_parent_device_connect(EXCHANGE_SERIALIZE, device->handle, … … 125 148 if (!parent_sess) 126 149 return ENOMEM; 127 150 128 151 /* See UHCI design guide for these values p.45, 129 152 * write all WC bits in USB legacy register */ 130 153 const sysarg_t address = 0xc0; 131 154 const sysarg_t value = 0xaf00; 132 155 133 156 async_exch_t *exch = async_exchange_begin(parent_sess); 134 157 135 158 const int rc = async_req_3_0(exch, DEV_IFACE_ID(PCI_DEV_IFACE), 136 159 IPC_M_CONFIG_SPACE_WRITE_16, address, value); 137 160 138 161 async_exchange_end(exch); 139 162 async_hangup(parent_sess); 140 163 141 164 return rc; 142 165 }
Note:
See TracChangeset
for help on using the changeset viewer.
