1*6e778a7eSPedro F. Giffuni /*- 2*6e778a7eSPedro F. Giffuni * SPDX-License-Identifier: ISC 3*6e778a7eSPedro F. Giffuni * 4029c02a3SIlya Bakulin * Copyright (c) 2010 Broadcom Corporation 5029c02a3SIlya Bakulin * 6029c02a3SIlya Bakulin * Permission to use, copy, modify, and/or distribute this software for any 7029c02a3SIlya Bakulin * purpose with or without fee is hereby granted, provided that the above 8029c02a3SIlya Bakulin * copyright notice and this permission notice appear in all copies. 9029c02a3SIlya Bakulin * 10029c02a3SIlya Bakulin * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11029c02a3SIlya Bakulin * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12029c02a3SIlya Bakulin * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 13029c02a3SIlya Bakulin * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14029c02a3SIlya Bakulin * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 15029c02a3SIlya Bakulin * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 16029c02a3SIlya Bakulin * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17029c02a3SIlya Bakulin */ 18029c02a3SIlya Bakulin #define SDIO_FUNC_0 0 19029c02a3SIlya Bakulin #define SDIO_FUNC_1 1 20029c02a3SIlya Bakulin #define SDIO_FUNC_2 2 21029c02a3SIlya Bakulin 22029c02a3SIlya Bakulin #define SDIOD_FBR_SIZE 0x100 23029c02a3SIlya Bakulin 24029c02a3SIlya Bakulin /* io_en */ 25029c02a3SIlya Bakulin #define SDIO_FUNC_ENABLE_1 0x02 26029c02a3SIlya Bakulin #define SDIO_FUNC_ENABLE_2 0x04 27029c02a3SIlya Bakulin 28029c02a3SIlya Bakulin /* io_rdys */ 29029c02a3SIlya Bakulin #define SDIO_FUNC_READY_1 0x02 30029c02a3SIlya Bakulin #define SDIO_FUNC_READY_2 0x04 31029c02a3SIlya Bakulin 32029c02a3SIlya Bakulin /* intr_status */ 33029c02a3SIlya Bakulin #define INTR_STATUS_FUNC1 0x2 34029c02a3SIlya Bakulin #define INTR_STATUS_FUNC2 0x4 35029c02a3SIlya Bakulin 36029c02a3SIlya Bakulin /* Maximum number of I/O funcs */ 37029c02a3SIlya Bakulin #define SDIOD_MAX_IOFUNCS 7 38029c02a3SIlya Bakulin 39029c02a3SIlya Bakulin /* mask of register map */ 40029c02a3SIlya Bakulin #define REG_F0_REG_MASK 0x7FF 41029c02a3SIlya Bakulin #define REG_F1_MISC_MASK 0x1FFFF 42029c02a3SIlya Bakulin 43029c02a3SIlya Bakulin /* as of sdiod rev 0, supports 3 functions */ 44029c02a3SIlya Bakulin #define SBSDIO_NUM_FUNCTION 3 45029c02a3SIlya Bakulin 46029c02a3SIlya Bakulin /* function 0 vendor specific CCCR registers */ 47029c02a3SIlya Bakulin #define SDIO_CCCR_BRCM_CARDCAP 0xf0 48029c02a3SIlya Bakulin #define SDIO_CCCR_BRCM_CARDCAP_CMD14_SUPPORT 0x02 49029c02a3SIlya Bakulin #define SDIO_CCCR_BRCM_CARDCAP_CMD14_EXT 0x04 50029c02a3SIlya Bakulin #define SDIO_CCCR_BRCM_CARDCAP_CMD_NODEC 0x08 51029c02a3SIlya Bakulin #define SDIO_CCCR_BRCM_CARDCTRL 0xf1 52029c02a3SIlya Bakulin #define SDIO_CCCR_BRCM_CARDCTRL_WLANRESET 0x02 53029c02a3SIlya Bakulin #define SDIO_CCCR_BRCM_SEPINT 0xf2 54029c02a3SIlya Bakulin 55029c02a3SIlya Bakulin #define SDIO_SEPINT_MASK 0x01 56029c02a3SIlya Bakulin #define SDIO_SEPINT_OE 0x02 57029c02a3SIlya Bakulin #define SDIO_SEPINT_ACT_HI 0x04 58029c02a3SIlya Bakulin 59029c02a3SIlya Bakulin /* function 1 miscellaneous registers */ 60029c02a3SIlya Bakulin 61029c02a3SIlya Bakulin /* sprom command and status */ 62029c02a3SIlya Bakulin #define SBSDIO_SPROM_CS 0x10000 63029c02a3SIlya Bakulin /* sprom info register */ 64029c02a3SIlya Bakulin #define SBSDIO_SPROM_INFO 0x10001 65029c02a3SIlya Bakulin /* sprom indirect access data byte 0 */ 66029c02a3SIlya Bakulin #define SBSDIO_SPROM_DATA_LOW 0x10002 67029c02a3SIlya Bakulin /* sprom indirect access data byte 1 */ 68029c02a3SIlya Bakulin #define SBSDIO_SPROM_DATA_HIGH 0x10003 69029c02a3SIlya Bakulin /* sprom indirect access addr byte 0 */ 70029c02a3SIlya Bakulin #define SBSDIO_SPROM_ADDR_LOW 0x10004 71029c02a3SIlya Bakulin /* gpio select */ 72029c02a3SIlya Bakulin #define SBSDIO_GPIO_SELECT 0x10005 73029c02a3SIlya Bakulin /* gpio output */ 74029c02a3SIlya Bakulin #define SBSDIO_GPIO_OUT 0x10006 75029c02a3SIlya Bakulin /* gpio enable */ 76029c02a3SIlya Bakulin #define SBSDIO_GPIO_EN 0x10007 77029c02a3SIlya Bakulin /* rev < 7, watermark for sdio device */ 78029c02a3SIlya Bakulin #define SBSDIO_WATERMARK 0x10008 79029c02a3SIlya Bakulin /* control busy signal generation */ 80029c02a3SIlya Bakulin #define SBSDIO_DEVICE_CTL 0x10009 81029c02a3SIlya Bakulin 82029c02a3SIlya Bakulin /* SB Address Window Low (b15) */ 83029c02a3SIlya Bakulin #define SBSDIO_FUNC1_SBADDRLOW 0x1000A 84029c02a3SIlya Bakulin /* SB Address Window Mid (b23:b16) */ 85029c02a3SIlya Bakulin #define SBSDIO_FUNC1_SBADDRMID 0x1000B 86029c02a3SIlya Bakulin /* SB Address Window High (b31:b24) */ 87029c02a3SIlya Bakulin #define SBSDIO_FUNC1_SBADDRHIGH 0x1000C 88029c02a3SIlya Bakulin /* Frame Control (frame term/abort) */ 89029c02a3SIlya Bakulin #define SBSDIO_FUNC1_FRAMECTRL 0x1000D 90029c02a3SIlya Bakulin /* ChipClockCSR (ALP/HT ctl/status) */ 91029c02a3SIlya Bakulin #define SBSDIO_FUNC1_CHIPCLKCSR 0x1000E 92029c02a3SIlya Bakulin /* SdioPullUp (on cmd, d0-d2) */ 93029c02a3SIlya Bakulin #define SBSDIO_FUNC1_SDIOPULLUP 0x1000F 94029c02a3SIlya Bakulin /* Write Frame Byte Count Low */ 95029c02a3SIlya Bakulin #define SBSDIO_FUNC1_WFRAMEBCLO 0x10019 96029c02a3SIlya Bakulin /* Write Frame Byte Count High */ 97029c02a3SIlya Bakulin #define SBSDIO_FUNC1_WFRAMEBCHI 0x1001A 98029c02a3SIlya Bakulin /* Read Frame Byte Count Low */ 99029c02a3SIlya Bakulin #define SBSDIO_FUNC1_RFRAMEBCLO 0x1001B 100029c02a3SIlya Bakulin /* Read Frame Byte Count High */ 101029c02a3SIlya Bakulin #define SBSDIO_FUNC1_RFRAMEBCHI 0x1001C 102029c02a3SIlya Bakulin /* MesBusyCtl (rev 11) */ 103029c02a3SIlya Bakulin #define SBSDIO_FUNC1_MESBUSYCTRL 0x1001D 104029c02a3SIlya Bakulin /* Sdio Core Rev 12 */ 105029c02a3SIlya Bakulin #define SBSDIO_FUNC1_WAKEUPCTRL 0x1001E 106029c02a3SIlya Bakulin #define SBSDIO_FUNC1_WCTRL_ALPWAIT_MASK 0x1 107029c02a3SIlya Bakulin #define SBSDIO_FUNC1_WCTRL_ALPWAIT_SHIFT 0 108029c02a3SIlya Bakulin #define SBSDIO_FUNC1_WCTRL_HTWAIT_MASK 0x2 109029c02a3SIlya Bakulin #define SBSDIO_FUNC1_WCTRL_HTWAIT_SHIFT 1 110029c02a3SIlya Bakulin #define SBSDIO_FUNC1_SLEEPCSR 0x1001F 111029c02a3SIlya Bakulin #define SBSDIO_FUNC1_SLEEPCSR_KSO_MASK 0x1 112029c02a3SIlya Bakulin #define SBSDIO_FUNC1_SLEEPCSR_KSO_SHIFT 0 113029c02a3SIlya Bakulin #define SBSDIO_FUNC1_SLEEPCSR_KSO_EN 1 114029c02a3SIlya Bakulin #define SBSDIO_FUNC1_SLEEPCSR_DEVON_MASK 0x2 115029c02a3SIlya Bakulin #define SBSDIO_FUNC1_SLEEPCSR_DEVON_SHIFT 1 116029c02a3SIlya Bakulin 117029c02a3SIlya Bakulin #define SBSDIO_FUNC1_MISC_REG_START 0x10000 /* f1 misc register start */ 118029c02a3SIlya Bakulin #define SBSDIO_FUNC1_MISC_REG_LIMIT 0x1001F /* f1 misc register end */ 119029c02a3SIlya Bakulin 120029c02a3SIlya Bakulin /* function 1 OCP space */ 121029c02a3SIlya Bakulin 122029c02a3SIlya Bakulin /* sb offset addr is <= 15 bits, 32k */ 123029c02a3SIlya Bakulin #define SBSDIO_SB_OFT_ADDR_MASK 0x07FFF 124029c02a3SIlya Bakulin #define SBSDIO_SB_OFT_ADDR_LIMIT 0x08000 125029c02a3SIlya Bakulin /* with b15, maps to 32-bit SB access */ 126029c02a3SIlya Bakulin #define SBSDIO_SB_ACCESS_2_4B_FLAG 0x08000 127029c02a3SIlya Bakulin 128029c02a3SIlya Bakulin /* valid bits in SBSDIO_FUNC1_SBADDRxxx regs */ 129029c02a3SIlya Bakulin 130029c02a3SIlya Bakulin #define SBSDIO_SBADDRLOW_MASK 0x80 /* Valid bits in SBADDRLOW */ 131029c02a3SIlya Bakulin #define SBSDIO_SBADDRMID_MASK 0xff /* Valid bits in SBADDRMID */ 132029c02a3SIlya Bakulin #define SBSDIO_SBADDRHIGH_MASK 0xffU /* Valid bits in SBADDRHIGH */ 133029c02a3SIlya Bakulin /* Address bits from SBADDR regs */ 134029c02a3SIlya Bakulin #define SBSDIO_SBWINDOW_MASK 0xffff8000 135029c02a3SIlya Bakulin 136029c02a3SIlya Bakulin #define SDIOH_READ 0 /* Read request */ 137029c02a3SIlya Bakulin #define SDIOH_WRITE 1 /* Write request */ 138029c02a3SIlya Bakulin 139029c02a3SIlya Bakulin #define SDIOH_DATA_FIX 0 /* Fixed addressing */ 140029c02a3SIlya Bakulin #define SDIOH_DATA_INC 1 /* Incremental addressing */ 141029c02a3SIlya Bakulin 142029c02a3SIlya Bakulin /* internal return code */ 143029c02a3SIlya Bakulin #define SUCCESS 0 144029c02a3SIlya Bakulin #define ERROR 1 145029c02a3SIlya Bakulin 146029c02a3SIlya Bakulin /* Packet alignment for most efficient SDIO (can change based on platform) */ 147029c02a3SIlya Bakulin #define BRCMF_SDALIGN (1 << 6) 148029c02a3SIlya Bakulin 149029c02a3SIlya Bakulin /** 150029c02a3SIlya Bakulin * enum brcmf_sdiod_state - the state of the bus. 151029c02a3SIlya Bakulin * 152029c02a3SIlya Bakulin * @BRCMF_SDIOD_DOWN: Device can be accessed, no DPC. 153029c02a3SIlya Bakulin * @BRCMF_SDIOD_DATA: Ready for data transfers, DPC enabled. 154029c02a3SIlya Bakulin * @BRCMF_SDIOD_NOMEDIUM: No medium access to dongle possible. 155029c02a3SIlya Bakulin */ 156029c02a3SIlya Bakulin enum brcmf_sdiod_state { 157029c02a3SIlya Bakulin BRCMF_SDIOD_DOWN, 158029c02a3SIlya Bakulin BRCMF_SDIOD_DATA, 159029c02a3SIlya Bakulin BRCMF_SDIOD_NOMEDIUM 160029c02a3SIlya Bakulin }; 161