1*4882a593Smuzhiyun /* 2*4882a593Smuzhiyun * Broadcom PCI-SPI Host Controller Register Definitions 3*4882a593Smuzhiyun * 4*4882a593Smuzhiyun * Copyright (C) 2020, Broadcom. 5*4882a593Smuzhiyun * 6*4882a593Smuzhiyun * Unless you and Broadcom execute a separate written software license 7*4882a593Smuzhiyun * agreement governing use of this software, this software is licensed to you 8*4882a593Smuzhiyun * under the terms of the GNU General Public License version 2 (the "GPL"), 9*4882a593Smuzhiyun * available at http://www.broadcom.com/licenses/GPLv2.php, with the 10*4882a593Smuzhiyun * following added to such license: 11*4882a593Smuzhiyun * 12*4882a593Smuzhiyun * As a special exception, the copyright holders of this software give you 13*4882a593Smuzhiyun * permission to link this software with independent modules, and to copy and 14*4882a593Smuzhiyun * distribute the resulting executable under terms of your choice, provided that 15*4882a593Smuzhiyun * you also meet, for each linked independent module, the terms and conditions of 16*4882a593Smuzhiyun * the license of that module. An independent module is a module which is not 17*4882a593Smuzhiyun * derived from this software. The special exception does not apply to any 18*4882a593Smuzhiyun * modifications of the software. 19*4882a593Smuzhiyun * 20*4882a593Smuzhiyun * 21*4882a593Smuzhiyun * <<Broadcom-WL-IPTag/Dual:>> 22*4882a593Smuzhiyun */ 23*4882a593Smuzhiyun #ifndef _BCM_PCI_SPI_H 24*4882a593Smuzhiyun #define _BCM_PCI_SPI_H 25*4882a593Smuzhiyun 26*4882a593Smuzhiyun /* cpp contortions to concatenate w/arg prescan */ 27*4882a593Smuzhiyun #ifndef PAD 28*4882a593Smuzhiyun #define _PADLINE(line) pad ## line 29*4882a593Smuzhiyun #define _XSTR(line) _PADLINE(line) 30*4882a593Smuzhiyun #define PAD _XSTR(__LINE__) 31*4882a593Smuzhiyun #endif /* PAD */ 32*4882a593Smuzhiyun 33*4882a593Smuzhiyun /* 34*4882a593Smuzhiyun +---------------------------------------------------------------------------+ 35*4882a593Smuzhiyun | | 36*4882a593Smuzhiyun | 7 6 5 4 3 2 1 0 | 37*4882a593Smuzhiyun | 0x0000 SPI_CTRL SPIE SPE 0 MSTR CPOL CPHA SPR1 SPR0 | 38*4882a593Smuzhiyun | 0x0004 SPI_STAT SPIF WCOL ST1 ST0 WFFUL WFEMP RFFUL RFEMP | 39*4882a593Smuzhiyun | 0x0008 SPI_DATA Bits 31:0, data to send out on MOSI | 40*4882a593Smuzhiyun | 0x000C SPI_EXT ICNT1 ICNT0 BSWAP *HSMODE ESPR1 ESPR0 | 41*4882a593Smuzhiyun | 0x0020 GPIO_OE 0=input, 1=output PWR_OE CS_OE | 42*4882a593Smuzhiyun | 0x0024 GPIO_DATA CARD:1=missing, 0=present CARD PWR_DAT CS_DAT | 43*4882a593Smuzhiyun | 0x0040 INT_EDGE 0=level, 1=edge DEV_E SPI_E | 44*4882a593Smuzhiyun | 0x0044 INT_POL 1=active high, 0=active low DEV_P SPI_P | 45*4882a593Smuzhiyun | 0x0048 INTMASK DEV SPI | 46*4882a593Smuzhiyun | 0x004C INTSTATUS DEV SPI | 47*4882a593Smuzhiyun | 0x0060 HEXDISP Reset value: 0x14e443f5. In hexdisp mode, value | 48*4882a593Smuzhiyun | shows on the Raggedstone1 4-digit 7-segment display. | 49*4882a593Smuzhiyun | 0x0064 CURRENT_MA Low 16 bits indicate card current consumption in mA | 50*4882a593Smuzhiyun | 0x006C DISP_SEL Display mode (0=hexdisp, 1=current) DSP | 51*4882a593Smuzhiyun | 0x00C0 PLL_CTL bit31=ext_clk, remainder unused. | 52*4882a593Smuzhiyun | 0x00C4 PLL_STAT LOCK | 53*4882a593Smuzhiyun | 0x00C8 CLK_FREQ | 54*4882a593Smuzhiyun | 0x00CC CLK_CNT | 55*4882a593Smuzhiyun | | 56*4882a593Smuzhiyun | *Notes: HSMODE is not implemented, never set this bit! | 57*4882a593Smuzhiyun | BSWAP is available in rev >= 8 | 58*4882a593Smuzhiyun | | 59*4882a593Smuzhiyun +---------------------------------------------------------------------------+ 60*4882a593Smuzhiyun */ 61*4882a593Smuzhiyun 62*4882a593Smuzhiyun typedef volatile struct { 63*4882a593Smuzhiyun uint32 spih_ctrl; /* 0x00 SPI Control Register */ 64*4882a593Smuzhiyun uint32 spih_stat; /* 0x04 SPI Status Register */ 65*4882a593Smuzhiyun uint32 spih_data; /* 0x08 SPI Data Register, 32-bits wide */ 66*4882a593Smuzhiyun uint32 spih_ext; /* 0x0C SPI Extension Register */ 67*4882a593Smuzhiyun uint32 PAD[4]; /* 0x10-0x1F PADDING */ 68*4882a593Smuzhiyun 69*4882a593Smuzhiyun uint32 spih_gpio_ctrl; /* 0x20 SPI GPIO Control Register */ 70*4882a593Smuzhiyun uint32 spih_gpio_data; /* 0x24 SPI GPIO Data Register */ 71*4882a593Smuzhiyun uint32 PAD[6]; /* 0x28-0x3F PADDING */ 72*4882a593Smuzhiyun 73*4882a593Smuzhiyun uint32 spih_int_edge; /* 0x40 SPI Interrupt Edge Register (0=Level, 1=Edge) */ 74*4882a593Smuzhiyun uint32 spih_int_pol; /* 0x44 SPI Interrupt Polarity Register (0=Active Low, */ 75*4882a593Smuzhiyun /* 1=Active High) */ 76*4882a593Smuzhiyun uint32 spih_int_mask; /* 0x48 SPI Interrupt Mask */ 77*4882a593Smuzhiyun uint32 spih_int_status; /* 0x4C SPI Interrupt Status */ 78*4882a593Smuzhiyun uint32 PAD[4]; /* 0x50-0x5F PADDING */ 79*4882a593Smuzhiyun 80*4882a593Smuzhiyun uint32 spih_hex_disp; /* 0x60 SPI 4-digit hex display value */ 81*4882a593Smuzhiyun uint32 spih_current_ma; /* 0x64 SPI SD card current consumption in mA */ 82*4882a593Smuzhiyun uint32 PAD[1]; /* 0x68 PADDING */ 83*4882a593Smuzhiyun uint32 spih_disp_sel; /* 0x6c SPI 4-digit hex display mode select (1=current) */ 84*4882a593Smuzhiyun uint32 PAD[4]; /* 0x70-0x7F PADDING */ 85*4882a593Smuzhiyun uint32 PAD[8]; /* 0x80-0x9F PADDING */ 86*4882a593Smuzhiyun uint32 PAD[8]; /* 0xA0-0xBF PADDING */ 87*4882a593Smuzhiyun uint32 spih_pll_ctrl; /* 0xC0 PLL Control Register */ 88*4882a593Smuzhiyun uint32 spih_pll_status; /* 0xC4 PLL Status Register */ 89*4882a593Smuzhiyun uint32 spih_xtal_freq; /* 0xC8 External Clock Frequency in units of 10000Hz */ 90*4882a593Smuzhiyun uint32 spih_clk_count; /* 0xCC External Clock Count Register */ 91*4882a593Smuzhiyun 92*4882a593Smuzhiyun } spih_regs_t; 93*4882a593Smuzhiyun 94*4882a593Smuzhiyun typedef volatile struct { 95*4882a593Smuzhiyun uint32 cfg_space[0x40]; /* 0x000-0x0FF PCI Configuration Space (Read Only) */ 96*4882a593Smuzhiyun uint32 P_IMG_CTRL0; /* 0x100 PCI Image0 Control Register */ 97*4882a593Smuzhiyun 98*4882a593Smuzhiyun uint32 P_BA0; /* 0x104 32 R/W PCI Image0 Base Address register */ 99*4882a593Smuzhiyun uint32 P_AM0; /* 0x108 32 R/W PCI Image0 Address Mask register */ 100*4882a593Smuzhiyun uint32 P_TA0; /* 0x10C 32 R/W PCI Image0 Translation Address register */ 101*4882a593Smuzhiyun uint32 P_IMG_CTRL1; /* 0x110 32 R/W PCI Image1 Control register */ 102*4882a593Smuzhiyun uint32 P_BA1; /* 0x114 32 R/W PCI Image1 Base Address register */ 103*4882a593Smuzhiyun uint32 P_AM1; /* 0x118 32 R/W PCI Image1 Address Mask register */ 104*4882a593Smuzhiyun uint32 P_TA1; /* 0x11C 32 R/W PCI Image1 Translation Address register */ 105*4882a593Smuzhiyun uint32 P_IMG_CTRL2; /* 0x120 32 R/W PCI Image2 Control register */ 106*4882a593Smuzhiyun uint32 P_BA2; /* 0x124 32 R/W PCI Image2 Base Address register */ 107*4882a593Smuzhiyun uint32 P_AM2; /* 0x128 32 R/W PCI Image2 Address Mask register */ 108*4882a593Smuzhiyun uint32 P_TA2; /* 0x12C 32 R/W PCI Image2 Translation Address register */ 109*4882a593Smuzhiyun uint32 P_IMG_CTRL3; /* 0x130 32 R/W PCI Image3 Control register */ 110*4882a593Smuzhiyun uint32 P_BA3; /* 0x134 32 R/W PCI Image3 Base Address register */ 111*4882a593Smuzhiyun uint32 P_AM3; /* 0x138 32 R/W PCI Image3 Address Mask register */ 112*4882a593Smuzhiyun uint32 P_TA3; /* 0x13C 32 R/W PCI Image3 Translation Address register */ 113*4882a593Smuzhiyun uint32 P_IMG_CTRL4; /* 0x140 32 R/W PCI Image4 Control register */ 114*4882a593Smuzhiyun uint32 P_BA4; /* 0x144 32 R/W PCI Image4 Base Address register */ 115*4882a593Smuzhiyun uint32 P_AM4; /* 0x148 32 R/W PCI Image4 Address Mask register */ 116*4882a593Smuzhiyun uint32 P_TA4; /* 0x14C 32 R/W PCI Image4 Translation Address register */ 117*4882a593Smuzhiyun uint32 P_IMG_CTRL5; /* 0x150 32 R/W PCI Image5 Control register */ 118*4882a593Smuzhiyun uint32 P_BA5; /* 0x154 32 R/W PCI Image5 Base Address register */ 119*4882a593Smuzhiyun uint32 P_AM5; /* 0x158 32 R/W PCI Image5 Address Mask register */ 120*4882a593Smuzhiyun uint32 P_TA5; /* 0x15C 32 R/W PCI Image5 Translation Address register */ 121*4882a593Smuzhiyun uint32 P_ERR_CS; /* 0x160 32 R/W PCI Error Control and Status register */ 122*4882a593Smuzhiyun uint32 P_ERR_ADDR; /* 0x164 32 R PCI Erroneous Address register */ 123*4882a593Smuzhiyun uint32 P_ERR_DATA; /* 0x168 32 R PCI Erroneous Data register */ 124*4882a593Smuzhiyun 125*4882a593Smuzhiyun uint32 PAD[5]; /* 0x16C-0x17F PADDING */ 126*4882a593Smuzhiyun 127*4882a593Smuzhiyun uint32 WB_CONF_SPC_BAR; /* 0x180 32 R WISHBONE Configuration Space Base Address */ 128*4882a593Smuzhiyun uint32 W_IMG_CTRL1; /* 0x184 32 R/W WISHBONE Image1 Control register */ 129*4882a593Smuzhiyun uint32 W_BA1; /* 0x188 32 R/W WISHBONE Image1 Base Address register */ 130*4882a593Smuzhiyun uint32 W_AM1; /* 0x18C 32 R/W WISHBONE Image1 Address Mask register */ 131*4882a593Smuzhiyun uint32 W_TA1; /* 0x190 32 R/W WISHBONE Image1 Translation Address reg */ 132*4882a593Smuzhiyun uint32 W_IMG_CTRL2; /* 0x194 32 R/W WISHBONE Image2 Control register */ 133*4882a593Smuzhiyun uint32 W_BA2; /* 0x198 32 R/W WISHBONE Image2 Base Address register */ 134*4882a593Smuzhiyun uint32 W_AM2; /* 0x19C 32 R/W WISHBONE Image2 Address Mask register */ 135*4882a593Smuzhiyun uint32 W_TA2; /* 0x1A0 32 R/W WISHBONE Image2 Translation Address reg */ 136*4882a593Smuzhiyun uint32 W_IMG_CTRL3; /* 0x1A4 32 R/W WISHBONE Image3 Control register */ 137*4882a593Smuzhiyun uint32 W_BA3; /* 0x1A8 32 R/W WISHBONE Image3 Base Address register */ 138*4882a593Smuzhiyun uint32 W_AM3; /* 0x1AC 32 R/W WISHBONE Image3 Address Mask register */ 139*4882a593Smuzhiyun uint32 W_TA3; /* 0x1B0 32 R/W WISHBONE Image3 Translation Address reg */ 140*4882a593Smuzhiyun uint32 W_IMG_CTRL4; /* 0x1B4 32 R/W WISHBONE Image4 Control register */ 141*4882a593Smuzhiyun uint32 W_BA4; /* 0x1B8 32 R/W WISHBONE Image4 Base Address register */ 142*4882a593Smuzhiyun uint32 W_AM4; /* 0x1BC 32 R/W WISHBONE Image4 Address Mask register */ 143*4882a593Smuzhiyun uint32 W_TA4; /* 0x1C0 32 R/W WISHBONE Image4 Translation Address reg */ 144*4882a593Smuzhiyun uint32 W_IMG_CTRL5; /* 0x1C4 32 R/W WISHBONE Image5 Control register */ 145*4882a593Smuzhiyun uint32 W_BA5; /* 0x1C8 32 R/W WISHBONE Image5 Base Address register */ 146*4882a593Smuzhiyun uint32 W_AM5; /* 0x1CC 32 R/W WISHBONE Image5 Address Mask register */ 147*4882a593Smuzhiyun uint32 W_TA5; /* 0x1D0 32 R/W WISHBONE Image5 Translation Address reg */ 148*4882a593Smuzhiyun uint32 W_ERR_CS; /* 0x1D4 32 R/W WISHBONE Error Control and Status reg */ 149*4882a593Smuzhiyun uint32 W_ERR_ADDR; /* 0x1D8 32 R WISHBONE Erroneous Address register */ 150*4882a593Smuzhiyun uint32 W_ERR_DATA; /* 0x1DC 32 R WISHBONE Erroneous Data register */ 151*4882a593Smuzhiyun uint32 CNF_ADDR; /* 0x1E0 32 R/W Configuration Cycle register */ 152*4882a593Smuzhiyun uint32 CNF_DATA; /* 0x1E4 32 R/W Configuration Cycle Generation Data reg */ 153*4882a593Smuzhiyun 154*4882a593Smuzhiyun uint32 INT_ACK; /* 0x1E8 32 R Interrupt Acknowledge register */ 155*4882a593Smuzhiyun uint32 ICR; /* 0x1EC 32 R/W Interrupt Control register */ 156*4882a593Smuzhiyun uint32 ISR; /* 0x1F0 32 R/W Interrupt Status register */ 157*4882a593Smuzhiyun } spih_pciregs_t; 158*4882a593Smuzhiyun 159*4882a593Smuzhiyun /* 160*4882a593Smuzhiyun * PCI Core interrupt enable and status bit definitions. 161*4882a593Smuzhiyun */ 162*4882a593Smuzhiyun 163*4882a593Smuzhiyun /* PCI Core ICR Register bit definitions */ 164*4882a593Smuzhiyun #define PCI_INT_PROP_EN (1 << 0) /* Interrupt Propagation Enable */ 165*4882a593Smuzhiyun #define PCI_WB_ERR_INT_EN (1 << 1) /* Wishbone Error Interrupt Enable */ 166*4882a593Smuzhiyun #define PCI_PCI_ERR_INT_EN (1 << 2) /* PCI Error Interrupt Enable */ 167*4882a593Smuzhiyun #define PCI_PAR_ERR_INT_EN (1 << 3) /* Parity Error Interrupt Enable */ 168*4882a593Smuzhiyun #define PCI_SYS_ERR_INT_EN (1 << 4) /* System Error Interrupt Enable */ 169*4882a593Smuzhiyun #define PCI_SOFTWARE_RESET (1U << 31) /* Software reset of the PCI Core. */ 170*4882a593Smuzhiyun 171*4882a593Smuzhiyun /* PCI Core ISR Register bit definitions */ 172*4882a593Smuzhiyun #define PCI_INT_PROP_ST (1 << 0) /* Interrupt Propagation Status */ 173*4882a593Smuzhiyun #define PCI_WB_ERR_INT_ST (1 << 1) /* Wishbone Error Interrupt Status */ 174*4882a593Smuzhiyun #define PCI_PCI_ERR_INT_ST (1 << 2) /* PCI Error Interrupt Status */ 175*4882a593Smuzhiyun #define PCI_PAR_ERR_INT_ST (1 << 3) /* Parity Error Interrupt Status */ 176*4882a593Smuzhiyun #define PCI_SYS_ERR_INT_ST (1 << 4) /* System Error Interrupt Status */ 177*4882a593Smuzhiyun 178*4882a593Smuzhiyun /* Registers on the Wishbone bus */ 179*4882a593Smuzhiyun #define SPIH_CTLR_INTR (1 << 0) /* SPI Host Controller Core Interrupt */ 180*4882a593Smuzhiyun #define SPIH_DEV_INTR (1 << 1) /* SPI Device Interrupt */ 181*4882a593Smuzhiyun #define SPIH_WFIFO_INTR (1 << 2) /* SPI Tx FIFO Empty Intr (FPGA Rev >= 8) */ 182*4882a593Smuzhiyun 183*4882a593Smuzhiyun /* GPIO Bit definitions */ 184*4882a593Smuzhiyun #define SPIH_CS (1 << 0) /* SPI Chip Select (active low) */ 185*4882a593Smuzhiyun #define SPIH_SLOT_POWER (1 << 1) /* SD Card Slot Power Enable */ 186*4882a593Smuzhiyun #define SPIH_CARD_DETECT (1 << 2) /* SD Card Detect */ 187*4882a593Smuzhiyun 188*4882a593Smuzhiyun /* SPI Status Register Bit definitions */ 189*4882a593Smuzhiyun #define SPIH_STATE_MASK 0x30 /* SPI Transfer State Machine state mask */ 190*4882a593Smuzhiyun #define SPIH_STATE_SHIFT 4 /* SPI Transfer State Machine state shift */ 191*4882a593Smuzhiyun #define SPIH_WFFULL (1 << 3) /* SPI Write FIFO Full */ 192*4882a593Smuzhiyun #define SPIH_WFEMPTY (1 << 2) /* SPI Write FIFO Empty */ 193*4882a593Smuzhiyun #define SPIH_RFFULL (1 << 1) /* SPI Read FIFO Full */ 194*4882a593Smuzhiyun #define SPIH_RFEMPTY (1 << 0) /* SPI Read FIFO Empty */ 195*4882a593Smuzhiyun 196*4882a593Smuzhiyun #define SPIH_EXT_CLK (1U << 31) /* Use External Clock as PLL Clock source. */ 197*4882a593Smuzhiyun 198*4882a593Smuzhiyun #define SPIH_PLL_NO_CLK (1 << 1) /* Set to 1 if the PLL's input clock is lost. */ 199*4882a593Smuzhiyun #define SPIH_PLL_LOCKED (1 << 3) /* Set to 1 when the PLL is locked. */ 200*4882a593Smuzhiyun 201*4882a593Smuzhiyun /* Spin bit loop bound check */ 202*4882a593Smuzhiyun #define SPI_SPIN_BOUND 0xf4240 /* 1 million */ 203*4882a593Smuzhiyun 204*4882a593Smuzhiyun #endif /* _BCM_PCI_SPI_H */ 205