From patchwork Mon Jun 16 13:40:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 4359321 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5C2CFBEEAA for ; Mon, 16 Jun 2014 13:52:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 68D482025A for ; Mon, 16 Jun 2014 13:52:47 +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 6FDC6202A1 for ; Mon, 16 Jun 2014 13:52:45 +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 1WwX9T-00045R-7U; Mon, 16 Jun 2014 13:40:47 +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 1WwX8w-0002VE-DC for linux-arm-kernel@lists.infradead.org; Mon, 16 Jun 2014 13:40:14 +0000 Received: by mail-ig0-f175.google.com with SMTP id uq10so2911324igb.14 for ; Mon, 16 Jun 2014 06:39:52 -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=cZ6PQKR6lulinTgQyA/F7ItVAnnOp8mw71kqcGVrGfQ=; b=Tw8PYFFb2aSsWHCsO1xUR+LPlZlrasEb9VKfjqhwKhKMKqFTxkVnL5Qq3rAczcxAai 5qRTab10S6ixw5Acgm+DPohcZFkGGzD4VtPmp+eo6YTu2WO8UksfIogRxIV+Dnz0PwVC h3Xbk+gNSVA485iLoEPW9mdwzAX1GtYERKh74ji3RYK1SN10Uw+oZWSh0Op4DYqUAXDl 9x9XUj1uf3aX/dY1hU19q/07ExXJWZrCimkwIUH3eTwEScnnfezgZhr3O0JLKlk2+cyd XOS4xRzpDptjnWPWw+71j4sij8goQ+EzIlrZd8QHPdy53yMQ6u0Rj5iNiJ4Au0IOhiih RD1w== X-Gm-Message-State: ALoCoQksYoIuMaBAoweF62VrrEZVFPQGPSiEi0FaUtlakLfBQ4r2ZsCL0C0z/oyA1J0lBtSPvezS X-Received: by 10.42.110.141 with SMTP id q13mr21548092icp.32.1402925992614; Mon, 16 Jun 2014 06:39:52 -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.51 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 16 Jun 2014 06:39:52 -0700 (PDT) From: Alex Elder To: mturquette@linaro.org, mporter@linaro.org, bcm@fixthebug.org Subject: [PATCH v6 3/7] clk: bcm281xx: add an initialized flag Date: Mon, 16 Jun 2014 08:40:03 -0500 Message-Id: <1402926007-4436-4-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_064014_485703_0A409BEF X-CRM114-Status: GOOD ( 14.80 ) 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 Add a flag that tracks whether a clock has already been initialized. Use it to avoid initializing a clock more than once. Signed-off-by: Alex Elder --- drivers/clk/bcm/clk-kona.c | 12 ++++++++++++ drivers/clk/bcm/clk-kona.h | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/drivers/clk/bcm/clk-kona.c b/drivers/clk/bcm/clk-kona.c index cacbfd6..2e27924 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 */ @@ -1041,6 +1044,9 @@ static int kona_clk_prepare(struct clk_hw *hw) unsigned long flags; int ret = 0; + if (clk_is_initialized(bcm_clk)) + return 0; + ccu = bcm_clk->ccu; flags = ccu_lock(ccu); __ccu_write_enable(ccu); @@ -1057,11 +1063,17 @@ static int kona_clk_prepare(struct clk_hw *hw) __ccu_write_disable(ccu); ccu_unlock(ccu, flags); + if (!ret) + clk_set_initialized(bcm_clk); + return ret; } static void kona_clk_unprepare(struct clk_hw *hw) { + struct kona_clk *bcm_clk = to_kona_clk(hw); + + WARN_ON(!clk_is_initialized(bcm_clk)); /* Nothing to do. */ } diff --git a/drivers/clk/bcm/clk-kona.h b/drivers/clk/bcm/clk-kona.h index 4c7e796..ea77ec1 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) \ { \