Changeset 79ae36dd in mainline for uspace/drv/uhci_hcd/pci.c
- Timestamp:
- 2011-06-08T19:01:55Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0eff68e
- Parents:
- 764d71e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci_hcd/pci.c
r764d71e r79ae36dd 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 28 29 /** 29 30 * @addtogroup drvusbuhcihc … … 34 35 * PCI related functions needed by the UHCI driver. 35 36 */ 37 36 38 #include <errno.h> 37 39 #include <assert.h> … … 59 61 assert(io_reg_size); 60 62 assert(irq_no); 61 62 int parent_phone=63 devman_parent_device_connect( dev->handle, IPC_FLAG_BLOCKING);64 if (parent_phone < 0) {65 return parent_phone;66 }67 63 64 async_sess_t *parent_sess = 65 devman_parent_device_connect(EXCHANGE_SERIALIZE, dev->handle, 66 IPC_FLAG_BLOCKING); 67 if (!parent_sess) 68 return ENOMEM; 69 68 70 hw_resource_list_t hw_resources; 69 int rc = hw_res_get_resource_list(parent_ phone, &hw_resources);71 int rc = hw_res_get_resource_list(parent_sess, &hw_resources); 70 72 if (rc != EOK) { 71 async_hangup(parent_ phone);73 async_hangup(parent_sess); 72 74 return rc; 73 75 } 74 76 75 77 uintptr_t io_address = 0; 76 78 size_t io_size = 0; 77 79 bool io_found = false; 78 80 79 81 int irq = 0; 80 82 bool irq_found = false; 81 83 82 84 size_t i; 83 85 for (i = 0; i < hw_resources.count; i++) { 84 86 const hw_resource_t *res = &hw_resources.resources[i]; 85 switch (res->type) 86 { 87 switch (res->type) { 87 88 case INTERRUPT: 88 89 irq = res->res.interrupt.irq; … … 90 91 usb_log_debug2("Found interrupt: %d.\n", irq); 91 92 break; 92 93 93 case IO_RANGE: 94 94 io_address = res->res.io_range.address; … … 98 98 io_found = true; 99 99 break; 100 101 100 default: 102 101 break; 103 102 } 104 103 } 105 async_hangup(parent_phone); 106 104 105 async_hangup(parent_sess); 106 107 107 if (!io_found || !irq_found) 108 108 return ENOENT; 109 109 110 110 *io_reg_address = io_address; 111 111 *io_reg_size = io_size; 112 112 *irq_no = irq; 113 113 114 114 return EOK; 115 115 } 116 /*----------------------------------------------------------------------------*/ 116 117 117 /** Call the PCI driver with a request to enable interrupts 118 118 * … … 122 122 int pci_enable_interrupts(const ddf_dev_t *device) 123 123 { 124 const int parent_phone = 125 devman_parent_device_connect(device->handle, IPC_FLAG_BLOCKING); 126 if (parent_phone < 0) { 127 return parent_phone; 128 } 129 const bool enabled = hw_res_enable_interrupt(parent_phone); 130 async_hangup(parent_phone); 124 async_sess_t *parent_sess = 125 devman_parent_device_connect(EXCHANGE_SERIALIZE, device->handle, 126 IPC_FLAG_BLOCKING); 127 if (!parent_sess) 128 return ENOMEM; 129 130 const bool enabled = hw_res_enable_interrupt(parent_sess); 131 async_hangup(parent_sess); 132 131 133 return enabled ? EOK : EIO; 132 134 } 133 /*----------------------------------------------------------------------------*/ 135 134 136 /** Call the PCI driver with a request to clear legacy support register 135 137 * … … 140 142 { 141 143 assert(device); 142 const int parent_phone = 143 devman_parent_device_connect(device->handle, IPC_FLAG_BLOCKING); 144 if (parent_phone < 0) { 145 return parent_phone; 146 } 147 144 145 async_sess_t *parent_sess = 146 devman_parent_device_connect(EXCHANGE_SERIALIZE, device->handle, 147 IPC_FLAG_BLOCKING); 148 if (!parent_sess) 149 return ENOMEM; 150 148 151 /* See UHCI design guide for these values p.45, 149 152 * write all WC bits in USB legacy register */ 150 153 const sysarg_t address = 0xc0; 151 154 const sysarg_t value = 0xaf00; 152 153 const int rc = async_req_3_0(parent_phone, DEV_IFACE_ID(PCI_DEV_IFACE), 155 156 async_exch_t *exch = async_exchange_begin(parent_sess); 157 158 const int rc = async_req_3_0(exch, DEV_IFACE_ID(PCI_DEV_IFACE), 154 159 IPC_M_CONFIG_SPACE_WRITE_16, address, value); 155 async_hangup(parent_phone); 156 160 161 async_exchange_end(exch); 162 async_hangup(parent_sess); 163 157 164 return rc; 158 165 } 159 /*----------------------------------------------------------------------------*/160 /**161 * @}162 */163 166 164 167 /**
Note:
See TracChangeset
for help on using the changeset viewer.