From patchwork Fri Jul 2 22:51:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 12356761 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EECEFC07E96 for ; Fri, 2 Jul 2021 22:54:23 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A78F5613B6 for ; Fri, 2 Jul 2021 22:54:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A78F5613B6 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=googlemail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Sffy+8pWT9hQFiDtZlmN9aBpoM+gi6aKqFzawSZWxSA=; b=mqvTEhLtFJ0SEQ Kar9saUGUIoesVpD/0yjoO9mYnaFcezpsiim2xiL/3IGO1mgp1Px0e/ARHlFEN6qS2RcFydxcU32u Gm0Dn723d1qlzQfMmdLC8AFXdvqF3WX3aYJsorwhryZxMqxfQn0iuuKv7LH7n47z4LtAWH/w3iC67 eLNGXXb2px5NJxOmZNrQ15DMGfh3t3ti2lZU7pzlcm5xZsjNcciXfubfeDTLG7McLm0GUTdL2PBLk YXW9Yfxf8W4drVacsqM49KrKlaacVQcCekYqYL6uvXciD90WujnuKMV313MCE1gpEiwfVEnHMRR7Z MR7WhtCGHje02CG/HWCQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lzS17-004C2d-WB; Fri, 02 Jul 2021 22:52:14 +0000 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lzS0u-004Bz4-VR for linux-arm-kernel@lists.infradead.org; Fri, 02 Jul 2021 22:52:02 +0000 Received: by mail-ej1-x62b.google.com with SMTP id bg14so18604217ejb.9 for ; Fri, 02 Jul 2021 15:52:00 -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=HRumRN+oHdFjvLIRdcVzwfTrA5nmsRmInxPnAaaB7X2j/LQ2967HYdl/4XRPQftLtv uhK7Vb+IhctpmFO2OrnNxazEaujd6E84Q5iQ11v/vawgY0lxVoGQ+AzRzIIoV+Sdu63l 8AKpamdQHOloOVezZdChDPkHKjR5qBzFvFXXGhbEDtInHrMrW2MrYaNJd07gkF17brhA RT5opzYAAnatkHR4JCsnBqNvA5EOg5v3oWPpBCvbIoAiQ8TqhAWaqUDEkH4Riq02ZhZ8 g0rZioxk9gtFFdHD0jwwmDrWMbFNoHx9sF4tU5uUmeqrnGXZRtxlaUsYxptitKGTEezh gAbg== X-Gm-Message-State: AOAM530QZgrx/qG2HQAL+HLQ3L8NuadlJsAbKRHpXLfQRSgI6y7pzovM 7odZF8iClN3DQAXJR69HDAI= X-Google-Smtp-Source: ABdhPJwtzWyis2mfuY/taJOWeS/vOPZB1y7JjZJkpRVbpg/Yfy0fom9pRY11N/LQRFPXjnDFZK9t2Q== 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210702_155201_051757_DCB52FFE X-CRM114-Status: GOOD ( 16.60 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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);