Changeset 00aece0 in mainline for uspace/drv/bus/usb/uhci/pci.c
- Timestamp:
- 2012-02-18T16:47:38Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4449c6c
- Parents:
- bd5f3b7 (diff), f943dd3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/uhci/pci.c
rbd5f3b7 r00aece0 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 29 28 /** 30 29 * @addtogroup drvusbuhcihc … … 39 38 #include <assert.h> 40 39 #include <devman.h> 41 #include <device/hw_res .h>40 #include <device/hw_res_parsed.h> 42 41 43 42 #include <usb/debug.h> … … 61 60 assert(io_reg_size); 62 61 assert(irq_no); 63 62 64 63 async_sess_t *parent_sess = 65 64 devman_parent_device_connect(EXCHANGE_SERIALIZE, dev->handle, … … 67 66 if (!parent_sess) 68 67 return ENOMEM; 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; 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); 72 async_hangup(parent_sess); 73 if (ret != EOK) { 74 return ret; 75 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 } 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; 103 81 } 104 105 async_hangup(parent_sess); 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 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); 114 91 return EOK; 115 92 } 116 93 /*----------------------------------------------------------------------------*/ 117 94 /** Call the PCI driver with a request to enable interrupts 118 95 * … … 127 104 if (!parent_sess) 128 105 return ENOMEM; 129 106 130 107 const bool enabled = hw_res_enable_interrupt(parent_sess); 131 108 async_hangup(parent_sess); 132 109 133 110 return enabled ? EOK : EIO; 134 111 } 135 112 /*----------------------------------------------------------------------------*/ 136 113 /** Call the PCI driver with a request to clear legacy support register 137 114 * … … 142 119 { 143 120 assert(device); 144 121 145 122 async_sess_t *parent_sess = 146 123 devman_parent_device_connect(EXCHANGE_SERIALIZE, device->handle, … … 148 125 if (!parent_sess) 149 126 return ENOMEM; 150 127 151 128 /* See UHCI design guide for these values p.45, 152 129 * write all WC bits in USB legacy register */ 153 130 const sysarg_t address = 0xc0; 154 131 const sysarg_t value = 0xaf00; 155 132 156 133 async_exch_t *exch = async_exchange_begin(parent_sess); 157 134 158 135 const int rc = async_req_3_0(exch, DEV_IFACE_ID(PCI_DEV_IFACE), 159 136 IPC_M_CONFIG_SPACE_WRITE_16, address, value); 160 137 161 138 async_exchange_end(exch); 162 139 async_hangup(parent_sess); 163 140 164 141 return rc; 165 142 }
Note:
See TracChangeset
for help on using the changeset viewer.