Changeset 400575c5 in mainline for uspace/drv/uhci-hcd/main.c


Ignore:
Timestamp:
2011-02-04T17:19:20Z (14 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e29e09cf, e778543
Parents:
458e40c (diff), 89acf204 (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:

Add UHCI Host Controller driver (uhci-hcd)
Add UHCI Root Hub driver (uhci-rhd)

hcd is able to communicate with usb dvices if request sent to hcd follow
USB specification (no isochronous transfers)
rhd does not support device removal

File:
1 moved

Legend:

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

    r458e40c r400575c5  
    11/*
    2  * Copyright (c) 2010 Vojtech Horky
     2 * Copyright (c) 2011 Vojtech Horky, Jan Vesely
    33 * All rights reserved.
    44 *
     
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 #include <usb/hcdhubd.h>
     28/** @addtogroup usb
     29 * @{
     30 */
     31/** @file
     32 * @brief UHCI driver
     33 */
     34#include <driver.h>
    2935#include <usb_iface.h>
     36
     37#include <errno.h>
     38
    3039#include <usb/debug.h>
    31 #include <errno.h>
    32 #include <str_error.h>
    33 #include <driver.h>
     40
     41#include "iface.h"
     42#include "pci.h"
     43#include "root_hub.h"
    3444#include "uhci.h"
     45
     46#define NAME "uhci-hcd"
    3547
    3648static int usb_iface_get_hc_handle(device_t *dev, devman_handle_t *handle)
     
    5466static int uhci_add_device(device_t *device)
    5567{
    56         usb_dprintf(NAME, 1, "uhci_add_device() called\n");
     68        assert(device);
     69
     70        usb_log_info("uhci_add_device() called\n");
    5771        device->ops = &uhci_ops;
    5872
     
    6579
    6680        if (rc != EOK) {
    67                 fprintf(stderr,
    68                     NAME ": failed to get I/O registers addresses: %s.\n",
    69                     str_error(rc));
     81                usb_log_error("Failed(%d) to get I/O registers addresses for device:.\n",
     82                    rc, device->handle);
    7083                return rc;
    7184        }
    7285
    73         usb_dprintf(NAME, 2, "I/O regs at 0x%X (size %zu), IRQ %d.\n",
     86        usb_log_info("I/O regs at 0x%X (size %zu), IRQ %d.\n",
    7487            io_reg_base, io_reg_size, irq);
    7588
    76         /*
    77          * We need to announce the presence of our root hub.
    78          */
    79         usb_dprintf(NAME, 2, "adding root hub\n");
    80         usb_hcd_add_root_hub(device);
     89        uhci_t *uhci_hc = malloc(sizeof(uhci_t));
     90        if (!uhci_hc) {
     91                usb_log_error("Failed to allocaete memory for uhci hcd driver.\n");
     92                return ENOMEM;
     93        }
     94
     95        int ret = uhci_init(uhci_hc, (void*)io_reg_base, io_reg_size);
     96        if (ret != EOK) {
     97                usb_log_error("Failed to init uhci-hcd.\n");
     98                return ret;
     99        }
     100        device_t *rh;
     101        ret = setup_root_hub(&rh, device);
     102
     103        if (ret != EOK) {
     104                usb_log_error("Failed to setup uhci root hub.\n");
     105                /* TODO: destroy uhci here */
     106                return ret;
     107        }
     108
     109        ret = child_device_register(rh, device);
     110        if (ret != EOK) {
     111                usb_log_error("Failed to register root hub.\n");
     112                /* TODO: destroy uhci here */
     113                return ret;
     114        }
     115
     116        device->driver_data = uhci_hc;
    81117
    82118        return EOK;
     
    98134         */
    99135        sleep(5);
    100         usb_dprintf_enable(NAME, 5);
     136        usb_log_enable(USB_LOG_LEVEL_INFO, NAME);
    101137
    102138        return driver_main(&uhci_driver);
    103139}
     140/**
     141 * @}
     142 */
Note: See TracChangeset for help on using the changeset viewer.