Add Marvell berlin4ct clk support
Subsystems (3)
cover Add Marvell berlin4ct clk support
Add berlin4ct clk driver. The berlin4ct SoC contains:
two kinds of PLL: normal PLL and AVPLL. The normal PLL support is done. The AVPLL support is in TODO list.
two kinds of clk: normal clk and gate clk. The normal clk supports changing divider, selecting clock source, disabling/enabling etc. The gate clk only supports disabling/enabling. Both are supported in this series.
Jisheng Zhang (5):
clk: berlin: add common pll driver
clk: berlin: add common clk driver for newer SoCs
clk: berlin: add clk support for berlin4ct
dt-bindings: add binding for marvell berlin4ct SoC
arm64: dts: berlin4ct: add pll and clock nodes
.../bindings/clock/marvell,berlin4ct.txt | 38 +++++ arch/arm64/boot/dts/marvell/berlin4ct.dtsi | 38 +++++ drivers/clk/berlin/Makefile | 2 +- drivers/clk/berlin/clk-berlin4ct.c | 164 +++++++++++++++++++++ drivers/clk/berlin/clk.c | 147 ++++++++++++++++++ drivers/clk/berlin/clk.h | 38 +++++ drivers/clk/berlin/pll.c | 119 +++++++++++++++ include/dt-bindings/clock/berlin4ct.h | 56 +++++++ 8 files changed, 601 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/clock/marvell,berlin4ct.txt create mode 100644 drivers/clk/berlin/clk-berlin4ct.c create mode 100644 drivers/clk/berlin/clk.c create mode 100644 drivers/clk/berlin/clk.h create mode 100644 drivers/clk/berlin/pll.c create mode 100644 include/dt-bindings/clock/berlin4ct.h
Signature · 1 line
2.5.3
PATCH 1/5 clk: berlin: add common pll driver
Add pll driver for Marvell SoCs newer than BG2, BG2CD, BG2Q.
--- drivers/clk/berlin/Makefile | 2 +- drivers/clk/berlin/pll.c | 119 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 drivers/clk/berlin/pll.c
drivers/clk/berlin/Makefile +1 -1
@@ -1,4 +1,4 @@ -obj-y += berlin2-avpll.o berlin2-pll.o berlin2-div.o +obj-y += pll.o berlin2-avpll.o berlin2-pll.o berlin2-div.o obj-$(CONFIG_MACH_BERLIN_BG2) += bg2.o obj-$(CONFIG_MACH_BERLIN_BG2CD) += bg2.o obj-$(CONFIG_MACH_BERLIN_BG2Q) += bg2q.o
drivers/clk/berlin/pll.c new file +119 -0
119 lines not on this page · raw message
Signature · 1 line
2.5.3
Re: [PATCH 1/5] clk: berlin: add common pll driver
drivers/clk/berlin/pll.c line 4
Quoted 10 lines · Jisheng Zhang
drivers/clk/berlin/pll.c new file +4
-0@@ -0,0 +1,119 @@ + +#define to_berlin_pll (hw) container_of(hw, struct berlin_pll, hw) + +static u8 vcodiv_berlin[] = {1 ,2 ,4 ,8 ,16 ,32 ,64 ,128 };
This is an array of 1 << index position...
Quoted 8 lines
drivers/clk/berlin/pll.c new file +8
-0+ +static unsigned long berlin_pll_recalc_rate (struct clk_hw *hw, +unsigned long parent_rate) +{ +u32 val, fbdiv, rfdiv, vcodivsel, bypass; +struct berlin_pll *pll =to_berlin_pll (hw); + + bypass =readl_relaxed (pll->bypass);
drivers/clk/berlin/pll.c line 61
Quoted 10 lines
drivers/clk/berlin/pll.c new file +10
-0+if (bypass & (1 << pll->bypass_shift)) +return parent_rate; + + val =readl_relaxed (pll->ctrl +PLL_CTRL0 ); + fbdiv = (val >>12 ) &0x1FF ; + rfdiv = (val >>3 ) &0x1FF ; + val =readl_relaxed (pll->ctrl +PLL_CTRL1 ); + vcodivsel = (val >>9 ) &0x7 ; +return parent_rate * fbdiv *4 / rfdiv / + vcodiv_berlin[vcodivsel];
so we can replace this with 1 << vcodivsel?
drivers/clk/berlin/pll.c line 72
Quoted 11 lines
drivers/clk/berlin/pll.c new file +11
-0+} + +static u8 berlin_pll_get_parent (struct clk_hw *hw) +{ +struct berlin_pll *pll =to_berlin_pll (hw); +u32 bypass =readl_relaxed (pll->bypass); + +if (bypass & (1 << pll->bypass_shift)) +return 1 ; +else +return 0 ;
Simplify this to
if (bypass & (1 << pll->bypass_shift)) return 1; return 0;
or
return !!(bypass & (1 << pll->bypass_shift))
drivers/clk/berlin/pll.c line 80
Quoted 8 lines
drivers/clk/berlin/pll.c new file +8
-0+} + +static const struct clk_ops berlin_pll_ops = { + .recalc_rate = berlin_pll_recalc_rate, + .get_parent = berlin_pll_get_parent, +}; + +void __init berlin_pll_setup (struct device_node *np)
static?
Quoted 5 lines
drivers/clk/berlin/pll.c new file +5
-0+{ +struct clk_init_data init; +struct berlin_pll *pll; +const char *parent_names[PLL_SOURCE_MAX ]; +struct clk *clk;
drivers/clk/berlin/pll.c line 95
Quoted 10 lines
drivers/clk/berlin/pll.c new file +10
-0+int ret, num_parents; + + num_parents =of_clk_get_parent_count (np); +if (num_parents <=0 || num_parents >PLL_SOURCE_MAX ) +return ; + +of_clk_parent_fill (np, parent_names, num_parents); + + pll =kzalloc (sizeof (*pll),GFP_KERNEL ); +if (WARN_ON (!pll))
We already print a big warning on allocation failures, so drop the WARN_ON please.
drivers/clk/berlin/pll.c line 107
Quoted 12 lines
drivers/clk/berlin/pll.c new file +12
-0+return ; + + pll->ctrl =of_iomap (np,0 ); + pll->bypass =of_iomap (np,1 ); + ret =of_property_read_u8 (np,"bypass-shift" , &pll->bypass_shift); +if (WARN_ON (!pll->ctrl || !pll->bypass || ret)) +return ; + + init.name = np->name; + init.ops = &berlin_pll_ops; + init.parent_names = parent_names; + init.num_parents = num_parents;
init.flags is not initialized. Please initialize the init struct on the stack to 0 to avoid future problems.
drivers/clk/berlin/pll.c line 117
Quoted 10 lines
drivers/clk/berlin/pll.c new file +10
-0+ + pll->hw.init = &init; + + clk =clk_register (NULL , &pll->hw); +if (WARN_ON (IS_ERR (clk))) +return ; + + ret =of_clk_add_provider (np, of_clk_src_simple_get, clk); +if (WARN_ON (ret)) +return ;
This return is useless.
Quoted 1 line
drivers/clk/berlin/pll.c new file +1
-0+}
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH 1/5] clk: berlin: add common pll driver
Hi Stephen,
Quoted 13 lines · On Thu, 1 Oct 2015 15:32:20 -0700 Stephen Boyd <[email protected]> wrote:
drivers/clk/berlin/pll.c line 4
Quoted 10 lines · Jisheng Zhang
drivers/clk/berlin/pll.c new file +4
-0@@ -0,0 +1,119 @@ + +#define to_berlin_pll (hw) container_of(hw, struct berlin_pll, hw) + +static u8 vcodiv_berlin[] = {1 ,2 ,4 ,8 ,16 ,32 ,64 ,128 };This is an array of 1 << index position...
oops, yes! I didn't realize this before! Accept all the comments below, will update in v2.
Thanks a lot for review,
Jisheng
Quoted 105 lines
Quoted 9 lines
drivers/clk/berlin/pll.c new file +8
-0+ +static unsigned long berlin_pll_recalc_rate (struct clk_hw *hw, +unsigned long parent_rate) +{ +u32 val, fbdiv, rfdiv, vcodivsel, bypass; +struct berlin_pll *pll =to_berlin_pll (hw); + + bypass =readl_relaxed (pll->bypass);drivers/clk/berlin/pll.c line 61
Quoted 10 lines
drivers/clk/berlin/pll.c new file +10
-0+if (bypass & (1 << pll->bypass_shift)) +return parent_rate; + + val =readl_relaxed (pll->ctrl +PLL_CTRL0 ); + fbdiv = (val >>12 ) &0x1FF ; + rfdiv = (val >>3 ) &0x1FF ; + val =readl_relaxed (pll->ctrl +PLL_CTRL1 ); + vcodivsel = (val >>9 ) &0x7 ; +return parent_rate * fbdiv *4 / rfdiv / + vcodiv_berlin[vcodivsel];so we can replace this with 1 << vcodivsel?
drivers/clk/berlin/pll.c line 72
Quoted 11 lines
drivers/clk/berlin/pll.c new file +11
-0+} + +static u8 berlin_pll_get_parent (struct clk_hw *hw) +{ +struct berlin_pll *pll =to_berlin_pll (hw); +u32 bypass =readl_relaxed (pll->bypass); + +if (bypass & (1 << pll->bypass_shift)) +return 1 ; +else +return 0 ;Simplify this to
if (bypass & (1 << pll->bypass_shift)) return 1; return 0;or
return !!(bypass & (1 << pll->bypass_shift))drivers/clk/berlin/pll.c line 80
Quoted 8 lines
drivers/clk/berlin/pll.c new file +8
-0+} + +static const struct clk_ops berlin_pll_ops = { + .recalc_rate = berlin_pll_recalc_rate, + .get_parent = berlin_pll_get_parent, +}; + +void __init berlin_pll_setup (struct device_node *np)static?
Quoted 5 lines
drivers/clk/berlin/pll.c new file +5
-0+{ +struct clk_init_data init; +struct berlin_pll *pll; +const char *parent_names[PLL_SOURCE_MAX ]; +struct clk *clk;drivers/clk/berlin/pll.c line 95
Quoted 10 lines
drivers/clk/berlin/pll.c new file +10
-0+int ret, num_parents; + + num_parents =of_clk_get_parent_count (np); +if (num_parents <=0 || num_parents >PLL_SOURCE_MAX ) +return ; + +of_clk_parent_fill (np, parent_names, num_parents); + + pll =kzalloc (sizeof (*pll),GFP_KERNEL ); +if (WARN_ON (!pll))We already print a big warning on allocation failures, so drop the
WARN_ONplease.drivers/clk/berlin/pll.c line 107
Quoted 12 lines
drivers/clk/berlin/pll.c new file +12
-0+return ; + + pll->ctrl =of_iomap (np,0 ); + pll->bypass =of_iomap (np,1 ); + ret =of_property_read_u8 (np,"bypass-shift" , &pll->bypass_shift); +if (WARN_ON (!pll->ctrl || !pll->bypass || ret)) +return ; + + init.name = np->name; + init.ops = &berlin_pll_ops; + init.parent_names = parent_names; + init.num_parents = num_parents;init.flags is not initialized. Please initialize the init struct on the stack to 0 to avoid future problems.
drivers/clk/berlin/pll.c line 117
Quoted 10 lines
drivers/clk/berlin/pll.c new file +10
-0+ + pll->hw.init = &init; + + clk =clk_register (NULL , &pll->hw); +if (WARN_ON (IS_ERR (clk))) +return ; + + ret =of_clk_add_provider (np, of_clk_src_simple_get, clk); +if (WARN_ON (ret)) +return ;This return is useless.
Quoted 1 line
drivers/clk/berlin/pll.c new file +1
-0+}
PATCH 2/5 clk: berlin: add common clk driver for newer SoCs
In reply to Jisheng ZhangAdd berlin-clk driver for Marvell SoCs newer than BG2, BG2CD, BG2Q. berlin_clk_register() is provided for registering such kind of clk.
--- drivers/clk/berlin/Makefile | 2 +- drivers/clk/berlin/clk.c | 147 ++++++++++++++++++++++++++++++++++++++++++++ drivers/clk/berlin/clk.h | 38 ++++++++++++ 3 files changed, 186 insertions(+), 1 deletion(-) create mode 100644 drivers/clk/berlin/clk.c create mode 100644 drivers/clk/berlin/clk.h
drivers/clk/berlin/Makefile +1 -1
@@ -1,4 +1,4 @@ -obj-y += pll.o berlin2-avpll.o berlin2-pll.o berlin2-div.o +obj-y += pll.o clk.o berlin2-avpll.o berlin2-pll.o berlin2-div.o obj-$(CONFIG_MACH_BERLIN_BG2) += bg2.o obj-$(CONFIG_MACH_BERLIN_BG2CD) += bg2.o obj-$(CONFIG_MACH_BERLIN_BG2Q) += bg2q.o
drivers/clk/berlin/clk.c new file +147 -0
147 lines not on this page · raw message
drivers/clk/berlin/clk.h new file +38 -0
@@ -0,0 +1,38 @@ +/* +* Copyright (c) 2015 Marvell Technology Group Ltd. +* +* Author: Jisheng Zhang <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef __BERLIN_CLK_H +#define __BERLIN_CLK_H + +struct gateclk_desc { +const char *name; +const char *parent_name; +u8 bit_idx; +unsigned long flags; +}; + +struct clk_desc { +const char *name; +u32 offset; +unsigned long flags; +}; + +struct clk *__init berlin_clk_register (const char *name,int num_parents, +const char **parent_names,unsigned long flags, +void __iomem *base); +#endif
Signature · 1 line
2.5.3
Re: [PATCH 2/5] clk: berlin: add common clk driver for newer SoCs
Quoted 10 lines · Jisheng Zhang
drivers/clk/berlin/clk.c new file +10
-0+ +static u8 clk_div[] = {1 ,2 ,4 ,6 ,8 ,12 ,1 ,1 }; + +static unsigned long berlin_clk_recalc_rate (struct clk_hw *hw, +unsigned long parent_rate) +{ +u32 val, divider; +struct berlin_clk *clk =to_berlin_clk (hw); + + val =readl_relaxed (clk->base);
drivers/clk/berlin/clk.c line 60
Quoted 10 lines
drivers/clk/berlin/clk.c new file +10
-0+if (val &CLKD3SWITCH ) + divider =3 ; +else { +if (val &CLKSWITCH ) { + val >>=CLKSEL_SHIFT ; + val &=CLKSEL_MASK ; + divider = clk_div[val]; + }else + divider =1 ; + }
How about we drop the clk_div array and use code?
if (val & CLKSWITCH) {
val >>= CLKSEL_SHIFT;
val &= CLKSEL_MASK;
}
divider = 1
if (val < 6)
divider <<= val;Quoted 3 lines
drivers/clk/berlin/clk.c new file +3
-0+ +return parent_rate / divider; +}
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH 3/5 clk: berlin: add clk support for berlin4ct
In reply to Jisheng ZhangThis patch supports the gate-clk and berlin-clk in berlin4ct SoC.
--- drivers/clk/berlin/Makefile | 2 +- drivers/clk/berlin/clk-berlin4ct.c | 164 +++++++++++++++++++++++++++++++++++++ 2 files changed, 165 insertions(+), 1 deletion(-) create mode 100644 drivers/clk/berlin/clk-berlin4ct.c
drivers/clk/berlin/Makefile +1 -1
@@ -1,4 +1,4 @@ -obj-y += pll.o clk.o berlin2-avpll.o berlin2-pll.o berlin2-div.o +obj-y += pll.o clk.o clk-berlin4ct.o berlin2-avpll.o berlin2-pll.o berlin2-div.o obj-$(CONFIG_MACH_BERLIN_BG2) += bg2.o obj-$(CONFIG_MACH_BERLIN_BG2CD) += bg2.o obj-$(CONFIG_MACH_BERLIN_BG2Q) += bg2q.o
drivers/clk/berlin/clk-berlin4ct.c new file +164 -0
164 lines not on this page · raw message
Signature · 1 line
2.5.3
Re: [PATCH 3/5] clk: berlin: add clk support for berlin4ct
Quoted 6 lines · Jisheng Zhang
+ */
drivers/clk/berlin/clk-berlin4ct.c new file +5
-0+#include <linux/clk-provider.h> +#include <linux/io.h> +#include <linux/kernel.h> +#include <linux/of.h> +#include <linux/of_address.h>
drivers/clk/berlin/clk-berlin4ct.c line 32
Quoted 10 lines
drivers/clk/berlin/clk-berlin4ct.c new file +10
-0+#include <linux/slab.h> + +#include "clk.h" + +#define CLK_SOURCE_MAX 5 + +static struct clk_onecell_data gateclk_data; +static struct clk_onecell_data clk_data; + +static DEFINE_SPINLOCK (lock);
This is really generic. How about berlin4ct_lock? That will make lockdep happy because the name for the key will have some meaning.
drivers/clk/berlin/clk-berlin4ct.c line 100
Quoted 12 lines
drivers/clk/berlin/clk-berlin4ct.c new file +12
-0+static void __init berlin4ct_gateclk_setup (struct device_node *np) +{ +int i, n, ret; +void __iomem *base; +struct clk **clks; + + base =of_iomap (np,0 ); +if (WARN_ON (!base)) +return ; + + n =ARRAY_SIZE (berlin4ct_gates); + clks =kzalloc (n *sizeof (struct clk *),GFP_KERNEL );
kcalloc()
Review
Quoted 1 line
(quoted diff) +1
-0+ if (WARN_ON(!clks))
Same comment about dropping WARN_ON for an allocation failure.
Quoted 7 lines
drivers/clk/berlin/clk-berlin4ct.c new file +7
-0+return ; + +for (i =0 ; i < n; i++) { + clks[i] =clk_register_gate (NULL , berlin4ct_gates[i].name, + berlin4ct_gates[i].parent_name, + berlin4ct_gates[i].flags, base, + berlin4ct_gates[i].bit_idx,0 , &lock);
drivers/clk/berlin/clk-berlin4ct.c line 118
Quoted 10 lines
drivers/clk/berlin/clk-berlin4ct.c new file +10
-0+WARN_ON (IS_ERR (clks[i])); + } + + gateclk_data.clks = clks; + gateclk_data.clk_num = i; + + ret =of_clk_add_provider (np, of_clk_src_onecell_get, + &gateclk_data); +if (WARN_ON (ret)) +return ;
Drop that return please.
Quoted 14 lines
drivers/clk/berlin/clk-berlin4ct.c new file +14
-0+ +} +CLK_OF_DECLARE (berlin4ct_gateclk,"marvell,berlin4ct-gateclk" , + berlin4ct_gateclk_setup); + +static void __init berlin4ct_clk_setup (struct device_node *np) +{ +int i, n, ret, num_parents; +void __iomem *base; +struct clk **clks; +const char *parent_names[CLK_SOURCE_MAX ]; + + num_parents =of_clk_get_parent_count (np); +if (num_parents <=0 || num_parents >CLK_SOURCE_MAX )
drivers/clk/berlin/clk-berlin4ct.c line 142
Quoted 10 lines
drivers/clk/berlin/clk-berlin4ct.c new file +10
-0+return ; + +of_clk_parent_fill (np, parent_names, num_parents); + + base =of_iomap (np,0 ); +if (WARN_ON (!base)) +return ; + + n =ARRAY_SIZE (berlin4ct_descs); + clks =kzalloc (n *sizeof (struct clk *),GFP_KERNEL );
kcalloc()
Review
Quoted 1 line
(quoted diff) +1
-0+ if (WARN_ON(!clks))
Same comment about dropping WARN_ON for an allocation failure.
Quoted 7 lines
drivers/clk/berlin/clk-berlin4ct.c new file +7
-0+return ; + +for (i =0 ; i < n; i++) { + clks[i] =berlin_clk_register (berlin4ct_descs[i].name, + num_parents, parent_names, + berlin4ct_descs[i].flags, + base + berlin4ct_descs[i].offset);
drivers/clk/berlin/clk-berlin4ct.c line 160
Quoted 10 lines
drivers/clk/berlin/clk-berlin4ct.c new file +10
-0+WARN_ON (IS_ERR (clks[i])); + } + + clk_data.clks = clks; + clk_data.clk_num = i; + + ret =of_clk_add_provider (np, of_clk_src_onecell_get, + &clk_data); +if (WARN_ON (ret)) +return ;
Drop that return please.
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH 4/5 dt-bindings: add binding for marvell berlin4ct SoC
In reply to Jisheng ZhangThis adds a dt-binding include for Marvell berlin4ct clock IDs.
--- .../bindings/clock/marvell,berlin4ct.txt | 38 +++++++++++++++ include/dt-bindings/clock/berlin4ct.h | 56 ++++++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/marvell,berlin4ct.txt create mode 100644 include/dt-bindings/clock/berlin4ct.h
Documentation/devicetree/bindings/clock/marvell,berlin4ct.txt new file +38 -0
@@ -0,0 +1,38 @@ +* Marvell berlin4ct Clock Controllers + +This binding uses the common clock binding[1]. + +[1] Documentation/devicetree/bindings/clock/clock-bindings.txt + +The berlin4ct clock subsystem generates and supplies clock to various +controllers within the berlin4ct SoC. The berlin4ct contains 3 clock controller +blocks: pll, gateclk, berlin-clk. + +Required Properties: + +- compatible: should be one of the following. + - "marvell,berlin-pll" - pll compatible + - "marvell,berlin4ct-clk" - berlin clk compatible + - "marvell,berlin4ct-gateclk" - gateclk compatible +- reg: physical base address of the clock controller and length of memory mapped + region. For pll, the second reg defines the bypass register base address and + length of memory mapped region. +- #clock-cells: for pll should 0, for gateclk and berlin clk should be 1. +- #bypass-shift: the bypass bit in bypass register. + +Example: + +syspll: syspll { + compatible = "marvell,berlin-pll"; + reg = <0xea0200 0x14>, <0xea0710 4>; + #clock-cells = <0>; + clocks = <&osc>; + bypass-shift = /bits/ 8 <0>; +}; + +clk: clk { + compatible = "marvell,berlin4ct-clk"; + reg = <0xea0720 0x144>; + #clock-cells = <1>; + clocks = <&syspll>; +};
include/dt-bindings/clock/berlin4ct.h new file +56 -0
56 lines not on this page · raw message
Signature · 1 line
2.5.3
Re: [PATCH 4/5] dt-bindings: add binding for marvell berlin4ct SoC
Quoted 26 lines · Jisheng Zhang
Documentation/devicetree/bindings/clock/marvell,berlin4ct.txt new file +26
-0+This binding uses the common clock binding[1]. + +[1] Documentation/devicetree/bindings/clock/clock-bindings.txt + +The berlin4ct clock subsystem generates and supplies clock to various +controllers within the berlin4ct SoC. The berlin4ct contains 3 clock controller +blocks: pll, gateclk, berlin-clk. + +Required Properties: + +- compatible: should be one of the following. + - "marvell,berlin-pll" - pll compatible + - "marvell,berlin4ct-clk" - berlin clk compatible + - "marvell,berlin4ct-gateclk" - gateclk compatible +- reg: physical base address of the clock controller and length of memory mapped + region. For pll, the second reg defines the bypass register base address and + length of memory mapped region. +- #clock-cells: for pll should 0, for gateclk and berlin clk should be 1. +- #bypass-shift: the bypass bit in bypass register. + +Example: + +syspll: syspll { + compatible = "marvell,berlin-pll"; + reg = <0xea0200 0x14>, <0xea0710 4>; + #clock-cells = <0>;
Documentation/devicetree/bindings/clock/marvell,berlin4ct.txt line 38
Quoted 10 lines
Documentation/devicetree/bindings/clock/marvell,berlin4ct.txt new file +10
-0+ clocks = <&osc>; + bypass-shift = /bits/ 8 <0>; +}; + +clk: clk { + compatible = "marvell,berlin4ct-clk"; + reg = <0xea0720 0x144>; + #clock-cells = <1>; + clocks = <&syspll>; +};
Is there one clock controller at 0xea0000 of size 0x1000? We've been trying to push people towards using the device model and writing drivers with probe instead of using CLK_OF_DECLARE() for their platform clocks. From the looks of this binding, we're splitting up the different types of clocks into their own nodes and then registering them with CLK_OF_DECLARE.
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH 4/5] dt-bindings: add binding for marvell berlin4ct SoC
Hi Stephen,
Quoted 31 lines · On Thu, 1 Oct 2015 15:50:27 -0700 Stephen Boyd <[email protected]> wrote:
Quoted 30 lines · Jisheng Zhang
Documentation/devicetree/bindings/clock/marvell,berlin4ct.txt new file +30
-0+This binding uses the common clock binding[1]. + +[1] Documentation/devicetree/bindings/clock/clock-bindings.txt + +The berlin4ct clock subsystem generates and supplies clock to various +controllers within the berlin4ct SoC. The berlin4ct contains 3 clock controller +blocks: pll, gateclk, berlin-clk. + +Required Properties: + +- compatible: should be one of the following. + - "marvell,berlin-pll" - pll compatible + - "marvell,berlin4ct-clk" - berlin clk compatible + - "marvell,berlin4ct-gateclk" - gateclk compatible +- reg: physical base address of the clock controller and length of memory mapped + region. For pll, the second reg defines the bypass register base address and + length of memory mapped region. +- #clock-cells: for pll should 0, for gateclk and berlin clk should be 1. +- #bypass-shift: the bypass bit in bypass register. + +Example: + +syspll: syspll { + compatible = "marvell,berlin-pll"; + reg = <0xea0200 0x14>, <0xea0710 4>; + #clock-cells = <0>; + clocks = <&osc>; + bypass-shift = /bits/ 8 <0>; +}; +
Quoted 8 lines
Documentation/devicetree/bindings/clock/marvell,berlin4ct.txt line 38
Quoted 6 lines
Documentation/devicetree/bindings/clock/marvell,berlin4ct.txt new file +6
-0+clk: clk { + compatible = "marvell,berlin4ct-clk"; + reg = <0xea0720 0x144>; + #clock-cells = <1>; + clocks = <&syspll>; +};Is there one clock controller at
0xea0000of size0x1000? We've
there's no clock controller at 0xea0000 with so big size. In BG4CT, we have the following different kind of plls/clks
1. cpupll/syspll/mempll: the same IP, the pll register is put with the user together, plus one shared bypass control register. For example: mempll register is put with DDR controller registers together. cpupll, syspll and mempll share the same bypass register: 0xea0710.
2. gateclks: the clk can only be enabled or disabled, the control bits are put into one(or two) register(s)
3. clks: can be disabled/enabled, change the divider, etc.. all these clks registers are put together. In this register space, some space may not be used.
[PATCH 5/5] shows the layout of the clk/pll registers
Quoted 2 lines
been trying to push people towards using the device model and writing drivers with probe instead of using
CLK_OF_DECLARE()for
Is there any existing clk drivers switched to this type. I'll grep and take that for an example.
Quoted 3 lines
their platform clocks. From the looks of this binding, we're splitting up the different types of clocks into their own nodes and then registering them with
CLK_OF_DECLARE.
Could you please kindly give advice about how to avoid the splitting?
Thanks a lot for review,
Jisheng
PATCH 5/5 arm64: dts: berlin4ct: add pll and clock nodes
In reply to Jisheng ZhangAdd syspll, mempll, cpupll, gate-clk and berlin-clk nodes.
--- arch/arm64/boot/dts/marvell/berlin4ct.dtsi | 38 ++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
arch/arm64/boot/dts/marvell/berlin4ct.dtsi +38 -0
@@ -42,6 +42,7 @@ * OTHER DEALINGS IN THE SOFTWARE. */ +#include <dt-bindings/clock/berlin4ct.h> #include <dt-bindings/interrupt-controller/arm-gic.h> / {
@@ -135,6 +136,22 @@ interrupts = <GIC_PPI 9 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_HIGH)>; }; + cpupll: cpupll { + compatible = "marvell,berlin-pll"; + reg = <0x922000 0x14>, <0xea0710 4>; + #clock-cells = <0>; + clocks = <&osc>, <&clk CLK_CPUFASTREF>; + bypass-shift = /bits/ 8 <2>; + }; + + mempll: mempll { + compatible = "marvell,berlin-pll"; + reg = <0x940034 0x14>, <0xea0710 4>; + #clock-cells = <0>; + clocks = <&osc>, <&clk CLK_MEMFASTREF>; + bypass-shift = /bits/ 8 <1>; + }; + apb at e80000 { compatible = "simple-bus"; #address-cells = <1>;
@@ -225,6 +242,27 @@ }; }; + syspll: syspll { + compatible = "marvell,berlin-pll"; + reg = <0xea0200 0x14>, <0xea0710 4>; + #clock-cells = <0>; + clocks = <&osc>; + bypass-shift = /bits/ 8 <0>; + }; + + gateclk: gateclk { + compatible = "marvell,berlin4ct-gateclk"; + reg = <0xea0700 4>; + #clock-cells = <1>; + }; + + clk: clk { + compatible = "marvell,berlin4ct-clk"; + reg = <0xea0720 0x144>; + #clock-cells = <1>; + clocks = <&syspll>; + }; + soc_pinctrl: pinctrl at ea8000 { compatible = "marvell,berlin4ct-soc-pinctrl"; reg = <0xea8000 0x14>;
Signature · 1 line
2.5.3
+ CLK maintainers
sorry, yesterday I pressed ENTER quickly before --to list is completed
Quoted 32 lines · On Tue, 22 Sep 2015 22:12:31 +0800 Jisheng Zhang <[email protected]> wrote:
Add berlin4ct clk driver. The berlin4ct SoC contains:
two kinds of PLL: normal PLL and AVPLL. The normal PLL support is done. The AVPLL support is in TODO list.
two kinds of clk: normal clk and gate clk. The normal clk supports changing divider, selecting clock source, disabling/enabling etc. The gate clk only supports disabling/enabling. Both are supported in this series.
Jisheng Zhang (5):
clk: berlin: add common pll driver
clk: berlin: add common clk driver for newer SoCs
clk: berlin: add clk support for berlin4ct
dt-bindings: add binding for marvell berlin4ct SoC
arm64: dts: berlin4ct: add pll and clock nodes.../bindings/clock/marvell,berlin4ct.txt | 38 +++++ arch/arm64/boot/dts/marvell/berlin4ct.dtsi | 38 +++++ drivers/clk/berlin/Makefile | 2 +- drivers/clk/berlin/clk-berlin4ct.c | 164 +++++++++++++++++++++ drivers/clk/berlin/clk.c | 147 ++++++++++++++++++ drivers/clk/berlin/clk.h | 38 +++++ drivers/clk/berlin/pll.c | 119 +++++++++++++++ include/dt-bindings/clock/berlin4ct.h | 56 +++++++ 8 files changed, 601 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/clock/marvell,berlin4ct.txt create mode 100644 drivers/clk/berlin/clk-berlin4ct.c create mode 100644 drivers/clk/berlin/clk.c create mode 100644 drivers/clk/berlin/clk.h create mode 100644 drivers/clk/berlin/pll.c create mode 100644 include/dt-bindings/clock/berlin4ct.h