Changeset df6ded8 in mainline for uspace/drv/bus/usb/ehci/res.c


Ignore:
Timestamp:
2018-02-28T16:37:50Z (6 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1b20da0
Parents:
f5e5f73 (diff), b2dca8de (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.
git-author:
Jakub Jermar <jakub@…> (2018-02-28 16:06:42)
git-committer:
Jakub Jermar <jakub@…> (2018-02-28 16:37:50)
Message:

Merge github.com:helenos-xhci-team/helenos

This commit merges support for USB 3 and generally refactors, fixes,
extends and cleans up the existing USB framework.

Notable additions and features:

  • new host controller driver has been implemented to control various xHC models (among others, NEC Renesas uPD720200)
  • isochronous data transfer mode
  • support for explicit USB device removal
  • USB tablet driver
File:
1 edited

Legend:

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

    rf5e5f73 rdf6ded8  
    11/*
    22 * Copyright (c) 2011 Jan Vesely
     3 * Copyright (c) 2018 Ondrej Hlavaty
    34 * All rights reserved.
    45 *
     
    4546#include <pci_dev_iface.h>
    4647
     48#include "hc.h"
    4749#include "res.h"
    4850#include "ehci_regs.h"
     
    7375            eecp + USBLEGSUP_OFFSET, &usblegsup);
    7476        if (ret != EOK) {
    75                 usb_log_error("Failed to read USBLEGSUP: %s.\n", str_error(ret));
    76                 return ret;
    77         }
    78         usb_log_debug2("USBLEGSUP: %" PRIx32 ".\n", usblegsup);
     77                usb_log_error("Failed to read USBLEGSUP: %s.", str_error(ret));
     78                return ret;
     79        }
     80        usb_log_debug2("USBLEGSUP: %" PRIx32 ".", usblegsup);
    7981
    8082        /* Request control from firmware/BIOS by writing 1 to highest
    8183         * byte. (OS Control semaphore)*/
    82         usb_log_debug("Requesting OS control.\n");
     84        usb_log_debug("Requesting OS control.");
    8385        ret = pci_config_space_write_8(parent_sess,
    8486            eecp + USBLEGSUP_OFFSET + 3, 1);
    8587        if (ret != EOK) {
    86                 usb_log_error("Failed to request OS EHCI control: %s.\n",
     88                usb_log_error("Failed to request OS EHCI control: %s.",
    8789                    str_error(ret));
    8890                return ret;
     
    102104
    103105        if ((usblegsup & USBLEGSUP_BIOS_CONTROL) == 0) {
    104                 usb_log_info("BIOS released control after %zu usec.\n", wait);
     106                usb_log_info("BIOS released control after %zu usec.", wait);
    105107                return EOK;
    106108        }
     
    108110        /* BIOS failed to hand over control, this should not happen. */
    109111        usb_log_warning( "BIOS failed to release control after "
    110             "%zu usecs, force it.\n", wait);
     112            "%zu usecs, force it.", wait);
    111113        ret = pci_config_space_write_32(parent_sess,
    112114            eecp + USBLEGSUP_OFFSET, USBLEGSUP_OS_CONTROL);
    113115        if (ret != EOK) {
    114                 usb_log_error("Failed to force OS control: %s.\n",
     116                usb_log_error("Failed to force OS control: %s.",
    115117                    str_error(ret));
    116118                return ret;
     
    129131                    eecp + USBLEGCTLSTS_OFFSET, &usblegctlsts);
    130132                if (ret != EOK) {
    131                         usb_log_error("Failed to get USBLEGCTLSTS: %s.\n",
     133                        usb_log_error("Failed to get USBLEGCTLSTS: %s.",
    132134                            str_error(ret));
    133135                        return ret;
    134136                }
    135                 usb_log_debug2("USBLEGCTLSTS: %" PRIx32 ".\n", usblegctlsts);
     137                usb_log_debug2("USBLEGCTLSTS: %" PRIx32 ".", usblegctlsts);
    136138                /*
    137139                 * Zero SMI enables in legacy control register.
     
    142144                    eecp + USBLEGCTLSTS_OFFSET, 0xe0000000);
    143145                if (ret != EOK) {
    144                         usb_log_error("Failed to zero USBLEGCTLSTS: %s\n",
     146                        usb_log_error("Failed to zero USBLEGCTLSTS: %s",
    145147                            str_error(ret));
    146148                        return ret;
     
    152154                    eecp + USBLEGCTLSTS_OFFSET, &usblegctlsts);
    153155                if (ret != EOK) {
    154                         usb_log_error("Failed to get USBLEGCTLSTS 2: %s.\n",
     156                        usb_log_error("Failed to get USBLEGCTLSTS 2: %s.",
    155157                            str_error(ret));
    156158                        return ret;
    157159                }
    158                 usb_log_debug2("Zeroed USBLEGCTLSTS: %" PRIx32 ".\n",
     160                usb_log_debug2("Zeroed USBLEGCTLSTS: %" PRIx32 ".",
    159161                    usblegctlsts);
    160162        }
     
    164166            eecp + USBLEGSUP_OFFSET, &usblegsup);
    165167        if (ret != EOK) {
    166                 usb_log_error("Failed to read USBLEGSUP: %s.\n",
    167                     str_error(ret));
    168                 return ret;
    169         }
    170         usb_log_debug2("USBLEGSUP: %" PRIx32 ".\n", usblegsup);
     168                usb_log_error("Failed to read USBLEGSUP: %s.",
     169                    str_error(ret));
     170                return ret;
     171        }
     172        usb_log_debug2("USBLEGSUP: %" PRIx32 ".", usblegsup);
    171173        return ret;
    172174}
    173175
    174 errno_t disable_legacy(ddf_dev_t *device)
     176errno_t disable_legacy(hc_device_t *hcd)
    175177{
    176         assert(device);
    177 
    178         async_sess_t *parent_sess = ddf_dev_parent_sess_get(device);
     178        hc_t *hc = hcd_to_hc(hcd);
     179
     180        async_sess_t *parent_sess = ddf_dev_parent_sess_get(hcd->ddf_dev);
    179181        if (parent_sess == NULL)
    180182                return ENOMEM;
    181183
    182         usb_log_debug("Disabling EHCI legacy support.\n");
    183 
    184         hw_res_list_parsed_t res;
    185         hw_res_list_parsed_init(&res);
    186         errno_t ret = hw_res_get_list_parsed(parent_sess, &res, 0);
    187         if (ret != EOK) {
    188                 usb_log_error("Failed to get resource list: %s\n",
    189                     str_error(ret));
    190                 goto clean;
    191         }
    192 
    193         if (res.mem_ranges.count < 1) {
    194                 usb_log_error("Incorrect mem range count: %zu",
    195                     res.mem_ranges.count);
    196                 ret = EINVAL;
    197                 goto clean;
    198         }
    199 
    200         /* Map EHCI registers */
    201         void *regs = NULL;
    202         ret = pio_enable_range(&res.mem_ranges.ranges[0], &regs);
    203         if (ret != EOK) {
    204                 usb_log_error("Failed to map registers %p: %s.\n",
    205                     RNGABSPTR(res.mem_ranges.ranges[0]), str_error(ret));
    206                 goto clean;
    207         }
    208 
    209         usb_log_debug("Registers mapped at: %p.\n", regs);
    210 
    211         ehci_caps_regs_t *ehci_caps = regs;
    212 
    213         const uint32_t hcc_params = EHCI_RD(ehci_caps->hccparams);
    214         usb_log_debug2("Value of hcc params register: %x.\n", hcc_params);
     184        usb_log_debug("Disabling EHCI legacy support.");
     185
     186        const uint32_t hcc_params = EHCI_RD(hc->caps->hccparams);
     187        usb_log_debug2("Value of hcc params register: %x.", hcc_params);
    215188
    216189        /* Read value of EHCI Extended Capabilities Pointer
     
    218191        const uint32_t eecp =
    219192            (hcc_params >> EHCI_CAPS_HCC_EECP_SHIFT) & EHCI_CAPS_HCC_EECP_MASK;
    220         usb_log_debug2("Value of EECP: %x.\n", eecp);
    221 
    222         ret = disable_extended_caps(parent_sess, eecp);
    223         if (ret != EOK) {
    224                 usb_log_error("Failed to disable extended capabilities: %s.\n",
     193        usb_log_debug2("Value of EECP: %x.", eecp);
     194
     195        int ret = disable_extended_caps(parent_sess, eecp);
     196        if (ret != EOK) {
     197                usb_log_error("Failed to disable extended capabilities: %s.",
    225198                    str_error(ret));
    226199                    goto clean;
    227200        }
    228201clean:
    229         //TODO unmap registers
    230         hw_res_list_parsed_clean(&res);
     202        async_hangup(parent_sess);
    231203        return ret;
    232204}
Note: See TracChangeset for help on using the changeset viewer.