1*83d290c5STom Rini /* SPDX-License-Identifier: GPL-2.0+ */ 2f4d9bd06SMarek Vasut /* linux/arch/arm/plat-s3c/include/plat/regs-otg.h 3f4d9bd06SMarek Vasut * 4f4d9bd06SMarek Vasut * Copyright (C) 2004 Herbert Poetzl <herbert@13thfloor.at> 5f4d9bd06SMarek Vasut * 6f4d9bd06SMarek Vasut * Registers remapping: 7f4d9bd06SMarek Vasut * Lukasz Majewski <l.majewski@samsumg.com> 8f4d9bd06SMarek Vasut */ 9f4d9bd06SMarek Vasut 10f4d9bd06SMarek Vasut #ifndef __ASM_ARCH_REGS_USB_OTG_HS_H 11f4d9bd06SMarek Vasut #define __ASM_ARCH_REGS_USB_OTG_HS_H 12f4d9bd06SMarek Vasut 13f4d9bd06SMarek Vasut /* USB2.0 OTG Controller register */ 14f4d9bd06SMarek Vasut struct dwc2_usbotg_phy { 15f4d9bd06SMarek Vasut u32 phypwr; 16f4d9bd06SMarek Vasut u32 phyclk; 17f4d9bd06SMarek Vasut u32 rstcon; 18f4d9bd06SMarek Vasut }; 19f4d9bd06SMarek Vasut 20f4d9bd06SMarek Vasut /* Device Logical IN Endpoint-Specific Registers */ 21f4d9bd06SMarek Vasut struct dwc2_dev_in_endp { 22f4d9bd06SMarek Vasut u32 diepctl; 23f4d9bd06SMarek Vasut u8 res1[4]; 24f4d9bd06SMarek Vasut u32 diepint; 25f4d9bd06SMarek Vasut u8 res2[4]; 26f4d9bd06SMarek Vasut u32 dieptsiz; 27f4d9bd06SMarek Vasut u32 diepdma; 28f4d9bd06SMarek Vasut u8 res3[4]; 29f4d9bd06SMarek Vasut u32 diepdmab; 30f4d9bd06SMarek Vasut }; 31f4d9bd06SMarek Vasut 32f4d9bd06SMarek Vasut /* Device Logical OUT Endpoint-Specific Registers */ 33f4d9bd06SMarek Vasut struct dwc2_dev_out_endp { 34f4d9bd06SMarek Vasut u32 doepctl; 35f4d9bd06SMarek Vasut u8 res1[4]; 36f4d9bd06SMarek Vasut u32 doepint; 37f4d9bd06SMarek Vasut u8 res2[4]; 38f4d9bd06SMarek Vasut u32 doeptsiz; 39f4d9bd06SMarek Vasut u32 doepdma; 40f4d9bd06SMarek Vasut u8 res3[4]; 41f4d9bd06SMarek Vasut u32 doepdmab; 42f4d9bd06SMarek Vasut }; 43f4d9bd06SMarek Vasut 44f4d9bd06SMarek Vasut struct ep_fifo { 45f4d9bd06SMarek Vasut u32 fifo; 46f4d9bd06SMarek Vasut u8 res[4092]; 47f4d9bd06SMarek Vasut }; 48f4d9bd06SMarek Vasut 49f4d9bd06SMarek Vasut /* USB2.0 OTG Controller register */ 50f4d9bd06SMarek Vasut struct dwc2_usbotg_reg { 51f4d9bd06SMarek Vasut /* Core Global Registers */ 52f4d9bd06SMarek Vasut u32 gotgctl; /* OTG Control & Status */ 53f4d9bd06SMarek Vasut u32 gotgint; /* OTG Interrupt */ 54f4d9bd06SMarek Vasut u32 gahbcfg; /* Core AHB Configuration */ 55f4d9bd06SMarek Vasut u32 gusbcfg; /* Core USB Configuration */ 56f4d9bd06SMarek Vasut u32 grstctl; /* Core Reset */ 57f4d9bd06SMarek Vasut u32 gintsts; /* Core Interrupt */ 58f4d9bd06SMarek Vasut u32 gintmsk; /* Core Interrupt Mask */ 59f4d9bd06SMarek Vasut u32 grxstsr; /* Receive Status Debug Read/Status Read */ 60f4d9bd06SMarek Vasut u32 grxstsp; /* Receive Status Debug Pop/Status Pop */ 61f4d9bd06SMarek Vasut u32 grxfsiz; /* Receive FIFO Size */ 62f4d9bd06SMarek Vasut u32 gnptxfsiz; /* Non-Periodic Transmit FIFO Size */ 63f4d9bd06SMarek Vasut u8 res1[216]; 64f4d9bd06SMarek Vasut u32 dieptxf[15]; /* Device Periodic Transmit FIFO size register */ 65f4d9bd06SMarek Vasut u8 res2[1728]; 66f4d9bd06SMarek Vasut /* Device Configuration */ 67f4d9bd06SMarek Vasut u32 dcfg; /* Device Configuration Register */ 68f4d9bd06SMarek Vasut u32 dctl; /* Device Control */ 69f4d9bd06SMarek Vasut u32 dsts; /* Device Status */ 70f4d9bd06SMarek Vasut u8 res3[4]; 71f4d9bd06SMarek Vasut u32 diepmsk; /* Device IN Endpoint Common Interrupt Mask */ 72f4d9bd06SMarek Vasut u32 doepmsk; /* Device OUT Endpoint Common Interrupt Mask */ 73f4d9bd06SMarek Vasut u32 daint; /* Device All Endpoints Interrupt */ 74f4d9bd06SMarek Vasut u32 daintmsk; /* Device All Endpoints Interrupt Mask */ 75f4d9bd06SMarek Vasut u8 res4[224]; 76f4d9bd06SMarek Vasut struct dwc2_dev_in_endp in_endp[16]; 77f4d9bd06SMarek Vasut struct dwc2_dev_out_endp out_endp[16]; 78f4d9bd06SMarek Vasut u8 res5[768]; 79f4d9bd06SMarek Vasut struct ep_fifo ep[16]; 80f4d9bd06SMarek Vasut }; 81f4d9bd06SMarek Vasut 82f4d9bd06SMarek Vasut /*===================================================================== */ 83f4d9bd06SMarek Vasut /*definitions related to CSR setting */ 84f4d9bd06SMarek Vasut 85507e677bSMarek Vasut /* DWC2_UDC_OTG_GOTGCTL */ 86f4d9bd06SMarek Vasut #define B_SESSION_VALID (0x1<<19) 87f4d9bd06SMarek Vasut #define A_SESSION_VALID (0x1<<18) 88f4d9bd06SMarek Vasut 89507e677bSMarek Vasut /* DWC2_UDC_OTG_GAHBCFG */ 90f4d9bd06SMarek Vasut #define PTXFE_HALF (0<<8) 91f4d9bd06SMarek Vasut #define PTXFE_ZERO (1<<8) 92f4d9bd06SMarek Vasut #define NPTXFE_HALF (0<<7) 93f4d9bd06SMarek Vasut #define NPTXFE_ZERO (1<<7) 94f4d9bd06SMarek Vasut #define MODE_SLAVE (0<<5) 95f4d9bd06SMarek Vasut #define MODE_DMA (1<<5) 96f4d9bd06SMarek Vasut #define BURST_SINGLE (0<<1) 97f4d9bd06SMarek Vasut #define BURST_INCR (1<<1) 98f4d9bd06SMarek Vasut #define BURST_INCR4 (3<<1) 99f4d9bd06SMarek Vasut #define BURST_INCR8 (5<<1) 100f4d9bd06SMarek Vasut #define BURST_INCR16 (7<<1) 101f4d9bd06SMarek Vasut #define GBL_INT_UNMASK (1<<0) 102f4d9bd06SMarek Vasut #define GBL_INT_MASK (0<<0) 103f4d9bd06SMarek Vasut 104507e677bSMarek Vasut /* DWC2_UDC_OTG_GRSTCTL */ 105f4d9bd06SMarek Vasut #define AHB_MASTER_IDLE (1u<<31) 106f4d9bd06SMarek Vasut #define CORE_SOFT_RESET (0x1<<0) 107f4d9bd06SMarek Vasut 108507e677bSMarek Vasut /* DWC2_UDC_OTG_GINTSTS/DWC2_UDC_OTG_GINTMSK core interrupt register */ 109f4d9bd06SMarek Vasut #define INT_RESUME (1u<<31) 110f4d9bd06SMarek Vasut #define INT_DISCONN (0x1<<29) 111f4d9bd06SMarek Vasut #define INT_CONN_ID_STS_CNG (0x1<<28) 112f4d9bd06SMarek Vasut #define INT_OUT_EP (0x1<<19) 113f4d9bd06SMarek Vasut #define INT_IN_EP (0x1<<18) 114f4d9bd06SMarek Vasut #define INT_ENUMDONE (0x1<<13) 115f4d9bd06SMarek Vasut #define INT_RESET (0x1<<12) 116f4d9bd06SMarek Vasut #define INT_SUSPEND (0x1<<11) 117f4d9bd06SMarek Vasut #define INT_EARLY_SUSPEND (0x1<<10) 118f4d9bd06SMarek Vasut #define INT_NP_TX_FIFO_EMPTY (0x1<<5) 119f4d9bd06SMarek Vasut #define INT_RX_FIFO_NOT_EMPTY (0x1<<4) 120f4d9bd06SMarek Vasut #define INT_SOF (0x1<<3) 121f4d9bd06SMarek Vasut #define INT_DEV_MODE (0x0<<0) 122f4d9bd06SMarek Vasut #define INT_HOST_MODE (0x1<<1) 123f4d9bd06SMarek Vasut #define INT_GOUTNakEff (0x01<<7) 124f4d9bd06SMarek Vasut #define INT_GINNakEff (0x01<<6) 125f4d9bd06SMarek Vasut 126f4d9bd06SMarek Vasut #define FULL_SPEED_CONTROL_PKT_SIZE 8 127f4d9bd06SMarek Vasut #define FULL_SPEED_BULK_PKT_SIZE 64 128f4d9bd06SMarek Vasut 129f4d9bd06SMarek Vasut #define HIGH_SPEED_CONTROL_PKT_SIZE 64 130f4d9bd06SMarek Vasut #define HIGH_SPEED_BULK_PKT_SIZE 512 131f4d9bd06SMarek Vasut 13247117882SXu Ziyuan #define RX_FIFO_SIZE (1024) 13347117882SXu Ziyuan #define NPTX_FIFO_SIZE (1024) 13447117882SXu Ziyuan #define PTX_FIFO_SIZE (384) 135f4d9bd06SMarek Vasut 136f4d9bd06SMarek Vasut #define DEPCTL_TXFNUM_0 (0x0<<22) 137f4d9bd06SMarek Vasut #define DEPCTL_TXFNUM_1 (0x1<<22) 138f4d9bd06SMarek Vasut #define DEPCTL_TXFNUM_2 (0x2<<22) 139f4d9bd06SMarek Vasut #define DEPCTL_TXFNUM_3 (0x3<<22) 140f4d9bd06SMarek Vasut #define DEPCTL_TXFNUM_4 (0x4<<22) 141f4d9bd06SMarek Vasut 142f4d9bd06SMarek Vasut /* Enumeration speed */ 143f4d9bd06SMarek Vasut #define USB_HIGH_30_60MHZ (0x0<<1) 144f4d9bd06SMarek Vasut #define USB_FULL_30_60MHZ (0x1<<1) 145f4d9bd06SMarek Vasut #define USB_LOW_6MHZ (0x2<<1) 146f4d9bd06SMarek Vasut #define USB_FULL_48MHZ (0x3<<1) 147f4d9bd06SMarek Vasut 148507e677bSMarek Vasut /* DWC2_UDC_OTG_GRXSTSP STATUS */ 149f4d9bd06SMarek Vasut #define OUT_PKT_RECEIVED (0x2<<17) 150f4d9bd06SMarek Vasut #define OUT_TRANSFER_COMPLELTED (0x3<<17) 151f4d9bd06SMarek Vasut #define SETUP_TRANSACTION_COMPLETED (0x4<<17) 152f4d9bd06SMarek Vasut #define SETUP_PKT_RECEIVED (0x6<<17) 153f4d9bd06SMarek Vasut #define GLOBAL_OUT_NAK (0x1<<17) 154f4d9bd06SMarek Vasut 155507e677bSMarek Vasut /* DWC2_UDC_OTG_DCTL device control register */ 156f4d9bd06SMarek Vasut #define NORMAL_OPERATION (0x1<<0) 157f4d9bd06SMarek Vasut #define SOFT_DISCONNECT (0x1<<1) 158f4d9bd06SMarek Vasut 159507e677bSMarek Vasut /* DWC2_UDC_OTG_DAINT device all endpoint interrupt register */ 160f4d9bd06SMarek Vasut #define DAINT_OUT_BIT (16) 161f4d9bd06SMarek Vasut #define DAINT_MASK (0xFFFF) 162f4d9bd06SMarek Vasut 163507e677bSMarek Vasut /* DWC2_UDC_OTG_DIEPCTL0/DOEPCTL0 device 164f4d9bd06SMarek Vasut control IN/OUT endpoint 0 control register */ 165f4d9bd06SMarek Vasut #define DEPCTL_EPENA (0x1<<31) 166f4d9bd06SMarek Vasut #define DEPCTL_EPDIS (0x1<<30) 167f4d9bd06SMarek Vasut #define DEPCTL_SETD1PID (0x1<<29) 168f4d9bd06SMarek Vasut #define DEPCTL_SETD0PID (0x1<<28) 169f4d9bd06SMarek Vasut #define DEPCTL_SNAK (0x1<<27) 170f4d9bd06SMarek Vasut #define DEPCTL_CNAK (0x1<<26) 171f4d9bd06SMarek Vasut #define DEPCTL_STALL (0x1<<21) 172f4d9bd06SMarek Vasut #define DEPCTL_TYPE_BIT (18) 173f4d9bd06SMarek Vasut #define DEPCTL_TYPE_MASK (0x3<<18) 174f4d9bd06SMarek Vasut #define DEPCTL_CTRL_TYPE (0x0<<18) 175f4d9bd06SMarek Vasut #define DEPCTL_ISO_TYPE (0x1<<18) 176f4d9bd06SMarek Vasut #define DEPCTL_BULK_TYPE (0x2<<18) 177f4d9bd06SMarek Vasut #define DEPCTL_INTR_TYPE (0x3<<18) 178f4d9bd06SMarek Vasut #define DEPCTL_USBACTEP (0x1<<15) 179f4d9bd06SMarek Vasut #define DEPCTL_NEXT_EP_BIT (11) 180f4d9bd06SMarek Vasut #define DEPCTL_MPS_BIT (0) 181f4d9bd06SMarek Vasut #define DEPCTL_MPS_MASK (0x7FF) 182f4d9bd06SMarek Vasut 183f4d9bd06SMarek Vasut #define DEPCTL0_MPS_64 (0x0<<0) 184f4d9bd06SMarek Vasut #define DEPCTL0_MPS_32 (0x1<<0) 185f4d9bd06SMarek Vasut #define DEPCTL0_MPS_16 (0x2<<0) 186f4d9bd06SMarek Vasut #define DEPCTL0_MPS_8 (0x3<<0) 187f4d9bd06SMarek Vasut #define DEPCTL_MPS_BULK_512 (512<<0) 188f4d9bd06SMarek Vasut #define DEPCTL_MPS_INT_MPS_16 (16<<0) 189f4d9bd06SMarek Vasut 190f4d9bd06SMarek Vasut #define DIEPCTL0_NEXT_EP_BIT (11) 191f4d9bd06SMarek Vasut 192f4d9bd06SMarek Vasut 193507e677bSMarek Vasut /* DWC2_UDC_OTG_DIEPMSK/DOEPMSK device IN/OUT endpoint 194f4d9bd06SMarek Vasut common interrupt mask register */ 195507e677bSMarek Vasut /* DWC2_UDC_OTG_DIEPINTn/DOEPINTn device IN/OUT endpoint interrupt register */ 196f4d9bd06SMarek Vasut #define BACK2BACK_SETUP_RECEIVED (0x1<<6) 197f4d9bd06SMarek Vasut #define INTKNEPMIS (0x1<<5) 198f4d9bd06SMarek Vasut #define INTKN_TXFEMP (0x1<<4) 199f4d9bd06SMarek Vasut #define NON_ISO_IN_EP_TIMEOUT (0x1<<3) 200f4d9bd06SMarek Vasut #define CTRL_OUT_EP_SETUP_PHASE_DONE (0x1<<3) 201f4d9bd06SMarek Vasut #define AHB_ERROR (0x1<<2) 202f4d9bd06SMarek Vasut #define EPDISBLD (0x1<<1) 203f4d9bd06SMarek Vasut #define TRANSFER_DONE (0x1<<0) 204f4d9bd06SMarek Vasut 205f4d9bd06SMarek Vasut #define USB_PHY_CTRL_EN0 (0x1 << 0) 206f4d9bd06SMarek Vasut 207f4d9bd06SMarek Vasut /* OPHYPWR */ 208f4d9bd06SMarek Vasut #define PHY_0_SLEEP (0x1 << 5) 209f4d9bd06SMarek Vasut #define OTG_DISABLE_0 (0x1 << 4) 210f4d9bd06SMarek Vasut #define ANALOG_PWRDOWN (0x1 << 3) 211f4d9bd06SMarek Vasut #define FORCE_SUSPEND_0 (0x1 << 0) 212f4d9bd06SMarek Vasut 213f4d9bd06SMarek Vasut /* URSTCON */ 214f4d9bd06SMarek Vasut #define HOST_SW_RST (0x1 << 4) 215f4d9bd06SMarek Vasut #define PHY_SW_RST1 (0x1 << 3) 216f4d9bd06SMarek Vasut #define PHYLNK_SW_RST (0x1 << 2) 217f4d9bd06SMarek Vasut #define LINK_SW_RST (0x1 << 1) 218f4d9bd06SMarek Vasut #define PHY_SW_RST0 (0x1 << 0) 219f4d9bd06SMarek Vasut 220f4d9bd06SMarek Vasut /* OPHYCLK */ 221f4d9bd06SMarek Vasut #define COMMON_ON_N1 (0x1 << 7) 222f4d9bd06SMarek Vasut #define COMMON_ON_N0 (0x1 << 4) 223f4d9bd06SMarek Vasut #define ID_PULLUP0 (0x1 << 2) 224f4d9bd06SMarek Vasut #define CLK_SEL_24MHZ (0x3 << 0) 225f4d9bd06SMarek Vasut #define CLK_SEL_12MHZ (0x2 << 0) 226f4d9bd06SMarek Vasut #define CLK_SEL_48MHZ (0x0 << 0) 227f4d9bd06SMarek Vasut 228f4d9bd06SMarek Vasut #define EXYNOS4X12_ID_PULLUP0 (0x01 << 3) 229f4d9bd06SMarek Vasut #define EXYNOS4X12_COMMON_ON_N0 (0x01 << 4) 230f4d9bd06SMarek Vasut #define EXYNOS4X12_CLK_SEL_12MHZ (0x02 << 0) 231f4d9bd06SMarek Vasut #define EXYNOS4X12_CLK_SEL_24MHZ (0x05 << 0) 232f4d9bd06SMarek Vasut 233f4d9bd06SMarek Vasut /* Device Configuration Register DCFG */ 234f4d9bd06SMarek Vasut #define DEV_SPEED_HIGH_SPEED_20 (0x0 << 0) 235f4d9bd06SMarek Vasut #define DEV_SPEED_FULL_SPEED_20 (0x1 << 0) 236f4d9bd06SMarek Vasut #define DEV_SPEED_LOW_SPEED_11 (0x2 << 0) 237f4d9bd06SMarek Vasut #define DEV_SPEED_FULL_SPEED_11 (0x3 << 0) 238f4d9bd06SMarek Vasut #define EP_MISS_CNT(x) (x << 18) 239f4d9bd06SMarek Vasut #define DEVICE_ADDRESS(x) (x << 4) 240f4d9bd06SMarek Vasut 241f4d9bd06SMarek Vasut /* Core Reset Register (GRSTCTL) */ 242f4d9bd06SMarek Vasut #define TX_FIFO_FLUSH (0x1 << 5) 243f4d9bd06SMarek Vasut #define RX_FIFO_FLUSH (0x1 << 4) 244f4d9bd06SMarek Vasut #define TX_FIFO_NUMBER(x) (x << 6) 245f4d9bd06SMarek Vasut #define TX_FIFO_FLUSH_ALL TX_FIFO_NUMBER(0x10) 246f4d9bd06SMarek Vasut 247f4d9bd06SMarek Vasut /* Masks definitions */ 248f4d9bd06SMarek Vasut #define GINTMSK_INIT (INT_OUT_EP | INT_IN_EP | INT_RESUME | INT_ENUMDONE\ 249f4d9bd06SMarek Vasut | INT_RESET | INT_SUSPEND) 250f4d9bd06SMarek Vasut #define DOEPMSK_INIT (CTRL_OUT_EP_SETUP_PHASE_DONE | AHB_ERROR|TRANSFER_DONE) 251f4d9bd06SMarek Vasut #define DIEPMSK_INIT (NON_ISO_IN_EP_TIMEOUT|AHB_ERROR|TRANSFER_DONE) 252f4d9bd06SMarek Vasut #define GAHBCFG_INIT (PTXFE_HALF | NPTXFE_HALF | MODE_DMA | BURST_INCR4\ 253f4d9bd06SMarek Vasut | GBL_INT_UNMASK) 254f4d9bd06SMarek Vasut 255f4d9bd06SMarek Vasut /* Device Endpoint X Transfer Size Register (DIEPTSIZX) */ 256f4d9bd06SMarek Vasut #define DIEPT_SIZ_PKT_CNT(x) (x << 19) 257f4d9bd06SMarek Vasut #define DIEPT_SIZ_XFER_SIZE(x) (x << 0) 258f4d9bd06SMarek Vasut 259f4d9bd06SMarek Vasut /* Device OUT Endpoint X Transfer Size Register (DOEPTSIZX) */ 260f4d9bd06SMarek Vasut #define DOEPT_SIZ_PKT_CNT(x) (x << 19) 261f4d9bd06SMarek Vasut #define DOEPT_SIZ_XFER_SIZE(x) (x << 0) 262f4d9bd06SMarek Vasut #define DOEPT_SIZ_XFER_SIZE_MAX_EP0 (0x7F << 0) 263f4d9bd06SMarek Vasut #define DOEPT_SIZ_XFER_SIZE_MAX_EP (0x7FFF << 0) 264f4d9bd06SMarek Vasut 265f4d9bd06SMarek Vasut /* Device Endpoint-N Control Register (DIEPCTLn/DOEPCTLn) */ 266f4d9bd06SMarek Vasut #define DIEPCTL_TX_FIFO_NUM(x) (x << 22) 267f4d9bd06SMarek Vasut #define DIEPCTL_TX_FIFO_NUM_MASK (~DIEPCTL_TX_FIFO_NUM(0xF)) 268f4d9bd06SMarek Vasut 269f4d9bd06SMarek Vasut /* Device ALL Endpoints Interrupt Register (DAINT) */ 270f4d9bd06SMarek Vasut #define DAINT_IN_EP_INT(x) (x << 0) 271f4d9bd06SMarek Vasut #define DAINT_OUT_EP_INT(x) (x << 16) 272f4d9bd06SMarek Vasut #endif 273