1 /* 2 * Broadcom SiliconBackplane SDIO/PCMCIA hardware-specific 3 * device core support 4 * 5 * Copyright (C) 1999-2019, Broadcom. 6 * 7 * Unless you and Broadcom execute a separate written software license 8 * agreement governing use of this software, this software is licensed to you 9 * under the terms of the GNU General Public License version 2 (the "GPL"), 10 * available at http://www.broadcom.com/licenses/GPLv2.php, with the 11 * following added to such license: 12 * 13 * As a special exception, the copyright holders of this software give you 14 * permission to link this software with independent modules, and to copy and 15 * distribute the resulting executable under terms of your choice, provided that 16 * you also meet, for each linked independent module, the terms and conditions 17 * of the license of that module. An independent module is a module which is 18 * not derived from this software. The special exception does not apply to any 19 * modifications of the software. 20 * 21 * Notwithstanding the above, under no circumstances may you combine this 22 * software in any way with any other Broadcom software provided under a license 23 * other than the GPL, without Broadcom's express prior written consent. 24 * 25 * 26 * <<Broadcom-WL-IPTag/Open:>> 27 * 28 * $Id: sbsdpcmdev.h 616398 2016-02-01 09:37:52Z $ 29 */ 30 31 #ifndef _sbsdpcmdev_h_ 32 #define _sbsdpcmdev_h_ 33 34 /* cpp contortions to concatenate w/arg prescan */ 35 #ifndef PAD 36 #define _PADLINE(line) pad##line 37 #define _XSTR(line) _PADLINE(line) 38 #define PAD _XSTR(__LINE__) 39 #endif /* PAD */ 40 41 typedef volatile struct { 42 dma64regs_t xmt; /* dma tx */ 43 uint32 PAD[2]; 44 dma64regs_t rcv; /* dma rx */ 45 uint32 PAD[2]; 46 } dma64p_t; 47 48 /* dma64 sdiod corerev >= 1 */ 49 typedef volatile struct { 50 dma64p_t dma64regs[2]; 51 dma64diag_t dmafifo; /* DMA Diagnostic Regs, 0x280-0x28c */ 52 uint32 PAD[92]; 53 } sdiodma64_t; 54 55 /* dma32 sdiod corerev == 0 */ 56 typedef volatile struct { 57 dma32regp_t dma32regs[2]; /* dma tx & rx, 0x200-0x23c */ 58 dma32diag_t dmafifo; /* DMA Diagnostic Regs, 0x240-0x24c */ 59 uint32 PAD[108]; 60 } sdiodma32_t; 61 62 /* dma32 regs for pcmcia core */ 63 typedef volatile struct { 64 dma32regp_t dmaregs; /* DMA Regs, 0x200-0x21c, rev8 */ 65 dma32diag_t dmafifo; /* DMA Diagnostic Regs, 0x220-0x22c */ 66 uint32 PAD[116]; 67 } pcmdma32_t; 68 69 /* core registers */ 70 typedef volatile struct { 71 uint32 corecontrol; /* CoreControl, 0x000, rev8 */ 72 uint32 corestatus; /* CoreStatus, 0x004, rev8 */ 73 uint32 PAD[1]; 74 uint32 biststatus; /* BistStatus, 0x00c, rev8 */ 75 76 /* PCMCIA access */ 77 uint16 pcmciamesportaladdr; /* PcmciaMesPortalAddr, 0x010, rev8 */ 78 uint16 PAD[1]; 79 uint16 pcmciamesportalmask; /* PcmciaMesPortalMask, 0x014, rev8 */ 80 uint16 PAD[1]; 81 uint16 pcmciawrframebc; /* PcmciaWrFrameBC, 0x018, rev8 */ 82 uint16 PAD[1]; 83 uint16 pcmciaunderflowtimer; /* PcmciaUnderflowTimer, 0x01c, rev8 */ 84 uint16 PAD[1]; 85 86 /* interrupt */ 87 uint32 intstatus; /* IntStatus, 0x020, rev8 */ 88 uint32 hostintmask; /* IntHostMask, 0x024, rev8 */ 89 uint32 intmask; /* IntSbMask, 0x028, rev8 */ 90 uint32 sbintstatus; /* SBIntStatus, 0x02c, rev8 */ 91 uint32 sbintmask; /* SBIntMask, 0x030, rev8 */ 92 uint32 funcintmask; /* SDIO Function Interrupt Mask, SDIO rev4 */ 93 uint32 PAD[2]; 94 uint32 tosbmailbox; /* ToSBMailbox, 0x040, rev8 */ 95 uint32 tohostmailbox; /* ToHostMailbox, 0x044, rev8 */ 96 uint32 tosbmailboxdata; /* ToSbMailboxData, 0x048, rev8 */ 97 uint32 tohostmailboxdata; /* ToHostMailboxData, 0x04c, rev8 */ 98 99 /* synchronized access to registers in SDIO clock domain */ 100 uint32 sdioaccess; /* SdioAccess, 0x050, rev8 */ 101 uint32 PAD[1]; 102 uint32 MiscHostAccessIntEn; 103 uint32 PAD[1]; 104 105 /* PCMCIA frame control */ 106 uint8 pcmciaframectrl; /* pcmciaFrameCtrl, 0x060, rev8 */ 107 uint8 PAD[3]; 108 uint8 pcmciawatermark; /* pcmciaWaterMark, 0x064, rev8 */ 109 uint8 PAD[155]; 110 111 /* interrupt batching control */ 112 uint32 intrcvlazy; /* IntRcvLazy, 0x100, rev8 */ 113 uint32 PAD[3]; 114 115 /* counters */ 116 uint32 cmd52rd; /* Cmd52RdCount, 0x110, rev8, SDIO: cmd52 reads */ 117 uint32 cmd52wr; /* Cmd52WrCount, 0x114, rev8, SDIO: cmd52 writes */ 118 uint32 cmd53rd; /* Cmd53RdCount, 0x118, rev8, SDIO: cmd53 reads */ 119 uint32 cmd53wr; /* Cmd53WrCount, 0x11c, rev8, SDIO: cmd53 writes */ 120 uint32 abort; /* AbortCount, 0x120, rev8, SDIO: aborts */ 121 uint32 datacrcerror; /* DataCrcErrorCount, 0x124, rev8, SDIO: frames w/bad 122 CRC */ 123 uint32 rdoutofsync; /* RdOutOfSyncCount, 0x128, rev8, SDIO/PCMCIA: Rd Frm 124 OOS */ 125 uint32 wroutofsync; /* RdOutOfSyncCount, 0x12c, rev8, SDIO/PCMCIA: Wr Frm 126 OOS */ 127 uint32 128 writebusy; /* WriteBusyCount, 0x130, rev8, SDIO: dev asserted "busy" */ 129 uint32 readwait; /* ReadWaitCount, 0x134, rev8, SDIO: read: no data avail */ 130 uint32 readterm; /* ReadTermCount, 0x138, rev8, SDIO: rd frm terminates */ 131 uint32 writeterm; /* WriteTermCount, 0x13c, rev8, SDIO: wr frm terminates */ 132 uint32 PAD[40]; 133 uint32 clockctlstatus; /* ClockCtlStatus, 0x1e0, rev8 */ 134 uint32 PAD[1]; 135 uint32 powerctl; /* 0x1e8 */ 136 uint32 PAD[5]; 137 138 /* DMA engines */ 139 volatile union { 140 pcmdma32_t pcm32; 141 sdiodma32_t sdiod32; 142 sdiodma64_t sdiod64; 143 } dma; 144 145 /* SDIO/PCMCIA CIS region */ 146 char cis[512]; /* 512 byte CIS, 0x400-0x5ff, rev6 */ 147 148 /* PCMCIA function control registers */ 149 char pcmciafcr[256]; /* PCMCIA FCR, 0x600-6ff, rev6 */ 150 uint16 PAD[55]; 151 152 /* PCMCIA backplane access */ 153 uint16 backplanecsr; /* BackplaneCSR, 0x76E, rev6 */ 154 uint16 backplaneaddr0; /* BackplaneAddr0, 0x770, rev6 */ 155 uint16 backplaneaddr1; /* BackplaneAddr1, 0x772, rev6 */ 156 uint16 backplaneaddr2; /* BackplaneAddr2, 0x774, rev6 */ 157 uint16 backplaneaddr3; /* BackplaneAddr3, 0x776, rev6 */ 158 uint16 backplanedata0; /* BackplaneData0, 0x778, rev6 */ 159 uint16 backplanedata1; /* BackplaneData1, 0x77a, rev6 */ 160 uint16 backplanedata2; /* BackplaneData2, 0x77c, rev6 */ 161 uint16 backplanedata3; /* BackplaneData3, 0x77e, rev6 */ 162 uint16 PAD[31]; 163 164 /* sprom "size" & "blank" info */ 165 uint16 spromstatus; /* SPROMStatus, 0x7BE, rev2 */ 166 uint32 PAD[464]; 167 168 /* Sonics SiliconBackplane registers */ 169 sbconfig_t sbconfig; /* SbConfig Regs, 0xf00-0xfff, rev8 */ 170 } sdpcmd_regs_t; 171 172 /* corecontrol */ 173 #define CC_CISRDY (1 << 0) /* CIS Ready */ 174 #define CC_BPRESEN (1 << 1) /* CCCR RES signal causes backplane reset */ 175 #define CC_F2RDY (1 << 2) /* set CCCR IOR2 bit */ 176 #define CC_CLRPADSISO (1 << 3) /* clear SDIO pads isolation bit (rev 11) */ 177 #define CC_XMTDATAAVAIL_MODE (1 << 4) /* data avail generates an interrupt */ 178 #define CC_XMTDATAAVAIL_CTRL (1 << 5) /* data avail interrupt ctrl */ 179 180 /* corestatus */ 181 #define CS_PCMCIAMODE (1 << 0) /* Device Mode; 0=SDIO, 1=PCMCIA */ 182 #define CS_SMARTDEV (1 << 1) /* 1=smartDev enabled */ 183 #define CS_F2ENABLED (1 << 2) /* 1=host has enabled the device */ 184 185 #define PCMCIA_MES_PA_MASK 0x7fff /* PCMCIA Message Portal Address Mask */ 186 #define PCMCIA_MES_PM_MASK 0x7fff /* PCMCIA Message Portal Mask Mask */ 187 #define PCMCIA_WFBC_MASK 0xffff /* PCMCIA Write Frame Byte Count Mask */ 188 #define PCMCIA_UT_MASK 0x07ff /* PCMCIA Underflow Timer Mask */ 189 190 /* intstatus */ 191 #define I_SMB_SW0 (1 << 0) /* To SB Mail S/W interrupt 0 */ 192 #define I_SMB_SW1 (1 << 1) /* To SB Mail S/W interrupt 1 */ 193 #define I_SMB_SW2 (1 << 2) /* To SB Mail S/W interrupt 2 */ 194 #define I_SMB_SW3 (1 << 3) /* To SB Mail S/W interrupt 3 */ 195 #define I_SMB_SW_MASK 0x0000000f /* To SB Mail S/W interrupts mask */ 196 #define I_SMB_SW_SHIFT 0 /* To SB Mail S/W interrupts shift */ 197 #define I_HMB_SW0 (1 << 4) /* To Host Mail S/W interrupt 0 */ 198 #define I_HMB_SW1 (1 << 5) /* To Host Mail S/W interrupt 1 */ 199 #define I_HMB_SW2 (1 << 6) /* To Host Mail S/W interrupt 2 */ 200 #define I_HMB_SW3 (1 << 7) /* To Host Mail S/W interrupt 3 */ 201 #define I_HMB_SW_MASK 0x000000f0 /* To Host Mail S/W interrupts mask */ 202 #define I_HMB_SW_SHIFT 4 /* To Host Mail S/W interrupts shift */ 203 #define I_WR_OOSYNC (1 << 8) /* Write Frame Out Of Sync */ 204 #define I_RD_OOSYNC (1 << 9) /* Read Frame Out Of Sync */ 205 #define I_PC (1 << 10) /* descriptor error */ 206 #define I_PD (1 << 11) /* data error */ 207 #define I_DE (1 << 12) /* Descriptor protocol Error */ 208 #define I_RU (1 << 13) /* Receive descriptor Underflow */ 209 #define I_RO (1 << 14) /* Receive fifo Overflow */ 210 #define I_XU (1 << 15) /* Transmit fifo Underflow */ 211 #define I_RI (1 << 16) /* Receive Interrupt */ 212 #define I_BUSPWR (1 << 17) /* SDIO Bus Power Change (rev 9) */ 213 #define I_XMTDATA_AVAIL (1 << 23) /* bits in fifo */ 214 #define I_XI (1 << 24) /* Transmit Interrupt */ 215 #define I_RF_TERM (1 << 25) /* Read Frame Terminate */ 216 #define I_WF_TERM (1 << 26) /* Write Frame Terminate */ 217 #define I_PCMCIA_XU (1 << 27) /* PCMCIA Transmit FIFO Underflow */ 218 #define I_SBINT (1 << 28) /* sbintstatus Interrupt */ 219 #define I_CHIPACTIVE (1 << 29) /* chip transitioned from doze to active state \ 220 */ 221 #define I_SRESET (1 << 30) /* CCCR RES interrupt */ 222 #define I_IOE2 (1U << 31) /* CCCR IOE2 Bit Changed */ 223 #define I_ERRORS (I_PC | I_PD | I_DE | I_RU | I_RO | I_XU) /* DMA Errors */ 224 #define I_DMA (I_RI | I_XI | I_ERRORS) 225 226 /* sbintstatus */ 227 #define I_SB_SERR (1 << 8) /* Backplane SError (write) */ 228 #define I_SB_RESPERR (1 << 9) /* Backplane Response Error (read) */ 229 #define I_SB_SPROMERR (1 << 10) /* Error accessing the sprom */ 230 231 /* sdioaccess */ 232 #define SDA_DATA_MASK 0x000000ff /* Read/Write Data Mask */ 233 #define SDA_ADDR_MASK 0x000fff00 /* Read/Write Address Mask */ 234 #define SDA_ADDR_SHIFT 8 /* Read/Write Address Shift */ 235 #define SDA_WRITE 0x01000000 /* Write bit */ 236 #define SDA_READ 0x00000000 /* Write bit cleared for Read */ 237 #define SDA_BUSY 0x80000000 /* Busy bit */ 238 239 /* sdioaccess-accessible register address spaces */ 240 #define SDA_CCCR_SPACE 0x000 /* sdioAccess CCCR register space */ 241 #define SDA_F1_FBR_SPACE 0x100 /* sdioAccess F1 FBR register space */ 242 #define SDA_F2_FBR_SPACE 0x200 /* sdioAccess F2 FBR register space */ 243 #define SDA_F1_REG_SPACE 0x300 /* sdioAccess F1 core-specific register space \ 244 */ 245 #define SDA_F3_FBR_SPACE 0x400 /* sdioAccess F3 FBR register space */ 246 247 /* SDA_F1_REG_SPACE sdioaccess-accessible F1 reg space register offsets */ 248 #define SDA_CHIPCONTROLDATA 0x006 /* ChipControlData */ 249 #define SDA_CHIPCONTROLENAB 0x007 /* ChipControlEnable */ 250 #define SDA_F2WATERMARK 0x008 /* Function 2 Watermark */ 251 #define SDA_DEVICECONTROL 0x009 /* DeviceControl */ 252 #define SDA_SBADDRLOW 0x00a /* SbAddrLow */ 253 #define SDA_SBADDRMID 0x00b /* SbAddrMid */ 254 #define SDA_SBADDRHIGH 0x00c /* SbAddrHigh */ 255 #define SDA_FRAMECTRL 0x00d /* FrameCtrl */ 256 #define SDA_CHIPCLOCKCSR 0x00e /* ChipClockCSR */ 257 #define SDA_SDIOPULLUP 0x00f /* SdioPullUp */ 258 #define SDA_SDIOWRFRAMEBCLOW 0x019 /* SdioWrFrameBCLow */ 259 #define SDA_SDIOWRFRAMEBCHIGH 0x01a /* SdioWrFrameBCHigh */ 260 #define SDA_SDIORDFRAMEBCLOW 0x01b /* SdioRdFrameBCLow */ 261 #define SDA_SDIORDFRAMEBCHIGH 0x01c /* SdioRdFrameBCHigh */ 262 #define SDA_MESBUSYCNTRL 0x01d /* mesBusyCntrl */ 263 #define SDA_WAKEUPCTRL 0x01e /* WakeupCtrl */ 264 #define SDA_SLEEPCSR 0x01f /* sleepCSR */ 265 266 /* SDA_F1_REG_SPACE register bits */ 267 /* sleepCSR register */ 268 #define SDA_SLEEPCSR_KEEP_SDIO_ON 0x1 269 270 /* SDA_F2WATERMARK */ 271 #define SDA_F2WATERMARK_MASK 0x7f /* F2Watermark Mask */ 272 273 /* SDA_SBADDRLOW */ 274 #define SDA_SBADDRLOW_MASK 0x80 /* SbAddrLow Mask */ 275 276 /* SDA_SBADDRMID */ 277 #define SDA_SBADDRMID_MASK 0xff /* SbAddrMid Mask */ 278 279 /* SDA_SBADDRHIGH */ 280 #define SDA_SBADDRHIGH_MASK 0xff /* SbAddrHigh Mask */ 281 282 /* SDA_FRAMECTRL */ 283 #define SFC_RF_TERM (1 << 0) /* Read Frame Terminate */ 284 #define SFC_WF_TERM (1 << 1) /* Write Frame Terminate */ 285 #define SFC_CRC4WOOS (1 << 2) /* HW reports CRC error for write out of sync */ 286 #define SFC_ABORTALL (1 << 3) /* Abort cancels all in-progress frames */ 287 288 /* pcmciaframectrl */ 289 #define PFC_RF_TERM (1 << 0) /* Read Frame Terminate */ 290 #define PFC_WF_TERM (1 << 1) /* Write Frame Terminate */ 291 292 /* intrcvlazy */ 293 #define IRL_TO_MASK 0x00ffffff /* timeout */ 294 #define IRL_FC_MASK 0xff000000 /* frame count */ 295 #define IRL_FC_SHIFT 24 /* frame count */ 296 297 /* rx header */ 298 typedef volatile struct { 299 uint16 len; 300 uint16 flags; 301 } sdpcmd_rxh_t; 302 303 /* rx header flags */ 304 #define RXF_CRC 0x0001 /* CRC error detected */ 305 #define RXF_WOOS 0x0002 /* write frame out of sync */ 306 #define RXF_WF_TERM 0x0004 /* write frame terminated */ 307 #define RXF_ABORT 0x0008 /* write frame aborted */ 308 #define RXF_DISCARD \ 309 (RXF_CRC | RXF_WOOS | RXF_WF_TERM | RXF_ABORT) /* bad frame */ 310 311 /* HW frame tag */ 312 #define SDPCM_FRAMETAG_LEN 4 /* HW frametag: 2 bytes len, 2 bytes check val */ 313 314 #define SDPCM_HWEXT_LEN 8 315 316 #endif /* _sbsdpcmdev_h_ */ 317