Ignore:
File:
1 edited

Legend:

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

    r366e9b6 r53a309e  
    3636#include <assert.h>
    3737#include <ddf/driver.h>
    38 #include <devman.h>
    3938#include <errno.h>
    4039#include <io/log.h>
     
    5049#define NAME "uhci"
    5150
    52 static int uhci_driver_init(hcd_t *, const hw_res_list_parsed_t *);
    53 static int uhci_driver_start(hcd_t *, bool);
     51static int uhci_driver_init(hcd_t *, const hw_res_list_parsed_t *, bool);
    5452static void uhci_driver_fini(hcd_t *);
    55 static int disable_legacy(hcd_t *, ddf_dev_t *);
     53static int disable_legacy(ddf_dev_t *);
    5654
    5755static const ddf_hc_driver_t uhci_hc_driver = {
    5856        .claim = disable_legacy,
     57        .hc_speed = USB_SPEED_FULL,
    5958        .irq_code_gen = uhci_hc_gen_irq_code,
    6059        .init = uhci_driver_init,
    61         .start = uhci_driver_start,
    62         .setup_root_hub = hcd_setup_virtual_root_hub,
    6360        .fini = uhci_driver_fini,
    6461        .name = "UHCI",
     
    7067};
    7168
    72 static int uhci_driver_init(hcd_t *hcd, const hw_res_list_parsed_t *res)
     69static int uhci_driver_init(hcd_t *hcd, const hw_res_list_parsed_t *res, bool irq)
    7370{
    74         int err;
    75 
    7671        assert(hcd);
    7772        assert(hcd_get_driver_data(hcd) == NULL);
     
    8176                return ENOMEM;
    8277
    83         if ((err = hc_init(instance, res)) != EOK)
    84                 goto err;
    85 
    86         hcd_set_implementation(hcd, instance, &uhci_hc_driver.ops, &instance->bus.base);
    87 
    88         return EOK;
    89 
    90 err:
    91         free(instance);
    92         return err;
    93 }
    94 
    95 static int uhci_driver_start(hcd_t *hcd, bool interrupts)
    96 {
    97         assert(hcd);
    98         hc_t *hc = hcd_get_driver_data(hcd);
    99 
    100         hc->hw_interrupts = interrupts;
    101         hc_start(hc);
    102         return EOK;
     78        const int ret = hc_init(instance, res, irq);
     79        if (ret == EOK) {
     80                hcd_set_implementation(hcd, instance, &uhci_hc_driver.ops);
     81        } else {
     82                free(instance);
     83        }
     84        return ret;
    10385}
    10486
     
    11092                hc_fini(hc);
    11193
    112         hcd_set_implementation(hcd, NULL, NULL, NULL);
     94        hcd_set_implementation(hcd, NULL, NULL);
    11395        free(hc);
    11496}
     
    119101 * @return Error code.
    120102 */
    121 static int disable_legacy(hcd_t *hcd, ddf_dev_t *device)
     103static int disable_legacy(ddf_dev_t *device)
    122104{
    123105        assert(device);
    124106
    125         async_sess_t *parent_sess = devman_parent_device_connect(
    126             ddf_dev_get_handle(device), IPC_FLAG_BLOCKING);
    127         if (!parent_sess)
     107        async_sess_t *parent_sess = ddf_dev_parent_sess_get(device);
     108        if (parent_sess == NULL)
    128109                return ENOMEM;
    129110
    130111        /* See UHCI design guide page 45 for these values.
    131112         * Write all WC bits in USB legacy register */
    132         const int rc = pci_config_space_write_16(parent_sess, 0xc0, 0xaf00);
    133 
    134         async_hangup(parent_sess);
    135         return rc;
     113        return pci_config_space_write_16(parent_sess, 0xc0, 0xaf00);
    136114}
    137115
Note: See TracChangeset for help on using the changeset viewer.