From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.54 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795997861; b=QDWPT+GsuBNuLB5uNjVrhVCiSmyxZBXPUHlmY5NaHR455JI+R1kJm+gFe06MUz+A0MbO 4VAOfsao5CyR0YsLoGeV1zTyqTfFYGhZ3d48SoOCSSchFOc7QDcr8Gv2lO1ucXxoJA+vc p+1xgZrVLsbm6qthnhuA4DHHWZU/zg+I/T5uV1sb3Kv2A8jfDhMZKS9cMuuLdnngKPFV5 3TrTRHseWX4QVIBN0oOs2Qz16ztKxrrkvoGwI5RHtnWmi7eKa6r7ggGnP9lfM4XtTLVqD c+FrOLaNyM3hxJ2BXayVbYLu8ODqh8bRTHEev2DgQjpytQNZaRBtkR5DVT6HLtrgOOQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795997861; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Message-ID:X-Google-Original-Message-ID:Date:From:To:Cc:Subject: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=QEIH1Sd/T+srRwK7bCNvnvTq9uzKXIMJ/a9ZISzB2GE=; b=Ych3UpN0kAUX/oOEfvG++szkqY9K9YRhjL067ZqYvhdf9z5dYFBPBmUMvIa9f1ZrRSDh Kv2uptpBTrDQCVa+XdqrYwIX6lqB8xloc93Mp0oA6xlHSFA9m0iCD4y2Jmsab86EiQeO1 2k+lPrtfXzuPqfS55hNtpaJOnwDg1y/RdUhJjSS5q6X6DxEbd45wltQV8FRtEsAUiX7/U tfpS5Hqu3KBhwjZRuO8JZqkrOhegCQqi0V3AtmSwTbypHQYfh+QV2PMafIf+G4OPnZzOp bl2vPGT6Q1s3KxbEUVW0S1lb6Rrd+FCAvO4UFA+TSwqWLrRiBkWOGlS5Q1TA1lBvwMw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=hQ9Ua9b3; arc=none smtp.remote-ip=209.85.128.54 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3E12B606A325 for ; Mon, 30 Nov 2026 00:17:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3E12B606A325 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=hQ9Ua9b3 Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-4a214c5c4c0so95561575e9.3 for ; Sun, 29 Nov 2026 16:17:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795997859; x=1796602659; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:subject:cc:to:from:date:message-id:from:to:cc:subject :date:message-id:reply-to:content-type; bh=QEIH1Sd/T+srRwK7bCNvnvTq9uzKXIMJ/a9ZISzB2GE=; b=hQ9Ua9b3JL7VB714JZj9n4O8/SowMhQVnrjtKK/Ydc+24cDs9AjOB7l0E+WDXXb4lY 6zwKf2ZSuuKgjm/xZV/NGbLnOTaf4LZWNxk3xisec8P7jUmkNw4EGkRxntD90/fO2K6a RaqLHYIb9KZ7uPB1cJOE0Xtu+KixkETg0a+QrpJMM8rADy/LH++sI7pv4Ppf/YFhPqi0 HqZJoeivuWb4ab1ljxV95kfv0Z3p01Pa7B2+UeYwNvawZjs6M6eNXv3LGqqMteBtTQGQ XZZip1Sdw0bj47LXaBKBbuPbe2ZJgnp4QUjFw/06uaqpbuNnRJmYxOw3Sil5tzLVMY+v lOLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795997859; x=1796602659; h=in-reply-to:content-disposition:content-type:mime-version :references:subject:cc:to:from:date:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=QEIH1Sd/T+srRwK7bCNvnvTq9uzKXIMJ/a9ZISzB2GE=; b=aEltqVdWglqbzOv4FNPjcaHFQ0j8XJk9zgQ2NIrys8W2IdWFMJdlieHHjSLQtmElDP Ueflj0FYvl7gwu2V0ohrfdB/DTXpy3IlROUM020t+ee1y9d+bzFgt3YztQ1DF1InGe3+ NMFHWcfbspm5Oj6r414xAg8st6VcfV8ZmBhw1NPTozRMQ7b76M/qo0pxtyQIK2rphJd/ IBvEquQYc2Q87OqLqjn7Ju8oSPTRzc6lanMCmPDBGt/9lvKe5LwagFSvt/EqtLnpJNzi AWZTdaWT3s67tZ99ktRPCEMG6zrAHXgR93LHFo9qiukpR5tK588DOaZMAlITUeIKjx6T Hy3g== X-Forwarded-Encrypted: i=1; AL+hErHXaBYZo370JON8LDqLdm8nKOhb5k8m3eb0azLmu9RNwwSVfTi/LWliXwPBKNaxE1pExqPfjoQ9BUA=@vger.kernel.org X-Gm-Message-State: APuU4Z+j2l+It/a0Ahe2fiUO6osB9X5OEey+xX6XP9ijHyzq/OjX4JQF ZW8/kIupLgui9X4tK/P9HLBOAr6KhAxjK/ADq/cUz9Jdl8eVEpKzXumw X-Gm-Gg: AZFdTZeOnQrM3YNoOAmyY/GLSUU7HzPFY2PGHJKrmomizhmAKHV3Ec0aV5QZzHnclJ4 OUiSmP9gKva+flG9I0VryL/jjSklG/CZnMPI7lFT85fjUVjozrOLZVCzyCtLT38vgCOwAOhADcR +qje9Ijj1RsfdmkRGWuAroHolszKrxZTbDdTE5S3oPtZNxSJlYICLPJiz4z2BxFa1OQc1CH+WpN jJ6fuUW2wVl3juRR62wDrhFLTevRE0gVm/AaePILpLBiBfz61bHjQLCxyyA4GXthW+grySMTkwA 5lY9TVydQkm3aayQeVXYMrPuyo4Vg7+1zlF8RuyM2rImyCcfc6qRCV7dWdmQLEPsaQBcQIYIhaV OKCWsOe1W1D47zwoShb+o9JOQWoR0JW5jwLgpEgkUyCsLgxROiW/KcvbN+WDvOpe4ReTxV2GPm5 E9El9zWkVSdsbMnTCvNt3/MRpB8jQAU+u5b/5xr9WVKHp0qfpXTWLaGfvSCS1WDBjXrGkrWozjG G9FuRKCh0ysaFmYxoT4WZmhgcwC6lUofOdJcRHPprnN97GK5MoK/pYNk9GQvF73n07jf0S49tiP tp82SS3cFMDQBTshLe5ycOtor1AZiWy7846/LJOQ961AM/72iMGuQSqpa0K5SnslkQ9aOZ+58Eh 2OcptMhx4hKHMG3pS X-Received: by 2002:a05:600c:64c9:b0:4bb:679a:86ee with SMTP id 5b1f17b1804b1-4bb88938dbemr624900955e9.29.1795997859320; Sun, 29 Nov 2026 16:17:39 -0800 (PST) Received: from Ansuel-XPS. (93-34-92-103.ip49.fastwebnet.it. [93.34.92.103]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb853ca452sm846465615e9.15.2026.11.29.16.17.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2026 16:17:38 -0800 (PST) Message-ID: <6b0cc0a2.202ed97a.2b44d3.211f@mx.google.com> X-Google-Original-Message-ID: Date: Mon, 30 Nov 2026 01:17:36 +0100 From: Christian Marangi To: Brian Masney Cc: Stephen Boyd , Brian Masney , Jerome Brunet , linux-clk@vger.kernel.org Subject: Re: [PATCH v8 2/2] clk: en7523: add support for .set_rate for en7581 References: <20261121215918.183705-1-ansuelsmth@gmail.com> <20261121215918.183705-3-ansuelsmth@gmail.com> <179599743683.206543.380687323566580404.b4-review@b4> X-Mailing-List: linux-clk@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <179599743683.206543.380687323566580404.b4-review@b4> On Sun, Nov 29, 2026 at 07:10:36PM -0500, Brian Masney wrote: > Hi Christian, > > > Add support for EN7523 driver to configure rate for Airoha EN7581 SoC. > > The SoC expose both base clock selector and clock divisor hence it's > > possible to change the rate. > > > > This will be especially needed for new SoC AN7583 that require changes > > for the MDIO and the eMMC. > > > > The clock were assumed correctly configured by the bootloader but this > > goes against the rule of "kernel should not depend on external > > configuration". > > > > To support the use of standard clock divider API, clock_div_table are added > > where needed (BUS, SPI and SLIC) in additionl to the previous info to > > derive and simulate the clock from the divisor registers. > > > > Recalc rate for Airoha EN7581 is updated to use the divider_recalc_rate API > > for consistency with .set_rate and .determine_rate. > > > > en7523_get_div() is updated to use the div table to drop redundant values. > > > > Signed-off-by: Christian Marangi > > --- > > drivers/clk/clk-en7523.c | 341 +++++++++++++++++++++++++++++++++++---- > > 1 file changed, 307 insertions(+), 34 deletions(-) > > > > diff --git a/drivers/clk/clk-en7523.c b/drivers/clk/clk-en7523.c > > index dd572333d1ac..762b77dd19d0 100644 > > --- a/drivers/clk/clk-en7523.c > > +++ b/drivers/clk/clk-en7523.c > > @@ -116,9 +116,7 @@ struct en_clk_desc { > > u16 div_reg; > > u8 div_bits; > > u8 div_shift; > > - u16 div_val0; > > - u8 div_step; > > - u8 div_offset; > > + const struct clk_div_table *div_table; > > }; > > > > struct en_clk_gate { > > @@ -161,7 +159,88 @@ struct en_clk_soc_data { > > static const u32 gsw_base[] = { 400000000, 500000000 }; > > static const u32 emi_base[] = { 333000000, 400000000 }; > > static const u32 bus_base[] = { 500000000, 540000000 }; > > +/* From documentation divisor 1 is n/a */ > > +static const struct clk_div_table bus_div[] = { > > + { .val = 1, .div = 2 }, > > + { .val = 2, .div = 3 }, > > + { .val = 3, .div = 4 }, > > + { .val = 4, .div = 5 }, > > + { .val = 5, .div = 6 }, > > + { .val = 6, .div = 7 }, > > + { .val = 7, .div = 8 }, > > Is there a case where the register can be 0? Should there be this entry > as well? > > { .val = 0, .div = 1 } > BUS is special. val 0 is invalid and rejected by the HW. This was already handled by the pre-div-api implementation. > > + { /* sentinel */ } > > +}; > > static const u32 slic_base[] = { 100000000, 3125000 }; > > +static const struct clk_div_table slic_div[] = { > > + { .val = 0, .div = 20 }, > > + { .val = 1, .div = 2 }, > > + { .val = 2, .div = 4 }, > > + { .val = 3, .div = 6 }, > > + { .val = 4, .div = 8 }, > > + { .val = 5, .div = 10 }, > > + { .val = 6, .div = 12 }, > > + { .val = 7, .div = 14 }, > > + { .val = 8, .div = 16 }, > > + { .val = 9, .div = 18 }, > > + { .val = 10, .div = 20 }, > > + { .val = 11, .div = 22 }, > > + { .val = 12, .div = 24 }, > > + { .val = 13, .div = 26 }, > > + { .val = 14, .div = 28 }, > > + { .val = 15, .div = 30 }, > > + { .val = 16, .div = 32 }, > > + { .val = 17, .div = 34 }, > > + { .val = 18, .div = 36 }, > > + { .val = 19, .div = 38 }, > > + { .val = 20, .div = 40 }, > > + { .val = 21, .div = 42 }, > > + { .val = 22, .div = 44 }, > > + { .val = 23, .div = 46 }, > > + { .val = 24, .div = 48 }, > > + { .val = 25, .div = 50 }, > > + { .val = 26, .div = 52 }, > > + { .val = 27, .div = 54 }, > > + { .val = 28, .div = 56 }, > > + { .val = 29, .div = 58 }, > > + { .val = 30, .div = 60 }, > > + { .val = 31, .div = 62 }, > > + { /* sentinel */ } > > +}; > > +static const struct clk_div_table spi_div[] = { > > + { .val = 0, .div = 40 }, > > + { .val = 1, .div = 2 }, > > + { .val = 2, .div = 4 }, > > + { .val = 3, .div = 6 }, > > + { .val = 4, .div = 8 }, > > + { .val = 5, .div = 10 }, > > + { .val = 6, .div = 12 }, > > + { .val = 7, .div = 14 }, > > + { .val = 8, .div = 16 }, > > + { .val = 9, .div = 18 }, > > + { .val = 10, .div = 20 }, > > + { .val = 11, .div = 22 }, > > + { .val = 12, .div = 24 }, > > + { .val = 13, .div = 26 }, > > + { .val = 14, .div = 28 }, > > + { .val = 15, .div = 30 }, > > + { .val = 16, .div = 32 }, > > + { .val = 17, .div = 34 }, > > + { .val = 18, .div = 36 }, > > + { .val = 19, .div = 38 }, > > + { .val = 20, .div = 40 }, > > + { .val = 21, .div = 42 }, > > + { .val = 22, .div = 44 }, > > + { .val = 23, .div = 46 }, > > + { .val = 24, .div = 48 }, > > + { .val = 25, .div = 50 }, > > + { .val = 26, .div = 52 }, > > + { .val = 27, .div = 54 }, > > + { .val = 28, .div = 56 }, > > + { .val = 29, .div = 58 }, > > + { .val = 30, .div = 60 }, > > + { .val = 31, .div = 62 }, > > + { /* sentinel */ } > > +}; > > static const u32 npu_base[] = { 333000000, 400000000, 500000000 }; > > /* EN7581 */ > > static const u32 emi7581_base[] = { 540000000, 480000000, 400000000, 300000000 }; > > @@ -185,8 +264,6 @@ static const struct en_clk_desc en7523_base_clks[] = { > > > > .div_bits = 3, > > .div_shift = 0, > > - .div_step = 1, > > - .div_offset = 1, > > }, { > > .id = EN7523_CLK_EMI, > > .name = "emi", > > @@ -199,8 +276,6 @@ static const struct en_clk_desc en7523_base_clks[] = { > > > > .div_bits = 3, > > .div_shift = 0, > > - .div_step = 1, > > - .div_offset = 1, > > }, { > > .id = EN7523_CLK_BUS, > > .name = "bus", > > @@ -213,8 +288,7 @@ static const struct en_clk_desc en7523_base_clks[] = { > > > > .div_bits = 3, > > .div_shift = 0, > > - .div_step = 1, > > - .div_offset = 1, > > + .div_table = bus_div, > > }, { > > .id = EN7523_CLK_SLIC, > > .name = "slic", > > @@ -228,8 +302,7 @@ static const struct en_clk_desc en7523_base_clks[] = { > > .div_reg = REG_SPI_CLK_DIV_SEL, > > .div_bits = 5, > > .div_shift = 24, > > - .div_val0 = 20, > > - .div_step = 2, > > + .div_table = slic_div, > > }, { > > .id = EN7523_CLK_SPI, > > .name = "spi", > > @@ -240,8 +313,7 @@ static const struct en_clk_desc en7523_base_clks[] = { > > > > .div_bits = 5, > > .div_shift = 8, > > - .div_val0 = 40, > > - .div_step = 2, > > + .div_table = spi_div, > > }, { > > .id = EN7523_CLK_NPU, > > .name = "npu", > > @@ -254,8 +326,6 @@ static const struct en_clk_desc en7523_base_clks[] = { > > > > .div_bits = 3, > > .div_shift = 0, > > - .div_step = 1, > > - .div_offset = 1, > > }, { > > .id = EN7523_CLK_CRYPTO, > > .name = "crypto", > > @@ -281,8 +351,6 @@ static const struct en_clk_desc en7581_base_clks[] = { > > > > .div_bits = 3, > > .div_shift = 0, > > - .div_step = 1, > > - .div_offset = 1, > > }, { > > .id = EN7523_CLK_EMI, > > .name = "emi", > > @@ -295,8 +363,6 @@ static const struct en_clk_desc en7581_base_clks[] = { > > > > .div_bits = 3, > > .div_shift = 0, > > - .div_step = 1, > > - .div_offset = 1, > > }, { > > .id = EN7523_CLK_BUS, > > .name = "bus", > > @@ -309,8 +375,7 @@ static const struct en_clk_desc en7581_base_clks[] = { > > > > .div_bits = 3, > > .div_shift = 0, > > - .div_step = 1, > > - .div_offset = 1, > > + .div_table = bus_div, > > }, { > > .id = EN7523_CLK_SLIC, > > .name = "slic", > > @@ -324,8 +389,7 @@ static const struct en_clk_desc en7581_base_clks[] = { > > .div_reg = REG_SPI_CLK_DIV_SEL, > > .div_bits = 5, > > .div_shift = 24, > > - .div_val0 = 20, > > - .div_step = 2, > > + .div_table = slic_div, > > }, { > > .id = EN7523_CLK_SPI, > > .name = "spi", > > @@ -336,8 +400,7 @@ static const struct en_clk_desc en7581_base_clks[] = { > > > > .div_bits = 5, > > .div_shift = 8, > > - .div_val0 = 40, > > - .div_step = 2, > > + .div_table = spi_div, > > }, { > > .id = EN7523_CLK_NPU, > > .name = "npu", > > @@ -350,8 +413,6 @@ static const struct en_clk_desc en7581_base_clks[] = { > > > > .div_bits = 3, > > .div_shift = 0, > > - .div_step = 1, > > - .div_offset = 1, > > }, { > > .id = EN7523_CLK_CRYPTO, > > .name = "crypto", > > @@ -568,16 +629,20 @@ static u32 en7523_get_base_rate(const struct en_clk_desc *desc, u32 val) > > > > static u32 en7523_get_div(const struct en_clk_desc *desc, u32 val) > > { > > - if (!desc->div_bits) > > - return 1; > > + const struct clk_div_table *clkt; > > > > val >>= desc->div_shift; > > val &= (1 << desc->div_bits) - 1; > > > > - if (!val && desc->div_val0) > > - return desc->div_val0; > > + if (desc->div_table) { > > + for (clkt = desc->div_table; clkt->div; clkt++) > > + if (clkt->val == val) > > + return clkt->div; > > > > - return (val + desc->div_offset) * desc->div_step; > > + return 0; > > + } > > + > > + return val + 1; > > } > > > > static int en7523_pci_is_enabled(struct clk_hw *hw) > > @@ -710,10 +775,18 @@ static void en7523_register_clocks(struct device *dev, struct clk_hw_onecell_dat > > const struct en_clk_desc *desc = &en7523_base_clks[i]; > > u32 reg = desc->div_reg ? desc->div_reg : desc->base_reg; > > u32 val = readl(base + desc->base_reg); > > + u32 div; > > > > rate = en7523_get_base_rate(desc, val); > > + > > val = readl(base + reg); > > - rate /= en7523_get_div(desc, val); > > + if (desc->div_bits) { > > + div = en7523_get_div(desc, val); > > + if (!div) > > + continue; > > Should there be some kind of log message here? > dbg or err? > > + > > + rate /= div; > > + } > > > > hw = clk_hw_register_fixed_rate(dev, desc->name, NULL, 0, rate); > > if (IS_ERR(hw)) { > > @@ -776,11 +849,211 @@ static unsigned long en7581_recalc_rate(struct clk_hw *hw, > > return 0; > > } > > > > - return rate / en7523_get_div(desc, val); > > + if (desc->div_bits) { > > + val >>= desc->div_shift; > > + val &= (1 << desc->div_bits) - 1; > > + > > + rate = divider_recalc_rate(hw, rate, val, desc->div_table, > > + 0, desc->div_bits); > > + } > > + > > + return rate; > > +} > > + > > +/* > > + * Simulate rate with every divisor supported > > + * 1. Search the divisor for the requested rate > > + * 2. Simulate the final rate with the new divisor > > + */ > > +static unsigned long en7581_get_div_for_rate(struct clk_hw *hw, > > + unsigned long rate, > > + unsigned long parent_rate, > > + const struct en_clk_desc *desc, > > + int *div_val) > > +{ > > + *div_val = divider_get_val(rate, parent_rate, desc->div_table, > > + desc->div_bits, 0); > > + if (*div_val < 0) > > + return 0; > > + > > + return divider_recalc_rate(hw, parent_rate, *div_val, > > + desc->div_table, 0, > > + desc->div_bits); > > +} > > + > > +static int en7581_get_vals_for_rate(struct clk_hw *hw, > > + const struct en_clk_desc *desc, > > + unsigned long rate, > > + u32 *base_val, u32 *div_val) > > +{ > > + struct device *dev = clk_hw_get_dev(hw); > > + int tmp_base_val = 0, tmp_div_val = 0; > > + unsigned long parent_rate, tmp_rate; > > + > > + if (!rate || (!desc->base_bits && !desc->div_bits)) > > + return -EINVAL; > > + > > + if (!desc->base_bits) { > > + parent_rate = desc->base_value; > > + > > + tmp_rate = en7581_get_div_for_rate(hw, rate, parent_rate, > > + desc, &tmp_div_val); > > + > > + /* Matching clock found */ > > + if (tmp_rate == rate) > > + goto exit; > > + } > > + > > + /* Search requested rate with every matching base rate + divisor */ > > + for (; tmp_base_val < desc->n_base_values; tmp_base_val++) { > > + parent_rate = desc->base_values[tmp_base_val]; > > + tmp_rate = parent_rate; > > + > > + if (desc->div_bits) > > + tmp_rate = en7581_get_div_for_rate(hw, rate, parent_rate, > > + desc, &tmp_div_val); > > + > > + /* Matching clock found */ > > + if (tmp_rate == rate) > > + break; > > + } > > + > > + /* Impossible, should be validated by determine rate */ > > + if (tmp_base_val >= desc->n_base_values) { > > + dev_err(dev, "Invalid rate for clock %s\n", > > + desc->name); > > dev_err() shouldn't be in the hot path of set_rate(). Make this a > dev_dbg() as well. > > > + return -EINVAL; > > + } > > + > > +exit: > > + *base_val = tmp_base_val; > > + *div_val = tmp_div_val; > > + > > + return 0; > > +} > > + > > +static void en7581_update_best_rate(struct clk_rate_request *req, > > + unsigned long requested_rate, > > + unsigned long tmp_rate, > > + unsigned long *best_diff) > > +{ > > + unsigned long diff; > > + > > + if (!tmp_rate || tmp_rate < req->min_rate || > > + tmp_rate > req->max_rate) > > + return; > > + > > + diff = abs_diff(requested_rate, tmp_rate); > > + if (diff < *best_diff) { > > + *best_diff = diff; > > + req->rate = tmp_rate; > > + } > > +} > > + > > +static void en7581_find_best_rate(struct clk_hw *hw, > > + struct clk_rate_request *req, > > + const struct en_clk_desc *desc, > > + unsigned long parent_rate, > > + unsigned long requested_rate, > > + unsigned long *best_diff) > > +{ > > + struct clk_rate_request div_req = *req; > > + int ret; > > + > > + if (!desc->div_bits) { > > + en7581_update_best_rate(req, requested_rate, parent_rate, > > + best_diff); > > + return; > > + } > > + > > + /* Treat each internal base rate as a fixed parent for the divider. */ > > + div_req.rate = clamp(requested_rate, req->min_rate, req->max_rate); > > + div_req.rate = min(div_req.rate, parent_rate); > > The min() here shouldn't be needed. When rate >= parent_rate, the > smallest table divider is returned. > > Also just a heads up that I posted a guidelines file for the Common Clk > Subsystem to the review prompts repo. It's not merged as of this > writing, but Sashiko will start using this once it's merged. You can > download the clk.md file and point your favorite $AI_AGENT at this > review file before posting your next version. > > https://github.com/masoncl/review-prompts/pull/123 > This was something that sashiko pointed out... the min is needed to prevent a div by zero. The previous revision pointed out this. Since you requested these changes, I should merge these changes with the 7583 series correct? -- Ansuel