xref: /linux/drivers/usb/chipidea/bits.h (revision d9958306d4be14f4c7466242b38ed3893a7b1386)
1*d9958306SNishad Kamdar /* SPDX-License-Identifier: GPL-2.0 */
2e443b333SAlexander Shishkin /*
3e443b333SAlexander Shishkin  * bits.h - register bits of the ChipIdea USB IP core
4e443b333SAlexander Shishkin  *
5e443b333SAlexander Shishkin  * Copyright (C) 2008 Chipidea - MIPS Technologies, Inc. All rights reserved.
6e443b333SAlexander Shishkin  *
7e443b333SAlexander Shishkin  * Author: David Lopo
8e443b333SAlexander Shishkin  */
9e443b333SAlexander Shishkin 
10e443b333SAlexander Shishkin #ifndef __DRIVERS_USB_CHIPIDEA_BITS_H
11e443b333SAlexander Shishkin #define __DRIVERS_USB_CHIPIDEA_BITS_H
12e443b333SAlexander Shishkin 
13758fc986SAlexander Shishkin #include <linux/usb/ehci_def.h>
14758fc986SAlexander Shishkin 
15cb271f3cSPeter Chen /*
16cb271f3cSPeter Chen  * ID
17cb271f3cSPeter Chen  * For 1.x revision, bit24 - bit31 are reserved
18cb271f3cSPeter Chen  * For 2.x revision, bit25 - bit28 are 0x2
19cb271f3cSPeter Chen  */
20cb271f3cSPeter Chen #define TAG		      (0x1F << 16)
21cb271f3cSPeter Chen #define REVISION	      (0xF << 21)
22cb271f3cSPeter Chen #define VERSION		      (0xF << 25)
23cb271f3cSPeter Chen #define CIVERSION	      (0x7 << 29)
24cb271f3cSPeter Chen 
2565668718SPeter Chen /* SBUSCFG */
2665668718SPeter Chen #define AHBBRST_MASK		0x7
2765668718SPeter Chen 
28e443b333SAlexander Shishkin /* HCCPARAMS */
29e443b333SAlexander Shishkin #define HCCPARAMS_LEN         BIT(17)
30e443b333SAlexander Shishkin 
31e443b333SAlexander Shishkin /* DCCPARAMS */
32e443b333SAlexander Shishkin #define DCCPARAMS_DEN         (0x1F << 0)
33e443b333SAlexander Shishkin #define DCCPARAMS_DC          BIT(7)
34eb70e5abSAlexander Shishkin #define DCCPARAMS_HC          BIT(8)
35e443b333SAlexander Shishkin 
36e443b333SAlexander Shishkin /* TESTMODE */
37e443b333SAlexander Shishkin #define TESTMODE_FORCE        BIT(0)
38e443b333SAlexander Shishkin 
39e443b333SAlexander Shishkin /* USBCMD */
40e443b333SAlexander Shishkin #define USBCMD_RS             BIT(0)
41e443b333SAlexander Shishkin #define USBCMD_RST            BIT(1)
42e443b333SAlexander Shishkin #define USBCMD_SUTW           BIT(13)
43e443b333SAlexander Shishkin #define USBCMD_ATDTW          BIT(14)
44e443b333SAlexander Shishkin 
45e443b333SAlexander Shishkin /* USBSTS & USBINTR */
46e443b333SAlexander Shishkin #define USBi_UI               BIT(0)
47e443b333SAlexander Shishkin #define USBi_UEI              BIT(1)
48e443b333SAlexander Shishkin #define USBi_PCI              BIT(2)
49e443b333SAlexander Shishkin #define USBi_URI              BIT(6)
50e443b333SAlexander Shishkin #define USBi_SLI              BIT(8)
51e443b333SAlexander Shishkin 
52e443b333SAlexander Shishkin /* DEVICEADDR */
53e443b333SAlexander Shishkin #define DEVICEADDR_USBADRA    BIT(24)
54e443b333SAlexander Shishkin #define DEVICEADDR_USBADR     (0x7FUL << 25)
55e443b333SAlexander Shishkin 
5628362673SPeter Chen /* TTCTRL */
5728362673SPeter Chen #define TTCTRL_TTHA_MASK	(0x7fUL << 24)
5828362673SPeter Chen /* Set non-zero value for internal TT Hub address representation */
5928362673SPeter Chen #define TTCTRL_TTHA		(0x7fUL << 24)
6028362673SPeter Chen 
6196625eadSPeter Chen /* BURSTSIZE */
6296625eadSPeter Chen #define RX_BURST_MASK		0xff
6396625eadSPeter Chen #define TX_BURST_MASK		0xff00
6496625eadSPeter Chen 
65e443b333SAlexander Shishkin /* PORTSC */
66826cfe75SLi Jun #define PORTSC_CCS            BIT(0)
67826cfe75SLi Jun #define PORTSC_CSC            BIT(1)
68826cfe75SLi Jun #define PORTSC_PEC            BIT(3)
69826cfe75SLi Jun #define PORTSC_OCC            BIT(5)
70e443b333SAlexander Shishkin #define PORTSC_FPR            BIT(6)
71e443b333SAlexander Shishkin #define PORTSC_SUSP           BIT(7)
72e443b333SAlexander Shishkin #define PORTSC_HSP            BIT(9)
73826cfe75SLi Jun #define PORTSC_PP             BIT(12)
74e443b333SAlexander Shishkin #define PORTSC_PTC            (0x0FUL << 16)
75961ea496SLi Jun #define PORTSC_WKCN           BIT(20)
76864cf949SPeter Chen #define PORTSC_PHCD(d)	      ((d) ? BIT(22) : BIT(23))
7740dcd0e8SMichael Grzeschik /* PTS and PTW for non lpm version only */
784f6743d5SMichael Grzeschik #define PORTSC_PFSC           BIT(24)
7940dcd0e8SMichael Grzeschik #define PORTSC_PTS(d)						\
80dec23dcaSFabio Estevam 	(u32)((((d) & 0x3) << 30) | (((d) & 0x4) ? BIT(25) : 0))
8140dcd0e8SMichael Grzeschik #define PORTSC_PTW            BIT(28)
8240dcd0e8SMichael Grzeschik #define PORTSC_STS            BIT(29)
83e443b333SAlexander Shishkin 
84826cfe75SLi Jun #define PORTSC_W1C_BITS						\
85826cfe75SLi Jun 	(PORTSC_CSC | PORTSC_PEC | PORTSC_OCC)
86826cfe75SLi Jun 
87e443b333SAlexander Shishkin /* DEVLC */
884f6743d5SMichael Grzeschik #define DEVLC_PFSC            BIT(23)
89e443b333SAlexander Shishkin #define DEVLC_PSPD            (0x03UL << 25)
90e443b333SAlexander Shishkin #define DEVLC_PSPD_HS         (0x02UL << 25)
9140dcd0e8SMichael Grzeschik #define DEVLC_PTW             BIT(27)
9240dcd0e8SMichael Grzeschik #define DEVLC_STS             BIT(28)
93dec23dcaSFabio Estevam #define DEVLC_PTS(d)          (u32)(((d) & 0x7) << 29)
9440dcd0e8SMichael Grzeschik 
9540dcd0e8SMichael Grzeschik /* Encoding for DEVLC_PTS and PORTSC_PTS */
9640dcd0e8SMichael Grzeschik #define PTS_UTMI              0
9740dcd0e8SMichael Grzeschik #define PTS_ULPI              2
9840dcd0e8SMichael Grzeschik #define PTS_SERIAL            3
9940dcd0e8SMichael Grzeschik #define PTS_HSIC              4
100e443b333SAlexander Shishkin 
1015f36e231SAlexander Shishkin /* OTGSC */
1025f36e231SAlexander Shishkin #define OTGSC_IDPU	      BIT(5)
103826cfe75SLi Jun #define OTGSC_HADP	      BIT(6)
104e287b67bSLi Jun #define OTGSC_HABA	      BIT(7)
1055f36e231SAlexander Shishkin #define OTGSC_ID	      BIT(8)
1065f36e231SAlexander Shishkin #define OTGSC_AVV	      BIT(9)
1075f36e231SAlexander Shishkin #define OTGSC_ASV	      BIT(10)
1085f36e231SAlexander Shishkin #define OTGSC_BSV	      BIT(11)
1095f36e231SAlexander Shishkin #define OTGSC_BSE	      BIT(12)
1105f36e231SAlexander Shishkin #define OTGSC_IDIS	      BIT(16)
1115f36e231SAlexander Shishkin #define OTGSC_AVVIS	      BIT(17)
1125f36e231SAlexander Shishkin #define OTGSC_ASVIS	      BIT(18)
1135f36e231SAlexander Shishkin #define OTGSC_BSVIS	      BIT(19)
1145f36e231SAlexander Shishkin #define OTGSC_BSEIS	      BIT(20)
115c10b4f03SPeter Chen #define OTGSC_1MSIS	      BIT(21)
116c10b4f03SPeter Chen #define OTGSC_DPIS	      BIT(22)
1175f36e231SAlexander Shishkin #define OTGSC_IDIE	      BIT(24)
1185f36e231SAlexander Shishkin #define OTGSC_AVVIE	      BIT(25)
1195f36e231SAlexander Shishkin #define OTGSC_ASVIE	      BIT(26)
1205f36e231SAlexander Shishkin #define OTGSC_BSVIE	      BIT(27)
1215f36e231SAlexander Shishkin #define OTGSC_BSEIE	      BIT(28)
122c10b4f03SPeter Chen #define OTGSC_1MSIE	      BIT(29)
123c10b4f03SPeter Chen #define OTGSC_DPIE	      BIT(30)
124c10b4f03SPeter Chen #define OTGSC_INT_EN_BITS	(OTGSC_IDIE | OTGSC_AVVIE | OTGSC_ASVIE \
125c10b4f03SPeter Chen 				| OTGSC_BSVIE | OTGSC_BSEIE | OTGSC_1MSIE \
126c10b4f03SPeter Chen 				| OTGSC_DPIE)
127c10b4f03SPeter Chen #define OTGSC_INT_STATUS_BITS	(OTGSC_IDIS | OTGSC_AVVIS | OTGSC_ASVIS	\
128c10b4f03SPeter Chen 				| OTGSC_BSVIS | OTGSC_BSEIS | OTGSC_1MSIS \
129c10b4f03SPeter Chen 				| OTGSC_DPIS)
1305f36e231SAlexander Shishkin 
131e443b333SAlexander Shishkin /* USBMODE */
132e443b333SAlexander Shishkin #define USBMODE_CM            (0x03UL <<  0)
133758fc986SAlexander Shishkin #define USBMODE_CM_DC         (0x02UL <<  0)
134e443b333SAlexander Shishkin #define USBMODE_SLOM          BIT(3)
135758fc986SAlexander Shishkin #define USBMODE_CI_SDIS       BIT(4)
136e443b333SAlexander Shishkin 
137e443b333SAlexander Shishkin /* ENDPTCTRL */
138e443b333SAlexander Shishkin #define ENDPTCTRL_RXS         BIT(0)
139e443b333SAlexander Shishkin #define ENDPTCTRL_RXT         (0x03UL <<  2)
140e443b333SAlexander Shishkin #define ENDPTCTRL_RXR         BIT(6)         /* reserved for port 0 */
141e443b333SAlexander Shishkin #define ENDPTCTRL_RXE         BIT(7)
142e443b333SAlexander Shishkin #define ENDPTCTRL_TXS         BIT(16)
143e443b333SAlexander Shishkin #define ENDPTCTRL_TXT         (0x03UL << 18)
144e443b333SAlexander Shishkin #define ENDPTCTRL_TXR         BIT(22)        /* reserved for port 0 */
145e443b333SAlexander Shishkin #define ENDPTCTRL_TXE         BIT(23)
146e443b333SAlexander Shishkin 
147e443b333SAlexander Shishkin #endif /* __DRIVERS_USB_CHIPIDEA_BITS_H */
148