Add support for RaspberryPi RP1 PCI device using a DT overlay
Subsystems (10)
Andrea della Porta
maintainerv3 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.
-PATCHES 5 and 6: preparatory patches that fix the address mapping
translation (especially wrt dma-ranges).
-PATCH 7 and 8: add clock and gpio device drivers.
-PATCH 9: 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 10: 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 11: add the external clock node (used by RP1) to the main dts.
-PATCH 12: 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
Link:
- [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 V3:
NEW ADDITIONS ------------------------------------------------
- Fixed a bug in of_pci_prop_ranges() that was incorrectly using a CPU address instead of PCI bus address while assigning "ranges" properties to PCI-PCI bridge nodes.
As a side effect, the patch "PCI: of_property: Sanitize 32 bit PCI address parsed from DT" has been dropped since it's no longer necessary.
RP1 misc driver -----------------------------------
- Dropped -@ option while compiling the dtso.
- Removed unused includes.
- Dropped unused sys_clk references.
- Got rid of dump_bar().
- Added the relevant unregister function on exit paths for mapped interrupts and domain.
- Added missing MODULE_DEVICE_TABLE().
- reset_control no longer claimed in probe().
- dtbo_size and dtbo_start local vars definition moved at the beginnning of the probe() function.
- the DTB overlay is now applied after the interrupt controller has been setup.
- Reworked the Kconfig dependency list for CONFIG_MISC_RP1 to avoid a recursion.
GPIO/PINCTRL --------------------------------------
- Gpio line names changes (and relative dtbo and preparatory patches) have been dropped.
CLOCKS --------------------------------------
- raspberrypi,rp1-clocks.h: license adjusted.
- Removed unused headers.
- Replaced locally defined KHZ and MHZ with defines from linux/units.h
- Added regmap support for registers which also has builtin support for showing regs via debugfs. Dropped the previous implementation of debugfs attributes.
- Reworked the clock tree using clk_parent_data instead of strings. This also allowed to get rid of __clk_get_hw() and friends.
- Split a couple of lines assigning to calc_rate into multi-lines for ease of understanding.
- Dropped .set_rate function from rp1_pll_ph_ops since it does nothing.
- Initialize struct clk_init_data init via = {} instead of memset.
- Used dev_err_probe() instead of dev_err().
- Module init/exit declaration replaced by module_platform_driver().
- Kconfig: CONFIG_COMMON_CLOCK_RP1 now depends on CONFIG_MISC_RP1 instead of CONFIG_PCI.
DTS -----------------------------------------
- "rp1-xosc" renamed to "xosc"
BINDINGS ------------------------------------
- raspberrypi,rp1-gpio.yaml: removed a paragraph in the description of pinctrl node since it's already covered by pinctrl-bindings.
- All paths to referenced bindings are now full-paths.
- Uniformly using single quotes over double quotes on patterns and strings.
- Amended some node names to adhere to DTS coding style.
- Dropped unused labels in examples.
- pci-ep-bus.yaml: simplified the definition of pci-ep-bus node.
- pci-ep-bus.yaml: added additionalProperties: true.
- pci1de4,1.yaml: interrupt-controller and #interrupt-cells moved from pci-ep-bus node to the main device.
- pci1de4,1.yaml: @unit-number not optional anymore.
- pci1de4,1.yaml: droppped pci-ep-bus redefinition (already inherited by pci-ep-bus.yaml). Also removed the internal SoC nodes.
Andrea della Porta (12):
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
PCI: of_property: Assign PCI instead of CPU bus address to dynamic
bridge nodes
of: address: Preserve the flags portion on 1:1 dma-ranges mapping
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 | 62 + .../devicetree/bindings/misc/pci1de4,1.yaml | 80 + .../devicetree/bindings/pci/pci-ep-bus.yaml | 58 + .../pinctrl/raspberrypi,rp1-gpio.yaml | 163 ++ MAINTAINERS | 14 + arch/arm64/boot/dts/broadcom/bcm2712.dtsi | 7 + arch/arm64/boot/dts/broadcom/rp1.dtso | 61 + arch/arm64/configs/defconfig | 3 + drivers/clk/Kconfig | 8 + drivers/clk/Makefile | 1 + drivers/clk/clk-rp1.c | 1540 +++++++++++++++++ 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 | 357 ++++ drivers/misc/rp1/rp1_pci.h | 14 + drivers/of/address.c | 3 +- drivers/pci/of_property.c | 2 +- drivers/pci/quirks.c | 1 + drivers/pinctrl/Kconfig | 11 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/pinctrl-rp1.c | 801 +++++++++ .../clock/raspberrypi,rp1-clocks.h | 61 + include/linux/pci_ids.h | 3 + 26 files changed, 3283 insertions(+), 2 deletions(-) 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 v3 1/12 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 | 62 +++++++++++++++++++ MAINTAINERS | 6 ++ .../clock/raspberrypi,rp1-clocks.h | 61 ++++++++++++++++++ 3 files changed, 129 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 +62 -0
@@ -0,0 +1,62 @@ +# 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': + description: + The index in the assigned-clocks is mapped to the output clock as per + definitions in include/dt-bindings/clock/raspberrypi,rp1-clocks.h. + const: 1 + + clocks: + maxItems: 1 + + clock-names: + const: xosc + +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>; + clock-names = "xosc"; + }; + };
MAINTAINERS +6 -0
@@ -19380,6 +19380,12 @@ F: Documentation/devicetree/bindings/media/raspberrypi,pispbe.yaml F: drivers/media/platform/raspberrypi/pisp_be/ F: include/uapi/linux/media/raspberrypi/ +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
Re: [PATCH v3 01/12] dt-bindings: clock: Add RaspberryPi RP1 clock bindings
Quoted 5 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]>---
Please do not send new versions of patchsets while discussion is still going. I responded to you on v2, pretty next day I think. It took you two weeks to respond to my comments. That was on 21st of October, a week ago, so I still have some time to respond to you.
Best regards,
Krzysztof
Re: [PATCH v3 01/12] dt-bindings: clock: Add RaspberryPi RP1 clock bindings
In reply to Andrea della PortaQuoted 38 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]>--- .../clock/raspberrypi,rp1-clocks.yaml | 62 +++++++++++++++++++ MAINTAINERS | 6 ++ .../clock/raspberrypi,rp1-clocks.h | 61 ++++++++++++++++++ 3 files changed, 129 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml create mode 100644 include/dt-bindings/clock/raspberrypi,rp1-clocks.hDocumentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml new file +20
-0@@ -0,0 +1,62 @@ +# 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:
Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml line 30
Quoted 10 lines
Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml new file +10
-0+ compatible: + const: raspberrypi,rp1-clocks + + reg: + maxItems: 1 + + '#clock-cells': + description: + The index in the assigned-clocks is mapped to the output clock as per + definitions in include/dt-bindings/clock/raspberrypi,rp1-clocks.h.
You still describe how current driver matches assigned-clocks to your output clocks. That's not the property of clock-cells and that's not how assigned-clocks work.
There are no assigned clocks in your DTS, so this is really irrelevant (or not correct, choose).
Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml line 37
Quoted 7 lines
Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml new file +7
-0+ const: 1 + + clocks: + maxItems: 1 + + clock-names: + const: xosc
What is the purpose of clock-names if you do not use it? Drop.
Quoted 13 lines
Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml new file +13
-0+ +required: + - compatible + - reg + - '#clock-cells' + - clocks + +additionalProperties: false + +examples: + - | + #include <dt-bindings/clock/raspberrypi,rp1-clocks.h> +
Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml line 60
Quoted 10 lines
Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml new file +10
-0+ 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>; + clock-names = "xosc";
Only one space after '='.
Best regards,
Krzysztof
Andrea della Porta
maintainerRe: [PATCH v3 01/12] dt-bindings: clock: Add RaspberryPi RP1 clock bindings
Hi Krzysztof,
Quoted 45 lines · Krzysztof Kozlowski
Quoted 44 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]>--- .../clock/raspberrypi,rp1-clocks.yaml | 62 +++++++++++++++++++ MAINTAINERS | 6 ++ .../clock/raspberrypi,rp1-clocks.h | 61 ++++++++++++++++++ 3 files changed, 129 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml create mode 100644 include/dt-bindings/clock/raspberrypi,rp1-clocks.hDocumentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml new file +26
-0@@ -0,0 +1,62 @@ +# 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 +
Quoted 8 lines
Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml line 30
Quoted 4 lines
Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml new file +4
-0+ '#clock-cells': + description: + The index in the assigned-clocks is mapped to the output clock as per + definitions in include/dt-bindings/clock/raspberrypi,rp1-clocks.h.You still describe how current driver matches assigned-clocks to your output clocks. That's not the property of clock-cells and that's not how assigned-clocks work.
This description is taken by another upstream binding, please see Documentation/devicetree/bindings/clock/renesas,5p35023.yaml
Its purpose is to let the user know how clock-cell number specified in assigned-clocks is mapped to the clock provided by this generator. Since some of these clocks are shared among peripherals, their frequency cannot be set by consumers, so it's the provider itself (i.e. the clock device described with this binding) that should take care of them. The renesas example has assigned-clocks specified though, please see below.
Quoted 3 lines
There are no assigned clocks in your DTS, so this is really irrelevant (or not correct, choose).
In the first revision of this patchset (please see [1] and following messages) I had the assigned-clocks setup in the example while trying to explain their purpose, but Conor said those didn't seem to be relevant, hence I dropped them. Maybe I had to be more incisive on that.
So, I'd be inclined to retain the description as it is and reintroduce some assigned-clocks in the example as in the renesas one, would it be ok for you?
Quoted 11 lines
Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml line 37
Quoted 9 lines
Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml new file +7
-0+ const: 1 + + clocks: + maxItems: 1 + + clock-names: + const: xoscWhat is the purpose of clock-names if you do not use it? Drop.
Ack.
Quoted 18 lines
Quoted 18 lines
Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml new file +17
-0+ +required: + - compatible + - reg + - '#clock-cells' + - clocks + +additionalProperties: false + +examples: + - | + #include <dt-bindings/clock/raspberrypi,rp1-clocks.h> + + rp1 { + #address-cells = <2>; + #size-cells = <2>; +
Quoted 8 lines
Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml line 60
Quoted 6 lines
Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml new file +6
-0+ clocks@c040018000 { + compatible = "raspberrypi,rp1-clocks"; + reg = <0xc0 0x40018000 0x0 0x10038>; + #clock-cells = <1>; + clocks = <&clk_rp1_xosc>; + clock-names = "xosc";Only one space after '='.
I will drop the name since the driver will not refer to it via clk_get() but will use clk_parent_data::index.
Many thanks,
Andrea
[1] - https://lore.kernel.org/all/20240822-refutable-railroad-a3f111ab1e3f@spud/
Quoted 4 lines
Best regards,
Krzysztof
Andrea della Porta
maintainerRe: [PATCH v3 01/12] dt-bindings: clock: Add RaspberryPi RP1 clock bindings
Hi Krzysztof,
Quoted 71 lines · Andrea della Porta
Hi Krzysztof,
Quoted 45 lines · Krzysztof Kozlowski
Quoted 44 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]>--- .../clock/raspberrypi,rp1-clocks.yaml | 62 +++++++++++++++++++ MAINTAINERS | 6 ++ .../clock/raspberrypi,rp1-clocks.h | 61 ++++++++++++++++++ 3 files changed, 129 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml create mode 100644 include/dt-bindings/clock/raspberrypi,rp1-clocks.hDocumentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml new file +26
-0@@ -0,0 +1,62 @@ +# 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 +Quoted 8 lines
Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml line 30
Quoted 4 lines
Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml new file +4
-0+ '#clock-cells': + description: + The index in the assigned-clocks is mapped to the output clock as per + definitions in include/dt-bindings/clock/raspberrypi,rp1-clocks.h.You still describe how current driver matches assigned-clocks to your output clocks. That's not the property of clock-cells and that's not how assigned-clocks work.
This description is taken by another upstream binding, please see
Documentation/devicetree/bindings/clock/renesas,5p35023.yamlIts purpose is to let the user know how clock-cell number specified in assigned-clocks is mapped to the clock provided by this generator. Since some of these clocks are shared among peripherals, their frequency cannot be set by consumers, so it's the provider itself (i.e. the clock device described with this binding) that should take care of them. The renesas example has assigned-clocks specified though, please see below.
Quoted 3 lines
There are no assigned clocks in your DTS, so this is really irrelevant (or not correct, choose).
Quoted 6 lines
In the first revision of this patchset (please see [1] and following messages) I had the assigned-clocks setup in the example while trying to explain their purpose, but Conor said those didn't seem to be relevant, hence I dropped them. Maybe I had to be more incisive on that.
So, I'd be inclined to retain the description as it is and reintroduce some assigned-clocks in the example as in the renesas one, would it be ok for you?
Since I'm on the verge of producing a new patchset revision, may I kindly ask some comments on this? Is it ok for you?
Many thanks,
Andrea
Quoted 54 lines
Quoted 12 lines
Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml line 37
Quoted 10 lines
Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml new file +7
-0+ const: 1 + + clocks: + maxItems: 1 + + clock-names: + const: xoscWhat is the purpose of clock-names if you do not use it? Drop.
Ack.
Quoted 18 lines
Quoted 18 lines
Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml new file +17
-0+ +required: + - compatible + - reg + - '#clock-cells' + - clocks + +additionalProperties: false + +examples: + - | + #include <dt-bindings/clock/raspberrypi,rp1-clocks.h> + + rp1 { + #address-cells = <2>; + #size-cells = <2>; +Quoted 8 lines
Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml line 60
Quoted 6 lines
Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml new file +6
-0+ clocks@c040018000 { + compatible = "raspberrypi,rp1-clocks"; + reg = <0xc0 0x40018000 0x0 0x10038>; + #clock-cells = <1>; + clocks = <&clk_rp1_xosc>; + clock-names = "xosc";Only one space after '='.
I will drop the name since the driver will not refer to it via
clk_get()but will useclk_parent_data::index.Many thanks,
Andrea[1] - https://lore.kernel.org/all/20240822-refutable-railroad-a3f111ab1e3f@spud/
Quoted 4 lines
Best regards,
Krzysztof
Stephen Boyd
maintainerRe: [PATCH v3 01/12] dt-bindings: clock: Add RaspberryPi RP1 clock bindings
Quoting Andrea della Porta (2024-11-15 03:31:45)
Quoted 32 lines · Andrea della Porta
Quoted 24 lines · Krzysztof Kozlowski
Quoted 8 lines
Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml line 30
Quoted 4 lines
Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml new file +4
-0+ '#clock-cells': + description: + The index in the assigned-clocks is mapped to the output clock as per + definitions in include/dt-bindings/clock/raspberrypi,rp1-clocks.h.You still describe how current driver matches assigned-clocks to your output clocks. That's not the property of clock-cells and that's not how assigned-clocks work.
This description is taken by another upstream binding, please see
Documentation/devicetree/bindings/clock/renesas,5p35023.yamlIts purpose is to let the user know how clock-cell number specified in assigned-clocks is mapped to the clock provided by this generator. Since some of these clocks are shared among peripherals, their frequency cannot be set by consumers, so it's the provider itself (i.e. the clock device described with this binding) that should take care of them. The renesas example has assigned-clocks specified though, please see below.
Quoted 3 lines
There are no assigned clocks in your DTS, so this is really irrelevant (or not correct, choose).
Quoted 6 lines
In the first revision of this patchset (please see [1] and following messages) I had the assigned-clocks setup in the example while trying to explain their purpose, but Conor said those didn't seem to be relevant, hence I dropped them. Maybe I had to be more incisive on that.
So, I'd be inclined to retain the description as it is and reintroduce some assigned-clocks in the example as in the renesas one, would it be ok for you?
Quoted 3 lines
Since I'm on the verge of producing a new patchset revision, may I kindly ask some comments on this? Is it ok for you?
Everyone knows how #clock-cells works. It shouldn't need a description about how it works. It should just point at the header file with the numbers if anything.
Andrea della Porta
maintainerPATCH v3 2/12 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 | 163 ++++++++++++++++++ MAINTAINERS | 2 + 2 files changed, 165 insertions(+) create mode 100644 Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml
Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml new file +163 -0
@@ -0,0 +1,163 @@ +# 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 + +additionalProperties: + anyOf: + - type: object + additionalProperties: false + 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: + A string (or list of strings) adhering to the pattern 'gpio[0-5][0-9]' + function: true + bias-disable: true + bias-pull-down: true + bias-pull-up: true + slew-rate: + description: 0 is slow slew rate, 1 is fast slew rate + enum: [ 0, 1 ] + drive-strength: + enum: [ 2, 4, 8, 12 ] + + - type: object + additionalProperties: + $ref: "#/additionalProperties/anyOf/0" + +allOf: + - $ref: pinctrl.yaml# + +required: + - reg + - compatible + - '#gpio-cells' + - gpio-controller + - interrupts + - '#interrupt-cells' + - interrupt-controller + +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-uart0-14-15 { + pin_txd { + function = "uart0"; + pins = "gpio14"; + bias-disable; + }; + + pin_rxd { + function = "uart0"; + pins = "gpio15"; + bias-pull-up; + }; + }; + }; + };
MAINTAINERS +2 -0
@@ -19384,7 +19384,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
Re: [PATCH v3 02/12] dt-bindings: pinctrl: Add RaspberryPi RP1 gpio/pinctrl/pinmux bindings
Quoted 20 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]>--- .../pinctrl/raspberrypi,rp1-gpio.yaml | 163 ++++++++++++++++++ MAINTAINERS | 2 + 2 files changed, 165 insertions(+) create mode 100644 Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yamlDocumentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml new file +4
-0@@ -0,0 +1,163 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pinctrl/raspberrypi,rp1-gpio.yaml#
Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml line 14
Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml new file +10
-0+$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
Please wrap code according to coding style (checkpatch is not a coding style description but only a tool).
Quoted 26 lines
Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml new file +26
-0+ 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.
Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml line 50
Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml new file +10
-0+ + '#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 + +additionalProperties:
Not much improved. You are supposed to have here pattern, just like other bindings. I asked for this last time.
And there are examples using it - almost all or most of pinctrl bindings, including bindings having subnodes (but you do not use such case here).
Quoted 19 lines
Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml new file +19
-0+ anyOf: + - type: object + additionalProperties: false + 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: + A string (or list of strings) adhering to the pattern 'gpio[0-5][0-9]' + function: true + bias-disable: true + bias-pull-down: true
Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml line 79
Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml new file +10
-0+ bias-pull-up: true + slew-rate: + description: 0 is slow slew rate, 1 is fast slew rate + enum: [ 0, 1 ] + drive-strength: + enum: [ 2, 4, 8, 12 ] + + - type: object + additionalProperties: + $ref: "#/additionalProperties/anyOf/0"
Your example does not use any subnodes, so this looks not needed.
Best regards,
Krzysztof
Andrea della Porta
maintainerRe: [PATCH v3 02/12] dt-bindings: pinctrl: Add RaspberryPi RP1 gpio/pinctrl/pinmux bindings
Hi Krzysztof,
Quoted 26 lines · Krzysztof Kozlowski
Quoted 25 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]>--- .../pinctrl/raspberrypi,rp1-gpio.yaml | 163 ++++++++++++++++++ MAINTAINERS | 2 + 2 files changed, 165 insertions(+) create mode 100644 Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yamlDocumentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml new file +9
-0@@ -0,0 +1,163 @@ +# 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:
Quoted 8 lines
Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml line 14
Quoted 5 lines
Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml new file +5
-0+ - 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 alsoPlease wrap code according to coding style (checkpatch is not a coding style description but only a tool).
Ack.
Quoted 41 lines
Quoted 27 lines
Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml new file +26
-0+ 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.Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml line 50
Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml new file +10
-0+ + '#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 + +additionalProperties:Not much improved. You are supposed to have here pattern, just like other bindings. I asked for this last time.
Quoted 3 lines
And there are examples using it - almost all or most of pinctrl bindings, including bindings having subnodes (but you do not use such case here).
This is the same approach used in [1], which seems quite recent. I did't use pattern because I wouldn't really want to enforce a particular naming scheme. Subnodes are used, please see below. Since pinctrl.yaml explicitly says that there is no common binding but each device has its own, I thought that was reasonable choice. Should I enforce some common pattern, then?
Quoted 24 lines
Quoted 24 lines
Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml new file +23
-0+ anyOf: + - type: object + additionalProperties: false + 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: + A string (or list of strings) adhering to the pattern 'gpio[0-5][0-9]' + function: true + bias-disable: true + bias-pull-down: true + bias-pull-up: true + slew-rate: + description: 0 is slow slew rate, 1 is fast slew rate + enum: [ 0, 1 ]
Quoted 8 lines
Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml line 79
Quoted 6 lines
Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml new file +6
-0+ drive-strength: + enum: [ 2, 4, 8, 12 ] + + - type: object + additionalProperties: + $ref: "#/additionalProperties/anyOf/0"Your example does not use any subnodes, so this looks not needed.
The example has subnodes, as in the following excerpt from the example:
rp1-uart0-14-15 {
pin_txd {
function = "uart0";
pins = "gpio14";
bias-disable;
};
pin_rxd {
function = "uart0";
pins = "gpio15";
bias-pull-up;
};
};Many thanks,
Andrea
[1] - Documentation/devicetree/bindings/pinctrl/renesas,rzg2l-pinctrl.yaml
Quoted 4 lines
Best regards,
Krzysztof
Re: [PATCH v3 02/12] dt-bindings: pinctrl: Add RaspberryPi RP1 gpio/pinctrl/pinmux bindings
Quoted 81 lines · Andrea della Porta
Hi Krzysztof,
Quoted 26 lines · Krzysztof Kozlowski
Quoted 25 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]>--- .../pinctrl/raspberrypi,rp1-gpio.yaml | 163 ++++++++++++++++++ MAINTAINERS | 2 + 2 files changed, 165 insertions(+) create mode 100644 Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yamlDocumentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml new file +9
-0@@ -0,0 +1,163 @@ +# 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:Quoted 8 lines
Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml line 14
Quoted 5 lines
Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml new file +5
-0+ - 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 alsoPlease wrap code according to coding style (checkpatch is not a coding style description but only a tool).
Ack.
Quoted 41 lines
Quoted 27 lines
Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml new file +26
-0+ 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.Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml line 50
Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml new file +10
-0+ + '#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 + +additionalProperties:Not much improved. You are supposed to have here pattern, just like other bindings. I asked for this last time.
Quoted 5 lines
Quoted 3 lines
And there are examples using it - almost all or most of pinctrl bindings, including bindings having subnodes (but you do not use such case here).
This is the same approach used in [1], which seems quite recent. I did't
2021, so not that recent, but you are right that it's not the example I would recommend. See rather:
git grep pins -- Documentation/devicetree/bindings/pinctrl/ | grep '\$'
pins, groups, states, etc.
Quoted 2 lines
use pattern because I wouldn't really want to enforce a particular naming scheme. Subnodes are used, please see below. Since
pinctrl.yamlexplicitly
But we want to enforce, because it brings uniformity and matches partially generic naming patterns.
Quoted 3 lines
says that there is no common binding but each device has its own, I thought that was reasonable choice. Should I enforce some common pattern, then?
Yes, you should. Again, look at other bindings, e.g. qcom tlmm or lpass lpi.
Quoted 34 lines
Quoted 25 lines
Quoted 25 lines
Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml new file +23
-0+ anyOf: + - type: object + additionalProperties: false + 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: + A string (or list of strings) adhering to the pattern 'gpio[0-5][0-9]' + function: true + bias-disable: true + bias-pull-down: true + bias-pull-up: true + slew-rate: + description: 0 is slow slew rate, 1 is fast slew rate + enum: [ 0, 1 ]Quoted 8 lines
Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml line 79
Quoted 6 lines
Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml new file +6
-0+ drive-strength: + enum: [ 2, 4, 8, 12 ] + + - type: object + additionalProperties: + $ref: "#/additionalProperties/anyOf/0"Your example does not use any subnodes, so this looks not needed.
Quoted 1 line
The example has subnodes, as in the following excerpt from the example:
I meant, you do not need properties in subnodes (1st level). You only want properties in subnodes of subnodes, so 2nd level. What is the point of allowing them in 1st level?
Best regards,
Krzysztof
Andrea della Porta
maintainerRe: [PATCH v3 02/12] dt-bindings: pinctrl: Add RaspberryPi RP1 gpio/pinctrl/pinmux bindings
Hi Krzysztof,
Quoted 86 lines · Krzysztof Kozlowski
Quoted 85 lines · Andrea della Porta
Hi Krzysztof,
Quoted 26 lines · Krzysztof Kozlowski
Quoted 25 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]>--- .../pinctrl/raspberrypi,rp1-gpio.yaml | 163 ++++++++++++++++++ MAINTAINERS | 2 + 2 files changed, 165 insertions(+) create mode 100644 Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yamlDocumentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml new file +9
-0@@ -0,0 +1,163 @@ +# 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:Quoted 8 lines
Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml line 14
Quoted 5 lines
Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml new file +5
-0+ - 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 alsoPlease wrap code according to coding style (checkpatch is not a coding style description but only a tool).
Ack.
Quoted 44 lines
Quoted 27 lines
Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml new file +26
-0+ 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.Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml line 50
Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml new file +10
-0+ + '#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 + +additionalProperties:Not much improved. You are supposed to have here pattern, just like other bindings. I asked for this last time.
And there are examples using it - almost all or most of pinctrl bindings, including bindings having subnodes (but you do not use such case here).
Quoted 8 lines
Quoted 1 line
This is the same approach used in [1], which seems quite recent. I did't
2021, so not that recent, but you are right that it's not the example I would recommend. See rather:
git grep pins --Documentation/devicetree/bindings/pinctrl/| grep '\$'pins, groups, states, etc.
Perfect. Thanks for the example suggestion.
Quoted 6 lines
Quoted 3 lines
use pattern because I wouldn't really want to enforce a particular naming scheme. Subnodes are used, please see below. Since
pinctrl.yamlexplicitlyBut we want to enforce, because it brings uniformity and matches partially generic naming patterns.
Ack.
Quoted 6 lines
Quoted 4 lines
says that there is no common binding but each device has its own, I thought that was reasonable choice. Should I enforce some common pattern, then?
Yes, you should. Again, look at other bindings, e.g. qcom tlmm or lpass lpi.
Ok.
Quoted 35 lines
Quoted 35 lines
Quoted 34 lines
Quoted 22 lines
Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml new file +19
-0+ anyOf: + - type: object + additionalProperties: false + 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: + A string (or list of strings) adhering to the pattern 'gpio[0-5][0-9]' + function: true + bias-disable: true + bias-pull-down: trueDocumentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml line 79
Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml new file +10
-0+ bias-pull-up: true + slew-rate: + description: 0 is slow slew rate, 1 is fast slew rate + enum: [ 0, 1 ] + drive-strength: + enum: [ 2, 4, 8, 12 ] + + - type: object + additionalProperties: + $ref: "#/additionalProperties/anyOf/0"Your example does not use any subnodes, so this looks not needed.
Quoted 5 lines
Quoted 1 line
The example has subnodes, as in the following excerpt from the example:
I meant, you do not need properties in subnodes (1st level). You only want properties in subnodes of subnodes, so 2nd level. What is the point of allowing them in 1st level?
I will add those two sub-nodes to the example:
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;
};
};The first is just a group of pins with the same settings, the second is a pin group with different settings per pin. This is basically the same usage as in qcom,sm4250-lpass-lpi-pinctrl.yaml.
Many thanks,
Andrea
Quoted 6 lines
Best regards,
Krzysztof
Re: [PATCH v3 02/12] dt-bindings: pinctrl: Add RaspberryPi RP1 gpio/pinctrl/pinmux bindings
Quoted 31 lines · Andrea della Porta
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Your example does not use any subnodes, so this looks not needed.
The example has subnodes, as in the following excerpt from the example:
I meant, you do not need properties in subnodes (1st level). You only want properties in subnodes of subnodes, so 2nd level. What is the point of allowing them in 1st level?
I will add those two sub-nodes to the example:
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; }; };
Quoted 4 lines
The first is just a group of pins with the same settings, the second is a pin group with different settings per pin. This is basically the same usage as in qcom,sm4250-lpass-lpi-pinctrl.yaml.
Ack, that's ok then.
Best regards,
Krzysztof
Andrea della Porta
maintainerPATCH v3 3/12 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 Endpoints 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
@@ -19384,6 +19384,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
Re: [PATCH v3 03/12] dt-bindings: pci: Add common schema for devices accessible through PCI BARs
Quoted 25 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]>--- .../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.yamlDocumentation/devicetree/bindings/pci/pci-ep-bus.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/pci/pci-ep-bus.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml#
Documentation/devicetree/bindings/pci/pci-ep-bus.yaml line 15
Quoted 10 lines
Documentation/devicetree/bindings/pci/pci-ep-bus.yaml new file +10
-0+ +title: Common Properties for PCI MFD Endpoints 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
Please wrap code according to coding style (checkpatch is not a coding style description but only a tool).
Above applies to all places here and other bindings.
Best regards,
Krzysztof
Andrea della Porta
maintainerRe: [PATCH v3 03/12] dt-bindings: pci: Add common schema for devices accessible through PCI BARs
Hi Krzysztof,
Quoted 40 lines · Krzysztof Kozlowski
Quoted 25 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]>--- .../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.yamlDocumentation/devicetree/bindings/pci/pci-ep-bus.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/pci/pci-ep-bus.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml#Documentation/devicetree/bindings/pci/pci-ep-bus.yaml line 15
Quoted 10 lines
Documentation/devicetree/bindings/pci/pci-ep-bus.yaml new file +10
-0+ +title: Common Properties for PCI MFD Endpoints 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, andPlease wrap code according to coding style (checkpatch is not a coding style description but only a tool).
Quoted 1 line
Above applies to all places here and other bindings.
Are you referring to the title being longer than 80 column here, right? Because the description seems correctly wrapped... or should I add a newline for each paragraph?
Many thanks,
Andrea
Quoted 4 lines
Best regards,
Krzysztof
Re: [PATCH v3 03/12] dt-bindings: pci: Add common schema for devices accessible through PCI BARs
Quoted 43 lines · Andrea della Porta
Hi Krzysztof,
Quoted 40 lines · Krzysztof Kozlowski
Quoted 25 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]>--- .../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.yamlDocumentation/devicetree/bindings/pci/pci-ep-bus.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/pci/pci-ep-bus.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml#Documentation/devicetree/bindings/pci/pci-ep-bus.yaml line 15
Quoted 10 lines
Documentation/devicetree/bindings/pci/pci-ep-bus.yaml new file +10
-0+ +title: Common Properties for PCI MFD Endpoints 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, andPlease wrap code according to coding style (checkpatch is not a coding style description but only a tool).
Quoted 5 lines
Quoted 1 line
Above applies to all places here and other bindings.
Are you referring to the title being longer than 80 column here, right? Because the description seems correctly wrapped... or should I add a newline for each paragraph?
Hmm, I might commented on wrong description. I just looked at patch #2 and there it's passed 80.
Here the title is not wrapped.
Best regards,
Krzysztof
Andrea della Porta
maintainerRe: [PATCH v3 03/12] dt-bindings: pci: Add common schema for devices accessible through PCI BARs
Hi Krzysztof,
Quoted 46 lines · Krzysztof Kozlowski
Quoted 45 lines · Andrea della Porta
Hi Krzysztof,
Quoted 41 lines · Krzysztof Kozlowski
Quoted 25 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]>--- .../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.yamlDocumentation/devicetree/bindings/pci/pci-ep-bus.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/pci/pci-ep-bus.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml#Documentation/devicetree/bindings/pci/pci-ep-bus.yaml line 15
Quoted 10 lines
Documentation/devicetree/bindings/pci/pci-ep-bus.yaml new file +10
-0+ +title: Common Properties for PCI MFD Endpoints 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, andPlease wrap code according to coding style (checkpatch is not a coding style description but only a tool).
Above applies to all places here and other bindings.
Quoted 8 lines
Quoted 3 lines
Are you referring to the title being longer than 80 column here, right? Because the description seems correctly wrapped... or should I add a newline for each paragraph?
Hmm, I might commented on wrong description. I just looked at patch #2 and there it's passed 80.
Here the title is not wrapped.
Ack.
Many thanks,
Andrea
Quoted 4 lines
Best regards,
Krzysztof
Andrea della Porta
maintainerPATCH v3 4/12 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 | 80 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 81 insertions(+) create mode 100644 Documentation/devicetree/bindings/misc/pci1de4,1.yaml
Documentation/devicetree/bindings/misc/pci1de4,1.yaml new file +80 -0
@@ -0,0 +1,80 @@ +# 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. + + 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 = <0xc0 0x40000000 + 0x01 0x00 0x00000000 + 0x00 0x00400000>; + dma-ranges = <0x10 0x00000000 + 0x43000000 0x10 0x00000000 + 0x10 0x00000000>; + #address-cells = <2>; + #size-cells = <2>; + + rp1_clocks: clocks@c040018000 { + compatible = "raspberrypi,rp1-clocks"; + reg = <0xc0 0x40018000 0x0 0x10038>; + #clock-cells = <1>; + clocks = <&clk_rp1_xosc>; + clock-names = "xosc"; + }; + }; + }; + };
MAINTAINERS +1 -0
@@ -19384,6 +19384,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
Re: [PATCH v3 04/12] dt-bindings: misc: Add device specific bindings for RaspberryPi RP1
Quoted 61 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]>--- .../devicetree/bindings/misc/pci1de4,1.yaml | 80 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 81 insertions(+) create mode 100644 Documentation/devicetree/bindings/misc/pci1de4,1.yamlDocumentation/devicetree/bindings/misc/pci1de4,1.yaml new file +44
-0@@ -0,0 +1,80 @@ +# 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. + + interrupt-controller: true + +unevaluatedProperties: false + +required: + - compatible + - '#interrupt-cells' + - interrupt-controller + - pci-ep-bus@1 + +examples:
Documentation/devicetree/bindings/misc/pci1de4,1.yaml line 54
Quoted 10 lines
Documentation/devicetree/bindings/misc/pci1de4,1.yaml new file +10
-0+ - | + pci { + #address-cells = <3>; + #size-cells = <2>; + + rp1@0,0 { + compatible = "pci1de4,1"; + ranges = <0x01 0x00 0x00000000 + 0x82010000 0x00 0x00 + 0x00 0x400000>;
Could you please have the 'ranges' in a single line as used everywhere?
- Mani
Quoted 41 lines
Documentation/devicetree/bindings/misc/pci1de4,1.yaml new file +26
-0+ #address-cells = <3>; + #size-cells = <2>; + interrupt-controller; + #interrupt-cells = <2>; + + pci_ep_bus: pci-ep-bus@1 { + compatible = "simple-bus"; + ranges = <0xc0 0x40000000 + 0x01 0x00 0x00000000 + 0x00 0x00400000>; + dma-ranges = <0x10 0x00000000 + 0x43000000 0x10 0x00000000 + 0x10 0x00000000>; + #address-cells = <2>; + #size-cells = <2>; + + rp1_clocks: clocks@c040018000 { + compatible = "raspberrypi,rp1-clocks"; + reg = <0xc0 0x40018000 0x0 0x10038>; + #clock-cells = <1>; + clocks = <&clk_rp1_xosc>; + clock-names = "xosc"; + }; + }; + }; + };MAINTAINERS +1
-0@@ -19384,6 +19384,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.hSignature · 1 line
2.35.3
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Andrea della Porta
maintainerRe: [PATCH v3 04/12] dt-bindings: misc: Add device specific bindings for RaspberryPi RP1
Hi Manivannan,
Quoted 75 lines · Manivannan Sadhasivam
Quoted 61 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]>--- .../devicetree/bindings/misc/pci1de4,1.yaml | 80 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 81 insertions(+) create mode 100644 Documentation/devicetree/bindings/misc/pci1de4,1.yamlDocumentation/devicetree/bindings/misc/pci1de4,1.yaml new file +44
-0@@ -0,0 +1,80 @@ +# 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. + + interrupt-controller: true + +unevaluatedProperties: false + +required: + - compatible + - '#interrupt-cells' + - interrupt-controller + - pci-ep-bus@1 + +examples:Documentation/devicetree/bindings/misc/pci1de4,1.yaml line 54
Quoted 10 lines
Documentation/devicetree/bindings/misc/pci1de4,1.yaml new file +10
-0+ - | + pci { + #address-cells = <3>; + #size-cells = <2>; + + rp1@0,0 { + compatible = "pci1de4,1"; + ranges = <0x01 0x00 0x00000000 + 0x82010000 0x00 0x00 + 0x00 0x400000>;Could you please have the 'ranges' in a single line as used everywhere?
Quoted 1 line
- Mani
Sure.
Many thanks,
Andrea
Quoted 45 lines
Quoted 42 lines
Documentation/devicetree/bindings/misc/pci1de4,1.yaml new file +26
-0+ #address-cells = <3>; + #size-cells = <2>; + interrupt-controller; + #interrupt-cells = <2>; + + pci_ep_bus: pci-ep-bus@1 { + compatible = "simple-bus"; + ranges = <0xc0 0x40000000 + 0x01 0x00 0x00000000 + 0x00 0x00400000>; + dma-ranges = <0x10 0x00000000 + 0x43000000 0x10 0x00000000 + 0x10 0x00000000>; + #address-cells = <2>; + #size-cells = <2>; + + rp1_clocks: clocks@c040018000 { + compatible = "raspberrypi,rp1-clocks"; + reg = <0xc0 0x40018000 0x0 0x10038>; + #clock-cells = <1>; + clocks = <&clk_rp1_xosc>; + clock-names = "xosc"; + }; + }; + }; + };MAINTAINERS +1
-0@@ -19384,6 +19384,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.hSignature · 1 line
2.35.3Signature · 1 line
மணிவண்ணன் சதாசிவம்
Andrea della Porta
maintainerPATCH v3 5/12 PCI: of_property: Assign PCI instead of CPU bus address to dynamic bridge nodes
In reply to Andrea della PortaWhen populating "ranges" property for a PCI bridge, of_pci_prop_ranges() incorrectly use the CPU bus address of the resource. Since this is a PCI-PCI bridge, the window should instead be in PCI address space. Call pci_bus_address() on the resource in order to obtain the PCI bus address.
--- drivers/pci/of_property.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/of_property.c +1 -1
@@ -126,7 +126,7 @@ static int of_pci_prop_ranges(struct pci_dev *pdev, struct of_changeset *ocs,if (of_pci_get_addr_flags (&res[j], &flags))continue ; - val64 = res[j].start; + val64 =pci_bus_address (pdev, &res[j] - pdev->resource);of_pci_set_address (pdev, rp[i].parent_addr, val64,0 , flags, false);if (pci_is_bridge (pdev)) {
Signature · 1 line
2.35.3
Re: [PATCH v3 05/12] PCI: of_property: Assign PCI instead of CPU bus address to dynamic bridge nodes
Quoted 7 lines · Andrea della Porta
When populating "ranges" property for a PCI bridge,
of_pci_prop_ranges()incorrectly use the CPU bus address of the resource. Since this is a PCI-PCI bridge, the window should instead be in PCI address space. Callpci_bus_address()on the resource in order to obtain the PCI bus address.Signed-off-by Andrea della Porta <[email protected]>
Thanks for working through this!
Quoted 20 lines
--- drivers/pci/of_property.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pci/of_property.c +1
-1@@ -126,7 +126,7 @@ static int of_pci_prop_ranges(struct pci_dev *pdev, struct of_changeset *ocs,if (of_pci_get_addr_flags (&res[j], &flags))continue ; - val64 = res[j].start; + val64 =pci_bus_address (pdev, &res[j] - pdev->resource);of_pci_set_address (pdev, rp[i].parent_addr, val64,0 , flags, false);if (pci_is_bridge (pdev)) {Signature · 1 line
2.35.3
Re: [PATCH v3 05/12] PCI: of_property: Assign PCI instead of CPU bus address to dynamic bridge nodes
In reply to Andrea della PortaQuoted 6 lines · Andrea della Porta
When populating "ranges" property for a PCI bridge,
of_pci_prop_ranges()incorrectly use the CPU bus address of the resource. Since this is a PCI-PCI bridge, the window should instead be in PCI address space. Callpci_bus_address()on the resource in order to obtain the PCI bus address.
of_pci_prop_ranges() could be called for PCI devices also (not just PCI bridges), right?
- Mani
Quoted 21 lines
Signed-off-by Andrea della Porta <[email protected]>--- drivers/pci/of_property.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pci/of_property.c +1
-1@@ -126,7 +126,7 @@ static int of_pci_prop_ranges(struct pci_dev *pdev, struct of_changeset *ocs,if (of_pci_get_addr_flags (&res[j], &flags))continue ; - val64 = res[j].start; + val64 =pci_bus_address (pdev, &res[j] - pdev->resource);of_pci_set_address (pdev, rp[i].parent_addr, val64,0 , flags, false);if (pci_is_bridge (pdev)) {Signature · 1 line
2.35.3
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Andrea della Porta
maintainerRe: [PATCH v3 05/12] PCI: of_property: Assign PCI instead of CPU bus address to dynamic bridge nodes
Hi Manivannan,
Quoted 10 lines · Manivannan Sadhasivam
Quoted 6 lines · Andrea della Porta
When populating "ranges" property for a PCI bridge,
of_pci_prop_ranges()incorrectly use the CPU bus address of the resource. Since this is a PCI-PCI bridge, the window should instead be in PCI address space. Callpci_bus_address()on the resource in order to obtain the PCI bus address.
of_pci_prop_ranges()could be called for PCI devices also (not just PCI bridges), right?
Correct. Please note however that while the PCI-PCI bridge has the parent address in CPU space, an endpoint device has it in PCI space: here we're focusing on the bridge part. It probably used to work before since in many cases the CPU and PCI address are the same, but it breaks down when they differ.
Many thanks,
Andrea
Quoted 27 lines
- Mani
Quoted 21 lines
Signed-off-by Andrea della Porta <[email protected]>--- drivers/pci/of_property.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pci/of_property.c +1
-1@@ -126,7 +126,7 @@ static int of_pci_prop_ranges(struct pci_dev *pdev, struct of_changeset *ocs,if (of_pci_get_addr_flags (&res[j], &flags))continue ; - val64 = res[j].start; + val64 =pci_bus_address (pdev, &res[j] - pdev->resource);of_pci_set_address (pdev, rp[i].parent_addr, val64,0 , flags, false);if (pci_is_bridge (pdev)) {Signature · 1 line
2.35.3Signature · 1 line
மணிவண்ணன் சதாசிவம்
Re: [PATCH v3 05/12] PCI: of_property: Assign PCI instead of CPU bus address to dynamic bridge nodes
Quoted 11 lines · Andrea della Porta
Hi Manivannan,
Quoted 8 lines · Manivannan Sadhasivam
Quoted 6 lines · Andrea della Porta
When populating "ranges" property for a PCI bridge,
of_pci_prop_ranges()incorrectly use the CPU bus address of the resource. Since this is a PCI-PCI bridge, the window should instead be in PCI address space. Callpci_bus_address()on the resource in order to obtain the PCI bus address.
Quoted 9 lines
Quoted 2 lines
of_pci_prop_ranges()could be called for PCI devices also (not just PCI bridges), right?Correct. Please note however that while the PCI-PCI bridge has the parent address in CPU space, an endpoint device has it in PCI space: here we're focusing on the bridge part. It probably used to work before since in many cases the CPU and PCI address are the same, but it breaks down when they differ.
When you say 'focusing', you are specifically referring to the bridge part of this API I believe. But I don't see a check for the bridge in your change, which is what concerning me. Am I missing something?
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Re: [PATCH v3 05/12] PCI: of_property: Assign PCI instead of CPU bus address to dynamic bridge nodes
Quoted 18 lines · Manivannan Sadhasivam
Quoted 8 lines · Andrea della Porta
Quoted 7 lines · Manivannan Sadhasivam
Quoted 5 lines · Andrea della Porta
When populating "ranges" property for a PCI bridge,
of_pci_prop_ranges()incorrectly use the CPU bus address of the resource. Since this is a PCI-PCI bridge, the window should instead be in PCI address space. Callpci_bus_address()on the resource in order to obtain the PCI bus address.Quoted 8 lines
Quoted 2 lines
of_pci_prop_ranges()could be called for PCI devices also (not just PCI bridges), right?Correct. Please note however that while the PCI-PCI bridge has the parent address in CPU space, an endpoint device has it in PCI space: here we're focusing on the bridge part. It probably used to work before since in many cases the CPU and PCI address are the same, but it breaks down when they differ.
Quoted 4 lines
When you say 'focusing', you are specifically referring to the bridge part of this API I believe. But I don't see a check for the bridge in your change, which is what concerning me. Am I missing something?
I think we want this change for all devices in the PCI address domain, including PCI-PCI bridges and endpoints, don't we? All those "ranges" addresses should be in the PCI domain.
Bjorn
Re: [PATCH v3 05/12] PCI: of_property: Assign PCI instead of CPU bus address to dynamic bridge nodes
Quoted 19 lines · Bjorn Helgaas
Quoted 18 lines · Manivannan Sadhasivam
Quoted 16 lines · Andrea della Porta
Quoted 9 lines · Manivannan Sadhasivam
Quoted 5 lines · Andrea della Porta
When populating "ranges" property for a PCI bridge,
of_pci_prop_ranges()incorrectly use the CPU bus address of the resource. Since this is a PCI-PCI bridge, the window should instead be in PCI address space. Callpci_bus_address()on the resource in order to obtain the PCI bus address.
of_pci_prop_ranges()could be called for PCI devices also (not just PCI bridges), right?Correct. Please note however that while the PCI-PCI bridge has the parent address in CPU space, an endpoint device has it in PCI space: here we're focusing on the bridge part. It probably used to work before since in many cases the CPU and PCI address are the same, but it breaks down when they differ.
Quoted 9 lines
Quoted 4 lines
When you say 'focusing', you are specifically referring to the bridge part of this API I believe. But I don't see a check for the bridge in your change, which is what concerning me. Am I missing something?
I think we want this change for all devices in the PCI address domain, including PCI-PCI bridges and endpoints, don't we? All those "ranges" addresses should be in the PCI domain.
Yeah, right. I was slightly confused by the commit message. Maybe including a sentence about how the change will work fine for endpoint devices would help. Also, why it went unnoticed till now (ie., both CPU and PCI addresses are same in many SoCs).
Also there should be a fixes tag (also CC stable) since this is a potential bug fix.
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Andrea della Porta
maintainerRe: [PATCH v3 05/12] PCI: of_property: Assign PCI instead of CPU bus address to dynamic bridge nodes
Hi Manivannan,
Quoted 30 lines · Manivannan Sadhasivam
Quoted 19 lines · Bjorn Helgaas
Quoted 18 lines · Manivannan Sadhasivam
Quoted 16 lines · Andrea della Porta
Quoted 9 lines · Manivannan Sadhasivam
Quoted 5 lines · Andrea della Porta
When populating "ranges" property for a PCI bridge,
of_pci_prop_ranges()incorrectly use the CPU bus address of the resource. Since this is a PCI-PCI bridge, the window should instead be in PCI address space. Callpci_bus_address()on the resource in order to obtain the PCI bus address.
of_pci_prop_ranges()could be called for PCI devices also (not just PCI bridges), right?Correct. Please note however that while the PCI-PCI bridge has the parent address in CPU space, an endpoint device has it in PCI space: here we're focusing on the bridge part. It probably used to work before since in many cases the CPU and PCI address are the same, but it breaks down when they differ.
Quoted 9 lines
Quoted 4 lines
When you say 'focusing', you are specifically referring to the bridge part of this API I believe. But I don't see a check for the bridge in your change, which is what concerning me. Am I missing something?
I think we want this change for all devices in the PCI address domain, including PCI-PCI bridges and endpoints, don't we? All those "ranges" addresses should be in the PCI domain.
Quoted 4 lines
Yeah, right. I was slightly confused by the commit message. Maybe including a sentence about how the change will work fine for endpoint devices would help. Also, why it went unnoticed till now (ie., both CPU and PCI addresses are same in many SoCs).
Sorry for the (admittedly) confusing explanation from my side. What I would have really liked to convey is that although the root complex (that is itself a bridge) is the ultimate 'translator' between CPU and PCI addresses, all the other entities are of course under PCI address space. In fact, any resource submitted to of_pci_set_address() is intended to be a PCI bus address, and this is valid for both sub-bridges and EPs.
Quoted 3 lines
Also there should be a fixes tag (also CC stable) since this is a potential bug fix.
Sure. I think it could be better to resend this specific patch (and maybe also the patch "of: address: Preserve the flags portion on 1:1 dma-ranges mapping", which is also a kind of bugfix) as standalone ones instead of prerequisites for the RP1 patchset, if it's not a concern to anyone...
Regards,
Andrea
Quoted 5 lines
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Re: [PATCH v3 05/12] PCI: of_property: Assign PCI instead of CPU bus address to dynamic bridge nodes
Quoted 38 lines · Andrea della Porta
Hi Manivannan,
Quoted 30 lines · Manivannan Sadhasivam
Quoted 19 lines · Bjorn Helgaas
Quoted 18 lines · Manivannan Sadhasivam
Quoted 16 lines · Andrea della Porta
Quoted 9 lines · Manivannan Sadhasivam
Quoted 5 lines · Andrea della Porta
When populating "ranges" property for a PCI bridge,
of_pci_prop_ranges()incorrectly use the CPU bus address of the resource. Since this is a PCI-PCI bridge, the window should instead be in PCI address space. Callpci_bus_address()on the resource in order to obtain the PCI bus address.
of_pci_prop_ranges()could be called for PCI devices also (not just PCI bridges), right?Correct. Please note however that while the PCI-PCI bridge has the parent address in CPU space, an endpoint device has it in PCI space: here we're focusing on the bridge part. It probably used to work before since in many cases the CPU and PCI address are the same, but it breaks down when they differ.
Quoted 9 lines
Quoted 4 lines
When you say 'focusing', you are specifically referring to the bridge part of this API I believe. But I don't see a check for the bridge in your change, which is what concerning me. Am I missing something?
I think we want this change for all devices in the PCI address domain, including PCI-PCI bridges and endpoints, don't we? All those "ranges" addresses should be in the PCI domain.
Quoted 4 lines
Yeah, right. I was slightly confused by the commit message. Maybe including a sentence about how the change will work fine for endpoint devices would help. Also, why it went unnoticed till now (ie., both CPU and PCI addresses are same in many SoCs).
Quoted 7 lines
Sorry for the (admittedly) confusing explanation from my side. What I would have really liked to convey is that although the root complex (that is itself a bridge) is the ultimate 'translator' between CPU and PCI addresses, all the other entities are of course under PCI address space. In fact, any resource submitted to
of_pci_set_address()is intended to be a PCI bus address, and this is valid for both sub-bridges and EPs.
Sounds good. We usually have empty ranges for PCI bridges (1:1 mapping), so that also lead to the confusion at my end.
Quoted 9 lines
Quoted 3 lines
Also there should be a fixes tag (also CC stable) since this is a potential bug fix.
Sure. I think it could be better to resend this specific patch (and maybe also the patch "of: address: Preserve the flags portion on 1:1 dma-ranges mapping", which is also a kind of bugfix) as standalone ones instead of prerequisites for the RP1 patchset, if it's not a concern to anyone...
In fact, it is recommended to send fixes separately (or at the start of the series). So there should be no concerns.
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Re: [PATCH v3 05/12] PCI: of_property: Assign PCI instead of CPU bus address to dynamic bridge nodes
In reply to Manivannan SadhasivamHi Mani,
Quoted 30 lines · Manivannan Sadhasivam
Quoted 19 lines · Bjorn Helgaas
Quoted 18 lines · Manivannan Sadhasivam
Quoted 16 lines · Andrea della Porta
Quoted 9 lines · Manivannan Sadhasivam
Quoted 5 lines · Andrea della Porta
When populating "ranges" property for a PCI bridge,
of_pci_prop_ranges()incorrectly use the CPU bus address of the resource. Since this is a PCI-PCI bridge, the window should instead be in PCI address space. Callpci_bus_address()on the resource in order to obtain the PCI bus address.
of_pci_prop_ranges()could be called for PCI devices also (not just PCI bridges), right?Correct. Please note however that while the PCI-PCI bridge has the parent address in CPU space, an endpoint device has it in PCI space: here we're focusing on the bridge part. It probably used to work before since in many cases the CPU and PCI address are the same, but it breaks down when they differ.
Quoted 9 lines
Quoted 4 lines
When you say 'focusing', you are specifically referring to the bridge part of this API I believe. But I don't see a check for the bridge in your change, which is what concerning me. Am I missing something?
I think we want this change for all devices in the PCI address domain, including PCI-PCI bridges and endpoints, don't we? All those "ranges" addresses should be in the PCI domain.
Quoted 4 lines
Yeah, right. I was slightly confused by the commit message. Maybe including a sentence about how the change will work fine for endpoint devices would help. Also, why it went unnoticed till now (ie., both CPU and PCI addresses are same in many SoCs).
Most probably it is unnoticed because until now nobody has enabled /selected CONFIG_PCI_DYNAMIC_OF_NODES ?
~Stan
Re: [PATCH v3 05/12] PCI: of_property: Assign PCI instead of CPU bus address to dynamic bridge nodes
In reply to Andrea della PortaHi Andrea,
Quoted 7 lines · On Mon, 28 Oct 2024 15:07:22 +0100 Andrea della Porta <[email protected]>…
When populating "ranges" property for a PCI bridge,
of_pci_prop_ranges()incorrectly use the CPU bus address of the resource. Since this is a PCI-PCI bridge, the window should instead be in PCI address space. Callpci_bus_address()on the resource in order to obtain the PCI bus address.Signed-off-by Andrea della Porta <[email protected]>
Tested ok with my LAN966x PCI device.
Best regards,
Hervé
Andrea della Porta
maintainerRe: [PATCH v3 05/12] PCI: of_property: Assign PCI instead of CPU bus address to dynamic bridge nodes
Hi Herve,
Quoted 11 lines · Herve Codina
Hi Andrea,
Quoted 6 lines · On Mon, 28 Oct 2024 15:07:22 +0100 Andrea della Porta <[email protected]>…
When populating "ranges" property for a PCI bridge,
of_pci_prop_ranges()incorrectly use the CPU bus address of the resource. Since this is a PCI-PCI bridge, the window should instead be in PCI address space. Callpci_bus_address()on the resource in order to obtain the PCI bus address.
Quoted 5 lines
Quoted 1 line
Signed-off-by Andrea della Porta <[email protected]>Tested ok with my LAN966x PCI device.
Tested-by Herve Codina <[email protected]>
Thanks for testing that!
Regards,
Andrea
Quoted 3 lines
Best regards,
Hervé
Andrea della Porta
maintainerPATCH v3 6/12 of: address: Preserve the flags portion on 1:1 dma-ranges mapping
In reply to Andrea della PortaA missing or empty dma-ranges in a DT node implies a 1:1 mapping for dma translations. In this specific case, the current behaviour is to zero out the entire specifier so that the translation could be carried on as an offset from zero. This includes address specifier that has flags (e.g. PCI ranges).
Once the flags portion has been zeroed, the translation chain is broken since the mapping functions will check the upcoming address specifier against mismatching flags, always failing the 1:1 mapping and its entire purpose of always succeeding.
Set to zero only the address portion while passing the flags through.
--- drivers/of/address.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/of/address.c +2 -1
@@ -455,7 +455,8 @@ static int of_translate_one(struct device_node *parent, struct of_bus *bus, }if (ranges ==NULL || rlen ==0 ) { offset =of_read_number (addr, na); -memset (addr,0 , pna *4 ); +/* copy the address while preserving the flags */ +memset (addr + pbus->flag_cells,0 , (pna - pbus->flag_cells) *4 );pr_debug ("empty ranges; 1:1 translation\n" ); goto finish; }
Signature · 1 line
2.35.3
Re: [PATCH v3 06/12] of: address: Preserve the flags portion on 1:1 dma-ranges mapping
Hi Andrea,
Quoted 11 lines · On Mon, 28 Oct 2024 15:07:23 +0100 Andrea della Porta <[email protected]>…
A missing or empty dma-ranges in a DT node implies a 1:1 mapping for dma translations. In this specific case, the current behaviour is to zero out the entire specifier so that the translation could be carried on as an offset from zero. This includes address specifier that has flags (e.g. PCI ranges).
Once the flags portion has been zeroed, the translation chain is broken since the mapping functions will check the upcoming address specifier against mismatching flags, always failing the 1:1 mapping and its entire purpose of always succeeding.
Set to zero only the address portion while passing the flags through.
Quoted 1 line
Signed-off-by Andrea della Porta <[email protected]>
Tested ok with my LAN966x PCI device.
Best regards,
Hervé
Andrea della Porta
maintainerPATCH v3 7/12 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 | 8 + drivers/clk/Makefile | 1 + drivers/clk/clk-rp1.c | 1540 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 1550 insertions(+) create mode 100644 drivers/clk/clk-rp1.c
MAINTAINERS +1 -0
@@ -19387,6 +19387,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 +8 -0
@@ -88,6 +88,14 @@ 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 + 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
@@ -68,6 +68,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 +1540 -0
1,540 lines not on this page · raw message
Signature · 1 line
2.35.3
Stephen Boyd
maintainerRe: [PATCH v3 07/12] clk: rp1: Add support for clocks provided by RP1
Quoting Andrea della Porta (2024-10-28 07:07:24)
Quoted 4 lines
drivers/clk/clk-rp1.c new file +0
-1--- /dev/null
[...]
drivers/clk/clk-rp1.c line 328
Quoted 4 lines
drivers/clk/clk-rp1.c new file +4
-0+ +struct rp1_clockman { +struct device *dev; +void __iomem *regs;
Do you still need this if there's a regmap?
drivers/clk/clk-rp1.c line 330
Quoted 2 lines
drivers/clk/clk-rp1.c new file +2
-0+struct regmap *regmap; +spinlock_t regs_lock;/* spinlock for all clocks */
Do you need this or is the spinlock in the regmap sufficient?
drivers/clk/clk-rp1.c line 337
Quoted 7 lines
drivers/clk/clk-rp1.c new file +7
-0+ +/* Must be last */ +struct clk_hw_onecell_data onecell; +}; + +struct rp1_pll_core_data { +const char *name;
These 'name' members can move to clk_init_data?
drivers/clk/clk-rp1.c line 342
Quoted 5 lines
drivers/clk/clk-rp1.c new file +5
-0+u32 cs_reg; +u32 pwr_reg; +u32 fbdiv_int_reg; +u32 fbdiv_frac_reg; +unsigned long flags;
And probably flags as well? It seems like clk_init_data should be declared at the same time as struct rp1_pll_core_data is.
Quoted 47 lines
drivers/clk/clk-rp1.c new file +47
-0+u32 fc0_src; +}; + +struct rp1_pll_data { +const char *name; +u32 ctrl_reg; +unsigned long flags; +u32 fc0_src; +}; + +struct rp1_pll_ph_data { +const char *name; +unsigned int phase; +unsigned int fixed_divider; +u32 ph_reg; +unsigned long flags; +u32 fc0_src; +}; + +struct rp1_pll_divider_data { +const char *name; +u32 sec_reg; +unsigned long flags; +u32 fc0_src; +}; + +struct rp1_clock_data { +const char *name; +int num_std_parents; +int num_aux_parents; +unsigned long flags; +u32 oe_mask; +u32 clk_src_mask; +u32 ctrl_reg; +u32 div_int_reg; +u32 div_frac_reg; +u32 sel_reg; +u32 div_int_max; +unsigned long max_freq; +u32 fc0_src; +}; + +struct rp1_clk_desc { +struct clk_hw *(*clk_register)(struct rp1_clockman *clockman, +struct rp1_clk_desc *desc); +const void *data; +struct clk_hw hw;
drivers/clk/clk-rp1.c line 399
Quoted 10 lines
drivers/clk/clk-rp1.c new file +10
-0+struct rp1_clockman *clockman; +unsigned long cached_rate; +struct clk_divider div; +}; + +#define FIELD_SET (_reg, _mask, _val) \ +do { \ + u32 mask = (_mask); \ + (_reg) &= ~mask; \ + (_reg) |= FIELD_PREP(mask, (_val)); \
Please just write
reg &= ~mask reg |= FIELD_PREP(mask, val);
instead of using this macro.
Quoted 3 lines
drivers/clk/clk-rp1.c new file +3
-0+}while (0 ) + +
[...]
Quoted 78 lines
drivers/clk/clk-rp1.c new file +78
-0+ +static struct clk_hw *rp1_register_pll_core (struct rp1_clockman *clockman, +struct rp1_clk_desc *desc) +{ +const struct rp1_pll_core_data *pll_core_data = desc->data; +struct clk_init_data init = { }; +int ret; + +/* All of the PLL cores derive from the external oscillator. */ + init.parent_data = desc->hw.init->parent_data; + init.num_parents = desc->hw.init->num_parents; + init.name = pll_core_data->name; + init.ops = &rp1_pll_core_ops; + init.flags = pll_core_data->flags |CLK_IGNORE_UNUSED |CLK_IS_CRITICAL ; + + desc->clockman = clockman; + desc->hw.init = &init; + + ret =devm_clk_hw_register (clockman->dev, &desc->hw); + +if (ret) +return ERR_PTR (ret); + +return &desc->hw; +} + +static struct clk_hw *rp1_register_pll (struct rp1_clockman *clockman, +struct rp1_clk_desc *desc) +{ +const struct rp1_pll_data *pll_data = desc->data; +struct clk_init_data init = { }; +int ret; + + init.parent_data = desc->hw.init->parent_data; + init.num_parents = desc->hw.init->num_parents; + init.name = pll_data->name; + init.ops = &rp1_pll_ops; + init.flags = pll_data->flags |CLK_IGNORE_UNUSED |CLK_IS_CRITICAL ; + + desc->clockman = clockman; + desc->hw.init = &init; + + ret =devm_clk_hw_register (clockman->dev, &desc->hw); + +if (ret) +return ERR_PTR (ret); + +return &desc->hw; +} + +static struct clk_hw *rp1_register_pll_ph (struct rp1_clockman *clockman, +struct rp1_clk_desc *desc) +{ +const struct rp1_pll_ph_data *ph_data = desc->data; +struct clk_init_data init = { }; +int ret; + + init.parent_data = desc->hw.init->parent_data; + init.num_parents = desc->hw.init->num_parents; + init.name = ph_data->name; + init.ops = &rp1_pll_ph_ops; + init.flags = ph_data->flags |CLK_IGNORE_UNUSED ; + + desc->clockman = clockman; + desc->hw.init = &init; + + ret =devm_clk_hw_register (clockman->dev, &desc->hw); + +if (ret) +return ERR_PTR (ret); + +return &desc->hw; +} + +static struct clk_hw *rp1_register_pll_divider (struct rp1_clockman *clockman, +struct rp1_clk_desc *desc) +{ +const struct rp1_pll_data *divider_data = desc->data;
drivers/clk/clk-rp1.c line 1232
Quoted 10 lines
drivers/clk/clk-rp1.c new file +10
-0+struct clk_init_data init = { }; +int ret; + + init.parent_data = desc->hw.init->parent_data; + init.num_parents = desc->hw.init->num_parents; + init.name = divider_data->name; + init.ops = &rp1_pll_divider_ops; + init.flags = divider_data->flags |CLK_IGNORE_UNUSED |CLK_IS_CRITICAL ; + + desc->div.reg = clockman->regs + divider_data->ctrl_reg;
Why is 'regs' used here? Isn't everything using a regmap now so it's all offsets?
Quoted 45 lines
drivers/clk/clk-rp1.c new file +45
-0+ desc->div.shift =PLL_SEC_DIV_SHIFT ; + desc->div.width =PLL_SEC_DIV_WIDTH ; + desc->div.flags =CLK_DIVIDER_ROUND_CLOSEST ; + desc->div.flags |=CLK_IS_CRITICAL ; + desc->div.lock = &clockman->regs_lock; + desc->div.hw.init = &init; + desc->div.table = pll_sec_div_table; + + desc->clockman = clockman; + + ret =devm_clk_hw_register (clockman->dev, &desc->div.hw); + +if (ret) +return ERR_PTR (ret); + +return &desc->div.hw; +} + +static struct clk_hw *rp1_register_clock (struct rp1_clockman *clockman, +struct rp1_clk_desc *desc) +{ +const struct rp1_clock_data *clock_data = desc->data; +struct clk_init_data init = { }; +int ret; + +if (WARN_ON_ONCE (MAX_CLK_PARENTS < + clock_data->num_std_parents + clock_data->num_aux_parents)) +return NULL ; + +/* There must be a gap for the AUX selector */ +if (WARN_ON_ONCE (clock_data->num_std_parents >AUX_SEL && + desc->hw.init->parent_data[AUX_SEL ].index !=-1 )) +return NULL ; + + init.parent_data = desc->hw.init->parent_data; + init.num_parents = desc->hw.init->num_parents; + init.name = clock_data->name; + init.flags = clock_data->flags |CLK_IGNORE_UNUSED ; + init.ops = &rp1_clk_ops; + + desc->clockman = clockman; + desc->hw.init = &init; + + ret =devm_clk_hw_register (clockman->dev, &desc->hw); +
drivers/clk/clk-rp1.c line 1287
Quoted 10 lines
drivers/clk/clk-rp1.c new file +10
-0+if (ret) +return ERR_PTR (ret); + +return &desc->hw; +} + +/* Assignment helper macros for different clock types. */ +#define _REGISTER (f, ...) { .clk_register = f, __VA_ARGS__ } + +#define PARENT_CLK (pnum, ...) .hw.init = &(const struct clk_init_data) { \
Instead of this macro just use CLK_HW_INIT_HW() or CLK_HW_INIT_PARENTS_DATA()?
Quoted 200 lines
drivers/clk/clk-rp1.c new file +200
-0+ .parent_data = (const struct \ + clk_parent_data[]) { \ + __VA_ARGS__ \ + }, \ + .num_parents = pnum } + +#define CLK_DATA (type, ...) .data = &(struct type) { __VA_ARGS__ } + +#define REGISTER_PLL_CORE (...) _REGISTER(&rp1_register_pll_core, \ + __VA_ARGS__) + +#define REGISTER_PLL (...) _REGISTER(&rp1_register_pll, \ + __VA_ARGS__) + +#define REGISTER_PLL_PH (...) _REGISTER(&rp1_register_pll_ph, \ + __VA_ARGS__) + +#define REGISTER_PLL_DIV (...) _REGISTER(&rp1_register_pll_divider, \ + __VA_ARGS__) + +#define REGISTER_CLK (...) _REGISTER(&rp1_register_clock, \ + __VA_ARGS__) + +static struct rp1_clk_desc clk_desc_array[] = { + [RP1_PLL_SYS_CORE] = REGISTER_PLL_CORE(PARENT_CLK(1, { .index = 0 }), + CLK_DATA(rp1_pll_core_data, + .name = "pll_sys_core", + .cs_reg = PLL_SYS_CS, + .pwr_reg = PLL_SYS_PWR, + .fbdiv_int_reg = PLL_SYS_FBDIV_INT, + .fbdiv_frac_reg = PLL_SYS_FBDIV_FRAC, + )), + + [RP1_PLL_AUDIO_CORE] = REGISTER_PLL_CORE(PARENT_CLK(1, { .index = 0 }), + CLK_DATA(rp1_pll_core_data, + .name = "pll_audio_core", + .cs_reg = PLL_AUDIO_CS, + .pwr_reg = PLL_AUDIO_PWR, + .fbdiv_int_reg = PLL_AUDIO_FBDIV_INT, + .fbdiv_frac_reg = PLL_AUDIO_FBDIV_FRAC, + )), + + [RP1_PLL_VIDEO_CORE] = REGISTER_PLL_CORE(PARENT_CLK(1, { .index = 0 }), + CLK_DATA(rp1_pll_core_data, + .name = "pll_video_core", + .cs_reg = PLL_VIDEO_CS, + .pwr_reg = PLL_VIDEO_PWR, + .fbdiv_int_reg = PLL_VIDEO_FBDIV_INT, + .fbdiv_frac_reg = PLL_VIDEO_FBDIV_FRAC, + )), + + [RP1_PLL_SYS ] =REGISTER_PLL (PARENT_CLK (1 , + { .hw = &clk_desc_array[RP1_PLL_SYS_CORE].hw } + ), + CLK_DATA(rp1_pll_data, + .name = "pll_sys", + .ctrl_reg = PLL_SYS_PRIM, + .fc0_src = FC_NUM(0, 2), + )), + + [RP1_CLK_ETH_TSU] = REGISTER_CLK(PARENT_CLK(1, { .index = 0 }), + CLK_DATA(rp1_clock_data, + .name = "clk_eth_tsu", + .num_std_parents = 0, + .num_aux_parents = 1, + .ctrl_reg = CLK_ETH_TSU_CTRL, + .div_int_reg = CLK_ETH_TSU_DIV_INT, + .sel_reg = CLK_ETH_TSU_SEL, + .div_int_max = DIV_INT_8BIT_MAX, + .max_freq = 50 * HZ_PER_MHZ, + .fc0_src = FC_NUM(5, 7), + )), + + [RP1_CLK_SYS ] =REGISTER_CLK (PARENT_CLK (3 , + { .index = 0 }, + { .index = -1 }, + { .hw = &clk_desc_array[RP1_PLL_SYS].hw } + ), + CLK_DATA(rp1_clock_data, + .name = "clk_sys", + .num_std_parents = 3, + .num_aux_parents = 0, + .ctrl_reg = CLK_SYS_CTRL, + .div_int_reg = CLK_SYS_DIV_INT, + .sel_reg = CLK_SYS_SEL, + .div_int_max = DIV_INT_24BIT_MAX, + .max_freq = 200 * HZ_PER_MHZ, + .fc0_src = FC_NUM(0, 4), + .clk_src_mask = 0x3, + )), + + [RP1_PLL_SYS_PRI_PH ] =REGISTER_PLL_PH (PARENT_CLK (1 , + { .hw = &clk_desc_array[RP1_PLL_SYS].hw } + ), + CLK_DATA(rp1_pll_ph_data, + .name = "pll_sys_pri_ph", + .ph_reg = PLL_SYS_PRIM, + .fixed_divider = 2, + .phase = RP1_PLL_PHASE_0, + .fc0_src = FC_NUM(1, 2), + )), + + [RP1_PLL_SYS_SEC ] =REGISTER_PLL_DIV (PARENT_CLK (1 , + { .hw = &clk_desc_array[RP1_PLL_SYS_CORE].hw } + ), + CLK_DATA(rp1_pll_data, + .name = "pll_sys_sec", + .ctrl_reg = PLL_SYS_SEC, + .fc0_src = FC_NUM(2, 2), + )), +}; + +static const struct regmap_range rp1_reg_ranges[] = { +regmap_reg_range (PLL_SYS_CS ,PLL_SYS_SEC ), +regmap_reg_range (PLL_AUDIO_CS ,PLL_AUDIO_TERN ), +regmap_reg_range (PLL_VIDEO_CS ,PLL_VIDEO_SEC ), +regmap_reg_range (GPCLK_OE_CTRL ,GPCLK_OE_CTRL ), +regmap_reg_range (CLK_SYS_CTRL ,CLK_SYS_DIV_INT ), +regmap_reg_range (CLK_SYS_SEL ,CLK_SYS_SEL ), +regmap_reg_range (CLK_SLOW_SYS_CTRL ,CLK_SLOW_SYS_DIV_INT ), +regmap_reg_range (CLK_SLOW_SYS_SEL ,CLK_SLOW_SYS_SEL ), +regmap_reg_range (CLK_DMA_CTRL ,CLK_DMA_DIV_INT ), +regmap_reg_range (CLK_DMA_SEL ,CLK_DMA_SEL ), +regmap_reg_range (CLK_UART_CTRL ,CLK_UART_DIV_INT ), +regmap_reg_range (CLK_UART_SEL ,CLK_UART_SEL ), +regmap_reg_range (CLK_ETH_CTRL ,CLK_ETH_DIV_INT ), +regmap_reg_range (CLK_ETH_SEL ,CLK_ETH_SEL ), +regmap_reg_range (CLK_PWM0_CTRL ,CLK_PWM0_SEL ), +regmap_reg_range (CLK_PWM1_CTRL ,CLK_PWM1_SEL ), +regmap_reg_range (CLK_AUDIO_IN_CTRL ,CLK_AUDIO_IN_DIV_INT ), +regmap_reg_range (CLK_AUDIO_IN_SEL ,CLK_AUDIO_IN_SEL ), +regmap_reg_range (CLK_AUDIO_OUT_CTRL ,CLK_AUDIO_OUT_DIV_INT ), +regmap_reg_range (CLK_AUDIO_OUT_SEL ,CLK_AUDIO_OUT_SEL ), +regmap_reg_range (CLK_I2S_CTRL ,CLK_I2S_DIV_INT ), +regmap_reg_range (CLK_I2S_SEL ,CLK_I2S_SEL ), +regmap_reg_range (CLK_MIPI0_CFG_CTRL ,CLK_MIPI0_CFG_DIV_INT ), +regmap_reg_range (CLK_MIPI0_CFG_SEL ,CLK_MIPI0_CFG_SEL ), +regmap_reg_range (CLK_MIPI1_CFG_CTRL ,CLK_MIPI1_CFG_DIV_INT ), +regmap_reg_range (CLK_MIPI1_CFG_SEL ,CLK_MIPI1_CFG_SEL ), +regmap_reg_range (CLK_PCIE_AUX_CTRL ,CLK_PCIE_AUX_DIV_INT ), +regmap_reg_range (CLK_PCIE_AUX_SEL ,CLK_PCIE_AUX_SEL ), +regmap_reg_range (CLK_USBH0_MICROFRAME_CTRL ,CLK_USBH0_MICROFRAME_DIV_INT ), +regmap_reg_range (CLK_USBH0_MICROFRAME_SEL ,CLK_USBH0_MICROFRAME_SEL ), +regmap_reg_range (CLK_USBH1_MICROFRAME_CTRL ,CLK_USBH1_MICROFRAME_DIV_INT ), +regmap_reg_range (CLK_USBH1_MICROFRAME_SEL ,CLK_USBH1_MICROFRAME_SEL ), +regmap_reg_range (CLK_USBH0_SUSPEND_CTRL ,CLK_USBH0_SUSPEND_DIV_INT ), +regmap_reg_range (CLK_USBH0_SUSPEND_SEL ,CLK_USBH0_SUSPEND_SEL ), +regmap_reg_range (CLK_USBH1_SUSPEND_CTRL ,CLK_USBH1_SUSPEND_DIV_INT ), +regmap_reg_range (CLK_USBH1_SUSPEND_SEL ,CLK_USBH1_SUSPEND_SEL ), +regmap_reg_range (CLK_ETH_TSU_CTRL ,CLK_ETH_TSU_DIV_INT ), +regmap_reg_range (CLK_ETH_TSU_SEL ,CLK_ETH_TSU_SEL ), +regmap_reg_range (CLK_ADC_CTRL ,CLK_ADC_DIV_INT ), +regmap_reg_range (CLK_ADC_SEL ,CLK_ADC_SEL ), +regmap_reg_range (CLK_SDIO_TIMER_CTRL ,CLK_SDIO_TIMER_DIV_INT ), +regmap_reg_range (CLK_SDIO_TIMER_SEL ,CLK_SDIO_TIMER_SEL ), +regmap_reg_range (CLK_SDIO_ALT_SRC_CTRL ,CLK_SDIO_ALT_SRC_DIV_INT ), +regmap_reg_range (CLK_SDIO_ALT_SRC_SEL ,CLK_SDIO_ALT_SRC_SEL ), +regmap_reg_range (CLK_GP0_CTRL ,CLK_GP0_SEL ), +regmap_reg_range (CLK_GP1_CTRL ,CLK_GP1_SEL ), +regmap_reg_range (CLK_GP2_CTRL ,CLK_GP2_SEL ), +regmap_reg_range (CLK_GP3_CTRL ,CLK_GP3_SEL ), +regmap_reg_range (CLK_GP4_CTRL ,CLK_GP4_SEL ), +regmap_reg_range (CLK_GP5_CTRL ,CLK_GP5_SEL ), +regmap_reg_range (CLK_SYS_RESUS_CTRL ,CLK_SYS_RESUS_CTRL ), +regmap_reg_range (CLK_SLOW_SYS_RESUS_CTRL ,CLK_SLOW_SYS_RESUS_CTRL ), +regmap_reg_range (FC0_REF_KHZ ,FC0_RESULT ), +regmap_reg_range (VIDEO_CLK_VEC_CTRL ,VIDEO_CLK_VEC_DIV_INT ), +regmap_reg_range (VIDEO_CLK_VEC_SEL ,VIDEO_CLK_DPI_DIV_INT ), +regmap_reg_range (VIDEO_CLK_DPI_SEL ,VIDEO_CLK_MIPI1_DPI_SEL ), +}; + +static const struct regmap_access_table rp1_reg_table = { + .yes_ranges = rp1_reg_ranges, + .n_yes_ranges =ARRAY_SIZE (rp1_reg_ranges), +}; + +static const struct regmap_config rp1_clk_regmap_cfg = { + .reg_bits =32 , + .val_bits =32 , + .reg_stride =4 , + .max_register =PLL_VIDEO_SEC , + .name ="rp1-clk" , + .rd_table = &rp1_reg_table, +}; + +static int rp1_clk_probe (struct platform_device *pdev) +{ +const size_t asize =ARRAY_SIZE (clk_desc_array); +struct rp1_clk_desc *desc; +struct device *dev = &pdev->dev; +struct rp1_clockman *clockman; +struct clk_hw **hws; +unsigned int i; + + clockman =devm_kzalloc (dev,struct_size (clockman, onecell.hws, asize), +GFP_KERNEL ); +if (!clockman) +return -ENOMEM ; + +spin_lock_init (&clockman->regs_lock);
drivers/clk/clk-rp1.c line 1497
Quoted 10 lines
drivers/clk/clk-rp1.c new file +10
-0+ clockman->dev = dev; + + clockman->regs =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (clockman->regs)) +return PTR_ERR (clockman->regs); + + clockman->regmap =devm_regmap_init_mmio (dev, clockman->regs, + &rp1_clk_regmap_cfg); +if (IS_ERR (clockman->regmap)) { +dev_err (dev,"could not init clock regmap\n" );
return dev_err_probe()?
Quoted 22 lines
drivers/clk/clk-rp1.c new file +22
-0+return PTR_ERR (clockman->regmap); + } + + clockman->onecell.num = asize; + hws = clockman->onecell.hws; + +for (i =0 ; i < asize; i++) { + desc = &clk_desc_array[i]; +if (desc->clk_register && desc->data) { + hws[i] = desc->clk_register (clockman, desc); +if (IS_ERR_OR_NULL (hws[i])) +dev_err_probe (dev,PTR_ERR (hws[i]), +"Unable to register clock: %s\n" , +clk_hw_get_name (hws[i])); + } + } + +platform_set_drvdata (pdev, clockman); + +return devm_of_clk_add_hw_provider (dev, of_clk_hw_onecell_get, + &clockman->onecell); +}
Andrea della Porta
maintainerRe: [PATCH v3 07/12] clk: rp1: Add support for clocks provided by RP1
Hi Stephen,
Quoted 6 lines · Stephen Boyd
Quoting Andrea della Porta (2024-10-28 07:07:24)
Quoted 4 lines
drivers/clk/clk-rp1.c new file +0
-1--- /dev/null[...]
Quoted 6 lines
drivers/clk/clk-rp1.c line 328
Quoted 4 lines
drivers/clk/clk-rp1.c new file +4
-0+ +struct rp1_clockman { +struct device *dev; +void __iomem *regs;Do you still need this if there's a regmap?
Unfortunately the clk_divider registered in rp1_register_pll_divider() mandates the use of a MMIO registeri, and yes, the divider and teh other clock shares some registers. AFAICT there were attempts to upstream generic regmap support for clk_divider, but right now there are just custom implementations (e.g. drivers/clk/qcom/clk-regmap.c). So, in order to use regmap, that clock divider shoulf be first augmented with regmap support. Please let me know if you think it's worth the effort.
Quoted 5 lines
drivers/clk/clk-rp1.c line 330
Quoted 3 lines
drivers/clk/clk-rp1.c new file +2
-0+struct regmap *regmap; +spinlock_t regs_lock;/* spinlock for all clocks */ Do you need this or is the spinlock in the regmap sufficient?
The original code wrapped multiple registers write/read inside the spinlock, so I suspect that using the internal regmap spinlock for each single transaciton (so to open up for interleaved register access, although I have no evidence of that) could have side-effects so I would prefer to stay safe and manage the lock from outside. I could easily use regmap_multi_reg_write() and friends to synchronize access across multiple registers but then we would have the problem above about missing regmap support in clk_divider, since now it's solved by passing the same spinlock to it too. I'm open to alternatives here...
Quoted 10 lines
drivers/clk/clk-rp1.c line 337
Quoted 8 lines
drivers/clk/clk-rp1.c new file +7
-0+ +/* Must be last */ +struct clk_hw_onecell_data onecell; +}; + +struct rp1_pll_core_data { +const char *name;These 'name' members can move to
clk_init_data?
You've read my mind, I was exactly planning that for the next revision
Quoted 9 lines
drivers/clk/clk-rp1.c line 342
Quoted 6 lines
drivers/clk/clk-rp1.c new file +5
-0+u32 cs_reg; +u32 pwr_reg; +u32 fbdiv_int_reg; +u32 fbdiv_frac_reg; +unsigned long flags;And probably flags as well? It seems like
clk_init_datashould be declared at the same time as structrp1_pll_core_datais.
Ditto.
Quoted 61 lines
Quoted 48 lines
drivers/clk/clk-rp1.c new file +47
-0+u32 fc0_src; +}; + +struct rp1_pll_data { +const char *name; +u32 ctrl_reg; +unsigned long flags; +u32 fc0_src; +}; + +struct rp1_pll_ph_data { +const char *name; +unsigned int phase; +unsigned int fixed_divider; +u32 ph_reg; +unsigned long flags; +u32 fc0_src; +}; + +struct rp1_pll_divider_data { +const char *name; +u32 sec_reg; +unsigned long flags; +u32 fc0_src; +}; + +struct rp1_clock_data { +const char *name; +int num_std_parents; +int num_aux_parents; +unsigned long flags; +u32 oe_mask; +u32 clk_src_mask; +u32 ctrl_reg; +u32 div_int_reg; +u32 div_frac_reg; +u32 sel_reg; +u32 div_int_max; +unsigned long max_freq; +u32 fc0_src; +}; + +struct rp1_clk_desc { +struct clk_hw *(*clk_register)(struct rp1_clockman *clockman, +struct rp1_clk_desc *desc); +const void *data; +struct clk_hw hw;drivers/clk/clk-rp1.c line 399
Quoted 10 lines
drivers/clk/clk-rp1.c new file +10
-0+struct rp1_clockman *clockman; +unsigned long cached_rate; +struct clk_divider div; +}; + +#define FIELD_SET (_reg, _mask, _val) \ +do { \ + u32 mask = (_mask); \ + (_reg) &= ~mask; \ + (_reg) |= FIELD_PREP(mask, (_val)); \Please just write
Quoted 4 lines
reg &= ~mask reg |= FIELD_PREP(mask, val);instead of using this macro.
Ack.
Quoted 88 lines
Quoted 4 lines
drivers/clk/clk-rp1.c new file +3
-0+}while (0 ) + +[...]
Quoted 83 lines
drivers/clk/clk-rp1.c new file +83
-0+ +static struct clk_hw *rp1_register_pll_core (struct rp1_clockman *clockman, +struct rp1_clk_desc *desc) +{ +const struct rp1_pll_core_data *pll_core_data = desc->data; +struct clk_init_data init = { }; +int ret; + +/* All of the PLL cores derive from the external oscillator. */ + init.parent_data = desc->hw.init->parent_data; + init.num_parents = desc->hw.init->num_parents; + init.name = pll_core_data->name; + init.ops = &rp1_pll_core_ops; + init.flags = pll_core_data->flags |CLK_IGNORE_UNUSED |CLK_IS_CRITICAL ; + + desc->clockman = clockman; + desc->hw.init = &init; + + ret =devm_clk_hw_register (clockman->dev, &desc->hw); + +if (ret) +return ERR_PTR (ret); + +return &desc->hw; +} + +static struct clk_hw *rp1_register_pll (struct rp1_clockman *clockman, +struct rp1_clk_desc *desc) +{ +const struct rp1_pll_data *pll_data = desc->data; +struct clk_init_data init = { }; +int ret; + + init.parent_data = desc->hw.init->parent_data; + init.num_parents = desc->hw.init->num_parents; + init.name = pll_data->name; + init.ops = &rp1_pll_ops; + init.flags = pll_data->flags |CLK_IGNORE_UNUSED |CLK_IS_CRITICAL ; + + desc->clockman = clockman; + desc->hw.init = &init; + + ret =devm_clk_hw_register (clockman->dev, &desc->hw); + +if (ret) +return ERR_PTR (ret); + +return &desc->hw; +} + +static struct clk_hw *rp1_register_pll_ph (struct rp1_clockman *clockman, +struct rp1_clk_desc *desc) +{ +const struct rp1_pll_ph_data *ph_data = desc->data; +struct clk_init_data init = { }; +int ret; + + init.parent_data = desc->hw.init->parent_data; + init.num_parents = desc->hw.init->num_parents; + init.name = ph_data->name; + init.ops = &rp1_pll_ph_ops; + init.flags = ph_data->flags |CLK_IGNORE_UNUSED ; + + desc->clockman = clockman; + desc->hw.init = &init; + + ret =devm_clk_hw_register (clockman->dev, &desc->hw); + +if (ret) +return ERR_PTR (ret); + +return &desc->hw; +} + +static struct clk_hw *rp1_register_pll_divider (struct rp1_clockman *clockman, +struct rp1_clk_desc *desc) +{ +const struct rp1_pll_data *divider_data = desc->data; +struct clk_init_data init = { }; +int ret; + + init.parent_data = desc->hw.init->parent_data; + init.num_parents = desc->hw.init->num_parents;
Quoted 8 lines
drivers/clk/clk-rp1.c line 1232
Quoted 5 lines
drivers/clk/clk-rp1.c new file +5
-0+ init.name = divider_data->name; + init.ops = &rp1_pll_divider_ops; + init.flags = divider_data->flags |CLK_IGNORE_UNUSED |CLK_IS_CRITICAL ; + + desc->div.reg = clockman->regs + divider_data->ctrl_reg;Why is 'regs' used here? Isn't everything using a regmap now so it's all offsets?
Already explained above.
Quoted 51 lines
Quoted 51 lines
drivers/clk/clk-rp1.c new file +50
-0+ desc->div.shift =PLL_SEC_DIV_SHIFT ; + desc->div.width =PLL_SEC_DIV_WIDTH ; + desc->div.flags =CLK_DIVIDER_ROUND_CLOSEST ; + desc->div.flags |=CLK_IS_CRITICAL ; + desc->div.lock = &clockman->regs_lock; + desc->div.hw.init = &init; + desc->div.table = pll_sec_div_table; + + desc->clockman = clockman; + + ret =devm_clk_hw_register (clockman->dev, &desc->div.hw); + +if (ret) +return ERR_PTR (ret); + +return &desc->div.hw; +} + +static struct clk_hw *rp1_register_clock (struct rp1_clockman *clockman, +struct rp1_clk_desc *desc) +{ +const struct rp1_clock_data *clock_data = desc->data; +struct clk_init_data init = { }; +int ret; + +if (WARN_ON_ONCE (MAX_CLK_PARENTS < + clock_data->num_std_parents + clock_data->num_aux_parents)) +return NULL ; + +/* There must be a gap for the AUX selector */ +if (WARN_ON_ONCE (clock_data->num_std_parents >AUX_SEL && + desc->hw.init->parent_data[AUX_SEL ].index !=-1 )) +return NULL ; + + init.parent_data = desc->hw.init->parent_data; + init.num_parents = desc->hw.init->num_parents; + init.name = clock_data->name; + init.flags = clock_data->flags |CLK_IGNORE_UNUSED ; + init.ops = &rp1_clk_ops; + + desc->clockman = clockman; + desc->hw.init = &init; + + ret =devm_clk_hw_register (clockman->dev, &desc->hw); + +if (ret) +return ERR_PTR (ret); + +return &desc->hw; +}
Quoted 8 lines
drivers/clk/clk-rp1.c line 1287
Quoted 5 lines
drivers/clk/clk-rp1.c new file +5
-0+ +/* Assignment helper macros for different clock types. */ +#define _REGISTER (f, ...) { .clk_register = f, __VA_ARGS__ } + +#define PARENT_CLK (pnum, ...) .hw.init = &(const struct clk_init_data) { \Instead of this macro just use
CLK_HW_INIT_HW()orCLK_HW_INIT_PARENTS_DATA()?
Ack.
Quoted 205 lines
Quoted 205 lines
drivers/clk/clk-rp1.c new file +204
-0+ .parent_data = (const struct \ + clk_parent_data[]) { \ + __VA_ARGS__ \ + }, \ + .num_parents = pnum } + +#define CLK_DATA (type, ...) .data = &(struct type) { __VA_ARGS__ } + +#define REGISTER_PLL_CORE (...) _REGISTER(&rp1_register_pll_core, \ + __VA_ARGS__) + +#define REGISTER_PLL (...) _REGISTER(&rp1_register_pll, \ + __VA_ARGS__) + +#define REGISTER_PLL_PH (...) _REGISTER(&rp1_register_pll_ph, \ + __VA_ARGS__) + +#define REGISTER_PLL_DIV (...) _REGISTER(&rp1_register_pll_divider, \ + __VA_ARGS__) + +#define REGISTER_CLK (...) _REGISTER(&rp1_register_clock, \ + __VA_ARGS__) + +static struct rp1_clk_desc clk_desc_array[] = { + [RP1_PLL_SYS_CORE] = REGISTER_PLL_CORE(PARENT_CLK(1, { .index = 0 }), + CLK_DATA(rp1_pll_core_data, + .name = "pll_sys_core", + .cs_reg = PLL_SYS_CS, + .pwr_reg = PLL_SYS_PWR, + .fbdiv_int_reg = PLL_SYS_FBDIV_INT, + .fbdiv_frac_reg = PLL_SYS_FBDIV_FRAC, + )), + + [RP1_PLL_AUDIO_CORE] = REGISTER_PLL_CORE(PARENT_CLK(1, { .index = 0 }), + CLK_DATA(rp1_pll_core_data, + .name = "pll_audio_core", + .cs_reg = PLL_AUDIO_CS, + .pwr_reg = PLL_AUDIO_PWR, + .fbdiv_int_reg = PLL_AUDIO_FBDIV_INT, + .fbdiv_frac_reg = PLL_AUDIO_FBDIV_FRAC, + )), + + [RP1_PLL_VIDEO_CORE] = REGISTER_PLL_CORE(PARENT_CLK(1, { .index = 0 }), + CLK_DATA(rp1_pll_core_data, + .name = "pll_video_core", + .cs_reg = PLL_VIDEO_CS, + .pwr_reg = PLL_VIDEO_PWR, + .fbdiv_int_reg = PLL_VIDEO_FBDIV_INT, + .fbdiv_frac_reg = PLL_VIDEO_FBDIV_FRAC, + )), + + [RP1_PLL_SYS ] =REGISTER_PLL (PARENT_CLK (1 , + { .hw = &clk_desc_array[RP1_PLL_SYS_CORE].hw } + ), + CLK_DATA(rp1_pll_data, + .name = "pll_sys", + .ctrl_reg = PLL_SYS_PRIM, + .fc0_src = FC_NUM(0, 2), + )), + + [RP1_CLK_ETH_TSU] = REGISTER_CLK(PARENT_CLK(1, { .index = 0 }), + CLK_DATA(rp1_clock_data, + .name = "clk_eth_tsu", + .num_std_parents = 0, + .num_aux_parents = 1, + .ctrl_reg = CLK_ETH_TSU_CTRL, + .div_int_reg = CLK_ETH_TSU_DIV_INT, + .sel_reg = CLK_ETH_TSU_SEL, + .div_int_max = DIV_INT_8BIT_MAX, + .max_freq = 50 * HZ_PER_MHZ, + .fc0_src = FC_NUM(5, 7), + )), + + [RP1_CLK_SYS ] =REGISTER_CLK (PARENT_CLK (3 , + { .index = 0 }, + { .index = -1 }, + { .hw = &clk_desc_array[RP1_PLL_SYS].hw } + ), + CLK_DATA(rp1_clock_data, + .name = "clk_sys", + .num_std_parents = 3, + .num_aux_parents = 0, + .ctrl_reg = CLK_SYS_CTRL, + .div_int_reg = CLK_SYS_DIV_INT, + .sel_reg = CLK_SYS_SEL, + .div_int_max = DIV_INT_24BIT_MAX, + .max_freq = 200 * HZ_PER_MHZ, + .fc0_src = FC_NUM(0, 4), + .clk_src_mask = 0x3, + )), + + [RP1_PLL_SYS_PRI_PH ] =REGISTER_PLL_PH (PARENT_CLK (1 , + { .hw = &clk_desc_array[RP1_PLL_SYS].hw } + ), + CLK_DATA(rp1_pll_ph_data, + .name = "pll_sys_pri_ph", + .ph_reg = PLL_SYS_PRIM, + .fixed_divider = 2, + .phase = RP1_PLL_PHASE_0, + .fc0_src = FC_NUM(1, 2), + )), + + [RP1_PLL_SYS_SEC ] =REGISTER_PLL_DIV (PARENT_CLK (1 , + { .hw = &clk_desc_array[RP1_PLL_SYS_CORE].hw } + ), + CLK_DATA(rp1_pll_data, + .name = "pll_sys_sec", + .ctrl_reg = PLL_SYS_SEC, + .fc0_src = FC_NUM(2, 2), + )), +}; + +static const struct regmap_range rp1_reg_ranges[] = { +regmap_reg_range (PLL_SYS_CS ,PLL_SYS_SEC ), +regmap_reg_range (PLL_AUDIO_CS ,PLL_AUDIO_TERN ), +regmap_reg_range (PLL_VIDEO_CS ,PLL_VIDEO_SEC ), +regmap_reg_range (GPCLK_OE_CTRL ,GPCLK_OE_CTRL ), +regmap_reg_range (CLK_SYS_CTRL ,CLK_SYS_DIV_INT ), +regmap_reg_range (CLK_SYS_SEL ,CLK_SYS_SEL ), +regmap_reg_range (CLK_SLOW_SYS_CTRL ,CLK_SLOW_SYS_DIV_INT ), +regmap_reg_range (CLK_SLOW_SYS_SEL ,CLK_SLOW_SYS_SEL ), +regmap_reg_range (CLK_DMA_CTRL ,CLK_DMA_DIV_INT ), +regmap_reg_range (CLK_DMA_SEL ,CLK_DMA_SEL ), +regmap_reg_range (CLK_UART_CTRL ,CLK_UART_DIV_INT ), +regmap_reg_range (CLK_UART_SEL ,CLK_UART_SEL ), +regmap_reg_range (CLK_ETH_CTRL ,CLK_ETH_DIV_INT ), +regmap_reg_range (CLK_ETH_SEL ,CLK_ETH_SEL ), +regmap_reg_range (CLK_PWM0_CTRL ,CLK_PWM0_SEL ), +regmap_reg_range (CLK_PWM1_CTRL ,CLK_PWM1_SEL ), +regmap_reg_range (CLK_AUDIO_IN_CTRL ,CLK_AUDIO_IN_DIV_INT ), +regmap_reg_range (CLK_AUDIO_IN_SEL ,CLK_AUDIO_IN_SEL ), +regmap_reg_range (CLK_AUDIO_OUT_CTRL ,CLK_AUDIO_OUT_DIV_INT ), +regmap_reg_range (CLK_AUDIO_OUT_SEL ,CLK_AUDIO_OUT_SEL ), +regmap_reg_range (CLK_I2S_CTRL ,CLK_I2S_DIV_INT ), +regmap_reg_range (CLK_I2S_SEL ,CLK_I2S_SEL ), +regmap_reg_range (CLK_MIPI0_CFG_CTRL ,CLK_MIPI0_CFG_DIV_INT ), +regmap_reg_range (CLK_MIPI0_CFG_SEL ,CLK_MIPI0_CFG_SEL ), +regmap_reg_range (CLK_MIPI1_CFG_CTRL ,CLK_MIPI1_CFG_DIV_INT ), +regmap_reg_range (CLK_MIPI1_CFG_SEL ,CLK_MIPI1_CFG_SEL ), +regmap_reg_range (CLK_PCIE_AUX_CTRL ,CLK_PCIE_AUX_DIV_INT ), +regmap_reg_range (CLK_PCIE_AUX_SEL ,CLK_PCIE_AUX_SEL ), +regmap_reg_range (CLK_USBH0_MICROFRAME_CTRL ,CLK_USBH0_MICROFRAME_DIV_INT ), +regmap_reg_range (CLK_USBH0_MICROFRAME_SEL ,CLK_USBH0_MICROFRAME_SEL ), +regmap_reg_range (CLK_USBH1_MICROFRAME_CTRL ,CLK_USBH1_MICROFRAME_DIV_INT ), +regmap_reg_range (CLK_USBH1_MICROFRAME_SEL ,CLK_USBH1_MICROFRAME_SEL ), +regmap_reg_range (CLK_USBH0_SUSPEND_CTRL ,CLK_USBH0_SUSPEND_DIV_INT ), +regmap_reg_range (CLK_USBH0_SUSPEND_SEL ,CLK_USBH0_SUSPEND_SEL ), +regmap_reg_range (CLK_USBH1_SUSPEND_CTRL ,CLK_USBH1_SUSPEND_DIV_INT ), +regmap_reg_range (CLK_USBH1_SUSPEND_SEL ,CLK_USBH1_SUSPEND_SEL ), +regmap_reg_range (CLK_ETH_TSU_CTRL ,CLK_ETH_TSU_DIV_INT ), +regmap_reg_range (CLK_ETH_TSU_SEL ,CLK_ETH_TSU_SEL ), +regmap_reg_range (CLK_ADC_CTRL ,CLK_ADC_DIV_INT ), +regmap_reg_range (CLK_ADC_SEL ,CLK_ADC_SEL ), +regmap_reg_range (CLK_SDIO_TIMER_CTRL ,CLK_SDIO_TIMER_DIV_INT ), +regmap_reg_range (CLK_SDIO_TIMER_SEL ,CLK_SDIO_TIMER_SEL ), +regmap_reg_range (CLK_SDIO_ALT_SRC_CTRL ,CLK_SDIO_ALT_SRC_DIV_INT ), +regmap_reg_range (CLK_SDIO_ALT_SRC_SEL ,CLK_SDIO_ALT_SRC_SEL ), +regmap_reg_range (CLK_GP0_CTRL ,CLK_GP0_SEL ), +regmap_reg_range (CLK_GP1_CTRL ,CLK_GP1_SEL ), +regmap_reg_range (CLK_GP2_CTRL ,CLK_GP2_SEL ), +regmap_reg_range (CLK_GP3_CTRL ,CLK_GP3_SEL ), +regmap_reg_range (CLK_GP4_CTRL ,CLK_GP4_SEL ), +regmap_reg_range (CLK_GP5_CTRL ,CLK_GP5_SEL ), +regmap_reg_range (CLK_SYS_RESUS_CTRL ,CLK_SYS_RESUS_CTRL ), +regmap_reg_range (CLK_SLOW_SYS_RESUS_CTRL ,CLK_SLOW_SYS_RESUS_CTRL ), +regmap_reg_range (FC0_REF_KHZ ,FC0_RESULT ), +regmap_reg_range (VIDEO_CLK_VEC_CTRL ,VIDEO_CLK_VEC_DIV_INT ), +regmap_reg_range (VIDEO_CLK_VEC_SEL ,VIDEO_CLK_DPI_DIV_INT ), +regmap_reg_range (VIDEO_CLK_DPI_SEL ,VIDEO_CLK_MIPI1_DPI_SEL ), +}; + +static const struct regmap_access_table rp1_reg_table = { + .yes_ranges = rp1_reg_ranges, + .n_yes_ranges =ARRAY_SIZE (rp1_reg_ranges), +}; + +static const struct regmap_config rp1_clk_regmap_cfg = { + .reg_bits =32 , + .val_bits =32 , + .reg_stride =4 , + .max_register =PLL_VIDEO_SEC , + .name ="rp1-clk" , + .rd_table = &rp1_reg_table, +}; + +static int rp1_clk_probe (struct platform_device *pdev) +{ +const size_t asize =ARRAY_SIZE (clk_desc_array); +struct rp1_clk_desc *desc; +struct device *dev = &pdev->dev; +struct rp1_clockman *clockman; +struct clk_hw **hws; +unsigned int i; + + clockman =devm_kzalloc (dev,struct_size (clockman, onecell.hws, asize), +GFP_KERNEL ); +if (!clockman) +return -ENOMEM ; + +spin_lock_init (&clockman->regs_lock); + clockman->dev = dev; + + clockman->regs =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (clockman->regs))
Quoted 8 lines
drivers/clk/clk-rp1.c line 1497
Quoted 6 lines
drivers/clk/clk-rp1.c new file +6
-0+return PTR_ERR (clockman->regs); + + clockman->regmap =devm_regmap_init_mmio (dev, clockman->regs, + &rp1_clk_regmap_cfg); +if (IS_ERR (clockman->regmap)) { +dev_err (dev,"could not init clock regmap\n" );return
dev_err_probe()?
Ack.
Many thanks,
Andrea
Quoted 23 lines
Quoted 23 lines
drivers/clk/clk-rp1.c new file +22
-0+return PTR_ERR (clockman->regmap); + } + + clockman->onecell.num = asize; + hws = clockman->onecell.hws; + +for (i =0 ; i < asize; i++) { + desc = &clk_desc_array[i]; +if (desc->clk_register && desc->data) { + hws[i] = desc->clk_register (clockman, desc); +if (IS_ERR_OR_NULL (hws[i])) +dev_err_probe (dev,PTR_ERR (hws[i]), +"Unable to register clock: %s\n" , +clk_hw_get_name (hws[i])); + } + } + +platform_set_drvdata (pdev, clockman); + +return devm_of_clk_add_hw_provider (dev, of_clk_hw_onecell_get, + &clockman->onecell); +}
kernel test robot
build botRe: [PATCH v3 07/12] clk: rp1: Add support for clocks provided by RP1
In reply to Andrea della Portakernel test robot noticed the following build warnings:
Hi Andrea,
kernel test robot noticed the following build warnings:
[auto build test WARNING on clk/clk-next]
[also build test WARNING on char-misc/char-misc-testing char-misc/char-misc-next char-misc/char-misc-linus robh/for-next linus/master v6.12-rc5] [cannot apply to next-20241031]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Andrea-della-Porta/dt-bindings-clock-Add-RaspberryPi-RP1-clock-bindings/20241028-221122 base: https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next patch link: https://lore.kernel.org/r/c20e3d6d87c71691b149cdeeafc94009953346b2.1730123575.git.andrea.porta%40suse.com patch subject: [PATCH v3 07/12] clk: rp1: Add support for clocks provided by RP1 config: s390-allmodconfig (https://download.01.org/0day-ci/archive/20241031/[email protected]/config) compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project 639a7ac648f1e50ccd2556e17d401c04f9cce625) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241031/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
In file included from drivers/clk/clk-rp1.c:9:
In file included from include/linux/regmap.h:20:
In file included from include/linux/iopoll.h:14:
In file included from include/linux/io.h:14:
In file included from arch/s390/include/asm/io.h:93:
include/asm-generic/io.h:548:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
548 | val = __raw_readb(PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:561:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
561 | val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/big_endian.h:37:59: note: expanded from macro '__le16_to_cpu'
37 | #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
| ^
include/uapi/linux/swab.h:102:54: note: expanded from macro '__swab16'
102 | #define __swab16(x) (__u16)__builtin_bswap16((__u16)(x))
| ^
In file included from drivers/clk/clk-rp1.c:9:
In file included from include/linux/regmap.h:20:
In file included from include/linux/iopoll.h:14:
In file included from include/linux/io.h:14:
In file included from arch/s390/include/asm/io.h:93:
include/asm-generic/io.h:574:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
574 | val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/big_endian.h:35:59: note: expanded from macro '__le32_to_cpu'
35 | #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
| ^
include/uapi/linux/swab.h:115:54: note: expanded from macro '__swab32'
115 | #define __swab32(x) (__u32)__builtin_bswap32((__u32)(x))
| ^
In file included from drivers/clk/clk-rp1.c:9:
In file included from include/linux/regmap.h:20:
In file included from include/linux/iopoll.h:14:
In file included from include/linux/io.h:14:
In file included from arch/s390/include/asm/io.h:93:
include/asm-generic/io.h:585:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
585 | __raw_writeb(value, PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:595:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
595 | __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:605:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
605 | __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:693:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
693 | readsb(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:701:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
701 | readsw(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:709:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
709 | readsl(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:718:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
718 | writesb(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:727:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
727 | writesw(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:736:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
736 | writesl(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
In file included from drivers/clk/clk-rp1.c:11:
In file included from include/linux/module.h:19:
In file included from include/linux/elf.h:6:
In file included from arch/s390/include/asm/elf.h:181:
In file included from arch/s390/include/asm/mmu_context.h:11:
In file included from arch/s390/include/asm/pgalloc.h:18:
In file included from include/linux/mm.h:2213:
include/linux/vmstat.h:504:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
504 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
505 | item];
| ~~~~
include/linux/vmstat.h:511:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
511 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
512 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
518 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
include/linux/vmstat.h:524:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
524 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
525 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
>> drivers/clk/clk-rp1.c:621:2: warning: result of comparison of constant 18446744073709551615 with expression of type 'typeof (_Generic((mask), char: (unsigned char)0, unsigned char: (unsigned char)0, signed char: (unsigned char)0, unsigned short: (unsigned short)0, short: (unsigned short)0, unsigned int: (unsigned int)0, int: (unsigned int)0, unsigned long: (unsigned long)0, long: (unsigned long)0, unsigned long long: (unsigned long long)0, long long: (unsigned long long)0, default: (mask)))' (aka 'unsigned int') is always false [-Wtautological-constant-out-of-range-compare]
621 | FIELD_SET(prim, PLL_PRIM_DIV1_MASK, prim_div1);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/clk/clk-rp1.c:399:12: note: expanded from macro 'FIELD_SET'
399 | (_reg) |= FIELD_PREP(mask, (_val)); \
| ^~~~~~~~~~~~~~~~~~~~~~~~
include/linux/bitfield.h:115:3: note: expanded from macro 'FIELD_PREP'
115 | __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/bitfield.h:72:53: note: expanded from macro '__BF_FIELD_CHECK'
72 | BUILD_BUG_ON_MSG(__bf_cast_unsigned(_mask, _mask) > \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
73 | __bf_cast_unsigned(_reg, ~0ull), \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
74 | _pfx "type of reg too small for mask"); \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
include/linux/compiler_types.h:517:22: note: expanded from macro 'compiletime_assert'
517 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler_types.h:505:23: note: expanded from macro '_compiletime_assert'
505 | __compiletime_assert(condition, msg, prefix, suffix)
| ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler_types.h:497:9: note: expanded from macro '__compiletime_assert'
497 | if (!(condition)) \
| ^~~~~~~~~
drivers/clk/clk-rp1.c:622:2: warning: result of comparison of constant 18446744073709551615 with expression of type 'typeof (_Generic((mask), char: (unsigned char)0, unsigned char: (unsigned char)0, signed char: (unsigned char)0, unsigned short: (unsigned short)0, short: (unsigned short)0, unsigned int: (unsigned int)0, int: (unsigned int)0, unsigned long: (unsigned long)0, long: (unsigned long)0, unsigned long long: (unsigned long long)0, long long: (unsigned long long)0, default: (mask)))' (aka 'unsigned int') is always false [-Wtautological-constant-out-of-range-compare]
622 | FIELD_SET(prim, PLL_PRIM_DIV2_MASK, prim_div2);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/clk/clk-rp1.c:399:12: note: expanded from macro 'FIELD_SET'
399 | (_reg) |= FIELD_PREP(mask, (_val)); \
| ^~~~~~~~~~~~~~~~~~~~~~~~
include/linux/bitfield.h:115:3: note: expanded from macro 'FIELD_PREP'
115 | __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/bitfield.h:72:53: note: expanded from macro '__BF_FIELD_CHECK'
72 | BUILD_BUG_ON_MSG(__bf_cast_unsigned(_mask, _mask) > \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
73 | __bf_cast_unsigned(_reg, ~0ull), \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
74 | _pfx "type of reg too small for mask"); \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
include/linux/compiler_types.h:517:22: note: expanded from macro 'compiletime_assert'
517 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler_types.h:505:23: note: expanded from macro '_compiletime_assert'
505 | __compiletime_assert(condition, msg, prefix, suffix)
| ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler_types.h:497:9: note: expanded from macro '__compiletime_assert'
497 | if (!(condition)) \
| ^~~~~~~~~
drivers/clk/clk-rp1.c:767:2: warning: result of comparison of constant 18446744073709551615 with expression of type 'typeof (_Generic((mask), char: (unsigned char)0, unsigned char: (unsigned char)0, signed char: (unsigned char)0, unsigned short: (unsigned short)0, short: (unsigned short)0, unsigned int: (unsigned int)0, int: (unsigned int)0, unsigned long: (unsigned long)0, long: (unsigned long)0, unsigned long long: (unsigned long long)0, long long: (unsigned long long)0, default: (mask)))' (aka 'unsigned int') is always false [-Wtautological-constant-out-of-range-compare]
767 | FIELD_SET(sec, PLL_SEC_DIV_MASK, div);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/clk/clk-rp1.c:399:12: note: expanded from macro 'FIELD_SET'
399 | (_reg) |= FIELD_PREP(mask, (_val)); \
| ^~~~~~~~~~~~~~~~~~~~~~~~
include/linux/bitfield.h:115:3: note: expanded from macro 'FIELD_PREP'
115 | __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/bitfield.h:72:53: note: expanded from macro '__BF_FIELD_CHECK'
72 | BUILD_BUG_ON_MSG(__bf_cast_unsigned(_mask, _mask) > \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
73 | __bf_cast_unsigned(_reg, ~0ull), \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
74 | _pfx "type of reg too small for mask"); \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
include/linux/compiler_types.h:517:22: note: expanded from macro 'compiletime_assert'
517 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler_types.h:505:23: note: expanded from macro '_compiletime_assert'
505 | __compiletime_assert(condition, msg, prefix, suffix)
| ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler_types.h:497:9: note: expanded from macro '__compiletime_assert'
497 | if (!(condition)) \
| ^~~~~~~~~
drivers/clk/clk-rp1.c:948:3: warning: result of comparison of constant 18446744073709551615 with expression of type 'typeof (_Generic((mask), char: (unsigned char)0, unsigned char: (unsigned char)0, signed char: (unsigned char)0, unsigned short: (unsigned short)0, short: (unsigned short)0, unsigned int: (unsigned int)0, int: (unsigned int)0, unsigned long: (unsigned long)0, long: (unsigned long)0, unsigned long long: (unsigned long long)0, long long: (unsigned long long)0, default: (mask)))' (aka 'unsigned int') is always false [-Wtautological-constant-out-of-range-compare]
948 | FIELD_SET(ctrl, CLK_CTRL_AUXSRC_MASK, index - data->num_std_parents);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/clk/clk-rp1.c:399:12: note: expanded from macro 'FIELD_SET'
399 | (_reg) |= FIELD_PREP(mask, (_val)); \
| ^~~~~~~~~~~~~~~~~~~~~~~~
include/linux/bitfield.h:115:3: note: expanded from macro 'FIELD_PREP'
115 | __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/bitfield.h:72:53: note: expanded from macro '__BF_FIELD_CHECK'
72 | BUILD_BUG_ON_MSG(__bf_cast_unsigned(_mask, _mask) > \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
73 | __bf_cast_unsigned(_reg, ~0ull), \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
74 | _pfx "type of reg too small for mask"); \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
include/linux/compiler_types.h:517:22: note: expanded from macro 'compiletime_assert'
517 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler_types.h:505:23: note: expanded from macro '_compiletime_assert'
505 | __compiletime_assert(condition, msg, prefix, suffix)
| ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for MODVERSIONS
Depends on [n]: MODULES [=y] && !COMPILE_TEST [=y]
Selected by [y]:
- RANDSTRUCT_FULL [=y] && (CC_HAS_RANDSTRUCT [=y] || GCC_PLUGINS [=n]) && MODULES [=y]
vim +621 drivers/clk/clk-rp1.c
607
608 static int rp1_pll_set_rate(struct clk_hw *hw,
609 unsigned long rate, unsigned long parent_rate)
610 {
611 struct rp1_clk_desc *pll = container_of(hw, struct rp1_clk_desc, hw);
612 struct rp1_clockman *clockman = pll->clockman;
613 const struct rp1_pll_data *data = pll->data;
614
615 u32 prim, prim_div1, prim_div2;
616
617 get_pll_prim_dividers(rate, parent_rate, &prim_div1, &prim_div2);
618
619 spin_lock(&clockman->regs_lock);
620 prim = clockman_read(clockman, data->ctrl_reg);
> 621 FIELD_SET(prim, PLL_PRIM_DIV1_MASK, prim_div1);
622 FIELD_SET(prim, PLL_PRIM_DIV2_MASK, prim_div2);
623 clockman_write(clockman, data->ctrl_reg, prim);
624 spin_unlock(&clockman->regs_lock);
625
626 return 0;
627 }
628
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH v3 07/12] clk: rp1: Add support for clocks provided by RP1
In reply to Andrea della Portakernel test robot noticed the following build errors:
Hi Andrea,
kernel test robot noticed the following build errors:
[auto build test ERROR on clk/clk-next]
[also build test ERROR on char-misc/char-misc-testing char-misc/char-misc-next char-misc/char-misc-linus robh/for-next linus/master v6.12-rc5] [cannot apply to next-20241031]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Andrea-della-Porta/dt-bindings-clock-Add-RaspberryPi-RP1-clock-bindings/20241028-221122 base: https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next patch link: https://lore.kernel.org/r/c20e3d6d87c71691b149cdeeafc94009953346b2.1730123575.git.andrea.porta%40suse.com patch subject: [PATCH v3 07/12] clk: rp1: Add support for clocks provided by RP1 config: sparc-allmodconfig (https://download.01.org/0day-ci/archive/20241031/[email protected]/config) compiler: sparc64-linux-gcc (GCC) 14.1.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241031/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
drivers/clk/clk-rp1.c: In function 'rp1_pll_set_rate':
>> drivers/clk/clk-rp1.c:399:19: error: implicit declaration of function 'FIELD_PREP'; did you mean 'FIELD_SET'? [-Wimplicit-function-declaration]
399 | (_reg) |= FIELD_PREP(mask, (_val)); \
| ^~~~~~~~~~
drivers/clk/clk-rp1.c:621:9: note: in expansion of macro 'FIELD_SET'
621 | FIELD_SET(prim, PLL_PRIM_DIV1_MASK, prim_div1);
| ^~~~~~~~~vim +399 drivers/clk/clk-rp1.c
394
395 #define FIELD_SET(_reg, _mask, _val) \
396 do { \
397 u32 mask = (_mask); \
398 (_reg) &= ~mask; \
> 399 (_reg) |= FIELD_PREP(mask, (_val)); \
400 } while (0)
401
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH v3 07/12] clk: rp1: Add support for clocks provided by RP1
In reply to Andrea della Portakernel test robot noticed the following build errors:
Hi Andrea,
kernel test robot noticed the following build errors:
[auto build test ERROR on clk/clk-next]
[also build test ERROR on char-misc/char-misc-testing char-misc/char-misc-next char-misc/char-misc-linus robh/for-next linus/master v6.12-rc5] [cannot apply to next-20241031]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Andrea-della-Porta/dt-bindings-clock-Add-RaspberryPi-RP1-clock-bindings/20241028-221122 base: https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next patch link: https://lore.kernel.org/r/c20e3d6d87c71691b149cdeeafc94009953346b2.1730123575.git.andrea.porta%40suse.com patch subject: [PATCH v3 07/12] clk: rp1: Add support for clocks provided by RP1 config: hexagon-allmodconfig (https://download.01.org/0day-ci/archive/20241101/[email protected]/config) compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project 639a7ac648f1e50ccd2556e17d401c04f9cce625) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241101/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
In file included from drivers/clk/clk-rp1.c:9:
In file included from include/linux/regmap.h:20:
In file included from include/linux/iopoll.h:14:
In file included from include/linux/io.h:14:
In file included from arch/hexagon/include/asm/io.h:328:
include/asm-generic/io.h:548:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
548 | val = __raw_readb(PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:561:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
561 | val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu'
37 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
| ^
In file included from drivers/clk/clk-rp1.c:9:
In file included from include/linux/regmap.h:20:
In file included from include/linux/iopoll.h:14:
In file included from include/linux/io.h:14:
In file included from arch/hexagon/include/asm/io.h:328:
include/asm-generic/io.h:574:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
574 | val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu'
35 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
| ^
In file included from drivers/clk/clk-rp1.c:9:
In file included from include/linux/regmap.h:20:
In file included from include/linux/iopoll.h:14:
In file included from include/linux/io.h:14:
In file included from arch/hexagon/include/asm/io.h:328:
include/asm-generic/io.h:585:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
585 | __raw_writeb(value, PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:595:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
595 | __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:605:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
605 | __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
>> drivers/clk/clk-rp1.c:621:2: error: call to undeclared function 'FIELD_PREP'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
621 | FIELD_SET(prim, PLL_PRIM_DIV1_MASK, prim_div1);
| ^
drivers/clk/clk-rp1.c:399:12: note: expanded from macro 'FIELD_SET'
399 | (_reg) |= FIELD_PREP(mask, (_val)); \
| ^
drivers/clk/clk-rp1.c:622:2: error: call to undeclared function 'FIELD_PREP'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
622 | FIELD_SET(prim, PLL_PRIM_DIV2_MASK, prim_div2);
| ^
drivers/clk/clk-rp1.c:399:12: note: expanded from macro 'FIELD_SET'
399 | (_reg) |= FIELD_PREP(mask, (_val)); \
| ^
drivers/clk/clk-rp1.c:767:2: error: call to undeclared function 'FIELD_PREP'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
767 | FIELD_SET(sec, PLL_SEC_DIV_MASK, div);
| ^
drivers/clk/clk-rp1.c:399:12: note: expanded from macro 'FIELD_SET'
399 | (_reg) |= FIELD_PREP(mask, (_val)); \
| ^
drivers/clk/clk-rp1.c:948:3: error: call to undeclared function 'FIELD_PREP'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
948 | FIELD_SET(ctrl, CLK_CTRL_AUXSRC_MASK, index - data->num_std_parents);
| ^
drivers/clk/clk-rp1.c:399:12: note: expanded from macro 'FIELD_SET'
399 | (_reg) |= FIELD_PREP(mask, (_val)); \
| ^6 warnings and 4 errors generated.
Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for MODVERSIONS
Depends on [n]: MODULES [=y] && !COMPILE_TEST [=y]
Selected by [y]:
- RANDSTRUCT_FULL [=y] && (CC_HAS_RANDSTRUCT [=y] || GCC_PLUGINS [=n]) && MODULES [=y]
WARNING: unmet direct dependencies detected for GET_FREE_REGION
Depends on [n]: SPARSEMEM [=n]
Selected by [m]:
- RESOURCE_KUNIT_TEST [=m] && RUNTIME_TESTING_MENU [=y] && KUNIT [=m]
vim +/FIELD_PREP +621 drivers/clk/clk-rp1.c
607
608 static int rp1_pll_set_rate(struct clk_hw *hw,
609 unsigned long rate, unsigned long parent_rate)
610 {
611 struct rp1_clk_desc *pll = container_of(hw, struct rp1_clk_desc, hw);
612 struct rp1_clockman *clockman = pll->clockman;
613 const struct rp1_pll_data *data = pll->data;
614
615 u32 prim, prim_div1, prim_div2;
616
617 get_pll_prim_dividers(rate, parent_rate, &prim_div1, &prim_div2);
618
619 spin_lock(&clockman->regs_lock);
620 prim = clockman_read(clockman, data->ctrl_reg);
> 621 FIELD_SET(prim, PLL_PRIM_DIV1_MASK, prim_div1);
622 FIELD_SET(prim, PLL_PRIM_DIV2_MASK, prim_div2);
623 clockman_write(clockman, data->ctrl_reg, prim);
624 spin_unlock(&clockman->regs_lock);
625
626 return 0;
627 }
628
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Andrea della Porta
maintainerPATCH v3 8/12 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 | 801 ++++++++++++++++++++++++++++++++++ 4 files changed, 814 insertions(+) create mode 100644 drivers/pinctrl/pinctrl-rp1.c
MAINTAINERS +1 -0
@@ -19388,6 +19388,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
@@ -587,6 +587,17 @@ config PINCTRL_MLXBF3 each pin. This driver can also be built as a module called pinctrl-mlxbf3. +config PINCTRL_RP1 + bool "Pinctrl driver for RP1" + select PINMUX + select PINCONF + select GENERIC_PINCONF + select GPIOLIB + select GPIOLIB_IRQCHIP + 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
@@ -47,6 +47,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 +801 -0
801 lines not on this page · raw message
Signature · 1 line
2.35.3
Re: [PATCH v3 08/12] pinctrl: rp1: Implement RaspberryPi RP1 gpio support
Quoted 6 lines · Andrea della Porta
The 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.
Signed-off-by Andrea della Porta <[email protected]>
This looks good to me.
Can this patch and the GPIO/pinctrl bindings simply be applied to the pinctrl tree once the bindings are finalized?
Yours,
Linus Walleij
Re: [PATCH v3 08/12] pinctrl: rp1: Implement RaspberryPi RP1 gpio support
In reply to Andrea della Portadrivers/pinctrl/Kconfig config PINCTRL_MLXBF3 · line 596
Quoted 7 lines · Andrea della Porta
drivers/pinctrl/Kconfig +7
-0+config PINCTRL_RP1 + bool "Pinctrl driver for RP1" + select PINMUX + select PINCONF + select GENERIC_PINCONF + select GPIOLIB + select GPIOLIB_IRQCHIP
Just a quick thing:
You don't happen to want:
depends on MISC_RP1
default MISC_RP1
So it will always come in tandem withMISC_RP1?
Yours,
Linus Walleij
Andrea della Porta
maintainerRe: [PATCH v3 08/12] pinctrl: rp1: Implement RaspberryPi RP1 gpio support
Hi Linus,
Quoted 11 lines · Linus Walleij
drivers/pinctrl/Kconfig config PINCTRL_MLXBF3 · line 596
Quoted 7 lines · Andrea della Porta
drivers/pinctrl/Kconfig +7
-0+config PINCTRL_RP1 + bool "Pinctrl driver for RP1" + select PINMUX + select PINCONF + select GENERIC_PINCONF + select GPIOLIB + select GPIOLIB_IRQCHIP
Quoted 8 lines
Just a quick thing:
You don't happen to want:
depends onMISC_RP1
defaultMISC_RP1So it will always come in tandem with
MISC_RP1?
You're right! Added.
However I will postpone the "default MISC_RP1" line after checking why the pinctrl driver does not work when compiled as a module (right now it's bool, not tristate).
Many thanks,
Andrea
Quoted 3 lines
Yours,
Linus Walleij
Andrea della Porta
maintainerPATCH v3 9/12 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 v3 10/12] misc: rp1: RaspberryPi RP1 misc driver", since they are closely related in terms of compiling.
MAINTAINERS | 1 + arch/arm64/boot/dts/broadcom/rp1.dtso | 61 +++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 arch/arm64/boot/dts/broadcom/rp1.dtso
MAINTAINERS +1 -0
@@ -19383,6 +19383,7 @@ F: include/uapi/linux/media/raspberrypi/ 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 +61 -0
61 lines not on this page · raw message
Signature · 1 line
2.35.3
Re: [PATCH v3 09/12] arm64: dts: rp1: Add support for RaspberryPi's RP1 device
Hi Andrea,
Quoted 60 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]>---
NOTE: this patch should be taken by the same maintainer that will take "[PATCH v3 10/12] misc: rp1: RaspberryPi RP1 misc driver", since they are closely related in terms of compiling.MAINTAINERS | 1 + arch/arm64/boot/dts/broadcom/rp1.dtso | 61 +++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 arch/arm64/boot/dts/broadcom/rp1.dtsoMAINTAINERS +1
-0@@ -19383,6 +19383,7 @@ F: include/uapi/linux/media/raspberrypi/ 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.yamlarch/arm64/boot/dts/broadcom/rp1.dtso new file +23
-0@@ -0,0 +1,61 @@ +// SPDX-License-Identifier: (GPL-2.0 OR MIT) + +#include <dt-bindings/gpio/gpio.h> +#include <dt-bindings/interrupt-controller/irq.h> +#include <dt-bindings/clock/raspberrypi,rp1-clocks.h> + +/dts-v1/; +/plugin/; + +/ { + fragment@0 { + target-path=""; + __overlay__ { + compatible = "pci1de4,1"; + #address-cells = <3>; + #size-cells = <2>; + interrupt-controller; + #interrupt-cells = <2>; + + pci_ep_bus: pci-ep-bus@1 { + compatible = "simple-bus"; + ranges = <0xc0 0x40000000 + 0x01 0x00 0x00000000
arch/arm64/boot/dts/broadcom/rp1.dtso line 33
Quoted 10 lines
arch/arm64/boot/dts/broadcom/rp1.dtso new file +10
-0+ 0x00 0x00400000>; + dma-ranges = <0x10 0x00000000 + 0x43000000 0x10 0x00000000 + 0x10 0x00000000>; + #address-cells = <2>; + #size-cells = <2>; + + rp1_clocks: clocks@c040018000 { + compatible = "raspberrypi,rp1-clocks"; + reg = <0xc0 0x40018000 0x0 0x10038>;
shouldn't this be:
rp1_clocks: clocks@18000 {
reg = <0x00 0x00018000 0x0 0x10038>;
...
}?
And for other nodes too...
~Stan
Quoted 28 lines
arch/arm64/boot/dts/broadcom/rp1.dtso new file +28
-0+ #clock-cells = <1>; + clocks = <&clk_rp1_xosc>; + clock-names = "xosc"; + assigned-clocks = <&rp1_clocks RP1_PLL_SYS_CORE>, + <&rp1_clocks RP1_PLL_SYS>, + <&rp1_clocks RP1_CLK_SYS>; + assigned-clock-rates = <1000000000>, // RP1_PLL_SYS_CORE + <200000000>, // RP1_PLL_SYS + <200000000>; // RP1_CLK_SYS + }; + + rp1_gpio: pinctrl@c0400d0000 { + compatible = "raspberrypi,rp1-gpio"; + reg = <0xc0 0x400d0000 0x0 0xc000>, + <0xc0 0x400e0000 0x0 0xc000>, + <0xc0 0x400f0000 0x0 0xc000>; + 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>; + }; + }; + }; + }; +};
Andrea della Porta
maintainerRe: [PATCH v3 09/12] arm64: dts: rp1: Add support for RaspberryPi's RP1 device
Hi Stan,
Quoted 76 lines · Stanimir Varbanov
Hi Andrea,
Quoted 60 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]>---
NOTE: this patch should be taken by the same maintainer that will take "[PATCH v3 10/12] misc: rp1: RaspberryPi RP1 misc driver", since they are closely related in terms of compiling.MAINTAINERS | 1 + arch/arm64/boot/dts/broadcom/rp1.dtso | 61 +++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 arch/arm64/boot/dts/broadcom/rp1.dtsoMAINTAINERS +1
-0@@ -19383,6 +19383,7 @@ F: include/uapi/linux/media/raspberrypi/ 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.yamlarch/arm64/boot/dts/broadcom/rp1.dtso new file +23
-0@@ -0,0 +1,61 @@ +// SPDX-License-Identifier: (GPL-2.0 OR MIT) + +#include <dt-bindings/gpio/gpio.h> +#include <dt-bindings/interrupt-controller/irq.h> +#include <dt-bindings/clock/raspberrypi,rp1-clocks.h> + +/dts-v1/; +/plugin/; + +/ { + fragment@0 { + target-path=""; + __overlay__ { + compatible = "pci1de4,1"; + #address-cells = <3>; + #size-cells = <2>; + interrupt-controller; + #interrupt-cells = <2>; + + pci_ep_bus: pci-ep-bus@1 { + compatible = "simple-bus"; + ranges = <0xc0 0x40000000 + 0x01 0x00 0x00000000arch/arm64/boot/dts/broadcom/rp1.dtso line 33
Quoted 10 lines
arch/arm64/boot/dts/broadcom/rp1.dtso new file +10
-0+ 0x00 0x00400000>; + dma-ranges = <0x10 0x00000000 + 0x43000000 0x10 0x00000000 + 0x10 0x00000000>; + #address-cells = <2>; + #size-cells = <2>; + + rp1_clocks: clocks@c040018000 { + compatible = "raspberrypi,rp1-clocks"; + reg = <0xc0 0x40018000 0x0 0x10038>;shouldn't this be:
Quoted 8 lines
rp1_clocks: clocks@18000 { reg = <0x00 0x00018000 0x0 0x10038>; ... }?
And for other nodes too...
For that to be @18000 instead of @c040018000, you should also change the "ranges" entry in pci-ep-bus node, as follows:
ranges = <0x00 0x00018000 //This was: 0xc0 0x40000000
0x01 0x00 0x00000000
0x00 0x00400000>;which is of course feasible, but I prefer to use addresses that resemble (at least to some extent) the ones in RP1 docs.
Many thanks,
Andrea
Quoted 32 lines
~Stan
Quoted 28 lines
arch/arm64/boot/dts/broadcom/rp1.dtso new file +28
-0+ #clock-cells = <1>; + clocks = <&clk_rp1_xosc>; + clock-names = "xosc"; + assigned-clocks = <&rp1_clocks RP1_PLL_SYS_CORE>, + <&rp1_clocks RP1_PLL_SYS>, + <&rp1_clocks RP1_CLK_SYS>; + assigned-clock-rates = <1000000000>, // RP1_PLL_SYS_CORE + <200000000>, // RP1_PLL_SYS + <200000000>; // RP1_CLK_SYS + }; + + rp1_gpio: pinctrl@c0400d0000 { + compatible = "raspberrypi,rp1-gpio"; + reg = <0xc0 0x400d0000 0x0 0xc000>, + <0xc0 0x400e0000 0x0 0xc000>, + <0xc0 0x400f0000 0x0 0xc000>; + 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>; + }; + }; + }; + }; +};
Andrea della Porta
maintainerRe: [PATCH v3 09/12] arm64: dts: rp1: Add support for RaspberryPi's RP1 device
Hi Stan,
Quoted 5 lines · Andrea della Porta
Hi Stan,
Quoted 2 lines · Stanimir Varbanov
Hi Andrea,
...
Quoted 15 lines
Quoted 10 lines
shouldn't this be:
rp1_clocks: clocks@18000 { reg = <0x00 0x00018000 0x0 0x10038>; ... }?
And for other nodes too...
For that to be @18000 instead of @c040018000, you should also change the "ranges" entry in pci-ep-bus node, as follows:
ranges = <
0x000x00018000//This was:0xc00x40000000
Quoted 8 lines
0x01 0x00 0x00000000 0x00 0x00400000>;which is of course feasible, but I prefer to use addresses that resemble (at least to some extent) the ones in RP1 docs.
Many thanks,
Andrea
Sorry, this should be like this
ranges = <0x00 0x00000000 //This was: 0xc0 0x40000000
0x01 0x00 0x00000000
0x00 0x00400000>;i.e. the child address in the range should be 0 and not 0x18000. Anyway you got the point: in theory we can replace that address with whatever placeholder we want and from a functional perspective, it will work, as long as you change all the relevant mappings. After some brainstorming we've decided to choose a simpler scheme that will resemble more the internal address described in the RP1 reference manual. 0xC040000000 will become 0x40000000.
Many thanks,
Andrea
...
Andrea della Porta
maintainerPATCH v3 10/12 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.
Since the gpio line names should be provided by the user, there is an interface through configfs that allows the userspace to load a DT overlay that will provide gpio-line-names property. The interface can be invoked like this:
cat rpi-rp1-gpios-5-b.dtbo > /sys/kernel/config/rp1-cfg/gpio_set_names
and is designed to be similar to what users are already used to from distro with downstream kernel.
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 | 357 ++++++++++++++++++++++++++++++++++ drivers/misc/rp1/rp1_pci.h | 14 ++ drivers/pci/quirks.c | 1 + include/linux/pci_ids.h | 3 + 10 files changed, 410 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
@@ -19389,6 +19389,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
@@ -628,4 +628,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
@@ -72,3 +72,4 @@ obj-$(CONFIG_TPS6594_PFSM) += tps6594-pfsm.o obj-$(CONFIG_NSM) += nsm.o obj-$(CONFIG_MARVELL_CN10K_DPI) += mrvl_cn10k_dpi.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 +357 -0
357 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
@@ -6266,6 +6266,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0xa76e, dpc_log_size);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_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
@@ -2611,6 +2611,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
Re: [PATCH v3 10/12] misc: rp1: RaspberryPi RP1 misc driver
Quoted 235 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.
Since the gpio line names should be provided by the user, there is an interface through configfs that allows the userspace to load a DT overlay that will provide gpio-line-names property. The interface can be invoked like this:
cat rpi-rp1-gpios-5-b.dtbo >
/sys/kernel/config/rp1-cfg/gpio_set_namesand is designed to be similar to what users are already used to from distro with downstream kernel.
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.
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 | 357 ++++++++++++++++++++++++++++++++++ drivers/misc/rp1/rp1_pci.h | 14 ++ drivers/pci/quirks.c | 1 + include/linux/pci_ids.h | 3 + 10 files changed, 410 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@@ -19389,6 +19389,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@@ -628,4 +628,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@@ -72,3 +72,4 @@ obj-$(CONFIG_TPS6594_PFSM) += tps6594-pfsm.o obj-$(CONFIG_NSM) += nsm.o obj-$(CONFIG_MARVELL_CN10K_DPI) += mrvl_cn10k_dpi.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 +90
-0@@ -0,0 +1,357 @@ +// 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> +#include <linux/of_platform.h> +#include <linux/pci.h> +#include <linux/platform_device.h> + +#include "rp1_pci.h" + +#define RP1_DRIVER_NAME "rp1" + +#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_IO_BANK0 0 +#define RP1_INT_IO_BANK1 1 +#define RP1_INT_IO_BANK2 2 +#define RP1_INT_AUDIO_IN 3 +#define RP1_INT_AUDIO_OUT 4 +#define RP1_INT_PWM0 5 +#define RP1_INT_ETH 6 +#define RP1_INT_I2C0 7 +#define RP1_INT_I2C1 8 +#define RP1_INT_I2C2 9 +#define RP1_INT_I2C3 10 +#define RP1_INT_I2C4 11 +#define RP1_INT_I2C5 12 +#define RP1_INT_I2C6 13 +#define RP1_INT_I2S0 14 +#define RP1_INT_I2S1 15 +#define RP1_INT_I2S2 16 +#define RP1_INT_SDIO0 17 +#define RP1_INT_SDIO1 18 +#define RP1_INT_SPI0 19 +#define RP1_INT_SPI1 20 +#define RP1_INT_SPI2 21 +#define RP1_INT_SPI3 22 +#define RP1_INT_SPI4 23 +#define RP1_INT_SPI5 24 +#define RP1_INT_UART0 25 +#define RP1_INT_TIMER_0 26 +#define RP1_INT_TIMER_1 27 +#define RP1_INT_TIMER_2 28 +#define RP1_INT_TIMER_3 29 +#define RP1_INT_USBHOST0 30 +#define RP1_INT_USBHOST0_0 31 +#define RP1_INT_USBHOST0_1 32 +#define RP1_INT_USBHOST0_2 33 +#define RP1_INT_USBHOST0_3 34 +#define RP1_INT_USBHOST1 35 +#define RP1_INT_USBHOST1_0 36 +#define RP1_INT_USBHOST1_1 37 +#define RP1_INT_USBHOST1_2 38 +#define RP1_INT_USBHOST1_3 39 +#define RP1_INT_DMA 40 +#define RP1_INT_PWM1 41 +#define RP1_INT_UART1 42 +#define RP1_INT_UART2 43 +#define RP1_INT_UART3 44 +#define RP1_INT_UART4 45 +#define RP1_INT_UART5 46 +#define RP1_INT_MIPI0 47 +#define RP1_INT_MIPI1 48 +#define RP1_INT_VIDEO_OUT 49 +#define RP1_INT_PIO_0 50 +#define RP1_INT_PIO_1 51 +#define RP1_INT_ADC_FIFO 52
drivers/misc/rp1/rp1_pci.c line 100
Quoted 10 lines
drivers/misc/rp1/rp1_pci.c new file +10
-0+#define RP1_INT_PCIE_OUT 53 +#define RP1_INT_SPI6 54 +#define RP1_INT_SPI7 55 +#define RP1_INT_SPI8 56 +#define RP1_INT_SYSCFG 58 +#define RP1_INT_CLOCKS_DEFAULT 59 +#define RP1_INT_VBUSCTRL 60 +#define RP1_INT_PROC_MISC 57 +#define RP1_INT_END 61 +
How those interrupts are supposed to be used by rp1-pci.dtso (or from rp1.dtso)?
include/dt-bindings/interrupt-controller/raspberrypi,rp1-interrupts.h ?
Quoted 50 lines
drivers/misc/rp1/rp1_pci.c new file +50
-0+struct rp1_dev { +struct pci_dev *pdev; +struct device *dev; +struct irq_domain *domain; +struct irq_data *pcie_irqds[64 ]; +void __iomem *bar1; +int ovcs_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)); +} + +static void msix_cfg_clr (struct rp1_dev *rp1,unsigned int hwirq,u32 value) +{ +iowrite32 (value, rp1->bar1 +RP1_PCIE_APBS_BASE +REG_CLR +MSIX_CFG (hwirq)); +} + +static void rp1_mask_irq (struct irq_data *irqd) +{ +struct rp1_dev *rp1 = irqd->domain->host_data; +struct irq_data *pcie_irqd = rp1->pcie_irqds[irqd->hwirq]; + +pci_msi_mask_irq (pcie_irqd); +} + +static void rp1_unmask_irq (struct irq_data *irqd) +{ +struct rp1_dev *rp1 = irqd->domain->host_data; +struct irq_data *pcie_irqd = rp1->pcie_irqds[irqd->hwirq]; + +pci_msi_unmask_irq (pcie_irqd); +} + +static int rp1_irq_set_type (struct irq_data *irqd,unsigned int type) +{ +struct rp1_dev *rp1 = irqd->domain->host_data; +unsigned int hwirq = (unsigned int )irqd->hwirq; + +switch (type) { +case IRQ_TYPE_LEVEL_HIGH : +dev_dbg (rp1->dev,"MSIX IACK EN for irq %d\n" , hwirq); +msix_cfg_set (rp1, hwirq,MSIX_CFG_IACK_EN ); + rp1->level_triggered_irq[hwirq] = true; +break ; +case IRQ_TYPE_EDGE_RISING : +msix_cfg_clr (rp1, hwirq,MSIX_CFG_IACK_EN ); + rp1->level_triggered_irq[hwirq] = false;
drivers/misc/rp1/rp1_pci.c line 160
Quoted 10 lines
drivers/misc/rp1/rp1_pci.c new file +10
-0+break ; +default : +return -EINVAL ; + } + +return 0 ; +} + +static struct irq_chip rp1_irq_chip = { + .name ="rp1_irq_chip" ,
tabs instead of spaces here and below.
drivers/misc/rp1/rp1_pci.c line 171
Quoted 11 lines
drivers/misc/rp1/rp1_pci.c new file +11
-0+ .irq_mask = rp1_mask_irq, + .irq_unmask = rp1_unmask_irq, + .irq_set_type = rp1_irq_set_type, +}; + +static void rp1_chained_handle_irq (struct irq_desc *desc) +{ +unsigned int hwirq = desc->irq_data.hwirq &RP1_HW_IRQ_MASK ; +struct rp1_dev *rp1 =irq_desc_get_handler_data (desc); +struct irq_chip *chip =irq_desc_get_chip (desc); +int virq;
unsigned int
Quoted 56 lines
drivers/misc/rp1/rp1_pci.c new file +56
-0+ +chained_irq_enter (chip, desc); + + virq =irq_find_mapping (rp1->domain, hwirq); +generic_handle_irq (virq); +if (rp1->level_triggered_irq[hwirq]) +msix_cfg_set (rp1, hwirq,MSIX_CFG_IACK ); + +chained_irq_exit (chip, desc); +} + +static int rp1_irq_xlate (struct irq_domain *d,struct device_node *node, +const u32 *intspec,unsigned int intsize, +unsigned long *out_hwirq,unsigned int *out_type) +{ +struct rp1_dev *rp1 = d->host_data; +struct irq_data *pcie_irqd; +unsigned long hwirq; +int pcie_irq; +int ret; + + ret =irq_domain_xlate_twocell (d, node, intspec, intsize, + &hwirq, out_type); +if (ret) +return ret; + + pcie_irq =pci_irq_vector (rp1->pdev, hwirq); + pcie_irqd =irq_get_irq_data (pcie_irq); + rp1->pcie_irqds[hwirq] = pcie_irqd; + *out_hwirq = hwirq; + +return 0 ; +} + +static int rp1_irq_activate (struct irq_domain *d,struct irq_data *irqd, +bool reserve) +{ +struct rp1_dev *rp1 = d->host_data; + +msix_cfg_set (rp1, (unsigned int )irqd->hwirq,MSIX_CFG_ENABLE ); + +return 0 ; +} + +static void rp1_irq_deactivate (struct irq_domain *d,struct irq_data *irqd) +{ +struct rp1_dev *rp1 = d->host_data; + +msix_cfg_clr (rp1, (unsigned int )irqd->hwirq,MSIX_CFG_ENABLE ); +} + +static const struct irq_domain_ops rp1_domain_ops = { + .xlate = rp1_irq_xlate, + .activate = rp1_irq_activate, + .deactivate = rp1_irq_deactivate, +};
drivers/misc/rp1/rp1_pci.c line 237
Quoted 10 lines
drivers/misc/rp1/rp1_pci.c new file +10
-0+ +static void rp1_unregister_interrupts (struct pci_dev *pdev) +{ +struct rp1_dev *rp1 =pci_get_drvdata (pdev); +int irq, i; + +for (i =0 ; i <RP1_INT_END ; i++) { + irq =irq_find_mapping (rp1->domain, i); +irq_dispose_mapping (irq); + }
new line
Quoted 16 lines
drivers/misc/rp1/rp1_pci.c new file +16
-0+irq_domain_remove (rp1->domain); +pci_free_irq_vectors (pdev); +} + +static int rp1_probe (struct pci_dev *pdev,const struct pci_device_id *id) +{ +u32 dtbo_size = __dtbo_rp1_pci_end - __dtbo_rp1_pci_begin; +void *dtbo_start = __dtbo_rp1_pci_begin; +struct device *dev = &pdev->dev; +struct device_node *rp1_node; +struct rp1_dev *rp1; +int err =0 ; +int i; + + rp1_node =dev_of_node (dev); +if (!rp1_node) {
drivers/misc/rp1/rp1_pci.c line 263
Quoted 10 lines
drivers/misc/rp1/rp1_pci.c new file +10
-0+dev_err (dev,"Missing of_node for device\n" ); +return -EINVAL ; + } + + rp1 =devm_kzalloc (&pdev->dev,sizeof (*rp1),GFP_KERNEL ); +if (!rp1) +return -ENOMEM ; + + rp1->pdev = pdev; + rp1->dev = &pdev->dev;
rp1->dev is used only once in dev_dbg macro. You could drop it and extract struct device from rp1->pdev.
drivers/misc/rp1/rp1_pci.c line 267
Quoted 4 lines
drivers/misc/rp1/rp1_pci.c new file +4
-0+ +if (pci_resource_len (pdev,1 ) <=0x10000 ) { +dev_err (&pdev->dev, +"Not initialised - is the firmware running?\n" );
no need of a new line
drivers/misc/rp1/rp1_pci.c line 274
Quoted 7 lines
drivers/misc/rp1/rp1_pci.c new file +7
-0+return -EINVAL ; + } + + err =pcim_enable_device (pdev); +if (err <0 ) { +dev_err (&pdev->dev,"Enabling PCI device has failed: %d" , + err);
ditto
drivers/misc/rp1/rp1_pci.c line 287
Quoted 13 lines
drivers/misc/rp1/rp1_pci.c new file +13
-0+return err; + } + + rp1->bar1 =pcim_iomap (pdev,1 ,0 ); +if (!rp1->bar1) { +dev_err (&pdev->dev,"Cannot map PCI BAR\n" ); +return -EIO ; + } + +pci_set_master (pdev); + + err =pci_alloc_irq_vectors (pdev,RP1_INT_END ,RP1_INT_END , +PCI_IRQ_MSIX );
ditto
drivers/misc/rp1/rp1_pci.c line 288
Quoted 1 line
drivers/misc/rp1/rp1_pci.c new file +1
-0+if (err !=RP1_INT_END ) {
an 'err' could be smaller then RP1_INT_END but still positive, thus .probe will return positive error code.
drivers/misc/rp1/rp1_pci.c line 295
Quoted 7 lines
drivers/misc/rp1/rp1_pci.c new file +7
-0+dev_err (&pdev->dev,"pci_alloc_irq_vectors failed - %d\n" , err); +return err; + } + +pci_set_drvdata (pdev, rp1); + rp1->domain =irq_domain_add_linear (rp1_node,RP1_INT_END , + &rp1_domain_ops, rp1);
irq_domain_add_linear() could fail, check for error ...
drivers/misc/rp1/rp1_pci.c line 298
Quoted 3 lines
drivers/misc/rp1/rp1_pci.c new file +3
-0+ +for (i =0 ; i <RP1_INT_END ; i++) { +int irq =irq_create_mapping (rp1->domain, i);
irq_create_mapping() returns 'unsigned int', maybe something like this:
unsigned int irq = irq_create_mapping(rp1->domain, i);
if (!irq) {
err = -EINVAL; (or -ENOMEM)
...
}drivers/misc/rp1/rp1_pci.c line 303
Quoted 5 lines
drivers/misc/rp1/rp1_pci.c new file +5
-0+ +if (irq <0 ) { +dev_err (&pdev->dev,"failed to create irq mapping\n" ); + err = irq; + goto err_unload_overlay;
goto err_unregister_interrupts; ?
drivers/misc/rp1/rp1_pci.c line 304
Quoted 1 line
drivers/misc/rp1/rp1_pci.c new file +1
-0+ }
new line, please
Quoted 61 lines
drivers/misc/rp1/rp1_pci.c new file +53
-0+irq_set_chip_and_handler (irq, &rp1_irq_chip, handle_level_irq); +irq_set_probe (irq); +irq_set_chained_handler_and_data (pci_irq_vector (pdev, i), + rp1_chained_handle_irq, rp1); + } + + err =of_overlay_fdt_apply (dtbo_start, dtbo_size, &rp1->ovcs_id, rp1_node); +if (err) + goto err_unregister_interrupts; + + err =of_platform_default_populate (rp1_node,NULL , dev); +if (err) + goto err_unload_overlay; + +return 0 ; + +err_unload_overlay: +of_overlay_remove (&rp1->ovcs_id); +err_unregister_interrupts: +rp1_unregister_interrupts (pdev); + +return err; +} + +static void rp1_remove (struct pci_dev *pdev) +{ +struct rp1_dev *rp1 =pci_get_drvdata (pdev); +struct device *dev = &pdev->dev; + +of_platform_depopulate (dev); +of_overlay_remove (&rp1->ovcs_id); +rp1_unregister_interrupts (pdev); +} + +static const struct pci_device_id dev_id_table[] = { + {PCI_DEVICE (PCI_VENDOR_ID_RPI ,PCI_DEVICE_ID_RPI_RP1_C0 ), }, + {0 , } +}; +MODULE_DEVICE_TABLE (pci, dev_id_table); + +static struct pci_driver rp1_driver = { + .name =RP1_DRIVER_NAME , + .id_table = dev_id_table, + .probe = rp1_probe, + .remove = rp1_remove, +}; + +module_pci_driver (rp1_driver); + +MODULE_AUTHOR ("Phil Elwell <[email protected]>" ); +MODULE_AUTHOR ("Andrea della Porta <[email protected]>" ); +MODULE_DESCRIPTION ("RP1 wrapper" ); +MODULE_LICENSE ("GPL" );drivers/misc/rp1/rp1_pci.h new file +2
-0@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +
drivers/misc/rp1/rp1_pci.h line 12
Quoted 10 lines
drivers/misc/rp1/rp1_pci.h new file +10
-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[];
Could you point me where those two variables are used outside of rp1_pci.c?
~Stan
Andrea della Porta
maintainerRe: [PATCH v3 10/12] misc: rp1: RaspberryPi RP1 misc driver
Hi Stan,
Quoted 241 lines · Stanimir Varbanov
Quoted 240 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.
Since the gpio line names should be provided by the user, there is an interface through configfs that allows the userspace to load a DT overlay that will provide gpio-line-names property. The interface can be invoked like this:
cat rpi-rp1-gpios-5-b.dtbo >
/sys/kernel/config/rp1-cfg/gpio_set_namesand is designed to be similar to what users are already used to from distro with downstream kernel.
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.
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 | 357 ++++++++++++++++++++++++++++++++++ drivers/misc/rp1/rp1_pci.h | 14 ++ drivers/pci/quirks.c | 1 + include/linux/pci_ids.h | 3 + 10 files changed, 410 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@@ -19389,6 +19389,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@@ -628,4 +628,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@@ -72,3 +72,4 @@ obj-$(CONFIG_TPS6594_PFSM) += tps6594-pfsm.o obj-$(CONFIG_NSM) += nsm.o obj-$(CONFIG_MARVELL_CN10K_DPI) += mrvl_cn10k_dpi.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 +95
-0@@ -0,0 +1,357 @@ +// 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> +#include <linux/of_platform.h> +#include <linux/pci.h> +#include <linux/platform_device.h> + +#include "rp1_pci.h" + +#define RP1_DRIVER_NAME "rp1" + +#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_IO_BANK0 0 +#define RP1_INT_IO_BANK1 1 +#define RP1_INT_IO_BANK2 2 +#define RP1_INT_AUDIO_IN 3 +#define RP1_INT_AUDIO_OUT 4 +#define RP1_INT_PWM0 5 +#define RP1_INT_ETH 6 +#define RP1_INT_I2C0 7 +#define RP1_INT_I2C1 8 +#define RP1_INT_I2C2 9 +#define RP1_INT_I2C3 10 +#define RP1_INT_I2C4 11 +#define RP1_INT_I2C5 12 +#define RP1_INT_I2C6 13 +#define RP1_INT_I2S0 14 +#define RP1_INT_I2S1 15 +#define RP1_INT_I2S2 16 +#define RP1_INT_SDIO0 17 +#define RP1_INT_SDIO1 18 +#define RP1_INT_SPI0 19 +#define RP1_INT_SPI1 20 +#define RP1_INT_SPI2 21 +#define RP1_INT_SPI3 22 +#define RP1_INT_SPI4 23 +#define RP1_INT_SPI5 24 +#define RP1_INT_UART0 25 +#define RP1_INT_TIMER_0 26 +#define RP1_INT_TIMER_1 27 +#define RP1_INT_TIMER_2 28 +#define RP1_INT_TIMER_3 29 +#define RP1_INT_USBHOST0 30 +#define RP1_INT_USBHOST0_0 31 +#define RP1_INT_USBHOST0_1 32 +#define RP1_INT_USBHOST0_2 33 +#define RP1_INT_USBHOST0_3 34 +#define RP1_INT_USBHOST1 35 +#define RP1_INT_USBHOST1_0 36 +#define RP1_INT_USBHOST1_1 37 +#define RP1_INT_USBHOST1_2 38 +#define RP1_INT_USBHOST1_3 39 +#define RP1_INT_DMA 40 +#define RP1_INT_PWM1 41 +#define RP1_INT_UART1 42 +#define RP1_INT_UART2 43 +#define RP1_INT_UART3 44 +#define RP1_INT_UART4 45 +#define RP1_INT_UART5 46 +#define RP1_INT_MIPI0 47 +#define RP1_INT_MIPI1 48 +#define RP1_INT_VIDEO_OUT 49 +#define RP1_INT_PIO_0 50 +#define RP1_INT_PIO_1 51 +#define RP1_INT_ADC_FIFO 52 +#define RP1_INT_PCIE_OUT 53 +#define RP1_INT_SPI6 54 +#define RP1_INT_SPI7 55 +#define RP1_INT_SPI8 56 +#define RP1_INT_SYSCFG 58
Quoted 8 lines
drivers/misc/rp1/rp1_pci.c line 100
Quoted 5 lines
drivers/misc/rp1/rp1_pci.c new file +5
-0+#define RP1_INT_CLOCKS_DEFAULT 59 +#define RP1_INT_VBUSCTRL 60 +#define RP1_INT_PROC_MISC 57 +#define RP1_INT_END 61 +How those interrupts are supposed to be used by rp1-pci.dtso (or from rp1.dtso)?
Unfortunately they will not. See below.
Quoted 2 lines
include/dt-bindings/interrupt-controller/raspberrypi,rp1-interrupts.h?
Please see:
https://lore.kernel.org/all/[email protected]/
Quoted 55 lines
Quoted 55 lines
drivers/misc/rp1/rp1_pci.c new file +54
-0+struct rp1_dev { +struct pci_dev *pdev; +struct device *dev; +struct irq_domain *domain; +struct irq_data *pcie_irqds[64 ]; +void __iomem *bar1; +int ovcs_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)); +} + +static void msix_cfg_clr (struct rp1_dev *rp1,unsigned int hwirq,u32 value) +{ +iowrite32 (value, rp1->bar1 +RP1_PCIE_APBS_BASE +REG_CLR +MSIX_CFG (hwirq)); +} + +static void rp1_mask_irq (struct irq_data *irqd) +{ +struct rp1_dev *rp1 = irqd->domain->host_data; +struct irq_data *pcie_irqd = rp1->pcie_irqds[irqd->hwirq]; + +pci_msi_mask_irq (pcie_irqd); +} + +static void rp1_unmask_irq (struct irq_data *irqd) +{ +struct rp1_dev *rp1 = irqd->domain->host_data; +struct irq_data *pcie_irqd = rp1->pcie_irqds[irqd->hwirq]; + +pci_msi_unmask_irq (pcie_irqd); +} + +static int rp1_irq_set_type (struct irq_data *irqd,unsigned int type) +{ +struct rp1_dev *rp1 = irqd->domain->host_data; +unsigned int hwirq = (unsigned int )irqd->hwirq; + +switch (type) { +case IRQ_TYPE_LEVEL_HIGH : +dev_dbg (rp1->dev,"MSIX IACK EN for irq %d\n" , hwirq); +msix_cfg_set (rp1, hwirq,MSIX_CFG_IACK_EN ); + rp1->level_triggered_irq[hwirq] = true; +break ; +case IRQ_TYPE_EDGE_RISING : +msix_cfg_clr (rp1, hwirq,MSIX_CFG_IACK_EN ); + rp1->level_triggered_irq[hwirq] = false; +break ; +default : +return -EINVAL ; + }
Quoted 8 lines
drivers/misc/rp1/rp1_pci.c line 160
Quoted 6 lines
drivers/misc/rp1/rp1_pci.c new file +6
-0+ +return 0 ; +} + +static struct irq_chip rp1_irq_chip = { + .name ="rp1_irq_chip" ,tabs instead of spaces here and below.
Ack.
Quoted 14 lines
drivers/misc/rp1/rp1_pci.c line 171
Quoted 12 lines
drivers/misc/rp1/rp1_pci.c new file +11
-0+ .irq_mask = rp1_mask_irq, + .irq_unmask = rp1_unmask_irq, + .irq_set_type = rp1_irq_set_type, +}; + +static void rp1_chained_handle_irq (struct irq_desc *desc) +{ +unsigned int hwirq = desc->irq_data.hwirq &RP1_HW_IRQ_MASK ; +struct rp1_dev *rp1 =irq_desc_get_handler_data (desc); +struct irq_chip *chip =irq_desc_get_chip (desc); +int virq;unsigned int
Ack.
Quoted 61 lines
Quoted 61 lines
drivers/misc/rp1/rp1_pci.c new file +60
-0+ +chained_irq_enter (chip, desc); + + virq =irq_find_mapping (rp1->domain, hwirq); +generic_handle_irq (virq); +if (rp1->level_triggered_irq[hwirq]) +msix_cfg_set (rp1, hwirq,MSIX_CFG_IACK ); + +chained_irq_exit (chip, desc); +} + +static int rp1_irq_xlate (struct irq_domain *d,struct device_node *node, +const u32 *intspec,unsigned int intsize, +unsigned long *out_hwirq,unsigned int *out_type) +{ +struct rp1_dev *rp1 = d->host_data; +struct irq_data *pcie_irqd; +unsigned long hwirq; +int pcie_irq; +int ret; + + ret =irq_domain_xlate_twocell (d, node, intspec, intsize, + &hwirq, out_type); +if (ret) +return ret; + + pcie_irq =pci_irq_vector (rp1->pdev, hwirq); + pcie_irqd =irq_get_irq_data (pcie_irq); + rp1->pcie_irqds[hwirq] = pcie_irqd; + *out_hwirq = hwirq; + +return 0 ; +} + +static int rp1_irq_activate (struct irq_domain *d,struct irq_data *irqd, +bool reserve) +{ +struct rp1_dev *rp1 = d->host_data; + +msix_cfg_set (rp1, (unsigned int )irqd->hwirq,MSIX_CFG_ENABLE ); + +return 0 ; +} + +static void rp1_irq_deactivate (struct irq_domain *d,struct irq_data *irqd) +{ +struct rp1_dev *rp1 = d->host_data; + +msix_cfg_clr (rp1, (unsigned int )irqd->hwirq,MSIX_CFG_ENABLE ); +} + +static const struct irq_domain_ops rp1_domain_ops = { + .xlate = rp1_irq_xlate, + .activate = rp1_irq_activate, + .deactivate = rp1_irq_deactivate, +}; + +static void rp1_unregister_interrupts (struct pci_dev *pdev) +{ +struct rp1_dev *rp1 =pci_get_drvdata (pdev);
Quoted 8 lines
drivers/misc/rp1/rp1_pci.c line 237
Quoted 6 lines
drivers/misc/rp1/rp1_pci.c new file +6
-0+int irq, i; + +for (i =0 ; i <RP1_INT_END ; i++) { + irq =irq_find_mapping (rp1->domain, i); +irq_dispose_mapping (irq); + }new line
Ack.
Quoted 22 lines
Quoted 22 lines
drivers/misc/rp1/rp1_pci.c new file +21
-0+irq_domain_remove (rp1->domain); +pci_free_irq_vectors (pdev); +} + +static int rp1_probe (struct pci_dev *pdev,const struct pci_device_id *id) +{ +u32 dtbo_size = __dtbo_rp1_pci_end - __dtbo_rp1_pci_begin; +void *dtbo_start = __dtbo_rp1_pci_begin; +struct device *dev = &pdev->dev; +struct device_node *rp1_node; +struct rp1_dev *rp1; +int err =0 ; +int i; + + rp1_node =dev_of_node (dev); +if (!rp1_node) { +dev_err (dev,"Missing of_node for device\n" ); +return -EINVAL ; + } + + rp1 =devm_kzalloc (&pdev->dev,sizeof (*rp1),GFP_KERNEL );
Quoted 8 lines
drivers/misc/rp1/rp1_pci.c line 263
Quoted 5 lines
drivers/misc/rp1/rp1_pci.c new file +5
-0+if (!rp1) +return -ENOMEM ; + + rp1->pdev = pdev; + rp1->dev = &pdev->dev;
rp1->devis used only once indev_dbgmacro. You could drop it and extract struct device fromrp1->pdev.
Good catch, thanks!
Quoted 7 lines
drivers/misc/rp1/rp1_pci.c line 267
Quoted 5 lines
drivers/misc/rp1/rp1_pci.c new file +4
-0+ +if (pci_resource_len (pdev,1 ) <=0x10000 ) { +dev_err (&pdev->dev, +"Not initialised - is the firmware running?\n" );no need of a new line
It goes past 80 columns, no?
Quoted 10 lines
drivers/misc/rp1/rp1_pci.c line 274
Quoted 8 lines
drivers/misc/rp1/rp1_pci.c new file +7
-0+return -EINVAL ; + } + + err =pcim_enable_device (pdev); +if (err <0 ) { +dev_err (&pdev->dev,"Enabling PCI device has failed: %d" , + err);ditto
Ditto.
Quoted 16 lines
Quoted 4 lines
drivers/misc/rp1/rp1_pci.c new file +3
-0+return err; + } +drivers/misc/rp1/rp1_pci.c line 287
Quoted 10 lines
drivers/misc/rp1/rp1_pci.c new file +10
-0+ rp1->bar1 =pcim_iomap (pdev,1 ,0 ); +if (!rp1->bar1) { +dev_err (&pdev->dev,"Cannot map PCI BAR\n" ); +return -EIO ; + } + +pci_set_master (pdev); + + err =pci_alloc_irq_vectors (pdev,RP1_INT_END ,RP1_INT_END , +PCI_IRQ_MSIX );ditto
Ditto.
Quoted 5 lines
drivers/misc/rp1/rp1_pci.c line 288
Quoted 2 lines
drivers/misc/rp1/rp1_pci.c new file +1
-0+if (err !=RP1_INT_END ) {an 'err' could be smaller then
RP1_INT_ENDbut still positive, thus .probe will return positive error code.
Ack.
Quoted 10 lines
drivers/misc/rp1/rp1_pci.c line 295
Quoted 8 lines
drivers/misc/rp1/rp1_pci.c new file +7
-0+dev_err (&pdev->dev,"pci_alloc_irq_vectors failed - %d\n" , err); +return err; + } + +pci_set_drvdata (pdev, rp1); + rp1->domain =irq_domain_add_linear (rp1_node,RP1_INT_END , + &rp1_domain_ops, rp1);
irq_domain_add_linear()could fail, check for error ...
Ack.
Quoted 7 lines
drivers/misc/rp1/rp1_pci.c line 298
Quoted 4 lines
drivers/misc/rp1/rp1_pci.c new file +3
-0+ +for (i =0 ; i <RP1_INT_END ; i++) { +int irq =irq_create_mapping (rp1->domain, i);
irq_create_mapping()returns 'unsigned int', maybe something like this:
Quoted 5 lines
unsigned int irq = irq_create_mapping(rp1->domain, i);
if (!irq) {
err = -EINVAL; (or -ENOMEM)
...
}Right, thanks.
Quoted 8 lines
drivers/misc/rp1/rp1_pci.c line 303
Quoted 6 lines
drivers/misc/rp1/rp1_pci.c new file +5
-0+ +if (irq <0 ) { +dev_err (&pdev->dev,"failed to create irq mapping\n" ); + err = irq; + goto err_unload_overlay;goto
err_unregister_interrupts; ?
Ack.
Quoted 4 lines
drivers/misc/rp1/rp1_pci.c line 304
Quoted 2 lines
drivers/misc/rp1/rp1_pci.c new file +1
-0+ }new line, please
Ack.
Quoted 66 lines
Quoted 66 lines
drivers/misc/rp1/rp1_pci.c new file +53
-0+irq_set_chip_and_handler (irq, &rp1_irq_chip, handle_level_irq); +irq_set_probe (irq); +irq_set_chained_handler_and_data (pci_irq_vector (pdev, i), + rp1_chained_handle_irq, rp1); + } + + err =of_overlay_fdt_apply (dtbo_start, dtbo_size, &rp1->ovcs_id, rp1_node); +if (err) + goto err_unregister_interrupts; + + err =of_platform_default_populate (rp1_node,NULL , dev); +if (err) + goto err_unload_overlay; + +return 0 ; + +err_unload_overlay: +of_overlay_remove (&rp1->ovcs_id); +err_unregister_interrupts: +rp1_unregister_interrupts (pdev); + +return err; +} + +static void rp1_remove (struct pci_dev *pdev) +{ +struct rp1_dev *rp1 =pci_get_drvdata (pdev); +struct device *dev = &pdev->dev; + +of_platform_depopulate (dev); +of_overlay_remove (&rp1->ovcs_id); +rp1_unregister_interrupts (pdev); +} + +static const struct pci_device_id dev_id_table[] = { + {PCI_DEVICE (PCI_VENDOR_ID_RPI ,PCI_DEVICE_ID_RPI_RP1_C0 ), }, + {0 , } +}; +MODULE_DEVICE_TABLE (pci, dev_id_table); + +static struct pci_driver rp1_driver = { + .name =RP1_DRIVER_NAME , + .id_table = dev_id_table, + .probe = rp1_probe, + .remove = rp1_remove, +}; + +module_pci_driver (rp1_driver); + +MODULE_AUTHOR ("Phil Elwell <[email protected]>" ); +MODULE_AUTHOR ("Andrea della Porta <[email protected]>" ); +MODULE_DESCRIPTION ("RP1 wrapper" ); +MODULE_LICENSE ("GPL" );drivers/misc/rp1/rp1_pci.h new file +6
-0@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/* +* Copyright (c) 2018-24 Raspberry Pi Ltd. +* All rights reserved. +*/
Quoted 8 lines
drivers/misc/rp1/rp1_pci.h line 12
Quoted 6 lines
drivers/misc/rp1/rp1_pci.h new file +6
-0+ +#ifndef _RP1_EXTERN_H_ +#define _RP1_EXTERN_H_ + +extern char __dtbo_rp1_pci_begin[]; +extern char __dtbo_rp1_pci_end[];Could you point me where those two variables are used outside of
rp1_pci.c?
Nowhere else. For the rationale behind this please see:
https://lore.kernel.org/all/[email protected]/
and followups.
Many thanks,
Andrea
Quoted 3 lines
~Stan
Andrea della Porta
maintainerPATCH v3 11/12 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.dtsi | 7 +++++++ 1 file changed, 7 insertions(+)
arch/arm64/boot/dts/broadcom/bcm2712.dtsi +7 -0
@@ -38,6 +38,13 @@ clk_emmc2: clk-emmc2 { clock-frequency = <200000000>; clock-output-names = "emmc2-clock"; }; + + clk_rp1_xosc: clock-rp1-xosc { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-output-names = "rp1-xosc"; + clock-frequency = <50000000>; + }; }; cpus: cpus {
Signature · 1 line
2.35.3
Stephen Boyd
maintainerRe: [PATCH v3 11/12] arm64: dts: bcm2712: Add external clock for RP1 chipset on Rpi5
Quoting Andrea della Porta (2024-10-28 07:07:28)
arch/arm64/boot/dts/broadcom/bcm2712.dtsi clk_emmc2: clk-emmc2 { · line 42
Quoted 10 lines
arch/arm64/boot/dts/broadcom/bcm2712.dtsi +2
-0@@ -38,6 +38,13 @@ clk_emmc2: clk-emmc2 { clock-frequency = <200000000>; clock-output-names = "emmc2-clock"; }; + + clk_rp1_xosc: clock-rp1-xosc {
The node name is preferred to be clock-50000000 now.
Andrea della Porta
maintainerRe: [PATCH v3 11/12] arm64: dts: bcm2712: Add external clock for RP1 chipset on Rpi5
Hi Stephen,
Quoted 13 lines · Stephen Boyd
Quoting Andrea della Porta (2024-10-28 07:07:28)
arch/arm64/boot/dts/broadcom/bcm2712.dtsi clk_emmc2: clk-emmc2 { · line 42
Quoted 10 lines
arch/arm64/boot/dts/broadcom/bcm2712.dtsi +2
-0@@ -38,6 +38,13 @@ clk_emmc2: clk-emmc2 { clock-frequency = <200000000>; clock-output-names = "emmc2-clock"; }; + + clk_rp1_xosc: clock-rp1-xosc {The node name is preferred to be clock-50000000 now.
Ack.
Many thanks,
Andrea
Andrea della Porta
maintainerPATCH v3 12/12 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=y CONFIG_PINCTRL_SA8775P=y CONFIG_PINCTRL_SC7180=y CONFIG_PINCTRL_SC7280=y
@@ -689,6 +690,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
@@ -1270,6 +1272,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