Unit BCMSDHOST

From Ultibo.org
Revision as of 04:18, 25 July 2021 by Ultibo (Talk | contribs)

Jump to: navigation, search

Return to Unit Reference


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


To be documented

Type definitions



BCMSDHOST mailbox tag request

TBCMSDHOSTMailboxTagSetSDHostClock = record

Mailbox tag request for BCMSDHOST_MBOX_TAG_SET_SDHOST_CLOCK
Clock:LongWord;  
Value1:LongWord;  
Value2:LongWord;  

BCMSDHOST host

PBCMSDHOSTHost = ^TBCMSDHOSTHost;

TBCMSDHOSTHost = record

SDHCI Properties
SDHCI:TSDHCIHost;  
BCMSDHOST Properties
IRQ:LongWord; The IRQ number for this device
DREQ:LongWord; The DMA DREQ ID for this device
Lock:TSpinHandle; Host lock (Differs from lock in Host portion) (Spin lock due to use by interrupt handler)
EnableFIQ:LongBool; Use FIQ instead of IRQ
GPIOFirst:LongWord; The starting pin number for GPIO assignments (or GPIO_PIN_UNKNOWN if externally configured)
GPIOLast:LongWord; The ending pin number for GPIO assignments (or GPIO_PIN_UNKNOWN if externally configured)
GPIOFunction:LongWord; The function number for GPIO assignments (or GPIO_FUNCTION_UNKNOWN if externally configured)
ClockDivider:LongWord; Cached Clock Divider (CDIV) register
HostConfiguration:LongWord; Cached Host Configuration (HCFG) register
FirmwareSetsClockDivider:LongBool; True if the firmware controls the clock divider
CommandQuickPollRetries:LongWord;  
NanosecondsPerFifoWord:LongWord;  
AllowDMA:LongBool;  
ResetClock:LongBool; Reset the clock for the next request
MaxDelay:LongWord; Maximum length of time spent waiting (in Milliseconds)
StopTime:Int64; When the last stop was issued (in Clock Ticks)
DrainWords:LongWord; Last words of FIFO to drain on DMA read
DrainOffset:LongWord; Offset for data during FIFO drain on DMA read
UseDMA:LongBool; Use DMA for the current data transfer
UseBusy:LongBool; Wait for busy interrupt on current command
DelayAfterStop:LongWord; Minimum time between stop and subsequent data transfer (in Microseconds)
DelayAfterThisStop:LongWord; Minimum time between this stop and subsequent data transfer (in Microseconds)
UserOverclock50:LongWord; User's preferred frequency to use when 50MHz is requested (in MHz)
Overclock50:LongWord; Frequency to use when 50MHz is requested (in MHz)
Overclock:LongWord; Current frequency if overclocked, else zero (in Hz)
PIOLimit:LongWord; Maximum block count for PIO (0 = always DMA / 0x7FFFFFF = always PIO)
PIOTimeout:LongWord; PIO Read or Write block timeout (in milliseconds)
DMAData:TDMAData; DMA data descriptor for current request (If applicable)
DMADirection:LongWord; DMA data direction for current request (If applicable)
DMABuffer:Pointer; DMA bounce buffer for the current request (If applicable)


Public variables


None defined

Function declarations



Initialization functions

procedure BCMSDHOSTInit;
Description: Initialize the BCMSDHOST unit and version table
Note Called only during system startup


BCMSDHOST functions

function BCMSDHOSTCreate(Address:PtrUInt; const Name:String; IRQ,DREQ,ClockMinimum,ClockMaximum,GPIOFirst,GPIOLast,GPIOFunction:LongWord; EnableFIQ:Boolean):PSDHCIHost;
Description: Create and register a new BCMSDHOST SDHCI device which can be accessed using the SDHCI API
Address The address of the BCMSDHOST registers
Name The text description of this device which will show in the device list (Optional)
IRQ The interrupt number for the BCMSDHOST
DREQ The DMA data request ID for the BCMSDHOST
ClockMinimum The minimum frequency for the BCMSDHOST clock
ClockMaximum The maximum frequency for the BCMSDHOST clock
GPIOFirst The starting pin number for GPIO assignments (or GPIO_PIN_UNKNOWN if externally configured)
GPIOLast The ending pin number for GPIO assignments (or GPIO_PIN_UNKNOWN if externally configured)
GPIOFunction The function number for GPIO assignments (or GPIO_FUNCTION_UNKNOWN if externally configured)
EnableFIQ Enable fast interrupt support for the BCMSDHOST
Return Pointer to the new SDHCI device or nil if the SDHCI device could not be created


function BCMSDHOSTDestroy(SDHCI:PSDHCIHost):LongWord;
Description: Stop, deregister and destroy a BCMSDHOST SDHCI device created by this driver
SDHCI The SDHCI device to destroy
Return ERROR_SUCCESS if completed or another error code on failure


BCMSDHOST MMC functions

function BCMSDHOSTSendCommand(MMC:PMMCDevice; Command:PMMCCommand):LongWord;
Description: Implementation of MMCDeviceSendCommand API for BCMSDHOST SDHCI
Note Not intended to be called directly by applications, use MMCDeviceSendCommand instead.


function BCMSDHOSTSetIOS(MMC:PMMCDevice):LongWord;
Description: Implementation of MMCDeviceSetIOS API for BCMSDHOST SDHCI
Note Not intended to be called directly by applications, use MMCDeviceSetIOS instead.


function BCMSDHOSTGetCardDetect(MMC:PMMCDevice):LongWord;
Description: Implementation of MMCDeviceGetCardDetect API for BCMSDHOST SDHCI
Note Not intended to be called directly by applications, use MMCDeviceGetCardDetect instead.


function BCMSDHOSTGetWriteProtect(MMC:PMMCDevice):LongWord;
Description: Implementation of MMCDeviceGetWriteProtect API for BCMSDHOST SDHCI
Note Not intended to be called directly by applications, use MMCDeviceGetWriteProtect instead.


BCMSDHOST SDHCI functions

function BCMSDHOSTHostStart(SDHCI:PSDHCIHost):LongWord;
Description: Implementation of SDHCIHostStart API for BCMSDHOST SDHCI
Note Not intended to be called directly by applications, use SDHCIHostStart instead.


function BCMSDHOSTHostStop(SDHCI:PSDHCIHost):LongWord;
Description: Implementation of SDHCIHostStop API for BCMSDHOST SDHCI
Note Not intended to be called directly by applications, use SDHCIHostStop instead.


function BCMSDHOSTReset(SDHCI:PSDHCIHost; Mask:Byte):LongWord;
Description: Implementation of SDHCIReset API for BCMSDHOST SDHCI
Note Not intended to be called directly by applications, use SDHCIReset instead.


function BCMSDHOSTHardwareReset(SDHCI:PSDHCIHost):LongWord;
Description: Implementation of SDHCIHardwareReset API for BCMSDHOST SDHCI
Note Not intended to be called directly by applications, use SDHCIHardwareReset instead.


function BCMSDHOSTSetPower(SDHCI:PSDHCIHost; Power:Word):LongWord;
Description: Implementation of SDHCISetPower API for BCMSDHOST SDHCI
Note Not intended to be called directly by applications, use SDHCISetPower instead.


function BCMSDHOSTSetClock(SDHCI:PSDHCIHost; Clock:LongWord):LongWord;
Description: Implementation of SDHCISetClock API for BCMSDHOST SDHCI
Note Not intended to be called directly by applications, use SDHCISetClock instead.


procedure BCMSDHOSTCommandWaitWorker(SDHCI:PSDHCIHost);
Description: Worker thread task to wait for BCMSDHOST command completion
Note Not intended to be called directly by applications


procedure BCMSDHOSTDMARequestCompleted(Request:PDMARequest);
Description: DMA Request completion callback for the BCMSDHOST host controller
Note Not intended to be called directly by applications


function BCMSDHOSTSharedInterruptHandler(Number,CPUID,Flags:LongWord; SDHCI:PSDHCIHost):LongWord;
Description: Interrupt handler for the BCMSDHOST host controller
Note Not intended to be called directly by applications


BCMSDHOST helper functions

function BCMSDHOSTSetSDHostClock(var Clock,Value1,Value2:LongWord):LongWord;
Description: Set the SD Host Clock value in the Mailbox property tags channel
Note None documented


Return to Unit Reference