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 | /** @addtogroup usb
|
---|
29 | * @{
|
---|
30 | */
|
---|
31 | /** @file
|
---|
32 | * @brief UHCI driver
|
---|
33 | */
|
---|
34 | #include <ddf/driver.h>
|
---|
35 | #include <errno.h>
|
---|
36 | #include <str_error.h>
|
---|
37 |
|
---|
38 | #include <usb/ddfiface.h>
|
---|
39 | #include <usb/debug.h>
|
---|
40 |
|
---|
41 | #include "iface.h"
|
---|
42 | #include "uhci.h"
|
---|
43 |
|
---|
44 | #define NAME "uhci-hcd"
|
---|
45 |
|
---|
46 | static int uhci_add_device(ddf_dev_t *device);
|
---|
47 | /*----------------------------------------------------------------------------*/
|
---|
48 | static driver_ops_t uhci_driver_ops = {
|
---|
49 | .add_device = uhci_add_device,
|
---|
50 | };
|
---|
51 | /*----------------------------------------------------------------------------*/
|
---|
52 | static driver_t uhci_driver = {
|
---|
53 | .name = NAME,
|
---|
54 | .driver_ops = &uhci_driver_ops
|
---|
55 | };
|
---|
56 | /*----------------------------------------------------------------------------*/
|
---|
57 | /** Initializes a new ddf driver instance for uhci hc and hub.
|
---|
58 | *
|
---|
59 | * @param[in] device DDF instance of the device to initialize.
|
---|
60 | * @return Error code.
|
---|
61 | *
|
---|
62 | * Gets and initialies hardware resources, disables any legacy support,
|
---|
63 | * and reports root hub device.
|
---|
64 | */
|
---|
65 | int uhci_add_device(ddf_dev_t *device)
|
---|
66 | {
|
---|
67 | usb_log_info("uhci_add_device() called\n");
|
---|
68 | assert(device);
|
---|
69 | uhci_t *uhci = malloc(sizeof(uhci_t));
|
---|
70 | if (uhci == NULL) {
|
---|
71 | usb_log_error("Failed to allocate UHCI driver.\n");
|
---|
72 | return ENOMEM;
|
---|
73 | }
|
---|
74 |
|
---|
75 | int ret = uhci_init(uhci, device);
|
---|
76 | if (ret != EOK) {
|
---|
77 | usb_log_error("Failed to initialzie UHCI driver.\n");
|
---|
78 | return ret;
|
---|
79 | }
|
---|
80 | device->driver_data = uhci;
|
---|
81 | return EOK;
|
---|
82 | }
|
---|
83 | /*----------------------------------------------------------------------------*/
|
---|
84 | /** Initializes global driver structures (NONE).
|
---|
85 | *
|
---|
86 | * @param[in] argc Nmber of arguments in argv vector (ignored).
|
---|
87 | * @param[in] argv Cmdline argument vector (ignored).
|
---|
88 | * @return Error code.
|
---|
89 | *
|
---|
90 | * Driver debug level is set here.
|
---|
91 | */
|
---|
92 | int main(int argc, char *argv[])
|
---|
93 | {
|
---|
94 | sleep(3);
|
---|
95 | usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME);
|
---|
96 |
|
---|
97 | return ddf_driver_main(&uhci_driver);
|
---|
98 | }
|
---|
99 | /**
|
---|
100 | * @}
|
---|
101 | */
|
---|