From patchwork Thu Mar 16 03:05:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xingyu Wu X-Patchwork-Id: 13176938 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BDD29C61DA4 for ; Thu, 16 Mar 2023 03:05:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=KQVaL/N/wn2G5tucJbhCq7xNGowVbC1euYtpAKLSg10=; b=cswNoOVimUvTaJ SCb5UKJKroNgvfYco8IoSiVqimjpkajFTTTH5K9u8ICD23ocDZmJNKpfSPHl2TVcm1YhvhO7qyZML stFGP3r6WNQx79h40GcnSneoDaxxHqzbKAfGukJmaLE+r0qQq3ha8VvRttPi0+axcrD/Gv0yRULKw NqDM+fXqJ0HdN9AkNptCkudLIihFfpyEen0zABxXu/Iixd26k+WW+35f682Xtv6TmbWCv78hYg6Lg r6Kaz5xiSoi4s9BDzUefch3YZQAWLTY0R4ft4AH+lsZMsa6PCUUe884phru2tPHEHp+GgOJv7jjZd wR1QwWPDzW1rngrO7RgQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pcdw7-00F3Ix-09; Thu, 16 Mar 2023 03:05:51 +0000 Received: from fd01.gateway.ufhost.com ([61.152.239.71]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pcdvz-00F3B6-20 for linux-riscv@lists.infradead.org; Thu, 16 Mar 2023 03:05:46 +0000 Received: from EXMBX166.cuchost.com (unknown [175.102.18.54]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "EXMBX166", Issuer "EXMBX166" (not verified)) by fd01.gateway.ufhost.com (Postfix) with ESMTP id D7FF924E292; Thu, 16 Mar 2023 11:05:18 +0800 (CST) Received: from EXMBX061.cuchost.com (172.16.6.61) by EXMBX166.cuchost.com (172.16.6.76) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 16 Mar 2023 11:05:17 +0800 Received: from localhost.localdomain (113.72.145.194) by EXMBX061.cuchost.com (172.16.6.61) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 16 Mar 2023 11:05:15 +0800 From: Xingyu Wu To: , , "Michael Turquette" , Stephen Boyd , Krzysztof Kozlowski , Philipp Zabel , Conor Dooley , "Emil Renner Berthing" CC: Rob Herring , Paul Walmsley , Palmer Dabbelt , Albert Ou , Hal Feng , Xingyu Wu , William Qiu , , Subject: [PATCH v2 1/6] dt-bindings: clock: Add StarFive JH7110 PLL clock generator Date: Thu, 16 Mar 2023 11:05:09 +0800 Message-ID: <20230316030514.137427-2-xingyu.wu@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230316030514.137427-1-xingyu.wu@starfivetech.com> References: <20230316030514.137427-1-xingyu.wu@starfivetech.com> MIME-Version: 1.0 X-Originating-IP: [113.72.145.194] X-ClientProxiedBy: EXCAS064.cuchost.com (172.16.6.24) To EXMBX061.cuchost.com (172.16.6.61) X-YovoleRuleAgent: yovoleflag X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230315_200543_947477_0293213C X-CRM114-Status: GOOD ( 13.65 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add bindings for the PLL clock generator on the JH7110 RISC-V SoC. Signed-off-by: Xingyu Wu Reviewed-by: Krzysztof Kozlowski --- .../bindings/clock/starfive,jh7110-pll.yaml | 46 +++++++++++++++++++ .../dt-bindings/clock/starfive,jh7110-crg.h | 6 +++ 2 files changed, 52 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/starfive,jh7110-pll.yaml diff --git a/Documentation/devicetree/bindings/clock/starfive,jh7110-pll.yaml b/Documentation/devicetree/bindings/clock/starfive,jh7110-pll.yaml new file mode 100644 index 000000000000..9397516f60ba --- /dev/null +++ b/Documentation/devicetree/bindings/clock/starfive,jh7110-pll.yaml @@ -0,0 +1,46 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/clock/starfive,jh7110-pll.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: StarFive JH7110 PLL Clock Generator + +description: + This PLL are high speed, low jitter frequency synthesizers in JH7110. + Each PLL clocks work in integer mode or fraction mode by some dividers, + and the configuration registers and dividers are set in several syscon + registers. So pll node should be a child of SYS-SYSCON node. + The formula for calculating frequency is that, + Fvco = Fref * (NI + NF) / M / Q1 + +maintainers: + - Xingyu Wu + +properties: + compatible: + const: starfive,jh7110-pll + + clocks: + maxItems: 1 + description: Main Oscillator (24 MHz) + + '#clock-cells': + const: 1 + description: + See for valid indices. + +required: + - compatible + - clocks + - '#clock-cells' + +additionalProperties: false + +examples: + - | + pllclk: pll-clock-controller { + compatible = "starfive,jh7110-pll"; + clocks = <&osc>; + #clock-cells = <1>; + }; diff --git a/include/dt-bindings/clock/starfive,jh7110-crg.h b/include/dt-bindings/clock/starfive,jh7110-crg.h index 06257bfd9ac1..086a6ddcf380 100644 --- a/include/dt-bindings/clock/starfive,jh7110-crg.h +++ b/include/dt-bindings/clock/starfive,jh7110-crg.h @@ -6,6 +6,12 @@ #ifndef __DT_BINDINGS_CLOCK_STARFIVE_JH7110_CRG_H__ #define __DT_BINDINGS_CLOCK_STARFIVE_JH7110_CRG_H__ +/* PLL clocks */ +#define JH7110_CLK_PLL0_OUT 0 +#define JH7110_CLK_PLL1_OUT 1 +#define JH7110_CLK_PLL2_OUT 2 +#define JH7110_PLLCLK_END 3 + /* SYSCRG clocks */ #define JH7110_SYSCLK_CPU_ROOT 0 #define JH7110_SYSCLK_CPU_CORE 1 From patchwork Thu Mar 16 03:05:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xingyu Wu X-Patchwork-Id: 13176934 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 628BDC6FD1D for ; Thu, 16 Mar 2023 03:05:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=EFKuhWvpJRFjlWpXjfQ+l2vVD6hm+VfAerhCpE4LWpk=; b=L4AFsk9OYwFpQj Q62uB51e52autbW3Pie6/NEnSRL5VgFFqDFm/YaajCw27XDHgK3pS6oz22O5PvdcWl2QuhBepd0+N H1uNBOZhUJv9NzGCNEXf+3NVVVNyRs1AqZCzFANLgsXNMgfYLiSUJt6FxTgeP3dVM2lhQKPM0SeIu puVELHlaru1kJ+rqrQZBcds/LyezBa1Ok3XmPDMqWE93f6WhsrzHzFzErmV4bPPB+lrcyrHJ9yl56 PRTzmB+6GggNgmsNMQNkMTg5m07zTYvxu4lpHZW8RYUwM8E0dd4kffPjc/Sn5pj0q38PVJgh3GrlI 9nveevAAavZ/18ZughxA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pcdvu-00F3DH-0Q; Thu, 16 Mar 2023 03:05:38 +0000 Received: from ex01.ufhost.com ([61.152.239.75]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pcdvp-00F3AW-0U for linux-riscv@lists.infradead.org; Thu, 16 Mar 2023 03:05:36 +0000 Received: from EXMBX165.cuchost.com (unknown [175.102.18.54]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "EXMBX165", Issuer "EXMBX165" (not verified)) by ex01.ufhost.com (Postfix) with ESMTP id 2F42A24E208; Thu, 16 Mar 2023 11:05:18 +0800 (CST) Received: from EXMBX061.cuchost.com (172.16.6.61) by EXMBX165.cuchost.com (172.16.6.75) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 16 Mar 2023 11:05:18 +0800 Received: from localhost.localdomain (113.72.145.194) by EXMBX061.cuchost.com (172.16.6.61) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 16 Mar 2023 11:05:16 +0800 From: Xingyu Wu To: , , "Michael Turquette" , Stephen Boyd , Krzysztof Kozlowski , Philipp Zabel , Conor Dooley , "Emil Renner Berthing" CC: Rob Herring , Paul Walmsley , Palmer Dabbelt , Albert Ou , Hal Feng , Xingyu Wu , William Qiu , , Subject: [PATCH v2 2/6] clk: starfive: Add StarFive JH7110 PLL clock driver Date: Thu, 16 Mar 2023 11:05:10 +0800 Message-ID: <20230316030514.137427-3-xingyu.wu@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230316030514.137427-1-xingyu.wu@starfivetech.com> References: <20230316030514.137427-1-xingyu.wu@starfivetech.com> MIME-Version: 1.0 X-Originating-IP: [113.72.145.194] X-ClientProxiedBy: EXCAS064.cuchost.com (172.16.6.24) To EXMBX061.cuchost.com (172.16.6.61) X-YovoleRuleAgent: yovoleflag X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230315_200533_792904_5DB35265 X-CRM114-Status: GOOD ( 23.24 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add driver for the StarFive JH7110 PLL clock controller. Signed-off-by: Xingyu Wu --- drivers/clk/starfive/Kconfig | 8 + drivers/clk/starfive/Makefile | 1 + .../clk/starfive/clk-starfive-jh7110-pll.c | 420 ++++++++++++++++++ .../clk/starfive/clk-starfive-jh7110-pll.h | 293 ++++++++++++ 4 files changed, 722 insertions(+) create mode 100644 drivers/clk/starfive/clk-starfive-jh7110-pll.c create mode 100644 drivers/clk/starfive/clk-starfive-jh7110-pll.h diff --git a/drivers/clk/starfive/Kconfig b/drivers/clk/starfive/Kconfig index 71c1148ee5f6..e306edf4defa 100644 --- a/drivers/clk/starfive/Kconfig +++ b/drivers/clk/starfive/Kconfig @@ -21,6 +21,14 @@ config CLK_STARFIVE_JH7100_AUDIO Say Y or M here to support the audio clocks on the StarFive JH7100 SoC. +config CLK_STARFIVE_JH7110_PLL + bool "StarFive JH7110 PLL clock support" + depends on ARCH_STARFIVE || COMPILE_TEST + default ARCH_STARFIVE + help + Say yes here to support the PLL clock controller on the + StarFive JH7110 SoC. + config CLK_STARFIVE_JH7110_SYS bool "StarFive JH7110 system clock support" depends on ARCH_STARFIVE || COMPILE_TEST diff --git a/drivers/clk/starfive/Makefile b/drivers/clk/starfive/Makefile index f3df7d957b1e..b48e539e52b0 100644 --- a/drivers/clk/starfive/Makefile +++ b/drivers/clk/starfive/Makefile @@ -4,5 +4,6 @@ obj-$(CONFIG_CLK_STARFIVE_JH71X0) += clk-starfive-jh71x0.o obj-$(CONFIG_CLK_STARFIVE_JH7100) += clk-starfive-jh7100.o obj-$(CONFIG_CLK_STARFIVE_JH7100_AUDIO) += clk-starfive-jh7100-audio.o +obj-$(CONFIG_CLK_STARFIVE_JH7110_PLL) += clk-starfive-jh7110-pll.o obj-$(CONFIG_CLK_STARFIVE_JH7110_SYS) += clk-starfive-jh7110-sys.o obj-$(CONFIG_CLK_STARFIVE_JH7110_AON) += clk-starfive-jh7110-aon.o diff --git a/drivers/clk/starfive/clk-starfive-jh7110-pll.c b/drivers/clk/starfive/clk-starfive-jh7110-pll.c new file mode 100644 index 000000000000..b947861065db --- /dev/null +++ b/drivers/clk/starfive/clk-starfive-jh7110-pll.c @@ -0,0 +1,420 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * StarFive JH7110 PLL Clock Generator Driver + * + * Copyright (C) 2022 StarFive Technology Co., Ltd. + * Copyright (C) 2022 Xingyu Wu + * + * This driver is about to register JH7110 PLL clock generator and support ops. + * The JH7110 have three PLL clock, PLL0, PLL1 and PLL2. + * Each PLL clocks work in integer mode or fraction mode by some dividers, + * and the configuration registers and dividers are set in several syscon registers. + * The formula for calculating frequency is: + * Fvco = Fref * (NI + NF) / M / Q1 + * Fref: OSC source clock rate + * NI: integer frequency dividing ratio of feedback divider, set by fbdiv[11:0]. + * NF: fractional frequency dividing ratio, set by frac[23:0]. NF = frac[23:0] / 2^24 = 0 ~ 0.999. + * M: frequency dividing ratio of pre-divider, set by prediv[5:0]. + * Q1: frequency dividing ratio of post divider, set by postdiv1[1:0], Q1= 1,2,4,8. + */ + +#include +#include +#include +#include +#include +#include + +#include + +#include "clk-starfive-jh7110-pll.h" + +static struct jh7110_clk_pll_data *jh7110_pll_data_from(struct clk_hw *hw) +{ + return container_of(hw, struct jh7110_clk_pll_data, hw); +} + +static struct jh7110_clk_pll_priv *jh7110_pll_priv_from(struct jh7110_clk_pll_data *data) +{ + return container_of(data, struct jh7110_clk_pll_priv, data[data->idx]); +} + +/* Read register value from syscon and calculate PLL(x) frequency */ +static unsigned long jh7110_pll_get_freq(struct jh7110_clk_pll_data *data, + unsigned long parent_rate) +{ + struct jh7110_clk_pll_priv *priv = jh7110_pll_priv_from(data); + struct jh7110_pll_syscon_offset *offset = &data->offset; + struct jh7110_pll_syscon_mask *mask = &data->mask; + struct jh7110_pll_syscon_shift *shift = &data->shift; + unsigned long freq = 0; + unsigned long frac_cal; + u32 dacpd; + u32 dsmpd; + u32 fbdiv; + u32 prediv; + u32 postdiv1; + u32 frac; + u32 reg_value; + + if (regmap_read(priv->syscon_regmap, offset->dacpd, ®_value)) + goto read_register_error; + dacpd = (reg_value & mask->dacpd) >> shift->dacpd; + + if (regmap_read(priv->syscon_regmap, offset->dsmpd, ®_value)) + goto read_register_error; + dsmpd = (reg_value & mask->dsmpd) >> shift->dsmpd; + + if (regmap_read(priv->syscon_regmap, offset->fbdiv, ®_value)) + goto read_register_error; + fbdiv = (reg_value & mask->fbdiv) >> shift->fbdiv; + /* fbdiv value should be 8 to 4095 */ + if (fbdiv < 8) + goto read_register_error; + + if (regmap_read(priv->syscon_regmap, offset->prediv, ®_value)) + goto read_register_error; + prediv = (reg_value & mask->prediv) >> shift->prediv; + + if (regmap_read(priv->syscon_regmap, offset->postdiv1, ®_value)) + goto read_register_error; + /* postdiv1 = 2 ^ reg_value */ + postdiv1 = 1 << ((reg_value & mask->postdiv1) >> shift->postdiv1); + + if (regmap_read(priv->syscon_regmap, offset->frac, ®_value)) + goto read_register_error; + frac = (reg_value & mask->frac) >> shift->frac; + + /* + * Integer Mode (Both 1) or Fraction Mode (Both 0). + * And the decimal places are counted by expanding them by + * a factor of STARFIVE_PLL_FRAC_PATR_SIZE. + */ + if (dacpd == 1 && dsmpd == 1) + frac_cal = 0; + else if (dacpd == 0 && dsmpd == 0) + frac_cal = (unsigned long)frac * STARFIVE_PLL_FRAC_PATR_SIZE / (1 << 24); + else + goto read_register_error; + + if (frac_cal) + /* fraction mode: Fvco = Fref * (NI + NF) / M / Q1 */ + freq = parent_rate / STARFIVE_PLL_FRAC_PATR_SIZE * + (fbdiv * STARFIVE_PLL_FRAC_PATR_SIZE + frac_cal) / prediv / postdiv1; + else + /* integer mode: Fvco = Fref * NI / M / Q1 */ + freq = parent_rate * fbdiv / prediv / postdiv1; + +read_register_error: + return freq; +} + +/* Select the appropriate frequency from the already configured registers value */ +static int jh7110_pll_select_freq_syscon(struct jh7110_clk_pll_data *data, + unsigned long target_rate) +{ + struct jh7110_clk_pll_priv *priv = jh7110_pll_priv_from(data); + const struct starfive_pll_syscon_value *syscon_value; + unsigned int id; + unsigned int pll_arry_size; + + if (data->idx == JH7110_CLK_PLL0_OUT) + pll_arry_size = ARRAY_SIZE(jh7110_pll0_syscon_freq); + else if (data->idx == JH7110_CLK_PLL1_OUT) + pll_arry_size = ARRAY_SIZE(jh7110_pll1_syscon_freq); + else + pll_arry_size = ARRAY_SIZE(jh7110_pll2_syscon_freq); + + for (id = 0; id < pll_arry_size; id++) { + if (data->idx == JH7110_CLK_PLL0_OUT) + syscon_value = &jh7110_pll0_syscon_freq[id]; + else if (data->idx == JH7110_CLK_PLL1_OUT) + syscon_value = &jh7110_pll1_syscon_freq[id]; + else + syscon_value = &jh7110_pll2_syscon_freq[id]; + + if (target_rate == syscon_value->freq) + goto select_succeed; + } + + dev_err(priv->dev, "pll%d frequency:%ld do not match, please check it.\n", + data->idx, target_rate); + return -EINVAL; + +select_succeed: + data->freq_select_idx = id; + return 0; +} + +static int jh7110_pll_set_freq_syscon(struct jh7110_clk_pll_data *data) +{ + struct jh7110_clk_pll_priv *priv = jh7110_pll_priv_from(data); + struct jh7110_pll_syscon_offset *offset = &data->offset; + struct jh7110_pll_syscon_mask *mask = &data->mask; + struct jh7110_pll_syscon_shift *shift = &data->shift; + unsigned int freq_idx = data->freq_select_idx; + const struct starfive_pll_syscon_value *syscon_value; + int ret; + + if (data->idx == JH7110_CLK_PLL0_OUT) + syscon_value = &jh7110_pll0_syscon_freq[freq_idx]; + else if (data->idx == JH7110_CLK_PLL1_OUT) + syscon_value = &jh7110_pll1_syscon_freq[freq_idx]; + else + syscon_value = &jh7110_pll2_syscon_freq[freq_idx]; + + ret = regmap_update_bits(priv->syscon_regmap, offset->dacpd, mask->dacpd, + (syscon_value->dacpd << shift->dacpd)); + if (ret) + goto set_failed; + + ret = regmap_update_bits(priv->syscon_regmap, offset->dsmpd, mask->dsmpd, + (syscon_value->dsmpd << shift->dsmpd)); + if (ret) + goto set_failed; + + ret = regmap_update_bits(priv->syscon_regmap, offset->prediv, mask->prediv, + (syscon_value->prediv << shift->prediv)); + if (ret) + goto set_failed; + + ret = regmap_update_bits(priv->syscon_regmap, offset->fbdiv, mask->fbdiv, + (syscon_value->fbdiv << shift->fbdiv)); + if (ret) + goto set_failed; + + ret = regmap_update_bits(priv->syscon_regmap, offset->postdiv1, mask->postdiv1, + ((syscon_value->postdiv1 >> 1) << shift->postdiv1)); + if (ret) + goto set_failed; + + /* frac: Integer Mode (Both 1) or Fraction Mode (Both 0) */ + if (syscon_value->dacpd == 0 && syscon_value->dsmpd == 0) + ret = regmap_update_bits(priv->syscon_regmap, offset->frac, mask->frac, + (syscon_value->frac << shift->frac)); + else if (syscon_value->dacpd != syscon_value->dsmpd) + ret = -EINVAL; + +set_failed: + return ret; +} + +static unsigned long jh7110_pll_recalc_rate(struct clk_hw *hw, unsigned long parent_rate) +{ + struct jh7110_clk_pll_data *data = jh7110_pll_data_from(hw); + + return jh7110_pll_get_freq(data, parent_rate); +} + +static int jh7110_pll_determine_rate(struct clk_hw *hw, struct clk_rate_request *req) +{ + struct jh7110_clk_pll_data *data = jh7110_pll_data_from(hw); + int ret = jh7110_pll_select_freq_syscon(data, req->rate); + + if (ret) + return ret; + + if (data->idx == JH7110_CLK_PLL0_OUT) + req->rate = jh7110_pll0_syscon_freq[data->freq_select_idx].freq; + else if (data->idx == JH7110_CLK_PLL1_OUT) + req->rate = jh7110_pll1_syscon_freq[data->freq_select_idx].freq; + else + req->rate = jh7110_pll2_syscon_freq[data->freq_select_idx].freq; + + return 0; +} + +static int jh7110_pll_set_rate(struct clk_hw *hw, unsigned long rate, + unsigned long parent_rate) +{ + struct jh7110_clk_pll_data *data = jh7110_pll_data_from(hw); + + return jh7110_pll_set_freq_syscon(data); +} + +#ifdef CONFIG_DEBUG_FS +static void jh7110_pll_debug_init(struct clk_hw *hw, struct dentry *dentry) +{ + static const struct debugfs_reg32 jh7110_clk_pll_reg = { + .name = "CTRL", + .offset = 0, + }; + struct jh7110_clk_pll_data *data = jh7110_pll_data_from(hw); + struct jh7110_clk_pll_priv *priv = jh7110_pll_priv_from(data); + struct debugfs_regset32 *regset; + + regset = devm_kzalloc(priv->dev, sizeof(*regset), GFP_KERNEL); + if (!regset) + return; + + regset->regs = &jh7110_clk_pll_reg; + regset->nregs = 1; + + debugfs_create_regset32("registers", 0400, dentry, regset); +} +#else +#define jh7110_pll_debug_init NULL +#endif + +static const struct clk_ops jh7110_pll_ops = { + .recalc_rate = jh7110_pll_recalc_rate, + .determine_rate = jh7110_pll_determine_rate, + .set_rate = jh7110_pll_set_rate, + .debug_init = jh7110_pll_debug_init, +}; + +/* get offset, mask and shift of PLL(x) syscon */ +static int jh7110_pll_data_get(struct jh7110_clk_pll_data *data, int index) +{ + struct jh7110_pll_syscon_offset *offset = &data->offset; + struct jh7110_pll_syscon_mask *mask = &data->mask; + struct jh7110_pll_syscon_shift *shift = &data->shift; + + if (index == JH7110_CLK_PLL0_OUT) { + offset->dacpd = STARFIVE_JH7110_PLL0_DACPD_OFFSET; + offset->dsmpd = STARFIVE_JH7110_PLL0_DSMPD_OFFSET; + offset->fbdiv = STARFIVE_JH7110_PLL0_FBDIV_OFFSET; + offset->frac = STARFIVE_JH7110_PLL0_FRAC_OFFSET; + offset->prediv = STARFIVE_JH7110_PLL0_PREDIV_OFFSET; + offset->postdiv1 = STARFIVE_JH7110_PLL0_POSTDIV1_OFFSET; + + mask->dacpd = STARFIVE_JH7110_PLL0_DACPD_MASK; + mask->dsmpd = STARFIVE_JH7110_PLL0_DSMPD_MASK; + mask->fbdiv = STARFIVE_JH7110_PLL0_FBDIV_MASK; + mask->frac = STARFIVE_JH7110_PLL0_FRAC_MASK; + mask->prediv = STARFIVE_JH7110_PLL0_PREDIV_MASK; + mask->postdiv1 = STARFIVE_JH7110_PLL0_POSTDIV1_MASK; + + shift->dacpd = STARFIVE_JH7110_PLL0_DACPD_SHIFT; + shift->dsmpd = STARFIVE_JH7110_PLL0_DSMPD_SHIFT; + shift->fbdiv = STARFIVE_JH7110_PLL0_FBDIV_SHIFT; + shift->frac = STARFIVE_JH7110_PLL0_FRAC_SHIFT; + shift->prediv = STARFIVE_JH7110_PLL0_PREDIV_SHIFT; + shift->postdiv1 = STARFIVE_JH7110_PLL0_POSTDIV1_SHIFT; + + } else if (index == JH7110_CLK_PLL1_OUT) { + offset->dacpd = STARFIVE_JH7110_PLL1_DACPD_OFFSET; + offset->dsmpd = STARFIVE_JH7110_PLL1_DSMPD_OFFSET; + offset->fbdiv = STARFIVE_JH7110_PLL1_FBDIV_OFFSET; + offset->frac = STARFIVE_JH7110_PLL1_FRAC_OFFSET; + offset->prediv = STARFIVE_JH7110_PLL1_PREDIV_OFFSET; + offset->postdiv1 = STARFIVE_JH7110_PLL1_POSTDIV1_OFFSET; + + mask->dacpd = STARFIVE_JH7110_PLL1_DACPD_MASK; + mask->dsmpd = STARFIVE_JH7110_PLL1_DSMPD_MASK; + mask->fbdiv = STARFIVE_JH7110_PLL1_FBDIV_MASK; + mask->frac = STARFIVE_JH7110_PLL1_FRAC_MASK; + mask->prediv = STARFIVE_JH7110_PLL1_PREDIV_MASK; + mask->postdiv1 = STARFIVE_JH7110_PLL1_POSTDIV1_MASK; + + shift->dacpd = STARFIVE_JH7110_PLL1_DACPD_SHIFT; + shift->dsmpd = STARFIVE_JH7110_PLL1_DSMPD_SHIFT; + shift->fbdiv = STARFIVE_JH7110_PLL1_FBDIV_SHIFT; + shift->frac = STARFIVE_JH7110_PLL1_FRAC_SHIFT; + shift->prediv = STARFIVE_JH7110_PLL1_PREDIV_SHIFT; + shift->postdiv1 = STARFIVE_JH7110_PLL1_POSTDIV1_SHIFT; + + } else if (index == JH7110_CLK_PLL2_OUT) { + offset->dacpd = STARFIVE_JH7110_PLL2_DACPD_OFFSET; + offset->dsmpd = STARFIVE_JH7110_PLL2_DSMPD_OFFSET; + offset->fbdiv = STARFIVE_JH7110_PLL2_FBDIV_OFFSET; + offset->frac = STARFIVE_JH7110_PLL2_FRAC_OFFSET; + offset->prediv = STARFIVE_JH7110_PLL2_PREDIV_OFFSET; + offset->postdiv1 = STARFIVE_JH7110_PLL2_POSTDIV1_OFFSET; + + mask->dacpd = STARFIVE_JH7110_PLL2_DACPD_MASK; + mask->dsmpd = STARFIVE_JH7110_PLL2_DSMPD_MASK; + mask->fbdiv = STARFIVE_JH7110_PLL2_FBDIV_MASK; + mask->frac = STARFIVE_JH7110_PLL2_FRAC_MASK; + mask->prediv = STARFIVE_JH7110_PLL2_PREDIV_MASK; + mask->postdiv1 = STARFIVE_JH7110_PLL2_POSTDIV1_MASK; + + shift->dacpd = STARFIVE_JH7110_PLL2_DACPD_SHIFT; + shift->dsmpd = STARFIVE_JH7110_PLL2_DSMPD_SHIFT; + shift->fbdiv = STARFIVE_JH7110_PLL2_FBDIV_SHIFT; + shift->frac = STARFIVE_JH7110_PLL2_FRAC_SHIFT; + shift->prediv = STARFIVE_JH7110_PLL2_PREDIV_SHIFT; + shift->postdiv1 = STARFIVE_JH7110_PLL2_POSTDIV1_SHIFT; + + } else { + return -ENOENT; + } + + return 0; +} + +static struct clk_hw *jh7110_pll_get(struct of_phandle_args *clkspec, void *data) +{ + struct jh7110_clk_pll_priv *priv = data; + unsigned int idx = clkspec->args[0]; + + if (idx < JH7110_PLLCLK_END) + return &priv->data[idx].hw; + + return ERR_PTR(-EINVAL); +} + +static int jh7110_pll_probe(struct platform_device *pdev) +{ + const char *pll_name[JH7110_PLLCLK_END] = { + "pll0_out", + "pll1_out", + "pll2_out" + }; + struct jh7110_clk_pll_priv *priv; + struct jh7110_clk_pll_data *data; + int ret; + unsigned int idx; + + priv = devm_kzalloc(&pdev->dev, struct_size(priv, data, JH7110_PLLCLK_END), + GFP_KERNEL); + if (!priv) + return -ENOMEM; + + priv->dev = &pdev->dev; + priv->syscon_regmap = syscon_node_to_regmap(priv->dev->of_node->parent); + if (IS_ERR(priv->syscon_regmap)) + return PTR_ERR(priv->syscon_regmap); + + for (idx = 0; idx < JH7110_PLLCLK_END; idx++) { + struct clk_parent_data parents = { + .index = 0, + }; + struct clk_init_data init = { + .name = pll_name[idx], + .ops = &jh7110_pll_ops, + .parent_data = &parents, + .num_parents = 1, + .flags = 0, + }; + + data = &priv->data[idx]; + + ret = jh7110_pll_data_get(data, idx); + if (ret) + return ret; + + data->hw.init = &init; + data->idx = idx; + + ret = devm_clk_hw_register(&pdev->dev, &data->hw); + if (ret) + return ret; + } + + return devm_of_clk_add_hw_provider(&pdev->dev, jh7110_pll_get, priv); +} + +static const struct of_device_id jh7110_pll_match[] = { + { .compatible = "starfive,jh7110-pll" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, jh7110_pll_match); + +static struct platform_driver jh7110_pll_driver = { + .driver = { + .name = "clk-starfive-jh7110-pll", + .of_match_table = jh7110_pll_match, + }, +}; +builtin_platform_driver_probe(jh7110_pll_driver, jh7110_pll_probe); diff --git a/drivers/clk/starfive/clk-starfive-jh7110-pll.h b/drivers/clk/starfive/clk-starfive-jh7110-pll.h new file mode 100644 index 000000000000..3deb35f144dc --- /dev/null +++ b/drivers/clk/starfive/clk-starfive-jh7110-pll.h @@ -0,0 +1,293 @@ +/* SPDX-License-Identifier: GPL-2.0 OR MIT */ +/* + * StarFive JH7110 PLL Clock Generator Driver + * + * Copyright (C) 2022 Xingyu Wu + */ + +#ifndef _CLK_STARFIVE_JH7110_PLL_H_ +#define _CLK_STARFIVE_JH7110_PLL_H_ + +#include + +/* The decimal places are counted by expanding them by a factor of STARFIVE_PLL_FRAC_PATR_SIZE. */ +#define STARFIVE_PLL_FRAC_PATR_SIZE 1000 + +#define STARFIVE_JH7110_PLL0_DACPD_OFFSET 0x18 +#define STARFIVE_JH7110_PLL0_DACPD_SHIFT 24 +#define STARFIVE_JH7110_PLL0_DACPD_MASK BIT(24) +#define STARFIVE_JH7110_PLL0_DSMPD_OFFSET 0x18 +#define STARFIVE_JH7110_PLL0_DSMPD_SHIFT 25 +#define STARFIVE_JH7110_PLL0_DSMPD_MASK BIT(25) +#define STARFIVE_JH7110_PLL0_FBDIV_OFFSET 0x1c +#define STARFIVE_JH7110_PLL0_FBDIV_SHIFT 0 +#define STARFIVE_JH7110_PLL0_FBDIV_MASK GENMASK(11, 0) +#define STARFIVE_JH7110_PLL0_FRAC_OFFSET 0x20 +#define STARFIVE_JH7110_PLL0_FRAC_SHIFT 0 +#define STARFIVE_JH7110_PLL0_FRAC_MASK GENMASK(23, 0) +#define STARFIVE_JH7110_PLL0_POSTDIV1_OFFSET 0x20 +#define STARFIVE_JH7110_PLL0_POSTDIV1_SHIFT 28 +#define STARFIVE_JH7110_PLL0_POSTDIV1_MASK GENMASK(29, 28) +#define STARFIVE_JH7110_PLL0_PREDIV_OFFSET 0x24 +#define STARFIVE_JH7110_PLL0_PREDIV_SHIFT 0 +#define STARFIVE_JH7110_PLL0_PREDIV_MASK GENMASK(5, 0) + +#define STARFIVE_JH7110_PLL1_DACPD_OFFSET 0x24 +#define STARFIVE_JH7110_PLL1_DACPD_SHIFT 15 +#define STARFIVE_JH7110_PLL1_DACPD_MASK BIT(15) +#define STARFIVE_JH7110_PLL1_DSMPD_OFFSET 0x24 +#define STARFIVE_JH7110_PLL1_DSMPD_SHIFT 16 +#define STARFIVE_JH7110_PLL1_DSMPD_MASK BIT(16) +#define STARFIVE_JH7110_PLL1_FBDIV_OFFSET 0x24 +#define STARFIVE_JH7110_PLL1_FBDIV_SHIFT 17 +#define STARFIVE_JH7110_PLL1_FBDIV_MASK GENMASK(28, 17) +#define STARFIVE_JH7110_PLL1_FRAC_OFFSET 0x28 +#define STARFIVE_JH7110_PLL1_FRAC_SHIFT 0 +#define STARFIVE_JH7110_PLL1_FRAC_MASK GENMASK(23, 0) +#define STARFIVE_JH7110_PLL1_POSTDIV1_OFFSET 0x28 +#define STARFIVE_JH7110_PLL1_POSTDIV1_SHIFT 28 +#define STARFIVE_JH7110_PLL1_POSTDIV1_MASK GENMASK(29, 28) +#define STARFIVE_JH7110_PLL1_PREDIV_OFFSET 0x2c +#define STARFIVE_JH7110_PLL1_PREDIV_SHIFT 0 +#define STARFIVE_JH7110_PLL1_PREDIV_MASK GENMASK(5, 0) + +#define STARFIVE_JH7110_PLL2_DACPD_OFFSET 0x2c +#define STARFIVE_JH7110_PLL2_DACPD_SHIFT 15 +#define STARFIVE_JH7110_PLL2_DACPD_MASK BIT(15) +#define STARFIVE_JH7110_PLL2_DSMPD_OFFSET 0x2c +#define STARFIVE_JH7110_PLL2_DSMPD_SHIFT 16 +#define STARFIVE_JH7110_PLL2_DSMPD_MASK BIT(16) +#define STARFIVE_JH7110_PLL2_FBDIV_OFFSET 0x2c +#define STARFIVE_JH7110_PLL2_FBDIV_SHIFT 17 +#define STARFIVE_JH7110_PLL2_FBDIV_MASK GENMASK(28, 17) +#define STARFIVE_JH7110_PLL2_FRAC_OFFSET 0x30 +#define STARFIVE_JH7110_PLL2_FRAC_SHIFT 0 +#define STARFIVE_JH7110_PLL2_FRAC_MASK GENMASK(23, 0) +#define STARFIVE_JH7110_PLL2_POSTDIV1_OFFSET 0x30 +#define STARFIVE_JH7110_PLL2_POSTDIV1_SHIFT 28 +#define STARFIVE_JH7110_PLL2_POSTDIV1_MASK GENMASK(29, 28) +#define STARFIVE_JH7110_PLL2_PREDIV_OFFSET 0x34 +#define STARFIVE_JH7110_PLL2_PREDIV_SHIFT 0 +#define STARFIVE_JH7110_PLL2_PREDIV_MASK GENMASK(5, 0) + +struct jh7110_pll_syscon_offset { + unsigned int dacpd; + unsigned int dsmpd; + unsigned int fbdiv; + unsigned int frac; + unsigned int prediv; + unsigned int postdiv1; +}; + +struct jh7110_pll_syscon_mask { + u32 dacpd; + u32 dsmpd; + u32 fbdiv; + u32 frac; + u32 prediv; + u32 postdiv1; +}; + +struct jh7110_pll_syscon_shift { + char dacpd; + char dsmpd; + char fbdiv; + char frac; + char prediv; + char postdiv1; +}; + +struct jh7110_clk_pll_data { + struct clk_hw hw; + unsigned int idx; + unsigned int freq_select_idx; + + struct jh7110_pll_syscon_offset offset; + struct jh7110_pll_syscon_mask mask; + struct jh7110_pll_syscon_shift shift; +}; + +struct jh7110_clk_pll_priv { + struct device *dev; + struct regmap *syscon_regmap; + struct jh7110_clk_pll_data data[]; +}; + +struct starfive_pll_syscon_value { + unsigned long freq; + u32 prediv; + u32 fbdiv; + u32 postdiv1; +/* Both daxpd and dsmpd set 1 while integer multiple mode */ +/* Both daxpd and dsmpd set 0 while fraction multiple mode */ + u32 dacpd; + u32 dsmpd; +/* frac value should be decimals multiplied by 2^24 */ + u32 frac; +}; + +enum starfive_pll0_freq_index { + PLL0_FREQ_375 = 0, + PLL0_FREQ_500, + PLL0_FREQ_625, + PLL0_FREQ_750, + PLL0_FREQ_875, + PLL0_FREQ_1000, + PLL0_FREQ_1250, + PLL0_FREQ_1375, + PLL0_FREQ_1500, + PLL0_FREQ_MAX +}; + +enum starfive_pll1_freq_index { + PLL1_FREQ_1066 = 0, + PLL1_FREQ_1200, + PLL1_FREQ_1400, + PLL1_FREQ_1600, + PLL1_FREQ_MAX +}; + +enum starfive_pll2_freq_index { + PLL2_FREQ_1188 = 0, + PLL2_FREQ_12288, + PLL2_FREQ_MAX +}; + +/* + * Because the pll frequency is relatively fixed, + * it cannot be set arbitrarily, so it needs a specific configuration. + * PLL0 frequency should be multiple of 125MHz (USB frequency). + */ +static const struct starfive_pll_syscon_value + jh7110_pll0_syscon_freq[] = { + [PLL0_FREQ_375] = { + .freq = 375000000, + .prediv = 8, + .fbdiv = 125, + .postdiv1 = 1, + .dacpd = 1, + .dsmpd = 1, + }, + [PLL0_FREQ_500] = { + .freq = 500000000, + .prediv = 6, + .fbdiv = 125, + .postdiv1 = 1, + .dacpd = 1, + .dsmpd = 1, + }, + [PLL0_FREQ_625] = { + .freq = 625000000, + .prediv = 24, + .fbdiv = 625, + .postdiv1 = 1, + .dacpd = 1, + .dsmpd = 1, + }, + [PLL0_FREQ_750] = { + .freq = 750000000, + .prediv = 4, + .fbdiv = 125, + .postdiv1 = 1, + .dacpd = 1, + .dsmpd = 1, + }, + [PLL0_FREQ_875] = { + .freq = 875000000, + .prediv = 24, + .fbdiv = 875, + .postdiv1 = 1, + .dacpd = 1, + .dsmpd = 1, + }, + [PLL0_FREQ_1000] = { + .freq = 1000000000, + .prediv = 3, + .fbdiv = 125, + .postdiv1 = 1, + .dacpd = 1, + .dsmpd = 1, + }, + [PLL0_FREQ_1250] = { + .freq = 1250000000, + .prediv = 12, + .fbdiv = 625, + .postdiv1 = 1, + .dacpd = 1, + .dsmpd = 1, + }, + [PLL0_FREQ_1375] = { + .freq = 1375000000, + .prediv = 24, + .fbdiv = 1375, + .postdiv1 = 1, + .dacpd = 1, + .dsmpd = 1, + }, + [PLL0_FREQ_1500] = { + .freq = 1500000000, + .prediv = 2, + .fbdiv = 125, + .postdiv1 = 1, + .dacpd = 1, + .dsmpd = 1, + }, +}; + +static const struct starfive_pll_syscon_value + jh7110_pll1_syscon_freq[] = { + [PLL1_FREQ_1066] = { + .freq = 1066000000, + .prediv = 12, + .fbdiv = 533, + .postdiv1 = 1, + .dacpd = 1, + .dsmpd = 1, + }, + [PLL1_FREQ_1200] = { + .freq = 1200000000, + .prediv = 1, + .fbdiv = 50, + .postdiv1 = 1, + .dacpd = 1, + .dsmpd = 1, + }, + [PLL1_FREQ_1400] = { + .freq = 1400000000, + .prediv = 6, + .fbdiv = 350, + .postdiv1 = 1, + .dacpd = 1, + .dsmpd = 1, + }, + [PLL1_FREQ_1600] = { + .freq = 1600000000, + .prediv = 3, + .fbdiv = 200, + .postdiv1 = 1, + .dacpd = 1, + .dsmpd = 1, + }, +}; + +static const struct starfive_pll_syscon_value + jh7110_pll2_syscon_freq[] = { + [PLL2_FREQ_1188] = { + .freq = 1188000000, + .prediv = 2, + .fbdiv = 99, + .postdiv1 = 1, + .dacpd = 1, + .dsmpd = 1, + }, + [PLL2_FREQ_12288] = { + .freq = 1228800000, + .prediv = 5, + .fbdiv = 256, + .postdiv1 = 1, + .dacpd = 1, + .dsmpd = 1, + }, +}; + +#endif From patchwork Thu Mar 16 03:05:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xingyu Wu X-Patchwork-Id: 13176933 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 05D64C61DA4 for ; Thu, 16 Mar 2023 03:05:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=YBH2aCwyUK1ULYNcEhvJ0ftTwxG55m70CHBHbQZVUfA=; b=4928ntALurYnsx BL2uNqR/+CO3FjLOZEvMHrWpfA/Pq8nSXZgcTsDGNGvNPac5UsqoPzn1u4LBGclvoHX5W5WDgNssm N3+z+69nILUm6fyuD27cDL9KZ0PJ/AA1QlBmuwIbqXhe5DjT/hCcAsxgKiMZI8Z6/dWEMDXRpBBbY q5sxca62o4K9BtX2yr+susEdZz570FwOAyvgLaO6i5owfP6yvpREAkbK8yu0h7iFhpbkf+NDD3JVb UsXctfWo5DOiDw6AmmYCPBsfiPqDmo96Ls8fOVzIYN2jr57fjIPm6Rkx6fuikkYINSoQQAcOipF7I teAfkoz1vSu2jpES/5GA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pcdvs-00F3CT-1n; Thu, 16 Mar 2023 03:05:36 +0000 Received: from ex01.ufhost.com ([61.152.239.75]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pcdvo-00F3AU-2t for linux-riscv@lists.infradead.org; Thu, 16 Mar 2023 03:05:34 +0000 Received: from EXMBX166.cuchost.com (unknown [175.102.18.54]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "EXMBX166", Issuer "EXMBX166" (not verified)) by ex01.ufhost.com (Postfix) with ESMTP id 4142324E207; Thu, 16 Mar 2023 11:05:19 +0800 (CST) Received: from EXMBX061.cuchost.com (172.16.6.61) by EXMBX166.cuchost.com (172.16.6.76) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 16 Mar 2023 11:05:19 +0800 Received: from localhost.localdomain (113.72.145.194) by EXMBX061.cuchost.com (172.16.6.61) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 16 Mar 2023 11:05:17 +0800 From: Xingyu Wu To: , , "Michael Turquette" , Stephen Boyd , Krzysztof Kozlowski , Philipp Zabel , Conor Dooley , "Emil Renner Berthing" CC: Rob Herring , Paul Walmsley , Palmer Dabbelt , Albert Ou , Hal Feng , Xingyu Wu , William Qiu , , Subject: [PATCH v2 3/6] dt-bindings: soc: starfive: syscon: Add optional patternProperties Date: Thu, 16 Mar 2023 11:05:11 +0800 Message-ID: <20230316030514.137427-4-xingyu.wu@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230316030514.137427-1-xingyu.wu@starfivetech.com> References: <20230316030514.137427-1-xingyu.wu@starfivetech.com> MIME-Version: 1.0 X-Originating-IP: [113.72.145.194] X-ClientProxiedBy: EXCAS064.cuchost.com (172.16.6.24) To EXMBX061.cuchost.com (172.16.6.61) X-YovoleRuleAgent: yovoleflag X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230315_200533_239133_3588549F X-CRM114-Status: UNSURE ( 9.23 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add optional compatible and patternProperties. Signed-off-by: Xingyu Wu --- .../soc/starfive/starfive,jh7110-syscon.yaml | 39 ++++++++++++++++--- 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/Documentation/devicetree/bindings/soc/starfive/starfive,jh7110-syscon.yaml b/Documentation/devicetree/bindings/soc/starfive/starfive,jh7110-syscon.yaml index ae7f1d6916af..b61d8921ef42 100644 --- a/Documentation/devicetree/bindings/soc/starfive/starfive,jh7110-syscon.yaml +++ b/Documentation/devicetree/bindings/soc/starfive/starfive,jh7110-syscon.yaml @@ -15,16 +15,31 @@ description: | properties: compatible: - items: - - enum: - - starfive,jh7110-aon-syscon - - starfive,jh7110-stg-syscon - - starfive,jh7110-sys-syscon - - const: syscon + oneOf: + - items: + - enum: + - starfive,jh7110-aon-syscon + - starfive,jh7110-stg-syscon + - starfive,jh7110-sys-syscon + - const: syscon + - items: + - enum: + - starfive,jh7110-aon-syscon + - starfive,jh7110-stg-syscon + - starfive,jh7110-sys-syscon + - const: syscon + - const: simple-mfd reg: maxItems: 1 +patternProperties: + # Optional children + "pll-clock-controller": + type: object + $ref: /schemas/clock/starfive,jh7110-pll.yaml# + description: Clock provider for PLL. + required: - compatible - reg @@ -38,4 +53,16 @@ examples: reg = <0x10240000 0x1000>; }; + - | + syscon@13030000 { + compatible = "starfive,jh7110-sys-syscon", "syscon", "simple-mfd"; + reg = <0x13030000 0x1000>; + + pll-clock-controller { + compatible = "starfive,jh7110-pll"; + clocks = <&osc>; + #clock-cells = <1>; + }; + }; + ... From patchwork Thu Mar 16 03:05:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xingyu Wu X-Patchwork-Id: 13176937 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 11DE3C6FD1D for ; Thu, 16 Mar 2023 03:05:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hIgyFm9/i4QMyWJjsj9HWEjE8fRv0UJ8dP414oELV68=; b=rhWSSGLfbXBnuF REyojKij/p8PAquJIFtBjKFE9GByPAI3bGynDyTI+em+aFKqwRE0L7Chs4W/OVuWgNzDD/6bb2Aew RmJYEw7YSwLQkFGbYyF9RmQvYNyfwybqX8X2WUVbuv3jEwisqxlNKGRDx0BhZbQov9MnvnJmwt6yX qoCGcDa3b8dgR+Bz1spsG6Pm0vtrr4Z8hn3/+jG+T0fNbmBzFpWVGbiIIMxlmQEjkBU/F6eluitfe PPt/z6fRPtzsrUCSNIWA6znLn/ISREQaO/6gICspLoqq9os3ZwKmSheqPNUShD2SmssWvSkoyPWgu U5Vv8J7h93zGLQ7xI1Ag==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pcdw6-00F3IA-00; Thu, 16 Mar 2023 03:05:50 +0000 Received: from fd01.gateway.ufhost.com ([61.152.239.71]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pcdvz-00F3B3-20 for linux-riscv@lists.infradead.org; Thu, 16 Mar 2023 03:05:46 +0000 Received: from EXMBX165.cuchost.com (unknown [175.102.18.54]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "EXMBX165", Issuer "EXMBX165" (not verified)) by fd01.gateway.ufhost.com (Postfix) with ESMTP id 35AD624E0D6; Thu, 16 Mar 2023 11:05:20 +0800 (CST) Received: from EXMBX061.cuchost.com (172.16.6.61) by EXMBX165.cuchost.com (172.16.6.75) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 16 Mar 2023 11:05:20 +0800 Received: from localhost.localdomain (113.72.145.194) by EXMBX061.cuchost.com (172.16.6.61) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 16 Mar 2023 11:05:18 +0800 From: Xingyu Wu To: , , "Michael Turquette" , Stephen Boyd , Krzysztof Kozlowski , Philipp Zabel , Conor Dooley , "Emil Renner Berthing" CC: Rob Herring , Paul Walmsley , Palmer Dabbelt , Albert Ou , Hal Feng , Xingyu Wu , William Qiu , , Subject: [PATCH v2 4/6] dt-bindings: clock: jh7110-syscrg: Add PLL clock inputs Date: Thu, 16 Mar 2023 11:05:12 +0800 Message-ID: <20230316030514.137427-5-xingyu.wu@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230316030514.137427-1-xingyu.wu@starfivetech.com> References: <20230316030514.137427-1-xingyu.wu@starfivetech.com> MIME-Version: 1.0 X-Originating-IP: [113.72.145.194] X-ClientProxiedBy: EXCAS064.cuchost.com (172.16.6.24) To EXMBX061.cuchost.com (172.16.6.61) X-YovoleRuleAgent: yovoleflag X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230315_200543_945555_94778B1F X-CRM114-Status: UNSURE ( 8.63 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add PLL clock inputs from PLL clock generator. Signed-off-by: Xingyu Wu Acked-by: Krzysztof Kozlowski --- .../clock/starfive,jh7110-syscrg.yaml | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/clock/starfive,jh7110-syscrg.yaml b/Documentation/devicetree/bindings/clock/starfive,jh7110-syscrg.yaml index 84373ae31644..55d4e7f09cd5 100644 --- a/Documentation/devicetree/bindings/clock/starfive,jh7110-syscrg.yaml +++ b/Documentation/devicetree/bindings/clock/starfive,jh7110-syscrg.yaml @@ -27,6 +27,9 @@ properties: - description: External I2S RX left/right channel clock - description: External TDM clock - description: External audio master clock + - description: PLL0 + - description: PLL1 + - description: PLL2 - items: - description: Main Oscillator (24 MHz) @@ -38,6 +41,9 @@ properties: - description: External I2S RX left/right channel clock - description: External TDM clock - description: External audio master clock + - description: PLL0 + - description: PLL1 + - description: PLL2 clock-names: oneOf: @@ -52,6 +58,9 @@ properties: - const: i2srx_lrck_ext - const: tdm_ext - const: mclk_ext + - const: pll0_out + - const: pll1_out + - const: pll2_out - items: - const: osc @@ -63,6 +72,9 @@ properties: - const: i2srx_lrck_ext - const: tdm_ext - const: mclk_ext + - const: pll0_out + - const: pll1_out + - const: pll2_out '#clock-cells': const: 1 @@ -93,12 +105,16 @@ examples: <&gmac1_rgmii_rxin>, <&i2stx_bclk_ext>, <&i2stx_lrck_ext>, <&i2srx_bclk_ext>, <&i2srx_lrck_ext>, - <&tdm_ext>, <&mclk_ext>; + <&tdm_ext>, <&mclk_ext>, + <&pllclk JH7110_CLK_PLL0_OUT>, + <&pllclk JH7110_CLK_PLL1_OUT>, + <&pllclk JH7110_CLK_PLL2_OUT>; clock-names = "osc", "gmac1_rmii_refin", "gmac1_rgmii_rxin", "i2stx_bclk_ext", "i2stx_lrck_ext", "i2srx_bclk_ext", "i2srx_lrck_ext", - "tdm_ext", "mclk_ext"; + "tdm_ext", "mclk_ext", + "pll0_out", "pll1_out", "pll2_out"; #clock-cells = <1>; #reset-cells = <1>; }; From patchwork Thu Mar 16 03:05:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xingyu Wu X-Patchwork-Id: 13176939 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EFF60C7618D for ; Thu, 16 Mar 2023 03:05:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=XhCHfW/+z3YlGDJ309PS7LGjaldKxGtcdiuHXWfPDuY=; b=e1iv4SgXjFLdMC A3T79daxvYujj4x4UAZC6LgvcDW5u/2WFP2DkAURSPLaiwzVA7o82TYpXETVKUKoCJphlDq4VyFgm hVfnvOd4+S7aa404GbfmFhPdwrBpx0HDEhgqnx9jUPxzOgK9WYvs/yfGFISvEGgCzJJYvuk91OJcS bN+jdtUa7hmy8y4fjjEsIac1tR2IXZegx8id08tnUGaqobAkjo9r1akHfhuV/efq59X3tGqw2dP8X PW4jhA9NkaSB8wEA3NdMfz8M4MS7elB5JLGek28vXHNUWykPhLA/RU16ebD+48gu1L0iHKDy84rc1 PU5wSEEq1Gt0eGyzq5SQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pcdw6-00F3IW-1e; Thu, 16 Mar 2023 03:05:50 +0000 Received: from fd01.gateway.ufhost.com ([61.152.239.71]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pcdvz-00F3B4-20 for linux-riscv@lists.infradead.org; Thu, 16 Mar 2023 03:05:46 +0000 Received: from EXMBX166.cuchost.com (unknown [175.102.18.54]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "EXMBX166", Issuer "EXMBX166" (not verified)) by fd01.gateway.ufhost.com (Postfix) with ESMTP id 21D6824E2AB; Thu, 16 Mar 2023 11:05:21 +0800 (CST) Received: from EXMBX061.cuchost.com (172.16.6.61) by EXMBX166.cuchost.com (172.16.6.76) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 16 Mar 2023 11:05:21 +0800 Received: from localhost.localdomain (113.72.145.194) by EXMBX061.cuchost.com (172.16.6.61) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 16 Mar 2023 11:05:19 +0800 From: Xingyu Wu To: , , "Michael Turquette" , Stephen Boyd , Krzysztof Kozlowski , Philipp Zabel , Conor Dooley , "Emil Renner Berthing" CC: Rob Herring , Paul Walmsley , Palmer Dabbelt , Albert Ou , Hal Feng , Xingyu Wu , William Qiu , , Subject: [PATCH v2 5/6] clk: starfive: jh7110-sys: Modify PLL clocks source Date: Thu, 16 Mar 2023 11:05:13 +0800 Message-ID: <20230316030514.137427-6-xingyu.wu@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230316030514.137427-1-xingyu.wu@starfivetech.com> References: <20230316030514.137427-1-xingyu.wu@starfivetech.com> MIME-Version: 1.0 X-Originating-IP: [113.72.145.194] X-ClientProxiedBy: EXCAS064.cuchost.com (172.16.6.24) To EXMBX061.cuchost.com (172.16.6.61) X-YovoleRuleAgent: yovoleflag X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230315_200543_955794_94770175 X-CRM114-Status: GOOD ( 14.30 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Modify PLL clocks source to be got from dts instead of the fixed factor clocks. Signed-off-by: Xingyu Wu --- drivers/clk/starfive/Kconfig | 1 + .../clk/starfive/clk-starfive-jh7110-sys.c | 35 ++++--------------- 2 files changed, 7 insertions(+), 29 deletions(-) diff --git a/drivers/clk/starfive/Kconfig b/drivers/clk/starfive/Kconfig index e306edf4defa..903a5097c642 100644 --- a/drivers/clk/starfive/Kconfig +++ b/drivers/clk/starfive/Kconfig @@ -35,6 +35,7 @@ config CLK_STARFIVE_JH7110_SYS select AUXILIARY_BUS select CLK_STARFIVE_JH71X0 select RESET_STARFIVE_JH7110 + select CLK_STARFIVE_JH7110_PLL default ARCH_STARFIVE help Say yes here to support the system clock controller on the diff --git a/drivers/clk/starfive/clk-starfive-jh7110-sys.c b/drivers/clk/starfive/clk-starfive-jh7110-sys.c index b90d8035ba18..4bd8ff5ff912 100644 --- a/drivers/clk/starfive/clk-starfive-jh7110-sys.c +++ b/drivers/clk/starfive/clk-starfive-jh7110-sys.c @@ -329,9 +329,6 @@ static struct clk_hw *jh7110_sysclk_get(struct of_phandle_args *clkspec, void *d if (idx < JH7110_SYSCLK_END) return &priv->reg[idx].hw; - if (idx >= JH7110_SYSCLK_PLL0_OUT && idx <= JH7110_SYSCLK_PLL2_OUT) - return priv->pll[idx - JH7110_SYSCLK_PLL0_OUT]; - return ERR_PTR(-EINVAL); } @@ -355,29 +352,6 @@ static int __init jh7110_syscrg_probe(struct platform_device *pdev) dev_set_drvdata(priv->dev, (void *)(&priv->base)); - /* - * These PLL clocks are not actually fixed factor clocks and can be - * controlled by the syscon registers of JH7110. They will be dropped - * and registered in the PLL clock driver instead. - */ - /* 24MHz -> 1000.0MHz */ - priv->pll[0] = devm_clk_hw_register_fixed_factor(priv->dev, "pll0_out", - "osc", 0, 125, 3); - if (IS_ERR(priv->pll[0])) - return PTR_ERR(priv->pll[0]); - - /* 24MHz -> 1066.0MHz */ - priv->pll[1] = devm_clk_hw_register_fixed_factor(priv->dev, "pll1_out", - "osc", 0, 533, 12); - if (IS_ERR(priv->pll[1])) - return PTR_ERR(priv->pll[1]); - - /* 24MHz -> 1188.0MHz */ - priv->pll[2] = devm_clk_hw_register_fixed_factor(priv->dev, "pll2_out", - "osc", 0, 99, 2); - if (IS_ERR(priv->pll[2])) - return PTR_ERR(priv->pll[2]); - for (idx = 0; idx < JH7110_SYSCLK_END; idx++) { u32 max = jh7110_sysclk_data[idx].max; struct clk_parent_data parents[4] = {}; @@ -415,9 +389,12 @@ static int __init jh7110_syscrg_probe(struct platform_device *pdev) parents[i].fw_name = "tdm_ext"; else if (pidx == JH7110_SYSCLK_MCLK_EXT) parents[i].fw_name = "mclk_ext"; - else if (pidx >= JH7110_SYSCLK_PLL0_OUT && - pidx <= JH7110_SYSCLK_PLL2_OUT) - parents[i].hw = priv->pll[pidx - JH7110_SYSCLK_PLL0_OUT]; + else if (pidx == JH7110_SYSCLK_PLL0_OUT) + parents[i].fw_name = "pll0_out"; + else if (pidx == JH7110_SYSCLK_PLL1_OUT) + parents[i].fw_name = "pll1_out"; + else if (pidx == JH7110_SYSCLK_PLL2_OUT) + parents[i].fw_name = "pll2_out"; } clk->hw.init = &init; From patchwork Thu Mar 16 03:05:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xingyu Wu X-Patchwork-Id: 13176935 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3DCA2C61DA4 for ; Thu, 16 Mar 2023 03:05:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=YpZYl+0obSps+Xz/bMV5GpiwkpAkhd2NSVzhmZSzo1I=; b=4/dKl84fagvnl1 HXza26HDN5GKs3nBLgPefcZw2pRGgacobmpFf/QGUcEzUpfdaMcT06J1OpAXbI+e4MnzXfC7fuxeU ljze/Ox5S8Rr58JcqpQ/wLeh8aFKCYKDlWRwtQsCoXHTJtVVyvB49n/2ThwmMgrKJl9EJY2xLmxSQ NUaHdZld309UjnAZu8z2hFiEwGdM1f1TrUxa/x3k60uhf//K+/D03MF6rhKWAk4fEulyEgvGkihx4 mMWC9z01e3LNhNb4ufyQL/e8ND1adZmPBmsvHm5S+399TCIb+Y+Q1VafAIWRA6on1mRqrLFVt6K1Q ZIOYoGaxT6iyuQ59R4iQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pcdw2-00F3Gd-14; Thu, 16 Mar 2023 03:05:46 +0000 Received: from fd01.gateway.ufhost.com ([61.152.239.71]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pcdvz-00F3B5-20 for linux-riscv@lists.infradead.org; Thu, 16 Mar 2023 03:05:45 +0000 Received: from EXMBX165.cuchost.com (unknown [175.102.18.54]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "EXMBX165", Issuer "EXMBX165" (not verified)) by fd01.gateway.ufhost.com (Postfix) with ESMTP id EFADD24E2B2; Thu, 16 Mar 2023 11:05:21 +0800 (CST) Received: from EXMBX061.cuchost.com (172.16.6.61) by EXMBX165.cuchost.com (172.16.6.75) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 16 Mar 2023 11:05:21 +0800 Received: from localhost.localdomain (113.72.145.194) by EXMBX061.cuchost.com (172.16.6.61) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 16 Mar 2023 11:05:20 +0800 From: Xingyu Wu To: , , "Michael Turquette" , Stephen Boyd , Krzysztof Kozlowski , Philipp Zabel , Conor Dooley , "Emil Renner Berthing" CC: Rob Herring , Paul Walmsley , Palmer Dabbelt , Albert Ou , Hal Feng , Xingyu Wu , William Qiu , , Subject: [PATCH v2 6/6] riscv: dts: starfive: jh7110: Add PLL clock node and modify syscrg node Date: Thu, 16 Mar 2023 11:05:14 +0800 Message-ID: <20230316030514.137427-7-xingyu.wu@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230316030514.137427-1-xingyu.wu@starfivetech.com> References: <20230316030514.137427-1-xingyu.wu@starfivetech.com> MIME-Version: 1.0 X-Originating-IP: [113.72.145.194] X-ClientProxiedBy: EXCAS064.cuchost.com (172.16.6.24) To EXMBX061.cuchost.com (172.16.6.61) X-YovoleRuleAgent: yovoleflag X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230315_200543_803336_0A937F9E X-CRM114-Status: UNSURE ( 9.60 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add the PLL clock node for the Starfive JH7110 SoC and modify the SYSCRG node to add PLL clocks. Signed-off-by: Xingyu Wu --- arch/riscv/boot/dts/starfive/jh7110.dtsi | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/arch/riscv/boot/dts/starfive/jh7110.dtsi b/arch/riscv/boot/dts/starfive/jh7110.dtsi index 49dd62276b0d..37ccd4600da8 100644 --- a/arch/riscv/boot/dts/starfive/jh7110.dtsi +++ b/arch/riscv/boot/dts/starfive/jh7110.dtsi @@ -461,19 +461,29 @@ syscrg: clock-controller@13020000 { <&gmac1_rgmii_rxin>, <&i2stx_bclk_ext>, <&i2stx_lrck_ext>, <&i2srx_bclk_ext>, <&i2srx_lrck_ext>, - <&tdm_ext>, <&mclk_ext>; + <&tdm_ext>, <&mclk_ext>, + <&pllclk JH7110_CLK_PLL0_OUT>, + <&pllclk JH7110_CLK_PLL1_OUT>, + <&pllclk JH7110_CLK_PLL2_OUT>; clock-names = "osc", "gmac1_rmii_refin", "gmac1_rgmii_rxin", "i2stx_bclk_ext", "i2stx_lrck_ext", "i2srx_bclk_ext", "i2srx_lrck_ext", - "tdm_ext", "mclk_ext"; + "tdm_ext", "mclk_ext", + "pll0_out", "pll1_out", "pll2_out"; #clock-cells = <1>; #reset-cells = <1>; }; sys_syscon: syscon@13030000 { - compatible = "starfive,jh7110-sys-syscon", "syscon"; + compatible = "starfive,jh7110-sys-syscon", "syscon", "simple-mfd"; reg = <0x0 0x13030000 0x0 0x1000>; + + pllclk: pll-clock-controller { + compatible = "starfive,jh7110-pll"; + clocks = <&osc>; + #clock-cells = <1>; + }; }; sysgpio: pinctrl@13040000 {