Difference between revisions of "Unit BCMSDHOST"
Line 16: | Line 16: | ||
---- | ---- | ||
− | '' | + | |
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''BCMSDHOST specific constants''' <code> BCMSDHOST_* </code></div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | | <code>BCMSDHOST_DESCRIPTION = 'Broadcom BCM27XX SDHOST';</code> | ||
+ | | style="width: 50%;"|Description of BCMSDHOST device | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>BCMSDHOST_FIFO_READ_THRESHOLD = 4;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>BCMSDHOST_FIFO_WRITE_THRESHOLD = 4;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>BCMSDHOST_ALLOW_CMD23_READ = 1;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>BCMSDHOST_ALLOW_CMD23_WRITE = 0;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDDATA_FIFO_PIO_BURST = 8;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>BCMSDHOST_CMD_DALLY_US = 1;</code> | ||
+ | | | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''BCMSDHOST register''' <code> BCMSDHOST_* </code></div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDCMD = $00;</code> | ||
+ | | style="width: 50%;"|Command to SD card - 16 R/W | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDARG = $04;</code> | ||
+ | | Argument to SD card - 32 R/W | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDTOUT = $08;</code> | ||
+ | | Start value for timeout counter - 32 R/W | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDCDIV = $0c;</code> | ||
+ | | Start value for clock divider - 11 R/W | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDRSP0 = $10;</code> | ||
+ | | SD card response (31:0)- 32 R | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDRSP1 = $14;</code> | ||
+ | | SD card response (63:32) - 32 R | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDRSP2 = $18;</code> | ||
+ | | SD card response (95:64) - 32 R | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDRSP3 = $1c;</code> | ||
+ | | SD card response (127:96)- 32 R | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDHSTS = $20;</code> | ||
+ | | SD host status - 11 R | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDVDD = $30;</code> | ||
+ | | SD card power control - 1 R/W | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDEDM = $34;</code> | ||
+ | | Emergency Debug Mode - 13 R/W | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDHCFG = $38;</code> | ||
+ | | Host configuration - 2 R/W | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDHBCT = $3c;</code> | ||
+ | | Host byte count (debug) - 32 R/W | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDDATA = $40;</code> | ||
+ | | Data to/from SD card - 32 R/W | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDHBLC = $50;</code> | ||
+ | | Host block count (SDIO/SDHC) - 9 R/W | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''BCMSDHOST command register''' <code> BCMSDHOST_SDCMD_* </code></div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDCMD_NEW_FLAG = $8000;</code> | ||
+ | | style="width: 50%;"| | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDCMD_FAIL_FLAG = $4000;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDCMD_BUSYWAIT = $800;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDCMD_NO_RESPONSE = $400;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDCMD_LONG_RESPONSE = $200;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDCMD_WRITE_CMD = $80;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDCMD_READ_CMD = $40;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDCMD_CMD_MASK = $3f;</code> | ||
+ | | | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''BCMSDHOST clock divider register''' <code> BCMSDHOST_SDCDIV_* </code></div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDCDIV_MAX_CDIV = $7ff;</code> | ||
+ | | style="width: 50%;"| | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''BCMSDHOST host status register''' <code> BCMSDHOST_SDHSTS_* </code></div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDHSTS_BUSY_IRPT = $400;</code> | ||
+ | | style="width: 50%;"| | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDHSTS_BLOCK_IRPT = $200;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDHSTS_SDIO_IRPT = $100;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDHSTS_REW_TIME_OUT = $80;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDHSTS_CMD_TIME_OUT = $40;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDHSTS_CRC16_ERROR = $20;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDHSTS_CRC7_ERROR = $10;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDHSTS_FIFO_ERROR = $08;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>04 Reserved</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>02 Reserved</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDHSTS_DATA_FLAG = $01;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDHSTS_TRANSFER_ERROR_MASK = BCMSDHOST_SDHSTS_CRC7_ERROR or BCMSDHOST_SDHSTS_CRC16_ERROR or BCMSDHOST_SDHSTS_REW_TIME_OUT or BCMSDHOST_SDHSTS_FIFO_ERROR;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDHSTS_ERROR_MASK = BCMSDHOST_SDHSTS_CMD_TIME_OUT or BCMSDHOST_SDHSTS_TRANSFER_ERROR_MASK;</code> | ||
+ | | | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''BCMSDHOST host configuration register''' <code> BCMSDHOST_SDHCFG_* </code></div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDHCFG_BUSY_IRPT_EN = (1 shl 10);</code> | ||
+ | | style="width: 50%;"| | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDHCFG_BLOCK_IRPT_EN = (1 shl 8);</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDHCFG_SDIO_IRPT_EN = (1 shl 5);</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDHCFG_DATA_IRPT_EN = (1 shl 4);</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDHCFG_SLOW_CARD = (1 shl 3);</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDHCFG_WIDE_EXT_BUS = (1 shl 2);</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDHCFG_WIDE_INT_BUS = (1 shl 1);</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDHCFG_REL_CMD_LINE = (1 shl 0);</code> | ||
+ | | | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''BCMSDHOST emergency debug mode register''' <code> BCMSDHOST_SDEDM_* </code></div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDEDM_FORCE_DATA_MODE = (1 shl 19);</code> | ||
+ | | style="width: 50%;"| | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDEDM_CLOCK_PULSE = (1 shl 20);</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDEDM_BYPASS = (1 shl 21);</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDEDM_WRITE_THRESHOLD_SHIFT = 9;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDEDM_READ_THRESHOLD_SHIFT = 14;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDEDM_THRESHOLD_MASK = $1f;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDEDM_FSM_MASK = $f;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDEDM_FSM_IDENTMODE = $0;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDEDM_FSM_DATAMODE = $1;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDEDM_FSM_READDATA = $2;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDEDM_FSM_WRITEDATA = $3;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDEDM_FSM_READWAIT = $4;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDEDM_FSM_READCRC = $5;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDEDM_FSM_WRITECRC = $6;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDEDM_FSM_WRITEWAIT1 = $7;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDEDM_FSM_POWERDOWN = $8;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDEDM_FSM_POWERUP = $9;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDEDM_FSM_WRITESTART1 = $a;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDEDM_FSM_WRITESTART2 = $b;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDEDM_FSM_GENPULSES = $c;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDEDM_FSM_WRITEWAIT2 = $d;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDEDM_FSM_STARTPOWDOWN = $f;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>BCMSDHOST_SDDATA_FIFO_WORDS = 16;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>BCMSDHOST_USE_CMD23_FLAGS = (BCMSDHOST_ALLOW_CMD23_READ * MMC_DATA_READ) or (BCMSDHOST_ALLOW_CMD23_WRITE * MMC_DATA_WRITE);</code> | ||
+ | | | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;"> | ||
+ | <div style="font-size: 14px; padding-left: 12px;">'''BCMSDHOST mailbox constants''' <code> BCMSDHOST_MBOX_TAG_SET_* </code></div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | | <code>BCMSDHOST_MBOX_TAG_SET_SDHOST_CLOCK = $00038042;</code> | ||
+ | | style="width: 50%;"|Tell the firmware the SD Host clock setting so it will be adjusted for changes in core frequency | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
=== Type definitions === | === Type definitions === |
Revision as of 04:44, 25 July 2021
Return to Unit Reference
Contents
[hide]Description
Broadcom BCM27XX SDHOST driver
The SDHOST controller on the BCM27XX is a non SDHCI-compliant device which requires a specific driver.
It can be routed to GPIO pins 22 to 27 (ALT0) or 48 to 53 (ALT0) in order to control the SD card slot when the SDHCI device is being used for the on board WiFi.
Note that on the Raspberry Pi 4 the SD card is no longer connected to pins 48 to 53 so the SDHOST controller cannot control the primary SD card, there is an additional SDHCI controller (EMMC2) for that purpose.
Constants
BCMSDHOST_*
BCMSDHOST_*
BCMSDHOST_SDCMD_*
BCMSDHOST_SDCDIV_*
BCMSDHOST_SDHSTS_*
BCMSDHOST_SDHCFG_*
BCMSDHOST_SDEDM_*
BCMSDHOST_MBOX_TAG_SET_*
Type definitions
BCMSDHOST mailbox tag request
TBCMSDHOSTMailboxTagSetSDHostClock = record
BCMSDHOST host
Public variables
None defined
Function declarations
Initialization functions
BCMSDHOST functions
function BCMSDHOSTCreate(Address:PtrUInt; const Name:String; IRQ,DREQ,ClockMinimum,ClockMaximum,GPIOFirst,GPIOLast,GPIOFunction:LongWord; EnableFIQ:Boolean):PSDHCIHost;
function BCMSDHOSTDestroy(SDHCI:PSDHCIHost):LongWord;
BCMSDHOST MMC functions
function BCMSDHOSTSendCommand(MMC:PMMCDevice; Command:PMMCCommand):LongWord;
function BCMSDHOSTSetIOS(MMC:PMMCDevice):LongWord;
function BCMSDHOSTGetCardDetect(MMC:PMMCDevice):LongWord;
function BCMSDHOSTGetWriteProtect(MMC:PMMCDevice):LongWord;
BCMSDHOST SDHCI functions
function BCMSDHOSTHostStart(SDHCI:PSDHCIHost):LongWord;
function BCMSDHOSTHostStop(SDHCI:PSDHCIHost):LongWord;
function BCMSDHOSTReset(SDHCI:PSDHCIHost; Mask:Byte):LongWord;
function BCMSDHOSTHardwareReset(SDHCI:PSDHCIHost):LongWord;
function BCMSDHOSTSetPower(SDHCI:PSDHCIHost; Power:Word):LongWord;
function BCMSDHOSTSetClock(SDHCI:PSDHCIHost; Clock:LongWord):LongWord;
procedure BCMSDHOSTCommandWaitWorker(SDHCI:PSDHCIHost);
procedure BCMSDHOSTDMARequestCompleted(Request:PDMARequest);
function BCMSDHOSTSharedInterruptHandler(Number,CPUID,Flags:LongWord; SDHCI:PSDHCIHost):LongWord;
BCMSDHOST helper functions
function BCMSDHOSTSetSDHostClock(var Clock,Value1,Value2:LongWord):LongWord;
Return to Unit Reference