source: mainline/uspace/drv/ehci-hcd/main.c@ f123909

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since f123909 was f123909, checked in by Jan Vesely <jano.vesely@…>, 14 years ago

Doxygen fixes and refactoring.

UHCI root hub driver should be complete (except may be for the BUG)

  • Property mode set to 100644
File size: 3.5 KB
Line 
1/*
2 * Copyright (c) 2011 Jan Vesely
3 * Copyright (c) 2011 Vojtech Horky
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * - Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * - Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * - The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29/** @addtogroup drvusbehci
30 * @{
31 */
32/** @file
33 * Main routines of EHCI driver.
34 */
35#include <ddf/driver.h>
36#include <ddf/interrupt.h>
37#include <device/hw_res.h>
38#include <errno.h>
39#include <str_error.h>
40
41#include <usb_iface.h>
42#include <usb/ddfiface.h>
43#include <usb/debug.h>
44
45#include "pci.h"
46
47#define NAME "ehci-hcd"
48
49static int ehci_add_device(ddf_dev_t *device);
50/*----------------------------------------------------------------------------*/
51static driver_ops_t ehci_driver_ops = {
52 .add_device = ehci_add_device,
53};
54/*----------------------------------------------------------------------------*/
55static driver_t ehci_driver = {
56 .name = NAME,
57 .driver_ops = &ehci_driver_ops
58};
59/*----------------------------------------------------------------------------*/
60/** Initializes a new ddf driver instance of EHCI hcd.
61 *
62 * @param[in] device DDF instance of the device to initialize.
63 * @return Error code.
64 */
65static int ehci_add_device(ddf_dev_t *device)
66{
67 assert(device);
68#define CHECK_RET_RETURN(ret, message...) \
69if (ret != EOK) { \
70 usb_log_error(message); \
71 return ret; \
72}
73
74 usb_log_info("uhci_add_device() called\n");
75
76 uintptr_t mem_reg_base = 0;
77 size_t mem_reg_size = 0;
78 int irq = 0;
79
80 int ret =
81 pci_get_my_registers(device, &mem_reg_base, &mem_reg_size, &irq);
82 CHECK_RET_RETURN(ret,
83 "Failed(%d) to get memory addresses:.\n", ret, device->handle);
84 usb_log_info("Memory mapped regs at 0x%X (size %zu), IRQ %d.\n",
85 mem_reg_base, mem_reg_size, irq);
86
87 ret = pci_disable_legacy(device);
88 CHECK_RET_RETURN(ret,
89 "Failed(%d) disable legacy USB: %s.\n", ret, str_error(ret));
90
91 return EOK;
92#undef CHECK_RET_RETURN
93}
94/*----------------------------------------------------------------------------*/
95/** Initializes global driver structures (NONE).
96 *
97 * @param[in] argc Nmber of arguments in argv vector (ignored).
98 * @param[in] argv Cmdline argument vector (ignored).
99 * @return Error code.
100 *
101 * Driver debug level is set here.
102 */
103int main(int argc, char *argv[])
104{
105 usb_log_enable(USB_LOG_LEVEL_ERROR, NAME);
106 return ddf_driver_main(&ehci_driver);
107}
108/**
109 * @}
110 */
Note: See TracBrowser for help on using the repository browser.