From 7f4e9de6d5ed1963f84bb10300d3ee0cc8121a66 Mon Sep 17 00:00:00 2001 From: Berkus Decker Date: Sat, 22 Jan 2022 02:13:41 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20Update=20BcmHost=20for=20rp?= =?UTF-8?q?i4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- machine/src/platform/rpi3/mod.rs | 75 ++++++++++++++++++++++++++++---- 1 file changed, 67 insertions(+), 8 deletions(-) diff --git a/machine/src/platform/rpi3/mod.rs b/machine/src/platform/rpi3/mod.rs index 38fab56..aba0b4b 100644 --- a/machine/src/platform/rpi3/mod.rs +++ b/machine/src/platform/rpi3/mod.rs @@ -19,11 +19,55 @@ pub mod vc; pub struct BcmHost; +// Per : +// +// SoC Peripheral Address Peripheral Size SDRAM Address Source +// BCM2835 0x20000000 0x01000000 0x40000000 +// BCM2836 0x3f000000 0x01000000 0xc0000000 +// BCM2837 0x3f000000 0x01000000 0xc0000000 +// BCM2711 0xfe000000 0x01800000 0xc0000000 + +// +// The BCM2835 is the Broadcom chip used in the Raspberry Pi Model A, B, B+, the Compute Module, and the Raspberry Pi Zero. +// The BCM2836 is used in the Raspberry Pi 2 Model B. +// The BCM2837 is used in the Raspberry Pi 3, and in later models of the Raspberry Pi 2. +// The BCM2837B0 is used in the Raspberry Pi 3B+ and 3A+. +// The BCM2711 is used in the Raspberry Pi 4 Model B. +// RP3A0 (BCM2710A1 — which is the die packaged inside the BCM2837 chip - Raspberry Pi 3) used in Raspberry Pi Zero 2 W + +// Machine Board Chip +// raspi1 raspi bcm2835 +// raspi1 raspi bcm2835 +// raspi3b+ raspi bcm2837 +// raspi4 raspi bcm2711 + impl BcmHost { + /// At which address to load the kernel binary. + pub const fn kernel_load_address() -> u64 { + 0x8_0000 + } + + /// As per + /// + pub fn bus2phys(bus: usize) -> usize { + bus & !0xc000_0000 + } + + pub fn phys2bus(phys: usize) -> usize { + phys | 0xc000_0000 + } +} + +// RasPi3B+ +#[cfg(feature = "rpi3")] +impl BcmHost { + /// Name of the hardware device this BcmHost is compiled for. + pub const fn board_name() -> &'static str { + "Raspberry Pi 3+" + } + /// This returns the ARM-side physical address where peripherals are mapped. /// - /// As per - /// BCM SOC could address only 1Gb of memory, so 0x4000_0000 is the high watermark. pub const fn get_peripheral_address() -> usize { 0x3f00_0000 } @@ -37,14 +81,29 @@ impl BcmHost { pub const fn get_sdram_address() -> usize { 0xc000_0000 // uncached } +} - /// As per - /// - pub fn bus2phys(bus: usize) -> usize { - bus & !0xc000_0000 +// RasPi4 +#[cfg(feature = "rpi4")] +impl BcmHost { + /// Name of the hardware device this BcmHost is compiled for. + pub const fn board_name() -> &'static str { + "Raspberry Pi 4+" } - pub fn phys2bus(phys: usize) -> usize { - phys | 0xc000_0000 + /// This returns the ARM-side physical address where peripherals are mapped. + /// + pub const fn get_peripheral_address() -> usize { + 0xfe00_0000 + } + + /// This returns the size of the peripherals' space. + pub const fn get_peripheral_size() -> usize { + 0x0180_0000 + } + + /// This returns the bus address of the SDRAM. + pub const fn get_sdram_address() -> usize { + 0xc000_0000 // uncached } }