Difference between revisions of "Unit BCMSDHOST"

From Ultibo.org
Jump to: navigation, search
Line 21: Line 21:
 
----
 
----
  
''To be documented''
+
 
 +
'''BCMSDHOST mailbox tag request'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
 
 +
<code>TBCMSDHOSTMailboxTagSetSDHostClock = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|Mailbox tag request for BCMSDHOST_MBOX_TAG_SET_SDHOST_CLOCK
 +
|-
 +
| <code>Clock:LongWord;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>Value1:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
| <code>Value2:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''BCMSDHOST host'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PBCMSDHOSTHost = ^TBCMSDHOSTHost;</code>
 +
 
 +
<code>TBCMSDHOSTHost = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|''SDHCI Properties''
 +
|-
 +
| <code>SDHCI:TSDHCIHost;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|colspan="2"|''BCMSDHOST Properties''
 +
|-
 +
| <code>IRQ:LongWord;</code>
 +
| The IRQ number for this device
 +
|-
 +
| <code>DREQ:LongWord;</code>
 +
| The DMA DREQ ID for this device
 +
|-
 +
| <code>Lock:TSpinHandle;</code>
 +
| Host lock (Differs from lock in Host portion) (Spin lock due to use by interrupt handler)
 +
|-
 +
| <code>EnableFIQ:LongBool;</code>
 +
| Use FIQ instead of IRQ
 +
|-
 +
| <code>GPIOFirst:LongWord;</code>
 +
| The starting pin number for GPIO assignments (or GPIO_PIN_UNKNOWN if externally configured)
 +
|-
 +
| <code>GPIOLast:LongWord;</code>
 +
| The ending pin number for GPIO assignments (or GPIO_PIN_UNKNOWN if externally configured)
 +
|-
 +
| <code>GPIOFunction:LongWord;</code>
 +
| The function number for GPIO assignments (or GPIO_FUNCTION_UNKNOWN if externally configured)
 +
|-
 +
| <code>ClockDivider:LongWord;</code>
 +
| Cached Clock Divider (CDIV) register
 +
|-
 +
| <code>HostConfiguration:LongWord;</code>
 +
| Cached Host Configuration (HCFG) register
 +
|-
 +
| <code>FirmwareSetsClockDivider:LongBool;</code>
 +
| True if the firmware controls the clock divider
 +
|-
 +
| <code>CommandQuickPollRetries:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
| <code>NanosecondsPerFifoWord:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
| <code>AllowDMA:LongBool;</code>
 +
| &nbsp;
 +
|-
 +
| <code>ResetClock:LongBool;</code>
 +
| Reset the clock for the next request
 +
|-
 +
| <code>MaxDelay:LongWord;</code>
 +
| Maximum length of time spent waiting (in Milliseconds)
 +
|-
 +
| <code>StopTime:Int64;</code>
 +
| When the last stop was issued (in Clock Ticks)
 +
|-
 +
| <code>DrainWords:LongWord;</code>
 +
| Last words of FIFO to drain on DMA read
 +
|-
 +
| <code>DrainOffset:LongWord;</code>
 +
| Offset for data during FIFO drain on DMA read
 +
|-
 +
| <code>UseDMA:LongBool;</code>
 +
| Use DMA for the current data transfer
 +
|-
 +
| <code>UseBusy:LongBool;</code>
 +
| Wait for busy interrupt on current command
 +
|-
 +
| <code>DelayAfterStop:LongWord;</code>
 +
| Minimum time between stop and subsequent data transfer (in Microseconds)
 +
|-
 +
| <code>DelayAfterThisStop:LongWord;</code>
 +
| Minimum time between this stop and subsequent data transfer (in Microseconds)
 +
|-
 +
| <code>UserOverclock50:LongWord;</code>
 +
| User's preferred frequency to use when 50MHz is requested (in MHz)
 +
|-
 +
| <code>Overclock50:LongWord;</code>
 +
| Frequency to use when 50MHz is requested (in MHz)
 +
|-
 +
| <code>Overclock:LongWord;</code>
 +
| Current frequency if overclocked, else zero (in Hz)
 +
|-
 +
| <code>PIOLimit:LongWord;</code>
 +
| Maximum block count for PIO (0 = always DMA / 0x7FFFFFF = always PIO)
 +
|-
 +
| <code>PIOTimeout:LongWord;</code>
 +
| PIO Read or Write block timeout (in milliseconds)
 +
|-
 +
| <code>DMAData:TDMAData;</code>
 +
| DMA data descriptor for current request (If applicable)
 +
|-
 +
| <code>DMADirection:LongWord;</code>
 +
| DMA data direction for current request (If applicable)
 +
|-
 +
| <code>DMABuffer:Pointer;</code>
 +
| DMA bounce buffer for the current request (If applicable)
 +
|-
 +
|}
 +
</div></div>
 +
<br />
  
 
=== Public variables ===
 
=== Public variables ===

Revision as of 04:18, 25 July 2021

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

[Expand]

TBCMSDHOSTMailboxTagSetSDHostClock = record

BCMSDHOST host

[Expand]

PBCMSDHOSTHost = ^TBCMSDHOSTHost;

TBCMSDHOSTHost = record


Public variables


None defined

Function declarations



Initialization functions

[Expand]
procedure BCMSDHOSTInit;
Description: Initialize the BCMSDHOST unit and version table


BCMSDHOST functions

[Expand]
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


[Expand]
function BCMSDHOSTDestroy(SDHCI:PSDHCIHost):LongWord;
Description: Stop, deregister and destroy a BCMSDHOST SDHCI device created by this driver


BCMSDHOST MMC functions

[Expand]
function BCMSDHOSTSendCommand(MMC:PMMCDevice; Command:PMMCCommand):LongWord;
Description: Implementation of MMCDeviceSendCommand API for BCMSDHOST SDHCI


[Expand]
function BCMSDHOSTSetIOS(MMC:PMMCDevice):LongWord;
Description: Implementation of MMCDeviceSetIOS API for BCMSDHOST SDHCI


[Expand]
function BCMSDHOSTGetCardDetect(MMC:PMMCDevice):LongWord;
Description: Implementation of MMCDeviceGetCardDetect API for BCMSDHOST SDHCI


[Expand]
function BCMSDHOSTGetWriteProtect(MMC:PMMCDevice):LongWord;
Description: Implementation of MMCDeviceGetWriteProtect API for BCMSDHOST SDHCI


BCMSDHOST SDHCI functions

[Expand]
function BCMSDHOSTHostStart(SDHCI:PSDHCIHost):LongWord;
Description: Implementation of SDHCIHostStart API for BCMSDHOST SDHCI


[Expand]
function BCMSDHOSTHostStop(SDHCI:PSDHCIHost):LongWord;
Description: Implementation of SDHCIHostStop API for BCMSDHOST SDHCI


[Expand]
function BCMSDHOSTReset(SDHCI:PSDHCIHost; Mask:Byte):LongWord;
Description: Implementation of SDHCIReset API for BCMSDHOST SDHCI


[Expand]
function BCMSDHOSTHardwareReset(SDHCI:PSDHCIHost):LongWord;
Description: Implementation of SDHCIHardwareReset API for BCMSDHOST SDHCI


[Expand]
function BCMSDHOSTSetPower(SDHCI:PSDHCIHost; Power:Word):LongWord;
Description: Implementation of SDHCISetPower API for BCMSDHOST SDHCI


[Expand]
function BCMSDHOSTSetClock(SDHCI:PSDHCIHost; Clock:LongWord):LongWord;
Description: Implementation of SDHCISetClock API for BCMSDHOST SDHCI


[Expand]
procedure BCMSDHOSTCommandWaitWorker(SDHCI:PSDHCIHost);
Description: Worker thread task to wait for BCMSDHOST command completion


[Expand]
procedure BCMSDHOSTDMARequestCompleted(Request:PDMARequest);
Description: DMA Request completion callback for the BCMSDHOST host controller


[Expand]
function BCMSDHOSTSharedInterruptHandler(Number,CPUID,Flags:LongWord; SDHCI:PSDHCIHost):LongWord;
Description: Interrupt handler for the BCMSDHOST host controller


BCMSDHOST helper functions

[Expand]
function BCMSDHOSTSetSDHostClock(var Clock,Value1,Value2:LongWord):LongWord;
Description: Set the SD Host Clock value in the Mailbox property tags channel


Return to Unit Reference