Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branches 'clk-mediatek', 'clk-sunplus', 'clk-loongson' and 'clk-socfpga' into clk-next

- Frequency Hopping (FHCTL) on MediaTek MT6795, MT8173, MT8192 and
MT8195 SoCs
- Converted most Mediatek clock drivers to struct platform_driver
- MediaTek clock drivers can be built as modules
- Mediatek MT8188 SoC clk drivers
- Clock driver for Sunplus SP7021 SoC
- Reimplement Loongson-1 clk driver with DT support
- Clk driver support for Loongson-2 SoCs
- Migrate socfpga clk driver to of_clk_add_hw_provider()

* clk-mediatek: (84 commits)
clk: mediatek: fhctl: Mark local variables static
clk: mediatek: Use right match table, include mod_devicetable
clk: mediatek: Add MT8188 adsp clock support
clk: mediatek: Add MT8188 imp i2c wrapper clock support
clk: mediatek: Add MT8188 wpesys clock support
clk: mediatek: Add MT8188 vppsys1 clock support
clk: mediatek: Add MT8188 vppsys0 clock support
clk: mediatek: Add MT8188 vencsys clock support
clk: mediatek: Add MT8188 vdosys1 clock support
clk: mediatek: Add MT8188 vdosys0 clock support
clk: mediatek: Add MT8188 vdecsys clock support
clk: mediatek: Add MT8188 mfgcfg clock support
clk: mediatek: Add MT8188 ipesys clock support
clk: mediatek: Add MT8188 imgsys clock support
clk: mediatek: Add MT8188 ccusys clock support
clk: mediatek: Add MT8188 camsys clock support
clk: mediatek: Add MT8188 infrastructure clock support
clk: mediatek: Add MT8188 peripheral clock support
clk: mediatek: Add MT8188 topckgen clock support
clk: mediatek: Add MT8188 apmixedsys clock support
...

* clk-sunplus:
clk: Add Sunplus SP7021 clock driver

* clk-loongson:
clk: clk-loongson2: add clock controller driver support
dt-bindings: clock: add loongson-2 boot clock index
MAINTAINERS: remove obsolete file entry in MIPS/LOONGSON1 ARCHITECTURE
MIPS: loongson32: Update the clock initialization
clk: loongson1: Re-implement the clock driver
clk: loongson1: Remove the outdated driver
dt-bindings: clock: Add Loongson-1 clock

* clk-socfpga:
clk: socfpga: arria10: use of_clk_add_hw_provider and improve error handling
clk: socfpga: use of_clk_add_hw_provider and improve error handling
clk: socfpga: arria10: use of_clk_add_hw_provider and improve error handling
clk: socfpga: use of_clk_add_hw_provider and improve error handling
clk: socfpga: arria10: use of_clk_add_hw_provider and improve error handling
clk: socfpga: use of_clk_add_hw_provider and improve error handling

+9247 -4858
+45
Documentation/devicetree/bindings/clock/loongson,ls1x-clk.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/clock/loongson,ls1x-clk.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Loongson-1 Clock Controller 8 + 9 + maintainers: 10 + - Keguang Zhang <keguang.zhang@gmail.com> 11 + 12 + properties: 13 + compatible: 14 + enum: 15 + - loongson,ls1b-clk 16 + - loongson,ls1c-clk 17 + 18 + reg: 19 + maxItems: 1 20 + 21 + clocks: 22 + maxItems: 1 23 + 24 + "#clock-cells": 25 + const: 1 26 + 27 + required: 28 + - compatible 29 + - reg 30 + - clocks 31 + - "#clock-cells" 32 + 33 + additionalProperties: false 34 + 35 + examples: 36 + - | 37 + clkc: clock-controller@1fe78030 { 38 + compatible = "loongson,ls1b-clk"; 39 + reg = <0x1fe78030 0x8>; 40 + 41 + clocks = <&xtal>; 42 + #clock-cells = <1>; 43 + }; 44 + 45 + ...
+6 -1
Documentation/devicetree/bindings/clock/mediatek,mt8186-fhctl.yaml
··· 16 16 17 17 properties: 18 18 compatible: 19 - const: mediatek,mt8186-fhctl 19 + enum: 20 + - mediatek,mt6795-fhctl 21 + - mediatek,mt8173-fhctl 22 + - mediatek,mt8186-fhctl 23 + - mediatek,mt8192-fhctl 24 + - mediatek,mt8195-fhctl 20 25 21 26 reg: 22 27 maxItems: 1
+71
Documentation/devicetree/bindings/clock/mediatek,mt8188-clock.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/clock/mediatek,mt8188-clock.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: MediaTek Functional Clock Controller for MT8188 8 + 9 + maintainers: 10 + - Garmin Chang <garmin.chang@mediatek.com> 11 + 12 + description: | 13 + The clock architecture in MediaTek like below 14 + PLLs --> 15 + dividers --> 16 + muxes 17 + --> 18 + clock gate 19 + 20 + The devices provide clock gate control in different IP blocks. 21 + 22 + properties: 23 + compatible: 24 + enum: 25 + - mediatek,mt8188-adsp-audio26m 26 + - mediatek,mt8188-camsys 27 + - mediatek,mt8188-camsys-rawa 28 + - mediatek,mt8188-camsys-rawb 29 + - mediatek,mt8188-camsys-yuva 30 + - mediatek,mt8188-camsys-yuvb 31 + - mediatek,mt8188-ccusys 32 + - mediatek,mt8188-imgsys 33 + - mediatek,mt8188-imgsys-wpe1 34 + - mediatek,mt8188-imgsys-wpe2 35 + - mediatek,mt8188-imgsys-wpe3 36 + - mediatek,mt8188-imgsys1-dip-nr 37 + - mediatek,mt8188-imgsys1-dip-top 38 + - mediatek,mt8188-imp-iic-wrap-c 39 + - mediatek,mt8188-imp-iic-wrap-en 40 + - mediatek,mt8188-imp-iic-wrap-w 41 + - mediatek,mt8188-ipesys 42 + - mediatek,mt8188-mfgcfg 43 + - mediatek,mt8188-vdecsys 44 + - mediatek,mt8188-vdecsys-soc 45 + - mediatek,mt8188-vencsys 46 + - mediatek,mt8188-vppsys0 47 + - mediatek,mt8188-vppsys1 48 + - mediatek,mt8188-wpesys 49 + - mediatek,mt8188-wpesys-vpp0 50 + 51 + reg: 52 + maxItems: 1 53 + 54 + '#clock-cells': 55 + const: 1 56 + 57 + required: 58 + - compatible 59 + - reg 60 + - '#clock-cells' 61 + 62 + additionalProperties: false 63 + 64 + examples: 65 + - | 66 + clock-controller@11283000 { 67 + compatible = "mediatek,mt8188-imp-iic-wrap-c"; 68 + reg = <0x11283000 0x1000>; 69 + #clock-cells = <1>; 70 + }; 71 +
+55
Documentation/devicetree/bindings/clock/mediatek,mt8188-sys-clock.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/clock/mediatek,mt8188-sys-clock.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: MediaTek System Clock Controller for MT8188 8 + 9 + maintainers: 10 + - Garmin Chang <garmin.chang@mediatek.com> 11 + 12 + description: | 13 + The clock architecture in MediaTek like below 14 + PLLs --> 15 + dividers --> 16 + muxes 17 + --> 18 + clock gate 19 + 20 + The apmixedsys provides most of PLLs which generated from SoC 26m. 21 + The topckgen provides dividers and muxes which provide the clock source to other IP blocks. 22 + The infracfg_ao provides clock gate in peripheral and infrastructure IP blocks. 23 + The mcusys provides mux control to select the clock source in AP MCU. 24 + The device nodes also provide the system control capacity for configuration. 25 + 26 + properties: 27 + compatible: 28 + items: 29 + - enum: 30 + - mediatek,mt8188-apmixedsys 31 + - mediatek,mt8188-infracfg-ao 32 + - mediatek,mt8188-pericfg-ao 33 + - mediatek,mt8188-topckgen 34 + - const: syscon 35 + 36 + reg: 37 + maxItems: 1 38 + 39 + '#clock-cells': 40 + const: 1 41 + 42 + required: 43 + - compatible 44 + - reg 45 + - '#clock-cells' 46 + 47 + additionalProperties: false 48 + 49 + examples: 50 + - | 51 + clock-controller@10000000 { 52 + compatible = "mediatek,mt8188-topckgen", "syscon"; 53 + reg = <0x10000000 0x1000>; 54 + #clock-cells = <1>; 55 + };
+2 -1
MAINTAINERS
··· 2849 2849 F: arch/arm/boot/dts/sunplus-sp7021*.dts* 2850 2850 F: arch/arm/configs/sp7021_*defconfig 2851 2851 F: arch/arm/mach-sunplus/ 2852 + F: drivers/clk/clk-sp7021.c 2852 2853 F: drivers/irqchip/irq-sp7021-intc.c 2853 2854 F: drivers/reset/reset-sunplus.c 2854 2855 F: include/dt-bindings/clock/sunplus,sp7021-clkc.h ··· 12122 12121 L: linux-clk@vger.kernel.org 12123 12122 S: Maintained 12124 12123 F: Documentation/devicetree/bindings/clock/loongson,ls2k-clk.yaml 12124 + F: drivers/clk/clk-loongson2.c 12125 12125 F: include/dt-bindings/clock/loongson,ls2k-clk.h 12126 12126 12127 12127 LSILOGIC MPT FUSION DRIVERS (FC/SAS/SPI) ··· 14002 14000 S: Maintained 14003 14001 F: arch/mips/include/asm/mach-loongson32/ 14004 14002 F: arch/mips/loongson32/ 14005 - F: drivers/*/*/*loongson1* 14006 14003 F: drivers/*/*loongson1* 14007 14004 14008 14005 MIPS/LOONGSON2EF ARCHITECTURE
-1
arch/mips/include/asm/mach-loongson32/platform.h
··· 20 20 extern struct platform_device ls1x_rtc_pdev; 21 21 extern struct platform_device ls1x_wdt_pdev; 22 22 23 - void __init ls1x_clk_init(void); 24 23 void __init ls1x_rtc_set_extclk(struct platform_device *pdev); 25 24 void __init ls1x_serial_set_uartclk(struct platform_device *pdev); 26 25
+2 -1
arch/mips/loongson32/common/time.c
··· 4 4 */ 5 5 6 6 #include <linux/clk.h> 7 + #include <linux/of_clk.h> 7 8 #include <linux/interrupt.h> 8 9 #include <linux/sizes.h> 9 10 #include <asm/time.h> ··· 212 211 struct clk *clk = NULL; 213 212 214 213 /* initialize LS1X clocks */ 215 - ls1x_clk_init(); 214 + of_clk_init(NULL); 216 215 217 216 #ifdef CONFIG_CEVT_CSRC_LS1X 218 217 /* setup LS1X PWM timer */
+19
drivers/clk/Kconfig
··· 325 325 This driver supports the clocking features of the Cirrus Logic 326 326 Lochnagar audio development board. 327 327 328 + config COMMON_CLK_LOONGSON2 329 + bool "Clock driver for Loongson-2 SoC" 330 + depends on LOONGARCH || COMPILE_TEST 331 + help 332 + This driver provides support for clock controller on Loongson-2 SoC. 333 + The clock controller can generates and supplies clock to various 334 + peripherals within the SoC. 335 + Say Y here to support Loongson-2 SoC clock driver. 336 + 328 337 config COMMON_CLK_NXP 329 338 def_bool COMMON_CLK && (ARCH_LPC18XX || ARCH_LPC32XX) 330 339 select REGMAP_MMIO if ARCH_LPC32XX ··· 453 444 default SOC_CANAAN 454 445 help 455 446 Support for the Canaan Kendryte K210 RISC-V SoC clocks. 447 + 448 + config COMMON_CLK_SP7021 449 + tristate "Clock driver for Sunplus SP7021 SoC" 450 + depends on SOC_SP7021 || COMPILE_TEST 451 + default SOC_SP7021 452 + help 453 + This driver supports the Sunplus SP7021 SoC clocks. 454 + It implements SP7021 PLLs/gate. 455 + Not all features of the PLL are currently supported 456 + by the driver. 456 457 457 458 source "drivers/clk/actions/Kconfig" 458 459 source "drivers/clk/analogbits/Kconfig"
+3 -1
drivers/clk/Makefile
··· 43 43 obj-$(CONFIG_LMK04832) += clk-lmk04832.o 44 44 obj-$(CONFIG_COMMON_CLK_LAN966X) += clk-lan966x.o 45 45 obj-$(CONFIG_COMMON_CLK_LOCHNAGAR) += clk-lochnagar.o 46 + obj-$(CONFIG_MACH_LOONGSON32) += clk-loongson1.o 47 + obj-$(CONFIG_COMMON_CLK_LOONGSON2) += clk-loongson2.o 46 48 obj-$(CONFIG_COMMON_CLK_MAX77686) += clk-max77686.o 47 49 obj-$(CONFIG_COMMON_CLK_MAX9485) += clk-max9485.o 48 50 obj-$(CONFIG_ARCH_MILBEAUT_M10V) += clk-milbeaut.o ··· 67 65 obj-$(CONFIG_COMMON_CLK_SI514) += clk-si514.o 68 66 obj-$(CONFIG_COMMON_CLK_SI544) += clk-si544.o 69 67 obj-$(CONFIG_COMMON_CLK_SI570) += clk-si570.o 68 + obj-$(CONFIG_COMMON_CLK_SP7021) += clk-sp7021.o 70 69 obj-$(CONFIG_COMMON_CLK_STM32F) += clk-stm32f4.o 71 70 obj-$(CONFIG_COMMON_CLK_STM32H7) += clk-stm32h7.o 72 71 obj-$(CONFIG_COMMON_CLK_STM32MP157) += clk-stm32mp1.o ··· 97 94 obj-y += ingenic/ 98 95 obj-$(CONFIG_ARCH_K3) += keystone/ 99 96 obj-$(CONFIG_ARCH_KEYSTONE) += keystone/ 100 - obj-$(CONFIG_MACH_LOONGSON32) += loongson1/ 101 97 obj-y += mediatek/ 102 98 obj-$(CONFIG_ARCH_MESON) += meson/ 103 99 obj-y += microchip/
+303
drivers/clk/clk-loongson1.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-or-later 2 + /* 3 + * Clock driver for Loongson-1 SoC 4 + * 5 + * Copyright (C) 2012-2023 Keguang Zhang <keguang.zhang@gmail.com> 6 + */ 7 + 8 + #include <linux/bits.h> 9 + #include <linux/clk-provider.h> 10 + #include <linux/container_of.h> 11 + #include <linux/io.h> 12 + #include <linux/of_address.h> 13 + #include <linux/slab.h> 14 + #include <linux/spinlock.h> 15 + #include <linux/printk.h> 16 + 17 + #include <dt-bindings/clock/loongson,ls1x-clk.h> 18 + 19 + /* Loongson 1 Clock Register Definitions */ 20 + #define CLK_PLL_FREQ 0x0 21 + #define CLK_PLL_DIV 0x4 22 + 23 + static DEFINE_SPINLOCK(ls1x_clk_div_lock); 24 + 25 + struct ls1x_clk_pll_data { 26 + u32 fixed; 27 + u8 shift; 28 + u8 int_shift; 29 + u8 int_width; 30 + u8 frac_shift; 31 + u8 frac_width; 32 + }; 33 + 34 + struct ls1x_clk_div_data { 35 + u8 shift; 36 + u8 width; 37 + unsigned long flags; 38 + const struct clk_div_table *table; 39 + u8 bypass_shift; 40 + u8 bypass_inv; 41 + spinlock_t *lock; /* protect access to DIV registers */ 42 + }; 43 + 44 + struct ls1x_clk { 45 + void __iomem *reg; 46 + unsigned int offset; 47 + struct clk_hw hw; 48 + const void *data; 49 + }; 50 + 51 + #define to_ls1x_clk(_hw) container_of(_hw, struct ls1x_clk, hw) 52 + 53 + static inline unsigned long ls1x_pll_rate_part(unsigned int val, 54 + unsigned int shift, 55 + unsigned int width) 56 + { 57 + return (val & GENMASK(shift + width, shift)) >> shift; 58 + } 59 + 60 + static unsigned long ls1x_pll_recalc_rate(struct clk_hw *hw, 61 + unsigned long parent_rate) 62 + { 63 + struct ls1x_clk *ls1x_clk = to_ls1x_clk(hw); 64 + const struct ls1x_clk_pll_data *d = ls1x_clk->data; 65 + u32 val, rate; 66 + 67 + val = readl(ls1x_clk->reg); 68 + rate = d->fixed; 69 + rate += ls1x_pll_rate_part(val, d->int_shift, d->int_width); 70 + if (d->frac_width) 71 + rate += ls1x_pll_rate_part(val, d->frac_shift, d->frac_width); 72 + rate *= parent_rate; 73 + rate >>= d->shift; 74 + 75 + return rate; 76 + } 77 + 78 + static const struct clk_ops ls1x_pll_clk_ops = { 79 + .recalc_rate = ls1x_pll_recalc_rate, 80 + }; 81 + 82 + static unsigned long ls1x_divider_recalc_rate(struct clk_hw *hw, 83 + unsigned long parent_rate) 84 + { 85 + struct ls1x_clk *ls1x_clk = to_ls1x_clk(hw); 86 + const struct ls1x_clk_div_data *d = ls1x_clk->data; 87 + unsigned int val; 88 + 89 + val = readl(ls1x_clk->reg) >> d->shift; 90 + val &= clk_div_mask(d->width); 91 + 92 + return divider_recalc_rate(hw, parent_rate, val, d->table, 93 + d->flags, d->width); 94 + } 95 + 96 + static long ls1x_divider_round_rate(struct clk_hw *hw, unsigned long rate, 97 + unsigned long *prate) 98 + { 99 + struct ls1x_clk *ls1x_clk = to_ls1x_clk(hw); 100 + const struct ls1x_clk_div_data *d = ls1x_clk->data; 101 + 102 + return divider_round_rate(hw, rate, prate, d->table, 103 + d->width, d->flags); 104 + } 105 + 106 + static int ls1x_divider_set_rate(struct clk_hw *hw, unsigned long rate, 107 + unsigned long parent_rate) 108 + { 109 + struct ls1x_clk *ls1x_clk = to_ls1x_clk(hw); 110 + const struct ls1x_clk_div_data *d = ls1x_clk->data; 111 + int val, div_val; 112 + unsigned long flags = 0; 113 + 114 + div_val = divider_get_val(rate, parent_rate, d->table, 115 + d->width, d->flags); 116 + if (div_val < 0) 117 + return div_val; 118 + 119 + spin_lock_irqsave(d->lock, flags); 120 + 121 + /* Bypass the clock */ 122 + val = readl(ls1x_clk->reg); 123 + if (d->bypass_inv) 124 + val &= ~BIT(d->bypass_shift); 125 + else 126 + val |= BIT(d->bypass_shift); 127 + writel(val, ls1x_clk->reg); 128 + 129 + val = readl(ls1x_clk->reg); 130 + val &= ~(clk_div_mask(d->width) << d->shift); 131 + val |= (u32)div_val << d->shift; 132 + writel(val, ls1x_clk->reg); 133 + 134 + /* Restore the clock */ 135 + val = readl(ls1x_clk->reg); 136 + if (d->bypass_inv) 137 + val |= BIT(d->bypass_shift); 138 + else 139 + val &= ~BIT(d->bypass_shift); 140 + writel(val, ls1x_clk->reg); 141 + 142 + spin_unlock_irqrestore(d->lock, flags); 143 + 144 + return 0; 145 + } 146 + 147 + static const struct clk_ops ls1x_clk_divider_ops = { 148 + .recalc_rate = ls1x_divider_recalc_rate, 149 + .round_rate = ls1x_divider_round_rate, 150 + .set_rate = ls1x_divider_set_rate, 151 + }; 152 + 153 + #define LS1X_CLK_PLL(_name, _offset, _fixed, _shift, \ 154 + f_shift, f_width, i_shift, i_width) \ 155 + struct ls1x_clk _name = { \ 156 + .offset = (_offset), \ 157 + .data = &(const struct ls1x_clk_pll_data) { \ 158 + .fixed = (_fixed), \ 159 + .shift = (_shift), \ 160 + .int_shift = (i_shift), \ 161 + .int_width = (i_width), \ 162 + .frac_shift = (f_shift), \ 163 + .frac_width = (f_width), \ 164 + }, \ 165 + .hw.init = &(const struct clk_init_data) { \ 166 + .name = #_name, \ 167 + .ops = &ls1x_pll_clk_ops, \ 168 + .parent_data = &(const struct clk_parent_data) { \ 169 + .fw_name = "xtal", \ 170 + .name = "xtal", \ 171 + .index = -1, \ 172 + }, \ 173 + .num_parents = 1, \ 174 + }, \ 175 + } 176 + 177 + #define LS1X_CLK_DIV(_name, _pname, _offset, _shift, _width, \ 178 + _table, _bypass_shift, _bypass_inv, _flags) \ 179 + struct ls1x_clk _name = { \ 180 + .offset = (_offset), \ 181 + .data = &(const struct ls1x_clk_div_data){ \ 182 + .shift = (_shift), \ 183 + .width = (_width), \ 184 + .table = (_table), \ 185 + .flags = (_flags), \ 186 + .bypass_shift = (_bypass_shift), \ 187 + .bypass_inv = (_bypass_inv), \ 188 + .lock = &ls1x_clk_div_lock, \ 189 + }, \ 190 + .hw.init = &(const struct clk_init_data) { \ 191 + .name = #_name, \ 192 + .ops = &ls1x_clk_divider_ops, \ 193 + .parent_hws = (const struct clk_hw *[]) { _pname }, \ 194 + .num_parents = 1, \ 195 + .flags = CLK_GET_RATE_NOCACHE, \ 196 + }, \ 197 + } 198 + 199 + static LS1X_CLK_PLL(ls1b_clk_pll, CLK_PLL_FREQ, 12, 1, 0, 5, 0, 0); 200 + static LS1X_CLK_DIV(ls1b_clk_cpu, &ls1b_clk_pll.hw, CLK_PLL_DIV, 201 + 20, 4, NULL, 8, 0, 202 + CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ROUND_CLOSEST); 203 + static LS1X_CLK_DIV(ls1b_clk_dc, &ls1b_clk_pll.hw, CLK_PLL_DIV, 204 + 26, 4, NULL, 12, 0, CLK_DIVIDER_ONE_BASED); 205 + static LS1X_CLK_DIV(ls1b_clk_ahb, &ls1b_clk_pll.hw, CLK_PLL_DIV, 206 + 14, 4, NULL, 10, 0, CLK_DIVIDER_ONE_BASED); 207 + static CLK_FIXED_FACTOR(ls1b_clk_apb, "ls1b_clk_apb", "ls1b_clk_ahb", 2, 1, 208 + CLK_SET_RATE_PARENT); 209 + 210 + static struct clk_hw_onecell_data ls1b_clk_hw_data = { 211 + .hws = { 212 + [LS1X_CLKID_PLL] = &ls1b_clk_pll.hw, 213 + [LS1X_CLKID_CPU] = &ls1b_clk_cpu.hw, 214 + [LS1X_CLKID_DC] = &ls1b_clk_dc.hw, 215 + [LS1X_CLKID_AHB] = &ls1b_clk_ahb.hw, 216 + [LS1X_CLKID_APB] = &ls1b_clk_apb.hw, 217 + }, 218 + .num = CLK_NR_CLKS, 219 + }; 220 + 221 + static const struct clk_div_table ls1c_ahb_div_table[] = { 222 + [0] = { .val = 0, .div = 2 }, 223 + [1] = { .val = 1, .div = 4 }, 224 + [2] = { .val = 2, .div = 3 }, 225 + [3] = { .val = 3, .div = 3 }, 226 + [4] = { /* sentinel */ } 227 + }; 228 + 229 + static LS1X_CLK_PLL(ls1c_clk_pll, CLK_PLL_FREQ, 0, 2, 8, 8, 16, 8); 230 + static LS1X_CLK_DIV(ls1c_clk_cpu, &ls1c_clk_pll.hw, CLK_PLL_DIV, 231 + 8, 7, NULL, 0, 1, 232 + CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ROUND_CLOSEST); 233 + static LS1X_CLK_DIV(ls1c_clk_dc, &ls1c_clk_pll.hw, CLK_PLL_DIV, 234 + 24, 7, NULL, 4, 1, CLK_DIVIDER_ONE_BASED); 235 + static LS1X_CLK_DIV(ls1c_clk_ahb, &ls1c_clk_cpu.hw, CLK_PLL_FREQ, 236 + 0, 2, ls1c_ahb_div_table, 0, 0, CLK_DIVIDER_ALLOW_ZERO); 237 + static CLK_FIXED_FACTOR(ls1c_clk_apb, "ls1c_clk_apb", "ls1c_clk_ahb", 1, 1, 238 + CLK_SET_RATE_PARENT); 239 + 240 + static struct clk_hw_onecell_data ls1c_clk_hw_data = { 241 + .hws = { 242 + [LS1X_CLKID_PLL] = &ls1c_clk_pll.hw, 243 + [LS1X_CLKID_CPU] = &ls1c_clk_cpu.hw, 244 + [LS1X_CLKID_DC] = &ls1c_clk_dc.hw, 245 + [LS1X_CLKID_AHB] = &ls1c_clk_ahb.hw, 246 + [LS1X_CLKID_APB] = &ls1c_clk_apb.hw, 247 + }, 248 + .num = CLK_NR_CLKS, 249 + }; 250 + 251 + static void __init ls1x_clk_init(struct device_node *np, 252 + struct clk_hw_onecell_data *hw_data) 253 + { 254 + struct ls1x_clk *ls1x_clk; 255 + void __iomem *reg; 256 + int i, ret; 257 + 258 + reg = of_iomap(np, 0); 259 + if (!reg) { 260 + pr_err("Unable to map base for %pOF\n", np); 261 + return; 262 + } 263 + 264 + for (i = 0; i < hw_data->num; i++) { 265 + /* array might be sparse */ 266 + if (!hw_data->hws[i]) 267 + continue; 268 + 269 + if (i != LS1X_CLKID_APB) { 270 + ls1x_clk = to_ls1x_clk(hw_data->hws[i]); 271 + ls1x_clk->reg = reg + ls1x_clk->offset; 272 + } 273 + 274 + ret = of_clk_hw_register(np, hw_data->hws[i]); 275 + if (ret) 276 + goto err; 277 + } 278 + 279 + ret = of_clk_add_hw_provider(np, of_clk_hw_onecell_get, hw_data); 280 + if (!ret) 281 + return; 282 + 283 + err: 284 + pr_err("Failed to register %pOF\n", np); 285 + 286 + while (--i >= 0) 287 + clk_hw_unregister(hw_data->hws[i]); 288 + 289 + iounmap(reg); 290 + } 291 + 292 + static void __init ls1b_clk_init(struct device_node *np) 293 + { 294 + return ls1x_clk_init(np, &ls1b_clk_hw_data); 295 + } 296 + 297 + static void __init ls1c_clk_init(struct device_node *np) 298 + { 299 + return ls1x_clk_init(np, &ls1c_clk_hw_data); 300 + } 301 + 302 + CLK_OF_DECLARE(ls1b_clk, "loongson,ls1b-clk", ls1b_clk_init); 303 + CLK_OF_DECLARE(ls1c_clk, "loongson,ls1c-clk", ls1c_clk_init);
+341
drivers/clk/clk-loongson2.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 2 + /* 3 + * Author: Yinbo Zhu <zhuyinbo@loongson.cn> 4 + * Copyright (C) 2022-2023 Loongson Technology Corporation Limited 5 + */ 6 + 7 + #include <linux/err.h> 8 + #include <linux/init.h> 9 + #include <linux/clk-provider.h> 10 + #include <linux/slab.h> 11 + #include <linux/module.h> 12 + #include <linux/platform_device.h> 13 + #include <linux/io-64-nonatomic-lo-hi.h> 14 + #include <dt-bindings/clock/loongson,ls2k-clk.h> 15 + 16 + #define LOONGSON2_PLL_MULT_SHIFT 32 17 + #define LOONGSON2_PLL_MULT_WIDTH 10 18 + #define LOONGSON2_PLL_DIV_SHIFT 26 19 + #define LOONGSON2_PLL_DIV_WIDTH 6 20 + #define LOONGSON2_APB_FREQSCALE_SHIFT 20 21 + #define LOONGSON2_APB_FREQSCALE_WIDTH 3 22 + #define LOONGSON2_USB_FREQSCALE_SHIFT 16 23 + #define LOONGSON2_USB_FREQSCALE_WIDTH 3 24 + #define LOONGSON2_SATA_FREQSCALE_SHIFT 12 25 + #define LOONGSON2_SATA_FREQSCALE_WIDTH 3 26 + #define LOONGSON2_BOOT_FREQSCALE_SHIFT 8 27 + #define LOONGSON2_BOOT_FREQSCALE_WIDTH 3 28 + 29 + static void __iomem *loongson2_pll_base; 30 + 31 + static const struct clk_parent_data pdata[] = { 32 + { .fw_name = "ref_100m",}, 33 + }; 34 + 35 + static struct clk_hw *loongson2_clk_register(struct device *dev, 36 + const char *name, 37 + const char *parent_name, 38 + const struct clk_ops *ops, 39 + unsigned long flags) 40 + { 41 + int ret; 42 + struct clk_hw *hw; 43 + struct clk_init_data init; 44 + 45 + hw = devm_kzalloc(dev, sizeof(*hw), GFP_KERNEL); 46 + if (!hw) 47 + return ERR_PTR(-ENOMEM); 48 + 49 + init.name = name; 50 + init.ops = ops; 51 + init.flags = flags; 52 + init.num_parents = 1; 53 + 54 + if (!parent_name) 55 + init.parent_data = pdata; 56 + else 57 + init.parent_names = &parent_name; 58 + 59 + hw->init = &init; 60 + 61 + ret = devm_clk_hw_register(dev, hw); 62 + if (ret) 63 + hw = ERR_PTR(ret); 64 + 65 + return hw; 66 + } 67 + 68 + static unsigned long loongson2_calc_pll_rate(int offset, unsigned long rate) 69 + { 70 + u64 val; 71 + u32 mult, div; 72 + 73 + val = readq(loongson2_pll_base + offset); 74 + 75 + mult = (val >> LOONGSON2_PLL_MULT_SHIFT) & 76 + clk_div_mask(LOONGSON2_PLL_MULT_WIDTH); 77 + div = (val >> LOONGSON2_PLL_DIV_SHIFT) & 78 + clk_div_mask(LOONGSON2_PLL_DIV_WIDTH); 79 + 80 + return div_u64((u64)rate * mult, div); 81 + } 82 + 83 + static unsigned long loongson2_node_recalc_rate(struct clk_hw *hw, 84 + unsigned long parent_rate) 85 + { 86 + return loongson2_calc_pll_rate(0x0, parent_rate); 87 + } 88 + 89 + static const struct clk_ops loongson2_node_clk_ops = { 90 + .recalc_rate = loongson2_node_recalc_rate, 91 + }; 92 + 93 + static unsigned long loongson2_ddr_recalc_rate(struct clk_hw *hw, 94 + unsigned long parent_rate) 95 + { 96 + return loongson2_calc_pll_rate(0x10, parent_rate); 97 + } 98 + 99 + static const struct clk_ops loongson2_ddr_clk_ops = { 100 + .recalc_rate = loongson2_ddr_recalc_rate, 101 + }; 102 + 103 + static unsigned long loongson2_dc_recalc_rate(struct clk_hw *hw, 104 + unsigned long parent_rate) 105 + { 106 + return loongson2_calc_pll_rate(0x20, parent_rate); 107 + } 108 + 109 + static const struct clk_ops loongson2_dc_clk_ops = { 110 + .recalc_rate = loongson2_dc_recalc_rate, 111 + }; 112 + 113 + static unsigned long loongson2_pix0_recalc_rate(struct clk_hw *hw, 114 + unsigned long parent_rate) 115 + { 116 + return loongson2_calc_pll_rate(0x30, parent_rate); 117 + } 118 + 119 + static const struct clk_ops loongson2_pix0_clk_ops = { 120 + .recalc_rate = loongson2_pix0_recalc_rate, 121 + }; 122 + 123 + static unsigned long loongson2_pix1_recalc_rate(struct clk_hw *hw, 124 + unsigned long parent_rate) 125 + { 126 + return loongson2_calc_pll_rate(0x40, parent_rate); 127 + } 128 + 129 + static const struct clk_ops loongson2_pix1_clk_ops = { 130 + .recalc_rate = loongson2_pix1_recalc_rate, 131 + }; 132 + 133 + static unsigned long loongson2_calc_rate(unsigned long rate, 134 + int shift, int width) 135 + { 136 + u64 val; 137 + u32 mult; 138 + 139 + val = readq(loongson2_pll_base + 0x50); 140 + 141 + mult = (val >> shift) & clk_div_mask(width); 142 + 143 + return div_u64((u64)rate * (mult + 1), 8); 144 + } 145 + 146 + static unsigned long loongson2_boot_recalc_rate(struct clk_hw *hw, 147 + unsigned long parent_rate) 148 + { 149 + return loongson2_calc_rate(parent_rate, 150 + LOONGSON2_BOOT_FREQSCALE_SHIFT, 151 + LOONGSON2_BOOT_FREQSCALE_WIDTH); 152 + } 153 + 154 + static const struct clk_ops loongson2_boot_clk_ops = { 155 + .recalc_rate = loongson2_boot_recalc_rate, 156 + }; 157 + 158 + static unsigned long loongson2_apb_recalc_rate(struct clk_hw *hw, 159 + unsigned long parent_rate) 160 + { 161 + return loongson2_calc_rate(parent_rate, 162 + LOONGSON2_APB_FREQSCALE_SHIFT, 163 + LOONGSON2_APB_FREQSCALE_WIDTH); 164 + } 165 + 166 + static const struct clk_ops loongson2_apb_clk_ops = { 167 + .recalc_rate = loongson2_apb_recalc_rate, 168 + }; 169 + 170 + static unsigned long loongson2_usb_recalc_rate(struct clk_hw *hw, 171 + unsigned long parent_rate) 172 + { 173 + return loongson2_calc_rate(parent_rate, 174 + LOONGSON2_USB_FREQSCALE_SHIFT, 175 + LOONGSON2_USB_FREQSCALE_WIDTH); 176 + } 177 + 178 + static const struct clk_ops loongson2_usb_clk_ops = { 179 + .recalc_rate = loongson2_usb_recalc_rate, 180 + }; 181 + 182 + static unsigned long loongson2_sata_recalc_rate(struct clk_hw *hw, 183 + unsigned long parent_rate) 184 + { 185 + return loongson2_calc_rate(parent_rate, 186 + LOONGSON2_SATA_FREQSCALE_SHIFT, 187 + LOONGSON2_SATA_FREQSCALE_WIDTH); 188 + } 189 + 190 + static const struct clk_ops loongson2_sata_clk_ops = { 191 + .recalc_rate = loongson2_sata_recalc_rate, 192 + }; 193 + 194 + static inline int loongson2_check_clk_hws(struct clk_hw *clks[], unsigned int count) 195 + { 196 + unsigned int i; 197 + 198 + for (i = 0; i < count; i++) 199 + if (IS_ERR(clks[i])) { 200 + pr_err("Loongson2 clk %u: register failed with %ld\n", 201 + i, PTR_ERR(clks[i])); 202 + return PTR_ERR(clks[i]); 203 + } 204 + 205 + return 0; 206 + } 207 + 208 + static int loongson2_clk_probe(struct platform_device *pdev) 209 + { 210 + int ret; 211 + struct clk_hw **hws; 212 + struct clk_hw_onecell_data *clk_hw_data; 213 + spinlock_t loongson2_clk_lock; 214 + struct device *dev = &pdev->dev; 215 + 216 + loongson2_pll_base = devm_platform_ioremap_resource(pdev, 0); 217 + if (IS_ERR(loongson2_pll_base)) 218 + return PTR_ERR(loongson2_pll_base); 219 + 220 + clk_hw_data = devm_kzalloc(dev, struct_size(clk_hw_data, hws, LOONGSON2_CLK_END), 221 + GFP_KERNEL); 222 + if (WARN_ON(!clk_hw_data)) 223 + return -ENOMEM; 224 + 225 + clk_hw_data->num = LOONGSON2_CLK_END; 226 + hws = clk_hw_data->hws; 227 + 228 + hws[LOONGSON2_NODE_PLL] = loongson2_clk_register(dev, "node_pll", 229 + NULL, 230 + &loongson2_node_clk_ops, 0); 231 + 232 + hws[LOONGSON2_DDR_PLL] = loongson2_clk_register(dev, "ddr_pll", 233 + NULL, 234 + &loongson2_ddr_clk_ops, 0); 235 + 236 + hws[LOONGSON2_DC_PLL] = loongson2_clk_register(dev, "dc_pll", 237 + NULL, 238 + &loongson2_dc_clk_ops, 0); 239 + 240 + hws[LOONGSON2_PIX0_PLL] = loongson2_clk_register(dev, "pix0_pll", 241 + NULL, 242 + &loongson2_pix0_clk_ops, 0); 243 + 244 + hws[LOONGSON2_PIX1_PLL] = loongson2_clk_register(dev, "pix1_pll", 245 + NULL, 246 + &loongson2_pix1_clk_ops, 0); 247 + 248 + hws[LOONGSON2_BOOT_CLK] = loongson2_clk_register(dev, "boot", 249 + NULL, 250 + &loongson2_boot_clk_ops, 0); 251 + 252 + hws[LOONGSON2_NODE_CLK] = devm_clk_hw_register_divider(dev, "node", 253 + "node_pll", 0, 254 + loongson2_pll_base + 0x8, 0, 255 + 6, CLK_DIVIDER_ONE_BASED, 256 + &loongson2_clk_lock); 257 + 258 + /* 259 + * The hda clk divisor in the upper 32bits and the clk-prodiver 260 + * layer code doesn't support 64bit io operation thus a conversion 261 + * is required that subtract shift by 32 and add 4byte to the hda 262 + * address 263 + */ 264 + hws[LOONGSON2_HDA_CLK] = devm_clk_hw_register_divider(dev, "hda", 265 + "ddr_pll", 0, 266 + loongson2_pll_base + 0x22, 12, 267 + 7, CLK_DIVIDER_ONE_BASED, 268 + &loongson2_clk_lock); 269 + 270 + hws[LOONGSON2_GPU_CLK] = devm_clk_hw_register_divider(dev, "gpu", 271 + "ddr_pll", 0, 272 + loongson2_pll_base + 0x18, 22, 273 + 6, CLK_DIVIDER_ONE_BASED, 274 + &loongson2_clk_lock); 275 + 276 + hws[LOONGSON2_DDR_CLK] = devm_clk_hw_register_divider(dev, "ddr", 277 + "ddr_pll", 0, 278 + loongson2_pll_base + 0x18, 0, 279 + 6, CLK_DIVIDER_ONE_BASED, 280 + &loongson2_clk_lock); 281 + 282 + hws[LOONGSON2_GMAC_CLK] = devm_clk_hw_register_divider(dev, "gmac", 283 + "dc_pll", 0, 284 + loongson2_pll_base + 0x28, 22, 285 + 6, CLK_DIVIDER_ONE_BASED, 286 + &loongson2_clk_lock); 287 + 288 + hws[LOONGSON2_DC_CLK] = devm_clk_hw_register_divider(dev, "dc", 289 + "dc_pll", 0, 290 + loongson2_pll_base + 0x28, 0, 291 + 6, CLK_DIVIDER_ONE_BASED, 292 + &loongson2_clk_lock); 293 + 294 + hws[LOONGSON2_APB_CLK] = loongson2_clk_register(dev, "apb", 295 + "gmac", 296 + &loongson2_apb_clk_ops, 0); 297 + 298 + hws[LOONGSON2_USB_CLK] = loongson2_clk_register(dev, "usb", 299 + "gmac", 300 + &loongson2_usb_clk_ops, 0); 301 + 302 + hws[LOONGSON2_SATA_CLK] = loongson2_clk_register(dev, "sata", 303 + "gmac", 304 + &loongson2_sata_clk_ops, 0); 305 + 306 + hws[LOONGSON2_PIX0_CLK] = clk_hw_register_divider(NULL, "pix0", 307 + "pix0_pll", 0, 308 + loongson2_pll_base + 0x38, 0, 6, 309 + CLK_DIVIDER_ONE_BASED, 310 + &loongson2_clk_lock); 311 + 312 + hws[LOONGSON2_PIX1_CLK] = clk_hw_register_divider(NULL, "pix1", 313 + "pix1_pll", 0, 314 + loongson2_pll_base + 0x48, 0, 6, 315 + CLK_DIVIDER_ONE_BASED, 316 + &loongson2_clk_lock); 317 + 318 + ret = loongson2_check_clk_hws(hws, LOONGSON2_CLK_END); 319 + if (ret) 320 + return ret; 321 + 322 + return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_hw_data); 323 + } 324 + 325 + static const struct of_device_id loongson2_clk_match_table[] = { 326 + { .compatible = "loongson,ls2k-clk" }, 327 + { } 328 + }; 329 + MODULE_DEVICE_TABLE(of, loongson2_clk_match_table); 330 + 331 + static struct platform_driver loongson2_clk_driver = { 332 + .probe = loongson2_clk_probe, 333 + .driver = { 334 + .name = "loongson2-clk", 335 + .of_match_table = loongson2_clk_match_table, 336 + }, 337 + }; 338 + module_platform_driver(loongson2_clk_driver); 339 + 340 + MODULE_DESCRIPTION("Loongson2 clock driver"); 341 + MODULE_LICENSE("GPL");
+713
drivers/clk/clk-sp7021.c
··· 1 + // SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + /* 3 + * Copyright (C) Sunplus Technology Co., Ltd. 4 + * All rights reserved. 5 + */ 6 + #include <linux/module.h> 7 + #include <linux/clk-provider.h> 8 + #include <linux/of.h> 9 + #include <linux/bitfield.h> 10 + #include <linux/slab.h> 11 + #include <linux/io.h> 12 + #include <linux/err.h> 13 + #include <linux/platform_device.h> 14 + 15 + #include <dt-bindings/clock/sunplus,sp7021-clkc.h> 16 + 17 + /* speical div_width values for PLLTV/PLLA */ 18 + #define DIV_TV 33 19 + #define DIV_A 34 20 + 21 + /* PLLTV parameters */ 22 + enum { 23 + SEL_FRA, 24 + SDM_MOD, 25 + PH_SEL, 26 + NFRA, 27 + DIVR, 28 + DIVN, 29 + DIVM, 30 + P_MAX 31 + }; 32 + 33 + #define MASK_SEL_FRA GENMASK(1, 1) 34 + #define MASK_SDM_MOD GENMASK(2, 2) 35 + #define MASK_PH_SEL GENMASK(4, 4) 36 + #define MASK_NFRA GENMASK(12, 6) 37 + #define MASK_DIVR GENMASK(8, 7) 38 + #define MASK_DIVN GENMASK(7, 0) 39 + #define MASK_DIVM GENMASK(14, 8) 40 + 41 + /* HIWORD_MASK FIELD_PREP */ 42 + #define HWM_FIELD_PREP(mask, value) \ 43 + ({ \ 44 + u32 _m = mask; \ 45 + (_m << 16) | FIELD_PREP(_m, value); \ 46 + }) 47 + 48 + struct sp_pll { 49 + struct clk_hw hw; 50 + void __iomem *reg; 51 + spinlock_t lock; /* lock for reg */ 52 + int div_shift; 53 + int div_width; 54 + int pd_bit; /* power down bit idx */ 55 + int bp_bit; /* bypass bit idx */ 56 + unsigned long brate; /* base rate, TODO: replace brate with muldiv */ 57 + u32 p[P_MAX]; /* for hold PLLTV/PLLA parameters */ 58 + }; 59 + 60 + #define to_sp_pll(_hw) container_of(_hw, struct sp_pll, hw) 61 + 62 + struct sp_clk_gate_info { 63 + u16 reg; /* reg_index_shift */ 64 + u16 ext_parent; /* parent is extclk */ 65 + }; 66 + 67 + static const struct sp_clk_gate_info sp_clk_gates[] = { 68 + { 0x02 }, 69 + { 0x05 }, 70 + { 0x06 }, 71 + { 0x07 }, 72 + { 0x09 }, 73 + { 0x0b, 1 }, 74 + { 0x0f, 1 }, 75 + { 0x14 }, 76 + { 0x15 }, 77 + { 0x16 }, 78 + { 0x17 }, 79 + { 0x18, 1 }, 80 + { 0x19, 1 }, 81 + { 0x1a, 1 }, 82 + { 0x1b, 1 }, 83 + { 0x1c, 1 }, 84 + { 0x1d, 1 }, 85 + { 0x1e }, 86 + { 0x1f, 1 }, 87 + { 0x20 }, 88 + { 0x21 }, 89 + { 0x22 }, 90 + { 0x23 }, 91 + { 0x24 }, 92 + { 0x25 }, 93 + { 0x26 }, 94 + { 0x2a }, 95 + { 0x2b }, 96 + { 0x2d }, 97 + { 0x2e }, 98 + { 0x30 }, 99 + { 0x31 }, 100 + { 0x32 }, 101 + { 0x33 }, 102 + { 0x3d }, 103 + { 0x3e }, 104 + { 0x3f }, 105 + { 0x42 }, 106 + { 0x44 }, 107 + { 0x4b }, 108 + { 0x4c }, 109 + { 0x4d }, 110 + { 0x4e }, 111 + { 0x4f }, 112 + { 0x50 }, 113 + { 0x55 }, 114 + { 0x60 }, 115 + { 0x61 }, 116 + { 0x6a }, 117 + { 0x73 }, 118 + { 0x86 }, 119 + { 0x8a }, 120 + { 0x8b }, 121 + { 0x8d }, 122 + { 0x8e }, 123 + { 0x8f }, 124 + { 0x90 }, 125 + { 0x92 }, 126 + { 0x93 }, 127 + { 0x95 }, 128 + { 0x96 }, 129 + { 0x97 }, 130 + { 0x98 }, 131 + { 0x99 }, 132 + }; 133 + 134 + #define _M 1000000UL 135 + #define F_27M (27 * _M) 136 + 137 + /*********************************** PLL_TV **********************************/ 138 + 139 + /* TODO: set proper FVCO range */ 140 + #define FVCO_MIN (100 * _M) 141 + #define FVCO_MAX (200 * _M) 142 + 143 + #define F_MIN (FVCO_MIN / 8) 144 + #define F_MAX (FVCO_MAX) 145 + 146 + static long plltv_integer_div(struct sp_pll *clk, unsigned long freq) 147 + { 148 + /* valid m values: 27M must be divisible by m */ 149 + static const u32 m_table[] = { 150 + 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24, 25, 27, 30, 32 151 + }; 152 + u32 m, n, r; 153 + unsigned long fvco, nf; 154 + long ret; 155 + 156 + freq = clamp(freq, F_MIN, F_MAX); 157 + 158 + /* DIVR 0~3 */ 159 + for (r = 0; r <= 3; r++) { 160 + fvco = freq << r; 161 + if (fvco <= FVCO_MAX) 162 + break; 163 + } 164 + 165 + /* DIVM */ 166 + for (m = 0; m < ARRAY_SIZE(m_table); m++) { 167 + nf = fvco * m_table[m]; 168 + n = nf / F_27M; 169 + if ((n * F_27M) == nf) 170 + break; 171 + } 172 + if (m >= ARRAY_SIZE(m_table)) { 173 + ret = -EINVAL; 174 + goto err_not_found; 175 + } 176 + 177 + /* save parameters */ 178 + clk->p[SEL_FRA] = 0; 179 + clk->p[DIVR] = r; 180 + clk->p[DIVN] = n; 181 + clk->p[DIVM] = m_table[m]; 182 + 183 + return freq; 184 + 185 + err_not_found: 186 + pr_err("%s: %s freq:%lu not found a valid setting\n", 187 + __func__, clk_hw_get_name(&clk->hw), freq); 188 + 189 + return ret; 190 + } 191 + 192 + /* parameters for PLLTV fractional divider */ 193 + static const u32 pt[][5] = { 194 + /* conventional fractional */ 195 + { 196 + 1, /* factor */ 197 + 5, /* 5 * p0 (nint) */ 198 + 1, /* 1 * p0 */ 199 + F_27M, /* F_27M / p0 */ 200 + 1, /* p0 / p2 */ 201 + }, 202 + /* phase rotation */ 203 + { 204 + 10, /* factor */ 205 + 54, /* 5.4 * p0 (nint) */ 206 + 2, /* 0.2 * p0 */ 207 + F_27M / 10, /* F_27M / p0 */ 208 + 5, /* p0 / p2 */ 209 + }, 210 + }; 211 + 212 + static const u32 sdm_mod_vals[] = { 91, 55 }; 213 + 214 + static long plltv_fractional_div(struct sp_pll *clk, unsigned long freq) 215 + { 216 + u32 m, r; 217 + u32 nint, nfra; 218 + u32 df_quotient_min = 210000000; 219 + u32 df_remainder_min = 0; 220 + unsigned long fvco, nf, f, fout = 0; 221 + int sdm, ph; 222 + 223 + freq = clamp(freq, F_MIN, F_MAX); 224 + 225 + /* DIVR 0~3 */ 226 + for (r = 0; r <= 3; r++) { 227 + fvco = freq << r; 228 + if (fvco <= FVCO_MAX) 229 + break; 230 + } 231 + f = F_27M >> r; 232 + 233 + /* PH_SEL */ 234 + for (ph = ARRAY_SIZE(pt) - 1; ph >= 0; ph--) { 235 + const u32 *pp = pt[ph]; 236 + 237 + /* SDM_MOD */ 238 + for (sdm = 0; sdm < ARRAY_SIZE(sdm_mod_vals); sdm++) { 239 + u32 mod = sdm_mod_vals[sdm]; 240 + 241 + /* DIVM 1~32 */ 242 + for (m = 1; m <= 32; m++) { 243 + u32 df; /* diff freq */ 244 + u32 df_quotient, df_remainder; 245 + 246 + nf = fvco * m; 247 + nint = nf / pp[3]; 248 + 249 + if (nint < pp[1]) 250 + continue; 251 + if (nint > pp[1]) 252 + break; 253 + 254 + nfra = (((nf % pp[3]) * mod * pp[4]) + (F_27M / 2)) / F_27M; 255 + if (nfra) { 256 + u32 df0 = f * (nint + pp[2]) / pp[0]; 257 + u32 df1 = f * (mod - nfra) / mod / pp[4]; 258 + 259 + df = df0 - df1; 260 + } else { 261 + df = f * (nint) / pp[0]; 262 + } 263 + 264 + df_quotient = df / m; 265 + df_remainder = ((df % m) * 1000) / m; 266 + 267 + if (freq > df_quotient) { 268 + df_quotient = freq - df_quotient - 1; 269 + df_remainder = 1000 - df_remainder; 270 + } else { 271 + df_quotient = df_quotient - freq; 272 + } 273 + 274 + if (df_quotient_min > df_quotient || 275 + (df_quotient_min == df_quotient && 276 + df_remainder_min > df_remainder)) { 277 + /* found a closer freq, save parameters */ 278 + clk->p[SEL_FRA] = 1; 279 + clk->p[SDM_MOD] = sdm; 280 + clk->p[PH_SEL] = ph; 281 + clk->p[NFRA] = nfra; 282 + clk->p[DIVR] = r; 283 + clk->p[DIVM] = m; 284 + 285 + fout = df / m; 286 + df_quotient_min = df_quotient; 287 + df_remainder_min = df_remainder; 288 + } 289 + } 290 + } 291 + } 292 + 293 + if (!fout) { 294 + pr_err("%s: %s freq:%lu not found a valid setting\n", 295 + __func__, clk_hw_get_name(&clk->hw), freq); 296 + return -EINVAL; 297 + } 298 + 299 + return fout; 300 + } 301 + 302 + static long plltv_div(struct sp_pll *clk, unsigned long freq) 303 + { 304 + if (freq % 100) 305 + return plltv_fractional_div(clk, freq); 306 + 307 + return plltv_integer_div(clk, freq); 308 + } 309 + 310 + static int plltv_set_rate(struct sp_pll *clk) 311 + { 312 + unsigned long flags; 313 + u32 r0, r1, r2; 314 + 315 + r0 = BIT(clk->bp_bit + 16); 316 + r0 |= HWM_FIELD_PREP(MASK_SEL_FRA, clk->p[SEL_FRA]); 317 + r0 |= HWM_FIELD_PREP(MASK_SDM_MOD, clk->p[SDM_MOD]); 318 + r0 |= HWM_FIELD_PREP(MASK_PH_SEL, clk->p[PH_SEL]); 319 + r0 |= HWM_FIELD_PREP(MASK_NFRA, clk->p[NFRA]); 320 + 321 + r1 = HWM_FIELD_PREP(MASK_DIVR, clk->p[DIVR]); 322 + 323 + r2 = HWM_FIELD_PREP(MASK_DIVN, clk->p[DIVN] - 1); 324 + r2 |= HWM_FIELD_PREP(MASK_DIVM, clk->p[DIVM] - 1); 325 + 326 + spin_lock_irqsave(&clk->lock, flags); 327 + writel(r0, clk->reg); 328 + writel(r1, clk->reg + 4); 329 + writel(r2, clk->reg + 8); 330 + spin_unlock_irqrestore(&clk->lock, flags); 331 + 332 + return 0; 333 + } 334 + 335 + /*********************************** PLL_A ***********************************/ 336 + 337 + /* from Q628_PLLs_REG_setting.xlsx */ 338 + static const struct { 339 + u32 rate; 340 + u32 regs[5]; 341 + } pa[] = { 342 + { 343 + .rate = 135475200, 344 + .regs = { 345 + 0x4801, 346 + 0x02df, 347 + 0x248f, 348 + 0x0211, 349 + 0x33e9 350 + } 351 + }, 352 + { 353 + .rate = 147456000, 354 + .regs = { 355 + 0x4801, 356 + 0x1adf, 357 + 0x2490, 358 + 0x0349, 359 + 0x33e9 360 + } 361 + }, 362 + { 363 + .rate = 196608000, 364 + .regs = { 365 + 0x4801, 366 + 0x42ef, 367 + 0x2495, 368 + 0x01c6, 369 + 0x33e9 370 + } 371 + }, 372 + }; 373 + 374 + static int plla_set_rate(struct sp_pll *clk) 375 + { 376 + const u32 *pp = pa[clk->p[0]].regs; 377 + unsigned long flags; 378 + int i; 379 + 380 + spin_lock_irqsave(&clk->lock, flags); 381 + for (i = 0; i < ARRAY_SIZE(pa->regs); i++) 382 + writel(0xffff0000 | pp[i], clk->reg + (i * 4)); 383 + spin_unlock_irqrestore(&clk->lock, flags); 384 + 385 + return 0; 386 + } 387 + 388 + static long plla_round_rate(struct sp_pll *clk, unsigned long rate) 389 + { 390 + int i = ARRAY_SIZE(pa); 391 + 392 + while (--i) { 393 + if (rate >= pa[i].rate) 394 + break; 395 + } 396 + clk->p[0] = i; 397 + 398 + return pa[i].rate; 399 + } 400 + 401 + /********************************** SP_PLL ***********************************/ 402 + 403 + static long sp_pll_calc_div(struct sp_pll *clk, unsigned long rate) 404 + { 405 + u32 fbdiv; 406 + u32 max = 1 << clk->div_width; 407 + 408 + fbdiv = DIV_ROUND_CLOSEST(rate, clk->brate); 409 + if (fbdiv > max) 410 + fbdiv = max; 411 + 412 + return fbdiv; 413 + } 414 + 415 + static long sp_pll_round_rate(struct clk_hw *hw, unsigned long rate, 416 + unsigned long *prate) 417 + { 418 + struct sp_pll *clk = to_sp_pll(hw); 419 + long ret; 420 + 421 + if (rate == *prate) { 422 + ret = *prate; /* bypass */ 423 + } else if (clk->div_width == DIV_A) { 424 + ret = plla_round_rate(clk, rate); 425 + } else if (clk->div_width == DIV_TV) { 426 + ret = plltv_div(clk, rate); 427 + if (ret < 0) 428 + ret = *prate; 429 + } else { 430 + ret = sp_pll_calc_div(clk, rate) * clk->brate; 431 + } 432 + 433 + return ret; 434 + } 435 + 436 + static unsigned long sp_pll_recalc_rate(struct clk_hw *hw, 437 + unsigned long prate) 438 + { 439 + struct sp_pll *clk = to_sp_pll(hw); 440 + u32 reg = readl(clk->reg); 441 + unsigned long ret; 442 + 443 + if (reg & BIT(clk->bp_bit)) { 444 + ret = prate; /* bypass */ 445 + } else if (clk->div_width == DIV_A) { 446 + ret = pa[clk->p[0]].rate; 447 + } else if (clk->div_width == DIV_TV) { 448 + u32 m, r, reg2; 449 + 450 + r = FIELD_GET(MASK_DIVR, readl(clk->reg + 4)); 451 + reg2 = readl(clk->reg + 8); 452 + m = FIELD_GET(MASK_DIVM, reg2) + 1; 453 + 454 + if (reg & MASK_SEL_FRA) { 455 + /* fractional divider */ 456 + u32 sdm = FIELD_GET(MASK_SDM_MOD, reg); 457 + u32 ph = FIELD_GET(MASK_PH_SEL, reg); 458 + u32 nfra = FIELD_GET(MASK_NFRA, reg); 459 + const u32 *pp = pt[ph]; 460 + unsigned long r0, r1; 461 + 462 + ret = prate >> r; 463 + r0 = ret * (pp[1] + pp[2]) / pp[0]; 464 + r1 = ret * (sdm_mod_vals[sdm] - nfra) / sdm_mod_vals[sdm] / pp[4]; 465 + ret = (r0 - r1) / m; 466 + } else { 467 + /* integer divider */ 468 + u32 n = FIELD_GET(MASK_DIVN, reg2) + 1; 469 + 470 + ret = (prate / m * n) >> r; 471 + } 472 + } else { 473 + u32 fbdiv = ((reg >> clk->div_shift) & ((1 << clk->div_width) - 1)) + 1; 474 + 475 + ret = clk->brate * fbdiv; 476 + } 477 + 478 + return ret; 479 + } 480 + 481 + static int sp_pll_set_rate(struct clk_hw *hw, unsigned long rate, 482 + unsigned long prate) 483 + { 484 + struct sp_pll *clk = to_sp_pll(hw); 485 + unsigned long flags; 486 + u32 reg; 487 + 488 + reg = BIT(clk->bp_bit + 16); /* HIWORD_MASK */ 489 + 490 + if (rate == prate) { 491 + reg |= BIT(clk->bp_bit); /* bypass */ 492 + } else if (clk->div_width == DIV_A) { 493 + return plla_set_rate(clk); 494 + } else if (clk->div_width == DIV_TV) { 495 + return plltv_set_rate(clk); 496 + } else if (clk->div_width) { 497 + u32 fbdiv = sp_pll_calc_div(clk, rate); 498 + u32 mask = GENMASK(clk->div_shift + clk->div_width - 1, clk->div_shift); 499 + 500 + reg |= mask << 16; 501 + reg |= ((fbdiv - 1) << clk->div_shift) & mask; 502 + } 503 + 504 + spin_lock_irqsave(&clk->lock, flags); 505 + writel(reg, clk->reg); 506 + spin_unlock_irqrestore(&clk->lock, flags); 507 + 508 + return 0; 509 + } 510 + 511 + static int sp_pll_enable(struct clk_hw *hw) 512 + { 513 + struct sp_pll *clk = to_sp_pll(hw); 514 + 515 + writel(BIT(clk->pd_bit + 16) | BIT(clk->pd_bit), clk->reg); 516 + 517 + return 0; 518 + } 519 + 520 + static void sp_pll_disable(struct clk_hw *hw) 521 + { 522 + struct sp_pll *clk = to_sp_pll(hw); 523 + 524 + writel(BIT(clk->pd_bit + 16), clk->reg); 525 + } 526 + 527 + static int sp_pll_is_enabled(struct clk_hw *hw) 528 + { 529 + struct sp_pll *clk = to_sp_pll(hw); 530 + 531 + return readl(clk->reg) & BIT(clk->pd_bit); 532 + } 533 + 534 + static const struct clk_ops sp_pll_ops = { 535 + .enable = sp_pll_enable, 536 + .disable = sp_pll_disable, 537 + .is_enabled = sp_pll_is_enabled, 538 + .round_rate = sp_pll_round_rate, 539 + .recalc_rate = sp_pll_recalc_rate, 540 + .set_rate = sp_pll_set_rate 541 + }; 542 + 543 + static const struct clk_ops sp_pll_sub_ops = { 544 + .enable = sp_pll_enable, 545 + .disable = sp_pll_disable, 546 + .is_enabled = sp_pll_is_enabled, 547 + .recalc_rate = sp_pll_recalc_rate, 548 + }; 549 + 550 + static struct clk_hw *sp_pll_register(struct device *dev, const char *name, 551 + const struct clk_parent_data *parent_data, 552 + void __iomem *reg, int pd_bit, int bp_bit, 553 + unsigned long brate, int shift, int width, 554 + unsigned long flags) 555 + { 556 + struct sp_pll *pll; 557 + struct clk_hw *hw; 558 + struct clk_init_data initd = { 559 + .name = name, 560 + .parent_data = parent_data, 561 + .ops = (bp_bit >= 0) ? &sp_pll_ops : &sp_pll_sub_ops, 562 + .num_parents = 1, 563 + .flags = flags, 564 + }; 565 + int ret; 566 + 567 + pll = devm_kzalloc(dev, sizeof(*pll), GFP_KERNEL); 568 + if (!pll) 569 + return ERR_PTR(-ENOMEM); 570 + 571 + pll->hw.init = &initd; 572 + pll->reg = reg; 573 + pll->pd_bit = pd_bit; 574 + pll->bp_bit = bp_bit; 575 + pll->brate = brate; 576 + pll->div_shift = shift; 577 + pll->div_width = width; 578 + spin_lock_init(&pll->lock); 579 + 580 + hw = &pll->hw; 581 + ret = devm_clk_hw_register(dev, hw); 582 + if (ret) 583 + return ERR_PTR(ret); 584 + 585 + return hw; 586 + } 587 + 588 + #define PLLA_CTL (pll_base + 0x1c) 589 + #define PLLE_CTL (pll_base + 0x30) 590 + #define PLLF_CTL (pll_base + 0x34) 591 + #define PLLTV_CTL (pll_base + 0x38) 592 + 593 + static int sp7021_clk_probe(struct platform_device *pdev) 594 + { 595 + static const u32 sp_clken[] = { 596 + 0x67ef, 0x03ff, 0xff03, 0xfff0, 0x0004, /* G0.1~5 */ 597 + 0x0000, 0x8000, 0xffff, 0x0040, 0x0000, /* G0.6~10 */ 598 + }; 599 + static struct clk_parent_data pd_ext, pd_sys, pd_e; 600 + struct device *dev = &pdev->dev; 601 + void __iomem *clk_base, *pll_base, *sys_base; 602 + struct clk_hw_onecell_data *clk_data; 603 + struct clk_hw **hws; 604 + int i; 605 + 606 + clk_base = devm_platform_ioremap_resource(pdev, 0); 607 + if (!clk_base) 608 + return -ENXIO; 609 + pll_base = devm_platform_ioremap_resource(pdev, 1); 610 + if (!pll_base) 611 + return -ENXIO; 612 + sys_base = devm_platform_ioremap_resource(pdev, 2); 613 + if (!sys_base) 614 + return -ENXIO; 615 + 616 + /* enable default clks */ 617 + for (i = 0; i < ARRAY_SIZE(sp_clken); i++) 618 + writel((sp_clken[i] << 16) | sp_clken[i], clk_base + i * 4); 619 + 620 + clk_data = devm_kzalloc(dev, struct_size(clk_data, hws, CLK_MAX), 621 + GFP_KERNEL); 622 + if (!clk_data) 623 + return -ENOMEM; 624 + 625 + hws = clk_data->hws; 626 + pd_ext.index = 0; 627 + 628 + /* PLLs */ 629 + hws[PLL_A] = sp_pll_register(dev, "plla", &pd_ext, PLLA_CTL, 630 + 11, 12, 27000000, 0, DIV_A, 0); 631 + if (IS_ERR(hws[PLL_A])) 632 + return PTR_ERR(hws[PLL_A]); 633 + 634 + hws[PLL_E] = sp_pll_register(dev, "plle", &pd_ext, PLLE_CTL, 635 + 6, 2, 50000000, 0, 0, 0); 636 + if (IS_ERR(hws[PLL_E])) 637 + return PTR_ERR(hws[PLL_E]); 638 + pd_e.hw = hws[PLL_E]; 639 + hws[PLL_E_2P5] = sp_pll_register(dev, "plle_2p5", &pd_e, PLLE_CTL, 640 + 13, -1, 2500000, 0, 0, 0); 641 + if (IS_ERR(hws[PLL_E_2P5])) 642 + return PTR_ERR(hws[PLL_E_2P5]); 643 + hws[PLL_E_25] = sp_pll_register(dev, "plle_25", &pd_e, PLLE_CTL, 644 + 12, -1, 25000000, 0, 0, 0); 645 + if (IS_ERR(hws[PLL_E_25])) 646 + return PTR_ERR(hws[PLL_E_25]); 647 + hws[PLL_E_112P5] = sp_pll_register(dev, "plle_112p5", &pd_e, PLLE_CTL, 648 + 11, -1, 112500000, 0, 0, 0); 649 + if (IS_ERR(hws[PLL_E_112P5])) 650 + return PTR_ERR(hws[PLL_E_112P5]); 651 + 652 + hws[PLL_F] = sp_pll_register(dev, "pllf", &pd_ext, PLLF_CTL, 653 + 0, 10, 13500000, 1, 4, 0); 654 + if (IS_ERR(hws[PLL_F])) 655 + return PTR_ERR(hws[PLL_F]); 656 + 657 + hws[PLL_TV] = sp_pll_register(dev, "plltv", &pd_ext, PLLTV_CTL, 658 + 0, 15, 27000000, 0, DIV_TV, 0); 659 + if (IS_ERR(hws[PLL_TV])) 660 + return PTR_ERR(hws[PLL_TV]); 661 + hws[PLL_TV_A] = devm_clk_hw_register_divider(dev, "plltv_a", "plltv", 0, 662 + PLLTV_CTL + 4, 5, 1, 663 + CLK_DIVIDER_POWER_OF_TWO, 664 + &to_sp_pll(hws[PLL_TV])->lock); 665 + if (IS_ERR(hws[PLL_TV_A])) 666 + return PTR_ERR(hws[PLL_TV_A]); 667 + 668 + /* system clock, should not be disabled */ 669 + hws[PLL_SYS] = sp_pll_register(dev, "pllsys", &pd_ext, sys_base, 670 + 10, 9, 13500000, 0, 4, CLK_IS_CRITICAL); 671 + if (IS_ERR(hws[PLL_SYS])) 672 + return PTR_ERR(hws[PLL_SYS]); 673 + pd_sys.hw = hws[PLL_SYS]; 674 + 675 + /* gates */ 676 + for (i = 0; i < ARRAY_SIZE(sp_clk_gates); i++) { 677 + char name[10]; 678 + u32 j = sp_clk_gates[i].reg; 679 + struct clk_parent_data *pd = sp_clk_gates[i].ext_parent ? &pd_ext : &pd_sys; 680 + 681 + sprintf(name, "%02d_0x%02x", i, j); 682 + hws[i] = devm_clk_hw_register_gate_parent_data(dev, name, pd, 0, 683 + clk_base + (j >> 4) * 4, 684 + j & 0x0f, 685 + CLK_GATE_HIWORD_MASK, 686 + NULL); 687 + if (IS_ERR(hws[i])) 688 + return PTR_ERR(hws[i]); 689 + } 690 + 691 + clk_data->num = CLK_MAX; 692 + 693 + return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_data); 694 + } 695 + 696 + static const struct of_device_id sp7021_clk_dt_ids[] = { 697 + { .compatible = "sunplus,sp7021-clkc" }, 698 + { } 699 + }; 700 + MODULE_DEVICE_TABLE(of, sp7021_clk_dt_ids); 701 + 702 + static struct platform_driver sp7021_clk_driver = { 703 + .probe = sp7021_clk_probe, 704 + .driver = { 705 + .name = "sp7021-clk", 706 + .of_match_table = sp7021_clk_dt_ids, 707 + }, 708 + }; 709 + module_platform_driver(sp7021_clk_driver); 710 + 711 + MODULE_AUTHOR("Sunplus Technology"); 712 + MODULE_LICENSE("GPL"); 713 + MODULE_DESCRIPTION("Clock driver for Sunplus SP7021 SoC");
-4
drivers/clk/loongson1/Makefile
··· 1 - # SPDX-License-Identifier: GPL-2.0-only 2 - obj-y += clk.o 3 - obj-$(CONFIG_LOONGSON1_LS1B) += clk-loongson1b.o 4 - obj-$(CONFIG_LOONGSON1_LS1C) += clk-loongson1c.o
-118
drivers/clk/loongson1/clk-loongson1b.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-or-later 2 - /* 3 - * Copyright (c) 2012-2016 Zhang, Keguang <keguang.zhang@gmail.com> 4 - */ 5 - 6 - #include <linux/clkdev.h> 7 - #include <linux/clk-provider.h> 8 - #include <linux/io.h> 9 - #include <linux/err.h> 10 - 11 - #include <loongson1.h> 12 - #include "clk.h" 13 - 14 - #define OSC (33 * 1000000) 15 - #define DIV_APB 2 16 - 17 - static DEFINE_SPINLOCK(_lock); 18 - 19 - static unsigned long ls1x_pll_recalc_rate(struct clk_hw *hw, 20 - unsigned long parent_rate) 21 - { 22 - u32 pll, rate; 23 - 24 - pll = __raw_readl(LS1X_CLK_PLL_FREQ); 25 - rate = 12 + (pll & GENMASK(5, 0)); 26 - rate *= OSC; 27 - rate >>= 1; 28 - 29 - return rate; 30 - } 31 - 32 - static const struct clk_ops ls1x_pll_clk_ops = { 33 - .recalc_rate = ls1x_pll_recalc_rate, 34 - }; 35 - 36 - static const char *const cpu_parents[] = { "cpu_clk_div", "osc_clk", }; 37 - static const char *const ahb_parents[] = { "ahb_clk_div", "osc_clk", }; 38 - static const char *const dc_parents[] = { "dc_clk_div", "osc_clk", }; 39 - 40 - void __init ls1x_clk_init(void) 41 - { 42 - struct clk_hw *hw; 43 - 44 - hw = clk_hw_register_fixed_rate(NULL, "osc_clk", NULL, 0, OSC); 45 - clk_hw_register_clkdev(hw, "osc_clk", NULL); 46 - 47 - /* clock derived from 33 MHz OSC clk */ 48 - hw = clk_hw_register_pll(NULL, "pll_clk", "osc_clk", 49 - &ls1x_pll_clk_ops, 0); 50 - clk_hw_register_clkdev(hw, "pll_clk", NULL); 51 - 52 - /* clock derived from PLL clk */ 53 - /* _____ 54 - * _______________________| | 55 - * OSC ___/ | MUX |___ CPU CLK 56 - * \___ PLL ___ CPU DIV ___| | 57 - * |_____| 58 - */ 59 - hw = clk_hw_register_divider(NULL, "cpu_clk_div", "pll_clk", 60 - CLK_GET_RATE_NOCACHE, LS1X_CLK_PLL_DIV, 61 - DIV_CPU_SHIFT, DIV_CPU_WIDTH, 62 - CLK_DIVIDER_ONE_BASED | 63 - CLK_DIVIDER_ROUND_CLOSEST, &_lock); 64 - clk_hw_register_clkdev(hw, "cpu_clk_div", NULL); 65 - hw = clk_hw_register_mux(NULL, "cpu_clk", cpu_parents, 66 - ARRAY_SIZE(cpu_parents), 67 - CLK_SET_RATE_NO_REPARENT, LS1X_CLK_PLL_DIV, 68 - BYPASS_CPU_SHIFT, BYPASS_CPU_WIDTH, 0, &_lock); 69 - clk_hw_register_clkdev(hw, "cpu_clk", NULL); 70 - 71 - /* _____ 72 - * _______________________| | 73 - * OSC ___/ | MUX |___ DC CLK 74 - * \___ PLL ___ DC DIV ___| | 75 - * |_____| 76 - */ 77 - hw = clk_hw_register_divider(NULL, "dc_clk_div", "pll_clk", 78 - 0, LS1X_CLK_PLL_DIV, DIV_DC_SHIFT, 79 - DIV_DC_WIDTH, CLK_DIVIDER_ONE_BASED, &_lock); 80 - clk_hw_register_clkdev(hw, "dc_clk_div", NULL); 81 - hw = clk_hw_register_mux(NULL, "dc_clk", dc_parents, 82 - ARRAY_SIZE(dc_parents), 83 - CLK_SET_RATE_NO_REPARENT, LS1X_CLK_PLL_DIV, 84 - BYPASS_DC_SHIFT, BYPASS_DC_WIDTH, 0, &_lock); 85 - clk_hw_register_clkdev(hw, "dc_clk", NULL); 86 - 87 - /* _____ 88 - * _______________________| | 89 - * OSC ___/ | MUX |___ DDR CLK 90 - * \___ PLL ___ DDR DIV ___| | 91 - * |_____| 92 - */ 93 - hw = clk_hw_register_divider(NULL, "ahb_clk_div", "pll_clk", 94 - 0, LS1X_CLK_PLL_DIV, DIV_DDR_SHIFT, 95 - DIV_DDR_WIDTH, CLK_DIVIDER_ONE_BASED, 96 - &_lock); 97 - clk_hw_register_clkdev(hw, "ahb_clk_div", NULL); 98 - hw = clk_hw_register_mux(NULL, "ahb_clk", ahb_parents, 99 - ARRAY_SIZE(ahb_parents), 100 - CLK_SET_RATE_NO_REPARENT, LS1X_CLK_PLL_DIV, 101 - BYPASS_DDR_SHIFT, BYPASS_DDR_WIDTH, 0, &_lock); 102 - clk_hw_register_clkdev(hw, "ahb_clk", NULL); 103 - clk_hw_register_clkdev(hw, "ls1x-dma", NULL); 104 - clk_hw_register_clkdev(hw, "stmmaceth", NULL); 105 - 106 - /* clock derived from AHB clk */ 107 - /* APB clk is always half of the AHB clk */ 108 - hw = clk_hw_register_fixed_factor(NULL, "apb_clk", "ahb_clk", 0, 1, 109 - DIV_APB); 110 - clk_hw_register_clkdev(hw, "apb_clk", NULL); 111 - clk_hw_register_clkdev(hw, "ls1x-ac97", NULL); 112 - clk_hw_register_clkdev(hw, "ls1x-i2c", NULL); 113 - clk_hw_register_clkdev(hw, "ls1x-nand", NULL); 114 - clk_hw_register_clkdev(hw, "ls1x-pwmtimer", NULL); 115 - clk_hw_register_clkdev(hw, "ls1x-spi", NULL); 116 - clk_hw_register_clkdev(hw, "ls1x-wdt", NULL); 117 - clk_hw_register_clkdev(hw, "serial8250", NULL); 118 - }
-95
drivers/clk/loongson1/clk-loongson1c.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-or-later 2 - /* 3 - * Copyright (c) 2016 Yang Ling <gnaygnil@gmail.com> 4 - */ 5 - 6 - #include <linux/clkdev.h> 7 - #include <linux/clk-provider.h> 8 - #include <linux/io.h> 9 - 10 - #include <loongson1.h> 11 - #include "clk.h" 12 - 13 - #define OSC (24 * 1000000) 14 - #define DIV_APB 1 15 - 16 - static DEFINE_SPINLOCK(_lock); 17 - 18 - static unsigned long ls1x_pll_recalc_rate(struct clk_hw *hw, 19 - unsigned long parent_rate) 20 - { 21 - u32 pll, rate; 22 - 23 - pll = __raw_readl(LS1X_CLK_PLL_FREQ); 24 - rate = ((pll >> 8) & 0xff) + ((pll >> 16) & 0xff); 25 - rate *= OSC; 26 - rate >>= 2; 27 - 28 - return rate; 29 - } 30 - 31 - static const struct clk_ops ls1x_pll_clk_ops = { 32 - .recalc_rate = ls1x_pll_recalc_rate, 33 - }; 34 - 35 - static const struct clk_div_table ahb_div_table[] = { 36 - [0] = { .val = 0, .div = 2 }, 37 - [1] = { .val = 1, .div = 4 }, 38 - [2] = { .val = 2, .div = 3 }, 39 - [3] = { .val = 3, .div = 3 }, 40 - [4] = { /* sentinel */ } 41 - }; 42 - 43 - void __init ls1x_clk_init(void) 44 - { 45 - struct clk_hw *hw; 46 - 47 - hw = clk_hw_register_fixed_rate(NULL, "osc_clk", NULL, 0, OSC); 48 - clk_hw_register_clkdev(hw, "osc_clk", NULL); 49 - 50 - /* clock derived from 24 MHz OSC clk */ 51 - hw = clk_hw_register_pll(NULL, "pll_clk", "osc_clk", 52 - &ls1x_pll_clk_ops, 0); 53 - clk_hw_register_clkdev(hw, "pll_clk", NULL); 54 - 55 - hw = clk_hw_register_divider(NULL, "cpu_clk_div", "pll_clk", 56 - CLK_GET_RATE_NOCACHE, LS1X_CLK_PLL_DIV, 57 - DIV_CPU_SHIFT, DIV_CPU_WIDTH, 58 - CLK_DIVIDER_ONE_BASED | 59 - CLK_DIVIDER_ROUND_CLOSEST, &_lock); 60 - clk_hw_register_clkdev(hw, "cpu_clk_div", NULL); 61 - hw = clk_hw_register_fixed_factor(NULL, "cpu_clk", "cpu_clk_div", 62 - 0, 1, 1); 63 - clk_hw_register_clkdev(hw, "cpu_clk", NULL); 64 - 65 - hw = clk_hw_register_divider(NULL, "dc_clk_div", "pll_clk", 66 - 0, LS1X_CLK_PLL_DIV, DIV_DC_SHIFT, 67 - DIV_DC_WIDTH, CLK_DIVIDER_ONE_BASED, &_lock); 68 - clk_hw_register_clkdev(hw, "dc_clk_div", NULL); 69 - hw = clk_hw_register_fixed_factor(NULL, "dc_clk", "dc_clk_div", 70 - 0, 1, 1); 71 - clk_hw_register_clkdev(hw, "dc_clk", NULL); 72 - 73 - hw = clk_hw_register_divider_table(NULL, "ahb_clk_div", "cpu_clk_div", 74 - 0, LS1X_CLK_PLL_FREQ, DIV_DDR_SHIFT, 75 - DIV_DDR_WIDTH, CLK_DIVIDER_ALLOW_ZERO, 76 - ahb_div_table, &_lock); 77 - clk_hw_register_clkdev(hw, "ahb_clk_div", NULL); 78 - hw = clk_hw_register_fixed_factor(NULL, "ahb_clk", "ahb_clk_div", 79 - 0, 1, 1); 80 - clk_hw_register_clkdev(hw, "ahb_clk", NULL); 81 - clk_hw_register_clkdev(hw, "ls1x-dma", NULL); 82 - clk_hw_register_clkdev(hw, "stmmaceth", NULL); 83 - 84 - /* clock derived from AHB clk */ 85 - hw = clk_hw_register_fixed_factor(NULL, "apb_clk", "ahb_clk", 0, 1, 86 - DIV_APB); 87 - clk_hw_register_clkdev(hw, "apb_clk", NULL); 88 - clk_hw_register_clkdev(hw, "ls1x-ac97", NULL); 89 - clk_hw_register_clkdev(hw, "ls1x-i2c", NULL); 90 - clk_hw_register_clkdev(hw, "ls1x-nand", NULL); 91 - clk_hw_register_clkdev(hw, "ls1x-pwmtimer", NULL); 92 - clk_hw_register_clkdev(hw, "ls1x-spi", NULL); 93 - clk_hw_register_clkdev(hw, "ls1x-wdt", NULL); 94 - clk_hw_register_clkdev(hw, "serial8250", NULL); 95 - }
-41
drivers/clk/loongson1/clk.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-or-later 2 - /* 3 - * Copyright (c) 2012-2016 Zhang, Keguang <keguang.zhang@gmail.com> 4 - */ 5 - 6 - #include <linux/clk-provider.h> 7 - #include <linux/slab.h> 8 - 9 - #include "clk.h" 10 - 11 - struct clk_hw *__init clk_hw_register_pll(struct device *dev, 12 - const char *name, 13 - const char *parent_name, 14 - const struct clk_ops *ops, 15 - unsigned long flags) 16 - { 17 - int ret; 18 - struct clk_hw *hw; 19 - struct clk_init_data init; 20 - 21 - /* allocate the divider */ 22 - hw = kzalloc(sizeof(*hw), GFP_KERNEL); 23 - if (!hw) 24 - return ERR_PTR(-ENOMEM); 25 - 26 - init.name = name; 27 - init.ops = ops; 28 - init.flags = flags; 29 - init.parent_names = parent_name ? &parent_name : NULL; 30 - init.num_parents = parent_name ? 1 : 0; 31 - hw->init = &init; 32 - 33 - /* register the clock */ 34 - ret = clk_hw_register(dev, hw); 35 - if (ret) { 36 - kfree(hw); 37 - hw = ERR_PTR(ret); 38 - } 39 - 40 - return hw; 41 - }
-15
drivers/clk/loongson1/clk.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 - /* 3 - * Copyright (c) 2012-2016 Zhang, Keguang <keguang.zhang@gmail.com> 4 - */ 5 - 6 - #ifndef __LOONGSON1_CLK_H 7 - #define __LOONGSON1_CLK_H 8 - 9 - struct clk_hw *clk_hw_register_pll(struct device *dev, 10 - const char *name, 11 - const char *parent_name, 12 - const struct clk_ops *ops, 13 - unsigned long flags); 14 - 15 - #endif /* __LOONGSON1_CLK_H */
+334 -67
drivers/clk/mediatek/Kconfig
··· 75 75 This driver supports MediaTek MT2701 g3dsys clocks. 76 76 77 77 config COMMON_CLK_MT2712 78 - bool "Clock driver for MediaTek MT2712" 78 + tristate "Clock driver for MediaTek MT2712" 79 79 depends on (ARCH_MEDIATEK && ARM64) || COMPILE_TEST 80 80 select COMMON_CLK_MEDIATEK 81 81 default ARCH_MEDIATEK && ARM64 ··· 83 83 This driver supports MediaTek MT2712 basic clocks. 84 84 85 85 config COMMON_CLK_MT2712_BDPSYS 86 - bool "Clock driver for MediaTek MT2712 bdpsys" 86 + tristate "Clock driver for MediaTek MT2712 bdpsys" 87 87 depends on COMMON_CLK_MT2712 88 88 help 89 89 This driver supports MediaTek MT2712 bdpsys clocks. 90 90 91 91 config COMMON_CLK_MT2712_IMGSYS 92 - bool "Clock driver for MediaTek MT2712 imgsys" 92 + tristate "Clock driver for MediaTek MT2712 imgsys" 93 93 depends on COMMON_CLK_MT2712 94 94 help 95 95 This driver supports MediaTek MT2712 imgsys clocks. 96 96 97 97 config COMMON_CLK_MT2712_JPGDECSYS 98 - bool "Clock driver for MediaTek MT2712 jpgdecsys" 98 + tristate "Clock driver for MediaTek MT2712 jpgdecsys" 99 99 depends on COMMON_CLK_MT2712 100 100 help 101 101 This driver supports MediaTek MT2712 jpgdecsys clocks. 102 102 103 103 config COMMON_CLK_MT2712_MFGCFG 104 - bool "Clock driver for MediaTek MT2712 mfgcfg" 104 + tristate "Clock driver for MediaTek MT2712 mfgcfg" 105 105 depends on COMMON_CLK_MT2712 106 106 help 107 107 This driver supports MediaTek MT2712 mfgcfg clocks. 108 108 109 109 config COMMON_CLK_MT2712_MMSYS 110 - bool "Clock driver for MediaTek MT2712 mmsys" 110 + tristate "Clock driver for MediaTek MT2712 mmsys" 111 111 depends on COMMON_CLK_MT2712 112 112 help 113 113 This driver supports MediaTek MT2712 mmsys clocks. 114 114 115 115 config COMMON_CLK_MT2712_VDECSYS 116 - bool "Clock driver for MediaTek MT2712 vdecsys" 116 + tristate "Clock driver for MediaTek MT2712 vdecsys" 117 117 depends on COMMON_CLK_MT2712 118 118 help 119 119 This driver supports MediaTek MT2712 vdecsys clocks. 120 120 121 121 config COMMON_CLK_MT2712_VENCSYS 122 - bool "Clock driver for MediaTek MT2712 vencsys" 122 + tristate "Clock driver for MediaTek MT2712 vencsys" 123 123 depends on COMMON_CLK_MT2712 124 124 help 125 125 This driver supports MediaTek MT2712 vencsys clocks. ··· 133 133 This driver supports MediaTek MT6765 basic clocks. 134 134 135 135 config COMMON_CLK_MT6765_AUDIOSYS 136 - bool "Clock driver for MediaTek MT6765 audiosys" 136 + tristate "Clock driver for MediaTek MT6765 audiosys" 137 137 depends on COMMON_CLK_MT6765 138 138 help 139 139 This driver supports MediaTek MT6765 audiosys clocks. 140 140 141 141 config COMMON_CLK_MT6765_CAMSYS 142 - bool "Clock driver for MediaTek MT6765 camsys" 142 + tristate "Clock driver for MediaTek MT6765 camsys" 143 143 depends on COMMON_CLK_MT6765 144 144 help 145 145 This driver supports MediaTek MT6765 camsys clocks. 146 146 147 147 config COMMON_CLK_MT6765_GCESYS 148 - bool "Clock driver for MediaTek MT6765 gcesys" 148 + tristate "Clock driver for MediaTek MT6765 gcesys" 149 149 depends on COMMON_CLK_MT6765 150 150 help 151 151 This driver supports MediaTek MT6765 gcesys clocks. 152 152 153 153 config COMMON_CLK_MT6765_MMSYS 154 - bool "Clock driver for MediaTek MT6765 mmsys" 154 + tristate "Clock driver for MediaTek MT6765 mmsys" 155 155 depends on COMMON_CLK_MT6765 156 156 help 157 157 This driver supports MediaTek MT6765 mmsys clocks. 158 158 159 159 config COMMON_CLK_MT6765_IMGSYS 160 - bool "Clock driver for MediaTek MT6765 imgsys" 160 + tristate "Clock driver for MediaTek MT6765 imgsys" 161 161 depends on COMMON_CLK_MT6765 162 162 help 163 163 This driver supports MediaTek MT6765 imgsys clocks. 164 164 165 165 config COMMON_CLK_MT6765_VCODECSYS 166 - bool "Clock driver for MediaTek MT6765 vcodecsys" 166 + tristate "Clock driver for MediaTek MT6765 vcodecsys" 167 167 depends on COMMON_CLK_MT6765 168 168 help 169 169 This driver supports MediaTek MT6765 vcodecsys clocks. 170 170 171 171 config COMMON_CLK_MT6765_MFGSYS 172 - bool "Clock driver for MediaTek MT6765 mfgsys" 172 + tristate "Clock driver for MediaTek MT6765 mfgsys" 173 173 depends on COMMON_CLK_MT6765 174 174 help 175 175 This driver supports MediaTek MT6765 mfgsys clocks. 176 176 177 177 config COMMON_CLK_MT6765_MIPI0ASYS 178 - bool "Clock driver for MediaTek MT6765 mipi0asys" 178 + tristate "Clock driver for MediaTek MT6765 mipi0asys" 179 179 depends on COMMON_CLK_MT6765 180 180 help 181 181 This driver supports MediaTek MT6765 mipi0asys clocks. 182 182 183 183 config COMMON_CLK_MT6765_MIPI0BSYS 184 - bool "Clock driver for MediaTek MT6765 mipi0bsys" 184 + tristate "Clock driver for MediaTek MT6765 mipi0bsys" 185 185 depends on COMMON_CLK_MT6765 186 186 help 187 187 This driver supports MediaTek MT6765 mipi0bsys clocks. 188 188 189 189 config COMMON_CLK_MT6765_MIPI1ASYS 190 - bool "Clock driver for MediaTek MT6765 mipi1asys" 190 + tristate "Clock driver for MediaTek MT6765 mipi1asys" 191 191 depends on COMMON_CLK_MT6765 192 192 help 193 193 This driver supports MediaTek MT6765 mipi1asys clocks. 194 194 195 195 config COMMON_CLK_MT6765_MIPI1BSYS 196 - bool "Clock driver for MediaTek MT6765 mipi1bsys" 196 + tristate "Clock driver for MediaTek MT6765 mipi1bsys" 197 197 depends on COMMON_CLK_MT6765 198 198 help 199 199 This driver supports MediaTek MT6765 mipi1bsys clocks. 200 200 201 201 config COMMON_CLK_MT6765_MIPI2ASYS 202 - bool "Clock driver for MediaTek MT6765 mipi2asys" 202 + tristate "Clock driver for MediaTek MT6765 mipi2asys" 203 203 depends on COMMON_CLK_MT6765 204 204 help 205 205 This driver supports MediaTek MT6765 mipi2asys clocks. 206 206 207 207 config COMMON_CLK_MT6765_MIPI2BSYS 208 - bool "Clock driver for MediaTek MT6765 mipi2bsys" 208 + tristate "Clock driver for MediaTek MT6765 mipi2bsys" 209 209 depends on COMMON_CLK_MT6765 210 210 help 211 211 This driver supports MediaTek MT6765 mipi2bsys clocks. ··· 270 270 tristate "Clock driver for MediaTek MT6795" 271 271 depends on ARCH_MEDIATEK || COMPILE_TEST 272 272 select COMMON_CLK_MEDIATEK 273 + select COMMON_CLK_MEDIATEK_FHCTL 273 274 default ARCH_MEDIATEK 274 275 help 275 276 This driver supports MediaTek MT6795 basic clocks and clocks ··· 313 312 This driver supports MediaTek MT6797 basic clocks. 314 313 315 314 config COMMON_CLK_MT6797_MMSYS 316 - bool "Clock driver for MediaTek MT6797 mmsys" 315 + tristate "Clock driver for MediaTek MT6797 mmsys" 317 316 depends on COMMON_CLK_MT6797 318 317 help 319 318 This driver supports MediaTek MT6797 mmsys clocks. 320 319 321 320 config COMMON_CLK_MT6797_IMGSYS 322 - bool "Clock driver for MediaTek MT6797 imgsys" 321 + tristate "Clock driver for MediaTek MT6797 imgsys" 323 322 depends on COMMON_CLK_MT6797 324 323 help 325 324 This driver supports MediaTek MT6797 imgsys clocks. 326 325 327 326 config COMMON_CLK_MT6797_VDECSYS 328 - bool "Clock driver for MediaTek MT6797 vdecsys" 327 + tristate "Clock driver for MediaTek MT6797 vdecsys" 329 328 depends on COMMON_CLK_MT6797 330 329 help 331 330 This driver supports MediaTek MT6797 vdecsys clocks. 332 331 333 332 config COMMON_CLK_MT6797_VENCSYS 334 - bool "Clock driver for MediaTek MT6797 vencsys" 333 + tristate "Clock driver for MediaTek MT6797 vencsys" 335 334 depends on COMMON_CLK_MT6797 336 335 help 337 336 This driver supports MediaTek MT6797 vencsys clocks. 338 337 339 338 config COMMON_CLK_MT7622 340 - bool "Clock driver for MediaTek MT7622" 339 + tristate "Clock driver for MediaTek MT7622" 341 340 depends on ARCH_MEDIATEK || COMPILE_TEST 342 341 select COMMON_CLK_MEDIATEK 343 342 default ARCH_MEDIATEK ··· 346 345 required for various periperals found on MediaTek. 347 346 348 347 config COMMON_CLK_MT7622_ETHSYS 349 - bool "Clock driver for MediaTek MT7622 ETHSYS" 348 + tristate "Clock driver for MediaTek MT7622 ETHSYS" 350 349 depends on COMMON_CLK_MT7622 351 350 help 352 351 This driver add support for clocks for Ethernet and SGMII 353 352 required on MediaTek MT7622 SoC. 354 353 355 354 config COMMON_CLK_MT7622_HIFSYS 356 - bool "Clock driver for MediaTek MT7622 HIFSYS" 355 + tristate "Clock driver for MediaTek MT7622 HIFSYS" 357 356 depends on COMMON_CLK_MT7622 358 357 help 359 358 This driver supports MediaTek MT7622 HIFSYS clocks providing 360 359 to PCI-E and USB. 361 360 362 361 config COMMON_CLK_MT7622_AUDSYS 363 - bool "Clock driver for MediaTek MT7622 AUDSYS" 362 + tristate "Clock driver for MediaTek MT7622 AUDSYS" 364 363 depends on COMMON_CLK_MT7622 365 364 help 366 365 This driver supports MediaTek MT7622 AUDSYS clocks providing ··· 407 406 required on MediaTek MT7981 SoC. 408 407 409 408 config COMMON_CLK_MT7986 410 - bool "Clock driver for MediaTek MT7986" 409 + tristate "Clock driver for MediaTek MT7986" 411 410 depends on ARCH_MEDIATEK || COMPILE_TEST 412 411 select COMMON_CLK_MEDIATEK 413 412 default ARCH_MEDIATEK ··· 416 415 required for various peripherals found on MediaTek. 417 416 418 417 config COMMON_CLK_MT7986_ETHSYS 419 - bool "Clock driver for MediaTek MT7986 ETHSYS" 418 + tristate "Clock driver for MediaTek MT7986 ETHSYS" 420 419 depends on COMMON_CLK_MT7986 421 420 default COMMON_CLK_MT7986 422 421 help ··· 424 423 required on MediaTek MT7986 SoC. 425 424 426 425 config COMMON_CLK_MT8135 427 - bool "Clock driver for MediaTek MT8135" 426 + tristate "Clock driver for MediaTek MT8135" 428 427 depends on (ARCH_MEDIATEK && ARM) || COMPILE_TEST 429 428 select COMMON_CLK_MEDIATEK 430 429 default ARCH_MEDIATEK && ARM ··· 432 431 This driver supports MediaTek MT8135 clocks. 433 432 434 433 config COMMON_CLK_MT8167 435 - bool "Clock driver for MediaTek MT8167" 434 + tristate "Clock driver for MediaTek MT8167" 436 435 depends on (ARCH_MEDIATEK && ARM64) || COMPILE_TEST 437 436 select COMMON_CLK_MEDIATEK 438 437 default ARCH_MEDIATEK ··· 440 439 This driver supports MediaTek MT8167 basic clocks. 441 440 442 441 config COMMON_CLK_MT8167_AUDSYS 443 - bool "Clock driver for MediaTek MT8167 audsys" 442 + tristate "Clock driver for MediaTek MT8167 audsys" 444 443 depends on COMMON_CLK_MT8167 445 444 default COMMON_CLK_MT8167 446 445 help 447 446 This driver supports MediaTek MT8167 audsys clocks. 448 447 449 448 config COMMON_CLK_MT8167_IMGSYS 450 - bool "Clock driver for MediaTek MT8167 imgsys" 449 + tristate "Clock driver for MediaTek MT8167 imgsys" 451 450 depends on COMMON_CLK_MT8167 452 451 default COMMON_CLK_MT8167 453 452 help 454 453 This driver supports MediaTek MT8167 imgsys clocks. 455 454 456 455 config COMMON_CLK_MT8167_MFGCFG 457 - bool "Clock driver for MediaTek MT8167 mfgcfg" 456 + tristate "Clock driver for MediaTek MT8167 mfgcfg" 458 457 depends on COMMON_CLK_MT8167 459 458 default COMMON_CLK_MT8167 460 459 help 461 460 This driver supports MediaTek MT8167 mfgcfg clocks. 462 461 463 462 config COMMON_CLK_MT8167_MMSYS 464 - bool "Clock driver for MediaTek MT8167 mmsys" 463 + tristate "Clock driver for MediaTek MT8167 mmsys" 465 464 depends on COMMON_CLK_MT8167 466 465 default COMMON_CLK_MT8167 467 466 help 468 467 This driver supports MediaTek MT8167 mmsys clocks. 469 468 470 469 config COMMON_CLK_MT8167_VDECSYS 471 - bool "Clock driver for MediaTek MT8167 vdecsys" 470 + tristate "Clock driver for MediaTek MT8167 vdecsys" 472 471 depends on COMMON_CLK_MT8167 473 472 default COMMON_CLK_MT8167 474 473 help ··· 478 477 tristate "Clock driver for MediaTek MT8173" 479 478 depends on ARM64 || COMPILE_TEST 480 479 select COMMON_CLK_MEDIATEK 480 + select COMMON_CLK_MEDIATEK_FHCTL 481 481 default ARCH_MEDIATEK 482 482 help 483 483 This driver supports MediaTek MT8173 basic clocks and clocks ··· 513 511 This driver supports MediaTek MT8173 vencsys clocks. 514 512 515 513 config COMMON_CLK_MT8183 516 - bool "Clock driver for MediaTek MT8183" 514 + tristate "Clock driver for MediaTek MT8183" 517 515 depends on (ARCH_MEDIATEK && ARM64) || COMPILE_TEST 518 516 select COMMON_CLK_MEDIATEK 519 517 default ARCH_MEDIATEK && ARM64 ··· 521 519 This driver supports MediaTek MT8183 basic clocks. 522 520 523 521 config COMMON_CLK_MT8183_AUDIOSYS 524 - bool "Clock driver for MediaTek MT8183 audiosys" 522 + tristate "Clock driver for MediaTek MT8183 audiosys" 525 523 depends on COMMON_CLK_MT8183 526 524 default COMMON_CLK_MT8183 527 525 help 528 526 This driver supports MediaTek MT8183 audiosys clocks. 529 527 530 528 config COMMON_CLK_MT8183_CAMSYS 531 - bool "Clock driver for MediaTek MT8183 camsys" 529 + tristate "Clock driver for MediaTek MT8183 camsys" 532 530 depends on COMMON_CLK_MT8183 533 531 default COMMON_CLK_MT8183 534 532 help 535 533 This driver supports MediaTek MT8183 camsys clocks. 536 534 537 535 config COMMON_CLK_MT8183_IMGSYS 538 - bool "Clock driver for MediaTek MT8183 imgsys" 536 + tristate "Clock driver for MediaTek MT8183 imgsys" 539 537 depends on COMMON_CLK_MT8183 540 538 default COMMON_CLK_MT8183 541 539 help 542 540 This driver supports MediaTek MT8183 imgsys clocks. 543 541 544 542 config COMMON_CLK_MT8183_IPU_CORE0 545 - bool "Clock driver for MediaTek MT8183 ipu_core0" 543 + tristate "Clock driver for MediaTek MT8183 ipu_core0" 546 544 depends on COMMON_CLK_MT8183 547 545 default COMMON_CLK_MT8183 548 546 help 549 547 This driver supports MediaTek MT8183 ipu_core0 clocks. 550 548 551 549 config COMMON_CLK_MT8183_IPU_CORE1 552 - bool "Clock driver for MediaTek MT8183 ipu_core1" 550 + tristate "Clock driver for MediaTek MT8183 ipu_core1" 553 551 depends on COMMON_CLK_MT8183 554 552 default COMMON_CLK_MT8183 555 553 help 556 554 This driver supports MediaTek MT8183 ipu_core1 clocks. 557 555 558 556 config COMMON_CLK_MT8183_IPU_ADL 559 - bool "Clock driver for MediaTek MT8183 ipu_adl" 557 + tristate "Clock driver for MediaTek MT8183 ipu_adl" 560 558 depends on COMMON_CLK_MT8183 561 559 default COMMON_CLK_MT8183 562 560 help 563 561 This driver supports MediaTek MT8183 ipu_adl clocks. 564 562 565 563 config COMMON_CLK_MT8183_IPU_CONN 566 - bool "Clock driver for MediaTek MT8183 ipu_conn" 564 + tristate "Clock driver for MediaTek MT8183 ipu_conn" 567 565 depends on COMMON_CLK_MT8183 568 566 default COMMON_CLK_MT8183 569 567 help 570 568 This driver supports MediaTek MT8183 ipu_conn clocks. 571 569 572 570 config COMMON_CLK_MT8183_MFGCFG 573 - bool "Clock driver for MediaTek MT8183 mfgcfg" 571 + tristate "Clock driver for MediaTek MT8183 mfgcfg" 574 572 depends on COMMON_CLK_MT8183 575 573 default COMMON_CLK_MT8183 576 574 help 577 575 This driver supports MediaTek MT8183 mfgcfg clocks. 578 576 579 577 config COMMON_CLK_MT8183_MMSYS 580 - bool "Clock driver for MediaTek MT8183 mmsys" 578 + tristate "Clock driver for MediaTek MT8183 mmsys" 581 579 depends on COMMON_CLK_MT8183 582 580 default COMMON_CLK_MT8183 583 581 help 584 582 This driver supports MediaTek MT8183 mmsys clocks. 585 583 586 584 config COMMON_CLK_MT8183_VDECSYS 587 - bool "Clock driver for MediaTek MT8183 vdecsys" 585 + tristate "Clock driver for MediaTek MT8183 vdecsys" 588 586 depends on COMMON_CLK_MT8183 589 587 default COMMON_CLK_MT8183 590 588 help 591 589 This driver supports MediaTek MT8183 vdecsys clocks. 592 590 593 591 config COMMON_CLK_MT8183_VENCSYS 594 - bool "Clock driver for MediaTek MT8183 vencsys" 592 + tristate "Clock driver for MediaTek MT8183 vencsys" 595 593 depends on COMMON_CLK_MT8183 596 594 default COMMON_CLK_MT8183 597 595 help 598 596 This driver supports MediaTek MT8183 vencsys clocks. 599 597 600 598 config COMMON_CLK_MT8186 601 - bool "Clock driver for MediaTek MT8186" 599 + tristate "Clock driver for MediaTek MT8186" 602 600 depends on ARM64 || COMPILE_TEST 603 601 select COMMON_CLK_MEDIATEK 604 602 select COMMON_CLK_MEDIATEK_FHCTL ··· 606 604 help 607 605 This driver supports MediaTek MT8186 clocks. 608 606 609 - config COMMON_CLK_MT8192 610 - bool "Clock driver for MediaTek MT8192" 607 + config COMMON_CLK_MT8186_CAMSYS 608 + tristate "Clock driver for MediaTek MT8186 camsys" 609 + depends on COMMON_CLK_MT8186 610 + default COMMON_CLK_MT8186 611 + help 612 + This driver supports MediaTek MT8186 camsys and camsys_raw clocks. 613 + 614 + config COMMON_CLK_MT8186_IMGSYS 615 + tristate "Clock driver for MediaTek MT8186 imgsys" 616 + depends on COMMON_CLK_MT8186 617 + default COMMON_CLK_MT8186 618 + help 619 + This driver supports MediaTek MT8186 imgsys and imgsys2 clocks. 620 + 621 + config COMMON_CLK_MT8186_IPESYS 622 + tristate "Clock driver for MediaTek MT8186 ipesys" 623 + depends on COMMON_CLK_MT8186_IMGSYS 624 + default COMMON_CLK_MT8186_IMGSYS 625 + help 626 + This driver supports MediaTek MT8186 ipesys clocks. 627 + 628 + config COMMON_CLK_MT8186_WPESYS 629 + tristate "Clock driver for MediaTek MT8186 wpesys" 630 + depends on COMMON_CLK_MT8186_IMGSYS 631 + default COMMON_CLK_MT8186_IMGSYS 632 + help 633 + This driver supports MediaTek MT8186 Warp Engine clocks. 634 + 635 + config COMMON_CLK_MT8186_IMP_IIC_WRAP 636 + tristate "Clock driver for MediaTek MT8186 imp_iic_wrap" 637 + depends on COMMON_CLK_MT8186 638 + default COMMON_CLK_MT8186 639 + help 640 + This driver supports MediaTek MT8186 imp_iic_wrap clocks. 641 + 642 + config COMMON_CLK_MT8186_MCUSYS 643 + tristate "Clock driver for MediaTek MT8186 mcusys" 644 + depends on COMMON_CLK_MT8186 645 + default COMMON_CLK_MT8186 646 + help 647 + This driver supports MediaTek MT8186 mcusys clocks. 648 + 649 + config COMMON_CLK_MT8186_MDPSYS 650 + tristate "Clock driver for MediaTek MT8186 mdpsys" 651 + depends on COMMON_CLK_MT8186 652 + default COMMON_CLK_MT8186 653 + help 654 + This driver supports MediaTek MT8186 mdpsys clocks. 655 + 656 + config COMMON_CLK_MT8186_MFGCFG 657 + tristate "Clock driver for MediaTek MT8186 mfgcfg" 658 + depends on COMMON_CLK_MT8186 659 + default COMMON_CLK_MT8186 660 + help 661 + This driver supports MediaTek MT8186 mfgcfg clocks. 662 + 663 + config COMMON_CLK_MT8186_MMSYS 664 + tristate "Clock driver for MediaTek MT8186 mmsys" 665 + depends on COMMON_CLK_MT8186 666 + default COMMON_CLK_MT8186 667 + help 668 + This driver supports MediaTek MT8186 mmsys clocks. 669 + 670 + config COMMON_CLK_MT8186_VDECSYS 671 + tristate "Clock driver for MediaTek MT8186 vdecsys" 672 + depends on COMMON_CLK_MT8186 673 + default COMMON_CLK_MT8186 674 + help 675 + This driver supports MediaTek MT8186 vdecsys and vdecsys_soc clocks. 676 + 677 + config COMMON_CLK_MT8186_VENCSYS 678 + tristate "Clock driver for MediaTek MT8186 vencsys" 679 + depends on COMMON_CLK_MT8186 680 + default COMMON_CLK_MT8186 681 + help 682 + This driver supports MediaTek MT8186 vencsys clocks. 683 + 684 + config COMMON_CLK_MT8188 685 + tristate "Clock driver for MediaTek MT8188" 611 686 depends on ARM64 || COMPILE_TEST 612 687 select COMMON_CLK_MEDIATEK 688 + select COMMON_CLK_MEDIATEK_FHCTL 689 + default ARCH_MEDIATEK 690 + help 691 + This driver supports MediaTek MT8188 clocks. 692 + 693 + config COMMON_CLK_MT8188_ADSP_AUDIO26M 694 + tristate "Clock driver for MediaTek MT8188 adsp audio26m" 695 + depends on COMMON_CLK_MT8188 696 + default COMMON_CLK_MT8188 697 + help 698 + This driver supports MediaTek MT8188 adsp audio26m clocks. 699 + 700 + config COMMON_CLK_MT8188_CAMSYS 701 + tristate "Clock driver for MediaTek MT8188 camsys" 702 + depends on COMMON_CLK_MT8188_VPPSYS 703 + default COMMON_CLK_MT8188_VPPSYS 704 + help 705 + This driver supports MediaTek MT8188 camsys and camsys_raw clocks. 706 + 707 + config COMMON_CLK_MT8188_IMGSYS 708 + tristate "Clock driver for MediaTek MT8188 imgsys" 709 + depends on COMMON_CLK_MT8188_VPPSYS 710 + default COMMON_CLK_MT8188_VPPSYS 711 + help 712 + This driver supports MediaTek MT8188 imgsys and imgsys2 clocks. 713 + 714 + config COMMON_CLK_MT8188_IMP_IIC_WRAP 715 + tristate "Clock driver for MediaTek MT8188 imp_iic_wrap" 716 + depends on COMMON_CLK_MT8188 717 + default COMMON_CLK_MT8188 718 + help 719 + This driver supports MediaTek MT8188 I2C/I3C clocks. 720 + 721 + config COMMON_CLK_MT8188_IPESYS 722 + tristate "Clock driver for MediaTek MT8188 ipesys" 723 + depends on COMMON_CLK_MT8188_IMGSYS 724 + default COMMON_CLK_MT8188_IMGSYS 725 + help 726 + This driver supports MediaTek MT8188 ipesys clocks. 727 + 728 + config COMMON_CLK_MT8188_MFGCFG 729 + tristate "Clock driver for MediaTek MT8188 mfgcfg" 730 + depends on COMMON_CLK_MT8188 731 + default COMMON_CLK_MT8188 732 + help 733 + This driver supports MediaTek MT8188 mfgcfg clocks. 734 + 735 + config COMMON_CLK_MT8188_VDECSYS 736 + tristate "Clock driver for MediaTek MT8188 vdecsys" 737 + depends on COMMON_CLK_MT8188_VPPSYS 738 + default COMMON_CLK_MT8188_VPPSYS 739 + help 740 + This driver supports MediaTek MT8188 vdecsys and vdecsys_soc clocks. 741 + 742 + config COMMON_CLK_MT8188_VDOSYS 743 + tristate "Clock driver for MediaTek MT8188 vdosys" 744 + depends on COMMON_CLK_MT8188 745 + default COMMON_CLK_MT8188 746 + help 747 + This driver supports MediaTek MT8188 vdosys0/1 (multimedia) clocks. 748 + 749 + config COMMON_CLK_MT8188_VENCSYS 750 + tristate "Clock driver for MediaTek MT8188 vencsys" 751 + depends on COMMON_CLK_MT8188_VPPSYS 752 + default COMMON_CLK_MT8188_VPPSYS 753 + help 754 + This driver supports MediaTek MT8188 vencsys clocks. 755 + 756 + config COMMON_CLK_MT8188_VPPSYS 757 + tristate "Clock driver for MediaTek MT8188 vppsys" 758 + depends on COMMON_CLK_MT8188 759 + default COMMON_CLK_MT8188 760 + help 761 + This driver supports MediaTek MT8188 vppsys0/1 clocks. 762 + 763 + config COMMON_CLK_MT8188_WPESYS 764 + tristate "Clock driver for MediaTek MT8188 wpesys" 765 + depends on COMMON_CLK_MT8188_IMGSYS 766 + default COMMON_CLK_MT8188_IMGSYS 767 + help 768 + This driver supports MediaTek MT8188 Warp Engine clocks. 769 + 770 + config COMMON_CLK_MT8192 771 + tristate "Clock driver for MediaTek MT8192" 772 + depends on ARM64 || COMPILE_TEST 773 + select COMMON_CLK_MEDIATEK 774 + select COMMON_CLK_MEDIATEK_FHCTL 613 775 default ARM64 614 776 help 615 777 This driver supports MediaTek MT8192 basic clocks. 616 778 617 779 config COMMON_CLK_MT8192_AUDSYS 618 - bool "Clock driver for MediaTek MT8192 audsys" 780 + tristate "Clock driver for MediaTek MT8192 audsys" 619 781 depends on COMMON_CLK_MT8192 620 782 help 621 783 This driver supports MediaTek MT8192 audsys clocks. 622 784 623 785 config COMMON_CLK_MT8192_CAMSYS 624 - bool "Clock driver for MediaTek MT8192 camsys" 786 + tristate "Clock driver for MediaTek MT8192 camsys" 625 787 depends on COMMON_CLK_MT8192 626 788 help 627 789 This driver supports MediaTek MT8192 camsys and camsys_raw clocks. 628 790 629 791 config COMMON_CLK_MT8192_IMGSYS 630 - bool "Clock driver for MediaTek MT8192 imgsys" 792 + tristate "Clock driver for MediaTek MT8192 imgsys" 631 793 depends on COMMON_CLK_MT8192 632 794 help 633 795 This driver supports MediaTek MT8192 imgsys and imgsys2 clocks. 634 796 635 797 config COMMON_CLK_MT8192_IMP_IIC_WRAP 636 - bool "Clock driver for MediaTek MT8192 imp_iic_wrap" 798 + tristate "Clock driver for MediaTek MT8192 imp_iic_wrap" 637 799 depends on COMMON_CLK_MT8192 638 800 help 639 801 This driver supports MediaTek MT8192 imp_iic_wrap clocks. 640 802 641 803 config COMMON_CLK_MT8192_IPESYS 642 - bool "Clock driver for MediaTek MT8192 ipesys" 804 + tristate "Clock driver for MediaTek MT8192 ipesys" 643 805 depends on COMMON_CLK_MT8192 644 806 help 645 807 This driver supports MediaTek MT8192 ipesys clocks. 646 808 647 809 config COMMON_CLK_MT8192_MDPSYS 648 - bool "Clock driver for MediaTek MT8192 mdpsys" 810 + tristate "Clock driver for MediaTek MT8192 mdpsys" 649 811 depends on COMMON_CLK_MT8192 650 812 help 651 813 This driver supports MediaTek MT8192 mdpsys clocks. 652 814 653 815 config COMMON_CLK_MT8192_MFGCFG 654 - bool "Clock driver for MediaTek MT8192 mfgcfg" 816 + tristate "Clock driver for MediaTek MT8192 mfgcfg" 655 817 depends on COMMON_CLK_MT8192 656 818 help 657 819 This driver supports MediaTek MT8192 mfgcfg clocks. 658 820 659 821 config COMMON_CLK_MT8192_MMSYS 660 - bool "Clock driver for MediaTek MT8192 mmsys" 822 + tristate "Clock driver for MediaTek MT8192 mmsys" 661 823 depends on COMMON_CLK_MT8192 662 824 help 663 825 This driver supports MediaTek MT8192 mmsys clocks. 664 826 665 827 config COMMON_CLK_MT8192_MSDC 666 - bool "Clock driver for MediaTek MT8192 msdc" 828 + tristate "Clock driver for MediaTek MT8192 msdc" 667 829 depends on COMMON_CLK_MT8192 668 830 help 669 831 This driver supports MediaTek MT8192 msdc and msdc_top clocks. 670 832 671 833 config COMMON_CLK_MT8192_SCP_ADSP 672 - bool "Clock driver for MediaTek MT8192 scp_adsp" 834 + tristate "Clock driver for MediaTek MT8192 scp_adsp" 673 835 depends on COMMON_CLK_MT8192 674 836 help 675 837 This driver supports MediaTek MT8192 scp_adsp clocks. 676 838 677 839 config COMMON_CLK_MT8192_VDECSYS 678 - bool "Clock driver for MediaTek MT8192 vdecsys" 840 + tristate "Clock driver for MediaTek MT8192 vdecsys" 679 841 depends on COMMON_CLK_MT8192 680 842 help 681 843 This driver supports MediaTek MT8192 vdecsys and vdecsys_soc clocks. 682 844 683 845 config COMMON_CLK_MT8192_VENCSYS 684 - bool "Clock driver for MediaTek MT8192 vencsys" 846 + tristate "Clock driver for MediaTek MT8192 vencsys" 685 847 depends on COMMON_CLK_MT8192 686 848 help 687 849 This driver supports MediaTek MT8192 vencsys clocks. ··· 854 688 bool "Clock driver for MediaTek MT8195" 855 689 depends on ARM64 || COMPILE_TEST 856 690 select COMMON_CLK_MEDIATEK 691 + select COMMON_CLK_MEDIATEK_FHCTL 857 692 default ARCH_MEDIATEK 858 693 help 859 694 This driver supports MediaTek MT8195 clocks. 695 + 696 + config COMMON_CLK_MT8195_APUSYS 697 + tristate "Clock driver for MediaTek MT8195 apusys" 698 + depends on COMMON_CLK_MT8195 699 + default COMMON_CLK_MT8195 700 + help 701 + This driver supports MediaTek MT8195 AI Processor Unit System clocks. 702 + 703 + config COMMON_CLK_MT8195_AUDSYS 704 + tristate "Clock driver for MediaTek MT8195 audsys" 705 + depends on COMMON_CLK_MT8195 706 + default COMMON_CLK_MT8195 707 + help 708 + This driver supports MediaTek MT8195 audsys clocks. 709 + 710 + config COMMON_CLK_MT8195_IMP_IIC_WRAP 711 + tristate "Clock driver for MediaTek MT8195 imp_iic_wrap" 712 + depends on COMMON_CLK_MT8195 713 + default COMMON_CLK_MT8195 714 + help 715 + This driver supports MediaTek MT8195 I2C/I3C clocks. 716 + 717 + config COMMON_CLK_MT8195_MFGCFG 718 + tristate "Clock driver for MediaTek MT8195 mfgcfg" 719 + depends on COMMON_CLK_MT8195 720 + default COMMON_CLK_MT8195 721 + help 722 + This driver supports MediaTek MT8195 mfgcfg clocks. 723 + 724 + config COMMON_CLK_MT8195_MSDC 725 + tristate "Clock driver for MediaTek MT8195 msdc" 726 + depends on COMMON_CLK_MT8195 727 + default COMMON_CLK_MT8195 728 + help 729 + This driver supports MediaTek MT8195 MMC and SD Controller's 730 + msdc and msdc_top clocks. 731 + 732 + config COMMON_CLK_MT8195_SCP_ADSP 733 + tristate "Clock driver for MediaTek MT8195 scp_adsp" 734 + depends on COMMON_CLK_MT8195 735 + default COMMON_CLK_MT8195 736 + help 737 + This driver supports MediaTek MT8195 System Companion Processor 738 + Audio DSP clocks. 739 + 740 + config COMMON_CLK_MT8195_VDOSYS 741 + tristate "Clock driver for MediaTek MT8195 vdosys" 742 + depends on COMMON_CLK_MT8195 743 + default COMMON_CLK_MT8195 744 + help 745 + This driver supports MediaTek MT8195 vdosys0/1 (multimedia) clocks. 746 + 747 + config COMMON_CLK_MT8195_VPPSYS 748 + tristate "Clock driver for MediaTek MT8195 vppsys" 749 + depends on COMMON_CLK_MT8195 750 + default COMMON_CLK_MT8195 751 + help 752 + This driver supports MediaTek MT8195 vppsys0/1 clocks. 753 + 754 + config COMMON_CLK_MT8195_CAMSYS 755 + tristate "Clock driver for MediaTek MT8195 camsys" 756 + depends on COMMON_CLK_MT8195_VPPSYS 757 + default COMMON_CLK_MT8195_VPPSYS 758 + help 759 + This driver supports MediaTek MT8195 camsys and camsys_raw clocks. 760 + 761 + config COMMON_CLK_MT8195_IMGSYS 762 + tristate "Clock driver for MediaTek MT8195 imgsys" 763 + depends on COMMON_CLK_MT8195_VPPSYS 764 + default COMMON_CLK_MT8195_VPPSYS 765 + help 766 + This driver supports MediaTek MT8195 imgsys and imgsys2 clocks. 767 + 768 + config COMMON_CLK_MT8195_IPESYS 769 + tristate "Clock driver for MediaTek MT8195 ipesys" 770 + depends on COMMON_CLK_MT8195_IMGSYS 771 + default COMMON_CLK_MT8195_IMGSYS 772 + help 773 + This driver supports MediaTek MT8195 ipesys clocks. 774 + 775 + config COMMON_CLK_MT8195_WPESYS 776 + tristate "Clock driver for MediaTek MT8195 wpesys" 777 + depends on COMMON_CLK_MT8195_IMGSYS 778 + default COMMON_CLK_MT8195_IMGSYS 779 + help 780 + This driver supports MediaTek MT8195 Warp Engine clocks. 781 + 782 + config COMMON_CLK_MT8195_VDECSYS 783 + tristate "Clock driver for MediaTek MT8195 vdecsys" 784 + depends on COMMON_CLK_MT8195_VPPSYS 785 + default COMMON_CLK_MT8195_VPPSYS 786 + help 787 + This driver supports MediaTek MT8195 vdecsys and vdecsys_soc clocks. 788 + 789 + config COMMON_CLK_MT8195_VENCSYS 790 + tristate "Clock driver for MediaTek MT8195 vencsys" 791 + depends on COMMON_CLK_MT8195_VPPSYS 792 + default COMMON_CLK_MT8195_VPPSYS 793 + help 794 + This driver supports MediaTek MT8195 vencsys clocks. 860 795 861 796 config COMMON_CLK_MT8365 862 797 tristate "Clock driver for MediaTek MT8365" ··· 1010 743 This driver supports MediaTek MT8365 venc clocks. 1011 744 1012 745 config COMMON_CLK_MT8516 1013 - bool "Clock driver for MediaTek MT8516" 746 + tristate "Clock driver for MediaTek MT8516" 1014 747 depends on ARCH_MEDIATEK || COMPILE_TEST 1015 748 select COMMON_CLK_MEDIATEK 1016 749 default ARCH_MEDIATEK ··· 1018 751 This driver supports MediaTek MT8516 clocks. 1019 752 1020 753 config COMMON_CLK_MT8516_AUDSYS 1021 - bool "Clock driver for MediaTek MT8516 audsys" 754 + tristate "Clock driver for MediaTek MT8516 audsys" 1022 755 depends on COMMON_CLK_MT8516 1023 756 help 1024 757 This driver supports MediaTek MT8516 audsys clocks.
+48 -20
drivers/clk/mediatek/Makefile
··· 38 38 obj-$(CONFIG_COMMON_CLK_MT2701_IMGSYS) += clk-mt2701-img.o 39 39 obj-$(CONFIG_COMMON_CLK_MT2701_MMSYS) += clk-mt2701-mm.o 40 40 obj-$(CONFIG_COMMON_CLK_MT2701_VDECSYS) += clk-mt2701-vdec.o 41 - obj-$(CONFIG_COMMON_CLK_MT2712) += clk-mt2712.o 41 + obj-$(CONFIG_COMMON_CLK_MT2712) += clk-mt2712-apmixedsys.o clk-mt2712.o 42 42 obj-$(CONFIG_COMMON_CLK_MT2712_BDPSYS) += clk-mt2712-bdp.o 43 43 obj-$(CONFIG_COMMON_CLK_MT2712_IMGSYS) += clk-mt2712-img.o 44 44 obj-$(CONFIG_COMMON_CLK_MT2712_JPGDECSYS) += clk-mt2712-jpgdec.o ··· 46 46 obj-$(CONFIG_COMMON_CLK_MT2712_MMSYS) += clk-mt2712-mm.o 47 47 obj-$(CONFIG_COMMON_CLK_MT2712_VDECSYS) += clk-mt2712-vdec.o 48 48 obj-$(CONFIG_COMMON_CLK_MT2712_VENCSYS) += clk-mt2712-venc.o 49 - obj-$(CONFIG_COMMON_CLK_MT7622) += clk-mt7622.o 49 + obj-$(CONFIG_COMMON_CLK_MT7622) += clk-mt7622-apmixedsys.o clk-mt7622.o \ 50 + clk-mt7622-infracfg.o 50 51 obj-$(CONFIG_COMMON_CLK_MT7622_ETHSYS) += clk-mt7622-eth.o 51 52 obj-$(CONFIG_COMMON_CLK_MT7622_HIFSYS) += clk-mt7622-hif.o 52 53 obj-$(CONFIG_COMMON_CLK_MT7622_AUDSYS) += clk-mt7622-aud.o ··· 62 61 obj-$(CONFIG_COMMON_CLK_MT7986) += clk-mt7986-topckgen.o 63 62 obj-$(CONFIG_COMMON_CLK_MT7986) += clk-mt7986-infracfg.o 64 63 obj-$(CONFIG_COMMON_CLK_MT7986_ETHSYS) += clk-mt7986-eth.o 65 - obj-$(CONFIG_COMMON_CLK_MT8135) += clk-mt8135.o 66 - obj-$(CONFIG_COMMON_CLK_MT8167) += clk-mt8167.o 64 + obj-$(CONFIG_COMMON_CLK_MT8135) += clk-mt8135-apmixedsys.o clk-mt8135.o 65 + obj-$(CONFIG_COMMON_CLK_MT8167) += clk-mt8167-apmixedsys.o clk-mt8167.o 67 66 obj-$(CONFIG_COMMON_CLK_MT8167_AUDSYS) += clk-mt8167-aud.o 68 67 obj-$(CONFIG_COMMON_CLK_MT8167_IMGSYS) += clk-mt8167-img.o 69 68 obj-$(CONFIG_COMMON_CLK_MT8167_MFGCFG) += clk-mt8167-mfgcfg.o ··· 75 74 obj-$(CONFIG_COMMON_CLK_MT8173_MMSYS) += clk-mt8173-mm.o 76 75 obj-$(CONFIG_COMMON_CLK_MT8173_VDECSYS) += clk-mt8173-vdecsys.o 77 76 obj-$(CONFIG_COMMON_CLK_MT8173_VENCSYS) += clk-mt8173-vencsys.o 78 - obj-$(CONFIG_COMMON_CLK_MT8183) += clk-mt8183.o 77 + obj-$(CONFIG_COMMON_CLK_MT8183) += clk-mt8183-apmixedsys.o clk-mt8183.o 79 78 obj-$(CONFIG_COMMON_CLK_MT8183_AUDIOSYS) += clk-mt8183-audio.o 80 79 obj-$(CONFIG_COMMON_CLK_MT8183_CAMSYS) += clk-mt8183-cam.o 81 80 obj-$(CONFIG_COMMON_CLK_MT8183_IMGSYS) += clk-mt8183-img.o ··· 87 86 obj-$(CONFIG_COMMON_CLK_MT8183_MMSYS) += clk-mt8183-mm.o 88 87 obj-$(CONFIG_COMMON_CLK_MT8183_VDECSYS) += clk-mt8183-vdec.o 89 88 obj-$(CONFIG_COMMON_CLK_MT8183_VENCSYS) += clk-mt8183-venc.o 90 - obj-$(CONFIG_COMMON_CLK_MT8186) += clk-mt8186-mcu.o clk-mt8186-topckgen.o clk-mt8186-infra_ao.o \ 91 - clk-mt8186-apmixedsys.o clk-mt8186-imp_iic_wrap.o \ 92 - clk-mt8186-mfg.o clk-mt8186-mm.o clk-mt8186-wpe.o \ 93 - clk-mt8186-img.o clk-mt8186-vdec.o clk-mt8186-venc.o \ 94 - clk-mt8186-cam.o clk-mt8186-mdp.o clk-mt8186-ipe.o 95 - obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o 89 + obj-$(CONFIG_COMMON_CLK_MT8186) += clk-mt8186-apmixedsys.o clk-mt8186-topckgen.o \ 90 + clk-mt8186-infra_ao.o 91 + obj-$(CONFIG_COMMON_CLK_MT8186_CAMSYS) += clk-mt8186-cam.o 92 + obj-$(CONFIG_COMMON_CLK_MT8186_IMGSYS) += clk-mt8186-img.o 93 + obj-$(CONFIG_COMMON_CLK_MT8186_IMP_IIC_WRAP) += clk-mt8186-imp_iic_wrap.o 94 + obj-$(CONFIG_COMMON_CLK_MT8186_IPESYS) += clk-mt8186-ipe.o 95 + obj-$(CONFIG_COMMON_CLK_MT8186_MCUSYS) += clk-mt8186-mcu.o 96 + obj-$(CONFIG_COMMON_CLK_MT8186_MDPSYS) += clk-mt8186-mdp.o 97 + obj-$(CONFIG_COMMON_CLK_MT8186_MFGCFG) += clk-mt8186-mfg.o 98 + obj-$(CONFIG_COMMON_CLK_MT8186_MMSYS) += clk-mt8186-mm.o 99 + obj-$(CONFIG_COMMON_CLK_MT8186_VDECSYS) += clk-mt8186-vdec.o 100 + obj-$(CONFIG_COMMON_CLK_MT8186_VENCSYS) += clk-mt8186-venc.o 101 + obj-$(CONFIG_COMMON_CLK_MT8186_WPESYS) += clk-mt8186-wpe.o 102 + obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o clk-mt8188-topckgen.o \ 103 + clk-mt8188-peri_ao.o clk-mt8188-infra_ao.o 104 + obj-$(CONFIG_COMMON_CLK_MT8188_ADSP_AUDIO26M) += clk-mt8188-adsp_audio26m.o 105 + obj-$(CONFIG_COMMON_CLK_MT8188_CAMSYS) += clk-mt8188-cam.o clk-mt8188-ccu.o 106 + obj-$(CONFIG_COMMON_CLK_MT8188_IMGSYS) += clk-mt8188-img.o 107 + obj-$(CONFIG_COMMON_CLK_MT8188_IMP_IIC_WRAP) += clk-mt8188-imp_iic_wrap.o 108 + obj-$(CONFIG_COMMON_CLK_MT8188_IPESYS) += clk-mt8188-ipe.o 109 + obj-$(CONFIG_COMMON_CLK_MT8188_MFGCFG) += clk-mt8188-mfg.o 110 + obj-$(CONFIG_COMMON_CLK_MT8188_VDECSYS) += clk-mt8188-vdec.o 111 + obj-$(CONFIG_COMMON_CLK_MT8188_VDOSYS) += clk-mt8188-vdo0.o clk-mt8188-vdo1.o 112 + obj-$(CONFIG_COMMON_CLK_MT8188_VENCSYS) += clk-mt8188-venc.o 113 + obj-$(CONFIG_COMMON_CLK_MT8188_VPPSYS) += clk-mt8188-vpp0.o clk-mt8188-vpp1.o 114 + obj-$(CONFIG_COMMON_CLK_MT8188_WPESYS) += clk-mt8188-wpe.o 115 + obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192-apmixedsys.o clk-mt8192.o 96 116 obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o 97 117 obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o 98 118 obj-$(CONFIG_COMMON_CLK_MT8192_IMGSYS) += clk-mt8192-img.o ··· 127 105 obj-$(CONFIG_COMMON_CLK_MT8192_VDECSYS) += clk-mt8192-vdec.o 128 106 obj-$(CONFIG_COMMON_CLK_MT8192_VENCSYS) += clk-mt8192-venc.o 129 107 obj-$(CONFIG_COMMON_CLK_MT8195) += clk-mt8195-apmixedsys.o clk-mt8195-topckgen.o \ 130 - clk-mt8195-peri_ao.o clk-mt8195-infra_ao.o \ 131 - clk-mt8195-cam.o clk-mt8195-ccu.o clk-mt8195-img.o \ 132 - clk-mt8195-ipe.o clk-mt8195-mfg.o clk-mt8195-scp_adsp.o \ 133 - clk-mt8195-vdec.o clk-mt8195-vdo0.o clk-mt8195-vdo1.o \ 134 - clk-mt8195-venc.o clk-mt8195-vpp0.o clk-mt8195-vpp1.o \ 135 - clk-mt8195-wpe.o clk-mt8195-imp_iic_wrap.o \ 136 - clk-mt8195-apusys_pll.o 137 - obj-$(CONFIG_COMMON_CLK_MT8365) += clk-mt8365.o 108 + clk-mt8195-peri_ao.o clk-mt8195-infra_ao.o 109 + obj-$(CONFIG_COMMON_CLK_MT8195_APUSYS) += clk-mt8195-apusys_pll.o 110 + obj-$(CONFIG_COMMON_CLK_MT8195_CAMSYS) += clk-mt8195-cam.o clk-mt8195-ccu.o 111 + obj-$(CONFIG_COMMON_CLK_MT8195_IMGSYS) += clk-mt8195-img.o 112 + obj-$(CONFIG_COMMON_CLK_MT8195_IMP_IIC_WRAP) += clk-mt8195-imp_iic_wrap.o 113 + obj-$(CONFIG_COMMON_CLK_MT8195_IPESYS) += clk-mt8195-ipe.o 114 + obj-$(CONFIG_COMMON_CLK_MT8195_MFGCFG) += clk-mt8195-mfg.o 115 + obj-$(CONFIG_COMMON_CLK_MT8195_SCP_ADSP) += clk-mt8195-scp_adsp.o 116 + obj-$(CONFIG_COMMON_CLK_MT8195_VDECSYS) += clk-mt8195-vdec.o 117 + obj-$(CONFIG_COMMON_CLK_MT8195_VDOSYS) += clk-mt8195-vdo0.o clk-mt8195-vdo1.o 118 + obj-$(CONFIG_COMMON_CLK_MT8195_VENCSYS) += clk-mt8195-venc.o 119 + obj-$(CONFIG_COMMON_CLK_MT8195_VPPSYS) += clk-mt8195-vpp0.o clk-mt8195-vpp1.o 120 + obj-$(CONFIG_COMMON_CLK_MT8195_WPESYS) += clk-mt8195-wpe.o 121 + obj-$(CONFIG_COMMON_CLK_MT8365) += clk-mt8365-apmixedsys.o clk-mt8365.o 138 122 obj-$(CONFIG_COMMON_CLK_MT8365_APU) += clk-mt8365-apu.o 139 123 obj-$(CONFIG_COMMON_CLK_MT8365_CAM) += clk-mt8365-cam.o 140 124 obj-$(CONFIG_COMMON_CLK_MT8365_MFG) += clk-mt8365-mfg.o 141 125 obj-$(CONFIG_COMMON_CLK_MT8365_MMSYS) += clk-mt8365-mm.o 142 126 obj-$(CONFIG_COMMON_CLK_MT8365_VDEC) += clk-mt8365-vdec.o 143 127 obj-$(CONFIG_COMMON_CLK_MT8365_VENC) += clk-mt8365-venc.o 144 - obj-$(CONFIG_COMMON_CLK_MT8516) += clk-mt8516.o 128 + obj-$(CONFIG_COMMON_CLK_MT8516) += clk-mt8516-apmixedsys.o clk-mt8516.o 145 129 obj-$(CONFIG_COMMON_CLK_MT8516_AUDSYS) += clk-mt8516-aud.o
+23 -3
drivers/clk/mediatek/clk-fhctl.c
··· 14 14 #define PERCENT_TO_DDSLMT(dds, percent_m10) \ 15 15 ((((dds) * (percent_m10)) >> 5) / 100) 16 16 17 - static const struct fhctl_offset fhctl_offset = { 17 + static const struct fhctl_offset fhctl_offset_v1 = { 18 + .offset_hp_en = 0x0, 19 + .offset_clk_con = 0x4, 20 + .offset_rst_con = 0x8, 21 + .offset_slope0 = 0xc, 22 + .offset_slope1 = 0x10, 23 + .offset_cfg = 0x0, 24 + .offset_updnlmt = 0x4, 25 + .offset_dds = 0x8, 26 + .offset_dvfs = 0xc, 27 + .offset_mon = 0x10, 28 + }; 29 + 30 + static const struct fhctl_offset fhctl_offset_v2 = { 18 31 .offset_hp_en = 0x0, 19 32 .offset_clk_con = 0x8, 20 33 .offset_rst_con = 0xc, ··· 40 27 .offset_mon = 0x10, 41 28 }; 42 29 43 - const struct fhctl_offset *fhctl_get_offset_table(void) 30 + const struct fhctl_offset *fhctl_get_offset_table(enum fhctl_variant v) 44 31 { 45 - return &fhctl_offset; 32 + switch (v) { 33 + case FHCTL_PLLFH_V1: 34 + return &fhctl_offset_v1; 35 + case FHCTL_PLLFH_V2: 36 + return &fhctl_offset_v2; 37 + default: 38 + return ERR_PTR(-EINVAL); 39 + }; 46 40 } 47 41 48 42 static void dump_hw(struct mtk_clk_pll *pll, struct fh_pll_regs *regs,
+8 -1
drivers/clk/mediatek/clk-fhctl.h
··· 7 7 #ifndef __CLK_FHCTL_H 8 8 #define __CLK_FHCTL_H 9 9 10 + #include "clk-pllfh.h" 11 + 12 + enum fhctl_variant { 13 + FHCTL_PLLFH_V1, 14 + FHCTL_PLLFH_V2, 15 + }; 16 + 10 17 struct fhctl_offset { 11 18 u32 offset_hp_en; 12 19 u32 offset_clk_con; ··· 26 19 u32 offset_dvfs; 27 20 u32 offset_mon; 28 21 }; 29 - const struct fhctl_offset *fhctl_get_offset_table(void); 22 + const struct fhctl_offset *fhctl_get_offset_table(enum fhctl_variant v); 30 23 const struct fh_operation *fhctl_get_ops(void); 31 24 void fhctl_hw_init(struct mtk_fh *fh); 32 25
+11 -34
drivers/clk/mediatek/clk-mt2701-aud.c
··· 15 15 16 16 #include <dt-bindings/clock/mt2701-clk.h> 17 17 18 - #define GATE_AUDIO0(_id, _name, _parent, _shift) { \ 19 - .id = _id, \ 20 - .name = _name, \ 21 - .parent_name = _parent, \ 22 - .regs = &audio0_cg_regs, \ 23 - .shift = _shift, \ 24 - .ops = &mtk_clk_gate_ops_no_setclr, \ 25 - } 18 + #define GATE_AUDIO0(_id, _name, _parent, _shift) \ 19 + GATE_MTK(_id, _name, _parent, &audio0_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr) 26 20 27 - #define GATE_AUDIO1(_id, _name, _parent, _shift) { \ 28 - .id = _id, \ 29 - .name = _name, \ 30 - .parent_name = _parent, \ 31 - .regs = &audio1_cg_regs, \ 32 - .shift = _shift, \ 33 - .ops = &mtk_clk_gate_ops_no_setclr, \ 34 - } 21 + #define GATE_AUDIO1(_id, _name, _parent, _shift) \ 22 + GATE_MTK(_id, _name, _parent, &audio1_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr) 35 23 36 - #define GATE_AUDIO2(_id, _name, _parent, _shift) { \ 37 - .id = _id, \ 38 - .name = _name, \ 39 - .parent_name = _parent, \ 40 - .regs = &audio2_cg_regs, \ 41 - .shift = _shift, \ 42 - .ops = &mtk_clk_gate_ops_no_setclr, \ 43 - } 24 + #define GATE_AUDIO2(_id, _name, _parent, _shift) \ 25 + GATE_MTK(_id, _name, _parent, &audio2_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr) 44 26 45 - #define GATE_AUDIO3(_id, _name, _parent, _shift) { \ 46 - .id = _id, \ 47 - .name = _name, \ 48 - .parent_name = _parent, \ 49 - .regs = &audio3_cg_regs, \ 50 - .shift = _shift, \ 51 - .ops = &mtk_clk_gate_ops_no_setclr, \ 52 - } 27 + #define GATE_AUDIO3(_id, _name, _parent, _shift) \ 28 + GATE_MTK(_id, _name, _parent, &audio3_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr) 53 29 54 30 static const struct mtk_gate_regs audio0_cg_regs = { 55 31 .set_ofs = 0x0, ··· 124 148 { .compatible = "mediatek,mt2701-audsys", .data = &audio_desc }, 125 149 { /* sentinel */ } 126 150 }; 151 + MODULE_DEVICE_TABLE(of, of_match_clk_mt2701_aud); 127 152 128 153 static int clk_mt2701_aud_probe(struct platform_device *pdev) 129 154 { ··· 164 187 .of_match_table = of_match_clk_mt2701_aud, 165 188 }, 166 189 }; 167 - 168 - builtin_platform_driver(clk_mt2701_aud_drv); 190 + module_platform_driver(clk_mt2701_aud_drv); 191 + MODULE_LICENSE("GPL");
+7 -18
drivers/clk/mediatek/clk-mt2701-bdp.c
··· 24 24 .sta_ofs = 0x0110, 25 25 }; 26 26 27 - #define GATE_BDP0(_id, _name, _parent, _shift) { \ 28 - .id = _id, \ 29 - .name = _name, \ 30 - .parent_name = _parent, \ 31 - .regs = &bdp0_cg_regs, \ 32 - .shift = _shift, \ 33 - .ops = &mtk_clk_gate_ops_setclr_inv, \ 34 - } 27 + #define GATE_BDP0(_id, _name, _parent, _shift) \ 28 + GATE_MTK(_id, _name, _parent, &bdp0_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv) 35 29 36 - #define GATE_BDP1(_id, _name, _parent, _shift) { \ 37 - .id = _id, \ 38 - .name = _name, \ 39 - .parent_name = _parent, \ 40 - .regs = &bdp1_cg_regs, \ 41 - .shift = _shift, \ 42 - .ops = &mtk_clk_gate_ops_setclr_inv, \ 43 - } 30 + #define GATE_BDP1(_id, _name, _parent, _shift) \ 31 + GATE_MTK(_id, _name, _parent, &bdp1_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv) 44 32 45 33 static const struct mtk_gate bdp_clks[] = { 46 34 GATE_BDP0(CLK_BDP_BRG_BA, "brg_baclk", "mm_sel", 0), ··· 95 107 /* sentinel */ 96 108 } 97 109 }; 110 + MODULE_DEVICE_TABLE(of, of_match_clk_mt2701_bdp); 98 111 99 112 static struct platform_driver clk_mt2701_bdp_drv = { 100 113 .probe = mtk_clk_simple_probe, ··· 105 116 .of_match_table = of_match_clk_mt2701_bdp, 106 117 }, 107 118 }; 108 - 109 - builtin_platform_driver(clk_mt2701_bdp_drv); 119 + module_platform_driver(clk_mt2701_bdp_drv); 120 + MODULE_LICENSE("GPL");
+5 -10
drivers/clk/mediatek/clk-mt2701-eth.c
··· 16 16 .sta_ofs = 0x0030, 17 17 }; 18 18 19 - #define GATE_ETH(_id, _name, _parent, _shift) { \ 20 - .id = _id, \ 21 - .name = _name, \ 22 - .parent_name = _parent, \ 23 - .regs = &eth_cg_regs, \ 24 - .shift = _shift, \ 25 - .ops = &mtk_clk_gate_ops_no_setclr_inv, \ 26 - } 19 + #define GATE_ETH(_id, _name, _parent, _shift) \ 20 + GATE_MTK(_id, _name, _parent, &eth_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv) 27 21 28 22 static const struct mtk_gate eth_clks[] = { 29 23 GATE_DUMMY(CLK_DUMMY, "eth_dummy"), ··· 49 55 { .compatible = "mediatek,mt2701-ethsys", .data = &eth_desc }, 50 56 { /* sentinel */ } 51 57 }; 58 + MODULE_DEVICE_TABLE(of, of_match_clk_mt2701_eth); 52 59 53 60 static struct platform_driver clk_mt2701_eth_drv = { 54 61 .probe = mtk_clk_simple_probe, ··· 59 64 .of_match_table = of_match_clk_mt2701_eth, 60 65 }, 61 66 }; 62 - 63 - builtin_platform_driver(clk_mt2701_eth_drv); 67 + module_platform_driver(clk_mt2701_eth_drv); 68 + MODULE_LICENSE("GPL");
+5 -10
drivers/clk/mediatek/clk-mt2701-g3d.c
··· 16 16 17 17 #include <dt-bindings/clock/mt2701-clk.h> 18 18 19 - #define GATE_G3D(_id, _name, _parent, _shift) { \ 20 - .id = _id, \ 21 - .name = _name, \ 22 - .parent_name = _parent, \ 23 - .regs = &g3d_cg_regs, \ 24 - .shift = _shift, \ 25 - .ops = &mtk_clk_gate_ops_setclr, \ 26 - } 19 + #define GATE_G3D(_id, _name, _parent, _shift) \ 20 + GATE_MTK(_id, _name, _parent, &g3d_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 27 21 28 22 static const struct mtk_gate_regs g3d_cg_regs = { 29 23 .sta_ofs = 0x0, ··· 48 54 { .compatible = "mediatek,mt2701-g3dsys", .data = &g3d_desc }, 49 55 { /* sentinel */ } 50 56 }; 57 + MODULE_DEVICE_TABLE(of, of_match_clk_mt2701_g3d); 51 58 52 59 static struct platform_driver clk_mt2701_g3d_drv = { 53 60 .probe = mtk_clk_simple_probe, ··· 58 63 .of_match_table = of_match_clk_mt2701_g3d, 59 64 }, 60 65 }; 61 - 62 - builtin_platform_driver(clk_mt2701_g3d_drv); 66 + module_platform_driver(clk_mt2701_g3d_drv); 67 + MODULE_LICENSE("GPL");
+5 -10
drivers/clk/mediatek/clk-mt2701-hif.c
··· 16 16 .sta_ofs = 0x0030, 17 17 }; 18 18 19 - #define GATE_HIF(_id, _name, _parent, _shift) { \ 20 - .id = _id, \ 21 - .name = _name, \ 22 - .parent_name = _parent, \ 23 - .regs = &hif_cg_regs, \ 24 - .shift = _shift, \ 25 - .ops = &mtk_clk_gate_ops_no_setclr_inv, \ 26 - } 19 + #define GATE_HIF(_id, _name, _parent, _shift) \ 20 + GATE_MTK(_id, _name, _parent, &hif_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv) 27 21 28 22 static const struct mtk_gate hif_clks[] = { 29 23 GATE_DUMMY(CLK_DUMMY, "hif_dummy"), ··· 46 52 { .compatible = "mediatek,mt2701-hifsys", .data = &hif_desc }, 47 53 { /* sentinel */ } 48 54 }; 55 + MODULE_DEVICE_TABLE(of, of_match_clk_mt2701_hif); 49 56 50 57 static struct platform_driver clk_mt2701_hif_drv = { 51 58 .probe = mtk_clk_simple_probe, ··· 56 61 .of_match_table = of_match_clk_mt2701_hif, 57 62 }, 58 63 }; 59 - 60 - builtin_platform_driver(clk_mt2701_hif_drv); 64 + module_platform_driver(clk_mt2701_hif_drv); 65 + MODULE_LICENSE("GPL");
+5 -10
drivers/clk/mediatek/clk-mt2701-img.c
··· 18 18 .sta_ofs = 0x0000, 19 19 }; 20 20 21 - #define GATE_IMG(_id, _name, _parent, _shift) { \ 22 - .id = _id, \ 23 - .name = _name, \ 24 - .parent_name = _parent, \ 25 - .regs = &img_cg_regs, \ 26 - .shift = _shift, \ 27 - .ops = &mtk_clk_gate_ops_setclr, \ 28 - } 21 + #define GATE_IMG(_id, _name, _parent, _shift) \ 22 + GATE_MTK(_id, _name, _parent, &img_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 29 23 30 24 static const struct mtk_gate img_clks[] = { 31 25 GATE_IMG(CLK_IMG_SMI_COMM, "img_smi_comm", "mm_sel", 0), ··· 43 49 /* sentinel */ 44 50 } 45 51 }; 52 + MODULE_DEVICE_TABLE(of, of_match_clk_mt2701_img); 46 53 47 54 static struct platform_driver clk_mt2701_img_drv = { 48 55 .probe = mtk_clk_simple_probe, ··· 53 58 .of_match_table = of_match_clk_mt2701_img, 54 59 }, 55 60 }; 56 - 57 - builtin_platform_driver(clk_mt2701_img_drv); 61 + module_platform_driver(clk_mt2701_img_drv); 62 + MODULE_LICENSE("GPL");
+18 -38
drivers/clk/mediatek/clk-mt2701-mm.c
··· 24 24 .sta_ofs = 0x0110, 25 25 }; 26 26 27 - #define GATE_DISP0(_id, _name, _parent, _shift) { \ 28 - .id = _id, \ 29 - .name = _name, \ 30 - .parent_name = _parent, \ 31 - .regs = &disp0_cg_regs, \ 32 - .shift = _shift, \ 33 - .ops = &mtk_clk_gate_ops_setclr, \ 34 - } 27 + #define GATE_DISP0(_id, _name, _parent, _shift) \ 28 + GATE_MTK(_id, _name, _parent, &disp0_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 35 29 36 - #define GATE_DISP1(_id, _name, _parent, _shift) { \ 37 - .id = _id, \ 38 - .name = _name, \ 39 - .parent_name = _parent, \ 40 - .regs = &disp1_cg_regs, \ 41 - .shift = _shift, \ 42 - .ops = &mtk_clk_gate_ops_setclr, \ 43 - } 30 + #define GATE_DISP1(_id, _name, _parent, _shift) \ 31 + GATE_MTK(_id, _name, _parent, &disp1_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 44 32 45 33 static const struct mtk_gate mm_clks[] = { 46 34 GATE_DISP0(CLK_MM_SMI_COMMON, "mm_smi_comm", "mm_sel", 0), ··· 67 79 GATE_DISP1(CLK_MM_TVE_FMM, "mm_tve_fmm", "mm_sel", 14), 68 80 }; 69 81 70 - static int clk_mt2701_mm_probe(struct platform_device *pdev) 71 - { 72 - struct device *dev = &pdev->dev; 73 - struct device_node *node = dev->parent->of_node; 74 - struct clk_hw_onecell_data *clk_data; 75 - int r; 82 + static const struct mtk_clk_desc mm_desc = { 83 + .clks = mm_clks, 84 + .num_clks = ARRAY_SIZE(mm_clks), 85 + }; 76 86 77 - clk_data = mtk_alloc_clk_data(CLK_MM_NR); 78 - 79 - mtk_clk_register_gates(&pdev->dev, node, mm_clks, 80 - ARRAY_SIZE(mm_clks), clk_data); 81 - 82 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 83 - if (r) 84 - dev_err(&pdev->dev, 85 - "could not register clock provider: %s: %d\n", 86 - pdev->name, r); 87 - 88 - return r; 89 - } 87 + static const struct platform_device_id clk_mt2701_mm_id_table[] = { 88 + { .name = "clk-mt2701-mm", .driver_data = (kernel_ulong_t)&mm_desc }, 89 + { /* sentinel */ } 90 + }; 91 + MODULE_DEVICE_TABLE(platform, clk_mt2701_mm_id_table); 90 92 91 93 static struct platform_driver clk_mt2701_mm_drv = { 92 - .probe = clk_mt2701_mm_probe, 94 + .probe = mtk_clk_pdev_probe, 95 + .remove = mtk_clk_pdev_remove, 93 96 .driver = { 94 97 .name = "clk-mt2701-mm", 95 98 }, 99 + .id_table = clk_mt2701_mm_id_table, 96 100 }; 97 - 98 - builtin_platform_driver(clk_mt2701_mm_drv); 101 + module_platform_driver(clk_mt2701_mm_drv); 102 + MODULE_LICENSE("GPL");
+7 -18
drivers/clk/mediatek/clk-mt2701-vdec.c
··· 24 24 .sta_ofs = 0x0008, 25 25 }; 26 26 27 - #define GATE_VDEC0(_id, _name, _parent, _shift) { \ 28 - .id = _id, \ 29 - .name = _name, \ 30 - .parent_name = _parent, \ 31 - .regs = &vdec0_cg_regs, \ 32 - .shift = _shift, \ 33 - .ops = &mtk_clk_gate_ops_setclr_inv, \ 34 - } 27 + #define GATE_VDEC0(_id, _name, _parent, _shift) \ 28 + GATE_MTK(_id, _name, _parent, &vdec0_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv) 35 29 36 - #define GATE_VDEC1(_id, _name, _parent, _shift) { \ 37 - .id = _id, \ 38 - .name = _name, \ 39 - .parent_name = _parent, \ 40 - .regs = &vdec1_cg_regs, \ 41 - .shift = _shift, \ 42 - .ops = &mtk_clk_gate_ops_setclr_inv, \ 43 - } 30 + #define GATE_VDEC1(_id, _name, _parent, _shift) \ 31 + GATE_MTK(_id, _name, _parent, &vdec1_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv) 44 32 45 33 static const struct mtk_gate vdec_clks[] = { 46 34 GATE_VDEC0(CLK_VDEC_CKGEN, "vdec_cken", "vdec_sel", 0), ··· 48 60 /* sentinel */ 49 61 } 50 62 }; 63 + MODULE_DEVICE_TABLE(of, of_match_clk_mt2701_vdec); 51 64 52 65 static struct platform_driver clk_mt2701_vdec_drv = { 53 66 .probe = mtk_clk_simple_probe, ··· 58 69 .of_match_table = of_match_clk_mt2701_vdec, 59 70 }, 60 71 }; 61 - 62 - builtin_platform_driver(clk_mt2701_vdec_drv); 72 + module_platform_driver(clk_mt2701_vdec_drv); 73 + MODULE_LICENSE("GPL");
+11 -33
drivers/clk/mediatek/clk-mt2701.c
··· 636 636 .sta_ofs = 0x012C, 637 637 }; 638 638 639 - #define GATE_TOP_AUD(_id, _name, _parent, _shift) { \ 640 - .id = _id, \ 641 - .name = _name, \ 642 - .parent_name = _parent, \ 643 - .regs = &top_aud_cg_regs, \ 644 - .shift = _shift, \ 645 - .ops = &mtk_clk_gate_ops_no_setclr, \ 646 - } 639 + #define GATE_TOP_AUD(_id, _name, _parent, _shift) \ 640 + GATE_MTK(_id, _name, _parent, &top_aud_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr) 647 641 648 642 static const struct mtk_gate top_clks[] = { 649 643 GATE_TOP_AUD(CLK_TOP_AUD_48K_TIMING, "a1sys_hp_ck", "aud_mux1_div", ··· 681 687 ARRAY_SIZE(top_muxes), base, 682 688 &mt2701_clk_lock, clk_data); 683 689 684 - mtk_clk_register_dividers(top_adj_divs, ARRAY_SIZE(top_adj_divs), 690 + mtk_clk_register_dividers(&pdev->dev, top_adj_divs, ARRAY_SIZE(top_adj_divs), 685 691 base, &mt2701_clk_lock, clk_data); 686 692 687 693 mtk_clk_register_gates(&pdev->dev, node, top_clks, ··· 696 702 .sta_ofs = 0x0048, 697 703 }; 698 704 699 - #define GATE_ICG(_id, _name, _parent, _shift) { \ 700 - .id = _id, \ 701 - .name = _name, \ 702 - .parent_name = _parent, \ 703 - .regs = &infra_cg_regs, \ 704 - .shift = _shift, \ 705 - .ops = &mtk_clk_gate_ops_setclr, \ 706 - } 705 + #define GATE_ICG(_id, _name, _parent, _shift) \ 706 + GATE_MTK(_id, _name, _parent, &infra_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 707 707 708 708 static const struct mtk_gate infra_clks[] = { 709 709 GATE_ICG(CLK_INFRA_DBG, "dbgclk", "axi_sel", 0), ··· 811 823 .sta_ofs = 0x001c, 812 824 }; 813 825 814 - #define GATE_PERI0(_id, _name, _parent, _shift) { \ 815 - .id = _id, \ 816 - .name = _name, \ 817 - .parent_name = _parent, \ 818 - .regs = &peri0_cg_regs, \ 819 - .shift = _shift, \ 820 - .ops = &mtk_clk_gate_ops_setclr, \ 821 - } 826 + #define GATE_PERI0(_id, _name, _parent, _shift) \ 827 + GATE_MTK(_id, _name, _parent, &peri0_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 822 828 823 - #define GATE_PERI1(_id, _name, _parent, _shift) { \ 824 - .id = _id, \ 825 - .name = _name, \ 826 - .parent_name = _parent, \ 827 - .regs = &peri1_cg_regs, \ 828 - .shift = _shift, \ 829 - .ops = &mtk_clk_gate_ops_setclr, \ 830 - } 829 + #define GATE_PERI1(_id, _name, _parent, _shift) \ 830 + GATE_MTK(_id, _name, _parent, &peri1_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 831 831 832 832 static const struct mtk_gate peri_clks[] = { 833 833 GATE_PERI0(CLK_PERI_USB0_MCU, "usb0_mcu_ck", "axi_sel", 31), ··· 999 1023 /* sentinel */ 1000 1024 } 1001 1025 }; 1026 + MODULE_DEVICE_TABLE(of, of_match_clk_mt2701); 1002 1027 1003 1028 static int clk_mt2701_probe(struct platform_device *pdev) 1004 1029 { ··· 1033 1056 } 1034 1057 1035 1058 arch_initcall(clk_mt2701_init); 1059 + MODULE_LICENSE("GPL");
+168
drivers/clk/mediatek/clk-mt2712-apmixedsys.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Copyright (c) 2017 MediaTek Inc. 4 + * Weiyi Lu <weiyi.lu@mediatek.com> 5 + * Copyright (c) 2023 Collabora Ltd. 6 + * AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> 7 + */ 8 + #include <linux/clk.h> 9 + #include <linux/of.h> 10 + #include <linux/platform_device.h> 11 + 12 + #include "clk-pll.h" 13 + #include "clk-mtk.h" 14 + 15 + #include <dt-bindings/clock/mt2712-clk.h> 16 + 17 + #define MT2712_PLL_FMAX (3000UL * MHZ) 18 + 19 + #define CON0_MT2712_RST_BAR BIT(24) 20 + 21 + #define PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits, \ 22 + _pd_reg, _pd_shift, _tuner_reg, _tuner_en_reg, \ 23 + _tuner_en_bit, _pcw_reg, _pcw_shift, \ 24 + _div_table) { \ 25 + .id = _id, \ 26 + .name = _name, \ 27 + .reg = _reg, \ 28 + .pwr_reg = _pwr_reg, \ 29 + .en_mask = _en_mask, \ 30 + .flags = _flags, \ 31 + .rst_bar_mask = CON0_MT2712_RST_BAR, \ 32 + .fmax = MT2712_PLL_FMAX, \ 33 + .pcwbits = _pcwbits, \ 34 + .pd_reg = _pd_reg, \ 35 + .pd_shift = _pd_shift, \ 36 + .tuner_reg = _tuner_reg, \ 37 + .tuner_en_reg = _tuner_en_reg, \ 38 + .tuner_en_bit = _tuner_en_bit, \ 39 + .pcw_reg = _pcw_reg, \ 40 + .pcw_shift = _pcw_shift, \ 41 + .div_table = _div_table, \ 42 + } 43 + 44 + #define PLL(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits, \ 45 + _pd_reg, _pd_shift, _tuner_reg, _tuner_en_reg, \ 46 + _tuner_en_bit, _pcw_reg, _pcw_shift) \ 47 + PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags, \ 48 + _pcwbits, _pd_reg, _pd_shift, _tuner_reg, \ 49 + _tuner_en_reg, _tuner_en_bit, _pcw_reg, \ 50 + _pcw_shift, NULL) 51 + 52 + static const struct mtk_pll_div_table armca35pll_div_table[] = { 53 + { .div = 0, .freq = MT2712_PLL_FMAX }, 54 + { .div = 1, .freq = 1202500000 }, 55 + { .div = 2, .freq = 500500000 }, 56 + { .div = 3, .freq = 315250000 }, 57 + { .div = 4, .freq = 157625000 }, 58 + { /* sentinel */ } 59 + }; 60 + 61 + static const struct mtk_pll_div_table armca72pll_div_table[] = { 62 + { .div = 0, .freq = MT2712_PLL_FMAX }, 63 + { .div = 1, .freq = 994500000 }, 64 + { .div = 2, .freq = 520000000 }, 65 + { .div = 3, .freq = 315250000 }, 66 + { .div = 4, .freq = 157625000 }, 67 + { /* sentinel */ } 68 + }; 69 + 70 + static const struct mtk_pll_div_table mmpll_div_table[] = { 71 + { .div = 0, .freq = MT2712_PLL_FMAX }, 72 + { .div = 1, .freq = 1001000000 }, 73 + { .div = 2, .freq = 601250000 }, 74 + { .div = 3, .freq = 250250000 }, 75 + { .div = 4, .freq = 125125000 }, 76 + { /* sentinel */ } 77 + }; 78 + 79 + static const struct mtk_pll_data plls[] = { 80 + PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0230, 0x023C, 0xf0000100, 81 + HAVE_RST_BAR, 31, 0x0230, 4, 0, 0, 0, 0x0234, 0), 82 + PLL(CLK_APMIXED_UNIVPLL, "univpll", 0x0240, 0x024C, 0xfe000100, 83 + HAVE_RST_BAR, 31, 0x0240, 4, 0, 0, 0, 0x0244, 0), 84 + PLL(CLK_APMIXED_VCODECPLL, "vcodecpll", 0x0320, 0x032C, 0xc0000100, 85 + 0, 31, 0x0320, 4, 0, 0, 0, 0x0324, 0), 86 + PLL(CLK_APMIXED_VENCPLL, "vencpll", 0x0280, 0x028C, 0x00000100, 87 + 0, 31, 0x0280, 4, 0, 0, 0, 0x0284, 0), 88 + PLL(CLK_APMIXED_APLL1, "apll1", 0x0330, 0x0340, 0x00000100, 89 + 0, 31, 0x0330, 4, 0x0338, 0x0014, 0, 0x0334, 0), 90 + PLL(CLK_APMIXED_APLL2, "apll2", 0x0350, 0x0360, 0x00000100, 91 + 0, 31, 0x0350, 4, 0x0358, 0x0014, 1, 0x0354, 0), 92 + PLL(CLK_APMIXED_LVDSPLL, "lvdspll", 0x0370, 0x037c, 0x00000100, 93 + 0, 31, 0x0370, 4, 0, 0, 0, 0x0374, 0), 94 + PLL(CLK_APMIXED_LVDSPLL2, "lvdspll2", 0x0390, 0x039C, 0x00000100, 95 + 0, 31, 0x0390, 4, 0, 0, 0, 0x0394, 0), 96 + PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x0270, 0x027C, 0x00000100, 97 + 0, 31, 0x0270, 4, 0, 0, 0, 0x0274, 0), 98 + PLL(CLK_APMIXED_MSDCPLL2, "msdcpll2", 0x0410, 0x041C, 0x00000100, 99 + 0, 31, 0x0410, 4, 0, 0, 0, 0x0414, 0), 100 + PLL(CLK_APMIXED_TVDPLL, "tvdpll", 0x0290, 0x029C, 0xc0000100, 101 + 0, 31, 0x0290, 4, 0, 0, 0, 0x0294, 0), 102 + PLL_B(CLK_APMIXED_MMPLL, "mmpll", 0x0250, 0x0260, 0x00000100, 103 + 0, 31, 0x0250, 4, 0, 0, 0, 0x0254, 0, mmpll_div_table), 104 + PLL_B(CLK_APMIXED_ARMCA35PLL, "armca35pll", 0x0100, 0x0110, 0xf0000100, 105 + HAVE_RST_BAR, 31, 0x0100, 4, 0, 0, 0, 0x0104, 0, armca35pll_div_table), 106 + PLL_B(CLK_APMIXED_ARMCA72PLL, "armca72pll", 0x0210, 0x0220, 0x00000100, 107 + 0, 31, 0x0210, 4, 0, 0, 0, 0x0214, 0, armca72pll_div_table), 108 + PLL(CLK_APMIXED_ETHERPLL, "etherpll", 0x0300, 0x030C, 0xc0000100, 109 + 0, 31, 0x0300, 4, 0, 0, 0, 0x0304, 0), 110 + }; 111 + 112 + static int clk_mt2712_apmixed_probe(struct platform_device *pdev) 113 + { 114 + struct clk_hw_onecell_data *clk_data; 115 + int r; 116 + struct device_node *node = pdev->dev.of_node; 117 + 118 + clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK); 119 + if (!clk_data) 120 + return -ENOMEM; 121 + 122 + r = mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data); 123 + if (r) 124 + goto free_clk_data; 125 + 126 + r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 127 + if (r) { 128 + dev_err(&pdev->dev, "Cannot register clock provider: %d\n", r); 129 + goto unregister_plls; 130 + } 131 + 132 + return 0; 133 + 134 + unregister_plls: 135 + mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data); 136 + free_clk_data: 137 + mtk_free_clk_data(clk_data); 138 + return r; 139 + } 140 + 141 + static int clk_mt2712_apmixed_remove(struct platform_device *pdev) 142 + { 143 + struct device_node *node = pdev->dev.of_node; 144 + struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev); 145 + 146 + of_clk_del_provider(node); 147 + mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data); 148 + mtk_free_clk_data(clk_data); 149 + 150 + return 0; 151 + } 152 + 153 + static const struct of_device_id of_match_clk_mt2712_apmixed[] = { 154 + { .compatible = "mediatek,mt2712-apmixedsys" }, 155 + { /* sentinel */ } 156 + }; 157 + MODULE_DEVICE_TABLE(of, of_match_clk_mt2712_apmixed); 158 + 159 + static struct platform_driver clk_mt2712_apmixed_drv = { 160 + .probe = clk_mt2712_apmixed_probe, 161 + .remove = clk_mt2712_apmixed_remove, 162 + .driver = { 163 + .name = "clk-mt2712-apmixed", 164 + .of_match_table = of_match_clk_mt2712_apmixed, 165 + }, 166 + }; 167 + module_platform_driver(clk_mt2712_apmixed_drv) 168 + MODULE_LICENSE("GPL");
+5 -10
drivers/clk/mediatek/clk-mt2712-bdp.c
··· 18 18 .sta_ofs = 0x100, 19 19 }; 20 20 21 - #define GATE_BDP(_id, _name, _parent, _shift) { \ 22 - .id = _id, \ 23 - .name = _name, \ 24 - .parent_name = _parent, \ 25 - .regs = &bdp_cg_regs, \ 26 - .shift = _shift, \ 27 - .ops = &mtk_clk_gate_ops_no_setclr, \ 28 - } 21 + #define GATE_BDP(_id, _name, _parent, _shift) \ 22 + GATE_MTK(_id, _name, _parent, &bdp_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr) 29 23 30 24 static const struct mtk_gate bdp_clks[] = { 31 25 GATE_BDP(CLK_BDP_BRIDGE_B, "bdp_bridge_b", "mm_sel", 0), ··· 65 71 /* sentinel */ 66 72 } 67 73 }; 74 + MODULE_DEVICE_TABLE(of, of_match_clk_mt2712_bdp); 68 75 69 76 static struct platform_driver clk_mt2712_bdp_drv = { 70 77 .probe = mtk_clk_simple_probe, ··· 75 80 .of_match_table = of_match_clk_mt2712_bdp, 76 81 }, 77 82 }; 78 - 79 - builtin_platform_driver(clk_mt2712_bdp_drv); 83 + module_platform_driver(clk_mt2712_bdp_drv); 84 + MODULE_LICENSE("GPL");
+5 -10
drivers/clk/mediatek/clk-mt2712-img.c
··· 18 18 .sta_ofs = 0x0, 19 19 }; 20 20 21 - #define GATE_IMG(_id, _name, _parent, _shift) { \ 22 - .id = _id, \ 23 - .name = _name, \ 24 - .parent_name = _parent, \ 25 - .regs = &img_cg_regs, \ 26 - .shift = _shift, \ 27 - .ops = &mtk_clk_gate_ops_no_setclr, \ 28 - } 21 + #define GATE_IMG(_id, _name, _parent, _shift) \ 22 + GATE_MTK(_id, _name, _parent, &img_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr) 29 23 30 24 static const struct mtk_gate img_clks[] = { 31 25 GATE_IMG(CLK_IMG_SMI_LARB2, "img_smi_larb2", "mm_sel", 0), ··· 43 49 /* sentinel */ 44 50 } 45 51 }; 52 + MODULE_DEVICE_TABLE(of, of_match_clk_mt2712_img); 46 53 47 54 static struct platform_driver clk_mt2712_img_drv = { 48 55 .probe = mtk_clk_simple_probe, ··· 53 58 .of_match_table = of_match_clk_mt2712_img, 54 59 }, 55 60 }; 56 - 57 - builtin_platform_driver(clk_mt2712_img_drv); 61 + module_platform_driver(clk_mt2712_img_drv); 62 + MODULE_LICENSE("GPL");
+5 -10
drivers/clk/mediatek/clk-mt2712-jpgdec.c
··· 18 18 .sta_ofs = 0x0, 19 19 }; 20 20 21 - #define GATE_JPGDEC(_id, _name, _parent, _shift) { \ 22 - .id = _id, \ 23 - .name = _name, \ 24 - .parent_name = _parent, \ 25 - .regs = &jpgdec_cg_regs, \ 26 - .shift = _shift, \ 27 - .ops = &mtk_clk_gate_ops_setclr_inv, \ 28 - } 21 + #define GATE_JPGDEC(_id, _name, _parent, _shift) \ 22 + GATE_MTK(_id, _name, _parent, &jpgdec_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv) 29 23 30 24 static const struct mtk_gate jpgdec_clks[] = { 31 25 GATE_JPGDEC(CLK_JPGDEC_JPGDEC1, "jpgdec_jpgdec1", "jpgdec_sel", 0), ··· 39 45 /* sentinel */ 40 46 } 41 47 }; 48 + MODULE_DEVICE_TABLE(of, of_match_clk_mt2712_jpgdec); 42 49 43 50 static struct platform_driver clk_mt2712_jpgdec_drv = { 44 51 .probe = mtk_clk_simple_probe, ··· 49 54 .of_match_table = of_match_clk_mt2712_jpgdec, 50 55 }, 51 56 }; 52 - 53 - builtin_platform_driver(clk_mt2712_jpgdec_drv); 57 + module_platform_driver(clk_mt2712_jpgdec_drv); 58 + MODULE_LICENSE("GPL");
+5 -10
drivers/clk/mediatek/clk-mt2712-mfg.c
··· 18 18 .sta_ofs = 0x0, 19 19 }; 20 20 21 - #define GATE_MFG(_id, _name, _parent, _shift) { \ 22 - .id = _id, \ 23 - .name = _name, \ 24 - .parent_name = _parent, \ 25 - .regs = &mfg_cg_regs, \ 26 - .shift = _shift, \ 27 - .ops = &mtk_clk_gate_ops_setclr, \ 28 - } 21 + #define GATE_MFG(_id, _name, _parent, _shift) \ 22 + GATE_MTK(_id, _name, _parent, &mfg_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 29 23 30 24 static const struct mtk_gate mfg_clks[] = { 31 25 GATE_MFG(CLK_MFG_BG3D, "mfg_bg3d", "mfg_sel", 0), ··· 38 44 /* sentinel */ 39 45 } 40 46 }; 47 + MODULE_DEVICE_TABLE(of, of_match_clk_mt2712_mfg); 41 48 42 49 static struct platform_driver clk_mt2712_mfg_drv = { 43 50 .probe = mtk_clk_simple_probe, ··· 48 53 .of_match_table = of_match_clk_mt2712_mfg, 49 54 }, 50 55 }; 51 - 52 - builtin_platform_driver(clk_mt2712_mfg_drv); 56 + module_platform_driver(clk_mt2712_mfg_drv); 57 + MODULE_LICENSE("GPL");
+20 -46
drivers/clk/mediatek/clk-mt2712-mm.c
··· 30 30 .sta_ofs = 0x220, 31 31 }; 32 32 33 - #define GATE_MM0(_id, _name, _parent, _shift) { \ 34 - .id = _id, \ 35 - .name = _name, \ 36 - .parent_name = _parent, \ 37 - .regs = &mm0_cg_regs, \ 38 - .shift = _shift, \ 39 - .ops = &mtk_clk_gate_ops_setclr, \ 40 - } 33 + #define GATE_MM0(_id, _name, _parent, _shift) \ 34 + GATE_MTK(_id, _name, _parent, &mm0_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 41 35 42 - #define GATE_MM1(_id, _name, _parent, _shift) { \ 43 - .id = _id, \ 44 - .name = _name, \ 45 - .parent_name = _parent, \ 46 - .regs = &mm1_cg_regs, \ 47 - .shift = _shift, \ 48 - .ops = &mtk_clk_gate_ops_setclr, \ 49 - } 36 + #define GATE_MM1(_id, _name, _parent, _shift) \ 37 + GATE_MTK(_id, _name, _parent, &mm1_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 50 38 51 - #define GATE_MM2(_id, _name, _parent, _shift) { \ 52 - .id = _id, \ 53 - .name = _name, \ 54 - .parent_name = _parent, \ 55 - .regs = &mm2_cg_regs, \ 56 - .shift = _shift, \ 57 - .ops = &mtk_clk_gate_ops_setclr, \ 58 - } 39 + #define GATE_MM2(_id, _name, _parent, _shift) \ 40 + GATE_MTK(_id, _name, _parent, &mm2_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 59 41 60 42 static const struct mtk_gate mm_clks[] = { 61 43 /* MM0 */ ··· 108 126 GATE_MM2(CLK_MM_DSI3_DIGITAL, "mm_dsi3_digital", "dsi1_lntc", 6), 109 127 }; 110 128 111 - static int clk_mt2712_mm_probe(struct platform_device *pdev) 112 - { 113 - struct device *dev = &pdev->dev; 114 - struct device_node *node = dev->parent->of_node; 115 - struct clk_hw_onecell_data *clk_data; 116 - int r; 129 + static const struct mtk_clk_desc mm_desc = { 130 + .clks = mm_clks, 131 + .num_clks = ARRAY_SIZE(mm_clks), 132 + }; 117 133 118 - clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK); 119 - 120 - mtk_clk_register_gates(&pdev->dev, node, mm_clks, 121 - ARRAY_SIZE(mm_clks), clk_data); 122 - 123 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 124 - 125 - if (r != 0) 126 - pr_err("%s(): could not register clock provider: %d\n", 127 - __func__, r); 128 - 129 - return r; 130 - } 134 + static const struct platform_device_id clk_mt2712_mm_id_table[] = { 135 + { .name = "clk-mt2712-mm", .driver_data = (kernel_ulong_t)&mm_desc }, 136 + { /* sentinel */ } 137 + }; 138 + MODULE_DEVICE_TABLE(platform, clk_mt2712_mm_id_table); 131 139 132 140 static struct platform_driver clk_mt2712_mm_drv = { 133 - .probe = clk_mt2712_mm_probe, 141 + .probe = mtk_clk_pdev_probe, 142 + .remove = mtk_clk_pdev_remove, 134 143 .driver = { 135 144 .name = "clk-mt2712-mm", 136 145 }, 146 + .id_table = clk_mt2712_mm_id_table, 137 147 }; 138 - 139 - builtin_platform_driver(clk_mt2712_mm_drv); 148 + module_platform_driver(clk_mt2712_mm_drv); 149 + MODULE_LICENSE("GPL");
+7 -18
drivers/clk/mediatek/clk-mt2712-vdec.c
··· 24 24 .sta_ofs = 0x8, 25 25 }; 26 26 27 - #define GATE_VDEC0(_id, _name, _parent, _shift) { \ 28 - .id = _id, \ 29 - .name = _name, \ 30 - .parent_name = _parent, \ 31 - .regs = &vdec0_cg_regs, \ 32 - .shift = _shift, \ 33 - .ops = &mtk_clk_gate_ops_setclr_inv, \ 34 - } 27 + #define GATE_VDEC0(_id, _name, _parent, _shift) \ 28 + GATE_MTK(_id, _name, _parent, &vdec0_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv) 35 29 36 - #define GATE_VDEC1(_id, _name, _parent, _shift) { \ 37 - .id = _id, \ 38 - .name = _name, \ 39 - .parent_name = _parent, \ 40 - .regs = &vdec1_cg_regs, \ 41 - .shift = _shift, \ 42 - .ops = &mtk_clk_gate_ops_setclr_inv, \ 43 - } 30 + #define GATE_VDEC1(_id, _name, _parent, _shift) \ 31 + GATE_MTK(_id, _name, _parent, &vdec1_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv) 44 32 45 33 static const struct mtk_gate vdec_clks[] = { 46 34 /* VDEC0 */ ··· 51 63 /* sentinel */ 52 64 } 53 65 }; 66 + MODULE_DEVICE_TABLE(of, of_match_clk_mt2712_vdec); 54 67 55 68 static struct platform_driver clk_mt2712_vdec_drv = { 56 69 .probe = mtk_clk_simple_probe, ··· 61 72 .of_match_table = of_match_clk_mt2712_vdec, 62 73 }, 63 74 }; 64 - 65 - builtin_platform_driver(clk_mt2712_vdec_drv); 75 + module_platform_driver(clk_mt2712_vdec_drv); 76 + MODULE_LICENSE("GPL");
+5 -10
drivers/clk/mediatek/clk-mt2712-venc.c
··· 18 18 .sta_ofs = 0x0, 19 19 }; 20 20 21 - #define GATE_VENC(_id, _name, _parent, _shift) { \ 22 - .id = _id, \ 23 - .name = _name, \ 24 - .parent_name = _parent, \ 25 - .regs = &venc_cg_regs, \ 26 - .shift = _shift, \ 27 - .ops = &mtk_clk_gate_ops_setclr_inv, \ 28 - } 21 + #define GATE_VENC(_id, _name, _parent, _shift) \ 22 + GATE_MTK(_id, _name, _parent, &venc_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv) 29 23 30 24 static const struct mtk_gate venc_clks[] = { 31 25 GATE_VENC(CLK_VENC_SMI_COMMON_CON, "venc_smi", "mm_sel", 0), ··· 40 46 /* sentinel */ 41 47 } 42 48 }; 49 + MODULE_DEVICE_TABLE(of, of_match_clk_mt2712_venc); 43 50 44 51 static struct platform_driver clk_mt2712_venc_drv = { 45 52 .probe = mtk_clk_simple_probe, ··· 50 55 .of_match_table = of_match_clk_mt2712_venc, 51 56 }, 52 57 }; 53 - 54 - builtin_platform_driver(clk_mt2712_venc_drv); 58 + module_platform_driver(clk_mt2712_venc_drv); 59 + MODULE_LICENSE("GPL");
+268 -736
drivers/clk/mediatek/clk-mt2712.c
··· 14 14 #include <linux/slab.h> 15 15 16 16 #include "clk-gate.h" 17 - #include "clk-pll.h" 18 17 #include "clk-mtk.h" 19 18 20 19 #include <dt-bindings/clock/mt2712-clk.h> ··· 35 36 FIXED_CLK(CLK_TOP_CVBSPLL, "cvbspll", NULL, 108000000), 36 37 }; 37 38 38 - static const struct mtk_fixed_factor top_early_divs[] = { 39 - FACTOR(CLK_TOP_SYS_26M, "sys_26m", "clk26m", 1, 40 - 1), 41 - FACTOR(CLK_TOP_CLK26M_D2, "clk26m_d2", "sys_26m", 1, 42 - 2), 43 - }; 44 - 45 39 static const struct mtk_fixed_factor top_divs[] = { 46 - FACTOR(CLK_TOP_ARMCA35PLL, "armca35pll_ck", "armca35pll", 1, 47 - 1), 48 - FACTOR(CLK_TOP_ARMCA35PLL_600M, "armca35pll_600m", "armca35pll_ck", 1, 49 - 2), 50 - FACTOR(CLK_TOP_ARMCA35PLL_400M, "armca35pll_400m", "armca35pll_ck", 1, 51 - 3), 52 - FACTOR(CLK_TOP_ARMCA72PLL, "armca72pll_ck", "armca72pll", 1, 53 - 1), 54 - FACTOR(CLK_TOP_SYSPLL, "syspll_ck", "mainpll", 1, 55 - 1), 56 - FACTOR(CLK_TOP_SYSPLL_D2, "syspll_d2", "syspll_ck", 1, 57 - 2), 58 - FACTOR(CLK_TOP_SYSPLL1_D2, "syspll1_d2", "syspll_d2", 1, 59 - 2), 60 - FACTOR(CLK_TOP_SYSPLL1_D4, "syspll1_d4", "syspll_d2", 1, 61 - 4), 62 - FACTOR(CLK_TOP_SYSPLL1_D8, "syspll1_d8", "syspll_d2", 1, 63 - 8), 64 - FACTOR(CLK_TOP_SYSPLL1_D16, "syspll1_d16", "syspll_d2", 1, 65 - 16), 66 - FACTOR(CLK_TOP_SYSPLL_D3, "syspll_d3", "syspll_ck", 1, 67 - 3), 68 - FACTOR(CLK_TOP_SYSPLL2_D2, "syspll2_d2", "syspll_d3", 1, 69 - 2), 70 - FACTOR(CLK_TOP_SYSPLL2_D4, "syspll2_d4", "syspll_d3", 1, 71 - 4), 72 - FACTOR(CLK_TOP_SYSPLL_D5, "syspll_d5", "syspll_ck", 1, 73 - 5), 74 - FACTOR(CLK_TOP_SYSPLL3_D2, "syspll3_d2", "syspll_d5", 1, 75 - 2), 76 - FACTOR(CLK_TOP_SYSPLL3_D4, "syspll3_d4", "syspll_d5", 1, 77 - 4), 78 - FACTOR(CLK_TOP_SYSPLL_D7, "syspll_d7", "syspll_ck", 1, 79 - 7), 80 - FACTOR(CLK_TOP_SYSPLL4_D2, "syspll4_d2", "syspll_d7", 1, 81 - 2), 82 - FACTOR(CLK_TOP_SYSPLL4_D4, "syspll4_d4", "syspll_d7", 1, 83 - 4), 84 - FACTOR(CLK_TOP_UNIVPLL, "univpll_ck", "univpll", 1, 85 - 1), 86 - FACTOR(CLK_TOP_UNIVPLL_D7, "univpll_d7", "univpll_ck", 1, 87 - 7), 88 - FACTOR(CLK_TOP_UNIVPLL_D26, "univpll_d26", "univpll_ck", 1, 89 - 26), 90 - FACTOR(CLK_TOP_UNIVPLL_D52, "univpll_d52", "univpll_ck", 1, 91 - 52), 92 - FACTOR(CLK_TOP_UNIVPLL_D104, "univpll_d104", "univpll_ck", 1, 93 - 104), 94 - FACTOR(CLK_TOP_UNIVPLL_D208, "univpll_d208", "univpll_ck", 1, 95 - 208), 96 - FACTOR(CLK_TOP_UNIVPLL_D2, "univpll_d2", "univpll_ck", 1, 97 - 2), 98 - FACTOR(CLK_TOP_UNIVPLL1_D2, "univpll1_d2", "univpll_d2", 1, 99 - 2), 100 - FACTOR(CLK_TOP_UNIVPLL1_D4, "univpll1_d4", "univpll_d2", 1, 101 - 4), 102 - FACTOR(CLK_TOP_UNIVPLL1_D8, "univpll1_d8", "univpll_d2", 1, 103 - 8), 104 - FACTOR(CLK_TOP_UNIVPLL_D3, "univpll_d3", "univpll_ck", 1, 105 - 3), 106 - FACTOR(CLK_TOP_UNIVPLL2_D2, "univpll2_d2", "univpll_d3", 1, 107 - 2), 108 - FACTOR(CLK_TOP_UNIVPLL2_D4, "univpll2_d4", "univpll_d3", 1, 109 - 4), 110 - FACTOR(CLK_TOP_UNIVPLL2_D8, "univpll2_d8", "univpll_d3", 1, 111 - 8), 112 - FACTOR(CLK_TOP_UNIVPLL_D5, "univpll_d5", "univpll_ck", 1, 113 - 5), 114 - FACTOR(CLK_TOP_UNIVPLL3_D2, "univpll3_d2", "univpll_d5", 1, 115 - 2), 116 - FACTOR(CLK_TOP_UNIVPLL3_D4, "univpll3_d4", "univpll_d5", 1, 117 - 4), 118 - FACTOR(CLK_TOP_UNIVPLL3_D8, "univpll3_d8", "univpll_d5", 1, 119 - 8), 120 - FACTOR(CLK_TOP_F_MP0_PLL1, "f_mp0_pll1_ck", "univpll_d2", 1, 121 - 1), 122 - FACTOR(CLK_TOP_F_MP0_PLL2, "f_mp0_pll2_ck", "univpll1_d2", 1, 123 - 1), 124 - FACTOR(CLK_TOP_F_BIG_PLL1, "f_big_pll1_ck", "univpll_d2", 1, 125 - 1), 126 - FACTOR(CLK_TOP_F_BIG_PLL2, "f_big_pll2_ck", "univpll1_d2", 1, 127 - 1), 128 - FACTOR(CLK_TOP_F_BUS_PLL1, "f_bus_pll1_ck", "univpll_d2", 1, 129 - 1), 130 - FACTOR(CLK_TOP_F_BUS_PLL2, "f_bus_pll2_ck", "univpll1_d2", 1, 131 - 1), 132 - FACTOR(CLK_TOP_APLL1, "apll1_ck", "apll1", 1, 133 - 1), 134 - FACTOR(CLK_TOP_APLL1_D2, "apll1_d2", "apll1_ck", 1, 135 - 2), 136 - FACTOR(CLK_TOP_APLL1_D4, "apll1_d4", "apll1_ck", 1, 137 - 4), 138 - FACTOR(CLK_TOP_APLL1_D8, "apll1_d8", "apll1_ck", 1, 139 - 8), 140 - FACTOR(CLK_TOP_APLL1_D16, "apll1_d16", "apll1_ck", 1, 141 - 16), 142 - FACTOR(CLK_TOP_APLL2, "apll2_ck", "apll2", 1, 143 - 1), 144 - FACTOR(CLK_TOP_APLL2_D2, "apll2_d2", "apll2_ck", 1, 145 - 2), 146 - FACTOR(CLK_TOP_APLL2_D4, "apll2_d4", "apll2_ck", 1, 147 - 4), 148 - FACTOR(CLK_TOP_APLL2_D8, "apll2_d8", "apll2_ck", 1, 149 - 8), 150 - FACTOR(CLK_TOP_APLL2_D16, "apll2_d16", "apll2_ck", 1, 151 - 16), 152 - FACTOR(CLK_TOP_LVDSPLL, "lvdspll_ck", "lvdspll", 1, 153 - 1), 154 - FACTOR(CLK_TOP_LVDSPLL_D2, "lvdspll_d2", "lvdspll_ck", 1, 155 - 2), 156 - FACTOR(CLK_TOP_LVDSPLL_D4, "lvdspll_d4", "lvdspll_ck", 1, 157 - 4), 158 - FACTOR(CLK_TOP_LVDSPLL_D8, "lvdspll_d8", "lvdspll_ck", 1, 159 - 8), 160 - FACTOR(CLK_TOP_LVDSPLL2, "lvdspll2_ck", "lvdspll2", 1, 161 - 1), 162 - FACTOR(CLK_TOP_LVDSPLL2_D2, "lvdspll2_d2", "lvdspll2_ck", 1, 163 - 2), 164 - FACTOR(CLK_TOP_LVDSPLL2_D4, "lvdspll2_d4", "lvdspll2_ck", 1, 165 - 4), 166 - FACTOR(CLK_TOP_LVDSPLL2_D8, "lvdspll2_d8", "lvdspll2_ck", 1, 167 - 8), 168 - FACTOR(CLK_TOP_ETHERPLL_125M, "etherpll_125m", "etherpll", 1, 169 - 1), 170 - FACTOR(CLK_TOP_ETHERPLL_50M, "etherpll_50m", "etherpll", 1, 171 - 1), 172 - FACTOR(CLK_TOP_CVBS, "cvbs", "cvbspll", 1, 173 - 1), 174 - FACTOR(CLK_TOP_CVBS_D2, "cvbs_d2", "cvbs", 1, 175 - 2), 176 - FACTOR(CLK_TOP_MMPLL, "mmpll_ck", "mmpll", 1, 177 - 1), 178 - FACTOR(CLK_TOP_MMPLL_D2, "mmpll_d2", "mmpll_ck", 1, 179 - 2), 180 - FACTOR(CLK_TOP_VENCPLL, "vencpll_ck", "vencpll", 1, 181 - 1), 182 - FACTOR(CLK_TOP_VENCPLL_D2, "vencpll_d2", "vencpll_ck", 1, 183 - 2), 184 - FACTOR(CLK_TOP_VCODECPLL, "vcodecpll_ck", "vcodecpll", 1, 185 - 1), 186 - FACTOR(CLK_TOP_VCODECPLL_D2, "vcodecpll_d2", "vcodecpll_ck", 1, 187 - 2), 188 - FACTOR(CLK_TOP_TVDPLL, "tvdpll_ck", "tvdpll", 1, 189 - 1), 190 - FACTOR(CLK_TOP_TVDPLL_D2, "tvdpll_d2", "tvdpll_ck", 1, 191 - 2), 192 - FACTOR(CLK_TOP_TVDPLL_D4, "tvdpll_d4", "tvdpll_ck", 1, 193 - 4), 194 - FACTOR(CLK_TOP_TVDPLL_D8, "tvdpll_d8", "tvdpll_ck", 1, 195 - 8), 196 - FACTOR(CLK_TOP_TVDPLL_429M, "tvdpll_429m", "tvdpll", 1, 197 - 1), 198 - FACTOR(CLK_TOP_TVDPLL_429M_D2, "tvdpll_429m_d2", "tvdpll_429m", 1, 199 - 2), 200 - FACTOR(CLK_TOP_TVDPLL_429M_D4, "tvdpll_429m_d4", "tvdpll_429m", 1, 201 - 4), 202 - FACTOR(CLK_TOP_MSDCPLL, "msdcpll_ck", "msdcpll", 1, 203 - 1), 204 - FACTOR(CLK_TOP_MSDCPLL_D2, "msdcpll_d2", "msdcpll_ck", 1, 205 - 2), 206 - FACTOR(CLK_TOP_MSDCPLL_D4, "msdcpll_d4", "msdcpll_ck", 1, 207 - 4), 208 - FACTOR(CLK_TOP_MSDCPLL2, "msdcpll2_ck", "msdcpll2", 1, 209 - 1), 210 - FACTOR(CLK_TOP_MSDCPLL2_D2, "msdcpll2_d2", "msdcpll2_ck", 1, 211 - 2), 212 - FACTOR(CLK_TOP_MSDCPLL2_D4, "msdcpll2_d4", "msdcpll2_ck", 1, 213 - 4), 214 - FACTOR(CLK_TOP_D2A_ULCLK_6P5M, "d2a_ulclk_6p5m", "clk26m", 1, 215 - 4), 216 - FACTOR(CLK_TOP_APLL1_D3, "apll1_d3", "apll1_ck", 1, 217 - 3), 218 - FACTOR(CLK_TOP_APLL2_D3, "apll2_d3", "apll2_ck", 1, 219 - 3), 40 + FACTOR(CLK_TOP_SYS_26M, "sys_26m", "clk26m", 1, 1), 41 + FACTOR(CLK_TOP_CLK26M_D2, "clk26m_d2", "sys_26m", 1, 2), 42 + FACTOR(CLK_TOP_ARMCA35PLL, "armca35pll_ck", "armca35pll", 1, 1), 43 + FACTOR(CLK_TOP_ARMCA35PLL_600M, "armca35pll_600m", "armca35pll_ck", 1, 2), 44 + FACTOR(CLK_TOP_ARMCA35PLL_400M, "armca35pll_400m", "armca35pll_ck", 1, 3), 45 + FACTOR(CLK_TOP_ARMCA72PLL, "armca72pll_ck", "armca72pll", 1, 1), 46 + FACTOR(CLK_TOP_SYSPLL, "syspll_ck", "mainpll", 1, 1), 47 + FACTOR(CLK_TOP_SYSPLL_D2, "syspll_d2", "syspll_ck", 1, 2), 48 + FACTOR(CLK_TOP_SYSPLL1_D2, "syspll1_d2", "syspll_d2", 1, 2), 49 + FACTOR(CLK_TOP_SYSPLL1_D4, "syspll1_d4", "syspll_d2", 1, 4), 50 + FACTOR(CLK_TOP_SYSPLL1_D8, "syspll1_d8", "syspll_d2", 1, 8), 51 + FACTOR(CLK_TOP_SYSPLL1_D16, "syspll1_d16", "syspll_d2", 1, 16), 52 + FACTOR(CLK_TOP_SYSPLL_D3, "syspll_d3", "syspll_ck", 1, 3), 53 + FACTOR(CLK_TOP_SYSPLL2_D2, "syspll2_d2", "syspll_d3", 1, 2), 54 + FACTOR(CLK_TOP_SYSPLL2_D4, "syspll2_d4", "syspll_d3", 1, 4), 55 + FACTOR(CLK_TOP_SYSPLL_D5, "syspll_d5", "syspll_ck", 1, 5), 56 + FACTOR(CLK_TOP_SYSPLL3_D2, "syspll3_d2", "syspll_d5", 1, 2), 57 + FACTOR(CLK_TOP_SYSPLL3_D4, "syspll3_d4", "syspll_d5", 1, 4), 58 + FACTOR(CLK_TOP_SYSPLL_D7, "syspll_d7", "syspll_ck", 1, 7), 59 + FACTOR(CLK_TOP_SYSPLL4_D2, "syspll4_d2", "syspll_d7", 1, 2), 60 + FACTOR(CLK_TOP_SYSPLL4_D4, "syspll4_d4", "syspll_d7", 1, 4), 61 + FACTOR(CLK_TOP_UNIVPLL, "univpll_ck", "univpll", 1, 1), 62 + FACTOR(CLK_TOP_UNIVPLL_D7, "univpll_d7", "univpll_ck", 1, 7), 63 + FACTOR(CLK_TOP_UNIVPLL_D26, "univpll_d26", "univpll_ck", 1, 26), 64 + FACTOR(CLK_TOP_UNIVPLL_D52, "univpll_d52", "univpll_ck", 1, 52), 65 + FACTOR(CLK_TOP_UNIVPLL_D104, "univpll_d104", "univpll_ck", 1, 104), 66 + FACTOR(CLK_TOP_UNIVPLL_D208, "univpll_d208", "univpll_ck", 1, 208), 67 + FACTOR(CLK_TOP_UNIVPLL_D2, "univpll_d2", "univpll_ck", 1, 2), 68 + FACTOR(CLK_TOP_UNIVPLL1_D2, "univpll1_d2", "univpll_d2", 1, 2), 69 + FACTOR(CLK_TOP_UNIVPLL1_D4, "univpll1_d4", "univpll_d2", 1, 4), 70 + FACTOR(CLK_TOP_UNIVPLL1_D8, "univpll1_d8", "univpll_d2", 1, 8), 71 + FACTOR(CLK_TOP_UNIVPLL_D3, "univpll_d3", "univpll_ck", 1, 3), 72 + FACTOR(CLK_TOP_UNIVPLL2_D2, "univpll2_d2", "univpll_d3", 1, 2), 73 + FACTOR(CLK_TOP_UNIVPLL2_D4, "univpll2_d4", "univpll_d3", 1, 4), 74 + FACTOR(CLK_TOP_UNIVPLL2_D8, "univpll2_d8", "univpll_d3", 1, 8), 75 + FACTOR(CLK_TOP_UNIVPLL_D5, "univpll_d5", "univpll_ck", 1, 5), 76 + FACTOR(CLK_TOP_UNIVPLL3_D2, "univpll3_d2", "univpll_d5", 1, 2), 77 + FACTOR(CLK_TOP_UNIVPLL3_D4, "univpll3_d4", "univpll_d5", 1, 4), 78 + FACTOR(CLK_TOP_UNIVPLL3_D8, "univpll3_d8", "univpll_d5", 1, 8), 79 + FACTOR(CLK_TOP_F_MP0_PLL1, "f_mp0_pll1_ck", "univpll_d2", 1, 1), 80 + FACTOR(CLK_TOP_F_MP0_PLL2, "f_mp0_pll2_ck", "univpll1_d2", 1, 1), 81 + FACTOR(CLK_TOP_F_BIG_PLL1, "f_big_pll1_ck", "univpll_d2", 1, 1), 82 + FACTOR(CLK_TOP_F_BIG_PLL2, "f_big_pll2_ck", "univpll1_d2", 1, 1), 83 + FACTOR(CLK_TOP_F_BUS_PLL1, "f_bus_pll1_ck", "univpll_d2", 1, 1), 84 + FACTOR(CLK_TOP_F_BUS_PLL2, "f_bus_pll2_ck", "univpll1_d2", 1, 1), 85 + FACTOR(CLK_TOP_APLL1, "apll1_ck", "apll1", 1, 1), 86 + FACTOR(CLK_TOP_APLL1_D2, "apll1_d2", "apll1_ck", 1, 2), 87 + FACTOR(CLK_TOP_APLL1_D4, "apll1_d4", "apll1_ck", 1, 4), 88 + FACTOR(CLK_TOP_APLL1_D8, "apll1_d8", "apll1_ck", 1, 8), 89 + FACTOR(CLK_TOP_APLL1_D16, "apll1_d16", "apll1_ck", 1, 16), 90 + FACTOR(CLK_TOP_APLL2, "apll2_ck", "apll2", 1, 1), 91 + FACTOR(CLK_TOP_APLL2_D2, "apll2_d2", "apll2_ck", 1, 2), 92 + FACTOR(CLK_TOP_APLL2_D4, "apll2_d4", "apll2_ck", 1, 4), 93 + FACTOR(CLK_TOP_APLL2_D8, "apll2_d8", "apll2_ck", 1, 8), 94 + FACTOR(CLK_TOP_APLL2_D16, "apll2_d16", "apll2_ck", 1, 16), 95 + FACTOR(CLK_TOP_LVDSPLL, "lvdspll_ck", "lvdspll", 1, 1), 96 + FACTOR(CLK_TOP_LVDSPLL_D2, "lvdspll_d2", "lvdspll_ck", 1, 2), 97 + FACTOR(CLK_TOP_LVDSPLL_D4, "lvdspll_d4", "lvdspll_ck", 1, 4), 98 + FACTOR(CLK_TOP_LVDSPLL_D8, "lvdspll_d8", "lvdspll_ck", 1, 8), 99 + FACTOR(CLK_TOP_LVDSPLL2, "lvdspll2_ck", "lvdspll2", 1, 1), 100 + FACTOR(CLK_TOP_LVDSPLL2_D2, "lvdspll2_d2", "lvdspll2_ck", 1, 2), 101 + FACTOR(CLK_TOP_LVDSPLL2_D4, "lvdspll2_d4", "lvdspll2_ck", 1, 4), 102 + FACTOR(CLK_TOP_LVDSPLL2_D8, "lvdspll2_d8", "lvdspll2_ck", 1, 8), 103 + FACTOR(CLK_TOP_ETHERPLL_125M, "etherpll_125m", "etherpll", 1, 1), 104 + FACTOR(CLK_TOP_ETHERPLL_50M, "etherpll_50m", "etherpll", 1, 1), 105 + FACTOR(CLK_TOP_CVBS, "cvbs", "cvbspll", 1, 1), 106 + FACTOR(CLK_TOP_CVBS_D2, "cvbs_d2", "cvbs", 1, 2), 107 + FACTOR(CLK_TOP_MMPLL, "mmpll_ck", "mmpll", 1, 1), 108 + FACTOR(CLK_TOP_MMPLL_D2, "mmpll_d2", "mmpll_ck", 1, 2), 109 + FACTOR(CLK_TOP_VENCPLL, "vencpll_ck", "vencpll", 1, 1), 110 + FACTOR(CLK_TOP_VENCPLL_D2, "vencpll_d2", "vencpll_ck", 1, 2), 111 + FACTOR(CLK_TOP_VCODECPLL, "vcodecpll_ck", "vcodecpll", 1, 1), 112 + FACTOR(CLK_TOP_VCODECPLL_D2, "vcodecpll_d2", "vcodecpll_ck", 1, 2), 113 + FACTOR(CLK_TOP_TVDPLL, "tvdpll_ck", "tvdpll", 1, 1), 114 + FACTOR(CLK_TOP_TVDPLL_D2, "tvdpll_d2", "tvdpll_ck", 1, 2), 115 + FACTOR(CLK_TOP_TVDPLL_D4, "tvdpll_d4", "tvdpll_ck", 1, 4), 116 + FACTOR(CLK_TOP_TVDPLL_D8, "tvdpll_d8", "tvdpll_ck", 1, 8), 117 + FACTOR(CLK_TOP_TVDPLL_429M, "tvdpll_429m", "tvdpll", 1, 1), 118 + FACTOR(CLK_TOP_TVDPLL_429M_D2, "tvdpll_429m_d2", "tvdpll_429m", 1, 2), 119 + FACTOR(CLK_TOP_TVDPLL_429M_D4, "tvdpll_429m_d4", "tvdpll_429m", 1, 4), 120 + FACTOR(CLK_TOP_MSDCPLL, "msdcpll_ck", "msdcpll", 1, 1), 121 + FACTOR(CLK_TOP_MSDCPLL_D2, "msdcpll_d2", "msdcpll_ck", 1, 2), 122 + FACTOR(CLK_TOP_MSDCPLL_D4, "msdcpll_d4", "msdcpll_ck", 1, 4), 123 + FACTOR(CLK_TOP_MSDCPLL2, "msdcpll2_ck", "msdcpll2", 1, 1), 124 + FACTOR(CLK_TOP_MSDCPLL2_D2, "msdcpll2_d2", "msdcpll2_ck", 1, 2), 125 + FACTOR(CLK_TOP_MSDCPLL2_D4, "msdcpll2_d4", "msdcpll2_ck", 1, 4), 126 + FACTOR(CLK_TOP_D2A_ULCLK_6P5M, "d2a_ulclk_6p5m", "clk26m", 1, 4), 127 + FACTOR(CLK_TOP_APLL1_D3, "apll1_d3", "apll1_ck", 1, 3), 128 + FACTOR(CLK_TOP_APLL2_D3, "apll2_d3", "apll2_ck", 1, 3), 220 129 }; 221 130 222 131 static const char * const axi_parents[] = { ··· 644 737 static struct mtk_composite top_muxes[] = { 645 738 /* CLK_CFG_0 */ 646 739 MUX_GATE_FLAGS(CLK_TOP_AXI_SEL, "axi_sel", axi_parents, 0x040, 0, 3, 647 - 7, CLK_IS_CRITICAL), 740 + 7, CLK_IS_CRITICAL), 648 741 MUX_GATE_FLAGS(CLK_TOP_MEM_SEL, "mem_sel", mem_parents, 0x040, 8, 1, 649 - 15, CLK_IS_CRITICAL), 650 - MUX_GATE(CLK_TOP_MM_SEL, "mm_sel", 651 - mm_parents, 0x040, 24, 3, 31), 742 + 15, CLK_IS_CRITICAL), 743 + MUX_GATE(CLK_TOP_MM_SEL, "mm_sel", mm_parents, 0x040, 24, 3, 31), 652 744 /* CLK_CFG_1 */ 653 - MUX_GATE(CLK_TOP_PWM_SEL, "pwm_sel", 654 - pwm_parents, 0x050, 0, 2, 7), 655 - MUX_GATE(CLK_TOP_VDEC_SEL, "vdec_sel", 656 - vdec_parents, 0x050, 8, 4, 15), 657 - MUX_GATE(CLK_TOP_VENC_SEL, "venc_sel", 658 - venc_parents, 0x050, 16, 4, 23), 659 - MUX_GATE(CLK_TOP_MFG_SEL, "mfg_sel", 660 - mfg_parents, 0x050, 24, 4, 31), 745 + MUX_GATE(CLK_TOP_PWM_SEL, "pwm_sel", pwm_parents, 0x050, 0, 2, 7), 746 + MUX_GATE(CLK_TOP_VDEC_SEL, "vdec_sel", vdec_parents, 0x050, 8, 4, 15), 747 + MUX_GATE(CLK_TOP_VENC_SEL, "venc_sel", venc_parents, 0x050, 16, 4, 23), 748 + MUX_GATE(CLK_TOP_MFG_SEL, "mfg_sel", mfg_parents, 0x050, 24, 4, 31), 661 749 /* CLK_CFG_2 */ 662 - MUX_GATE(CLK_TOP_CAMTG_SEL, "camtg_sel", 663 - camtg_parents, 0x060, 0, 4, 7), 664 - MUX_GATE(CLK_TOP_UART_SEL, "uart_sel", 665 - uart_parents, 0x060, 8, 1, 15), 666 - MUX_GATE(CLK_TOP_SPI_SEL, "spi_sel", 667 - spi_parents, 0x060, 16, 3, 23), 668 - MUX_GATE(CLK_TOP_USB20_SEL, "usb20_sel", 669 - usb20_parents, 0x060, 24, 2, 31), 750 + MUX_GATE(CLK_TOP_CAMTG_SEL, "camtg_sel", camtg_parents, 0x060, 0, 4, 7), 751 + MUX_GATE(CLK_TOP_UART_SEL, "uart_sel", uart_parents, 0x060, 8, 1, 15), 752 + MUX_GATE(CLK_TOP_SPI_SEL, "spi_sel", spi_parents, 0x060, 16, 3, 23), 753 + MUX_GATE(CLK_TOP_USB20_SEL, "usb20_sel", usb20_parents, 0x060, 24, 2, 31), 670 754 /* CLK_CFG_3 */ 671 - MUX_GATE(CLK_TOP_USB30_SEL, "usb30_sel", 672 - usb30_parents, 0x070, 0, 2, 7), 673 - MUX_GATE(CLK_TOP_MSDC50_0_HCLK_SEL, "msdc50_0_h_sel", 674 - msdc50_0_h_parents, 0x070, 8, 3, 15), 675 - MUX_GATE(CLK_TOP_MSDC50_0_SEL, "msdc50_0_sel", 676 - msdc50_0_parents, 0x070, 16, 4, 23), 677 - MUX_GATE(CLK_TOP_MSDC30_1_SEL, "msdc30_1_sel", 678 - msdc30_1_parents, 0x070, 24, 3, 31), 755 + MUX_GATE(CLK_TOP_USB30_SEL, "usb30_sel", usb30_parents, 0x070, 0, 2, 7), 756 + MUX_GATE(CLK_TOP_MSDC50_0_HCLK_SEL, "msdc50_0_h_sel", msdc50_0_h_parents, 757 + 0x070, 8, 3, 15), 758 + MUX_GATE(CLK_TOP_MSDC50_0_SEL, "msdc50_0_sel", msdc50_0_parents, 759 + 0x070, 16, 4, 23), 760 + MUX_GATE(CLK_TOP_MSDC30_1_SEL, "msdc30_1_sel", msdc30_1_parents, 761 + 0x070, 24, 3, 31), 679 762 /* CLK_CFG_4 */ 680 - MUX_GATE(CLK_TOP_MSDC30_2_SEL, "msdc30_2_sel", 681 - msdc30_1_parents, 0x080, 0, 3, 7), 682 - MUX_GATE(CLK_TOP_MSDC30_3_SEL, "msdc30_3_sel", 683 - msdc30_3_parents, 0x080, 8, 4, 15), 684 - MUX_GATE(CLK_TOP_AUDIO_SEL, "audio_sel", 685 - audio_parents, 0x080, 16, 2, 23), 686 - MUX_GATE(CLK_TOP_AUD_INTBUS_SEL, "aud_intbus_sel", 687 - aud_intbus_parents, 0x080, 24, 3, 31), 763 + MUX_GATE(CLK_TOP_MSDC30_2_SEL, "msdc30_2_sel", msdc30_1_parents, 764 + 0x080, 0, 3, 7), 765 + MUX_GATE(CLK_TOP_MSDC30_3_SEL, "msdc30_3_sel", msdc30_3_parents, 766 + 0x080, 8, 4, 15), 767 + MUX_GATE(CLK_TOP_AUDIO_SEL, "audio_sel", audio_parents, 768 + 0x080, 16, 2, 23), 769 + MUX_GATE(CLK_TOP_AUD_INTBUS_SEL, "aud_intbus_sel", aud_intbus_parents, 770 + 0x080, 24, 3, 31), 688 771 /* CLK_CFG_5 */ 689 - MUX_GATE(CLK_TOP_PMICSPI_SEL, "pmicspi_sel", 690 - pmicspi_parents, 0x090, 0, 3, 7), 691 - MUX_GATE(CLK_TOP_DPILVDS1_SEL, "dpilvds1_sel", 692 - dpilvds1_parents, 0x090, 8, 3, 15), 693 - MUX_GATE(CLK_TOP_ATB_SEL, "atb_sel", 694 - atb_parents, 0x090, 16, 2, 23), 695 - MUX_GATE(CLK_TOP_NR_SEL, "nr_sel", 696 - nr_parents, 0x090, 24, 3, 31), 772 + MUX_GATE(CLK_TOP_PMICSPI_SEL, "pmicspi_sel", pmicspi_parents, 0x090, 0, 3, 7), 773 + MUX_GATE(CLK_TOP_DPILVDS1_SEL, "dpilvds1_sel", dpilvds1_parents, 774 + 0x090, 8, 3, 15), 775 + MUX_GATE(CLK_TOP_ATB_SEL, "atb_sel", atb_parents, 0x090, 16, 2, 23), 776 + MUX_GATE(CLK_TOP_NR_SEL, "nr_sel", nr_parents, 0x090, 24, 3, 31), 697 777 /* CLK_CFG_6 */ 698 - MUX_GATE(CLK_TOP_NFI2X_SEL, "nfi2x_sel", 699 - nfi2x_parents, 0x0a0, 0, 4, 7), 700 - MUX_GATE(CLK_TOP_IRDA_SEL, "irda_sel", 701 - irda_parents, 0x0a0, 8, 2, 15), 702 - MUX_GATE(CLK_TOP_CCI400_SEL, "cci400_sel", 703 - cci400_parents, 0x0a0, 16, 3, 23), 704 - MUX_GATE(CLK_TOP_AUD_1_SEL, "aud_1_sel", 705 - aud_1_parents, 0x0a0, 24, 2, 31), 778 + MUX_GATE(CLK_TOP_NFI2X_SEL, "nfi2x_sel", nfi2x_parents, 0x0a0, 0, 4, 7), 779 + MUX_GATE(CLK_TOP_IRDA_SEL, "irda_sel", irda_parents, 0x0a0, 8, 2, 15), 780 + MUX_GATE(CLK_TOP_CCI400_SEL, "cci400_sel", cci400_parents, 0x0a0, 16, 3, 23), 781 + MUX_GATE(CLK_TOP_AUD_1_SEL, "aud_1_sel", aud_1_parents, 0x0a0, 24, 2, 31), 706 782 /* CLK_CFG_7 */ 707 - MUX_GATE(CLK_TOP_AUD_2_SEL, "aud_2_sel", 708 - aud_2_parents, 0x0b0, 0, 2, 7), 709 - MUX_GATE(CLK_TOP_MEM_MFG_IN_AS_SEL, "mem_mfg_sel", 710 - mem_mfg_parents, 0x0b0, 8, 2, 15), 711 - MUX_GATE(CLK_TOP_AXI_MFG_IN_AS_SEL, "axi_mfg_sel", 712 - axi_mfg_parents, 0x0b0, 16, 2, 23), 713 - MUX_GATE(CLK_TOP_SCAM_SEL, "scam_sel", 714 - scam_parents, 0x0b0, 24, 2, 31), 783 + MUX_GATE(CLK_TOP_AUD_2_SEL, "aud_2_sel", aud_2_parents, 0x0b0, 0, 2, 7), 784 + MUX_GATE(CLK_TOP_MEM_MFG_IN_AS_SEL, "mem_mfg_sel", mem_mfg_parents, 785 + 0x0b0, 8, 2, 15), 786 + MUX_GATE(CLK_TOP_AXI_MFG_IN_AS_SEL, "axi_mfg_sel", axi_mfg_parents, 787 + 0x0b0, 16, 2, 23), 788 + MUX_GATE(CLK_TOP_SCAM_SEL, "scam_sel", scam_parents, 0x0b0, 24, 2, 31), 715 789 /* CLK_CFG_8 */ 716 - MUX_GATE(CLK_TOP_NFIECC_SEL, "nfiecc_sel", 717 - nfiecc_parents, 0x0c0, 0, 3, 7), 718 - MUX_GATE(CLK_TOP_PE2_MAC_P0_SEL, "pe2_mac_p0_sel", 719 - pe2_mac_p0_parents, 0x0c0, 8, 3, 15), 720 - MUX_GATE(CLK_TOP_PE2_MAC_P1_SEL, "pe2_mac_p1_sel", 721 - pe2_mac_p0_parents, 0x0c0, 16, 3, 23), 722 - MUX_GATE(CLK_TOP_DPILVDS_SEL, "dpilvds_sel", 723 - dpilvds_parents, 0x0c0, 24, 3, 31), 790 + MUX_GATE(CLK_TOP_NFIECC_SEL, "nfiecc_sel", nfiecc_parents, 0x0c0, 0, 3, 7), 791 + MUX_GATE(CLK_TOP_PE2_MAC_P0_SEL, "pe2_mac_p0_sel", pe2_mac_p0_parents, 792 + 0x0c0, 8, 3, 15), 793 + MUX_GATE(CLK_TOP_PE2_MAC_P1_SEL, "pe2_mac_p1_sel", pe2_mac_p0_parents, 794 + 0x0c0, 16, 3, 23), 795 + MUX_GATE(CLK_TOP_DPILVDS_SEL, "dpilvds_sel", dpilvds_parents, 0x0c0, 24, 3, 31), 724 796 /* CLK_CFG_9 */ 725 - MUX_GATE(CLK_TOP_MSDC50_3_HCLK_SEL, "msdc50_3_h_sel", 726 - msdc50_0_h_parents, 0x0d0, 0, 3, 7), 727 - MUX_GATE(CLK_TOP_HDCP_SEL, "hdcp_sel", 728 - hdcp_parents, 0x0d0, 8, 2, 15), 729 - MUX_GATE(CLK_TOP_HDCP_24M_SEL, "hdcp_24m_sel", 730 - hdcp_24m_parents, 0x0d0, 16, 2, 23), 731 - MUX_GATE_FLAGS(CLK_TOP_RTC_SEL, "rtc_sel", rtc_parents, 0x0d0, 24, 2, 732 - 31, CLK_IS_CRITICAL), 797 + MUX_GATE(CLK_TOP_MSDC50_3_HCLK_SEL, "msdc50_3_h_sel", msdc50_0_h_parents, 798 + 0x0d0, 0, 3, 7), 799 + MUX_GATE(CLK_TOP_HDCP_SEL, "hdcp_sel", hdcp_parents, 0x0d0, 8, 2, 15), 800 + MUX_GATE(CLK_TOP_HDCP_24M_SEL, "hdcp_24m_sel", hdcp_24m_parents, 801 + 0x0d0, 16, 2, 23), 802 + MUX_GATE_FLAGS(CLK_TOP_RTC_SEL, "rtc_sel", rtc_parents, 803 + 0x0d0, 24, 2, 31, CLK_IS_CRITICAL), 733 804 /* CLK_CFG_10 */ 734 - MUX_GATE(CLK_TOP_SPINOR_SEL, "spinor_sel", 735 - spinor_parents, 0x500, 0, 4, 7), 736 - MUX_GATE(CLK_TOP_APLL_SEL, "apll_sel", 737 - apll_parents, 0x500, 8, 4, 15), 738 - MUX_GATE(CLK_TOP_APLL2_SEL, "apll2_sel", 739 - apll_parents, 0x500, 16, 4, 23), 740 - MUX_GATE(CLK_TOP_A1SYS_HP_SEL, "a1sys_hp_sel", 741 - a1sys_hp_parents, 0x500, 24, 3, 31), 805 + MUX_GATE(CLK_TOP_SPINOR_SEL, "spinor_sel", spinor_parents, 0x500, 0, 4, 7), 806 + MUX_GATE(CLK_TOP_APLL_SEL, "apll_sel", apll_parents, 0x500, 8, 4, 15), 807 + MUX_GATE(CLK_TOP_APLL2_SEL, "apll2_sel", apll_parents, 0x500, 16, 4, 23), 808 + MUX_GATE(CLK_TOP_A1SYS_HP_SEL, "a1sys_hp_sel", a1sys_hp_parents, 809 + 0x500, 24, 3, 31), 742 810 /* CLK_CFG_11 */ 743 - MUX_GATE(CLK_TOP_A2SYS_HP_SEL, "a2sys_hp_sel", 744 - a2sys_hp_parents, 0x510, 0, 3, 7), 745 - MUX_GATE(CLK_TOP_ASM_L_SEL, "asm_l_sel", 746 - asm_l_parents, 0x510, 8, 2, 15), 747 - MUX_GATE(CLK_TOP_ASM_M_SEL, "asm_m_sel", 748 - asm_l_parents, 0x510, 16, 2, 23), 749 - MUX_GATE(CLK_TOP_ASM_H_SEL, "asm_h_sel", 750 - asm_l_parents, 0x510, 24, 2, 31), 811 + MUX_GATE(CLK_TOP_A2SYS_HP_SEL, "a2sys_hp_sel", a2sys_hp_parents, 0x510, 0, 3, 7), 812 + MUX_GATE(CLK_TOP_ASM_L_SEL, "asm_l_sel", asm_l_parents, 0x510, 8, 2, 15), 813 + MUX_GATE(CLK_TOP_ASM_M_SEL, "asm_m_sel", asm_l_parents, 0x510, 16, 2, 23), 814 + MUX_GATE(CLK_TOP_ASM_H_SEL, "asm_h_sel", asm_l_parents, 0x510, 24, 2, 31), 751 815 /* CLK_CFG_12 */ 752 - MUX_GATE(CLK_TOP_I2SO1_SEL, "i2so1_sel", 753 - i2so1_parents, 0x520, 0, 2, 7), 754 - MUX_GATE(CLK_TOP_I2SO2_SEL, "i2so2_sel", 755 - i2so1_parents, 0x520, 8, 2, 15), 756 - MUX_GATE(CLK_TOP_I2SO3_SEL, "i2so3_sel", 757 - i2so1_parents, 0x520, 16, 2, 23), 758 - MUX_GATE(CLK_TOP_TDMO0_SEL, "tdmo0_sel", 759 - i2so1_parents, 0x520, 24, 2, 31), 816 + MUX_GATE(CLK_TOP_I2SO1_SEL, "i2so1_sel", i2so1_parents, 0x520, 0, 2, 7), 817 + MUX_GATE(CLK_TOP_I2SO2_SEL, "i2so2_sel", i2so1_parents, 0x520, 8, 2, 15), 818 + MUX_GATE(CLK_TOP_I2SO3_SEL, "i2so3_sel", i2so1_parents, 0x520, 16, 2, 23), 819 + MUX_GATE(CLK_TOP_TDMO0_SEL, "tdmo0_sel", i2so1_parents, 0x520, 24, 2, 31), 760 820 /* CLK_CFG_13 */ 761 - MUX_GATE(CLK_TOP_TDMO1_SEL, "tdmo1_sel", 762 - i2so1_parents, 0x530, 0, 2, 7), 763 - MUX_GATE(CLK_TOP_I2SI1_SEL, "i2si1_sel", 764 - i2so1_parents, 0x530, 8, 2, 15), 765 - MUX_GATE(CLK_TOP_I2SI2_SEL, "i2si2_sel", 766 - i2so1_parents, 0x530, 16, 2, 23), 767 - MUX_GATE(CLK_TOP_I2SI3_SEL, "i2si3_sel", 768 - i2so1_parents, 0x530, 24, 2, 31), 821 + MUX_GATE(CLK_TOP_TDMO1_SEL, "tdmo1_sel", i2so1_parents, 0x530, 0, 2, 7), 822 + MUX_GATE(CLK_TOP_I2SI1_SEL, "i2si1_sel", i2so1_parents, 0x530, 8, 2, 15), 823 + MUX_GATE(CLK_TOP_I2SI2_SEL, "i2si2_sel", i2so1_parents, 0x530, 16, 2, 23), 824 + MUX_GATE(CLK_TOP_I2SI3_SEL, "i2si3_sel", i2so1_parents, 0x530, 24, 2, 31), 769 825 /* CLK_CFG_14 */ 770 - MUX_GATE(CLK_TOP_ETHER_125M_SEL, "ether_125m_sel", 771 - ether_125m_parents, 0x540, 0, 2, 7), 772 - MUX_GATE(CLK_TOP_ETHER_50M_SEL, "ether_50m_sel", 773 - ether_50m_parents, 0x540, 8, 2, 15), 774 - MUX_GATE(CLK_TOP_JPGDEC_SEL, "jpgdec_sel", 775 - jpgdec_parents, 0x540, 16, 4, 23), 776 - MUX_GATE(CLK_TOP_SPISLV_SEL, "spislv_sel", 777 - spislv_parents, 0x540, 24, 3, 31), 826 + MUX_GATE(CLK_TOP_ETHER_125M_SEL, "ether_125m_sel", ether_125m_parents, 827 + 0x540, 0, 2, 7), 828 + MUX_GATE(CLK_TOP_ETHER_50M_SEL, "ether_50m_sel", ether_50m_parents, 829 + 0x540, 8, 2, 15), 830 + MUX_GATE(CLK_TOP_JPGDEC_SEL, "jpgdec_sel", jpgdec_parents, 0x540, 16, 4, 23), 831 + MUX_GATE(CLK_TOP_SPISLV_SEL, "spislv_sel", spislv_parents, 0x540, 24, 3, 31), 778 832 /* CLK_CFG_15 */ 779 - MUX_GATE(CLK_TOP_ETHER_50M_RMII_SEL, "ether_sel", 780 - ether_parents, 0x550, 0, 2, 7), 781 - MUX_GATE(CLK_TOP_CAM2TG_SEL, "cam2tg_sel", 782 - camtg_parents, 0x550, 8, 4, 15), 783 - MUX_GATE(CLK_TOP_DI_SEL, "di_sel", 784 - di_parents, 0x550, 16, 3, 23), 785 - MUX_GATE(CLK_TOP_TVD_SEL, "tvd_sel", 786 - tvd_parents, 0x550, 24, 2, 31), 833 + MUX_GATE(CLK_TOP_ETHER_50M_RMII_SEL, "ether_sel", ether_parents, 0x550, 0, 2, 7), 834 + MUX_GATE(CLK_TOP_CAM2TG_SEL, "cam2tg_sel", camtg_parents, 0x550, 8, 4, 15), 835 + MUX_GATE(CLK_TOP_DI_SEL, "di_sel", di_parents, 0x550, 16, 3, 23), 836 + MUX_GATE(CLK_TOP_TVD_SEL, "tvd_sel", tvd_parents, 0x550, 24, 2, 31), 787 837 /* CLK_CFG_16 */ 788 - MUX_GATE(CLK_TOP_I2C_SEL, "i2c_sel", 789 - i2c_parents, 0x560, 0, 3, 7), 790 - MUX_GATE(CLK_TOP_PWM_INFRA_SEL, "pwm_infra_sel", 791 - pwm_parents, 0x560, 8, 2, 15), 792 - MUX_GATE(CLK_TOP_MSDC0P_AES_SEL, "msdc0p_aes_sel", 793 - msdc0p_aes_parents, 0x560, 16, 2, 23), 794 - MUX_GATE(CLK_TOP_CMSYS_SEL, "cmsys_sel", 795 - cmsys_parents, 0x560, 24, 3, 31), 838 + MUX_GATE(CLK_TOP_I2C_SEL, "i2c_sel", i2c_parents, 0x560, 0, 3, 7), 839 + MUX_GATE(CLK_TOP_PWM_INFRA_SEL, "pwm_infra_sel", pwm_parents, 0x560, 8, 2, 15), 840 + MUX_GATE(CLK_TOP_MSDC0P_AES_SEL, "msdc0p_aes_sel", msdc0p_aes_parents, 841 + 0x560, 16, 2, 23), 842 + MUX_GATE(CLK_TOP_CMSYS_SEL, "cmsys_sel", cmsys_parents, 0x560, 24, 3, 31), 796 843 /* CLK_CFG_17 */ 797 - MUX_GATE(CLK_TOP_GCPU_SEL, "gcpu_sel", 798 - gcpu_parents, 0x570, 0, 3, 7), 844 + MUX_GATE(CLK_TOP_GCPU_SEL, "gcpu_sel", gcpu_parents, 0x570, 0, 3, 7), 799 845 /* CLK_AUDDIV_4 */ 800 - MUX(CLK_TOP_AUD_APLL1_SEL, "aud_apll1_sel", 801 - aud_apll1_parents, 0x134, 0, 1), 802 - MUX(CLK_TOP_AUD_APLL2_SEL, "aud_apll2_sel", 803 - aud_apll2_parents, 0x134, 1, 1), 804 - MUX(CLK_TOP_DA_AUDULL_VTX_6P5M_SEL, "audull_vtx_sel", 805 - audull_vtx_parents, 0x134, 31, 1), 806 - MUX(CLK_TOP_APLL1_REF_SEL, "apll1_ref_sel", 807 - apll1_ref_parents, 0x134, 4, 3), 808 - MUX(CLK_TOP_APLL2_REF_SEL, "apll2_ref_sel", 809 - apll1_ref_parents, 0x134, 7, 3), 846 + MUX(CLK_TOP_AUD_APLL1_SEL, "aud_apll1_sel", aud_apll1_parents, 0x134, 0, 1), 847 + MUX(CLK_TOP_AUD_APLL2_SEL, "aud_apll2_sel", aud_apll2_parents, 0x134, 1, 1), 848 + MUX(CLK_TOP_DA_AUDULL_VTX_6P5M_SEL, "audull_vtx_sel", audull_vtx_parents, 849 + 0x134, 31, 1), 850 + MUX(CLK_TOP_APLL1_REF_SEL, "apll1_ref_sel", apll1_ref_parents, 0x134, 4, 3), 851 + MUX(CLK_TOP_APLL2_REF_SEL, "apll2_ref_sel", apll1_ref_parents, 0x134, 7, 3), 810 852 }; 811 853 812 854 static const char * const mcu_mp0_parents[] = { ··· 782 926 static struct mtk_composite mcu_muxes[] = { 783 927 /* mp0_pll_divider_cfg */ 784 928 MUX_GATE_FLAGS(CLK_MCU_MP0_SEL, "mcu_mp0_sel", mcu_mp0_parents, 0x7A0, 785 - 9, 2, -1, CLK_IS_CRITICAL), 929 + 9, 2, -1, CLK_IS_CRITICAL), 786 930 /* mp2_pll_divider_cfg */ 787 931 MUX_GATE_FLAGS(CLK_MCU_MP2_SEL, "mcu_mp2_sel", mcu_mp2_parents, 0x7A8, 788 - 9, 2, -1, CLK_IS_CRITICAL), 932 + 9, 2, -1, CLK_IS_CRITICAL), 789 933 /* bus_pll_divider_cfg */ 790 934 MUX_GATE_FLAGS(CLK_MCU_BUS_SEL, "mcu_bus_sel", mcu_bus_parents, 0x7C0, 791 - 9, 2, -1, CLK_IS_CRITICAL), 935 + 9, 2, -1, CLK_IS_CRITICAL), 792 936 }; 793 937 794 938 static const struct mtk_clk_divider top_adj_divs[] = { ··· 814 958 .sta_ofs = 0x424, 815 959 }; 816 960 817 - #define GATE_TOP0(_id, _name, _parent, _shift) { \ 818 - .id = _id, \ 819 - .name = _name, \ 820 - .parent_name = _parent, \ 821 - .regs = &top0_cg_regs, \ 822 - .shift = _shift, \ 823 - .ops = &mtk_clk_gate_ops_no_setclr, \ 824 - } 961 + #define GATE_TOP0(_id, _name, _parent, _shift) \ 962 + GATE_MTK(_id, _name, _parent, &top0_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr) 825 963 826 - #define GATE_TOP1(_id, _name, _parent, _shift) { \ 827 - .id = _id, \ 828 - .name = _name, \ 829 - .parent_name = _parent, \ 830 - .regs = &top1_cg_regs, \ 831 - .shift = _shift, \ 832 - .ops = &mtk_clk_gate_ops_no_setclr_inv, \ 833 - } 964 + #define GATE_TOP1(_id, _name, _parent, _shift) \ 965 + GATE_MTK(_id, _name, _parent, &top1_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv) 834 966 835 967 static const struct mtk_gate top_clks[] = { 836 968 /* TOP0 */ ··· 842 998 .sta_ofs = 0x48, 843 999 }; 844 1000 845 - #define GATE_INFRA(_id, _name, _parent, _shift) { \ 846 - .id = _id, \ 847 - .name = _name, \ 848 - .parent_name = _parent, \ 849 - .regs = &infra_cg_regs, \ 850 - .shift = _shift, \ 851 - .ops = &mtk_clk_gate_ops_setclr, \ 852 - } 1001 + #define GATE_INFRA(_id, _name, _parent, _shift) \ 1002 + GATE_MTK(_id, _name, _parent, &infra_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 853 1003 854 1004 static const struct mtk_gate infra_clks[] = { 855 1005 GATE_INFRA(CLK_INFRA_DBGCLK, "infra_dbgclk", "axi_sel", 0), ··· 873 1035 .sta_ofs = 0x42c, 874 1036 }; 875 1037 876 - #define GATE_PERI0(_id, _name, _parent, _shift) { \ 877 - .id = _id, \ 878 - .name = _name, \ 879 - .parent_name = _parent, \ 880 - .regs = &peri0_cg_regs, \ 881 - .shift = _shift, \ 882 - .ops = &mtk_clk_gate_ops_setclr, \ 883 - } 1038 + #define GATE_PERI0(_id, _name, _parent, _shift) \ 1039 + GATE_MTK(_id, _name, _parent, &peri0_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 884 1040 885 - #define GATE_PERI1(_id, _name, _parent, _shift) { \ 886 - .id = _id, \ 887 - .name = _name, \ 888 - .parent_name = _parent, \ 889 - .regs = &peri1_cg_regs, \ 890 - .shift = _shift, \ 891 - .ops = &mtk_clk_gate_ops_setclr, \ 892 - } 1041 + #define GATE_PERI1(_id, _name, _parent, _shift) \ 1042 + GATE_MTK(_id, _name, _parent, &peri1_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 893 1043 894 - #define GATE_PERI2(_id, _name, _parent, _shift) { \ 895 - .id = _id, \ 896 - .name = _name, \ 897 - .parent_name = _parent, \ 898 - .regs = &peri2_cg_regs, \ 899 - .shift = _shift, \ 900 - .ops = &mtk_clk_gate_ops_no_setclr_inv, \ 901 - } 1044 + #define GATE_PERI2(_id, _name, _parent, _shift) \ 1045 + GATE_MTK(_id, _name, _parent, &peri2_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv) 902 1046 903 1047 static const struct mtk_gate peri_clks[] = { 904 1048 /* PERI0 */ 905 - GATE_PERI0(CLK_PERI_NFI, "per_nfi", 906 - "axi_sel", 0), 907 - GATE_PERI0(CLK_PERI_THERM, "per_therm", 908 - "axi_sel", 1), 909 - GATE_PERI0(CLK_PERI_PWM0, "per_pwm0", 910 - "pwm_sel", 2), 911 - GATE_PERI0(CLK_PERI_PWM1, "per_pwm1", 912 - "pwm_sel", 3), 913 - GATE_PERI0(CLK_PERI_PWM2, "per_pwm2", 914 - "pwm_sel", 4), 915 - GATE_PERI0(CLK_PERI_PWM3, "per_pwm3", 916 - "pwm_sel", 5), 917 - GATE_PERI0(CLK_PERI_PWM4, "per_pwm4", 918 - "pwm_sel", 6), 919 - GATE_PERI0(CLK_PERI_PWM5, "per_pwm5", 920 - "pwm_sel", 7), 921 - GATE_PERI0(CLK_PERI_PWM6, "per_pwm6", 922 - "pwm_sel", 8), 923 - GATE_PERI0(CLK_PERI_PWM7, "per_pwm7", 924 - "pwm_sel", 9), 925 - GATE_PERI0(CLK_PERI_PWM, "per_pwm", 926 - "pwm_sel", 10), 927 - GATE_PERI0(CLK_PERI_AP_DMA, "per_ap_dma", 928 - "axi_sel", 13), 929 - GATE_PERI0(CLK_PERI_MSDC30_0, "per_msdc30_0", 930 - "msdc50_0_sel", 14), 931 - GATE_PERI0(CLK_PERI_MSDC30_1, "per_msdc30_1", 932 - "msdc30_1_sel", 15), 933 - GATE_PERI0(CLK_PERI_MSDC30_2, "per_msdc30_2", 934 - "msdc30_2_sel", 16), 935 - GATE_PERI0(CLK_PERI_MSDC30_3, "per_msdc30_3", 936 - "msdc30_3_sel", 17), 937 - GATE_PERI0(CLK_PERI_UART0, "per_uart0", 938 - "uart_sel", 20), 939 - GATE_PERI0(CLK_PERI_UART1, "per_uart1", 940 - "uart_sel", 21), 941 - GATE_PERI0(CLK_PERI_UART2, "per_uart2", 942 - "uart_sel", 22), 943 - GATE_PERI0(CLK_PERI_UART3, "per_uart3", 944 - "uart_sel", 23), 945 - GATE_PERI0(CLK_PERI_I2C0, "per_i2c0", 946 - "axi_sel", 24), 947 - GATE_PERI0(CLK_PERI_I2C1, "per_i2c1", 948 - "axi_sel", 25), 949 - GATE_PERI0(CLK_PERI_I2C2, "per_i2c2", 950 - "axi_sel", 26), 951 - GATE_PERI0(CLK_PERI_I2C3, "per_i2c3", 952 - "axi_sel", 27), 953 - GATE_PERI0(CLK_PERI_I2C4, "per_i2c4", 954 - "axi_sel", 28), 955 - GATE_PERI0(CLK_PERI_AUXADC, "per_auxadc", 956 - "ltepll_fs26m", 29), 957 - GATE_PERI0(CLK_PERI_SPI0, "per_spi0", 958 - "spi_sel", 30), 1049 + GATE_PERI0(CLK_PERI_NFI, "per_nfi", "axi_sel", 0), 1050 + GATE_PERI0(CLK_PERI_THERM, "per_therm", "axi_sel", 1), 1051 + GATE_PERI0(CLK_PERI_PWM0, "per_pwm0", "pwm_sel", 2), 1052 + GATE_PERI0(CLK_PERI_PWM1, "per_pwm1", "pwm_sel", 3), 1053 + GATE_PERI0(CLK_PERI_PWM2, "per_pwm2", "pwm_sel", 4), 1054 + GATE_PERI0(CLK_PERI_PWM3, "per_pwm3", "pwm_sel", 5), 1055 + GATE_PERI0(CLK_PERI_PWM4, "per_pwm4", "pwm_sel", 6), 1056 + GATE_PERI0(CLK_PERI_PWM5, "per_pwm5", "pwm_sel", 7), 1057 + GATE_PERI0(CLK_PERI_PWM6, "per_pwm6", "pwm_sel", 8), 1058 + GATE_PERI0(CLK_PERI_PWM7, "per_pwm7", "pwm_sel", 9), 1059 + GATE_PERI0(CLK_PERI_PWM, "per_pwm", "pwm_sel", 10), 1060 + GATE_PERI0(CLK_PERI_AP_DMA, "per_ap_dma", "axi_sel", 13), 1061 + GATE_PERI0(CLK_PERI_MSDC30_0, "per_msdc30_0", "msdc50_0_sel", 14), 1062 + GATE_PERI0(CLK_PERI_MSDC30_1, "per_msdc30_1", "msdc30_1_sel", 15), 1063 + GATE_PERI0(CLK_PERI_MSDC30_2, "per_msdc30_2", "msdc30_2_sel", 16), 1064 + GATE_PERI0(CLK_PERI_MSDC30_3, "per_msdc30_3", "msdc30_3_sel", 17), 1065 + GATE_PERI0(CLK_PERI_UART0, "per_uart0", "uart_sel", 20), 1066 + GATE_PERI0(CLK_PERI_UART1, "per_uart1", "uart_sel", 21), 1067 + GATE_PERI0(CLK_PERI_UART2, "per_uart2", "uart_sel", 22), 1068 + GATE_PERI0(CLK_PERI_UART3, "per_uart3", "uart_sel", 23), 1069 + GATE_PERI0(CLK_PERI_I2C0, "per_i2c0", "axi_sel", 24), 1070 + GATE_PERI0(CLK_PERI_I2C1, "per_i2c1", "axi_sel", 25), 1071 + GATE_PERI0(CLK_PERI_I2C2, "per_i2c2", "axi_sel", 26), 1072 + GATE_PERI0(CLK_PERI_I2C3, "per_i2c3", "axi_sel", 27), 1073 + GATE_PERI0(CLK_PERI_I2C4, "per_i2c4", "axi_sel", 28), 1074 + GATE_PERI0(CLK_PERI_AUXADC, "per_auxadc", "ltepll_fs26m", 29), 1075 + GATE_PERI0(CLK_PERI_SPI0, "per_spi0", "spi_sel", 30), 959 1076 /* PERI1 */ 960 - GATE_PERI1(CLK_PERI_SPI, "per_spi", 961 - "spinor_sel", 1), 962 - GATE_PERI1(CLK_PERI_I2C5, "per_i2c5", 963 - "axi_sel", 3), 964 - GATE_PERI1(CLK_PERI_SPI2, "per_spi2", 965 - "spi_sel", 5), 966 - GATE_PERI1(CLK_PERI_SPI3, "per_spi3", 967 - "spi_sel", 6), 968 - GATE_PERI1(CLK_PERI_SPI5, "per_spi5", 969 - "spi_sel", 8), 970 - GATE_PERI1(CLK_PERI_UART4, "per_uart4", 971 - "uart_sel", 9), 972 - GATE_PERI1(CLK_PERI_SFLASH, "per_sflash", 973 - "uart_sel", 11), 974 - GATE_PERI1(CLK_PERI_GMAC, "per_gmac", 975 - "uart_sel", 12), 976 - GATE_PERI1(CLK_PERI_PCIE0, "per_pcie0", 977 - "uart_sel", 14), 978 - GATE_PERI1(CLK_PERI_PCIE1, "per_pcie1", 979 - "uart_sel", 15), 980 - GATE_PERI1(CLK_PERI_GMAC_PCLK, "per_gmac_pclk", 981 - "uart_sel", 16), 1077 + GATE_PERI1(CLK_PERI_SPI, "per_spi", "spinor_sel", 1), 1078 + GATE_PERI1(CLK_PERI_I2C5, "per_i2c5", "axi_sel", 3), 1079 + GATE_PERI1(CLK_PERI_SPI2, "per_spi2", "spi_sel", 5), 1080 + GATE_PERI1(CLK_PERI_SPI3, "per_spi3", "spi_sel", 6), 1081 + GATE_PERI1(CLK_PERI_SPI5, "per_spi5", "spi_sel", 8), 1082 + GATE_PERI1(CLK_PERI_UART4, "per_uart4", "uart_sel", 9), 1083 + GATE_PERI1(CLK_PERI_SFLASH, "per_sflash", "uart_sel", 11), 1084 + GATE_PERI1(CLK_PERI_GMAC, "per_gmac", "uart_sel", 12), 1085 + GATE_PERI1(CLK_PERI_PCIE0, "per_pcie0", "uart_sel", 14), 1086 + GATE_PERI1(CLK_PERI_PCIE1, "per_pcie1", "uart_sel", 15), 1087 + GATE_PERI1(CLK_PERI_GMAC_PCLK, "per_gmac_pclk", "uart_sel", 16), 982 1088 /* PERI2 */ 983 - GATE_PERI2(CLK_PERI_MSDC50_0_EN, "per_msdc50_0_en", 984 - "msdc50_0_sel", 0), 985 - GATE_PERI2(CLK_PERI_MSDC30_1_EN, "per_msdc30_1_en", 986 - "msdc30_1_sel", 1), 987 - GATE_PERI2(CLK_PERI_MSDC30_2_EN, "per_msdc30_2_en", 988 - "msdc30_2_sel", 2), 989 - GATE_PERI2(CLK_PERI_MSDC30_3_EN, "per_msdc30_3_en", 990 - "msdc30_3_sel", 3), 991 - GATE_PERI2(CLK_PERI_MSDC50_0_HCLK_EN, "per_msdc50_0_h", 992 - "msdc50_0_h_sel", 4), 993 - GATE_PERI2(CLK_PERI_MSDC50_3_HCLK_EN, "per_msdc50_3_h", 994 - "msdc50_3_h_sel", 5), 995 - GATE_PERI2(CLK_PERI_MSDC30_0_QTR_EN, "per_msdc30_0_q", 996 - "axi_sel", 6), 997 - GATE_PERI2(CLK_PERI_MSDC30_3_QTR_EN, "per_msdc30_3_q", 998 - "mem_sel", 7), 999 - }; 1000 - 1001 - #define MT2712_PLL_FMAX (3000UL * MHZ) 1002 - 1003 - #define CON0_MT2712_RST_BAR BIT(24) 1004 - 1005 - #define PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits, \ 1006 - _pd_reg, _pd_shift, _tuner_reg, _tuner_en_reg, \ 1007 - _tuner_en_bit, _pcw_reg, _pcw_shift, \ 1008 - _div_table) { \ 1009 - .id = _id, \ 1010 - .name = _name, \ 1011 - .reg = _reg, \ 1012 - .pwr_reg = _pwr_reg, \ 1013 - .en_mask = _en_mask, \ 1014 - .flags = _flags, \ 1015 - .rst_bar_mask = CON0_MT2712_RST_BAR, \ 1016 - .fmax = MT2712_PLL_FMAX, \ 1017 - .pcwbits = _pcwbits, \ 1018 - .pd_reg = _pd_reg, \ 1019 - .pd_shift = _pd_shift, \ 1020 - .tuner_reg = _tuner_reg, \ 1021 - .tuner_en_reg = _tuner_en_reg, \ 1022 - .tuner_en_bit = _tuner_en_bit, \ 1023 - .pcw_reg = _pcw_reg, \ 1024 - .pcw_shift = _pcw_shift, \ 1025 - .div_table = _div_table, \ 1026 - } 1027 - 1028 - #define PLL(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits, \ 1029 - _pd_reg, _pd_shift, _tuner_reg, _tuner_en_reg, \ 1030 - _tuner_en_bit, _pcw_reg, _pcw_shift) \ 1031 - PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags, \ 1032 - _pcwbits, _pd_reg, _pd_shift, _tuner_reg, \ 1033 - _tuner_en_reg, _tuner_en_bit, _pcw_reg, \ 1034 - _pcw_shift, NULL) 1035 - 1036 - static const struct mtk_pll_div_table armca35pll_div_table[] = { 1037 - { .div = 0, .freq = MT2712_PLL_FMAX }, 1038 - { .div = 1, .freq = 1202500000 }, 1039 - { .div = 2, .freq = 500500000 }, 1040 - { .div = 3, .freq = 315250000 }, 1041 - { .div = 4, .freq = 157625000 }, 1042 - { } /* sentinel */ 1043 - }; 1044 - 1045 - static const struct mtk_pll_div_table armca72pll_div_table[] = { 1046 - { .div = 0, .freq = MT2712_PLL_FMAX }, 1047 - { .div = 1, .freq = 994500000 }, 1048 - { .div = 2, .freq = 520000000 }, 1049 - { .div = 3, .freq = 315250000 }, 1050 - { .div = 4, .freq = 157625000 }, 1051 - { } /* sentinel */ 1052 - }; 1053 - 1054 - static const struct mtk_pll_div_table mmpll_div_table[] = { 1055 - { .div = 0, .freq = MT2712_PLL_FMAX }, 1056 - { .div = 1, .freq = 1001000000 }, 1057 - { .div = 2, .freq = 601250000 }, 1058 - { .div = 3, .freq = 250250000 }, 1059 - { .div = 4, .freq = 125125000 }, 1060 - { } /* sentinel */ 1061 - }; 1062 - 1063 - static const struct mtk_pll_data plls[] = { 1064 - PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0230, 0x023C, 0xf0000100, 1065 - HAVE_RST_BAR, 31, 0x0230, 4, 0, 0, 0, 0x0234, 0), 1066 - PLL(CLK_APMIXED_UNIVPLL, "univpll", 0x0240, 0x024C, 0xfe000100, 1067 - HAVE_RST_BAR, 31, 0x0240, 4, 0, 0, 0, 0x0244, 0), 1068 - PLL(CLK_APMIXED_VCODECPLL, "vcodecpll", 0x0320, 0x032C, 0xc0000100, 1069 - 0, 31, 0x0320, 4, 0, 0, 0, 0x0324, 0), 1070 - PLL(CLK_APMIXED_VENCPLL, "vencpll", 0x0280, 0x028C, 0x00000100, 1071 - 0, 31, 0x0280, 4, 0, 0, 0, 0x0284, 0), 1072 - PLL(CLK_APMIXED_APLL1, "apll1", 0x0330, 0x0340, 0x00000100, 1073 - 0, 31, 0x0330, 4, 0x0338, 0x0014, 0, 0x0334, 0), 1074 - PLL(CLK_APMIXED_APLL2, "apll2", 0x0350, 0x0360, 0x00000100, 1075 - 0, 31, 0x0350, 4, 0x0358, 0x0014, 1, 0x0354, 0), 1076 - PLL(CLK_APMIXED_LVDSPLL, "lvdspll", 0x0370, 0x037c, 0x00000100, 1077 - 0, 31, 0x0370, 4, 0, 0, 0, 0x0374, 0), 1078 - PLL(CLK_APMIXED_LVDSPLL2, "lvdspll2", 0x0390, 0x039C, 0x00000100, 1079 - 0, 31, 0x0390, 4, 0, 0, 0, 0x0394, 0), 1080 - PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x0270, 0x027C, 0x00000100, 1081 - 0, 31, 0x0270, 4, 0, 0, 0, 0x0274, 0), 1082 - PLL(CLK_APMIXED_MSDCPLL2, "msdcpll2", 0x0410, 0x041C, 0x00000100, 1083 - 0, 31, 0x0410, 4, 0, 0, 0, 0x0414, 0), 1084 - PLL(CLK_APMIXED_TVDPLL, "tvdpll", 0x0290, 0x029C, 0xc0000100, 1085 - 0, 31, 0x0290, 4, 0, 0, 0, 0x0294, 0), 1086 - PLL_B(CLK_APMIXED_MMPLL, "mmpll", 0x0250, 0x0260, 0x00000100, 1087 - 0, 31, 0x0250, 4, 0, 0, 0, 0x0254, 0, 1088 - mmpll_div_table), 1089 - PLL_B(CLK_APMIXED_ARMCA35PLL, "armca35pll", 0x0100, 0x0110, 0xf0000100, 1090 - HAVE_RST_BAR, 31, 0x0100, 4, 0, 0, 0, 0x0104, 0, 1091 - armca35pll_div_table), 1092 - PLL_B(CLK_APMIXED_ARMCA72PLL, "armca72pll", 0x0210, 0x0220, 0x00000100, 1093 - 0, 31, 0x0210, 4, 0, 0, 0, 0x0214, 0, 1094 - armca72pll_div_table), 1095 - PLL(CLK_APMIXED_ETHERPLL, "etherpll", 0x0300, 0x030C, 0xc0000100, 1096 - 0, 31, 0x0300, 4, 0, 0, 0, 0x0304, 0), 1089 + GATE_PERI2(CLK_PERI_MSDC50_0_EN, "per_msdc50_0_en", "msdc50_0_sel", 0), 1090 + GATE_PERI2(CLK_PERI_MSDC30_1_EN, "per_msdc30_1_en", "msdc30_1_sel", 1), 1091 + GATE_PERI2(CLK_PERI_MSDC30_2_EN, "per_msdc30_2_en", "msdc30_2_sel", 2), 1092 + GATE_PERI2(CLK_PERI_MSDC30_3_EN, "per_msdc30_3_en", "msdc30_3_sel", 3), 1093 + GATE_PERI2(CLK_PERI_MSDC50_0_HCLK_EN, "per_msdc50_0_h", "msdc50_0_h_sel", 4), 1094 + GATE_PERI2(CLK_PERI_MSDC50_3_HCLK_EN, "per_msdc50_3_h", "msdc50_3_h_sel", 5), 1095 + GATE_PERI2(CLK_PERI_MSDC30_0_QTR_EN, "per_msdc30_0_q", "axi_sel", 6), 1096 + GATE_PERI2(CLK_PERI_MSDC30_3_QTR_EN, "per_msdc30_3_q", "mem_sel", 7), 1097 1097 }; 1098 1098 1099 1099 static u16 infrasys_rst_ofs[] = { 0x30, 0x34, }; ··· 952 1276 }, 953 1277 }; 954 1278 955 - static int clk_mt2712_apmixed_probe(struct platform_device *pdev) 956 - { 957 - struct clk_hw_onecell_data *clk_data; 958 - int r; 959 - struct device_node *node = pdev->dev.of_node; 960 - 961 - clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK); 962 - 963 - mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data); 964 - 965 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 966 - 967 - if (r != 0) 968 - pr_err("%s(): could not register clock provider: %d\n", 969 - __func__, r); 970 - 971 - return r; 972 - } 973 - 974 - static struct clk_hw_onecell_data *top_clk_data; 975 - 976 - static void clk_mt2712_top_init_early(struct device_node *node) 977 - { 978 - int r, i; 979 - 980 - if (!top_clk_data) { 981 - top_clk_data = mtk_alloc_clk_data(CLK_TOP_NR_CLK); 982 - 983 - for (i = 0; i < CLK_TOP_NR_CLK; i++) 984 - top_clk_data->hws[i] = ERR_PTR(-EPROBE_DEFER); 985 - } 986 - 987 - mtk_clk_register_factors(top_early_divs, ARRAY_SIZE(top_early_divs), 988 - top_clk_data); 989 - 990 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, top_clk_data); 991 - if (r) 992 - pr_err("%s(): could not register clock provider: %d\n", 993 - __func__, r); 994 - } 995 - 996 - CLK_OF_DECLARE_DRIVER(mt2712_topckgen, "mediatek,mt2712-topckgen", 997 - clk_mt2712_top_init_early); 998 - 999 - static int clk_mt2712_top_probe(struct platform_device *pdev) 1000 - { 1001 - int r, i; 1002 - struct device_node *node = pdev->dev.of_node; 1003 - void __iomem *base; 1004 - 1005 - base = devm_platform_ioremap_resource(pdev, 0); 1006 - if (IS_ERR(base)) { 1007 - pr_err("%s(): ioremap failed\n", __func__); 1008 - return PTR_ERR(base); 1009 - } 1010 - 1011 - if (!top_clk_data) { 1012 - top_clk_data = mtk_alloc_clk_data(CLK_TOP_NR_CLK); 1013 - } else { 1014 - for (i = 0; i < CLK_TOP_NR_CLK; i++) { 1015 - if (top_clk_data->hws[i] == ERR_PTR(-EPROBE_DEFER)) 1016 - top_clk_data->hws[i] = ERR_PTR(-ENOENT); 1017 - } 1018 - } 1019 - 1020 - mtk_clk_register_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks), 1021 - top_clk_data); 1022 - mtk_clk_register_factors(top_early_divs, ARRAY_SIZE(top_early_divs), 1023 - top_clk_data); 1024 - mtk_clk_register_factors(top_divs, ARRAY_SIZE(top_divs), top_clk_data); 1025 - mtk_clk_register_composites(&pdev->dev, top_muxes, 1026 - ARRAY_SIZE(top_muxes), base, 1027 - &mt2712_clk_lock, top_clk_data); 1028 - mtk_clk_register_dividers(top_adj_divs, ARRAY_SIZE(top_adj_divs), base, 1029 - &mt2712_clk_lock, top_clk_data); 1030 - mtk_clk_register_gates(&pdev->dev, node, top_clks, 1031 - ARRAY_SIZE(top_clks), top_clk_data); 1032 - 1033 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, top_clk_data); 1034 - 1035 - if (r != 0) 1036 - pr_err("%s(): could not register clock provider: %d\n", 1037 - __func__, r); 1038 - 1039 - return r; 1040 - } 1041 - 1042 - static int clk_mt2712_mcu_probe(struct platform_device *pdev) 1043 - { 1044 - struct clk_hw_onecell_data *clk_data; 1045 - int r; 1046 - struct device_node *node = pdev->dev.of_node; 1047 - void __iomem *base; 1048 - 1049 - base = devm_platform_ioremap_resource(pdev, 0); 1050 - if (IS_ERR(base)) { 1051 - pr_err("%s(): ioremap failed\n", __func__); 1052 - return PTR_ERR(base); 1053 - } 1054 - 1055 - clk_data = mtk_alloc_clk_data(CLK_MCU_NR_CLK); 1056 - 1057 - r = mtk_clk_register_composites(&pdev->dev, mcu_muxes, 1058 - ARRAY_SIZE(mcu_muxes), base, 1059 - &mt2712_clk_lock, clk_data); 1060 - if (r) 1061 - dev_err(&pdev->dev, "Could not register composites: %d\n", r); 1062 - 1063 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 1064 - 1065 - if (r != 0) 1066 - pr_err("%s(): could not register clock provider: %d\n", 1067 - __func__, r); 1068 - 1069 - return r; 1070 - } 1071 - 1072 - static const struct of_device_id of_match_clk_mt2712[] = { 1073 - { 1074 - .compatible = "mediatek,mt2712-apmixedsys", 1075 - .data = clk_mt2712_apmixed_probe, 1076 - }, { 1077 - .compatible = "mediatek,mt2712-topckgen", 1078 - .data = clk_mt2712_top_probe, 1079 - }, { 1080 - .compatible = "mediatek,mt2712-mcucfg", 1081 - .data = clk_mt2712_mcu_probe, 1082 - }, { 1083 - /* sentinel */ 1084 - } 1279 + static const struct mtk_clk_desc topck_desc = { 1280 + .clks = top_clks, 1281 + .num_clks = ARRAY_SIZE(top_clks), 1282 + .fixed_clks = top_fixed_clks, 1283 + .num_fixed_clks = ARRAY_SIZE(top_fixed_clks), 1284 + .factor_clks = top_divs, 1285 + .num_factor_clks = ARRAY_SIZE(top_divs), 1286 + .composite_clks = top_muxes, 1287 + .num_composite_clks = ARRAY_SIZE(top_muxes), 1288 + .divider_clks = top_adj_divs, 1289 + .num_divider_clks = ARRAY_SIZE(top_adj_divs), 1290 + .clk_lock = &mt2712_clk_lock, 1085 1291 }; 1086 1292 1087 - static int clk_mt2712_probe(struct platform_device *pdev) 1088 - { 1089 - int (*clk_probe)(struct platform_device *); 1090 - int r; 1091 - 1092 - clk_probe = of_device_get_match_data(&pdev->dev); 1093 - if (!clk_probe) 1094 - return -EINVAL; 1095 - 1096 - r = clk_probe(pdev); 1097 - if (r != 0) 1098 - dev_err(&pdev->dev, 1099 - "could not register clock provider: %s: %d\n", 1100 - pdev->name, r); 1101 - 1102 - return r; 1103 - } 1293 + static const struct mtk_clk_desc mcu_desc = { 1294 + .composite_clks = mcu_muxes, 1295 + .num_composite_clks = ARRAY_SIZE(mcu_muxes), 1296 + .clk_lock = &mt2712_clk_lock, 1297 + }; 1104 1298 1105 1299 static const struct mtk_clk_desc infra_desc = { 1106 1300 .clks = infra_clks, ··· 984 1438 .rst_desc = &clk_rst_desc[1], 985 1439 }; 986 1440 987 - static const struct of_device_id of_match_clk_mt2712_simple[] = { 1441 + static const struct of_device_id of_match_clk_mt2712[] = { 988 1442 { .compatible = "mediatek,mt2712-infracfg", .data = &infra_desc }, 1443 + { .compatible = "mediatek,mt2712-mcucfg", .data = &mcu_desc }, 989 1444 { .compatible = "mediatek,mt2712-pericfg", .data = &peri_desc, }, 1445 + { .compatible = "mediatek,mt2712-topckgen", .data = &topck_desc }, 990 1446 { /* sentinel */ } 991 1447 }; 992 - 993 - static struct platform_driver clk_mt2712_simple_drv = { 994 - .probe = mtk_clk_simple_probe, 995 - .remove = mtk_clk_simple_remove, 996 - .driver = { 997 - .name = "clk-mt2712-simple", 998 - .of_match_table = of_match_clk_mt2712_simple, 999 - }, 1000 - }; 1448 + MODULE_DEVICE_TABLE(of, of_match_clk_mt2712); 1001 1449 1002 1450 static struct platform_driver clk_mt2712_drv = { 1003 - .probe = clk_mt2712_probe, 1451 + .probe = mtk_clk_simple_probe, 1452 + .remove = mtk_clk_simple_remove, 1004 1453 .driver = { 1005 1454 .name = "clk-mt2712", 1006 1455 .of_match_table = of_match_clk_mt2712, 1007 1456 }, 1008 1457 }; 1009 - 1010 - static int __init clk_mt2712_init(void) 1011 - { 1012 - int ret = platform_driver_register(&clk_mt2712_drv); 1013 - 1014 - if (ret) 1015 - return ret; 1016 - return platform_driver_register(&clk_mt2712_simple_drv); 1017 - } 1018 - 1019 - arch_initcall(clk_mt2712_init); 1458 + module_platform_driver(clk_mt2712_drv); 1459 + MODULE_LICENSE("GPL");
+7 -18
drivers/clk/mediatek/clk-mt6765-audio.c
··· 24 24 .sta_ofs = 0x4, 25 25 }; 26 26 27 - #define GATE_AUDIO0(_id, _name, _parent, _shift) { \ 28 - .id = _id, \ 29 - .name = _name, \ 30 - .parent_name = _parent, \ 31 - .regs = &audio0_cg_regs, \ 32 - .shift = _shift, \ 33 - .ops = &mtk_clk_gate_ops_no_setclr, \ 34 - } 27 + #define GATE_AUDIO0(_id, _name, _parent, _shift) \ 28 + GATE_MTK(_id, _name, _parent, &audio0_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr) 35 29 36 - #define GATE_AUDIO1(_id, _name, _parent, _shift) { \ 37 - .id = _id, \ 38 - .name = _name, \ 39 - .parent_name = _parent, \ 40 - .regs = &audio1_cg_regs, \ 41 - .shift = _shift, \ 42 - .ops = &mtk_clk_gate_ops_no_setclr, \ 43 - } 30 + #define GATE_AUDIO1(_id, _name, _parent, _shift) \ 31 + GATE_MTK(_id, _name, _parent, &audio1_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr) 44 32 45 33 static const struct mtk_gate audio_clks[] = { 46 34 /* AUDIO0 */ ··· 65 77 /* sentinel */ 66 78 } 67 79 }; 80 + MODULE_DEVICE_TABLE(of, of_match_clk_mt6765_audio); 68 81 69 82 static struct platform_driver clk_mt6765_audio_drv = { 70 83 .probe = mtk_clk_simple_probe, ··· 75 86 .of_match_table = of_match_clk_mt6765_audio, 76 87 }, 77 88 }; 78 - 79 - builtin_platform_driver(clk_mt6765_audio_drv); 89 + module_platform_driver(clk_mt6765_audio_drv); 90 + MODULE_LICENSE("GPL");
+5 -10
drivers/clk/mediatek/clk-mt6765-cam.c
··· 18 18 .sta_ofs = 0x0, 19 19 }; 20 20 21 - #define GATE_CAM(_id, _name, _parent, _shift) { \ 22 - .id = _id, \ 23 - .name = _name, \ 24 - .parent_name = _parent, \ 25 - .regs = &cam_cg_regs, \ 26 - .shift = _shift, \ 27 - .ops = &mtk_clk_gate_ops_setclr, \ 28 - } 21 + #define GATE_CAM(_id, _name, _parent, _shift) \ 22 + GATE_MTK(_id, _name, _parent, &cam_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 29 23 30 24 static const struct mtk_gate cam_clks[] = { 31 25 GATE_CAM(CLK_CAM_LARB3, "cam_larb3", "mm_ck", 0), ··· 46 52 /* sentinel */ 47 53 } 48 54 }; 55 + MODULE_DEVICE_TABLE(of, of_match_clk_mt6765_cam); 49 56 50 57 static struct platform_driver clk_mt6765_cam_drv = { 51 58 .probe = mtk_clk_simple_probe, ··· 56 61 .of_match_table = of_match_clk_mt6765_cam, 57 62 }, 58 63 }; 59 - 60 - builtin_platform_driver(clk_mt6765_cam_drv); 64 + module_platform_driver(clk_mt6765_cam_drv); 65 + MODULE_LICENSE("GPL");
+5 -10
drivers/clk/mediatek/clk-mt6765-img.c
··· 18 18 .sta_ofs = 0x0, 19 19 }; 20 20 21 - #define GATE_IMG(_id, _name, _parent, _shift) { \ 22 - .id = _id, \ 23 - .name = _name, \ 24 - .parent_name = _parent, \ 25 - .regs = &img_cg_regs, \ 26 - .shift = _shift, \ 27 - .ops = &mtk_clk_gate_ops_setclr, \ 28 - } 21 + #define GATE_IMG(_id, _name, _parent, _shift) \ 22 + GATE_MTK(_id, _name, _parent, &img_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 29 23 30 24 static const struct mtk_gate img_clks[] = { 31 25 GATE_IMG(CLK_IMG_LARB2, "img_larb2", "mm_ck", 0), ··· 42 48 /* sentinel */ 43 49 } 44 50 }; 51 + MODULE_DEVICE_TABLE(of, of_match_clk_mt6765_img); 45 52 46 53 static struct platform_driver clk_mt6765_img_drv = { 47 54 .probe = mtk_clk_simple_probe, ··· 52 57 .of_match_table = of_match_clk_mt6765_img, 53 58 }, 54 59 }; 55 - 56 - builtin_platform_driver(clk_mt6765_img_drv); 60 + module_platform_driver(clk_mt6765_img_drv); 61 + MODULE_LICENSE("GPL");
+5 -10
drivers/clk/mediatek/clk-mt6765-mipi0a.c
··· 18 18 .sta_ofs = 0x80, 19 19 }; 20 20 21 - #define GATE_MIPI0A(_id, _name, _parent, _shift) { \ 22 - .id = _id, \ 23 - .name = _name, \ 24 - .parent_name = _parent, \ 25 - .regs = &mipi0a_cg_regs, \ 26 - .shift = _shift, \ 27 - .ops = &mtk_clk_gate_ops_no_setclr_inv, \ 28 - } 21 + #define GATE_MIPI0A(_id, _name, _parent, _shift) \ 22 + GATE_MTK(_id, _name, _parent, &mipi0a_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv) 29 23 30 24 static const struct mtk_gate mipi0a_clks[] = { 31 25 GATE_MIPI0A(CLK_MIPI0A_CSR_CSI_EN_0A, ··· 39 45 /* sentinel */ 40 46 } 41 47 }; 48 + MODULE_DEVICE_TABLE(of, of_match_clk_mt6765_mipi0a); 42 49 43 50 static struct platform_driver clk_mt6765_mipi0a_drv = { 44 51 .probe = mtk_clk_simple_probe, ··· 49 54 .of_match_table = of_match_clk_mt6765_mipi0a, 50 55 }, 51 56 }; 52 - 53 - builtin_platform_driver(clk_mt6765_mipi0a_drv); 57 + module_platform_driver(clk_mt6765_mipi0a_drv); 58 + MODULE_LICENSE("GPL");
+5 -10
drivers/clk/mediatek/clk-mt6765-mm.c
··· 18 18 .sta_ofs = 0x100, 19 19 }; 20 20 21 - #define GATE_MM(_id, _name, _parent, _shift) { \ 22 - .id = _id, \ 23 - .name = _name, \ 24 - .parent_name = _parent, \ 25 - .regs = &mm_cg_regs, \ 26 - .shift = _shift, \ 27 - .ops = &mtk_clk_gate_ops_setclr, \ 28 - } 21 + #define GATE_MM(_id, _name, _parent, _shift) \ 22 + GATE_MTK(_id, _name, _parent, &mm_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 29 23 30 24 static const struct mtk_gate mm_clks[] = { 31 25 /* MM */ ··· 68 74 /* sentinel */ 69 75 } 70 76 }; 77 + MODULE_DEVICE_TABLE(of, of_match_clk_mt6765_mm); 71 78 72 79 static struct platform_driver clk_mt6765_mm_drv = { 73 80 .probe = mtk_clk_simple_probe, ··· 78 83 .of_match_table = of_match_clk_mt6765_mm, 79 84 }, 80 85 }; 81 - 82 - builtin_platform_driver(clk_mt6765_mm_drv); 86 + module_platform_driver(clk_mt6765_mm_drv); 87 + MODULE_LICENSE("GPL");
+5 -10
drivers/clk/mediatek/clk-mt6765-vcodec.c
··· 18 18 .sta_ofs = 0x0, 19 19 }; 20 20 21 - #define GATE_VENC(_id, _name, _parent, _shift) { \ 22 - .id = _id, \ 23 - .name = _name, \ 24 - .parent_name = _parent, \ 25 - .regs = &venc_cg_regs, \ 26 - .shift = _shift, \ 27 - .ops = &mtk_clk_gate_ops_setclr_inv, \ 28 - } 21 + #define GATE_VENC(_id, _name, _parent, _shift) \ 22 + GATE_MTK(_id, _name, _parent, &venc_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv) 29 23 30 24 static const struct mtk_gate venc_clks[] = { 31 25 GATE_VENC(CLK_VENC_SET0_LARB, "venc_set0_larb", "mm_ck", 0), ··· 41 47 /* sentinel */ 42 48 } 43 49 }; 50 + MODULE_DEVICE_TABLE(of, of_match_clk_mt6765_vcodec); 44 51 45 52 static struct platform_driver clk_mt6765_vcodec_drv = { 46 53 .probe = mtk_clk_simple_probe, ··· 51 56 .of_match_table = of_match_clk_mt6765_vcodec, 52 57 }, 53 58 }; 54 - 55 - builtin_platform_driver(clk_mt6765_vcodec_drv); 59 + module_platform_driver(clk_mt6765_vcodec_drv); 60 + MODULE_LICENSE("GPL");
+18 -64
drivers/clk/mediatek/clk-mt6765.c
··· 483 483 .sta_ofs = 0x320, 484 484 }; 485 485 486 - #define GATE_TOP0(_id, _name, _parent, _shift) { \ 487 - .id = _id, \ 488 - .name = _name, \ 489 - .parent_name = _parent, \ 490 - .regs = &top0_cg_regs, \ 491 - .shift = _shift, \ 492 - .ops = &mtk_clk_gate_ops_no_setclr, \ 493 - } 486 + #define GATE_TOP0(_id, _name, _parent, _shift) \ 487 + GATE_MTK(_id, _name, _parent, &top0_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr) 494 488 495 - #define GATE_TOP1(_id, _name, _parent, _shift) { \ 496 - .id = _id, \ 497 - .name = _name, \ 498 - .parent_name = _parent, \ 499 - .regs = &top1_cg_regs, \ 500 - .shift = _shift, \ 501 - .ops = &mtk_clk_gate_ops_no_setclr_inv, \ 502 - } 489 + #define GATE_TOP1(_id, _name, _parent, _shift) \ 490 + GATE_MTK(_id, _name, _parent, &top1_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv) 503 491 504 - #define GATE_TOP2(_id, _name, _parent, _shift) { \ 505 - .id = _id, \ 506 - .name = _name, \ 507 - .parent_name = _parent, \ 508 - .regs = &top2_cg_regs, \ 509 - .shift = _shift, \ 510 - .ops = &mtk_clk_gate_ops_no_setclr, \ 511 - } 492 + #define GATE_TOP2(_id, _name, _parent, _shift) \ 493 + GATE_MTK(_id, _name, _parent, &top2_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr) 512 494 513 495 static const struct mtk_gate top_clks[] = { 514 496 /* TOP0 */ ··· 541 559 .sta_ofs = 0xc8, 542 560 }; 543 561 544 - #define GATE_IFR2(_id, _name, _parent, _shift) { \ 545 - .id = _id, \ 546 - .name = _name, \ 547 - .parent_name = _parent, \ 548 - .regs = &ifr2_cg_regs, \ 549 - .shift = _shift, \ 550 - .ops = &mtk_clk_gate_ops_setclr, \ 551 - } 562 + #define GATE_IFR2(_id, _name, _parent, _shift) \ 563 + GATE_MTK(_id, _name, _parent, &ifr2_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 552 564 553 - #define GATE_IFR3(_id, _name, _parent, _shift) { \ 554 - .id = _id, \ 555 - .name = _name, \ 556 - .parent_name = _parent, \ 557 - .regs = &ifr3_cg_regs, \ 558 - .shift = _shift, \ 559 - .ops = &mtk_clk_gate_ops_setclr, \ 560 - } 565 + #define GATE_IFR3(_id, _name, _parent, _shift) \ 566 + GATE_MTK(_id, _name, _parent, &ifr3_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 561 567 562 - #define GATE_IFR4(_id, _name, _parent, _shift) { \ 563 - .id = _id, \ 564 - .name = _name, \ 565 - .parent_name = _parent, \ 566 - .regs = &ifr4_cg_regs, \ 567 - .shift = _shift, \ 568 - .ops = &mtk_clk_gate_ops_setclr, \ 569 - } 568 + #define GATE_IFR4(_id, _name, _parent, _shift) \ 569 + GATE_MTK(_id, _name, _parent, &ifr4_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 570 570 571 - #define GATE_IFR5(_id, _name, _parent, _shift) { \ 572 - .id = _id, \ 573 - .name = _name, \ 574 - .parent_name = _parent, \ 575 - .regs = &ifr5_cg_regs, \ 576 - .shift = _shift, \ 577 - .ops = &mtk_clk_gate_ops_setclr, \ 578 - } 571 + #define GATE_IFR5(_id, _name, _parent, _shift) \ 572 + GATE_MTK(_id, _name, _parent, &ifr5_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 579 573 580 574 static const struct mtk_gate ifr_clks[] = { 581 575 /* INFRA_TOPAXI */ ··· 632 674 .sta_ofs = 0x14, 633 675 }; 634 676 635 - #define GATE_APMIXED(_id, _name, _parent, _shift) { \ 636 - .id = _id, \ 637 - .name = _name, \ 638 - .parent_name = _parent, \ 639 - .regs = &apmixed_cg_regs, \ 640 - .shift = _shift, \ 641 - .ops = &mtk_clk_gate_ops_no_setclr_inv, \ 642 - } 677 + #define GATE_APMIXED(_id, _name, _parent, _shift) \ 678 + GATE_MTK(_id, _name, _parent, &apmixed_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv) 643 679 644 680 static const struct mtk_gate apmixed_clks[] = { 645 681 /* AUDIO0 */ ··· 840 888 /* sentinel */ 841 889 } 842 890 }; 891 + MODULE_DEVICE_TABLE(of, of_match_clk_mt6765); 843 892 844 893 static int clk_mt6765_probe(struct platform_device *pdev) 845 894 { ··· 874 921 } 875 922 876 923 arch_initcall(clk_mt6765_init); 924 + MODULE_LICENSE("GPL");
+1
drivers/clk/mediatek/clk-mt6779-aud.c
··· 102 102 /* sentinel */ 103 103 } 104 104 }; 105 + MODULE_DEVICE_TABLE(of, of_match_clk_mt6779_aud); 105 106 106 107 static struct platform_driver clk_mt6779_aud_drv = { 107 108 .probe = mtk_clk_simple_probe,
+1
drivers/clk/mediatek/clk-mt6779-cam.c
··· 51 51 /* sentinel */ 52 52 } 53 53 }; 54 + MODULE_DEVICE_TABLE(of, of_match_clk_mt6779_cam); 54 55 55 56 static struct platform_driver clk_mt6779_cam_drv = { 56 57 .probe = mtk_clk_simple_probe,
+1
drivers/clk/mediatek/clk-mt6779-img.c
··· 43 43 /* sentinel */ 44 44 } 45 45 }; 46 + MODULE_DEVICE_TABLE(of, of_match_clk_mt6779_img); 46 47 47 48 static struct platform_driver clk_mt6779_img_drv = { 48 49 .probe = mtk_clk_simple_probe,
+1
drivers/clk/mediatek/clk-mt6779-ipe.c
··· 45 45 /* sentinel */ 46 46 } 47 47 }; 48 + MODULE_DEVICE_TABLE(of, of_match_clk_mt6779_ipe); 48 49 49 50 static struct platform_driver clk_mt6779_ipe_drv = { 50 51 .probe = mtk_clk_simple_probe,
+1
drivers/clk/mediatek/clk-mt6779-mfg.c
··· 40 40 /* sentinel */ 41 41 } 42 42 }; 43 + MODULE_DEVICE_TABLE(of, of_match_clk_mt6779_mfg); 43 44 44 45 static struct platform_driver clk_mt6779_mfg_drv = { 45 46 .probe = mtk_clk_simple_probe,
+12 -13
drivers/clk/mediatek/clk-mt6779-mm.c
··· 85 85 GATE_MM1(CLK_MM_DISP_OVL_FBDC, "mm_disp_ovl_fbdc", "mm_sel", 16), 86 86 }; 87 87 88 - static int clk_mt6779_mm_probe(struct platform_device *pdev) 89 - { 90 - struct device *dev = &pdev->dev; 91 - struct device_node *node = dev->parent->of_node; 92 - struct clk_hw_onecell_data *clk_data; 88 + static const struct mtk_clk_desc mm_desc = { 89 + .clks = mm_clks, 90 + .num_clks = ARRAY_SIZE(mm_clks), 91 + }; 93 92 94 - clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK); 95 - 96 - mtk_clk_register_gates(&pdev->dev, node, mm_clks, 97 - ARRAY_SIZE(mm_clks), clk_data); 98 - 99 - return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 100 - } 93 + static const struct platform_device_id clk_mt6779_mm_id_table[] = { 94 + { .name = "clk-mt6779-mm", .driver_data = (kernel_ulong_t)&mm_desc }, 95 + { /* sentinel */ } 96 + }; 97 + MODULE_DEVICE_TABLE(platform, clk_mt6779_mm_id_table); 101 98 102 99 static struct platform_driver clk_mt6779_mm_drv = { 103 - .probe = clk_mt6779_mm_probe, 100 + .probe = mtk_clk_pdev_probe, 101 + .remove = mtk_clk_pdev_remove, 104 102 .driver = { 105 103 .name = "clk-mt6779-mm", 106 104 }, 105 + .id_table = clk_mt6779_mm_id_table, 107 106 }; 108 107 109 108 module_platform_driver(clk_mt6779_mm_drv);
+1
drivers/clk/mediatek/clk-mt6779-vdec.c
··· 52 52 /* sentinel */ 53 53 } 54 54 }; 55 + MODULE_DEVICE_TABLE(of, of_match_clk_mt6779_vdec); 55 56 56 57 static struct platform_driver clk_mt6779_vdec_drv = { 57 58 .probe = mtk_clk_simple_probe,
+1
drivers/clk/mediatek/clk-mt6779-venc.c
··· 43 43 /* sentinel */ 44 44 } 45 45 }; 46 + MODULE_DEVICE_TABLE(of, of_match_clk_mt6779_venc); 46 47 47 48 static struct platform_driver clk_mt6779_venc_drv = { 48 49 .probe = mtk_clk_simple_probe,
+1
drivers/clk/mediatek/clk-mt6779.c
··· 1299 1299 { .compatible = "mediatek,mt6779-infracfg_ao", .data = &infra_desc }, 1300 1300 { /* sentinel */ } 1301 1301 }; 1302 + MODULE_DEVICE_TABLE(of, of_match_clk_mt6779); 1302 1303 1303 1304 static struct platform_driver clk_mt6779_infra_drv = { 1304 1305 .probe = mtk_clk_simple_probe,
+61 -3
drivers/clk/mediatek/clk-mt6795-apmixedsys.c
··· 7 7 #include <dt-bindings/clock/mediatek,mt6795-clk.h> 8 8 #include <linux/module.h> 9 9 #include <linux/platform_device.h> 10 + #include "clk-fhctl.h" 10 11 #include "clk-mtk.h" 11 12 #include "clk-pll.h" 13 + #include "clk-pllfh.h" 12 14 13 15 #define REG_REF2USB 0x8 14 16 #define REG_AP_PLL_CON7 0x1c ··· 60 58 PLL(CLK_APMIXED_APLL2, "apll2", 0x2b4, 0x2c4, 0, 0, 31, 0x2b4, 4, 0x2bc, 0x2b8, 0), 61 59 }; 62 60 61 + enum fh_pll_id { 62 + FH_CA53PLL_LL, 63 + FH_CA53PLL_BL, 64 + FH_MAINPLL, 65 + FH_MPLL, 66 + FH_MSDCPLL, 67 + FH_MMPLL, 68 + FH_VENCPLL, 69 + FH_TVDPLL, 70 + FH_VCODECPLL, 71 + FH_NR_FH, 72 + }; 73 + 74 + #define _FH(_pllid, _fhid, _slope, _offset) { \ 75 + .data = { \ 76 + .pll_id = _pllid, \ 77 + .fh_id = _fhid, \ 78 + .fh_ver = FHCTL_PLLFH_V1, \ 79 + .fhx_offset = _offset, \ 80 + .dds_mask = GENMASK(21, 0), \ 81 + .slope0_value = _slope, \ 82 + .slope1_value = _slope, \ 83 + .sfstrx_en = BIT(2), \ 84 + .frddsx_en = BIT(1), \ 85 + .fhctlx_en = BIT(0), \ 86 + .tgl_org = BIT(31), \ 87 + .dvfs_tri = BIT(31), \ 88 + .pcwchg = BIT(31), \ 89 + .dt_val = 0x0, \ 90 + .df_val = 0x9, \ 91 + .updnlmt_shft = 16, \ 92 + .msk_frddsx_dys = GENMASK(23, 20), \ 93 + .msk_frddsx_dts = GENMASK(19, 16), \ 94 + }, \ 95 + } 96 + 97 + #define FH(_pllid, _fhid, _offset) _FH(_pllid, _fhid, 0x6003c97, _offset) 98 + #define FH_M(_pllid, _fhid, _offset) _FH(_pllid, _fhid, 0x6000140, _offset) 99 + 100 + static struct mtk_pllfh_data pllfhs[] = { 101 + FH(CLK_APMIXED_ARMCA53PLL, FH_CA53PLL_BL, 0x38), 102 + FH(CLK_APMIXED_MAINPLL, FH_MAINPLL, 0x60), 103 + FH_M(CLK_APMIXED_MPLL, FH_MPLL, 0x74), 104 + FH(CLK_APMIXED_MSDCPLL, FH_MSDCPLL, 0x88), 105 + FH(CLK_APMIXED_MMPLL, FH_MMPLL, 0x9c), 106 + FH(CLK_APMIXED_VENCPLL, FH_VENCPLL, 0xb0), 107 + FH(CLK_APMIXED_TVDPLL, FH_TVDPLL, 0xc4), 108 + FH(CLK_APMIXED_VCODECPLL, FH_VCODECPLL, 0xd8), 109 + }; 110 + 63 111 static void clk_mt6795_apmixed_setup_md1(void __iomem *base) 64 112 { 65 113 void __iomem *reg = base + REG_AP_PLL_CON7; ··· 131 79 { .compatible = "mediatek,mt6795-apmixedsys" }, 132 80 { /* sentinel */ } 133 81 }; 82 + MODULE_DEVICE_TABLE(of, of_match_clk_mt6795_apmixed); 134 83 135 84 static int clk_mt6795_apmixed_probe(struct platform_device *pdev) 136 85 { 137 86 struct clk_hw_onecell_data *clk_data; 138 87 struct device *dev = &pdev->dev; 139 88 struct device_node *node = dev->of_node; 89 + const u8 *fhctl_node = "mediatek,mt6795-fhctl"; 140 90 void __iomem *base; 141 91 struct clk_hw *hw; 142 92 int ret; ··· 151 97 if (!clk_data) 152 98 return -ENOMEM; 153 99 154 - ret = mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data); 100 + fhctl_parse_dt(fhctl_node, pllfhs, ARRAY_SIZE(pllfhs)); 101 + ret = mtk_clk_register_pllfhs(node, plls, ARRAY_SIZE(plls), 102 + pllfhs, ARRAY_SIZE(pllfhs), clk_data); 155 103 if (ret) 156 104 goto free_clk_data; 157 105 ··· 180 124 unregister_ref2usb: 181 125 mtk_clk_unregister_ref2usb_tx(clk_data->hws[CLK_APMIXED_REF2USB_TX]); 182 126 unregister_plls: 183 - mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data); 127 + mtk_clk_unregister_pllfhs(plls, ARRAY_SIZE(plls), pllfhs, 128 + ARRAY_SIZE(pllfhs), clk_data); 184 129 free_clk_data: 185 130 mtk_free_clk_data(clk_data); 186 131 return ret; ··· 194 137 195 138 of_clk_del_provider(node); 196 139 mtk_clk_unregister_ref2usb_tx(clk_data->hws[CLK_APMIXED_REF2USB_TX]); 197 - mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data); 140 + mtk_clk_unregister_pllfhs(plls, ARRAY_SIZE(plls), pllfhs, 141 + ARRAY_SIZE(pllfhs), clk_data); 198 142 mtk_free_clk_data(clk_data); 199 143 200 144 return 0;
+1
drivers/clk/mediatek/clk-mt6795-infracfg.c
··· 81 81 { .compatible = "mediatek,mt6795-infracfg" }, 82 82 { /* sentinel */ } 83 83 }; 84 + MODULE_DEVICE_TABLE(of, of_match_clk_mt6795_infracfg); 84 85 85 86 static int clk_mt6795_infracfg_probe(struct platform_device *pdev) 86 87 {
+1
drivers/clk/mediatek/clk-mt6795-mfg.c
··· 35 35 { .compatible = "mediatek,mt6795-mfgcfg", .data = &mfg_desc }, 36 36 { /* sentinel */ } 37 37 }; 38 + MODULE_DEVICE_TABLE(of, of_match_clk_mt6795_mfg); 38 39 39 40 static struct platform_driver clk_mt6795_mfg_drv = { 40 41 .driver = {
+12 -44
drivers/clk/mediatek/clk-mt6795-mm.c
··· 76 76 GATE_MM1(CLK_MM_DPI_ENGINE, "mm_dpi_engine", "mm_sel", 9), 77 77 }; 78 78 79 - static int clk_mt6795_mm_probe(struct platform_device *pdev) 80 - { 81 - struct device *dev = &pdev->dev; 82 - struct device_node *node = dev->parent->of_node; 83 - struct clk_hw_onecell_data *clk_data; 84 - int ret; 79 + static const struct mtk_clk_desc mm_desc = { 80 + .clks = mm_gates, 81 + .num_clks = ARRAY_SIZE(mm_gates), 82 + }; 85 83 86 - clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK); 87 - if (!clk_data) 88 - return -ENOMEM; 89 - 90 - ret = mtk_clk_register_gates(&pdev->dev, node, mm_gates, 91 - ARRAY_SIZE(mm_gates), clk_data); 92 - if (ret) 93 - goto free_clk_data; 94 - 95 - ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 96 - if (ret) 97 - goto unregister_gates; 98 - 99 - platform_set_drvdata(pdev, clk_data); 100 - 101 - return 0; 102 - 103 - unregister_gates: 104 - mtk_clk_unregister_gates(mm_gates, ARRAY_SIZE(mm_gates), clk_data); 105 - free_clk_data: 106 - mtk_free_clk_data(clk_data); 107 - return ret; 108 - } 109 - 110 - static int clk_mt6795_mm_remove(struct platform_device *pdev) 111 - { 112 - struct device *dev = &pdev->dev; 113 - struct device_node *node = dev->parent->of_node; 114 - struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev); 115 - 116 - of_clk_del_provider(node); 117 - mtk_clk_unregister_gates(mm_gates, ARRAY_SIZE(mm_gates), clk_data); 118 - mtk_free_clk_data(clk_data); 119 - 120 - return 0; 121 - } 84 + static const struct platform_device_id clk_mt6795_mm_id_table[] = { 85 + { .name = "clk-mt6795-mm", .driver_data = (kernel_ulong_t)&mm_desc }, 86 + { /* sentinel */ } 87 + }; 88 + MODULE_DEVICE_TABLE(platform, clk_mt6795_mm_id_table); 122 89 123 90 static struct platform_driver clk_mt6795_mm_drv = { 124 91 .driver = { 125 92 .name = "clk-mt6795-mm", 126 93 }, 127 - .probe = clk_mt6795_mm_probe, 128 - .remove = clk_mt6795_mm_remove, 94 + .id_table = clk_mt6795_mm_id_table, 95 + .probe = mtk_clk_pdev_probe, 96 + .remove = mtk_clk_pdev_remove, 129 97 }; 130 98 module_platform_driver(clk_mt6795_mm_drv); 131 99
+1
drivers/clk/mediatek/clk-mt6795-pericfg.c
··· 89 89 { .compatible = "mediatek,mt6795-pericfg" }, 90 90 { /* sentinel */ } 91 91 }; 92 + MODULE_DEVICE_TABLE(of, of_match_clk_mt6795_pericfg); 92 93 93 94 static int clk_mt6795_pericfg_probe(struct platform_device *pdev) 94 95 {
+1
drivers/clk/mediatek/clk-mt6795-topckgen.c
··· 539 539 { .compatible = "mediatek,mt6795-topckgen", .data = &topck_desc }, 540 540 { /* sentinel */ } 541 541 }; 542 + MODULE_DEVICE_TABLE(of, of_match_clk_mt6795_topckgen); 542 543 543 544 static struct platform_driver clk_mt6795_topckgen_drv = { 544 545 .driver = {
+1
drivers/clk/mediatek/clk-mt6795-vdecsys.c
··· 40 40 { .compatible = "mediatek,mt6795-vdecsys", .data = &vdec_desc }, 41 41 { /* sentinel */ } 42 42 }; 43 + MODULE_DEVICE_TABLE(of, of_match_clk_mt6795_vdecsys); 43 44 44 45 static struct platform_driver clk_mt6795_vdecsys_drv = { 45 46 .probe = mtk_clk_simple_probe,
+1
drivers/clk/mediatek/clk-mt6795-vencsys.c
··· 35 35 { .compatible = "mediatek,mt6795-vencsys", .data = &venc_desc }, 36 36 { /* sentinel */ } 37 37 }; 38 + MODULE_DEVICE_TABLE(of, of_match_clk_mt6795_vencsys); 38 39 39 40 static struct platform_driver clk_mt6795_vencsys_drv = { 40 41 .driver = {
+5 -10
drivers/clk/mediatek/clk-mt6797-img.c
··· 16 16 .sta_ofs = 0x0000, 17 17 }; 18 18 19 - #define GATE_IMG(_id, _name, _parent, _shift) { \ 20 - .id = _id, \ 21 - .name = _name, \ 22 - .parent_name = _parent, \ 23 - .regs = &img_cg_regs, \ 24 - .shift = _shift, \ 25 - .ops = &mtk_clk_gate_ops_setclr, \ 26 - } 19 + #define GATE_IMG(_id, _name, _parent, _shift) \ 20 + GATE_MTK(_id, _name, _parent, &img_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 27 21 28 22 static const struct mtk_gate img_clks[] = { 29 23 GATE_IMG(CLK_IMG_FDVT, "img_fdvt", "mm_sel", 11), ··· 39 45 /* sentinel */ 40 46 } 41 47 }; 48 + MODULE_DEVICE_TABLE(of, of_match_clk_mt6797_img); 42 49 43 50 static struct platform_driver clk_mt6797_img_drv = { 44 51 .probe = mtk_clk_simple_probe, ··· 49 54 .of_match_table = of_match_clk_mt6797_img, 50 55 }, 51 56 }; 52 - 53 - builtin_platform_driver(clk_mt6797_img_drv); 57 + module_platform_driver(clk_mt6797_img_drv); 58 + MODULE_LICENSE("GPL");
+18 -38
drivers/clk/mediatek/clk-mt6797-mm.c
··· 23 23 .sta_ofs = 0x0110, 24 24 }; 25 25 26 - #define GATE_MM0(_id, _name, _parent, _shift) { \ 27 - .id = _id, \ 28 - .name = _name, \ 29 - .parent_name = _parent, \ 30 - .regs = &mm0_cg_regs, \ 31 - .shift = _shift, \ 32 - .ops = &mtk_clk_gate_ops_setclr, \ 33 - } 26 + #define GATE_MM0(_id, _name, _parent, _shift) \ 27 + GATE_MTK(_id, _name, _parent, &mm0_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 34 28 35 - #define GATE_MM1(_id, _name, _parent, _shift) { \ 36 - .id = _id, \ 37 - .name = _name, \ 38 - .parent_name = _parent, \ 39 - .regs = &mm1_cg_regs, \ 40 - .shift = _shift, \ 41 - .ops = &mtk_clk_gate_ops_setclr, \ 42 - } 29 + #define GATE_MM1(_id, _name, _parent, _shift) \ 30 + GATE_MTK(_id, _name, _parent, &mm1_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 43 31 44 32 static const struct mtk_gate mm_clks[] = { 45 33 GATE_MM0(CLK_MM_SMI_COMMON, "mm_smi_common", "mm_sel", 0), ··· 80 92 "clk26m", 3), 81 93 }; 82 94 83 - static int clk_mt6797_mm_probe(struct platform_device *pdev) 84 - { 85 - struct device *dev = &pdev->dev; 86 - struct device_node *node = dev->parent->of_node; 87 - struct clk_hw_onecell_data *clk_data; 88 - int r; 95 + static const struct mtk_clk_desc mm_desc = { 96 + .clks = mm_clks, 97 + .num_clks = ARRAY_SIZE(mm_clks), 98 + }; 89 99 90 - clk_data = mtk_alloc_clk_data(CLK_MM_NR); 91 - 92 - mtk_clk_register_gates(&pdev->dev, node, mm_clks, 93 - ARRAY_SIZE(mm_clks), clk_data); 94 - 95 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 96 - if (r) 97 - dev_err(&pdev->dev, 98 - "could not register clock provider: %s: %d\n", 99 - pdev->name, r); 100 - 101 - return r; 102 - } 100 + static const struct platform_device_id clk_mt6797_mm_id_table[] = { 101 + { .name = "clk-mt6797-mm", .driver_data = (kernel_ulong_t)&mm_desc }, 102 + { /* sentinel */ } 103 + }; 104 + MODULE_DEVICE_TABLE(platform, clk_mt6797_mm_id_table); 103 105 104 106 static struct platform_driver clk_mt6797_mm_drv = { 105 - .probe = clk_mt6797_mm_probe, 107 + .probe = mtk_clk_pdev_probe, 108 + .remove = mtk_clk_pdev_remove, 106 109 .driver = { 107 110 .name = "clk-mt6797-mm", 108 111 }, 112 + .id_table = clk_mt6797_mm_id_table, 109 113 }; 110 - 111 - builtin_platform_driver(clk_mt6797_mm_drv); 114 + module_platform_driver(clk_mt6797_mm_drv); 115 + MODULE_LICENSE("GPL");
+7 -18
drivers/clk/mediatek/clk-mt6797-vdec.c
··· 24 24 .sta_ofs = 0x0008, 25 25 }; 26 26 27 - #define GATE_VDEC0(_id, _name, _parent, _shift) { \ 28 - .id = _id, \ 29 - .name = _name, \ 30 - .parent_name = _parent, \ 31 - .regs = &vdec0_cg_regs, \ 32 - .shift = _shift, \ 33 - .ops = &mtk_clk_gate_ops_setclr_inv, \ 34 - } 27 + #define GATE_VDEC0(_id, _name, _parent, _shift) \ 28 + GATE_MTK(_id, _name, _parent, &vdec0_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv) 35 29 36 - #define GATE_VDEC1(_id, _name, _parent, _shift) { \ 37 - .id = _id, \ 38 - .name = _name, \ 39 - .parent_name = _parent, \ 40 - .regs = &vdec1_cg_regs, \ 41 - .shift = _shift, \ 42 - .ops = &mtk_clk_gate_ops_setclr_inv, \ 43 - } 30 + #define GATE_VDEC1(_id, _name, _parent, _shift) \ 31 + GATE_MTK(_id, _name, _parent, &vdec1_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv) 44 32 45 33 static const struct mtk_gate vdec_clks[] = { 46 34 GATE_VDEC0(CLK_VDEC_CKEN_ENG, "vdec_cken_eng", "vdec_sel", 8), ··· 50 62 /* sentinel */ 51 63 } 52 64 }; 65 + MODULE_DEVICE_TABLE(of, of_match_clk_mt6797_vdec); 53 66 54 67 static struct platform_driver clk_mt6797_vdec_drv = { 55 68 .probe = mtk_clk_simple_probe, ··· 60 71 .of_match_table = of_match_clk_mt6797_vdec, 61 72 }, 62 73 }; 63 - 64 - builtin_platform_driver(clk_mt6797_vdec_drv); 74 + module_platform_driver(clk_mt6797_vdec_drv); 75 + MODULE_LICENSE("GPL");
+5 -10
drivers/clk/mediatek/clk-mt6797-venc.c
··· 18 18 .sta_ofs = 0x0000, 19 19 }; 20 20 21 - #define GATE_VENC(_id, _name, _parent, _shift) { \ 22 - .id = _id, \ 23 - .name = _name, \ 24 - .parent_name = _parent, \ 25 - .regs = &venc_cg_regs, \ 26 - .shift = _shift, \ 27 - .ops = &mtk_clk_gate_ops_setclr_inv, \ 28 - } 21 + #define GATE_VENC(_id, _name, _parent, _shift) \ 22 + GATE_MTK(_id, _name, _parent, &venc_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv) 29 23 30 24 static const struct mtk_gate venc_clks[] = { 31 25 GATE_VENC(CLK_VENC_0, "venc_0", "mm_sel", 0), ··· 41 47 /* sentinel */ 42 48 } 43 49 }; 50 + MODULE_DEVICE_TABLE(of, of_match_clk_mt6797_venc); 44 51 45 52 static struct platform_driver clk_mt6797_venc_drv = { 46 53 .probe = mtk_clk_simple_probe, ··· 51 56 .of_match_table = of_match_clk_mt6797_venc, 52 57 }, 53 58 }; 54 - 55 - builtin_platform_driver(clk_mt6797_venc_drv); 59 + module_platform_driver(clk_mt6797_venc_drv); 60 + MODULE_LICENSE("GPL");
+14 -30
drivers/clk/mediatek/clk-mt6797.c
··· 421 421 .sta_ofs = 0x00b0, 422 422 }; 423 423 424 - #define GATE_ICG0(_id, _name, _parent, _shift) { \ 425 - .id = _id, \ 426 - .name = _name, \ 427 - .parent_name = _parent, \ 428 - .regs = &infra0_cg_regs, \ 429 - .shift = _shift, \ 430 - .ops = &mtk_clk_gate_ops_setclr, \ 431 - } 424 + #define GATE_ICG0(_id, _name, _parent, _shift) \ 425 + GATE_MTK(_id, _name, _parent, &infra0_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 432 426 433 - #define GATE_ICG1(_id, _name, _parent, _shift) \ 434 - GATE_ICG1_FLAGS(_id, _name, _parent, _shift, 0) 427 + #define GATE_ICG1(_id, _name, _parent, _shift) \ 428 + GATE_MTK(_id, _name, _parent, &infra1_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 435 429 436 - #define GATE_ICG1_FLAGS(_id, _name, _parent, _shift, _flags) { \ 437 - .id = _id, \ 438 - .name = _name, \ 439 - .parent_name = _parent, \ 440 - .regs = &infra1_cg_regs, \ 441 - .shift = _shift, \ 442 - .ops = &mtk_clk_gate_ops_setclr, \ 443 - .flags = _flags, \ 444 - } 430 + #define GATE_ICG1_FLAGS(_id, _name, _parent, _shift, _flags) \ 431 + GATE_MTK_FLAGS(_id, _name, _parent, &infra1_cg_regs, _shift, \ 432 + &mtk_clk_gate_ops_setclr, _flags) 445 433 446 - #define GATE_ICG2(_id, _name, _parent, _shift) \ 447 - GATE_ICG2_FLAGS(_id, _name, _parent, _shift, 0) 434 + #define GATE_ICG2(_id, _name, _parent, _shift) \ 435 + GATE_MTK(_id, _name, _parent, &infra2_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 448 436 449 - #define GATE_ICG2_FLAGS(_id, _name, _parent, _shift, _flags) { \ 450 - .id = _id, \ 451 - .name = _name, \ 452 - .parent_name = _parent, \ 453 - .regs = &infra2_cg_regs, \ 454 - .shift = _shift, \ 455 - .ops = &mtk_clk_gate_ops_setclr, \ 456 - .flags = _flags, \ 457 - } 437 + #define GATE_ICG2_FLAGS(_id, _name, _parent, _shift, _flags) \ 438 + GATE_MTK_FLAGS(_id, _name, _parent, &infra2_cg_regs, _shift, \ 439 + &mtk_clk_gate_ops_setclr, _flags) 458 440 459 441 /* 460 442 * Clock gates dramc and dramc_b are needed by the DRAM controller. ··· 670 688 /* sentinel */ 671 689 } 672 690 }; 691 + MODULE_DEVICE_TABLE(of, of_match_clk_mt6797); 673 692 674 693 static int clk_mt6797_probe(struct platform_device *pdev) 675 694 { ··· 704 721 } 705 722 706 723 arch_initcall(clk_mt6797_init); 724 + MODULE_LICENSE("GPL");
+152
drivers/clk/mediatek/clk-mt7622-apmixedsys.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Copyright (c) 2017 MediaTek Inc. 4 + * Copyright (c) 2023 Collabora, Ltd. 5 + * AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> 6 + */ 7 + 8 + #include <dt-bindings/clock/mt7622-clk.h> 9 + #include <linux/clk.h> 10 + #include <linux/of.h> 11 + #include <linux/platform_device.h> 12 + 13 + #include "clk-gate.h" 14 + #include "clk-mtk.h" 15 + #include "clk-pll.h" 16 + 17 + #define MT7622_PLL_FMAX (2500UL * MHZ) 18 + #define CON0_MT7622_RST_BAR BIT(27) 19 + 20 + #define PLL_xtal(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits,\ 21 + _pd_reg, _pd_shift, _tuner_reg, _pcw_reg, \ 22 + _pcw_shift, _div_table, _parent_name) { \ 23 + .id = _id, \ 24 + .name = _name, \ 25 + .reg = _reg, \ 26 + .pwr_reg = _pwr_reg, \ 27 + .en_mask = _en_mask, \ 28 + .flags = _flags, \ 29 + .rst_bar_mask = CON0_MT7622_RST_BAR, \ 30 + .fmax = MT7622_PLL_FMAX, \ 31 + .pcwbits = _pcwbits, \ 32 + .pd_reg = _pd_reg, \ 33 + .pd_shift = _pd_shift, \ 34 + .tuner_reg = _tuner_reg, \ 35 + .pcw_reg = _pcw_reg, \ 36 + .pcw_shift = _pcw_shift, \ 37 + .div_table = _div_table, \ 38 + .parent_name = _parent_name, \ 39 + } 40 + 41 + #define PLL(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits, \ 42 + _pd_reg, _pd_shift, _tuner_reg, _pcw_reg, \ 43 + _pcw_shift) \ 44 + PLL_xtal(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits,\ 45 + _pd_reg, _pd_shift, _tuner_reg, _pcw_reg, _pcw_shift, \ 46 + NULL, "clkxtal") 47 + 48 + static const struct mtk_gate_regs apmixed_cg_regs = { 49 + .set_ofs = 0x8, 50 + .clr_ofs = 0x8, 51 + .sta_ofs = 0x8, 52 + }; 53 + 54 + #define GATE_APMIXED_AO(_id, _name, _parent, _shift) \ 55 + GATE_MTK_FLAGS(_id, _name, _parent, &apmixed_cg_regs, _shift, \ 56 + &mtk_clk_gate_ops_no_setclr_inv, CLK_IS_CRITICAL) 57 + 58 + static const struct mtk_pll_data plls[] = { 59 + PLL(CLK_APMIXED_ARMPLL, "armpll", 0x0200, 0x020C, 0, 60 + PLL_AO, 21, 0x0204, 24, 0, 0x0204, 0), 61 + PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0210, 0x021C, 0, 62 + HAVE_RST_BAR, 21, 0x0214, 24, 0, 0x0214, 0), 63 + PLL(CLK_APMIXED_UNIV2PLL, "univ2pll", 0x0220, 0x022C, 0, 64 + HAVE_RST_BAR, 7, 0x0224, 24, 0, 0x0224, 14), 65 + PLL(CLK_APMIXED_ETH1PLL, "eth1pll", 0x0300, 0x0310, 0, 66 + 0, 21, 0x0300, 1, 0, 0x0304, 0), 67 + PLL(CLK_APMIXED_ETH2PLL, "eth2pll", 0x0314, 0x0320, 0, 68 + 0, 21, 0x0314, 1, 0, 0x0318, 0), 69 + PLL(CLK_APMIXED_AUD1PLL, "aud1pll", 0x0324, 0x0330, 0, 70 + 0, 31, 0x0324, 1, 0, 0x0328, 0), 71 + PLL(CLK_APMIXED_AUD2PLL, "aud2pll", 0x0334, 0x0340, 0, 72 + 0, 31, 0x0334, 1, 0, 0x0338, 0), 73 + PLL(CLK_APMIXED_TRGPLL, "trgpll", 0x0344, 0x0354, 0, 74 + 0, 21, 0x0344, 1, 0, 0x0348, 0), 75 + PLL(CLK_APMIXED_SGMIPLL, "sgmipll", 0x0358, 0x0368, 0, 76 + 0, 21, 0x0358, 1, 0, 0x035C, 0), 77 + }; 78 + 79 + static const struct mtk_gate apmixed_clks[] = { 80 + GATE_APMIXED_AO(CLK_APMIXED_MAIN_CORE_EN, "main_core_en", "mainpll", 5), 81 + }; 82 + 83 + static int clk_mt7622_apmixed_probe(struct platform_device *pdev) 84 + { 85 + void __iomem *base; 86 + struct clk_hw_onecell_data *clk_data; 87 + struct device_node *node = pdev->dev.of_node; 88 + struct device *dev = &pdev->dev; 89 + int ret; 90 + 91 + base = devm_platform_ioremap_resource(pdev, 0); 92 + if (IS_ERR(base)) 93 + return PTR_ERR(base); 94 + 95 + clk_data = mtk_devm_alloc_clk_data(dev, CLK_APMIXED_NR_CLK); 96 + if (!clk_data) 97 + return -ENOMEM; 98 + 99 + ret = mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data); 100 + if (ret) 101 + return ret; 102 + 103 + ret = mtk_clk_register_gates(&pdev->dev, node, apmixed_clks, 104 + ARRAY_SIZE(apmixed_clks), clk_data); 105 + if (ret) 106 + goto unregister_plls; 107 + 108 + ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 109 + if (ret) 110 + goto unregister_gates; 111 + 112 + return 0; 113 + 114 + unregister_gates: 115 + mtk_clk_unregister_gates(apmixed_clks, ARRAY_SIZE(apmixed_clks), clk_data); 116 + unregister_plls: 117 + mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data); 118 + 119 + return ret; 120 + } 121 + 122 + static int clk_mt7622_apmixed_remove(struct platform_device *pdev) 123 + { 124 + struct device_node *node = pdev->dev.of_node; 125 + struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev); 126 + 127 + of_clk_del_provider(node); 128 + mtk_clk_unregister_gates(apmixed_clks, ARRAY_SIZE(apmixed_clks), clk_data); 129 + mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data); 130 + mtk_free_clk_data(clk_data); 131 + 132 + return 0; 133 + } 134 + 135 + static const struct of_device_id of_match_clk_mt7622_apmixed[] = { 136 + { .compatible = "mediatek,mt7622-apmixedsys" }, 137 + { /* sentinel */ } 138 + }; 139 + MODULE_DEVICE_TABLE(of, of_match_clk_mt7622_apmixed); 140 + 141 + static struct platform_driver clk_mt7622_apmixed_drv = { 142 + .probe = clk_mt7622_apmixed_probe, 143 + .remove = clk_mt7622_apmixed_remove, 144 + .driver = { 145 + .name = "clk-mt7622-apmixed", 146 + .of_match_table = of_match_clk_mt7622_apmixed, 147 + }, 148 + }; 149 + module_platform_driver(clk_mt7622_apmixed_drv) 150 + 151 + MODULE_DESCRIPTION("MediaTek MT7622 apmixedsys clocks driver"); 152 + MODULE_LICENSE("GPL");
+11 -34
drivers/clk/mediatek/clk-mt7622-aud.c
··· 16 16 17 17 #include <dt-bindings/clock/mt7622-clk.h> 18 18 19 - #define GATE_AUDIO0(_id, _name, _parent, _shift) { \ 20 - .id = _id, \ 21 - .name = _name, \ 22 - .parent_name = _parent, \ 23 - .regs = &audio0_cg_regs, \ 24 - .shift = _shift, \ 25 - .ops = &mtk_clk_gate_ops_no_setclr, \ 26 - } 19 + #define GATE_AUDIO0(_id, _name, _parent, _shift) \ 20 + GATE_MTK(_id, _name, _parent, &audio0_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr) 27 21 28 - #define GATE_AUDIO1(_id, _name, _parent, _shift) { \ 29 - .id = _id, \ 30 - .name = _name, \ 31 - .parent_name = _parent, \ 32 - .regs = &audio1_cg_regs, \ 33 - .shift = _shift, \ 34 - .ops = &mtk_clk_gate_ops_no_setclr, \ 35 - } 22 + #define GATE_AUDIO1(_id, _name, _parent, _shift) \ 23 + GATE_MTK(_id, _name, _parent, &audio1_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr) 36 24 37 - #define GATE_AUDIO2(_id, _name, _parent, _shift) { \ 38 - .id = _id, \ 39 - .name = _name, \ 40 - .parent_name = _parent, \ 41 - .regs = &audio2_cg_regs, \ 42 - .shift = _shift, \ 43 - .ops = &mtk_clk_gate_ops_no_setclr, \ 44 - } 25 + #define GATE_AUDIO2(_id, _name, _parent, _shift) \ 26 + GATE_MTK(_id, _name, _parent, &audio2_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr) 45 27 46 - #define GATE_AUDIO3(_id, _name, _parent, _shift) { \ 47 - .id = _id, \ 48 - .name = _name, \ 49 - .parent_name = _parent, \ 50 - .regs = &audio3_cg_regs, \ 51 - .shift = _shift, \ 52 - .ops = &mtk_clk_gate_ops_no_setclr, \ 53 - } 28 + #define GATE_AUDIO3(_id, _name, _parent, _shift) \ 29 + GATE_MTK(_id, _name, _parent, &audio3_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr) 54 30 55 31 static const struct mtk_gate_regs audio0_cg_regs = { 56 32 .set_ofs = 0x0, ··· 145 169 { .compatible = "mediatek,mt7622-audsys", .data = &audio_desc }, 146 170 { /* sentinel */ } 147 171 }; 172 + MODULE_DEVICE_TABLE(of, of_match_clk_mt7622_aud); 148 173 149 174 static struct platform_driver clk_mt7622_aud_drv = { 150 175 .probe = clk_mt7622_aud_probe, ··· 155 178 .of_match_table = of_match_clk_mt7622_aud, 156 179 }, 157 180 }; 158 - 159 - builtin_platform_driver(clk_mt7622_aud_drv); 181 + module_platform_driver(clk_mt7622_aud_drv); 182 + MODULE_LICENSE("GPL");
+7 -18
drivers/clk/mediatek/clk-mt7622-eth.c
··· 16 16 17 17 #include <dt-bindings/clock/mt7622-clk.h> 18 18 19 - #define GATE_ETH(_id, _name, _parent, _shift) { \ 20 - .id = _id, \ 21 - .name = _name, \ 22 - .parent_name = _parent, \ 23 - .regs = &eth_cg_regs, \ 24 - .shift = _shift, \ 25 - .ops = &mtk_clk_gate_ops_no_setclr_inv, \ 26 - } 19 + #define GATE_ETH(_id, _name, _parent, _shift) \ 20 + GATE_MTK(_id, _name, _parent, &eth_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv) 27 21 28 22 static const struct mtk_gate_regs eth_cg_regs = { 29 23 .set_ofs = 0x30, ··· 39 45 .sta_ofs = 0xE4, 40 46 }; 41 47 42 - #define GATE_SGMII(_id, _name, _parent, _shift) { \ 43 - .id = _id, \ 44 - .name = _name, \ 45 - .parent_name = _parent, \ 46 - .regs = &sgmii_cg_regs, \ 47 - .shift = _shift, \ 48 - .ops = &mtk_clk_gate_ops_no_setclr_inv, \ 49 - } 48 + #define GATE_SGMII(_id, _name, _parent, _shift) \ 49 + GATE_MTK(_id, _name, _parent, &sgmii_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv) 50 50 51 51 static const struct mtk_gate sgmii_clks[] = { 52 52 GATE_SGMII(CLK_SGMII_TX250M_EN, "sgmii_tx250m_en", ··· 77 89 { .compatible = "mediatek,mt7622-sgmiisys", .data = &sgmii_desc }, 78 90 { /* sentinel */ } 79 91 }; 92 + MODULE_DEVICE_TABLE(of, of_match_clk_mt7622_eth); 80 93 81 94 static struct platform_driver clk_mt7622_eth_drv = { 82 95 .probe = mtk_clk_simple_probe, ··· 87 98 .of_match_table = of_match_clk_mt7622_eth, 88 99 }, 89 100 }; 90 - 91 - builtin_platform_driver(clk_mt7622_eth_drv); 101 + module_platform_driver(clk_mt7622_eth_drv); 102 + MODULE_LICENSE("GPL");
+7 -18
drivers/clk/mediatek/clk-mt7622-hif.c
··· 16 16 17 17 #include <dt-bindings/clock/mt7622-clk.h> 18 18 19 - #define GATE_PCIE(_id, _name, _parent, _shift) { \ 20 - .id = _id, \ 21 - .name = _name, \ 22 - .parent_name = _parent, \ 23 - .regs = &pcie_cg_regs, \ 24 - .shift = _shift, \ 25 - .ops = &mtk_clk_gate_ops_no_setclr_inv, \ 26 - } 19 + #define GATE_PCIE(_id, _name, _parent, _shift) \ 20 + GATE_MTK(_id, _name, _parent, &pcie_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv) 27 21 28 - #define GATE_SSUSB(_id, _name, _parent, _shift) { \ 29 - .id = _id, \ 30 - .name = _name, \ 31 - .parent_name = _parent, \ 32 - .regs = &ssusb_cg_regs, \ 33 - .shift = _shift, \ 34 - .ops = &mtk_clk_gate_ops_no_setclr_inv, \ 35 - } 22 + #define GATE_SSUSB(_id, _name, _parent, _shift) \ 23 + GATE_MTK(_id, _name, _parent, &ssusb_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv) 36 24 37 25 static const struct mtk_gate_regs pcie_cg_regs = { 38 26 .set_ofs = 0x30, ··· 89 101 { .compatible = "mediatek,mt7622-ssusbsys", .data = &ssusb_desc }, 90 102 { /* sentinel */ } 91 103 }; 104 + MODULE_DEVICE_TABLE(of, of_match_clk_mt7622_hif); 92 105 93 106 static struct platform_driver clk_mt7622_hif_drv = { 94 107 .probe = mtk_clk_simple_probe, ··· 99 110 .of_match_table = of_match_clk_mt7622_hif, 100 111 }, 101 112 }; 102 - 103 - builtin_platform_driver(clk_mt7622_hif_drv); 113 + module_platform_driver(clk_mt7622_hif_drv); 114 + MODULE_LICENSE("GPL");
+128
drivers/clk/mediatek/clk-mt7622-infracfg.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Copyright (c) 2017 MediaTek Inc. 4 + * Copyright (c) 2023 Collabora, Ltd. 5 + * AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> 6 + */ 7 + 8 + #include <dt-bindings/clock/mt7622-clk.h> 9 + #include <linux/module.h> 10 + #include <linux/platform_device.h> 11 + 12 + #include "clk-cpumux.h" 13 + #include "clk-gate.h" 14 + #include "clk-mtk.h" 15 + #include "reset.h" 16 + 17 + #define GATE_INFRA(_id, _name, _parent, _shift) \ 18 + GATE_MTK(_id, _name, _parent, &infra_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 19 + 20 + static const struct mtk_gate_regs infra_cg_regs = { 21 + .set_ofs = 0x40, 22 + .clr_ofs = 0x44, 23 + .sta_ofs = 0x48, 24 + }; 25 + 26 + static const char * const infra_mux1_parents[] = { 27 + "clkxtal", 28 + "armpll", 29 + "main_core_en", 30 + "armpll" 31 + }; 32 + 33 + static const struct mtk_composite cpu_muxes[] = { 34 + MUX(CLK_INFRA_MUX1_SEL, "infra_mux1_sel", infra_mux1_parents, 0x000, 2, 2), 35 + }; 36 + 37 + static const struct mtk_gate infra_clks[] = { 38 + GATE_INFRA(CLK_INFRA_DBGCLK_PD, "infra_dbgclk_pd", "axi_sel", 0), 39 + GATE_INFRA(CLK_INFRA_TRNG, "trng_ck", "axi_sel", 2), 40 + GATE_INFRA(CLK_INFRA_AUDIO_PD, "infra_audio_pd", "aud_intbus_sel", 5), 41 + GATE_INFRA(CLK_INFRA_IRRX_PD, "infra_irrx_pd", "irrx_sel", 16), 42 + GATE_INFRA(CLK_INFRA_APXGPT_PD, "infra_apxgpt_pd", "f10m_ref_sel", 18), 43 + GATE_INFRA(CLK_INFRA_PMIC_PD, "infra_pmic_pd", "pmicspi_sel", 22), 44 + }; 45 + 46 + static u16 infrasys_rst_ofs[] = { 0x30 }; 47 + 48 + static const struct mtk_clk_rst_desc clk_rst_desc = { 49 + .version = MTK_RST_SIMPLE, 50 + .rst_bank_ofs = infrasys_rst_ofs, 51 + .rst_bank_nr = ARRAY_SIZE(infrasys_rst_ofs), 52 + }; 53 + 54 + static const struct of_device_id of_match_clk_mt7622_infracfg[] = { 55 + { .compatible = "mediatek,mt7622-infracfg" }, 56 + { /* sentinel */ } 57 + }; 58 + MODULE_DEVICE_TABLE(of, of_match_clk_mt7622_infracfg); 59 + 60 + static int clk_mt7622_infracfg_probe(struct platform_device *pdev) 61 + { 62 + struct clk_hw_onecell_data *clk_data; 63 + struct device_node *node = pdev->dev.of_node; 64 + void __iomem *base; 65 + int ret; 66 + 67 + base = devm_platform_ioremap_resource(pdev, 0); 68 + if (IS_ERR(base)) 69 + return PTR_ERR(base); 70 + 71 + clk_data = mtk_alloc_clk_data(CLK_INFRA_NR_CLK); 72 + if (!clk_data) 73 + return -ENOMEM; 74 + 75 + ret = mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc); 76 + if (ret) 77 + goto free_clk_data; 78 + 79 + ret = mtk_clk_register_gates(&pdev->dev, node, infra_clks, 80 + ARRAY_SIZE(infra_clks), clk_data); 81 + if (ret) 82 + goto free_clk_data; 83 + 84 + ret = mtk_clk_register_cpumuxes(&pdev->dev, node, cpu_muxes, 85 + ARRAY_SIZE(cpu_muxes), clk_data); 86 + if (ret) 87 + goto unregister_gates; 88 + 89 + ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 90 + if (ret) 91 + goto unregister_cpumuxes; 92 + 93 + return 0; 94 + 95 + unregister_cpumuxes: 96 + mtk_clk_unregister_cpumuxes(cpu_muxes, ARRAY_SIZE(cpu_muxes), clk_data); 97 + unregister_gates: 98 + mtk_clk_unregister_gates(infra_clks, ARRAY_SIZE(infra_clks), clk_data); 99 + free_clk_data: 100 + mtk_free_clk_data(clk_data); 101 + return ret; 102 + } 103 + 104 + static int clk_mt7622_infracfg_remove(struct platform_device *pdev) 105 + { 106 + struct device_node *node = pdev->dev.of_node; 107 + struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev); 108 + 109 + of_clk_del_provider(node); 110 + mtk_clk_unregister_cpumuxes(cpu_muxes, ARRAY_SIZE(cpu_muxes), clk_data); 111 + mtk_clk_unregister_gates(infra_clks, ARRAY_SIZE(infra_clks), clk_data); 112 + mtk_free_clk_data(clk_data); 113 + 114 + return 0; 115 + } 116 + 117 + static struct platform_driver clk_mt7622_infracfg_drv = { 118 + .driver = { 119 + .name = "clk-mt7622-infracfg", 120 + .of_match_table = of_match_clk_mt7622_infracfg, 121 + }, 122 + .probe = clk_mt7622_infracfg_probe, 123 + .remove = clk_mt7622_infracfg_remove, 124 + }; 125 + module_platform_driver(clk_mt7622_infracfg_drv); 126 + 127 + MODULE_DESCRIPTION("MediaTek MT7622 infracfg clocks driver"); 128 + MODULE_LICENSE("GPL");
+52 -309
drivers/clk/mediatek/clk-mt7622.c
··· 14 14 #include "clk-cpumux.h" 15 15 #include "clk-gate.h" 16 16 #include "clk-mtk.h" 17 - #include "clk-pll.h" 18 17 19 18 #include <dt-bindings/clock/mt7622-clk.h> 20 19 #include <linux/clk.h> /* for consumer */ 21 20 22 - #define MT7622_PLL_FMAX (2500UL * MHZ) 23 - #define CON0_MT7622_RST_BAR BIT(27) 21 + #define GATE_TOP0(_id, _name, _parent, _shift) \ 22 + GATE_MTK(_id, _name, _parent, &top0_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr) 24 23 25 - #define PLL_xtal(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits,\ 26 - _pd_reg, _pd_shift, _tuner_reg, _pcw_reg, \ 27 - _pcw_shift, _div_table, _parent_name) { \ 28 - .id = _id, \ 29 - .name = _name, \ 30 - .reg = _reg, \ 31 - .pwr_reg = _pwr_reg, \ 32 - .en_mask = _en_mask, \ 33 - .flags = _flags, \ 34 - .rst_bar_mask = CON0_MT7622_RST_BAR, \ 35 - .fmax = MT7622_PLL_FMAX, \ 36 - .pcwbits = _pcwbits, \ 37 - .pd_reg = _pd_reg, \ 38 - .pd_shift = _pd_shift, \ 39 - .tuner_reg = _tuner_reg, \ 40 - .pcw_reg = _pcw_reg, \ 41 - .pcw_shift = _pcw_shift, \ 42 - .div_table = _div_table, \ 43 - .parent_name = _parent_name, \ 44 - } 24 + #define GATE_TOP1(_id, _name, _parent, _shift) \ 25 + GATE_MTK(_id, _name, _parent, &top1_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr) 45 26 46 - #define PLL(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits, \ 47 - _pd_reg, _pd_shift, _tuner_reg, _pcw_reg, \ 48 - _pcw_shift) \ 49 - PLL_xtal(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits,\ 50 - _pd_reg, _pd_shift, _tuner_reg, _pcw_reg, _pcw_shift, \ 51 - NULL, "clkxtal") 27 + #define GATE_PERI0(_id, _name, _parent, _shift) \ 28 + GATE_MTK(_id, _name, _parent, &peri0_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 52 29 53 - #define GATE_APMIXED(_id, _name, _parent, _shift) { \ 54 - .id = _id, \ 55 - .name = _name, \ 56 - .parent_name = _parent, \ 57 - .regs = &apmixed_cg_regs, \ 58 - .shift = _shift, \ 59 - .ops = &mtk_clk_gate_ops_no_setclr_inv, \ 60 - } 30 + #define GATE_PERI0_AO(_id, _name, _parent, _shift) \ 31 + GATE_MTK_FLAGS(_id, _name, _parent, &peri0_cg_regs, _shift, \ 32 + &mtk_clk_gate_ops_setclr, CLK_IS_CRITICAL) 61 33 62 - #define GATE_INFRA(_id, _name, _parent, _shift) { \ 63 - .id = _id, \ 64 - .name = _name, \ 65 - .parent_name = _parent, \ 66 - .regs = &infra_cg_regs, \ 67 - .shift = _shift, \ 68 - .ops = &mtk_clk_gate_ops_setclr, \ 69 - } 70 - 71 - #define GATE_TOP0(_id, _name, _parent, _shift) { \ 72 - .id = _id, \ 73 - .name = _name, \ 74 - .parent_name = _parent, \ 75 - .regs = &top0_cg_regs, \ 76 - .shift = _shift, \ 77 - .ops = &mtk_clk_gate_ops_no_setclr, \ 78 - } 79 - 80 - #define GATE_TOP1(_id, _name, _parent, _shift) { \ 81 - .id = _id, \ 82 - .name = _name, \ 83 - .parent_name = _parent, \ 84 - .regs = &top1_cg_regs, \ 85 - .shift = _shift, \ 86 - .ops = &mtk_clk_gate_ops_no_setclr, \ 87 - } 88 - 89 - #define GATE_PERI0(_id, _name, _parent, _shift) { \ 90 - .id = _id, \ 91 - .name = _name, \ 92 - .parent_name = _parent, \ 93 - .regs = &peri0_cg_regs, \ 94 - .shift = _shift, \ 95 - .ops = &mtk_clk_gate_ops_setclr, \ 96 - } 97 - 98 - #define GATE_PERI1(_id, _name, _parent, _shift) { \ 99 - .id = _id, \ 100 - .name = _name, \ 101 - .parent_name = _parent, \ 102 - .regs = &peri1_cg_regs, \ 103 - .shift = _shift, \ 104 - .ops = &mtk_clk_gate_ops_setclr, \ 105 - } 34 + #define GATE_PERI1(_id, _name, _parent, _shift) \ 35 + GATE_MTK(_id, _name, _parent, &peri1_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 106 36 107 37 static DEFINE_SPINLOCK(mt7622_clk_lock); 108 - 109 - static const char * const infra_mux1_parents[] = { 110 - "clkxtal", 111 - "armpll", 112 - "main_core_en", 113 - "armpll" 114 - }; 115 38 116 39 static const char * const axi_parents[] = { 117 40 "clkxtal", ··· 215 292 "syspll1_d4" 216 293 }; 217 294 218 - static const struct mtk_gate_regs apmixed_cg_regs = { 219 - .set_ofs = 0x8, 220 - .clr_ofs = 0x8, 221 - .sta_ofs = 0x8, 222 - }; 223 - 224 - static const struct mtk_gate_regs infra_cg_regs = { 225 - .set_ofs = 0x40, 226 - .clr_ofs = 0x44, 227 - .sta_ofs = 0x48, 228 - }; 229 - 230 295 static const struct mtk_gate_regs top0_cg_regs = { 231 296 .set_ofs = 0x120, 232 297 .clr_ofs = 0x120, ··· 237 326 .set_ofs = 0xC, 238 327 .clr_ofs = 0x14, 239 328 .sta_ofs = 0x1C, 240 - }; 241 - 242 - static const struct mtk_pll_data plls[] = { 243 - PLL(CLK_APMIXED_ARMPLL, "armpll", 0x0200, 0x020C, 0, 244 - PLL_AO, 21, 0x0204, 24, 0, 0x0204, 0), 245 - PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0210, 0x021C, 0, 246 - HAVE_RST_BAR, 21, 0x0214, 24, 0, 0x0214, 0), 247 - PLL(CLK_APMIXED_UNIV2PLL, "univ2pll", 0x0220, 0x022C, 0, 248 - HAVE_RST_BAR, 7, 0x0224, 24, 0, 0x0224, 14), 249 - PLL(CLK_APMIXED_ETH1PLL, "eth1pll", 0x0300, 0x0310, 0, 250 - 0, 21, 0x0300, 1, 0, 0x0304, 0), 251 - PLL(CLK_APMIXED_ETH2PLL, "eth2pll", 0x0314, 0x0320, 0, 252 - 0, 21, 0x0314, 1, 0, 0x0318, 0), 253 - PLL(CLK_APMIXED_AUD1PLL, "aud1pll", 0x0324, 0x0330, 0, 254 - 0, 31, 0x0324, 1, 0, 0x0328, 0), 255 - PLL(CLK_APMIXED_AUD2PLL, "aud2pll", 0x0334, 0x0340, 0, 256 - 0, 31, 0x0334, 1, 0, 0x0338, 0), 257 - PLL(CLK_APMIXED_TRGPLL, "trgpll", 0x0344, 0x0354, 0, 258 - 0, 21, 0x0344, 1, 0, 0x0348, 0), 259 - PLL(CLK_APMIXED_SGMIPLL, "sgmipll", 0x0358, 0x0368, 0, 260 - 0, 21, 0x0358, 1, 0, 0x035C, 0), 261 - }; 262 - 263 - static const struct mtk_gate apmixed_clks[] = { 264 - GATE_APMIXED(CLK_APMIXED_MAIN_CORE_EN, "main_core_en", "mainpll", 5), 265 - }; 266 - 267 - static const struct mtk_gate infra_clks[] = { 268 - GATE_INFRA(CLK_INFRA_DBGCLK_PD, "infra_dbgclk_pd", "axi_sel", 0), 269 - GATE_INFRA(CLK_INFRA_TRNG, "trng_ck", "axi_sel", 2), 270 - GATE_INFRA(CLK_INFRA_AUDIO_PD, "infra_audio_pd", "aud_intbus_sel", 5), 271 - GATE_INFRA(CLK_INFRA_IRRX_PD, "infra_irrx_pd", "irrx_sel", 16), 272 - GATE_INFRA(CLK_INFRA_APXGPT_PD, "infra_apxgpt_pd", "f10m_ref_sel", 18), 273 - GATE_INFRA(CLK_INFRA_PMIC_PD, "infra_pmic_pd", "pmicspi_sel", 22), 274 329 }; 275 330 276 331 static const struct mtk_fixed_clk top_fixed_clks[] = { ··· 362 485 GATE_PERI0(CLK_PERI_AP_DMA_PD, "peri_ap_dma_pd", "axi_sel", 12), 363 486 GATE_PERI0(CLK_PERI_MSDC30_0_PD, "peri_msdc30_0", "msdc30_0_sel", 13), 364 487 GATE_PERI0(CLK_PERI_MSDC30_1_PD, "peri_msdc30_1", "msdc30_1_sel", 14), 365 - GATE_PERI0(CLK_PERI_UART0_PD, "peri_uart0_pd", "axi_sel", 17), 488 + GATE_PERI0_AO(CLK_PERI_UART0_PD, "peri_uart0_pd", "axi_sel", 17), 366 489 GATE_PERI0(CLK_PERI_UART1_PD, "peri_uart1_pd", "axi_sel", 18), 367 490 GATE_PERI0(CLK_PERI_UART2_PD, "peri_uart2_pd", "axi_sel", 19), 368 491 GATE_PERI0(CLK_PERI_UART3_PD, "peri_uart3_pd", "axi_sel", 20), ··· 383 506 GATE_PERI1(CLK_PERI_IRTX_PD, "peri_irtx_pd", "irtx_sel", 2), 384 507 }; 385 508 386 - static struct mtk_composite infra_muxes[] = { 387 - MUX(CLK_INFRA_MUX1_SEL, "infra_mux1_sel", infra_mux1_parents, 388 - 0x000, 2, 2), 389 - }; 390 - 391 509 static struct mtk_composite top_muxes[] = { 392 510 /* CLK_CFG_0 */ 393 - MUX_GATE(CLK_TOP_AXI_SEL, "axi_sel", axi_parents, 394 - 0x040, 0, 3, 7), 395 - MUX_GATE(CLK_TOP_MEM_SEL, "mem_sel", mem_parents, 396 - 0x040, 8, 1, 15), 397 - MUX_GATE(CLK_TOP_DDRPHYCFG_SEL, "ddrphycfg_sel", ddrphycfg_parents, 398 - 0x040, 16, 1, 23), 511 + MUX_GATE_FLAGS(CLK_TOP_AXI_SEL, "axi_sel", axi_parents, 512 + 0x040, 0, 3, 7, CLK_IS_CRITICAL), 513 + MUX_GATE_FLAGS(CLK_TOP_MEM_SEL, "mem_sel", mem_parents, 514 + 0x040, 8, 1, 15, CLK_IS_CRITICAL), 515 + MUX_GATE_FLAGS(CLK_TOP_DDRPHYCFG_SEL, "ddrphycfg_sel", ddrphycfg_parents, 516 + 0x040, 16, 1, 23, CLK_IS_CRITICAL), 399 517 MUX_GATE(CLK_TOP_ETH_SEL, "eth_sel", eth_parents, 400 518 0x040, 24, 3, 31), 401 519 ··· 482 610 MUX(CLK_PERIBUS_SEL, "peribus_ck_sel", peribus_ck_parents, 0x05C, 0, 1), 483 611 }; 484 612 485 - static u16 infrasys_rst_ofs[] = { 0x30, }; 486 613 static u16 pericfg_rst_ofs[] = { 0x0, 0x4, }; 487 614 488 - static const struct mtk_clk_rst_desc clk_rst_desc[] = { 489 - /* infrasys */ 490 - { 491 - .version = MTK_RST_SIMPLE, 492 - .rst_bank_ofs = infrasys_rst_ofs, 493 - .rst_bank_nr = ARRAY_SIZE(infrasys_rst_ofs), 494 - }, 495 - /* pericfg */ 496 - { 497 - .version = MTK_RST_SIMPLE, 498 - .rst_bank_ofs = pericfg_rst_ofs, 499 - .rst_bank_nr = ARRAY_SIZE(pericfg_rst_ofs), 500 - }, 615 + static const struct mtk_clk_rst_desc clk_rst_desc = { 616 + .version = MTK_RST_SIMPLE, 617 + .rst_bank_ofs = pericfg_rst_ofs, 618 + .rst_bank_nr = ARRAY_SIZE(pericfg_rst_ofs), 501 619 }; 502 620 503 - static int mtk_topckgen_init(struct platform_device *pdev) 504 - { 505 - struct clk_hw_onecell_data *clk_data; 506 - void __iomem *base; 507 - struct device_node *node = pdev->dev.of_node; 621 + static const struct mtk_clk_desc topck_desc = { 622 + .clks = top_clks, 623 + .num_clks = ARRAY_SIZE(top_clks), 624 + .fixed_clks = top_fixed_clks, 625 + .num_fixed_clks = ARRAY_SIZE(top_fixed_clks), 626 + .factor_clks = top_divs, 627 + .num_factor_clks = ARRAY_SIZE(top_divs), 628 + .composite_clks = top_muxes, 629 + .num_composite_clks = ARRAY_SIZE(top_muxes), 630 + .divider_clks = top_adj_divs, 631 + .num_divider_clks = ARRAY_SIZE(top_adj_divs), 632 + .clk_lock = &mt7622_clk_lock, 633 + }; 508 634 509 - base = devm_platform_ioremap_resource(pdev, 0); 510 - if (IS_ERR(base)) 511 - return PTR_ERR(base); 512 - 513 - clk_data = mtk_alloc_clk_data(CLK_TOP_NR_CLK); 514 - 515 - mtk_clk_register_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks), 516 - clk_data); 517 - 518 - mtk_clk_register_factors(top_divs, ARRAY_SIZE(top_divs), 519 - clk_data); 520 - 521 - mtk_clk_register_composites(&pdev->dev, top_muxes, 522 - ARRAY_SIZE(top_muxes), base, 523 - &mt7622_clk_lock, clk_data); 524 - 525 - mtk_clk_register_dividers(top_adj_divs, ARRAY_SIZE(top_adj_divs), 526 - base, &mt7622_clk_lock, clk_data); 527 - 528 - mtk_clk_register_gates(&pdev->dev, node, top_clks, 529 - ARRAY_SIZE(top_clks), clk_data); 530 - 531 - clk_prepare_enable(clk_data->hws[CLK_TOP_AXI_SEL]->clk); 532 - clk_prepare_enable(clk_data->hws[CLK_TOP_MEM_SEL]->clk); 533 - clk_prepare_enable(clk_data->hws[CLK_TOP_DDRPHYCFG_SEL]->clk); 534 - 535 - return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 536 - } 537 - 538 - static int mtk_infrasys_init(struct platform_device *pdev) 539 - { 540 - struct device_node *node = pdev->dev.of_node; 541 - struct clk_hw_onecell_data *clk_data; 542 - int r; 543 - 544 - clk_data = mtk_alloc_clk_data(CLK_INFRA_NR_CLK); 545 - 546 - mtk_clk_register_gates(&pdev->dev, node, infra_clks, 547 - ARRAY_SIZE(infra_clks), clk_data); 548 - 549 - mtk_clk_register_cpumuxes(&pdev->dev, node, infra_muxes, 550 - ARRAY_SIZE(infra_muxes), clk_data); 551 - 552 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, 553 - clk_data); 554 - if (r) 555 - return r; 556 - 557 - mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc[0]); 558 - 559 - return 0; 560 - } 561 - 562 - static int mtk_apmixedsys_init(struct platform_device *pdev) 563 - { 564 - struct clk_hw_onecell_data *clk_data; 565 - struct device_node *node = pdev->dev.of_node; 566 - 567 - clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK); 568 - if (!clk_data) 569 - return -ENOMEM; 570 - 571 - mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), 572 - clk_data); 573 - 574 - mtk_clk_register_gates(&pdev->dev, node, apmixed_clks, 575 - ARRAY_SIZE(apmixed_clks), clk_data); 576 - 577 - clk_prepare_enable(clk_data->hws[CLK_APMIXED_ARMPLL]->clk); 578 - clk_prepare_enable(clk_data->hws[CLK_APMIXED_MAIN_CORE_EN]->clk); 579 - 580 - return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 581 - } 582 - 583 - static int mtk_pericfg_init(struct platform_device *pdev) 584 - { 585 - struct clk_hw_onecell_data *clk_data; 586 - void __iomem *base; 587 - int r; 588 - struct device_node *node = pdev->dev.of_node; 589 - 590 - base = devm_platform_ioremap_resource(pdev, 0); 591 - if (IS_ERR(base)) 592 - return PTR_ERR(base); 593 - 594 - clk_data = mtk_alloc_clk_data(CLK_PERI_NR_CLK); 595 - 596 - mtk_clk_register_gates(&pdev->dev, node, peri_clks, 597 - ARRAY_SIZE(peri_clks), clk_data); 598 - 599 - mtk_clk_register_composites(&pdev->dev, peri_muxes, 600 - ARRAY_SIZE(peri_muxes), base, 601 - &mt7622_clk_lock, clk_data); 602 - 603 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 604 - if (r) 605 - return r; 606 - 607 - clk_prepare_enable(clk_data->hws[CLK_PERI_UART0_PD]->clk); 608 - 609 - mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc[1]); 610 - 611 - return 0; 612 - } 635 + static const struct mtk_clk_desc peri_desc = { 636 + .clks = peri_clks, 637 + .num_clks = ARRAY_SIZE(peri_clks), 638 + .composite_clks = peri_muxes, 639 + .num_composite_clks = ARRAY_SIZE(peri_muxes), 640 + .rst_desc = &clk_rst_desc, 641 + .clk_lock = &mt7622_clk_lock, 642 + }; 613 643 614 644 static const struct of_device_id of_match_clk_mt7622[] = { 615 - { 616 - .compatible = "mediatek,mt7622-apmixedsys", 617 - .data = mtk_apmixedsys_init, 618 - }, { 619 - .compatible = "mediatek,mt7622-infracfg", 620 - .data = mtk_infrasys_init, 621 - }, { 622 - .compatible = "mediatek,mt7622-topckgen", 623 - .data = mtk_topckgen_init, 624 - }, { 625 - .compatible = "mediatek,mt7622-pericfg", 626 - .data = mtk_pericfg_init, 627 - }, { 628 - /* sentinel */ 629 - } 645 + { .compatible = "mediatek,mt7622-topckgen", .data = &topck_desc }, 646 + { .compatible = "mediatek,mt7622-pericfg", .data = &peri_desc }, 647 + { /* sentinel */ } 630 648 }; 631 - 632 - static int clk_mt7622_probe(struct platform_device *pdev) 633 - { 634 - int (*clk_init)(struct platform_device *); 635 - int r; 636 - 637 - clk_init = of_device_get_match_data(&pdev->dev); 638 - if (!clk_init) 639 - return -EINVAL; 640 - 641 - r = clk_init(pdev); 642 - if (r) 643 - dev_err(&pdev->dev, 644 - "could not register clock provider: %s: %d\n", 645 - pdev->name, r); 646 - 647 - return r; 648 - } 649 + MODULE_DEVICE_TABLE(of, of_match_clk_mt7622); 649 650 650 651 static struct platform_driver clk_mt7622_drv = { 651 - .probe = clk_mt7622_probe, 652 652 .driver = { 653 653 .name = "clk-mt7622", 654 654 .of_match_table = of_match_clk_mt7622, 655 655 }, 656 + .probe = mtk_clk_simple_probe, 657 + .remove = mtk_clk_simple_remove, 656 658 }; 659 + module_platform_driver(clk_mt7622_drv) 657 660 658 - static int clk_mt7622_init(void) 659 - { 660 - return platform_driver_register(&clk_mt7622_drv); 661 - } 662 - 663 - arch_initcall(clk_mt7622_init); 661 + MODULE_DESCRIPTION("MediaTek MT7622 clocks driver"); 662 + MODULE_LICENSE("GPL");
+6 -16
drivers/clk/mediatek/clk-mt7629-eth.c
··· 16 16 17 17 #include <dt-bindings/clock/mt7629-clk.h> 18 18 19 - #define GATE_ETH(_id, _name, _parent, _shift) { \ 20 - .id = _id, \ 21 - .name = _name, \ 22 - .parent_name = _parent, \ 23 - .regs = &eth_cg_regs, \ 24 - .shift = _shift, \ 25 - .ops = &mtk_clk_gate_ops_no_setclr_inv, \ 26 - } 19 + #define GATE_ETH(_id, _name, _parent, _shift) \ 20 + GATE_MTK(_id, _name, _parent, &eth_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv) 27 21 28 22 static const struct mtk_gate_regs eth_cg_regs = { 29 23 .set_ofs = 0x30, ··· 39 45 .sta_ofs = 0xE4, 40 46 }; 41 47 42 - #define GATE_SGMII(_id, _name, _parent, _shift) { \ 43 - .id = _id, \ 44 - .name = _name, \ 45 - .parent_name = _parent, \ 46 - .regs = &sgmii_cg_regs, \ 47 - .shift = _shift, \ 48 - .ops = &mtk_clk_gate_ops_no_setclr_inv, \ 49 - } 48 + #define GATE_SGMII(_id, _name, _parent, _shift) \ 49 + GATE_MTK(_id, _name, _parent, &sgmii_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv) 50 50 51 51 static const struct mtk_gate sgmii_clks[2][4] = { 52 52 { ··· 126 138 /* sentinel */ 127 139 } 128 140 }; 141 + MODULE_DEVICE_TABLE(of, of_match_clk_mt7629_eth); 129 142 130 143 static int clk_mt7629_eth_probe(struct platform_device *pdev) 131 144 { ··· 155 166 }; 156 167 157 168 builtin_platform_driver(clk_mt7629_eth_drv); 169 + MODULE_LICENSE("GPL");
+7 -18
drivers/clk/mediatek/clk-mt7629-hif.c
··· 16 16 17 17 #include <dt-bindings/clock/mt7629-clk.h> 18 18 19 - #define GATE_PCIE(_id, _name, _parent, _shift) { \ 20 - .id = _id, \ 21 - .name = _name, \ 22 - .parent_name = _parent, \ 23 - .regs = &pcie_cg_regs, \ 24 - .shift = _shift, \ 25 - .ops = &mtk_clk_gate_ops_no_setclr_inv, \ 26 - } 19 + #define GATE_PCIE(_id, _name, _parent, _shift) \ 20 + GATE_MTK(_id, _name, _parent, &pcie_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv) 27 21 28 - #define GATE_SSUSB(_id, _name, _parent, _shift) { \ 29 - .id = _id, \ 30 - .name = _name, \ 31 - .parent_name = _parent, \ 32 - .regs = &ssusb_cg_regs, \ 33 - .shift = _shift, \ 34 - .ops = &mtk_clk_gate_ops_no_setclr_inv, \ 35 - } 22 + #define GATE_SSUSB(_id, _name, _parent, _shift) \ 23 + GATE_MTK(_id, _name, _parent, &ssusb_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv) 36 24 37 25 static const struct mtk_gate_regs pcie_cg_regs = { 38 26 .set_ofs = 0x30, ··· 84 96 { .compatible = "mediatek,mt7629-ssusbsys", .data = &ssusb_desc }, 85 97 { /* sentinel */ } 86 98 }; 99 + MODULE_DEVICE_TABLE(of, of_match_clk_mt7629_hif); 87 100 88 101 static struct platform_driver clk_mt7629_hif_drv = { 89 102 .probe = mtk_clk_simple_probe, ··· 94 105 .of_match_table = of_match_clk_mt7629_hif, 95 106 }, 96 107 }; 97 - 98 - builtin_platform_driver(clk_mt7629_hif_drv); 108 + module_platform_driver(clk_mt7629_hif_drv); 109 + MODULE_LICENSE("GPL");
+10 -32
drivers/clk/mediatek/clk-mt7629.c
··· 50 50 _pd_reg, _pd_shift, _tuner_reg, _pcw_reg, _pcw_shift, \ 51 51 NULL, "clk20m") 52 52 53 - #define GATE_APMIXED(_id, _name, _parent, _shift) { \ 54 - .id = _id, \ 55 - .name = _name, \ 56 - .parent_name = _parent, \ 57 - .regs = &apmixed_cg_regs, \ 58 - .shift = _shift, \ 59 - .ops = &mtk_clk_gate_ops_no_setclr_inv, \ 60 - } 53 + #define GATE_APMIXED(_id, _name, _parent, _shift) \ 54 + GATE_MTK(_id, _name, _parent, &apmixed_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv) 61 55 62 - #define GATE_INFRA(_id, _name, _parent, _shift) { \ 63 - .id = _id, \ 64 - .name = _name, \ 65 - .parent_name = _parent, \ 66 - .regs = &infra_cg_regs, \ 67 - .shift = _shift, \ 68 - .ops = &mtk_clk_gate_ops_setclr, \ 69 - } 56 + #define GATE_INFRA(_id, _name, _parent, _shift) \ 57 + GATE_MTK(_id, _name, _parent, &infra_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 70 58 71 - #define GATE_PERI0(_id, _name, _parent, _shift) { \ 72 - .id = _id, \ 73 - .name = _name, \ 74 - .parent_name = _parent, \ 75 - .regs = &peri0_cg_regs, \ 76 - .shift = _shift, \ 77 - .ops = &mtk_clk_gate_ops_setclr, \ 78 - } 59 + #define GATE_PERI0(_id, _name, _parent, _shift) \ 60 + GATE_MTK(_id, _name, _parent, &peri0_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 79 61 80 - #define GATE_PERI1(_id, _name, _parent, _shift) { \ 81 - .id = _id, \ 82 - .name = _name, \ 83 - .parent_name = _parent, \ 84 - .regs = &peri1_cg_regs, \ 85 - .shift = _shift, \ 86 - .ops = &mtk_clk_gate_ops_setclr, \ 87 - } 62 + #define GATE_PERI1(_id, _name, _parent, _shift) \ 63 + GATE_MTK(_id, _name, _parent, &peri1_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 88 64 89 65 static DEFINE_SPINLOCK(mt7629_clk_lock); 90 66 ··· 660 684 /* sentinel */ 661 685 } 662 686 }; 687 + MODULE_DEVICE_TABLE(of, of_match_clk_mt7629); 663 688 664 689 static int clk_mt7629_probe(struct platform_device *pdev) 665 690 { ··· 694 717 } 695 718 696 719 arch_initcall(clk_mt7629_init); 720 + MODULE_LICENSE("GPL");
+2
drivers/clk/mediatek/clk-mt7981-apmixed.c
··· 66 66 { .compatible = "mediatek,mt7981-apmixedsys", }, 67 67 { /* sentinel */ } 68 68 }; 69 + MODULE_DEVICE_TABLE(of, of_match_clk_mt7981_apmixed); 69 70 70 71 static int clk_mt7981_apmixed_probe(struct platform_device *pdev) 71 72 { ··· 101 100 }, 102 101 }; 103 102 builtin_platform_driver(clk_mt7981_apmixed_drv); 103 + MODULE_LICENSE("GPL");
+2 -1
drivers/clk/mediatek/clk-mt7981-eth.c
··· 105 105 { .compatible = "mediatek,mt7981-sgmiisys_1", .data = &sgmii1_desc }, 106 106 { /* sentinel */ } 107 107 }; 108 + MODULE_DEVICE_TABLE(of, of_match_clk_mt7981_eth); 108 109 109 110 static struct platform_driver clk_mt7981_eth_drv = { 110 111 .probe = mtk_clk_simple_probe, ··· 116 115 }, 117 116 }; 118 117 module_platform_driver(clk_mt7981_eth_drv); 119 - MODULE_LICENSE("GPL v2"); 118 + MODULE_LICENSE("GPL");
+3 -1
drivers/clk/mediatek/clk-mt7981-infracfg.c
··· 195 195 { .compatible = "mediatek,mt7981-infracfg", .data = &infracfg_desc }, 196 196 { /* sentinel */ } 197 197 }; 198 + MODULE_DEVICE_TABLE(of, of_match_clk_mt7981_infracfg); 198 199 199 200 static struct platform_driver clk_mt7981_infracfg_drv = { 200 201 .probe = mtk_clk_simple_probe, ··· 205 204 .of_match_table = of_match_clk_mt7981_infracfg, 206 205 }, 207 206 }; 208 - builtin_platform_driver(clk_mt7981_infracfg_drv); 207 + module_platform_driver(clk_mt7981_infracfg_drv); 208 + MODULE_LICENSE("GPL");
+3 -1
drivers/clk/mediatek/clk-mt7981-topckgen.c
··· 410 410 { .compatible = "mediatek,mt7981-topckgen", .data = &topck_desc }, 411 411 { /* sentinel */ } 412 412 }; 413 + MODULE_DEVICE_TABLE(of, of_match_clk_mt7981_topckgen); 413 414 414 415 static struct platform_driver clk_mt7981_topckgen_drv = { 415 416 .probe = mtk_clk_simple_probe, ··· 420 419 .of_match_table = of_match_clk_mt7981_topckgen, 421 420 }, 422 421 }; 423 - builtin_platform_driver(clk_mt7981_topckgen_drv); 422 + module_platform_driver(clk_mt7981_topckgen_drv); 423 + MODULE_LICENSE("GPL");
+4 -4
drivers/clk/mediatek/clk-mt7986-apmixed.c
··· 42 42 "clkxtal") 43 43 44 44 static const struct mtk_pll_data plls[] = { 45 - PLL(CLK_APMIXED_ARMPLL, "armpll", 0x0200, 0x020C, 0x0, 0, 32, 45 + PLL(CLK_APMIXED_ARMPLL, "armpll", 0x0200, 0x020C, 0x0, PLL_AO, 32, 46 46 0x0200, 4, 0, 0x0204, 0), 47 47 PLL(CLK_APMIXED_NET2PLL, "net2pll", 0x0210, 0x021C, 0x0, 0, 32, 48 48 0x0210, 4, 0, 0x0214, 0), ··· 62 62 63 63 static const struct of_device_id of_match_clk_mt7986_apmixed[] = { 64 64 { .compatible = "mediatek,mt7986-apmixedsys", }, 65 - {} 65 + { } 66 66 }; 67 + MODULE_DEVICE_TABLE(of, of_match_clk_mt7986_apmixed); 67 68 68 69 static int clk_mt7986_apmixed_probe(struct platform_device *pdev) 69 70 { ··· 77 76 return -ENOMEM; 78 77 79 78 mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data); 80 - 81 - clk_prepare_enable(clk_data->hws[CLK_APMIXED_ARMPLL]->clk); 82 79 83 80 r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 84 81 if (r) { ··· 99 100 }, 100 101 }; 101 102 builtin_platform_driver(clk_mt7986_apmixed_drv); 103 + MODULE_LICENSE("GPL");
+39 -69
drivers/clk/mediatek/clk-mt7986-eth.c
··· 22 22 .sta_ofs = 0xe4, 23 23 }; 24 24 25 - #define GATE_SGMII0(_id, _name, _parent, _shift) \ 26 - { \ 27 - .id = _id, .name = _name, .parent_name = _parent, \ 28 - .regs = &sgmii0_cg_regs, .shift = _shift, \ 29 - .ops = &mtk_clk_gate_ops_no_setclr_inv, \ 30 - } 25 + #define GATE_SGMII0(_id, _name, _parent, _shift) \ 26 + GATE_MTK(_id, _name, _parent, &sgmii0_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv) 31 27 32 - static const struct mtk_gate sgmii0_clks[] __initconst = { 28 + static const struct mtk_gate sgmii0_clks[] = { 33 29 GATE_SGMII0(CLK_SGMII0_TX250M_EN, "sgmii0_tx250m_en", "top_xtal", 2), 34 30 GATE_SGMII0(CLK_SGMII0_RX250M_EN, "sgmii0_rx250m_en", "top_xtal", 3), 35 31 GATE_SGMII0(CLK_SGMII0_CDR_REF, "sgmii0_cdr_ref", "top_xtal", 4), ··· 38 42 .sta_ofs = 0xe4, 39 43 }; 40 44 41 - #define GATE_SGMII1(_id, _name, _parent, _shift) \ 42 - { \ 43 - .id = _id, .name = _name, .parent_name = _parent, \ 44 - .regs = &sgmii1_cg_regs, .shift = _shift, \ 45 - .ops = &mtk_clk_gate_ops_no_setclr_inv, \ 46 - } 45 + #define GATE_SGMII1(_id, _name, _parent, _shift) \ 46 + GATE_MTK(_id, _name, _parent, &sgmii1_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv) 47 47 48 - static const struct mtk_gate sgmii1_clks[] __initconst = { 48 + static const struct mtk_gate sgmii1_clks[] = { 49 49 GATE_SGMII1(CLK_SGMII1_TX250M_EN, "sgmii1_tx250m_en", "top_xtal", 2), 50 50 GATE_SGMII1(CLK_SGMII1_RX250M_EN, "sgmii1_rx250m_en", "top_xtal", 3), 51 51 GATE_SGMII1(CLK_SGMII1_CDR_REF, "sgmii1_cdr_ref", "top_xtal", 4), ··· 54 62 .sta_ofs = 0x30, 55 63 }; 56 64 57 - #define GATE_ETH(_id, _name, _parent, _shift) \ 58 - { \ 59 - .id = _id, .name = _name, .parent_name = _parent, \ 60 - .regs = &eth_cg_regs, .shift = _shift, \ 61 - .ops = &mtk_clk_gate_ops_no_setclr_inv, \ 62 - } 65 + #define GATE_ETH(_id, _name, _parent, _shift) \ 66 + GATE_MTK(_id, _name, _parent, &eth_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv) 63 67 64 - static const struct mtk_gate eth_clks[] __initconst = { 68 + static const struct mtk_gate eth_clks[] = { 65 69 GATE_ETH(CLK_ETH_FE_EN, "eth_fe_en", "netsys_2x_sel", 6), 66 70 GATE_ETH(CLK_ETH_GP2_EN, "eth_gp2_en", "sgm_325m_sel", 7), 67 71 GATE_ETH(CLK_ETH_GP1_EN, "eth_gp1_en", "sgm_325m_sel", 8), ··· 65 77 GATE_ETH(CLK_ETH_WOCPU0_EN, "eth_wocpu0_en", "netsys_mcu_sel", 15), 66 78 }; 67 79 68 - static void __init mtk_sgmiisys_0_init(struct device_node *node) 69 - { 70 - struct clk_hw_onecell_data *clk_data; 71 - int r; 80 + static const struct mtk_clk_desc eth_desc = { 81 + .clks = eth_clks, 82 + .num_clks = ARRAY_SIZE(eth_clks), 83 + }; 72 84 73 - clk_data = mtk_alloc_clk_data(ARRAY_SIZE(sgmii0_clks)); 85 + static const struct mtk_clk_desc sgmii0_desc = { 86 + .clks = sgmii0_clks, 87 + .num_clks = ARRAY_SIZE(sgmii0_clks), 88 + }; 74 89 75 - mtk_clk_register_gates(NULL, node, sgmii0_clks, 76 - ARRAY_SIZE(sgmii0_clks), clk_data); 90 + static const struct mtk_clk_desc sgmii1_desc = { 91 + .clks = sgmii1_clks, 92 + .num_clks = ARRAY_SIZE(sgmii1_clks), 93 + }; 77 94 78 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 79 - if (r) 80 - pr_err("%s(): could not register clock provider: %d\n", 81 - __func__, r); 82 - } 83 - CLK_OF_DECLARE(mtk_sgmiisys_0, "mediatek,mt7986-sgmiisys_0", 84 - mtk_sgmiisys_0_init); 95 + static const struct of_device_id of_match_clk_mt7986_eth[] = { 96 + { .compatible = "mediatek,mt7986-ethsys", .data = &eth_desc }, 97 + { .compatible = "mediatek,mt7986-sgmiisys_0", .data = &sgmii0_desc }, 98 + { .compatible = "mediatek,mt7986-sgmiisys_1", .data = &sgmii1_desc }, 99 + { /* sentinel */ } 100 + }; 101 + MODULE_DEVICE_TABLE(of, of_match_clk_mt7986_eth); 85 102 86 - static void __init mtk_sgmiisys_1_init(struct device_node *node) 87 - { 88 - struct clk_hw_onecell_data *clk_data; 89 - int r; 103 + static struct platform_driver clk_mt7986_eth_drv = { 104 + .driver = { 105 + .name = "clk-mt7986-eth", 106 + .of_match_table = of_match_clk_mt7986_eth, 107 + }, 108 + .probe = mtk_clk_simple_probe, 109 + .remove = mtk_clk_simple_remove, 110 + }; 111 + module_platform_driver(clk_mt7986_eth_drv); 90 112 91 - clk_data = mtk_alloc_clk_data(ARRAY_SIZE(sgmii1_clks)); 92 - 93 - mtk_clk_register_gates(NULL, node, sgmii1_clks, 94 - ARRAY_SIZE(sgmii1_clks), clk_data); 95 - 96 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 97 - 98 - if (r) 99 - pr_err("%s(): could not register clock provider: %d\n", 100 - __func__, r); 101 - } 102 - CLK_OF_DECLARE(mtk_sgmiisys_1, "mediatek,mt7986-sgmiisys_1", 103 - mtk_sgmiisys_1_init); 104 - 105 - static void __init mtk_ethsys_init(struct device_node *node) 106 - { 107 - struct clk_hw_onecell_data *clk_data; 108 - int r; 109 - 110 - clk_data = mtk_alloc_clk_data(ARRAY_SIZE(eth_clks)); 111 - 112 - mtk_clk_register_gates(NULL, node, eth_clks, ARRAY_SIZE(eth_clks), clk_data); 113 - 114 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 115 - 116 - if (r) 117 - pr_err("%s(): could not register clock provider: %d\n", 118 - __func__, r); 119 - } 120 - CLK_OF_DECLARE(mtk_ethsys, "mediatek,mt7986-ethsys", mtk_ethsys_init); 113 + MODULE_DESCRIPTION("MediaTek MT7986 Ethernet clocks driver"); 114 + MODULE_LICENSE("GPL");
+26 -64
drivers/clk/mediatek/clk-mt7986-infracfg.c
··· 87 87 .sta_ofs = 0x68, 88 88 }; 89 89 90 - #define GATE_INFRA0(_id, _name, _parent, _shift) \ 91 - { \ 92 - .id = _id, .name = _name, .parent_name = _parent, \ 93 - .regs = &infra0_cg_regs, .shift = _shift, \ 94 - .ops = &mtk_clk_gate_ops_setclr, \ 95 - } 90 + #define GATE_INFRA0(_id, _name, _parent, _shift) \ 91 + GATE_MTK(_id, _name, _parent, &infra0_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 96 92 97 - #define GATE_INFRA1(_id, _name, _parent, _shift) \ 98 - { \ 99 - .id = _id, .name = _name, .parent_name = _parent, \ 100 - .regs = &infra1_cg_regs, .shift = _shift, \ 101 - .ops = &mtk_clk_gate_ops_setclr, \ 102 - } 93 + #define GATE_INFRA1(_id, _name, _parent, _shift) \ 94 + GATE_MTK(_id, _name, _parent, &infra1_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 103 95 104 - #define GATE_INFRA2(_id, _name, _parent, _shift) \ 105 - { \ 106 - .id = _id, .name = _name, .parent_name = _parent, \ 107 - .regs = &infra2_cg_regs, .shift = _shift, \ 108 - .ops = &mtk_clk_gate_ops_setclr, \ 109 - } 96 + #define GATE_INFRA2(_id, _name, _parent, _shift) \ 97 + GATE_MTK(_id, _name, _parent, &infra2_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 110 98 111 99 static const struct mtk_gate infra_clks[] = { 112 100 /* INFRA0 */ ··· 157 169 GATE_INFRA2(CLK_INFRA_IPCIEB_CK, "infra_ipcieb", "sysaxi_sel", 15), 158 170 }; 159 171 160 - static int clk_mt7986_infracfg_probe(struct platform_device *pdev) 161 - { 162 - struct clk_hw_onecell_data *clk_data; 163 - struct device_node *node = pdev->dev.of_node; 164 - int r; 165 - void __iomem *base; 166 - int nr = ARRAY_SIZE(infra_divs) + ARRAY_SIZE(infra_muxes) + 167 - ARRAY_SIZE(infra_clks); 168 - 169 - base = of_iomap(node, 0); 170 - if (!base) { 171 - pr_err("%s(): ioremap failed\n", __func__); 172 - return -ENOMEM; 173 - } 174 - 175 - clk_data = mtk_alloc_clk_data(nr); 176 - 177 - if (!clk_data) 178 - return -ENOMEM; 179 - 180 - mtk_clk_register_factors(infra_divs, ARRAY_SIZE(infra_divs), clk_data); 181 - mtk_clk_register_muxes(&pdev->dev, infra_muxes, 182 - ARRAY_SIZE(infra_muxes), node, 183 - &mt7986_clk_lock, clk_data); 184 - mtk_clk_register_gates(&pdev->dev, node, infra_clks, 185 - ARRAY_SIZE(infra_clks), clk_data); 186 - 187 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 188 - if (r) { 189 - pr_err("%s(): could not register clock provider: %d\n", 190 - __func__, r); 191 - goto free_infracfg_data; 192 - } 193 - return r; 194 - 195 - free_infracfg_data: 196 - mtk_free_clk_data(clk_data); 197 - return r; 198 - 199 - } 200 - 201 - static const struct of_device_id of_match_clk_mt7986_infracfg[] = { 202 - { .compatible = "mediatek,mt7986-infracfg", }, 203 - {} 172 + static const struct mtk_clk_desc infra_desc = { 173 + .clks = infra_clks, 174 + .num_clks = ARRAY_SIZE(infra_clks), 175 + .factor_clks = infra_divs, 176 + .num_factor_clks = ARRAY_SIZE(infra_divs), 177 + .mux_clks = infra_muxes, 178 + .num_mux_clks = ARRAY_SIZE(infra_muxes), 179 + .clk_lock = &mt7986_clk_lock, 204 180 }; 205 181 182 + static const struct of_device_id of_match_clk_mt7986_infracfg[] = { 183 + { .compatible = "mediatek,mt7986-infracfg", .data = &infra_desc }, 184 + { /* sentinel */ } 185 + }; 186 + MODULE_DEVICE_TABLE(of, of_match_clk_mt7986_infracfg); 187 + 206 188 static struct platform_driver clk_mt7986_infracfg_drv = { 207 - .probe = clk_mt7986_infracfg_probe, 208 189 .driver = { 209 190 .name = "clk-mt7986-infracfg", 210 191 .of_match_table = of_match_clk_mt7986_infracfg, 211 192 }, 193 + .probe = mtk_clk_simple_probe, 194 + .remove = mtk_clk_simple_remove, 212 195 }; 213 - builtin_platform_driver(clk_mt7986_infracfg_drv); 196 + module_platform_driver(clk_mt7986_infracfg_drv); 197 + 198 + MODULE_DESCRIPTION("MediaTek MT7986 infracfg clocks driver"); 199 + MODULE_LICENSE("GPL");
+3 -1
drivers/clk/mediatek/clk-mt7986-topckgen.c
··· 304 304 { .compatible = "mediatek,mt7986-topckgen", .data = &topck_desc }, 305 305 { /* sentinel */ } 306 306 }; 307 + MODULE_DEVICE_TABLE(of, of_match_clk_mt7986_topckgen); 307 308 308 309 static struct platform_driver clk_mt7986_topckgen_drv = { 309 310 .probe = mtk_clk_simple_probe, ··· 314 313 .of_match_table = of_match_clk_mt7986_topckgen, 315 314 }, 316 315 }; 317 - builtin_platform_driver(clk_mt7986_topckgen_drv); 316 + module_platform_driver(clk_mt7986_topckgen_drv); 317 + MODULE_LICENSE("GPL");
+105
drivers/clk/mediatek/clk-mt8135-apmixedsys.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Copyright (c) 2014 MediaTek Inc. 4 + * James Liao <jamesjj.liao@mediatek.com> 5 + * Copyright (c) 2023 Collabora, Ltd. 6 + * AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> 7 + */ 8 + 9 + #include <dt-bindings/clock/mt8135-clk.h> 10 + #include <linux/clk.h> 11 + #include <linux/of.h> 12 + #include <linux/platform_device.h> 13 + 14 + #include "clk-mtk.h" 15 + #include "clk-pll.h" 16 + 17 + #define MT8135_PLL_FMAX (2000 * MHZ) 18 + #define CON0_MT8135_RST_BAR BIT(27) 19 + 20 + #define PLL(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits, _pd_reg, _pd_shift, _tuner_reg, _pcw_reg, _pcw_shift) { \ 21 + .id = _id, \ 22 + .name = _name, \ 23 + .reg = _reg, \ 24 + .pwr_reg = _pwr_reg, \ 25 + .en_mask = _en_mask, \ 26 + .flags = _flags, \ 27 + .rst_bar_mask = CON0_MT8135_RST_BAR, \ 28 + .fmax = MT8135_PLL_FMAX, \ 29 + .pcwbits = _pcwbits, \ 30 + .pd_reg = _pd_reg, \ 31 + .pd_shift = _pd_shift, \ 32 + .tuner_reg = _tuner_reg, \ 33 + .pcw_reg = _pcw_reg, \ 34 + .pcw_shift = _pcw_shift, \ 35 + } 36 + 37 + static const struct mtk_pll_data plls[] = { 38 + PLL(CLK_APMIXED_ARMPLL1, "armpll1", 0x200, 0x218, 0x80000000, 0, 21, 0x204, 24, 0x0, 0x204, 0), 39 + PLL(CLK_APMIXED_ARMPLL2, "armpll2", 0x2cc, 0x2e4, 0x80000000, 0, 21, 0x2d0, 24, 0x0, 0x2d0, 0), 40 + PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x21c, 0x234, 0xf0000000, HAVE_RST_BAR, 21, 0x21c, 6, 0x0, 0x220, 0), 41 + PLL(CLK_APMIXED_UNIVPLL, "univpll", 0x238, 0x250, 0xf3000000, HAVE_RST_BAR, 7, 0x238, 6, 0x0, 0x238, 9), 42 + PLL(CLK_APMIXED_MMPLL, "mmpll", 0x254, 0x26c, 0xf0000000, HAVE_RST_BAR, 21, 0x254, 6, 0x0, 0x258, 0), 43 + PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x278, 0x290, 0x80000000, 0, 21, 0x278, 6, 0x0, 0x27c, 0), 44 + PLL(CLK_APMIXED_TVDPLL, "tvdpll", 0x294, 0x2ac, 0x80000000, 0, 31, 0x294, 6, 0x0, 0x298, 0), 45 + PLL(CLK_APMIXED_LVDSPLL, "lvdspll", 0x2b0, 0x2c8, 0x80000000, 0, 21, 0x2b0, 6, 0x0, 0x2b4, 0), 46 + PLL(CLK_APMIXED_AUDPLL, "audpll", 0x2e8, 0x300, 0x80000000, 0, 31, 0x2e8, 6, 0x2f8, 0x2ec, 0), 47 + PLL(CLK_APMIXED_VDECPLL, "vdecpll", 0x304, 0x31c, 0x80000000, 0, 21, 0x2b0, 6, 0x0, 0x308, 0), 48 + }; 49 + 50 + static int clk_mt8135_apmixed_probe(struct platform_device *pdev) 51 + { 52 + struct clk_hw_onecell_data *clk_data; 53 + struct device_node *node = pdev->dev.of_node; 54 + int ret; 55 + 56 + clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK); 57 + if (!clk_data) 58 + return -ENOMEM; 59 + 60 + ret = mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data); 61 + if (ret) 62 + return ret; 63 + 64 + ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 65 + if (ret) 66 + goto unregister_plls; 67 + 68 + return 0; 69 + 70 + unregister_plls: 71 + mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data); 72 + 73 + return ret; 74 + } 75 + 76 + static int clk_mt8135_apmixed_remove(struct platform_device *pdev) 77 + { 78 + struct device_node *node = pdev->dev.of_node; 79 + struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev); 80 + 81 + of_clk_del_provider(node); 82 + mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data); 83 + mtk_free_clk_data(clk_data); 84 + 85 + return 0; 86 + } 87 + 88 + static const struct of_device_id of_match_clk_mt8135_apmixed[] = { 89 + { .compatible = "mediatek,mt8135-apmixedsys" }, 90 + { /* sentinel */ } 91 + }; 92 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8135_apmixed); 93 + 94 + static struct platform_driver clk_mt8135_apmixed_drv = { 95 + .probe = clk_mt8135_apmixed_probe, 96 + .remove = clk_mt8135_apmixed_remove, 97 + .driver = { 98 + .name = "clk-mt8135-apmixed", 99 + .of_match_table = of_match_clk_mt8135_apmixed, 100 + }, 101 + }; 102 + module_platform_driver(clk_mt8135_apmixed_drv) 103 + 104 + MODULE_DESCRIPTION("MediaTek MT8135 apmixedsys clocks driver"); 105 + MODULE_LICENSE("GPL");
+89 -181
drivers/clk/mediatek/clk-mt8135.c
··· 5 5 */ 6 6 7 7 #include <linux/clk.h> 8 + #include <linux/module.h> 8 9 #include <linux/of.h> 9 10 #include <linux/of_address.h> 11 + #include <linux/platform_device.h> 10 12 #include <linux/slab.h> 11 13 #include <linux/mfd/syscon.h> 12 14 #include <dt-bindings/clock/mt8135-clk.h> ··· 19 17 20 18 static DEFINE_SPINLOCK(mt8135_clk_lock); 21 19 22 - static const struct mtk_fixed_factor root_clk_alias[] __initconst = { 20 + static const struct mtk_fixed_factor top_divs[] = { 21 + FACTOR(CLK_DUMMY, "top_divs_dummy", "clk_null", 1, 1), 23 22 FACTOR(CLK_TOP_DSI0_LNTC_DSICLK, "dsi0_lntc_dsiclk", "clk_null", 1, 1), 24 23 FACTOR(CLK_TOP_HDMITX_CLKDIG_CTS, "hdmitx_clkdig_cts", "clk_null", 1, 1), 25 24 FACTOR(CLK_TOP_CLKPH_MCK, "clkph_mck", "clk_null", 1, 1), 26 25 FACTOR(CLK_TOP_CPUM_TCK_IN, "cpum_tck_in", "clk_null", 1, 1), 27 - }; 28 26 29 - static const struct mtk_fixed_factor top_divs[] __initconst = { 30 27 FACTOR(CLK_TOP_MAINPLL_806M, "mainpll_806m", "mainpll", 1, 2), 31 28 FACTOR(CLK_TOP_MAINPLL_537P3M, "mainpll_537p3m", "mainpll", 1, 3), 32 29 FACTOR(CLK_TOP_MAINPLL_322P4M, "mainpll_322p4m", "mainpll", 1, 5), ··· 101 100 FACTOR(CLK_TOP_MEMPLL_MCK_D4, "mempll_mck_d4", "clkph_mck", 1, 4), 102 101 }; 103 102 104 - static const char * const axi_parents[] __initconst = { 103 + static const char * const axi_parents[] = { 105 104 "clk26m", 106 105 "syspll_d3", 107 106 "syspll_d4", ··· 111 110 "syspll_d3p5" 112 111 }; 113 112 114 - static const char * const smi_parents[] __initconst = { 113 + static const char * const smi_parents[] = { 115 114 "clk26m", 116 115 "clkph_mck", 117 116 "syspll_d2p5", ··· 129 128 "lvdspll" 130 129 }; 131 130 132 - static const char * const mfg_parents[] __initconst = { 131 + static const char * const mfg_parents[] = { 133 132 "clk26m", 134 133 "univpll1_d4", 135 134 "syspll_d2", ··· 145 144 "mmpll_d7" 146 145 }; 147 146 148 - static const char * const irda_parents[] __initconst = { 147 + static const char * const irda_parents[] = { 149 148 "clk26m", 150 149 "univpll2_d8", 151 150 "univpll1_d6" 152 151 }; 153 152 154 - static const char * const cam_parents[] __initconst = { 153 + static const char * const cam_parents[] = { 155 154 "clk26m", 156 155 "syspll_d3", 157 156 "syspll_d3p5", ··· 162 161 "univpll1_d4" 163 162 }; 164 163 165 - static const char * const aud_intbus_parents[] __initconst = { 164 + static const char * const aud_intbus_parents[] = { 166 165 "clk26m", 167 166 "syspll_d6", 168 167 "univpll_d10" 169 168 }; 170 169 171 - static const char * const jpg_parents[] __initconst = { 170 + static const char * const jpg_parents[] = { 172 171 "clk26m", 173 172 "syspll_d5", 174 173 "syspll_d4", ··· 178 177 "univpll_d5" 179 178 }; 180 179 181 - static const char * const disp_parents[] __initconst = { 180 + static const char * const disp_parents[] = { 182 181 "clk26m", 183 182 "syspll_d3p5", 184 183 "syspll_d3", ··· 189 188 "vdecpll" 190 189 }; 191 190 192 - static const char * const msdc30_parents[] __initconst = { 191 + static const char * const msdc30_parents[] = { 193 192 "clk26m", 194 193 "syspll_d6", 195 194 "syspll_d5", ··· 198 197 "msdcpll" 199 198 }; 200 199 201 - static const char * const usb20_parents[] __initconst = { 200 + static const char * const usb20_parents[] = { 202 201 "clk26m", 203 202 "univpll2_d6", 204 203 "univpll1_d10" 205 204 }; 206 205 207 - static const char * const venc_parents[] __initconst = { 206 + static const char * const venc_parents[] = { 208 207 "clk26m", 209 208 "syspll_d3", 210 209 "syspll_d8", ··· 215 214 "mmpll_d6" 216 215 }; 217 216 218 - static const char * const spi_parents[] __initconst = { 217 + static const char * const spi_parents[] = { 219 218 "clk26m", 220 219 "syspll_d6", 221 220 "syspll_d8", ··· 224 223 "univpll1_d8" 225 224 }; 226 225 227 - static const char * const uart_parents[] __initconst = { 226 + static const char * const uart_parents[] = { 228 227 "clk26m", 229 228 "univpll2_d8" 230 229 }; 231 230 232 - static const char * const mem_parents[] __initconst = { 231 + static const char * const mem_parents[] = { 233 232 "clk26m", 234 233 "clkph_mck" 235 234 }; 236 235 237 - static const char * const camtg_parents[] __initconst = { 236 + static const char * const camtg_parents[] = { 238 237 "clk26m", 239 238 "univpll_d26", 240 239 "univpll1_d6", ··· 242 241 "syspll_d8" 243 242 }; 244 243 245 - static const char * const audio_parents[] __initconst = { 244 + static const char * const audio_parents[] = { 246 245 "clk26m", 247 246 "syspll_d24" 248 247 }; 249 248 250 - static const char * const fix_parents[] __initconst = { 249 + static const char * const fix_parents[] = { 251 250 "rtc32k", 252 251 "clk26m", 253 252 "univpll_d5", ··· 258 257 "univpll1_d8" 259 258 }; 260 259 261 - static const char * const vdec_parents[] __initconst = { 260 + static const char * const vdec_parents[] = { 262 261 "clk26m", 263 262 "vdecpll", 264 263 "clkph_mck", ··· 277 276 "lvdspll" 278 277 }; 279 278 280 - static const char * const ddrphycfg_parents[] __initconst = { 279 + static const char * const ddrphycfg_parents[] = { 281 280 "clk26m", 282 281 "axi_sel", 283 282 "syspll_d12" 284 283 }; 285 284 286 - static const char * const dpilvds_parents[] __initconst = { 285 + static const char * const dpilvds_parents[] = { 287 286 "clk26m", 288 287 "lvdspll", 289 288 "lvdspll_d2", ··· 291 290 "lvdspll_d8" 292 291 }; 293 292 294 - static const char * const pmicspi_parents[] __initconst = { 293 + static const char * const pmicspi_parents[] = { 295 294 "clk26m", 296 295 "univpll2_d6", 297 296 "syspll_d8", ··· 302 301 "syspll_d24" 303 302 }; 304 303 305 - static const char * const smi_mfg_as_parents[] __initconst = { 304 + static const char * const smi_mfg_as_parents[] = { 306 305 "clk26m", 307 306 "smi_sel", 308 307 "mfg_sel", 309 308 "mem_sel" 310 309 }; 311 310 312 - static const char * const gcpu_parents[] __initconst = { 311 + static const char * const gcpu_parents[] = { 313 312 "clk26m", 314 313 "syspll_d4", 315 314 "univpll_d7", ··· 317 316 "syspll_d6" 318 317 }; 319 318 320 - static const char * const dpi1_parents[] __initconst = { 319 + static const char * const dpi1_parents[] = { 321 320 "clk26m", 322 321 "tvhdmi_h_ck", 323 322 "tvhdmi_d2", 324 323 "tvhdmi_d4" 325 324 }; 326 325 327 - static const char * const cci_parents[] __initconst = { 326 + static const char * const cci_parents[] = { 328 327 "clk26m", 329 328 "mainpll_537p3m", 330 329 "univpll_d3", ··· 333 332 "syspll_d5" 334 333 }; 335 334 336 - static const char * const apll_parents[] __initconst = { 335 + static const char * const apll_parents[] = { 337 336 "clk26m", 338 337 "apll_ck", 339 338 "apll_d4", ··· 342 341 "apll_d24" 343 342 }; 344 343 345 - static const char * const hdmipll_parents[] __initconst = { 344 + static const char * const hdmipll_parents[] = { 346 345 "clk26m", 347 346 "hdmitx_clkdig_cts", 348 347 "hdmitx_clkdig_d2", 349 348 "hdmitx_clkdig_d3" 350 349 }; 351 350 352 - static const struct mtk_composite top_muxes[] __initconst = { 351 + static const struct mtk_composite top_muxes[] = { 353 352 /* CLK_CFG_0 */ 354 353 MUX_GATE(CLK_TOP_AXI_SEL, "axi_sel", axi_parents, 355 354 0x0140, 0, 3, INVALID_MUX_GATE_BIT), ··· 391 390 MUX_GATE(CLK_TOP_GCPU_SEL, "gcpu_sel", gcpu_parents, 0x0164, 24, 3, 31), 392 391 /* CLK_CFG_9 */ 393 392 MUX_GATE(CLK_TOP_DPI1_SEL, "dpi1_sel", dpi1_parents, 0x0168, 0, 2, 7), 394 - MUX_GATE(CLK_TOP_CCI_SEL, "cci_sel", cci_parents, 0x0168, 8, 3, 15), 393 + MUX_GATE_FLAGS(CLK_TOP_CCI_SEL, "cci_sel", cci_parents, 0x0168, 8, 3, 15, CLK_IS_CRITICAL), 395 394 MUX_GATE(CLK_TOP_APLL_SEL, "apll_sel", apll_parents, 0x0168, 16, 3, 23), 396 395 MUX_GATE(CLK_TOP_HDMIPLL_SEL, "hdmipll_sel", hdmipll_parents, 0x0168, 24, 2, 31), 397 396 }; ··· 402 401 .sta_ofs = 0x0048, 403 402 }; 404 403 405 - #define GATE_ICG(_id, _name, _parent, _shift) { \ 406 - .id = _id, \ 407 - .name = _name, \ 408 - .parent_name = _parent, \ 409 - .regs = &infra_cg_regs, \ 410 - .shift = _shift, \ 411 - .ops = &mtk_clk_gate_ops_setclr, \ 412 - } 404 + #define GATE_ICG(_id, _name, _parent, _shift) \ 405 + GATE_MTK(_id, _name, _parent, &infra_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 413 406 414 - static const struct mtk_gate infra_clks[] __initconst = { 407 + #define GATE_ICG_AO(_id, _name, _parent, _shift) \ 408 + GATE_MTK_FLAGS(_id, _name, _parent, &infra_cg_regs, _shift, \ 409 + &mtk_clk_gate_ops_setclr, CLK_IS_CRITICAL) 410 + 411 + static const struct mtk_gate infra_clks[] = { 412 + GATE_DUMMY(CLK_DUMMY, "infra_dummy"), 415 413 GATE_ICG(CLK_INFRA_PMIC_WRAP, "pmic_wrap_ck", "axi_sel", 23), 416 414 GATE_ICG(CLK_INFRA_PMICSPI, "pmicspi_ck", "pmicspi_sel", 22), 417 415 GATE_ICG(CLK_INFRA_CCIF1_AP_CTRL, "ccif1_ap_ctrl", "axi_sel", 21), 418 416 GATE_ICG(CLK_INFRA_CCIF0_AP_CTRL, "ccif0_ap_ctrl", "axi_sel", 20), 419 417 GATE_ICG(CLK_INFRA_KP, "kp_ck", "axi_sel", 16), 420 418 GATE_ICG(CLK_INFRA_CPUM, "cpum_ck", "cpum_tck_in", 15), 421 - GATE_ICG(CLK_INFRA_M4U, "m4u_ck", "mem_sel", 8), 419 + GATE_ICG_AO(CLK_INFRA_M4U, "m4u_ck", "mem_sel", 8), 422 420 GATE_ICG(CLK_INFRA_MFGAXI, "mfgaxi_ck", "axi_sel", 7), 423 421 GATE_ICG(CLK_INFRA_DEVAPC, "devapc_ck", "axi_sel", 6), 424 422 GATE_ICG(CLK_INFRA_AUDIO, "audio_ck", "aud_intbus_sel", 5), ··· 438 438 .sta_ofs = 0x001c, 439 439 }; 440 440 441 - #define GATE_PERI0(_id, _name, _parent, _shift) { \ 442 - .id = _id, \ 443 - .name = _name, \ 444 - .parent_name = _parent, \ 445 - .regs = &peri0_cg_regs, \ 446 - .shift = _shift, \ 447 - .ops = &mtk_clk_gate_ops_setclr, \ 448 - } 441 + #define GATE_PERI0(_id, _name, _parent, _shift) \ 442 + GATE_MTK(_id, _name, _parent, &peri0_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 449 443 450 - #define GATE_PERI1(_id, _name, _parent, _shift) { \ 451 - .id = _id, \ 452 - .name = _name, \ 453 - .parent_name = _parent, \ 454 - .regs = &peri1_cg_regs, \ 455 - .shift = _shift, \ 456 - .ops = &mtk_clk_gate_ops_setclr, \ 457 - } 444 + #define GATE_PERI1(_id, _name, _parent, _shift) \ 445 + GATE_MTK(_id, _name, _parent, &peri1_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 458 446 459 - static const struct mtk_gate peri_gates[] __initconst = { 447 + static const struct mtk_gate peri_gates[] = { 448 + GATE_DUMMY(CLK_DUMMY, "peri_dummy"), 460 449 /* PERI0 */ 461 450 GATE_PERI0(CLK_PERI_I2C5, "i2c5_ck", "axi_sel", 31), 462 451 GATE_PERI0(CLK_PERI_I2C4, "i2c4_ck", "axi_sel", 30), ··· 491 502 GATE_PERI1(CLK_PERI_I2C6, "i2c6_ck", "axi_sel", 0), 492 503 }; 493 504 494 - static const char * const uart_ck_sel_parents[] __initconst = { 505 + static const char * const uart_ck_sel_parents[] = { 495 506 "clk26m", 496 507 "uart_sel", 497 508 }; 498 509 499 - static const struct mtk_composite peri_clks[] __initconst = { 510 + static const struct mtk_composite peri_clks[] = { 500 511 MUX(CLK_PERI_UART0_SEL, "uart0_ck_sel", uart_ck_sel_parents, 0x40c, 0, 1), 501 512 MUX(CLK_PERI_UART1_SEL, "uart1_ck_sel", uart_ck_sel_parents, 0x40c, 1, 1), 502 513 MUX(CLK_PERI_UART2_SEL, "uart2_ck_sel", uart_ck_sel_parents, 0x40c, 2, 1), ··· 521 532 } 522 533 }; 523 534 524 - static void __init mtk_topckgen_init(struct device_node *node) 525 - { 526 - struct clk_hw_onecell_data *clk_data; 527 - void __iomem *base; 528 - int r; 529 - 530 - base = of_iomap(node, 0); 531 - if (!base) { 532 - pr_err("%s(): ioremap failed\n", __func__); 533 - return; 534 - } 535 - 536 - clk_data = mtk_alloc_clk_data(CLK_TOP_NR_CLK); 537 - 538 - mtk_clk_register_factors(root_clk_alias, ARRAY_SIZE(root_clk_alias), clk_data); 539 - mtk_clk_register_factors(top_divs, ARRAY_SIZE(top_divs), clk_data); 540 - mtk_clk_register_composites(NULL, top_muxes, 541 - ARRAY_SIZE(top_muxes), base, 542 - &mt8135_clk_lock, clk_data); 543 - 544 - clk_prepare_enable(clk_data->hws[CLK_TOP_CCI_SEL]->clk); 545 - 546 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 547 - if (r) 548 - pr_err("%s(): could not register clock provider: %d\n", 549 - __func__, r); 550 - } 551 - CLK_OF_DECLARE(mtk_topckgen, "mediatek,mt8135-topckgen", mtk_topckgen_init); 552 - 553 - static void __init mtk_infrasys_init(struct device_node *node) 554 - { 555 - struct clk_hw_onecell_data *clk_data; 556 - int r; 557 - 558 - clk_data = mtk_alloc_clk_data(CLK_INFRA_NR_CLK); 559 - 560 - mtk_clk_register_gates(NULL, node, infra_clks, 561 - ARRAY_SIZE(infra_clks), clk_data); 562 - 563 - clk_prepare_enable(clk_data->hws[CLK_INFRA_M4U]->clk); 564 - 565 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 566 - if (r) 567 - pr_err("%s(): could not register clock provider: %d\n", 568 - __func__, r); 569 - 570 - mtk_register_reset_controller(node, &clk_rst_desc[0]); 571 - } 572 - CLK_OF_DECLARE(mtk_infrasys, "mediatek,mt8135-infracfg", mtk_infrasys_init); 573 - 574 - static void __init mtk_pericfg_init(struct device_node *node) 575 - { 576 - struct clk_hw_onecell_data *clk_data; 577 - int r; 578 - void __iomem *base; 579 - 580 - base = of_iomap(node, 0); 581 - if (!base) { 582 - pr_err("%s(): ioremap failed\n", __func__); 583 - return; 584 - } 585 - 586 - clk_data = mtk_alloc_clk_data(CLK_PERI_NR_CLK); 587 - 588 - mtk_clk_register_gates(NULL, node, peri_gates, 589 - ARRAY_SIZE(peri_gates), clk_data); 590 - mtk_clk_register_composites(NULL, peri_clks, 591 - ARRAY_SIZE(peri_clks), base, 592 - &mt8135_clk_lock, clk_data); 593 - 594 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 595 - if (r) 596 - pr_err("%s(): could not register clock provider: %d\n", 597 - __func__, r); 598 - 599 - mtk_register_reset_controller(node, &clk_rst_desc[1]); 600 - } 601 - CLK_OF_DECLARE(mtk_pericfg, "mediatek,mt8135-pericfg", mtk_pericfg_init); 602 - 603 - #define MT8135_PLL_FMAX (2000 * MHZ) 604 - #define CON0_MT8135_RST_BAR BIT(27) 605 - 606 - #define PLL(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits, _pd_reg, _pd_shift, _tuner_reg, _pcw_reg, _pcw_shift) { \ 607 - .id = _id, \ 608 - .name = _name, \ 609 - .reg = _reg, \ 610 - .pwr_reg = _pwr_reg, \ 611 - .en_mask = _en_mask, \ 612 - .flags = _flags, \ 613 - .rst_bar_mask = CON0_MT8135_RST_BAR, \ 614 - .fmax = MT8135_PLL_FMAX, \ 615 - .pcwbits = _pcwbits, \ 616 - .pd_reg = _pd_reg, \ 617 - .pd_shift = _pd_shift, \ 618 - .tuner_reg = _tuner_reg, \ 619 - .pcw_reg = _pcw_reg, \ 620 - .pcw_shift = _pcw_shift, \ 621 - } 622 - 623 - static const struct mtk_pll_data plls[] = { 624 - PLL(CLK_APMIXED_ARMPLL1, "armpll1", 0x200, 0x218, 0x80000000, 0, 21, 0x204, 24, 0x0, 0x204, 0), 625 - PLL(CLK_APMIXED_ARMPLL2, "armpll2", 0x2cc, 0x2e4, 0x80000000, 0, 21, 0x2d0, 24, 0x0, 0x2d0, 0), 626 - PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x21c, 0x234, 0xf0000000, HAVE_RST_BAR, 21, 0x21c, 6, 0x0, 0x220, 0), 627 - PLL(CLK_APMIXED_UNIVPLL, "univpll", 0x238, 0x250, 0xf3000000, HAVE_RST_BAR, 7, 0x238, 6, 0x0, 0x238, 9), 628 - PLL(CLK_APMIXED_MMPLL, "mmpll", 0x254, 0x26c, 0xf0000000, HAVE_RST_BAR, 21, 0x254, 6, 0x0, 0x258, 0), 629 - PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x278, 0x290, 0x80000000, 0, 21, 0x278, 6, 0x0, 0x27c, 0), 630 - PLL(CLK_APMIXED_TVDPLL, "tvdpll", 0x294, 0x2ac, 0x80000000, 0, 31, 0x294, 6, 0x0, 0x298, 0), 631 - PLL(CLK_APMIXED_LVDSPLL, "lvdspll", 0x2b0, 0x2c8, 0x80000000, 0, 21, 0x2b0, 6, 0x0, 0x2b4, 0), 632 - PLL(CLK_APMIXED_AUDPLL, "audpll", 0x2e8, 0x300, 0x80000000, 0, 31, 0x2e8, 6, 0x2f8, 0x2ec, 0), 633 - PLL(CLK_APMIXED_VDECPLL, "vdecpll", 0x304, 0x31c, 0x80000000, 0, 21, 0x2b0, 6, 0x0, 0x308, 0), 535 + static const struct mtk_clk_desc infra_desc = { 536 + .clks = infra_clks, 537 + .num_clks = ARRAY_SIZE(infra_clks), 538 + .rst_desc = &clk_rst_desc[0], 634 539 }; 635 540 636 - static void __init mtk_apmixedsys_init(struct device_node *node) 637 - { 638 - struct clk_hw_onecell_data *clk_data; 541 + static const struct mtk_clk_desc peri_desc = { 542 + .clks = peri_gates, 543 + .num_clks = ARRAY_SIZE(peri_gates), 544 + .composite_clks = peri_clks, 545 + .num_composite_clks = ARRAY_SIZE(peri_clks), 546 + .clk_lock = &mt8135_clk_lock, 547 + .rst_desc = &clk_rst_desc[1], 548 + }; 639 549 640 - clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK); 641 - if (!clk_data) 642 - return; 550 + static const struct mtk_clk_desc topck_desc = { 551 + .factor_clks = top_divs, 552 + .num_factor_clks = ARRAY_SIZE(top_divs), 553 + .composite_clks = top_muxes, 554 + .num_composite_clks = ARRAY_SIZE(top_muxes), 555 + .clk_lock = &mt8135_clk_lock, 556 + }; 643 557 644 - mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data); 645 - } 646 - CLK_OF_DECLARE(mtk_apmixedsys, "mediatek,mt8135-apmixedsys", 647 - mtk_apmixedsys_init); 558 + static const struct of_device_id of_match_clk_mt8135[] = { 559 + { .compatible = "mediatek,mt8135-infracfg", .data = &infra_desc }, 560 + { .compatible = "mediatek,mt8135-pericfg", .data = &peri_desc }, 561 + { .compatible = "mediatek,mt8135-topckgen", .data = &topck_desc }, 562 + { /* sentinel */ } 563 + }; 564 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8135); 565 + 566 + static struct platform_driver clk_mt8135_drv = { 567 + .driver = { 568 + .name = "clk-mt8135", 569 + .of_match_table = of_match_clk_mt8135, 570 + }, 571 + .probe = mtk_clk_simple_probe, 572 + .remove = mtk_clk_simple_remove, 573 + }; 574 + module_platform_driver(clk_mt8135_drv); 575 + 576 + MODULE_DESCRIPTION("MediaTek MT8135 clocks driver"); 577 + MODULE_LICENSE("GPL");
+145
drivers/clk/mediatek/clk-mt8167-apmixedsys.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Copyright (c) 2020 MediaTek Inc. 4 + * Copyright (c) 2020 BayLibre, SAS 5 + * Copyright (c) 2023 Collabora, Ltd. 6 + */ 7 + 8 + #include <dt-bindings/clock/mt8167-clk.h> 9 + #include <linux/clk.h> 10 + #include <linux/of.h> 11 + #include <linux/platform_device.h> 12 + 13 + #include "clk-pll.h" 14 + #include "clk-mtk.h" 15 + 16 + static DEFINE_SPINLOCK(mt8167_apmixed_clk_lock); 17 + 18 + #define MT8167_PLL_FMAX (2500UL * MHZ) 19 + 20 + #define CON0_MT8167_RST_BAR BIT(27) 21 + 22 + #define PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits, \ 23 + _pd_reg, _pd_shift, _tuner_reg, _pcw_reg, \ 24 + _pcw_shift, _div_table) { \ 25 + .id = _id, \ 26 + .name = _name, \ 27 + .reg = _reg, \ 28 + .pwr_reg = _pwr_reg, \ 29 + .en_mask = _en_mask, \ 30 + .flags = _flags, \ 31 + .rst_bar_mask = CON0_MT8167_RST_BAR, \ 32 + .fmax = MT8167_PLL_FMAX, \ 33 + .pcwbits = _pcwbits, \ 34 + .pd_reg = _pd_reg, \ 35 + .pd_shift = _pd_shift, \ 36 + .tuner_reg = _tuner_reg, \ 37 + .pcw_reg = _pcw_reg, \ 38 + .pcw_shift = _pcw_shift, \ 39 + .div_table = _div_table, \ 40 + } 41 + 42 + #define PLL(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits, \ 43 + _pd_reg, _pd_shift, _tuner_reg, _pcw_reg, \ 44 + _pcw_shift) \ 45 + PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits, \ 46 + _pd_reg, _pd_shift, _tuner_reg, _pcw_reg, _pcw_shift, \ 47 + NULL) 48 + 49 + static const struct mtk_pll_div_table mmpll_div_table[] = { 50 + { .div = 0, .freq = MT8167_PLL_FMAX }, 51 + { .div = 1, .freq = 1000000000 }, 52 + { .div = 2, .freq = 604500000 }, 53 + { .div = 3, .freq = 253500000 }, 54 + { .div = 4, .freq = 126750000 }, 55 + { /* sentinel */ } 56 + }; 57 + 58 + static const struct mtk_pll_data plls[] = { 59 + PLL(CLK_APMIXED_ARMPLL, "armpll", 0x0100, 0x0110, 0, 0, 60 + 21, 0x0104, 24, 0, 0x0104, 0), 61 + PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0120, 0x0130, 0, 62 + HAVE_RST_BAR, 21, 0x0124, 24, 0, 0x0124, 0), 63 + PLL(CLK_APMIXED_UNIVPLL, "univpll", 0x0140, 0x0150, 0x30000000, 64 + HAVE_RST_BAR, 7, 0x0144, 24, 0, 0x0144, 0), 65 + PLL_B(CLK_APMIXED_MMPLL, "mmpll", 0x0160, 0x0170, 0, 0, 66 + 21, 0x0164, 24, 0, 0x0164, 0, mmpll_div_table), 67 + PLL(CLK_APMIXED_APLL1, "apll1", 0x0180, 0x0190, 0, 0, 68 + 31, 0x0180, 1, 0x0194, 0x0184, 0), 69 + PLL(CLK_APMIXED_APLL2, "apll2", 0x01A0, 0x01B0, 0, 0, 70 + 31, 0x01A0, 1, 0x01B4, 0x01A4, 0), 71 + PLL(CLK_APMIXED_TVDPLL, "tvdpll", 0x01C0, 0x01D0, 0, 0, 72 + 21, 0x01C4, 24, 0, 0x01C4, 0), 73 + PLL(CLK_APMIXED_LVDSPLL, "lvdspll", 0x01E0, 0x01F0, 0, 0, 74 + 21, 0x01E4, 24, 0, 0x01E4, 0), 75 + }; 76 + 77 + #define DIV_ADJ_FLAG(_id, _name, _parent, _reg, _shift, _width, _flag) { \ 78 + .id = _id, \ 79 + .name = _name, \ 80 + .parent_name = _parent, \ 81 + .div_reg = _reg, \ 82 + .div_shift = _shift, \ 83 + .div_width = _width, \ 84 + .clk_divider_flags = _flag, \ 85 + } 86 + 87 + static const struct mtk_clk_divider adj_divs[] = { 88 + DIV_ADJ_FLAG(CLK_APMIXED_HDMI_REF, "hdmi_ref", "tvdpll", 89 + 0x1c4, 24, 3, CLK_DIVIDER_POWER_OF_TWO), 90 + }; 91 + 92 + static int clk_mt8167_apmixed_probe(struct platform_device *pdev) 93 + { 94 + void __iomem *base; 95 + struct clk_hw_onecell_data *clk_data; 96 + struct device_node *node = pdev->dev.of_node; 97 + struct device *dev = &pdev->dev; 98 + int ret; 99 + 100 + base = devm_platform_ioremap_resource(pdev, 0); 101 + if (IS_ERR(base)) 102 + return PTR_ERR(base); 103 + 104 + clk_data = mtk_devm_alloc_clk_data(dev, MT8167_CLK_APMIXED_NR_CLK); 105 + if (!clk_data) 106 + return -ENOMEM; 107 + 108 + ret = mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data); 109 + if (ret) 110 + return ret; 111 + 112 + ret = mtk_clk_register_dividers(dev, adj_divs, ARRAY_SIZE(adj_divs), base, 113 + &mt8167_apmixed_clk_lock, clk_data); 114 + if (ret) 115 + goto unregister_plls; 116 + 117 + ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 118 + if (ret) 119 + goto unregister_dividers; 120 + 121 + return 0; 122 + 123 + unregister_dividers: 124 + mtk_clk_unregister_dividers(adj_divs, ARRAY_SIZE(adj_divs), clk_data); 125 + unregister_plls: 126 + mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data); 127 + 128 + return ret; 129 + } 130 + 131 + static const struct of_device_id of_match_clk_mt8167_apmixed[] = { 132 + { .compatible = "mediatek,mt8167-apmixedsys" }, 133 + { /* sentinel */ } 134 + }; 135 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8167_apmixed); 136 + 137 + static struct platform_driver clk_mt8167_apmixed_drv = { 138 + .probe = clk_mt8167_apmixed_probe, 139 + .driver = { 140 + .name = "clk-mt8167-apmixed", 141 + .of_match_table = of_match_clk_mt8167_apmixed, 142 + }, 143 + }; 144 + builtin_platform_driver(clk_mt8167_apmixed_drv) 145 + MODULE_LICENSE("GPL");
+23 -23
drivers/clk/mediatek/clk-mt8167-aud.c
··· 23 23 .sta_ofs = 0x0, 24 24 }; 25 25 26 - #define GATE_AUD(_id, _name, _parent, _shift) { \ 27 - .id = _id, \ 28 - .name = _name, \ 29 - .parent_name = _parent, \ 30 - .regs = &aud_cg_regs, \ 31 - .shift = _shift, \ 32 - .ops = &mtk_clk_gate_ops_no_setclr, \ 33 - } 26 + #define GATE_AUD(_id, _name, _parent, _shift) \ 27 + GATE_MTK(_id, _name, _parent, &aud_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr) 34 28 35 - static const struct mtk_gate aud_clks[] __initconst = { 29 + 30 + static const struct mtk_gate aud_clks[] = { 36 31 GATE_AUD(CLK_AUD_AFE, "aud_afe", "clk26m_ck", 2), 37 32 GATE_AUD(CLK_AUD_I2S, "aud_i2s", "i2s_infra_bck", 6), 38 33 GATE_AUD(CLK_AUD_22M, "aud_22m", "rg_aud_engen1", 8), ··· 43 48 GATE_AUD(CLK_AUD_TML, "aud_tml", "aud_afe", 27), 44 49 }; 45 50 46 - static void __init mtk_audsys_init(struct device_node *node) 47 - { 48 - struct clk_hw_onecell_data *clk_data; 49 - int r; 51 + static const struct mtk_clk_desc aud_desc = { 52 + .clks = aud_clks, 53 + .num_clks = ARRAY_SIZE(aud_clks), 54 + }; 50 55 51 - clk_data = mtk_alloc_clk_data(CLK_AUD_NR_CLK); 56 + static const struct of_device_id of_match_clk_mt8167_audsys[] = { 57 + { .compatible = "mediatek,mt8167-audsys", .data = &aud_desc }, 58 + { /* sentinel */ } 59 + }; 60 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8167_audsys); 52 61 53 - mtk_clk_register_gates(NULL, node, aud_clks, ARRAY_SIZE(aud_clks), clk_data); 54 - 55 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 56 - if (r) 57 - pr_err("%s(): could not register clock provider: %d\n", 58 - __func__, r); 59 - 60 - } 61 - CLK_OF_DECLARE(mtk_audsys, "mediatek,mt8167-audsys", mtk_audsys_init); 62 + static struct platform_driver clk_mt8167_audsys_drv = { 63 + .probe = mtk_clk_simple_probe, 64 + .remove = mtk_clk_simple_remove, 65 + .driver = { 66 + .name = "clk-mt8167-audsys", 67 + .of_match_table = of_match_clk_mt8167_audsys, 68 + }, 69 + }; 70 + module_platform_driver(clk_mt8167_audsys_drv); 71 + MODULE_LICENSE("GPL");
+22 -24
drivers/clk/mediatek/clk-mt8167-img.c
··· 23 23 .sta_ofs = 0x0, 24 24 }; 25 25 26 - #define GATE_IMG(_id, _name, _parent, _shift) { \ 27 - .id = _id, \ 28 - .name = _name, \ 29 - .parent_name = _parent, \ 30 - .regs = &img_cg_regs, \ 31 - .shift = _shift, \ 32 - .ops = &mtk_clk_gate_ops_setclr, \ 33 - } 26 + #define GATE_IMG(_id, _name, _parent, _shift) \ 27 + GATE_MTK(_id, _name, _parent, &img_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 34 28 35 - static const struct mtk_gate img_clks[] __initconst = { 29 + static const struct mtk_gate img_clks[] = { 36 30 GATE_IMG(CLK_IMG_LARB1_SMI, "img_larb1_smi", "smi_mm", 0), 37 31 GATE_IMG(CLK_IMG_CAM_SMI, "img_cam_smi", "smi_mm", 5), 38 32 GATE_IMG(CLK_IMG_CAM_CAM, "img_cam_cam", "smi_mm", 6), ··· 35 41 GATE_IMG(CLK_IMG_VENC, "img_venc", "smi_mm", 9), 36 42 }; 37 43 38 - static void __init mtk_imgsys_init(struct device_node *node) 39 - { 40 - struct clk_hw_onecell_data *clk_data; 41 - int r; 44 + static const struct mtk_clk_desc img_desc = { 45 + .clks = img_clks, 46 + .num_clks = ARRAY_SIZE(img_clks), 47 + }; 42 48 43 - clk_data = mtk_alloc_clk_data(CLK_IMG_NR_CLK); 49 + static const struct of_device_id of_match_clk_mt8167_imgsys[] = { 50 + { .compatible = "mediatek,mt8167-imgsys", .data = &img_desc }, 51 + { /* sentinel */ } 52 + }; 53 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8167_imgsys); 44 54 45 - mtk_clk_register_gates(NULL, node, img_clks, ARRAY_SIZE(img_clks), clk_data); 46 - 47 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 48 - 49 - if (r) 50 - pr_err("%s(): could not register clock provider: %d\n", 51 - __func__, r); 52 - 53 - } 54 - CLK_OF_DECLARE(mtk_imgsys, "mediatek,mt8167-imgsys", mtk_imgsys_init); 55 + static struct platform_driver clk_mt8167_imgsys_drv = { 56 + .probe = mtk_clk_simple_probe, 57 + .remove = mtk_clk_simple_remove, 58 + .driver = { 59 + .name = "clk-mt8167-imgsys", 60 + .of_match_table = of_match_clk_mt8167_imgsys, 61 + }, 62 + }; 63 + module_platform_driver(clk_mt8167_imgsys_drv); 64 + MODULE_LICENSE("GPL");
+22 -24
drivers/clk/mediatek/clk-mt8167-mfgcfg.c
··· 23 23 .sta_ofs = 0x0, 24 24 }; 25 25 26 - #define GATE_MFG(_id, _name, _parent, _shift) { \ 27 - .id = _id, \ 28 - .name = _name, \ 29 - .parent_name = _parent, \ 30 - .regs = &mfg_cg_regs, \ 31 - .shift = _shift, \ 32 - .ops = &mtk_clk_gate_ops_setclr, \ 33 - } 26 + #define GATE_MFG(_id, _name, _parent, _shift) \ 27 + GATE_MTK(_id, _name, _parent, &mfg_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 34 28 35 - static const struct mtk_gate mfg_clks[] __initconst = { 29 + static const struct mtk_gate mfg_clks[] = { 36 30 GATE_MFG(CLK_MFG_BAXI, "mfg_baxi", "ahb_infra_sel", 0), 37 31 GATE_MFG(CLK_MFG_BMEM, "mfg_bmem", "gfmux_emi1x_sel", 1), 38 32 GATE_MFG(CLK_MFG_BG3D, "mfg_bg3d", "mfg_mm", 2), 39 33 GATE_MFG(CLK_MFG_B26M, "mfg_b26m", "clk26m_ck", 3), 40 34 }; 41 35 42 - static void __init mtk_mfgcfg_init(struct device_node *node) 43 - { 44 - struct clk_hw_onecell_data *clk_data; 45 - int r; 36 + static const struct mtk_clk_desc mfg_desc = { 37 + .clks = mfg_clks, 38 + .num_clks = ARRAY_SIZE(mfg_clks), 39 + }; 46 40 47 - clk_data = mtk_alloc_clk_data(CLK_MFG_NR_CLK); 41 + static const struct of_device_id of_match_clk_mt8167_mfgcfg[] = { 42 + { .compatible = "mediatek,mt8167-mfgcfg", .data = &mfg_desc }, 43 + { /* sentinel */ } 44 + }; 45 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8167_mfgcfg); 48 46 49 - mtk_clk_register_gates(NULL, node, mfg_clks, ARRAY_SIZE(mfg_clks), clk_data); 50 - 51 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 52 - 53 - if (r) 54 - pr_err("%s(): could not register clock provider: %d\n", 55 - __func__, r); 56 - 57 - } 58 - CLK_OF_DECLARE(mtk_mfgcfg, "mediatek,mt8167-mfgcfg", mtk_mfgcfg_init); 47 + static struct platform_driver clk_mt8167_mfgcfg_drv = { 48 + .probe = mtk_clk_simple_probe, 49 + .remove = mtk_clk_simple_remove, 50 + .driver = { 51 + .name = "clk-mt8167-mfgcfg", 52 + .of_match_table = of_match_clk_mt8167_mfgcfg, 53 + }, 54 + }; 55 + module_platform_driver(clk_mt8167_mfgcfg_drv); 56 + MODULE_LICENSE("GPL");
+17 -52
drivers/clk/mediatek/clk-mt8167-mm.c
··· 29 29 .sta_ofs = 0x110, 30 30 }; 31 31 32 - #define GATE_MM0(_id, _name, _parent, _shift) { \ 33 - .id = _id, \ 34 - .name = _name, \ 35 - .parent_name = _parent, \ 36 - .regs = &mm0_cg_regs, \ 37 - .shift = _shift, \ 38 - .ops = &mtk_clk_gate_ops_setclr, \ 39 - } 32 + #define GATE_MM0(_id, _name, _parent, _shift) \ 33 + GATE_MTK(_id, _name, _parent, &mm0_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 40 34 41 - #define GATE_MM1(_id, _name, _parent, _shift) { \ 42 - .id = _id, \ 43 - .name = _name, \ 44 - .parent_name = _parent, \ 45 - .regs = &mm1_cg_regs, \ 46 - .shift = _shift, \ 47 - .ops = &mtk_clk_gate_ops_setclr, \ 48 - } 35 + #define GATE_MM1(_id, _name, _parent, _shift) \ 36 + GATE_MTK(_id, _name, _parent, &mm1_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 49 37 50 38 static const struct mtk_gate mm_clks[] = { 51 39 /* MM0 */ ··· 74 86 GATE_MM1(CLK_MM_HDMI_PLL, "mm_hdmi_pll", "hdmtx_dig_cts", 21), 75 87 }; 76 88 77 - struct clk_mt8167_mm_driver_data { 78 - const struct mtk_gate *gates_clk; 79 - int gates_num; 89 + static const struct mtk_clk_desc mm_desc = { 90 + .clks = mm_clks, 91 + .num_clks = ARRAY_SIZE(mm_clks), 80 92 }; 81 93 82 - static const struct clk_mt8167_mm_driver_data mt8167_mmsys_driver_data = { 83 - .gates_clk = mm_clks, 84 - .gates_num = ARRAY_SIZE(mm_clks), 94 + static const struct platform_device_id clk_mt8167_mm_id_table[] = { 95 + { .name = "clk-mt8167-mm", .driver_data = (kernel_ulong_t)&mm_desc }, 96 + { /* sentinel */ } 85 97 }; 98 + MODULE_DEVICE_TABLE(platform, clk_mt8167_mm_id_table); 86 99 87 - static int clk_mt8167_mm_probe(struct platform_device *pdev) 88 - { 89 - struct device *dev = &pdev->dev; 90 - struct device_node *node = dev->parent->of_node; 91 - const struct clk_mt8167_mm_driver_data *data; 92 - struct clk_hw_onecell_data *clk_data; 93 - int ret; 94 - 95 - clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK); 96 - if (!clk_data) 97 - return -ENOMEM; 98 - 99 - data = &mt8167_mmsys_driver_data; 100 - 101 - ret = mtk_clk_register_gates(&pdev->dev, node, data->gates_clk, 102 - data->gates_num, clk_data); 103 - if (ret) 104 - return ret; 105 - 106 - ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 107 - if (ret) 108 - return ret; 109 - 110 - return 0; 111 - } 112 - 113 - static struct platform_driver clk_mt8173_mm_drv = { 100 + static struct platform_driver clk_mt8167_mm_drv = { 101 + .probe = mtk_clk_pdev_probe, 102 + .remove = mtk_clk_pdev_remove, 114 103 .driver = { 115 104 .name = "clk-mt8167-mm", 116 105 }, 117 - .probe = clk_mt8167_mm_probe, 106 + .id_table = clk_mt8167_mm_id_table, 118 107 }; 119 - 120 - builtin_platform_driver(clk_mt8173_mm_drv); 108 + module_platform_driver(clk_mt8167_mm_drv); 109 + MODULE_LICENSE("GPL");
+24 -33
drivers/clk/mediatek/clk-mt8167-vdec.c
··· 29 29 .sta_ofs = 0x8, 30 30 }; 31 31 32 - #define GATE_VDEC0_I(_id, _name, _parent, _shift) { \ 33 - .id = _id, \ 34 - .name = _name, \ 35 - .parent_name = _parent, \ 36 - .regs = &vdec0_cg_regs, \ 37 - .shift = _shift, \ 38 - .ops = &mtk_clk_gate_ops_setclr_inv, \ 39 - } 32 + #define GATE_VDEC0_I(_id, _name, _parent, _shift) \ 33 + GATE_MTK(_id, _name, _parent, &vdec0_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv) 40 34 41 - #define GATE_VDEC1_I(_id, _name, _parent, _shift) { \ 42 - .id = _id, \ 43 - .name = _name, \ 44 - .parent_name = _parent, \ 45 - .regs = &vdec1_cg_regs, \ 46 - .shift = _shift, \ 47 - .ops = &mtk_clk_gate_ops_setclr_inv, \ 48 - } 35 + #define GATE_VDEC1_I(_id, _name, _parent, _shift) \ 36 + GATE_MTK(_id, _name, _parent, &vdec1_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv) 49 37 50 - static const struct mtk_gate vdec_clks[] __initconst = { 38 + static const struct mtk_gate vdec_clks[] = { 51 39 /* VDEC0 */ 52 40 GATE_VDEC0_I(CLK_VDEC_CKEN, "vdec_cken", "rg_vdec", 0), 53 41 /* VDEC1 */ 54 42 GATE_VDEC1_I(CLK_VDEC_LARB1_CKEN, "vdec_larb1_cken", "smi_mm", 0), 55 43 }; 56 44 57 - static void __init mtk_vdecsys_init(struct device_node *node) 58 - { 59 - struct clk_hw_onecell_data *clk_data; 60 - int r; 45 + static const struct mtk_clk_desc vdec_desc = { 46 + .clks = vdec_clks, 47 + .num_clks = ARRAY_SIZE(vdec_clks), 48 + }; 61 49 62 - clk_data = mtk_alloc_clk_data(CLK_VDEC_NR_CLK); 50 + static const struct of_device_id of_match_clk_mt8167_vdec[] = { 51 + { .compatible = "mediatek,mt8167-vdecsys", .data = &vdec_desc }, 52 + { /* sentinel */ } 53 + }; 54 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8167_vdec); 63 55 64 - mtk_clk_register_gates(NULL, node, vdec_clks, ARRAY_SIZE(vdec_clks), 65 - clk_data); 66 - 67 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 68 - 69 - if (r) 70 - pr_err("%s(): could not register clock provider: %d\n", 71 - __func__, r); 72 - 73 - } 74 - CLK_OF_DECLARE(mtk_vdecsys, "mediatek,mt8167-vdecsys", mtk_vdecsys_init); 56 + static struct platform_driver clk_mt8167_vdec_drv = { 57 + .probe = mtk_clk_simple_probe, 58 + .remove = mtk_clk_simple_remove, 59 + .driver = { 60 + .name = "clk-mt8167-vdecsys", 61 + .of_match_table = of_match_clk_mt8167_vdec, 62 + }, 63 + }; 64 + module_platform_driver(clk_mt8167_vdec_drv); 65 + MODULE_LICENSE("GPL");
+99 -267
drivers/clk/mediatek/clk-mt8167.c
··· 11 11 #include <linux/of_address.h> 12 12 #include <linux/slab.h> 13 13 #include <linux/mfd/syscon.h> 14 + #include <linux/platform_device.h> 14 15 15 16 #include "clk-gate.h" 16 17 #include "clk-mtk.h" 17 - #include "clk-pll.h" 18 18 19 19 #include <dt-bindings/clock/mt8167-clk.h> 20 20 21 21 static DEFINE_SPINLOCK(mt8167_clk_lock); 22 22 23 - static const struct mtk_fixed_clk fixed_clks[] __initconst = { 23 + static const struct mtk_fixed_clk fixed_clks[] = { 24 24 FIXED_CLK(CLK_TOP_CLK_NULL, "clk_null", NULL, 0), 25 25 FIXED_CLK(CLK_TOP_I2S_INFRA_BCK, "i2s_infra_bck", "clk_null", 26000000), 26 26 FIXED_CLK(CLK_TOP_MEMPLL, "mempll", "clk26m", 800000000), ··· 29 29 FIXED_CLK(CLK_TOP_LVDSTX_CLKDIG_CTS, "lvdstx_dig_cts", "clk26m", 52500000), 30 30 }; 31 31 32 - static const struct mtk_fixed_factor top_divs[] __initconst = { 32 + static const struct mtk_fixed_factor top_divs[] = { 33 33 FACTOR(CLK_TOP_DMPLL, "dmpll_ck", "mempll", 1, 1), 34 34 FACTOR(CLK_TOP_MAINPLL_D2, "mainpll_d2", "mainpll", 1, 2), 35 35 FACTOR(CLK_TOP_MAINPLL_D4, "mainpll_d4", "mainpll", 1, 4), ··· 85 85 FACTOR(CLK_TOP_ETH_D2, "eth_d2_ck", "eth_sel", 1, 2), 86 86 }; 87 87 88 - static const char * const uart0_parents[] __initconst = { 88 + static const char * const uart0_parents[] = { 89 89 "clk26m_ck", 90 90 "univpll_d24" 91 91 }; 92 92 93 - static const char * const gfmux_emi1x_parents[] __initconst = { 93 + static const char * const gfmux_emi1x_parents[] = { 94 94 "clk26m_ck", 95 95 "dmpll_ck" 96 96 }; 97 97 98 - static const char * const emi_ddrphy_parents[] __initconst = { 98 + static const char * const emi_ddrphy_parents[] = { 99 99 "gfmux_emi1x_sel", 100 100 "gfmux_emi1x_sel" 101 101 }; 102 102 103 - static const char * const ahb_infra_parents[] __initconst = { 103 + static const char * const ahb_infra_parents[] = { 104 104 "clk_null", 105 105 "clk26m_ck", 106 106 "mainpll_d11", ··· 116 116 "mainpll_d10" 117 117 }; 118 118 119 - static const char * const csw_mux_mfg_parents[] __initconst = { 119 + static const char * const csw_mux_mfg_parents[] = { 120 120 "clk_null", 121 121 "clk_null", 122 122 "univpll_d3", ··· 127 127 "mmpll380m" 128 128 }; 129 129 130 - static const char * const msdc0_parents[] __initconst = { 130 + static const char * const msdc0_parents[] = { 131 131 "clk26m_ck", 132 132 "univpll_d6", 133 133 "mainpll_d8", ··· 138 138 "mmpll_d2" 139 139 }; 140 140 141 - static const char * const camtg_mm_parents[] __initconst = { 141 + static const char * const camtg_mm_parents[] = { 142 142 "clk_null", 143 143 "clk26m_ck", 144 144 "usb_phy48m_ck", ··· 146 146 "univpll_d6" 147 147 }; 148 148 149 - static const char * const pwm_mm_parents[] __initconst = { 149 + static const char * const pwm_mm_parents[] = { 150 150 "clk26m_ck", 151 151 "univpll_d12" 152 152 }; 153 153 154 - static const char * const uart1_parents[] __initconst = { 154 + static const char * const uart1_parents[] = { 155 155 "clk26m_ck", 156 156 "univpll_d24" 157 157 }; 158 158 159 - static const char * const msdc1_parents[] __initconst = { 159 + static const char * const msdc1_parents[] = { 160 160 "clk26m_ck", 161 161 "univpll_d6", 162 162 "mainpll_d8", ··· 167 167 "mmpll_d2" 168 168 }; 169 169 170 - static const char * const spm_52m_parents[] __initconst = { 170 + static const char * const spm_52m_parents[] = { 171 171 "clk26m_ck", 172 172 "univpll_d24" 173 173 }; 174 174 175 - static const char * const pmicspi_parents[] __initconst = { 175 + static const char * const pmicspi_parents[] = { 176 176 "univpll_d20", 177 177 "usb_phy48m_ck", 178 178 "univpll_d16", 179 179 "clk26m_ck" 180 180 }; 181 181 182 - static const char * const qaxi_aud26m_parents[] __initconst = { 182 + static const char * const qaxi_aud26m_parents[] = { 183 183 "clk26m_ck", 184 184 "ahb_infra_sel" 185 185 }; 186 186 187 - static const char * const aud_intbus_parents[] __initconst = { 187 + static const char * const aud_intbus_parents[] = { 188 188 "clk_null", 189 189 "clk26m_ck", 190 190 "mainpll_d22", ··· 192 192 "mainpll_d11" 193 193 }; 194 194 195 - static const char * const nfi2x_pad_parents[] __initconst = { 195 + static const char * const nfi2x_pad_parents[] = { 196 196 "clk_null", 197 197 "clk_null", 198 198 "clk_null", ··· 280 280 "mainpll_d5" 281 281 }; 282 282 283 - static const char * const nfi1x_pad_parents[] __initconst = { 283 + static const char * const nfi1x_pad_parents[] = { 284 284 "ahb_infra_sel", 285 285 "nfi1x_ck" 286 286 }; 287 287 288 - static const char * const mfg_mm_parents[] __initconst = { 288 + static const char * const mfg_mm_parents[] = { 289 289 "clk_null", 290 290 "clk_null", 291 291 "clk_null", ··· 325 325 "mainpll_d14" 326 326 }; 327 327 328 - static const char * const ddrphycfg_parents[] __initconst = { 328 + static const char * const ddrphycfg_parents[] = { 329 329 "clk26m_ck", 330 330 "mainpll_d16" 331 331 }; 332 332 333 - static const char * const smi_mm_parents[] __initconst = { 333 + static const char * const smi_mm_parents[] = { 334 334 "clk26m_ck", 335 335 "clk_null", 336 336 "clk_null", ··· 346 346 "mainpll_d14" 347 347 }; 348 348 349 - static const char * const usb_78m_parents[] __initconst = { 349 + static const char * const usb_78m_parents[] = { 350 350 "clk_null", 351 351 "clk26m_ck", 352 352 "univpll_d16", ··· 354 354 "mainpll_d20" 355 355 }; 356 356 357 - static const char * const scam_mm_parents[] __initconst = { 357 + static const char * const scam_mm_parents[] = { 358 358 "clk_null", 359 359 "clk26m_ck", 360 360 "mainpll_d14", ··· 362 362 "mainpll_d12" 363 363 }; 364 364 365 - static const char * const spinor_parents[] __initconst = { 365 + static const char * const spinor_parents[] = { 366 366 "clk26m_d2", 367 367 "clk26m_ck", 368 368 "mainpll_d40", ··· 373 373 "univpll_d12" 374 374 }; 375 375 376 - static const char * const msdc2_parents[] __initconst = { 376 + static const char * const msdc2_parents[] = { 377 377 "clk26m_ck", 378 378 "univpll_d6", 379 379 "mainpll_d8", ··· 384 384 "mmpll_d2" 385 385 }; 386 386 387 - static const char * const eth_parents[] __initconst = { 387 + static const char * const eth_parents[] = { 388 388 "clk26m_ck", 389 389 "mainpll_d40", 390 390 "univpll_d24", ··· 392 392 "mainpll_d20" 393 393 }; 394 394 395 - static const char * const vdec_mm_parents[] __initconst = { 395 + static const char * const vdec_mm_parents[] = { 396 396 "clk26m_ck", 397 397 "univpll_d4", 398 398 "mainpll_d4", ··· 401 401 "mainpll_d6" 402 402 }; 403 403 404 - static const char * const dpi0_mm_parents[] __initconst = { 404 + static const char * const dpi0_mm_parents[] = { 405 405 "clk26m_ck", 406 406 "lvdspll_ck", 407 407 "lvdspll_d2", ··· 409 409 "lvdspll_d8" 410 410 }; 411 411 412 - static const char * const dpi1_mm_parents[] __initconst = { 412 + static const char * const dpi1_mm_parents[] = { 413 413 "clk26m_ck", 414 414 "tvdpll_d2", 415 415 "tvdpll_d4", ··· 417 417 "tvdpll_d16" 418 418 }; 419 419 420 - static const char * const axi_mfg_in_parents[] __initconst = { 420 + static const char * const axi_mfg_in_parents[] = { 421 421 "clk26m_ck", 422 422 "mainpll_d11", 423 423 "univpll_d24", 424 424 "mmpll380m" 425 425 }; 426 426 427 - static const char * const slow_mfg_parents[] __initconst = { 427 + static const char * const slow_mfg_parents[] = { 428 428 "clk26m_ck", 429 429 "univpll_d12", 430 430 "univpll_d24" 431 431 }; 432 432 433 - static const char * const aud1_parents[] __initconst = { 433 + static const char * const aud1_parents[] = { 434 434 "clk26m_ck", 435 435 "apll1_ck" 436 436 }; 437 437 438 - static const char * const aud2_parents[] __initconst = { 438 + static const char * const aud2_parents[] = { 439 439 "clk26m_ck", 440 440 "apll2_ck" 441 441 }; 442 442 443 - static const char * const aud_engen1_parents[] __initconst = { 443 + static const char * const aud_engen1_parents[] = { 444 444 "clk26m_ck", 445 445 "rg_apll1_d2_en", 446 446 "rg_apll1_d4_en", 447 447 "rg_apll1_d8_en" 448 448 }; 449 449 450 - static const char * const aud_engen2_parents[] __initconst = { 450 + static const char * const aud_engen2_parents[] = { 451 451 "clk26m_ck", 452 452 "rg_apll2_d2_en", 453 453 "rg_apll2_d4_en", 454 454 "rg_apll2_d8_en" 455 455 }; 456 456 457 - static const char * const i2c_parents[] __initconst = { 457 + static const char * const i2c_parents[] = { 458 458 "clk26m_ck", 459 459 "univpll_d20", 460 460 "univpll_d16", 461 461 "univpll_d12" 462 462 }; 463 463 464 - static const char * const aud_i2s0_m_parents[] __initconst = { 464 + static const char * const aud_i2s0_m_parents[] = { 465 465 "rg_aud1", 466 466 "rg_aud2" 467 467 }; 468 468 469 - static const char * const pwm_parents[] __initconst = { 469 + static const char * const pwm_parents[] = { 470 470 "clk26m_ck", 471 471 "univpll_d12" 472 472 }; 473 473 474 - static const char * const spi_parents[] __initconst = { 474 + static const char * const spi_parents[] = { 475 475 "clk26m_ck", 476 476 "univpll_d12", 477 477 "univpll_d8", 478 478 "univpll_d6" 479 479 }; 480 480 481 - static const char * const aud_spdifin_parents[] __initconst = { 481 + static const char * const aud_spdifin_parents[] = { 482 482 "clk26m_ck", 483 483 "univpll_d2" 484 484 }; 485 485 486 - static const char * const uart2_parents[] __initconst = { 486 + static const char * const uart2_parents[] = { 487 487 "clk26m_ck", 488 488 "univpll_d24" 489 489 }; 490 490 491 - static const char * const bsi_parents[] __initconst = { 491 + static const char * const bsi_parents[] = { 492 492 "clk26m_ck", 493 493 "mainpll_d10", 494 494 "mainpll_d12", 495 495 "mainpll_d20" 496 496 }; 497 497 498 - static const char * const dbg_atclk_parents[] __initconst = { 498 + static const char * const dbg_atclk_parents[] = { 499 499 "clk_null", 500 500 "clk26m_ck", 501 501 "mainpll_d5", ··· 503 503 "univpll_d5" 504 504 }; 505 505 506 - static const char * const csw_nfiecc_parents[] __initconst = { 506 + static const char * const csw_nfiecc_parents[] = { 507 507 "clk_null", 508 508 "mainpll_d7", 509 509 "mainpll_d6", ··· 511 511 "mainpll_d5" 512 512 }; 513 513 514 - static const char * const nfiecc_parents[] __initconst = { 514 + static const char * const nfiecc_parents[] = { 515 515 "clk_null", 516 516 "nfi2x_pad_sel", 517 517 "mainpll_d4", ··· 625 625 0x07c, 13, 3), 626 626 }; 627 627 628 - static const char * const ifr_mux1_parents[] __initconst = { 628 + static const char * const ifr_mux1_parents[] = { 629 629 "clk26m_ck", 630 630 "armpll", 631 631 "univpll", 632 632 "mainpll_d2" 633 633 }; 634 634 635 - static const char * const ifr_eth_25m_parents[] __initconst = { 635 + static const char * const ifr_eth_25m_parents[] = { 636 636 "eth_d2_ck", 637 637 "rg_eth" 638 638 }; 639 639 640 - static const char * const ifr_i2c0_parents[] __initconst = { 640 + static const char * const ifr_i2c0_parents[] = { 641 641 "ahb_infra_d2", 642 642 "rg_i2c" 643 643 }; 644 644 645 - static const struct mtk_composite ifr_muxes[] __initconst = { 645 + static const struct mtk_composite ifr_muxes[] = { 646 646 MUX(CLK_IFR_MUX1_SEL, "ifr_mux1_sel", ifr_mux1_parents, 0x000, 647 647 2, 2), 648 648 MUX(CLK_IFR_ETH_25M_SEL, "ifr_eth_25m_sel", ifr_eth_25m_parents, 0x080, ··· 685 685 0x0078, 0, 8), 686 686 }; 687 687 688 - #define DIV_ADJ_FLAG(_id, _name, _parent, _reg, _shift, _width, _flag) { \ 689 - .id = _id, \ 690 - .name = _name, \ 691 - .parent_name = _parent, \ 692 - .div_reg = _reg, \ 693 - .div_shift = _shift, \ 694 - .div_width = _width, \ 695 - .clk_divider_flags = _flag, \ 696 - } 697 - 698 - static const struct mtk_clk_divider apmixed_adj_divs[] = { 699 - DIV_ADJ_FLAG(CLK_APMIXED_HDMI_REF, "hdmi_ref", "tvdpll", 700 - 0x1c4, 24, 3, CLK_DIVIDER_POWER_OF_TWO), 701 - }; 702 - 703 688 static const struct mtk_gate_regs top0_cg_regs = { 704 689 .set_ofs = 0x50, 705 690 .clr_ofs = 0x80, ··· 721 736 .sta_ofs = 0x44, 722 737 }; 723 738 724 - #define GATE_TOP0(_id, _name, _parent, _shift) { \ 725 - .id = _id, \ 726 - .name = _name, \ 727 - .parent_name = _parent, \ 728 - .regs = &top0_cg_regs, \ 729 - .shift = _shift, \ 730 - .ops = &mtk_clk_gate_ops_setclr, \ 731 - } 739 + #define GATE_TOP0(_id, _name, _parent, _shift) \ 740 + GATE_MTK(_id, _name, _parent, &top0_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 732 741 733 - #define GATE_TOP0_I(_id, _name, _parent, _shift) { \ 734 - .id = _id, \ 735 - .name = _name, \ 736 - .parent_name = _parent, \ 737 - .regs = &top0_cg_regs, \ 738 - .shift = _shift, \ 739 - .ops = &mtk_clk_gate_ops_setclr_inv, \ 740 - } 742 + #define GATE_TOP0_I(_id, _name, _parent, _shift) \ 743 + GATE_MTK(_id, _name, _parent, &top0_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv) 741 744 742 - #define GATE_TOP1(_id, _name, _parent, _shift) { \ 743 - .id = _id, \ 744 - .name = _name, \ 745 - .parent_name = _parent, \ 746 - .regs = &top1_cg_regs, \ 747 - .shift = _shift, \ 748 - .ops = &mtk_clk_gate_ops_setclr, \ 749 - } 745 + #define GATE_TOP1(_id, _name, _parent, _shift) \ 746 + GATE_MTK(_id, _name, _parent, &top1_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 750 747 751 - #define GATE_TOP2(_id, _name, _parent, _shift) { \ 752 - .id = _id, \ 753 - .name = _name, \ 754 - .parent_name = _parent, \ 755 - .regs = &top2_cg_regs, \ 756 - .shift = _shift, \ 757 - .ops = &mtk_clk_gate_ops_setclr, \ 758 - } 748 + #define GATE_TOP2(_id, _name, _parent, _shift) \ 749 + GATE_MTK(_id, _name, _parent, &top2_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 759 750 760 - #define GATE_TOP2_I(_id, _name, _parent, _shift) { \ 761 - .id = _id, \ 762 - .name = _name, \ 763 - .parent_name = _parent, \ 764 - .regs = &top2_cg_regs, \ 765 - .shift = _shift, \ 766 - .ops = &mtk_clk_gate_ops_setclr_inv, \ 767 - } 751 + #define GATE_TOP2_I(_id, _name, _parent, _shift) \ 752 + GATE_MTK(_id, _name, _parent, &top2_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv) 768 753 769 - #define GATE_TOP3(_id, _name, _parent, _shift) { \ 770 - .id = _id, \ 771 - .name = _name, \ 772 - .parent_name = _parent, \ 773 - .regs = &top3_cg_regs, \ 774 - .shift = _shift, \ 775 - .ops = &mtk_clk_gate_ops_setclr, \ 776 - } 754 + #define GATE_TOP3(_id, _name, _parent, _shift) \ 755 + GATE_MTK(_id, _name, _parent, &top3_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 777 756 778 - #define GATE_TOP4_I(_id, _name, _parent, _shift) { \ 779 - .id = _id, \ 780 - .name = _name, \ 781 - .parent_name = _parent, \ 782 - .regs = &top4_cg_regs, \ 783 - .shift = _shift, \ 784 - .ops = &mtk_clk_gate_ops_setclr_inv, \ 785 - } 757 + #define GATE_TOP4_I(_id, _name, _parent, _shift) \ 758 + GATE_MTK(_id, _name, _parent, &top4_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv) 786 759 787 - #define GATE_TOP5(_id, _name, _parent, _shift) { \ 788 - .id = _id, \ 789 - .name = _name, \ 790 - .parent_name = _parent, \ 791 - .regs = &top5_cg_regs, \ 792 - .shift = _shift, \ 793 - .ops = &mtk_clk_gate_ops_no_setclr, \ 794 - } 760 + #define GATE_TOP5(_id, _name, _parent, _shift) \ 761 + GATE_MTK(_id, _name, _parent, &top5_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr) 795 762 796 - static const struct mtk_gate top_clks[] __initconst = { 763 + static const struct mtk_gate top_clks[] = { 797 764 /* TOP0 */ 798 765 GATE_TOP0(CLK_TOP_PWM_MM, "pwm_mm", "pwm_mm_sel", 0), 799 766 GATE_TOP0(CLK_TOP_CAM_MM, "cam_mm", "camtg_mm_sel", 1), ··· 858 921 GATE_TOP5(CLK_TOP_APLL12_DIV6, "apll12_div6", "apll12_ck_div6", 8), 859 922 }; 860 923 861 - static void __init mtk_topckgen_init(struct device_node *node) 862 - { 863 - struct clk_hw_onecell_data *clk_data; 864 - int r; 865 - void __iomem *base; 866 - 867 - base = of_iomap(node, 0); 868 - if (!base) { 869 - pr_err("%s(): ioremap failed\n", __func__); 870 - return; 871 - } 872 - 873 - clk_data = mtk_alloc_clk_data(MT8167_CLK_TOP_NR_CLK); 874 - 875 - mtk_clk_register_fixed_clks(fixed_clks, ARRAY_SIZE(fixed_clks), 876 - clk_data); 877 - mtk_clk_register_gates(NULL, node, top_clks, ARRAY_SIZE(top_clks), clk_data); 878 - 879 - mtk_clk_register_factors(top_divs, ARRAY_SIZE(top_divs), clk_data); 880 - mtk_clk_register_composites(NULL, top_muxes, 881 - ARRAY_SIZE(top_muxes), base, 882 - &mt8167_clk_lock, clk_data); 883 - mtk_clk_register_dividers(top_adj_divs, ARRAY_SIZE(top_adj_divs), 884 - base, &mt8167_clk_lock, clk_data); 885 - 886 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 887 - if (r) 888 - pr_err("%s(): could not register clock provider: %d\n", 889 - __func__, r); 890 - } 891 - CLK_OF_DECLARE(mtk_topckgen, "mediatek,mt8167-topckgen", mtk_topckgen_init); 892 - 893 - static void __init mtk_infracfg_init(struct device_node *node) 894 - { 895 - struct clk_hw_onecell_data *clk_data; 896 - int r; 897 - void __iomem *base; 898 - 899 - base = of_iomap(node, 0); 900 - if (!base) { 901 - pr_err("%s(): ioremap failed\n", __func__); 902 - return; 903 - } 904 - 905 - clk_data = mtk_alloc_clk_data(CLK_IFR_NR_CLK); 906 - 907 - mtk_clk_register_composites(NULL, ifr_muxes, 908 - ARRAY_SIZE(ifr_muxes), base, 909 - &mt8167_clk_lock, clk_data); 910 - 911 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 912 - if (r) 913 - pr_err("%s(): could not register clock provider: %d\n", 914 - __func__, r); 915 - } 916 - CLK_OF_DECLARE(mtk_infracfg, "mediatek,mt8167-infracfg", mtk_infracfg_init); 917 - 918 - #define MT8167_PLL_FMAX (2500UL * MHZ) 919 - 920 - #define CON0_MT8167_RST_BAR BIT(27) 921 - 922 - #define PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits, \ 923 - _pd_reg, _pd_shift, _tuner_reg, _pcw_reg, \ 924 - _pcw_shift, _div_table) { \ 925 - .id = _id, \ 926 - .name = _name, \ 927 - .reg = _reg, \ 928 - .pwr_reg = _pwr_reg, \ 929 - .en_mask = _en_mask, \ 930 - .flags = _flags, \ 931 - .rst_bar_mask = CON0_MT8167_RST_BAR, \ 932 - .fmax = MT8167_PLL_FMAX, \ 933 - .pcwbits = _pcwbits, \ 934 - .pd_reg = _pd_reg, \ 935 - .pd_shift = _pd_shift, \ 936 - .tuner_reg = _tuner_reg, \ 937 - .pcw_reg = _pcw_reg, \ 938 - .pcw_shift = _pcw_shift, \ 939 - .div_table = _div_table, \ 940 - } 941 - 942 - #define PLL(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits, \ 943 - _pd_reg, _pd_shift, _tuner_reg, _pcw_reg, \ 944 - _pcw_shift) \ 945 - PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits, \ 946 - _pd_reg, _pd_shift, _tuner_reg, _pcw_reg, _pcw_shift, \ 947 - NULL) 948 - 949 - static const struct mtk_pll_div_table mmpll_div_table[] = { 950 - { .div = 0, .freq = MT8167_PLL_FMAX }, 951 - { .div = 1, .freq = 1000000000 }, 952 - { .div = 2, .freq = 604500000 }, 953 - { .div = 3, .freq = 253500000 }, 954 - { .div = 4, .freq = 126750000 }, 955 - { } /* sentinel */ 924 + static const struct mtk_clk_desc topck_desc = { 925 + .clks = top_clks, 926 + .num_clks = ARRAY_SIZE(top_clks), 927 + .fixed_clks = fixed_clks, 928 + .num_fixed_clks = ARRAY_SIZE(fixed_clks), 929 + .factor_clks = top_divs, 930 + .num_factor_clks = ARRAY_SIZE(top_divs), 931 + .composite_clks = top_muxes, 932 + .num_composite_clks = ARRAY_SIZE(top_muxes), 933 + .divider_clks = top_adj_divs, 934 + .num_divider_clks = ARRAY_SIZE(top_adj_divs), 935 + .clk_lock = &mt8167_clk_lock, 956 936 }; 957 937 958 - static const struct mtk_pll_data plls[] = { 959 - PLL(CLK_APMIXED_ARMPLL, "armpll", 0x0100, 0x0110, 0, 0, 960 - 21, 0x0104, 24, 0, 0x0104, 0), 961 - PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0120, 0x0130, 0, 962 - HAVE_RST_BAR, 21, 0x0124, 24, 0, 0x0124, 0), 963 - PLL(CLK_APMIXED_UNIVPLL, "univpll", 0x0140, 0x0150, 0x30000000, 964 - HAVE_RST_BAR, 7, 0x0144, 24, 0, 0x0144, 0), 965 - PLL_B(CLK_APMIXED_MMPLL, "mmpll", 0x0160, 0x0170, 0, 0, 966 - 21, 0x0164, 24, 0, 0x0164, 0, mmpll_div_table), 967 - PLL(CLK_APMIXED_APLL1, "apll1", 0x0180, 0x0190, 0, 0, 968 - 31, 0x0180, 1, 0x0194, 0x0184, 0), 969 - PLL(CLK_APMIXED_APLL2, "apll2", 0x01A0, 0x01B0, 0, 0, 970 - 31, 0x01A0, 1, 0x01B4, 0x01A4, 0), 971 - PLL(CLK_APMIXED_TVDPLL, "tvdpll", 0x01C0, 0x01D0, 0, 0, 972 - 21, 0x01C4, 24, 0, 0x01C4, 0), 973 - PLL(CLK_APMIXED_LVDSPLL, "lvdspll", 0x01E0, 0x01F0, 0, 0, 974 - 21, 0x01E4, 24, 0, 0x01E4, 0), 938 + static const struct mtk_clk_desc infra_desc = { 939 + .composite_clks = ifr_muxes, 940 + .num_composite_clks = ARRAY_SIZE(ifr_muxes), 941 + .clk_lock = &mt8167_clk_lock, 975 942 }; 976 943 977 - static void __init mtk_apmixedsys_init(struct device_node *node) 978 - { 979 - struct clk_hw_onecell_data *clk_data; 980 - void __iomem *base; 981 - int r; 944 + static const struct of_device_id of_match_clk_mt8167[] = { 945 + { .compatible = "mediatek,mt8167-topckgen", .data = &topck_desc }, 946 + { .compatible = "mediatek,mt8167-infracfg", .data = &infra_desc }, 947 + { /* sentinel */ } 948 + }; 949 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8167); 982 950 983 - base = of_iomap(node, 0); 984 - if (!base) { 985 - pr_err("%s(): ioremap failed\n", __func__); 986 - return; 987 - } 988 - 989 - clk_data = mtk_alloc_clk_data(MT8167_CLK_APMIXED_NR_CLK); 990 - 991 - mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data); 992 - mtk_clk_register_dividers(apmixed_adj_divs, ARRAY_SIZE(apmixed_adj_divs), 993 - base, &mt8167_clk_lock, clk_data); 994 - 995 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 996 - if (r) 997 - pr_err("%s(): could not register clock provider: %d\n", 998 - __func__, r); 999 - 1000 - } 1001 - CLK_OF_DECLARE(mtk_apmixedsys, "mediatek,mt8167-apmixedsys", 1002 - mtk_apmixedsys_init); 951 + static struct platform_driver clk_mt8167_drv = { 952 + .probe = mtk_clk_simple_probe, 953 + .remove = mtk_clk_simple_remove, 954 + .driver = { 955 + .name = "clk-mt8167", 956 + .of_match_table = of_match_clk_mt8167, 957 + }, 958 + }; 959 + module_platform_driver(clk_mt8167_drv); 960 + MODULE_LICENSE("GPL");
+63 -3
drivers/clk/mediatek/clk-mt8173-apmixedsys.c
··· 9 9 #include <linux/of_address.h> 10 10 #include <linux/module.h> 11 11 #include <linux/platform_device.h> 12 + #include "clk-fhctl.h" 12 13 #include "clk-mtk.h" 13 14 #include "clk-pll.h" 15 + #include "clk-pllfh.h" 14 16 15 17 #define REGOFF_REF2USB 0x8 16 18 #define REGOFF_HDMI_REF 0x40 ··· 79 77 PLL(CLK_APMIXED_MSDCPLL2, "msdcpll2", 0x2f0, 0x2fc, 0, 0, 21, 0x2f0, 4, 0x0, 0x2f4, 0), 80 78 }; 81 79 80 + enum fh_pll_id { 81 + FH_ARMCA7PLL, 82 + FH_ARMCA15PLL, 83 + FH_MAINPLL, 84 + FH_MPLL, 85 + FH_MSDCPLL, 86 + FH_MMPLL, 87 + FH_VENCPLL, 88 + FH_TVDPLL, 89 + FH_VCODECPLL, 90 + FH_LVDSPLL, 91 + FH_MSDC2PLL, 92 + FH_NR_FH, 93 + }; 94 + 95 + #define FH(_pllid, _fhid, _offset) { \ 96 + .data = { \ 97 + .pll_id = _pllid, \ 98 + .fh_id = _fhid, \ 99 + .fh_ver = FHCTL_PLLFH_V1, \ 100 + .fhx_offset = _offset, \ 101 + .dds_mask = GENMASK(21, 0), \ 102 + .slope0_value = 0x6003c97, \ 103 + .slope1_value = 0x6003c97, \ 104 + .sfstrx_en = BIT(2), \ 105 + .frddsx_en = BIT(1), \ 106 + .fhctlx_en = BIT(0), \ 107 + .tgl_org = BIT(31), \ 108 + .dvfs_tri = BIT(31), \ 109 + .pcwchg = BIT(31), \ 110 + .dt_val = 0x0, \ 111 + .df_val = 0x9, \ 112 + .updnlmt_shft = 16, \ 113 + .msk_frddsx_dys = GENMASK(23, 20), \ 114 + .msk_frddsx_dts = GENMASK(19, 16), \ 115 + }, \ 116 + } 117 + 118 + static struct mtk_pllfh_data pllfhs[] = { 119 + FH(CLK_APMIXED_ARMCA7PLL, FH_ARMCA7PLL, 0x38), 120 + FH(CLK_APMIXED_ARMCA15PLL, FH_ARMCA15PLL, 0x4c), 121 + FH(CLK_APMIXED_MAINPLL, FH_MAINPLL, 0x60), 122 + FH(CLK_APMIXED_MPLL, FH_MPLL, 0x74), 123 + FH(CLK_APMIXED_MSDCPLL, FH_MSDCPLL, 0x88), 124 + FH(CLK_APMIXED_MMPLL, FH_MMPLL, 0x9c), 125 + FH(CLK_APMIXED_VENCPLL, FH_VENCPLL, 0xb0), 126 + FH(CLK_APMIXED_TVDPLL, FH_TVDPLL, 0xc4), 127 + FH(CLK_APMIXED_VCODECPLL, FH_VCODECPLL, 0xd8), 128 + FH(CLK_APMIXED_LVDSPLL, FH_LVDSPLL, 0xec), 129 + FH(CLK_APMIXED_MSDCPLL2, FH_MSDC2PLL, 0x100), 130 + }; 131 + 82 132 static const struct of_device_id of_match_clk_mt8173_apmixed[] = { 83 133 { .compatible = "mediatek,mt8173-apmixedsys" }, 84 134 { /* sentinel */ } 85 135 }; 136 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8173_apmixed); 86 137 87 138 static int clk_mt8173_apmixed_probe(struct platform_device *pdev) 88 139 { 140 + const u8 *fhctl_node = "mediatek,mt8173-fhctl"; 89 141 struct device_node *node = pdev->dev.of_node; 90 142 struct clk_hw_onecell_data *clk_data; 91 143 void __iomem *base; ··· 154 98 if (IS_ERR_OR_NULL(clk_data)) 155 99 return -ENOMEM; 156 100 157 - r = mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data); 101 + fhctl_parse_dt(fhctl_node, pllfhs, ARRAY_SIZE(pllfhs)); 102 + r = mtk_clk_register_pllfhs(node, plls, ARRAY_SIZE(plls), 103 + pllfhs, ARRAY_SIZE(pllfhs), clk_data); 158 104 if (r) 159 105 goto free_clk_data; 160 106 ··· 182 124 unregister_ref2usb: 183 125 mtk_clk_unregister_ref2usb_tx(clk_data->hws[CLK_APMIXED_REF2USB_TX]); 184 126 unregister_plls: 185 - mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data); 127 + mtk_clk_unregister_pllfhs(plls, ARRAY_SIZE(plls), pllfhs, 128 + ARRAY_SIZE(pllfhs), clk_data); 186 129 free_clk_data: 187 130 mtk_free_clk_data(clk_data); 188 131 return r; ··· 196 137 197 138 of_clk_del_provider(node); 198 139 mtk_clk_unregister_ref2usb_tx(clk_data->hws[CLK_APMIXED_REF2USB_TX]); 199 - mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data); 140 + mtk_clk_unregister_pllfhs(plls, ARRAY_SIZE(plls), pllfhs, 141 + ARRAY_SIZE(pllfhs), clk_data); 200 142 mtk_free_clk_data(clk_data); 201 143 202 144 return 0;
+1
drivers/clk/mediatek/clk-mt8173-img.c
··· 40 40 { .compatible = "mediatek,mt8173-imgsys", .data = &img_desc }, 41 41 { /* sentinel */ } 42 42 }; 43 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8173_imgsys); 43 44 44 45 static struct platform_driver clk_mt8173_vdecsys_drv = { 45 46 .probe = mtk_clk_simple_probe,
+1
drivers/clk/mediatek/clk-mt8173-infracfg.c
··· 74 74 { .compatible = "mediatek,mt8173-infracfg" }, 75 75 { /* sentinel */ } 76 76 }; 77 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8173_infracfg); 77 78 78 79 static void clk_mt8173_infra_init_early(struct device_node *node) 79 80 {
+16 -66
drivers/clk/mediatek/clk-mt8173-mm.c
··· 25 25 .sta_ofs = 0x0110, 26 26 }; 27 27 28 - #define GATE_MM0(_id, _name, _parent, _shift) { \ 29 - .id = _id, \ 30 - .name = _name, \ 31 - .parent_name = _parent, \ 32 - .regs = &mm0_cg_regs, \ 33 - .shift = _shift, \ 34 - .ops = &mtk_clk_gate_ops_setclr, \ 35 - } 28 + #define GATE_MM0(_id, _name, _parent, _shift) \ 29 + GATE_MTK(_id, _name, _parent, &mm0_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 36 30 37 - #define GATE_MM1(_id, _name, _parent, _shift) { \ 38 - .id = _id, \ 39 - .name = _name, \ 40 - .parent_name = _parent, \ 41 - .regs = &mm1_cg_regs, \ 42 - .shift = _shift, \ 43 - .ops = &mtk_clk_gate_ops_setclr, \ 44 - } 31 + #define GATE_MM1(_id, _name, _parent, _shift) \ 32 + GATE_MTK(_id, _name, _parent, &mm1_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 45 33 46 34 static const struct mtk_gate mt8173_mm_clks[] = { 35 + GATE_DUMMY(CLK_DUMMY, "mm_dummy"), 47 36 /* MM0 */ 48 37 GATE_MM0(CLK_MM_SMI_COMMON, "mm_smi_common", "mm_sel", 0), 49 38 GATE_MM0(CLK_MM_SMI_LARB0, "mm_smi_larb0", "mm_sel", 1), ··· 89 100 GATE_MM1(CLK_MM_HDMI_HDCP24M, "mm_hdmi_hdcp24m", "hdcp_24m_sel", 20), 90 101 }; 91 102 92 - struct clk_mt8173_mm_driver_data { 93 - const struct mtk_gate *gates_clk; 94 - int gates_num; 103 + static const struct mtk_clk_desc mm_desc = { 104 + .clks = mt8173_mm_clks, 105 + .num_clks = ARRAY_SIZE(mt8173_mm_clks), 95 106 }; 96 107 97 - static const struct clk_mt8173_mm_driver_data mt8173_mmsys_driver_data = { 98 - .gates_clk = mt8173_mm_clks, 99 - .gates_num = ARRAY_SIZE(mt8173_mm_clks), 108 + static const struct platform_device_id clk_mt8173_mm_id_table[] = { 109 + { .name = "clk-mt8173-mm", .driver_data = (kernel_ulong_t)&mm_desc }, 110 + { /* sentinel */ } 100 111 }; 101 - 102 - static int clk_mt8173_mm_probe(struct platform_device *pdev) 103 - { 104 - struct device *dev = &pdev->dev; 105 - struct device_node *node = dev->parent->of_node; 106 - const struct clk_mt8173_mm_driver_data *data; 107 - struct clk_hw_onecell_data *clk_data; 108 - int ret; 109 - 110 - clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK); 111 - if (!clk_data) 112 - return -ENOMEM; 113 - 114 - data = &mt8173_mmsys_driver_data; 115 - 116 - ret = mtk_clk_register_gates(&pdev->dev, node, data->gates_clk, 117 - data->gates_num, clk_data); 118 - if (ret) 119 - return ret; 120 - 121 - ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 122 - if (ret) 123 - return ret; 124 - 125 - return 0; 126 - } 127 - 128 - static int clk_mt8173_mm_remove(struct platform_device *pdev) 129 - { 130 - struct device *dev = &pdev->dev; 131 - struct device_node *node = dev->parent->of_node; 132 - struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev); 133 - const struct clk_mt8173_mm_driver_data *data = &mt8173_mmsys_driver_data; 134 - 135 - of_clk_del_provider(node); 136 - mtk_clk_unregister_gates(data->gates_clk, data->gates_num, clk_data); 137 - mtk_free_clk_data(clk_data); 138 - 139 - return 0; 140 - } 112 + MODULE_DEVICE_TABLE(platform, clk_mt8173_mm_id_table); 141 113 142 114 static struct platform_driver clk_mt8173_mm_drv = { 143 115 .driver = { 144 116 .name = "clk-mt8173-mm", 145 117 }, 146 - .probe = clk_mt8173_mm_probe, 147 - .remove = clk_mt8173_mm_remove, 118 + .id_table = clk_mt8173_mm_id_table, 119 + .probe = mtk_clk_pdev_probe, 120 + .remove = mtk_clk_pdev_remove, 148 121 }; 149 - 150 - builtin_platform_driver(clk_mt8173_mm_drv); 122 + module_platform_driver(clk_mt8173_mm_drv); 151 123 152 124 MODULE_DESCRIPTION("MediaTek MT8173 MultiMedia clocks driver"); 153 125 MODULE_LICENSE("GPL");
+1
drivers/clk/mediatek/clk-mt8173-pericfg.c
··· 107 107 { .compatible = "mediatek,mt8173-pericfg", .data = &peri_desc }, 108 108 { /* sentinel */ } 109 109 }; 110 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8173_pericfg); 110 111 111 112 static struct platform_driver clk_mt8173_pericfg_drv = { 112 113 .driver = {
+1
drivers/clk/mediatek/clk-mt8173-topckgen.c
··· 638 638 { .compatible = "mediatek,mt8173-topckgen", .data = &topck_desc }, 639 639 { /* sentinel */ } 640 640 }; 641 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8173_topckgen); 641 642 642 643 static struct platform_driver clk_mt8173_topckgen_drv = { 643 644 .driver = {
+1
drivers/clk/mediatek/clk-mt8173-vdecsys.c
··· 42 42 { .compatible = "mediatek,mt8173-vdecsys", .data = &vdec_desc }, 43 43 { /* sentinel */ } 44 44 }; 45 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8173_vdecsys); 45 46 46 47 static struct platform_driver clk_mt8173_vdecsys_drv = { 47 48 .probe = mtk_clk_simple_probe,
+1
drivers/clk/mediatek/clk-mt8173-vencsys.c
··· 49 49 { .compatible = "mediatek,mt8173-vencltsys", .data = &venc_lt_desc }, 50 50 { /* sentinel */ } 51 51 }; 52 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8173_vencsys); 52 53 53 54 static struct platform_driver clk_mt8173_vencsys_drv = { 54 55 .driver = {
+195
drivers/clk/mediatek/clk-mt8183-apmixedsys.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Copyright (c) 2018 MediaTek Inc. 4 + * Weiyi Lu <weiyi.lu@mediatek.com> 5 + * Copyright (c) 2023 Collabora, Ltd. 6 + * AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> 7 + */ 8 + 9 + #include <dt-bindings/clock/mt8183-clk.h> 10 + #include <linux/clk.h> 11 + #include <linux/of.h> 12 + #include <linux/platform_device.h> 13 + 14 + #include "clk-gate.h" 15 + #include "clk-mtk.h" 16 + #include "clk-pll.h" 17 + 18 + static const struct mtk_gate_regs apmixed_cg_regs = { 19 + .set_ofs = 0x20, 20 + .clr_ofs = 0x20, 21 + .sta_ofs = 0x20, 22 + }; 23 + 24 + #define GATE_APMIXED_FLAGS(_id, _name, _parent, _shift, _flags) \ 25 + GATE_MTK_FLAGS(_id, _name, _parent, &apmixed_cg_regs, \ 26 + _shift, &mtk_clk_gate_ops_no_setclr_inv, _flags) 27 + 28 + #define GATE_APMIXED(_id, _name, _parent, _shift) \ 29 + GATE_APMIXED_FLAGS(_id, _name, _parent, _shift, 0) 30 + 31 + /* 32 + * CRITICAL CLOCK: 33 + * apmixed_appll26m is the toppest clock gate of all PLLs. 34 + */ 35 + static const struct mtk_gate apmixed_clks[] = { 36 + /* AUDIO0 */ 37 + GATE_APMIXED(CLK_APMIXED_SSUSB_26M, "apmixed_ssusb26m", "f_f26m_ck", 4), 38 + GATE_APMIXED_FLAGS(CLK_APMIXED_APPLL_26M, "apmixed_appll26m", 39 + "f_f26m_ck", 5, CLK_IS_CRITICAL), 40 + GATE_APMIXED(CLK_APMIXED_MIPIC0_26M, "apmixed_mipic026m", "f_f26m_ck", 6), 41 + GATE_APMIXED(CLK_APMIXED_MDPLLGP_26M, "apmixed_mdpll26m", "f_f26m_ck", 7), 42 + GATE_APMIXED(CLK_APMIXED_MMSYS_26M, "apmixed_mmsys26m", "f_f26m_ck", 8), 43 + GATE_APMIXED(CLK_APMIXED_UFS_26M, "apmixed_ufs26m", "f_f26m_ck", 9), 44 + GATE_APMIXED(CLK_APMIXED_MIPIC1_26M, "apmixed_mipic126m", "f_f26m_ck", 11), 45 + GATE_APMIXED(CLK_APMIXED_MEMPLL_26M, "apmixed_mempll26m", "f_f26m_ck", 13), 46 + GATE_APMIXED(CLK_APMIXED_CLKSQ_LVPLL_26M, "apmixed_lvpll26m", "f_f26m_ck", 14), 47 + GATE_APMIXED(CLK_APMIXED_MIPID0_26M, "apmixed_mipid026m", "f_f26m_ck", 16), 48 + GATE_APMIXED(CLK_APMIXED_MIPID1_26M, "apmixed_mipid126m", "f_f26m_ck", 17), 49 + }; 50 + 51 + #define MT8183_PLL_FMAX (3800UL * MHZ) 52 + #define MT8183_PLL_FMIN (1500UL * MHZ) 53 + 54 + #define PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags, \ 55 + _rst_bar_mask, _pcwbits, _pcwibits, _pd_reg, \ 56 + _pd_shift, _tuner_reg, _tuner_en_reg, \ 57 + _tuner_en_bit, _pcw_reg, _pcw_shift, \ 58 + _pcw_chg_reg, _div_table) { \ 59 + .id = _id, \ 60 + .name = _name, \ 61 + .reg = _reg, \ 62 + .pwr_reg = _pwr_reg, \ 63 + .en_mask = _en_mask, \ 64 + .flags = _flags, \ 65 + .rst_bar_mask = _rst_bar_mask, \ 66 + .fmax = MT8183_PLL_FMAX, \ 67 + .fmin = MT8183_PLL_FMIN, \ 68 + .pcwbits = _pcwbits, \ 69 + .pcwibits = _pcwibits, \ 70 + .pd_reg = _pd_reg, \ 71 + .pd_shift = _pd_shift, \ 72 + .tuner_reg = _tuner_reg, \ 73 + .tuner_en_reg = _tuner_en_reg, \ 74 + .tuner_en_bit = _tuner_en_bit, \ 75 + .pcw_reg = _pcw_reg, \ 76 + .pcw_shift = _pcw_shift, \ 77 + .pcw_chg_reg = _pcw_chg_reg, \ 78 + .div_table = _div_table, \ 79 + } 80 + 81 + #define PLL(_id, _name, _reg, _pwr_reg, _en_mask, _flags, \ 82 + _rst_bar_mask, _pcwbits, _pcwibits, _pd_reg, \ 83 + _pd_shift, _tuner_reg, _tuner_en_reg, \ 84 + _tuner_en_bit, _pcw_reg, _pcw_shift, \ 85 + _pcw_chg_reg) \ 86 + PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags, \ 87 + _rst_bar_mask, _pcwbits, _pcwibits, _pd_reg, \ 88 + _pd_shift, _tuner_reg, _tuner_en_reg, \ 89 + _tuner_en_bit, _pcw_reg, _pcw_shift, \ 90 + _pcw_chg_reg, NULL) 91 + 92 + static const struct mtk_pll_div_table armpll_div_table[] = { 93 + { .div = 0, .freq = MT8183_PLL_FMAX }, 94 + { .div = 1, .freq = 1500 * MHZ }, 95 + { .div = 2, .freq = 750 * MHZ }, 96 + { .div = 3, .freq = 375 * MHZ }, 97 + { .div = 4, .freq = 187500000 }, 98 + { /* sentinel */ } 99 + }; 100 + 101 + static const struct mtk_pll_div_table mfgpll_div_table[] = { 102 + { .div = 0, .freq = MT8183_PLL_FMAX }, 103 + { .div = 1, .freq = 1600 * MHZ }, 104 + { .div = 2, .freq = 800 * MHZ }, 105 + { .div = 3, .freq = 400 * MHZ }, 106 + { .div = 4, .freq = 200 * MHZ }, 107 + { /* sentinel */ } 108 + }; 109 + 110 + static const struct mtk_pll_data plls[] = { 111 + PLL_B(CLK_APMIXED_ARMPLL_LL, "armpll_ll", 0x0200, 0x020C, 0, 112 + HAVE_RST_BAR | PLL_AO, BIT(24), 22, 8, 0x0204, 24, 0x0, 0x0, 0, 113 + 0x0204, 0, 0, armpll_div_table), 114 + PLL_B(CLK_APMIXED_ARMPLL_L, "armpll_l", 0x0210, 0x021C, 0, 115 + HAVE_RST_BAR | PLL_AO, BIT(24), 22, 8, 0x0214, 24, 0x0, 0x0, 0, 116 + 0x0214, 0, 0, armpll_div_table), 117 + PLL(CLK_APMIXED_CCIPLL, "ccipll", 0x0290, 0x029C, 0, 118 + HAVE_RST_BAR | PLL_AO, BIT(24), 22, 8, 0x0294, 24, 0x0, 0x0, 0, 119 + 0x0294, 0, 0), 120 + PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0220, 0x022C, 0, 121 + HAVE_RST_BAR, BIT(24), 22, 8, 0x0224, 24, 0x0, 0x0, 0, 122 + 0x0224, 0, 0), 123 + PLL(CLK_APMIXED_UNIV2PLL, "univ2pll", 0x0230, 0x023C, 0, 124 + HAVE_RST_BAR, BIT(24), 22, 8, 0x0234, 24, 0x0, 0x0, 0, 125 + 0x0234, 0, 0), 126 + PLL_B(CLK_APMIXED_MFGPLL, "mfgpll", 0x0240, 0x024C, 0, 127 + 0, 0, 22, 8, 0x0244, 24, 0x0, 0x0, 0, 0x0244, 0, 0, 128 + mfgpll_div_table), 129 + PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x0250, 0x025C, 0, 130 + 0, 0, 22, 8, 0x0254, 24, 0x0, 0x0, 0, 0x0254, 0, 0), 131 + PLL(CLK_APMIXED_TVDPLL, "tvdpll", 0x0260, 0x026C, 0, 132 + 0, 0, 22, 8, 0x0264, 24, 0x0, 0x0, 0, 0x0264, 0, 0), 133 + PLL(CLK_APMIXED_MMPLL, "mmpll", 0x0270, 0x027C, 0, 134 + HAVE_RST_BAR, BIT(23), 22, 8, 0x0274, 24, 0x0, 0x0, 0, 135 + 0x0274, 0, 0), 136 + PLL(CLK_APMIXED_APLL1, "apll1", 0x02A0, 0x02B0, 0, 137 + 0, 0, 32, 8, 0x02A0, 1, 0x02A8, 0x0014, 0, 0x02A4, 0, 0x02A0), 138 + PLL(CLK_APMIXED_APLL2, "apll2", 0x02b4, 0x02c4, 0, 139 + 0, 0, 32, 8, 0x02B4, 1, 0x02BC, 0x0014, 1, 0x02B8, 0, 0x02B4), 140 + }; 141 + 142 + static int clk_mt8183_apmixed_probe(struct platform_device *pdev) 143 + { 144 + void __iomem *base; 145 + struct clk_hw_onecell_data *clk_data; 146 + struct device_node *node = pdev->dev.of_node; 147 + struct device *dev = &pdev->dev; 148 + int ret; 149 + 150 + base = devm_platform_ioremap_resource(pdev, 0); 151 + if (IS_ERR(base)) 152 + return PTR_ERR(base); 153 + 154 + clk_data = mtk_devm_alloc_clk_data(dev, CLK_APMIXED_NR_CLK); 155 + if (!clk_data) 156 + return -ENOMEM; 157 + 158 + ret = mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data); 159 + if (ret) 160 + return ret; 161 + 162 + ret = mtk_clk_register_gates(&pdev->dev, node, apmixed_clks, 163 + ARRAY_SIZE(apmixed_clks), clk_data); 164 + if (ret) 165 + goto unregister_plls; 166 + 167 + ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 168 + if (ret) 169 + goto unregister_gates; 170 + 171 + return 0; 172 + 173 + unregister_gates: 174 + mtk_clk_unregister_gates(apmixed_clks, ARRAY_SIZE(apmixed_clks), clk_data); 175 + unregister_plls: 176 + mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data); 177 + 178 + return ret; 179 + } 180 + 181 + static const struct of_device_id of_match_clk_mt8183_apmixed[] = { 182 + { .compatible = "mediatek,mt8183-apmixedsys" }, 183 + { /* sentinel */ } 184 + }; 185 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8183_apmixed); 186 + 187 + static struct platform_driver clk_mt8183_apmixed_drv = { 188 + .probe = clk_mt8183_apmixed_probe, 189 + .driver = { 190 + .name = "clk-mt8183-apmixed", 191 + .of_match_table = of_match_clk_mt8183_apmixed, 192 + }, 193 + }; 194 + builtin_platform_driver(clk_mt8183_apmixed_drv) 195 + MODULE_LICENSE("GPL");
+3 -2
drivers/clk/mediatek/clk-mt8183-audio.c
··· 97 97 { .compatible = "mediatek,mt8183-audiosys", .data = &audio_desc }, 98 98 { /* sentinel */ } 99 99 }; 100 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8183_audio); 100 101 101 102 static struct platform_driver clk_mt8183_audio_drv = { 102 103 .probe = clk_mt8183_audio_probe, ··· 107 106 .of_match_table = of_match_clk_mt8183_audio, 108 107 }, 109 108 }; 110 - 111 - builtin_platform_driver(clk_mt8183_audio_drv); 109 + module_platform_driver(clk_mt8183_audio_drv); 110 + MODULE_LICENSE("GPL");
+3 -2
drivers/clk/mediatek/clk-mt8183-cam.c
··· 47 47 /* sentinel */ 48 48 } 49 49 }; 50 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8183_cam); 50 51 51 52 static struct platform_driver clk_mt8183_cam_drv = { 52 53 .probe = mtk_clk_simple_probe, ··· 57 56 .of_match_table = of_match_clk_mt8183_cam, 58 57 }, 59 58 }; 60 - 61 - builtin_platform_driver(clk_mt8183_cam_drv); 59 + module_platform_driver(clk_mt8183_cam_drv); 60 + MODULE_LICENSE("GPL");
+3 -2
drivers/clk/mediatek/clk-mt8183-img.c
··· 47 47 /* sentinel */ 48 48 } 49 49 }; 50 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8183_img); 50 51 51 52 static struct platform_driver clk_mt8183_img_drv = { 52 53 .probe = mtk_clk_simple_probe, ··· 57 56 .of_match_table = of_match_clk_mt8183_img, 58 57 }, 59 58 }; 60 - 61 - builtin_platform_driver(clk_mt8183_img_drv); 59 + module_platform_driver(clk_mt8183_img_drv); 60 + MODULE_LICENSE("GPL");
+3 -2
drivers/clk/mediatek/clk-mt8183-ipu0.c
··· 40 40 /* sentinel */ 41 41 } 42 42 }; 43 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8183_ipu_core0); 43 44 44 45 static struct platform_driver clk_mt8183_ipu_core0_drv = { 45 46 .probe = mtk_clk_simple_probe, ··· 50 49 .of_match_table = of_match_clk_mt8183_ipu_core0, 51 50 }, 52 51 }; 53 - 54 - builtin_platform_driver(clk_mt8183_ipu_core0_drv); 52 + module_platform_driver(clk_mt8183_ipu_core0_drv); 53 + MODULE_LICENSE("GPL");
+3 -2
drivers/clk/mediatek/clk-mt8183-ipu1.c
··· 40 40 /* sentinel */ 41 41 } 42 42 }; 43 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8183_ipu_core1); 43 44 44 45 static struct platform_driver clk_mt8183_ipu_core1_drv = { 45 46 .probe = mtk_clk_simple_probe, ··· 50 49 .of_match_table = of_match_clk_mt8183_ipu_core1, 51 50 }, 52 51 }; 53 - 54 - builtin_platform_driver(clk_mt8183_ipu_core1_drv); 52 + module_platform_driver(clk_mt8183_ipu_core1_drv); 53 + MODULE_LICENSE("GPL");
+3 -2
drivers/clk/mediatek/clk-mt8183-ipu_adl.c
··· 38 38 /* sentinel */ 39 39 } 40 40 }; 41 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8183_ipu_adl); 41 42 42 43 static struct platform_driver clk_mt8183_ipu_adl_drv = { 43 44 .probe = mtk_clk_simple_probe, ··· 48 47 .of_match_table = of_match_clk_mt8183_ipu_adl, 49 48 }, 50 49 }; 51 - 52 - builtin_platform_driver(clk_mt8183_ipu_adl_drv); 50 + module_platform_driver(clk_mt8183_ipu_adl_drv); 51 + MODULE_LICENSE("GPL");
+3 -2
drivers/clk/mediatek/clk-mt8183-ipu_conn.c
··· 107 107 /* sentinel */ 108 108 } 109 109 }; 110 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8183_ipu_conn); 110 111 111 112 static struct platform_driver clk_mt8183_ipu_conn_drv = { 112 113 .probe = mtk_clk_simple_probe, ··· 117 116 .of_match_table = of_match_clk_mt8183_ipu_conn, 118 117 }, 119 118 }; 120 - 121 - builtin_platform_driver(clk_mt8183_ipu_conn_drv); 119 + module_platform_driver(clk_mt8183_ipu_conn_drv); 120 + MODULE_LICENSE("GPL");
+3 -2
drivers/clk/mediatek/clk-mt8183-mfgcfg.c
··· 39 39 /* sentinel */ 40 40 } 41 41 }; 42 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8183_mfg); 42 43 43 44 static struct platform_driver clk_mt8183_mfg_drv = { 44 45 .probe = mtk_clk_simple_probe, ··· 49 48 .of_match_table = of_match_clk_mt8183_mfg, 50 49 }, 51 50 }; 52 - 53 - builtin_platform_driver(clk_mt8183_mfg_drv); 51 + module_platform_driver(clk_mt8183_mfg_drv); 52 + MODULE_LICENSE("GPL");
+14 -15
drivers/clk/mediatek/clk-mt8183-mm.c
··· 82 82 GATE_MM1(CLK_MM_DBI_IF, "mm_dbi_if", "dpi0_sel", 13), 83 83 }; 84 84 85 - static int clk_mt8183_mm_probe(struct platform_device *pdev) 86 - { 87 - struct device *dev = &pdev->dev; 88 - struct device_node *node = dev->parent->of_node; 89 - struct clk_hw_onecell_data *clk_data; 85 + static const struct mtk_clk_desc mm_desc = { 86 + .clks = mm_clks, 87 + .num_clks = ARRAY_SIZE(mm_clks), 88 + }; 90 89 91 - clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK); 92 - 93 - mtk_clk_register_gates(&pdev->dev, node, mm_clks, 94 - ARRAY_SIZE(mm_clks), clk_data); 95 - 96 - return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 97 - } 90 + static const struct platform_device_id clk_mt8183_mm_id_table[] = { 91 + { .name = "clk-mt8183-mm", .driver_data = (kernel_ulong_t)&mm_desc }, 92 + { /* sentinel */ } 93 + }; 94 + MODULE_DEVICE_TABLE(platform, clk_mt8183_mm_id_table); 98 95 99 96 static struct platform_driver clk_mt8183_mm_drv = { 100 - .probe = clk_mt8183_mm_probe, 97 + .probe = mtk_clk_pdev_probe, 98 + .remove = mtk_clk_pdev_remove, 101 99 .driver = { 102 100 .name = "clk-mt8183-mm", 103 101 }, 102 + .id_table = clk_mt8183_mm_id_table, 104 103 }; 105 - 106 - builtin_platform_driver(clk_mt8183_mm_drv); 104 + module_platform_driver(clk_mt8183_mm_drv); 105 + MODULE_LICENSE("GPL");
+3 -2
drivers/clk/mediatek/clk-mt8183-vdec.c
··· 51 51 /* sentinel */ 52 52 } 53 53 }; 54 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8183_vdec); 54 55 55 56 static struct platform_driver clk_mt8183_vdec_drv = { 56 57 .probe = mtk_clk_simple_probe, ··· 61 60 .of_match_table = of_match_clk_mt8183_vdec, 62 61 }, 63 62 }; 64 - 65 - builtin_platform_driver(clk_mt8183_vdec_drv); 63 + module_platform_driver(clk_mt8183_vdec_drv); 64 + MODULE_LICENSE("GPL");
+3 -2
drivers/clk/mediatek/clk-mt8183-venc.c
··· 43 43 /* sentinel */ 44 44 } 45 45 }; 46 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8183_venc); 46 47 47 48 static struct platform_driver clk_mt8183_venc_drv = { 48 49 .probe = mtk_clk_simple_probe, ··· 53 52 .of_match_table = of_match_clk_mt8183_venc, 54 53 }, 55 54 }; 56 - 57 - builtin_platform_driver(clk_mt8183_venc_drv); 55 + module_platform_driver(clk_mt8183_venc_drv); 56 + MODULE_LICENSE("GPL");
+187 -586
drivers/clk/mediatek/clk-mt8183.c
··· 14 14 #include "clk-gate.h" 15 15 #include "clk-mtk.h" 16 16 #include "clk-mux.h" 17 - #include "clk-pll.h" 18 17 19 18 #include <dt-bindings/clock/mt8183-clk.h> 20 19 ··· 25 26 FIXED_CLK(CLK_TOP_UNIVP_192M, "univpll_192m", "univpll", 192000000), 26 27 }; 27 28 28 - static const struct mtk_fixed_factor top_early_divs[] = { 29 - FACTOR(CLK_TOP_CLK13M, "clk13m", "clk26m", 1, 2), 30 - }; 31 - 29 + /* 30 + * To retain compatibility with older devicetrees, we keep CLK_TOP_CLK13M 31 + * valid, but renamed from "clk13m" (defined as fixed clock in the new 32 + * devicetrees) to "clk26m_d2", satisfying the older clock assignments. 33 + * This means that on new devicetrees "clk26m_d2" is unused. 34 + */ 32 35 static const struct mtk_fixed_factor top_divs[] = { 36 + FACTOR(CLK_TOP_CLK13M, "clk26m_d2", "clk26m", 1, 2), 33 37 FACTOR(CLK_TOP_F26M_CK_D2, "csw_f26m_ck_d2", "clk26m", 1, 2), 34 38 FACTOR_FLAGS(CLK_TOP_SYSPLL_CK, "syspll_ck", "mainpll", 1, 1, 0), 35 39 FACTOR_FLAGS(CLK_TOP_SYSPLL_D2, "syspll_d2", "syspll_ck", 1, 2, 0), ··· 451 449 static const struct mtk_mux top_muxes[] = { 452 450 /* CLK_CFG_0 */ 453 451 MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_MUX_AXI, "axi_sel", 454 - axi_parents, 0x40, 455 - 0x44, 0x48, 0, 2, 7, 0x004, 0, CLK_IS_CRITICAL), 452 + axi_parents, 0x40, 0x44, 0x48, 0, 2, 7, 0x004, 0, CLK_IS_CRITICAL), 456 453 MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_MM, "mm_sel", 457 - mm_parents, 0x40, 458 - 0x44, 0x48, 8, 3, 15, 0x004, 1), 454 + mm_parents, 0x40, 0x44, 0x48, 8, 3, 15, 0x004, 1), 459 455 MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_IMG, "img_sel", 460 - img_parents, 0x40, 461 - 0x44, 0x48, 16, 3, 23, 0x004, 2), 456 + img_parents, 0x40, 0x44, 0x48, 16, 3, 23, 0x004, 2), 462 457 MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_CAM, "cam_sel", 463 - cam_parents, 0x40, 464 - 0x44, 0x48, 24, 4, 31, 0x004, 3), 458 + cam_parents, 0x40, 0x44, 0x48, 24, 4, 31, 0x004, 3), 465 459 /* CLK_CFG_1 */ 466 460 MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_DSP, "dsp_sel", 467 - dsp_parents, 0x50, 468 - 0x54, 0x58, 0, 4, 7, 0x004, 4), 461 + dsp_parents, 0x50, 0x54, 0x58, 0, 4, 7, 0x004, 4), 469 462 MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_DSP1, "dsp1_sel", 470 - dsp1_parents, 0x50, 471 - 0x54, 0x58, 8, 4, 15, 0x004, 5), 463 + dsp1_parents, 0x50, 0x54, 0x58, 8, 4, 15, 0x004, 5), 472 464 MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_DSP2, "dsp2_sel", 473 - dsp2_parents, 0x50, 474 - 0x54, 0x58, 16, 4, 23, 0x004, 6), 465 + dsp2_parents, 0x50, 0x54, 0x58, 16, 4, 23, 0x004, 6), 475 466 MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_IPU_IF, "ipu_if_sel", 476 - ipu_if_parents, 0x50, 477 - 0x54, 0x58, 24, 4, 31, 0x004, 7), 467 + ipu_if_parents, 0x50, 0x54, 0x58, 24, 4, 31, 0x004, 7), 478 468 /* CLK_CFG_2 */ 479 469 MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_MFG, "mfg_sel", 480 - mfg_parents, 0x60, 481 - 0x64, 0x68, 0, 2, 7, 0x004, 8), 470 + mfg_parents, 0x60, 0x64, 0x68, 0, 2, 7, 0x004, 8), 482 471 MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_F52M_MFG, "f52m_mfg_sel", 483 - f52m_mfg_parents, 0x60, 484 - 0x64, 0x68, 8, 2, 15, 0x004, 9), 472 + f52m_mfg_parents, 0x60, 0x64, 0x68, 8, 2, 15, 0x004, 9), 485 473 MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_CAMTG, "camtg_sel", 486 - camtg_parents, 0x60, 487 - 0x64, 0x68, 16, 3, 23, 0x004, 10), 474 + camtg_parents, 0x60, 0x64, 0x68, 16, 3, 23, 0x004, 10), 488 475 MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_CAMTG2, "camtg2_sel", 489 - camtg2_parents, 0x60, 490 - 0x64, 0x68, 24, 3, 31, 0x004, 11), 476 + camtg2_parents, 0x60, 0x64, 0x68, 24, 3, 31, 0x004, 11), 491 477 /* CLK_CFG_3 */ 492 478 MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_CAMTG3, "camtg3_sel", 493 - camtg3_parents, 0x70, 494 - 0x74, 0x78, 0, 3, 7, 0x004, 12), 479 + camtg3_parents, 0x70, 0x74, 0x78, 0, 3, 7, 0x004, 12), 495 480 MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_CAMTG4, "camtg4_sel", 496 - camtg4_parents, 0x70, 497 - 0x74, 0x78, 8, 3, 15, 0x004, 13), 481 + camtg4_parents, 0x70, 0x74, 0x78, 8, 3, 15, 0x004, 13), 498 482 MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_UART, "uart_sel", 499 - uart_parents, 0x70, 500 - 0x74, 0x78, 16, 1, 23, 0x004, 14), 483 + uart_parents, 0x70, 0x74, 0x78, 16, 1, 23, 0x004, 14), 501 484 MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_SPI, "spi_sel", 502 - spi_parents, 0x70, 503 - 0x74, 0x78, 24, 2, 31, 0x004, 15), 485 + spi_parents, 0x70, 0x74, 0x78, 24, 2, 31, 0x004, 15), 504 486 /* CLK_CFG_4 */ 505 487 MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_MSDC50_0_HCLK, "msdc50_hclk_sel", 506 - msdc50_hclk_parents, 0x80, 507 - 0x84, 0x88, 0, 2, 7, 0x004, 16), 488 + msdc50_hclk_parents, 0x80, 0x84, 0x88, 0, 2, 7, 0x004, 16), 508 489 MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_MSDC50_0, "msdc50_0_sel", 509 - msdc50_0_parents, 0x80, 510 - 0x84, 0x88, 8, 3, 15, 0x004, 17), 490 + msdc50_0_parents, 0x80, 0x84, 0x88, 8, 3, 15, 0x004, 17), 511 491 MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_MSDC30_1, "msdc30_1_sel", 512 - msdc30_1_parents, 0x80, 513 - 0x84, 0x88, 16, 3, 23, 0x004, 18), 492 + msdc30_1_parents, 0x80, 0x84, 0x88, 16, 3, 23, 0x004, 18), 514 493 MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_MSDC30_2, "msdc30_2_sel", 515 - msdc30_2_parents, 0x80, 516 - 0x84, 0x88, 24, 3, 31, 0x004, 19), 494 + msdc30_2_parents, 0x80, 0x84, 0x88, 24, 3, 31, 0x004, 19), 517 495 /* CLK_CFG_5 */ 518 496 MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_AUDIO, "audio_sel", 519 - audio_parents, 0x90, 520 - 0x94, 0x98, 0, 2, 7, 0x004, 20), 497 + audio_parents, 0x90, 0x94, 0x98, 0, 2, 7, 0x004, 20), 521 498 MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_AUD_INTBUS, "aud_intbus_sel", 522 - aud_intbus_parents, 0x90, 523 - 0x94, 0x98, 8, 2, 15, 0x004, 21), 499 + aud_intbus_parents, 0x90, 0x94, 0x98, 8, 2, 15, 0x004, 21), 524 500 MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_PMICSPI, "pmicspi_sel", 525 - pmicspi_parents, 0x90, 526 - 0x94, 0x98, 16, 2, 23, 0x004, 22), 501 + pmicspi_parents, 0x90, 0x94, 0x98, 16, 2, 23, 0x004, 22), 527 502 MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_FPWRAP_ULPOSC, "fpwrap_ulposc_sel", 528 - fpwrap_ulposc_parents, 0x90, 529 - 0x94, 0x98, 24, 2, 31, 0x004, 23), 503 + fpwrap_ulposc_parents, 0x90, 0x94, 0x98, 24, 2, 31, 0x004, 23), 530 504 /* CLK_CFG_6 */ 531 505 MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_ATB, "atb_sel", 532 - atb_parents, 0xa0, 533 - 0xa4, 0xa8, 0, 2, 7, 0x004, 24), 506 + atb_parents, 0xa0, 0xa4, 0xa8, 0, 2, 7, 0x004, 24), 534 507 MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_DPI0, "dpi0_sel", 535 - dpi0_parents, 0xa0, 536 - 0xa4, 0xa8, 16, 4, 23, 0x004, 26), 508 + dpi0_parents, 0xa0, 0xa4, 0xa8, 16, 4, 23, 0x004, 26), 537 509 MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_SCAM, "scam_sel", 538 - scam_parents, 0xa0, 539 - 0xa4, 0xa8, 24, 1, 31, 0x004, 27), 510 + scam_parents, 0xa0, 0xa4, 0xa8, 24, 1, 31, 0x004, 27), 540 511 /* CLK_CFG_7 */ 541 512 MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_DISP_PWM, "disppwm_sel", 542 - disppwm_parents, 0xb0, 543 - 0xb4, 0xb8, 0, 3, 7, 0x004, 28), 513 + disppwm_parents, 0xb0, 0xb4, 0xb8, 0, 3, 7, 0x004, 28), 544 514 MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_USB_TOP, "usb_top_sel", 545 - usb_top_parents, 0xb0, 546 - 0xb4, 0xb8, 8, 2, 15, 0x004, 29), 515 + usb_top_parents, 0xb0, 0xb4, 0xb8, 8, 2, 15, 0x004, 29), 547 516 MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_SSUSB_TOP_XHCI, "ssusb_top_xhci_sel", 548 - ssusb_top_xhci_parents, 0xb0, 549 - 0xb4, 0xb8, 16, 2, 23, 0x004, 30), 517 + ssusb_top_xhci_parents, 0xb0, 0xb4, 0xb8, 16, 2, 23, 0x004, 30), 550 518 MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_MUX_SPM, "spm_sel", 551 - spm_parents, 0xb0, 552 - 0xb4, 0xb8, 24, 1, 31, 0x008, 0, CLK_IS_CRITICAL), 519 + spm_parents, 0xb0, 0xb4, 0xb8, 24, 1, 31, 0x008, 0, CLK_IS_CRITICAL), 553 520 /* CLK_CFG_8 */ 554 521 MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_I2C, "i2c_sel", 555 - i2c_parents, 0xc0, 556 - 0xc4, 0xc8, 0, 2, 7, 0x008, 1), 522 + i2c_parents, 0xc0, 0xc4, 0xc8, 0, 2, 7, 0x008, 1), 557 523 MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_SCP, "scp_sel", 558 - scp_parents, 0xc0, 559 - 0xc4, 0xc8, 8, 3, 15, 0x008, 2), 524 + scp_parents, 0xc0, 0xc4, 0xc8, 8, 3, 15, 0x008, 2), 560 525 MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_SENINF, "seninf_sel", 561 - seninf_parents, 0xc0, 562 - 0xc4, 0xc8, 16, 2, 23, 0x008, 3), 526 + seninf_parents, 0xc0, 0xc4, 0xc8, 16, 2, 23, 0x008, 3), 563 527 MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_DXCC, "dxcc_sel", 564 - dxcc_parents, 0xc0, 565 - 0xc4, 0xc8, 24, 2, 31, 0x008, 4), 528 + dxcc_parents, 0xc0, 0xc4, 0xc8, 24, 2, 31, 0x008, 4), 566 529 /* CLK_CFG_9 */ 567 530 MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_AUD_ENG1, "aud_eng1_sel", 568 - aud_engen1_parents, 0xd0, 569 - 0xd4, 0xd8, 0, 2, 7, 0x008, 5), 531 + aud_engen1_parents, 0xd0, 0xd4, 0xd8, 0, 2, 7, 0x008, 5), 570 532 MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_AUD_ENG2, "aud_eng2_sel", 571 - aud_engen2_parents, 0xd0, 572 - 0xd4, 0xd8, 8, 2, 15, 0x008, 6), 533 + aud_engen2_parents, 0xd0, 0xd4, 0xd8, 8, 2, 15, 0x008, 6), 573 534 MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_FAES_UFSFDE, "faes_ufsfde_sel", 574 - faes_ufsfde_parents, 0xd0, 575 - 0xd4, 0xd8, 16, 3, 23, 0x008, 7), 535 + faes_ufsfde_parents, 0xd0, 0xd4, 0xd8, 16, 3, 23, 0x008, 7), 576 536 MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_FUFS, "fufs_sel", 577 - fufs_parents, 0xd0, 578 - 0xd4, 0xd8, 24, 2, 31, 0x008, 8), 537 + fufs_parents, 0xd0, 0xd4, 0xd8, 24, 2, 31, 0x008, 8), 579 538 /* CLK_CFG_10 */ 580 539 MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_AUD_1, "aud_1_sel", 581 - aud_1_parents, 0xe0, 582 - 0xe4, 0xe8, 0, 1, 7, 0x008, 9), 540 + aud_1_parents, 0xe0, 0xe4, 0xe8, 0, 1, 7, 0x008, 9), 583 541 MUX_GATE_CLR_SET_UPD(CLK_TOP_MUX_AUD_2, "aud_2_sel", 584 - aud_2_parents, 0xe0, 585 - 0xe4, 0xe8, 8, 1, 15, 0x008, 10), 542 + aud_2_parents, 0xe0, 0xe4, 0xe8, 8, 1, 15, 0x008, 10), 586 543 }; 587 544 588 545 static const char * const apll_i2s0_parents[] = { ··· 605 644 }; 606 645 607 646 static struct mtk_composite top_aud_comp[] = { 608 - MUX(CLK_TOP_MUX_APLL_I2S0, "apll_i2s0_sel", apll_i2s0_parents, 609 - 0x320, 8, 1), 610 - MUX(CLK_TOP_MUX_APLL_I2S1, "apll_i2s1_sel", apll_i2s1_parents, 611 - 0x320, 9, 1), 612 - MUX(CLK_TOP_MUX_APLL_I2S2, "apll_i2s2_sel", apll_i2s2_parents, 613 - 0x320, 10, 1), 614 - MUX(CLK_TOP_MUX_APLL_I2S3, "apll_i2s3_sel", apll_i2s3_parents, 615 - 0x320, 11, 1), 616 - MUX(CLK_TOP_MUX_APLL_I2S4, "apll_i2s4_sel", apll_i2s4_parents, 617 - 0x320, 12, 1), 618 - MUX(CLK_TOP_MUX_APLL_I2S5, "apll_i2s5_sel", apll_i2s5_parents, 619 - 0x328, 20, 1), 620 - DIV_GATE(CLK_TOP_APLL12_DIV0, "apll12_div0", "apll_i2s0_sel", 621 - 0x320, 2, 0x324, 8, 0), 622 - DIV_GATE(CLK_TOP_APLL12_DIV1, "apll12_div1", "apll_i2s1_sel", 623 - 0x320, 3, 0x324, 8, 8), 624 - DIV_GATE(CLK_TOP_APLL12_DIV2, "apll12_div2", "apll_i2s2_sel", 625 - 0x320, 4, 0x324, 8, 16), 626 - DIV_GATE(CLK_TOP_APLL12_DIV3, "apll12_div3", "apll_i2s3_sel", 627 - 0x320, 5, 0x324, 8, 24), 628 - DIV_GATE(CLK_TOP_APLL12_DIV4, "apll12_div4", "apll_i2s4_sel", 629 - 0x320, 6, 0x328, 8, 0), 630 - DIV_GATE(CLK_TOP_APLL12_DIVB, "apll12_divb", "apll12_div4", 631 - 0x320, 7, 0x328, 8, 8), 647 + MUX(CLK_TOP_MUX_APLL_I2S0, "apll_i2s0_sel", apll_i2s0_parents, 0x320, 8, 1), 648 + MUX(CLK_TOP_MUX_APLL_I2S1, "apll_i2s1_sel", apll_i2s1_parents, 0x320, 9, 1), 649 + MUX(CLK_TOP_MUX_APLL_I2S2, "apll_i2s2_sel", apll_i2s2_parents, 0x320, 10, 1), 650 + MUX(CLK_TOP_MUX_APLL_I2S3, "apll_i2s3_sel", apll_i2s3_parents, 0x320, 11, 1), 651 + MUX(CLK_TOP_MUX_APLL_I2S4, "apll_i2s4_sel", apll_i2s4_parents, 0x320, 12, 1), 652 + MUX(CLK_TOP_MUX_APLL_I2S5, "apll_i2s5_sel", apll_i2s5_parents, 0x328, 20, 1), 653 + DIV_GATE(CLK_TOP_APLL12_DIV0, "apll12_div0", "apll_i2s0_sel", 0x320, 2, 0x324, 8, 0), 654 + DIV_GATE(CLK_TOP_APLL12_DIV1, "apll12_div1", "apll_i2s1_sel", 0x320, 3, 0x324, 8, 8), 655 + DIV_GATE(CLK_TOP_APLL12_DIV2, "apll12_div2", "apll_i2s2_sel", 0x320, 4, 0x324, 8, 16), 656 + DIV_GATE(CLK_TOP_APLL12_DIV3, "apll12_div3", "apll_i2s3_sel", 0x320, 5, 0x324, 8, 24), 657 + DIV_GATE(CLK_TOP_APLL12_DIV4, "apll12_div4", "apll_i2s4_sel", 0x320, 6, 0x328, 8, 0), 658 + DIV_GATE(CLK_TOP_APLL12_DIVB, "apll12_divb", "apll12_div4", 0x320, 7, 0x328, 8, 8), 632 659 }; 633 660 634 661 static const struct mtk_gate_regs top_cg_regs = { ··· 677 728 678 729 static const struct mtk_gate infra_clks[] = { 679 730 /* INFRA0 */ 680 - GATE_INFRA0(CLK_INFRA_PMIC_TMR, "infra_pmic_tmr", 681 - "axi_sel", 0), 682 - GATE_INFRA0(CLK_INFRA_PMIC_AP, "infra_pmic_ap", 683 - "axi_sel", 1), 684 - GATE_INFRA0(CLK_INFRA_PMIC_MD, "infra_pmic_md", 685 - "axi_sel", 2), 686 - GATE_INFRA0(CLK_INFRA_PMIC_CONN, "infra_pmic_conn", 687 - "axi_sel", 3), 688 - GATE_INFRA0(CLK_INFRA_SCPSYS, "infra_scp", 689 - "scp_sel", 4), 690 - GATE_INFRA0(CLK_INFRA_SEJ, "infra_sej", 691 - "f_f26m_ck", 5), 692 - GATE_INFRA0(CLK_INFRA_APXGPT, "infra_apxgpt", 693 - "axi_sel", 6), 694 - GATE_INFRA0(CLK_INFRA_ICUSB, "infra_icusb", 695 - "axi_sel", 8), 696 - GATE_INFRA0(CLK_INFRA_GCE, "infra_gce", 697 - "axi_sel", 9), 698 - GATE_INFRA0(CLK_INFRA_THERM, "infra_therm", 699 - "axi_sel", 10), 700 - GATE_INFRA0(CLK_INFRA_I2C0, "infra_i2c0", 701 - "i2c_sel", 11), 702 - GATE_INFRA0(CLK_INFRA_I2C1, "infra_i2c1", 703 - "i2c_sel", 12), 704 - GATE_INFRA0(CLK_INFRA_I2C2, "infra_i2c2", 705 - "i2c_sel", 13), 706 - GATE_INFRA0(CLK_INFRA_I2C3, "infra_i2c3", 707 - "i2c_sel", 14), 708 - GATE_INFRA0(CLK_INFRA_PWM_HCLK, "infra_pwm_hclk", 709 - "axi_sel", 15), 710 - GATE_INFRA0(CLK_INFRA_PWM1, "infra_pwm1", 711 - "i2c_sel", 16), 712 - GATE_INFRA0(CLK_INFRA_PWM2, "infra_pwm2", 713 - "i2c_sel", 17), 714 - GATE_INFRA0(CLK_INFRA_PWM3, "infra_pwm3", 715 - "i2c_sel", 18), 716 - GATE_INFRA0(CLK_INFRA_PWM4, "infra_pwm4", 717 - "i2c_sel", 19), 718 - GATE_INFRA0(CLK_INFRA_PWM, "infra_pwm", 719 - "i2c_sel", 21), 720 - GATE_INFRA0(CLK_INFRA_UART0, "infra_uart0", 721 - "uart_sel", 22), 722 - GATE_INFRA0(CLK_INFRA_UART1, "infra_uart1", 723 - "uart_sel", 23), 724 - GATE_INFRA0(CLK_INFRA_UART2, "infra_uart2", 725 - "uart_sel", 24), 726 - GATE_INFRA0(CLK_INFRA_UART3, "infra_uart3", 727 - "uart_sel", 25), 728 - GATE_INFRA0(CLK_INFRA_GCE_26M, "infra_gce_26m", 729 - "axi_sel", 27), 730 - GATE_INFRA0(CLK_INFRA_CQ_DMA_FPC, "infra_cqdma_fpc", 731 - "axi_sel", 28), 732 - GATE_INFRA0(CLK_INFRA_BTIF, "infra_btif", 733 - "axi_sel", 31), 731 + GATE_INFRA0(CLK_INFRA_PMIC_TMR, "infra_pmic_tmr", "axi_sel", 0), 732 + GATE_INFRA0(CLK_INFRA_PMIC_AP, "infra_pmic_ap", "axi_sel", 1), 733 + GATE_INFRA0(CLK_INFRA_PMIC_MD, "infra_pmic_md", "axi_sel", 2), 734 + GATE_INFRA0(CLK_INFRA_PMIC_CONN, "infra_pmic_conn", "axi_sel", 3), 735 + GATE_INFRA0(CLK_INFRA_SCPSYS, "infra_scp", "scp_sel", 4), 736 + GATE_INFRA0(CLK_INFRA_SEJ, "infra_sej", "f_f26m_ck", 5), 737 + GATE_INFRA0(CLK_INFRA_APXGPT, "infra_apxgpt", "axi_sel", 6), 738 + GATE_INFRA0(CLK_INFRA_ICUSB, "infra_icusb", "axi_sel", 8), 739 + GATE_INFRA0(CLK_INFRA_GCE, "infra_gce", "axi_sel", 9), 740 + GATE_INFRA0(CLK_INFRA_THERM, "infra_therm", "axi_sel", 10), 741 + GATE_INFRA0(CLK_INFRA_I2C0, "infra_i2c0", "i2c_sel", 11), 742 + GATE_INFRA0(CLK_INFRA_I2C1, "infra_i2c1", "i2c_sel", 12), 743 + GATE_INFRA0(CLK_INFRA_I2C2, "infra_i2c2", "i2c_sel", 13), 744 + GATE_INFRA0(CLK_INFRA_I2C3, "infra_i2c3", "i2c_sel", 14), 745 + GATE_INFRA0(CLK_INFRA_PWM_HCLK, "infra_pwm_hclk", "axi_sel", 15), 746 + GATE_INFRA0(CLK_INFRA_PWM1, "infra_pwm1", "i2c_sel", 16), 747 + GATE_INFRA0(CLK_INFRA_PWM2, "infra_pwm2", "i2c_sel", 17), 748 + GATE_INFRA0(CLK_INFRA_PWM3, "infra_pwm3", "i2c_sel", 18), 749 + GATE_INFRA0(CLK_INFRA_PWM4, "infra_pwm4", "i2c_sel", 19), 750 + GATE_INFRA0(CLK_INFRA_PWM, "infra_pwm", "i2c_sel", 21), 751 + GATE_INFRA0(CLK_INFRA_UART0, "infra_uart0", "uart_sel", 22), 752 + GATE_INFRA0(CLK_INFRA_UART1, "infra_uart1", "uart_sel", 23), 753 + GATE_INFRA0(CLK_INFRA_UART2, "infra_uart2", "uart_sel", 24), 754 + GATE_INFRA0(CLK_INFRA_UART3, "infra_uart3", "uart_sel", 25), 755 + GATE_INFRA0(CLK_INFRA_GCE_26M, "infra_gce_26m", "axi_sel", 27), 756 + GATE_INFRA0(CLK_INFRA_CQ_DMA_FPC, "infra_cqdma_fpc", "axi_sel", 28), 757 + GATE_INFRA0(CLK_INFRA_BTIF, "infra_btif", "axi_sel", 31), 734 758 /* INFRA1 */ 735 - GATE_INFRA1(CLK_INFRA_SPI0, "infra_spi0", 736 - "spi_sel", 1), 737 - GATE_INFRA1(CLK_INFRA_MSDC0, "infra_msdc0", 738 - "msdc50_hclk_sel", 2), 739 - GATE_INFRA1(CLK_INFRA_MSDC1, "infra_msdc1", 740 - "axi_sel", 4), 741 - GATE_INFRA1(CLK_INFRA_MSDC2, "infra_msdc2", 742 - "axi_sel", 5), 743 - GATE_INFRA1(CLK_INFRA_MSDC0_SCK, "infra_msdc0_sck", 744 - "msdc50_0_sel", 6), 745 - GATE_INFRA1(CLK_INFRA_DVFSRC, "infra_dvfsrc", 746 - "f_f26m_ck", 7), 747 - GATE_INFRA1(CLK_INFRA_GCPU, "infra_gcpu", 748 - "axi_sel", 8), 749 - GATE_INFRA1(CLK_INFRA_TRNG, "infra_trng", 750 - "axi_sel", 9), 751 - GATE_INFRA1(CLK_INFRA_AUXADC, "infra_auxadc", 752 - "f_f26m_ck", 10), 753 - GATE_INFRA1(CLK_INFRA_CPUM, "infra_cpum", 754 - "axi_sel", 11), 755 - GATE_INFRA1(CLK_INFRA_CCIF1_AP, "infra_ccif1_ap", 756 - "axi_sel", 12), 757 - GATE_INFRA1(CLK_INFRA_CCIF1_MD, "infra_ccif1_md", 758 - "axi_sel", 13), 759 - GATE_INFRA1(CLK_INFRA_AUXADC_MD, "infra_auxadc_md", 760 - "f_f26m_ck", 14), 761 - GATE_INFRA1(CLK_INFRA_MSDC1_SCK, "infra_msdc1_sck", 762 - "msdc30_1_sel", 16), 763 - GATE_INFRA1(CLK_INFRA_MSDC2_SCK, "infra_msdc2_sck", 764 - "msdc30_2_sel", 17), 765 - GATE_INFRA1(CLK_INFRA_AP_DMA, "infra_apdma", 766 - "axi_sel", 18), 767 - GATE_INFRA1(CLK_INFRA_XIU, "infra_xiu", 768 - "axi_sel", 19), 769 - GATE_INFRA1(CLK_INFRA_DEVICE_APC, "infra_device_apc", 770 - "axi_sel", 20), 771 - GATE_INFRA1(CLK_INFRA_CCIF_AP, "infra_ccif_ap", 772 - "axi_sel", 23), 773 - GATE_INFRA1(CLK_INFRA_DEBUGSYS, "infra_debugsys", 774 - "axi_sel", 24), 775 - GATE_INFRA1(CLK_INFRA_AUDIO, "infra_audio", 776 - "axi_sel", 25), 777 - GATE_INFRA1(CLK_INFRA_CCIF_MD, "infra_ccif_md", 778 - "axi_sel", 26), 779 - GATE_INFRA1(CLK_INFRA_DXCC_SEC_CORE, "infra_dxcc_sec_core", 780 - "dxcc_sel", 27), 781 - GATE_INFRA1(CLK_INFRA_DXCC_AO, "infra_dxcc_ao", 782 - "dxcc_sel", 28), 783 - GATE_INFRA1(CLK_INFRA_DEVMPU_BCLK, "infra_devmpu_bclk", 784 - "axi_sel", 30), 785 - GATE_INFRA1(CLK_INFRA_DRAMC_F26M, "infra_dramc_f26m", 786 - "f_f26m_ck", 31), 759 + GATE_INFRA1(CLK_INFRA_SPI0, "infra_spi0", "spi_sel", 1), 760 + GATE_INFRA1(CLK_INFRA_MSDC0, "infra_msdc0", "msdc50_hclk_sel", 2), 761 + GATE_INFRA1(CLK_INFRA_MSDC1, "infra_msdc1", "axi_sel", 4), 762 + GATE_INFRA1(CLK_INFRA_MSDC2, "infra_msdc2", "axi_sel", 5), 763 + GATE_INFRA1(CLK_INFRA_MSDC0_SCK, "infra_msdc0_sck", "msdc50_0_sel", 6), 764 + GATE_INFRA1(CLK_INFRA_DVFSRC, "infra_dvfsrc", "f_f26m_ck", 7), 765 + GATE_INFRA1(CLK_INFRA_GCPU, "infra_gcpu", "axi_sel", 8), 766 + GATE_INFRA1(CLK_INFRA_TRNG, "infra_trng", "axi_sel", 9), 767 + GATE_INFRA1(CLK_INFRA_AUXADC, "infra_auxadc", "f_f26m_ck", 10), 768 + GATE_INFRA1(CLK_INFRA_CPUM, "infra_cpum", "axi_sel", 11), 769 + GATE_INFRA1(CLK_INFRA_CCIF1_AP, "infra_ccif1_ap", "axi_sel", 12), 770 + GATE_INFRA1(CLK_INFRA_CCIF1_MD, "infra_ccif1_md", "axi_sel", 13), 771 + GATE_INFRA1(CLK_INFRA_AUXADC_MD, "infra_auxadc_md", "f_f26m_ck", 14), 772 + GATE_INFRA1(CLK_INFRA_MSDC1_SCK, "infra_msdc1_sck", "msdc30_1_sel", 16), 773 + GATE_INFRA1(CLK_INFRA_MSDC2_SCK, "infra_msdc2_sck", "msdc30_2_sel", 17), 774 + GATE_INFRA1(CLK_INFRA_AP_DMA, "infra_apdma", "axi_sel", 18), 775 + GATE_INFRA1(CLK_INFRA_XIU, "infra_xiu", "axi_sel", 19), 776 + GATE_INFRA1(CLK_INFRA_DEVICE_APC, "infra_device_apc", "axi_sel", 20), 777 + GATE_INFRA1(CLK_INFRA_CCIF_AP, "infra_ccif_ap", "axi_sel", 23), 778 + GATE_INFRA1(CLK_INFRA_DEBUGSYS, "infra_debugsys", "axi_sel", 24), 779 + GATE_INFRA1(CLK_INFRA_AUDIO, "infra_audio", "axi_sel", 25), 780 + GATE_INFRA1(CLK_INFRA_CCIF_MD, "infra_ccif_md", "axi_sel", 26), 781 + GATE_INFRA1(CLK_INFRA_DXCC_SEC_CORE, "infra_dxcc_sec_core", "dxcc_sel", 27), 782 + GATE_INFRA1(CLK_INFRA_DXCC_AO, "infra_dxcc_ao", "dxcc_sel", 28), 783 + GATE_INFRA1(CLK_INFRA_DEVMPU_BCLK, "infra_devmpu_bclk", "axi_sel", 30), 784 + GATE_INFRA1(CLK_INFRA_DRAMC_F26M, "infra_dramc_f26m", "f_f26m_ck", 31), 787 785 /* INFRA2 */ 788 - GATE_INFRA2(CLK_INFRA_IRTX, "infra_irtx", 789 - "f_f26m_ck", 0), 790 - GATE_INFRA2(CLK_INFRA_USB, "infra_usb", 791 - "usb_top_sel", 1), 792 - GATE_INFRA2(CLK_INFRA_DISP_PWM, "infra_disppwm", 793 - "axi_sel", 2), 794 - GATE_INFRA2(CLK_INFRA_CLDMA_BCLK, "infra_cldma_bclk", 795 - "axi_sel", 3), 796 - GATE_INFRA2(CLK_INFRA_AUDIO_26M_BCLK, "infra_audio_26m_bclk", 797 - "f_f26m_ck", 4), 798 - GATE_INFRA2(CLK_INFRA_SPI1, "infra_spi1", 799 - "spi_sel", 6), 800 - GATE_INFRA2(CLK_INFRA_I2C4, "infra_i2c4", 801 - "i2c_sel", 7), 802 - GATE_INFRA2(CLK_INFRA_MODEM_TEMP_SHARE, "infra_md_tmp_share", 803 - "f_f26m_ck", 8), 804 - GATE_INFRA2(CLK_INFRA_SPI2, "infra_spi2", 805 - "spi_sel", 9), 806 - GATE_INFRA2(CLK_INFRA_SPI3, "infra_spi3", 807 - "spi_sel", 10), 808 - GATE_INFRA2(CLK_INFRA_UNIPRO_SCK, "infra_unipro_sck", 809 - "ssusb_top_xhci_sel", 11), 810 - GATE_INFRA2(CLK_INFRA_UNIPRO_TICK, "infra_unipro_tick", 811 - "fufs_sel", 12), 812 - GATE_INFRA2(CLK_INFRA_UFS_MP_SAP_BCLK, "infra_ufs_mp_sap_bck", 813 - "fufs_sel", 13), 814 - GATE_INFRA2(CLK_INFRA_MD32_BCLK, "infra_md32_bclk", 815 - "axi_sel", 14), 816 - GATE_INFRA2(CLK_INFRA_UNIPRO_MBIST, "infra_unipro_mbist", 817 - "axi_sel", 16), 818 - GATE_INFRA2(CLK_INFRA_I2C5, "infra_i2c5", 819 - "i2c_sel", 18), 820 - GATE_INFRA2(CLK_INFRA_I2C5_ARBITER, "infra_i2c5_arbiter", 821 - "i2c_sel", 19), 822 - GATE_INFRA2(CLK_INFRA_I2C5_IMM, "infra_i2c5_imm", 823 - "i2c_sel", 20), 824 - GATE_INFRA2(CLK_INFRA_I2C1_ARBITER, "infra_i2c1_arbiter", 825 - "i2c_sel", 21), 826 - GATE_INFRA2(CLK_INFRA_I2C1_IMM, "infra_i2c1_imm", 827 - "i2c_sel", 22), 828 - GATE_INFRA2(CLK_INFRA_I2C2_ARBITER, "infra_i2c2_arbiter", 829 - "i2c_sel", 23), 830 - GATE_INFRA2(CLK_INFRA_I2C2_IMM, "infra_i2c2_imm", 831 - "i2c_sel", 24), 832 - GATE_INFRA2(CLK_INFRA_SPI4, "infra_spi4", 833 - "spi_sel", 25), 834 - GATE_INFRA2(CLK_INFRA_SPI5, "infra_spi5", 835 - "spi_sel", 26), 836 - GATE_INFRA2(CLK_INFRA_CQ_DMA, "infra_cqdma", 837 - "axi_sel", 27), 838 - GATE_INFRA2(CLK_INFRA_UFS, "infra_ufs", 839 - "fufs_sel", 28), 840 - GATE_INFRA2(CLK_INFRA_AES_UFSFDE, "infra_aes_ufsfde", 841 - "faes_ufsfde_sel", 29), 842 - GATE_INFRA2(CLK_INFRA_UFS_TICK, "infra_ufs_tick", 843 - "fufs_sel", 30), 786 + GATE_INFRA2(CLK_INFRA_IRTX, "infra_irtx", "f_f26m_ck", 0), 787 + GATE_INFRA2(CLK_INFRA_USB, "infra_usb", "usb_top_sel", 1), 788 + GATE_INFRA2(CLK_INFRA_DISP_PWM, "infra_disppwm", "axi_sel", 2), 789 + GATE_INFRA2(CLK_INFRA_CLDMA_BCLK, "infra_cldma_bclk", "axi_sel", 3), 790 + GATE_INFRA2(CLK_INFRA_AUDIO_26M_BCLK, "infra_audio_26m_bclk", "f_f26m_ck", 4), 791 + GATE_INFRA2(CLK_INFRA_SPI1, "infra_spi1", "spi_sel", 6), 792 + GATE_INFRA2(CLK_INFRA_I2C4, "infra_i2c4", "i2c_sel", 7), 793 + GATE_INFRA2(CLK_INFRA_MODEM_TEMP_SHARE, "infra_md_tmp_share", "f_f26m_ck", 8), 794 + GATE_INFRA2(CLK_INFRA_SPI2, "infra_spi2", "spi_sel", 9), 795 + GATE_INFRA2(CLK_INFRA_SPI3, "infra_spi3", "spi_sel", 10), 796 + GATE_INFRA2(CLK_INFRA_UNIPRO_SCK, "infra_unipro_sck", "ssusb_top_xhci_sel", 11), 797 + GATE_INFRA2(CLK_INFRA_UNIPRO_TICK, "infra_unipro_tick", "fufs_sel", 12), 798 + GATE_INFRA2(CLK_INFRA_UFS_MP_SAP_BCLK, "infra_ufs_mp_sap_bck", "fufs_sel", 13), 799 + GATE_INFRA2(CLK_INFRA_MD32_BCLK, "infra_md32_bclk", "axi_sel", 14), 800 + GATE_INFRA2(CLK_INFRA_UNIPRO_MBIST, "infra_unipro_mbist", "axi_sel", 16), 801 + GATE_INFRA2(CLK_INFRA_I2C5, "infra_i2c5", "i2c_sel", 18), 802 + GATE_INFRA2(CLK_INFRA_I2C5_ARBITER, "infra_i2c5_arbiter", "i2c_sel", 19), 803 + GATE_INFRA2(CLK_INFRA_I2C5_IMM, "infra_i2c5_imm", "i2c_sel", 20), 804 + GATE_INFRA2(CLK_INFRA_I2C1_ARBITER, "infra_i2c1_arbiter", "i2c_sel", 21), 805 + GATE_INFRA2(CLK_INFRA_I2C1_IMM, "infra_i2c1_imm", "i2c_sel", 22), 806 + GATE_INFRA2(CLK_INFRA_I2C2_ARBITER, "infra_i2c2_arbiter", "i2c_sel", 23), 807 + GATE_INFRA2(CLK_INFRA_I2C2_IMM, "infra_i2c2_imm", "i2c_sel", 24), 808 + GATE_INFRA2(CLK_INFRA_SPI4, "infra_spi4", "spi_sel", 25), 809 + GATE_INFRA2(CLK_INFRA_SPI5, "infra_spi5", "spi_sel", 26), 810 + GATE_INFRA2(CLK_INFRA_CQ_DMA, "infra_cqdma", "axi_sel", 27), 811 + GATE_INFRA2(CLK_INFRA_UFS, "infra_ufs", "fufs_sel", 28), 812 + GATE_INFRA2(CLK_INFRA_AES_UFSFDE, "infra_aes_ufsfde", "faes_ufsfde_sel", 29), 813 + GATE_INFRA2(CLK_INFRA_UFS_TICK, "infra_ufs_tick", "fufs_sel", 30), 844 814 /* INFRA3 */ 845 - GATE_INFRA3(CLK_INFRA_MSDC0_SELF, "infra_msdc0_self", 846 - "msdc50_0_sel", 0), 847 - GATE_INFRA3(CLK_INFRA_MSDC1_SELF, "infra_msdc1_self", 848 - "msdc50_0_sel", 1), 849 - GATE_INFRA3(CLK_INFRA_MSDC2_SELF, "infra_msdc2_self", 850 - "msdc50_0_sel", 2), 851 - GATE_INFRA3(CLK_INFRA_UFS_AXI, "infra_ufs_axi", 852 - "axi_sel", 5), 853 - GATE_INFRA3(CLK_INFRA_I2C6, "infra_i2c6", 854 - "i2c_sel", 6), 855 - GATE_INFRA3(CLK_INFRA_AP_MSDC0, "infra_ap_msdc0", 856 - "msdc50_hclk_sel", 7), 857 - GATE_INFRA3(CLK_INFRA_MD_MSDC0, "infra_md_msdc0", 858 - "msdc50_hclk_sel", 8), 859 - GATE_INFRA3(CLK_INFRA_CCIF2_AP, "infra_ccif2_ap", 860 - "axi_sel", 16), 861 - GATE_INFRA3(CLK_INFRA_CCIF2_MD, "infra_ccif2_md", 862 - "axi_sel", 17), 863 - GATE_INFRA3(CLK_INFRA_CCIF3_AP, "infra_ccif3_ap", 864 - "axi_sel", 18), 865 - GATE_INFRA3(CLK_INFRA_CCIF3_MD, "infra_ccif3_md", 866 - "axi_sel", 19), 867 - GATE_INFRA3(CLK_INFRA_SEJ_F13M, "infra_sej_f13m", 868 - "f_f26m_ck", 20), 869 - GATE_INFRA3(CLK_INFRA_AES_BCLK, "infra_aes_bclk", 870 - "axi_sel", 21), 871 - GATE_INFRA3(CLK_INFRA_I2C7, "infra_i2c7", 872 - "i2c_sel", 22), 873 - GATE_INFRA3(CLK_INFRA_I2C8, "infra_i2c8", 874 - "i2c_sel", 23), 875 - GATE_INFRA3(CLK_INFRA_FBIST2FPC, "infra_fbist2fpc", 876 - "msdc50_0_sel", 24), 815 + GATE_INFRA3(CLK_INFRA_MSDC0_SELF, "infra_msdc0_self", "msdc50_0_sel", 0), 816 + GATE_INFRA3(CLK_INFRA_MSDC1_SELF, "infra_msdc1_self", "msdc50_0_sel", 1), 817 + GATE_INFRA3(CLK_INFRA_MSDC2_SELF, "infra_msdc2_self", "msdc50_0_sel", 2), 818 + GATE_INFRA3(CLK_INFRA_UFS_AXI, "infra_ufs_axi", "axi_sel", 5), 819 + GATE_INFRA3(CLK_INFRA_I2C6, "infra_i2c6", "i2c_sel", 6), 820 + GATE_INFRA3(CLK_INFRA_AP_MSDC0, "infra_ap_msdc0", "msdc50_hclk_sel", 7), 821 + GATE_INFRA3(CLK_INFRA_MD_MSDC0, "infra_md_msdc0", "msdc50_hclk_sel", 8), 822 + GATE_INFRA3(CLK_INFRA_CCIF2_AP, "infra_ccif2_ap", "axi_sel", 16), 823 + GATE_INFRA3(CLK_INFRA_CCIF2_MD, "infra_ccif2_md", "axi_sel", 17), 824 + GATE_INFRA3(CLK_INFRA_CCIF3_AP, "infra_ccif3_ap", "axi_sel", 18), 825 + GATE_INFRA3(CLK_INFRA_CCIF3_MD, "infra_ccif3_md", "axi_sel", 19), 826 + GATE_INFRA3(CLK_INFRA_SEJ_F13M, "infra_sej_f13m", "f_f26m_ck", 20), 827 + GATE_INFRA3(CLK_INFRA_AES_BCLK, "infra_aes_bclk", "axi_sel", 21), 828 + GATE_INFRA3(CLK_INFRA_I2C7, "infra_i2c7", "i2c_sel", 22), 829 + GATE_INFRA3(CLK_INFRA_I2C8, "infra_i2c8", "i2c_sel", 23), 830 + GATE_INFRA3(CLK_INFRA_FBIST2FPC, "infra_fbist2fpc", "msdc50_0_sel", 24), 877 831 }; 878 832 879 833 static const struct mtk_gate_regs peri_cg_regs = { ··· 793 941 GATE_PERI(CLK_PERI_AXI, "peri_axi", "axi_sel", 31), 794 942 }; 795 943 796 - static const struct mtk_gate_regs apmixed_cg_regs = { 797 - .set_ofs = 0x20, 798 - .clr_ofs = 0x20, 799 - .sta_ofs = 0x20, 800 - }; 801 - 802 - #define GATE_APMIXED_FLAGS(_id, _name, _parent, _shift, _flags) \ 803 - GATE_MTK_FLAGS(_id, _name, _parent, &apmixed_cg_regs, \ 804 - _shift, &mtk_clk_gate_ops_no_setclr_inv, _flags) 805 - 806 - #define GATE_APMIXED(_id, _name, _parent, _shift) \ 807 - GATE_APMIXED_FLAGS(_id, _name, _parent, _shift, 0) 808 - 809 - /* 810 - * CRITICAL CLOCK: 811 - * apmixed_appll26m is the toppest clock gate of all PLLs. 812 - */ 813 - static const struct mtk_gate apmixed_clks[] = { 814 - /* AUDIO0 */ 815 - GATE_APMIXED(CLK_APMIXED_SSUSB_26M, "apmixed_ssusb26m", 816 - "f_f26m_ck", 4), 817 - GATE_APMIXED_FLAGS(CLK_APMIXED_APPLL_26M, "apmixed_appll26m", 818 - "f_f26m_ck", 5, CLK_IS_CRITICAL), 819 - GATE_APMIXED(CLK_APMIXED_MIPIC0_26M, "apmixed_mipic026m", 820 - "f_f26m_ck", 6), 821 - GATE_APMIXED(CLK_APMIXED_MDPLLGP_26M, "apmixed_mdpll26m", 822 - "f_f26m_ck", 7), 823 - GATE_APMIXED(CLK_APMIXED_MMSYS_26M, "apmixed_mmsys26m", 824 - "f_f26m_ck", 8), 825 - GATE_APMIXED(CLK_APMIXED_UFS_26M, "apmixed_ufs26m", 826 - "f_f26m_ck", 9), 827 - GATE_APMIXED(CLK_APMIXED_MIPIC1_26M, "apmixed_mipic126m", 828 - "f_f26m_ck", 11), 829 - GATE_APMIXED(CLK_APMIXED_MEMPLL_26M, "apmixed_mempll26m", 830 - "f_f26m_ck", 13), 831 - GATE_APMIXED(CLK_APMIXED_CLKSQ_LVPLL_26M, "apmixed_lvpll26m", 832 - "f_f26m_ck", 14), 833 - GATE_APMIXED(CLK_APMIXED_MIPID0_26M, "apmixed_mipid026m", 834 - "f_f26m_ck", 16), 835 - GATE_APMIXED(CLK_APMIXED_MIPID1_26M, "apmixed_mipid126m", 836 - "f_f26m_ck", 17), 837 - }; 838 - 839 - #define MT8183_PLL_FMAX (3800UL * MHZ) 840 - #define MT8183_PLL_FMIN (1500UL * MHZ) 841 - 842 - #define PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags, \ 843 - _rst_bar_mask, _pcwbits, _pcwibits, _pd_reg, \ 844 - _pd_shift, _tuner_reg, _tuner_en_reg, \ 845 - _tuner_en_bit, _pcw_reg, _pcw_shift, \ 846 - _pcw_chg_reg, _div_table) { \ 847 - .id = _id, \ 848 - .name = _name, \ 849 - .reg = _reg, \ 850 - .pwr_reg = _pwr_reg, \ 851 - .en_mask = _en_mask, \ 852 - .flags = _flags, \ 853 - .rst_bar_mask = _rst_bar_mask, \ 854 - .fmax = MT8183_PLL_FMAX, \ 855 - .fmin = MT8183_PLL_FMIN, \ 856 - .pcwbits = _pcwbits, \ 857 - .pcwibits = _pcwibits, \ 858 - .pd_reg = _pd_reg, \ 859 - .pd_shift = _pd_shift, \ 860 - .tuner_reg = _tuner_reg, \ 861 - .tuner_en_reg = _tuner_en_reg, \ 862 - .tuner_en_bit = _tuner_en_bit, \ 863 - .pcw_reg = _pcw_reg, \ 864 - .pcw_shift = _pcw_shift, \ 865 - .pcw_chg_reg = _pcw_chg_reg, \ 866 - .div_table = _div_table, \ 867 - } 868 - 869 - #define PLL(_id, _name, _reg, _pwr_reg, _en_mask, _flags, \ 870 - _rst_bar_mask, _pcwbits, _pcwibits, _pd_reg, \ 871 - _pd_shift, _tuner_reg, _tuner_en_reg, \ 872 - _tuner_en_bit, _pcw_reg, _pcw_shift, \ 873 - _pcw_chg_reg) \ 874 - PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags, \ 875 - _rst_bar_mask, _pcwbits, _pcwibits, _pd_reg, \ 876 - _pd_shift, _tuner_reg, _tuner_en_reg, \ 877 - _tuner_en_bit, _pcw_reg, _pcw_shift, \ 878 - _pcw_chg_reg, NULL) 879 - 880 - static const struct mtk_pll_div_table armpll_div_table[] = { 881 - { .div = 0, .freq = MT8183_PLL_FMAX }, 882 - { .div = 1, .freq = 1500 * MHZ }, 883 - { .div = 2, .freq = 750 * MHZ }, 884 - { .div = 3, .freq = 375 * MHZ }, 885 - { .div = 4, .freq = 187500000 }, 886 - { } /* sentinel */ 887 - }; 888 - 889 - static const struct mtk_pll_div_table mfgpll_div_table[] = { 890 - { .div = 0, .freq = MT8183_PLL_FMAX }, 891 - { .div = 1, .freq = 1600 * MHZ }, 892 - { .div = 2, .freq = 800 * MHZ }, 893 - { .div = 3, .freq = 400 * MHZ }, 894 - { .div = 4, .freq = 200 * MHZ }, 895 - { } /* sentinel */ 896 - }; 897 - 898 - static const struct mtk_pll_data plls[] = { 899 - PLL_B(CLK_APMIXED_ARMPLL_LL, "armpll_ll", 0x0200, 0x020C, 0, 900 - HAVE_RST_BAR | PLL_AO, BIT(24), 22, 8, 0x0204, 24, 0x0, 0x0, 0, 901 - 0x0204, 0, 0, armpll_div_table), 902 - PLL_B(CLK_APMIXED_ARMPLL_L, "armpll_l", 0x0210, 0x021C, 0, 903 - HAVE_RST_BAR | PLL_AO, BIT(24), 22, 8, 0x0214, 24, 0x0, 0x0, 0, 904 - 0x0214, 0, 0, armpll_div_table), 905 - PLL(CLK_APMIXED_CCIPLL, "ccipll", 0x0290, 0x029C, 0, 906 - HAVE_RST_BAR | PLL_AO, BIT(24), 22, 8, 0x0294, 24, 0x0, 0x0, 0, 907 - 0x0294, 0, 0), 908 - PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0220, 0x022C, 0, 909 - HAVE_RST_BAR, BIT(24), 22, 8, 0x0224, 24, 0x0, 0x0, 0, 910 - 0x0224, 0, 0), 911 - PLL(CLK_APMIXED_UNIV2PLL, "univ2pll", 0x0230, 0x023C, 0, 912 - HAVE_RST_BAR, BIT(24), 22, 8, 0x0234, 24, 0x0, 0x0, 0, 913 - 0x0234, 0, 0), 914 - PLL_B(CLK_APMIXED_MFGPLL, "mfgpll", 0x0240, 0x024C, 0, 915 - 0, 0, 22, 8, 0x0244, 24, 0x0, 0x0, 0, 0x0244, 0, 0, 916 - mfgpll_div_table), 917 - PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x0250, 0x025C, 0, 918 - 0, 0, 22, 8, 0x0254, 24, 0x0, 0x0, 0, 0x0254, 0, 0), 919 - PLL(CLK_APMIXED_TVDPLL, "tvdpll", 0x0260, 0x026C, 0, 920 - 0, 0, 22, 8, 0x0264, 24, 0x0, 0x0, 0, 0x0264, 0, 0), 921 - PLL(CLK_APMIXED_MMPLL, "mmpll", 0x0270, 0x027C, 0, 922 - HAVE_RST_BAR, BIT(23), 22, 8, 0x0274, 24, 0x0, 0x0, 0, 923 - 0x0274, 0, 0), 924 - PLL(CLK_APMIXED_APLL1, "apll1", 0x02A0, 0x02B0, 0, 925 - 0, 0, 32, 8, 0x02A0, 1, 0x02A8, 0x0014, 0, 0x02A4, 0, 0x02A0), 926 - PLL(CLK_APMIXED_APLL2, "apll2", 0x02b4, 0x02c4, 0, 927 - 0, 0, 32, 8, 0x02B4, 1, 0x02BC, 0x0014, 1, 0x02B8, 0, 0x02B4), 928 - }; 929 - 930 944 static u16 infra_rst_ofs[] = { 931 945 INFRA_RST0_SET_OFFSET, 932 946 INFRA_RST1_SET_OFFSET, ··· 805 1087 .rst_bank_ofs = infra_rst_ofs, 806 1088 .rst_bank_nr = ARRAY_SIZE(infra_rst_ofs), 807 1089 }; 808 - 809 - static int clk_mt8183_apmixed_probe(struct platform_device *pdev) 810 - { 811 - struct clk_hw_onecell_data *clk_data; 812 - struct device_node *node = pdev->dev.of_node; 813 - 814 - clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK); 815 - 816 - mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data); 817 - 818 - mtk_clk_register_gates(&pdev->dev, node, apmixed_clks, 819 - ARRAY_SIZE(apmixed_clks), clk_data); 820 - 821 - return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 822 - } 823 - 824 - static struct clk_hw_onecell_data *top_clk_data; 825 - 826 - static void clk_mt8183_top_init_early(struct device_node *node) 827 - { 828 - int i; 829 - 830 - top_clk_data = mtk_alloc_clk_data(CLK_TOP_NR_CLK); 831 - 832 - for (i = 0; i < CLK_TOP_NR_CLK; i++) 833 - top_clk_data->hws[i] = ERR_PTR(-EPROBE_DEFER); 834 - 835 - mtk_clk_register_factors(top_early_divs, ARRAY_SIZE(top_early_divs), 836 - top_clk_data); 837 - 838 - of_clk_add_hw_provider(node, of_clk_hw_onecell_get, top_clk_data); 839 - } 840 - 841 - CLK_OF_DECLARE_DRIVER(mt8183_topckgen, "mediatek,mt8183-topckgen", 842 - clk_mt8183_top_init_early); 843 1090 844 1091 /* Register mux notifier for MFG mux */ 845 1092 static int clk_mt8183_reg_mfg_mux_notifier(struct device *dev, struct clk *clk) ··· 828 1145 return devm_mtk_clk_mux_notifier_register(dev, clk, mfg_mux_nb); 829 1146 } 830 1147 831 - static int clk_mt8183_top_probe(struct platform_device *pdev) 832 - { 833 - void __iomem *base; 834 - struct device_node *node = pdev->dev.of_node; 835 - int ret; 836 - 837 - base = devm_platform_ioremap_resource(pdev, 0); 838 - if (IS_ERR(base)) 839 - return PTR_ERR(base); 840 - 841 - mtk_clk_register_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks), 842 - top_clk_data); 843 - 844 - mtk_clk_register_factors(top_early_divs, ARRAY_SIZE(top_early_divs), 845 - top_clk_data); 846 - 847 - mtk_clk_register_factors(top_divs, ARRAY_SIZE(top_divs), top_clk_data); 848 - 849 - mtk_clk_register_muxes(&pdev->dev, top_muxes, 850 - ARRAY_SIZE(top_muxes), node, 851 - &mt8183_clk_lock, top_clk_data); 852 - 853 - mtk_clk_register_composites(&pdev->dev, top_aud_comp, 854 - ARRAY_SIZE(top_aud_comp), base, 855 - &mt8183_clk_lock, top_clk_data); 856 - 857 - mtk_clk_register_gates(&pdev->dev, node, top_clks, 858 - ARRAY_SIZE(top_clks), top_clk_data); 859 - 860 - ret = clk_mt8183_reg_mfg_mux_notifier(&pdev->dev, 861 - top_clk_data->hws[CLK_TOP_MUX_MFG]->clk); 862 - if (ret) 863 - return ret; 864 - 865 - return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, 866 - top_clk_data); 867 - } 868 - 869 - static int clk_mt8183_mcu_probe(struct platform_device *pdev) 870 - { 871 - struct clk_hw_onecell_data *clk_data; 872 - struct device_node *node = pdev->dev.of_node; 873 - void __iomem *base; 874 - 875 - base = devm_platform_ioremap_resource(pdev, 0); 876 - if (IS_ERR(base)) 877 - return PTR_ERR(base); 878 - 879 - clk_data = mtk_alloc_clk_data(CLK_MCU_NR_CLK); 880 - 881 - mtk_clk_register_composites(&pdev->dev, mcu_muxes, 882 - ARRAY_SIZE(mcu_muxes), base, 883 - &mt8183_clk_lock, clk_data); 884 - 885 - return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 886 - } 887 - 888 - static const struct of_device_id of_match_clk_mt8183[] = { 889 - { 890 - .compatible = "mediatek,mt8183-apmixedsys", 891 - .data = clk_mt8183_apmixed_probe, 892 - }, { 893 - .compatible = "mediatek,mt8183-topckgen", 894 - .data = clk_mt8183_top_probe, 895 - }, { 896 - .compatible = "mediatek,mt8183-mcucfg", 897 - .data = clk_mt8183_mcu_probe, 898 - }, { 899 - /* sentinel */ 900 - } 901 - }; 902 - 903 - static int clk_mt8183_probe(struct platform_device *pdev) 904 - { 905 - int (*clk_probe)(struct platform_device *pdev); 906 - int r; 907 - 908 - clk_probe = of_device_get_match_data(&pdev->dev); 909 - if (!clk_probe) 910 - return -EINVAL; 911 - 912 - r = clk_probe(pdev); 913 - if (r) 914 - dev_err(&pdev->dev, 915 - "could not register clock provider: %s: %d\n", 916 - pdev->name, r); 917 - 918 - return r; 919 - } 920 - 921 1148 static const struct mtk_clk_desc infra_desc = { 922 1149 .clks = infra_clks, 923 1150 .num_clks = ARRAY_SIZE(infra_clks), 924 1151 .rst_desc = &clk_rst_desc, 1152 + }; 1153 + 1154 + static const struct mtk_clk_desc mcu_desc = { 1155 + .composite_clks = mcu_muxes, 1156 + .num_composite_clks = ARRAY_SIZE(mcu_muxes), 1157 + .clk_lock = &mt8183_clk_lock, 925 1158 }; 926 1159 927 1160 static const struct mtk_clk_desc peri_desc = { ··· 845 1246 .num_clks = ARRAY_SIZE(peri_clks), 846 1247 }; 847 1248 848 - static const struct of_device_id of_match_clk_mt8183_simple[] = { 1249 + static const struct mtk_clk_desc topck_desc = { 1250 + .fixed_clks = top_fixed_clks, 1251 + .num_fixed_clks = ARRAY_SIZE(top_fixed_clks), 1252 + .factor_clks = top_divs, 1253 + .num_factor_clks = ARRAY_SIZE(top_divs), 1254 + .mux_clks = top_muxes, 1255 + .num_mux_clks = ARRAY_SIZE(top_muxes), 1256 + .composite_clks = top_aud_comp, 1257 + .num_composite_clks = ARRAY_SIZE(top_aud_comp), 1258 + .clks = top_clks, 1259 + .num_clks = ARRAY_SIZE(top_clks), 1260 + .clk_lock = &mt8183_clk_lock, 1261 + .clk_notifier_func = clk_mt8183_reg_mfg_mux_notifier, 1262 + .mfg_clk_idx = CLK_TOP_MUX_MFG, 1263 + }; 1264 + 1265 + static const struct of_device_id of_match_clk_mt8183[] = { 849 1266 { .compatible = "mediatek,mt8183-infracfg", .data = &infra_desc }, 1267 + { .compatible = "mediatek,mt8183-mcucfg", .data = &mcu_desc }, 850 1268 { .compatible = "mediatek,mt8183-pericfg", .data = &peri_desc, }, 1269 + { .compatible = "mediatek,mt8183-topckgen", .data = &topck_desc }, 851 1270 { /* sentinel */ } 852 1271 }; 853 - 854 - static struct platform_driver clk_mt8183_simple_drv = { 855 - .probe = mtk_clk_simple_probe, 856 - .remove = mtk_clk_simple_remove, 857 - .driver = { 858 - .name = "clk-mt8183-simple", 859 - .of_match_table = of_match_clk_mt8183_simple, 860 - }, 861 - }; 1272 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8183); 862 1273 863 1274 static struct platform_driver clk_mt8183_drv = { 864 - .probe = clk_mt8183_probe, 1275 + .probe = mtk_clk_simple_probe, 1276 + .remove = mtk_clk_simple_remove, 865 1277 .driver = { 866 1278 .name = "clk-mt8183", 867 1279 .of_match_table = of_match_clk_mt8183, 868 1280 }, 869 1281 }; 870 - 871 - static int __init clk_mt8183_init(void) 872 - { 873 - int ret = platform_driver_register(&clk_mt8183_drv); 874 - 875 - if (ret) 876 - return ret; 877 - return platform_driver_register(&clk_mt8183_simple_drv); 878 - } 879 - 880 - arch_initcall(clk_mt8183_init); 1282 + module_platform_driver(clk_mt8183_drv) 1283 + MODULE_LICENSE("GPL");
+5 -1
drivers/clk/mediatek/clk-mt8186-apmixedsys.c
··· 7 7 #include <linux/platform_device.h> 8 8 #include <dt-bindings/clock/mt8186-clk.h> 9 9 10 + #include "clk-fhctl.h" 10 11 #include "clk-mtk.h" 11 12 #include "clk-pll.h" 12 13 #include "clk-pllfh.h" ··· 99 98 .data = { \ 100 99 .pll_id = _pllid, \ 101 100 .fh_id = _fhid, \ 101 + .fh_ver = FHCTL_PLLFH_V2, \ 102 102 .fhx_offset = _offset, \ 103 103 .dds_mask = GENMASK(21, 0), \ 104 104 .slope0_value = 0x6003c97, \ ··· 136 134 { .compatible = "mediatek,mt8186-apmixedsys", }, 137 135 {} 138 136 }; 137 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8186_apmixed); 139 138 140 139 static int clk_mt8186_apmixed_probe(struct platform_device *pdev) 141 140 { ··· 193 190 .of_match_table = of_match_clk_mt8186_apmixed, 194 191 }, 195 192 }; 196 - builtin_platform_driver(clk_mt8186_apmixed_drv); 193 + module_platform_driver(clk_mt8186_apmixed_drv); 194 + MODULE_LICENSE("GPL");
+3 -1
drivers/clk/mediatek/clk-mt8186-cam.c
··· 78 78 /* sentinel */ 79 79 } 80 80 }; 81 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8186_cam); 81 82 82 83 static struct platform_driver clk_mt8186_cam_drv = { 83 84 .probe = mtk_clk_simple_probe, ··· 88 87 .of_match_table = of_match_clk_mt8186_cam, 89 88 }, 90 89 }; 91 - builtin_platform_driver(clk_mt8186_cam_drv); 90 + module_platform_driver(clk_mt8186_cam_drv); 91 + MODULE_LICENSE("GPL");
+3 -1
drivers/clk/mediatek/clk-mt8186-img.c
··· 56 56 /* sentinel */ 57 57 } 58 58 }; 59 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8186_img); 59 60 60 61 static struct platform_driver clk_mt8186_img_drv = { 61 62 .probe = mtk_clk_simple_probe, ··· 66 65 .of_match_table = of_match_clk_mt8186_img, 67 66 }, 68 67 }; 69 - builtin_platform_driver(clk_mt8186_img_drv); 68 + module_platform_driver(clk_mt8186_img_drv); 69 + MODULE_LICENSE("GPL");
+3 -1
drivers/clk/mediatek/clk-mt8186-imp_iic_wrap.c
··· 55 55 /* sentinel */ 56 56 } 57 57 }; 58 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8186_imp_iic_wrap); 58 59 59 60 static struct platform_driver clk_mt8186_imp_iic_wrap_drv = { 60 61 .probe = mtk_clk_simple_probe, ··· 65 64 .of_match_table = of_match_clk_mt8186_imp_iic_wrap, 66 65 }, 67 66 }; 68 - builtin_platform_driver(clk_mt8186_imp_iic_wrap_drv); 67 + module_platform_driver(clk_mt8186_imp_iic_wrap_drv); 68 + MODULE_LICENSE("GPL");
+3 -1
drivers/clk/mediatek/clk-mt8186-infra_ao.c
··· 227 227 /* sentinel */ 228 228 } 229 229 }; 230 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8186_infra_ao); 230 231 231 232 static struct platform_driver clk_mt8186_infra_ao_drv = { 232 233 .probe = mtk_clk_simple_probe, ··· 237 236 .of_match_table = of_match_clk_mt8186_infra_ao, 238 237 }, 239 238 }; 240 - builtin_platform_driver(clk_mt8186_infra_ao_drv); 239 + module_platform_driver(clk_mt8186_infra_ao_drv); 240 + MODULE_LICENSE("GPL");
+3 -1
drivers/clk/mediatek/clk-mt8186-ipe.c
··· 43 43 /* sentinel */ 44 44 } 45 45 }; 46 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8186_ipe); 46 47 47 48 static struct platform_driver clk_mt8186_ipe_drv = { 48 49 .probe = mtk_clk_simple_probe, ··· 53 52 .of_match_table = of_match_clk_mt8186_ipe, 54 53 }, 55 54 }; 56 - builtin_platform_driver(clk_mt8186_ipe_drv); 55 + module_platform_driver(clk_mt8186_ipe_drv); 56 + MODULE_LICENSE("GPL");
+14 -55
drivers/clk/mediatek/clk-mt8186-mcu.c
··· 43 43 MUX(CLK_MCU_ARMPLL_BUS_SEL, "mcu_armpll_bus_sel", mcu_armpll_bus_parents, 0x2E0, 9, 2), 44 44 }; 45 45 46 - static const struct of_device_id of_match_clk_mt8186_mcu[] = { 47 - { .compatible = "mediatek,mt8186-mcusys", }, 48 - {} 46 + static const struct mtk_clk_desc mcu_desc = { 47 + .composite_clks = mcu_muxes, 48 + .num_composite_clks = ARRAY_SIZE(mcu_muxes), 49 49 }; 50 50 51 - static int clk_mt8186_mcu_probe(struct platform_device *pdev) 52 - { 53 - struct clk_hw_onecell_data *clk_data; 54 - struct device_node *node = pdev->dev.of_node; 55 - int r; 56 - void __iomem *base; 57 - 58 - clk_data = mtk_alloc_clk_data(CLK_MCU_NR_CLK); 59 - if (!clk_data) 60 - return -ENOMEM; 61 - 62 - base = devm_platform_ioremap_resource(pdev, 0); 63 - if (IS_ERR(base)) { 64 - r = PTR_ERR(base); 65 - goto free_mcu_data; 66 - } 67 - 68 - r = mtk_clk_register_composites(&pdev->dev, mcu_muxes, 69 - ARRAY_SIZE(mcu_muxes), base, 70 - NULL, clk_data); 71 - if (r) 72 - goto free_mcu_data; 73 - 74 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 75 - if (r) 76 - goto unregister_composite_muxes; 77 - 78 - platform_set_drvdata(pdev, clk_data); 79 - 80 - return r; 81 - 82 - unregister_composite_muxes: 83 - mtk_clk_unregister_composites(mcu_muxes, ARRAY_SIZE(mcu_muxes), clk_data); 84 - free_mcu_data: 85 - mtk_free_clk_data(clk_data); 86 - return r; 87 - } 88 - 89 - static int clk_mt8186_mcu_remove(struct platform_device *pdev) 90 - { 91 - struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev); 92 - struct device_node *node = pdev->dev.of_node; 93 - 94 - of_clk_del_provider(node); 95 - mtk_clk_unregister_composites(mcu_muxes, ARRAY_SIZE(mcu_muxes), clk_data); 96 - mtk_free_clk_data(clk_data); 97 - 98 - return 0; 99 - } 51 + static const struct of_device_id of_match_clk_mt8186_mcu[] = { 52 + { .compatible = "mediatek,mt8186-mcusys", .data = &mcu_desc }, 53 + { /* sentinel */} 54 + }; 55 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8186_mcu); 100 56 101 57 static struct platform_driver clk_mt8186_mcu_drv = { 102 - .probe = clk_mt8186_mcu_probe, 103 - .remove = clk_mt8186_mcu_remove, 104 58 .driver = { 105 59 .name = "clk-mt8186-mcu", 106 60 .of_match_table = of_match_clk_mt8186_mcu, 107 61 }, 62 + .probe = mtk_clk_simple_probe, 63 + .remove = mtk_clk_simple_remove, 108 64 }; 109 - builtin_platform_driver(clk_mt8186_mcu_drv); 65 + module_platform_driver(clk_mt8186_mcu_drv); 66 + 67 + MODULE_DESCRIPTION("MediaTek MT8186 mcusys clocks driver"); 68 + MODULE_LICENSE("GPL");
+3 -1
drivers/clk/mediatek/clk-mt8186-mdp.c
··· 68 68 /* sentinel */ 69 69 } 70 70 }; 71 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8186_mdp); 71 72 72 73 static struct platform_driver clk_mt8186_mdp_drv = { 73 74 .probe = mtk_clk_simple_probe, ··· 78 77 .of_match_table = of_match_clk_mt8186_mdp, 79 78 }, 80 79 }; 81 - builtin_platform_driver(clk_mt8186_mdp_drv); 80 + module_platform_driver(clk_mt8186_mdp_drv); 81 + MODULE_LICENSE("GPL");
+3 -1
drivers/clk/mediatek/clk-mt8186-mfg.c
··· 37 37 /* sentinel */ 38 38 } 39 39 }; 40 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8186_mfg); 40 41 41 42 static struct platform_driver clk_mt8186_mfg_drv = { 42 43 .probe = mtk_clk_simple_probe, ··· 47 46 .of_match_table = of_match_clk_mt8186_mfg, 48 47 }, 49 48 }; 50 - builtin_platform_driver(clk_mt8186_mfg_drv); 49 + module_platform_driver(clk_mt8186_mfg_drv); 50 + MODULE_LICENSE("GPL");
+14 -45
drivers/clk/mediatek/clk-mt8186-mm.c
··· 58 58 GATE_MM1(CLK_MM_DISP_26M, "mm_disp_26m_ck", "top_disp", 10), 59 59 }; 60 60 61 - static int clk_mt8186_mm_probe(struct platform_device *pdev) 62 - { 63 - struct device *dev = &pdev->dev; 64 - struct device_node *node = dev->parent->of_node; 65 - struct clk_hw_onecell_data *clk_data; 66 - int r; 61 + static const struct mtk_clk_desc mm_desc = { 62 + .clks = mm_clks, 63 + .num_clks = ARRAY_SIZE(mm_clks), 64 + }; 67 65 68 - clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK); 69 - if (!clk_data) 70 - return -ENOMEM; 71 - 72 - r = mtk_clk_register_gates(&pdev->dev, node, mm_clks, 73 - ARRAY_SIZE(mm_clks), clk_data); 74 - if (r) 75 - goto free_mm_data; 76 - 77 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 78 - if (r) 79 - goto unregister_gates; 80 - 81 - platform_set_drvdata(pdev, clk_data); 82 - 83 - return r; 84 - 85 - unregister_gates: 86 - mtk_clk_unregister_gates(mm_clks, ARRAY_SIZE(mm_clks), clk_data); 87 - free_mm_data: 88 - mtk_free_clk_data(clk_data); 89 - return r; 90 - } 91 - 92 - static int clk_mt8186_mm_remove(struct platform_device *pdev) 93 - { 94 - struct device *dev = &pdev->dev; 95 - struct device_node *node = dev->parent->of_node; 96 - struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev); 97 - 98 - of_clk_del_provider(node); 99 - mtk_clk_unregister_gates(mm_clks, ARRAY_SIZE(mm_clks), clk_data); 100 - mtk_free_clk_data(clk_data); 101 - 102 - return 0; 103 - } 66 + static const struct platform_device_id clk_mt8186_mm_id_table[] = { 67 + { .name = "clk-mt8186-mm", .driver_data = (kernel_ulong_t)&mm_desc }, 68 + { /* sentinel */ } 69 + }; 70 + MODULE_DEVICE_TABLE(platform, clk_mt8186_mm_id_table); 104 71 105 72 static struct platform_driver clk_mt8186_mm_drv = { 106 - .probe = clk_mt8186_mm_probe, 107 - .remove = clk_mt8186_mm_remove, 73 + .probe = mtk_clk_pdev_probe, 74 + .remove = mtk_clk_pdev_remove, 108 75 .driver = { 109 76 .name = "clk-mt8186-mm", 110 77 }, 78 + .id_table = clk_mt8186_mm_id_table, 111 79 }; 112 - builtin_platform_driver(clk_mt8186_mm_drv); 80 + module_platform_driver(clk_mt8186_mm_drv); 81 + MODULE_LICENSE("GPL");
+3 -1
drivers/clk/mediatek/clk-mt8186-topckgen.c
··· 721 721 { .compatible = "mediatek,mt8186-topckgen", .data = &topck_desc }, 722 722 { /* sentinel */ } 723 723 }; 724 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8186_topck); 724 725 725 726 static struct platform_driver clk_mt8186_topck_drv = { 726 727 .probe = mtk_clk_simple_probe, ··· 731 730 .of_match_table = of_match_clk_mt8186_topck, 732 731 }, 733 732 }; 734 - builtin_platform_driver(clk_mt8186_topck_drv); 733 + module_platform_driver(clk_mt8186_topck_drv); 734 + MODULE_LICENSE("GPL");
+3 -1
drivers/clk/mediatek/clk-mt8186-vdec.c
··· 76 76 /* sentinel */ 77 77 } 78 78 }; 79 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8186_vdec); 79 80 80 81 static struct platform_driver clk_mt8186_vdec_drv = { 81 82 .probe = mtk_clk_simple_probe, ··· 86 85 .of_match_table = of_match_clk_mt8186_vdec, 87 86 }, 88 87 }; 89 - builtin_platform_driver(clk_mt8186_vdec_drv); 88 + module_platform_driver(clk_mt8186_vdec_drv); 89 + MODULE_LICENSE("GPL");
+3 -1
drivers/clk/mediatek/clk-mt8186-venc.c
··· 39 39 /* sentinel */ 40 40 } 41 41 }; 42 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8186_venc); 42 43 43 44 static struct platform_driver clk_mt8186_venc_drv = { 44 45 .probe = mtk_clk_simple_probe, ··· 49 48 .of_match_table = of_match_clk_mt8186_venc, 50 49 }, 51 50 }; 52 - builtin_platform_driver(clk_mt8186_venc_drv); 51 + module_platform_driver(clk_mt8186_venc_drv); 52 + MODULE_LICENSE("GPL");
+3 -1
drivers/clk/mediatek/clk-mt8186-wpe.c
··· 39 39 /* sentinel */ 40 40 } 41 41 }; 42 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8186_wpe); 42 43 43 44 static struct platform_driver clk_mt8186_wpe_drv = { 44 45 .probe = mtk_clk_simple_probe, ··· 49 48 .of_match_table = of_match_clk_mt8186_wpe, 50 49 }, 51 50 }; 52 - builtin_platform_driver(clk_mt8186_wpe_drv); 51 + module_platform_driver(clk_mt8186_wpe_drv); 52 + MODULE_LICENSE("GPL");
+50
drivers/clk/mediatek/clk-mt8188-adsp_audio26m.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Copyright (c) 2022 MediaTek Inc. 4 + * Author: Garmin Chang <garmin.chang@mediatek.com> 5 + */ 6 + 7 + #include <linux/clk-provider.h> 8 + #include <linux/mod_devicetable.h> 9 + #include <linux/platform_device.h> 10 + 11 + #include <dt-bindings/clock/mediatek,mt8188-clk.h> 12 + 13 + #include "clk-gate.h" 14 + #include "clk-mtk.h" 15 + 16 + static const struct mtk_gate_regs adsp_audio26m_cg_regs = { 17 + .set_ofs = 0x80, 18 + .clr_ofs = 0x80, 19 + .sta_ofs = 0x80, 20 + }; 21 + 22 + #define GATE_ADSP_FLAGS(_id, _name, _parent, _shift) \ 23 + GATE_MTK(_id, _name, _parent, &adsp_audio26m_cg_regs, _shift, \ 24 + &mtk_clk_gate_ops_no_setclr) 25 + 26 + static const struct mtk_gate adsp_audio26m_clks[] = { 27 + GATE_ADSP_FLAGS(CLK_AUDIODSP_AUDIO26M, "audiodsp_audio26m", "clk26m", 3), 28 + }; 29 + 30 + static const struct mtk_clk_desc adsp_audio26m_desc = { 31 + .clks = adsp_audio26m_clks, 32 + .num_clks = ARRAY_SIZE(adsp_audio26m_clks), 33 + }; 34 + 35 + static const struct of_device_id of_match_clk_mt8188_adsp_audio26m[] = { 36 + { .compatible = "mediatek,mt8188-adsp-audio26m", .data = &adsp_audio26m_desc }, 37 + { /* sentinel */ } 38 + }; 39 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8188_adsp_audio26m); 40 + 41 + static struct platform_driver clk_mt8188_adsp_audio26m_drv = { 42 + .probe = mtk_clk_simple_probe, 43 + .remove = mtk_clk_simple_remove, 44 + .driver = { 45 + .name = "clk-mt8188-adsp_audio26m", 46 + .of_match_table = of_match_clk_mt8188_adsp_audio26m, 47 + }, 48 + }; 49 + module_platform_driver(clk_mt8188_adsp_audio26m_drv); 50 + MODULE_LICENSE("GPL");
+157
drivers/clk/mediatek/clk-mt8188-apmixedsys.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Copyright (c) 2022 MediaTek Inc. 4 + * Author: Garmin Chang <garmin.chang@mediatek.com> 5 + */ 6 + 7 + #include <dt-bindings/clock/mediatek,mt8188-clk.h> 8 + #include <linux/of_device.h> 9 + #include <linux/platform_device.h> 10 + 11 + #include "clk-gate.h" 12 + #include "clk-mtk.h" 13 + #include "clk-pll.h" 14 + 15 + static const struct mtk_gate_regs apmixed_cg_regs = { 16 + .set_ofs = 0x8, 17 + .clr_ofs = 0x8, 18 + .sta_ofs = 0x8, 19 + }; 20 + 21 + #define GATE_APMIXED(_id, _name, _parent, _shift) \ 22 + GATE_MTK(_id, _name, _parent, &apmixed_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv) 23 + 24 + static const struct mtk_gate apmixed_clks[] = { 25 + GATE_APMIXED(CLK_APMIXED_PLL_SSUSB26M_EN, "pll_ssusb26m_en", "clk26m", 1), 26 + }; 27 + 28 + #define MT8188_PLL_FMAX (3800UL * MHZ) 29 + #define MT8188_PLL_FMIN (1500UL * MHZ) 30 + #define MT8188_INTEGER_BITS 8 31 + 32 + #define PLL(_id, _name, _reg, _pwr_reg, _en_mask, _flags, \ 33 + _rst_bar_mask, _pcwbits, _pd_reg, _pd_shift, \ 34 + _tuner_reg, _tuner_en_reg, _tuner_en_bit, \ 35 + _pcw_reg, _pcw_shift, _pcw_chg_reg, \ 36 + _en_reg, _pll_en_bit) { \ 37 + .id = _id, \ 38 + .name = _name, \ 39 + .reg = _reg, \ 40 + .pwr_reg = _pwr_reg, \ 41 + .en_mask = _en_mask, \ 42 + .flags = _flags, \ 43 + .rst_bar_mask = _rst_bar_mask, \ 44 + .fmax = MT8188_PLL_FMAX, \ 45 + .fmin = MT8188_PLL_FMIN, \ 46 + .pcwbits = _pcwbits, \ 47 + .pcwibits = MT8188_INTEGER_BITS, \ 48 + .pd_reg = _pd_reg, \ 49 + .pd_shift = _pd_shift, \ 50 + .tuner_reg = _tuner_reg, \ 51 + .tuner_en_reg = _tuner_en_reg, \ 52 + .tuner_en_bit = _tuner_en_bit, \ 53 + .pcw_reg = _pcw_reg, \ 54 + .pcw_shift = _pcw_shift, \ 55 + .pcw_chg_reg = _pcw_chg_reg, \ 56 + .en_reg = _en_reg, \ 57 + .pll_en_bit = _pll_en_bit, \ 58 + } 59 + 60 + static const struct mtk_pll_data plls[] = { 61 + PLL(CLK_APMIXED_ETHPLL, "ethpll", 0x044C, 0x0458, 0, 62 + 0, 0, 22, 0x0450, 24, 0, 0, 0, 0x0450, 0, 0, 0, 9), 63 + PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x0514, 0x0520, 0, 64 + 0, 0, 22, 0x0518, 24, 0, 0, 0, 0x0518, 0, 0, 0, 9), 65 + PLL(CLK_APMIXED_TVDPLL1, "tvdpll1", 0x0524, 0x0530, 0, 66 + 0, 0, 22, 0x0528, 24, 0, 0, 0, 0x0528, 0, 0, 0, 9), 67 + PLL(CLK_APMIXED_TVDPLL2, "tvdpll2", 0x0534, 0x0540, 0, 68 + 0, 0, 22, 0x0538, 24, 0, 0, 0, 0x0538, 0, 0, 0, 9), 69 + PLL(CLK_APMIXED_MMPLL, "mmpll", 0x0544, 0x0550, 0xff000000, 70 + HAVE_RST_BAR, BIT(23), 22, 0x0548, 24, 0, 0, 0, 0x0548, 0, 0, 0, 9), 71 + PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x045C, 0x0468, 0xff000000, 72 + HAVE_RST_BAR, BIT(23), 22, 0x0460, 24, 0, 0, 0, 0x0460, 0, 0, 0, 9), 73 + PLL(CLK_APMIXED_IMGPLL, "imgpll", 0x0554, 0x0560, 0, 74 + 0, 0, 22, 0x0558, 24, 0, 0, 0, 0x0558, 0, 0, 0, 9), 75 + PLL(CLK_APMIXED_UNIVPLL, "univpll", 0x0504, 0x0510, 0xff000000, 76 + HAVE_RST_BAR, BIT(23), 22, 0x0508, 24, 0, 0, 0, 0x0508, 0, 0, 0, 9), 77 + PLL(CLK_APMIXED_ADSPPLL, "adsppll", 0x042C, 0x0438, 0, 78 + 0, 0, 22, 0x0430, 24, 0, 0, 0, 0x0430, 0, 0, 0, 9), 79 + PLL(CLK_APMIXED_APLL1, "apll1", 0x0304, 0x0314, 0, 80 + 0, 0, 32, 0x0308, 24, 0x0034, 0x0000, 12, 0x030C, 0, 0, 0, 9), 81 + PLL(CLK_APMIXED_APLL2, "apll2", 0x0318, 0x0328, 0, 82 + 0, 0, 32, 0x031C, 24, 0x0038, 0x0000, 13, 0x0320, 0, 0, 0, 9), 83 + PLL(CLK_APMIXED_APLL3, "apll3", 0x032C, 0x033C, 0, 84 + 0, 0, 32, 0x0330, 24, 0x003C, 0x0000, 14, 0x0334, 0, 0, 0, 9), 85 + PLL(CLK_APMIXED_APLL4, "apll4", 0x0404, 0x0414, 0, 86 + 0, 0, 32, 0x0408, 24, 0x0040, 0x0000, 15, 0x040C, 0, 0, 0, 9), 87 + PLL(CLK_APMIXED_APLL5, "apll5", 0x0418, 0x0428, 0, 88 + 0, 0, 32, 0x041C, 24, 0x0044, 0x0000, 16, 0x0420, 0, 0, 0, 9), 89 + PLL(CLK_APMIXED_MFGPLL, "mfgpll", 0x0340, 0x034C, 0, 90 + 0, 0, 22, 0x0344, 24, 0, 0, 0, 0x0344, 0, 0, 0, 9), 91 + }; 92 + 93 + static const struct of_device_id of_match_clk_mt8188_apmixed[] = { 94 + { .compatible = "mediatek,mt8188-apmixedsys" }, 95 + { /* sentinel */ } 96 + }; 97 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8188_apmixed); 98 + 99 + static int clk_mt8188_apmixed_probe(struct platform_device *pdev) 100 + { 101 + struct clk_hw_onecell_data *clk_data; 102 + struct device_node *node = pdev->dev.of_node; 103 + int r; 104 + 105 + clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK); 106 + if (!clk_data) 107 + return -ENOMEM; 108 + 109 + r = mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data); 110 + if (r) 111 + goto free_apmixed_data; 112 + 113 + r = mtk_clk_register_gates(&pdev->dev, node, apmixed_clks, 114 + ARRAY_SIZE(apmixed_clks), clk_data); 115 + if (r) 116 + goto unregister_plls; 117 + 118 + r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 119 + if (r) 120 + goto unregister_gates; 121 + 122 + platform_set_drvdata(pdev, clk_data); 123 + 124 + return 0; 125 + 126 + unregister_gates: 127 + mtk_clk_unregister_gates(apmixed_clks, ARRAY_SIZE(apmixed_clks), clk_data); 128 + unregister_plls: 129 + mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data); 130 + free_apmixed_data: 131 + mtk_free_clk_data(clk_data); 132 + return r; 133 + } 134 + 135 + static int clk_mt8188_apmixed_remove(struct platform_device *pdev) 136 + { 137 + struct device_node *node = pdev->dev.of_node; 138 + struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev); 139 + 140 + of_clk_del_provider(node); 141 + mtk_clk_unregister_gates(apmixed_clks, ARRAY_SIZE(apmixed_clks), clk_data); 142 + mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data); 143 + mtk_free_clk_data(clk_data); 144 + 145 + return 0; 146 + } 147 + 148 + static struct platform_driver clk_mt8188_apmixed_drv = { 149 + .probe = clk_mt8188_apmixed_probe, 150 + .remove = clk_mt8188_apmixed_remove, 151 + .driver = { 152 + .name = "clk-mt8188-apmixed", 153 + .of_match_table = of_match_clk_mt8188_apmixed, 154 + }, 155 + }; 156 + module_platform_driver(clk_mt8188_apmixed_drv); 157 + MODULE_LICENSE("GPL");
+120
drivers/clk/mediatek/clk-mt8188-cam.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Copyright (c) 2022 MediaTek Inc. 4 + * Author: Garmin Chang <garmin.chang@mediatek.com> 5 + */ 6 + 7 + #include <dt-bindings/clock/mediatek,mt8188-clk.h> 8 + #include <linux/clk-provider.h> 9 + #include <linux/platform_device.h> 10 + 11 + #include "clk-gate.h" 12 + #include "clk-mtk.h" 13 + 14 + static const struct mtk_gate_regs cam_cg_regs = { 15 + .set_ofs = 0x4, 16 + .clr_ofs = 0x8, 17 + .sta_ofs = 0x0, 18 + }; 19 + 20 + #define GATE_CAM(_id, _name, _parent, _shift) \ 21 + GATE_MTK(_id, _name, _parent, &cam_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 22 + 23 + static const struct mtk_gate cam_main_clks[] = { 24 + GATE_CAM(CLK_CAM_MAIN_LARB13, "cam_main_larb13", "top_cam", 0), 25 + GATE_CAM(CLK_CAM_MAIN_LARB14, "cam_main_larb14", "top_cam", 1), 26 + GATE_CAM(CLK_CAM_MAIN_CAM, "cam_main_cam", "top_cam", 2), 27 + GATE_CAM(CLK_CAM_MAIN_CAM_SUBA, "cam_main_cam_suba", "top_cam", 3), 28 + GATE_CAM(CLK_CAM_MAIN_CAM_SUBB, "cam_main_cam_subb", "top_cam", 4), 29 + GATE_CAM(CLK_CAM_MAIN_CAMTG, "cam_main_camtg", "top_cam", 7), 30 + GATE_CAM(CLK_CAM_MAIN_SENINF, "cam_main_seninf", "top_cam", 8), 31 + GATE_CAM(CLK_CAM_MAIN_GCAMSVA, "cam_main_gcamsva", "top_cam", 9), 32 + GATE_CAM(CLK_CAM_MAIN_GCAMSVB, "cam_main_gcamsvb", "top_cam", 10), 33 + GATE_CAM(CLK_CAM_MAIN_GCAMSVC, "cam_main_gcamsvc", "top_cam", 11), 34 + GATE_CAM(CLK_CAM_MAIN_GCAMSVD, "cam_main_gcamsvd", "top_cam", 12), 35 + GATE_CAM(CLK_CAM_MAIN_GCAMSVE, "cam_main_gcamsve", "top_cam", 13), 36 + GATE_CAM(CLK_CAM_MAIN_GCAMSVF, "cam_main_gcamsvf", "top_cam", 14), 37 + GATE_CAM(CLK_CAM_MAIN_GCAMSVG, "cam_main_gcamsvg", "top_cam", 15), 38 + GATE_CAM(CLK_CAM_MAIN_GCAMSVH, "cam_main_gcamsvh", "top_cam", 16), 39 + GATE_CAM(CLK_CAM_MAIN_GCAMSVI, "cam_main_gcamsvi", "top_cam", 17), 40 + GATE_CAM(CLK_CAM_MAIN_GCAMSVJ, "cam_main_gcamsvj", "top_cam", 18), 41 + GATE_CAM(CLK_CAM_MAIN_CAMSV_TOP, "cam_main_camsv", "top_cam", 19), 42 + GATE_CAM(CLK_CAM_MAIN_CAMSV_CQ_A, "cam_main_camsv_cq_a", "top_cam", 20), 43 + GATE_CAM(CLK_CAM_MAIN_CAMSV_CQ_B, "cam_main_camsv_cq_b", "top_cam", 21), 44 + GATE_CAM(CLK_CAM_MAIN_CAMSV_CQ_C, "cam_main_camsv_cq_c", "top_cam", 22), 45 + GATE_CAM(CLK_CAM_MAIN_FAKE_ENG, "cam_main_fake_eng", "top_cam", 28), 46 + GATE_CAM(CLK_CAM_MAIN_CAM2MM0_GALS, "cam_main_cam2mm0_gals", "top_cam", 29), 47 + GATE_CAM(CLK_CAM_MAIN_CAM2MM1_GALS, "cam_main_cam2mm1_gals", "top_cam", 30), 48 + GATE_CAM(CLK_CAM_MAIN_CAM2SYS_GALS, "cam_main_cam2sys_gals", "top_cam", 31), 49 + }; 50 + 51 + static const struct mtk_gate cam_rawa_clks[] = { 52 + GATE_CAM(CLK_CAM_RAWA_LARBX, "cam_rawa_larbx", "top_cam", 0), 53 + GATE_CAM(CLK_CAM_RAWA_CAM, "cam_rawa_cam", "top_cam", 1), 54 + GATE_CAM(CLK_CAM_RAWA_CAMTG, "cam_rawa_camtg", "top_cam", 2), 55 + }; 56 + 57 + static const struct mtk_gate cam_rawb_clks[] = { 58 + GATE_CAM(CLK_CAM_RAWB_LARBX, "cam_rawb_larbx", "top_cam", 0), 59 + GATE_CAM(CLK_CAM_RAWB_CAM, "cam_rawb_cam", "top_cam", 1), 60 + GATE_CAM(CLK_CAM_RAWB_CAMTG, "cam_rawb_camtg", "top_cam", 2), 61 + }; 62 + 63 + static const struct mtk_gate cam_yuva_clks[] = { 64 + GATE_CAM(CLK_CAM_YUVA_LARBX, "cam_yuva_larbx", "top_cam", 0), 65 + GATE_CAM(CLK_CAM_YUVA_CAM, "cam_yuva_cam", "top_cam", 1), 66 + GATE_CAM(CLK_CAM_YUVA_CAMTG, "cam_yuva_camtg", "top_cam", 2), 67 + }; 68 + 69 + static const struct mtk_gate cam_yuvb_clks[] = { 70 + GATE_CAM(CLK_CAM_YUVB_LARBX, "cam_yuvb_larbx", "top_cam", 0), 71 + GATE_CAM(CLK_CAM_YUVB_CAM, "cam_yuvb_cam", "top_cam", 1), 72 + GATE_CAM(CLK_CAM_YUVB_CAMTG, "cam_yuvb_camtg", "top_cam", 2), 73 + }; 74 + 75 + static const struct mtk_clk_desc cam_main_desc = { 76 + .clks = cam_main_clks, 77 + .num_clks = ARRAY_SIZE(cam_main_clks), 78 + }; 79 + 80 + static const struct mtk_clk_desc cam_rawa_desc = { 81 + .clks = cam_rawa_clks, 82 + .num_clks = ARRAY_SIZE(cam_rawa_clks), 83 + }; 84 + 85 + static const struct mtk_clk_desc cam_rawb_desc = { 86 + .clks = cam_rawb_clks, 87 + .num_clks = ARRAY_SIZE(cam_rawb_clks), 88 + }; 89 + 90 + static const struct mtk_clk_desc cam_yuva_desc = { 91 + .clks = cam_yuva_clks, 92 + .num_clks = ARRAY_SIZE(cam_yuva_clks), 93 + }; 94 + 95 + static const struct mtk_clk_desc cam_yuvb_desc = { 96 + .clks = cam_yuvb_clks, 97 + .num_clks = ARRAY_SIZE(cam_yuvb_clks), 98 + }; 99 + 100 + static const struct of_device_id of_match_clk_mt8188_cam[] = { 101 + { .compatible = "mediatek,mt8188-camsys", .data = &cam_main_desc }, 102 + { .compatible = "mediatek,mt8188-camsys-rawa", .data = &cam_rawa_desc }, 103 + { .compatible = "mediatek,mt8188-camsys-rawb", .data = &cam_rawb_desc }, 104 + { .compatible = "mediatek,mt8188-camsys-yuva", .data = &cam_yuva_desc }, 105 + { .compatible = "mediatek,mt8188-camsys-yuvb", .data = &cam_yuvb_desc }, 106 + { /* sentinel */ } 107 + }; 108 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8188_cam); 109 + 110 + static struct platform_driver clk_mt8188_cam_drv = { 111 + .probe = mtk_clk_simple_probe, 112 + .remove = mtk_clk_simple_remove, 113 + .driver = { 114 + .name = "clk-mt8188-cam", 115 + .of_match_table = of_match_clk_mt8188_cam, 116 + }, 117 + }; 118 + 119 + module_platform_driver(clk_mt8188_cam_drv); 120 + MODULE_LICENSE("GPL");
+50
drivers/clk/mediatek/clk-mt8188-ccu.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Copyright (c) 2022 MediaTek Inc. 4 + * Author: Garmin Chang <garmin.chang@mediatek.com> 5 + */ 6 + 7 + #include <dt-bindings/clock/mediatek,mt8188-clk.h> 8 + #include <linux/clk-provider.h> 9 + #include <linux/platform_device.h> 10 + 11 + #include "clk-gate.h" 12 + #include "clk-mtk.h" 13 + 14 + static const struct mtk_gate_regs ccu_cg_regs = { 15 + .set_ofs = 0x4, 16 + .clr_ofs = 0x8, 17 + .sta_ofs = 0x0, 18 + }; 19 + 20 + #define GATE_CCU(_id, _name, _parent, _shift) \ 21 + GATE_MTK(_id, _name, _parent, &ccu_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 22 + 23 + static const struct mtk_gate ccu_clks[] = { 24 + GATE_CCU(CLK_CCU_LARB27, "ccu_larb27", "top_ccu", 0), 25 + GATE_CCU(CLK_CCU_AHB, "ccu_ahb", "top_ccu", 1), 26 + GATE_CCU(CLK_CCU_CCU0, "ccu_ccu0", "top_ccu", 2), 27 + }; 28 + 29 + static const struct mtk_clk_desc ccu_desc = { 30 + .clks = ccu_clks, 31 + .num_clks = ARRAY_SIZE(ccu_clks), 32 + }; 33 + 34 + static const struct of_device_id of_match_clk_mt8188_ccu[] = { 35 + { .compatible = "mediatek,mt8188-ccusys", .data = &ccu_desc }, 36 + { /* sentinel */ } 37 + }; 38 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8188_ccu); 39 + 40 + static struct platform_driver clk_mt8188_ccu_drv = { 41 + .probe = mtk_clk_simple_probe, 42 + .remove = mtk_clk_simple_remove, 43 + .driver = { 44 + .name = "clk-mt8188-ccu", 45 + .of_match_table = of_match_clk_mt8188_ccu, 46 + }, 47 + }; 48 + 49 + module_platform_driver(clk_mt8188_ccu_drv); 50 + MODULE_LICENSE("GPL");
+112
drivers/clk/mediatek/clk-mt8188-img.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Copyright (c) 2022 MediaTek Inc. 4 + * Author: Garmin Chang <garmin.chang@mediatek.com> 5 + */ 6 + 7 + #include <dt-bindings/clock/mediatek,mt8188-clk.h> 8 + #include <linux/clk-provider.h> 9 + #include <linux/platform_device.h> 10 + 11 + #include "clk-gate.h" 12 + #include "clk-mtk.h" 13 + 14 + static const struct mtk_gate_regs imgsys_cg_regs = { 15 + .set_ofs = 0x4, 16 + .clr_ofs = 0x8, 17 + .sta_ofs = 0x0, 18 + }; 19 + 20 + #define GATE_IMGSYS(_id, _name, _parent, _shift) \ 21 + GATE_MTK(_id, _name, _parent, &imgsys_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 22 + 23 + static const struct mtk_gate imgsys_main_clks[] = { 24 + GATE_IMGSYS(CLK_IMGSYS_MAIN_LARB9, "imgsys_main_larb9", "top_img", 0), 25 + GATE_IMGSYS(CLK_IMGSYS_MAIN_TRAW0, "imgsys_main_traw0", "top_img", 1), 26 + GATE_IMGSYS(CLK_IMGSYS_MAIN_TRAW1, "imgsys_main_traw1", "top_img", 2), 27 + GATE_IMGSYS(CLK_IMGSYS_MAIN_VCORE_GALS, "imgsys_main_vcore_gals", "top_img", 3), 28 + GATE_IMGSYS(CLK_IMGSYS_MAIN_DIP0, "imgsys_main_dip0", "top_img", 8), 29 + GATE_IMGSYS(CLK_IMGSYS_MAIN_WPE0, "imgsys_main_wpe0", "top_img", 9), 30 + GATE_IMGSYS(CLK_IMGSYS_MAIN_IPE, "imgsys_main_ipe", "top_img", 10), 31 + GATE_IMGSYS(CLK_IMGSYS_MAIN_WPE1, "imgsys_main_wpe1", "top_img", 12), 32 + GATE_IMGSYS(CLK_IMGSYS_MAIN_WPE2, "imgsys_main_wpe2", "top_img", 13), 33 + GATE_IMGSYS(CLK_IMGSYS_MAIN_GALS, "imgsys_main_gals", "top_img", 31), 34 + }; 35 + 36 + static const struct mtk_gate imgsys_wpe1_clks[] = { 37 + GATE_IMGSYS(CLK_IMGSYS_WPE1_LARB11, "imgsys_wpe1_larb11", "top_img", 0), 38 + GATE_IMGSYS(CLK_IMGSYS_WPE1, "imgsys_wpe1", "top_img", 1), 39 + }; 40 + 41 + static const struct mtk_gate imgsys_wpe2_clks[] = { 42 + GATE_IMGSYS(CLK_IMGSYS_WPE2_LARB11, "imgsys_wpe2_larb11", "top_img", 0), 43 + GATE_IMGSYS(CLK_IMGSYS_WPE2, "imgsys_wpe2", "top_img", 1), 44 + }; 45 + 46 + static const struct mtk_gate imgsys_wpe3_clks[] = { 47 + GATE_IMGSYS(CLK_IMGSYS_WPE3_LARB11, "imgsys_wpe3_larb11", "top_img", 0), 48 + GATE_IMGSYS(CLK_IMGSYS_WPE3, "imgsys_wpe3", "top_img", 1), 49 + }; 50 + 51 + static const struct mtk_gate imgsys1_dip_top_clks[] = { 52 + GATE_IMGSYS(CLK_IMGSYS1_DIP_TOP_LARB10, "imgsys1_dip_larb10", "top_img", 0), 53 + GATE_IMGSYS(CLK_IMGSYS1_DIP_TOP_DIP_TOP, "imgsys1_dip_dip_top", "top_img", 1), 54 + }; 55 + 56 + static const struct mtk_gate imgsys1_dip_nr_clks[] = { 57 + GATE_IMGSYS(CLK_IMGSYS1_DIP_NR_LARB15, "imgsys1_dip_nr_larb15", "top_img", 0), 58 + GATE_IMGSYS(CLK_IMGSYS1_DIP_NR_DIP_NR, "imgsys1_dip_nr_dip_nr", "top_img", 1), 59 + }; 60 + 61 + static const struct mtk_clk_desc imgsys_main_desc = { 62 + .clks = imgsys_main_clks, 63 + .num_clks = ARRAY_SIZE(imgsys_main_clks), 64 + }; 65 + 66 + static const struct mtk_clk_desc imgsys_wpe1_desc = { 67 + .clks = imgsys_wpe1_clks, 68 + .num_clks = ARRAY_SIZE(imgsys_wpe1_clks), 69 + }; 70 + 71 + static const struct mtk_clk_desc imgsys_wpe2_desc = { 72 + .clks = imgsys_wpe2_clks, 73 + .num_clks = ARRAY_SIZE(imgsys_wpe2_clks), 74 + }; 75 + 76 + static const struct mtk_clk_desc imgsys_wpe3_desc = { 77 + .clks = imgsys_wpe3_clks, 78 + .num_clks = ARRAY_SIZE(imgsys_wpe3_clks), 79 + }; 80 + 81 + static const struct mtk_clk_desc imgsys1_dip_top_desc = { 82 + .clks = imgsys1_dip_top_clks, 83 + .num_clks = ARRAY_SIZE(imgsys1_dip_top_clks), 84 + }; 85 + 86 + static const struct mtk_clk_desc imgsys1_dip_nr_desc = { 87 + .clks = imgsys1_dip_nr_clks, 88 + .num_clks = ARRAY_SIZE(imgsys1_dip_nr_clks), 89 + }; 90 + 91 + static const struct of_device_id of_match_clk_mt8188_imgsys_main[] = { 92 + { .compatible = "mediatek,mt8188-imgsys", .data = &imgsys_main_desc }, 93 + { .compatible = "mediatek,mt8188-imgsys-wpe1", .data = &imgsys_wpe1_desc }, 94 + { .compatible = "mediatek,mt8188-imgsys-wpe2", .data = &imgsys_wpe2_desc }, 95 + { .compatible = "mediatek,mt8188-imgsys-wpe3", .data = &imgsys_wpe3_desc }, 96 + { .compatible = "mediatek,mt8188-imgsys1-dip-top", .data = &imgsys1_dip_top_desc }, 97 + { .compatible = "mediatek,mt8188-imgsys1-dip-nr", .data = &imgsys1_dip_nr_desc }, 98 + { /* sentinel */ } 99 + }; 100 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8188_imgsys_main); 101 + 102 + static struct platform_driver clk_mt8188_imgsys_main_drv = { 103 + .probe = mtk_clk_simple_probe, 104 + .remove = mtk_clk_simple_remove, 105 + .driver = { 106 + .name = "clk-mt8188-imgsys_main", 107 + .of_match_table = of_match_clk_mt8188_imgsys_main, 108 + }, 109 + }; 110 + 111 + module_platform_driver(clk_mt8188_imgsys_main_drv); 112 + MODULE_LICENSE("GPL");
+82
drivers/clk/mediatek/clk-mt8188-imp_iic_wrap.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Copyright (c) 2022 MediaTek Inc. 4 + * Author: Garmin Chang <garmin.chang@mediatek.com> 5 + */ 6 + 7 + #include <linux/clk-provider.h> 8 + #include <linux/mod_devicetable.h> 9 + #include <linux/platform_device.h> 10 + 11 + #include <dt-bindings/clock/mediatek,mt8188-clk.h> 12 + 13 + #include "clk-gate.h" 14 + #include "clk-mtk.h" 15 + 16 + static const struct mtk_gate_regs imp_iic_wrap_cg_regs = { 17 + .set_ofs = 0xe08, 18 + .clr_ofs = 0xe04, 19 + .sta_ofs = 0xe00, 20 + }; 21 + 22 + #define GATE_IMP_IIC_WRAP(_id, _name, _parent, _shift) \ 23 + GATE_MTK_FLAGS(_id, _name, _parent, &imp_iic_wrap_cg_regs, _shift, \ 24 + &mtk_clk_gate_ops_setclr, CLK_OPS_PARENT_ENABLE) 25 + 26 + static const struct mtk_gate imp_iic_wrap_c_clks[] = { 27 + GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_C_AP_CLOCK_I2C0, 28 + "imp_iic_wrap_c_ap_clock_i2c0", "top_i2c", 0), 29 + GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_C_AP_CLOCK_I2C2, 30 + "imp_iic_wrap_c_ap_clock_i2c2", "top_i2c", 1), 31 + GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_C_AP_CLOCK_I2C3, 32 + "imp_iic_wrap_c_ap_clock_i2c3", "top_i2c", 2), 33 + }; 34 + 35 + static const struct mtk_gate imp_iic_wrap_w_clks[] = { 36 + GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_W_AP_CLOCK_I2C1, 37 + "imp_iic_wrap_w_ap_clock_i2c1", "top_i2c", 0), 38 + GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_W_AP_CLOCK_I2C4, 39 + "imp_iic_wrap_w_ap_clock_i2c4", "top_i2c", 1), 40 + }; 41 + 42 + static const struct mtk_gate imp_iic_wrap_en_clks[] = { 43 + GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_EN_AP_CLOCK_I2C5, 44 + "imp_iic_wrap_en_ap_clock_i2c5", "top_i2c", 0), 45 + GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_EN_AP_CLOCK_I2C6, 46 + "imp_iic_wrap_en_ap_clock_i2c6", "top_i2c", 1), 47 + }; 48 + 49 + static const struct mtk_clk_desc imp_iic_wrap_c_desc = { 50 + .clks = imp_iic_wrap_c_clks, 51 + .num_clks = ARRAY_SIZE(imp_iic_wrap_c_clks), 52 + }; 53 + 54 + static const struct mtk_clk_desc imp_iic_wrap_w_desc = { 55 + .clks = imp_iic_wrap_w_clks, 56 + .num_clks = ARRAY_SIZE(imp_iic_wrap_w_clks), 57 + }; 58 + 59 + static const struct mtk_clk_desc imp_iic_wrap_en_desc = { 60 + .clks = imp_iic_wrap_en_clks, 61 + .num_clks = ARRAY_SIZE(imp_iic_wrap_en_clks), 62 + }; 63 + 64 + static const struct of_device_id of_match_clk_mt8188_imp_iic_wrap[] = { 65 + { .compatible = "mediatek,mt8188-imp-iic-wrap-c", .data = &imp_iic_wrap_c_desc }, 66 + { .compatible = "mediatek,mt8188-imp-iic-wrap-w", .data = &imp_iic_wrap_w_desc }, 67 + { .compatible = "mediatek,mt8188-imp-iic-wrap-en", .data = &imp_iic_wrap_en_desc }, 68 + { /* sentinel */ } 69 + }; 70 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8188_imp_iic_wrap); 71 + 72 + static struct platform_driver clk_mt8188_imp_iic_wrap_drv = { 73 + .probe = mtk_clk_simple_probe, 74 + .remove = mtk_clk_simple_remove, 75 + .driver = { 76 + .name = "clk-mt8188-imp_iic_wrap", 77 + .of_match_table = of_match_clk_mt8188_imp_iic_wrap, 78 + }, 79 + }; 80 + 81 + module_platform_driver(clk_mt8188_imp_iic_wrap_drv); 82 + MODULE_LICENSE("GPL");
+199
drivers/clk/mediatek/clk-mt8188-infra_ao.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Copyright (c) 2022 MediaTek Inc. 4 + * Author: Garmin Chang <garmin.chang@mediatek.com> 5 + */ 6 + 7 + #include <dt-bindings/clock/mediatek,mt8188-clk.h> 8 + #include <linux/clk-provider.h> 9 + #include <linux/platform_device.h> 10 + 11 + #include "clk-gate.h" 12 + #include "clk-mtk.h" 13 + 14 + static const struct mtk_gate_regs infra_ao0_cg_regs = { 15 + .set_ofs = 0x80, 16 + .clr_ofs = 0x84, 17 + .sta_ofs = 0x90, 18 + }; 19 + 20 + static const struct mtk_gate_regs infra_ao1_cg_regs = { 21 + .set_ofs = 0x88, 22 + .clr_ofs = 0x8c, 23 + .sta_ofs = 0x94, 24 + }; 25 + 26 + static const struct mtk_gate_regs infra_ao2_cg_regs = { 27 + .set_ofs = 0xa4, 28 + .clr_ofs = 0xa8, 29 + .sta_ofs = 0xac, 30 + }; 31 + 32 + static const struct mtk_gate_regs infra_ao3_cg_regs = { 33 + .set_ofs = 0xc0, 34 + .clr_ofs = 0xc4, 35 + .sta_ofs = 0xc8, 36 + }; 37 + 38 + static const struct mtk_gate_regs infra_ao4_cg_regs = { 39 + .set_ofs = 0xe0, 40 + .clr_ofs = 0xe4, 41 + .sta_ofs = 0xe8, 42 + }; 43 + 44 + #define GATE_INFRA_AO0_FLAGS(_id, _name, _parent, _shift, _flag) \ 45 + GATE_MTK_FLAGS(_id, _name, _parent, &infra_ao0_cg_regs, _shift, \ 46 + &mtk_clk_gate_ops_setclr, _flag) 47 + 48 + #define GATE_INFRA_AO0(_id, _name, _parent, _shift) \ 49 + GATE_INFRA_AO0_FLAGS(_id, _name, _parent, _shift, 0) 50 + 51 + #define GATE_INFRA_AO1_FLAGS(_id, _name, _parent, _shift, _flag) \ 52 + GATE_MTK_FLAGS(_id, _name, _parent, &infra_ao1_cg_regs, _shift, \ 53 + &mtk_clk_gate_ops_setclr, _flag) 54 + 55 + #define GATE_INFRA_AO1(_id, _name, _parent, _shift) \ 56 + GATE_INFRA_AO1_FLAGS(_id, _name, _parent, _shift, 0) 57 + 58 + #define GATE_INFRA_AO2(_id, _name, _parent, _shift) \ 59 + GATE_MTK(_id, _name, _parent, &infra_ao2_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 60 + 61 + #define GATE_INFRA_AO2_FLAGS(_id, _name, _parent, _shift, _flag) \ 62 + GATE_MTK_FLAGS(_id, _name, _parent, &infra_ao2_cg_regs, _shift, \ 63 + &mtk_clk_gate_ops_setclr, _flag) 64 + 65 + #define GATE_INFRA_AO3_FLAGS(_id, _name, _parent, _shift, _flag) \ 66 + GATE_MTK_FLAGS(_id, _name, _parent, &infra_ao3_cg_regs, _shift, \ 67 + &mtk_clk_gate_ops_setclr, _flag) 68 + 69 + #define GATE_INFRA_AO3(_id, _name, _parent, _shift) \ 70 + GATE_INFRA_AO3_FLAGS(_id, _name, _parent, _shift, 0) 71 + 72 + #define GATE_INFRA_AO4_FLAGS(_id, _name, _parent, _shift, _flag) \ 73 + GATE_MTK_FLAGS(_id, _name, _parent, &infra_ao4_cg_regs, _shift, \ 74 + &mtk_clk_gate_ops_setclr, _flag) 75 + 76 + #define GATE_INFRA_AO4(_id, _name, _parent, _shift) \ 77 + GATE_INFRA_AO4_FLAGS(_id, _name, _parent, _shift, 0) 78 + 79 + static const struct mtk_gate infra_ao_clks[] = { 80 + /* INFRA_AO0 */ 81 + GATE_INFRA_AO0(CLK_INFRA_AO_PMIC_TMR, "infra_ao_pmic_tmr", "top_pwrap_ulposc", 0), 82 + GATE_INFRA_AO0(CLK_INFRA_AO_PMIC_AP, "infra_ao_pmic_ap", "top_pwrap_ulposc", 1), 83 + GATE_INFRA_AO0(CLK_INFRA_AO_PMIC_MD, "infra_ao_pmic_md", "top_pwrap_ulposc", 2), 84 + GATE_INFRA_AO0(CLK_INFRA_AO_PMIC_CONN, "infra_ao_pmic_conn", "top_pwrap_ulposc", 3), 85 + /* infra_ao_sej is main clock is for secure engine with JTAG support */ 86 + GATE_INFRA_AO0_FLAGS(CLK_INFRA_AO_SEJ, "infra_ao_sej", "top_axi", 5, CLK_IS_CRITICAL), 87 + GATE_INFRA_AO0(CLK_INFRA_AO_APXGPT, "infra_ao_apxgpt", "top_axi", 6), 88 + GATE_INFRA_AO0(CLK_INFRA_AO_GCE, "infra_ao_gce", "top_axi", 8), 89 + GATE_INFRA_AO0(CLK_INFRA_AO_GCE2, "infra_ao_gce2", "top_axi", 9), 90 + GATE_INFRA_AO0(CLK_INFRA_AO_THERM, "infra_ao_therm", "top_axi", 10), 91 + GATE_INFRA_AO0(CLK_INFRA_AO_PWM_HCLK, "infra_ao_pwm_h", "top_axi", 15), 92 + GATE_INFRA_AO0(CLK_INFRA_AO_PWM1, "infra_ao_pwm1", "top_pwm", 16), 93 + GATE_INFRA_AO0(CLK_INFRA_AO_PWM2, "infra_ao_pwm2", "top_pwm", 17), 94 + GATE_INFRA_AO0(CLK_INFRA_AO_PWM3, "infra_ao_pwm3", "top_pwm", 18), 95 + GATE_INFRA_AO0(CLK_INFRA_AO_PWM4, "infra_ao_pwm4", "top_pwm", 19), 96 + GATE_INFRA_AO0(CLK_INFRA_AO_PWM, "infra_ao_pwm", "top_pwm", 21), 97 + GATE_INFRA_AO0(CLK_INFRA_AO_UART0, "infra_ao_uart0", "top_uart", 22), 98 + GATE_INFRA_AO0(CLK_INFRA_AO_UART1, "infra_ao_uart1", "top_uart", 23), 99 + GATE_INFRA_AO0(CLK_INFRA_AO_UART2, "infra_ao_uart2", "top_uart", 24), 100 + GATE_INFRA_AO0(CLK_INFRA_AO_UART3, "infra_ao_uart3", "top_uart", 25), 101 + GATE_INFRA_AO0(CLK_INFRA_AO_UART4, "infra_ao_uart4", "top_uart", 26), 102 + GATE_INFRA_AO0(CLK_INFRA_AO_GCE_26M, "infra_ao_gce_26m", "clk26m", 27), 103 + GATE_INFRA_AO0(CLK_INFRA_AO_CQ_DMA_FPC, "infra_ao_dma", "pad_fpc_ck", 28), 104 + GATE_INFRA_AO0(CLK_INFRA_AO_UART5, "infra_ao_uart5", "top_uart", 29), 105 + /* INFRA_AO1 */ 106 + GATE_INFRA_AO1(CLK_INFRA_AO_HDMI_26M, "infra_ao_hdmi_26m", "clk26m", 0), 107 + GATE_INFRA_AO1(CLK_INFRA_AO_SPI0, "infra_ao_spi0", "top_spi", 1), 108 + GATE_INFRA_AO1(CLK_INFRA_AO_MSDC0, "infra_ao_msdc0", "top_msdc5hclk", 2), 109 + GATE_INFRA_AO1(CLK_INFRA_AO_MSDC1, "infra_ao_msdc1", "top_axi", 4), 110 + GATE_INFRA_AO1(CLK_INFRA_AO_MSDC2, "infra_ao_msdc2", "top_axi", 5), 111 + GATE_INFRA_AO1(CLK_INFRA_AO_MSDC0_SRC, "infra_ao_msdc0_clk", "top_msdc50_0", 6), 112 + /* infra_ao_dvfsrc is for internal DVFS usage, should not be handled by Linux. */ 113 + GATE_INFRA_AO1_FLAGS(CLK_INFRA_AO_DVFSRC, "infra_ao_dvfsrc", 114 + "clk26m", 7, CLK_IS_CRITICAL), 115 + GATE_INFRA_AO1(CLK_INFRA_AO_TRNG, "infra_ao_trng", "top_axi", 9), 116 + GATE_INFRA_AO1(CLK_INFRA_AO_AUXADC, "infra_ao_auxadc", "clk26m", 10), 117 + GATE_INFRA_AO1(CLK_INFRA_AO_CPUM, "infra_ao_cpum", "top_axi", 11), 118 + GATE_INFRA_AO1(CLK_INFRA_AO_HDMI_32K, "infra_ao_hdmi_32k", "clk32k", 12), 119 + GATE_INFRA_AO1(CLK_INFRA_AO_CEC_66M_HCLK, "infra_ao_cec_66m_hclk", "top_axi", 13), 120 + GATE_INFRA_AO1(CLK_INFRA_AO_PCIE_TL_26M, "infra_ao_pcie_tl_26m", "clk26m", 15), 121 + GATE_INFRA_AO1(CLK_INFRA_AO_MSDC1_SRC, "infra_ao_msdc1_clk", "top_msdc30_1", 16), 122 + GATE_INFRA_AO1(CLK_INFRA_AO_CEC_66M_BCLK, "infra_ao_cec_66m_bclk", "top_axi", 17), 123 + GATE_INFRA_AO1(CLK_INFRA_AO_PCIE_TL_96M, "infra_ao_pcie_tl_96m", "top_tl", 18), 124 + /* infra_ao_dapc is for device access permission control module */ 125 + GATE_INFRA_AO1_FLAGS(CLK_INFRA_AO_DEVICE_APC, "infra_ao_dapc", 126 + "top_axi", 20, CLK_IS_CRITICAL), 127 + GATE_INFRA_AO1(CLK_INFRA_AO_ECC_66M_HCLK, "infra_ao_ecc_66m_hclk", "top_axi", 23), 128 + GATE_INFRA_AO1(CLK_INFRA_AO_DEBUGSYS, "infra_ao_debugsys", "top_axi", 24), 129 + GATE_INFRA_AO1(CLK_INFRA_AO_AUDIO, "infra_ao_audio", "top_axi", 25), 130 + GATE_INFRA_AO1(CLK_INFRA_AO_PCIE_TL_32K, "infra_ao_pcie_tl_32k", "clk32k", 26), 131 + GATE_INFRA_AO1(CLK_INFRA_AO_DBG_TRACE, "infra_ao_dbg_trace", "top_axi", 29), 132 + GATE_INFRA_AO1(CLK_INFRA_AO_DRAMC_F26M, "infra_ao_dramc26", "clk26m", 31), 133 + /* INFRA_AO2 */ 134 + GATE_INFRA_AO2(CLK_INFRA_AO_IRTX, "infra_ao_irtx", "top_axi", 0), 135 + GATE_INFRA_AO2(CLK_INFRA_AO_DISP_PWM, "infra_ao_disp_pwm", "top_disp_pwm0", 2), 136 + GATE_INFRA_AO2(CLK_INFRA_AO_CLDMA_BCLK, "infra_ao_cldmabclk", "top_axi", 3), 137 + GATE_INFRA_AO2(CLK_INFRA_AO_AUDIO_26M_BCLK, "infra_ao_audio26m", "clk26m", 4), 138 + GATE_INFRA_AO2(CLK_INFRA_AO_SPI1, "infra_ao_spi1", "top_spi", 6), 139 + GATE_INFRA_AO2(CLK_INFRA_AO_SPI2, "infra_ao_spi2", "top_spi", 9), 140 + GATE_INFRA_AO2(CLK_INFRA_AO_SPI3, "infra_ao_spi3", "top_spi", 10), 141 + GATE_INFRA_AO2_FLAGS(CLK_INFRA_AO_FSSPM, "infra_ao_fsspm", 142 + "top_sspm", 15, CLK_IS_CRITICAL), 143 + GATE_INFRA_AO2_FLAGS(CLK_INFRA_AO_SSPM_BUS_HCLK, "infra_ao_sspm_hclk", 144 + "top_axi", 17, CLK_IS_CRITICAL), 145 + GATE_INFRA_AO2(CLK_INFRA_AO_APDMA_BCLK, "infra_ao_apdma_bclk", "top_axi", 18), 146 + GATE_INFRA_AO2(CLK_INFRA_AO_SPI4, "infra_ao_spi4", "top_spi", 25), 147 + GATE_INFRA_AO2(CLK_INFRA_AO_SPI5, "infra_ao_spi5", "top_spi", 26), 148 + GATE_INFRA_AO2(CLK_INFRA_AO_CQ_DMA, "infra_ao_cq_dma", "top_axi", 27), 149 + /* INFRA_AO3 */ 150 + GATE_INFRA_AO3(CLK_INFRA_AO_MSDC0_SELF, "infra_ao_msdc0sf", "top_msdc50_0", 0), 151 + GATE_INFRA_AO3(CLK_INFRA_AO_MSDC1_SELF, "infra_ao_msdc1sf", "top_msdc50_0", 1), 152 + GATE_INFRA_AO3(CLK_INFRA_AO_MSDC2_SELF, "infra_ao_msdc2sf", "top_msdc50_0", 2), 153 + GATE_INFRA_AO3(CLK_INFRA_AO_I2S_DMA, "infra_ao_i2s_dma", "top_axi", 5), 154 + GATE_INFRA_AO3(CLK_INFRA_AO_AP_MSDC0, "infra_ao_ap_msdc0", "top_msdc50_0", 7), 155 + GATE_INFRA_AO3(CLK_INFRA_AO_MD_MSDC0, "infra_ao_md_msdc0", "top_msdc50_0", 8), 156 + GATE_INFRA_AO3(CLK_INFRA_AO_MSDC30_2, "infra_ao_msdc30_2", "top_msdc30_2", 9), 157 + GATE_INFRA_AO3(CLK_INFRA_AO_GCPU, "infra_ao_gcpu", "top_gcpu", 10), 158 + GATE_INFRA_AO3(CLK_INFRA_AO_PCIE_PERI_26M, "infra_ao_pcie_peri_26m", "clk26m", 15), 159 + GATE_INFRA_AO3(CLK_INFRA_AO_GCPU_66M_BCLK, "infra_ao_gcpu_66m_bclk", "top_axi", 16), 160 + GATE_INFRA_AO3(CLK_INFRA_AO_GCPU_133M_BCLK, "infra_ao_gcpu_133m_bclk", "top_axi", 17), 161 + GATE_INFRA_AO3(CLK_INFRA_AO_DISP_PWM1, "infra_ao_disp_pwm1", "top_disp_pwm1", 20), 162 + GATE_INFRA_AO3(CLK_INFRA_AO_FBIST2FPC, "infra_ao_fbist2fpc", "top_msdc50_0", 24), 163 + /* infra_ao_dapc_sync is for device access permission control module */ 164 + GATE_INFRA_AO3_FLAGS(CLK_INFRA_AO_DEVICE_APC_SYNC, "infra_ao_dapc_sync", 165 + "top_axi", 25, CLK_IS_CRITICAL), 166 + GATE_INFRA_AO3(CLK_INFRA_AO_PCIE_P1_PERI_26M, "infra_ao_pcie_p1_peri_26m", "clk26m", 26), 167 + /* INFRA_AO4 */ 168 + /* infra_ao_133m_mclk_set/infra_ao_66m_mclk_set are main clocks of peripheral */ 169 + GATE_INFRA_AO4_FLAGS(CLK_INFRA_AO_133M_MCLK_CK, "infra_ao_133m_mclk_set", 170 + "top_axi", 0, CLK_IS_CRITICAL), 171 + GATE_INFRA_AO4_FLAGS(CLK_INFRA_AO_66M_MCLK_CK, "infra_ao_66m_mclk_set", 172 + "top_axi", 1, CLK_IS_CRITICAL), 173 + GATE_INFRA_AO4(CLK_INFRA_AO_PCIE_PL_P_250M_P0, "infra_ao_pcie_pl_p_250m_p0", 174 + "pextp_pipe", 7), 175 + GATE_INFRA_AO4(CLK_INFRA_AO_RG_AES_MSDCFDE_CK_0P, 176 + "infra_ao_aes_msdcfde_0p", "top_aes_msdcfde", 18), 177 + }; 178 + 179 + static const struct mtk_clk_desc infra_ao_desc = { 180 + .clks = infra_ao_clks, 181 + .num_clks = ARRAY_SIZE(infra_ao_clks), 182 + }; 183 + 184 + static const struct of_device_id of_match_clk_mt8188_infra_ao[] = { 185 + { .compatible = "mediatek,mt8188-infracfg-ao", .data = &infra_ao_desc }, 186 + { /* sentinel */ } 187 + }; 188 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8188_infra_ao); 189 + 190 + static struct platform_driver clk_mt8188_infra_ao_drv = { 191 + .probe = mtk_clk_simple_probe, 192 + .remove = mtk_clk_simple_remove, 193 + .driver = { 194 + .name = "clk-mt8188-infra_ao", 195 + .of_match_table = of_match_clk_mt8188_infra_ao, 196 + }, 197 + }; 198 + module_platform_driver(clk_mt8188_infra_ao_drv); 199 + MODULE_LICENSE("GPL");
+52
drivers/clk/mediatek/clk-mt8188-ipe.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Copyright (c) 2022 MediaTek Inc. 4 + * Author: Garmin Chang <garmin.chang@mediatek.com> 5 + */ 6 + 7 + #include <dt-bindings/clock/mediatek,mt8188-clk.h> 8 + #include <linux/clk-provider.h> 9 + #include <linux/platform_device.h> 10 + 11 + #include "clk-gate.h" 12 + #include "clk-mtk.h" 13 + 14 + static const struct mtk_gate_regs ipe_cg_regs = { 15 + .set_ofs = 0x4, 16 + .clr_ofs = 0x8, 17 + .sta_ofs = 0x0, 18 + }; 19 + 20 + #define GATE_IPE(_id, _name, _parent, _shift) \ 21 + GATE_MTK(_id, _name, _parent, &ipe_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 22 + 23 + static const struct mtk_gate ipe_clks[] = { 24 + GATE_IPE(CLK_IPE_DPE, "ipe_dpe", "top_ipe", 0), 25 + GATE_IPE(CLK_IPE_FDVT, "ipe_fdvt", "top_ipe", 1), 26 + GATE_IPE(CLK_IPE_ME, "ipe_me", "top_ipe", 2), 27 + GATE_IPE(CLK_IPESYS_TOP, "ipesys_top", "top_ipe", 3), 28 + GATE_IPE(CLK_IPE_SMI_LARB12, "ipe_smi_larb12", "top_ipe", 4), 29 + }; 30 + 31 + static const struct mtk_clk_desc ipe_desc = { 32 + .clks = ipe_clks, 33 + .num_clks = ARRAY_SIZE(ipe_clks), 34 + }; 35 + 36 + static const struct of_device_id of_match_clk_mt8188_ipe[] = { 37 + { .compatible = "mediatek,mt8188-ipesys", .data = &ipe_desc }, 38 + { /* sentinel */ } 39 + }; 40 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8188_ipe); 41 + 42 + static struct platform_driver clk_mt8188_ipe_drv = { 43 + .probe = mtk_clk_simple_probe, 44 + .remove = mtk_clk_simple_remove, 45 + .driver = { 46 + .name = "clk-mt8188-ipe", 47 + .of_match_table = of_match_clk_mt8188_ipe, 48 + }, 49 + }; 50 + 51 + module_platform_driver(clk_mt8188_ipe_drv); 52 + MODULE_LICENSE("GPL");
+49
drivers/clk/mediatek/clk-mt8188-mfg.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Copyright (c) 2022 MediaTek Inc. 4 + * Author: Garmin Chang <garmin.chang@mediatek.com> 5 + */ 6 + 7 + #include <dt-bindings/clock/mediatek,mt8188-clk.h> 8 + #include <linux/clk-provider.h> 9 + #include <linux/platform_device.h> 10 + 11 + #include "clk-gate.h" 12 + #include "clk-mtk.h" 13 + 14 + static const struct mtk_gate_regs mfgcfg_cg_regs = { 15 + .set_ofs = 0x4, 16 + .clr_ofs = 0x8, 17 + .sta_ofs = 0x0, 18 + }; 19 + 20 + #define GATE_MFG(_id, _name, _parent, _shift) \ 21 + GATE_MTK_FLAGS(_id, _name, _parent, &mfgcfg_cg_regs, _shift, \ 22 + &mtk_clk_gate_ops_setclr, CLK_SET_RATE_PARENT) 23 + 24 + static const struct mtk_gate mfgcfg_clks[] = { 25 + GATE_MFG(CLK_MFGCFG_BG3D, "mfgcfg_bg3d", "mfg_ck_fast_ref", 0), 26 + }; 27 + 28 + static const struct mtk_clk_desc mfgcfg_desc = { 29 + .clks = mfgcfg_clks, 30 + .num_clks = ARRAY_SIZE(mfgcfg_clks), 31 + }; 32 + 33 + static const struct of_device_id of_match_clk_mt8188_mfgcfg[] = { 34 + { .compatible = "mediatek,mt8188-mfgcfg", .data = &mfgcfg_desc }, 35 + { /* sentinel */ } 36 + }; 37 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8188_mfgcfg); 38 + 39 + static struct platform_driver clk_mt8188_mfgcfg_drv = { 40 + .probe = mtk_clk_simple_probe, 41 + .remove = mtk_clk_simple_remove, 42 + .driver = { 43 + .name = "clk-mt8188-mfgcfg", 44 + .of_match_table = of_match_clk_mt8188_mfgcfg, 45 + }, 46 + }; 47 + 48 + module_platform_driver(clk_mt8188_mfgcfg_drv); 49 + MODULE_LICENSE("GPL");
+59
drivers/clk/mediatek/clk-mt8188-peri_ao.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Copyright (c) 2022 MediaTek Inc. 4 + * Author: Garmin Chang <garmin.chang@mediatek.com> 5 + */ 6 + 7 + #include <dt-bindings/clock/mediatek,mt8188-clk.h> 8 + #include <linux/clk-provider.h> 9 + #include <linux/platform_device.h> 10 + 11 + #include "clk-gate.h" 12 + #include "clk-mtk.h" 13 + 14 + static const struct mtk_gate_regs peri_ao_cg_regs = { 15 + .set_ofs = 0x10, 16 + .clr_ofs = 0x14, 17 + .sta_ofs = 0x18, 18 + }; 19 + 20 + #define GATE_PERI_AO(_id, _name, _parent, _shift) \ 21 + GATE_MTK(_id, _name, _parent, &peri_ao_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 22 + 23 + static const struct mtk_gate peri_ao_clks[] = { 24 + GATE_PERI_AO(CLK_PERI_AO_ETHERNET, "peri_ao_ethernet", "top_axi", 0), 25 + GATE_PERI_AO(CLK_PERI_AO_ETHERNET_BUS, "peri_ao_ethernet_bus", "top_axi", 1), 26 + GATE_PERI_AO(CLK_PERI_AO_FLASHIF_BUS, "peri_ao_flashif_bus", "top_axi", 3), 27 + GATE_PERI_AO(CLK_PERI_AO_FLASHIF_26M, "peri_ao_flashif_26m", "clk26m", 4), 28 + GATE_PERI_AO(CLK_PERI_AO_FLASHIFLASHCK, "peri_ao_flashiflashck", "top_spinor", 5), 29 + GATE_PERI_AO(CLK_PERI_AO_SSUSB_2P_BUS, "peri_ao_ssusb_2p_bus", "top_usb_top_2p", 9), 30 + GATE_PERI_AO(CLK_PERI_AO_SSUSB_2P_XHCI, "peri_ao_ssusb_2p_xhci", "top_ssusb_xhci_2p", 10), 31 + GATE_PERI_AO(CLK_PERI_AO_SSUSB_3P_BUS, "peri_ao_ssusb_3p_bus", "top_usb_top_3p", 11), 32 + GATE_PERI_AO(CLK_PERI_AO_SSUSB_3P_XHCI, "peri_ao_ssusb_3p_xhci", "top_ssusb_xhci_3p", 12), 33 + GATE_PERI_AO(CLK_PERI_AO_SSUSB_BUS, "peri_ao_ssusb_bus", "top_usb_top", 13), 34 + GATE_PERI_AO(CLK_PERI_AO_SSUSB_XHCI, "peri_ao_ssusb_xhci", "top_ssusb_xhci", 14), 35 + GATE_PERI_AO(CLK_PERI_AO_ETHERNET_MAC, "peri_ao_ethernet_mac_clk", "top_snps_eth_250m", 16), 36 + GATE_PERI_AO(CLK_PERI_AO_PCIE_P0_FMEM, "peri_ao_pcie_p0_fmem", "hd_466m_fmem_ck", 24), 37 + }; 38 + 39 + static const struct mtk_clk_desc peri_ao_desc = { 40 + .clks = peri_ao_clks, 41 + .num_clks = ARRAY_SIZE(peri_ao_clks), 42 + }; 43 + 44 + static const struct of_device_id of_match_clk_mt8188_peri_ao[] = { 45 + { .compatible = "mediatek,mt8188-pericfg-ao", .data = &peri_ao_desc }, 46 + { /* sentinel */ } 47 + }; 48 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8188_peri_ao); 49 + 50 + static struct platform_driver clk_mt8188_peri_ao_drv = { 51 + .probe = mtk_clk_simple_probe, 52 + .remove = mtk_clk_simple_remove, 53 + .driver = { 54 + .name = "clk-mt8188-peri_ao", 55 + .of_match_table = of_match_clk_mt8188_peri_ao, 56 + }, 57 + }; 58 + module_platform_driver(clk_mt8188_peri_ao_drv); 59 + MODULE_LICENSE("GPL");
+1350
drivers/clk/mediatek/clk-mt8188-topckgen.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Copyright (c) 2022 MediaTek Inc. 4 + * Author: Garmin Chang <garmin.chang@mediatek.com> 5 + */ 6 + 7 + #include <dt-bindings/clock/mediatek,mt8188-clk.h> 8 + #include <linux/of_device.h> 9 + #include <linux/platform_device.h> 10 + 11 + #include "clk-gate.h" 12 + #include "clk-mtk.h" 13 + #include "clk-mux.h" 14 + 15 + static DEFINE_SPINLOCK(mt8188_clk_lock); 16 + 17 + static const struct mtk_fixed_clk top_fixed_clks[] = { 18 + FIXED_CLK(CLK_TOP_ULPOSC1, "ulposc_ck1", NULL, 260000000), 19 + FIXED_CLK(CLK_TOP_MPHONE_SLAVE_BCK, "mphone_slave_bck", NULL, 49152000), 20 + FIXED_CLK(CLK_TOP_PAD_FPC, "pad_fpc_ck", NULL, 50000000), 21 + FIXED_CLK(CLK_TOP_466M_FMEM, "hd_466m_fmem_ck", NULL, 533000000), 22 + FIXED_CLK(CLK_TOP_PEXTP_PIPE, "pextp_pipe", NULL, 250000000), 23 + FIXED_CLK(CLK_TOP_DSI_PHY, "dsi_phy", NULL, 500000000), 24 + }; 25 + 26 + static const struct mtk_fixed_factor top_divs[] = { 27 + FACTOR(CLK_TOP_MAINPLL_D3, "mainpll_d3", "mainpll", 1, 3), 28 + FACTOR(CLK_TOP_MAINPLL_D4, "mainpll_d4", "mainpll", 1, 4), 29 + FACTOR(CLK_TOP_MAINPLL_D4_D2, "mainpll_d4_d2", "mainpll_d4", 1, 2), 30 + FACTOR(CLK_TOP_MAINPLL_D4_D4, "mainpll_d4_d4", "mainpll_d4", 1, 4), 31 + FACTOR(CLK_TOP_MAINPLL_D4_D8, "mainpll_d4_d8", "mainpll_d4", 1, 8), 32 + FACTOR(CLK_TOP_MAINPLL_D5, "mainpll_d5", "mainpll", 1, 5), 33 + FACTOR(CLK_TOP_MAINPLL_D5_D2, "mainpll_d5_d2", "mainpll_d5", 1, 2), 34 + FACTOR(CLK_TOP_MAINPLL_D5_D4, "mainpll_d5_d4", "mainpll_d5", 1, 4), 35 + FACTOR(CLK_TOP_MAINPLL_D5_D8, "mainpll_d5_d8", "mainpll_d5", 1, 8), 36 + FACTOR(CLK_TOP_MAINPLL_D6, "mainpll_d6", "mainpll", 1, 6), 37 + FACTOR(CLK_TOP_MAINPLL_D6_D2, "mainpll_d6_d2", "mainpll_d6", 1, 2), 38 + FACTOR(CLK_TOP_MAINPLL_D6_D4, "mainpll_d6_d4", "mainpll_d6", 1, 4), 39 + FACTOR(CLK_TOP_MAINPLL_D6_D8, "mainpll_d6_d8", "mainpll_d6", 1, 8), 40 + FACTOR(CLK_TOP_MAINPLL_D7, "mainpll_d7", "mainpll", 1, 7), 41 + FACTOR(CLK_TOP_MAINPLL_D7_D2, "mainpll_d7_d2", "mainpll_d7", 1, 2), 42 + FACTOR(CLK_TOP_MAINPLL_D7_D4, "mainpll_d7_d4", "mainpll_d7", 1, 4), 43 + FACTOR(CLK_TOP_MAINPLL_D7_D8, "mainpll_d7_d8", "mainpll_d7", 1, 8), 44 + FACTOR(CLK_TOP_MAINPLL_D9, "mainpll_d9", "mainpll", 1, 9), 45 + FACTOR(CLK_TOP_UNIVPLL_D2, "univpll_d2", "univpll", 1, 2), 46 + FACTOR(CLK_TOP_UNIVPLL_D3, "univpll_d3", "univpll", 1, 3), 47 + FACTOR(CLK_TOP_UNIVPLL_D4, "univpll_d4", "univpll", 1, 4), 48 + FACTOR(CLK_TOP_UNIVPLL_D4_D2, "univpll_d4_d2", "univpll_d4", 1, 2), 49 + FACTOR(CLK_TOP_UNIVPLL_D4_D4, "univpll_d4_d4", "univpll_d4", 1, 4), 50 + FACTOR(CLK_TOP_UNIVPLL_D4_D8, "univpll_d4_d8", "univpll_d4", 1, 8), 51 + FACTOR(CLK_TOP_UNIVPLL_D5, "univpll_d5", "univpll", 1, 5), 52 + FACTOR(CLK_TOP_UNIVPLL_D5_D2, "univpll_d5_d2", "univpll_d5", 1, 2), 53 + FACTOR(CLK_TOP_UNIVPLL_D5_D4, "univpll_d5_d4", "univpll_d5", 1, 4), 54 + FACTOR(CLK_TOP_UNIVPLL_D5_D8, "univpll_d5_d8", "univpll_d5", 1, 8), 55 + FACTOR(CLK_TOP_UNIVPLL_D6, "univpll_d6", "univpll", 1, 6), 56 + FACTOR(CLK_TOP_UNIVPLL_D6_D2, "univpll_d6_d2", "univpll_d6", 1, 2), 57 + FACTOR(CLK_TOP_UNIVPLL_D6_D4, "univpll_d6_d4", "univpll_d6", 1, 4), 58 + FACTOR(CLK_TOP_UNIVPLL_D6_D8, "univpll_d6_d8", "univpll_d6", 1, 8), 59 + FACTOR(CLK_TOP_UNIVPLL_D7, "univpll_d7", "univpll", 1, 7), 60 + FACTOR(CLK_TOP_UNIVPLL_192M, "univpll_192m", "univpll", 1, 13), 61 + FACTOR(CLK_TOP_UNIVPLL_192M_D4, "univpll_192m_d4", "univpll_192m", 1, 4), 62 + FACTOR(CLK_TOP_UNIVPLL_192M_D8, "univpll_192m_d8", "univpll_192m", 1, 8), 63 + FACTOR(CLK_TOP_UNIVPLL_192M_D10, "univpll_192m_d10", "univpll_192m", 1, 10), 64 + FACTOR(CLK_TOP_UNIVPLL_192M_D16, "univpll_192m_d16", "univpll_192m", 1, 16), 65 + FACTOR(CLK_TOP_UNIVPLL_192M_D32, "univpll_192m_d32", "univpll_192m", 1, 32), 66 + FACTOR(CLK_TOP_APLL1_D3, "apll1_d3", "apll1", 1, 3), 67 + FACTOR(CLK_TOP_APLL1_D4, "apll1_d4", "apll1", 1, 4), 68 + FACTOR(CLK_TOP_APLL2_D3, "apll2_d3", "apll2", 1, 3), 69 + FACTOR(CLK_TOP_APLL2_D4, "apll2_d4", "apll2", 1, 4), 70 + FACTOR(CLK_TOP_APLL3_D4, "apll3_d4", "apll3", 1, 4), 71 + FACTOR(CLK_TOP_APLL4_D4, "apll4_d4", "apll4", 1, 4), 72 + FACTOR(CLK_TOP_APLL5_D4, "apll5_d4", "apll5", 1, 4), 73 + FACTOR(CLK_TOP_MMPLL_D4, "mmpll_d4", "mmpll", 1, 4), 74 + FACTOR(CLK_TOP_MMPLL_D4_D2, "mmpll_d4_d2", "mmpll_d4", 1, 2), 75 + FACTOR(CLK_TOP_MMPLL_D5, "mmpll_d5", "mmpll", 1, 5), 76 + FACTOR(CLK_TOP_MMPLL_D5_D2, "mmpll_d5_d2", "mmpll_d5", 1, 2), 77 + FACTOR(CLK_TOP_MMPLL_D5_D4, "mmpll_d5_d4", "mmpll_d5", 1, 4), 78 + FACTOR(CLK_TOP_MMPLL_D6, "mmpll_d6", "mmpll", 1, 6), 79 + FACTOR(CLK_TOP_MMPLL_D6_D2, "mmpll_d6_d2", "mmpll_d6", 1, 2), 80 + FACTOR(CLK_TOP_MMPLL_D7, "mmpll_d7", "mmpll", 1, 7), 81 + FACTOR(CLK_TOP_MMPLL_D9, "mmpll_d9", "mmpll", 1, 9), 82 + FACTOR(CLK_TOP_TVDPLL1_D2, "tvdpll1_d2", "tvdpll1", 1, 2), 83 + FACTOR(CLK_TOP_TVDPLL1_D4, "tvdpll1_d4", "tvdpll1", 1, 4), 84 + FACTOR(CLK_TOP_TVDPLL1_D8, "tvdpll1_d8", "tvdpll1", 1, 8), 85 + FACTOR(CLK_TOP_TVDPLL1_D16, "tvdpll1_d16", "tvdpll1", 1, 16), 86 + FACTOR(CLK_TOP_TVDPLL2_D2, "tvdpll2_d2", "tvdpll2", 1, 2), 87 + FACTOR(CLK_TOP_TVDPLL2_D4, "tvdpll2_d4", "tvdpll2", 1, 4), 88 + FACTOR(CLK_TOP_TVDPLL2_D8, "tvdpll2_d8", "tvdpll2", 1, 8), 89 + FACTOR(CLK_TOP_TVDPLL2_D16, "tvdpll2_d16", "tvdpll2", 1, 16), 90 + FACTOR(CLK_TOP_MSDCPLL_D2, "msdcpll_d2", "msdcpll", 1, 2), 91 + FACTOR(CLK_TOP_MSDCPLL_D16, "msdcpll_d16", "msdcpll", 1, 16), 92 + FACTOR(CLK_TOP_ETHPLL_D2, "ethpll_d2", "ethpll", 1, 2), 93 + FACTOR(CLK_TOP_ETHPLL_D4, "ethpll_d4", "ethpll", 1, 4), 94 + FACTOR(CLK_TOP_ETHPLL_D8, "ethpll_d8", "ethpll", 1, 8), 95 + FACTOR(CLK_TOP_ETHPLL_D10, "ethpll_d10", "ethpll", 1, 10), 96 + FACTOR(CLK_TOP_ADSPPLL_D2, "adsppll_d2", "adsppll", 1, 2), 97 + FACTOR(CLK_TOP_ADSPPLL_D4, "adsppll_d4", "adsppll", 1, 4), 98 + FACTOR(CLK_TOP_ADSPPLL_D8, "adsppll_d8", "adsppll", 1, 8), 99 + FACTOR(CLK_TOP_ULPOSC1_D2, "ulposc1_d2", "ulposc_ck1", 1, 2), 100 + FACTOR(CLK_TOP_ULPOSC1_D4, "ulposc1_d4", "ulposc_ck1", 1, 4), 101 + FACTOR(CLK_TOP_ULPOSC1_D8, "ulposc1_d8", "ulposc_ck1", 1, 8), 102 + FACTOR(CLK_TOP_ULPOSC1_D7, "ulposc1_d7", "ulposc_ck1", 1, 7), 103 + FACTOR(CLK_TOP_ULPOSC1_D10, "ulposc1_d10", "ulposc_ck1", 1, 10), 104 + FACTOR(CLK_TOP_ULPOSC1_D16, "ulposc1_d16", "ulposc_ck1", 1, 16), 105 + }; 106 + 107 + static const char * const axi_parents[] = { 108 + "clk26m", 109 + "mainpll_d4_d4", 110 + "mainpll_d7_d2", 111 + "mainpll_d4_d2", 112 + "mainpll_d5_d2", 113 + "mainpll_d6_d2", 114 + "ulposc1_d4" 115 + }; 116 + 117 + static const char * const spm_parents[] = { 118 + "clk26m", 119 + "ulposc1_d10", 120 + "mainpll_d7_d4", 121 + "clk32k" 122 + }; 123 + 124 + static const char * const scp_parents[] = { 125 + "clk26m", 126 + "univpll_d4", 127 + "mainpll_d6", 128 + "univpll_d6", 129 + "univpll_d4_d2", 130 + "mainpll_d4_d2", 131 + "univpll_d3", 132 + "mainpll_d3" 133 + }; 134 + 135 + static const char * const bus_aximem_parents[] = { 136 + "clk26m", 137 + "mainpll_d7_d2", 138 + "mainpll_d4_d2", 139 + "mainpll_d5_d2", 140 + "mainpll_d6" 141 + }; 142 + 143 + static const char * const vpp_parents[] = { 144 + "clk26m", 145 + "univpll_d6_d2", 146 + "mainpll_d5_d2", 147 + "mmpll_d6_d2", 148 + "univpll_d5_d2", 149 + "univpll_d4_d2", 150 + "mmpll_d4_d2", 151 + "mmpll_d7", 152 + "univpll_d6", 153 + "mainpll_d4", 154 + "mmpll_d5", 155 + "tvdpll1", 156 + "tvdpll2", 157 + "univpll_d4", 158 + "mmpll_d4" 159 + }; 160 + 161 + static const char * const ethdr_parents[] = { 162 + "clk26m", 163 + "univpll_d6_d2", 164 + "mainpll_d5_d2", 165 + "mmpll_d6_d2", 166 + "univpll_d5_d2", 167 + "univpll_d4_d2", 168 + "mmpll_d4_d2", 169 + "mmpll_d7", 170 + "univpll_d6", 171 + "mainpll_d4", 172 + "mmpll_d5_d4", 173 + "tvdpll1", 174 + "tvdpll2", 175 + "univpll_d4", 176 + "mmpll_d4" 177 + }; 178 + 179 + static const char * const ipe_parents[] = { 180 + "clk26m", 181 + "imgpll", 182 + "mainpll_d4", 183 + "mmpll_d6", 184 + "univpll_d6", 185 + "mainpll_d6", 186 + "mmpll_d4_d2", 187 + "univpll_d4_d2", 188 + "mainpll_d4_d2", 189 + "mmpll_d6_d2", 190 + "univpll_d5_d2", 191 + "mainpll_d7" 192 + }; 193 + 194 + static const char * const cam_parents[] = { 195 + "clk26m", 196 + "tvdpll1", 197 + "mainpll_d4", 198 + "mmpll_d4", 199 + "univpll_d4", 200 + "univpll_d5", 201 + "univpll_d6", 202 + "mmpll_d7", 203 + "univpll_d4_d2", 204 + "mainpll_d4_d2", 205 + "imgpll" 206 + }; 207 + 208 + static const char * const ccu_parents[] = { 209 + "clk26m", 210 + "univpll_d6", 211 + "mainpll_d4_d2", 212 + "mainpll_d4", 213 + "univpll_d5", 214 + "mainpll_d6", 215 + "mmpll_d6", 216 + "mmpll_d7", 217 + "univpll_d4_d2", 218 + "univpll_d7" 219 + }; 220 + 221 + static const char * const ccu_ahb_parents[] = { 222 + "clk26m", 223 + "univpll_d6", 224 + "mainpll_d4_d2", 225 + "mainpll_d4", 226 + "univpll_d5", 227 + "mainpll_d6", 228 + "mmpll_d6", 229 + "mmpll_d7", 230 + "univpll_d4_d2", 231 + "univpll_d7" 232 + }; 233 + 234 + static const char * const img_parents[] = { 235 + "clk26m", 236 + "imgpll", 237 + "univpll_d4", 238 + "mainpll_d4", 239 + "univpll_d5", 240 + "mmpll_d6", 241 + "mmpll_d7", 242 + "univpll_d6", 243 + "mainpll_d6", 244 + "mmpll_d4_d2", 245 + "univpll_d4_d2", 246 + "mainpll_d4_d2", 247 + "univpll_d5_d2" 248 + }; 249 + 250 + static const char * const camtm_parents[] = { 251 + "clk26m", 252 + "univpll_d4_d4", 253 + "univpll_d6_d2", 254 + "univpll_d6_d4" 255 + }; 256 + 257 + static const char * const dsp_parents[] = { 258 + "clk26m", 259 + "univpll_d6_d2", 260 + "univpll_d4_d2", 261 + "univpll_d5", 262 + "univpll_d4", 263 + "mmpll_d4", 264 + "mainpll_d3", 265 + "univpll_d3" 266 + }; 267 + 268 + static const char * const dsp1_parents[] = { 269 + "clk26m", 270 + "univpll_d6_d2", 271 + "mainpll_d4_d2", 272 + "univpll_d5", 273 + "mmpll_d5", 274 + "univpll_d4", 275 + "mainpll_d3", 276 + "univpll_d3" 277 + }; 278 + 279 + static const char * const dsp2_parents[] = { 280 + "clk26m", 281 + "univpll_d6_d2", 282 + "mainpll_d4_d2", 283 + "univpll_d5", 284 + "mmpll_d5", 285 + "univpll_d4", 286 + "mainpll_d3", 287 + "univpll_d3" 288 + }; 289 + 290 + static const char * const dsp3_parents[] = { 291 + "clk26m", 292 + "univpll_d6_d2", 293 + "mainpll_d4_d2", 294 + "univpll_d5", 295 + "mmpll_d5", 296 + "univpll_d4", 297 + "mainpll_d3", 298 + "univpll_d3" 299 + }; 300 + 301 + static const char * const dsp4_parents[] = { 302 + "clk26m", 303 + "univpll_d6_d2", 304 + "univpll_d4_d2", 305 + "mainpll_d4", 306 + "univpll_d4", 307 + "mmpll_d4", 308 + "mainpll_d3", 309 + "univpll_d3" 310 + }; 311 + 312 + static const char * const dsp5_parents[] = { 313 + "clk26m", 314 + "univpll_d6_d2", 315 + "univpll_d4_d2", 316 + "mainpll_d4", 317 + "univpll_d4", 318 + "mmpll_d4", 319 + "mainpll_d3", 320 + "univpll_d3" 321 + }; 322 + 323 + static const char * const dsp6_parents[] = { 324 + "clk26m", 325 + "univpll_d6_d2", 326 + "univpll_d4_d2", 327 + "mainpll_d4", 328 + "univpll_d4", 329 + "mmpll_d4", 330 + "mainpll_d3", 331 + "univpll_d3" 332 + }; 333 + 334 + static const char * const dsp7_parents[] = { 335 + "clk26m", 336 + "univpll_d6_d2", 337 + "univpll_d4_d2", 338 + "univpll_d5", 339 + "univpll_d4", 340 + "mmpll_d4", 341 + "mainpll_d3", 342 + "univpll_d3" 343 + }; 344 + 345 + static const char * const mfg_core_tmp_parents[] = { 346 + "clk26m", 347 + "mainpll_d5_d2", 348 + "univpll_d6", 349 + "univpll_d7" 350 + }; 351 + 352 + static const char * const camtg_parents[] = { 353 + "clk26m", 354 + "univpll_192m_d8", 355 + "univpll_d6_d8", 356 + "univpll_192m_d4", 357 + "univpll_192m_d10", 358 + "clk13m", 359 + "univpll_192m_d16", 360 + "univpll_192m_d32" 361 + }; 362 + 363 + static const char * const camtg2_parents[] = { 364 + "clk26m", 365 + "univpll_192m_d8", 366 + "univpll_d6_d8", 367 + "univpll_192m_d4", 368 + "univpll_192m_d10", 369 + "clk13m", 370 + "univpll_192m_d16", 371 + "univpll_192m_d32" 372 + }; 373 + 374 + static const char * const camtg3_parents[] = { 375 + "clk26m", 376 + "univpll_192m_d8", 377 + "univpll_d6_d8", 378 + "univpll_192m_d4", 379 + "univpll_192m_d10", 380 + "clk13m", 381 + "univpll_192m_d16", 382 + "univpll_192m_d32" 383 + }; 384 + 385 + static const char * const uart_parents[] = { 386 + "clk26m", 387 + "univpll_d6_d8" 388 + }; 389 + 390 + static const char * const spi_parents[] = { 391 + "clk26m", 392 + "mainpll_d5_d4", 393 + "mainpll_d6_d4", 394 + "univpll_d6_d4", 395 + "univpll_d6_d2", 396 + "mainpll_d6_d2", 397 + "mainpll_d4_d4", 398 + "univpll_d5_d4" 399 + }; 400 + 401 + static const char * const msdc5hclk_parents[] = { 402 + "clk26m", 403 + "mainpll_d4_d2", 404 + "mainpll_d6_d2" 405 + }; 406 + 407 + static const char * const msdc50_0_parents[] = { 408 + "clk26m", 409 + "msdcpll", 410 + "msdcpll_d2", 411 + "univpll_d4_d4", 412 + "mainpll_d6_d2", 413 + "univpll_d4_d2" 414 + }; 415 + 416 + static const char * const msdc30_1_parents[] = { 417 + "clk26m", 418 + "univpll_d6_d2", 419 + "mainpll_d6_d2", 420 + "mainpll_d7_d2", 421 + "msdcpll_d2" 422 + }; 423 + 424 + static const char * const msdc30_2_parents[] = { 425 + "clk26m", 426 + "univpll_d6_d2", 427 + "mainpll_d6_d2", 428 + "mainpll_d7_d2", 429 + "msdcpll_d2" 430 + }; 431 + 432 + static const char * const intdir_parents[] = { 433 + "clk26m", 434 + "univpll_d6", 435 + "mainpll_d4", 436 + "univpll_d4" 437 + }; 438 + 439 + static const char * const aud_intbus_parents[] = { 440 + "clk26m", 441 + "mainpll_d4_d4", 442 + "mainpll_d7_d4" 443 + }; 444 + 445 + static const char * const audio_h_parents[] = { 446 + "clk26m", 447 + "univpll_d7", 448 + "apll1", 449 + "apll2" 450 + }; 451 + 452 + static const char * const pwrap_ulposc_parents[] = { 453 + "clk26m", 454 + "ulposc1_d10", 455 + "ulposc1_d7", 456 + "ulposc1_d8", 457 + "ulposc1_d16", 458 + "mainpll_d4_d8", 459 + "univpll_d5_d8", 460 + "tvdpll1_d16" 461 + }; 462 + 463 + static const char * const atb_parents[] = { 464 + "clk26m", 465 + "mainpll_d4_d2", 466 + "mainpll_d5_d2" 467 + }; 468 + 469 + static const char * const sspm_parents[] = { 470 + "clk26m", 471 + "mainpll_d7_d2", 472 + "mainpll_d6_d2", 473 + "mainpll_d5_d2", 474 + "mainpll_d9", 475 + "mainpll_d4_d2" 476 + }; 477 + 478 + static const char * const dp_parents[] = { 479 + "clk26m", 480 + "tvdpll1_d2", 481 + "tvdpll2_d2", 482 + "tvdpll1_d4", 483 + "tvdpll2_d4", 484 + "tvdpll1_d8", 485 + "tvdpll2_d8", 486 + "tvdpll1_d16", 487 + "tvdpll2_d16" 488 + }; 489 + 490 + static const char * const edp_parents[] = { 491 + "clk26m", 492 + "tvdpll1_d2", 493 + "tvdpll2_d2", 494 + "tvdpll1_d4", 495 + "tvdpll2_d4", 496 + "tvdpll1_d8", 497 + "tvdpll2_d8", 498 + "tvdpll1_d16", 499 + "tvdpll2_d16" 500 + }; 501 + 502 + static const char * const dpi_parents[] = { 503 + "clk26m", 504 + "tvdpll1_d2", 505 + "tvdpll2_d2", 506 + "tvdpll1_d4", 507 + "tvdpll2_d4", 508 + "tvdpll1_d8", 509 + "tvdpll2_d8", 510 + "tvdpll1_d16", 511 + "tvdpll2_d16" 512 + }; 513 + 514 + static const char * const disp_pwm0_parents[] = { 515 + "clk26m", 516 + "univpll_d6_d4", 517 + "ulposc1_d2", 518 + "ulposc1_d4", 519 + "ulposc1_d16", 520 + "ethpll_d4" 521 + }; 522 + 523 + static const char * const disp_pwm1_parents[] = { 524 + "clk26m", 525 + "univpll_d6_d4", 526 + "ulposc1_d2", 527 + "ulposc1_d4", 528 + "ulposc1_d16" 529 + }; 530 + 531 + static const char * const usb_parents[] = { 532 + "clk26m", 533 + "univpll_d5_d4", 534 + "univpll_d6_d4", 535 + "univpll_d5_d2" 536 + }; 537 + 538 + static const char * const ssusb_xhci_parents[] = { 539 + "clk26m", 540 + "univpll_d5_d4", 541 + "univpll_d6_d4", 542 + "univpll_d5_d2" 543 + }; 544 + 545 + static const char * const usb_2p_parents[] = { 546 + "clk26m", 547 + "univpll_d5_d4", 548 + "univpll_d6_d4", 549 + "univpll_d5_d2" 550 + }; 551 + 552 + static const char * const ssusb_xhci_2p_parents[] = { 553 + "clk26m", 554 + "univpll_d5_d4", 555 + "univpll_d6_d4", 556 + "univpll_d5_d2" 557 + }; 558 + 559 + static const char * const usb_3p_parents[] = { 560 + "clk26m", 561 + "univpll_d5_d4", 562 + "univpll_d6_d4", 563 + "univpll_d5_d2" 564 + }; 565 + 566 + static const char * const ssusb_xhci_3p_parents[] = { 567 + "clk26m", 568 + "univpll_d5_d4", 569 + "univpll_d6_d4", 570 + "univpll_d5_d2" 571 + }; 572 + 573 + static const char * const i2c_parents[] = { 574 + "clk26m", 575 + "mainpll_d4_d8", 576 + "univpll_d5_d4" 577 + }; 578 + 579 + static const char * const seninf_parents[] = { 580 + "clk26m", 581 + "univpll_d4_d4", 582 + "univpll_d6_d2", 583 + "mainpll_d4_d2", 584 + "univpll_d7", 585 + "univpll_d6", 586 + "mmpll_d6", 587 + "univpll_d5" 588 + }; 589 + 590 + static const char * const seninf1_parents[] = { 591 + "clk26m", 592 + "univpll_d4_d4", 593 + "univpll_d6_d2", 594 + "mainpll_d4_d2", 595 + "univpll_d7", 596 + "univpll_d6", 597 + "mmpll_d6", 598 + "univpll_d5" 599 + }; 600 + 601 + static const char * const gcpu_parents[] = { 602 + "clk26m", 603 + "mainpll_d6", 604 + "univpll_d4_d2", 605 + "mmpll_d5_d2", 606 + "univpll_d5_d2" 607 + }; 608 + 609 + static const char * const venc_parents[] = { 610 + "clk26m", 611 + "mmpll_d4_d2", 612 + "mainpll_d6", 613 + "univpll_d4_d2", 614 + "mainpll_d4_d2", 615 + "univpll_d6", 616 + "mmpll_d6", 617 + "mainpll_d5_d2", 618 + "mainpll_d6_d2", 619 + "mmpll_d9", 620 + "univpll_d4_d4", 621 + "mainpll_d4", 622 + "univpll_d4", 623 + "univpll_d5", 624 + "univpll_d5_d2", 625 + "mainpll_d5" 626 + }; 627 + 628 + static const char * const vdec_parents[] = { 629 + "clk26m", 630 + "mainpll_d5_d2", 631 + "mmpll_d6_d2", 632 + "univpll_d5_d2", 633 + "univpll_d4_d2", 634 + "mmpll_d4_d2", 635 + "univpll_d6", 636 + "mainpll_d5", 637 + "univpll_d5", 638 + "mmpll_d6", 639 + "mainpll_d4", 640 + "tvdpll2", 641 + "univpll_d4", 642 + "imgpll", 643 + "univpll_d6_d2", 644 + "mmpll_d9" 645 + }; 646 + 647 + static const char * const pwm_parents[] = { 648 + "clk32k", 649 + "clk26m", 650 + "univpll_d4_d8", 651 + "univpll_d6_d4" 652 + }; 653 + 654 + static const char * const mcupm_parents[] = { 655 + "clk26m", 656 + "mainpll_d6_d2", 657 + "mainpll_d7_d4" 658 + }; 659 + 660 + static const char * const spmi_p_mst_parents[] = { 661 + "clk26m", 662 + "clk13m", 663 + "ulposc1_d8", 664 + "ulposc1_d10", 665 + "ulposc1_d16", 666 + "ulposc1_d7", 667 + "clk32k", 668 + "mainpll_d7_d8", 669 + "mainpll_d6_d8", 670 + "mainpll_d5_d8" 671 + }; 672 + 673 + static const char * const spmi_m_mst_parents[] = { 674 + "clk26m", 675 + "clk13m", 676 + "ulposc1_d8", 677 + "ulposc1_d10", 678 + "ulposc1_d16", 679 + "ulposc1_d7", 680 + "clk32k", 681 + "mainpll_d7_d8", 682 + "mainpll_d6_d8", 683 + "mainpll_d5_d8" 684 + }; 685 + 686 + static const char * const dvfsrc_parents[] = { 687 + "clk26m", 688 + "ulposc1_d10", 689 + "univpll_d6_d8", 690 + "msdcpll_d16" 691 + }; 692 + 693 + static const char * const tl_parents[] = { 694 + "clk26m", 695 + "univpll_d5_d4", 696 + "mainpll_d4_d4" 697 + }; 698 + 699 + static const char * const aes_msdcfde_parents[] = { 700 + "clk26m", 701 + "mainpll_d4_d2", 702 + "mainpll_d6", 703 + "mainpll_d4_d4", 704 + "univpll_d4_d2", 705 + "univpll_d6" 706 + }; 707 + 708 + static const char * const dsi_occ_parents[] = { 709 + "clk26m", 710 + "univpll_d6_d2", 711 + "univpll_d5_d2", 712 + "univpll_d4_d2" 713 + }; 714 + 715 + static const char * const wpe_vpp_parents[] = { 716 + "clk26m", 717 + "mainpll_d5_d2", 718 + "mmpll_d6_d2", 719 + "univpll_d5_d2", 720 + "mainpll_d4_d2", 721 + "univpll_d4_d2", 722 + "mmpll_d4_d2", 723 + "mainpll_d6", 724 + "mmpll_d7", 725 + "univpll_d6", 726 + "mainpll_d5", 727 + "univpll_d5", 728 + "mainpll_d4", 729 + "tvdpll1", 730 + "univpll_d4" 731 + }; 732 + 733 + static const char * const hdcp_parents[] = { 734 + "clk26m", 735 + "univpll_d4_d8", 736 + "mainpll_d5_d8", 737 + "univpll_d6_d4" 738 + }; 739 + 740 + static const char * const hdcp_24m_parents[] = { 741 + "clk26m", 742 + "univpll_192m_d4", 743 + "univpll_192m_d8", 744 + "univpll_d6_d8" 745 + }; 746 + 747 + static const char * const hdmi_apb_parents[] = { 748 + "clk26m", 749 + "univpll_d6_d4", 750 + "msdcpll_d2" 751 + }; 752 + 753 + static const char * const snps_eth_250m_parents[] = { 754 + "clk26m", 755 + "ethpll_d2" 756 + }; 757 + 758 + static const char * const snps_eth_62p4m_ptp_parents[] = { 759 + "apll2_d3", 760 + "apll1_d3", 761 + "clk26m", 762 + "ethpll_d8" 763 + }; 764 + 765 + static const char * const snps_eth_50m_rmii_parents[] = { 766 + "clk26m", 767 + "ethpll_d10" 768 + }; 769 + 770 + static const char * const adsp_parents[] = { 771 + "clk26m", 772 + "clk13m", 773 + "mainpll_d6", 774 + "mainpll_d5_d2", 775 + "univpll_d4_d4", 776 + "univpll_d4", 777 + "ulposc1_d2", 778 + "ulposc1_ck1", 779 + "adsppll", 780 + "adsppll_d2", 781 + "adsppll_d4", 782 + "adsppll_d8" 783 + }; 784 + 785 + static const char * const audio_local_bus_parents[] = { 786 + "clk26m", 787 + "clk13m", 788 + "mainpll_d4_d4", 789 + "mainpll_d7_d2", 790 + "mainpll_d5_d2", 791 + "mainpll_d4_d2", 792 + "mainpll_d7", 793 + "mainpll_d4", 794 + "univpll_d6", 795 + "ulposc1_ck1", 796 + "ulposc1_d4", 797 + "ulposc1_d2" 798 + }; 799 + 800 + static const char * const asm_h_parents[] = { 801 + "clk26m", 802 + "univpll_d6_d4", 803 + "univpll_d6_d2", 804 + "mainpll_d5_d2" 805 + }; 806 + 807 + static const char * const asm_l_parents[] = { 808 + "clk26m", 809 + "univpll_d6_d4", 810 + "univpll_d6_d2", 811 + "mainpll_d5_d2" 812 + }; 813 + 814 + static const char * const apll1_parents[] = { 815 + "clk26m", 816 + "apll1_d4" 817 + }; 818 + 819 + static const char * const apll2_parents[] = { 820 + "clk26m", 821 + "apll2_d4" 822 + }; 823 + 824 + static const char * const apll3_parents[] = { 825 + "clk26m", 826 + "apll3_d4" 827 + }; 828 + 829 + static const char * const apll4_parents[] = { 830 + "clk26m", 831 + "apll4_d4" 832 + }; 833 + 834 + static const char * const apll5_parents[] = { 835 + "clk26m", 836 + "apll5_d4" 837 + }; 838 + 839 + static const char * const i2so1_parents[] = { 840 + "clk26m", 841 + "apll1", 842 + "apll2", 843 + "apll3", 844 + "apll4", 845 + "apll5" 846 + }; 847 + 848 + static const char * const i2so2_parents[] = { 849 + "clk26m", 850 + "apll1", 851 + "apll2", 852 + "apll3", 853 + "apll4", 854 + "apll5" 855 + }; 856 + 857 + static const char * const i2si1_parents[] = { 858 + "clk26m", 859 + "apll1", 860 + "apll2", 861 + "apll3", 862 + "apll4", 863 + "apll5" 864 + }; 865 + 866 + static const char * const i2si2_parents[] = { 867 + "clk26m", 868 + "apll1", 869 + "apll2", 870 + "apll3", 871 + "apll4", 872 + "apll5" 873 + }; 874 + 875 + static const char * const dptx_parents[] = { 876 + "clk26m", 877 + "apll1", 878 + "apll2", 879 + "apll3", 880 + "apll4", 881 + "apll5" 882 + }; 883 + 884 + static const char * const aud_iec_parents[] = { 885 + "clk26m", 886 + "apll1", 887 + "apll2", 888 + "apll3", 889 + "apll4", 890 + "apll5" 891 + }; 892 + 893 + static const char * const a1sys_hp_parents[] = { 894 + "clk26m", 895 + "apll1_d4" 896 + }; 897 + 898 + static const char * const a2sys_parents[] = { 899 + "clk26m", 900 + "apll2_d4" 901 + }; 902 + 903 + static const char * const a3sys_parents[] = { 904 + "clk26m", 905 + "apll3_d4", 906 + "apll4_d4", 907 + "apll5_d4" 908 + }; 909 + 910 + static const char * const a4sys_parents[] = { 911 + "clk26m", 912 + "apll3_d4", 913 + "apll4_d4", 914 + "apll5_d4" 915 + }; 916 + 917 + static const char * const ecc_parents[] = { 918 + "clk26m", 919 + "mainpll_d4_d4", 920 + "mainpll_d5_d2", 921 + "mainpll_d4_d2", 922 + "mainpll_d6", 923 + "univpll_d6" 924 + }; 925 + 926 + static const char * const spinor_parents[] = { 927 + "clk26m", 928 + "clk13m", 929 + "mainpll_d7_d8", 930 + "univpll_d6_d8" 931 + }; 932 + 933 + static const char * const ulposc_parents[] = { 934 + "ulposc_ck1", 935 + "ethpll_d2", 936 + "mainpll_d4_d2", 937 + "ethpll_d10" 938 + }; 939 + 940 + static const char * const srck_parents[] = { 941 + "ulposc1_d10", 942 + "clk26m" 943 + }; 944 + 945 + static const char * const mfg_fast_ref_parents[] = { 946 + "top_mfg_core_tmp", 947 + "mfgpll" 948 + }; 949 + 950 + static const struct mtk_mux top_mtk_muxes[] = { 951 + /* 952 + * CLK_CFG_0 953 + * axi_sel and bus_aximem_sel are bus clocks, should not be closed by Linux. 954 + * spm_sel and scp_sel are main clocks in always-on co-processor. 955 + */ 956 + MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_AXI, "top_axi", axi_parents, 957 + 0x020, 0x024, 0x028, 0, 4, 7, 0x04, 0, CLK_IS_CRITICAL), 958 + MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_SPM, "top_spm", spm_parents, 959 + 0x020, 0x024, 0x028, 8, 4, 15, 0x04, 1, CLK_IS_CRITICAL), 960 + MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_SCP, "top_scp", scp_parents, 961 + 0x020, 0x024, 0x028, 16, 4, 23, 0x04, 2, CLK_IS_CRITICAL), 962 + MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_BUS_AXIMEM, "top_bus_aximem", bus_aximem_parents, 963 + 0x020, 0x024, 0x028, 24, 4, 31, 0x04, 3, CLK_IS_CRITICAL), 964 + /* CLK_CFG_1 */ 965 + MUX_GATE_CLR_SET_UPD(CLK_TOP_VPP, "top_vpp", 966 + vpp_parents, 0x02C, 0x030, 0x034, 0, 4, 7, 0x04, 4), 967 + MUX_GATE_CLR_SET_UPD(CLK_TOP_ETHDR, "top_ethdr", 968 + ethdr_parents, 0x02C, 0x030, 0x034, 8, 4, 15, 0x04, 5), 969 + MUX_GATE_CLR_SET_UPD(CLK_TOP_IPE, "top_ipe", 970 + ipe_parents, 0x02C, 0x030, 0x034, 16, 4, 23, 0x04, 6), 971 + MUX_GATE_CLR_SET_UPD(CLK_TOP_CAM, "top_cam", 972 + cam_parents, 0x02C, 0x030, 0x034, 24, 4, 31, 0x04, 7), 973 + /* CLK_CFG_2 */ 974 + MUX_GATE_CLR_SET_UPD(CLK_TOP_CCU, "top_ccu", 975 + ccu_parents, 0x038, 0x03C, 0x040, 0, 4, 7, 0x04, 8), 976 + MUX_GATE_CLR_SET_UPD(CLK_TOP_CCU_AHB, "top_ccu_ahb", 977 + ccu_ahb_parents, 0x038, 0x03C, 0x040, 8, 4, 15, 0x04, 9), 978 + MUX_GATE_CLR_SET_UPD(CLK_TOP_IMG, "top_img", 979 + img_parents, 0x038, 0x03C, 0x040, 16, 4, 23, 0x04, 10), 980 + MUX_GATE_CLR_SET_UPD(CLK_TOP_CAMTM, "top_camtm", 981 + camtm_parents, 0x038, 0x03C, 0x040, 24, 4, 31, 0x04, 11), 982 + /* CLK_CFG_3 */ 983 + MUX_GATE_CLR_SET_UPD(CLK_TOP_DSP, "top_dsp", 984 + dsp_parents, 0x044, 0x048, 0x04C, 0, 4, 7, 0x04, 12), 985 + MUX_GATE_CLR_SET_UPD(CLK_TOP_DSP1, "top_dsp1", 986 + dsp1_parents, 0x044, 0x048, 0x04C, 8, 4, 15, 0x04, 13), 987 + MUX_GATE_CLR_SET_UPD(CLK_TOP_DSP2, "top_dsp2", 988 + dsp2_parents, 0x044, 0x048, 0x04C, 16, 4, 23, 0x04, 14), 989 + MUX_GATE_CLR_SET_UPD(CLK_TOP_DSP3, "top_dsp3", 990 + dsp3_parents, 0x044, 0x048, 0x04C, 24, 4, 31, 0x04, 15), 991 + /* CLK_CFG_4 */ 992 + MUX_GATE_CLR_SET_UPD(CLK_TOP_DSP4, "top_dsp4", 993 + dsp4_parents, 0x050, 0x054, 0x058, 0, 4, 7, 0x04, 16), 994 + MUX_GATE_CLR_SET_UPD(CLK_TOP_DSP5, "top_dsp5", 995 + dsp5_parents, 0x050, 0x054, 0x058, 8, 4, 15, 0x04, 17), 996 + MUX_GATE_CLR_SET_UPD(CLK_TOP_DSP6, "top_dsp6", 997 + dsp6_parents, 0x050, 0x054, 0x058, 16, 4, 23, 0x04, 18), 998 + MUX_GATE_CLR_SET_UPD(CLK_TOP_DSP7, "top_dsp7", 999 + dsp7_parents, 0x050, 0x054, 0x058, 24, 4, 31, 0x04, 19), 1000 + /* CLK_CFG_5 */ 1001 + MUX_GATE_CLR_SET_UPD(CLK_TOP_MFG_CORE_TMP, "top_mfg_core_tmp", 1002 + mfg_core_tmp_parents, 0x05C, 0x060, 0x064, 0, 4, 7, 0x04, 20), 1003 + MUX_GATE_CLR_SET_UPD(CLK_TOP_CAMTG, "top_camtg", 1004 + camtg_parents, 0x05C, 0x060, 0x064, 8, 4, 15, 0x04, 21), 1005 + MUX_GATE_CLR_SET_UPD(CLK_TOP_CAMTG2, "top_camtg2", 1006 + camtg2_parents, 0x05C, 0x060, 0x064, 16, 4, 23, 0x04, 22), 1007 + MUX_GATE_CLR_SET_UPD(CLK_TOP_CAMTG3, "top_camtg3", 1008 + camtg3_parents, 0x05C, 0x060, 0x064, 24, 4, 31, 0x04, 23), 1009 + /* CLK_CFG_6 */ 1010 + MUX_GATE_CLR_SET_UPD(CLK_TOP_UART, "top_uart", 1011 + uart_parents, 0x068, 0x06C, 0x070, 0, 4, 7, 0x04, 24), 1012 + MUX_GATE_CLR_SET_UPD(CLK_TOP_SPI, "top_spi", 1013 + spi_parents, 0x068, 0x06C, 0x070, 8, 4, 15, 0x04, 25), 1014 + MUX_GATE_CLR_SET_UPD(CLK_TOP_MSDC50_0_HCLK, "top_msdc5hclk", 1015 + msdc5hclk_parents, 0x068, 0x06C, 0x070, 16, 4, 23, 0x04, 26), 1016 + MUX_GATE_CLR_SET_UPD(CLK_TOP_MSDC50_0, "top_msdc50_0", 1017 + msdc50_0_parents, 0x068, 0x06C, 0x070, 24, 4, 31, 0x04, 27), 1018 + /* CLK_CFG_7 */ 1019 + MUX_GATE_CLR_SET_UPD(CLK_TOP_MSDC30_1, "top_msdc30_1", 1020 + msdc30_1_parents, 0x074, 0x078, 0x07C, 0, 4, 7, 0x04, 28), 1021 + MUX_GATE_CLR_SET_UPD(CLK_TOP_MSDC30_2, "top_msdc30_2", 1022 + msdc30_2_parents, 0x074, 0x078, 0x07C, 8, 4, 15, 0x04, 29), 1023 + MUX_GATE_CLR_SET_UPD(CLK_TOP_INTDIR, "top_intdir", 1024 + intdir_parents, 0x074, 0x078, 0x07C, 16, 4, 23, 0x04, 30), 1025 + MUX_GATE_CLR_SET_UPD(CLK_TOP_AUD_INTBUS, "top_aud_intbus", 1026 + aud_intbus_parents, 0x074, 0x078, 0x07C, 24, 4, 31, 0x04, 31), 1027 + /* CLK_CFG_8 */ 1028 + MUX_GATE_CLR_SET_UPD(CLK_TOP_AUDIO_H, "top_audio_h", 1029 + audio_h_parents, 0x080, 0x084, 0x088, 0, 4, 7, 0x08, 0), 1030 + MUX_GATE_CLR_SET_UPD(CLK_TOP_PWRAP_ULPOSC, "top_pwrap_ulposc", 1031 + pwrap_ulposc_parents, 0x080, 0x084, 0x088, 8, 4, 15, 0x08, 1), 1032 + MUX_GATE_CLR_SET_UPD(CLK_TOP_ATB, "top_atb", 1033 + atb_parents, 0x080, 0x084, 0x088, 16, 4, 23, 0x08, 2), 1034 + MUX_GATE_CLR_SET_UPD(CLK_TOP_SSPM, "top_sspm", 1035 + sspm_parents, 0x080, 0x084, 0x088, 24, 4, 31, 0x08, 3), 1036 + /* CLK_CFG_9 */ 1037 + MUX_GATE_CLR_SET_UPD(CLK_TOP_DP, "top_dp", 1038 + dp_parents, 0x08C, 0x090, 0x094, 0, 4, 7, 0x08, 4), 1039 + MUX_GATE_CLR_SET_UPD(CLK_TOP_EDP, "top_edp", 1040 + edp_parents, 0x08C, 0x090, 0x094, 8, 4, 15, 0x08, 5), 1041 + MUX_GATE_CLR_SET_UPD(CLK_TOP_DPI, "top_dpi", 1042 + dpi_parents, 0x08C, 0x090, 0x094, 16, 4, 23, 0x08, 6), 1043 + MUX_GATE_CLR_SET_UPD(CLK_TOP_DISP_PWM0, "top_disp_pwm0", 1044 + disp_pwm0_parents, 0x08C, 0x090, 0x094, 24, 4, 31, 0x08, 7), 1045 + /* CLK_CFG_10 */ 1046 + MUX_GATE_CLR_SET_UPD(CLK_TOP_DISP_PWM1, "top_disp_pwm1", 1047 + disp_pwm1_parents, 0x098, 0x09C, 0x0A0, 0, 4, 7, 0x08, 8), 1048 + MUX_GATE_CLR_SET_UPD(CLK_TOP_USB_TOP, "top_usb_top", 1049 + usb_parents, 0x098, 0x09C, 0x0A0, 8, 4, 15, 0x08, 9), 1050 + MUX_GATE_CLR_SET_UPD(CLK_TOP_SSUSB_XHCI, "top_ssusb_xhci", 1051 + ssusb_xhci_parents, 0x098, 0x09C, 0x0A0, 16, 4, 23, 0x08, 10), 1052 + MUX_GATE_CLR_SET_UPD(CLK_TOP_USB_TOP_2P, "top_usb_top_2p", 1053 + usb_2p_parents, 0x098, 0x09C, 0x0A0, 24, 4, 31, 0x08, 11), 1054 + /* CLK_CFG_11 */ 1055 + MUX_GATE_CLR_SET_UPD(CLK_TOP_SSUSB_XHCI_2P, "top_ssusb_xhci_2p", 1056 + ssusb_xhci_2p_parents, 0x0A4, 0x0A8, 0x0AC, 0, 4, 7, 0x08, 12), 1057 + MUX_GATE_CLR_SET_UPD(CLK_TOP_USB_TOP_3P, "top_usb_top_3p", 1058 + usb_3p_parents, 0x0A4, 0x0A8, 0x0AC, 8, 4, 15, 0x08, 13), 1059 + MUX_GATE_CLR_SET_UPD(CLK_TOP_SSUSB_XHCI_3P, "top_ssusb_xhci_3p", 1060 + ssusb_xhci_3p_parents, 0x0A4, 0x0A8, 0x0AC, 16, 4, 23, 0x08, 14), 1061 + MUX_GATE_CLR_SET_UPD(CLK_TOP_I2C, "top_i2c", 1062 + i2c_parents, 0x0A4, 0x0A8, 0x0AC, 24, 4, 31, 0x08, 15), 1063 + /* CLK_CFG_12 */ 1064 + MUX_GATE_CLR_SET_UPD(CLK_TOP_SENINF, "top_seninf", 1065 + seninf_parents, 0x0B0, 0x0B4, 0x0B8, 0, 4, 7, 0x08, 16), 1066 + MUX_GATE_CLR_SET_UPD(CLK_TOP_SENINF1, "top_seninf1", 1067 + seninf1_parents, 0x0B0, 0x0B4, 0x0B8, 8, 4, 15, 0x08, 17), 1068 + MUX_GATE_CLR_SET_UPD(CLK_TOP_GCPU, "top_gcpu", 1069 + gcpu_parents, 0x0B0, 0x0B4, 0x0B8, 16, 4, 23, 0x08, 18), 1070 + MUX_GATE_CLR_SET_UPD(CLK_TOP_VENC, "top_venc", 1071 + venc_parents, 0x0B0, 0x0B4, 0x0B8, 24, 4, 31, 0x08, 19), 1072 + /* 1073 + * CLK_CFG_13 1074 + * top_mcupm is main clock in co-processor, should not be handled by Linux. 1075 + */ 1076 + MUX_GATE_CLR_SET_UPD(CLK_TOP_VDEC, "top_vdec", 1077 + vdec_parents, 0x0BC, 0x0C0, 0x0C4, 0, 4, 7, 0x08, 20), 1078 + MUX_GATE_CLR_SET_UPD(CLK_TOP_PWM, "top_pwm", 1079 + pwm_parents, 0x0BC, 0x0C0, 0x0C4, 8, 4, 15, 0x08, 21), 1080 + MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_MCUPM, "top_mcupm", mcupm_parents, 1081 + 0x0BC, 0x0C0, 0x0C4, 16, 4, 23, 0x08, 22, CLK_IS_CRITICAL), 1082 + MUX_GATE_CLR_SET_UPD(CLK_TOP_SPMI_P_MST, "top_spmi_p_mst", 1083 + spmi_p_mst_parents, 0x0BC, 0x0C0, 0x0C4, 24, 4, 31, 0x08, 23), 1084 + /* 1085 + * CLK_CFG_14 1086 + * dvfsrc_sel is for internal DVFS usage, should not be handled by Linux. 1087 + */ 1088 + MUX_GATE_CLR_SET_UPD(CLK_TOP_SPMI_M_MST, "top_spmi_m_mst", 1089 + spmi_m_mst_parents, 0x0C8, 0x0CC, 0x0D0, 0, 4, 7, 0x08, 24), 1090 + MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_DVFSRC, "top_dvfsrc", dvfsrc_parents, 1091 + 0x0C8, 0x0CC, 0x0D0, 8, 4, 15, 0x08, 25, CLK_IS_CRITICAL), 1092 + MUX_GATE_CLR_SET_UPD(CLK_TOP_TL, "top_tl", 1093 + tl_parents, 0x0C8, 0x0CC, 0x0D0, 16, 4, 23, 0x08, 26), 1094 + MUX_GATE_CLR_SET_UPD(CLK_TOP_AES_MSDCFDE, "top_aes_msdcfde", 1095 + aes_msdcfde_parents, 0x0C8, 0x0CC, 0x0D0, 24, 4, 31, 0x08, 27), 1096 + /* CLK_CFG_15 */ 1097 + MUX_GATE_CLR_SET_UPD(CLK_TOP_DSI_OCC, "top_dsi_occ", 1098 + dsi_occ_parents, 0x0D4, 0x0D8, 0x0DC, 0, 4, 7, 0x08, 28), 1099 + MUX_GATE_CLR_SET_UPD(CLK_TOP_WPE_VPP, "top_wpe_vpp", 1100 + wpe_vpp_parents, 0x0D4, 0x0D8, 0x0DC, 8, 4, 15, 0x08, 29), 1101 + MUX_GATE_CLR_SET_UPD(CLK_TOP_HDCP, "top_hdcp", 1102 + hdcp_parents, 0x0D4, 0x0D8, 0x0DC, 16, 4, 23, 0x08, 30), 1103 + MUX_GATE_CLR_SET_UPD(CLK_TOP_HDCP_24M, "top_hdcp_24m", 1104 + hdcp_24m_parents, 0x0D4, 0x0D8, 0x0DC, 24, 4, 31, 0x08, 31), 1105 + /* CLK_CFG_16 */ 1106 + MUX_GATE_CLR_SET_UPD(CLK_TOP_HDMI_APB, "top_hdmi_apb", 1107 + hdmi_apb_parents, 0x0E0, 0x0E4, 0x0E8, 0, 4, 7, 0x0C, 0), 1108 + MUX_GATE_CLR_SET_UPD(CLK_TOP_SNPS_ETH_250M, "top_snps_eth_250m", 1109 + snps_eth_250m_parents, 0x0E0, 0x0E4, 0x0E8, 8, 4, 15, 0x0C, 1), 1110 + MUX_GATE_CLR_SET_UPD(CLK_TOP_SNPS_ETH_62P4M_PTP, "top_snps_eth_62p4m_ptp", 1111 + snps_eth_62p4m_ptp_parents, 0x0E0, 0x0E4, 0x0E8, 16, 4, 23, 0x0C, 2), 1112 + MUX_GATE_CLR_SET_UPD(CLK_TOP_SNPS_ETH_50M_RMII, "snps_eth_50m_rmii", 1113 + snps_eth_50m_rmii_parents, 0x0E0, 0x0E4, 0x0E8, 24, 4, 31, 0x0C, 3), 1114 + /* CLK_CFG_17 */ 1115 + MUX_GATE_CLR_SET_UPD(CLK_TOP_ADSP, "top_adsp", 1116 + adsp_parents, 0x0EC, 0x0F0, 0x0F4, 0, 4, 7, 0x0C, 4), 1117 + MUX_GATE_CLR_SET_UPD(CLK_TOP_AUDIO_LOCAL_BUS, "top_audio_local_bus", 1118 + audio_local_bus_parents, 0x0EC, 0x0F0, 0x0F4, 8, 4, 15, 0x0C, 5), 1119 + MUX_GATE_CLR_SET_UPD(CLK_TOP_ASM_H, "top_asm_h", 1120 + asm_h_parents, 0x0EC, 0x0F0, 0x0F4, 16, 4, 23, 0x0C, 6), 1121 + MUX_GATE_CLR_SET_UPD(CLK_TOP_ASM_L, "top_asm_l", 1122 + asm_l_parents, 0x0EC, 0x0F0, 0x0F4, 24, 4, 31, 0x0C, 7), 1123 + /* CLK_CFG_18 */ 1124 + MUX_GATE_CLR_SET_UPD(CLK_TOP_APLL1, "top_apll1", 1125 + apll1_parents, 0x0F8, 0x0FC, 0x100, 0, 4, 7, 0x0C, 8), 1126 + MUX_GATE_CLR_SET_UPD(CLK_TOP_APLL2, "top_apll2", 1127 + apll2_parents, 0x0F8, 0x0FC, 0x100, 8, 4, 15, 0x0C, 9), 1128 + MUX_GATE_CLR_SET_UPD(CLK_TOP_APLL3, "top_apll3", 1129 + apll3_parents, 0x0F8, 0x0FC, 0x100, 16, 4, 23, 0x0C, 10), 1130 + MUX_GATE_CLR_SET_UPD(CLK_TOP_APLL4, "top_apll4", 1131 + apll4_parents, 0x0F8, 0x0FC, 0x100, 24, 4, 31, 0x0C, 11), 1132 + /* CLK_CFG_19 */ 1133 + MUX_GATE_CLR_SET_UPD(CLK_TOP_APLL5, "top_apll5", 1134 + apll5_parents, 0x0104, 0x0108, 0x010C, 0, 4, 7, 0x0C, 12), 1135 + MUX_GATE_CLR_SET_UPD(CLK_TOP_I2SO1, "top_i2so1", 1136 + i2so1_parents, 0x0104, 0x0108, 0x010C, 8, 4, 15, 0x0C, 13), 1137 + MUX_GATE_CLR_SET_UPD(CLK_TOP_I2SO2, "top_i2so2", 1138 + i2so2_parents, 0x0104, 0x0108, 0x010C, 16, 4, 23, 0x0C, 14), 1139 + MUX_GATE_CLR_SET_UPD(CLK_TOP_I2SI1, "top_i2si1", 1140 + i2si1_parents, 0x0104, 0x0108, 0x010C, 24, 4, 31, 0x0C, 15), 1141 + /* CLK_CFG_20 */ 1142 + MUX_GATE_CLR_SET_UPD(CLK_TOP_I2SI2, "top_i2si2", 1143 + i2si2_parents, 0x0110, 0x0114, 0x0118, 0, 4, 7, 0x0C, 16), 1144 + MUX_GATE_CLR_SET_UPD(CLK_TOP_DPTX, "top_dptx", 1145 + dptx_parents, 0x0110, 0x0114, 0x0118, 8, 4, 15, 0x0C, 17), 1146 + MUX_GATE_CLR_SET_UPD(CLK_TOP_AUD_IEC, "top_aud_iec", 1147 + aud_iec_parents, 0x0110, 0x0114, 0x0118, 16, 4, 23, 0x0C, 18), 1148 + MUX_GATE_CLR_SET_UPD(CLK_TOP_A1SYS_HP, "top_a1sys_hp", 1149 + a1sys_hp_parents, 0x0110, 0x0114, 0x0118, 24, 4, 31, 0x0C, 19), 1150 + /* CLK_CFG_21 */ 1151 + MUX_GATE_CLR_SET_UPD(CLK_TOP_A2SYS, "top_a2sys", 1152 + a2sys_parents, 0x011C, 0x0120, 0x0124, 0, 4, 7, 0x0C, 20), 1153 + MUX_GATE_CLR_SET_UPD(CLK_TOP_A3SYS, "top_a3sys", 1154 + a3sys_parents, 0x011C, 0x0120, 0x0124, 8, 4, 15, 0x0C, 21), 1155 + MUX_GATE_CLR_SET_UPD(CLK_TOP_A4SYS, "top_a4sys", 1156 + a4sys_parents, 0x011C, 0x0120, 0x0124, 16, 4, 23, 0x0C, 22), 1157 + MUX_GATE_CLR_SET_UPD(CLK_TOP_ECC, "top_ecc", 1158 + ecc_parents, 0x011C, 0x0120, 0x0124, 24, 4, 31, 0x0C, 23), 1159 + /* 1160 + * CLK_CFG_22 1161 + * top_ulposc/top_srck are clock source of always on co-processor, 1162 + * should not be closed by Linux. 1163 + */ 1164 + MUX_GATE_CLR_SET_UPD(CLK_TOP_SPINOR, "top_spinor", 1165 + spinor_parents, 0x0128, 0x012C, 0x0130, 0, 4, 7, 0x0C, 24), 1166 + MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_ULPOSC, "top_ulposc", ulposc_parents, 1167 + 0x0128, 0x012C, 0x0130, 8, 4, 15, 0x0C, 25, CLK_IS_CRITICAL), 1168 + MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_SRCK, "top_srck", srck_parents, 1169 + 0x0128, 0x012C, 0x0130, 16, 4, 23, 0x0C, 26, CLK_IS_CRITICAL), 1170 + }; 1171 + 1172 + static const struct mtk_composite top_adj_divs[] = { 1173 + DIV_GATE(CLK_TOP_APLL12_CK_DIV0, "apll12_div0", "top_i2si1", 0x0320, 0, 0x0328, 8, 0), 1174 + DIV_GATE(CLK_TOP_APLL12_CK_DIV1, "apll12_div1", "top_i2si2", 0x0320, 1, 0x0328, 8, 8), 1175 + DIV_GATE(CLK_TOP_APLL12_CK_DIV2, "apll12_div2", "top_i2so1", 0x0320, 2, 0x0328, 8, 16), 1176 + DIV_GATE(CLK_TOP_APLL12_CK_DIV3, "apll12_div3", "top_i2so2", 0x0320, 3, 0x0328, 8, 24), 1177 + DIV_GATE(CLK_TOP_APLL12_CK_DIV4, "apll12_div4", "top_aud_iec", 0x0320, 4, 0x0334, 8, 0), 1178 + DIV_GATE(CLK_TOP_APLL12_CK_DIV9, "apll12_div9", "top_dptx", 0x0320, 9, 0x0338, 8, 8), 1179 + }; 1180 + static const struct mtk_gate_regs top0_cg_regs = { 1181 + .set_ofs = 0x238, 1182 + .clr_ofs = 0x238, 1183 + .sta_ofs = 0x238, 1184 + }; 1185 + 1186 + static const struct mtk_gate_regs top1_cg_regs = { 1187 + .set_ofs = 0x250, 1188 + .clr_ofs = 0x250, 1189 + .sta_ofs = 0x250, 1190 + }; 1191 + 1192 + #define GATE_TOP0(_id, _name, _parent, _shift) \ 1193 + GATE_MTK(_id, _name, _parent, &top0_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv) 1194 + 1195 + #define GATE_TOP1(_id, _name, _parent, _shift) \ 1196 + GATE_MTK(_id, _name, _parent, &top1_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv) 1197 + 1198 + static const struct mtk_gate top_clks[] = { 1199 + /* TOP0 */ 1200 + GATE_TOP0(CLK_TOP_CFGREG_CLOCK_EN_VPP0, "cfgreg_clock_vpp0", "top_vpp", 0), 1201 + GATE_TOP0(CLK_TOP_CFGREG_CLOCK_EN_VPP1, "cfgreg_clock_vpp1", "top_vpp", 1), 1202 + GATE_TOP0(CLK_TOP_CFGREG_CLOCK_EN_VDO0, "cfgreg_clock_vdo0", "top_vpp", 2), 1203 + GATE_TOP0(CLK_TOP_CFGREG_CLOCK_EN_VDO1, "cfgreg_clock_vdo1", "top_vpp", 3), 1204 + GATE_TOP0(CLK_TOP_CFGREG_CLOCK_ISP_AXI_GALS, "cfgreg_clock_isp_axi_gals", "top_vpp", 4), 1205 + GATE_TOP0(CLK_TOP_CFGREG_F26M_VPP0, "cfgreg_f26m_vpp0", "clk26m", 5), 1206 + GATE_TOP0(CLK_TOP_CFGREG_F26M_VPP1, "cfgreg_f26m_vpp1", "clk26m", 6), 1207 + GATE_TOP0(CLK_TOP_CFGREG_F26M_VDO0, "cfgreg_f26m_vdo0", "clk26m", 7), 1208 + GATE_TOP0(CLK_TOP_CFGREG_F26M_VDO1, "cfgreg_f26m_vdo1", "clk26m", 8), 1209 + GATE_TOP0(CLK_TOP_CFGREG_AUD_F26M_AUD, "cfgreg_aud_f26m_aud", "clk26m", 9), 1210 + GATE_TOP0(CLK_TOP_CFGREG_UNIPLL_SES, "cfgreg_unipll_ses", "univpll_d2", 15), 1211 + GATE_TOP0(CLK_TOP_CFGREG_F_PCIE_PHY_REF, "cfgreg_f_pcie_phy_ref", "clk26m", 18), 1212 + /* TOP1 */ 1213 + GATE_TOP1(CLK_TOP_SSUSB_TOP_REF, "ssusb_ref", "clk26m", 0), 1214 + GATE_TOP1(CLK_TOP_SSUSB_PHY_REF, "ssusb_phy_ref", "clk26m", 1), 1215 + GATE_TOP1(CLK_TOP_SSUSB_TOP_P1_REF, "ssusb_p1_ref", "clk26m", 2), 1216 + GATE_TOP1(CLK_TOP_SSUSB_PHY_P1_REF, "ssusb_phy_p1_ref", "clk26m", 3), 1217 + GATE_TOP1(CLK_TOP_SSUSB_TOP_P2_REF, "ssusb_p2_ref", "clk26m", 4), 1218 + GATE_TOP1(CLK_TOP_SSUSB_PHY_P2_REF, "ssusb_phy_p2_ref", "clk26m", 5), 1219 + GATE_TOP1(CLK_TOP_SSUSB_TOP_P3_REF, "ssusb_p3_ref", "clk26m", 6), 1220 + GATE_TOP1(CLK_TOP_SSUSB_PHY_P3_REF, "ssusb_phy_p3_ref", "clk26m", 7), 1221 + }; 1222 + 1223 + static const struct of_device_id of_match_clk_mt8188_topck[] = { 1224 + { .compatible = "mediatek,mt8188-topckgen" }, 1225 + { /* sentinel */ } 1226 + }; 1227 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8188_topck); 1228 + 1229 + /* Register mux notifier for MFG mux */ 1230 + static int clk_mt8188_reg_mfg_mux_notifier(struct device *dev, struct clk *clk) 1231 + { 1232 + struct mtk_mux_nb *mfg_mux_nb; 1233 + 1234 + mfg_mux_nb = devm_kzalloc(dev, sizeof(*mfg_mux_nb), GFP_KERNEL); 1235 + if (!mfg_mux_nb) 1236 + return -ENOMEM; 1237 + 1238 + mfg_mux_nb->ops = &clk_mux_ops; 1239 + mfg_mux_nb->bypass_index = 0; /* Bypass to TOP_MFG_CORE_TMP */ 1240 + 1241 + return devm_mtk_clk_mux_notifier_register(dev, clk, mfg_mux_nb); 1242 + } 1243 + 1244 + static int clk_mt8188_topck_probe(struct platform_device *pdev) 1245 + { 1246 + struct clk_hw_onecell_data *top_clk_data; 1247 + struct device_node *node = pdev->dev.of_node; 1248 + struct clk_hw *hw; 1249 + int r; 1250 + void __iomem *base; 1251 + 1252 + top_clk_data = mtk_alloc_clk_data(CLK_TOP_NR_CLK); 1253 + if (!top_clk_data) 1254 + return -ENOMEM; 1255 + 1256 + base = devm_platform_ioremap_resource(pdev, 0); 1257 + if (IS_ERR(base)) { 1258 + r = PTR_ERR(base); 1259 + goto free_top_data; 1260 + } 1261 + 1262 + r = mtk_clk_register_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks), 1263 + top_clk_data); 1264 + if (r) 1265 + goto free_top_data; 1266 + 1267 + r = mtk_clk_register_factors(top_divs, ARRAY_SIZE(top_divs), top_clk_data); 1268 + if (r) 1269 + goto unregister_fixed_clks; 1270 + 1271 + r = mtk_clk_register_muxes(&pdev->dev, top_mtk_muxes, 1272 + ARRAY_SIZE(top_mtk_muxes), node, 1273 + &mt8188_clk_lock, top_clk_data); 1274 + if (r) 1275 + goto unregister_factors; 1276 + 1277 + hw = devm_clk_hw_register_mux(&pdev->dev, "mfg_ck_fast_ref", mfg_fast_ref_parents, 1278 + ARRAY_SIZE(mfg_fast_ref_parents), CLK_SET_RATE_PARENT, 1279 + (base + 0x250), 8, 1, 0, &mt8188_clk_lock); 1280 + if (IS_ERR(hw)) { 1281 + r = PTR_ERR(hw); 1282 + goto unregister_muxes; 1283 + } 1284 + top_clk_data->hws[CLK_TOP_MFG_CK_FAST_REF] = hw; 1285 + 1286 + r = clk_mt8188_reg_mfg_mux_notifier(&pdev->dev, 1287 + top_clk_data->hws[CLK_TOP_MFG_CK_FAST_REF]->clk); 1288 + if (r) 1289 + goto unregister_muxes; 1290 + 1291 + r = mtk_clk_register_composites(&pdev->dev, top_adj_divs, 1292 + ARRAY_SIZE(top_adj_divs), base, 1293 + &mt8188_clk_lock, top_clk_data); 1294 + if (r) 1295 + goto unregister_muxes; 1296 + 1297 + r = mtk_clk_register_gates(&pdev->dev, node, top_clks, 1298 + ARRAY_SIZE(top_clks), top_clk_data); 1299 + if (r) 1300 + goto unregister_composite_divs; 1301 + 1302 + r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, top_clk_data); 1303 + if (r) 1304 + goto unregister_gates; 1305 + 1306 + platform_set_drvdata(pdev, top_clk_data); 1307 + 1308 + return r; 1309 + 1310 + unregister_gates: 1311 + mtk_clk_unregister_gates(top_clks, ARRAY_SIZE(top_clks), top_clk_data); 1312 + unregister_composite_divs: 1313 + mtk_clk_unregister_composites(top_adj_divs, ARRAY_SIZE(top_adj_divs), top_clk_data); 1314 + unregister_muxes: 1315 + mtk_clk_unregister_muxes(top_mtk_muxes, ARRAY_SIZE(top_mtk_muxes), top_clk_data); 1316 + unregister_factors: 1317 + mtk_clk_unregister_factors(top_divs, ARRAY_SIZE(top_divs), top_clk_data); 1318 + unregister_fixed_clks: 1319 + mtk_clk_unregister_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks), top_clk_data); 1320 + free_top_data: 1321 + mtk_free_clk_data(top_clk_data); 1322 + return r; 1323 + } 1324 + 1325 + static int clk_mt8188_topck_remove(struct platform_device *pdev) 1326 + { 1327 + struct clk_hw_onecell_data *top_clk_data = platform_get_drvdata(pdev); 1328 + struct device_node *node = pdev->dev.of_node; 1329 + 1330 + of_clk_del_provider(node); 1331 + mtk_clk_unregister_gates(top_clks, ARRAY_SIZE(top_clks), top_clk_data); 1332 + mtk_clk_unregister_composites(top_adj_divs, ARRAY_SIZE(top_adj_divs), top_clk_data); 1333 + mtk_clk_unregister_muxes(top_mtk_muxes, ARRAY_SIZE(top_mtk_muxes), top_clk_data); 1334 + mtk_clk_unregister_factors(top_divs, ARRAY_SIZE(top_divs), top_clk_data); 1335 + mtk_clk_unregister_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks), top_clk_data); 1336 + mtk_free_clk_data(top_clk_data); 1337 + 1338 + return 0; 1339 + } 1340 + 1341 + static struct platform_driver clk_mt8188_topck_drv = { 1342 + .probe = clk_mt8188_topck_probe, 1343 + .remove = clk_mt8188_topck_remove, 1344 + .driver = { 1345 + .name = "clk-mt8188-topck", 1346 + .of_match_table = of_match_clk_mt8188_topck, 1347 + }, 1348 + }; 1349 + module_platform_driver(clk_mt8188_topck_drv); 1350 + MODULE_LICENSE("GPL");
+92
drivers/clk/mediatek/clk-mt8188-vdec.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Copyright (c) 2022 MediaTek Inc. 4 + * Author: Garmin Chang <garmin.chang@mediatek.com> 5 + */ 6 + 7 + #include <dt-bindings/clock/mediatek,mt8188-clk.h> 8 + #include <linux/clk-provider.h> 9 + #include <linux/platform_device.h> 10 + 11 + #include "clk-gate.h" 12 + #include "clk-mtk.h" 13 + 14 + static const struct mtk_gate_regs vdec0_cg_regs = { 15 + .set_ofs = 0x0, 16 + .clr_ofs = 0x4, 17 + .sta_ofs = 0x0, 18 + }; 19 + 20 + static const struct mtk_gate_regs vdec1_cg_regs = { 21 + .set_ofs = 0x200, 22 + .clr_ofs = 0x204, 23 + .sta_ofs = 0x200, 24 + }; 25 + 26 + static const struct mtk_gate_regs vdec2_cg_regs = { 27 + .set_ofs = 0x8, 28 + .clr_ofs = 0xc, 29 + .sta_ofs = 0x8, 30 + }; 31 + 32 + #define GATE_VDEC0(_id, _name, _parent, _shift) \ 33 + GATE_MTK(_id, _name, _parent, &vdec0_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv) 34 + 35 + #define GATE_VDEC1(_id, _name, _parent, _shift) \ 36 + GATE_MTK(_id, _name, _parent, &vdec1_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv) 37 + 38 + #define GATE_VDEC2(_id, _name, _parent, _shift) \ 39 + GATE_MTK(_id, _name, _parent, &vdec2_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv) 40 + 41 + static const struct mtk_gate vdec1_clks[] = { 42 + /* VDEC1_0 */ 43 + GATE_VDEC0(CLK_VDEC1_SOC_VDEC, "vdec1_soc_vdec", "top_vdec", 0), 44 + GATE_VDEC0(CLK_VDEC1_SOC_VDEC_ACTIVE, "vdec1_soc_vdec_active", "top_vdec", 4), 45 + GATE_VDEC0(CLK_VDEC1_SOC_VDEC_ENG, "vdec1_soc_vdec_eng", "top_vdec", 8), 46 + /* VDEC1_1 */ 47 + GATE_VDEC1(CLK_VDEC1_SOC_LAT, "vdec1_soc_lat", "top_vdec", 0), 48 + GATE_VDEC1(CLK_VDEC1_SOC_LAT_ACTIVE, "vdec1_soc_lat_active", "top_vdec", 4), 49 + GATE_VDEC1(CLK_VDEC1_SOC_LAT_ENG, "vdec1_soc_lat_eng", "top_vdec", 8), 50 + /* VDEC1_2 */ 51 + GATE_VDEC2(CLK_VDEC1_SOC_LARB1, "vdec1_soc_larb1", "top_vdec", 0), 52 + }; 53 + 54 + static const struct mtk_gate vdec2_clks[] = { 55 + /* VDEC2_0 */ 56 + GATE_VDEC0(CLK_VDEC2_VDEC, "vdec2_vdec", "top_vdec", 0), 57 + GATE_VDEC0(CLK_VDEC2_VDEC_ACTIVE, "vdec2_vdec_active", "top_vdec", 4), 58 + GATE_VDEC0(CLK_VDEC2_VDEC_ENG, "vdec2_vdec_eng", "top_vdec", 8), 59 + /* VDEC2_1 */ 60 + GATE_VDEC1(CLK_VDEC2_LAT, "vdec2_lat", "top_vdec", 0), 61 + /* VDEC2_2 */ 62 + GATE_VDEC2(CLK_VDEC2_LARB1, "vdec2_larb1", "top_vdec", 0), 63 + }; 64 + 65 + static const struct mtk_clk_desc vdec1_desc = { 66 + .clks = vdec1_clks, 67 + .num_clks = ARRAY_SIZE(vdec1_clks), 68 + }; 69 + 70 + static const struct mtk_clk_desc vdec2_desc = { 71 + .clks = vdec2_clks, 72 + .num_clks = ARRAY_SIZE(vdec2_clks), 73 + }; 74 + 75 + static const struct of_device_id of_match_clk_mt8188_vdec[] = { 76 + { .compatible = "mediatek,mt8188-vdecsys-soc", .data = &vdec1_desc }, 77 + { .compatible = "mediatek,mt8188-vdecsys", .data = &vdec2_desc }, 78 + { /* sentinel */ } 79 + }; 80 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8188_vdec); 81 + 82 + static struct platform_driver clk_mt8188_vdec_drv = { 83 + .probe = mtk_clk_simple_probe, 84 + .remove = mtk_clk_simple_remove, 85 + .driver = { 86 + .name = "clk-mt8188-vdec", 87 + .of_match_table = of_match_clk_mt8188_vdec, 88 + }, 89 + }; 90 + 91 + module_platform_driver(clk_mt8188_vdec_drv); 92 + MODULE_LICENSE("GPL");
+107
drivers/clk/mediatek/clk-mt8188-vdo0.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Copyright (c) 2022 MediaTek Inc. 4 + * Author: Garmin Chang <garmin.chang@mediatek.com> 5 + */ 6 + 7 + #include <linux/clk-provider.h> 8 + #include <linux/mod_devicetable.h> 9 + #include <linux/platform_device.h> 10 + 11 + #include <dt-bindings/clock/mediatek,mt8188-clk.h> 12 + 13 + #include "clk-gate.h" 14 + #include "clk-mtk.h" 15 + 16 + static const struct mtk_gate_regs vdo0_0_cg_regs = { 17 + .set_ofs = 0x104, 18 + .clr_ofs = 0x108, 19 + .sta_ofs = 0x100, 20 + }; 21 + 22 + static const struct mtk_gate_regs vdo0_1_cg_regs = { 23 + .set_ofs = 0x114, 24 + .clr_ofs = 0x118, 25 + .sta_ofs = 0x110, 26 + }; 27 + 28 + static const struct mtk_gate_regs vdo0_2_cg_regs = { 29 + .set_ofs = 0x124, 30 + .clr_ofs = 0x128, 31 + .sta_ofs = 0x120, 32 + }; 33 + 34 + #define GATE_VDO0_0(_id, _name, _parent, _shift) \ 35 + GATE_MTK(_id, _name, _parent, &vdo0_0_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 36 + 37 + #define GATE_VDO0_1(_id, _name, _parent, _shift) \ 38 + GATE_MTK(_id, _name, _parent, &vdo0_1_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 39 + 40 + #define GATE_VDO0_2(_id, _name, _parent, _shift) \ 41 + GATE_MTK(_id, _name, _parent, &vdo0_2_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 42 + 43 + #define GATE_VDO0_2_FLAGS(_id, _name, _parent, _shift, _flags) \ 44 + GATE_MTK_FLAGS(_id, _name, _parent, &vdo0_2_cg_regs, _shift, \ 45 + &mtk_clk_gate_ops_setclr, _flags) 46 + 47 + static const struct mtk_gate vdo0_clks[] = { 48 + /* VDO0_0 */ 49 + GATE_VDO0_0(CLK_VDO0_DISP_OVL0, "vdo0_disp_ovl0", "top_vpp", 0), 50 + GATE_VDO0_0(CLK_VDO0_FAKE_ENG0, "vdo0_fake_eng0", "top_vpp", 2), 51 + GATE_VDO0_0(CLK_VDO0_DISP_CCORR0, "vdo0_disp_ccorr0", "top_vpp", 4), 52 + GATE_VDO0_0(CLK_VDO0_DISP_MUTEX0, "vdo0_disp_mutex0", "top_vpp", 6), 53 + GATE_VDO0_0(CLK_VDO0_DISP_GAMMA0, "vdo0_disp_gamma0", "top_vpp", 8), 54 + GATE_VDO0_0(CLK_VDO0_DISP_DITHER0, "vdo0_disp_dither0", "top_vpp", 10), 55 + GATE_VDO0_0(CLK_VDO0_DISP_WDMA0, "vdo0_disp_wdma0", "top_vpp", 17), 56 + GATE_VDO0_0(CLK_VDO0_DISP_RDMA0, "vdo0_disp_rdma0", "top_vpp", 19), 57 + GATE_VDO0_0(CLK_VDO0_DSI0, "vdo0_dsi0", "top_vpp", 21), 58 + GATE_VDO0_0(CLK_VDO0_DSI1, "vdo0_dsi1", "top_vpp", 22), 59 + GATE_VDO0_0(CLK_VDO0_DSC_WRAP0, "vdo0_dsc_wrap0", "top_vpp", 23), 60 + GATE_VDO0_0(CLK_VDO0_VPP_MERGE0, "vdo0_vpp_merge0", "top_vpp", 24), 61 + GATE_VDO0_0(CLK_VDO0_DP_INTF0, "vdo0_dp_intf0", "top_vpp", 25), 62 + GATE_VDO0_0(CLK_VDO0_DISP_AAL0, "vdo0_disp_aal0", "top_vpp", 26), 63 + GATE_VDO0_0(CLK_VDO0_INLINEROT0, "vdo0_inlinerot0", "top_vpp", 27), 64 + GATE_VDO0_0(CLK_VDO0_APB_BUS, "vdo0_apb_bus", "top_vpp", 28), 65 + GATE_VDO0_0(CLK_VDO0_DISP_COLOR0, "vdo0_disp_color0", "top_vpp", 29), 66 + GATE_VDO0_0(CLK_VDO0_MDP_WROT0, "vdo0_mdp_wrot0", "top_vpp", 30), 67 + GATE_VDO0_0(CLK_VDO0_DISP_RSZ0, "vdo0_disp_rsz0", "top_vpp", 31), 68 + /* VDO0_1 */ 69 + GATE_VDO0_1(CLK_VDO0_DISP_POSTMASK0, "vdo0_disp_postmask0", "top_vpp", 0), 70 + GATE_VDO0_1(CLK_VDO0_FAKE_ENG1, "vdo0_fake_eng1", "top_vpp", 1), 71 + GATE_VDO0_1(CLK_VDO0_DL_ASYNC2, "vdo0_dl_async2", "top_vpp", 5), 72 + GATE_VDO0_1(CLK_VDO0_DL_RELAY3, "vdo0_dl_relay3", "top_vpp", 6), 73 + GATE_VDO0_1(CLK_VDO0_DL_RELAY4, "vdo0_dl_relay4", "top_vpp", 7), 74 + GATE_VDO0_1(CLK_VDO0_SMI_GALS, "vdo0_smi_gals", "top_vpp", 10), 75 + GATE_VDO0_1(CLK_VDO0_SMI_COMMON, "vdo0_smi_common", "top_vpp", 11), 76 + GATE_VDO0_1(CLK_VDO0_SMI_EMI, "vdo0_smi_emi", "top_vpp", 12), 77 + GATE_VDO0_1(CLK_VDO0_SMI_IOMMU, "vdo0_smi_iommu", "top_vpp", 13), 78 + GATE_VDO0_1(CLK_VDO0_SMI_LARB, "vdo0_smi_larb", "top_vpp", 14), 79 + GATE_VDO0_1(CLK_VDO0_SMI_RSI, "vdo0_smi_rsi", "top_vpp", 15), 80 + /* VDO0_2 */ 81 + GATE_VDO0_2(CLK_VDO0_DSI0_DSI, "vdo0_dsi0_dsi", "top_dsi_occ", 0), 82 + GATE_VDO0_2(CLK_VDO0_DSI1_DSI, "vdo0_dsi1_dsi", "top_dsi_occ", 8), 83 + GATE_VDO0_2_FLAGS(CLK_VDO0_DP_INTF0_DP_INTF, "vdo0_dp_intf0_dp_intf", 84 + "top_edp", 16, CLK_SET_RATE_PARENT), 85 + }; 86 + 87 + static const struct mtk_clk_desc vdo0_desc = { 88 + .clks = vdo0_clks, 89 + .num_clks = ARRAY_SIZE(vdo0_clks), 90 + }; 91 + 92 + static const struct platform_device_id clk_mt8188_vdo0_id_table[] = { 93 + { .name = "clk-mt8188-vdo0", .driver_data = (kernel_ulong_t)&vdo0_desc }, 94 + { /* sentinel */ } 95 + }; 96 + MODULE_DEVICE_TABLE(platform, clk_mt8188_vdo0_id_table); 97 + 98 + static struct platform_driver clk_mt8188_vdo0_drv = { 99 + .probe = mtk_clk_pdev_probe, 100 + .remove = mtk_clk_pdev_remove, 101 + .driver = { 102 + .name = "clk-mt8188-vdo0", 103 + }, 104 + .id_table = clk_mt8188_vdo0_id_table, 105 + }; 106 + module_platform_driver(clk_mt8188_vdo0_drv); 107 + MODULE_LICENSE("GPL");
+154
drivers/clk/mediatek/clk-mt8188-vdo1.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Copyright (c) 2022 MediaTek Inc. 4 + * Author: Garmin Chang <garmin.chang@mediatek.com> 5 + */ 6 + 7 + #include <linux/clk-provider.h> 8 + #include <linux/mod_devicetable.h> 9 + #include <linux/platform_device.h> 10 + 11 + #include <dt-bindings/clock/mediatek,mt8188-clk.h> 12 + 13 + #include "clk-gate.h" 14 + #include "clk-mtk.h" 15 + 16 + static const struct mtk_gate_regs vdo1_0_cg_regs = { 17 + .set_ofs = 0x104, 18 + .clr_ofs = 0x108, 19 + .sta_ofs = 0x100, 20 + }; 21 + 22 + static const struct mtk_gate_regs vdo1_1_cg_regs = { 23 + .set_ofs = 0x114, 24 + .clr_ofs = 0x118, 25 + .sta_ofs = 0x110, 26 + }; 27 + 28 + static const struct mtk_gate_regs vdo1_2_cg_regs = { 29 + .set_ofs = 0x124, 30 + .clr_ofs = 0x128, 31 + .sta_ofs = 0x120, 32 + }; 33 + 34 + static const struct mtk_gate_regs vdo1_3_cg_regs = { 35 + .set_ofs = 0x134, 36 + .clr_ofs = 0x138, 37 + .sta_ofs = 0x130, 38 + }; 39 + 40 + static const struct mtk_gate_regs vdo1_4_cg_regs = { 41 + .set_ofs = 0x144, 42 + .clr_ofs = 0x148, 43 + .sta_ofs = 0x140, 44 + }; 45 + 46 + #define GATE_VDO1_0(_id, _name, _parent, _shift) \ 47 + GATE_MTK(_id, _name, _parent, &vdo1_0_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 48 + 49 + #define GATE_VDO1_1(_id, _name, _parent, _shift) \ 50 + GATE_MTK(_id, _name, _parent, &vdo1_1_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 51 + 52 + #define GATE_VDO1_2(_id, _name, _parent, _shift) \ 53 + GATE_MTK(_id, _name, _parent, &vdo1_2_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 54 + 55 + #define GATE_VDO1_3(_id, _name, _parent, _shift) \ 56 + GATE_MTK(_id, _name, _parent, &vdo1_3_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 57 + 58 + #define GATE_VDO1_3_FLAGS(_id, _name, _parent, _shift, _flags) \ 59 + GATE_MTK_FLAGS(_id, _name, _parent, &vdo1_3_cg_regs, _shift, \ 60 + &mtk_clk_gate_ops_setclr, _flags) 61 + 62 + #define GATE_VDO1_4(_id, _name, _parent, _shift) \ 63 + GATE_MTK(_id, _name, _parent, &vdo1_4_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 64 + 65 + static const struct mtk_gate vdo1_clks[] = { 66 + /* VDO1_0 */ 67 + GATE_VDO1_0(CLK_VDO1_SMI_LARB2, "vdo1_smi_larb2", "top_vpp", 0), 68 + GATE_VDO1_0(CLK_VDO1_SMI_LARB3, "vdo1_smi_larb3", "top_vpp", 1), 69 + GATE_VDO1_0(CLK_VDO1_GALS, "vdo1_gals", "top_vpp", 2), 70 + GATE_VDO1_0(CLK_VDO1_FAKE_ENG0, "vdo1_fake_eng0", "top_vpp", 3), 71 + GATE_VDO1_0(CLK_VDO1_FAKE_ENG1, "vdo1_fake_eng1", "top_vpp", 4), 72 + GATE_VDO1_0(CLK_VDO1_MDP_RDMA0, "vdo1_mdp_rdma0", "top_vpp", 5), 73 + GATE_VDO1_0(CLK_VDO1_MDP_RDMA1, "vdo1_mdp_rdma1", "top_vpp", 6), 74 + GATE_VDO1_0(CLK_VDO1_MDP_RDMA2, "vdo1_mdp_rdma2", "top_vpp", 7), 75 + GATE_VDO1_0(CLK_VDO1_MDP_RDMA3, "vdo1_mdp_rdma3", "top_vpp", 8), 76 + GATE_VDO1_0(CLK_VDO1_VPP_MERGE0, "vdo1_vpp_merge0", "top_vpp", 9), 77 + GATE_VDO1_0(CLK_VDO1_VPP_MERGE1, "vdo1_vpp_merge1", "top_vpp", 10), 78 + GATE_VDO1_0(CLK_VDO1_VPP_MERGE2, "vdo1_vpp_merge2", "top_vpp", 11), 79 + /* VDO1_1 */ 80 + GATE_VDO1_1(CLK_VDO1_VPP_MERGE3, "vdo1_vpp_merge3", "top_vpp", 0), 81 + GATE_VDO1_1(CLK_VDO1_VPP_MERGE4, "vdo1_vpp_merge4", "top_vpp", 1), 82 + GATE_VDO1_1(CLK_VDO1_VPP2_TO_VDO1_DL_ASYNC, "vdo1_vpp2_to_vdo1_dl_async", "top_vpp", 2), 83 + GATE_VDO1_1(CLK_VDO1_VPP3_TO_VDO1_DL_ASYNC, "vdo1_vpp3_to_vdo1_dl_async", "top_vpp", 3), 84 + GATE_VDO1_1(CLK_VDO1_DISP_MUTEX, "vdo1_disp_mutex", "top_vpp", 4), 85 + GATE_VDO1_1(CLK_VDO1_MDP_RDMA4, "vdo1_mdp_rdma4", "top_vpp", 5), 86 + GATE_VDO1_1(CLK_VDO1_MDP_RDMA5, "vdo1_mdp_rdma5", "top_vpp", 6), 87 + GATE_VDO1_1(CLK_VDO1_MDP_RDMA6, "vdo1_mdp_rdma6", "top_vpp", 7), 88 + GATE_VDO1_1(CLK_VDO1_MDP_RDMA7, "vdo1_mdp_rdma7", "top_vpp", 8), 89 + GATE_VDO1_1(CLK_VDO1_DP_INTF0_MMCK, "vdo1_dp_intf0_mmck", "top_vpp", 9), 90 + GATE_VDO1_1(CLK_VDO1_DPI0_MM, "vdo1_dpi0_mm_ck", "top_vpp", 10), 91 + GATE_VDO1_1(CLK_VDO1_DPI1_MM, "vdo1_dpi1_mm_ck", "top_vpp", 11), 92 + GATE_VDO1_1(CLK_VDO1_MERGE0_DL_ASYNC, "vdo1_merge0_dl_async", "top_vpp", 13), 93 + GATE_VDO1_1(CLK_VDO1_MERGE1_DL_ASYNC, "vdo1_merge1_dl_async", "top_vpp", 14), 94 + GATE_VDO1_1(CLK_VDO1_MERGE2_DL_ASYNC, "vdo1_merge2_dl_async", "top_vpp", 15), 95 + GATE_VDO1_1(CLK_VDO1_MERGE3_DL_ASYNC, "vdo1_merge3_dl_async", "top_vpp", 16), 96 + GATE_VDO1_1(CLK_VDO1_MERGE4_DL_ASYNC, "vdo1_merge4_dl_async", "top_vpp", 17), 97 + GATE_VDO1_1(CLK_VDO1_DSC_VDO1_DL_ASYNC, "vdo1_dsc_vdo1_dl_async", "top_vpp", 18), 98 + GATE_VDO1_1(CLK_VDO1_MERGE_VDO1_DL_ASYNC, "vdo1_merge_vdo1_dl_async", "top_vpp", 19), 99 + GATE_VDO1_1(CLK_VDO1_PADDING0, "vdo1_padding0", "top_vpp", 20), 100 + GATE_VDO1_1(CLK_VDO1_PADDING1, "vdo1_padding1", "top_vpp", 21), 101 + GATE_VDO1_1(CLK_VDO1_PADDING2, "vdo1_padding2", "top_vpp", 22), 102 + GATE_VDO1_1(CLK_VDO1_PADDING3, "vdo1_padding3", "top_vpp", 23), 103 + GATE_VDO1_1(CLK_VDO1_PADDING4, "vdo1_padding4", "top_vpp", 24), 104 + GATE_VDO1_1(CLK_VDO1_PADDING5, "vdo1_padding5", "top_vpp", 25), 105 + GATE_VDO1_1(CLK_VDO1_PADDING6, "vdo1_padding6", "top_vpp", 26), 106 + GATE_VDO1_1(CLK_VDO1_PADDING7, "vdo1_padding7", "top_vpp", 27), 107 + GATE_VDO1_1(CLK_VDO1_DISP_RSZ0, "vdo1_disp_rsz0", "top_vpp", 28), 108 + GATE_VDO1_1(CLK_VDO1_DISP_RSZ1, "vdo1_disp_rsz1", "top_vpp", 29), 109 + GATE_VDO1_1(CLK_VDO1_DISP_RSZ2, "vdo1_disp_rsz2", "top_vpp", 30), 110 + GATE_VDO1_1(CLK_VDO1_DISP_RSZ3, "vdo1_disp_rsz3", "top_vpp", 31), 111 + /* VDO1_2 */ 112 + GATE_VDO1_2(CLK_VDO1_HDR_VDO_FE0, "vdo1_hdr_vdo_fe0", "top_vpp", 0), 113 + GATE_VDO1_2(CLK_VDO1_HDR_GFX_FE0, "vdo1_hdr_gfx_fe0", "top_vpp", 1), 114 + GATE_VDO1_2(CLK_VDO1_HDR_VDO_BE, "vdo1_hdr_vdo_be", "top_vpp", 2), 115 + GATE_VDO1_2(CLK_VDO1_HDR_VDO_FE1, "vdo1_hdr_vdo_fe1", "top_vpp", 16), 116 + GATE_VDO1_2(CLK_VDO1_HDR_GFX_FE1, "vdo1_hdr_gfx_fe1", "top_vpp", 17), 117 + GATE_VDO1_2(CLK_VDO1_DISP_MIXER, "vdo1_disp_mixer", "top_vpp", 18), 118 + GATE_VDO1_2(CLK_VDO1_HDR_VDO_FE0_DL_ASYNC, "vdo1_hdr_vdo_fe0_dl_async", "top_vpp", 19), 119 + GATE_VDO1_2(CLK_VDO1_HDR_VDO_FE1_DL_ASYNC, "vdo1_hdr_vdo_fe1_dl_async", "top_vpp", 20), 120 + GATE_VDO1_2(CLK_VDO1_HDR_GFX_FE0_DL_ASYNC, "vdo1_hdr_gfx_fe0_dl_async", "top_vpp", 21), 121 + GATE_VDO1_2(CLK_VDO1_HDR_GFX_FE1_DL_ASYNC, "vdo1_hdr_gfx_fe1_dl_async", "top_vpp", 22), 122 + GATE_VDO1_2(CLK_VDO1_HDR_VDO_BE_DL_ASYNC, "vdo1_hdr_vdo_be_dl_async", "top_vpp", 23), 123 + /* VDO1_3 */ 124 + GATE_VDO1_3(CLK_VDO1_DPI0, "vdo1_dpi0_ck", "top_vpp", 0), 125 + GATE_VDO1_3(CLK_VDO1_DISP_MONITOR_DPI0, "vdo1_disp_monitor_dpi0_ck", "top_vpp", 1), 126 + GATE_VDO1_3(CLK_VDO1_DPI1, "vdo1_dpi1_ck", "top_vpp", 8), 127 + GATE_VDO1_3(CLK_VDO1_DISP_MONITOR_DPI1, "vdo1_disp_monitor_dpi1_ck", "top_vpp", 9), 128 + GATE_VDO1_3_FLAGS(CLK_VDO1_DPINTF, "vdo1_dpintf", "top_dp", 16, CLK_SET_RATE_PARENT), 129 + GATE_VDO1_3(CLK_VDO1_DISP_MONITOR_DPINTF, "vdo1_disp_monitor_dpintf_ck", "top_vpp", 17), 130 + /* VDO1_4 */ 131 + GATE_VDO1_4(CLK_VDO1_26M_SLOW, "vdo1_26m_slow_ck", "clk26m", 8), 132 + }; 133 + 134 + static const struct mtk_clk_desc vdo1_desc = { 135 + .clks = vdo1_clks, 136 + .num_clks = ARRAY_SIZE(vdo1_clks), 137 + }; 138 + 139 + static const struct platform_device_id clk_mt8188_vdo1_id_table[] = { 140 + { .name = "clk-mt8188-vdo1", .driver_data = (kernel_ulong_t)&vdo1_desc }, 141 + { /* sentinel */ } 142 + }; 143 + MODULE_DEVICE_TABLE(platform, clk_mt8188_vdo1_id_table); 144 + 145 + static struct platform_driver clk_mt8188_vdo1_drv = { 146 + .probe = mtk_clk_pdev_probe, 147 + .remove = mtk_clk_pdev_remove, 148 + .driver = { 149 + .name = "clk-mt8188-vdo1", 150 + }, 151 + .id_table = clk_mt8188_vdo1_id_table, 152 + }; 153 + module_platform_driver(clk_mt8188_vdo1_drv); 154 + MODULE_LICENSE("GPL");
+56
drivers/clk/mediatek/clk-mt8188-venc.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Copyright (c) 2022 MediaTek Inc. 4 + * Author: Garmin Chang <garmin.chang@mediatek.com> 5 + */ 6 + 7 + #include <linux/clk-provider.h> 8 + #include <linux/mod_devicetable.h> 9 + #include <linux/platform_device.h> 10 + 11 + #include <dt-bindings/clock/mediatek,mt8188-clk.h> 12 + 13 + #include "clk-gate.h" 14 + #include "clk-mtk.h" 15 + 16 + static const struct mtk_gate_regs venc1_cg_regs = { 17 + .set_ofs = 0x4, 18 + .clr_ofs = 0x8, 19 + .sta_ofs = 0x0, 20 + }; 21 + 22 + #define GATE_VENC1(_id, _name, _parent, _shift) \ 23 + GATE_MTK(_id, _name, _parent, &venc1_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv) 24 + 25 + static const struct mtk_gate venc1_clks[] = { 26 + GATE_VENC1(CLK_VENC1_LARB, "venc1_larb", "top_venc", 0), 27 + GATE_VENC1(CLK_VENC1_VENC, "venc1_venc", "top_venc", 4), 28 + GATE_VENC1(CLK_VENC1_JPGENC, "venc1_jpgenc", "top_venc", 8), 29 + GATE_VENC1(CLK_VENC1_JPGDEC, "venc1_jpgdec", "top_venc", 12), 30 + GATE_VENC1(CLK_VENC1_JPGDEC_C1, "venc1_jpgdec_c1", "top_venc", 16), 31 + GATE_VENC1(CLK_VENC1_GALS, "venc1_gals", "top_venc", 28), 32 + GATE_VENC1(CLK_VENC1_GALS_SRAM, "venc1_gals_sram", "top_venc", 31), 33 + }; 34 + 35 + static const struct mtk_clk_desc venc1_desc = { 36 + .clks = venc1_clks, 37 + .num_clks = ARRAY_SIZE(venc1_clks), 38 + }; 39 + 40 + static const struct of_device_id of_match_clk_mt8188_venc1[] = { 41 + { .compatible = "mediatek,mt8188-vencsys", .data = &venc1_desc }, 42 + { /* sentinel */ } 43 + }; 44 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8188_venc1); 45 + 46 + static struct platform_driver clk_mt8188_venc1_drv = { 47 + .probe = mtk_clk_simple_probe, 48 + .remove = mtk_clk_simple_remove, 49 + .driver = { 50 + .name = "clk-mt8188-venc1", 51 + .of_match_table = of_match_clk_mt8188_venc1, 52 + }, 53 + }; 54 + 55 + module_platform_driver(clk_mt8188_venc1_drv); 56 + MODULE_LICENSE("GPL");
+114
drivers/clk/mediatek/clk-mt8188-vpp0.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Copyright (c) 2022 MediaTek Inc. 4 + * Author: Garmin Chang <garmin.chang@mediatek.com> 5 + */ 6 + 7 + #include <dt-bindings/clock/mediatek,mt8188-clk.h> 8 + #include <linux/clk-provider.h> 9 + #include <linux/platform_device.h> 10 + 11 + #include "clk-gate.h" 12 + #include "clk-mtk.h" 13 + 14 + static const struct mtk_gate_regs vpp0_0_cg_regs = { 15 + .set_ofs = 0x24, 16 + .clr_ofs = 0x28, 17 + .sta_ofs = 0x20, 18 + }; 19 + 20 + static const struct mtk_gate_regs vpp0_1_cg_regs = { 21 + .set_ofs = 0x30, 22 + .clr_ofs = 0x34, 23 + .sta_ofs = 0x2c, 24 + }; 25 + 26 + static const struct mtk_gate_regs vpp0_2_cg_regs = { 27 + .set_ofs = 0x3c, 28 + .clr_ofs = 0x40, 29 + .sta_ofs = 0x38, 30 + }; 31 + 32 + #define GATE_VPP0_0(_id, _name, _parent, _shift) \ 33 + GATE_MTK(_id, _name, _parent, &vpp0_0_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 34 + 35 + #define GATE_VPP0_1(_id, _name, _parent, _shift) \ 36 + GATE_MTK(_id, _name, _parent, &vpp0_1_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 37 + 38 + #define GATE_VPP0_2(_id, _name, _parent, _shift) \ 39 + GATE_MTK(_id, _name, _parent, &vpp0_2_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 40 + 41 + static const struct mtk_gate vpp0_clks[] = { 42 + /* VPP0_0 */ 43 + GATE_VPP0_0(CLK_VPP0_MDP_FG, "vpp0_mdp_fg", "top_vpp", 1), 44 + GATE_VPP0_0(CLK_VPP0_STITCH, "vpp0_stitch", "top_vpp", 2), 45 + GATE_VPP0_0(CLK_VPP0_PADDING, "vpp0_padding", "top_vpp", 7), 46 + GATE_VPP0_0(CLK_VPP0_MDP_TCC, "vpp0_mdp_tcc", "top_vpp", 8), 47 + GATE_VPP0_0(CLK_VPP0_WARP0_ASYNC_TX, "vpp0_warp0_async_tx", "top_vpp", 10), 48 + GATE_VPP0_0(CLK_VPP0_WARP1_ASYNC_TX, "vpp0_warp1_async_tx", "top_vpp", 11), 49 + GATE_VPP0_0(CLK_VPP0_MUTEX, "vpp0_mutex", "top_vpp", 13), 50 + GATE_VPP0_0(CLK_VPP02VPP1_RELAY, "vpp02vpp1_relay", "top_vpp", 14), 51 + GATE_VPP0_0(CLK_VPP0_VPP12VPP0_ASYNC, "vpp0_vpp12vpp0_async", "top_vpp", 15), 52 + GATE_VPP0_0(CLK_VPP0_MMSYSRAM_TOP, "vpp0_mmsysram_top", "top_vpp", 16), 53 + GATE_VPP0_0(CLK_VPP0_MDP_AAL, "vpp0_mdp_aal", "top_vpp", 17), 54 + GATE_VPP0_0(CLK_VPP0_MDP_RSZ, "vpp0_mdp_rsz", "top_vpp", 18), 55 + /* VPP0_1 */ 56 + GATE_VPP0_1(CLK_VPP0_SMI_COMMON_MMSRAM, "vpp0_smi_common_mmsram", "top_vpp", 0), 57 + GATE_VPP0_1(CLK_VPP0_GALS_VDO0_LARB0_MMSRAM, "vpp0_gals_vdo0_larb0_mmsram", "top_vpp", 1), 58 + GATE_VPP0_1(CLK_VPP0_GALS_VDO0_LARB1_MMSRAM, "vpp0_gals_vdo0_larb1_mmsram", "top_vpp", 2), 59 + GATE_VPP0_1(CLK_VPP0_GALS_VENCSYS_MMSRAM, "vpp0_gals_vencsys_mmsram", "top_vpp", 3), 60 + GATE_VPP0_1(CLK_VPP0_GALS_VENCSYS_CORE1_MMSRAM, 61 + "vpp0_gals_vencsys_core1_mmsram", "top_vpp", 4), 62 + GATE_VPP0_1(CLK_VPP0_GALS_INFRA_MMSRAM, "vpp0_gals_infra_mmsram", "top_vpp", 5), 63 + GATE_VPP0_1(CLK_VPP0_GALS_CAMSYS_MMSRAM, "vpp0_gals_camsys_mmsram", "top_vpp", 6), 64 + GATE_VPP0_1(CLK_VPP0_GALS_VPP1_LARB5_MMSRAM, "vpp0_gals_vpp1_larb5_mmsram", "top_vpp", 7), 65 + GATE_VPP0_1(CLK_VPP0_GALS_VPP1_LARB6_MMSRAM, "vpp0_gals_vpp1_larb6_mmsram", "top_vpp", 8), 66 + GATE_VPP0_1(CLK_VPP0_SMI_REORDER_MMSRAM, "vpp0_smi_reorder_mmsram", "top_vpp", 9), 67 + GATE_VPP0_1(CLK_VPP0_SMI_IOMMU, "vpp0_smi_iommu", "top_vpp", 10), 68 + GATE_VPP0_1(CLK_VPP0_GALS_IMGSYS_CAMSYS, "vpp0_gals_imgsys_camsys", "top_vpp", 11), 69 + GATE_VPP0_1(CLK_VPP0_MDP_RDMA, "vpp0_mdp_rdma", "top_vpp", 12), 70 + GATE_VPP0_1(CLK_VPP0_MDP_WROT, "vpp0_mdp_wrot", "top_vpp", 13), 71 + GATE_VPP0_1(CLK_VPP0_GALS_EMI0_EMI1, "vpp0_gals_emi0_emi1", "top_vpp", 16), 72 + GATE_VPP0_1(CLK_VPP0_SMI_SUB_COMMON_REORDER, "vpp0_smi_sub_common_reorder", "top_vpp", 17), 73 + GATE_VPP0_1(CLK_VPP0_SMI_RSI, "vpp0_smi_rsi", "top_vpp", 18), 74 + GATE_VPP0_1(CLK_VPP0_SMI_COMMON_LARB4, "vpp0_smi_common_larb4", "top_vpp", 19), 75 + GATE_VPP0_1(CLK_VPP0_GALS_VDEC_VDEC_CORE1, "vpp0_gals_vdec_vdec_core1", "top_vpp", 20), 76 + GATE_VPP0_1(CLK_VPP0_GALS_VPP1_WPESYS, "vpp0_gals_vpp1_wpesys", "top_vpp", 21), 77 + GATE_VPP0_1(CLK_VPP0_GALS_VDO0_VDO1_VENCSYS_CORE1, 78 + "vpp0_gals_vdo0_vdo1_vencsys_core1", "top_vpp", 22), 79 + GATE_VPP0_1(CLK_VPP0_FAKE_ENG, "vpp0_fake_eng", "top_vpp", 23), 80 + GATE_VPP0_1(CLK_VPP0_MDP_HDR, "vpp0_mdp_hdr", "top_vpp", 24), 81 + GATE_VPP0_1(CLK_VPP0_MDP_TDSHP, "vpp0_mdp_tdshp", "top_vpp", 25), 82 + GATE_VPP0_1(CLK_VPP0_MDP_COLOR, "vpp0_mdp_color", "top_vpp", 26), 83 + GATE_VPP0_1(CLK_VPP0_MDP_OVL, "vpp0_mdp_ovl", "top_vpp", 27), 84 + GATE_VPP0_1(CLK_VPP0_DSIP_RDMA, "vpp0_dsip_rdma", "top_vpp", 28), 85 + GATE_VPP0_1(CLK_VPP0_DISP_WDMA, "vpp0_disp_wdma", "top_vpp", 29), 86 + GATE_VPP0_1(CLK_VPP0_MDP_HMS, "vpp0_mdp_hms", "top_vpp", 30), 87 + /* VPP0_2 */ 88 + GATE_VPP0_2(CLK_VPP0_WARP0_RELAY, "vpp0_warp0_relay", "top_wpe_vpp", 0), 89 + GATE_VPP0_2(CLK_VPP0_WARP0_ASYNC, "vpp0_warp0_async", "top_wpe_vpp", 1), 90 + GATE_VPP0_2(CLK_VPP0_WARP1_RELAY, "vpp0_warp1_relay", "top_wpe_vpp", 2), 91 + GATE_VPP0_2(CLK_VPP0_WARP1_ASYNC, "vpp0_warp1_async", "top_wpe_vpp", 3), 92 + }; 93 + 94 + static const struct mtk_clk_desc vpp0_desc = { 95 + .clks = vpp0_clks, 96 + .num_clks = ARRAY_SIZE(vpp0_clks), 97 + }; 98 + 99 + static const struct platform_device_id clk_mt8188_vpp0_id_table[] = { 100 + { .name = "clk-mt8188-vpp0", .driver_data = (kernel_ulong_t)&vpp0_desc }, 101 + { /* sentinel */ } 102 + }; 103 + MODULE_DEVICE_TABLE(platform, clk_mt8188_vpp0_id_table); 104 + 105 + static struct platform_driver clk_mt8188_vpp0_drv = { 106 + .probe = mtk_clk_pdev_probe, 107 + .remove = mtk_clk_pdev_remove, 108 + .driver = { 109 + .name = "clk-mt8188-vpp0", 110 + }, 111 + .id_table = clk_mt8188_vpp0_id_table, 112 + }; 113 + module_platform_driver(clk_mt8188_vpp0_drv); 114 + MODULE_LICENSE("GPL");
+109
drivers/clk/mediatek/clk-mt8188-vpp1.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Copyright (c) 2022 MediaTek Inc. 4 + * Author: Garmin Chang <garmin.chang@mediatek.com> 5 + */ 6 + 7 + #include <dt-bindings/clock/mediatek,mt8188-clk.h> 8 + #include <linux/clk-provider.h> 9 + #include <linux/platform_device.h> 10 + 11 + #include "clk-gate.h" 12 + #include "clk-mtk.h" 13 + 14 + static const struct mtk_gate_regs vpp1_0_cg_regs = { 15 + .set_ofs = 0x104, 16 + .clr_ofs = 0x108, 17 + .sta_ofs = 0x100, 18 + }; 19 + 20 + static const struct mtk_gate_regs vpp1_1_cg_regs = { 21 + .set_ofs = 0x114, 22 + .clr_ofs = 0x118, 23 + .sta_ofs = 0x110, 24 + }; 25 + 26 + #define GATE_VPP1_0(_id, _name, _parent, _shift) \ 27 + GATE_MTK(_id, _name, _parent, &vpp1_0_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 28 + 29 + #define GATE_VPP1_1(_id, _name, _parent, _shift) \ 30 + GATE_MTK(_id, _name, _parent, &vpp1_1_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 31 + 32 + static const struct mtk_gate vpp1_clks[] = { 33 + /* VPP1_0 */ 34 + GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_OVL, "vpp1_svpp1_mdp_ovl", "top_vpp", 0), 35 + GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_TCC, "vpp1_svpp1_mdp_tcc", "top_vpp", 1), 36 + GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_WROT, "vpp1_svpp1_mdp_wrot", "top_vpp", 2), 37 + GATE_VPP1_0(CLK_VPP1_SVPP1_VPP_PAD, "vpp1_svpp1_vpp_pad", "top_vpp", 3), 38 + GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_WROT, "vpp1_svpp2_mdp_wrot", "top_vpp", 4), 39 + GATE_VPP1_0(CLK_VPP1_SVPP2_VPP_PAD, "vpp1_svpp2_vpp_pad", "top_vpp", 5), 40 + GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_WROT, "vpp1_svpp3_mdp_wrot", "top_vpp", 6), 41 + GATE_VPP1_0(CLK_VPP1_SVPP3_VPP_PAD, "vpp1_svpp3_vpp_pad", "top_vpp", 7), 42 + GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_RDMA, "vpp1_svpp1_mdp_rdma", "top_vpp", 8), 43 + GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_FG, "vpp1_svpp1_mdp_fg", "top_vpp", 9), 44 + GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_RDMA, "vpp1_svpp2_mdp_rdma", "top_vpp", 10), 45 + GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_FG, "vpp1_svpp2_mdp_fg", "top_vpp", 11), 46 + GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_RDMA, "vpp1_svpp3_mdp_rdma", "top_vpp", 12), 47 + GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_FG, "vpp1_svpp3_mdp_fg", "top_vpp", 13), 48 + GATE_VPP1_0(CLK_VPP1_VPP_SPLIT, "vpp1_vpp_split", "top_vpp", 14), 49 + GATE_VPP1_0(CLK_VPP1_SVPP2_VDO0_DL_RELAY, "vpp1_svpp2_vdo0_dl_relay", "top_vpp", 15), 50 + GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_RSZ, "vpp1_svpp1_mdp_rsz", "top_vpp", 16), 51 + GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_TDSHP, "vpp1_svpp1_mdp_tdshp", "top_vpp", 17), 52 + GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_COLOR, "vpp1_svpp1_mdp_color", "top_vpp", 18), 53 + GATE_VPP1_0(CLK_VPP1_SVPP3_VDO1_DL_RELAY, "vpp1_svpp3_vdo1_dl_relay", "top_vpp", 19), 54 + GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_RSZ, "vpp1_svpp2_mdp_rsz", "top_vpp", 20), 55 + GATE_VPP1_0(CLK_VPP1_SVPP2_VPP_MERGE, "vpp1_svpp2_vpp_merge", "top_vpp", 21), 56 + GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_TDSHP, "vpp1_svpp2_mdp_tdshp", "top_vpp", 22), 57 + GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_COLOR, "vpp1_svpp2_mdp_color", "top_vpp", 23), 58 + GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_RSZ, "vpp1_svpp3_mdp_rsz", "top_vpp", 24), 59 + GATE_VPP1_0(CLK_VPP1_SVPP3_VPP_MERGE, "vpp1_svpp3_vpp_merge", "top_vpp", 25), 60 + GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_TDSHP, "vpp1_svpp3_mdp_tdshp", "top_vpp", 26), 61 + GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_COLOR, "vpp1_svpp3_mdp_color", "top_vpp", 27), 62 + GATE_VPP1_0(CLK_VPP1_GALS5, "vpp1_gals5", "top_vpp", 28), 63 + GATE_VPP1_0(CLK_VPP1_GALS6, "vpp1_gals6", "top_vpp", 29), 64 + GATE_VPP1_0(CLK_VPP1_LARB5, "vpp1_larb5", "top_vpp", 30), 65 + GATE_VPP1_0(CLK_VPP1_LARB6, "vpp1_larb6", "top_vpp", 31), 66 + /* VPP1_1 */ 67 + GATE_VPP1_1(CLK_VPP1_SVPP1_MDP_HDR, "vpp1_svpp1_mdp_hdr", "top_vpp", 0), 68 + GATE_VPP1_1(CLK_VPP1_SVPP1_MDP_AAL, "vpp1_svpp1_mdp_aal", "top_vpp", 1), 69 + GATE_VPP1_1(CLK_VPP1_SVPP2_MDP_HDR, "vpp1_svpp2_mdp_hdr", "top_vpp", 2), 70 + GATE_VPP1_1(CLK_VPP1_SVPP2_MDP_AAL, "vpp1_svpp2_mdp_aal", "top_vpp", 3), 71 + GATE_VPP1_1(CLK_VPP1_SVPP3_MDP_HDR, "vpp1_svpp3_mdp_hdr", "top_vpp", 4), 72 + GATE_VPP1_1(CLK_VPP1_SVPP3_MDP_AAL, "vpp1_svpp3_mdp_aal", "top_vpp", 5), 73 + GATE_VPP1_1(CLK_VPP1_DISP_MUTEX, "vpp1_disp_mutex", "top_vpp", 7), 74 + GATE_VPP1_1(CLK_VPP1_SVPP2_VDO1_DL_RELAY, "vpp1_svpp2_vdo1_dl_relay", "top_vpp", 8), 75 + GATE_VPP1_1(CLK_VPP1_SVPP3_VDO0_DL_RELAY, "vpp1_svpp3_vdo0_dl_relay", "top_vpp", 9), 76 + GATE_VPP1_1(CLK_VPP1_VPP0_DL_ASYNC, "vpp1_vpp0_dl_async", "top_vpp", 10), 77 + GATE_VPP1_1(CLK_VPP1_VPP0_DL1_RELAY, "vpp1_vpp0_dl1_relay", "top_vpp", 11), 78 + GATE_VPP1_1(CLK_VPP1_LARB5_FAKE_ENG, "vpp1_larb5_fake_eng", "top_vpp", 12), 79 + GATE_VPP1_1(CLK_VPP1_LARB6_FAKE_ENG, "vpp1_larb6_fake_eng", "top_vpp", 13), 80 + GATE_VPP1_1(CLK_VPP1_HDMI_META, "vpp1_hdmi_meta", "top_vpp", 16), 81 + GATE_VPP1_1(CLK_VPP1_VPP_SPLIT_HDMI, "vpp1_vpp_split_hdmi", "top_vpp", 17), 82 + GATE_VPP1_1(CLK_VPP1_DGI_IN, "vpp1_dgi_in", "top_vpp", 18), 83 + GATE_VPP1_1(CLK_VPP1_DGI_OUT, "vpp1_dgi_out", "top_vpp", 19), 84 + GATE_VPP1_1(CLK_VPP1_VPP_SPLIT_DGI, "vpp1_vpp_split_dgi", "top_vpp", 20), 85 + GATE_VPP1_1(CLK_VPP1_DL_CON_OCC, "vpp1_dl_con_occ", "top_vpp", 21), 86 + GATE_VPP1_1(CLK_VPP1_VPP_SPLIT_26M, "vpp1_vpp_split_26m", "top_vpp", 26), 87 + }; 88 + 89 + static const struct mtk_clk_desc vpp1_desc = { 90 + .clks = vpp1_clks, 91 + .num_clks = ARRAY_SIZE(vpp1_clks), 92 + }; 93 + 94 + static const struct platform_device_id clk_mt8188_vpp1_id_table[] = { 95 + { .name = "clk-mt8188-vpp1", .driver_data = (kernel_ulong_t)&vpp1_desc }, 96 + { /* sentinel */ } 97 + }; 98 + MODULE_DEVICE_TABLE(platform, clk_mt8188_vpp1_id_table); 99 + 100 + static struct platform_driver clk_mt8188_vpp1_drv = { 101 + .probe = mtk_clk_pdev_probe, 102 + .remove = mtk_clk_pdev_remove, 103 + .driver = { 104 + .name = "clk-mt8188-vpp1", 105 + }, 106 + .id_table = clk_mt8188_vpp1_id_table, 107 + }; 108 + module_platform_driver(clk_mt8188_vpp1_drv); 109 + MODULE_LICENSE("GPL");
+105
drivers/clk/mediatek/clk-mt8188-wpe.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Copyright (c) 2022 MediaTek Inc. 4 + * Author: Garmin Chang <garmin.chang@mediatek.com> 5 + */ 6 + 7 + #include <linux/clk-provider.h> 8 + #include <linux/mod_devicetable.h> 9 + #include <linux/platform_device.h> 10 + 11 + #include <dt-bindings/clock/mediatek,mt8188-clk.h> 12 + 13 + #include "clk-gate.h" 14 + #include "clk-mtk.h" 15 + 16 + static const struct mtk_gate_regs wpe_top_cg_regs = { 17 + .set_ofs = 0x0, 18 + .clr_ofs = 0x0, 19 + .sta_ofs = 0x0, 20 + }; 21 + 22 + static const struct mtk_gate_regs wpe_vpp0_0_cg_regs = { 23 + .set_ofs = 0x58, 24 + .clr_ofs = 0x58, 25 + .sta_ofs = 0x58, 26 + }; 27 + 28 + static const struct mtk_gate_regs wpe_vpp0_1_cg_regs = { 29 + .set_ofs = 0x5c, 30 + .clr_ofs = 0x5c, 31 + .sta_ofs = 0x5c, 32 + }; 33 + 34 + #define GATE_WPE_TOP(_id, _name, _parent, _shift) \ 35 + GATE_MTK(_id, _name, _parent, &wpe_top_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv) 36 + 37 + #define GATE_WPE_VPP0_0(_id, _name, _parent, _shift) \ 38 + GATE_MTK(_id, _name, _parent, &wpe_vpp0_0_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv) 39 + 40 + #define GATE_WPE_VPP0_1(_id, _name, _parent, _shift) \ 41 + GATE_MTK(_id, _name, _parent, &wpe_vpp0_1_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv) 42 + 43 + static const struct mtk_gate wpe_top_clks[] = { 44 + GATE_WPE_TOP(CLK_WPE_TOP_WPE_VPP0, "wpe_wpe_vpp0", "top_wpe_vpp", 16), 45 + GATE_WPE_TOP(CLK_WPE_TOP_SMI_LARB7, "wpe_smi_larb7", "top_wpe_vpp", 18), 46 + GATE_WPE_TOP(CLK_WPE_TOP_WPESYS_EVENT_TX, "wpe_wpesys_event_tx", "top_wpe_vpp", 20), 47 + GATE_WPE_TOP(CLK_WPE_TOP_SMI_LARB7_PCLK_EN, "wpe_smi_larb7_p_en", "top_wpe_vpp", 24), 48 + }; 49 + 50 + static const struct mtk_gate wpe_vpp0_clks[] = { 51 + /* WPE_VPP00 */ 52 + GATE_WPE_VPP0_0(CLK_WPE_VPP0_VGEN, "wpe_vpp0_vgen", "top_img", 0), 53 + GATE_WPE_VPP0_0(CLK_WPE_VPP0_EXT, "wpe_vpp0_ext", "top_img", 1), 54 + GATE_WPE_VPP0_0(CLK_WPE_VPP0_VFC, "wpe_vpp0_vfc", "top_img", 2), 55 + GATE_WPE_VPP0_0(CLK_WPE_VPP0_CACH0_TOP, "wpe_vpp0_cach0_top", "top_img", 3), 56 + GATE_WPE_VPP0_0(CLK_WPE_VPP0_CACH0_DMA, "wpe_vpp0_cach0_dma", "top_img", 4), 57 + GATE_WPE_VPP0_0(CLK_WPE_VPP0_CACH1_TOP, "wpe_vpp0_cach1_top", "top_img", 5), 58 + GATE_WPE_VPP0_0(CLK_WPE_VPP0_CACH1_DMA, "wpe_vpp0_cach1_dma", "top_img", 6), 59 + GATE_WPE_VPP0_0(CLK_WPE_VPP0_CACH2_TOP, "wpe_vpp0_cach2_top", "top_img", 7), 60 + GATE_WPE_VPP0_0(CLK_WPE_VPP0_CACH2_DMA, "wpe_vpp0_cach2_dma", "top_img", 8), 61 + GATE_WPE_VPP0_0(CLK_WPE_VPP0_CACH3_TOP, "wpe_vpp0_cach3_top", "top_img", 9), 62 + GATE_WPE_VPP0_0(CLK_WPE_VPP0_CACH3_DMA, "wpe_vpp0_cach3_dma", "top_img", 10), 63 + GATE_WPE_VPP0_0(CLK_WPE_VPP0_PSP, "wpe_vpp0_psp", "top_img", 11), 64 + GATE_WPE_VPP0_0(CLK_WPE_VPP0_PSP2, "wpe_vpp0_psp2", "top_img", 12), 65 + GATE_WPE_VPP0_0(CLK_WPE_VPP0_SYNC, "wpe_vpp0_sync", "top_img", 13), 66 + GATE_WPE_VPP0_0(CLK_WPE_VPP0_C24, "wpe_vpp0_c24", "top_img", 14), 67 + GATE_WPE_VPP0_0(CLK_WPE_VPP0_MDP_CROP, "wpe_vpp0_mdp_crop", "top_img", 15), 68 + GATE_WPE_VPP0_0(CLK_WPE_VPP0_ISP_CROP, "wpe_vpp0_isp_crop", "top_img", 16), 69 + GATE_WPE_VPP0_0(CLK_WPE_VPP0_TOP, "wpe_vpp0_top", "top_img", 17), 70 + /* WPE_VPP0_1 */ 71 + GATE_WPE_VPP0_1(CLK_WPE_VPP0_VECI, "wpe_vpp0_veci", "top_img", 0), 72 + GATE_WPE_VPP0_1(CLK_WPE_VPP0_VEC2I, "wpe_vpp0_vec2i", "top_img", 1), 73 + GATE_WPE_VPP0_1(CLK_WPE_VPP0_VEC3I, "wpe_vpp0_vec3i", "top_img", 2), 74 + GATE_WPE_VPP0_1(CLK_WPE_VPP0_WPEO, "wpe_vpp0_wpeo", "top_img", 3), 75 + GATE_WPE_VPP0_1(CLK_WPE_VPP0_MSKO, "wpe_vpp0_msko", "top_img", 4), 76 + }; 77 + 78 + static const struct mtk_clk_desc wpe_top_desc = { 79 + .clks = wpe_top_clks, 80 + .num_clks = ARRAY_SIZE(wpe_top_clks), 81 + }; 82 + 83 + static const struct mtk_clk_desc wpe_vpp0_desc = { 84 + .clks = wpe_vpp0_clks, 85 + .num_clks = ARRAY_SIZE(wpe_vpp0_clks), 86 + }; 87 + 88 + static const struct of_device_id of_match_clk_mt8188_wpe[] = { 89 + { .compatible = "mediatek,mt8188-wpesys", .data = &wpe_top_desc }, 90 + { .compatible = "mediatek,mt8188-wpesys-vpp0", .data = &wpe_vpp0_desc }, 91 + { /* sentinel */ } 92 + }; 93 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8188_wpe); 94 + 95 + static struct platform_driver clk_mt8188_wpe_drv = { 96 + .probe = mtk_clk_simple_probe, 97 + .remove = mtk_clk_simple_remove, 98 + .driver = { 99 + .name = "clk-mt8188-wpe", 100 + .of_match_table = of_match_clk_mt8188_wpe, 101 + }, 102 + }; 103 + 104 + module_platform_driver(clk_mt8188_wpe_drv); 105 + MODULE_LICENSE("GPL");
+215
drivers/clk/mediatek/clk-mt8192-apmixedsys.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Copyright (c) 2021 MediaTek Inc. 4 + * Chun-Jie Chen <chun-jie.chen@mediatek.com> 5 + * Copyright (c) 2023 Collabora Ltd. 6 + * AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> 7 + */ 8 + 9 + #include <dt-bindings/clock/mt8192-clk.h> 10 + #include <linux/module.h> 11 + #include <linux/platform_device.h> 12 + #include "clk-fhctl.h" 13 + #include "clk-gate.h" 14 + #include "clk-mtk.h" 15 + #include "clk-pll.h" 16 + #include "clk-pllfh.h" 17 + 18 + static const struct mtk_gate_regs apmixed_cg_regs = { 19 + .set_ofs = 0x14, 20 + .clr_ofs = 0x14, 21 + .sta_ofs = 0x14, 22 + }; 23 + 24 + #define GATE_APMIXED(_id, _name, _parent, _shift) \ 25 + GATE_MTK(_id, _name, _parent, &apmixed_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv) 26 + 27 + static const struct mtk_gate apmixed_clks[] = { 28 + GATE_APMIXED(CLK_APMIXED_MIPID26M, "mipid26m", "clk26m", 16), 29 + }; 30 + 31 + #define MT8192_PLL_FMAX (3800UL * MHZ) 32 + #define MT8192_PLL_FMIN (1500UL * MHZ) 33 + #define MT8192_INTEGER_BITS 8 34 + 35 + #define PLL(_id, _name, _reg, _pwr_reg, _en_mask, _flags, \ 36 + _rst_bar_mask, _pcwbits, _pd_reg, _pd_shift, \ 37 + _tuner_reg, _tuner_en_reg, _tuner_en_bit, \ 38 + _pcw_reg, _pcw_shift, _pcw_chg_reg, \ 39 + _en_reg, _pll_en_bit) { \ 40 + .id = _id, \ 41 + .name = _name, \ 42 + .reg = _reg, \ 43 + .pwr_reg = _pwr_reg, \ 44 + .en_mask = _en_mask, \ 45 + .flags = _flags, \ 46 + .rst_bar_mask = _rst_bar_mask, \ 47 + .fmax = MT8192_PLL_FMAX, \ 48 + .fmin = MT8192_PLL_FMIN, \ 49 + .pcwbits = _pcwbits, \ 50 + .pcwibits = MT8192_INTEGER_BITS, \ 51 + .pd_reg = _pd_reg, \ 52 + .pd_shift = _pd_shift, \ 53 + .tuner_reg = _tuner_reg, \ 54 + .tuner_en_reg = _tuner_en_reg, \ 55 + .tuner_en_bit = _tuner_en_bit, \ 56 + .pcw_reg = _pcw_reg, \ 57 + .pcw_shift = _pcw_shift, \ 58 + .pcw_chg_reg = _pcw_chg_reg, \ 59 + .en_reg = _en_reg, \ 60 + .pll_en_bit = _pll_en_bit, \ 61 + } 62 + 63 + #define PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags, \ 64 + _rst_bar_mask, _pcwbits, _pd_reg, _pd_shift, \ 65 + _tuner_reg, _tuner_en_reg, _tuner_en_bit, \ 66 + _pcw_reg, _pcw_shift) \ 67 + PLL(_id, _name, _reg, _pwr_reg, _en_mask, _flags, \ 68 + _rst_bar_mask, _pcwbits, _pd_reg, _pd_shift, \ 69 + _tuner_reg, _tuner_en_reg, _tuner_en_bit, \ 70 + _pcw_reg, _pcw_shift, 0, 0, 0) 71 + 72 + static const struct mtk_pll_data plls[] = { 73 + PLL_B(CLK_APMIXED_MAINPLL, "mainpll", 0x0340, 0x034c, 0xff000000, 74 + HAVE_RST_BAR, BIT(23), 22, 0x0344, 24, 0, 0, 0, 0x0344, 0), 75 + PLL_B(CLK_APMIXED_UNIVPLL, "univpll", 0x0308, 0x0314, 0xff000000, 76 + HAVE_RST_BAR, BIT(23), 22, 0x030c, 24, 0, 0, 0, 0x030c, 0), 77 + PLL(CLK_APMIXED_USBPLL, "usbpll", 0x03c4, 0x03cc, 0x00000000, 78 + 0, 0, 22, 0x03c4, 24, 0, 0, 0, 0x03c4, 0, 0x03c4, 0x03cc, 2), 79 + PLL_B(CLK_APMIXED_MSDCPLL, "msdcpll", 0x0350, 0x035c, 0x00000000, 80 + 0, 0, 22, 0x0354, 24, 0, 0, 0, 0x0354, 0), 81 + PLL_B(CLK_APMIXED_MMPLL, "mmpll", 0x0360, 0x036c, 0xff000000, 82 + HAVE_RST_BAR, BIT(23), 22, 0x0364, 24, 0, 0, 0, 0x0364, 0), 83 + PLL_B(CLK_APMIXED_ADSPPLL, "adsppll", 0x0370, 0x037c, 0xff000000, 84 + HAVE_RST_BAR, BIT(23), 22, 0x0374, 24, 0, 0, 0, 0x0374, 0), 85 + PLL_B(CLK_APMIXED_MFGPLL, "mfgpll", 0x0268, 0x0274, 0x00000000, 86 + 0, 0, 22, 0x026c, 24, 0, 0, 0, 0x026c, 0), 87 + PLL_B(CLK_APMIXED_TVDPLL, "tvdpll", 0x0380, 0x038c, 0x00000000, 88 + 0, 0, 22, 0x0384, 24, 0, 0, 0, 0x0384, 0), 89 + PLL_B(CLK_APMIXED_APLL1, "apll1", 0x0318, 0x0328, 0x00000000, 90 + 0, 0, 32, 0x031c, 24, 0x0040, 0x000c, 0, 0x0320, 0), 91 + PLL_B(CLK_APMIXED_APLL2, "apll2", 0x032c, 0x033c, 0x00000000, 92 + 0, 0, 32, 0x0330, 24, 0, 0, 0, 0x0334, 0), 93 + }; 94 + 95 + enum fh_pll_id { 96 + FH_ARMPLL_LL, 97 + FH_ARMPLL_BL0, 98 + FH_ARMPLL_BL1, 99 + FH_ARMPLL_BL2, 100 + FH_ARMPLL_BL3, 101 + FH_CCIPLL, 102 + FH_MFGPLL, 103 + FH_MEMPLL, 104 + FH_MPLL, 105 + FH_MMPLL, 106 + FH_MAINPLL, 107 + FH_MSDCPLL, 108 + FH_ADSPPLL, 109 + FH_APUPLL, 110 + FH_TVDPLL, 111 + FH_NR_FH, 112 + }; 113 + 114 + #define FH(_pllid, _fhid, _offset) { \ 115 + .data = { \ 116 + .pll_id = _pllid, \ 117 + .fh_id = _fhid, \ 118 + .fh_ver = FHCTL_PLLFH_V2, \ 119 + .fhx_offset = _offset, \ 120 + .dds_mask = GENMASK(21, 0), \ 121 + .slope0_value = 0x6003c97, \ 122 + .slope1_value = 0x6003c97, \ 123 + .sfstrx_en = BIT(2), \ 124 + .frddsx_en = BIT(1), \ 125 + .fhctlx_en = BIT(0), \ 126 + .tgl_org = BIT(31), \ 127 + .dvfs_tri = BIT(31), \ 128 + .pcwchg = BIT(31), \ 129 + .dt_val = 0x0, \ 130 + .df_val = 0x9, \ 131 + .updnlmt_shft = 16, \ 132 + .msk_frddsx_dys = GENMASK(23, 20), \ 133 + .msk_frddsx_dts = GENMASK(19, 16), \ 134 + }, \ 135 + } 136 + 137 + static struct mtk_pllfh_data pllfhs[] = { 138 + FH(CLK_APMIXED_MFGPLL, FH_MFGPLL, 0xb4), 139 + FH(CLK_APMIXED_MMPLL, FH_MMPLL, 0xf0), 140 + FH(CLK_APMIXED_MAINPLL, FH_MAINPLL, 0x104), 141 + FH(CLK_APMIXED_MSDCPLL, FH_MSDCPLL, 0x118), 142 + FH(CLK_APMIXED_ADSPPLL, FH_ADSPPLL, 0x12c), 143 + FH(CLK_APMIXED_TVDPLL, FH_TVDPLL, 0x154), 144 + }; 145 + 146 + static const struct of_device_id of_match_clk_mt8192_apmixed[] = { 147 + { .compatible = "mediatek,mt8192-apmixedsys" }, 148 + { /* sentinel */ } 149 + }; 150 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8192_apmixed); 151 + 152 + static int clk_mt8192_apmixed_probe(struct platform_device *pdev) 153 + { 154 + struct clk_hw_onecell_data *clk_data; 155 + struct device_node *node = pdev->dev.of_node; 156 + const u8 *fhctl_node = "mediatek,mt8192-fhctl"; 157 + int r; 158 + 159 + clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK); 160 + if (!clk_data) 161 + return -ENOMEM; 162 + 163 + fhctl_parse_dt(fhctl_node, pllfhs, ARRAY_SIZE(pllfhs)); 164 + 165 + r = mtk_clk_register_pllfhs(node, plls, ARRAY_SIZE(plls), 166 + pllfhs, ARRAY_SIZE(pllfhs), clk_data); 167 + if (r) 168 + goto free_clk_data; 169 + 170 + r = mtk_clk_register_gates(&pdev->dev, node, apmixed_clks, 171 + ARRAY_SIZE(apmixed_clks), clk_data); 172 + if (r) 173 + goto unregister_plls; 174 + 175 + r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 176 + if (r) 177 + goto unregister_gates; 178 + 179 + return r; 180 + 181 + unregister_gates: 182 + mtk_clk_unregister_gates(apmixed_clks, ARRAY_SIZE(apmixed_clks), clk_data); 183 + unregister_plls: 184 + mtk_clk_unregister_pllfhs(plls, ARRAY_SIZE(plls), pllfhs, 185 + ARRAY_SIZE(pllfhs), clk_data); 186 + free_clk_data: 187 + mtk_free_clk_data(clk_data); 188 + return r; 189 + } 190 + 191 + static int clk_mt8192_apmixed_remove(struct platform_device *pdev) 192 + { 193 + struct device_node *node = pdev->dev.of_node; 194 + struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev); 195 + 196 + of_clk_del_provider(node); 197 + mtk_clk_unregister_gates(apmixed_clks, ARRAY_SIZE(apmixed_clks), clk_data); 198 + mtk_clk_unregister_pllfhs(plls, ARRAY_SIZE(plls), pllfhs, 199 + ARRAY_SIZE(pllfhs), clk_data); 200 + mtk_free_clk_data(clk_data); 201 + 202 + return 0; 203 + } 204 + 205 + static struct platform_driver clk_mt8192_apmixed_drv = { 206 + .driver = { 207 + .name = "clk-mt8192-apmixed", 208 + .of_match_table = of_match_clk_mt8192_apmixed, 209 + }, 210 + .probe = clk_mt8192_apmixed_probe, 211 + .remove = clk_mt8192_apmixed_remove, 212 + }; 213 + module_platform_driver(clk_mt8192_apmixed_drv); 214 + MODULE_DESCRIPTION("MediaTek MT8192 apmixed clocks driver"); 215 + MODULE_LICENSE("GPL");
+3 -2
drivers/clk/mediatek/clk-mt8192-aud.c
··· 107 107 { .compatible = "mediatek,mt8192-audsys", .data = &aud_desc }, 108 108 { /* sentinel */ } 109 109 }; 110 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8192_aud); 110 111 111 112 static struct platform_driver clk_mt8192_aud_drv = { 112 113 .probe = clk_mt8192_aud_probe, ··· 117 116 .of_match_table = of_match_clk_mt8192_aud, 118 117 }, 119 118 }; 120 - 121 - builtin_platform_driver(clk_mt8192_aud_drv); 119 + module_platform_driver(clk_mt8192_aud_drv); 120 + MODULE_LICENSE("GPL");
+3 -2
drivers/clk/mediatek/clk-mt8192-cam.c
··· 95 95 /* sentinel */ 96 96 } 97 97 }; 98 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8192_cam); 98 99 99 100 static struct platform_driver clk_mt8192_cam_drv = { 100 101 .probe = mtk_clk_simple_probe, ··· 105 104 .of_match_table = of_match_clk_mt8192_cam, 106 105 }, 107 106 }; 108 - 109 - builtin_platform_driver(clk_mt8192_cam_drv); 107 + module_platform_driver(clk_mt8192_cam_drv); 108 + MODULE_LICENSE("GPL");
+3 -2
drivers/clk/mediatek/clk-mt8192-img.c
··· 58 58 /* sentinel */ 59 59 } 60 60 }; 61 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8192_img); 61 62 62 63 static struct platform_driver clk_mt8192_img_drv = { 63 64 .probe = mtk_clk_simple_probe, ··· 68 67 .of_match_table = of_match_clk_mt8192_img, 69 68 }, 70 69 }; 71 - 72 - builtin_platform_driver(clk_mt8192_img_drv); 70 + module_platform_driver(clk_mt8192_img_drv); 71 + MODULE_LICENSE("GPL");
+3 -2
drivers/clk/mediatek/clk-mt8192-imp_iic_wrap.c
··· 107 107 /* sentinel */ 108 108 } 109 109 }; 110 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8192_imp_iic_wrap); 110 111 111 112 static struct platform_driver clk_mt8192_imp_iic_wrap_drv = { 112 113 .probe = mtk_clk_simple_probe, ··· 117 116 .of_match_table = of_match_clk_mt8192_imp_iic_wrap, 118 117 }, 119 118 }; 120 - 121 - builtin_platform_driver(clk_mt8192_imp_iic_wrap_drv); 119 + module_platform_driver(clk_mt8192_imp_iic_wrap_drv); 120 + MODULE_LICENSE("GPL");
+3 -2
drivers/clk/mediatek/clk-mt8192-ipe.c
··· 45 45 /* sentinel */ 46 46 } 47 47 }; 48 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8192_ipe); 48 49 49 50 static struct platform_driver clk_mt8192_ipe_drv = { 50 51 .probe = mtk_clk_simple_probe, ··· 55 54 .of_match_table = of_match_clk_mt8192_ipe, 56 55 }, 57 56 }; 58 - 59 - builtin_platform_driver(clk_mt8192_ipe_drv); 57 + module_platform_driver(clk_mt8192_ipe_drv); 58 + MODULE_LICENSE("GPL");
+3 -2
drivers/clk/mediatek/clk-mt8192-mdp.c
··· 70 70 /* sentinel */ 71 71 } 72 72 }; 73 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8192_mdp); 73 74 74 75 static struct platform_driver clk_mt8192_mdp_drv = { 75 76 .probe = mtk_clk_simple_probe, ··· 80 79 .of_match_table = of_match_clk_mt8192_mdp, 81 80 }, 82 81 }; 83 - 84 - builtin_platform_driver(clk_mt8192_mdp_drv); 82 + module_platform_driver(clk_mt8192_mdp_drv); 83 + MODULE_LICENSE("GPL");
+3 -2
drivers/clk/mediatek/clk-mt8192-mfg.c
··· 40 40 /* sentinel */ 41 41 } 42 42 }; 43 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8192_mfg); 43 44 44 45 static struct platform_driver clk_mt8192_mfg_drv = { 45 46 .probe = mtk_clk_simple_probe, ··· 50 49 .of_match_table = of_match_clk_mt8192_mfg, 51 50 }, 52 51 }; 53 - 54 - builtin_platform_driver(clk_mt8192_mfg_drv); 52 + module_platform_driver(clk_mt8192_mfg_drv); 53 + MODULE_LICENSE("GPL");
+14 -20
drivers/clk/mediatek/clk-mt8192-mm.c
··· 80 80 GATE_MM2(CLK_MM_32KHZ, "mm_32khz", "clk32k", 25), 81 81 }; 82 82 83 - static int clk_mt8192_mm_probe(struct platform_device *pdev) 84 - { 85 - struct device *dev = &pdev->dev; 86 - struct device_node *node = dev->parent->of_node; 87 - struct clk_hw_onecell_data *clk_data; 88 - int r; 83 + static const struct mtk_clk_desc mm_desc = { 84 + .clks = mm_clks, 85 + .num_clks = ARRAY_SIZE(mm_clks), 86 + }; 89 87 90 - clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK); 91 - if (!clk_data) 92 - return -ENOMEM; 93 - 94 - r = mtk_clk_register_gates(&pdev->dev, node, mm_clks, 95 - ARRAY_SIZE(mm_clks), clk_data); 96 - if (r) 97 - return r; 98 - 99 - return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 100 - } 88 + static const struct platform_device_id clk_mt8192_mm_id_table[] = { 89 + { .name = "clk-mt8192-mm", .driver_data = (kernel_ulong_t)&mm_desc }, 90 + { /* sentinel */ } 91 + }; 92 + MODULE_DEVICE_TABLE(platform, clk_mt8192_mm_id_table); 101 93 102 94 static struct platform_driver clk_mt8192_mm_drv = { 103 - .probe = clk_mt8192_mm_probe, 95 + .probe = mtk_clk_pdev_probe, 96 + .remove = mtk_clk_pdev_remove, 104 97 .driver = { 105 98 .name = "clk-mt8192-mm", 106 99 }, 100 + .id_table = clk_mt8192_mm_id_table, 107 101 }; 108 - 109 - builtin_platform_driver(clk_mt8192_mm_drv); 102 + module_platform_driver(clk_mt8192_mm_drv); 103 + MODULE_LICENSE("GPL");
+3 -2
drivers/clk/mediatek/clk-mt8192-msdc.c
··· 52 52 /* sentinel */ 53 53 } 54 54 }; 55 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8192_msdc); 55 56 56 57 static struct platform_driver clk_mt8192_msdc_drv = { 57 58 .probe = mtk_clk_simple_probe, ··· 62 61 .of_match_table = of_match_clk_mt8192_msdc, 63 62 }, 64 63 }; 65 - 66 - builtin_platform_driver(clk_mt8192_msdc_drv); 64 + module_platform_driver(clk_mt8192_msdc_drv); 65 + MODULE_LICENSE("GPL");
+3 -2
drivers/clk/mediatek/clk-mt8192-scp_adsp.c
··· 38 38 /* sentinel */ 39 39 } 40 40 }; 41 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8192_scp_adsp); 41 42 42 43 static struct platform_driver clk_mt8192_scp_adsp_drv = { 43 44 .probe = mtk_clk_simple_probe, ··· 48 47 .of_match_table = of_match_clk_mt8192_scp_adsp, 49 48 }, 50 49 }; 51 - 52 - builtin_platform_driver(clk_mt8192_scp_adsp_drv); 50 + module_platform_driver(clk_mt8192_scp_adsp_drv); 51 + MODULE_LICENSE("GPL");
+3 -2
drivers/clk/mediatek/clk-mt8192-vdec.c
··· 82 82 /* sentinel */ 83 83 } 84 84 }; 85 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8192_vdec); 85 86 86 87 static struct platform_driver clk_mt8192_vdec_drv = { 87 88 .probe = mtk_clk_simple_probe, ··· 92 91 .of_match_table = of_match_clk_mt8192_vdec, 93 92 }, 94 93 }; 95 - 96 - builtin_platform_driver(clk_mt8192_vdec_drv); 94 + module_platform_driver(clk_mt8192_vdec_drv); 95 + MODULE_LICENSE("GPL");
+3 -2
drivers/clk/mediatek/clk-mt8192-venc.c
··· 41 41 /* sentinel */ 42 42 } 43 43 }; 44 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8192_venc); 44 45 45 46 static struct platform_driver clk_mt8192_venc_drv = { 46 47 .probe = mtk_clk_simple_probe, ··· 51 50 .of_match_table = of_match_clk_mt8192_venc, 52 51 }, 53 52 }; 54 - 55 - builtin_platform_driver(clk_mt8192_venc_drv); 53 + module_platform_driver(clk_mt8192_venc_drv); 54 + MODULE_LICENSE("GPL");
+6 -154
drivers/clk/mediatek/clk-mt8192.c
··· 15 15 #include "clk-gate.h" 16 16 #include "clk-mtk.h" 17 17 #include "clk-mux.h" 18 - #include "clk-pll.h" 19 18 20 19 #include <dt-bindings/clock/mt8192-clk.h> 21 20 #include <dt-bindings/reset/mt8192-resets.h> ··· 711 712 DIV_GATE(CLK_TOP_APLL12_DIV9, "apll12_div9", "apll_i2s9_m_sel", 0x320, 10, 0x338, 8, 16), 712 713 }; 713 714 714 - static const struct mtk_gate_regs apmixed_cg_regs = { 715 - .set_ofs = 0x14, 716 - .clr_ofs = 0x14, 717 - .sta_ofs = 0x14, 718 - }; 719 - 720 - #define GATE_APMIXED(_id, _name, _parent, _shift) \ 721 - GATE_MTK(_id, _name, _parent, &apmixed_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv) 722 - 723 - static const struct mtk_gate apmixed_clks[] = { 724 - GATE_APMIXED(CLK_APMIXED_MIPID26M, "mipid26m", "clk26m", 16), 725 - }; 726 - 727 715 static const struct mtk_gate_regs infra0_cg_regs = { 728 716 .set_ofs = 0x80, 729 717 .clr_ofs = 0x84, ··· 964 978 .rst_idx_map_nr = ARRAY_SIZE(infra_ao_idx_map), 965 979 }; 966 980 967 - #define MT8192_PLL_FMAX (3800UL * MHZ) 968 - #define MT8192_PLL_FMIN (1500UL * MHZ) 969 - #define MT8192_INTEGER_BITS 8 970 - 971 - #define PLL(_id, _name, _reg, _pwr_reg, _en_mask, _flags, \ 972 - _rst_bar_mask, _pcwbits, _pd_reg, _pd_shift, \ 973 - _tuner_reg, _tuner_en_reg, _tuner_en_bit, \ 974 - _pcw_reg, _pcw_shift, _pcw_chg_reg, \ 975 - _en_reg, _pll_en_bit) { \ 976 - .id = _id, \ 977 - .name = _name, \ 978 - .reg = _reg, \ 979 - .pwr_reg = _pwr_reg, \ 980 - .en_mask = _en_mask, \ 981 - .flags = _flags, \ 982 - .rst_bar_mask = _rst_bar_mask, \ 983 - .fmax = MT8192_PLL_FMAX, \ 984 - .fmin = MT8192_PLL_FMIN, \ 985 - .pcwbits = _pcwbits, \ 986 - .pcwibits = MT8192_INTEGER_BITS, \ 987 - .pd_reg = _pd_reg, \ 988 - .pd_shift = _pd_shift, \ 989 - .tuner_reg = _tuner_reg, \ 990 - .tuner_en_reg = _tuner_en_reg, \ 991 - .tuner_en_bit = _tuner_en_bit, \ 992 - .pcw_reg = _pcw_reg, \ 993 - .pcw_shift = _pcw_shift, \ 994 - .pcw_chg_reg = _pcw_chg_reg, \ 995 - .en_reg = _en_reg, \ 996 - .pll_en_bit = _pll_en_bit, \ 997 - } 998 - 999 - #define PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags, \ 1000 - _rst_bar_mask, _pcwbits, _pd_reg, _pd_shift, \ 1001 - _tuner_reg, _tuner_en_reg, _tuner_en_bit, \ 1002 - _pcw_reg, _pcw_shift) \ 1003 - PLL(_id, _name, _reg, _pwr_reg, _en_mask, _flags, \ 1004 - _rst_bar_mask, _pcwbits, _pd_reg, _pd_shift, \ 1005 - _tuner_reg, _tuner_en_reg, _tuner_en_bit, \ 1006 - _pcw_reg, _pcw_shift, 0, 0, 0) 1007 - 1008 - static const struct mtk_pll_data plls[] = { 1009 - PLL_B(CLK_APMIXED_MAINPLL, "mainpll", 0x0340, 0x034c, 0xff000000, 1010 - HAVE_RST_BAR, BIT(23), 22, 0x0344, 24, 0, 0, 0, 0x0344, 0), 1011 - PLL_B(CLK_APMIXED_UNIVPLL, "univpll", 0x0308, 0x0314, 0xff000000, 1012 - HAVE_RST_BAR, BIT(23), 22, 0x030c, 24, 0, 0, 0, 0x030c, 0), 1013 - PLL(CLK_APMIXED_USBPLL, "usbpll", 0x03c4, 0x03cc, 0x00000000, 1014 - 0, 0, 22, 0x03c4, 24, 0, 0, 0, 0x03c4, 0, 0x03c4, 0x03cc, 2), 1015 - PLL_B(CLK_APMIXED_MSDCPLL, "msdcpll", 0x0350, 0x035c, 0x00000000, 1016 - 0, 0, 22, 0x0354, 24, 0, 0, 0, 0x0354, 0), 1017 - PLL_B(CLK_APMIXED_MMPLL, "mmpll", 0x0360, 0x036c, 0xff000000, 1018 - HAVE_RST_BAR, BIT(23), 22, 0x0364, 24, 0, 0, 0, 0x0364, 0), 1019 - PLL_B(CLK_APMIXED_ADSPPLL, "adsppll", 0x0370, 0x037c, 0xff000000, 1020 - HAVE_RST_BAR, BIT(23), 22, 0x0374, 24, 0, 0, 0, 0x0374, 0), 1021 - PLL_B(CLK_APMIXED_MFGPLL, "mfgpll", 0x0268, 0x0274, 0x00000000, 1022 - 0, 0, 22, 0x026c, 24, 0, 0, 0, 0x026c, 0), 1023 - PLL_B(CLK_APMIXED_TVDPLL, "tvdpll", 0x0380, 0x038c, 0x00000000, 1024 - 0, 0, 22, 0x0384, 24, 0, 0, 0, 0x0384, 0), 1025 - PLL_B(CLK_APMIXED_APLL1, "apll1", 0x0318, 0x0328, 0x00000000, 1026 - 0, 0, 32, 0x031c, 24, 0x0040, 0x000c, 0, 0x0320, 0), 1027 - PLL_B(CLK_APMIXED_APLL2, "apll2", 0x032c, 0x033c, 0x00000000, 1028 - 0, 0, 32, 0x0330, 24, 0, 0, 0, 0x0334, 0), 1029 - }; 1030 - 1031 981 /* Register mux notifier for MFG mux */ 1032 982 static int clk_mt8192_reg_mfg_mux_notifier(struct device *dev, struct clk *clk) 1033 983 { ··· 984 1062 mfg_mux_nb->bypass_index = 0; /* Bypass to 26M crystal */ 985 1063 986 1064 return devm_mtk_clk_mux_notifier_register(dev, clk, mfg_mux_nb); 987 - } 988 - 989 - static int clk_mt8192_apmixed_probe(struct platform_device *pdev) 990 - { 991 - struct clk_hw_onecell_data *clk_data; 992 - struct device_node *node = pdev->dev.of_node; 993 - int r; 994 - 995 - clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK); 996 - if (!clk_data) 997 - return -ENOMEM; 998 - 999 - mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data); 1000 - r = mtk_clk_register_gates(&pdev->dev, node, apmixed_clks, 1001 - ARRAY_SIZE(apmixed_clks), clk_data); 1002 - if (r) 1003 - goto free_clk_data; 1004 - 1005 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 1006 - if (r) 1007 - goto unregister_gates; 1008 - 1009 - return r; 1010 - 1011 - unregister_gates: 1012 - mtk_clk_unregister_gates(apmixed_clks, ARRAY_SIZE(apmixed_clks), clk_data); 1013 - free_clk_data: 1014 - mtk_free_clk_data(clk_data); 1015 - return r; 1016 - } 1017 - 1018 - static const struct of_device_id of_match_clk_mt8192[] = { 1019 - { 1020 - .compatible = "mediatek,mt8192-apmixedsys", 1021 - .data = clk_mt8192_apmixed_probe, 1022 - }, { 1023 - /* sentinel */ 1024 - } 1025 - }; 1026 - 1027 - static int clk_mt8192_probe(struct platform_device *pdev) 1028 - { 1029 - int (*clk_probe)(struct platform_device *pdev); 1030 - int r; 1031 - 1032 - clk_probe = of_device_get_match_data(&pdev->dev); 1033 - if (!clk_probe) 1034 - return -EINVAL; 1035 - 1036 - r = clk_probe(pdev); 1037 - if (r) 1038 - dev_err(&pdev->dev, "could not register clock provider: %s: %d\n", pdev->name, r); 1039 - 1040 - return r; 1041 1065 } 1042 1066 1043 1067 static const struct mtk_clk_desc infra_desc = { ··· 1013 1145 .mfg_clk_idx = CLK_TOP_MFG_PLL_SEL, 1014 1146 }; 1015 1147 1016 - static const struct of_device_id of_match_clk_mt8192_simple[] = { 1148 + static const struct of_device_id of_match_clk_mt8192[] = { 1017 1149 { .compatible = "mediatek,mt8192-infracfg", .data = &infra_desc }, 1018 1150 { .compatible = "mediatek,mt8192-pericfg", .data = &peri_desc }, 1019 1151 { .compatible = "mediatek,mt8192-topckgen", .data = &topck_desc }, 1020 1152 { /* sentinel */ } 1021 1153 }; 1022 - 1023 - static struct platform_driver clk_mt8192_simple_drv = { 1024 - .probe = mtk_clk_simple_probe, 1025 - .remove = mtk_clk_simple_remove, 1026 - .driver = { 1027 - .name = "clk-mt8192-simple", 1028 - .of_match_table = of_match_clk_mt8192_simple, 1029 - }, 1030 - }; 1154 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8192); 1031 1155 1032 1156 static struct platform_driver clk_mt8192_drv = { 1033 - .probe = clk_mt8192_probe, 1034 1157 .driver = { 1035 1158 .name = "clk-mt8192", 1036 1159 .of_match_table = of_match_clk_mt8192, 1037 1160 }, 1161 + .probe = mtk_clk_simple_probe, 1162 + .remove = mtk_clk_simple_remove, 1038 1163 }; 1039 - 1040 - static int __init clk_mt8192_init(void) 1041 - { 1042 - int ret = platform_driver_register(&clk_mt8192_drv); 1043 - 1044 - if (ret) 1045 - return ret; 1046 - return platform_driver_register(&clk_mt8192_simple_drv); 1047 - } 1048 - 1049 - arch_initcall(clk_mt8192_init); 1164 + module_platform_driver(clk_mt8192_drv); 1165 + MODULE_LICENSE("GPL");
+69 -4
drivers/clk/mediatek/clk-mt8195-apmixedsys.c
··· 3 3 // Copyright (c) 2021 MediaTek Inc. 4 4 // Author: Chun-Jie Chen <chun-jie.chen@mediatek.com> 5 5 6 + #include "clk-fhctl.h" 6 7 #include "clk-gate.h" 7 8 #include "clk-mtk.h" 8 9 #include "clk-pll.h" 10 + #include "clk-pllfh.h" 9 11 10 12 #include <dt-bindings/clock/mt8195-clk.h> 11 13 #include <linux/of_device.h> ··· 107 105 0, 0, 22, 0x0158, 24, 0, 0, 0, 0x0158, 0, 0x0158, 0, 9), 108 106 }; 109 107 108 + enum fh_pll_id { 109 + FH_ARMPLL_LL, 110 + FH_ARMPLL_BL, 111 + FH_MEMPLL, 112 + FH_ADSPPLL, 113 + FH_NNAPLL, 114 + FH_CCIPLL, 115 + FH_MFGPLL, 116 + FH_TVDPLL2, 117 + FH_MPLL, 118 + FH_MMPLL, 119 + FH_MAINPLL, 120 + FH_MSDCPLL, 121 + FH_IMGPLL, 122 + FH_VDECPLL, 123 + FH_TVDPLL1, 124 + FH_NR_FH, 125 + }; 126 + 127 + #define FH(_pllid, _fhid, _offset) { \ 128 + .data = { \ 129 + .pll_id = _pllid, \ 130 + .fh_id = _fhid, \ 131 + .fh_ver = FHCTL_PLLFH_V2, \ 132 + .fhx_offset = _offset, \ 133 + .dds_mask = GENMASK(21, 0), \ 134 + .slope0_value = 0x6003c97, \ 135 + .slope1_value = 0x6003c97, \ 136 + .sfstrx_en = BIT(2), \ 137 + .frddsx_en = BIT(1), \ 138 + .fhctlx_en = BIT(0), \ 139 + .tgl_org = BIT(31), \ 140 + .dvfs_tri = BIT(31), \ 141 + .pcwchg = BIT(31), \ 142 + .dt_val = 0x0, \ 143 + .df_val = 0x9, \ 144 + .updnlmt_shft = 16, \ 145 + .msk_frddsx_dys = GENMASK(23, 20), \ 146 + .msk_frddsx_dts = GENMASK(19, 16), \ 147 + }, \ 148 + } 149 + 150 + static struct mtk_pllfh_data pllfhs[] = { 151 + FH(CLK_APMIXED_ADSPPLL, FH_ADSPPLL, 0x78), 152 + FH(CLK_APMIXED_NNAPLL, FH_NNAPLL, 0x8c), 153 + FH(CLK_APMIXED_MFGPLL, FH_MFGPLL, 0xb4), 154 + FH(CLK_APMIXED_TVDPLL2, FH_TVDPLL2, 0xc8), 155 + FH(CLK_APMIXED_MMPLL, FH_MMPLL, 0xf0), 156 + FH(CLK_APMIXED_MAINPLL, FH_MAINPLL, 0x104), 157 + FH(CLK_APMIXED_MSDCPLL, FH_MSDCPLL, 0x118), 158 + FH(CLK_APMIXED_IMGPLL, FH_IMGPLL, 0x12c), 159 + FH(CLK_APMIXED_VDECPLL, FH_VDECPLL, 0x140), 160 + FH(CLK_APMIXED_TVDPLL2, FH_TVDPLL1, 0x154), 161 + }; 162 + 110 163 static const struct of_device_id of_match_clk_mt8195_apmixed[] = { 111 164 { .compatible = "mediatek,mt8195-apmixedsys", }, 112 165 {} 113 166 }; 167 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8195_apmixed); 114 168 115 169 static int clk_mt8195_apmixed_probe(struct platform_device *pdev) 116 170 { 117 171 struct clk_hw_onecell_data *clk_data; 118 172 struct device_node *node = pdev->dev.of_node; 173 + const u8 *fhctl_node = "mediatek,mt8195-fhctl"; 119 174 int r; 120 175 121 176 clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK); 122 177 if (!clk_data) 123 178 return -ENOMEM; 124 179 125 - r = mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data); 180 + fhctl_parse_dt(fhctl_node, pllfhs, ARRAY_SIZE(pllfhs)); 181 + 182 + r = mtk_clk_register_pllfhs(node, plls, ARRAY_SIZE(plls), 183 + pllfhs, ARRAY_SIZE(pllfhs), clk_data); 126 184 if (r) 127 185 goto free_apmixed_data; 128 186 ··· 202 140 unregister_gates: 203 141 mtk_clk_unregister_gates(apmixed_clks, ARRAY_SIZE(apmixed_clks), clk_data); 204 142 unregister_plls: 205 - mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data); 143 + mtk_clk_unregister_pllfhs(plls, ARRAY_SIZE(plls), pllfhs, 144 + ARRAY_SIZE(pllfhs), clk_data); 206 145 free_apmixed_data: 207 146 mtk_free_clk_data(clk_data); 208 147 return r; ··· 216 153 217 154 of_clk_del_provider(node); 218 155 mtk_clk_unregister_gates(apmixed_clks, ARRAY_SIZE(apmixed_clks), clk_data); 219 - mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data); 156 + mtk_clk_unregister_pllfhs(plls, ARRAY_SIZE(plls), pllfhs, 157 + ARRAY_SIZE(pllfhs), clk_data); 220 158 mtk_free_clk_data(clk_data); 221 159 222 160 return 0; ··· 231 167 .of_match_table = of_match_clk_mt8195_apmixed, 232 168 }, 233 169 }; 234 - builtin_platform_driver(clk_mt8195_apmixed_drv); 170 + module_platform_driver(clk_mt8195_apmixed_drv); 171 + MODULE_LICENSE("GPL");
+3 -1
drivers/clk/mediatek/clk-mt8195-apusys_pll.c
··· 101 101 { .compatible = "mediatek,mt8195-apusys_pll", }, 102 102 {} 103 103 }; 104 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8195_apusys_pll); 104 105 105 106 static struct platform_driver clk_mt8195_apusys_pll_drv = { 106 107 .probe = clk_mt8195_apusys_pll_probe, ··· 111 110 .of_match_table = of_match_clk_mt8195_apusys_pll, 112 111 }, 113 112 }; 114 - builtin_platform_driver(clk_mt8195_apusys_pll_drv); 113 + module_platform_driver(clk_mt8195_apusys_pll_drv); 114 + MODULE_LICENSE("GPL");
+3 -1
drivers/clk/mediatek/clk-mt8195-cam.c
··· 131 131 /* sentinel */ 132 132 } 133 133 }; 134 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8195_cam); 134 135 135 136 static struct platform_driver clk_mt8195_cam_drv = { 136 137 .probe = mtk_clk_simple_probe, ··· 141 140 .of_match_table = of_match_clk_mt8195_cam, 142 141 }, 143 142 }; 144 - builtin_platform_driver(clk_mt8195_cam_drv); 143 + module_platform_driver(clk_mt8195_cam_drv); 144 + MODULE_LICENSE("GPL");
+3 -1
drivers/clk/mediatek/clk-mt8195-ccu.c
··· 39 39 /* sentinel */ 40 40 } 41 41 }; 42 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8195_ccu); 42 43 43 44 static struct platform_driver clk_mt8195_ccu_drv = { 44 45 .probe = mtk_clk_simple_probe, ··· 49 48 .of_match_table = of_match_clk_mt8195_ccu, 50 49 }, 51 50 }; 52 - builtin_platform_driver(clk_mt8195_ccu_drv); 51 + module_platform_driver(clk_mt8195_ccu_drv); 52 + MODULE_LICENSE("GPL");
+3 -1
drivers/clk/mediatek/clk-mt8195-img.c
··· 85 85 /* sentinel */ 86 86 } 87 87 }; 88 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8195_img); 88 89 89 90 static struct platform_driver clk_mt8195_img_drv = { 90 91 .probe = mtk_clk_simple_probe, ··· 95 94 .of_match_table = of_match_clk_mt8195_img, 96 95 }, 97 96 }; 98 - builtin_platform_driver(clk_mt8195_img_drv); 97 + module_platform_driver(clk_mt8195_img_drv); 98 + MODULE_LICENSE("GPL");
+3 -1
drivers/clk/mediatek/clk-mt8195-imp_iic_wrap.c
··· 55 55 /* sentinel */ 56 56 } 57 57 }; 58 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8195_imp_iic_wrap); 58 59 59 60 static struct platform_driver clk_mt8195_imp_iic_wrap_drv = { 60 61 .probe = mtk_clk_simple_probe, ··· 65 64 .of_match_table = of_match_clk_mt8195_imp_iic_wrap, 66 65 }, 67 66 }; 68 - builtin_platform_driver(clk_mt8195_imp_iic_wrap_drv); 67 + module_platform_driver(clk_mt8195_imp_iic_wrap_drv); 68 + MODULE_LICENSE("GPL");
+3 -1
drivers/clk/mediatek/clk-mt8195-infra_ao.c
··· 229 229 /* sentinel */ 230 230 } 231 231 }; 232 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8195_infra_ao); 232 233 233 234 static struct platform_driver clk_mt8195_infra_ao_drv = { 234 235 .probe = mtk_clk_simple_probe, ··· 239 238 .of_match_table = of_match_clk_mt8195_infra_ao, 240 239 }, 241 240 }; 242 - builtin_platform_driver(clk_mt8195_infra_ao_drv); 241 + module_platform_driver(clk_mt8195_infra_ao_drv); 242 + MODULE_LICENSE("GPL");
+3 -1
drivers/clk/mediatek/clk-mt8195-ipe.c
··· 40 40 /* sentinel */ 41 41 } 42 42 }; 43 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8195_ipe); 43 44 44 45 static struct platform_driver clk_mt8195_ipe_drv = { 45 46 .probe = mtk_clk_simple_probe, ··· 50 49 .of_match_table = of_match_clk_mt8195_ipe, 51 50 }, 52 51 }; 53 - builtin_platform_driver(clk_mt8195_ipe_drv); 52 + module_platform_driver(clk_mt8195_ipe_drv); 53 + MODULE_LICENSE("GPL");
+3 -1
drivers/clk/mediatek/clk-mt8195-mfg.c
··· 38 38 /* sentinel */ 39 39 } 40 40 }; 41 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8195_mfg); 41 42 42 43 static struct platform_driver clk_mt8195_mfg_drv = { 43 44 .probe = mtk_clk_simple_probe, ··· 48 47 .of_match_table = of_match_clk_mt8195_mfg, 49 48 }, 50 49 }; 51 - builtin_platform_driver(clk_mt8195_mfg_drv); 50 + module_platform_driver(clk_mt8195_mfg_drv); 51 + MODULE_LICENSE("GPL");
+3 -1
drivers/clk/mediatek/clk-mt8195-peri_ao.c
··· 51 51 /* sentinel */ 52 52 } 53 53 }; 54 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8195_peri_ao); 54 55 55 56 static struct platform_driver clk_mt8195_peri_ao_drv = { 56 57 .probe = mtk_clk_simple_probe, ··· 61 60 .of_match_table = of_match_clk_mt8195_peri_ao, 62 61 }, 63 62 }; 64 - builtin_platform_driver(clk_mt8195_peri_ao_drv); 63 + module_platform_driver(clk_mt8195_peri_ao_drv); 64 + MODULE_LICENSE("GPL");
+3 -1
drivers/clk/mediatek/clk-mt8195-scp_adsp.c
··· 36 36 /* sentinel */ 37 37 } 38 38 }; 39 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8195_scp_adsp); 39 40 40 41 static struct platform_driver clk_mt8195_scp_adsp_drv = { 41 42 .probe = mtk_clk_simple_probe, ··· 46 45 .of_match_table = of_match_clk_mt8195_scp_adsp, 47 46 }, 48 47 }; 49 - builtin_platform_driver(clk_mt8195_scp_adsp_drv); 48 + module_platform_driver(clk_mt8195_scp_adsp_drv); 49 + MODULE_LICENSE("GPL");
+3 -1
drivers/clk/mediatek/clk-mt8195-topckgen.c
··· 1219 1219 { .compatible = "mediatek,mt8195-topckgen", }, 1220 1220 {} 1221 1221 }; 1222 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8195_topck); 1222 1223 1223 1224 /* Register mux notifier for MFG mux */ 1224 1225 static int clk_mt8195_reg_mfg_mux_notifier(struct device *dev, struct clk *clk) ··· 1341 1340 .of_match_table = of_match_clk_mt8195_topck, 1342 1341 }, 1343 1342 }; 1344 - builtin_platform_driver(clk_mt8195_topck_drv); 1343 + module_platform_driver(clk_mt8195_topck_drv); 1344 + MODULE_LICENSE("GPL");
+3 -1
drivers/clk/mediatek/clk-mt8195-vdec.c
··· 93 93 /* sentinel */ 94 94 } 95 95 }; 96 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8195_vdec); 96 97 97 98 static struct platform_driver clk_mt8195_vdec_drv = { 98 99 .probe = mtk_clk_simple_probe, ··· 103 102 .of_match_table = of_match_clk_mt8195_vdec, 104 103 }, 105 104 }; 106 - builtin_platform_driver(clk_mt8195_vdec_drv); 105 + module_platform_driver(clk_mt8195_vdec_drv); 106 + MODULE_LICENSE("GPL");
+14 -45
drivers/clk/mediatek/clk-mt8195-vdo0.c
··· 93 93 "top_edp", 16, CLK_SET_RATE_PARENT), 94 94 }; 95 95 96 - static int clk_mt8195_vdo0_probe(struct platform_device *pdev) 97 - { 98 - struct device *dev = &pdev->dev; 99 - struct device_node *node = dev->parent->of_node; 100 - struct clk_hw_onecell_data *clk_data; 101 - int r; 96 + static const struct mtk_clk_desc vdo0_desc = { 97 + .clks = vdo0_clks, 98 + .num_clks = ARRAY_SIZE(vdo0_clks), 99 + }; 102 100 103 - clk_data = mtk_alloc_clk_data(CLK_VDO0_NR_CLK); 104 - if (!clk_data) 105 - return -ENOMEM; 106 - 107 - r = mtk_clk_register_gates(&pdev->dev, node, vdo0_clks, 108 - ARRAY_SIZE(vdo0_clks), clk_data); 109 - if (r) 110 - goto free_vdo0_data; 111 - 112 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 113 - if (r) 114 - goto unregister_gates; 115 - 116 - platform_set_drvdata(pdev, clk_data); 117 - 118 - return r; 119 - 120 - unregister_gates: 121 - mtk_clk_unregister_gates(vdo0_clks, ARRAY_SIZE(vdo0_clks), clk_data); 122 - free_vdo0_data: 123 - mtk_free_clk_data(clk_data); 124 - return r; 125 - } 126 - 127 - static int clk_mt8195_vdo0_remove(struct platform_device *pdev) 128 - { 129 - struct device *dev = &pdev->dev; 130 - struct device_node *node = dev->parent->of_node; 131 - struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev); 132 - 133 - of_clk_del_provider(node); 134 - mtk_clk_unregister_gates(vdo0_clks, ARRAY_SIZE(vdo0_clks), clk_data); 135 - mtk_free_clk_data(clk_data); 136 - 137 - return 0; 138 - } 101 + static const struct platform_device_id clk_mt8195_vdo0_id_table[] = { 102 + { .name = "clk-mt8195-vdo0", .driver_data = (kernel_ulong_t)&vdo0_desc }, 103 + { /* sentinel */ } 104 + }; 105 + MODULE_DEVICE_TABLE(platform, clk_mt8195_vdo0_id_table); 139 106 140 107 static struct platform_driver clk_mt8195_vdo0_drv = { 141 - .probe = clk_mt8195_vdo0_probe, 142 - .remove = clk_mt8195_vdo0_remove, 108 + .probe = mtk_clk_pdev_probe, 109 + .remove = mtk_clk_pdev_remove, 143 110 .driver = { 144 111 .name = "clk-mt8195-vdo0", 145 112 }, 113 + .id_table = clk_mt8195_vdo0_id_table, 146 114 }; 147 - builtin_platform_driver(clk_mt8195_vdo0_drv); 115 + module_platform_driver(clk_mt8195_vdo0_drv); 116 + MODULE_LICENSE("GPL");
+14 -45
drivers/clk/mediatek/clk-mt8195-vdo1.c
··· 120 120 GATE_VDO1_4(CLK_VDO1_DPI1_HDMI, "vdo1_dpi1_hdmi", "hdmi_txpll", 0), 121 121 }; 122 122 123 - static int clk_mt8195_vdo1_probe(struct platform_device *pdev) 124 - { 125 - struct device *dev = &pdev->dev; 126 - struct device_node *node = dev->parent->of_node; 127 - struct clk_hw_onecell_data *clk_data; 128 - int r; 123 + static const struct mtk_clk_desc vdo1_desc = { 124 + .clks = vdo1_clks, 125 + .num_clks = ARRAY_SIZE(vdo1_clks), 126 + }; 129 127 130 - clk_data = mtk_alloc_clk_data(CLK_VDO1_NR_CLK); 131 - if (!clk_data) 132 - return -ENOMEM; 133 - 134 - r = mtk_clk_register_gates(&pdev->dev, node, vdo1_clks, 135 - ARRAY_SIZE(vdo1_clks), clk_data); 136 - if (r) 137 - goto free_vdo1_data; 138 - 139 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 140 - if (r) 141 - goto unregister_gates; 142 - 143 - platform_set_drvdata(pdev, clk_data); 144 - 145 - return r; 146 - 147 - unregister_gates: 148 - mtk_clk_unregister_gates(vdo1_clks, ARRAY_SIZE(vdo1_clks), clk_data); 149 - free_vdo1_data: 150 - mtk_free_clk_data(clk_data); 151 - return r; 152 - } 153 - 154 - static int clk_mt8195_vdo1_remove(struct platform_device *pdev) 155 - { 156 - struct device *dev = &pdev->dev; 157 - struct device_node *node = dev->parent->of_node; 158 - struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev); 159 - 160 - of_clk_del_provider(node); 161 - mtk_clk_unregister_gates(vdo1_clks, ARRAY_SIZE(vdo1_clks), clk_data); 162 - mtk_free_clk_data(clk_data); 163 - 164 - return 0; 165 - } 128 + static const struct platform_device_id clk_mt8195_vdo1_id_table[] = { 129 + { .name = "clk-mt8195-vdo1", .driver_data = (kernel_ulong_t)&vdo1_desc }, 130 + { /* sentinel */ } 131 + }; 132 + MODULE_DEVICE_TABLE(platform, clk_mt8195_vdo1_id_table); 166 133 167 134 static struct platform_driver clk_mt8195_vdo1_drv = { 168 - .probe = clk_mt8195_vdo1_probe, 169 - .remove = clk_mt8195_vdo1_remove, 135 + .probe = mtk_clk_pdev_probe, 136 + .remove = mtk_clk_pdev_remove, 170 137 .driver = { 171 138 .name = "clk-mt8195-vdo1", 172 139 }, 140 + .id_table = clk_mt8195_vdo1_id_table, 173 141 }; 174 - builtin_platform_driver(clk_mt8195_vdo1_drv); 142 + module_platform_driver(clk_mt8195_vdo1_drv); 143 + MODULE_LICENSE("GPL");
+3 -1
drivers/clk/mediatek/clk-mt8195-venc.c
··· 58 58 /* sentinel */ 59 59 } 60 60 }; 61 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8195_venc); 61 62 62 63 static struct platform_driver clk_mt8195_venc_drv = { 63 64 .probe = mtk_clk_simple_probe, ··· 68 67 .of_match_table = of_match_clk_mt8195_venc, 69 68 }, 70 69 }; 71 - builtin_platform_driver(clk_mt8195_venc_drv); 70 + module_platform_driver(clk_mt8195_venc_drv); 71 + MODULE_LICENSE("GPL");
+14 -44
drivers/clk/mediatek/clk-mt8195-vpp0.c
··· 86 86 GATE_VPP0_2(CLK_VPP0_WARP1_MDP_DL_ASYNC, "vpp0_warp1_mdp_dl_async", "top_wpe_vpp", 3), 87 87 }; 88 88 89 - static int clk_mt8195_vpp0_probe(struct platform_device *pdev) 90 - { 91 - struct device *dev = &pdev->dev; 92 - struct device_node *node = dev->parent->of_node; 93 - struct clk_hw_onecell_data *clk_data; 94 - int r; 89 + static const struct mtk_clk_desc vpp0_desc = { 90 + .clks = vpp0_clks, 91 + .num_clks = ARRAY_SIZE(vpp0_clks), 92 + }; 95 93 96 - clk_data = mtk_alloc_clk_data(CLK_VPP0_NR_CLK); 97 - if (!clk_data) 98 - return -ENOMEM; 99 - 100 - r = mtk_clk_register_gates(dev, node, vpp0_clks, ARRAY_SIZE(vpp0_clks), clk_data); 101 - if (r) 102 - goto free_vpp0_data; 103 - 104 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 105 - if (r) 106 - goto unregister_gates; 107 - 108 - platform_set_drvdata(pdev, clk_data); 109 - 110 - return r; 111 - 112 - unregister_gates: 113 - mtk_clk_unregister_gates(vpp0_clks, ARRAY_SIZE(vpp0_clks), clk_data); 114 - free_vpp0_data: 115 - mtk_free_clk_data(clk_data); 116 - return r; 117 - } 118 - 119 - static int clk_mt8195_vpp0_remove(struct platform_device *pdev) 120 - { 121 - struct device *dev = &pdev->dev; 122 - struct device_node *node = dev->parent->of_node; 123 - struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev); 124 - 125 - of_clk_del_provider(node); 126 - mtk_clk_unregister_gates(vpp0_clks, ARRAY_SIZE(vpp0_clks), clk_data); 127 - mtk_free_clk_data(clk_data); 128 - 129 - return 0; 130 - } 94 + static const struct platform_device_id clk_mt8195_vpp0_id_table[] = { 95 + { .name = "clk-mt8195-vpp0", .driver_data = (kernel_ulong_t)&vpp0_desc }, 96 + { /* sentinel */ } 97 + }; 98 + MODULE_DEVICE_TABLE(platform, clk_mt8195_vpp0_id_table); 131 99 132 100 static struct platform_driver clk_mt8195_vpp0_drv = { 133 - .probe = clk_mt8195_vpp0_probe, 134 - .remove = clk_mt8195_vpp0_remove, 101 + .probe = mtk_clk_pdev_probe, 102 + .remove = mtk_clk_pdev_remove, 135 103 .driver = { 136 104 .name = "clk-mt8195-vpp0", 137 105 }, 106 + .id_table = clk_mt8195_vpp0_id_table, 138 107 }; 139 - builtin_platform_driver(clk_mt8195_vpp0_drv); 108 + module_platform_driver(clk_mt8195_vpp0_drv); 109 + MODULE_LICENSE("GPL");
+14 -44
drivers/clk/mediatek/clk-mt8195-vpp1.c
··· 84 84 GATE_VPP1_1(CLK_VPP1_VPP_SPLIT_26M, "vpp1_vpp_split_26m", "clk26m", 26), 85 85 }; 86 86 87 - static int clk_mt8195_vpp1_probe(struct platform_device *pdev) 88 - { 89 - struct device *dev = &pdev->dev; 90 - struct device_node *node = dev->parent->of_node; 91 - struct clk_hw_onecell_data *clk_data; 92 - int r; 87 + static const struct mtk_clk_desc vpp1_desc = { 88 + .clks = vpp1_clks, 89 + .num_clks = ARRAY_SIZE(vpp1_clks), 90 + }; 93 91 94 - clk_data = mtk_alloc_clk_data(CLK_VPP1_NR_CLK); 95 - if (!clk_data) 96 - return -ENOMEM; 97 - 98 - r = mtk_clk_register_gates(dev, node, vpp1_clks, ARRAY_SIZE(vpp1_clks), clk_data); 99 - if (r) 100 - goto free_vpp1_data; 101 - 102 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 103 - if (r) 104 - goto unregister_gates; 105 - 106 - platform_set_drvdata(pdev, clk_data); 107 - 108 - return r; 109 - 110 - unregister_gates: 111 - mtk_clk_unregister_gates(vpp1_clks, ARRAY_SIZE(vpp1_clks), clk_data); 112 - free_vpp1_data: 113 - mtk_free_clk_data(clk_data); 114 - return r; 115 - } 116 - 117 - static int clk_mt8195_vpp1_remove(struct platform_device *pdev) 118 - { 119 - struct device *dev = &pdev->dev; 120 - struct device_node *node = dev->parent->of_node; 121 - struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev); 122 - 123 - of_clk_del_provider(node); 124 - mtk_clk_unregister_gates(vpp1_clks, ARRAY_SIZE(vpp1_clks), clk_data); 125 - mtk_free_clk_data(clk_data); 126 - 127 - return 0; 128 - } 92 + static const struct platform_device_id clk_mt8195_vpp1_id_table[] = { 93 + { .name = "clk-mt8195-vpp1", .driver_data = (kernel_ulong_t)&vpp1_desc }, 94 + { /* sentinel */ } 95 + }; 96 + MODULE_DEVICE_TABLE(platform, clk_mt8195_vpp1_id_table); 129 97 130 98 static struct platform_driver clk_mt8195_vpp1_drv = { 131 - .probe = clk_mt8195_vpp1_probe, 132 - .remove = clk_mt8195_vpp1_remove, 99 + .probe = mtk_clk_pdev_probe, 100 + .remove = mtk_clk_pdev_remove, 133 101 .driver = { 134 102 .name = "clk-mt8195-vpp1", 135 103 }, 104 + .id_table = clk_mt8195_vpp1_id_table, 136 105 }; 137 - builtin_platform_driver(clk_mt8195_vpp1_drv); 106 + module_platform_driver(clk_mt8195_vpp1_drv); 107 + MODULE_LICENSE("GPL");
+3 -1
drivers/clk/mediatek/clk-mt8195-wpe.c
··· 132 132 /* sentinel */ 133 133 } 134 134 }; 135 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8195_wpe); 135 136 136 137 static struct platform_driver clk_mt8195_wpe_drv = { 137 138 .probe = mtk_clk_simple_probe, ··· 142 141 .of_match_table = of_match_clk_mt8195_wpe, 143 142 }, 144 143 }; 145 - builtin_platform_driver(clk_mt8195_wpe_drv); 144 + module_platform_driver(clk_mt8195_wpe_drv); 145 + MODULE_LICENSE("GPL");
+166
drivers/clk/mediatek/clk-mt8365-apmixedsys.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Copyright (c) 2022 MediaTek Inc. 4 + * Copyright (c) 2023 Collabora Ltd. 5 + */ 6 + 7 + #include <dt-bindings/clock/mediatek,mt8365-clk.h> 8 + #include <linux/clk.h> 9 + #include <linux/of.h> 10 + #include <linux/platform_device.h> 11 + 12 + #include "clk-pll.h" 13 + #include "clk-mtk.h" 14 + 15 + #define MT8365_PLL_FMAX (3800UL * MHZ) 16 + #define MT8365_PLL_FMIN (1500UL * MHZ) 17 + #define CON0_MT8365_RST_BAR BIT(23) 18 + 19 + #define PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits, \ 20 + _pd_reg, _pd_shift, _tuner_reg, _tuner_en_reg, \ 21 + _tuner_en_bit, _pcw_reg, _pcw_shift, _div_table, \ 22 + _rst_bar_mask, _pcw_chg_reg) { \ 23 + .id = _id, \ 24 + .name = _name, \ 25 + .reg = _reg, \ 26 + .pwr_reg = _pwr_reg, \ 27 + .en_mask = _en_mask, \ 28 + .flags = _flags, \ 29 + .rst_bar_mask = _rst_bar_mask, \ 30 + .fmax = MT8365_PLL_FMAX, \ 31 + .fmin = MT8365_PLL_FMIN, \ 32 + .pcwbits = _pcwbits, \ 33 + .pcwibits = 8, \ 34 + .pd_reg = _pd_reg, \ 35 + .pd_shift = _pd_shift, \ 36 + .tuner_reg = _tuner_reg, \ 37 + .tuner_en_reg = _tuner_en_reg, \ 38 + .tuner_en_bit = _tuner_en_bit, \ 39 + .pcw_reg = _pcw_reg, \ 40 + .pcw_shift = _pcw_shift, \ 41 + .pcw_chg_reg = _pcw_chg_reg, \ 42 + .div_table = _div_table, \ 43 + } 44 + 45 + #define PLL(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits, \ 46 + _pd_reg, _pd_shift, _tuner_reg, \ 47 + _tuner_en_reg, _tuner_en_bit, _pcw_reg, \ 48 + _pcw_shift, _rst_bar_mask, _pcw_chg_reg) \ 49 + PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags, \ 50 + _pcwbits, _pd_reg, _pd_shift, \ 51 + _tuner_reg, _tuner_en_reg, _tuner_en_bit, \ 52 + _pcw_reg, _pcw_shift, NULL, _rst_bar_mask, \ 53 + _pcw_chg_reg) \ 54 + 55 + static const struct mtk_pll_div_table armpll_div_table[] = { 56 + { .div = 0, .freq = MT8365_PLL_FMAX }, 57 + { .div = 1, .freq = 1500 * MHZ }, 58 + { .div = 2, .freq = 750 * MHZ }, 59 + { .div = 3, .freq = 375 * MHZ }, 60 + { .div = 4, .freq = 182500000 }, 61 + { } /* sentinel */ 62 + }; 63 + 64 + static const struct mtk_pll_div_table mfgpll_div_table[] = { 65 + { .div = 0, .freq = MT8365_PLL_FMAX }, 66 + { .div = 1, .freq = 1600 * MHZ }, 67 + { .div = 2, .freq = 800 * MHZ }, 68 + { .div = 3, .freq = 400 * MHZ }, 69 + { .div = 4, .freq = 200 * MHZ }, 70 + { } /* sentinel */ 71 + }; 72 + 73 + static const struct mtk_pll_div_table dsppll_div_table[] = { 74 + { .div = 0, .freq = MT8365_PLL_FMAX }, 75 + { .div = 1, .freq = 1600 * MHZ }, 76 + { .div = 2, .freq = 600 * MHZ }, 77 + { .div = 3, .freq = 400 * MHZ }, 78 + { .div = 4, .freq = 200 * MHZ }, 79 + { } /* sentinel */ 80 + }; 81 + 82 + static const struct mtk_pll_data plls[] = { 83 + PLL_B(CLK_APMIXED_ARMPLL, "armpll", 0x030C, 0x0318, 0x00000001, PLL_AO, 84 + 22, 0x0310, 24, 0, 0, 0, 0x0310, 0, armpll_div_table, 0, 0), 85 + PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0228, 0x0234, 0xFF000001, 86 + HAVE_RST_BAR, 22, 0x022C, 24, 0, 0, 0, 0x022C, 0, CON0_MT8365_RST_BAR, 0), 87 + PLL(CLK_APMIXED_UNIVPLL, "univpll2", 0x0208, 0x0214, 0xFF000001, 88 + HAVE_RST_BAR, 22, 0x020C, 24, 0, 0, 0, 0x020C, 0, CON0_MT8365_RST_BAR, 0), 89 + PLL_B(CLK_APMIXED_MFGPLL, "mfgpll", 0x0218, 0x0224, 0x00000001, 0, 22, 90 + 0x021C, 24, 0, 0, 0, 0x021C, 0, mfgpll_div_table, 0, 0), 91 + PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x0350, 0x035C, 0x00000001, 0, 22, 92 + 0x0354, 24, 0, 0, 0, 0x0354, 0, 0, 0), 93 + PLL(CLK_APMIXED_MMPLL, "mmpll", 0x0330, 0x033C, 0x00000001, 0, 22, 94 + 0x0334, 24, 0, 0, 0, 0x0334, 0, 0, 0), 95 + PLL(CLK_APMIXED_APLL1, "apll1", 0x031C, 0x032C, 0x00000001, 0, 32, 96 + 0x0320, 24, 0x0040, 0x000C, 0, 0x0324, 0, 0, 0x0320), 97 + PLL(CLK_APMIXED_APLL2, "apll2", 0x0360, 0x0370, 0x00000001, 0, 32, 98 + 0x0364, 24, 0x004C, 0x000C, 5, 0x0368, 0, 0, 0x0364), 99 + PLL(CLK_APMIXED_LVDSPLL, "lvdspll", 0x0374, 0x0380, 0x00000001, 0, 22, 100 + 0x0378, 24, 0, 0, 0, 0x0378, 0, 0, 0), 101 + PLL_B(CLK_APMIXED_DSPPLL, "dsppll", 0x0390, 0x039C, 0x00000001, 0, 22, 102 + 0x0394, 24, 0, 0, 0, 0x0394, 0, dsppll_div_table, 0, 0), 103 + PLL(CLK_APMIXED_APUPLL, "apupll", 0x03A0, 0x03AC, 0x00000001, 0, 22, 104 + 0x03A4, 24, 0, 0, 0, 0x03A4, 0, 0, 0), 105 + }; 106 + 107 + static int clk_mt8365_apmixed_probe(struct platform_device *pdev) 108 + { 109 + void __iomem *base; 110 + struct clk_hw_onecell_data *clk_data; 111 + struct device_node *node = pdev->dev.of_node; 112 + struct device *dev = &pdev->dev; 113 + struct clk_hw *hw; 114 + int ret; 115 + 116 + base = devm_platform_ioremap_resource(pdev, 0); 117 + if (IS_ERR(base)) 118 + return PTR_ERR(base); 119 + 120 + clk_data = mtk_devm_alloc_clk_data(dev, CLK_APMIXED_NR_CLK); 121 + if (!clk_data) 122 + return -ENOMEM; 123 + 124 + hw = devm_clk_hw_register_gate(dev, "univ_en", "univpll2", 0, 125 + base + 0x204, 0, 0, NULL); 126 + if (IS_ERR(hw)) 127 + return PTR_ERR(hw); 128 + clk_data->hws[CLK_APMIXED_UNIV_EN] = hw; 129 + 130 + hw = devm_clk_hw_register_gate(dev, "usb20_en", "univ_en", 0, 131 + base + 0x204, 1, 0, NULL); 132 + if (IS_ERR(hw)) 133 + return PTR_ERR(hw); 134 + clk_data->hws[CLK_APMIXED_USB20_EN] = hw; 135 + 136 + ret = mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data); 137 + if (ret) 138 + return ret; 139 + 140 + ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 141 + if (ret) 142 + goto unregister_plls; 143 + 144 + return 0; 145 + 146 + unregister_plls: 147 + mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data); 148 + 149 + return ret; 150 + } 151 + 152 + static const struct of_device_id of_match_clk_mt8365_apmixed[] = { 153 + { .compatible = "mediatek,mt8365-apmixedsys" }, 154 + { /* sentinel */ } 155 + }; 156 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8365_apmixed); 157 + 158 + static struct platform_driver clk_mt8365_apmixed_drv = { 159 + .probe = clk_mt8365_apmixed_probe, 160 + .driver = { 161 + .name = "clk-mt8365-apmixed", 162 + .of_match_table = of_match_clk_mt8365_apmixed, 163 + }, 164 + }; 165 + builtin_platform_driver(clk_mt8365_apmixed_drv) 166 + MODULE_LICENSE("GPL");
+2 -1
drivers/clk/mediatek/clk-mt8365-apu.c
··· 42 42 /* sentinel */ 43 43 } 44 44 }; 45 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8365_apu); 45 46 46 47 static struct platform_driver clk_mt8365_apu_drv = { 47 48 .probe = mtk_clk_simple_probe, ··· 52 51 .of_match_table = of_match_clk_mt8365_apu, 53 52 }, 54 53 }; 55 - builtin_platform_driver(clk_mt8365_apu_drv); 54 + module_platform_driver(clk_mt8365_apu_drv); 56 55 MODULE_LICENSE("GPL");
+2 -1
drivers/clk/mediatek/clk-mt8365-cam.c
··· 44 44 /* sentinel */ 45 45 } 46 46 }; 47 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8365_cam); 47 48 48 49 static struct platform_driver clk_mt8365_cam_drv = { 49 50 .probe = mtk_clk_simple_probe, ··· 54 53 .of_match_table = of_match_clk_mt8365_cam, 55 54 }, 56 55 }; 57 - builtin_platform_driver(clk_mt8365_cam_drv); 56 + module_platform_driver(clk_mt8365_cam_drv); 58 57 MODULE_LICENSE("GPL");
+2 -1
drivers/clk/mediatek/clk-mt8365-mfg.c
··· 50 50 /* sentinel */ 51 51 } 52 52 }; 53 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8365_mfg); 53 54 54 55 static struct platform_driver clk_mt8365_mfg_drv = { 55 56 .probe = mtk_clk_simple_probe, ··· 60 59 .of_match_table = of_match_clk_mt8365_mfg, 61 60 }, 62 61 }; 63 - builtin_platform_driver(clk_mt8365_mfg_drv); 62 + module_platform_driver(clk_mt8365_mfg_drv); 64 63 MODULE_LICENSE("GPL");
+13 -29
drivers/clk/mediatek/clk-mt8365-mm.c
··· 72 72 GATE_MM1(CLK_MM_LVDSTX_CTS, "mm_flvdstx_cts", "lvdstx_dig_cts", 3), 73 73 }; 74 74 75 - static int clk_mt8365_mm_probe(struct platform_device *pdev) 76 - { 77 - struct device *dev = &pdev->dev; 78 - struct device_node *node = dev->parent->of_node; 79 - struct clk_hw_onecell_data *clk_data; 80 - int ret; 75 + static const struct mtk_clk_desc mm_desc = { 76 + .clks = mm_clks, 77 + .num_clks = ARRAY_SIZE(mm_clks), 78 + }; 81 79 82 - clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK); 83 - 84 - ret = mtk_clk_register_gates(dev, node, mm_clks, 85 - ARRAY_SIZE(mm_clks), clk_data); 86 - if (ret) 87 - goto err_free_clk_data; 88 - 89 - ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 90 - if (ret) 91 - goto err_unregister_gates; 92 - 93 - return 0; 94 - 95 - err_unregister_gates: 96 - mtk_clk_unregister_gates(mm_clks, ARRAY_SIZE(mm_clks), clk_data); 97 - 98 - err_free_clk_data: 99 - mtk_free_clk_data(clk_data); 100 - 101 - return ret; 102 - } 80 + static const struct platform_device_id clk_mt8365_mm_id_table[] = { 81 + { .name = "clk-mt8365-mm", .driver_data = (kernel_ulong_t)&mm_desc }, 82 + { /* sentinel */ } 83 + }; 84 + MODULE_DEVICE_TABLE(platform, clk_mt8365_mm_id_table); 103 85 104 86 static struct platform_driver clk_mt8365_mm_drv = { 105 - .probe = clk_mt8365_mm_probe, 87 + .probe = mtk_clk_pdev_probe, 88 + .remove = mtk_clk_pdev_remove, 106 89 .driver = { 107 90 .name = "clk-mt8365-mm", 108 91 }, 92 + .id_table = clk_mt8365_mm_id_table, 109 93 }; 110 - builtin_platform_driver(clk_mt8365_mm_drv); 94 + module_platform_driver(clk_mt8365_mm_drv); 111 95 MODULE_LICENSE("GPL");
+2 -1
drivers/clk/mediatek/clk-mt8365-vdec.c
··· 50 50 /* sentinel */ 51 51 } 52 52 }; 53 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8365_vdec); 53 54 54 55 static struct platform_driver clk_mt8365_vdec_drv = { 55 56 .probe = mtk_clk_simple_probe, ··· 60 59 .of_match_table = of_match_clk_mt8365_vdec, 61 60 }, 62 61 }; 63 - builtin_platform_driver(clk_mt8365_vdec_drv); 62 + module_platform_driver(clk_mt8365_vdec_drv); 64 63 MODULE_LICENSE("GPL");
+2 -1
drivers/clk/mediatek/clk-mt8365-venc.c
··· 39 39 /* sentinel */ 40 40 } 41 41 }; 42 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8365_venc); 42 43 43 44 static struct platform_driver clk_mt8365_venc_drv = { 44 45 .probe = mtk_clk_simple_probe, ··· 49 48 .of_match_table = of_match_clk_mt8365_venc, 50 49 }, 51 50 }; 52 - builtin_platform_driver(clk_mt8365_venc_drv); 51 + module_platform_driver(clk_mt8365_venc_drv); 53 52 MODULE_LICENSE("GPL");
+115 -467
drivers/clk/mediatek/clk-mt8365.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 /* 3 3 * Copyright (C) 2022 MediaTek Inc. 4 + * Copyright (C) 2023 Collabora Ltd. 5 + * AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> 4 6 */ 5 7 6 8 #include <dt-bindings/clock/mediatek,mt8365-clk.h> ··· 19 17 #include "clk-gate.h" 20 18 #include "clk-mtk.h" 21 19 #include "clk-mux.h" 22 - #include "clk-pll.h" 23 20 24 21 static DEFINE_SPINLOCK(mt8365_clk_lock); 25 22 ··· 384 383 "univpll2_d8" 385 384 }; 386 385 387 - static const char * const apll_i2s0_parents[] = { 386 + static const char * const apll_i2s_parents[] = { 388 387 "aud_1_sel", 389 388 "aud_2_sel" 390 389 }; 391 390 392 - static struct mtk_composite top_misc_mux_gates[] = { 391 + static struct mtk_composite top_misc_muxes[] = { 393 392 /* CLK_CFG_11 */ 394 393 MUX_GATE(CLK_TOP_MBIST_DIAG_SEL, "mbist_diag_sel", mbist_diag_parents, 395 394 0x0ec, 0, 2, 7), 396 - }; 397 - 398 - struct mt8365_clk_audio_mux { 399 - int id; 400 - const char *name; 401 - u8 shift; 402 - }; 403 - 404 - static struct mt8365_clk_audio_mux top_misc_muxes[] = { 405 - { CLK_TOP_APLL_I2S0_SEL, "apll_i2s0_sel", 11}, 406 - { CLK_TOP_APLL_I2S1_SEL, "apll_i2s1_sel", 12}, 407 - { CLK_TOP_APLL_I2S2_SEL, "apll_i2s2_sel", 13}, 408 - { CLK_TOP_APLL_I2S3_SEL, "apll_i2s3_sel", 14}, 409 - { CLK_TOP_APLL_TDMOUT_SEL, "apll_tdmout_sel", 15}, 410 - { CLK_TOP_APLL_TDMIN_SEL, "apll_tdmin_sel", 16}, 411 - { CLK_TOP_APLL_SPDIF_SEL, "apll_spdif_sel", 17}, 395 + /* Audio MUX */ 396 + MUX(CLK_TOP_APLL_I2S0_SEL, "apll_i2s0_sel", apll_i2s_parents, 0x0320, 11, 1), 397 + MUX(CLK_TOP_APLL_I2S1_SEL, "apll_i2s1_sel", apll_i2s_parents, 0x0320, 12, 1), 398 + MUX(CLK_TOP_APLL_I2S2_SEL, "apll_i2s2_sel", apll_i2s_parents, 0x0320, 13, 1), 399 + MUX(CLK_TOP_APLL_I2S3_SEL, "apll_i2s3_sel", apll_i2s_parents, 0x0320, 14, 1), 400 + MUX(CLK_TOP_APLL_TDMOUT_SEL, "apll_tdmout_sel", apll_i2s_parents, 0x0320, 15, 1), 401 + MUX(CLK_TOP_APLL_TDMIN_SEL, "apll_tdmin_sel", apll_i2s_parents, 0x0320, 16, 1), 402 + MUX(CLK_TOP_APLL_SPDIF_SEL, "apll_spdif_sel", apll_i2s_parents, 0x0320, 17, 1), 412 403 }; 413 404 414 405 #define CLK_CFG_UPDATE 0x004 ··· 563 570 0x32c, 0, 8, CLK_DIVIDER_ROUND_CLOSEST), 564 571 }; 565 572 566 - struct mtk_simple_gate { 567 - int id; 568 - const char *name; 569 - const char *parent; 570 - u32 reg; 571 - u8 shift; 572 - unsigned long gate_flags; 573 + static const struct mtk_gate_regs top0_cg_regs = { 574 + .set_ofs = 0, 575 + .clr_ofs = 0, 576 + .sta_ofs = 0, 573 577 }; 574 578 575 - static const struct mtk_simple_gate top_clk_gates[] = { 576 - { CLK_TOP_CONN_32K, "conn_32k", "clk32k", 0x0, 10, CLK_GATE_SET_TO_DISABLE }, 577 - { CLK_TOP_CONN_26M, "conn_26m", "clk26m", 0x0, 11, CLK_GATE_SET_TO_DISABLE }, 578 - { CLK_TOP_DSP_32K, "dsp_32k", "clk32k", 0x0, 16, CLK_GATE_SET_TO_DISABLE }, 579 - { CLK_TOP_DSP_26M, "dsp_26m", "clk26m", 0x0, 17, CLK_GATE_SET_TO_DISABLE }, 580 - { CLK_TOP_USB20_48M_EN, "usb20_48m_en", "usb20_192m_d4", 0x104, 8, 0 }, 581 - { CLK_TOP_UNIVPLL_48M_EN, "univpll_48m_en", "usb20_192m_d4", 0x104, 9, 0 }, 582 - { CLK_TOP_LVDSTX_CLKDIG_EN, "lvdstx_dig_en", "lvdstx_dig_cts", 0x104, 20, 0 }, 583 - { CLK_TOP_VPLL_DPIX_EN, "vpll_dpix_en", "vpll_dpix", 0x104, 21, 0 }, 584 - { CLK_TOP_SSUSB_TOP_CK_EN, "ssusb_top_ck_en", NULL, 0x104, 22, 0 }, 585 - { CLK_TOP_SSUSB_PHY_CK_EN, "ssusb_phy_ck_en", NULL, 0x104, 23, 0 }, 586 - { CLK_TOP_AUD_I2S0_M, "aud_i2s0_m_ck", "apll12_ck_div0", 0x320, 0, 0 }, 587 - { CLK_TOP_AUD_I2S1_M, "aud_i2s1_m_ck", "apll12_ck_div1", 0x320, 1, 0 }, 588 - { CLK_TOP_AUD_I2S2_M, "aud_i2s2_m_ck", "apll12_ck_div2", 0x320, 2, 0 }, 589 - { CLK_TOP_AUD_I2S3_M, "aud_i2s3_m_ck", "apll12_ck_div3", 0x320, 3, 0 }, 590 - { CLK_TOP_AUD_TDMOUT_M, "aud_tdmout_m_ck", "apll12_ck_div4", 0x320, 4, 0 }, 591 - { CLK_TOP_AUD_TDMOUT_B, "aud_tdmout_b_ck", "apll12_ck_div4b", 0x320, 5, 0 }, 592 - { CLK_TOP_AUD_TDMIN_M, "aud_tdmin_m_ck", "apll12_ck_div5", 0x320, 6, 0 }, 593 - { CLK_TOP_AUD_TDMIN_B, "aud_tdmin_b_ck", "apll12_ck_div5b", 0x320, 7, 0 }, 594 - { CLK_TOP_AUD_SPDIF_M, "aud_spdif_m_ck", "apll12_ck_div6", 0x320, 8, 0 }, 579 + static const struct mtk_gate_regs top1_cg_regs = { 580 + .set_ofs = 0x104, 581 + .clr_ofs = 0x104, 582 + .sta_ofs = 0x104, 583 + }; 584 + 585 + static const struct mtk_gate_regs top2_cg_regs = { 586 + .set_ofs = 0x320, 587 + .clr_ofs = 0x320, 588 + .sta_ofs = 0x320, 589 + }; 590 + 591 + #define GATE_TOP0(_id, _name, _parent, _shift) \ 592 + GATE_MTK(_id, _name, _parent, &top0_cg_regs, \ 593 + _shift, &mtk_clk_gate_ops_no_setclr_inv) 594 + 595 + #define GATE_TOP1(_id, _name, _parent, _shift) \ 596 + GATE_MTK(_id, _name, _parent, &top1_cg_regs, \ 597 + _shift, &mtk_clk_gate_ops_no_setclr) 598 + 599 + #define GATE_TOP2(_id, _name, _parent, _shift) \ 600 + GATE_MTK(_id, _name, _parent, &top2_cg_regs, \ 601 + _shift, &mtk_clk_gate_ops_no_setclr) 602 + 603 + static const struct mtk_gate top_clk_gates[] = { 604 + GATE_TOP0(CLK_TOP_CONN_32K, "conn_32k", "clk32k", 10), 605 + GATE_TOP0(CLK_TOP_CONN_26M, "conn_26m", "clk26m", 11), 606 + GATE_TOP0(CLK_TOP_DSP_32K, "dsp_32k", "clk32k", 16), 607 + GATE_TOP0(CLK_TOP_DSP_26M, "dsp_26m", "clk26m", 17), 608 + GATE_TOP1(CLK_TOP_USB20_48M_EN, "usb20_48m_en", "usb20_192m_d4", 8), 609 + GATE_TOP1(CLK_TOP_UNIVPLL_48M_EN, "univpll_48m_en", "usb20_192m_d4", 9), 610 + GATE_TOP1(CLK_TOP_LVDSTX_CLKDIG_EN, "lvdstx_dig_en", "lvdstx_dig_cts", 20), 611 + GATE_TOP1(CLK_TOP_VPLL_DPIX_EN, "vpll_dpix_en", "vpll_dpix", 21), 612 + GATE_TOP1(CLK_TOP_SSUSB_TOP_CK_EN, "ssusb_top_ck_en", NULL, 22), 613 + GATE_TOP1(CLK_TOP_SSUSB_PHY_CK_EN, "ssusb_phy_ck_en", NULL, 23), 614 + GATE_TOP2(CLK_TOP_AUD_I2S0_M, "aud_i2s0_m_ck", "apll12_ck_div0", 0), 615 + GATE_TOP2(CLK_TOP_AUD_I2S1_M, "aud_i2s1_m_ck", "apll12_ck_div1", 1), 616 + GATE_TOP2(CLK_TOP_AUD_I2S2_M, "aud_i2s2_m_ck", "apll12_ck_div2", 2), 617 + GATE_TOP2(CLK_TOP_AUD_I2S3_M, "aud_i2s3_m_ck", "apll12_ck_div3", 3), 618 + GATE_TOP2(CLK_TOP_AUD_TDMOUT_M, "aud_tdmout_m_ck", "apll12_ck_div4", 4), 619 + GATE_TOP2(CLK_TOP_AUD_TDMOUT_B, "aud_tdmout_b_ck", "apll12_ck_div4b", 5), 620 + GATE_TOP2(CLK_TOP_AUD_TDMIN_M, "aud_tdmin_m_ck", "apll12_ck_div5", 6), 621 + GATE_TOP2(CLK_TOP_AUD_TDMIN_B, "aud_tdmin_b_ck", "apll12_ck_div5b", 7), 622 + GATE_TOP2(CLK_TOP_AUD_SPDIF_M, "aud_spdif_m_ck", "apll12_ck_div6", 8), 595 623 }; 596 624 597 625 static const struct mtk_gate_regs ifr2_cg_regs = { ··· 645 631 .sta_ofs = 0xd8, 646 632 }; 647 633 648 - #define GATE_IFR2(_id, _name, _parent, _shift) { \ 649 - .id = _id, \ 650 - .name = _name, \ 651 - .parent_name = _parent, \ 652 - .regs = &ifr2_cg_regs, \ 653 - .shift = _shift, \ 654 - .ops = &mtk_clk_gate_ops_setclr, \ 655 - } 634 + #define GATE_IFRX(_id, _name, _parent, _shift, _regs) \ 635 + GATE_MTK(_id, _name, _parent, _regs, _shift, \ 636 + &mtk_clk_gate_ops_setclr) 656 637 657 - #define GATE_IFR3(_id, _name, _parent, _shift) { \ 658 - .id = _id, \ 659 - .name = _name, \ 660 - .parent_name = _parent, \ 661 - .regs = &ifr3_cg_regs, \ 662 - .shift = _shift, \ 663 - .ops = &mtk_clk_gate_ops_setclr, \ 664 - } 638 + #define GATE_IFR2(_id, _name, _parent, _shift) \ 639 + GATE_IFRX(_id, _name, _parent, _shift, &ifr2_cg_regs) 665 640 666 - #define GATE_IFR4(_id, _name, _parent, _shift) { \ 667 - .id = _id, \ 668 - .name = _name, \ 669 - .parent_name = _parent, \ 670 - .regs = &ifr4_cg_regs, \ 671 - .shift = _shift, \ 672 - .ops = &mtk_clk_gate_ops_setclr, \ 673 - } 641 + #define GATE_IFR3(_id, _name, _parent, _shift) \ 642 + GATE_IFRX(_id, _name, _parent, _shift, &ifr3_cg_regs) 674 643 675 - #define GATE_IFR5(_id, _name, _parent, _shift) { \ 676 - .id = _id, \ 677 - .name = _name, \ 678 - .parent_name = _parent, \ 679 - .regs = &ifr5_cg_regs, \ 680 - .shift = _shift, \ 681 - .ops = &mtk_clk_gate_ops_setclr, \ 682 - } 644 + #define GATE_IFR4(_id, _name, _parent, _shift) \ 645 + GATE_IFRX(_id, _name, _parent, _shift, &ifr4_cg_regs) 683 646 684 - #define GATE_IFR6(_id, _name, _parent, _shift) { \ 685 - .id = _id, \ 686 - .name = _name, \ 687 - .parent_name = _parent, \ 688 - .regs = &ifr6_cg_regs, \ 689 - .shift = _shift, \ 690 - .ops = &mtk_clk_gate_ops_setclr, \ 691 - } 647 + #define GATE_IFR5(_id, _name, _parent, _shift) \ 648 + GATE_IFRX(_id, _name, _parent, _shift, &ifr5_cg_regs) 649 + 650 + #define GATE_IFR6(_id, _name, _parent, _shift) \ 651 + GATE_IFRX(_id, _name, _parent, _shift, &ifr6_cg_regs) 692 652 693 653 static const struct mtk_gate ifr_clks[] = { 694 654 /* IFR2 */ ··· 741 753 GATE_IFR6(CLK_IFR_SSUSB_XHCI, "ifr_ssusb_xhci", "ssusb_xhci_sel", 11), 742 754 }; 743 755 744 - static const struct mtk_simple_gate peri_clks[] = { 745 - { CLK_PERIAXI, "periaxi", "axi_sel", 0x20c, 31, 0 }, 756 + static const struct mtk_gate_regs peri_cg_regs = { 757 + .set_ofs = 0x20c, 758 + .clr_ofs = 0x20c, 759 + .sta_ofs = 0x20c, 746 760 }; 747 761 748 - #define MT8365_PLL_FMAX (3800UL * MHZ) 749 - #define MT8365_PLL_FMIN (1500UL * MHZ) 750 - #define CON0_MT8365_RST_BAR BIT(23) 751 - 752 - #define PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits, \ 753 - _pd_reg, _pd_shift, _tuner_reg, _tuner_en_reg, \ 754 - _tuner_en_bit, _pcw_reg, _pcw_shift, _div_table, \ 755 - _rst_bar_mask, _pcw_chg_reg) { \ 756 - .id = _id, \ 757 - .name = _name, \ 758 - .reg = _reg, \ 759 - .pwr_reg = _pwr_reg, \ 760 - .en_mask = _en_mask, \ 761 - .flags = _flags, \ 762 - .rst_bar_mask = _rst_bar_mask, \ 763 - .fmax = MT8365_PLL_FMAX, \ 764 - .fmin = MT8365_PLL_FMIN, \ 765 - .pcwbits = _pcwbits, \ 766 - .pcwibits = 8, \ 767 - .pd_reg = _pd_reg, \ 768 - .pd_shift = _pd_shift, \ 769 - .tuner_reg = _tuner_reg, \ 770 - .tuner_en_reg = _tuner_en_reg, \ 771 - .tuner_en_bit = _tuner_en_bit, \ 772 - .pcw_reg = _pcw_reg, \ 773 - .pcw_shift = _pcw_shift, \ 774 - .pcw_chg_reg = _pcw_chg_reg, \ 775 - .div_table = _div_table, \ 776 - } 777 - 778 - #define PLL(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits, \ 779 - _pd_reg, _pd_shift, _tuner_reg, \ 780 - _tuner_en_reg, _tuner_en_bit, _pcw_reg, \ 781 - _pcw_shift, _rst_bar_mask, _pcw_chg_reg) \ 782 - PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags, \ 783 - _pcwbits, _pd_reg, _pd_shift, \ 784 - _tuner_reg, _tuner_en_reg, _tuner_en_bit, \ 785 - _pcw_reg, _pcw_shift, NULL, _rst_bar_mask, \ 786 - _pcw_chg_reg) \ 787 - 788 - static const struct mtk_pll_div_table armpll_div_table[] = { 789 - { .div = 0, .freq = MT8365_PLL_FMAX }, 790 - { .div = 1, .freq = 1500 * MHZ }, 791 - { .div = 2, .freq = 750 * MHZ }, 792 - { .div = 3, .freq = 375 * MHZ }, 793 - { .div = 4, .freq = 182500000 }, 794 - { } /* sentinel */ 762 + static const struct mtk_gate peri_clks[] = { 763 + GATE_MTK(CLK_PERIAXI, "periaxi", "axi_sel", &peri_cg_regs, 31, 764 + &mtk_clk_gate_ops_no_setclr), 795 765 }; 796 766 797 - static const struct mtk_pll_div_table mfgpll_div_table[] = { 798 - { .div = 0, .freq = MT8365_PLL_FMAX }, 799 - { .div = 1, .freq = 1600 * MHZ }, 800 - { .div = 2, .freq = 800 * MHZ }, 801 - { .div = 3, .freq = 400 * MHZ }, 802 - { .div = 4, .freq = 200 * MHZ }, 803 - { } /* sentinel */ 767 + static const struct mtk_clk_desc topck_desc = { 768 + .clks = top_clk_gates, 769 + .num_clks = ARRAY_SIZE(top_clk_gates), 770 + .fixed_clks = top_fixed_clks, 771 + .num_fixed_clks = ARRAY_SIZE(top_fixed_clks), 772 + .factor_clks = top_divs, 773 + .num_factor_clks = ARRAY_SIZE(top_divs), 774 + .mux_clks = top_muxes, 775 + .num_mux_clks = ARRAY_SIZE(top_muxes), 776 + .composite_clks = top_misc_muxes, 777 + .num_composite_clks = ARRAY_SIZE(top_misc_muxes), 778 + .divider_clks = top_adj_divs, 779 + .num_divider_clks = ARRAY_SIZE(top_adj_divs), 780 + .clk_lock = &mt8365_clk_lock, 804 781 }; 805 782 806 - static const struct mtk_pll_div_table dsppll_div_table[] = { 807 - { .div = 0, .freq = MT8365_PLL_FMAX }, 808 - { .div = 1, .freq = 1600 * MHZ }, 809 - { .div = 2, .freq = 600 * MHZ }, 810 - { .div = 3, .freq = 400 * MHZ }, 811 - { .div = 4, .freq = 200 * MHZ }, 812 - { } /* sentinel */ 783 + static const struct mtk_clk_desc infra_desc = { 784 + .clks = ifr_clks, 785 + .num_clks = ARRAY_SIZE(ifr_clks), 813 786 }; 814 787 815 - static const struct mtk_pll_data plls[] = { 816 - PLL_B(CLK_APMIXED_ARMPLL, "armpll", 0x030C, 0x0318, 0x00000001, PLL_AO, 817 - 22, 0x0310, 24, 0, 0, 0, 0x0310, 0, armpll_div_table, 0, 0), 818 - PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0228, 0x0234, 0xFF000001, 819 - HAVE_RST_BAR, 22, 0x022C, 24, 0, 0, 0, 0x022C, 0, 820 - CON0_MT8365_RST_BAR, 0), 821 - PLL(CLK_APMIXED_UNIVPLL, "univpll2", 0x0208, 0x0214, 0xFF000001, 822 - HAVE_RST_BAR, 22, 0x020C, 24, 0, 0, 0, 0x020C, 0, 823 - CON0_MT8365_RST_BAR, 0), 824 - PLL_B(CLK_APMIXED_MFGPLL, "mfgpll", 0x0218, 0x0224, 0x00000001, 0, 22, 825 - 0x021C, 24, 0, 0, 0, 0x021C, 0, mfgpll_div_table, 0, 0), 826 - PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x0350, 0x035C, 0x00000001, 0, 22, 827 - 0x0354, 24, 0, 0, 0, 0x0354, 0, 0, 0), 828 - PLL(CLK_APMIXED_MMPLL, "mmpll", 0x0330, 0x033C, 0x00000001, 0, 22, 829 - 0x0334, 24, 0, 0, 0, 0x0334, 0, 0, 0), 830 - PLL(CLK_APMIXED_APLL1, "apll1", 0x031C, 0x032C, 0x00000001, 0, 32, 831 - 0x0320, 24, 0x0040, 0x000C, 0, 0x0324, 0, 0, 0x0320), 832 - PLL(CLK_APMIXED_APLL2, "apll2", 0x0360, 0x0370, 0x00000001, 0, 32, 833 - 0x0364, 24, 0x004C, 0x000C, 5, 0x0368, 0, 0, 0x0364), 834 - PLL(CLK_APMIXED_LVDSPLL, "lvdspll", 0x0374, 0x0380, 0x00000001, 0, 22, 835 - 0x0378, 24, 0, 0, 0, 0x0378, 0, 0, 0), 836 - PLL_B(CLK_APMIXED_DSPPLL, "dsppll", 0x0390, 0x039C, 0x00000001, 0, 22, 837 - 0x0394, 24, 0, 0, 0, 0x0394, 0, dsppll_div_table, 0, 0), 838 - PLL(CLK_APMIXED_APUPLL, "apupll", 0x03A0, 0x03AC, 0x00000001, 0, 22, 839 - 0x03A4, 24, 0, 0, 0, 0x03A4, 0, 0, 0), 788 + static const struct mtk_clk_desc peri_desc = { 789 + .clks = peri_clks, 790 + .num_clks = ARRAY_SIZE(peri_clks), 840 791 }; 841 792 842 - static int clk_mt8365_apmixed_probe(struct platform_device *pdev) 843 - { 844 - void __iomem *base; 845 - struct clk_hw_onecell_data *clk_data; 846 - struct device_node *node = pdev->dev.of_node; 847 - struct device *dev = &pdev->dev; 848 - struct clk_hw *hw; 849 - int ret; 850 - 851 - base = devm_platform_ioremap_resource(pdev, 0); 852 - if (IS_ERR(base)) 853 - return PTR_ERR(base); 854 - 855 - clk_data = mtk_devm_alloc_clk_data(dev, CLK_APMIXED_NR_CLK); 856 - if (!clk_data) 857 - return -ENOMEM; 858 - 859 - hw = devm_clk_hw_register_gate(dev, "univ_en", "univpll2", 0, 860 - base + 0x204, 0, 0, NULL); 861 - if (IS_ERR(hw)) 862 - return PTR_ERR(hw); 863 - clk_data->hws[CLK_APMIXED_UNIV_EN] = hw; 864 - 865 - hw = devm_clk_hw_register_gate(dev, "usb20_en", "univ_en", 0, 866 - base + 0x204, 1, 0, NULL); 867 - if (IS_ERR(hw)) 868 - return PTR_ERR(hw); 869 - clk_data->hws[CLK_APMIXED_USB20_EN] = hw; 870 - 871 - ret = mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data); 872 - if (ret) 873 - return ret; 874 - 875 - ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 876 - if (ret) 877 - goto unregister_plls; 878 - 879 - return 0; 880 - 881 - unregister_plls: 882 - mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data); 883 - 884 - return ret; 885 - } 886 - 887 - static int 888 - clk_mt8365_register_mtk_simple_gates(struct device *dev, void __iomem *base, 889 - struct clk_hw_onecell_data *clk_data, 890 - const struct mtk_simple_gate *gates, 891 - unsigned int num_gates) 892 - { 893 - unsigned int i; 894 - 895 - for (i = 0; i != num_gates; ++i) { 896 - const struct mtk_simple_gate *gate = &gates[i]; 897 - struct clk_hw *hw; 898 - 899 - hw = devm_clk_hw_register_gate(dev, gate->name, gate->parent, 0, 900 - base + gate->reg, gate->shift, 901 - gate->gate_flags, NULL); 902 - if (IS_ERR(hw)) 903 - return PTR_ERR(hw); 904 - 905 - clk_data->hws[gate->id] = hw; 906 - } 907 - 908 - return 0; 909 - } 910 - 911 - static int clk_mt8365_top_probe(struct platform_device *pdev) 912 - { 913 - void __iomem *base; 914 - struct clk_hw_onecell_data *clk_data; 915 - struct device_node *node = pdev->dev.of_node; 916 - struct device *dev = &pdev->dev; 917 - int ret; 918 - int i; 919 - 920 - base = devm_platform_ioremap_resource(pdev, 0); 921 - if (IS_ERR(base)) 922 - return PTR_ERR(base); 923 - 924 - clk_data = mtk_alloc_clk_data(CLK_TOP_NR_CLK); 925 - if (!clk_data) 926 - return -ENOMEM; 927 - 928 - ret = mtk_clk_register_fixed_clks(top_fixed_clks, 929 - ARRAY_SIZE(top_fixed_clks), clk_data); 930 - if (ret) 931 - goto free_clk_data; 932 - 933 - ret = mtk_clk_register_factors(top_divs, ARRAY_SIZE(top_divs), 934 - clk_data); 935 - if (ret) 936 - goto unregister_fixed_clks; 937 - 938 - ret = mtk_clk_register_muxes(&pdev->dev, top_muxes, 939 - ARRAY_SIZE(top_muxes), node, 940 - &mt8365_clk_lock, clk_data); 941 - if (ret) 942 - goto unregister_factors; 943 - 944 - ret = mtk_clk_register_composites(&pdev->dev, top_misc_mux_gates, 945 - ARRAY_SIZE(top_misc_mux_gates), base, 946 - &mt8365_clk_lock, clk_data); 947 - if (ret) 948 - goto unregister_muxes; 949 - 950 - for (i = 0; i != ARRAY_SIZE(top_misc_muxes); ++i) { 951 - struct mt8365_clk_audio_mux *mux = &top_misc_muxes[i]; 952 - struct clk_hw *hw; 953 - 954 - hw = devm_clk_hw_register_mux(dev, mux->name, apll_i2s0_parents, 955 - ARRAY_SIZE(apll_i2s0_parents), 956 - CLK_SET_RATE_PARENT, base + 0x320, 957 - mux->shift, 1, 0, NULL); 958 - if (IS_ERR(hw)) { 959 - ret = PTR_ERR(hw); 960 - goto unregister_composites; 961 - } 962 - 963 - clk_data->hws[mux->id] = hw; 964 - } 965 - 966 - ret = mtk_clk_register_dividers(top_adj_divs, ARRAY_SIZE(top_adj_divs), 967 - base, &mt8365_clk_lock, clk_data); 968 - if (ret) 969 - goto unregister_composites; 970 - 971 - ret = clk_mt8365_register_mtk_simple_gates(dev, base, clk_data, 972 - top_clk_gates, 973 - ARRAY_SIZE(top_clk_gates)); 974 - if (ret) 975 - goto unregister_dividers; 976 - 977 - ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 978 - if (ret) 979 - goto unregister_dividers; 980 - 981 - return 0; 982 - unregister_dividers: 983 - mtk_clk_unregister_dividers(top_adj_divs, ARRAY_SIZE(top_adj_divs), 984 - clk_data); 985 - unregister_composites: 986 - mtk_clk_unregister_composites(top_misc_mux_gates, 987 - ARRAY_SIZE(top_misc_mux_gates), clk_data); 988 - unregister_muxes: 989 - mtk_clk_unregister_muxes(top_muxes, ARRAY_SIZE(top_muxes), clk_data); 990 - unregister_factors: 991 - mtk_clk_unregister_factors(top_divs, ARRAY_SIZE(top_divs), clk_data); 992 - unregister_fixed_clks: 993 - mtk_clk_unregister_fixed_clks(top_fixed_clks, 994 - ARRAY_SIZE(top_fixed_clks), clk_data); 995 - free_clk_data: 996 - mtk_free_clk_data(clk_data); 997 - 998 - return ret; 999 - } 1000 - 1001 - static int clk_mt8365_infra_probe(struct platform_device *pdev) 1002 - { 1003 - struct clk_hw_onecell_data *clk_data; 1004 - struct device_node *node = pdev->dev.of_node; 1005 - int ret; 1006 - 1007 - clk_data = mtk_alloc_clk_data(CLK_IFR_NR_CLK); 1008 - if (!clk_data) 1009 - return -ENOMEM; 1010 - 1011 - ret = mtk_clk_register_gates(&pdev->dev, node, ifr_clks, 1012 - ARRAY_SIZE(ifr_clks), clk_data); 1013 - if (ret) 1014 - goto free_clk_data; 1015 - 1016 - ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 1017 - if (ret) 1018 - goto unregister_gates; 1019 - 1020 - return 0; 1021 - 1022 - unregister_gates: 1023 - mtk_clk_unregister_gates(ifr_clks, ARRAY_SIZE(ifr_clks), clk_data); 1024 - free_clk_data: 1025 - mtk_free_clk_data(clk_data); 1026 - 1027 - return ret; 1028 - } 1029 - 1030 - static int clk_mt8365_peri_probe(struct platform_device *pdev) 1031 - { 1032 - void __iomem *base; 1033 - struct clk_hw_onecell_data *clk_data; 1034 - struct device *dev = &pdev->dev; 1035 - struct device_node *node = dev->of_node; 1036 - int ret; 1037 - 1038 - base = devm_platform_ioremap_resource(pdev, 0); 1039 - if (IS_ERR(base)) 1040 - return PTR_ERR(base); 1041 - 1042 - clk_data = mtk_devm_alloc_clk_data(dev, CLK_PERI_NR_CLK); 1043 - if (!clk_data) 1044 - return -ENOMEM; 1045 - 1046 - ret = clk_mt8365_register_mtk_simple_gates(dev, base, clk_data, 1047 - peri_clks, 1048 - ARRAY_SIZE(peri_clks)); 1049 - if (ret) 1050 - return ret; 1051 - 1052 - ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 1053 - 1054 - return ret; 1055 - } 1056 - 1057 - static int clk_mt8365_mcu_probe(struct platform_device *pdev) 1058 - { 1059 - struct clk_hw_onecell_data *clk_data; 1060 - struct device_node *node = pdev->dev.of_node; 1061 - void __iomem *base; 1062 - int ret; 1063 - 1064 - base = devm_platform_ioremap_resource(pdev, 0); 1065 - if (IS_ERR(base)) 1066 - return PTR_ERR(base); 1067 - 1068 - clk_data = mtk_alloc_clk_data(CLK_MCU_NR_CLK); 1069 - if (!clk_data) 1070 - return -ENOMEM; 1071 - 1072 - ret = mtk_clk_register_composites(&pdev->dev, mcu_muxes, 1073 - ARRAY_SIZE(mcu_muxes), base, 1074 - &mt8365_clk_lock, clk_data); 1075 - if (ret) 1076 - goto free_clk_data; 1077 - 1078 - ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 1079 - if (ret) 1080 - goto unregister_composites; 1081 - 1082 - return 0; 1083 - 1084 - unregister_composites: 1085 - mtk_clk_unregister_composites(mcu_muxes, ARRAY_SIZE(mcu_muxes), 1086 - clk_data); 1087 - free_clk_data: 1088 - mtk_free_clk_data(clk_data); 1089 - 1090 - return ret; 1091 - } 793 + static const struct mtk_clk_desc mcu_desc = { 794 + .composite_clks = mcu_muxes, 795 + .num_composite_clks = ARRAY_SIZE(mcu_muxes), 796 + .clk_lock = &mt8365_clk_lock, 797 + }; 1092 798 1093 799 static const struct of_device_id of_match_clk_mt8365[] = { 1094 - { 1095 - .compatible = "mediatek,mt8365-apmixedsys", 1096 - .data = clk_mt8365_apmixed_probe, 1097 - }, { 1098 - .compatible = "mediatek,mt8365-topckgen", 1099 - .data = clk_mt8365_top_probe, 1100 - }, { 1101 - .compatible = "mediatek,mt8365-infracfg", 1102 - .data = clk_mt8365_infra_probe, 1103 - }, { 1104 - .compatible = "mediatek,mt8365-pericfg", 1105 - .data = clk_mt8365_peri_probe, 1106 - }, { 1107 - .compatible = "mediatek,mt8365-mcucfg", 1108 - .data = clk_mt8365_mcu_probe, 1109 - }, { 1110 - /* sentinel */ 1111 - } 800 + { .compatible = "mediatek,mt8365-topckgen", .data = &topck_desc }, 801 + { .compatible = "mediatek,mt8365-infracfg", .data = &infra_desc }, 802 + { .compatible = "mediatek,mt8365-pericfg", .data = &peri_desc }, 803 + { .compatible = "mediatek,mt8365-mcucfg", .data = &mcu_desc }, 804 + { /* sentinel */ } 1112 805 }; 1113 - 1114 - static int clk_mt8365_probe(struct platform_device *pdev) 1115 - { 1116 - int (*clk_probe)(struct platform_device *pdev); 1117 - int ret; 1118 - 1119 - clk_probe = of_device_get_match_data(&pdev->dev); 1120 - if (!clk_probe) 1121 - return -EINVAL; 1122 - 1123 - ret = clk_probe(pdev); 1124 - if (ret) 1125 - dev_err(&pdev->dev, 1126 - "%s: could not register clock provider: %d\n", 1127 - pdev->name, ret); 1128 - 1129 - return ret; 1130 - } 806 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8365); 1131 807 1132 808 static struct platform_driver clk_mt8365_drv = { 1133 - .probe = clk_mt8365_probe, 1134 809 .driver = { 1135 810 .name = "clk-mt8365", 1136 811 .of_match_table = of_match_clk_mt8365, 1137 812 }, 813 + .probe = mtk_clk_simple_probe, 814 + .remove = mtk_clk_simple_remove, 1138 815 }; 1139 - 1140 - static int __init clk_mt8365_init(void) 1141 - { 1142 - return platform_driver_register(&clk_mt8365_drv); 1143 - } 1144 - arch_initcall(clk_mt8365_init); 816 + module_platform_driver(clk_mt8365_drv); 1145 817 MODULE_LICENSE("GPL");
+122
drivers/clk/mediatek/clk-mt8516-apmixedsys.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Copyright (c) 2019 MediaTek Inc. 4 + * James Liao <jamesjj.liao@mediatek.com> 5 + * Fabien Parent <fparent@baylibre.com> 6 + * 7 + * Copyright (c) 2023 Collabora, Ltd. 8 + * AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> 9 + */ 10 + 11 + #include <dt-bindings/clock/mt8516-clk.h> 12 + #include <linux/clk.h> 13 + #include <linux/of.h> 14 + #include <linux/platform_device.h> 15 + 16 + #include "clk-mtk.h" 17 + #include "clk-pll.h" 18 + 19 + #define MT8516_PLL_FMAX (1502UL * MHZ) 20 + 21 + #define CON0_MT8516_RST_BAR BIT(27) 22 + 23 + #define PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits, \ 24 + _pd_reg, _pd_shift, _tuner_reg, _pcw_reg, \ 25 + _pcw_shift, _div_table) { \ 26 + .id = _id, \ 27 + .name = _name, \ 28 + .reg = _reg, \ 29 + .pwr_reg = _pwr_reg, \ 30 + .en_mask = _en_mask, \ 31 + .flags = _flags, \ 32 + .rst_bar_mask = CON0_MT8516_RST_BAR, \ 33 + .fmax = MT8516_PLL_FMAX, \ 34 + .pcwbits = _pcwbits, \ 35 + .pd_reg = _pd_reg, \ 36 + .pd_shift = _pd_shift, \ 37 + .tuner_reg = _tuner_reg, \ 38 + .pcw_reg = _pcw_reg, \ 39 + .pcw_shift = _pcw_shift, \ 40 + .div_table = _div_table, \ 41 + } 42 + 43 + #define PLL(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits, \ 44 + _pd_reg, _pd_shift, _tuner_reg, _pcw_reg, \ 45 + _pcw_shift) \ 46 + PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits, \ 47 + _pd_reg, _pd_shift, _tuner_reg, _pcw_reg, _pcw_shift, \ 48 + NULL) 49 + 50 + static const struct mtk_pll_div_table mmpll_div_table[] = { 51 + { .div = 0, .freq = MT8516_PLL_FMAX }, 52 + { .div = 1, .freq = 1000000000 }, 53 + { .div = 2, .freq = 604500000 }, 54 + { .div = 3, .freq = 253500000 }, 55 + { .div = 4, .freq = 126750000 }, 56 + { } /* sentinel */ 57 + }; 58 + 59 + static const struct mtk_pll_data plls[] = { 60 + PLL(CLK_APMIXED_ARMPLL, "armpll", 0x0100, 0x0110, 0, 0, 61 + 21, 0x0104, 24, 0, 0x0104, 0), 62 + PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0120, 0x0130, 0, 63 + HAVE_RST_BAR, 21, 0x0124, 24, 0, 0x0124, 0), 64 + PLL(CLK_APMIXED_UNIVPLL, "univpll", 0x0140, 0x0150, 0x30000000, 65 + HAVE_RST_BAR, 7, 0x0144, 24, 0, 0x0144, 0), 66 + PLL_B(CLK_APMIXED_MMPLL, "mmpll", 0x0160, 0x0170, 0, 0, 67 + 21, 0x0164, 24, 0, 0x0164, 0, mmpll_div_table), 68 + PLL(CLK_APMIXED_APLL1, "apll1", 0x0180, 0x0190, 0, 0, 69 + 31, 0x0180, 1, 0x0194, 0x0184, 0), 70 + PLL(CLK_APMIXED_APLL2, "apll2", 0x01A0, 0x01B0, 0, 0, 71 + 31, 0x01A0, 1, 0x01B4, 0x01A4, 0), 72 + }; 73 + 74 + static int clk_mt8516_apmixed_probe(struct platform_device *pdev) 75 + { 76 + void __iomem *base; 77 + struct clk_hw_onecell_data *clk_data; 78 + struct device_node *node = pdev->dev.of_node; 79 + struct device *dev = &pdev->dev; 80 + int ret; 81 + 82 + base = devm_platform_ioremap_resource(pdev, 0); 83 + if (IS_ERR(base)) 84 + return PTR_ERR(base); 85 + 86 + clk_data = mtk_devm_alloc_clk_data(dev, CLK_APMIXED_NR_CLK); 87 + if (!clk_data) 88 + return -ENOMEM; 89 + 90 + ret = mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data); 91 + if (ret) 92 + return ret; 93 + 94 + ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 95 + if (ret) 96 + goto unregister_plls; 97 + 98 + return 0; 99 + 100 + unregister_plls: 101 + mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data); 102 + 103 + return ret; 104 + } 105 + 106 + static const struct of_device_id of_match_clk_mt8516_apmixed[] = { 107 + { .compatible = "mediatek,mt8516-apmixedsys" }, 108 + { /* sentinel */ } 109 + }; 110 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8516_apmixed); 111 + 112 + static struct platform_driver clk_mt8516_apmixed_drv = { 113 + .probe = clk_mt8516_apmixed_probe, 114 + .driver = { 115 + .name = "clk-mt8516-apmixed", 116 + .of_match_table = of_match_clk_mt8516_apmixed, 117 + }, 118 + }; 119 + builtin_platform_driver(clk_mt8516_apmixed_drv) 120 + 121 + MODULE_DESCRIPTION("MediaTek MT8516 apmixedsys clocks driver"); 122 + MODULE_LICENSE("GPL");
+24 -22
drivers/clk/mediatek/clk-mt8516-aud.c
··· 3 3 * Copyright (c) 2019 MediaTek Inc. 4 4 * Author: James Liao <jamesjj.liao@mediatek.com> 5 5 * Fabien Parent <fparent@baylibre.com> 6 + * Copyright (c) 2023 Collabora Ltd. 6 7 */ 7 8 8 9 #include <linux/clk-provider.h> ··· 23 22 .sta_ofs = 0x0, 24 23 }; 25 24 26 - #define GATE_AUD(_id, _name, _parent, _shift) { \ 27 - .id = _id, \ 28 - .name = _name, \ 29 - .parent_name = _parent, \ 30 - .regs = &aud_cg_regs, \ 31 - .shift = _shift, \ 32 - .ops = &mtk_clk_gate_ops_no_setclr, \ 33 - } 25 + #define GATE_AUD(_id, _name, _parent, _shift) \ 26 + GATE_MTK(_id, _name, _parent, &aud_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr) 34 27 35 - static const struct mtk_gate aud_clks[] __initconst = { 28 + static const struct mtk_gate aud_clks[] = { 36 29 GATE_AUD(CLK_AUD_AFE, "aud_afe", "clk26m_ck", 2), 37 30 GATE_AUD(CLK_AUD_I2S, "aud_i2s", "i2s_infra_bck", 6), 38 31 GATE_AUD(CLK_AUD_22M, "aud_22m", "rg_aud_engen1", 8), ··· 42 47 GATE_AUD(CLK_AUD_TML, "aud_tml", "aud_afe", 27), 43 48 }; 44 49 45 - static void __init mtk_audsys_init(struct device_node *node) 46 - { 47 - struct clk_hw_onecell_data *clk_data; 48 - int r; 50 + static const struct mtk_clk_desc aud_desc = { 51 + .clks = aud_clks, 52 + .num_clks = ARRAY_SIZE(aud_clks), 53 + }; 49 54 50 - clk_data = mtk_alloc_clk_data(CLK_AUD_NR_CLK); 55 + static const struct of_device_id of_match_clk_mt8516_aud[] = { 56 + { .compatible = "mediatek,mt8516-audsys", .data = &aud_desc }, 57 + { /* sentinel */ } 58 + }; 59 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8516_aud); 51 60 52 - mtk_clk_register_gates(NULL, node, aud_clks, ARRAY_SIZE(aud_clks), clk_data); 61 + static struct platform_driver clk_mt8516_aud_drv = { 62 + .probe = mtk_clk_simple_probe, 63 + .remove = mtk_clk_simple_remove, 64 + .driver = { 65 + .name = "clk-mt8516-aud", 66 + .of_match_table = of_match_clk_mt8516_aud, 67 + }, 68 + }; 69 + module_platform_driver(clk_mt8516_aud_drv); 53 70 54 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 55 - if (r) 56 - pr_err("%s(): could not register clock provider: %d\n", 57 - __func__, r); 58 - 59 - } 60 - CLK_OF_DECLARE(mtk_audsys, "mediatek,mt8516-audsys", mtk_audsys_init); 71 + MODULE_DESCRIPTION("MediaTek MT8516 audiosys clocks driver"); 72 + MODULE_LICENSE("GPL");
+47 -179
drivers/clk/mediatek/clk-mt8516.c
··· 3 3 * Copyright (c) 2019 MediaTek Inc. 4 4 * Author: James Liao <jamesjj.liao@mediatek.com> 5 5 * Fabien Parent <fparent@baylibre.com> 6 + * Copyright (c) 2023 Collabora Ltd. 6 7 */ 7 8 8 9 #include <linux/delay.h> ··· 11 10 #include <linux/of_address.h> 12 11 #include <linux/slab.h> 13 12 #include <linux/mfd/syscon.h> 13 + #include <linux/platform_device.h> 14 14 15 15 #include "clk-gate.h" 16 16 #include "clk-mtk.h" 17 - #include "clk-pll.h" 18 17 19 18 #include <dt-bindings/clock/mt8516-clk.h> 20 19 ··· 526 525 .sta_ofs = 0x44, 527 526 }; 528 527 529 - #define GATE_TOP1(_id, _name, _parent, _shift) { \ 530 - .id = _id, \ 531 - .name = _name, \ 532 - .parent_name = _parent, \ 533 - .regs = &top1_cg_regs, \ 534 - .shift = _shift, \ 535 - .ops = &mtk_clk_gate_ops_setclr, \ 536 - } 528 + #define GATE_TOP1(_id, _name, _parent, _shift) \ 529 + GATE_MTK(_id, _name, _parent, &top1_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 537 530 538 - #define GATE_TOP2(_id, _name, _parent, _shift) { \ 539 - .id = _id, \ 540 - .name = _name, \ 541 - .parent_name = _parent, \ 542 - .regs = &top2_cg_regs, \ 543 - .shift = _shift, \ 544 - .ops = &mtk_clk_gate_ops_setclr, \ 545 - } 531 + #define GATE_TOP2(_id, _name, _parent, _shift) \ 532 + GATE_MTK(_id, _name, _parent, &top2_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 546 533 547 - #define GATE_TOP2_I(_id, _name, _parent, _shift) { \ 548 - .id = _id, \ 549 - .name = _name, \ 550 - .parent_name = _parent, \ 551 - .regs = &top2_cg_regs, \ 552 - .shift = _shift, \ 553 - .ops = &mtk_clk_gate_ops_setclr_inv, \ 554 - } 534 + #define GATE_TOP2_I(_id, _name, _parent, _shift) \ 535 + GATE_MTK(_id, _name, _parent, &top2_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv) 555 536 556 - #define GATE_TOP3(_id, _name, _parent, _shift) { \ 557 - .id = _id, \ 558 - .name = _name, \ 559 - .parent_name = _parent, \ 560 - .regs = &top3_cg_regs, \ 561 - .shift = _shift, \ 562 - .ops = &mtk_clk_gate_ops_setclr, \ 563 - } 537 + #define GATE_TOP3(_id, _name, _parent, _shift) \ 538 + GATE_MTK(_id, _name, _parent, &top3_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 564 539 565 - #define GATE_TOP4_I(_id, _name, _parent, _shift) { \ 566 - .id = _id, \ 567 - .name = _name, \ 568 - .parent_name = _parent, \ 569 - .regs = &top4_cg_regs, \ 570 - .shift = _shift, \ 571 - .ops = &mtk_clk_gate_ops_setclr_inv, \ 572 - } 540 + #define GATE_TOP4_I(_id, _name, _parent, _shift) \ 541 + GATE_MTK(_id, _name, _parent, &top4_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv) 573 542 574 - #define GATE_TOP5(_id, _name, _parent, _shift) { \ 575 - .id = _id, \ 576 - .name = _name, \ 577 - .parent_name = _parent, \ 578 - .regs = &top5_cg_regs, \ 579 - .shift = _shift, \ 580 - .ops = &mtk_clk_gate_ops_no_setclr, \ 581 - } 543 + #define GATE_TOP5(_id, _name, _parent, _shift) \ 544 + GATE_MTK(_id, _name, _parent, &top5_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 582 545 583 546 static const struct mtk_gate top_clks[] __initconst = { 584 547 /* TOP1 */ ··· 640 675 GATE_TOP5(CLK_TOP_APLL12_DIV6, "apll12_div6", "apll12_ck_div6", 8), 641 676 }; 642 677 643 - static void __init mtk_topckgen_init(struct device_node *node) 644 - { 645 - struct clk_hw_onecell_data *clk_data; 646 - int r; 647 - void __iomem *base; 648 - 649 - base = of_iomap(node, 0); 650 - if (!base) { 651 - pr_err("%s(): ioremap failed\n", __func__); 652 - return; 653 - } 654 - 655 - clk_data = mtk_alloc_clk_data(CLK_TOP_NR_CLK); 656 - 657 - mtk_clk_register_fixed_clks(fixed_clks, ARRAY_SIZE(fixed_clks), 658 - clk_data); 659 - mtk_clk_register_gates(NULL, node, top_clks, ARRAY_SIZE(top_clks), clk_data); 660 - 661 - mtk_clk_register_factors(top_divs, ARRAY_SIZE(top_divs), clk_data); 662 - mtk_clk_register_composites(NULL, top_muxes, 663 - ARRAY_SIZE(top_muxes), base, 664 - &mt8516_clk_lock, clk_data); 665 - mtk_clk_register_dividers(top_adj_divs, ARRAY_SIZE(top_adj_divs), 666 - base, &mt8516_clk_lock, clk_data); 667 - 668 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 669 - if (r) 670 - pr_err("%s(): could not register clock provider: %d\n", 671 - __func__, r); 672 - } 673 - CLK_OF_DECLARE(mtk_topckgen, "mediatek,mt8516-topckgen", mtk_topckgen_init); 674 - 675 - static void __init mtk_infracfg_init(struct device_node *node) 676 - { 677 - struct clk_hw_onecell_data *clk_data; 678 - int r; 679 - void __iomem *base; 680 - 681 - base = of_iomap(node, 0); 682 - if (!base) { 683 - pr_err("%s(): ioremap failed\n", __func__); 684 - return; 685 - } 686 - 687 - clk_data = mtk_alloc_clk_data(CLK_IFR_NR_CLK); 688 - 689 - mtk_clk_register_composites(NULL, ifr_muxes, 690 - ARRAY_SIZE(ifr_muxes), base, 691 - &mt8516_clk_lock, clk_data); 692 - 693 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 694 - if (r) 695 - pr_err("%s(): could not register clock provider: %d\n", 696 - __func__, r); 697 - } 698 - CLK_OF_DECLARE(mtk_infracfg, "mediatek,mt8516-infracfg", mtk_infracfg_init); 699 - 700 - #define MT8516_PLL_FMAX (1502UL * MHZ) 701 - 702 - #define CON0_MT8516_RST_BAR BIT(27) 703 - 704 - #define PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits, \ 705 - _pd_reg, _pd_shift, _tuner_reg, _pcw_reg, \ 706 - _pcw_shift, _div_table) { \ 707 - .id = _id, \ 708 - .name = _name, \ 709 - .reg = _reg, \ 710 - .pwr_reg = _pwr_reg, \ 711 - .en_mask = _en_mask, \ 712 - .flags = _flags, \ 713 - .rst_bar_mask = CON0_MT8516_RST_BAR, \ 714 - .fmax = MT8516_PLL_FMAX, \ 715 - .pcwbits = _pcwbits, \ 716 - .pd_reg = _pd_reg, \ 717 - .pd_shift = _pd_shift, \ 718 - .tuner_reg = _tuner_reg, \ 719 - .pcw_reg = _pcw_reg, \ 720 - .pcw_shift = _pcw_shift, \ 721 - .div_table = _div_table, \ 722 - } 723 - 724 - #define PLL(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits, \ 725 - _pd_reg, _pd_shift, _tuner_reg, _pcw_reg, \ 726 - _pcw_shift) \ 727 - PLL_B(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits, \ 728 - _pd_reg, _pd_shift, _tuner_reg, _pcw_reg, _pcw_shift, \ 729 - NULL) 730 - 731 - static const struct mtk_pll_div_table mmpll_div_table[] = { 732 - { .div = 0, .freq = MT8516_PLL_FMAX }, 733 - { .div = 1, .freq = 1000000000 }, 734 - { .div = 2, .freq = 604500000 }, 735 - { .div = 3, .freq = 253500000 }, 736 - { .div = 4, .freq = 126750000 }, 737 - { } /* sentinel */ 678 + static const struct mtk_clk_desc topck_desc = { 679 + .clks = top_clks, 680 + .num_clks = ARRAY_SIZE(top_clks), 681 + .fixed_clks = fixed_clks, 682 + .num_fixed_clks = ARRAY_SIZE(fixed_clks), 683 + .factor_clks = top_divs, 684 + .num_factor_clks = ARRAY_SIZE(top_divs), 685 + .composite_clks = top_muxes, 686 + .num_composite_clks = ARRAY_SIZE(top_muxes), 687 + .divider_clks = top_adj_divs, 688 + .num_divider_clks = ARRAY_SIZE(top_adj_divs), 689 + .clk_lock = &mt8516_clk_lock, 738 690 }; 739 691 740 - static const struct mtk_pll_data plls[] = { 741 - PLL(CLK_APMIXED_ARMPLL, "armpll", 0x0100, 0x0110, 0, 0, 742 - 21, 0x0104, 24, 0, 0x0104, 0), 743 - PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x0120, 0x0130, 0, 744 - HAVE_RST_BAR, 21, 0x0124, 24, 0, 0x0124, 0), 745 - PLL(CLK_APMIXED_UNIVPLL, "univpll", 0x0140, 0x0150, 0x30000000, 746 - HAVE_RST_BAR, 7, 0x0144, 24, 0, 0x0144, 0), 747 - PLL_B(CLK_APMIXED_MMPLL, "mmpll", 0x0160, 0x0170, 0, 0, 748 - 21, 0x0164, 24, 0, 0x0164, 0, mmpll_div_table), 749 - PLL(CLK_APMIXED_APLL1, "apll1", 0x0180, 0x0190, 0, 0, 750 - 31, 0x0180, 1, 0x0194, 0x0184, 0), 751 - PLL(CLK_APMIXED_APLL2, "apll2", 0x01A0, 0x01B0, 0, 0, 752 - 31, 0x01A0, 1, 0x01B4, 0x01A4, 0), 692 + static const struct mtk_clk_desc infra_desc = { 693 + .composite_clks = ifr_muxes, 694 + .num_composite_clks = ARRAY_SIZE(ifr_muxes), 695 + .clk_lock = &mt8516_clk_lock, 753 696 }; 754 697 755 - static void __init mtk_apmixedsys_init(struct device_node *node) 756 - { 757 - struct clk_hw_onecell_data *clk_data; 758 - void __iomem *base; 759 - int r; 698 + static const struct of_device_id of_match_clk_mt8516[] = { 699 + { .compatible = "mediatek,mt8516-topckgen", .data = &topck_desc }, 700 + { .compatible = "mediatek,mt8516-infracfg", .data = &infra_desc }, 701 + { /* sentinel */ } 702 + }; 703 + MODULE_DEVICE_TABLE(of, of_match_clk_mt8516); 760 704 761 - base = of_iomap(node, 0); 762 - if (!base) { 763 - pr_err("%s(): ioremap failed\n", __func__); 764 - return; 765 - } 705 + static struct platform_driver clk_mt8516_drv = { 706 + .probe = mtk_clk_simple_probe, 707 + .remove = mtk_clk_simple_remove, 708 + .driver = { 709 + .name = "clk-mt8516", 710 + .of_match_table = of_match_clk_mt8516, 711 + }, 712 + }; 713 + module_platform_driver(clk_mt8516_drv); 766 714 767 - clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK); 768 - 769 - mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data); 770 - 771 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 772 - if (r) 773 - pr_err("%s(): could not register clock provider: %d\n", 774 - __func__, r); 775 - 776 - } 777 - CLK_OF_DECLARE(mtk_apmixedsys, "mediatek,mt8516-apmixedsys", 778 - mtk_apmixedsys_init); 715 + MODULE_DESCRIPTION("MediaTek MT8516 clocks driver"); 716 + MODULE_LICENSE("GPL");
+68 -14
drivers/clk/mediatek/clk-mtk.c
··· 12 12 #include <linux/module.h> 13 13 #include <linux/of.h> 14 14 #include <linux/of_address.h> 15 - #include <linux/of_device.h> 16 15 #include <linux/platform_device.h> 17 16 #include <linux/slab.h> 18 17 ··· 393 394 } 394 395 EXPORT_SYMBOL_GPL(mtk_clk_unregister_composites); 395 396 396 - int mtk_clk_register_dividers(const struct mtk_clk_divider *mcds, int num, 397 + int mtk_clk_register_dividers(struct device *dev, 398 + const struct mtk_clk_divider *mcds, int num, 397 399 void __iomem *base, spinlock_t *lock, 398 400 struct clk_hw_onecell_data *clk_data) 399 401 { ··· 413 413 continue; 414 414 } 415 415 416 - hw = clk_hw_register_divider(NULL, mcd->name, mcd->parent_name, 416 + hw = clk_hw_register_divider(dev, mcd->name, mcd->parent_name, 417 417 mcd->flags, base + mcd->div_reg, mcd->div_shift, 418 418 mcd->div_width, mcd->clk_divider_flags, lock); 419 419 ··· 463 463 } 464 464 EXPORT_SYMBOL_GPL(mtk_clk_unregister_dividers); 465 465 466 - int mtk_clk_simple_probe(struct platform_device *pdev) 466 + static int __mtk_clk_simple_probe(struct platform_device *pdev, 467 + struct device_node *node) 467 468 { 469 + const struct platform_device_id *id; 468 470 const struct mtk_clk_desc *mcd; 469 471 struct clk_hw_onecell_data *clk_data; 470 - struct device_node *node = pdev->dev.of_node; 471 472 void __iomem *base; 472 473 int num_clks, r; 473 474 474 - mcd = of_device_get_match_data(&pdev->dev); 475 - if (!mcd) 476 - return -EINVAL; 475 + mcd = device_get_match_data(&pdev->dev); 476 + if (!mcd) { 477 + /* Clock driver wasn't registered from devicetree */ 478 + id = platform_get_device_id(pdev); 479 + if (id) 480 + mcd = (const struct mtk_clk_desc *)id->driver_data; 481 + 482 + if (!mcd) 483 + return -EINVAL; 484 + } 477 485 478 486 /* Composite clocks needs us to pass iomem pointer */ 479 487 if (mcd->composite_clks) { ··· 497 489 /* Calculate how many clk_hw_onecell_data entries to allocate */ 498 490 num_clks = mcd->num_clks + mcd->num_composite_clks; 499 491 num_clks += mcd->num_fixed_clks + mcd->num_factor_clks; 500 - num_clks += mcd->num_mux_clks; 492 + num_clks += mcd->num_mux_clks + mcd->num_divider_clks; 501 493 502 494 clk_data = mtk_alloc_clk_data(num_clks); 503 495 if (!clk_data) ··· 535 527 goto unregister_muxes; 536 528 } 537 529 530 + if (mcd->divider_clks) { 531 + r = mtk_clk_register_dividers(&pdev->dev, 532 + mcd->divider_clks, 533 + mcd->num_divider_clks, 534 + base, mcd->clk_lock, clk_data); 535 + if (r) 536 + goto unregister_composites; 537 + } 538 + 538 539 if (mcd->clks) { 539 540 r = mtk_clk_register_gates(&pdev->dev, node, mcd->clks, 540 541 mcd->num_clks, clk_data); 541 542 if (r) 542 - goto unregister_composites; 543 + goto unregister_dividers; 543 544 } 544 545 545 546 if (mcd->clk_notifier_func) { ··· 577 560 unregister_clks: 578 561 if (mcd->clks) 579 562 mtk_clk_unregister_gates(mcd->clks, mcd->num_clks, clk_data); 563 + unregister_dividers: 564 + if (mcd->divider_clks) 565 + mtk_clk_unregister_dividers(mcd->divider_clks, 566 + mcd->num_divider_clks, clk_data); 580 567 unregister_composites: 581 568 if (mcd->composite_clks) 582 569 mtk_clk_unregister_composites(mcd->composite_clks, ··· 603 582 iounmap(base); 604 583 return r; 605 584 } 606 - EXPORT_SYMBOL_GPL(mtk_clk_simple_probe); 607 585 608 - int mtk_clk_simple_remove(struct platform_device *pdev) 586 + static int __mtk_clk_simple_remove(struct platform_device *pdev, 587 + struct device_node *node) 609 588 { 610 - const struct mtk_clk_desc *mcd = of_device_get_match_data(&pdev->dev); 611 589 struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev); 612 - struct device_node *node = pdev->dev.of_node; 590 + const struct mtk_clk_desc *mcd = device_get_match_data(&pdev->dev); 613 591 614 592 of_clk_del_provider(node); 615 593 if (mcd->clks) 616 594 mtk_clk_unregister_gates(mcd->clks, mcd->num_clks, clk_data); 595 + if (mcd->divider_clks) 596 + mtk_clk_unregister_dividers(mcd->divider_clks, 597 + mcd->num_divider_clks, clk_data); 617 598 if (mcd->composite_clks) 618 599 mtk_clk_unregister_composites(mcd->composite_clks, 619 600 mcd->num_composite_clks, clk_data); ··· 631 608 mtk_free_clk_data(clk_data); 632 609 633 610 return 0; 611 + } 612 + 613 + int mtk_clk_pdev_probe(struct platform_device *pdev) 614 + { 615 + struct device *dev = &pdev->dev; 616 + struct device_node *node = dev->parent->of_node; 617 + 618 + return __mtk_clk_simple_probe(pdev, node); 619 + } 620 + EXPORT_SYMBOL_GPL(mtk_clk_pdev_probe); 621 + 622 + int mtk_clk_simple_probe(struct platform_device *pdev) 623 + { 624 + struct device_node *node = pdev->dev.of_node; 625 + 626 + return __mtk_clk_simple_probe(pdev, node); 627 + } 628 + EXPORT_SYMBOL_GPL(mtk_clk_simple_probe); 629 + 630 + int mtk_clk_pdev_remove(struct platform_device *pdev) 631 + { 632 + struct device *dev = &pdev->dev; 633 + struct device_node *node = dev->parent->of_node; 634 + 635 + return __mtk_clk_simple_remove(pdev, node); 636 + } 637 + EXPORT_SYMBOL_GPL(mtk_clk_pdev_remove); 638 + 639 + int mtk_clk_simple_remove(struct platform_device *pdev) 640 + { 641 + return __mtk_clk_simple_remove(pdev, pdev->dev.of_node); 634 642 } 635 643 EXPORT_SYMBOL_GPL(mtk_clk_simple_remove); 636 644
+6 -1
drivers/clk/mediatek/clk-mtk.h
··· 202 202 .div_width = _width, \ 203 203 } 204 204 205 - int mtk_clk_register_dividers(const struct mtk_clk_divider *mcds, int num, 205 + int mtk_clk_register_dividers(struct device *dev, 206 + const struct mtk_clk_divider *mcds, int num, 206 207 void __iomem *base, spinlock_t *lock, 207 208 struct clk_hw_onecell_data *clk_data); 208 209 void mtk_clk_unregister_dividers(const struct mtk_clk_divider *mcds, int num, ··· 223 222 size_t num_clks; 224 223 const struct mtk_composite *composite_clks; 225 224 size_t num_composite_clks; 225 + const struct mtk_clk_divider *divider_clks; 226 + size_t num_divider_clks; 226 227 const struct mtk_fixed_clk *fixed_clks; 227 228 size_t num_fixed_clks; 228 229 const struct mtk_fixed_factor *factor_clks; ··· 239 236 unsigned int mfg_clk_idx; 240 237 }; 241 238 239 + int mtk_clk_pdev_probe(struct platform_device *pdev); 240 + int mtk_clk_pdev_remove(struct platform_device *pdev); 242 241 int mtk_clk_simple_probe(struct platform_device *pdev); 243 242 int mtk_clk_simple_remove(struct platform_device *pdev); 244 243
+21 -5
drivers/clk/mediatek/clk-pllfh.c
··· 110 110 iounmap(base); 111 111 goto out_node_put; 112 112 } 113 + EXPORT_SYMBOL_GPL(fhctl_parse_dt); 113 114 114 - static void pllfh_init(struct mtk_fh *fh, struct mtk_pllfh_data *pllfh_data) 115 + static int pllfh_init(struct mtk_fh *fh, struct mtk_pllfh_data *pllfh_data) 115 116 { 116 117 struct fh_pll_regs *regs = &fh->regs; 117 118 const struct fhctl_offset *offset; 118 119 void __iomem *base = pllfh_data->state.base; 119 120 void __iomem *fhx_base = base + pllfh_data->data.fhx_offset; 120 121 121 - offset = fhctl_get_offset_table(); 122 + offset = fhctl_get_offset_table(pllfh_data->data.fh_ver); 123 + if (IS_ERR(offset)) 124 + return PTR_ERR(offset); 122 125 123 126 regs->reg_hp_en = base + offset->offset_hp_en; 124 127 regs->reg_clk_con = base + offset->offset_clk_con; ··· 139 136 fh->lock = &pllfh_lock; 140 137 141 138 fh->ops = fhctl_get_ops(); 139 + 140 + return 0; 142 141 } 143 142 144 143 static bool fhctl_is_supported_and_enabled(const struct mtk_pllfh_data *pllfh) ··· 154 149 { 155 150 struct clk_hw *hw; 156 151 struct mtk_fh *fh; 152 + int ret; 157 153 158 154 fh = kzalloc(sizeof(*fh), GFP_KERNEL); 159 155 if (!fh) 160 156 return ERR_PTR(-ENOMEM); 161 157 162 - pllfh_init(fh, pllfh_data); 158 + ret = pllfh_init(fh, pllfh_data); 159 + if (ret) { 160 + hw = ERR_PTR(ret); 161 + goto out; 162 + } 163 163 164 164 hw = mtk_clk_register_pll_ops(&fh->clk_pll, pll_data, base, 165 165 &mtk_pllfh_ops); 166 166 167 167 if (IS_ERR(hw)) 168 + goto out; 169 + 170 + fhctl_hw_init(fh); 171 + 172 + out: 173 + if (IS_ERR(hw)) 168 174 kfree(fh); 169 - else 170 - fhctl_hw_init(fh); 171 175 172 176 return hw; 173 177 } ··· 255 241 256 242 return PTR_ERR(hw); 257 243 } 244 + EXPORT_SYMBOL_GPL(mtk_clk_register_pllfhs); 258 245 259 246 void mtk_clk_unregister_pllfhs(const struct mtk_pll_data *plls, int num_plls, 260 247 struct mtk_pllfh_data *pllfhs, int num_fhs, ··· 295 280 296 281 iounmap(base); 297 282 } 283 + EXPORT_SYMBOL_GPL(mtk_clk_unregister_pllfhs);
+1
drivers/clk/mediatek/clk-pllfh.h
··· 18 18 struct fh_pll_data { 19 19 int pll_id; 20 20 int fh_id; 21 + int fh_ver; 21 22 u32 fhx_offset; 22 23 u32 dds_mask; 23 24 u32 slope0_value;
+19 -7
drivers/clk/socfpga/clk-gate-a10.c
··· 40 40 }; 41 41 42 42 static void __init __socfpga_gate_init(struct device_node *node, 43 - const struct clk_ops *ops) 43 + const struct clk_ops *ops) 44 44 { 45 45 u32 clk_gate[2]; 46 46 u32 div_reg[3]; ··· 94 94 socfpga_clk->hw.hw.init = &init; 95 95 hw_clk = &socfpga_clk->hw.hw; 96 96 97 - if (clk_hw_register(NULL, hw_clk)) { 98 - kfree(socfpga_clk); 99 - return; 97 + rc = clk_hw_register(NULL, hw_clk); 98 + if (rc) { 99 + pr_err("Could not register clock:%s\n", clk_name); 100 + goto err_clk_hw_register; 100 101 } 101 - rc = of_clk_add_provider(node, of_clk_src_simple_get, hw_clk); 102 - if (WARN_ON(rc)) 103 - return; 102 + 103 + rc = of_clk_add_hw_provider(node, of_clk_hw_simple_get, hw_clk); 104 + if (rc) { 105 + pr_err("Could not register clock provider for node:%s\n", 106 + clk_name); 107 + goto err_of_clk_add_hw_provider; 108 + } 109 + 110 + return; 111 + 112 + err_of_clk_add_hw_provider: 113 + clk_hw_unregister(hw_clk); 114 + err_clk_hw_register: 115 + kfree(socfpga_clk); 104 116 } 105 117 106 118 void __init socfpga_a10_gate_init(struct device_node *node)
+22 -13
drivers/clk/socfpga/clk-gate.c
··· 126 126 struct clk_init_data init; 127 127 struct clk_ops *ops; 128 128 int rc; 129 - int err; 130 129 131 130 socfpga_clk = kzalloc(sizeof(*socfpga_clk), GFP_KERNEL); 132 131 if (WARN_ON(!socfpga_clk)) 133 132 return; 134 133 135 134 ops = kmemdup(&gateclk_ops, sizeof(gateclk_ops), GFP_KERNEL); 136 - if (WARN_ON(!ops)) { 137 - kfree(socfpga_clk); 138 - return; 139 - } 135 + if (WARN_ON(!ops)) 136 + goto err_kmemdup; 140 137 141 138 rc = of_property_read_u32_array(node, "clk-gate", clk_gate, 2); 142 139 if (rc) ··· 179 182 180 183 hw_clk = &socfpga_clk->hw.hw; 181 184 182 - err = clk_hw_register(NULL, hw_clk); 183 - if (err) { 184 - kfree(ops); 185 - kfree(socfpga_clk); 186 - return; 185 + rc = clk_hw_register(NULL, hw_clk); 186 + if (rc) { 187 + pr_err("Could not register clock:%s\n", clk_name); 188 + goto err_clk_hw_register; 187 189 } 188 - rc = of_clk_add_provider(node, of_clk_src_simple_get, hw_clk); 189 - if (WARN_ON(rc)) 190 - return; 190 + 191 + rc = of_clk_add_hw_provider(node, of_clk_hw_simple_get, hw_clk); 192 + if (rc) { 193 + pr_err("Could not register clock provider for node:%s\n", 194 + clk_name); 195 + goto err_of_clk_add_hw_provider; 196 + } 197 + 198 + return; 199 + 200 + err_of_clk_add_hw_provider: 201 + clk_hw_unregister(hw_clk); 202 + err_clk_hw_register: 203 + kfree(ops); 204 + err_kmemdup: 205 + kfree(socfpga_clk); 191 206 }
+13 -9
drivers/clk/socfpga/clk-periph-a10.c
··· 57 57 .get_parent = clk_periclk_get_parent, 58 58 }; 59 59 60 - static __init void __socfpga_periph_init(struct device_node *node, 61 - const struct clk_ops *ops) 60 + static void __init __socfpga_periph_init(struct device_node *node, 61 + const struct clk_ops *ops) 62 62 { 63 63 u32 reg; 64 64 struct clk_hw *hw_clk; ··· 106 106 107 107 hw_clk = &periph_clk->hw.hw; 108 108 109 - if (clk_hw_register(NULL, hw_clk)) { 110 - kfree(periph_clk); 111 - return; 109 + rc = clk_hw_register(NULL, hw_clk); 110 + if (rc) { 111 + pr_err("Could not register clock:%s\n", clk_name); 112 + goto err_clk_hw_register; 112 113 } 113 - rc = of_clk_add_provider(node, of_clk_src_simple_get, hw_clk); 114 - if (rc < 0) { 114 + 115 + rc = of_clk_add_hw_provider(node, of_clk_hw_simple_get, hw_clk); 116 + if (rc) { 115 117 pr_err("Could not register clock provider for node:%s\n", 116 118 clk_name); 117 - goto err_clk; 119 + goto err_of_clk_add_hw_provider; 118 120 } 119 121 120 122 return; 121 123 122 - err_clk: 124 + err_of_clk_add_hw_provider: 123 125 clk_hw_unregister(hw_clk); 126 + err_clk_hw_register: 127 + kfree(periph_clk); 124 128 } 125 129 126 130 void __init socfpga_a10_periph_init(struct device_node *node)
+20 -6
drivers/clk/socfpga/clk-periph.c
··· 47 47 .get_parent = clk_periclk_get_parent, 48 48 }; 49 49 50 - static __init void __socfpga_periph_init(struct device_node *node, 51 - const struct clk_ops *ops) 50 + static void __init __socfpga_periph_init(struct device_node *node, 51 + const struct clk_ops *ops) 52 52 { 53 53 u32 reg; 54 54 struct clk_hw *hw_clk; ··· 96 96 periph_clk->hw.hw.init = &init; 97 97 hw_clk = &periph_clk->hw.hw; 98 98 99 - if (clk_hw_register(NULL, hw_clk)) { 100 - kfree(periph_clk); 101 - return; 99 + rc = clk_hw_register(NULL, hw_clk); 100 + if (rc) { 101 + pr_err("Could not register clock:%s\n", clk_name); 102 + goto err_clk_hw_register; 102 103 } 103 - rc = of_clk_add_provider(node, of_clk_src_simple_get, hw_clk); 104 + 105 + rc = of_clk_add_hw_provider(node, of_clk_hw_simple_get, hw_clk); 106 + if (rc) { 107 + pr_err("Could not register clock provider for node:%s\n", 108 + clk_name); 109 + goto err_of_clk_add_hw_provider; 110 + } 111 + 112 + return; 113 + 114 + err_of_clk_add_hw_provider: 115 + clk_hw_unregister(hw_clk); 116 + err_clk_hw_register: 117 + kfree(periph_clk); 104 118 } 105 119 106 120 void __init socfpga_periph_init(struct device_node *node)
+22 -8
drivers/clk/socfpga/clk-pll-a10.c
··· 63 63 .get_parent = clk_pll_get_parent, 64 64 }; 65 65 66 - static struct clk_hw * __init __socfpga_pll_init(struct device_node *node, 67 - const struct clk_ops *ops) 66 + static void __init __socfpga_pll_init(struct device_node *node, 67 + const struct clk_ops *ops) 68 68 { 69 69 u32 reg; 70 70 struct clk_hw *hw_clk; ··· 73 73 const char *parent_name[SOCFGPA_MAX_PARENTS]; 74 74 struct clk_init_data init; 75 75 struct device_node *clkmgr_np; 76 + int rc; 76 77 int i = 0; 77 78 78 79 of_property_read_u32(node, "reg", &reg); 79 80 80 81 pll_clk = kzalloc(sizeof(*pll_clk), GFP_KERNEL); 81 82 if (WARN_ON(!pll_clk)) 82 - return NULL; 83 + return; 83 84 84 85 clkmgr_np = of_find_compatible_node(NULL, NULL, "altr,clk-mgr"); 85 86 clk_mgr_a10_base_addr = of_iomap(clkmgr_np, 0); ··· 104 103 pll_clk->hw.bit_idx = SOCFPGA_PLL_EXT_ENA; 105 104 hw_clk = &pll_clk->hw.hw; 106 105 107 - if (clk_hw_register(NULL, hw_clk)) { 108 - kfree(pll_clk); 109 - return NULL; 106 + rc = clk_hw_register(NULL, hw_clk); 107 + if (rc) { 108 + pr_err("Could not register clock:%s\n", clk_name); 109 + goto err_clk_hw_register; 110 110 } 111 - of_clk_add_provider(node, of_clk_src_simple_get, hw_clk); 112 - return hw_clk; 111 + 112 + rc = of_clk_add_hw_provider(node, of_clk_hw_simple_get, hw_clk); 113 + if (rc) { 114 + pr_err("Could not register clock provider for node:%s\n", 115 + clk_name); 116 + goto err_of_clk_add_hw_provider; 117 + } 118 + 119 + return; 120 + 121 + err_of_clk_add_hw_provider: 122 + clk_hw_unregister(hw_clk); 123 + err_clk_hw_register: 124 + kfree(pll_clk); 113 125 } 114 126 115 127 void __init socfpga_a10_pll_init(struct device_node *node)
+22 -10
drivers/clk/socfpga/clk-pll.c
··· 70 70 .get_parent = clk_pll_get_parent, 71 71 }; 72 72 73 - static __init struct clk_hw *__socfpga_pll_init(struct device_node *node, 74 - const struct clk_ops *ops) 73 + static void __init __socfpga_pll_init(struct device_node *node, 74 + const struct clk_ops *ops) 75 75 { 76 76 u32 reg; 77 77 struct clk_hw *hw_clk; ··· 80 80 const char *parent_name[SOCFPGA_MAX_PARENTS]; 81 81 struct clk_init_data init; 82 82 struct device_node *clkmgr_np; 83 - int err; 83 + int rc; 84 84 85 85 of_property_read_u32(node, "reg", &reg); 86 86 87 87 pll_clk = kzalloc(sizeof(*pll_clk), GFP_KERNEL); 88 88 if (WARN_ON(!pll_clk)) 89 - return NULL; 89 + return; 90 90 91 91 clkmgr_np = of_find_compatible_node(NULL, NULL, "altr,clk-mgr"); 92 92 clk_mgr_base_addr = of_iomap(clkmgr_np, 0); ··· 108 108 109 109 hw_clk = &pll_clk->hw.hw; 110 110 111 - err = clk_hw_register(NULL, hw_clk); 112 - if (err) { 113 - kfree(pll_clk); 114 - return ERR_PTR(err); 111 + rc = clk_hw_register(NULL, hw_clk); 112 + if (rc) { 113 + pr_err("Could not register clock:%s\n", clk_name); 114 + goto err_clk_hw_register; 115 115 } 116 - of_clk_add_provider(node, of_clk_src_simple_get, hw_clk); 117 - return hw_clk; 116 + 117 + rc = of_clk_add_hw_provider(node, of_clk_hw_simple_get, hw_clk); 118 + if (rc) { 119 + pr_err("Could not register clock provider for node:%s\n", 120 + clk_name); 121 + goto err_of_clk_add_hw_provider; 122 + } 123 + 124 + return; 125 + 126 + err_of_clk_add_hw_provider: 127 + clk_hw_unregister(hw_clk); 128 + err_clk_hw_register: 129 + kfree(pll_clk); 118 130 } 119 131 120 132 void __init socfpga_pll_init(struct device_node *node)
+19
include/dt-bindings/clock/loongson,ls1x-clk.h
··· 1 + /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ 2 + /* 3 + * Loongson-1 clock tree IDs 4 + * 5 + * Copyright (C) 2023 Keguang Zhang <keguang.zhang@gmail.com> 6 + */ 7 + 8 + #ifndef __DT_BINDINGS_CLOCK_LS1X_CLK_H__ 9 + #define __DT_BINDINGS_CLOCK_LS1X_CLK_H__ 10 + 11 + #define LS1X_CLKID_PLL 0 12 + #define LS1X_CLKID_CPU 1 13 + #define LS1X_CLKID_DC 2 14 + #define LS1X_CLKID_AHB 3 15 + #define LS1X_CLKID_APB 4 16 + 17 + #define CLK_NR_CLKS (LS1X_CLKID_APB + 1) 18 + 19 + #endif /* __DT_BINDINGS_CLOCK_LS1X_CLK_H__ */
+2 -1
include/dt-bindings/clock/loongson,ls2k-clk.h
··· 24 24 #define LOONGSON2_SATA_CLK 14 25 25 #define LOONGSON2_PIX0_CLK 15 26 26 #define LOONGSON2_PIX1_CLK 16 27 - #define LOONGSON2_CLK_END 17 27 + #define LOONGSON2_BOOT_CLK 17 28 + #define LOONGSON2_CLK_END 18 28 29 29 30 #endif
+726
include/dt-bindings/clock/mediatek,mt8188-clk.h
··· 1 + /* SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) */ 2 + /* 3 + * Copyright (c) 2022 MediaTek Inc. 4 + * Author: Garmin Chang <garmin.chang@mediatek.com> 5 + */ 6 + 7 + #ifndef _DT_BINDINGS_CLK_MT8188_H 8 + #define _DT_BINDINGS_CLK_MT8188_H 9 + 10 + /* TOPCKGEN */ 11 + #define CLK_TOP_AXI 0 12 + #define CLK_TOP_SPM 1 13 + #define CLK_TOP_SCP 2 14 + #define CLK_TOP_BUS_AXIMEM 3 15 + #define CLK_TOP_VPP 4 16 + #define CLK_TOP_ETHDR 5 17 + #define CLK_TOP_IPE 6 18 + #define CLK_TOP_CAM 7 19 + #define CLK_TOP_CCU 8 20 + #define CLK_TOP_CCU_AHB 9 21 + #define CLK_TOP_IMG 10 22 + #define CLK_TOP_CAMTM 11 23 + #define CLK_TOP_DSP 12 24 + #define CLK_TOP_DSP1 13 25 + #define CLK_TOP_DSP2 14 26 + #define CLK_TOP_DSP3 15 27 + #define CLK_TOP_DSP4 16 28 + #define CLK_TOP_DSP5 17 29 + #define CLK_TOP_DSP6 18 30 + #define CLK_TOP_DSP7 19 31 + #define CLK_TOP_MFG_CORE_TMP 20 32 + #define CLK_TOP_CAMTG 21 33 + #define CLK_TOP_CAMTG2 22 34 + #define CLK_TOP_CAMTG3 23 35 + #define CLK_TOP_UART 24 36 + #define CLK_TOP_SPI 25 37 + #define CLK_TOP_MSDC50_0_HCLK 26 38 + #define CLK_TOP_MSDC50_0 27 39 + #define CLK_TOP_MSDC30_1 28 40 + #define CLK_TOP_MSDC30_2 29 41 + #define CLK_TOP_INTDIR 30 42 + #define CLK_TOP_AUD_INTBUS 31 43 + #define CLK_TOP_AUDIO_H 32 44 + #define CLK_TOP_PWRAP_ULPOSC 33 45 + #define CLK_TOP_ATB 34 46 + #define CLK_TOP_SSPM 35 47 + #define CLK_TOP_DP 36 48 + #define CLK_TOP_EDP 37 49 + #define CLK_TOP_DPI 38 50 + #define CLK_TOP_DISP_PWM0 39 51 + #define CLK_TOP_DISP_PWM1 40 52 + #define CLK_TOP_USB_TOP 41 53 + #define CLK_TOP_SSUSB_XHCI 42 54 + #define CLK_TOP_USB_TOP_2P 43 55 + #define CLK_TOP_SSUSB_XHCI_2P 44 56 + #define CLK_TOP_USB_TOP_3P 45 57 + #define CLK_TOP_SSUSB_XHCI_3P 46 58 + #define CLK_TOP_I2C 47 59 + #define CLK_TOP_SENINF 48 60 + #define CLK_TOP_SENINF1 49 61 + #define CLK_TOP_GCPU 50 62 + #define CLK_TOP_VENC 51 63 + #define CLK_TOP_VDEC 52 64 + #define CLK_TOP_PWM 53 65 + #define CLK_TOP_MCUPM 54 66 + #define CLK_TOP_SPMI_P_MST 55 67 + #define CLK_TOP_SPMI_M_MST 56 68 + #define CLK_TOP_DVFSRC 57 69 + #define CLK_TOP_TL 58 70 + #define CLK_TOP_AES_MSDCFDE 59 71 + #define CLK_TOP_DSI_OCC 60 72 + #define CLK_TOP_WPE_VPP 61 73 + #define CLK_TOP_HDCP 62 74 + #define CLK_TOP_HDCP_24M 63 75 + #define CLK_TOP_HDMI_APB 64 76 + #define CLK_TOP_SNPS_ETH_250M 65 77 + #define CLK_TOP_SNPS_ETH_62P4M_PTP 66 78 + #define CLK_TOP_SNPS_ETH_50M_RMII 67 79 + #define CLK_TOP_ADSP 68 80 + #define CLK_TOP_AUDIO_LOCAL_BUS 69 81 + #define CLK_TOP_ASM_H 70 82 + #define CLK_TOP_ASM_L 71 83 + #define CLK_TOP_APLL1 72 84 + #define CLK_TOP_APLL2 73 85 + #define CLK_TOP_APLL3 74 86 + #define CLK_TOP_APLL4 75 87 + #define CLK_TOP_APLL5 76 88 + #define CLK_TOP_I2SO1 77 89 + #define CLK_TOP_I2SO2 78 90 + #define CLK_TOP_I2SI1 79 91 + #define CLK_TOP_I2SI2 80 92 + #define CLK_TOP_DPTX 81 93 + #define CLK_TOP_AUD_IEC 82 94 + #define CLK_TOP_A1SYS_HP 83 95 + #define CLK_TOP_A2SYS 84 96 + #define CLK_TOP_A3SYS 85 97 + #define CLK_TOP_A4SYS 86 98 + #define CLK_TOP_ECC 87 99 + #define CLK_TOP_SPINOR 88 100 + #define CLK_TOP_ULPOSC 89 101 + #define CLK_TOP_SRCK 90 102 + #define CLK_TOP_MFG_CK_FAST_REF 91 103 + #define CLK_TOP_MAINPLL_D3 92 104 + #define CLK_TOP_MAINPLL_D4 93 105 + #define CLK_TOP_MAINPLL_D4_D2 94 106 + #define CLK_TOP_MAINPLL_D4_D4 95 107 + #define CLK_TOP_MAINPLL_D4_D8 96 108 + #define CLK_TOP_MAINPLL_D5 97 109 + #define CLK_TOP_MAINPLL_D5_D2 98 110 + #define CLK_TOP_MAINPLL_D5_D4 99 111 + #define CLK_TOP_MAINPLL_D5_D8 100 112 + #define CLK_TOP_MAINPLL_D6 101 113 + #define CLK_TOP_MAINPLL_D6_D2 102 114 + #define CLK_TOP_MAINPLL_D6_D4 103 115 + #define CLK_TOP_MAINPLL_D6_D8 104 116 + #define CLK_TOP_MAINPLL_D7 105 117 + #define CLK_TOP_MAINPLL_D7_D2 106 118 + #define CLK_TOP_MAINPLL_D7_D4 107 119 + #define CLK_TOP_MAINPLL_D7_D8 108 120 + #define CLK_TOP_MAINPLL_D9 109 121 + #define CLK_TOP_UNIVPLL_D2 110 122 + #define CLK_TOP_UNIVPLL_D3 111 123 + #define CLK_TOP_UNIVPLL_D4 112 124 + #define CLK_TOP_UNIVPLL_D4_D2 113 125 + #define CLK_TOP_UNIVPLL_D4_D4 114 126 + #define CLK_TOP_UNIVPLL_D4_D8 115 127 + #define CLK_TOP_UNIVPLL_D5 116 128 + #define CLK_TOP_UNIVPLL_D5_D2 117 129 + #define CLK_TOP_UNIVPLL_D5_D4 118 130 + #define CLK_TOP_UNIVPLL_D5_D8 119 131 + #define CLK_TOP_UNIVPLL_D6 120 132 + #define CLK_TOP_UNIVPLL_D6_D2 121 133 + #define CLK_TOP_UNIVPLL_D6_D4 122 134 + #define CLK_TOP_UNIVPLL_D6_D8 123 135 + #define CLK_TOP_UNIVPLL_D7 124 136 + #define CLK_TOP_UNIVPLL_192M 125 137 + #define CLK_TOP_UNIVPLL_192M_D4 126 138 + #define CLK_TOP_UNIVPLL_192M_D8 127 139 + #define CLK_TOP_UNIVPLL_192M_D10 128 140 + #define CLK_TOP_UNIVPLL_192M_D16 129 141 + #define CLK_TOP_UNIVPLL_192M_D32 130 142 + #define CLK_TOP_APLL1_D3 131 143 + #define CLK_TOP_APLL1_D4 132 144 + #define CLK_TOP_APLL2_D3 133 145 + #define CLK_TOP_APLL2_D4 134 146 + #define CLK_TOP_APLL3_D4 135 147 + #define CLK_TOP_APLL4_D4 136 148 + #define CLK_TOP_APLL5_D4 137 149 + #define CLK_TOP_MMPLL_D4 138 150 + #define CLK_TOP_MMPLL_D4_D2 139 151 + #define CLK_TOP_MMPLL_D5 140 152 + #define CLK_TOP_MMPLL_D5_D2 141 153 + #define CLK_TOP_MMPLL_D5_D4 142 154 + #define CLK_TOP_MMPLL_D6 143 155 + #define CLK_TOP_MMPLL_D6_D2 144 156 + #define CLK_TOP_MMPLL_D7 145 157 + #define CLK_TOP_MMPLL_D9 146 158 + #define CLK_TOP_TVDPLL1 147 159 + #define CLK_TOP_TVDPLL1_D2 148 160 + #define CLK_TOP_TVDPLL1_D4 149 161 + #define CLK_TOP_TVDPLL1_D8 150 162 + #define CLK_TOP_TVDPLL1_D16 151 163 + #define CLK_TOP_TVDPLL2 152 164 + #define CLK_TOP_TVDPLL2_D2 153 165 + #define CLK_TOP_TVDPLL2_D4 154 166 + #define CLK_TOP_TVDPLL2_D8 155 167 + #define CLK_TOP_TVDPLL2_D16 156 168 + #define CLK_TOP_MSDCPLL_D2 157 169 + #define CLK_TOP_MSDCPLL_D16 158 170 + #define CLK_TOP_ETHPLL 159 171 + #define CLK_TOP_ETHPLL_D2 160 172 + #define CLK_TOP_ETHPLL_D4 161 173 + #define CLK_TOP_ETHPLL_D8 162 174 + #define CLK_TOP_ETHPLL_D10 163 175 + #define CLK_TOP_ADSPPLL_D2 164 176 + #define CLK_TOP_ADSPPLL_D4 165 177 + #define CLK_TOP_ADSPPLL_D8 166 178 + #define CLK_TOP_ULPOSC1 167 179 + #define CLK_TOP_ULPOSC1_D2 168 180 + #define CLK_TOP_ULPOSC1_D4 169 181 + #define CLK_TOP_ULPOSC1_D8 170 182 + #define CLK_TOP_ULPOSC1_D7 171 183 + #define CLK_TOP_ULPOSC1_D10 172 184 + #define CLK_TOP_ULPOSC1_D16 173 185 + #define CLK_TOP_MPHONE_SLAVE_BCK 174 186 + #define CLK_TOP_PAD_FPC 175 187 + #define CLK_TOP_466M_FMEM 176 188 + #define CLK_TOP_PEXTP_PIPE 177 189 + #define CLK_TOP_DSI_PHY 178 190 + #define CLK_TOP_APLL12_CK_DIV0 179 191 + #define CLK_TOP_APLL12_CK_DIV1 180 192 + #define CLK_TOP_APLL12_CK_DIV2 181 193 + #define CLK_TOP_APLL12_CK_DIV3 182 194 + #define CLK_TOP_APLL12_CK_DIV4 183 195 + #define CLK_TOP_APLL12_CK_DIV9 184 196 + #define CLK_TOP_CFGREG_CLOCK_EN_VPP0 185 197 + #define CLK_TOP_CFGREG_CLOCK_EN_VPP1 186 198 + #define CLK_TOP_CFGREG_CLOCK_EN_VDO0 187 199 + #define CLK_TOP_CFGREG_CLOCK_EN_VDO1 188 200 + #define CLK_TOP_CFGREG_CLOCK_ISP_AXI_GALS 189 201 + #define CLK_TOP_CFGREG_F26M_VPP0 190 202 + #define CLK_TOP_CFGREG_F26M_VPP1 191 203 + #define CLK_TOP_CFGREG_F26M_VDO0 192 204 + #define CLK_TOP_CFGREG_F26M_VDO1 193 205 + #define CLK_TOP_CFGREG_AUD_F26M_AUD 194 206 + #define CLK_TOP_CFGREG_UNIPLL_SES 195 207 + #define CLK_TOP_CFGREG_F_PCIE_PHY_REF 196 208 + #define CLK_TOP_SSUSB_TOP_REF 197 209 + #define CLK_TOP_SSUSB_PHY_REF 198 210 + #define CLK_TOP_SSUSB_TOP_P1_REF 199 211 + #define CLK_TOP_SSUSB_PHY_P1_REF 200 212 + #define CLK_TOP_SSUSB_TOP_P2_REF 201 213 + #define CLK_TOP_SSUSB_PHY_P2_REF 202 214 + #define CLK_TOP_SSUSB_TOP_P3_REF 203 215 + #define CLK_TOP_SSUSB_PHY_P3_REF 204 216 + #define CLK_TOP_NR_CLK 205 217 + 218 + /* INFRACFG_AO */ 219 + #define CLK_INFRA_AO_PMIC_TMR 0 220 + #define CLK_INFRA_AO_PMIC_AP 1 221 + #define CLK_INFRA_AO_PMIC_MD 2 222 + #define CLK_INFRA_AO_PMIC_CONN 3 223 + #define CLK_INFRA_AO_SEJ 4 224 + #define CLK_INFRA_AO_APXGPT 5 225 + #define CLK_INFRA_AO_GCE 6 226 + #define CLK_INFRA_AO_GCE2 7 227 + #define CLK_INFRA_AO_THERM 8 228 + #define CLK_INFRA_AO_PWM_HCLK 9 229 + #define CLK_INFRA_AO_PWM1 10 230 + #define CLK_INFRA_AO_PWM2 11 231 + #define CLK_INFRA_AO_PWM3 12 232 + #define CLK_INFRA_AO_PWM4 13 233 + #define CLK_INFRA_AO_PWM 14 234 + #define CLK_INFRA_AO_UART0 15 235 + #define CLK_INFRA_AO_UART1 16 236 + #define CLK_INFRA_AO_UART2 17 237 + #define CLK_INFRA_AO_UART3 18 238 + #define CLK_INFRA_AO_UART4 19 239 + #define CLK_INFRA_AO_GCE_26M 20 240 + #define CLK_INFRA_AO_CQ_DMA_FPC 21 241 + #define CLK_INFRA_AO_UART5 22 242 + #define CLK_INFRA_AO_HDMI_26M 23 243 + #define CLK_INFRA_AO_SPI0 24 244 + #define CLK_INFRA_AO_MSDC0 25 245 + #define CLK_INFRA_AO_MSDC1 26 246 + #define CLK_INFRA_AO_MSDC2 27 247 + #define CLK_INFRA_AO_MSDC0_SRC 28 248 + #define CLK_INFRA_AO_DVFSRC 29 249 + #define CLK_INFRA_AO_TRNG 30 250 + #define CLK_INFRA_AO_AUXADC 31 251 + #define CLK_INFRA_AO_CPUM 32 252 + #define CLK_INFRA_AO_HDMI_32K 33 253 + #define CLK_INFRA_AO_CEC_66M_HCLK 34 254 + #define CLK_INFRA_AO_PCIE_TL_26M 35 255 + #define CLK_INFRA_AO_MSDC1_SRC 36 256 + #define CLK_INFRA_AO_CEC_66M_BCLK 37 257 + #define CLK_INFRA_AO_PCIE_TL_96M 38 258 + #define CLK_INFRA_AO_DEVICE_APC 39 259 + #define CLK_INFRA_AO_ECC_66M_HCLK 40 260 + #define CLK_INFRA_AO_DEBUGSYS 41 261 + #define CLK_INFRA_AO_AUDIO 42 262 + #define CLK_INFRA_AO_PCIE_TL_32K 43 263 + #define CLK_INFRA_AO_DBG_TRACE 44 264 + #define CLK_INFRA_AO_DRAMC_F26M 45 265 + #define CLK_INFRA_AO_IRTX 46 266 + #define CLK_INFRA_AO_DISP_PWM 47 267 + #define CLK_INFRA_AO_CLDMA_BCLK 48 268 + #define CLK_INFRA_AO_AUDIO_26M_BCLK 49 269 + #define CLK_INFRA_AO_SPI1 50 270 + #define CLK_INFRA_AO_SPI2 51 271 + #define CLK_INFRA_AO_SPI3 52 272 + #define CLK_INFRA_AO_FSSPM 53 273 + #define CLK_INFRA_AO_SSPM_BUS_HCLK 54 274 + #define CLK_INFRA_AO_APDMA_BCLK 55 275 + #define CLK_INFRA_AO_SPI4 56 276 + #define CLK_INFRA_AO_SPI5 57 277 + #define CLK_INFRA_AO_CQ_DMA 58 278 + #define CLK_INFRA_AO_MSDC0_SELF 59 279 + #define CLK_INFRA_AO_MSDC1_SELF 60 280 + #define CLK_INFRA_AO_MSDC2_SELF 61 281 + #define CLK_INFRA_AO_I2S_DMA 62 282 + #define CLK_INFRA_AO_AP_MSDC0 63 283 + #define CLK_INFRA_AO_MD_MSDC0 64 284 + #define CLK_INFRA_AO_MSDC30_2 65 285 + #define CLK_INFRA_AO_GCPU 66 286 + #define CLK_INFRA_AO_PCIE_PERI_26M 67 287 + #define CLK_INFRA_AO_GCPU_66M_BCLK 68 288 + #define CLK_INFRA_AO_GCPU_133M_BCLK 69 289 + #define CLK_INFRA_AO_DISP_PWM1 70 290 + #define CLK_INFRA_AO_FBIST2FPC 71 291 + #define CLK_INFRA_AO_DEVICE_APC_SYNC 72 292 + #define CLK_INFRA_AO_PCIE_P1_PERI_26M 73 293 + #define CLK_INFRA_AO_133M_MCLK_CK 74 294 + #define CLK_INFRA_AO_66M_MCLK_CK 75 295 + #define CLK_INFRA_AO_PCIE_PL_P_250M_P0 76 296 + #define CLK_INFRA_AO_RG_AES_MSDCFDE_CK_0P 77 297 + #define CLK_INFRA_AO_NR_CLK 78 298 + 299 + /* APMIXEDSYS */ 300 + #define CLK_APMIXED_ETHPLL 0 301 + #define CLK_APMIXED_MSDCPLL 1 302 + #define CLK_APMIXED_TVDPLL1 2 303 + #define CLK_APMIXED_TVDPLL2 3 304 + #define CLK_APMIXED_MMPLL 4 305 + #define CLK_APMIXED_MAINPLL 5 306 + #define CLK_APMIXED_IMGPLL 6 307 + #define CLK_APMIXED_UNIVPLL 7 308 + #define CLK_APMIXED_ADSPPLL 8 309 + #define CLK_APMIXED_APLL1 9 310 + #define CLK_APMIXED_APLL2 10 311 + #define CLK_APMIXED_APLL3 11 312 + #define CLK_APMIXED_APLL4 12 313 + #define CLK_APMIXED_APLL5 13 314 + #define CLK_APMIXED_MFGPLL 14 315 + #define CLK_APMIXED_PLL_SSUSB26M_EN 15 316 + #define CLK_APMIXED_NR_CLK 16 317 + 318 + /* AUDIODSP */ 319 + #define CLK_AUDIODSP_AUDIO26M 0 320 + #define CLK_AUDIODSP_NR_CLK 1 321 + 322 + /* PERICFG_AO */ 323 + #define CLK_PERI_AO_ETHERNET 0 324 + #define CLK_PERI_AO_ETHERNET_BUS 1 325 + #define CLK_PERI_AO_FLASHIF_BUS 2 326 + #define CLK_PERI_AO_FLASHIF_26M 3 327 + #define CLK_PERI_AO_FLASHIFLASHCK 4 328 + #define CLK_PERI_AO_SSUSB_2P_BUS 5 329 + #define CLK_PERI_AO_SSUSB_2P_XHCI 6 330 + #define CLK_PERI_AO_SSUSB_3P_BUS 7 331 + #define CLK_PERI_AO_SSUSB_3P_XHCI 8 332 + #define CLK_PERI_AO_SSUSB_BUS 9 333 + #define CLK_PERI_AO_SSUSB_XHCI 10 334 + #define CLK_PERI_AO_ETHERNET_MAC 11 335 + #define CLK_PERI_AO_PCIE_P0_FMEM 12 336 + #define CLK_PERI_AO_NR_CLK 13 337 + 338 + /* IMP_IIC_WRAP_C */ 339 + #define CLK_IMP_IIC_WRAP_C_AP_CLOCK_I2C0 0 340 + #define CLK_IMP_IIC_WRAP_C_AP_CLOCK_I2C2 1 341 + #define CLK_IMP_IIC_WRAP_C_AP_CLOCK_I2C3 2 342 + #define CLK_IMP_IIC_WRAP_C_NR_CLK 3 343 + 344 + /* IMP_IIC_WRAP_W */ 345 + #define CLK_IMP_IIC_WRAP_W_AP_CLOCK_I2C1 0 346 + #define CLK_IMP_IIC_WRAP_W_AP_CLOCK_I2C4 1 347 + #define CLK_IMP_IIC_WRAP_W_NR_CLK 2 348 + 349 + /* IMP_IIC_WRAP_EN */ 350 + #define CLK_IMP_IIC_WRAP_EN_AP_CLOCK_I2C5 0 351 + #define CLK_IMP_IIC_WRAP_EN_AP_CLOCK_I2C6 1 352 + #define CLK_IMP_IIC_WRAP_EN_NR_CLK 2 353 + 354 + /* MFGCFG */ 355 + #define CLK_MFGCFG_BG3D 0 356 + #define CLK_MFGCFG_NR_CLK 1 357 + 358 + /* VPPSYS0 */ 359 + #define CLK_VPP0_MDP_FG 0 360 + #define CLK_VPP0_STITCH 1 361 + #define CLK_VPP0_PADDING 2 362 + #define CLK_VPP0_MDP_TCC 3 363 + #define CLK_VPP0_WARP0_ASYNC_TX 4 364 + #define CLK_VPP0_WARP1_ASYNC_TX 5 365 + #define CLK_VPP0_MUTEX 6 366 + #define CLK_VPP02VPP1_RELAY 7 367 + #define CLK_VPP0_VPP12VPP0_ASYNC 8 368 + #define CLK_VPP0_MMSYSRAM_TOP 9 369 + #define CLK_VPP0_MDP_AAL 10 370 + #define CLK_VPP0_MDP_RSZ 11 371 + #define CLK_VPP0_SMI_COMMON_MMSRAM 12 372 + #define CLK_VPP0_GALS_VDO0_LARB0_MMSRAM 13 373 + #define CLK_VPP0_GALS_VDO0_LARB1_MMSRAM 14 374 + #define CLK_VPP0_GALS_VENCSYS_MMSRAM 15 375 + #define CLK_VPP0_GALS_VENCSYS_CORE1_MMSRAM 16 376 + #define CLK_VPP0_GALS_INFRA_MMSRAM 17 377 + #define CLK_VPP0_GALS_CAMSYS_MMSRAM 18 378 + #define CLK_VPP0_GALS_VPP1_LARB5_MMSRAM 19 379 + #define CLK_VPP0_GALS_VPP1_LARB6_MMSRAM 20 380 + #define CLK_VPP0_SMI_REORDER_MMSRAM 21 381 + #define CLK_VPP0_SMI_IOMMU 22 382 + #define CLK_VPP0_GALS_IMGSYS_CAMSYS 23 383 + #define CLK_VPP0_MDP_RDMA 24 384 + #define CLK_VPP0_MDP_WROT 25 385 + #define CLK_VPP0_GALS_EMI0_EMI1 26 386 + #define CLK_VPP0_SMI_SUB_COMMON_REORDER 27 387 + #define CLK_VPP0_SMI_RSI 28 388 + #define CLK_VPP0_SMI_COMMON_LARB4 29 389 + #define CLK_VPP0_GALS_VDEC_VDEC_CORE1 30 390 + #define CLK_VPP0_GALS_VPP1_WPESYS 31 391 + #define CLK_VPP0_GALS_VDO0_VDO1_VENCSYS_CORE1 32 392 + #define CLK_VPP0_FAKE_ENG 33 393 + #define CLK_VPP0_MDP_HDR 34 394 + #define CLK_VPP0_MDP_TDSHP 35 395 + #define CLK_VPP0_MDP_COLOR 36 396 + #define CLK_VPP0_MDP_OVL 37 397 + #define CLK_VPP0_DSIP_RDMA 38 398 + #define CLK_VPP0_DISP_WDMA 39 399 + #define CLK_VPP0_MDP_HMS 40 400 + #define CLK_VPP0_WARP0_RELAY 41 401 + #define CLK_VPP0_WARP0_ASYNC 42 402 + #define CLK_VPP0_WARP1_RELAY 43 403 + #define CLK_VPP0_WARP1_ASYNC 44 404 + #define CLK_VPP0_NR_CLK 45 405 + 406 + /* WPESYS */ 407 + #define CLK_WPE_TOP_WPE_VPP0 0 408 + #define CLK_WPE_TOP_SMI_LARB7 1 409 + #define CLK_WPE_TOP_WPESYS_EVENT_TX 2 410 + #define CLK_WPE_TOP_SMI_LARB7_PCLK_EN 3 411 + #define CLK_WPE_TOP_NR_CLK 4 412 + 413 + /* WPESYS_VPP0 */ 414 + #define CLK_WPE_VPP0_VECI 0 415 + #define CLK_WPE_VPP0_VEC2I 1 416 + #define CLK_WPE_VPP0_VEC3I 2 417 + #define CLK_WPE_VPP0_WPEO 3 418 + #define CLK_WPE_VPP0_MSKO 4 419 + #define CLK_WPE_VPP0_VGEN 5 420 + #define CLK_WPE_VPP0_EXT 6 421 + #define CLK_WPE_VPP0_VFC 7 422 + #define CLK_WPE_VPP0_CACH0_TOP 8 423 + #define CLK_WPE_VPP0_CACH0_DMA 9 424 + #define CLK_WPE_VPP0_CACH1_TOP 10 425 + #define CLK_WPE_VPP0_CACH1_DMA 11 426 + #define CLK_WPE_VPP0_CACH2_TOP 12 427 + #define CLK_WPE_VPP0_CACH2_DMA 13 428 + #define CLK_WPE_VPP0_CACH3_TOP 14 429 + #define CLK_WPE_VPP0_CACH3_DMA 15 430 + #define CLK_WPE_VPP0_PSP 16 431 + #define CLK_WPE_VPP0_PSP2 17 432 + #define CLK_WPE_VPP0_SYNC 18 433 + #define CLK_WPE_VPP0_C24 19 434 + #define CLK_WPE_VPP0_MDP_CROP 20 435 + #define CLK_WPE_VPP0_ISP_CROP 21 436 + #define CLK_WPE_VPP0_TOP 22 437 + #define CLK_WPE_VPP0_NR_CLK 23 438 + 439 + /* VPPSYS1 */ 440 + #define CLK_VPP1_SVPP1_MDP_OVL 0 441 + #define CLK_VPP1_SVPP1_MDP_TCC 1 442 + #define CLK_VPP1_SVPP1_MDP_WROT 2 443 + #define CLK_VPP1_SVPP1_VPP_PAD 3 444 + #define CLK_VPP1_SVPP2_MDP_WROT 4 445 + #define CLK_VPP1_SVPP2_VPP_PAD 5 446 + #define CLK_VPP1_SVPP3_MDP_WROT 6 447 + #define CLK_VPP1_SVPP3_VPP_PAD 7 448 + #define CLK_VPP1_SVPP1_MDP_RDMA 8 449 + #define CLK_VPP1_SVPP1_MDP_FG 9 450 + #define CLK_VPP1_SVPP2_MDP_RDMA 10 451 + #define CLK_VPP1_SVPP2_MDP_FG 11 452 + #define CLK_VPP1_SVPP3_MDP_RDMA 12 453 + #define CLK_VPP1_SVPP3_MDP_FG 13 454 + #define CLK_VPP1_VPP_SPLIT 14 455 + #define CLK_VPP1_SVPP2_VDO0_DL_RELAY 15 456 + #define CLK_VPP1_SVPP1_MDP_RSZ 16 457 + #define CLK_VPP1_SVPP1_MDP_TDSHP 17 458 + #define CLK_VPP1_SVPP1_MDP_COLOR 18 459 + #define CLK_VPP1_SVPP3_VDO1_DL_RELAY 19 460 + #define CLK_VPP1_SVPP2_MDP_RSZ 20 461 + #define CLK_VPP1_SVPP2_VPP_MERGE 21 462 + #define CLK_VPP1_SVPP2_MDP_TDSHP 22 463 + #define CLK_VPP1_SVPP2_MDP_COLOR 23 464 + #define CLK_VPP1_SVPP3_MDP_RSZ 24 465 + #define CLK_VPP1_SVPP3_VPP_MERGE 25 466 + #define CLK_VPP1_SVPP3_MDP_TDSHP 26 467 + #define CLK_VPP1_SVPP3_MDP_COLOR 27 468 + #define CLK_VPP1_GALS5 28 469 + #define CLK_VPP1_GALS6 29 470 + #define CLK_VPP1_LARB5 30 471 + #define CLK_VPP1_LARB6 31 472 + #define CLK_VPP1_SVPP1_MDP_HDR 32 473 + #define CLK_VPP1_SVPP1_MDP_AAL 33 474 + #define CLK_VPP1_SVPP2_MDP_HDR 34 475 + #define CLK_VPP1_SVPP2_MDP_AAL 35 476 + #define CLK_VPP1_SVPP3_MDP_HDR 36 477 + #define CLK_VPP1_SVPP3_MDP_AAL 37 478 + #define CLK_VPP1_DISP_MUTEX 38 479 + #define CLK_VPP1_SVPP2_VDO1_DL_RELAY 39 480 + #define CLK_VPP1_SVPP3_VDO0_DL_RELAY 40 481 + #define CLK_VPP1_VPP0_DL_ASYNC 41 482 + #define CLK_VPP1_VPP0_DL1_RELAY 42 483 + #define CLK_VPP1_LARB5_FAKE_ENG 43 484 + #define CLK_VPP1_LARB6_FAKE_ENG 44 485 + #define CLK_VPP1_HDMI_META 45 486 + #define CLK_VPP1_VPP_SPLIT_HDMI 46 487 + #define CLK_VPP1_DGI_IN 47 488 + #define CLK_VPP1_DGI_OUT 48 489 + #define CLK_VPP1_VPP_SPLIT_DGI 49 490 + #define CLK_VPP1_DL_CON_OCC 50 491 + #define CLK_VPP1_VPP_SPLIT_26M 51 492 + #define CLK_VPP1_NR_CLK 52 493 + 494 + /* IMGSYS */ 495 + #define CLK_IMGSYS_MAIN_LARB9 0 496 + #define CLK_IMGSYS_MAIN_TRAW0 1 497 + #define CLK_IMGSYS_MAIN_TRAW1 2 498 + #define CLK_IMGSYS_MAIN_VCORE_GALS 3 499 + #define CLK_IMGSYS_MAIN_DIP0 4 500 + #define CLK_IMGSYS_MAIN_WPE0 5 501 + #define CLK_IMGSYS_MAIN_IPE 6 502 + #define CLK_IMGSYS_MAIN_WPE1 7 503 + #define CLK_IMGSYS_MAIN_WPE2 8 504 + #define CLK_IMGSYS_MAIN_GALS 9 505 + #define CLK_IMGSYS_MAIN_NR_CLK 10 506 + 507 + /* IMGSYS1_DIP_TOP */ 508 + #define CLK_IMGSYS1_DIP_TOP_LARB10 0 509 + #define CLK_IMGSYS1_DIP_TOP_DIP_TOP 1 510 + #define CLK_IMGSYS1_DIP_TOP_NR_CLK 2 511 + 512 + /* IMGSYS1_DIP_NR */ 513 + #define CLK_IMGSYS1_DIP_NR_LARB15 0 514 + #define CLK_IMGSYS1_DIP_NR_DIP_NR 1 515 + #define CLK_IMGSYS1_DIP_NR_NR_CLK 2 516 + 517 + /* IMGSYS_WPE1 */ 518 + #define CLK_IMGSYS_WPE1_LARB11 0 519 + #define CLK_IMGSYS_WPE1 1 520 + #define CLK_IMGSYS_WPE1_NR_CLK 2 521 + 522 + /* IPESYS */ 523 + #define CLK_IPE_DPE 0 524 + #define CLK_IPE_FDVT 1 525 + #define CLK_IPE_ME 2 526 + #define CLK_IPESYS_TOP 3 527 + #define CLK_IPE_SMI_LARB12 4 528 + #define CLK_IPE_NR_CLK 5 529 + 530 + /* IMGSYS_WPE2 */ 531 + #define CLK_IMGSYS_WPE2_LARB11 0 532 + #define CLK_IMGSYS_WPE2 1 533 + #define CLK_IMGSYS_WPE2_NR_CLK 2 534 + 535 + /* IMGSYS_WPE3 */ 536 + #define CLK_IMGSYS_WPE3_LARB11 0 537 + #define CLK_IMGSYS_WPE3 1 538 + #define CLK_IMGSYS_WPE3_NR_CLK 2 539 + 540 + /* CAMSYS */ 541 + #define CLK_CAM_MAIN_LARB13 0 542 + #define CLK_CAM_MAIN_LARB14 1 543 + #define CLK_CAM_MAIN_CAM 2 544 + #define CLK_CAM_MAIN_CAM_SUBA 3 545 + #define CLK_CAM_MAIN_CAM_SUBB 4 546 + #define CLK_CAM_MAIN_CAMTG 5 547 + #define CLK_CAM_MAIN_SENINF 6 548 + #define CLK_CAM_MAIN_GCAMSVA 7 549 + #define CLK_CAM_MAIN_GCAMSVB 8 550 + #define CLK_CAM_MAIN_GCAMSVC 9 551 + #define CLK_CAM_MAIN_GCAMSVD 10 552 + #define CLK_CAM_MAIN_GCAMSVE 11 553 + #define CLK_CAM_MAIN_GCAMSVF 12 554 + #define CLK_CAM_MAIN_GCAMSVG 13 555 + #define CLK_CAM_MAIN_GCAMSVH 14 556 + #define CLK_CAM_MAIN_GCAMSVI 15 557 + #define CLK_CAM_MAIN_GCAMSVJ 16 558 + #define CLK_CAM_MAIN_CAMSV_TOP 17 559 + #define CLK_CAM_MAIN_CAMSV_CQ_A 18 560 + #define CLK_CAM_MAIN_CAMSV_CQ_B 19 561 + #define CLK_CAM_MAIN_CAMSV_CQ_C 20 562 + #define CLK_CAM_MAIN_FAKE_ENG 21 563 + #define CLK_CAM_MAIN_CAM2MM0_GALS 22 564 + #define CLK_CAM_MAIN_CAM2MM1_GALS 23 565 + #define CLK_CAM_MAIN_CAM2SYS_GALS 24 566 + #define CLK_CAM_MAIN_NR_CLK 25 567 + 568 + /* CAMSYS_RAWA */ 569 + #define CLK_CAM_RAWA_LARBX 0 570 + #define CLK_CAM_RAWA_CAM 1 571 + #define CLK_CAM_RAWA_CAMTG 2 572 + #define CLK_CAM_RAWA_NR_CLK 3 573 + 574 + /* CAMSYS_YUVA */ 575 + #define CLK_CAM_YUVA_LARBX 0 576 + #define CLK_CAM_YUVA_CAM 1 577 + #define CLK_CAM_YUVA_CAMTG 2 578 + #define CLK_CAM_YUVA_NR_CLK 3 579 + 580 + /* CAMSYS_RAWB */ 581 + #define CLK_CAM_RAWB_LARBX 0 582 + #define CLK_CAM_RAWB_CAM 1 583 + #define CLK_CAM_RAWB_CAMTG 2 584 + #define CLK_CAM_RAWB_NR_CLK 3 585 + 586 + /* CAMSYS_YUVB */ 587 + #define CLK_CAM_YUVB_LARBX 0 588 + #define CLK_CAM_YUVB_CAM 1 589 + #define CLK_CAM_YUVB_CAMTG 2 590 + #define CLK_CAM_YUVB_NR_CLK 3 591 + 592 + /* CCUSYS */ 593 + #define CLK_CCU_LARB27 0 594 + #define CLK_CCU_AHB 1 595 + #define CLK_CCU_CCU0 2 596 + #define CLK_CCU_NR_CLK 3 597 + 598 + /* VDECSYS_SOC */ 599 + #define CLK_VDEC1_SOC_LARB1 0 600 + #define CLK_VDEC1_SOC_LAT 1 601 + #define CLK_VDEC1_SOC_LAT_ACTIVE 2 602 + #define CLK_VDEC1_SOC_LAT_ENG 3 603 + #define CLK_VDEC1_SOC_VDEC 4 604 + #define CLK_VDEC1_SOC_VDEC_ACTIVE 5 605 + #define CLK_VDEC1_SOC_VDEC_ENG 6 606 + #define CLK_VDEC1_NR_CLK 7 607 + 608 + /* VDECSYS */ 609 + #define CLK_VDEC2_LARB1 0 610 + #define CLK_VDEC2_LAT 1 611 + #define CLK_VDEC2_VDEC 2 612 + #define CLK_VDEC2_VDEC_ACTIVE 3 613 + #define CLK_VDEC2_VDEC_ENG 4 614 + #define CLK_VDEC2_NR_CLK 5 615 + 616 + /* VENCSYS */ 617 + #define CLK_VENC1_LARB 0 618 + #define CLK_VENC1_VENC 1 619 + #define CLK_VENC1_JPGENC 2 620 + #define CLK_VENC1_JPGDEC 3 621 + #define CLK_VENC1_JPGDEC_C1 4 622 + #define CLK_VENC1_GALS 5 623 + #define CLK_VENC1_GALS_SRAM 6 624 + #define CLK_VENC1_NR_CLK 7 625 + 626 + /* VDOSYS0 */ 627 + #define CLK_VDO0_DISP_OVL0 0 628 + #define CLK_VDO0_FAKE_ENG0 1 629 + #define CLK_VDO0_DISP_CCORR0 2 630 + #define CLK_VDO0_DISP_MUTEX0 3 631 + #define CLK_VDO0_DISP_GAMMA0 4 632 + #define CLK_VDO0_DISP_DITHER0 5 633 + #define CLK_VDO0_DISP_WDMA0 6 634 + #define CLK_VDO0_DISP_RDMA0 7 635 + #define CLK_VDO0_DSI0 8 636 + #define CLK_VDO0_DSI1 9 637 + #define CLK_VDO0_DSC_WRAP0 10 638 + #define CLK_VDO0_VPP_MERGE0 11 639 + #define CLK_VDO0_DP_INTF0 12 640 + #define CLK_VDO0_DISP_AAL0 13 641 + #define CLK_VDO0_INLINEROT0 14 642 + #define CLK_VDO0_APB_BUS 15 643 + #define CLK_VDO0_DISP_COLOR0 16 644 + #define CLK_VDO0_MDP_WROT0 17 645 + #define CLK_VDO0_DISP_RSZ0 18 646 + #define CLK_VDO0_DISP_POSTMASK0 19 647 + #define CLK_VDO0_FAKE_ENG1 20 648 + #define CLK_VDO0_DL_ASYNC2 21 649 + #define CLK_VDO0_DL_RELAY3 22 650 + #define CLK_VDO0_DL_RELAY4 23 651 + #define CLK_VDO0_SMI_GALS 24 652 + #define CLK_VDO0_SMI_COMMON 25 653 + #define CLK_VDO0_SMI_EMI 26 654 + #define CLK_VDO0_SMI_IOMMU 27 655 + #define CLK_VDO0_SMI_LARB 28 656 + #define CLK_VDO0_SMI_RSI 29 657 + #define CLK_VDO0_DSI0_DSI 30 658 + #define CLK_VDO0_DSI1_DSI 31 659 + #define CLK_VDO0_DP_INTF0_DP_INTF 32 660 + #define CLK_VDO0_NR_CLK 33 661 + 662 + /* VDOSYS1 */ 663 + #define CLK_VDO1_SMI_LARB2 0 664 + #define CLK_VDO1_SMI_LARB3 1 665 + #define CLK_VDO1_GALS 2 666 + #define CLK_VDO1_FAKE_ENG0 3 667 + #define CLK_VDO1_FAKE_ENG1 4 668 + #define CLK_VDO1_MDP_RDMA0 5 669 + #define CLK_VDO1_MDP_RDMA1 6 670 + #define CLK_VDO1_MDP_RDMA2 7 671 + #define CLK_VDO1_MDP_RDMA3 8 672 + #define CLK_VDO1_VPP_MERGE0 9 673 + #define CLK_VDO1_VPP_MERGE1 10 674 + #define CLK_VDO1_VPP_MERGE2 11 675 + #define CLK_VDO1_VPP_MERGE3 12 676 + #define CLK_VDO1_VPP_MERGE4 13 677 + #define CLK_VDO1_VPP2_TO_VDO1_DL_ASYNC 14 678 + #define CLK_VDO1_VPP3_TO_VDO1_DL_ASYNC 15 679 + #define CLK_VDO1_DISP_MUTEX 16 680 + #define CLK_VDO1_MDP_RDMA4 17 681 + #define CLK_VDO1_MDP_RDMA5 18 682 + #define CLK_VDO1_MDP_RDMA6 19 683 + #define CLK_VDO1_MDP_RDMA7 20 684 + #define CLK_VDO1_DP_INTF0_MMCK 21 685 + #define CLK_VDO1_DPI0_MM 22 686 + #define CLK_VDO1_DPI1_MM 23 687 + #define CLK_VDO1_MERGE0_DL_ASYNC 24 688 + #define CLK_VDO1_MERGE1_DL_ASYNC 25 689 + #define CLK_VDO1_MERGE2_DL_ASYNC 26 690 + #define CLK_VDO1_MERGE3_DL_ASYNC 27 691 + #define CLK_VDO1_MERGE4_DL_ASYNC 28 692 + #define CLK_VDO1_DSC_VDO1_DL_ASYNC 29 693 + #define CLK_VDO1_MERGE_VDO1_DL_ASYNC 30 694 + #define CLK_VDO1_PADDING0 31 695 + #define CLK_VDO1_PADDING1 32 696 + #define CLK_VDO1_PADDING2 33 697 + #define CLK_VDO1_PADDING3 34 698 + #define CLK_VDO1_PADDING4 35 699 + #define CLK_VDO1_PADDING5 36 700 + #define CLK_VDO1_PADDING6 37 701 + #define CLK_VDO1_PADDING7 38 702 + #define CLK_VDO1_DISP_RSZ0 39 703 + #define CLK_VDO1_DISP_RSZ1 40 704 + #define CLK_VDO1_DISP_RSZ2 41 705 + #define CLK_VDO1_DISP_RSZ3 42 706 + #define CLK_VDO1_HDR_VDO_FE0 43 707 + #define CLK_VDO1_HDR_GFX_FE0 44 708 + #define CLK_VDO1_HDR_VDO_BE 45 709 + #define CLK_VDO1_HDR_VDO_FE1 46 710 + #define CLK_VDO1_HDR_GFX_FE1 47 711 + #define CLK_VDO1_DISP_MIXER 48 712 + #define CLK_VDO1_HDR_VDO_FE0_DL_ASYNC 49 713 + #define CLK_VDO1_HDR_VDO_FE1_DL_ASYNC 50 714 + #define CLK_VDO1_HDR_GFX_FE0_DL_ASYNC 51 715 + #define CLK_VDO1_HDR_GFX_FE1_DL_ASYNC 52 716 + #define CLK_VDO1_HDR_VDO_BE_DL_ASYNC 53 717 + #define CLK_VDO1_DPI0 54 718 + #define CLK_VDO1_DISP_MONITOR_DPI0 55 719 + #define CLK_VDO1_DPI1 56 720 + #define CLK_VDO1_DISP_MONITOR_DPI1 57 721 + #define CLK_VDO1_DPINTF 58 722 + #define CLK_VDO1_DISP_MONITOR_DPINTF 59 723 + #define CLK_VDO1_26M_SLOW 60 724 + #define CLK_VDO1_NR_CLK 61 725 + 726 + #endif /* _DT_BINDINGS_CLK_MT8188_H */
+19
include/linux/clk-provider.h
··· 608 608 __devm_clk_hw_register_gate((dev), NULL, (name), (parent_name), NULL, \ 609 609 NULL, (flags), (reg), (bit_idx), \ 610 610 (clk_gate_flags), (lock)) 611 + /** 612 + * devm_clk_hw_register_gate_parent_data - register a gate clock with the 613 + * clock framework 614 + * @dev: device that is registering this clock 615 + * @name: name of this clock 616 + * @parent_data: parent clk data 617 + * @flags: framework-specific flags for this clock 618 + * @reg: register address to control gating of this clock 619 + * @bit_idx: which bit in the register controls gating of this clock 620 + * @clk_gate_flags: gate-specific flags for this clock 621 + * @lock: shared register lock for this clock 622 + */ 623 + #define devm_clk_hw_register_gate_parent_data(dev, name, parent_data, flags, \ 624 + reg, bit_idx, clk_gate_flags, \ 625 + lock) \ 626 + __devm_clk_hw_register_gate((dev), NULL, (name), NULL, NULL, \ 627 + (parent_data), (flags), (reg), (bit_idx), \ 628 + (clk_gate_flags), (lock)) 629 + 611 630 void clk_unregister_gate(struct clk *clk); 612 631 void clk_hw_unregister_gate(struct clk_hw *hw); 613 632 int clk_gate_is_enabled(struct clk_hw *hw);