From patchwork Tue Oct 23 15:50:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 10653311 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 02C5313B5 for ; Tue, 23 Oct 2018 15:53:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E0665287F3 for ; Tue, 23 Oct 2018 15:53:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D41492890C; Tue, 23 Oct 2018 15:53:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 64C22287F3 for ; Tue, 23 Oct 2018 15:53:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=JpmF2pc3EBX/VUkZEzRe4/NZaTVIL9CcvYOFE3t4uJE=; b=i+Fk5WWYZMEgT6 3SryWNZOlhfgQzQmA/OZUgTY8ns+59DvAS2jewEa3VKEEVjl3YqkaRrDASLShkzECHKjtImzYlYUX HCeyvzbMr4QCkXKIpl1gZNftNCgaTaHBTnTGAsXsivma/+kXa4YwIH1ZAA08vPncyZtbhkWDx73/y hgODhYVkAd4kNQlzPCxYBZ+dSy1zfVwv7b/ohtywCjKmHcoSdCUkprm+rA1K6Vqa7I+FzcT6cz6Xq tv3N9zREecULf3grkK9+EkBGZUlxIxsplUy+IR3657x4JaCs4p4RVPd0G0ItgYF6kQNzRsWpQ7WO5 mSvKvj62kt8gyjnCDD5A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gEyzi-0005Fd-Ow; Tue, 23 Oct 2018 15:53:22 +0000 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gEyxp-0004Gr-M1 for linux-arm-kernel@lists.infradead.org; Tue, 23 Oct 2018 15:51:37 +0000 Received: by mail-pf1-x443.google.com with SMTP id g21-v6so883051pfi.7 for ; Tue, 23 Oct 2018 08:51:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=o90/LNGE9upjKhzjm4op/FMEilKM/vCgfq8hDXmKf64=; b=Imiflp8pAB0VUbU3b//nP/qfOOs9pPcI2UxiPmJMGI1ZPfR+nxptAquSUYIsT5doA5 4S2HXsqpScsl1Nq3AbDgfUvQz63mZoRIVxzfYb6qUzBINDm3vF8tETPxifYLyoGPGgqT abK0Zl2QvfHgYu7TeNXCXPBliH4IGtcEV+7t0= 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=o90/LNGE9upjKhzjm4op/FMEilKM/vCgfq8hDXmKf64=; b=VqvOUnvveVuLpSTYgiQtJjZ6tdnSvrxx+f1/5hQZuU5FKzvY+AD7gKkgVTuWGqkr6P 8PpCbh7shSvndLGTMXkKVjby/zFxEV0QytxVFjjk/+45OyvlOzTEOMXCg1rEQcoemGCz JwzLIbfOJznXnPQdf/c75Imxkvj1WxYyvf87ryBFeDHLR9zpchSAQBHWnseDiTIRoMaw 80RU84z5CTZ6EkE2Gcikx/1DA7DU5d5YhoIeADr/iqsquro0uRsICrvtQ7fDE8eZXZhg xiDGpWxs9ztCBp1uoxe6fhrGMNEbIaIJq5ggdl/rpd2NmfCrktvZnULT/mstsjeejIGw wXiA== X-Gm-Message-State: ABuFfoilI/GkWiWhlvYioc85D/J5GTcUNyAEhQZLFtcO4FBE1Jbuu4BR KjKdLgpr/7kN0z06rQ8FeBlbbA== X-Google-Smtp-Source: ACcGV618MFfAxH9ZOLOgjXtx3sU4kllTNV131HDzCFD6/jCITjF+8GvPpW//NyAt/wn5FCe4GTtMBw== X-Received: by 2002:a62:d085:: with SMTP id p127-v6mr24323446pfg.202.1540309874761; Tue, 23 Oct 2018 08:51:14 -0700 (PDT) Received: from localhost.localdomain ([27.7.51.1]) by smtp.gmail.com with ESMTPSA id o75-v6sm7442829pfg.0.2018.10.23.08.51.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Oct 2018 08:51:14 -0700 (PDT) From: Jagan Teki To: Maxime Ripard , Chen-Yu Tsai , Icenowy Zheng , Jernej Skrabec , Vasily Khoruzhick , Rob Herring , Mark Rutland , Catalin Marinas , Will Deacon , David Airlie , dri-devel@lists.freedesktop.org, Michael Turquette , Stephen Boyd , linux-clk@vger.kernel.org, Michael Trimarchi , linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com Subject: [PATCH v2 03/15] clk: sunxi-ng: Add check for maximum rate to NKM PLLs Date: Tue, 23 Oct 2018 21:20:23 +0530 Message-Id: <20181023155035.9101-4-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20181023155035.9101-1-jagan@amarulasolutions.com> References: <20181023155035.9101-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181023_085125_801178_27DCC922 X-CRM114-Status: GOOD ( 15.48 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jagan Teki Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Some NKM PLLs, frequency can be set above PLL working range. Add a constraint for maximum supported rate. This way, drivers can specify which is maximum allowed rate for PLL. Signed-off-by: Jagan Teki Acked-by: Stephen Boyd --- Changes for v2: - new patch drivers/clk/sunxi-ng/ccu_nkm.c | 7 +++++++ drivers/clk/sunxi-ng/ccu_nkm.h | 1 + 2 files changed, 8 insertions(+) diff --git a/drivers/clk/sunxi-ng/ccu_nkm.c b/drivers/clk/sunxi-ng/ccu_nkm.c index d17539dc88dd..574fd2cd2a79 100644 --- a/drivers/clk/sunxi-ng/ccu_nkm.c +++ b/drivers/clk/sunxi-ng/ccu_nkm.c @@ -132,6 +132,13 @@ static unsigned long ccu_nkm_round_rate(struct ccu_mux_internal *mux, return rate; } + if (nkm->max_rate && rate > nkm->max_rate) { + rate = nkm->max_rate; + if (nkm->common.features & CCU_FEATURE_FIXED_POSTDIV) + rate /= nkm->fixed_post_div; + return rate; + } + ccu_nkm_find_best(*parent_rate, rate, &_nkm); rate = *parent_rate * _nkm.n * _nkm.k / _nkm.m; diff --git a/drivers/clk/sunxi-ng/ccu_nkm.h b/drivers/clk/sunxi-ng/ccu_nkm.h index ff5bd00f429f..c82590481188 100644 --- a/drivers/clk/sunxi-ng/ccu_nkm.h +++ b/drivers/clk/sunxi-ng/ccu_nkm.h @@ -36,6 +36,7 @@ struct ccu_nkm { unsigned int fixed_post_div; unsigned int min_rate; + unsigned int max_rate; struct ccu_common common; };