From patchwork Sun Jul 30 16:41:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jernej_=C5=A0krabec?= X-Patchwork-Id: 9870593 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 059DA603B4 for ; Sun, 30 Jul 2017 16:43:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB48F28562 for ; Sun, 30 Jul 2017 16:43:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E01872859F; Sun, 30 Jul 2017 16:43:14 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 ECADF28564 for ; Sun, 30 Jul 2017 16:43:13 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=Mpxvf6bcKRlGsZDq/5PGUiMkG6IKSHFYqRtGif1YOXc=; b=oli53CGln3bT4QpDNmekuYI/CH hFIxQ89CMTAq0Zrh4QaG8GCprFdtvafKNj327BsE6uS/mAUNGb0uc8QXoPhLgaEvkRbMnsb6Jy+SE kp1aj34cT+BciFtsDJqHXtSEqH510bhHw5Kut6kgkzpE8x4DnDoAFgAEBnwrjUUKBRFMOGlouGFGR le9B7tuqWQI0wcRnH3apLyQ2Uot2cR35YTngkMbJMAAymuOs2tOpf4VUnN4eguFzNzCCIQo6BvVp/ SCxLkyvUzZizM2LymkEyK0zOO++qFjbGKe7t3mceZmUavcjWAe4xfMc3+uH1Q2hJeXZxkCxpyQZqN VAaSgr/w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dbrIi-0002FP-GD; Sun, 30 Jul 2017 16:42:44 +0000 Received: from mailoutvs1.siol.net ([213.250.19.134] helo=mail.siol.net) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dbrId-0002Bj-Fd for linux-arm-kernel@lists.infradead.org; Sun, 30 Jul 2017 16:42:42 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.siol.net (Postfix) with ESMTP id AA2E4520961; Sun, 30 Jul 2017 18:42:15 +0200 (CEST) X-Virus-Scanned: amavisd-new at psrvmta11.zcs-production.pri Received: from mail.siol.net ([127.0.0.1]) by localhost (psrvmta11.zcs-production.pri [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id lnv9Fn33eGin; Sun, 30 Jul 2017 18:42:15 +0200 (CEST) Received: from mail.siol.net (localhost [127.0.0.1]) by mail.siol.net (Postfix) with ESMTPS id 464D15208EB; Sun, 30 Jul 2017 18:42:15 +0200 (CEST) Received: from localhost.localdomain (cpe-86-58-68-135.ftth.triera.net [86.58.68.135]) (Authenticated sender: 031275009) by mail.siol.net (Postfix) with ESMTPSA id E13195208FA; Sun, 30 Jul 2017 18:42:12 +0200 (CEST) From: Jernej Skrabec To: maxime.ripard@free-electrons.com Subject: [PATCH 1/4] clk: sunxi-ng: Fix fractional mode for N-M clocks Date: Sun, 30 Jul 2017 18:41:47 +0200 Message-Id: <20170730164150.26302-2-jernej.skrabec@siol.net> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20170730164150.26302-1-jernej.skrabec@siol.net> References: <20170730164150.26302-1-jernej.skrabec@siol.net> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170730_094239_802434_CC8600F8 X-CRM114-Status: GOOD ( 10.07 ) 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: mturquette@baylibre.com, linux-sunxi@googlegroups.com, sboyd@codeaurora.org, linux-kernel@vger.kernel.org, wens@csie.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 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 N-M factor clock driver is missing a call to ccu_frac_helper_enable() when fractional mode is used. Additionally, most SoCs require that M factor must be set to 0 when fractional mode is used. Without this patch, clock keeps the old value and clk_set_rate() returns without error. Fixes: 6174a1e24b0d ("clk: sunxi-ng: Add N-M-factor clock support") CC: Maxime Ripard Signed-off-by: Jernej Skrabec --- drivers/clk/sunxi-ng/ccu_nm.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/clk/sunxi-ng/ccu_nm.c b/drivers/clk/sunxi-ng/ccu_nm.c index 5e5e90a4a50c..c6ba866b99d3 100644 --- a/drivers/clk/sunxi-ng/ccu_nm.c +++ b/drivers/clk/sunxi-ng/ccu_nm.c @@ -117,10 +117,22 @@ static int ccu_nm_set_rate(struct clk_hw *hw, unsigned long rate, unsigned long flags; u32 reg; - if (ccu_frac_helper_has_rate(&nm->common, &nm->frac, rate)) + if (ccu_frac_helper_has_rate(&nm->common, &nm->frac, rate)) { + spin_lock_irqsave(nm->common.lock, flags); + + /* most SoCs require M to be 0 if fractional mode is used */ + reg = readl(nm->common.base + nm->common.reg); + reg &= ~GENMASK(nm->m.width + nm->m.shift - 1, nm->m.shift); + writel(reg, nm->common.base + nm->common.reg); + + spin_unlock_irqrestore(nm->common.lock, flags); + + ccu_frac_helper_enable(&nm->common, &nm->frac); + return ccu_frac_helper_set_rate(&nm->common, &nm->frac, rate); - else + } else { ccu_frac_helper_disable(&nm->common, &nm->frac); + } _nm.min_n = nm->n.min ?: 1; _nm.max_n = nm->n.max ?: 1 << nm->n.width;