From patchwork Tue Jul 9 12:31:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Heiko_St=C3=BCbner?= X-Patchwork-Id: 13727795 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0A322C3DA47 for ; Tue, 9 Jul 2024 12:32:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=CUSKijRkYP2c/rjAoHax8YGDcdf+G7V68MnEAefITNg=; b=vsVj7Dq1dMnncx 5Cgoo0BB2KGo/8fI1JIH8YfAoCknDU5VjcqNbqVukMRi6QQw0UnTZU8OThM2xDYe+EdW1F1uhLOMM aNW157rfqpuVKPN+mF94+eS75bNHePsToYJmPY4ySLeMlvucP/fWa4Eb3aL93UM/cCPJZvyAaNOqe GffiaMTuf+JDgl1jcz9GqbGRTbeekr2IoGXQs3IU7yQI4k1VGmZADzQnKgqvLaT+1q2W6209+wtdk pDrPNCjjVSV0pppYgTm7oW3yanSAZVhHdKqRAmTEJoKTsVYktAS+hj8RGd9Qi0kMOGVI9OM5sIPHA SycE+GdzLRaRMrtltf8g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRA15-000000078X8-3pAQ; Tue, 09 Jul 2024 12:32:19 +0000 Received: from gloria.sntech.de ([185.11.138.130]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRA0a-000000078Kx-0wCz; Tue, 09 Jul 2024 12:31:49 +0000 Received: from i5e860d18.versanet.de ([94.134.13.24] helo=phil.lan) by gloria.sntech.de with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sRA0T-00074P-3S; Tue, 09 Jul 2024 14:31:41 +0200 From: Heiko Stuebner To: mturquette@baylibre.com, sboyd@kernel.org Cc: robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, heiko@sntech.de, quentin.schulz@cherry.de, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org Subject: [PATCH 1/6] dt-bindings: clocks: add binding for generic clock-generators Date: Tue, 9 Jul 2024 14:31:16 +0200 Message-Id: <20240709123121.1452394-2-heiko@sntech.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240709123121.1452394-1-heiko@sntech.de> References: <20240709123121.1452394-1-heiko@sntech.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240709_053148_285370_A0FD7C7D X-CRM114-Status: GOOD ( 18.04 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org In contrast to fixed clocks that are described as ungateable, boards sometimes use additional clock generators for things like PCIe reference clocks, that need actual supplies to get enabled and enable-gpios to be toggled for them to work. This adds a binding for such clock generators that are not configurable themself, but need to handle supplies for them to work. While in a lot of cases the type of the IC used is described in board schematics, in some cases just a generic type description like "100MHz, 3.3V" might also be used. The binding therefore allows both cases. Specifying the type is of course preferred. The clock-frequency is set in devicetree, because while some clock generators have pins to decide between multipls output rates, those are generally set statically on the board-layout-level. Signed-off-by: Heiko Stuebner --- .../bindings/clock/clock-generator.yaml | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/clock-generator.yaml diff --git a/Documentation/devicetree/bindings/clock/clock-generator.yaml b/Documentation/devicetree/bindings/clock/clock-generator.yaml new file mode 100644 index 0000000000000..f44e61e414e89 --- /dev/null +++ b/Documentation/devicetree/bindings/clock/clock-generator.yaml @@ -0,0 +1,62 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/clock/clock-generator.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Simple clock generators + +maintainers: + - Heiko Stuebner + +properties: + $nodename: + anyOf: + - description: + Preferred name is 'clock-' with being the output + frequency as defined in the 'clock-frequency' property. + pattern: "^clock-([0-9]+|[a-z0-9-]+)$" + - description: Any name allowed + deprecated: true + + compatible: + oneOf: + - const: clock-generator + - items: + - enum: + - diodes,pi6c557-03b + - diodes,pi6c557-05b + - const: clock-generator + + "#clock-cells": + const: 0 + + clock-frequency: true + + clock-output-names: + maxItems: 1 + + enable-gpios: + description: + Contains a single GPIO specifier for the GPIO that enables and disables + the clock generator. + maxItems: 1 + + vdd-supply: + description: handle of the regulator that provides the supply voltage + +required: + - compatible + - "#clock-cells" + - clock-frequency + +additionalProperties: false + +examples: + - | + clock { + compatible = "clock-generator"; + #clock-cells = <0>; + clock-frequency = <1000000000>; + }; +... From patchwork Tue Jul 9 12:31:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Heiko_St=C3=BCbner?= X-Patchwork-Id: 13727799 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9376EC2BD09 for ; Tue, 9 Jul 2024 12:33:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=kplclFa9lF4HyegQeo2b4MB7l13WO/ZM0rLL2y8WpbE=; b=FisfV8Bj7qNq9q jmBopj5BLgfdhRHqd7K7vZyP6Xm6N8+WlTS8tkxaPevE//fWyxu5A09Y+/SSOd5VCTa8Yvnn9BivI Q0JMZJ4s8zJrQ0bnvLR9rHIyX+ieyKdert8n+jZ6YUvKX6goa+x+j/R84e4ZhvMIvXbKe8cnSo2wk ycGMbxKXWiilCpsqA1zUQjRcYDvBSsBVuJwj982oANEBKdbXrmPEhFenBER3dxcNxDx5qLuSXXc+M 5hYxx1pQHG48axxrw/xvlsJpJB3/dmGar9rhqMXo3AE4yTUf4TvOoxZofKPzwdSkWlkN8vui3BWEn HrBG+vZYXqakOitil2Zg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRA2A-00000007981-1Ib6; Tue, 09 Jul 2024 12:33:26 +0000 Received: from gloria.sntech.de ([185.11.138.130]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRA0a-000000078LE-44vq; Tue, 09 Jul 2024 12:31:52 +0000 Received: from i5e860d18.versanet.de ([94.134.13.24] helo=phil.lan) by gloria.sntech.de with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sRA0T-00074P-LW; Tue, 09 Jul 2024 14:31:41 +0200 From: Heiko Stuebner To: mturquette@baylibre.com, sboyd@kernel.org Cc: robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, heiko@sntech.de, quentin.schulz@cherry.de, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org Subject: [PATCH 2/6] clk: add driver for generic clock generators Date: Tue, 9 Jul 2024 14:31:17 +0200 Message-Id: <20240709123121.1452394-3-heiko@sntech.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240709123121.1452394-1-heiko@sntech.de> References: <20240709123121.1452394-1-heiko@sntech.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240709_053149_032326_86525399 X-CRM114-Status: GOOD ( 24.87 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org In contrast to fixed clocks that are described as ungateable, boards sometimes use additional clock generators for things like PCIe reference clocks, that need actual supplies to get enabled and enable-gpios to be toggled for them to work. This adds a driver for those generic unconfigurable clock generators. Signed-off-by: Heiko Stuebner --- drivers/clk/Kconfig | 7 ++ drivers/clk/Makefile | 1 + drivers/clk/clk-generator.c | 133 ++++++++++++++++++++++++++++++++++++ 3 files changed, 141 insertions(+) create mode 100644 drivers/clk/clk-generator.c diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig index 3e9099504fad4..76c53ddc472ce 100644 --- a/drivers/clk/Kconfig +++ b/drivers/clk/Kconfig @@ -247,6 +247,13 @@ config COMMON_CLK_GEMINI This driver supports the SoC clocks on the Cortina Systems Gemini platform, also known as SL3516 or CS3516. +config COMMON_CLK_GENERATOR + tristate "Clock driver for generic clock generators" + depends on GPIOLIB && REGULATOR + help + This driver supports generic clock generators that are not + configurable but need supplies to be enabled to run. + config COMMON_CLK_LAN966X tristate "Generic Clock Controller driver for LAN966X SoC" depends on HAS_IOMEM diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile index 4abe16c8ccdfe..9cb0801155771 100644 --- a/drivers/clk/Makefile +++ b/drivers/clk/Makefile @@ -36,6 +36,7 @@ obj-$(CONFIG_COMMON_CLK_FIXED_MMIO) += clk-fixed-mmio.o obj-$(CONFIG_COMMON_CLK_FSL_FLEXSPI) += clk-fsl-flexspi.o obj-$(CONFIG_COMMON_CLK_FSL_SAI) += clk-fsl-sai.o obj-$(CONFIG_COMMON_CLK_GEMINI) += clk-gemini.o +obj-$(CONFIG_COMMON_CLK_GENERATOR) += clk-generator.o obj-$(CONFIG_COMMON_CLK_ASPEED) += clk-aspeed.o obj-$(CONFIG_MACH_ASPEED_G6) += clk-ast2600.o obj-$(CONFIG_ARCH_HIGHBANK) += clk-highbank.o diff --git a/drivers/clk/clk-generator.c b/drivers/clk/clk-generator.c new file mode 100644 index 0000000000000..99737bab1f5ad --- /dev/null +++ b/drivers/clk/clk-generator.c @@ -0,0 +1,133 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2024 Heiko Stuebner + * + * Generic unconfigurable clock generators + */ + +#include +#include +#include +#include +#include +#include +#include + +struct clk_generator { + struct device *dev; + struct clk_hw hw; + u32 rate; + struct regulator *supply; + struct gpio_desc *enable_gpio; +}; + +#define to_clk_generator(_hw) container_of(_hw, struct clk_generator, hw) + +static int clk_generator_prepare(struct clk_hw *hw) +{ + return regulator_enable(to_clk_generator(hw)->supply); +} + +static void clk_generator_unprepare(struct clk_hw *hw) +{ + regulator_disable(to_clk_generator(hw)->supply); +} + +static int clk_generator_enable(struct clk_hw *hw) +{ + gpiod_set_value(to_clk_generator(hw)->enable_gpio, 1); + return 0; +} + +static void clk_generator_disable(struct clk_hw *hw) +{ + gpiod_set_value(to_clk_generator(hw)->enable_gpio, 0); +} + +static unsigned long clk_generator_recalc_rate(struct clk_hw *hw, + unsigned long parent_rate) +{ + return to_clk_generator(hw)->rate; +} + +const struct clk_ops clk_generator_ops = { + .prepare = clk_generator_prepare, + .unprepare = clk_generator_unprepare, + .enable = clk_generator_enable, + .disable = clk_generator_disable, + .recalc_rate = clk_generator_recalc_rate, +}; + +static int clk_generator_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct clk_generator *clkgen; + const char *clk_name; + int ret; + + clkgen = devm_kzalloc(dev, sizeof(*clkgen), GFP_KERNEL); + if (!clkgen) + return -ENOMEM; + + clkgen->dev = dev; + + if (device_property_read_u32(dev, "clock-frequency", &clkgen->rate)) + return -EIO; + + ret = device_property_read_string(dev, "clock-output-names", &clk_name); + if (ret) + clk_name = fwnode_get_name(dev->fwnode); + + clkgen->supply = devm_regulator_get_optional(dev, "vdd"); + if (IS_ERR(clkgen->supply)) { + if (PTR_ERR(clkgen->supply) != -ENODEV) + return dev_err_probe(dev, PTR_ERR(clkgen->supply), + "failed to get regulator\n"); + clkgen->supply = NULL; + } + + clkgen->enable_gpio = devm_gpiod_get_optional(dev, "enable", + GPIOD_OUT_LOW); + if (IS_ERR(clkgen->enable_gpio)) + return dev_err_probe(dev, PTR_ERR(clkgen->enable_gpio), + "failed to get gpio\n"); + + ret = gpiod_direction_output(clkgen->enable_gpio, 0); + if (ret < 0) + return ret; + + clkgen->hw.init = CLK_HW_INIT_NO_PARENT(clk_name, &clk_generator_ops, 0); + + /* register the clock */ + ret = devm_clk_hw_register(dev, &clkgen->hw); + if (ret) + return dev_err_probe(dev, ret, + "failed to register clock\n"); + + ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, + &clkgen->hw); + if (ret) + return dev_err_probe(dev, ret, + "failed to register clock provider\n"); + + return 0; +} + +static const struct of_device_id clk_generator_ids[] = { + { .compatible = "clock-generator" }, + { } +}; +MODULE_DEVICE_TABLE(of, clk_generator_ids); + +static struct platform_driver clk_generator_driver = { + .driver = { + .name = "clk_generator", + .of_match_table = clk_generator_ids, + }, + .probe = clk_generator_probe, +}; +module_platform_driver(clk_generator_driver); + +MODULE_AUTHOR("Heiko Stuebner "); +MODULE_DESCRIPTION("Clock-generator driver"); +MODULE_LICENSE("GPL"); From patchwork Tue Jul 9 12:31:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Heiko_St=C3=BCbner?= X-Patchwork-Id: 13727798 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4DE27C2BD09 for ; Tue, 9 Jul 2024 12:33:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1Veqt5DjIe/5t/1jz1ptxxDJ2v/rdRrVyoLoz2679JU=; b=ii1JuaFXXqoRo3 toEj1FMd646ED7OJBy87qhy/ibTF7q1wxhns6G1AyMprHvfemywu02YBJn2C5nd+snCSqIucJxnFI S2b/lCbx7/PQmdJZkclTebl2N/s3eP926PVjOP/xz27I7si7/OpF75m5dPyMqdX5d+ppWkFpUKzXa ij7sGqSV3u8jzh0UikjeIEz+QTStfJXr2vGp/jpEPjbCrE7dlOVu4gTGMqoBijytv4JvgrkLJH2NF 0esIx1sH1+JVM/tWLYTyq4h0tw9cUIE8xFG0H0eVmUCJLHDVTBd5fvXkhLJE9nQCDW/XzJgNcmgDt B1EePoyl98nLmxFE27Bw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRA1v-000000078zU-1guY; Tue, 09 Jul 2024 12:33:11 +0000 Received: from gloria.sntech.de ([185.11.138.130]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRA0b-000000078Le-2kua; Tue, 09 Jul 2024 12:31:51 +0000 Received: from i5e860d18.versanet.de ([94.134.13.24] helo=phil.lan) by gloria.sntech.de with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sRA0U-00074P-6m; Tue, 09 Jul 2024 14:31:42 +0200 From: Heiko Stuebner To: mturquette@baylibre.com, sboyd@kernel.org Cc: robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, heiko@sntech.de, quentin.schulz@cherry.de, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org Subject: [PATCH 3/6] arm64: dts: rockchip: fix the pcie clock generator on Rock 5 ITX Date: Tue, 9 Jul 2024 14:31:18 +0200 Message-Id: <20240709123121.1452394-4-heiko@sntech.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240709123121.1452394-1-heiko@sntech.de> References: <20240709123121.1452394-1-heiko@sntech.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240709_053149_883593_FF28D66F X-CRM114-Status: GOOD ( 16.35 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org The Rock 5 ITX uses two PCIe controllers to drive both a M.2 slot and its SATA controller with 2 lanes each. The supply for the clock generator is the same that supplies the M.2 slot, but the SATA controller port is supplied by a different rail. This leads to the effect that if the PCIe30x4 controller for the M.2 probes first, everything works normally. But if the PCIe30x2 controller that is connected to the SATA controller probes first, it will hang on the first DBI read as nothing will have enabled the refclock before. Fix this by describing the clock generator with its supplies so that both controllers can reference it as needed. Signed-off-by: Heiko Stuebner --- .../boot/dts/rockchip/rk3588-rock-5itx.dts | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/arch/arm64/boot/dts/rockchip/rk3588-rock-5itx.dts b/arch/arm64/boot/dts/rockchip/rk3588-rock-5itx.dts index 41d92ceeeb09c..21fb3d940b489 100644 --- a/arch/arm64/boot/dts/rockchip/rk3588-rock-5itx.dts +++ b/arch/arm64/boot/dts/rockchip/rk3588-rock-5itx.dts @@ -77,6 +77,15 @@ hdd-led2 { }; }; + /* Unnamed clock generator: 100MHz,3.3V,3225 */ + pcie30_port0_refclk: pcie30_port1_refclk: pcie-clock-generator { + compatible = "clock-generator"; + #clock-cells = <0>; + clock-frequency = <100000000>; + clock-output-names = "pcie30_refclk"; + vdd-supply = <&vcc3v3_pi6c_05>; + }; + fan0: pwm-fan { compatible = "pwm-fan"; #cooling-cells = <2>; @@ -151,13 +160,14 @@ vcc3v3_lan: vcc3v3_lan_phy2: regulator-vcc3v3-lan { vin-supply = <&vcc_3v3_s3>; }; - vcc3v3_mkey: regulator-vcc3v3-mkey { + /* The PCIE30x4_PWREN_H controls two regulators */ + vcc3v3_mkey: vcc3v3_pi6c_05: regulator-vcc3v3-pi6c-05 { compatible = "regulator-fixed"; enable-active-high; gpios = <&gpio1 RK_PA4 GPIO_ACTIVE_HIGH>; pinctrl-names = "default"; pinctrl-0 = <&pcie30x4_pwren_h>; - regulator-name = "vcc3v3_mkey"; + regulator-name = "vcc3v3_pi6c_05"; regulator-min-microvolt = <3300000>; regulator-max-microvolt = <3300000>; startup-delay-us = <5000>; @@ -519,6 +529,14 @@ &pcie30phy { /* ASMedia ASM1164 Sata controller */ &pcie3x2 { + clocks = <&cru ACLK_PCIE_2L_MSTR>, <&cru ACLK_PCIE_2L_SLV>, + <&cru ACLK_PCIE_2L_DBI>, <&cru PCLK_PCIE_2L>, + <&cru CLK_PCIE_AUX1>, <&cru CLK_PCIE2L_PIPE>, + <&pcie30_port1_refclk>; + clock-names = "aclk_mst", "aclk_slv", + "aclk_dbi", "pclk", + "aux", "pipe", + "ref"; pinctrl-names = "default"; pinctrl-0 = <&pcie30x2_perstn_m1_l>; reset-gpios = <&gpio4 RK_PB0 GPIO_ACTIVE_HIGH>; @@ -528,6 +546,18 @@ &pcie3x2 { /* M.2 M.key */ &pcie3x4 { + /* + * The board has a gpio-controlled "pcie_refclk" generator, + * so add it to the list of clocks. + */ + clocks = <&cru ACLK_PCIE_4L_MSTR>, <&cru ACLK_PCIE_4L_SLV>, + <&cru ACLK_PCIE_4L_DBI>, <&cru PCLK_PCIE_4L>, + <&cru CLK_PCIE_AUX0>, <&cru CLK_PCIE4L_PIPE>, + <&pcie30_port0_refclk>; + clock-names = "aclk_mst", "aclk_slv", + "aclk_dbi", "pclk", + "aux", "pipe", + "ref"; num-lanes = <2>; pinctrl-names = "default"; pinctrl-0 = <&pcie30x4_perstn_m1_l>; From patchwork Tue Jul 9 12:31:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Heiko_St=C3=BCbner?= X-Patchwork-Id: 13727800 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5E10DC3DA41 for ; Tue, 9 Jul 2024 12:33:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qEQOIEdtuwkHkybLBFlI7kFBtQWGfQaMGmPwqeG6T54=; b=5D0CHvje3Yh0M2 EYjctMzFURC0mdWuEzkK2AO3wwH//EJbPEllJm8rZUGo0UeEh9rseu2UPiXDrVMhNcfd90HC5IwC0 O9lj8/qCXduWEIvoMM/8NbN08uofneBO9X1eceuCnz35661hEtSoneuGti8a9fMSuaMGKOzmAW+rB VpT3nWNP0K1noOegdy0IWo4jqQt4RzOrKHNWS0fW5f/1gUCb0TmZsq99yZmPDRlnNCy8A+9zfFaQ9 WvUZ+rJ4zVRpfNK0RmTdjuWV1axHvAXtfIg/SxMOHlTlNpaSnrms1i0FF4C8js9k8mGX01PoG2u2s lA8nHhN04eZkEeMItfWQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRA2W-000000079Hd-40bf; Tue, 09 Jul 2024 12:33:48 +0000 Received: from gloria.sntech.de ([185.11.138.130]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRA0h-000000078OD-3ous; Tue, 09 Jul 2024 12:31:57 +0000 Received: from i5e860d18.versanet.de ([94.134.13.24] helo=phil.lan) by gloria.sntech.de with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sRA0U-00074P-Or; Tue, 09 Jul 2024 14:31:42 +0200 From: Heiko Stuebner To: mturquette@baylibre.com, sboyd@kernel.org Cc: robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, heiko@sntech.de, quentin.schulz@cherry.de, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org Subject: [PATCH 4/6] arm64: dts: rockchip: use clock-generator for pcie-refclk on rk3588-jaguar Date: Tue, 9 Jul 2024 14:31:19 +0200 Message-Id: <20240709123121.1452394-5-heiko@sntech.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240709123121.1452394-1-heiko@sntech.de> References: <20240709123121.1452394-1-heiko@sntech.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240709_053155_965713_27D1F9AF X-CRM114-Status: GOOD ( 13.89 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Using a combination of fixed clock and gpio-gate clock works but does not describe the actual hardware. Use the new clock-generator binding to describe this in a nicer way. Signed-off-by: Heiko Stuebner --- arch/arm64/boot/dts/rockchip/rk3588-jaguar.dts | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/arch/arm64/boot/dts/rockchip/rk3588-jaguar.dts b/arch/arm64/boot/dts/rockchip/rk3588-jaguar.dts index 71999f4f170af..b3c2aaedacf57 100644 --- a/arch/arm64/boot/dts/rockchip/rk3588-jaguar.dts +++ b/arch/arm64/boot/dts/rockchip/rk3588-jaguar.dts @@ -88,21 +88,16 @@ led-1 { * 100MHz reference clock for PCIe peripherals from PI6C557-05BLE * clock generator. * The clock output is gated via the OE pin on the clock generator. - * This is modeled as a fixed-clock plus a gpio-gate-clock. */ - pcie_refclk_gen: pcie-refclk-gen-clock { - compatible = "fixed-clock"; + pcie_refclk: pcie-clock-generator { + compatible = "diodes,pi6c557-05b", "clock-generator"; #clock-cells = <0>; clock-frequency = <100000000>; - }; - - pcie_refclk: pcie-refclk-clock { - compatible = "gpio-gate-clock"; - clocks = <&pcie_refclk_gen>; - #clock-cells = <0>; + clock-output-names = "pcie3_refclk"; enable-gpios = <&gpio0 RK_PC6 GPIO_ACTIVE_LOW>; /* PCIE30X4_CLKREQN_M0 */ pinctrl-names = "default"; pinctrl-0 = <&pcie30x4_clkreqn_m0>; + vdd-supply = <&vcca_3v3_s0>; }; pps { From patchwork Tue Jul 9 12:31:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Heiko_St=C3=BCbner?= X-Patchwork-Id: 13727796 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D176EC3DA41 for ; Tue, 9 Jul 2024 12:32:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=4YE+uW4V8VWFVMjsvXxDDcMZiu+pZe10lPaiU+tQYew=; b=tURCER1JMK5Bu2 P4Hqr9pgyjoBueiDYnsp3PpB5ru/oYEhGdua09BPOVH7T2c6Vas7vAbJtflObpvHKDYsOtiNA1W5C 7Sqo3+woY7aKfVucPJxqWHpiZwA3JFQdw34/aO164UG8SYOUFAkitEd53WzY3qIooW7hdjBxUEGks azgYYu/mbIFbPp7KOybcUWs3WLIUmuwHlK6zXy851tObD4zv55JuZQgiZH9qrRCLzvRizzBNciHlQ ByqfZNN2LBGWSee6eWmKXMBrssCTM6BvncEEZ3l3EN23uqCSP8sHO0yAoEf+h3hmcbVbwmR3wN+2e 72d67l0MBraf0sJowWig==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRA1J-000000078fu-3Ay6; Tue, 09 Jul 2024 12:32:33 +0000 Received: from gloria.sntech.de ([185.11.138.130]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRA0a-000000078L0-3bzz; Tue, 09 Jul 2024 12:31:50 +0000 Received: from i5e860d18.versanet.de ([94.134.13.24] helo=phil.lan) by gloria.sntech.de with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sRA0V-00074P-AQ; Tue, 09 Jul 2024 14:31:43 +0200 From: Heiko Stuebner To: mturquette@baylibre.com, sboyd@kernel.org Cc: robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, heiko@sntech.de, quentin.schulz@cherry.de, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org Subject: [PATCH 5/6] arm64: dts: rockchip: use clock-generator for pcie-refclk on rk3588-tiger Date: Tue, 9 Jul 2024 14:31:20 +0200 Message-Id: <20240709123121.1452394-6-heiko@sntech.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240709123121.1452394-1-heiko@sntech.de> References: <20240709123121.1452394-1-heiko@sntech.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240709_053148_917791_96E816E4 X-CRM114-Status: GOOD ( 13.67 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Using a combination of fixed clock and gpio-gate clock works but does not describe the actual hardware. Use the new clock-generator binding to describe this in a nicer way. Signed-off-by: Heiko Stuebner --- arch/arm64/boot/dts/rockchip/rk3588-tiger.dtsi | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/arch/arm64/boot/dts/rockchip/rk3588-tiger.dtsi b/arch/arm64/boot/dts/rockchip/rk3588-tiger.dtsi index f870f84da1e6d..4c5be356fa7fe 100644 --- a/arch/arm64/boot/dts/rockchip/rk3588-tiger.dtsi +++ b/arch/arm64/boot/dts/rockchip/rk3588-tiger.dtsi @@ -49,19 +49,14 @@ led-1 { * 100MHz reference clock for PCIe peripherals from PI6C557-05BLE * clock generator. * The clock output is gated via the OE pin on the clock generator. - * This is modeled as a fixed-clock plus a gpio-gate-clock. */ - pcie_refclk_gen: pcie-refclk-gen-clock { - compatible = "fixed-clock"; + pcie_refclk: pcie-clock-generator { + compatible = "diodes,pi6c557-05b", "clock-generator"; #clock-cells = <0>; clock-frequency = <100000000>; - }; - - pcie_refclk: pcie-refclk-clock { - compatible = "gpio-gate-clock"; - clocks = <&pcie_refclk_gen>; - #clock-cells = <0>; + clock-output-names = "pcie3_refclk"; enable-gpios = <&gpio4 RK_PB4 GPIO_ACTIVE_HIGH>; /* PCIE30X4_CLKREQN_M1_L */ + vdd-supply = <&vcca_3v3_s0>; }; vcc_1v1_nldo_s3: vcc-1v1-nldo-s3-regulator { From patchwork Tue Jul 9 12:31:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Heiko_St=C3=BCbner?= X-Patchwork-Id: 13727797 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 28CD0C2BD09 for ; Tue, 9 Jul 2024 12:32:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=sIL2u5LMd/CcwxaOf68DamUCEEwtGMnzc+sSuXy5gCo=; b=aXZSUd1PRrLAeu NLGaBonlvWFJkVpy0uVFGJoXmXdn/qir4cRh1rrJRg1bBzR+1QIhOdU6qWY0+YQaAbEMRftEgVquk PpKVQkrqpEcZB1fUcAdG8SwNKhdP4HK9fJvWbIc6RlvbJmARBN3K473rUc5MG6mPXCoYYtcHqeXHs 67UQJpIC4RfAFgdMDiNDWCHTSIeIfyaJ/75MwIjT7B9RODyx2TpRP3RHiU5MJpNKNQeYQ5z2NWA8P viePX0PyW/nBXyIkDKO2ruEiq3vUvxA9j94L8ldOZzOEuQzCxrwQF4OZrFgAGXrJlbWuj9ZPZsQgg QdRaW5Y5flh4IofVhWZg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRA1a-000000078qO-2QHB; Tue, 09 Jul 2024 12:32:50 +0000 Received: from gloria.sntech.de ([185.11.138.130]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRA0b-000000078LW-0uPA; Tue, 09 Jul 2024 12:31:51 +0000 Received: from i5e860d18.versanet.de ([94.134.13.24] helo=phil.lan) by gloria.sntech.de with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sRA0V-00074P-Sp; Tue, 09 Jul 2024 14:31:43 +0200 From: Heiko Stuebner To: mturquette@baylibre.com, sboyd@kernel.org Cc: robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, heiko@sntech.de, quentin.schulz@cherry.de, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org Subject: [PATCH 6/6] arm64: dts: rockchip: add pinctrl for clk-generator gpio on rk3588-tiger Date: Tue, 9 Jul 2024 14:31:21 +0200 Message-Id: <20240709123121.1452394-7-heiko@sntech.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240709123121.1452394-1-heiko@sntech.de> References: <20240709123121.1452394-1-heiko@sntech.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240709_053149_271962_7BDBED2A X-CRM114-Status: GOOD ( 12.62 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Having pinctrl entries defined for used gpios is helpful as it makes sure the pin isn't used anywhere else. The somewhat similar rk3588-jaguar board has a pinctrl entry already, so add the same for rk3588-tiger. Signed-off-by: Heiko Stuebner --- arch/arm64/boot/dts/rockchip/rk3588-tiger.dtsi | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/arm64/boot/dts/rockchip/rk3588-tiger.dtsi b/arch/arm64/boot/dts/rockchip/rk3588-tiger.dtsi index 4c5be356fa7fe..fb5f1fa25fb9e 100644 --- a/arch/arm64/boot/dts/rockchip/rk3588-tiger.dtsi +++ b/arch/arm64/boot/dts/rockchip/rk3588-tiger.dtsi @@ -56,6 +56,8 @@ pcie_refclk: pcie-clock-generator { clock-frequency = <100000000>; clock-output-names = "pcie3_refclk"; enable-gpios = <&gpio4 RK_PB4 GPIO_ACTIVE_HIGH>; /* PCIE30X4_CLKREQN_M1_L */ + pinctrl-names = "default"; + pinctrl-0 = <&pcie30x4_clkreqn_m1_l>; vdd-supply = <&vcca_3v3_s0>; }; @@ -339,6 +341,12 @@ module_led_pin: module-led-pin { }; }; + pcie30x4 { + pcie30x4_clkreqn_m1_l: pcie30x4-clkreqn-m1-l { + rockchip,pins = <4 RK_PB4 RK_FUNC_GPIO &pcfg_pull_none>; + }; + }; + usb3 { usb3_id: usb3-id { rockchip,pins =