Changeset 7813516 in mainline for uspace/drv/bus/usb/uhci


Ignore:
Timestamp:
2014-01-01T01:19:10Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7191992
Parents:
d1df381
Message:

uhci,ohci,ehci: Use all hw resources to initialize HC

Location:
uspace/drv/bus/usb/uhci
Files:
3 edited

Legend:

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

    rd1df381 r7813516  
    212212 * interrupt fibrils.
    213213 */
    214 int hc_init(hc_t *instance, addr_range_t *regs, bool interrupts)
    215 {
    216         assert(instance);
    217         assert(regs);
    218         assert(regs->size >= sizeof(uhci_regs_t));
     214int hc_init(hc_t *instance, const hw_res_list_parsed_t *hw_res, bool interrupts)
     215{
     216        assert(instance);
     217        assert(hw_res);
     218        if (hw_res->io_ranges.count != 1 ||
     219            hw_res->io_ranges.ranges[0].size < sizeof(uhci_regs_t))
     220            return EINVAL;
    219221
    220222        instance->hw_interrupts = interrupts;
     
    222224
    223225        /* allow access to hc control registers */
    224         uhci_regs_t *io;
    225         int ret = pio_enable_range(regs, (void **) &io);
     226        int ret = pio_enable_range(&hw_res->io_ranges.ranges[0],
     227            (void **) &instance->registers);
    226228        if (ret != EOK) {
    227                 usb_log_error("Failed to gain access to registers at %p: %s.\n",
    228                     io, str_error(ret));
     229                usb_log_error("Failed to gain access to registers: %s.\n",
     230                    str_error(ret));
    229231                return ret;
    230232        }
    231         instance->registers = io;
    232 
    233         usb_log_debug(
    234             "Device registers at %p (%zuB) accessible.\n", io, regs->size);
     233
     234        usb_log_debug("Device registers at %" PRIx64 " (%zuB) accessible.\n",
     235            hw_res->io_ranges.ranges[0].address.absolute,
     236            hw_res->io_ranges.ranges[0].size);
    235237
    236238        ret = hc_init_mem_structures(instance);
     
    253255
    254256        return EOK;
     257}
     258
     259/** Safely dispose host controller internal structures
     260 *
     261 * @param[in] instance Host controller structure to use.
     262 */
     263void hc_fini(hc_t *instance)
     264{
     265        assert(instance);
     266        //TODO Implement
    255267}
    256268
  • uspace/drv/bus/usb/uhci/hc.h

    rd1df381 r7813516  
    129129int hc_gen_irq_code(irq_code_t *code, const hw_res_list_parsed_t *hw_res);
    130130void hc_interrupt(hc_t *instance, uint16_t status);
    131 int hc_init(hc_t *instance, addr_range_t *regs, bool interupts);
     131int hc_init(hc_t *instance, const hw_res_list_parsed_t *hw_res, bool interupts);
     132void hc_fini(hc_t *instance);
    132133int hc_schedule(hcd_t *hcd, usb_transfer_batch_t *batch);
    133134
    134 /** Safely dispose host controller internal structures
    135  *
    136  * @param[in] instance Host controller structure to use.
    137  */
    138 static inline void hc_fini(hc_t *instance) {} /* TODO: implement*/
    139135#endif
    140136
  • uspace/drv/bus/usb/uhci/uhci.c

    rd1df381 r7813516  
    8989        hw_res_list_parsed_t hw_res;
    9090        int ret = hcd_ddf_get_registers(device, &hw_res);
    91         if (ret != EOK ||
    92             hw_res.irqs.count != 1 || hw_res.io_ranges.count != 1) {
     91        if (ret != EOK) {
    9392                usb_log_error("Failed to get register memory addresses "
    9493                    "for %" PRIun ": %s.\n", ddf_dev_get_handle(device),
     
    9695                return ret;
    9796        }
    98         addr_range_t regs = hw_res.io_ranges.ranges[0];
    9997
    10098        ret = hcd_ddf_setup_hc(device, USB_SPEED_FULL,
     
    125123        }
    126124
    127         ret = hc_init(hc, &regs, interrupts);
     125        ret = hc_init(hc, &hw_res, interrupts);
    128126        hw_res_list_parsed_clean(&hw_res);
    129127        if (ret != EOK) {
    130128                usb_log_error("Failed to init uhci_hcd: %s.\n", str_error(ret));
    131129                goto irq_unregister;
    132                 // TODO This is unfortunate, we have neither legacy nor real USB
    133130        }
    134131
Note: See TracChangeset for help on using the changeset viewer.