Changeset 9dfb034 in mainline


Ignore:
Timestamp:
2025-03-04T17:35:28Z (24 hours ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Parents:
77a0119
Message:

Implement quiesce for EHCI and OHCI.

Location:
uspace/drv/bus/usb
Files:
6 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{
  • uspace/drv/bus/usb/ehci/hc.h

    r77a0119 r9dfb034  
    11/*
     2 * Copyright (c) 2025 Jiri Svoboda
    23 * Copyright (c) 2011 Jan Vesely
    34 * Copyright (c) 2018 Ondrej Hlavaty
     
    107108    const hw_res_list_parsed_t *, int *);
    108109extern errno_t hc_gone(hc_device_t *);
     110extern errno_t hc_quiesce(hc_device_t *);
    109111
    110112/** Runtime operations */
  • uspace/drv/bus/usb/ehci/main.c

    r77a0119 r9dfb034  
    11/*
     2 * Copyright (c) 2025 Jiri Svoboda
    23 * Copyright (c) 2011 Jan Vesely
    34 * Copyright (c) 2011 Vojtech Horky
     
    5455        .setup_root_hub = hc_setup_roothub,
    5556        .hc_gone = hc_gone,
     57        .hc_quiesce = hc_quiesce
    5658};
    5759
  • uspace/drv/bus/usb/ohci/hc.c

    r77a0119 r9dfb034  
    11/*
     2 * Copyright (c) 2025 Jiri Svoboda
    23 * Copyright (c) 2011 Jan Vesely
    34 * Copyright (c) 2018 Ondrej Hlavaty
     
    196197}
    197198
     199/** Quiesce host controller
     200 *
     201 * @param hcd Host controller device
     202 */
     203int hc_quiesce(hc_device_t *hcd)
     204{
     205        hc_t *instance = hcd_to_hc(hcd);
     206
     207        /* OHCI guide page 42 */
     208        usb_log_debug2("Started hc initialization routine.");
     209
     210        /* Reset hc */
     211        usb_log_debug2("HC reset.");
     212        size_t time = 0;
     213        OHCI_WR(instance->registers->command_status, CS_HCR);
     214        while (OHCI_RD(instance->registers->command_status) & CS_HCR) {
     215                fibril_usleep(10);
     216                time += 10;
     217        }
     218        usb_log_debug2("HC reset complete in %zu us.", time);
     219
     220        return EOK;
     221}
     222
    198223void hc_enqueue_endpoint(hc_t *instance, const endpoint_t *ep)
    199224{
  • uspace/drv/bus/usb/ohci/hc.h

    r77a0119 r9dfb034  
    11/*
     2 * Copyright (c) 2025 Jiri Svoboda
    23 * Copyright (c) 2011 Jan Vesely
    34 * Copyright (c) 2018 Ondrej Hlavaty
     
    9798extern errno_t hc_setup_roothub(hc_device_t *);
    9899extern errno_t hc_gone(hc_device_t *);
     100extern errno_t hc_quiesce(hc_device_t *);
    99101
    100102extern void hc_enqueue_endpoint(hc_t *, const endpoint_t *);
  • uspace/drv/bus/usb/ohci/main.c

    r77a0119 r9dfb034  
    11/*
     2 * Copyright (c) 2025 Jiri Svoboda
    23 * Copyright (c) 2011 Jan Vesely
    34 * Copyright (c) 2011 Vojtech Horky
     
    6061        .setup_root_hub = hc_setup_roothub,
    6162        .hc_gone = hc_gone,
     63        .hc_quiesce = hc_quiesce
    6264};
    6365
Note: See TracChangeset for help on using the changeset viewer.