From patchwork Mon Jun 16 13:40:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 4359331 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 8980F9F3DF for ; Mon, 16 Jun 2014 13:53:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1967B202A7 for ; Mon, 16 Jun 2014 13:53:09 +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 8C2DB2025A for ; Mon, 16 Jun 2014 13:53:07 +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 1WwX9G-0003xm-8L; Mon, 16 Jun 2014 13:40:34 +0000 Received: from mail-ie0-f179.google.com ([209.85.223.179]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WwX8u-0002UZ-C5 for linux-arm-kernel@lists.infradead.org; Mon, 16 Jun 2014 13:40:13 +0000 Received: by mail-ie0-f179.google.com with SMTP id tr6so5052605ieb.10 for ; Mon, 16 Jun 2014 06:39:51 -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=LlNe0GvRvL/D2RZLEHThfEAEnzbmYVH//TfSgxfiVoY=; b=SGv9rFshF3rhSp+DGD73HgAEKhx5nErbFXSAqEepqZA7no0sgdYUezm1/3l2o+3w81 SQ21o2PG2rntZLMdVDQ+n1JFsyHMDQ62nGG8wooxrnp473y8Yk+jKaOiuhA5Gw30FeGc 23WJZZ4EVoYYAUwIpSGJY+UhELI2t4NlpLdbheN0DnHwL6pQ9QQUwg6d8s6ZAXWbZSiY k8JJKAwUEKbtlPNX76Zv4PkCOiOPCQXVWu1x7DKN5stYv8JxC4ysRfTHHEEQj/tCOz5q 29v6HKJ/GkXy2EUfB1yGN4cGCMJwHD5nCfX1LXBu6ifqPFO5OBd4vIman+8z6BFNJnvU fYrg== X-Gm-Message-State: ALoCoQkPgY99RfPHbGjkJr5A33e3I5Zreyp5r6fLAmHkvrBabfwudbJGGYmyU09hffsqq4iPgoZG X-Received: by 10.42.121.212 with SMTP id k20mr21346949icr.21.1402925991476; Mon, 16 Jun 2014 06:39:51 -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 k20sm20775727igf.5.2014.06.16.06.39.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 16 Jun 2014 06:39:51 -0700 (PDT) From: Alex Elder To: mturquette@linaro.org, mporter@linaro.org, bcm@fixthebug.org Subject: [PATCH v6 2/7] clk: kona: don't init clocks at startup time Date: Mon, 16 Jun 2014 08:40:02 -0500 Message-Id: <1402926007-4436-3-git-send-email-elder@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1402926007-4436-1-git-send-email-elder@linaro.org> References: <1402926007-4436-1-git-send-email-elder@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140616_064012_485718_F6229E91 X-CRM114-Status: GOOD ( 18.35 ) X-Spam-Score: -0.8 (/) 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.18-1 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.9 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 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 */