Commit 49d63971 authored by Andrea della Porta's avatar Andrea della Porta Committed by Florian Fainelli
Browse files

misc: rp1: RaspberryPi RP1 misc driver

The RaspberryPi RP1 is a PCI multi function device containing
peripherals ranging from Ethernet to USB controller, I2C, SPI
and others.

Implement a bare minimum driver to operate the RP1, leveraging
actual OF based driver implementations for the on-board peripherals
by loading a devicetree overlay during driver probe if the RP1
node is not already present in the DT.

The peripherals are accessed by mapping MMIO registers starting
from PCI BAR1 region.

With the overlay approach we can achieve more generic and agnostic
approach to managing this chipset, being that it is a PCI endpoint
and could possibly be reused in other hw implementations. The
presented approach is also used by Bootlin's Microchip LAN966x
patchset (see link) as well, for a similar chipset.
In this case, the inclusion tree for the DT overlay is as follow
(the arrow points to the includer):

 rp1-pci.dtso <---- rp1-common.dtsi

On the other hand, to ensure compatibility with downstream, this
driver can also work with a DT already comprising the RP1 node, so
the dynamically loaded overlay will not be used if the DT is already
fully defined.

The reason why this driver is contained in drivers/misc has
been paved by Bootlin's LAN966X driver, which first used the
overlay approach to implement non discoverable peripherals behind a
PCI bus. For RP1, the same arguments apply: it's not used as an SoC
since the driver code is not running on-chip and is not like an MFD
since it does not really need all the MFD infrastructure (shared regs,
etc.). So, for this particular use, misc has been proposed and deemed
as a good choice. For further details about that please check the links.

This driver is heavily based on downstream code from RaspberryPi
Foundation, and the original author is Phil Elwell.

Link: https://datasheets.raspberrypi.com/rp1/rp1-peripherals.pdf
Link: https://lore.kernel.org/all/20240612140208.GC1504919@google.com/
Link: https://lore.kernel.org/all/83f7fa09-d0e6-4f36-a27d-cee08979be2a@app.fastmail.com/
Link: https://lore.kernel.org/all/2024081356-mutable-everyday-6f9d@gregkh/
Link: https://lore.kernel.org/all/20240808154658.247873-1-herve.codina@bootlin.com/



Signed-off-by: default avatarAndrea della Porta <andrea.porta@suse.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>   # quirks.c, pci_ids.h
Acked-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/r/20250529135052.28398-7-andrea.porta@suse.com


Signed-off-by: default avatarFlorian Fainelli <florian.fainelli@broadcom.com>
parent 4732f079
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -660,4 +660,5 @@ source "drivers/misc/pvpanic/Kconfig"
source "drivers/misc/mchp_pci1xxxx/Kconfig"
source "drivers/misc/keba/Kconfig"
source "drivers/misc/amd-sbi/Kconfig"
source "drivers/misc/rp1/Kconfig"
endmenu
+1 −0
Original line number Diff line number Diff line
@@ -75,3 +75,4 @@ lan966x-pci-objs += lan966x_pci.dtbo.o
obj-$(CONFIG_MCHP_LAN966X_PCI)	+= lan966x-pci.o
obj-y				+= keba/
obj-y				+= amd-sbi/
obj-$(CONFIG_MISC_RP1)		+= rp1/
+20 −0
Original line number Diff line number Diff line
# SPDX-License-Identifier: GPL-2.0-only
#
# RaspberryPi RP1 misc device
#

config MISC_RP1
	tristate "RaspberryPi RP1 misc device"
	depends on OF_IRQ && OF_OVERLAY && PCI_MSI && PCI_QUIRKS
	select PCI_DYNAMIC_OF_NODES
	help
	  Support the RP1 peripheral chip found on Raspberry Pi 5 board.

	  This device supports several sub-devices including e.g. Ethernet
	  controller, USB controller, I2C, SPI and UART.

	  The driver is responsible for enabling the DT node once the PCIe
	  endpoint has been configured, and handling interrupts.

	  This driver uses an overlay to load other drivers to support for
	  RP1 internal sub-devices.
+3 −0
Original line number Diff line number Diff line
# SPDX-License-Identifier: GPL-2.0-only
obj-$(CONFIG_MISC_RP1)		+= rp1-pci.o
rp1-pci-objs			:= rp1_pci.o rp1-pci.dtbo.o
+25 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: (GPL-2.0 OR MIT)

/*
 * The dts overlay is included from the dts directory so
 * it can be possible to check it with CHECK_DTBS while
 * also compile it from the driver source directory.
 */

/dts-v1/;
/plugin/;

/ {
	fragment@0 {
		target-path="";
		__overlay__ {
			compatible = "pci1de4,1";
			#address-cells = <3>;
			#size-cells = <2>;
			interrupt-controller;
			#interrupt-cells = <2>;

			#include "arm64/broadcom/rp1-common.dtsi"
		};
	};
};
Loading