162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Definitions for TUSB6010 USB 2.0 OTG Dual Role controller 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Copyright (C) 2006 Nokia Corporation 662306a36Sopenharmony_ci * Tony Lindgren <tony@atomide.com> 762306a36Sopenharmony_ci */ 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci#ifndef __TUSB6010_H__ 1062306a36Sopenharmony_ci#define __TUSB6010_H__ 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci/* VLYNQ control register. 32-bit at offset 0x000 */ 1362306a36Sopenharmony_ci#define TUSB_VLYNQ_CTRL 0x004 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ci/* Mentor Graphics OTG core registers. 8,- 16- and 32-bit at offset 0x400 */ 1662306a36Sopenharmony_ci#define TUSB_BASE_OFFSET 0x400 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_ci/* FIFO registers 32-bit at offset 0x600 */ 1962306a36Sopenharmony_ci#define TUSB_FIFO_BASE 0x600 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ci/* Device System & Control registers. 32-bit at offset 0x800 */ 2262306a36Sopenharmony_ci#define TUSB_SYS_REG_BASE 0x800 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_ci#define TUSB_DEV_CONF (TUSB_SYS_REG_BASE + 0x000) 2562306a36Sopenharmony_ci#define TUSB_DEV_CONF_USB_HOST_MODE (1 << 16) 2662306a36Sopenharmony_ci#define TUSB_DEV_CONF_PROD_TEST_MODE (1 << 15) 2762306a36Sopenharmony_ci#define TUSB_DEV_CONF_SOFT_ID (1 << 1) 2862306a36Sopenharmony_ci#define TUSB_DEV_CONF_ID_SEL (1 << 0) 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ci#define TUSB_PHY_OTG_CTRL_ENABLE (TUSB_SYS_REG_BASE + 0x004) 3162306a36Sopenharmony_ci#define TUSB_PHY_OTG_CTRL (TUSB_SYS_REG_BASE + 0x008) 3262306a36Sopenharmony_ci#define TUSB_PHY_OTG_CTRL_WRPROTECT (0xa5 << 24) 3362306a36Sopenharmony_ci#define TUSB_PHY_OTG_CTRL_OTG_ID_PULLUP (1 << 23) 3462306a36Sopenharmony_ci#define TUSB_PHY_OTG_CTRL_OTG_VBUS_DET_EN (1 << 19) 3562306a36Sopenharmony_ci#define TUSB_PHY_OTG_CTRL_OTG_SESS_END_EN (1 << 18) 3662306a36Sopenharmony_ci#define TUSB_PHY_OTG_CTRL_TESTM2 (1 << 17) 3762306a36Sopenharmony_ci#define TUSB_PHY_OTG_CTRL_TESTM1 (1 << 16) 3862306a36Sopenharmony_ci#define TUSB_PHY_OTG_CTRL_TESTM0 (1 << 15) 3962306a36Sopenharmony_ci#define TUSB_PHY_OTG_CTRL_TX_DATA2 (1 << 14) 4062306a36Sopenharmony_ci#define TUSB_PHY_OTG_CTRL_TX_GZ2 (1 << 13) 4162306a36Sopenharmony_ci#define TUSB_PHY_OTG_CTRL_TX_ENABLE2 (1 << 12) 4262306a36Sopenharmony_ci#define TUSB_PHY_OTG_CTRL_DM_PULLDOWN (1 << 11) 4362306a36Sopenharmony_ci#define TUSB_PHY_OTG_CTRL_DP_PULLDOWN (1 << 10) 4462306a36Sopenharmony_ci#define TUSB_PHY_OTG_CTRL_OSC_EN (1 << 9) 4562306a36Sopenharmony_ci#define TUSB_PHY_OTG_CTRL_PHYREF_CLKSEL(v) (((v) & 3) << 7) 4662306a36Sopenharmony_ci#define TUSB_PHY_OTG_CTRL_PD (1 << 6) 4762306a36Sopenharmony_ci#define TUSB_PHY_OTG_CTRL_PLL_ON (1 << 5) 4862306a36Sopenharmony_ci#define TUSB_PHY_OTG_CTRL_EXT_RPU (1 << 4) 4962306a36Sopenharmony_ci#define TUSB_PHY_OTG_CTRL_PWR_GOOD (1 << 3) 5062306a36Sopenharmony_ci#define TUSB_PHY_OTG_CTRL_RESET (1 << 2) 5162306a36Sopenharmony_ci#define TUSB_PHY_OTG_CTRL_SUSPENDM (1 << 1) 5262306a36Sopenharmony_ci#define TUSB_PHY_OTG_CTRL_CLK_MODE (1 << 0) 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_ci/*OTG status register */ 5562306a36Sopenharmony_ci#define TUSB_DEV_OTG_STAT (TUSB_SYS_REG_BASE + 0x00c) 5662306a36Sopenharmony_ci#define TUSB_DEV_OTG_STAT_PWR_CLK_GOOD (1 << 8) 5762306a36Sopenharmony_ci#define TUSB_DEV_OTG_STAT_SESS_END (1 << 7) 5862306a36Sopenharmony_ci#define TUSB_DEV_OTG_STAT_SESS_VALID (1 << 6) 5962306a36Sopenharmony_ci#define TUSB_DEV_OTG_STAT_VBUS_VALID (1 << 5) 6062306a36Sopenharmony_ci#define TUSB_DEV_OTG_STAT_VBUS_SENSE (1 << 4) 6162306a36Sopenharmony_ci#define TUSB_DEV_OTG_STAT_ID_STATUS (1 << 3) 6262306a36Sopenharmony_ci#define TUSB_DEV_OTG_STAT_HOST_DISCON (1 << 2) 6362306a36Sopenharmony_ci#define TUSB_DEV_OTG_STAT_LINE_STATE (3 << 0) 6462306a36Sopenharmony_ci#define TUSB_DEV_OTG_STAT_DP_ENABLE (1 << 1) 6562306a36Sopenharmony_ci#define TUSB_DEV_OTG_STAT_DM_ENABLE (1 << 0) 6662306a36Sopenharmony_ci 6762306a36Sopenharmony_ci#define TUSB_DEV_OTG_TIMER (TUSB_SYS_REG_BASE + 0x010) 6862306a36Sopenharmony_ci# define TUSB_DEV_OTG_TIMER_ENABLE (1 << 31) 6962306a36Sopenharmony_ci# define TUSB_DEV_OTG_TIMER_VAL(v) ((v) & 0x07ffffff) 7062306a36Sopenharmony_ci#define TUSB_PRCM_REV (TUSB_SYS_REG_BASE + 0x014) 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ci/* PRCM configuration register */ 7362306a36Sopenharmony_ci#define TUSB_PRCM_CONF (TUSB_SYS_REG_BASE + 0x018) 7462306a36Sopenharmony_ci#define TUSB_PRCM_CONF_SFW_CPEN (1 << 24) 7562306a36Sopenharmony_ci#define TUSB_PRCM_CONF_SYS_CLKSEL(v) (((v) & 3) << 16) 7662306a36Sopenharmony_ci 7762306a36Sopenharmony_ci/* PRCM management register */ 7862306a36Sopenharmony_ci#define TUSB_PRCM_MNGMT (TUSB_SYS_REG_BASE + 0x01c) 7962306a36Sopenharmony_ci#define TUSB_PRCM_MNGMT_SRP_FIX_TIMER(v) (((v) & 0xf) << 25) 8062306a36Sopenharmony_ci#define TUSB_PRCM_MNGMT_SRP_FIX_EN (1 << 24) 8162306a36Sopenharmony_ci#define TUSB_PRCM_MNGMT_VBUS_VALID_TIMER(v) (((v) & 0xf) << 20) 8262306a36Sopenharmony_ci#define TUSB_PRCM_MNGMT_VBUS_VALID_FLT_EN (1 << 19) 8362306a36Sopenharmony_ci#define TUSB_PRCM_MNGMT_DFT_CLK_DIS (1 << 18) 8462306a36Sopenharmony_ci#define TUSB_PRCM_MNGMT_VLYNQ_CLK_DIS (1 << 17) 8562306a36Sopenharmony_ci#define TUSB_PRCM_MNGMT_OTG_SESS_END_EN (1 << 10) 8662306a36Sopenharmony_ci#define TUSB_PRCM_MNGMT_OTG_VBUS_DET_EN (1 << 9) 8762306a36Sopenharmony_ci#define TUSB_PRCM_MNGMT_OTG_ID_PULLUP (1 << 8) 8862306a36Sopenharmony_ci#define TUSB_PRCM_MNGMT_15_SW_EN (1 << 4) 8962306a36Sopenharmony_ci#define TUSB_PRCM_MNGMT_33_SW_EN (1 << 3) 9062306a36Sopenharmony_ci#define TUSB_PRCM_MNGMT_5V_CPEN (1 << 2) 9162306a36Sopenharmony_ci#define TUSB_PRCM_MNGMT_PM_IDLE (1 << 1) 9262306a36Sopenharmony_ci#define TUSB_PRCM_MNGMT_DEV_IDLE (1 << 0) 9362306a36Sopenharmony_ci 9462306a36Sopenharmony_ci/* Wake-up source clear and mask registers */ 9562306a36Sopenharmony_ci#define TUSB_PRCM_WAKEUP_SOURCE (TUSB_SYS_REG_BASE + 0x020) 9662306a36Sopenharmony_ci#define TUSB_PRCM_WAKEUP_CLEAR (TUSB_SYS_REG_BASE + 0x028) 9762306a36Sopenharmony_ci#define TUSB_PRCM_WAKEUP_MASK (TUSB_SYS_REG_BASE + 0x02c) 9862306a36Sopenharmony_ci#define TUSB_PRCM_WAKEUP_RESERVED_BITS (0xffffe << 13) 9962306a36Sopenharmony_ci#define TUSB_PRCM_WGPIO_7 (1 << 12) 10062306a36Sopenharmony_ci#define TUSB_PRCM_WGPIO_6 (1 << 11) 10162306a36Sopenharmony_ci#define TUSB_PRCM_WGPIO_5 (1 << 10) 10262306a36Sopenharmony_ci#define TUSB_PRCM_WGPIO_4 (1 << 9) 10362306a36Sopenharmony_ci#define TUSB_PRCM_WGPIO_3 (1 << 8) 10462306a36Sopenharmony_ci#define TUSB_PRCM_WGPIO_2 (1 << 7) 10562306a36Sopenharmony_ci#define TUSB_PRCM_WGPIO_1 (1 << 6) 10662306a36Sopenharmony_ci#define TUSB_PRCM_WGPIO_0 (1 << 5) 10762306a36Sopenharmony_ci#define TUSB_PRCM_WHOSTDISCON (1 << 4) /* Host disconnect */ 10862306a36Sopenharmony_ci#define TUSB_PRCM_WBUS (1 << 3) /* USB bus resume */ 10962306a36Sopenharmony_ci#define TUSB_PRCM_WNORCS (1 << 2) /* NOR chip select */ 11062306a36Sopenharmony_ci#define TUSB_PRCM_WVBUS (1 << 1) /* OTG PHY VBUS */ 11162306a36Sopenharmony_ci#define TUSB_PRCM_WID (1 << 0) /* OTG PHY ID detect */ 11262306a36Sopenharmony_ci 11362306a36Sopenharmony_ci#define TUSB_PULLUP_1_CTRL (TUSB_SYS_REG_BASE + 0x030) 11462306a36Sopenharmony_ci#define TUSB_PULLUP_2_CTRL (TUSB_SYS_REG_BASE + 0x034) 11562306a36Sopenharmony_ci#define TUSB_INT_CTRL_REV (TUSB_SYS_REG_BASE + 0x038) 11662306a36Sopenharmony_ci#define TUSB_INT_CTRL_CONF (TUSB_SYS_REG_BASE + 0x03c) 11762306a36Sopenharmony_ci#define TUSB_USBIP_INT_SRC (TUSB_SYS_REG_BASE + 0x040) 11862306a36Sopenharmony_ci#define TUSB_USBIP_INT_SET (TUSB_SYS_REG_BASE + 0x044) 11962306a36Sopenharmony_ci#define TUSB_USBIP_INT_CLEAR (TUSB_SYS_REG_BASE + 0x048) 12062306a36Sopenharmony_ci#define TUSB_USBIP_INT_MASK (TUSB_SYS_REG_BASE + 0x04c) 12162306a36Sopenharmony_ci#define TUSB_DMA_INT_SRC (TUSB_SYS_REG_BASE + 0x050) 12262306a36Sopenharmony_ci#define TUSB_DMA_INT_SET (TUSB_SYS_REG_BASE + 0x054) 12362306a36Sopenharmony_ci#define TUSB_DMA_INT_CLEAR (TUSB_SYS_REG_BASE + 0x058) 12462306a36Sopenharmony_ci#define TUSB_DMA_INT_MASK (TUSB_SYS_REG_BASE + 0x05c) 12562306a36Sopenharmony_ci#define TUSB_GPIO_INT_SRC (TUSB_SYS_REG_BASE + 0x060) 12662306a36Sopenharmony_ci#define TUSB_GPIO_INT_SET (TUSB_SYS_REG_BASE + 0x064) 12762306a36Sopenharmony_ci#define TUSB_GPIO_INT_CLEAR (TUSB_SYS_REG_BASE + 0x068) 12862306a36Sopenharmony_ci#define TUSB_GPIO_INT_MASK (TUSB_SYS_REG_BASE + 0x06c) 12962306a36Sopenharmony_ci 13062306a36Sopenharmony_ci/* NOR flash interrupt source registers */ 13162306a36Sopenharmony_ci#define TUSB_INT_SRC (TUSB_SYS_REG_BASE + 0x070) 13262306a36Sopenharmony_ci#define TUSB_INT_SRC_SET (TUSB_SYS_REG_BASE + 0x074) 13362306a36Sopenharmony_ci#define TUSB_INT_SRC_CLEAR (TUSB_SYS_REG_BASE + 0x078) 13462306a36Sopenharmony_ci#define TUSB_INT_MASK (TUSB_SYS_REG_BASE + 0x07c) 13562306a36Sopenharmony_ci#define TUSB_INT_SRC_TXRX_DMA_DONE (1 << 24) 13662306a36Sopenharmony_ci#define TUSB_INT_SRC_USB_IP_CORE (1 << 17) 13762306a36Sopenharmony_ci#define TUSB_INT_SRC_OTG_TIMEOUT (1 << 16) 13862306a36Sopenharmony_ci#define TUSB_INT_SRC_VBUS_SENSE_CHNG (1 << 15) 13962306a36Sopenharmony_ci#define TUSB_INT_SRC_ID_STATUS_CHNG (1 << 14) 14062306a36Sopenharmony_ci#define TUSB_INT_SRC_DEV_WAKEUP (1 << 13) 14162306a36Sopenharmony_ci#define TUSB_INT_SRC_DEV_READY (1 << 12) 14262306a36Sopenharmony_ci#define TUSB_INT_SRC_USB_IP_TX (1 << 9) 14362306a36Sopenharmony_ci#define TUSB_INT_SRC_USB_IP_RX (1 << 8) 14462306a36Sopenharmony_ci#define TUSB_INT_SRC_USB_IP_VBUS_ERR (1 << 7) 14562306a36Sopenharmony_ci#define TUSB_INT_SRC_USB_IP_VBUS_REQ (1 << 6) 14662306a36Sopenharmony_ci#define TUSB_INT_SRC_USB_IP_DISCON (1 << 5) 14762306a36Sopenharmony_ci#define TUSB_INT_SRC_USB_IP_CONN (1 << 4) 14862306a36Sopenharmony_ci#define TUSB_INT_SRC_USB_IP_SOF (1 << 3) 14962306a36Sopenharmony_ci#define TUSB_INT_SRC_USB_IP_RST_BABBLE (1 << 2) 15062306a36Sopenharmony_ci#define TUSB_INT_SRC_USB_IP_RESUME (1 << 1) 15162306a36Sopenharmony_ci#define TUSB_INT_SRC_USB_IP_SUSPEND (1 << 0) 15262306a36Sopenharmony_ci 15362306a36Sopenharmony_ci/* NOR flash interrupt registers reserved bits. Must be written as 0 */ 15462306a36Sopenharmony_ci#define TUSB_INT_MASK_RESERVED_17 (0x3fff << 17) 15562306a36Sopenharmony_ci#define TUSB_INT_MASK_RESERVED_13 (1 << 13) 15662306a36Sopenharmony_ci#define TUSB_INT_MASK_RESERVED_8 (0xf << 8) 15762306a36Sopenharmony_ci#define TUSB_INT_SRC_RESERVED_26 (0x1f << 26) 15862306a36Sopenharmony_ci#define TUSB_INT_SRC_RESERVED_18 (0x3f << 18) 15962306a36Sopenharmony_ci#define TUSB_INT_SRC_RESERVED_10 (0x03 << 10) 16062306a36Sopenharmony_ci 16162306a36Sopenharmony_ci/* Reserved bits for NOR flash interrupt mask and clear register */ 16262306a36Sopenharmony_ci#define TUSB_INT_MASK_RESERVED_BITS (TUSB_INT_MASK_RESERVED_17 | \ 16362306a36Sopenharmony_ci TUSB_INT_MASK_RESERVED_13 | \ 16462306a36Sopenharmony_ci TUSB_INT_MASK_RESERVED_8) 16562306a36Sopenharmony_ci 16662306a36Sopenharmony_ci/* Reserved bits for NOR flash interrupt status register */ 16762306a36Sopenharmony_ci#define TUSB_INT_SRC_RESERVED_BITS (TUSB_INT_SRC_RESERVED_26 | \ 16862306a36Sopenharmony_ci TUSB_INT_SRC_RESERVED_18 | \ 16962306a36Sopenharmony_ci TUSB_INT_SRC_RESERVED_10) 17062306a36Sopenharmony_ci 17162306a36Sopenharmony_ci#define TUSB_GPIO_REV (TUSB_SYS_REG_BASE + 0x080) 17262306a36Sopenharmony_ci#define TUSB_GPIO_CONF (TUSB_SYS_REG_BASE + 0x084) 17362306a36Sopenharmony_ci#define TUSB_DMA_CTRL_REV (TUSB_SYS_REG_BASE + 0x100) 17462306a36Sopenharmony_ci#define TUSB_DMA_REQ_CONF (TUSB_SYS_REG_BASE + 0x104) 17562306a36Sopenharmony_ci#define TUSB_EP0_CONF (TUSB_SYS_REG_BASE + 0x108) 17662306a36Sopenharmony_ci#define TUSB_DMA_EP_MAP (TUSB_SYS_REG_BASE + 0x148) 17762306a36Sopenharmony_ci 17862306a36Sopenharmony_ci/* Offsets from each ep base register */ 17962306a36Sopenharmony_ci#define TUSB_EP_TX_OFFSET 0x10c /* EP_IN in docs */ 18062306a36Sopenharmony_ci#define TUSB_EP_RX_OFFSET 0x14c /* EP_OUT in docs */ 18162306a36Sopenharmony_ci#define TUSB_EP_MAX_PACKET_SIZE_OFFSET 0x188 18262306a36Sopenharmony_ci 18362306a36Sopenharmony_ci#define TUSB_WAIT_COUNT (TUSB_SYS_REG_BASE + 0x1c8) 18462306a36Sopenharmony_ci#define TUSB_SCRATCH_PAD (TUSB_SYS_REG_BASE + 0x1c4) 18562306a36Sopenharmony_ci#define TUSB_PROD_TEST_RESET (TUSB_SYS_REG_BASE + 0x1d8) 18662306a36Sopenharmony_ci 18762306a36Sopenharmony_ci/* Device System & Control register bitfields */ 18862306a36Sopenharmony_ci#define TUSB_INT_CTRL_CONF_INT_RELCYC(v) (((v) & 0x7) << 18) 18962306a36Sopenharmony_ci#define TUSB_INT_CTRL_CONF_INT_POLARITY (1 << 17) 19062306a36Sopenharmony_ci#define TUSB_INT_CTRL_CONF_INT_MODE (1 << 16) 19162306a36Sopenharmony_ci#define TUSB_GPIO_CONF_DMAREQ(v) (((v) & 0x3f) << 24) 19262306a36Sopenharmony_ci#define TUSB_DMA_REQ_CONF_BURST_SIZE(v) (((v) & 3) << 26) 19362306a36Sopenharmony_ci#define TUSB_DMA_REQ_CONF_DMA_REQ_EN(v) (((v) & 0x3f) << 20) 19462306a36Sopenharmony_ci#define TUSB_DMA_REQ_CONF_DMA_REQ_ASSER(v) (((v) & 0xf) << 16) 19562306a36Sopenharmony_ci#define TUSB_EP0_CONFIG_SW_EN (1 << 8) 19662306a36Sopenharmony_ci#define TUSB_EP0_CONFIG_DIR_TX (1 << 7) 19762306a36Sopenharmony_ci#define TUSB_EP0_CONFIG_XFR_SIZE(v) ((v) & 0x7f) 19862306a36Sopenharmony_ci#define TUSB_EP_CONFIG_SW_EN (1 << 31) 19962306a36Sopenharmony_ci#define TUSB_EP_CONFIG_XFR_SIZE(v) ((v) & 0x7fffffff) 20062306a36Sopenharmony_ci#define TUSB_PROD_TEST_RESET_VAL 0xa596 20162306a36Sopenharmony_ci#define TUSB_EP_FIFO(ep) (TUSB_FIFO_BASE + (ep) * 0x20) 20262306a36Sopenharmony_ci 20362306a36Sopenharmony_ci#define TUSB_DIDR1_LO (TUSB_SYS_REG_BASE + 0x1f8) 20462306a36Sopenharmony_ci#define TUSB_DIDR1_HI (TUSB_SYS_REG_BASE + 0x1fc) 20562306a36Sopenharmony_ci#define TUSB_DIDR1_HI_CHIP_REV(v) (((v) >> 17) & 0xf) 20662306a36Sopenharmony_ci#define TUSB_DIDR1_HI_REV_20 0 20762306a36Sopenharmony_ci#define TUSB_DIDR1_HI_REV_30 1 20862306a36Sopenharmony_ci#define TUSB_DIDR1_HI_REV_31 2 20962306a36Sopenharmony_ci 21062306a36Sopenharmony_ci#define TUSB_REV_10 0x10 21162306a36Sopenharmony_ci#define TUSB_REV_20 0x20 21262306a36Sopenharmony_ci#define TUSB_REV_30 0x30 21362306a36Sopenharmony_ci#define TUSB_REV_31 0x31 21462306a36Sopenharmony_ci 21562306a36Sopenharmony_ci#endif /* __TUSB6010_H__ */ 216