18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * bits.h - register bits of the ChipIdea USB IP core 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2008 Chipidea - MIPS Technologies, Inc. All rights reserved. 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Author: David Lopo 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#ifndef __DRIVERS_USB_CHIPIDEA_BITS_H 118c2ecf20Sopenharmony_ci#define __DRIVERS_USB_CHIPIDEA_BITS_H 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#include <linux/usb/ehci_def.h> 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci/* 168c2ecf20Sopenharmony_ci * ID 178c2ecf20Sopenharmony_ci * For 1.x revision, bit24 - bit31 are reserved 188c2ecf20Sopenharmony_ci * For 2.x revision, bit25 - bit28 are 0x2 198c2ecf20Sopenharmony_ci */ 208c2ecf20Sopenharmony_ci#define TAG (0x1F << 16) 218c2ecf20Sopenharmony_ci#define REVISION (0xF << 21) 228c2ecf20Sopenharmony_ci#define VERSION (0xF << 25) 238c2ecf20Sopenharmony_ci#define CIVERSION (0x7 << 29) 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci/* SBUSCFG */ 268c2ecf20Sopenharmony_ci#define AHBBRST_MASK 0x7 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci/* HCCPARAMS */ 298c2ecf20Sopenharmony_ci#define HCCPARAMS_LEN BIT(17) 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci/* DCCPARAMS */ 328c2ecf20Sopenharmony_ci#define DCCPARAMS_DEN (0x1F << 0) 338c2ecf20Sopenharmony_ci#define DCCPARAMS_DC BIT(7) 348c2ecf20Sopenharmony_ci#define DCCPARAMS_HC BIT(8) 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci/* TESTMODE */ 378c2ecf20Sopenharmony_ci#define TESTMODE_FORCE BIT(0) 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci/* USBCMD */ 408c2ecf20Sopenharmony_ci#define USBCMD_RS BIT(0) 418c2ecf20Sopenharmony_ci#define USBCMD_RST BIT(1) 428c2ecf20Sopenharmony_ci#define USBCMD_SUTW BIT(13) 438c2ecf20Sopenharmony_ci#define USBCMD_ATDTW BIT(14) 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci/* USBSTS & USBINTR */ 468c2ecf20Sopenharmony_ci#define USBi_UI BIT(0) 478c2ecf20Sopenharmony_ci#define USBi_UEI BIT(1) 488c2ecf20Sopenharmony_ci#define USBi_PCI BIT(2) 498c2ecf20Sopenharmony_ci#define USBi_URI BIT(6) 508c2ecf20Sopenharmony_ci#define USBi_SLI BIT(8) 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci/* DEVICEADDR */ 538c2ecf20Sopenharmony_ci#define DEVICEADDR_USBADRA BIT(24) 548c2ecf20Sopenharmony_ci#define DEVICEADDR_USBADR (0x7FUL << 25) 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci/* TTCTRL */ 578c2ecf20Sopenharmony_ci#define TTCTRL_TTHA_MASK (0x7fUL << 24) 588c2ecf20Sopenharmony_ci/* Set non-zero value for internal TT Hub address representation */ 598c2ecf20Sopenharmony_ci#define TTCTRL_TTHA (0x7fUL << 24) 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ci/* BURSTSIZE */ 628c2ecf20Sopenharmony_ci#define RX_BURST_MASK 0xff 638c2ecf20Sopenharmony_ci#define TX_BURST_MASK 0xff00 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci/* PORTSC */ 668c2ecf20Sopenharmony_ci#define PORTSC_CCS BIT(0) 678c2ecf20Sopenharmony_ci#define PORTSC_CSC BIT(1) 688c2ecf20Sopenharmony_ci#define PORTSC_PEC BIT(3) 698c2ecf20Sopenharmony_ci#define PORTSC_OCC BIT(5) 708c2ecf20Sopenharmony_ci#define PORTSC_FPR BIT(6) 718c2ecf20Sopenharmony_ci#define PORTSC_SUSP BIT(7) 728c2ecf20Sopenharmony_ci#define PORTSC_HSP BIT(9) 738c2ecf20Sopenharmony_ci#define PORTSC_PP BIT(12) 748c2ecf20Sopenharmony_ci#define PORTSC_PTC (0x0FUL << 16) 758c2ecf20Sopenharmony_ci#define PORTSC_WKCN BIT(20) 768c2ecf20Sopenharmony_ci#define PORTSC_PHCD(d) ((d) ? BIT(22) : BIT(23)) 778c2ecf20Sopenharmony_ci/* PTS and PTW for non lpm version only */ 788c2ecf20Sopenharmony_ci#define PORTSC_PFSC BIT(24) 798c2ecf20Sopenharmony_ci#define PORTSC_PTS(d) \ 808c2ecf20Sopenharmony_ci (u32)((((d) & 0x3) << 30) | (((d) & 0x4) ? BIT(25) : 0)) 818c2ecf20Sopenharmony_ci#define PORTSC_PTW BIT(28) 828c2ecf20Sopenharmony_ci#define PORTSC_STS BIT(29) 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci#define PORTSC_W1C_BITS \ 858c2ecf20Sopenharmony_ci (PORTSC_CSC | PORTSC_PEC | PORTSC_OCC) 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci/* DEVLC */ 888c2ecf20Sopenharmony_ci#define DEVLC_PFSC BIT(23) 898c2ecf20Sopenharmony_ci#define DEVLC_PSPD (0x03UL << 25) 908c2ecf20Sopenharmony_ci#define DEVLC_PSPD_HS (0x02UL << 25) 918c2ecf20Sopenharmony_ci#define DEVLC_PTW BIT(27) 928c2ecf20Sopenharmony_ci#define DEVLC_STS BIT(28) 938c2ecf20Sopenharmony_ci#define DEVLC_PTS(d) (u32)(((d) & 0x7) << 29) 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci/* Encoding for DEVLC_PTS and PORTSC_PTS */ 968c2ecf20Sopenharmony_ci#define PTS_UTMI 0 978c2ecf20Sopenharmony_ci#define PTS_ULPI 2 988c2ecf20Sopenharmony_ci#define PTS_SERIAL 3 998c2ecf20Sopenharmony_ci#define PTS_HSIC 4 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_ci/* OTGSC */ 1028c2ecf20Sopenharmony_ci#define OTGSC_IDPU BIT(5) 1038c2ecf20Sopenharmony_ci#define OTGSC_HADP BIT(6) 1048c2ecf20Sopenharmony_ci#define OTGSC_HABA BIT(7) 1058c2ecf20Sopenharmony_ci#define OTGSC_ID BIT(8) 1068c2ecf20Sopenharmony_ci#define OTGSC_AVV BIT(9) 1078c2ecf20Sopenharmony_ci#define OTGSC_ASV BIT(10) 1088c2ecf20Sopenharmony_ci#define OTGSC_BSV BIT(11) 1098c2ecf20Sopenharmony_ci#define OTGSC_BSE BIT(12) 1108c2ecf20Sopenharmony_ci#define OTGSC_IDIS BIT(16) 1118c2ecf20Sopenharmony_ci#define OTGSC_AVVIS BIT(17) 1128c2ecf20Sopenharmony_ci#define OTGSC_ASVIS BIT(18) 1138c2ecf20Sopenharmony_ci#define OTGSC_BSVIS BIT(19) 1148c2ecf20Sopenharmony_ci#define OTGSC_BSEIS BIT(20) 1158c2ecf20Sopenharmony_ci#define OTGSC_1MSIS BIT(21) 1168c2ecf20Sopenharmony_ci#define OTGSC_DPIS BIT(22) 1178c2ecf20Sopenharmony_ci#define OTGSC_IDIE BIT(24) 1188c2ecf20Sopenharmony_ci#define OTGSC_AVVIE BIT(25) 1198c2ecf20Sopenharmony_ci#define OTGSC_ASVIE BIT(26) 1208c2ecf20Sopenharmony_ci#define OTGSC_BSVIE BIT(27) 1218c2ecf20Sopenharmony_ci#define OTGSC_BSEIE BIT(28) 1228c2ecf20Sopenharmony_ci#define OTGSC_1MSIE BIT(29) 1238c2ecf20Sopenharmony_ci#define OTGSC_DPIE BIT(30) 1248c2ecf20Sopenharmony_ci#define OTGSC_INT_EN_BITS (OTGSC_IDIE | OTGSC_AVVIE | OTGSC_ASVIE \ 1258c2ecf20Sopenharmony_ci | OTGSC_BSVIE | OTGSC_BSEIE | OTGSC_1MSIE \ 1268c2ecf20Sopenharmony_ci | OTGSC_DPIE) 1278c2ecf20Sopenharmony_ci#define OTGSC_INT_STATUS_BITS (OTGSC_IDIS | OTGSC_AVVIS | OTGSC_ASVIS \ 1288c2ecf20Sopenharmony_ci | OTGSC_BSVIS | OTGSC_BSEIS | OTGSC_1MSIS \ 1298c2ecf20Sopenharmony_ci | OTGSC_DPIS) 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_ci/* USBMODE */ 1328c2ecf20Sopenharmony_ci#define USBMODE_CM (0x03UL << 0) 1338c2ecf20Sopenharmony_ci#define USBMODE_CM_DC (0x02UL << 0) 1348c2ecf20Sopenharmony_ci#define USBMODE_SLOM BIT(3) 1358c2ecf20Sopenharmony_ci#define USBMODE_CI_SDIS BIT(4) 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_ci/* ENDPTCTRL */ 1388c2ecf20Sopenharmony_ci#define ENDPTCTRL_RXS BIT(0) 1398c2ecf20Sopenharmony_ci#define ENDPTCTRL_RXT (0x03UL << 2) 1408c2ecf20Sopenharmony_ci#define ENDPTCTRL_RXR BIT(6) /* reserved for port 0 */ 1418c2ecf20Sopenharmony_ci#define ENDPTCTRL_RXE BIT(7) 1428c2ecf20Sopenharmony_ci#define ENDPTCTRL_TXS BIT(16) 1438c2ecf20Sopenharmony_ci#define ENDPTCTRL_TXT (0x03UL << 18) 1448c2ecf20Sopenharmony_ci#define ENDPTCTRL_TXR BIT(22) /* reserved for port 0 */ 1458c2ecf20Sopenharmony_ci#define ENDPTCTRL_TXE BIT(23) 1468c2ecf20Sopenharmony_ci 1478c2ecf20Sopenharmony_ci#endif /* __DRIVERS_USB_CHIPIDEA_BITS_H */ 148