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

Merge branches 'clk-socfpga', 'clk-renesas', 'clk-cleanup', 'clk-samsung' and 'clk-mediatek' into clk-next

* clk-socfpga:
clk: socfpga: agilex5: add clock driver for Agilex5

* clk-renesas: (35 commits)
clk: renesas: r9a09g077: Add SPI module clocks
clk: renesas: r9a09g056: Add USB3.0 clocks/resets
clk: renesas: r9a09g057: Add USB3.0 clocks/resets
clk: renesas: r9a09g047: Add RSCI clocks/resets
dt-bindings: clock: renesas,r9a09g056-cpg: Add USB3.0 core clocks
dt-bindings: clock: renesas,r9a09g057-cpg: Add USB3.0 core clocks
clk: renesas: r9a06g032: Fix memory leak in error path
clk: renesas: r9a09g077: Use devm_ helpers for divider clock registration
clk: renesas: r9a09g077: Remove stray blank line
clk: renesas: r9a09g077: Propagate rate changes to parent clocks
clk: renesas: r8a779a0: Add 3DGE module clock
clk: renesas: r8a779a0: Add ZG Core clock
clk: renesas: rcar-gen4: Add support for clock dividers in FRQCRB
dt-bindings: clock: r8a779a0: Add ZG core clock
clk: renesas: r9a09g056: Add clock and reset entries for ISP
clk: renesas: r9a09g056: Add support for PLLVDO, CRU clocks, and resets
clk: renesas: r9a09g056: Add clocks and resets for DSI and LCDC modules
clk: renesas: r9a09g077: Add TSU module clock
clk: renesas: r9a09g057: Add clock and reset entries for DSI and LCDC
clk: renesas: rzv2h: Add support for DSI clocks
...

* clk-cleanup:
clk: keystone: fix compile testing
clk: keystone: syscon-clk: fix regmap leak on probe failure
clk: samsung: exynos-clkout: Assign .num before accessing .hws
clk: actions: Fix discarding const qualifier by 'container_of' macro
clk: spacemit: Set clk_hw_onecell_data::num before using flex array
clk: spacemit: fix comment typo
clk: keystone: Fix discarded const qualifiers
clk: sprd: sc9860: Simplify with of_device_get_match_data()

* clk-samsung:
firmware: exynos-acpm: add empty method to allow compile test
MAINTAINERS: add ACPM clock bindings and driver
clk: samsung: add Exynos ACPM clock driver
firmware: exynos-acpm: register ACPM clocks pdev
firmware: exynos-acpm: add DVFS protocol
dt-bindings: firmware: google,gs101-acpm-ipc: add ACPM clocks
clk: samsung: clk-pll: simplify samsung_pll_lock_wait()
clk: samsung: exynosautov920: add block mfc clock support
clk: samsung: exynosautov920: add clock support
dt-bindings: clock: exynosautov920: add mfc clock definitions
dt-bindings: clock: exynosautov920: add m2m clock definitions
dt-bindings: clock: google,gs101-clock: add power-domains

* clk-mediatek:
clk: en7523: Add reset-controller support for EN7523 SoC
dt-bindings: clock: airoha: Add reset support to EN7523 clock binding

+1936 -136
+1 -2
Documentation/devicetree/bindings/clock/airoha,en7523-scu.yaml
··· 64 64 reg: 65 65 minItems: 2 66 66 67 - '#reset-cells': false 68 - 69 67 - if: 70 68 properties: 71 69 compatible: ··· 83 85 reg = <0x1fa20000 0x400>, 84 86 <0x1fb00000 0x1000>; 85 87 #clock-cells = <1>; 88 + #reset-cells = <1>; 86 89 }; 87 90 88 91 - |
+3
Documentation/devicetree/bindings/clock/google,gs101-clock.yaml
··· 46 46 "#clock-cells": 47 47 const: 1 48 48 49 + power-domains: 50 + maxItems: 1 51 + 49 52 reg: 50 53 maxItems: 1 51 54
+42
Documentation/devicetree/bindings/clock/samsung,exynosautov920-clock.yaml
··· 38 38 - samsung,exynosautov920-cmu-hsi0 39 39 - samsung,exynosautov920-cmu-hsi1 40 40 - samsung,exynosautov920-cmu-hsi2 41 + - samsung,exynosautov920-cmu-m2m 42 + - samsung,exynosautov920-cmu-mfc 41 43 - samsung,exynosautov920-cmu-misc 42 44 - samsung,exynosautov920-cmu-peric0 43 45 - samsung,exynosautov920-cmu-peric1 ··· 227 225 - const: ufs 228 226 - const: embd 229 227 - const: ethernet 228 + 229 + - if: 230 + properties: 231 + compatible: 232 + contains: 233 + const: samsung,exynosautov920-cmu-m2m 234 + 235 + then: 236 + properties: 237 + clocks: 238 + items: 239 + - description: External reference clock (38.4 MHz) 240 + - description: CMU_M2M NOC clock (from CMU_TOP) 241 + - description: CMU_M2M JPEG clock (from CMU_TOP) 242 + 243 + clock-names: 244 + items: 245 + - const: oscclk 246 + - const: noc 247 + - const: jpeg 248 + 249 + - if: 250 + properties: 251 + compatible: 252 + contains: 253 + const: samsung,exynosautov920-cmu-mfc 254 + 255 + then: 256 + properties: 257 + clocks: 258 + items: 259 + - description: External reference clock (38.4 MHz) 260 + - description: CMU_MFC MFC clock (from CMU_TOP) 261 + - description: CMU_MFC WFD clock (from CMU_TOP) 262 + 263 + clock-names: 264 + items: 265 + - const: oscclk 266 + - const: mfc 267 + - const: wfd 230 268 231 269 required: 232 270 - compatible
+11
Documentation/devicetree/bindings/firmware/google,gs101-acpm-ipc.yaml
··· 24 24 compatible: 25 25 const: google,gs101-acpm-ipc 26 26 27 + "#clock-cells": 28 + const: 1 29 + description: 30 + Clocks that are variable and index based. These clocks don't provide 31 + an entire range of values between the limits but only discrete points 32 + within the range. The firmware also manages the voltage scaling 33 + appropriately with the clock scaling. The argument is the ID of the 34 + clock contained by the firmware messages. 35 + 27 36 mboxes: 28 37 maxItems: 1 29 38 ··· 54 45 55 46 required: 56 47 - compatible 48 + - "#clock-cells" 57 49 - mboxes 58 50 - shmem 59 51 ··· 66 56 67 57 power-management { 68 58 compatible = "google,gs101-acpm-ipc"; 59 + #clock-cells = <1>; 69 60 mboxes = <&ap2apm_mailbox>; 70 61 shmem = <&apm_sram>; 71 62
+2 -1
MAINTAINERS
··· 10601 10601 F: arch/arm64/boot/dts/exynos/google/ 10602 10602 F: drivers/clk/samsung/clk-gs101.c 10603 10603 F: drivers/phy/samsung/phy-gs101-ufs.c 10604 - F: include/dt-bindings/clock/google,gs101.h 10604 + F: include/dt-bindings/clock/google,gs101* 10605 10605 K: [gG]oogle.?[tT]ensor 10606 10606 10607 10607 GPD FAN DRIVER ··· 22761 22761 L: linux-samsung-soc@vger.kernel.org 22762 22762 S: Supported 22763 22763 F: Documentation/devicetree/bindings/firmware/google,gs101-acpm-ipc.yaml 22764 + F: drivers/clk/samsung/clk-acpm.c 22764 22765 F: drivers/firmware/samsung/exynos-acpm* 22765 22766 F: include/linux/firmware/samsung/exynos-acpm-protocol.h 22766 22767
+1 -2
drivers/clk/Makefile
··· 125 125 obj-y += imgtec/ 126 126 obj-y += imx/ 127 127 obj-y += ingenic/ 128 - obj-$(CONFIG_ARCH_K3) += keystone/ 129 - obj-$(CONFIG_ARCH_KEYSTONE) += keystone/ 128 + obj-y += keystone/ 130 129 obj-y += mediatek/ 131 130 obj-$(CONFIG_ARCH_MESON) += meson/ 132 131 obj-y += microchip/
+1 -1
drivers/clk/actions/owl-common.h
··· 32 32 }; 33 33 34 34 static inline struct owl_clk_common * 35 - hw_to_owl_clk_common(const struct clk_hw *hw) 35 + hw_to_owl_clk_common(struct clk_hw *hw) 36 36 { 37 37 return container_of(hw, struct owl_clk_common, hw); 38 38 }
+1 -1
drivers/clk/actions/owl-composite.h
··· 108 108 }, \ 109 109 } 110 110 111 - static inline struct owl_composite *hw_to_owl_comp(const struct clk_hw *hw) 111 + static inline struct owl_composite *hw_to_owl_comp(struct clk_hw *hw) 112 112 { 113 113 struct owl_clk_common *common = hw_to_owl_clk_common(hw); 114 114
+1 -1
drivers/clk/actions/owl-divider.h
··· 49 49 }, \ 50 50 } 51 51 52 - static inline struct owl_divider *hw_to_owl_divider(const struct clk_hw *hw) 52 + static inline struct owl_divider *hw_to_owl_divider(struct clk_hw *hw) 53 53 { 54 54 struct owl_clk_common *common = hw_to_owl_clk_common(hw); 55 55
+1 -1
drivers/clk/actions/owl-factor.h
··· 57 57 58 58 #define div_mask(d) ((1 << ((d)->width)) - 1) 59 59 60 - static inline struct owl_factor *hw_to_owl_factor(const struct clk_hw *hw) 60 + static inline struct owl_factor *hw_to_owl_factor(struct clk_hw *hw) 61 61 { 62 62 struct owl_clk_common *common = hw_to_owl_clk_common(hw); 63 63
+1 -1
drivers/clk/actions/owl-gate.h
··· 56 56 }, \ 57 57 } \ 58 58 59 - static inline struct owl_gate *hw_to_owl_gate(const struct clk_hw *hw) 59 + static inline struct owl_gate *hw_to_owl_gate(struct clk_hw *hw) 60 60 { 61 61 struct owl_clk_common *common = hw_to_owl_clk_common(hw); 62 62
+1 -1
drivers/clk/actions/owl-mux.h
··· 44 44 }, \ 45 45 } 46 46 47 - static inline struct owl_mux *hw_to_owl_mux(const struct clk_hw *hw) 47 + static inline struct owl_mux *hw_to_owl_mux(struct clk_hw *hw) 48 48 { 49 49 struct owl_clk_common *common = hw_to_owl_clk_common(hw); 50 50
+1 -1
drivers/clk/actions/owl-pll.h
··· 98 98 99 99 #define mul_mask(m) ((1 << ((m)->width)) - 1) 100 100 101 - static inline struct owl_pll *hw_to_owl_pll(const struct clk_hw *hw) 101 + static inline struct owl_pll *hw_to_owl_pll(struct clk_hw *hw) 102 102 { 103 103 struct owl_clk_common *common = hw_to_owl_clk_common(hw); 104 104
+59 -5
drivers/clk/clk-en7523.c
··· 9 9 #include <linux/regmap.h> 10 10 #include <linux/reset-controller.h> 11 11 #include <dt-bindings/clock/en7523-clk.h> 12 + #include <dt-bindings/reset/airoha,en7523-reset.h> 12 13 #include <dt-bindings/reset/airoha,en7581-reset.h> 13 14 14 15 #define RST_NR_PER_BANK 32 ··· 300 299 REG_RST_CTRL1, 301 300 }; 302 301 302 + static const u16 en7523_rst_map[] = { 303 + /* RST_CTRL2 */ 304 + [EN7523_XPON_PHY_RST] = 0, 305 + [EN7523_XSI_MAC_RST] = 7, 306 + [EN7523_XSI_PHY_RST] = 8, 307 + [EN7523_NPU_RST] = 9, 308 + [EN7523_I2S_RST] = 10, 309 + [EN7523_TRNG_RST] = 11, 310 + [EN7523_TRNG_MSTART_RST] = 12, 311 + [EN7523_DUAL_HSI0_RST] = 13, 312 + [EN7523_DUAL_HSI1_RST] = 14, 313 + [EN7523_HSI_RST] = 15, 314 + [EN7523_DUAL_HSI0_MAC_RST] = 16, 315 + [EN7523_DUAL_HSI1_MAC_RST] = 17, 316 + [EN7523_HSI_MAC_RST] = 18, 317 + [EN7523_WDMA_RST] = 19, 318 + [EN7523_WOE0_RST] = 20, 319 + [EN7523_WOE1_RST] = 21, 320 + [EN7523_HSDMA_RST] = 22, 321 + [EN7523_I2C2RBUS_RST] = 23, 322 + [EN7523_TDMA_RST] = 24, 323 + /* RST_CTRL1 */ 324 + [EN7523_PCM1_ZSI_ISI_RST] = RST_NR_PER_BANK + 0, 325 + [EN7523_FE_PDMA_RST] = RST_NR_PER_BANK + 1, 326 + [EN7523_FE_QDMA_RST] = RST_NR_PER_BANK + 2, 327 + [EN7523_PCM_SPIWP_RST] = RST_NR_PER_BANK + 4, 328 + [EN7523_CRYPTO_RST] = RST_NR_PER_BANK + 6, 329 + [EN7523_TIMER_RST] = RST_NR_PER_BANK + 8, 330 + [EN7523_PCM1_RST] = RST_NR_PER_BANK + 11, 331 + [EN7523_UART_RST] = RST_NR_PER_BANK + 12, 332 + [EN7523_GPIO_RST] = RST_NR_PER_BANK + 13, 333 + [EN7523_GDMA_RST] = RST_NR_PER_BANK + 14, 334 + [EN7523_I2C_MASTER_RST] = RST_NR_PER_BANK + 16, 335 + [EN7523_PCM2_ZSI_ISI_RST] = RST_NR_PER_BANK + 17, 336 + [EN7523_SFC_RST] = RST_NR_PER_BANK + 18, 337 + [EN7523_UART2_RST] = RST_NR_PER_BANK + 19, 338 + [EN7523_GDMP_RST] = RST_NR_PER_BANK + 20, 339 + [EN7523_FE_RST] = RST_NR_PER_BANK + 21, 340 + [EN7523_USB_HOST_P0_RST] = RST_NR_PER_BANK + 22, 341 + [EN7523_GSW_RST] = RST_NR_PER_BANK + 23, 342 + [EN7523_SFC2_PCM_RST] = RST_NR_PER_BANK + 25, 343 + [EN7523_PCIE0_RST] = RST_NR_PER_BANK + 26, 344 + [EN7523_PCIE1_RST] = RST_NR_PER_BANK + 27, 345 + [EN7523_PCIE_HB_RST] = RST_NR_PER_BANK + 29, 346 + [EN7523_XPON_MAC_RST] = RST_NR_PER_BANK + 31, 347 + }; 348 + 303 349 static const u16 en7581_rst_map[] = { 304 350 /* RST_CTRL2 */ 305 351 [EN7581_XPON_PHY_RST] = 0, ··· 404 356 [EN7581_PCIE_HB_RST] = RST_NR_PER_BANK + 29, 405 357 [EN7581_XPON_MAC_RST] = RST_NR_PER_BANK + 31, 406 358 }; 359 + 360 + static int en7581_reset_register(struct device *dev, void __iomem *base, 361 + const u16 *rst_map, int nr_resets); 407 362 408 363 static u32 en7523_get_base_rate(const struct en_clk_desc *desc, u32 val) 409 364 { ··· 603 552 604 553 en7523_register_clocks(&pdev->dev, clk_data, base, np_base); 605 554 606 - return 0; 555 + return en7581_reset_register(&pdev->dev, np_base, en7523_rst_map, 556 + ARRAY_SIZE(en7523_rst_map)); 607 557 } 608 558 609 559 static void en7581_register_clocks(struct device *dev, struct clk_hw_onecell_data *clk_data, ··· 704 652 .status = en7523_reset_status, 705 653 }; 706 654 707 - static int en7581_reset_register(struct device *dev, void __iomem *base) 655 + static int en7581_reset_register(struct device *dev, void __iomem *base, 656 + const u16 *rst_map, int nr_resets) 708 657 { 709 658 struct en_rst_data *rst_data; 710 659 ··· 714 661 return -ENOMEM; 715 662 716 663 rst_data->bank_ofs = en7581_rst_ofs; 717 - rst_data->idx_map = en7581_rst_map; 664 + rst_data->idx_map = rst_map; 718 665 rst_data->base = base; 719 666 720 - rst_data->rcdev.nr_resets = ARRAY_SIZE(en7581_rst_map); 667 + rst_data->rcdev.nr_resets = nr_resets; 721 668 rst_data->rcdev.of_xlate = en7523_reset_xlate; 722 669 rst_data->rcdev.ops = &en7581_reset_ops; 723 670 rst_data->rcdev.of_node = dev->of_node; ··· 751 698 val = readl(base + REG_NP_SCU_PCIC); 752 699 writel(val | 3, base + REG_NP_SCU_PCIC); 753 700 754 - return en7581_reset_register(&pdev->dev, base); 701 + return en7581_reset_register(&pdev->dev, base, en7581_rst_map, 702 + ARRAY_SIZE(en7581_rst_map)); 755 703 } 756 704 757 705 static int en7523_clk_probe(struct platform_device *pdev)
+2 -2
drivers/clk/keystone/sci-clk.c
··· 496 496 static int _cmp_sci_clk_list(void *priv, const struct list_head *a, 497 497 const struct list_head *b) 498 498 { 499 - struct sci_clk *ca = container_of(a, struct sci_clk, node); 500 - struct sci_clk *cb = container_of(b, struct sci_clk, node); 499 + const struct sci_clk *ca = container_of(a, struct sci_clk, node); 500 + const struct sci_clk *cb = container_of(b, struct sci_clk, node); 501 501 502 502 return _cmp_sci_clk(ca, &cb); 503 503 }
+1 -1
drivers/clk/keystone/syscon-clk.c
··· 129 129 if (IS_ERR(base)) 130 130 return PTR_ERR(base); 131 131 132 - regmap = regmap_init_mmio(dev, base, &ti_syscon_regmap_cfg); 132 + regmap = devm_regmap_init_mmio(dev, base, &ti_syscon_regmap_cfg); 133 133 if (IS_ERR(regmap)) 134 134 return dev_err_probe(dev, PTR_ERR(regmap), 135 135 "failed to get regmap\n");
+6 -1
drivers/clk/renesas/r8a779a0-cpg-mssr.c
··· 26 26 27 27 enum clk_ids { 28 28 /* Core Clock Outputs exported to DT */ 29 - LAST_DT_CORE_CLK = R8A779A0_CLK_OSC, 29 + LAST_DT_CORE_CLK = R8A779A0_CLK_ZG, 30 30 31 31 /* External Input Clocks */ 32 32 CLK_EXTAL, ··· 39 39 CLK_PLL21, 40 40 CLK_PLL30, 41 41 CLK_PLL31, 42 + CLK_PLL4, 42 43 CLK_PLL5, 43 44 CLK_PLL1_DIV2, 44 45 CLK_PLL20_DIV2, ··· 66 65 #define CPG_PLL21CR 0x0838 /* PLL21 Control Register */ 67 66 #define CPG_PLL30CR 0x083c /* PLL30 Control Register */ 68 67 #define CPG_PLL31CR 0x0840 /* PLL31 Control Register */ 68 + #define CPG_PLL4CR 0x0844 /* PLL4 Control Register */ 69 69 70 70 static const struct cpg_core_clk r8a779a0_core_clks[] __initconst = { 71 71 /* External Clock Inputs */ ··· 81 79 DEF_PLL(".pll21", CLK_PLL21, CPG_PLL21CR), 82 80 DEF_PLL(".pll30", CLK_PLL30, CPG_PLL30CR), 83 81 DEF_PLL(".pll31", CLK_PLL31, CPG_PLL31CR), 82 + DEF_PLL(".pll4", CLK_PLL4, CPG_PLL4CR), 84 83 85 84 DEF_FIXED(".pll1_div2", CLK_PLL1_DIV2, CLK_PLL1, 2, 1), 86 85 DEF_FIXED(".pll20_div2", CLK_PLL20_DIV2, CLK_PLL20, 2, 1), ··· 101 98 /* Core Clock Outputs */ 102 99 DEF_GEN4_Z("z0", R8A779A0_CLK_Z0, CLK_TYPE_GEN4_Z, CLK_PLL20, 2, 0), 103 100 DEF_GEN4_Z("z1", R8A779A0_CLK_Z1, CLK_TYPE_GEN4_Z, CLK_PLL21, 2, 8), 101 + DEF_GEN4_Z("zg", R8A779A0_CLK_ZG, CLK_TYPE_GEN4_Z, CLK_PLL4, 2, 88), 104 102 DEF_FIXED("zx", R8A779A0_CLK_ZX, CLK_PLL20_DIV2, 2, 1), 105 103 DEF_FIXED("s1d1", R8A779A0_CLK_S1D1, CLK_S1, 1, 1), 106 104 DEF_FIXED("s1d2", R8A779A0_CLK_S1D2, CLK_S1, 2, 1), ··· 142 138 }; 143 139 144 140 static const struct mssr_mod_clk r8a779a0_mod_clks[] __initconst = { 141 + DEF_MOD("3dge", 0, R8A779A0_CLK_ZG), 145 142 DEF_MOD("isp0", 16, R8A779A0_CLK_S1D1), 146 143 DEF_MOD("isp1", 17, R8A779A0_CLK_S1D1), 147 144 DEF_MOD("isp2", 18, R8A779A0_CLK_S1D1),
+3 -3
drivers/clk/renesas/r9a06g032-clocks.c
··· 1333 1333 if (IS_ERR(mclk)) 1334 1334 return PTR_ERR(mclk); 1335 1335 1336 - clocks->reg = of_iomap(np, 0); 1337 - if (WARN_ON(!clocks->reg)) 1338 - return -ENOMEM; 1336 + clocks->reg = devm_of_iomap(dev, np, 0, NULL); 1337 + if (IS_ERR(clocks->reg)) 1338 + return PTR_ERR(clocks->reg); 1339 1339 1340 1340 r9a06g032_init_h2mode(clocks); 1341 1341
+143 -1
drivers/clk/renesas/r9a09g047-cpg.c
··· 16 16 17 17 enum clk_ids { 18 18 /* Core Clock Outputs exported to DT */ 19 - LAST_DT_CORE_CLK = R9A09G047_USB3_0_CLKCORE, 19 + LAST_DT_CORE_CLK = R9A09G047_USB2_0_CLK_CORE1, 20 20 21 21 /* External Input Clocks */ 22 22 CLK_AUDIO_EXTAL, ··· 44 44 CLK_PLLCLN_DIV8, 45 45 CLK_PLLCLN_DIV16, 46 46 CLK_PLLCLN_DIV20, 47 + CLK_PLLCLN_DIV64, 48 + CLK_PLLCLN_DIV256, 49 + CLK_PLLCLN_DIV1024, 47 50 CLK_PLLDTY_ACPU, 48 51 CLK_PLLDTY_ACPU_DIV2, 49 52 CLK_PLLDTY_ACPU_DIV4, ··· 145 142 DEF_FIXED(".pllcln_div8", CLK_PLLCLN_DIV8, CLK_PLLCLN, 1, 8), 146 143 DEF_FIXED(".pllcln_div16", CLK_PLLCLN_DIV16, CLK_PLLCLN, 1, 16), 147 144 DEF_FIXED(".pllcln_div20", CLK_PLLCLN_DIV20, CLK_PLLCLN, 1, 20), 145 + DEF_FIXED(".pllcln_div64", CLK_PLLCLN_DIV64, CLK_PLLCLN, 1, 64), 146 + DEF_FIXED(".pllcln_div256", CLK_PLLCLN_DIV256, CLK_PLLCLN, 1, 256), 147 + DEF_FIXED(".pllcln_div1024", CLK_PLLCLN_DIV1024, CLK_PLLCLN, 1, 1024), 148 148 149 149 DEF_DDIV(".plldty_acpu", CLK_PLLDTY_ACPU, CLK_PLLDTY, CDDIV0_DIVCTL2, dtable_2_64), 150 150 DEF_FIXED(".plldty_acpu_div2", CLK_PLLDTY_ACPU_DIV2, CLK_PLLDTY_ACPU, 1, 2), ··· 183 177 CDDIV1_DIVCTL3, dtable_1_8), 184 178 DEF_FIXED("iotop_0_shclk", R9A09G047_IOTOP_0_SHCLK, CLK_PLLCM33_DIV16, 1, 1), 185 179 DEF_FIXED("spi_clk_spi", R9A09G047_SPI_CLK_SPI, CLK_PLLCM33_XSPI, 1, 2), 180 + DEF_FIXED("usb2_0_clk_core0", R9A09G047_USB2_0_CLK_CORE0, CLK_QEXTAL, 1, 1), 181 + DEF_FIXED("usb2_0_clk_core1", R9A09G047_USB2_0_CLK_CORE1, CLK_QEXTAL, 1, 1), 186 182 DEF_FIXED("gbeth_0_clk_ptp_ref_i", R9A09G047_GBETH_0_CLK_PTP_REF_I, 187 183 CLK_PLLETH_DIV_125_FIX, 1, 1), 188 184 DEF_FIXED("gbeth_1_clk_ptp_ref_i", R9A09G047_GBETH_1_CLK_PTP_REF_I, ··· 224 216 BUS_MSTOP(5, BIT(13))), 225 217 DEF_MOD("wdt_3_clk_loco", CLK_QEXTAL, 5, 2, 2, 18, 226 218 BUS_MSTOP(5, BIT(13))), 219 + DEF_MOD("rsci0_pclk", CLK_PLLCLN_DIV16, 5, 13, 2, 29, 220 + BUS_MSTOP(11, BIT(3))), 221 + DEF_MOD("rsci0_tclk", CLK_PLLCLN_DIV16, 5, 14, 2, 30, 222 + BUS_MSTOP(11, BIT(3))), 223 + DEF_MOD("rsci0_ps_ps3_n", CLK_PLLCLN_DIV1024, 5, 15, 2, 31, 224 + BUS_MSTOP(11, BIT(3))), 225 + DEF_MOD("rsci0_ps_ps2_n", CLK_PLLCLN_DIV256, 6, 0, 3, 0, 226 + BUS_MSTOP(11, BIT(3))), 227 + DEF_MOD("rsci0_ps_ps1_n", CLK_PLLCLN_DIV64, 6, 1, 3, 1, 228 + BUS_MSTOP(11, BIT(3))), 229 + DEF_MOD("rsci1_pclk", CLK_PLLCLN_DIV16, 6, 2, 3, 2, 230 + BUS_MSTOP(11, BIT(4))), 231 + DEF_MOD("rsci1_tclk", CLK_PLLCLN_DIV16, 6, 3, 3, 3, 232 + BUS_MSTOP(11, BIT(4))), 233 + DEF_MOD("rsci1_ps_ps3_n", CLK_PLLCLN_DIV1024, 6, 4, 3, 4, 234 + BUS_MSTOP(11, BIT(4))), 235 + DEF_MOD("rsci1_ps_ps2_n", CLK_PLLCLN_DIV256, 6, 5, 3, 5, 236 + BUS_MSTOP(11, BIT(4))), 237 + DEF_MOD("rsci1_ps_ps1_n", CLK_PLLCLN_DIV64, 6, 6, 3, 6, 238 + BUS_MSTOP(11, BIT(4))), 239 + DEF_MOD("rsci2_pclk", CLK_PLLCLN_DIV16, 6, 7, 3, 7, 240 + BUS_MSTOP(11, BIT(5))), 241 + DEF_MOD("rsci2_tclk", CLK_PLLCLN_DIV16, 6, 8, 3, 8, 242 + BUS_MSTOP(11, BIT(5))), 243 + DEF_MOD("rsci2_ps_ps3_n", CLK_PLLCLN_DIV1024, 6, 9, 3, 9, 244 + BUS_MSTOP(11, BIT(5))), 245 + DEF_MOD("rsci2_ps_ps2_n", CLK_PLLCLN_DIV256, 6, 10, 3, 10, 246 + BUS_MSTOP(11, BIT(5))), 247 + DEF_MOD("rsci2_ps_ps1_n", CLK_PLLCLN_DIV64, 6, 11, 3, 11, 248 + BUS_MSTOP(11, BIT(5))), 249 + DEF_MOD("rsci3_pclk", CLK_PLLCLN_DIV16, 6, 12, 3, 12, 250 + BUS_MSTOP(11, BIT(6))), 251 + DEF_MOD("rsci3_tclk", CLK_PLLCLN_DIV16, 6, 13, 3, 13, 252 + BUS_MSTOP(11, BIT(6))), 253 + DEF_MOD("rsci3_ps_ps3_n", CLK_PLLCLN_DIV1024, 6, 14, 3, 14, 254 + BUS_MSTOP(11, BIT(6))), 255 + DEF_MOD("rsci3_ps_ps2_n", CLK_PLLCLN_DIV256, 6, 15, 3, 15, 256 + BUS_MSTOP(11, BIT(6))), 257 + DEF_MOD("rsci3_ps_ps1_n", CLK_PLLCLN_DIV64, 7, 0, 3, 16, 258 + BUS_MSTOP(11, BIT(6))), 259 + DEF_MOD("rsci4_pclk", CLK_PLLCLN_DIV16, 7, 1, 3, 17, 260 + BUS_MSTOP(11, BIT(7))), 261 + DEF_MOD("rsci4_tclk", CLK_PLLCLN_DIV16, 7, 2, 3, 18, 262 + BUS_MSTOP(11, BIT(7))), 263 + DEF_MOD("rsci4_ps_ps3_n", CLK_PLLCLN_DIV1024, 7, 3, 3, 19, 264 + BUS_MSTOP(11, BIT(7))), 265 + DEF_MOD("rsci4_ps_ps2_n", CLK_PLLCLN_DIV256, 7, 4, 3, 20, 266 + BUS_MSTOP(11, BIT(7))), 267 + DEF_MOD("rsci4_ps_ps1_n", CLK_PLLCLN_DIV64, 7, 5, 3, 21, 268 + BUS_MSTOP(11, BIT(7))), 269 + DEF_MOD("rsci5_pclk", CLK_PLLCLN_DIV16, 7, 6, 3, 22, 270 + BUS_MSTOP(11, BIT(8))), 271 + DEF_MOD("rsci5_tclk", CLK_PLLCLN_DIV16, 7, 7, 3, 23, 272 + BUS_MSTOP(11, BIT(8))), 273 + DEF_MOD("rsci5_ps_ps3_n", CLK_PLLCLN_DIV1024, 7, 8, 3, 24, 274 + BUS_MSTOP(11, BIT(8))), 275 + DEF_MOD("rsci5_ps_ps2_n", CLK_PLLCLN_DIV256, 7, 9, 3, 25, 276 + BUS_MSTOP(11, BIT(8))), 277 + DEF_MOD("rsci5_ps_ps1_n", CLK_PLLCLN_DIV64, 7, 10, 3, 26, 278 + BUS_MSTOP(11, BIT(8))), 279 + DEF_MOD("rsci6_pclk", CLK_PLLCLN_DIV16, 7, 11, 3, 27, 280 + BUS_MSTOP(11, BIT(9))), 281 + DEF_MOD("rsci6_tclk", CLK_PLLCLN_DIV16, 7, 12, 3, 28, 282 + BUS_MSTOP(11, BIT(9))), 283 + DEF_MOD("rsci6_ps_ps3_n", CLK_PLLCLN_DIV1024, 7, 13, 3, 29, 284 + BUS_MSTOP(11, BIT(9))), 285 + DEF_MOD("rsci6_ps_ps2_n", CLK_PLLCLN_DIV256, 7, 14, 3, 30, 286 + BUS_MSTOP(11, BIT(9))), 287 + DEF_MOD("rsci6_ps_ps1_n", CLK_PLLCLN_DIV64, 7, 15, 3, 31, 288 + BUS_MSTOP(11, BIT(9))), 289 + DEF_MOD("rsci7_pclk", CLK_PLLCLN_DIV16, 8, 0, 4, 0, 290 + BUS_MSTOP(11, BIT(10))), 291 + DEF_MOD("rsci7_tclk", CLK_PLLCLN_DIV16, 8, 1, 4, 1, 292 + BUS_MSTOP(11, BIT(10))), 293 + DEF_MOD("rsci7_ps_ps3_n", CLK_PLLCLN_DIV1024, 8, 2, 4, 2, 294 + BUS_MSTOP(11, BIT(10))), 295 + DEF_MOD("rsci7_ps_ps2_n", CLK_PLLCLN_DIV256, 8, 3, 4, 3, 296 + BUS_MSTOP(11, BIT(10))), 297 + DEF_MOD("rsci7_ps_ps1_n", CLK_PLLCLN_DIV64, 8, 4, 4, 4, 298 + BUS_MSTOP(11, BIT(10))), 299 + DEF_MOD("rsci8_pclk", CLK_PLLCLN_DIV16, 8, 5, 4, 5, 300 + BUS_MSTOP(11, BIT(11))), 301 + DEF_MOD("rsci8_tclk", CLK_PLLCLN_DIV16, 8, 6, 4, 6, 302 + BUS_MSTOP(11, BIT(11))), 303 + DEF_MOD("rsci8_ps_ps3_n", CLK_PLLCLN_DIV1024, 8, 7, 4, 7, 304 + BUS_MSTOP(11, BIT(11))), 305 + DEF_MOD("rsci8_ps_ps2_n", CLK_PLLCLN_DIV256, 8, 8, 4, 8, 306 + BUS_MSTOP(11, BIT(11))), 307 + DEF_MOD("rsci8_ps_ps1_n", CLK_PLLCLN_DIV64, 8, 9, 4, 9, 308 + BUS_MSTOP(11, BIT(11))), 309 + DEF_MOD("rsci9_pclk", CLK_PLLCLN_DIV16, 8, 10, 4, 10, 310 + BUS_MSTOP(11, BIT(12))), 311 + DEF_MOD("rsci9_tclk", CLK_PLLCLN_DIV16, 8, 11, 4, 11, 312 + BUS_MSTOP(11, BIT(12))), 313 + DEF_MOD("rsci9_ps_ps3_n", CLK_PLLCLN_DIV1024, 8, 12, 4, 12, 314 + BUS_MSTOP(11, BIT(12))), 315 + DEF_MOD("rsci9_ps_ps2_n", CLK_PLLCLN_DIV256, 8, 13, 4, 13, 316 + BUS_MSTOP(11, BIT(12))), 317 + DEF_MOD("rsci9_ps_ps1_n", CLK_PLLCLN_DIV64, 8, 14, 4, 14, 318 + BUS_MSTOP(11, BIT(12))), 227 319 DEF_MOD("scif_0_clk_pck", CLK_PLLCM33_DIV16, 8, 15, 4, 15, 228 320 BUS_MSTOP(3, BIT(14))), 229 321 DEF_MOD("i3c_0_pclkrw", CLK_PLLCLN_DIV16, 9, 0, 4, 16, ··· 390 282 BUS_MSTOP(7, BIT(12))), 391 283 DEF_MOD("usb3_0_pclk_usbtst", CLK_PLLDTY_ACPU_DIV4, 11, 0, 5, 16, 392 284 BUS_MSTOP(7, BIT(14))), 285 + DEF_MOD("usb2_0_u2h0_hclk", CLK_PLLDTY_DIV8, 11, 3, 5, 19, 286 + BUS_MSTOP(7, BIT(7))), 287 + DEF_MOD("usb2_0_u2h1_hclk", CLK_PLLDTY_DIV8, 11, 4, 5, 20, 288 + BUS_MSTOP(7, BIT(8))), 289 + DEF_MOD("usb2_0_u2p_exr_cpuclk", CLK_PLLDTY_ACPU_DIV4, 11, 5, 5, 21, 290 + BUS_MSTOP(7, BIT(9))), 291 + DEF_MOD("usb2_0_pclk_usbtst0", CLK_PLLDTY_ACPU_DIV4, 11, 6, 5, 22, 292 + BUS_MSTOP(7, BIT(10))), 293 + DEF_MOD("usb2_0_pclk_usbtst1", CLK_PLLDTY_ACPU_DIV4, 11, 7, 5, 23, 294 + BUS_MSTOP(7, BIT(11))), 393 295 DEF_MOD_MUX_EXTERNAL("gbeth_0_clk_tx_i", CLK_SMUX2_GBE0_TXCLK, 11, 8, 5, 24, 394 296 BUS_MSTOP(8, BIT(5)), 1), 395 297 DEF_MOD_MUX_EXTERNAL("gbeth_0_clk_rx_i", CLK_SMUX2_GBE0_RXCLK, 11, 9, 5, 25, ··· 457 339 DEF_RST(7, 6, 3, 7), /* WDT_1_RESET */ 458 340 DEF_RST(7, 7, 3, 8), /* WDT_2_RESET */ 459 341 DEF_RST(7, 8, 3, 9), /* WDT_3_RESET */ 342 + DEF_RST(8, 1, 3, 18), /* RSCI0_PRESETN */ 343 + DEF_RST(8, 2, 3, 19), /* RSCI0_TRESETN */ 344 + DEF_RST(8, 3, 3, 20), /* RSCI1_PRESETN */ 345 + DEF_RST(8, 4, 3, 21), /* RSCI1_TRESETN */ 346 + DEF_RST(8, 5, 3, 22), /* RSCI2_PRESETN */ 347 + DEF_RST(8, 6, 3, 23), /* RSCI2_TRESETN */ 348 + DEF_RST(8, 7, 3, 24), /* RSCI3_PRESETN */ 349 + DEF_RST(8, 8, 3, 25), /* RSCI3_TRESETN */ 350 + DEF_RST(8, 9, 3, 26), /* RSCI4_PRESETN */ 351 + DEF_RST(8, 10, 3, 27), /* RSCI4_TRESETN */ 352 + DEF_RST(8, 11, 3, 28), /* RSCI5_PRESETN */ 353 + DEF_RST(8, 12, 3, 29), /* RSCI5_TRESETN */ 354 + DEF_RST(8, 13, 3, 30), /* RSCI6_PRESETN */ 355 + DEF_RST(8, 14, 3, 31), /* RSCI6_TRESETN */ 356 + DEF_RST(8, 15, 4, 0), /* RSCI7_PRESETN */ 357 + DEF_RST(9, 0, 4, 1), /* RSCI7_TRESETN */ 358 + DEF_RST(9, 1, 4, 2), /* RSCI8_PRESETN */ 359 + DEF_RST(9, 2, 4, 3), /* RSCI8_TRESETN */ 360 + DEF_RST(9, 3, 4, 4), /* RSCI9_PRESETN */ 361 + DEF_RST(9, 4, 4, 5), /* RSCI9_TRESETN */ 460 362 DEF_RST(9, 5, 4, 6), /* SCIF_0_RST_SYSTEM_N */ 461 363 DEF_RST(9, 6, 4, 7), /* I3C_0_PRESETN */ 462 364 DEF_RST(9, 7, 4, 8), /* I3C_0_TRESETN */ ··· 497 359 DEF_RST(10, 8, 4, 25), /* SDHI_1_IXRST */ 498 360 DEF_RST(10, 9, 4, 26), /* SDHI_2_IXRST */ 499 361 DEF_RST(10, 10, 4, 27), /* USB3_0_ARESETN */ 362 + DEF_RST(10, 12, 4, 29), /* USB2_0_U2H0_HRESETN */ 363 + DEF_RST(10, 13, 4, 30), /* USB2_0_U2H1_HRESETN */ 364 + DEF_RST(10, 14, 4, 31), /* USB2_0_U2P_EXL_SYSRST */ 365 + DEF_RST(10, 15, 5, 0), /* USB2_0_PRESETN */ 500 366 DEF_RST(11, 0, 5, 1), /* GBETH_0_ARESETN_I */ 501 367 DEF_RST(11, 1, 5, 2), /* GBETH_1_ARESETN_I */ 502 368 DEF_RST(12, 5, 5, 22), /* CRU_0_PRESETN */
+117 -1
drivers/clk/renesas/r9a09g056-cpg.c
··· 6 6 */ 7 7 8 8 #include <linux/clk-provider.h> 9 + #include <linux/clk/renesas.h> 9 10 #include <linux/device.h> 10 11 #include <linux/init.h> 11 12 #include <linux/kernel.h> ··· 17 16 18 17 enum clk_ids { 19 18 /* Core Clock Outputs exported to DT */ 20 - LAST_DT_CORE_CLK = R9A09G056_SPI_CLK_SPI, 19 + LAST_DT_CORE_CLK = R9A09G056_USB3_0_CLKCORE, 21 20 22 21 /* External Input Clocks */ 23 22 CLK_AUDIO_EXTAL, ··· 29 28 CLK_PLLCLN, 30 29 CLK_PLLDTY, 31 30 CLK_PLLCA55, 31 + CLK_PLLVDO, 32 32 CLK_PLLETH, 33 + CLK_PLLDSI, 33 34 CLK_PLLGPU, 34 35 35 36 /* Internal Core Clocks */ ··· 50 47 CLK_PLLDTY_ACPU_DIV2, 51 48 CLK_PLLDTY_ACPU_DIV4, 52 49 CLK_PLLDTY_DIV8, 50 + CLK_PLLDTY_DIV16, 51 + CLK_PLLVDO_CRU0, 52 + CLK_PLLVDO_CRU1, 53 + CLK_PLLVDO_ISP, 53 54 CLK_PLLETH_DIV_250_FIX, 54 55 CLK_PLLETH_DIV_125_FIX, 55 56 CLK_CSDIV_PLLETH_GBE0, ··· 62 55 CLK_SMUX2_GBE0_RXCLK, 63 56 CLK_SMUX2_GBE1_TXCLK, 64 57 CLK_SMUX2_GBE1_RXCLK, 58 + CLK_CDIV4_PLLETH_LPCLK, 59 + CLK_PLLETH_LPCLK_GEAR, 60 + CLK_PLLDSI_GEAR, 65 61 CLK_PLLGPU_GEAR, 66 62 67 63 /* Module Clocks */ ··· 79 69 {0, 0}, 80 70 }; 81 71 72 + static const struct clk_div_table dtable_2_4[] = { 73 + {0, 2}, 74 + {1, 4}, 75 + {0, 0}, 76 + }; 77 + 82 78 static const struct clk_div_table dtable_2_16[] = { 83 79 {0, 2}, 84 80 {1, 4}, 85 81 {2, 8}, 86 82 {3, 16}, 83 + {0, 0}, 84 + }; 85 + 86 + static const struct clk_div_table dtable_2_32[] = { 87 + {0, 2}, 88 + {1, 4}, 89 + {2, 6}, 90 + {3, 8}, 91 + {4, 10}, 92 + {5, 12}, 93 + {6, 14}, 94 + {7, 16}, 95 + {8, 18}, 96 + {9, 20}, 97 + {10, 22}, 98 + {11, 24}, 99 + {12, 26}, 100 + {13, 28}, 101 + {14, 30}, 102 + {15, 32}, 87 103 {0, 0}, 88 104 }; 89 105 ··· 128 92 {2, 100}, 129 93 {0, 0}, 130 94 }; 95 + 96 + static const struct clk_div_table dtable_16_128[] = { 97 + {0, 16}, 98 + {1, 32}, 99 + {2, 64}, 100 + {3, 128}, 101 + {0, 0}, 102 + }; 103 + 104 + RZV2H_CPG_PLL_DSI_LIMITS(rzv2n_cpg_pll_dsi_limits); 105 + #define PLLDSI PLL_PACK_LIMITS(0xc0, 1, 0, &rzv2n_cpg_pll_dsi_limits) 131 106 132 107 /* Mux clock tables */ 133 108 static const char * const smux2_gbe0_rxclk[] = { ".plleth_gbe0", "et0_rxclk" }; ··· 159 112 DEF_FIXED(".pllcln", CLK_PLLCLN, CLK_QEXTAL, 200, 3), 160 113 DEF_FIXED(".plldty", CLK_PLLDTY, CLK_QEXTAL, 200, 3), 161 114 DEF_PLL(".pllca55", CLK_PLLCA55, CLK_QEXTAL, PLLCA55), 115 + DEF_FIXED(".pllvdo", CLK_PLLVDO, CLK_QEXTAL, 105, 2), 162 116 DEF_FIXED(".plleth", CLK_PLLETH, CLK_QEXTAL, 125, 3), 117 + DEF_PLLDSI(".plldsi", CLK_PLLDSI, CLK_QEXTAL, PLLDSI), 163 118 DEF_PLL(".pllgpu", CLK_PLLGPU, CLK_QEXTAL, PLLGPU), 164 119 165 120 /* Internal Core Clocks */ ··· 183 134 DEF_FIXED(".plldty_acpu_div2", CLK_PLLDTY_ACPU_DIV2, CLK_PLLDTY_ACPU, 1, 2), 184 135 DEF_FIXED(".plldty_acpu_div4", CLK_PLLDTY_ACPU_DIV4, CLK_PLLDTY_ACPU, 1, 4), 185 136 DEF_FIXED(".plldty_div8", CLK_PLLDTY_DIV8, CLK_PLLDTY, 1, 8), 137 + DEF_FIXED(".plldty_div16", CLK_PLLDTY_DIV16, CLK_PLLDTY, 1, 16), 138 + 139 + DEF_DDIV(".pllvdo_cru0", CLK_PLLVDO_CRU0, CLK_PLLVDO, CDDIV3_DIVCTL3, dtable_2_4), 140 + DEF_DDIV(".pllvdo_cru1", CLK_PLLVDO_CRU1, CLK_PLLVDO, CDDIV4_DIVCTL0, dtable_2_4), 141 + DEF_DDIV(".pllvdo_isp", CLK_PLLVDO_ISP, CLK_PLLVDO, CDDIV2_DIVCTL3, dtable_2_64), 186 142 187 143 DEF_FIXED(".plleth_250_fix", CLK_PLLETH_DIV_250_FIX, CLK_PLLETH, 1, 4), 188 144 DEF_FIXED(".plleth_125_fix", CLK_PLLETH_DIV_125_FIX, CLK_PLLETH_DIV_250_FIX, 1, 2), ··· 199 145 DEF_SMUX(".smux2_gbe0_rxclk", CLK_SMUX2_GBE0_RXCLK, SSEL0_SELCTL3, smux2_gbe0_rxclk), 200 146 DEF_SMUX(".smux2_gbe1_txclk", CLK_SMUX2_GBE1_TXCLK, SSEL1_SELCTL0, smux2_gbe1_txclk), 201 147 DEF_SMUX(".smux2_gbe1_rxclk", CLK_SMUX2_GBE1_RXCLK, SSEL1_SELCTL1, smux2_gbe1_rxclk), 148 + DEF_FIXED(".cdiv4_plleth_lpclk", CLK_CDIV4_PLLETH_LPCLK, CLK_PLLETH, 1, 4), 149 + DEF_CSDIV(".plleth_lpclk_gear", CLK_PLLETH_LPCLK_GEAR, CLK_CDIV4_PLLETH_LPCLK, 150 + CSDIV0_DIVCTL2, dtable_16_128), 151 + 152 + DEF_PLLDSI_DIV(".plldsi_gear", CLK_PLLDSI_GEAR, CLK_PLLDSI, 153 + CSDIV1_DIVCTL2, dtable_2_32), 202 154 203 155 DEF_DDIV(".pllgpu_gear", CLK_PLLGPU_GEAR, CLK_PLLGPU, CDDIV3_DIVCTL1, dtable_2_64), 204 156 ··· 226 166 CLK_PLLETH_DIV_125_FIX, 1, 1), 227 167 DEF_FIXED_MOD_STATUS("spi_clk_spi", R9A09G056_SPI_CLK_SPI, CLK_PLLCM33_XSPI, 1, 2, 228 168 FIXED_MOD_CONF_XSPI), 169 + DEF_FIXED("usb3_0_ref_alt_clk_p", R9A09G056_USB3_0_REF_ALT_CLK_P, CLK_QEXTAL, 1, 1), 170 + DEF_FIXED("usb3_0_core_clk", R9A09G056_USB3_0_CLKCORE, CLK_QEXTAL, 1, 1), 229 171 }; 230 172 231 173 static const struct rzv2h_mod_clk r9a09g056_mod_clks[] __initconst = { ··· 321 259 BUS_MSTOP(8, BIT(4))), 322 260 DEF_MOD("sdhi_2_aclk", CLK_PLLDTY_ACPU_DIV4, 10, 14, 5, 14, 323 261 BUS_MSTOP(8, BIT(4))), 262 + DEF_MOD("usb3_0_aclk", CLK_PLLDTY_DIV8, 10, 15, 5, 15, 263 + BUS_MSTOP(7, BIT(12))), 264 + DEF_MOD("usb3_0_pclk_usbtst", CLK_PLLDTY_ACPU_DIV4, 11, 0, 5, 16, 265 + BUS_MSTOP(7, BIT(14))), 324 266 DEF_MOD("usb2_0_u2h0_hclk", CLK_PLLDTY_DIV8, 11, 3, 5, 19, 325 267 BUS_MSTOP(7, BIT(7))), 326 268 DEF_MOD("usb2_0_u2p_exr_cpuclk", CLK_PLLDTY_ACPU_DIV4, 11, 5, 5, 21, ··· 355 289 BUS_MSTOP(8, BIT(6))), 356 290 DEF_MOD("gbeth_1_aclk_i", CLK_PLLDTY_DIV8, 12, 3, 6, 3, 357 291 BUS_MSTOP(8, BIT(6))), 292 + DEF_MOD("cru_0_aclk", CLK_PLLDTY_ACPU_DIV2, 13, 2, 6, 18, 293 + BUS_MSTOP(9, BIT(4))), 294 + DEF_MOD_NO_PM("cru_0_vclk", CLK_PLLVDO_CRU0, 13, 3, 6, 19, 295 + BUS_MSTOP(9, BIT(4))), 296 + DEF_MOD("cru_0_pclk", CLK_PLLDTY_DIV16, 13, 4, 6, 20, 297 + BUS_MSTOP(9, BIT(4))), 298 + DEF_MOD("cru_1_aclk", CLK_PLLDTY_ACPU_DIV2, 13, 5, 6, 21, 299 + BUS_MSTOP(9, BIT(5))), 300 + DEF_MOD_NO_PM("cru_1_vclk", CLK_PLLVDO_CRU1, 13, 6, 6, 22, 301 + BUS_MSTOP(9, BIT(5))), 302 + DEF_MOD("cru_1_pclk", CLK_PLLDTY_DIV16, 13, 7, 6, 23, 303 + BUS_MSTOP(9, BIT(5))), 304 + DEF_MOD("isp_0_reg_aclk", CLK_PLLDTY_ACPU_DIV2, 14, 2, 7, 2, 305 + BUS_MSTOP(9, BIT(8))), 306 + DEF_MOD("isp_0_pclk", CLK_PLLDTY_DIV16, 14, 3, 7, 3, 307 + BUS_MSTOP(9, BIT(8))), 308 + DEF_MOD("isp_0_vin_aclk", CLK_PLLDTY_ACPU_DIV2, 14, 4, 7, 4, 309 + BUS_MSTOP(9, BIT(9))), 310 + DEF_MOD("isp_0_isp_sclk", CLK_PLLVDO_ISP, 14, 5, 7, 5, 311 + BUS_MSTOP(9, BIT(9))), 312 + DEF_MOD("dsi_0_pclk", CLK_PLLDTY_DIV16, 14, 8, 7, 8, 313 + BUS_MSTOP(9, BIT(14) | BIT(15))), 314 + DEF_MOD("dsi_0_aclk", CLK_PLLDTY_ACPU_DIV2, 14, 9, 7, 9, 315 + BUS_MSTOP(9, BIT(14) | BIT(15))), 316 + DEF_MOD("dsi_0_vclk1", CLK_PLLDSI_GEAR, 14, 10, 7, 10, 317 + BUS_MSTOP(9, BIT(14) | BIT(15))), 318 + DEF_MOD("dsi_0_lpclk", CLK_PLLETH_LPCLK_GEAR, 14, 11, 7, 11, 319 + BUS_MSTOP(9, BIT(14) | BIT(15))), 320 + DEF_MOD("dsi_0_pllref_clk", CLK_QEXTAL, 14, 12, 7, 12, 321 + BUS_MSTOP(9, BIT(14) | BIT(15))), 322 + DEF_MOD("lcdc_0_clk_a", CLK_PLLDTY_ACPU_DIV2, 14, 13, 7, 13, 323 + BUS_MSTOP(10, BIT(1) | BIT(2) | BIT(3))), 324 + DEF_MOD("lcdc_0_clk_p", CLK_PLLDTY_DIV16, 14, 14, 7, 14, 325 + BUS_MSTOP(10, BIT(1) | BIT(2) | BIT(3))), 326 + DEF_MOD("lcdc_0_clk_d", CLK_PLLDSI_GEAR, 14, 15, 7, 15, 327 + BUS_MSTOP(10, BIT(1) | BIT(2) | BIT(3))), 358 328 DEF_MOD("gpu_0_clk", CLK_PLLGPU_GEAR, 15, 0, 7, 16, 359 329 BUS_MSTOP(3, BIT(4))), 360 330 DEF_MOD("gpu_0_axi_clk", CLK_PLLDTY_ACPU_DIV2, 15, 1, 7, 17, ··· 432 330 DEF_RST(10, 7, 4, 24), /* SDHI_0_IXRST */ 433 331 DEF_RST(10, 8, 4, 25), /* SDHI_1_IXRST */ 434 332 DEF_RST(10, 9, 4, 26), /* SDHI_2_IXRST */ 333 + DEF_RST(10, 10, 4, 27), /* USB3_0_ARESETN */ 435 334 DEF_RST(10, 12, 4, 29), /* USB2_0_U2H0_HRESETN */ 436 335 DEF_RST(10, 14, 4, 31), /* USB2_0_U2P_EXL_SYSRST */ 437 336 DEF_RST(10, 15, 5, 0), /* USB2_0_PRESETN */ 438 337 DEF_RST(11, 0, 5, 1), /* GBETH_0_ARESETN_I */ 439 338 DEF_RST(11, 1, 5, 2), /* GBETH_1_ARESETN_I */ 339 + DEF_RST(12, 5, 5, 22), /* CRU_0_PRESETN */ 340 + DEF_RST(12, 6, 5, 23), /* CRU_0_ARESETN */ 341 + DEF_RST(12, 7, 5, 24), /* CRU_0_S_RESETN */ 342 + DEF_RST(12, 8, 5, 25), /* CRU_1_PRESETN */ 343 + DEF_RST(12, 9, 5, 26), /* CRU_1_ARESETN */ 344 + DEF_RST(12, 10, 5, 27), /* CRU_1_S_RESETN */ 345 + DEF_RST(13, 1, 6, 2), /* ISP_0_VIN_ARESETN */ 346 + DEF_RST(13, 2, 6, 3), /* ISP_0_REG_ARESETN */ 347 + DEF_RST(13, 3, 6, 4), /* ISP_0_ISP_SRESETN */ 348 + DEF_RST(13, 4, 6, 5), /* ISP_0_PRESETN */ 349 + DEF_RST(13, 7, 6, 8), /* DSI_0_PRESETN */ 350 + DEF_RST(13, 8, 6, 9), /* DSI_0_ARESETN */ 351 + DEF_RST(13, 12, 6, 13), /* LCDC_0_RESET_N */ 440 352 DEF_RST(13, 13, 6, 14), /* GPU_0_RESETN */ 441 353 DEF_RST(13, 14, 6, 15), /* GPU_0_AXI_RESETN */ 442 354 DEF_RST(13, 15, 6, 16), /* GPU_0_ACE_RESETN */
+101 -1
drivers/clk/renesas/r9a09g057-cpg.c
··· 6 6 */ 7 7 8 8 #include <linux/clk-provider.h> 9 + #include <linux/clk/renesas.h> 9 10 #include <linux/device.h> 10 11 #include <linux/init.h> 11 12 #include <linux/kernel.h> ··· 17 16 18 17 enum clk_ids { 19 18 /* Core Clock Outputs exported to DT */ 20 - LAST_DT_CORE_CLK = R9A09G057_SPI_CLK_SPI, 19 + LAST_DT_CORE_CLK = R9A09G057_USB3_1_CLKCORE, 21 20 22 21 /* External Input Clocks */ 23 22 CLK_AUDIO_EXTAL, ··· 31 30 CLK_PLLCA55, 32 31 CLK_PLLVDO, 33 32 CLK_PLLETH, 33 + CLK_PLLDSI, 34 34 CLK_PLLGPU, 35 35 36 36 /* Internal Core Clocks */ ··· 57 55 CLK_PLLVDO_CRU1, 58 56 CLK_PLLVDO_CRU2, 59 57 CLK_PLLVDO_CRU3, 58 + CLK_PLLVDO_ISP, 60 59 CLK_PLLETH_DIV_250_FIX, 61 60 CLK_PLLETH_DIV_125_FIX, 62 61 CLK_CSDIV_PLLETH_GBE0, ··· 66 63 CLK_SMUX2_GBE0_RXCLK, 67 64 CLK_SMUX2_GBE1_TXCLK, 68 65 CLK_SMUX2_GBE1_RXCLK, 66 + CLK_CDIV4_PLLETH_LPCLK, 67 + CLK_PLLETH_LPCLK_GEAR, 68 + CLK_PLLDSI_GEAR, 69 69 CLK_PLLGPU_GEAR, 70 70 71 71 /* Module Clocks */ ··· 97 91 {0, 0}, 98 92 }; 99 93 94 + static const struct clk_div_table dtable_2_32[] = { 95 + {0, 2}, 96 + {1, 4}, 97 + {2, 6}, 98 + {3, 8}, 99 + {4, 10}, 100 + {5, 12}, 101 + {6, 14}, 102 + {7, 16}, 103 + {8, 18}, 104 + {9, 20}, 105 + {10, 22}, 106 + {11, 24}, 107 + {12, 26}, 108 + {13, 28}, 109 + {14, 30}, 110 + {15, 32}, 111 + {0, 0}, 112 + }; 113 + 100 114 static const struct clk_div_table dtable_2_64[] = { 101 115 {0, 2}, 102 116 {1, 4}, ··· 132 106 {2, 100}, 133 107 {0, 0}, 134 108 }; 109 + 110 + static const struct clk_div_table dtable_16_128[] = { 111 + {0, 16}, 112 + {1, 32}, 113 + {2, 64}, 114 + {3, 128}, 115 + {0, 0}, 116 + }; 117 + 118 + RZV2H_CPG_PLL_DSI_LIMITS(rzv2h_cpg_pll_dsi_limits); 119 + #define PLLDSI PLL_PACK_LIMITS(0xc0, 1, 0, &rzv2h_cpg_pll_dsi_limits) 135 120 136 121 /* Mux clock tables */ 137 122 static const char * const smux2_gbe0_rxclk[] = { ".plleth_gbe0", "et0_rxclk" }; ··· 165 128 DEF_PLL(".pllca55", CLK_PLLCA55, CLK_QEXTAL, PLLCA55), 166 129 DEF_FIXED(".pllvdo", CLK_PLLVDO, CLK_QEXTAL, 105, 2), 167 130 DEF_FIXED(".plleth", CLK_PLLETH, CLK_QEXTAL, 125, 3), 131 + DEF_PLLDSI(".plldsi", CLK_PLLDSI, CLK_QEXTAL, PLLDSI), 168 132 DEF_PLL(".pllgpu", CLK_PLLGPU, CLK_QEXTAL, PLLGPU), 169 133 170 134 /* Internal Core Clocks */ ··· 195 157 DEF_DDIV(".pllvdo_cru1", CLK_PLLVDO_CRU1, CLK_PLLVDO, CDDIV4_DIVCTL0, dtable_2_4), 196 158 DEF_DDIV(".pllvdo_cru2", CLK_PLLVDO_CRU2, CLK_PLLVDO, CDDIV4_DIVCTL1, dtable_2_4), 197 159 DEF_DDIV(".pllvdo_cru3", CLK_PLLVDO_CRU3, CLK_PLLVDO, CDDIV4_DIVCTL2, dtable_2_4), 160 + DEF_DDIV(".pllvdo_isp", CLK_PLLVDO_ISP, CLK_PLLVDO, CDDIV2_DIVCTL3, dtable_2_64), 198 161 199 162 DEF_FIXED(".plleth_250_fix", CLK_PLLETH_DIV_250_FIX, CLK_PLLETH, 1, 4), 200 163 DEF_FIXED(".plleth_125_fix", CLK_PLLETH_DIV_125_FIX, CLK_PLLETH_DIV_250_FIX, 1, 2), ··· 207 168 DEF_SMUX(".smux2_gbe0_rxclk", CLK_SMUX2_GBE0_RXCLK, SSEL0_SELCTL3, smux2_gbe0_rxclk), 208 169 DEF_SMUX(".smux2_gbe1_txclk", CLK_SMUX2_GBE1_TXCLK, SSEL1_SELCTL0, smux2_gbe1_txclk), 209 170 DEF_SMUX(".smux2_gbe1_rxclk", CLK_SMUX2_GBE1_RXCLK, SSEL1_SELCTL1, smux2_gbe1_rxclk), 171 + DEF_FIXED(".cdiv4_plleth_lpclk", CLK_CDIV4_PLLETH_LPCLK, CLK_PLLETH, 1, 4), 172 + DEF_CSDIV(".plleth_lpclk_gear", CLK_PLLETH_LPCLK_GEAR, CLK_CDIV4_PLLETH_LPCLK, 173 + CSDIV0_DIVCTL2, dtable_16_128), 174 + 175 + DEF_PLLDSI_DIV(".plldsi_gear", CLK_PLLDSI_GEAR, CLK_PLLDSI, 176 + CSDIV1_DIVCTL2, dtable_2_32), 210 177 211 178 DEF_DDIV(".pllgpu_gear", CLK_PLLGPU_GEAR, CLK_PLLGPU, CDDIV3_DIVCTL1, dtable_2_64), 212 179 ··· 235 190 CLK_PLLETH_DIV_125_FIX, 1, 1), 236 191 DEF_FIXED_MOD_STATUS("spi_clk_spi", R9A09G057_SPI_CLK_SPI, CLK_PLLCM33_XSPI, 1, 2, 237 192 FIXED_MOD_CONF_XSPI), 193 + DEF_FIXED("usb3_0_ref_alt_clk_p", R9A09G057_USB3_0_REF_ALT_CLK_P, CLK_QEXTAL, 1, 1), 194 + DEF_FIXED("usb3_0_core_clk", R9A09G057_USB3_0_CLKCORE, CLK_QEXTAL, 1, 1), 195 + DEF_FIXED("usb3_1_ref_alt_clk_p", R9A09G057_USB3_1_REF_ALT_CLK_P, CLK_QEXTAL, 1, 1), 196 + DEF_FIXED("usb3_1_core_clk", R9A09G057_USB3_1_CLKCORE, CLK_QEXTAL, 1, 1), 238 197 }; 239 198 240 199 static const struct rzv2h_mod_clk r9a09g057_mod_clks[] __initconst = { ··· 288 239 BUS_MSTOP(5, BIT(13))), 289 240 DEF_MOD("wdt_3_clk_loco", CLK_QEXTAL, 5, 2, 2, 18, 290 241 BUS_MSTOP(5, BIT(13))), 242 + DEF_MOD("rtc_0_clk_rtc", CLK_PLLCM33_DIV16, 5, 3, 2, 19, 243 + BUS_MSTOP(3, BIT(11) | BIT(12))), 291 244 DEF_MOD("rspi_0_pclk", CLK_PLLCLN_DIV8, 5, 4, 2, 20, 292 245 BUS_MSTOP(11, BIT(0))), 293 246 DEF_MOD("rspi_0_pclk_sfr", CLK_PLLCLN_DIV8, 5, 5, 2, 21, ··· 364 313 BUS_MSTOP(8, BIT(4))), 365 314 DEF_MOD("sdhi_2_aclk", CLK_PLLDTY_ACPU_DIV4, 10, 14, 5, 14, 366 315 BUS_MSTOP(8, BIT(4))), 316 + DEF_MOD("usb3_0_aclk", CLK_PLLDTY_DIV8, 10, 15, 5, 15, 317 + BUS_MSTOP(7, BIT(12))), 318 + DEF_MOD("usb3_0_pclk_usbtst", CLK_PLLDTY_ACPU_DIV4, 11, 0, 5, 16, 319 + BUS_MSTOP(7, BIT(14))), 320 + DEF_MOD("usb3_1_aclk", CLK_PLLDTY_DIV8, 11, 1, 5, 17, 321 + BUS_MSTOP(7, BIT(13))), 322 + DEF_MOD("usb3_1_pclk_usbtst", CLK_PLLDTY_ACPU_DIV4, 11, 2, 5, 18, 323 + BUS_MSTOP(7, BIT(15))), 367 324 DEF_MOD("usb2_0_u2h0_hclk", CLK_PLLDTY_DIV8, 11, 3, 5, 19, 368 325 BUS_MSTOP(7, BIT(7))), 369 326 DEF_MOD("usb2_0_u2h1_hclk", CLK_PLLDTY_DIV8, 11, 4, 5, 20, ··· 430 371 BUS_MSTOP(9, BIT(7))), 431 372 DEF_MOD("cru_3_pclk", CLK_PLLDTY_DIV16, 13, 13, 6, 29, 432 373 BUS_MSTOP(9, BIT(7))), 374 + DEF_MOD("isp_0_reg_aclk", CLK_PLLDTY_ACPU_DIV2, 14, 2, 7, 2, 375 + BUS_MSTOP(9, BIT(8))), 376 + DEF_MOD("isp_0_pclk", CLK_PLLDTY_DIV16, 14, 3, 7, 3, 377 + BUS_MSTOP(9, BIT(8))), 378 + DEF_MOD("isp_0_vin_aclk", CLK_PLLDTY_ACPU_DIV2, 14, 4, 7, 4, 379 + BUS_MSTOP(9, BIT(9))), 380 + DEF_MOD("isp_0_isp_sclk", CLK_PLLVDO_ISP, 14, 5, 7, 5, 381 + BUS_MSTOP(9, BIT(9))), 382 + DEF_MOD("dsi_0_pclk", CLK_PLLDTY_DIV16, 14, 8, 7, 8, 383 + BUS_MSTOP(9, BIT(14) | BIT(15))), 384 + DEF_MOD("dsi_0_aclk", CLK_PLLDTY_ACPU_DIV2, 14, 9, 7, 9, 385 + BUS_MSTOP(9, BIT(14) | BIT(15))), 386 + DEF_MOD("dsi_0_vclk1", CLK_PLLDSI_GEAR, 14, 10, 7, 10, 387 + BUS_MSTOP(9, BIT(14) | BIT(15))), 388 + DEF_MOD("dsi_0_lpclk", CLK_PLLETH_LPCLK_GEAR, 14, 11, 7, 11, 389 + BUS_MSTOP(9, BIT(14) | BIT(15))), 390 + DEF_MOD("dsi_0_pllref_clk", CLK_QEXTAL, 14, 12, 7, 12, 391 + BUS_MSTOP(9, BIT(14) | BIT(15))), 392 + DEF_MOD("lcdc_0_clk_a", CLK_PLLDTY_ACPU_DIV2, 14, 13, 7, 13, 393 + BUS_MSTOP(10, BIT(1) | BIT(2) | BIT(3))), 394 + DEF_MOD("lcdc_0_clk_p", CLK_PLLDTY_DIV16, 14, 14, 7, 14, 395 + BUS_MSTOP(10, BIT(1) | BIT(2) | BIT(3))), 396 + DEF_MOD("lcdc_0_clk_d", CLK_PLLDSI_GEAR, 14, 15, 7, 15, 397 + BUS_MSTOP(10, BIT(1) | BIT(2) | BIT(3))), 433 398 DEF_MOD("gpu_0_clk", CLK_PLLGPU_GEAR, 15, 0, 7, 16, 434 399 BUS_MSTOP(3, BIT(4))), 435 400 DEF_MOD("gpu_0_axi_clk", CLK_PLLDTY_ACPU_DIV2, 15, 1, 7, 17, 436 401 BUS_MSTOP(3, BIT(4))), 437 402 DEF_MOD("gpu_0_ace_clk", CLK_PLLDTY_ACPU_DIV2, 15, 2, 7, 18, 438 403 BUS_MSTOP(3, BIT(4))), 404 + DEF_MOD("tsu_0_pclk", CLK_QEXTAL, 16, 9, 8, 9, 405 + BUS_MSTOP(5, BIT(2))), 406 + DEF_MOD("tsu_1_pclk", CLK_QEXTAL, 16, 10, 8, 10, 407 + BUS_MSTOP(2, BIT(15))), 439 408 }; 440 409 441 410 static const struct rzv2h_reset r9a09g057_resets[] __initconst = { ··· 488 401 DEF_RST(7, 6, 3, 7), /* WDT_1_RESET */ 489 402 DEF_RST(7, 7, 3, 8), /* WDT_2_RESET */ 490 403 DEF_RST(7, 8, 3, 9), /* WDT_3_RESET */ 404 + DEF_RST(7, 9, 3, 10), /* RTC_0_RST_RTC */ 405 + DEF_RST(7, 10, 3, 11), /* RTC_0_RST_RTC_V */ 491 406 DEF_RST(7, 11, 3, 12), /* RSPI_0_PRESETN */ 492 407 DEF_RST(7, 12, 3, 13), /* RSPI_0_TRESETN */ 493 408 DEF_RST(7, 13, 3, 14), /* RSPI_1_PRESETN */ ··· 513 424 DEF_RST(10, 7, 4, 24), /* SDHI_0_IXRST */ 514 425 DEF_RST(10, 8, 4, 25), /* SDHI_1_IXRST */ 515 426 DEF_RST(10, 9, 4, 26), /* SDHI_2_IXRST */ 427 + DEF_RST(10, 10, 4, 27), /* USB3_0_ARESETN */ 428 + DEF_RST(10, 11, 4, 28), /* USB3_1_ARESETN */ 516 429 DEF_RST(10, 12, 4, 29), /* USB2_0_U2H0_HRESETN */ 517 430 DEF_RST(10, 13, 4, 30), /* USB2_0_U2H1_HRESETN */ 518 431 DEF_RST(10, 14, 4, 31), /* USB2_0_U2P_EXL_SYSRST */ ··· 533 442 DEF_RST(12, 14, 5, 31), /* CRU_3_PRESETN */ 534 443 DEF_RST(12, 15, 6, 0), /* CRU_3_ARESETN */ 535 444 DEF_RST(13, 0, 6, 1), /* CRU_3_S_RESETN */ 445 + DEF_RST(13, 1, 6, 2), /* ISP_0_VIN_ARESETN */ 446 + DEF_RST(13, 2, 6, 3), /* ISP_0_REG_ARESETN */ 447 + DEF_RST(13, 3, 6, 4), /* ISP_0_ISP_SRESETN */ 448 + DEF_RST(13, 4, 6, 5), /* ISP_0_PRESETN */ 449 + DEF_RST(13, 7, 6, 8), /* DSI_0_PRESETN */ 450 + DEF_RST(13, 8, 6, 9), /* DSI_0_ARESETN */ 451 + DEF_RST(13, 12, 6, 13), /* LCDC_0_RESET_N */ 536 452 DEF_RST(13, 13, 6, 14), /* GPU_0_RESETN */ 537 453 DEF_RST(13, 14, 6, 15), /* GPU_0_AXI_RESETN */ 538 454 DEF_RST(13, 15, 6, 16), /* GPU_0_ACE_RESETN */ 455 + DEF_RST(15, 7, 7, 8), /* TSU_0_PRESETN */ 456 + DEF_RST(15, 8, 7, 9), /* TSU_1_PRESETN */ 539 457 }; 540 458 541 459 const struct rzv2h_cpg_info r9a09g057_cpg_info __initconst = {
+41 -16
drivers/clk/renesas/r9a09g077-cpg.c
··· 46 46 #define DIVCA55C2 CONF_PACK(SCKCR2, 10, 1) 47 47 #define DIVCA55C3 CONF_PACK(SCKCR2, 11, 1) 48 48 #define DIVCA55S CONF_PACK(SCKCR2, 12, 1) 49 + #define DIVSPI3ASYNC CONF_PACK(SCKCR2, 16, 2) 49 50 #define DIVSCI5ASYNC CONF_PACK(SCKCR2, 18, 2) 50 51 52 + #define DIVSPI0ASYNC CONF_PACK(SCKCR3, 0, 2) 53 + #define DIVSPI1ASYNC CONF_PACK(SCKCR3, 2, 2) 54 + #define DIVSPI2ASYNC CONF_PACK(SCKCR3, 4, 2) 51 55 #define DIVSCI0ASYNC CONF_PACK(SCKCR3, 6, 2) 52 56 #define DIVSCI1ASYNC CONF_PACK(SCKCR3, 8, 2) 53 57 #define DIVSCI2ASYNC CONF_PACK(SCKCR3, 10, 2) ··· 59 55 #define DIVSCI4ASYNC CONF_PACK(SCKCR3, 14, 2) 60 56 61 57 #define SEL_PLL CONF_PACK(SCKCR, 22, 1) 62 - 63 58 64 59 enum rzt2h_clk_types { 65 60 CLK_TYPE_RZT2H_DIV = CLK_TYPE_CUSTOM, /* Clock with divider */ ··· 97 94 CLK_SCI3ASYNC, 98 95 CLK_SCI4ASYNC, 99 96 CLK_SCI5ASYNC, 97 + CLK_SPI0ASYNC, 98 + CLK_SPI1ASYNC, 99 + CLK_SPI2ASYNC, 100 + CLK_SPI3ASYNC, 100 101 101 102 /* Module Clocks */ 102 103 MOD_CLK_BASE, ··· 161 154 DEF_DIV(".sci5async", CLK_SCI5ASYNC, CLK_PLL4D1, DIVSCI5ASYNC, 162 155 dtable_24_25_30_32), 163 156 157 + DEF_DIV(".spi0async", CLK_SPI0ASYNC, CLK_PLL4D1, DIVSPI0ASYNC, 158 + dtable_24_25_30_32), 159 + DEF_DIV(".spi1async", CLK_SPI1ASYNC, CLK_PLL4D1, DIVSPI1ASYNC, 160 + dtable_24_25_30_32), 161 + DEF_DIV(".spi2async", CLK_SPI2ASYNC, CLK_PLL4D1, DIVSPI2ASYNC, 162 + dtable_24_25_30_32), 163 + DEF_DIV(".spi3async", CLK_SPI3ASYNC, CLK_PLL4D1, DIVSPI3ASYNC, 164 + dtable_24_25_30_32), 165 + 164 166 /* Core output clk */ 165 167 DEF_DIV("CA55C0", R9A09G077_CLK_CA55C0, CLK_SEL_CLK_PLL0, DIVCA55C0, 166 168 dtable_1_2), ··· 204 188 DEF_MOD("sci4fck", 12, CLK_SCI4ASYNC), 205 189 DEF_MOD("iic0", 100, R9A09G077_CLK_PCLKL), 206 190 DEF_MOD("iic1", 101, R9A09G077_CLK_PCLKL), 191 + DEF_MOD("spi0", 104, CLK_SPI0ASYNC), 192 + DEF_MOD("spi1", 105, CLK_SPI1ASYNC), 193 + DEF_MOD("spi2", 106, CLK_SPI2ASYNC), 194 + DEF_MOD("adc0", 206, R9A09G077_CLK_PCLKH), 195 + DEF_MOD("adc1", 207, R9A09G077_CLK_PCLKH), 196 + DEF_MOD("adc2", 225, R9A09G077_CLK_PCLKM), 197 + DEF_MOD("tsu", 307, R9A09G077_CLK_PCLKL), 207 198 DEF_MOD("gmac0", 400, R9A09G077_CLK_PCLKM), 208 199 DEF_MOD("ethsw", 401, R9A09G077_CLK_PCLKM), 209 200 DEF_MOD("ethss", 403, R9A09G077_CLK_PCLKM), ··· 219 196 DEF_MOD("gmac2", 417, R9A09G077_CLK_PCLKAM), 220 197 DEF_MOD("sci5fck", 600, CLK_SCI5ASYNC), 221 198 DEF_MOD("iic2", 601, R9A09G077_CLK_PCLKL), 199 + DEF_MOD("spi3", 602, CLK_SPI3ASYNC), 222 200 DEF_MOD("sdhi0", 1212, R9A09G077_CLK_PCLKAM), 223 201 DEF_MOD("sdhi1", 1213, R9A09G077_CLK_PCLKAM), 224 202 }; ··· 240 216 parent_name = __clk_get_name(parent); 241 217 242 218 if (core->dtable) 243 - clk_hw = clk_hw_register_divider_table(dev, core->name, 244 - parent_name, 0, 245 - addr, 246 - GET_SHIFT(core->conf), 247 - GET_WIDTH(core->conf), 248 - core->flag, 249 - core->dtable, 250 - &pub->rmw_lock); 219 + clk_hw = devm_clk_hw_register_divider_table(dev, core->name, 220 + parent_name, 221 + CLK_SET_RATE_PARENT, 222 + addr, 223 + GET_SHIFT(core->conf), 224 + GET_WIDTH(core->conf), 225 + core->flag, 226 + core->dtable, 227 + &pub->rmw_lock); 251 228 else 252 - clk_hw = clk_hw_register_divider(dev, core->name, 253 - parent_name, 0, 254 - addr, 255 - GET_SHIFT(core->conf), 256 - GET_WIDTH(core->conf), 257 - core->flag, &pub->rmw_lock); 229 + clk_hw = devm_clk_hw_register_divider(dev, core->name, 230 + parent_name, 231 + CLK_SET_RATE_PARENT, 232 + addr, 233 + GET_SHIFT(core->conf), 234 + GET_WIDTH(core->conf), 235 + core->flag, &pub->rmw_lock); 258 236 259 237 if (IS_ERR(clk_hw)) 260 238 return ERR_CAST(clk_hw); 261 239 262 240 return clk_hw->clk; 263 - 264 241 } 265 242 266 243 static struct clk * __init
+1 -1
drivers/clk/renesas/rcar-cpg-lib.c
··· 35 35 val |= set; 36 36 writel(val, reg); 37 37 spin_unlock_irqrestore(&cpg_lock, flags); 38 - }; 38 + } 39 39 40 40 static int cpg_simple_notifier_call(struct notifier_block *nb, 41 41 unsigned long action, void *data)
+7 -2
drivers/clk/renesas/rcar-gen4-cpg.c
··· 257 257 } 258 258 259 259 /* 260 - * Z0 Clock & Z1 Clock 260 + * Z0, Z1 and ZG Clock 261 261 */ 262 262 #define CPG_FRQCRB 0x00000804 263 263 #define CPG_FRQCRB_KICK BIT(31) ··· 389 389 390 390 if (offset < 32) { 391 391 zclk->reg = reg + CPG_FRQCRC0; 392 - } else { 392 + } else if (offset < 64) { 393 393 zclk->reg = reg + CPG_FRQCRC1; 394 394 offset -= 32; 395 + } else if (offset < 96) { 396 + zclk->reg = reg + CPG_FRQCRB; 397 + offset -= 64; 398 + } else { 399 + return ERR_PTR(-EINVAL); 395 400 } 396 401 zclk->kick_reg = reg + CPG_FRQCRB; 397 402 zclk->hw.init = &init;
+152 -35
drivers/clk/renesas/renesas-cpg-mssr.c
··· 40 40 #define WARN_DEBUG(x) do { } while (0) 41 41 #endif 42 42 43 + #define RZT2H_RESET_REG_READ_COUNT 7 44 + 43 45 /* 44 - * Module Standby and Software Reset register offets. 46 + * Module Standby and Software Reset register offsets. 45 47 * 46 48 * If the registers exist, these are valid for SH-Mobile, R-Mobile, 47 49 * R-Car Gen2, R-Car Gen3, and RZ/G1. ··· 137 135 0x2C20, 0x2C24, 0x2C28, 0x2C2C, 0x2C30, 0x2C34, 0x2C38, 0x2C3C, 138 136 0x2C40, 0x2C44, 0x2C48, 0x2C4C, 0x2C50, 0x2C54, 0x2C58, 0x2C5C, 139 137 0x2C60, 0x2C64, 0x2C68, 0x2C6C, 0x2C70, 0x2C74, 138 + }; 139 + 140 + static const u16 mrcr_for_rzt2h[] = { 141 + 0x240, /* MRCTLA */ 142 + 0x244, /* Reserved */ 143 + 0x248, /* Reserved */ 144 + 0x24C, /* Reserved */ 145 + 0x250, /* MRCTLE */ 146 + 0x254, /* Reserved */ 147 + 0x258, /* Reserved */ 148 + 0x25C, /* Reserved */ 149 + 0x260, /* MRCTLI */ 150 + 0x264, /* Reserved */ 151 + 0x268, /* Reserved */ 152 + 0x26C, /* Reserved */ 153 + 0x270, /* MRCTLM */ 140 154 }; 141 155 142 156 /* ··· 308 290 309 291 spin_unlock_irqrestore(&priv->pub.rmw_lock, flags); 310 292 311 - if (!enable || priv->reg_layout == CLK_REG_LAYOUT_RZ_A || 312 - priv->reg_layout == CLK_REG_LAYOUT_RZ_T2H) 293 + if (!enable || priv->reg_layout == CLK_REG_LAYOUT_RZ_A) 313 294 return 0; 295 + 296 + if (priv->reg_layout == CLK_REG_LAYOUT_RZ_T2H) { 297 + /* 298 + * For the RZ/T2H case, it is necessary to perform a read-back after 299 + * accessing the MSTPCRm register and to dummy-read any register of 300 + * the IP at least seven times. Instead of memory-mapping the IP 301 + * register, we simply add a delay after the read operation. 302 + */ 303 + cpg_rzt2h_mstp_read(hw, priv->control_regs[reg]); 304 + udelay(10); 305 + return 0; 306 + } 314 307 315 308 error = readl_poll_timeout_atomic(priv->pub.base0 + priv->status_regs[reg], 316 309 value, !(value & bitmask), 0, 10); ··· 480 451 break; 481 452 } 482 453 483 - if (IS_ERR_OR_NULL(clk)) 454 + if (IS_ERR(clk)) 484 455 goto fail; 485 456 486 457 dev_dbg(dev, "Core clock %pC at %lu Hz\n", clk, clk_get_rate(clk)); ··· 705 676 706 677 #define rcdev_to_priv(x) container_of(x, struct cpg_mssr_priv, rcdev) 707 678 708 - static int cpg_mssr_reset(struct reset_controller_dev *rcdev, 709 - unsigned long id) 679 + static int cpg_mssr_reset_operate(struct reset_controller_dev *rcdev, 680 + const char *func, bool set, unsigned long id) 710 681 { 711 682 struct cpg_mssr_priv *priv = rcdev_to_priv(rcdev); 712 683 unsigned int reg = id / 32; 713 684 unsigned int bit = id % 32; 685 + const u16 off = set ? priv->reset_regs[reg] : priv->reset_clear_regs[reg]; 714 686 u32 bitmask = BIT(bit); 715 687 716 - dev_dbg(priv->dev, "reset %u%02u\n", reg, bit); 688 + if (func) 689 + dev_dbg(priv->dev, "%s %u%02u\n", func, reg, bit); 717 690 718 - /* Reset module */ 719 - writel(bitmask, priv->pub.base0 + priv->reset_regs[reg]); 720 - 721 - /* Wait for at least one cycle of the RCLK clock (@ ca. 32 kHz) */ 722 - udelay(35); 723 - 724 - /* Release module from reset state */ 725 - writel(bitmask, priv->pub.base0 + priv->reset_clear_regs[reg]); 691 + writel(bitmask, priv->pub.base0 + off); 692 + readl(priv->pub.base0 + off); 693 + barrier_data(priv->pub.base0 + off); 726 694 727 695 return 0; 728 696 } 729 697 730 - static int cpg_mssr_assert(struct reset_controller_dev *rcdev, unsigned long id) 698 + static int cpg_mssr_reset(struct reset_controller_dev *rcdev, 699 + unsigned long id) 731 700 { 732 701 struct cpg_mssr_priv *priv = rcdev_to_priv(rcdev); 733 - unsigned int reg = id / 32; 734 - unsigned int bit = id % 32; 735 - u32 bitmask = BIT(bit); 736 702 737 - dev_dbg(priv->dev, "assert %u%02u\n", reg, bit); 703 + /* Reset module */ 704 + cpg_mssr_reset_operate(rcdev, "reset", true, id); 738 705 739 - writel(bitmask, priv->pub.base0 + priv->reset_regs[reg]); 740 - return 0; 706 + /* 707 + * On R-Car Gen4, delay after SRCR has been written is 1ms. 708 + * On older SoCs, delay after SRCR has been written is 35us 709 + * (one cycle of the RCLK clock @ ca. 32 kHz). 710 + */ 711 + if (priv->reg_layout == CLK_REG_LAYOUT_RCAR_GEN4) 712 + usleep_range(1000, 2000); 713 + else 714 + usleep_range(35, 1000); 715 + 716 + /* Release module from reset state */ 717 + return cpg_mssr_reset_operate(rcdev, NULL, false, id); 718 + } 719 + 720 + static int cpg_mssr_assert(struct reset_controller_dev *rcdev, unsigned long id) 721 + { 722 + return cpg_mssr_reset_operate(rcdev, "assert", true, id); 741 723 } 742 724 743 725 static int cpg_mssr_deassert(struct reset_controller_dev *rcdev, 744 726 unsigned long id) 745 727 { 746 - struct cpg_mssr_priv *priv = rcdev_to_priv(rcdev); 747 - unsigned int reg = id / 32; 748 - unsigned int bit = id % 32; 749 - u32 bitmask = BIT(bit); 750 - 751 - dev_dbg(priv->dev, "deassert %u%02u\n", reg, bit); 752 - 753 - writel(bitmask, priv->pub.base0 + priv->reset_clear_regs[reg]); 754 - return 0; 728 + return cpg_mssr_reset_operate(rcdev, "deassert", false, id); 755 729 } 756 730 757 731 static int cpg_mssr_status(struct reset_controller_dev *rcdev, ··· 768 736 return !!(readl(priv->pub.base0 + priv->reset_regs[reg]) & bitmask); 769 737 } 770 738 739 + static int cpg_mrcr_set_reset_state(struct reset_controller_dev *rcdev, 740 + unsigned long id, bool set) 741 + { 742 + struct cpg_mssr_priv *priv = rcdev_to_priv(rcdev); 743 + unsigned int reg = id / 32; 744 + unsigned int bit = id % 32; 745 + u32 bitmask = BIT(bit); 746 + void __iomem *reg_addr; 747 + unsigned long flags; 748 + unsigned int i; 749 + u32 val; 750 + 751 + dev_dbg(priv->dev, "%s %u%02u\n", set ? "assert" : "deassert", reg, bit); 752 + 753 + spin_lock_irqsave(&priv->pub.rmw_lock, flags); 754 + 755 + reg_addr = priv->pub.base0 + priv->reset_regs[reg]; 756 + /* Read current value and modify */ 757 + val = readl(reg_addr); 758 + if (set) 759 + val |= bitmask; 760 + else 761 + val &= ~bitmask; 762 + writel(val, reg_addr); 763 + 764 + /* 765 + * For secure processing after release from a module reset, one must 766 + * perform multiple dummy reads of the same register. 767 + */ 768 + for (i = 0; !set && i < RZT2H_RESET_REG_READ_COUNT; i++) 769 + readl(reg_addr); 770 + 771 + /* Verify the operation */ 772 + val = readl(reg_addr); 773 + if (set == !(bitmask & val)) { 774 + dev_err(priv->dev, "Reset register %u%02u operation failed\n", reg, bit); 775 + spin_unlock_irqrestore(&priv->pub.rmw_lock, flags); 776 + return -EIO; 777 + } 778 + 779 + spin_unlock_irqrestore(&priv->pub.rmw_lock, flags); 780 + 781 + return 0; 782 + } 783 + 784 + static int cpg_mrcr_reset(struct reset_controller_dev *rcdev, unsigned long id) 785 + { 786 + int ret; 787 + 788 + ret = cpg_mrcr_set_reset_state(rcdev, id, true); 789 + if (ret) 790 + return ret; 791 + 792 + return cpg_mrcr_set_reset_state(rcdev, id, false); 793 + } 794 + 795 + static int cpg_mrcr_assert(struct reset_controller_dev *rcdev, unsigned long id) 796 + { 797 + return cpg_mrcr_set_reset_state(rcdev, id, true); 798 + } 799 + 800 + static int cpg_mrcr_deassert(struct reset_controller_dev *rcdev, unsigned long id) 801 + { 802 + return cpg_mrcr_set_reset_state(rcdev, id, false); 803 + } 804 + 771 805 static const struct reset_control_ops cpg_mssr_reset_ops = { 772 806 .reset = cpg_mssr_reset, 773 807 .assert = cpg_mssr_assert, 774 808 .deassert = cpg_mssr_deassert, 809 + .status = cpg_mssr_status, 810 + }; 811 + 812 + static const struct reset_control_ops cpg_mrcr_reset_ops = { 813 + .reset = cpg_mrcr_reset, 814 + .assert = cpg_mrcr_assert, 815 + .deassert = cpg_mrcr_deassert, 775 816 .status = cpg_mssr_status, 776 817 }; 777 818 ··· 865 760 866 761 static int cpg_mssr_reset_controller_register(struct cpg_mssr_priv *priv) 867 762 { 868 - priv->rcdev.ops = &cpg_mssr_reset_ops; 763 + /* 764 + * RZ/T2H (and family) has the Module Reset Control Registers 765 + * which allows control resets of certain modules. 766 + * The number of resets is not equal to the number of module clocks. 767 + */ 768 + if (priv->reg_layout == CLK_REG_LAYOUT_RZ_T2H) { 769 + priv->rcdev.ops = &cpg_mrcr_reset_ops; 770 + priv->rcdev.nr_resets = ARRAY_SIZE(mrcr_for_rzt2h) * 32; 771 + } else { 772 + priv->rcdev.ops = &cpg_mssr_reset_ops; 773 + priv->rcdev.nr_resets = priv->num_mod_clks; 774 + } 775 + 869 776 priv->rcdev.of_node = priv->dev->of_node; 870 777 priv->rcdev.of_reset_n_cells = 1; 871 778 priv->rcdev.of_xlate = cpg_mssr_reset_xlate; 872 - priv->rcdev.nr_resets = priv->num_mod_clks; 779 + 873 780 return devm_reset_controller_register(priv->dev, &priv->rcdev); 874 781 } 875 782 ··· 1286 1169 priv->control_regs = stbcr; 1287 1170 } else if (priv->reg_layout == CLK_REG_LAYOUT_RZ_T2H) { 1288 1171 priv->control_regs = mstpcr_for_rzt2h; 1172 + priv->reset_regs = mrcr_for_rzt2h; 1289 1173 } else if (priv->reg_layout == CLK_REG_LAYOUT_RCAR_GEN4) { 1290 1174 priv->status_regs = mstpsr_for_gen4; 1291 1175 priv->control_regs = mstpcr_for_gen4; ··· 1383 1265 goto reserve_exit; 1384 1266 1385 1267 /* Reset Controller not supported for Standby Control SoCs */ 1386 - if (priv->reg_layout == CLK_REG_LAYOUT_RZ_A || 1387 - priv->reg_layout == CLK_REG_LAYOUT_RZ_T2H) 1268 + if (priv->reg_layout == CLK_REG_LAYOUT_RZ_A) 1388 1269 goto reserve_exit; 1389 1270 1390 1271 error = cpg_mssr_reset_controller_register(priv);
+1 -1
drivers/clk/renesas/rzg2l-cpg.c
··· 1177 1177 goto fail; 1178 1178 } 1179 1179 1180 - if (IS_ERR_OR_NULL(clk)) 1180 + if (IS_ERR(clk)) 1181 1181 goto fail; 1182 1182 1183 1183 dev_dbg(dev, "Core clock %pC at %lu Hz\n", clk, clk_get_rate(clk));
+506 -8
drivers/clk/renesas/rzv2h-cpg.c
··· 14 14 #include <linux/bitfield.h> 15 15 #include <linux/clk.h> 16 16 #include <linux/clk-provider.h> 17 + #include <linux/clk/renesas.h> 17 18 #include <linux/delay.h> 18 19 #include <linux/init.h> 19 20 #include <linux/iopoll.h> 21 + #include <linux/limits.h> 22 + #include <linux/math.h> 23 + #include <linux/math64.h> 24 + #include <linux/minmax.h> 20 25 #include <linux/mod_devicetable.h> 21 26 #include <linux/module.h> 22 27 #include <linux/of.h> ··· 31 26 #include <linux/refcount.h> 32 27 #include <linux/reset-controller.h> 33 28 #include <linux/string_choices.h> 29 + #include <linux/units.h> 34 30 35 31 #include <dt-bindings/clock/renesas-cpg-mssr.h> 36 32 ··· 53 47 54 48 #define CPG_PLL_STBY(x) ((x)) 55 49 #define CPG_PLL_STBY_RESETB BIT(0) 50 + #define CPG_PLL_STBY_SSC_EN BIT(2) 56 51 #define CPG_PLL_STBY_RESETB_WEN BIT(16) 52 + #define CPG_PLL_STBY_SSC_EN_WEN BIT(18) 57 53 #define CPG_PLL_CLK1(x) ((x) + 0x004) 58 - #define CPG_PLL_CLK1_KDIV(x) ((s16)FIELD_GET(GENMASK(31, 16), (x))) 59 - #define CPG_PLL_CLK1_MDIV(x) FIELD_GET(GENMASK(15, 6), (x)) 60 - #define CPG_PLL_CLK1_PDIV(x) FIELD_GET(GENMASK(5, 0), (x)) 54 + #define CPG_PLL_CLK1_KDIV GENMASK(31, 16) 55 + #define CPG_PLL_CLK1_MDIV GENMASK(15, 6) 56 + #define CPG_PLL_CLK1_PDIV GENMASK(5, 0) 61 57 #define CPG_PLL_CLK2(x) ((x) + 0x008) 62 - #define CPG_PLL_CLK2_SDIV(x) FIELD_GET(GENMASK(2, 0), (x)) 58 + #define CPG_PLL_CLK2_SDIV GENMASK(2, 0) 63 59 #define CPG_PLL_MON(x) ((x) + 0x010) 64 60 #define CPG_PLL_MON_RESETB BIT(0) 65 61 #define CPG_PLL_MON_LOCK BIT(4) ··· 72 64 ((base) + ((((index) * (16))) + (bit))) 73 65 74 66 #define CPG_CLKSTATUS0 (0x700) 67 + 68 + /* On RZ/G3E SoC we have two DSI PLLs */ 69 + #define MAX_CPG_DSI_PLL 2 70 + 71 + /** 72 + * struct rzv2h_pll_dsi_info - PLL DSI information, holds the limits and parameters 73 + * 74 + * @pll_dsi_limits: PLL DSI parameters limits 75 + * @pll_dsi_parameters: Calculated PLL DSI parameters 76 + * @req_pll_dsi_rate: Requested PLL DSI rate 77 + */ 78 + struct rzv2h_pll_dsi_info { 79 + const struct rzv2h_pll_limits *pll_dsi_limits; 80 + struct rzv2h_pll_div_pars pll_dsi_parameters; 81 + unsigned long req_pll_dsi_rate; 82 + }; 75 83 76 84 /** 77 85 * struct rzv2h_cpg_priv - Clock Pulse Generator Private Data ··· 104 80 * @ff_mod_status_ops: Fixed Factor Module Status Clock operations 105 81 * @mstop_count: Array of mstop values 106 82 * @rcdev: Reset controller entity 83 + * @pll_dsi_info: Array of PLL DSI information, holds the limits and parameters 107 84 */ 108 85 struct rzv2h_cpg_priv { 109 86 struct device *dev; ··· 123 98 atomic_t *mstop_count; 124 99 125 100 struct reset_controller_dev rcdev; 101 + 102 + struct rzv2h_pll_dsi_info pll_dsi_info[MAX_CPG_DSI_PLL]; 126 103 }; 127 104 128 105 #define rcdev_to_priv(x) container_of(x, struct rzv2h_cpg_priv, rcdev) ··· 195 168 #define to_rzv2h_ff_mod_status_clk(_hw) \ 196 169 container_of(_hw, struct rzv2h_ff_mod_status_clk, fix.hw) 197 170 171 + /** 172 + * struct rzv2h_plldsi_div_clk - PLL DSI DDIV clock 173 + * 174 + * @dtable: divider table 175 + * @priv: CPG private data 176 + * @hw: divider clk 177 + * @ddiv: divider configuration 178 + */ 179 + struct rzv2h_plldsi_div_clk { 180 + const struct clk_div_table *dtable; 181 + struct rzv2h_cpg_priv *priv; 182 + struct clk_hw hw; 183 + struct ddiv ddiv; 184 + }; 185 + 186 + #define to_plldsi_div_clk(_hw) \ 187 + container_of(_hw, struct rzv2h_plldsi_div_clk, hw) 188 + 189 + #define RZ_V2H_OSC_CLK_IN_MEGA (24 * MEGA) 190 + #define RZV2H_MAX_DIV_TABLES (16) 191 + 192 + /** 193 + * rzv2h_get_pll_pars - Finds the best combination of PLL parameters 194 + * for a given frequency. 195 + * 196 + * @limits: Pointer to the structure containing the limits for the PLL parameters 197 + * @pars: Pointer to the structure where the best calculated PLL parameters values 198 + * will be stored 199 + * @freq_millihz: Target output frequency in millihertz 200 + * 201 + * This function calculates the best set of PLL parameters (M, K, P, S) to achieve 202 + * the desired frequency. 203 + * There is no direct formula to calculate the PLL parameters, as it's an open 204 + * system of equations, therefore this function uses an iterative approach to 205 + * determine the best solution. The best solution is one that minimizes the error 206 + * (desired frequency - actual frequency). 207 + * 208 + * Return: true if a valid set of parameters values is found, false otherwise. 209 + */ 210 + bool rzv2h_get_pll_pars(const struct rzv2h_pll_limits *limits, 211 + struct rzv2h_pll_pars *pars, u64 freq_millihz) 212 + { 213 + u64 fout_min_millihz = mul_u32_u32(limits->fout.min, MILLI); 214 + u64 fout_max_millihz = mul_u32_u32(limits->fout.max, MILLI); 215 + struct rzv2h_pll_pars p, best; 216 + 217 + if (freq_millihz > fout_max_millihz || 218 + freq_millihz < fout_min_millihz) 219 + return false; 220 + 221 + /* Initialize best error to maximum possible value */ 222 + best.error_millihz = S64_MAX; 223 + 224 + for (p.p = limits->p.min; p.p <= limits->p.max; p.p++) { 225 + u32 fref = RZ_V2H_OSC_CLK_IN_MEGA / p.p; 226 + u16 divider; 227 + 228 + for (divider = 1 << limits->s.min, p.s = limits->s.min; 229 + p.s <= limits->s.max; p.s++, divider <<= 1) { 230 + for (p.m = limits->m.min; p.m <= limits->m.max; p.m++) { 231 + u64 output_m, output_k_range; 232 + s64 pll_k, output_k; 233 + u64 fvco, output; 234 + 235 + /* 236 + * The frequency generated by the PLL + divider 237 + * is calculated as follows: 238 + * 239 + * With: 240 + * Freq = Ffout = Ffvco / 2^(pll_s) 241 + * Ffvco = (pll_m + (pll_k / 65536)) * Ffref 242 + * Ffref = 24MHz / pll_p 243 + * 244 + * Freq can also be rewritten as: 245 + * Freq = Ffvco / 2^(pll_s) 246 + * = ((pll_m + (pll_k / 65536)) * Ffref) / 2^(pll_s) 247 + * = (pll_m * Ffref) / 2^(pll_s) + ((pll_k / 65536) * Ffref) / 2^(pll_s) 248 + * = output_m + output_k 249 + * 250 + * Every parameter has been determined at this 251 + * point, but pll_k. 252 + * 253 + * Considering that: 254 + * limits->k.min <= pll_k <= limits->k.max 255 + * Then: 256 + * -0.5 <= (pll_k / 65536) < 0.5 257 + * Therefore: 258 + * -Ffref / (2 * 2^(pll_s)) <= output_k < Ffref / (2 * 2^(pll_s)) 259 + */ 260 + 261 + /* Compute output M component (in mHz) */ 262 + output_m = DIV_ROUND_CLOSEST_ULL(mul_u32_u32(p.m, fref) * MILLI, 263 + divider); 264 + /* Compute range for output K (in mHz) */ 265 + output_k_range = DIV_ROUND_CLOSEST_ULL(mul_u32_u32(fref, MILLI), 266 + 2 * divider); 267 + /* 268 + * No point in continuing if we can't achieve 269 + * the desired frequency 270 + */ 271 + if (freq_millihz < (output_m - output_k_range) || 272 + freq_millihz >= (output_m + output_k_range)) { 273 + continue; 274 + } 275 + 276 + /* 277 + * Compute the K component 278 + * 279 + * Since: 280 + * Freq = output_m + output_k 281 + * Then: 282 + * output_k = Freq - output_m 283 + * = ((pll_k / 65536) * Ffref) / 2^(pll_s) 284 + * Therefore: 285 + * pll_k = (output_k * 65536 * 2^(pll_s)) / Ffref 286 + */ 287 + output_k = freq_millihz - output_m; 288 + pll_k = div_s64(output_k * 65536ULL * divider, 289 + fref); 290 + pll_k = DIV_S64_ROUND_CLOSEST(pll_k, MILLI); 291 + 292 + /* Validate K value within allowed limits */ 293 + if (pll_k < limits->k.min || 294 + pll_k > limits->k.max) 295 + continue; 296 + 297 + p.k = pll_k; 298 + 299 + /* Compute (Ffvco * 65536) */ 300 + fvco = mul_u32_u32(p.m * 65536 + p.k, fref); 301 + if (fvco < mul_u32_u32(limits->fvco.min, 65536) || 302 + fvco > mul_u32_u32(limits->fvco.max, 65536)) 303 + continue; 304 + 305 + /* PLL_M component of (output * 65536 * PLL_P) */ 306 + output = mul_u32_u32(p.m * 65536, RZ_V2H_OSC_CLK_IN_MEGA); 307 + /* PLL_K component of (output * 65536 * PLL_P) */ 308 + output += p.k * RZ_V2H_OSC_CLK_IN_MEGA; 309 + /* Make it in mHz */ 310 + output *= MILLI; 311 + output = DIV_U64_ROUND_CLOSEST(output, 65536 * p.p * divider); 312 + 313 + /* Check output frequency against limits */ 314 + if (output < fout_min_millihz || 315 + output > fout_max_millihz) 316 + continue; 317 + 318 + p.error_millihz = freq_millihz - output; 319 + p.freq_millihz = output; 320 + 321 + /* If an exact match is found, return immediately */ 322 + if (p.error_millihz == 0) { 323 + *pars = p; 324 + return true; 325 + } 326 + 327 + /* Update best match if error is smaller */ 328 + if (abs(best.error_millihz) > abs(p.error_millihz)) 329 + best = p; 330 + } 331 + } 332 + } 333 + 334 + /* If no valid parameters were found, return false */ 335 + if (best.error_millihz == S64_MAX) 336 + return false; 337 + 338 + *pars = best; 339 + return true; 340 + } 341 + EXPORT_SYMBOL_NS_GPL(rzv2h_get_pll_pars, "RZV2H_CPG"); 342 + 343 + /* 344 + * rzv2h_get_pll_divs_pars - Finds the best combination of PLL parameters 345 + * and divider value for a given frequency. 346 + * 347 + * @limits: Pointer to the structure containing the limits for the PLL parameters 348 + * @pars: Pointer to the structure where the best calculated PLL parameters and 349 + * divider values will be stored 350 + * @table: Pointer to the array of valid divider values 351 + * @table_size: Size of the divider values array 352 + * @freq_millihz: Target output frequency in millihertz 353 + * 354 + * This function calculates the best set of PLL parameters (M, K, P, S) and divider 355 + * value to achieve the desired frequency. See rzv2h_get_pll_pars() for more details 356 + * on how the PLL parameters are calculated. 357 + * 358 + * freq_millihz is the desired frequency generated by the PLL followed by a 359 + * a gear. 360 + */ 361 + bool rzv2h_get_pll_divs_pars(const struct rzv2h_pll_limits *limits, 362 + struct rzv2h_pll_div_pars *pars, 363 + const u8 *table, u8 table_size, u64 freq_millihz) 364 + { 365 + struct rzv2h_pll_div_pars p, best; 366 + 367 + best.div.error_millihz = S64_MAX; 368 + p.div.error_millihz = S64_MAX; 369 + for (unsigned int i = 0; i < table_size; i++) { 370 + if (!rzv2h_get_pll_pars(limits, &p.pll, freq_millihz * table[i])) 371 + continue; 372 + 373 + p.div.divider_value = table[i]; 374 + p.div.freq_millihz = DIV_U64_ROUND_CLOSEST(p.pll.freq_millihz, table[i]); 375 + p.div.error_millihz = freq_millihz - p.div.freq_millihz; 376 + 377 + if (p.div.error_millihz == 0) { 378 + *pars = p; 379 + return true; 380 + } 381 + 382 + if (abs(best.div.error_millihz) > abs(p.div.error_millihz)) 383 + best = p; 384 + } 385 + 386 + if (best.div.error_millihz == S64_MAX) 387 + return false; 388 + 389 + *pars = best; 390 + return true; 391 + } 392 + EXPORT_SYMBOL_NS_GPL(rzv2h_get_pll_divs_pars, "RZV2H_CPG"); 393 + 394 + static unsigned long rzv2h_cpg_plldsi_div_recalc_rate(struct clk_hw *hw, 395 + unsigned long parent_rate) 396 + { 397 + struct rzv2h_plldsi_div_clk *dsi_div = to_plldsi_div_clk(hw); 398 + struct rzv2h_cpg_priv *priv = dsi_div->priv; 399 + struct ddiv ddiv = dsi_div->ddiv; 400 + u32 div; 401 + 402 + div = readl(priv->base + ddiv.offset); 403 + div >>= ddiv.shift; 404 + div &= clk_div_mask(ddiv.width); 405 + div = dsi_div->dtable[div].div; 406 + 407 + return DIV_ROUND_CLOSEST_ULL(parent_rate, div); 408 + } 409 + 410 + static int rzv2h_cpg_plldsi_div_determine_rate(struct clk_hw *hw, 411 + struct clk_rate_request *req) 412 + { 413 + struct rzv2h_plldsi_div_clk *dsi_div = to_plldsi_div_clk(hw); 414 + struct pll_clk *pll_clk = to_pll(clk_hw_get_parent(hw)); 415 + struct rzv2h_cpg_priv *priv = dsi_div->priv; 416 + u8 table[RZV2H_MAX_DIV_TABLES] = { 0 }; 417 + struct rzv2h_pll_div_pars *dsi_params; 418 + struct rzv2h_pll_dsi_info *dsi_info; 419 + const struct clk_div_table *div; 420 + unsigned int i = 0; 421 + u64 rate_millihz; 422 + 423 + dsi_info = &priv->pll_dsi_info[pll_clk->pll.instance]; 424 + dsi_params = &dsi_info->pll_dsi_parameters; 425 + 426 + rate_millihz = mul_u32_u32(req->rate, MILLI); 427 + if (rate_millihz == dsi_params->div.error_millihz + dsi_params->div.freq_millihz) 428 + goto exit_determine_rate; 429 + 430 + for (div = dsi_div->dtable; div->div; div++) { 431 + if (i >= RZV2H_MAX_DIV_TABLES) 432 + return -EINVAL; 433 + table[i++] = div->div; 434 + } 435 + 436 + if (!rzv2h_get_pll_divs_pars(dsi_info->pll_dsi_limits, dsi_params, table, i, 437 + rate_millihz)) { 438 + dev_err(priv->dev, "failed to determine rate for req->rate: %lu\n", 439 + req->rate); 440 + return -EINVAL; 441 + } 442 + 443 + exit_determine_rate: 444 + req->rate = DIV_ROUND_CLOSEST_ULL(dsi_params->div.freq_millihz, MILLI); 445 + req->best_parent_rate = req->rate * dsi_params->div.divider_value; 446 + dsi_info->req_pll_dsi_rate = req->best_parent_rate; 447 + 448 + return 0; 449 + } 450 + 451 + static int rzv2h_cpg_plldsi_div_set_rate(struct clk_hw *hw, 452 + unsigned long rate, 453 + unsigned long parent_rate) 454 + { 455 + struct rzv2h_plldsi_div_clk *dsi_div = to_plldsi_div_clk(hw); 456 + struct pll_clk *pll_clk = to_pll(clk_hw_get_parent(hw)); 457 + struct rzv2h_cpg_priv *priv = dsi_div->priv; 458 + struct rzv2h_pll_div_pars *dsi_params; 459 + struct rzv2h_pll_dsi_info *dsi_info; 460 + struct ddiv ddiv = dsi_div->ddiv; 461 + const struct clk_div_table *clkt; 462 + bool divider_found = false; 463 + u32 val, shift; 464 + 465 + dsi_info = &priv->pll_dsi_info[pll_clk->pll.instance]; 466 + dsi_params = &dsi_info->pll_dsi_parameters; 467 + 468 + for (clkt = dsi_div->dtable; clkt->div; clkt++) { 469 + if (clkt->div == dsi_params->div.divider_value) { 470 + divider_found = true; 471 + break; 472 + } 473 + } 474 + 475 + if (!divider_found) 476 + return -EINVAL; 477 + 478 + shift = ddiv.shift; 479 + val = readl(priv->base + ddiv.offset) | DDIV_DIVCTL_WEN(shift); 480 + val &= ~(clk_div_mask(ddiv.width) << shift); 481 + val |= clkt->val << shift; 482 + writel(val, priv->base + ddiv.offset); 483 + 484 + return 0; 485 + } 486 + 487 + static const struct clk_ops rzv2h_cpg_plldsi_div_ops = { 488 + .recalc_rate = rzv2h_cpg_plldsi_div_recalc_rate, 489 + .determine_rate = rzv2h_cpg_plldsi_div_determine_rate, 490 + .set_rate = rzv2h_cpg_plldsi_div_set_rate, 491 + }; 492 + 493 + static struct clk * __init 494 + rzv2h_cpg_plldsi_div_clk_register(const struct cpg_core_clk *core, 495 + struct rzv2h_cpg_priv *priv) 496 + { 497 + struct rzv2h_plldsi_div_clk *clk_hw_data; 498 + struct clk **clks = priv->clks; 499 + struct clk_init_data init; 500 + const struct clk *parent; 501 + const char *parent_name; 502 + struct clk_hw *clk_hw; 503 + int ret; 504 + 505 + parent = clks[core->parent]; 506 + if (IS_ERR(parent)) 507 + return ERR_CAST(parent); 508 + 509 + clk_hw_data = devm_kzalloc(priv->dev, sizeof(*clk_hw_data), GFP_KERNEL); 510 + if (!clk_hw_data) 511 + return ERR_PTR(-ENOMEM); 512 + 513 + clk_hw_data->priv = priv; 514 + clk_hw_data->ddiv = core->cfg.ddiv; 515 + clk_hw_data->dtable = core->dtable; 516 + 517 + parent_name = __clk_get_name(parent); 518 + init.name = core->name; 519 + init.ops = &rzv2h_cpg_plldsi_div_ops; 520 + init.flags = core->flag; 521 + init.parent_names = &parent_name; 522 + init.num_parents = 1; 523 + 524 + clk_hw = &clk_hw_data->hw; 525 + clk_hw->init = &init; 526 + 527 + ret = devm_clk_hw_register(priv->dev, clk_hw); 528 + if (ret) 529 + return ERR_PTR(ret); 530 + 531 + return clk_hw->clk; 532 + } 533 + 534 + static int rzv2h_cpg_plldsi_determine_rate(struct clk_hw *hw, 535 + struct clk_rate_request *req) 536 + { 537 + struct pll_clk *pll_clk = to_pll(hw); 538 + struct rzv2h_cpg_priv *priv = pll_clk->priv; 539 + struct rzv2h_pll_dsi_info *dsi_info; 540 + u64 rate_millihz; 541 + 542 + dsi_info = &priv->pll_dsi_info[pll_clk->pll.instance]; 543 + /* check if the divider has already invoked the algorithm */ 544 + if (req->rate == dsi_info->req_pll_dsi_rate) 545 + return 0; 546 + 547 + /* If the req->rate doesn't match we do the calculation assuming there is no divider */ 548 + rate_millihz = mul_u32_u32(req->rate, MILLI); 549 + if (!rzv2h_get_pll_pars(dsi_info->pll_dsi_limits, 550 + &dsi_info->pll_dsi_parameters.pll, rate_millihz)) { 551 + dev_err(priv->dev, 552 + "failed to determine rate for req->rate: %lu\n", 553 + req->rate); 554 + return -EINVAL; 555 + } 556 + 557 + req->rate = DIV_ROUND_CLOSEST_ULL(dsi_info->pll_dsi_parameters.pll.freq_millihz, MILLI); 558 + dsi_info->req_pll_dsi_rate = req->rate; 559 + 560 + return 0; 561 + } 562 + 563 + static int rzv2h_cpg_pll_set_rate(struct pll_clk *pll_clk, 564 + struct rzv2h_pll_pars *params, 565 + bool ssc_disable) 566 + { 567 + struct rzv2h_cpg_priv *priv = pll_clk->priv; 568 + u16 offset = pll_clk->pll.offset; 569 + u32 val; 570 + int ret; 571 + 572 + /* Put PLL into standby mode */ 573 + writel(CPG_PLL_STBY_RESETB_WEN, priv->base + CPG_PLL_STBY(offset)); 574 + ret = readl_poll_timeout_atomic(priv->base + CPG_PLL_MON(offset), 575 + val, !(val & CPG_PLL_MON_LOCK), 576 + 100, 2000); 577 + if (ret) { 578 + dev_err(priv->dev, "Failed to put PLLDSI into standby mode"); 579 + return ret; 580 + } 581 + 582 + /* Output clock setting 1 */ 583 + writel(FIELD_PREP(CPG_PLL_CLK1_KDIV, (u16)params->k) | 584 + FIELD_PREP(CPG_PLL_CLK1_MDIV, params->m) | 585 + FIELD_PREP(CPG_PLL_CLK1_PDIV, params->p), 586 + priv->base + CPG_PLL_CLK1(offset)); 587 + 588 + /* Output clock setting 2 */ 589 + val = readl(priv->base + CPG_PLL_CLK2(offset)); 590 + writel((val & ~CPG_PLL_CLK2_SDIV) | FIELD_PREP(CPG_PLL_CLK2_SDIV, params->s), 591 + priv->base + CPG_PLL_CLK2(offset)); 592 + 593 + /* Put PLL to normal mode */ 594 + if (ssc_disable) 595 + val = CPG_PLL_STBY_SSC_EN_WEN; 596 + else 597 + val = CPG_PLL_STBY_SSC_EN_WEN | CPG_PLL_STBY_SSC_EN; 598 + writel(val | CPG_PLL_STBY_RESETB_WEN | CPG_PLL_STBY_RESETB, 599 + priv->base + CPG_PLL_STBY(offset)); 600 + 601 + /* PLL normal mode transition, output clock stability check */ 602 + ret = readl_poll_timeout_atomic(priv->base + CPG_PLL_MON(offset), 603 + val, (val & CPG_PLL_MON_LOCK), 604 + 100, 2000); 605 + if (ret) { 606 + dev_err(priv->dev, "Failed to put PLLDSI into normal mode"); 607 + return ret; 608 + } 609 + 610 + return 0; 611 + } 612 + 613 + static int rzv2h_cpg_plldsi_set_rate(struct clk_hw *hw, unsigned long rate, 614 + unsigned long parent_rate) 615 + { 616 + struct pll_clk *pll_clk = to_pll(hw); 617 + struct rzv2h_pll_dsi_info *dsi_info; 618 + struct rzv2h_cpg_priv *priv = pll_clk->priv; 619 + 620 + dsi_info = &priv->pll_dsi_info[pll_clk->pll.instance]; 621 + 622 + return rzv2h_cpg_pll_set_rate(pll_clk, &dsi_info->pll_dsi_parameters.pll, true); 623 + } 624 + 198 625 static int rzv2h_cpg_pll_clk_is_enabled(struct clk_hw *hw) 199 626 { 200 627 struct pll_clk *pll_clk = to_pll(hw); ··· 712 231 clk1 = readl(priv->base + CPG_PLL_CLK1(pll.offset)); 713 232 clk2 = readl(priv->base + CPG_PLL_CLK2(pll.offset)); 714 233 715 - rate = mul_u64_u32_shr(parent_rate, (CPG_PLL_CLK1_MDIV(clk1) << 16) + 716 - CPG_PLL_CLK1_KDIV(clk1), 16 + CPG_PLL_CLK2_SDIV(clk2)); 234 + rate = mul_u64_u32_shr(parent_rate, (FIELD_GET(CPG_PLL_CLK1_MDIV, clk1) << 16) + 235 + (s16)FIELD_GET(CPG_PLL_CLK1_KDIV, clk1), 236 + 16 + FIELD_GET(CPG_PLL_CLK2_SDIV, clk2)); 717 237 718 - return DIV_ROUND_CLOSEST_ULL(rate, CPG_PLL_CLK1_PDIV(clk1)); 238 + return DIV_ROUND_CLOSEST_ULL(rate, FIELD_GET(CPG_PLL_CLK1_PDIV, clk1)); 719 239 } 240 + 241 + static const struct clk_ops rzv2h_cpg_plldsi_ops = { 242 + .recalc_rate = rzv2h_cpg_pll_clk_recalc_rate, 243 + .determine_rate = rzv2h_cpg_plldsi_determine_rate, 244 + .set_rate = rzv2h_cpg_plldsi_set_rate, 245 + }; 720 246 721 247 static const struct clk_ops rzv2h_cpg_pll_ops = { 722 248 .is_enabled = rzv2h_cpg_pll_clk_is_enabled, ··· 750 262 pll_clk = devm_kzalloc(dev, sizeof(*pll_clk), GFP_KERNEL); 751 263 if (!pll_clk) 752 264 return ERR_PTR(-ENOMEM); 265 + 266 + if (core->type == CLK_TYPE_PLLDSI) 267 + priv->pll_dsi_info[core->cfg.pll.instance].pll_dsi_limits = 268 + core->cfg.pll.limits; 753 269 754 270 parent_name = __clk_get_name(parent); 755 271 init.name = core->name; ··· 1079 587 case CLK_TYPE_SMUX: 1080 588 clk = rzv2h_cpg_mux_clk_register(core, priv); 1081 589 break; 590 + case CLK_TYPE_PLLDSI: 591 + clk = rzv2h_cpg_pll_clk_register(core, priv, &rzv2h_cpg_plldsi_ops); 592 + break; 593 + case CLK_TYPE_PLLDSI_DIV: 594 + clk = rzv2h_cpg_plldsi_div_clk_register(core, priv); 595 + break; 1082 596 default: 1083 597 goto fail; 1084 598 } 1085 599 1086 - if (IS_ERR_OR_NULL(clk)) 600 + if (IS_ERR(clk)) 1087 601 goto fail; 1088 602 1089 603 dev_dbg(dev, "Core clock %pC at %lu Hz\n", clk, clk_get_rate(clk));
+27 -4
drivers/clk/renesas/rzv2h-cpg.h
··· 16 16 * 17 17 * @offset: STBY register offset 18 18 * @has_clkn: Flag to indicate if CLK1/2 are accessible or not 19 + * @instance: PLL instance number 19 20 */ 20 21 struct pll { 21 22 unsigned int offset:9; 22 23 unsigned int has_clkn:1; 24 + unsigned int instance:2; 25 + const struct rzv2h_pll_limits *limits; 23 26 }; 24 27 25 - #define PLL_PACK(_offset, _has_clkn) \ 28 + #define PLL_PACK_LIMITS(_offset, _has_clkn, _instance, _limits) \ 26 29 ((struct pll){ \ 27 30 .offset = _offset, \ 28 - .has_clkn = _has_clkn \ 31 + .has_clkn = _has_clkn, \ 32 + .instance = _instance, \ 33 + .limits = _limits \ 29 34 }) 30 35 31 - #define PLLCA55 PLL_PACK(0x60, 1) 32 - #define PLLGPU PLL_PACK(0x120, 1) 36 + #define PLL_PACK(_offset, _has_clkn, _instance) \ 37 + PLL_PACK_LIMITS(_offset, _has_clkn, _instance, NULL) 38 + 39 + #define PLLCA55 PLL_PACK(0x60, 1, 0) 40 + #define PLLGPU PLL_PACK(0x120, 1, 0) 33 41 34 42 /** 35 43 * struct ddiv - Structure for dynamic switching divider ··· 123 115 #define CPG_SSEL1 (0x304) 124 116 #define CPG_CDDIV0 (0x400) 125 117 #define CPG_CDDIV1 (0x404) 118 + #define CPG_CDDIV2 (0x408) 126 119 #define CPG_CDDIV3 (0x40C) 127 120 #define CPG_CDDIV4 (0x410) 128 121 #define CPG_CSDIV0 (0x500) 122 + #define CPG_CSDIV1 (0x504) 129 123 130 124 #define CDDIV0_DIVCTL1 DDIV_PACK(CPG_CDDIV0, 4, 3, 1) 131 125 #define CDDIV0_DIVCTL2 DDIV_PACK(CPG_CDDIV0, 8, 3, 2) ··· 135 125 #define CDDIV1_DIVCTL1 DDIV_PACK(CPG_CDDIV1, 4, 2, 5) 136 126 #define CDDIV1_DIVCTL2 DDIV_PACK(CPG_CDDIV1, 8, 2, 6) 137 127 #define CDDIV1_DIVCTL3 DDIV_PACK(CPG_CDDIV1, 12, 2, 7) 128 + #define CDDIV2_DIVCTL3 DDIV_PACK(CPG_CDDIV2, 12, 3, 11) 138 129 #define CDDIV3_DIVCTL1 DDIV_PACK(CPG_CDDIV3, 4, 3, 13) 139 130 #define CDDIV3_DIVCTL2 DDIV_PACK(CPG_CDDIV3, 8, 3, 14) 140 131 #define CDDIV3_DIVCTL3 DDIV_PACK(CPG_CDDIV3, 12, 1, 15) ··· 145 134 146 135 #define CSDIV0_DIVCTL0 DDIV_PACK(CPG_CSDIV0, 0, 2, CSDIV_NO_MON) 147 136 #define CSDIV0_DIVCTL1 DDIV_PACK(CPG_CSDIV0, 4, 2, CSDIV_NO_MON) 137 + #define CSDIV0_DIVCTL2 DDIV_PACK(CPG_CSDIV0, 8, 2, CSDIV_NO_MON) 148 138 #define CSDIV0_DIVCTL3 DDIV_PACK_NO_RMW(CPG_CSDIV0, 12, 2, CSDIV_NO_MON) 139 + #define CSDIV1_DIVCTL2 DDIV_PACK(CPG_CSDIV1, 8, 4, CSDIV_NO_MON) 149 140 150 141 #define SSEL0_SELCTL2 SMUX_PACK(CPG_SSEL0, 8, 1) 151 142 #define SSEL0_SELCTL3 SMUX_PACK(CPG_SSEL0, 12, 1) ··· 201 188 CLK_TYPE_PLL, 202 189 CLK_TYPE_DDIV, /* Dynamic Switching Divider */ 203 190 CLK_TYPE_SMUX, /* Static Mux */ 191 + CLK_TYPE_PLLDSI, /* PLLDSI */ 192 + CLK_TYPE_PLLDSI_DIV, /* PLLDSI divider */ 204 193 }; 205 194 206 195 #define DEF_TYPE(_name, _id, _type...) \ ··· 233 218 .num_parents = ARRAY_SIZE(_parent_names), \ 234 219 .flag = CLK_SET_RATE_PARENT, \ 235 220 .mux_flags = CLK_MUX_HIWORD_MASK) 221 + #define DEF_PLLDSI(_name, _id, _parent, _pll_packed) \ 222 + DEF_TYPE(_name, _id, CLK_TYPE_PLLDSI, .parent = _parent, .cfg.pll = _pll_packed) 223 + #define DEF_PLLDSI_DIV(_name, _id, _parent, _ddiv_packed, _dtable) \ 224 + DEF_TYPE(_name, _id, CLK_TYPE_PLLDSI_DIV, \ 225 + .cfg.ddiv = _ddiv_packed, \ 226 + .dtable = _dtable, \ 227 + .parent = _parent, \ 228 + .flag = CLK_SET_RATE_PARENT) 236 229 237 230 /** 238 231 * struct rzv2h_mod_clk - Module Clocks definitions
+10
drivers/clk/samsung/Kconfig
··· 95 95 status of the certains clocks from SoC, but it could also be tied to 96 96 other devices as an input clock. 97 97 98 + config EXYNOS_ACPM_CLK 99 + tristate "Clock driver controlled via ACPM interface" 100 + depends on EXYNOS_ACPM_PROTOCOL || (COMPILE_TEST && !EXYNOS_ACPM_PROTOCOL) 101 + help 102 + This driver provides support for clocks that are controlled by 103 + firmware that implements the ACPM interface. 104 + 105 + This driver uses the ACPM interface to interact with the firmware 106 + providing all the clock controlls. 107 + 98 108 config TESLA_FSD_COMMON_CLK 99 109 bool "Tesla FSD clock controller support" if COMPILE_TEST 100 110 depends on COMMON_CLK_SAMSUNG
+1
drivers/clk/samsung/Makefile
··· 28 28 obj-$(CONFIG_EXYNOS_ARM64_COMMON_CLK) += clk-exynosautov9.o 29 29 obj-$(CONFIG_EXYNOS_ARM64_COMMON_CLK) += clk-exynosautov920.o 30 30 obj-$(CONFIG_EXYNOS_ARM64_COMMON_CLK) += clk-gs101.o 31 + obj-$(CONFIG_EXYNOS_ACPM_CLK) += clk-acpm.o 31 32 obj-$(CONFIG_S3C64XX_COMMON_CLK) += clk-s3c64xx.o 32 33 obj-$(CONFIG_S5PV210_COMMON_CLK) += clk-s5pv210.o clk-s5pv210-audss.o 33 34 obj-$(CONFIG_TESLA_FSD_COMMON_CLK) += clk-fsd.o
+185
drivers/clk/samsung/clk-acpm.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Samsung Exynos ACPM protocol based clock driver. 4 + * 5 + * Copyright 2025 Linaro Ltd. 6 + */ 7 + 8 + #include <linux/array_size.h> 9 + #include <linux/clk-provider.h> 10 + #include <linux/container_of.h> 11 + #include <linux/device/devres.h> 12 + #include <linux/device.h> 13 + #include <linux/err.h> 14 + #include <linux/firmware/samsung/exynos-acpm-protocol.h> 15 + #include <linux/module.h> 16 + #include <linux/platform_device.h> 17 + #include <linux/types.h> 18 + 19 + struct acpm_clk { 20 + u32 id; 21 + struct clk_hw hw; 22 + unsigned int mbox_chan_id; 23 + const struct acpm_handle *handle; 24 + }; 25 + 26 + struct acpm_clk_variant { 27 + const char *name; 28 + }; 29 + 30 + struct acpm_clk_driver_data { 31 + const struct acpm_clk_variant *clks; 32 + unsigned int nr_clks; 33 + unsigned int mbox_chan_id; 34 + }; 35 + 36 + #define to_acpm_clk(clk) container_of(clk, struct acpm_clk, hw) 37 + 38 + #define ACPM_CLK(cname) \ 39 + { \ 40 + .name = cname, \ 41 + } 42 + 43 + static const struct acpm_clk_variant gs101_acpm_clks[] = { 44 + ACPM_CLK("mif"), 45 + ACPM_CLK("int"), 46 + ACPM_CLK("cpucl0"), 47 + ACPM_CLK("cpucl1"), 48 + ACPM_CLK("cpucl2"), 49 + ACPM_CLK("g3d"), 50 + ACPM_CLK("g3dl2"), 51 + ACPM_CLK("tpu"), 52 + ACPM_CLK("intcam"), 53 + ACPM_CLK("tnr"), 54 + ACPM_CLK("cam"), 55 + ACPM_CLK("mfc"), 56 + ACPM_CLK("disp"), 57 + ACPM_CLK("bo"), 58 + }; 59 + 60 + static const struct acpm_clk_driver_data acpm_clk_gs101 = { 61 + .clks = gs101_acpm_clks, 62 + .nr_clks = ARRAY_SIZE(gs101_acpm_clks), 63 + .mbox_chan_id = 0, 64 + }; 65 + 66 + static unsigned long acpm_clk_recalc_rate(struct clk_hw *hw, 67 + unsigned long parent_rate) 68 + { 69 + struct acpm_clk *clk = to_acpm_clk(hw); 70 + 71 + return clk->handle->ops.dvfs_ops.get_rate(clk->handle, 72 + clk->mbox_chan_id, clk->id); 73 + } 74 + 75 + static int acpm_clk_determine_rate(struct clk_hw *hw, 76 + struct clk_rate_request *req) 77 + { 78 + /* 79 + * We can't figure out what rate it will be, so just return the 80 + * rate back to the caller. acpm_clk_recalc_rate() will be called 81 + * after the rate is set and we'll know what rate the clock is 82 + * running at then. 83 + */ 84 + return 0; 85 + } 86 + 87 + static int acpm_clk_set_rate(struct clk_hw *hw, unsigned long rate, 88 + unsigned long parent_rate) 89 + { 90 + struct acpm_clk *clk = to_acpm_clk(hw); 91 + 92 + return clk->handle->ops.dvfs_ops.set_rate(clk->handle, 93 + clk->mbox_chan_id, clk->id, rate); 94 + } 95 + 96 + static const struct clk_ops acpm_clk_ops = { 97 + .recalc_rate = acpm_clk_recalc_rate, 98 + .determine_rate = acpm_clk_determine_rate, 99 + .set_rate = acpm_clk_set_rate, 100 + }; 101 + 102 + static int acpm_clk_register(struct device *dev, struct acpm_clk *aclk, 103 + const char *name) 104 + { 105 + struct clk_init_data init = {}; 106 + 107 + init.name = name; 108 + init.ops = &acpm_clk_ops; 109 + aclk->hw.init = &init; 110 + 111 + return devm_clk_hw_register(dev, &aclk->hw); 112 + } 113 + 114 + static int acpm_clk_probe(struct platform_device *pdev) 115 + { 116 + const struct acpm_handle *acpm_handle; 117 + struct clk_hw_onecell_data *clk_data; 118 + struct clk_hw **hws; 119 + struct device *dev = &pdev->dev; 120 + struct acpm_clk *aclks; 121 + unsigned int mbox_chan_id; 122 + int i, err, count; 123 + 124 + acpm_handle = devm_acpm_get_by_node(dev, dev->parent->of_node); 125 + if (IS_ERR(acpm_handle)) 126 + return dev_err_probe(dev, PTR_ERR(acpm_handle), 127 + "Failed to get acpm handle\n"); 128 + 129 + count = acpm_clk_gs101.nr_clks; 130 + mbox_chan_id = acpm_clk_gs101.mbox_chan_id; 131 + 132 + clk_data = devm_kzalloc(dev, struct_size(clk_data, hws, count), 133 + GFP_KERNEL); 134 + if (!clk_data) 135 + return -ENOMEM; 136 + 137 + clk_data->num = count; 138 + hws = clk_data->hws; 139 + 140 + aclks = devm_kcalloc(dev, count, sizeof(*aclks), GFP_KERNEL); 141 + if (!aclks) 142 + return -ENOMEM; 143 + 144 + for (i = 0; i < count; i++) { 145 + struct acpm_clk *aclk = &aclks[i]; 146 + 147 + /* 148 + * The code assumes the clock IDs start from zero, 149 + * are sequential and do not have gaps. 150 + */ 151 + aclk->id = i; 152 + aclk->handle = acpm_handle; 153 + aclk->mbox_chan_id = mbox_chan_id; 154 + 155 + hws[i] = &aclk->hw; 156 + 157 + err = acpm_clk_register(dev, aclk, 158 + acpm_clk_gs101.clks[i].name); 159 + if (err) 160 + return dev_err_probe(dev, err, 161 + "Failed to register clock\n"); 162 + } 163 + 164 + return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, 165 + clk_data); 166 + } 167 + 168 + static const struct platform_device_id acpm_clk_id[] = { 169 + { "gs101-acpm-clk" }, 170 + {} 171 + }; 172 + MODULE_DEVICE_TABLE(platform, acpm_clk_id); 173 + 174 + static struct platform_driver acpm_clk_driver = { 175 + .driver = { 176 + .name = "acpm-clocks", 177 + }, 178 + .probe = acpm_clk_probe, 179 + .id_table = acpm_clk_id, 180 + }; 181 + module_platform_driver(acpm_clk_driver); 182 + 183 + MODULE_AUTHOR("Tudor Ambarus <tudor.ambarus@linaro.org>"); 184 + MODULE_DESCRIPTION("Samsung Exynos ACPM clock driver"); 185 + MODULE_LICENSE("GPL");
+1 -1
drivers/clk/samsung/clk-exynos-clkout.c
··· 175 175 clkout->mux.shift = EXYNOS_CLKOUT_MUX_SHIFT; 176 176 clkout->mux.lock = &clkout->slock; 177 177 178 + clkout->data.num = EXYNOS_CLKOUT_NR_CLKS; 178 179 clkout->data.hws[0] = clk_hw_register_composite(NULL, "clkout", 179 180 parent_names, parent_count, &clkout->mux.hw, 180 181 &clk_mux_ops, NULL, NULL, &clkout->gate.hw, ··· 186 185 goto err_unmap; 187 186 } 188 187 189 - clkout->data.num = EXYNOS_CLKOUT_NR_CLKS; 190 188 ret = of_clk_add_hw_provider(clkout->np, of_clk_hw_onecell_get, &clkout->data); 191 189 if (ret) 192 190 goto err_clk_unreg;
+90
drivers/clk/samsung/clk-exynosautov920.c
··· 27 27 #define CLKS_NR_HSI0 (CLK_DOUT_HSI0_PCIE_APB + 1) 28 28 #define CLKS_NR_HSI1 (CLK_MOUT_HSI1_USBDRD + 1) 29 29 #define CLKS_NR_HSI2 (CLK_DOUT_HSI2_ETHERNET_PTP + 1) 30 + #define CLKS_NR_M2M (CLK_DOUT_M2M_NOCP + 1) 31 + #define CLKS_NR_MFC (CLK_DOUT_MFC_NOCP + 1) 30 32 31 33 /* ---- CMU_TOP ------------------------------------------------------------ */ 32 34 ··· 1823 1821 .clk_name = "noc", 1824 1822 }; 1825 1823 1824 + /* ---- CMU_M2M --------------------------------------------------------- */ 1825 + 1826 + /* Register Offset definitions for CMU_M2M (0x1a800000) */ 1827 + #define PLL_CON0_MUX_CLKCMU_M2M_JPEG_USER 0x600 1828 + #define PLL_CON0_MUX_CLKCMU_M2M_NOC_USER 0x610 1829 + #define CLK_CON_DIV_DIV_CLK_M2M_NOCP 0x1800 1830 + 1831 + static const unsigned long m2m_clk_regs[] __initconst = { 1832 + PLL_CON0_MUX_CLKCMU_M2M_JPEG_USER, 1833 + PLL_CON0_MUX_CLKCMU_M2M_NOC_USER, 1834 + CLK_CON_DIV_DIV_CLK_M2M_NOCP, 1835 + }; 1836 + 1837 + /* List of parent clocks for Muxes in CMU_M2M */ 1838 + PNAME(mout_clkcmu_m2m_noc_user_p) = { "oscclk", "dout_clkcmu_m2m_noc" }; 1839 + PNAME(mout_clkcmu_m2m_jpeg_user_p) = { "oscclk", "dout_clkcmu_m2m_jpeg" }; 1840 + 1841 + static const struct samsung_mux_clock m2m_mux_clks[] __initconst = { 1842 + MUX(CLK_MOUT_M2M_JPEG_USER, "mout_clkcmu_m2m_jpeg_user", 1843 + mout_clkcmu_m2m_jpeg_user_p, PLL_CON0_MUX_CLKCMU_M2M_JPEG_USER, 4, 1), 1844 + MUX(CLK_MOUT_M2M_NOC_USER, "mout_clkcmu_m2m_noc_user", 1845 + mout_clkcmu_m2m_noc_user_p, PLL_CON0_MUX_CLKCMU_M2M_NOC_USER, 4, 1), 1846 + }; 1847 + 1848 + static const struct samsung_div_clock m2m_div_clks[] __initconst = { 1849 + DIV(CLK_DOUT_M2M_NOCP, "dout_m2m_nocp", 1850 + "mout_clkcmu_m2m_noc_user", CLK_CON_DIV_DIV_CLK_M2M_NOCP, 1851 + 0, 3), 1852 + }; 1853 + 1854 + static const struct samsung_cmu_info m2m_cmu_info __initconst = { 1855 + .mux_clks = m2m_mux_clks, 1856 + .nr_mux_clks = ARRAY_SIZE(m2m_mux_clks), 1857 + .div_clks = m2m_div_clks, 1858 + .nr_div_clks = ARRAY_SIZE(m2m_div_clks), 1859 + .nr_clk_ids = CLKS_NR_M2M, 1860 + .clk_regs = m2m_clk_regs, 1861 + .nr_clk_regs = ARRAY_SIZE(m2m_clk_regs), 1862 + .clk_name = "noc", 1863 + }; 1864 + 1865 + /* ---- CMU_MFC --------------------------------------------------------- */ 1866 + 1867 + /* Register Offset definitions for CMU_MFC (0x19c00000) */ 1868 + #define PLL_CON0_MUX_CLKCMU_MFC_MFC_USER 0x600 1869 + #define PLL_CON0_MUX_CLKCMU_MFC_WFD_USER 0x610 1870 + #define CLK_CON_DIV_DIV_CLK_MFC_NOCP 0x1800 1871 + 1872 + static const unsigned long mfc_clk_regs[] __initconst = { 1873 + PLL_CON0_MUX_CLKCMU_MFC_MFC_USER, 1874 + PLL_CON0_MUX_CLKCMU_MFC_WFD_USER, 1875 + CLK_CON_DIV_DIV_CLK_MFC_NOCP, 1876 + }; 1877 + 1878 + /* List of parent clocks for Muxes in CMU_MFC */ 1879 + PNAME(mout_clkcmu_mfc_mfc_user_p) = { "oscclk", "dout_clkcmu_mfc_mfc" }; 1880 + PNAME(mout_clkcmu_mfc_wfd_user_p) = { "oscclk", "dout_clkcmu_mfc_wfd" }; 1881 + 1882 + static const struct samsung_mux_clock mfc_mux_clks[] __initconst = { 1883 + MUX(CLK_MOUT_MFC_MFC_USER, "mout_clkcmu_mfc_mfc_user", 1884 + mout_clkcmu_mfc_mfc_user_p, PLL_CON0_MUX_CLKCMU_MFC_MFC_USER, 4, 1), 1885 + MUX(CLK_MOUT_MFC_WFD_USER, "mout_clkcmu_mfc_wfd_user", 1886 + mout_clkcmu_mfc_wfd_user_p, PLL_CON0_MUX_CLKCMU_MFC_WFD_USER, 4, 1), 1887 + }; 1888 + 1889 + static const struct samsung_div_clock mfc_div_clks[] __initconst = { 1890 + DIV(CLK_DOUT_MFC_NOCP, "dout_mfc_nocp", 1891 + "mout_clkcmu_mfc_mfc_user", CLK_CON_DIV_DIV_CLK_MFC_NOCP, 1892 + 0, 3), 1893 + }; 1894 + 1895 + static const struct samsung_cmu_info mfc_cmu_info __initconst = { 1896 + .mux_clks = mfc_mux_clks, 1897 + .nr_mux_clks = ARRAY_SIZE(mfc_mux_clks), 1898 + .div_clks = mfc_div_clks, 1899 + .nr_div_clks = ARRAY_SIZE(mfc_div_clks), 1900 + .nr_clk_ids = CLKS_NR_MFC, 1901 + .clk_regs = mfc_clk_regs, 1902 + .nr_clk_regs = ARRAY_SIZE(mfc_clk_regs), 1903 + .clk_name = "noc", 1904 + }; 1905 + 1826 1906 static int __init exynosautov920_cmu_probe(struct platform_device *pdev) 1827 1907 { 1828 1908 const struct samsung_cmu_info *info; ··· 1935 1851 }, { 1936 1852 .compatible = "samsung,exynosautov920-cmu-hsi2", 1937 1853 .data = &hsi2_cmu_info, 1854 + }, { 1855 + .compatible = "samsung,exynosautov920-cmu-m2m", 1856 + .data = &m2m_cmu_info, 1857 + }, { 1858 + .compatible = "samsung,exynosautov920-cmu-mfc", 1859 + .data = &mfc_cmu_info, 1938 1860 }, 1939 1861 { } 1940 1862 };
+10 -31
drivers/clk/samsung/clk-pll.c
··· 11 11 #include <linux/iopoll.h> 12 12 #include <linux/delay.h> 13 13 #include <linux/slab.h> 14 - #include <linux/timekeeping.h> 15 14 #include <linux/clk-provider.h> 16 15 #include <linux/io.h> 17 16 #include "clk.h" 18 17 #include "clk-pll.h" 19 18 20 - #define PLL_TIMEOUT_US 20000U 21 - #define PLL_TIMEOUT_LOOPS 1000000U 19 + #define PLL_TIMEOUT_LOOPS 20000U 22 20 23 21 struct samsung_clk_pll { 24 22 struct clk_hw hw; ··· 69 71 return 0; 70 72 } 71 73 72 - static bool pll_early_timeout = true; 73 - 74 - static int __init samsung_pll_disable_early_timeout(void) 75 - { 76 - pll_early_timeout = false; 77 - return 0; 78 - } 79 - arch_initcall(samsung_pll_disable_early_timeout); 80 - 81 74 /* Wait until the PLL is locked */ 82 75 static int samsung_pll_lock_wait(struct samsung_clk_pll *pll, 83 76 unsigned int reg_mask) 84 77 { 85 - int i, ret; 78 + int ret; 86 79 u32 val; 87 80 88 81 /* ··· 82 93 * initialized, another when the timekeeping is suspended. udelay() also 83 94 * cannot be used when the clocksource is not running on arm64, since 84 95 * the current timer is used as cycle counter. So a simple busy loop 85 - * is used here in that special cases. The limit of iterations has been 86 - * derived from experimental measurements of various PLLs on multiple 87 - * Exynos SoC variants. Single register read time was usually in range 88 - * 0.4...1.5 us, never less than 0.4 us. 96 + * is used here. 97 + * The limit of iterations has been derived from experimental 98 + * measurements of various PLLs on multiple Exynos SoC variants. Single 99 + * register read time was usually in range 0.4...1.5 us, never less than 100 + * 0.4 us. 89 101 */ 90 - if (pll_early_timeout || timekeeping_suspended) { 91 - i = PLL_TIMEOUT_LOOPS; 92 - while (i-- > 0) { 93 - if (readl_relaxed(pll->con_reg) & reg_mask) 94 - return 0; 95 - 96 - cpu_relax(); 97 - } 98 - ret = -ETIMEDOUT; 99 - } else { 100 - ret = readl_relaxed_poll_timeout_atomic(pll->con_reg, val, 101 - val & reg_mask, 0, PLL_TIMEOUT_US); 102 - } 103 - 102 + ret = readl_relaxed_poll_timeout_atomic(pll->con_reg, val, 103 + val & reg_mask, 0, 104 + PLL_TIMEOUT_LOOPS); 104 105 if (ret < 0) 105 106 pr_err("Could not lock PLL %s\n", clk_hw_get_name(&pll->hw)); 106 107
+2 -2
drivers/clk/spacemit/ccu-k1.c
··· 1018 1018 if (!clk_data) 1019 1019 return -ENOMEM; 1020 1020 1021 + clk_data->num = data->num; 1022 + 1021 1023 for (i = 0; i < data->num; i++) { 1022 1024 struct clk_hw *hw = data->hws[i]; 1023 1025 struct ccu_common *common; ··· 1045 1043 1046 1044 clk_data->hws[i] = hw; 1047 1045 } 1048 - 1049 - clk_data->num = data->num; 1050 1046 1051 1047 ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_data); 1052 1048 if (ret)
+1 -1
drivers/clk/spacemit/ccu_mix.h
··· 220 220 extern const struct clk_ops spacemit_ccu_mux_gate_ops; 221 221 extern const struct clk_ops spacemit_ccu_mux_div_ops; 222 222 extern const struct clk_ops spacemit_ccu_mux_div_gate_ops; 223 - #endif /* _CCU_DIV_H_ */ 223 + #endif /* _CCU_MIX_H_ */
+2 -6
drivers/clk/sprd/sc9860-clk.c
··· 2021 2021 2022 2022 static int sc9860_clk_probe(struct platform_device *pdev) 2023 2023 { 2024 - const struct of_device_id *match; 2025 2024 const struct sprd_clk_desc *desc; 2026 2025 int ret; 2027 2026 2028 - match = of_match_node(sprd_sc9860_clk_ids, pdev->dev.of_node); 2029 - if (!match) { 2030 - pr_err("%s: of_match_node() failed", __func__); 2027 + desc = device_get_match_data(&pdev->dev); 2028 + if (!desc) 2031 2029 return -ENODEV; 2032 - } 2033 2030 2034 - desc = match->data; 2035 2031 ret = sprd_clk_regmap_init(pdev, desc); 2036 2032 if (ret) 2037 2033 return ret;
+3 -1
drivers/firmware/samsung/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0-only 2 2 3 - acpm-protocol-objs := exynos-acpm.o exynos-acpm-pmic.o 3 + acpm-protocol-objs := exynos-acpm.o 4 + acpm-protocol-objs += exynos-acpm-pmic.o 5 + acpm-protocol-objs += exynos-acpm-dvfs.o 4 6 obj-$(CONFIG_EXYNOS_ACPM_PROTOCOL) += acpm-protocol.o
+80
drivers/firmware/samsung/exynos-acpm-dvfs.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Copyright 2020 Samsung Electronics Co., Ltd. 4 + * Copyright 2020 Google LLC. 5 + * Copyright 2025 Linaro Ltd. 6 + */ 7 + 8 + #include <linux/bitfield.h> 9 + #include <linux/firmware/samsung/exynos-acpm-protocol.h> 10 + #include <linux/ktime.h> 11 + #include <linux/types.h> 12 + #include <linux/units.h> 13 + 14 + #include "exynos-acpm.h" 15 + #include "exynos-acpm-dvfs.h" 16 + 17 + #define ACPM_DVFS_ID GENMASK(11, 0) 18 + #define ACPM_DVFS_REQ_TYPE GENMASK(15, 0) 19 + 20 + #define ACPM_DVFS_FREQ_REQ 0 21 + #define ACPM_DVFS_FREQ_GET 1 22 + 23 + static void acpm_dvfs_set_xfer(struct acpm_xfer *xfer, u32 *cmd, size_t cmdlen, 24 + unsigned int acpm_chan_id, bool response) 25 + { 26 + xfer->acpm_chan_id = acpm_chan_id; 27 + xfer->txd = cmd; 28 + xfer->txlen = cmdlen; 29 + 30 + if (response) { 31 + xfer->rxd = cmd; 32 + xfer->rxlen = cmdlen; 33 + } 34 + } 35 + 36 + static void acpm_dvfs_init_set_rate_cmd(u32 cmd[4], unsigned int clk_id, 37 + unsigned long rate) 38 + { 39 + cmd[0] = FIELD_PREP(ACPM_DVFS_ID, clk_id); 40 + cmd[1] = rate / HZ_PER_KHZ; 41 + cmd[2] = FIELD_PREP(ACPM_DVFS_REQ_TYPE, ACPM_DVFS_FREQ_REQ); 42 + cmd[3] = ktime_to_ms(ktime_get()); 43 + } 44 + 45 + int acpm_dvfs_set_rate(const struct acpm_handle *handle, 46 + unsigned int acpm_chan_id, unsigned int clk_id, 47 + unsigned long rate) 48 + { 49 + struct acpm_xfer xfer = {0}; 50 + u32 cmd[4]; 51 + 52 + acpm_dvfs_init_set_rate_cmd(cmd, clk_id, rate); 53 + acpm_dvfs_set_xfer(&xfer, cmd, sizeof(cmd), acpm_chan_id, false); 54 + 55 + return acpm_do_xfer(handle, &xfer); 56 + } 57 + 58 + static void acpm_dvfs_init_get_rate_cmd(u32 cmd[4], unsigned int clk_id) 59 + { 60 + cmd[0] = FIELD_PREP(ACPM_DVFS_ID, clk_id); 61 + cmd[2] = FIELD_PREP(ACPM_DVFS_REQ_TYPE, ACPM_DVFS_FREQ_GET); 62 + cmd[3] = ktime_to_ms(ktime_get()); 63 + } 64 + 65 + unsigned long acpm_dvfs_get_rate(const struct acpm_handle *handle, 66 + unsigned int acpm_chan_id, unsigned int clk_id) 67 + { 68 + struct acpm_xfer xfer; 69 + unsigned int cmd[4] = {0}; 70 + int ret; 71 + 72 + acpm_dvfs_init_get_rate_cmd(cmd, clk_id); 73 + acpm_dvfs_set_xfer(&xfer, cmd, sizeof(cmd), acpm_chan_id, true); 74 + 75 + ret = acpm_do_xfer(handle, &xfer); 76 + if (ret) 77 + return 0; 78 + 79 + return xfer.rxd[1] * HZ_PER_KHZ; 80 + }
+21
drivers/firmware/samsung/exynos-acpm-dvfs.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-only */ 2 + /* 3 + * Copyright 2020 Samsung Electronics Co., Ltd. 4 + * Copyright 2020 Google LLC. 5 + * Copyright 2025 Linaro Ltd. 6 + */ 7 + #ifndef __EXYNOS_ACPM_DVFS_H__ 8 + #define __EXYNOS_ACPM_DVFS_H__ 9 + 10 + #include <linux/types.h> 11 + 12 + struct acpm_handle; 13 + 14 + int acpm_dvfs_set_rate(const struct acpm_handle *handle, 15 + unsigned int acpm_chan_id, unsigned int id, 16 + unsigned long rate); 17 + unsigned long acpm_dvfs_get_rate(const struct acpm_handle *handle, 18 + unsigned int acpm_chan_id, 19 + unsigned int clk_id); 20 + 21 + #endif /* __EXYNOS_ACPM_DVFS_H__ */
+26
drivers/firmware/samsung/exynos-acpm.c
··· 29 29 #include <linux/types.h> 30 30 31 31 #include "exynos-acpm.h" 32 + #include "exynos-acpm-dvfs.h" 32 33 #include "exynos-acpm-pmic.h" 33 34 34 35 #define ACPM_PROTOCOL_SEQNUM GENMASK(21, 16) ··· 177 176 /** 178 177 * struct acpm_match_data - of_device_id data. 179 178 * @initdata_base: offset in SRAM where the channels configuration resides. 179 + * @acpm_clk_dev_name: base name for the ACPM clocks device that we're registering. 180 180 */ 181 181 struct acpm_match_data { 182 182 loff_t initdata_base; 183 + const char *acpm_clk_dev_name; 183 184 }; 184 185 185 186 #define client_to_acpm_chan(c) container_of(c, struct acpm_chan, cl) ··· 593 590 */ 594 591 static void acpm_setup_ops(struct acpm_info *acpm) 595 592 { 593 + struct acpm_dvfs_ops *dvfs_ops = &acpm->handle.ops.dvfs_ops; 596 594 struct acpm_pmic_ops *pmic_ops = &acpm->handle.ops.pmic_ops; 595 + 596 + dvfs_ops->set_rate = acpm_dvfs_set_rate; 597 + dvfs_ops->get_rate = acpm_dvfs_get_rate; 597 598 598 599 pmic_ops->read_reg = acpm_pmic_read_reg; 599 600 pmic_ops->bulk_read = acpm_pmic_bulk_read; ··· 606 599 pmic_ops->update_reg = acpm_pmic_update_reg; 607 600 } 608 601 602 + static void acpm_clk_pdev_unregister(void *data) 603 + { 604 + platform_device_unregister(data); 605 + } 606 + 609 607 static int acpm_probe(struct platform_device *pdev) 610 608 { 611 609 const struct acpm_match_data *match_data; 610 + struct platform_device *acpm_clk_pdev; 612 611 struct device *dev = &pdev->dev; 613 612 struct device_node *shmem; 614 613 struct acpm_info *acpm; ··· 654 641 acpm_setup_ops(acpm); 655 642 656 643 platform_set_drvdata(pdev, acpm); 644 + 645 + acpm_clk_pdev = platform_device_register_data(dev, 646 + match_data->acpm_clk_dev_name, 647 + PLATFORM_DEVID_NONE, NULL, 0); 648 + if (IS_ERR(acpm_clk_pdev)) 649 + return dev_err_probe(dev, PTR_ERR(acpm_clk_pdev), 650 + "Failed to register ACPM clocks device.\n"); 651 + 652 + ret = devm_add_action_or_reset(dev, acpm_clk_pdev_unregister, 653 + acpm_clk_pdev); 654 + if (ret) 655 + return dev_err_probe(dev, ret, "Failed to add devm action.\n"); 657 656 658 657 return devm_of_platform_populate(dev); 659 658 } ··· 766 741 767 742 static const struct acpm_match_data acpm_gs101 = { 768 743 .initdata_base = ACPM_GS101_INITDATA_BASE, 744 + .acpm_clk_dev_name = "gs101-acpm-clk", 769 745 }; 770 746 771 747 static const struct of_device_id acpm_match[] = {
+26
include/dt-bindings/clock/google,gs101-acpm.h
··· 1 + /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ 2 + /* 3 + * Copyright 2025 Linaro Ltd. 4 + * 5 + * Device Tree binding constants for Google gs101 ACPM clock controller. 6 + */ 7 + 8 + #ifndef _DT_BINDINGS_CLOCK_GOOGLE_GS101_ACPM_H 9 + #define _DT_BINDINGS_CLOCK_GOOGLE_GS101_ACPM_H 10 + 11 + #define GS101_CLK_ACPM_DVFS_MIF 0 12 + #define GS101_CLK_ACPM_DVFS_INT 1 13 + #define GS101_CLK_ACPM_DVFS_CPUCL0 2 14 + #define GS101_CLK_ACPM_DVFS_CPUCL1 3 15 + #define GS101_CLK_ACPM_DVFS_CPUCL2 4 16 + #define GS101_CLK_ACPM_DVFS_G3D 5 17 + #define GS101_CLK_ACPM_DVFS_G3DL2 6 18 + #define GS101_CLK_ACPM_DVFS_TPU 7 19 + #define GS101_CLK_ACPM_DVFS_INTCAM 8 20 + #define GS101_CLK_ACPM_DVFS_TNR 9 21 + #define GS101_CLK_ACPM_DVFS_CAM 10 22 + #define GS101_CLK_ACPM_DVFS_MFC 11 23 + #define GS101_CLK_ACPM_DVFS_DISP 12 24 + #define GS101_CLK_ACPM_DVFS_BO 13 25 + 26 + #endif /* _DT_BINDINGS_CLOCK_GOOGLE_GS101_ACPM_H */
+1
include/dt-bindings/clock/r8a779a0-cpg-mssr.h
··· 51 51 #define R8A779A0_CLK_CBFUSA 40 52 52 #define R8A779A0_CLK_R 41 53 53 #define R8A779A0_CLK_OSC 42 54 + #define R8A779A0_CLK_ZG 43 54 55 55 56 #endif /* __DT_BINDINGS_CLOCK_R8A779A0_CPG_MSSR_H__ */
+2
include/dt-bindings/clock/renesas,r9a09g047-cpg.h
··· 22 22 #define R9A09G047_GBETH_1_CLK_PTP_REF_I 11 23 23 #define R9A09G047_USB3_0_REF_ALT_CLK_P 12 24 24 #define R9A09G047_USB3_0_CLKCORE 13 25 + #define R9A09G047_USB2_0_CLK_CORE0 14 26 + #define R9A09G047_USB2_0_CLK_CORE1 15 25 27 26 28 #endif /* __DT_BINDINGS_CLOCK_RENESAS_R9A09G047_CPG_H__ */
+2
include/dt-bindings/clock/renesas,r9a09g056-cpg.h
··· 21 21 #define R9A09G056_GBETH_0_CLK_PTP_REF_I 10 22 22 #define R9A09G056_GBETH_1_CLK_PTP_REF_I 11 23 23 #define R9A09G056_SPI_CLK_SPI 12 24 + #define R9A09G056_USB3_0_REF_ALT_CLK_P 13 25 + #define R9A09G056_USB3_0_CLKCORE 14 24 26 25 27 #endif /* __DT_BINDINGS_CLOCK_RENESAS_R9A09G056_CPG_H__ */
+4
include/dt-bindings/clock/renesas,r9a09g057-cpg.h
··· 22 22 #define R9A09G057_GBETH_0_CLK_PTP_REF_I 11 23 23 #define R9A09G057_GBETH_1_CLK_PTP_REF_I 12 24 24 #define R9A09G057_SPI_CLK_SPI 13 25 + #define R9A09G057_USB3_0_REF_ALT_CLK_P 14 26 + #define R9A09G057_USB3_0_CLKCORE 15 27 + #define R9A09G057_USB3_1_REF_ALT_CLK_P 16 28 + #define R9A09G057_USB3_1_CLKCORE 17 25 29 26 30 #endif /* __DT_BINDINGS_CLOCK_RENESAS_R9A09G057_CPG_H__ */
+10
include/dt-bindings/clock/samsung,exynosautov920.h
··· 295 295 #define CLK_DOUT_HSI2_ETHERNET 6 296 296 #define CLK_DOUT_HSI2_ETHERNET_PTP 7 297 297 298 + /* CMU_M2M */ 299 + #define CLK_MOUT_M2M_JPEG_USER 1 300 + #define CLK_MOUT_M2M_NOC_USER 2 301 + #define CLK_DOUT_M2M_NOCP 3 302 + 303 + /* CMU_MFC */ 304 + #define CLK_MOUT_MFC_MFC_USER 1 305 + #define CLK_MOUT_MFC_WFD_USER 2 306 + #define CLK_DOUT_MFC_NOCP 3 307 + 298 308 #endif /* _DT_BINDINGS_CLOCK_EXYNOSAUTOV920_H */
+61
include/dt-bindings/reset/airoha,en7523-reset.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-only */ 2 + /* 3 + * Copyright (C) 2024 iopsys Software Solutions AB. 4 + * Copyright (C) 2025 Genexis AB. 5 + * 6 + * Author: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu> 7 + * 8 + * based on 9 + * include/dt-bindings/reset/airoha,en7581-reset.h 10 + * by Lorenzo Bianconi <lorenzo@kernel.org> 11 + */ 12 + 13 + #ifndef __DT_BINDINGS_RESET_CONTROLLER_AIROHA_EN7523_H_ 14 + #define __DT_BINDINGS_RESET_CONTROLLER_AIROHA_EN7523_H_ 15 + 16 + /* RST_CTRL2 */ 17 + #define EN7523_XPON_PHY_RST 0 18 + #define EN7523_XSI_MAC_RST 1 19 + #define EN7523_XSI_PHY_RST 2 20 + #define EN7523_NPU_RST 3 21 + #define EN7523_I2S_RST 4 22 + #define EN7523_TRNG_RST 5 23 + #define EN7523_TRNG_MSTART_RST 6 24 + #define EN7523_DUAL_HSI0_RST 7 25 + #define EN7523_DUAL_HSI1_RST 8 26 + #define EN7523_HSI_RST 9 27 + #define EN7523_DUAL_HSI0_MAC_RST 10 28 + #define EN7523_DUAL_HSI1_MAC_RST 11 29 + #define EN7523_HSI_MAC_RST 12 30 + #define EN7523_WDMA_RST 13 31 + #define EN7523_WOE0_RST 14 32 + #define EN7523_WOE1_RST 15 33 + #define EN7523_HSDMA_RST 16 34 + #define EN7523_I2C2RBUS_RST 17 35 + #define EN7523_TDMA_RST 18 36 + /* RST_CTRL1 */ 37 + #define EN7523_PCM1_ZSI_ISI_RST 19 38 + #define EN7523_FE_PDMA_RST 20 39 + #define EN7523_FE_QDMA_RST 21 40 + #define EN7523_PCM_SPIWP_RST 22 41 + #define EN7523_CRYPTO_RST 23 42 + #define EN7523_TIMER_RST 24 43 + #define EN7523_PCM1_RST 25 44 + #define EN7523_UART_RST 26 45 + #define EN7523_GPIO_RST 27 46 + #define EN7523_GDMA_RST 28 47 + #define EN7523_I2C_MASTER_RST 29 48 + #define EN7523_PCM2_ZSI_ISI_RST 30 49 + #define EN7523_SFC_RST 31 50 + #define EN7523_UART2_RST 32 51 + #define EN7523_GDMP_RST 33 52 + #define EN7523_FE_RST 34 53 + #define EN7523_USB_HOST_P0_RST 35 54 + #define EN7523_GSW_RST 36 55 + #define EN7523_SFC2_PCM_RST 37 56 + #define EN7523_PCIE0_RST 38 57 + #define EN7523_PCIE1_RST 39 58 + #define EN7523_PCIE_HB_RST 40 59 + #define EN7523_XPON_MAC_RST 41 60 + 61 + #endif /* __DT_BINDINGS_RESET_CONTROLLER_AIROHA_EN7523_H_ */
+145
include/linux/clk/renesas.h
··· 10 10 #ifndef __LINUX_CLK_RENESAS_H_ 11 11 #define __LINUX_CLK_RENESAS_H_ 12 12 13 + #include <linux/clk-provider.h> 13 14 #include <linux/types.h> 15 + #include <linux/units.h> 14 16 15 17 struct device; 16 18 struct device_node; ··· 34 32 #define cpg_mssr_attach_dev NULL 35 33 #define cpg_mssr_detach_dev NULL 36 34 #endif 35 + 36 + /** 37 + * struct rzv2h_pll_limits - PLL parameter constraints 38 + * 39 + * This structure defines the minimum and maximum allowed values for 40 + * various parameters used to configure a PLL. These limits ensure 41 + * the PLL operates within valid and stable ranges. 42 + * 43 + * @fout: Output frequency range (in MHz) 44 + * @fout.min: Minimum allowed output frequency 45 + * @fout.max: Maximum allowed output frequency 46 + * 47 + * @fvco: PLL oscillation frequency range (in MHz) 48 + * @fvco.min: Minimum allowed VCO frequency 49 + * @fvco.max: Maximum allowed VCO frequency 50 + * 51 + * @m: Main-divider range 52 + * @m.min: Minimum main-divider value 53 + * @m.max: Maximum main-divider value 54 + * 55 + * @p: Pre-divider range 56 + * @p.min: Minimum pre-divider value 57 + * @p.max: Maximum pre-divider value 58 + * 59 + * @s: Divider range 60 + * @s.min: Minimum divider value 61 + * @s.max: Maximum divider value 62 + * 63 + * @k: Delta-sigma modulator range (signed) 64 + * @k.min: Minimum delta-sigma value 65 + * @k.max: Maximum delta-sigma value 66 + */ 67 + struct rzv2h_pll_limits { 68 + struct { 69 + u32 min; 70 + u32 max; 71 + } fout; 72 + 73 + struct { 74 + u32 min; 75 + u32 max; 76 + } fvco; 77 + 78 + struct { 79 + u16 min; 80 + u16 max; 81 + } m; 82 + 83 + struct { 84 + u8 min; 85 + u8 max; 86 + } p; 87 + 88 + struct { 89 + u8 min; 90 + u8 max; 91 + } s; 92 + 93 + struct { 94 + s16 min; 95 + s16 max; 96 + } k; 97 + }; 98 + 99 + /** 100 + * struct rzv2h_pll_pars - PLL configuration parameters 101 + * 102 + * This structure contains the configuration parameters for the 103 + * Phase-Locked Loop (PLL), used to achieve a specific output frequency. 104 + * 105 + * @m: Main divider value 106 + * @p: Pre-divider value 107 + * @s: Output divider value 108 + * @k: Delta-sigma modulation value 109 + * @freq_millihz: Calculated PLL output frequency in millihertz 110 + * @error_millihz: Frequency error from target in millihertz (signed) 111 + */ 112 + struct rzv2h_pll_pars { 113 + u16 m; 114 + u8 p; 115 + u8 s; 116 + s16 k; 117 + u64 freq_millihz; 118 + s64 error_millihz; 119 + }; 120 + 121 + /** 122 + * struct rzv2h_pll_div_pars - PLL parameters with post-divider 123 + * 124 + * This structure is used for PLLs that include an additional post-divider 125 + * stage after the main PLL block. It contains both the PLL configuration 126 + * parameters and the resulting frequency/error values after the divider. 127 + * 128 + * @pll: Main PLL configuration parameters (see struct rzv2h_pll_pars) 129 + * 130 + * @div: Post-divider configuration and result 131 + * @div.divider_value: Divider applied to the PLL output 132 + * @div.freq_millihz: Output frequency after divider in millihertz 133 + * @div.error_millihz: Frequency error from target in millihertz (signed) 134 + */ 135 + struct rzv2h_pll_div_pars { 136 + struct rzv2h_pll_pars pll; 137 + struct { 138 + u8 divider_value; 139 + u64 freq_millihz; 140 + s64 error_millihz; 141 + } div; 142 + }; 143 + 144 + #define RZV2H_CPG_PLL_DSI_LIMITS(name) \ 145 + static const struct rzv2h_pll_limits (name) = { \ 146 + .fout = { .min = 25 * MEGA, .max = 375 * MEGA }, \ 147 + .fvco = { .min = 1600 * MEGA, .max = 3200 * MEGA }, \ 148 + .m = { .min = 64, .max = 533 }, \ 149 + .p = { .min = 1, .max = 4 }, \ 150 + .s = { .min = 0, .max = 6 }, \ 151 + .k = { .min = -32768, .max = 32767 }, \ 152 + } \ 153 + 154 + #ifdef CONFIG_CLK_RZV2H 155 + bool rzv2h_get_pll_pars(const struct rzv2h_pll_limits *limits, 156 + struct rzv2h_pll_pars *pars, u64 freq_millihz); 157 + 158 + bool rzv2h_get_pll_divs_pars(const struct rzv2h_pll_limits *limits, 159 + struct rzv2h_pll_div_pars *pars, 160 + const u8 *table, u8 table_size, u64 freq_millihz); 161 + #else 162 + static inline bool rzv2h_get_pll_pars(const struct rzv2h_pll_limits *limits, 163 + struct rzv2h_pll_pars *pars, 164 + u64 freq_millihz) 165 + { 166 + return false; 167 + } 168 + 169 + static inline bool rzv2h_get_pll_divs_pars(const struct rzv2h_pll_limits *limits, 170 + struct rzv2h_pll_div_pars *pars, 171 + const u8 *table, u8 table_size, 172 + u64 freq_millihz) 173 + { 174 + return false; 175 + } 176 + #endif 177 + 37 178 #endif
+19
include/linux/firmware/samsung/exynos-acpm-protocol.h
··· 13 13 struct acpm_handle; 14 14 struct device_node; 15 15 16 + struct acpm_dvfs_ops { 17 + int (*set_rate)(const struct acpm_handle *handle, 18 + unsigned int acpm_chan_id, unsigned int clk_id, 19 + unsigned long rate); 20 + unsigned long (*get_rate)(const struct acpm_handle *handle, 21 + unsigned int acpm_chan_id, 22 + unsigned int clk_id); 23 + }; 24 + 16 25 struct acpm_pmic_ops { 17 26 int (*read_reg)(const struct acpm_handle *handle, 18 27 unsigned int acpm_chan_id, u8 type, u8 reg, u8 chan, ··· 41 32 }; 42 33 43 34 struct acpm_ops { 35 + struct acpm_dvfs_ops dvfs_ops; 44 36 struct acpm_pmic_ops pmic_ops; 45 37 }; 46 38 ··· 55 45 56 46 struct device; 57 47 48 + #if IS_ENABLED(CONFIG_EXYNOS_ACPM_PROTOCOL) 58 49 const struct acpm_handle *devm_acpm_get_by_node(struct device *dev, 59 50 struct device_node *np); 51 + #else 52 + 53 + static inline const struct acpm_handle *devm_acpm_get_by_node(struct device *dev, 54 + struct device_node *np) 55 + { 56 + return NULL; 57 + } 58 + #endif 60 59 61 60 #endif /* __EXYNOS_ACPM_PROTOCOL_H */