Ignore:
File:
1 edited

Legend:

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

    r53a309e r366e9b6  
    3636#include <assert.h>
    3737#include <ddf/driver.h>
     38#include <devman.h>
    3839#include <errno.h>
    3940#include <io/log.h>
     
    4950#define NAME "uhci"
    5051
    51 static int uhci_driver_init(hcd_t *, const hw_res_list_parsed_t *, bool);
     52static int uhci_driver_init(hcd_t *, const hw_res_list_parsed_t *);
     53static int uhci_driver_start(hcd_t *, bool);
    5254static void uhci_driver_fini(hcd_t *);
    53 static int disable_legacy(ddf_dev_t *);
     55static int disable_legacy(hcd_t *, ddf_dev_t *);
    5456
    5557static const ddf_hc_driver_t uhci_hc_driver = {
    5658        .claim = disable_legacy,
    57         .hc_speed = USB_SPEED_FULL,
    5859        .irq_code_gen = uhci_hc_gen_irq_code,
    5960        .init = uhci_driver_init,
     61        .start = uhci_driver_start,
     62        .setup_root_hub = hcd_setup_virtual_root_hub,
    6063        .fini = uhci_driver_fini,
    6164        .name = "UHCI",
     
    6770};
    6871
    69 static int uhci_driver_init(hcd_t *hcd, const hw_res_list_parsed_t *res, bool irq)
     72static int uhci_driver_init(hcd_t *hcd, const hw_res_list_parsed_t *res)
    7073{
     74        int err;
     75
    7176        assert(hcd);
    7277        assert(hcd_get_driver_data(hcd) == NULL);
     
    7681                return ENOMEM;
    7782
    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;
     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
     90err:
     91        free(instance);
     92        return err;
     93}
     94
     95static 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;
    85103}
    86104
     
    92110                hc_fini(hc);
    93111
    94         hcd_set_implementation(hcd, NULL, NULL);
     112        hcd_set_implementation(hcd, NULL, NULL, NULL);
    95113        free(hc);
    96114}
     
    101119 * @return Error code.
    102120 */
    103 static int disable_legacy(ddf_dev_t *device)
     121static int disable_legacy(hcd_t *hcd, ddf_dev_t *device)
    104122{
    105123        assert(device);
    106124
    107         async_sess_t *parent_sess = ddf_dev_parent_sess_get(device);
    108         if (parent_sess == NULL)
     125        async_sess_t *parent_sess = devman_parent_device_connect(
     126            ddf_dev_get_handle(device), IPC_FLAG_BLOCKING);
     127        if (!parent_sess)
    109128                return ENOMEM;
    110129
    111130        /* See UHCI design guide page 45 for these values.
    112131         * Write all WC bits in USB legacy register */
    113         return pci_config_space_write_16(parent_sess, 0xc0, 0xaf00);
     132        const int rc = pci_config_space_write_16(parent_sess, 0xc0, 0xaf00);
     133
     134        async_hangup(parent_sess);
     135        return rc;
    114136}
    115137
Note: See TracChangeset for help on using the changeset viewer.