source: mainline/uspace/drv/bus/usb/ohci/hc.h

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