source: mainline/uspace/drv/bus/usb/xhci/main.c@ 47b2d7e3

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

usb: decrease and unify verbosity of HC drivers to LVL_NOTE

  • Property mode set to 100644
File size: 3.3 KB
Line 
1/*
2 * Copyright (c) 2018 Ondrej Hlavaty, Petr Manek
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 drvusbxhci
30 * @{
31 */
32/** @file
33 * Main routines of XHCI driver.
34 */
35
36#include <ddf/driver.h>
37#include <errno.h>
38#include <io/log.h>
39#include <io/logctl.h>
40#include <usb/debug.h>
41#include <usb/host/ddf_helpers.h>
42
43#include "hc.h"
44#include "rh.h"
45#include "endpoint.h"
46
47#define NAME "xhci"
48
49static inline xhci_hc_t *hcd_to_hc(hc_device_t *hcd)
50{
51 assert(hcd);
52 return (xhci_hc_t *) hcd;
53}
54
55static errno_t hcd_hc_add(hc_device_t *hcd, const hw_res_list_parsed_t *hw_res)
56{
57 errno_t err;
58 xhci_hc_t *hc = hcd_to_hc(hcd);
59 hc_device_setup(hcd, (bus_t *) &hc->bus);
60
61 if ((err = hc_init_mmio(hc, hw_res)))
62 return err;
63
64 if ((err = hc_init_memory(hc, hcd->ddf_dev)))
65 return err;
66
67 return EOK;
68}
69
70static errno_t hcd_irq_code_gen(irq_code_t *code, hc_device_t *hcd,
71 const hw_res_list_parsed_t *hw_res, int *irq)
72{
73 xhci_hc_t *hc = hcd_to_hc(hcd);
74 return hc_irq_code_gen(code, hc, hw_res, irq);
75}
76
77static errno_t hcd_claim(hc_device_t *hcd)
78{
79 xhci_hc_t *hc = hcd_to_hc(hcd);
80 return hc_claim(hc, hcd->ddf_dev);
81}
82
83static errno_t hcd_start(hc_device_t *hcd)
84{
85 xhci_hc_t *hc = hcd_to_hc(hcd);
86 return hc_start(hc);
87}
88
89static errno_t hcd_hc_gone(hc_device_t *hcd)
90{
91 xhci_hc_t *hc = hcd_to_hc(hcd);
92 hc_fini(hc);
93 return EOK;
94}
95
96static const hc_driver_t xhci_driver = {
97 .name = NAME,
98 .hc_device_size = sizeof(xhci_hc_t),
99
100 .hc_add = hcd_hc_add,
101 .irq_code_gen = hcd_irq_code_gen,
102 .claim = hcd_claim,
103 .start = hcd_start,
104 .hc_gone = hcd_hc_gone,
105};
106
107/** Initializes global driver structures (NONE).
108 *
109 * @param[in] argc Nmber of arguments in argv vector (ignored).
110 * @param[in] argv Cmdline argument vector (ignored).
111 * @return Error code.
112 *
113 * Driver debug level is set here.
114 */
115errno_t main(int argc, char *argv[])
116{
117 log_init(NAME);
118 logctl_set_log_level(NAME, LVL_NOTE);
119 return hc_driver_main(&xhci_driver);
120}
121
122/**
123 * @}
124 */
Note: See TracBrowser for help on using the repository browser.