From patchwork Thu Jan 9 21:18:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3792 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 906BD4173F for ; Thu, 9 Jan 2025 22:19:19 +0100 (CET) Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-5d3fe991854sf1366699a12.0 for ; Thu, 09 Jan 2025 13:19:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1736457559; cv=pass; d=google.com; s=arc-20240605; b=CGQ5YSQ1dRrYZSLLAygo1A52yiFKAvhT8TIATP017x179EgJ18HhY3etCwRZexCXdP Cqdi0HvIYhg2pk9MXjDgwNLrxZA1Yng8IBqaQOWIAscssD+O5HroT67SkJB0x5E1s1Zo u+ufTvuVScS5/n9cjOApWyYDSIF2Vb5X3gMEUIDrEiOS4LQXSJio8D6i0wyp3q5I9Imi a0pL2XoljLLJKF26vH9RGSO1u2V4vmWyroxCsMAj35G53C0mApV1xsn9Ey1Avpe41V4v Wg7OmuXs90PZMAofI3pYsQ+c+Ua5FglsLoDbBMVEP5IgknOBOdQZNZb/tuQNukv0/38S SlzA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=Cbc5DjvD5nD8JOylMVZ7iYP7Y35VpDR9IKbZDJINLZU=; fh=2ULE1xu2PPPlr3PVbsEABJ65jR0eL+hXkT1v9X3IpXg=; b=br/gagh7+fmCiCo59Ab4EXo32M82yZiMW7iuK/cjqNNGsbpgZbOUlhnpgpkD9QYKuM 3hxK2bx1uSpi/tpmmv9D1T6RjRjpVHLgM9EjJMHm3UZ4aixw2GrWgqYcXUYuIFDKsZpS 6aarNKM+RyWGxobIQJHAfHfVDqESflfuGih7AeTNBQIze3wgHTi2FcJKSwj+vX2ADdLA cPvmpO+snnIfETHxdxt3ywRzH7BHuixe/ovcYRr4lk5NcPACdHQaM08RRqL/BUEx/FIP AJChCFZbLLRyJkAlx3Ln/cw08EG9ErtY+mLcI7HXKUZwdT5KDJGHOca2J68fYyKnmvHJ MfIA==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=ZxInToGI; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1736457559; x=1737062359; darn=patchwork.amarulasolutions.com; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=Cbc5DjvD5nD8JOylMVZ7iYP7Y35VpDR9IKbZDJINLZU=; b=W5vrnPc4xYHUwgAfh8RDOyNiHKwjUUtEVGG3CQ31paVrCxoTswOCRNr7WXqwCs4Xg8 rRrS5sEOi4p1tGGkgtxQqDHyY7RMoXKbEZux43PPkIwgpYaG/o1Y2z9qyERjclcu9nEx +sfLerk6H811WoQGS5Azbx2gZRClRZrK1Pj8Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736457559; x=1737062359; h=list-unsubscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :x-beenthere:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Cbc5DjvD5nD8JOylMVZ7iYP7Y35VpDR9IKbZDJINLZU=; b=ueJmLN8gcspCVl3cdsi8/PFiDK4DdtYRhv31nJRfh0j4Upw+lFGIbyubv5qdQYc0cb wD/C2oHB0n/8XRlQk7BTiPoTW+sxv6AlMUY0N5QqDmRO+weqLZfuGvOfce3DVUtiTh45 Rjc/mgNcZT96m8r2K8eYWFqYExljUFMNfWs94xvBO8/JjEp0W20N6oxnpIuDQyCaYRi5 P4aFaWcCpp/F9YO1l216i/u71N7VJpzs/eHkCDqrI8lhIh7RahQMtM+u8Ie0cVIUMUlU 4NxE7+TKd0SG2UbEWstVKIFokqPQ12izG8Xb7+9TEO+Ao1GGVf2Aya2PMT77AzhattxN 0kdw== X-Forwarded-Encrypted: i=2; AJvYcCVkKED0C1zcyQmUU5FfpjN+HsF6wwO+aMfJCvBa7UbFQH/pftli71U6hRBKfDSFn6F8hKV1dDFSI8sZGUwB@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0YxCDl3czcoNsrE6LmCzLsvq24XutceJPaWbJPI7n69v7rXpPDJA jg8VN/+Ivzz6bCRE2b4IwKhDDfZvf0SR5WtdUn1RFusNWaUmbYh/xp9nj7osgljvQA== X-Google-Smtp-Source: AGHT+IF5D7rslEPwdAjlCbCDKSVZTOXKFkv/QLQrFPMfyL+fObSwOyILoc77cPjJGaQR0obFQR7/Cw== X-Received: by 2002:a05:6402:5246:b0:5d0:ceec:dee1 with SMTP id 4fb4d7f45d1cf-5d972e0af6bmr8164933a12.13.1736457559045; Thu, 09 Jan 2025 13:19:19 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a50:cc8f:0:b0:5d3:ea2f:696f with SMTP id 4fb4d7f45d1cf-5d9851c93f6ls475954a12.0.-pod-prod-01-eu; Thu, 09 Jan 2025 13:19:17 -0800 (PST) X-Received: by 2002:a05:6402:280e:b0:5d3:e9fd:9a15 with SMTP id 4fb4d7f45d1cf-5d972e6f473mr7969824a12.32.1736457557258; Thu, 09 Jan 2025 13:19:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1736457557; cv=none; d=google.com; s=arc-20240605; b=Kjo4w53p6lyfgATFIgZRtxjdK+p4Uvoxi7jHS8aXTpZDiFIfKGCnkURa3NM/P5Fwjq f87aXuipotX/yAtRJhgr8LKNWVAzNAflp5Je6cJ+0fADE/xb3EFGBMaMImFou62DxpCq tlErUnsehKDevt5IvtcjPlNGuW8icsITn/gYM0Ds+yzA3u4p6Af9dZ6wep9RPlwPgpip lh4Qc0JMlaTqpm2Ms3U3o7/RxTXtzUL+hux77gCwCAjOWAZ+pgitRw3jOKVv1Ult94cm XA8zBCznd1YPMGZUeq564cedv/J2cs0cOIrpgc+3582XoJ1Py0PkXRLnP9Y+xEzJZpxw 2wtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=kMDwINMgp57JdnWDRo35bVQVHIu764enuWXH+P8QtD8=; fh=YFlUV5ccCq4J8t54esOF4Sg6NxdNpGYs78cMg2bEWwM=; b=CF3BhqAEtJG/pne1e/QkwnJLCJ4DN81UzKuhdhvCb2rOfyYbWvj9sxfdAdj41M5X1P 3YpysGawFUAmpoeb3fvf+CdDyT0KyarEEXkW9lFdDKtGHzmYI6kjxH6ZW0k7mirrZgzy 9C73QTiCafvYPSD/bJtWTWvFjbu4qvMOQ6vNZjMp7AzTuz4LNI2LD06q2G/ca413YbR4 IoGmAbVPTB9o2tgT+jVXPyA3ZZ2N1aYOhR/wd1qd1TlQiIyrnTrdXBjyeTuDXsq1996z onqDSfaLQa+cMmwMnXhtRdCM1AZ6E4yuUeK+aV4tXHV2z2w2wlQOjDXPnxw7/IW3U0lN zLrA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=ZxInToGI; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id 4fb4d7f45d1cf-5d9903bcc57sor942534a12.5.2025.01.09.13.19.17 for (Google Transport Security); Thu, 09 Jan 2025 13:19:17 -0800 (PST) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Gm-Gg: ASbGncse+ziczqLfON3GinHY96QtbKZMK5e95LLSMHTqDOpp/od1Id4CtVzitr4j4ot c2r8pAwSYO8Q2O1s36A2pGNSwzDftcJejah9wwPsNtLtfXHOGowwoBOpUhH1kcbXBOsQ/TZxVbp FO1orEh+ouezoxcrSS0MZrCILdqXo84VK4ngEgm9i5oJMdpJvp4v2dItCUyEGDlaJzjkOcGtlNK w0iOACdjPnOkLw2jK+tSysYG+LXdHKknU8kQf5tpEcGQ2UZmP/pFAivUuZuJgLb4YmslAcjAyFY uOifn4533CfeMSnbu9bMSqO40N9MjreA0vpIAdwoUYNIRXHLj9cjLP41GaBiu34BQG8f3d4yxx4 iubsXKAWKmRQlUd+wwQ== X-Received: by 2002:a05:6402:3225:b0:5d9:b8a:9e08 with SMTP id 4fb4d7f45d1cf-5d972e1b768mr7727175a12.16.1736457556741; Thu, 09 Jan 2025 13:19:16 -0800 (PST) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-79-41-6-15.retail.telecomitalia.it. [79.41.6.15]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5d9900c4b56sm925567a12.32.2025.01.09.13.19.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2025 13:19:15 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Alexandre Torgue , Conor Dooley , Krzysztof Kozlowski , Maxime Coquelin , Michael Turquette , Philipp Zabel , Rob Herring , Stephen Boyd , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com Subject: [PATCH v2 1/4] dt-bindings: clock: convert stm32 rcc bindings to json-schema Date: Thu, 9 Jan 2025 22:18:28 +0100 Message-ID: <20250109211908.1553072-2-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250109211908.1553072-1-dario.binacchi@amarulasolutions.com> References: <20250109211908.1553072-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=ZxInToGI; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The patch converts st,stm32-rcc.txt to the JSON schema, but it does more than that. The old bindings, in fact, only covered the stm32f{4,7} platforms and not the stm32h7. Therefore, to avoid patch submission tests failing, it was necessary to add the corresponding compatible (i. e. st,stm32h743-rcc) and specify that, in this case, 3 are the clocks instead of the 2 required for the stm32f{4,7} platforms. Additionally, the old bindings made no mention of the st,syscfg property, which is used by both the stm32f{4,7} and the stm32h7 platforms. The patch also fixes the files referencing to the old st,stm32-rcc.txt. Signed-off-by: Dario Binacchi Reviewed-by: Krzysztof Kozlowski --- Changes in v2: - Fixup patches: 2/6 dt-bindings: reset: st,stm32-rcc: update reference due to rename 3/6 dt-bindings: clock: stm32fx: update reference due to rename - Update the commit message - Reduce the description section of the yaml file - List the items with description for the clocks property - Use only one example - Rename rcc to clock-controller@58024400 for the node of the example .../bindings/clock/st,stm32-rcc.txt | 138 ------------------ .../bindings/clock/st,stm32-rcc.yaml | 111 ++++++++++++++ .../bindings/reset/st,stm32-rcc.txt | 2 +- include/dt-bindings/clock/stm32fx-clock.h | 2 +- 4 files changed, 113 insertions(+), 140 deletions(-) delete mode 100644 Documentation/devicetree/bindings/clock/st,stm32-rcc.txt create mode 100644 Documentation/devicetree/bindings/clock/st,stm32-rcc.yaml diff --git a/Documentation/devicetree/bindings/clock/st,stm32-rcc.txt b/Documentation/devicetree/bindings/clock/st,stm32-rcc.txt deleted file mode 100644 index cfa04b614d8a..000000000000 --- a/Documentation/devicetree/bindings/clock/st,stm32-rcc.txt +++ /dev/null @@ -1,138 +0,0 @@ -STMicroelectronics STM32 Reset and Clock Controller -=================================================== - -The RCC IP is both a reset and a clock controller. - -Please refer to clock-bindings.txt for common clock controller binding usage. -Please also refer to reset.txt for common reset controller binding usage. - -Required properties: -- compatible: Should be: - "st,stm32f42xx-rcc" - "st,stm32f469-rcc" - "st,stm32f746-rcc" - "st,stm32f769-rcc" - -- reg: should be register base and length as documented in the - datasheet -- #reset-cells: 1, see below -- #clock-cells: 2, device nodes should specify the clock in their "clocks" - property, containing a phandle to the clock device node, an index selecting - between gated clocks and other clocks and an index specifying the clock to - use. -- clocks: External oscillator clock phandle - - high speed external clock signal (HSE) - - external I2S clock (I2S_CKIN) - -Example: - - rcc: rcc@40023800 { - #reset-cells = <1>; - #clock-cells = <2> - compatible = "st,stm32f42xx-rcc", "st,stm32-rcc"; - reg = <0x40023800 0x400>; - clocks = <&clk_hse>, <&clk_i2s_ckin>; - }; - -Specifying gated clocks -======================= - -The primary index must be set to 0. - -The secondary index is the bit number within the RCC register bank, starting -from the first RCC clock enable register (RCC_AHB1ENR, address offset 0x30). - -It is calculated as: index = register_offset / 4 * 32 + bit_offset. -Where bit_offset is the bit offset within the register (LSB is 0, MSB is 31). - -To simplify the usage and to share bit definition with the reset and clock -drivers of the RCC IP, macros are available to generate the index in -human-readble format. - -For STM32F4 series, the macro are available here: - - include/dt-bindings/mfd/stm32f4-rcc.h - -Example: - - /* Gated clock, AHB1 bit 0 (GPIOA) */ - ... { - clocks = <&rcc 0 STM32F4_AHB1_CLOCK(GPIOA)> - }; - - /* Gated clock, AHB2 bit 4 (CRYP) */ - ... { - clocks = <&rcc 0 STM32F4_AHB2_CLOCK(CRYP)> - }; - -Specifying other clocks -======================= - -The primary index must be set to 1. - -The secondary index is bound with the following magic numbers: - - 0 SYSTICK - 1 FCLK - 2 CLK_LSI (low-power clock source) - 3 CLK_LSE (generated from a 32.768 kHz low-speed external - crystal or ceramic resonator) - 4 CLK_HSE_RTC (HSE division factor for RTC clock) - 5 CLK_RTC (real-time clock) - 6 PLL_VCO_I2S (vco frequency of I2S pll) - 7 PLL_VCO_SAI (vco frequency of SAI pll) - 8 CLK_LCD (LCD-TFT) - 9 CLK_I2S (I2S clocks) - 10 CLK_SAI1 (audio clocks) - 11 CLK_SAI2 - 12 CLK_I2SQ_PDIV (post divisor of pll i2s q divisor) - 13 CLK_SAIQ_PDIV (post divisor of pll sai q divisor) - - 14 CLK_HSI (Internal ocscillator clock) - 15 CLK_SYSCLK (System Clock) - 16 CLK_HDMI_CEC (HDMI-CEC clock) - 17 CLK_SPDIF (SPDIF-Rx clock) - 18 CLK_USART1 (U(s)arts clocks) - 19 CLK_USART2 - 20 CLK_USART3 - 21 CLK_UART4 - 22 CLK_UART5 - 23 CLK_USART6 - 24 CLK_UART7 - 25 CLK_UART8 - 26 CLK_I2C1 (I2S clocks) - 27 CLK_I2C2 - 28 CLK_I2C3 - 29 CLK_I2C4 - 30 CLK_LPTIMER (LPTimer1 clock) - 31 CLK_PLL_SRC - 32 CLK_DFSDM1 - 33 CLK_ADFSDM1 - 34 CLK_F769_DSI -) - -Example: - - /* Misc clock, FCLK */ - ... { - clocks = <&rcc 1 STM32F4_APB1_CLOCK(TIM2)> - }; - - -Specifying softreset control of devices -======================================= - -Device nodes should specify the reset channel required in their "resets" -property, containing a phandle to the reset device node and an index specifying -which channel to use. -The index is the bit number within the RCC registers bank, starting from RCC -base address. -It is calculated as: index = register_offset / 4 * 32 + bit_offset. -Where bit_offset is the bit offset within the register. -For example, for CRC reset: - crc = AHB1RSTR_offset / 4 * 32 + CRCRST_bit_offset = 0x10 / 4 * 32 + 12 = 140 - -example: - - timer2 { - resets = <&rcc STM32F4_APB1_RESET(TIM2)>; - }; diff --git a/Documentation/devicetree/bindings/clock/st,stm32-rcc.yaml b/Documentation/devicetree/bindings/clock/st,stm32-rcc.yaml new file mode 100644 index 000000000000..779e547700be --- /dev/null +++ b/Documentation/devicetree/bindings/clock/st,stm32-rcc.yaml @@ -0,0 +1,111 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/clock/st,stm32-rcc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: STMicroelectronics STM32 Reset Clock Controller + +maintainers: + - Dario Binacchi + +description: | + The RCC IP is both a reset and a clock controller. + The reset phandle argument is the bit number within the RCC registers bank, + starting from RCC base address. + +properties: + compatible: + oneOf: + - items: + - const: st,stm32f42xx-rcc + - const: st,stm32-rcc + - items: + - enum: + - st,stm32f469-rcc + - const: st,stm32f42xx-rcc + - const: st,stm32-rcc + - items: + - const: st,stm32f746-rcc + - const: st,stm32-rcc + - items: + - enum: + - st,stm32f769-rcc + - const: st,stm32f746-rcc + - const: st,stm32-rcc + - items: + - const: st,stm32h743-rcc + - const: st,stm32-rcc + + reg: + maxItems: 1 + + '#reset-cells': + const: 1 + + '#clock-cells': + enum: [1, 2] + + clocks: + minItems: 2 + maxItems: 3 + + st,syscfg: + $ref: /schemas/types.yaml#/definitions/phandle + description: + Phandle to system configuration controller. It can be used to control the + power domain circuitry. + +required: + - compatible + - reg + - '#reset-cells' + - '#clock-cells' + - clocks + - st,syscfg + +allOf: + - if: + properties: + compatible: + contains: + const: st,stm32h743-rcc + then: + properties: + '#clock-cells': + const: 1 + description: | + The clock index for the specified type. + clocks: + items: + - description: high speed external (HSE) clock input + - description: low speed external (LSE) clock input + - description: Inter-IC sound (I2S) clock input + else: + properties: + '#clock-cells': + const: 2 + description: | + - The first cell is the clock type, possible values are 0 for + gated clocks and 1 otherwise. + - The second cell is the clock index for the specified type. + clocks: + items: + - description: high speed external (HSE) clock input + - description: Inter-IC sound (I2S) clock input + +additionalProperties: false + +examples: + # Reset and Clock Control Module node: + - | + clock-controller@58024400 { + compatible = "st,stm32h743-rcc", "st,stm32-rcc"; + reg = <0x58024400 0x400>; + #clock-cells = <1>; + #reset-cells = <1>; + clocks = <&clk_hse>, <&clk_lse>, <&clk_i2s>; + st,syscfg = <&pwrcfg>; + }; + +... diff --git a/Documentation/devicetree/bindings/reset/st,stm32-rcc.txt b/Documentation/devicetree/bindings/reset/st,stm32-rcc.txt index 01db34375192..384035e8e60b 100644 --- a/Documentation/devicetree/bindings/reset/st,stm32-rcc.txt +++ b/Documentation/devicetree/bindings/reset/st,stm32-rcc.txt @@ -3,4 +3,4 @@ STMicroelectronics STM32 Peripheral Reset Controller The RCC IP is both a reset and a clock controller. -Please see Documentation/devicetree/bindings/clock/st,stm32-rcc.txt +Please see Documentation/devicetree/bindings/clock/st,stm32-rcc.yaml diff --git a/include/dt-bindings/clock/stm32fx-clock.h b/include/dt-bindings/clock/stm32fx-clock.h index e5dad050d518..b6ff9c68cb3f 100644 --- a/include/dt-bindings/clock/stm32fx-clock.h +++ b/include/dt-bindings/clock/stm32fx-clock.h @@ -10,7 +10,7 @@ * List of clocks which are not derived from system clock (SYSCLOCK) * * The index of these clocks is the secondary index of DT bindings - * (see Documentation/devicetree/bindings/clock/st,stm32-rcc.txt) + * (see Documentation/devicetree/bindings/clock/st,stm32-rcc.yaml) * * e.g: ; From patchwork Thu Jan 9 21:18:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3793 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 1EE064173F for ; Thu, 9 Jan 2025 22:19:22 +0100 (CET) Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-5d3fe991854sf1366764a12.0 for ; Thu, 09 Jan 2025 13:19:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1736457562; cv=pass; d=google.com; s=arc-20240605; b=jKTcrXIUZKix4jQXQbPf7h26GkQe53zIFWlL4jFWyx/TZt2O8oBBh9+cv4e15POjlc iuifmvS9Qu8oMgFv4zGDCSSN+ey4p1raEQy6nczbKHt8isEQRJjAPD3RdXBOuECDGwvq Y3rH/EYQVwfJXsKx1854jlYKEXbbgFLhzbKhM0htYWz8XA3msClOsvP/6mrgClLz64Bv kRZpPIqrUQjszznjUnkvjnYUxTT91D6z98YvxHhx/jD0MxgExEvosQiCqmEmMb1AFfaf /SOh6tqblDbyxIywu2OKtqhiyY8oe3usJNmNxGU2nQoJH5yH3y682Gh17JDxCTiNikse mD0w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=vV3mfIBJlCDgJaVLtXYTAc49Iq5XARsbh/+pemiJMOs=; fh=3rpf7UtSqJAzrTakccLdSs4gxeMOZXiLYaoLgBcwsM8=; b=LB2jPFI2HeS+VGmBzsYmzCFBQ9F8KqHY4iHD90yMNfltwyn8+mQDOuXOdweNxA1JL8 CpefhmkEr9EVX/bZk3uGH1UyJFdCauojQf7pFUj9RYd7ONYWZC+PAQRQZIo3jjXndyln uM3Ag0crJsLrXC+lyORsixK81DVLV/Lplfcgjx49uTZ/Dk1kZQ0G41cijr4EPMciZxKn I7Y4LeGdUGWKNb33aelPL/qaIrY1DTLG1nAXUu3pR20QKCv3zBI2f5t8ctoOv2XsWf4a 4q26A5QNMdkHyZrjkhLVgJbuvu+PzWWTsRjj76iqelykBx6qV7PdLMLBVPAX6dFdQ1sX 8QIw==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=HOr4GNoY; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1736457562; x=1737062362; darn=patchwork.amarulasolutions.com; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=vV3mfIBJlCDgJaVLtXYTAc49Iq5XARsbh/+pemiJMOs=; b=G1NOqd8QlS256EfbVR1igdgowMK3hgZkJeNu1YU392Dlyq5O80sDfCLBEwofhb6h0v 9BKasS1oDE46i14QwaQKVCG+UEIR5ee/1ch5Lgunbv6zOBIZOs+w0HezvRuaBfYq+33U muxB6lwK8PGjN+Kv63VVSR5J+MwXRtnm8vZ6E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736457562; x=1737062362; h=list-unsubscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :x-beenthere:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=vV3mfIBJlCDgJaVLtXYTAc49Iq5XARsbh/+pemiJMOs=; b=ca1CbcGHX0efAPTb4qEhGNSuS5HAHBDtzs6B628eET65A0MlSN3Cj5vz4+gr4nVZs3 ZTlTUOoQoBVRTNpVcVYjfL9DwsFTO+XNq9mJ1RCH1wMBQAc3Y3lOd2mV3MLkD/0WwAIj MO0t04tey2B4nVdvFm0vf4K+Iv4R3zFNXgovCuL/7DrA7Iuw0Z9p6GKJBr+mqVl1zG8B fp6LBSlFJlPF4FZKUXEd3TgGvyVlJ+vusv7IGyrwrBLTth61Qs3cvO9iqb10uWPfFdXf ek9RbER9uuUJn88M67oV6ggGTGXgce0WJ5vsHeA84B4nSboYlpguZoCY6oR+RU26S9WT cHLA== X-Forwarded-Encrypted: i=2; AJvYcCV28XHzW1EJciiDaBjZ8xu2GureMoTNwYqmMRp+w8fJ1GV4GknBF8P+tAU889NfCJOk/oO2K++EY8Yf0PFr@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0YyAg75PdDQoh87ti9wvY8slmAsyFckOdOScne+TuD//l9T1tMwF Moil01T6X4urh7Kt8jeHw7E6mD5ae6z3TjkvA45Ci/AtQkzUpp8SrC00otucQNDKVQ== X-Google-Smtp-Source: AGHT+IETng90WtWucWEfYBOi5bbE8jZ86unzOkTHWaoEEV9ZK7g2G95s335kHyZGFc7aGRd/RXFWjg== X-Received: by 2002:a05:6402:13c8:b0:5d1:43e4:bcaf with SMTP id 4fb4d7f45d1cf-5d972d26597mr7504083a12.0.1736457561628; Thu, 09 Jan 2025 13:19:21 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a50:d51a:0:b0:5d9:7c9f:1d95 with SMTP id 4fb4d7f45d1cf-5d9856b5790ls509915a12.2.-pod-prod-01-eu; Thu, 09 Jan 2025 13:19:20 -0800 (PST) X-Received: by 2002:a05:6402:5246:b0:5d0:ceec:dee1 with SMTP id 4fb4d7f45d1cf-5d972e0af6bmr8164982a12.13.1736457559798; Thu, 09 Jan 2025 13:19:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1736457559; cv=none; d=google.com; s=arc-20240605; b=Y45sslrcwWFV9CGEH3NR7T1J2GTboJnIpWBosxyq/Mu8DkvuIGFBGlKJyE6jDkKzmy RI1Pu//zlSgjBCd/j05a2Fb3/cGW4wfcIIkBmhQhohOR3cFfAZPs3c/WdLajC/9jo608 F/TiXs/CGhdF6v+gMb/OCxBDdVjpILQW6LPxnDdSeVrRsUmliRC6/bBRG9R/zJolHXD4 Eg1/UyI6TjQ1xLZDpChVrojdG2/1CzJKRTuMYrWsB14UXzkyXo13zpWixGtOFzg75pUj /DQVUaYxuDu1ejR5ap1p2Jw5jr64mR38prQkWkVvD7VGks9lIS+YYjjooNk272AlIWCu J/8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=68CdHAZCqU/700PS8wNVBBVrBBOJwhpJC23uvX7+CAE=; fh=eH+0Y7Diz6V5mR4yjTADWqq/BPeQ1lWG3GpSj4kCN9U=; b=NAxnfbOxiS1M8LCVsFJWAWbY1DddiOTQn4Kx9t2BKHujEUXCtf8Jw3EAVZExQo1OOu 7QSbuiLmdJxyXhWu6GkXe/nVDOz2J+l80m1iwitJQK11hQ98sLcFEoNj5i7TX8i1gy1s ly8fUiZAzVn5IVBMNj7zSqtFgDPVKrgJa0tyVGiZkQBR49YSBrqw9FWcq1fAr1Vg4S1c V6UYm3ctaBDZAYdm1qgVt0pKQNOh9xXTv+xKlUq8LaKJs1iGuOK/sVrVNP9gIbzJev0O eoVny1/TQ+yv91wcTf7/m0BG60CrjfAHU5TvQv4IZkUu+srQv4MPD4412nIW6qI0t+Ds ssTA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=HOr4GNoY; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id 4fb4d7f45d1cf-5d9903bb494sor1078937a12.4.2025.01.09.13.19.19 for (Google Transport Security); Thu, 09 Jan 2025 13:19:19 -0800 (PST) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Gm-Gg: ASbGncsmhBmrB5gsrVv6FsSof7dmPMc1Tb3H3p/BniZ3PfOVXtNHnXfOdBeWxRVBnAK RzpUHRD0PRegGNuvXqQT/5CxBqox1I1VBa4WsIsUVOMMyMhbM6gao7QNNfWOVkW6VoduK02/3Rs XGwCTumQAUewul6TGVbL6isOvyPCldl2a+WWo/palSv/VQsi2xV2IUls7cso7CSm4S6adgI3fxm DFqKCx9w6AiicLBBZ2wZVvXmwcUw2VNECbkIvsUICg1oipQHnpgElCt/qTeqi/fR8m8/CHrI4U4 eY1kZxh9G8mr0C7KWyaBYrAvDy+LlJbCS/QebzywsjCPCrmp7qVVnouZR8QlbA0c3xVrX7TpE01 /yAxB/zkXVG/ehad7RA== X-Received: by 2002:a05:6402:4407:b0:5d3:d733:7ad4 with SMTP id 4fb4d7f45d1cf-5d972dfe6abmr8251883a12.3.1736457559390; Thu, 09 Jan 2025 13:19:19 -0800 (PST) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-79-41-6-15.retail.telecomitalia.it. [79.41.6.15]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5d9900c4b56sm925567a12.32.2025.01.09.13.19.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2025 13:19:18 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Alexandre Torgue , Conor Dooley , Krzysztof Kozlowski , Maxime Coquelin , Michael Turquette , Rob Herring , Stephen Boyd , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com Subject: [PATCH v2 2/4] dt-bindings: clock: st,stm32-rcc: support spread spectrum clocking Date: Thu, 9 Jan 2025 22:18:29 +0100 Message-ID: <20250109211908.1553072-3-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250109211908.1553072-1-dario.binacchi@amarulasolutions.com> References: <20250109211908.1553072-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=HOr4GNoY; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The addition of DT bindings for enabling and tuning spread spectrum clocking generation is available only for the main PLL of stm32f{4,7} platforms. Signed-off-by: Dario Binacchi Reviewed-by: Krzysztof Kozlowski --- Changes in v2: - Update the commit message - Change st,ssc-modmethod type from non-unique-string-array to string .../bindings/clock/st,stm32-rcc.yaml | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/Documentation/devicetree/bindings/clock/st,stm32-rcc.yaml b/Documentation/devicetree/bindings/clock/st,stm32-rcc.yaml index 779e547700be..628bbbcf2875 100644 --- a/Documentation/devicetree/bindings/clock/st,stm32-rcc.yaml +++ b/Documentation/devicetree/bindings/clock/st,stm32-rcc.yaml @@ -56,6 +56,26 @@ properties: Phandle to system configuration controller. It can be used to control the power domain circuitry. + st,ssc-modfreq-hz: + description: + The modulation frequency for main PLL (in Hz) + + st,ssc-moddepth-permyriad: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + The modulation rate for main PLL (in permyriad, i.e. 0.01%) + minimum: 25 + maximum: 200 + + st,ssc-modmethod: + $ref: /schemas/types.yaml#/definitions/string + description: + The modulation techniques for main PLL. + items: + enum: + - center-spread + - down-spread + required: - compatible - reg @@ -81,6 +101,10 @@ allOf: - description: high speed external (HSE) clock input - description: low speed external (LSE) clock input - description: Inter-IC sound (I2S) clock input + st,ssc-modfreq-hz: false + st,ssc-moddepth-permyriad: false + st,ssc-modmethod: false + else: properties: '#clock-cells': @@ -98,6 +122,18 @@ additionalProperties: false examples: # Reset and Clock Control Module node: + - | + clock-controller@40023800 { + compatible = "st,stm32f42xx-rcc", "st,stm32-rcc"; + reg = <0x40023800 0x400>; + #clock-cells = <2>; + #reset-cells = <1>; + clocks = <&clk_hse>, <&clk_i2s_ckin>; + st,syscfg = <&pwrcfg>; + st,ssc-modfreq-hz = <10000>; + st,ssc-moddepth-permyriad = <200>; + st,ssc-modmethod = "center-spread"; + }; - | clock-controller@58024400 { compatible = "st,stm32h743-rcc", "st,stm32-rcc"; From patchwork Thu Jan 9 21:18:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3794 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 2A7C64173F for ; Thu, 9 Jan 2025 22:19:23 +0100 (CET) Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-aa67f03ca86sf95934266b.2 for ; Thu, 09 Jan 2025 13:19:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1736457563; cv=pass; d=google.com; s=arc-20240605; b=VFP41zGUaxrqd/FU88GAf6kr0beqPlrHQiz9JZQ6/ZH6/KWq4CUM1sl2nyxkzMbR5o A+vQ2hL42gMQMwSTRlkTyAcam8kVUhqwzFykdrfWWFGAEWRiHTFZD8Px6lapNhqlDWB0 G3dyzDxXaNzvmqoWBFaOBpbsrcMfzc89K9HiXxg049ehjwCyS1pX3Zb8ymXOhKh+NIyH gjpe4S7vh+mGxP4fOL0AVB2f2tkbCk0XkHTSYp/IGPyNSCxWEPhFbYWbb0naaxavmFzt nK0EBdc1/mkK1h1xZnKOSZX3rXEatNkEcRQeVs3V4g85zUA99yn/zMIlStsmbXZdsaWU jaTg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=XtbjdETKR/arvBjKY7fm1vE6kJB4kTw5aeYbUgY4Kd0=; fh=QTgKwgZAfXKcQQV+dp3IMCmXX0NkFdh6fUNcYzK3X+o=; b=e9Pp6pg9BAynapFLB5PpSr6IFDmnALeK24XYTxv3LD8RGnwQm3BqVbZLV42z17Cx41 cxZLxcFzCNqFb45QimlvmvcU2bg6Vd5aGCFPIW8COtk9bvUdB931qq+DS+ScdUHRp1G1 DHFdeIEWrpqkdqXLjT596Q814pwgXXvB+D1Fecs/OV5ttUtYGDd8UpDA1xYjkQaKvGiW ceGbIwBujlxS84l4MCaBd26/zLeR6h9PFzMryekyQFMSno6frW5ACYaVdGT4z9VDBHVH NiQ6FAXbBFDA06KSFzBzou1e7NxOYBTXU6UN8EUgimJNLYiJHdl1D5ZaTPvDKF3OTNF/ h5vA==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=I5GgHCBE; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1736457563; x=1737062363; darn=patchwork.amarulasolutions.com; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=XtbjdETKR/arvBjKY7fm1vE6kJB4kTw5aeYbUgY4Kd0=; b=pCU2QJbpsGMWGpAXxt+XJt/xZdpN6reY+cD5Sbh5qoGDp2JNsIU+fSLogT6uXLhczJ YB+gPPtOFI7PD82gPQB5F+ymK3+33kPXgv6UXkyRINxP1sxn5N3QC9fo52VnSMUUXgFO y1fy8z8STuZMmt621wwAPHEV3O2MRk0l8G2M8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736457563; x=1737062363; h=list-unsubscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :x-beenthere:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=XtbjdETKR/arvBjKY7fm1vE6kJB4kTw5aeYbUgY4Kd0=; b=v6ssKdyID0OgMzzKvjwc0/wOTMXELHO6VP5eGcYK8SLDQDTbdQzzrSlRVOnjGfzB6x r93NUqFd529v1irX/nVbCegLb5jJam9Co6tXjDSq9czBwEEcOE81GNb69NX6xUrvrJy0 x+dH/184UiFOckVPKV1+UxibJl2z5Kkm8taQhP/Etfxb8z6i/H6Eti/16sFxHj6rcwLL Dev916VlbOPYxF4W8RsRfvzRP0AFC3MVbsJQoB7g8udWaDIDT3Gf/+zh4wBsRrEUUJML 8UWq7oZIAOJ7tO2cNY9JFSaSj1KiOvUv60WFoKN/nGCa1urFtpwl2VU+xr/kRhg/TuAo 3viQ== X-Forwarded-Encrypted: i=2; AJvYcCUbcBxXu5c4yRmGcpEaxwm320yxV5qzfI7+KQTDQlpK4lp5vAMJxtp6xkMOPysly/oftBjwZJebmO3h8osX@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0YxJWTzJ4+I6QHlr9V6lftAGPYD3WmliDf28sbz9TOzG3iyN2U1x i+eDv9K11JLIftjmLcXJmRwF3aEvYEuI0JAitfXyPbTElC8dZUPClCZyzofcg99SGg== X-Google-Smtp-Source: AGHT+IFdahOK2A0LTn2/AnVORd0dG9pSh2yBkjPxWOaL1TDumXG3lS5anrvtLpfYiiGCLj8IBFd8Bw== X-Received: by 2002:a05:6402:40c1:b0:5d1:1064:326a with SMTP id 4fb4d7f45d1cf-5d972e1c39fmr18965795a12.15.1736457562761; Thu, 09 Jan 2025 13:19:22 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a50:d485:0:b0:5d0:e410:4698 with SMTP id 4fb4d7f45d1cf-5d9855ad73dls464247a12.1.-pod-prod-05-eu; Thu, 09 Jan 2025 13:19:21 -0800 (PST) X-Received: by 2002:a05:6402:26cf:b0:5d4:55e:f99e with SMTP id 4fb4d7f45d1cf-5d972e1d7dfmr19583239a12.18.1736457560905; Thu, 09 Jan 2025 13:19:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1736457560; cv=none; d=google.com; s=arc-20240605; b=E8aGijDBkRIKuJd+nqXu3yfH8lUP94DSviXIGuQVwsCS/rw5rA3AO3Ew5s746X+YjT LuZsaMaFKX7p5v16rOjQjXYEW/4Bx2VU7aNuklsfn5UQn0YRC6yCA6+0f/sdD+FenbRM 7dmOR8lRtF51pnbYL8EjVy2OfoyCbNdxJhoDBdQgxEpnIawzXckQZgYZ2zaz+hp/fpzf QtYITsGhvjbGDd1jyJLeOkuXBFeLO7s4npoBVKhT5j39s1WlIYvysj6R8UabZ7/BsRY7 rve+gBlhhtqmMIxEIgGz7BdkeZDWhGZ5zIFtgiNiD7HEK9r3Do9DOE2bsjGnNaj2IpX2 2f4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=4PuckIz6TtMrm6FhKB7AMqxRoyDL7dpmszhuAU6edRg=; fh=LKhgYKqW/DH7bOgdnVELRgL+gR1eISg3bEXUN1rI9pA=; b=Jg0WZjlhCMjdvwibJ84G7M85Z7iFcGY6NwL7JcmKRu4MOIhUzwE1ixH6xQCCDiQ4xK O4ngTMy6jSnGheFucpRu9PNzkoNLtv4zRXV0Nrb8dIs8nbQR/Kr1y7/7gk3VZWxM8gY0 gvSXHAw1fToR2BRJ7bIbA6XIC1jMO1dVi96ra8QkqQ5T+QteFm14xZzYYgL4fogM6EvI q62DIAxZthLq7f/M4zX6He1vN3fucWnxYz697a2EKgv5qY4WAO81dwVzguoHZ3RThpgA Fjt/JgCAdLeyTtWg8oa3UDZpKXOI+x5FA9r6jDQUcncBeZLvXx86KHzE5B5FItnoyJRP VE8w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=I5GgHCBE; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id a640c23a62f3a-ab2c90dc5b1sor86274766b.7.2025.01.09.13.19.20 for (Google Transport Security); Thu, 09 Jan 2025 13:19:20 -0800 (PST) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Gm-Gg: ASbGncu/1z7xwGJbymo2XOqZGTJPCHT511hwPg2UqWgFRORFMsfne3Xhh3qHtRY2t/1 5YaRswZgRsSRV4V74QqAuhhiZHf/RwYP5V3EmG/c/j2HhdqVug1VtWa6B/h5YsGpMeD2OoIORbj dqRUu0mQ/AKP5dMkZgWVUXgxBA7FrBy7B72nrsSULcqAeT1msKQaTcetkMLdaZRi9MYbR0m2/Rz taDAsYaSfFEMX/lHSNxYpXWTrtEtjN4kLQM9a5Clg8V3/DIcip0GEeyyMzT+i7i9he74s10qIf6 ObMQEPo9fOia3CvU2mYOitQekpveHq7rrnOxfCpUhJObk8Hi3hwRRbWnANXIzujHoH0jihq8Tab P1moVbYYoOt9obmqH1Q== X-Received: by 2002:a05:6402:400a:b0:5d2:7199:ac2 with SMTP id 4fb4d7f45d1cf-5d972e00032mr18870795a12.2.1736457560441; Thu, 09 Jan 2025 13:19:20 -0800 (PST) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-79-41-6-15.retail.telecomitalia.it. [79.41.6.15]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5d9900c4b56sm925567a12.32.2025.01.09.13.19.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2025 13:19:20 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Alexandre Torgue , Maxime Coquelin , Michael Turquette , Stephen Boyd , linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com Subject: [PATCH v2 3/4] clk: stm32f4: use FIELD helpers to access the PLLCFGR fields Date: Thu, 9 Jan 2025 22:18:30 +0100 Message-ID: <20250109211908.1553072-4-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250109211908.1553072-1-dario.binacchi@amarulasolutions.com> References: <20250109211908.1553072-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=I5GgHCBE; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Use GENMASK() along with FIELD_GET() and FIELD_PREP() helpers to access the PLLCFGR fields instead of manually masking and shifting. Signed-off-by: Dario Binacchi --- (no changes since v1) drivers/clk/clk-stm32f4.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/clk/clk-stm32f4.c b/drivers/clk/clk-stm32f4.c index 07c13ebe327d..db1c56c8d54f 100644 --- a/drivers/clk/clk-stm32f4.c +++ b/drivers/clk/clk-stm32f4.c @@ -5,6 +5,7 @@ * Inspired by clk-asm9260.c . */ +#include #include #include #include @@ -39,6 +40,8 @@ #define STM32F4_RCC_DCKCFGR 0x8c #define STM32F7_RCC_DCKCFGR2 0x90 +#define STM32F4_RCC_PLLCFGR_N_MASK GENMASK(14, 6) + #define NONE -1 #define NO_IDX NONE #define NO_MUX NONE @@ -632,9 +635,11 @@ static unsigned long stm32f4_pll_recalc(struct clk_hw *hw, { struct clk_gate *gate = to_clk_gate(hw); struct stm32f4_pll *pll = to_stm32f4_pll(gate); + unsigned long val; unsigned long n; - n = (readl(base + pll->offset) >> 6) & 0x1ff; + val = readl(base + pll->offset); + n = FIELD_GET(STM32F4_RCC_PLLCFGR_N_MASK, val); return parent_rate * n; } @@ -673,9 +678,10 @@ static int stm32f4_pll_set_rate(struct clk_hw *hw, unsigned long rate, n = rate / parent_rate; - val = readl(base + pll->offset) & ~(0x1ff << 6); + val = readl(base + pll->offset) & ~STM32F4_RCC_PLLCFGR_N_MASK; + val |= FIELD_PREP(STM32F4_RCC_PLLCFGR_N_MASK, n); - writel(val | ((n & 0x1ff) << 6), base + pll->offset); + writel(val, base + pll->offset); if (pll_state) stm32f4_pll_enable(hw); From patchwork Thu Jan 9 21:18:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3795 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 2CC6F4173F for ; Thu, 9 Jan 2025 22:19:25 +0100 (CET) Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-5d3bf75bbf1sf1337410a12.1 for ; Thu, 09 Jan 2025 13:19:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1736457565; cv=pass; d=google.com; s=arc-20240605; b=MUKq5F0qYNptlvj3MZUGq31r8fFNsA3hmvezB1pGuJ+wP85OfiiOmK/FZzD/eHQAdQ aYfYRVLwM4TJVKiZo88Ba5SgA8Iok+8nETKUts1dBnYJM5X9quWNi/bK+R6fiegVYud6 L+M1irq8KyhTg9owZoyw4XCUmbRwnh1YSVwwLJek5Xaq7stSYSqGMjKvWoMIOn5/mdeJ nCy8itZtPTRCD7gsZD9uNJ6zqLMAOQnmH+cykdiLEEsJ2EV3aP++cC2e9hva3bPwtLxr 9/ADoHcPd2jje4aSkFUXt82La8tvvF4J++GFcXh9uWPy/X00Wgj0dH1iAoSNjByFzyTd ENGA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=J0wQfIuD63U+vBkV3+ZhJU8RQ7vtbwkK73Xn7DO+Jok=; fh=adto3IhHGbCeg2+Hk0cv8VZ4X+RFz+be+EvjxCLIzyE=; b=JmIO9Sc7aYCqnFKOrVp6gx9i6iKSsUntNVpKQ0BjWj13sqWJJt44Z+vocE6UJHL2r2 CwF4t8U36PeBfYyIE9V/82JUqsXiB3kj7WIqPZpfWTUh5b3o7MVoEsHhIDJaZRUSCx78 4ki9H3bTYN27aBMZ342sanr/uPyRXQsyWvTZkN8i05rG013SqvfVe9tXnVJbYDwbudvg MFfrCdrULahz8vGItJEynJEYH26c9fXeIuDfr8qQ6qg/GY8QlHYPH66AKNqz6Aid2yfS j3f5OsG44WkUj6nFAXEd+zPQVxyRiMP+ELWBv1wC0XPexDnHjsA13FDtNghhnSK2KOHx eCEQ==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=FaIYTnY6; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1736457565; x=1737062365; darn=patchwork.amarulasolutions.com; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=J0wQfIuD63U+vBkV3+ZhJU8RQ7vtbwkK73Xn7DO+Jok=; b=PZ4IfdszlNTvsuEpuGJ8G/Yv8e/63HQmeIQJ9XVPiIRykl0MQFbG7WmX4nYOvLFb26 F4ZVqyhlcQyFwLAqXQNVsNTovmxMihikvVLanPSFSXrCBiEtG/vVxZrYHOE/KxD1YMe/ ZqgDIt9blR87ndbko8SQtVX6w7S253ybW94T0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736457565; x=1737062365; h=list-unsubscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :x-beenthere:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=J0wQfIuD63U+vBkV3+ZhJU8RQ7vtbwkK73Xn7DO+Jok=; b=kAg52dmAgGT3yr4J/V4ydJCaYFgwA9HImYruT1Rj2avkPC5gkz7UROSa+YEf0Ptfvh odMgGUkjTZ4uWbR0uAvC+MT4SyoC2yEgn2GkyChMT9JBNEejYh+LxEa6l7vTc6KrQcBv E0ZhOCGwn/ocZr60JVVa9VeANOPY9QzLmoIpCmA8nRyQsJfWJDyby/DCQNfueW5mYMIe vR80q0Q1Xd2wbC39Xsg9SnHXW2JjTc6qIL3GuWlVD7Jcw527KyhV6oMB+38cAi9EB2AY iQQM4QWc+RpvfIQyItaOgXUBRkE/Yva05CDd7W1lTye0dgZlQMb9u4qSdBtME3L4wPup 6AbQ== X-Forwarded-Encrypted: i=2; AJvYcCUOzRS7FeKdzFUjVHVKwHjdZ9o58fWJND73Ttk6RQ94myeiQz/QjbHMp62En+/JS/P02FhnZJ/mlpLn1ea2@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0YySW9IBVndraV2d1PEb7haVyIhKUI9eARbDKCZN8YnPxtvGvmrD InEeHe1TwH8+8GrmOam56MQTmKpxhDp1l3X3iu9FN+/adWg5zcp9/Vx5i2Po7YMGEA== X-Google-Smtp-Source: AGHT+IFRLvVh6gaVI4rcgOYDMs1aGI3EtHsFmoSxjwSHaLRFEO1nibCOwIpz4bPzZs3aJOXUtiByYA== X-Received: by 2002:a05:6402:4408:b0:5d3:eb50:4e33 with SMTP id 4fb4d7f45d1cf-5d9861d1511mr4211525a12.5.1736457564609; Thu, 09 Jan 2025 13:19:24 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a50:bb6d:0:b0:5d3:ce70:f232 with SMTP id 4fb4d7f45d1cf-5d9855ab306ls457420a12.2.-pod-prod-00-eu; Thu, 09 Jan 2025 13:19:23 -0800 (PST) X-Received: by 2002:a05:6402:518b:b0:5d0:d2b1:6831 with SMTP id 4fb4d7f45d1cf-5d98a50f99amr3621999a12.14.1736457562734; Thu, 09 Jan 2025 13:19:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1736457562; cv=none; d=google.com; s=arc-20240605; b=eudJ77V1aHz65JasrpFQMHvza0FCfwM2iAdE+pxiUDhY/wmt6MIpUuvA01X92svojV KANmYFC2t6LIeOVFMUCE2x1Q1drYAxBlagPTbOvPpr6stakWzbIlXHaWPQDOEFe0WbuC kgMp7Y8tXz7U45GqzESmsgKdXMserYd3buIpZb3MyB/S3gVu+cjU25lnnn74Mmrthyno 58Q8kOY4fB1FGnGcwjQmARfw0FW72G17KEg45viPu5Wz0/KZuP7xZBXMxX4JH9wNAWCy dbH1l0lNEIWkH2lT2tiYu2Fn5B6doLRVmnxiob/7aTgufVvv8QPiZhMOCNuY3VCHyXoj oUng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=iJ26hgnRMCLZPTXr7KLkVyqRMMqeBIF3e9Y1qTU0tFU=; fh=LKhgYKqW/DH7bOgdnVELRgL+gR1eISg3bEXUN1rI9pA=; b=YkjlS5muyxhPPofit/dWId9Y1s80g2EW6dvimdPM0/tpoP2OcjKKqwnD7OAfHQo2I1 GDC3IvUgY5n9r/DF6Asxm+KBtzwoH9eC8Z6o9OpS45+AUmuS8vDkfWQWf+JiL0K17mep 55awlhbhpfnHgvknkFn2OEGfRXfa5tyfUb6Hi1eO9AJB5Qv7cp9+cj/qy/5zTeUHCey1 JG1JLvhhI4XA08I0Uu0Qf0yb6ON7LZFqxiYg4gE3i2LHGLtlT8LNbDgplQja9DkQ245Z jWYtKYKQLsax3UFvi+qSr9HUkZNA7uVCEVjWDJ8vObDokqRr8pKDxq/yDa0YR6Ogw7mf ujXg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=FaIYTnY6; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id 4fb4d7f45d1cf-5d990442605sor989588a12.4.2025.01.09.13.19.22 for (Google Transport Security); Thu, 09 Jan 2025 13:19:22 -0800 (PST) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Gm-Gg: ASbGncshPHNjr/XsH4/tRcat6M7C2vDqbeafHUhKf7kYVOrtxEMIpczSQWfp+gJPFuR ZOA/7UQX8QMmu1jHG2mjQUea+oBMuAQK6S6QqpVp7Y6kwGmnZb0Bgz5CoPKlWPBos0UHa0Lo5Vt 3Oz7/BJTU6SpCAaNWqEuf1yVZcalsY+B+it49TjiuyPagwsrXInI3WZf47JTYelleE4CSP++4DG ozLVi0AxG8bkL2MudLrAaNjN+REjrj2c6pl4sTUY2iVUVcODuPBP0XKH8BDtkWEOh8g3CH/dm+K UlzKnTxdabxYR1RB2kSreHl8G6WMP8OhgTSC10IEe1IEaUVxfkHap3G6UerH2N6dXWGk/BwE95e UaGZKJgptUm86sIxelA== X-Received: by 2002:a05:6402:40cc:b0:5d0:d328:3a43 with SMTP id 4fb4d7f45d1cf-5d98a24a72fmr3294628a12.6.1736457562307; Thu, 09 Jan 2025 13:19:22 -0800 (PST) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-79-41-6-15.retail.telecomitalia.it. [79.41.6.15]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5d9900c4b56sm925567a12.32.2025.01.09.13.19.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2025 13:19:22 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Alexandre Torgue , Maxime Coquelin , Michael Turquette , Stephen Boyd , linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com Subject: [PATCH v2 4/4] clk: stm32f4: support spread spectrum clock generation Date: Thu, 9 Jan 2025 22:18:31 +0100 Message-ID: <20250109211908.1553072-5-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250109211908.1553072-1-dario.binacchi@amarulasolutions.com> References: <20250109211908.1553072-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=FaIYTnY6; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Support spread spectrum clock generation for the main PLL, the only one for which this functionality is available. Tested on the STM32F469I-DISCO board. Signed-off-by: Dario Binacchi --- Changes in v2: - Fixup patches: 2/6 dt-bindings: reset: st,stm32-rcc: update reference due to rename 3/6 dt-bindings: clock: stm32fx: update reference due to rename to 1/6 dt-bindings: clock: convert stm32 rcc bindings to json-schema - Changes to dt-bindings: clock: convert stm32 rcc bindings to json-schema - Changes to dt-bindings: clock: st,stm32-rcc: support spread spectrum clocking drivers/clk/clk-stm32f4.c | 143 +++++++++++++++++++++++++++++++++++++- 1 file changed, 140 insertions(+), 3 deletions(-) diff --git a/drivers/clk/clk-stm32f4.c b/drivers/clk/clk-stm32f4.c index db1c56c8d54f..6c80c0dbb0a3 100644 --- a/drivers/clk/clk-stm32f4.c +++ b/drivers/clk/clk-stm32f4.c @@ -35,6 +35,7 @@ #define STM32F4_RCC_APB2ENR 0x44 #define STM32F4_RCC_BDCR 0x70 #define STM32F4_RCC_CSR 0x74 +#define STM32F4_RCC_SSCGR 0x80 #define STM32F4_RCC_PLLI2SCFGR 0x84 #define STM32F4_RCC_PLLSAICFGR 0x88 #define STM32F4_RCC_DCKCFGR 0x8c @@ -42,6 +43,12 @@ #define STM32F4_RCC_PLLCFGR_N_MASK GENMASK(14, 6) +#define STM32F4_RCC_SSCGR_SSCGEN BIT(31) +#define STM32F4_RCC_SSCGR_SPREADSEL BIT(30) +#define STM32F4_RCC_SSCGR_RESERVED_MASK GENMASK(29, 28) +#define STM32F4_RCC_SSCGR_INCSTEP_MASK GENMASK(27, 13) +#define STM32F4_RCC_SSCGR_MODPER_MASK GENMASK(12, 0) + #define NONE -1 #define NO_IDX NONE #define NO_MUX NONE @@ -512,6 +519,17 @@ static const struct clk_div_table pll_divr_table[] = { { 2, 2 }, { 3, 3 }, { 4, 4 }, { 5, 5 }, { 6, 6 }, { 7, 7 }, { 0 } }; +enum stm32f4_pll_ssc_mod_type { + STM32F4_PLL_SSC_CENTER_SPREAD, + STM32F4_PLL_SSC_DOWN_SPREAD, +}; + +struct stm32f4_pll_ssc { + unsigned int mod_freq; + unsigned int mod_depth; + enum stm32f4_pll_ssc_mod_type mod_type; +}; + struct stm32f4_pll { spinlock_t *lock; struct clk_gate gate; @@ -519,6 +537,8 @@ struct stm32f4_pll { u8 bit_rdy_idx; u8 status; u8 n_start; + bool ssc_enable; + struct stm32f4_pll_ssc ssc_conf; }; #define to_stm32f4_pll(_gate) container_of(_gate, struct stm32f4_pll, gate) @@ -541,6 +561,7 @@ struct stm32f4_vco_data { u8 offset; u8 bit_idx; u8 bit_rdy_idx; + bool sscg; }; static const struct stm32f4_vco_data vco_data[] = { @@ -661,6 +682,34 @@ static long stm32f4_pll_round_rate(struct clk_hw *hw, unsigned long rate, return *prate * n; } +static void stm32f4_pll_set_ssc(struct clk_hw *hw, unsigned long parent_rate, + unsigned int ndiv) +{ + struct clk_gate *gate = to_clk_gate(hw); + struct stm32f4_pll *pll = to_stm32f4_pll(gate); + struct stm32f4_pll_ssc *ssc = &pll->ssc_conf; + u32 modeper, incstep; + u32 sscgr; + + sscgr = readl(base + STM32F4_RCC_SSCGR); + /* reserved field must be kept at reset value */ + sscgr &= STM32F4_RCC_SSCGR_RESERVED_MASK; + + modeper = DIV_ROUND_CLOSEST(parent_rate, 4 * ssc->mod_freq); + incstep = DIV_ROUND_CLOSEST(((1 << 15) - 1) * ssc->mod_depth * ndiv, + 5 * 10000 * modeper); + sscgr |= STM32F4_RCC_SSCGR_SSCGEN | + FIELD_PREP(STM32F4_RCC_SSCGR_INCSTEP_MASK, incstep) | + FIELD_PREP(STM32F4_RCC_SSCGR_MODPER_MASK, modeper); + + if (ssc->mod_type) + sscgr |= STM32F4_RCC_SSCGR_SPREADSEL; + + pr_debug("%s: pll: %s: modeper: %d, incstep: %d, sscgr: 0x%08x\n", + __func__, clk_hw_get_name(hw), modeper, incstep, sscgr); + writel(sscgr, base + STM32F4_RCC_SSCGR); +} + static int stm32f4_pll_set_rate(struct clk_hw *hw, unsigned long rate, unsigned long parent_rate) { @@ -683,6 +732,9 @@ static int stm32f4_pll_set_rate(struct clk_hw *hw, unsigned long rate, writel(val, base + pll->offset); + if (pll->ssc_enable) + stm32f4_pll_set_ssc(hw, parent_rate, n); + if (pll_state) stm32f4_pll_enable(hw); @@ -788,6 +840,87 @@ static struct clk_hw *clk_register_pll_div(const char *name, return hw; } +static int stm32f4_pll_init_ssc(struct clk_hw *hw, struct stm32f4_pll_ssc *conf) +{ + struct clk_gate *gate = to_clk_gate(hw); + struct stm32f4_pll *pll = to_stm32f4_pll(gate); + struct clk_hw *parent; + unsigned long parent_rate; + int pll_state; + unsigned long n, val; + + parent = clk_hw_get_parent(hw); + if (!parent) { + pr_err("%s: failed to get clock parent\n", __func__); + return -ENODEV; + } + + parent_rate = clk_hw_get_rate(parent); + + pll->ssc_enable = true; + memcpy(&pll->ssc_conf, conf, sizeof(pll->ssc_conf)); + + pll_state = stm32f4_pll_is_enabled(hw); + + if (pll_state) + stm32f4_pll_disable(hw); + + val = readl(base + pll->offset); + n = FIELD_GET(STM32F4_RCC_PLLCFGR_N_MASK, val); + + pr_debug("%s: pll: %s, parent: %s, parent-rate: %lu, n: %lu\n", + __func__, clk_hw_get_name(hw), clk_hw_get_name(parent), + parent_rate, n); + + stm32f4_pll_set_ssc(hw, parent_rate, n); + + if (pll_state) + stm32f4_pll_enable(hw); + + return 0; +} + +static int stm32f4_pll_ssc_parse_dt(struct device_node *np, + struct stm32f4_pll_ssc *conf) +{ + int ret; + const char *s; + + if (!conf) + return -EINVAL; + + ret = of_property_read_u32(np, "st,ssc-modfreq-hz", &conf->mod_freq); + if (ret) + return ret; + + ret = of_property_read_u32(np, "st,ssc-moddepth-permyriad", + &conf->mod_depth); + if (ret) { + pr_err("%pOF: missing st,ssc-moddepth-permyriad\n", np); + return ret; + } + + ret = of_property_read_string(np, "st,ssc-modmethod", &s); + if (ret) { + pr_err("%pOF: missing st,ssc-modmethod\n", np); + return ret; + } + + if (!strcmp(s, "down-spread")) { + conf->mod_type = STM32F4_PLL_SSC_DOWN_SPREAD; + } else if (!strcmp(s, "center-spread")) { + conf->mod_type = STM32F4_PLL_SSC_CENTER_SPREAD; + } else { + pr_err("%pOF: wrong value (%s) for fsl,ssc-modmethod\n", np, s); + return -EINVAL; + } + + pr_debug("%pOF: SSCG settings: mod_freq: %d, mod_depth: %d mod_method: %s [%d]\n", + np, conf->mod_freq, conf->mod_depth, s, conf->mod_type); + + return 0; +} + static struct clk_hw *stm32f4_rcc_register_pll(const char *pllsrc, const struct stm32f4_pll_data *data, spinlock_t *lock) { @@ -1695,7 +1828,8 @@ static void __init stm32f4_rcc_init(struct device_node *np) const struct of_device_id *match; const struct stm32f4_clk_data *data; unsigned long pllm; - struct clk_hw *pll_src_hw; + struct clk_hw *pll_src_hw, *pll_vco_hw; + struct stm32f4_pll_ssc ssc_conf; base = of_iomap(np, 0); if (!base) { @@ -1754,8 +1888,8 @@ static void __init stm32f4_rcc_init(struct device_node *np) clk_hw_register_fixed_factor(NULL, "vco_in", pll_src, 0, 1, pllm); - stm32f4_rcc_register_pll("vco_in", &data->pll_data[0], - &stm32f4_clk_lock); + pll_vco_hw = stm32f4_rcc_register_pll("vco_in", &data->pll_data[0], + &stm32f4_clk_lock); clks[PLL_VCO_I2S] = stm32f4_rcc_register_pll("vco_in", &data->pll_data[1], &stm32f4_clk_lock); @@ -1900,6 +2034,9 @@ static void __init stm32f4_rcc_init(struct device_node *np) of_clk_add_hw_provider(np, stm32f4_rcc_lookup_clk, NULL); + if (!stm32f4_pll_ssc_parse_dt(np, &ssc_conf)) + stm32f4_pll_init_ssc(pll_vco_hw, &ssc_conf); + return; fail: kfree(clks);