xref: /plan9/sys/src/9/kw/usbehci.h (revision 5bdeb9a20ca533546de47a1bc407975caf1023f5)
1 /* override default macros from ../port/usb.h */
2 #undef	dprint
3 #undef	ddprint
4 #undef	deprint
5 #undef	ddeprint
6 #define dprint		if(ehcidebug)print
7 #define ddprint		if(ehcidebug>1)print
8 #define deprint		if(ehcidebug || ep->debug)print
9 #define ddeprint	if(ehcidebug>1 || ep->debug>1)print
10 
11 typedef struct Ctlr Ctlr;
12 typedef struct Eopio Eopio;
13 typedef struct Isoio Isoio;
14 typedef struct Poll Poll;
15 typedef struct Qh Qh;
16 typedef struct Qtree Qtree;
17 
18 #pragma incomplete Ctlr;
19 #pragma incomplete Ecapio;
20 #pragma incomplete Eopio;
21 #pragma incomplete Edbgio;
22 #pragma incomplete Isoio;
23 #pragma incomplete Poll;
24 #pragma incomplete Qh;
25 #pragma incomplete Qtree;
26 
27 struct Poll
28 {
29 	Lock;
30 	Rendez;
31 	int	must;
32 	int	does;
33 };
34 
35 struct Ctlr
36 {
37 	Rendez;			/* for waiting to async advance doorbell */
38 	Lock;			/* for ilock. qh lists and basic ctlr I/O */
39 	QLock	portlck;	/* for port resets/enable... (and doorbell) */
40 	int	active;		/* in use or not */
41 	Ecapio*	capio;		/* Capability i/o regs */
42 	Eopio*	opio;		/* Operational i/o regs */
43 
44 	int	nframes;	/* 1024, 512, or 256 frames in the list */
45 	ulong*	frames;		/* periodic frame list (hw) */
46 	Qh*	qhs;		/* async Qh circular list for bulk/ctl */
47 	Qtree*	tree;		/* tree of Qhs for the periodic list */
48 	int	ntree;		/* number of dummy qhs in tree */
49 	Qh*	intrqhs;		/* list of (not dummy) qhs in tree  */
50 	Isoio*	iso;		/* list of active Iso I/O */
51 	ulong	load;
52 	ulong	isoload;
53 	int	nintr;		/* number of interrupts attended */
54 	int	ntdintr;	/* number of intrs. with something to do */
55 	int	nqhintr;	/* number of async td intrs. */
56 	int	nisointr;	/* number of periodic td intrs. */
57 	int	nreqs;
58 	Poll	poll;
59 };
60 
61 /*
62  * Operational registers (hw)
63  */
64 struct Eopio
65 {
66 	ulong	cmd;		/* 00 command */
67 	ulong	sts;		/* 04 status */
68 	ulong	intr;		/* 08 interrupt enable */
69 	ulong	frno;		/* 0c frame index */
70 	ulong	seg;		/* 10 bits 63:32 of EHCI datastructs (unused) */
71 	ulong	frbase;		/* 14 frame list base addr, 4096-byte boundary */
72 	ulong	link;		/* 18 link for async list */
73 	uchar	d2c[0x40-0x1c];	/* 1c dummy */
74 	ulong	config;		/* 40 1: all ports default-routed to this HC */
75 	ulong	portsc[1];	/* 44 Port status and control, one per port */
76 
77 	/*
78 	 * these are present on the Kirkwood USB controller.
79 	 * are they standard now?  Marvell doesn't document them publically.
80 	 */
81 	uchar	_pad0[0x64-0x48];
82 	ulong	otgsc;
83 	ulong	usbmode;
84 	ulong	epsetupsts;
85 	ulong	epprime;
86 	ulong	epflush;
87 	ulong	epsts;
88 	ulong	epcompl;
89 	ulong	epctl[6];
90 
91 	/* freescale registers */
92 	uchar	_pad1[0x2c0-0x98];
93 	ulong	snoop1;
94 	ulong	snoop2;
95 	ulong	agecntthresh;
96 	ulong	prictl;		/* priority control */
97 	ulong	sictl;		/* system interface control */
98 
99 	uchar	_pad2[0x3c0-0x2d4];
100 	ulong	ctl;
101 };
102 
103 extern int ehcidebug;
104 
105 void	ehcilinkage(Hci *hp);
106 void	ehcimeminit(Ctlr *ctlr);
107 void	ehcirun(Ctlr *ctlr, int on);
108