From patchwork Tue May 19 16:55:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 48759 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id EB1BE2121F for ; Tue, 19 May 2015 17:00:28 +0000 (UTC) Received: by wixv7 with SMTP id v7sf10098468wix.0 for ; Tue, 19 May 2015 10:00:28 -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=T43S+HIzRcKv2lXqXvcq0RCJuRMKyAiARcEbZ18uTss=; b=brapeIq0+9DAKdwGK+sJedsLe6flNY9axpLiECHwr6b3E5CLr5LCyPwMidRK6+LFD8 wJb6vP4E/66KHaxJYRNl9TW7Jsl6yyOeR1YqfRKDSm0Eliq1b/2lmIyR7yDcgh6lUWGN VkPH+dhNoFS2ho3F3dC3kvoTu+AwvfAeMxlvSNndifDddsmuEZbHFLPo2iaht/k+9plE zDDnlDfQ4YsT8An+Z98LiQTHqhqofJE+L5YsFSJgA68P6/pdO08EASI5TV2mHAemxxfd 7LsVb9bRMaPAl0cuZMPiUe5FV9MJC+CvZSWME8AAAifhVdl3SYSHD8MkEevwJxkUHtG5 /Dzg== X-Gm-Message-State: ALoCoQlOKYo45RIBmz6GCyYfUF8+hpHUiIENoZDj+Xy1TTG15JLpwGi+0Seq0HqIRi3Rch8jwPQb X-Received: by 10.112.29.39 with SMTP id g7mr22549962lbh.1.1432054828173; Tue, 19 May 2015 10:00:28 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.23.232 with SMTP id p8ls93766laf.13.gmail; Tue, 19 May 2015 10:00:28 -0700 (PDT) X-Received: by 10.152.26.130 with SMTP id l2mr22665570lag.20.1432054828005; Tue, 19 May 2015 10:00:28 -0700 (PDT) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id c17si3160633lbq.1.2015.05.19.10.00.27 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 May 2015 10:00:27 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by lagr1 with SMTP id r1so33909424lag.0 for ; Tue, 19 May 2015 10:00:27 -0700 (PDT) X-Received: by 10.112.161.226 with SMTP id xv2mr23021237lbb.106.1432054827862; Tue, 19 May 2015 10:00:27 -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.112.108.230 with SMTP id hn6csp940701lbb; Tue, 19 May 2015 10:00:26 -0700 (PDT) X-Received: by 10.68.57.239 with SMTP id l15mr30110949pbq.93.1432054825901; Tue, 19 May 2015 10:00:25 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w2si22164137pde.152.2015.05.19.10.00.18; Tue, 19 May 2015 10:00:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755536AbbESQ72 (ORCPT + 28 others); Tue, 19 May 2015 12:59:28 -0400 Received: from mail-pd0-f178.google.com ([209.85.192.178]:32820 "EHLO mail-pd0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751428AbbESQzu (ORCPT ); Tue, 19 May 2015 12:55:50 -0400 Received: by pdbqa5 with SMTP id qa5so33049044pdb.0 for ; Tue, 19 May 2015 09:55:49 -0700 (PDT) X-Received: by 10.66.123.81 with SMTP id ly17mr33984966pab.31.1432054549750; Tue, 19 May 2015 09:55:49 -0700 (PDT) Received: from t430.cg.shawcable.net ([184.64.168.246]) by mx.google.com with ESMTPSA id rx6sm11817453pbc.54.2015.05.19.09.55.48 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 19 May 2015 09:55:49 -0700 (PDT) From: Mathieu Poirier To: gregkh@linuxfoundation.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, zhang.chunyan@linaro.org, kaixu.xia@linaro.org, mathieu.poirier@linaro.org Subject: [PATCH 07/16] coresight: funnel: let runtime PM handle core clock Date: Tue, 19 May 2015 10:55:12 -0600 Message-Id: <1432054521-24807-8-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1432054521-24807-1-git-send-email-mathieu.poirier@linaro.org> References: <1432054521-24807-1-git-send-email-mathieu.poirier@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: mathieu.poirier@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.215.46 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: , From: Linus Walleij This uses runtime PM to manage the PCLK ("amba_pclk") instead of screwing around with the framework by going in and taking a copy from the amba device. The amba bus core will unprepare and disable the clock when the device is unused when CONFIG_PM is selected, else the clock will be always on. Prior to this patch, as the AMBA primecell bus code enables the PCLK, it would be left on after probe as clk_disable_unprepare() was not called. Now the runtime PM callbacks will make sure the PCLK is properly disabled after probe. Reviewed-by: Ulf Hansson Signed-off-by: Linus Walleij Signed-off-by: Mathieu Poirier --- drivers/hwtracing/coresight/coresight-funnel.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-funnel.c b/drivers/hwtracing/coresight/coresight-funnel.c index 3db36f70b666..330de2c88759 100644 --- a/drivers/hwtracing/coresight/coresight-funnel.c +++ b/drivers/hwtracing/coresight/coresight-funnel.c @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include @@ -36,14 +36,12 @@ * @base: memory mapped base address for this component. * @dev: the device entity associated to this component. * @csdev: component vitals needed by the framework. - * @clk: the clock this component is associated to. * @priority: port selection order. */ struct funnel_drvdata { void __iomem *base; struct device *dev; struct coresight_device *csdev; - struct clk *clk; unsigned long priority; }; @@ -67,12 +65,8 @@ static int funnel_enable(struct coresight_device *csdev, int inport, int outport) { struct funnel_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); - int ret; - - ret = clk_prepare_enable(drvdata->clk); - if (ret) - return ret; + pm_runtime_get_sync(drvdata->dev); funnel_enable_hw(drvdata, inport); dev_info(drvdata->dev, "FUNNEL inport %d enabled\n", inport); @@ -98,8 +92,7 @@ static void funnel_disable(struct coresight_device *csdev, int inport, struct funnel_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); funnel_disable_hw(drvdata, inport); - - clk_disable_unprepare(drvdata->clk); + pm_runtime_put(drvdata->dev); dev_info(drvdata->dev, "FUNNEL inport %d disabled\n", inport); } @@ -153,16 +146,14 @@ static u32 get_funnel_ctrl_hw(struct funnel_drvdata *drvdata) static ssize_t funnel_ctrl_show(struct device *dev, struct device_attribute *attr, char *buf) { - int ret; u32 val; struct funnel_drvdata *drvdata = dev_get_drvdata(dev->parent); - ret = clk_prepare_enable(drvdata->clk); - if (ret) - return ret; + pm_runtime_get_sync(drvdata->dev); val = get_funnel_ctrl_hw(drvdata); - clk_disable_unprepare(drvdata->clk); + + pm_runtime_put(drvdata->dev); return sprintf(buf, "%#x\n", val); } @@ -205,8 +196,7 @@ static int funnel_probe(struct amba_device *adev, const struct amba_id *id) return PTR_ERR(base); drvdata->base = base; - - drvdata->clk = adev->pclk; + pm_runtime_put(&adev->dev); desc = devm_kzalloc(dev, sizeof(*desc), GFP_KERNEL); if (!desc)