Add support for RaspberryPi RP1 PCI device using a DT overlay
Subsystems (9)
Andrea della Porta
maintainerv6 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. Followup 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 though the on-board gpio controller.
-PATCH 5 and 6: add clock and gpio device drivers.
-PATCH 7: the devicetree overlay describing the RP1 chipset. Please
note that this patch should be taken by the same maintainer that will also take patch 11, since txeieh dtso is compiled in as binary blob and is closely coupled to the driver.
-PATCH 8: this is the main patch to support RP1 chipset and peripherals
enabling through dtb overlay. The dtso since is intimately coupled with the driver and will be linked in as binary blob in the driver obj. 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: add the external clock node (used by RP1) to the main dts.
-PATCH 10: add the relevant kernel CONFIG_ options to defconfig.
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.
Please note that albeit this patchset has no prerequisites in order to be applied cleanly, it still depends on Stanimir's WIP patchset for BCM2712 PCIe controller (see [5]) in order to work at runtime.
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/
CHANGES IN V6:
PATCH RELATED -------------------------------------------------
- patch 2: added: Reviewed-by: Linus Walleij <[email protected]>
- patch 3 and 4: added: 'Reviewed-by: Rob Herring (Arm) <[email protected]>'
- patch 8: removed a stale paragraph from git commit message regarding gpio renaming through configfs
RP1 MISC DRIVER -----------------------------------
- interrupts definitions moved as documentation from rp1_pci.c to pci1de4,1.yaml binding schema
Andrea della Porta (10):
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: bcm2712: Add external clock for RP1 chipset on Rpi5
arm64: defconfig: Enable RP1 misc/clock/gpio drivers
.../clock/raspberrypi,rp1-clocks.yaml | 58 + .../devicetree/bindings/misc/pci1de4,1.yaml | 135 ++ .../devicetree/bindings/pci/pci-ep-bus.yaml | 58 + .../pinctrl/raspberrypi,rp1-gpio.yaml | 198 +++ MAINTAINERS | 14 + .../boot/dts/broadcom/bcm2712-rpi-5-b.dts | 7 + arch/arm64/boot/dts/broadcom/rp1.dtso | 58 + arch/arm64/configs/defconfig | 3 + drivers/clk/Kconfig | 9 + drivers/clk/Makefile | 1 + drivers/clk/clk-rp1.c | 1527 +++++++++++++++++ drivers/misc/Kconfig | 1 + drivers/misc/Makefile | 1 + drivers/misc/rp1/Kconfig | 21 + drivers/misc/rp1/Makefile | 3 + drivers/misc/rp1/rp1-pci.dtso | 8 + drivers/misc/rp1/rp1_pci.c | 305 ++++ drivers/misc/rp1/rp1_pci.h | 14 + drivers/pci/quirks.c | 1 + drivers/pinctrl/Kconfig | 11 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/pinctrl-rp1.c | 789 +++++++++ .../clock/raspberrypi,rp1-clocks.h | 61 + include/linux/pci_ids.h | 3 + 24 files changed, 3287 insertions(+) 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/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/misc/rp1/rp1_pci.h 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 v6 1/10 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 ++++++++++++++++++ MAINTAINERS | 6 ++ .../clock/raspberrypi,rp1-clocks.h | 61 +++++++++++++++++++ 3 files changed, 125 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: + - Andrea 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 though 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>; + }; + };
MAINTAINERS +6 -0
@@ -19574,6 +19574,12 @@ 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: Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml +F: include/dt-bindings/clock/rp1.h + RC-CORE / LIRC FRAMEWORK M: Sean Young <[email protected]> L: [email protected]
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 v6 2/10 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 ++++++++++++++++++ MAINTAINERS | 2 + 2 files changed, 200 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: + - Andrea 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; + }; + }; + }; + };
MAINTAINERS +2 -0
@@ -19578,7 +19578,9 @@ RASPBERRY PI RP1 PCI DRIVER M: Andrea della Porta <[email protected]> S: Maintained F: Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml +F: Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml F: include/dt-bindings/clock/rp1.h +F: include/dt-bindings/misc/rp1.h RC-CORE / LIRC FRAMEWORK M: Sean Young <[email protected]>
Signature · 1 line
2.35.3
Andrea della Porta
maintainerPATCH v6 3/10 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 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 59 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: + - Andrea 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 +...
MAINTAINERS +1 -0
@@ -19578,6 +19578,7 @@ RASPBERRY PI RP1 PCI DRIVER M: Andrea della Porta <[email protected]> S: Maintained F: Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml +F: Documentation/devicetree/bindings/pci/pci-ep-bus.yaml F: Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml F: include/dt-bindings/clock/rp1.h F: include/dt-bindings/misc/rp1.h
Signature · 1 line
2.35.3
Andrea della Porta
maintainerPATCH v6 4/10 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 | 135 ++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 136 insertions(+) create mode 100644 Documentation/devicetree/bindings/misc/pci1de4,1.yaml
Documentation/devicetree/bindings/misc/pci1de4,1.yaml new file +135 -0
@@ -0,0 +1,135 @@ +# 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: + - Andrea 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. + 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>; + }; + }; + }; + };
MAINTAINERS +1 -0
@@ -19578,6 +19578,7 @@ RASPBERRY PI RP1 PCI DRIVER M: Andrea della Porta <[email protected]> S: Maintained F: Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml +F: Documentation/devicetree/bindings/misc/pci1de4,1.yaml F: Documentation/devicetree/bindings/pci/pci-ep-bus.yaml F: Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml F: include/dt-bindings/clock/rp1.h
Signature · 1 line
2.35.3
Andrea della Porta
maintainerPATCH v6 5/10 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 | 1 + drivers/clk/Kconfig | 9 + drivers/clk/Makefile | 1 + drivers/clk/clk-rp1.c | 1527 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 1538 insertions(+) create mode 100644 drivers/clk/clk-rp1.c
MAINTAINERS +1 -0
@@ -19581,6 +19581,7 @@ F: Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml F: Documentation/devicetree/bindings/misc/pci1de4,1.yaml F: Documentation/devicetree/bindings/pci/pci-ep-bus.yaml F: Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml +F: drivers/clk/clk-rp1.c F: include/dt-bindings/clock/rp1.h F: include/dt-bindings/misc/rp1.h
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 +1527 -0
1,527 lines not on this page · raw message
Signature · 1 line
2.35.3
Andrea della Porta
maintainerPATCH v6 6/10 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 | 789 ++++++++++++++++++++++++++++++++++ 4 files changed, 802 insertions(+) create mode 100644 drivers/pinctrl/pinctrl-rp1.c
MAINTAINERS +1 -0
@@ -19582,6 +19582,7 @@ F: Documentation/devicetree/bindings/misc/pci1de4,1.yaml F: Documentation/devicetree/bindings/pci/pci-ep-bus.yaml F: Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml F: drivers/clk/clk-rp1.c +F: drivers/pinctrl/pinctrl-rp1.c F: include/dt-bindings/clock/rp1.h F: include/dt-bindings/misc/rp1.h
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 +789 -0
789 lines not on this page · raw message
Signature · 1 line
2.35.3
Andrea della Porta
maintainerPATCH v6 7/10 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.
---
NOTE: this patch should be taken by the same maintainer that will take "[PATCH v6 08/10] misc: rp1: RaspberryPi RP1 misc driver", since they are closely related in terms of compiling.
MAINTAINERS | 1 + arch/arm64/boot/dts/broadcom/rp1.dtso | 58 +++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 arch/arm64/boot/dts/broadcom/rp1.dtso
MAINTAINERS +1 -0
@@ -19577,6 +19577,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.dtso F: Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml F: Documentation/devicetree/bindings/misc/pci1de4,1.yaml F: Documentation/devicetree/bindings/pci/pci-ep-bus.yaml
arch/arm64/boot/dts/broadcom/rp1.dtso new file +58 -0
58 lines not on this page · raw message
Signature · 1 line
2.35.3
Andrea della Porta
maintainerPATCH v6 8/10 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.
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.
For reasons why this driver is contained in drivers/misc, 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 | 21 +++ drivers/misc/rp1/Makefile | 3 + drivers/misc/rp1/rp1-pci.dtso | 8 + drivers/misc/rp1/rp1_pci.c | 305 ++++++++++++++++++++++++++++++++++ drivers/misc/rp1/rp1_pci.h | 14 ++ drivers/pci/quirks.c | 1 + include/linux/pci_ids.h | 3 + 10 files changed, 358 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 create mode 100644 drivers/misc/rp1/rp1_pci.h
MAINTAINERS +1 -0
@@ -19583,6 +19583,7 @@ F: Documentation/devicetree/bindings/misc/pci1de4,1.yaml F: Documentation/devicetree/bindings/pci/pci-ep-bus.yaml F: Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml F: drivers/clk/clk-rp1.c +F: drivers/misc/rp1/ F: drivers/pinctrl/pinctrl-rp1.c F: include/dt-bindings/clock/rp1.h F: include/dt-bindings/misc/rp1.h
drivers/misc/Kconfig +1 -0
@@ -651,4 +651,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
@@ -74,3 +74,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 +21 -0
@@ -0,0 +1,21 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# RaspberryPi RP1 misc device +# + +config MISC_RP1 + tristate "RaspberryPi RP1 PCIe support" + depends on OF_IRQ && PCI_MSI && PCI_QUIRKS + select OF_OVERLAY + 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 +8 -0
@@ -0,0 +1,8 @@ +// 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. + */ + +#include "arm64/broadcom/rp1.dtso"
drivers/misc/rp1/rp1_pci.c new file +305 -0
305 lines not on this page · raw message
drivers/misc/rp1/rp1_pci.h new file +14 -0
@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/* +* Copyright (c) 2018-24 Raspberry Pi Ltd. +* All rights reserved. +*/ + +#ifndef _RP1_EXTERN_H_ +#define _RP1_EXTERN_H_ + +extern char __dtbo_rp1_pci_begin[]; +extern char __dtbo_rp1_pci_end[]; + +#endif
drivers/pci/quirks.c +1 -0
@@ -6269,6 +6269,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
@@ -2615,6 +2615,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 v6 9/10 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 v6 10/10 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
@@ -609,6 +609,7 @@ CONFIG_PINCTRL_QCM2290=y CONFIG_PINCTRL_QCS404=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
@@ -690,6 +691,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
@@ -1272,6 +1274,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
Greg Kroah-Hartman
maintainerRe: [PATCH v6 08/10] misc: rp1: RaspberryPi RP1 misc driver
In reply to Andrea della PortaQuoted 11 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.
The peripherals are accessed by mapping MMIO registers starting from PCI BAR1 region.
Quoted 8 lines
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.
For reasons why this driver is contained in
drivers/misc, please check the links.
Links aren't always around all the time, please document it here why this is needed, and then links can "add to" that summary.
Quoted 123 lines
This driver is heavily based on downstream code from RaspberryPi Foundation, and the original author is Phil Elwell.
Signed-off-by Andrea della Porta <[email protected]>--- MAINTAINERS | 1 + drivers/misc/Kconfig | 1 + drivers/misc/Makefile | 1 + drivers/misc/rp1/Kconfig | 21 +++ drivers/misc/rp1/Makefile | 3 + drivers/misc/rp1/rp1-pci.dtso | 8 + drivers/misc/rp1/rp1_pci.c | 305 ++++++++++++++++++++++++++++++++++ drivers/misc/rp1/rp1_pci.h | 14 ++ drivers/pci/quirks.c | 1 + include/linux/pci_ids.h | 3 + 10 files changed, 358 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 create mode 100644 drivers/misc/rp1/rp1_pci.hMAINTAINERS +1
-0@@ -19583,6 +19583,7 @@ F: Documentation/devicetree/bindings/misc/pci1de4,1.yaml F: Documentation/devicetree/bindings/pci/pci-ep-bus.yaml F: Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml F: drivers/clk/clk-rp1.c +F: drivers/misc/rp1/ F: drivers/pinctrl/pinctrl-rp1.c F: include/dt-bindings/clock/rp1.h F: include/dt-bindings/misc/rp1.hdrivers/misc/Kconfig +1
-0@@ -651,4 +651,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" endmenudrivers/misc/Makefile +1
-0@@ -74,3 +74,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 +21
-0@@ -0,0 +1,21 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# RaspberryPi RP1 misc device +# + +config MISC_RP1 + tristate "RaspberryPi RP1 PCIe support" + depends on OF_IRQ && PCI_MSI && PCI_QUIRKS + select OF_OVERLAY + 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.odrivers/misc/rp1/rp1-pci.dtso new file +8
-0@@ -0,0 +1,8 @@ +// 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. + */ + +#include "arm64/broadcom/rp1.dtso"drivers/misc/rp1/rp1_pci.c new file +8
-0@@ -0,0 +1,305 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (c) 2018-24 Raspberry Pi Ltd. +* All rights reserved. +*/ + +#include <linux/err.h> +#include <linux/interrupt.h>
drivers/misc/rp1/rp1_pci.c line 18
Quoted 10 lines
drivers/misc/rp1/rp1_pci.c new file +10
-0+#include <linux/irq.h> +#include <linux/irqchip/chained_irq.h> +#include <linux/irqdomain.h> +#include <linux/module.h> +#include <linux/msi.h> +#include <linux/of_platform.h> +#include <linux/pci.h> +#include <linux/platform_device.h> + +#include "rp1_pci.h"
Why does a self-contained .c file need a .h file? Please put it all in here.
drivers/misc/rp1/rp1_pci.c line 20
Quoted 2 lines
drivers/misc/rp1/rp1_pci.c new file +2
-0+ +#define RP1_DRIVER_NAME "rp1"
KBUILD_MODNAME?
Quoted 24 lines
drivers/misc/rp1/rp1_pci.c new file +21
-0+ +#define RP1_HW_IRQ_MASK GENMASK(5, 0) + +#define REG_SET 0x800 +#define REG_CLR 0xc00 + +/* MSI-X CFG registers start at 0x8 */ +#define MSIX_CFG (x) (0x8 + (4 * (x))) + +#define MSIX_CFG_IACK_EN BIT(3) +#define MSIX_CFG_IACK BIT(2) +#define MSIX_CFG_ENABLE BIT(0) + +/* Address map */ +#define RP1_PCIE_APBS_BASE 0x108000 + +/* Interrupts */ +#define RP1_INT_END 61 + +struct rp1_dev { +struct pci_dev *pdev;
drivers/misc/rp1/rp1_pci.c line 51
Quoted 10 lines
drivers/misc/rp1/rp1_pci.c new file +10
-0+struct irq_domain *domain; +struct irq_data *pcie_irqds[64 ]; +void __iomem *bar1; +int ovcs_id;/* overlay changeset id */ +bool level_triggered_irq[RP1_INT_END ]; +}; + +static void msix_cfg_set (struct rp1_dev *rp1,unsigned int hwirq,u32 value) +{ +iowrite32 (value, rp1->bar1 +RP1_PCIE_APBS_BASE +REG_SET +MSIX_CFG (hwirq));
Do your writes need a read to flush them properly? Or can they handle this automatically?
thanks,
greg k-h
Re: [PATCH v6 02/10] dt-bindings: pinctrl: Add RaspberryPi RP1 gpio/pinctrl/pinmux bindings
In reply to Andrea della PortaQuoted 6 lines · Andrea della Porta
Add device tree bindings for the gpio/pin/mux controller that is part of the RP1 multi function device, and relative entries in
MAINTAINERSfile.Signed-off-by Andrea della Porta <[email protected]>Reviewed-by Krzysztof Kozlowski <[email protected]>Reviewed-by Linus Walleij <[email protected]>
Signature · 1 line
Florian
Re: [PATCH v6 03/10] dt-bindings: pci: Add common schema for devices accessible through PCI BARs
In reply to Andrea della PortaQuoted 9 lines · Andrea della Porta
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.
Signed-off-by Andrea della Porta <[email protected]>Reviewed-by Rob Herring (Arm) <[email protected]>
Signature · 1 line
Florian
Re: [PATCH v6 01/10] dt-bindings: clock: Add RaspberryPi RP1 clock bindings
In reply to Andrea della PortaQuoted 24 lines · Andrea della Porta
Add device tree bindings for the clock generator found in RP1 multi function device, and relative entries in
MAINTAINERSfile.Signed-off-by Andrea della Porta <[email protected]>Reviewed-by Krzysztof Kozlowski <[email protected]>--- .../clock/raspberrypi,rp1-clocks.yaml | 58 ++++++++++++++++++ MAINTAINERS | 6 ++ .../clock/raspberrypi,rp1-clocks.h | 61 +++++++++++++++++++ 3 files changed, 125 insertions(+)create mode 100644
Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yamlcreate mode 100644include/dt-bindings/clock/raspberrypi,rp1-clocks.hDocumentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml new file +5
-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#
Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml line 15
Quoted 10 lines
Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml new file +10
-0+ +title: RaspberryPi RP1 clock generator + +maintainers: + - Andrea 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 though dividers to generate + the clocks to drive the sub-peripherals embedded inside the chipset.
typo: though -> through
Signature · 1 line
Florian
Re: [PATCH v6 09/10] arm64: dts: bcm2712: Add external clock for RP1 chipset on Rpi5
In reply to Andrea della PortaQuoted 4 lines · Andrea della Porta
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]>
I don't expect conflicts so this could go through the tree that will merge the misc driver (Greg?).
Signature · 1 line
Florian
Re: [PATCH v6 07/10] arm64: dts: rp1: Add support for RaspberryPi's RP1 device
In reply to Andrea della PortaQuoted 9 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.Signed-off-by Andrea della Porta <[email protected]>
Same comment as patch 9, I am happy if Greg takes this patch directly through his tree.
Signature · 1 line
Florian
Re: [PATCH v6 04/10] dt-bindings: misc: Add device specific bindings for RaspberryPi RP1
In reply to Andrea della PortaQuoted 6 lines · Andrea della Porta
The 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.
Signed-off-by Andrea della Porta <[email protected]>Reviewed-by Rob Herring (Arm) <[email protected]>
Signature · 1 line
Florian
Andrea della Porta
maintainerRe: [PATCH v6 08/10] misc: rp1: RaspberryPi RP1 misc driver
In reply to Greg Kroah-HartmanHi Greg,
Quoted 18 lines · Greg Kroah-Hartman
Quoted 17 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.
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.
Quoted 5 lines
Quoted 2 lines
For reasons why this driver is contained in
drivers/misc, please check the links.Links aren't always around all the time, please document it here why this is needed, and then links can "add to" that summary.
Ack.
Quoted 5 lines
Quoted 5 lines
This driver is heavily based on downstream code from RaspberryPi Foundation, and the original author is Phil Elwell.
...
Quoted 19 lines
Quoted 19 lines
drivers/misc/rp1/rp1_pci.c new file +13
-0@@ -0,0 +1,305 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (c) 2018-24 Raspberry Pi Ltd. +* All rights reserved. +*/ + +#include <linux/err.h> +#include <linux/interrupt.h> +#include <linux/irq.h> +#include <linux/irqchip/chained_irq.h> +#include <linux/irqdomain.h> +#include <linux/module.h> +#include <linux/msi.h>
Quoted 8 lines
drivers/misc/rp1/rp1_pci.c line 18
Quoted 5 lines
drivers/misc/rp1/rp1_pci.c new file +5
-0+#include <linux/of_platform.h> +#include <linux/pci.h> +#include <linux/platform_device.h> + +#include "rp1_pci.h" Why does a self-contained .c file need a .h file? Please put it all in here.
I agree with you. Indeed, the very first version of this patch had the header file placed inside the .c, but I received concerns about it and some advice to do it differently, as you can see here:
https://lore.kernel.org/all/ZtWDpaqUG9d9yPPf@apocalypse/
so I've changed it accordingly in V2. So right now I'm not sure what the acceptable behaviour should be ...
Quoted 5 lines
drivers/misc/rp1/rp1_pci.c line 20
Quoted 3 lines
drivers/misc/rp1/rp1_pci.c new file +2
-0+ +#define RP1_DRIVER_NAME "rp1"
KBUILD_MODNAME?
Right. Thanks for pointing that out.
Quoted 22 lines
Quoted 19 lines
drivers/misc/rp1/rp1_pci.c new file +18
-0+ +#define RP1_HW_IRQ_MASK GENMASK(5, 0) + +#define REG_SET 0x800 +#define REG_CLR 0xc00 + +/* MSI-X CFG registers start at 0x8 */ +#define MSIX_CFG (x) (0x8 + (4 * (x))) + +#define MSIX_CFG_IACK_EN BIT(3) +#define MSIX_CFG_IACK BIT(2) +#define MSIX_CFG_ENABLE BIT(0) + +/* Address map */ +#define RP1_PCIE_APBS_BASE 0x108000 + +/* Interrupts */ +#define RP1_INT_END 61
Quoted 17 lines
drivers/misc/rp1/rp1_pci.c line 51
Quoted 13 lines
drivers/misc/rp1/rp1_pci.c new file +13
-0+ +struct rp1_dev { +struct pci_dev *pdev; +struct irq_domain *domain; +struct irq_data *pcie_irqds[64 ]; +void __iomem *bar1; +int ovcs_id;/* overlay changeset id */ +bool level_triggered_irq[RP1_INT_END ]; +}; + +static void msix_cfg_set (struct rp1_dev *rp1,unsigned int hwirq,u32 value) +{ +iowrite32 (value, rp1->bar1 +RP1_PCIE_APBS_BASE +REG_SET +MSIX_CFG (hwirq));Do your writes need a read to flush them properly? Or can they handle this automatically?
I had some thoughts with RaspberryPi foundation folks to double check it, and it seems that there should be no need to readback the value (unless we want to go really paranoid), so I would avoid that since in case of level handled interrupt we would end up reading the register on every triggering interrupts.
Many thanks,
Andrea
Quoted 3 lines
thanks,
greg k-h
Greg Kroah-Hartman
maintainerRe: [PATCH v6 08/10] misc: rp1: RaspberryPi RP1 misc driver
Quoted 65 lines · Andrea della Porta
Hi Greg,
Quoted 18 lines · Greg Kroah-Hartman
Quoted 17 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.
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.
Quoted 5 lines
Quoted 2 lines
For reasons why this driver is contained in
drivers/misc, please check the links.Links aren't always around all the time, please document it here why this is needed, and then links can "add to" that summary.
Ack.
Quoted 5 lines
Quoted 5 lines
This driver is heavily based on downstream code from RaspberryPi Foundation, and the original author is Phil Elwell.
...
Quoted 19 lines
Quoted 19 lines
drivers/misc/rp1/rp1_pci.c new file +13
-0@@ -0,0 +1,305 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (c) 2018-24 Raspberry Pi Ltd. +* All rights reserved. +*/ + +#include <linux/err.h> +#include <linux/interrupt.h> +#include <linux/irq.h> +#include <linux/irqchip/chained_irq.h> +#include <linux/irqdomain.h> +#include <linux/module.h> +#include <linux/msi.h> Quoted 8 lines
drivers/misc/rp1/rp1_pci.c line 18
Quoted 5 lines
drivers/misc/rp1/rp1_pci.c new file +5
-0+#include <linux/of_platform.h> +#include <linux/pci.h> +#include <linux/platform_device.h> + +#include "rp1_pci.h" Why does a self-contained .c file need a .h file? Please put it all in here.
Quoted 6 lines
I agree with you. Indeed, the very first version of this patch had the header file placed inside the .c, but I received concerns about it and some advice to do it differently, as you can see here:
https://lore.kernel.org/all/ZtWDpaqUG9d9yPPf@apocalypse/
so I've changed it accordingly in V2. So right now I'm not sure what the acceptable behaviour should be ...
It's a pretty simple rule:
Only use a .h file if multiple .c files need to see the symbol.
So no .h file is needed here.
Quoted 17 lines
Quoted 7 lines
Quoted 7 lines
drivers/misc/rp1/rp1_pci.c new file +7
-0+struct rp1_dev { +struct pci_dev *pdev; +struct irq_domain *domain; +struct irq_data *pcie_irqds[64 ]; +void __iomem *bar1; +int ovcs_id;/* overlay changeset id */ +bool level_triggered_irq[RP1_INT_END ];Quoted 9 lines
drivers/misc/rp1/rp1_pci.c line 51
Quoted 5 lines
drivers/misc/rp1/rp1_pci.c new file +5
-0+}; + +static void msix_cfg_set (struct rp1_dev *rp1,unsigned int hwirq,u32 value) +{ +iowrite32 (value, rp1->bar1 +RP1_PCIE_APBS_BASE +REG_SET +MSIX_CFG (hwirq));Do your writes need a read to flush them properly? Or can they handle this automatically?
Quoted 4 lines
I had some thoughts with RaspberryPi foundation folks to double check it, and it seems that there should be no need to readback the value (unless we want to go really paranoid), so I would avoid that since in case of level handled interrupt we would end up reading the register on every triggering interrupts.
Ok, if it passes testing, that's fine, hopefully it works properly, but if not, you now have a trail to go and fix it in the future :)
thanks,
greg k-h
Andrea della Porta
maintainerRe: [PATCH v6 08/10] misc: rp1: RaspberryPi RP1 misc driver
Hi Greg,
Quoted 73 lines · Greg Kroah-Hartman
Quoted 65 lines · Andrea della Porta
Hi Greg,
Quoted 18 lines · Greg Kroah-Hartman
Quoted 17 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.
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.
Quoted 5 lines
Quoted 2 lines
For reasons why this driver is contained in
drivers/misc, please check the links.Links aren't always around all the time, please document it here why this is needed, and then links can "add to" that summary.
Ack.
Quoted 5 lines
Quoted 5 lines
This driver is heavily based on downstream code from RaspberryPi Foundation, and the original author is Phil Elwell.
...
Quoted 19 lines
Quoted 19 lines
drivers/misc/rp1/rp1_pci.c new file +13
-0@@ -0,0 +1,305 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (c) 2018-24 Raspberry Pi Ltd. +* All rights reserved. +*/ + +#include <linux/err.h> +#include <linux/interrupt.h> +#include <linux/irq.h> +#include <linux/irqchip/chained_irq.h> +#include <linux/irqdomain.h> +#include <linux/module.h> +#include <linux/msi.h> Quoted 8 lines
drivers/misc/rp1/rp1_pci.c line 18
Quoted 5 lines
drivers/misc/rp1/rp1_pci.c new file +5
-0+#include <linux/of_platform.h> +#include <linux/pci.h> +#include <linux/platform_device.h> + +#include "rp1_pci.h" Why does a self-contained .c file need a .h file? Please put it all in here.
Quoted 6 lines
I agree with you. Indeed, the very first version of this patch had the header file placed inside the .c, but I received concerns about it and some advice to do it differently, as you can see here:
https://lore.kernel.org/all/ZtWDpaqUG9d9yPPf@apocalypse/
so I've changed it accordingly in V2. So right now I'm not sure what the acceptable behaviour should be ...
Quoted 4 lines
It's a pretty simple rule:
Only use a .h file if multiple .c files need to see the symbol.So no .h file is needed here.
Perfect, I'll revert back that two lines to V1 then. Please be aware though that this will trigger the following checkpatch warning:
WARNING: externs should be avoided in .c files
Quoted 18 lines
Quoted 18 lines
Quoted 17 lines
drivers/misc/rp1/rp1_pci.c line 51
Quoted 13 lines
drivers/misc/rp1/rp1_pci.c new file +12
-0+struct rp1_dev { +struct pci_dev *pdev; +struct irq_domain *domain; +struct irq_data *pcie_irqds[64 ]; +void __iomem *bar1; +int ovcs_id;/* overlay changeset id */ +bool level_triggered_irq[RP1_INT_END ]; +}; + +static void msix_cfg_set (struct rp1_dev *rp1,unsigned int hwirq,u32 value) +{ +iowrite32 (value, rp1->bar1 +RP1_PCIE_APBS_BASE +REG_SET +MSIX_CFG (hwirq));Do your writes need a read to flush them properly? Or can they handle this automatically?
Quoted 7 lines
Quoted 4 lines
I had some thoughts with RaspberryPi foundation folks to double check it, and it seems that there should be no need to readback the value (unless we want to go really paranoid), so I would avoid that since in case of level handled interrupt we would end up reading the register on every triggering interrupts.
Ok, if it passes testing, that's fine, hopefully it works properly, but if not, you now have a trail to go and fix it in the future :)
Sure :)
Many thanks,
Andrea
Quoted 4 lines
thanks,
greg k-h
Greg Kroah-Hartman
maintainerRe: [PATCH v6 08/10] misc: rp1: RaspberryPi RP1 misc driver
Quoted 79 lines · Andrea della Porta
Hi Greg,
Quoted 76 lines · Greg Kroah-Hartman
Quoted 65 lines · Andrea della Porta
Hi Greg,
Quoted 18 lines · Greg Kroah-Hartman
Quoted 17 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.
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.
Quoted 5 lines
Quoted 2 lines
For reasons why this driver is contained in
drivers/misc, please check the links.Links aren't always around all the time, please document it here why this is needed, and then links can "add to" that summary.
Ack.
Quoted 5 lines
Quoted 5 lines
This driver is heavily based on downstream code from RaspberryPi Foundation, and the original author is Phil Elwell.
...
Quoted 19 lines
Quoted 19 lines
drivers/misc/rp1/rp1_pci.c new file +13
-0@@ -0,0 +1,305 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (c) 2018-24 Raspberry Pi Ltd. +* All rights reserved. +*/ + +#include <linux/err.h> +#include <linux/interrupt.h> +#include <linux/irq.h> +#include <linux/irqchip/chained_irq.h> +#include <linux/irqdomain.h> +#include <linux/module.h> +#include <linux/msi.h> Quoted 8 lines
drivers/misc/rp1/rp1_pci.c line 18
Quoted 5 lines
drivers/misc/rp1/rp1_pci.c new file +5
-0+#include <linux/of_platform.h> +#include <linux/pci.h> +#include <linux/platform_device.h> + +#include "rp1_pci.h" Why does a self-contained .c file need a .h file? Please put it all in here.
Quoted 6 lines
I agree with you. Indeed, the very first version of this patch had the header file placed inside the .c, but I received concerns about it and some advice to do it differently, as you can see here:
https://lore.kernel.org/all/ZtWDpaqUG9d9yPPf@apocalypse/
so I've changed it accordingly in V2. So right now I'm not sure what the acceptable behaviour should be ...It's a pretty simple rule:
Only use a .h file if multiple .c files need to see the symbol.
Quoted 6 lines
Quoted 1 line
So no .h file is needed here.
Perfect, I'll revert back that two lines to V1 then. Please be aware though that this will trigger the following checkpatch warning:
WARNING: externs should be avoided in .c files
Well where are those externs defined at? Shouldn't there be a .h file for them somewhere in the tree if they really are global?
thanks,
greg k-h
Andrea della Porta
maintainerRe: [PATCH v6 08/10] misc: rp1: RaspberryPi RP1 misc driver
Hi Greg,
Quoted 82 lines · Greg Kroah-Hartman
Quoted 81 lines · Andrea della Porta
Hi Greg,
Quoted 77 lines · Greg Kroah-Hartman
Quoted 65 lines · Andrea della Porta
Hi Greg,
Quoted 18 lines · Greg Kroah-Hartman
Quoted 17 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.
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.
Quoted 5 lines
Quoted 2 lines
For reasons why this driver is contained in
drivers/misc, please check the links.Links aren't always around all the time, please document it here why this is needed, and then links can "add to" that summary.
Ack.
Quoted 5 lines
Quoted 5 lines
This driver is heavily based on downstream code from RaspberryPi Foundation, and the original author is Phil Elwell.
...
Quoted 19 lines
Quoted 19 lines
drivers/misc/rp1/rp1_pci.c new file +13
-0@@ -0,0 +1,305 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (c) 2018-24 Raspberry Pi Ltd. +* All rights reserved. +*/ + +#include <linux/err.h> +#include <linux/interrupt.h> +#include <linux/irq.h> +#include <linux/irqchip/chained_irq.h> +#include <linux/irqdomain.h> +#include <linux/module.h> +#include <linux/msi.h> Quoted 8 lines
drivers/misc/rp1/rp1_pci.c line 18
Quoted 5 lines
drivers/misc/rp1/rp1_pci.c new file +5
-0+#include <linux/of_platform.h> +#include <linux/pci.h> +#include <linux/platform_device.h> + +#include "rp1_pci.h" Why does a self-contained .c file need a .h file? Please put it all in here.
Quoted 6 lines
I agree with you. Indeed, the very first version of this patch had the header file placed inside the .c, but I received concerns about it and some advice to do it differently, as you can see here:
https://lore.kernel.org/all/ZtWDpaqUG9d9yPPf@apocalypse/
so I've changed it accordingly in V2. So right now I'm not sure what the acceptable behaviour should be ...It's a pretty simple rule:
Only use a .h file if multiple .c files need to see the symbol.So no .h file is needed here.
Quoted 7 lines
Quoted 4 lines
Perfect, I'll revert back that two lines to V1 then. Please be aware though that this will trigger the following checkpatch warning:
WARNING: externs should be avoided in .c files
Well where are those externs defined at? Shouldn't there be a .h file for them somewhere in the tree if they really are global?
Those symbols are deined in drivers/misc/rp1/rp1-pci.dtbo.S (added by this patchset) and created by cmd_wrap_S_dtb in scripts/Makefile.lib. They are just placeholders that contains rp1-pci.dtbo as
a binary blob, in order for the driver (rp1_pci.c) to be able to use the binary buffer representing the overlay and address it from the driver probe function.
So there's no other reference from outside rp1_pci.c to those two symbols. In comparison, this is the very same approach used by a recently accepted patch involving drivers/misc/lan966x_pci.c, which also has the two externs in it and triggers the same checkpatch warning.
Many thanks,
Andrea
Quoted 4 lines
thanks,
greg k-h
Greg Kroah-Hartman
maintainerRe: [PATCH v6 08/10] misc: rp1: RaspberryPi RP1 misc driver
Quoted 93 lines · Andrea della Porta
Hi Greg,
Quoted 82 lines · Greg Kroah-Hartman
Quoted 81 lines · Andrea della Porta
Hi Greg,
Quoted 77 lines · Greg Kroah-Hartman
Quoted 65 lines · Andrea della Porta
Hi Greg,
Quoted 18 lines · Greg Kroah-Hartman
Quoted 17 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.
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.
Quoted 5 lines
Quoted 2 lines
For reasons why this driver is contained in
drivers/misc, please check the links.Links aren't always around all the time, please document it here why this is needed, and then links can "add to" that summary.
Ack.
Quoted 5 lines
Quoted 5 lines
This driver is heavily based on downstream code from RaspberryPi Foundation, and the original author is Phil Elwell.
...
Quoted 19 lines
Quoted 19 lines
drivers/misc/rp1/rp1_pci.c new file +13
-0@@ -0,0 +1,305 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (c) 2018-24 Raspberry Pi Ltd. +* All rights reserved. +*/ + +#include <linux/err.h> +#include <linux/interrupt.h> +#include <linux/irq.h> +#include <linux/irqchip/chained_irq.h> +#include <linux/irqdomain.h> +#include <linux/module.h> +#include <linux/msi.h> Quoted 8 lines
drivers/misc/rp1/rp1_pci.c line 18
Quoted 5 lines
drivers/misc/rp1/rp1_pci.c new file +5
-0+#include <linux/of_platform.h> +#include <linux/pci.h> +#include <linux/platform_device.h> + +#include "rp1_pci.h" Why does a self-contained .c file need a .h file? Please put it all in here.
Quoted 6 lines
I agree with you. Indeed, the very first version of this patch had the header file placed inside the .c, but I received concerns about it and some advice to do it differently, as you can see here:
https://lore.kernel.org/all/ZtWDpaqUG9d9yPPf@apocalypse/
so I've changed it accordingly in V2. So right now I'm not sure what the acceptable behaviour should be ...It's a pretty simple rule:
Only use a .h file if multiple .c files need to see the symbol.So no .h file is needed here.
Quoted 7 lines
Quoted 4 lines
Perfect, I'll revert back that two lines to V1 then. Please be aware though that this will trigger the following checkpatch warning:
WARNING: externs should be avoided in .c files
Well where are those externs defined at? Shouldn't there be a .h file for them somewhere in the tree if they really are global?
Quoted 10 lines
Those symbols are deined in
drivers/misc/rp1/rp1-pci.dtbo.S(added by this patchset) and created bycmd_wrap_S_dtbinscripts/Makefile.lib. They are just placeholders that contains rp1-pci.dtbo as
a binary blob, in order for the driver (rp1_pci.c) to be able to use the binary buffer representing the overlay and address it from the driver probe function.
So there's no other reference from outsiderp1_pci.cto those two symbols. In comparison, this is the very same approach used by a recently accepted patch involvingdrivers/misc/lan966x_pci.c, which also has the two externs in it and triggers the same checkpatch warning.
Ok, that's fine, checkpatch is just a hint, not a hard-and-fast-rule.
thanks,
greg k-h
Re: [PATCH v6 08/10] misc: rp1: RaspberryPi RP1 misc driver
In reply to Andrea della PortaQuoted 5 lines
Quoted 2 lines
Well where are those externs defined at? Shouldn't there be a .h file for them somewhere in the tree if they really are global?
Those symbols are deined in
drivers/misc/rp1/rp1-pci.dtbo.S(added by this patchset) and created bycmd_wrap_S_dtbinscripts/Makefile.lib.
Could cmd_wrap_S_dtb be extended to actually produce a header?
But that might confuse static analysers?
Andrew
Andrea della Porta
maintainerRe: [PATCH v6 08/10] misc: rp1: RaspberryPi RP1 misc driver
Hi Andrew,
Quoted 7 lines · Andrew Lunn
Quoted 5 lines
Quoted 2 lines
Well where are those externs defined at? Shouldn't there be a .h file for them somewhere in the tree if they really are global?
Those symbols are deined in
drivers/misc/rp1/rp1-pci.dtbo.S(added by this patchset) and created bycmd_wrap_S_dtbinscripts/Makefile.lib.Could
cmd_wrap_S_dtbbe extended to actually produce a header?
It will produce a header nonetheless, one which is needed by just one .c file violating Greg's rule about having a header only if referenced by more than one source and the symbol is truly global, IMHO.
Thanks,
Andrea
Quoted 4 lines
But that might confuse static analysers?
Andrew
Re: [PATCH v6 08/10] misc: rp1: RaspberryPi RP1 misc driver
In reply to Greg Kroah-HartmanHi Andrea,
Quoted 105 lines · On Tue, 21 Jan 2025 15:49:04 +0100 Greg Kroah-Hartman…
Quoted 93 lines · Andrea della Porta
Hi Greg,
Quoted 82 lines · Greg Kroah-Hartman
Quoted 81 lines · Andrea della Porta
Hi Greg,
Quoted 77 lines · Greg Kroah-Hartman
Quoted 65 lines · Andrea della Porta
Hi Greg,
Quoted 18 lines · Greg Kroah-Hartman
Quoted 17 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.
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.
Quoted 5 lines
Quoted 2 lines
For reasons why this driver is contained in
drivers/misc, please check the links.Links aren't always around all the time, please document it here why this is needed, and then links can "add to" that summary.
Ack.
Quoted 5 lines
Quoted 5 lines
This driver is heavily based on downstream code from RaspberryPi Foundation, and the original author is Phil Elwell.
...
Quoted 19 lines
Quoted 19 lines
drivers/misc/rp1/rp1_pci.c new file +13
-0@@ -0,0 +1,305 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (c) 2018-24 Raspberry Pi Ltd. +* All rights reserved. +*/ + +#include <linux/err.h> +#include <linux/interrupt.h> +#include <linux/irq.h> +#include <linux/irqchip/chained_irq.h> +#include <linux/irqdomain.h> +#include <linux/module.h> +#include <linux/msi.h> Quoted 8 lines
drivers/misc/rp1/rp1_pci.c line 18
Quoted 5 lines
drivers/misc/rp1/rp1_pci.c new file +5
-0+#include <linux/of_platform.h> +#include <linux/pci.h> +#include <linux/platform_device.h> + +#include "rp1_pci.h" Why does a self-contained .c file need a .h file? Please put it all in here.
Quoted 6 lines
I agree with you. Indeed, the very first version of this patch had the header file placed inside the .c, but I received concerns about it and some advice to do it differently, as you can see here:
https://lore.kernel.org/all/ZtWDpaqUG9d9yPPf@apocalypse/
so I've changed it accordingly in V2. So right now I'm not sure what the acceptable behaviour should be ...It's a pretty simple rule:
Only use a .h file if multiple .c files need to see the symbol.So no .h file is needed here.
Quoted 7 lines
Quoted 4 lines
Perfect, I'll revert back that two lines to V1 then. Please be aware though that this will trigger the following checkpatch warning:
WARNING: externs should be avoided in .c files
Well where are those externs defined at? Shouldn't there be a .h file for them somewhere in the tree if they really are global?
Quoted 10 lines
Those symbols are deined in
drivers/misc/rp1/rp1-pci.dtbo.S(added by this patchset) and created bycmd_wrap_S_dtbinscripts/Makefile.lib. They are just placeholders that contains rp1-pci.dtbo as
a binary blob, in order for the driver (rp1_pci.c) to be able to use the binary buffer representing the overlay and address it from the driver probe function.
So there's no other reference from outsiderp1_pci.cto those two symbols. In comparison, this is the very same approach used by a recently accepted patch involvingdrivers/misc/lan966x_pci.c, which also has the two externs in it and triggers the same checkpatch warning.
Quoted 2 lines
Ok, that's fine, checkpatch is just a hint, not a hard-and-fast-rule.
Maybe just to avoid confusion for future readers, you can add a comment as I did for the lan966x:
https://elixir.bootlin.com/linux/v6.13-rc3/source/drivers/misc/lan966x_pci.c#L21
This will not avoid the warning but will give an explanation to people looking closer at this checkpatch warning.
Best regards,
Hervé
Andrea della Porta
maintainerRe: [PATCH v6 08/10] misc: rp1: RaspberryPi RP1 misc driver
Hi Herve,
Quoted 113 lines · Herve Codina
Hi Andrea,
Quoted 105 lines · On Tue, 21 Jan 2025 15:49:04 +0100 Greg Kroah-Hartman…
Quoted 93 lines · Andrea della Porta
Hi Greg,
Quoted 82 lines · Greg Kroah-Hartman
Quoted 81 lines · Andrea della Porta
Hi Greg,
Quoted 77 lines · Greg Kroah-Hartman
Quoted 65 lines · Andrea della Porta
Hi Greg,
Quoted 18 lines · Greg Kroah-Hartman
Quoted 17 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.
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.
Quoted 5 lines
Quoted 2 lines
For reasons why this driver is contained in
drivers/misc, please check the links.Links aren't always around all the time, please document it here why this is needed, and then links can "add to" that summary.
Ack.
Quoted 5 lines
Quoted 5 lines
This driver is heavily based on downstream code from RaspberryPi Foundation, and the original author is Phil Elwell.
...
Quoted 19 lines
Quoted 19 lines
drivers/misc/rp1/rp1_pci.c new file +13
-0@@ -0,0 +1,305 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (c) 2018-24 Raspberry Pi Ltd. +* All rights reserved. +*/ + +#include <linux/err.h> +#include <linux/interrupt.h> +#include <linux/irq.h> +#include <linux/irqchip/chained_irq.h> +#include <linux/irqdomain.h> +#include <linux/module.h> +#include <linux/msi.h> Quoted 8 lines
drivers/misc/rp1/rp1_pci.c line 18
Quoted 5 lines
drivers/misc/rp1/rp1_pci.c new file +5
-0+#include <linux/of_platform.h> +#include <linux/pci.h> +#include <linux/platform_device.h> + +#include "rp1_pci.h" Why does a self-contained .c file need a .h file? Please put it all in here.
Quoted 6 lines
I agree with you. Indeed, the very first version of this patch had the header file placed inside the .c, but I received concerns about it and some advice to do it differently, as you can see here:
https://lore.kernel.org/all/ZtWDpaqUG9d9yPPf@apocalypse/
so I've changed it accordingly in V2. So right now I'm not sure what the acceptable behaviour should be ...It's a pretty simple rule:
Only use a .h file if multiple .c files need to see the symbol.So no .h file is needed here.
Quoted 7 lines
Quoted 4 lines
Perfect, I'll revert back that two lines to V1 then. Please be aware though that this will trigger the following checkpatch warning:
WARNING: externs should be avoided in .c files
Well where are those externs defined at? Shouldn't there be a .h file for them somewhere in the tree if they really are global?
Quoted 10 lines
Those symbols are deined in
drivers/misc/rp1/rp1-pci.dtbo.S(added by this patchset) and created bycmd_wrap_S_dtbinscripts/Makefile.lib. They are just placeholders that contains rp1-pci.dtbo as
a binary blob, in order for the driver (rp1_pci.c) to be able to use the binary buffer representing the overlay and address it from the driver probe function.
So there's no other reference from outsiderp1_pci.cto those two symbols. In comparison, this is the very same approach used by a recently accepted patch involvingdrivers/misc/lan966x_pci.c, which also has the two externs in it and triggers the same checkpatch warning.Quoted 2 lines
Ok, that's fine, checkpatch is just a hint, not a hard-and-fast-rule.
Quoted 6 lines
Maybe just to avoid confusion for future readers, you can add a comment as I did for the lan966x:
https://elixir.bootlin.com/linux/v6.13-rc3/source/drivers/misc/lan966x_pci.c#L21This will not avoid the warning but will give an explanation to people looking closer at this checkpatch warning.
Good advice, thanks Herve! Added...
Regards,
Andrea
Quoted 3 lines
Best regards,
Hervé
Re: [PATCH v6 05/10] clk: rp1: Add support for clocks provided by RP1
In reply to Andrea della PortaQuoted 5 lines · Andrea della Porta
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.
drivers/clk/clk-rp1.c new file +1
-0+#define PLL_PRIM_DIV1_SHIFT 16
drivers/clk/clk-rp1.c
Quoted 10 lines
drivers/clk/clk-rp1.c new file +10
-0+#define PLL_PRIM_DIV1_WIDTH 3 +#define PLL_PRIM_DIV1_MASK GENMASK(PLL_PRIM_DIV1_SHIFT + \ + PLL_PRIM_DIV1_WIDTH - 1, \ + PLL_PRIM_DIV1_SHIFT) + +#define PLL_PRIM_DIV2_SHIFT 12 +#define PLL_PRIM_DIV2_WIDTH 3 +#define PLL_PRIM_DIV2_MASK GENMASK(PLL_PRIM_DIV2_SHIFT + \ + PLL_PRIM_DIV2_WIDTH - 1, \ + PLL_PRIM_DIV2_SHIFT)
Maybe this is standard drivers/clk style, but this seems like overkill to me. I think this would be sufficient and easier to read:
#define PLL_PRIM_DIV1_MASK GENMASK(18, 16) #define PLL_PRIM_DIV2_MASK GENMASK(14, 12)
drivers/clk/clk-rp1.c line 625
Quoted 11 lines
drivers/clk/clk-rp1.c new file +11
-0+static unsigned long rp1_pll_recalc_rate (struct clk_hw *hw, +unsigned long parent_rate) +{ + struct rp1_clk_desc *pll = container_of(hw, struct rp1_clk_desc, hw); +struct rp1_clockman *clockman = pll->clockman; +const struct rp1_pll_data *data = pll->data; +u32 prim, prim_div1, prim_div2; + + prim =clockman_read (clockman, data->ctrl_reg); + prim_div1 = (prim &PLL_PRIM_DIV1_MASK ) >>PLL_PRIM_DIV1_SHIFT ; + prim_div2 = (prim &PLL_PRIM_DIV2_MASK ) >>PLL_PRIM_DIV2_SHIFT ;
And then here, I think you can just use FIELD_GET():
prim_div1 = FIELD_GET(PLL_PRIM_DIV1_MASK, prim); prim_div2 = FIELD_GET(PLL_PRIM_DIV2_MASK, prim);
It looks like the same could be done for PLL_SEC_DIV_MASK, PLL_CS_REFDIV_SHIFT, PLL_PH_PHASE_SHIFT, CLK_CTRL_AUXSRC_MASK, etc.
Andrea della Porta
maintainerRe: [PATCH v6 05/10] clk: rp1: Add support for clocks provided by RP1
Hi Bjorn,
Quoted 20 lines · Bjorn Helgaas
Quoted 5 lines · Andrea della Porta
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.
drivers/clk/clk-rp1.c new file +1
-0+#define PLL_PRIM_DIV1_SHIFT 16drivers/clk/clk-rp1.c
Quoted 10 lines
drivers/clk/clk-rp1.c new file +10
-0+#define PLL_PRIM_DIV1_WIDTH 3 +#define PLL_PRIM_DIV1_MASK GENMASK(PLL_PRIM_DIV1_SHIFT + \ + PLL_PRIM_DIV1_WIDTH - 1, \ + PLL_PRIM_DIV1_SHIFT) + +#define PLL_PRIM_DIV2_SHIFT 12 +#define PLL_PRIM_DIV2_WIDTH 3 +#define PLL_PRIM_DIV2_MASK GENMASK(PLL_PRIM_DIV2_SHIFT + \ + PLL_PRIM_DIV2_WIDTH - 1, \ + PLL_PRIM_DIV2_SHIFT)Maybe this is standard
drivers/clkstyle, but this seems like overkill to me. I think this would be sufficient and easier to read:
Quoted 2 lines
#define PLL_PRIM_DIV1_MASK GENMASK(18, 16) #define PLL_PRIM_DIV2_MASK GENMASK(14, 12)
Ack.
Quoted 15 lines
drivers/clk/clk-rp1.c line 625
Quoted 12 lines
drivers/clk/clk-rp1.c new file +11
-0+static unsigned long rp1_pll_recalc_rate (struct clk_hw *hw, +unsigned long parent_rate) +{ + struct rp1_clk_desc *pll = container_of(hw, struct rp1_clk_desc, hw); +struct rp1_clockman *clockman = pll->clockman; +const struct rp1_pll_data *data = pll->data; +u32 prim, prim_div1, prim_div2; + + prim =clockman_read (clockman, data->ctrl_reg); + prim_div1 = (prim &PLL_PRIM_DIV1_MASK ) >>PLL_PRIM_DIV1_SHIFT ; + prim_div2 = (prim &PLL_PRIM_DIV2_MASK ) >>PLL_PRIM_DIV2_SHIFT ;And then here, I think you can just use
FIELD_GET():
Quoted 5 lines
prim_div1 = FIELD_GET(PLL_PRIM_DIV1_MASK, prim); prim_div2 = FIELD_GET(PLL_PRIM_DIV2_MASK, prim);It looks like the same could be done for
PLL_SEC_DIV_MASK,PLL_CS_REFDIV_SHIFT,PLL_PH_PHASE_SHIFT,CLK_CTRL_AUXSRC_MASK, etc.
Ack.
Regards,
Andrea