Unit BCM2711

From Ultibo.org
Revision as of 03:44, 19 June 2021 by Ultibo (Talk | contribs)

Jump to: navigation, search

Return to Unit Reference


Description


Ultibo BCM2711 interface unit

This unit provides the BCM2711 specific implementations of the following devices:

  • SPI0
  • SPI1
  • SPI2
  • SPI3
  • SPI4
  • SPI5
  • SPI6
  • I2C0
  • I2C1
  • I2C3
  • I2C4
  • I2C5
  • I2C6
  • I2C Slave
  • SPI Slave
  • DMA
  • PWM0
  • PWM1
  • PCM
  • GPIO
  • UART0
  • UART1
  • UART2
  • UART3
  • UART4
  • UART5
  • EMMC0
  • EMMC1
  • EMMC2
  • Clock (System Timer)
  • Clock (ARM Timer)
  • Clock (Local Timer)
  • ARM Timer
  • Local Timer
  • Random
  • Mailbox
  • Watchdog
  • Framebuffer

BCM2711 SPI0/3/4/5/6 Device

The BCM2711 has 5 master mode SPI controllers that support 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/3/4/5/6 controllers support polled, interrupt and DMA modes and include 3 chip selects although only CS0 and CS1 are available on the 40 pin header.

The GPIO pins and functions for each device are shown below, not all of these combinations are accessible via the 40 pin header.

         Device     Line      Pin          Function             Notes
          SPI0      CS1       GPIO_PIN_7   GPIO_FUNCTION_ALT0  
                    CS0       GPIO_PIN_8   GPIO_FUNCTION_ALT0  
                    MISO      GPIO_PIN_9   GPIO_FUNCTION_ALT0
                    MOSI      GPIO_PIN_10  GPIO_FUNCTION_ALT0
                    SCLK      GPIO_PIN_11  GPIO_FUNCTION_ALT0
                                  
                    CS1       GPIO_PIN_35  GPIO_FUNCTION_ALT0   CM4 only
                    CS0       GPIO_PIN_36  GPIO_FUNCTION_ALT0
                    MISO      GPIO_PIN_37  GPIO_FUNCTION_ALT0
                    MOSI      GPIO_PIN_38  GPIO_FUNCTION_ALT0
                    SCLK      GPIO_PIN_39  GPIO_FUNCTION_ALT0
                                  
          SPI3      CS1       GPIO_PIN_24  GPIO_FUNCTION_ALT5
                    CS0       GPIO_PIN_0   GPIO_FUNCTION_ALT3
                    MISO      GPIO_PIN_1   GPIO_FUNCTION_ALT3
                    MOSI      GPIO_PIN_2   GPIO_FUNCTION_ALT3
                    SCLK      GPIO_PIN_3   GPIO_FUNCTION_ALT3
                                  
          SPI4      CS1       GPIO_PIN_25  GPIO_FUNCTION_ALT5
                    CS0       GPIO_PIN_4   GPIO_FUNCTION_ALT3
                    MISO      GPIO_PIN_5   GPIO_FUNCTION_ALT3
                    MOSI      GPIO_PIN_6   GPIO_FUNCTION_ALT3
                    SCLK      GPIO_PIN_7   GPIO_FUNCTION_ALT3
                                  
          SPI5      CS1       GPIO_PIN_26  GPIO_FUNCTION_ALT5
                    CS0       GPIO_PIN_12  GPIO_FUNCTION_ALT3
                    MISO      GPIO_PIN_13  GPIO_FUNCTION_ALT3
                    MOSI      GPIO_PIN_14  GPIO_FUNCTION_ALT3
                    SCLK      GPIO_PIN_15  GPIO_FUNCTION_ALT3
                                  
          SPI6      CS1       GPIO_PIN_27  GPIO_FUNCTION_ALT5
                    CS0       GPIO_PIN_18  GPIO_FUNCTION_ALT3
                    MISO      GPIO_PIN_19  GPIO_FUNCTION_ALT3
                    MOSI      GPIO_PIN_20  GPIO_FUNCTION_ALT3
                    SCLK      GPIO_PIN_21  GPIO_FUNCTION_ALT3

BCM2711 I2C0/1/3/4/5/6 Device

The BCM2711 has 8 Broadcom Serial Controller (BSC) devices which are fast mode (400Kz) I2C masters numbered BSC0 to BSC7 (I2C0 to I2C7).

Devices BSC2 and BSC7 is dedicated to the HDMI interfaces and are not available 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.

The GPIO pins and functions for each device are shown below, not all of these combinations are accessible via the 40 pin header.

          Device     Line      Pin          Function             Notes
          I2C0       SDA0      GPIO_PIN_0   GPIO_FUNCTION_ALT0
                     SCL0      GPIO_PIN_1   GPIO_FUNCTION_ALT0
                     
                     SDA0      GPIO_PIN_28  GPIO_FUNCTION_ALT0
                     SCL0      GPIO_PIN_29  GPIO_FUNCTION_ALT0
                     
                     SDA0      GPIO_PIN_44  GPIO_FUNCTION_ALT1
                     SCL0      GPIO_PIN_45  GPIO_FUNCTION_ALT1
                     
          I2C1       SDA1      GPIO_PIN_2   GPIO_FUNCTION_ALT0
                     SCL1      GPIO_PIN_3   GPIO_FUNCTION_ALT0
                    
                     SDA1      GPIO_PIN_44  GPIO_FUNCTION_ALT2
                     SCL1      GPIO_PIN_45  GPIO_FUNCTION_ALT2
           
          I2C2       SDA2                                       Not Available
                     SCL2                                       Not Available
           
          I2C3       SDA3      GPIO_PIN_2   GPIO_FUNCTION_ALT5
                     SCL3      GPIO_PIN_3   GPIO_FUNCTION_ALT5
                                  
                     SDA3      GPIO_PIN_4   GPIO_FUNCTION_ALT5
                     SCL3      GPIO_PIN_5   GPIO_FUNCTION_ALT5
                                  
          I2C4       SDA4      GPIO_PIN_6   GPIO_FUNCTION_ALT5
                     SCL4      GPIO_PIN_7   GPIO_FUNCTION_ALT5
                                  
                     SDA4      GPIO_PIN_8   GPIO_FUNCTION_ALT5
                     SCL4      GPIO_PIN_9   GPIO_FUNCTION_ALT5
                     
          I2C5       SDA5      GPIO_PIN_10  GPIO_FUNCTION_ALT5
                     SCL5      GPIO_PIN_11  GPIO_FUNCTION_ALT5
                     
                     SDA5      GPIO_PIN_12  GPIO_FUNCTION_ALT5
                     SCL5      GPIO_PIN_13  GPIO_FUNCTION_ALT5
                     
          I2C6       SDA6      GPIO_PIN_0   GPIO_FUNCTION_ALT5
                     SCL6      GPIO_PIN_1   GPIO_FUNCTION_ALT5
                     
                     SDA6      GPIO_PIN_22  GPIO_FUNCTION_ALT5
                     SCL6      GPIO_PIN_23  GPIO_FUNCTION_ALT5
           
          I2C7       SDA7                                       Not Available
                     SCL7                                       Not Available

Note: On the Raspberry Pi 4B the ID EEPROM pins on the 40 pin header are actually connected to GPIO 0 and 1 (I2C0).

BCM2711 SPI1/2 Device

The SPI1/2 devices are part of the AUX device which also includes the UART1 device.

They are master SPI devices which are considered secondary low throughput interfaces as they have small FIFOs and no DMA support.

The GPIO pins and functions for each device are shown below, not all of these combinations are accessible via the 40 pin header.

          Device     Line      Pin          Function             Notes
          SPI1       CS2       GPIO_PIN_16  GPIO_FUNCTION_ALT4  
                     CS1       GPIO_PIN_17  GPIO_FUNCTION_ALT4  
                     CS0       GPIO_PIN_18  GPIO_FUNCTION_ALT4  
                     MISO      GPIO_PIN_19  GPIO_FUNCTION_ALT4
                     MOSI      GPIO_PIN_20  GPIO_FUNCTION_ALT4
                     SCLK      GPIO_PIN_21  GPIO_FUNCTION_ALT4

          SPI2       CS2       GPIO_PIN_45  GPIO_FUNCTION_ALT4   CM4 only
                     CS1       GPIO_PIN_44  GPIO_FUNCTION_ALT4
                     CS0       GPIO_PIN_43  GPIO_FUNCTION_ALT4
                     MISO      GPIO_PIN_40  GPIO_FUNCTION_ALT4
                     MOSI      GPIO_PIN_41  GPIO_FUNCTION_ALT4
                     SCLK      GPIO_PIN_42  GPIO_FUNCTION_ALT4

Note: The GPIO function assignments section of the BCM2711 ARM Peripherals document incorrectly lists SPI2 as SPI0.

BCM2711 SPI/I2C Slave Device

The slave device can be used as either an I2C or an SPI interface, the I2C slave supports 400KHz fast mode operation. Only 7 bit addressing is supported, DMA is not supported and neither is clock stretching.

Unlike earlier models where the SPI slave device was apparently faulty on the Raspberry Pi 4 is reported to work.

The GPIO pins and functions for each device are shown below, not all of these combinations are accessible via the 40 pin header.

          Device     Line      Pin          Function             Notes
          SPI Slave  CS        GPIO_PIN_8   GPIO_FUNCTION_ALT3
                     MISO      GPIO_PIN_9   GPIO_FUNCTION_ALT3
                     MOSI      GPIO_PIN_10  GPIO_FUNCTION_ALT3
                     SCLK      GPIO_PIN_11  GPIO_FUNCTION_ALT3
          I2C Slave  SDA       GPIO_PIN_10  GPIO_FUNCTION_ALT3
                     SCL       GPIO_PIN_11  GPIO_FUNCTION_ALT3

Note: The BCM2711 ARM Peripherals document does not include documentation for the I2C/SPI slave.

BCM2711 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 10 are Lite channels which do not support stride and only allow transfers up to 64KB per control block.

Channels 11 to 14 are 40 bit channels which allow access to memory and peripherals beyond the 1GB boundary and have higher performance because they directly access the full 35 bit address map and can perform write bursts (DMA channel 11 is used to access the PCIe interface).

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).

BCM2711 PWM0/1 Device

The BCM2711 has two PWM controllers with 2 independent output bit streams with multiple algorithms for generating the output pulse. The PWM controllers support either a single data register (independent per channel) or a 16 x 32 FIFO which also supports DMA mode transmission.

On the Raspberry Pi 4B PWM1_0 and PWM1_1 are also connected via GPIO pins 40 and 41 to the audio circuit and allow playback of digital audio signals via the 4 pole line jack.

The GPIO pins and functions for each device are shown below, not all of these combinations are accessible via the 40 pin header.

          Device     Line      Pin          Function             Notes
          PWM0       PWM0_0    GPIO_PIN_12  GPIO_FUNCTION_ALT0 
                     PWM0_1    GPIO_PIN_13  GPIO_FUNCTION_ALT0 
                     PWM0_0    GPIO_PIN_18  GPIO_FUNCTION_ALT5 
                     PWM0_1    GPIO_PIN_19  GPIO_FUNCTION_ALT5 
           
                     PWM0_1    GPIO_PIN_45  GPIO_FUNCTION_ALT0

          PWM1       PWM1_0    GPIO_PIN_40  GPIO_FUNCTION_ALT0 
                     PWM1_1    GPIO_PIN_41  GPIO_FUNCTION_ALT0 

On the Raspberry Pi 4B pins 12, 18 and 19 are exposed on the 40 pin header.

BCM2711 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 40 pin header of the Raspberry Pi, for details of which pins are available see:

Raspberry Pi 4B - https://www.raspberrypi.org/documentation/usage/gpio/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.

BCM2711 UART0/2/3/4/5 Device

The UART0/2/3/4/5 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 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 4B none of these alternate pin mappings are exposed via the 40 pin header and therefore cannot be used easily. This means that UART0 and UART1 cannot be used via the 40 pin header at the same time.

On the Raspberry Pi 4B the UART0 can be mapped to GPIO pins 32 and 33 (Alternate function 3) to communicate with the built in Bluetooth module.

The GPIO pins and functions for each device are shown below, not all of these combinations are accessible via the 40 pin header.

          Device     Line      Pin          Function             Notes
          UART0      TXD       GPIO_PIN_14  GPIO_FUNCTION_ALT0  
                     RXD       GPIO_PIN_15  GPIO_FUNCTION_ALT0  
                     CTS       GPIO_PIN_16  GPIO_FUNCTION_ALT3  
                     RTS       GPIO_PIN_17  GPIO_FUNCTION_ALT3  
                                 
                     TXD       GPIO_PIN_32  GPIO_FUNCTION_ALT3  
                     RXD       GPIO_PIN_33  GPIO_FUNCTION_ALT3  
                     CTS       GPIO_PIN_30  GPIO_FUNCTION_ALT3  
                     RTS       GPIO_PIN_31  GPIO_FUNCTION_ALT3  
                                  
                     TXD       GPIO_PIN_36  GPIO_FUNCTION_ALT2  
                     RXD       GPIO_PIN_37  GPIO_FUNCTION_ALT2  
                     CTS       GPIO_PIN_38  GPIO_FUNCTION_ALT2  
                     RTS       GPIO_PIN_39  GPIO_FUNCTION_ALT2  
                                  
          UART2      TXD       GPIO_PIN_0   GPIO_FUNCTION_ALT4  
                     RXD       GPIO_PIN_1   GPIO_FUNCTION_ALT4  
                     CTS       GPIO_PIN_2   GPIO_FUNCTION_ALT4  
                     RTS       GPIO_PIN_3   GPIO_FUNCTION_ALT4  
                                  
          UART3      TXD       GPIO_PIN_4   GPIO_FUNCTION_ALT4  
                     RXD       GPIO_PIN_5   GPIO_FUNCTION_ALT4  
                     CTS       GPIO_PIN_6   GPIO_FUNCTION_ALT4  
                     RTS       GPIO_PIN_7   GPIO_FUNCTION_ALT4  
                                  
          UART4      TXD       GPIO_PIN_8   GPIO_FUNCTION_ALT4  
                     RXD       GPIO_PIN_9   GPIO_FUNCTION_ALT4  
                     CTS       GPIO_PIN_10  GPIO_FUNCTION_ALT4  
                     RTS       GPIO_PIN_11  GPIO_FUNCTION_ALT4  
                                  
          UART5      TXD       GPIO_PIN_12  GPIO_FUNCTION_ALT4  
                     RXD       GPIO_PIN_13  GPIO_FUNCTION_ALT4  
                     CTS       GPIO_PIN_14  GPIO_FUNCTION_ALT4  
                     RTS       GPIO_PIN_15  GPIO_FUNCTION_ALT4  

BCM2711 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 4B none of these alternate pin mappings are exposed via the 40 pin header and therefore cannot be used easily. This means that UART0 and UART1 cannot be used via the 40 pin header at the same time.

On the Raspberry Pi 4B the UART1 can be mapped to GPIO pins 32 and 33 (Alternate function 5) to communicate with the built in Bluetooth module.

The GPIO pins and functions for the device are shown below, not all of these combinations are accessible via the 40 pin header.

          Device     Line      Pin          Function             Notes
          UART1      TXD       GPIO_PIN_14  GPIO_FUNCTION_ALT5  
                     RXD       GPIO_PIN_15  GPIO_FUNCTION_ALT5  
                     CTS       GPIO_PIN_16  GPIO_FUNCTION_ALT5  
                     RTS       GPIO_PIN_17  GPIO_FUNCTION_ALT5  
           
                     TXD       GPIO_PIN_32  GPIO_FUNCTION_ALT5  
                     RXD       GPIO_PIN_33  GPIO_FUNCTION_ALT5  
                     CTS       GPIO_PIN_30  GPIO_FUNCTION_ALT5  
                     RTS       GPIO_PIN_31  GPIO_FUNCTION_ALT5  

BCM2711 EMMC0 (SDHCI) Device

The SDHCI controller on the BCM2711 is an Arasan SD Host controller.

The Card Detect pin is not connected.

The Write Protect pin is not connected.

The device can be routed to GPIO pins 22 to 27 (ALT3) or 48 to 53 (ALT3), it can also be routed to GPIO pins 34 to 39 (ALT3) to provide an SDIO controller for the on board WiFi.

BCM2711 EMMC1 (SDHOST) Device

The SDHOST controller on the BCM2711 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) however only 22 to 27 are accessible to use.

BCM2711 EMMC2 (SDHCI) Device

The EMMC2 controller on the BCM2711 is an SDHCI-compliant device which does not appear on the GPIO pins and is internally connected to the SD card slot.

The BCM2838_GPPINMUX register allows routing the SDHCI controller (EMMC0) to the SD card slot which then renders the EMMC2 unusable.

BCM2711 Clock (System Timer) Device

The clock device in the BCM2711 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 cannot be stopped and the counter cannot be set or reset.

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.

BCM2711 Clock (ARM Timer) Device

This device represents that free running counter from the ARM Timer device (below) as a clock device. The free running counter does not appear in the original SP804 timer. The counter is 32 bits wide and has its own divider that is 8 bits wide meaning that it can be set to clock rates of between 975KHz and 250MHz (or 1.5MHz to 400MHz on the Raspberry Pi 3B).

The counter does not generate an interrupt and cannot be set or reset but it can be stopped and started.

BCM2711 ARM Timer Device

The ARM Timer device in the BCM2711 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 from a load or reload register to begin counting again.

Constants


To be documented

Type definitions


To be documented

Public variables


None defined

Function declarations


To be documented


Return to Unit Reference