Changeset 8300c72 in mainline for uspace/drv/bus


Ignore:
Timestamp:
2025-03-03T22:58:05Z (8 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
77a0119
Parents:
f35749e
Message:

Quiesce devices before proceeding with shutdown.

Only implemented for e1k, uhci and xhci.

Location:
uspace/drv/bus/usb
Files:
6 edited

Legend:

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

    rf35749e r8300c72  
    11/*
     2 * Copyright (c) 2025 Jiri Svoboda
    23 * Copyright (c) 2011 Jan Vesely
    34 * Copyright (c) 2018 Ondrej Hlavaty, Petr Manek
     
    267268}
    268269
     270/** Quiesce host controller.
     271 *
     272 * @param[in] instance Host controller structure to use.
     273 */
     274int hc_quiesce(hc_device_t *hcd)
     275{
     276        hc_t *instance = hcd_to_hc(hcd);
     277        uhci_regs_t *registers = instance->registers;
     278
     279        /* Reset everything, who knows what touched it before us */
     280        pio_write_16(&registers->usbcmd, UHCI_CMD_GLOBAL_RESET);
     281        fibril_usleep(50000); /* 50ms according to USB spec(root hub reset) */
     282        pio_write_16(&registers->usbcmd, 0);
     283
     284        /* Reset hc, all states and counters. Hope that hw is not broken */
     285        pio_write_16(&registers->usbcmd, UHCI_CMD_HCRESET);
     286        do {
     287                fibril_usleep(10);
     288        } while ((pio_read_16(&registers->usbcmd) & UHCI_CMD_HCRESET) != 0);
     289
     290        return EOK;
     291}
     292
    269293/** Initialize UHCI hc hw resources.
    270294 *
  • uspace/drv/bus/usb/uhci/hc.h

    rf35749e r8300c72  
    11/*
     2 * Copyright (c) 2025 Jiri Svoboda
    23 * Copyright (c) 2011 Jan Vesely
    34 * Copyright (c) 2018 Ondrej Hlavaty
     
    164165extern errno_t hc_setup_roothub(hc_device_t *);
    165166extern errno_t hc_gone(hc_device_t *);
     167extern errno_t hc_quiesce(hc_device_t *);
    166168
    167169#endif
  • uspace/drv/bus/usb/uhci/main.c

    rf35749e r8300c72  
    11/*
     2 * Copyright (c) 2025 Jiri Svoboda
    23 * Copyright (c) 2011 Vojtech Horky, Jan Vesely
    34 * Copyright (c) 2018 Ondrej Hlavaty, Petr Manek
     
    6162        .setup_root_hub = hc_setup_roothub,
    6263        .hc_gone = hc_gone,
     64        .hc_quiesce = hc_quiesce
    6365};
    6466
  • uspace/drv/bus/usb/xhci/hc.c

    rf35749e r8300c72  
    11/*
     2 * Copyright (c) 2025 Jiri Svoboda
    23 * Copyright (c) 2018 Ondrej Hlavaty, Petr Manek, Jaroslav Jindrak, Jan Hrach, Michal Staruch
    34 * All rights reserved.
     
    746747}
    747748
     749/**
     750 * Quiesce host controller.
     751 */
     752errno_t hc_quiesce(xhci_hc_t *hc)
     753{
     754        hc_stop(hc);
     755        usb_log_info("HC quiesced.");
     756        return EOK;
     757}
     758
    748759unsigned hc_speed_to_psiv(usb_speed_t speed)
    749760{
  • uspace/drv/bus/usb/xhci/hc.h

    rf35749e r8300c72  
    11/*
     2 * Copyright (c) 2025 Jiri Svoboda
    23 * Copyright (c) 2018 Ondrej Hlavaty, Jan Hrach, Jaroslav Jindrak, Petr Manek
    34 * All rights reserved.
     
    119120extern errno_t hc_start(xhci_hc_t *);
    120121extern void hc_fini(xhci_hc_t *);
     122extern errno_t hc_quiesce(xhci_hc_t *);
    121123
    122124extern void hc_ring_doorbell(xhci_hc_t *, unsigned, unsigned);
  • uspace/drv/bus/usb/xhci/main.c

    rf35749e r8300c72  
    11/*
     2 * Copyright (c) 2025 Jiri Svoboda
    23 * Copyright (c) 2018 Ondrej Hlavaty, Petr Manek
    34 * All rights reserved.
     
    9495}
    9596
     97static errno_t hcd_hc_quiesce(hc_device_t *hcd)
     98{
     99        xhci_hc_t *hc = hcd_to_hc(hcd);
     100        hc_quiesce(hc);
     101        return EOK;
     102}
     103
    96104static const hc_driver_t xhci_driver = {
    97105        .name = NAME,
     
    103111        .start = hcd_start,
    104112        .hc_gone = hcd_hc_gone,
     113        .hc_quiesce = hcd_hc_quiesce
    105114};
    106115
Note: See TracChangeset for help on using the changeset viewer.