Changeset 19a1800 in mainline for uspace/drv/vhc/hub.c


Ignore:
Timestamp:
2011-03-01T22:20:56Z (14 years ago)
Author:
Matej Klonfar <maklf@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e24e7b1
Parents:
976f546 (diff), ac8285d (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 with the current development

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/vhc/hub.c

    r976f546 r19a1800  
    2727 */
    2828
    29 /** @addtogroup usb
     29/** @addtogroup drvusbvhc
    3030 * @{
    3131 */
     
    3939#include <str_error.h>
    4040#include <stdlib.h>
    41 #include <driver.h>
    42 #include <usb/usbdrv.h>
     41#include <ddf/driver.h>
     42#include <devman.h>
     43#include <usb/hub.h>
     44#include <usb/recognise.h>
    4345
    4446#include "hub.h"
    4547#include "hub/virthub.h"
    4648#include "vhcd.h"
     49#include "conn.h"
    4750
    4851usbvirt_device_t virtual_hub_device;
     52static ddf_dev_ops_t rh_ops = {
     53        .interfaces[USB_DEV_IFACE] = &rh_usb_iface,
     54};
    4955
    5056static int hub_register_in_devman_fibril(void *arg);
    5157
    52 void virtual_hub_device_init(device_t *hc_dev)
     58void virtual_hub_device_init(ddf_fun_t *hc_dev)
    5359{
    5460        virthub_init(&virtual_hub_device);
     
    6369            = fibril_create(hub_register_in_devman_fibril, hc_dev);
    6470        if (root_hub_registration == 0) {
    65                 printf(NAME ": failed to register root hub\n");
     71                usb_log_fatal("Failed to create hub registration fibril.\n");
    6672                return;
    6773        }
    6874
    6975        fibril_add_ready(root_hub_registration);
     76}
     77
     78static int pretend_port_rest(int unused, void *unused2)
     79{
     80        return EOK;
    7081}
    7182
     
    7788int hub_register_in_devman_fibril(void *arg)
    7889{
    79         device_t *hc_dev = (device_t *) arg;
     90        ddf_fun_t *hc_dev = (ddf_fun_t *) arg;
    8091
    81         int hc = usb_drv_hc_connect(hc_dev, hc_dev->handle, IPC_FLAG_BLOCKING);
    82         if (hc < 0) {
    83                 printf(NAME ": failed to register root hub\n");
    84                 return hc;
     92        /*
     93         * Wait until parent device is properly initialized.
     94         */
     95        int phone;
     96        do {
     97                phone = devman_device_connect(hc_dev->handle, 0);
     98        } while (phone < 0);
     99        async_hangup(phone);
     100
     101        int rc;
     102
     103        usb_hc_connection_t hc_conn;
     104        rc = usb_hc_connection_initialize(&hc_conn, hc_dev->handle);
     105        assert(rc == EOK);
     106
     107        rc = usb_hc_connection_open(&hc_conn);
     108        assert(rc == EOK);
     109
     110        ddf_fun_t *hub_dev;
     111        rc = usb_hc_new_device_wrapper(hc_dev->dev, &hc_conn,
     112            USB_SPEED_FULL,
     113            pretend_port_rest, 0, NULL,
     114            NULL, NULL, &rh_ops, hc_dev, &hub_dev);
     115        if (rc != EOK) {
     116                usb_log_fatal("Failed to create root hub: %s.\n",
     117                    str_error(rc));
    85118        }
    86119
    87         usb_drv_reserve_default_address(hc);
     120        usb_hc_connection_close(&hc_conn);
    88121
    89         usb_address_t hub_address = usb_drv_request_address(hc);
    90         usb_drv_req_set_address(hc, USB_ADDRESS_DEFAULT, hub_address);
     122        usb_log_info("Created root hub function (handle %zu).\n",
     123            (size_t) hub_dev->handle);
    91124
    92         usb_drv_release_default_address(hc);
    93 
    94         devman_handle_t hub_handle;
    95         usb_drv_register_child_in_devman(hc, hc_dev, hub_address, &hub_handle);
    96         usb_drv_bind_address(hc, hub_address, hub_handle);
    97 
    98         return EOK;
     125        return 0;
    99126}
    100127       
Note: See TracChangeset for help on using the changeset viewer.