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

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since b60944b was 32fb6bce, checked in by Ondřej Hlavatý <aearsis@…>, 8 years ago

usbhost: refactoring

This commit moves interrupt, status and schedule to bus
operations. Then the purpose of hcd_t is better defined, and split into
hc_driver_t and hc_device_t. hc_driver_t is used to wrap driver
implementation by the library (similar to how usb_driver_t is used to
wrap usb device drivers). hc_device_t is used as a parent for hc_t
inside drivers, and is allocated inside the DDF device node.

To support these changes, some local identifiers were renamed, some
functions were moved and/or renamed and their arguments changed. The
most notable one being hcd_send_batch → bus_device_send_batch.

  • Property mode set to 100644
File size: 3.2 KB
Line 
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 drvusbehci
29 * @{
30 */
31/** @file
32 * @brief EHCI host controller driver structure
33 */
34#ifndef DRV_EHCI_HC_H
35#define DRV_EHCI_HC_H
36
37#include <adt/list.h>
38#include <ddi.h>
39#include <ddf/driver.h>
40#include <device/hw_res_parsed.h>
41#include <fibril.h>
42#include <fibril_synch.h>
43#include <stdbool.h>
44#include <stdint.h>
45
46#include <usb/host/hcd.h>
47#include <usb/host/endpoint.h>
48#include <usb/host/usb_transfer_batch.h>
49
50#include "ehci_regs.h"
51#include "ehci_rh.h"
52#include "hw_struct/link_pointer.h"
53#include "endpoint_list.h"
54
55/** Main EHCI driver structure */
56typedef struct hc {
57 /* Common device header */
58 hc_device_t base;
59
60 /** Memory mapped CAPS register area */
61 ehci_caps_regs_t *caps;
62 /** Memory mapped I/O registers area */
63 ehci_regs_t *registers;
64
65 /** Iso transfer list */
66 link_pointer_t *periodic_list_base;
67
68 /** CONTROL and BULK schedules */
69 endpoint_list_t async_list;
70
71 /** INT schedule */
72 endpoint_list_t int_list;
73
74 /** List of active transfers */
75 list_t pending_batches;
76
77 /** Guards schedule and endpoint manipulation */
78 fibril_mutex_t guard;
79
80 /** Wait for hc to restart async chedule */
81 fibril_condvar_t async_doorbell;
82
83 /** USB hub emulation structure */
84 ehci_rh_t rh;
85
86 /** USB bookkeeping */
87 ehci_bus_t bus;
88} hc_t;
89
90static inline hc_t *hcd_to_hc(hc_device_t *hcd)
91{
92 assert(hcd);
93 return (hc_t *) hcd;
94}
95
96void hc_enqueue_endpoint(hc_t *, const endpoint_t *);
97void hc_dequeue_endpoint(hc_t *, const endpoint_t *);
98
99/* Boottime operations */
100int hc_add(hc_device_t *, const hw_res_list_parsed_t *);
101int hc_start(hc_device_t *);
102int hc_gen_irq_code(irq_code_t *, hc_device_t *, const hw_res_list_parsed_t *);
103int hc_gone(hc_device_t *);
104
105/** Runtime operations */
106void ehci_hc_interrupt(bus_t *, uint32_t);
107int ehci_hc_status(bus_t *, uint32_t *);
108int ehci_hc_schedule(usb_transfer_batch_t *);
109
110#endif
111/**
112 * @}
113 */
Note: See TracBrowser for help on using the repository browser.