From patchwork Fri Jul 14 14:49:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Priit Laes X-Patchwork-Id: 9841255 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 0DE2E60381 for ; Fri, 14 Jul 2017 14:51:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1F8E28779 for ; Fri, 14 Jul 2017 14:51:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E68C228798; Fri, 14 Jul 2017 14:51:30 +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.1 required=2.0 tests=BAYES_00,DKIM_ADSP_ALL, DKIM_SIGNED,DKIM_VALID autolearn=no 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 9C1BB28779 for ; Fri, 14 Jul 2017 14:51:30 +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=OY0qyLhiBbGFxbVu5nNsvNsiSObywXLBxYeDGC+ah28=; b=aI1D8ACVaC0PMujzEKS+xpsdQ/ 5S3UFW5hYizl3qtWASmkm1J6+8y8K1hMSmVlXhFP4eEIoSyebzl5meNwNbM9La732jxDoxsbdD8vt 5zhypShWQ/B/DlkJuAg1y1XH1AXLwxHQzHJVHPWwbpqZXEocekTAl3cI1IW9gnkrdgUNjawhAVXj1 rkPsgqCfULkPv4+xIz6ar5pTQAbEkb02ssiZ5DUz7B7snetXV0M9D+Jq2stWSI4AuqFjXnAAuWuji fwKRv+zlsZQxo7DMR3NUCnoiCCPswleOUnGO6ui5xBVFwo1l5ZIlTJJozB6FSAD1vomjfCOU4r5Lg Vruv47Ew==; 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 1dW1wE-00040I-A2; Fri, 14 Jul 2017 14:51:26 +0000 Received: from plaes.org ([188.166.43.21]) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dW1w9-0003xn-NX for linux-arm-kernel@lists.infradead.org; Fri, 14 Jul 2017 14:51:23 +0000 Received: from localhost (85.253.161.114.cable.starman.ee [85.253.161.114]) by plaes.org (Postfix) with ESMTPSA id 136D741A19; Fri, 14 Jul 2017 14:50:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=plaes.org; s=mail; t=1500043857; bh=teXMb8ciIIc93Mn8pvhvqrBwW1xlTQwaUUVI+1KWf6Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:In-Reply-To: References:From; b=G0TDCxShV0o74uJMYsodI2BK8nOlMyIHf/+g2gzAkgWHlIkttZP4F4MPvzbkicmlr 7o2M+fi+J0gNsZJuhz2pPdQNXJYr5oKxqtjbjB+GnfXrvP03YvVgWXxN52LLc4i6Ea teuvQNEv/4EFttHvaa9vKi8fd9c1KYIshD/Mg1ADK7lAQ6BIUxy+mNN3/GwPJYVFC+ TJI1JH6ul7XD/brDHUwdvqZy2Y8fRbiJNObH0JWhHMAGZKTUiT5zFiAko5dccXSPRP HIXTxEph1qcRWblcA+3cTP8E3gJ/92Wir+bIpH5vFzQzhd89DZ4wz89vX/h9o8iz8Q w7ySWH0O+Fzuw== From: Priit Laes To: Michael Turquette , Stephen Boyd , Rob Herring , Mark Rutland , Maxime Ripard , Chen-Yu Tsai , Russell King , Philipp Zabel , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 1/6] clk: sunxi-ng: div: Add support for fixed post-divider Date: Fri, 14 Jul 2017 17:49:23 +0300 Message-Id: <946794e97ae2c36cd67c272099e8236a589efc28.1500043741.git-series.plaes@plaes.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: References: In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170714_075122_146185_1D909966 X-CRM114-Status: GOOD ( 10.11 ) 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: linux-sunxi@googlegroups.com, Priit Laes , Jonathan Liu 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 SATA clock on sun4i/sun7i is of type (parent) / M / 6 where 6 is fixed post-divider. Signed-off-by: Priit Laes --- drivers/clk/sunxi-ng/ccu_div.c | 15 +++++++++++++-- drivers/clk/sunxi-ng/ccu_div.h | 3 ++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/clk/sunxi-ng/ccu_div.c b/drivers/clk/sunxi-ng/ccu_div.c index c0e5c10..744502a 100644 --- a/drivers/clk/sunxi-ng/ccu_div.c +++ b/drivers/clk/sunxi-ng/ccu_div.c @@ -21,6 +21,9 @@ static unsigned long ccu_div_round_rate(struct ccu_mux_internal *mux, { struct ccu_div *cd = data; + if (cd->common.features & CCU_FEATURE_FIXED_POSTDIV) + rate *= cd->fixed_post_div; + return divider_round_rate_parent(&cd->common.hw, parent, rate, parent_rate, cd->div.table, cd->div.width, @@ -62,8 +65,13 @@ static unsigned long ccu_div_recalc_rate(struct clk_hw *hw, parent_rate = ccu_mux_helper_apply_prediv(&cd->common, &cd->mux, -1, parent_rate); - return divider_recalc_rate(hw, parent_rate, val, cd->div.table, - cd->div.flags); + val = divider_recalc_rate(hw, parent_rate, val, cd->div.table, + cd->div.flags); + + if (cd->common.features & CCU_FEATURE_FIXED_POSTDIV) + val /= cd->fixed_post_div; + + return val; } static int ccu_div_determine_rate(struct clk_hw *hw, @@ -86,6 +94,9 @@ static int ccu_div_set_rate(struct clk_hw *hw, unsigned long rate, parent_rate = ccu_mux_helper_apply_prediv(&cd->common, &cd->mux, -1, parent_rate); + if (cd->common.features & CCU_FEATURE_FIXED_POSTDIV) + rate *= cd->fixed_post_div; + val = divider_get_val(rate, parent_rate, cd->div.table, cd->div.width, cd->div.flags); diff --git a/drivers/clk/sunxi-ng/ccu_div.h b/drivers/clk/sunxi-ng/ccu_div.h index 08d0744..f3a5028 100644 --- a/drivers/clk/sunxi-ng/ccu_div.h +++ b/drivers/clk/sunxi-ng/ccu_div.h @@ -86,9 +86,10 @@ struct ccu_div_internal { struct ccu_div { u32 enable; - struct ccu_div_internal div; + struct ccu_div_internal div; struct ccu_mux_internal mux; struct ccu_common common; + unsigned int fixed_post_div; }; #define SUNXI_CCU_DIV_TABLE_WITH_GATE(_struct, _name, _parent, _reg, \