Unit BCM2709
Return to Unit Reference
Description
This unit provides the BCM2709 specific implementations of the following devices:
- SPI0
- I2C0
- I2C1
- SPI1
- SPI2
- I2C Slave
- SPI Slave
- DMA
- PWM0
- PWM1
- PCM
- GPIO
- UART0
- UART1
- SDHCI (eMMC)
- Clock
- ARM Timer
- Local Timer
- Random
- Mailbox
- Watchdog
- Framebuffer
- MIPI CSI-2 (Camera Serial Interface)
- DSI (Display Serial Interface)
BCM2709 SPI0 Device
The BCM2709 has a single master mode SPI controller that supports 3 wire, 2 wire and LoSSI modes of operation. It also has 2 auxiliary SPI masters which do not support DMA mode (see SPI1/2 below).
The main SPI0 controller supports polled, interrupt and DMA modes and includes 3 chip selects although only CS0 and 1 are available on the 26 or 40 pin header.
By default SPI0 can appear on GPIO pins 7 to 11 (CS1, CS0, MISO, MOSI, SCLK) using alternate function 0 or on GPIO pins 35 to 39 (CS1, CS0, MISO, MOSI, SCLK) using alternate function 0, only pins 7 to 11 are available on the header.
BCM2709 I2C0/1 Device
The BCM2709 has 3 Broadcom Serial Controller (BSC) devices which are fast mode (400Kz) masters numbered BSC0, BSC1 and BSC2.
Device BSC2 is dedicated to the HDMI interface and is not availale for use by the ARM processor. All BSC devices contain a 16 byte FIFO, support 7 bit and 10 bit addressing and have software configurable clock timing.
By default BSC0 can appear on GPIO pins 0 and 1 (Alternate function 0), 28 and 29 (Alternate function 0) or 44 and 45 (Alternate function 1). Unfortunately on all except the Revision 1 models none of these pins are available on the 26 or 40 pin header.
Note: On the Raspberry Pi A+/B+/Zero/2B/3B the ID EEPROM pins on the 40 pin header are actually connected to GPIO 0 and 1 (BSC0)
Device BSC1 can appear on GPIO pins 2 and 3 (Alternate function 0) or 44 and 45 (Alternate function 2) but only pins 2 and 3 are exposed on the 26 or 40 pin header.
BCM2709 SPI1/2 Device
The BCM2709 has 2 additional SPI universal masters available as part of the AUX device which support interrupt mode but not DMA and therefore only allow limited bandwidth transfers due to the CPU overhead required to sustain high data rates.
Both devices support 3 chip selects, by default SPI1 is available on GPIO pins 16 to 21 (CS2, CS1, CS0, MISO, MOSI, SCLK) using alternate function 4 and SPI2 is available on GPIO pins 40 to 45 (MISO, MOSI, SCLK, CS0, CS1, CS2) using alternate function 4. Only pins 16 to 21 are available on the header and only on the 40 pin header of the Raspberry Pi A+/B+/Zero/2B/3B.
BCM2709 DMA Device
The DMA controller has 16 channels in total although not all are available for software to use as some are already used by the GPU.
The firmware will pass the value dma.dmachans on the command line which will indicate which channels are available for our use.
Channels 0 to 6 are normal channels which support 2D stride and transfers up to 1GB per control block
Channels 7 to 14 are Lite channels which do not support stride and only allow transfers up to 64KB per control block
Channel 15 is not mentioned in most documentation and is shown as not available in the mask passed in dma.dmachans
Channel 0 and 15 are Bulk channels which have an additional FIFO for faster transfers (8 beat burst per read)
BCM2709 PWM0/1 Device
The BCM2709 has a single PWM controller with 2 independent output bit streams with multiple algorithms for generating the output pulse. The PWM controller supports either a single data register (independent per channel) or a 16 x 32 FIFO which also supports DMA mode transmission.
On the Raspberry Pi PWM0 and PWM1 are also connected via GPIO pins 40 and 45 (40 and 41 on the Raspberry Pi 3B) to the audio circuit and allow playback of digital audio signals via the 3 or 4 pole line jack (depending on model). PWM0 is available on GPIO pins 12 (function 0), 18 (function 5), 40 (function 0) and 52 (function 1). PWM1 is available on GPIO pins 13 (function 0), 19 (function 5), 41, 45 (function 0) and 53 (function 1).
On the Raspberry Pi A and B only pin 18 is exposed on the 26 pin header.
On the Raspberry Pi A+/B+/Zero/2B/3B pins 12, 18 and 19 are exposed on the 40 pin header.
BCM2709 GPIO Device
The GPIO has 54 pins available each with multiple alternate functions. All pins can be configured as input or output and all can have pull up or down applied.
Not all pins are exposed on the 26 or 40 pin header of the Raspberry Pi, for details of which pins are available see:
Raspberry Pi A and B - https://www.raspberrypi.org/documentation/usage/gpio/README.md
Raspberry Pi A+/B+/2B/3B/Zero - https://www.raspberrypi.org/documentation/usage/gpio-plus-and-raspi2/README.md
Some of the 54 pins are used for peripheral communication (such as the SD card) and are not available for general use, take care when changing function selects on pins to avoid disabling certain system peripherals.
Event detection can be enabled for both high and low levels as well as rising and falling edges, there is also an asynchronous rising or falling edge detection which can detect edges of very short duration.
BCM2709 UART0 Device
The UART0 device is an ARM PL011 UART which supports programmable baud rates, start, stop and parity bits and hardware flow control and many others. The UART0 is similar to the industry standard 16C650 but with a number of differences, the PL011 has a some optional features such as IrDA, Serial InfraRed and DMA which are not supported by the Broadcom implementation. In the standard configuration the UART0 TX and RX lines are connected to GPIO pins 14 and 15 respectively (Alternate function 0) but they can be remapped via GPIO function selects to a number of other locations. On the Raspberry Pi (all models) none of these alternate pin mappings are exposed via the 26 or 40 pin header and therefore cannot be used easily. This means that UART0 and UART1 cannot be used at the same time.
On the Raspberry Pi 3B the UART0 can be mapped to GPIO pins 32 and 33 (Alternate function 3) to communicate with the built in Bluetooth module.
BCM2709 UART1 Device
The UART1 device is a Broadcom implementation that is part of the AUX device which also includes the SPI1 and SPI2 devices. This device is termed a Mini UART and has a smaller feature set than the PL011 UART but still supports a fairly standard communication protocol with programmable baud rate and hardware flow control.
The Mini UART is similar to the standard 16550 device but is missing some of the features, the device also has no DMA support so high speed transfers will produce a higher CPU load. In the standard configuration the UART1 TX and RX lines are connected to GPIO pins 14 and 15 respectively (Alternate function 5) but they can be remapped via GPIO function selects to a number of other locations. On the Raspberry Pi (all models) none of these alternate pin mappings are exposed via the 26 or 40 pin header and therefore cannot be used easily. This means that UART0 and UART1 cannot be used at the same time.
On the Raspberry Pi 3B the UART1 can be mapped to GPIO pins 32 and 33 (Alternate function 5) to communicate with the built in Bluetooth module.
BCM2709 SDHCI Device
The SDHCI controller on the BCM2709 is an Arasan SD Host controller.
The Card Detect pin is not connected.
The Write Protect pin is not connected.
BCM2709 Clock Device
The clock device in the BCM2709 is based on the System Timer which is a 64 bit free running counter that runs at 1MHz regardless of core or CPU clock speeds.
The System Timer includes 4 compare registers which can each generate an interrupt when the compare value is matched, however 2 of the 4 are consumed by the GPU and on the Raspberry Pi A/B/A+/B+/Zero the other 2 are used for the scheduler and clock interrupts in Ultibo.
This device simply exposes the free running counter as a clock value and does not provide access to the timer compare functionality or to interrupt based events, for those see the timer devices below.
BCM2709 ARM Timer Device
The ARM Timer device in the BCM2709 is based on the ARM SP804 timer with some modifications and additions. In the Raspberry Pi it is connected to the core clock which by default is 250MHz but was increased to 400MHz on the Raspberry Pi 3B.
The divider is 10 bits wide which means that the ARM Timer can be set to clock rates of between 250KHz and 250MHz (or 400KHz to 400MHz on the Raspberry Pi 3B). Both the counter and the load/reload value are 32 bits wide by default giving a wide range of tick intervals.
The ARM Timer features a free running counter which is not enabled or used by this driver and a down counter which operates in wrapping mode so that each time it reaches 0 it triggers an interrupt and reloads the value ?rom a load or reload register to begin counting again.
Constants
To be documented
Type definitions
To be documented
Public variables
To be documented
Function declarations
Initialization functions
procedure BCM2709Init;
Note | None documented |
---|
BCM2709 SPI0 functions
function BCM2709SPI0Start(SPI:PSPIDevice; Mode,ClockRate,ClockPhase,ClockPolarity:LongWord):LongWord;
Note | None documented |
---|
function BCM2709SPI0Stop(SPI:PSPIDevice):LongWord;
Note | None documented |
---|
function BCM2709SPI0WriteRead(SPI:PSPIDevice; ChipSelect:Word; Source,Dest:Pointer; Size,Flags:LongWord; var Count:LongWord):LongWord;
Note | None documented |
---|
function BCM2709SPI0SetMode(SPI:PSPIDevice; Mode:LongWord):LongWord;
Note | None documented |
---|
function BCM2709SPI0SetClockRate(SPI:PSPIDevice; ChipSelect:Word; ClockRate:LongWord):LongWord;
Note | None documented |
---|
function BCM2709SPI0SetClockPhase(SPI:PSPIDevice; ClockPhase:LongWord):LongWord;
Note | None documented |
---|
function BCM2709SPI0SetClockPolarity(SPI:PSPIDevice; ClockPolarity:LongWord):LongWord;
Note | None documented |
---|
function BCM2709SPI0SetSelectPolarity(SPI:PSPIDevice; ChipSelect:Word; SelectPolarity:LongWord):LongWord;
Note | None documented |
---|
procedure BCM2709SPI0ReadFIFO(SPI:PBCM2709SPI0Device);
Note | Called ?rom within the interrupt handler |
---|
procedure BCM2709SPI0WriteFIFO(SPI:PBCM2709SPI0Device);
Note | Called ?rom within the interrupt handler |
---|
procedure BCM2709SPI0InterruptHandler(SPI:PBCM2709SPI0Device);
Note | None documented |
---|
procedure BCM2709SPI0DMARequestCompleted(Request:PDMARequest);
Note | None documented |
---|
BCM2709 BSCI2C (I2C0/1) functions
function BCM2709BSCI2CStart(I2C:PI2CDevice;Rate:LongWord):LongWord;
Note | None documented |
---|
function BCM2709BSCI2CStop(I2C:PI2CDevice):LongWord;
Note | None documented |
---|
function BCM2709BSCI2CRead(I2C:PI2CDevice; Address:Word; Buffer:Pointer; Size:LongWord; var Count:LongWord):LongWord;
Note | None documented |
---|
function BCM2709BSCI2CWrite(I2C:PI2CDevice; Address:Word; Buffer:Pointer; Size:LongWord; var Count:LongWord):LongWord;
Note | None documented |
---|
function BCM2709BSCI2CWriteRead(I2C:PI2CDevice; Address:Word; Initial:Pointer; Len:LongWord; Data:Pointer; Size:LongWord; var Count:LongWord):LongWord;
Note | None documented |
---|
function BCM2709BSCI2CWriteWrite(I2C:PI2CDevice; Address:Word; Initial:Pointer; Len:LongWord; Data:Pointer; Size:LongWord; var Count:LongWord):LongWord;
Note | None documented |
---|
function BCM2709BSCI2CSetRate(I2C:PI2CDevice; Rate:LongWord):LongWord;
Note | None documented |
---|
function BCM2709BSCI2CSetAddress(I2C:PI2CDevice; Address:Word):LongWord;
Note | None documented |
---|
procedure BCM2709BSCI2CFillFIFO(I2C:PBCM2709BSCI2CDevice);
Note | Called ?rom within the interrupt handler |
---|
procedure BCM2709BSCI2CDrainFIFO(I2C:PBCM2709BSCI2CDevice);
Note | Called ?rom within the interrupt handler |
---|
procedure BCM2709BSCI2CInterruptHandler(IRQData:PBCM2709BSCI2CIRQData);
Note | Thread submitting the current request will hold the I2C device lock |
---|
BCM2709 DMA functions
function BCM2709DMAHostStart(DMA:PDMAHost):LongWord;
Note | None documented |
---|
function BCM2709DMAHostStop(DMA:PDMAHost):LongWord;
Note | None documented |
---|
function BCM2709DMAHostSubmit(DMA:PDMAHost; Request:PDMARequest):LongWord;
Note | None documented |
---|
function BCM2709DMAHostCancel(DMA:PDMAHost; Request:PDMARequest):LongWord;
Note | None documented |
---|
procedure BCM2709DMAInterruptHandler(Channel:PBCM2709DMAChannel);
Note | None documented |
---|
procedure BCM2709DMASharedInterruptHandler(DMA:PBCM2709DMAHost);
Note | None documented |
---|
procedure BCM2709DMARequestComplete(Channel:PBCM2709DMAChannel);
Note | None documented |
---|
function BCM2709DMAPeripheralToDREQ(Peripheral:LongWord):LongWord;
Note | None documented |
---|
procedure BCM2709DMADataToControlBlock(Request:PDMARequest; Data:PDMAData; Block:PBCM2836DMAControlBlock; Bulk,Lite:Boolean);
Note | None documented |
---|
BCM2709 PWM0/1 functions
function BCM2709PWMStart(PWM:PPWMDevice):LongWord;
Note | None documented |
---|
function BCM2709PWMStop(PWM:PPWMDevice):LongWord;
Note | None documented |
---|
function BCM2709PWMWrite(PWM:PPWMDevice; Value:LongWord):LongWord;
Note | None documented |
---|
function BCM2709PWMSetGPIO(PWM:PPWMDevice; GPIO:LongWord):LongWord;
Note | None documented |
---|
function BCM2709PWMResetGPIO(PWM:PPWMDevice; GPIO:LongWord):LongWord;
Note | None documented |
---|
function BCM2709PWMSetMode(PWM:PPWMDevice; Mode:LongWord):LongWord;
Note | None documented |
---|
function BCM2709PWMSetRange(PWM:PPWMDevice; Range:LongWord):LongWord;
Note | None documented |
---|
function BCM2709PWMSetFrequency(PWM:PPWMDevice; Frequency:LongWord):LongWord;
Note | None documented |
---|
function BCM2709PWMSetPolarity(PWM:PPWMDevice; Polarity:LongWord):LongWord;
Note | None documented |
---|
function BCM2709PWMConfigure(PWM:PPWMDevice; DutyNS,PeriodNS:LongWord):LongWord;
Note | None documented |
---|
function BCM2709PWMClockStart(PWM:PPWMDevice; Frequency:LongWord):LongWord;
Note | None documented |
---|
function BCM2709PWMClockStop(PWM:PPWMDevice):LongWord;
Note | None documented |
---|
function BCM2709PWMClockEnabled(PWM:PPWMDevice):Boolean;
Note | None documented |
---|
BCM2709 GPIO functions
function BCM2709GPIOStart(GPIO:PGPIODevice):LongWord;
Note | None documented |
---|
function BCM2709GPIOStop(GPIO:PGPIODevice):LongWord;
Note | None documented |
---|
function BCM2709GPIORead(GPIO:PGPIODevice; Reg:LongWord):LongWord;
Note | None documented |
---|
procedure BCM2709GPIOWrite(GPIO:PGPIODevice; Reg,Value:LongWord);
Note | None documented |
---|
function BCM2709GPIOInputGet(GPIO:PGPIODevice; Pin:LongWord):LongWord;
Note | None documented |
---|
function BCM2709GPIOInputWait(GPIO:PGPIODevice; Pin,Trigger,Timeout:LongWord):LongWord;
Note | None documented |
---|
function BCM2709GPIOInputEvent(GPIO:PGPIODevice; Pin,Trigger,Flags,Timeout:LongWord; Callback:TGPIOCallback; Data:Pointer):LongWord;
Note | None documented |
---|
function BCM2709GPIOInputCancel(GPIO:PGPIODevice; Pin:LongWord):LongWord;
Note | None documented |
---|
function BCM2709GPIOOutputSet(GPIO:PGPIODevice; Pin,Level:LongWord):LongWord;
Note | None documented |
---|
function BCM2709GPIOPullSelect(GPIO:PGPIODevice; Pin,Mode:LongWord):LongWord;
Note | None documented |
---|
function BCM2709GPIOFunctionGet(GPIO:PGPIODevice; Pin:LongWord):LongWord;
Note | None documented |
---|
function BCM2709GPIOFunctionSelect(GPIO:PGPIODevice; Pin,Mode:LongWord):LongWord;
Note | None documented |
---|
procedure BCM2709GPIOInterruptHandler(Bank:PBCM2709GPIOBank);
Note | None documented |
---|
procedure BCM2709GPIOEventTrigger(Pin:PGPIOPin);
Note | None documented |
---|
procedure BCM2709GPIOEventTimeout(Event:PGPIOEvent);
Note | None documented |
---|
BCM2709 UART0 functions
function BCM2709UART0Open(UART:PUARTDevice; BaudRate,DataBits,StopBits,Parity,FlowControl:LongWord):LongWord;
Note | None documented |
---|
function BCM2709UART0Close(UART:PUARTDevice):LongWord;
Note | None documented |
---|
function BCM2709UART0Read(UART:PUARTDevice; Buffer:Pointer; Size,Flags:LongWord; var Count:LongWord):LongWord;
Note | None documented |
---|
function BCM2709UART0Write(UART:PUARTDevice; Buffer:Pointer; Size,Flags:LongWord; var Count:LongWord):LongWord;
Note | None documented |
---|
function BCM2709UART0Status(UART:PUARTDevice):LongWord;
Note | None documented |
---|
procedure BCM2709UART0InterruptHandler(UART:PUARTDevice);
Note | None documented |
---|
procedure BCM2709UART0Receive(UART:PUARTDevice);
Note | None documented |
---|
procedure BCM2709UART0Transmit(UART:PUARTDevice);
Note | None documented |
---|
BCM2709 SDHCI functions
function BCM2709SDHCIHostStart(SDHCI:PSDHCIHost):LongWord;
Note | None documented |
---|
function BCM2709SDHCIHostStop(SDHCI:PSDHCIHost):LongWord;
Note | None documented |
---|
function BCM2709SDHCIHostReadByte(SDHCI:PSDHCIHost; Reg:LongWord):Byte;
Note | The Broadcom document BCM2835-ARM-Peripherals page 66 states the following: Contrary to Arasans documentation the EMMC module registers can only be accessed as 32 bit registers, i.e. the two LSBs of the address are always zero. For this reason this code must simulate Byte and Word reads using LongWord reads. |
---|
function BCM2709SDHCIHostReadWord(SDHCI:PSDHCIHost; Reg:LongWord):Word;
Note | The Broadcom document BCM2835-ARM-Peripherals page 66 states the following: Contrary to Arasans documentation the EMMC module registers can only be accessed as 32 bit registers, i.e. the two LSBs of the address are always zero. For this reason this code must simulate Byte and Word reads using LongWord reads. |
---|
function BCM2709SDHCIHostReadLong(SDHCI:PSDHCIHost; Reg:LongWord):LongWord;
Note | None documented |
---|
procedure BCM2709SDHCIHostWriteByte(SDHCI:PSDHCIHost; Reg:LongWord; Value:Byte);
Note | The Broadcom document BCM2835-ARM-Peripherals page 66 states the following: Contrary to Arasans documentation the EMMC module registers can only be accessed as 32 bit registers, i.e. the two LSBs of the address are always zero. For this reason this code must simulate Byte and Word writes using LongWord writes. |
---|
procedure BCM2709SDHCIHostWriteWord(SDHCI:PSDHCIHost; Reg:LongWord; Value:Word);
Note | The Broadcom document BCM2835-ARM-Peripherals page 66 states the following: Contrary to Arasans documentation the EMMC module registers can only be accessed as 32 bit registers, i.e. the two LSBs of the address are always zero. For this reason this code must simulate Byte and Word writes using LongWord writes. |
---|
procedure BCM2709SDHCIHostWriteLong(SDHCI:PSDHCIHost; Reg:LongWord; Value:LongWord);
Note | The source code of U-Boot and Linux kernel drivers have this comment The Arasan has a bugette whereby it may lose the content of successive writes to registers that are within two SD-card clock cycles of each other (a clock domain crossing problem). It seems, however, that the data register does not have this problem. (Which is just as well - otherwise we'd have to nobble the DMA engine too) For this reason this code must delay after each write to the registers. |
---|
procedure BCM2709SDHCIInterruptHandler(SDHCI:PSDHCIHost);
Note | None documented |
---|
function BCM2709SDHCISetupInterrupts(SDHCI:PSDHCIHost):LongWord;
Note | None documented |
---|
function BCM2709MMCDeviceGetCardDetect(MMC:PMMCDevice):LongWord;
Note | None documented |
---|
BCM2709 clock functions
function BCM2709ClockRead(Clock:PClockDevice):LongWord;
Note | None documented |
---|
function BCM2709ClockRead64(Clock:PClockDevice):Int64;
Note | None documented |
---|
BCM2709 ARM timer functions
function BCM2709ARMTimerStart(Timer:PTimerDevice):LongWord;
Note | Not intended to be called directly by applications, use TimerDeviceStart instead |
---|
function BCM2709ARMTimerStop(Timer:PTimerDevice):LongWord;
Note | Not intended to be called directly by applications, use TimerDeviceStop instead |
---|
function BCM2709ARMTimerRead64(Timer:PTimerDevice):Int64;
Note | Not intended to be called directly by applications, use TimerDeviceRead64 instead |
---|
function BCM2709ARMTimerWait(Timer:PTimerDevice):LongWord;
Note | Not intended to be called directly by applications, use TimerDeviceWait instead |
---|
function BCM2709ARMTimerEvent(Timer:PTimerDevice; Flags:LongWord; Callback:TTimerCallback; Data:Pointer):LongWord;
Note | Not intended to be called directly by applications, use TimerDeviceEvent instead |
---|
function BCM2709ARMTimerCancel(Timer:PTimerDevice):LongWord;
Note | Not intended to be called directly by applications, use TimerDeviceCancel instead |
---|
function BCM2709ARMTimer?etRate(Timer:PTimerDevice; Rate:LongWord):LongWord;
Note | Not intended to be called directly by applications, use TimerDevice?etRate instead |
---|
function BCM2709ARMTimer?etInterval(Timer:PTimerDevice; Interval:LongWord):LongWord;
Note | Not intended to be called directly by applications, use TimerDevice?etInterval instead |
---|
procedure BCM2709ARMTimerInterruptHandler(Timer:PTimerDevice);
Note | Not intended to be called directly by applications |
---|
procedure BCM2709ARMTimerEventTrigger(Timer:PTimerDevice);
Note | Not intended to be called directly by applications |
---|
BCM2709 random functions
function BCM2709RandomStart(Random:PRandomDevice):LongWord;
Note | None documented |
---|
function BCM2709RandomStop(Random:PRandomDevice):LongWord;
Note | None documented |
---|
function BCM2709RandomReadLongWord(Random:PRandomDevice):LongWord;
Note | None documented |
---|
Return to Unit Reference