clk: Add clock driver for mb86s7x
Subsystems (2)
PATCH 4/8 clk: Add clock driver for mb86s7x
The CRG11 clock controller is managed by remote f/w.
This driver simply maps Linux CLK ops onto mailbox api.
--- .../bindings/clock/fujitsu,mb86s7x_clk.txt | 32 ++ drivers/clk/Makefile | 1 + drivers/clk/clk-mb86s7x.c | 352 +++++++++++++++++++++ 3 files changed, 385 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/fujitsu,mb86s7x_clk.txt create mode 100644 drivers/clk/clk-mb86s7x.c
Documentation/devicetree/bindings/clock/fujitsu,mb86s7x_clk.txt new file +32 -0
@@ -0,0 +1,32 @@ +Fujitsu CRG11 clock driver bindings +----------------------------------- + +Required properties : +- compatible : Shall contain "fujitsu,mb86s7x_clk" +- #clock-cells : Shall be 0 +- cntrlr : 0->ALW, 1->DDR3, 2->MAIN, 3->CA15, 4->HDMI, 5->DPHY +- domain : [0, 15] +- port : [0,7] -> Gateable Clock Ports. [8]->UngatedCLK + +The consumer specifies the desired clock pointing to its phandle. + +Example: + + clk_alw_2_1: clk_alw_2_1 { + compatible = "fujitsu,mb86s7x_clk"; + #clock-cells = <0>; + cntrlr = <0>; + domain = <2>; + port = <1>; + }; + + mhu: mhu0 at 2b1f0000 { + #mbox-cells = <1>; + compatible = "fujitsu,mhu"; + reg = <0 0x2B1F0000 0x1000>; + interrupts = <0 36 4>, /* LP Non-Sec */ + <0 35 4>, /* HP Non-Sec */ + <0 37 4>; /* Secure */ + clocks = <&clk_alw_2_1>; + clock-names = "clk"; + };
drivers/clk/Makefile +1 -0
@@ -20,6 +20,7 @@ obj-$(CONFIG_ARCH_HIGHBANK) += clk-highbank.o obj-$(CONFIG_MACH_LOONGSON1) += clk-ls1x.o obj-$(CONFIG_COMMON_CLK_MAX77686) += clk-max77686.o obj-$(CONFIG_ARCH_MOXART) += clk-moxart.o +obj-$(CONFIG_ARCH_MB86S7X) += clk-mb86s7x.o obj-$(CONFIG_ARCH_NOMADIK) += clk-nomadik.o obj-$(CONFIG_ARCH_NSPIRE) += clk-nspire.o obj-$(CONFIG_CLK_PPC_CORENET) += clk-ppc-corenet.o
drivers/clk/clk-mb86s7x.c new file +352 -0
352 lines not on this page · raw message
Signature · 1 line
1.8.1.2
PATCH 4/8 clk: Add clock driver for mb86s7x
Quoted 14 lines · On Sunday 13 July 2014 14:30:52 Mollie Wu wrote:
--- .../bindings/clock/fujitsu,mb86s7x_clk.txt | 32 ++ drivers/clk/Makefile | 1 + drivers/clk/clk-mb86s7x.c | 352 +++++++++++++++++++++ 3 files changed, 385 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/fujitsu,mb86s7x_clk.txt create mode 100644 drivers/clk/clk-mb86s7x.cDocumentation/devicetree/bindings/clock/fujitsu,mb86s7x_clk.txt new file +0
-0
Documentation/devicetree/bindings/clock/fujitsu,mb86s7x_clk.txt line 5
Quoted 5 lines
Documentation/devicetree/bindings/clock/fujitsu,mb86s7x_clk.txt new file +5
-0@@ -0,0 +1,32 @@ +Fujitsu CRG11 clock driver bindings +----------------------------------- + +Required properties : +- compatible : Shall contain "fujitsu,mb86s7x_clk"
No wildcards in compatible strings please.
Documentation/devicetree/bindings/clock/fujitsu,mb86s7x_clk.txt line 9
Quoted 4 lines
Documentation/devicetree/bindings/clock/fujitsu,mb86s7x_clk.txt new file +4
-0+- #clock-cells : Shall be 0 +- cntrlr : 0->ALW, 1->DDR3, 2->MAIN, 3->CA15, 4->HDMI, 5->DPHY +- domain : [0, 15] +- port : [0,7] -> Gateable Clock Ports. [8]->UngatedCLK
It would be good to be a bit more verbose here.
Quoted 44 lines
Documentation/devicetree/bindings/clock/fujitsu,mb86s7x_clk.txt new file +43
-0+ +struct clk *mb86s7x_clclk_register(struct device *cpu_dev) +{ + struct clk_init_data init; + struct cl_clk *clc; + + clc = kzalloc(sizeof(*clc), GFP_KERNEL); + if (!clc) { + pr_err("could not allocate cl_clk\n"); + return ERR_PTR(-ENOMEM); + } + + clc->hw.init = &init; + clc->cluster = topology_physical_package_id(cpu_dev->id); + + init.name = dev_name(cpu_dev); + init.ops = &clk_clc_ops; + init.flags = CLK_IS_ROOT | CLK_GET_RATE_NOCACHE; + init.num_parents = 0; + + return devm_clk_register(cpu_dev, &clc->hw); +} + +static int mb86s7x_clclk_of_init(void) +{ + int cpu; + struct clk *clk; + + for_each_possible_cpu(cpu) { + struct device *cpu_dev = get_cpu_device(cpu); + + if (!cpu_dev) { + pr_err("failed to get cpu%d device\n", cpu); + continue; + } + + clk = mb86s7x_clclk_register(cpu_dev); + if (IS_ERR(clk)) { + pr_err("failed to register cpu%d clock\n", cpu); + continue; + } + if (clk_register_clkdev(clk, NULL, dev_name(cpu_dev))) { + pr_err("failed to register cpu%d clock lookup\n", cpu);
Documentation/devicetree/bindings/clock/fujitsu,mb86s7x_clk.txt
Quoted 10 lines
Documentation/devicetree/bindings/clock/fujitsu,mb86s7x_clk.txt new file +10
-0+ continue; + } + pr_debug("registered clk for %s\n", dev_name(cpu_dev)); + } + + platform_device_register_simple("arm-bL-cpufreq-dt", -1, NULL, 0); + + return 0; +} +module_init(mb86s7x_clclk_of_init);
This looks weird: why don't you probe the clocks from DT like normal?
Why do you register a platform device here? Are you trying to hide the fact that the cpufreq stuff still doesn't use proper DT probing?
Arnd
PATCH 4/8 clk: Add clock driver for mb86s7x
Quoted 10 lines · Arnd Bergmann
Quoted 8 lines · On Sunday 13 July 2014 14:30:52 Mollie Wu wrote:
--- .../bindings/clock/fujitsu,mb86s7x_clk.txt | 32 ++ drivers/clk/Makefile | 1 + drivers/clk/clk-mb86s7x.c | 352 +++++++++++++++++++++ 3 files changed, 385 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/fujitsu,mb86s7x_clk.txt create mode 100644 drivers/clk/clk-mb86s7x.c
Quoted 14 lines
Documentation/devicetree/bindings/clock/fujitsu,mb86s7x_clk.txt line 5
Quoted 11 lines
Documentation/devicetree/bindings/clock/fujitsu,mb86s7x_clk.txt new file +5
-0@@ -0,0 +1,32 @@ +Fujitsu CRG11 clock driver bindings +----------------------------------- + +Required properties : +- compatible : Shall contain "fujitsu,mb86s7x_clk"No wildcards in compatible strings please.
OK
Quoted 7 lines
Documentation/devicetree/bindings/clock/fujitsu,mb86s7x_clk.txt line 9
Quoted 4 lines
Documentation/devicetree/bindings/clock/fujitsu,mb86s7x_clk.txt new file +4
-0+- #clock-cells : Shall be 0 +- cntrlr : 0->ALW, 1->DDR3, 2->MAIN, 3->CA15, 4->HDMI, 5->DPHY +- domain : [0, 15] +- port : [0,7] -> Gateable Clock Ports. [8]->UngatedCLKIt would be good to be a bit more verbose here.
That is how the clock controller is on this soc. The UngatedCLK is the source of 8 gateable clock ports as well as having its own output port. The PLLs and divisors are internally programmed by the remote master.
Quoted 48 lines
Quoted 48 lines
Documentation/devicetree/bindings/clock/fujitsu,mb86s7x_clk.txt new file +48
-0+ +struct clk *mb86s7x_clclk_register(struct device *cpu_dev) +{ + struct clk_init_data init; + struct cl_clk *clc; + + clc = kzalloc(sizeof(*clc), GFP_KERNEL); + if (!clc) { + pr_err("could not allocate cl_clk\n"); + return ERR_PTR(-ENOMEM); + } + + clc->hw.init = &init; + clc->cluster = topology_physical_package_id(cpu_dev->id); + + init.name = dev_name(cpu_dev); + init.ops = &clk_clc_ops; + init.flags = CLK_IS_ROOT | CLK_GET_RATE_NOCACHE; + init.num_parents = 0; + + return devm_clk_register(cpu_dev, &clc->hw); +} + +static int mb86s7x_clclk_of_init(void) +{ + int cpu; + struct clk *clk; + + for_each_possible_cpu(cpu) { + struct device *cpu_dev = get_cpu_device(cpu); + + if (!cpu_dev) { + pr_err("failed to get cpu%d device\n", cpu); + continue; + } + + clk = mb86s7x_clclk_register(cpu_dev); + if (IS_ERR(clk)) { + pr_err("failed to register cpu%d clock\n", cpu); + continue; + } + if (clk_register_clkdev(clk, NULL, dev_name(cpu_dev))) { + pr_err("failed to register cpu%d clock lookup\n", cpu); + continue; + } + pr_debug("registered clk for %s\n", dev_name(cpu_dev)); + } +
Quoted 9 lines
Documentation/devicetree/bindings/clock/fujitsu,mb86s7x_clk.txt
Quoted 6 lines
Documentation/devicetree/bindings/clock/fujitsu,mb86s7x_clk.txt new file +5
-0+ platform_device_register_simple("arm-bL-cpufreq-dt", -1, NULL, 0); + + return 0; +} +module_init(mb86s7x_clclk_of_init);This looks weird: why don't you probe the clocks from DT like normal?
We need to register clocks for each cpu populated, which is only after all clock providers are probed by CLK_OF_DECLARE()
Quoted 3 lines
Why do you register a platform device here? Are you trying to hide the fact that the cpufreq stuff still doesn't use proper DT probing?
Yup, the generic bL cpufreq driver doesn't probe by DT.
thanks
-jassi