From patchwork Tue Apr 18 11:21:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Gautam X-Patchwork-Id: 751803 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3w6jQv49Qgz9s2s for ; Tue, 18 Apr 2017 21:22:31 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=codeaurora.org header.i=@codeaurora.org header.b="f7RbAzaq"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=codeaurora.org header.i=@codeaurora.org header.b="f7RbAzaq"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756485AbdDRLWO (ORCPT ); Tue, 18 Apr 2017 07:22:14 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:49594 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756471AbdDRLWB (ORCPT ); Tue, 18 Apr 2017 07:22:01 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id D220860F68; Tue, 18 Apr 2017 11:21:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1492514508; bh=AMj9aiIxk3vCAZkYFKSzgn2Zzv/2HLo8+JjRqxTp+dY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f7RbAzaqbP6EY6TU3WzlTzcFmvC67b+bjufNADU1y7B+Lzv/ohNuFgk66x5nco38S DVum+r+Djd1PJVBXPNHpAn1ALEidcJPQtd9GWL3DuDu03EEnnX9FOdPT3r/hXhSCMT PLkIdQPm67eq82Ge6nkv8c4SxNtckP1BNTEQGZpA= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED, T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from blr-ubuntu-41.ap.qualcomm.com (unknown [202.46.23.61]) (using TLSv1.1 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: vivek.gautam@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 78E2260F71; Tue, 18 Apr 2017 11:21:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1492514508; bh=AMj9aiIxk3vCAZkYFKSzgn2Zzv/2HLo8+JjRqxTp+dY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f7RbAzaqbP6EY6TU3WzlTzcFmvC67b+bjufNADU1y7B+Lzv/ohNuFgk66x5nco38S DVum+r+Djd1PJVBXPNHpAn1ALEidcJPQtd9GWL3DuDu03EEnnX9FOdPT3r/hXhSCMT PLkIdQPm67eq82Ge6nkv8c4SxNtckP1BNTEQGZpA= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 78E2260F71 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=vivek.gautam@codeaurora.org From: Vivek Gautam To: p.zabel@pengutronix.de, swarren@wwwdotorg.org, balbi@kernel.org Cc: linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org, linux-usb@vger.kernel.org, thierry.reding@gmail.com, gregkh@linuxfoundation.org, linux-arm-msm@vger.kernel.org, Vivek Gautam Subject: [PATCH V3 3/4] usb: dwc3: of-simple: Add support to get resets for the device Date: Tue, 18 Apr 2017 16:51:27 +0530 Message-Id: <1492514488-27385-4-git-send-email-vivek.gautam@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1492514488-27385-1-git-send-email-vivek.gautam@codeaurora.org> References: <1492514488-27385-1-git-send-email-vivek.gautam@codeaurora.org> Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org Add support to get a list of resets available for the device. These resets must be kept de-asserted until the device is in use. Cc: Felipe Balbi Cc: Philipp Zabel Signed-off-by: Vivek Gautam --- drivers/usb/dwc3/dwc3-of-simple.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/drivers/usb/dwc3/dwc3-of-simple.c b/drivers/usb/dwc3/dwc3-of-simple.c index fe414e7a9c78..9116df649f0b 100644 --- a/drivers/usb/dwc3/dwc3-of-simple.c +++ b/drivers/usb/dwc3/dwc3-of-simple.c @@ -29,13 +29,39 @@ #include #include #include +#include struct dwc3_of_simple { struct device *dev; struct clk **clks; int num_clocks; + struct reset_control_array *resets; }; +static int dwc3_of_simple_reset_init(struct dwc3_of_simple *simple) +{ + struct device *dev = simple->dev; + int ret; + + simple->resets = of_reset_control_array_get_exclusive(dev->of_node); + if (IS_ERR(simple->resets)) { + ret = PTR_ERR(simple->resets); + if (ret == -ENOENT) + /* not all controllers required resets */ + return 0; + dev_err(dev, "failed to get device resets\n"); + return ret; + } + + ret = reset_control_array_deassert(simple->resets); + if (ret) { + reset_control_array_put(simple->resets); + return ret; + } + + return 0; +} + static int dwc3_of_simple_clk_init(struct dwc3_of_simple *simple, int count) { struct device *dev = simple->dev; @@ -100,6 +126,10 @@ static int dwc3_of_simple_probe(struct platform_device *pdev) if (ret) return ret; + ret = dwc3_of_simple_reset_init(simple); + if (ret) + return ret; + ret = of_platform_populate(np, NULL, NULL, dev); if (ret) { for (i = 0; i < simple->num_clocks; i++) { @@ -107,6 +137,9 @@ static int dwc3_of_simple_probe(struct platform_device *pdev) clk_put(simple->clks[i]); } + reset_control_array_assert(simple->resets); + reset_control_array_put(simple->resets); + return ret; } @@ -128,6 +161,9 @@ static int dwc3_of_simple_remove(struct platform_device *pdev) clk_put(simple->clks[i]); } + reset_control_array_assert(simple->resets); + reset_control_array_put(simple->resets); + of_platform_depopulate(dev); pm_runtime_put_sync(dev);