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: 31313 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f72.google.com (mail-oa0-f72.google.com [209.85.219.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id AD61120AE6 for ; Mon, 2 Jun 2014 22:47:07 +0000 (UTC) Received: by mail-oa0-f72.google.com with SMTP id l6sf30418000oag.11 for ; Mon, 02 Jun 2014 15:47:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=dIt6Yu8mvkgGqwMyfbvXw0XCME44c17OM4ZyhMM2Koo=; b=VQiZCCFD2+50JLPMG3lwdtm4TVkAL1KTgQ7nlN9Q01AJkCHYZU01/05RVZhnhhG6bg R++gCMTg7p3Gn7Rp0+TR8ppmwViMC8mOpY3dsyuMcWdrjWJRlWWD7miZvtHYvJ0RO+rx 1TO7oPYe4/AOuVd2jF1OPaAiRirgmf+KRpiAGwVvBkd8iyqDzTbyFU6rZYd9Q/7y00cY 2WiKSfEsoC8ivGkg6DG0WgdD/GhnMMkIduF7d369E5h5/h8uQzuj50J6PUneLzHc5Odm ZZ91qk7dV+3gaZG1qW9V8W464FfZWqIOjJf9SgyLgRUPfMibYodHSQgGxoXwAwDdNsJK u3nQ== X-Gm-Message-State: ALoCoQkCmZlxWntTN8R2H9URD36Q5gPsi64msh5pV/QDvH/VEOxK4Ve+l8Rwf9avCicd0u8LwWTQ X-Received: by 10.43.126.130 with SMTP id gw2mr14359523icc.15.1401749227228; Mon, 02 Jun 2014 15:47:07 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.87.33 with SMTP id q30ls2203505qgd.10.gmail; Mon, 02 Jun 2014 15:47:07 -0700 (PDT) X-Received: by 10.58.126.135 with SMTP id my7mr8598642veb.27.1401749227052; Mon, 02 Jun 2014 15:47:07 -0700 (PDT) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id aq10si8814372vdd.28.2014.06.02.15.47.07 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 02 Jun 2014 15:47:07 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) client-ip=209.85.220.178; Received: by mail-vc0-f178.google.com with SMTP id hy4so2222617vcb.9 for ; Mon, 02 Jun 2014 15:47:07 -0700 (PDT) X-Received: by 10.52.68.72 with SMTP id u8mr13827807vdt.29.1401749226977; Mon, 02 Jun 2014 15:47:06 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp132185vcb; Mon, 2 Jun 2014 15:47:06 -0700 (PDT) X-Received: by 10.68.193.193 with SMTP id hq1mr43936517pbc.107.1401749226184; Mon, 02 Jun 2014 15:47:06 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id in9si17537699pbd.29.2014.06.02.15.47.05; Mon, 02 Jun 2014 15:47:05 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753239AbaFBWq5 (ORCPT + 27 others); Mon, 2 Jun 2014 18:46:57 -0400 Received: from mail-ie0-f170.google.com ([209.85.223.170]:56065 "EHLO mail-ie0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752989AbaFBWo5 (ORCPT ); Mon, 2 Jun 2014 18:44:57 -0400 Received: by mail-ie0-f170.google.com with SMTP id to1so3997071ieb.1 for ; Mon, 02 Jun 2014 15:44:56 -0700 (PDT) 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 Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.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> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: elder@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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; -}