From 1bb914dbedea64a60164f63cbd9ea58359018ddc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rafa=C5=82=20Mi=C5=82ecki?= Date: Fri, 26 Aug 2016 17:02:30 +0200 Subject: [PATCH] bcm53xx: use the latest 6th version of ILP clock driver patch MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit It still wasn't accepted, so don't switch to 0xx prefix yet. Signed-off-by: Rafał Miłecki --- ...m-Add-driver-for-BCM53573-ILP-clock.patch} | 109 +++++++++++------- .../905-BCM53573-minor-hacks.patch | 2 +- 2 files changed, 67 insertions(+), 44 deletions(-) rename target/linux/bcm53xx/patches-4.4/{830-clk-bcm-Add-driver-for-Northstar-ILP-clock.patch => 830-clk-bcm-Add-driver-for-BCM53573-ILP-clock.patch} (64%) diff --git a/target/linux/bcm53xx/patches-4.4/830-clk-bcm-Add-driver-for-Northstar-ILP-clock.patch b/target/linux/bcm53xx/patches-4.4/830-clk-bcm-Add-driver-for-BCM53573-ILP-clock.patch similarity index 64% rename from target/linux/bcm53xx/patches-4.4/830-clk-bcm-Add-driver-for-Northstar-ILP-clock.patch rename to target/linux/bcm53xx/patches-4.4/830-clk-bcm-Add-driver-for-BCM53573-ILP-clock.patch index 4cf9b71416..322a1660d0 100644 --- a/target/linux/bcm53xx/patches-4.4/830-clk-bcm-Add-driver-for-Northstar-ILP-clock.patch +++ b/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?= 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 Content-Type: text/plain; charset=UTF-8 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. 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 Make ILP DT entry part of PMU 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 + 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/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 -+++ b/Documentation/devicetree/bindings/clock/brcm,ns-ilp.txt ++++ b/Documentation/devicetree/bindings/clock/brcm,bcm53573-ilp.txt @@ -0,0 +1,40 @@ -+Broadcom Northstar ILP clock -+============================ ++Broadcom BCM53573 ILP clock ++=========================== + +This binding uses the common clock binding: + Documentation/devicetree/bindings/clock/clock-bindings.txt + +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 +handing power-related aspects. Please note PMU contains more subdevices, @@ -54,7 +66,7 @@ V3: Drop #include +which has to be referenced. + +Required properties: -+- compatible: "brcm,ns-ilp" ++- compatible: "brcm,bcm53573-ilp" +- reg: iomem address range of PMU (Power Management Unit) +- reg-names: "pmu", the only needed & supported reg right now +- clocks: has to reference an ALP clock @@ -69,7 +81,7 @@ V3: Drop #include + #size-cells = <1>; + + ilp: ilp@0 { -+ compatible = "brcm,ns-ilp"; ++ compatible = "brcm,bcm53573-ilp"; + reg = <0 0x1000>; + reg-names = "pmu"; + clocks = <&alp>; @@ -83,10 +95,10 @@ V3: Drop #include obj-$(CONFIG_ARCH_BCM_CYGNUS) += clk-cygnus.o obj-$(CONFIG_ARCH_BCM_NSP) += 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 -+++ 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 + * @@ -95,7 +107,6 @@ V3: Drop #include + * published by the Free Software Foundation. + */ + -+#include +#include +#include +#include @@ -108,15 +119,14 @@ V3: Drop #include +#define XTAL_CTL_EN 0x80000000 +#define PMU_SLOW_CLK_PERIOD 0x6dc + -+struct ns_ilp { -+ struct clk *clk; ++struct bcm53573_ilp { + struct clk_hw hw; + 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(0x10000, ilp->pmu + 0x674); @@ -124,14 +134,22 @@ V3: Drop #include + 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; + 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 */ + writel(XTAL_CTL_EN, pmu + PMU_XTAL_FREQ_RATIO); @@ -159,6 +177,8 @@ V3: Drop #include + num++; + break; + } ++ ++ cpu_relax(); + } + + /* Disable measurement to save power */ @@ -169,14 +189,15 @@ V3: Drop #include + 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 clk_init_data init = { 0 }; + const char *parent_name; @@ -209,27 +230,29 @@ V3: Drop #include + } + + init.name = np->name; -+ init.ops = &ns_ilp_clk_ops; ++ init.ops = &bcm53573_ilp_clk_ops; + init.parent_names = &parent_name; + init.num_parents = 1; + + 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; + -+ 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) -+ goto err_clk_unregister; ++ goto err_clk_hw_unregister; + + return; + -+err_clk_unregister: -+ clk_unregister(ilp->clk); ++err_clk_hw_unregister: ++ clk_hw_unregister(&ilp->hw); +err_unmap_pmu: + iounmap(ilp->pmu); +err_free_ilp: + kfree(ilp); + 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); diff --git a/target/linux/bcm53xx/patches-4.4/905-BCM53573-minor-hacks.patch b/target/linux/bcm53xx/patches-4.4/905-BCM53573-minor-hacks.patch index c48170aa97..6f17e10ded 100644 --- a/target/linux/bcm53xx/patches-4.4/905-BCM53573-minor-hacks.patch +++ b/target/linux/bcm53xx/patches-4.4/905-BCM53573-minor-hacks.patch @@ -16,7 +16,7 @@ Signed-off-by: Rafał Miłecki }; + ilp: ilp@0 { -+ compatible = "brcm,ns-ilp"; ++ compatible = "brcm,bcm53573-ilp"; + reg = <0x18012000 0x1000>; + reg-names = "pmu"; + clocks = <&alp>; -- 2.25.1