Changeset 291b8bc in mainline for uspace/drv/ohci/hc.c


Ignore:
Timestamp:
2011-03-26T13:28:43Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f62468c
Parents:
889e8e3 (diff), c9f5e238 (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 development/ changes

File:
1 edited

Legend:

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

    r889e8e3 r291b8bc  
    3939#include <usb/debug.h>
    4040#include <usb/usb.h>
    41 #include <usb/hub.h>
    4241#include <usb/ddfiface.h>
    4342#include <usb/usbdevice.h>
     
    4544#include "hc.h"
    4645
    47 static int dummy_reset(int foo, void *arg);
    4846static int interrupt_emulator(hc_t *instance);
     47/*----------------------------------------------------------------------------*/
     48int hc_register_hub(hc_t *instance, ddf_fun_t *hub_fun)
     49{
     50        assert(instance);
     51        assert(hub_fun);
     52
     53        usb_address_t hub_address =
     54            device_keeper_get_free_address(&instance->manager, USB_SPEED_FULL);
     55        instance->rh.address = hub_address;
     56        usb_device_keeper_bind(
     57            &instance->manager, hub_address, hub_fun->handle);
     58
     59        char *match_str = NULL;
     60        int ret = asprintf(&match_str, "usb&mid");
     61        ret = (match_str == NULL) ? ret : EOK;
     62        if (ret < 0) {
     63                usb_log_error("Failed to create root hub match-id string.\n");
     64                return ret;
     65        }
     66
     67        ret = ddf_fun_add_match_id(hub_fun, match_str, 100);
     68        if (ret != EOK) {
     69                usb_log_error("Failed add create root hub match-id.\n");
     70        }
     71        return ret;
     72}
    4973/*----------------------------------------------------------------------------*/
    5074int hc_init(hc_t *instance, ddf_fun_t *fun, ddf_dev_t *dev,
     
    6892        }
    6993
     94        rh_init(&instance->rh, dev, instance->registers);
    7095
    71         rh_init(&instance->rh, dev, instance->registers);
    7296        /* TODO: implement */
    73         return EOK;
    74 }
    75 /*----------------------------------------------------------------------------*/
    76 int hc_register_hub(hc_t *instance)
    77 {
    78         async_usleep(1000000);
    79 #define CHECK_RET_RETURN(ret, msg...) \
    80         if (ret != EOK) { \
    81                 usb_log_error(msg); \
    82                 return ret; \
    83         } else (void)0
    84         assert(instance);
    85         assert(instance->ddf_instance);
    86         assert(instance->ddf_instance->handle);
    87         ddf_dev_t *dev = instance->rh.device;
    88         int ret = EOK;
    89 
    90         usb_hc_connection_t conn;
    91         ret =
    92             usb_hc_connection_initialize(&conn, instance->ddf_instance->handle);
    93         CHECK_RET_RETURN(ret, "Failed to initialize hc connection.\n");
    94 
    95         ret = usb_hc_connection_open(&conn);
    96         CHECK_RET_RETURN(ret, "Failed to open hc connection.\n");
    97 
    98         usb_address_t address;
    99         devman_handle_t handle;
    100         ret = usb_hc_new_device_wrapper(dev, &conn, USB_SPEED_FULL, dummy_reset,
    101             0, instance, &address, &handle, NULL, NULL, NULL);
    102         if (ret != EOK) {
    103                 usb_log_error("Failed to add rh device.\n");
    104                 instance->rh.address = -1;
    105                 return ret;
    106         }
    107 
    108         ret = usb_hc_connection_close(&conn);
    109         CHECK_RET_RETURN(ret, "Failed to close hc connection.\n");
    11097        return EOK;
    11198}
     
    134121}
    135122/*----------------------------------------------------------------------------*/
    136 static int dummy_reset(int foo, void *arg)
    137 {
    138         hc_t *hc = (hc_t*)arg;
    139         assert(hc);
    140         hc->rh.address = 0;
    141         return EOK;
    142 }
    143 /*----------------------------------------------------------------------------*/
    144 static int interrupt_emulator(hc_t *instance)
     123int interrupt_emulator(hc_t *instance)
    145124{
    146125        assert(instance);
Note: See TracChangeset for help on using the changeset viewer.