1 /* Copyright (c) 2011,2012 Simon Schubert <2@0x2c.org>.
2 * Modifications by Jacob Alexander 2014-2015 <haata@kiibohd.com>
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 // ----- Local Includes -----
23 #include "usb-common.h"
27 // ----- Structs -----
33 struct USB_ADDINFO_t {
34 UNION_STRUCT_START(8);
40 CTASSERT_SIZE_BIT(struct USB_ADDINFO_t, 8);
42 struct USB_OTGSTAT_t {
43 UNION_STRUCT_START(8);
49 uint8_t line_state : 1;
54 CTASSERT_SIZE_BIT(struct USB_OTGSTAT_t, 8);
57 UNION_STRUCT_START(8);
67 CTASSERT_SIZE_BIT(struct USB_OTGCTL_t, 8);
70 UNION_STRUCT_START(8);
81 CTASSERT_SIZE_BIT(struct USB_ISTAT_t, 8);
83 struct USB_ERRSTAT_t {
84 UNION_STRUCT_START(8);
95 CTASSERT_SIZE_BIT(struct USB_ERRSTAT_t, 8);
98 UNION_STRUCT_START(8);
100 enum usb_ep_pingpong pingpong : 1;
101 enum usb_ep_dir dir : 1;
105 CTASSERT_SIZE_BIT(struct USB_STAT_t, 8);
109 struct /* common */ {
120 uint8_t hostmodeen : 1;
122 uint8_t token_busy : 1;
125 struct /* device */ {
128 uint8_t txd_suspend : 1;
134 CTASSERT_SIZE_BIT(struct USB_CTL_t, 8);
137 UNION_STRUCT_START(8);
142 CTASSERT_SIZE_BIT(struct USB_ADDR_t, 8);
145 UNION_STRUCT_START(8);
147 enum usb_tok_pid pid : 4;
150 CTASSERT_SIZE_BIT(struct USB_TOKEN_t, 8);
153 UNION_STRUCT_START(8);
158 uint8_t epctldis : 1;
160 uint8_t retrydis : 1;
161 uint8_t hostwohub : 1;
164 CTASSERT_SIZE_BIT(struct USB_ENDPT_t, 8);
166 struct USB_USBCTRL_t {
167 UNION_STRUCT_START(8);
173 CTASSERT_SIZE_BIT(struct USB_USBCTRL_t, 8);
175 struct USB_OBSERVE_t {
176 UNION_STRUCT_START(8);
184 CTASSERT_SIZE_BIT(struct USB_OBSERVE_t, 8);
186 struct USB_CONTROL_t {
187 UNION_STRUCT_START(8);
189 uint8_t dppullupnonotg : 1;
193 CTASSERT_SIZE_BIT(struct USB_CONTROL_t, 8);
195 struct USB_USBTRC0_t {
196 UNION_STRUCT_START(8);
197 uint8_t usb_resume_int : 1;
198 uint8_t sync_det : 1;
200 uint8_t usbresmen : 1;
202 uint8_t usbreset : 1;
205 CTASSERT_SIZE_BIT(struct USB_USBTRC0_t, 8);
214 struct USB_ADDINFO_t addinfo;
216 struct USB_OTGSTAT_t otgistat;
218 struct USB_OTGSTAT_t otgicr;
220 struct USB_OTGSTAT_t otgstat;
222 struct USB_OTGCTL_t otgctl;
224 uint8_t _pad8[0x80 - 0x20];
225 struct USB_ISTAT_t istat;
227 struct USB_ISTAT_t inten;
229 struct USB_ERRSTAT_t errstat;
231 struct USB_ERRSTAT_t erren;
233 struct USB_STAT_t stat;
235 struct USB_CTL_t ctl;
237 struct USB_ADDR_t addr;
248 struct USB_TOKEN_t token;
256 uint8_t _pad23[0xc0 - 0xb8];
261 struct USB_USBCTRL_t usbctrl;
263 struct USB_OBSERVE_t observe;
265 struct USB_CONTROL_t control;
267 struct USB_USBTRC0_t usbtrc0;
270 uint8_t usbfrmadjust;
273 CTASSERT_SIZE_BYTE(struct USB_t, 0x118);
276 struct USB_BD_BITS_t {
284 enum usb_data01 data01 : 1;
290 struct /* processor */ {
292 enum usb_tok_pid tok_pid : 4;
293 uint32_t _rsvd6 : 26;
300 CTASSERT_SIZE_BYTE(struct USB_BD_t, 8);
302 extern volatile struct USB_t USB0;