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


Ignore:
Timestamp:
2013-09-15T06:33:53Z (11 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/uhci/hc.c

    rdd7078c r3f03199  
    111111 * @param[out] cmds Commands buffer.
    112112 * @param[in] cmds_size Size of the commands buffer (bytes).
    113  * @param[in] regs Physical address of device's registers.
    114  * @param[in] reg_size Size of the register area (bytes).
     113 * @param[in] regs Device's register range.
    115114 *
    116115 * @return Error code.
     
    118117int
    119118hc_get_irq_code(irq_pio_range_t ranges[], size_t ranges_size, irq_cmd_t cmds[],
    120     size_t cmds_size, uintptr_t regs, size_t reg_size)
     119    size_t cmds_size, addr_range_t *regs)
    121120{
    122121        if ((ranges_size < sizeof(uhci_irq_pio_ranges)) ||
    123122            (cmds_size < sizeof(uhci_irq_commands)) ||
    124             (reg_size < sizeof(uhci_regs_t)))
     123            (RNGSZ(*regs) < sizeof(uhci_regs_t)))
    125124                return EOVERFLOW;
    126125
    127126        memcpy(ranges, uhci_irq_pio_ranges, sizeof(uhci_irq_pio_ranges));
    128         ranges[0].base = regs;
     127        ranges[0].base = RNGABS(*regs);
    129128
    130129        memcpy(cmds, uhci_irq_commands, sizeof(uhci_irq_commands));
    131         uhci_regs_t *registers = (uhci_regs_t *) regs;
     130        uhci_regs_t *registers = (uhci_regs_t *) RNGABSPTR(*regs);
    132131        cmds[0].addr = (void*)&registers->usbsts;
    133132        cmds[3].addr = (void*)&registers->usbsts;
     133
     134        return EOK;
     135}
     136
     137/** Register interrupt handler.
     138 *
     139 * @param[in] device Host controller DDF device
     140 * @param[in] regs Register range
     141 * @param[in] irq Interrupt number
     142 * @paran[in] handler Interrupt handler
     143 *
     144 * @return EOK on success or negative error code
     145 */
     146int hc_register_irq_handler(ddf_dev_t *device, addr_range_t *regs, int irq,
     147    interrupt_handler_t handler)
     148{
     149        assert(device);
     150        irq_pio_range_t irq_ranges[hc_irq_pio_range_count()];
     151        irq_cmd_t irq_cmds[hc_irq_cmd_count()];
     152
     153        int ret = hc_get_irq_code(irq_ranges, sizeof(irq_ranges), irq_cmds,
     154            sizeof(irq_cmds), regs);
     155        if (ret != EOK) {
     156                usb_log_error("Failed to generate IRQ commands: %s.\n",
     157                    str_error(ret));
     158                return ret;
     159        }
     160
     161        irq_code_t irq_code = {
     162                .rangecount = hc_irq_pio_range_count(),
     163                .ranges = irq_ranges,
     164                .cmdcount = hc_irq_cmd_count(),
     165                .cmds = irq_cmds
     166        };
     167
     168        /* Register handler to avoid interrupt lockup */
     169        ret = register_interrupt_handler(device, irq, handler, &irq_code);
     170        if (ret != EOK) {
     171                usb_log_error("Failed to register interrupt handler: %s.\n",
     172                    str_error(ret));
     173                return ret;
     174        }
    134175
    135176        return EOK;
     
    196237 *
    197238 * @param[in] instance Memory place to initialize.
    198  * @param[in] regs Address of I/O control registers.
    199  * @param[in] reg_size Size of I/O control registers.
     239 * @param[in] regs Range of device's I/O control registers.
    200240 * @param[in] interrupts True if hw interrupts should be used.
    201241 * @return Error code.
     
    205245 * interrupt fibrils.
    206246 */
    207 int hc_init(hc_t *instance, void *regs, size_t reg_size, bool interrupts)
    208 {
    209         assert(reg_size >= sizeof(uhci_regs_t));
     247int hc_init(hc_t *instance, addr_range_t *regs, bool interrupts)
     248{
     249        assert(instance);
     250        assert(regs);
     251        assert(regs->size >= sizeof(uhci_regs_t));
    210252
    211253        instance->hw_interrupts = interrupts;
     
    214256        /* allow access to hc control registers */
    215257        uhci_regs_t *io;
    216         int ret = pio_enable(regs, reg_size, (void **)&io);
     258        int ret = pio_enable_range(regs, (void **) &io);
    217259        if (ret != EOK) {
    218260                usb_log_error("Failed to gain access to registers at %p: %s.\n",
     
    223265
    224266        usb_log_debug(
    225             "Device registers at %p (%zuB) accessible.\n", io, reg_size);
     267            "Device registers at %p (%zuB) accessible.\n", io, regs->size);
    226268
    227269        ret = hc_init_mem_structures(instance);
Note: See TracChangeset for help on using the changeset viewer.