Linux-Clk Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v5 00/27] clk: bcm: rpi: Add support for BCM2711 firmware clocks
@ 2020-06-15  8:40 Maxime Ripard
  2020-06-15  8:40 ` [PATCH v5 01/27] dt-bindings: arm: bcm: Convert BCM2835 firmware binding to YAML Maxime Ripard
                   ` (28 more replies)
  0 siblings, 29 replies; 64+ messages in thread
From: Maxime Ripard @ 2020-06-15  8:40 UTC (permalink / raw)
  To: Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, Stephen Boyd, linux-clk, Philipp Zabel,
	Maxime Ripard, devicetree, Kamal Dasu, Rob Herring

Hi,

Since the whole DRM/HDMI support began to grow fairly big, I've chosen
to split away the two discussions between the firmware clocks and the
HDMI support.

Let me know what you think,
Maxime

Cc: bcm-kernel-feedback-list@broadcom.com
Cc: devicetree@vger.kernel.org
Cc: Kamal Dasu <kdasu.kdev@gmail.com>
Cc: linux-clk@vger.kernel.org
Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Stephen Boyd <sboyd@kernel.org>

Changes from v4:
  - Rebased on 5.8-rc1
  - Added more tags
  - Fixed a typo in a variable name

Changes from v3:
  - Moved the firmware structure to the driver, and changed for u32
  - Prevented cache issues with MMIO driver
  - Removed message when discovering min and max rates
  - Added the gathered tags

Changes from v2:
  - Rebased on top of next-20200526
  - Split away from the HDMI series
  - Fixed an of_node leakage in the firmware driver
  - Fixed an of_node leakage in the firmware clocks driver
  - Added the min/max rate retrieval to all the firmware clocks
  - Added proper name for the firmware clocks
  - Removed the PLLB setup from the firmware clocks and moved it back to
    the MMIO driver

Florian Fainelli (1):
  dt-bindings: arm: bcm: Convert BCM2835 firmware binding to YAML

Maxime Ripard (26):
  dt-bindings: clock: Add a binding for the RPi Firmware clocks
  firmware: rpi: Only create clocks device if we don't have a node for it
  clk: bcm: rpi: Allow the driver to be probed by DT
  clk: bcm: rpi: Statically init clk_init_data
  clk: bcm: rpi: Use clk_hw_register for pllb_arm
  clk: bcm: rpi: Remove global pllb_arm clock pointer
  clk: bcm: rpi: Make sure pllb_arm is removed
  clk: bcm: rpi: Remove pllb_arm_lookup global pointer
  clk: bcm: rpi: Switch to clk_hw_register_clkdev
  clk: bcm: rpi: Make sure the clkdev lookup is removed
  clk: bcm: rpi: Use CCF boundaries instead of rolling our own
  clk: bcm: rpi: Create a data structure for the clocks
  clk: bcm: rpi: Add clock id to data
  clk: bcm: rpi: Pass the clocks data to the firmware function
  clk: bcm: rpi: Rename is_prepared function
  clk: bcm: rpi: Split pllb clock hooks
  clk: bcm: rpi: Make the PLLB registration function return a clk_hw
  clk: bcm: rpi: Add DT provider for the clocks
  clk: bcm: rpi: Add an enum for the firmware clocks
  clk: bcm: rpi: Discover the firmware clocks
  clk: bcm: rpi: Give firmware clocks a name
  Revert "clk: bcm2835: remove pllb"
  ARM: dts: bcm2711: Add firmware clocks node
  clk: bcm2835: Allow custom CCF flags for the PLLs
  clk: bcm2835: Don't cache the PLLB rate
  clk: bcm: rpi: Remove the quirks for the CPU clock

 Documentation/devicetree/bindings/arm/bcm/raspberrypi,bcm2835-firmware.txt  |  14 +---
 Documentation/devicetree/bindings/arm/bcm/raspberrypi,bcm2835-firmware.yaml |  59 ++++++++++++++-
 arch/arm/boot/dts/bcm2711-rpi-4-b.dts                                       |   5 +-
 drivers/clk/bcm/clk-bcm2835.c                                               |  34 ++++++--
 drivers/clk/bcm/clk-raspberrypi.c                                           | 311 +++++++++++++++++++++++++++++++++++++++++++-----------------------------
 drivers/firmware/raspberrypi.c                                              |  14 +++-
 6 files changed, 294 insertions(+), 143 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/arm/bcm/raspberrypi,bcm2835-firmware.txt
 create mode 100644 Documentation/devicetree/bindings/arm/bcm/raspberrypi,bcm2835-firmware.yaml

base-commit: b3a9e3b9622ae10064826dccb4f7a52bd88c7407
-- 
git-series 0.9.1

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH v5 01/27] dt-bindings: arm: bcm: Convert BCM2835 firmware binding to YAML
  2020-06-15  8:40 [PATCH v5 00/27] clk: bcm: rpi: Add support for BCM2711 firmware clocks Maxime Ripard
@ 2020-06-15  8:40 ` Maxime Ripard
  2020-06-25  0:42   ` Stephen Boyd
  2020-06-15  8:40 ` [PATCH v5 02/27] dt-bindings: clock: Add a binding for the RPi Firmware clocks Maxime Ripard
                   ` (27 subsequent siblings)
  28 siblings, 1 reply; 64+ messages in thread
From: Maxime Ripard @ 2020-06-15  8:40 UTC (permalink / raw)
  To: Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, Stephen Boyd, linux-clk, Philipp Zabel,
	Maxime Ripard, Florian Fainelli

From: Florian Fainelli <f.fainelli@gmail.com>

Convert the Raspberry Pi BCM2835 firmware binding document to YAML.
Verified with dt_binding_check and dtbs_check.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
 Documentation/devicetree/bindings/arm/bcm/raspberrypi,bcm2835-firmware.txt  | 14 --------------
 Documentation/devicetree/bindings/arm/bcm/raspberrypi,bcm2835-firmware.yaml | 35 +++++++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+), 14 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/arm/bcm/raspberrypi,bcm2835-firmware.txt
 create mode 100644 Documentation/devicetree/bindings/arm/bcm/raspberrypi,bcm2835-firmware.yaml

diff --git a/Documentation/devicetree/bindings/arm/bcm/raspberrypi,bcm2835-firmware.txt b/Documentation/devicetree/bindings/arm/bcm/raspberrypi,bcm2835-firmware.txt
deleted file mode 100644
index 6824b3180ffb..000000000000
--- a/Documentation/devicetree/bindings/arm/bcm/raspberrypi,bcm2835-firmware.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-Raspberry Pi VideoCore firmware driver
-
-Required properties:
-
-- compatible:		Should be "raspberrypi,bcm2835-firmware"
-- mboxes:		Phandle to the firmware device's Mailbox.
-			  (See: ../mailbox/mailbox.txt for more information)
-
-Example:
-
-firmware {
-	compatible = "raspberrypi,bcm2835-firmware";
-	mboxes = <&mailbox>;
-};
diff --git a/Documentation/devicetree/bindings/arm/bcm/raspberrypi,bcm2835-firmware.yaml b/Documentation/devicetree/bindings/arm/bcm/raspberrypi,bcm2835-firmware.yaml
new file mode 100644
index 000000000000..cec540c052b6
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/bcm/raspberrypi,bcm2835-firmware.yaml
@@ -0,0 +1,35 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/arm/bcm/raspberrypi,bcm2835-firmware.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Raspberry Pi VideoCore firmware driver
+
+maintainers:
+  - Eric Anholt <eric@anholt.net>
+  - Stefan Wahren <wahrenst@gmx.net>
+
+properties:
+  compatible:
+    items:
+      - const: raspberrypi,bcm2835-firmware
+      - const: simple-bus
+
+  mboxes:
+    $ref: '/schemas/types.yaml#/definitions/phandle'
+    description: |
+      Phandle to the firmware device's Mailbox.
+      (See: ../mailbox/mailbox.txt for more information)
+
+required:
+  - compatible
+  - mboxes
+
+examples:
+  - |
+    firmware {
+        compatible = "raspberrypi,bcm2835-firmware", "simple-bus";
+        mboxes = <&mailbox>;
+    };
+...
-- 
git-series 0.9.1

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH v5 02/27] dt-bindings: clock: Add a binding for the RPi Firmware clocks
  2020-06-15  8:40 [PATCH v5 00/27] clk: bcm: rpi: Add support for BCM2711 firmware clocks Maxime Ripard
  2020-06-15  8:40 ` [PATCH v5 01/27] dt-bindings: arm: bcm: Convert BCM2835 firmware binding to YAML Maxime Ripard
@ 2020-06-15  8:40 ` Maxime Ripard
  2020-06-25  0:42   ` Stephen Boyd
  2020-06-15  8:40 ` [PATCH v5 03/27] firmware: rpi: Only create clocks device if we don't have a node for it Maxime Ripard
                   ` (26 subsequent siblings)
  28 siblings, 1 reply; 64+ messages in thread
From: Maxime Ripard @ 2020-06-15  8:40 UTC (permalink / raw)
  To: Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, Stephen Boyd, linux-clk, Philipp Zabel,
	Maxime Ripard, devicetree, Rob Herring

The firmware running on the RPi VideoCore can be used to discover and
change the various clocks running in the BCM2711. Since devices will
need to use them through the DT, let's add a pretty simple binding.

Cc: Michael Turquette <mturquette@baylibre.com>
Cc: linux-clk@vger.kernel.org
Cc: devicetree@vger.kernel.org
Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Reviewed-by: Rob Herring <robh+dt@kernel.org>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
 Documentation/devicetree/bindings/arm/bcm/raspberrypi,bcm2835-firmware.yaml | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/Documentation/devicetree/bindings/arm/bcm/raspberrypi,bcm2835-firmware.yaml b/Documentation/devicetree/bindings/arm/bcm/raspberrypi,bcm2835-firmware.yaml
index cec540c052b6..b48ed875eb8e 100644
--- a/Documentation/devicetree/bindings/arm/bcm/raspberrypi,bcm2835-firmware.yaml
+++ b/Documentation/devicetree/bindings/arm/bcm/raspberrypi,bcm2835-firmware.yaml
@@ -22,6 +22,25 @@ properties:
       Phandle to the firmware device's Mailbox.
       (See: ../mailbox/mailbox.txt for more information)
 
+  clocks:
+    type: object
+
+    properties:
+      compatible:
+        const: raspberrypi,firmware-clocks
+
+      "#clock-cells":
+        const: 1
+        description: >
+          The argument is the ID of the clocks contained by the
+          firmware messages.
+
+    required:
+      - compatible
+      - "#clock-cells"
+
+    additionalProperties: false
+
 required:
   - compatible
   - mboxes
@@ -31,5 +50,10 @@ examples:
     firmware {
         compatible = "raspberrypi,bcm2835-firmware", "simple-bus";
         mboxes = <&mailbox>;
+
+        firmware_clocks: clocks {
+            compatible = "raspberrypi,firmware-clocks";
+            #clock-cells = <1>;
+        };
     };
 ...
-- 
git-series 0.9.1

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH v5 03/27] firmware: rpi: Only create clocks device if we don't have a node for it
  2020-06-15  8:40 [PATCH v5 00/27] clk: bcm: rpi: Add support for BCM2711 firmware clocks Maxime Ripard
  2020-06-15  8:40 ` [PATCH v5 01/27] dt-bindings: arm: bcm: Convert BCM2835 firmware binding to YAML Maxime Ripard
  2020-06-15  8:40 ` [PATCH v5 02/27] dt-bindings: clock: Add a binding for the RPi Firmware clocks Maxime Ripard
@ 2020-06-15  8:40 ` Maxime Ripard
  2020-06-25  0:42   ` Stephen Boyd
  2020-06-15  8:40 ` [PATCH v5 04/27] clk: bcm: rpi: Allow the driver to be probed by DT Maxime Ripard
                   ` (25 subsequent siblings)
  28 siblings, 1 reply; 64+ messages in thread
From: Maxime Ripard @ 2020-06-15  8:40 UTC (permalink / raw)
  To: Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, Stephen Boyd, linux-clk, Philipp Zabel,
	Maxime Ripard

The firmware clocks driver was previously probed through a platform_device
created by the firmware driver.

Since we will now have a node for that clocks driver, we need to create the
device only in the case where there's no node for it already.

Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
 drivers/firmware/raspberrypi.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/firmware/raspberrypi.c b/drivers/firmware/raspberrypi.c
index ef8098856a47..b25901a77c09 100644
--- a/drivers/firmware/raspberrypi.c
+++ b/drivers/firmware/raspberrypi.c
@@ -208,6 +208,20 @@ rpi_register_hwmon_driver(struct device *dev, struct rpi_firmware *fw)
 
 static void rpi_register_clk_driver(struct device *dev)
 {
+	struct device_node *firmware;
+
+	/*
+	 * Earlier DTs don't have a node for the firmware clocks but
+	 * rely on us creating a platform device by hand. If we do
+	 * have a node for the firmware clocks, just bail out here.
+	 */
+	firmware = of_get_compatible_child(dev->of_node,
+					   "raspberrypi,firmware-clocks");
+	if (firmware) {
+		of_node_put(firmware);
+		return;
+	}
+
 	rpi_clk = platform_device_register_data(dev, "raspberrypi-clk",
 						-1, NULL, 0);
 }
-- 
git-series 0.9.1

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH v5 04/27] clk: bcm: rpi: Allow the driver to be probed by DT
  2020-06-15  8:40 [PATCH v5 00/27] clk: bcm: rpi: Add support for BCM2711 firmware clocks Maxime Ripard
                   ` (2 preceding siblings ...)
  2020-06-15  8:40 ` [PATCH v5 03/27] firmware: rpi: Only create clocks device if we don't have a node for it Maxime Ripard
@ 2020-06-15  8:40 ` Maxime Ripard
  2020-06-25  0:42   ` Stephen Boyd
  2020-06-15  8:40 ` [PATCH v5 05/27] clk: bcm: rpi: Statically init clk_init_data Maxime Ripard
                   ` (24 subsequent siblings)
  28 siblings, 1 reply; 64+ messages in thread
From: Maxime Ripard @ 2020-06-15  8:40 UTC (permalink / raw)
  To: Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, Stephen Boyd, linux-clk, Philipp Zabel,
	Maxime Ripard

The current firmware clock driver for the RaspberryPi can only be probed by
manually registering an associated platform_device.

While this works fine for cpufreq where the device gets attached a clkdev
lookup, it would be tedious to maintain a table of all the devices using
one of the clocks exposed by the firmware.

Since the DT on the other hand is the perfect place to store those
associations, make the firmware clocks driver probe-able through the device
tree so that we can represent it as a node.

Cc: Michael Turquette <mturquette@baylibre.com>
Cc: linux-clk@vger.kernel.org
Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
 drivers/clk/bcm/clk-raspberrypi.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/bcm/clk-raspberrypi.c b/drivers/clk/bcm/clk-raspberrypi.c
index 1654fd0eedc9..8610355bda47 100644
--- a/drivers/clk/bcm/clk-raspberrypi.c
+++ b/drivers/clk/bcm/clk-raspberrypi.c
@@ -255,8 +255,16 @@ static int raspberrypi_clk_probe(struct platform_device *pdev)
 	struct raspberrypi_clk *rpi;
 	int ret;
 
-	firmware_node = of_find_compatible_node(NULL, NULL,
-					"raspberrypi,bcm2835-firmware");
+	/*
+	 * We can be probed either through the an old-fashioned
+	 * platform device registration or through a DT node that is a
+	 * child of the firmware node. Handle both cases.
+	 */
+	if (dev->of_node)
+		firmware_node = of_get_parent(dev->of_node);
+	else
+		firmware_node = of_find_compatible_node(NULL, NULL,
+							"raspberrypi,bcm2835-firmware");
 	if (!firmware_node) {
 		dev_err(dev, "Missing firmware node\n");
 		return -ENOENT;
@@ -300,9 +308,16 @@ static int raspberrypi_clk_remove(struct platform_device *pdev)
 	return 0;
 }
 
+static const struct of_device_id raspberrypi_clk_match[] = {
+	{ .compatible = "raspberrypi,firmware-clocks" },
+	{ },
+};
+MODULE_DEVICE_TABLE(of, raspberrypi_clk_match);
+
 static struct platform_driver raspberrypi_clk_driver = {
 	.driver = {
 		.name = "raspberrypi-clk",
+		.of_match_table = raspberrypi_clk_match,
 	},
 	.probe          = raspberrypi_clk_probe,
 	.remove		= raspberrypi_clk_remove,
-- 
git-series 0.9.1

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH v5 05/27] clk: bcm: rpi: Statically init clk_init_data
  2020-06-15  8:40 [PATCH v5 00/27] clk: bcm: rpi: Add support for BCM2711 firmware clocks Maxime Ripard
                   ` (3 preceding siblings ...)
  2020-06-15  8:40 ` [PATCH v5 04/27] clk: bcm: rpi: Allow the driver to be probed by DT Maxime Ripard
@ 2020-06-15  8:40 ` Maxime Ripard
  2020-06-25  0:42   ` Stephen Boyd
  2020-06-15  8:40 ` [PATCH v5 06/27] clk: bcm: rpi: Use clk_hw_register for pllb_arm Maxime Ripard
                   ` (23 subsequent siblings)
  28 siblings, 1 reply; 64+ messages in thread
From: Maxime Ripard @ 2020-06-15  8:40 UTC (permalink / raw)
  To: Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, Stephen Boyd, linux-clk, Philipp Zabel,
	Maxime Ripard

Instead of declaring the clk_init_data and then calling memset on it, just
initialise properly.

Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Stephen Boyd <sboyd@kernel.org>
Cc: linux-clk@vger.kernel.org
Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
 drivers/clk/bcm/clk-raspberrypi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/clk/bcm/clk-raspberrypi.c b/drivers/clk/bcm/clk-raspberrypi.c
index 8610355bda47..ddc72207212e 100644
--- a/drivers/clk/bcm/clk-raspberrypi.c
+++ b/drivers/clk/bcm/clk-raspberrypi.c
@@ -175,11 +175,10 @@ static const struct clk_ops raspberrypi_firmware_pll_clk_ops = {
 
 static int raspberrypi_register_pllb(struct raspberrypi_clk *rpi)
 {
+	struct clk_init_data init = {};
 	u32 min_rate = 0, max_rate = 0;
-	struct clk_init_data init;
 	int ret;
 
-	memset(&init, 0, sizeof(init));
 
 	/* All of the PLLs derive from the external oscillator. */
 	init.parent_names = (const char *[]){ "osc" };
-- 
git-series 0.9.1

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH v5 06/27] clk: bcm: rpi: Use clk_hw_register for pllb_arm
  2020-06-15  8:40 [PATCH v5 00/27] clk: bcm: rpi: Add support for BCM2711 firmware clocks Maxime Ripard
                   ` (4 preceding siblings ...)
  2020-06-15  8:40 ` [PATCH v5 05/27] clk: bcm: rpi: Statically init clk_init_data Maxime Ripard
@ 2020-06-15  8:40 ` Maxime Ripard
  2020-06-25  0:42   ` Stephen Boyd
  2020-06-15  8:40 ` [PATCH v5 07/27] clk: bcm: rpi: Remove global pllb_arm clock pointer Maxime Ripard
                   ` (22 subsequent siblings)
  28 siblings, 1 reply; 64+ messages in thread
From: Maxime Ripard @ 2020-06-15  8:40 UTC (permalink / raw)
  To: Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, Stephen Boyd, linux-clk, Philipp Zabel,
	Maxime Ripard

The pllb_arm clock is defined as a fixed factor clock with the pllb
clock as a parent. However, all its configuration is entirely static,
and thus we don't really need to call clk_hw_register_fixed_factor() but
can simply call clk_hw_register() with a static clk_fixed_factor
structure.

Cc: Michael Turquette <mturquette@baylibre.com>
Cc: linux-clk@vger.kernel.org
Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
 drivers/clk/bcm/clk-raspberrypi.c | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/drivers/clk/bcm/clk-raspberrypi.c b/drivers/clk/bcm/clk-raspberrypi.c
index ddc72207212e..5f0d4875e145 100644
--- a/drivers/clk/bcm/clk-raspberrypi.c
+++ b/drivers/clk/bcm/clk-raspberrypi.c
@@ -225,16 +225,28 @@ static int raspberrypi_register_pllb(struct raspberrypi_clk *rpi)
 	return devm_clk_hw_register(rpi->dev, &rpi->pllb);
 }
 
+static struct clk_fixed_factor raspberrypi_clk_pllb_arm = {
+	.mult = 1,
+	.div = 2,
+	.hw.init = &(struct clk_init_data) {
+		.name		= "pllb_arm",
+		.parent_names	= (const char *[]){ "pllb" },
+		.num_parents	= 1,
+		.ops		= &clk_fixed_factor_ops,
+		.flags		= CLK_SET_RATE_PARENT | CLK_GET_RATE_NOCACHE,
+	},
+};
+
 static int raspberrypi_register_pllb_arm(struct raspberrypi_clk *rpi)
 {
-	rpi->pllb_arm = clk_hw_register_fixed_factor(rpi->dev,
-				"pllb_arm", "pllb",
-				CLK_SET_RATE_PARENT | CLK_GET_RATE_NOCACHE,
-				1, 2);
-	if (IS_ERR(rpi->pllb_arm)) {
+	int ret;
+
+	ret = clk_hw_register(rpi->dev, &raspberrypi_clk_pllb_arm.hw);
+	if (ret) {
 		dev_err(rpi->dev, "Failed to initialize pllb_arm\n");
-		return PTR_ERR(rpi->pllb_arm);
+		return ret;
 	}
+	rpi->pllb_arm = &raspberrypi_clk_pllb_arm.hw;
 
 	rpi->pllb_arm_lookup = clkdev_hw_create(rpi->pllb_arm, NULL, "cpu0");
 	if (!rpi->pllb_arm_lookup) {
-- 
git-series 0.9.1

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH v5 07/27] clk: bcm: rpi: Remove global pllb_arm clock pointer
  2020-06-15  8:40 [PATCH v5 00/27] clk: bcm: rpi: Add support for BCM2711 firmware clocks Maxime Ripard
                   ` (5 preceding siblings ...)
  2020-06-15  8:40 ` [PATCH v5 06/27] clk: bcm: rpi: Use clk_hw_register for pllb_arm Maxime Ripard
@ 2020-06-15  8:40 ` Maxime Ripard
  2020-06-25  0:42   ` Stephen Boyd
  2020-06-15  8:40 ` [PATCH v5 08/27] clk: bcm: rpi: Make sure pllb_arm is removed Maxime Ripard
                   ` (21 subsequent siblings)
  28 siblings, 1 reply; 64+ messages in thread
From: Maxime Ripard @ 2020-06-15  8:40 UTC (permalink / raw)
  To: Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, Stephen Boyd, linux-clk, Philipp Zabel,
	Maxime Ripard

The pllb_arm clk_hw pointer in the raspberry_clk structure isn't used
anywhere but in the raspberrypi_register_pllb_arm.

Let's remove it, this will make our lives easier in future patches.

Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Stephen Boyd <sboyd@kernel.org>
Cc: linux-clk@vger.kernel.org
Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
 drivers/clk/bcm/clk-raspberrypi.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/clk/bcm/clk-raspberrypi.c b/drivers/clk/bcm/clk-raspberrypi.c
index 5f0d4875e145..b21dd6ddc4fe 100644
--- a/drivers/clk/bcm/clk-raspberrypi.c
+++ b/drivers/clk/bcm/clk-raspberrypi.c
@@ -40,7 +40,6 @@ struct raspberrypi_clk {
 	unsigned long max_rate;
 
 	struct clk_hw pllb;
-	struct clk_hw *pllb_arm;
 	struct clk_lookup *pllb_arm_lookup;
 };
 
@@ -246,12 +245,12 @@ static int raspberrypi_register_pllb_arm(struct raspberrypi_clk *rpi)
 		dev_err(rpi->dev, "Failed to initialize pllb_arm\n");
 		return ret;
 	}
-	rpi->pllb_arm = &raspberrypi_clk_pllb_arm.hw;
 
-	rpi->pllb_arm_lookup = clkdev_hw_create(rpi->pllb_arm, NULL, "cpu0");
+	rpi->pllb_arm_lookup = clkdev_hw_create(&raspberrypi_clk_pllb_arm.hw,
+						NULL, "cpu0");
 	if (!rpi->pllb_arm_lookup) {
 		dev_err(rpi->dev, "Failed to initialize pllb_arm_lookup\n");
-		clk_hw_unregister_fixed_factor(rpi->pllb_arm);
+		clk_hw_unregister_fixed_factor(&raspberrypi_clk_pllb_arm.hw);
 		return -ENOMEM;
 	}
 
-- 
git-series 0.9.1

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH v5 08/27] clk: bcm: rpi: Make sure pllb_arm is removed
  2020-06-15  8:40 [PATCH v5 00/27] clk: bcm: rpi: Add support for BCM2711 firmware clocks Maxime Ripard
                   ` (6 preceding siblings ...)
  2020-06-15  8:40 ` [PATCH v5 07/27] clk: bcm: rpi: Remove global pllb_arm clock pointer Maxime Ripard
@ 2020-06-15  8:40 ` Maxime Ripard
  2020-06-25  0:42   ` Stephen Boyd
  2020-06-15  8:40 ` [PATCH v5 09/27] clk: bcm: rpi: Remove pllb_arm_lookup global pointer Maxime Ripard
                   ` (20 subsequent siblings)
  28 siblings, 1 reply; 64+ messages in thread
From: Maxime Ripard @ 2020-06-15  8:40 UTC (permalink / raw)
  To: Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, Stephen Boyd, linux-clk, Philipp Zabel,
	Maxime Ripard

The pllb_arm clock was created at probe time, but was never removed if
something went wrong later in probe, or if the driver was ever removed from
the system.

Now that we are using clk_hw_register(), we can just use its managed variant
to take care of that for us.

Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Stephen Boyd <sboyd@kernel.org>
Cc: linux-clk@vger.kernel.org
Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
 drivers/clk/bcm/clk-raspberrypi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/clk/bcm/clk-raspberrypi.c b/drivers/clk/bcm/clk-raspberrypi.c
index b21dd6ddc4fe..d62605861028 100644
--- a/drivers/clk/bcm/clk-raspberrypi.c
+++ b/drivers/clk/bcm/clk-raspberrypi.c
@@ -240,7 +240,7 @@ static int raspberrypi_register_pllb_arm(struct raspberrypi_clk *rpi)
 {
 	int ret;
 
-	ret = clk_hw_register(rpi->dev, &raspberrypi_clk_pllb_arm.hw);
+	ret = devm_clk_hw_register(rpi->dev, &raspberrypi_clk_pllb_arm.hw);
 	if (ret) {
 		dev_err(rpi->dev, "Failed to initialize pllb_arm\n");
 		return ret;
@@ -250,7 +250,6 @@ static int raspberrypi_register_pllb_arm(struct raspberrypi_clk *rpi)
 						NULL, "cpu0");
 	if (!rpi->pllb_arm_lookup) {
 		dev_err(rpi->dev, "Failed to initialize pllb_arm_lookup\n");
-		clk_hw_unregister_fixed_factor(&raspberrypi_clk_pllb_arm.hw);
 		return -ENOMEM;
 	}
 
-- 
git-series 0.9.1

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH v5 09/27] clk: bcm: rpi: Remove pllb_arm_lookup global pointer
  2020-06-15  8:40 [PATCH v5 00/27] clk: bcm: rpi: Add support for BCM2711 firmware clocks Maxime Ripard
                   ` (7 preceding siblings ...)
  2020-06-15  8:40 ` [PATCH v5 08/27] clk: bcm: rpi: Make sure pllb_arm is removed Maxime Ripard
@ 2020-06-15  8:40 ` Maxime Ripard
  2020-06-25  0:42   ` Stephen Boyd
  2020-06-25  0:44   ` Stephen Boyd
  2020-06-15  8:40 ` [PATCH v5 10/27] clk: bcm: rpi: Switch to clk_hw_register_clkdev Maxime Ripard
                   ` (19 subsequent siblings)
  28 siblings, 2 replies; 64+ messages in thread
From: Maxime Ripard @ 2020-06-15  8:40 UTC (permalink / raw)
  To: Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, Stephen Boyd, linux-clk, Philipp Zabel,
	Maxime Ripard

The pllb_arm_lookup pointer in the struct raspberrypi_clk is not used for
anything but to store the returned pointer to clkdev_hw_create, and is not
used anywhere else in the driver.

Let's remove that global pointer from the structure.

Cc: Michael Turquette <mturquette@baylibre.com>
Cc: linux-clk@vger.kernel.org
Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
 drivers/clk/bcm/clk-raspberrypi.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/clk/bcm/clk-raspberrypi.c b/drivers/clk/bcm/clk-raspberrypi.c
index d62605861028..5a06c4991c7f 100644
--- a/drivers/clk/bcm/clk-raspberrypi.c
+++ b/drivers/clk/bcm/clk-raspberrypi.c
@@ -40,7 +40,6 @@ struct raspberrypi_clk {
 	unsigned long max_rate;
 
 	struct clk_hw pllb;
-	struct clk_lookup *pllb_arm_lookup;
 };
 
 /*
@@ -238,6 +237,7 @@ static struct clk_fixed_factor raspberrypi_clk_pllb_arm = {
 
 static int raspberrypi_register_pllb_arm(struct raspberrypi_clk *rpi)
 {
+	struct clk_lookup *pllb_arm_lookup;
 	int ret;
 
 	ret = devm_clk_hw_register(rpi->dev, &raspberrypi_clk_pllb_arm.hw);
@@ -246,9 +246,9 @@ static int raspberrypi_register_pllb_arm(struct raspberrypi_clk *rpi)
 		return ret;
 	}
 
-	rpi->pllb_arm_lookup = clkdev_hw_create(&raspberrypi_clk_pllb_arm.hw,
-						NULL, "cpu0");
-	if (!rpi->pllb_arm_lookup) {
+	pllb_arm_lookup = clkdev_hw_create(&raspberrypi_clk_pllb_arm.hw,
+					   NULL, "cpu0");
+	if (!pllb_arm_lookup) {
 		dev_err(rpi->dev, "Failed to initialize pllb_arm_lookup\n");
 		return -ENOMEM;
 	}
-- 
git-series 0.9.1

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH v5 10/27] clk: bcm: rpi: Switch to clk_hw_register_clkdev
  2020-06-15  8:40 [PATCH v5 00/27] clk: bcm: rpi: Add support for BCM2711 firmware clocks Maxime Ripard
                   ` (8 preceding siblings ...)
  2020-06-15  8:40 ` [PATCH v5 09/27] clk: bcm: rpi: Remove pllb_arm_lookup global pointer Maxime Ripard
@ 2020-06-15  8:40 ` Maxime Ripard
  2020-06-25  0:44   ` Stephen Boyd
  2020-06-15  8:40 ` [PATCH v5 11/27] clk: bcm: rpi: Make sure the clkdev lookup is removed Maxime Ripard
                   ` (18 subsequent siblings)
  28 siblings, 1 reply; 64+ messages in thread
From: Maxime Ripard @ 2020-06-15  8:40 UTC (permalink / raw)
  To: Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, Stephen Boyd, linux-clk, Philipp Zabel,
	Maxime Ripard

Since we don't care about retrieving the clk_lookup structure pointer
returned by clkdev_hw_create, we can just use the clk_hw_register_clkdev
function.

Cc: Michael Turquette <mturquette@baylibre.com>
Cc: linux-clk@vger.kernel.org
Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
 drivers/clk/bcm/clk-raspberrypi.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/clk/bcm/clk-raspberrypi.c b/drivers/clk/bcm/clk-raspberrypi.c
index 5a06c4991c7f..23f06618a356 100644
--- a/drivers/clk/bcm/clk-raspberrypi.c
+++ b/drivers/clk/bcm/clk-raspberrypi.c
@@ -237,7 +237,6 @@ static struct clk_fixed_factor raspberrypi_clk_pllb_arm = {
 
 static int raspberrypi_register_pllb_arm(struct raspberrypi_clk *rpi)
 {
-	struct clk_lookup *pllb_arm_lookup;
 	int ret;
 
 	ret = devm_clk_hw_register(rpi->dev, &raspberrypi_clk_pllb_arm.hw);
@@ -246,11 +245,11 @@ static int raspberrypi_register_pllb_arm(struct raspberrypi_clk *rpi)
 		return ret;
 	}
 
-	pllb_arm_lookup = clkdev_hw_create(&raspberrypi_clk_pllb_arm.hw,
-					   NULL, "cpu0");
-	if (!pllb_arm_lookup) {
-		dev_err(rpi->dev, "Failed to initialize pllb_arm_lookup\n");
-		return -ENOMEM;
+	ret = clk_hw_register_clkdev(&raspberrypi_clk_pllb_arm.hw,
+				     NULL, "cpu0");
+	if (ret) {
+		dev_err(rpi->dev, "Failed to initialize clkdev\n");
+		return ret;
 	}
 
 	return 0;
-- 
git-series 0.9.1

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH v5 11/27] clk: bcm: rpi: Make sure the clkdev lookup is removed
  2020-06-15  8:40 [PATCH v5 00/27] clk: bcm: rpi: Add support for BCM2711 firmware clocks Maxime Ripard
                   ` (9 preceding siblings ...)
  2020-06-15  8:40 ` [PATCH v5 10/27] clk: bcm: rpi: Switch to clk_hw_register_clkdev Maxime Ripard
@ 2020-06-15  8:40 ` Maxime Ripard
  2020-06-25  0:44   ` Stephen Boyd
  2020-06-15  8:40 ` [PATCH v5 12/27] clk: bcm: rpi: Use CCF boundaries instead of rolling our own Maxime Ripard
                   ` (17 subsequent siblings)
  28 siblings, 1 reply; 64+ messages in thread
From: Maxime Ripard @ 2020-06-15  8:40 UTC (permalink / raw)
  To: Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, Stephen Boyd, linux-clk, Philipp Zabel,
	Maxime Ripard

The clkdev lookup created for the cpufreq device is never removed if
there's an issue later in probe or at module removal time.

Let's convert to the managed variant of the clk_hw_register_clkdev function
to make sure it happens.

Cc: Michael Turquette <mturquette@baylibre.com>
Cc: linux-clk@vger.kernel.org
Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
 drivers/clk/bcm/clk-raspberrypi.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/bcm/clk-raspberrypi.c b/drivers/clk/bcm/clk-raspberrypi.c
index 23f06618a356..a20492fade6a 100644
--- a/drivers/clk/bcm/clk-raspberrypi.c
+++ b/drivers/clk/bcm/clk-raspberrypi.c
@@ -245,8 +245,9 @@ static int raspberrypi_register_pllb_arm(struct raspberrypi_clk *rpi)
 		return ret;
 	}
 
-	ret = clk_hw_register_clkdev(&raspberrypi_clk_pllb_arm.hw,
-				     NULL, "cpu0");
+	ret = devm_clk_hw_register_clkdev(rpi->dev,
+					  &raspberrypi_clk_pllb_arm.hw,
+					  NULL, "cpu0");
 	if (ret) {
 		dev_err(rpi->dev, "Failed to initialize clkdev\n");
 		return ret;
-- 
git-series 0.9.1

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH v5 12/27] clk: bcm: rpi: Use CCF boundaries instead of rolling our own
  2020-06-15  8:40 [PATCH v5 00/27] clk: bcm: rpi: Add support for BCM2711 firmware clocks Maxime Ripard
                   ` (10 preceding siblings ...)
  2020-06-15  8:40 ` [PATCH v5 11/27] clk: bcm: rpi: Make sure the clkdev lookup is removed Maxime Ripard
@ 2020-06-15  8:40 ` Maxime Ripard
  2020-06-25  0:44   ` Stephen Boyd
  2020-06-15  8:40 ` [PATCH v5 13/27] clk: bcm: rpi: Create a data structure for the clocks Maxime Ripard
                   ` (16 subsequent siblings)
  28 siblings, 1 reply; 64+ messages in thread
From: Maxime Ripard @ 2020-06-15  8:40 UTC (permalink / raw)
  To: Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, Stephen Boyd, linux-clk, Philipp Zabel,
	Maxime Ripard

The raspberrypi firmware clock driver has a min_rate / max_rate clamping by
storing the info it needs in a private structure.

However, the CCF already provides such a facility, so we can switch to it
to remove the boilerplate.

Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
 drivers/clk/bcm/clk-raspberrypi.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/drivers/clk/bcm/clk-raspberrypi.c b/drivers/clk/bcm/clk-raspberrypi.c
index a20492fade6a..e135ad28d38d 100644
--- a/drivers/clk/bcm/clk-raspberrypi.c
+++ b/drivers/clk/bcm/clk-raspberrypi.c
@@ -36,9 +36,6 @@ struct raspberrypi_clk {
 	struct rpi_firmware *firmware;
 	struct platform_device *cpufreq;
 
-	unsigned long min_rate;
-	unsigned long max_rate;
-
 	struct clk_hw pllb;
 };
 
@@ -142,13 +139,11 @@ static int raspberrypi_fw_pll_set_rate(struct clk_hw *hw, unsigned long rate,
 static int raspberrypi_pll_determine_rate(struct clk_hw *hw,
 					  struct clk_rate_request *req)
 {
-	struct raspberrypi_clk *rpi = container_of(hw, struct raspberrypi_clk,
-						   pllb);
 	u64 div, final_rate;
 	u32 ndiv, fdiv;
 
 	/* We can't use req->rate directly as it would overflow */
-	final_rate = clamp(req->rate, rpi->min_rate, rpi->max_rate);
+	final_rate = clamp(req->rate, req->min_rate, req->max_rate);
 
 	div = (u64)final_rate << A2W_PLL_FRAC_BITS;
 	do_div(div, req->best_parent_rate);
@@ -215,12 +210,15 @@ static int raspberrypi_register_pllb(struct raspberrypi_clk *rpi)
 	dev_info(rpi->dev, "CPU frequency range: min %u, max %u\n",
 		 min_rate, max_rate);
 
-	rpi->min_rate = min_rate * RPI_FIRMWARE_PLLB_ARM_DIV_RATE;
-	rpi->max_rate = max_rate * RPI_FIRMWARE_PLLB_ARM_DIV_RATE;
-
 	rpi->pllb.init = &init;
 
-	return devm_clk_hw_register(rpi->dev, &rpi->pllb);
+	ret = devm_clk_hw_register(rpi->dev, &rpi->pllb);
+	if (!ret)
+		clk_hw_set_rate_range(&rpi->pllb,
+				      min_rate * RPI_FIRMWARE_PLLB_ARM_DIV_RATE,
+				      max_rate * RPI_FIRMWARE_PLLB_ARM_DIV_RATE);
+
+	return ret;
 }
 
 static struct clk_fixed_factor raspberrypi_clk_pllb_arm = {
-- 
git-series 0.9.1

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH v5 13/27] clk: bcm: rpi: Create a data structure for the clocks
  2020-06-15  8:40 [PATCH v5 00/27] clk: bcm: rpi: Add support for BCM2711 firmware clocks Maxime Ripard
                   ` (11 preceding siblings ...)
  2020-06-15  8:40 ` [PATCH v5 12/27] clk: bcm: rpi: Use CCF boundaries instead of rolling our own Maxime Ripard
@ 2020-06-15  8:40 ` Maxime Ripard
  2020-06-25  0:44   ` Stephen Boyd
  2020-06-15  8:40 ` [PATCH v5 14/27] clk: bcm: rpi: Add clock id to data Maxime Ripard
                   ` (15 subsequent siblings)
  28 siblings, 1 reply; 64+ messages in thread
From: Maxime Ripard @ 2020-06-15  8:40 UTC (permalink / raw)
  To: Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, Stephen Boyd, linux-clk, Philipp Zabel,
	Maxime Ripard

So far the driver has really only been providing a single clock, and stored
both the data associated to that clock in particular with the data
associated to the "controller".

Since we will change that in the future, let's decouple the clock data from
the provider data.

Cc: Michael Turquette <mturquette@baylibre.com>
Cc: linux-clk@vger.kernel.org
Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
 drivers/clk/bcm/clk-raspberrypi.c | 31 +++++++++++++++++++++----------
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/drivers/clk/bcm/clk-raspberrypi.c b/drivers/clk/bcm/clk-raspberrypi.c
index e135ad28d38d..00735704eabc 100644
--- a/drivers/clk/bcm/clk-raspberrypi.c
+++ b/drivers/clk/bcm/clk-raspberrypi.c
@@ -35,8 +35,11 @@ struct raspberrypi_clk {
 	struct device *dev;
 	struct rpi_firmware *firmware;
 	struct platform_device *cpufreq;
+};
 
-	struct clk_hw pllb;
+struct raspberrypi_clk_data {
+	struct clk_hw hw;
+	struct raspberrypi_clk *rpi;
 };
 
 /*
@@ -80,8 +83,9 @@ static int raspberrypi_clock_property(struct rpi_firmware *firmware, u32 tag,
 
 static int raspberrypi_fw_pll_is_on(struct clk_hw *hw)
 {
-	struct raspberrypi_clk *rpi = container_of(hw, struct raspberrypi_clk,
-						   pllb);
+	struct raspberrypi_clk_data *data =
+		container_of(hw, struct raspberrypi_clk_data, hw);
+	struct raspberrypi_clk *rpi = data->rpi;
 	u32 val = 0;
 	int ret;
 
@@ -98,8 +102,9 @@ static int raspberrypi_fw_pll_is_on(struct clk_hw *hw)
 static unsigned long raspberrypi_fw_pll_get_rate(struct clk_hw *hw,
 						 unsigned long parent_rate)
 {
-	struct raspberrypi_clk *rpi = container_of(hw, struct raspberrypi_clk,
-						   pllb);
+	struct raspberrypi_clk_data *data =
+		container_of(hw, struct raspberrypi_clk_data, hw);
+	struct raspberrypi_clk *rpi = data->rpi;
 	u32 val = 0;
 	int ret;
 
@@ -116,8 +121,9 @@ static unsigned long raspberrypi_fw_pll_get_rate(struct clk_hw *hw,
 static int raspberrypi_fw_pll_set_rate(struct clk_hw *hw, unsigned long rate,
 				       unsigned long parent_rate)
 {
-	struct raspberrypi_clk *rpi = container_of(hw, struct raspberrypi_clk,
-						   pllb);
+	struct raspberrypi_clk_data *data =
+		container_of(hw, struct raspberrypi_clk_data, hw);
+	struct raspberrypi_clk *rpi = data->rpi;
 	u32 new_rate = rate / RPI_FIRMWARE_PLLB_ARM_DIV_RATE;
 	int ret;
 
@@ -168,10 +174,15 @@ static const struct clk_ops raspberrypi_firmware_pll_clk_ops = {
 
 static int raspberrypi_register_pllb(struct raspberrypi_clk *rpi)
 {
+	struct raspberrypi_clk_data *data;
 	struct clk_init_data init = {};
 	u32 min_rate = 0, max_rate = 0;
 	int ret;
 
+	data = devm_kzalloc(rpi->dev, sizeof(*data), GFP_KERNEL);
+	if (!data)
+		return -ENOMEM;
+	data->rpi = rpi;
 
 	/* All of the PLLs derive from the external oscillator. */
 	init.parent_names = (const char *[]){ "osc" };
@@ -210,11 +221,11 @@ static int raspberrypi_register_pllb(struct raspberrypi_clk *rpi)
 	dev_info(rpi->dev, "CPU frequency range: min %u, max %u\n",
 		 min_rate, max_rate);
 
-	rpi->pllb.init = &init;
+	data->hw.init = &init;
 
-	ret = devm_clk_hw_register(rpi->dev, &rpi->pllb);
+	ret = devm_clk_hw_register(rpi->dev, &data->hw);
 	if (!ret)
-		clk_hw_set_rate_range(&rpi->pllb,
+		clk_hw_set_rate_range(&data->hw,
 				      min_rate * RPI_FIRMWARE_PLLB_ARM_DIV_RATE,
 				      max_rate * RPI_FIRMWARE_PLLB_ARM_DIV_RATE);
 
-- 
git-series 0.9.1

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH v5 14/27] clk: bcm: rpi: Add clock id to data
  2020-06-15  8:40 [PATCH v5 00/27] clk: bcm: rpi: Add support for BCM2711 firmware clocks Maxime Ripard
                   ` (12 preceding siblings ...)
  2020-06-15  8:40 ` [PATCH v5 13/27] clk: bcm: rpi: Create a data structure for the clocks Maxime Ripard
@ 2020-06-15  8:40 ` Maxime Ripard
  2020-06-25  0:45   ` Stephen Boyd
  2020-06-15  8:40 ` [PATCH v5 15/27] clk: bcm: rpi: Pass the clocks data to the firmware function Maxime Ripard
                   ` (14 subsequent siblings)
  28 siblings, 1 reply; 64+ messages in thread
From: Maxime Ripard @ 2020-06-15  8:40 UTC (permalink / raw)
  To: Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, Stephen Boyd, linux-clk, Philipp Zabel,
	Maxime Ripard

The driver has really only supported one clock so far and has hardcoded the
ID used in communications with the firmware in all the functions
implementing the clock framework hooks. Let's store that in the clock data
structure so that we can support more clocks later on.

Cc: Michael Turquette <mturquette@baylibre.com>
Cc: linux-clk@vger.kernel.org
Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
 drivers/clk/bcm/clk-raspberrypi.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/clk/bcm/clk-raspberrypi.c b/drivers/clk/bcm/clk-raspberrypi.c
index 00735704eabc..97ac04604b0a 100644
--- a/drivers/clk/bcm/clk-raspberrypi.c
+++ b/drivers/clk/bcm/clk-raspberrypi.c
@@ -39,6 +39,9 @@ struct raspberrypi_clk {
 
 struct raspberrypi_clk_data {
 	struct clk_hw hw;
+
+	unsigned int id;
+
 	struct raspberrypi_clk *rpi;
 };
 
@@ -91,7 +94,7 @@ static int raspberrypi_fw_pll_is_on(struct clk_hw *hw)
 
 	ret = raspberrypi_clock_property(rpi->firmware,
 					 RPI_FIRMWARE_GET_CLOCK_STATE,
-					 RPI_FIRMWARE_ARM_CLK_ID, &val);
+					 data->id, &val);
 	if (ret)
 		return 0;
 
@@ -110,8 +113,7 @@ static unsigned long raspberrypi_fw_pll_get_rate(struct clk_hw *hw,
 
 	ret = raspberrypi_clock_property(rpi->firmware,
 					 RPI_FIRMWARE_GET_CLOCK_RATE,
-					 RPI_FIRMWARE_ARM_CLK_ID,
-					 &val);
+					 data->id, &val);
 	if (ret)
 		return ret;
 
@@ -129,8 +131,7 @@ static int raspberrypi_fw_pll_set_rate(struct clk_hw *hw, unsigned long rate,
 
 	ret = raspberrypi_clock_property(rpi->firmware,
 					 RPI_FIRMWARE_SET_CLOCK_RATE,
-					 RPI_FIRMWARE_ARM_CLK_ID,
-					 &new_rate);
+					 data->id, &new_rate);
 	if (ret)
 		dev_err_ratelimited(rpi->dev, "Failed to change %s frequency: %d",
 				    clk_hw_get_name(hw), ret);
@@ -183,6 +184,7 @@ static int raspberrypi_register_pllb(struct raspberrypi_clk *rpi)
 	if (!data)
 		return -ENOMEM;
 	data->rpi = rpi;
+	data->id = RPI_FIRMWARE_ARM_CLK_ID;
 
 	/* All of the PLLs derive from the external oscillator. */
 	init.parent_names = (const char *[]){ "osc" };
@@ -194,8 +196,7 @@ static int raspberrypi_register_pllb(struct raspberrypi_clk *rpi)
 	/* Get min & max rates set by the firmware */
 	ret = raspberrypi_clock_property(rpi->firmware,
 					 RPI_FIRMWARE_GET_MIN_CLOCK_RATE,
-					 RPI_FIRMWARE_ARM_CLK_ID,
-					 &min_rate);
+					 data->id, &min_rate);
 	if (ret) {
 		dev_err(rpi->dev, "Failed to get %s min freq: %d\n",
 			init.name, ret);
@@ -204,8 +205,7 @@ static int raspberrypi_register_pllb(struct raspberrypi_clk *rpi)
 
 	ret = raspberrypi_clock_property(rpi->firmware,
 					 RPI_FIRMWARE_GET_MAX_CLOCK_RATE,
-					 RPI_FIRMWARE_ARM_CLK_ID,
-					 &max_rate);
+					 data->id, &max_rate);
 	if (ret) {
 		dev_err(rpi->dev, "Failed to get %s max freq: %d\n",
 			init.name, ret);
-- 
git-series 0.9.1

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH v5 15/27] clk: bcm: rpi: Pass the clocks data to the firmware function
  2020-06-15  8:40 [PATCH v5 00/27] clk: bcm: rpi: Add support for BCM2711 firmware clocks Maxime Ripard
                   ` (13 preceding siblings ...)
  2020-06-15  8:40 ` [PATCH v5 14/27] clk: bcm: rpi: Add clock id to data Maxime Ripard
@ 2020-06-15  8:40 ` Maxime Ripard
  2020-06-25  0:45   ` Stephen Boyd
  2020-06-15  8:40 ` [PATCH v5 16/27] clk: bcm: rpi: Rename is_prepared function Maxime Ripard
                   ` (13 subsequent siblings)
  28 siblings, 1 reply; 64+ messages in thread
From: Maxime Ripard @ 2020-06-15  8:40 UTC (permalink / raw)
  To: Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, Stephen Boyd, linux-clk, Philipp Zabel,
	Maxime Ripard

The raspberry_clock_property only takes the clock ID as an argument, but
now that we have a clock data structure it makes more sense to just pass
that structure instead.

Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Stephen Boyd <sboyd@kernel.org>
Cc: linux-clk@vger.kernel.org
Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
 drivers/clk/bcm/clk-raspberrypi.c | 29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/drivers/clk/bcm/clk-raspberrypi.c b/drivers/clk/bcm/clk-raspberrypi.c
index 97ac04604b0a..3fce49a65a79 100644
--- a/drivers/clk/bcm/clk-raspberrypi.c
+++ b/drivers/clk/bcm/clk-raspberrypi.c
@@ -65,11 +65,12 @@ struct raspberrypi_firmware_prop {
 	__le32 disable_turbo;
 } __packed;
 
-static int raspberrypi_clock_property(struct rpi_firmware *firmware, u32 tag,
-				      u32 clk, u32 *val)
+static int raspberrypi_clock_property(struct rpi_firmware *firmware,
+				      const struct raspberrypi_clk_data *data,
+				      u32 tag, u32 *val)
 {
 	struct raspberrypi_firmware_prop msg = {
-		.id = cpu_to_le32(clk),
+		.id = cpu_to_le32(data->id),
 		.val = cpu_to_le32(*val),
 		.disable_turbo = cpu_to_le32(1),
 	};
@@ -92,9 +93,8 @@ static int raspberrypi_fw_pll_is_on(struct clk_hw *hw)
 	u32 val = 0;
 	int ret;
 
-	ret = raspberrypi_clock_property(rpi->firmware,
-					 RPI_FIRMWARE_GET_CLOCK_STATE,
-					 data->id, &val);
+	ret = raspberrypi_clock_property(rpi->firmware, data,
+					 RPI_FIRMWARE_GET_CLOCK_STATE, &val);
 	if (ret)
 		return 0;
 
@@ -111,9 +111,8 @@ static unsigned long raspberrypi_fw_pll_get_rate(struct clk_hw *hw,
 	u32 val = 0;
 	int ret;
 
-	ret = raspberrypi_clock_property(rpi->firmware,
-					 RPI_FIRMWARE_GET_CLOCK_RATE,
-					 data->id, &val);
+	ret = raspberrypi_clock_property(rpi->firmware, data,
+					 RPI_FIRMWARE_GET_CLOCK_RATE, &val);
 	if (ret)
 		return ret;
 
@@ -129,9 +128,9 @@ static int raspberrypi_fw_pll_set_rate(struct clk_hw *hw, unsigned long rate,
 	u32 new_rate = rate / RPI_FIRMWARE_PLLB_ARM_DIV_RATE;
 	int ret;
 
-	ret = raspberrypi_clock_property(rpi->firmware,
+	ret = raspberrypi_clock_property(rpi->firmware, data,
 					 RPI_FIRMWARE_SET_CLOCK_RATE,
-					 data->id, &new_rate);
+					 &new_rate);
 	if (ret)
 		dev_err_ratelimited(rpi->dev, "Failed to change %s frequency: %d",
 				    clk_hw_get_name(hw), ret);
@@ -194,18 +193,18 @@ static int raspberrypi_register_pllb(struct raspberrypi_clk *rpi)
 	init.flags = CLK_GET_RATE_NOCACHE | CLK_IGNORE_UNUSED;
 
 	/* Get min & max rates set by the firmware */
-	ret = raspberrypi_clock_property(rpi->firmware,
+	ret = raspberrypi_clock_property(rpi->firmware, data,
 					 RPI_FIRMWARE_GET_MIN_CLOCK_RATE,
-					 data->id, &min_rate);
+					 &min_rate);
 	if (ret) {
 		dev_err(rpi->dev, "Failed to get %s min freq: %d\n",
 			init.name, ret);
 		return ret;
 	}
 
-	ret = raspberrypi_clock_property(rpi->firmware,
+	ret = raspberrypi_clock_property(rpi->firmware, data,
 					 RPI_FIRMWARE_GET_MAX_CLOCK_RATE,
-					 data->id, &max_rate);
+					 &max_rate);
 	if (ret) {
 		dev_err(rpi->dev, "Failed to get %s max freq: %d\n",
 			init.name, ret);
-- 
git-series 0.9.1

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH v5 16/27] clk: bcm: rpi: Rename is_prepared function
  2020-06-15  8:40 [PATCH v5 00/27] clk: bcm: rpi: Add support for BCM2711 firmware clocks Maxime Ripard
                   ` (14 preceding siblings ...)
  2020-06-15  8:40 ` [PATCH v5 15/27] clk: bcm: rpi: Pass the clocks data to the firmware function Maxime Ripard
@ 2020-06-15  8:40 ` Maxime Ripard
  2020-06-25  0:45   ` Stephen Boyd
  2020-06-15  8:40 ` [PATCH v5 17/27] clk: bcm: rpi: Split pllb clock hooks Maxime Ripard
                   ` (12 subsequent siblings)
  28 siblings, 1 reply; 64+ messages in thread
From: Maxime Ripard @ 2020-06-15  8:40 UTC (permalink / raw)
  To: Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, Stephen Boyd, linux-clk, Philipp Zabel,
	Maxime Ripard

The raspberrypi_fw_pll_is_on function doesn't only apply to PLL
registered in the driver, but any clock exposed by the firmware.

Since we also implement the is_prepared hook, make the function
consistent with the other function names.

Cc: Michael Turquette <mturquette@baylibre.com>
Cc: linux-clk@vger.kernel.org
Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
 drivers/clk/bcm/clk-raspberrypi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/bcm/clk-raspberrypi.c b/drivers/clk/bcm/clk-raspberrypi.c
index 3fce49a65a79..58ac1b104429 100644
--- a/drivers/clk/bcm/clk-raspberrypi.c
+++ b/drivers/clk/bcm/clk-raspberrypi.c
@@ -85,7 +85,7 @@ static int raspberrypi_clock_property(struct rpi_firmware *firmware,
 	return 0;
 }
 
-static int raspberrypi_fw_pll_is_on(struct clk_hw *hw)
+static int raspberrypi_fw_is_prepared(struct clk_hw *hw)
 {
 	struct raspberrypi_clk_data *data =
 		container_of(hw, struct raspberrypi_clk_data, hw);
@@ -166,7 +166,7 @@ static int raspberrypi_pll_determine_rate(struct clk_hw *hw,
 }
 
 static const struct clk_ops raspberrypi_firmware_pll_clk_ops = {
-	.is_prepared = raspberrypi_fw_pll_is_on,
+	.is_prepared = raspberrypi_fw_is_prepared,
 	.recalc_rate = raspberrypi_fw_pll_get_rate,
 	.set_rate = raspberrypi_fw_pll_set_rate,
 	.determine_rate = raspberrypi_pll_determine_rate,
-- 
git-series 0.9.1

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH v5 17/27] clk: bcm: rpi: Split pllb clock hooks
  2020-06-15  8:40 [PATCH v5 00/27] clk: bcm: rpi: Add support for BCM2711 firmware clocks Maxime Ripard
                   ` (15 preceding siblings ...)
  2020-06-15  8:40 ` [PATCH v5 16/27] clk: bcm: rpi: Rename is_prepared function Maxime Ripard
@ 2020-06-15  8:40 ` Maxime Ripard
  2020-06-25  0:45   ` Stephen Boyd
  2020-06-15  8:40 ` [PATCH v5 18/27] clk: bcm: rpi: Make the PLLB registration function return a clk_hw Maxime Ripard
                   ` (11 subsequent siblings)
  28 siblings, 1 reply; 64+ messages in thread
From: Maxime Ripard @ 2020-06-15  8:40 UTC (permalink / raw)
  To: Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, Stephen Boyd, linux-clk, Philipp Zabel,
	Maxime Ripard

The driver only supports the pllb for now and all the clock framework hooks
are a mix of the generic firmware interface and the specifics of the pllb.
Since we will support more clocks in the future let's split the generic and
specific hooks

Cc: Michael Turquette <mturquette@baylibre.com>
Cc: linux-clk@vger.kernel.org
Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
 drivers/clk/bcm/clk-raspberrypi.c | 30 ++++++++++++++++++++++--------
 1 file changed, 22 insertions(+), 8 deletions(-)

diff --git a/drivers/clk/bcm/clk-raspberrypi.c b/drivers/clk/bcm/clk-raspberrypi.c
index 58ac1b104429..19571602ba64 100644
--- a/drivers/clk/bcm/clk-raspberrypi.c
+++ b/drivers/clk/bcm/clk-raspberrypi.c
@@ -102,8 +102,8 @@ static int raspberrypi_fw_is_prepared(struct clk_hw *hw)
 }
 
 
-static unsigned long raspberrypi_fw_pll_get_rate(struct clk_hw *hw,
-						 unsigned long parent_rate)
+static unsigned long raspberrypi_fw_get_rate(struct clk_hw *hw,
+					     unsigned long parent_rate)
 {
 	struct raspberrypi_clk_data *data =
 		container_of(hw, struct raspberrypi_clk_data, hw);
@@ -116,21 +116,27 @@ static unsigned long raspberrypi_fw_pll_get_rate(struct clk_hw *hw,
 	if (ret)
 		return ret;
 
-	return val * RPI_FIRMWARE_PLLB_ARM_DIV_RATE;
+	return val;
 }
 
-static int raspberrypi_fw_pll_set_rate(struct clk_hw *hw, unsigned long rate,
-				       unsigned long parent_rate)
+static unsigned long raspberrypi_fw_pll_get_rate(struct clk_hw *hw,
+						 unsigned long parent_rate)
+{
+	return raspberrypi_fw_get_rate(hw, parent_rate) *
+		RPI_FIRMWARE_PLLB_ARM_DIV_RATE;
+}
+
+static int raspberrypi_fw_set_rate(struct clk_hw *hw, unsigned long rate,
+				   unsigned long parent_rate)
 {
 	struct raspberrypi_clk_data *data =
 		container_of(hw, struct raspberrypi_clk_data, hw);
 	struct raspberrypi_clk *rpi = data->rpi;
-	u32 new_rate = rate / RPI_FIRMWARE_PLLB_ARM_DIV_RATE;
+	u32 _rate = rate;
 	int ret;
 
 	ret = raspberrypi_clock_property(rpi->firmware, data,
-					 RPI_FIRMWARE_SET_CLOCK_RATE,
-					 &new_rate);
+					 RPI_FIRMWARE_SET_CLOCK_RATE, &_rate);
 	if (ret)
 		dev_err_ratelimited(rpi->dev, "Failed to change %s frequency: %d",
 				    clk_hw_get_name(hw), ret);
@@ -138,6 +144,14 @@ static int raspberrypi_fw_pll_set_rate(struct clk_hw *hw, unsigned long rate,
 	return ret;
 }
 
+static int raspberrypi_fw_pll_set_rate(struct clk_hw *hw, unsigned long rate,
+				       unsigned long parent_rate)
+{
+	u32 new_rate = rate / RPI_FIRMWARE_PLLB_ARM_DIV_RATE;
+
+	return raspberrypi_fw_set_rate(hw, new_rate, parent_rate);
+}
+
 /*
  * Sadly there is no firmware rate rounding interface. We borrowed it from
  * clk-bcm2835.
-- 
git-series 0.9.1

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH v5 18/27] clk: bcm: rpi: Make the PLLB registration function return a clk_hw
  2020-06-15  8:40 [PATCH v5 00/27] clk: bcm: rpi: Add support for BCM2711 firmware clocks Maxime Ripard
                   ` (16 preceding siblings ...)
  2020-06-15  8:40 ` [PATCH v5 17/27] clk: bcm: rpi: Split pllb clock hooks Maxime Ripard
@ 2020-06-15  8:40 ` Maxime Ripard
  2020-06-25  0:45   ` Stephen Boyd
  2020-06-15  8:40 ` [PATCH v5 19/27] clk: bcm: rpi: Add DT provider for the clocks Maxime Ripard
                   ` (10 subsequent siblings)
  28 siblings, 1 reply; 64+ messages in thread
From: Maxime Ripard @ 2020-06-15  8:40 UTC (permalink / raw)
  To: Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, Stephen Boyd, linux-clk, Philipp Zabel,
	Maxime Ripard

The raspberrypi_register_pllb has been returning an integer so far to
notify whether the functions has exited successfully or not.

However, the OF provider functions in the clock framework require access to
the clk_hw structure so that we can expose those clocks to device tree
consumers.

Since we'll want that for the future clocks, let's return a clk_hw pointer
instead of the return code.

Cc: Michael Turquette <mturquette@baylibre.com>
Cc: linux-clk@vger.kernel.org
Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
 drivers/clk/bcm/clk-raspberrypi.c | 46 ++++++++++++++++----------------
 1 file changed, 24 insertions(+), 22 deletions(-)

diff --git a/drivers/clk/bcm/clk-raspberrypi.c b/drivers/clk/bcm/clk-raspberrypi.c
index 19571602ba64..d2cb90c086a7 100644
--- a/drivers/clk/bcm/clk-raspberrypi.c
+++ b/drivers/clk/bcm/clk-raspberrypi.c
@@ -186,7 +186,7 @@ static const struct clk_ops raspberrypi_firmware_pll_clk_ops = {
 	.determine_rate = raspberrypi_pll_determine_rate,
 };
 
-static int raspberrypi_register_pllb(struct raspberrypi_clk *rpi)
+static struct clk_hw *raspberrypi_register_pllb(struct raspberrypi_clk *rpi)
 {
 	struct raspberrypi_clk_data *data;
 	struct clk_init_data init = {};
@@ -195,7 +195,7 @@ static int raspberrypi_register_pllb(struct raspberrypi_clk *rpi)
 
 	data = devm_kzalloc(rpi->dev, sizeof(*data), GFP_KERNEL);
 	if (!data)
-		return -ENOMEM;
+		return ERR_PTR(-ENOMEM);
 	data->rpi = rpi;
 	data->id = RPI_FIRMWARE_ARM_CLK_ID;
 
@@ -213,7 +213,7 @@ static int raspberrypi_register_pllb(struct raspberrypi_clk *rpi)
 	if (ret) {
 		dev_err(rpi->dev, "Failed to get %s min freq: %d\n",
 			init.name, ret);
-		return ret;
+		return ERR_PTR(ret);
 	}
 
 	ret = raspberrypi_clock_property(rpi->firmware, data,
@@ -222,13 +222,13 @@ static int raspberrypi_register_pllb(struct raspberrypi_clk *rpi)
 	if (ret) {
 		dev_err(rpi->dev, "Failed to get %s max freq: %d\n",
 			init.name, ret);
-		return ret;
+		return ERR_PTR(ret);
 	}
 
 	if (!min_rate || !max_rate) {
 		dev_err(rpi->dev, "Unexpected frequency range: min %u, max %u\n",
 			min_rate, max_rate);
-		return -EINVAL;
+		return ERR_PTR(-EINVAL);
 	}
 
 	dev_info(rpi->dev, "CPU frequency range: min %u, max %u\n",
@@ -237,12 +237,14 @@ static int raspberrypi_register_pllb(struct raspberrypi_clk *rpi)
 	data->hw.init = &init;
 
 	ret = devm_clk_hw_register(rpi->dev, &data->hw);
-	if (!ret)
-		clk_hw_set_rate_range(&data->hw,
-				      min_rate * RPI_FIRMWARE_PLLB_ARM_DIV_RATE,
-				      max_rate * RPI_FIRMWARE_PLLB_ARM_DIV_RATE);
+	if (ret)
+		return ERR_PTR(ret);
 
-	return ret;
+	clk_hw_set_rate_range(&data->hw,
+			      min_rate * RPI_FIRMWARE_PLLB_ARM_DIV_RATE,
+			      max_rate * RPI_FIRMWARE_PLLB_ARM_DIV_RATE);
+
+	return &data->hw;
 }
 
 static struct clk_fixed_factor raspberrypi_clk_pllb_arm = {
@@ -257,14 +259,14 @@ static struct clk_fixed_factor raspberrypi_clk_pllb_arm = {
 	},
 };
 
-static int raspberrypi_register_pllb_arm(struct raspberrypi_clk *rpi)
+static struct clk_hw *raspberrypi_register_pllb_arm(struct raspberrypi_clk *rpi)
 {
 	int ret;
 
 	ret = devm_clk_hw_register(rpi->dev, &raspberrypi_clk_pllb_arm.hw);
 	if (ret) {
 		dev_err(rpi->dev, "Failed to initialize pllb_arm\n");
-		return ret;
+		return ERR_PTR(ret);
 	}
 
 	ret = devm_clk_hw_register_clkdev(rpi->dev,
@@ -272,10 +274,10 @@ static int raspberrypi_register_pllb_arm(struct raspberrypi_clk *rpi)
 					  NULL, "cpu0");
 	if (ret) {
 		dev_err(rpi->dev, "Failed to initialize clkdev\n");
-		return ret;
+		return ERR_PTR(ret);
 	}
 
-	return 0;
+	return &raspberrypi_clk_pllb_arm.hw;
 }
 
 static int raspberrypi_clk_probe(struct platform_device *pdev)
@@ -284,7 +286,7 @@ static int raspberrypi_clk_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct rpi_firmware *firmware;
 	struct raspberrypi_clk *rpi;
-	int ret;
+	struct clk_hw *hw;
 
 	/*
 	 * We can be probed either through the an old-fashioned
@@ -314,15 +316,15 @@ static int raspberrypi_clk_probe(struct platform_device *pdev)
 	rpi->firmware = firmware;
 	platform_set_drvdata(pdev, rpi);
 
-	ret = raspberrypi_register_pllb(rpi);
-	if (ret) {
-		dev_err(dev, "Failed to initialize pllb, %d\n", ret);
-		return ret;
+	hw = raspberrypi_register_pllb(rpi);
+	if (IS_ERR(hw)) {
+		dev_err(dev, "Failed to initialize pllb, %ld\n", PTR_ERR(hw));
+		return PTR_ERR(hw);
 	}
 
-	ret = raspberrypi_register_pllb_arm(rpi);
-	if (ret)
-		return ret;
+	hw = raspberrypi_register_pllb_arm(rpi);
+	if (IS_ERR(hw))
+		return PTR_ERR(hw);
 
 	rpi->cpufreq = platform_device_register_data(dev, "raspberrypi-cpufreq",
 						     -1, NULL, 0);
-- 
git-series 0.9.1

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH v5 19/27] clk: bcm: rpi: Add DT provider for the clocks
  2020-06-15  8:40 [PATCH v5 00/27] clk: bcm: rpi: Add support for BCM2711 firmware clocks Maxime Ripard
                   ` (17 preceding siblings ...)
  2020-06-15  8:40 ` [PATCH v5 18/27] clk: bcm: rpi: Make the PLLB registration function return a clk_hw Maxime Ripard
@ 2020-06-15  8:40 ` Maxime Ripard
  2020-06-25  0:45   ` Stephen Boyd
  2020-06-15  8:41 ` [PATCH v5 20/27] clk: bcm: rpi: Add an enum for the firmware clocks Maxime Ripard
                   ` (9 subsequent siblings)
  28 siblings, 1 reply; 64+ messages in thread
From: Maxime Ripard @ 2020-06-15  8:40 UTC (permalink / raw)
  To: Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, Stephen Boyd, linux-clk, Philipp Zabel,
	Maxime Ripard

For the upcoming registration of the clocks provided by the firmware, make
sure it's exposed to the device tree providers.

Cc: Michael Turquette <mturquette@baylibre.com>
Cc: linux-clk@vger.kernel.org
Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
 drivers/clk/bcm/clk-raspberrypi.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/clk/bcm/clk-raspberrypi.c b/drivers/clk/bcm/clk-raspberrypi.c
index d2cb90c086a7..5f4e2d49432f 100644
--- a/drivers/clk/bcm/clk-raspberrypi.c
+++ b/drivers/clk/bcm/clk-raspberrypi.c
@@ -31,6 +31,8 @@
 
 #define A2W_PLL_FRAC_BITS		20
 
+#define NUM_FW_CLKS			16
+
 struct raspberrypi_clk {
 	struct device *dev;
 	struct rpi_firmware *firmware;
@@ -282,11 +284,13 @@ static struct clk_hw *raspberrypi_register_pllb_arm(struct raspberrypi_clk *rpi)
 
 static int raspberrypi_clk_probe(struct platform_device *pdev)
 {
+	struct clk_hw_onecell_data *clk_data;
 	struct device_node *firmware_node;
 	struct device *dev = &pdev->dev;
 	struct rpi_firmware *firmware;
 	struct raspberrypi_clk *rpi;
 	struct clk_hw *hw;
+	int ret;
 
 	/*
 	 * We can be probed either through the an old-fashioned
@@ -316,6 +320,11 @@ static int raspberrypi_clk_probe(struct platform_device *pdev)
 	rpi->firmware = firmware;
 	platform_set_drvdata(pdev, rpi);
 
+	clk_data = devm_kzalloc(dev, struct_size(clk_data, hws, NUM_FW_CLKS),
+				GFP_KERNEL);
+	if (!clk_data)
+		return -ENOMEM;
+
 	hw = raspberrypi_register_pllb(rpi);
 	if (IS_ERR(hw)) {
 		dev_err(dev, "Failed to initialize pllb, %ld\n", PTR_ERR(hw));
@@ -325,6 +334,13 @@ static int raspberrypi_clk_probe(struct platform_device *pdev)
 	hw = raspberrypi_register_pllb_arm(rpi);
 	if (IS_ERR(hw))
 		return PTR_ERR(hw);
+	clk_data->hws[RPI_FIRMWARE_ARM_CLK_ID] = hw;
+	clk_data->num = RPI_FIRMWARE_ARM_CLK_ID + 1;
+
+	ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get,
+					  clk_data);
+	if (ret)
+		return ret;
 
 	rpi->cpufreq = platform_device_register_data(dev, "raspberrypi-cpufreq",
 						     -1, NULL, 0);
-- 
git-series 0.9.1

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH v5 20/27] clk: bcm: rpi: Add an enum for the firmware clocks
  2020-06-15  8:40 [PATCH v5 00/27] clk: bcm: rpi: Add support for BCM2711 firmware clocks Maxime Ripard
                   ` (18 preceding siblings ...)
  2020-06-15  8:40 ` [PATCH v5 19/27] clk: bcm: rpi: Add DT provider for the clocks Maxime Ripard
@ 2020-06-15  8:41 ` Maxime Ripard
  2020-06-25  0:45   ` Stephen Boyd
  2020-06-15  8:41 ` [PATCH v5 21/27] clk: bcm: rpi: Discover " Maxime Ripard
                   ` (8 subsequent siblings)
  28 siblings, 1 reply; 64+ messages in thread
From: Maxime Ripard @ 2020-06-15  8:41 UTC (permalink / raw)
  To: Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, Stephen Boyd, linux-clk, Philipp Zabel,
	Maxime Ripard

While the firmware allows us to discover the available clocks, we need to
discriminate those clocks to only register the ones meaningful to Linux.
The firmware also doesn't provide a clock name, so having a list of the ID
will help us to give clocks a proper name later on.

Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
 drivers/clk/bcm/clk-raspberrypi.c | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/drivers/clk/bcm/clk-raspberrypi.c b/drivers/clk/bcm/clk-raspberrypi.c
index 5f4e2d49432f..eebd16040f8a 100644
--- a/drivers/clk/bcm/clk-raspberrypi.c
+++ b/drivers/clk/bcm/clk-raspberrypi.c
@@ -18,7 +18,23 @@
 
 #include <soc/bcm2835/raspberrypi-firmware.h>
 
-#define RPI_FIRMWARE_ARM_CLK_ID		0x00000003
+enum rpi_firmware_clk_id {
+	RPI_FIRMWARE_EMMC_CLK_ID = 1,
+	RPI_FIRMWARE_UART_CLK_ID,
+	RPI_FIRMWARE_ARM_CLK_ID,
+	RPI_FIRMWARE_CORE_CLK_ID,
+	RPI_FIRMWARE_V3D_CLK_ID,
+	RPI_FIRMWARE_H264_CLK_ID,
+	RPI_FIRMWARE_ISP_CLK_ID,
+	RPI_FIRMWARE_SDRAM_CLK_ID,
+	RPI_FIRMWARE_PIXEL_CLK_ID,
+	RPI_FIRMWARE_PWM_CLK_ID,
+	RPI_FIRMWARE_HEVC_CLK_ID,
+	RPI_FIRMWARE_EMMC2_CLK_ID,
+	RPI_FIRMWARE_M2MC_CLK_ID,
+	RPI_FIRMWARE_PIXEL_BVB_CLK_ID,
+	RPI_FIRMWARE_NUM_CLK_ID,
+};
 
 #define RPI_FIRMWARE_STATE_ENABLE_BIT	BIT(0)
 #define RPI_FIRMWARE_STATE_WAIT_BIT	BIT(1)
@@ -31,8 +47,6 @@
 
 #define A2W_PLL_FRAC_BITS		20
 
-#define NUM_FW_CLKS			16
-
 struct raspberrypi_clk {
 	struct device *dev;
 	struct rpi_firmware *firmware;
@@ -320,7 +334,8 @@ static int raspberrypi_clk_probe(struct platform_device *pdev)
 	rpi->firmware = firmware;
 	platform_set_drvdata(pdev, rpi);
 
-	clk_data = devm_kzalloc(dev, struct_size(clk_data, hws, NUM_FW_CLKS),
+	clk_data = devm_kzalloc(dev, struct_size(clk_data, hws,
+						 RPI_FIRMWARE_NUM_CLK_ID),
 				GFP_KERNEL);
 	if (!clk_data)
 		return -ENOMEM;
-- 
git-series 0.9.1

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH v5 21/27] clk: bcm: rpi: Discover the firmware clocks
  2020-06-15  8:40 [PATCH v5 00/27] clk: bcm: rpi: Add support for BCM2711 firmware clocks Maxime Ripard
                   ` (19 preceding siblings ...)
  2020-06-15  8:41 ` [PATCH v5 20/27] clk: bcm: rpi: Add an enum for the firmware clocks Maxime Ripard
@ 2020-06-15  8:41 ` Maxime Ripard
  2020-06-25  0:45   ` Stephen Boyd
  2020-06-15  8:41 ` [PATCH v5 22/27] clk: bcm: rpi: Give firmware clocks a name Maxime Ripard
                   ` (7 subsequent siblings)
  28 siblings, 1 reply; 64+ messages in thread
From: Maxime Ripard @ 2020-06-15  8:41 UTC (permalink / raw)
  To: Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, Stephen Boyd, linux-clk, Philipp Zabel,
	Maxime Ripard

The RaspberryPi4 firmware actually exposes more clocks than are currently
handled by the driver and we will need to change some of them directly
based on the pixel rate for the display related clocks, or the load for the
GPU.

Since the firmware implements DVFS, this rate change can have a number of
side-effects, including adjusting the various PLL voltages or the PLL
parents. The firmware also implements thermal throttling, so even some
thermal pressure can change those parameters behind Linux back.

DVFS is currently implemented on the arm, core, h264, v3d, isp and hevc
clocks, so updating any of them using the MMIO driver (and thus behind the
firmware's back) can lead to troubles, the arm clock obviously being the
most problematic.

In order to make Linux play as nice as possible with those constraints, it
makes sense to rely on the firmware clocks as much as possible. However,
the firmware doesn't seem to provide some equivalents to their MMIO
counterparts, so we can't really replace that driver entirely.

Fortunately, the firmware has an interface to discover the clocks it
exposes.

Let's use it to discover, register the clocks in the clocks framework and
then expose them through the device tree for consumers to use them.

Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Stephen Boyd <sboyd@kernel.org>
Cc: linux-clk@vger.kernel.org
Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
 drivers/clk/bcm/clk-raspberrypi.c | 153 ++++++++++++++++++++++++++++---
 1 file changed, 141 insertions(+), 12 deletions(-)

diff --git a/drivers/clk/bcm/clk-raspberrypi.c b/drivers/clk/bcm/clk-raspberrypi.c
index eebd16040f8a..11a62bde5203 100644
--- a/drivers/clk/bcm/clk-raspberrypi.c
+++ b/drivers/clk/bcm/clk-raspberrypi.c
@@ -296,6 +296,144 @@ static struct clk_hw *raspberrypi_register_pllb_arm(struct raspberrypi_clk *rpi)
 	return &raspberrypi_clk_pllb_arm.hw;
 }
 
+static int raspberrypi_fw_dumb_determine_rate(struct clk_hw *hw,
+					      struct clk_rate_request *req)
+{
+	/*
+	 * The firmware will do the rounding but that isn't part of
+	 * the interface with the firmware, so we just do our best
+	 * here.
+	 */
+	req->rate = clamp(req->rate, req->min_rate, req->max_rate);
+	return 0;
+}
+
+static const struct clk_ops raspberrypi_firmware_clk_ops = {
+	.is_prepared	= raspberrypi_fw_is_prepared,
+	.recalc_rate	= raspberrypi_fw_get_rate,
+	.determine_rate	= raspberrypi_fw_dumb_determine_rate,
+	.set_rate	= raspberrypi_fw_set_rate,
+};
+
+static struct clk_hw *raspberrypi_clk_register(struct raspberrypi_clk *rpi,
+					       unsigned int parent,
+					       unsigned int id)
+{
+	struct raspberrypi_clk_data *data;
+	struct clk_init_data init = {};
+	u32 min_rate, max_rate;
+	int ret;
+
+	if (id == RPI_FIRMWARE_ARM_CLK_ID) {
+		struct clk_hw *hw;
+
+		hw = raspberrypi_register_pllb(rpi);
+		if (IS_ERR(hw)) {
+			dev_err(rpi->dev, "Failed to initialize pllb, %ld\n",
+				PTR_ERR(hw));
+			return hw;
+		}
+
+		return raspberrypi_register_pllb_arm(rpi);
+	}
+
+	data = devm_kzalloc(rpi->dev, sizeof(*data), GFP_KERNEL);
+	if (!data)
+		return ERR_PTR(-ENOMEM);
+	data->rpi = rpi;
+	data->id = id;
+
+	init.name = devm_kasprintf(rpi->dev, GFP_KERNEL, "fw-clk-%u", id);
+	init.ops = &raspberrypi_firmware_clk_ops;
+	init.flags = CLK_GET_RATE_NOCACHE;
+
+	data->hw.init = &init;
+
+	ret = raspberrypi_clock_property(rpi->firmware, data,
+					 RPI_FIRMWARE_GET_MIN_CLOCK_RATE,
+					 &min_rate);
+	if (ret) {
+		dev_err(rpi->dev, "Failed to get clock %d min freq: %d",
+			id, ret);
+		return ERR_PTR(ret);
+	}
+
+	ret = raspberrypi_clock_property(rpi->firmware, data,
+					 RPI_FIRMWARE_GET_MAX_CLOCK_RATE,
+					 &max_rate);
+	if (ret) {
+		dev_err(rpi->dev, "Failed to get clock %d max freq: %d\n",
+			id, ret);
+		return ERR_PTR(ret);
+	}
+
+	ret = devm_clk_hw_register(rpi->dev, &data->hw);
+	if (ret)
+		return ERR_PTR(ret);
+
+	clk_hw_set_rate_range(&data->hw, min_rate, max_rate);
+
+	if (id == RPI_FIRMWARE_ARM_CLK_ID) {
+		ret = devm_clk_hw_register_clkdev(rpi->dev, &data->hw,
+						  NULL, "cpu0");
+		if (ret) {
+			dev_err(rpi->dev, "Failed to initialize clkdev\n");
+			return ERR_PTR(ret);
+		}
+	}
+
+	return &data->hw;
+}
+
+struct rpi_firmware_get_clocks_response {
+	u32 parent;
+	u32 id;
+};
+
+static int raspberrypi_discover_clocks(struct raspberrypi_clk *rpi,
+				       struct clk_hw_onecell_data *data)
+{
+	struct rpi_firmware_get_clocks_response *clks;
+	int ret;
+
+	clks = devm_kcalloc(rpi->dev,
+			    sizeof(*clks), RPI_FIRMWARE_NUM_CLK_ID,
+			    GFP_KERNEL);
+	if (!clks)
+		return -ENOMEM;
+
+	ret = rpi_firmware_property(rpi->firmware, RPI_FIRMWARE_GET_CLOCKS,
+				    clks,
+				    sizeof(*clks) * RPI_FIRMWARE_NUM_CLK_ID);
+	if (ret)
+		return ret;
+
+	while (clks->id) {
+		struct clk_hw *hw;
+
+		switch (clks->id) {
+		case RPI_FIRMWARE_ARM_CLK_ID:
+		case RPI_FIRMWARE_CORE_CLK_ID:
+		case RPI_FIRMWARE_M2MC_CLK_ID:
+		case RPI_FIRMWARE_V3D_CLK_ID:
+			hw = raspberrypi_clk_register(rpi, clks->parent,
+						      clks->id);
+			if (IS_ERR(hw))
+				return PTR_ERR(hw);
+
+			data->hws[clks->id] = hw;
+			data->num = clks->id + 1;
+			fallthrough;
+
+		default:
+			clks++;
+			break;
+		}
+	}
+
+	return 0;
+}
+
 static int raspberrypi_clk_probe(struct platform_device *pdev)
 {
 	struct clk_hw_onecell_data *clk_data;
@@ -303,7 +441,6 @@ static int raspberrypi_clk_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct rpi_firmware *firmware;
 	struct raspberrypi_clk *rpi;
-	struct clk_hw *hw;
 	int ret;
 
 	/*
@@ -340,17 +477,9 @@ static int raspberrypi_clk_probe(struct platform_device *pdev)
 	if (!clk_data)
 		return -ENOMEM;
 
-	hw = raspberrypi_register_pllb(rpi);
-	if (IS_ERR(hw)) {
-		dev_err(dev, "Failed to initialize pllb, %ld\n", PTR_ERR(hw));
-		return PTR_ERR(hw);
-	}
-
-	hw = raspberrypi_register_pllb_arm(rpi);
-	if (IS_ERR(hw))
-		return PTR_ERR(hw);
-	clk_data->hws[RPI_FIRMWARE_ARM_CLK_ID] = hw;
-	clk_data->num = RPI_FIRMWARE_ARM_CLK_ID + 1;
+	ret = raspberrypi_discover_clocks(rpi, clk_data);
+	if (ret)
+		return ret;
 
 	ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get,
 					  clk_data);
-- 
git-series 0.9.1

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH v5 22/27] clk: bcm: rpi: Give firmware clocks a name
  2020-06-15  8:40 [PATCH v5 00/27] clk: bcm: rpi: Add support for BCM2711 firmware clocks Maxime Ripard
                   ` (20 preceding siblings ...)
  2020-06-15  8:41 ` [PATCH v5 21/27] clk: bcm: rpi: Discover " Maxime Ripard
@ 2020-06-15  8:41 ` Maxime Ripard
  2020-06-25  0:45   ` Stephen Boyd
  2020-06-15  8:41 ` [PATCH v5 23/27] Revert "clk: bcm2835: remove pllb" Maxime Ripard
                   ` (6 subsequent siblings)
  28 siblings, 1 reply; 64+ messages in thread
From: Maxime Ripard @ 2020-06-15  8:41 UTC (permalink / raw)
  To: Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, Stephen Boyd, linux-clk, Philipp Zabel,
	Maxime Ripard

We've registered the firmware clocks using their ID as name, but it's much
more convenient to register them using their proper name. Since the
firmware doesn't provide it, we have to duplicate it.

Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
 drivers/clk/bcm/clk-raspberrypi.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/bcm/clk-raspberrypi.c b/drivers/clk/bcm/clk-raspberrypi.c
index 11a62bde5203..adc0bb56008a 100644
--- a/drivers/clk/bcm/clk-raspberrypi.c
+++ b/drivers/clk/bcm/clk-raspberrypi.c
@@ -36,6 +36,23 @@ enum rpi_firmware_clk_id {
 	RPI_FIRMWARE_NUM_CLK_ID,
 };
 
+static char *rpi_firmware_clk_names[] = {
+	[RPI_FIRMWARE_EMMC_CLK_ID]	= "emmc",
+	[RPI_FIRMWARE_UART_CLK_ID]	= "uart",
+	[RPI_FIRMWARE_ARM_CLK_ID]	= "arm",
+	[RPI_FIRMWARE_CORE_CLK_ID]	= "core",
+	[RPI_FIRMWARE_V3D_CLK_ID]	= "v3d",
+	[RPI_FIRMWARE_H264_CLK_ID]	= "h264",
+	[RPI_FIRMWARE_ISP_CLK_ID]	= "isp",
+	[RPI_FIRMWARE_SDRAM_CLK_ID]	= "sdram",
+	[RPI_FIRMWARE_PIXEL_CLK_ID]	= "pixel",
+	[RPI_FIRMWARE_PWM_CLK_ID]	= "pwm",
+	[RPI_FIRMWARE_HEVC_CLK_ID]	= "hevc",
+	[RPI_FIRMWARE_EMMC2_CLK_ID]	= "emmc2",
+	[RPI_FIRMWARE_M2MC_CLK_ID]	= "m2mc",
+	[RPI_FIRMWARE_PIXEL_BVB_CLK_ID]	= "pixel-bvb",
+};
+
 #define RPI_FIRMWARE_STATE_ENABLE_BIT	BIT(0)
 #define RPI_FIRMWARE_STATE_WAIT_BIT	BIT(1)
 
@@ -343,7 +360,9 @@ static struct clk_hw *raspberrypi_clk_register(struct raspberrypi_clk *rpi,
 	data->rpi = rpi;
 	data->id = id;
 
-	init.name = devm_kasprintf(rpi->dev, GFP_KERNEL, "fw-clk-%u", id);
+	init.name = devm_kasprintf(rpi->dev, GFP_KERNEL,
+				   "fw-clk-%s",
+				   rpi_firmware_clk_names[id]);
 	init.ops = &raspberrypi_firmware_clk_ops;
 	init.flags = CLK_GET_RATE_NOCACHE;
 
-- 
git-series 0.9.1

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH v5 23/27] Revert "clk: bcm2835: remove pllb"
  2020-06-15  8:40 [PATCH v5 00/27] clk: bcm: rpi: Add support for BCM2711 firmware clocks Maxime Ripard
                   ` (21 preceding siblings ...)
  2020-06-15  8:41 ` [PATCH v5 22/27] clk: bcm: rpi: Give firmware clocks a name Maxime Ripard
@ 2020-06-15  8:41 ` Maxime Ripard
  2020-06-25  0:45   ` Stephen Boyd
  2020-06-15  8:41 ` [PATCH v5 24/27] ARM: dts: bcm2711: Add firmware clocks node Maxime Ripard
                   ` (5 subsequent siblings)
  28 siblings, 1 reply; 64+ messages in thread
From: Maxime Ripard @ 2020-06-15  8:41 UTC (permalink / raw)
  To: Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, Stephen Boyd, linux-clk, Philipp Zabel,
	Maxime Ripard

This reverts commit 2256d89333bd17b8b56b42734a7e1046d52f7fc3. Since we
will be expanding the firmware clock driver, we'll need to remove the
quirks to deal with the PLLB. However, we still want to expose the clock
tree properly, so having that clock in the MMIO driver will allow that.

Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
 drivers/clk/bcm/clk-bcm2835.c | 30 ++++++++++++++++++++++++++----
 1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c
index 6bb7efa12037..32f5c13be9d1 100644
--- a/drivers/clk/bcm/clk-bcm2835.c
+++ b/drivers/clk/bcm/clk-bcm2835.c
@@ -1684,10 +1684,32 @@ static const struct bcm2835_clk_desc clk_desc_array[] = {
 		.fixed_divider = 1,
 		.flags = CLK_SET_RATE_PARENT),
 
-	/*
-	 * PLLB is used for the ARM's clock. Controlled by firmware, see
-	 * clk-raspberrypi.c.
-	 */
+	/* PLLB is used for the ARM's clock. */
+	[BCM2835_PLLB]		= REGISTER_PLL(
+		SOC_ALL,
+		.name = "pllb",
+		.cm_ctrl_reg = CM_PLLB,
+		.a2w_ctrl_reg = A2W_PLLB_CTRL,
+		.frac_reg = A2W_PLLB_FRAC,
+		.ana_reg_base = A2W_PLLB_ANA0,
+		.reference_enable_mask = A2W_XOSC_CTRL_PLLB_ENABLE,
+		.lock_mask = CM_LOCK_FLOCKB,
+
+		.ana = &bcm2835_ana_default,
+
+		.min_rate = 600000000u,
+		.max_rate = 3000000000u,
+		.max_fb_rate = BCM2835_MAX_FB_RATE),
+	[BCM2835_PLLB_ARM]	= REGISTER_PLL_DIV(
+		SOC_ALL,
+		.name = "pllb_arm",
+		.source_pll = "pllb",
+		.cm_reg = CM_PLLB,
+		.a2w_reg = A2W_PLLB_ARM,
+		.load_mask = CM_PLLB_LOADARM,
+		.hold_mask = CM_PLLB_HOLDARM,
+		.fixed_divider = 1,
+		.flags = CLK_SET_RATE_PARENT),
 
 	/*
 	 * PLLC is the core PLL, used to drive the core VPU clock.
-- 
git-series 0.9.1

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH v5 24/27] ARM: dts: bcm2711: Add firmware clocks node
  2020-06-15  8:40 [PATCH v5 00/27] clk: bcm: rpi: Add support for BCM2711 firmware clocks Maxime Ripard
                   ` (22 preceding siblings ...)
  2020-06-15  8:41 ` [PATCH v5 23/27] Revert "clk: bcm2835: remove pllb" Maxime Ripard
@ 2020-06-15  8:41 ` Maxime Ripard
  2020-06-25  8:16   ` Nicolas Saenz Julienne
  2020-06-15  8:41 ` [PATCH v5 25/27] clk: bcm2835: Allow custom CCF flags for the PLLs Maxime Ripard
                   ` (4 subsequent siblings)
  28 siblings, 1 reply; 64+ messages in thread
From: Maxime Ripard @ 2020-06-15  8:41 UTC (permalink / raw)
  To: Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, Stephen Boyd, linux-clk, Philipp Zabel,
	Maxime Ripard

Now that we have a clock driver for the clocks exposed by the firmware,
let's add the device tree nodes for it.

Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
 arch/arm/boot/dts/bcm2711-rpi-4-b.dts | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/boot/dts/bcm2711-rpi-4-b.dts b/arch/arm/boot/dts/bcm2711-rpi-4-b.dts
index c7f1d97e69bb..222d7825e1ab 100644
--- a/arch/arm/boot/dts/bcm2711-rpi-4-b.dts
+++ b/arch/arm/boot/dts/bcm2711-rpi-4-b.dts
@@ -69,6 +69,11 @@
 };
 
 &firmware {
+	firmware_clocks: clocks {
+		compatible = "raspberrypi,firmware-clocks";
+		#clock-cells = <1>;
+	};
+
 	expgpio: gpio {
 		compatible = "raspberrypi,firmware-gpio";
 		gpio-controller;
-- 
git-series 0.9.1

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH v5 25/27] clk: bcm2835: Allow custom CCF flags for the PLLs
  2020-06-15  8:40 [PATCH v5 00/27] clk: bcm: rpi: Add support for BCM2711 firmware clocks Maxime Ripard
                   ` (23 preceding siblings ...)
  2020-06-15  8:41 ` [PATCH v5 24/27] ARM: dts: bcm2711: Add firmware clocks node Maxime Ripard
@ 2020-06-15  8:41 ` Maxime Ripard
  2020-06-25  0:46   ` Stephen Boyd
  2020-06-15  8:41 ` [PATCH v5 26/27] clk: bcm2835: Don't cache the PLLB rate Maxime Ripard
                   ` (3 subsequent siblings)
  28 siblings, 1 reply; 64+ messages in thread
From: Maxime Ripard @ 2020-06-15  8:41 UTC (permalink / raw)
  To: Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, Stephen Boyd, linux-clk, Philipp Zabel,
	Maxime Ripard

While some clock types allow for each clock to specify its own custom
flags, the PLLs can't. We will need this for the PLLB, so let's add it.

Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
 drivers/clk/bcm/clk-bcm2835.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c
index 32f5c13be9d1..b50f00f109bf 100644
--- a/drivers/clk/bcm/clk-bcm2835.c
+++ b/drivers/clk/bcm/clk-bcm2835.c
@@ -421,6 +421,7 @@ struct bcm2835_pll_data {
 	u32 reference_enable_mask;
 	/* Bit in CM_LOCK to indicate when the PLL has locked. */
 	u32 lock_mask;
+	u32 flags;
 
 	const struct bcm2835_pll_ana_bits *ana;
 
@@ -1310,7 +1311,7 @@ static struct clk_hw *bcm2835_register_pll(struct bcm2835_cprman *cprman,
 	init.num_parents = 1;
 	init.name = pll_data->name;
 	init.ops = &bcm2835_pll_clk_ops;
-	init.flags = CLK_IGNORE_UNUSED;
+	init.flags = pll_data->flags | CLK_IGNORE_UNUSED;
 
 	pll = kzalloc(sizeof(*pll), GFP_KERNEL);
 	if (!pll)
-- 
git-series 0.9.1

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH v5 26/27] clk: bcm2835: Don't cache the PLLB rate
  2020-06-15  8:40 [PATCH v5 00/27] clk: bcm: rpi: Add support for BCM2711 firmware clocks Maxime Ripard
                   ` (24 preceding siblings ...)
  2020-06-15  8:41 ` [PATCH v5 25/27] clk: bcm2835: Allow custom CCF flags for the PLLs Maxime Ripard
@ 2020-06-15  8:41 ` Maxime Ripard
  2020-06-25  0:46   ` Stephen Boyd
  2020-06-15  8:41 ` [PATCH v5 27/27] clk: bcm: rpi: Remove the quirks for the CPU clock Maxime Ripard
                   ` (2 subsequent siblings)
  28 siblings, 1 reply; 64+ messages in thread
From: Maxime Ripard @ 2020-06-15  8:41 UTC (permalink / raw)
  To: Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, Stephen Boyd, linux-clk, Philipp Zabel,
	Maxime Ripard

The PLLB rate will be changed through the firmware clocks drivers and will
change behind this drivers' back, so we don't want to cache the rate.

Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
 drivers/clk/bcm/clk-bcm2835.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c
index b50f00f109bf..027eba31f793 100644
--- a/drivers/clk/bcm/clk-bcm2835.c
+++ b/drivers/clk/bcm/clk-bcm2835.c
@@ -1700,7 +1700,8 @@ static const struct bcm2835_clk_desc clk_desc_array[] = {
 
 		.min_rate = 600000000u,
 		.max_rate = 3000000000u,
-		.max_fb_rate = BCM2835_MAX_FB_RATE),
+		.max_fb_rate = BCM2835_MAX_FB_RATE,
+		.flags = CLK_GET_RATE_NOCACHE),
 	[BCM2835_PLLB_ARM]	= REGISTER_PLL_DIV(
 		SOC_ALL,
 		.name = "pllb_arm",
@@ -1710,7 +1711,7 @@ static const struct bcm2835_clk_desc clk_desc_array[] = {
 		.load_mask = CM_PLLB_LOADARM,
 		.hold_mask = CM_PLLB_HOLDARM,
 		.fixed_divider = 1,
-		.flags = CLK_SET_RATE_PARENT),
+		.flags = CLK_SET_RATE_PARENT | CLK_GET_RATE_NOCACHE),
 
 	/*
 	 * PLLC is the core PLL, used to drive the core VPU clock.
-- 
git-series 0.9.1

^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH v5 27/27] clk: bcm: rpi: Remove the quirks for the CPU clock
  2020-06-15  8:40 [PATCH v5 00/27] clk: bcm: rpi: Add support for BCM2711 firmware clocks Maxime Ripard
                   ` (25 preceding siblings ...)
  2020-06-15  8:41 ` [PATCH v5 26/27] clk: bcm2835: Don't cache the PLLB rate Maxime Ripard
@ 2020-06-15  8:41 ` Maxime Ripard
  2020-06-25  0:46   ` Stephen Boyd
  2020-06-19  9:37 ` [PATCH v5 00/27] clk: bcm: rpi: Add support for BCM2711 firmware clocks Stephen Boyd
  2020-06-25  1:15 ` Stephen Boyd
  28 siblings, 1 reply; 64+ messages in thread
From: Maxime Ripard @ 2020-06-15  8:41 UTC (permalink / raw)
  To: Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, Stephen Boyd, linux-clk, Philipp Zabel,
	Maxime Ripard

The CPU clock has had so far a bunch of quirks to expose the clock tree
properly, but since we reverted to exposing them through the MMIO driver,
we can remove that code from the firmware driver.

Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
 drivers/clk/bcm/clk-raspberrypi.c | 164 +-------------------------------
 1 file changed, 164 deletions(-)

diff --git a/drivers/clk/bcm/clk-raspberrypi.c b/drivers/clk/bcm/clk-raspberrypi.c
index adc0bb56008a..5cc82954e1ce 100644
--- a/drivers/clk/bcm/clk-raspberrypi.c
+++ b/drivers/clk/bcm/clk-raspberrypi.c
@@ -56,14 +56,6 @@ static char *rpi_firmware_clk_names[] = {
 #define RPI_FIRMWARE_STATE_ENABLE_BIT	BIT(0)
 #define RPI_FIRMWARE_STATE_WAIT_BIT	BIT(1)
 
-/*
- * Even though the firmware interface alters 'pllb' the frequencies are
- * provided as per 'pllb_arm'. We need to scale before passing them trough.
- */
-#define RPI_FIRMWARE_PLLB_ARM_DIV_RATE	2
-
-#define A2W_PLL_FRAC_BITS		20
-
 struct raspberrypi_clk {
 	struct device *dev;
 	struct rpi_firmware *firmware;
@@ -152,13 +144,6 @@ static unsigned long raspberrypi_fw_get_rate(struct clk_hw *hw,
 	return val;
 }
 
-static unsigned long raspberrypi_fw_pll_get_rate(struct clk_hw *hw,
-						 unsigned long parent_rate)
-{
-	return raspberrypi_fw_get_rate(hw, parent_rate) *
-		RPI_FIRMWARE_PLLB_ARM_DIV_RATE;
-}
-
 static int raspberrypi_fw_set_rate(struct clk_hw *hw, unsigned long rate,
 				   unsigned long parent_rate)
 {
@@ -177,142 +162,6 @@ static int raspberrypi_fw_set_rate(struct clk_hw *hw, unsigned long rate,
 	return ret;
 }
 
-static int raspberrypi_fw_pll_set_rate(struct clk_hw *hw, unsigned long rate,
-				       unsigned long parent_rate)
-{
-	u32 new_rate = rate / RPI_FIRMWARE_PLLB_ARM_DIV_RATE;
-
-	return raspberrypi_fw_set_rate(hw, new_rate, parent_rate);
-}
-
-/*
- * Sadly there is no firmware rate rounding interface. We borrowed it from
- * clk-bcm2835.
- */
-static int raspberrypi_pll_determine_rate(struct clk_hw *hw,
-					  struct clk_rate_request *req)
-{
-	u64 div, final_rate;
-	u32 ndiv, fdiv;
-
-	/* We can't use req->rate directly as it would overflow */
-	final_rate = clamp(req->rate, req->min_rate, req->max_rate);
-
-	div = (u64)final_rate << A2W_PLL_FRAC_BITS;
-	do_div(div, req->best_parent_rate);
-
-	ndiv = div >> A2W_PLL_FRAC_BITS;
-	fdiv = div & ((1 << A2W_PLL_FRAC_BITS) - 1);
-
-	final_rate = ((u64)req->best_parent_rate *
-					((ndiv << A2W_PLL_FRAC_BITS) + fdiv));
-
-	req->rate = final_rate >> A2W_PLL_FRAC_BITS;
-
-	return 0;
-}
-
-static const struct clk_ops raspberrypi_firmware_pll_clk_ops = {
-	.is_prepared = raspberrypi_fw_is_prepared,
-	.recalc_rate = raspberrypi_fw_pll_get_rate,
-	.set_rate = raspberrypi_fw_pll_set_rate,
-	.determine_rate = raspberrypi_pll_determine_rate,
-};
-
-static struct clk_hw *raspberrypi_register_pllb(struct raspberrypi_clk *rpi)
-{
-	struct raspberrypi_clk_data *data;
-	struct clk_init_data init = {};
-	u32 min_rate = 0, max_rate = 0;
-	int ret;
-
-	data = devm_kzalloc(rpi->dev, sizeof(*data), GFP_KERNEL);
-	if (!data)
-		return ERR_PTR(-ENOMEM);
-	data->rpi = rpi;
-	data->id = RPI_FIRMWARE_ARM_CLK_ID;
-
-	/* All of the PLLs derive from the external oscillator. */
-	init.parent_names = (const char *[]){ "osc" };
-	init.num_parents = 1;
-	init.name = "pllb";
-	init.ops = &raspberrypi_firmware_pll_clk_ops;
-	init.flags = CLK_GET_RATE_NOCACHE | CLK_IGNORE_UNUSED;
-
-	/* Get min & max rates set by the firmware */
-	ret = raspberrypi_clock_property(rpi->firmware, data,
-					 RPI_FIRMWARE_GET_MIN_CLOCK_RATE,
-					 &min_rate);
-	if (ret) {
-		dev_err(rpi->dev, "Failed to get %s min freq: %d\n",
-			init.name, ret);
-		return ERR_PTR(ret);
-	}
-
-	ret = raspberrypi_clock_property(rpi->firmware, data,
-					 RPI_FIRMWARE_GET_MAX_CLOCK_RATE,
-					 &max_rate);
-	if (ret) {
-		dev_err(rpi->dev, "Failed to get %s max freq: %d\n",
-			init.name, ret);
-		return ERR_PTR(ret);
-	}
-
-	if (!min_rate || !max_rate) {
-		dev_err(rpi->dev, "Unexpected frequency range: min %u, max %u\n",
-			min_rate, max_rate);
-		return ERR_PTR(-EINVAL);
-	}
-
-	dev_info(rpi->dev, "CPU frequency range: min %u, max %u\n",
-		 min_rate, max_rate);
-
-	data->hw.init = &init;
-
-	ret = devm_clk_hw_register(rpi->dev, &data->hw);
-	if (ret)
-		return ERR_PTR(ret);
-
-	clk_hw_set_rate_range(&data->hw,
-			      min_rate * RPI_FIRMWARE_PLLB_ARM_DIV_RATE,
-			      max_rate * RPI_FIRMWARE_PLLB_ARM_DIV_RATE);
-
-	return &data->hw;
-}
-
-static struct clk_fixed_factor raspberrypi_clk_pllb_arm = {
-	.mult = 1,
-	.div = 2,
-	.hw.init = &(struct clk_init_data) {
-		.name		= "pllb_arm",
-		.parent_names	= (const char *[]){ "pllb" },
-		.num_parents	= 1,
-		.ops		= &clk_fixed_factor_ops,
-		.flags		= CLK_SET_RATE_PARENT | CLK_GET_RATE_NOCACHE,
-	},
-};
-
-static struct clk_hw *raspberrypi_register_pllb_arm(struct raspberrypi_clk *rpi)
-{
-	int ret;
-
-	ret = devm_clk_hw_register(rpi->dev, &raspberrypi_clk_pllb_arm.hw);
-	if (ret) {
-		dev_err(rpi->dev, "Failed to initialize pllb_arm\n");
-		return ERR_PTR(ret);
-	}
-
-	ret = devm_clk_hw_register_clkdev(rpi->dev,
-					  &raspberrypi_clk_pllb_arm.hw,
-					  NULL, "cpu0");
-	if (ret) {
-		dev_err(rpi->dev, "Failed to initialize clkdev\n");
-		return ERR_PTR(ret);
-	}
-
-	return &raspberrypi_clk_pllb_arm.hw;
-}
-
 static int raspberrypi_fw_dumb_determine_rate(struct clk_hw *hw,
 					      struct clk_rate_request *req)
 {
@@ -341,19 +190,6 @@ static struct clk_hw *raspberrypi_clk_register(struct raspberrypi_clk *rpi,
 	u32 min_rate, max_rate;
 	int ret;
 
-	if (id == RPI_FIRMWARE_ARM_CLK_ID) {
-		struct clk_hw *hw;
-
-		hw = raspberrypi_register_pllb(rpi);
-		if (IS_ERR(hw)) {
-			dev_err(rpi->dev, "Failed to initialize pllb, %ld\n",
-				PTR_ERR(hw));
-			return hw;
-		}
-
-		return raspberrypi_register_pllb_arm(rpi);
-	}
-
 	data = devm_kzalloc(rpi->dev, sizeof(*data), GFP_KERNEL);
 	if (!data)
 		return ERR_PTR(-ENOMEM);
-- 
git-series 0.9.1

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v5 00/27] clk: bcm: rpi: Add support for BCM2711 firmware clocks
  2020-06-15  8:40 [PATCH v5 00/27] clk: bcm: rpi: Add support for BCM2711 firmware clocks Maxime Ripard
                   ` (26 preceding siblings ...)
  2020-06-15  8:41 ` [PATCH v5 27/27] clk: bcm: rpi: Remove the quirks for the CPU clock Maxime Ripard
@ 2020-06-19  9:37 ` Stephen Boyd
  2020-06-19  9:44   ` Nicolas Saenz Julienne
  2020-06-19 11:52   ` Maxime Ripard
  2020-06-25  1:15 ` Stephen Boyd
  28 siblings, 2 replies; 64+ messages in thread
From: Stephen Boyd @ 2020-06-19  9:37 UTC (permalink / raw)
  To: Maxime Ripard, Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, linux-clk, Philipp Zabel, Maxime Ripard,
	devicetree, Kamal Dasu, Rob Herring

Quoting Maxime Ripard (2020-06-15 01:40:40)
> Hi,
> 
> Since the whole DRM/HDMI support began to grow fairly big, I've chosen
> to split away the two discussions between the firmware clocks and the
> HDMI support.
> 
> Let me know what you think,
> Maxime

Do you want this to go through clk tree? Or looking for acks/review
tags?

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v5 00/27] clk: bcm: rpi: Add support for BCM2711 firmware clocks
  2020-06-19  9:37 ` [PATCH v5 00/27] clk: bcm: rpi: Add support for BCM2711 firmware clocks Stephen Boyd
@ 2020-06-19  9:44   ` Nicolas Saenz Julienne
  2020-06-19 23:57     ` Stephen Boyd
  2020-06-19 11:52   ` Maxime Ripard
  1 sibling, 1 reply; 64+ messages in thread
From: Nicolas Saenz Julienne @ 2020-06-19  9:44 UTC (permalink / raw)
  To: Stephen Boyd, Maxime Ripard
  Cc: devicetree, Tim Gover, Dave Stevenson, Mike Turquette,
	Kamal Dasu, linux-kernel, linux-clk, Rob Herring,
	bcm-kernel-feedback-list, linux-rpi-kernel, Philipp Zabel,
	Phil Elwell, linux-arm-kernel


[-- Attachment #1: Type: text/plain, Size: 527 bytes --]

On Fri, 2020-06-19 at 02:37 -0700, Stephen Boyd wrote:
> Quoting Maxime Ripard (2020-06-15 01:40:40)
> > Hi,
> > 
> > Since the whole DRM/HDMI support began to grow fairly big, I've chosen
> > to split away the two discussions between the firmware clocks and the
> > HDMI support.
> > 
> > Let me know what you think,
> > Maxime
> 
> Do you want this to go through clk tree? Or looking for acks/review
> tags?
> 

FWIW I don't mind taking the device tree changes trough the RPi soc tree.

Regards,
Nicolas


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v5 00/27] clk: bcm: rpi: Add support for BCM2711 firmware clocks
  2020-06-19  9:37 ` [PATCH v5 00/27] clk: bcm: rpi: Add support for BCM2711 firmware clocks Stephen Boyd
  2020-06-19  9:44   ` Nicolas Saenz Julienne
@ 2020-06-19 11:52   ` Maxime Ripard
  2020-06-19 23:57     ` Stephen Boyd
  1 sibling, 1 reply; 64+ messages in thread
From: Maxime Ripard @ 2020-06-19 11:52 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: Nicolas Saenz Julienne, linux-rpi-kernel,
	bcm-kernel-feedback-list, linux-arm-kernel, linux-kernel,
	Dave Stevenson, Tim Gover, Phil Elwell, Mike Turquette,
	linux-clk, Philipp Zabel, devicetree, Kamal Dasu, Rob Herring


[-- Attachment #1: Type: text/plain, Size: 593 bytes --]

Hi Stephen,

On Fri, Jun 19, 2020 at 02:37:37AM -0700, Stephen Boyd wrote:
> Quoting Maxime Ripard (2020-06-15 01:40:40)
> > Hi,
> > 
> > Since the whole DRM/HDMI support began to grow fairly big, I've chosen
> > to split away the two discussions between the firmware clocks and the
> > HDMI support.
> > 
> > Let me know what you think,
> > Maxime
> 
> Do you want this to go through clk tree? Or looking for acks/review
> tags?

As far as I understood, you usually apply the bcm patches to the clk
tree directly, so if you could apply them it would be awesome :)

Maxime

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v5 00/27] clk: bcm: rpi: Add support for BCM2711 firmware clocks
  2020-06-19  9:44   ` Nicolas Saenz Julienne
@ 2020-06-19 23:57     ` Stephen Boyd
  2020-06-20  0:20       ` Stephen Boyd
  0 siblings, 1 reply; 64+ messages in thread
From: Stephen Boyd @ 2020-06-19 23:57 UTC (permalink / raw)
  To: Maxime Ripard, Nicolas Saenz Julienne
  Cc: devicetree, Tim Gover, Dave Stevenson, Mike Turquette,
	Kamal Dasu, linux-kernel, linux-clk, Rob Herring,
	bcm-kernel-feedback-list, linux-rpi-kernel, Philipp Zabel,
	Phil Elwell, linux-arm-kernel

Quoting Nicolas Saenz Julienne (2020-06-19 02:44:54)
> On Fri, 2020-06-19 at 02:37 -0700, Stephen Boyd wrote:
> > Quoting Maxime Ripard (2020-06-15 01:40:40)
> > > Hi,
> > > 
> > > Since the whole DRM/HDMI support began to grow fairly big, I've chosen
> > > to split away the two discussions between the firmware clocks and the
> > > HDMI support.
> > > 
> > > Let me know what you think,
> > > Maxime
> > 
> > Do you want this to go through clk tree? Or looking for acks/review
> > tags?
> > 
> 
> FWIW I don't mind taking the device tree changes trough the RPi soc tree.
> 

Sounds good.

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v5 00/27] clk: bcm: rpi: Add support for BCM2711 firmware clocks
  2020-06-19 11:52   ` Maxime Ripard
@ 2020-06-19 23:57     ` Stephen Boyd
  0 siblings, 0 replies; 64+ messages in thread
From: Stephen Boyd @ 2020-06-19 23:57 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: Nicolas Saenz Julienne, linux-rpi-kernel,
	bcm-kernel-feedback-list, linux-arm-kernel, linux-kernel,
	Dave Stevenson, Tim Gover, Phil Elwell, Mike Turquette,
	linux-clk, Philipp Zabel, devicetree, Kamal Dasu, Rob Herring

Quoting Maxime Ripard (2020-06-19 04:52:55)
> Hi Stephen,
> 
> On Fri, Jun 19, 2020 at 02:37:37AM -0700, Stephen Boyd wrote:
> > Quoting Maxime Ripard (2020-06-15 01:40:40)
> > > Hi,
> > > 
> > > Since the whole DRM/HDMI support began to grow fairly big, I've chosen
> > > to split away the two discussions between the firmware clocks and the
> > > HDMI support.
> > > 
> > > Let me know what you think,
> > > Maxime
> > 
> > Do you want this to go through clk tree? Or looking for acks/review
> > tags?
> 
> As far as I understood, you usually apply the bcm patches to the clk
> tree directly, so if you could apply them it would be awesome :)
> 

Ok. Thanks for letting me know.

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v5 00/27] clk: bcm: rpi: Add support for BCM2711 firmware clocks
  2020-06-19 23:57     ` Stephen Boyd
@ 2020-06-20  0:20       ` Stephen Boyd
  2020-06-25  0:40         ` Stephen Boyd
  0 siblings, 1 reply; 64+ messages in thread
From: Stephen Boyd @ 2020-06-20  0:20 UTC (permalink / raw)
  To: Maxime Ripard, Nicolas Saenz Julienne
  Cc: devicetree, Tim Gover, Kamal Dasu, Mike Turquette,
	Dave Stevenson, linux-kernel, Phil Elwell, Rob Herring,
	bcm-kernel-feedback-list, linux-rpi-kernel, Philipp Zabel,
	linux-clk, linux-arm-kernel

Quoting Stephen Boyd (2020-06-19 16:57:10)
> Quoting Nicolas Saenz Julienne (2020-06-19 02:44:54)
> > On Fri, 2020-06-19 at 02:37 -0700, Stephen Boyd wrote:
> > > Quoting Maxime Ripard (2020-06-15 01:40:40)
> > > > Hi,
> > > > 
> > > > Since the whole DRM/HDMI support began to grow fairly big, I've chosen
> > > > to split away the two discussions between the firmware clocks and the
> > > > HDMI support.
> > > > 
> > > > Let me know what you think,
> > > > Maxime
> > > 
> > > Do you want this to go through clk tree? Or looking for acks/review
> > > tags?
> > > 
> > 
> > FWIW I don't mind taking the device tree changes trough the RPi soc tree.
> > 
> 
> Sounds good.
> 

Just to clarify, that is just the dts patch? Or the binding patches too?

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v5 00/27] clk: bcm: rpi: Add support for BCM2711 firmware clocks
  2020-06-20  0:20       ` Stephen Boyd
@ 2020-06-25  0:40         ` Stephen Boyd
  0 siblings, 0 replies; 64+ messages in thread
From: Stephen Boyd @ 2020-06-25  0:40 UTC (permalink / raw)
  To: Maxime Ripard, Nicolas Saenz Julienne
  Cc: devicetree, Tim Gover, Kamal Dasu, Mike Turquette,
	Dave Stevenson, linux-kernel, Phil Elwell, Rob Herring,
	bcm-kernel-feedback-list, linux-rpi-kernel, Philipp Zabel,
	linux-clk, linux-arm-kernel

Quoting Stephen Boyd (2020-06-19 17:20:24)
> Quoting Stephen Boyd (2020-06-19 16:57:10)
> > Quoting Nicolas Saenz Julienne (2020-06-19 02:44:54)
> > > On Fri, 2020-06-19 at 02:37 -0700, Stephen Boyd wrote:
> > > > Quoting Maxime Ripard (2020-06-15 01:40:40)
> > > > > Hi,
> > > > > 
> > > > > Since the whole DRM/HDMI support began to grow fairly big, I've chosen
> > > > > to split away the two discussions between the firmware clocks and the
> > > > > HDMI support.
> > > > > 
> > > > > Let me know what you think,
> > > > > Maxime
> > > > 
> > > > Do you want this to go through clk tree? Or looking for acks/review
> > > > tags?
> > > > 
> > > 
> > > FWIW I don't mind taking the device tree changes trough the RPi soc tree.
> > > 
> > 
> > Sounds good.
> > 
> 
> Just to clarify, that is just the dts patch? Or the binding patches too?

Ok. I'll push everything out now and you can tell me to undo that if
it's wrong.

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v5 01/27] dt-bindings: arm: bcm: Convert BCM2835 firmware binding to YAML
  2020-06-15  8:40 ` [PATCH v5 01/27] dt-bindings: arm: bcm: Convert BCM2835 firmware binding to YAML Maxime Ripard
@ 2020-06-25  0:42   ` Stephen Boyd
  0 siblings, 0 replies; 64+ messages in thread
From: Stephen Boyd @ 2020-06-25  0:42 UTC (permalink / raw)
  To: Maxime Ripard, Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, linux-clk, Philipp Zabel, Maxime Ripard,
	Florian Fainelli

Quoting Maxime Ripard (2020-06-15 01:40:41)
> From: Florian Fainelli <f.fainelli@gmail.com>
> 
> Convert the Raspberry Pi BCM2835 firmware binding document to YAML.
> Verified with dt_binding_check and dtbs_check.
> 
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> ---

Applied to clk-next

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v5 02/27] dt-bindings: clock: Add a binding for the RPi Firmware clocks
  2020-06-15  8:40 ` [PATCH v5 02/27] dt-bindings: clock: Add a binding for the RPi Firmware clocks Maxime Ripard
@ 2020-06-25  0:42   ` Stephen Boyd
  0 siblings, 0 replies; 64+ messages in thread
From: Stephen Boyd @ 2020-06-25  0:42 UTC (permalink / raw)
  To: Maxime Ripard, Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, linux-clk, Philipp Zabel, Maxime Ripard,
	devicetree, Rob Herring

Quoting Maxime Ripard (2020-06-15 01:40:42)
> The firmware running on the RPi VideoCore can be used to discover and
> change the various clocks running in the BCM2711. Since devices will
> need to use them through the DT, let's add a pretty simple binding.
> 
> Cc: Michael Turquette <mturquette@baylibre.com>
> Cc: linux-clk@vger.kernel.org
> Cc: devicetree@vger.kernel.org
> Reviewed-by: Stephen Boyd <sboyd@kernel.org>
> Reviewed-by: Rob Herring <robh+dt@kernel.org>
> Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> ---

Applied to clk-next

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v5 03/27] firmware: rpi: Only create clocks device if we don't have a node for it
  2020-06-15  8:40 ` [PATCH v5 03/27] firmware: rpi: Only create clocks device if we don't have a node for it Maxime Ripard
@ 2020-06-25  0:42   ` Stephen Boyd
  0 siblings, 0 replies; 64+ messages in thread
From: Stephen Boyd @ 2020-06-25  0:42 UTC (permalink / raw)
  To: Maxime Ripard, Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, linux-clk, Philipp Zabel, Maxime Ripard

Quoting Maxime Ripard (2020-06-15 01:40:43)
> The firmware clocks driver was previously probed through a platform_device
> created by the firmware driver.
> 
> Since we will now have a node for that clocks driver, we need to create the
> device only in the case where there's no node for it already.
> 
> Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> ---

Applied to clk-next

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v5 04/27] clk: bcm: rpi: Allow the driver to be probed by DT
  2020-06-15  8:40 ` [PATCH v5 04/27] clk: bcm: rpi: Allow the driver to be probed by DT Maxime Ripard
@ 2020-06-25  0:42   ` Stephen Boyd
  0 siblings, 0 replies; 64+ messages in thread
From: Stephen Boyd @ 2020-06-25  0:42 UTC (permalink / raw)
  To: Maxime Ripard, Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, linux-clk, Philipp Zabel, Maxime Ripard

Quoting Maxime Ripard (2020-06-15 01:40:44)
> The current firmware clock driver for the RaspberryPi can only be probed by
> manually registering an associated platform_device.
> 
> While this works fine for cpufreq where the device gets attached a clkdev
> lookup, it would be tedious to maintain a table of all the devices using
> one of the clocks exposed by the firmware.
> 
> Since the DT on the other hand is the perfect place to store those
> associations, make the firmware clocks driver probe-able through the device
> tree so that we can represent it as a node.
> 
> Cc: Michael Turquette <mturquette@baylibre.com>
> Cc: linux-clk@vger.kernel.org
> Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Reviewed-by: Stephen Boyd <sboyd@kernel.org>
> Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> ---

Applied to clk-next

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v5 05/27] clk: bcm: rpi: Statically init clk_init_data
  2020-06-15  8:40 ` [PATCH v5 05/27] clk: bcm: rpi: Statically init clk_init_data Maxime Ripard
@ 2020-06-25  0:42   ` Stephen Boyd
  0 siblings, 0 replies; 64+ messages in thread
From: Stephen Boyd @ 2020-06-25  0:42 UTC (permalink / raw)
  To: Maxime Ripard, Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, linux-clk, Philipp Zabel, Maxime Ripard

Quoting Maxime Ripard (2020-06-15 01:40:45)
> Instead of declaring the clk_init_data and then calling memset on it, just
> initialise properly.
> 
> Cc: Michael Turquette <mturquette@baylibre.com>
> Cc: Stephen Boyd <sboyd@kernel.org>
> Cc: linux-clk@vger.kernel.org
> Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Reviewed-by: Stephen Boyd <sboyd@kernel.org>
> Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> ---

Applied to clk-next

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v5 06/27] clk: bcm: rpi: Use clk_hw_register for pllb_arm
  2020-06-15  8:40 ` [PATCH v5 06/27] clk: bcm: rpi: Use clk_hw_register for pllb_arm Maxime Ripard
@ 2020-06-25  0:42   ` Stephen Boyd
  0 siblings, 0 replies; 64+ messages in thread
From: Stephen Boyd @ 2020-06-25  0:42 UTC (permalink / raw)
  To: Maxime Ripard, Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, linux-clk, Philipp Zabel, Maxime Ripard

Quoting Maxime Ripard (2020-06-15 01:40:46)
> The pllb_arm clock is defined as a fixed factor clock with the pllb
> clock as a parent. However, all its configuration is entirely static,
> and thus we don't really need to call clk_hw_register_fixed_factor() but
> can simply call clk_hw_register() with a static clk_fixed_factor
> structure.
> 
> Cc: Michael Turquette <mturquette@baylibre.com>
> Cc: linux-clk@vger.kernel.org
> Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Reviewed-by: Stephen Boyd <sboyd@kernel.org>
> Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> ---

Applied to clk-next

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v5 07/27] clk: bcm: rpi: Remove global pllb_arm clock pointer
  2020-06-15  8:40 ` [PATCH v5 07/27] clk: bcm: rpi: Remove global pllb_arm clock pointer Maxime Ripard
@ 2020-06-25  0:42   ` Stephen Boyd
  0 siblings, 0 replies; 64+ messages in thread
From: Stephen Boyd @ 2020-06-25  0:42 UTC (permalink / raw)
  To: Maxime Ripard, Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, linux-clk, Philipp Zabel, Maxime Ripard

Quoting Maxime Ripard (2020-06-15 01:40:47)
> The pllb_arm clk_hw pointer in the raspberry_clk structure isn't used
> anywhere but in the raspberrypi_register_pllb_arm.
> 
> Let's remove it, this will make our lives easier in future patches.
> 
> Cc: Michael Turquette <mturquette@baylibre.com>
> Cc: Stephen Boyd <sboyd@kernel.org>
> Cc: linux-clk@vger.kernel.org
> Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Reviewed-by: Stephen Boyd <sboyd@kernel.org>
> Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> ---

Applied to clk-next

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v5 08/27] clk: bcm: rpi: Make sure pllb_arm is removed
  2020-06-15  8:40 ` [PATCH v5 08/27] clk: bcm: rpi: Make sure pllb_arm is removed Maxime Ripard
@ 2020-06-25  0:42   ` Stephen Boyd
  0 siblings, 0 replies; 64+ messages in thread
From: Stephen Boyd @ 2020-06-25  0:42 UTC (permalink / raw)
  To: Maxime Ripard, Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, linux-clk, Philipp Zabel, Maxime Ripard

Quoting Maxime Ripard (2020-06-15 01:40:48)
> The pllb_arm clock was created at probe time, but was never removed if
> something went wrong later in probe, or if the driver was ever removed from
> the system.
> 
> Now that we are using clk_hw_register(), we can just use its managed variant
> to take care of that for us.
> 
> Cc: Michael Turquette <mturquette@baylibre.com>
> Cc: Stephen Boyd <sboyd@kernel.org>
> Cc: linux-clk@vger.kernel.org
> Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Reviewed-by: Stephen Boyd <sboyd@kernel.org>
> Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> ---

Applied to clk-next

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v5 09/27] clk: bcm: rpi: Remove pllb_arm_lookup global pointer
  2020-06-15  8:40 ` [PATCH v5 09/27] clk: bcm: rpi: Remove pllb_arm_lookup global pointer Maxime Ripard
@ 2020-06-25  0:42   ` Stephen Boyd
  2020-06-25  0:44   ` Stephen Boyd
  1 sibling, 0 replies; 64+ messages in thread
From: Stephen Boyd @ 2020-06-25  0:42 UTC (permalink / raw)
  To: Maxime Ripard, Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, linux-clk, Philipp Zabel, Maxime Ripard

Quoting Maxime Ripard (2020-06-15 01:40:49)
> The pllb_arm_lookup pointer in the struct raspberrypi_clk is not used for
> anything but to store the returned pointer to clkdev_hw_create, and is not
> used anywhere else in the driver.
> 
> Let's remove that global pointer from the structure.
> 
> Cc: Michael Turquette <mturquette@baylibre.com>
> Cc: linux-clk@vger.kernel.org
> Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Reviewed-by: Stephen Boyd <sboyd@kernel.org>
> Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> ---

Applied to clk-next

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v5 09/27] clk: bcm: rpi: Remove pllb_arm_lookup global pointer
  2020-06-15  8:40 ` [PATCH v5 09/27] clk: bcm: rpi: Remove pllb_arm_lookup global pointer Maxime Ripard
  2020-06-25  0:42   ` Stephen Boyd
@ 2020-06-25  0:44   ` Stephen Boyd
  1 sibling, 0 replies; 64+ messages in thread
From: Stephen Boyd @ 2020-06-25  0:44 UTC (permalink / raw)
  To: Maxime Ripard, Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, linux-clk, Philipp Zabel, Maxime Ripard

Quoting Maxime Ripard (2020-06-15 01:40:49)
> The pllb_arm_lookup pointer in the struct raspberrypi_clk is not used for
> anything but to store the returned pointer to clkdev_hw_create, and is not
> used anywhere else in the driver.
> 
> Let's remove that global pointer from the structure.
> 
> Cc: Michael Turquette <mturquette@baylibre.com>
> Cc: linux-clk@vger.kernel.org
> Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Reviewed-by: Stephen Boyd <sboyd@kernel.org>
> Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> ---

Applied to clk-next

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v5 10/27] clk: bcm: rpi: Switch to clk_hw_register_clkdev
  2020-06-15  8:40 ` [PATCH v5 10/27] clk: bcm: rpi: Switch to clk_hw_register_clkdev Maxime Ripard
@ 2020-06-25  0:44   ` Stephen Boyd
  0 siblings, 0 replies; 64+ messages in thread
From: Stephen Boyd @ 2020-06-25  0:44 UTC (permalink / raw)
  To: Maxime Ripard, Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, linux-clk, Philipp Zabel, Maxime Ripard

Quoting Maxime Ripard (2020-06-15 01:40:50)
> Since we don't care about retrieving the clk_lookup structure pointer
> returned by clkdev_hw_create, we can just use the clk_hw_register_clkdev
> function.
> 
> Cc: Michael Turquette <mturquette@baylibre.com>
> Cc: linux-clk@vger.kernel.org
> Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Reviewed-by: Stephen Boyd <sboyd@kernel.org>
> Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> ---

Applied to clk-next

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v5 11/27] clk: bcm: rpi: Make sure the clkdev lookup is removed
  2020-06-15  8:40 ` [PATCH v5 11/27] clk: bcm: rpi: Make sure the clkdev lookup is removed Maxime Ripard
@ 2020-06-25  0:44   ` Stephen Boyd
  0 siblings, 0 replies; 64+ messages in thread
From: Stephen Boyd @ 2020-06-25  0:44 UTC (permalink / raw)
  To: Maxime Ripard, Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, linux-clk, Philipp Zabel, Maxime Ripard

Quoting Maxime Ripard (2020-06-15 01:40:51)
> The clkdev lookup created for the cpufreq device is never removed if
> there's an issue later in probe or at module removal time.
> 
> Let's convert to the managed variant of the clk_hw_register_clkdev function
> to make sure it happens.
> 
> Cc: Michael Turquette <mturquette@baylibre.com>
> Cc: linux-clk@vger.kernel.org
> Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Reviewed-by: Stephen Boyd <sboyd@kernel.org>
> Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> ---

Applied to clk-next

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v5 12/27] clk: bcm: rpi: Use CCF boundaries instead of rolling our own
  2020-06-15  8:40 ` [PATCH v5 12/27] clk: bcm: rpi: Use CCF boundaries instead of rolling our own Maxime Ripard
@ 2020-06-25  0:44   ` Stephen Boyd
  0 siblings, 0 replies; 64+ messages in thread
From: Stephen Boyd @ 2020-06-25  0:44 UTC (permalink / raw)
  To: Maxime Ripard, Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, linux-clk, Philipp Zabel, Maxime Ripard

Quoting Maxime Ripard (2020-06-15 01:40:52)
> The raspberrypi firmware clock driver has a min_rate / max_rate clamping by
> storing the info it needs in a private structure.
> 
> However, the CCF already provides such a facility, so we can switch to it
> to remove the boilerplate.
> 
> Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> ---

Applied to clk-next

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v5 13/27] clk: bcm: rpi: Create a data structure for the clocks
  2020-06-15  8:40 ` [PATCH v5 13/27] clk: bcm: rpi: Create a data structure for the clocks Maxime Ripard
@ 2020-06-25  0:44   ` Stephen Boyd
  0 siblings, 0 replies; 64+ messages in thread
From: Stephen Boyd @ 2020-06-25  0:44 UTC (permalink / raw)
  To: Maxime Ripard, Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, linux-clk, Philipp Zabel, Maxime Ripard

Quoting Maxime Ripard (2020-06-15 01:40:53)
> So far the driver has really only been providing a single clock, and stored
> both the data associated to that clock in particular with the data
> associated to the "controller".
> 
> Since we will change that in the future, let's decouple the clock data from
> the provider data.
> 
> Cc: Michael Turquette <mturquette@baylibre.com>
> Cc: linux-clk@vger.kernel.org
> Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Reviewed-by: Stephen Boyd <sboyd@kernel.org>
> Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> ---

Applied to clk-next

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v5 14/27] clk: bcm: rpi: Add clock id to data
  2020-06-15  8:40 ` [PATCH v5 14/27] clk: bcm: rpi: Add clock id to data Maxime Ripard
@ 2020-06-25  0:45   ` Stephen Boyd
  0 siblings, 0 replies; 64+ messages in thread
From: Stephen Boyd @ 2020-06-25  0:45 UTC (permalink / raw)
  To: Maxime Ripard, Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, linux-clk, Philipp Zabel, Maxime Ripard

Quoting Maxime Ripard (2020-06-15 01:40:54)
> The driver has really only supported one clock so far and has hardcoded the
> ID used in communications with the firmware in all the functions
> implementing the clock framework hooks. Let's store that in the clock data
> structure so that we can support more clocks later on.
> 
> Cc: Michael Turquette <mturquette@baylibre.com>
> Cc: linux-clk@vger.kernel.org
> Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Reviewed-by: Stephen Boyd <sboyd@kernel.org>
> Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> ---

Applied to clk-next

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v5 15/27] clk: bcm: rpi: Pass the clocks data to the firmware function
  2020-06-15  8:40 ` [PATCH v5 15/27] clk: bcm: rpi: Pass the clocks data to the firmware function Maxime Ripard
@ 2020-06-25  0:45   ` Stephen Boyd
  0 siblings, 0 replies; 64+ messages in thread
From: Stephen Boyd @ 2020-06-25  0:45 UTC (permalink / raw)
  To: Maxime Ripard, Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, linux-clk, Philipp Zabel, Maxime Ripard

Quoting Maxime Ripard (2020-06-15 01:40:55)
> The raspberry_clock_property only takes the clock ID as an argument, but
> now that we have a clock data structure it makes more sense to just pass
> that structure instead.
> 
> Cc: Michael Turquette <mturquette@baylibre.com>
> Cc: Stephen Boyd <sboyd@kernel.org>
> Cc: linux-clk@vger.kernel.org
> Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Reviewed-by: Stephen Boyd <sboyd@kernel.org>
> Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> ---

Applied to clk-next

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v5 16/27] clk: bcm: rpi: Rename is_prepared function
  2020-06-15  8:40 ` [PATCH v5 16/27] clk: bcm: rpi: Rename is_prepared function Maxime Ripard
@ 2020-06-25  0:45   ` Stephen Boyd
  0 siblings, 0 replies; 64+ messages in thread
From: Stephen Boyd @ 2020-06-25  0:45 UTC (permalink / raw)
  To: Maxime Ripard, Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, linux-clk, Philipp Zabel, Maxime Ripard

Quoting Maxime Ripard (2020-06-15 01:40:56)
> The raspberrypi_fw_pll_is_on function doesn't only apply to PLL
> registered in the driver, but any clock exposed by the firmware.
> 
> Since we also implement the is_prepared hook, make the function
> consistent with the other function names.
> 
> Cc: Michael Turquette <mturquette@baylibre.com>
> Cc: linux-clk@vger.kernel.org
> Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Reviewed-by: Stephen Boyd <sboyd@kernel.org>
> Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> ---

Applied to clk-next

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v5 17/27] clk: bcm: rpi: Split pllb clock hooks
  2020-06-15  8:40 ` [PATCH v5 17/27] clk: bcm: rpi: Split pllb clock hooks Maxime Ripard
@ 2020-06-25  0:45   ` Stephen Boyd
  0 siblings, 0 replies; 64+ messages in thread
From: Stephen Boyd @ 2020-06-25  0:45 UTC (permalink / raw)
  To: Maxime Ripard, Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, linux-clk, Philipp Zabel, Maxime Ripard

Quoting Maxime Ripard (2020-06-15 01:40:57)
> The driver only supports the pllb for now and all the clock framework hooks
> are a mix of the generic firmware interface and the specifics of the pllb.
> Since we will support more clocks in the future let's split the generic and
> specific hooks
> 
> Cc: Michael Turquette <mturquette@baylibre.com>
> Cc: linux-clk@vger.kernel.org
> Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Reviewed-by: Stephen Boyd <sboyd@kernel.org>
> Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> ---

Applied to clk-next

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v5 18/27] clk: bcm: rpi: Make the PLLB registration function return a clk_hw
  2020-06-15  8:40 ` [PATCH v5 18/27] clk: bcm: rpi: Make the PLLB registration function return a clk_hw Maxime Ripard
@ 2020-06-25  0:45   ` Stephen Boyd
  0 siblings, 0 replies; 64+ messages in thread
From: Stephen Boyd @ 2020-06-25  0:45 UTC (permalink / raw)
  To: Maxime Ripard, Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, linux-clk, Philipp Zabel, Maxime Ripard

Quoting Maxime Ripard (2020-06-15 01:40:58)
> The raspberrypi_register_pllb has been returning an integer so far to
> notify whether the functions has exited successfully or not.
> 
> However, the OF provider functions in the clock framework require access to
> the clk_hw structure so that we can expose those clocks to device tree
> consumers.
> 
> Since we'll want that for the future clocks, let's return a clk_hw pointer
> instead of the return code.
> 
> Cc: Michael Turquette <mturquette@baylibre.com>
> Cc: linux-clk@vger.kernel.org
> Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Reviewed-by: Stephen Boyd <sboyd@kernel.org>
> Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> ---

Applied to clk-next

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v5 19/27] clk: bcm: rpi: Add DT provider for the clocks
  2020-06-15  8:40 ` [PATCH v5 19/27] clk: bcm: rpi: Add DT provider for the clocks Maxime Ripard
@ 2020-06-25  0:45   ` Stephen Boyd
  0 siblings, 0 replies; 64+ messages in thread
From: Stephen Boyd @ 2020-06-25  0:45 UTC (permalink / raw)
  To: Maxime Ripard, Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, linux-clk, Philipp Zabel, Maxime Ripard

Quoting Maxime Ripard (2020-06-15 01:40:59)
> For the upcoming registration of the clocks provided by the firmware, make
> sure it's exposed to the device tree providers.
> 
> Cc: Michael Turquette <mturquette@baylibre.com>
> Cc: linux-clk@vger.kernel.org
> Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Reviewed-by: Stephen Boyd <sboyd@kernel.org>
> Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> ---

Applied to clk-next

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v5 20/27] clk: bcm: rpi: Add an enum for the firmware clocks
  2020-06-15  8:41 ` [PATCH v5 20/27] clk: bcm: rpi: Add an enum for the firmware clocks Maxime Ripard
@ 2020-06-25  0:45   ` Stephen Boyd
  0 siblings, 0 replies; 64+ messages in thread
From: Stephen Boyd @ 2020-06-25  0:45 UTC (permalink / raw)
  To: Maxime Ripard, Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, linux-clk, Philipp Zabel, Maxime Ripard

Quoting Maxime Ripard (2020-06-15 01:41:00)
> While the firmware allows us to discover the available clocks, we need to
> discriminate those clocks to only register the ones meaningful to Linux.
> The firmware also doesn't provide a clock name, so having a list of the ID
> will help us to give clocks a proper name later on.
> 
> Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> ---

Applied to clk-next

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v5 21/27] clk: bcm: rpi: Discover the firmware clocks
  2020-06-15  8:41 ` [PATCH v5 21/27] clk: bcm: rpi: Discover " Maxime Ripard
@ 2020-06-25  0:45   ` Stephen Boyd
  0 siblings, 0 replies; 64+ messages in thread
From: Stephen Boyd @ 2020-06-25  0:45 UTC (permalink / raw)
  To: Maxime Ripard, Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, linux-clk, Philipp Zabel, Maxime Ripard

Quoting Maxime Ripard (2020-06-15 01:41:01)
> The RaspberryPi4 firmware actually exposes more clocks than are currently
> handled by the driver and we will need to change some of them directly
> based on the pixel rate for the display related clocks, or the load for the
> GPU.
> 
> Since the firmware implements DVFS, this rate change can have a number of
> side-effects, including adjusting the various PLL voltages or the PLL
> parents. The firmware also implements thermal throttling, so even some
> thermal pressure can change those parameters behind Linux back.
> 
> DVFS is currently implemented on the arm, core, h264, v3d, isp and hevc
> clocks, so updating any of them using the MMIO driver (and thus behind the
> firmware's back) can lead to troubles, the arm clock obviously being the
> most problematic.
> 
> In order to make Linux play as nice as possible with those constraints, it
> makes sense to rely on the firmware clocks as much as possible. However,
> the firmware doesn't seem to provide some equivalents to their MMIO
> counterparts, so we can't really replace that driver entirely.
> 
> Fortunately, the firmware has an interface to discover the clocks it
> exposes.
> 
> Let's use it to discover, register the clocks in the clocks framework and
> then expose them through the device tree for consumers to use them.
> 
> Cc: Michael Turquette <mturquette@baylibre.com>
> Cc: Stephen Boyd <sboyd@kernel.org>
> Cc: linux-clk@vger.kernel.org
> Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Reviewed-by: Stephen Boyd <sboyd@kernel.org>
> Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> ---

Applied to clk-next

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v5 22/27] clk: bcm: rpi: Give firmware clocks a name
  2020-06-15  8:41 ` [PATCH v5 22/27] clk: bcm: rpi: Give firmware clocks a name Maxime Ripard
@ 2020-06-25  0:45   ` Stephen Boyd
  0 siblings, 0 replies; 64+ messages in thread
From: Stephen Boyd @ 2020-06-25  0:45 UTC (permalink / raw)
  To: Maxime Ripard, Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, linux-clk, Philipp Zabel, Maxime Ripard

Quoting Maxime Ripard (2020-06-15 01:41:02)
> We've registered the firmware clocks using their ID as name, but it's much
> more convenient to register them using their proper name. Since the
> firmware doesn't provide it, we have to duplicate it.
> 
> Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> ---

Applied to clk-next

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v5 23/27] Revert "clk: bcm2835: remove pllb"
  2020-06-15  8:41 ` [PATCH v5 23/27] Revert "clk: bcm2835: remove pllb" Maxime Ripard
@ 2020-06-25  0:45   ` Stephen Boyd
  0 siblings, 0 replies; 64+ messages in thread
From: Stephen Boyd @ 2020-06-25  0:45 UTC (permalink / raw)
  To: Maxime Ripard, Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, linux-clk, Philipp Zabel, Maxime Ripard

Quoting Maxime Ripard (2020-06-15 01:41:03)
> This reverts commit 2256d89333bd17b8b56b42734a7e1046d52f7fc3. Since we
> will be expanding the firmware clock driver, we'll need to remove the
> quirks to deal with the PLLB. However, we still want to expose the clock
> tree properly, so having that clock in the MMIO driver will allow that.
> 
> Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> ---

Applied to clk-next

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v5 25/27] clk: bcm2835: Allow custom CCF flags for the PLLs
  2020-06-15  8:41 ` [PATCH v5 25/27] clk: bcm2835: Allow custom CCF flags for the PLLs Maxime Ripard
@ 2020-06-25  0:46   ` Stephen Boyd
  0 siblings, 0 replies; 64+ messages in thread
From: Stephen Boyd @ 2020-06-25  0:46 UTC (permalink / raw)
  To: Maxime Ripard, Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, linux-clk, Philipp Zabel, Maxime Ripard

Quoting Maxime Ripard (2020-06-15 01:41:05)
> While some clock types allow for each clock to specify its own custom
> flags, the PLLs can't. We will need this for the PLLB, so let's add it.
> 
> Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> ---

Applied to clk-next

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v5 26/27] clk: bcm2835: Don't cache the PLLB rate
  2020-06-15  8:41 ` [PATCH v5 26/27] clk: bcm2835: Don't cache the PLLB rate Maxime Ripard
@ 2020-06-25  0:46   ` Stephen Boyd
  0 siblings, 0 replies; 64+ messages in thread
From: Stephen Boyd @ 2020-06-25  0:46 UTC (permalink / raw)
  To: Maxime Ripard, Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, linux-clk, Philipp Zabel, Maxime Ripard

Quoting Maxime Ripard (2020-06-15 01:41:06)
> The PLLB rate will be changed through the firmware clocks drivers and will
> change behind this drivers' back, so we don't want to cache the rate.
> 
> Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> ---

Applied to clk-next

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v5 27/27] clk: bcm: rpi: Remove the quirks for the CPU clock
  2020-06-15  8:41 ` [PATCH v5 27/27] clk: bcm: rpi: Remove the quirks for the CPU clock Maxime Ripard
@ 2020-06-25  0:46   ` Stephen Boyd
  0 siblings, 0 replies; 64+ messages in thread
From: Stephen Boyd @ 2020-06-25  0:46 UTC (permalink / raw)
  To: Maxime Ripard, Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, linux-clk, Philipp Zabel, Maxime Ripard

Quoting Maxime Ripard (2020-06-15 01:41:07)
> The CPU clock has had so far a bunch of quirks to expose the clock tree
> properly, but since we reverted to exposing them through the MMIO driver,
> we can remove that code from the firmware driver.
> 
> Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> ---

Applied to clk-next

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v5 00/27] clk: bcm: rpi: Add support for BCM2711 firmware clocks
  2020-06-15  8:40 [PATCH v5 00/27] clk: bcm: rpi: Add support for BCM2711 firmware clocks Maxime Ripard
                   ` (27 preceding siblings ...)
  2020-06-19  9:37 ` [PATCH v5 00/27] clk: bcm: rpi: Add support for BCM2711 firmware clocks Stephen Boyd
@ 2020-06-25  1:15 ` Stephen Boyd
  28 siblings, 0 replies; 64+ messages in thread
From: Stephen Boyd @ 2020-06-25  1:15 UTC (permalink / raw)
  To: Maxime Ripard, Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, linux-clk, Philipp Zabel, Maxime Ripard,
	devicetree, Kamal Dasu, Rob Herring

Quoting Maxime Ripard (2020-06-15 01:40:40)
> Hi,
> 
> Since the whole DRM/HDMI support began to grow fairly big, I've chosen
> to split away the two discussions between the firmware clocks and the
> HDMI support.
> 

I see one problem.

WARNING: modpost: missing MODULE_LICENSE() in drivers/clk/bcm/clk-bcm2711-dvp.o

Can you send a followup patch to fix this?

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH v5 24/27] ARM: dts: bcm2711: Add firmware clocks node
  2020-06-15  8:41 ` [PATCH v5 24/27] ARM: dts: bcm2711: Add firmware clocks node Maxime Ripard
@ 2020-06-25  8:16   ` Nicolas Saenz Julienne
  0 siblings, 0 replies; 64+ messages in thread
From: Nicolas Saenz Julienne @ 2020-06-25  8:16 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: linux-rpi-kernel, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel, Dave Stevenson, Tim Gover, Phil Elwell,
	Mike Turquette, Stephen Boyd, linux-clk, Philipp Zabel


[-- Attachment #1: Type: text/plain, Size: 343 bytes --]

On Mon, 2020-06-15 at 10:41 +0200, Maxime Ripard wrote:
> Now that we have a clock driver for the clocks exposed by the firmware,
> let's add the device tree nodes for it.
> 
> Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> ---

Applied for-next.

Thanks!
Nicolas


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 64+ messages in thread

end of thread, back to index

Thread overview: 64+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-15  8:40 [PATCH v5 00/27] clk: bcm: rpi: Add support for BCM2711 firmware clocks Maxime Ripard
2020-06-15  8:40 ` [PATCH v5 01/27] dt-bindings: arm: bcm: Convert BCM2835 firmware binding to YAML Maxime Ripard
2020-06-25  0:42   ` Stephen Boyd
2020-06-15  8:40 ` [PATCH v5 02/27] dt-bindings: clock: Add a binding for the RPi Firmware clocks Maxime Ripard
2020-06-25  0:42   ` Stephen Boyd
2020-06-15  8:40 ` [PATCH v5 03/27] firmware: rpi: Only create clocks device if we don't have a node for it Maxime Ripard
2020-06-25  0:42   ` Stephen Boyd
2020-06-15  8:40 ` [PATCH v5 04/27] clk: bcm: rpi: Allow the driver to be probed by DT Maxime Ripard
2020-06-25  0:42   ` Stephen Boyd
2020-06-15  8:40 ` [PATCH v5 05/27] clk: bcm: rpi: Statically init clk_init_data Maxime Ripard
2020-06-25  0:42   ` Stephen Boyd
2020-06-15  8:40 ` [PATCH v5 06/27] clk: bcm: rpi: Use clk_hw_register for pllb_arm Maxime Ripard
2020-06-25  0:42   ` Stephen Boyd
2020-06-15  8:40 ` [PATCH v5 07/27] clk: bcm: rpi: Remove global pllb_arm clock pointer Maxime Ripard
2020-06-25  0:42   ` Stephen Boyd
2020-06-15  8:40 ` [PATCH v5 08/27] clk: bcm: rpi: Make sure pllb_arm is removed Maxime Ripard
2020-06-25  0:42   ` Stephen Boyd
2020-06-15  8:40 ` [PATCH v5 09/27] clk: bcm: rpi: Remove pllb_arm_lookup global pointer Maxime Ripard
2020-06-25  0:42   ` Stephen Boyd
2020-06-25  0:44   ` Stephen Boyd
2020-06-15  8:40 ` [PATCH v5 10/27] clk: bcm: rpi: Switch to clk_hw_register_clkdev Maxime Ripard
2020-06-25  0:44   ` Stephen Boyd
2020-06-15  8:40 ` [PATCH v5 11/27] clk: bcm: rpi: Make sure the clkdev lookup is removed Maxime Ripard
2020-06-25  0:44   ` Stephen Boyd
2020-06-15  8:40 ` [PATCH v5 12/27] clk: bcm: rpi: Use CCF boundaries instead of rolling our own Maxime Ripard
2020-06-25  0:44   ` Stephen Boyd
2020-06-15  8:40 ` [PATCH v5 13/27] clk: bcm: rpi: Create a data structure for the clocks Maxime Ripard
2020-06-25  0:44   ` Stephen Boyd
2020-06-15  8:40 ` [PATCH v5 14/27] clk: bcm: rpi: Add clock id to data Maxime Ripard
2020-06-25  0:45   ` Stephen Boyd
2020-06-15  8:40 ` [PATCH v5 15/27] clk: bcm: rpi: Pass the clocks data to the firmware function Maxime Ripard
2020-06-25  0:45   ` Stephen Boyd
2020-06-15  8:40 ` [PATCH v5 16/27] clk: bcm: rpi: Rename is_prepared function Maxime Ripard
2020-06-25  0:45   ` Stephen Boyd
2020-06-15  8:40 ` [PATCH v5 17/27] clk: bcm: rpi: Split pllb clock hooks Maxime Ripard
2020-06-25  0:45   ` Stephen Boyd
2020-06-15  8:40 ` [PATCH v5 18/27] clk: bcm: rpi: Make the PLLB registration function return a clk_hw Maxime Ripard
2020-06-25  0:45   ` Stephen Boyd
2020-06-15  8:40 ` [PATCH v5 19/27] clk: bcm: rpi: Add DT provider for the clocks Maxime Ripard
2020-06-25  0:45   ` Stephen Boyd
2020-06-15  8:41 ` [PATCH v5 20/27] clk: bcm: rpi: Add an enum for the firmware clocks Maxime Ripard
2020-06-25  0:45   ` Stephen Boyd
2020-06-15  8:41 ` [PATCH v5 21/27] clk: bcm: rpi: Discover " Maxime Ripard
2020-06-25  0:45   ` Stephen Boyd
2020-06-15  8:41 ` [PATCH v5 22/27] clk: bcm: rpi: Give firmware clocks a name Maxime Ripard
2020-06-25  0:45   ` Stephen Boyd
2020-06-15  8:41 ` [PATCH v5 23/27] Revert "clk: bcm2835: remove pllb" Maxime Ripard
2020-06-25  0:45   ` Stephen Boyd
2020-06-15  8:41 ` [PATCH v5 24/27] ARM: dts: bcm2711: Add firmware clocks node Maxime Ripard
2020-06-25  8:16   ` Nicolas Saenz Julienne
2020-06-15  8:41 ` [PATCH v5 25/27] clk: bcm2835: Allow custom CCF flags for the PLLs Maxime Ripard
2020-06-25  0:46   ` Stephen Boyd
2020-06-15  8:41 ` [PATCH v5 26/27] clk: bcm2835: Don't cache the PLLB rate Maxime Ripard
2020-06-25  0:46   ` Stephen Boyd
2020-06-15  8:41 ` [PATCH v5 27/27] clk: bcm: rpi: Remove the quirks for the CPU clock Maxime Ripard
2020-06-25  0:46   ` Stephen Boyd
2020-06-19  9:37 ` [PATCH v5 00/27] clk: bcm: rpi: Add support for BCM2711 firmware clocks Stephen Boyd
2020-06-19  9:44   ` Nicolas Saenz Julienne
2020-06-19 23:57     ` Stephen Boyd
2020-06-20  0:20       ` Stephen Boyd
2020-06-25  0:40         ` Stephen Boyd
2020-06-19 11:52   ` Maxime Ripard
2020-06-19 23:57     ` Stephen Boyd
2020-06-25  1:15 ` Stephen Boyd

Linux-Clk Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-clk/0 linux-clk/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-clk linux-clk/ https://lore.kernel.org/linux-clk \
		linux-clk@vger.kernel.org
	public-inbox-index linux-clk

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-clk


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git