From patchwork Fri Mar 30 15:28:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10317903 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 917B46063D for ; Fri, 30 Mar 2018 15:32:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8087E28949 for ; Fri, 30 Mar 2018 15:32:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 74D0F28C03; Fri, 30 Mar 2018 15:32:47 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 026DD28BB6 for ; Fri, 30 Mar 2018 15:32:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=ABNSjFBfVWPjrFHZ7M1LTdrQXkLvuTx24CbzJxIKdBs=; b=jW1lXOmJ76gHiTseWzSLZV34CQ vBrWy8lzM44PYfKMjom67PSGIbSNRk28UYLou5n36mLu9Wnyye4qpvHsx3ocMwD7M+3X7uDEOz2RG HBQS3He13Af0PEXUw4ZHOSsBjhIxNHhPo1T98AxkK1y1xx92U7olEGDupakkU3gNdAIsOEpy5HY2t cTsF5o0OV73bNeVwFE1agEDq/zBcL3gXzUq8Fd20veJ4hJwU/CL1bq94I+k1NNIwCP2pnalgw7+BW NlFerOTmC2wV+kM9+jPO6Z/EQ7WWeerb5hChS/Ze1bvTSKfIQ8am89dXA2giVO2VdP3lV7tDotuSi 0HvQ4+zQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1f1w18-0006KA-Hb; Fri, 30 Mar 2018 15:32:38 +0000 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f1vxr-0003Yp-AG for linux-arm-kernel@lists.infradead.org; Fri, 30 Mar 2018 15:29:16 +0000 Received: by mail-wm0-x244.google.com with SMTP id r131so17265832wmb.2 for ; Fri, 30 Mar 2018 08:29:10 -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=4aOE1cBJK6+a3WSpuJdQVMX+6l4vKRSi1H4WXYh1kT8=; b=sOuJ9/S3QNJLsc9+nLbvYSZa2z29/Vu35K2gglPWJyHboBzEoKOVbYCSDsXUp/CHzg XTP6T25rwAgpjLxWztuFzICI2n0pwNXVCwTIeZ+0Cd0WAEUXunQQsozkGepuBNiKQOdo vqg30Pe5TPYKc3bcvsIbvhPbLbfXV84KwuqRur2GSEMhRvvwzxK3doP2FxvKJp2y7dCo 12j1QSHX7punzmk8aHrrdojOmFJbdWiYfv9ac9FfwjBv1CJjZY8iTjd7CZ8kzCsz/SLu PZuS5jZlnieib0WWLTOB3mphKlcf1Fgw++8sBDJUOmESwTWkjpaWfLGdtJFRYiwNCSmg 6xjQ== 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=4aOE1cBJK6+a3WSpuJdQVMX+6l4vKRSi1H4WXYh1kT8=; b=Upw7ibQcucIK0iQ7TAOkteaePI5fTrRgvip8jmkPazYLnjD2JFHWUMXw+57Km9l5t8 /v9nsyvGQ+No3mTKtz1muM830VdDiorSzCbzYoR1+tcyn88jbIXis8X7IfowPPycgVPw zPsnEuBS3D0bFZj+sywRvMCNaR0yWuS/eKPaQZlZb4We93mRctEm+PR39J8lkSuGQkAw HqcuS2ATXruIB7cohLXJu9KJjqErawi7inV7UYloMTqxwPc3tGSpdhp0DdksL39Z2587 VBo03nhsOpByxL5j7DW2VmbAvNP95NwB34zE9FnKXaOnCdgVVvjIsCJEwDrNcfBpZcoq Jpaw== X-Gm-Message-State: AElRT7GuaBE+2IwAVI69MDE901NVI1uu/zZEBNaX8fbZMbika5uiF/MO NtnT0cH8UTslj2hRhikfUFErCA== X-Google-Smtp-Source: AIpwx4/Hrity2Ev1hynSblV+Ae1gNbj3127T946DRt29UDqdtCAk8Fc0mU5kJHLWQvXUB/Uhl6nURg== X-Received: by 10.28.177.215 with SMTP id a206mr2567359wmf.142.1522423749309; Fri, 30 Mar 2018 08:29:09 -0700 (PDT) Received: from brgl-bgdev.baylibre.local ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id n49sm14429881wrn.90.2018.03.30.08.29.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Mar 2018 08:29:08 -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 , Philipp Zabel Subject: [PATCH v5 7/8] remoteproc/davinci: use the reset framework Date: Fri, 30 Mar 2018 17:28:55 +0200 Message-Id: <20180330152856.12297-8-brgl@bgdev.pl> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180330152856.12297-1-brgl@bgdev.pl> References: <20180330152856.12297-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180330_082915_366495_40056E04 X-CRM114-Status: GOOD ( 18.19 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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 --- 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;