Changeset ff582d47 in mainline


Ignore:
Timestamp:
2011-03-21T12:51:02Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
be7950e8
Parents:
8627377
Message:

A really ugly way to register hub

Location:
uspace/drv/ohci
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/ohci/hc.c

    r8627377 rff582d47  
    4040#include <usb/usb.h>
    4141#include <usb/hub.h>
     42#include <usb/ddfiface.h>
    4243#include <usb/usbdevice.h>
    43 #include <usb/ddfiface.h>
    4444
    4545#include "hc.h"
    4646
     47static int dummy_reset(int foo, void *bar)
     48{
     49        return EOK;
     50}
    4751/*----------------------------------------------------------------------------*/
    4852int hc_init(hc_t *instance, ddf_fun_t *fun, ddf_dev_t *dev,
     
    5054{
    5155        assert(instance);
    52         int ret = pio_enable((void*)regs, reg_size, (void**)&instance->registers);
     56        int ret = EOK;
     57
     58        ret = pio_enable((void*)regs, reg_size, (void**)&instance->registers);
    5359        if (ret != EOK) {
    5460                usb_log_error("Failed to gain access to device registers.\n");
    5561                return ret;
    5662        }
     63        instance->ddf_instance = fun;
    5764        device_keeper_init(&instance->manager);
    5865
     
    6067        rh_init(&instance->rh, dev, instance->registers);
    6168        /* TODO: implement */
    62         /* TODO: register root hub */
    6369        return EOK;
    6470}
    6571/*----------------------------------------------------------------------------*/
    66 int hc_register_hub(hc_t *instance, ddf_dev_t *dev)
     72int hc_register_hub(hc_t *instance)
    6773{
     74        async_usleep(1000000);
     75#define CHECK_RET_RETURN(ret, msg...) \
     76        if (ret != EOK) { \
     77                usb_log_error(msg); \
     78                return ret; \
     79        } else (void)0
    6880        assert(instance);
     81        assert(instance->ddf_instance);
     82        assert(instance->ddf_instance->handle);
     83        ddf_dev_t *dev = instance->rh.device;
     84        int ret = EOK;
     85
     86        usb_hc_connection_t conn;
     87        ret =
     88            usb_hc_connection_initialize(&conn, instance->ddf_instance->handle);
     89        CHECK_RET_RETURN(ret, "Failed to initialize hc connection.\n");
     90
     91        ret = usb_hc_connection_open(&conn);
     92        CHECK_RET_RETURN(ret, "Failed to open hc connection.\n");
     93
     94        usb_address_t address;
     95        devman_handle_t handle;
     96        ret = usb_hc_new_device_wrapper(dev, &conn, USB_SPEED_FULL, dummy_reset,
     97            0, NULL, &address, &handle, NULL, NULL, NULL);
     98        CHECK_RET_RETURN(ret, "Failed to add rh device.\n");
     99
     100        ret = usb_hc_connection_close(&conn);
     101        CHECK_RET_RETURN(ret, "Failed to close hc connection.\n");
    69102        return EOK;
    70103}
  • uspace/drv/ohci/hc.h

    r8627377 rff582d47  
    5959     uintptr_t regs, size_t reg_size, bool interrupts);
    6060
    61 int hc_register_hub(hc_t *instance, ddf_dev_t *dev);
     61int hc_register_hub(hc_t *instance);
    6262
    6363int hc_schedule(hc_t *instance, batch_t *batch);
  • uspace/drv/ohci/main.c

    r8627377 rff582d47  
    179179        hc_fun->driver_data = hcd;
    180180
    181         hc_register_hub(hcd, device);
     181        fid_t later = fibril_create((int(*)(void*))hc_register_hub, hcd);
     182        fibril_add_ready(later);
    182183
    183184        usb_log_info("Controlling new OHCI device `%s' (handle %llu).\n",
Note: See TracChangeset for help on using the changeset viewer.