From patchwork Thu May 29 14:05:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 31127 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f198.google.com (mail-ob0-f198.google.com [209.85.214.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1614A203E6 for ; Thu, 29 May 2014 14:07:16 +0000 (UTC) Received: by mail-ob0-f198.google.com with SMTP id va2sf1678863obc.5 for ; Thu, 29 May 2014 07:07:16 -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=tZ3/iC9ve8zlxSlrUM24RvUR3cpu4LDar6UfY5RYGrY=; b=H+FXajSU5lBptCpntwHCijQWHH/T0rwfk9VccgPfkhVgz45+vUUOed/xubVMgB6Wfq iBkIcOIhWgR8+vYse9kYB1ZnwcQTw0BhyAdoV6iNFHfDTUmaA/XlD5UVOIuA2nJ/IPO3 7RN+5HQWKQmvh0RQ8FOcdbW4fDbYeV6aw0eLBc7OWH1dpk9ZUbo5pETTiptfYz5NWiO7 Woo5Jayza3vvQFQGrK6ul86CQGrjNjrm5MnnL2L0ToqCY9lzFLrcgpaxEi1X6jLthBxG aWbzKkv0RL4DlBxr6K5jC7CVVAZ0yd+RqqrgyGWZki/AdVOfGLDdxCkqi4lWLqw1iyvk jsTw== X-Gm-Message-State: ALoCoQmZgTmUHYvMLha8PpaubEHrW2CGkHZ09gR4C9iEpFznsgLRa1Md8J+jAvC1EjJBvFZUosEK X-Received: by 10.42.89.69 with SMTP id f5mr2882884icm.28.1401372436539; Thu, 29 May 2014 07:07:16 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.104.234 with SMTP id a97ls586604qgf.51.gmail; Thu, 29 May 2014 07:07:16 -0700 (PDT) X-Received: by 10.220.166.211 with SMTP id n19mr1055877vcy.69.1401372436369; Thu, 29 May 2014 07:07:16 -0700 (PDT) Received: from mail-vc0-f179.google.com (mail-vc0-f179.google.com [209.85.220.179]) by mx.google.com with ESMTPS id 5si531138vdy.104.2014.05.29.07.07.16 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 29 May 2014 07:07:16 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.179 as permitted sender) client-ip=209.85.220.179; Received: by mail-vc0-f179.google.com with SMTP id im17so432342vcb.10 for ; Thu, 29 May 2014 07:07:16 -0700 (PDT) X-Received: by 10.58.216.163 with SMTP id or3mr875254vec.80.1401372436256; Thu, 29 May 2014 07:07:16 -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 ib8csp31272vcb; Thu, 29 May 2014 07:07:15 -0700 (PDT) X-Received: by 10.66.146.170 with SMTP id td10mr9208549pab.105.1401372435311; Thu, 29 May 2014 07:07:15 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qg1si1117467pac.75.2014.05.29.07.07.14 for ; Thu, 29 May 2014 07:07:14 -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 S1757531AbaE2OHD (ORCPT + 27 others); Thu, 29 May 2014 10:07:03 -0400 Received: from mail-ie0-f171.google.com ([209.85.223.171]:57697 "EHLO mail-ie0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965128AbaE2OGH (ORCPT ); Thu, 29 May 2014 10:06:07 -0400 Received: by mail-ie0-f171.google.com with SMTP id to1so323681ieb.2 for ; Thu, 29 May 2014 07:06:05 -0700 (PDT) X-Received: by 10.50.79.195 with SMTP id l3mr10951030igx.36.1401372365803; Thu, 29 May 2014 07:06:05 -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 ng17sm2510130igb.13.2014.05.29.07.06.04 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 May 2014 07:06:05 -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 v3 2/5] clk: bcm281xx: implement prerequisite clocks Date: Thu, 29 May 2014 09:05:58 -0500 Message-Id: <1401372361-18842-3-git-send-email-elder@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1401372361-18842-1-git-send-email-elder@linaro.org> References: <1401372361-18842-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.179 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: , Allow a clock to specify a "prerequisite" clock. The prerequisite clock must be initialized before the clock that depends on it. A prerequisite clock is defined initially by its name; as that clock gets initialized the name gets replaced with a pointer to its clock structure pointer. Rework the KONA_CLK() macro, and define a new KONA_CLK_PREREQ() variant that allows a prerequisite clock to be specified. There exist clocks that could specify more than one prequisite, but almost all clocks only ever use one. We can add support for more than one if we find we need it at some point. Signed-off-by: Alex Elder --- drivers/clk/bcm/clk-kona.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ drivers/clk/bcm/clk-kona.h | 19 ++++++++++++++++--- 2 files changed, 61 insertions(+), 3 deletions(-) diff --git a/drivers/clk/bcm/clk-kona.c b/drivers/clk/bcm/clk-kona.c index 9691b62..d08b3e9 100644 --- a/drivers/clk/bcm/clk-kona.c +++ b/drivers/clk/bcm/clk-kona.c @@ -1247,6 +1247,48 @@ static bool __peri_clk_init(struct kona_clk *bcm_clk) return true; } +static bool __kona_clk_init(struct kona_clk *bcm_clk); +static bool __kona_prereq_init(struct kona_clk *bcm_clk) +{ + struct clk *clk; + struct clk_hw *hw; + struct kona_clk *prereq; + + BUG_ON(clk_is_initialized(bcm_clk)); + + if (!bcm_clk->p.prereq) + return true; + + clk = clk_get(NULL, bcm_clk->p.prereq); + if (IS_ERR(clk)) { + pr_err("%s: unable to get prereq clock %s for %s\n", + __func__, bcm_clk->p.prereq, bcm_clk->init_data.name); + return false; + } + hw = __clk_get_hw(clk); + if (!hw) { + pr_err("%s: null hw pointer for clock %s\n", __func__, + bcm_clk->init_data.name); + return false; + } + prereq = to_kona_clk(hw); + if (prereq->ccu != bcm_clk->ccu) { + pr_err("%s: prereq clock %s CCU different for clock %s\n", + __func__, bcm_clk->p.prereq, bcm_clk->init_data.name); + return false; + } + + /* Initialize the prerequisite clock first */ + if (!__kona_clk_init(prereq)) { + pr_err("%s: failed to init prereq %s for clock %s\n", + __func__, bcm_clk->p.prereq, bcm_clk->init_data.name); + return false; + } + bcm_clk->p.prereq_clk = clk; + + return true; +} + static bool __kona_clk_init(struct kona_clk *bcm_clk) { bool ret; @@ -1254,6 +1296,9 @@ static bool __kona_clk_init(struct kona_clk *bcm_clk) if (clk_is_initialized(bcm_clk)) return true; + if (!__kona_prereq_init(bcm_clk)) + return false; + switch (bcm_clk->type) { case bcm_clk_peri: ret = __peri_clk_init(bcm_clk); diff --git a/drivers/clk/bcm/clk-kona.h b/drivers/clk/bcm/clk-kona.h index 10e238d..be00767 100644 --- a/drivers/clk/bcm/clk-kona.h +++ b/drivers/clk/bcm/clk-kona.h @@ -22,6 +22,8 @@ #include #include #include +#include +#include #define BILLION 1000000000 @@ -408,6 +410,10 @@ struct kona_clk { enum bcm_clk_type type; u32 flags; /* BCM_CLK_KONA_FLAGS_* below */ union { + const char *prereq; + struct clk *prereq_clk; + } p; + union { void *data; struct peri_clk_data *peri; } u; @@ -422,15 +428,22 @@ struct kona_clk { #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) \ - { \ +#define ___KONA_CLK_COMMON(_ccu_name, _clk_name, _type) \ .init_data = { \ .name = #_clk_name, \ .ops = &kona_ ## _type ## _clk_ops, \ }, \ .ccu = &_ccu_name ## _ccu_data, \ .type = bcm_clk_ ## _type, \ - .u.data = &_clk_name ## _data, \ + .u.data = &_clk_name ## _data +#define KONA_CLK_PREREQ(_ccu_name, _clk_name, _type, _prereq) \ + { \ + .p.prereq = #_prereq, \ + ___KONA_CLK_COMMON(_ccu_name, _clk_name, _type), \ + } +#define KONA_CLK(_ccu_name, _clk_name, _type) \ + { \ + ___KONA_CLK_COMMON(_ccu_name, _clk_name, _type), \ } #define LAST_KONA_CLK { .type = bcm_clk_none }