From patchwork Sat May 24 00:53:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Turquette X-Patchwork-Id: 30861 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f72.google.com (mail-pa0-f72.google.com [209.85.220.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id F3ABE2066E for ; Sat, 24 May 2014 00:54:16 +0000 (UTC) Received: by mail-pa0-f72.google.com with SMTP id rd3sf21818645pab.11 for ; Fri, 23 May 2014 17:54: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:delivered-to:mime-version:to:from:in-reply-to:cc :references:message-id:user-agent:subject:date:sender:precedence :list-id:x-original-sender:x-original-authentication-results :mailing-list:list-post:list-help:list-archive:list-unsubscribe :content-type:content-transfer-encoding; bh=5NgWqQp76YsiEKbzAWIohVxAwA3HU2PhW6FM9a2Pwhc=; b=PTwYmGJnSmGlAMSsbgtf53Rk4Hv42xTRn1G5XP5jjCC+EP2uxH89LLqY71Q/PQlst4 N1Bg0RuU0JZU+zd7Y99Qxh/QiiaKpZkeeWRdzZQn71twtTuBtcDLlDj2zo7XaGL0uG5v WLpJjHMwmlowejrjoK/E7jQ3WBzgpJx72Mz6uDb6X1Fn/pDQyCLP29s01Xvkf3vP15np tep50pvPxTQnZvgE7VGUUrRnCwluBsX3zlw6rrorBzDExu1V6ecBzf+RMduoudeDFNMG 7tAeYKL71BQmRpZaPwsz+We2uh7w5PneQA+h1K9e3cxS4dAKli7KneSrtV/Rlr+nDGnZ NlNA== X-Gm-Message-State: ALoCoQm6O3WfyKRuF5Nw2o96tSxOefgWV3UglxbsXSJJOZt2fTLer87FqjklNPxP3fHlGWxAcwBH X-Received: by 10.66.142.9 with SMTP id rs9mr3766080pab.47.1400892855916; Fri, 23 May 2014 17:54:15 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.85.40 with SMTP id m37ls1957944qgd.18.gmail; Fri, 23 May 2014 17:54:15 -0700 (PDT) X-Received: by 10.58.228.163 with SMTP id sj3mr7134760vec.28.1400892855758; Fri, 23 May 2014 17:54:15 -0700 (PDT) Received: from mail-ve0-f177.google.com (mail-ve0-f177.google.com [209.85.128.177]) by mx.google.com with ESMTPS id rn6si2684251vcb.80.2014.05.23.17.54.15 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 23 May 2014 17:54:15 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.177 as permitted sender) client-ip=209.85.128.177; Received: by mail-ve0-f177.google.com with SMTP id db11so7022068veb.22 for ; Fri, 23 May 2014 17:54:15 -0700 (PDT) X-Received: by 10.221.29.137 with SMTP id ry9mr7151091vcb.6.1400892855601; Fri, 23 May 2014 17:54: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.220.221.72 with SMTP id ib8csp71566vcb; Fri, 23 May 2014 17:54:15 -0700 (PDT) X-Received: by 10.68.137.193 with SMTP id qk1mr10152657pbb.155.1400892854784; Fri, 23 May 2014 17:54:14 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id aq3si5984437pbc.124.2014.05.23.17.54.14; Fri, 23 May 2014 17:54:14 -0700 (PDT) Received-SPF: none (google.com: devicetree-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 S1751074AbaEXAyL (ORCPT + 8 others); Fri, 23 May 2014 20:54:11 -0400 Received: from mail-pb0-f54.google.com ([209.85.160.54]:46513 "EHLO mail-pb0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750985AbaEXAyK convert rfc822-to-8bit (ORCPT ); Fri, 23 May 2014 20:54:10 -0400 Received: by mail-pb0-f54.google.com with SMTP id jt11so4881042pbb.13 for ; Fri, 23 May 2014 17:54:09 -0700 (PDT) X-Received: by 10.68.129.99 with SMTP id nv3mr10114400pbb.128.1400892849673; Fri, 23 May 2014 17:54:09 -0700 (PDT) Received: from localhost ([2601:9:5900:1fe:ca60:ff:fe0a:8a36]) by mx.google.com with ESMTPSA id nf5sm6542935pbc.77.2014.05.23.17.54.07 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 23 May 2014 17:54:08 -0700 (PDT) MIME-Version: 1.0 To: Alex Elder , mporter@linaro.org, bcm@fixthebug.org, devicetree@vger.kernel.org From: Mike Turquette In-Reply-To: <1400590362-11177-3-git-send-email-elder@linaro.org> Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <1400590362-11177-1-git-send-email-elder@linaro.org> <1400590362-11177-3-git-send-email-elder@linaro.org> Message-ID: <20140524005358.23136.8918@quantum> User-Agent: alot/0.3.5 Subject: Re: [PATCH v2 2/5] clk: bcm281xx: implement prerequisite clocks Date: Fri, 23 May 2014 17:53:58 -0700 Sender: devicetree-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: devicetree@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: mturquette@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.177 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: , Quoting Alex Elder (2014-05-20 05:52:39) > @@ -743,11 +746,16 @@ struct clk *kona_clk_setup(struct kona_clk *bcm_clk) > clk = clk_register(NULL, &bcm_clk->hw); > if (IS_ERR(clk)) { > pr_err("%s: error registering clock %s (%ld)\n", __func__, > - init_data->name, PTR_ERR(clk)); > + name, PTR_ERR(clk)); > goto out_teardown; > } > BUG_ON(!clk); > > + /* Make it so we can look the clock up using clk_find() */ s/clk_find/clk_get/ ? > + bcm_clk->cl.con_id = name; > + bcm_clk->cl.clk = clk; > + clkdev_add(&bcm_clk->cl); This is not so nice. I'll explain more below. > + > return clk; > out_teardown: > bcm_clk_teardown(bcm_clk); > diff --git a/drivers/clk/bcm/clk-kona.c b/drivers/clk/bcm/clk-kona.c > index d8a7f38..fd070d6 100644 > --- a/drivers/clk/bcm/clk-kona.c > +++ b/drivers/clk/bcm/clk-kona.c > @@ -1195,6 +1195,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); The clkdev global namespace is getting polluted with all of these new prereq clocks. If there was an associated struct device *dev with them then it wouldn't be a problem, but you might get collisions with other clock drivers that also use NULL for the device. It would be a lot nicer for the clocks that require a prereq clock to just use clk_get(dev, "well_known_name"); in the same way that drivers use it, without considering it a special case. > + 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; The above seems like a lot effort to go to. Why not skip all of this and just implement the prerequisite logic in the .enable & .disable callbacks? E.g. your kona clk .enable callback would look like: I guess it might take some trickery to get clk_get to work like that. Let me know if I've completely lost the plot. Regards, Mike --- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/clk/bcm/clk-kona.c b/drivers/clk/bcm/clk-kona.c index d603c4e..51f35b4 100644 --- a/drivers/clk/bcm/clk-kona.c +++ b/drivers/clk/bcm/clk-kona.c @@ -987,6 +987,12 @@ static int kona_peri_clk_enable(struct clk_hw *hw) { struct kona_clk *bcm_clk = to_kona_clk(hw); struct bcm_clk_gate *gate = &bcm_clk->u.peri->gate; + int ret; + + hw->prereq_bus_clk = clk_get(hw->ccu, hw->prereq); + ret = clk_enable(prereq_bus_clk); + if (ret) + return ret; return clk_gate(bcm_clk->ccu, bcm_clk->init_data.name, gate, true); } @@ -997,6 +1003,9 @@ static void kona_peri_clk_disable(struct clk_hw *hw) struct bcm_clk_gate *gate = &bcm_clk->u.peri->gate; (void)clk_gate(bcm_clk->ccu, bcm_clk->init_data.name, gate, false); + + clk_disable(hw->prereq_bus_clk); + clk_put(hw->prereq_bus_clk); } static int kona_peri_clk_is_enabled(struct clk_hw *hw)