xref: /linux/include/linux/usb/ehci_def.h (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
15fd54aceSGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0+
20af36739SYinghai Lu /*
30af36739SYinghai Lu  * Copyright (c) 2001-2002 by David Brownell
40af36739SYinghai Lu  */
50af36739SYinghai Lu 
60af36739SYinghai Lu #ifndef __LINUX_USB_EHCI_DEF_H
70af36739SYinghai Lu #define __LINUX_USB_EHCI_DEF_H
80af36739SYinghai Lu 
9b9ec1c9dSChris Rorvick #include <linux/usb/ehci-dbgp.h>
10b9ec1c9dSChris Rorvick 
110af36739SYinghai Lu /* EHCI register interface, corresponds to EHCI Revision 0.95 specification */
120af36739SYinghai Lu 
130af36739SYinghai Lu /* Section 2.2 Host Controller Capability Registers */
140af36739SYinghai Lu struct ehci_caps {
150af36739SYinghai Lu 	/* these fields are specified as 8 and 16 bit registers,
160af36739SYinghai Lu 	 * but some hosts can't perform 8 or 16 bit PCI accesses.
17c430131aSJan Andersson 	 * some hosts treat caplength and hciversion as parts of a 32-bit
18c430131aSJan Andersson 	 * register, others treat them as two separate registers, this
19c430131aSJan Andersson 	 * affects the memory map for big endian controllers.
200af36739SYinghai Lu 	 */
210af36739SYinghai Lu 	u32		hc_capbase;
22c430131aSJan Andersson #define HC_LENGTH(ehci, p)	(0x00ff&((p) >> /* bits 7:0 / offset 00h */ \
23c430131aSJan Andersson 				(ehci_big_endian_capbase(ehci) ? 24 : 0)))
24c430131aSJan Andersson #define HC_VERSION(ehci, p)	(0xffff&((p) >> /* bits 31:16 / offset 02h */ \
25c430131aSJan Andersson 				(ehci_big_endian_capbase(ehci) ? 0 : 16)))
260af36739SYinghai Lu 	u32		hcs_params;     /* HCSPARAMS - offset 0x4 */
270af36739SYinghai Lu #define HCS_DEBUG_PORT(p)	(((p)>>20)&0xf)	/* bits 23:20, debug port? */
280af36739SYinghai Lu #define HCS_INDICATOR(p)	((p)&(1 << 16))	/* true: has port indicators */
290af36739SYinghai Lu #define HCS_N_CC(p)		(((p)>>12)&0xf)	/* bits 15:12, #companion HCs */
300af36739SYinghai Lu #define HCS_N_PCC(p)		(((p)>>8)&0xf)	/* bits 11:8, ports per CC */
310af36739SYinghai Lu #define HCS_PORTROUTED(p)	((p)&(1 << 7))	/* true: port routing */
320af36739SYinghai Lu #define HCS_PPC(p)		((p)&(1 << 4))	/* true: port power control */
330af36739SYinghai Lu #define HCS_N_PORTS(p)		(((p)>>0)&0xf)	/* bits 3:0, ports on HC */
3472dd1843SKees Cook #define HCS_N_PORTS_MAX		15		/* N_PORTS valid 0x1-0xF */
350af36739SYinghai Lu 
360af36739SYinghai Lu 	u32		hcc_params;      /* HCCPARAMS - offset 0x8 */
37aa4d8342SAlek Du /* EHCI 1.1 addendum */
38aa4d8342SAlek Du #define HCC_32FRAME_PERIODIC_LIST(p)	((p)&(1 << 19))
39aa4d8342SAlek Du #define HCC_PER_PORT_CHANGE_EVENT(p)	((p)&(1 << 18))
40aa4d8342SAlek Du #define HCC_LPM(p)			((p)&(1 << 17))
41aa4d8342SAlek Du #define HCC_HW_PREFETCH(p)		((p)&(1 << 16))
42aa4d8342SAlek Du 
430af36739SYinghai Lu #define HCC_EXT_CAPS(p)		(((p)>>8)&0xff)	/* for pci extended caps */
440af36739SYinghai Lu #define HCC_ISOC_CACHE(p)       ((p)&(1 << 7))  /* true: can cache isoc frame */
450af36739SYinghai Lu #define HCC_ISOC_THRES(p)       (((p)>>4)&0x7)  /* bits 6:4, uframes cached */
460af36739SYinghai Lu #define HCC_CANPARK(p)		((p)&(1 << 2))  /* true: can park on async qh */
470af36739SYinghai Lu #define HCC_PGM_FRAMELISTLEN(p) ((p)&(1 << 1))  /* true: periodic_size changes*/
480af36739SYinghai Lu #define HCC_64BIT_ADDR(p)       ((p)&(1))       /* true: can use 64-bit addr */
490af36739SYinghai Lu 	u8		portroute[8];	 /* nibbles for routing - offset 0xC */
5013954017SRabin Vincent };
510af36739SYinghai Lu 
520af36739SYinghai Lu 
530af36739SYinghai Lu /* Section 2.3 Host Controller Operational Registers */
540af36739SYinghai Lu struct ehci_regs {
550af36739SYinghai Lu 
560af36739SYinghai Lu 	/* USBCMD: offset 0x00 */
570af36739SYinghai Lu 	u32		command;
58aa4d8342SAlek Du 
59aa4d8342SAlek Du /* EHCI 1.1 addendum */
60aa4d8342SAlek Du #define CMD_HIRD	(0xf<<24)	/* host initiated resume duration */
61aa4d8342SAlek Du #define CMD_PPCEE	(1<<15)		/* per port change event enable */
62aa4d8342SAlek Du #define CMD_FSP		(1<<14)		/* fully synchronized prefetch */
63aa4d8342SAlek Du #define CMD_ASPE	(1<<13)		/* async schedule prefetch enable */
64aa4d8342SAlek Du #define CMD_PSPE	(1<<12)		/* periodic schedule prefetch enable */
650af36739SYinghai Lu /* 23:16 is r/w intr rate, in microframes; default "8" == 1/msec */
660af36739SYinghai Lu #define CMD_PARK	(1<<11)		/* enable "park" on async qh */
670af36739SYinghai Lu #define CMD_PARK_CNT(c)	(((c)>>8)&3)	/* how many transfers to park for */
680af36739SYinghai Lu #define CMD_LRESET	(1<<7)		/* partial reset (no ports, etc) */
690af36739SYinghai Lu #define CMD_IAAD	(1<<6)		/* "doorbell" interrupt async advance */
700af36739SYinghai Lu #define CMD_ASE		(1<<5)		/* async schedule enable */
710af36739SYinghai Lu #define CMD_PSE		(1<<4)		/* periodic schedule enable */
720af36739SYinghai Lu /* 3:2 is periodic frame list size */
730af36739SYinghai Lu #define CMD_RESET	(1<<1)		/* reset HC not bus */
740af36739SYinghai Lu #define CMD_RUN		(1<<0)		/* start/stop HC */
750af36739SYinghai Lu 
760af36739SYinghai Lu 	/* USBSTS: offset 0x04 */
770af36739SYinghai Lu 	u32		status;
78aa4d8342SAlek Du #define STS_PPCE_MASK	(0xff<<16)	/* Per-Port change event 1-16 */
790af36739SYinghai Lu #define STS_ASS		(1<<15)		/* Async Schedule Status */
800af36739SYinghai Lu #define STS_PSS		(1<<14)		/* Periodic Schedule Status */
810af36739SYinghai Lu #define STS_RECL	(1<<13)		/* Reclamation */
820af36739SYinghai Lu #define STS_HALT	(1<<12)		/* Not running (any reason) */
830af36739SYinghai Lu /* some bits reserved */
840af36739SYinghai Lu 	/* these STS_* flags are also intr_enable bits (USBINTR) */
850af36739SYinghai Lu #define STS_IAA		(1<<5)		/* Interrupted on async advance */
860af36739SYinghai Lu #define STS_FATAL	(1<<4)		/* such as some PCI access errors */
870af36739SYinghai Lu #define STS_FLR		(1<<3)		/* frame list rolled over */
880af36739SYinghai Lu #define STS_PCD		(1<<2)		/* port change detect */
890af36739SYinghai Lu #define STS_ERR		(1<<1)		/* "error" completion (overflow, ...) */
900af36739SYinghai Lu #define STS_INT		(1<<0)		/* "normal" completion (short, ...) */
910af36739SYinghai Lu 
920af36739SYinghai Lu 	/* USBINTR: offset 0x08 */
930af36739SYinghai Lu 	u32		intr_enable;
940af36739SYinghai Lu 
950af36739SYinghai Lu 	/* FRINDEX: offset 0x0C */
960af36739SYinghai Lu 	u32		frame_index;	/* current microframe number */
970af36739SYinghai Lu 	/* CTRLDSSEGMENT: offset 0x10 */
980af36739SYinghai Lu 	u32		segment;	/* address bits 63:32 if needed */
990af36739SYinghai Lu 	/* PERIODICLISTBASE: offset 0x14 */
1000af36739SYinghai Lu 	u32		frame_list;	/* points to periodic list */
1010af36739SYinghai Lu 	/* ASYNCLISTADDR: offset 0x18 */
1020af36739SYinghai Lu 	u32		async_next;	/* address of next async queue head */
1030af36739SYinghai Lu 
104a46af4ebSAlan Stern 	u32		reserved1[2];
105a46af4ebSAlan Stern 
106a46af4ebSAlan Stern 	/* TXFILLTUNING: offset 0x24 */
107a46af4ebSAlan Stern 	u32		txfill_tuning;	/* TX FIFO Tuning register */
108a46af4ebSAlan Stern #define TXFIFO_DEFAULT	(8<<16)		/* FIFO burst threshold 8 */
109a46af4ebSAlan Stern 
110a46af4ebSAlan Stern 	u32		reserved2[6];
1110af36739SYinghai Lu 
1120af36739SYinghai Lu 	/* CONFIGFLAG: offset 0x40 */
1130af36739SYinghai Lu 	u32		configured_flag;
1140af36739SYinghai Lu #define FLAG_CF		(1<<0)		/* true: we'll support "high speed" */
1150af36739SYinghai Lu 
11672dd1843SKees Cook 	union {
1170af36739SYinghai Lu 		/* PORTSC: offset 0x44 */
11872dd1843SKees Cook 		u32	port_status[HCS_N_PORTS_MAX];	/* up to N_PORTS */
119aa4d8342SAlek Du /* EHCI 1.1 addendum */
120aa4d8342SAlek Du #define PORTSC_SUSPEND_STS_ACK 0
121aa4d8342SAlek Du #define PORTSC_SUSPEND_STS_NYET 1
122aa4d8342SAlek Du #define PORTSC_SUSPEND_STS_STALL 2
123aa4d8342SAlek Du #define PORTSC_SUSPEND_STS_ERR 3
124aa4d8342SAlek Du 
125aa4d8342SAlek Du #define PORT_DEV_ADDR	(0x7f<<25)		/* device address */
126aa4d8342SAlek Du #define PORT_SSTS	(0x3<<23)		/* suspend status */
1270af36739SYinghai Lu /* 31:23 reserved */
1280af36739SYinghai Lu #define PORT_WKOC_E	(1<<22)		/* wake on overcurrent (enable) */
1290af36739SYinghai Lu #define PORT_WKDISC_E	(1<<21)		/* wake on disconnect (enable) */
1300af36739SYinghai Lu #define PORT_WKCONN_E	(1<<20)		/* wake on connect (enable) */
1310af36739SYinghai Lu /* 19:16 for port testing */
13279ad3b5aSBenoit Goby #define PORT_TEST(x)	(((x)&0xf)<<16)	/* Port Test Control */
13379ad3b5aSBenoit Goby #define PORT_TEST_PKT	PORT_TEST(0x4)	/* Port Test Control - packet test */
13479ad3b5aSBenoit Goby #define PORT_TEST_FORCE	PORT_TEST(0x5)	/* Port Test Control - force enable */
1350af36739SYinghai Lu #define PORT_LED_OFF	(0<<14)
1360af36739SYinghai Lu #define PORT_LED_AMBER	(1<<14)
1370af36739SYinghai Lu #define PORT_LED_GREEN	(2<<14)
1380af36739SYinghai Lu #define PORT_LED_MASK	(3<<14)
1390af36739SYinghai Lu #define PORT_OWNER	(1<<13)		/* true: companion hc owns this port */
1400af36739SYinghai Lu #define PORT_POWER	(1<<12)		/* true: has power (see PPC) */
1410af36739SYinghai Lu #define PORT_USB11(x) (((x)&(3<<10)) == (1<<10))	/* USB 1.1 device */
142cc7eac1eSYoshihiro Shimoda #define PORT_LS_MASK	(3<<10)		/* Link status (SE0, K or J */
1430af36739SYinghai Lu /* 9 reserved */
144aa4d8342SAlek Du #define PORT_LPM	(1<<9)		/* LPM transaction */
1450af36739SYinghai Lu #define PORT_RESET	(1<<8)		/* reset port */
1460af36739SYinghai Lu #define PORT_SUSPEND	(1<<7)		/* suspend port */
1470af36739SYinghai Lu #define PORT_RESUME	(1<<6)		/* resume it */
1480af36739SYinghai Lu #define PORT_OCC	(1<<5)		/* over current change */
1490af36739SYinghai Lu #define PORT_OC		(1<<4)		/* over current active */
1500af36739SYinghai Lu #define PORT_PEC	(1<<3)		/* port enable change */
1510af36739SYinghai Lu #define PORT_PE		(1<<2)		/* port enable */
1520af36739SYinghai Lu #define PORT_CSC	(1<<1)		/* connect status change */
1530af36739SYinghai Lu #define PORT_CONNECT	(1<<0)		/* device connected */
1540af36739SYinghai Lu #define PORT_RWC_BITS   (PORT_CSC | PORT_PEC | PORT_OCC)
15572dd1843SKees Cook 		struct {
156a46af4ebSAlan Stern 			u32	reserved3[9];
157a46af4ebSAlan Stern 			/* USBMODE: offset 0x68 */
158a46af4ebSAlan Stern 			u32	usbmode;	/* USB Device mode */
15972dd1843SKees Cook 		};
1600af36739SYinghai Lu #define USBMODE_SDIS	(1<<3)		/* Stream disable */
1610af36739SYinghai Lu #define USBMODE_BE	(1<<2)		/* BE/LE endianness select */
1620af36739SYinghai Lu #define USBMODE_CM_HC	(3<<0)		/* host controller mode */
1630af36739SYinghai Lu #define USBMODE_CM_IDLE	(0<<0)		/* idle state */
16472dd1843SKees Cook 	};
165a46af4ebSAlan Stern 
166331ac6b2SAlek Du /* Moorestown has some non-standard registers, partially due to the fact that
16725985edcSLucas De Marchi  * its EHCI controller has both TT and LPM support. HOSTPCx are extensions to
168331ac6b2SAlek Du  * PORTSCx
169331ac6b2SAlek Du  */
170*e4788edcSKees Cook 	union {
171*e4788edcSKees Cook 		struct {
172*e4788edcSKees Cook 			u32	reserved4;
173a46af4ebSAlan Stern 			/* HOSTPC: offset 0x84 */
17472dd1843SKees Cook 			u32	hostpc[HCS_N_PORTS_MAX];
175331ac6b2SAlek Du #define HOSTPC_PHCD	(1<<22)		/* Phy clock disable */
176331ac6b2SAlek Du #define HOSTPC_PSPD	(3<<25)		/* Port speed detection */
177*e4788edcSKees Cook 		};
178*e4788edcSKees Cook 
179*e4788edcSKees Cook 		/* Broadcom-proprietary USB_EHCI_INSNREG00 @ 0x80 */
180*e4788edcSKees Cook 		u32	brcm_insnreg[4];
181*e4788edcSKees Cook 	};
182a46af4ebSAlan Stern 
18372dd1843SKees Cook 	u32		reserved5[2];
184a46af4ebSAlan Stern 
185a46af4ebSAlan Stern 	/* USBMODE_EX: offset 0xc8 */
186a46af4ebSAlan Stern 	u32		usbmode_ex;	/* USB Device mode extension */
187331ac6b2SAlek Du #define USBMODE_EX_VBPS	(1<<5)		/* VBus Power Select On */
188331ac6b2SAlek Du #define USBMODE_EX_HC	(3<<0)		/* host controller mode */
189a46af4ebSAlan Stern };
190331ac6b2SAlek Du 
1910af36739SYinghai Lu #endif /* __LINUX_USB_EHCI_DEF_H */
192