Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 972e8a9 in mainline


Ignore:
Timestamp:
2014-01-02T20:48:33Z (8 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master
Children:
4942d63
Parents:
da06e92
Message:

ehci: Use the newly provided helper functions

Location:
uspace/drv/bus/usb/ehci
Files:
2 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ehci/Makefile

    rda06e92 r972e8a9  
    4545
    4646SOURCES = \
    47         ehci.c \
    4847        ehci_rh.c \
    4948        hc.c \
  • uspace/drv/bus/usb/ehci/main.c

    rda06e92 r972e8a9  
    4444
    4545#include "res.h"
    46 #include "ehci.h"
     46#include "hc.h"
    4747
    4848#define NAME "ehci"
     49// TODO: This should be merged to hc_interrupt
     50static void ehci_interrupt(hcd_t *hcd, uint32_t status)
     51{
     52        assert(hcd);
     53        if (hcd->driver.data)
     54                hc_interrupt(hcd->driver.data, status);
     55}
     56
     57static int ehci_driver_init(hcd_t *hcd, const hw_res_list_parsed_t *res, bool irq)
     58{
     59        assert(hcd);
     60        assert(hcd->driver.data == NULL);
     61
     62        hc_t *instance = malloc(sizeof(hc_t));
     63        if (!instance)
     64                return ENOMEM;
     65
     66        const int ret =  hc_init(instance, res, irq);
     67        if (ret == EOK)
     68                hcd_set_implementation(hcd, instance, hc_schedule,
     69                    NULL, NULL, ehci_interrupt);
     70        return ret;
     71}
     72
     73static void ehci_driver_fini(hcd_t *hcd)
     74{
     75        assert(hcd);
     76        if (hcd->driver.data)
     77                hc_fini(hcd->driver.data);
     78
     79        free(hcd->driver.data);
     80        hcd_set_implementation(hcd, NULL, NULL, NULL, NULL, NULL);
     81}
    4982
    5083static int ehci_dev_add(ddf_dev_t *device);
     
    67100static int ehci_dev_add(ddf_dev_t *device)
    68101{
     102        usb_log_debug("ehci_dev_add() called\n");
    69103        assert(device);
    70         hw_res_list_parsed_t hw_res;
    71         int ret = hcd_ddf_get_registers(device, &hw_res);
    72         if (ret != EOK ||
    73             hw_res.irqs.count != 1 || hw_res.mem_ranges.count != 1) {
    74                 usb_log_error("Failed to get register memory addresses "
    75                     "for %" PRIun ": %s.\n", ddf_dev_get_handle(device),
     104
     105        const int ret = ddf_hcd_device_setup_all(device, USB_SPEED_HIGH,
     106            BANDWIDTH_AVAILABLE_USB20, bandwidth_count_usb11,
     107            ddf_hcd_gen_irq_handler, hc_gen_irq_code,
     108            ehci_driver_init, ehci_driver_fini);
     109        if (ret != EOK) {
     110                usb_log_error("Failed to initialize EHCI driver: %s.\n",
    76111                    str_error(ret));
    77                 return ret;
    78112        }
    79         addr_range_t regs = hw_res.mem_ranges.ranges[0];
    80         const int irq = hw_res.irqs.irqs[0];
    81         hw_res_list_parsed_clean(&hw_res);
    82 
    83         usb_log_info("Memory mapped regs at %p (size %zu), IRQ %d.\n",
    84             RNGABSPTR(regs), RNGSZ(regs), irq);
    85 
    86         ret = disable_legacy(device, &regs);
    87         if (ret != EOK) {
    88                 usb_log_error("Failed to disable legacy USB: %s.\n",
    89                     str_error(ret));
    90                 return ret;
    91         }
    92 
    93         /* High Speed, no bandwidth */
    94         ret = device_setup_ehci(device);
    95         if (ret != EOK) {
    96                 usb_log_error("Failed to init ehci driver: %s\n",
    97                     str_error(ret));
    98                 return ret;
    99         }
    100 
    101         usb_log_info("Controlling new EHCI device `%s' (handle %" PRIun ").\n",
    102             ddf_dev_get_name(device), ddf_dev_get_handle(device));
     113        usb_log_info("Controlling new EHCI device '%s'.\n",
     114            ddf_dev_get_name(device));
    103115
    104116        return EOK;
Note: See TracChangeset for help on using the changeset viewer.