From patchwork Mon Jun 2 22:44:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 4284411 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 48B559F392 for ; Mon, 2 Jun 2014 22:48:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 625B32021B for ; Mon, 2 Jun 2014 22:48:20 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5483A20212 for ; Mon, 2 Jun 2014 22:48:19 +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 1Wraz3-0004Wk-VC; Mon, 02 Jun 2014 22:45:37 +0000 Received: from mail-ig0-f170.google.com ([209.85.213.170]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Wraym-0003O6-9A for linux-arm-kernel@lists.infradead.org; Mon, 02 Jun 2014 22:45:21 +0000 Received: by mail-ig0-f170.google.com with SMTP id uy17so3804162igb.3 for ; Mon, 02 Jun 2014 15:44:56 -0700 (PDT) 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=fL1ZklHw4HOtPnF74jTmFUF/bLDZ7xrk0A3I7VjOKWM=; b=SZCz9w3RSgjZE9NPszWPK/rj0KvLELRjOtYkeC8pGyDzH1Q7U2V2d7Ox3DSTYC6NLS 0BUawRQVe8SqBiV6tpDRvluHGarPMYMxzB3LrPSICyxK3ir/v5DXs78DFYbCRrxwCIPU g4t044urfbo+Lp1ogGAlVGa5Cpf41flDu+FmbWEpDvS9R/izNbKuXD9MGDeAIbvjpMT5 ZDlKrnai1m8j9SsPwb63h3HIaPNwwiDQHNaixH67t6n4G0jEjyL5hyYGL7TTrg4OuqG0 wIcxM3Vd+KA4tfzhsvdT7JqldOFE2I08SXDKrYHUcpd7BKPxeayG8RBJ+JEJWJRxeFq4 UWBQ== X-Gm-Message-State: ALoCoQlDJiumViF+1swnPhUy0leO5Q2Tbf3vJIVAQHx1RXMTo1/t1i6BKq3P/Zr97yMy4GGJdEL0 X-Received: by 10.50.131.132 with SMTP id om4mr23322878igb.14.1401749096863; Mon, 02 Jun 2014 15:44:56 -0700 (PDT) Received: from localhost.localdomain (c-71-195-31-37.hsd1.mn.comcast.net. [71.195.31.37]) by mx.google.com with ESMTPSA id o19sm3523192igi.20.2014.06.02.15.44.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 02 Jun 2014 15:44:56 -0700 (PDT) From: Alex Elder To: mturquette@linaro.org, mporter@linaro.org, bcm@fixthebug.org Subject: [PATCH v5 1/7] clk: kona: move some code Date: Mon, 2 Jun 2014 17:44:52 -0500 Message-Id: <1401749098-10185-2-git-send-email-elder@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1401749098-10185-1-git-send-email-elder@linaro.org> References: <1401749098-10185-1-git-send-email-elder@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140602_154520_419014_3BEEF701 X-CRM114-Status: GOOD ( 17.92 ) X-Spam-Score: -0.7 (/) Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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=-2.5 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, 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 Move the definition of __peri_clk_init() up in "clk-kona.c", in preparation for the next patch (so it's defined before it's needed). Move kona_ccu_init() and __kona_clk_init() as well. Done as a separate patch so doing so doesn't obscure other changes. Signed-off-by: Alex Elder --- drivers/clk/bcm/clk-kona.c | 174 ++++++++++++++++++++++----------------------- 1 file changed, 87 insertions(+), 87 deletions(-) diff --git a/drivers/clk/bcm/clk-kona.c b/drivers/clk/bcm/clk-kona.c index 95af2e6..b643d35 100644 --- a/drivers/clk/bcm/clk-kona.c +++ b/drivers/clk/bcm/clk-kona.c @@ -981,6 +981,93 @@ static int selector_write(struct ccu_data *ccu, struct bcm_clk_gate *gate, return ret; } +/* Put a peripheral clock into its initial state */ +static bool __peri_clk_init(struct kona_clk *bcm_clk) +{ + struct ccu_data *ccu = bcm_clk->ccu; + struct peri_clk_data *peri = bcm_clk->u.peri; + const char *name = bcm_clk->init_data.name; + struct bcm_clk_trig *trig; + + BUG_ON(bcm_clk->type != bcm_clk_peri); + + if (!policy_init(ccu, &peri->policy)) { + pr_err("%s: error initializing policy for %s\n", + __func__, name); + return false; + } + if (!gate_init(ccu, &peri->gate)) { + pr_err("%s: error initializing gate for %s\n", __func__, name); + return false; + } + if (!hyst_init(ccu, &peri->hyst)) { + pr_err("%s: error initializing hyst for %s\n", __func__, name); + return false; + } + if (!div_init(ccu, &peri->gate, &peri->div, &peri->trig)) { + pr_err("%s: error initializing divider for %s\n", __func__, + name); + return false; + } + + /* + * For the pre-divider and selector, the pre-trigger is used + * if it's present, otherwise we just use the regular trigger. + */ + trig = trigger_exists(&peri->pre_trig) ? &peri->pre_trig + : &peri->trig; + + if (!div_init(ccu, &peri->gate, &peri->pre_div, trig)) { + pr_err("%s: error initializing pre-divider for %s\n", __func__, + name); + return false; + } + + if (!sel_init(ccu, &peri->gate, &peri->sel, trig)) { + pr_err("%s: error initializing selector for %s\n", __func__, + name); + return false; + } + + return true; +} + +static bool __kona_clk_init(struct kona_clk *bcm_clk) +{ + switch (bcm_clk->type) { + case bcm_clk_peri: + return __peri_clk_init(bcm_clk); + default: + BUG(); + } + return -EINVAL; +} + +/* Set a CCU and all its clocks into their desired initial state */ +bool __init kona_ccu_init(struct ccu_data *ccu) +{ + unsigned long flags; + unsigned int which; + struct clk **clks = ccu->clk_data.clks; + bool success = true; + + flags = ccu_lock(ccu); + __ccu_write_enable(ccu); + + for (which = 0; which < ccu->clk_data.clk_num; which++) { + struct kona_clk *bcm_clk; + + if (!clks[which]) + continue; + bcm_clk = to_kona_clk(__clk_get_hw(clks[which])); + success &= __kona_clk_init(bcm_clk); + } + + __ccu_write_disable(ccu); + ccu_unlock(ccu, flags); + return success; +} + /* Clock operations */ static int kona_peri_clk_enable(struct clk_hw *hw) @@ -1192,90 +1279,3 @@ struct clk_ops kona_peri_clk_ops = { .get_parent = kona_peri_clk_get_parent, .set_rate = kona_peri_clk_set_rate, }; - -/* Put a peripheral clock into its initial state */ -static bool __peri_clk_init(struct kona_clk *bcm_clk) -{ - struct ccu_data *ccu = bcm_clk->ccu; - struct peri_clk_data *peri = bcm_clk->u.peri; - const char *name = bcm_clk->init_data.name; - struct bcm_clk_trig *trig; - - BUG_ON(bcm_clk->type != bcm_clk_peri); - - if (!policy_init(ccu, &peri->policy)) { - pr_err("%s: error initializing policy for %s\n", - __func__, name); - return false; - } - if (!gate_init(ccu, &peri->gate)) { - pr_err("%s: error initializing gate for %s\n", __func__, name); - return false; - } - if (!hyst_init(ccu, &peri->hyst)) { - pr_err("%s: error initializing hyst for %s\n", __func__, name); - return false; - } - if (!div_init(ccu, &peri->gate, &peri->div, &peri->trig)) { - pr_err("%s: error initializing divider for %s\n", __func__, - name); - return false; - } - - /* - * For the pre-divider and selector, the pre-trigger is used - * if it's present, otherwise we just use the regular trigger. - */ - trig = trigger_exists(&peri->pre_trig) ? &peri->pre_trig - : &peri->trig; - - if (!div_init(ccu, &peri->gate, &peri->pre_div, trig)) { - pr_err("%s: error initializing pre-divider for %s\n", __func__, - name); - return false; - } - - if (!sel_init(ccu, &peri->gate, &peri->sel, trig)) { - pr_err("%s: error initializing selector for %s\n", __func__, - name); - return false; - } - - return true; -} - -static bool __kona_clk_init(struct kona_clk *bcm_clk) -{ - switch (bcm_clk->type) { - case bcm_clk_peri: - return __peri_clk_init(bcm_clk); - default: - BUG(); - } - return -EINVAL; -} - -/* Set a CCU and all its clocks into their desired initial state */ -bool __init kona_ccu_init(struct ccu_data *ccu) -{ - unsigned long flags; - unsigned int which; - struct clk **clks = ccu->clk_data.clks; - bool success = true; - - flags = ccu_lock(ccu); - __ccu_write_enable(ccu); - - for (which = 0; which < ccu->clk_data.clk_num; which++) { - struct kona_clk *bcm_clk; - - if (!clks[which]) - continue; - bcm_clk = to_kona_clk(__clk_get_hw(clks[which])); - success &= __kona_clk_init(bcm_clk); - } - - __ccu_write_disable(ccu); - ccu_unlock(ccu, flags); - return success; -}