Add Bitmain BM1880 clock driver
Subsystems (3)
v7 cover Add Bitmain BM1880 clock driver
Hello,
This patchset adds common clock driver for Bitmain BM1880 SoC clock controller. The clock controller consists of gate, divider, mux and pll clocks with different compositions. Hence, the driver uses composite clock structure in place where multiple clocking units are combined together.
This patchset also removes UART fixed clock and sources clocks from clock controller for Sophon Edge board where the driver has been validated.
Thanks,
Mani
Changes in v7:
* Fixed the do_div() issue detected by kbuild test bot
Changes in v6:
* Dropped 'clk: Warn if clk_init_data is not zero initialized' patch
* Added fixes tag to the patch adding 'clk_hw_unregister_composite' definition
* Reworked the use of CLK_IS_CTITICAL flag from clk driver
* Removed the use of CLK_DIVIDER_HIWORD_MASK flag from driver
* Some misc cleanups to the driver
* Added Rob's reviewed tag for the binding
Changes in v5:
* Incorporated review comments from Rob on dt binding
Changes in v4:
* Fixed devicetree binding issue
* Added ARCH_BITMAIN as the default for the clk driver
Changes in v3:
* Switched to clk_hw_{register/unregister} APIs
* Returned clk_hw from the in-driver registration helpers
Changes in v2:
* Converted the dt binding to YAML
* Incorporated review comments from Stephen (majority of change is switching to new way of specifying clk parents)
Manivannan Sadhasivam (7):
clk: Zero init clk_init_data in helpers
clk: Add clk_hw_unregister_composite helper function definition
dt-bindings: clock: Add devicetree binding for BM1880 SoC
arm64: dts: bitmain: Add clock controller support for BM1880 SoC
arm64: dts: bitmain: Source common clock for UART controllers
clk: Add common clock driver for BM1880 SoC
MAINTAINERS: Add entry for BM1880 SoC clock driver
.../bindings/clock/bitmain,bm1880-clk.yaml | 76 ++ MAINTAINERS | 2 + .../boot/dts/bitmain/bm1880-sophon-edge.dts | 9 - arch/arm64/boot/dts/bitmain/bm1880.dtsi | 28 + drivers/clk/Kconfig | 7 + drivers/clk/Makefile | 1 + drivers/clk/clk-bm1880.c | 969 ++++++++++++++++++ drivers/clk/clk-composite.c | 13 +- drivers/clk/clk-divider.c | 2 +- drivers/clk/clk-fixed-rate.c | 2 +- drivers/clk/clk-gate.c | 2 +- drivers/clk/clk-mux.c | 2 +- include/dt-bindings/clock/bm1880-clock.h | 82 ++ 13 files changed, 1181 insertions(+), 14 deletions(-) create mode 100644 Documentation/devicetree/bindings/clock/bitmain,bm1880-clk.yaml create mode 100644 drivers/clk/clk-bm1880.c create mode 100644 include/dt-bindings/clock/bm1880-clock.h
Signature · 1 line
2.17.1
PATCH v7 1/7 clk: Zero init clk_init_data in helpers
The clk_init_data struct needs to be initialized to zero for the new parent_map implementation to work correctly. Otherwise, the member which is available first will get processed.
--- drivers/clk/clk-composite.c | 2 +- drivers/clk/clk-divider.c | 2 +- drivers/clk/clk-fixed-rate.c | 2 +- drivers/clk/clk-gate.c | 2 +- drivers/clk/clk-mux.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-)
drivers/clk/clk-composite.c +1 -1
@@ -207,7 +207,7 @@ struct clk_hw *clk_hw_register_composite(struct device *dev, const char *name, unsigned long flags) {struct clk_hw *hw; -struct clk_init_data init; +struct clk_init_data init = {};struct clk_composite *composite;struct clk_ops *clk_composite_ops;int ret;
drivers/clk/clk-divider.c +1 -1
@@ -471,7 +471,7 @@ static struct clk_hw *_register_divider(struct device *dev, const char *name, {struct clk_divider *div;struct clk_hw *hw; -struct clk_init_data init; +struct clk_init_data init = {};int ret;if (clk_divider_flags &CLK_DIVIDER_HIWORD_MASK ) {
drivers/clk/clk-fixed-rate.c +1 -1
@@ -58,7 +58,7 @@ struct clk_hw *clk_hw_register_fixed_rate_with_accuracy(struct device *dev, {struct clk_fixed_rate *fixed;struct clk_hw *hw; -struct clk_init_data init; +struct clk_init_data init = {};int ret;/* allocate fixed-rate clock */
drivers/clk/clk-gate.c +1 -1
@@ -141,7 +141,7 @@ struct clk_hw *clk_hw_register_gate(struct device *dev, const char *name, {struct clk_gate *gate;struct clk_hw *hw; -struct clk_init_data init; +struct clk_init_data init = {};int ret;if (clk_gate_flags &CLK_GATE_HIWORD_MASK ) {
drivers/clk/clk-mux.c +1 -1
@@ -153,7 +153,7 @@ struct clk_hw *clk_hw_register_mux_table(struct device *dev, const char *name, {struct clk_mux *mux;struct clk_hw *hw; -struct clk_init_data init; +struct clk_init_data init = {};u8 width =0 ;int ret;
Signature · 1 line
2.17.1
Re: [PATCH v7 1/7] clk: Zero init clk_init_data in helpers
Quoting Manivannan Sadhasivam (2019-11-15 08:28:55)
Quoted 6 lines
The
clk_init_datastruct needs to be initialized to zero for the newparent_mapimplementation to work correctly. Otherwise, the member which is available first will get processed.Signed-off-by Manivannan Sadhasivam <[email protected]>---
Applied to clk-next
PATCH v7 2/7 clk: Add clk_hw_unregister_composite helper function definition
In reply to Manivannan SadhasivamThis function has been delcared but not defined anywhere. Hence, this commit adds definition for it.
--- drivers/clk/clk-composite.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/clk/clk-composite.c +11 -0
@@ -343,3 +343,14 @@ void clk_unregister_composite(struct clk *clk)clk_unregister (clk);kfree (composite); } + +void clk_hw_unregister_composite (struct clk_hw *hw) +{ +struct clk_composite *composite; + + composite =to_clk_composite (hw); + +clk_hw_unregister (hw); +kfree (composite); +} +EXPORT_SYMBOL_GPL (clk_hw_unregister_composite);
Signature · 1 line
2.17.1
Re: [PATCH v7 2/7] clk: Add clk_hw_unregister_composite helper function definition
Quoting Manivannan Sadhasivam (2019-11-15 08:28:56)
Quoted 6 lines
This function has been delcared but not defined anywhere. Hence, this commit adds definition for it.
Fixes 49cb392d3639 ("clk: composite: Add hw based registration APIs")Signed-off-by Manivannan Sadhasivam <[email protected]>---
Applied to clk-next
PATCH v7 3/7 dt-bindings: clock: Add devicetree binding for BM1880 SoC
In reply to Manivannan SadhasivamAdd YAML devicetree binding for Bitmain BM1880 SoC.
--- .../bindings/clock/bitmain,bm1880-clk.yaml | 76 +++++++++++++++++ include/dt-bindings/clock/bm1880-clock.h | 82 +++++++++++++++++++ 2 files changed, 158 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/bitmain,bm1880-clk.yaml create mode 100644 include/dt-bindings/clock/bm1880-clock.h
Documentation/devicetree/bindings/clock/bitmain,bm1880-clk.yaml new file +76 -0
@@ -0,0 +1,76 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/bindings/clock/bitmain,bm1880-clk.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Bitmain BM1880 Clock Controller + +maintainers: + - Manivannan Sadhasivam <[email protected]> + +description: | + The Bitmain BM1880 clock controller generates and supplies clock to + various peripherals within the SoC. + + This binding uses common clock bindings + [1] Documentation/devicetree/bindings/clock/clock-bindings.txt + +properties: + compatible: + const: bitmain,bm1880-clk + + reg: + items: + - description: pll registers + - description: system registers + + reg-names: + items: + - const: pll + - const: sys + + clocks: + maxItems: 1 + + clock-names: + const: osc + + '#clock-cells': + const: 1 + +required: + - compatible + - reg + - reg-names + - clocks + - clock-names + - '#clock-cells' + +additionalProperties: false + +examples: + # Clock controller node: + - | + clk: clock-controller@e8 { + compatible = "bitmain,bm1880-clk"; + reg = <0xe8 0x0c>, <0x800 0xb0>; + reg-names = "pll", "sys"; + clocks = <&osc>; + clock-names = "osc"; + #clock-cells = <1>; + }; + + # Example UART controller node that consumes clock generated by the clock controller: + - | + uart0: serial@58018000 { + compatible = "snps,dw-apb-uart"; + reg = <0x0 0x58018000 0x0 0x2000>; + clocks = <&clk 45>, <&clk 46>; + clock-names = "baudclk", "apb_pclk"; + interrupts = <0 9 4>; + reg-shift = <2>; + reg-io-width = <4>; + }; + +...
include/dt-bindings/clock/bm1880-clock.h new file +82 -0
82 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [PATCH v7 3/7] dt-bindings: clock: Add devicetree binding for BM1880 SoC
Quoting Manivannan Sadhasivam (2019-11-15 08:28:57)
Quoted 5 lines
Add YAML devicetree binding for Bitmain BM1880 SoC.
Signed-off-by Manivannan Sadhasivam <[email protected]>Reviewed-by Rob Herring <[email protected]>---
Applied to clk-next
PATCH v7 4/7 arm64: dts: bitmain: Add clock controller support for BM1880 SoC
In reply to Manivannan SadhasivamAdd clock controller support for Bitmain BM1880 SoC.
--- arch/arm64/boot/dts/bitmain/bm1880.dtsi | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
arch/arm64/boot/dts/bitmain/bm1880.dtsi +16 -0
@@ -4,6 +4,7 @@ * Author: Manivannan Sadhasivam <[email protected]> */ +#include <dt-bindings/clock/bm1880-clock.h> #include <dt-bindings/interrupt-controller/arm-gic.h> #include <dt-bindings/reset/bitmain,bm1880-reset.h>
@@ -66,6 +67,12 @@ <GIC_PPI 10 IRQ_TYPE_LEVEL_LOW>; }; + osc: osc { + compatible = "fixed-clock"; + clock-frequency = <25000000>; + #clock-cells = <0>; + }; + soc { compatible = "simple-bus"; #address-cells = <2>;
@@ -94,6 +101,15 @@ reg = <0x400 0x120>; }; + clk: clock-controller@e8 { + compatible = "bitmain,bm1880-clk"; + reg = <0xe8 0x0c>, <0x800 0xb0>; + reg-names = "pll", "sys"; + clocks = <&osc>; + clock-names = "osc"; + #clock-cells = <1>; + }; + rst: reset-controller@c00 { compatible = "bitmain,bm1880-reset"; reg = <0xc00 0x8>;
Signature · 1 line
2.17.1
PATCH v7 5/7 arm64: dts: bitmain: Source common clock for UART controllers
In reply to Manivannan SadhasivamRemove fixed clock and source common clock for UART controllers.
--- arch/arm64/boot/dts/bitmain/bm1880-sophon-edge.dts | 9 --------- arch/arm64/boot/dts/bitmain/bm1880.dtsi | 12 ++++++++++++ 2 files changed, 12 insertions(+), 9 deletions(-)
arch/arm64/boot/dts/bitmain/bm1880-sophon-edge.dts +0 -9
@@ -49,12 +49,6 @@ reg = <0x1 0x00000000 0x0 0x40000000>; // 1GB }; - uart_clk: uart-clk { - compatible = "fixed-clock"; - clock-frequency = <500000000>; - #clock-cells = <0>; - }; - soc { gpio0: gpio@50027000 { porta: gpio-controller@0 {
@@ -173,21 +167,18 @@ &uart0 { status = "okay"; - clocks = <&uart_clk>; pinctrl-names = "default"; pinctrl-0 = <&pinctrl_uart0_default>; }; &uart1 { status = "okay"; - clocks = <&uart_clk>; pinctrl-names = "default"; pinctrl-0 = <&pinctrl_uart1_default>; }; &uart2 { status = "okay"; - clocks = <&uart_clk>; pinctrl-names = "default"; pinctrl-0 = <&pinctrl_uart2_default>; };
arch/arm64/boot/dts/bitmain/bm1880.dtsi +12 -0
@@ -174,6 +174,9 @@ uart0: serial@58018000 { compatible = "snps,dw-apb-uart"; reg = <0x0 0x58018000 0x0 0x2000>; + clocks = <&clk BM1880_CLK_UART_500M>, + <&clk BM1880_CLK_APB_UART>; + clock-names = "baudclk", "apb_pclk"; interrupts = <GIC_SPI 9 IRQ_TYPE_LEVEL_HIGH>; reg-shift = <2>; reg-io-width = <4>;
@@ -184,6 +187,9 @@ uart1: serial@5801A000 { compatible = "snps,dw-apb-uart"; reg = <0x0 0x5801a000 0x0 0x2000>; + clocks = <&clk BM1880_CLK_UART_500M>, + <&clk BM1880_CLK_APB_UART>; + clock-names = "baudclk", "apb_pclk"; interrupts = <GIC_SPI 12 IRQ_TYPE_LEVEL_HIGH>; reg-shift = <2>; reg-io-width = <4>;
@@ -194,6 +200,9 @@ uart2: serial@5801C000 { compatible = "snps,dw-apb-uart"; reg = <0x0 0x5801c000 0x0 0x2000>; + clocks = <&clk BM1880_CLK_UART_500M>, + <&clk BM1880_CLK_APB_UART>; + clock-names = "baudclk", "apb_pclk"; interrupts = <GIC_SPI 15 IRQ_TYPE_LEVEL_HIGH>; reg-shift = <2>; reg-io-width = <4>;
@@ -204,6 +213,9 @@ uart3: serial@5801E000 { compatible = "snps,dw-apb-uart"; reg = <0x0 0x5801e000 0x0 0x2000>; + clocks = <&clk BM1880_CLK_UART_500M>, + <&clk BM1880_CLK_APB_UART>; + clock-names = "baudclk", "apb_pclk"; interrupts = <GIC_SPI 18 IRQ_TYPE_LEVEL_HIGH>; reg-shift = <2>; reg-io-width = <4>;
Signature · 1 line
2.17.1
PATCH v7 6/7 clk: Add common clock driver for BM1880 SoC
In reply to Manivannan SadhasivamAdd common clock driver for Bitmain BM1880 SoC. The clock controller on BM1880 has supplies clocks to all peripherals in the form of gate clocks and composite clocks (fixed factor + gate).
--- drivers/clk/Kconfig | 7 + drivers/clk/Makefile | 1 + drivers/clk/clk-bm1880.c | 969 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 977 insertions(+) create mode 100644 drivers/clk/clk-bm1880.c
drivers/clk/Kconfig +7 -0
@@ -136,6 +136,13 @@ config COMMON_CLK_SI570 This driver supports Silicon Labs 570/571/598/599 programmable clock generators. +config COMMON_CLK_BM1880 + bool "Clock driver for Bitmain BM1880 SoC" + depends on ARCH_BITMAIN || COMPILE_TEST + default ARCH_BITMAIN + help + This driver supports the clocks on Bitmain BM1880 SoC. + config COMMON_CLK_CDCE706 tristate "Clock driver for TI CDCE706 clock synthesizer" depends on I2C
drivers/clk/Makefile +1 -0
@@ -22,6 +22,7 @@ obj-$(CONFIG_MACH_ASM9260) += clk-asm9260.o obj-$(CONFIG_COMMON_CLK_AXI_CLKGEN) += clk-axi-clkgen.o obj-$(CONFIG_ARCH_AXXIA) += clk-axm5516.o obj-$(CONFIG_COMMON_CLK_BD718XX) += clk-bd718x7.o +obj-$(CONFIG_COMMON_CLK_BM1880) += clk-bm1880.o obj-$(CONFIG_COMMON_CLK_CDCE706) += clk-cdce706.o obj-$(CONFIG_COMMON_CLK_CDCE925) += clk-cdce925.o obj-$(CONFIG_ARCH_CLPS711X) += clk-clps711x.o
drivers/clk/clk-bm1880.c new file +969 -0
969 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [PATCH v7 6/7] clk: Add common clock driver for BM1880 SoC
Quoting Manivannan Sadhasivam (2019-11-15 08:29:00)
Quoted 6 lines
Add common clock driver for Bitmain BM1880 SoC. The clock controller on BM1880 has supplies clocks to all peripherals in the form of gate clocks and composite clocks (fixed factor + gate).
Signed-off-by Manivannan Sadhasivam <[email protected]>---
Applied to clk-next
PATCH v7 7/7 MAINTAINERS: Add entry for BM1880 SoC clock driver
In reply to Manivannan SadhasivamAdd MAINTAINERS entry for Bitmain BM1880 SoC clock driver.
--- MAINTAINERS | 2 ++ 1 file changed, 2 insertions(+)
MAINTAINERS +2 -0
@@ -1529,8 +1529,10 @@ M: Manivannan Sadhasivam <[email protected]> L: [email protected] (moderated for non-subscribers) S: Maintained F: arch/arm64/boot/dts/bitmain/ +F: drivers/clk/clk-bm1880.c F: drivers/pinctrl/pinctrl-bm1880.c F: Documentation/devicetree/bindings/arm/bitmain.yaml +F: Documentation/devicetree/bindings/clock/bitmain,bm1880-clk.yaml F: Documentation/devicetree/bindings/pinctrl/bitmain,bm1880-pinctrl.txt ARM/CALXEDA HIGHBANK ARCHITECTURE
Signature · 1 line
2.17.1
Re: [PATCH v7 7/7] MAINTAINERS: Add entry for BM1880 SoC clock driver
Quoting Manivannan Sadhasivam (2019-11-15 08:29:01)
Quoted 4 lines
Add
MAINTAINERSentry for Bitmain BM1880 SoC clock driver.Signed-off-by Manivannan Sadhasivam <[email protected]>---
Applied to clk-next