From patchwork Wed Nov 4 10:16:56 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 4977 Delivered-To: michael@amarulasolutions.com Received: by 2002:a05:7301:5407:b0:36a:3487:1c26 with SMTP id aa7csp35440dyc; Wed, 4 Nov 2026 02:17:47 -0800 (PST) X-Received: by 2002:a05:6000:4810:b0:48b:2a2:31dc with SMTP id ffacd0b85a97d-48e6e5267c4mr36199683f8f.49.1793787467612; Wed, 04 Nov 2026 02:17:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1793787467; cv=none; d=google.com; s=arc-20260327; b=BeLX2CjY0jDLC8U9vNegdkAde0dv4YXWCO85LKAWi+n7CQI1+W2XNj833abxxughdp +eBlkkPg7zG/7YH8laYLXi17sc0pJN/6qs27qWKlAja/AfVsnDbkINVdMMUcym7kfzRd nDl2F8Pmill97TTCjiugzYwdW5EXw6oUG98cduj84x7S/yxlEP5XR4ucXYc1qT/go7Ve 8TCQNNsOcDOYRzZqisVbCcgEEFyuNh8/oTskKqrCT2WsJcSFTTmnF42NwTL2CQqOgPOj +J/OpaNRmWI8h6v8ReUWgYFAYCpTBA4NQLkKKpi6xL+2h56Zjiu4K681IR0mtWsocIAs KkGA== 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=xtoytOhDAraaCDXzQjcwaANupRV+STFp2/XgbK9TFAs=; fh=4KgKzUt+w1/nYxpJAYO/ECudv3fO5brOvX+6sjW+qV0=; b=c/esu136/9X/SBAF5ZjXru5ujicLCbSTo5ujx1qnqL/EwfZI+xC5uVaokbtrAzyx6F XL2ZGSoCaJyWjGqqD9Xpwgl2vmjPPMRlwL291a0zQDVm/j6bXHfvE32OvLL7fVItQ9/E GJKrOjYi+y4dfFyWWu185swreej2P3HJtsNvpS5lFV4TH/kYFfLuFt0gDY3PvtbnrCfP DI1Y8MpCWHNo610KoUvDxivAkTX9bFzRrWijQ5npEez6/ditJtpk6ZdgpXMsKDtnxodr K9La5RI0UJEfxl+IcJ++en46lm78pXOmCSJN6teqG0OPeyv4w5Ug7IC78cuiaI7RM1Or QNwg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="Lyxf/uVA"; 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 ffacd0b85a97d-48fed17a222sor255463f8f.14.2026.11.04.02.17.47 for (Google Transport Security); Wed, 04 Nov 2026 02:17:47 -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="Lyxf/uVA"; 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=1793787467; x=1794392267; 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=xtoytOhDAraaCDXzQjcwaANupRV+STFp2/XgbK9TFAs=; b=Lyxf/uVAYVqe6xvnAmmF/HqNWEaYIH0uqCODJInbResCgAK3mEcYxKV6qGgu0l06hl ZxT2cAcx60NDR5F4hdXW+52QDXSJiedfKUc+l9ueUVWp8tbV3nCudUDcVN9i9UXRqrL0 qxylTpET8oJxKtuAPM0kXrq9AYqXKr5q53NhQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793787467; x=1794392267; 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=xtoytOhDAraaCDXzQjcwaANupRV+STFp2/XgbK9TFAs=; b=JmhTBbpW+5FQacttK0s7wbnV1FjgZYq4BZf5K4h1Mb/OOmM36HBwIzxHPFx/qe6SW7 mrtGK9wwsl2eT5RhTMy4r9wg78kS2i3aWBnlVh4u+/Go/X0mZ4tXP6GBHqhSGuM1KI8q L/D8bplvirj2JpJGk0rxt2G5ZZj6B6bpJ5NyuKWxz2gmBcT3ex6AxGI/6YZEqE7iEc4N TnL2LdrpKszuWl9+gpoI1rP8slw1HF5CThha73xRFlvl0eYL6s/uqRJAVvlvI5X5Ud8R 9BmNOFiNrqSv0SpYBwqwU2N0AmEWdqaxnzw/uJ4+Qw6UC1iHNhxtcnEn6mGWGygoZ7eW VRMg== X-Gm-Message-State: APuU4Z+Usu/kUi/L4kBllxI3Y1clcG6if3pYKylDKHQabqJAl2KR4wVd gneN2YQCf9zX0qgfMMZ+ksCy42Spztt/LxxAvnejVw2eE7wKiE7kSfLl0fe0wCgnoOnFFw== X-Gm-Gg: AYBFou1Das/y3PhhocfmmtxPpLO3xUFWJRqOVD15xqvQODA/jCmayP0fooHtbq0FYM6 yBgD/mRpBQkW64Togr+3o2vwLBtvyL/qL45LwOjxvkb+t+fgPqVO8VBx4HRNcuug1UNl4lU5j70 Thw/hTaRQgmByrX2QXatqdQcT+DmEwm6tKWIbj6zaaciadc3mjNzI+Js8r4PkgMdIroG1oVazMs /wOkrF4EGEhrcrCO0BwuU4NuvE1QqmFmBf9NJV8JTOIsE60vV60CbMu0kN/9wReUuqHqn9ECEsm s7lshjoRLMbdU1hvcrNHEyv2k5t/S6nUMcbCR2WQCNW/djOM7PwbNUibuAfU0GDRkY+ZoBQeW48 710EZ5nJP+Rvy45OVD9aj+dhe3zs2Ua7uuRsopBp7O5O97N8YGTR7mTKi/4SxfgKZmL4crBjMD4 ouJZPUlTXvqPpPJMez8TPBvqSmEXk5bb6tnPkyCrohVvQEtlh20scLH5+RPHb78bIJYZTeNW+W2 XEKOe5nxR9QZiIlzzFhUBC87AgdOIBbpMX4wOPy+ugchd8+gBFyzDijA5ZgLvoGi6H4tPQHd+1N cNFwafi15aOBtFYZgGjEZ2rRhEIv/UFbE/+ViePbSFVJ5rEgHkukgzHLwnK0fj8ItfynFw9JnrV gMpp0mE8XtKOt4Qo5CRhAwalAWtehyzigKCNPnSr2kZwFoclu0G6Q X-Received: by 2002:a05:6000:2310:b0:490:a3e7:8af3 with SMTP id ffacd0b85a97d-490a3e78cd2mr400000f8f.35.1793787466939; Wed, 04 Nov 2026 02:17:46 -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.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2026 02:17:46 -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 2/3] clk: ti: dpll: use the generic spread spectrum configuration Date: Wed, 4 Nov 2026 11:16:56 +0100 Message-ID: <20261104101732.4043372-3-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 clock framework provides a generic API and DT property for spread spectrum clocking (SSC) since commit c86814e70390 ("clk: Introduce clk_hw_set_spread_spectrum"). Implement the set_spread_spectrum callback and convert the deprecated vendor specific properties to the generic configuration, so that existing DTs keep working. The SSC registers are programmed at the next rate change, as with the vendor specific properties. The generic framework expresses the spread in permyriad rather than permille, hence the change in the deltaM step computation, and also supports up-spread, which is rejected as the hardware does not support it. Signed-off-by: Dario Binacchi --- Changes in v4: - Keep the reverse Christmas tree order for the variables list - Check the range of the deprecated ti,ssc-deltam property - Drop the checks already done by the clock framework Changes in v3: - Keep parsing the deprecated vendor specific properties drivers/clk/ti/clock.h | 2 ++ drivers/clk/ti/dpll.c | 21 ++++++++++++---- drivers/clk/ti/dpll3xxx.c | 52 +++++++++++++++++++++++++++++++-------- include/linux/clk/ti.h | 9 ++----- 4 files changed, 62 insertions(+), 22 deletions(-) -- 2.43.0 diff --git a/drivers/clk/ti/clock.h b/drivers/clk/ti/clock.h index d5e24fe4ae3a..83225e506314 100644 --- a/drivers/clk/ti/clock.h +++ b/drivers/clk/ti/clock.h @@ -271,6 +271,8 @@ int omap3_noncore_dpll_set_rate_and_parent(struct clk_hw *hw, unsigned long rate, unsigned long parent_rate, u8 index); +int omap3_noncore_dpll_set_spread_spectrum(struct clk_hw *hw, + const struct clk_spread_spectrum *ss_conf); int omap3_noncore_dpll_determine_rate(struct clk_hw *hw, struct clk_rate_request *req); int omap2_dpll_determine_rate(struct clk_hw *hw, struct clk_rate_request *req); diff --git a/drivers/clk/ti/dpll.c b/drivers/clk/ti/dpll.c index e01272cd628d..60150006ee0b 100644 --- a/drivers/clk/ti/dpll.c +++ b/drivers/clk/ti/dpll.c @@ -51,6 +51,7 @@ static const struct clk_ops dpll_ck_ops = { .set_parent = &omap3_noncore_dpll_set_parent, .set_rate_and_parent = &omap3_noncore_dpll_set_rate_and_parent, .determine_rate = &omap3_noncore_dpll_determine_rate, + .set_spread_spectrum = &omap3_noncore_dpll_set_spread_spectrum, .get_parent = &omap2_init_dpll_parent, .save_context = &omap3_noncore_dpll_save_context, .restore_context = &omap3_noncore_dpll_restore_context, @@ -63,6 +64,7 @@ static const struct clk_ops dpll_no_gate_ck_ops = { .set_parent = &omap3_noncore_dpll_set_parent, .set_rate_and_parent = &omap3_noncore_dpll_set_rate_and_parent, .determine_rate = &omap3_noncore_dpll_determine_rate, + .set_spread_spectrum = &omap3_noncore_dpll_set_spread_spectrum, .save_context = &omap3_noncore_dpll_save_context, .restore_context = &omap3_noncore_dpll_restore_context }; @@ -276,6 +278,8 @@ static void __init of_ti_dpll_setup(struct device_node *node, struct clk_init_data *init = NULL; const char **parent_names = NULL; struct dpll_data *dd = NULL; + u32 ssc_modfreq = 0; + u32 ssc_deltam = 0; int ssc_clk_index; u8 dpll_mode = 0; u32 min_div; @@ -349,11 +353,18 @@ static void __init of_ti_dpll_setup(struct device_node *node, &dd->ssc_modfreq_reg)) goto cleanup; - of_property_read_u32(node, "ti,ssc-modfreq-hz", - &dd->ssc_modfreq); - of_property_read_u32(node, "ti,ssc-deltam", &dd->ssc_deltam); - dd->ssc_downspread = - of_property_read_bool(node, "ti,ssc-downspread"); + /* Deprecated, superseded by assigned-clock-sscs */ + of_property_read_u32(node, "ti,ssc-modfreq-hz", &ssc_modfreq); + of_property_read_u32(node, "ti,ssc-deltam", &ssc_deltam); + if (ssc_modfreq && ssc_deltam && ssc_deltam <= 1000) { + dd->ssc_conf.modfreq_hz = ssc_modfreq; + /* permille to permyriad */ + dd->ssc_conf.spread_bp = ssc_deltam * 10; + if (of_property_read_bool(node, "ti,ssc-downspread")) + dd->ssc_conf.method = CLK_SPREAD_DOWN; + else + dd->ssc_conf.method = CLK_SPREAD_CENTER; + } } if (of_property_read_bool(node, "ti,low-power-stop")) diff --git a/drivers/clk/ti/dpll3xxx.c b/drivers/clk/ti/dpll3xxx.c index 8c51b988a04f..052233f2e12b 100644 --- a/drivers/clk/ti/dpll3xxx.c +++ b/drivers/clk/ti/dpll3xxx.c @@ -295,30 +295,32 @@ static void _lookup_sddiv(struct clk_hw_omap *clk, u8 *sd_div, u16 m, u8 n) * omap3_noncore_dpll_ssc_program - set spread-spectrum clocking registers * @clk: struct clk * of DPLL to set * - * Enable the DPLL spread spectrum clocking if frequency modulation and - * frequency spreading have been set, otherwise disable it. + * Enable the DPLL spread spectrum clocking according to the configuration + * set by omap3_noncore_dpll_set_spread_spectrum(), otherwise disable it. */ static void omap3_noncore_dpll_ssc_program(struct clk_hw_omap *clk) { struct dpll_data *dd = clk->dpll_data; + const struct clk_spread_spectrum *conf = &dd->ssc_conf; + bool downspread = conf->method == CLK_SPREAD_DOWN; unsigned long ref_rate; u32 v, ctrl, mod_freq_divider, exponent, mantissa; u32 deltam_step, deltam_ceil; ctrl = ti_clk_ll_ops->clk_readl(&dd->control_reg); - if (dd->ssc_modfreq && dd->ssc_deltam) { + if (conf->method != CLK_SPREAD_NO) { ctrl |= dd->ssc_enable_mask; - if (dd->ssc_downspread) + if (downspread) ctrl |= dd->ssc_downspread_mask; else ctrl &= ~dd->ssc_downspread_mask; ref_rate = clk_hw_get_rate(dd->clk_ref); mod_freq_divider = - (ref_rate / dd->last_rounded_n) / (4 * dd->ssc_modfreq); - if (dd->ssc_modfreq > (ref_rate / 70)) + (ref_rate / dd->last_rounded_n) / (4 * conf->modfreq_hz); + if (conf->modfreq_hz > (ref_rate / 70)) pr_warn("clock: SSC modulation frequency of DPLL %s greater than %ld\n", __clk_get_name(clk->hw.clk), ref_rate / 70); @@ -337,9 +339,10 @@ static void omap3_noncore_dpll_ssc_program(struct clk_hw_omap *clk) v |= exponent << __ffs(dd->ssc_modfreq_exp_mask); ti_clk_ll_ops->clk_writel(v, &dd->ssc_modfreq_reg); - deltam_step = dd->last_rounded_m * dd->ssc_deltam; - deltam_step /= 10; - if (dd->ssc_downspread) + /* spread_bp is in permyriad, convert to percent first */ + deltam_step = dd->last_rounded_m * conf->spread_bp; + deltam_step /= 100; + if (downspread) deltam_step /= 2; deltam_step <<= __ffs(dd->ssc_deltam_int_mask); @@ -353,7 +356,7 @@ static void omap3_noncore_dpll_ssc_program(struct clk_hw_omap *clk) if (deltam_step & dd->ssc_deltam_frac_mask) deltam_ceil++; - if ((dd->ssc_downspread && + if ((downspread && ((dd->last_rounded_m - (2 * deltam_ceil)) < 20 || dd->last_rounded_m > 2045)) || ((dd->last_rounded_m - deltam_ceil) < 20 || @@ -682,6 +685,35 @@ int omap3_noncore_dpll_set_rate(struct clk_hw *hw, unsigned long rate, return ret; } +/** + * omap3_noncore_dpll_set_spread_spectrum - set the DPLL SSC configuration + * @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. + */ +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; + + if (!dd || !dd->ssc_enable_mask) + return -EOPNOTSUPP; + + /* Up-spread is not supported by the hardware */ + if (ss_conf->method == CLK_SPREAD_UP) + return -EINVAL; + + dd->ssc_conf = *ss_conf; + + return 0; +} + /** * omap3_noncore_dpll_set_rate_and_parent - set rate and parent for a DPLL clock * @hw: pointer to the clock to set rate and parent for diff --git a/include/linux/clk/ti.h b/include/linux/clk/ti.h index 61c4abf19995..8b29cd7db15c 100644 --- a/include/linux/clk/ti.h +++ b/include/linux/clk/ti.h @@ -65,10 +65,7 @@ struct clk_omap_reg { * @ssc_enable_mask: mask of the DPLL SSC enable bit in @control_reg * @ssc_downspread_mask: mask of the DPLL SSC low frequency only bit in * @control_reg - * @ssc_modfreq: the DPLL SSC frequency modulation in kHz - * @ssc_deltam: the DPLL SSC frequency spreading in permille (10th of percent) - * @ssc_downspread: require the only low frequency spread of the DPLL in SSC - * mode + * @ssc_conf: the DPLL SSC configuration * @flags: DPLL type/features (see below) * * Possible values for @flags: @@ -124,9 +121,7 @@ struct dpll_data { u32 ssc_modfreq_exp_mask; u32 ssc_enable_mask; u32 ssc_downspread_mask; - u32 ssc_modfreq; - u32 ssc_deltam; - bool ssc_downspread; + struct clk_spread_spectrum ssc_conf; u8 flags; };