Add clock support for Mediatek MT2701
Subsystems (3)
v13 cover Add clock support for Mediatek MT2701
This series is based on clk-next, add clock and reset controller support for Mediatek MT2701.
Since some patches in v11 had been applied into clk-next, they were not included in v13 series.
changes since v12:
- Rebase to clk-next.
- Use CLK_OF_DECLARE_DRIVER() instead of CLK_OF_DECLARE().
- Use dev_* and devm_* APIs instead of pr_* and ioremap().
- Refine init functions. Share error messages in common probe().
- Fix null pointer checking for clk_data.
changes since v11:
- Rebase to clk-next.
- Return error code from probe() if clock registration fail.
changes since v10:
- Remove COMMON_CLK dependency from clk/mediatek/Kconfig.
changes since v9:
- Rebase to v4.8-rc1.
- Drop a fix patch of parent clock initial state. It will be replaced by a new patch from Mike/Stephen.
- Replace clk.h with clk-provider.h.
- Correct register settings of clocks.
changes since v8:
- Rebase to v4.7-rc1.
- Include mt2701-resets.h in mt2701.dtsi.
- Remove an unused property from apmixedsys DT node.
changes since v7:
- Rebase to clk-next.
- Implement subsystem clocks in seperated files.
- Replace critical clock enabling with CLK_IS_CRITICAL flag.
- Reduce most clock registrations in CLK_OF_DECLARE().
- Remove __init and __initconst from most init fucntions and data, and replace driver registration with platform_driver_register().
- Replace some common function or variable names with unique names.
- Use real clock for UARTs.
changes since v6:
- Rebase to v4.6-rc1.
- Register subsystem clocks in probe() instead of CLK_OF_DECLARE().
- Add clocks that referred by subsystem clocks.
- Fix clk_data size of apmixedsys.
- Add config options for each subsystem clock provider.
changes since v5:
- Rebase to v4.5-rc1 and [1].
- Enable critical clocks for MT2701
- Refine dt-binding documents, add reset controller support for hifsys.
changes since v4:
- Rebase to v4.5-rc1.
- Remove CLK_SET_RATE_PARENT from divider flags.
- Add img_jpgdec_smi clock.
- Move clk/mediatek/Kconfig into menu section in clk/Kconfig.
changes since v3:
- Change the parent of mm_mdp_bls_26m from clk26m to pwm_sel.
changes since v2:
- Fix ethsys definition.
- Replace read-modify-write with regmap_update_bits() in clock operations.
- Move mt2701-resets.h to include/dt-bindings/reset/.
- Add hifsys reset patch from John Crispin.
changes since v1:
- Document MT2701 compatible strings.
[1] https://patchwork.kernel.org/patch/8147901/
Erin Lo (1):
arm: dts: mt2701: Use real clock for UARTs
James Liao (1):
arm: dts: mt2701: Add clock controller device nodes
Shunli Wang (2):
clk: mediatek: Add MT2701 clock support
reset: mediatek: Add MT2701 reset driver
arch/arm/boot/dts/mt2701.dtsi | 50 +- drivers/clk/mediatek/Kconfig | 43 ++ drivers/clk/mediatek/Makefile | 7 + drivers/clk/mediatek/clk-gate.c | 52 ++ drivers/clk/mediatek/clk-gate.h | 2 + drivers/clk/mediatek/clk-mt2701-bdp.c | 148 +++++ drivers/clk/mediatek/clk-mt2701-eth.c | 90 +++ drivers/clk/mediatek/clk-mt2701-hif.c | 91 +++ drivers/clk/mediatek/clk-mt2701-img.c | 90 +++ drivers/clk/mediatek/clk-mt2701-mm.c | 133 ++++ drivers/clk/mediatek/clk-mt2701-vdec.c | 101 +++ drivers/clk/mediatek/clk-mt2701.c | 1054 ++++++++++++++++++++++++++++++++ drivers/clk/mediatek/clk-mtk.c | 40 ++ drivers/clk/mediatek/clk-mtk.h | 41 +- drivers/clk/mediatek/clk-pll.c | 1 + 15 files changed, 1933 insertions(+), 10 deletions(-) create mode 100644 drivers/clk/mediatek/clk-mt2701-bdp.c create mode 100644 drivers/clk/mediatek/clk-mt2701-eth.c create mode 100644 drivers/clk/mediatek/clk-mt2701-hif.c create mode 100644 drivers/clk/mediatek/clk-mt2701-img.c create mode 100644 drivers/clk/mediatek/clk-mt2701-mm.c create mode 100644 drivers/clk/mediatek/clk-mt2701-vdec.c create mode 100644 drivers/clk/mediatek/clk-mt2701.c
--
1.9.1
PATCH v13 1/4 clk: mediatek: Add MT2701 clock support
From: Shunli Wang <[email protected]>
Add MT2701 clock support, include topckgen, apmixedsys, infracfg, pericfg and subsystem clocks.
--- drivers/clk/mediatek/Kconfig | 43 ++ drivers/clk/mediatek/Makefile | 7 + drivers/clk/mediatek/clk-gate.c | 52 ++ drivers/clk/mediatek/clk-gate.h | 2 + drivers/clk/mediatek/clk-mt2701-bdp.c | 148 +++++ drivers/clk/mediatek/clk-mt2701-eth.c | 90 +++ drivers/clk/mediatek/clk-mt2701-hif.c | 87 +++ drivers/clk/mediatek/clk-mt2701-img.c | 90 +++ drivers/clk/mediatek/clk-mt2701-mm.c | 133 ++++ drivers/clk/mediatek/clk-mt2701-vdec.c | 101 +++ drivers/clk/mediatek/clk-mt2701.c | 1046 ++++++++++++++++++++++++++++++++ drivers/clk/mediatek/clk-mtk.c | 40 ++ drivers/clk/mediatek/clk-mtk.h | 41 +- drivers/clk/mediatek/clk-pll.c | 1 + 14 files changed, 1876 insertions(+), 5 deletions(-) create mode 100644 drivers/clk/mediatek/clk-mt2701-bdp.c create mode 100644 drivers/clk/mediatek/clk-mt2701-eth.c create mode 100644 drivers/clk/mediatek/clk-mt2701-hif.c create mode 100644 drivers/clk/mediatek/clk-mt2701-img.c create mode 100644 drivers/clk/mediatek/clk-mt2701-mm.c create mode 100644 drivers/clk/mediatek/clk-mt2701-vdec.c create mode 100644 drivers/clk/mediatek/clk-mt2701.c
drivers/clk/mediatek/Kconfig +43 -0
@@ -6,6 +6,49 @@ config COMMON_CLK_MEDIATEK ---help--- Mediatek SoCs' clock support. +config COMMON_CLK_MT2701 + bool "Clock driver for Mediatek MT2701" + select COMMON_CLK_MEDIATEK + default ARCH_MEDIATEK + ---help--- + This driver supports Mediatek MT2701 basic clocks. + +config COMMON_CLK_MT2701_MMSYS + bool "Clock driver for Mediatek MT2701 mmsys" + select COMMON_CLK_MT2701 + ---help--- + This driver supports Mediatek MT2701 mmsys clocks. + +config COMMON_CLK_MT2701_IMGSYS + bool "Clock driver for Mediatek MT2701 imgsys" + select COMMON_CLK_MT2701 + ---help--- + This driver supports Mediatek MT2701 imgsys clocks. + +config COMMON_CLK_MT2701_VDECSYS + bool "Clock driver for Mediatek MT2701 vdecsys" + select COMMON_CLK_MT2701 + ---help--- + This driver supports Mediatek MT2701 vdecsys clocks. + +config COMMON_CLK_MT2701_HIFSYS + bool "Clock driver for Mediatek MT2701 hifsys" + select COMMON_CLK_MT2701 + ---help--- + This driver supports Mediatek MT2701 hifsys clocks. + +config COMMON_CLK_MT2701_ETHSYS + bool "Clock driver for Mediatek MT2701 ethsys" + select COMMON_CLK_MT2701 + ---help--- + This driver supports Mediatek MT2701 ethsys clocks. + +config COMMON_CLK_MT2701_BDPSYS + bool "Clock driver for Mediatek MT2701 bdpsys" + select COMMON_CLK_MT2701 + ---help--- + This driver supports Mediatek MT2701 bdpsys clocks. + config COMMON_CLK_MT8135 bool "Clock driver for Mediatek MT8135" select COMMON_CLK_MEDIATEK
drivers/clk/mediatek/Makefile +7 -0
@@ -1,4 +1,11 @@ obj-$(CONFIG_COMMON_CLK_MEDIATEK) += clk-mtk.o clk-pll.o clk-gate.o clk-apmixed.o obj-$(CONFIG_RESET_CONTROLLER) += reset.o +obj-$(CONFIG_COMMON_CLK_MT2701) += clk-mt2701.o +obj-$(CONFIG_COMMON_CLK_MT2701_BDPSYS) += clk-mt2701-bdp.o +obj-$(CONFIG_COMMON_CLK_MT2701_ETHSYS) += clk-mt2701-eth.o +obj-$(CONFIG_COMMON_CLK_MT2701_HIFSYS) += clk-mt2701-hif.o +obj-$(CONFIG_COMMON_CLK_MT2701_IMGSYS) += clk-mt2701-img.o +obj-$(CONFIG_COMMON_CLK_MT2701_MMSYS) += clk-mt2701-mm.o +obj-$(CONFIG_COMMON_CLK_MT2701_VDECSYS) += clk-mt2701-vdec.o obj-$(CONFIG_COMMON_CLK_MT8135) += clk-mt8135.o obj-$(CONFIG_COMMON_CLK_MT8173) += clk-mt8173.o
drivers/clk/mediatek/clk-gate.c +52 -0
70 lines not on this page · raw message
drivers/clk/mediatek/clk-gate.h +2 -0
@@ -36,6 +36,8 @@ static inline struct mtk_clk_gate *to_mtk_clk_gate(struct clk_hw *hw)extern const struct clk_ops mtk_clk_gate_ops_setclr;extern const struct clk_ops mtk_clk_gate_ops_setclr_inv; +extern const struct clk_ops mtk_clk_gate_ops_no_setclr; +extern const struct clk_ops mtk_clk_gate_ops_no_setclr_inv; struct clk *mtk_clk_register_gate( const char *name,
drivers/clk/mediatek/clk-mt2701-bdp.c new file +148 -0
148 lines not on this page · raw message
drivers/clk/mediatek/clk-mt2701-eth.c new file +90 -0
90 lines not on this page · raw message
drivers/clk/mediatek/clk-mt2701-hif.c new file +87 -0
87 lines not on this page · raw message
drivers/clk/mediatek/clk-mt2701-img.c new file +90 -0
90 lines not on this page · raw message
drivers/clk/mediatek/clk-mt2701-mm.c new file +133 -0
133 lines not on this page · raw message
drivers/clk/mediatek/clk-mt2701-vdec.c new file +101 -0
101 lines not on this page · raw message
drivers/clk/mediatek/clk-mt2701.c new file +1046 -0
1,046 lines not on this page · raw message
drivers/clk/mediatek/clk-mtk.c +40 -0
@@ -58,6 +58,9 @@ void mtk_clk_register_fixed_clks(const struct mtk_fixed_clk *clks,for (i =0 ; i < num; i++) {const struct mtk_fixed_clk *rc = &clks[i]; +if (clk_data && !IS_ERR_OR_NULL (clk_data->clks[rc->id])) +continue ; + clk =clk_register_fixed_rate (NULL , rc->name, rc->parent,0 , rc->rate);
@@ -81,6 +84,9 @@ void mtk_clk_register_factors(const struct mtk_fixed_factor *clks,for (i =0 ; i < num; i++) {const struct mtk_fixed_factor *ff = &clks[i]; +if (clk_data && !IS_ERR_OR_NULL (clk_data->clks[ff->id])) +continue ; + clk =clk_register_fixed_factor (NULL , ff->name, ff->parent_name,CLK_SET_RATE_PARENT , ff->mult, ff->div);
@@ -116,6 +122,9 @@ int mtk_clk_register_gates(struct device_node *node,for (i =0 ; i < num; i++) {const struct mtk_gate *gate = &clks[i]; +if (!IS_ERR_OR_NULL (clk_data->clks[gate->id])) +continue ; + clk = mtk_clk_register_gate(gate->name, gate->parent_name, regmap, gate->regs->set_ofs,
@@ -232,6 +241,9 @@ void mtk_clk_register_composites(const struct mtk_composite *mcs,for (i =0 ; i < num; i++) {const struct mtk_composite *mc = &mcs[i]; +if (clk_data && !IS_ERR_OR_NULL (clk_data->clks[mc->id])) +continue ; + clk =mtk_clk_register_composite (mc, base, lock);if (IS_ERR (clk)) {
@@ -244,3 +256,31 @@ void mtk_clk_register_composites(const struct mtk_composite *mcs, clk_data->clks[mc->id] = clk; } } + +void mtk_clk_register_dividers (const struct mtk_clk_divider *mcds, +int num,void __iomem *base,spinlock_t *lock, +struct clk_onecell_data *clk_data) +{ +struct clk *clk; +int i; + +for (i =0 ; i < num; i++) { +const struct mtk_clk_divider *mcd = &mcds[i]; + +if (clk_data && !IS_ERR_OR_NULL (clk_data->clks[mcd->id])) +continue ; + + clk =clk_register_divider (NULL , mcd->name, mcd->parent_name, + mcd->flags, base + mcd->div_reg, mcd->div_shift, + mcd->div_width, mcd->clk_divider_flags, lock); + +if (IS_ERR (clk)) { +pr_err ("Failed to register clk %s: %ld\n" , + mcd->name,PTR_ERR (clk)); +continue ; + } + +if (clk_data) + clk_data->clks[mcd->id] = clk; + } +}
drivers/clk/mediatek/clk-mtk.h +36 -5
69 lines not on this page · raw message
drivers/clk/mediatek/clk-pll.c +1 -0
@@ -301,6 +301,7 @@ static struct clk *mtk_clk_register_pll(const struct mtk_pll_data *data, pll->data = data; init.name = data->name; + init.flags = (data->flags &PLL_AO ) ?CLK_IS_CRITICAL :0 ; init.ops = &mtk_pll_ops; init.parent_names = &parent_name; init.num_parents =1 ;
Signature · 1 line
1.9.1
PATCH v13 2/4 reset: mediatek: Add MT2701 reset driver
In reply to Erin LoFrom: Shunli Wang <[email protected]>
In infrasys and perifsys, there are many reset control bits for kinds of modules. These bits are used as actual reset controllers to be registered into kernel's generic reset controller framework.
--- drivers/clk/mediatek/clk-mt2701-hif.c | 6 +++++- drivers/clk/mediatek/clk-mt2701.c | 12 ++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-)
drivers/clk/mediatek/clk-mt2701-hif.c +5 -1
@@ -53,8 +53,12 @@ static int mtk_hifsys_init(struct platform_device *pdev) clk_data); r =of_clk_add_provider (node, of_clk_src_onecell_get, clk_data); +if (r) +return r; -return r; +mtk_register_reset_controller (node,1 ,0x34 ); + +return 0 ; }static const struct of_device_id of_match_clk_mt2701_hif[] = {
drivers/clk/mediatek/clk-mt2701.c +10 -2
@@ -802,8 +802,12 @@ static int mtk_infrasys_init(struct platform_device *pdev) infra_clk_data); r =of_clk_add_provider (node, of_clk_src_onecell_get, infra_clk_data); +if (r) +return r; -return r; +mtk_register_reset_controller (node,2 ,0x30 ); + +return 0 ; }static const struct mtk_gate_regs peri0_cg_regs = {
@@ -920,8 +924,12 @@ static int mtk_pericfg_init(struct platform_device *pdev) &lock, clk_data); r =of_clk_add_provider (node, of_clk_src_onecell_get, clk_data); +if (r) +return r; -return r; +mtk_register_reset_controller (node,2 ,0x0 ); + +return 0 ; }#define MT8590_PLL_FMAX (2000 * MHZ)
Signature · 1 line
1.9.1
PATCH v13 3/4 arm: dts: mt2701: Add clock controller device nodes
In reply to Erin LoFrom: James Liao <[email protected]>
Add clock controller nodes for MT2701, include topckgen, infracfg, pericfg, apmixedsys, mmsys, imgsys, vdecsys, hifsys, ethsys and bdpsys. This patch also add two oscillators that provide clocks for MT2701.
--- arch/arm/boot/dts/mt2701.dtsi | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+)
arch/arm/boot/dts/mt2701.dtsi +42 -0
@@ -12,8 +12,10 @@ * GNU General Public License for more details. */ +#include <dt-bindings/clock/mt2701-clk.h> #include <dt-bindings/interrupt-controller/irq.h> #include <dt-bindings/interrupt-controller/arm-gic.h> +#include <dt-bindings/reset/mt2701-resets.h> #include "skeleton64.dtsi" #include "mt2701-pinfunc.h"
@@ -77,6 +79,20 @@ #clock-cells = <0>; }; + clk26m: oscillator at 0 { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-frequency = <26000000>; + clock-output-names = "clk26m"; + }; + + rtc32k: oscillator at 1 { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-frequency = <32000>; + clock-output-names = "rtc32k"; + }; + timer { compatible = "arm,armv7-timer"; interrupt-parent = <&gic>;
@@ -104,6 +120,26 @@ reg = <0 0x10005000 0 0x1000>; }; + topckgen: syscon at 10000000 { + compatible = "mediatek,mt2701-topckgen", "syscon"; + reg = <0 0x10000000 0 0x1000>; + #clock-cells = <1>; + }; + + infracfg: syscon at 10001000 { + compatible = "mediatek,mt2701-infracfg", "syscon"; + reg = <0 0x10001000 0 0x1000>; + #clock-cells = <1>; + #reset-cells = <1>; + }; + + pericfg: syscon at 10003000 { + compatible = "mediatek,mt2701-pericfg", "syscon"; + reg = <0 0x10003000 0 0x1000>; + #clock-cells = <1>; + #reset-cells = <1>; + }; + watchdog: watchdog at 10007000 { compatible = "mediatek,mt2701-wdt", "mediatek,mt6589-wdt";
@@ -128,6 +164,12 @@ reg = <0 0x10200100 0 0x1c>; }; + apmixedsys: syscon at 10209000 { + compatible = "mediatek,mt2701-apmixedsys", "syscon"; + reg = <0 0x10209000 0 0x1000>; + #clock-cells = <1>; + }; + gic: interrupt-controller at 10211000 { compatible = "arm,cortex-a7-gic"; interrupt-controller;
Signature · 1 line
1.9.1
PATCH v13 4/4 arm: dts: mt2701: Use real clock for UARTs
In reply to Erin LoWe used to use a fixed rate clock for the UARTs. Now that we have clock support we can associate the correct clocks to the UARTs and drop the 26MHz fixed rate UART clock.
--- arch/arm/boot/dts/mt2701.dtsi | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)
arch/arm/boot/dts/mt2701.dtsi +8 -10
@@ -73,12 +73,6 @@ #clock-cells = <0>; }; - uart_clk: dummy26m { - compatible = "fixed-clock"; - clock-frequency = <26000000>; - #clock-cells = <0>; - }; - clk26m: oscillator at 0 { compatible = "fixed-clock"; #clock-cells = <0>;
@@ -186,7 +180,8 @@ "mediatek,mt6577-uart"; reg = <0 0x11002000 0 0x400>; interrupts = <GIC_SPI 51 IRQ_TYPE_LEVEL_LOW>; - clocks = <&uart_clk>; + clocks = <&pericfg CLK_PERI_UART0_SEL>, <&pericfg CLK_PERI_UART0>; + clock-names = "baud", "bus"; status = "disabled"; };
@@ -195,7 +190,8 @@ "mediatek,mt6577-uart"; reg = <0 0x11003000 0 0x400>; interrupts = <GIC_SPI 52 IRQ_TYPE_LEVEL_LOW>; - clocks = <&uart_clk>; + clocks = <&pericfg CLK_PERI_UART1_SEL>, <&pericfg CLK_PERI_UART1>; + clock-names = "baud", "bus"; status = "disabled"; };
@@ -204,7 +200,8 @@ "mediatek,mt6577-uart"; reg = <0 0x11004000 0 0x400>; interrupts = <GIC_SPI 53 IRQ_TYPE_LEVEL_LOW>; - clocks = <&uart_clk>; + clocks = <&pericfg CLK_PERI_UART2_SEL>, <&pericfg CLK_PERI_UART2>; + clock-names = "baud", "bus"; status = "disabled"; };
@@ -213,7 +210,8 @@ "mediatek,mt6577-uart"; reg = <0 0x11005000 0 0x400>; interrupts = <GIC_SPI 54 IRQ_TYPE_LEVEL_LOW>; - clocks = <&uart_clk>; + clocks = <&pericfg CLK_PERI_UART3_SEL>, <&pericfg CLK_PERI_UART3>; + clock-names = "baud", "bus"; status = "disabled"; }; };
Signature · 1 line
1.9.1