Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1909185pxv; Fri, 2 Jul 2021 15:52:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwoiOf47Y93gXB+imvG4Nb7hwuDXbNUfPYFwz5oJqNGQnTe4AemU3fXvlsqpDxNr1/Be1nz X-Received: by 2002:a05:6e02:ef4:: with SMTP id j20mr1482963ilk.141.1625266370989; Fri, 02 Jul 2021 15:52:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625266370; cv=none; d=google.com; s=arc-20160816; b=X9XlpBBEymimMa7G2cfTrebssIOBJZXwCRUibIH/9b4pGRLX2WXvba8Pl5Gaj10hXq Ox1FtC1P8YXw1AkhIx66x7AloGjHLRGkLTbHQnlWjLxoLEeWgpFwgDgXijZ2BQihPm7O aGitYCKbbl2s6XNeooo0x9x0yKmSsM5B6lkKD5YKKNdPCEnefePewhxOuB62T8zqTBks qJ20Z7Nq7lxH+qRS+k0VtSi/XgeQZ3sjn7cjY8wE9+TVBVmLkeFulld6VrFMIi4wGmAV qpFP2B/hRoW6/Olt8sXzXxSX+AJPpGDFgFNsm5xxEQ/xWjGuItz9gU8i98ZuSaA7EztT KeWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=faNXvR3tx7KD+s7khCjZtAZqhs7ILrjagiLN5169MA8=; b=FU5MaP+W5wvXTYmRsG5r+y0+9DFE0GQjX+pUZ/LQ66ChPqhCMO4YcVRfgoiwx1+ew7 JnW96uBgPnVwL9fH+Wt2aXnifMBWP7xCgHmNE20gFMyBGhhiMi9CHj5/LsiyBwygEAqJ otwSQzgSGMHxsLW9NLbGpTFvymGR5qMJfiO7WcaKqsatR5CUvK9PCIcuDR08FWln722I DXh0TLTdrbnV8+2L/TKn81qB15J/JjIuSBmP119YEKTR8OouGT1hhuOs/K3OieMxhRYJ iHYw/HcP7R2K2k9lzMh3vR7ajffsBnBdfH7PWJrde/oRVpUmweBmcEEXbpfA6qX21r6M e00Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@googlemail.com header.s=20161025 header.b=uDJCglXn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=googlemail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r10si4744888ill.10.2021.07.02.15.52.39; Fri, 02 Jul 2021 15:52:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@googlemail.com header.s=20161025 header.b=uDJCglXn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=googlemail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231209AbhGBWyj (ORCPT + 99 others); Fri, 2 Jul 2021 18:54:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230104AbhGBWyf (ORCPT ); Fri, 2 Jul 2021 18:54:35 -0400 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49D8BC061762; Fri, 2 Jul 2021 15:52:01 -0700 (PDT) Received: by mail-ej1-x633.google.com with SMTP id gb6so1999285ejc.5; Fri, 02 Jul 2021 15:52:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=faNXvR3tx7KD+s7khCjZtAZqhs7ILrjagiLN5169MA8=; b=uDJCglXnuDw53LtC8KWzaQ83KG071Y8VkDrMy1Qy8tMYbffgHLiXZlmUUZiHIjtVp5 lhn3l6NJ5byXjBsyDlDbAuI6kJ99htHY2t7BF1zuYFY49bB7Ih0QlmnW733yBf1iI7rN 6WLwaQpzQSCpzu2H6wvomIFX3H0tXGoVtg+uZTBp/eLZzoptXVHvNoCTBnVEkhwmNt5n C/U3MkgYhBAPlaRHQKREloxHzwBfesjDtFU6BWg8K+y1VelqryEDpazd0vv6JFtySK7X IstacKz3/ejDkdTBalE5rANV3daRc5ASPPqmzonGubj8CLKcMVSu2p5H9iZ6W7tp8nOJ lkTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=faNXvR3tx7KD+s7khCjZtAZqhs7ILrjagiLN5169MA8=; b=Ex+NENxMMKwPut7Shh8O8xHcYHdy3dvV+dD3uJPbiUhUyJ1M5FnqaEbQZQCGBTDvVc pF/MMRwVdd2+23ehRRYFDGZCsqVEYMNBalXNIePINIoYavWe5VBaS+XfoHxeyMfqadPz KCFWStEaGLvza6Qy++ZKNi1fZrIejwZQh4U9kVOgQ7thU9M3+xGRLdrCeM6NEGlCQ/uK 3/BpylYIEOAC/zkjg5Shf6i1h8rA5xSvgnTaHZD1dHBPMgpYcvv3ylVWmVhjmNDfq4SE i2cWTArGEH6XdHUKNphiJe4YbaKDEAAYrjTV+WJFviYGHYp606fOoTljnBFdXKl3Mm5e /0Yg== X-Gm-Message-State: AOAM5331PPKTtslYJajcJUTSbFmgnGnAxmrYNfJbeQAcgMQrpuNp54Cq YZ4osIR0u4j9NzsRaUUetvYdEx4Zly8= X-Received: by 2002:a17:907:60d6:: with SMTP id hv22mr2030745ejc.78.1625266319554; Fri, 02 Jul 2021 15:51:59 -0700 (PDT) Received: from localhost.localdomain (dynamic-095-117-063-046.95.117.pool.telefonica.de. [95.117.63.46]) by smtp.googlemail.com with ESMTPSA id r17sm1866964edt.33.2021.07.02.15.51.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jul 2021 15:51:59 -0700 (PDT) From: Martin Blumenstingl To: linux-clk@vger.kernel.org, sboyd@kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Martin Blumenstingl Subject: [PATCH v1 1/6] clk: divider: Implement and wire up .determine_rate by default Date: Sat, 3 Jul 2021 00:51:40 +0200 Message-Id: <20210702225145.2643303-2-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210702225145.2643303-1-martin.blumenstingl@googlemail.com> References: <20210702225145.2643303-1-martin.blumenstingl@googlemail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org .determine_rate is meant to replace .round_rate. The former comes with a benefit which is especially relevant on 32-bit systems: since .determine_rate uses an "unsigned long" (compared to a "signed long" which is used by .round_rate) the maximum value on 32-bit systems increases from 2^31 (or approx. 2.14GHz) to 2^32 (or approx. 4.29GHz). Implement .determine_rate in addition to .round_rate so drivers that are using clk_divider_{ro_,}ops can benefit from this by default. Keep the .round_rate callback for now since some drivers rely on clk_divider_ops.round_rate being implemented. Signed-off-by: Martin Blumenstingl --- drivers/clk/clk-divider.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c index 87ba4966b0e8..f6b2bf558486 100644 --- a/drivers/clk/clk-divider.c +++ b/drivers/clk/clk-divider.c @@ -446,6 +446,27 @@ static long clk_divider_round_rate(struct clk_hw *hw, unsigned long rate, divider->width, divider->flags); } +static int clk_divider_determine_rate(struct clk_hw *hw, + struct clk_rate_request *req) +{ + struct clk_divider *divider = to_clk_divider(hw); + + /* if read only, just return current value */ + if (divider->flags & CLK_DIVIDER_READ_ONLY) { + u32 val; + + val = clk_div_readl(divider) >> divider->shift; + val &= clk_div_mask(divider->width); + + return divider_ro_determine_rate(hw, req, divider->table, + divider->width, + divider->flags, val); + } + + return divider_determine_rate(hw, req, divider->table, divider->width, + divider->flags); +} + int divider_get_val(unsigned long rate, unsigned long parent_rate, const struct clk_div_table *table, u8 width, unsigned long flags) @@ -501,6 +522,7 @@ static int clk_divider_set_rate(struct clk_hw *hw, unsigned long rate, const struct clk_ops clk_divider_ops = { .recalc_rate = clk_divider_recalc_rate, .round_rate = clk_divider_round_rate, + .determine_rate = clk_divider_determine_rate, .set_rate = clk_divider_set_rate, }; EXPORT_SYMBOL_GPL(clk_divider_ops); @@ -508,6 +530,7 @@ EXPORT_SYMBOL_GPL(clk_divider_ops); const struct clk_ops clk_divider_ro_ops = { .recalc_rate = clk_divider_recalc_rate, .round_rate = clk_divider_round_rate, + .determine_rate = clk_divider_determine_rate, }; EXPORT_SYMBOL_GPL(clk_divider_ro_ops); -- 2.32.0