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: 10654271 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 C956614BB for ; Wed, 24 Oct 2018 07:24:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AFF9E29B5B for ; Wed, 24 Oct 2018 07:24:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A0D8A2A658; Wed, 24 Oct 2018 07:24:50 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5C62329B5B for ; Wed, 24 Oct 2018 07:24:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C08166E290; Wed, 24 Oct 2018 07:21:49 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by gabe.freedesktop.org (Postfix) with ESMTPS id 318326E1DF for ; Tue, 23 Oct 2018 15:51:15 +0000 (UTC) Received: by mail-pg1-x542.google.com with SMTP id z2-v6so869656pgp.0 for ; Tue, 23 Oct 2018 08:51:15 -0700 (PDT) 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=Bw7pEO+6HEyMmsALLnzxKalniugoy6akjsdsqt1Jl60AQeoyJ9fQQyYVPzoCJLQPGg MNlHk6aEH9PNDeGADK1dEHHNqGQ78jxonXlNFWAoEkOMbO+Y9HsGFNr19WIhMsaSFTNN 231v0JSxOvH+A1eXzZq5A38LMxE3R0t4gWGj1gQiVLiO9MNnn1DFvtCsz4RD3a8w5KuB 5R7oR1UD49rTVh3jDszBozvAL5dI0LFZeguYrDeFkQLOznfhPfbOVtmXoW0khjt9atlK O6sYT9dWI02ZUTLIYwILN3SgGzqBuwVEDFTUK1sV1x2SDZd3L0ofKYjpF4b2EJQxjRlR 7ECA== X-Gm-Message-State: ABuFfoj6qs7kQaKACyYG0g3OHsAcb9ffB5t4LtSsvPl7h8WE3ePfAXkm VXc5wzjqhHuizPWUV3MFuP5rQA== 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-Mailman-Approved-At: Wed, 24 Oct 2018 07:21:17 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jagan Teki Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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; };