Changeset 3f03199 in mainline for uspace/drv/bus/usb/ohci/hc.c
- Timestamp:
- 2013-09-15T06:33:53Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9348862
- Parents:
- dd7078c (diff), 1c0cef0 (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/ohci/hc.c
rdd7078c r3f03199 109 109 * @param[out] cmds Commands buffer. 110 110 * @param[in] cmds_size Size of the commands buffer (bytes). 111 * @param[in] regs Physical address of device's registers. 112 * @param[in] reg_size Size of the register area (bytes). 111 * @param[in] regs Device's register range. 113 112 * 114 113 * @return Error code. … … 116 115 int 117 116 hc_get_irq_code(irq_pio_range_t ranges[], size_t ranges_size, irq_cmd_t cmds[], 118 size_t cmds_size, uintptr_t regs, size_t reg_size)117 size_t cmds_size, addr_range_t *regs) 119 118 { 120 119 if ((ranges_size < sizeof(ohci_pio_ranges)) || 121 120 (cmds_size < sizeof(ohci_irq_commands)) || 122 ( reg_size< sizeof(ohci_regs_t)))121 (RNGSZ(*regs) < sizeof(ohci_regs_t))) 123 122 return EOVERFLOW; 124 123 125 124 memcpy(ranges, ohci_pio_ranges, sizeof(ohci_pio_ranges)); 126 ranges[0].base = regs;125 ranges[0].base = RNGABS(*regs); 127 126 128 127 memcpy(cmds, ohci_irq_commands, sizeof(ohci_irq_commands)); 129 ohci_regs_t *registers = (ohci_regs_t *) regs;128 ohci_regs_t *registers = (ohci_regs_t *) RNGABSPTR(*regs); 130 129 cmds[0].addr = (void *) ®isters->interrupt_status; 131 130 cmds[3].addr = (void *) ®isters->interrupt_status; … … 135 134 } 136 135 136 /** Register interrupt handler. 137 * 138 * @param[in] device Host controller DDF device 139 * @param[in] regs Register range 140 * @param[in] irq Interrupt number 141 * @paran[in] handler Interrupt handler 142 * 143 * @return EOK on success or negative error code 144 */ 145 int hc_register_irq_handler(ddf_dev_t *device, addr_range_t *regs, int irq, 146 interrupt_handler_t handler) 147 { 148 int rc; 149 150 irq_pio_range_t irq_ranges[hc_irq_pio_range_count()]; 151 irq_cmd_t irq_cmds[hc_irq_cmd_count()]; 152 153 irq_code_t irq_code = { 154 .rangecount = hc_irq_pio_range_count(), 155 .ranges = irq_ranges, 156 .cmdcount = hc_irq_cmd_count(), 157 .cmds = irq_cmds 158 }; 159 160 rc = hc_get_irq_code(irq_ranges, sizeof(irq_ranges), irq_cmds, 161 sizeof(irq_cmds), regs); 162 if (rc != EOK) { 163 usb_log_error("Failed to generate IRQ code: %s.\n", 164 str_error(rc)); 165 return rc; 166 } 167 168 /* Register handler to avoid interrupt lockup */ 169 rc = register_interrupt_handler(device, irq, handler, &irq_code); 170 if (rc != EOK) { 171 usb_log_error("Failed to register interrupt handler: %s.\n", 172 str_error(rc)); 173 return rc; 174 } 175 176 return EOK; 177 } 178 137 179 /** Initialize OHCI hc driver structure 138 180 * 139 181 * @param[in] instance Memory place for the structure. 140 * @param[in] regs Address of the memory mapped I/O registers. 141 * @param[in] reg_size Size of the memory mapped area. 182 * @param[in] regs Device's I/O registers range. 142 183 * @param[in] interrupts True if w interrupts should be used 143 184 * @return Error code 144 185 */ 145 int hc_init(hc_t *instance, uintptr_t regs, size_t reg_size, bool interrupts) 146 { 147 assert(instance); 148 149 int ret = 150 pio_enable((void*)regs, reg_size, (void**)&instance->registers); 186 int hc_init(hc_t *instance, addr_range_t *regs, bool interrupts) 187 { 188 assert(instance); 189 190 int ret = pio_enable_range(regs, (void **) &instance->registers); 151 191 if (ret != EOK) { 152 usb_log_error("Failed to enable access to device regss: %s.\n",192 usb_log_error("Failed to gain access to device registers: %s.\n", 153 193 str_error(ret)); 154 194 return ret;
Note:
See TracChangeset
for help on using the changeset viewer.