source: mainline/uspace/drv/uhci-rhd/main.c@ 4e38d69

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

Fixes: set tracker speed in init

changes debug level

  • Property mode set to 100644
File size: 3.1 KB
RevLine 
[816175a2]1/*
[c56dbe0]2 * Copyright (c) 2011 Vojtech Horky, Jan Vesely
[816175a2]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 */
[c56dbe0]28/** @addtogroup usb
29 * @{
30 */
31/** @file
32 * @brief UHCI driver
33 */
[1256a0a]34#include <driver.h>
[c56dbe0]35#include <usb_iface.h>
36
[1256a0a]37#include <errno.h>
[7ce0fe3]38
39#include <usb/debug.h>
[1256a0a]40
41#include "root_hub.h"
42
[7ce0fe3]43#define NAME "uhci-rhd"
44
[1256a0a]45static int usb_iface_get_hc_handle(device_t *dev, devman_handle_t *handle)
46{
47 assert(dev);
48 assert(dev->driver_data);
[7ce0fe3]49 assert(handle);
50
[1256a0a]51 *handle = ((uhci_root_hub_t*)dev->driver_data)->hc_handle;
[7ce0fe3]52 usb_log_debug("Answering HC handle: %d.\n", *handle);
[816175a2]53
[1256a0a]54 return EOK;
55}
[816175a2]56
[1256a0a]57static usb_iface_t uhci_rh_usb_iface = {
58 .get_hc_handle = usb_iface_get_hc_handle
59};
[245b56b5]60
[1256a0a]61static device_ops_t uhci_rh_ops = {
62 .interfaces[USB_DEV_IFACE] = &uhci_rh_usb_iface,
[816175a2]63};
64
[1256a0a]65static int uhci_rh_add_device(device_t *device)
66{
67 if (!device)
68 return ENOTSUP;
[816175a2]69
[7ce0fe3]70 usb_log_debug2("%s called device %d\n", __FUNCTION__, device->handle);
[1256a0a]71 device->ops = &uhci_rh_ops;
[816175a2]72
[1256a0a]73 uhci_root_hub_t *rh = malloc(sizeof(uhci_root_hub_t));
74 if (!rh) {
[7ce0fe3]75 usb_log_error("Failed to allocate memory for driver instance.\n");
[1256a0a]76 return ENOMEM;
77 }
[7ce0fe3]78
79 /* TODO: get register values from hc */
[1256a0a]80 int ret = uhci_root_hub_init(rh, (void*)0xc030, 4, device);
81 if (ret != EOK) {
[7ce0fe3]82 usb_log_error("Failed(%d) to initialize driver instance.\n", ret);
[1256a0a]83 free(rh);
84 return ret;
85 }
[7ce0fe3]86
[1256a0a]87 device->driver_data = rh;
[5944244]88 usb_log_info("Sucessfully initialized driver instance for device:%d.\n",
[7ce0fe3]89 device->handle);
[1256a0a]90 return EOK;
91}
[816175a2]92
[1256a0a]93static driver_ops_t uhci_rh_driver_ops = {
94 .add_device = uhci_rh_add_device,
95};
[816175a2]96
[1256a0a]97static driver_t uhci_rh_driver = {
98 .name = NAME,
99 .driver_ops = &uhci_rh_driver_ops
100};
[816175a2]101
[1256a0a]102int main(int argc, char *argv[])
103{
[014d5033]104 usb_log_enable(USB_LOG_LEVEL_ERROR, NAME);
[1256a0a]105 return driver_main(&uhci_rh_driver);
106}
[c56dbe0]107/**
108 * @}
109 */
Note: See TracBrowser for help on using the repository browser.