Changeset e4d7363 in mainline for uspace/drv/bus/usb/ehci/main.c


Ignore:
Timestamp:
2017-06-22T21:34:39Z (7 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
91ca111
Parents:
cb89430
Message:

usbhost: refactor the initialization

Before that, drivers had to setup MMIO range multiple times, or even parse hw
resources themselves again. The former init method was split in half - init and
start. Init shall allocate and initialize inner structures, start shall start
the HC.

In the XHCI it is demonstrated how to isolate inner HC implementation from the
fact this driver is using libusbhost. It adds some boilerplate code, but
I think it leads to cleaner design.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ehci/main.c

    rcb89430 re4d7363  
    5252#define NAME "ehci"
    5353
    54 static int ehci_driver_init(hcd_t *, const hw_res_list_parsed_t *, bool);
     54static int ehci_driver_init(hcd_t *, const hw_res_list_parsed_t *);
     55static int ehci_driver_claim(hcd_t *, ddf_dev_t *);
     56static int ehci_driver_start(hcd_t *, bool);
    5557static void ehci_driver_fini(hcd_t *);
    5658
    5759static const ddf_hc_driver_t ehci_hc_driver = {
    58         .claim = disable_legacy,
    5960        .hc_speed = USB_SPEED_HIGH,
     61        .name = "EHCI-PCI",
     62        .init = ehci_driver_init,
    6063        .irq_code_gen = ehci_hc_gen_irq_code,
    61         .init = ehci_driver_init,
     64        .claim = ehci_driver_claim,
     65        .start = ehci_driver_start,
    6266        .fini = ehci_driver_fini,
    63         .name = "EHCI-PCI",
    6467        .ops = {
    6568                .schedule       = ehci_hc_schedule,
     
    7275
    7376
    74 static int ehci_driver_init(hcd_t *hcd, const hw_res_list_parsed_t *res,
    75     bool irq)
     77static int ehci_driver_init(hcd_t *hcd, const hw_res_list_parsed_t *res)
    7678{
    7779        assert(hcd);
     
    8284                return ENOMEM;
    8385
    84         const int ret = hc_init(instance, res, irq);
     86        const int ret = hc_init(instance, res);
    8587        if (ret == EOK) {
    8688                hcd_set_implementation(hcd, instance, &ehci_hc_driver.ops);
     
    8991        }
    9092        return ret;
     93}
     94
     95static int ehci_driver_claim(hcd_t *hcd, ddf_dev_t *dev)
     96{
     97        hc_t *instance = hcd_get_driver_data(hcd);
     98        assert(instance);
     99
     100        return disable_legacy(instance, dev);
     101}
     102
     103static int ehci_driver_start(hcd_t *hcd, bool irq) {
     104        hc_t *instance = hcd_get_driver_data(hcd);
     105        assert(instance);
     106
     107        return hc_start(instance, irq);
    91108}
    92109
Note: See TracChangeset for help on using the changeset viewer.