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

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 0539c14 was 5a6cc679, checked in by Jenda <jenda.jzqk73@…>, 8 years ago

Merge commit '50f19b7ee8e94570b5c63896736c4eb49cfa18db' into forwardport

Not all ints are converted to errno_t in xhci tree yet, however it compiles and works :)

  • Property mode set to 100644
File size: 3.0 KB
RevLine 
[c7137738]1/*
[c56dbe0]2 * Copyright (c) 2011 Vojtech Horky, Jan Vesely
[c7137738]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 */
[58563585]28
[e3a07bba]29/** @addtogroup drvusbuhci
[c56dbe0]30 * @{
31 */
32/** @file
[17ceb72]33 * @brief UHCI driver initialization
[c56dbe0]34 */
[8064c2f6]35
36#include <assert.h>
[eb1a2f4]37#include <ddf/driver.h>
[c56dbe0]38#include <errno.h>
[8064c2f6]39#include <io/log.h>
[b74ec299]40#include <io/logctl.h>
[e3a07bba]41#include <pci_dev_iface.h>
[8064c2f6]42#include <stdio.h>
[ab414a6]43#include <str_error.h>
[afcd86e]44#include <usb/debug.h>
[944f8fdd]45#include <usb/host/utility.h>
[afcd86e]46
[1a0fa29c]47#include "hc.h"
[c7137738]48
[497b6f31]49#define NAME "uhci"
[afcd86e]50
[5a6cc679]51static errno_t disable_legacy(hc_device_t *);
[76fbd9a]52
[32fb6bce]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,
[129b821f]60 .setup_root_hub = hc_setup_roothub,
[32fb6bce]61 .hc_gone = hc_gone,
[36a4738]62};
[76fbd9a]63
[e3a07bba]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 */
[5a6cc679]69static errno_t disable_legacy(hc_device_t *hcd)
[e3a07bba]70{
[32fb6bce]71 assert(hcd);
[e3a07bba]72
[32fb6bce]73 async_sess_t *parent_sess = ddf_dev_parent_sess_get(hcd->ddf_dev);
[d15797d]74 if (parent_sess == NULL)
[e3a07bba]75 return ENOMEM;
76
77 /* See UHCI design guide page 45 for these values.
78 * Write all WC bits in USB legacy register */
[53a309e]79 return pci_config_space_write_16(parent_sess, 0xc0, 0xaf00);
[e3a07bba]80}
[76fbd9a]81
[17ceb72]82/** Initialize global driver structures (NONE).
[a7e2f0d]83 *
[ea993d18]84 * @param[in] argc Number of arguments in argv vector (ignored).
[a7e2f0d]85 * @param[in] argv Cmdline argument vector (ignored).
86 * @return Error code.
87 *
88 * Driver debug level is set here.
89 */
[c7137738]90int main(int argc, char *argv[])
91{
[fbefd0e]92 printf(NAME ": HelenOS UHCI driver.\n");
[920d0fc]93 log_init(NAME);
[8ad2b0a]94 logctl_set_log_level(NAME, LVL_NOTE);
[32fb6bce]95 return hc_driver_main(&uhci_driver);
[c7137738]96}
[c56dbe0]97/**
98 * @}
99 */
Note: See TracBrowser for help on using the repository browser.