From eef70025c514cd5548fbfc2824485173f0992f52 Mon Sep 17 00:00:00 2001 From: Bluefooted Boobie Date: Sun, 22 Dec 2024 20:28:45 -0600 Subject: [PATCH 1/3] start work, based on https://github.com/AndrewFromMelbourne/raspberry_pi_revision/blob/master/raspberry_pi_revision.c --- rpi/rpi.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/rpi/rpi.go b/rpi/rpi.go index b149de7..f7cbe18 100644 --- a/rpi/rpi.go +++ b/rpi/rpi.go @@ -385,6 +385,7 @@ const ( memory2GB revisionCode = 3 << memoryShift memory4GB revisionCode = 4 << memoryShift memory8GB revisionCode = 5 << memoryShift + memory16GB revisionCode = 6 << memoryShift sonyUK revisionCode = 0 << manufacturerShift egoman revisionCode = 1 << manufacturerShift @@ -397,6 +398,7 @@ const ( bcm2836 revisionCode = 1 << processorShift bcm2837 revisionCode = 2 << processorShift bcm2711 revisionCode = 3 << processorShift + bcm2712 revisionCode = 4 << processorShift board1A revisionCode = 0x0 << boardShift board1B revisionCode = 0x1 << boardShift @@ -417,6 +419,11 @@ const ( boardZero2W revisionCode = 0x12 << boardShift board400 revisionCode = 0x13 << boardShift boardCM4 revisionCode = 0x14 << boardShift + boardCM4S revisionCode = 0x15 << boardShift + board5 revisionCode = 0x17 << boardShift + boardCM5 revisionCode = 0x18 << boardShift + board500 revisionCode = 0x19 << boardShift + boardCM5Lite revisionCode = 0x20 << boardShift ) // features represents the different features on various Raspberry Pi boards. @@ -514,6 +521,11 @@ func (f *features) init(v uint32) error { f.hdrHDMI = true case boardCM4: // Compute Module does not have a SODIMM header. + case board5: + f.hdrP1P40 = true + f.hdrAudio = true + f.audioLeft41 = true + f.hdrHDMI = true default: return fmt.Errorf("rpi: unknown hardware version: 0x%x", r) } From 276461501ef0da9764f3ae5e2e1e84d43628f92c Mon Sep 17 00:00:00 2001 From: Bluefooted Boobie Date: Sun, 22 Dec 2024 21:15:44 -0600 Subject: [PATCH 2/3] this isn't right yet, need to find datasheets, and this switch needs a lot more cases --- bcm283x/gpio.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/bcm283x/gpio.go b/bcm283x/gpio.go index 04e0992..8f56d33 100644 --- a/bcm283x/gpio.go +++ b/bcm283x/gpio.go @@ -1338,21 +1338,24 @@ func (d *driverGPIO) Init() (bool, error) { // Let's play safe here. dTCompatible := strings.Join(distro.DTCompatible(), " ") // Reference: https://www.raspberrypi.org/documentation/hardware/raspberrypi/peripheral_addresses.md - if strings.Contains(dTCompatible, "bcm2708") || - strings.Contains(dTCompatible, "bcm2835") { + switch { + case strings.Contains(dTCompatible, "bcm2708"), strings.Contains(dTCompatible, "bcm2835"): // RPi0/1. d.baseAddr = 0x20000000 d.dramBus = 0x40000000 d.useLegacyPull = true - } else if strings.Contains(dTCompatible, "bcm2709") || - strings.Contains(dTCompatible, "bcm2836") || - strings.Contains(dTCompatible, "bcm2710") || - strings.Contains(dTCompatible, "bcm2837") { + case strings.Contains(dTCompatible, "bcm2709"), strings.Contains(dTCompatible, "bcm2836"), strings.Contains(dTCompatible, "bcm2710"), strings.Contains(dTCompatible, "bcm2837"): // RPi2+ d.baseAddr = 0x3F000000 d.dramBus = 0xC0000000 d.useLegacyPull = true - } else { + case strings.Contains(dTCompatible, "bcm2712"): + // RPi5 + d.baseAddr = 0xFE000000 + d.dramBus = 0xC0000000 + d.useLegacyPull = false + mapping = mapping2711 + default: // RPi4B+ d.baseAddr = 0xFE000000 d.dramBus = 0xC0000000 @@ -1370,6 +1373,7 @@ func (d *driverGPIO) Init() (bool, error) { // virtual address space starting at address 0xF2000000. Thus a peripheral // advertised here at bus address 0x7Ennnnnn is available in the ARM kenel at // virtual address 0xF2nnnnnn. + d.gpioBaseAddr = d.baseAddr + 0x200000 // Mark the right pins as available even if the memory map fails so they can From 733237700967f1ee5bbd23dcf7ff9069c68a02de Mon Sep 17 00:00:00 2001 From: Bluefooted Boobie Date: Thu, 9 Jan 2025 10:28:42 -0600 Subject: [PATCH 3/3] docmument research --- bcm283x/gpio.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bcm283x/gpio.go b/bcm283x/gpio.go index 8f56d33..ad7ad8b 100644 --- a/bcm283x/gpio.go +++ b/bcm283x/gpio.go @@ -1350,7 +1350,7 @@ func (d *driverGPIO) Init() (bool, error) { d.dramBus = 0xC0000000 d.useLegacyPull = true case strings.Contains(dTCompatible, "bcm2712"): - // RPi5 + // RPi5 -- https://github.com/WiringPi/WiringPi/blob/master/wiringPi/wiringPi.c doesn't look optimistic d.baseAddr = 0xFE000000 d.dramBus = 0xC0000000 d.useLegacyPull = false