From patchwork Fri Apr 14 02:41:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xingyu Wu X-Patchwork-Id: 13210893 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 9C3FFC77B78 for ; Fri, 14 Apr 2023 02:43: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=M3cdd4OsiY+WwbDjoxW4j7eIP+oDLS7xbho+Sm6IOiY=; b=T1jVAxMPJTyvAO uh9B3+OgYgNIGJlpfwHC4Np5a53DPGRZD+oXlK+7y0ZXbK6o/PzDknw43I2zAv2o9H5bBcuoN6rpu fZ0GnOU7JINPH/qq+TtPDl1qo00SY2pLOuC3a+ED2fTj/R1QrsLE1Vpxck39i9Y25uX/ZcF9rPs3I EGt1oikx0nS53+JO0kjTS4Ho+I4XGRnFCJKHgzxNJJULp//SF77gnbK82DQVpMyRZlpXR/JpNW642 sZjjmB/CXffbifaQMiW1IQnY1qOCuqo466K/jAx/9VY22pBuQWYrDzVvGIQmmmhLBznVHgFMd0kBS haWj22RpWCu1Hc/0vHeQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pn9PV-008AEY-1q; Fri, 14 Apr 2023 02:43:37 +0000 Received: from ex01.ufhost.com ([61.152.239.75]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pn9PN-008A71-1z for linux-riscv@lists.infradead.org; Fri, 14 Apr 2023 02:43:33 +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 2BBC924E207; Fri, 14 Apr 2023 10:42:57 +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; Fri, 14 Apr 2023 10:42:57 +0800 Received: from localhost.localdomain (183.27.97.249) by EXMBX061.cuchost.com (172.16.6.61) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Fri, 14 Apr 2023 10:42:55 +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 v3 1/7] dt-bindings: clock: Add StarFive JH7110 PLL clock generator Date: Fri, 14 Apr 2023 10:41:51 +0800 Message-ID: <20230414024157.53203-2-xingyu.wu@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230414024157.53203-1-xingyu.wu@starfivetech.com> References: <20230414024157.53203-1-xingyu.wu@starfivetech.com> MIME-Version: 1.0 X-Originating-IP: [183.27.97.249] X-ClientProxiedBy: EXCAS066.cuchost.com (172.16.6.26) 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-20230413_194329_983181_FAAB8332 X-CRM114-Status: GOOD ( 13.37 ) 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. Reviewed-by: Krzysztof Kozlowski Signed-off-by: Xingyu Wu --- .../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..8aa8c7b8e42f --- /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: + - | + 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 Fri Apr 14 02:41:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xingyu Wu X-Patchwork-Id: 13210896 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 C6E33C77B71 for ; Fri, 14 Apr 2023 02:43:46 +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=IcNpaqIDebbzi289L62H9l+tkbgnAXRQDKAUToKdvto=; b=reOKtpd5YgTcob vovOlO94WKTcCkbjSZlLcxAfAWduzoQxbZEFL2Re7jiVWW13sy54qh5HTjsYbzYBlxesnj5g9QXni ztTt8EUXdU0fEcolsRn7mEdTu4AY3yUXE8enZQWYuzBTDbiVPsdKmr+1LaiSelgBfxxkAAC7qVV0S KEx6eWR/frm4nHDR7ZNbpZHbt9hTHB7EgyTyDaxN7CGE53an9yI/VY0yFTzACaA8nOFynm7UWunXi BSqJOj/Kz7ol/Ef+6sVo/+Z5mjSsRXgaXZ7EOftDnt0PwbEn5RZTs97yidlj/N+5DzzrB9U533o9A bBaodMDZLxBsD6GeSBpg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pn9PX-008AFa-2p; Fri, 14 Apr 2023 02:43:39 +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 1pn9PN-008A7O-2V for linux-riscv@lists.infradead.org; Fri, 14 Apr 2023 02:43: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 fd01.gateway.ufhost.com (Postfix) with ESMTP id 2936F24DB8C; Fri, 14 Apr 2023 10:42:58 +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; Fri, 14 Apr 2023 10:42:58 +0800 Received: from localhost.localdomain (183.27.97.249) by EXMBX061.cuchost.com (172.16.6.61) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Fri, 14 Apr 2023 10:42:56 +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 v3 2/7] clk: starfive: Add StarFive JH7110 PLL clock driver Date: Fri, 14 Apr 2023 10:41:52 +0800 Message-ID: <20230414024157.53203-3-xingyu.wu@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230414024157.53203-1-xingyu.wu@starfivetech.com> References: <20230414024157.53203-1-xingyu.wu@starfivetech.com> MIME-Version: 1.0 X-Originating-IP: [183.27.97.249] X-ClientProxiedBy: EXCAS066.cuchost.com (172.16.6.26) 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-20230413_194330_299316_6B729A1C X-CRM114-Status: GOOD ( 25.91 ) 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 and they work by reading and setting syscon registers. Signed-off-by: Xingyu Wu --- MAINTAINERS | 6 + drivers/clk/starfive/Kconfig | 8 + drivers/clk/starfive/Makefile | 1 + .../clk/starfive/clk-starfive-jh7110-pll.c | 427 ++++++++++++++++++ .../clk/starfive/clk-starfive-jh7110-pll.h | 293 ++++++++++++ 5 files changed, 735 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/MAINTAINERS b/MAINTAINERS index 4c0b39c44957..03051ae2e9e5 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -19911,6 +19911,12 @@ S: Supported F: Documentation/devicetree/bindings/mmc/starfive* F: drivers/mmc/host/dw_mmc-starfive.c +STARFIVE JH7110 PLL CLOCK DRIVER +M: Xingyu Wu +S: Supported +F: Documentation/devicetree/bindings/clock/starfive,jh7110-pll.yaml +F: drivers/clk/starfive/clk-starfive-jh7110-pll.* + STARFIVE JH71X0 CLOCK DRIVERS M: Emil Renner Berthing M: Hal Feng 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..43d707ea45c7 --- /dev/null +++ b/drivers/clk/starfive/clk-starfive-jh7110-pll.c @@ -0,0 +1,427 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * StarFive JH7110 PLL Clock Generator Driver + * + * Copyright (C) 2023 StarFive Technology Co., Ltd. + * + * 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 + +#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_val; + + if (regmap_read(priv->syscon_regmap, offset->dacpd, ®_val)) + goto read_error; + dacpd = (reg_val & mask->dacpd) >> shift->dacpd; + + if (regmap_read(priv->syscon_regmap, offset->dsmpd, ®_val)) + goto read_error; + dsmpd = (reg_val & mask->dsmpd) >> shift->dsmpd; + + if (regmap_read(priv->syscon_regmap, offset->fbdiv, ®_val)) + goto read_error; + fbdiv = (reg_val & mask->fbdiv) >> shift->fbdiv; + /* fbdiv value should be 8 to 4095 */ + if (fbdiv < 8) + goto read_error; + + if (regmap_read(priv->syscon_regmap, offset->prediv, ®_val)) + goto read_error; + prediv = (reg_val & mask->prediv) >> shift->prediv; + + if (regmap_read(priv->syscon_regmap, offset->postdiv1, ®_val)) + goto read_error; + /* postdiv1 = 2 ^ reg_val */ + postdiv1 = 1 << ((reg_val & mask->postdiv1) >> shift->postdiv1); + + if (regmap_read(priv->syscon_regmap, offset->frac, ®_val)) + goto read_error; + frac = (reg_val & 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_error; + + /* Fvco = Fref * (NI + NF) / M / Q1 */ + freq = parent_rate / STARFIVE_PLL_FRAC_PATR_SIZE * + (fbdiv * STARFIVE_PLL_FRAC_PATR_SIZE + frac_cal) / prediv / postdiv1; + +read_error: + return freq; +} + +static unsigned long jh7110_pll_rate_sub_fabs(unsigned long rate1, unsigned long rate2) +{ + return rate1 > rate2 ? (rate1 - rate2) : (rate2 - rate1); +} + +/* Select the appropriate frequency from the already configured registers value */ +static void jh7110_pll_select_near_freq_id(struct jh7110_clk_pll_data *data, + unsigned long rate) +{ + const struct starfive_pll_syscon_value *syscon_val; + unsigned int id; + unsigned int pll_arry_size; + unsigned long rate_diff; + + 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); + + /* compare the frequency one by one from small to large in order */ + for (id = 0; id < pll_arry_size; id++) { + if (data->idx == JH7110_CLK_PLL0_OUT) + syscon_val = &jh7110_pll0_syscon_freq[id]; + else if (data->idx == JH7110_CLK_PLL1_OUT) + syscon_val = &jh7110_pll1_syscon_freq[id]; + else + syscon_val = &jh7110_pll2_syscon_freq[id]; + + if (rate == syscon_val->freq) + goto match_end; + + /* select near frequency */ + if (rate < syscon_val->freq) { + /* The last frequency is closer to the target rate than this time. */ + if (id > 0) + if (rate_diff < jh7110_pll_rate_sub_fabs(rate, syscon_val->freq)) + id--; + + goto match_end; + } else { + rate_diff = jh7110_pll_rate_sub_fabs(rate, syscon_val->freq); + } + } + +match_end: + data->freq_select_idx = id; +} + +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_val; + int ret; + + if (data->idx == JH7110_CLK_PLL0_OUT) + syscon_val = &jh7110_pll0_syscon_freq[freq_idx]; + else if (data->idx == JH7110_CLK_PLL1_OUT) + syscon_val = &jh7110_pll1_syscon_freq[freq_idx]; + else + syscon_val = &jh7110_pll2_syscon_freq[freq_idx]; + + ret = regmap_update_bits(priv->syscon_regmap, offset->dacpd, mask->dacpd, + (syscon_val->dacpd << shift->dacpd)); + if (ret) + goto set_failed; + + ret = regmap_update_bits(priv->syscon_regmap, offset->dsmpd, mask->dsmpd, + (syscon_val->dsmpd << shift->dsmpd)); + if (ret) + goto set_failed; + + ret = regmap_update_bits(priv->syscon_regmap, offset->prediv, mask->prediv, + (syscon_val->prediv << shift->prediv)); + if (ret) + goto set_failed; + + ret = regmap_update_bits(priv->syscon_regmap, offset->fbdiv, mask->fbdiv, + (syscon_val->fbdiv << shift->fbdiv)); + if (ret) + goto set_failed; + + ret = regmap_update_bits(priv->syscon_regmap, offset->postdiv1, mask->postdiv1, + ((syscon_val->postdiv1 >> 1) << shift->postdiv1)); + if (ret) + goto set_failed; + + /* frac: Integer Mode (Both 1) or Fraction Mode (Both 0) */ + if (syscon_val->dacpd == 0 && syscon_val->dsmpd == 0) + ret = regmap_update_bits(priv->syscon_regmap, offset->frac, mask->frac, + (syscon_val->frac << shift->frac)); + else if (syscon_val->dacpd != syscon_val->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); + + jh7110_pll_select_near_freq_id(data, req->rate); + + 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..2cbfa9630c98 --- /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) 2023 StarFive Technology Co., Ltd. + */ + +#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 mode */ +/* Both daxpd and dsmpd set 0 while fraction 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_MAX] = { + [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_MAX] = { + [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_MAX] = { + [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 Fri Apr 14 02:41:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xingyu Wu X-Patchwork-Id: 13210891 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 F2D0DC77B71 for ; Fri, 14 Apr 2023 02:43:42 +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=MdUnlqhK8hQoiSQS7SXOXRkawtFZce+LfJNAeyYYtkU=; b=zxeAiCeJrJxkRg FN9mrdNoxT0//gWtPZstEghYdADmWAH0lEnTDOMBDk0ZdZWot7W6nZGlTSLgvDzu8Ov5uUzZlH3fa JQI/HltuWWgrbi+bq0TIzJGuQi6u0aHZsg6vklHk9EJcrIkghEdfjS+8hmoDY/0UngvZoMOUXarmi frstWlkvmyVTbEpOY1KLaJUQPFETdIw8bW7CdIGm5F30OFiU7d/XT5fFeUDFsQfSlI8iA/+dLyNpF dZ1QqWr8gMchStMc3WtYOhYfj03HiRg8oCya6360naXWyDcvP6WcwOm0vHgkcD4cVavl8wGxkOh0l AmdkyKoRYxrfV63XOjBA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pn9PU-008AE0-1g; Fri, 14 Apr 2023 02:43:36 +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 1pn9PN-008A7M-2V for linux-riscv@lists.infradead.org; Fri, 14 Apr 2023 02:43:33 +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 F3F5024E1B3; Fri, 14 Apr 2023 10:42:58 +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; Fri, 14 Apr 2023 10:42:58 +0800 Received: from localhost.localdomain (183.27.97.249) by EXMBX061.cuchost.com (172.16.6.61) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Fri, 14 Apr 2023 10:42:57 +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 v3 3/7] dt-bindings: clock: jh7110-syscrg: Add PLL clock inputs Date: Fri, 14 Apr 2023 10:41:53 +0800 Message-ID: <20230414024157.53203-4-xingyu.wu@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230414024157.53203-1-xingyu.wu@starfivetech.com> References: <20230414024157.53203-1-xingyu.wu@starfivetech.com> MIME-Version: 1.0 X-Originating-IP: [183.27.97.249] X-ClientProxiedBy: EXCAS066.cuchost.com (172.16.6.26) 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-20230413_194330_127941_36E69FD2 X-CRM114-Status: UNSURE ( 8.31 ) 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. Acked-by: Krzysztof Kozlowski Signed-off-by: Xingyu Wu --- .../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 Fri Apr 14 02:41:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xingyu Wu X-Patchwork-Id: 13210894 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 43570C77B73 for ; Fri, 14 Apr 2023 02:43:42 +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=DdWW5sWnWydtOIltLHnDzrVdC33Hp7mGGs8VUjDYEu4=; b=2Cvs+EwTQwaP6h Wtfr+QOHWG1W9quuYFeLV8fvWztA1SzIBUBFbic2MjRlesgk+L8cDMfB5Mo22rVbfDPSFUPKC5Wyq xlx1i78SqqH94qaSsEtRzNfWt3dMagHMU/7fYN/FK9FmJu7cqi1OC/GvhvyupxDQJ5Pthref+ggxQ 0gEz4esOtMI6kTXPN64O77OdZ1g9/+BTtIi47+LSNeUClDjfKoICcxkqrNUdb78pSoRq44tXYHFY5 /S+dFE5Te+HB/ZfunfqQYaif8uXs8f2UMWi8XPotIEDlZfHWnXj3LyeUuy/S+6VzOEphM4lpYoasD BvnuYjRfklTL9934vhjw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pn9PT-008ADf-3A; Fri, 14 Apr 2023 02:43:35 +0000 Received: from ex01.ufhost.com ([61.152.239.75]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pn9PN-008A73-1z for linux-riscv@lists.infradead.org; Fri, 14 Apr 2023 02:43:33 +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 D4F4124E27E; Fri, 14 Apr 2023 10:42:59 +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; Fri, 14 Apr 2023 10:42:59 +0800 Received: from localhost.localdomain (183.27.97.249) by EXMBX061.cuchost.com (172.16.6.61) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Fri, 14 Apr 2023 10:42:58 +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 v3 4/7] clk: starfive: jh7110-sys: Modify PLL clocks source Date: Fri, 14 Apr 2023 10:41:54 +0800 Message-ID: <20230414024157.53203-5-xingyu.wu@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230414024157.53203-1-xingyu.wu@starfivetech.com> References: <20230414024157.53203-1-xingyu.wu@starfivetech.com> MIME-Version: 1.0 X-Originating-IP: [183.27.97.249] X-ClientProxiedBy: EXCAS066.cuchost.com (172.16.6.26) 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-20230413_194329_977179_032A91E8 X-CRM114-Status: GOOD ( 13.92 ) 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 | 31 ++++--------------- 2 files changed, 7 insertions(+), 25 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 5ec210644e1d..439999dc2191 100644 --- a/drivers/clk/starfive/clk-starfive-jh7110-sys.c +++ b/drivers/clk/starfive/clk-starfive-jh7110-sys.c @@ -395,29 +395,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] = {}; @@ -455,8 +432,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 - 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 Fri Apr 14 02:41:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xingyu Wu X-Patchwork-Id: 13210892 X-Patchwork-Delegate: mail@conchuod.ie 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 5B841C77B77 for ; Fri, 14 Apr 2023 02:43: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=JvnffkgDn2uw9fIvTzdelJSCwpfutwGh2WEmUSeq208=; b=CUUh2FfWy4MASa k9yd5pe9jwgkVW5773nfX+l7zSA8NLRQtp+2tuZe/Xg+yAGo0biYtirLO5RLDwd7LXLIFpkuGtsLJ OTaH40JbRvoWlTWpv+BrWOU05sKSfAohP7Y3frTnXoK1flRC9Znwn1qvOntqUf2J1JS5OnPqAA6MY Dqeb65H+3ryb2DV6AGso53yT6d2YfAnYov9PsokX/XZdl03NrezlXdg/CvxJK1hquX473qfzOg2ik aQLMVFdi3NCISP0UmqSMBmqRMcsUxBPt5zOQi8mfkQqsNzbnD26vZ1huldolOPoKgCjNFvefaBd2r nFpfJ4SupmxAG389O0kg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pn9PV-008AEJ-09; Fri, 14 Apr 2023 02:43:37 +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 1pn9PN-008A7N-2V for linux-riscv@lists.infradead.org; Fri, 14 Apr 2023 02:43:33 +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 C011024E0F6; Fri, 14 Apr 2023 10:43:00 +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; Fri, 14 Apr 2023 10:43:00 +0800 Received: from localhost.localdomain (183.27.97.249) by EXMBX061.cuchost.com (172.16.6.61) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Fri, 14 Apr 2023 10:42:59 +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 v3 5/7] dt-bindings: soc: starfive: Add StarFive syscon module Date: Fri, 14 Apr 2023 10:41:55 +0800 Message-ID: <20230414024157.53203-6-xingyu.wu@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230414024157.53203-1-xingyu.wu@starfivetech.com> References: <20230414024157.53203-1-xingyu.wu@starfivetech.com> MIME-Version: 1.0 X-Originating-IP: [183.27.97.249] X-ClientProxiedBy: EXCAS066.cuchost.com (172.16.6.26) 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-20230413_194330_144887_BA2F2856 X-CRM114-Status: GOOD ( 12.82 ) 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 From: William Qiu Add documentation to describe StarFive System Controller Registers. Signed-off-by: William Qiu Reviewed-by: Rob Herring --- .../soc/starfive/starfive,jh7110-syscon.yaml | 58 +++++++++++++++++++ MAINTAINERS | 6 ++ 2 files changed, 64 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/starfive/starfive,jh7110-syscon.yaml diff --git a/Documentation/devicetree/bindings/soc/starfive/starfive,jh7110-syscon.yaml b/Documentation/devicetree/bindings/soc/starfive/starfive,jh7110-syscon.yaml new file mode 100644 index 000000000000..de086e74a229 --- /dev/null +++ b/Documentation/devicetree/bindings/soc/starfive/starfive,jh7110-syscon.yaml @@ -0,0 +1,58 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/soc/starfive/starfive,jh7110-syscon.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: StarFive JH7110 SoC system controller + +maintainers: + - William Qiu + +description: | + The StarFive JH7110 SoC system controller provides register information such + as offset, mask and shift to configure related modules such as MMC and PCIe. + +properties: + compatible: + oneOf: + - items: + - enum: + - starfive,jh7110-aon-syscon + - starfive,jh7110-sys-syscon + - const: syscon + - const: simple-mfd + - items: + - const: starfive,jh7110-stg-syscon + - const: syscon + + reg: + maxItems: 1 + + clock-controller: + $ref: /schemas/clock/starfive,jh7110-pll.yaml# + type: object + + power-controller: + $ref: /schemas/power/starfive,jh7110-pmu.yaml# + type: object + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + syscon@10240000 { + compatible = "starfive,jh7110-stg-syscon", "syscon"; + reg = <0x10240000 0x1000>; + }; + + syscon@13030000 { + compatible = "starfive,jh7110-sys-syscon", "syscon", "simple-mfd"; + reg = <0x13030000 0x1000>; + }; + +... diff --git a/MAINTAINERS b/MAINTAINERS index 03051ae2e9e5..0fafeea8ebdb 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -19917,6 +19917,11 @@ S: Supported F: Documentation/devicetree/bindings/clock/starfive,jh7110-pll.yaml F: drivers/clk/starfive/clk-starfive-jh7110-pll.* +STARFIVE JH7110 SYSCON +M: William Qiu +S: Supported +F: Documentation/devicetree/bindings/soc/starfive/starfive,jh7110-syscon.yaml + STARFIVE JH71X0 CLOCK DRIVERS M: Emil Renner Berthing M: Hal Feng @@ -19954,6 +19959,7 @@ STARFIVE SOC DRIVERS M: Conor Dooley S: Maintained T: git https://git.kernel.org/pub/scm/linux/kernel/git/conor/linux.git/ +F: Documentation/devicetree/bindings/soc/starfive/ F: drivers/soc/starfive/ STARFIVE TRNG DRIVER From patchwork Fri Apr 14 02:41:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xingyu Wu X-Patchwork-Id: 13210890 X-Patchwork-Delegate: mail@conchuod.ie 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 952BEC77B61 for ; Fri, 14 Apr 2023 02:43:41 +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=2A14iLG0h2zGrZyUmNieDX34W+XNFjckwWUrT1KLgnU=; b=XvKl1RB6JNszaE 7ACy7RH3JcMIiTPejMRd8tQFTKkEjjt31qrA0MXKM50ayoyrge57fFyulJfrqLOADPw9HvHpP3z8N YaN3jwAytf3V0jsiPAKAfWSgpUowCrt0+QWgh6NhUtn68uLxGOZT/NBTIaW1JDsFmOi/Fi/SjScd/ EZgxmeVp9fDh0ie45DZ5vxZQzRvcSPhTpU4xN4LPmM9qPuZDI7e9/pwZzG6rpYNLAZXcsfPOeaaTE c3Rvcjvb6xkT2/5kEe9kY821l2HehQKGR2k75I/NXR9oYqJoMrl+5E8MVQ1BpBIciB4Eksa0rzntM jsseaVg5jfubU23KJxTA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pn9PR-008ACf-1P; Fri, 14 Apr 2023 02:43:33 +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 1pn9PN-008A7P-2W for linux-riscv@lists.infradead.org; Fri, 14 Apr 2023 02:43:31 +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 9A0BF24E1D1; Fri, 14 Apr 2023 10:43:01 +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; Fri, 14 Apr 2023 10:43:01 +0800 Received: from localhost.localdomain (183.27.97.249) by EXMBX061.cuchost.com (172.16.6.61) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Fri, 14 Apr 2023 10:43:00 +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 v3 6/7] riscv: dts: starfive: jh7110: Add syscon nodes Date: Fri, 14 Apr 2023 10:41:56 +0800 Message-ID: <20230414024157.53203-7-xingyu.wu@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230414024157.53203-1-xingyu.wu@starfivetech.com> References: <20230414024157.53203-1-xingyu.wu@starfivetech.com> MIME-Version: 1.0 X-Originating-IP: [183.27.97.249] X-ClientProxiedBy: EXCAS066.cuchost.com (172.16.6.26) 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-20230413_194329_983261_538AEE6B X-CRM114-Status: UNSURE ( 8.73 ) 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 From: William Qiu Add stg_syscon/sys_syscon/aon_syscon nodes for JH7110 Soc. Signed-off-by: William Qiu Reviewed-by: Conor Dooley Reviewed-by: Emil Renner Berthing --- arch/riscv/boot/dts/starfive/jh7110.dtsi | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/arch/riscv/boot/dts/starfive/jh7110.dtsi b/arch/riscv/boot/dts/starfive/jh7110.dtsi index 4c5fdb905da8..f271c3184d3a 100644 --- a/arch/riscv/boot/dts/starfive/jh7110.dtsi +++ b/arch/riscv/boot/dts/starfive/jh7110.dtsi @@ -353,6 +353,11 @@ i2c2: i2c@10050000 { status = "disabled"; }; + stg_syscon: syscon@10240000 { + compatible = "starfive,jh7110-stg-syscon", "syscon"; + reg = <0x0 0x10240000 0x0 0x1000>; + }; + uart3: serial@12000000 { compatible = "snps,dw-apb-uart"; reg = <0x0 0x12000000 0x0 0x10000>; @@ -457,6 +462,11 @@ syscrg: clock-controller@13020000 { #reset-cells = <1>; }; + sys_syscon: syscon@13030000 { + compatible = "starfive,jh7110-sys-syscon", "syscon", "simple-mfd"; + reg = <0x0 0x13030000 0x0 0x1000>; + }; + sysgpio: pinctrl@13040000 { compatible = "starfive,jh7110-sys-pinctrl"; reg = <0x0 0x13040000 0x0 0x10000>; @@ -486,6 +496,11 @@ aoncrg: clock-controller@17000000 { #reset-cells = <1>; }; + aon_syscon: syscon@17010000 { + compatible = "starfive,jh7110-aon-syscon", "syscon", "simple-mfd"; + reg = <0x0 0x17010000 0x0 0x1000>; + }; + aongpio: pinctrl@17020000 { compatible = "starfive,jh7110-aon-pinctrl"; reg = <0x0 0x17020000 0x0 0x10000>; From patchwork Fri Apr 14 02:41:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xingyu Wu X-Patchwork-Id: 13210889 X-Patchwork-Delegate: mail@conchuod.ie 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 2D04EC77B6E for ; Fri, 14 Apr 2023 02:43:41 +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=KqiOlbwsq+h6ObvPx4bopJ0YJ5A2kCg1+MAp1Pw6gJ0=; b=AqnfPw7nKE0rs2 Flgn/J8kZOxQu2DJlWvMdd0Ip7+Qn8C+vC7eY1szvgtx6B3e72FI3qvR4TGKC8klRTtlXIedpH+Gs MX9Lbt6rzvIAT1aJwRJ3BE6149fW6i1t9XGAfsjufPslDGMylJGZzzaqFqZ0XKF7mYRs0SACEcMnC YqyNrYZ0fuZz7ufajL/0uT5ySYVxZVhhSUsjMhP7V9DoDI7LtSVh+RRR2a1m00Z+LfQkucg+vZFRj +ZDbnz1Erda2/6Fjta5pq5Tetb/MqBhyBgeGynTCDtA7T0Ek+OCiYS7h67KmDjixNnwBhDUNmsVkW 4gvr8GziAPmUGoXav3Fg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pn9PS-008ADC-1J; Fri, 14 Apr 2023 02:43:34 +0000 Received: from ex01.ufhost.com ([61.152.239.75]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pn9PN-008A72-1z for linux-riscv@lists.infradead.org; Fri, 14 Apr 2023 02:43:31 +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 79FF224E282; Fri, 14 Apr 2023 10:43:02 +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; Fri, 14 Apr 2023 10:43:02 +0800 Received: from localhost.localdomain (183.27.97.249) by EXMBX061.cuchost.com (172.16.6.61) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Fri, 14 Apr 2023 10:43:01 +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 v3 7/7] riscv: dts: starfive: jh7110: Add PLL clock node and modify syscrg node Date: Fri, 14 Apr 2023 10:41:57 +0800 Message-ID: <20230414024157.53203-8-xingyu.wu@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230414024157.53203-1-xingyu.wu@starfivetech.com> References: <20230414024157.53203-1-xingyu.wu@starfivetech.com> MIME-Version: 1.0 X-Originating-IP: [183.27.97.249] X-ClientProxiedBy: EXCAS066.cuchost.com (172.16.6.26) 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-20230413_194329_819248_C5D323F2 X-CRM114-Status: UNSURE ( 9.51 ) 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 input. Signed-off-by: Xingyu Wu --- arch/riscv/boot/dts/starfive/jh7110.dtsi | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/arch/riscv/boot/dts/starfive/jh7110.dtsi b/arch/riscv/boot/dts/starfive/jh7110.dtsi index f271c3184d3a..27f8ef37d029 100644 --- a/arch/riscv/boot/dts/starfive/jh7110.dtsi +++ b/arch/riscv/boot/dts/starfive/jh7110.dtsi @@ -452,12 +452,16 @@ 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>; }; @@ -465,6 +469,12 @@ syscrg: clock-controller@13020000 { sys_syscon: syscon@13030000 { compatible = "starfive,jh7110-sys-syscon", "syscon", "simple-mfd"; reg = <0x0 0x13030000 0x0 0x1000>; + + pllclk: clock-controller { + compatible = "starfive,jh7110-pll"; + clocks = <&osc>; + #clock-cells = <1>; + }; }; sysgpio: pinctrl@13040000 {