Ignore:
File:
1 edited

Legend:

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

    rcffa14e6 r171e668  
    4141#include <usb/debug.h>
    4242#include <usb/usb.h>
    43 #include <usb/ddfiface.h>
    4443
    4544#include "hc.h"
     
    8887static int hc_init_memory(hc_t *instance);
    8988static int interrupt_emulator(hc_t *instance);
    90 static int hc_schedule(hcd_t *hcd, usb_transfer_batch_t *batch);
    9189
    9290/** Get number of PIO ranges used in IRQ code.
     
    137135}
    138136
    139 /** Announce OHCI root hub to the DDF
    140  *
    141  * @param[in] instance OHCI driver intance
    142  * @param[in] hub_fun DDF fuction representing OHCI root hub
    143  * @return Error code
    144  */
    145 int hc_register_hub(hc_t *instance, ddf_fun_t *hub_fun)
    146 {
    147         assert(instance);
    148         assert(hub_fun);
    149 
    150         /* Try to get address 1 for root hub. */
    151         instance->rh.address = 1;
    152         int ret = usb_device_manager_request_address(
    153             &instance->generic.dev_manager, &instance->rh.address, false,
    154             USB_SPEED_FULL);
    155         if (ret != EOK) {
    156                 usb_log_error("Failed to get OHCI root hub address: %s\n",
    157                     str_error(ret));
    158                 return ret;
    159         }
    160 
    161 #define CHECK_RET_UNREG_RETURN(ret, message...) \
    162 if (ret != EOK) { \
    163         usb_log_error(message); \
    164         usb_endpoint_manager_remove_ep( \
    165             &instance->generic.ep_manager, instance->rh.address, 0, \
    166             USB_DIRECTION_BOTH, NULL, NULL); \
    167         usb_device_manager_release_address( \
    168             &instance->generic.dev_manager, instance->rh.address); \
    169         return ret; \
    170 } else (void)0
    171 
    172         ret = usb_endpoint_manager_add_ep(
    173             &instance->generic.ep_manager, instance->rh.address, 0,
    174             USB_DIRECTION_BOTH, USB_TRANSFER_CONTROL, USB_SPEED_FULL, 64,
    175             0, NULL, NULL);
    176         CHECK_RET_UNREG_RETURN(ret,
    177             "Failed to register root hub control endpoint: %s.\n",
    178             str_error(ret));
    179 
    180         ret = ddf_fun_add_match_id(hub_fun, "usb&class=hub", 100);
    181         CHECK_RET_UNREG_RETURN(ret,
    182             "Failed to add root hub match-id: %s.\n", str_error(ret));
    183 
    184         ret = ddf_fun_bind(hub_fun);
    185         CHECK_RET_UNREG_RETURN(ret,
    186             "Failed to bind root hub function: %s.\n", str_error(ret));
    187 
    188         ret = usb_device_manager_bind_address(&instance->generic.dev_manager,
    189             instance->rh.address, ddf_fun_get_handle(hub_fun));
    190         if (ret != EOK)
    191                 usb_log_warning("Failed to bind root hub address: %s.\n",
    192                     str_error(ret));
    193 
    194         return EOK;
    195 #undef CHECK_RET_RELEASE
    196 }
    197 
    198137/** Initialize OHCI hc driver structure
    199138 *
     
    221160        list_initialize(&instance->pending_batches);
    222161
    223         hcd_init(&instance->generic, USB_SPEED_FULL,
    224             BANDWIDTH_AVAILABLE_USB11, bandwidth_count_usb11);
    225         instance->generic.private_data = instance;
    226         instance->generic.schedule = hc_schedule;
    227         instance->generic.ep_add_hook = ohci_endpoint_init;
    228         instance->generic.ep_remove_hook = ohci_endpoint_fini;
    229 
    230162        ret = hc_init_memory(instance);
    231163        CHECK_RET_RETURN(ret, "Failed to create OHCI memory structures: %s.\n",
     
    243175        }
    244176
    245         rh_init(&instance->rh, instance->registers);
     177        ohci_rh_init(&instance->rh, instance->registers, "ohci rh");
    246178        hc_start(instance);
    247179
     
    330262
    331263        /* Check for root hub communication */
    332         if (batch->ep->address == instance->rh.address) {
     264        if (batch->ep->address == ohci_rh_get_address(&instance->rh)) {
    333265                usb_log_debug("OHCI root hub request.\n");
    334                 rh_request(&instance->rh, batch);
    335                 return EOK;
     266                return ohci_rh_schedule(&instance->rh, batch);
    336267        }
    337268        ohci_transfer_batch_t *ohci_batch = ohci_transfer_batch_get(batch);
     
    372303        usb_log_debug2("OHCI(%p) interrupt: %x.\n", instance, status);
    373304        if (status & I_RHSC)
    374                 rh_interrupt(&instance->rh);
     305                ohci_rh_interrupt(&instance->rh);
    375306
    376307        if (status & I_WDH) {
     
    602533        assert(instance);
    603534
    604         memset(&instance->rh, 0, sizeof(instance->rh));
     535        bzero(&instance->rh, sizeof(instance->rh));
    605536        /* Init queues */
    606537        const int ret = hc_init_transfer_lists(instance);
Note: See TracChangeset for help on using the changeset viewer.