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

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since ee0ffa6 was 129b821f, checked in by Ondřej Hlavatý <aearsis@…>, 8 years ago

usbhub: be aware of its own speed

This resulted in a bunch of changes just because the roothubs in older
HC's are virtual, and need to be aware of their own speed too.

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