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: 31967 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f198.google.com (mail-ig0-f198.google.com [209.85.213.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id BC285206A0 for ; Mon, 16 Jun 2014 13:41:15 +0000 (UTC) Received: by mail-ig0-f198.google.com with SMTP id uq10sf11627738igb.5 for ; Mon, 16 Jun 2014 06:41:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=bj/YKE0KHs//vmVhRrbAmP7sEwSuPPOXafwbK5Enh3g=; b=FscY6pqfTl4PHr7cRYuC6P4fzmJ5A7aQwnVtwbXiEEv6sStkCIeFwSPUN0aGIwk9J1 m3NLGviVnl2WCJRqyIb17sqyvij3iOcHnTCbWoK5Z36gQ8XLYOnyKTNX4yu7oKfZTPYj MSsNFY90HfDDxmbqRo7lPmaMINFOvVUePCMEqMslPVZNabTA/rIYAv8wSNymepH71URg mAdbOLKEkswi+a4p9nk9diClCwtRe4Z16LM9INd2MFe/fccg0Rrz9EdIlaNhOLS2d/Mz svNMsVx59PbZHY4ftrUwkS0Wfjxlq2O2MD77Ih2ZQKbMdrIpFVbtNiKTxR6qvoNBOhC8 +/yw== X-Gm-Message-State: ALoCoQnlhcvaIlHbu0TK6YwCoZznDQ4LLtRQRTfMKyD2BJy26WpN5fLFMvblQ3/jYjV98aMC8IaS X-Received: by 10.182.28.136 with SMTP id b8mr81473obh.19.1402926075294; Mon, 16 Jun 2014 06:41:15 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.80.81 with SMTP id b75ls4346706qgd.34.gmail; Mon, 16 Jun 2014 06:41:15 -0700 (PDT) X-Received: by 10.52.185.39 with SMTP id ez7mr13832658vdc.7.1402926075178; Mon, 16 Jun 2014 06:41:15 -0700 (PDT) Received: from mail-ve0-f172.google.com (mail-ve0-f172.google.com [209.85.128.172]) by mx.google.com with ESMTPS id o6si4113793vcr.56.2014.06.16.06.41.15 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 16 Jun 2014 06:41:15 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.172 as permitted sender) client-ip=209.85.128.172; Received: by mail-ve0-f172.google.com with SMTP id jz11so6030561veb.17 for ; Mon, 16 Jun 2014 06:41:15 -0700 (PDT) X-Received: by 10.221.51.77 with SMTP id vh13mr610208vcb.41.1402926075087; Mon, 16 Jun 2014 06:41:15 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.54.6 with SMTP id vs6csp135912vcb; Mon, 16 Jun 2014 06:41:14 -0700 (PDT) X-Received: by 10.68.196.137 with SMTP id im9mr24320811pbc.105.1402926073882; Mon, 16 Jun 2014 06:41:13 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fa1si10989710pbd.125.2014.06.16.06.41.13; Mon, 16 Jun 2014 06:41:13 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754189AbaFPNlL (ORCPT + 7 others); Mon, 16 Jun 2014 09:41:11 -0400 Received: from mail-ie0-f182.google.com ([209.85.223.182]:46917 "EHLO mail-ie0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753611AbaFPNjx (ORCPT ); Mon, 16 Jun 2014 09:39:53 -0400 Received: by mail-ie0-f182.google.com with SMTP id rp18so5020289iec.27 for ; Mon, 16 Jun 2014 06:39:52 -0700 (PDT) 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 Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.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> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: elder@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.172 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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) \ { \