clk: iproc: add support for BCM NS, NSP, and NS2
Subsystems (4)
cover clk: iproc: add support for BCM NS, NSP, and NS2
This patch series adds support for the Broadcom Northstar, Northstar Plus, and Northstar 2 clocks. Some slight modifications were necessary to clk-iproc-pll to get Northstar and Northstar Plus working, due to differences in register layout. This is the reason why the first patch is necessary. Some more modifications were necessary to clk-iproc-pll to get Northstar 2 working, due to differences in register layout (and resulting fallout in Cygnus and NSP). This is the reason why the sixth and seventh patches are necessary. The fifth patch is clean-up to prevent accidentally forgetting to adjust for the base write errata (which happened a few times, but was caught in internal review).
There is a potential merge "race" between the device tree changes and the clk changes. If the device tree changes go in before the clk changes, there is a window where there are non-working clk entries in the device tree. So, it makes the most sense for this series to be pulled into the clk maintainer's tree solely.
Also, the Northstar Plus device tree modifications were left out of this series due to potential complications with the merging of this series. Northstar Plus was recently accepted, and only exists in Florian's tree. This would cause merge issues in the clk tree. So, the NSP device tree changes will be submitted at a later date.
Thanks,
Jon
.../bindings/clock/brcm,iproc-clocks.txt | 78 ++++++ arch/arm/boot/dts/bcm5301x.dtsi | 67 ++++- arch/arm64/Kconfig.platforms | 1 + arch/arm64/boot/dts/broadcom/ns2.dtsi | 81 ++++++ drivers/clk/Makefile | 3 +- drivers/clk/bcm/Makefile | 3 + drivers/clk/bcm/clk-cygnus.c | 17 +- drivers/clk/bcm/clk-iproc-pll.c | 183 +++++++------ drivers/clk/bcm/clk-iproc.h | 22 +- drivers/clk/bcm/clk-ns2.c | 290 +++++++++++++++++++++ drivers/clk/bcm/clk-nsp.c | 143 ++++++++++ include/dt-bindings/clock/bcm-ns2.h | 72 +++++ include/dt-bindings/clock/bcm-nsp.h | 51 ++++ 13 files changed, 918 insertions(+), 93 deletions(-)
PATCH 1/10 clk: iproc: Add PWRCTRL support
Some iProc SoC clocks use a different way to control clock power, via the PWRDWN bit in the PLL control register. Since the PLL control register is used to access the PWRDWN bit, there is no need for the pwr_base when this is being used. A new flag, IPROC_CLK_EMBED_PWRCTRL, has been added to identify this usage. We can use the AON interface to write the values to enable/disable PWRDOWN.
--- drivers/clk/bcm/clk-iproc-pll.c | 55 ++++++++++++++++++++++++++++------------- drivers/clk/bcm/clk-iproc.h | 6 +++++ 2 files changed, 44 insertions(+), 17 deletions(-)
drivers/clk/bcm/clk-iproc-pll.c +38 -17
@@ -148,14 +148,25 @@ static void __pll_disable(struct iproc_pll *pll)writel (val, pll->asiu_base + ctrl->asiu.offset); } -/* latch input value so core power can be shut down */ - val =readl (pll->pwr_base + ctrl->aon.offset); - val |= (1 << ctrl->aon.iso_shift); -writel (val, pll->pwr_base + ctrl->aon.offset); - -/* power down the core */ - val &= ~(bit_mask (ctrl->aon.pwr_width) << ctrl->aon.pwr_shift); -writel (val, pll->pwr_base + ctrl->aon.offset); +if (ctrl->flags &IPROC_CLK_EMBED_PWRCTRL ) { + val =readl (pll->pll_base + ctrl->aon.offset); + val |= (bit_mask (ctrl->aon.pwr_width) << ctrl->aon.pwr_shift); +writel (val, pll->pll_base + ctrl->aon.offset); + +if (unlikely (ctrl->flags &IPROC_CLK_NEEDS_READ_BACK )) +readl (pll->pll_base + ctrl->aon.offset); + } + +if (pll->pwr_base) { +/* latch input value so core power can be shut down */ + val =readl (pll->pwr_base + ctrl->aon.offset); + val |= (1 << ctrl->aon.iso_shift); +writel (val, pll->pwr_base + ctrl->aon.offset); + +/* power down the core */ + val &= ~(bit_mask (ctrl->aon.pwr_width) << ctrl->aon.pwr_shift); +writel (val, pll->pwr_base + ctrl->aon.offset); + } }static int __pll_enable (struct iproc_pll *pll)
@@ -163,11 +174,22 @@ static int __pll_enable(struct iproc_pll *pll)const struct iproc_pll_ctrl *ctrl = pll->ctrl;u32 val; -/* power up the PLL and make sure it's not latched */ - val =readl (pll->pwr_base + ctrl->aon.offset); - val |=bit_mask (ctrl->aon.pwr_width) << ctrl->aon.pwr_shift; - val &= ~(1 << ctrl->aon.iso_shift); -writel (val, pll->pwr_base + ctrl->aon.offset); +if (ctrl->flags &IPROC_CLK_EMBED_PWRCTRL ) { + val =readl (pll->pll_base + ctrl->aon.offset); + val &= ~(bit_mask (ctrl->aon.pwr_width) << ctrl->aon.pwr_shift); +writel (val, pll->pll_base + ctrl->aon.offset); + +if (unlikely (ctrl->flags &IPROC_CLK_NEEDS_READ_BACK )) +readl (pll->pll_base + ctrl->aon.offset); + } + +if (pll->pwr_base) { +/* power up the PLL and make sure it's not latched */ + val =readl (pll->pwr_base + ctrl->aon.offset); + val |=bit_mask (ctrl->aon.pwr_width) << ctrl->aon.pwr_shift; + val &= ~(1 << ctrl->aon.iso_shift); +writel (val, pll->pwr_base + ctrl->aon.offset); + }/* certain PLLs also need to be ungated from the ASIU top level */ if (ctrl->flags &IPROC_CLK_PLL_ASIU ) {
@@ -610,9 +632,8 @@ void __init iproc_pll_clk_setup(struct device_node *node,if (WARN_ON (!pll->pll_base)) goto err_pll_iomap; +/* Some SoCs do not require the pwr_base, thus failing is not fatal */ pll->pwr_base =of_iomap (node,1 ); -if (WARN_ON (!pll->pwr_base)) - goto err_pwr_iomap;/* some PLLs require gating control at the top ASIU level */ if (pll_ctrl->flags &IPROC_CLK_PLL_ASIU ) {
@@ -695,9 +716,9 @@ err_pll_register:iounmap (pll->asiu_base); err_asiu_iomap: -iounmap (pll->pwr_base); +if (pll->pwr_base) +iounmap (pll->pwr_base); -err_pwr_iomap:iounmap (pll->pll_base); err_pll_iomap:
drivers/clk/bcm/clk-iproc.h +6 -0
@@ -49,6 +49,12 @@#define IPROC_CLK_PLL_NEEDS_SW_CFG BIT(4)/* +* Some PLLs use a different way to control clock power, via the PWRDWN bit in +* the PLL control register +*/ +#define IPROC_CLK_EMBED_PWRCTRL BIT(5) + +/* * Parameters for VCO frequency configuration * * VCO frequency =
Signature · 1 line
1.9.1
PATCH 2/10 clk: nsp: add clock support for Broadcom Northstar Plus SoC
In reply to Jon MasonThe Broadcom Northstar Plus SoC is architected under the iProc architecture. It has the following PLLs: ARMPLL, GENPLL, LCPLL0, all derived from an onboard crystal.
--- drivers/clk/bcm/Makefile | 2 + drivers/clk/bcm/clk-nsp.c | 139 ++++++++++++++++++++++++++++++++++++ include/dt-bindings/clock/bcm-nsp.h | 51 +++++++++++++ 3 files changed, 192 insertions(+) create mode 100644 drivers/clk/bcm/clk-nsp.c create mode 100644 include/dt-bindings/clock/bcm-nsp.h
drivers/clk/bcm/Makefile +2 -0
@@ -4,3 +4,5 @@ obj-$(CONFIG_CLK_BCM_KONA) += clk-bcm281xx.o obj-$(CONFIG_CLK_BCM_KONA) += clk-bcm21664.o obj-$(CONFIG_COMMON_CLK_IPROC) += clk-iproc-armpll.o clk-iproc-pll.o clk-iproc-asiu.o obj-$(CONFIG_ARCH_BCM_CYGNUS) += clk-cygnus.o +obj-$(CONFIG_ARCH_BCM_NSP) += clk-nsp.o +obj-$(CONFIG_ARCH_BCM_5301X) += clk-nsp.o
drivers/clk/bcm/clk-nsp.c new file +139 -0
139 lines not on this page · raw message
include/dt-bindings/clock/bcm-nsp.h new file +51 -0
51 lines not on this page · raw message
Signature · 1 line
1.9.1
Re: [PATCH 02/10] clk: nsp: add clock support for Broadcom Northstar Plus SoC
Quoted 15 lines · Jon Mason
drivers/clk/bcm/clk-nsp.c new file +9
-0@@ -0,0 +1,139 @@ +/* +* Copyright (C) 2015 Broadcom Corporation +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation version 2. +* +* This program is distributed "as is" WITHOUT ANY WARRANTY of any +* kind, whether express or implied; without even the implied warranty
drivers/clk/bcm/clk-nsp.c line 19
Quoted 10 lines
drivers/clk/bcm/clk-nsp.c new file +10
-0+* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#include <linux/kernel.h> +#include <linux/err.h> +#include <linux/clk-provider.h> +#include <linux/io.h> +#include <linux/of.h> +#include <linux/clkdev.h>
Is this used?
drivers/clk/bcm/clk-nsp.c line 21
Quoted 2 lines
drivers/clk/bcm/clk-nsp.c new file +2
-0+#include <linux/of_address.h> +#include <linux/delay.h>
Is this used?
Quoted 3 lines
drivers/clk/bcm/clk-nsp.c new file +3
-0+ +#include <dt-bindings/clock/bcm-nsp.h> +#include "clk-iproc.h"
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH 02/10] clk: nsp: add clock support for Broadcom Northstar Plus SoC
Quoted 29 lines · Stephen Boyd
Quoted 15 lines · Jon Mason
drivers/clk/bcm/clk-nsp.c new file +9
-0@@ -0,0 +1,139 @@ +/* +* Copyright (C) 2015 Broadcom Corporation +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation version 2. +* +* This program is distributed "as is" WITHOUT ANY WARRANTY of any +* kind, whether express or implied; without even the implied warranty drivers/clk/bcm/clk-nsp.c line 19
Quoted 10 lines
drivers/clk/bcm/clk-nsp.c new file +10
-0+* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#include <linux/kernel.h> +#include <linux/err.h> +#include <linux/clk-provider.h> +#include <linux/io.h> +#include <linux/of.h> +#include <linux/clkdev.h> Is this used?
Quoted 4 lines
drivers/clk/bcm/clk-nsp.c line 21
Quoted 2 lines
drivers/clk/bcm/clk-nsp.c new file +2
-0+#include <linux/of_address.h> +#include <linux/delay.h> Is this used?
I removed the clkdev and delay headers, and it appears to be working fine without them. I'll rework this commit and resubmit.
Thanks,
Jon
Quoted 8 lines
Quoted 4 lines
drivers/clk/bcm/clk-nsp.c new file +3
-0+ +#include <dt-bindings/clock/bcm-nsp.h> +#include "clk-iproc.h" Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH 3/10 clk: iproc: define Broadcom NSP iProc clock binding
In reply to Jon MasonDocument the device tree bindings for Broadcom Northstar Plus architecture based clock controller
--- .../bindings/clock/brcm,iproc-clocks.txt | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+)
Documentation/devicetree/bindings/clock/brcm,iproc-clocks.txt +30 -0
@@ -130,3 +130,33 @@ These clock IDs are defined in: ch3_unused mipipll 4 BCM_CYGNUS_MIPIPLL_CH3_UNUSED ch4_unused mipipll 5 BCM_CYGNUS_MIPIPLL_CH4_UNUSED ch5_unused mipipll 6 BCM_CYGNUS_MIPIPLL_CH5_UNUSED + +Northstar and Northstar Plus +------ +PLL and leaf clock compatible strings for Northstar and Northstar Plus are: + "brcm,nsp-armpll" + "brcm,nsp-genpll" + "brcm,nsp-lcpll0" + +The following table defines the set of PLL/clock index and ID for Northstar and +Northstar Plus. These clock IDs are defined in: + "include/dt-bindings/clock/bcm-nsp.h" + + Clock Source Index ID + --- ----- ----- --------- + crystal N/A N/A N/A + + armpll crystal N/A N/A + + genpll crystal 0 BCM_NSP_GENPLL + phy genpll 1 BCM_NSP_GENPLL_PHY_CLK + ethernetclk genpll 2 BCM_NSP_GENPLL_ENET_SW_CLK + usbclk genpll 3 BCM_NSP_GENPLL_USB_PHY_REF_CLK + iprocfast genpll 4 BCM_NSP_GENPLL_IPROCFAST_CLK + sata1 genpll 5 BCM_NSP_GENPLL_SATA1_CLK + sata2 genpll 6 BCM_NSP_GENPLL_SATA2_CLK + + lcpll0 crystal 0 BCM_NSP_LCPLL0 + pcie_phy lcpll0 1 BCM_NSP_LCPLL0_PCIE_PHY_REF_CLK + sdio lcpll0 2 BCM_NSP_LCPLL0_SDIO_CLK + ddr_phy lcpll0 3 BCM_NSP_LCPLL0_DDR_PHY_CLK
Signature · 1 line
1.9.1
PATCH 4/10 ARM: dts: enable clock support for BCM5301X
In reply to Jon MasonReplace current device tree dummy clocks with real clock support for Broadcom Northstar SoCs.
--- arch/arm/boot/dts/bcm5301x.dtsi | 67 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 60 insertions(+), 7 deletions(-)
arch/arm/boot/dts/bcm5301x.dtsi +60 -7
@@ -8,6 +8,7 @@ * Licensed under the GNU/GPL. See COPYING for details. */ +#include <dt-bindings/clock/bcm-nsp.h> #include <dt-bindings/gpio/gpio.h> #include <dt-bindings/input/input.h> #include <dt-bindings/interrupt-controller/irq.h>
@@ -55,14 +56,14 @@ compatible = "arm,cortex-a9-global-timer"; reg = <0x0200 0x100>; interrupts = <GIC_PPI 11 IRQ_TYPE_LEVEL_HIGH>; - clocks = <&clk_periph>; + clocks = <&periph_clk>; }; local-timer at 0600 { compatible = "arm,cortex-a9-twd-timer"; reg = <0x0600 0x100>; interrupts = <GIC_PPI 13 IRQ_TYPE_LEVEL_HIGH>; - clocks = <&clk_periph>; + clocks = <&periph_clk>; }; gic: interrupt-controller at 1000 {
@@ -94,14 +95,66 @@ clocks { #address-cells = <1>; - #size-cells = <0>; + #size-cells = <1>; + ranges; - /* As long as we do not have a real clock driver us this - * fixed clock */ - clk_periph: periph { + osc: oscillator { + #clock-cells = <0>; compatible = "fixed-clock"; + clock-frequency = <25000000>; + }; + + lcpll0: lcpll0 at 1800c100 { + #clock-cells = <1>; + compatible = "brcm,nsp-lcpll0"; + reg = <0x1800c100 0x14>; + clocks = <&osc>; + clock-output-names = "lcpll0", "pcie_phy", "sdio", + "ddr_phy"; + }; + + genpll: genpll at 1800c140 { + #clock-cells = <1>; + compatible = "brcm,nsp-genpll"; + reg = <0x1800c140 0x24>; + clocks = <&osc>; + clock-output-names = "genpll", "phy", "ethernetclk", + "usbclk", "iprocfast", "sata1", + "sata2"; + }; + + iprocmed: iprocmed { + #clock-cells = <0>; + compatible = "fixed-factor-clock"; + clocks = <&genpll BCM_NSP_GENPLL_IPROCFAST_CLK>; + clock-div = <2>; + clock-mult = <1>; + clock-output-names = "iprocmed"; + }; + + iprocslow: iprocslow { + #clock-cells = <0>; + compatible = "fixed-factor-clock"; + clocks = <&genpll BCM_NSP_GENPLL_IPROCFAST_CLK>; + clock-div = <4>; + clock-mult = <1>; + clock-output-names = "iprocslow"; + }; + + + a9pll: arm_clk at 19000000 { + #clock-cells = <0>; + compatible = "brcm,nsp-armpll"; + clocks = <&osc>; + reg = <0x19000000 0x1000>; + }; + + periph_clk: periph_clk { #clock-cells = <0>; - clock-frequency = <400000000>; + compatible = "fixed-factor-clock"; + clocks = <&a9pll>; + clock-div = <2>; + clock-mult = <1>; }; };
Signature · 1 line
1.9.1
Re: [PATCH 04/10] ARM: dts: enable clock support for BCM5301X
Quoted 5 lines · Jon Mason
Replace current device tree dummy clocks with real clock support for Broadcom Northstar SoCs.
Signed-off-by Jon Mason <[email protected]>---
I'd rather not take any dts changes through clk tree.
Quoted 25 lines
arch/arm/boot/dts/bcm5301x.dtsi | 67 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 60 insertions(+), 7 deletions(-)arch/arm/boot/dts/bcm5301x.dtsi +2
-2@@ -55,14 +56,14 @@ compatible = "arm,cortex-a9-global-timer"; reg = <0x0200 0x100>; interrupts = <GIC_PPI 11 IRQ_TYPE_LEVEL_HIGH>; - clocks = <&clk_periph>; + clocks = <&periph_clk>; }; local-timer at 0600 { compatible = "arm,cortex-a9-twd-timer"; reg = <0x0600 0x100>; interrupts = <GIC_PPI 13 IRQ_TYPE_LEVEL_HIGH>; - clocks = <&clk_periph>; + clocks = <&periph_clk>; }; gic: interrupt-controller at 1000 {
arch/arm/boot/dts/bcm5301x.dtsi line 96
Quoted 2 lines
arch/arm/boot/dts/bcm5301x.dtsi +0
-0@@ -94,14 +95,66 @@ clocks {
I'd expect this to only contain nodes that don't have a reg property. Clock providers that have a reg property would go into some soc node or bus. Perhaps that's the chipcommonA node, or axi?
Quoted 59 lines
arch/arm/boot/dts/bcm5301x.dtsi +52
-4#address-cells = <1>; - #size-cells = <0>; + #size-cells = <1>; + ranges; - /* As long as we do not have a real clock driver us this - * fixed clock */ - clk_periph: periph { + osc: oscillator { + #clock-cells = <0>; compatible = "fixed-clock"; + clock-frequency = <25000000>; + }; + + lcpll0: lcpll0 at 1800c100 { + #clock-cells = <1>; + compatible = "brcm,nsp-lcpll0"; + reg = <0x1800c100 0x14>; + clocks = <&osc>; + clock-output-names = "lcpll0", "pcie_phy", "sdio", + "ddr_phy"; + }; + + genpll: genpll at 1800c140 { + #clock-cells = <1>; + compatible = "brcm,nsp-genpll"; + reg = <0x1800c140 0x24>; + clocks = <&osc>; + clock-output-names = "genpll", "phy", "ethernetclk", + "usbclk", "iprocfast", "sata1", + "sata2"; + }; + + iprocmed: iprocmed { + #clock-cells = <0>; + compatible = "fixed-factor-clock"; + clocks = <&genpll BCM_NSP_GENPLL_IPROCFAST_CLK>; + clock-div = <2>; + clock-mult = <1>; + clock-output-names = "iprocmed"; + }; + + iprocslow: iprocslow { + #clock-cells = <0>; + compatible = "fixed-factor-clock"; + clocks = <&genpll BCM_NSP_GENPLL_IPROCFAST_CLK>; + clock-div = <4>; + clock-mult = <1>; + clock-output-names = "iprocslow"; + }; + + + a9pll: arm_clk at 19000000 { + #clock-cells = <0>; + compatible = "brcm,nsp-armpll"; + clocks = <&osc>; + reg = <0x19000000 0x1000>; + }; +
arch/arm/boot/dts/bcm5301x.dtsi line 160
Quoted 10 lines
arch/arm/boot/dts/bcm5301x.dtsi +5
-1+ periph_clk: periph_clk { #clock-cells = <0>; - clock-frequency = <400000000>; + compatible = "fixed-factor-clock"; + clocks = <&a9pll>; + clock-div = <2>; + clock-mult = <1>; }; };
We're trying to move away from putting individual clocks into DT like this. Is there some sort of clock controller that's at 0x1800c000, but we're just not exposing all the clocks in there? See this thread for more information on why we'd like to avoid this sort of design:
http://lkml.kernel.org/r/<20150416192014.19585.9663@quantum>
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH 04/10] ARM: dts: enable clock support for BCM5301X
Quoted 8 lines · Stephen Boyd
Quoted 5 lines · Jon Mason
Replace current device tree dummy clocks with real clock support for Broadcom Northstar SoCs.
Signed-off-by Jon Mason <[email protected]>---
I'd rather not take any dts changes through clk tree.
Ok, I'll split off the device tree portion of this patch series, and submit that after the clk driver portion has been accepted and pushed upstream.
Quoted 27 lines
Quoted 27 lines
arch/arm/boot/dts/bcm5301x.dtsi | 67 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 60 insertions(+), 7 deletions(-)arch/arm/boot/dts/bcm5301x.dtsi +2
-2@@ -55,14 +56,14 @@ compatible = "arm,cortex-a9-global-timer"; reg = <0x0200 0x100>; interrupts = <GIC_PPI 11 IRQ_TYPE_LEVEL_HIGH>; - clocks = <&clk_periph>; + clocks = <&periph_clk>; }; local-timer at 0600 { compatible = "arm,cortex-a9-twd-timer"; reg = <0x0600 0x100>; interrupts = <GIC_PPI 13 IRQ_TYPE_LEVEL_HIGH>; - clocks = <&clk_periph>; + clocks = <&periph_clk>; }; gic: interrupt-controller at 1000 {@@ -94,14 +95,66 @@
Quoted 6 lines
arch/arm/boot/dts/bcm5301x.dtsi line 96
Quoted 1 line
arch/arm/boot/dts/bcm5301x.dtsi +0
-0clocks {I'd expect this to only contain nodes that don't have a reg property. Clock providers that have a reg property would go into some soc node or bus. Perhaps that's the chipcommonA node, or axi?
This might get a little ugly, as some of the clocks are in the 0x18000000 and others are in 0x19000000. I would think it better to have them all in one place (as that is more readable). Do you preferr I split the pieces up into their respective DT nodes?
Quoted 77 lines
Quoted 60 lines
arch/arm/boot/dts/bcm5301x.dtsi +52
-4#address-cells = <1>; - #size-cells = <0>; + #size-cells = <1>; + ranges; - /* As long as we do not have a real clock driver us this - * fixed clock */ - clk_periph: periph { + osc: oscillator { + #clock-cells = <0>; compatible = "fixed-clock"; + clock-frequency = <25000000>; + }; + + lcpll0: lcpll0 at 1800c100 { + #clock-cells = <1>; + compatible = "brcm,nsp-lcpll0"; + reg = <0x1800c100 0x14>; + clocks = <&osc>; + clock-output-names = "lcpll0", "pcie_phy", "sdio", + "ddr_phy"; + }; + + genpll: genpll at 1800c140 { + #clock-cells = <1>; + compatible = "brcm,nsp-genpll"; + reg = <0x1800c140 0x24>; + clocks = <&osc>; + clock-output-names = "genpll", "phy", "ethernetclk", + "usbclk", "iprocfast", "sata1", + "sata2"; + }; + + iprocmed: iprocmed { + #clock-cells = <0>; + compatible = "fixed-factor-clock"; + clocks = <&genpll BCM_NSP_GENPLL_IPROCFAST_CLK>; + clock-div = <2>; + clock-mult = <1>; + clock-output-names = "iprocmed"; + }; + + iprocslow: iprocslow { + #clock-cells = <0>; + compatible = "fixed-factor-clock"; + clocks = <&genpll BCM_NSP_GENPLL_IPROCFAST_CLK>; + clock-div = <4>; + clock-mult = <1>; + clock-output-names = "iprocslow"; + }; + + + a9pll: arm_clk at 19000000 { + #clock-cells = <0>; + compatible = "brcm,nsp-armpll"; + clocks = <&osc>; + reg = <0x19000000 0x1000>; + }; +arch/arm/boot/dts/bcm5301x.dtsi line 160
Quoted 10 lines
arch/arm/boot/dts/bcm5301x.dtsi +5
-1+ periph_clk: periph_clk { #clock-cells = <0>; - clock-frequency = <400000000>; + compatible = "fixed-factor-clock"; + clocks = <&a9pll>; + clock-div = <2>; + clock-mult = <1>; }; };We're trying to move away from putting individual clocks into DT like this. Is there some sort of clock controller that's at
0x1800c000, but we're just not exposing all the clocks in there? See this thread for more information on why we'd like to avoid this sort of design:
Quoted 1 line
http://lkml.kernel.org/r/<20150416192014.19585.9663@quantum>
Okay, I'll clean-up the clock-output-names, per the referenced email.
Thanks,
Jon
Quoted 4 lines
Signature · 3 lines
-- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH 04/10] ARM: dts: enable clock support for BCM5301X
Quoted 36 lines · Jon Mason
Quoted 28 lines · Stephen Boyd
Quoted 26 lines · Jon Mason
arch/arm/boot/dts/bcm5301x.dtsi | 67 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 60 insertions(+), 7 deletions(-)arch/arm/boot/dts/bcm5301x.dtsi +2
-2@@ -55,14 +56,14 @@ compatible = "arm,cortex-a9-global-timer"; reg = <0x0200 0x100>; interrupts = <GIC_PPI 11 IRQ_TYPE_LEVEL_HIGH>; - clocks = <&clk_periph>; + clocks = <&periph_clk>; }; local-timer at 0600 { compatible = "arm,cortex-a9-twd-timer"; reg = <0x0600 0x100>; interrupts = <GIC_PPI 13 IRQ_TYPE_LEVEL_HIGH>; - clocks = <&clk_periph>; + clocks = <&periph_clk>; }; gic: interrupt-controller at 1000 {@@ -94,14 +95,66 @@Quoted 6 lines
arch/arm/boot/dts/bcm5301x.dtsi line 96
Quoted 1 line
arch/arm/boot/dts/bcm5301x.dtsi +0
-0clocks {I'd expect this to only contain nodes that don't have a reg property. Clock providers that have a reg property would go into some soc node or bus. Perhaps that's the chipcommonA node, or axi?
Quoted 4 lines
This might get a little ugly, as some of the clocks are in the
0x18000000and others are in0x19000000. I would think it better to have them all in one place (as that is more readable). Do you preferr I split the pieces up into their respective DT nodes?
Are there two clock controllers? Sorry I don't understand the architecture here very well. Nodes with reg properties in the same range should be near each other. We don't group all i2c controllers into the same node because they're logically i2c controllers. We express the hierarchy of devices with container nodes. The clocks node is only useful for board-level clocks, not things that are inside the SoC.
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH 04/10] ARM: dts: enable clock support for BCM5301X
Quoted 42 lines · Stephen Boyd
Quoted 36 lines · Jon Mason
Quoted 28 lines · Stephen Boyd
Quoted 26 lines · Jon Mason
arch/arm/boot/dts/bcm5301x.dtsi | 67 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 60 insertions(+), 7 deletions(-)arch/arm/boot/dts/bcm5301x.dtsi +2
-2@@ -55,14 +56,14 @@ compatible = "arm,cortex-a9-global-timer"; reg = <0x0200 0x100>; interrupts = <GIC_PPI 11 IRQ_TYPE_LEVEL_HIGH>; - clocks = <&clk_periph>; + clocks = <&periph_clk>; }; local-timer at 0600 { compatible = "arm,cortex-a9-twd-timer"; reg = <0x0600 0x100>; interrupts = <GIC_PPI 13 IRQ_TYPE_LEVEL_HIGH>; - clocks = <&clk_periph>; + clocks = <&periph_clk>; }; gic: interrupt-controller at 1000 {@@ -94,14 +95,66 @@Quoted 6 lines
arch/arm/boot/dts/bcm5301x.dtsi line 96
Quoted 1 line
arch/arm/boot/dts/bcm5301x.dtsi +0
-0clocks {I'd expect this to only contain nodes that don't have a reg property. Clock providers that have a reg property would go into some soc node or bus. Perhaps that's the chipcommonA node, or axi?
Quoted 4 lines
This might get a little ugly, as some of the clocks are in the
0x18000000and others are in0x19000000. I would think it better to have them all in one place (as that is more readable). Do you preferr I split the pieces up into their respective DT nodes?
Quoted 7 lines
Are there two clock controllers? Sorry I don't understand the architecture here very well. Nodes with reg properties in the same range should be near each other. We don't group all i2c controllers into the same node because they're logically i2c controllers. We express the hierarchy of devices with container nodes. The clocks node is only useful for board-level clocks, not things that are inside the SoC.
3 clock sources: a9pll, lcpll, and genpll. The first one resides in the IP block living at the 0x19000000 address range, while the latter two live in the 0x18000000 address range.
I'll split up the clocks amongst the respective entries, per your suggestion.
Thanks,
Jon
Quoted 4 lines
Signature · 3 lines
-- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH 5/10 clk: iproc: Add PLL base write function
In reply to Jon MasonAll writes to the PLL base address must be flushed if the IPROC_CLK_NEEDS_READ_BACK flag is set. If we add a function to make the necessary write and reads, we can make sure that any future code which makes PLL base writes will do the correct thing.
--- drivers/clk/bcm/clk-iproc-pll.c | 80 +++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 47 deletions(-)
drivers/clk/bcm/clk-iproc-pll.c +33 -47
@@ -137,6 +137,18 @@ static int pll_wait_for_lock(struct iproc_pll *pll)return -EIO ; } +static void iproc_pll_write (struct iproc_pll *pll,void __iomem *base, +u32 offset,u32 val) +{ +const struct iproc_pll_ctrl *ctrl = pll->ctrl; + +writel (val, base + offset); + +if (unlikely (ctrl->flags &IPROC_CLK_NEEDS_READ_BACK && + base == pll->pll_base)) + val =readl (base + offset); +} +static void __pll_disable (struct iproc_pll *pll) {const struct iproc_pll_ctrl *ctrl = pll->ctrl;
@@ -145,27 +157,24 @@ static void __pll_disable(struct iproc_pll *pll)if (ctrl->flags &IPROC_CLK_PLL_ASIU ) { val =readl (pll->asiu_base + ctrl->asiu.offset); val &= ~(1 << ctrl->asiu.en_shift); -writel (val, pll->asiu_base + ctrl->asiu.offset); +iproc_pll_write (pll, pll->asiu_base, ctrl->asiu.offset, val); }if (ctrl->flags &IPROC_CLK_EMBED_PWRCTRL ) { val =readl (pll->pll_base + ctrl->aon.offset); val |= (bit_mask (ctrl->aon.pwr_width) << ctrl->aon.pwr_shift); -writel (val, pll->pll_base + ctrl->aon.offset); - -if (unlikely (ctrl->flags &IPROC_CLK_NEEDS_READ_BACK )) -readl (pll->pll_base + ctrl->aon.offset); +iproc_pll_write (pll, pll->pll_base, ctrl->aon.offset, val); }if (pll->pwr_base) {/* latch input value so core power can be shut down */ val =readl (pll->pwr_base + ctrl->aon.offset); val |= (1 << ctrl->aon.iso_shift); -writel (val, pll->pwr_base + ctrl->aon.offset); +iproc_pll_write (pll, pll->pwr_base, ctrl->aon.offset, val);/* power down the core */ val &= ~(bit_mask (ctrl->aon.pwr_width) << ctrl->aon.pwr_shift); -writel (val, pll->pwr_base + ctrl->aon.offset); +iproc_pll_write (pll, pll->pwr_base, ctrl->aon.offset, val); } }
@@ -177,10 +186,7 @@ static int __pll_enable(struct iproc_pll *pll)if (ctrl->flags &IPROC_CLK_EMBED_PWRCTRL ) { val =readl (pll->pll_base + ctrl->aon.offset); val &= ~(bit_mask (ctrl->aon.pwr_width) << ctrl->aon.pwr_shift); -writel (val, pll->pll_base + ctrl->aon.offset); - -if (unlikely (ctrl->flags &IPROC_CLK_NEEDS_READ_BACK )) -readl (pll->pll_base + ctrl->aon.offset); +iproc_pll_write (pll, pll->pll_base, ctrl->aon.offset, val); }if (pll->pwr_base) {
@@ -188,14 +194,14 @@ static int __pll_enable(struct iproc_pll *pll) val =readl (pll->pwr_base + ctrl->aon.offset); val |=bit_mask (ctrl->aon.pwr_width) << ctrl->aon.pwr_shift; val &= ~(1 << ctrl->aon.iso_shift); -writel (val, pll->pwr_base + ctrl->aon.offset); +iproc_pll_write (pll, pll->pwr_base, ctrl->aon.offset, val); }/* certain PLLs also need to be ungated from the ASIU top level */ if (ctrl->flags &IPROC_CLK_PLL_ASIU ) { val =readl (pll->asiu_base + ctrl->asiu.offset); val |= (1 << ctrl->asiu.en_shift); -writel (val, pll->asiu_base + ctrl->asiu.offset); +iproc_pll_write (pll, pll->asiu_base, ctrl->asiu.offset, val); }return 0 ;
@@ -209,9 +215,7 @@ static void __pll_put_in_reset(struct iproc_pll *pll) val =readl (pll->pll_base + reset->offset); val &= ~(1 << reset->reset_shift |1 << reset->p_reset_shift); -writel (val, pll->pll_base + reset->offset); -if (unlikely (ctrl->flags &IPROC_CLK_NEEDS_READ_BACK )) -readl (pll->pll_base + reset->offset); +iproc_pll_write (pll, pll->pll_base, reset->offset, val); } static void __pll_bring_out_reset(struct iproc_pll *pll, unsigned int kp,
@@ -228,9 +232,7 @@ static void __pll_bring_out_reset(struct iproc_pll *pll, unsigned int kp, val |= ki << reset->ki_shift | kp << reset->kp_shift | ka << reset->ka_shift; val |=1 << reset->reset_shift |1 << reset->p_reset_shift; -writel (val, pll->pll_base + reset->offset); -if (unlikely (ctrl->flags &IPROC_CLK_NEEDS_READ_BACK )) -readl (pll->pll_base + reset->offset); +iproc_pll_write (pll, pll->pll_base, reset->offset, val); } static int pll_set_rate(struct iproc_clk *clk, unsigned int rate_index,
@@ -285,9 +287,8 @@ static int pll_set_rate(struct iproc_clk *clk, unsigned int rate_index,/* put PLL in reset */ __pll_put_in_reset (pll); -writel (0 , pll->pll_base + ctrl->vco_ctrl.u_offset); -if (unlikely (ctrl->flags &IPROC_CLK_NEEDS_READ_BACK )) -readl (pll->pll_base + ctrl->vco_ctrl.u_offset); +iproc_pll_write (pll, pll->pll_base, ctrl->vco_ctrl.u_offset,0 ); + val =readl (pll->pll_base + ctrl->vco_ctrl.l_offset);if (rate >=VCO_LOW && rate <VCO_MID )
@@ -298,17 +299,13 @@ static int pll_set_rate(struct iproc_clk *clk, unsigned int rate_index,else val |= (1 <<PLL_VCO_HIGH_SHIFT ); -writel (val, pll->pll_base + ctrl->vco_ctrl.l_offset); -if (unlikely (ctrl->flags &IPROC_CLK_NEEDS_READ_BACK )) -readl (pll->pll_base + ctrl->vco_ctrl.l_offset); +iproc_pll_write (pll, pll->pll_base, ctrl->vco_ctrl.l_offset, val);/* program integer part of NDIV */ val =readl (pll->pll_base + ctrl->ndiv_int.offset); val &= ~(bit_mask (ctrl->ndiv_int.width) << ctrl->ndiv_int.shift); val |= vco->ndiv_int << ctrl->ndiv_int.shift; -writel (val, pll->pll_base + ctrl->ndiv_int.offset); -if (unlikely (ctrl->flags &IPROC_CLK_NEEDS_READ_BACK )) -readl (pll->pll_base + ctrl->ndiv_int.offset); +iproc_pll_write (pll, pll->pll_base, ctrl->ndiv_int.offset, val);/* program fractional part of NDIV */ if (ctrl->flags &IPROC_CLK_PLL_HAS_NDIV_FRAC ) {
@@ -316,18 +313,15 @@ static int pll_set_rate(struct iproc_clk *clk, unsigned int rate_index, val &= ~(bit_mask (ctrl->ndiv_frac.width) << ctrl->ndiv_frac.shift); val |= vco->ndiv_frac << ctrl->ndiv_frac.shift; -writel (val, pll->pll_base + ctrl->ndiv_frac.offset); -if (unlikely (ctrl->flags &IPROC_CLK_NEEDS_READ_BACK )) -readl (pll->pll_base + ctrl->ndiv_frac.offset); +iproc_pll_write (pll, pll->pll_base, ctrl->ndiv_frac.offset, + val); }/* program PDIV */ val =readl (pll->pll_base + ctrl->pdiv.offset); val &= ~(bit_mask (ctrl->pdiv.width) << ctrl->pdiv.shift); val |= vco->pdiv << ctrl->pdiv.shift; -writel (val, pll->pll_base + ctrl->pdiv.offset); -if (unlikely (ctrl->flags &IPROC_CLK_NEEDS_READ_BACK )) -readl (pll->pll_base + ctrl->pdiv.offset); +iproc_pll_write (pll, pll->pll_base, ctrl->pdiv.offset, val);__pll_bring_out_reset (pll, kp, ka, ki);
@@ -467,14 +461,12 @@ static int iproc_clk_enable(struct clk_hw *hw)/* channel enable is active low */ val =readl (pll->pll_base + ctrl->enable.offset); val &= ~(1 << ctrl->enable.enable_shift); -writel (val, pll->pll_base + ctrl->enable.offset); +iproc_pll_write (pll, pll->pll_base, ctrl->enable.offset, val);/* also make sure channel is not held */ val =readl (pll->pll_base + ctrl->enable.offset); val &= ~(1 << ctrl->enable.hold_shift); -writel (val, pll->pll_base + ctrl->enable.offset); -if (unlikely (ctrl->flags &IPROC_CLK_NEEDS_READ_BACK )) -readl (pll->pll_base + ctrl->enable.offset); +iproc_pll_write (pll, pll->pll_base, ctrl->enable.offset, val);return 0 ; }
@@ -491,9 +483,7 @@ static void iproc_clk_disable(struct clk_hw *hw) val =readl (pll->pll_base + ctrl->enable.offset); val |=1 << ctrl->enable.enable_shift; -writel (val, pll->pll_base + ctrl->enable.offset); -if (unlikely (ctrl->flags &IPROC_CLK_NEEDS_READ_BACK )) -readl (pll->pll_base + ctrl->enable.offset); +iproc_pll_write (pll, pll->pll_base, ctrl->enable.offset, val); } static unsigned long iproc_clk_recalc_rate(struct clk_hw *hw,
@@ -562,9 +552,7 @@ static int iproc_clk_set_rate(struct clk_hw *hw, unsigned long rate, val &= ~(bit_mask (ctrl->mdiv.width) << ctrl->mdiv.shift); val |= div << ctrl->mdiv.shift; } -writel (val, pll->pll_base + ctrl->mdiv.offset); -if (unlikely (ctrl->flags &IPROC_CLK_NEEDS_READ_BACK )) -readl (pll->pll_base + ctrl->mdiv.offset); +iproc_pll_write (pll, pll->pll_base, ctrl->mdiv.offset, val); clk->rate = parent_rate / div;return 0 ;
@@ -591,9 +579,7 @@ static void iproc_pll_sw_cfg(struct iproc_pll *pll) val =readl (pll->pll_base + ctrl->sw_ctrl.offset); val |=BIT (ctrl->sw_ctrl.shift); -writel (val, pll->pll_base + ctrl->sw_ctrl.offset); -if (unlikely (ctrl->flags &IPROC_CLK_NEEDS_READ_BACK )) -readl (pll->pll_base + ctrl->sw_ctrl.offset); +iproc_pll_write (pll, pll->pll_base, ctrl->sw_ctrl.offset, val); } }
Signature · 1 line
1.9.1
Re: [PATCH 05/10] clk: iproc: Add PLL base write function
drivers/clk/bcm/clk-iproc-pll.c static int pll_wait_for_lock(struct iproc_pll *pll) · line 140
Quoted 9 lines · Jon Mason
drivers/clk/bcm/clk-iproc-pll.c +1
-0@@ -137,6 +137,18 @@ static int pll_wait_for_lock(struct iproc_pll *pll)return -EIO ; } +static void iproc_pll_write(struct iproc_pll *pll, void __iomem *base,
Seems that pll could be const too?
Quoted 4 lines
drivers/clk/bcm/clk-iproc-pll.c +4
-0+ u32 offset, u32 val) +{ +const struct iproc_pll_ctrl *ctrl = pll->ctrl; +
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH 05/10] clk: iproc: Add PLL base write function
Quoted 9 lines · Stephen Boyd
Quoted 8 lines · Jon Mason
drivers/clk/bcm/clk-iproc-pll.c +0
-0@@ -137,6 +137,18 @@ static int pll_wait_for_lock(struct iproc_pll *pll)return -EIO ; }
Quoted 3 lines
drivers/clk/bcm/clk-iproc-pll.c static int pll_wait_for_lock(struct iproc_pll *pll) · line 140
Quoted 1 line
drivers/clk/bcm/clk-iproc-pll.c +1
-0+static void iproc_pll_write(struct iproc_pll *pll, void __iomem *base,Seems that pll could be const too?
Yes, and offset can be const too. I'll make these changes and resubmit.
Thanks,
Jon
Quoted 9 lines
Quoted 5 lines
drivers/clk/bcm/clk-iproc-pll.c +4
-0+ u32 offset, u32 val) +{ +const struct iproc_pll_ctrl *ctrl = pll->ctrl; +Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH 05/10] clk: iproc: Add PLL base write function
In reply to Jon MasonQuoted 8 lines · Jon Mason
drivers/clk/bcm/clk-iproc-pll.c +0
-0@@ -137,6 +137,18 @@ static int pll_wait_for_lock(struct iproc_pll *pll)return -EIO ; }
drivers/clk/bcm/clk-iproc-pll.c static int pll_wait_for_lock(struct iproc_pll *pll) · line 149
Quoted 10 lines
drivers/clk/bcm/clk-iproc-pll.c +10
-0+static void iproc_pll_write (struct iproc_pll *pll,void __iomem *base, +u32 offset,u32 val) +{ +const struct iproc_pll_ctrl *ctrl = pll->ctrl; + +writel (val, base + offset); + +if (unlikely (ctrl->flags &IPROC_CLK_NEEDS_READ_BACK && + base == pll->pll_base)) + val =readl (base + offset);
Is there any point to assign val here?
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH 05/10] clk: iproc: Add PLL base write function
Quoted 9 lines · Stephen Boyd
Quoted 8 lines · Jon Mason
drivers/clk/bcm/clk-iproc-pll.c +0
-0@@ -137,6 +137,18 @@ static int pll_wait_for_lock(struct iproc_pll *pll)return -EIO ; }
Quoted 12 lines
drivers/clk/bcm/clk-iproc-pll.c static int pll_wait_for_lock(struct iproc_pll *pll) · line 149
Quoted 10 lines
drivers/clk/bcm/clk-iproc-pll.c +10
-0+static void iproc_pll_write (struct iproc_pll *pll,void __iomem *base, +u32 offset,u32 val) +{ +const struct iproc_pll_ctrl *ctrl = pll->ctrl; + +writel (val, base + offset); + +if (unlikely (ctrl->flags &IPROC_CLK_NEEDS_READ_BACK && + base == pll->pll_base)) + val =readl (base + offset);Is there any point to assign val here?
It is a flush. The val assignment could be excluded (and thus made const) if so desired.
Thanks,
Jon
Quoted 4 lines
Signature · 3 lines
-- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH 6/10 clk: iproc: Split off dig_filter
In reply to Jon MasonThe PLL loop filter/gain can be located in a separate register on some SoCs. Split these off into a separate variable, so that an offset can be added if necessary. Also, make the necessary modifications to the Cygnus and NSP drivers for this change.
--- drivers/clk/bcm/clk-cygnus.c | 17 +++++++++++------ drivers/clk/bcm/clk-iproc-pll.c | 14 +++++++++----- drivers/clk/bcm/clk-iproc.h | 10 +++++++++- drivers/clk/bcm/clk-nsp.c | 14 +++++++++----- 4 files changed, 38 insertions(+), 17 deletions(-)
drivers/clk/bcm/clk-cygnus.c +11 -6
@@ -34,9 +34,11 @@ { .offset = o, .en_shift = es, .high_shift = hs, \ .high_width = hw, .low_shift = ls, .low_width = lw } -#define reset_val (o, rs, prs, kis, kiw, kps, kpw, kas, kaw) { .offset = o, \ - .reset_shift = rs, .p_reset_shift = prs, .ki_shift = kis, \ - .ki_width = kiw, .kp_shift = kps, .kp_width = kpw, .ka_shift = kas, \ +#define reset_val (o, rs, prs) { .offset = o, .reset_shift = rs, \ + .p_reset_shift = prs } + +#define df_val (o, kis, kiw, kps, kpw, kas, kaw) { .offset = o, .ki_shift = kis,\ + .ki_width = kiw, .kp_shift = kps, .kp_width = kpw, .ka_shift = kas, \ .ka_width = kaw }#define vco_ctrl_val (uo, lo) { .u_offset = uo, .l_offset = lo }
@@ -56,7 +58,8 @@ static const struct iproc_pll_ctrl genpll = { .flags = IPROC_CLK_AON | IPROC_CLK_PLL_HAS_NDIV_FRAC | IPROC_CLK_PLL_NEEDS_SW_CFG, .aon = aon_val(0x0, 2, 1, 0), - .reset = reset_val(0x0, 11, 10, 4, 3, 0, 4, 7, 3), + .reset = reset_val(0x0, 11, 10), + .dig_filter = df_val(0x0, 4, 3, 0, 4, 7, 3), .sw_ctrl = sw_ctrl_val(0x10, 31), .ndiv_int = reg_val(0x10, 20, 10), .ndiv_frac = reg_val(0x10, 0, 20),
@@ -114,7 +117,8 @@ CLK_OF_DECLARE(cygnus_genpll, "brcm,cygnus-genpll", cygnus_genpll_clk_init);static const struct iproc_pll_ctrl lcpll0 = { .flags =IPROC_CLK_AON |IPROC_CLK_PLL_NEEDS_SW_CFG , .aon =aon_val (0x0 ,2 ,5 ,4 ), - .reset =reset_val (0x0 ,31 ,30 ,27 ,3 ,23 ,4 ,19 ,4 ), + .reset =reset_val (0x0 ,31 ,30 ), + .dig_filter =df_val (0x0 ,27 ,3 ,23 ,4 ,19 ,4 ), .sw_ctrl =sw_ctrl_val (0x4 ,31 ), .ndiv_int =reg_val (0x4 ,16 ,10 ), .pdiv =reg_val (0x4 ,26 ,4 ),
@@ -191,7 +195,8 @@ static const struct iproc_pll_ctrl mipipll = { IPROC_CLK_NEEDS_READ_BACK, .aon = aon_val(0x0, 4, 17, 16), .asiu = asiu_gate_val(0x0, 3), - .reset = reset_val(0x0, 11, 10, 4, 3, 0, 4, 7, 4), + .reset = reset_val(0x0, 11, 10), + .dig_filter = df_val(0x0, 4, 3, 0, 4, 7, 4), .ndiv_int = reg_val(0x10, 20, 10), .ndiv_frac = reg_val(0x10, 0, 20), .pdiv = reg_val(0x14, 0, 4),
drivers/clk/bcm/clk-iproc-pll.c +9 -5
@@ -224,13 +224,17 @@ static void __pll_bring_out_reset(struct iproc_pll *pll, unsigned int kp,u32 val;const struct iproc_pll_ctrl *ctrl = pll->ctrl;const struct iproc_pll_reset_ctrl *reset = &ctrl->reset; +const struct iproc_pll_dig_filter_ctrl *dig_filter = &ctrl->dig_filter; + + val =readl (pll->pll_base + dig_filter->offset); + val &= ~(bit_mask (dig_filter->ki_width) << dig_filter->ki_shift | +bit_mask (dig_filter->kp_width) << dig_filter->kp_shift | +bit_mask (dig_filter->ka_width) << dig_filter->ka_shift); + val |= ki << dig_filter->ki_shift | kp << dig_filter->kp_shift | + ka << dig_filter->ka_shift; +iproc_pll_write (pll, pll->pll_base, dig_filter->offset, val); val =readl (pll->pll_base + reset->offset); - val &= ~(bit_mask (reset->ki_width) << reset->ki_shift | -bit_mask (reset->kp_width) << reset->kp_shift | -bit_mask (reset->ka_width) << reset->ka_shift); - val |= ki << reset->ki_shift | kp << reset->kp_shift | - ka << reset->ka_shift; val |=1 << reset->reset_shift |1 << reset->p_reset_shift;iproc_pll_write (pll, pll->pll_base, reset->offset, val); }
drivers/clk/bcm/clk-iproc.h +9 -1
@@ -94,12 +94,19 @@ struct iproc_pll_aon_pwr_ctrl { };/* -* Control of the PLL reset, with Ki, Kp, and Ka parameters +* Control of the PLL reset */ struct iproc_pll_reset_ctrl {unsigned int offset;unsigned int reset_shift;unsigned int p_reset_shift; +}; + +/* +* Control of the Ki, Kp, and Ka parameters +*/ +struct iproc_pll_dig_filter_ctrl { +unsigned int offset;unsigned int ki_shift;unsigned int ki_width;unsigned int kp_shift;
@@ -129,6 +136,7 @@ struct iproc_pll_ctrl {struct iproc_pll_aon_pwr_ctrl aon;struct iproc_asiu_gate asiu;struct iproc_pll_reset_ctrl reset; +struct iproc_pll_dig_filter_ctrl dig_filter;struct iproc_pll_sw_ctrl sw_ctrl;struct iproc_clk_reg_op ndiv_int;struct iproc_clk_reg_op ndiv_frac;
drivers/clk/bcm/clk-nsp.c +9 -5
@@ -28,9 +28,11 @@#define aon_val (o, pw, ps, is) { .offset = o, .pwr_width = pw, \ .pwr_shift = ps, .iso_shift = is } -#define reset_val (o, rs, prs, kis, kiw, kps, kpw, kas, kaw) { .offset = o, \ - .reset_shift = rs, .p_reset_shift = prs, .ki_shift = kis, \ - .ki_width = kiw, .kp_shift = kps, .kp_width = kpw, .ka_shift = kas, \ +#define reset_val (o, rs, prs) { .offset = o, .reset_shift = rs, \ + .p_reset_shift = prs } + +#define df_val (o, kis, kiw, kps, kpw, kas, kaw) { .offset = o, .ki_shift = kis,\ + .ki_width = kiw, .kp_shift = kps, .kp_width = kpw, .ka_shift = kas, \ .ka_width = kaw }#define vco_ctrl_val (uo, lo) { .u_offset = uo, .l_offset = lo }
@@ -47,7 +49,8 @@ CLK_OF_DECLARE(nsp_armpll, "brcm,nsp-armpll", nsp_armpll_init);static const struct iproc_pll_ctrl genpll = { .flags =IPROC_CLK_PLL_HAS_NDIV_FRAC |IPROC_CLK_EMBED_PWRCTRL , .aon =aon_val (0x0 ,1 ,12 ,0 ), - .reset =reset_val (0x0 ,11 ,10 ,4 ,3 ,0 ,4 ,7 ,3 ), + .reset =reset_val (0x0 ,11 ,10 ), + .dig_filter =df_val (0x0 ,4 ,3 ,0 ,4 ,7 ,3 ), .ndiv_int =reg_val (0x14 ,20 ,10 ), .ndiv_frac =reg_val (0x14 ,0 ,20 ), .pdiv =reg_val (0x18 ,24 ,3 ),
@@ -103,7 +106,8 @@ CLK_OF_DECLARE(nsp_genpll_clk, "brcm,nsp-genpll", nsp_genpll_clk_init);static const struct iproc_pll_ctrl lcpll0 = { .flags =IPROC_CLK_PLL_HAS_NDIV_FRAC |IPROC_CLK_EMBED_PWRCTRL , .aon =aon_val (0x0 ,1 ,24 ,0 ), - .reset =reset_val (0x0 ,23 ,22 ,16 ,3 ,12 ,4 ,19 ,4 ), + .reset =reset_val (0x0 ,23 ,22 ), + .dig_filter =df_val (0x0 ,16 ,3 ,12 ,4 ,19 ,4 ), .ndiv_int =reg_val (0x4 ,20 ,8 ), .ndiv_frac =reg_val (0x4 ,0 ,20 ), .pdiv =reg_val (0x4 ,28 ,3 ),
Signature · 1 line
1.9.1
PATCH 7/10 clk: iproc: Separate status and control variables
In reply to Jon MasonSome PLLs have separate registers for Status and Control. The means the pll_base needs to be split into 2 new variables, so that those PLLs can specify device tree registers for those independently. Also, add a new driver flag to identify this presence of the split, and let the driver know that additional registers need to be used.
--- drivers/clk/bcm/clk-iproc-pll.c | 96 ++++++++++++++++++++++++----------------- drivers/clk/bcm/clk-iproc.h | 6 +++ 2 files changed, 62 insertions(+), 40 deletions(-)
drivers/clk/bcm/clk-iproc-pll.c +56 -40
@@ -74,7 +74,8 @@ struct iproc_clk { };struct iproc_pll { -void __iomem *pll_base; +void __iomem *status_base; +void __iomem *control_base;void __iomem *pwr_base;void __iomem *asiu_base;
@@ -127,7 +128,7 @@ static int pll_wait_for_lock(struct iproc_pll *pll)const struct iproc_pll_ctrl *ctrl = pll->ctrl;for (i =0 ; i <LOCK_DELAY ; i++) { -u32 val =readl (pll->pll_base + ctrl->status.offset); +u32 val =readl (pll->status_base + ctrl->status.offset);if (val & (1 << ctrl->status.shift))return 0 ;
@@ -145,7 +146,7 @@ static void iproc_pll_write(struct iproc_pll *pll, void __iomem *base,writel (val, base + offset);if (unlikely (ctrl->flags &IPROC_CLK_NEEDS_READ_BACK && - base == pll->pll_base)) + (base == pll->status_base || base == pll->control_base))) val =readl (base + offset); }
@@ -161,9 +162,9 @@ static void __pll_disable(struct iproc_pll *pll) }if (ctrl->flags &IPROC_CLK_EMBED_PWRCTRL ) { - val =readl (pll->pll_base + ctrl->aon.offset); + val =readl (pll->control_base + ctrl->aon.offset); val |= (bit_mask (ctrl->aon.pwr_width) << ctrl->aon.pwr_shift); -iproc_pll_write (pll, pll->pll_base, ctrl->aon.offset, val); +iproc_pll_write (pll, pll->control_base, ctrl->aon.offset, val); }if (pll->pwr_base) {
@@ -184,9 +185,9 @@ static int __pll_enable(struct iproc_pll *pll)u32 val;if (ctrl->flags &IPROC_CLK_EMBED_PWRCTRL ) { - val =readl (pll->pll_base + ctrl->aon.offset); + val =readl (pll->control_base + ctrl->aon.offset); val &= ~(bit_mask (ctrl->aon.pwr_width) << ctrl->aon.pwr_shift); -iproc_pll_write (pll, pll->pll_base, ctrl->aon.offset, val); +iproc_pll_write (pll, pll->control_base, ctrl->aon.offset, val); }if (pll->pwr_base) {
@@ -213,9 +214,9 @@ static void __pll_put_in_reset(struct iproc_pll *pll)const struct iproc_pll_ctrl *ctrl = pll->ctrl;const struct iproc_pll_reset_ctrl *reset = &ctrl->reset; - val =readl (pll->pll_base + reset->offset); + val =readl (pll->control_base + reset->offset); val &= ~(1 << reset->reset_shift |1 << reset->p_reset_shift); -iproc_pll_write (pll, pll->pll_base, reset->offset, val); +iproc_pll_write (pll, pll->control_base, reset->offset, val); } static void __pll_bring_out_reset(struct iproc_pll *pll, unsigned int kp,
@@ -226,17 +227,17 @@ static void __pll_bring_out_reset(struct iproc_pll *pll, unsigned int kp,const struct iproc_pll_reset_ctrl *reset = &ctrl->reset;const struct iproc_pll_dig_filter_ctrl *dig_filter = &ctrl->dig_filter; - val =readl (pll->pll_base + dig_filter->offset); + val =readl (pll->control_base + dig_filter->offset); val &= ~(bit_mask (dig_filter->ki_width) << dig_filter->ki_shift |bit_mask (dig_filter->kp_width) << dig_filter->kp_shift |bit_mask (dig_filter->ka_width) << dig_filter->ka_shift); val |= ki << dig_filter->ki_shift | kp << dig_filter->kp_shift | ka << dig_filter->ka_shift; -iproc_pll_write (pll, pll->pll_base, dig_filter->offset, val); +iproc_pll_write (pll, pll->control_base, dig_filter->offset, val); - val =readl (pll->pll_base + reset->offset); + val =readl (pll->control_base + reset->offset); val |=1 << reset->reset_shift |1 << reset->p_reset_shift; -iproc_pll_write (pll, pll->pll_base, reset->offset, val); +iproc_pll_write (pll, pll->control_base, reset->offset, val); } static int pll_set_rate(struct iproc_clk *clk, unsigned int rate_index,
@@ -291,9 +292,9 @@ static int pll_set_rate(struct iproc_clk *clk, unsigned int rate_index,/* put PLL in reset */ __pll_put_in_reset (pll); -iproc_pll_write (pll, pll->pll_base, ctrl->vco_ctrl.u_offset,0 ); +iproc_pll_write (pll, pll->control_base, ctrl->vco_ctrl.u_offset,0 ); - val =readl (pll->pll_base + ctrl->vco_ctrl.l_offset); + val =readl (pll->control_base + ctrl->vco_ctrl.l_offset);if (rate >=VCO_LOW && rate <VCO_MID ) val |= (1 <<PLL_VCO_LOW_SHIFT );
@@ -303,29 +304,29 @@ static int pll_set_rate(struct iproc_clk *clk, unsigned int rate_index,else val |= (1 <<PLL_VCO_HIGH_SHIFT ); -iproc_pll_write (pll, pll->pll_base, ctrl->vco_ctrl.l_offset, val); +iproc_pll_write (pll, pll->control_base, ctrl->vco_ctrl.l_offset, val);/* program integer part of NDIV */ - val =readl (pll->pll_base + ctrl->ndiv_int.offset); + val =readl (pll->control_base + ctrl->ndiv_int.offset); val &= ~(bit_mask (ctrl->ndiv_int.width) << ctrl->ndiv_int.shift); val |= vco->ndiv_int << ctrl->ndiv_int.shift; -iproc_pll_write (pll, pll->pll_base, ctrl->ndiv_int.offset, val); +iproc_pll_write (pll, pll->control_base, ctrl->ndiv_int.offset, val);/* program fractional part of NDIV */ if (ctrl->flags &IPROC_CLK_PLL_HAS_NDIV_FRAC ) { - val =readl (pll->pll_base + ctrl->ndiv_frac.offset); + val =readl (pll->control_base + ctrl->ndiv_frac.offset); val &= ~(bit_mask (ctrl->ndiv_frac.width) << ctrl->ndiv_frac.shift); val |= vco->ndiv_frac << ctrl->ndiv_frac.shift; -iproc_pll_write (pll, pll->pll_base, ctrl->ndiv_frac.offset, +iproc_pll_write (pll, pll->control_base, ctrl->ndiv_frac.offset, val); }/* program PDIV */ - val =readl (pll->pll_base + ctrl->pdiv.offset); + val =readl (pll->control_base + ctrl->pdiv.offset); val &= ~(bit_mask (ctrl->pdiv.width) << ctrl->pdiv.shift); val |= vco->pdiv << ctrl->pdiv.shift; -iproc_pll_write (pll, pll->pll_base, ctrl->pdiv.offset, val); +iproc_pll_write (pll, pll->control_base, ctrl->pdiv.offset, val);__pll_bring_out_reset (pll, kp, ka, ki);
@@ -372,7 +373,7 @@ static unsigned long iproc_pll_recalc_rate(struct clk_hw *hw,return 0 ;/* PLL needs to be locked */ - val =readl (pll->pll_base + ctrl->status.offset); + val =readl (pll->status_base + ctrl->status.offset);if ((val & (1 << ctrl->status.shift)) ==0 ) { clk->rate =0 ;return 0 ;
@@ -383,13 +384,13 @@ static unsigned long iproc_pll_recalc_rate(struct clk_hw *hw,* * ((ndiv_int + ndiv_frac / 2^20) * (parent clock rate / pdiv) */ - val =readl (pll->pll_base + ctrl->ndiv_int.offset); + val =readl (pll->control_base + ctrl->ndiv_int.offset); ndiv_int = (val >> ctrl->ndiv_int.shift) &bit_mask (ctrl->ndiv_int.width); ndiv = (u64 )ndiv_int << ctrl->ndiv_int.shift;if (ctrl->flags &IPROC_CLK_PLL_HAS_NDIV_FRAC ) { - val =readl (pll->pll_base + ctrl->ndiv_frac.offset); + val =readl (pll->control_base + ctrl->ndiv_frac.offset); ndiv_frac = (val >> ctrl->ndiv_frac.shift) &bit_mask (ctrl->ndiv_frac.width);
@@ -398,7 +399,7 @@ static unsigned long iproc_pll_recalc_rate(struct clk_hw *hw, ndiv_frac; } - val =readl (pll->pll_base + ctrl->pdiv.offset); + val =readl (pll->control_base + ctrl->pdiv.offset); pdiv = (val >> ctrl->pdiv.shift) &bit_mask (ctrl->pdiv.width); clk->rate = (ndiv * parent_rate) >> ctrl->ndiv_int.shift;
@@ -463,14 +464,14 @@ static int iproc_clk_enable(struct clk_hw *hw)u32 val;/* channel enable is active low */ - val =readl (pll->pll_base + ctrl->enable.offset); + val =readl (pll->control_base + ctrl->enable.offset); val &= ~(1 << ctrl->enable.enable_shift); -iproc_pll_write (pll, pll->pll_base, ctrl->enable.offset, val); +iproc_pll_write (pll, pll->control_base, ctrl->enable.offset, val);/* also make sure channel is not held */ - val =readl (pll->pll_base + ctrl->enable.offset); + val =readl (pll->control_base + ctrl->enable.offset); val &= ~(1 << ctrl->enable.hold_shift); -iproc_pll_write (pll, pll->pll_base, ctrl->enable.offset, val); +iproc_pll_write (pll, pll->control_base, ctrl->enable.offset, val);return 0 ; }
@@ -485,9 +486,9 @@ static void iproc_clk_disable(struct clk_hw *hw)if (ctrl->flags &IPROC_CLK_AON )return ; - val =readl (pll->pll_base + ctrl->enable.offset); + val =readl (pll->control_base + ctrl->enable.offset); val |=1 << ctrl->enable.enable_shift; -iproc_pll_write (pll, pll->pll_base, ctrl->enable.offset, val); +iproc_pll_write (pll, pll->control_base, ctrl->enable.offset, val); } static unsigned long iproc_clk_recalc_rate(struct clk_hw *hw,
@@ -502,7 +503,7 @@ static unsigned long iproc_clk_recalc_rate(struct clk_hw *hw,if (parent_rate ==0 )return 0 ; - val =readl (pll->pll_base + ctrl->mdiv.offset); + val =readl (pll->control_base + ctrl->mdiv.offset); mdiv = (val >> ctrl->mdiv.shift) &bit_mask (ctrl->mdiv.width);if (mdiv ==0 ) mdiv =256 ;
@@ -549,14 +550,14 @@ static int iproc_clk_set_rate(struct clk_hw *hw, unsigned long rate,if (div >256 )return -EINVAL ; - val =readl (pll->pll_base + ctrl->mdiv.offset); + val =readl (pll->control_base + ctrl->mdiv.offset);if (div ==256 ) { val &= ~(bit_mask (ctrl->mdiv.width) << ctrl->mdiv.shift); }else { val &= ~(bit_mask (ctrl->mdiv.width) << ctrl->mdiv.shift); val |= div << ctrl->mdiv.shift; } -iproc_pll_write (pll, pll->pll_base, ctrl->mdiv.offset, val); +iproc_pll_write (pll, pll->control_base, ctrl->mdiv.offset, val); clk->rate = parent_rate / div;return 0 ;
@@ -581,9 +582,10 @@ static void iproc_pll_sw_cfg(struct iproc_pll *pll)if (ctrl->flags &IPROC_CLK_PLL_NEEDS_SW_CFG ) {u32 val; - val =readl (pll->pll_base + ctrl->sw_ctrl.offset); + val =readl (pll->control_base + ctrl->sw_ctrl.offset); val |=BIT (ctrl->sw_ctrl.shift); -iproc_pll_write (pll, pll->pll_base, ctrl->sw_ctrl.offset, val); +iproc_pll_write (pll, pll->control_base, ctrl->sw_ctrl.offset, + val); } }
@@ -618,8 +620,8 @@ void __init iproc_pll_clk_setup(struct device_node *node,if (WARN_ON (!pll->clks)) goto err_clks; - pll->pll_base =of_iomap (node,0 ); -if (WARN_ON (!pll->pll_base)) + pll->control_base =of_iomap (node,0 ); +if (WARN_ON (!pll->control_base)) goto err_pll_iomap;/* Some SoCs do not require the pwr_base, thus failing is not fatal */
@@ -632,6 +634,16 @@ void __init iproc_pll_clk_setup(struct device_node *node, goto err_asiu_iomap; } +if (pll_ctrl->flags &IPROC_CLK_PLL_SPLIT_STAT_CTRL ) { +/* Some SoCs have a split status/control. If this does not +* exist, assume they are unified. +*/ + pll->status_base =of_iomap (node,2 ); +if (!pll->status_base) + goto err_status_iomap; + }else + pll->status_base = pll->control_base; +/* initialize and register the PLL itself */ pll->ctrl = pll_ctrl;
@@ -702,6 +714,10 @@ err_clk_register:clk_unregister (pll->clk_data.clks[i]); err_pll_register: +if (pll->status_base != pll->control_base) +iounmap (pll->status_base); + +err_status_iomap:if (pll->asiu_base)iounmap (pll->asiu_base);
@@ -709,7 +725,7 @@ err_asiu_iomap:if (pll->pwr_base)iounmap (pll->pwr_base); -iounmap (pll->pll_base); +iounmap (pll->control_base); err_pll_iomap:kfree (pll->clks);
drivers/clk/bcm/clk-iproc.h +6 -0
@@ -55,6 +55,12 @@#define IPROC_CLK_EMBED_PWRCTRL BIT(5)/* +* Some PLLs have separate registers for Status and Control. Identify this to +* let the driver know if additional registers need to be used +*/ +#define IPROC_CLK_PLL_SPLIT_STAT_CTRL BIT(6) + +/* * Parameters for VCO frequency configuration * * VCO frequency =
Signature · 1 line
1.9.1
PATCH 8/10 clk: iproc: define Broadcom NS2 iProc clock binding
In reply to Jon MasonDocument the device tree bindings for Broadcom Northstar 2 architecture based clock controller
--- .../bindings/clock/brcm,iproc-clocks.txt | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+)
Documentation/devicetree/bindings/clock/brcm,iproc-clocks.txt +48 -0
@@ -160,3 +160,51 @@ Northstar Plus. These clock IDs are defined in: pcie_phy lcpll0 1 BCM_NSP_LCPLL0_PCIE_PHY_REF_CLK sdio lcpll0 2 BCM_NSP_LCPLL0_SDIO_CLK ddr_phy lcpll0 3 BCM_NSP_LCPLL0_DDR_PHY_CLK + +Northstar 2 +----------- +PLL and leaf clock compatible strings for Northstar 2 are: + "brcm,ns2-genpll-scr" + "brcm,ns2-genpll-sw" + "brcm,ns2-lcpll-ddr" + "brcm,ns2-lcpll-ports" + +The following table defines the set of PLL/clock index and ID for Northstar 2. +These clock IDs are defined in: + "include/dt-bindings/clock/bcm-ns2.h" + + Clock Source Index ID + --- ----- ----- --------- + crystal N/A N/A N/A + + genpll_scr crystal 0 BCM_NS2_GENPLL_SCR + scr genpll_scr 1 BCM_NS2_GENPLL_SCR_SCR_CLK + fs genpll_scr 2 BCM_NS2_GENPLL_SCR_FS_CLK + audio_ref genpll_scr 3 BCM_NS2_GENPLL_SCR_AUDIO_CLK + ch3_unused genpll_scr 4 BCM_NS2_GENPLL_SCR_CH3_UNUSED + ch4_unused genpll_scr 5 BCM_NS2_GENPLL_SCR_CH4_UNUSED + ch5_unused genpll_scr 6 BCM_NS2_GENPLL_SCR_CH5_UNUSED + + genpll_sw crystal 0 BCM_NS2_GENPLL_SW + rpe genpll_sw 1 BCM_NS2_GENPLL_SW_RPE_CLK + 250 genpll_sw 2 BCM_NS2_GENPLL_SW_250_CLK + nic genpll_sw 3 BCM_NS2_GENPLL_SW_NIC_CLK + chimp genpll_sw 4 BCM_NS2_GENPLL_SW_CHIMP_CLK + port genpll_sw 5 BCM_NS2_GENPLL_SW_PORT_CLK + sdio genpll_sw 6 BCM_NS2_GENPLL_SW_SDIO_CLK + + lcpll_ddr crystal 0 BCM_NS2_LCPLL_DDR + pcie_sata_usb lcpll_ddr 1 BCM_NS2_LCPLL_DDR_PCIE_SATA_USB_CLK + ddr lcpll_ddr 2 BCM_NS2_LCPLL_DDR_DDR_CLK + ch2_unused lcpll_ddr 3 BCM_NS2_LCPLL_DDR_CH2_UNUSED + ch3_unused lcpll_ddr 4 BCM_NS2_LCPLL_DDR_CH3_UNUSED + ch4_unused lcpll_ddr 5 BCM_NS2_LCPLL_DDR_CH4_UNUSED + ch5_unused lcpll_ddr 6 BCM_NS2_LCPLL_DDR_CH5_UNUSED + + lcpll_ports crystal 0 BCM_NS2_LCPLL_PORTS + wan lcpll_ports 1 BCM_NS2_LCPLL_PORTS_WAN_CLK + rgmii lcpll_ports 2 BCM_NS2_LCPLL_PORTS_RGMII_CLK + ch2_unused lcpll_ports 3 BCM_NS2_LCPLL_PORTS_CH2_UNUSED + ch3_unused lcpll_ports 4 BCM_NS2_LCPLL_PORTS_CH3_UNUSED + ch4_unused lcpll_ports 5 BCM_NS2_LCPLL_PORTS_CH4_UNUSED + ch5_unused lcpll_ports 6 BCM_NS2_LCPLL_PORTS_CH5_UNUSED
Signature · 1 line
1.9.1
PATCH 9/10 clk: ns2: add clock support for Broadcom Northstar 2 SoC
In reply to Jon MasonThe Broadcom Northstar 2 SoC is architected under the iProc architecture. It has the following PLLs: GENPLL SCR, GENPLL SW, LCPLL DDR, LCPLL Ports, all derived from an onboard crystal.
--- arch/arm64/Kconfig.platforms | 1 + drivers/clk/Makefile | 3 +- drivers/clk/bcm/Makefile | 1 + drivers/clk/bcm/clk-ns2.c | 290 ++++++++++++++++++++++++++++++++++++ include/dt-bindings/clock/bcm-ns2.h | 72 +++++++++ 5 files changed, 366 insertions(+), 1 deletion(-) create mode 100644 drivers/clk/bcm/clk-ns2.c create mode 100644 include/dt-bindings/clock/bcm-ns2.h
arch/arm64/Kconfig.platforms +1 -0
@@ -2,6 +2,7 @@ menu "Platform selection" config ARCH_BCM_IPROC bool "Broadcom iProc SoC Family" + select COMMON_CLK_IPROC help This enables support for Broadcom iProc based SoCs
drivers/clk/Makefile +2 -1
@@ -47,7 +47,8 @@ obj-$(CONFIG_COMMON_CLK_WM831X) += clk-wm831x.o obj-$(CONFIG_COMMON_CLK_XGENE) += clk-xgene.o obj-$(CONFIG_COMMON_CLK_PWM) += clk-pwm.o obj-$(CONFIG_COMMON_CLK_AT91) += at91/ -obj-$(CONFIG_ARCH_BCM) += bcm/ +obj-$(CONFIG_CLK_BCM_KONA) += bcm/ +obj-$(CONFIG_COMMON_CLK_IPROC) += bcm/ obj-$(CONFIG_ARCH_BERLIN) += berlin/ obj-$(CONFIG_ARCH_HISI) += hisilicon/ obj-$(CONFIG_ARCH_MXC) += imx/
drivers/clk/bcm/Makefile +1 -0
@@ -3,6 +3,7 @@ obj-$(CONFIG_CLK_BCM_KONA) += clk-kona-setup.o obj-$(CONFIG_CLK_BCM_KONA) += clk-bcm281xx.o obj-$(CONFIG_CLK_BCM_KONA) += clk-bcm21664.o obj-$(CONFIG_COMMON_CLK_IPROC) += clk-iproc-armpll.o clk-iproc-pll.o clk-iproc-asiu.o +obj-$(CONFIG_COMMON_CLK_IPROC) += clk-ns2.o obj-$(CONFIG_ARCH_BCM_CYGNUS) += clk-cygnus.o obj-$(CONFIG_ARCH_BCM_NSP) += clk-nsp.o obj-$(CONFIG_ARCH_BCM_5301X) += clk-nsp.o
drivers/clk/bcm/clk-ns2.c new file +290 -0
290 lines not on this page · raw message
include/dt-bindings/clock/bcm-ns2.h new file +72 -0
72 lines not on this page · raw message
Signature · 1 line
1.9.1
Re: [PATCH 09/10] clk: ns2: add clock support for Broadcom Northstar 2 SoC
Quoted 15 lines · Jon Mason
drivers/clk/bcm/clk-ns2.c new file +9
-0@@ -0,0 +1,290 @@ +/* +* Copyright (C) 2015 Broadcom Corporation +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation version 2. +* +* This program is distributed "as is" WITHOUT ANY WARRANTY of any +* kind, whether express or implied; without even the implied warranty
drivers/clk/bcm/clk-ns2.c line 19
Quoted 10 lines
drivers/clk/bcm/clk-ns2.c new file +10
-0+* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#include <linux/kernel.h> +#include <linux/err.h> +#include <linux/clk-provider.h> +#include <linux/io.h> +#include <linux/of.h> +#include <linux/clkdev.h>
clkdev looks unused here too?
drivers/clk/bcm/clk-ns2.c line 21
Quoted 2 lines
drivers/clk/bcm/clk-ns2.c new file +2
-0+#include <linux/of_address.h> +#include <linux/delay.h>
And this one?
drivers/clk/bcm/clk-ns2.c line 26
Quoted 5 lines
drivers/clk/bcm/clk-ns2.c new file +5
-0+ +#include <dt-bindings/clock/bcm-ns2.h> +#include "clk-iproc.h" + +#define reg_val (o, s, w) { .offset = o, .shift = s, .width = w, }
I guess we missed this one already, but this isn't a macro resembling a function. Kernel style is to capitalize this sort of macro.
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH 09/10] clk: ns2: add clock support for Broadcom Northstar 2 SoC
Quoted 29 lines · Stephen Boyd
Quoted 15 lines · Jon Mason
drivers/clk/bcm/clk-ns2.c new file +9
-0@@ -0,0 +1,290 @@ +/* +* Copyright (C) 2015 Broadcom Corporation +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation version 2. +* +* This program is distributed "as is" WITHOUT ANY WARRANTY of any +* kind, whether express or implied; without even the implied warranty drivers/clk/bcm/clk-ns2.c line 19
Quoted 10 lines
drivers/clk/bcm/clk-ns2.c new file +10
-0+* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#include <linux/kernel.h> +#include <linux/err.h> +#include <linux/clk-provider.h> +#include <linux/io.h> +#include <linux/of.h> +#include <linux/clkdev.h> clkdev looks unused here too?
Quoted 4 lines
drivers/clk/bcm/clk-ns2.c line 21
Quoted 2 lines
drivers/clk/bcm/clk-ns2.c new file +2
-0+#include <linux/of_address.h> +#include <linux/delay.h> And this one?
Yes, already caught this when you mentioned the other file :)
Quoted 10 lines
drivers/clk/bcm/clk-ns2.c line 26
Quoted 6 lines
drivers/clk/bcm/clk-ns2.c new file +5
-0+ +#include <dt-bindings/clock/bcm-ns2.h> +#include "clk-iproc.h" + +#define reg_val (o, s, w) { .offset = o, .shift = s, .width = w, }I guess we missed this one already, but this isn't a macro resembling a function. Kernel style is to capitalize this sort of macro.
I agree, but I was following prior example in drivers/clk/bcm/clk-cygnus.c. I can make the changes here and do a patch for that file making the necessary changes as well. Just let me know your preference.
Thanks,
Jon
Quoted 4 lines
Signature · 3 lines
-- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH 09/10] clk: ns2: add clock support for Broadcom Northstar 2 SoC
In reply to Jon Masonarch/arm64/Kconfig.platforms menu "Platform selection" · line 5
Quoted 9 lines · Jon Mason
arch/arm64/Kconfig.platforms +1
-0@@ -2,6 +2,7 @@ menu "Platform selection" config ARCH_BCM_IPROC bool "Broadcom iProc SoC Family" + select COMMON_CLK_IPROC
Given that this is a visible option, I'd expect the defconfig to enable this.
Quoted 8 lines
arch/arm64/Kconfig.platforms +0
-0help This enables support for Broadcom iProc based SoCsdrivers/clk/Makefile +0
-0
drivers/clk/Makefile obj-$(CONFIG_COMMON_CLK_WM831X) += clk-wm831x.o · line 51
Quoted 6 lines
drivers/clk/Makefile +2
-1@@ -47,7 +47,8 @@ obj-$(CONFIG_COMMON_CLK_WM831X) += clk-wm831x.o obj-$(CONFIG_COMMON_CLK_XGENE) += clk-xgene.o obj-$(CONFIG_COMMON_CLK_PWM) += clk-pwm.o obj-$(CONFIG_COMMON_CLK_AT91) += at91/ -obj-$(CONFIG_ARCH_BCM) += bcm/ +obj-$(CONFIG_CLK_BCM_KONA) += bcm/ +obj-$(CONFIG_COMMON_CLK_IPROC) += bcm/
Also, perhaps we need some sort of Kconfig thing for overall bcm clock drivers, so that we don't have duplicate Makefile rules.
config COMMON_CLK_BCM
bool "Support for Broadcom clocks"
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH 09/10] clk: ns2: add clock support for Broadcom Northstar 2 SoC
Quoted 7 lines · Stephen Boyd
Quoted 6 lines · Jon Mason
arch/arm64/Kconfig.platforms +0
-0@@ -2,6 +2,7 @@ menu "Platform selection"
Quoted 6 lines
arch/arm64/Kconfig.platforms menu "Platform selection" · line 5
Quoted 3 lines
arch/arm64/Kconfig.platforms +1
-0config ARCH_BCM_IPROC bool "Broadcom iProc SoC Family" + select COMMON_CLK_IPROCGiven that this is a visible option, I'd expect the defconfig to enable this.
After looking at this again, it is completely unnecessary. Removed.
Quoted 19 lines
Quoted 9 lines
arch/arm64/Kconfig.platforms +0
-0help This enables support for Broadcom iProc based SoCsdrivers/clk/Makefile +0
-0drivers/clk/Makefile obj-$(CONFIG_COMMON_CLK_WM831X) += clk-wm831x.o · line 51
Quoted 6 lines
drivers/clk/Makefile +2
-1@@ -47,7 +47,8 @@ obj-$(CONFIG_COMMON_CLK_WM831X) += clk-wm831x.o obj-$(CONFIG_COMMON_CLK_XGENE) += clk-xgene.o obj-$(CONFIG_COMMON_CLK_PWM) += clk-pwm.o obj-$(CONFIG_COMMON_CLK_AT91) += at91/ -obj-$(CONFIG_ARCH_BCM) += bcm/ +obj-$(CONFIG_CLK_BCM_KONA) += bcm/ +obj-$(CONFIG_COMMON_CLK_IPROC) += bcm/Also, perhaps we need some sort of
Kconfigthing for overall bcm clock drivers, so that we don't have duplicateMakefilerules.
Quoted 2 lines
config
COMMON_CLK_BCM
bool "Support for Broadcom clocks"
Will do.
Thanks,
Jon
Quoted 4 lines
Signature · 3 lines
-- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Scott Branden
maintainerRe: [PATCH 09/10] clk: ns2: add clock support for Broadcom Northstar 2 SoC
Hi Jon,
Comment below.
Quoted 36 lines · Jon Mason
Quoted 7 lines · Stephen Boyd
Quoted 6 lines · Jon Mason
arch/arm64/Kconfig.platforms +0
-0@@ -2,6 +2,7 @@ menu "Platform selection"Quoted 6 lines
arch/arm64/Kconfig.platforms menu "Platform selection" · line 5
Quoted 3 lines
arch/arm64/Kconfig.platforms +1
-0config ARCH_BCM_IPROC bool "Broadcom iProc SoC Family" + select COMMON_CLK_IPROCGiven that this is a visible option, I'd expect the defconfig to enable this.
After looking at this again, it is completely unnecessary. Removed.
Quoted 19 lines
Quoted 9 lines
arch/arm64/Kconfig.platforms +0
-0help This enables support for Broadcom iProc based SoCsdrivers/clk/Makefile +0
-0drivers/clk/Makefile obj-$(CONFIG_COMMON_CLK_WM831X) += clk-wm831x.o · line 51
Quoted 6 lines
drivers/clk/Makefile +2
-1@@ -47,7 +47,8 @@ obj-$(CONFIG_COMMON_CLK_WM831X) += clk-wm831x.o obj-$(CONFIG_COMMON_CLK_XGENE) += clk-xgene.o obj-$(CONFIG_COMMON_CLK_PWM) += clk-pwm.o obj-$(CONFIG_COMMON_CLK_AT91) += at91/ -obj-$(CONFIG_ARCH_BCM) += bcm/ +obj-$(CONFIG_CLK_BCM_KONA) += bcm/ +obj-$(CONFIG_COMMON_CLK_IPROC) += bcm/Also, perhaps we need some sort of
Kconfigthing for overall bcm clock drivers, so that we don't have duplicateMakefilerules.
Quoted 4 lines
Quoted 2 lines
config
COMMON_CLK_BCM
bool "Support for Broadcom clocks"Will do.
Is that really necessary at all I think something like this work instead?
-obj-$(CONFIG_ARCH_BCM) += bcm/
+obj-y += bcm/
Quoted 9 lines
Thanks,
JonQuoted 4 lines
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH 09/10] clk: ns2: add clock support for Broadcom Northstar 2 SoC
Review
Quoted 8 lines · Scott Branden
Is that really necessary at all I think something like this work instead?
(quoted diff) +1
-1-obj-$(CONFIG_ARCH_BCM) += bcm/ +obj-y += bcm/
Yes that's fine too, as long as we don't add any obj-y inside bcm/Makefile
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH 10/10 ARM: dts: enable clock support for Broadcom NS2
In reply to Jon MasonAdd device tree entries for clock support for Broadcom Northstar 2 SoC
--- arch/arm64/boot/dts/broadcom/ns2.dtsi | 81 +++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+)
arch/arm64/boot/dts/broadcom/ns2.dtsi +81 -0
@@ -31,6 +31,7 @@ */ #include <dt-bindings/interrupt-controller/arm-gic.h> +#include <dt-bindings/clock/bcm-ns2.h> /memreserve/ 0x84b00000 0x00000008;
@@ -89,6 +90,86 @@ IRQ_TYPE_EDGE_RISING)>; }; + clocks { + #address-cells = <1>; + #size-cells = <1>; + ranges = <0 0 0x6501c000 0x00002000>; + + osc: oscillator { + #clock-cells = <0>; + compatible = "fixed-clock"; + clock-frequency = <25000000>; + }; + + lcpll_ddr: lcpll_ddr at 1058 { + #clock-cells = <1>; + compatible = "brcm,ns2-lcpll-ddr"; + reg = <0x1058 0x20>, + <0x0020 0x4>, + <0x104c 0x4>; + clocks = <&osc>; + clock-output-names = "lcpll_ddr", "pcie_sata_usb", + "ddr", "ddr_ch2_unused", + "ddr_ch3_unused", "ddr_ch4_unused", + "ddr_ch5_unused"; + }; + + lcpll_ports: lcpll_ports at 1078 { + #clock-cells = <1>; + compatible = "brcm,ns2-lcpll-ports"; + reg = <0x1078 0x20>, + <0x0020 0x4>, + <0x1054 0x4>; + clocks = <&osc>; + clock-output-names = "lcpll_ports", "wan", "rgmii", + "ports_ch2_unused", + "ports_ch3_unused", + "ports_ch4_unused", + "ports_ch5_unused"; + }; + + genpll_scr: genpll_scr at 1098 { + #clock-cells = <1>; + compatible = "brcm,ns2-genpll-scr"; + reg = <0x1098 0x32>, + <0x0020 0x4>, + <0x1044 0x4>; + clocks = <&osc>; + clock-output-names = "genpll_scr", "scr", "fs", + "audio_ref", "scr_ch3_unused", + "scr_ch4_unused", "scr_ch5_unused"; + }; + + genpll_sw: genpll_sw at 10c4 { + #clock-cells = <1>; + compatible = "brcm,ns2-genpll-sw"; + reg = <0x10c4 0x32>, + <0x0020 0x4>, + <0x1044 0x4>; + clocks = <&osc>; + clock-output-names = "genpll_sw", "rpe", "250", "nic", + "chimp", "port", "sdio"; + }; + + iprocmed: iprocmed { + #clock-cells = <0>; + compatible = "fixed-factor-clock"; + clocks = <&genpll_scr BCM_NS2_GENPLL_SCR_SCR_CLK>; + clock-div = <2>; + clock-mult = <1>; + clock-output-names = "iprocmed"; + }; + + iprocslow: iprocslow { + #clock-cells = <0>; + compatible = "fixed-factor-clock"; + clocks = <&genpll_scr BCM_NS2_GENPLL_SCR_SCR_CLK>; + clock-div = <4>; + clock-mult = <1>; + clock-output-names = "iprocslow"; + }; + }; + soc: soc { compatible = "simple-bus"; #address-cells = <1>;
Signature · 1 line
1.9.1