Ignore:
File:
1 edited

Legend:

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

    rb7fd2a0 re0a5d4c  
    11/*
    22 * Copyright (c) 2011 Vojtech Horky
     3 * Copyright (c) 2018 Ondrej Hlavaty
    34 * All rights reserved.
    45 *
     
    4041
    4142#include <usb/host/ddf_helpers.h>
     43#include <usb/host/utility.h>
    4244
    4345#include <usb/debug.h>
     
    6971                return ret;
    7072        }
    71         vhc_init(vhc);
    7273        return EOK;
    7374}
    7475
    75 hcd_ops_t vhc_hc_ops = {
    76         .schedule = vhc_schedule,
    77 };
    78 
    7976static errno_t vhc_dev_add(ddf_dev_t *dev)
    8077{
     78        /* Initialize generic structures */
     79        errno_t ret = hcd_ddf_setup_hc(dev, sizeof(vhc_data_t));
     80        if (ret != EOK) {
     81                usb_log_error("Failed to init HCD structures: %s.",
     82                   str_error(ret));
     83                return ret;
     84        }
     85        vhc_data_t *vhc = ddf_dev_data_get(dev);
     86        vhc_init(vhc);
     87
     88        hc_device_setup(&vhc->base, (bus_t *) &vhc->bus);
     89
    8190        /* Initialize virtual structure */
    8291        ddf_fun_t *ctl_fun = NULL;
    83         errno_t ret = vhc_control_node(dev, &ctl_fun);
     92        ret = vhc_control_node(dev, &ctl_fun);
    8493        if (ret != EOK) {
    85                 usb_log_error("Failed to setup control node.\n");
    86                 return ret;
    87         }
    88         vhc_data_t *data = ddf_fun_data_get(ctl_fun);
    89 
    90         /* Initialize generic structures */
    91         ret = hcd_ddf_setup_hc(dev, USB_SPEED_FULL,
    92             BANDWIDTH_AVAILABLE_USB11, bandwidth_count_usb11);
    93         if (ret != EOK) {
    94                 usb_log_error("Failed to init HCD structures: %s.\n",
    95                    str_error(ret));
    96                 ddf_fun_destroy(ctl_fun);
     94                usb_log_error("Failed to setup control node.");
    9795                return ret;
    9896        }
    9997
    100         hcd_set_implementation(dev_to_hcd(dev), data, &vhc_hc_ops);
    101 
    10298        /* Add virtual hub device */
    103         ret = vhc_virtdev_plug_hub(data, &data->hub, NULL, 0);
     99        ret = vhc_virtdev_plug_hub(vhc, &vhc->hub, NULL, 0);
    104100        if (ret != EOK) {
    105                 usb_log_error("Failed to plug root hub: %s.\n", str_error(ret));
     101                usb_log_error("Failed to plug root hub: %s.", str_error(ret));
    106102                ddf_fun_destroy(ctl_fun);
    107103                return ret;
     
    112108         * needs to be ready at this time.
    113109         */
    114         ret = hcd_ddf_setup_root_hub(dev);
     110        ret = hc_setup_virtual_root_hub(&vhc->base, USB_SPEED_HIGH);
    115111        if (ret != EOK) {
    116                 usb_log_error("Failed to init VHC root hub: %s\n",
     112                usb_log_error("Failed to init VHC root hub: %s",
    117113                        str_error(ret));
    118114                // TODO do something here...
Note: See TracChangeset for help on using the changeset viewer.