Redo PolarFire SoC's mailbox/clock devicestrees and related code
Subsystems (10)
Conor Dooley
maintainercover Redo PolarFire SoC's mailbox/clock devicestrees and related code
From: Conor Dooley <[email protected]>
Yo,
Here's something that I've been mulling over for a while, since I started to understand how devicetree stuff was "meant" to be done. There'd been little reason to actually press forward with it, because it is fairly disruptive. I've finally opted to do it, because a user has come along with a hwmon driver that needs to access the same register region as the mailbox and the author is not keen on using the aux bus, and because I do not want the new pic64gx SoC that's based on PolarFire SoC to use bindings etc that I know to be incorrect.
Given backwards compatibility needs to be maintained, this patch series isn't the prettiest thing I have ever written. The reset driver needs to retain support for the auxiliary bus, which looks a bit mess, but not much can be done there. The mailbox and clock drivers both have to have an "old probe" function to handle the old layout. Thankfully in the clock driver, the Meson clk-regmap support can be used to identically handle both old and new devicetree formats - but using a regmap in the mailbox driver was only really possible for the new format, so the code there is unfortunately a bit of an if/else mess that I'm both not proud of, nor really sure is worth "improving".
The series should be pretty splitable per subsystem, only the dts change has some sort of dependency, but I'll not be applying that till everything else is in Linus' tree, so that's not a big deal.
I've got all the Meson clock folks on CC, given I am moving their clk-regmap implementation to common code. There were one or two things I didn't really like about the implementation, but it is better than the Qualcomm one IMO and creating a third copy of clk-regmap is certainly not an improvement on having two copies!
I don't really want this stuff in stable, hence a lack of cc: stable anywhere here, since what's currently in the tree works fine for the currently supported hardware.
AFAIK, the only other project affected here is U-Boot - I've got some WIP work that I need to rebase and send for it before the dts patches here will be applied:
https://github.com/ConchuOD/u-boot/commits/syscon-clocks/
I previously submitted this as an RFC, only to Lee and the dt list, in order to get some feedback on the syscon/mfd bindings:
https://lore.kernel.org/all/20240815-shindig-bunny-fd42792d638a@spud/
I'm not really going to bother with a proper changelog, since that was submitted with lots of WIP code to get answers to some questions. The main change was "removing" some of the child nodes of the syscons.
Cheers,
Conor.
Conor Dooley (11):
dt-bindings: mailbox: mpfs: fix reg properties
mailbox: mpfs: support new, syscon based, devicetree configuration
dt-bindings: mfd: syscon document the non simple-mfd syscon on
PolarFire SoC
dt-bindings: soc: microchip: document the two simple-mfd syscons on
PolarFire SoC
soc: microchip: add mfd drivers for two syscon regions on PolarFire
SoC
reset: mpfs: add non-auxiliary bus probing
dt-bindings: clk: microchip: mpfs: remove first reg region
clk: move meson clk-regmap implementation to common code
clk: microchip: mpfs: use regmap clock types
riscv: dts: microchip: fix mailbox description
riscv: dts: microchip: convert clock and reset to use syscon
.../bindings/clock/microchip,mpfs-clkcfg.yaml | 36 +++---
.../mailbox/microchip,mpfs-mailbox.yaml | 13 +-
.../devicetree/bindings/mfd/syscon.yaml | 2 +
.../microchip/microchip,mpfs-control-scb.yaml | 44 +++++++
.../microchip,mpfs-mss-top-sysreg.yaml | 54 +++++++++
arch/riscv/boot/dts/microchip/mpfs.dtsi | 34 ++++--
drivers/clk/Kconfig | 4 +
drivers/clk/Makefile | 1 +
drivers/clk/{meson => }/clk-regmap.c | 2 +-
drivers/clk/meson/Kconfig | 46 ++++---
drivers/clk/meson/Makefile | 1 -
drivers/clk/meson/a1-peripherals.c | 2 +-
drivers/clk/meson/a1-pll.c | 2 +-
drivers/clk/meson/axg-aoclk.c | 2 +-
drivers/clk/meson/axg-audio.c | 2 +-
drivers/clk/meson/axg.c | 2 +-
drivers/clk/meson/c3-peripherals.c | 2 +-
drivers/clk/meson/c3-pll.c | 2 +-
drivers/clk/meson/clk-cpu-dyndiv.c | 2 +-
drivers/clk/meson/clk-dualdiv.c | 2 +-
drivers/clk/meson/clk-mpll.c | 2 +-
drivers/clk/meson/clk-phase.c | 2 +-
drivers/clk/meson/clk-pll.c | 2 +-
drivers/clk/meson/g12a-aoclk.c | 2 +-
drivers/clk/meson/g12a.c | 2 +-
drivers/clk/meson/gxbb-aoclk.c | 2 +-
drivers/clk/meson/gxbb.c | 2 +-
drivers/clk/meson/meson-aoclk.h | 2 +-
drivers/clk/meson/meson-eeclk.c | 2 +-
drivers/clk/meson/meson-eeclk.h | 2 +-
drivers/clk/meson/meson8-ddr.c | 2 +-
drivers/clk/meson/meson8b.c | 2 +-
drivers/clk/meson/s4-peripherals.c | 2 +-
drivers/clk/meson/s4-pll.c | 2 +-
drivers/clk/meson/sclk-div.c | 2 +-
drivers/clk/meson/vclk.h | 2 +-
drivers/clk/meson/vid-pll-div.c | 2 +-
drivers/clk/microchip/Kconfig | 3 +
drivers/clk/microchip/clk-mpfs.c | 114 +++++++++++++-----
drivers/mailbox/Kconfig | 1 +
drivers/mailbox/mailbox-mpfs.c | 87 ++++++++++---
drivers/reset/reset-mpfs.c | 83 +++++++++++--
drivers/soc/microchip/Kconfig | 13 ++
drivers/soc/microchip/Makefile | 1 +
drivers/soc/microchip/mpfs-control-scb.c | 45 +++++++
drivers/soc/microchip/mpfs-mss-top-sysreg.c | 48 ++++++++
.../meson => include/linux/clk}/clk-regmap.h | 0
47 files changed, 541 insertions(+), 143 deletions(-)
create mode 100644 Documentation/devicetree/bindings/soc/microchip/microchip,mpfs-control-scb.yaml
create mode 100644 Documentation/devicetree/bindings/soc/microchip/microchip,mpfs-mss-top-sysreg.yaml
rename drivers/clk/{meson => }/clk-regmap.c (99%)
create mode 100644 drivers/soc/microchip/mpfs-control-scb.c
create mode 100644 drivers/soc/microchip/mpfs-mss-top-sysreg.c
rename {drivers/clk/meson => include/linux/clk}/clk-regmap.h (100%)Signature · 1 line
2.45.2
Conor Dooley
maintainerPATCH 1/11 dt-bindings: mailbox: mpfs: fix reg properties
From: Conor Dooley <[email protected]>
When the binding for this was originally written, and later modified, mistakes were made - and the precise nature of the later modification should have been a giveaway, but alas I was naive at the time.
A more correct modelling of the hardware is to use two syscons and have a single reg entry for the mailbox, containing the mailbox region. The two syscons contain the general control/status registers for the mailbox and the interrupt related registers respectively. The reason for two syscons is that the same mailbox is present on the non-SoC version of the FPGA, which has no interrupt controller, and the shared part of the rtl was unchanged between devices.
This is now coming to a head, because the control/status registers share a register region with the "tvs" (temperature & voltage sensors) registers and, as it turns out, people do want to monitor temperatures and voltages...
--- .../bindings/mailbox/microchip,mpfs-mailbox.yaml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
Documentation/devicetree/bindings/mailbox/microchip,mpfs-mailbox.yaml +8 -5
@@ -15,6 +15,8 @@ properties: reg: oneOf: + - items: + - description: mailbox data registers - items: - description: mailbox control & data registers - description: mailbox interrupt registers
@@ -23,6 +25,7 @@ properties: - description: mailbox control registers - description: mailbox interrupt registers - description: mailbox data registers + deprecated: true interrupts: maxItems: 1
@@ -41,12 +44,12 @@ additionalProperties: false examples: - | soc { - #address-cells = <2>; - #size-cells = <2>; - mbox: mailbox@37020000 { + #address-cells = <1>; + #size-cells = <1>; + + mailbox@37020800 { compatible = "microchip,mpfs-mailbox"; - reg = <0x0 0x37020000 0x0 0x58>, <0x0 0x2000318C 0x0 0x40>, - <0x0 0x37020800 0x0 0x100>; + reg = <0x37020800 0x100>; interrupt-parent = <&L1>; interrupts = <96>; #mbox-cells = <1>;
Signature · 1 line
2.45.2
Re: [PATCH v1 01/11] dt-bindings: mailbox: mpfs: fix reg properties
Quoted 19 lines · Conor Dooley
From: Conor Dooley <[email protected]>
When the binding for this was originally written, and later modified, mistakes were made - and the precise nature of the later modification should have been a giveaway, but alas I was naive at the time.
A more correct modelling of the hardware is to use two syscons and have a single reg entry for the mailbox, containing the mailbox region. The two syscons contain the general control/status registers for the mailbox and the interrupt related registers respectively. The reason for two syscons is that the same mailbox is present on the non-SoC version of the FPGA, which has no interrupt controller, and the shared part of the rtl was unchanged between devices.
This is now coming to a head, because the control/status registers share a register region with the "tvs" (temperature & voltage sensors) registers and, as it turns out, people do want to monitor temperatures and voltages...
Quoted 5 lines
Signed-off-by Conor Dooley <[email protected]>--- .../bindings/mailbox/microchip,mpfs-mailbox.yaml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
Conor Dooley
maintainerPATCH 2/11 mailbox: mpfs: support new, syscon based, devicetree configuration
In reply to Conor DooleyFrom: Conor Dooley <[email protected]>
The two previous bindings for this hardware were incorrect, as the control/status and interrupt register regions should have been described as syscons and dealt with via regmap in the driver. Add support for accessing these registers using that method now, so that the hwmon driver can be supported without using auxdev or hacks with io_remap().
--- drivers/mailbox/Kconfig | 1 + drivers/mailbox/mailbox-mpfs.c | 87 +++++++++++++++++++++++++++------- 2 files changed, 71 insertions(+), 17 deletions(-)
drivers/mailbox/Kconfig +1 -0
@@ -168,6 +168,7 @@ config MAILBOX_TEST config POLARFIRE_SOC_MAILBOX tristate "PolarFire SoC (MPFS) Mailbox" depends on HAS_IOMEM + depends on MFD_SYSCON depends on ARCH_MICROCHIP_POLARFIRE || COMPILE_TEST help This driver adds support for the PolarFire SoC (MPFS) mailbox controller.
drivers/mailbox/mailbox-mpfs.c +70 -17
144 lines not on this page · raw message
Signature · 1 line
2.45.2
Conor Dooley
maintainerPATCH 3/11 dt-bindings: mfd: syscon document the non simple-mfd syscon on PolarFire SoC
In reply to Conor DooleyFrom: Conor Dooley <[email protected]>
The "mss_top_scb" register region on PolarFire SoC contains many different functions, including controls for the AXI bus and other things mainly of interest to the bootloader. The interrupt register for the system controller's mailbox is also in here, which is needed by the operating system.
--- Documentation/devicetree/bindings/mfd/syscon.yaml | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/mfd/syscon.yaml +2 -0
@@ -88,6 +88,7 @@ select: - mediatek,mt8173-pctl-a-syscfg - mediatek,mt8365-syscfg - microchip,lan966x-cpu-syscon + - microchip,mpfs-sysreg-scb - microchip,sam9x60-sfr - microchip,sama7g5-ddr3phy - mscc,ocelot-cpu-syscon
@@ -185,6 +186,7 @@ properties: - mediatek,mt8173-pctl-a-syscfg - mediatek,mt8365-syscfg - microchip,lan966x-cpu-syscon + - microchip,mpfs-sysreg-scb - microchip,sam9x60-sfr - microchip,sama7g5-ddr3phy - mscc,ocelot-cpu-syscon
Signature · 1 line
2.45.2
Re: [PATCH v1 03/11] dt-bindings: mfd: syscon document the non simple-mfd syscon on PolarFire SoC
Quoted 8 lines · Conor Dooley
From: Conor Dooley <[email protected]>
The "
mss_top_scb" register region on PolarFire SoC contains many different functions, including controls for the AXI bus and other things mainly of interest to the bootloader. The interrupt register for the system controller's mailbox is also in here, which is needed by the operating system.
Quoted 5 lines
Signed-off-by Conor Dooley <[email protected]>--- Documentation/devicetree/bindings/mfd/syscon.yaml | 2 ++ 1 file changed, 2 insertions(+)
Re: (subset) [PATCH v1 03/11] dt-bindings: mfd: syscon document the non simple-mfd syscon on PolarFire SoC
In reply to Conor DooleyQuoted 8 lines · Conor Dooley
The "
mss_top_scb" register region on PolarFire SoC contains many different functions, including controls for the AXI bus and other things mainly of interest to the bootloader. The interrupt register for the system controller's mailbox is also in here, which is needed by the operating system.[...]
Applied, thanks!
[03/11] dt-bindings: mfd: syscon document the non simple-mfd syscon on PolarFire SoC
commit: 8ae16d3b2ff6650a90be78881cb88dcdf1bd1370
--
Lee Jones [李琼斯]
Conor Dooley
maintainerPATCH 4/11 dt-bindings: soc: microchip: document the two simple-mfd syscons on PolarFire SoC
In reply to Conor DooleyFrom: Conor Dooley <[email protected]>
There are two syscons on PolarFire SoC that provide various functionality of use to the OS.
The first of these is the "control-scb" region, that contains the "tvs" temperature and voltage sensors and the control/status registers for the system controller's mailbox. The mailbox has a dedicated node, so there's no need for a child node describing it, looking the syscon up by compatible is sufficient.
The second, "mss-top-sysreg", contains clocks, pinctrl, resets, and interrupt controller and more. At this point, only the reset controller child is described as that's all that is described by the existing bindings. The clock controller already has a dedicated node, and will retain it as there are other clock regions, so like the mailbox, a compatible-based lookup of the syscon is sufficient to keep the clock driver working as before so no child is needed. There's also an interrupt multiplexing service provided by this syscon, for which there is work in progress at [1].
--- .../microchip/microchip,mpfs-control-scb.yaml | 44 +++++++++++++++ .../microchip,mpfs-mss-top-sysreg.yaml | 54 +++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/microchip/microchip,mpfs-control-scb.yaml create mode 100644 Documentation/devicetree/bindings/soc/microchip/microchip,mpfs-mss-top-sysreg.yaml
Documentation/devicetree/bindings/soc/microchip/microchip,mpfs-control-scb.yaml new file +44 -0
@@ -0,0 +1,44 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/soc/microchip/microchip,mpfs-control-scb.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Microchip PolarFire SoC System Controller Bus (SCB) Control Register region + +maintainers: + - Conor Dooley <[email protected]> + +description: + An assortment of system controller related registers, including voltage and + temperature sensors and the status/control registers for the system + controller's mailbox. + +properties: + compatible: + items: + - const: microchip,mpfs-control-scb + - const: syscon + - const: simple-mfd + + reg: + maxItems: 1 + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + soc { + #address-cells = <1>; + #size-cells = <1>; + + syscon@37020000 { + compatible = "microchip,mpfs-control-scb", "syscon", "simple-mfd"; + reg = <0x37020000 0x100>; + }; + }; +
Documentation/devicetree/bindings/soc/microchip/microchip,mpfs-mss-top-sysreg.yaml new file +54 -0
54 lines not on this page · raw message
Signature · 1 line
2.45.2
Rob Herring
maintainerRe: [PATCH v1 04/11] dt-bindings: soc: microchip: document the two simple-mfd syscons on PolarFire SoC
Quoted 48 lines · Conor Dooley
From: Conor Dooley <[email protected]>
There are two syscons on PolarFire SoC that provide various functionality of use to the OS.
The first of these is the "control-scb" region, that contains the "tvs" temperature and voltage sensors and the control/status registers for the system controller's mailbox. The mailbox has a dedicated node, so there's no need for a child node describing it, looking the syscon up by compatible is sufficient.
The second, "mss-top-sysreg", contains clocks, pinctrl, resets, and interrupt controller and more. At this point, only the reset controller child is described as that's all that is described by the existing bindings. The clock controller already has a dedicated node, and will retain it as there are other clock regions, so like the mailbox, a compatible-based lookup of the syscon is sufficient to keep the clock driver working as before so no child is needed. There's also an interrupt multiplexing service provided by this syscon, for which there is work in progress at [1].
Link https://lore.kernel.org/linux-gpio/20240723-uncouple-enforcer-7c48e4a4fefe@wendy/ [1] open hereSigned-off-by Conor Dooley <[email protected]>--- .../microchip/microchip,mpfs-control-scb.yaml | 44 +++++++++++++++ .../microchip,mpfs-mss-top-sysreg.yaml | 54 +++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/microchip/microchip,mpfs-control-scb.yaml create mode 100644 Documentation/devicetree/bindings/soc/microchip/microchip,mpfs-mss-top-sysreg.yamlDocumentation/devicetree/bindings/soc/microchip/microchip,mpfs-control-scb.yaml new file +12
-0@@ -0,0 +1,44 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/soc/microchip/microchip,mpfs-control-scb.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Microchip PolarFire SoC System Controller Bus (SCB) Control Register region + +maintainers: + - Conor Dooley <[email protected]> + +description:
Documentation/devicetree/bindings/soc/microchip/microchip,mpfs-control-scb.yaml line 22
Quoted 10 lines
Documentation/devicetree/bindings/soc/microchip/microchip,mpfs-control-scb.yaml new file +10
-0+ An assortment of system controller related registers, including voltage and + temperature sensors and the status/control registers for the system + controller's mailbox. + +properties: + compatible: + items: + - const: microchip,mpfs-control-scb + - const: syscon + - const: simple-mfd
Where's the child nodes?
Quoted 5 lines
Documentation/devicetree/bindings/soc/microchip/microchip,mpfs-control-scb.yaml new file +5
-0+ + reg: + maxItems: 1 + +required:
Documentation/devicetree/bindings/soc/microchip/microchip,mpfs-control-scb.yaml line 37
Quoted 10 lines
Documentation/devicetree/bindings/soc/microchip/microchip,mpfs-control-scb.yaml new file +10
-0+ - compatible + - reg + +additionalProperties: false + +examples: + - | + soc { + #address-cells = <1>; + #size-cells = <1>;
Don't need the soc node.
Quoted 30 lines
Documentation/devicetree/bindings/soc/microchip/microchip,mpfs-control-scb.yaml new file +7
-0+ + syscon@37020000 { + compatible = "microchip,mpfs-control-scb", "syscon", "simple-mfd"; + reg = <0x37020000 0x100>; + }; + }; +Documentation/devicetree/bindings/soc/microchip/microchip,mpfs-mss-top-sysreg.yaml new file +17
-0@@ -0,0 +1,54 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/soc/microchip/microchip,mpfs-mss-top-sysreg.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Microchip PolarFire SoC Microprocessor Subsystem (MSS) sysreg Register region + +maintainers: + - Conor Dooley <[email protected]> + +description: + An wide assortment of registers that control elements of the MSS on PolarFire + SoC, including pinmuxing, resets and clocks among others. + +properties: + compatible:
Documentation/devicetree/bindings/soc/microchip/microchip,mpfs-mss-top-sysreg.yaml line 27
Quoted 10 lines
Documentation/devicetree/bindings/soc/microchip/microchip,mpfs-mss-top-sysreg.yaml new file +10
-0+ items: + - const: microchip,mpfs-mss-top-sysreg + - const: syscon + - const: simple-mfd + + reg: + maxItems: 1 + + '#reset-cells': + description: |
Don't need '|'.
Quoted 30 lines
Documentation/devicetree/bindings/soc/microchip/microchip,mpfs-mss-top-sysreg.yaml new file +27
-0+ The AHB/AXI peripherals on the PolarFire SoC have reset support, so + from CLK_ENVM to CLK_CFM. The reset consumer should specify the + desired peripheral via the clock ID in its "resets" phandle cell. + See include/dt-bindings/clock/microchip,mpfs-clock.h for the full list + of PolarFire clock/reset IDs. + const: 1 + +required: + - compatible + - reg + - '#reset-cells' + +additionalProperties: false + +examples: + - | + soc { + #address-cells = <1>; + #size-cells = <1>; + + syscon@20002000 { + compatible = "microchip,mpfs-mss-top-sysreg", "syscon", "simple-mfd"; + reg = <0x20002000 0x1000>; + #reset-cells = <1>; + }; + }; +Signature · 1 line
2.45.2
Conor Dooley
maintainerPATCH 5/11 soc: microchip: add mfd drivers for two syscon regions on PolarFire SoC
In reply to Conor DooleyFrom: Conor Dooley <[email protected]>
The control-scb and mss-top-sysreg regions on PolarFire SoC both fulfill multiple purposes. The former is used for mailbox functions in addition to the temperature & voltage sensor while the latter is used for clocks, resets, interrupt muxing and pinctrl.
--- drivers/soc/microchip/Kconfig | 13 ++++++ drivers/soc/microchip/Makefile | 1 + drivers/soc/microchip/mpfs-control-scb.c | 45 +++++++++++++++++++ drivers/soc/microchip/mpfs-mss-top-sysreg.c | 48 +++++++++++++++++++++ 4 files changed, 107 insertions(+) create mode 100644 drivers/soc/microchip/mpfs-control-scb.c create mode 100644 drivers/soc/microchip/mpfs-mss-top-sysreg.c
drivers/soc/microchip/Kconfig +13 -0
@@ -9,3 +9,16 @@ config POLARFIRE_SOC_SYS_CTRL module will be called mpfs_system_controller. If unsure, say N. + +config POLARFIRE_SOC_SYSCONS + bool "PolarFire SoC (MPFS) syscon drivers" + default y + depends on ARCH_MICROCHIP + select MFD_CORE + help + These drivers add support for the syscons on PolarFire SoC (MPFS). + Without these drivers core parts of the kernel such as clocks + and resets will not function correctly. + + If unsure, and on a PolarFire SoC, say y. +
drivers/soc/microchip/Makefile +1 -0
@@ -1 +1,2 @@ obj-$(CONFIG_POLARFIRE_SOC_SYS_CTRL) += mpfs-sys-controller.o +obj-$(CONFIG_POLARFIRE_SOC_SYSCONS) += mpfs-control-scb.o mpfs-mss-top-sysreg.o
drivers/soc/microchip/mpfs-control-scb.c new file +45 -0
45 lines not on this page · raw message
drivers/soc/microchip/mpfs-mss-top-sysreg.c new file +48 -0
48 lines not on this page · raw message
Signature · 1 line
2.45.2
Conor Dooley
maintainerPATCH 6/11 reset: mpfs: add non-auxiliary bus probing
In reply to Conor DooleyFrom: Conor Dooley <[email protected]>
While the auxiliary bus was a nice bandaid, and meant that re-writing the representation of the clock regions in devicetree was not required, it has run its course. The "mss_top_sysreg" region that contains the clock and reset regions, also contains pinctrl and an interrupt controller, so the time has come rewrite the devicetree and probe the reset controller from an mfd devicetree node, rather than implement those drivers using the auxiliary bus. Wanting to avoid propagating this naive/incorrect description of the hardware to the new pic64gx SoC is a major motivating factor here.
--- drivers/reset/reset-mpfs.c | 83 ++++++++++++++++++++++++++++++++------ 1 file changed, 71 insertions(+), 12 deletions(-)
drivers/reset/reset-mpfs.c +71 -12
@@ -9,10 +9,12 @@#include <linux/auxiliary_bus.h> #include <linux/delay.h> #include <linux/io.h> +#include <linux/mfd/syscon.h> #include <linux/module.h> #include <linux/of.h> #include <linux/platform_device.h> #include <linux/slab.h> +#include <linux/regmap.h> #include <linux/reset-controller.h> #include <dt-bindings/clock/microchip,mpfs-clock.h> #include <soc/microchip/mpfs.h>
@@ -27,14 +29,37 @@#define MPFS_SLEEP_MIN_US 100#define MPFS_SLEEP_MAX_US 200 +#define REG_SUBBLK_RESET_CR 0x88u +/* block concurrent access to the soft reset register */ static DEFINE_SPINLOCK (mpfs_reset_lock);struct mpfs_reset {void __iomem *base; +struct regmap *regmap;struct reset_controller_dev rcdev; }; +static inline u32 mpfs_reset_read (struct mpfs_reset *rst) +{ +u32 ret; + +if (rst->regmap) +regmap_read (rst->regmap,REG_SUBBLK_RESET_CR , &ret); +else + ret =readl (rst->base); + +return ret; +} + +static inline void mpfs_reset_write (struct mpfs_reset *rst,u32 val) +{ +if (rst->regmap) +regmap_write (rst->regmap,REG_SUBBLK_RESET_CR , val); +else +writel (val, rst->base); +} +static inline struct mpfs_reset *to_mpfs_reset (struct reset_controller_dev *rcdev) { return container_of(rcdev, struct mpfs_reset, rcdev);
@@ -51,9 +76,9 @@ static int mpfs_assert(struct reset_controller_dev *rcdev, unsigned long id)spin_lock_irqsave (&mpfs_reset_lock, flags); - reg =readl (rst->base); + reg =mpfs_reset_read (rst); reg |=BIT (id); -writel (reg, rst->base); +mpfs_reset_write (rst, reg);spin_unlock_irqrestore (&mpfs_reset_lock, flags);
@@ -68,9 +93,9 @@ static int mpfs_deassert(struct reset_controller_dev *rcdev, unsigned long id)spin_lock_irqsave (&mpfs_reset_lock, flags); - reg =readl (rst->base); + reg =mpfs_reset_read (rst); reg &= ~BIT (id); -writel (reg, rst->base); +mpfs_reset_write (rst, reg);spin_unlock_irqrestore (&mpfs_reset_lock, flags);
@@ -80,7 +105,7 @@ static int mpfs_deassert(struct reset_controller_dev *rcdev, unsigned long id)static int mpfs_status (struct reset_controller_dev *rcdev,unsigned long id) {struct mpfs_reset *rst =to_mpfs_reset (rcdev); -u32 reg =readl (rst->base); +u32 reg =mpfs_reset_read (rst);/* * It is safe to return here as MPFS_NUM_RESETS makes sure the sign bit
@@ -130,11 +155,45 @@ static int mpfs_reset_xlate(struct reset_controller_dev *rcdev,return index -MPFS_PERIPH_OFFSET ; } -static int mpfs_reset_probe (struct auxiliary_device *adev, -const struct auxiliary_device_id *id) +static int mpfs_reset_mfd_probe (struct platform_device *pdev) { -struct device *dev = &adev->dev;struct reset_controller_dev *rcdev; +struct device *dev = &pdev->dev; +struct mpfs_reset *rst; + + rst =devm_kzalloc (dev,sizeof (*rst),GFP_KERNEL ); +if (!rst) +return -ENOMEM ; + + rcdev = &rst->rcdev; + rcdev->dev = dev; + rcdev->ops = &mpfs_reset_ops; + + rcdev->of_node = pdev->dev.parent->of_node; + rcdev->of_reset_n_cells =1 ; + rcdev->of_xlate = mpfs_reset_xlate; + rcdev->nr_resets =MPFS_NUM_RESETS ; + + rst->regmap =device_node_to_regmap (pdev->dev.parent->of_node); +if (IS_ERR (rst->regmap)) +dev_err_probe (dev,PTR_ERR (rst->regmap),"Failed to find syscon regmap\n" ); + +return devm_reset_controller_register (dev, rcdev); +} + +static struct platform_driver mpfs_reset_mfd_driver = { + .probe = mpfs_reset_mfd_probe, + .driver = { + .name ="mpfs-reset" , + }, +}; +module_platform_driver (mpfs_reset_mfd_driver); + +static int mpfs_reset_adev_probe (struct auxiliary_device *adev, +const struct auxiliary_device_id *id) +{ +struct reset_controller_dev *rcdev; +struct device *dev = &adev->dev;struct mpfs_reset *rst; rst =devm_kzalloc (dev,sizeof (*rst),GFP_KERNEL );
@@ -145,8 +204,8 @@ static int mpfs_reset_probe(struct auxiliary_device *adev, rcdev = &rst->rcdev; rcdev->dev = dev; - rcdev->dev->parent = dev->parent; rcdev->ops = &mpfs_reset_ops; + rcdev->of_node = dev->parent->of_node; rcdev->of_reset_n_cells =1 ; rcdev->of_xlate = mpfs_reset_xlate;
@@ -222,12 +281,12 @@ static const struct auxiliary_device_id mpfs_reset_ids[] = { };MODULE_DEVICE_TABLE (auxiliary, mpfs_reset_ids); -static struct auxiliary_driver mpfs_reset_driver = { - .probe = mpfs_reset_probe, +static struct auxiliary_driver mpfs_reset_aux_driver = { + .probe = mpfs_reset_adev_probe, .id_table = mpfs_reset_ids, }; -module_auxiliary_driver (mpfs_reset_driver); +module_auxiliary_driver (mpfs_reset_aux_driver);MODULE_DESCRIPTION ("Microchip PolarFire SoC Reset Driver" );MODULE_AUTHOR ("Conor Dooley <[email protected]>" );
Signature · 1 line
2.45.2
Philipp Zabel
maintainerRe: [PATCH v1 06/11] reset: mpfs: add non-auxiliary bus probing
Quoted 73 lines · Conor Dooley
From: Conor Dooley <[email protected]>
While the auxiliary bus was a nice bandaid, and meant that re-writing the representation of the clock regions in devicetree was not required, it has run its course. The "
mss_top_sysreg" region that contains the clock and reset regions, also contains pinctrl and an interrupt controller, so the time has come rewrite the devicetree and probe the reset controller from an mfd devicetree node, rather than implement those drivers using the auxiliary bus. Wanting to avoid propagating this naive/incorrect description of the hardware to the new pic64gx SoC is a major motivating factor here.Signed-off-by Conor Dooley <[email protected]>--- drivers/reset/reset-mpfs.c | 83 ++++++++++++++++++++++++++++++++------ 1 file changed, 71 insertions(+), 12 deletions(-)drivers/reset/reset-mpfs.c +25
-0@@ -9,10 +9,12 @@#include <linux/auxiliary_bus.h> #include <linux/delay.h> #include <linux/io.h> +#include <linux/mfd/syscon.h> #include <linux/module.h> #include <linux/of.h> #include <linux/platform_device.h> #include <linux/slab.h> +#include <linux/regmap.h> #include <linux/reset-controller.h> #include <dt-bindings/clock/microchip,mpfs-clock.h> #include <soc/microchip/mpfs.h> @@ -27,14 +29,37 @@#define MPFS_SLEEP_MIN_US 100#define MPFS_SLEEP_MAX_US 200 +#define REG_SUBBLK_RESET_CR 0x88u +/* block concurrent access to the soft reset register */ static DEFINE_SPINLOCK (mpfs_reset_lock);struct mpfs_reset {void __iomem *base; +struct regmap *regmap;struct reset_controller_dev rcdev; }; +static inline u32 mpfs_reset_read (struct mpfs_reset *rst) +{ +u32 ret; + +if (rst->regmap) +regmap_read (rst->regmap,REG_SUBBLK_RESET_CR , &ret); +else + ret =readl (rst->base); + +return ret; +} + +static inline void mpfs_reset_write (struct mpfs_reset *rst,u32 val) +{ +if (rst->regmap) +regmap_write (rst->regmap,REG_SUBBLK_RESET_CR , val); +else +writel (val, rst->base); +} +static inline struct mpfs_reset *to_mpfs_reset (struct reset_controller_dev *rcdev) { return container_of(rcdev, struct mpfs_reset, rcdev);
drivers/reset/reset-mpfs.c static int mpfs_assert(struct reset_controller_dev *rcdev, unsigned long id) · line 81
Quoted 8 lines
drivers/reset/reset-mpfs.c +2
-2@@ -51,9 +76,9 @@ static int mpfs_assert(struct reset_controller_dev *rcdev, unsigned long id)spin_lock_irqsave (&mpfs_reset_lock, flags); - reg =readl (rst->base); + reg =mpfs_reset_read (rst); reg |=BIT (id); -writel (reg, rst->base); +mpfs_reset_write (rst, reg);
This should use regmap_update_bits() in the regmap case, same in mpfs_deassert().
regards
Philipp
Conor Dooley
maintainerPATCH 7/11 dt-bindings: clk: microchip: mpfs: remove first reg region
In reply to Conor DooleyFrom: Conor Dooley <[email protected]>
The first reg region in this binding is not exclusively for clocks, as evidenced by the dual role of this device as a reset controller at present. The first region is however better described by a simple-mfd syscon, but this would have require a significant re-write of the devicetree for the platform, so the easy way out was chosen when reset support was first introduced. The region doesn't just contain clock and reset registers, it also contains pinctrl and interrupt controller functionality, so drop the region from the clock binding so that it can be described instead by a simple-mfd syscon rather than propagate this incorrect description of the hardware to the new pic64gx SoC.
--- .../bindings/clock/microchip,mpfs-clkcfg.yaml | 36 +++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-)
Documentation/devicetree/bindings/clock/microchip,mpfs-clkcfg.yaml +22 -14
@@ -22,16 +22,23 @@ properties: const: microchip,mpfs-clkcfg reg: - items: - - description: | - clock config registers: - These registers contain enable, reset & divider tables for the, cpu, - axi, ahb and rtc/mtimer reference clocks as well as enable and reset - for the peripheral clocks. - - description: | - mss pll dri registers: - Block of registers responsible for dynamic reconfiguration of the mss - pll + oneOf: + - items: + - description: | + clock config registers: + These registers contain enable, reset & divider tables for the, cpu, + axi, ahb and rtc/mtimer reference clocks as well as enable and reset + for the peripheral clocks. + - description: | + mss pll dri registers: + Block of registers responsible for dynamic reconfiguration of the mss + pll + deprecated: true + - items: + - description: | + mss pll dri registers: + Block of registers responsible for dynamic reconfiguration of the mss + pll clocks: maxItems: 1
@@ -69,11 +76,12 @@ examples: - | #include <dt-bindings/clock/microchip,mpfs-clock.h> soc { - #address-cells = <2>; - #size-cells = <2>; - clkcfg: clock-controller@20002000 { + #address-cells = <1>; + #size-cells = <1>; + + clkcfg: clock-controller@3E001000 { compatible = "microchip,mpfs-clkcfg"; - reg = <0x0 0x20002000 0x0 0x1000>, <0x0 0x3E001000 0x0 0x1000>; + reg = <0x3E001000 0x1000>; clocks = <&ref>; #clock-cells = <1>; };
Signature · 1 line
2.45.2
Re: [PATCH v1 07/11] dt-bindings: clk: microchip: mpfs: remove first reg region
Quoted 13 lines · Conor Dooley
From: Conor Dooley <[email protected]>
The first reg region in this binding is not exclusively for clocks, as evidenced by the dual role of this device as a reset controller at present. The first region is however better described by a simple-mfd syscon, but this would have require a significant re-write of the devicetree for the platform, so the easy way out was chosen when reset support was first introduced. The region doesn't just contain clock and reset registers, it also contains pinctrl and interrupt controller functionality, so drop the region from the clock binding so that it can be described instead by a simple-mfd syscon rather than propagate this incorrect description of the hardware to the new pic64gx SoC.
Quoted 5 lines
Signed-off-by Conor Dooley <[email protected]>--- .../bindings/clock/microchip,mpfs-clkcfg.yaml | 36 +++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-)
Conor Dooley
maintainerPATCH 8/11 clk: move meson clk-regmap implementation to common code
In reply to Conor DooleyFrom: Conor Dooley <[email protected]>
I like this one better than qualcomms and wish to use it for the PolarFire SoC clock drivers.
---
drivers/clk/Kconfig | 4 ++
drivers/clk/Makefile | 1 +
drivers/clk/{meson => }/clk-regmap.c | 2 +-
drivers/clk/meson/Kconfig | 46 +++++++++----------
drivers/clk/meson/Makefile | 1 -
drivers/clk/meson/a1-peripherals.c | 2 +-
drivers/clk/meson/a1-pll.c | 2 +-
drivers/clk/meson/axg-aoclk.c | 2 +-
drivers/clk/meson/axg-audio.c | 2 +-
drivers/clk/meson/axg.c | 2 +-
drivers/clk/meson/c3-peripherals.c | 2 +-
drivers/clk/meson/c3-pll.c | 2 +-
drivers/clk/meson/clk-cpu-dyndiv.c | 2 +-
drivers/clk/meson/clk-dualdiv.c | 2 +-
drivers/clk/meson/clk-mpll.c | 2 +-
drivers/clk/meson/clk-phase.c | 2 +-
drivers/clk/meson/clk-pll.c | 2 +-
drivers/clk/meson/g12a-aoclk.c | 2 +-
drivers/clk/meson/g12a.c | 2 +-
drivers/clk/meson/gxbb-aoclk.c | 2 +-
drivers/clk/meson/gxbb.c | 2 +-
drivers/clk/meson/meson-aoclk.h | 2 +-
drivers/clk/meson/meson-eeclk.c | 2 +-
drivers/clk/meson/meson-eeclk.h | 2 +-
drivers/clk/meson/meson8-ddr.c | 2 +-
drivers/clk/meson/meson8b.c | 2 +-
drivers/clk/meson/s4-peripherals.c | 2 +-
drivers/clk/meson/s4-pll.c | 2 +-
drivers/clk/meson/sclk-div.c | 2 +-
drivers/clk/meson/vclk.h | 2 +-
drivers/clk/meson/vid-pll-div.c | 2 +-
.../meson => include/linux/clk}/clk-regmap.h | 0
32 files changed, 53 insertions(+), 53 deletions(-)
rename drivers/clk/{meson => }/clk-regmap.c (99%)
rename {drivers/clk/meson => include/linux/clk}/clk-regmap.h (100%)drivers/clk/Kconfig +4 -0
@@ -33,6 +33,10 @@ menuconfig COMMON_CLK if COMMON_CLK +config COMMON_CLK_REGMAP + bool + select REGMAP + config COMMON_CLK_WM831X tristate "Clock driver for WM831x/2x PMICs" depends on MFD_WM831X
drivers/clk/Makefile +1 -0
@@ -14,6 +14,7 @@ obj-$(CONFIG_COMMON_CLK) += clk-gate.o obj-$(CONFIG_CLK_GATE_KUNIT_TEST) += clk-gate_test.o obj-$(CONFIG_COMMON_CLK) += clk-multiplier.o obj-$(CONFIG_COMMON_CLK) += clk-mux.o +obj-$(CONFIG_COMMON_CLK_REGMAP) += clk-regmap.o obj-$(CONFIG_COMMON_CLK) += clk-composite.o obj-$(CONFIG_COMMON_CLK) += clk-fractional-divider.o obj-$(CONFIG_CLK_FD_KUNIT_TEST) += clk-fractional-divider_test.o
drivers/clk/clk-regmap.c renamed from drivers/clk/meson/clk-regmap.c +1 -1
@@ -5,7 +5,7 @@*/ #include <linux/module.h> -#include "clk-regmap.h" +#include <linux/clk/clk-regmap.h> static int clk_regmap_gate_endisable (struct clk_hw *hw,int enable) {
drivers/clk/meson/Kconfig +21 -25
152 lines not on this page · raw message
drivers/clk/meson/Makefile +0 -1
@@ -9,7 +9,6 @@ obj-$(CONFIG_COMMON_CLK_MESON_EE_CLKC) += meson-eeclk.o obj-$(CONFIG_COMMON_CLK_MESON_MPLL) += clk-mpll.o obj-$(CONFIG_COMMON_CLK_MESON_PHASE) += clk-phase.o obj-$(CONFIG_COMMON_CLK_MESON_PLL) += clk-pll.o -obj-$(CONFIG_COMMON_CLK_MESON_REGMAP) += clk-regmap.o obj-$(CONFIG_COMMON_CLK_MESON_SCLK_DIV) += sclk-div.o obj-$(CONFIG_COMMON_CLK_MESON_VID_PLL_DIV) += vid-pll-div.o obj-$(CONFIG_COMMON_CLK_MESON_VCLK) += vclk.o
drivers/clk/meson/a1-peripherals.c +1 -1
@@ -12,7 +12,7 @@#include <linux/platform_device.h> #include "a1-peripherals.h" #include "clk-dualdiv.h" -#include "clk-regmap.h" +#include <linux/clk/clk-regmap.h> #include "meson-clkc-utils.h" #include <dt-bindings/clock/amlogic,a1-peripherals-clkc.h>
drivers/clk/meson/a1-pll.c +1 -1
@@ -11,7 +11,7 @@#include <linux/mod_devicetable.h> #include <linux/platform_device.h> #include "a1-pll.h" -#include "clk-regmap.h" +#include <linux/clk/clk-regmap.h> #include "meson-clkc-utils.h" #include <dt-bindings/clock/amlogic,a1-pll-clkc.h>
drivers/clk/meson/axg-aoclk.c +1 -1
@@ -15,7 +15,7 @@#include <linux/module.h> #include "meson-aoclk.h" -#include "clk-regmap.h" +#include <linux/clk/clk-regmap.h> #include "clk-dualdiv.h" #include <dt-bindings/clock/axg-aoclkc.h>
drivers/clk/meson/axg-audio.c +1 -1
@@ -17,7 +17,7 @@#include "meson-clkc-utils.h" #include "axg-audio.h" -#include "clk-regmap.h" +#include <linux/clk/clk-regmap.h> #include "clk-phase.h" #include "sclk-div.h"
drivers/clk/meson/axg.c +1 -1
@@ -15,7 +15,7 @@#include <linux/platform_device.h> #include <linux/module.h> -#include "clk-regmap.h" +#include <linux/clk/clk-regmap.h> #include "clk-pll.h" #include "clk-mpll.h" #include "axg.h"
drivers/clk/meson/c3-peripherals.c +1 -1
@@ -8,7 +8,7 @@#include <linux/clk-provider.h> #include <linux/platform_device.h> -#include "clk-regmap.h" +#include <linux/clk/clk-regmap.h> #include "clk-dualdiv.h" #include "meson-clkc-utils.h" #include <dt-bindings/clock/amlogic,c3-peripherals-clkc.h>
drivers/clk/meson/c3-pll.c +1 -1
@@ -8,7 +8,7 @@#include <linux/clk-provider.h> #include <linux/platform_device.h> -#include "clk-regmap.h" +#include <linux/clk/clk-regmap.h> #include "clk-pll.h" #include "meson-clkc-utils.h" #include <dt-bindings/clock/amlogic,c3-pll-clkc.h>
drivers/clk/meson/clk-cpu-dyndiv.c +1 -1
@@ -7,7 +7,7 @@#include <linux/clk-provider.h> #include <linux/module.h> -#include "clk-regmap.h" +#include <linux/clk/clk-regmap.h> #include "clk-cpu-dyndiv.h" static inline struct meson_clk_cpu_dyndiv_data *
drivers/clk/meson/clk-dualdiv.c +1 -1
@@ -24,7 +24,7 @@#include <linux/clk-provider.h> #include <linux/module.h> -#include "clk-regmap.h" +#include <linux/clk/clk-regmap.h> #include "clk-dualdiv.h" static inline struct meson_clk_dualdiv_data *
drivers/clk/meson/clk-mpll.c +1 -1
@@ -15,7 +15,7 @@#include <linux/module.h> #include <linux/spinlock.h> -#include "clk-regmap.h" +#include <linux/clk/clk-regmap.h> #include "clk-mpll.h" #define SDM_DEN 16384
drivers/clk/meson/clk-phase.c +1 -1
@@ -7,7 +7,7 @@#include <linux/clk-provider.h> #include <linux/module.h> -#include "clk-regmap.h" +#include <linux/clk/clk-regmap.h> #include "clk-phase.h" #define phase_step (_width) (360 / (1 << (_width)))
drivers/clk/meson/clk-pll.c +1 -1
@@ -33,7 +33,7 @@#include <linux/math64.h> #include <linux/module.h> -#include "clk-regmap.h" +#include <linux/clk/clk-regmap.h> #include "clk-pll.h" static inline struct meson_clk_pll_data *
drivers/clk/meson/g12a-aoclk.c +1 -1
@@ -15,7 +15,7 @@#include <linux/module.h> #include "meson-aoclk.h" -#include "clk-regmap.h" +#include <linux/clk/clk-regmap.h> #include "clk-dualdiv.h" #include <dt-bindings/clock/g12a-aoclkc.h>
drivers/clk/meson/g12a.c +1 -1
@@ -19,7 +19,7 @@#include "clk-mpll.h" #include "clk-pll.h" -#include "clk-regmap.h" +#include <linux/clk/clk-regmap.h> #include "clk-cpu-dyndiv.h" #include "vid-pll-div.h" #include "vclk.h"
drivers/clk/meson/gxbb-aoclk.c +1 -1
@@ -8,7 +8,7 @@#include <linux/module.h> #include "meson-aoclk.h" -#include "clk-regmap.h" +#include <linux/clk/clk-regmap.h> #include "clk-dualdiv.h" #include <dt-bindings/clock/gxbb-aoclkc.h>
drivers/clk/meson/gxbb.c +1 -1
@@ -11,7 +11,7 @@#include <linux/module.h> #include "gxbb.h" -#include "clk-regmap.h" +#include <linux/clk/clk-regmap.h> #include "clk-pll.h" #include "clk-mpll.h" #include "meson-eeclk.h"
drivers/clk/meson/meson-aoclk.h +1 -1
@@ -16,7 +16,7 @@#include <linux/regmap.h> #include <linux/reset-controller.h> -#include "clk-regmap.h" +#include <linux/clk/clk-regmap.h> #include "meson-clkc-utils.h" struct meson_aoclk_data {
drivers/clk/meson/meson-eeclk.c +1 -1
@@ -11,7 +11,7 @@#include <linux/regmap.h> #include <linux/module.h> -#include "clk-regmap.h" +#include <linux/clk/clk-regmap.h> #include "meson-eeclk.h" int meson_eeclkc_probe (struct platform_device *pdev)
drivers/clk/meson/meson-eeclk.h +1 -1
@@ -8,7 +8,7 @@#define __MESON_CLKC_H#include <linux/clk-provider.h> -#include "clk-regmap.h" +#include <linux/clk/clk-regmap.h> #include "meson-clkc-utils.h" struct platform_device ;
drivers/clk/meson/meson8-ddr.c +1 -1
@@ -10,7 +10,7 @@#include <linux/clk-provider.h> #include <linux/platform_device.h> -#include "clk-regmap.h" +#include <linux/clk/clk-regmap.h> #include "clk-pll.h" #define AM_DDR_PLL_CNTL 0x00
drivers/clk/meson/meson8b.c +1 -1
@@ -17,7 +17,7 @@#include <linux/regmap.h> #include "meson8b.h" -#include "clk-regmap.h" +#include <linux/clk/clk-regmap.h> #include "meson-clkc-utils.h" #include "clk-pll.h" #include "clk-mpll.h"
drivers/clk/meson/s4-peripherals.c +1 -1
@@ -10,7 +10,7 @@#include <linux/of_device.h> #include <linux/platform_device.h> -#include "clk-regmap.h" +#include <linux/clk/clk-regmap.h> #include "vid-pll-div.h" #include "clk-dualdiv.h" #include "s4-peripherals.h"
drivers/clk/meson/s4-pll.c +1 -1
@@ -12,7 +12,7 @@#include "clk-mpll.h" #include "clk-pll.h" -#include "clk-regmap.h" +#include <linux/clk/clk-regmap.h> #include "s4-pll.h" #include "meson-clkc-utils.h" #include <dt-bindings/clock/amlogic,s4-pll-clkc.h>
drivers/clk/meson/sclk-div.c +1 -1
@@ -19,7 +19,7 @@#include <linux/clk-provider.h> #include <linux/module.h> -#include "clk-regmap.h" +#include <linux/clk/clk-regmap.h> #include "sclk-div.h" static inline struct meson_sclk_div_data *
drivers/clk/meson/vclk.h +1 -1
@@ -6,7 +6,7 @@#ifndef __VCLK_H#define __VCLK_H -#include "clk-regmap.h" +#include <linux/clk/clk-regmap.h> #include "parm.h" /**
drivers/clk/meson/vid-pll-div.c +1 -1
@@ -7,7 +7,7 @@#include <linux/clk-provider.h> #include <linux/module.h> -#include "clk-regmap.h" +#include <linux/clk/clk-regmap.h> #include "vid-pll-div.h" static inline struct meson_vid_pll_div_data *
include/linux/clk/clk-regmap.h renamed from drivers/clk/meson/clk-regmap.h +0 -0
Signature · 1 line
2.45.2
Re: [PATCH v1 08/11] clk: move meson clk-regmap implementation to common code
Quoted 40 lines · Conor Dooley
From: Conor Dooley <[email protected]>
I like this one better than qualcomms and wish to use it for the PolarFire SoC clock drivers.
Signed-off-by Conor Dooley <[email protected]>--- drivers/clk/Kconfig | 4 ++ drivers/clk/Makefile | 1 + drivers/clk/{meson => }/clk-regmap.c | 2 +- drivers/clk/meson/Kconfig | 46 +++++++++---------- drivers/clk/meson/Makefile | 1 - drivers/clk/meson/a1-peripherals.c | 2 +- drivers/clk/meson/a1-pll.c | 2 +- drivers/clk/meson/axg-aoclk.c | 2 +- drivers/clk/meson/axg-audio.c | 2 +- drivers/clk/meson/axg.c | 2 +- drivers/clk/meson/c3-peripherals.c | 2 +- drivers/clk/meson/c3-pll.c | 2 +- drivers/clk/meson/clk-cpu-dyndiv.c | 2 +- drivers/clk/meson/clk-dualdiv.c | 2 +- drivers/clk/meson/clk-mpll.c | 2 +- drivers/clk/meson/clk-phase.c | 2 +- drivers/clk/meson/clk-pll.c | 2 +- drivers/clk/meson/g12a-aoclk.c | 2 +- drivers/clk/meson/g12a.c | 2 +- drivers/clk/meson/gxbb-aoclk.c | 2 +- drivers/clk/meson/gxbb.c | 2 +- drivers/clk/meson/meson-aoclk.h | 2 +- drivers/clk/meson/meson-eeclk.c | 2 +- drivers/clk/meson/meson-eeclk.h | 2 +- drivers/clk/meson/meson8-ddr.c | 2 +- drivers/clk/meson/meson8b.c | 2 +- drivers/clk/meson/s4-peripherals.c | 2 +- drivers/clk/meson/s4-pll.c | 2 +- drivers/clk/meson/sclk-div.c | 2 +- drivers/clk/meson/vclk.h | 2 +- drivers/clk/meson/vid-pll-div.c | 2 +- .../meson => include/linux/clk}/clk-regmap.h | 0 32 files changed, 53 insertions(+), 53 deletions(-)
Quoted 3 lines
rename
drivers/clk/{meson=>}/clk-regmap.c(99%)
rename {drivers/clk/meson=>include/linux/clk}/clk-regmap.h(100%)
<snip>
I don't have objections, but I think Stephen didn't like the idea a few years ago, but perhaps it has changed...
Anyway, take my:
Thanks,
Neil
Jerome Brunet
maintainerRe: [PATCH v1 08/11] clk: move meson clk-regmap implementation to common code
Quoted 42 lines · Neil Armstrong
Quoted 38 lines · Conor Dooley
From: Conor Dooley <[email protected]>
I like this one better than qualcomms and wish to use it for the PolarFire SoC clock drivers.Signed-off-by Conor Dooley <[email protected]>--- drivers/clk/Kconfig | 4 ++ drivers/clk/Makefile | 1 + drivers/clk/{meson => }/clk-regmap.c | 2 +- drivers/clk/meson/Kconfig | 46 +++++++++---------- drivers/clk/meson/Makefile | 1 - drivers/clk/meson/a1-peripherals.c | 2 +- drivers/clk/meson/a1-pll.c | 2 +- drivers/clk/meson/axg-aoclk.c | 2 +- drivers/clk/meson/axg-audio.c | 2 +- drivers/clk/meson/axg.c | 2 +- drivers/clk/meson/c3-peripherals.c | 2 +- drivers/clk/meson/c3-pll.c | 2 +- drivers/clk/meson/clk-cpu-dyndiv.c | 2 +- drivers/clk/meson/clk-dualdiv.c | 2 +- drivers/clk/meson/clk-mpll.c | 2 +- drivers/clk/meson/clk-phase.c | 2 +- drivers/clk/meson/clk-pll.c | 2 +- drivers/clk/meson/g12a-aoclk.c | 2 +- drivers/clk/meson/g12a.c | 2 +- drivers/clk/meson/gxbb-aoclk.c | 2 +- drivers/clk/meson/gxbb.c | 2 +- drivers/clk/meson/meson-aoclk.h | 2 +- drivers/clk/meson/meson-eeclk.c | 2 +- drivers/clk/meson/meson-eeclk.h | 2 +- drivers/clk/meson/meson8-ddr.c | 2 +- drivers/clk/meson/meson8b.c | 2 +- drivers/clk/meson/s4-peripherals.c | 2 +- drivers/clk/meson/s4-pll.c | 2 +- drivers/clk/meson/sclk-div.c | 2 +- drivers/clk/meson/vclk.h | 2 +- drivers/clk/meson/vid-pll-div.c | 2 +- .../meson => include/linux/clk}/clk-regmap.h | 0 32 files changed, 53 insertions(+), 53 deletions(-)Quoted 3 lines
rename
drivers/clk/{meson=>}/clk-regmap.c(99%)
rename {drivers/clk/meson=>include/linux/clk}/clk-regmap.h(100%)
Quoted 7 lines
<snip>
I don't have objections, but I think Stephen didn't like the idea a few years ago, but perhaps it has changed...
Anyway, take my:
Acked-by Neil Armstrong <[email protected]>
We had a similar discussion 3y ago indeed:
https://lore.kernel.org/linux-clk/162734682512.2368309.12015873010777083014@swboyd.mtv.corp.google.com/
There are needs for a common regmap backed clocks indeed, but allowing meson flavored regmap clocks to spread in the kernel was not really the prefered way to do it.
IIRC, Stephen's idea was more the bring regmap support in clk-gate.c, clk-mux, etc ... I'm not quite sure how make iomem and regmap co-exist in a manageable/maintainable way within those drivers (without adding yet another level of abstraction I mean) ? Silently creating a regmap maybe ? but that's probably a bit heavy. I did not really had time to dig more on this, I guess no one did.
I don't really have a preference one way or the other but if it is going to be exposed in 'include/linux', we need to be sure that's how we want to do it. With clocks poping in many driver subsystems, it will difficult to change afterward.
Quoted 3 lines
Thanks,
Neil
Signature · 1 line
Jerome
Conor Dooley
maintainerRe: [PATCH v1 08/11] clk: move meson clk-regmap implementation to common code
Quoted 52 lines · Jerome Brunet
Quoted 42 lines · Neil Armstrong
Quoted 38 lines · Conor Dooley
From: Conor Dooley <[email protected]>
I like this one better than qualcomms and wish to use it for the PolarFire SoC clock drivers.Signed-off-by Conor Dooley <[email protected]>--- drivers/clk/Kconfig | 4 ++ drivers/clk/Makefile | 1 + drivers/clk/{meson => }/clk-regmap.c | 2 +- drivers/clk/meson/Kconfig | 46 +++++++++---------- drivers/clk/meson/Makefile | 1 - drivers/clk/meson/a1-peripherals.c | 2 +- drivers/clk/meson/a1-pll.c | 2 +- drivers/clk/meson/axg-aoclk.c | 2 +- drivers/clk/meson/axg-audio.c | 2 +- drivers/clk/meson/axg.c | 2 +- drivers/clk/meson/c3-peripherals.c | 2 +- drivers/clk/meson/c3-pll.c | 2 +- drivers/clk/meson/clk-cpu-dyndiv.c | 2 +- drivers/clk/meson/clk-dualdiv.c | 2 +- drivers/clk/meson/clk-mpll.c | 2 +- drivers/clk/meson/clk-phase.c | 2 +- drivers/clk/meson/clk-pll.c | 2 +- drivers/clk/meson/g12a-aoclk.c | 2 +- drivers/clk/meson/g12a.c | 2 +- drivers/clk/meson/gxbb-aoclk.c | 2 +- drivers/clk/meson/gxbb.c | 2 +- drivers/clk/meson/meson-aoclk.h | 2 +- drivers/clk/meson/meson-eeclk.c | 2 +- drivers/clk/meson/meson-eeclk.h | 2 +- drivers/clk/meson/meson8-ddr.c | 2 +- drivers/clk/meson/meson8b.c | 2 +- drivers/clk/meson/s4-peripherals.c | 2 +- drivers/clk/meson/s4-pll.c | 2 +- drivers/clk/meson/sclk-div.c | 2 +- drivers/clk/meson/vclk.h | 2 +- drivers/clk/meson/vid-pll-div.c | 2 +- .../meson => include/linux/clk}/clk-regmap.h | 0 32 files changed, 53 insertions(+), 53 deletions(-)Quoted 3 lines
rename
drivers/clk/{meson=>}/clk-regmap.c(99%)
rename {drivers/clk/meson=>include/linux/clk}/clk-regmap.h(100%)Quoted 7 lines
<snip>
I don't have objections, but I think Stephen didn't like the idea a few years ago, but perhaps it has changed...
Anyway, take my:
Acked-by Neil Armstrong <[email protected]>
Quoted 6 lines
We had a similar discussion 3y ago indeed:
https://lore.kernel.org/linux-clk/162734682512.2368309.12015873010777083014@swboyd.mtv.corp.google.com/There are needs for a common regmap backed clocks indeed, but allowing meson flavored regmap clocks to spread in the kernel was not really the prefered way to do it.
Cool, thanks for that link.
Quoted 6 lines
IIRC, Stephen's idea was more the bring regmap support in
clk-gate.c, clk-mux, etc ... I'm not quite sure how make iomem and regmap co-exist in a manageable/maintainable way within those drivers (without adding yet another level of abstraction I mean) ? Silently creating a regmap maybe ? but that's probably a bit heavy. I did not really had time to dig more on this, I guess no one did.
I guess I have some motivation to looking into it at the moment. I had my reservations about the Meson approach too, liking it more than Qualcomm's didn't mean I completely liked it.
It was already my intention to implement point b of your mail, had the general idea here been acceptable, cos that's a divergence from how the generic clock types (that the driver in question currently uses) work. And on that note, I just noticed I left the mild-annoyance variable name "sigh" in the submitted driver changes, which I had used for the clk_regmap struct that your point b in the link relates to.
Quoted 4 lines
I don't really have a preference one way or the other but if it is going to be exposed in '
include/linux', we need to be sure that's how we want to do it. With clocks poping in many driver subsystems, it will difficult to change afterward.
Yeah, I agree. I didn't expect this to go in right away, and I also didn't want to surge ahead on some rework of the clock types, were people to hate even the reuse.
Conor Dooley
maintainerRe: [PATCH v1 08/11] clk: move meson clk-regmap implementation to common code
Stephen,
Quoted 79 lines · Conor Dooley
Quoted 52 lines · Jerome Brunet
Quoted 42 lines · Neil Armstrong
Quoted 38 lines · Conor Dooley
From: Conor Dooley <[email protected]>
I like this one better than qualcomms and wish to use it for the PolarFire SoC clock drivers.Signed-off-by Conor Dooley <[email protected]>--- drivers/clk/Kconfig | 4 ++ drivers/clk/Makefile | 1 + drivers/clk/{meson => }/clk-regmap.c | 2 +- drivers/clk/meson/Kconfig | 46 +++++++++---------- drivers/clk/meson/Makefile | 1 - drivers/clk/meson/a1-peripherals.c | 2 +- drivers/clk/meson/a1-pll.c | 2 +- drivers/clk/meson/axg-aoclk.c | 2 +- drivers/clk/meson/axg-audio.c | 2 +- drivers/clk/meson/axg.c | 2 +- drivers/clk/meson/c3-peripherals.c | 2 +- drivers/clk/meson/c3-pll.c | 2 +- drivers/clk/meson/clk-cpu-dyndiv.c | 2 +- drivers/clk/meson/clk-dualdiv.c | 2 +- drivers/clk/meson/clk-mpll.c | 2 +- drivers/clk/meson/clk-phase.c | 2 +- drivers/clk/meson/clk-pll.c | 2 +- drivers/clk/meson/g12a-aoclk.c | 2 +- drivers/clk/meson/g12a.c | 2 +- drivers/clk/meson/gxbb-aoclk.c | 2 +- drivers/clk/meson/gxbb.c | 2 +- drivers/clk/meson/meson-aoclk.h | 2 +- drivers/clk/meson/meson-eeclk.c | 2 +- drivers/clk/meson/meson-eeclk.h | 2 +- drivers/clk/meson/meson8-ddr.c | 2 +- drivers/clk/meson/meson8b.c | 2 +- drivers/clk/meson/s4-peripherals.c | 2 +- drivers/clk/meson/s4-pll.c | 2 +- drivers/clk/meson/sclk-div.c | 2 +- drivers/clk/meson/vclk.h | 2 +- drivers/clk/meson/vid-pll-div.c | 2 +- .../meson => include/linux/clk}/clk-regmap.h | 0 32 files changed, 53 insertions(+), 53 deletions(-)Quoted 3 lines
rename
drivers/clk/{meson=>}/clk-regmap.c(99%)
rename {drivers/clk/meson=>include/linux/clk}/clk-regmap.h(100%)Quoted 7 lines
<snip>
I don't have objections, but I think Stephen didn't like the idea a few years ago, but perhaps it has changed...
Anyway, take my:
Acked-by Neil Armstrong <[email protected]>Quoted 6 lines
We had a similar discussion 3y ago indeed:
https://lore.kernel.org/linux-clk/162734682512.2368309.12015873010777083014@swboyd.mtv.corp.google.com/There are needs for a common regmap backed clocks indeed, but allowing meson flavored regmap clocks to spread in the kernel was not really the prefered way to do it.
Cool, thanks for that link.
Quoted 6 lines
IIRC, Stephen's idea was more the bring regmap support in
clk-gate.c, clk-mux, etc ... I'm not quite sure how make iomem and regmap co-exist in a manageable/maintainable way within those drivers (without adding yet another level of abstraction I mean) ? Silently creating a regmap maybe ? but that's probably a bit heavy. I did not really had time to dig more on this, I guess no one did.I guess I have some motivation to looking into it at the moment. I had my reservations about the Meson approach too, liking it more than Qualcomm's didn't mean I completely liked it.
It was already my intention to implement point b of your mail, had the general idea here been acceptable, cos that's a divergence from how the generic clock types (that the driver in question currently uses) work. And on that note, I just noticed I left the mild-annoyance variable name "sigh" in the submitted driver changes, which I had used for theclk_regmapstruct that your point b in the link relates to.
Quoted 8 lines
Quoted 4 lines
I don't really have a preference one way or the other but if it is going to be exposed in '
include/linux', we need to be sure that's how we want to do it. With clocks poping in many driver subsystems, it will difficult to change afterward.Yeah, I agree. I didn't expect this to go in right away, and I also didn't want to surge ahead on some rework of the clock types, were people to hate even the reuse.
Hmm, so how (in-)complete of a regmap implementation can I get away with? I only need clk-gate and clk-divider for this patchset...
Shoving the regmap into the clk structs makes things pretty trivial as I don't need to do anything special in any function other than clk_*_readl()/clk_*_writel() and the registration code. A flag isn't even needed to determine if a clock is a regmap one I don't think, since you can just check if the regmap pointer is non-NULL. My use case doesn't actually need the registration code changes either as, currently, only reg gets set at runtime, but leaving that out is a level of incomplete I'd not let myself away with.
Obviously shoving the extra members into the clk structs has the downside of taking up a pointer and a offset worth of memory for each clock of that type registered, but it is substantially easier to support devices with multiple regmaps that way. Probably moot though since the approach you suggested in the thread linked above that implements a clk_hw_get_regmap() has to store a pointer to the regmap's identifier which would take up an identical amount of memory.
I don't really care which way you want it done, both are pretty easy to implement if I can get away with just doing so for the two standard clock types that I am using - is it okay to just do those two?
Cheers,
Conor.
Stephen Boyd
maintainerRe: [PATCH v1 08/11] clk: move meson clk-regmap implementation to common code
Quoting Conor Dooley (2024-11-06 04:56:25)
Quoted 27 lines · Conor Dooley
Quoted 17 lines
Quoted 6 lines
IIRC, Stephen's idea was more the bring regmap support in
clk-gate.c, clk-mux, etc ... I'm not quite sure how make iomem and regmap co-exist in a manageable/maintainable way within those drivers (without adding yet another level of abstraction I mean) ? Silently creating a regmap maybe ? but that's probably a bit heavy. I did not really had time to dig more on this, I guess no one did.I guess I have some motivation to looking into it at the moment. I had my reservations about the Meson approach too, liking it more than Qualcomm's didn't mean I completely liked it.
It was already my intention to implement point b of your mail, had the general idea here been acceptable, cos that's a divergence from how the generic clock types (that the driver in question currently uses) work. And on that note, I just noticed I left the mild-annoyance variable name "sigh" in the submitted driver changes, which I had used for theclk_regmapstruct that your point b in the link relates to.Quoted 8 lines
Quoted 4 lines
I don't really have a preference one way or the other but if it is going to be exposed in '
include/linux', we need to be sure that's how we want to do it. With clocks poping in many driver subsystems, it will difficult to change afterward.Yeah, I agree. I didn't expect this to go in right away, and I also didn't want to surge ahead on some rework of the clock types, were people to hate even the reuse.
Quoted 8 lines
Hmm, so how (in-)complete of a regmap implementation can I get away with? I only need clk-gate and clk-divider for this patchset...
Shoving the regmap into the clk structs makes things pretty trivial as I don't need to do anything special in any function other than clk_*_readl()/clk_*_writel() and the registration code. A flag isn't even needed to determine if a clock is a regmap one I don't think, since you can just check if the regmap pointer is non-NULL.
For the basic clk types I think it would be good to leave the old stuff alone. We have already split the logic out into helpers, so I wonder if we can do this better by making kernel modules for the different basic regmap clk types and exposing registration APIs. If we force drivers that use the basic regmap types to 'select' the module then we'll make it so that we don't include code that isn't used anywhere. That's one of the problems with the basic clk types, it's always built. It also lets us avoid making regmap a dependency for the clk framework at large.
Doing that would also let us avoid the flag because it will be explicit in any registration API, clk_register_divider() vs. clk_register_regmap_divider(). Yes we duplicate some boiler plate logic around read-only and registration paths, but this is alright as long as we can share most of the code and gain the advantage of removing the code entirely when it isn't used.
I wonder if we can even make a regmap on the fly for the iomem pointers so that clk_divider_readl() can always use the regmap API to access the hardware. Sounds wasteful but maybe it would work.
Quoted 11 lines
My use case doesn't
actually need the registration code changes either as, currently, only reg gets set at runtime, but leaving that out is a level of incomplete I'd not let myself away with.
Obviously shoving the extra members into the clk structs has the downside of taking up a pointer and a offset worth of memory for each clock of that type registered, but it is substantially easier to support devices with multiple regmaps that way. Probably moot though since the approach you suggested in the thread linked above that implements aclk_hw_get_regmap()has to store a pointer to the regmap's identifier which would take up an identical amount of memory.
We don't need to store the regmap identifier in the struct clk. We can store it in the 'struct clk_init_data' with some new field, and only do that when/if we actually need to. We would need to pass the init data to the clk_ops::init() callback though. We currently knock that out during registration so that clk_hw->init is NULL. Probably we can just set that to NULL after the init routine runs in __clk_core_init().
Long story short, don't add something to 'struct clk_core', 'struct clk', or 'struct clk_hw' for these details. We can have a 'struct clk_regmap_hw' that everyone else can build upon:
struct clk_regmap_hw {
struct regmap *regmap;
struct clk_hw hw;
};and then set the regmap pointer during registration in clk_hw_init_regmap().
int clk_hw_init_regmap(struct clk_hw *hw)
{
struct device *dev;
struct regmap *regmap;
struct clk_regmap_hw *rhw;
rhw = clk_hw_to_clk_regmap_hw(hw);
dev = clk_hw_get_dev(hw);
if (!dev)
return -EINVAL;
regmap = dev_get_regmap(dev, hw->init->regmap_name);
if (!regmap)
return -EINVAL; // Print helpful message
rhw->regmap = regmap;
return 0;
}or we can even make it so that there's clk_hw_init_regmap() and clk_hw_init_regmap_name() so that drivers can have multiple functions if the clks need different regmaps.
int my_init_regmap(struct clk_hw *hw)
{
int ret;
ret = clk_hw_init_regmap_name(hw, "my_name");
...
}If you don't need the multiple regmap support then it's fine to punt here until later.
Quoted 5 lines
I don't really care which way you want it done, both are pretty easy to implement if I can get away with just doing so for the two standard clock types that I am using - is it okay to just do those two?
Of course, doing only what is minimally required is better than changing everything if you're not sure the approach is going to land.
Conor Dooley
maintainerRe: [PATCH v1 08/11] clk: move meson clk-regmap implementation to common code
Quoted 20 lines · Stephen Boyd
Quoting Conor Dooley (2024-11-06 04:56:25)
Quoted 11 lines
My use case doesn't
actually need the registration code changes either as, currently, only reg gets set at runtime, but leaving that out is a level of incomplete I'd not let myself away with.
Obviously shoving the extra members into the clk structs has the downside of taking up a pointer and a offset worth of memory for each clock of that type registered, but it is substantially easier to support devices with multiple regmaps that way. Probably moot though since the approach you suggested in the thread linked above that implements aclk_hw_get_regmap()has to store a pointer to the regmap's identifier which would take up an identical amount of memory.We don't need to store the regmap identifier in the struct clk. We can store it in the 'struct
clk_init_data' with some new field, and only do that when/if we actually need to. We would need to pass the init data to theclk_ops::init()callback though. We currently knock that out during registration so thatclk_hw->initis NULL. Probably we can just set that to NULL after the init routine runs in__clk_core_init().
Quoted 8 lines
Long story short, don't add something to 'struct
clk_core', 'struct clk', or 'structclk_hw' for these details. We can have a 'structclk_regmap_hw' that everyone else can build upon:struct clk_regmap_hw { struct regmap *regmap; struct clk_hw hw; };
What's the point of this? I don't understand why you want to do this over what clk_divider et al already do, where clk_hw and the iomem pointer are in the struct itself.
Quoted 23 lines
and then set the regmap pointer during registration in
clk_hw_init_regmap().int
clk_hw_init_regmap(struct clk_hw *hw){ struct device *dev; struct regmap *regmap; struct clk_regmap_hw *rhw; rhw = clk_hw_to_clk_regmap_hw(hw); dev = clk_hw_get_dev(hw); if (!dev) return -EINVAL; regmap = dev_get_regmap(dev, hw->init->regmap_name); if (!regmap) return -EINVAL; // Print helpful message rhw->regmap = regmap; return 0; }
Stephen Boyd
maintainerRe: [PATCH v1 08/11] clk: move meson clk-regmap implementation to common code
Quoting Conor Dooley (2024-11-28 02:36:16)
Quoted 25 lines · Stephen Boyd
Quoted 24 lines
Quoting Conor Dooley (2024-11-06 04:56:25)
Quoted 11 lines
My use case doesn't
actually need the registration code changes either as, currently, only reg gets set at runtime, but leaving that out is a level of incomplete I'd not let myself away with.
Obviously shoving the extra members into the clk structs has the downside of taking up a pointer and a offset worth of memory for each clock of that type registered, but it is substantially easier to support devices with multiple regmaps that way. Probably moot though since the approach you suggested in the thread linked above that implements aclk_hw_get_regmap()has to store a pointer to the regmap's identifier which would take up an identical amount of memory.We don't need to store the regmap identifier in the struct clk. We can store it in the 'struct
clk_init_data' with some new field, and only do that when/if we actually need to. We would need to pass the init data to theclk_ops::init()callback though. We currently knock that out during registration so thatclk_hw->initis NULL. Probably we can just set that to NULL after the init routine runs in__clk_core_init().Long story short, don't add something to 'struct
clk_core', 'struct clk', or 'structclk_hw' for these details. We can have a 'structclk_regmap_hw' that everyone else can build upon:
Quoted 8 lines
Quoted 4 lines
struct clk_regmap_hw { struct regmap *regmap; struct clk_hw hw; };What's the point of this? I don't understand why you want to do this over what
clk_divideret al already do, whereclk_hwand the iomem pointer are in the struct itself.
Can you give an example? I don't understand what you're suggesting. I prefer a struct clk_regmap_hw like above so that the existing struct clk_hw in the kernel aren't increased by a pointer. SoC drivers can use the same struct as a replacement for their struct clk_hw member today.
Conor Dooley
maintainerRe: [PATCH v1 08/11] clk: move meson clk-regmap implementation to common code
Quoted 31 lines · Stephen Boyd
Quoting Conor Dooley (2024-11-28 02:36:16)
Quoted 30 lines · Stephen Boyd
Quoted 28 lines
Quoting Conor Dooley (2024-11-06 04:56:25)
Quoted 11 lines
My use case doesn't
actually need the registration code changes either as, currently, only reg gets set at runtime, but leaving that out is a level of incomplete I'd not let myself away with.
Obviously shoving the extra members into the clk structs has the downside of taking up a pointer and a offset worth of memory for each clock of that type registered, but it is substantially easier to support devices with multiple regmaps that way. Probably moot though since the approach you suggested in the thread linked above that implements aclk_hw_get_regmap()has to store a pointer to the regmap's identifier which would take up an identical amount of memory.We don't need to store the regmap identifier in the struct clk. We can store it in the 'struct
clk_init_data' with some new field, and only do that when/if we actually need to. We would need to pass the init data to theclk_ops::init()callback though. We currently knock that out during registration so thatclk_hw->initis NULL. Probably we can just set that to NULL after the init routine runs in__clk_core_init().Long story short, don't add something to 'struct
clk_core', 'struct clk', or 'structclk_hw' for these details. We can have a 'structclk_regmap_hw' that everyone else can build upon:struct clk_regmap_hw { struct regmap *regmap; struct clk_hw hw; };
Quoted 8 lines
Quoted 3 lines
What's the point of this? I don't understand why you want to do this over what
clk_divideret al already do, whereclk_hwand the iomem pointer are in the struct itself.Can you give an example? I don't understand what you're suggesting. I prefer a struct
clk_regmap_hwlike above so that the existing structclk_hwin the kernel aren't increased by a pointer. SoC drivers can use the same struct as a replacement for their structclk_hwmember today.
Best example I guess is to link what I did? This one is the core changes:
https://git.kernel.org/pub/scm/linux/kernel/git/conor/linux.git/commit/?h=syscon-rework-2&id=35904222355e971c24b3eb9b9fad3dd0c38d1393
clk-gate has my original hack that I did while trying to figure out what you wanted, clk-divider-regmap is a 99% copy of clk-divider with the types, function names and readl()/writel() implementations modified. Before your last set of comments I was doing something identical to the clk-gate change for clk-divider also.
Here's the changes required to my driver to make it work with the updated:
https://git.kernel.org/pub/scm/linux/kernel/git/conor/linux.git/commit/?h=syscon-rework-2&id=ea40211fe20f8bc6ef0320b93e1baa5b3f244601
It's pretty much a drop in replacement, other than the additional complexity in probe.
Hopefully that either gets my point across or lets you spot why I don't understand the benefit of a wrapper around clk_hw.
Cheers,
Conor.
Conor Dooley
maintainerRe: [PATCH v1 08/11] clk: move meson clk-regmap implementation to common code
Hey Stephen,
Any thoughts on the example I gave below?
Quoted 60 lines · Conor Dooley
Quoted 31 lines · Stephen Boyd
Quoting Conor Dooley (2024-11-28 02:36:16)
Quoted 30 lines · Stephen Boyd
Quoted 28 lines
Quoting Conor Dooley (2024-11-06 04:56:25)
Quoted 11 lines
My use case doesn't
actually need the registration code changes either as, currently, only reg gets set at runtime, but leaving that out is a level of incomplete I'd not let myself away with.
Obviously shoving the extra members into the clk structs has the downside of taking up a pointer and a offset worth of memory for each clock of that type registered, but it is substantially easier to support devices with multiple regmaps that way. Probably moot though since the approach you suggested in the thread linked above that implements aclk_hw_get_regmap()has to store a pointer to the regmap's identifier which would take up an identical amount of memory.We don't need to store the regmap identifier in the struct clk. We can store it in the 'struct
clk_init_data' with some new field, and only do that when/if we actually need to. We would need to pass the init data to theclk_ops::init()callback though. We currently knock that out during registration so thatclk_hw->initis NULL. Probably we can just set that to NULL after the init routine runs in__clk_core_init().Long story short, don't add something to 'struct
clk_core', 'struct clk', or 'structclk_hw' for these details. We can have a 'structclk_regmap_hw' that everyone else can build upon:struct clk_regmap_hw { struct regmap *regmap; struct clk_hw hw; };Quoted 8 lines
Quoted 3 lines
What's the point of this? I don't understand why you want to do this over what
clk_divideret al already do, whereclk_hwand the iomem pointer are in the struct itself.Can you give an example? I don't understand what you're suggesting. I prefer a struct
clk_regmap_hwlike above so that the existing structclk_hwin the kernel aren't increased by a pointer. SoC drivers can use the same struct as a replacement for their structclk_hwmember today.Best example I guess is to link what I did? This one is the core changes:
https://git.kernel.org/pub/scm/linux/kernel/git/conor/linux.git/commit/?h=syscon-rework-2&id=35904222355e971c24b3eb9b9fad3dd0c38d1393
clk-gate has my original hack that I did while trying to figure out what you wanted, clk-divider-regmap is a 99% copy of clk-divider with the types, function names and readl()/writel() implementations modified. Before your last set of comments I was doing something identical to the clk-gate change for clk-divider also.
Here's the changes required to my driver to make it work with the updated:
https://git.kernel.org/pub/scm/linux/kernel/git/conor/linux.git/commit/?h=syscon-rework-2&id=ea40211fe20f8bc6ef0320b93e1baa5b3f244601
It's pretty much a drop in replacement, other than the additional complexity in probe.Hopefully that either gets my point across or lets you spot why I don't understand the benefit of a wrapper around
clk_hw.Cheers,
Conor.
Conor Dooley
maintainerRe: [PATCH v1 08/11] clk: move meson clk-regmap implementation to common code
Quoted 3 lines · Conor Dooley
Hey Stephen,
Any thoughts on the example I gave below?
I'll give you a few more days to comment, and then I'll just send a fresh revision, implemented as below. The links seem to have expired in a rebase along the way, so I've provided some fresh links.
Cheers,
Conor.
Quoted 38 lines · Conor Dooley
Quoted 36 lines · Stephen Boyd
Quoted 35 lines
Quoting Conor Dooley (2024-11-28 02:36:16)
Quoted 33 lines · Stephen Boyd
Quoted 20 lines
Quoting Conor Dooley (2024-11-06 04:56:25)
Quoted 11 lines
My use case doesn't
actually need the registration code changes either as, currently, only reg gets set at runtime, but leaving that out is a level of incomplete I'd not let myself away with.
Obviously shoving the extra members into the clk structs has the downside of taking up a pointer and a offset worth of memory for each clock of that type registered, but it is substantially easier to support devices with multiple regmaps that way. Probably moot though since the approach you suggested in the thread linked above that implements aclk_hw_get_regmap()has to store a pointer to the regmap's identifier which would take up an identical amount of memory.We don't need to store the regmap identifier in the struct clk. We can store it in the 'struct
clk_init_data' with some new field, and only do that when/if we actually need to. We would need to pass the init data to theclk_ops::init()callback though. We currently knock that out during registration so thatclk_hw->initis NULL. Probably we can just set that to NULL after the init routine runs in__clk_core_init().Quoted 8 lines
Long story short, don't add something to 'struct
clk_core', 'struct clk', or 'structclk_hw' for these details. We can have a 'structclk_regmap_hw' that everyone else can build upon:struct clk_regmap_hw { struct regmap *regmap; struct clk_hw hw; };What's the point of this? I don't understand why you want to do this over what
clk_divideret al already do, whereclk_hwand the iomem pointer are in the struct itself.
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Can you give an example? I don't understand what you're suggesting. I prefer a struct
clk_regmap_hwlike above so that the existing structclk_hwin the kernel aren't increased by a pointer. SoC drivers can use the same struct as a replacement for their structclk_hwmember today.Best example I guess is to link what I did? This one is the core changes:
https://git.kernel.org/pub/scm/linux/kernel/git/conor/linux.git/commit/?h=syscon-rework-2&id=35904222355e971c24b3eb9b9fad3dd0c38d1393
Quoted 8 lines
Quoted 8 lines
clk-gate has my original hack that I did while trying to figure out what you wanted, clk-divider-regmap is a 99% copy of clk-divider with the types, function names and readl()/writel() implementations modified. Before your last set of comments I was doing something identical to the clk-gate change for clk-divider also.
Here's the changes required to my driver to make it work with the updated:
https://git.kernel.org/pub/scm/linux/kernel/git/conor/linux.git/commit/?h=syscon-rework-2&id=ea40211fe20f8bc6ef0320b93e1baa5b3f244601
Quoted 10 lines
Quoted 8 lines
It's pretty much a drop in replacement, other than the additional complexity in probe.
Hopefully that either gets my point across or lets you spot why I don't understand the benefit of a wrapper around
clk_hw.Cheers,
Conor.
Conor Dooley
maintainerPATCH 9/11 clk: microchip: mpfs: use regmap clock types
In reply to Conor DooleyFrom: Conor Dooley <[email protected]>
Convert the PolarFire SoC clock driver to use regmap clock types as a preparatory work for supporting the new binding for this device that will only provide the second of the two register regions, and will require the use of syscon regmap to access the "cfg" and "periph" clocks currently supported by the driver.
--- drivers/clk/microchip/Kconfig | 3 + drivers/clk/microchip/clk-mpfs.c | 114 ++++++++++++++++++++++--------- 2 files changed, 85 insertions(+), 32 deletions(-)
drivers/clk/microchip/Kconfig +3 -0
@@ -7,6 +7,9 @@ config MCHP_CLK_MPFS bool "Clk driver for PolarFire SoC" depends on ARCH_MICROCHIP_POLARFIRE || COMPILE_TEST default ARCH_MICROCHIP_POLARFIRE + depends on MFD_SYSCON select AUXILIARY_BUS + select COMMON_CLK_REGMAP + select REGMAP_MMIO help Supports Clock Configuration for PolarFire SoC
drivers/clk/microchip/clk-mpfs.c +82 -32
208 lines not on this page · raw message
Signature · 1 line
2.45.2
Conor Dooley
maintainerPATCH 10/11 riscv: dts: microchip: fix mailbox description
In reply to Conor DooleyFrom: Conor Dooley <[email protected]>
When the binding for the mailbox on PolarFire SoC was originally written, and later modified, mistakes were made - and the precise nature of the later modification should have been a giveaway, but alas I was naive at the time.
A more correct modelling of the hardware is to use two syscons and have a single reg entry for the mailbox, containing the mailbox region. The two syscons contain the general control/status registers for the mailbox and the interrupt related registers respectively. The reason for two syscons is that the same mailbox is present on the non-SoC version of the FPGA, which has no interrupt controller, and the shared part of the rtl was unchanged between devices.
--- arch/riscv/boot/dts/microchip/mpfs.dtsi | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
arch/riscv/boot/dts/microchip/mpfs.dtsi +12 -3
@@ -259,6 +259,11 @@ clkcfg: clkcfg@20002000 { #reset-cells = <1>; }; + sysreg_scb: syscon@20003000 { + compatible = "microchip,mpfs-sysreg-scb", "syscon"; + reg = <0x0 0x20003000 0x0 0x1000>; + }; + ccc_se: clock-controller@38010000 { compatible = "microchip,mpfs-ccc"; reg = <0x0 0x38010000 0x0 0x1000>, <0x0 0x38020000 0x0 0x1000>,
@@ -521,10 +526,14 @@ usb: usb@20201000 { status = "disabled"; }; - mbox: mailbox@37020000 { + control_scb: syscon@37020000 { + compatible = "microchip,mpfs-control-scb", "syscon", "simple-mfd"; + reg = <0x0 0x37020000 0x0 0x100>; + }; + + mbox: mailbox@37020800 { compatible = "microchip,mpfs-mailbox"; - reg = <0x0 0x37020000 0x0 0x58>, <0x0 0x2000318C 0x0 0x40>, - <0x0 0x37020800 0x0 0x100>; + reg = <0x0 0x37020800 0x0 0x100>; interrupt-parent = <&plic>; interrupts = <96>; #mbox-cells = <1>;
Signature · 1 line
2.45.2
Conor Dooley
maintainerRe: [PATCH v1 10/11] riscv: dts: microchip: fix mailbox description
Quoted 37 lines · Conor Dooley
From: Conor Dooley <[email protected]>
When the binding for the mailbox on PolarFire SoC was originally written, and later modified, mistakes were made - and the precise nature of the later modification should have been a giveaway, but alas I was naive at the time.
A more correct modelling of the hardware is to use two syscons and have a single reg entry for the mailbox, containing the mailbox region. The two syscons contain the general control/status registers for the mailbox and the interrupt related registers respectively. The reason for two syscons is that the same mailbox is present on the non-SoC version of the FPGA, which has no interrupt controller, and the shared part of the rtl was unchanged between devices.
Signed-off-by Conor Dooley <[email protected]>--- arch/riscv/boot/dts/microchip/mpfs.dtsi | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)arch/riscv/boot/dts/microchip/mpfs.dtsi +5
-0@@ -259,6 +259,11 @@ clkcfg: clkcfg@20002000 { #reset-cells = <1>; }; + sysreg_scb: syscon@20003000 { + compatible = "microchip,mpfs-sysreg-scb", "syscon"; + reg = <0x0 0x20003000 0x0 0x1000>; + }; + ccc_se: clock-controller@38010000 { compatible = "microchip,mpfs-ccc"; reg = <0x0 0x38010000 0x0 0x1000>, <0x0 0x38020000 0x0 0x1000>,
arch/riscv/boot/dts/microchip/mpfs.dtsi usb: usb@20201000 { · line 531
Quoted 7 lines
arch/riscv/boot/dts/microchip/mpfs.dtsi +3
-1@@ -521,10 +526,14 @@ usb: usb@20201000 { status = "disabled"; }; - mbox: mailbox@37020000 { + control_scb: syscon@37020000 { + compatible = "microchip,mpfs-control-scb", "syscon", "simple-mfd"; + reg = <0x0 0x37020000 0x0 0x100>;
It came up today that this 0x100 isn't correct - the actual size here is 4 KiB, so there's a zero missing.
Quoted 13 lines
arch/riscv/boot/dts/microchip/mpfs.dtsi +4
-2+ }; + + mbox: mailbox@37020800 { compatible = "microchip,mpfs-mailbox"; - reg = <0x0 0x37020000 0x0 0x58>, <0x0 0x2000318C 0x0 0x40>, - <0x0 0x37020800 0x0 0x100>; + reg = <0x0 0x37020800 0x0 0x100>; interrupt-parent = <&plic>; interrupts = <96>; #mbox-cells = <1>;Signature · 1 line
2.45.2
Conor Dooley
maintainerPATCH 11/11 riscv: dts: microchip: convert clock and reset to use syscon
In reply to Conor DooleyFrom: Conor Dooley <[email protected]>
The "subblock" clocks and reset registers on PolarFire SoC are located in the mss-top-sysreg region, alongside pinctrl and interrupt control functionality. Re-write the devicetree to describe the sys explicitly, as its own node, rather than as a region of the clock node. Correspondingly, the phandles to the reset controller must be updated to the new provider. The drivers will continue to support the old way of doing things.
--- arch/riscv/boot/dts/microchip/mpfs.dtsi | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
arch/riscv/boot/dts/microchip/mpfs.dtsi +12 -7
@@ -251,11 +251,9 @@ pdma: dma-controller@3000000 { #dma-cells = <1>; }; - clkcfg: clkcfg@20002000 { - compatible = "microchip,mpfs-clkcfg"; - reg = <0x0 0x20002000 0x0 0x1000>, <0x0 0x3E001000 0x0 0x1000>; - clocks = <&refclk>; - #clock-cells = <1>; + mss_top_sysreg: syscon@20002000 { + compatible = "microchip,mpfs-mss-top-sysreg", "syscon", "simple-mfd"; + reg = <0x0 0x20002000 0x0 0x1000>; #reset-cells = <1>; };
@@ -452,7 +450,7 @@ mac0: ethernet@20110000 { local-mac-address = [00 00 00 00 00 00]; clocks = <&clkcfg CLK_MAC0>, <&clkcfg CLK_AHB>; clock-names = "pclk", "hclk"; - resets = <&clkcfg CLK_MAC0>; + resets = <&mss_top_sysreg CLK_MAC0>; status = "disabled"; };
@@ -466,7 +464,7 @@ mac1: ethernet@20112000 { local-mac-address = [00 00 00 00 00 00]; clocks = <&clkcfg CLK_MAC1>, <&clkcfg CLK_AHB>; clock-names = "pclk", "hclk"; - resets = <&clkcfg CLK_MAC1>; + resets = <&mss_top_sysreg CLK_MAC1>; status = "disabled"; };
@@ -550,5 +548,12 @@ syscontroller_qspi: spi@37020100 { clocks = <&scbclk>; status = "disabled"; }; + + clkcfg: clkcfg@3e001000 { + compatible = "microchip,mpfs-clkcfg"; + reg = <0x0 0x3e001000 0x0 0x1000>; + clocks = <&refclk>; + #clock-cells = <1>; + }; }; };
Signature · 1 line
2.45.2