[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 | */
|
---|
[17ceb72] | 28 | /** @addtogroup drvusbuhcihc
|
---|
[c56dbe0] | 29 | * @{
|
---|
| 30 | */
|
---|
| 31 | /** @file
|
---|
[17ceb72] | 32 | * @brief UHCI driver initialization
|
---|
[c56dbe0] | 33 | */
|
---|
[eb1a2f4] | 34 | #include <ddf/driver.h>
|
---|
[c56dbe0] | 35 | #include <errno.h>
|
---|
[ab414a6] | 36 | #include <str_error.h>
|
---|
[c56dbe0] | 37 |
|
---|
[ab414a6] | 38 | #include <usb/ddfiface.h>
|
---|
[afcd86e] | 39 | #include <usb/debug.h>
|
---|
| 40 |
|
---|
[9351353] | 41 | #include "uhci.h"
|
---|
[c7137738] | 42 |
|
---|
[497b6f31] | 43 | #define NAME "uhci"
|
---|
[afcd86e] | 44 |
|
---|
[eb1a2f4] | 45 | static int uhci_add_device(ddf_dev_t *device);
|
---|
[36a4738] | 46 | /*----------------------------------------------------------------------------*/
|
---|
| 47 | static driver_ops_t uhci_driver_ops = {
|
---|
| 48 | .add_device = uhci_add_device,
|
---|
| 49 | };
|
---|
| 50 | /*----------------------------------------------------------------------------*/
|
---|
| 51 | static driver_t uhci_driver = {
|
---|
| 52 | .name = NAME,
|
---|
| 53 | .driver_ops = &uhci_driver_ops
|
---|
| 54 | };
|
---|
| 55 | /*----------------------------------------------------------------------------*/
|
---|
[17ceb72] | 56 | /** Initialize a new ddf driver instance for uhci hc and hub.
|
---|
[a7e2f0d] | 57 | *
|
---|
| 58 | * @param[in] device DDF instance of the device to initialize.
|
---|
| 59 | * @return Error code.
|
---|
| 60 | */
|
---|
| 61 | int uhci_add_device(ddf_dev_t *device)
|
---|
[86341e2] | 62 | {
|
---|
[ea993d18] | 63 | usb_log_debug2("uhci_add_device() called\n");
|
---|
[9351353] | 64 | assert(device);
|
---|
[ea993d18] | 65 |
|
---|
[5d915b7] | 66 | const int ret = device_setup_uhci(device);
|
---|
[b375bb8] | 67 | if (ret != EOK) {
|
---|
[4125b7d] | 68 | usb_log_error("Failed to initialize UHCI driver: %s.\n",
|
---|
| 69 | str_error(ret));
|
---|
[5d915b7] | 70 | } else {
|
---|
| 71 | usb_log_info("Controlling new UHCI device '%s'.\n",
|
---|
| 72 | device->name);
|
---|
[b375bb8] | 73 | }
|
---|
[fbefd0e] | 74 |
|
---|
[5d915b7] | 75 | return ret;
|
---|
[c7137738] | 76 | }
|
---|
[36a4738] | 77 | /*----------------------------------------------------------------------------*/
|
---|
[17ceb72] | 78 | /** Initialize global driver structures (NONE).
|
---|
[a7e2f0d] | 79 | *
|
---|
[ea993d18] | 80 | * @param[in] argc Number of arguments in argv vector (ignored).
|
---|
[a7e2f0d] | 81 | * @param[in] argv Cmdline argument vector (ignored).
|
---|
| 82 | * @return Error code.
|
---|
| 83 | *
|
---|
| 84 | * Driver debug level is set here.
|
---|
| 85 | */
|
---|
[c7137738] | 86 | int main(int argc, char *argv[])
|
---|
| 87 | {
|
---|
[fbefd0e] | 88 | printf(NAME ": HelenOS UHCI driver.\n");
|
---|
[215b001] | 89 | usb_log_enable(USB_LOG_LEVEL_DEFAULT, NAME);
|
---|
[c7137738] | 90 |
|
---|
[eb1a2f4] | 91 | return ddf_driver_main(&uhci_driver);
|
---|
[c7137738] | 92 | }
|
---|
[c56dbe0] | 93 | /**
|
---|
| 94 | * @}
|
---|
| 95 | */
|
---|