From patchwork Wed Nov 4 10:16:57 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 4978 Delivered-To: michael@amarulasolutions.com Received: by 2002:a05:7301:5407:b0:36a:3487:1c26 with SMTP id aa7csp35482dyc; Wed, 4 Nov 2026 02:17:49 -0800 (PST) X-Received: by 2002:a05:600c:a4e:b0:4a7:76fa:87e9 with SMTP id 5b1f17b1804b1-4ac187a766bmr355556005e9.21.1793787469666; Wed, 04 Nov 2026 02:17:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1793787469; cv=none; d=google.com; s=arc-20260327; b=jmpNqkyzNidGdr5ZSVfShTRltyCxpRerNFOCKpTN46TxM8+fz6UI3RP140dLYXvTRg wJxla0KhZ8MqbljnHIscyhuTX67nGV+9UuBbEjAr72j1jv/0VVnWVUQwoKe4eEnDN5PQ A4adWN+kt5FtI0y6zDOz+ii7vP/m3OZuwyzFsp0S+2VmkzIbSYZvL84Wk1QfUoLFtio8 ur0GUgdSpZyCYa9pBG6JAEoMjic+X5keK8GL0MMJIcPhJXcH1ySPnk9eaA/wX63mogPr NPL/2izhYzjM1iGpRNekT90P2ZkR02wsIGwci6nURxZ5GHC67Fox1Bru2JI/YIkz8SG9 aOVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=jbuhfSlfgFZ1tnBuSoCDBMKfZMfXYTX6enIbhL3dWk8=; fh=4KgKzUt+w1/nYxpJAYO/ECudv3fO5brOvX+6sjW+qV0=; b=ZKfIL6TeeKcNk9N5WI2cKMcF8E1vmyc31mPibMmY8dzoNb2GNAfUcO7aXro0I1C9SV TY+6zNAfRP2IdXM5aIZgClRwyu3oGrQ3oXrjp0OQriY7z/cNQ30VnaOy1uUvPVW9afCY x38xudsyPQxLcMDp3mMZTBzDiAYnaIn0/iRZXoxiq+SgniRZD1cOcYuAql+r9ishDyLw rGFKUEi4i0WjhVgsZwNFeOKu1wB5vFFL5WJIFUjL8oNcu9h3gZ+yHCXcJIWWaFRtOvAa OBiPWPEUfTlEBjtlOzsEIEVelhO7rYkxiPzm3bNMwq7P0A+nuYBHWuUKYy1Hmxo3pAIf xefA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="fxm9Iz/t"; 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=neutral header.i=@amarulasolutions.com Return-Path: Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id 5b1f17b1804b1-4b437f1f20esor3734565e9.0.2026.11.04.02.17.49 for (Google Transport Security); Wed, 04 Nov 2026 02:17:49 -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; Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="fxm9Iz/t"; 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=neutral header.i=@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1793787469; x=1794392269; darn=amarulasolutions.com; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=jbuhfSlfgFZ1tnBuSoCDBMKfZMfXYTX6enIbhL3dWk8=; b=fxm9Iz/t4/W5dWVXSGiQEU3Gl3to+eOq5FUHqtNsYH+H1JeboEMqUf54+SdVzGQX3F xMDGCluka7LZRa/hYCFm0Peltatfph0JIU6JSqlw/HDAQbRdZmiJwFPJerleWEmQII5D s5dQ3Ey+TC4SepGPZrBqgJe+JAflRpzLKmkA0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793787469; x=1794392269; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=jbuhfSlfgFZ1tnBuSoCDBMKfZMfXYTX6enIbhL3dWk8=; b=CPWqv+/7TMaB2NelwnsZb42RLSLlDsT+zmfid6QG8Pvvpp6kzzBkj0Ro0ocTzJSe6+ XigP6Z5kfqR3Osu93DV761v7sUNEBj5F4OONQh8iyduOJGAUDzCh0Yr5EZRvgFx4LGB/ 7haBJgAtwHLWqconPPGvnw7MU9q1hLnPEQAHBlop/JJSZY3PtTV0z8tDO2ww324upCvY PLNAO/dBYwHd+Edq/nTSwvvWGLCFQyx5duk9s+/XTh1iPYyBETPC5wFB2b4qxDOSOLqH x5hEe0i6KIUoIBJkj76UQbzINy7NjGRZLCNuJqCV1SQGXeLYgfRuMrMYQzubQui8vqvz rHcg== X-Gm-Message-State: APuU4Z89zaH4gzs/trfMBXPeaeLYqXVUtZjaLyc1+JMFSoP1pvLZSWCZ +5OQ3RUe50QSvnle4Yl0sATU5wau2zVERumnmFkc/n/kGrdg8IxEuhZKsmo72Sg86tgJvg== X-Gm-Gg: AYBFou1u0rRNEV9HYJwn6oAbqOs/rKLH1D6m4/J+CahlQ0RzPm+EStn5Pa8mjr8yiAg d+qLxy/vaALagVpJw2OSAGWvlCCufUtK4HQDcmmzNHQL/Srq2umqAw5Kq3ExO0cVST/vxhpd62F Vnrgf7116NxN6QkZTLQFlVlS8VkuwIfN797az/B5GrRAs+4+5ES85/PZFyO0D4xLrArD4hJPRLc WO4RSFa5t01OlbmLJ2P3KnQUIcB+ON2HFLd+d76gibxYO3hfczGtBoI4vTispSvChNAYeAFu0Zg G42BbmMU7WJUVNJR0R02kTZ9sTr5u1tX4sMJwe8HyHqdTQKVYLNkDzqjNMskgNX4+Mx9kYkZ9tj zuAd1VqUtPe3tilk/+7w4eWgAEEphvlW3TH7KxsErH8CrLkXVPUwBTg3eqjOvkyNT+2RtYCulVf USOHllECc9fbgwB9OtuGIavZDrOM9Qvouyj0PtUEn0HByLo5Sfjhi2C+j/nVCOuyNlGbc/dmlnm YPAL0tMVaRVxa5csuEp6yO1KXy1El12ncHbNziCHQ5mM6YI/GKuDryzTpLz0lw8TGnwKnRLvRrH i+0zNROteR7ul8FNX2/Lvh0oROQ2K7oAywZnNmDoP/Mw+Musq/d4KM9oQgjb1h1u0ocqX8X1C3G 1wBN/Kc8yZOATpbawkokACggoyOnjn8T4Jj7mMZjj+d0gO6Xx4mFH X-Received: by 2002:a05:600c:1f93:b0:4a1:7e76:d02f with SMTP id 5b1f17b1804b1-4ac180f299emr332117065e9.14.1793787469058; Wed, 04 Nov 2026 02:17:49 -0800 (PST) Return-Path: Received: from dario-ThinkPad-P14s-Gen-5.amarulasolutions.com ([217.201.213.4]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48feeb51a9csm3035105f8f.59.2026.11.04.02.17.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2026 02:17:48 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: michael@amarulasolutions.com, linux-amarula@amarulasolutions.com, Dario Binacchi , Brian Masney , Jerome Brunet , Stephen Boyd , Tero Kristo , linux-clk@vger.kernel.org, linux-omap@vger.kernel.org Subject: [PATCH v4 3/3] clk: ti: dpll: apply the spread spectrum configuration right away Date: Wed, 4 Nov 2026 11:16:57 +0100 Message-ID: <20261104101732.4043372-4-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261104101732.4043372-1-dario.binacchi@amarulasolutions.com> References: <20261104101732.4043372-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 The spread spectrum clocking (SSC) registers are only programmed by set_rate(), which the clock core skips when the requested rate is already the current one, e.g. when the bootloader has set it up. As a result, the SSC configuration is not applied, as it was with the vendor specific properties. Apply it from set_spread_spectrum() instead, reprogramming the DPLL at its current rate. Signed-off-by: Dario Binacchi --- Changes in v4: - Split the already applied check into the disabled and enabled cases - Keep the reverse Christmas tree order for the variables list Changes in v3: - Skip reprogramming only if the configuration is already applied to the hardware Changes in v2: - Check the DPLL lock state instead of its parent, as the reference and bypass clocks can be the same clock drivers/clk/ti/dpll3xxx.c | 56 ++++++++++++++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 6 deletions(-) -- 2.43.0 diff --git a/drivers/clk/ti/dpll3xxx.c b/drivers/clk/ti/dpll3xxx.c index 052233f2e12b..b48ea0492378 100644 --- a/drivers/clk/ti/dpll3xxx.c +++ b/drivers/clk/ti/dpll3xxx.c @@ -690,17 +690,22 @@ int omap3_noncore_dpll_set_rate(struct clk_hw *hw, unsigned long rate, * @hw: pointer to the clock to set the spread spectrum configuration for * @ss_conf: spread spectrum configuration * - * Stores the spread spectrum clocking (SSC) configuration of the DPLL. The - * configuration is programmed along with the DPLL multiplier and divider - * at the next rate change. The hardware supports center-spread and - * down-spread only. Returns 0 on success, or a negative error value on - * failure. + * Stores the spread spectrum clocking (SSC) configuration of the DPLL and, + * if the DPLL is locked, reprograms it at its current rate to apply it. + * Otherwise the configuration is applied at the next rate change. The + * hardware supports center-spread and down-spread only. Returns 0 on + * success, negative error value otherwise. */ int omap3_noncore_dpll_set_spread_spectrum(struct clk_hw *hw, const struct clk_spread_spectrum *ss_conf) { struct clk_hw_omap *clk = to_clk_hw_omap(hw); struct dpll_data *dd = clk->dpll_data; + struct clk_spread_spectrum old_conf; + struct clk_rate_request req; + unsigned long rate; + u32 ctrl; + int ret; if (!dd || !dd->ssc_enable_mask) return -EOPNOTSUPP; @@ -709,9 +714,48 @@ int omap3_noncore_dpll_set_spread_spectrum(struct clk_hw *hw, if (ss_conf->method == CLK_SPREAD_UP) return -EINVAL; + ctrl = ti_clk_ll_ops->clk_readl(&dd->control_reg); + + if (!memcmp(ss_conf, &dd->ssc_conf, sizeof(*ss_conf))) { + /* Already disabled */ + if (ss_conf->method == CLK_SPREAD_NO && + !(ctrl & dd->ssc_enable_mask)) + return 0; + + /* Already enabled */ + if (ss_conf->method != CLK_SPREAD_NO && + (ctrl & dd->ssc_enable_mask)) + return 0; + } + + old_conf = dd->ssc_conf; dd->ssc_conf = *ss_conf; - return 0; + /* Disabling SSC does not need to reprogram the DPLL */ + if (ss_conf->method == CLK_SPREAD_NO) { + omap3_noncore_dpll_ssc_program(clk); + return 0; + } + + /* Not locked: SSC is programmed along with the next rate change */ + if (((ctrl & dd->enable_mask) >> __ffs(dd->enable_mask)) != DPLL_LOCKED) + return 0; + + rate = clk_hw_get_rate(hw); + clk_hw_init_rate_request(hw, &req, rate); + ret = omap2_dpll_determine_rate(hw, &req); + if (!ret && req.rate != rate) + ret = -EINVAL; + if (!ret) + ret = omap3_noncore_dpll_set_rate(hw, rate, + clk_hw_get_rate(dd->clk_ref)); + if (ret) { + pr_warn("clock: %s: rate %lu can't be kept with SSC enabled\n", + clk_hw_get_name(hw), rate); + dd->ssc_conf = old_conf; + } + + return ret; } /**