From patchwork Mon Jun 2 22:44:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 31312 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f200.google.com (mail-ig0-f200.google.com [209.85.213.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 45ACF20AE6 for ; Mon, 2 Jun 2014 22:46:47 +0000 (UTC) Received: by mail-ig0-f200.google.com with SMTP id uy17sf13828340igb.11 for ; Mon, 02 Jun 2014 15:46:46 -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=aR/oElONKbq9BXSAoF9wNuy4HrXusa6b1Wlf/6regTc=; b=QfkMQhwjImn36UKi1gmzeb35PxM8EZhvvM6RquTXg3u0X3oyHvpEjb5aEM4hAFDwZ3 3vtxpZ+B8Qst9z5wMJUJlbnUQmEUAOg4CSFDsXaDvo0NYPOfNTKEKUCQ7pU+0vvuCwRI URAKybShNUeBUKzyl3a1Uv0LXR8R74zXC8ewzawyLI9/83XO+AJOv2RVc8hdXfSeLKlH MZAlxELQfditrNOdiIgdqL19OdDJYcekwKtx0XnOA/0EsC7pLFsoywSe8w0KCiT8olDm oWHDfAMkPgfjeAc4Hsypk5/nX5nytwl90twGGliwgiPlvrK6UhmT274U+OSAmrDvRPRT QkPw== X-Gm-Message-State: ALoCoQneDtNgQilaZPOvj0Xx3h3mfGYE208W/PiRhLPheuDvYSo7hTDTVeeKhlwULnLY8fXzUku4 X-Received: by 10.50.225.4 with SMTP id rg4mr7784470igc.1.1401749206721; Mon, 02 Jun 2014 15:46:46 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.84.239 with SMTP id l102ls2164566qgd.81.gmail; Mon, 02 Jun 2014 15:46:46 -0700 (PDT) X-Received: by 10.58.211.229 with SMTP id nf5mr32040805vec.19.1401749206561; Mon, 02 Jun 2014 15:46:46 -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 wv1si8802785vdb.80.2014.06.02.15.46.46 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 02 Jun 2014 15:46:46 -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 hy4so2162206vcb.23 for ; Mon, 02 Jun 2014 15:46:46 -0700 (PDT) X-Received: by 10.58.219.166 with SMTP id pp6mr33631388vec.1.1401749206464; Mon, 02 Jun 2014 15:46:46 -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 ib8csp132175vcb; Mon, 2 Jun 2014 15:46:46 -0700 (PDT) X-Received: by 10.66.151.144 with SMTP id uq16mr45023074pab.68.1401749205679; Mon, 02 Jun 2014 15:46:45 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id hm7si17777351pad.140.2014.06.02.15.46.45; Mon, 02 Jun 2014 15:46:45 -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 S932238AbaFBWqh (ORCPT + 27 others); Mon, 2 Jun 2014 18:46:37 -0400 Received: from mail-ie0-f170.google.com ([209.85.223.170]:39590 "EHLO mail-ie0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753021AbaFBWo6 (ORCPT ); Mon, 2 Jun 2014 18:44:58 -0400 Received: by mail-ie0-f170.google.com with SMTP id to1so3997083ieb.1 for ; Mon, 02 Jun 2014 15:44:57 -0700 (PDT) X-Received: by 10.43.82.132 with SMTP id ac4mr5676000icc.75.1401749097801; Mon, 02 Jun 2014 15:44:57 -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.56 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 02 Jun 2014 15:44:57 -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 2/7] clk: kona: don't init clocks at startup time Date: Mon, 2 Jun 2014 17:44:53 -0500 Message-Id: <1401749098-10185-3-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: , The last thing done for CCU setup is a call to kona_ccu_init(). This locks and enables write access on the CCU, then calls __kona_clk_init() for all of the clocks it provides. The purpose of this was to get or set the initial state of all the registers related to each clock. There's no reason to do this though. The common clock framework assumes nothing about the state of the hardware, and if a driver requires its clock to be in a particular state it can set that state up itself. Instead of initializing clocks at startup time, define a prepare method that performs that step when a clock is first needed. Signed-off-by: Alex Elder --- drivers/clk/bcm/clk-kona-setup.c | 3 --- drivers/clk/bcm/clk-kona.c | 49 +++++++++++++++++++--------------------- drivers/clk/bcm/clk-kona.h | 1 - 3 files changed, 23 insertions(+), 30 deletions(-) diff --git a/drivers/clk/bcm/clk-kona-setup.c b/drivers/clk/bcm/clk-kona-setup.c index e5aeded..317f7dd 100644 --- a/drivers/clk/bcm/clk-kona-setup.c +++ b/drivers/clk/bcm/clk-kona-setup.c @@ -867,9 +867,6 @@ void __init kona_dt_ccu_setup(struct ccu_data *ccu, goto out_err; } - if (!kona_ccu_init(ccu)) - pr_err("Broadcom %s initialization had errors\n", node->name); - return; out_err: kona_ccu_teardown(ccu); diff --git a/drivers/clk/bcm/clk-kona.c b/drivers/clk/bcm/clk-kona.c index b643d35..cacbfd6 100644 --- a/drivers/clk/bcm/clk-kona.c +++ b/drivers/clk/bcm/clk-kona.c @@ -1032,43 +1032,38 @@ static bool __peri_clk_init(struct kona_clk *bcm_clk) return true; } -static bool __kona_clk_init(struct kona_clk *bcm_clk) +/* Clock operations */ + +static int kona_clk_prepare(struct clk_hw *hw) { + struct kona_clk *bcm_clk = to_kona_clk(hw); + struct ccu_data *ccu; + unsigned long flags; + int ret = 0; + + ccu = bcm_clk->ccu; + flags = ccu_lock(ccu); + __ccu_write_enable(ccu); + switch (bcm_clk->type) { case bcm_clk_peri: - return __peri_clk_init(bcm_clk); + if (!__peri_clk_init(bcm_clk)) + ret = -EINVAL; + break; 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; + + return ret; } -/* Clock operations */ +static void kona_clk_unprepare(struct clk_hw *hw) +{ + /* Nothing to do. */ +} static int kona_peri_clk_enable(struct clk_hw *hw) { @@ -1270,6 +1265,8 @@ static int kona_peri_clk_set_rate(struct clk_hw *hw, unsigned long rate, } struct clk_ops kona_peri_clk_ops = { + .prepare = kona_clk_prepare, + .unprepare = kona_clk_unprepare, .enable = kona_peri_clk_enable, .disable = kona_peri_clk_disable, .is_enabled = kona_peri_clk_is_enabled, diff --git a/drivers/clk/bcm/clk-kona.h b/drivers/clk/bcm/clk-kona.h index 2537b30..4c7e796 100644 --- a/drivers/clk/bcm/clk-kona.h +++ b/drivers/clk/bcm/clk-kona.h @@ -511,6 +511,5 @@ extern u64 scaled_div_build(struct bcm_clk_div *div, u32 div_value, extern struct clk *kona_clk_setup(struct kona_clk *bcm_clk); extern void __init kona_dt_ccu_setup(struct ccu_data *ccu, struct device_node *node); -extern bool __init kona_ccu_init(struct ccu_data *ccu); #endif /* _CLK_KONA_H */