1 | /*
|
---|
2 | * Copyright (c) 2011 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 drvusbohcihc
|
---|
29 | * @{
|
---|
30 | */
|
---|
31 | /** @file
|
---|
32 | * @brief OHCI Host controller driver routines
|
---|
33 | */
|
---|
34 | #include <errno.h>
|
---|
35 | #include <str_error.h>
|
---|
36 | #include <adt/list.h>
|
---|
37 | #include <libarch/ddi.h>
|
---|
38 |
|
---|
39 | #include <usb/debug.h>
|
---|
40 | #include <usb/usb.h>
|
---|
41 | #include <usb/ddfiface.h>
|
---|
42 | #include <usb_iface.h>
|
---|
43 |
|
---|
44 | #include "ohci_hc.h"
|
---|
45 |
|
---|
46 | int ohci_hc_init(ohci_hc_t *instance, ddf_fun_t *fun,
|
---|
47 | uintptr_t regs, size_t reg_size, bool interrupts)
|
---|
48 | {
|
---|
49 | assert(instance);
|
---|
50 | int ret = pio_enable((void*)regs, reg_size, (void**)&instance->registers);
|
---|
51 | if (ret != EOK) {
|
---|
52 | usb_log_error("Failed to gain access to device registers.\n");
|
---|
53 | return ret;
|
---|
54 | }
|
---|
55 | instance->registers->interrupt_disable = 0;
|
---|
56 | /* enable interrupt on root hub status change */
|
---|
57 | instance->registers->interupt_enable |= IE_RHSC | IE_MIE;
|
---|
58 |
|
---|
59 |
|
---|
60 | ohci_rh_init(&instance->rh, instance->registers);
|
---|
61 | /* TODO: implement */
|
---|
62 | /* TODO: register root hub */
|
---|
63 | return EOK;
|
---|
64 | }
|
---|
65 | /*----------------------------------------------------------------------------*/
|
---|
66 | int ohci_hc_schedule(ohci_hc_t *instance, batch_t *batch)
|
---|
67 | {
|
---|
68 | assert(instance);
|
---|
69 | assert(batch);
|
---|
70 | if (batch->target.address == instance->rh.address) {
|
---|
71 | ohci_rh_request(&instance->rh, batch);
|
---|
72 | return EOK;
|
---|
73 | }
|
---|
74 | /* TODO: implement */
|
---|
75 | return EOK;
|
---|
76 | }
|
---|
77 | /*----------------------------------------------------------------------------*/
|
---|
78 | void ohci_hc_interrupt(ohci_hc_t *instance, uint16_t status)
|
---|
79 | {
|
---|
80 | assert(instance);
|
---|
81 | /* TODO: Check for interrupt cause */
|
---|
82 | ohci_rh_interrupt(&instance->rh);
|
---|
83 | /* TODO: implement */
|
---|
84 | }
|
---|
85 | /**
|
---|
86 | * @}
|
---|
87 | */
|
---|