From patchwork Fri Oct 26 14:43:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 10659099 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 2306713B5 for ; Mon, 29 Oct 2018 11:11:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1430429724 for ; Mon, 29 Oct 2018 11:11:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 050E929870; Mon, 29 Oct 2018 11:11:05 +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 B726629724 for ; Mon, 29 Oct 2018 11:11:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6155C89C85; Mon, 29 Oct 2018 11:10:32 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4EBA86E4B5 for ; Fri, 26 Oct 2018 14:44:24 +0000 (UTC) Received: by mail-pg1-x544.google.com with SMTP id c10-v6so649740pgq.4 for ; Fri, 26 Oct 2018 07:44:24 -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=ZqT7S7ccSlN0Z4oiBOZYnQBnDGQDeTm2f/tIRaoUEO4=; b=SrLjS6Ne56YFvestkmSABJqMO4xhxNZ1vVz9qdopX4qhmWkI4ZG2udcTznljdQGBN6 yxb93zuCx9CT9W093lPDrAEgL7Q6rD8X0eEScXjcwaCvbG2fwHg8D/hoIwX13N4rcZkc 5Rwhnxj2+cT3Cc5bct65T7Xy1GcPeRvbDwuvm2Fif+0mT43c5kp+b5P3B+HasIUwKpzr OeitUIk00WpXxQANwPzeDsoHgc1T7iTHvQuwJ73zRhk5O7MCOzOzQluL4y3F0YkOaOBJ /BvONWTk1kYEN7SXOeao6PdNqEXBck/ru/wEkXDCZe5xLrOEiCzy/ok1JD8UOMF237oc VNgQ== X-Gm-Message-State: AGRZ1gJmhHlySWmeNJ4gXi6g4b0f2+AFgHVhjBWTmP6g4+c6+CSVUkzC wMP1drTvTxakAzIsTAxuBBhaww== X-Google-Smtp-Source: AJdET5dwXUrFOyiMpZ7HyN1IfRqpZo8uWMppQAsUlS9mUf0ioXHLoBiT2n/c/xkE2UhLRT+xsEUqxg== X-Received: by 2002:a63:b218:: with SMTP id x24mr3606180pge.223.1540565063890; Fri, 26 Oct 2018 07:44:23 -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.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Oct 2018 07:44:23 -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 02/25] clk: sunxi-ng: Add check for minimal rate to NKM PLLs Date: Fri, 26 Oct 2018 20:13:21 +0530 Message-Id: <20181026144344.27778-3-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-Mailman-Approved-At: Mon, 29 Oct 2018 11:10:30 +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 doesn't work well when their output clock rate is set below certain rate. So, add support for minimal rate for relevant PLLs. 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 841840e35e61..d17539dc88dd 100644 --- a/drivers/clk/sunxi-ng/ccu_nkm.c +++ b/drivers/clk/sunxi-ng/ccu_nkm.c @@ -125,6 +125,13 @@ static unsigned long ccu_nkm_round_rate(struct ccu_mux_internal *mux, if (nkm->common.features & CCU_FEATURE_FIXED_POSTDIV) rate *= nkm->fixed_post_div; + if (rate < nkm->min_rate) { + rate = nkm->min_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 cc6efb70a102..ff5bd00f429f 100644 --- a/drivers/clk/sunxi-ng/ccu_nkm.h +++ b/drivers/clk/sunxi-ng/ccu_nkm.h @@ -35,6 +35,7 @@ struct ccu_nkm { struct ccu_mux_internal mux; unsigned int fixed_post_div; + unsigned int min_rate; struct ccu_common common; };