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 */ 480af36739SYinghai Lu 490af36739SYinghai Lu u32 hcc_params; /* HCCPARAMS - offset 0x8 */ 50aa4d8342SAlek Du /* EHCI 1.1 addendum */ 51aa4d8342SAlek Du #define HCC_32FRAME_PERIODIC_LIST(p) ((p)&(1 << 19)) 52aa4d8342SAlek Du #define HCC_PER_PORT_CHANGE_EVENT(p) ((p)&(1 << 18)) 53aa4d8342SAlek Du #define HCC_LPM(p) ((p)&(1 << 17)) 54aa4d8342SAlek Du #define HCC_HW_PREFETCH(p) ((p)&(1 << 16)) 55aa4d8342SAlek Du 560af36739SYinghai Lu #define HCC_EXT_CAPS(p) (((p)>>8)&0xff) /* for pci extended caps */ 570af36739SYinghai Lu #define HCC_ISOC_CACHE(p) ((p)&(1 << 7)) /* true: can cache isoc frame */ 580af36739SYinghai Lu #define HCC_ISOC_THRES(p) (((p)>>4)&0x7) /* bits 6:4, uframes cached */ 590af36739SYinghai Lu #define HCC_CANPARK(p) ((p)&(1 << 2)) /* true: can park on async qh */ 600af36739SYinghai Lu #define HCC_PGM_FRAMELISTLEN(p) ((p)&(1 << 1)) /* true: periodic_size changes*/ 610af36739SYinghai Lu #define HCC_64BIT_ADDR(p) ((p)&(1)) /* true: can use 64-bit addr */ 620af36739SYinghai Lu u8 portroute[8]; /* nibbles for routing - offset 0xC */ 6313954017SRabin Vincent }; 640af36739SYinghai Lu 650af36739SYinghai Lu 660af36739SYinghai Lu /* Section 2.3 Host Controller Operational Registers */ 670af36739SYinghai Lu struct ehci_regs { 680af36739SYinghai Lu 690af36739SYinghai Lu /* USBCMD: offset 0x00 */ 700af36739SYinghai Lu u32 command; 71aa4d8342SAlek Du 72aa4d8342SAlek Du /* EHCI 1.1 addendum */ 73aa4d8342SAlek Du #define CMD_HIRD (0xf<<24) /* host initiated resume duration */ 74aa4d8342SAlek Du #define CMD_PPCEE (1<<15) /* per port change event enable */ 75aa4d8342SAlek Du #define CMD_FSP (1<<14) /* fully synchronized prefetch */ 76aa4d8342SAlek Du #define CMD_ASPE (1<<13) /* async schedule prefetch enable */ 77aa4d8342SAlek Du #define CMD_PSPE (1<<12) /* periodic schedule prefetch enable */ 780af36739SYinghai Lu /* 23:16 is r/w intr rate, in microframes; default "8" == 1/msec */ 790af36739SYinghai Lu #define CMD_PARK (1<<11) /* enable "park" on async qh */ 800af36739SYinghai Lu #define CMD_PARK_CNT(c) (((c)>>8)&3) /* how many transfers to park for */ 810af36739SYinghai Lu #define CMD_LRESET (1<<7) /* partial reset (no ports, etc) */ 820af36739SYinghai Lu #define CMD_IAAD (1<<6) /* "doorbell" interrupt async advance */ 830af36739SYinghai Lu #define CMD_ASE (1<<5) /* async schedule enable */ 840af36739SYinghai Lu #define CMD_PSE (1<<4) /* periodic schedule enable */ 850af36739SYinghai Lu /* 3:2 is periodic frame list size */ 860af36739SYinghai Lu #define CMD_RESET (1<<1) /* reset HC not bus */ 870af36739SYinghai Lu #define CMD_RUN (1<<0) /* start/stop HC */ 880af36739SYinghai Lu 890af36739SYinghai Lu /* USBSTS: offset 0x04 */ 900af36739SYinghai Lu u32 status; 91aa4d8342SAlek Du #define STS_PPCE_MASK (0xff<<16) /* Per-Port change event 1-16 */ 920af36739SYinghai Lu #define STS_ASS (1<<15) /* Async Schedule Status */ 930af36739SYinghai Lu #define STS_PSS (1<<14) /* Periodic Schedule Status */ 940af36739SYinghai Lu #define STS_RECL (1<<13) /* Reclamation */ 950af36739SYinghai Lu #define STS_HALT (1<<12) /* Not running (any reason) */ 960af36739SYinghai Lu /* some bits reserved */ 970af36739SYinghai Lu /* these STS_* flags are also intr_enable bits (USBINTR) */ 980af36739SYinghai Lu #define STS_IAA (1<<5) /* Interrupted on async advance */ 990af36739SYinghai Lu #define STS_FATAL (1<<4) /* such as some PCI access errors */ 1000af36739SYinghai Lu #define STS_FLR (1<<3) /* frame list rolled over */ 1010af36739SYinghai Lu #define STS_PCD (1<<2) /* port change detect */ 1020af36739SYinghai Lu #define STS_ERR (1<<1) /* "error" completion (overflow, ...) */ 1030af36739SYinghai Lu #define STS_INT (1<<0) /* "normal" completion (short, ...) */ 1040af36739SYinghai Lu 1050af36739SYinghai Lu /* USBINTR: offset 0x08 */ 1060af36739SYinghai Lu u32 intr_enable; 1070af36739SYinghai Lu 1080af36739SYinghai Lu /* FRINDEX: offset 0x0C */ 1090af36739SYinghai Lu u32 frame_index; /* current microframe number */ 1100af36739SYinghai Lu /* CTRLDSSEGMENT: offset 0x10 */ 1110af36739SYinghai Lu u32 segment; /* address bits 63:32 if needed */ 1120af36739SYinghai Lu /* PERIODICLISTBASE: offset 0x14 */ 1130af36739SYinghai Lu u32 frame_list; /* points to periodic list */ 1140af36739SYinghai Lu /* ASYNCLISTADDR: offset 0x18 */ 1150af36739SYinghai Lu u32 async_next; /* address of next async queue head */ 1160af36739SYinghai Lu 117a46af4ebSAlan Stern u32 reserved1[2]; 118a46af4ebSAlan Stern 119a46af4ebSAlan Stern /* TXFILLTUNING: offset 0x24 */ 120a46af4ebSAlan Stern u32 txfill_tuning; /* TX FIFO Tuning register */ 121a46af4ebSAlan Stern #define TXFIFO_DEFAULT (8<<16) /* FIFO burst threshold 8 */ 122a46af4ebSAlan Stern 123a46af4ebSAlan Stern u32 reserved2[6]; 1240af36739SYinghai Lu 1250af36739SYinghai Lu /* CONFIGFLAG: offset 0x40 */ 1260af36739SYinghai Lu u32 configured_flag; 1270af36739SYinghai Lu #define FLAG_CF (1<<0) /* true: we'll support "high speed" */ 1280af36739SYinghai Lu 1290af36739SYinghai Lu /* PORTSC: offset 0x44 */ 1300af36739SYinghai Lu u32 port_status[0]; /* up to N_PORTS */ 131aa4d8342SAlek Du /* EHCI 1.1 addendum */ 132aa4d8342SAlek Du #define PORTSC_SUSPEND_STS_ACK 0 133aa4d8342SAlek Du #define PORTSC_SUSPEND_STS_NYET 1 134aa4d8342SAlek Du #define PORTSC_SUSPEND_STS_STALL 2 135aa4d8342SAlek Du #define PORTSC_SUSPEND_STS_ERR 3 136aa4d8342SAlek Du 137aa4d8342SAlek Du #define PORT_DEV_ADDR (0x7f<<25) /* device address */ 138aa4d8342SAlek Du #define PORT_SSTS (0x3<<23) /* suspend status */ 1390af36739SYinghai Lu /* 31:23 reserved */ 1400af36739SYinghai Lu #define PORT_WKOC_E (1<<22) /* wake on overcurrent (enable) */ 1410af36739SYinghai Lu #define PORT_WKDISC_E (1<<21) /* wake on disconnect (enable) */ 1420af36739SYinghai Lu #define PORT_WKCONN_E (1<<20) /* wake on connect (enable) */ 1430af36739SYinghai Lu /* 19:16 for port testing */ 14479ad3b5aSBenoit Goby #define PORT_TEST(x) (((x)&0xf)<<16) /* Port Test Control */ 14579ad3b5aSBenoit Goby #define PORT_TEST_PKT PORT_TEST(0x4) /* Port Test Control - packet test */ 14679ad3b5aSBenoit Goby #define PORT_TEST_FORCE PORT_TEST(0x5) /* Port Test Control - force enable */ 1470af36739SYinghai Lu #define PORT_LED_OFF (0<<14) 1480af36739SYinghai Lu #define PORT_LED_AMBER (1<<14) 1490af36739SYinghai Lu #define PORT_LED_GREEN (2<<14) 1500af36739SYinghai Lu #define PORT_LED_MASK (3<<14) 1510af36739SYinghai Lu #define PORT_OWNER (1<<13) /* true: companion hc owns this port */ 1520af36739SYinghai Lu #define PORT_POWER (1<<12) /* true: has power (see PPC) */ 1530af36739SYinghai Lu #define PORT_USB11(x) (((x)&(3<<10)) == (1<<10)) /* USB 1.1 device */ 154*cc7eac1eSYoshihiro Shimoda #define PORT_LS_MASK (3<<10) /* Link status (SE0, K or J */ 1550af36739SYinghai Lu /* 9 reserved */ 156aa4d8342SAlek Du #define PORT_LPM (1<<9) /* LPM transaction */ 1570af36739SYinghai Lu #define PORT_RESET (1<<8) /* reset port */ 1580af36739SYinghai Lu #define PORT_SUSPEND (1<<7) /* suspend port */ 1590af36739SYinghai Lu #define PORT_RESUME (1<<6) /* resume it */ 1600af36739SYinghai Lu #define PORT_OCC (1<<5) /* over current change */ 1610af36739SYinghai Lu #define PORT_OC (1<<4) /* over current active */ 1620af36739SYinghai Lu #define PORT_PEC (1<<3) /* port enable change */ 1630af36739SYinghai Lu #define PORT_PE (1<<2) /* port enable */ 1640af36739SYinghai Lu #define PORT_CSC (1<<1) /* connect status change */ 1650af36739SYinghai Lu #define PORT_CONNECT (1<<0) /* device connected */ 1660af36739SYinghai Lu #define PORT_RWC_BITS (PORT_CSC | PORT_PEC | PORT_OCC) 1670af36739SYinghai Lu 168a46af4ebSAlan Stern u32 reserved3[9]; 169a46af4ebSAlan Stern 170a46af4ebSAlan Stern /* USBMODE: offset 0x68 */ 171a46af4ebSAlan Stern u32 usbmode; /* USB Device mode */ 1720af36739SYinghai Lu #define USBMODE_SDIS (1<<3) /* Stream disable */ 1730af36739SYinghai Lu #define USBMODE_BE (1<<2) /* BE/LE endianness select */ 1740af36739SYinghai Lu #define USBMODE_CM_HC (3<<0) /* host controller mode */ 1750af36739SYinghai Lu #define USBMODE_CM_IDLE (0<<0) /* idle state */ 1760af36739SYinghai Lu 17745c2da62SJim Lin u32 reserved4[6]; 178a46af4ebSAlan Stern 179331ac6b2SAlek Du /* Moorestown has some non-standard registers, partially due to the fact that 18025985edcSLucas De Marchi * its EHCI controller has both TT and LPM support. HOSTPCx are extensions to 181331ac6b2SAlek Du * PORTSCx 182331ac6b2SAlek Du */ 183a46af4ebSAlan Stern /* HOSTPC: offset 0x84 */ 1847e8b3dfeSAlan Stern u32 hostpc[0]; /* HOSTPC extension */ 185331ac6b2SAlek Du #define HOSTPC_PHCD (1<<22) /* Phy clock disable */ 186331ac6b2SAlek Du #define HOSTPC_PSPD (3<<25) /* Port speed detection */ 187a46af4ebSAlan Stern 1887e8b3dfeSAlan Stern u32 reserved5[17]; 189a46af4ebSAlan Stern 190a46af4ebSAlan Stern /* USBMODE_EX: offset 0xc8 */ 191a46af4ebSAlan Stern u32 usbmode_ex; /* USB Device mode extension */ 192331ac6b2SAlek Du #define USBMODE_EX_VBPS (1<<5) /* VBus Power Select On */ 193331ac6b2SAlek Du #define USBMODE_EX_HC (3<<0) /* host controller mode */ 194a46af4ebSAlan Stern }; 195331ac6b2SAlek Du 1960af36739SYinghai Lu #endif /* __LINUX_USB_EHCI_DEF_H */ 197