Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp2018452rwb; Sun, 6 Aug 2023 08:04:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IExGNl295ir/e/lUWDRau/p4BqK4jwWD8V/B01dUvKpaRk0GnfclLWpDU/3gRrh/QUfM2cE X-Received: by 2002:a17:902:e5cb:b0:1bb:5b88:73da with SMTP id u11-20020a170902e5cb00b001bb5b8873damr6552575plf.61.1691334240170; Sun, 06 Aug 2023 08:04:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691334240; cv=none; d=google.com; s=arc-20160816; b=nPpsuxyOc87SDk7wSkrHEERFJzIYqu3cc4RvTh5nanYmBw9sz7rGtL9CxR8tbdwg8r kd03ikcIFVTZkgpUeaVbvAgu6qJRpGL0cY8NxLBuZGkK2cTy9/H3v6JgtKLTBxTg/DDL eNxf9VawwD1FbTSm08pm5sdZRLdRU3Vg7Uj6mfE1PL9aOg9KHPl4gTKMrYR8IYcZUHei pMFxhMzS8EBuRNz0cq9CKFHm9/8TKSQ60vwrNAOXokPiKgAgh2rSfiv9X7AN58045xM2 tBinggoYpGVovv94/f0xfh5Q26V1MS4ZZoeJDtaSQsKuPTNNL1mdpBak06GJipsvJhVG mqpg== 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=w3hZ38/+Ms3F1EqmzJCLkF+L8JHXcF7YJ7LY4cDwFEg=; fh=bO+B/XDIbJg/wyQv6Z9aSqnL/VU+wJ8UKqRO5hXOiwY=; b=c6fBZeEu9wSsNl85nNGI9fKJz6fV/sC4RCEsDt8P2AvGaq1k7Hg/Vx1W8n01p4nrKB EL4Q+aXSC6bB2kZPSIX9WH0xYAd70fV+kzYqBdZ76dctaGc3yD54sPpQh3M9/7MEdtW2 xHrD55JxwYVCnlGjotD22/dkrDQcIOXoepHpM0/387IgC40TOuUkGGRYWDGr74SGewM/ pPePOw7KkAkd36QFUs7mh7XhTqndLO5gGwWLsWO4CexTSajMxunOzIL5F6SKEC7fFr6L z/dXXnWKjR2u/mHr2vHaXQHobV/pr+eq97L1WzfY7BMN5drJEAJ02uZOKxU60nuXbVpr LOoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=SPzBm1Yd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id km16-20020a17090327d000b001b87b17cfb4si4462090plb.392.2023.08.06.08.03.45; Sun, 06 Aug 2023 08:04:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=SPzBm1Yd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229491AbjHFNmk (ORCPT + 99 others); Sun, 6 Aug 2023 09:42:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230298AbjHFNme (ORCPT ); Sun, 6 Aug 2023 09:42:34 -0400 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35D85CF; Sun, 6 Aug 2023 06:42:28 -0700 (PDT) Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-99c1c66876aso506639366b.2; Sun, 06 Aug 2023 06:42:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691329347; x=1691934147; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=w3hZ38/+Ms3F1EqmzJCLkF+L8JHXcF7YJ7LY4cDwFEg=; b=SPzBm1YdBbtvTEIV1JOBdfR6CA0fgKzXZBB3wpp0DTUZhu9WgsbenYO9PqwDRLMJ+r jUk0+YHw+cvFBmxegiMNcXHMYOF0LhZdlj6PZMaO4b+GigEkBr/CTDrEdhkFkMIXspFH Ip1Loq5vDqKtT3Ze61BeOgsI1D43+YqY24LuqlLCs8Ovyp6p0DUE82gIDFRkDVCQyKaD PXV33GqvZvHkcbEzFA76iGfYKNP5/0TrzUXLyH9s1B2LkUdwYsenlOCyMqsdTg1C/3eS 50Dwcfc8SbUpIPHleSHvIrasQoEzn/daEwOdElNh7dh8eAFugS7Z0Vrb1uve3j4xwfvA kGJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691329347; x=1691934147; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=w3hZ38/+Ms3F1EqmzJCLkF+L8JHXcF7YJ7LY4cDwFEg=; b=RxHNMxJmah+l1jMVg9sZQIcRdMHmwXlcIQ7Kj3L51vAx8Q4ii6ippi0h1p/L8IZ6sh Io2UsEqAGhouBPqlPjBdLqHP2ATgrtyQbD/4h0K4ZaUkviyu2Ld70xcjMEDpU+rwY6KJ xTG0b3iMWpYZQqNetO4WIUyW2k3ipZ+BklRbb5xie2uUShcY3j4cqea5DL1Ol8bgRP4j MV0uLUymYv3D5Gl3IwG46EPgZrHy1NCmk+vF1PBnAqnVqxBpmkHwSgEPWT4TPs2vV9J5 w5BpVwDTzu3iU1/cpX0CKl5bU9PJ4UufkHFJV30/H54oFPF/Rd4RHHaMEBpGHGiSMoPV dOAQ== X-Gm-Message-State: AOJu0YxEQ/zQodElquGbZS/t/mLCyAJDAx43WWpQBXhu2opdlNKw40LC D5Siz20axnuaapNSp6y8iBQ= X-Received: by 2002:a17:906:9bdb:b0:987:5761:2868 with SMTP id de27-20020a1709069bdb00b0098757612868mr5498868ejc.11.1691329346257; Sun, 06 Aug 2023 06:42:26 -0700 (PDT) Received: from jernej-laptop.localnet (82-149-1-233.dynamic.telemach.net. [82.149.1.233]) by smtp.gmail.com with ESMTPSA id oz13-20020a170906cd0d00b00992b71d8f19sm1357934ejb.133.2023.08.06.06.42.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Aug 2023 06:42:25 -0700 (PDT) From: Jernej =?utf-8?B?xaBrcmFiZWM=?= To: Maxime Ripard , Michael Turquette , Stephen Boyd , Chen-Yu Tsai , Samuel Holland , Andre Przywara , Roman Beranek , Frank Oltmanns Cc: linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Frank Oltmanns Subject: Re: [PATCH v5 08/11] clk: sunxi-ng: mux: Support finding closest rate Date: Sun, 06 Aug 2023 15:42:24 +0200 Message-ID: <4283806.ejJDZkT8p0@jernej-laptop> In-Reply-To: <20230806-pll-mipi_set_rate_parent-v5-8-db4f5ca33fc3@oltmanns.dev> References: <20230806-pll-mipi_set_rate_parent-v5-0-db4f5ca33fc3@oltmanns.dev> <20230806-pll-mipi_set_rate_parent-v5-8-db4f5ca33fc3@oltmanns.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Dne nedelja, 06. avgust 2023 ob 15:06:53 CEST je Frank Oltmanns napisal(a): > When finding the best rate for a mux clock, consider rates that are > higher than the requested rate when CCU_FEATURE_ROUND_CLOSEST is used. > Furthermore, introduce an initialization macro that sets this flag. > > Acked-by: Maxime Ripard > Signed-off-by: Frank Oltmanns Reviewed-by: Jernej Skrabec Best regards, Jernej > --- > drivers/clk/sunxi-ng/ccu_mux.c | 13 ++++++++++++- > drivers/clk/sunxi-ng/ccu_mux.h | 38 +++++++++++++++++++++++++++----------- > 2 files changed, 39 insertions(+), 12 deletions(-) > > diff --git a/drivers/clk/sunxi-ng/ccu_mux.c b/drivers/clk/sunxi-ng/ccu_mux.c > index 3ca695439620..5edc63b46651 100644 > --- a/drivers/clk/sunxi-ng/ccu_mux.c > +++ b/drivers/clk/sunxi-ng/ccu_mux.c > @@ -242,6 +242,17 @@ static int ccu_mux_set_parent(struct clk_hw *hw, u8 > index) return ccu_mux_helper_set_parent(&cm->common, &cm->mux, index); > } > > +static int ccu_mux_determine_rate(struct clk_hw *hw, > + struct clk_rate_request *req) > +{ > + struct ccu_mux *cm = hw_to_ccu_mux(hw); > + > + if (cm->common.features & CCU_FEATURE_CLOSEST_RATE) > + return clk_mux_determine_rate_flags(hw, req, CLK_MUX_ROUND_CLOSEST); > + > + return clk_mux_determine_rate_flags(hw, req, 0); > +} > + > static unsigned long ccu_mux_recalc_rate(struct clk_hw *hw, > unsigned long parent_rate) > { > @@ -259,7 +270,7 @@ const struct clk_ops ccu_mux_ops = { > .get_parent = ccu_mux_get_parent, > .set_parent = ccu_mux_set_parent, > > - .determine_rate = __clk_mux_determine_rate, > + .determine_rate = ccu_mux_determine_rate, > .recalc_rate = ccu_mux_recalc_rate, > }; > EXPORT_SYMBOL_NS_GPL(ccu_mux_ops, SUNXI_CCU); > diff --git a/drivers/clk/sunxi-ng/ccu_mux.h b/drivers/clk/sunxi-ng/ccu_mux.h > index 2c1811a445b0..eb1172ebbd94 100644 > --- a/drivers/clk/sunxi-ng/ccu_mux.h > +++ b/drivers/clk/sunxi-ng/ccu_mux.h > @@ -46,20 +46,36 @@ struct ccu_mux { > struct ccu_common common; > }; > > +#define SUNXI_CCU_MUX_TABLE_WITH_GATE_FEAT(_struct, _name, _parents, > _table, \ + _reg, _shift, _width, _gate, \ > + _flags, _features) \ > + struct ccu_mux _struct = { \ > + .enable = _gate, \ > + .mux = _SUNXI_CCU_MUX_TABLE(_shift, _width, _table), \ > + .common = { \ > + .reg = _reg, \ > + .hw.init = CLK_HW_INIT_PARENTS(_name, \ > + _parents, \ > + &ccu_mux_ops, \ > + _flags), \ > + .features = _features, \ > + } \ > + } > + > +#define SUNXI_CCU_MUX_TABLE_WITH_GATE_CLOSEST(_struct, _name, _parents, \ > + _table, _reg, _shift, \ > + _width, _gate, _flags) \ > + SUNXI_CCU_MUX_TABLE_WITH_GATE_FEAT(_struct, _name, _parents, \ > + _table, _reg, _shift, \ > + _width, _gate, _flags, \ > + CCU_FEATURE_CLOSEST_RATE) > + > #define SUNXI_CCU_MUX_TABLE_WITH_GATE(_struct, _name, _parents, _table, \ > _reg, _shift, _width, _gate, \ > _flags) \ > - struct ccu_mux _struct = { \ > - .enable = _gate, \ > - .mux = _SUNXI_CCU_MUX_TABLE(_shift, _width, _table), \ > - .common = { \ > - .reg = _reg, \ > - .hw.init = CLK_HW_INIT_PARENTS(_name, \ > - _parents, \ > - &ccu_mux_ops, \ > - _flags), \ > - } \ > - } > + SUNXI_CCU_MUX_TABLE_WITH_GATE_FEAT(_struct, _name, _parents, \ > + _table, _reg, _shift, \ > + _width, _gate, _flags, 0) > > #define SUNXI_CCU_MUX_WITH_GATE(_struct, _name, _parents, _reg, \ > _shift, _width, _gate, _flags) \