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

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

usb: decrease and unify verbosity of HC drivers to LVL_NOTE

  • Property mode set to 100644
File size: 3.3 KB
RevLine 
[5119d34]1/*
[e0a5d4c]2 * Copyright (c) 2018 Ondrej Hlavaty, Petr Manek
[5119d34]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>
[5cbccd4]41#include <usb/host/ddf_helpers.h>
42
43#include "hc.h"
[867b375]44#include "rh.h"
[c0ec9e7]45#include "endpoint.h"
[5119d34]46
47#define NAME "xhci"
48
[32fb6bce]49static inline xhci_hc_t *hcd_to_hc(hc_device_t *hcd)
50{
51 assert(hcd);
52 return (xhci_hc_t *) hcd;
53}
[e4d7363]54
[45457265]55static errno_t hcd_hc_add(hc_device_t *hcd, const hw_res_list_parsed_t *hw_res)
[e4d7363]56{
[45457265]57 errno_t err;
[32fb6bce]58 xhci_hc_t *hc = hcd_to_hc(hcd);
59 hc_device_setup(hcd, (bus_t *) &hc->bus);
[e4d7363]60
61 if ((err = hc_init_mmio(hc, hw_res)))
[32fb6bce]62 return err;
[e4d7363]63
[32fb6bce]64 if ((err = hc_init_memory(hc, hcd->ddf_dev)))
65 return err;
[e4d7363]66
67 return EOK;
68}
69
[ae3a941]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)
[e4d7363]72{
[32fb6bce]73 xhci_hc_t *hc = hcd_to_hc(hcd);
[132ab5d1]74 return hc_irq_code_gen(code, hc, hw_res, irq);
[e4d7363]75}
76
[45457265]77static errno_t hcd_claim(hc_device_t *hcd)
[e4d7363]78{
[32fb6bce]79 xhci_hc_t *hc = hcd_to_hc(hcd);
80 return hc_claim(hc, hcd->ddf_dev);
[e4d7363]81}
82
[45457265]83static errno_t hcd_start(hc_device_t *hcd)
[e4d7363]84{
[32fb6bce]85 xhci_hc_t *hc = hcd_to_hc(hcd);
[19f0048]86 return hc_start(hc);
[e4d7363]87}
88
[45457265]89static errno_t hcd_hc_gone(hc_device_t *hcd)
[e4d7363]90{
[32fb6bce]91 xhci_hc_t *hc = hcd_to_hc(hcd);
[e4d7363]92 hc_fini(hc);
[32fb6bce]93 return EOK;
[d37514e]94}
[5119d34]95
[32fb6bce]96static const hc_driver_t xhci_driver = {
[5119d34]97 .name = NAME,
[32fb6bce]98 .hc_device_size = sizeof(xhci_hc_t),
[5119d34]99
[32fb6bce]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};
[5119d34]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 */
[45457265]115errno_t main(int argc, char *argv[])
[5119d34]116{
117 log_init(NAME);
[b2dca8de]118 logctl_set_log_level(NAME, LVL_NOTE);
[32fb6bce]119 return hc_driver_main(&xhci_driver);
[5119d34]120}
121
122/**
123 * @}
124 */
Note: See TracBrowser for help on using the repository browser.