From patchwork Mon May 5 13:57:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 4115281 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 B32459F1E1 for ; Mon, 5 May 2014 14:01:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9C824201F5 for ; Mon, 5 May 2014 14:01:12 +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 5B6DC20384 for ; Mon, 5 May 2014 14:01:11 +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 1WhJPE-0006Wu-UF; Mon, 05 May 2014 13:58:08 +0000 Received: from mail-ig0-f175.google.com ([209.85.213.175]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WhJP7-0006Qa-N9 for linux-arm-kernel@lists.infradead.org; Mon, 05 May 2014 13:58:02 +0000 Received: by mail-ig0-f175.google.com with SMTP id uq10so2277940igb.14 for ; Mon, 05 May 2014 06:57:40 -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=JgjlsO7q/1HQ4kDHH3rP7QNrEBg6A6On1HC9YWp8NG6f5bNcDLsjQnPbFFHrB7/GJx Vm56RRaLLnNsrCZISh2nzO0H3YqZUsH8jTHFy7zKvN1/TsIVW+Zfnxgjuz71+TngM9u4 p1rGXmPwATUZm8fULCdDO5pM3QwiwLKjHek5rn3SMzbNi+HKSoxKDtsVYOGmix3qV99X uDNNAHv74t0dxwbZzMop9nw1WTcRYk13+8ZgsYl4kc0N79/dFRSdge9yw1poCz1gqQv/ u8iyVDWfABvHNRbNnpwl8AANz7nhT0OZoMn384RRzElF7HN9+l93nZW+WXorul+9bk2H KFIw== X-Gm-Message-State: ALoCoQl7ofE/OoUz3VP4+kKFvddYsXYkY/Y7dfCVv5T+PiAYRrmlGlZrGdyWj18jWSvVOTiGMRcE X-Received: by 10.42.214.143 with SMTP id ha15mr2423455icb.59.1399298260653; Mon, 05 May 2014 06:57:40 -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 w4sm27660107igl.7.2014.05.05.06.57.39 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 05 May 2014 06:57:39 -0700 (PDT) From: Alex Elder To: mturquette@linaro.org, mporter@linaro.org, bcm@fixthebug.org, devicetree@vger.kernel.org Subject: [PATCH 1/5] clk: bcm281xx: add an initialized flag Date: Mon, 5 May 2014 08:57:32 -0500 Message-Id: <1399298256-10965-2-git-send-email-elder@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1399298256-10965-1-git-send-email-elder@linaro.org> References: <1399298256-10965-1-git-send-email-elder@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140505_065801_788998_26E31D95 X-CRM114-Status: GOOD ( 15.51 ) 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) \ { \