Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port Zephyr RPI5 patches to zephyr-v3.6.0-xt #111

Merged
merged 30 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
5cc36a3
drivers: gpio: add brcmstb gpio driver
Lahyllas Mar 21, 2024
7d1490b
soc: brcm: add support for BCM2712
Lahyllas Mar 21, 2024
e3c0c39
board: raspberrypi: add support for Raspberry Pi 5
Lahyllas Mar 21, 2024
42d5a07
board: raspberrypi: enable serial communication on Raspberry Pi 5
mypark42 Mar 27, 2024
9f188ae
soc: bcm2712: backport to old hwm
Apr 13, 2024
429b54d
boards: raspberrypi: rpi_5: backport to old hwm
Apr 13, 2024
076ef39
snippets: add rpi_5_xen_domd to demo hw passing to xen domain
Apr 24, 2024
5b3b830
boards: arm64: rpi_5: add xen specific doc
Apr 15, 2024
53d8557
tests: drivers: sdhc: setup SDHC IO before test
danieldegrasse May 10, 2024
7c4da01
dts: arm64: bcm2712: pl011 add interrupt-names
May 20, 2024
1d9a179
dts: bindings: add bcm2712 sdhc
May 20, 2024
be63a28
dts: arm64: broadcom: bcm2712: add sdio1 sdhc node
May 20, 2024
b9018fb
boards: arm64: rpi_5: dts: increase ram size
May 24, 2024
7708fdb
dts: boards: arm64: rpi_5: add basic sd-card support
May 20, 2024
399ae45
drivers: sdhc: add bcm2712 sdhci driver
May 20, 2024
4be9afc
samples: subsys: fs: fs_sample: enable for rpi_5
May 20, 2024
f14ff31
fs/fatfs: Add CONFIG_FS_FATFS_LBA64
May 31, 2024
6bf5d92
fs/fatfs: Add CONFIG_FS_MULTI_PARTITION
Jun 1, 2024
2df8d85
drivers: sdhc: sdhci_common: fix sd write
Jun 18, 2024
586adbb
drivers: sdhc: brcm_bcm2712: drop unused io chunks
Jun 7, 2024
086638f
drivers: sdhc: brcm_bcm2712: drop unused mmc props
Jun 7, 2024
2c417e9
drivers: sdhc: sdhci_common: use config option for stop cmd tmo
Jun 7, 2024
e3c3bb6
drivers: sdhc: sdhci_common: use SDHCI_RESPONSE1/2/3 in sdhci_cmd_done()
Jun 7, 2024
4a3accf
drivers: sdhc: sdhci_common: break polling if err
Jun 7, 2024
e7ec100
drivers: sdhc: sdhci_common: add adma2 support
Jun 21, 2024
93e9009
drivers: sdhc: brcm_bcm2712: enable adma2
Jun 21, 2024
5cb9693
soc: arm64: bcm2712: increase irq number
Jul 1, 2024
23d527c
drivers: sdhc: sdhci_common: add irq support
Jul 1, 2024
bcfc843
drivers: sdhc: brcm_bcm2712: enable irq support
Jul 1, 2024
b06582f
drivers: sdhc: brcm_bcm2712: add sdhc_command retry
Jul 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions boards/arm64/rpi_5/Kconfig.board
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copyright 2024 Junho Lee <[email protected]>
# SPDX-License-Identifier: Apache-2.0

config BOARD_RPI_5
bool "Broadcom BCM2712"
depends on SOC_BCM2712
6 changes: 6 additions & 0 deletions boards/arm64/rpi_5/Kconfig.defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copyright 2023 honglin leng <[email protected]>
# SPDX-License-Identifier: Apache-2.0

config BOARD
default "Raspberry Pi 5"
depends on BOARD_RPI_5
1 change: 1 addition & 0 deletions boards/arm64/rpi_5/board.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# SPDX-License-Identifier: Apache-2.0
5 changes: 5 additions & 0 deletions boards/arm64/rpi_5/board.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
board:
name: rpi_5
vendor: raspberrypi
socs:
- name: bcm2712
193 changes: 193 additions & 0 deletions boards/arm64/rpi_5/doc/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
.. rpi_5:

Raspberry Pi 5 (Cortex-A76)
###########################

Overview
********

`Raspberry Pi 5 product-brief`_

Hardware
********

- Broadcom BCM2712 2.4GHz quad-core 64-bit Arm Cortex-A76 CPU, with cryptography extensions, 512KB per-core L2 caches and a 2MB shared L3 cache
- VideoCore VII GPU, supporting OpenGL ES 3.1, Vulkan 1.2
- Dual 4Kp60 HDMI® display output with HDR support
- 4Kp60 HEVC decoder
- LPDDR4X-4267 SDRAM (4GB and 8GB SKUs available at launch)
- Dual-band 802.11ac Wi-Fi®
- Bluetooth 5.0 / Bluetooth Low Energy (BLE)
- microSD card slot, with support for high-speed SDR104 mode
- 2 x USB 3.0 ports, supporting simultaneous 5Gbps operation
- 2 x USB 2.0 ports
- Gigabit Ethernet, with PoE+ support (requires separate PoE+ HAT)
- 2 x 4-lane MIPI camera/display transceivers
- PCIe 2.0 x1 interface for fast peripherals (requires separate M.2 HAT or other adapter)
- 5V/5A DC power via USB-C, with Power Delivery support
- Raspberry Pi standard 40-pin header
- Real-time clock (RTC), powered from external battery
- Power button

Supported Features
==================

The Raspberry Pi 5 board configuration supports the following hardware features:

.. list-table::
:header-rows: 1

* - Peripheral
- Kconfig option
- Devicetree compatible
* - GIC-400
- N/A
- :dtcompatible:`arm,gic-v2`
* - GPIO
- :kconfig:option:`CONFIG_GPIO`
- :dtcompatible:`brcm,brcmstb-gpio`
* - UART
- :kconfig:option:`CONFIG_SERIAL`
- :dtcompatible:`arm,pl011`

Not all hardware features are supported yet. See `Raspberry Pi hardware`_ for the complete list of hardware features.

The default configuration can be found in
:zephyr_file:`boards/raspberrypi/rpi_5/rpi_5_defconfig`.

Programming and Debugging
*************************

Blinky
======

In brief,
1. Format your Micro SD card with MBR and FAT32.
2. Save three files below in the root directory.
* config.txt
* zephyr.bin
* `bcm2712-rpi-5.dtb`_
3. Insert the Micro SD card and power on the Raspberry Pi 5.

then, You will see the Raspberry Pi 5 running the `zephyr.bin`.

config.txt
----------

.. code-block:: text

kernel=zephyr.bin
arm_64bit=1


zephyr.bin
----------

Build an app `samples/basic/blinky`

.. zephyr-app-commands::
:zephyr-app: samples/basic/blinky
:board: rpi_5
:goals: build

Copy `zephyr.bin` from `build/zephyr` directory to the root directory of the Micro SD card.

Insert the Micro SD card and power on the Raspberry Pi 5. And then, the STAT LED will start to blink.


Serial Communication
====================

wiring
------

You will need the following items:
* `Raspberry Pi Debug Probe`_
* JST cable: 3-pin JST connector to 3-pin JST connector cable
* USB cable: USB A male - Micro USB B male

Use the JST cable to connect the Raspberry Pi Debug Probe UART port to the Raspberry Pi 5 UART port between the HDMI ports.

Then connect the Raspberry Pi Debug Probe to your computer with a USB cable.


config.txt
----------

.. code-block:: text

kernel=zephyr.bin
arm_64bit=1
enable_uart=1
uart_2ndstage=1


zephyr.bin
----------

Build an app `samples/hello_world`

.. zephyr-app-commands::
:zephyr-app: samples/hello_world
:board: rpi_5
:goals: build

Copy `zephyr.bin` from `build/zephyr` directory to the root directory of the Micro SD card.

Insert the Micro SD card into your Raspberry Pi 5.


serial terminal emulator
------------------------

When you power on the Raspberry Pi 5, you will see the following output in the serial console:

.. code-block:: text

*** Booting Zephyr OS build XXXXXXXXXXXX ***
Hello World! rpi_5/bcm2712


.. _Raspberry Pi 5 product-brief:
https://datasheets.raspberrypi.com/rpi5/raspberry-pi-5-product-brief.pdf

.. _Raspberry Pi hardware:
https://www.raspberrypi.com/documentation/computers/raspberry-pi.html

.. _bcm2712-rpi-5.dtb:
https://github.com/raspberrypi/firmware/raw/master/boot/bcm2712-rpi-5-b.dtb

.. _Raspberry Pi Debug Probe:
https://www.raspberrypi.com/products/debug-probe/

XEN Dom0
========

The Raspberry Pi 5 platform can be used to run as Xen Zephyr Dom0. For such purposes the `xen_dom0`
snippet can be used.

Run below command as an example of RPI 5 Zephyr build as Dom0:

.. code-block:: bash

west build -b rpi_5 -p always -S xen_dom0 samples/hello_world

It is expected to be used with special application performing Xen Domain-0/Dom0 functions.

.. note::

The "hypervisor@x" and "memory@x" DT nodes may need to be updated depending on the Xen boot,
because normaly Xan will update DT for the target Kernel, but this is not possible in case
of Zephyr. See comments in `rpi_5_xen_dom0.dts`.

XEN DomD with HW passthrough
============================

The Raspberry Pi 5 platform can be used to run as Xen Zephyr DomD with RPI 5 HW support.
For such purposes the `rpi_5_xen_domd` snippet can be used.

Run the command below as an example of RPI 5 Zephyr build as DomD:

.. code-block:: bash

west build -b xenvm -S rpi_5_xen_domd samples/basic/blinky
89 changes: 89 additions & 0 deletions boards/arm64/rpi_5/rpi_5.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* Copyright 2024 Junho Lee <[email protected]>
* Copyright (c) 2024 EPAM Systems
*
* SPDX-License-Identifier: Apache-2.0
*/

/dts-v1/;

#include <broadcom/bcm2712.dtsi>
#include <zephyr/dt-bindings/gpio/gpio.h>

/ {
compatible = "raspberrypi,5-model-b", "brcm,bcm2712";
model = "Raspberry Pi 5";
#address-cells = <2>;
#size-cells = <1>;

aliases {
led0 = &led_act;
sdhc0 = &sdio1;
};

chosen {
zephyr,sram = &sram0;
zephyr,console = &uart10;
zephyr,shell-uart = &uart10;
};

leds {
compatible = "gpio-leds";

led_act: led-act {
gpios = <&gio_aon 9 GPIO_ACTIVE_LOW>;
label = "ACT";
};
};

sd_io_1v8_reg: sd_io_1v8_reg {
compatible = "regulator-gpio";
regulator-name = "vdd-sd-io";
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <3300000>;
regulator-boot-on;
regulator-always-on;
gpios = <&gio_aon 3 GPIO_ACTIVE_HIGH>;
states = <1800000 0x1
3300000 0x0>;
status = "okay";
};

sd_vcc_reg: sd_vcc_reg {
compatible = "regulator-fixed";
regulator-name = "vcc-sd";
regulator-boot-on;
enable-gpios = <&gio_aon 4 GPIO_ACTIVE_HIGH>;
status = "okay";
};
};

/* samples required more memory and RPI5 has it, set it to 4M */
&sram0 {
reg = <0x0 0x200000 0x400000>;
};

&gio_aon {
status = "okay";
};

&uart10 {
status = "okay";
current-speed = <115200>;
};

/* SDIO1 is used to drive removable the SD card */
&sdio1 {
vqmmc-supply = <&sd_io_1v8_reg>;
vmmc-supply = <&sd_vcc_reg>;
bus-width = <4>;
cd-gpios = <&gio_aon 5 GPIO_ACTIVE_LOW>;
/* request freq from hw */
max-bus-freq = <0>;
status = "okay";

disk {
compatible = "zephyr,sdmmc-disk";
status = "okay";
};
};
7 changes: 7 additions & 0 deletions boards/arm64/rpi_5/rpi_5.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
identifier: rpi_5
name: Raspberry Pi 5
type: mcu
arch: arm64
toolchain:
- zephyr
- cross-compile
12 changes: 12 additions & 0 deletions boards/arm64/rpi_5/rpi_5_defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# SPDX-License-Identifier: Apache-2.0

CONFIG_SOC_BCM2712=y
CONFIG_BOARD_RPI_5=y
CONFIG_ARM64_VA_BITS_40=y
CONFIG_ARM64_PA_BITS_40=y
CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y

# Enable serial console.
CONFIG_SERIAL=y
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y
1 change: 1 addition & 0 deletions drivers/gpio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ zephyr_library_sources_ifdef(CONFIG_GPIO_BCM2711 gpio_bcm2711.c)
zephyr_library_sources_ifdef(CONFIG_GPIO_RENESAS_RA gpio_renesas_ra.c)
zephyr_library_sources_ifdef(CONFIG_GPIO_RZT2M gpio_rzt2m.c)
zephyr_library_sources_ifdef(CONFIG_GPIO_AMBIQ gpio_ambiq.c)
zephyr_library_sources_ifdef(CONFIG_GPIO_BRCMSTB gpio_brcmstb.c)

if (CONFIG_GPIO_EMUL_SDL)
zephyr_library_sources(gpio_emul_sdl.c)
Expand Down
2 changes: 2 additions & 0 deletions drivers/gpio/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -240,4 +240,6 @@ source "drivers/gpio/Kconfig.rzt2m"

source "drivers/gpio/Kconfig.ambiq"

source "drivers/gpio/Kconfig.brcmstb"

endif # GPIO
9 changes: 9 additions & 0 deletions drivers/gpio/Kconfig.brcmstb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) 2024 Junho Lee <[email protected]>
# SPDX-License-Identifier: Apache-2.0

config GPIO_BRCMSTB
bool "Broadcom Set-top box SoC GPIO Driver"
default y
depends on DT_HAS_BRCM_BRCMSTB_GPIO_ENABLED
help
Enable Driver for Broadcom Set-top box SoC GPIO Banks.
Loading