Преглед изворни кода

bcm53xx: use the latest 6th version of ILP clock driver patch

It still wasn't accepted, so don't switch to 0xx prefix yet.

Signed-off-by: Rafał Miłecki <[email protected]>
Rafał Miłecki пре 9 година
родитељ
комит
1bb914dbed

+ 66 - 43
target/linux/bcm53xx/patches-4.4/830-clk-bcm-Add-driver-for-Northstar-ILP-clock.patch → target/linux/bcm53xx/patches-4.4/830-clk-bcm-Add-driver-for-BCM53573-ILP-clock.patch

@@ -1,15 +1,15 @@
-From 65acc8219d271d29b918ae4d6fe4d520203f25ae Mon Sep 17 00:00:00 2001
+From 1909c8bf322e0bbb068d57c370c5b64906a8c5a7 Mon Sep 17 00:00:00 2001
 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <[email protected]>
 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <[email protected]>
 Date: Fri, 29 Jul 2016 14:48:19 +0200
 Date: Fri, 29 Jul 2016 14:48:19 +0200
-Subject: [PATCH V3] clk: bcm: Add driver for Northstar ILP clock
+Subject: [PATCH V6] clk: bcm: Add driver for BCM53573 ILP clock
 MIME-Version: 1.0
 MIME-Version: 1.0
 Content-Type: text/plain; charset=UTF-8
 Content-Type: text/plain; charset=UTF-8
 Content-Transfer-Encoding: 8bit
 Content-Transfer-Encoding: 8bit
 
 
-This clock is present on cheaper Northstar devices like BCM53573 or
-BCM47189 using Corex-A7. ILP is a part of PMU (Power Management Unit)
-and so it should be defined as one of its subnodes (subdevices). For
-more details see Documentation entry.
+This clock is present on BCM53573 devices (including BCM47189) that use
+Cortex-A7. ILP is a part of PMU (Power Management Unit) and so it should
+be defined as one of its subnodes (subdevices). For more details see
+Documentation entry.
 
 
 Unfortunately there isn't a set of registers related to ILP clock only.
 Unfortunately there isn't a set of registers related to ILP clock only.
 We use registers 0x66c, 0x674 and 0x6dc and between them there are e.g.
 We use registers 0x66c, 0x674 and 0x6dc and between them there are e.g.
@@ -26,25 +26,37 @@ V2: Rebase on top of clk-next
 V3: Drop #include <linux/moduleh>
 V3: Drop #include <linux/moduleh>
     Make ILP DT entry part of PMU
     Make ILP DT entry part of PMU
     Describe ILP as subdevice of PMU in Documentation
     Describe ILP as subdevice of PMU in Documentation
+V4: Use BCM53573 name as suggested by Jon and Ray. It seems "Northstar"
+    (even if used in some resources) should be used in relation to
+    Cortex-A9 devices only.
+V5: Rename remaining "ns" references to "bcm53573", sorry, I sent V4 too
+    early.
+V6: Drop #include <linux/clk.h>
+    Use "int" as type where it matches usage
+    Add cpu_relax() in the loop
+    Add disable callback
+    Use _hw_ functions for registering struct clk_hw (new API)
+
+    Thanks a lot Stephen!
 ---
 ---
- .../devicetree/bindings/clock/brcm,ns-ilp.txt      |  40 ++++++
+ .../bindings/clock/brcm,bcm53573-ilp.txt           |  40 ++++++
  drivers/clk/bcm/Makefile                           |   1 +
  drivers/clk/bcm/Makefile                           |   1 +
- drivers/clk/bcm/clk-ns-ilp.c                       | 146 +++++++++++++++++++++
- 3 files changed, 187 insertions(+)
- create mode 100644 Documentation/devicetree/bindings/clock/brcm,ns-ilp.txt
- create mode 100644 drivers/clk/bcm/clk-ns-ilp.c
+ drivers/clk/bcm/clk-bcm53573-ilp.c                 | 157 +++++++++++++++++++++
+ 3 files changed, 198 insertions(+)
+ create mode 100644 Documentation/devicetree/bindings/clock/brcm,bcm53573-ilp.txt
+ create mode 100644 drivers/clk/bcm/clk-bcm53573-ilp.c
 
 
 --- /dev/null
 --- /dev/null
-+++ b/Documentation/devicetree/bindings/clock/brcm,ns-ilp.txt
++++ b/Documentation/devicetree/bindings/clock/brcm,bcm53573-ilp.txt
 @@ -0,0 +1,40 @@
 @@ -0,0 +1,40 @@
-+Broadcom Northstar ILP clock
-+============================
++Broadcom BCM53573 ILP clock
++===========================
 +
 +
 +This binding uses the common clock binding:
 +This binding uses the common clock binding:
 +    Documentation/devicetree/bindings/clock/clock-bindings.txt
 +    Documentation/devicetree/bindings/clock/clock-bindings.txt
 +
 +
 +This binding is used for ILP clock (sometimes referred as "slow clock")
 +This binding is used for ILP clock (sometimes referred as "slow clock")
-+on Broadcom Northstar devices using Corex-A7 CPU.
++on Broadcom BCM53573 devices using Cortex-A7 CPU.
 +
 +
 +This clock is part of PMU (Power Management Unit), a Broadcom's device
 +This clock is part of PMU (Power Management Unit), a Broadcom's device
 +handing power-related aspects. Please note PMU contains more subdevices,
 +handing power-related aspects. Please note PMU contains more subdevices,
@@ -54,7 +66,7 @@ V3: Drop #include <linux/moduleh>
 +which has to be referenced.
 +which has to be referenced.
 +
 +
 +Required properties:
 +Required properties:
-+- compatible: "brcm,ns-ilp"
++- compatible: "brcm,bcm53573-ilp"
 +- reg: iomem address range of PMU (Power Management Unit)
 +- reg: iomem address range of PMU (Power Management Unit)
 +- reg-names: "pmu", the only needed & supported reg right now
 +- reg-names: "pmu", the only needed & supported reg right now
 +- clocks: has to reference an ALP clock
 +- clocks: has to reference an ALP clock
@@ -69,7 +81,7 @@ V3: Drop #include <linux/moduleh>
 +	#size-cells = <1>;
 +	#size-cells = <1>;
 +
 +
 +	ilp: ilp@0 {
 +	ilp: ilp@0 {
-+		compatible = "brcm,ns-ilp";
++		compatible = "brcm,bcm53573-ilp";
 +		reg = <0 0x1000>;
 +		reg = <0 0x1000>;
 +		reg-names = "pmu";
 +		reg-names = "pmu";
 +		clocks = <&alp>;
 +		clocks = <&alp>;
@@ -83,10 +95,10 @@ V3: Drop #include <linux/moduleh>
  obj-$(CONFIG_ARCH_BCM_CYGNUS)	+= clk-cygnus.o
  obj-$(CONFIG_ARCH_BCM_CYGNUS)	+= clk-cygnus.o
  obj-$(CONFIG_ARCH_BCM_NSP)	+= clk-nsp.o
  obj-$(CONFIG_ARCH_BCM_NSP)	+= clk-nsp.o
  obj-$(CONFIG_ARCH_BCM_5301X)	+= clk-nsp.o
  obj-$(CONFIG_ARCH_BCM_5301X)	+= clk-nsp.o
-+obj-$(CONFIG_ARCH_BCM_5301X)	+= clk-ns-ilp.o
++obj-$(CONFIG_ARCH_BCM_53573)	+= clk-bcm53573-ilp.o
 --- /dev/null
 --- /dev/null
-+++ b/drivers/clk/bcm/clk-ns-ilp.c
-@@ -0,0 +1,146 @@
++++ b/drivers/clk/bcm/clk-bcm53573-ilp.c
+@@ -0,0 +1,157 @@
 +/*
 +/*
 + * Copyright (C) 2016 Rafał Miłecki <[email protected]>
 + * Copyright (C) 2016 Rafał Miłecki <[email protected]>
 + *
 + *
@@ -95,7 +107,6 @@ V3: Drop #include <linux/moduleh>
 + * published by the Free Software Foundation.
 + * published by the Free Software Foundation.
 + */
 + */
 +
 +
-+#include <linux/clk.h>
 +#include <linux/clk-provider.h>
 +#include <linux/clk-provider.h>
 +#include <linux/err.h>
 +#include <linux/err.h>
 +#include <linux/io.h>
 +#include <linux/io.h>
@@ -108,15 +119,14 @@ V3: Drop #include <linux/moduleh>
 +#define  XTAL_CTL_EN				0x80000000
 +#define  XTAL_CTL_EN				0x80000000
 +#define PMU_SLOW_CLK_PERIOD			0x6dc
 +#define PMU_SLOW_CLK_PERIOD			0x6dc
 +
 +
-+struct ns_ilp {
-+	struct clk *clk;
++struct bcm53573_ilp {
 +	struct clk_hw hw;
 +	struct clk_hw hw;
 +	void __iomem *pmu;
 +	void __iomem *pmu;
 +};
 +};
 +
 +
-+static int ns_ilp_enable(struct clk_hw *hw)
++static int bcm53573_ilp_enable(struct clk_hw *hw)
 +{
 +{
-+	struct ns_ilp *ilp = container_of(hw, struct ns_ilp, hw);
++	struct bcm53573_ilp *ilp = container_of(hw, struct bcm53573_ilp, hw);
 +
 +
 +	writel(0x10199, ilp->pmu + PMU_SLOW_CLK_PERIOD);
 +	writel(0x10199, ilp->pmu + PMU_SLOW_CLK_PERIOD);
 +	writel(0x10000, ilp->pmu + 0x674);
 +	writel(0x10000, ilp->pmu + 0x674);
@@ -124,14 +134,22 @@ V3: Drop #include <linux/moduleh>
 +	return 0;
 +	return 0;
 +}
 +}
 +
 +
-+static unsigned long ns_ilp_recalc_rate(struct clk_hw *hw,
-+					unsigned long parent_rate)
++static void bcm53573_ilp_disable(struct clk_hw *hw)
++{
++	struct bcm53573_ilp *ilp = container_of(hw, struct bcm53573_ilp, hw);
++
++	writel(0, ilp->pmu + PMU_SLOW_CLK_PERIOD);
++	writel(0, ilp->pmu + 0x674);
++}
++
++static unsigned long bcm53573_ilp_recalc_rate(struct clk_hw *hw,
++					      unsigned long parent_rate)
 +{
 +{
-+	struct ns_ilp *ilp = container_of(hw, struct ns_ilp, hw);
++	struct bcm53573_ilp *ilp = container_of(hw, struct bcm53573_ilp, hw);
 +	void __iomem *pmu = ilp->pmu;
 +	void __iomem *pmu = ilp->pmu;
 +	u32 last_val, cur_val;
 +	u32 last_val, cur_val;
-+	u32 sum = 0, num = 0, loop_num = 0;
-+	u32 avg;
++	int sum = 0, num = 0, loop_num = 0;
++	int avg;
 +
 +
 +	/* Enable measurement */
 +	/* Enable measurement */
 +	writel(XTAL_CTL_EN, pmu + PMU_XTAL_FREQ_RATIO);
 +	writel(XTAL_CTL_EN, pmu + PMU_XTAL_FREQ_RATIO);
@@ -159,6 +177,8 @@ V3: Drop #include <linux/moduleh>
 +			num++;
 +			num++;
 +			break;
 +			break;
 +		}
 +		}
++
++		cpu_relax();
 +	}
 +	}
 +
 +
 +	/* Disable measurement to save power */
 +	/* Disable measurement to save power */
@@ -169,14 +189,15 @@ V3: Drop #include <linux/moduleh>
 +	return parent_rate * 4 / avg;
 +	return parent_rate * 4 / avg;
 +}
 +}
 +
 +
-+static const struct clk_ops ns_ilp_clk_ops = {
-+	.enable = ns_ilp_enable,
-+	.recalc_rate = ns_ilp_recalc_rate,
++static const struct clk_ops bcm53573_ilp_clk_ops = {
++	.enable = bcm53573_ilp_enable,
++	.disable = bcm53573_ilp_disable,
++	.recalc_rate = bcm53573_ilp_recalc_rate,
 +};
 +};
 +
 +
-+static void ns_ilp_init(struct device_node *np)
++static void bcm53573_ilp_init(struct device_node *np)
 +{
 +{
-+	struct ns_ilp *ilp;
++	struct bcm53573_ilp *ilp;
 +	struct resource res;
 +	struct resource res;
 +	struct clk_init_data init = { 0 };
 +	struct clk_init_data init = { 0 };
 +	const char *parent_name;
 +	const char *parent_name;
@@ -209,27 +230,29 @@ V3: Drop #include <linux/moduleh>
 +	}
 +	}
 +
 +
 +	init.name = np->name;
 +	init.name = np->name;
-+	init.ops = &ns_ilp_clk_ops;
++	init.ops = &bcm53573_ilp_clk_ops;
 +	init.parent_names = &parent_name;
 +	init.parent_names = &parent_name;
 +	init.num_parents = 1;
 +	init.num_parents = 1;
 +
 +
 +	ilp->hw.init = &init;
 +	ilp->hw.init = &init;
-+	ilp->clk = clk_register(NULL, &ilp->hw);
-+	if (WARN_ON(IS_ERR(ilp->clk)))
++	err = clk_hw_register(NULL, &ilp->hw);
++	if (err)
 +		goto err_unmap_pmu;
 +		goto err_unmap_pmu;
 +
 +
-+	err = of_clk_add_provider(np, of_clk_src_simple_get, ilp->clk);
++	err = of_clk_add_hw_provider(np, of_clk_hw_simple_get, &ilp->hw);
 +	if (err)
 +	if (err)
-+		goto err_clk_unregister;
++		goto err_clk_hw_unregister;
 +
 +
 +	return;
 +	return;
 +
 +
-+err_clk_unregister:
-+	clk_unregister(ilp->clk);
++err_clk_hw_unregister:
++	clk_hw_unregister(&ilp->hw);
 +err_unmap_pmu:
 +err_unmap_pmu:
 +	iounmap(ilp->pmu);
 +	iounmap(ilp->pmu);
 +err_free_ilp:
 +err_free_ilp:
 +	kfree(ilp);
 +	kfree(ilp);
 +	pr_err("Failed to init ILP clock: %d\n", err);
 +	pr_err("Failed to init ILP clock: %d\n", err);
 +}
 +}
-+CLK_OF_DECLARE(ns_ilp_clk, "brcm,ns-ilp", ns_ilp_init);
++
++/* We need it very early for arch code, before device model gets ready */
++CLK_OF_DECLARE(bcm53573_ilp_clk, "brcm,bcm53573-ilp", bcm53573_ilp_init);

+ 1 - 1
target/linux/bcm53xx/patches-4.4/905-BCM53573-minor-hacks.patch

@@ -16,7 +16,7 @@ Signed-off-by: Rafał Miłecki <[email protected]>
  	};
  	};
  
  
 +	ilp: ilp@0 {
 +	ilp: ilp@0 {
-+		compatible = "brcm,ns-ilp";
++		compatible = "brcm,bcm53573-ilp";
 +		reg = <0x18012000 0x1000>;
 +		reg = <0x18012000 0x1000>;
 +		reg-names = "pmu";
 +		reg-names = "pmu";
 +		clocks = <&alp>;
 +		clocks = <&alp>;