Changeset 9dfb034 in mainline for uspace/drv/bus/usb/ehci/hc.c


Ignore:
Timestamp:
2025-03-04T17:35:28Z (34 hours ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
89b5a75, 94ea2e3
Parents:
77a0119
Message:

Implement quiesce for EHCI and OHCI.

File:
1 edited

Legend:

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

    r77a0119 r9dfb034  
    11/*
     2 * Copyright (c) 2025 Jiri Svoboda
    23 * Copyright (c) 2011 Jan Vesely
    34 * Copyright (c) 2018 Ondrej Hlavaty
     
    212213}
    213214
     215/** Quiesce host controller
     216 *
     217 * @param hcd Host controller device
     218 */
     219int hc_quiesce(hc_device_t *hcd)
     220{
     221        hc_t *instance = hcd_to_hc(hcd);
     222
     223        /*
     224         * Turn off the HC if it's running, Reseting a running device is
     225         * undefined
     226         */
     227        if (!(EHCI_RD(instance->registers->usbsts) & USB_STS_HC_HALTED_FLAG)) {
     228                /* disable all interrupts */
     229                EHCI_WR(instance->registers->usbintr, 0);
     230                /* ack all interrupts */
     231                EHCI_WR(instance->registers->usbsts, 0x3f);
     232                /* Stop HC hw */
     233                EHCI_WR(instance->registers->usbcmd, 0);
     234                /* Wait until hc is halted */
     235                while ((EHCI_RD(instance->registers->usbsts) & USB_STS_HC_HALTED_FLAG) == 0) {
     236                        fibril_usleep(1);
     237                }
     238                usb_log_info("HC(%p): EHCI turned off.", instance);
     239        } else {
     240                usb_log_info("HC(%p): EHCI was not running.", instance);
     241        }
     242
     243        /* Hw initialization sequence, see page 53 (pdf 63) */
     244        EHCI_SET(instance->registers->usbcmd, USB_CMD_HC_RESET_FLAG);
     245        usb_log_info("HC(%p): Waiting for HW reset.", instance);
     246        while (EHCI_RD(instance->registers->usbcmd) & USB_CMD_HC_RESET_FLAG) {
     247                fibril_usleep(1);
     248        }
     249        usb_log_debug("HC(%p): HW reset OK.", instance);
     250
     251        return EOK;
     252}
     253
    214254void hc_enqueue_endpoint(hc_t *instance, const endpoint_t *ep)
    215255{
Note: See TracChangeset for help on using the changeset viewer.