Changeset 48fe0c9 in mainline for uspace/drv/ohci/hc.c


Ignore:
Timestamp:
2011-03-21T13:43:27Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
361e61b, 5971dd3, 8a951ca
Parents:
0e45e7f (diff), 925e099 (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:

OHCI hc driver software side implementation

File:
1 moved

Legend:

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

    r0e45e7f r48fe0c9  
    3939#include <usb/debug.h>
    4040#include <usb/usb.h>
     41#include <usb/hub.h>
    4142#include <usb/ddfiface.h>
    42 #include <usb_iface.h>
     43#include <usb/usbdevice.h>
    4344
    44 #include "ohci_hc.h"
     45#include "hc.h"
    4546
    46 int ohci_hc_init(ohci_hc_t *instance, ddf_fun_t *fun,
     47static int dummy_reset(int foo, void *arg)
     48{
     49        hc_t *hc = (hc_t*)arg;
     50        assert(hc);
     51        hc->rh.address = 0;
     52        return EOK;
     53}
     54/*----------------------------------------------------------------------------*/
     55int hc_init(hc_t *instance, ddf_fun_t *fun, ddf_dev_t *dev,
    4756    uintptr_t regs, size_t reg_size, bool interrupts)
    4857{
    4958        assert(instance);
    50         int ret = pio_enable((void*)regs, reg_size, (void**)&instance->registers);
     59        int ret = EOK;
     60
     61        ret = pio_enable((void*)regs, reg_size, (void**)&instance->registers);
    5162        if (ret != EOK) {
    5263                usb_log_error("Failed to gain access to device registers.\n");
    5364                return ret;
    5465        }
    55         instance->registers->interrupt_disable = 0;
    56         /* enable interrupt on root hub status change */
    57         instance->registers->interupt_enable |= IE_RHSC | IE_MIE;
     66        instance->ddf_instance = fun;
     67        device_keeper_init(&instance->manager);
    5868
    5969
    60         ohci_rh_init(&instance->rh, instance->registers);
     70        rh_init(&instance->rh, dev, instance->registers);
    6171        /* TODO: implement */
    62         /* TODO: register root hub */
    6372        return EOK;
    6473}
    6574/*----------------------------------------------------------------------------*/
    66 int ohci_hc_schedule(ohci_hc_t *instance, batch_t *batch)
     75int hc_register_hub(hc_t *instance)
     76{
     77        async_usleep(1000000);
     78#define CHECK_RET_RETURN(ret, msg...) \
     79        if (ret != EOK) { \
     80                usb_log_error(msg); \
     81                return ret; \
     82        } else (void)0
     83        assert(instance);
     84        assert(instance->ddf_instance);
     85        assert(instance->ddf_instance->handle);
     86        ddf_dev_t *dev = instance->rh.device;
     87        int ret = EOK;
     88
     89        usb_hc_connection_t conn;
     90        ret =
     91            usb_hc_connection_initialize(&conn, instance->ddf_instance->handle);
     92        CHECK_RET_RETURN(ret, "Failed to initialize hc connection.\n");
     93
     94        ret = usb_hc_connection_open(&conn);
     95        CHECK_RET_RETURN(ret, "Failed to open hc connection.\n");
     96
     97        usb_address_t address;
     98        devman_handle_t handle;
     99        ret = usb_hc_new_device_wrapper(dev, &conn, USB_SPEED_FULL, dummy_reset,
     100            0, instance, &address, &handle, NULL, NULL, NULL);
     101        CHECK_RET_RETURN(ret, "Failed to add rh device.\n");
     102
     103        ret = usb_hc_connection_close(&conn);
     104        CHECK_RET_RETURN(ret, "Failed to close hc connection.\n");
     105        return EOK;
     106}
     107/*----------------------------------------------------------------------------*/
     108int hc_schedule(hc_t *instance, batch_t *batch)
    67109{
    68110        assert(instance);
    69111        assert(batch);
    70112        if (batch->target.address == instance->rh.address) {
    71                 ohci_rh_request(&instance->rh, batch);
    72                 return EOK;
     113                return rh_request(&instance->rh, batch);
    73114        }
    74115        /* TODO: implement */
    75         return EOK;
     116        return ENOTSUP;
    76117}
    77118/*----------------------------------------------------------------------------*/
    78 void ohci_hc_interrupt(ohci_hc_t *instance, uint16_t status)
     119void hc_interrupt(hc_t *instance, uint16_t status)
    79120{
    80121        assert(instance);
    81122        /* TODO: Check for interrupt cause */
    82         ohci_rh_interrupt(&instance->rh);
     123        rh_interrupt(&instance->rh);
    83124        /* TODO: implement */
    84125}
Note: See TracChangeset for help on using the changeset viewer.