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: 70552 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp257435wrt; Wed, 15 Mar 2023 20:10:39 -0700 (PDT) X-Google-Smtp-Source: AK7set/FzgwhOchAH8nFtKL4ODnAPXNja9knbYSwBB0G/BkPTWd15ezjT4Wkf+8FPEJZFA75sh0v X-Received: by 2002:a17:90b:4b84:b0:23d:3c7b:8684 with SMTP id lr4-20020a17090b4b8400b0023d3c7b8684mr2193096pjb.41.1678936239586; Wed, 15 Mar 2023 20:10:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678936239; cv=none; d=google.com; s=arc-20160816; b=Tswgx7WjOV336DbT1Pp6GH6L65pwt4LEYGWtljcXQ2s59Ln2FNw9Tgo3Ur0awUbPnA KOH+Uqk5B434vduBv41gG62n6asF+gFipQzheETWTyF48sE0vDtbIRovBAwIviz7o9k6 xgPX426DqJS3YTYe7BUTCiI38WjKOmUdnJAlm3G0QEj+LWwVdT9MiN0UHjVKWoW6FgYH CtsKFR8KAqcQ5b+HsMFX9Yd/YIrYZFiz0ezuI3/G90IFMw3OcJlVdCXxLNs9Dq+KIlL6 D7rJ+4gEDKimNj7hCCoHGcwuCjke1L1j7SOyTkHjfnNOSDfB3mQJbKZW5WBnARrYmSfA 661A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=E9bThVpg+mLWnONwxd8bQaHmZUZNWq/8h5NfZf80Iw8=; b=yw/0ZaYZdu0jyViN/dbsgdyC2uthc+MUxOMbeMC6E0IjtyTmAeNj6uzYqn8KtUnypp n1TvFEhBmomSLxTPGAVU36kzXNqwdIE4JY1KM7S3s9G3maCR/S3l9IiTEQ8TJ7uN+KC4 mNCbTLRbIPcSJbo7tzr19/j1PEqIuKVecbT5hyRG2RwaquReMHSo1FJRbPZA0HW4htoZ xWmqoBthw9yee/u5t9iKg9qena2mNngvjA7BuxPlXfgJGHN/bf5opqiTVl1lzDACGJJA lRqEMnOaqNwJ2KgQu/LUDfGYeQjV1AY2haqhZmCLYPGhaMGl8Am+vlcb2rUByjGiGipY 73Qw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x5-20020a17090a9dc500b0023b4e4bc44asi3332720pjv.149.2023.03.15.20.10.24; Wed, 15 Mar 2023 20:10:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229691AbjCPDFj convert rfc822-to-8bit (ORCPT + 99 others); Wed, 15 Mar 2023 23:05:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229827AbjCPDFX (ORCPT ); Wed, 15 Mar 2023 23:05:23 -0400 Received: from fd01.gateway.ufhost.com (fd01.gateway.ufhost.com [61.152.239.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88429422A; Wed, 15 Mar 2023 20:05:21 -0700 (PDT) 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760492245870170939?= X-GMAIL-MSGID: =?utf-8?q?1760492245870170939?= 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: 70550 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp257150wrt; Wed, 15 Mar 2023 20:09:48 -0700 (PDT) X-Google-Smtp-Source: AK7set/OoqBUTLJoOAuW1C0hYNLyvx0FZ8z+DHfgoNmNdzwGojfZTFzgO5dgNZGaHZHKvG8LnPw2 X-Received: by 2002:a17:902:db08:b0:1a0:6bd4:ea79 with SMTP id m8-20020a170902db0800b001a06bd4ea79mr1995997plx.58.1678936188021; Wed, 15 Mar 2023 20:09:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678936188; cv=none; d=google.com; s=arc-20160816; b=jV1DAWhNdg1jO5NS7065RrEggsVbEA+ZqP/xBx+bVyUP93qk6btl6EacZaZgxq5aZw Ejwyvhc7Vf5dGN2iKx4G9LsPRJZnsTHWsCTMgy+uNnonCYI96iyc6Ye561VLhymFS7BX ki10B26geLqrx+wMcIzMhaqmnuvg90I8gBkpAhJOr6nZk7ErDmYv01U2ngxrWia9FDOx VipxNNClUW+2nNV6O7WkjiHKLddJfVR9B/vdHkopzFvrBDer2ALLt4um5IT7R76q2/70 ryLliCkPUtpH5coGRnK9Tk0HEGgX9TO2MHCb9Zi+UFXfqQMaUI82qaJDDW5r5WxDqgKw +HLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=WnWLhmxNXSor/GldsGF7FCLtsuCg1k2cIMNCzGdnhLg=; b=DWpVlNUuXTeA8oO4DFtx5C0XtSWwQNziTQGieQtWuVO1FTHmZT3x/xliHzKWX0eg/e MMUtM0IoLyog7eOwOXi834BofW6CBGTSGw60pSq3U9CFzDPyI+lG2bW+4FgffP6CKKUR FeHKxqSYvpFbS4GLHW8eZu1UWn1oFHM0bJauv42lDWRX4JWP4yFGDqTz2r/S9IpV0Ip/ pwyWQep3q1Sm+Q/tncymUSQ7sx/q53gusdk13yg82hEq+KM4gALEmYjO3oim+dzTuX1o gXftCmwutqxA62aAXNWRX6JJn4drcFxbi63rK5rvxsfSh9rICiJHbPS9xb/dJrzAP3UB VROg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j5-20020a170902da8500b0019f33cb669asi2601419plx.615.2023.03.15.20.09.31; Wed, 15 Mar 2023 20:09:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229932AbjCPDFn convert rfc822-to-8bit (ORCPT + 99 others); Wed, 15 Mar 2023 23:05:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229841AbjCPDFZ (ORCPT ); Wed, 15 Mar 2023 23:05:25 -0400 Received: from ex01.ufhost.com (ex01.ufhost.com [61.152.239.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D35D1FD4; Wed, 15 Mar 2023 20:05:19 -0700 (PDT) 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760492192552710118?= X-GMAIL-MSGID: =?utf-8?q?1760492192552710118?= 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: 70553 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp257543wrt; Wed, 15 Mar 2023 20:10:59 -0700 (PDT) X-Google-Smtp-Source: AK7set/VrBOr286KjceZOZwj5Rv/FEE48SU8tgucqOLo1jrKBLUm6rW7Ek2WoCHOCQPcSzA0t9LV X-Received: by 2002:a05:6102:f86:b0:425:d18f:5771 with SMTP id e6-20020a0561020f8600b00425d18f5771mr2496301vsv.5.1678936259495; Wed, 15 Mar 2023 20:10:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678936259; cv=none; d=google.com; s=arc-20160816; b=OTJzsPLAmsL4f5aHZNOAcmU/QV7mZBY21aV/j/2gKWoGUgRfZZ0LGW/EbL401qV9zx CVvbPsdhBxrzqTBwuZUD3lnmW2Lz1DffGGWu0S2LrlzZwquL/GrLpoMJ23jLPMg75hUm sGvu4A6scYYvm7zoTOyNXxpd1B+3qTVizMLMVGBRztTQEzAoaXSdordvmcGAA/lgRfrd WORsj5xRzS5XJwsseAog81XGdHR44K3JlklrKYB1JwCfyoxtP8QMFP86YPnXDSbDX42s j/OKW03VQl9lD93Nfg7KqushBrmJQkPRATHo89AAdVD2xkyeCUFapNKXxYM0f+jRfswQ 0FrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=l8zBD3HfHpO9b8ZvjnoF1WOvMpsxtV4xsTTqEgicbAY=; b=nvKnU9y/tIPB+gxLI8+tl3lefP0nOeHRIW6veGldQsTPFcDvo/w7Bym5/aszKYivAp 4G5j0olfyQ41KibH/e+Eg/8to+CC6xikCwrUge+hQh0VoOSfv5fxZHsKS879JkkXOYHi L07xeliakMDQ04zIAXIVgKphCW0R7+uoIXs5beVWr8gFM9t0+lUtyB/mwcJce+Xl6IG6 a6mlg4tGjrWBHV4igab3hCqGmxuW7n1NLvT/wrMSR2/FZPVoHd+A9Fyo1V2OITjZh25S RYz5wq/8yl1GfbxBFVyGVlQqTeOG0hxePrUqdkGyqHnIMmYZOApC8Kk6SoDL+XjoN2mV lr5w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p2-20020ab03b82000000b00753be25739fsi3350573uaw.32.2023.03.15.20.10.43; Wed, 15 Mar 2023 20:10:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229872AbjCPDFf convert rfc822-to-8bit (ORCPT + 99 others); Wed, 15 Mar 2023 23:05:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229816AbjCPDFW (ORCPT ); Wed, 15 Mar 2023 23:05:22 -0400 Received: from ex01.ufhost.com (ex01.ufhost.com [61.152.239.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88B2640E6; Wed, 15 Mar 2023 20:05:20 -0700 (PDT) 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760492266812084519?= X-GMAIL-MSGID: =?utf-8?q?1760492266812084519?= 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: 70549 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp256214wrt; Wed, 15 Mar 2023 20:07:07 -0700 (PDT) X-Google-Smtp-Source: AK7set9TjaWVp4O2zctHULiLWIPnOpA/baHWV7yPIuB4ED+feF9/qWA/xjaP8OOThzRcKh6n5Mxy X-Received: by 2002:a05:6a20:918c:b0:d3:e4d8:a684 with SMTP id v12-20020a056a20918c00b000d3e4d8a684mr2319136pzd.7.1678936027166; Wed, 15 Mar 2023 20:07:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678936027; cv=none; d=google.com; s=arc-20160816; b=HeZo+kh0lvxGD/b5RNedxFu8AwU0oqKJQAc2N3sGU2g3//xDC/jy/tczveLaMy4AgX w2zQ8wZW5vGvvTF3/0EdOsfLBRAo0lzZjpJbYsuyYwKPamk5k4pHReyKW2DsafrTcJYk qIbel98HRzUgy8IAKMVeX0uaC2FOlbjJF69YJPBBxJ+As/3RHjajQyRjGz8v/7DcMNxl c0XV0fESiFyV+KSPZiHBKFKyXVdoS3z2Dhjtoa0LexkcqVXOEi/r4s4owNut5HRNkYh0 dEFKUqRN1e+sRmWrU27novd94uvoHgLMJ+ao9K5RbaF1vMtIvAYl27S23vRS4BZYXLG1 w4DA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=VJPOrRYDG8O6lmaoZnFeypk9HcojwWL4T8zcMMWzTCc=; b=wn8n2fyUSIDjk/+sfgkgE8KpISXXP2Sc/EDf4gjJgafBbI6TEmOT7fLavE7yHAD18Q Sq8v9D8SqRASbImig1dXD6C0PXEXnh69UPtKYl1orRKUYGEFbIn6DyTw1SaFs1X1aM4Q i+rRZsrB8o6n5/2wm9dQwQLJhbqyyGTPki9rHh74a5UhFrJJ0SO7Euihu3sRufxejJZa BP92Mud849FHbT0ENd1TeWzIh5B5G+rLiPWLKEDXrE3BRhd9mPUOB93pqrUPyiYnpp5W Zul6eNeYaELqaREHm0SUE8bJonA3LzhukdGNIaHcVx3jQGl6feXApLLFa8HMzR28i3te RBjA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cw10-20020a056a00450a00b005a8bf47f5d7si6400882pfb.207.2023.03.15.20.06.52; Wed, 15 Mar 2023 20:07:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230018AbjCPDFt convert rfc822-to-8bit (ORCPT + 99 others); Wed, 15 Mar 2023 23:05:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229844AbjCPDFZ (ORCPT ); Wed, 15 Mar 2023 23:05:25 -0400 Received: from fd01.gateway.ufhost.com (fd01.gateway.ufhost.com [61.152.239.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB6B24ED2; Wed, 15 Mar 2023 20:05:21 -0700 (PDT) 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760492023771471765?= X-GMAIL-MSGID: =?utf-8?q?1760492023771471765?= 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: 70551 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp257160wrt; Wed, 15 Mar 2023 20:09:50 -0700 (PDT) X-Google-Smtp-Source: AK7set9douWFhcdk5bHEb/TnUwF9mqYWJ0NUMUL8HdoLo8fNEn+jYyVrWPvQa4XH99O3swqfpK8S X-Received: by 2002:a05:6a20:c52f:b0:d4:2cc1:c7cd with SMTP id gm47-20020a056a20c52f00b000d42cc1c7cdmr1867969pzb.18.1678936190430; Wed, 15 Mar 2023 20:09:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678936190; cv=none; d=google.com; s=arc-20160816; b=XUoKd+wAuTVyjygzDUYWx/xSdV6AovXZ1C0u6QdUIClDP0GEtX/zgUuxc54eIcM1Ay RE4a4gV6XCzV91Kb4sbOy9VzjJepYXa/oJPx9Qr6FuhlIq9100Qh157dwXPhoQ+7D4me CFS1AIH4jYYUUs7GTo06T0nKiVbJLtM8l55wDyzcLDtmYRcgUTvCSgjNdkdOiC9GBMm7 2DhADKJFi5Efk1z7VEAdLyYIhuYOeUV+qTXFKn0AEVY7JQlHSRB6wDjNdoZh86KAaA3Z t9TIO1BUr4povdc1u7XDcMhlQPEgazV6m3e08QLKKoyU/gKkl3B25nZRgez+5ZrNAlr+ Mrjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=l1JeMCKG1/QetA3u/RD1xQvszXIJoMBhnccjEaEsgIo=; b=p6ODL3r9eAsF41IXAV6GFrRxJpvnvnZQbnWkw7f4EJQwke1+9gF9hIf7r+0vHfP7o5 f7+Ql+38k4laXzZQF2BYXKsQglnX/Pi35A5BL8eqZXJYdiWWnQOgsqsMc0LA52tGOgiI /7UFInU0Awlaotsh6ckk9tl1JR9stXuMAo2OPbW/7xBZCQGn6sYORu5noGdjpIOrfxMd eIVZZ5s9h2Pou9GffdPI6qrbbWHLrBX7H1rvICXU1Xgx3OPqusdrzlIOkMXzQrQUqqrn jrjFpJnZjmv7cS+jGhqcIqymO2lCFoZzogb+X11wfKprtke5LoKjlg3EDa93E6PZEnec GXcA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e71-20020a63694a000000b0050bd9c8922bsi4103896pgc.364.2023.03.15.20.09.34; Wed, 15 Mar 2023 20:09:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230044AbjCPDFv convert rfc822-to-8bit (ORCPT + 99 others); Wed, 15 Mar 2023 23:05:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229845AbjCPDFZ (ORCPT ); Wed, 15 Mar 2023 23:05:25 -0400 Received: from fd01.gateway.ufhost.com (fd01.gateway.ufhost.com [61.152.239.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72CC71FDC; Wed, 15 Mar 2023 20:05:22 -0700 (PDT) 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760492194774024494?= X-GMAIL-MSGID: =?utf-8?q?1760492194774024494?= 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: 70548 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp256162wrt; Wed, 15 Mar 2023 20:06:56 -0700 (PDT) X-Google-Smtp-Source: AK7set+73HdIVXpqpBddMtPJqVgH/G6mucz5xiM+1P6w96z6nV2du6yXWVNJ6HmKO67UKOg7r4rE X-Received: by 2002:a17:902:fa48:b0:1a0:4fb2:6623 with SMTP id lb8-20020a170902fa4800b001a04fb26623mr1393400plb.40.1678936016559; Wed, 15 Mar 2023 20:06:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678936016; cv=none; d=google.com; s=arc-20160816; b=tz8/QZmzgDUrhJppx07HlyAnWUV8CLsiRsvgRQtuPPBPxzJrp3X0JdSS1/Nbi8iV6A ozdd1Z1LJKnfpmzHAgEDudlJWvY1fYe+5fQZYzVOg8QM/IEfvJS5LQFxHgRx+La08u03 5V0s/LBBMzAewP2MsysMLO98wlA/SquAK9SPKHFU5HxwPmbGCnpdsD2IAmsWyPbOuLOx RheHwXqz2hQ4YQa3W8D0z7i8DfLe5hHO8EKPAahwfV1Xuzw5Wp9xnZ7hMf6yxP6ZD9g8 druu3w1xw8PtEfNh3btaiCbeT6Blzc0zol5PjuGqw+E5ECcsUPG+m7pdlevADKMdF7Bn fTjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=wu/3lVHOkN41vHNOfZ5EZAxy+GkLIwb7TV8ps/699EQ=; b=P19JPPBUZsBSwZ7B3vC+vYZEfU+HmhrDIswfkrwibxRvle9eVZQmjwvlkpXIi87LXB VR494Ror3aI8d8zkjawnTwIlj3uI2x/CDsocHpcZ/peluvhos6aHHZunAwP4HjxeCnJR e8G1sbavIvjdOAvMZnLlUbLMjFuPu5lgza/c/8qSPcAaxU92Yly6Q+zWqWEYJaZso/k0 5B+K9EBWnXjuyqIbqm1Xp0YFWgWSvYMjs2QTAUyjaV4rLJ/MBtN7Pq57opLWxp3CXPFa z1DcJOdVD+2ldJYRAn0a3tssNzLdQQjXJ28e00KC7zz7hl+AtO2Tmz+poYhruEjvVy3v YJ9A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a8-20020a170902ecc800b00194a944fecbsi7896160plh.268.2023.03.15.20.06.41; Wed, 15 Mar 2023 20:06:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229950AbjCPDFp convert rfc822-to-8bit (ORCPT + 99 others); Wed, 15 Mar 2023 23:05:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229793AbjCPDF0 (ORCPT ); Wed, 15 Mar 2023 23:05:26 -0400 Received: from fd01.gateway.ufhost.com (fd01.gateway.ufhost.com [61.152.239.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9830BF951; Wed, 15 Mar 2023 20:05:23 -0700 (PDT) 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760492012638683472?= X-GMAIL-MSGID: =?utf-8?q?1760492012638683472?= 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 {