From 770ade10cb154d66faa5ba13004ebcc84c3e888a Mon Sep 17 00:00:00 2001 From: Junho Lee Date: Thu, 21 Mar 2024 13:18:44 +0900 Subject: [PATCH 01/13] drivers: gpio: add brcmstb gpio driver Add GPIO driver for brcmstb, required by Raspberry Pi 5. Signed-off-by: Junho Lee (cherry picked from commit 31baddaa51d5b40e6e6394b8be6cb32e1e962f08) Signed-off-by: Grygorii Strashko --- drivers/gpio/CMakeLists.txt | 1 + drivers/gpio/Kconfig | 2 + drivers/gpio/Kconfig.brcmstb | 9 ++ drivers/gpio/gpio_brcmstb.c | 141 +++++++++++++++++++++++ dts/bindings/gpio/brcm,brcmstb-gpio.yaml | 19 +++ 5 files changed, 172 insertions(+) create mode 100644 drivers/gpio/Kconfig.brcmstb create mode 100644 drivers/gpio/gpio_brcmstb.c create mode 100644 dts/bindings/gpio/brcm,brcmstb-gpio.yaml diff --git a/drivers/gpio/CMakeLists.txt b/drivers/gpio/CMakeLists.txt index 3e4ae12dc4ad..d4fd0730e64f 100644 --- a/drivers/gpio/CMakeLists.txt +++ b/drivers/gpio/CMakeLists.txt @@ -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) diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index ff9d02704d84..dfe46a315816 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -240,4 +240,6 @@ source "drivers/gpio/Kconfig.rzt2m" source "drivers/gpio/Kconfig.ambiq" +source "drivers/gpio/Kconfig.brcmstb" + endif # GPIO diff --git a/drivers/gpio/Kconfig.brcmstb b/drivers/gpio/Kconfig.brcmstb new file mode 100644 index 000000000000..0974f05239e6 --- /dev/null +++ b/drivers/gpio/Kconfig.brcmstb @@ -0,0 +1,9 @@ +# Copyright (c) 2024 Junho Lee +# 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. diff --git a/drivers/gpio/gpio_brcmstb.c b/drivers/gpio/gpio_brcmstb.c new file mode 100644 index 000000000000..cfec6868f290 --- /dev/null +++ b/drivers/gpio/gpio_brcmstb.c @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2024 Junho Lee + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#define DT_DRV_COMPAT brcm_brcmstb_gpio + +#include +#include +#include +#include +#include + +#define GIO_DATA 0x04 +#define GIO_IODIR 0x08 + +#define DEV_CFG(dev) ((const struct gpio_brcmstb_config *)(dev)->config) +#define DEV_DATA(dev) ((struct gpio_brcmstb_data *)(dev)->data) + +struct gpio_brcmstb_config { + struct gpio_driver_config common; + + DEVICE_MMIO_NAMED_ROM(reg_base); + mem_addr_t offset; +}; + +struct gpio_brcmstb_data { + struct gpio_driver_data common; + + DEVICE_MMIO_NAMED_RAM(reg_base); + mem_addr_t base; +}; + +static int gpio_brcmstb_pin_configure(const struct device *port, gpio_pin_t pin, gpio_flags_t flags) +{ + struct gpio_brcmstb_data *data = port->data; + + if (flags & (GPIO_SINGLE_ENDED | GPIO_PULL_UP | GPIO_PULL_DOWN)) { + return -ENOTSUP; + } + + if (flags & GPIO_INPUT) { + sys_set_bit(data->base + GIO_IODIR, pin); + } else if (flags & GPIO_OUTPUT) { + sys_clear_bit(data->base + GIO_IODIR, pin); + + if (flags & GPIO_OUTPUT_INIT_HIGH) { + sys_set_bit(data->base + GIO_DATA, pin); + } else if (flags & GPIO_OUTPUT_INIT_LOW) { + sys_clear_bit(data->base + GIO_DATA, pin); + } + } + + return 0; +} + +static int gpio_brcmstb_port_get_raw(const struct device *port, gpio_port_value_t *value) +{ + struct gpio_brcmstb_data *data = port->data; + + *value = sys_read32(data->base + GIO_DATA); + + return 0; +} + +static int gpio_brcmstb_port_set_masked_raw(const struct device *port, gpio_port_pins_t mask, + gpio_port_value_t value) +{ + struct gpio_brcmstb_data *data = port->data; + + sys_clear_bits(data->base + GIO_DATA, mask); + sys_set_bits(data->base + GIO_DATA, (value & mask)); + + return 0; +} + +static int gpio_brcmstb_port_set_bits_raw(const struct device *port, gpio_port_pins_t pins) +{ + struct gpio_brcmstb_data *data = port->data; + + sys_set_bits(data->base + GIO_DATA, pins); + + return 0; +} + +static int gpio_brcmstb_port_clear_bits_raw(const struct device *port, gpio_port_pins_t pins) +{ + struct gpio_brcmstb_data *data = port->data; + + sys_clear_bits(data->base + GIO_DATA, pins); + + return 0; +} + +static int gpio_brcmstb_port_toggle_bits(const struct device *port, gpio_port_pins_t pins) +{ + struct gpio_brcmstb_data *data = port->data; + uint32_t reg_data; + + reg_data = sys_read32(data->base + GIO_DATA); + reg_data ^= pins; + sys_write32(reg_data, data->base + GIO_DATA); + + return 0; +} + +static const struct gpio_driver_api gpio_brcmstb_api = { + .pin_configure = gpio_brcmstb_pin_configure, + .port_get_raw = gpio_brcmstb_port_get_raw, + .port_set_masked_raw = gpio_brcmstb_port_set_masked_raw, + .port_set_bits_raw = gpio_brcmstb_port_set_bits_raw, + .port_clear_bits_raw = gpio_brcmstb_port_clear_bits_raw, + .port_toggle_bits = gpio_brcmstb_port_toggle_bits, +}; + +int gpio_brcmstb_init(const struct device *port) +{ + const struct gpio_brcmstb_config *config = port->config; + struct gpio_brcmstb_data *data = port->data; + + DEVICE_MMIO_NAMED_MAP(port, reg_base, K_MEM_CACHE_NONE); + data->base = DEVICE_MMIO_NAMED_GET(port, reg_base) + config->offset; + + return 0; +} + +#define GPIO_BRCMSTB_INIT(n) \ + static struct gpio_brcmstb_data gpio_brcmstb_data_##n; \ + \ + static const struct gpio_brcmstb_config gpio_brcmstb_cfg_##n = { \ + .common = {.port_pin_mask = GPIO_PORT_PIN_MASK_FROM_DT_INST(0)}, \ + DEVICE_MMIO_NAMED_ROM_INIT(reg_base, DT_INST_PARENT(n)), \ + .offset = DT_INST_REG_ADDR(n), \ + }; \ + \ + DEVICE_DT_INST_DEFINE(n, gpio_brcmstb_init, NULL, &gpio_brcmstb_data_##n, \ + &gpio_brcmstb_cfg_##n, PRE_KERNEL_1, CONFIG_GPIO_INIT_PRIORITY, \ + &gpio_brcmstb_api); + +DT_INST_FOREACH_STATUS_OKAY(GPIO_BRCMSTB_INIT) diff --git a/dts/bindings/gpio/brcm,brcmstb-gpio.yaml b/dts/bindings/gpio/brcm,brcmstb-gpio.yaml new file mode 100644 index 000000000000..55f58a9f3fdd --- /dev/null +++ b/dts/bindings/gpio/brcm,brcmstb-gpio.yaml @@ -0,0 +1,19 @@ +# Copyright (c) 2024 Junho Lee +# SPDX-License-Identifier: Apache-2.0 + +description: BRCMSTB GPIO + +compatible: "brcm,brcmstb-gpio" + +include: [gpio-controller.yaml, base.yaml] + +properties: + reg: + required: true + + "#gpio-cells": + const: 2 + +gpio-cells: + - pin + - flags From cd0f8e36fa1d258db612ef731b334ed77ad8d7eb Mon Sep 17 00:00:00 2001 From: Junho Lee Date: Thu, 21 Mar 2024 13:30:52 +0900 Subject: [PATCH 02/13] soc: brcm: add support for BCM2712 Add support for BCM2712, SoC of Raspberry Pi 5. Signed-off-by: Junho Lee (cherry picked from commit 76ec48179403d6fc15774579e837d0277c00dab6) Signed-off-by: Grygorii Strashko --- dts/arm64/broadcom/bcm2712.dtsi | 71 ++++++++++++++++++++++++++++++ soc/brcm/bcm2712/CMakeLists.txt | 4 ++ soc/brcm/bcm2712/Kconfig | 7 +++ soc/brcm/bcm2712/Kconfig.defconfig | 14 ++++++ soc/brcm/bcm2712/Kconfig.soc | 8 ++++ soc/brcm/bcm2712/mmu_regions.c | 26 +++++++++++ soc/brcm/bcm2712/soc.yml | 4 ++ 7 files changed, 134 insertions(+) create mode 100644 dts/arm64/broadcom/bcm2712.dtsi create mode 100644 soc/brcm/bcm2712/CMakeLists.txt create mode 100644 soc/brcm/bcm2712/Kconfig create mode 100644 soc/brcm/bcm2712/Kconfig.defconfig create mode 100644 soc/brcm/bcm2712/Kconfig.soc create mode 100644 soc/brcm/bcm2712/mmu_regions.c create mode 100644 soc/brcm/bcm2712/soc.yml diff --git a/dts/arm64/broadcom/bcm2712.dtsi b/dts/arm64/broadcom/bcm2712.dtsi new file mode 100644 index 000000000000..b9985e23e765 --- /dev/null +++ b/dts/arm64/broadcom/bcm2712.dtsi @@ -0,0 +1,71 @@ +/* + * Copyright 2024 Myeonghyeon Park + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include + +/ { + cpus { + #address-cells = <1>; + #size-cells = <0>; + + cpu@0 { + device_type = "cpu"; + compatible = "arm,cortex-a76"; + reg = <0>; + }; + }; + + interrupt-parent = <&gic>; + + timer { + compatible = "arm,armv8-timer"; + interrupts = , + , + , + ; + }; + + soc { + #address-cells = <2>; + #size-cells = <1>; + + sram0: memory@200000 { + device_type = "memory"; + compatible = "mmio-sram"; + reg = <0x0 0x200000 0x80000>; + }; + + gic: interrupt-controller@107fff9000 { + compatible = "arm,gic-v2", "arm,gic"; + reg = <0x10 0x7fff9000 0x1000>, + <0x10 0x7fffa000 0x2000>; + interrupt-controller; + #interrupt-cells = <4>; + status = "okay"; + }; + + gpio2@107d517c00 { + compatible = "simple-bus"; + reg = <0x10 0x7d517c00 0x40>; + + #address-cells = <1>; + #size-cells = <0>; + gio_aon: gpio@0 { + compatible = "brcm,brcmstb-gpio"; + reg = <0>; + gpio-controller; + #gpio-cells = <2>; + ngpios = <17>; + status = "disabled"; + }; + }; + }; +}; diff --git a/soc/brcm/bcm2712/CMakeLists.txt b/soc/brcm/bcm2712/CMakeLists.txt new file mode 100644 index 000000000000..733abbebd911 --- /dev/null +++ b/soc/brcm/bcm2712/CMakeLists.txt @@ -0,0 +1,4 @@ +# SPDX-License-Identifier: Apache-2.0 +zephyr_sources_ifdef(CONFIG_ARM_MMU mmu_regions.c) + +set(SOC_LINKER_SCRIPT ${ZEPHYR_BASE}/include/zephyr/arch/arm64/scripts/linker.ld CACHE INTERNAL "") diff --git a/soc/brcm/bcm2712/Kconfig b/soc/brcm/bcm2712/Kconfig new file mode 100644 index 000000000000..af683756c40b --- /dev/null +++ b/soc/brcm/bcm2712/Kconfig @@ -0,0 +1,7 @@ +# Copyright 2024 Junho Lee +# SPDX-License-Identifier: Apache-2.0 + +config SOC_BCM2712 + select ARM64 + select CPU_CORTEX_A76 + select ARM_ARCH_TIMER if SYS_CLOCK_EXISTS diff --git a/soc/brcm/bcm2712/Kconfig.defconfig b/soc/brcm/bcm2712/Kconfig.defconfig new file mode 100644 index 000000000000..e408b20271ad --- /dev/null +++ b/soc/brcm/bcm2712/Kconfig.defconfig @@ -0,0 +1,14 @@ +# Copyright 2024 Junho Lee +# SPDX-License-Identifier: Apache-2.0 + +if SOC_BCM2712 + +config NUM_IRQS + int + default 280 + +config SYS_CLOCK_HW_CYCLES_PER_SEC + int + default 54000000 + +endif diff --git a/soc/brcm/bcm2712/Kconfig.soc b/soc/brcm/bcm2712/Kconfig.soc new file mode 100644 index 000000000000..3d55282e5db5 --- /dev/null +++ b/soc/brcm/bcm2712/Kconfig.soc @@ -0,0 +1,8 @@ +# Copyright 2024 Junho Lee +# SPDX-License-Identifier: Apache-2.0 + +config SOC_BCM2712 + bool + +config SOC + default "bcm2712" if SOC_BCM2712 diff --git a/soc/brcm/bcm2712/mmu_regions.c b/soc/brcm/bcm2712/mmu_regions.c new file mode 100644 index 000000000000..ea3314ffc2ed --- /dev/null +++ b/soc/brcm/bcm2712/mmu_regions.c @@ -0,0 +1,26 @@ +/* + * Copyright 2024 Junho Lee + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include + +static const struct arm_mmu_region mmu_regions[] = { + MMU_REGION_FLAT_ENTRY("GIC", + DT_REG_ADDR_BY_IDX(DT_INST(0, arm_gic), 0), + DT_REG_SIZE_BY_IDX(DT_INST(0, arm_gic), 0), + MT_DEVICE_nGnRnE | MT_P_RW_U_NA | MT_DEFAULT_SECURE_STATE), + + MMU_REGION_FLAT_ENTRY("GIC", + DT_REG_ADDR_BY_IDX(DT_INST(0, arm_gic), 1), + DT_REG_SIZE_BY_IDX(DT_INST(0, arm_gic), 1), + MT_DEVICE_nGnRnE | MT_P_RW_U_NA | MT_DEFAULT_SECURE_STATE), +}; + +const struct arm_mmu_config mmu_config = { + .num_regions = ARRAY_SIZE(mmu_regions), + .mmu_regions = mmu_regions, +}; diff --git a/soc/brcm/bcm2712/soc.yml b/soc/brcm/bcm2712/soc.yml new file mode 100644 index 000000000000..ce95e07ac683 --- /dev/null +++ b/soc/brcm/bcm2712/soc.yml @@ -0,0 +1,4 @@ +series: +- name: bcm2712 + socs: + - name: bcm2712 From a13ec7657a82093fb7741df845d019575b43f133 Mon Sep 17 00:00:00 2001 From: Junho Lee Date: Thu, 21 Mar 2024 13:38:06 +0900 Subject: [PATCH 03/13] board: raspberrypi: add support for Raspberry Pi 5 Add support for Raspberry Pi 5. Currently only internal GPIO(gio_aon) is supported. 'Blinky' is the only sample that is working for now. Signed-off-by: Junho Lee (cherry picked from commit 73f4102ad852659baa177ff91c62ebdca6a51596) Signed-off-by: Grygorii Strashko --- boards/raspberrypi/rpi_5/Kconfig.rpi_5 | 5 ++ boards/raspberrypi/rpi_5/board.yml | 5 ++ boards/raspberrypi/rpi_5/doc/index.rst | 101 +++++++++++++++++++++++ boards/raspberrypi/rpi_5/rpi_5.dts | 38 +++++++++ boards/raspberrypi/rpi_5/rpi_5.yaml | 7 ++ boards/raspberrypi/rpi_5/rpi_5_defconfig | 5 ++ 6 files changed, 161 insertions(+) create mode 100644 boards/raspberrypi/rpi_5/Kconfig.rpi_5 create mode 100644 boards/raspberrypi/rpi_5/board.yml create mode 100644 boards/raspberrypi/rpi_5/doc/index.rst create mode 100644 boards/raspberrypi/rpi_5/rpi_5.dts create mode 100644 boards/raspberrypi/rpi_5/rpi_5.yaml create mode 100644 boards/raspberrypi/rpi_5/rpi_5_defconfig diff --git a/boards/raspberrypi/rpi_5/Kconfig.rpi_5 b/boards/raspberrypi/rpi_5/Kconfig.rpi_5 new file mode 100644 index 000000000000..8f06aba94743 --- /dev/null +++ b/boards/raspberrypi/rpi_5/Kconfig.rpi_5 @@ -0,0 +1,5 @@ +# Copyright 2024 Junho Lee +# SPDX-License-Identifier: Apache-2.0 + +config BOARD_RPI_5 + select SOC_BCM2712 diff --git a/boards/raspberrypi/rpi_5/board.yml b/boards/raspberrypi/rpi_5/board.yml new file mode 100644 index 000000000000..d604b7f4e513 --- /dev/null +++ b/boards/raspberrypi/rpi_5/board.yml @@ -0,0 +1,5 @@ +board: + name: rpi_5 + vendor: raspberrypi + socs: + - name: bcm2712 diff --git a/boards/raspberrypi/rpi_5/doc/index.rst b/boards/raspberrypi/rpi_5/doc/index.rst new file mode 100644 index 000000000000..65989d6bf755 --- /dev/null +++ b/boards/raspberrypi/rpi_5/doc/index.rst @@ -0,0 +1,101 @@ +.. 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` + +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. + +.. _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 diff --git a/boards/raspberrypi/rpi_5/rpi_5.dts b/boards/raspberrypi/rpi_5/rpi_5.dts new file mode 100644 index 000000000000..9033f91f9e64 --- /dev/null +++ b/boards/raspberrypi/rpi_5/rpi_5.dts @@ -0,0 +1,38 @@ +/* + * Copyright 2024 Junho Lee + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; + +#include +#include + +/ { + compatible = "raspberrypi,5-model-b", "brcm,bcm2712"; + model = "Raspberry Pi 5"; + #address-cells = <2>; + #size-cells = <1>; + + aliases { + led0 = &led_act; + }; + + chosen { + zephyr,sram = &sram0; + }; + + leds { + compatible = "gpio-leds"; + + led_act: led-act { + gpios = <&gio_aon 9 GPIO_ACTIVE_LOW>; + label = "ACT"; + }; + }; +}; + +&gio_aon { + status = "okay"; +}; diff --git a/boards/raspberrypi/rpi_5/rpi_5.yaml b/boards/raspberrypi/rpi_5/rpi_5.yaml new file mode 100644 index 000000000000..e293d78e9cd1 --- /dev/null +++ b/boards/raspberrypi/rpi_5/rpi_5.yaml @@ -0,0 +1,7 @@ +identifier: rpi_5 +name: Raspberry Pi 5 +type: mcu +arch: arm64 +toolchain: + - zephyr + - cross-compile diff --git a/boards/raspberrypi/rpi_5/rpi_5_defconfig b/boards/raspberrypi/rpi_5/rpi_5_defconfig new file mode 100644 index 000000000000..0ecf409b6f74 --- /dev/null +++ b/boards/raspberrypi/rpi_5/rpi_5_defconfig @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: Apache-2.0 + +CONFIG_ARM64_VA_BITS_40=y +CONFIG_ARM64_PA_BITS_40=y +CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y From 184e571cb64e57117ceda4e7b864ef26a5079494 Mon Sep 17 00:00:00 2001 From: Myeonghyeon Park Date: Wed, 27 Mar 2024 18:19:19 +0900 Subject: [PATCH 04/13] board: raspberrypi: enable serial communication on Raspberry Pi 5 Enable serial communication through UART port between HDMI ports. Signed-off-by: Myeonghyeon Park Signed-off-by: Junho Lee (cherry picked from commit 63692c1349f767c5c78ad30fb4b024c80cb61329) Signed-off-by: Grygorii Strashko --- boards/raspberrypi/rpi_5/doc/index.rst | 60 ++++++++++++++++++++++++ boards/raspberrypi/rpi_5/rpi_5.dts | 7 +++ boards/raspberrypi/rpi_5/rpi_5_defconfig | 5 ++ dts/arm64/broadcom/bcm2712.dtsi | 18 +++++++ 4 files changed, 90 insertions(+) diff --git a/boards/raspberrypi/rpi_5/doc/index.rst b/boards/raspberrypi/rpi_5/doc/index.rst index 65989d6bf755..c22c695a405d 100644 --- a/boards/raspberrypi/rpi_5/doc/index.rst +++ b/boards/raspberrypi/rpi_5/doc/index.rst @@ -46,6 +46,9 @@ The Raspberry Pi 5 board configuration supports the following hardware features: * - 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. @@ -91,6 +94,60 @@ Copy `zephyr.bin` from `build/zephyr` directory to the root directory of the Mic 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 @@ -99,3 +156,6 @@ Insert the Micro SD card and power on the Raspberry Pi 5. And then, the STAT LED .. _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/ diff --git a/boards/raspberrypi/rpi_5/rpi_5.dts b/boards/raspberrypi/rpi_5/rpi_5.dts index 9033f91f9e64..6fca0efd3d0c 100644 --- a/boards/raspberrypi/rpi_5/rpi_5.dts +++ b/boards/raspberrypi/rpi_5/rpi_5.dts @@ -21,6 +21,8 @@ chosen { zephyr,sram = &sram0; + zephyr,console = &uart10; + zephyr,shell-uart = &uart10; }; leds { @@ -36,3 +38,8 @@ &gio_aon { status = "okay"; }; + +&uart10 { + status = "okay"; + current-speed = <115200>; +}; diff --git a/boards/raspberrypi/rpi_5/rpi_5_defconfig b/boards/raspberrypi/rpi_5/rpi_5_defconfig index 0ecf409b6f74..bc0375e81203 100644 --- a/boards/raspberrypi/rpi_5/rpi_5_defconfig +++ b/boards/raspberrypi/rpi_5/rpi_5_defconfig @@ -3,3 +3,8 @@ 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 diff --git a/dts/arm64/broadcom/bcm2712.dtsi b/dts/arm64/broadcom/bcm2712.dtsi index b9985e23e765..a31e8b21d14b 100644 --- a/dts/arm64/broadcom/bcm2712.dtsi +++ b/dts/arm64/broadcom/bcm2712.dtsi @@ -67,5 +67,23 @@ status = "disabled"; }; }; + + uart10: serial@107d001000 { + compatible = "arm,pl011"; + reg = <0x10 0x7d001000 0x200>; + interrupts = ; + clocks = <&clk_uart>; + status = "disabled"; + }; + + }; + + clocks { + clk_uart: clk_uart { + compatible = "fixed-clock"; + clock-frequency = <44236800>; + #clock-cells = <0>; + }; }; }; From ae4aae68c5aced7a5682b2335a29a28011ee10e2 Mon Sep 17 00:00:00 2001 From: Grygorii Strashko Date: Sat, 13 Apr 2024 14:18:14 +0300 Subject: [PATCH 05/13] soc: bcm2712: backport to old hwm Mainline zephyr is moved to HWM v2 which rearranged *soc* and *boards* which prevents usage of patches [1] as is. Hence backport bcm2712 to old HWM. Not for upstream. [1] https://github.com/zephyrproject-rtos/zephyr/pull/70538 Signed-off-by: Grygorii Strashko --- soc/{brcm => arm64}/bcm2712/CMakeLists.txt | 0 soc/{brcm => arm64}/bcm2712/Kconfig.defconfig | 3 +++ soc/{brcm/bcm2712/Kconfig => arm64/bcm2712/Kconfig.soc} | 1 + soc/{brcm => arm64}/bcm2712/mmu_regions.c | 0 soc/{brcm => arm64}/bcm2712/soc.yml | 0 soc/brcm/bcm2712/Kconfig.soc | 8 -------- 6 files changed, 4 insertions(+), 8 deletions(-) rename soc/{brcm => arm64}/bcm2712/CMakeLists.txt (100%) rename soc/{brcm => arm64}/bcm2712/Kconfig.defconfig (86%) rename soc/{brcm/bcm2712/Kconfig => arm64/bcm2712/Kconfig.soc} (92%) rename soc/{brcm => arm64}/bcm2712/mmu_regions.c (100%) rename soc/{brcm => arm64}/bcm2712/soc.yml (100%) delete mode 100644 soc/brcm/bcm2712/Kconfig.soc diff --git a/soc/brcm/bcm2712/CMakeLists.txt b/soc/arm64/bcm2712/CMakeLists.txt similarity index 100% rename from soc/brcm/bcm2712/CMakeLists.txt rename to soc/arm64/bcm2712/CMakeLists.txt diff --git a/soc/brcm/bcm2712/Kconfig.defconfig b/soc/arm64/bcm2712/Kconfig.defconfig similarity index 86% rename from soc/brcm/bcm2712/Kconfig.defconfig rename to soc/arm64/bcm2712/Kconfig.defconfig index e408b20271ad..0f57c8dffe82 100644 --- a/soc/brcm/bcm2712/Kconfig.defconfig +++ b/soc/arm64/bcm2712/Kconfig.defconfig @@ -3,6 +3,9 @@ if SOC_BCM2712 +config SOC + default "bcm2712" + config NUM_IRQS int default 280 diff --git a/soc/brcm/bcm2712/Kconfig b/soc/arm64/bcm2712/Kconfig.soc similarity index 92% rename from soc/brcm/bcm2712/Kconfig rename to soc/arm64/bcm2712/Kconfig.soc index af683756c40b..e1d05aaa92bc 100644 --- a/soc/brcm/bcm2712/Kconfig +++ b/soc/arm64/bcm2712/Kconfig.soc @@ -2,6 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 config SOC_BCM2712 + bool "bcm2712" select ARM64 select CPU_CORTEX_A76 select ARM_ARCH_TIMER if SYS_CLOCK_EXISTS diff --git a/soc/brcm/bcm2712/mmu_regions.c b/soc/arm64/bcm2712/mmu_regions.c similarity index 100% rename from soc/brcm/bcm2712/mmu_regions.c rename to soc/arm64/bcm2712/mmu_regions.c diff --git a/soc/brcm/bcm2712/soc.yml b/soc/arm64/bcm2712/soc.yml similarity index 100% rename from soc/brcm/bcm2712/soc.yml rename to soc/arm64/bcm2712/soc.yml diff --git a/soc/brcm/bcm2712/Kconfig.soc b/soc/brcm/bcm2712/Kconfig.soc deleted file mode 100644 index 3d55282e5db5..000000000000 --- a/soc/brcm/bcm2712/Kconfig.soc +++ /dev/null @@ -1,8 +0,0 @@ -# Copyright 2024 Junho Lee -# SPDX-License-Identifier: Apache-2.0 - -config SOC_BCM2712 - bool - -config SOC - default "bcm2712" if SOC_BCM2712 From 3ae3a86e6935d66ccfb449bc7716047a53341f41 Mon Sep 17 00:00:00 2001 From: Grygorii Strashko Date: Sat, 13 Apr 2024 14:20:14 +0300 Subject: [PATCH 06/13] boards: raspberrypi: rpi_5: backport to old hwm Mainline zephyr is moved to HWM v2 which rearranged *soc* and *boards* which prevents usage of patches [1] as is. Hence backport RPI5 board to old HWM. Not for upstream. [1] https://github.com/zephyrproject-rtos/zephyr/pull/70538 Signed-off-by: Grygorii Strashko --- .../rpi_5/Kconfig.rpi_5 => arm64/rpi_5/Kconfig.board} | 3 ++- boards/arm64/rpi_5/Kconfig.defconfig | 6 ++++++ boards/arm64/rpi_5/board.cmake | 1 + boards/{raspberrypi => arm64}/rpi_5/board.yml | 0 boards/{raspberrypi => arm64}/rpi_5/doc/index.rst | 0 boards/{raspberrypi => arm64}/rpi_5/rpi_5.dts | 0 boards/{raspberrypi => arm64}/rpi_5/rpi_5.yaml | 0 boards/{raspberrypi => arm64}/rpi_5/rpi_5_defconfig | 2 ++ 8 files changed, 11 insertions(+), 1 deletion(-) rename boards/{raspberrypi/rpi_5/Kconfig.rpi_5 => arm64/rpi_5/Kconfig.board} (67%) create mode 100644 boards/arm64/rpi_5/Kconfig.defconfig create mode 100644 boards/arm64/rpi_5/board.cmake rename boards/{raspberrypi => arm64}/rpi_5/board.yml (100%) rename boards/{raspberrypi => arm64}/rpi_5/doc/index.rst (100%) rename boards/{raspberrypi => arm64}/rpi_5/rpi_5.dts (100%) rename boards/{raspberrypi => arm64}/rpi_5/rpi_5.yaml (100%) rename boards/{raspberrypi => arm64}/rpi_5/rpi_5_defconfig (83%) diff --git a/boards/raspberrypi/rpi_5/Kconfig.rpi_5 b/boards/arm64/rpi_5/Kconfig.board similarity index 67% rename from boards/raspberrypi/rpi_5/Kconfig.rpi_5 rename to boards/arm64/rpi_5/Kconfig.board index 8f06aba94743..2a60534b4c8d 100644 --- a/boards/raspberrypi/rpi_5/Kconfig.rpi_5 +++ b/boards/arm64/rpi_5/Kconfig.board @@ -2,4 +2,5 @@ # SPDX-License-Identifier: Apache-2.0 config BOARD_RPI_5 - select SOC_BCM2712 + bool "Broadcom BCM2712" + depends on SOC_BCM2712 diff --git a/boards/arm64/rpi_5/Kconfig.defconfig b/boards/arm64/rpi_5/Kconfig.defconfig new file mode 100644 index 000000000000..a555a718911a --- /dev/null +++ b/boards/arm64/rpi_5/Kconfig.defconfig @@ -0,0 +1,6 @@ +# Copyright 2023 honglin leng +# SPDX-License-Identifier: Apache-2.0 + +config BOARD + default "Raspberry Pi 5" + depends on BOARD_RPI_5 diff --git a/boards/arm64/rpi_5/board.cmake b/boards/arm64/rpi_5/board.cmake new file mode 100644 index 000000000000..9881313609aa --- /dev/null +++ b/boards/arm64/rpi_5/board.cmake @@ -0,0 +1 @@ +# SPDX-License-Identifier: Apache-2.0 diff --git a/boards/raspberrypi/rpi_5/board.yml b/boards/arm64/rpi_5/board.yml similarity index 100% rename from boards/raspberrypi/rpi_5/board.yml rename to boards/arm64/rpi_5/board.yml diff --git a/boards/raspberrypi/rpi_5/doc/index.rst b/boards/arm64/rpi_5/doc/index.rst similarity index 100% rename from boards/raspberrypi/rpi_5/doc/index.rst rename to boards/arm64/rpi_5/doc/index.rst diff --git a/boards/raspberrypi/rpi_5/rpi_5.dts b/boards/arm64/rpi_5/rpi_5.dts similarity index 100% rename from boards/raspberrypi/rpi_5/rpi_5.dts rename to boards/arm64/rpi_5/rpi_5.dts diff --git a/boards/raspberrypi/rpi_5/rpi_5.yaml b/boards/arm64/rpi_5/rpi_5.yaml similarity index 100% rename from boards/raspberrypi/rpi_5/rpi_5.yaml rename to boards/arm64/rpi_5/rpi_5.yaml diff --git a/boards/raspberrypi/rpi_5/rpi_5_defconfig b/boards/arm64/rpi_5/rpi_5_defconfig similarity index 83% rename from boards/raspberrypi/rpi_5/rpi_5_defconfig rename to boards/arm64/rpi_5/rpi_5_defconfig index bc0375e81203..d3b777c339e5 100644 --- a/boards/raspberrypi/rpi_5/rpi_5_defconfig +++ b/boards/arm64/rpi_5/rpi_5_defconfig @@ -1,5 +1,7 @@ # 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 From bce36aa9f3dd52e40edbaceb842f0e287dc50095 Mon Sep 17 00:00:00 2001 From: Grygorii Strashko Date: Mon, 15 Apr 2024 10:42:47 +0300 Subject: [PATCH 07/13] drivers: xen: add XEN_EVENTS Kconfig option The XEN events consume 72K of RAM, but they might be not used. Add XEN EVENTS Kconfig option so XEN events could be gracefully disabled if not needed. Signed-off-by: Grygorii Strashko --- arch/arm64/core/xen/CMakeLists.txt | 2 +- drivers/serial/Kconfig.xen | 1 + drivers/xen/CMakeLists.txt | 2 +- drivers/xen/Kconfig | 6 ++++++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/arch/arm64/core/xen/CMakeLists.txt b/arch/arm64/core/xen/CMakeLists.txt index b0b573b7b9b2..e056ab29725b 100644 --- a/arch/arm64/core/xen/CMakeLists.txt +++ b/arch/arm64/core/xen/CMakeLists.txt @@ -8,4 +8,4 @@ zephyr_compile_options($<$:-D__ASSEMBLY__>) zephyr_compile_options(-D__XEN_INTERFACE_VERSION__=0x00040e00) zephyr_library_sources(hypercall.S) -zephyr_library_sources(enlighten.c) +zephyr_library_sources_ifdef(CONFIG_XEN_EVENTS enlighten.c) diff --git a/drivers/serial/Kconfig.xen b/drivers/serial/Kconfig.xen index 02492e7483fc..7a8f30590adc 100644 --- a/drivers/serial/Kconfig.xen +++ b/drivers/serial/Kconfig.xen @@ -11,6 +11,7 @@ config UART_XEN_HVC select SERIAL_HAS_DRIVER select SERIAL_SUPPORT_INTERRUPT depends on XEN && !XEN_DOM0 && !XEN_DOM0LESS + select XEN_EVENTS if UART_INTERRUPT_DRIVEN help Enable Xen ring buffer based hypervisor console driver. Used for Zephyr as unprivileged domain. diff --git a/drivers/xen/CMakeLists.txt b/drivers/xen/CMakeLists.txt index 76b02dfaa623..2c87f3766ec3 100644 --- a/drivers/xen/CMakeLists.txt +++ b/drivers/xen/CMakeLists.txt @@ -2,7 +2,7 @@ # Copyright (c) 2021-2023 EPAM Systems zephyr_sources(hvm.c) -zephyr_sources(events.c) +zephyr_sources_ifdef(CONFIG_XEN_EVENTS events.c) zephyr_sources_ifdef(CONFIG_XEN_GRANT_TABLE gnttab.c) zephyr_sources(memory.c) zephyr_include_directories_ifdef(CONFIG_XEN_REGIONS ${ZEPHYR_BASE}/kernel/include) diff --git a/drivers/xen/Kconfig b/drivers/xen/Kconfig index 39baec1a8e1f..952029185585 100644 --- a/drivers/xen/Kconfig +++ b/drivers/xen/Kconfig @@ -29,6 +29,12 @@ config XEN_GRANT_TABLE_INIT_PRIORITY depends on XEN_GRANT_TABLE default 50 +config XEN_EVENTS + bool "Xen events driver" + default y + help + Xen event channels driver. + endmenu endif # XEN From 475af0421cbcbb793318f99ca4a6e32d396ec0f9 Mon Sep 17 00:00:00 2001 From: Grygorii Strashko Date: Wed, 17 Apr 2024 12:47:15 +0300 Subject: [PATCH 08/13] HACK: boards: arm64: xenvm: reduce hypervisor node memory The current "hypervisor" node defined to use 16M of MMIO memory, which is way too much. reduce it to 65K. Otherwise it's required to allocate bug number of grant frames for domain (max_grant_frames). As suggested by Dmytro Firsov. Signed-off-by: Grygorii Strashko --- boards/arm64/xenvm/xenvm.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boards/arm64/xenvm/xenvm.dts b/boards/arm64/xenvm/xenvm.dts index bbba268d9a35..9857f7885064 100644 --- a/boards/arm64/xenvm/xenvm.dts +++ b/boards/arm64/xenvm/xenvm.dts @@ -69,7 +69,7 @@ hypervisor: hypervisor@38000000 { compatible = "xen,xen"; - reg = <0x00 0x38000000 0x00 0x1000000>; + reg = <0x00 0x38000000 0x00 0x10000>; interrupts = ; interrupt-parent = <&gic>; }; From ead4c0868b2a027810cc0adc659bca3e76ac62e5 Mon Sep 17 00:00:00 2001 From: Grygorii Strashko Date: Wed, 17 Apr 2024 13:23:25 +0300 Subject: [PATCH 09/13] boards: arm64: xenvm: defconfig: disable XEN_REGIONS The CONFIG_XEN_REGIONS is enabled by default, but second memory range is not defined for "hypervisor" node which causes build failure. Hence, disable CONFIG_XEN_REGIONS for xenvm platform. Signed-off-by: Grygorii Strashko --- boards/arm64/xenvm/xenvm_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/boards/arm64/xenvm/xenvm_defconfig b/boards/arm64/xenvm/xenvm_defconfig index 39e8a20767cb..52f16c0df2cb 100644 --- a/boards/arm64/xenvm/xenvm_defconfig +++ b/boards/arm64/xenvm/xenvm_defconfig @@ -18,3 +18,4 @@ CONFIG_LOG_MODE_MINIMAL=n CONFIG_USERSPACE=n CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y +CONFIG_XEN_REGIONS=n From 2bccb36e197b1a9965d86a5d9e152306d0f8daa8 Mon Sep 17 00:00:00 2001 From: Grygorii Strashko Date: Wed, 17 Apr 2024 13:01:31 +0300 Subject: [PATCH 10/13] HACK: TMP: xen: public: domctl: tmp adjust version Tmp adjust XEN_DOMCTL_INTERFACE_VERSION to start with XEN 4.19. See commit bdb1184d4f6bf4e0121fda34a6c1cb51fe270e7d ("domctl: bump interface version"), there were no Xen interface struct changes. Signed-off-by: Grygorii Strashko --- include/zephyr/xen/public/domctl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/zephyr/xen/public/domctl.h b/include/zephyr/xen/public/domctl.h index dbb9f04dc2e7..cb0a3adbf6e9 100644 --- a/include/zephyr/xen/public/domctl.h +++ b/include/zephyr/xen/public/domctl.h @@ -20,7 +20,7 @@ #include "grant_table.h" #include "memory.h" -#define XEN_DOMCTL_INTERFACE_VERSION 0x00000015 +#define XEN_DOMCTL_INTERFACE_VERSION 0x00000016 /* * NB. xen_domctl.domain is an IN/OUT parameter for this operation. From c8d922a576a7dfd4a9cd443c4053cff2256526ae Mon Sep 17 00:00:00 2001 From: Grygorii Strashko Date: Sat, 13 Apr 2024 15:07:18 +0300 Subject: [PATCH 11/13] snippets: xen_dom0: add rpi5 board Add RPI5 board support. Signed-off-by: Grygorii Strashko --- snippets/xen_dom0/boards/rpi_5.overlay | 51 ++++++++++++++++++++++++++ snippets/xen_dom0/snippet.yml | 3 ++ 2 files changed, 54 insertions(+) create mode 100644 snippets/xen_dom0/boards/rpi_5.overlay diff --git a/snippets/xen_dom0/boards/rpi_5.overlay b/snippets/xen_dom0/boards/rpi_5.overlay new file mode 100644 index 000000000000..cbe9d3812733 --- /dev/null +++ b/snippets/xen_dom0/boards/rpi_5.overlay @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2024 EPAM Systems. + * + * SPDX-License-Identifier: Apache-2.0 + */ + + /delete-node/ &sram0; + +#include + +/ { + #address-cells = <2>; + #size-cells = <1>; + /* + * This node may differs on different setups, please check + * following line in Xen boot log to set it right: + * (XEN) Grant table range: 0x00000002800000-0x00000002840000 + * Also, add extended region 1: + * (XEN) d0: extended region 1: 0x40000000->0x5fe00000 + * + * Xen passes actual values for setup in domain device tree, but Zephyr + * is not capable to parse and handle it in runtime. + */ + hypervisor: hypervisor@2800000 { + compatible = "xen,xen"; + reg = <0x00 0x2800000 0x40000>, <0x00 0x2a00000 0x5400000>; + interrupts = ; + interrupt-parent = <&gic>; + status = "okay"; + }; + + /* + * This node may differs on different setups, because Xen picks + * region for Domain-0 for every specific configuration. You can + * start Xen for your platform and check following log: + * (XEN) Allocating 1:1 mappings totalling 512MB for dom0: + * (XEN) BANK[0] 0x00000060000000-0x00000080000000 (512MB) + * (XEN) Loading zImage from 0000000000080000 to 0000000060000000-0000000060038004 + * + * Xen passes actual values for setup in domain device tree, but Zephyr + * is not capable to parse and handle it in runtime. + */ + sram0: memory@8000000 { + compatible = "mmio-sram"; + reg = <0x00 0x8000000 DT_SIZE_M(128)>; + }; +}; + +&uart10 { + status = "disabled"; +}; diff --git a/snippets/xen_dom0/snippet.yml b/snippets/xen_dom0/snippet.yml index ff47714267c0..9bbf3839ed06 100644 --- a/snippets/xen_dom0/snippet.yml +++ b/snippets/xen_dom0/snippet.yml @@ -16,3 +16,6 @@ boards: rcar_spider_ca55: append: EXTRA_DTC_OVERLAY_FILE: boards/rcar_spider_ca55.overlay + rpi_5: + append: + EXTRA_DTC_OVERLAY_FILE: boards/rpi_5.overlay From e8daa5b5f5bcc8ad5c9d3f44faf63ed46a939699 Mon Sep 17 00:00:00 2001 From: Grygorii Strashko Date: Wed, 24 Apr 2024 21:58:42 +0300 Subject: [PATCH 12/13] snippets: add rpi_5_xen_domd to demo hw passing to xen domain Add rpi_5_xen_domd snippet to demonstrate enabling RPI 5 HW in Xen domain. Only GPIO LED is supported. Signed-off-by: Grygorii Strashko --- snippets/rpi_5_xen_domd/README.rst | 17 +++++++ snippets/rpi_5_xen_domd/rpi_5_xen_domd.conf | 3 ++ .../rpi_5_xen_domd/rpi_5_xen_domd.overlay | 45 +++++++++++++++++++ snippets/rpi_5_xen_domd/snippet.yml | 4 ++ 4 files changed, 69 insertions(+) create mode 100644 snippets/rpi_5_xen_domd/README.rst create mode 100644 snippets/rpi_5_xen_domd/rpi_5_xen_domd.conf create mode 100644 snippets/rpi_5_xen_domd/rpi_5_xen_domd.overlay create mode 100644 snippets/rpi_5_xen_domd/snippet.yml diff --git a/snippets/rpi_5_xen_domd/README.rst b/snippets/rpi_5_xen_domd/README.rst new file mode 100644 index 000000000000..37a7c271e909 --- /dev/null +++ b/snippets/rpi_5_xen_domd/README.rst @@ -0,0 +1,17 @@ +.. _rpi_5_xen_domd: + +RPI 5 Xen DomD: snippet for XEN HW domain +######################################### + +Overview +******** + +This snippet allows user to build Zephyr `xenvm` with RPI 5 hardware support as +a Xen hardware domain (DomD) to demonstrate how RPI 5 hardware can be passed to Xen domain. +Only GPIO LED is supported for now. + +For example: + +.. code-block:: console + + west build -b xenvm -S rpi_5_xen_domd samples/basic/blinky diff --git a/snippets/rpi_5_xen_domd/rpi_5_xen_domd.conf b/snippets/rpi_5_xen_domd/rpi_5_xen_domd.conf new file mode 100644 index 000000000000..cd989de2f625 --- /dev/null +++ b/snippets/rpi_5_xen_domd/rpi_5_xen_domd.conf @@ -0,0 +1,3 @@ +CONFIG_ARM64_VA_BITS_40=y +CONFIG_ARM64_PA_BITS_40=y +CONFIG_UART_INTERRUPT_DRIVEN=n diff --git a/snippets/rpi_5_xen_domd/rpi_5_xen_domd.overlay b/snippets/rpi_5_xen_domd/rpi_5_xen_domd.overlay new file mode 100644 index 000000000000..0074cdae2464 --- /dev/null +++ b/snippets/rpi_5_xen_domd/rpi_5_xen_domd.overlay @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2024 EPAM Systems. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include + +/ { + compatible = "raspberrypi,5-model-b-domd", "raspberrypi,5-model-b", "brcm,bcm2712"; + model = "Raspberry Pi 5 Xen DomD"; + + chosen { + zephyr,shell-uart = &xen_hvc; + }; + + aliases { + led0 = &led_act; + }; + + leds { + compatible = "gpio-leds"; + + led_act: led-act { + gpios = <&gio_aon 9 GPIO_ACTIVE_LOW>; + label = "ACT"; + }; + }; + + gpio2@107d517c00 { + compatible = "simple-bus"; + reg = <0x10 0x7d517c00 0x0 0x40>; + + #address-cells = <1>; + #size-cells = <0>; + gio_aon: gpio@0 { + compatible = "brcm,brcmstb-gpio"; + reg = <0>; + gpio-controller; + #gpio-cells = <2>; + ngpios = <17>; + }; + }; +}; diff --git a/snippets/rpi_5_xen_domd/snippet.yml b/snippets/rpi_5_xen_domd/snippet.yml new file mode 100644 index 000000000000..ef650dc0c232 --- /dev/null +++ b/snippets/rpi_5_xen_domd/snippet.yml @@ -0,0 +1,4 @@ +name: rpi_5_xen_domd +append: + EXTRA_DTC_OVERLAY_FILE: rpi_5_xen_domd.overlay + EXTRA_CONF_FILE: rpi_5_xen_domd.conf From dd6cfaf901643dfaabeff82de8db5171525c5c8a Mon Sep 17 00:00:00 2001 From: Grygorii Strashko Date: Mon, 15 Apr 2024 11:49:23 +0300 Subject: [PATCH 13/13] boards: arm64: rpi_5: add xen specific doc Add Xen specific documentation. Signed-off-by: Grygorii Strashko --- boards/arm64/rpi_5/doc/index.rst | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/boards/arm64/rpi_5/doc/index.rst b/boards/arm64/rpi_5/doc/index.rst index c22c695a405d..99bf51879d6f 100644 --- a/boards/arm64/rpi_5/doc/index.rst +++ b/boards/arm64/rpi_5/doc/index.rst @@ -159,3 +159,35 @@ When you power on the Raspberry Pi 5, you will see the following output in the s .. _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