From patchwork Fri May 12 02:20:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xingyu Wu X-Patchwork-Id: 92924 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp4801833vqo; Thu, 11 May 2023 19:25:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4PYLyBTsxftqQeZLimzgFltIjYA+7ZHzWNIYN2ZodU3kydrPuFw9U2ZGNV4RzzBE2WcZ3u X-Received: by 2002:a05:6a21:32a8:b0:100:60f3:2975 with SMTP id yt40-20020a056a2132a800b0010060f32975mr21361070pzb.4.1683858356623; Thu, 11 May 2023 19:25:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683858356; cv=none; d=google.com; s=arc-20160816; b=S0IPfdBxCxxyHePRr7gJBsG3jDNsoWQyMZDK8Mzt+3N6JnwLjLiTnWC3EmioRjJUnQ g355t3paTW6v+f7lFkSUa6vzXk393bjahtC3HshXX6ykOM7P2ivlSoH1KY3Gcp46W7VE 3mi+53gVE6eUOI1C9LcYy/pIC1Il4G+06hpEXgp+Mu+Sj+f62/kWwS0ozglN8wp/BHIQ W5CWld8/xia9X8Zw9PhsgEttmJpt9+UEy2ivU0Rh5l9USdzrjRPTtDM/rVpqsZ1H0W6r hfT+aP2VqzwhtGK7U8WTcPX+BTCdlm9yxsTTXpFh9c9k3nNaBLwIR6LJ3B8xtPIT/eQV 4f4A== 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=E1D/hT86jY4a9M+Oep7LH+vCGrSRWz0dsvCeYPMH5DY=; b=ThtQcs0E6sjrCDHoDWT6fCImEHHEl2l2gv0dEPqAUtz3W1JHpAmqxOivFlM5zQ6KO+ vqWX580TlHkr39t/AnsY/KPpJcyXfa9Wez9QevQ2Q/h7We5yeAtWtsRfTwi88xRxwAUN 3CDJomopalE/7kVPZ99KPliKzt7mxbxlLIIdL4BZH4w4lhV8rnBkr0dCZBOmj//Z0FBK xbWTux3x1aSOptfjkzakP6fBcRpGd/24rJuP9OTfE/YrL8O8J+3g/yRcbhU3y+o5BQzv 4qJACN2cN6Ova5ON2Xn/dDSRet/zTH2Icix/phVyk8taZN6cet6c1D/IR6exFbmM5Fbv UfMw== 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 u16-20020a63b550000000b0053072cbae67si3633861pgo.379.2023.05.11.19.25.42; Thu, 11 May 2023 19:25: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 S239839AbjELCWj convert rfc822-to-8bit (ORCPT + 99 others); Thu, 11 May 2023 22:22:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239780AbjELCWW (ORCPT ); Thu, 11 May 2023 22:22:22 -0400 Received: from fd01.gateway.ufhost.com (fd01.gateway.ufhost.com [61.152.239.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B90365BA5; Thu, 11 May 2023 19:22:20 -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 00D1E817A; Fri, 12 May 2023 10:22:14 +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, 12 May 2023 10:22:13 +0800 Received: from localhost.localdomain (113.72.146.187) by EXMBX061.cuchost.com (172.16.6.61) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Fri, 12 May 2023 10:22:12 +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 v4 1/7] dt-bindings: clock: Add StarFive JH7110 PLL clock generator Date: Fri, 12 May 2023 10:20:30 +0800 Message-ID: <20230512022036.97987-2-xingyu.wu@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230512022036.97987-1-xingyu.wu@starfivetech.com> References: <20230512022036.97987-1-xingyu.wu@starfivetech.com> MIME-Version: 1.0 X-Originating-IP: [113.72.146.187] X-ClientProxiedBy: EXCAS062.cuchost.com (172.16.6.22) 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_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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?1765653459935625694?= X-GMAIL-MSGID: =?utf-8?q?1765653459935625694?= 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 May 12 02:20:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xingyu Wu X-Patchwork-Id: 92927 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp4805762vqo; Thu, 11 May 2023 19:39:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6wf3OjN34O1MiHEt2iHDmzImL3/l7D1HRK/gOMO+mHIqwrU0diMRY8qvih0ePx7Rxs+xY6 X-Received: by 2002:a17:903:2343:b0:1ac:85b0:1bd8 with SMTP id c3-20020a170903234300b001ac85b01bd8mr15059079plh.34.1683859155204; Thu, 11 May 2023 19:39:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683859155; cv=none; d=google.com; s=arc-20160816; b=D9nj5QSeiVCBwY0Sb+QCzrRcXJBcxynee6ZHst/1EZFrSj1JkTrYAESMMGitvSxfGj aw0s2m2VQ5SKTMVk9OwqAb9Bx5Sln1ITxRPn65PMZkd4McXGcPyQODpOqWK4/wozuu8G hbUZ8ZW0Gy3/epaOK1VTYeY7FxOMbbhGgenz1lH3y0AD4Lc67zWxRqRpcgc9U72xWWDc nh7cwONSVPUVfPHlIo0XCBCnonYI+lxZMmLhpiiIMWRRnNCH5/5hQghW/jGN1avxhEZM CBZOBiAEKwUJB2y5XciKPBsOoDGLCtMKDngIaFoS29qjlb4G3YwlK4WLSpRI7g9ZoNke vqdQ== 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=JErnqIWZYjwFYZ83Qm6RttNYf6L4wOjUur6f4FuJ+Ho=; b=iIJ2z2Cxc+Wixg4q9pMT1VorF6cXti2G/F7ym2waTa6UnWpN22jhIr2c00+w6jij5V WB265E+dDAZ5Liw+xcBGFq7zhHJsxmusUqVJUs+zE/uwJgtFtDjRBQwM7KjxdYxVTQKl b1dy3wm4hN+Y29iRYigQvr8hq8gq5BsgDLwSmxtO7aWRtmqk/atypSTS8UZosLV5D4me ygfB/HPSMx2GQ6A6tUDvth6NLov2W5CZAMmO2aRay9UzLbnY37UCM9cXCylb/F/5AsAb IwkBGNtcnmE2zfkjL6Mvm1wjMSb4FLufiah71+uoHbsiLMvhAv+F3IfunDLH0mLfHot4 qPsw== 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 u11-20020a170902b28b00b001a69d1be166si8021179plr.450.2023.05.11.19.39.01; Thu, 11 May 2023 19:39:15 -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 S239856AbjELCWt convert rfc822-to-8bit (ORCPT + 99 others); Thu, 11 May 2023 22:22:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232858AbjELCWY (ORCPT ); Thu, 11 May 2023 22:22:24 -0400 Received: from ex01.ufhost.com (ex01.ufhost.com [61.152.239.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 481055583; Thu, 11 May 2023 19:22: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 ex01.ufhost.com (Postfix) with ESMTP id EE3B024E28F; Fri, 12 May 2023 10:22:14 +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, 12 May 2023 10:22:15 +0800 Received: from localhost.localdomain (113.72.146.187) by EXMBX061.cuchost.com (172.16.6.61) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Fri, 12 May 2023 10:22:13 +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 v4 2/7] clk: starfive: Add StarFive JH7110 PLL clock driver Date: Fri, 12 May 2023 10:20:31 +0800 Message-ID: <20230512022036.97987-3-xingyu.wu@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230512022036.97987-1-xingyu.wu@starfivetech.com> References: <20230512022036.97987-1-xingyu.wu@starfivetech.com> MIME-Version: 1.0 X-Originating-IP: [113.72.146.187] X-ClientProxiedBy: EXCAS062.cuchost.com (172.16.6.22) 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,T_SCC_BODY_TEXT_LINE 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?1765654297637284548?= X-GMAIL-MSGID: =?utf-8?q?1765654297637284548?= 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 | 309 ++++++++++++++++ .../clk/starfive/clk-starfive-jh7110-pll.h | 331 ++++++++++++++++++ 5 files changed, 655 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 7e0b87d5aa2e..0fb4a703f66f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -20087,6 +20087,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 5d2333106f13..5195f7be5213 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..f86deddd4bef --- /dev/null +++ b/drivers/clk/starfive/clk-starfive-jh7110-pll.c @@ -0,0 +1,309 @@ +// 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" + +struct jh7110_pll_conf_variant { + unsigned int pll_nums; + struct jh7110_pll_syscon_conf conf[]; +}; + +static const struct jh7110_pll_conf_variant jh7110_pll_variant = { + .pll_nums = JH7110_PLLCLK_END, + .conf = { + JH7110_PLL(JH7110_CLK_PLL0_OUT, "pll0_out", + JH7110_PLL0_FREQ_MAX, jh7110_pll0_syscon_val_preset), + JH7110_PLL(JH7110_CLK_PLL1_OUT, "pll1_out", + JH7110_PLL1_FREQ_MAX, jh7110_pll1_syscon_val_preset), + JH7110_PLL(JH7110_CLK_PLL2_OUT, "pll2_out", + JH7110_PLL2_FREQ_MAX, jh7110_pll2_syscon_val_preset), + }, +}; + +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->conf.offsets; + struct jh7110_pll_syscon_mask *mask = &data->conf.masks; + struct jh7110_pll_syscon_shift *shift = &data->conf.shifts; + unsigned long frac_cal; + u32 dacpd; + u32 dsmpd; + u32 fbdiv; + u32 prediv; + u32 postdiv1; + u32 frac; + u32 reg_val; + + regmap_read(priv->syscon_regmap, offset->dacpd, ®_val); + dacpd = (reg_val & mask->dacpd) >> shift->dacpd; + + regmap_read(priv->syscon_regmap, offset->dsmpd, ®_val); + dsmpd = (reg_val & mask->dsmpd) >> shift->dsmpd; + + regmap_read(priv->syscon_regmap, offset->fbdiv, ®_val); + fbdiv = (reg_val & mask->fbdiv) >> shift->fbdiv; + + regmap_read(priv->syscon_regmap, offset->prediv, ®_val); + prediv = (reg_val & mask->prediv) >> shift->prediv; + + regmap_read(priv->syscon_regmap, offset->postdiv1, ®_val); + /* postdiv1 = 2 ^ reg_val */ + postdiv1 = 1 << ((reg_val & mask->postdiv1) >> shift->postdiv1); + + regmap_read(priv->syscon_regmap, offset->frac, ®_val); + 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 + return 0; + + /* Fvco = Fref * (NI + NF) / M / Q1 */ + return (parent_rate / STARFIVE_PLL_FRAC_PATR_SIZE * + (fbdiv * STARFIVE_PLL_FRAC_PATR_SIZE + frac_cal) / prediv / postdiv1); +} + +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 jh7110_pll_syscon_val *val; + unsigned int id; + unsigned long rate_diff; + + /* compare the frequency one by one from small to large in order */ + for (id = 0; id < data->conf.preset_val_nums; id++) { + val = &data->conf.preset_val[id]; + + if (rate == val->freq) + goto match_end; + + /* select near frequency */ + if (rate < 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, val->freq)) + id--; + + goto match_end; + } else { + rate_diff = jh7110_pll_rate_sub_fabs(rate, 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->conf.offsets; + struct jh7110_pll_syscon_mask *mask = &data->conf.masks; + struct jh7110_pll_syscon_shift *shift = &data->conf.shifts; + const struct jh7110_pll_syscon_val *val = &data->conf.preset_val[data->freq_select_idx]; + + /* frac: Integer Mode (Both 1) or Fraction Mode (Both 0) */ + if (val->dacpd == 0 && val->dsmpd == 0) + regmap_update_bits(priv->syscon_regmap, offset->frac, mask->frac, + (val->frac << shift->frac)); + else if (val->dacpd != val->dsmpd) + return -EINVAL; + + /* fbdiv value should be 8 to 4095 */ + if (val->fbdiv < 8) + return -EINVAL; + + regmap_update_bits(priv->syscon_regmap, offset->dacpd, mask->dacpd, + (val->dacpd << shift->dacpd)); + regmap_update_bits(priv->syscon_regmap, offset->dsmpd, mask->dsmpd, + (val->dsmpd << shift->dsmpd)); + regmap_update_bits(priv->syscon_regmap, offset->prediv, mask->prediv, + (val->prediv << shift->prediv)); + regmap_update_bits(priv->syscon_regmap, offset->fbdiv, mask->fbdiv, + (val->fbdiv << shift->fbdiv)); + regmap_update_bits(priv->syscon_regmap, offset->postdiv1, mask->postdiv1, + ((val->postdiv1 >> 1) << shift->postdiv1)); + + return 0; +} + +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); + req->rate = data->conf.preset_val[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, +}; + +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 < priv->pll_nums) + return &priv->data[idx].hw; + + return ERR_PTR(-EINVAL); +} + +static int jh7110_pll_probe(struct platform_device *pdev) +{ + const struct jh7110_pll_conf_variant *variant; + struct jh7110_clk_pll_priv *priv; + struct jh7110_clk_pll_data *data; + int ret; + unsigned int idx; + + variant = of_device_get_match_data(&pdev->dev); + if (!variant) + return -ENOMEM; + + priv = devm_kzalloc(&pdev->dev, struct_size(priv, data, variant->pll_nums), + 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); + + priv->pll_nums = variant->pll_nums; + for (idx = 0; idx < priv->pll_nums; idx++) { + struct clk_parent_data parents = { + .index = 0, + }; + struct clk_init_data init = { + .name = variant->conf[idx].name, + .ops = &jh7110_pll_ops, + .parent_data = &parents, + .num_parents = 1, + .flags = 0, + }; + + data = &priv->data[idx]; + data->conf = variant->conf[idx]; + 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", .data = &jh7110_pll_variant }, + { /* 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..526f21670fe3 --- /dev/null +++ b/drivers/clk/starfive/clk-starfive-jh7110-pll.h @@ -0,0 +1,331 @@ +/* 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_CLK_PLL0_OUT_DACPD_OFFSET 0x18 +#define STARFIVE_JH7110_CLK_PLL0_OUT_DACPD_SHIFT 24 +#define STARFIVE_JH7110_CLK_PLL0_OUT_DACPD_MASK BIT(24) +#define STARFIVE_JH7110_CLK_PLL0_OUT_DSMPD_OFFSET 0x18 +#define STARFIVE_JH7110_CLK_PLL0_OUT_DSMPD_SHIFT 25 +#define STARFIVE_JH7110_CLK_PLL0_OUT_DSMPD_MASK BIT(25) +#define STARFIVE_JH7110_CLK_PLL0_OUT_FBDIV_OFFSET 0x1c +#define STARFIVE_JH7110_CLK_PLL0_OUT_FBDIV_SHIFT 0 +#define STARFIVE_JH7110_CLK_PLL0_OUT_FBDIV_MASK GENMASK(11, 0) +#define STARFIVE_JH7110_CLK_PLL0_OUT_FRAC_OFFSET 0x20 +#define STARFIVE_JH7110_CLK_PLL0_OUT_FRAC_SHIFT 0 +#define STARFIVE_JH7110_CLK_PLL0_OUT_FRAC_MASK GENMASK(23, 0) +#define STARFIVE_JH7110_CLK_PLL0_OUT_POSTDIV1_OFFSET 0x20 +#define STARFIVE_JH7110_CLK_PLL0_OUT_POSTDIV1_SHIFT 28 +#define STARFIVE_JH7110_CLK_PLL0_OUT_POSTDIV1_MASK GENMASK(29, 28) +#define STARFIVE_JH7110_CLK_PLL0_OUT_PREDIV_OFFSET 0x24 +#define STARFIVE_JH7110_CLK_PLL0_OUT_PREDIV_SHIFT 0 +#define STARFIVE_JH7110_CLK_PLL0_OUT_PREDIV_MASK GENMASK(5, 0) + +#define STARFIVE_JH7110_CLK_PLL1_OUT_DACPD_OFFSET 0x24 +#define STARFIVE_JH7110_CLK_PLL1_OUT_DACPD_SHIFT 15 +#define STARFIVE_JH7110_CLK_PLL1_OUT_DACPD_MASK BIT(15) +#define STARFIVE_JH7110_CLK_PLL1_OUT_DSMPD_OFFSET 0x24 +#define STARFIVE_JH7110_CLK_PLL1_OUT_DSMPD_SHIFT 16 +#define STARFIVE_JH7110_CLK_PLL1_OUT_DSMPD_MASK BIT(16) +#define STARFIVE_JH7110_CLK_PLL1_OUT_FBDIV_OFFSET 0x24 +#define STARFIVE_JH7110_CLK_PLL1_OUT_FBDIV_SHIFT 17 +#define STARFIVE_JH7110_CLK_PLL1_OUT_FBDIV_MASK GENMASK(28, 17) +#define STARFIVE_JH7110_CLK_PLL1_OUT_FRAC_OFFSET 0x28 +#define STARFIVE_JH7110_CLK_PLL1_OUT_FRAC_SHIFT 0 +#define STARFIVE_JH7110_CLK_PLL1_OUT_FRAC_MASK GENMASK(23, 0) +#define STARFIVE_JH7110_CLK_PLL1_OUT_POSTDIV1_OFFSET 0x28 +#define STARFIVE_JH7110_CLK_PLL1_OUT_POSTDIV1_SHIFT 28 +#define STARFIVE_JH7110_CLK_PLL1_OUT_POSTDIV1_MASK GENMASK(29, 28) +#define STARFIVE_JH7110_CLK_PLL1_OUT_PREDIV_OFFSET 0x2c +#define STARFIVE_JH7110_CLK_PLL1_OUT_PREDIV_SHIFT 0 +#define STARFIVE_JH7110_CLK_PLL1_OUT_PREDIV_MASK GENMASK(5, 0) + +#define STARFIVE_JH7110_CLK_PLL2_OUT_DACPD_OFFSET 0x2c +#define STARFIVE_JH7110_CLK_PLL2_OUT_DACPD_SHIFT 15 +#define STARFIVE_JH7110_CLK_PLL2_OUT_DACPD_MASK BIT(15) +#define STARFIVE_JH7110_CLK_PLL2_OUT_DSMPD_OFFSET 0x2c +#define STARFIVE_JH7110_CLK_PLL2_OUT_DSMPD_SHIFT 16 +#define STARFIVE_JH7110_CLK_PLL2_OUT_DSMPD_MASK BIT(16) +#define STARFIVE_JH7110_CLK_PLL2_OUT_FBDIV_OFFSET 0x2c +#define STARFIVE_JH7110_CLK_PLL2_OUT_FBDIV_SHIFT 17 +#define STARFIVE_JH7110_CLK_PLL2_OUT_FBDIV_MASK GENMASK(28, 17) +#define STARFIVE_JH7110_CLK_PLL2_OUT_FRAC_OFFSET 0x30 +#define STARFIVE_JH7110_CLK_PLL2_OUT_FRAC_SHIFT 0 +#define STARFIVE_JH7110_CLK_PLL2_OUT_FRAC_MASK GENMASK(23, 0) +#define STARFIVE_JH7110_CLK_PLL2_OUT_POSTDIV1_OFFSET 0x30 +#define STARFIVE_JH7110_CLK_PLL2_OUT_POSTDIV1_SHIFT 28 +#define STARFIVE_JH7110_CLK_PLL2_OUT_POSTDIV1_MASK GENMASK(29, 28) +#define STARFIVE_JH7110_CLK_PLL2_OUT_PREDIV_OFFSET 0x34 +#define STARFIVE_JH7110_CLK_PLL2_OUT_PREDIV_SHIFT 0 +#define STARFIVE_JH7110_CLK_PLL2_OUT_PREDIV_MASK GENMASK(5, 0) + +#define JH7110_PLL(_idx, _name, _nums, _val) \ +[_idx] = { \ + .name = _name, \ + .offsets = { \ + .dacpd = STARFIVE_##_idx##_DACPD_OFFSET, \ + .dsmpd = STARFIVE_##_idx##_DSMPD_OFFSET, \ + .fbdiv = STARFIVE_##_idx##_FBDIV_OFFSET, \ + .frac = STARFIVE_##_idx##_FRAC_OFFSET, \ + .prediv = STARFIVE_##_idx##_PREDIV_OFFSET, \ + .postdiv1 = STARFIVE_##_idx##_POSTDIV1_OFFSET, \ + }, \ + .masks = { \ + .dacpd = STARFIVE_##_idx##_DACPD_MASK, \ + .dsmpd = STARFIVE_##_idx##_DSMPD_MASK, \ + .fbdiv = STARFIVE_##_idx##_FBDIV_MASK, \ + .frac = STARFIVE_##_idx##_FRAC_MASK, \ + .prediv = STARFIVE_##_idx##_PREDIV_MASK, \ + .postdiv1 = STARFIVE_##_idx##_POSTDIV1_MASK, \ + }, \ + .shifts = { \ + .dacpd = STARFIVE_##_idx##_DACPD_SHIFT, \ + .dsmpd = STARFIVE_##_idx##_DSMPD_SHIFT, \ + .fbdiv = STARFIVE_##_idx##_FBDIV_SHIFT, \ + .frac = STARFIVE_##_idx##_FRAC_SHIFT, \ + .prediv = STARFIVE_##_idx##_PREDIV_SHIFT, \ + .postdiv1 = STARFIVE_##_idx##_POSTDIV1_SHIFT, \ + }, \ + .preset_val_nums = _nums, \ + .preset_val = _val, \ +} + +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_pll_syscon_val { + 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; +}; + +struct jh7110_pll_syscon_conf { + char *name; + struct jh7110_pll_syscon_offset offsets; + struct jh7110_pll_syscon_mask masks; + struct jh7110_pll_syscon_shift shifts; + unsigned int preset_val_nums; + const struct jh7110_pll_syscon_val *preset_val; +}; + +struct jh7110_clk_pll_data { + struct clk_hw hw; + unsigned int idx; + unsigned int freq_select_idx; + struct jh7110_pll_syscon_conf conf; +}; + +struct jh7110_clk_pll_priv { + unsigned int pll_nums; + struct device *dev; + struct regmap *syscon_regmap; + struct jh7110_clk_pll_data data[]; +}; + +enum jh7110_pll0_freq_index { + JH7110_PLL0_FREQ_375 = 0, + JH7110_PLL0_FREQ_500, + JH7110_PLL0_FREQ_625, + JH7110_PLL0_FREQ_750, + JH7110_PLL0_FREQ_875, + JH7110_PLL0_FREQ_1000, + JH7110_PLL0_FREQ_1250, + JH7110_PLL0_FREQ_1375, + JH7110_PLL0_FREQ_1500, + JH7110_PLL0_FREQ_MAX +}; + +enum jh7110_pll1_freq_index { + JH7110_PLL1_FREQ_1066 = 0, + JH7110_PLL1_FREQ_1200, + JH7110_PLL1_FREQ_1400, + JH7110_PLL1_FREQ_1600, + JH7110_PLL1_FREQ_MAX +}; + +enum jh7110_pll2_freq_index { + JH7110_PLL2_FREQ_1188 = 0, + JH7110_PLL2_FREQ_12288, + JH7110_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 jh7110_pll_syscon_val + jh7110_pll0_syscon_val_preset[] = { + [JH7110_PLL0_FREQ_375] = { + .freq = 375000000, + .prediv = 8, + .fbdiv = 125, + .postdiv1 = 1, + .dacpd = 1, + .dsmpd = 1, + }, + [JH7110_PLL0_FREQ_500] = { + .freq = 500000000, + .prediv = 6, + .fbdiv = 125, + .postdiv1 = 1, + .dacpd = 1, + .dsmpd = 1, + }, + [JH7110_PLL0_FREQ_625] = { + .freq = 625000000, + .prediv = 24, + .fbdiv = 625, + .postdiv1 = 1, + .dacpd = 1, + .dsmpd = 1, + }, + [JH7110_PLL0_FREQ_750] = { + .freq = 750000000, + .prediv = 4, + .fbdiv = 125, + .postdiv1 = 1, + .dacpd = 1, + .dsmpd = 1, + }, + [JH7110_PLL0_FREQ_875] = { + .freq = 875000000, + .prediv = 24, + .fbdiv = 875, + .postdiv1 = 1, + .dacpd = 1, + .dsmpd = 1, + }, + [JH7110_PLL0_FREQ_1000] = { + .freq = 1000000000, + .prediv = 3, + .fbdiv = 125, + .postdiv1 = 1, + .dacpd = 1, + .dsmpd = 1, + }, + [JH7110_PLL0_FREQ_1250] = { + .freq = 1250000000, + .prediv = 12, + .fbdiv = 625, + .postdiv1 = 1, + .dacpd = 1, + .dsmpd = 1, + }, + [JH7110_PLL0_FREQ_1375] = { + .freq = 1375000000, + .prediv = 24, + .fbdiv = 1375, + .postdiv1 = 1, + .dacpd = 1, + .dsmpd = 1, + }, + [JH7110_PLL0_FREQ_1500] = { + .freq = 1500000000, + .prediv = 2, + .fbdiv = 125, + .postdiv1 = 1, + .dacpd = 1, + .dsmpd = 1, + }, +}; + +static const struct jh7110_pll_syscon_val + jh7110_pll1_syscon_val_preset[] = { + [JH7110_PLL1_FREQ_1066] = { + .freq = 1066000000, + .prediv = 12, + .fbdiv = 533, + .postdiv1 = 1, + .dacpd = 1, + .dsmpd = 1, + }, + [JH7110_PLL1_FREQ_1200] = { + .freq = 1200000000, + .prediv = 1, + .fbdiv = 50, + .postdiv1 = 1, + .dacpd = 1, + .dsmpd = 1, + }, + [JH7110_PLL1_FREQ_1400] = { + .freq = 1400000000, + .prediv = 6, + .fbdiv = 350, + .postdiv1 = 1, + .dacpd = 1, + .dsmpd = 1, + }, + [JH7110_PLL1_FREQ_1600] = { + .freq = 1600000000, + .prediv = 3, + .fbdiv = 200, + .postdiv1 = 1, + .dacpd = 1, + .dsmpd = 1, + }, +}; + +static const struct jh7110_pll_syscon_val + jh7110_pll2_syscon_val_preset[] = { + [JH7110_PLL2_FREQ_1188] = { + .freq = 1188000000, + .prediv = 2, + .fbdiv = 99, + .postdiv1 = 1, + .dacpd = 1, + .dsmpd = 1, + }, + [JH7110_PLL2_FREQ_12288] = { + .freq = 1228800000, + .prediv = 5, + .fbdiv = 256, + .postdiv1 = 1, + .dacpd = 1, + .dsmpd = 1, + }, +}; + +#endif From patchwork Fri May 12 02:20:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xingyu Wu X-Patchwork-Id: 92922 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp4801330vqo; Thu, 11 May 2023 19:24:11 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4Xc1xSkreTW4qrn4pTLGRqImo7avrUSyeZy/5F+yu7Pzd2s691K3Wa0zT0m8OLzvvRk4kM X-Received: by 2002:a17:90a:e545:b0:24e:2e86:5465 with SMTP id ei5-20020a17090ae54500b0024e2e865465mr23165974pjb.31.1683858250932; Thu, 11 May 2023 19:24:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683858250; cv=none; d=google.com; s=arc-20160816; b=c8K3X/gkztSPsJM0R9YNu8oTWl0hKv0aTWfrSs31XnnotEM6xxLZOkGRtP1lmxWr9N 4Df9PQz5xVJEtfjnySk6wtfB4vNQ3gP7dTirihP1nAZmNOnhNWdqlaw/LJP7m9JaI8er JHIkkCz+LKW3xBAZv0fbb4IAu4Nu4cButZOAFywn+xhOGDiwTn5x11WPV8E9YnGeDrNs ampuYyq+N5ot/1oBOeZmwUyibHgCq9nJgPASsDfFnzVhmaudErEHa+mzV2z9xVieJQpo wf9zBLwu/T5CrNWtAzovNclhYt9jgcolnlj5aH4RrSmNC7ySA003E5iJssucIB9apQJG krKw== 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=PwbGvwuLjPEWuiiw4Gz44ViK028lH+sHoEfkYYz3Blw=; b=w/vydRopzxsKAJsBkdctbTXgF9SpfwZ9tQ5BbRIrscbr+AeuemVmJv8g7Ee0uUs1bO T7CsAgot4kRzN+h5Dhg7hHwtoC+PV9fYQaqEz3YSqFs7ne+yDCHxOzuujb0vCQwNcByE 90yW8jbtjq9aATrNBuGC5ZKFBQZaUiFyEVWuu2HUXQ06sisir2TVbEi38OPZjNsEerp7 ehLXc2D74dOyEzEJ0jlIABbzkgwgTwbtL25fGioWE/rbUqL+J88OM70dDn4fP3Pp5PwT aBXM83CU772XmD5e1jQn9Bw6kW0CzsktqH/fzMICqBvLHf0uq7nfQW2dxpBSynTw5v38 teww== 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 s20-20020a63af54000000b005192d51325dsi7667520pgo.42.2023.05.11.19.23.58; Thu, 11 May 2023 19:24:10 -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 S239752AbjELCWf convert rfc822-to-8bit (ORCPT + 99 others); Thu, 11 May 2023 22:22:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231799AbjELCWX (ORCPT ); Thu, 11 May 2023 22:22:23 -0400 Received: from ex01.ufhost.com (ex01.ufhost.com [61.152.239.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 208D159C5; Thu, 11 May 2023 19:22:22 -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 B900324E291; Fri, 12 May 2023 10:22:15 +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, 12 May 2023 10:22:15 +0800 Received: from localhost.localdomain (113.72.146.187) by EXMBX061.cuchost.com (172.16.6.61) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Fri, 12 May 2023 10:22:14 +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 v4 3/7] dt-bindings: clock: jh7110-syscrg: Add PLL clock inputs Date: Fri, 12 May 2023 10:20:32 +0800 Message-ID: <20230512022036.97987-4-xingyu.wu@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230512022036.97987-1-xingyu.wu@starfivetech.com> References: <20230512022036.97987-1-xingyu.wu@starfivetech.com> MIME-Version: 1.0 X-Originating-IP: [113.72.146.187] X-ClientProxiedBy: EXCAS062.cuchost.com (172.16.6.22) 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,T_SCC_BODY_TEXT_LINE 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?1765653349213080463?= X-GMAIL-MSGID: =?utf-8?q?1765653349213080463?= 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..fcb363353050 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 0>, + <&pllclk 1>, + <&pllclk 2>; 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 May 12 02:20:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xingyu Wu X-Patchwork-Id: 92920 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp4801195vqo; Thu, 11 May 2023 19:23:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ58P9i/2gNZdeMbkdYdd8ejfdxTH+TDbrSiCmynWcaDCXTeZ4jt8NNz0EVj7R6QEUwsMM79 X-Received: by 2002:a17:902:8d8b:b0:1a9:3fab:3ebe with SMTP id v11-20020a1709028d8b00b001a93fab3ebemr23269250plo.10.1683858230011; Thu, 11 May 2023 19:23:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683858229; cv=none; d=google.com; s=arc-20160816; b=Di1iuqdKcAt52kh8299j9WC+e3JPI/fW3pCMs0qsdh0K3I9ZvEKOr3mcIDKlHfb08a 9DaOR8NmLCQ9+VPYgaQdf6mXJUeJbVXlQlrXoZ+Hm1SQPY0GiW1GP3v2Dui/aFl2Ty6J PvtFSt8ws/wYSrzFG9E0WYilFSgydUbe5MYla1pqP+ZujIXAyvCnwrmR1J2VVWMh5fvH gwP66dwIj0le0A9ljzkdQC7Vtmar6/tCCFIho9dk7yERI1KeCEva7i6TfDN6xD8hiIsF vXt9yuZqHvc0RXMOpHarhsQrwF8PbZydQvUuTNnzQi/yk+9U3HLRIfBAmPswjxqTBFVv xktg== 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=yahsJlx9NDQa1+R0oJpjkBPZ5trgQlDM28rkOPNl9XY=; b=eDf48UO4S4+dbIiXCsos+6yFS/1heJCmyQ59ctr2TdH9+0zxibeKvGm3o1fZC1Gtmu Me2lQomLh+GGTF0xaLPCJruIp4uBo1K8s6TOr6R4sHtyWCaRn/oz/5L6+Xllqt7kogAG PFQYMynZGy+9rp3rqxC9gx5fYCZnxlW/Gj5INLCeEnx8xvXCZQaEEkazhsiaFD4tDGbQ fU9OAFtnPaSbN3Zi8JRR8B5ioPKAdvYA1poi08eGD4Ml0ABHcWCE3l3s5w4Yuokj4WDG eZAmwovAw13U7C2a6DqWADPTUF1e50QrlSKRalKO/xLavFCm23rqPFVjum+LsyWnT6p9 uNUQ== 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-20020a170902bd0200b001a814f7db5fsi7585094pls.632.2023.05.11.19.23.37; Thu, 11 May 2023 19:23:49 -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 S239791AbjELCWZ convert rfc822-to-8bit (ORCPT + 99 others); Thu, 11 May 2023 22:22:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239776AbjELCWW (ORCPT ); Thu, 11 May 2023 22:22:22 -0400 Received: from fd01.gateway.ufhost.com (fd01.gateway.ufhost.com [61.152.239.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 709DF4C26; Thu, 11 May 2023 19:22:19 -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 976E68157; Fri, 12 May 2023 10:22:16 +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, 12 May 2023 10:22:16 +0800 Received: from localhost.localdomain (113.72.146.187) by EXMBX061.cuchost.com (172.16.6.61) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Fri, 12 May 2023 10:22: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 v4 4/7] clk: starfive: jh7110-sys: Modify PLL clocks source Date: Fri, 12 May 2023 10:20:33 +0800 Message-ID: <20230512022036.97987-5-xingyu.wu@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230512022036.97987-1-xingyu.wu@starfivetech.com> References: <20230512022036.97987-1-xingyu.wu@starfivetech.com> MIME-Version: 1.0 X-Originating-IP: [113.72.146.187] X-ClientProxiedBy: EXCAS062.cuchost.com (172.16.6.22) 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_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE 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?1765653327421105056?= X-GMAIL-MSGID: =?utf-8?q?1765653327421105056?= 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 5195f7be5213..978b78ec08b1 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 if RESET_CONTROLLER + 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 e6031345ef05..7fd30c571059 100644 --- a/drivers/clk/starfive/clk-starfive-jh7110-sys.c +++ b/drivers/clk/starfive/clk-starfive-jh7110-sys.c @@ -402,29 +402,6 @@ static int __init jh7110_syscrg_probe(struct platform_device *pdev) if (IS_ERR(priv->base)) return PTR_ERR(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] = {}; @@ -462,8 +439,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 May 12 02:20:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xingyu Wu X-Patchwork-Id: 92921 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp4801239vqo; Thu, 11 May 2023 19:23:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6UU+BitCR9HtkMCO9aGLJtXyllKhaW1ulbt8sDBKtJpbNb5h3iUScFvUJXIxTY10DQQoVk X-Received: by 2002:a17:90a:8c17:b0:24d:f3cc:7d34 with SMTP id a23-20020a17090a8c1700b0024df3cc7d34mr23437402pjo.32.1683858236012; Thu, 11 May 2023 19:23:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683858235; cv=none; d=google.com; s=arc-20160816; b=gly9AM56f4k0zHTEeEyEDr1PxAXWi5M1mQpwzMMWWQe562Fb78SC3S597sdiodjfUe tZ2RY2t/fOv9Zl07t8RzMSPBGDVe8zzdn5ls3c3rg5jelfGg5R0Oht5IUWt2ebnCDfl0 mISBr8vf/jc4uKWF/YTzsklXEfJre8/km9HHjZAB4EUG9OnFgfn2lC5YZiszCz110zgf fKC1kvliQ+z59L/b5TtCx1BXYDcjFNHTIsFMsiZg7vSDbAVmRC3p/+iNITKWpZXjQUjb 5Jc0ZaYmzNrdElKf0aGwbz2Ni99JLDR7a2cqE6+LEDX9WrzFdtW/00HvyC3FdLRZ2B05 tvnw== 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=qNgPVwgEy7rFNir/H0szZCA1vhzF/XAkh+c2An2O6ps=; b=zHRHklDK3w0+FvZzkxRPXFDP9ZcGe2h037p22rl85QnwqoPGQabKGwEM1m6ultEQfK N/kcySvyBaZPgPUjsPG/VwwHTw0FZUmTFrnRRqbfxDc/qu7j7LKqAVNdNN33+FuRcTFc rFdQgq7u48+q0//XmlH+dbadCVqr00IF5e6V+iB5uWsMBHoEueucJHO95AGBukm7bEOD JeEsPOgJFJU5vk/hQmcnjnukRR2jm4TWDP1wHwi3n0HcV7JtFOY/cN/HkfIvIUQ5YRbA 8a29cN6ndhWbi94YWEeNnpJNAwlLEeGVhrjMWSTo9KqV20pjnmsdNC1xkHtzNj+SxZlX j/SA== 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 u13-20020a17090ae00d00b0024ddf090102si31743465pjy.56.2023.05.11.19.23.43; Thu, 11 May 2023 19:23:55 -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 S239776AbjELCW3 convert rfc822-to-8bit (ORCPT + 99 others); Thu, 11 May 2023 22:22:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239779AbjELCWW (ORCPT ); Thu, 11 May 2023 22:22:22 -0400 Received: from fd01.gateway.ufhost.com (fd01.gateway.ufhost.com [61.152.239.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70A3259F1; Thu, 11 May 2023 19:22: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 fd01.gateway.ufhost.com (Postfix) with ESMTP id 7E33E8159; Fri, 12 May 2023 10:22:17 +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, 12 May 2023 10:22:17 +0800 Received: from localhost.localdomain (113.72.146.187) by EXMBX061.cuchost.com (172.16.6.61) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Fri, 12 May 2023 10:22: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 v4 5/7] dt-bindings: soc: starfive: Add StarFive syscon module Date: Fri, 12 May 2023 10:20:34 +0800 Message-ID: <20230512022036.97987-6-xingyu.wu@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230512022036.97987-1-xingyu.wu@starfivetech.com> References: <20230512022036.97987-1-xingyu.wu@starfivetech.com> MIME-Version: 1.0 X-Originating-IP: [113.72.146.187] X-ClientProxiedBy: EXCAS062.cuchost.com (172.16.6.22) 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_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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?1765653333721191280?= X-GMAIL-MSGID: =?utf-8?q?1765653333721191280?= From: William Qiu Add documentation to describe StarFive System Controller Registers. Co-developed-by: Xingyu Wu Signed-off-by: Xingyu Wu Reviewed-by: Rob Herring Signed-off-by: William Qiu --- .../soc/starfive/starfive,jh7110-syscon.yaml | 67 +++++++++++++++++++ MAINTAINERS | 7 ++ 2 files changed, 74 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..26dc99cb0c89 --- /dev/null +++ b/Documentation/devicetree/bindings/soc/starfive/starfive,jh7110-syscon.yaml @@ -0,0 +1,67 @@ +# 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: + - const: starfive,jh7110-sys-syscon + - const: syscon + - const: simple-mfd + - items: + - enum: + - starfive,jh7110-aon-syscon + - starfive,jh7110-stg-syscon + - const: syscon + + reg: + maxItems: 1 + + clock-controller: + $ref: /schemas/clock/starfive,jh7110-pll.yaml# + type: object + + "#power-domain-cells": + const: 1 + +required: + - compatible + - reg + +allOf: + - if: + properties: + compatible: + contains: + const: starfive,jh7110-aon-syscon + then: + required: + - "#power-domain-cells" + +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 0fb4a703f66f..60bbc3a05d79 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -20093,6 +20093,12 @@ 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 +M: Xingyu Wu +S: Supported +F: Documentation/devicetree/bindings/soc/starfive/starfive,jh7110-syscon.yaml + STARFIVE JH71X0 CLOCK DRIVERS M: Emil Renner Berthing M: Hal Feng @@ -20130,6 +20136,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 May 12 02:20:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xingyu Wu X-Patchwork-Id: 92926 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp4805256vqo; Thu, 11 May 2023 19:37:32 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4tgMCmK5WEHBhfAV4hZhMhKrS3qNGKJhPxZ/OJz62sWjx6+kdTV+3i7WSXpQzdH13drIjm X-Received: by 2002:a17:902:e802:b0:19d:297:f30b with SMTP id u2-20020a170902e80200b0019d0297f30bmr29827088plg.19.1683859051812; Thu, 11 May 2023 19:37:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683859051; cv=none; d=google.com; s=arc-20160816; b=Cl2J+I98KafCu4R6mAQmcaaUagRza4pFpY24ZjK5bTjjlNjuhU3jDOTjLDZzKjaS2U nYdCZxakOkBNPVtZeS967yRAXlun1eZnVgPCf545LPrTbugaOQfqLdZF+3bFyoPv+GEx 212vsIXMMWC2MZ70Pa038rabR2s4+RE5Fc1Kiq85Y3Cy2vloxkEEfg5TEg4lPzFIXsI+ tjqOdx/qy9IoYUtQy6zQ4m0b9CHAVL77Yk7kRb2/AyDTIjkqDP0CayDN+9DwtvaNsYJ4 guTRWw2Tn1SdOaFVBk0YaB9o9M+8vAwFOWa7AWayBX6reYqDMNUTSGRbP8nI9Y8gd5K3 vrbg== 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=F+qWMV9mS0I4G/hMdHkhBaDWQ9kkie+44XeaPLenib4=; b=QfQ7YVCgoVzVHw/c6RXf8oITPpm9XBAKP0bHvgESw5y63fAWPJRJLiO8zIoR8RlHdl adV9IspC1U5Qo2IkOYbyffhZLUNAWf+4xdvV0Kyfz+qSZIA4c2hT9Ddnib10kmTFrPWg VFwHiYbo3H28NJBG8McOH07KJbt1F9boEw886DRJYAiI4WGWrBASH/QRI/FoniVh8f15 OpfSndEllIqtwrl7Mgr5AOcosh25WGf51EBb1XPOR+WNynqf9CPIGC8QDZ8Rr3GXe0hx EyZ75w8xfcuMaPbnC9aB+CvBTf/PgqC1edxHprs5bqWv9eSSFyu6QWoIDlDBbh/VKf/0 xrwg== 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 u11-20020a170902b28b00b001a69d1be166si8021179plr.450.2023.05.11.19.37.15; Thu, 11 May 2023 19:37:31 -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 S239851AbjELCWr convert rfc822-to-8bit (ORCPT + 99 others); Thu, 11 May 2023 22:22:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239785AbjELCWX (ORCPT ); Thu, 11 May 2023 22:22:23 -0400 Received: from ex01.ufhost.com (ex01.ufhost.com [61.152.239.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8F035B9F; Thu, 11 May 2023 19:22: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 5DA0C24E27E; Fri, 12 May 2023 10:22: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; Fri, 12 May 2023 10:22:18 +0800 Received: from localhost.localdomain (113.72.146.187) by EXMBX061.cuchost.com (172.16.6.61) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Fri, 12 May 2023 10:22: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 v4 6/7] riscv: dts: starfive: jh7110: Add syscon nodes Date: Fri, 12 May 2023 10:20:35 +0800 Message-ID: <20230512022036.97987-7-xingyu.wu@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230512022036.97987-1-xingyu.wu@starfivetech.com> References: <20230512022036.97987-1-xingyu.wu@starfivetech.com> MIME-Version: 1.0 X-Originating-IP: [113.72.146.187] X-ClientProxiedBy: EXCAS062.cuchost.com (172.16.6.22) 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,T_SCC_BODY_TEXT_LINE 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?1765654189321079118?= X-GMAIL-MSGID: =?utf-8?q?1765654189321079118?= From: William Qiu Add stg_syscon/sys_syscon/aon_syscon nodes for JH7110 Soc. Co-developed-by: Xingyu Wu Signed-off-by: Xingyu Wu Reviewed-by: Conor Dooley Reviewed-by: Emil Renner Berthing Signed-off-by: William Qiu --- arch/riscv/boot/dts/starfive/jh7110.dtsi | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/arch/riscv/boot/dts/starfive/jh7110.dtsi b/arch/riscv/boot/dts/starfive/jh7110.dtsi index 4c5fdb905da8..fa27fd4169a8 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,12 @@ aoncrg: clock-controller@17000000 { #reset-cells = <1>; }; + aon_syscon: syscon@17010000 { + compatible = "starfive,jh7110-aon-syscon", "syscon"; + reg = <0x0 0x17010000 0x0 0x1000>; + #power-domain-cells = <1>; + }; + aongpio: pinctrl@17020000 { compatible = "starfive,jh7110-aon-pinctrl"; reg = <0x0 0x17020000 0x0 0x10000>; From patchwork Fri May 12 02:20:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xingyu Wu X-Patchwork-Id: 92928 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp4806461vqo; Thu, 11 May 2023 19:41:36 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7148+vA//UE4A3OMelXXYljkusJ4ysJdVUJ6sIIqNN89ASHuQ6qcHXalLY25F349UrmNgg X-Received: by 2002:a17:902:8691:b0:19a:9890:eac6 with SMTP id g17-20020a170902869100b0019a9890eac6mr22325745plo.24.1683859296364; Thu, 11 May 2023 19:41:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683859296; cv=none; d=google.com; s=arc-20160816; b=qIRUNY6sCGmxYV6vZx6M0//suFiPMwPdjZ846k8ce3YqGB84FjlJf5s6HuSYRqqSiv amcHf0a5L9daRCBvm+5dgiJFPfvqDwCeuy6DgIWn/7Dr9AFWSe8+bYW6I7pa/CZA+CMj woxsUJK2Ah1/xcWKN/+4cdggSgRA/nTfCFcEqREeO6Q2rulWZGsGjPOYrUx0lvFvqyhd ORRpsl+0peuADsWZoOq6vZHyluD4zjP1V3GMrWz30trr8c1phWfuD9y9QrXydFElb8K/ 7ALW8gS58uVlE7PEzhAoiCAZEFVFTw10eiBPRf2dorv4ROwxQdbxCwQkW0iXoJ8WjaBd 52rw== 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=gXqNfPggJVd1KlyQ41yc5b1lmYfr1ku/JbFW/SJa8HY=; b=wuvRtL3g2yvKf/VtJKbCke7JyOzhZ7J7a0WKfqhdf801eV4bciuNNDMPKT02+wWgJC 6aUsj1gveo49rGywdlZyY1eTqqWkwYVgyc4aHC8gwxq7sv+CGSlzTRC6OvoauLudSsHN ebYTJWEstpQgoWc/Mi2DtkrtbCped9gN8jko3qSaBMwbg8WdDhgxOY3qaLBYvqQAJ9X/ AmPFv7xl5dz7wPRx8cL7EbP5OpkQl4D9D1ZT5mVS5O8DbyufTvH1oaoaMZMJ5ByscJop n+1XuTexVrPW3ykEucYtPsqLkOVC2mnBP0FdiAmNhqM4OT1mKMebh5gXdwqhia4EdU8j rSQg== 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 h9-20020a170902f54900b001a1abc91952si3013130plf.194.2023.05.11.19.41.23; Thu, 11 May 2023 19:41:36 -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 S239829AbjELCWn convert rfc822-to-8bit (ORCPT + 99 others); Thu, 11 May 2023 22:22:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239784AbjELCWX (ORCPT ); Thu, 11 May 2023 22:22:23 -0400 Received: from ex01.ufhost.com (ex01.ufhost.com [61.152.239.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA0DE5BA9; Thu, 11 May 2023 19:22:20 -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 36DD824E290; Fri, 12 May 2023 10:22:19 +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, 12 May 2023 10:22:19 +0800 Received: from localhost.localdomain (113.72.146.187) by EXMBX061.cuchost.com (172.16.6.61) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Fri, 12 May 2023 10:22: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 v4 7/7] riscv: dts: starfive: jh7110: Add PLL clock node and modify syscrg node Date: Fri, 12 May 2023 10:20:36 +0800 Message-ID: <20230512022036.97987-8-xingyu.wu@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230512022036.97987-1-xingyu.wu@starfivetech.com> References: <20230512022036.97987-1-xingyu.wu@starfivetech.com> MIME-Version: 1.0 X-Originating-IP: [113.72.146.187] X-ClientProxiedBy: EXCAS062.cuchost.com (172.16.6.22) 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,T_SCC_BODY_TEXT_LINE 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?1765654445953475317?= X-GMAIL-MSGID: =?utf-8?q?1765654445953475317?= 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 fa27fd4169a8..cdfd036a0e6c 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 {