From patchwork Fri Oct 23 14:55:31 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 4892 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 A74843F0E2 for ; Fri, 23 Oct 2026 16:56:04 +0200 (CEST) Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-48e00f3929bsf1433544f8f.0 for ; Fri, 23 Oct 2026 07:56:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1792767364; cv=pass; d=google.com; s=arc-20260327; b=Qv8K98OTxnSpjJPdeKb4K64XLgVB49xodX2CnjCD9UtSETbvr1mdttI0p9dbCCeULE wl0Vs76o0obagYeYwdkDHoZincHb/fP4+ByopeJuZlbeqjr9sZIDsqM5rwEETWoBz3Vy iwb8wxqHYQ7BgVBkNiziSiEFj4tARKzi7QScVKuKzcffJfR2lQCd30Z8UU6+JQKp8BAo Rbno9P7O1Stc+7PqX2n7+P0Bi/nYivuqV4GNif7hacVRF+BaAq8jJ5zS5xv01r9YSUmd 8ZZRlkYtspxoukOMErSj+DcS+wFdHKyiR/ciHk6sKh+4n6tuJPhz6DY8XbXuuRP0F4Au Xmgg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; 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=h7zopdJEA74F1NJCM2VxN+YxXQxfdW5V2XE4UHy/JsQ=; fh=bitP2BqN+NzugEldU8nxs0kXBJcXnpyDnhm7pi8iYmg=; b=rD7D4xKvwN+lTalthzJhTkXYMBFeIKj8nHdP6sf/6PC7gXznMlftPWVoVr7pKu+D1n n5RxXgjh/J982A5BblAGoX5hwMXwJEgAL8FwUteiemZArvk4h8U0ebIylR09OfJFrcP8 EZHND3DK+94FfLTIGUD4xtKjnRTc5MOayKvsaVj+g4FdYkZ3ulXjtHhkMWUyCRzqo82P 0lg/mQ0sDF1uavKO5iZGZkMcwcCIb5Jcbh7Bgiaxfjkv/+ADQ0BnYElT8j5GxAB4yUP3 9Vy74bzK0lSjV7HGLsKhvsBQFIlZvBzeW/NkhiZ7SYRzBv6Sw/e+pWIrRE2vMYoNaBzs Fjaw==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=MIagqK0l; 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=1792767364; x=1793372164; darn=patchwork.amarulasolutions.com; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:content-type :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:content-type; bh=h7zopdJEA74F1NJCM2VxN+YxXQxfdW5V2XE4UHy/JsQ=; b=MLMH/9NMy645Anq627Q1FE4mviSbgT8ZDMxF1K+Cfh/LY39ly1vVJTlQP6FjYBPxb1 d5F4VXshMWZioY/aXlq1Qv5wadd67eG2iOuGWutKiZWVv2njiXDPXF5+6FRp7xjN+LxX gtG+pscyh3UW6I3Fw1AE9PTT4Anw6MbZYscX4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792767364; x=1793372164; h=list-unsubscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :content-type:x-original-authentication-results:x-original-sender :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-gg:x-beenthere:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=h7zopdJEA74F1NJCM2VxN+YxXQxfdW5V2XE4UHy/JsQ=; b=A8pIWAC+9WPyXogY59RUMi4oJ50PY2Pity+3J7663rhsy87vIDQDLWti3A47Rj0TMV 3pfOCiVtSHDaMDlc+Dsh5l12terxRB4fZhrj93IDX43WVP9OfH537hYk28OcQGPa07OM JRqyqt1evaJFUVDIMX1yFqvddPMBE1B8xNIuAShBZJxoSdpK5xK+b+5cUWtMPXmMppsO +NhuRyZM1PqN8Brxu1Qhdig8bdP0QYhVYBJx5pYhOeGgk/xNs1vUF0Oa4yR+U01CQLPD s/eNtX1kElqEBvpkDU3ix5rOypeV6tb9DLRHfmhbG6/K5Ddl03DbhGf0W6praM3aT6aq ZafQ== X-Forwarded-Encrypted: i=2; AKwUvBwDKhLEbPY17/3E5QbIExAJjYy73ijH1SVSz8UGmfdNGq6HONd02HBHbYhXLjDdvEu2mjZmLvzBy2wC24sJ@patchwork.amarulasolutions.com X-Gm-Message-State: AFq9FYJDWY7YffXDq0Hl4twozGqMdr3opEyBMW31axSZscZ8RKb17DbE 4iB8fu48/R8JykUe7My/tzJLa8Zc49374vuHVwGzpd3cQ9ziWLQ5EHGLnvUKhS/t/ExTGg== X-Received: by 2002:a05:6000:188a:b0:48a:f4d4:e1f3 with SMTP id ffacd0b85a97d-48e38599f31mr4209633f8f.13.1792767364295; Fri, 23 Oct 2026 07:56:04 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com; h="ATskLddWG5/VeE5iF8iXZ80m3I5JsgS/STEBxk4ORsi6UYPHHA==" Received: by 2002:a5d:6041:0:b0:487:615:30c0 with SMTP id ffacd0b85a97d-48e2ca6532als716014f8f.2.-pod-prod-00-eu-canary; Fri, 23 Oct 2026 07:56:02 -0700 (PDT) X-Received: by 2002:a5d:5d0f:0:b0:48d:f1ab:faf9 with SMTP id ffacd0b85a97d-48e3859a291mr4550276f8f.16.1792767362449; Fri, 23 Oct 2026 07:56:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1792767362; cv=none; d=google.com; s=arc-20260327; b=R0dgWfCfjXdNd1Pjrk7rqs8jbTTfVQBKfzCrujH8o6mMSNU0E+swvr+Y7TXFhvBPd9 WQW82T13bk8qTCfSIYEFkBHGehvkzSHpw/z+jazqD86jQJrGNjmQMhBDpv7UsU812f5p NZ1o6bR5Z+S9HRizTYVkzyGl2ObK99BNU4KeAtjhpTM9ah9+wbkpJtHc03llFdg8l7+O 7EKCuV95vZKDGAWQZqk9PxHFAnhqQ4iUfI38pmSj7eUv8g5/ckYjb3WR1PBXfyG2IHUT SJSBbRZJNOg5Vws2bQSxjJNymH/+dKxjS70W9maRhG0YQaSVhyaJ5YN/G9/5utmjIDup Na1w== 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=80oQFk83gUm5oUkUtGxTmSCfXu9EgvcllbggxNBcnbY=; fh=PbD9/XAkGeXOdmhINiq9gVEkmozRqhY0cRjgzaGu/Os=; b=AtvJ2XwlXfzBX4a4ZFsAk1ItAQiCsG0NcgpILVPBfrPwjTMtzLjWQ4yAyO2gR5nZeH l++Jd55uhlB6cmBbG87s8rfn0/ImLd86vjorqc/o1Ltfk9hN/PEeSQiUvoTnsRfcgME3 uNprDl8CLCQEEy9JuMKlaD7IKPtiZQo7PSyn3uF5cHKSeX1mFVbYLoXjEaT1Qz6JpYn5 axYRTcIEH5m36GC9uB50qJva7nCJWMI7SC6TzqoUBpeTgmRcrRbyvZ9B078bz9rnEaW2 E5Or7ZK7e3ryhLWLJd6IwZuO5cqO83DRWLAMlNywbVqg0dMaxuJbUTtk1ZW/ZduQ+EYT dfUA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=MIagqK0l; 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 Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id ffacd0b85a97d-48e3d4cecc0sor23015f8f.8.2026.10.23.07.56.02 for (Google Transport Security); Fri, 23 Oct 2026 07:56:02 -0700 (PDT) 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: AYBFou0exlCK2oSmb0/5iPnVHc1NXpuiJRPS2p/WrFclvYAxI4JE4WF6UwQXoi458Xn WRRX4ZK4eUsfTte1atF28h+c8q00d5pvse9Iz4in5BpBcTj/YuEmy4JCDkZM1sjJOb/qZebTW98 EHa9+lLTqHzypt1OFtW4V1jgtbGduEYvxZYKIPKeEqz7VllJgpVbBeRm2dwP6Lu07bRYcOq7b5Z SohSLUbSw6sYWGkRA/hpnBQs6XqTTPyIHATwi1ibYBxsHH6l0t5vhTrHI+d36PVmsmnsiDoccGn LkhASvrHM5Fh0KAQl0gYXg6KFycJVUdetwrBPEN3ZGo+72MQwm8os6PqQ+ewUK8uvwUZgRl22Ch GIIJ1OGyNO+oERGYC96VESXtqjrxy6Mp8w2DeVYGt8vytGbF+DFuIdiqsjQSDTrcyWGLp7hEmF2 OXjMaC3qew0S8IE8zYrDd18c3IUwkRF/BwxuHzOlQISguEyNwKuFK1aksAtgR9Tuji8ZQHq3zF7 kiIw23lPFaUvnU26fITrWC15QGWhx2+GwegwE0t5VZbl93jZrtAYakVu3Sb7RLCOx1Ae6cQal5v 7A4b2Ck0ieT9hJVxaRcBSq6XQZkTae2ByU05OdVwbiDUJqwv/HECZlPXVPOw1U4/YWBHCbx9vQA acg84P/0eO03rIonvxgaipoqikeG3fWehPvolyHzTDHu4Ke3X7/hx X-Received: by 2002:a05:6000:4a0a:b0:48e:22fd:1ea3 with SMTP id ffacd0b85a97d-48e2d279e8fmr11095010f8f.28.1792767361919; Fri, 23 Oct 2026 07:56:01 -0700 (PDT) Received: from dario-ThinkPad-P14s-Gen-5.homenet.telecomitalia.it (host-79-14-29-58.business.telecomitalia.it. [79.14.29.58]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e3d42f884sm226760f8f.57.2026.10.23.07.56.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2026 07:56:01 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, michael@amarulasolutions.com, Dario Binacchi , Brian Masney , Jerome Brunet , Stephen Boyd , Tero Kristo , linux-clk@vger.kernel.org, linux-omap@vger.kernel.org Subject: [PATCH 2/3] clk: ti: dpll: use the generic spread spectrum configuration Date: Fri, 23 Oct 2026 16:55:31 +0200 Message-ID: <20261023145555.3578469-3-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261023145555.3578469-1-dario.binacchi@amarulasolutions.com> References: <20261023145555.3578469-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=MIagqK0l; 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 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 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 drop the vendor specific properties. 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 --- drivers/clk/ti/clock.h | 2 ++ drivers/clk/ti/dpll.c | 8 ++--- drivers/clk/ti/dpll3xxx.c | 61 ++++++++++++++++++++++++++++++++------- include/linux/clk/ti.h | 9 ++---- 4 files changed, 57 insertions(+), 23 deletions(-) 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..626b44297e42 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 }; @@ -348,12 +350,6 @@ static void __init of_ti_dpll_setup(struct device_node *node, if (ti_clk_get_reg_addr(node, ssc_clk_index++, &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"); } 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..634fe0a1f9fd 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,44 @@ 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; + + switch (ss_conf->method) { + case CLK_SPREAD_NO: + break; + case CLK_SPREAD_CENTER: + case CLK_SPREAD_DOWN: + if (!ss_conf->modfreq_hz || !ss_conf->spread_bp) + return -EINVAL; + break; + default: + /* Up-spread is not supported by the hardware */ + 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 54a3fa370004..81ac070551f9 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, as set by clk_hw_set_spread_spectrum() * @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; };