From patchwork Tue Mar 27 09:20:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10309611 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 A99A460212 for ; Tue, 27 Mar 2018 09:20:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 983FB29C3E for ; Tue, 27 Mar 2018 09:20:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C5DE29C3F; Tue, 27 Mar 2018 09:20:53 +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 253F429C40 for ; Tue, 27 Mar 2018 09:20:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752258AbeC0JUu (ORCPT ); Tue, 27 Mar 2018 05:20:50 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:40801 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751106AbeC0JUq (ORCPT ); Tue, 27 Mar 2018 05:20:46 -0400 Received: by mail-wr0-f196.google.com with SMTP id z8so21630071wrh.7 for ; Tue, 27 Mar 2018 02:20:45 -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=bxYahFQx3XoeG5bMbnub7b0Bflb9wg52zn23L5bL7k4=; b=GDgGDpYE4mP9ZGAbpURzeqeIUTAKjoI8ateq3q9suXKY56uFKVkOIxJlqKVmddBaMg ssuGiBjrmoz4b2Dg6CNOOWm/Nyg5AANwz++vmeKoHpsqCDH8y5e5tm4kJW4u0MK1LE3f K1WM55LFYRwmdWzAueJAZtGhJUrmb9XKxo6ogJr09QQyu9dtcYNInu3hWRu0qRJADdtJ qirqrmIFsF14qxvz0GrTbYwu19+RZJevKE0QttWz+aTIDy7TgKZJ/6kXKJo/9siHR5mQ 8ZO8VKniuuqEY9h/x1OAmAD5871cmDOIVMpAYm5/1jZRzlCXnEuU4B40LmnrsWq/NsVl StjQ== 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=bxYahFQx3XoeG5bMbnub7b0Bflb9wg52zn23L5bL7k4=; b=rEY+sffKDeSKciYnPIHqjNn1Mvmki5CP38Q6EcLfqqlJ5X7ODwxr1nnAiqog05jh+4 QgOapvrU9nfjJUCWjpK0Y+v76P52vfcSH/SgDmt6klv1kUWCJ7erKpgujBp8XWnj0n1v qCWC15hOI0cBO/mKPgb+i07xSZFjZVnyj5lK0/kw3ht2oPSI8TTs3OXzEl1p8vNzpvlg guidskBPZowaGyE2i+ZmUaJbVINweixM8wgOvL4jPivWPw7Nwc5blFx1op1ZGJPl3l0s m8Mz+60L/Fe0aLFHB7TvAezBRukUWfDqN7Kbl/m96x34UVEGKrUwShg53AfCNWt8WiQJ jUcQ== X-Gm-Message-State: AElRT7G8N709oanSPhIty33AcVhRuEaGY8Jvk7utfmY9f+Aw4i1X3WBz a0mfSbRag35F16+7+mfQez/+Qw== X-Google-Smtp-Source: AG47ELv7GM2o3uz5bOkLAS91C7IDnMPd5OmfFGaTeG4qou4KztXoTlfihegnJH7TLkX/CZSKloSYsQ== X-Received: by 10.223.134.210 with SMTP id 18mr36730693wry.232.1522142444918; Tue, 27 Mar 2018 02:20:44 -0700 (PDT) Received: from brgl-bgdev.baylibre.local ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id h190sm1288925wmd.22.2018.03.27.02.20.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Mar 2018 02:20:44 -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 v3 7/8] remoteproc/davinci: use the reset framework Date: Tue, 27 Mar 2018 11:20:30 +0200 Message-Id: <20180327092031.11251-8-brgl@bgdev.pl> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180327092031.11251-1-brgl@bgdev.pl> References: <20180327092031.11251-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 | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/drivers/remoteproc/da8xx_remoteproc.c b/drivers/remoteproc/da8xx_remoteproc.c index b668e32996e2..788f59809c02 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) { @@ -309,7 +332,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;