1 | /*
|
---|
2 | * Copyright (c) 2011 Jan Vesely
|
---|
3 | * Copyright (c) 2018 Ondrej Hlavaty
|
---|
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 |
|
---|
30 | /** @addtogroup drvusbohci
|
---|
31 | * @{
|
---|
32 | */
|
---|
33 | /** @file
|
---|
34 | * @brief OHCI host controller driver structure
|
---|
35 | */
|
---|
36 |
|
---|
37 | #ifndef DRV_OHCI_HC_H
|
---|
38 | #define DRV_OHCI_HC_H
|
---|
39 |
|
---|
40 | #include <adt/list.h>
|
---|
41 | #include <ddi.h>
|
---|
42 | #include <ddf/driver.h>
|
---|
43 | #include <device/hw_res_parsed.h>
|
---|
44 | #include <fibril.h>
|
---|
45 | #include <fibril_synch.h>
|
---|
46 | #include <stdbool.h>
|
---|
47 | #include <stdint.h>
|
---|
48 |
|
---|
49 | #include <usb/host/hcd.h>
|
---|
50 | #include <usb/host/endpoint.h>
|
---|
51 | #include <usb/host/usb_transfer_batch.h>
|
---|
52 |
|
---|
53 | #include "ohci_regs.h"
|
---|
54 | #include "ohci_rh.h"
|
---|
55 | #include "ohci_bus.h"
|
---|
56 | #include "endpoint_list.h"
|
---|
57 | #include "hw_struct/hcca.h"
|
---|
58 |
|
---|
59 | /** Main OHCI driver structure */
|
---|
60 | typedef struct hc {
|
---|
61 | /** Common hcd header */
|
---|
62 | hc_device_t base;
|
---|
63 |
|
---|
64 | /** Memory mapped I/O registers area */
|
---|
65 | ohci_regs_t *registers;
|
---|
66 |
|
---|
67 | /** Host controller communication area structure */
|
---|
68 | hcca_t *hcca;
|
---|
69 |
|
---|
70 | /** Transfer schedules */
|
---|
71 | endpoint_list_t lists[4];
|
---|
72 |
|
---|
73 | /** List of active endpoints */
|
---|
74 | list_t pending_endpoints;
|
---|
75 |
|
---|
76 | /** Guards schedule and endpoint manipulation */
|
---|
77 | fibril_mutex_t guard;
|
---|
78 |
|
---|
79 | /** USB hub emulation structure */
|
---|
80 | ohci_rh_t rh;
|
---|
81 |
|
---|
82 | /** USB bookkeeping */
|
---|
83 | ohci_bus_t bus;
|
---|
84 | } hc_t;
|
---|
85 |
|
---|
86 | static inline hc_t *hcd_to_hc(hc_device_t *hcd)
|
---|
87 | {
|
---|
88 | assert(hcd);
|
---|
89 | return (hc_t *) hcd;
|
---|
90 | }
|
---|
91 |
|
---|
92 | extern errno_t hc_add(hc_device_t *, const hw_res_list_parsed_t *);
|
---|
93 | extern errno_t hc_gen_irq_code(irq_code_t *, hc_device_t *,
|
---|
94 | const hw_res_list_parsed_t *, int *);
|
---|
95 | extern errno_t hc_gain_control(hc_device_t *);
|
---|
96 | extern errno_t hc_start(hc_device_t *);
|
---|
97 | extern errno_t hc_setup_roothub(hc_device_t *);
|
---|
98 | extern errno_t hc_gone(hc_device_t *);
|
---|
99 |
|
---|
100 | extern void hc_enqueue_endpoint(hc_t *, const endpoint_t *);
|
---|
101 | extern void hc_dequeue_endpoint(hc_t *, const endpoint_t *);
|
---|
102 |
|
---|
103 | extern errno_t ohci_hc_schedule(usb_transfer_batch_t *);
|
---|
104 | extern errno_t ohci_hc_status(bus_t *, uint32_t *);
|
---|
105 | extern void ohci_hc_interrupt(bus_t *, uint32_t);
|
---|
106 |
|
---|
107 | #endif
|
---|
108 |
|
---|
109 | /**
|
---|
110 | * @}
|
---|
111 | */
|
---|