Add support for RaspberryPi RP1 PCI device using a DT overlay
Subsystems (9)
Andrea della Porta
maintainerv8 cover Add support for RaspberryPi RP1 PCI device using a DT overlay
RP1 is an MFD chipset that acts as a south-bridge PCIe endpoint sporting a pletora of subdevices (i.e. Ethernet, USB host controller, I2C, PWM, etc.) whose registers are all reachable starting from an offset from the BAR address. The main point here is that while the RP1 as an endpoint itself is discoverable via usual PCI enumeraiton, the devices it contains are not discoverable and must be declared e.g. via the devicetree.
This patchset is an attempt to provide a minimum infrastructure to allow the RP1 chipset to be discovered and perpherals it contains to be added from a devictree overlay loaded during RP1 PCI endpoint enumeration. To ensure compatibility with downstream, a devicetree already comprising the RP1 node is also provided, so it's not strictly necessary to use the dynamically loaded overlay if the devicetree is already fully defined at the origin.
To achieve this modularity, the RP1 node DT definitions are arranged by file inclusion as per following schema (the arrow points to the includer, see also [9]):
rp1-pci.dtso rp1.dtso
^ ^
| |rp1-common.dtsi ----> rp1-nexus.dtsi ----> bcm2712-rpi-5-b-monolithic.dts
^
|
bcm2712-rpi-5-b.dtsFollowup patches should add support for the several peripherals contained in RP1.
This work is based upon dowstream drivers code and the proposal from RH et al. (see [1] and [2]). A similar approach is also pursued in [3].
The patches are ordered as follows:
-PATCHES 1 to 4: add binding schemas for clock, gpio and RP1 peripherals.
They are needed to support the other peripherals, e.g. the ethernet mac depends on a clock generated by RP1 and the phy is reset through the on-board gpio controller.
-PATCH 5 and 6: add clock and gpio device drivers.
-PATCH 7: the devicetree node describing the RP1 chipset. Please
note that this patch should be taken by the same maintainer that will also take patch 8, since the definition it contains is possibly used by the dtso compiled in as binary blob and is closely coupled to the driver.
-PATCH 8: this is the main patch to support RP1 chipset. It can work
either with a fully defined devicetree (i.e. one that already included the rp1 node since boot time) or with a runtime loaded dtb overlay which is linked as binary blob in the driver obj. This duality is useful to comply with both downstream and upstream needs (see [9]). The real dtso is in devicetree folder while the dtso in driver folder is just a placeholder to include the real dtso.
In this way it is possible to check the dtso against dt-bindings. The reason why drivers/misc has been selected as containing folder for this driver can be seen in [6], [7] and [8].
-PATCH 9: the fully fledged devictree containing also the rp1 node.
This devicetree is similar to the one downstream is using.
-PATCH 10 (OPTIONAL): this patch introduces a new scenario about how
the rp1 node is specified and loaded in DT. On top of the base DT (without rp1 node), the fw loads this overlay and the end result is the same devicetree as in patch 9, which is then passed to the next stage (either the kernel or u-boot/bootloader).
While this patch is not strictly necessary and can therefore be dropped (see [10]), it's not introducing much extra work and maybe can come in handy while debugging.
-PATCH 11: add the external clock node (used by RP1) to the main dts.
-PATCH 12: add the relevant kernel CONFIG_ options to defconfig.
-PATCH 13: enable CONFIG_OF_OVERLAY in order for 'make defconfig'
to produce a configuration valid for the RP1 driver. Without this patch, the user has to explicitly enable it since the misc driver depends on OF_OVERLAY.
This patchset is also a first attempt to be more agnostic wrt hardware description standards such as OF devicetree and ACPI, where 'agnostic' means "using DT in coexistence with ACPI", as been already promoted by e.g. AL (see [4]). Although there's currently no evidence it will also run out of the box on purely ACPI system, it is a first step towards that direction.
Many thanks,
Andrea della Porta
Links:
- [1]: https://lpc.events/event/17/contributions/1421/attachments/1337/2680/LPC2023%20Non-discoverable%20devices%20in%20PCI.pdf
- [2]: https://lore.kernel.org/lkml/[email protected]/t/
- [3]: https://lore.kernel.org/all/[email protected]/#t
- [4]: https://lore.kernel.org/all/[email protected]/
- [5]: https://lore.kernel.org/all/[email protected]/
- [6]: https://lore.kernel.org/all/[email protected]/
- [7]: https://lore.kernel.org/all/[email protected]/
- [8]: https://lore.kernel.org/all/2024081356-mutable-everyday-6f9d@gregkh/
- [9]: https://lore.kernel.org/all/Z87wTfChRC5Ruwc0@apocalypse/
- [10]: https://lore.kernel.org/all/CAMEGJJ0f4YUgdWBhxvQ_dquZHztve9KO7pvQjoDWJ3=zd3cgcg@mail.gmail.com/#t
CHANGES IN V8
PATCH RELATED -------------------------------------------------
- This cover letter and patch 8 commit messages now have more details explaining the new DT include files organization.
- Added two new patches numbered 9 and 10 respectively dealing with the new DT inclusion schema.
BINDINGS ------------------------------------------------------
- Modified maintainer first name for get_maintainer.pl to be able to retrieve the entire name correctly from the .yaml files. As a consequence, MAINTAINERS file does not need an entry for schemas anymore.
- pci1de4,1.yaml: Added a statement about the ints activation type for rp1 peripherals: only level high or rising edge are supported since they all are active high only.
RP1 PINCTRL DRIVER ---------------------------------
- Added GPIOCHIP_IRQ_RESOURCE_HELPERS.
RP1 CLOCK DRIVER ------------------------------------
- Added PLL_DIV_INVALID to denote invalid values in pll_sec_div_table[].
- Dropped some empty lines.
- Changed TODO comment to better reflect the intent
- Changed a WARN() into WARN_ONCE() to prevent flooding
- Fixed the hard limit condition "rate > 4000000000ll" in rp1_clock_set_rate_and_parent() to "rate > data->max_freq", in order to check against the limit specific for that clock.
- Style change: dropped an empty line
RP1 MISC DRIVER -----------------------------------
- rp1_pci.c: Added a suitable dev_err() warning in case of_platform_default_populate() fails.
- rp1_pci.c: Fixed the mismatching %d vs %u in dev_dbg().
- rp1_pci.c: Changed the error string printed on pci_alloc_irq_vectors() failure, plus minor cosmetic changes such as capitalization of error strings.
- rp1_pci.c: Changed dev_err() to dev_err_probe() where appropriate.
- rp1_pci.c: Updated the year in the top header copyright notice, also added a newline between lines. Also, changed the error string 'Not initialised' to 'Not initialized'.
- rp1_pci.c: Changed MODULE_DESCRIPTION() string to match the one in Kconfig.
- rp1-pci.dtso: Minor change to the top header comment to unify the multi-line comment style.
- Kconfig: Changed description in the header comment to match the description in the tristate option.
Andrea della Porta (13):
dt-bindings: clock: Add RaspberryPi RP1 clock bindings
dt-bindings: pinctrl: Add RaspberryPi RP1 gpio/pinctrl/pinmux bindings
dt-bindings: pci: Add common schema for devices accessible through PCI
BARs
dt-bindings: misc: Add device specific bindings for RaspberryPi RP1
clk: rp1: Add support for clocks provided by RP1
pinctrl: rp1: Implement RaspberryPi RP1 gpio support
arm64: dts: rp1: Add support for RaspberryPi's RP1 device
misc: rp1: RaspberryPi RP1 misc driver
arm64: dts: Add board DTS for Rpi5 which includes RP1 node
arm64: dts: Add overlay for RP1 device
arm64: dts: bcm2712: Add external clock for RP1 chipset on Rpi5
arm64: defconfig: Enable RP1 misc/clock/gpio drivers
arm64: defconfig: Enable OF_OVERLAY option
.../clock/raspberrypi,rp1-clocks.yaml | 58 + .../devicetree/bindings/misc/pci1de4,1.yaml | 137 ++ .../devicetree/bindings/pci/pci-ep-bus.yaml | 58 + .../pinctrl/raspberrypi,rp1-gpio.yaml | 198 +++ MAINTAINERS | 8 + arch/arm64/boot/dts/broadcom/Makefile | 4 +- .../broadcom/bcm2712-rpi-5-b-monolithic.dts | 8 + .../boot/dts/broadcom/bcm2712-rpi-5-b.dts | 7 + arch/arm64/boot/dts/broadcom/rp1-common.dtsi | 42 + arch/arm64/boot/dts/broadcom/rp1-nexus.dtsi | 14 + arch/arm64/boot/dts/broadcom/rp1.dtso | 11 + arch/arm64/configs/defconfig | 4 + drivers/clk/Kconfig | 9 + drivers/clk/Makefile | 1 + drivers/clk/clk-rp1.c | 1512 +++++++++++++++++ drivers/misc/Kconfig | 1 + drivers/misc/Makefile | 1 + drivers/misc/rp1/Kconfig | 20 + drivers/misc/rp1/Makefile | 3 + drivers/misc/rp1/rp1-pci.dtso | 25 + drivers/misc/rp1/rp1_pci.c | 333 ++++ drivers/pci/quirks.c | 1 + drivers/pinctrl/Kconfig | 11 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/pinctrl-rp1.c | 790 +++++++++ .../clock/raspberrypi,rp1-clocks.h | 61 + include/linux/pci_ids.h | 3 + 27 files changed, 3320 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml create mode 100644 Documentation/devicetree/bindings/misc/pci1de4,1.yaml create mode 100644 Documentation/devicetree/bindings/pci/pci-ep-bus.yaml create mode 100644 Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml create mode 100644 arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b-monolithic.dts create mode 100644 arch/arm64/boot/dts/broadcom/rp1-common.dtsi create mode 100644 arch/arm64/boot/dts/broadcom/rp1-nexus.dtsi create mode 100644 arch/arm64/boot/dts/broadcom/rp1.dtso create mode 100644 drivers/clk/clk-rp1.c create mode 100644 drivers/misc/rp1/Kconfig create mode 100644 drivers/misc/rp1/Makefile create mode 100644 drivers/misc/rp1/rp1-pci.dtso create mode 100644 drivers/misc/rp1/rp1_pci.c create mode 100644 drivers/pinctrl/pinctrl-rp1.c create mode 100644 include/dt-bindings/clock/raspberrypi,rp1-clocks.h
Signature · 1 line
2.35.3
Andrea della Porta
maintainerPATCH v8 1/13 dt-bindings: clock: Add RaspberryPi RP1 clock bindings
Add device tree bindings for the clock generator found in RP1 multi function device, and relative entries in MAINTAINERS file.
--- .../clock/raspberrypi,rp1-clocks.yaml | 58 ++++++++++++++++++ .../clock/raspberrypi,rp1-clocks.h | 61 +++++++++++++++++++ 2 files changed, 119 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml create mode 100644 include/dt-bindings/clock/raspberrypi,rp1-clocks.h
Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml new file +58 -0
@@ -0,0 +1,58 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/clock/raspberrypi,rp1-clocks.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: RaspberryPi RP1 clock generator + +maintainers: + - A. della Porta <[email protected]> + +description: | + The RP1 contains a clock generator designed as three PLLs (CORE, AUDIO, + VIDEO), and each PLL output can be programmed through dividers to generate + the clocks to drive the sub-peripherals embedded inside the chipset. + + Link to datasheet: + https://datasheets.raspberrypi.com/rp1/rp1-peripherals.pdf + +properties: + compatible: + const: raspberrypi,rp1-clocks + + reg: + maxItems: 1 + + '#clock-cells': + const: 1 + description: + The available clocks are defined in + include/dt-bindings/clock/raspberrypi,rp1-clocks.h. + + clocks: + maxItems: 1 + +required: + - compatible + - reg + - '#clock-cells' + - clocks + +additionalProperties: false + +examples: + - | + #include <dt-bindings/clock/raspberrypi,rp1-clocks.h> + + rp1 { + #address-cells = <2>; + #size-cells = <2>; + + clocks@c040018000 { + compatible = "raspberrypi,rp1-clocks"; + reg = <0xc0 0x40018000 0x0 0x10038>; + #clock-cells = <1>; + clocks = <&clk_rp1_xosc>; + }; + };
include/dt-bindings/clock/raspberrypi,rp1-clocks.h new file +61 -0
61 lines not on this page · raw message
Signature · 1 line
2.35.3
Andrea della Porta
maintainerPATCH v8 2/13 dt-bindings: pinctrl: Add RaspberryPi RP1 gpio/pinctrl/pinmux bindings
In reply to Andrea della PortaAdd device tree bindings for the gpio/pin/mux controller that is part of the RP1 multi function device, and relative entries in MAINTAINERS file.
--- .../pinctrl/raspberrypi,rp1-gpio.yaml | 198 ++++++++++++++++++ 1 file changed, 198 insertions(+) create mode 100644 Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml
Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml new file +198 -0
@@ -0,0 +1,198 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pinctrl/raspberrypi,rp1-gpio.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: RaspberryPi RP1 GPIO/Pinconf/Pinmux Controller submodule + +maintainers: + - A. della Porta <[email protected]> + +description: + The RP1 chipset is a Multi Function Device containing, among other + sub-peripherals, a gpio/pinconf/mux controller whose 54 pins are grouped + into 3 banks. + It works also as an interrupt controller for those gpios. + +properties: + compatible: + const: raspberrypi,rp1-gpio + + reg: + maxItems: 3 + description: One reg specifier for each one of the 3 pin banks. + + '#gpio-cells': + description: The first cell is the pin number and the second cell is used + to specify the flags (see include/dt-bindings/gpio/gpio.h). + const: 2 + + gpio-controller: true + + gpio-ranges: + maxItems: 1 + + gpio-line-names: + maxItems: 54 + + interrupts: + maxItems: 3 + description: One interrupt specifier for each one of the 3 pin banks. + + '#interrupt-cells': + description: + Specifies the Bank number [0, 1, 2] and Flags as defined in + include/dt-bindings/interrupt-controller/irq.h. + const: 2 + + interrupt-controller: true + +patternProperties: + '-state$': + oneOf: + - $ref: '#/$defs/raspberrypi-rp1-state' + - patternProperties: + '-pins$': + $ref: '#/$defs/raspberrypi-rp1-state' + additionalProperties: false + +$defs: + raspberrypi-rp1-state: + allOf: + - $ref: pincfg-node.yaml# + - $ref: pinmux-node.yaml# + + description: + Pin controller client devices use pin configuration subnodes (children + and grandchildren) for desired pin configuration. + Client device subnodes use below standard properties. + + properties: + pins: + description: + List of gpio pins affected by the properties specified in this + subnode. + items: + pattern: '^gpio([0-9]|[1-4][0-9]|5[0-3])$' + + function: + enum: [ alt0, alt1, alt2, alt3, alt4, gpio, alt6, alt7, alt8, none, + aaud, dcd0, dpi, dsi0_te_ext, dsi1_te_ext, dsr0, dtr0, gpclk0, + gpclk1, gpclk2, gpclk3, gpclk4, gpclk5, i2c0, i2c1, i2c2, i2c3, + i2c4, i2c5, i2c6, i2s0, i2s1, i2s2, ir, mic, pcie_clkreq_n, + pio, proc_rio, pwm0, pwm1, ri0, sd0, sd1, spi0, spi1, spi2, + spi3, spi4, spi5, spi6, spi7, spi8, uart0, uart1, uart2, uart3, + uart4, uart5, vbus0, vbus1, vbus2, vbus3 ] + + description: + Specify the alternative function to be configured for the specified + pins. + + bias-disable: true + bias-pull-down: true + bias-pull-up: true + input-enable: true + input-schmitt-enable: true + output-enable: true + output-high: true + output-low: true + slew-rate: + description: 0 is slow slew rate, 1 is fast slew rate + enum: [ 0, 1 ] + drive-strength: + enum: [ 2, 4, 8, 12 ] + + additionalProperties: false + +allOf: + - $ref: pinctrl.yaml# + +required: + - reg + - compatible + - '#gpio-cells' + - gpio-controller + - interrupts + - '#interrupt-cells' + - interrupt-controller + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + + rp1 { + #address-cells = <2>; + #size-cells = <2>; + + rp1_gpio: pinctrl@c0400d0000 { + reg = <0xc0 0x400d0000 0x0 0xc000>, + <0xc0 0x400e0000 0x0 0xc000>, + <0xc0 0x400f0000 0x0 0xc000>; + compatible = "raspberrypi,rp1-gpio"; + gpio-controller; + #gpio-cells = <2>; + interrupt-controller; + #interrupt-cells = <2>; + interrupts = <0 IRQ_TYPE_LEVEL_HIGH>, + <1 IRQ_TYPE_LEVEL_HIGH>, + <2 IRQ_TYPE_LEVEL_HIGH>; + gpio-line-names = + "ID_SDA", // GPIO0 + "ID_SCL", // GPIO1 + "GPIO2", "GPIO3", "GPIO4", "GPIO5", "GPIO6", + "GPIO7", "GPIO8", "GPIO9", "GPIO10", "GPIO11", + "GPIO12", "GPIO13", "GPIO14", "GPIO15", "GPIO16", + "GPIO17", "GPIO18", "GPIO19", "GPIO20", "GPIO21", + "GPIO22", "GPIO23", "GPIO24", "GPIO25", "GPIO26", + "GPIO27", + "PCIE_RP1_WAKE", // GPIO28 + "FAN_TACH", // GPIO29 + "HOST_SDA", // GPIO30 + "HOST_SCL", // GPIO31 + "ETH_RST_N", // GPIO32 + "", // GPIO33 + "CD0_IO0_MICCLK", // GPIO34 + "CD0_IO0_MICDAT0", // GPIO35 + "RP1_PCIE_CLKREQ_N", // GPIO36 + "", // GPIO37 + "CD0_SDA", // GPIO38 + "CD0_SCL", // GPIO39 + "CD1_SDA", // GPIO40 + "CD1_SCL", // GPIO41 + "USB_VBUS_EN", // GPIO42 + "USB_OC_N", // GPIO43 + "RP1_STAT_LED", // GPIO44 + "FAN_PWM", // GPIO45 + "CD1_IO0_MICCLK", // GPIO46 + "2712_WAKE", // GPIO47 + "CD1_IO1_MICDAT1", // GPIO48 + "EN_MAX_USB_CUR", // GPIO49 + "", // GPIO50 + "", // GPIO51 + "", // GPIO52 + ""; // GPIO53 + + rp1-i2s0-default-state { + function = "i2s0"; + pins = "gpio18", "gpio19", "gpio20", "gpio21"; + bias-disable; + }; + + rp1-uart0-default-state { + txd-pins { + function = "uart0"; + pins = "gpio14"; + bias-disable; + }; + + rxd-pins { + function = "uart0"; + pins = "gpio15"; + bias-pull-up; + }; + }; + }; + };
Signature · 1 line
2.35.3
Andrea della Porta
maintainerPATCH v8 3/13 dt-bindings: pci: Add common schema for devices accessible through PCI BARs
In reply to Andrea della PortaCommon YAML schema for devices that exports internal peripherals through PCI BARs. The BARs are exposed as simple-buses through which the peripherals can be accessed.
This is not intended to be used as a standalone binding, but should be included by device specific bindings.
--- .../devicetree/bindings/pci/pci-ep-bus.yaml | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/pci-ep-bus.yaml
Documentation/devicetree/bindings/pci/pci-ep-bus.yaml new file +58 -0
@@ -0,0 +1,58 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pci/pci-ep-bus.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Common Properties for PCI MFD EP with Peripherals Addressable from BARs + +maintainers: + - A. della Porta <[email protected]> + +description: + Define a generic node representing a PCI endpoint which contains several sub- + peripherals. The peripherals can be accessed through one or more BARs. + This common schema is intended to be referenced from device tree bindings, and + does not represent a device tree binding by itself. + +properties: + '#address-cells': + const: 3 + + '#size-cells': + const: 2 + + ranges: + minItems: 1 + maxItems: 6 + items: + maxItems: 8 + additionalItems: true + items: + - maximum: 5 # The BAR number + - const: 0 + - const: 0 + +patternProperties: + '^pci-ep-bus@[0-5]$': + type: object + description: + One node for each BAR used by peripherals contained in the PCI endpoint. + Each node represent a bus on which peripherals are connected. + This allows for some segmentation, e.g. one peripheral is accessible + through BAR0 and another through BAR1, and you don't want the two + peripherals to be able to act on the other BAR. Alternatively, when + different peripherals need to share BARs, you can define only one node + and use 'ranges' property to map all the used BARs. + + additionalProperties: true + + properties: + compatible: + const: simple-bus + + required: + - compatible + +additionalProperties: true +...
Signature · 1 line
2.35.3
Andrea della Porta
maintainerPATCH v8 4/13 dt-bindings: misc: Add device specific bindings for RaspberryPi RP1
In reply to Andrea della PortaThe RP1 is a MFD that exposes its peripherals through PCI BARs. This schema is intended as minimal support for the clock generator and gpio controller peripherals which are accessible through BAR1.
--- .../devicetree/bindings/misc/pci1de4,1.yaml | 137 ++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 Documentation/devicetree/bindings/misc/pci1de4,1.yaml
Documentation/devicetree/bindings/misc/pci1de4,1.yaml new file +137 -0
@@ -0,0 +1,137 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/misc/pci1de4,1.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: RaspberryPi RP1 MFD PCI device + +maintainers: + - A. della Porta <[email protected]> + +description: + The RaspberryPi RP1 is a PCI multi function device containing + peripherals ranging from Ethernet to USB controller, I2C, SPI + and others. + The peripherals are accessed by addressing the PCI BAR1 region. + +allOf: + - $ref: /schemas/pci/pci-ep-bus.yaml + +properties: + compatible: + additionalItems: true + maxItems: 3 + items: + - const: pci1de4,1 + + '#interrupt-cells': + const: 2 + description: | + Specifies respectively the interrupt number and flags as defined + in include/dt-bindings/interrupt-controller/irq.h. + Since all interrupts are active high, only IRQ_TYPE_LEVEL_HIGH + and IRQ_TYPE_EDGE_RISING can be specified as type flags. + The supported values for the interrupt number are: + - IO BANK0: 0 + - IO BANK1: 1 + - IO BANK2: 2 + - AUDIO IN: 3 + - AUDIO OUT: 4 + - PWM0: 5 + - ETH: 6 + - I2C0: 7 + - I2C1: 8 + - I2C2: 9 + - I2C3: 10 + - I2C4: 11 + - I2C5: 12 + - I2C6: 13 + - I2S0: 14 + - I2S1: 15 + - I2S2: 16 + - SDIO0: 17 + - SDIO1: 18 + - SPI0: 19 + - SPI1: 20 + - SPI2: 21 + - SPI3: 22 + - SPI4: 23 + - SPI5: 24 + - UART0: 25 + - TIMER0: 26 + - TIMER1: 27 + - TIMER2: 28 + - TIMER3: 29 + - USB HOST0: 30 + - USB HOST0-0: 31 + - USB HOST0-1: 32 + - USB HOST0-2: 33 + - USB HOST0-3: 34 + - USB HOST1: 35 + - USB HOST1-0: 36 + - USB HOST1-1: 37 + - USB HOST1-2: 38 + - USB HOST1-3: 39 + - DMA: 40 + - PWM1: 41 + - UART1: 42 + - UART2: 43 + - UART3: 44 + - UART4: 45 + - UART5: 46 + - MIPI0: 47 + - MIPI1: 48 + - VIDEO OUT: 49 + - PIO0: 50 + - PIO1: 51 + - ADC FIFO: 52 + - PCIE OUT: 53 + - SPI6: 54 + - SPI7: 55 + - SPI8: 56 + - PROC MISC: 57 + - SYSCFG: 58 + - CLOCKS DEFAULT: 59 + - VBUSCTRL: 60 + + interrupt-controller: true + +unevaluatedProperties: false + +required: + - compatible + - '#interrupt-cells' + - interrupt-controller + - pci-ep-bus@1 + +examples: + - | + pci { + #address-cells = <3>; + #size-cells = <2>; + + rp1@0,0 { + compatible = "pci1de4,1"; + ranges = <0x01 0x00 0x00000000 0x82010000 0x00 0x00 0x00 0x400000>; + #address-cells = <3>; + #size-cells = <2>; + interrupt-controller; + #interrupt-cells = <2>; + + pci_ep_bus: pci-ep-bus@1 { + compatible = "simple-bus"; + ranges = <0x00 0x40000000 0x01 0x00 0x00000000 0x00 0x00400000>; + dma-ranges = <0x10 0x00000000 0x43000000 0x10 0x00000000 0x10 0x00000000>; + #address-cells = <2>; + #size-cells = <2>; + + rp1_clocks: clocks@40018000 { + compatible = "raspberrypi,rp1-clocks"; + reg = <0x00 0x40018000 0x0 0x10038>; + #clock-cells = <1>; + clocks = <&clk_rp1_xosc>; + }; + }; + }; + };
Signature · 1 line
2.35.3
Andrea della Porta
maintainerPATCH v8 5/13 clk: rp1: Add support for clocks provided by RP1
In reply to Andrea della PortaRaspberryPi RP1 is an MFD providing, among other peripherals, several clock generators and PLLs that drives the sub-peripherals. Add the driver to support the clock providers.
--- MAINTAINERS | 5 + drivers/clk/Kconfig | 9 + drivers/clk/Makefile | 1 + drivers/clk/clk-rp1.c | 1512 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 1527 insertions(+) create mode 100644 drivers/clk/clk-rp1.c
MAINTAINERS +5 -0
@@ -19748,6 +19748,11 @@ S: Maintained F: Documentation/devicetree/bindings/media/raspberrypi,rp1-cfe.yaml F: drivers/media/platform/raspberrypi/rp1-cfe/ +RASPBERRY PI RP1 PCI DRIVER +M: Andrea della Porta <[email protected]> +S: Maintained +F: drivers/clk/clk-rp1.c + RC-CORE / LIRC FRAMEWORK M: Sean Young <[email protected]> L: [email protected]
drivers/clk/Kconfig +9 -0
@@ -88,6 +88,15 @@ config COMMON_CLK_RK808 These multi-function devices have two fixed-rate oscillators, clocked at 32KHz each. Clkout1 is always on, Clkout2 can off by control register. +config COMMON_CLK_RP1 + tristate "Raspberry Pi RP1-based clock support" + depends on MISC_RP1 || COMPILE_TEST + default MISC_RP1 + help + Enable common clock framework support for Raspberry Pi RP1. + This multi-function device has 3 main PLLs and several clock + generators to drive the internal sub-peripherals. + config COMMON_CLK_HI655X tristate "Clock driver for Hi655x" if EXPERT depends on (MFD_HI655X_PMIC || COMPILE_TEST)
drivers/clk/Makefile +1 -0
@@ -84,6 +84,7 @@ obj-$(CONFIG_CLK_LS1028A_PLLDIG) += clk-plldig.o obj-$(CONFIG_COMMON_CLK_PWM) += clk-pwm.o obj-$(CONFIG_CLK_QORIQ) += clk-qoriq.o obj-$(CONFIG_COMMON_CLK_RK808) += clk-rk808.o +obj-$(CONFIG_COMMON_CLK_RP1) += clk-rp1.o obj-$(CONFIG_COMMON_CLK_HI655X) += clk-hi655x.o obj-$(CONFIG_COMMON_CLK_S2MPS11) += clk-s2mps11.o obj-$(CONFIG_COMMON_CLK_SCMI) += clk-scmi.o
drivers/clk/clk-rp1.c new file +1512 -0
1,512 lines not on this page · raw message
Signature · 1 line
2.35.3
Andrea della Porta
maintainerPATCH v8 6/13 pinctrl: rp1: Implement RaspberryPi RP1 gpio support
In reply to Andrea della PortaThe RP1 is an MFD supporting a gpio controller and /pinmux/pinctrl. Add minimum support for the gpio only portion. The driver is in pinctrl folder since upcoming patches will add the pinmux/pinctrl support where the gpio part can be seen as an addition.
--- MAINTAINERS | 1 + drivers/pinctrl/Kconfig | 11 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/pinctrl-rp1.c | 790 ++++++++++++++++++++++++++++++++++ 4 files changed, 803 insertions(+) create mode 100644 drivers/pinctrl/pinctrl-rp1.c
MAINTAINERS +1 -0
@@ -19752,6 +19752,7 @@ RASPBERRY PI RP1 PCI DRIVER M: Andrea della Porta <[email protected]> S: Maintained F: drivers/clk/clk-rp1.c +F: drivers/pinctrl/pinctrl-rp1.c RC-CORE / LIRC FRAMEWORK M: Sean Young <[email protected]>
drivers/pinctrl/Kconfig +11 -0
@@ -612,6 +612,17 @@ config PINCTRL_MLXBF3 each pin. This driver can also be built as a module called pinctrl-mlxbf3. +config PINCTRL_RP1 + tristate "Pinctrl driver for RP1" + depends on MISC_RP1 + default MISC_RP1 + select PINMUX + select PINCONF + select GENERIC_PINCONF + help + Enable the gpio and pinctrl/mux driver for RaspberryPi RP1 + multi function device. + source "drivers/pinctrl/actions/Kconfig" source "drivers/pinctrl/aspeed/Kconfig" source "drivers/pinctrl/bcm/Kconfig"
drivers/pinctrl/Makefile +1 -0
@@ -48,6 +48,7 @@ obj-$(CONFIG_PINCTRL_PIC32) += pinctrl-pic32.o obj-$(CONFIG_PINCTRL_PISTACHIO) += pinctrl-pistachio.o obj-$(CONFIG_PINCTRL_RK805) += pinctrl-rk805.o obj-$(CONFIG_PINCTRL_ROCKCHIP) += pinctrl-rockchip.o +obj-$(CONFIG_PINCTRL_RP1) += pinctrl-rp1.o obj-$(CONFIG_PINCTRL_SCMI) += pinctrl-scmi.o obj-$(CONFIG_PINCTRL_SINGLE) += pinctrl-single.o obj-$(CONFIG_PINCTRL_ST) += pinctrl-st.o
drivers/pinctrl/pinctrl-rp1.c new file +790 -0
790 lines not on this page · raw message
Signature · 1 line
2.35.3
Andrea della Porta
maintainerPATCH v8 7/13 arm64: dts: rp1: Add support for RaspberryPi's RP1 device
In reply to Andrea della PortaRaspberryPi RP1 is a multi function PCI endpoint device that exposes several subperipherals via PCI BAR.
Add a dtb overlay that will be compiled into a binary blob and linked in the RP1 driver.
This overlay offers just minimal support to represent the RP1 device itself, the sub-peripherals will be added by future patches.
--- MAINTAINERS | 1 + arch/arm64/boot/dts/broadcom/rp1-common.dtsi | 42 ++++++++++++++++++++ arch/arm64/boot/dts/broadcom/rp1-nexus.dtsi | 14 +++++++ 3 files changed, 57 insertions(+) create mode 100644 arch/arm64/boot/dts/broadcom/rp1-common.dtsi create mode 100644 arch/arm64/boot/dts/broadcom/rp1-nexus.dtsi
MAINTAINERS +1 -0
@@ -19751,6 +19751,7 @@ F: drivers/media/platform/raspberrypi/rp1-cfe/ RASPBERRY PI RP1 PCI DRIVER M: Andrea della Porta <[email protected]> S: Maintained +F: arch/arm64/boot/dts/broadcom/rp1*.dts* F: drivers/clk/clk-rp1.c F: drivers/pinctrl/pinctrl-rp1.c
arch/arm64/boot/dts/broadcom/rp1-common.dtsi new file +42 -0
42 lines not on this page · raw message
arch/arm64/boot/dts/broadcom/rp1-nexus.dtsi new file +14 -0
@@ -0,0 +1,14 @@ +// SPDX-License-Identifier: (GPL-2.0 OR MIT) + +rp1_nexus { + compatible = "pci1de4,1"; + #address-cells = <3>; + #size-cells = <2>; + ranges = <0x01 0x00 0x00000000 + 0x02000000 0x00 0x00000000 + 0x0 0x400000>; + interrupt-controller; + #interrupt-cells = <2>; + + #include "rp1-common.dtsi" +};
Signature · 1 line
2.35.3
Andrea della Porta
maintainerPATCH v8 8/13 misc: rp1: RaspberryPi RP1 misc driver
In reply to Andrea della PortaThe 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.
--- MAINTAINERS | 1 + drivers/misc/Kconfig | 1 + drivers/misc/Makefile | 1 + drivers/misc/rp1/Kconfig | 20 ++ drivers/misc/rp1/Makefile | 3 + drivers/misc/rp1/rp1-pci.dtso | 25 +++ drivers/misc/rp1/rp1_pci.c | 333 ++++++++++++++++++++++++++++++++++ drivers/pci/quirks.c | 1 + include/linux/pci_ids.h | 3 + 9 files changed, 388 insertions(+) create mode 100644 drivers/misc/rp1/Kconfig create mode 100644 drivers/misc/rp1/Makefile create mode 100644 drivers/misc/rp1/rp1-pci.dtso create mode 100644 drivers/misc/rp1/rp1_pci.c
MAINTAINERS +1 -0
@@ -19753,6 +19753,7 @@ M: Andrea della Porta <[email protected]> S: Maintained F: arch/arm64/boot/dts/broadcom/rp1*.dts* F: drivers/clk/clk-rp1.c +F: drivers/misc/rp1/ F: drivers/pinctrl/pinctrl-rp1.c RC-CORE / LIRC FRAMEWORK
drivers/misc/Kconfig +1 -0
@@ -649,4 +649,5 @@ source "drivers/misc/uacce/Kconfig" source "drivers/misc/pvpanic/Kconfig" source "drivers/misc/mchp_pci1xxxx/Kconfig" source "drivers/misc/keba/Kconfig" +source "drivers/misc/rp1/Kconfig" endmenu
drivers/misc/Makefile +1 -0
@@ -75,3 +75,4 @@ lan966x-pci-objs := lan966x_pci.o lan966x-pci-objs += lan966x_pci.dtbo.o obj-$(CONFIG_MCHP_LAN966X_PCI) += lan966x-pci.o obj-y += keba/ +obj-$(CONFIG_MISC_RP1) += rp1/
drivers/misc/rp1/Kconfig new file +20 -0
@@ -0,0 +1,20 @@ +# 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.
drivers/misc/rp1/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0-only +obj-$(CONFIG_MISC_RP1) += rp1-pci.o +rp1-pci-objs := rp1_pci.o rp1-pci.dtbo.o
drivers/misc/rp1/rp1-pci.dtso new file +25 -0
@@ -0,0 +1,25 @@ +// 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" + }; + }; +};
drivers/misc/rp1/rp1_pci.c new file +333 -0
333 lines not on this page · raw message
drivers/pci/quirks.c +1 -0
@@ -6283,6 +6283,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_XILINX, 0x5020, of_pci_make_dev_node);DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_XILINX ,0x5021 , of_pci_make_dev_node);DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_REDHAT ,0x0005 , of_pci_make_dev_node);DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_EFAR ,0x9660 , of_pci_make_dev_node); +DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_RPI ,PCI_DEVICE_ID_RPI_RP1_C0 , of_pci_make_dev_node);/* * Devices known to require a longer delay before first config space access
include/linux/pci_ids.h +3 -0
@@ -2620,6 +2620,9 @@#define PCI_VENDOR_ID_TEKRAM 0x1de1#define PCI_DEVICE_ID_TEKRAM_DC290 0xdc29 +#define PCI_VENDOR_ID_RPI 0x1de4 +#define PCI_DEVICE_ID_RPI_RP1_C0 0x0001 +#define PCI_VENDOR_ID_ALIBABA 0x1ded#define PCI_VENDOR_ID_CXL 0x1e98
Signature · 1 line
2.35.3
Andrea della Porta
maintainerPATCH v8 9/13 arm64: dts: Add board DTS for Rpi5 which includes RP1 node
In reply to Andrea della PortaAdd the board 'monolithic' DTS for RaspberryPi 5 which includes the RP1 node definition. The inclusion treeis as follow (the arrow points to the includer):
rp1-common.dtsi ----> rp1-nexus.dtsi ----> bcm2712-rpi-5-b-monolithic.dts
^
|
bcm2712-rpi-5-b.dtsThis is designed to maximize the compatibility with downstream DT while ensuring that a fully defined DT (one which includes the RP1 node as opposed to load it from overlay at runtime) is present since early boot stage.
---
Right now bcm2712-rpi-5-b.dts is the overlay-ready DT which will make the RP1 driver to load the RP1 dtb overlay at runtime, while bcm2712-rpi-5-b-monolithic.dts is the fully defined one (i.e. it already contains RP1 node, so no overlay is loaded nor needed). Depending on which one we want to be considered the default, we can swap the file names to align with downstream naming convention that has only the fully defined DT called bcm2712-rpi-5-b.dts.
--- arch/arm64/boot/dts/broadcom/Makefile | 1 + .../boot/dts/broadcom/bcm2712-rpi-5-b-monolithic.dts | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b-monolithic.dts
arch/arm64/boot/dts/broadcom/Makefile +1 -0
@@ -7,6 +7,7 @@ dtb-$(CONFIG_ARCH_BCM2835) += bcm2711-rpi-400.dtb \ bcm2711-rpi-4-b.dtb \ bcm2711-rpi-cm4-io.dtb \ bcm2712-rpi-5-b.dtb \ + bcm2712-rpi-5-b-monolithic.dtb \ bcm2712-d-rpi-5-b.dtb \ bcm2837-rpi-3-a-plus.dtb \ bcm2837-rpi-3-b.dtb \
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b-monolithic.dts new file +8 -0
@@ -0,0 +1,8 @@ +// SPDX-License-Identifier: (GPL-2.0 OR MIT) +/dts-v1/; + +#include "bcm2712-rpi-5-b.dts" + +&pcie2 { + #include "rp1-nexus.dtsi" +};
Signature · 1 line
2.35.3
Andrea della Porta
maintainerPATCH v8 10/13 arm64: dts: Add overlay for RP1 device
In reply to Andrea della PortaDefine the RP1 node in an overlay. The inclusion tree is as follow (the arrow points to the includer):
rp1.dtso
^
|rp1-common.dtsi ----> rp1-nexus.dtsi
---
This patch can be considered optional, since it fills just the second scenario as detailed in [1], which is the RP1 DT node loaded from a dtb overlay by the FW at early boot stage.
This may be useful for debug purpose, but as such not strictly necessary.
[1] https://lore.kernel.org/all/CAMEGJJ0f4YUgdWBhxvQ_dquZHztve9KO7pvQjoDWJ3=zd3cgcg@mail.gmail.com/#t
--- arch/arm64/boot/dts/broadcom/Makefile | 3 ++- arch/arm64/boot/dts/broadcom/rp1.dtso | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 arch/arm64/boot/dts/broadcom/rp1.dtso
arch/arm64/boot/dts/broadcom/Makefile +2 -1
@@ -13,7 +13,8 @@ dtb-$(CONFIG_ARCH_BCM2835) += bcm2711-rpi-400.dtb \ bcm2837-rpi-3-b.dtb \ bcm2837-rpi-3-b-plus.dtb \ bcm2837-rpi-cm3-io3.dtb \ - bcm2837-rpi-zero-2-w.dtb + bcm2837-rpi-zero-2-w.dtb \ + rp1.dtbo subdir-y += bcmbca subdir-y += northstar2
arch/arm64/boot/dts/broadcom/rp1.dtso new file +11 -0
@@ -0,0 +1,11 @@ +// SPDX-License-Identifier: (GPL-2.0 OR MIT) + +/dts-v1/; +/plugin/; + +&pcie2 { + #address-cells = <3>; + #size-cells = <2>; + + #include "rp1-nexus.dtsi" +};
Signature · 1 line
2.35.3
Andrea della Porta
maintainerPATCH v8 11/13 arm64: dts: bcm2712: Add external clock for RP1 chipset on Rpi5
In reply to Andrea della PortaThe RP1 found on Raspberry Pi 5 board needs an external crystal at 50MHz. Add clk_rp1_xosc node to provide that.
--- arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts | 7 +++++++ 1 file changed, 7 insertions(+)
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts +7 -0
@@ -16,6 +16,13 @@ chosen: chosen { stdout-path = "serial10:115200n8"; }; + clk_rp1_xosc: clock-50000000 { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-output-names = "rp1-xosc"; + clock-frequency = <50000000>; + }; + /* Will be filled by the bootloader */ memory@0 { device_type = "memory";
Signature · 1 line
2.35.3
Andrea della Porta
maintainerPATCH v8 12/13 arm64: defconfig: Enable RP1 misc/clock/gpio drivers
In reply to Andrea della PortaSelect the RP1 drivers needed to operate the PCI endpoint containing several peripherals such as Ethernet and USB Controller. This chip is present on RaspberryPi 5.
--- arch/arm64/configs/defconfig | 3 +++ 1 file changed, 3 insertions(+)
arch/arm64/configs/defconfig +3 -0
@@ -618,6 +618,7 @@ CONFIG_PINCTRL_QCS615=y CONFIG_PINCTRL_QCS8300=y CONFIG_PINCTRL_QDF2XXX=y CONFIG_PINCTRL_QDU1000=y +CONFIG_PINCTRL_RP1=m CONFIG_PINCTRL_SA8775P=y CONFIG_PINCTRL_SC7180=y CONFIG_PINCTRL_SC7280=y
@@ -700,6 +701,7 @@ CONFIG_SENSORS_RASPBERRYPI_HWMON=m CONFIG_SENSORS_SL28CPLD=m CONFIG_SENSORS_INA2XX=m CONFIG_SENSORS_INA3221=m +CONFIG_MISC_RP1=m CONFIG_THERMAL_GOV_POWER_ALLOCATOR=y CONFIG_CPU_THERMAL=y CONFIG_DEVFREQ_THERMAL=y
@@ -1289,6 +1291,7 @@ CONFIG_COMMON_CLK_CS2000_CP=y CONFIG_COMMON_CLK_FSL_SAI=y CONFIG_COMMON_CLK_S2MPS11=y CONFIG_COMMON_CLK_PWM=y +CONFIG_COMMON_CLK_RP1=m CONFIG_COMMON_CLK_RS9_PCIE=y CONFIG_COMMON_CLK_VC3=y CONFIG_COMMON_CLK_VC5=y
Signature · 1 line
2.35.3
Andrea della Porta
maintainerPATCH v8 13/13 arm64: defconfig: Enable OF_OVERLAY option
In reply to Andrea della PortaThe RP1 driver uses the infrastructure enabled by OF_OVERLAY config option. Enable that option in defconfig in order to produce a kernel usable on RaspberryPi5 avoiding to enable it separately.
---
The following metrics should help to decide whether this patch is acceptable or not. The defconfig kernel with CONFIG_OF_OVERLAY=y added (wrt to the defconfig one without that set) has:
- same uncompressed kernel image size (due to ELF section alignment I guess)
- ~7Kb bigger Image.gz
- 3 new modules (all related to RP1, i.e.: clk-rp1, pinctrl-rp1 and rp1-pci)
- 27 added symbols, of which 5 exported
hoping this is enough to gather a rough idea of the impact. Please note that OF_OVERLAY has to be defined in a way or another, otherwise the RP1 driver won't work correctly in case the dtb overlay embedded into the driver is used.
Another way would be to add a phony target to the arm64 makefile which just add that config option to the target.
--- arch/arm64/configs/defconfig | 1 + 1 file changed, 1 insertion(+)
arch/arm64/configs/defconfig +1 -0
@@ -1643,6 +1643,7 @@ CONFIG_FPGA_BRIDGE=m CONFIG_ALTERA_FREEZE_BRIDGE=m CONFIG_FPGA_REGION=m CONFIG_OF_FPGA_REGION=m +CONFIG_OF_OVERLAY=y CONFIG_TEE=y CONFIG_OPTEE=y CONFIG_MUX_GPIO=m
Signature · 1 line
2.35.3
Krzysztof Wilczynski
AppliedRe: [PATCH v8 03/13] dt-bindings: pci: Add common schema for devices accessible through PCI BARs
In reply to Andrea della PortaHello,
Quoted 6 lines
Common YAML schema for devices that exports internal peripherals through PCI BARs. The BARs are exposed as simple-buses through which the peripherals can be accessed.
This is not intended to be used as a standalone binding, but should be included by device specific bindings.
Applied to dt-bindings, thank you!
Krzysztof
Re: [PATCH v8 08/13] misc: rp1: RaspberryPi RP1 misc driver
In reply to Andrea della PortaHello,
Thank you for sending new version. Appreciated.
Quoted 4 lines
drivers/misc/rp1/rp1_pci.c new file +4
-0+case IRQ_TYPE_LEVEL_HIGH : +dev_dbg (&rp1->pdev->dev,"MSIX IACK EN for irq %u\n" , hwirq); +msix_cfg_set (rp1, hwirq,MSIX_CFG_IACK_EN ); + rp1->level_triggered_irq[hwirq] = true;
[...]
drivers/misc/rp1/rp1_pci.c line 271
Quoted 5 lines
drivers/misc/rp1/rp1_pci.c new file +5
-0+if (!irq) { +dev_err (&pdev->dev,"Failed to create irq mapping\n" ); + err = -EINVAL ; + goto err_unregister_interrupts; + }
A small nitpick: "IRQ" in both of the above. Not a blocker, though, so feel free to ignore this feedback.
Krzysztof
Andrea della Porta
maintainerRe: [PATCH v8 08/13] misc: rp1: RaspberryPi RP1 misc driver
Hi Krzysztof,
Quoted 10 lines · Krzysztof Wilczynski
Hello,
Thank you for sending new version. Appreciated.
Quoted 4 lines
drivers/misc/rp1/rp1_pci.c new file +4
-0+case IRQ_TYPE_LEVEL_HIGH : +dev_dbg (&rp1->pdev->dev,"MSIX IACK EN for irq %u\n" , hwirq); +msix_cfg_set (rp1, hwirq,MSIX_CFG_IACK_EN ); + rp1->level_triggered_irq[hwirq] = true;[...]
Quoted 8 lines
drivers/misc/rp1/rp1_pci.c line 271
Quoted 5 lines
drivers/misc/rp1/rp1_pci.c new file +5
-0+if (!irq) { +dev_err (&pdev->dev,"Failed to create irq mapping\n" ); + err = -EINVAL ; + goto err_unregister_interrupts; + }A small nitpick: "IRQ" in both of the above. Not a blocker, though, so feel free to ignore this feedback.
Ack.
Many thanks,
Andrea
Quoted 2 lines
Krzysztof
Andrea della Porta
maintainerHi,
Quoted 7 lines · Andrea della Porta
RP1 is an MFD chipset that acts as a south-bridge PCIe endpoint sporting a pletora of subdevices (i.e. Ethernet, USB host controller, I2C, PWM, etc.) whose registers are all reachable starting from an offset from the BAR address. The main point here is that while the RP1 as an endpoint itself is discoverable via usual PCI enumeraiton, the devices it contains are not discoverable and must be declared e.g. via the devicetree.
...
since there has been no feedback for a while, a gentle reminder about this patchset.
Several patches have at least one Reviewed-by tag, with the exception of:
- PATCH 5, 8: those are, respectively, the driver for RP1 clock and misc core which have no major rework since the inception.
- PATCH 9, 10: those are new patches, where the most relevant change is a rearrangement of the dts include hierarchy to be flexible enough to support both the dtb overlay approach and the monolithic dtb.
- PATCH 13: just enables OF_OVERLAY config option. Some metric data have been added to help evaluating the impact.
Many thanks,
Andrea
Re: [PATCH v8 10/13] arm64: dts: Add overlay for RP1 device
In reply to Andrea della PortaHi Andrea,
just a nit. Could you please add "broadcom:" to the subject?
Am 19.03.25 um 22:52 schrieb Andrea della Porta:
Quoted 53 lines
Define the RP1 node in an overlay. The inclusion tree is as follow (the arrow points to the includer):
rp1.dtso ^ |
rp1-common.dtsi---->rp1-nexus.dtsiSigned-off-by Andrea della Porta <[email protected]>---
This patch can be considered optional, since it fills just the second scenario as detailed in [1], which is the RP1 DT node loaded from a dtb overlay by the FW at early boot stage.
This may be useful for debug purpose, but as such not strictly necessary.[1] https://lore.kernel.org/all/CAMEGJJ0f4YUgdWBhxvQ_dquZHztve9KO7pvQjoDWJ3=zd3cgcg@mail.gmail.com/#t
--- arch/arm64/boot/dts/broadcom/Makefile | 3 ++- arch/arm64/boot/dts/broadcom/rp1.dtso | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-)create mode 100644
arch/arm64/boot/dts/broadcom/rp1.dtsoarch/arm64/boot/dts/broadcom/Makefile +2
-1@@ -13,7 +13,8 @@ dtb-$(CONFIG_ARCH_BCM2835) += bcm2711-rpi-400.dtb \ bcm2837-rpi-3-b.dtb \ bcm2837-rpi-3-b-plus.dtb \ bcm2837-rpi-cm3-io3.dtb \ - bcm2837-rpi-zero-2-w.dtb + bcm2837-rpi-zero-2-w.dtb \ + rp1.dtbo subdir-y += bcmbca subdir-y += northstar2arch/arm64/boot/dts/broadcom/rp1.dtso new file +11
-0@@ -0,0 +1,11 @@ +// SPDX-License-Identifier: (GPL-2.0 OR MIT) + +/dts-v1/; +/plugin/; + +&pcie2 { + #address-cells = <3>; + #size-cells = <2>; + + #include "rp1-nexus.dtsi" +};
Re: [PATCH v8 09/13] arm64: dts: Add board DTS for Rpi5 which includes RP1 node
In reply to Andrea della PortaHi Andrea,
Am 19.03.25 um 22:52 schrieb Andrea della Porta:
Quoted 8 lines
Add the board 'monolithic' DTS for RaspberryPi 5 which includes the RP1 node definition. The inclusion treeis as follow (the arrow points to the includer):
rp1-common.dtsi---->rp1-nexus.dtsi---->bcm2712-rpi-5-b-monolithic.dts^ | bcm2712-rpi-5-b.dts
sorry for the delay. I'm not happy with the monolithic appendix.
How about bcm2712-rpi-5-b-rp1.dts or something more self-explaining?Regards
Quoted 6 lines
This is designed to maximize the compatibility with downstream DT while ensuring that a fully defined DT (one which includes the RP1 node as opposed to load it from overlay at runtime) is present since early boot stage.
Signed-off-by Andrea della Porta <[email protected]>
Quoted 8 lines
---
Right nowbcm2712-rpi-5-b.dtsis the overlay-ready DT which will make the RP1 driver to load the RP1 dtb overlay at runtime, whilebcm2712-rpi-5-b-monolithic.dtsis the fully defined one (i.e. it already contains RP1 node, so no overlay is loaded nor needed). Depending on which one we want to be considered the default, we can swap the file names to align with downstream naming convention that has only the fully defined DT calledbcm2712-rpi-5-b.dts.
Could you please move some of this good explanation into this dts file as comment?
Quoted 32 lines
--- arch/arm64/boot/dts/broadcom/Makefile | 1 + .../boot/dts/broadcom/bcm2712-rpi-5-b-monolithic.dts | 8 ++++++++ 2 files changed, 9 insertions(+)create mode 100644
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b-monolithic.dtsarch/arm64/boot/dts/broadcom/Makefile +1
-0@@ -7,6 +7,7 @@ dtb-$(CONFIG_ARCH_BCM2835) += bcm2711-rpi-400.dtb \ bcm2711-rpi-4-b.dtb \ bcm2711-rpi-cm4-io.dtb \ bcm2712-rpi-5-b.dtb \ + bcm2712-rpi-5-b-monolithic.dtb \ bcm2712-d-rpi-5-b.dtb \ bcm2837-rpi-3-a-plus.dtb \ bcm2837-rpi-3-b.dtb \arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b-monolithic.dts new file +8
-0@@ -0,0 +1,8 @@ +// SPDX-License-Identifier: (GPL-2.0 OR MIT) +/dts-v1/; + +#include "bcm2712-rpi-5-b.dts" + +&pcie2 { + #include "rp1-nexus.dtsi" +};
Re: [PATCH v8 13/13] arm64: defconfig: Enable OF_OVERLAY option
In reply to Andrea della PortaAm 19.03.25 um 22:52 schrieb Andrea della Porta:
Quoted 5 lines
The RP1 driver uses the infrastructure enabled by
OF_OVERLAYconfig option. Enable that option in defconfig in order to produce a kernel usable on RaspberryPi5 avoiding to enable it separately.Signed-off-by Andrea della Porta <[email protected]>
Re: [PATCH v8 11/13] arm64: dts: bcm2712: Add external clock for RP1 chipset on Rpi5
In reply to Andrea della PortaHi Andrea,
Am 19.03.25 um 22:52 schrieb Andrea della Porta:
Quoted 5 lines
The RP1 found on Raspberry Pi 5 board needs an external crystal at 50MHz. Add
clk_rp1_xoscnode to provide that.Signed-off-by Andrea della Porta <[email protected]>Reviewed-by Florian Fainelli <[email protected]>
i'm fine with the patch content, but I think this is necessary before Patch 9 is applied?
Quoted 22 lines
--- arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts | 7 +++++++ 1 file changed, 7 insertions(+)arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts +7
-0@@ -16,6 +16,13 @@ chosen: chosen { stdout-path = "serial10:115200n8"; }; + clk_rp1_xosc: clock-50000000 { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-output-names = "rp1-xosc"; + clock-frequency = <50000000>; + }; + /* Will be filled by the bootloader */ memory@0 { device_type = "memory";
Re: [PATCH v8 05/13] clk: rp1: Add support for clocks provided by RP1
In reply to Andrea della PortaHi Andrea,
Am 19.03.25 um 22:52 schrieb Andrea della Porta:
Quoted 68 lines
RaspberryPi RP1 is an MFD providing, among other peripherals, several clock generators and PLLs that drives the sub-peripherals. Add the driver to support the clock providers.
Signed-off-by Andrea della Porta <[email protected]>--- MAINTAINERS | 5 + drivers/clk/Kconfig | 9 + drivers/clk/Makefile | 1 + drivers/clk/clk-rp1.c | 1512 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 1527 insertions(+)create mode 100644
drivers/clk/clk-rp1.cMAINTAINERS +5
-0@@ -19748,6 +19748,11 @@ S: Maintained F: Documentation/devicetree/bindings/media/raspberrypi,rp1-cfe.yaml F: drivers/media/platform/raspberrypi/rp1-cfe/ +RASPBERRY PI RP1 PCI DRIVER +M: Andrea della Porta <[email protected]> +S: Maintained +F: drivers/clk/clk-rp1.c + RC-CORE / LIRC FRAMEWORK M: Sean Young <[email protected]> L: [email protected]drivers/clk/Kconfig +9
-0@@ -88,6 +88,15 @@ config COMMON_CLK_RK808 These multi-function devices have two fixed-rate oscillators, clocked at 32KHz each. Clkout1 is always on, Clkout2 can off by control register. +config COMMON_CLK_RP1 + tristate "Raspberry Pi RP1-based clock support" + depends on MISC_RP1 || COMPILE_TEST + default MISC_RP1 + help + Enable common clock framework support for Raspberry Pi RP1. + This multi-function device has 3 main PLLs and several clock + generators to drive the internal sub-peripherals. + config COMMON_CLK_HI655X tristate "Clock driver for Hi655x" if EXPERT depends on (MFD_HI655X_PMIC || COMPILE_TEST)drivers/clk/Makefile +1
-0@@ -84,6 +84,7 @@ obj-$(CONFIG_CLK_LS1028A_PLLDIG) += clk-plldig.o obj-$(CONFIG_COMMON_CLK_PWM) += clk-pwm.o obj-$(CONFIG_CLK_QORIQ) += clk-qoriq.o obj-$(CONFIG_COMMON_CLK_RK808) += clk-rk808.o +obj-$(CONFIG_COMMON_CLK_RP1) += clk-rp1.o obj-$(CONFIG_COMMON_CLK_HI655X) += clk-hi655x.o obj-$(CONFIG_COMMON_CLK_S2MPS11) += clk-s2mps11.o obj-$(CONFIG_COMMON_CLK_SCMI) += clk-scmi.odrivers/clk/clk-rp1.c new file +1
-0@@ -0,0 +1,1512 @@ +// SPDX-License-Identifier: GPL-2.0
...
Quoted 13 lines
drivers/clk/clk-rp1.c new file +13
-0+ +static int rp1_pll_divider_set_rate (struct clk_hw *hw, +unsigned long rate, +unsigned long parent_rate) +{ + struct rp1_clk_desc *divider = container_of(hw, struct rp1_clk_desc, div.hw); +struct rp1_clockman *clockman = divider->clockman; +const struct rp1_pll_data *data = divider->data; +u32 div, sec; + + div =DIV_ROUND_UP_ULL (parent_rate, rate); + div =clamp (div,8u ,19u ); +
drivers/clk/clk-rp1.c line 745
Quoted 10 lines
drivers/clk/clk-rp1.c new file +10
-0+spin_lock (&clockman->regs_lock); + sec =clockman_read (clockman, data->ctrl_reg); + sec &= ~PLL_SEC_DIV_MASK ; + sec |=FIELD_PREP (PLL_SEC_DIV_MASK , div); + +/* Must keep the divider in reset to change the value. */ + sec |=PLL_SEC_RST ; +clockman_write (clockman, data->ctrl_reg, sec); + +/* TODO: must sleep 10 pll vco cycles */
Is it possible to implement this with some kind of xsleep or xdelay?
Quoted 8 lines
drivers/clk/clk-rp1.c new file +7
-0+ sec &= ~PLL_SEC_RST ; +clockman_write (clockman, data->ctrl_reg, sec); +spin_unlock (&clockman->regs_lock); + +return 0 ; +} +
Greg Kroah-Hartman
maintainerRe: [PATCH v8 08/13] misc: rp1: RaspberryPi RP1 misc driver
In reply to Andrea della PortaQuoted 3 lines · Andrea della Porta
The RaspberryPi RP1 is a PCI multi function device containing peripherals ranging from Ethernet to USB controller, I2C, SPI and others.
So shouldn't this be using the auxbus code? That's designed to "split up" PCI devices such that you can share them this way.
Or did that get rejected somewhere previously?
thanks,
greg k-h
Re: [PATCH v8 08/13] misc: rp1: RaspberryPi RP1 misc driver
Hi Greg,
Quoted 10 lines · On Tue, 15 Apr 2025 16:06:43 +0200 Greg Kroah-Hartman…
Quoted 3 lines · Andrea della Porta
The RaspberryPi RP1 is a PCI multi function device containing peripherals ranging from Ethernet to USB controller, I2C, SPI and others.
So shouldn't this be using the auxbus code? That's designed to "split up" PCI devices such that you can share them this way.
Or did that get rejected somewhere previously?
It doesn't use auxbus probably for the exact same reason that the one given for the LAN966x PCI device driver [0] and [1].
Avoid all boiler plate needed with auxbus whereas drivers already exist as platform drivers. Internal devices are handled by those platform drivers. Those devi just need to be described as platform devices and device-tree is fully relevant for that description.
[0] https://lore.kernel.org/all/CAL_Jsq+1r3SSaXupdNAcXO-4rcV-_3_hwh0XJaBsB9fuX5nBCQ@mail.gmail.com/
[1] https://lore.kernel.org/all/[email protected]/
Best regards,
Hervé
Greg Kroah-Hartman
maintainerRe: [PATCH v8 08/13] misc: rp1: RaspberryPi RP1 misc driver
Quoted 19 lines · Herve Codina
Hi Greg,
Quoted 10 lines · On Tue, 15 Apr 2025 16:06:43 +0200 Greg Kroah-Hartman…
Quoted 3 lines · Andrea della Porta
The RaspberryPi RP1 is a PCI multi function device containing peripherals ranging from Ethernet to USB controller, I2C, SPI and others.
So shouldn't this be using the auxbus code? That's designed to "split up" PCI devices such that you can share them this way.
Or did that get rejected somewhere previously?
It doesn't use auxbus probably for the exact same reason that the one given for the LAN966x PCI device driver [0] and [1].
Quoted 7 lines
Avoid all boiler plate needed with auxbus whereas drivers already exist as platform drivers. Internal devices are handled by those platform drivers. Those devi just need to be described as platform devices and device-tree is fully relevant for that description.
[0] https://lore.kernel.org/all/CAL_Jsq+1r3SSaXupdNAcXO-4rcV-_3_hwh0XJaBsB9fuX5nBCQ@mail.gmail.com/
[1] https://lore.kernel.org/all/[email protected]/
I really hate creating platform devices below a PCI device, so I'll keep complaining about this every time people try to do it.
thanks,
greg k-h
Andrea della Porta
maintainerRe: [PATCH v8 08/13] misc: rp1: RaspberryPi RP1 misc driver
Hi Greg,
Quoted 25 lines · Greg Kroah-Hartman
Quoted 24 lines · Herve Codina
Hi Greg,
Quoted 10 lines · On Tue, 15 Apr 2025 16:06:43 +0200 Greg Kroah-Hartman…
Quoted 3 lines · Andrea della Porta
The RaspberryPi RP1 is a PCI multi function device containing peripherals ranging from Ethernet to USB controller, I2C, SPI and others.
So shouldn't this be using the auxbus code? That's designed to "split up" PCI devices such that you can share them this way.
Or did that get rejected somewhere previously?
It doesn't use auxbus probably for the exact same reason that the one given for the LAN966x PCI device driver [0] and [1].
Avoid all boiler plate needed with auxbus whereas drivers already exist as platform drivers. Internal devices are handled by those platform drivers. Those devi just need to be described as platform devices and device-tree is fully relevant for that description.
Quoted 5 lines
Quoted 2 lines
[0] https://lore.kernel.org/all/CAL_Jsq+1r3SSaXupdNAcXO-4rcV-_3_hwh0XJaBsB9fuX5nBCQ@mail.gmail.com/
[1] https://lore.kernel.org/all/[email protected]/I really hate creating platform devices below a PCI device, so I'll keep complaining about this every time people try to do it.
I agree with you, but as Herve has already pointed out this would mean incurring in significant work to adapt drivers for all the peripherals (there are quite a few), while with this approach they would be left untouched.
Many thanks,
Andrea
Quoted 4 lines
thanks,
greg k-h
Greg Kroah-Hartman
maintainerRe: [PATCH v8 08/13] misc: rp1: RaspberryPi RP1 misc driver
Quoted 31 lines · Andrea della Porta
Hi Greg,
Quoted 28 lines · Greg Kroah-Hartman
Quoted 26 lines · Herve Codina
Hi Greg,
Quoted 10 lines · On Tue, 15 Apr 2025 16:06:43 +0200 Greg Kroah-Hartman…
Quoted 3 lines · Andrea della Porta
The RaspberryPi RP1 is a PCI multi function device containing peripherals ranging from Ethernet to USB controller, I2C, SPI and others.
So shouldn't this be using the auxbus code? That's designed to "split up" PCI devices such that you can share them this way.
Or did that get rejected somewhere previously?
It doesn't use auxbus probably for the exact same reason that the one given for the LAN966x PCI device driver [0] and [1].
Avoid all boiler plate needed with auxbus whereas drivers already exist as platform drivers. Internal devices are handled by those platform drivers. Those devi just need to be described as platform devices and device-tree is fully relevant for that description.
[0] https://lore.kernel.org/all/CAL_Jsq+1r3SSaXupdNAcXO-4rcV-_3_hwh0XJaBsB9fuX5nBCQ@mail.gmail.com/
[1] https://lore.kernel.org/all/[email protected]/
Quoted 6 lines
Quoted 2 lines
I really hate creating platform devices below a PCI device, so I'll keep complaining about this every time people try to do it.
I agree with you, but as Herve has already pointed out this would mean incurring in significant work to adapt drivers for all the peripherals (there are quite a few), while with this approach they would be left untouched.
We have no problem with reworking existing drivers, especially if they will be doing the correct thing. Don't let that be an excuse, it doesn't work with me, sorry :)
greg k-h
Rob Herring
maintainerRe: [PATCH v8 08/13] misc: rp1: RaspberryPi RP1 misc driver
Quoted 36 lines · Greg Kroah-Hartman
Quoted 34 lines · Andrea della Porta
Hi Greg,
Quoted 30 lines · Greg Kroah-Hartman
Quoted 19 lines · Herve Codina
Hi Greg,
Quoted 10 lines · On Tue, 15 Apr 2025 16:06:43 +0200 Greg Kroah-Hartman…
Quoted 3 lines · Andrea della Porta
The RaspberryPi RP1 is a PCI multi function device containing peripherals ranging from Ethernet to USB controller, I2C, SPI and others.
So shouldn't this be using the auxbus code? That's designed to "split up" PCI devices such that you can share them this way.
Or did that get rejected somewhere previously?
It doesn't use auxbus probably for the exact same reason that the one given for the LAN966x PCI device driver [0] and [1].
Quoted 7 lines
Avoid all boiler plate needed with auxbus whereas drivers already exist as platform drivers. Internal devices are handled by those platform drivers. Those devi just need to be described as platform devices and device-tree is fully relevant for that description.
[0] https://lore.kernel.org/all/CAL_Jsq+1r3SSaXupdNAcXO-4rcV-_3_hwh0XJaBsB9fuX5nBCQ@mail.gmail.com/
[1] https://lore.kernel.org/all/[email protected]/I really hate creating platform devices below a PCI device, so I'll keep complaining about this every time people try to do it.
Quoted 7 lines
Quoted 3 lines
I agree with you, but as Herve has already pointed out this would mean incurring in significant work to adapt drivers for all the peripherals (there are quite a few), while with this approach they would be left untouched.
We have no problem with reworking existing drivers, especially if they will be doing the correct thing. Don't let that be an excuse, it doesn't work with me, sorry :)
Let me resurrect of_platform_bus so we can stop repeating the same conversation... MMIO based devices using DT (and ACPI) are platform devices. There is no other answer in the kernel today.
Rob
Andrea della Porta
maintainerRe: [PATCH v8 05/13] clk: rp1: Add support for clocks provided by RP1
In reply to Stefan WahrenHi Stefan,
Quoted 88 lines · Stefan Wahren
Hi Andrea,
Am 19.03.25 um 22:52 schrieb Andrea della Porta:
Quoted 68 lines
RaspberryPi RP1 is an MFD providing, among other peripherals, several clock generators and PLLs that drives the sub-peripherals. Add the driver to support the clock providers.
Signed-off-by Andrea della Porta <[email protected]>--- MAINTAINERS | 5 + drivers/clk/Kconfig | 9 + drivers/clk/Makefile | 1 + drivers/clk/clk-rp1.c | 1512 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 1527 insertions(+)create mode 100644
drivers/clk/clk-rp1.cMAINTAINERS +5
-0@@ -19748,6 +19748,11 @@ S: Maintained F: Documentation/devicetree/bindings/media/raspberrypi,rp1-cfe.yaml F: drivers/media/platform/raspberrypi/rp1-cfe/ +RASPBERRY PI RP1 PCI DRIVER +M: Andrea della Porta <[email protected]> +S: Maintained +F: drivers/clk/clk-rp1.c + RC-CORE / LIRC FRAMEWORK M: Sean Young <[email protected]> L: [email protected]drivers/clk/Kconfig +9
-0@@ -88,6 +88,15 @@ config COMMON_CLK_RK808 These multi-function devices have two fixed-rate oscillators, clocked at 32KHz each. Clkout1 is always on, Clkout2 can off by control register. +config COMMON_CLK_RP1 + tristate "Raspberry Pi RP1-based clock support" + depends on MISC_RP1 || COMPILE_TEST + default MISC_RP1 + help + Enable common clock framework support for Raspberry Pi RP1. + This multi-function device has 3 main PLLs and several clock + generators to drive the internal sub-peripherals. + config COMMON_CLK_HI655X tristate "Clock driver for Hi655x" if EXPERT depends on (MFD_HI655X_PMIC || COMPILE_TEST)drivers/clk/Makefile +1
-0@@ -84,6 +84,7 @@ obj-$(CONFIG_CLK_LS1028A_PLLDIG) += clk-plldig.o obj-$(CONFIG_COMMON_CLK_PWM) += clk-pwm.o obj-$(CONFIG_CLK_QORIQ) += clk-qoriq.o obj-$(CONFIG_COMMON_CLK_RK808) += clk-rk808.o +obj-$(CONFIG_COMMON_CLK_RP1) += clk-rp1.o obj-$(CONFIG_COMMON_CLK_HI655X) += clk-hi655x.o obj-$(CONFIG_COMMON_CLK_S2MPS11) += clk-s2mps11.o obj-$(CONFIG_COMMON_CLK_SCMI) += clk-scmi.odrivers/clk/clk-rp1.c new file +1
-0@@ -0,0 +1,1512 @@ +// SPDX-License-Identifier: GPL-2.0 ...
Quoted 16 lines
drivers/clk/clk-rp1.c new file +16
-0+ +static int rp1_pll_divider_set_rate (struct clk_hw *hw, +unsigned long rate, +unsigned long parent_rate) +{ + struct rp1_clk_desc *divider = container_of(hw, struct rp1_clk_desc, div.hw); +struct rp1_clockman *clockman = divider->clockman; +const struct rp1_pll_data *data = divider->data; +u32 div, sec; + + div =DIV_ROUND_UP_ULL (parent_rate, rate); + div =clamp (div,8u ,19u ); + +spin_lock (&clockman->regs_lock); + sec =clockman_read (clockman, data->ctrl_reg); + sec &= ~PLL_SEC_DIV_MASK ;
Quoted 8 lines
drivers/clk/clk-rp1.c line 745
Quoted 7 lines
drivers/clk/clk-rp1.c new file +7
-0+ sec |=FIELD_PREP (PLL_SEC_DIV_MASK , div); + +/* Must keep the divider in reset to change the value. */ + sec |=PLL_SEC_RST ; +clockman_write (clockman, data->ctrl_reg, sec); + +/* TODO: must sleep 10 pll vco cycles */ Is it possible to implement this with some kind of xsleep or xdelay?
I guess so... unless anyone knows a better method such as checking for some undocumented register flag which reveals when the clock is stable so it can be enabled (Phil, Dave, please feel free to step in with advice if you have any), I think this line could solve the issue:
ndelay (10 * div * NSEC_PER_SEC / parent_rate);
Many thanks,
Andrea
Quoted 8 lines
Quoted 8 lines
drivers/clk/clk-rp1.c new file +7
-0+ sec &= ~PLL_SEC_RST ; +clockman_write (clockman, data->ctrl_reg, sec); +spin_unlock (&clockman->regs_lock); + +return 0 ; +} +
Andrea della Porta
maintainerRe: [PATCH v8 09/13] arm64: dts: Add board DTS for Rpi5 which includes RP1 node
In reply to Stefan WahrenHi Stefan,
Quoted 7 lines · Stefan Wahren
Hi Andrea,
Am 19.03.25 um 22:52 schrieb Andrea della Porta:
Quoted 4 lines
Add the board 'monolithic' DTS for RaspberryPi 5 which includes the RP1 node definition. The inclusion treeis as follow (the arrow points to the includer):
Quoted 7 lines
Quoted 4 lines
rp1-common.dtsi---->rp1-nexus.dtsi---->bcm2712-rpi-5-b-monolithic.dts^ | bcm2712-rpi-5-b.dtssorry for the delay. I'm not happy with the monolithic appendix.
How about
bcm2712-rpi-5-b-rp1.dtsor something more self-explaining?Regards
Sure, good catch. I'd go even further saying that we can rename (or merge if the destination file already exists) as:
bcm2712-rpi-5-b.dts -> bcm2712-rpi-5-b-norp1.dts (or some better suffix other than -norp1) bcm2712-rpi-5-b-monolithic.dts -> bcm2712-rpi-5-b.dts
so the monolithic one, which seems to be the 'safest' option as of now, would be the default dtb. Do you think it could be ok?
Quoted 14 lines
Quoted 6 lines
This is designed to maximize the compatibility with downstream DT while ensuring that a fully defined DT (one which includes the RP1 node as opposed to load it from overlay at runtime) is present since early boot stage.
Signed-off-by Andrea della Porta <[email protected]>Quoted 8 lines
---
Right nowbcm2712-rpi-5-b.dtsis the overlay-ready DT which will make the RP1 driver to load the RP1 dtb overlay at runtime, whilebcm2712-rpi-5-b-monolithic.dtsis the fully defined one (i.e. it already contains RP1 node, so no overlay is loaded nor needed). Depending on which one we want to be considered the default, we can swap the file names to align with downstream naming convention that has only the fully defined DT calledbcm2712-rpi-5-b.dts.
Quoted 2 lines
Could you please move some of this good explanation into this dts file as comment?
Sure.
Thanks,
Andrea
Quoted 33 lines
Quoted 32 lines
--- arch/arm64/boot/dts/broadcom/Makefile | 1 + .../boot/dts/broadcom/bcm2712-rpi-5-b-monolithic.dts | 8 ++++++++ 2 files changed, 9 insertions(+)create mode 100644
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b-monolithic.dtsarch/arm64/boot/dts/broadcom/Makefile +1
-0@@ -7,6 +7,7 @@ dtb-$(CONFIG_ARCH_BCM2835) += bcm2711-rpi-400.dtb \ bcm2711-rpi-4-b.dtb \ bcm2711-rpi-cm4-io.dtb \ bcm2712-rpi-5-b.dtb \ + bcm2712-rpi-5-b-monolithic.dtb \ bcm2712-d-rpi-5-b.dtb \ bcm2837-rpi-3-a-plus.dtb \ bcm2837-rpi-3-b.dtb \arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b-monolithic.dts new file +8
-0@@ -0,0 +1,8 @@ +// SPDX-License-Identifier: (GPL-2.0 OR MIT) +/dts-v1/; + +#include "bcm2712-rpi-5-b.dts" + +&pcie2 { + #include "rp1-nexus.dtsi" +};
Andrea della Porta
maintainerRe: [PATCH v8 10/13] arm64: dts: Add overlay for RP1 device
In reply to Stefan WahrenHi Stefan,
Quoted 3 lines · Stefan Wahren
Hi Andrea,
just a nit. Could you please add "broadcom:" to the subject?
Consider it done.
Many thanks,
Andrea
Quoted 55 lines
Am 19.03.25 um 22:52 schrieb Andrea della Porta:
Quoted 52 lines
Define the RP1 node in an overlay. The inclusion tree is as follow (the arrow points to the includer):
rp1.dtso ^ |
rp1-common.dtsi---->rp1-nexus.dtsiSigned-off-by Andrea della Porta <[email protected]>---
This patch can be considered optional, since it fills just the second scenario as detailed in [1], which is the RP1 DT node loaded from a dtb overlay by the FW at early boot stage.
This may be useful for debug purpose, but as such not strictly necessary.[1] https://lore.kernel.org/all/CAMEGJJ0f4YUgdWBhxvQ_dquZHztve9KO7pvQjoDWJ3=zd3cgcg@mail.gmail.com/#t
--- arch/arm64/boot/dts/broadcom/Makefile | 3 ++- arch/arm64/boot/dts/broadcom/rp1.dtso | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-)create mode 100644
arch/arm64/boot/dts/broadcom/rp1.dtsoarch/arm64/boot/dts/broadcom/Makefile +2
-1@@ -13,7 +13,8 @@ dtb-$(CONFIG_ARCH_BCM2835) += bcm2711-rpi-400.dtb \ bcm2837-rpi-3-b.dtb \ bcm2837-rpi-3-b-plus.dtb \ bcm2837-rpi-cm3-io3.dtb \ - bcm2837-rpi-zero-2-w.dtb + bcm2837-rpi-zero-2-w.dtb \ + rp1.dtbo subdir-y += bcmbca subdir-y += northstar2arch/arm64/boot/dts/broadcom/rp1.dtso new file +11
-0@@ -0,0 +1,11 @@ +// SPDX-License-Identifier: (GPL-2.0 OR MIT) + +/dts-v1/; +/plugin/; + +&pcie2 { + #address-cells = <3>; + #size-cells = <2>; + + #include "rp1-nexus.dtsi" +};
Re: [PATCH v8 09/13] arm64: dts: Add board DTS for Rpi5 which includes RP1 node
In reply to Andrea della PortaHi Andrea,
Am 16.04.25 um 19:43 schrieb Andrea della Porta:
Quoted 17 lines
Hi Stefan,
Quoted 7 lines · Stefan Wahren
Hi Andrea,
Am 19.03.25 um 22:52 schrieb Andrea della Porta:
Quoted 4 lines
Add the board 'monolithic' DTS for RaspberryPi 5 which includes the RP1 node definition. The inclusion treeis as follow (the arrow points to the includer):
Quoted 7 lines
Quoted 4 lines
rp1-common.dtsi---->rp1-nexus.dtsi---->bcm2712-rpi-5-b-monolithic.dts^ | bcm2712-rpi-5-b.dtssorry for the delay. I'm not happy with the monolithic appendix.
How about
bcm2712-rpi-5-b-rp1.dtsor something more self-explaining?Regards
Quoted 8 lines
Sure, good catch. I'd go even further saying that we can rename (or merge if the destination file already exists) as:
bcm2712-rpi-5-b.dts -> bcm2712-rpi-5-b-norp1.dts (or some better suffix other than -norp1) bcm2712-rpi-5-b-monolithic.dts -> bcm2712-rpi-5-b.dtsso the monolithic one, which seems to be the 'safest' option as of now, would be the default dtb. Do you think it could be ok?
i like the idea (include rp1 into default dtb), but not a fan of negative logic in naming. Unfortunately I don't have better idea.
Regards
Quoted 54 lines
Quoted 15 lines
Quoted 7 lines
This is designed to maximize the compatibility with downstream DT while ensuring that a fully defined DT (one which includes the RP1 node as opposed to load it from overlay at runtime) is present since early boot stage.
Signed-off-by Andrea della Porta <[email protected]>Quoted 8 lines
---
Right nowbcm2712-rpi-5-b.dtsis the overlay-ready DT which will make the RP1 driver to load the RP1 dtb overlay at runtime, whilebcm2712-rpi-5-b-monolithic.dtsis the fully defined one (i.e. it already contains RP1 node, so no overlay is loaded nor needed). Depending on which one we want to be considered the default, we can swap the file names to align with downstream naming convention that has only the fully defined DT calledbcm2712-rpi-5-b.dts.Quoted 2 lines
Could you please move some of this good explanation into this dts file as comment?
Sure.
Thanks,
AndreaQuoted 32 lines
Quoted 32 lines
--- arch/arm64/boot/dts/broadcom/Makefile | 1 + .../boot/dts/broadcom/bcm2712-rpi-5-b-monolithic.dts | 8 ++++++++ 2 files changed, 9 insertions(+)create mode 100644
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b-monolithic.dtsarch/arm64/boot/dts/broadcom/Makefile +1
-0@@ -7,6 +7,7 @@ dtb-$(CONFIG_ARCH_BCM2835) += bcm2711-rpi-400.dtb \ bcm2711-rpi-4-b.dtb \ bcm2711-rpi-cm4-io.dtb \ bcm2712-rpi-5-b.dtb \ + bcm2712-rpi-5-b-monolithic.dtb \ bcm2712-d-rpi-5-b.dtb \ bcm2837-rpi-3-a-plus.dtb \ bcm2837-rpi-3-b.dtb \arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b-monolithic.dts new file +8
-0@@ -0,0 +1,8 @@ +// SPDX-License-Identifier: (GPL-2.0 OR MIT) +/dts-v1/; + +#include "bcm2712-rpi-5-b.dts" + +&pcie2 { + #include "rp1-nexus.dtsi" +};
Andrea della Porta
maintainerRe: [PATCH v8 11/13] arm64: dts: bcm2712: Add external clock for RP1 chipset on Rpi5
In reply to Stefan WahrenHi Stefan,
Quoted 10 lines · Stefan Wahren
Hi Andrea,
Am 19.03.25 um 22:52 schrieb Andrea della Porta:
Quoted 5 lines
The RP1 found on Raspberry Pi 5 board needs an external crystal at 50MHz. Add
clk_rp1_xoscnode to provide that.Signed-off-by Andrea della Porta <[email protected]>Reviewed-by Florian Fainelli <[email protected]>i'm fine with the patch content, but I think this is necessary before Patch 9 is applied?
True. Thanks for pointing that out.
Cheers,
Andrea
Quoted 23 lines
Quoted 22 lines
--- arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts | 7 +++++++ 1 file changed, 7 insertions(+)arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts +7
-0@@ -16,6 +16,13 @@ chosen: chosen { stdout-path = "serial10:115200n8"; }; + clk_rp1_xosc: clock-50000000 { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-output-names = "rp1-xosc"; + clock-frequency = <50000000>; + }; + /* Will be filled by the bootloader */ memory@0 { device_type = "memory";
Andrea della Porta
maintainerRe: [PATCH v8 09/13] arm64: dts: Add board DTS for Rpi5 which includes RP1 node
In reply to Stefan WahrenHi Stefan,
Quoted 23 lines · Stefan Wahren
Hi Andrea,
Am 16.04.25 um 19:43 schrieb Andrea della Porta:
Quoted 20 lines
Hi Stefan,
Quoted 7 lines · Stefan Wahren
Hi Andrea,
Am 19.03.25 um 22:52 schrieb Andrea della Porta:
Quoted 4 lines
Add the board 'monolithic' DTS for RaspberryPi 5 which includes the RP1 node definition. The inclusion treeis as follow (the arrow points to the includer):
Quoted 7 lines
Quoted 4 lines
rp1-common.dtsi---->rp1-nexus.dtsi---->bcm2712-rpi-5-b-monolithic.dts^ | bcm2712-rpi-5-b.dtssorry for the delay. I'm not happy with the monolithic appendix.
How about
bcm2712-rpi-5-b-rp1.dtsor something more self-explaining?RegardsSure, good catch. I'd go even further saying that we can rename (or merge if the destination file already exists) as:
Quoted 8 lines
Quoted 5 lines
bcm2712-rpi-5-b.dts -> bcm2712-rpi-5-b-norp1.dts (or some better suffix other than -norp1) bcm2712-rpi-5-b-monolithic.dts -> bcm2712-rpi-5-b.dtsso the monolithic one, which seems to be the 'safest' option as of now, would be the default dtb. Do you think it could be ok?
i like the idea (include rp1 into default dtb), but not a fan of negative logic in naming. Unfortunately I don't have better idea.
Hmm ok... I'd propose 'bcm2712-rpi-5-b-ovl-rp1.dts'. Could it work?
Regards,
Andrea
Quoted 56 lines
Regards
Quoted 54 lines
Quoted 15 lines
Quoted 7 lines
This is designed to maximize the compatibility with downstream DT while ensuring that a fully defined DT (one which includes the RP1 node as opposed to load it from overlay at runtime) is present since early boot stage.
Signed-off-by Andrea della Porta <[email protected]>Quoted 8 lines
---
Right nowbcm2712-rpi-5-b.dtsis the overlay-ready DT which will make the RP1 driver to load the RP1 dtb overlay at runtime, whilebcm2712-rpi-5-b-monolithic.dtsis the fully defined one (i.e. it already contains RP1 node, so no overlay is loaded nor needed). Depending on which one we want to be considered the default, we can swap the file names to align with downstream naming convention that has only the fully defined DT calledbcm2712-rpi-5-b.dts.Quoted 2 lines
Could you please move some of this good explanation into this dts file as comment?
Sure.
Thanks,
AndreaQuoted 32 lines
Quoted 32 lines
--- arch/arm64/boot/dts/broadcom/Makefile | 1 + .../boot/dts/broadcom/bcm2712-rpi-5-b-monolithic.dts | 8 ++++++++ 2 files changed, 9 insertions(+)create mode 100644
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b-monolithic.dtsarch/arm64/boot/dts/broadcom/Makefile +1
-0@@ -7,6 +7,7 @@ dtb-$(CONFIG_ARCH_BCM2835) += bcm2711-rpi-400.dtb \ bcm2711-rpi-4-b.dtb \ bcm2711-rpi-cm4-io.dtb \ bcm2712-rpi-5-b.dtb \ + bcm2712-rpi-5-b-monolithic.dtb \ bcm2712-d-rpi-5-b.dtb \ bcm2837-rpi-3-a-plus.dtb \ bcm2837-rpi-3-b.dtb \arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b-monolithic.dts new file +8
-0@@ -0,0 +1,8 @@ +// SPDX-License-Identifier: (GPL-2.0 OR MIT) +/dts-v1/; + +#include "bcm2712-rpi-5-b.dts" + +&pcie2 { + #include "rp1-nexus.dtsi" +};
Re: [PATCH v8 07/13] arm64: dts: rp1: Add support for RaspberryPi's RP1 device
In reply to Andrea della PortaQuoted 7 lines · Andrea della Porta
RaspberryPi RP1 is a multi function PCI endpoint device that exposes several subperipherals via PCI BAR.
Add a dtb overlay that will be compiled into a binary blob and linked in the RP1 driver.
This overlay offers just minimal support to represent the RP1 device itself, the sub-peripherals will be added by future patches.
Would be nice to have a blank line between paragraphs.
Re: [PATCH v8 08/13] misc: rp1: RaspberryPi RP1 misc driver
In reply to Andrea della PortaQuoted 39 lines · Andrea della Porta
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.dtsiOn 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/mischas 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.
Quoted 7 lines
Signed-off-by Andrea della Porta <[email protected]>
Quoted 29 lines
drivers/pci/quirks.c +1
-0@@ -6283,6 +6283,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_XILINX, 0x5020, of_pci_make_dev_node);DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_XILINX ,0x5021 , of_pci_make_dev_node);DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_REDHAT ,0x0005 , of_pci_make_dev_node);DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_EFAR ,0x9660 , of_pci_make_dev_node); +DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_RPI ,PCI_DEVICE_ID_RPI_RP1_C0 , of_pci_make_dev_node);/* * Devices known to require a longer delay before first config space access include/linux/pci_ids.h +3
-0@@ -2620,6 +2620,9 @@#define PCI_VENDOR_ID_TEKRAM 0x1de1#define PCI_DEVICE_ID_TEKRAM_DC290 0xdc29 +#define PCI_VENDOR_ID_RPI 0x1de4 +#define PCI_DEVICE_ID_RPI_RP1_C0 0x0001 +#define PCI_VENDOR_ID_ALIBABA 0x1ded#define PCI_VENDOR_ID_CXL 0x1e98Signature · 1 line
2.35.3
Andrea della Porta
maintainerRe: [PATCH v8 07/13] arm64: dts: rp1: Add support for RaspberryPi's RP1 device
In reply to Bjorn HelgaasHi Bjorn,
Quoted 10 lines · Bjorn Helgaas
Quoted 7 lines · Andrea della Porta
RaspberryPi RP1 is a multi function PCI endpoint device that exposes several subperipherals via PCI BAR.
Add a dtb overlay that will be compiled into a binary blob and linked in the RP1 driver.
This overlay offers just minimal support to represent the RP1 device itself, the sub-peripherals will be added by future patches.Would be nice to have a blank line between paragraphs.
Ack.
Thanks,
Andrea
Re: [PATCH v8 05/13] clk: rp1: Add support for clocks provided by RP1
In reply to Andrea della PortaHi Andrea & Stefan.
Quoted 101 lines · Andrea della Porta
Hi Stefan,
Quoted 88 lines · Stefan Wahren
Hi Andrea,
Am 19.03.25 um 22:52 schrieb Andrea della Porta:
Quoted 68 lines
RaspberryPi RP1 is an MFD providing, among other peripherals, several clock generators and PLLs that drives the sub-peripherals. Add the driver to support the clock providers.
Signed-off-by Andrea della Porta <[email protected]>--- MAINTAINERS | 5 + drivers/clk/Kconfig | 9 + drivers/clk/Makefile | 1 + drivers/clk/clk-rp1.c | 1512 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 1527 insertions(+)create mode 100644
drivers/clk/clk-rp1.cMAINTAINERS +5
-0@@ -19748,6 +19748,11 @@ S: Maintained F: Documentation/devicetree/bindings/media/raspberrypi,rp1-cfe.yaml F: drivers/media/platform/raspberrypi/rp1-cfe/ +RASPBERRY PI RP1 PCI DRIVER +M: Andrea della Porta <[email protected]> +S: Maintained +F: drivers/clk/clk-rp1.c + RC-CORE / LIRC FRAMEWORK M: Sean Young <[email protected]> L: [email protected]drivers/clk/Kconfig +9
-0@@ -88,6 +88,15 @@ config COMMON_CLK_RK808 These multi-function devices have two fixed-rate oscillators, clocked at 32KHz each. Clkout1 is always on, Clkout2 can off by control register. +config COMMON_CLK_RP1 + tristate "Raspberry Pi RP1-based clock support" + depends on MISC_RP1 || COMPILE_TEST + default MISC_RP1 + help + Enable common clock framework support for Raspberry Pi RP1. + This multi-function device has 3 main PLLs and several clock + generators to drive the internal sub-peripherals. + config COMMON_CLK_HI655X tristate "Clock driver for Hi655x" if EXPERT depends on (MFD_HI655X_PMIC || COMPILE_TEST)drivers/clk/Makefile +1
-0@@ -84,6 +84,7 @@ obj-$(CONFIG_CLK_LS1028A_PLLDIG) += clk-plldig.o obj-$(CONFIG_COMMON_CLK_PWM) += clk-pwm.o obj-$(CONFIG_CLK_QORIQ) += clk-qoriq.o obj-$(CONFIG_COMMON_CLK_RK808) += clk-rk808.o +obj-$(CONFIG_COMMON_CLK_RP1) += clk-rp1.o obj-$(CONFIG_COMMON_CLK_HI655X) += clk-hi655x.o obj-$(CONFIG_COMMON_CLK_S2MPS11) += clk-s2mps11.o obj-$(CONFIG_COMMON_CLK_SCMI) += clk-scmi.odrivers/clk/clk-rp1.c new file +1
-0@@ -0,0 +1,1512 @@ +// SPDX-License-Identifier: GPL-2.0 ...
Quoted 16 lines
drivers/clk/clk-rp1.c new file +16
-0+ +static int rp1_pll_divider_set_rate (struct clk_hw *hw, +unsigned long rate, +unsigned long parent_rate) +{ + struct rp1_clk_desc *divider = container_of(hw, struct rp1_clk_desc, div.hw); +struct rp1_clockman *clockman = divider->clockman; +const struct rp1_pll_data *data = divider->data; +u32 div, sec; + + div =DIV_ROUND_UP_ULL (parent_rate, rate); + div =clamp (div,8u ,19u ); + +spin_lock (&clockman->regs_lock); + sec =clockman_read (clockman, data->ctrl_reg); + sec &= ~PLL_SEC_DIV_MASK ;Quoted 8 lines
drivers/clk/clk-rp1.c line 745
Quoted 7 lines
drivers/clk/clk-rp1.c new file +7
-0+ sec |=FIELD_PREP (PLL_SEC_DIV_MASK , div); + +/* Must keep the divider in reset to change the value. */ + sec |=PLL_SEC_RST ; +clockman_write (clockman, data->ctrl_reg, sec); + +/* TODO: must sleep 10 pll vco cycles */ Is it possible to implement this with some kind of xsleep or xdelay?
Quoted 6 lines
I guess so... unless anyone knows a better method such as checking for some undocumented register flag which reveals when the clock is stable so it can be enabled (Phil, Dave, please feel free to step in with advice if you have any), I think this line could solve the issue:
ndelay (10 * div *
NSEC_PER_SEC/parent_rate);
I've checked with those involved in the hardware side. There's no hardware flag that the clock is stable, so the ndelay is probably the best option. The VCO can go as low as 600MHz, so the max delay would be 166ns.
Thanks for your continuing work on this.
Dave
Quoted 11 lines
Many thanks,
AndreaQuoted 8 lines
Quoted 8 lines
drivers/clk/clk-rp1.c new file +7
-0+ sec &= ~PLL_SEC_RST ; +clockman_write (clockman, data->ctrl_reg, sec); +spin_unlock (&clockman->regs_lock); + +return 0 ; +} +
Andrea della Porta
maintainerRe: [PATCH v8 05/13] clk: rp1: Add support for clocks provided by RP1
Hi Dave,
Quoted 109 lines · Dave Stevenson
Hi Andrea & Stefan.
Quoted 106 lines · Andrea della Porta
Hi Stefan,
Quoted 88 lines · Stefan Wahren
Hi Andrea,
Am 19.03.25 um 22:52 schrieb Andrea della Porta:
Quoted 68 lines
RaspberryPi RP1 is an MFD providing, among other peripherals, several clock generators and PLLs that drives the sub-peripherals. Add the driver to support the clock providers.
Signed-off-by Andrea della Porta <[email protected]>--- MAINTAINERS | 5 + drivers/clk/Kconfig | 9 + drivers/clk/Makefile | 1 + drivers/clk/clk-rp1.c | 1512 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 1527 insertions(+)create mode 100644
drivers/clk/clk-rp1.cMAINTAINERS +5
-0@@ -19748,6 +19748,11 @@ S: Maintained F: Documentation/devicetree/bindings/media/raspberrypi,rp1-cfe.yaml F: drivers/media/platform/raspberrypi/rp1-cfe/ +RASPBERRY PI RP1 PCI DRIVER +M: Andrea della Porta <[email protected]> +S: Maintained +F: drivers/clk/clk-rp1.c + RC-CORE / LIRC FRAMEWORK M: Sean Young <[email protected]> L: [email protected]drivers/clk/Kconfig +9
-0@@ -88,6 +88,15 @@ config COMMON_CLK_RK808 These multi-function devices have two fixed-rate oscillators, clocked at 32KHz each. Clkout1 is always on, Clkout2 can off by control register. +config COMMON_CLK_RP1 + tristate "Raspberry Pi RP1-based clock support" + depends on MISC_RP1 || COMPILE_TEST + default MISC_RP1 + help + Enable common clock framework support for Raspberry Pi RP1. + This multi-function device has 3 main PLLs and several clock + generators to drive the internal sub-peripherals. + config COMMON_CLK_HI655X tristate "Clock driver for Hi655x" if EXPERT depends on (MFD_HI655X_PMIC || COMPILE_TEST)drivers/clk/Makefile +1
-0@@ -84,6 +84,7 @@ obj-$(CONFIG_CLK_LS1028A_PLLDIG) += clk-plldig.o obj-$(CONFIG_COMMON_CLK_PWM) += clk-pwm.o obj-$(CONFIG_CLK_QORIQ) += clk-qoriq.o obj-$(CONFIG_COMMON_CLK_RK808) += clk-rk808.o +obj-$(CONFIG_COMMON_CLK_RP1) += clk-rp1.o obj-$(CONFIG_COMMON_CLK_HI655X) += clk-hi655x.o obj-$(CONFIG_COMMON_CLK_S2MPS11) += clk-s2mps11.o obj-$(CONFIG_COMMON_CLK_SCMI) += clk-scmi.odrivers/clk/clk-rp1.c new file +1
-0@@ -0,0 +1,1512 @@ +// SPDX-License-Identifier: GPL-2.0 ...
Quoted 16 lines
drivers/clk/clk-rp1.c new file +16
-0+ +static int rp1_pll_divider_set_rate (struct clk_hw *hw, +unsigned long rate, +unsigned long parent_rate) +{ + struct rp1_clk_desc *divider = container_of(hw, struct rp1_clk_desc, div.hw); +struct rp1_clockman *clockman = divider->clockman; +const struct rp1_pll_data *data = divider->data; +u32 div, sec; + + div =DIV_ROUND_UP_ULL (parent_rate, rate); + div =clamp (div,8u ,19u ); + +spin_lock (&clockman->regs_lock); + sec =clockman_read (clockman, data->ctrl_reg); + sec &= ~PLL_SEC_DIV_MASK ;Quoted 8 lines
drivers/clk/clk-rp1.c line 745
Quoted 7 lines
drivers/clk/clk-rp1.c new file +7
-0+ sec |=FIELD_PREP (PLL_SEC_DIV_MASK , div); + +/* Must keep the divider in reset to change the value. */ + sec |=PLL_SEC_RST ; +clockman_write (clockman, data->ctrl_reg, sec); + +/* TODO: must sleep 10 pll vco cycles */ Is it possible to implement this with some kind of xsleep or xdelay?
I guess so... unless anyone knows a better method such as checking for some undocumented register flag which reveals when the clock is stable so it can be enabled (Phil, Dave, please feel free to step in with advice if you have any), I think this line could solve the issue:
Quoted 6 lines
Quoted 1 line
ndelay (10 * div *
NSEC_PER_SEC/parent_rate);I've checked with those involved in the hardware side. There's no hardware flag that the clock is stable, so the ndelay is probably the best option. The VCO can go as low as 600MHz, so the max delay would be 166ns.
Perfect, I'll use ndelay then. However, shouldn't this be 16ns max? I think this formula should give a good estimate:
10ULL * div * NSEC_PER_SEC / parent_rate
and has the advantage of not depending on hard coded values.
Quoted 2 lines
Thanks for your continuing work on this.
Thank you for checking.
Regards,
Andrea
Quoted 14 lines
Dave
Quoted 11 lines
Many thanks,
AndreaQuoted 8 lines
Quoted 8 lines
drivers/clk/clk-rp1.c new file +7
-0+ sec &= ~PLL_SEC_RST ; +clockman_write (clockman, data->ctrl_reg, sec); +spin_unlock (&clockman->regs_lock); + +return 0 ; +} +
Re: [PATCH v8 05/13] clk: rp1: Add support for clocks provided by RP1
Quoted 120 lines · Andrea della Porta
Hi Dave,
Quoted 109 lines · Dave Stevenson
Hi Andrea & Stefan.
Quoted 106 lines · Andrea della Porta
Hi Stefan,
Quoted 88 lines · Stefan Wahren
Hi Andrea,
Am 19.03.25 um 22:52 schrieb Andrea della Porta:
Quoted 68 lines
RaspberryPi RP1 is an MFD providing, among other peripherals, several clock generators and PLLs that drives the sub-peripherals. Add the driver to support the clock providers.
Signed-off-by Andrea della Porta <[email protected]>--- MAINTAINERS | 5 + drivers/clk/Kconfig | 9 + drivers/clk/Makefile | 1 + drivers/clk/clk-rp1.c | 1512 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 1527 insertions(+)create mode 100644
drivers/clk/clk-rp1.cMAINTAINERS +5
-0@@ -19748,6 +19748,11 @@ S: Maintained F: Documentation/devicetree/bindings/media/raspberrypi,rp1-cfe.yaml F: drivers/media/platform/raspberrypi/rp1-cfe/ +RASPBERRY PI RP1 PCI DRIVER +M: Andrea della Porta <[email protected]> +S: Maintained +F: drivers/clk/clk-rp1.c + RC-CORE / LIRC FRAMEWORK M: Sean Young <[email protected]> L: [email protected]drivers/clk/Kconfig +9
-0@@ -88,6 +88,15 @@ config COMMON_CLK_RK808 These multi-function devices have two fixed-rate oscillators, clocked at 32KHz each. Clkout1 is always on, Clkout2 can off by control register. +config COMMON_CLK_RP1 + tristate "Raspberry Pi RP1-based clock support" + depends on MISC_RP1 || COMPILE_TEST + default MISC_RP1 + help + Enable common clock framework support for Raspberry Pi RP1. + This multi-function device has 3 main PLLs and several clock + generators to drive the internal sub-peripherals. + config COMMON_CLK_HI655X tristate "Clock driver for Hi655x" if EXPERT depends on (MFD_HI655X_PMIC || COMPILE_TEST)drivers/clk/Makefile +1
-0@@ -84,6 +84,7 @@ obj-$(CONFIG_CLK_LS1028A_PLLDIG) += clk-plldig.o obj-$(CONFIG_COMMON_CLK_PWM) += clk-pwm.o obj-$(CONFIG_CLK_QORIQ) += clk-qoriq.o obj-$(CONFIG_COMMON_CLK_RK808) += clk-rk808.o +obj-$(CONFIG_COMMON_CLK_RP1) += clk-rp1.o obj-$(CONFIG_COMMON_CLK_HI655X) += clk-hi655x.o obj-$(CONFIG_COMMON_CLK_S2MPS11) += clk-s2mps11.o obj-$(CONFIG_COMMON_CLK_SCMI) += clk-scmi.odrivers/clk/clk-rp1.c new file +1
-0@@ -0,0 +1,1512 @@ +// SPDX-License-Identifier: GPL-2.0 ...
Quoted 16 lines
drivers/clk/clk-rp1.c new file +16
-0+ +static int rp1_pll_divider_set_rate (struct clk_hw *hw, +unsigned long rate, +unsigned long parent_rate) +{ + struct rp1_clk_desc *divider = container_of(hw, struct rp1_clk_desc, div.hw); +struct rp1_clockman *clockman = divider->clockman; +const struct rp1_pll_data *data = divider->data; +u32 div, sec; + + div =DIV_ROUND_UP_ULL (parent_rate, rate); + div =clamp (div,8u ,19u ); + +spin_lock (&clockman->regs_lock); + sec =clockman_read (clockman, data->ctrl_reg); + sec &= ~PLL_SEC_DIV_MASK ;Quoted 8 lines
drivers/clk/clk-rp1.c line 745
Quoted 7 lines
drivers/clk/clk-rp1.c new file +7
-0+ sec |=FIELD_PREP (PLL_SEC_DIV_MASK , div); + +/* Must keep the divider in reset to change the value. */ + sec |=PLL_SEC_RST ; +clockman_write (clockman, data->ctrl_reg, sec); + +/* TODO: must sleep 10 pll vco cycles */ Is it possible to implement this with some kind of xsleep or xdelay?
I guess so... unless anyone knows a better method such as checking for some undocumented register flag which reveals when the clock is stable so it can be enabled (Phil, Dave, please feel free to step in with advice if you have any), I think this line could solve the issue:
Quoted 6 lines
Quoted 1 line
ndelay (10 * div *
NSEC_PER_SEC/parent_rate);I've checked with those involved in the hardware side. There's no hardware flag that the clock is stable, so the ndelay is probably the best option. The VCO can go as low as 600MHz, so the max delay would be 166ns.
Quoted 6 lines
Perfect, I'll use ndelay then. However, shouldn't this be 16ns max? I think this formula should give a good estimate:
10ULL * div *
NSEC_PER_SEC/parent_rateand has the advantage of not depending on hard coded values.
I'd copied the number my colleague had given :-) He's now left for the Easter weekend, but I can hassle him again on Tuesday.
I was expecting a computation rather than hard coded value, but was giving the maximum as significant delays aren't very friendly. The fact that we haven't noticed any issues with no delay at all implies to me that this delay may only be a level of polishing rather than anything critical. Although there is also the possibility that they haven't been reconfigured on a regular basis either.
Dave
Quoted 22 lines
Quoted 2 lines
Thanks for your continuing work on this.
Thank you for checking.
Regards,
AndreaQuoted 14 lines
Dave
Quoted 11 lines
Many thanks,
AndreaQuoted 8 lines
Quoted 8 lines
drivers/clk/clk-rp1.c new file +7
-0+ sec &= ~PLL_SEC_RST ; +clockman_write (clockman, data->ctrl_reg, sec); +spin_unlock (&clockman->regs_lock); + +return 0 ; +} +