Skip to content

Commit ad2a966

Browse files
cloudkucoolandBluefooted Boobie
andauthored
Initial support for more current Raspberry Pi models (i.e. 5) (#65)
* start work, based on https://github.com/AndrewFromMelbourne/raspberry_pi_revision/blob/master/raspberry_pi_revision.c * this isn't right yet, need to find datasheets, and this switch needs a lot more cases * docmument research --------- Co-authored-by: Bluefooted Boobie <scot@birdhouse>
1 parent 63e6b8c commit ad2a966

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

bcm283x/gpio.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,21 +1338,24 @@ func (d *driverGPIO) Init() (bool, error) {
13381338
// Let's play safe here.
13391339
dTCompatible := strings.Join(distro.DTCompatible(), " ")
13401340
// Reference: https://www.raspberrypi.org/documentation/hardware/raspberrypi/peripheral_addresses.md
1341-
if strings.Contains(dTCompatible, "bcm2708") ||
1342-
strings.Contains(dTCompatible, "bcm2835") {
1341+
switch {
1342+
case strings.Contains(dTCompatible, "bcm2708"), strings.Contains(dTCompatible, "bcm2835"):
13431343
// RPi0/1.
13441344
d.baseAddr = 0x20000000
13451345
d.dramBus = 0x40000000
13461346
d.useLegacyPull = true
1347-
} else if strings.Contains(dTCompatible, "bcm2709") ||
1348-
strings.Contains(dTCompatible, "bcm2836") ||
1349-
strings.Contains(dTCompatible, "bcm2710") ||
1350-
strings.Contains(dTCompatible, "bcm2837") {
1347+
case strings.Contains(dTCompatible, "bcm2709"), strings.Contains(dTCompatible, "bcm2836"), strings.Contains(dTCompatible, "bcm2710"), strings.Contains(dTCompatible, "bcm2837"):
13511348
// RPi2+
13521349
d.baseAddr = 0x3F000000
13531350
d.dramBus = 0xC0000000
13541351
d.useLegacyPull = true
1355-
} else {
1352+
case strings.Contains(dTCompatible, "bcm2712"):
1353+
// RPi5 -- https://github.com/WiringPi/WiringPi/blob/master/wiringPi/wiringPi.c doesn't look optimistic
1354+
d.baseAddr = 0xFE000000
1355+
d.dramBus = 0xC0000000
1356+
d.useLegacyPull = false
1357+
mapping = mapping2711
1358+
default:
13561359
// RPi4B+
13571360
d.baseAddr = 0xFE000000
13581361
d.dramBus = 0xC0000000
@@ -1370,6 +1373,7 @@ func (d *driverGPIO) Init() (bool, error) {
13701373
// virtual address space starting at address 0xF2000000. Thus a peripheral
13711374
// advertised here at bus address 0x7Ennnnnn is available in the ARM kenel at
13721375
// virtual address 0xF2nnnnnn.
1376+
13731377
d.gpioBaseAddr = d.baseAddr + 0x200000
13741378

13751379
// Mark the right pins as available even if the memory map fails so they can

rpi/rpi.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ const (
385385
memory2GB revisionCode = 3 << memoryShift
386386
memory4GB revisionCode = 4 << memoryShift
387387
memory8GB revisionCode = 5 << memoryShift
388+
memory16GB revisionCode = 6 << memoryShift
388389

389390
sonyUK revisionCode = 0 << manufacturerShift
390391
egoman revisionCode = 1 << manufacturerShift
@@ -397,6 +398,7 @@ const (
397398
bcm2836 revisionCode = 1 << processorShift
398399
bcm2837 revisionCode = 2 << processorShift
399400
bcm2711 revisionCode = 3 << processorShift
401+
bcm2712 revisionCode = 4 << processorShift
400402

401403
board1A revisionCode = 0x0 << boardShift
402404
board1B revisionCode = 0x1 << boardShift
@@ -417,6 +419,11 @@ const (
417419
boardZero2W revisionCode = 0x12 << boardShift
418420
board400 revisionCode = 0x13 << boardShift
419421
boardCM4 revisionCode = 0x14 << boardShift
422+
boardCM4S revisionCode = 0x15 << boardShift
423+
board5 revisionCode = 0x17 << boardShift
424+
boardCM5 revisionCode = 0x18 << boardShift
425+
board500 revisionCode = 0x19 << boardShift
426+
boardCM5Lite revisionCode = 0x20 << boardShift
420427
)
421428

422429
// features represents the different features on various Raspberry Pi boards.
@@ -514,6 +521,11 @@ func (f *features) init(v uint32) error {
514521
f.hdrHDMI = true
515522
case boardCM4:
516523
// Compute Module does not have a SODIMM header.
524+
case board5:
525+
f.hdrP1P40 = true
526+
f.hdrAudio = true
527+
f.audioLeft41 = true
528+
f.hdrHDMI = true
517529
default:
518530
return fmt.Errorf("rpi: unknown hardware version: 0x%x", r)
519531
}

0 commit comments

Comments
 (0)