From patchwork Mon Jun 2 22:44:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 4284391 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 75596BEEA7 for ; Mon, 2 Jun 2014 22:48:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A8B0B200D7 for ; Mon, 2 Jun 2014 22:48:18 +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 AC44320170 for ; Mon, 2 Jun 2014 22:48:17 +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 1Wrayy-0004WN-Cu; Mon, 02 Jun 2014 22:45:32 +0000 Received: from mail-ie0-f180.google.com ([209.85.223.180]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Wrayl-0003O8-To for linux-arm-kernel@lists.infradead.org; Mon, 02 Jun 2014 22:45:20 +0000 Received: by mail-ie0-f180.google.com with SMTP id tp5so5015501ieb.25 for ; Mon, 02 Jun 2014 15:44:58 -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=jqZXf+nP0WEC2khRIt2IyFX6z/lxfmjFD3dQAOehHD/J1tIfLmtfClrtZ16JQps2+i hZPEmQ/7qeZWFRaGw+tFmyej//MES48lPjPDZyVsFwKbvriALfSBEVOApwwsS0gjii1H drr3lbPIGNuwBMOkkFz1VkWRi3UPCxkTvw0oX6c67ciaHPg/nQbeCpO9CVgtN0jSM3tL sm61aWexzLhHYXkZg/33T68Rw9M1M8FOFVmcgSmiC4bX3plS+cUnthqvSxDhOfsMTRXq ojPGv1V+2kKL11rt8SsN+m1znAEl4Ib+M7Chexocd+Q4nNcFzQr0M2kbJIBZtli9KtZa MLnA== X-Gm-Message-State: ALoCoQlNP+/G6gKMCZtbgtpGeNzT7vCS+AXPNhe9XCuJJYK/A1XNqOlqjPk1EzN3BdXD/Ry0srrF X-Received: by 10.42.91.73 with SMTP id o9mr6021808icm.69.1401749098825; Mon, 02 Jun 2014 15:44:58 -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.57 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 02 Jun 2014 15:44:58 -0700 (PDT) From: Alex Elder To: mturquette@linaro.org, mporter@linaro.org, bcm@fixthebug.org Subject: [PATCH v5 3/7] clk: bcm281xx: add an initialized flag Date: Mon, 2 Jun 2014 17:44:54 -0500 Message-Id: <1401749098-10185-4-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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140602_154520_019024_645E2144 X-CRM114-Status: GOOD ( 15.23 ) 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. 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) \ { \