source: mainline/uspace/drv/bus/usb/uhci/main.c

Last change on this file was 8300c72, checked in by Jiri Svoboda <jiri@…>, 4 months ago

Quiesce devices before proceeding with shutdown.

Only implemented for e1k, uhci and xhci.

  • Property mode set to 100644
File size: 3.1 KB
RevLine 
[c7137738]1/*
[8300c72]2 * Copyright (c) 2025 Jiri Svoboda
[c56dbe0]3 * Copyright (c) 2011 Vojtech Horky, Jan Vesely
[e0a5d4c]4 * Copyright (c) 2018 Ondrej Hlavaty, Petr Manek
[c7137738]5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * - Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * - Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * - The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
[58563585]30
[e3a07bba]31/** @addtogroup drvusbuhci
[c56dbe0]32 * @{
33 */
34/** @file
[17ceb72]35 * @brief UHCI driver initialization
[c56dbe0]36 */
[8064c2f6]37
38#include <assert.h>
[eb1a2f4]39#include <ddf/driver.h>
[c56dbe0]40#include <errno.h>
[8064c2f6]41#include <io/log.h>
[b74ec299]42#include <io/logctl.h>
[e3a07bba]43#include <pci_dev_iface.h>
[8064c2f6]44#include <stdio.h>
[ab414a6]45#include <str_error.h>
[afcd86e]46#include <usb/debug.h>
[944f8fdd]47#include <usb/host/utility.h>
[afcd86e]48
[1a0fa29c]49#include "hc.h"
[c7137738]50
[497b6f31]51#define NAME "uhci"
[afcd86e]52
[5a6cc679]53static errno_t disable_legacy(hc_device_t *);
[76fbd9a]54
[32fb6bce]55static const hc_driver_t uhci_driver = {
56 .name = NAME,
57 .hc_device_size = sizeof(hc_t),
58 .claim = disable_legacy,
59 .irq_code_gen = hc_gen_irq_code,
60 .hc_add = hc_add,
61 .start = hc_start,
[129b821f]62 .setup_root_hub = hc_setup_roothub,
[32fb6bce]63 .hc_gone = hc_gone,
[8300c72]64 .hc_quiesce = hc_quiesce
[36a4738]65};
[76fbd9a]66
[e3a07bba]67/** Call the PCI driver with a request to clear legacy support register
68 *
69 * @param[in] device Device asking to disable interrupts
70 * @return Error code.
71 */
[5a6cc679]72static errno_t disable_legacy(hc_device_t *hcd)
[e3a07bba]73{
[32fb6bce]74 assert(hcd);
[e3a07bba]75
[32fb6bce]76 async_sess_t *parent_sess = ddf_dev_parent_sess_get(hcd->ddf_dev);
[d15797d]77 if (parent_sess == NULL)
[e3a07bba]78 return ENOMEM;
79
[7c3fb9b]80 /*
81 * See UHCI design guide page 45 for these values.
82 * Write all WC bits in USB legacy register
83 */
[53a309e]84 return pci_config_space_write_16(parent_sess, 0xc0, 0xaf00);
[e3a07bba]85}
[76fbd9a]86
[17ceb72]87/** Initialize global driver structures (NONE).
[a7e2f0d]88 *
[ea993d18]89 * @param[in] argc Number of arguments in argv vector (ignored).
[a7e2f0d]90 * @param[in] argv Cmdline argument vector (ignored).
91 * @return Error code.
92 *
93 * Driver debug level is set here.
94 */
[c7137738]95int main(int argc, char *argv[])
96{
[fbefd0e]97 printf(NAME ": HelenOS UHCI driver.\n");
[920d0fc]98 log_init(NAME);
[8ad2b0a]99 logctl_set_log_level(NAME, LVL_NOTE);
[32fb6bce]100 return hc_driver_main(&uhci_driver);
[c7137738]101}
[c56dbe0]102/**
103 * @}
104 */
Note: See TracBrowser for help on using the repository browser.