source: mainline/uspace/drv/bus/usb/ohci/ohci_regs.h@ 4e732f1a

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 4e732f1a was 2acae4d, checked in by Jan Vesely <jano.vesely@…>, 12 years ago

ohci: Use pio_* functions to access registers.

This makes io accesses traceable, among other things

  • Property mode set to 100644
File size: 9.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 drvusbohci
29 * @{
30 */
31/** @file
32 * @brief OHCI host controller register structure
33 */
34#ifndef DRV_OHCI_OHCI_REGS_H
35#define DRV_OHCI_OHCI_REGS_H
36#include <ddi.h>
37#include <sys/types.h>
38#include <byteorder.h>
39
40#define OHCI_WR(reg, val) pio_write_32(&(reg), host2uint32_t_le(val))
41#define OHCI_RD(reg) uint32_t_le2host(pio_read_32(&(reg)))
42#define OHCI_SET(reg, val) pio_set_32(&(reg), host2uint32_t_le(val), 1)
43#define OHCI_CLR(reg, val) pio_clear_32(&(reg), host2uint32_t_le(val), 1)
44
45#define LEGACY_REGS_OFFSET 0x100
46
47/** OHCI memory mapped registers structure */
48typedef struct ohci_regs {
49 const ioport32_t revision;
50#define R_REVISION_MASK (0x3f)
51#define R_LEGACY_FLAG (0x80)
52
53 ioport32_t control;
54/* Control-bulk service ratio */
55#define C_CBSR_1_1 (0x0)
56#define C_CBSR_1_2 (0x1)
57#define C_CBSR_1_3 (0x2)
58#define C_CBSR_1_4 (0x3)
59#define C_CBSR_MASK (0x3)
60#define C_CBSR_SHIFT 0
61
62#define C_PLE (1 << 2) /* Periodic list enable */
63#define C_IE (1 << 3) /* Isochronous enable */
64#define C_CLE (1 << 4) /* Control list enable */
65#define C_BLE (1 << 5) /* Bulk list enable */
66
67/* Host controller functional state */
68#define C_HCFS_RESET (0x0)
69#define C_HCFS_RESUME (0x1)
70#define C_HCFS_OPERATIONAL (0x2)
71#define C_HCFS_SUSPEND (0x3)
72#define C_HCFS_GET(reg) ((OHCI_RD(reg) >> 6) & 0x3)
73#define C_HCFS_SET(reg, value) \
74do { \
75 uint32_t r = OHCI_RD(reg); \
76 r &= ~(0x3 << 6); \
77 r |= (value & 0x3) << 6; \
78 OHCI_WR(reg, r); \
79} while (0)
80
81#define C_IR (1 << 8) /* Interrupt routing, make sure it's 0 */
82#define C_RWC (1 << 9) /* Remote wakeup connected, host specific */
83#define C_RWE (1 << 10) /* Remote wakeup enable */
84
85 ioport32_t command_status;
86#define CS_HCR (1 << 0) /* Host controller reset */
87#define CS_CLF (1 << 1) /* Control list filled */
88#define CS_BLF (1 << 2) /* Bulk list filled */
89#define CS_OCR (1 << 3) /* Ownership change request */
90#if 0
91#define CS_SOC_MASK (0x3) /* Scheduling overrun count */
92#define CS_SOC_SHIFT (16)
93#endif
94
95 /** Interupt enable/disable/status,
96 * reads give the same value,
97 * writing causes enable/disable,
98 * status is write-clean (writing 1 clears the bit*/
99 ioport32_t interrupt_status;
100 ioport32_t interrupt_enable;
101 ioport32_t interrupt_disable;
102#define I_SO (1 << 0) /* Scheduling overrun */
103#define I_WDH (1 << 1) /* Done head write-back */
104#define I_SF (1 << 2) /* Start of frame */
105#define I_RD (1 << 3) /* Resume detect */
106#define I_UE (1 << 4) /* Unrecoverable error */
107#define I_FNO (1 << 5) /* Frame number overflow */
108#define I_RHSC (1 << 6) /* Root hub status change */
109#define I_OC (1 << 30) /* Ownership change */
110#define I_MI (1 << 31) /* Master interrupt (any/all) */
111
112 /** HCCA pointer (see hw_struct hcca.h) */
113 ioport32_t hcca;
114#define HCCA_PTR_MASK 0xffffff00 /* HCCA is 256B aligned */
115
116 /** Currently executed periodic endpoint */
117 const ioport32_t periodic_current;
118
119 /** The first control endpoint */
120 ioport32_t control_head;
121
122 /** Currently executed control endpoint */
123 ioport32_t control_current;
124
125 /** The first bulk endpoint */
126 ioport32_t bulk_head;
127
128 /** Currently executed bulk endpoint */
129 ioport32_t bulk_current;
130
131 /** Done TD list, this value is periodically written to HCCA */
132 const ioport32_t done_head;
133
134 /** Frame time and max packet size for all transfers */
135 ioport32_t fm_interval;
136#define FMI_FI_MASK (0x3fff) /* Frame interval in bit times (should be 11999)*/
137#define FMI_FI_SHIFT (0)
138#define FMI_FSMPS_MASK (0x7fff) /* Full speed max packet size */
139#define FMI_FSMPS_SHIFT (16)
140#define FMI_TOGGLE_FLAG (1 << 31)
141
142 /** Bit times remaining in current frame */
143 const ioport32_t fm_remaining;
144#define FMR_FR_MASK FMI_FI_MASK
145#define FMR_FR_SHIFT FMI_FI_SHIFT
146#define FMR_TOGGLE_FLAG FMI_TOGGLE_FLAG
147
148 /** Frame number */
149 const ioport32_t fm_number;
150#define FMN_NUMBER_MASK (0xffff)
151
152 /** Remaining bit time in frame to start periodic transfers */
153 ioport32_t periodic_start;
154#define PS_MASK 0x3fff
155#define PS_SHIFT 0
156
157 /** Threshold for starting LS transaction */
158 ioport32_t ls_threshold;
159#define LST_LST_MASK (0x7fff)
160
161 /** The first root hub control register */
162 ioport32_t rh_desc_a;
163/** Number of downstream ports, max 15 */
164#define RHDA_NDS_MASK (0xff)
165/** Power switching mode: 0-global, 1-per port*/
166#define RHDA_PSM_FLAG (1 << 8)
167/** No power switch: 1-power on, 0-use PSM*/
168#define RHDA_NPS_FLAG (1 << 9)
169/** 1-Compound device, must be 0 */
170#define RHDA_DT_FLAG (1 << 10)
171/** Over-current mode: 0-global, 1-per port */
172#define RHDA_OCPM_FLAG (1 << 11)
173/** OC control: 0-use OCPM, 1-OC off */
174#define RHDA_NOCP_FLAG (1 << 12)
175/** Power on to power good time */
176#define RHDA_POTPGT_SHIFT 24
177
178 /** The other root hub control register */
179 ioport32_t rh_desc_b;
180/** Device removable mask */
181#define RHDB_DR_SHIFT 0
182#define RHDB_DR_MASK 0xffff
183/** Power control mask */
184#define RHDB_PCC_MASK (0xffff)
185#define RHDB_PCC_SHIFT 16
186
187 /** Root hub status register */
188 ioport32_t rh_status;
189/* read: 0,
190 * write: 0-no effect,
191 * 1-turn off port power for ports
192 * specified in PPCM(RHDB), or all ports,
193 * if power is set globally */
194#define RHS_LPS_FLAG (1 << 0)
195#define RHS_CLEAR_GLOBAL_POWER RHS_LPS_FLAG /* synonym for the above */
196/** Over-current indicator, if per-port: 0 */
197#define RHS_OCI_FLAG (1 << 1)
198
199/* read: 0-connect status change does not wake HC
200 * 1-connect status change wakes HC
201 * write: 1-set DRWE, 0-no effect */
202#define RHS_DRWE_FLAG (1 << 15)
203#define RHS_SET_DRWE RHS_DRWE_FLAG
204/* read: 0,
205 * write: 0-no effect
206 * 1-turn on port power for ports
207 * specified in PPCM(RHDB), or all ports,
208 * if power is set globally */
209#define RHS_LPSC_FLAG (1 << 16)
210#define RHS_SET_GLOBAL_POWER RHS_LPSC_FLAG /* synonym for the above */
211/** Over-current change indicator*/
212#define RHS_OCIC_FLAG (1 << 17)
213#define RHS_CLEAR_DRWE (1 << 31)
214
215 /** Root hub per port status */
216 ioport32_t rh_port_status[];
217#define RHPS_CCS_FLAG (1 << 0) /* r: current connect status,
218 * w: 1-clear port enable, 0-N/S*/
219#define RHPS_CLEAR_PORT_ENABLE RHPS_CCS_FLAG
220#define RHPS_PES_FLAG (1 << 1) /* r: port enable status
221 * w: 1-set port enable, 0-N/S */
222#define RHPS_SET_PORT_ENABLE RHPS_PES_FLAG
223#define RHPS_PSS_FLAG (1 << 2) /* r: port suspend status
224 * w: 1-set port suspend, 0-N/S */
225#define RHPS_SET_PORT_SUSPEND RHPS_PSS_FLAG
226#define RHPS_POCI_FLAG (1 << 3) /* r: port over-current
227 * (if reports are per-port
228 * w: 1-clear port suspend
229 * (start resume if suspened)
230 * 0-nothing */
231#define RHPS_CLEAR_PORT_SUSPEND RHPS_POCI_FLAG
232#define RHPS_PRS_FLAG (1 << 4) /* r: port reset status
233 * w: 1-set port reset, 0-N/S */
234#define RHPS_SET_PORT_RESET RHPS_PRS_FLAG
235#define RHPS_PPS_FLAG (1 << 8) /* r: port power status
236 * w: 1-set port power, 0-N/S */
237#define RHPS_SET_PORT_POWER RHPS_PPS_FLAG
238#define RHPS_LSDA_FLAG (1 << 9) /* r: low speed device attached
239 * w: 1-clear port power, 0-N/S*/
240#define RHPS_CLEAR_PORT_POWER RHPS_LSDA_FLAG
241#define RHPS_CSC_FLAG (1 << 16) /* connect status change WC */
242#define RHPS_PESC_FLAG (1 << 17) /* port enable status change WC */
243#define RHPS_PSSC_FLAG (1 << 18) /* port suspend status change WC */
244#define RHPS_OCIC_FLAG (1 << 19) /* port over-current change WC */
245#define RHPS_PRSC_FLAG (1 << 20) /* port reset status change WC */
246#define RHPS_CHANGE_WC_MASK (0x1f0000)
247} ohci_regs_t;
248#endif
249/**
250 * @}
251 */
Note: See TracBrowser for help on using the repository browser.