Skip to contentSkip to conversation

Redo PolarFire SoC's mailbox/clock devicestrees and related code

PATCH Applied Conor Dooley 3 participants 14 messages Oct 29, 2025 – Nov 4, 2025

Subsystems (5)

v6 of 7 Applied Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v6 cover Redo PolarFire SoC's mailbox/clock devicestrees and related code

From: Conor Dooley <[email protected]>

In v5 the only real change is that I removed the attempt at a common implementation of regmap-based divider/gate clocks. The series hasn't managed to receive feedback on my approach in 2025, despite sending several revisions and bumps, and it is blocking support for both new drivers (gpio interrupt support, pinctrl and hwmon off the top of my head) and a new platform so I have decided to strip out the attempt at making something common in exchange for something that can be merged through the clk-microchip tree without relying on feedback from the clock maintainers.

Currently the driver uses the common gate and divider clocks, but the driver used to use its own custom clock types. Reprising this version of the code allows me to use regmap accessors in the driver without any wider impact, or attempting to create something that works for any other user. It has the advantage that it has already been tested in that prior for, and all that is done to the clock implementations is replacing readl()s and writel()s with their regmap equivalents.

Hopefully this change has made it possible to merge the series, Conor.

v6:
- make reset depend on MFD_SYSCON
- return regmap_update_bits() result directly instead of an additional return 0 in reset
- use regmap_update_bits() instead of regmap_read() -> regmap_write() RMW sequences in clock
- drop clock driver specific lock, since regmap has internal locking, from !msspll clocks
- implement determine_rate instead of round_rate
- drop patch 1 & 2 (soc bits) since I applied them as a pre-req for pinctrl work

v5:
- drop mfd patch applied by Lee
- remove attempt at common regmap divider/gate clocks, and replace it with a return to how the code used to look, before it started using the non-regmap versions of the common divider/gate, with the readl()/writel()s replaced by their regmap equivalents.

v4:
- unify both regmap clk implementations under one option
- change map_offset to a u32, after Gabriel pointed out that u8 was too restrictive.
- remove locking from regmap portion of reset driver, relying on inherent regmap lock

v3 changes:
- drop simple-mfd (for now) from syscon node

v2 cover letter:

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, 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 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, which I have already modified to support the new format.

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.

And as a "real" series where discussion lead to me dropping use of the amlogic clk-regmap support:
https://lore.kernel.org/linux-clk/20241002-private-unequal-33cfa6101338@spud/
As a result of that, I've implemented what I think Stephen was asking for - but I'm not at all sure that it is..

CC Conor Dooley <[email protected]>
CC Daire McNamara <[email protected]>
CC Michael Turquette <[email protected]>
CC Stephen Boyd <[email protected]>
CC Rob Herring <[email protected]>
CC Krzysztof Kozlowski <[email protected]>
CC Philipp Zabel <[email protected]>

Conor Dooley (7):
reset: mpfs: add non-auxiliary bus probing
dt-bindings: clk: microchip: mpfs: remove first reg region
clk: microchip: mpfs: use regmap for clocks
riscv: dts: microchip: fix mailbox description
riscv: dts: microchip: convert clock and reset to use syscon
MAINTAINERS: add new soc drivers to Microchip RISC-V entry
MAINTAINERS: rename Microchip RISC-V entry

 .../bindings/clock/microchip,mpfs-clkcfg.yaml |  36 +--
 MAINTAINERS                                   |   4 +-
 arch/riscv/boot/dts/microchip/mpfs.dtsi       |  34 ++-
 drivers/clk/microchip/Kconfig                 |   2 +
 drivers/clk/microchip/clk-mpfs.c              | 227 ++++++++++++++----
 drivers/reset/Kconfig                         |   1 +
 drivers/reset/reset-mpfs.c                    |  79 ++++--
 7 files changed, 298 insertions(+), 85 deletions(-)
Signature · 1 line
2.51.0
#1 lore raw

PATCH v6 1/7 reset: mpfs: add non-auxiliary bus probing

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.

---
v6:
- depend on MFD_SYSCON
- return regmap_update_bits() result directly instead of an additional return 0

v4:
- Only use driver specific lock for non-regmap writes

v2:
- Implement the request to use regmap_update_bits(). I found that I then hated the read/write helpers since they were just bloat, so I ripped them out. I replaced the regular spin_lock_irqsave() stuff with a guard(spinlock_irqsave), since that's a simpler way of handling the two different paths through such a trivial pair of functions.

---
 drivers/reset/Kconfig      |  1 +
 drivers/reset/reset-mpfs.c | 79 ++++++++++++++++++++++++++++++--------
 2 files changed, 63 insertions(+), 17 deletions(-)
drivers/reset/Kconfig +1 -0
index 78b7078478d4..0ec4b7cd08d6 100644
@@ -200,6 +200,7 @@ config RESET_PISTACHIO
 config RESET_POLARFIRE_SOC
 	bool "Microchip PolarFire SoC (MPFS) Reset Driver"
 	depends on MCHP_CLK_MPFS
+	depends on MFD_SYSCON
 	select AUXILIARY_BUS
 	default MCHP_CLK_MPFS
 	help
drivers/reset/reset-mpfs.c +62 -17

158 lines not on this page · raw message

Signature · 1 line
2.51.0
maintainer
#2 lore raw

Re: [PATCH v6 1/7] reset: mpfs: add non-auxiliary bus probing

Quoted 83 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.

---
v6:
- depend on MFD_SYSCON
- return regmap_update_bits() result directly instead of an additional return 0

v4:
- Only use driver specific lock for non-regmap writes

v2:
- Implement the request to use regmap_update_bits(). I found that I then hated the read/write helpers since they were just bloat, so I ripped them out. I replaced the regular spin_lock_irqsave() stuff with a guard(spinlock_irqsave), since that's a simpler way of handling the two different paths through such a trivial pair of functions.

---
 drivers/reset/Kconfig      |  1 +
 drivers/reset/reset-mpfs.c | 79 ++++++++++++++++++++++++++++++--------
 2 files changed, 63 insertions(+), 17 deletions(-)
drivers/reset/Kconfig +1 -0
index 78b7078478d4..0ec4b7cd08d6 100644
@@ -200,6 +200,7 @@ config RESET_PISTACHIO
 config RESET_POLARFIRE_SOC
 	bool "Microchip PolarFire SoC (MPFS) Reset Driver"
 	depends on MCHP_CLK_MPFS
+	depends on MFD_SYSCON
 	select AUXILIARY_BUS
 	default MCHP_CLK_MPFS
 	help
drivers/reset/reset-mpfs.c +7 -1
index f6fa10e03ea8..25de7df55301 100644
@@ -7,13 +7,16 @@
  *
  */
 #include <linux/auxiliary_bus.h>
+#include <linux/cleanup.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 <linux/slab.h>
 #include <dt-bindings/clock/microchip,mpfs-clock.h>
 #include <soc/microchip/mpfs.h>
 
@@ -27,11 +30,14 @@
 #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;
 };
 

drivers/reset/reset-mpfs.c static inline struct mpfs_reset *to_mpfs_reset(struct reset_controller_dev *rcde · line 58

Quoted 9 lines
drivers/reset/reset-mpfs.c +2 -2
@@ -46,41 +52,46 @@ static inline struct mpfs_reset *to_mpfs_reset(struct reset_controller_dev *rcde
 static int mpfs_assert(struct reset_controller_dev *rcdev, unsigned long id)
 {
 	struct mpfs_reset *rst = to_mpfs_reset(rcdev);
-	unsigned long flags;
 	u32 reg;
 
-	spin_lock_irqsave(&mpfs_reset_lock, flags);
+	if (rst->regmap)
+		return regmap_update_bits(rst->regmap, REG_SUBBLK_RESET_CR, BIT(id), BIT(id));

This could use regmap_set_bits().

drivers/reset/reset-mpfs.c static inline struct mpfs_reset *to_mpfs_reset(struct reset_controller_dev *rcde · line 64

Quoted 6 lines
drivers/reset/reset-mpfs.c +2 -0
+
+	guard(spinlock_irqsave)(&mpfs_reset_lock);
 
 	reg = readl(rst->base);
 	reg |= BIT(id);
 	writel(reg, rst->base);

Since I've just seen this in the i.MX8ULP series [1], it would be cleaner to convert the aux driver to regmap as well. The readl/writel() code paths could be dropped then.

[1] https://lore.kernel.org/lkml/[email protected]/

[...]

drivers/reset/reset-mpfs.c static inline struct mpfs_reset *to_mpfs_reset(struct reset_controller_dev *rcde · line 75

Quoted 9 lines
drivers/reset/reset-mpfs.c +2 -2
 static int mpfs_deassert(struct reset_controller_dev *rcdev, unsigned long id)
 {
 	struct mpfs_reset *rst = to_mpfs_reset(rcdev);
-	unsigned long flags;
 	u32 reg;
 
-	spin_lock_irqsave(&mpfs_reset_lock, flags);
+	if (rst->regmap)
+		return regmap_update_bits(rst->regmap, REG_SUBBLK_RESET_CR, BIT(id), 0);

And this could use regmap_clear_bits().

regards
Philipp

#3 lore raw

Re: [PATCH v6 1/7] reset: mpfs: add non-auxiliary bus probing

Quoted 25 lines · Philipp Zabel

drivers/reset/reset-mpfs.c static inline struct mpfs_reset *to_mpfs_reset(struct reset_controller_dev *rcde · line 58

Quoted 10 lines · Conor Dooley
drivers/reset/reset-mpfs.c +2 -2
@@ -46,41 +52,46 @@ static inline struct mpfs_reset *to_mpfs_reset(struct reset_controller_dev *rcde
 static int mpfs_assert(struct reset_controller_dev *rcdev, unsigned long id)
 {
 	struct mpfs_reset *rst = to_mpfs_reset(rcdev);
-	unsigned long flags;
 	u32 reg;
 
-	spin_lock_irqsave(&mpfs_reset_lock, flags);
+	if (rst->regmap)
+		return regmap_update_bits(rst->regmap, REG_SUBBLK_RESET_CR, BIT(id), BIT(id));

This could use regmap_set_bits().

drivers/reset/reset-mpfs.c static inline struct mpfs_reset *to_mpfs_reset(struct reset_controller_dev *rcde · line 64

Quoted 6 lines
drivers/reset/reset-mpfs.c +2 -0
+
+	guard(spinlock_irqsave)(&mpfs_reset_lock);
 
 	reg = readl(rst->base);
 	reg |= BIT(id);
 	writel(reg, rst->base);

Since I've just seen this in the i.MX8ULP series [1], it would be cleaner to convert the aux driver to regmap as well. The readl/writel() code paths could be dropped then.

Quoted 1 line

[1] https://lore.kernel.org/lkml/[email protected]/

Yeah, it's definitely a lot neater this way. I'll do that. Patch ends up touching the clock driver in the process, but I don't think that's a big deal, since it's just the auxdev bits relating to the iomem pointer becoming a regmap pointer instead.

#4 lore raw

Re: [PATCH v6 1/7] reset: mpfs: add non-auxiliary bus probing

In reply to Conor Dooley

Hi, Conor,

Quoted 157 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.

---
v6:
- depend on MFD_SYSCON
- return regmap_update_bits() result directly instead of an additional return 0

v4:
- Only use driver specific lock for non-regmap writes

v2:
- Implement the request to use regmap_update_bits(). I found that I then hated the read/write helpers since they were just bloat, so I ripped them out. I replaced the regular spin_lock_irqsave() stuff with a guard(spinlock_irqsave), since that's a simpler way of handling the two different paths through such a trivial pair of functions.

---
  drivers/reset/Kconfig      |  1 +
  drivers/reset/reset-mpfs.c | 79 ++++++++++++++++++++++++++++++--------
  2 files changed, 63 insertions(+), 17 deletions(-)
drivers/reset/Kconfig +1 -0
index 78b7078478d4..0ec4b7cd08d6 100644
@@ -200,6 +200,7 @@ config RESET_PISTACHIO
  config RESET_POLARFIRE_SOC
  	bool "Microchip PolarFire SoC (MPFS) Reset Driver"
  	depends on MCHP_CLK_MPFS
+	depends on MFD_SYSCON
  	select AUXILIARY_BUS
  	default MCHP_CLK_MPFS
  	help
drivers/reset/reset-mpfs.c +31 -13
index f6fa10e03ea8..25de7df55301 100644
@@ -7,13 +7,16 @@
   *
   */
  #include <linux/auxiliary_bus.h>
+#include <linux/cleanup.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 <linux/slab.h>
  #include <dt-bindings/clock/microchip,mpfs-clock.h>
  #include <soc/microchip/mpfs.h>
 
@@ -27,11 +30,14 @@
  #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;
  };
 
@@ -46,41 +52,46 @@ static inline struct mpfs_reset *to_mpfs_reset(struct reset_controller_dev *rcde
  static int mpfs_assert(struct reset_controller_dev *rcdev, unsigned long id)
  {
  	struct mpfs_reset *rst = to_mpfs_reset(rcdev);
-	unsigned long flags;
  	u32 reg;
 
-	spin_lock_irqsave(&mpfs_reset_lock, flags);
+	if (rst->regmap)
+		return regmap_update_bits(rst->regmap, REG_SUBBLK_RESET_CR, BIT(id), BIT(id));
+
+	guard(spinlock_irqsave)(&mpfs_reset_lock);
 
  	reg = readl(rst->base);
  	reg |= BIT(id);
  	writel(reg, rst->base);
 
-	spin_unlock_irqrestore(&mpfs_reset_lock, flags);
-
  	return 0;
  }
 
  static int mpfs_deassert(struct reset_controller_dev *rcdev, unsigned long id)
  {
  	struct mpfs_reset *rst = to_mpfs_reset(rcdev);
-	unsigned long flags;
  	u32 reg;
 
-	spin_lock_irqsave(&mpfs_reset_lock, flags);
+	if (rst->regmap)
+		return regmap_update_bits(rst->regmap, REG_SUBBLK_RESET_CR, BIT(id), 0);
+
+	guard(spinlock_irqsave)(&mpfs_reset_lock);
 
  	reg = readl(rst->base);
  	reg &= ~BIT(id);
  	writel(reg, rst->base);
 
-	spin_unlock_irqrestore(&mpfs_reset_lock, flags);
-
  	return 0;
  }
 
  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;
+
+	if (rst->regmap)
+		regmap_read(rst->regmap, REG_SUBBLK_RESET_CR, &reg);
+	else
+		reg = readl(rst->base);
 
  	/*
  	 * It is safe to return here as MPFS_NUM_RESETS makes sure the sign bit
@@ -130,11 +141,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;

drivers/reset/reset-mpfs.c static int mpfs_reset_xlate(struct reset_controller_dev *rcdev, · line 165

Quoted 10 lines
drivers/reset/reset-mpfs.c +10 -0
+	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");

Do you want to continue registering the reset controller here? rcdev->base is NULL, thus the reset controller ops will fail, if I'm not wrong.

Thank you,
Claudiu

#5 lore raw

Re: [PATCH v6 1/7] reset: mpfs: add non-auxiliary bus probing

Quoted 21 lines · claudiu beznea
Quoted 20 lines · Conor Dooley
drivers/reset/reset-mpfs.c +15 -3
-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;
Quoted 8 lines

drivers/reset/reset-mpfs.c static int mpfs_reset_xlate(struct reset_controller_dev *rcdev, · line 165

Quoted 5 lines
drivers/reset/reset-mpfs.c +5 -0
+	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");

Do you want to continue registering the reset controller here? rcdev->base is NULL, thus the reset controller ops will fail, if I'm not wrong.

Oh, good point. That line is missing a return.

#6 lore raw

PATCH v6 2/7 dt-bindings: clk: microchip: mpfs: remove first reg region

In reply to 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.

---
 .../bindings/clock/microchip,mpfs-clkcfg.yaml | 36 +++++++++++--------
 1 file changed, 22 insertions(+), 14 deletions(-)
Documentation/devicetree/bindings/clock/microchip,mpfs-clkcfg.yaml +22 -14
index e4e1c31267d2..ee4f31596d97 100644
@@ -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.51.0
#7 lore raw

PATCH v6 3/7 clk: microchip: mpfs: use regmap for clocks

In reply to Conor Dooley

From: Conor Dooley <[email protected]>

Convert the PolarFire SoC clock driver to use regmaps instead of iomem addresses 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.

This is effectively a revert of commit 4da2404bb003 ("clk: microchip:
mpfs: convert cfg_clk to clk_divider") and commit d815569783e6 ("clk:
microchip: mpfs: convert periph_clk to clk_gate") as it resurrects the ops structures removed in those commits, with the readl()s and writel()s replaced by regmap_read()s and regmap_writes()s.

---
v6:
- use regmap_update_bits() instead of regmap_read() -> regmap_write() RMW sequences
- drop driver specific lock, since regmap has internal locking
- implement determine_rate instead of round_rate

---
 drivers/clk/microchip/Kconfig    |   2 +
 drivers/clk/microchip/clk-mpfs.c | 227 +++++++++++++++++++++++++------
 2 files changed, 186 insertions(+), 43 deletions(-)
drivers/clk/microchip/Kconfig +2 -0
index 0724ce65898f..1b9e43eb5497 100644
@@ -7,6 +7,8 @@ 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 REGMAP_MMIO
 	help
 	  Supports Clock Configuration for PolarFire SoC
drivers/clk/microchip/clk-mpfs.c +184 -43

325 lines not on this page · raw message

Signature · 1 line
2.51.0
Reviewed-by on v6 3/7
#8 lore raw

Re: [PATCH v6 3/7] clk: microchip: mpfs: use regmap for clocks

Quoted 8 lines · Conor Dooley

From: Conor Dooley<[email protected]>

Convert the PolarFire SoC clock driver to use regmaps instead of iomem addresses 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.

Quoted 7 lines

This is effectively a revert of commit 4da2404bb003 ("clk: microchip:
mpfs: convert cfg_clk to clk_divider") and commit d815569783e6 ("clk:
microchip: mpfs: convert periph_clk to clk_gate") as it resurrects the ops structures removed in those commits, with the readl()s and writel()s replaced by regmap_read()s and regmap_writes()s.

#9 lore raw

PATCH v6 4/7 riscv: dts: microchip: fix mailbox description

In reply to 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.

---
 arch/riscv/boot/dts/microchip/mpfs.dtsi | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
arch/riscv/boot/dts/microchip/mpfs.dtsi +12 -3
index 9883ca3554c5..f9d6bf08e717 100644
@@ -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";
+			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 0x1000>;
 			interrupt-parent = <&plic>;
 			interrupts = <96>;
 			#mbox-cells = <1>;
Signature · 1 line
2.51.0
#10 lore raw

PATCH v6 5/7 riscv: dts: microchip: convert clock and reset to use syscon

In reply to Conor Dooley

From: 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
index f9d6bf08e717..5c2963e269b8 100644
@@ -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.51.0
#11 lore raw

PATCH v6 6/7 MAINTAINERS: add new soc drivers to Microchip RISC-V entry

In reply to Conor Dooley

From: Conor Dooley <[email protected]>

Add the two new syscon drivers to the RISC-V entry for Microchip platforms.

---
 MAINTAINERS | 2 ++
 1 file changed, 2 insertions(+)
MAINTAINERS +2 -0
index 46126ce2f968..a28740a7d87a 100644
@@ -22105,6 +22105,8 @@ F:	drivers/pci/controller/plda/pcie-microchip-host.c
 F:	drivers/pwm/pwm-microchip-core.c
 F:	drivers/reset/reset-mpfs.c
 F:	drivers/rtc/rtc-mpfs.c
+F:	drivers/soc/microchip/mpfs-control-scb.c
+F:	drivers/soc/microchip/mpfs-mss-top-sysreg.c
 F:	drivers/soc/microchip/mpfs-sys-controller.c
 F:	drivers/spi/spi-microchip-core-qspi.c
 F:	drivers/spi/spi-microchip-core.c
Signature · 1 line
2.51.0
#12 lore raw

PATCH v6 7/7 MAINTAINERS: rename Microchip RISC-V entry

In reply to Conor Dooley

From: Conor Dooley <[email protected]>

There's now non-FPGA RISC-V SoCs from Microchip, so rename the entry to reflect that.

---
 MAINTAINERS | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
MAINTAINERS +1 -1
index a28740a7d87a..24efae3df425 100644
@@ -22079,7 +22079,7 @@ T:	git git://git.kernel.org/pub/scm/linux/kernel/git/iommu/linux.git
 F:	Documentation/devicetree/bindings/iommu/riscv,iommu.yaml
 F:	drivers/iommu/riscv/
 
-RISC-V MICROCHIP FPGA SUPPORT
+RISC-V MICROCHIP SUPPORT
 M:	Conor Dooley <[email protected]>
 M:	Daire McNamara <[email protected]>
 L:	[email protected]
Signature · 1 line
2.51.0
#13 lore raw
In reply to Conor Dooley
Quoted 2 lines · Conor Dooley

dt-bindings: clk: microchip: mpfs: remove first reg region
clk: microchip: mpfs: use regmap for clocks

Applied to clk-microchip, thanks!