1 /* Copyright (c) 2011,2012 Simon Schubert <2@0x2c.org>.
2 * Modifications by Jacob Alexander 2014 <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/>.
18 // ----- Local Includes -----
21 #include "usb-common.h"
25 // ----- Structs -----
31 struct USB_ADDINFO_t {
32 UNION_STRUCT_START(8);
38 CTASSERT_SIZE_BIT(struct USB_ADDINFO_t, 8);
40 struct USB_OTGSTAT_t {
41 UNION_STRUCT_START(8);
47 uint8_t line_state : 1;
52 CTASSERT_SIZE_BIT(struct USB_OTGSTAT_t, 8);
55 UNION_STRUCT_START(8);
65 CTASSERT_SIZE_BIT(struct USB_OTGCTL_t, 8);
68 UNION_STRUCT_START(8);
79 CTASSERT_SIZE_BIT(struct USB_ISTAT_t, 8);
81 struct USB_ERRSTAT_t {
82 UNION_STRUCT_START(8);
93 CTASSERT_SIZE_BIT(struct USB_ERRSTAT_t, 8);
96 UNION_STRUCT_START(8);
98 enum usb_ep_pingpong pingpong : 1;
99 enum usb_ep_dir dir : 1;
103 CTASSERT_SIZE_BIT(struct USB_STAT_t, 8);
107 struct /* common */ {
118 uint8_t hostmodeen : 1;
120 uint8_t token_busy : 1;
123 struct /* device */ {
126 uint8_t txd_suspend : 1;
132 CTASSERT_SIZE_BIT(struct USB_CTL_t, 8);
135 UNION_STRUCT_START(8);
140 CTASSERT_SIZE_BIT(struct USB_ADDR_t, 8);
143 UNION_STRUCT_START(8);
145 enum usb_tok_pid pid : 4;
148 CTASSERT_SIZE_BIT(struct USB_TOKEN_t, 8);
151 UNION_STRUCT_START(8);
156 uint8_t epctldis : 1;
158 uint8_t retrydis : 1;
159 uint8_t hostwohub : 1;
162 CTASSERT_SIZE_BIT(struct USB_ENDPT_t, 8);
164 struct USB_USBCTRL_t {
165 UNION_STRUCT_START(8);
171 CTASSERT_SIZE_BIT(struct USB_USBCTRL_t, 8);
173 struct USB_OBSERVE_t {
174 UNION_STRUCT_START(8);
182 CTASSERT_SIZE_BIT(struct USB_OBSERVE_t, 8);
184 struct USB_CONTROL_t {
185 UNION_STRUCT_START(8);
187 uint8_t dppullupnonotg : 1;
191 CTASSERT_SIZE_BIT(struct USB_CONTROL_t, 8);
193 struct USB_USBTRC0_t {
194 UNION_STRUCT_START(8);
195 uint8_t usb_resume_int : 1;
196 uint8_t sync_det : 1;
198 uint8_t usbresmen : 1;
200 uint8_t usbreset : 1;
203 CTASSERT_SIZE_BIT(struct USB_USBTRC0_t, 8);
212 struct USB_ADDINFO_t addinfo;
214 struct USB_OTGSTAT_t otgistat;
216 struct USB_OTGSTAT_t otgicr;
218 struct USB_OTGSTAT_t otgstat;
220 struct USB_OTGCTL_t otgctl;
222 uint8_t _pad8[0x80 - 0x20];
223 struct USB_ISTAT_t istat;
225 struct USB_ISTAT_t inten;
227 struct USB_ERRSTAT_t errstat;
229 struct USB_ERRSTAT_t erren;
231 struct USB_STAT_t stat;
233 struct USB_CTL_t ctl;
235 struct USB_ADDR_t addr;
246 struct USB_TOKEN_t token;
254 uint8_t _pad23[0xc0 - 0xb8];
259 struct USB_USBCTRL_t usbctrl;
261 struct USB_OBSERVE_t observe;
263 struct USB_CONTROL_t control;
265 struct USB_USBTRC0_t usbtrc0;
268 uint8_t usbfrmadjust;
271 CTASSERT_SIZE_BYTE(struct USB_t, 0x118);
274 struct USB_BD_BITS_t {
282 enum usb_data01 data01 : 1;
288 struct /* processor */ {
290 enum usb_tok_pid tok_pid : 4;
291 uint32_t _rsvd6 : 26;
298 CTASSERT_SIZE_BYTE(struct USB_BD_t, 8);
300 extern volatile struct USB_t USB0;