From patchwork Tue May 20 12:52:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 4209381 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 DEDE09F23C for ; Tue, 20 May 2014 12:55:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0061E2020A for ; Tue, 20 May 2014 12:55:11 +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 0F2D7202FF for ; Tue, 20 May 2014 12:55:10 +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 1WmjXd-0007y9-8q; Tue, 20 May 2014 12:53:13 +0000 Received: from mail-ie0-f182.google.com ([209.85.223.182]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WmjXU-0007pI-Aw for linux-arm-kernel@lists.infradead.org; Tue, 20 May 2014 12:53:05 +0000 Received: by mail-ie0-f182.google.com with SMTP id as1so371466iec.13 for ; Tue, 20 May 2014 05:52:42 -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=XpU51ICCXPN3Y3Y1d5MapGXu/ps/GD6w1Ub7EQ0VsnE=; b=a5kT7m28tfbPqkKZy9ni3egB7t6ni/7N5umQonXTnaMr61GfiwqSIlvwbi3UY9ZeY9 ooRK3Xn3+73T76OYvzLppEdL2K5pCuFhsZzi3sgPUz5v1fZUa32RR85lsUS5RQ24gYB4 QE3or3ISTxWNLMQiQU/XQTtk5EBJy009NFKoEZ6IziFN+AltBqtm6eMFx3i+qUtPSOPY DkdUkm6+br9CEYhW4zRKPwqd63o4S2VKTc6z7Qfqcu1rphjaT6XW4JSMERb6zyshHskW GDghrUiAh2iZmlvDq8umVDwkPp6MfhGYLU2JgppM751B9ThqxP6fHdlQSyrYXRZmB7vh fA8w== X-Gm-Message-State: ALoCoQnvTGZ3mmLciZ5WwY5OBjl+wx/YhvdLDKSHimK5eXbNAIyth5Y0bTBGQk4D65I4mRG/lynE X-Received: by 10.50.61.243 with SMTP id t19mr4451644igr.41.1400590362222; Tue, 20 May 2014 05:52:42 -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 kw1sm28775309igb.4.2014.05.20.05.52.41 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 20 May 2014 05:52:41 -0700 (PDT) From: Alex Elder To: mturquette@linaro.org, mporter@linaro.org, bcm@fixthebug.org, devicetree@vger.kernel.org Subject: [PATCH v2 1/5] clk: bcm281xx: add an initialized flag Date: Tue, 20 May 2014 07:52:38 -0500 Message-Id: <1400590362-11177-2-git-send-email-elder@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1400590362-11177-1-git-send-email-elder@linaro.org> References: <1400590362-11177-1-git-send-email-elder@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140520_055304_469215_DD1787EE X-CRM114-Status: GOOD ( 15.79 ) 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 Add a flag that tracks whether a clock has already been initialized. This will be used by the next patch to avoid initializing a clock more than once when it's listed as a prerequisite. Signed-off-by: Alex Elder --- drivers/clk/bcm/clk-kona.c | 17 +++++++++++++++-- drivers/clk/bcm/clk-kona.h | 7 +++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/drivers/clk/bcm/clk-kona.c b/drivers/clk/bcm/clk-kona.c index d603c4e..d8a7f38 100644 --- a/drivers/clk/bcm/clk-kona.c +++ b/drivers/clk/bcm/clk-kona.c @@ -27,6 +27,9 @@ #define CCU_ACCESS_PASSWORD 0xA5A500 #define CLK_GATE_DELAY_LOOP 2000 +#define clk_is_initialized(_clk) FLAG_TEST((_clk), KONA, INITIALIZED) +#define clk_set_initialized(_clk) FLAG_SET((_clk), KONA, INITIALIZED) + /* Bitfield operations */ /* Produces a mask of set bits covering a range of a 32-bit value */ @@ -1194,13 +1197,23 @@ static bool __peri_clk_init(struct kona_clk *bcm_clk) static bool __kona_clk_init(struct kona_clk *bcm_clk) { + bool ret; + + if (clk_is_initialized(bcm_clk)) + return true; + switch (bcm_clk->type) { case bcm_clk_peri: - return __peri_clk_init(bcm_clk); + ret = __peri_clk_init(bcm_clk); + break; default: + ret = false; BUG(); } - return -EINVAL; + if (ret) + clk_set_initialized(bcm_clk); + + return ret; } /* Set a CCU and all its clocks into their desired initial state */ diff --git a/drivers/clk/bcm/clk-kona.h b/drivers/clk/bcm/clk-kona.h index 2537b30..10e238d 100644 --- a/drivers/clk/bcm/clk-kona.h +++ b/drivers/clk/bcm/clk-kona.h @@ -406,6 +406,7 @@ struct kona_clk { struct clk_init_data init_data; /* includes name of this clock */ struct ccu_data *ccu; /* ccu this clock is associated with */ enum bcm_clk_type type; + u32 flags; /* BCM_CLK_KONA_FLAGS_* below */ union { void *data; struct peri_clk_data *peri; @@ -414,6 +415,12 @@ struct kona_clk { #define to_kona_clk(_hw) \ container_of(_hw, struct kona_clk, hw) +/* + * Kona clock flags: + * INITIALIZED clock has been initialized already + */ +#define BCM_CLK_KONA_FLAGS_INITIALIZED ((u32)1 << 0) /* Clock initialized */ + /* Initialization macro for an entry in a CCU's kona_clks[] array. */ #define KONA_CLK(_ccu_name, _clk_name, _type) \ { \