Changeset 233e68d in mainline for uspace/drv/uhci-hcd/uhci.c


Ignore:
Timestamp:
2011-02-23T18:28:41Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e9e58ea3
Parents:
deece2f (diff), a9c674e0 (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:

Devel changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci-hcd/uhci.c

    rdeece2f r233e68d  
    3333 */
    3434#include <errno.h>
     35#include <str_error.h>
    3536#include <adt/list.h>
     37#include <libarch/ddi.h>
    3638
    3739#include <usb/debug.h>
    3840#include <usb/usb.h>
     41#include <usb/ddfiface.h>
     42#include <usb_iface.h>
    3943
    4044#include "uhci.h"
     45#include "iface.h"
     46
    4147static irq_cmd_t uhci_cmds[] = {
    4248        {
     
    5561};
    5662
     63static int usb_iface_get_address(ddf_fun_t *fun, devman_handle_t handle,
     64    usb_address_t *address)
     65{
     66        assert(fun);
     67        uhci_t *hc = fun_to_uhci(fun);
     68        assert(hc);
     69
     70        usb_address_t addr = usb_address_keeping_find(&hc->address_manager,
     71            handle);
     72        if (addr < 0) {
     73                return addr;
     74        }
     75
     76        if (address != NULL) {
     77                *address = addr;
     78        }
     79
     80        return EOK;
     81}
     82
     83
     84static usb_iface_t hc_usb_iface = {
     85        .get_hc_handle = usb_iface_get_hc_handle_hc_impl,
     86        .get_address = usb_iface_get_address
     87};
     88/*----------------------------------------------------------------------------*/
     89static ddf_dev_ops_t uhci_ops = {
     90        .interfaces[USB_DEV_IFACE] = &hc_usb_iface,
     91        .interfaces[USBHC_DEV_IFACE] = &uhci_iface
     92};
     93
    5794static int uhci_init_transfer_lists(uhci_t *instance);
    5895static int uhci_init_mem_structures(uhci_t *instance);
     
    71108        } else (void) 0
    72109
    73 int uhci_init(uhci_t *instance, void *regs, size_t reg_size)
     110int uhci_init(uhci_t *instance, ddf_dev_t *dev, void *regs, size_t reg_size)
    74111{
    75112        assert(reg_size >= sizeof(regs_t));
     113        int ret;
     114
     115        /*
     116         * Create UHCI function.
     117         */
     118        instance->ddf_instance = ddf_fun_create(dev, fun_exposed, "uhci");
     119        if (instance->ddf_instance == NULL) {
     120                usb_log_error("Failed to create UHCI device function.\n");
     121                return ENOMEM;
     122        }
     123        instance->ddf_instance->ops = &uhci_ops;
     124        instance->ddf_instance->driver_data = instance;
     125
     126        ret = ddf_fun_bind(instance->ddf_instance);
     127        CHECK_RET_RETURN(ret, "Failed to bind UHCI device function: %s.\n",
     128            str_error(ret));
    76129
    77130        /* allow access to hc control registers */
    78131        regs_t *io;
    79         int ret = pio_enable(regs, reg_size, (void**)&io);
     132        ret = pio_enable(regs, reg_size, (void**)&io);
    80133        CHECK_RET_RETURN(ret, "Failed to gain access to registers at %p.\n", io);
    81134        instance->registers = io;
Note: See TracChangeset for help on using the changeset viewer.