Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp1104945rdh; Fri, 24 Nov 2023 05:29:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IFz6DMjoeYZwPaDb5zVd5wRwFBamnfHFIG6sCo0nqaEtuyAABXmlIOqKnwgpcHfIB84JIGk X-Received: by 2002:a05:6808:d47:b0:3b8:42e9:95d8 with SMTP id w7-20020a0568080d4700b003b842e995d8mr3501437oik.38.1700832566639; Fri, 24 Nov 2023 05:29:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700832566; cv=none; d=google.com; s=arc-20160816; b=XstAobKmVrILNDfduCLs4L6IuOyiuTr1UeZfXV6th5XRn2sY7Embo4KtquulvF4vSD zikYMr0Cq59/AN1O0r38qxfUab17gupOAdapPbGtAB43l9VKRra8sEykhZ3zLb7ZG/Lf onWjtoNxHfHUsVP8zysehN3z8l4TG5hKZNfYSw7fD2Sy72f5eAvdlUR/w86Xwskb/ejh CaKI+pSGaH7KVdl/Ktu7Jus/SyCLWzNJNQygAvXlxZ4EgXd+MY4v7NalgPqqx9K8VEAR f3rceXYl1fuxTJGcGist5bGwXgCEGZL3vMLRD8NnImBIfdPgZeyOluL1JUk5MTYFzvYX UN1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=6Vh2HI7LlXpVzLq5VbBFa/JKlR1pzRd6vBC4WesJT8w=; fh=cmShaaKDM89fu74c5NvQ6BtZelLx90jo5mGjUZMX0tM=; b=GQTjoypxqxOGuvU59Hd8dqili+ly+JB6TZ8o0y6aZ6ugIdi1z5vpo7Gi7gNt8dSRzH N9ApKzsA8AWtl8+VKG+GXFHNz7vJ7Nk8ekBFWqz7Gawe2jmVkkLCOUKotI0w4dXLJvnS IDSptn3vjsxq2t+lKduen3ssk7qUfkSl8TdgZUHD2zQFVNNGxUBxybZ2ho3AhgtvCZeL 7iVBkaKadBu4H33h3OYtmphpVKqjO1mYCPc79FBegCF3JZN1GEoLT8WMqFIgmMU47gvJ KlbXJkIDN97Vm/MLG/tSBCwA4H7pjqn2s2+w7xdClWHoMb/thRiAN0+2doJNPysd/9Rn QA3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pqrs.dk header.s=key1 header.b="en/7+/NV"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id e9-20020a63ee09000000b005b8ebb76177si3665682pgi.561.2023.11.24.05.29.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Nov 2023 05:29:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@pqrs.dk header.s=key1 header.b="en/7+/NV"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 14DD98081699; Fri, 24 Nov 2023 05:29:20 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345088AbjKXN24 (ORCPT + 99 others); Fri, 24 Nov 2023 08:28:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232949AbjKXN2U (ORCPT ); Fri, 24 Nov 2023 08:28:20 -0500 Received: from out-186.mta0.migadu.com (out-186.mta0.migadu.com [91.218.175.186]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1B3419A1 for ; Fri, 24 Nov 2023 05:27:32 -0800 (PST) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pqrs.dk; s=key1; t=1700831884; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6Vh2HI7LlXpVzLq5VbBFa/JKlR1pzRd6vBC4WesJT8w=; b=en/7+/NVm9Fo4O4adG2WBHTA6hkVigaqX+uPnGm8qCYVDmWNcSljdLKiVHFEqxXkdJv0ZV dNQFyGOthyu68HAm+4kj1IV3dH3KR6qghLSV0OA6g7+DbnM6gb1DoqsgLE1iLtVp9AV1// vPrjuk1u85oCYxF8k9jLM6KGP8WLeeM5vfTSWE7Enr98Br4nKAjQGaXOIbg6f6agbEZSFk r/p3U7Fqr6/Y4+RRUkfAIX/ItAMHiDoDPbOgG27JllgGvEZXJ5jeEn9irT4ilyO2MXwwlu kBwGlnT1gpDFjYQsy700N5ZaDc4dj52b8abmAgusbADZkYS9vB+z0gdWQtbHkw== From: =?utf-8?q?Alvin_=C5=A0ipraga?= Date: Fri, 24 Nov 2023 14:17:44 +0100 Subject: [PATCH v6 3/3] clk: si5351: allow PLLs to be adjusted without reset MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20231124-alvin-clk-si5351-no-pll-reset-v6-3-69b82311cb90@bang-olufsen.dk> References: <20231124-alvin-clk-si5351-no-pll-reset-v6-0-69b82311cb90@bang-olufsen.dk> In-Reply-To: <20231124-alvin-clk-si5351-no-pll-reset-v6-0-69b82311cb90@bang-olufsen.dk> To: Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Conor Dooley , =?utf-8?q?Alvin_=C5=A0ipraga?= Cc: Sebastian Hesselbarth , Rabeeh Khoury , Jacob Siverskog , Sergej Sawazki , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Fri, 24 Nov 2023 05:29:21 -0800 (PST) From: Alvin Šipraga Introduce a new PLL reset mode flag which controls whether or not to reset a PLL after adjusting its rate. The mode can be configured through platform data or device tree. Since commit 6dc669a22c77 ("clk: si5351: Add PLL soft reset"), the driver unconditionally resets a PLL whenever its rate is adjusted. The rationale was that a PLL reset was required to get three outputs working at the same time. Before this change, the driver never reset the PLLs. Commit b26ff127c52c ("clk: si5351: Apply PLL soft reset before enabling the outputs") subsequently introduced an option to reset the PLL when enabling a clock output that sourced it. Here, the rationale was that this is required to get a deterministic phase relationship between multiple output clocks. This clearly shows that it is useful to reset the PLLs in applications where multiple clock outputs are used. However, the Si5351 also allows for glitch-free rate adjustment of its PLLs if one avoids resetting the PLL. In our audio application where a single Si5351 clock output is used to supply a runtime adjustable bit clock, this unconditional PLL reset behaviour introduces unwanted glitches in the clock output. It would appear that the problem being solved in the former commit may be solved by using the optional device tree property introduced in the latter commit, obviating the need for an unconditional PLL reset after rate adjustment. But it's not OK to break the default behaviour of the driver, and it cannot be assumed that all device trees are using the property introduced in the latter commit. Hence, the new behaviour is made opt-in. Cc: Sebastian Hesselbarth Cc: Rabeeh Khoury Cc: Jacob Siverskog Cc: Sergej Sawazki Signed-off-by: Alvin Šipraga Acked-by: Sebastian Hesselbarth --- drivers/clk/clk-si5351.c | 47 +++++++++++++++++++++++++++++++++--- include/linux/platform_data/si5351.h | 2 ++ 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/drivers/clk/clk-si5351.c b/drivers/clk/clk-si5351.c index cbf7cde01157..bed0fe3bfa08 100644 --- a/drivers/clk/clk-si5351.c +++ b/drivers/clk/clk-si5351.c @@ -506,6 +506,8 @@ static int si5351_pll_set_rate(struct clk_hw *hw, unsigned long rate, { struct si5351_hw_data *hwdata = container_of(hw, struct si5351_hw_data, hw); + struct si5351_platform_data *pdata = + hwdata->drvdata->client->dev.platform_data; u8 reg = (hwdata->num == 0) ? SI5351_PLLA_PARAMETERS : SI5351_PLLB_PARAMETERS; @@ -518,9 +520,10 @@ static int si5351_pll_set_rate(struct clk_hw *hw, unsigned long rate, (hwdata->params.p2 == 0) ? SI5351_CLK_INTEGER_MODE : 0); /* Do a pll soft reset on the affected pll */ - si5351_reg_write(hwdata->drvdata, SI5351_PLL_RESET, - hwdata->num == 0 ? SI5351_PLL_RESET_A : - SI5351_PLL_RESET_B); + if (pdata->pll_reset[hwdata->num]) + si5351_reg_write(hwdata->drvdata, SI5351_PLL_RESET, + hwdata->num == 0 ? SI5351_PLL_RESET_A : + SI5351_PLL_RESET_B); dev_dbg(&hwdata->drvdata->client->dev, "%s - %s: p1 = %lu, p2 = %lu, p3 = %lu, parent_rate = %lu, rate = %lu\n", @@ -1222,6 +1225,44 @@ static int si5351_dt_parse(struct i2c_client *client, } } + /* + * Parse PLL reset mode. For compatibility with older device trees, the + * default is to always reset a PLL after setting its rate. + */ + pdata->pll_reset[0] = true; + pdata->pll_reset[1] = true; + + of_property_for_each_u32(np, "silabs,pll-reset-mode", prop, p, num) { + if (num >= 2) { + dev_err(&client->dev, + "invalid pll %d on pll-reset-mode prop\n", num); + return -EINVAL; + } + + p = of_prop_next_u32(prop, p, &val); + if (!p) { + dev_err(&client->dev, + "missing pll-reset-mode for pll %d\n", num); + return -EINVAL; + } + + switch (val) { + case 0: + /* Reset PLL whenever its rate is adjusted */ + pdata->pll_reset[num] = true; + break; + case 1: + /* Don't reset PLL whenever its rate is adjusted */ + pdata->pll_reset[num] = false; + break; + default: + dev_err(&client->dev, + "invalid pll-reset-mode %d for pll %d\n", val, + num); + return -EINVAL; + } + } + /* per clkout properties */ for_each_child_of_node(np, child) { if (of_property_read_u32(child, "reg", &num)) { diff --git a/include/linux/platform_data/si5351.h b/include/linux/platform_data/si5351.h index c71a2dd66143..5f412a615532 100644 --- a/include/linux/platform_data/si5351.h +++ b/include/linux/platform_data/si5351.h @@ -105,10 +105,12 @@ struct si5351_clkout_config { * @clk_xtal: xtal input clock * @clk_clkin: clkin input clock * @pll_src: array of pll source clock setting + * @pll_reset: array indicating if plls should be reset after setting the rate * @clkout: array of clkout configuration */ struct si5351_platform_data { enum si5351_pll_src pll_src[2]; + bool pll_reset[2]; struct si5351_clkout_config clkout[8]; }; -- 2.42.1