From patchwork Fri Oct 26 14:43:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 10657517 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 F24E314BD for ; Fri, 26 Oct 2018 14:46:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E9AD12AB4E for ; Fri, 26 Oct 2018 14:46:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DD5192B1D8; Fri, 26 Oct 2018 14:46: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=-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 230062AB4E for ; Fri, 26 Oct 2018 14:46:49 +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=OE8Jt5Lltr8LfqILTk3YvMDCZqq9lyhc7EGHxgA0S5k=; b=JZBOuzPw5WnBrH RVRqw1D0YuguXYJU6ayCRM4e9bEWKFHTifbccq2W1q4CVKzkbLzIZXQzBP1maz//ZyXaoW/tFkYx1 0TvuIwI58LbUlGqauq77MKydSK+yp/QYh8ZnGfT2yyQV6s8p/aY2c1oRX8wCdWnW89I7lGGMlEzvF Ku/y36k5K05BNCw49nGmvJc19PZUDnL2GoPAJSugFB2ICdhN/iDsCTGfm4CCzH86c17j98somi1P4 yQ03ITakdtH9mSbnILNQAxObwIlhkogSCT7BrHIrRjbBon426Rk3r7H/PlkQZH0wRtDQ85OeO2ntg ihOIpRo9Rtii+NFejO9w==; 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 1gG3Nk-00030f-Uh; Fri, 26 Oct 2018 14:46:37 +0000 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gG3Ls-0000qo-DG for linux-arm-kernel@lists.infradead.org; Fri, 26 Oct 2018 14:44:52 +0000 Received: by mail-pf1-x442.google.com with SMTP id l17-v6so677807pff.2 for ; Fri, 26 Oct 2018 07:44:30 -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=LCfUU8SpHfEmAPHXqEtW+VtRBKPuExRqicCDj8q29y4=; b=nGIIzA9sUH3xhRTgytGk06e1T3qPtjrDwlKet6b3HqKEojx405qjqESehx1x4TqgHP G9gA3JalkS1tteEFAerR3AtMoRInyOlLRy1cPYF/iQINgLIYVRBOd/fYsUdt9yEqUFAY YgrxT1V8RmNHl8eu4ioOgMJz7EiMkyWdkFXJM= 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=LCfUU8SpHfEmAPHXqEtW+VtRBKPuExRqicCDj8q29y4=; b=R4TP/7X+9KjNhQt3mn1YbwPJ+DptQONehevfihggrtqx3jmjYlZej1O6vDO1eRCIb2 B7gp8M7YwIghtUEw9FXpzP2pdslkBZNai5qAkFk57uGLLxQShe0In3WuIlS2oeEF4oB/ BXS02A7jnObJBcqJyOX5a5sf9ZjqX0IrSkbFiNi5RSrb6IwH7o66ajr73SGXoNljtdRj qhIBBPkEcdSGI2s8NDPJvgVijPBroWZdxaMaZ6700dtGWB+Jl6PKbcZ0v0syyJ1crXT2 hCOhKb77csCYfiMpsq8K0reRCrSp+RbEGCaLHf3irHh1460jbald8os6Bt7OKSAeE5pq Rpvw== X-Gm-Message-State: AGRZ1gKmuxo5iRgs/hEvBqz1G5TmepKvTd0VaDXEy0LDrBMb2dbG6elP NGp9eGPWbzA1xd4rwpPwKL/vow== X-Google-Smtp-Source: AJdET5dCkTKMuBJG5eIyIgbSBBwJuaDl+Rpv9ClSqBLosTZXn8tzu1DRJ9schG34dsVFgG3vek45Iw== X-Received: by 2002:a63:ce56:: with SMTP id r22-v6mr3698001pgi.217.1540565069444; Fri, 26 Oct 2018 07:44:29 -0700 (PDT) Received: from localhost.localdomain ([27.7.51.1]) by smtp.gmail.com with ESMTPSA id z22-v6sm12044467pgv.24.2018.10.26.07.44.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Oct 2018 07:44:28 -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 v3 03/25] clk: sunxi-ng: Add check for maximum rate to NKM PLLs Date: Fri, 26 Oct 2018 20:13:22 +0530 Message-Id: <20181026144344.27778-4-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20181026144344.27778-1-jagan@amarulasolutions.com> References: <20181026144344.27778-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181026_074440_486997_7B84E187 X-CRM114-Status: GOOD ( 15.52 ) 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 Tested-by: Jagan Teki --- Changes for v3: - collect Stephen Ack - add tested credit Changes for v2: - none 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; };