Changeset 3f03199 in mainline for uspace/drv/bus/usb/ohci/hc.c


Ignore:
Timestamp:
2013-09-15T06:33:53Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
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.
Message:

Merge mainline changes.

Major conflicts in USB HC drivers.
Compiles and UHCI works (qemu).
OHCI has device remove problems.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ohci/hc.c

    rdd7078c r3f03199  
    109109 * @param[out] cmds Commands buffer.
    110110 * @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.
    113112 *
    114113 * @return Error code.
     
    116115int
    117116hc_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)
    119118{
    120119        if ((ranges_size < sizeof(ohci_pio_ranges)) ||
    121120            (cmds_size < sizeof(ohci_irq_commands)) ||
    122             (reg_size < sizeof(ohci_regs_t)))
     121            (RNGSZ(*regs) < sizeof(ohci_regs_t)))
    123122                return EOVERFLOW;
    124123
    125124        memcpy(ranges, ohci_pio_ranges, sizeof(ohci_pio_ranges));
    126         ranges[0].base = regs;
     125        ranges[0].base = RNGABS(*regs);
    127126
    128127        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);
    130129        cmds[0].addr = (void *) &registers->interrupt_status;
    131130        cmds[3].addr = (void *) &registers->interrupt_status;
     
    135134}
    136135
     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 */
     145int 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
    137179/** Initialize OHCI hc driver structure
    138180 *
    139181 * @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.
    142183 * @param[in] interrupts True if w interrupts should be used
    143184 * @return Error code
    144185 */
    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);
     186int 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);
    151191        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",
    153193                    str_error(ret));
    154194                return ret;
Note: See TracChangeset for help on using the changeset viewer.