From patchwork Sat Apr 16 18:55:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: vishnupatekar X-Patchwork-Id: 8861811 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4DBBEBF440 for ; Sat, 16 Apr 2016 18:57:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 68EE020222 for ; Sat, 16 Apr 2016 18:57:25 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8054A20154 for ; Sat, 16 Apr 2016 18:57:24 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1arVNn-0005Mf-8n; Sat, 16 Apr 2016 18:55:51 +0000 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1arVNc-0005KF-Pu for linux-arm-kernel@lists.infradead.org; Sat, 16 Apr 2016 18:55:41 +0000 Received: by mail-pf0-x244.google.com with SMTP id e190so13044974pfe.0 for ; Sat, 16 Apr 2016 11:55:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RnUuRf5SMSRLe30upovoqO7yYoiraXZbEwPqtbG925c=; b=HOKkYE8XCUFBXIcX+pE7QUf+4KiQhk2Xy7QwHzCoRm66Jxbqx35Wno24VNSho3cfrh 6+RA8TnJD4z3UB7emAmTkRRKet7T3S0e62Pa+UsPFjYgd4uiull7EslScD1n24ZTPA6l bu0gMN4Rces5VN9vH7iRQMS9QYTt3lZUhPWI35gob/mJzpULIE81hzb6bHN+RbYZD+a9 N3sTv2egwC90avjIZG7h4yw70K7Y7TCCaYbZBK125c59dqQKpoaaWV5XagM9Zo6Gmj5T jn4yiUOCZG3K2JR45+DEXdKrAvpbJMxwzqVFTz6HqdFrcftM19CA1jMmYhTMwOpGZFHO OmLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=RnUuRf5SMSRLe30upovoqO7yYoiraXZbEwPqtbG925c=; b=cToodS57rKFXeSvRhoDHxWIJsJzj0Ay8/es6r0rmrdfN+2FyBKTF2o2XwCLcmqirpc qRSuxUA1ZFgTdSFdhjv6ue360zSEzdh7O99OUQOPA1PoxRL4oo1Z/mXwj8uXbFdXNfjy iOD7bDBDLy7dRLmvvn51gHmGSJG87dkjjvubzo4LEqPCEoKxbJfOzT+I86cZ2xi/vlWM MRsQIVGu+q5NoknGkHrR53SMigEuCgu24uOn1pcyMHU0vcLnn+LckMAe1Qp6GA9+KDRI BZX2Lq82nsUrnl9/De5zZHIjnBkQspRdCqrsLC1tXbrPAGY7ynq3N8BZt7fHe6XEUwXz cYTQ== X-Gm-Message-State: AOPr4FUVp5pv3X9qV6zjvNtwzOZgnJeB3mcxrnM0IhfcboXH1RRmF8XbiN/Gv2brmdQPrA== X-Received: by 10.98.102.195 with SMTP id s64mr35032534pfj.89.1460832920214; Sat, 16 Apr 2016 11:55:20 -0700 (PDT) Received: from localhost.localdomain (amx-tls3.starhub.net.sg. [203.116.164.13]) by smtp.gmail.com with ESMTPSA id a205sm5365765pfa.6.2016.04.16.11.55.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 16 Apr 2016 11:55:19 -0700 (PDT) From: Vishnu Patekar To: maxime.ripard@free-electrons.com, emilio@elopez.com.ar, wens@csie.org Subject: [PATCH 2/2] clk: sunxi: add prediv table for a31 ahb1 clock Date: Sun, 17 Apr 2016 02:55:06 +0800 Message-Id: <1460832906-24064-3-git-send-email-vishnupatekar0510@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1460832906-24064-1-git-send-email-vishnupatekar0510@gmail.com> References: <1460832906-24064-1-git-send-email-vishnupatekar0510@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160416_115540_922312_63BC313C X-CRM114-Status: GOOD ( 13.37 ) X-Spam-Score: -2.5 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-sunxi@googlegroups.com, sboyd@codeaurora.org, linux-kernel@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-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP For ahb1 clock, move mshift and mwidth to parent specific width and shift. getter differentiates parents with prediv, with non-zero prediv width. Also, removed unused ahb1 recalc function, it's now handled in generic factors recalc. Signed-off-by: Vishnu Patekar --- drivers/clk/sunxi/clk-sunxi.c | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c index 91de0a0..5a5f26b 100644 --- a/drivers/clk/sunxi/clk-sunxi.c +++ b/drivers/clk/sunxi/clk-sunxi.c @@ -282,8 +282,6 @@ static void sun5i_a13_get_ahb_factors(struct factors_request *req) req->p = div; } -#define SUN6I_AHB1_PARENT_PLL6 3 - /** * sun6i_a31_get_ahb_factors() - calculates m, p factors for AHB * AHB rate is calculated as follows @@ -307,7 +305,7 @@ static void sun6i_get_ahb1_factors(struct factors_request *req) div = DIV_ROUND_UP(req->parent_rate, req->rate); /* calculate pre-divider if parent is pll6 */ - if (req->parent_index == SUN6I_AHB1_PARENT_PLL6) { + if (req->prediv_width) { if (div < 4) calcp = 0; else if (div / 2 < 4) @@ -329,22 +327,6 @@ static void sun6i_get_ahb1_factors(struct factors_request *req) } /** - * sun6i_ahb1_recalc() - calculates AHB clock rate from m, p factors and - * parent index - */ -static void sun6i_ahb1_recalc(struct factors_request *req) -{ - req->rate = req->parent_rate; - - /* apply pre-divider first if parent is pll6 */ - if (req->parent_index == SUN6I_AHB1_PARENT_PLL6) - req->rate /= req->m + 1; - - /* clk divider */ - req->rate >>= req->p; -} - -/** * sun4i_get_apb1_factors() - calculates m, p factors for APB1 * APB1 rate is calculated as follows * rate = (parent_rate >> p) / (m + 1); @@ -474,12 +456,17 @@ static const struct clk_factors_config sun5i_a13_ahb_config = { }; static const struct clk_factors_config sun6i_ahb1_config = { - .mshift = 6, - .mwidth = 2, .pshift = 4, .pwidth = 2, }; +static const struct clk_factors_prediv sun6i_ahb1_prediv[] = { + {.parent_index = 0, .shift = 0, .width = 0 }, /* LOSC */ + {.parent_index = 1, .shift = 0, .width = 0 }, /* OSC24MHz */ + {.parent_index = 2, .shift = 0, .width = 0 }, /* AXI */ + {.parent_index = 3, .shift = 6, .width = 2 } /* PLL6/Pre_div */ +}; + static const struct clk_factors_config sun4i_apb1_config = { .mshift = 0, .mwidth = 5, @@ -551,8 +538,8 @@ static const struct factors_data sun6i_ahb1_data __initconst = { .mux = 12, .muxmask = BIT(1) | BIT(0), .table = &sun6i_ahb1_config, + .prediv_table = sun6i_ahb1_prediv, .getter = sun6i_get_ahb1_factors, - .recalc = sun6i_ahb1_recalc, }; static const struct factors_data sun4i_apb1_data __initconst = {