From patchwork Fri Mar 23 09:36:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10303089 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 7D05360386 for ; Fri, 23 Mar 2018 09:36:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D62428C8F for ; Fri, 23 Mar 2018 09:36:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6235728D55; Fri, 23 Mar 2018 09:36: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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, 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 028B128C8F for ; Fri, 23 Mar 2018 09:36:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752306AbeCWJgb (ORCPT ); Fri, 23 Mar 2018 05:36:31 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:51104 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752254AbeCWJg2 (ORCPT ); Fri, 23 Mar 2018 05:36:28 -0400 Received: by mail-wm0-f67.google.com with SMTP id i75so2349343wmf.0 for ; Fri, 23 Mar 2018 02:36:27 -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=qtztQ/9TOPi+dkEP6jplsOMVA3ubNWNtfI7tSZpTpxI=; b=U/+jGi/QzDP5WqpQ7WIThZR+awrXeGD10WWxzSAq6CG9H1efrVllPxVCdZ48RDvEnw 2VKY2uD6AnJ+/KblJ92eddMZEZn80I1sYwbNoSwngoekhQ9rwvOiTKbY/JbWhYqR3FDr QRdQf0CwZsA3IJbsN3/XLNY9zcPuipaBdM36D8TXC9FbXTSY55gweol8iKUgou28ii1w KKhYEWuWx0mKe5BmCf8LnLmAmryf7g0n5Q1UpCsNnCDjNvUlmG0UM9yfLt1gYDJVvHHY PIsHYcPB3Tb/A0lcY/EK5H2iUTFmtPoU8vEh6fQLmC2yN2XMGZtBw9wW1ii171/u15RI nYgQ== 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=qtztQ/9TOPi+dkEP6jplsOMVA3ubNWNtfI7tSZpTpxI=; b=ir9coy+82lLnuH8J3gGyFHh1dJ6NaLS3c26Gm/uHdxNfsE+L/Q22Yyc2kZlVKqFRLN 39SyNavwRkGKXWq9Dak4JogL3Z7RADGTSshRSY6inRCQ6XgPySyf8ZAI/gmDNX3UtU+N ExPiXzfXLQ2gFfKb2ijskbs0UmgVxv9n9IUYWxBXsOi9sh+s9Q2bYAOveFAwM9yFaZyt LU3H4vod3fzw96P9KBrO0b6CPKVByNKPOOTKzHCZ79x7X29WCbDngIz83sxoC3teqC5J 1+BYFnLSsEEHbCbh5gO1EQPPEj2RBRfUhRyDp26uim6aBV9KBOQI0O827woJl74Sc8NX zBIg== X-Gm-Message-State: AElRT7E65I6aiIg/s4R5Sfg2WS5UJIowgZniMRidmJblcyLCzWD1zrAH FUcHdyja8YyvteqNDzb/3FDzgg== X-Google-Smtp-Source: AG47ELvK9O6wNk+rOEP9TNTe3ppvetCY6hgbMl3sogkm3SYU4AU1yrQgsWClxtTAFHyPevVVZzF2Dg== X-Received: by 10.28.227.66 with SMTP id a63mr7749066wmh.6.1521797786442; Fri, 23 Mar 2018 02:36:26 -0700 (PDT) Received: from brgl-bgdev.lan (LFbn-NIC-1-208-99.w2-15.abo.wanadoo.fr. [2.15.55.99]) by smtp.gmail.com with ESMTPSA id s125sm8045203wmf.4.2018.03.23.02.36.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Mar 2018 02:36:25 -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 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 v2 7/8] remoteproc: da8xx: use the reset framework Date: Fri, 23 Mar 2018 10:36:08 +0100 Message-Id: <20180323093609.24576-8-brgl@bgdev.pl> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180323093609.24576-1-brgl@bgdev.pl> References: <20180323093609.24576-1-brgl@bgdev.pl> Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@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 --- 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 f134192922e0..b99c0f0cc38e 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,11 @@ 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); + return ret; + } return 0; } @@ -163,8 +168,15 @@ static int da8xx_rproc_start(struct rproc *rproc) static int da8xx_rproc_stop(struct rproc *rproc) { struct da8xx_rproc *drproc = rproc->priv; + int ret; + + ret = reset_control_assert(drproc->dsp_reset); + if (ret) { + dev_err(rproc->dev.parent, + "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 +244,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 +281,17 @@ 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)) { + /* The platform lookup may not be registered yet. */ + if (PTR_ERR(dsp_reset) == -ENOENT) + return -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) { @@ -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;