From patchwork Tue Jan 14 18:19:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3803 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 90AEF3F332 for ; Tue, 14 Jan 2025 19:20:30 +0100 (CET) Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-3862c67763dsf2251797f8f.3 for ; Tue, 14 Jan 2025 10:20:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1736878830; cv=pass; d=google.com; s=arc-20240605; b=dBWjHRXsQC+BXMMKq2SWTgkgO6rvdkWOHjmyO7Exc+NdttGXP5/4l2/GZZ+Ytr2SX0 GRTj+B0Ff8GXg6dt9KP8o2g2fcCmUIX6/a4f+7XVBGEgDgRlHBu4mU4WVKPJCkK2r5sQ 5wQKBD3jH8y1mTZkOwprGmuLOsm59Z6p/DebpFcudf/o3nS23fUmoprlQGm4WhzQl6+m 66UhwLLpO2CvNbFc0m0SSlv8/GCzaXLuZMteT4MSgdA0fiefv2pEL05SX6AmH6DqjzV2 Bct/bpdbYGiOgEGqVDsPBcmReybRsayMiNmu+IveevcuAGBwOorDPgtHEz4BnyopdrSb 6i+g== 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=dRY2amOVT/Abp++CEmAwx7tS6AULHT2yF2ICdnyjb5c=; fh=tzp0Cbw96RQn4VKNK0+rhyLhZ9GDZOflcaD9Dbm+/yo=; b=XZT2Zq1HgLWkWbRfIQeU4m/9WmiuPwXsOYG4zJEveXcGRgB6mQLFLFZWSOdIcWE2Fn GbUr/XBeFv+lZ2uvYHfgMBLDAHVuHs0CF/jqW8QXGlpyLljUlA2GsXnbmYh6FV49Wuc2 sfdAXW2E3LsJ8ItBBnsDxdrlACRN0z8O6tHXoxOPfgmd6hn2JdCzKgDhfN7Lz+lyhg6F DWVkJvXXYr0F2qVw1J2YM217m9ko+1qyPqLF6XPP6X4N0KKn1xxrbmiB1mNT/zkoZt24 zSfHMPPVwxiLNyPsf1OqJcmq0WBfHX0xTfHXlXXDHZh3U3vhD+adYIkuZU0qWsP+iiaX yToQ==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="F/14V6Ah"; 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=1736878830; x=1737483630; 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=dRY2amOVT/Abp++CEmAwx7tS6AULHT2yF2ICdnyjb5c=; b=PQV9tcTMjtD3lwBsQoBh6Y1YLWfT9B3BO9b1ymybbTgv3Rf63/yRY3zN0tP5zBkWkL pJ/V0m+a0Lr0EhFGmGaeEawdocrtfTQEZbKmbPTZc0cKdx3QkFP2ZIkPJVNcckeoyZV+ yn/wkTQQxSnyvXbRQOx3vgD0Sd4l6BxTqheOs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736878830; x=1737483630; 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=dRY2amOVT/Abp++CEmAwx7tS6AULHT2yF2ICdnyjb5c=; b=vQCdxNPZ2H8r5CefwfSkv00sDpncUWtA1gOeOI9jBrkgnn8ZwLBRkWhZTSSHk/q84r orCSmxQzrP90FK7HDZM85x9te5kMIojNpKWKveTwXeC5wVBh3znySUWYPmNTpvW3cnGr rZ7XQve7eStKYG98OQ/5oXzvG7Smx6/uVBCMEnVcY4VdbVsBqvAT7TrJayfX2izOBZ02 gey83NZbAI0caAWBxPiDN/MrWVzvbV1GzgrxFOS+lCOcAr1RFmsYyCspQt040oiq0Mtb oAZu+e/xTq2fkz1Npw+at20UIuJXewvnmhBBus78ghK7hjx2oE+cEPn9IaddOl/338ll EgIQ== X-Forwarded-Encrypted: i=2; AJvYcCXGDcU3bKCxirOBu5ry5MhvoaJhV09suQgOJjyxmmhAhojOZsTD01QR8/uCPboyuY1Cec63ufzW6ss4FDto@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0YxjYXRcVqchvVVZRbn1+cyo0d4TJ6eK1LMWOUA4V4POUD7yHNYy uToGigRXzseCKeSNgF03iMUmn57RtPJXQxLC3Q5gRGifL8DRXMyxSQWZp+PV1pkFmQ== X-Google-Smtp-Source: AGHT+IHrVBWSn6AHNGGs/Ti+xZP1zY41q9CYAbEGczS15IFGcWN1h/gZYohG1rSzo5y6GZfL8AifAA== X-Received: by 2002:a05:6000:4615:b0:385:e013:39ef with SMTP id ffacd0b85a97d-38a872f6993mr21068962f8f.6.1736878830062; Tue, 14 Jan 2025 10:20:30 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:adf:8b12:0:b0:385:ee3e:ab95 with SMTP id ffacd0b85a97d-38a8af15669ls142952f8f.0.-pod-prod-08-eu; Tue, 14 Jan 2025 10:20:28 -0800 (PST) X-Received: by 2002:a05:6000:1446:b0:385:fc97:9c76 with SMTP id ffacd0b85a97d-38a872f7fd9mr23132008f8f.3.1736878828207; Tue, 14 Jan 2025 10:20:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1736878828; cv=none; d=google.com; s=arc-20240605; b=kuJFgdSbWFr8BuMupQglzgsWPHU2e7vF5RN2FC0V8ln2sgF/bJhh9a1Y/zr82Dwn96 iZpsP0j0Goc0/6Y4SkIUjcVdEk/K7aGW/TTcyBhOxjXvlwiTQeEH5WNTEnMTl7tkMOlM bB9WcZaJWWjIcsz/OQeJ/1KHXRp1Mz4KCEhIzLGIL8qHF9Slazaxymo7S+Gow4Uy1qrs 2Vc1goc1BjsOfQ2wQpLveW+S4ooBuyYVNuetlJ7BafxTNeZkQWF3KFP/vxbSYQIwilJU 65HXyPP65XXKaRCvWPmsx/wHEN30rU+UrUV+8jqPwez6JuuaXPnb0fI3xeASY5rQIl7f TGWw== 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=PIuIJty2uqhsaw1AaN2g8ZruUYEFqWvfVdT0janz1p8=; fh=R4QVkUy9N9G52dU21yOoSm0E7xk8rYofFC9cRclwBHs=; b=lJK27px0g6NmS0c30EAdRZFSI+MMAhMEic+Eht/GKSjkRAzc5WGvjRve6p0PCmTk0c uSZxBkla/7Xsea7pydybrXHaoejwU1iIPkjppmIP8vKW0gr9vgoiyLuM8MCcrluQ/bDQ YAiIBvNAduSc2RwipZnwHMsJzdkIyjEGrxTHmNRpZvBW4T0xvmksymgkzyEP0+aMWem6 hTabPby+k3lrmi7QR59axzao1t7wLT9jdNa0pgxQKu3BaMQfvuckEVPSEalj5hYUWohK Fiw/PdOpXBtPOjD63B+oX4O5yjraLyIrXjLv7xhdhMtP9LtiGwOP09p+f7RuiEj5kd1m USlQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="F/14V6Ah"; 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 5b1f17b1804b1-436e997f8d8sor37215545e9.1.2025.01.14.10.20.28 for (Google Transport Security); Tue, 14 Jan 2025 10:20:28 -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: ASbGncsKMCTGVhTe0OL4h+7Si5wG6IE+ej3R4u0HxBU1JA1fcrw3fcfMlD21ku20kGu ooOla1zwbE9HModK+Qmqzqe2eHYcCuoUU498vNB6/SxZenomTIdf4e+9lDAIcBPe0Y6b0mzxTq3 o9JUNm5ZlprItGoLd2oOqHmuXr7u2sqeKLCInNxsf927oFT8lzmk7ze4W4OPAl/XfO64tCWrRqW nd/VinltanAneW7IOdM6m/aVYvqwJh74YDuKhiI/UGuOuq5GWu2hOSZRZ3xmm4tzfu+ZoctFHls cmw8r/eCcgfne9DVmsU2KQ== X-Received: by 2002:a05:6000:156c:b0:382:5aae:87c7 with SMTP id ffacd0b85a97d-38a87312d17mr24074626f8f.31.1736878827238; Tue, 14 Jan 2025 10:20:27 -0800 (PST) Received: from dario-ThinkPad-T14s-Gen-2i.. ([2.196.42.147]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38be66b01c7sm278970f8f.22.2025.01.14.10.20.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 10:20:26 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Krzysztof Kozlowski , 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 v4 1/4] dt-bindings: clock: convert stm32 rcc bindings to json-schema Date: Tue, 14 Jan 2025 19:19:46 +0100 Message-ID: <20250114182021.670435-2-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250114182021.670435-1-dario.binacchi@amarulasolutions.com> References: <20250114182021.670435-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="F/14V6Ah"; 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 v4: - Put st,stm32f746-rcc and st,stm32h743-rcc under the enum of first group. Changes in v3: - Add 'Reviewed-by' tag of 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 | 108 ++++++++++++++ .../bindings/reset/st,stm32-rcc.txt | 2 +- include/dt-bindings/clock/stm32fx-clock.h | 2 +- 4 files changed, 110 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..8f2494a0b28e --- /dev/null +++ b/Documentation/devicetree/bindings/clock/st,stm32-rcc.yaml @@ -0,0 +1,108 @@ +# 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: + - enum: + - st,stm32f42xx-rcc + - st,stm32f746-rcc + - st,stm32h743-rcc + - const: st,stm32-rcc + - items: + - enum: + - st,stm32f469-rcc + - const: st,stm32f42xx-rcc + - const: st,stm32-rcc + - items: + - enum: + - st,stm32f769-rcc + - const: st,stm32f746-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 Tue Jan 14 18:19:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3804 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id C57C53F332 for ; Tue, 14 Jan 2025 19:20:31 +0100 (CET) Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-43582d49dacsf39637545e9.2 for ; Tue, 14 Jan 2025 10:20:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1736878831; cv=pass; d=google.com; s=arc-20240605; b=dgVWYzj1qOA9HNgtUrBfM1nPGznPyXqZ7aglYqqQe+cuuthAN51sZvee2xNAkL1A2c eCG30N0Fm6/84oalYerEueaYvtBKxIiU+IUoRt2REbrpICKTQMzlVLLU9hmEX+xgovdx wX0rqvxANdbXR9cucfFb5Ly2bBjaRQ+ngLCMtqYZa3q3OrBastA+UOcRgW4Q6e+mpD47 oCs8eIK7wVdNgHgYIKTu9rjLg+Qc0MqcFmautM8TjEOHekx539QctStFn23WdewUjddW CCWt4gjW3FzCWQ0k8YWpQjDZZZROm1pD0cFbGu8Go/ZLuouce/fVI1BLYZ6sr32vOz3k d2Yg== 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=okHm8FpseOZxCls+lTXwFSJhc7Zg5l2DPW17MGFLHXo=; fh=N+vpRtRxis16GJ89s3/34XbieAym33gyZ9O61OpZnBA=; b=Bawdi0kobKXKHpbgMM934qwFhDz0MAO8MVpZB3D8PrIkvQxUmmbPr5YR59I2/brp+W nfWthil7Zn5LW/x6Jw0rxoCcrelM4UmEtNmM7zKykWBNSXhrEYSGdv6HqX0bk9KyMknA EqpCfJ7CokO5qbQ9b73SOWjr58odoDOrpdXIH6O3ycgc/p6lyYMh7ADR5WLokW/QIBix nfRB4KxffL+kzie3GkAyqwPoARvxJGJPgbXO+dcc1oRzfRg8FFzI3R25du9uTeZAtBth bpCALFE03XkvC+x29R9uq2T8ykrJLg3YCj7Sx3A1JAAHef31gXPUPfvS2ONrPc+4mZqU 5IcA==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=mUfxtxPK; 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=1736878831; x=1737483631; 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=okHm8FpseOZxCls+lTXwFSJhc7Zg5l2DPW17MGFLHXo=; b=guC2fIdaaejDjyQaWYvF3TSBQ+ADxRYVPZBbb7xGp0ybtUvzoTrrKIf3GcL3bRiz1R 5R5bMOisO+9zV+BS58LkZcOI0lwa3Wswk6GVO3qhFZ4WTDUt+Gt3YYpJE8Oe25dxOCGW ODOXZB1GYhgWI2mlfcrk7bKrv+mxVCJeN+3D8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736878831; x=1737483631; 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=okHm8FpseOZxCls+lTXwFSJhc7Zg5l2DPW17MGFLHXo=; b=hzepsltiyTezx3c6YuZG5cnqHF3av/HB9vDYsgToFBLjBJwbXZHcM6v8FgqjLnZ+ED 7A1TNV1fcJodXAPKRB3kEVPRKS2SejL/KZ/bWZbd5fH5AXvlmNqcvcV0ct+9lh1EKNAR y5/2pOTqlaHM1Dgz0iCLVoKEh413BtOl+WaixMEWxEKIrKxBGqWA0uQALBxffhjcWxIS Rd/DuE8i9vLFJy5rtxDc9s9n0uKYBKmP+RfFV5qWVZEG/fdvtkX4wm52I7+KPBCCIG7s fQUT3ZN3RNdnCcfs9cL6S9H0jiNzfmQ82F4tBcpeT42yVs9Kop5t12T9zLbyxOEiBNO3 Xc5Q== X-Forwarded-Encrypted: i=2; AJvYcCVv0luO6QHis/3IQu91FaAfZLJ0QqABtfQ0bF29yMF9IAhGPecieVG/SQq20W5EpI6FS5+dkIkL3JCqc4s9@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0Yw25SAIxxCSHuCztrOIYfQyEZUf0so/HCOEa5khDE0Tw4nCRRsd SKYVn0571PE2kZXC+Nl+6J/x+dx+Z+ETHe0fhB4qlxxdFiJQZ1dpyLRO4hAFLF+Yeg== X-Google-Smtp-Source: AGHT+IE2+b/7aJ9UL2dw5hBIc0uyNlqI7bRy2L2KwUqMpQR9/n+9D9/IDQ+CrVsbwWSdPxKTie3aRQ== X-Received: by 2002:a05:600c:4e0b:b0:434:a7e3:db5c with SMTP id 5b1f17b1804b1-436e26aeeeemr265405905e9.11.1736878831229; Tue, 14 Jan 2025 10:20:31 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:600c:6c49:b0:436:8a89:bfe6 with SMTP id 5b1f17b1804b1-436e8843d8els30389965e9.1.-pod-prod-09-eu; Tue, 14 Jan 2025 10:20:29 -0800 (PST) X-Received: by 2002:a05:600c:1f86:b0:434:fd15:3adc with SMTP id 5b1f17b1804b1-436e2707303mr206600825e9.25.1736878829394; Tue, 14 Jan 2025 10:20:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1736878829; cv=none; d=google.com; s=arc-20240605; b=WUFHb/V2uxr3nrlBmG4mj6gYrmu+XvmvZfYLcL2tDuKB5Dswd25XvQpgX1+2nmE81Z CmsS3bMs9Zrw+aeFBj5lJnf8Gy/mwJdSkOa8TFuYMmleKHuVjBjbLsl4jNgo0ZF5PUjN O1xoIgCfPaMTLpafuD3GrzLAvBWOInSMDZli5P5grZpsBKIAMrSr/+4LsV93PZNZ8ggc tZHxwAT2nxAX/v4Te0iufr7ibRpjIMv4Xa5Kb9vUwIdjTA9mbyPntIE8xftBGkmJJXsd EHHcMdjiguuS8Q8st2lkR5NV6R6rBjcJf0oamw6iuwdAflvNpBjSVNcl/TfArxs63VtE 0G6A== 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=zpzT+aUzJ1Q97S7iT1IDWutNkzHMdDAlflIDJCmxtro=; fh=aLWgEPM+DVTqoB30lVkyyzFDp2H0k8cJSxUm9Og2ZbE=; b=dZ8mKJh29NsIg+PJIJbglpmWosJTQg9a0n9ccUFk9rGllWJQb+2uqt/qCqwG2iA8/4 sBSqL86G9BIcxqcIDI7i0i/gTS6qV+cZP586lqR6EWBih0+DmQ2rRJsI1xWGssdhjiv8 OcypciZBM9GYqju0Bg/wXwZux1OJLWcItyAVFEaDvPB/ojHJkOyyCnzta3yzcPun9F9n PzBkJYA1VTEfwC2eiwLwnswq3eCZhymzo8D2vrAAHz5cZUL3s7LWeOY780SW3LyK2nEV SWJdgEndwYo/eqIoybPM+ynMKHG/go0Q50XiggQm9nzOkORiLixTQjxTf9rpmjxEtlh0 HwYQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=mUfxtxPK; 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 5b1f17b1804b1-436eeffa831sor37671385e9.9.2025.01.14.10.20.29 for (Google Transport Security); Tue, 14 Jan 2025 10:20:29 -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: ASbGnctc2BFgNt0t56TUMRFW69LnJQKmI68ELYtAs9aujM/FcIqIuT1p3NOLC9EOuhP szO6W0tH/3EtBBm8/+8VpDEkCMq4CwnJ8ZZXnaUjKqIE4+/eACPJ61lutXO83DjJImPfznP8uzO g/HH2uxcrVTWe4OGJ+dE4ynrxod0XOs9tdJp7htotFSy2m8BhpMa4gv0z7v/Ra1G72LqTa7Y2kP bEvAE4MoSWVCmJTc0Xaq0RycSdpWrXj5PeErgRkn9DG23/c0lOtDamiihGIi6Tmes0ITVlnHOCS tEZJqXsotvQMiCO116fZJg== X-Received: by 2002:a5d:6da2:0:b0:385:fc70:7f6 with SMTP id ffacd0b85a97d-38a872fadf3mr22273830f8f.7.1736878828905; Tue, 14 Jan 2025 10:20:28 -0800 (PST) Received: from dario-ThinkPad-T14s-Gen-2i.. ([2.196.42.147]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38be66b01c7sm278970f8f.22.2025.01.14.10.20.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 10:20:28 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Krzysztof Kozlowski , 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 v4 2/4] dt-bindings: clock: st,stm32-rcc: support spread spectrum clocking Date: Tue, 14 Jan 2025 19:19:47 +0100 Message-ID: <20250114182021.670435-3-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250114182021.670435-1-dario.binacchi@amarulasolutions.com> References: <20250114182021.670435-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=mUfxtxPK; 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 --- (no changes since v3) Changes in v3: - Add 'Reviewed-by' tag of 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 8f2494a0b28e..f83a6120d65a 100644 --- a/Documentation/devicetree/bindings/clock/st,stm32-rcc.yaml +++ b/Documentation/devicetree/bindings/clock/st,stm32-rcc.yaml @@ -53,6 +53,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 @@ -78,6 +98,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': @@ -95,6 +119,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 Tue Jan 14 18:19:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3805 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 335A13F332 for ; Tue, 14 Jan 2025 19:20:33 +0100 (CET) Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4362f893bfasf31703695e9.1 for ; Tue, 14 Jan 2025 10:20:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1736878833; cv=pass; d=google.com; s=arc-20240605; b=GJDeH/xz6pi6AeLbY4e5Xi9l27x2eRinX0/UzdrLOLKvKxHAqpkRzeilx9+XV8Il9c Haw0FfLiOZKXwsdI5qVYvRlZJLGbLoIW/OcTF5PK3HoZy6dDDhb3GXIDgTP1MB65+IBd w3Vy0ueHWusy0ar9mZD0udRl2xBWrioNpWbFQarOiu8KU5RLpOPfQMcWqMyjUjcOdpUx c5LpRG3+dkMLQ2tO/JmUfdcRFTsi/GVKa2mpugirQjkuhSAX16iUqpyC13QZQmP0bZ7Z HlNte5quLLjCFk/iLDITLaQv7FJpvmtK7CdbCoeLqbOJCv6d+dN5W0/sexWruRga/FD+ XLkw== 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=usAKvCm24jXo7bK2/FrHvgtk9ddavMwsGtAilWtbAEI=; b=Ii0VK+RxeX5ybC+01BqdKVGPi2Vj8XvRhhZqfBdtKtsXLgXmNqAHaFQAwQTBZS71AU Gp7H+NA14gmE4NnT2utMRrfDUv4P/98KP3XHuoXg956cRA4y9G51AiwNzWerQtDTUH49 io4MVvRLAs16Rtt9Fw0gM14yTeA7EBrtZns/HLvwhbpeITrFGf7CnOX+IWbqDiIZgmjC 1JXt4dIq1+MzxOsWQ3ujqf/fDJD9/mAGQBW+l3S87FSFOK0e4CMHmB1Mqa6bxQ/lMwtI bSUY1+FdoO+yVEVkH04/zKKU+X8U3ozHHbHywX4149ZkbloFJrBFmf7OPnqsKMChNsTu 3IYw==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=TLHgoYHl; 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=1736878833; x=1737483633; 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=C1+WbbuEkcl3OV0HK6Ej6Tbj5K/68WBpDheA6MRBlaCjppYYDHH+3GoJksmd0K4P7Q CB5R5bNA7JLm9x5N2SRTf+PicbajVmcOzkJd32kRY0IOgLvwCJKbrxA2SxtLol3NMa2M VmLfJcTmAn28Ze0g7PY7hKgeIbOHgcwx3X4fY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736878833; x=1737483633; 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=jFqNnzj0nW5d/f8fygu9IQwftS+Xdn58Sy3oYd093ixLAylDKvm5yQnyzce35RSvc9 P8MnLzeGrsgS3JOOaArTgsRDcrlUllU7RsU4y6qSwshe42L1Tqctjf9g1db3fBoe6hvP FfWXmdGMIFrWj7SOxgbzuzXQALubKfKzxceBxYMSyM3JSlWckfGQgimJRSA2Qo1TYD9Y a6uBVQEeeeQfoMD/RdmAEgapD+UUoejyTKluFWEQ78tslhCj/j1w7fo4s5+kQT5RBLu6 E930I15DSmibOV3EtPsFEuNdDg/KCHotRN4j6PCN2OIfTO9RaeAqLtZGPRHO+tyCOi/c 0SVw== X-Forwarded-Encrypted: i=2; AJvYcCVIaOtW3Owqkv7XMGVsoRsg89OdISH8iuSa/YPy5JKtiLwK8S2QdfZihxktt7wrmerrwwiKw/zEzMNDtL0M@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0YwDMVo+6jHua3g6whoA2NjU1FG0cGBQnCIbVjz0blTbGdpqchHs 9af4trZAal0rKR70mpOfa7/YHwtM5fE/dc/jkImdwjzokikP3CdHVpqDROBo4ElT4g== X-Google-Smtp-Source: AGHT+IEupehV7X8PZYsXPT71GkEd4gQxs50W6YLAwr+1oBMcF6Q5YjZh9vs8WFLBVmr7e1Fjv914FQ== X-Received: by 2002:a05:600c:198c:b0:435:306:e5dd with SMTP id 5b1f17b1804b1-436e26f47e0mr210636225e9.22.1736878832770; Tue, 14 Jan 2025 10:20:32 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:600c:4e08:b0:436:5d0c:e9a4 with SMTP id 5b1f17b1804b1-436e87e0c5cls2314495e9.0.-pod-prod-08-eu; Tue, 14 Jan 2025 10:20:31 -0800 (PST) X-Received: by 2002:a05:600c:3516:b0:436:5165:f206 with SMTP id 5b1f17b1804b1-436e27075eemr244363305e9.31.1736878830860; Tue, 14 Jan 2025 10:20:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1736878830; cv=none; d=google.com; s=arc-20240605; b=X+4Y6t1pps4kIsyU3SLYOWXfuYiTc+e5AjdI+U8g1nUZut5HcGyg/zLX4mHKr5oMmL Ar4tnzvPXS1C5XxuQRwnB63XrqZL5bgrt8EFrUgpVddBY2w2dMP8FHYXpwQzx9yMSttN qDtgc3obF/p3cJYmAOsv7kHB01vkAIsBG5B6rT/QrjuR2/7MGTW7h/Ckgr492N+F/YVW uNlpK/9jMp0tIh7xPCdFKkyCnMvM/JRePytz9+QNipm/kXa35hY/LUIcJbznSbt5D6Jz Ohh1NMrRMRE8tKwf1czE0FiYvhb2bcZBSiU4NFmkAEwtlR9PDh1fOVYP2QxJ8wqLxT+A B5bw== 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=aD7Wxh+4P6bUEpohodxnQ6BqOoqYPI5eWTeXZXO0mb0fB0i0GX71xrRjM0szvoD6XI pmlnXSkwyVMhAmBFxYJ9YvCklBSs2x07wKgLV7A3Tctp1DLO43pJ19YtjVWtYFdbVeU8 BlwP3EVHSbHu5rQdSU5UUNe9YmUrIdY8hraE0GjytRcqETnj+RdpnOwFoLCdBmhbLSC/ Gw1Cg4M3pkAVWDwl5Ej1X2/AVxnfgiy+8rfxRxOUBvUwzphaevj2i40rLrEWLUKFmIjI 3v4R3dg7qTviyb4djQEy2hpmn5Gm9zdpL/r3fKEXDag5KS2JeKVK/xJQJC7RN9D76J2M hHWA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=TLHgoYHl; 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 5b1f17b1804b1-436e9997694sor37211055e9.6.2025.01.14.10.20.30 for (Google Transport Security); Tue, 14 Jan 2025 10:20:30 -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: ASbGncvDlXSbmgLq7DRD7j90vLTaLksE/Yf95lE9YHhVjOxXkjwP7oBIu6pEwzowdG8 vq5KAU89wXHZuhJKLD9GtocRVErnHJp34ZpLaRUmAX3ugdOW9Su8x8Lu6inDyaM3iZDuQ/LBxKb pMrzDfzmndk/kjZtAKYV71xnXkdO3lzZi7YAtkAgF6qRFDcNoSd5ZUhjReLNcgTXhi2LepiPcz2 5g3QVl+k4M2oOBiZmOvvo+Ra3N0q28t8POZKRXyKwE0ij3Sagaq1zmnrrayr/6FjHAYTyBfFt9D ui6YZlXruO5s82VblFwPSQ== X-Received: by 2002:a05:600c:4f0d:b0:434:ffe3:bc7d with SMTP id 5b1f17b1804b1-436e26ba521mr286846075e9.16.1736878830386; Tue, 14 Jan 2025 10:20:30 -0800 (PST) Received: from dario-ThinkPad-T14s-Gen-2i.. ([2.196.42.147]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38be66b01c7sm278970f8f.22.2025.01.14.10.20.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 10:20:30 -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 v4 3/4] clk: stm32f4: use FIELD helpers to access the PLLCFGR fields Date: Tue, 14 Jan 2025 19:19:48 +0100 Message-ID: <20250114182021.670435-4-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250114182021.670435-1-dario.binacchi@amarulasolutions.com> References: <20250114182021.670435-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=TLHgoYHl; 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 Tue Jan 14 18:19:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3806 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 828073F332 for ; Tue, 14 Jan 2025 19:20:34 +0100 (CET) Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-386333ea577sf2183949f8f.1 for ; Tue, 14 Jan 2025 10:20:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1736878834; cv=pass; d=google.com; s=arc-20240605; b=SNdTgX6/NyV2TqRb74lxj/48RXe/BvB0Zz/fz9Jyu5ORT7c5ccwWjs9dGIrFFQsUG/ mkVhXJBqq5LH8f3h6udu+B/dkMj8GsoGNgK4l/sjjjvokvNMWBQUJAu+vC74qlIooOVW yobQg6TDPxmrym6KAgLd6xTInuUyphR0hOLYUUjUjz+Ni53dCCFaQr+AcW633y+r42uC tAMYE17W3shJgdLIHP/ac10ec7NbjimnJslDBECkDITTdRftlLYnR24AcNXQHfanebfQ iBe8ysW2mHma32BTlEqIAmoCAYasWfd8OnQiFZcsxg3gDwjumz0AMacWEwUhB7EhJ18Z FN+w== 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=cDzlPBFHFhrSLV4n6gU3A8apmbVg6nzQNFM/aHWILO4=; fh=HjsZ7BYhPEGQ5aOG2JVhtWkJn4vEQ2TLizuPaUoHEt8=; b=H2iDSZFrsMkKcEJGb/0ROCEA8bkB0t0N0QZ1qhiV5/NyKWWXxtOk3jV66HlYyMXKa8 K3eRQJ3HLpAhdv75ED+AKBM/2n1fBDgFg81r6adUVLdnR4BT7mEvvHXPfTRqaSyF0PkL mrfW8Z0eJFV/La8Lh4jFHDlkCTWP0MbHCN0fTW0t4EFwq2mh+++h4Mf/glIRWqoU7C8V 2VVy4GhNxtoYmU3W4JPFzwEUNjc7Xpc5IVQ4tOsrRLup23RVhkHZykyyjdn0tXw9JY0Z jYOOSFJFldTP6R9LTPCmWAT0z+2Fkri4T6DYg152zKoYwQYKbLHK7euZTyDDS4O3sJ3b Qovw==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=H5AGyYg8; 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=1736878834; x=1737483634; 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=cDzlPBFHFhrSLV4n6gU3A8apmbVg6nzQNFM/aHWILO4=; b=f4FNzbORKG3TaRe6nUIiOyc+Poa8LeQKm/McjaNTr4u8I7S+8fakzOal3mVgExCxYB yGrGgnRUFVvGMklNWwjvalZ3GNPosJExsjI6AmR04SwF/aW3Pojf+Qo9JJ5ZnfTkiAMx Mh8KVowCMCcsx4xEXXkE99hyzSxUqs5USdiIc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736878834; x=1737483634; 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=cDzlPBFHFhrSLV4n6gU3A8apmbVg6nzQNFM/aHWILO4=; b=Iy5S8DRtoI2Yzamlp7DpnEW1kyhGRk7NQVtfbyrKVEv7t1uskuhvQcd73hkHtVYX2b 3Ru85fjOWLGa7qnHdKy46SSJ3GyRog8rDTqdOqE/4mbIYwuTTnOCP+LDuOtLsSaCd0+U LpHlEuO8lSmJHEvKLFp/hxgXbV5hvI6VJhiZbEMoHj9IfxV6qUWD7kP2JlWg0NIMiGQ/ WqtxY4zVN10fqAR3+KTPmH6Y8W5KoQCL+D2kCWAywiiuf/EG6z13nzw837H9tzEw4qZ8 lEOLjpAX3Mr9Q53QfBS3q5uwcp4L2CVuNzYtwzOujAPSH0be5IsALjESovVj+Jr7gP8u XVRw== X-Forwarded-Encrypted: i=2; AJvYcCXknxP8cDZ2fld717X+1wfXNdinJ07zs/mwG5cx1aZzwu7EEkY7sx7gtdzGf6Lxqf7weFzppf/JGaXPfg1k@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0Yz/UKdlAu9XXzKawZzXsI9Ug28QFX2ciE4AdbfNhlzRAjgksflg sLkDrxB5TzowhbJ8vcHRkn42/tN1SjwRSQmWLqQ2yAYEaFZGvC7dR5OC9KSbvKGQWA== X-Google-Smtp-Source: AGHT+IF0nOfuFmzFKW95Q7PcAff4Tj0JOjyn7gR0NUSZnh/gMH49V//S3DjKtPMN+5zbJMNLvsFT+g== X-Received: by 2002:a5d:5f85:0:b0:387:86cf:4e87 with SMTP id ffacd0b85a97d-38a872deb33mr23783786f8f.15.1736878834021; Tue, 14 Jan 2025 10:20:34 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a7b:c418:0:b0:42c:b037:5fba with SMTP id 5b1f17b1804b1-436e8849cbbls11036105e9.2.-pod-prod-06-eu; Tue, 14 Jan 2025 10:20:32 -0800 (PST) X-Received: by 2002:a5d:588f:0:b0:385:f062:c2df with SMTP id ffacd0b85a97d-38a872d2b3dmr857750f8f.11.1736878832229; Tue, 14 Jan 2025 10:20:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1736878832; cv=none; d=google.com; s=arc-20240605; b=NQqCoX94qWElr9zuu+R2x4zy4UfrO9AMCdNEd3LU5L8XLlHCKGmn7XgXP//heoe/qZ adxTADgoF/gfU38YLf1scoLetDVELV27lDLiJv2wlGS/WTS9l7W2rtNc3RWRtGXZ6HHf v5aVPYlC2JL2cv0GBGuSg81PVPP4qR8PY7ojbOkBBZB8sq/mDdRf+JNA3qGX+uFWxUq1 myNVapV6X069qvEiwV0jbL1LpmPNJT4kLPCUkQPVtxzUlKheD/1biUnr4DrS6q5EqRzX 1KaB2Eea5camPZr0BZM3DeIaxDy8DGw4ft/44nm07K2pRgyqx3Tobb9yax1qabghWcOn tb8g== 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=zkVJ9sQJb2vv3dExk46APkrSl3qRZZR081phjk5hrNg=; fh=LKhgYKqW/DH7bOgdnVELRgL+gR1eISg3bEXUN1rI9pA=; b=k/KXjJ89IB7MtkcyV3FsEBwbeMiI7lrF1ig8+7srnqYCMOkR30aelf8d8/boakewlo dRyCmJFQiRFQWGv4e8yjGL4L7ZqaLAWv5SRwnCnbH2CvwR6MXsVl2NnzOkOr5adVQ6r2 m7rUlgMj4ScKWUrrk9DxFjVziU+HsDLKS1dSd3fnxkszlFF26OiPCcp/wQYUkP5E7CTk uqfMFCTF4s/njxmnNHI5eaWCiFfRH/XEAJDHGRw8Hxfbj6niAMKASylEA9d2cwnUUvNl wHODbLb8S/s5rPVGHGCe72Cvzvl2raDf21kVlGQtQ1upIbs5mZJWE+NHxSKYzTj7FKx3 Ra4g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=H5AGyYg8; 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 ffacd0b85a97d-38a8e4d19e2sor4153921f8f.8.2025.01.14.10.20.32 for (Google Transport Security); Tue, 14 Jan 2025 10:20:32 -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: ASbGnct9E1vXKIHLk07OMmkYDiKD5nUpaMj+f7x9rEUfgaoP/7v/GYAC7bp9m8rArWx eeInmTFAQGtD5xvTGsfL0UussHm2Loaf5pfDI8aje2yPJp/M126S0QIJWPC20epa9l2JFJ3FiJD j+2q+sZFOZiXDU92E9kFdVCOZxLvxgY1i8kTiGday6VCKS8zA8HlchhAzl1wolPFT//3EwlaanA 9Pnx2Ra6i/9c4DHxN3Un+0u8w9xZF5J6FPkEBwM9B2Ri1l8i0e3BeK+tge2QsTaVl2OmyPpJq5d aVUElOrFm3lCBr/As3DS7g== X-Received: by 2002:a5d:6c68:0:b0:385:fd07:85f8 with SMTP id ffacd0b85a97d-38a872ebfbdmr20001278f8f.29.1736878831746; Tue, 14 Jan 2025 10:20:31 -0800 (PST) Received: from dario-ThinkPad-T14s-Gen-2i.. ([2.196.42.147]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38be66b01c7sm278970f8f.22.2025.01.14.10.20.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 10:20:31 -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 v4 4/4] clk: stm32f4: support spread spectrum clock generation Date: Tue, 14 Jan 2025 19:19:49 +0100 Message-ID: <20250114182021.670435-5-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250114182021.670435-1-dario.binacchi@amarulasolutions.com> References: <20250114182021.670435-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=H5AGyYg8; 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 v4: - Improve the compatible property in patch 1/4 "dt-bindings: clock: convert stm32 rcc bindings to json-schema" Changes in v3: - Changes to patch 4/4 "clk: stm32f4: support spread spectrum clock generation" according to Stephen Boyd's suggestions. - Drop pr_debug() from stm32f4_pll_set_ssc() - Add __init to stm32f4_pll_init_ssc() and stm32f4_pll_ssc_parse_dt(). - Add const to conf parameter of stm32f4_pll_init_ssc(). - Use fwnode_property_match_property_string() to parse the st,ssc-modmethod dts property. 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..f476883bc93b 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 @@ -367,6 +374,16 @@ static const struct stm32f4_gate_data stm32f769_gates[] __initconst = { { STM32F4_RCC_APB2ENR, 30, "mdio", "apb2_div" }, }; +enum stm32f4_pll_ssc_mod_type { + STM32F4_PLL_SSC_CENTER_SPREAD, + STM32F4_PLL_SSC_DOWN_SPREAD, +}; + +static const char * const stm32f4_ssc_mod_methods[] __initconst = { + [STM32F4_PLL_SSC_DOWN_SPREAD] = "down-spread", + [STM32F4_PLL_SSC_CENTER_SPREAD] = "center-spread", +}; + /* * This bitmask tells us which bit offsets (0..192) on STM32F4[23]xxx * have gate bits associated with them. Its combined hweight is 71. @@ -512,6 +529,12 @@ static const struct clk_div_table pll_divr_table[] = { { 2, 2 }, { 3, 3 }, { 4, 4 }, { 5, 5 }, { 6, 6 }, { 7, 7 }, { 0 } }; +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 +542,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 +566,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 +687,32 @@ 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; + + 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 +735,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 +843,84 @@ static struct clk_hw *clk_register_pll_div(const char *name, return hw; } +static int __init stm32f4_pll_init_ssc(struct clk_hw *hw, + const 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 __init 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 = fwnode_property_match_property_string(of_fwnode_handle(np), + "st,ssc-modmethod", + stm32f4_ssc_mod_methods, + ARRAY_SIZE(stm32f4_ssc_mod_methods)); + if (ret < 0) { + pr_err("%pOF: failed to get st,ssc-modmethod\n", np); + return ret; + } + + conf->mod_type = ret; + + 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);