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: 31307 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f70.google.com (mail-yh0-f70.google.com [209.85.213.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2399720AE6 for ; Mon, 2 Jun 2014 22:45:15 +0000 (UTC) Received: by mail-yh0-f70.google.com with SMTP id z6sf27991854yhz.9 for ; Mon, 02 Jun 2014 15:45:14 -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=izXuMShDlWjPOfdvju2S8hF+D9FbxwiLGH7e/tqiafwvgSWdUZnMFxEZ5SZG1GKhyM dWkQoXjZwdD/j6FQdyU0wa9nyvM0xQ1UohJkgKo7my28RTOMLXyu3qnkoqSdRNRP2VcS jK/Zub8fwBC3AlaI47Nz4Yeh3yYR4GNRgQOfHt9KuXF/Bzj3WTzgVIRxUuyXy7xCP0P9 hd2INNH2pPOH6psSsnK35rBiBlj1EfCLKwm6UCKjQpkk7dZOZr25Gf8hkPdhRoaZzNYF /Thr1/lvJYc7mECtzxl2pQdukGGtJY/jcD/XEqxsYtXH0epdO1TwBpxm0FVMEjxrKTIF IQRw== X-Gm-Message-State: ALoCoQkg+9tS704Mys43nJS1NffebfRX7OlLdprGRwO/PxEAZe37gWjkOj6mD0vdFMk50RFT4JS+ X-Received: by 10.58.119.100 with SMTP id kt4mr4708235veb.42.1401749114879; Mon, 02 Jun 2014 15:45:14 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.89.203 with SMTP id v69ls2219124qgd.6.gmail; Mon, 02 Jun 2014 15:45:14 -0700 (PDT) X-Received: by 10.220.92.193 with SMTP id s1mr4889633vcm.34.1401749114752; Mon, 02 Jun 2014 15:45:14 -0700 (PDT) Received: from mail-vc0-f173.google.com (mail-vc0-f173.google.com [209.85.220.173]) by mx.google.com with ESMTPS id x1si8825712vep.70.2014.06.02.15.45.14 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 02 Jun 2014 15:45:14 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.173 as permitted sender) client-ip=209.85.220.173; Received: by mail-vc0-f173.google.com with SMTP id ik5so2938624vcb.4 for ; Mon, 02 Jun 2014 15:45:14 -0700 (PDT) X-Received: by 10.52.110.105 with SMTP id hz9mr28189271vdb.9.1401749114663; Mon, 02 Jun 2014 15:45:14 -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.220.221.72 with SMTP id ib8csp132119vcb; Mon, 2 Jun 2014 15:45:14 -0700 (PDT) X-Received: by 10.68.254.5 with SMTP id ae5mr44116989pbd.83.1401749113675; Mon, 02 Jun 2014 15:45:13 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id av9si17543106pbd.28.2014.06.02.15.45.13; Mon, 02 Jun 2014 15:45: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 S932094AbaFBWpD (ORCPT + 27 others); Mon, 2 Jun 2014 18:45:03 -0400 Received: from mail-ig0-f169.google.com ([209.85.213.169]:40597 "EHLO mail-ig0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753088AbaFBWo7 (ORCPT ); Mon, 2 Jun 2014 18:44:59 -0400 Received: by mail-ig0-f169.google.com with SMTP id hl10so3808459igb.0 for ; Mon, 02 Jun 2014 15:44:58 -0700 (PDT) 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 Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.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> 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.220.173 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) \ { \