Changeset e4d7363 in mainline for uspace/drv/bus/usb/ehci/res.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/res.c

    rcb89430 re4d7363  
    172172}
    173173
    174 int disable_legacy(ddf_dev_t *device)
     174int disable_legacy(hc_t *hc, ddf_dev_t *device)
    175175{
    176176        assert(device);
     
    183183        usb_log_debug("Disabling EHCI legacy support.\n");
    184184
    185         hw_res_list_parsed_t res;
    186         hw_res_list_parsed_init(&res);
    187         int ret = hw_res_get_list_parsed(parent_sess, &res, 0);
    188         if (ret != EOK) {
    189                 usb_log_error("Failed to get resource list: %s\n",
    190                     str_error(ret));
    191                 goto clean;
    192         }
    193 
    194         if (res.mem_ranges.count < 1) {
    195                 usb_log_error("Incorrect mem range count: %zu",
    196                     res.mem_ranges.count);
    197                 ret = EINVAL;
    198                 goto clean;
    199         }
    200 
    201         /* Map EHCI registers */
    202         void *regs = NULL;
    203         ret = pio_enable_range(&res.mem_ranges.ranges[0], &regs);
    204         if (ret != EOK) {
    205                 usb_log_error("Failed to map registers %p: %s.\n",
    206                     RNGABSPTR(res.mem_ranges.ranges[0]), str_error(ret));
    207                 goto clean;
    208         }
    209 
    210         usb_log_debug("Registers mapped at: %p.\n", regs);
    211 
    212         ehci_caps_regs_t *ehci_caps = regs;
    213 
    214         const uint32_t hcc_params = EHCI_RD(ehci_caps->hccparams);
     185
     186        const uint32_t hcc_params = EHCI_RD(hc->caps->hccparams);
    215187        usb_log_debug2("Value of hcc params register: %x.\n", hcc_params);
    216188
     
    221193        usb_log_debug2("Value of EECP: %x.\n", eecp);
    222194
    223         ret = disable_extended_caps(parent_sess, eecp);
     195        int ret = disable_extended_caps(parent_sess, eecp);
    224196        if (ret != EOK) {
    225197                usb_log_error("Failed to disable extended capabilities: %s.\n",
     
    228200        }
    229201clean:
    230         //TODO unmap registers
    231         hw_res_list_parsed_clean(&res);
    232202        async_hangup(parent_sess);
    233203        return ret;
Note: See TracChangeset for help on using the changeset viewer.