From ca8cce9a40572eb5c2d4ec800782a4aacc54d872 Mon Sep 17 00:00:00 2001 From: Matheus Castello Date: Thu, 12 Oct 2023 17:47:04 -0300 Subject: [PATCH] Meadow.Linux: Add support for Raspberry Pi 5 pinout The Raspberry Pi 5 pinout is quite different from the previous versions, so we need to add a new pinout class for it. It use a in house developed silicon for I/O, the RP1 I/O controller. It's comes with a new pinctrl driver that changed the sysfs base from 0 to 53 and the gpiochip bank from gpiochip0 to gpiochip4. However, reusing what we already have from previous versions of Raspberry Pi, we can support this simply by modifying the LinuxFlexiPin to allow changing the SysFsGpio and GpiodChip. Signed-off-by: Matheus Castello --- .../Hardware/Pinouts/RaspberryPi5.cs | 19 +++++++++++++++++++ .../linux/Meadow.Linux/SysFs/LinuxFlexiPin.cs | 4 ++-- 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 source/implementations/linux/Meadow.Linux/Hardware/Pinouts/RaspberryPi5.cs diff --git a/source/implementations/linux/Meadow.Linux/Hardware/Pinouts/RaspberryPi5.cs b/source/implementations/linux/Meadow.Linux/Hardware/Pinouts/RaspberryPi5.cs new file mode 100644 index 000000000..2dda704f7 --- /dev/null +++ b/source/implementations/linux/Meadow.Linux/Hardware/Pinouts/RaspberryPi5.cs @@ -0,0 +1,19 @@ +using Meadow.Hardware; +using System.Collections; +using System.Collections.Generic; + +namespace Meadow.Pinouts +{ + public class RaspberryPi5 : RaspberryPi + { + public RaspberryPi5() + { + // the sysfs base for the pinctrl-rpi1 is 53 + // the gpiochip bank for pinctrl-rpi1 on rpi5 is gpiochip4 + foreach (LinuxFlexiPin pin in this.AllPins) { + pin.SysFsGpio += 53; + pin.GpiodChip = "gpiochip4"; + } + } + } +} diff --git a/source/implementations/linux/Meadow.Linux/SysFs/LinuxFlexiPin.cs b/source/implementations/linux/Meadow.Linux/SysFs/LinuxFlexiPin.cs index 66549c4d7..822fefee5 100644 --- a/source/implementations/linux/Meadow.Linux/SysFs/LinuxFlexiPin.cs +++ b/source/implementations/linux/Meadow.Linux/SysFs/LinuxFlexiPin.cs @@ -11,11 +11,11 @@ public class LinuxFlexiPin : Pin /// /// The pin's sysfs GPIO number /// - public int SysFsGpio { get; } + public int SysFsGpio { get; internal set; } /// /// The chip name for the gpiod driver /// - public string GpiodChip { get; } + public string GpiodChip { get; internal set; } /// /// The pin offset for the gpiod driver ///