source: mainline/uspace/drv/bus/usb/ehci/hc.h@ ca22536

Last change on this file since ca22536 was 9dfb034, checked in by Jiri Svoboda <jiri@…>, 5 months ago

Implement quiesce for EHCI and OHCI.

  • Property mode set to 100644
File size: 3.5 KB
Line 
1/*
2 * Copyright (c) 2025 Jiri Svoboda
3 * Copyright (c) 2011 Jan Vesely
4 * Copyright (c) 2018 Ondrej Hlavaty
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * - Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * - Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * - The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30/** @addtogroup drvusbehci
31 * @{
32 */
33/** @file
34 * @brief EHCI host controller driver structure
35 */
36#ifndef DRV_EHCI_HC_H
37#define DRV_EHCI_HC_H
38
39#include <adt/list.h>
40#include <ddi.h>
41#include <ddf/driver.h>
42#include <device/hw_res_parsed.h>
43#include <fibril.h>
44#include <fibril_synch.h>
45#include <stdbool.h>
46#include <stdint.h>
47
48#include <usb/host/hcd.h>
49#include <usb/host/endpoint.h>
50#include <usb/host/usb_transfer_batch.h>
51
52#include "ehci_regs.h"
53#include "ehci_rh.h"
54#include "hw_struct/link_pointer.h"
55#include "endpoint_list.h"
56
57/** Main EHCI driver structure */
58typedef struct hc {
59 /* Common device header */
60 hc_device_t base;
61
62 /** Memory mapped CAPS register area */
63 ehci_caps_regs_t *caps;
64 /** Memory mapped I/O registers area */
65 ehci_regs_t *registers;
66
67 /** Iso transfer list, backed by dma_buffer */
68 link_pointer_t *periodic_list;
69
70 dma_buffer_t dma_buffer;
71
72 /** CONTROL and BULK schedules */
73 endpoint_list_t async_list;
74
75 /** INT schedule */
76 endpoint_list_t int_list;
77
78 /** List of active transfers */
79 list_t pending_endpoints;
80
81 /** Guards schedule and endpoint manipulation */
82 fibril_mutex_t guard;
83
84 /** Wait for hc to restart async chedule */
85 fibril_condvar_t async_doorbell;
86
87 /** USB hub emulation structure */
88 ehci_rh_t rh;
89
90 /** USB bookkeeping */
91 ehci_bus_t bus;
92} hc_t;
93
94static inline hc_t *hcd_to_hc(hc_device_t *hcd)
95{
96 assert(hcd);
97 return (hc_t *) hcd;
98}
99
100void hc_enqueue_endpoint(hc_t *, const endpoint_t *);
101void hc_dequeue_endpoint(hc_t *, const endpoint_t *);
102
103/* Boottime operations */
104extern errno_t hc_add(hc_device_t *, const hw_res_list_parsed_t *);
105extern errno_t hc_start(hc_device_t *);
106extern errno_t hc_setup_roothub(hc_device_t *);
107extern errno_t hc_gen_irq_code(irq_code_t *, hc_device_t *,
108 const hw_res_list_parsed_t *, int *);
109extern errno_t hc_gone(hc_device_t *);
110extern errno_t hc_quiesce(hc_device_t *);
111
112/** Runtime operations */
113extern void ehci_hc_interrupt(bus_t *, uint32_t);
114extern errno_t ehci_hc_status(bus_t *, uint32_t *);
115extern errno_t ehci_hc_schedule(usb_transfer_batch_t *);
116
117#endif
118/**
119 * @}
120 */
Note: See TracBrowser for help on using the repository browser.