15fd54aceSGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0+ 20af36739SYinghai Lu /* 30af36739SYinghai Lu * Copyright (c) 2001-2002 by David Brownell 40af36739SYinghai Lu * 50af36739SYinghai Lu * This program is free software; you can redistribute it and/or modify it 60af36739SYinghai Lu * under the terms of the GNU General Public License as published by the 70af36739SYinghai Lu * Free Software Foundation; either version 2 of the License, or (at your 80af36739SYinghai Lu * option) any later version. 90af36739SYinghai Lu * 100af36739SYinghai Lu * This program is distributed in the hope that it will be useful, but 110af36739SYinghai Lu * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 120af36739SYinghai Lu * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 130af36739SYinghai Lu * for more details. 140af36739SYinghai Lu * 150af36739SYinghai Lu * You should have received a copy of the GNU General Public License 160af36739SYinghai Lu * along with this program; if not, write to the Free Software Foundation, 170af36739SYinghai Lu * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 180af36739SYinghai Lu */ 190af36739SYinghai Lu 200af36739SYinghai Lu #ifndef __LINUX_USB_EHCI_DEF_H 210af36739SYinghai Lu #define __LINUX_USB_EHCI_DEF_H 220af36739SYinghai Lu 23b9ec1c9dSChris Rorvick #include <linux/usb/ehci-dbgp.h> 24b9ec1c9dSChris Rorvick 250af36739SYinghai Lu /* EHCI register interface, corresponds to EHCI Revision 0.95 specification */ 260af36739SYinghai Lu 270af36739SYinghai Lu /* Section 2.2 Host Controller Capability Registers */ 280af36739SYinghai Lu struct ehci_caps { 290af36739SYinghai Lu /* these fields are specified as 8 and 16 bit registers, 300af36739SYinghai Lu * but some hosts can't perform 8 or 16 bit PCI accesses. 31c430131aSJan Andersson * some hosts treat caplength and hciversion as parts of a 32-bit 32c430131aSJan Andersson * register, others treat them as two separate registers, this 33c430131aSJan Andersson * affects the memory map for big endian controllers. 340af36739SYinghai Lu */ 350af36739SYinghai Lu u32 hc_capbase; 36c430131aSJan Andersson #define HC_LENGTH(ehci, p) (0x00ff&((p) >> /* bits 7:0 / offset 00h */ \ 37c430131aSJan Andersson (ehci_big_endian_capbase(ehci) ? 24 : 0))) 38c430131aSJan Andersson #define HC_VERSION(ehci, p) (0xffff&((p) >> /* bits 31:16 / offset 02h */ \ 39c430131aSJan Andersson (ehci_big_endian_capbase(ehci) ? 0 : 16))) 400af36739SYinghai Lu u32 hcs_params; /* HCSPARAMS - offset 0x4 */ 410af36739SYinghai Lu #define HCS_DEBUG_PORT(p) (((p)>>20)&0xf) /* bits 23:20, debug port? */ 420af36739SYinghai Lu #define HCS_INDICATOR(p) ((p)&(1 << 16)) /* true: has port indicators */ 430af36739SYinghai Lu #define HCS_N_CC(p) (((p)>>12)&0xf) /* bits 15:12, #companion HCs */ 440af36739SYinghai Lu #define HCS_N_PCC(p) (((p)>>8)&0xf) /* bits 11:8, ports per CC */ 450af36739SYinghai Lu #define HCS_PORTROUTED(p) ((p)&(1 << 7)) /* true: port routing */ 460af36739SYinghai Lu #define HCS_PPC(p) ((p)&(1 << 4)) /* true: port power control */ 470af36739SYinghai Lu #define HCS_N_PORTS(p) (((p)>>0)&0xf) /* bits 3:0, ports on HC */ 48*72dd1843SKees Cook #define HCS_N_PORTS_MAX 15 /* N_PORTS valid 0x1-0xF */ 490af36739SYinghai Lu 500af36739SYinghai Lu u32 hcc_params; /* HCCPARAMS - offset 0x8 */ 51aa4d8342SAlek Du /* EHCI 1.1 addendum */ 52aa4d8342SAlek Du #define HCC_32FRAME_PERIODIC_LIST(p) ((p)&(1 << 19)) 53aa4d8342SAlek Du #define HCC_PER_PORT_CHANGE_EVENT(p) ((p)&(1 << 18)) 54aa4d8342SAlek Du #define HCC_LPM(p) ((p)&(1 << 17)) 55aa4d8342SAlek Du #define HCC_HW_PREFETCH(p) ((p)&(1 << 16)) 56aa4d8342SAlek Du 570af36739SYinghai Lu #define HCC_EXT_CAPS(p) (((p)>>8)&0xff) /* for pci extended caps */ 580af36739SYinghai Lu #define HCC_ISOC_CACHE(p) ((p)&(1 << 7)) /* true: can cache isoc frame */ 590af36739SYinghai Lu #define HCC_ISOC_THRES(p) (((p)>>4)&0x7) /* bits 6:4, uframes cached */ 600af36739SYinghai Lu #define HCC_CANPARK(p) ((p)&(1 << 2)) /* true: can park on async qh */ 610af36739SYinghai Lu #define HCC_PGM_FRAMELISTLEN(p) ((p)&(1 << 1)) /* true: periodic_size changes*/ 620af36739SYinghai Lu #define HCC_64BIT_ADDR(p) ((p)&(1)) /* true: can use 64-bit addr */ 630af36739SYinghai Lu u8 portroute[8]; /* nibbles for routing - offset 0xC */ 6413954017SRabin Vincent }; 650af36739SYinghai Lu 660af36739SYinghai Lu 670af36739SYinghai Lu /* Section 2.3 Host Controller Operational Registers */ 680af36739SYinghai Lu struct ehci_regs { 690af36739SYinghai Lu 700af36739SYinghai Lu /* USBCMD: offset 0x00 */ 710af36739SYinghai Lu u32 command; 72aa4d8342SAlek Du 73aa4d8342SAlek Du /* EHCI 1.1 addendum */ 74aa4d8342SAlek Du #define CMD_HIRD (0xf<<24) /* host initiated resume duration */ 75aa4d8342SAlek Du #define CMD_PPCEE (1<<15) /* per port change event enable */ 76aa4d8342SAlek Du #define CMD_FSP (1<<14) /* fully synchronized prefetch */ 77aa4d8342SAlek Du #define CMD_ASPE (1<<13) /* async schedule prefetch enable */ 78aa4d8342SAlek Du #define CMD_PSPE (1<<12) /* periodic schedule prefetch enable */ 790af36739SYinghai Lu /* 23:16 is r/w intr rate, in microframes; default "8" == 1/msec */ 800af36739SYinghai Lu #define CMD_PARK (1<<11) /* enable "park" on async qh */ 810af36739SYinghai Lu #define CMD_PARK_CNT(c) (((c)>>8)&3) /* how many transfers to park for */ 820af36739SYinghai Lu #define CMD_LRESET (1<<7) /* partial reset (no ports, etc) */ 830af36739SYinghai Lu #define CMD_IAAD (1<<6) /* "doorbell" interrupt async advance */ 840af36739SYinghai Lu #define CMD_ASE (1<<5) /* async schedule enable */ 850af36739SYinghai Lu #define CMD_PSE (1<<4) /* periodic schedule enable */ 860af36739SYinghai Lu /* 3:2 is periodic frame list size */ 870af36739SYinghai Lu #define CMD_RESET (1<<1) /* reset HC not bus */ 880af36739SYinghai Lu #define CMD_RUN (1<<0) /* start/stop HC */ 890af36739SYinghai Lu 900af36739SYinghai Lu /* USBSTS: offset 0x04 */ 910af36739SYinghai Lu u32 status; 92aa4d8342SAlek Du #define STS_PPCE_MASK (0xff<<16) /* Per-Port change event 1-16 */ 930af36739SYinghai Lu #define STS_ASS (1<<15) /* Async Schedule Status */ 940af36739SYinghai Lu #define STS_PSS (1<<14) /* Periodic Schedule Status */ 950af36739SYinghai Lu #define STS_RECL (1<<13) /* Reclamation */ 960af36739SYinghai Lu #define STS_HALT (1<<12) /* Not running (any reason) */ 970af36739SYinghai Lu /* some bits reserved */ 980af36739SYinghai Lu /* these STS_* flags are also intr_enable bits (USBINTR) */ 990af36739SYinghai Lu #define STS_IAA (1<<5) /* Interrupted on async advance */ 1000af36739SYinghai Lu #define STS_FATAL (1<<4) /* such as some PCI access errors */ 1010af36739SYinghai Lu #define STS_FLR (1<<3) /* frame list rolled over */ 1020af36739SYinghai Lu #define STS_PCD (1<<2) /* port change detect */ 1030af36739SYinghai Lu #define STS_ERR (1<<1) /* "error" completion (overflow, ...) */ 1040af36739SYinghai Lu #define STS_INT (1<<0) /* "normal" completion (short, ...) */ 1050af36739SYinghai Lu 1060af36739SYinghai Lu /* USBINTR: offset 0x08 */ 1070af36739SYinghai Lu u32 intr_enable; 1080af36739SYinghai Lu 1090af36739SYinghai Lu /* FRINDEX: offset 0x0C */ 1100af36739SYinghai Lu u32 frame_index; /* current microframe number */ 1110af36739SYinghai Lu /* CTRLDSSEGMENT: offset 0x10 */ 1120af36739SYinghai Lu u32 segment; /* address bits 63:32 if needed */ 1130af36739SYinghai Lu /* PERIODICLISTBASE: offset 0x14 */ 1140af36739SYinghai Lu u32 frame_list; /* points to periodic list */ 1150af36739SYinghai Lu /* ASYNCLISTADDR: offset 0x18 */ 1160af36739SYinghai Lu u32 async_next; /* address of next async queue head */ 1170af36739SYinghai Lu 118a46af4ebSAlan Stern u32 reserved1[2]; 119a46af4ebSAlan Stern 120a46af4ebSAlan Stern /* TXFILLTUNING: offset 0x24 */ 121a46af4ebSAlan Stern u32 txfill_tuning; /* TX FIFO Tuning register */ 122a46af4ebSAlan Stern #define TXFIFO_DEFAULT (8<<16) /* FIFO burst threshold 8 */ 123a46af4ebSAlan Stern 124a46af4ebSAlan Stern u32 reserved2[6]; 1250af36739SYinghai Lu 1260af36739SYinghai Lu /* CONFIGFLAG: offset 0x40 */ 1270af36739SYinghai Lu u32 configured_flag; 1280af36739SYinghai Lu #define FLAG_CF (1<<0) /* true: we'll support "high speed" */ 1290af36739SYinghai Lu 130*72dd1843SKees Cook union { 1310af36739SYinghai Lu /* PORTSC: offset 0x44 */ 132*72dd1843SKees Cook u32 port_status[HCS_N_PORTS_MAX]; /* up to N_PORTS */ 133aa4d8342SAlek Du /* EHCI 1.1 addendum */ 134aa4d8342SAlek Du #define PORTSC_SUSPEND_STS_ACK 0 135aa4d8342SAlek Du #define PORTSC_SUSPEND_STS_NYET 1 136aa4d8342SAlek Du #define PORTSC_SUSPEND_STS_STALL 2 137aa4d8342SAlek Du #define PORTSC_SUSPEND_STS_ERR 3 138aa4d8342SAlek Du 139aa4d8342SAlek Du #define PORT_DEV_ADDR (0x7f<<25) /* device address */ 140aa4d8342SAlek Du #define PORT_SSTS (0x3<<23) /* suspend status */ 1410af36739SYinghai Lu /* 31:23 reserved */ 1420af36739SYinghai Lu #define PORT_WKOC_E (1<<22) /* wake on overcurrent (enable) */ 1430af36739SYinghai Lu #define PORT_WKDISC_E (1<<21) /* wake on disconnect (enable) */ 1440af36739SYinghai Lu #define PORT_WKCONN_E (1<<20) /* wake on connect (enable) */ 1450af36739SYinghai Lu /* 19:16 for port testing */ 14679ad3b5aSBenoit Goby #define PORT_TEST(x) (((x)&0xf)<<16) /* Port Test Control */ 14779ad3b5aSBenoit Goby #define PORT_TEST_PKT PORT_TEST(0x4) /* Port Test Control - packet test */ 14879ad3b5aSBenoit Goby #define PORT_TEST_FORCE PORT_TEST(0x5) /* Port Test Control - force enable */ 1490af36739SYinghai Lu #define PORT_LED_OFF (0<<14) 1500af36739SYinghai Lu #define PORT_LED_AMBER (1<<14) 1510af36739SYinghai Lu #define PORT_LED_GREEN (2<<14) 1520af36739SYinghai Lu #define PORT_LED_MASK (3<<14) 1530af36739SYinghai Lu #define PORT_OWNER (1<<13) /* true: companion hc owns this port */ 1540af36739SYinghai Lu #define PORT_POWER (1<<12) /* true: has power (see PPC) */ 1550af36739SYinghai Lu #define PORT_USB11(x) (((x)&(3<<10)) == (1<<10)) /* USB 1.1 device */ 156cc7eac1eSYoshihiro Shimoda #define PORT_LS_MASK (3<<10) /* Link status (SE0, K or J */ 1570af36739SYinghai Lu /* 9 reserved */ 158aa4d8342SAlek Du #define PORT_LPM (1<<9) /* LPM transaction */ 1590af36739SYinghai Lu #define PORT_RESET (1<<8) /* reset port */ 1600af36739SYinghai Lu #define PORT_SUSPEND (1<<7) /* suspend port */ 1610af36739SYinghai Lu #define PORT_RESUME (1<<6) /* resume it */ 1620af36739SYinghai Lu #define PORT_OCC (1<<5) /* over current change */ 1630af36739SYinghai Lu #define PORT_OC (1<<4) /* over current active */ 1640af36739SYinghai Lu #define PORT_PEC (1<<3) /* port enable change */ 1650af36739SYinghai Lu #define PORT_PE (1<<2) /* port enable */ 1660af36739SYinghai Lu #define PORT_CSC (1<<1) /* connect status change */ 1670af36739SYinghai Lu #define PORT_CONNECT (1<<0) /* device connected */ 1680af36739SYinghai Lu #define PORT_RWC_BITS (PORT_CSC | PORT_PEC | PORT_OCC) 169*72dd1843SKees Cook struct { 170a46af4ebSAlan Stern u32 reserved3[9]; 171a46af4ebSAlan Stern /* USBMODE: offset 0x68 */ 172a46af4ebSAlan Stern u32 usbmode; /* USB Device mode */ 173*72dd1843SKees Cook }; 1740af36739SYinghai Lu #define USBMODE_SDIS (1<<3) /* Stream disable */ 1750af36739SYinghai Lu #define USBMODE_BE (1<<2) /* BE/LE endianness select */ 1760af36739SYinghai Lu #define USBMODE_CM_HC (3<<0) /* host controller mode */ 1770af36739SYinghai Lu #define USBMODE_CM_IDLE (0<<0) /* idle state */ 178*72dd1843SKees Cook }; 179*72dd1843SKees Cook u32 reserved4; 180a46af4ebSAlan Stern 181331ac6b2SAlek Du /* Moorestown has some non-standard registers, partially due to the fact that 18225985edcSLucas De Marchi * its EHCI controller has both TT and LPM support. HOSTPCx are extensions to 183331ac6b2SAlek Du * PORTSCx 184331ac6b2SAlek Du */ 185a46af4ebSAlan Stern /* HOSTPC: offset 0x84 */ 186*72dd1843SKees Cook u32 hostpc[HCS_N_PORTS_MAX]; 187331ac6b2SAlek Du #define HOSTPC_PHCD (1<<22) /* Phy clock disable */ 188331ac6b2SAlek Du #define HOSTPC_PSPD (3<<25) /* Port speed detection */ 189a46af4ebSAlan Stern 190*72dd1843SKees Cook u32 reserved5[2]; 191a46af4ebSAlan Stern 192a46af4ebSAlan Stern /* USBMODE_EX: offset 0xc8 */ 193a46af4ebSAlan Stern u32 usbmode_ex; /* USB Device mode extension */ 194331ac6b2SAlek Du #define USBMODE_EX_VBPS (1<<5) /* VBus Power Select On */ 195331ac6b2SAlek Du #define USBMODE_EX_HC (3<<0) /* host controller mode */ 196a46af4ebSAlan Stern }; 197331ac6b2SAlek Du 1980af36739SYinghai Lu #endif /* __LINUX_USB_EHCI_DEF_H */ 199