1*4882a593Smuzhiyun /* 2*4882a593Smuzhiyun * SPI device spec header file 3*4882a593Smuzhiyun * 4*4882a593Smuzhiyun * Portions of this code are copyright (c) 2021 Cypress Semiconductor Corporation 5*4882a593Smuzhiyun * 6*4882a593Smuzhiyun * Copyright (C) 1999-2017, Broadcom Corporation 7*4882a593Smuzhiyun * 8*4882a593Smuzhiyun * Unless you and Broadcom execute a separate written software license 9*4882a593Smuzhiyun * agreement governing use of this software, this software is licensed to you 10*4882a593Smuzhiyun * under the terms of the GNU General Public License version 2 (the "GPL"), 11*4882a593Smuzhiyun * available at http://www.broadcom.com/licenses/GPLv2.php, with the 12*4882a593Smuzhiyun * following added to such license: 13*4882a593Smuzhiyun * 14*4882a593Smuzhiyun * As a special exception, the copyright holders of this software give you 15*4882a593Smuzhiyun * permission to link this software with independent modules, and to copy and 16*4882a593Smuzhiyun * distribute the resulting executable under terms of your choice, provided that 17*4882a593Smuzhiyun * you also meet, for each linked independent module, the terms and conditions of 18*4882a593Smuzhiyun * the license of that module. An independent module is a module which is not 19*4882a593Smuzhiyun * derived from this software. The special exception does not apply to any 20*4882a593Smuzhiyun * modifications of the software. 21*4882a593Smuzhiyun * 22*4882a593Smuzhiyun * Notwithstanding the above, under no circumstances may you combine this 23*4882a593Smuzhiyun * software in any way with any other Broadcom software provided under a license 24*4882a593Smuzhiyun * other than the GPL, without Broadcom's express prior written consent. 25*4882a593Smuzhiyun * 26*4882a593Smuzhiyun * 27*4882a593Smuzhiyun * <<Broadcom-WL-IPTag/Open:>> 28*4882a593Smuzhiyun * 29*4882a593Smuzhiyun * $Id: spid.h 514727 2014-11-12 03:02:48Z $ 30*4882a593Smuzhiyun */ 31*4882a593Smuzhiyun 32*4882a593Smuzhiyun #ifndef _SPI_H 33*4882a593Smuzhiyun #define _SPI_H 34*4882a593Smuzhiyun 35*4882a593Smuzhiyun /* 36*4882a593Smuzhiyun * Brcm SPI Device Register Map. 37*4882a593Smuzhiyun * 38*4882a593Smuzhiyun */ 39*4882a593Smuzhiyun 40*4882a593Smuzhiyun typedef volatile struct { 41*4882a593Smuzhiyun uint8 config; /* 0x00, len, endian, clock, speed, polarity, wakeup */ 42*4882a593Smuzhiyun uint8 response_delay; /* 0x01, read response delay in bytes (corerev < 3) */ 43*4882a593Smuzhiyun uint8 status_enable; /* 0x02, status-enable, intr with status, response_delay 44*4882a593Smuzhiyun * function selection, command/data error check 45*4882a593Smuzhiyun */ 46*4882a593Smuzhiyun uint8 reset_bp; /* 0x03, reset on wlan/bt backplane reset (corerev >= 1) */ 47*4882a593Smuzhiyun uint16 intr_reg; /* 0x04, Intr status register */ 48*4882a593Smuzhiyun uint16 intr_en_reg; /* 0x06, Intr mask register */ 49*4882a593Smuzhiyun uint32 status_reg; /* 0x08, RO, Status bits of last spi transfer */ 50*4882a593Smuzhiyun uint16 f1_info_reg; /* 0x0c, RO, enabled, ready for data transfer, blocksize */ 51*4882a593Smuzhiyun uint16 f2_info_reg; /* 0x0e, RO, enabled, ready for data transfer, blocksize */ 52*4882a593Smuzhiyun uint16 f3_info_reg; /* 0x10, RO, enabled, ready for data transfer, blocksize */ 53*4882a593Smuzhiyun uint32 test_read; /* 0x14, RO 0xfeedbead signature */ 54*4882a593Smuzhiyun uint32 test_rw; /* 0x18, RW */ 55*4882a593Smuzhiyun uint8 resp_delay_f0; /* 0x1c, read resp delay bytes for F0 (corerev >= 3) */ 56*4882a593Smuzhiyun uint8 resp_delay_f1; /* 0x1d, read resp delay bytes for F1 (corerev >= 3) */ 57*4882a593Smuzhiyun uint8 resp_delay_f2; /* 0x1e, read resp delay bytes for F2 (corerev >= 3) */ 58*4882a593Smuzhiyun uint8 resp_delay_f3; /* 0x1f, read resp delay bytes for F3 (corerev >= 3) */ 59*4882a593Smuzhiyun } spi_regs_t; 60*4882a593Smuzhiyun 61*4882a593Smuzhiyun /* SPI device register offsets */ 62*4882a593Smuzhiyun #define SPID_CONFIG 0x00 63*4882a593Smuzhiyun #define SPID_RESPONSE_DELAY 0x01 64*4882a593Smuzhiyun #define SPID_STATUS_ENABLE 0x02 65*4882a593Smuzhiyun #define SPID_RESET_BP 0x03 /* (corerev >= 1) */ 66*4882a593Smuzhiyun #define SPID_INTR_REG 0x04 /* 16 bits - Interrupt status */ 67*4882a593Smuzhiyun #define SPID_INTR_EN_REG 0x06 /* 16 bits - Interrupt mask */ 68*4882a593Smuzhiyun #define SPID_STATUS_REG 0x08 /* 32 bits */ 69*4882a593Smuzhiyun #define SPID_F1_INFO_REG 0x0C /* 16 bits */ 70*4882a593Smuzhiyun #define SPID_F2_INFO_REG 0x0E /* 16 bits */ 71*4882a593Smuzhiyun #define SPID_F3_INFO_REG 0x10 /* 16 bits */ 72*4882a593Smuzhiyun #define SPID_TEST_READ 0x14 /* 32 bits */ 73*4882a593Smuzhiyun #define SPID_TEST_RW 0x18 /* 32 bits */ 74*4882a593Smuzhiyun #define SPID_RESP_DELAY_F0 0x1c /* 8 bits (corerev >= 3) */ 75*4882a593Smuzhiyun #define SPID_RESP_DELAY_F1 0x1d /* 8 bits (corerev >= 3) */ 76*4882a593Smuzhiyun #define SPID_RESP_DELAY_F2 0x1e /* 8 bits (corerev >= 3) */ 77*4882a593Smuzhiyun #define SPID_RESP_DELAY_F3 0x1f /* 8 bits (corerev >= 3) */ 78*4882a593Smuzhiyun 79*4882a593Smuzhiyun /* Bit masks for SPID_CONFIG device register */ 80*4882a593Smuzhiyun #define WORD_LENGTH_32 0x1 /* 0/1 16/32 bit word length */ 81*4882a593Smuzhiyun #define ENDIAN_BIG 0x2 /* 0/1 Little/Big Endian */ 82*4882a593Smuzhiyun #define CLOCK_PHASE 0x4 /* 0/1 clock phase delay */ 83*4882a593Smuzhiyun #define CLOCK_POLARITY 0x8 /* 0/1 Idle state clock polarity is low/high */ 84*4882a593Smuzhiyun #define HIGH_SPEED_MODE 0x10 /* 1/0 High Speed mode / Normal mode */ 85*4882a593Smuzhiyun #define INTR_POLARITY 0x20 /* 1/0 Interrupt active polarity is high/low */ 86*4882a593Smuzhiyun #define WAKE_UP 0x80 /* 0/1 Wake-up command from Host to WLAN */ 87*4882a593Smuzhiyun 88*4882a593Smuzhiyun /* Bit mask for SPID_RESPONSE_DELAY device register */ 89*4882a593Smuzhiyun #define RESPONSE_DELAY_MASK 0xFF /* Configurable rd response delay in multiples of 8 bits */ 90*4882a593Smuzhiyun 91*4882a593Smuzhiyun /* Bit mask for SPID_STATUS_ENABLE device register */ 92*4882a593Smuzhiyun #define STATUS_ENABLE 0x1 /* 1/0 Status sent/not sent to host after read/write */ 93*4882a593Smuzhiyun #define INTR_WITH_STATUS 0x2 /* 0/1 Do-not / do-interrupt if status is sent */ 94*4882a593Smuzhiyun #define RESP_DELAY_ALL 0x4 /* Applicability of resp delay to F1 or all func's read */ 95*4882a593Smuzhiyun #define DWORD_PKT_LEN_EN 0x8 /* Packet len denoted in dwords instead of bytes */ 96*4882a593Smuzhiyun #define CMD_ERR_CHK_EN 0x20 /* Command error check enable */ 97*4882a593Smuzhiyun #define DATA_ERR_CHK_EN 0x40 /* Data error check enable */ 98*4882a593Smuzhiyun 99*4882a593Smuzhiyun /* Bit mask for SPID_RESET_BP device register */ 100*4882a593Smuzhiyun #define RESET_ON_WLAN_BP_RESET 0x4 /* enable reset for WLAN backplane */ 101*4882a593Smuzhiyun #define RESET_ON_BT_BP_RESET 0x8 /* enable reset for BT backplane */ 102*4882a593Smuzhiyun #define RESET_SPI 0x80 /* reset the above enabled logic */ 103*4882a593Smuzhiyun 104*4882a593Smuzhiyun /* Bit mask for card capability */ 105*4882a593Smuzhiyun #define SPID_CHIPID_PRESENT 0x20 /* duplicate of cardcapability chipid present */ 106*4882a593Smuzhiyun #define SPID_SECURE_MODE 0x40 /* duplicate of cardcapability secure mode */ 107*4882a593Smuzhiyun 108*4882a593Smuzhiyun /* Bit mask for SPID_INTR_REG device register */ 109*4882a593Smuzhiyun #define DATA_UNAVAILABLE 0x0001 /* Requested data not available; Clear by writing a "1" */ 110*4882a593Smuzhiyun #define F2_F3_FIFO_RD_UNDERFLOW 0x0002 111*4882a593Smuzhiyun #define F2_F3_FIFO_WR_OVERFLOW 0x0004 112*4882a593Smuzhiyun #define COMMAND_ERROR 0x0008 /* Cleared by writing 1 */ 113*4882a593Smuzhiyun #define DATA_ERROR 0x0010 /* Cleared by writing 1 */ 114*4882a593Smuzhiyun #define F2_PACKET_AVAILABLE 0x0020 115*4882a593Smuzhiyun #define F3_PACKET_AVAILABLE 0x0040 116*4882a593Smuzhiyun #define F1_OVERFLOW 0x0080 /* Due to last write. Bkplane has pending write requests */ 117*4882a593Smuzhiyun #define MISC_INTR0 0x0100 118*4882a593Smuzhiyun #define MISC_INTR1 0x0200 119*4882a593Smuzhiyun #define MISC_INTR2 0x0400 120*4882a593Smuzhiyun #define MISC_INTR3 0x0800 121*4882a593Smuzhiyun #define MISC_INTR4 0x1000 122*4882a593Smuzhiyun #define F1_INTR 0x2000 123*4882a593Smuzhiyun #define F2_INTR 0x4000 124*4882a593Smuzhiyun #define F3_INTR 0x8000 125*4882a593Smuzhiyun 126*4882a593Smuzhiyun /* Bit mask for 32bit SPID_STATUS_REG device register */ 127*4882a593Smuzhiyun #define STATUS_DATA_NOT_AVAILABLE 0x00000001 128*4882a593Smuzhiyun #define STATUS_UNDERFLOW 0x00000002 129*4882a593Smuzhiyun #define STATUS_OVERFLOW 0x00000004 130*4882a593Smuzhiyun #define STATUS_F2_INTR 0x00000008 131*4882a593Smuzhiyun #define STATUS_F3_INTR 0x00000010 132*4882a593Smuzhiyun #define STATUS_F2_RX_READY 0x00000020 133*4882a593Smuzhiyun #define STATUS_F3_RX_READY 0x00000040 134*4882a593Smuzhiyun #define STATUS_HOST_CMD_DATA_ERR 0x00000080 135*4882a593Smuzhiyun #define STATUS_F2_PKT_AVAILABLE 0x00000100 136*4882a593Smuzhiyun #define STATUS_F2_PKT_LEN_MASK 0x000FFE00 137*4882a593Smuzhiyun #define STATUS_F2_PKT_LEN_SHIFT 9 138*4882a593Smuzhiyun #define STATUS_F3_PKT_AVAILABLE 0x00100000 139*4882a593Smuzhiyun #define STATUS_F3_PKT_LEN_MASK 0xFFE00000 140*4882a593Smuzhiyun #define STATUS_F3_PKT_LEN_SHIFT 21 141*4882a593Smuzhiyun 142*4882a593Smuzhiyun /* Bit mask for 16 bits SPID_F1_INFO_REG device register */ 143*4882a593Smuzhiyun #define F1_ENABLED 0x0001 144*4882a593Smuzhiyun #define F1_RDY_FOR_DATA_TRANSFER 0x0002 145*4882a593Smuzhiyun #define F1_MAX_PKT_SIZE 0x01FC 146*4882a593Smuzhiyun 147*4882a593Smuzhiyun /* Bit mask for 16 bits SPID_F2_INFO_REG device register */ 148*4882a593Smuzhiyun #define F2_ENABLED 0x0001 149*4882a593Smuzhiyun #define F2_RDY_FOR_DATA_TRANSFER 0x0002 150*4882a593Smuzhiyun #define F2_MAX_PKT_SIZE 0x3FFC 151*4882a593Smuzhiyun 152*4882a593Smuzhiyun /* Bit mask for 16 bits SPID_F3_INFO_REG device register */ 153*4882a593Smuzhiyun #define F3_ENABLED 0x0001 154*4882a593Smuzhiyun #define F3_RDY_FOR_DATA_TRANSFER 0x0002 155*4882a593Smuzhiyun #define F3_MAX_PKT_SIZE 0x3FFC 156*4882a593Smuzhiyun 157*4882a593Smuzhiyun /* Bit mask for 32 bits SPID_TEST_READ device register read in 16bit LE mode */ 158*4882a593Smuzhiyun #define TEST_RO_DATA_32BIT_LE 0xFEEDBEAD 159*4882a593Smuzhiyun 160*4882a593Smuzhiyun /* Maximum number of I/O funcs */ 161*4882a593Smuzhiyun #define SPI_MAX_IOFUNCS 4 162*4882a593Smuzhiyun 163*4882a593Smuzhiyun #define SPI_MAX_PKT_LEN (2048*4) 164*4882a593Smuzhiyun 165*4882a593Smuzhiyun /* Misc defines */ 166*4882a593Smuzhiyun #define SPI_FUNC_0 0 167*4882a593Smuzhiyun #define SPI_FUNC_1 1 168*4882a593Smuzhiyun #define SPI_FUNC_2 2 169*4882a593Smuzhiyun #define SPI_FUNC_3 3 170*4882a593Smuzhiyun 171*4882a593Smuzhiyun #ifdef BCMQT 172*4882a593Smuzhiyun #define WAIT_F2RXFIFORDY 200 173*4882a593Smuzhiyun #define WAIT_F2RXFIFORDY_DELAY 100 174*4882a593Smuzhiyun #else 175*4882a593Smuzhiyun #define WAIT_F2RXFIFORDY 100 176*4882a593Smuzhiyun #define WAIT_F2RXFIFORDY_DELAY 20 177*4882a593Smuzhiyun #endif // endif 178*4882a593Smuzhiyun 179*4882a593Smuzhiyun #endif /* _SPI_H */ 180