From patchwork Thu Jun 21 07:37:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10479367 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A8B7B602CB for ; Thu, 21 Jun 2018 07:38:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 97C2B28717 for ; Thu, 21 Jun 2018 07:38:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8BED52874F; Thu, 21 Jun 2018 07:38:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A5A3828717 for ; Thu, 21 Jun 2018 07:38:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754488AbeFUHiJ (ORCPT ); Thu, 21 Jun 2018 03:38:09 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:35278 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754385AbeFUHhO (ORCPT ); Thu, 21 Jun 2018 03:37:14 -0400 Received: by mail-wr0-f193.google.com with SMTP id l8-v6so2038815wrr.2 for ; Thu, 21 Jun 2018 00:37:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rjpY3jf6dyNELzucLqZKmEbF+4d8cHbiFvTao+E9Rzk=; b=BY3jTZJDROJTX5ddS8XvWoM/grdDGSMrr52ma1z+K8vPigsCTYr6PAMfv76eZoIzpi 81/dhAU5rn+9G5EVdI1chRx1SpywAN5h5n2g2dYUdDJbl9Q4sGIXvtZt++Rqxiy4pWuS 8SU1SYeB0uQuJ1dgeLmg9kJIiOTx1ri/dX8402+4Vrp/q1Vbcuw2RQOm47omO6dB13Z4 HVqRSiw6iKFfUzVSwyfIZd0rBQbQ3ekbNTE/DdiNw/oWJKAGdqUQo9jyD/FOD/vPzgf9 Ful3k5I+oiCYWtvJUI44uhGJ4Y/ulJZZbj/z7ed3A4IuHu/wNUFoI14+YajxeFXIfene MlTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rjpY3jf6dyNELzucLqZKmEbF+4d8cHbiFvTao+E9Rzk=; b=F26BnK7nRLSAaIHSlcwHxvfshW6Cd7qeXog9w00j60Y2hHyrwlNAbEcnC60p7qyg0v iv63NjbmGuSd4str/WL1vxLe6EVZXTC9OQEXQnITK9q0RqJ5SfpBEz0yo7LOg2MOZTyY xGPhtRUktuTx1KsdMmTA9t9o0aNnCj8AmbMCV6yice56LMvmpCKnXrwx06XP/yi1ft5v 6+3H46VUms3Jbec1wEzHIyCxiu4QoMMj64zWbZMI2m8G59agC8Za5SRcDdPAbkqm/gD2 jxRhRB6dXFlZbo6xSZcZkRo+dNPWO2QDsRPDIwk4ZbOfYW35tKSrg6J95GZci6I91l0G NJfw== X-Gm-Message-State: APt69E0pdCj2Nh7AZKGnJ+o/aIfA1kBy1H9fYrzPVTSc4SStXlih3BcP jS9zdbYrVwoKVdOO5bfdJAo28g== X-Google-Smtp-Source: ADUXVKJAg/lY1LiN9zDnnIu1N1P7YOOXSWqrqG256kBl+ZKorvcKngLAvqcsRuwWwwYsz9AdHSgKeg== X-Received: by 2002:adf:9663:: with SMTP id c32-v6mr21717365wra.89.1529566633363; Thu, 21 Jun 2018 00:37:13 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id l7-v6sm767635wmh.1.2018.06.21.00.37.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Jun 2018 00:37:12 -0700 (PDT) From: Bartosz Golaszewski To: Sekhar Nori , Kevin Hilman , Rob Herring , Mark Rutland , Russell King , David Lechner , Michael Turquette , Stephen Boyd , Ohad Ben-Cohen , Bjorn Andersson Cc: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-remoteproc@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v7 1/4] remoteproc/davinci: use the reset framework Date: Thu, 21 Jun 2018 09:37:03 +0200 Message-Id: <20180621073706.22812-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180621073706.22812-1-brgl@bgdev.pl> References: <20180621073706.22812-1-brgl@bgdev.pl> Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Bartosz Golaszewski Switch to using the reset framework instead of handcoded reset routines we used so far. Signed-off-by: Bartosz Golaszewski Reviewed-by: Sekhar Nori Reviewed-by: Philipp Zabel Acked-by: Bjorn Andersson --- drivers/remoteproc/da8xx_remoteproc.c | 34 +++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/drivers/remoteproc/da8xx_remoteproc.c b/drivers/remoteproc/da8xx_remoteproc.c index b668e32996e2..76c06b70a1c6 100644 --- a/drivers/remoteproc/da8xx_remoteproc.c +++ b/drivers/remoteproc/da8xx_remoteproc.c @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -20,8 +21,6 @@ #include #include -#include /* for davinci_clk_reset_assert/deassert() */ - #include "remoteproc_internal.h" static char *da8xx_fw_name; @@ -72,6 +71,7 @@ struct da8xx_rproc { struct da8xx_rproc_mem *mem; int num_mems; struct clk *dsp_clk; + struct reset_control *dsp_reset; void (*ack_fxn)(struct irq_data *data); struct irq_data *irq_data; void __iomem *chipsig; @@ -138,6 +138,7 @@ static int da8xx_rproc_start(struct rproc *rproc) struct device *dev = rproc->dev.parent; struct da8xx_rproc *drproc = (struct da8xx_rproc *)rproc->priv; struct clk *dsp_clk = drproc->dsp_clk; + struct reset_control *dsp_reset = drproc->dsp_reset; int ret; /* hw requires the start (boot) address be on 1KB boundary */ @@ -155,7 +156,12 @@ static int da8xx_rproc_start(struct rproc *rproc) return ret; } - davinci_clk_reset_deassert(dsp_clk); + ret = reset_control_deassert(dsp_reset); + if (ret) { + dev_err(dev, "reset_control_deassert() failed: %d\n", ret); + clk_disable_unprepare(dsp_clk); + return ret; + } return 0; } @@ -163,8 +169,15 @@ static int da8xx_rproc_start(struct rproc *rproc) static int da8xx_rproc_stop(struct rproc *rproc) { struct da8xx_rproc *drproc = rproc->priv; + struct device *dev = rproc->dev.parent; + int ret; + + ret = reset_control_assert(drproc->dsp_reset); + if (ret) { + dev_err(dev, "reset_control_assert() failed: %d\n", ret); + return ret; + } - davinci_clk_reset_assert(drproc->dsp_clk); clk_disable_unprepare(drproc->dsp_clk); return 0; @@ -232,6 +245,7 @@ static int da8xx_rproc_probe(struct platform_device *pdev) struct resource *bootreg_res; struct resource *chipsig_res; struct clk *dsp_clk; + struct reset_control *dsp_reset; void __iomem *chipsig; void __iomem *bootreg; int irq; @@ -268,6 +282,15 @@ static int da8xx_rproc_probe(struct platform_device *pdev) return PTR_ERR(dsp_clk); } + dsp_reset = devm_reset_control_get_exclusive(dev, NULL); + if (IS_ERR(dsp_reset)) { + if (PTR_ERR(dsp_reset) != -EPROBE_DEFER) + dev_err(dev, "unable to get reset control: %ld\n", + PTR_ERR(dsp_reset)); + + return PTR_ERR(dsp_reset); + } + if (dev->of_node) { ret = of_reserved_mem_device_init(dev); if (ret) { @@ -287,6 +310,7 @@ static int da8xx_rproc_probe(struct platform_device *pdev) drproc = rproc->priv; drproc->rproc = rproc; drproc->dsp_clk = dsp_clk; + drproc->dsp_reset = dsp_reset; rproc->has_iommu = false; ret = da8xx_rproc_get_internal_memories(pdev, drproc); @@ -309,7 +333,7 @@ static int da8xx_rproc_probe(struct platform_device *pdev) * *not* in reset, but da8xx_rproc_start() needs the DSP to be * held in reset at the time it is called. */ - ret = davinci_clk_reset_assert(drproc->dsp_clk); + ret = reset_control_assert(dsp_reset); if (ret) goto free_rproc;