From patchwork Mon May 22 11:23:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Gautam X-Patchwork-Id: 9739961 X-Patchwork-Delegate: agross@codeaurora.org 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 6C774601C2 for ; Mon, 22 May 2017 11:24:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B73F28415 for ; Mon, 22 May 2017 11:24:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4F3BE28402; Mon, 22 May 2017 11:24:42 +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 C0F9128402 for ; Mon, 22 May 2017 11:24:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759174AbdEVLX4 (ORCPT ); Mon, 22 May 2017 07:23:56 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:37914 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759153AbdEVLXu (ORCPT ); Mon, 22 May 2017 07:23:50 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 7914460AC8; Mon, 22 May 2017 11:23:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1495452229; bh=5/SuMc19Umo9P46GxOrg8Oulb0kw46BzBoS/5v+XbKs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XwltULkLFArx1eUM25JGfG5z8m/k+bWlsb9n9K17H1BaCWpd5b69K7OwEV/PkrL9S ymMHOHayJiNMv+WZcpQwFWxVj2TKLq1V/wmHwgL0TgaIbGOAM/IZopz6cdeqDLZgbb ng4/pFywvb9ca9nQmGWGOwckKNXg9WQpSu5UNtwU= Received: from blr-ubuntu-41.ap.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.18.19]) (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 1C4E060867; Mon, 22 May 2017 11:23:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1495452228; bh=5/SuMc19Umo9P46GxOrg8Oulb0kw46BzBoS/5v+XbKs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M4Om/j921mgp1j+Uch2pPCRzqFVNlWbenMrdPdCl2bLVpXiC697KmH44lsxsiqvE3 q6RDuAgsLEFHdFhOyehImgssgzCinCHZTaaeJlVDMlbkhHlGv/l8AFHpm8wsxqqj0v /o3xxbbsO+eWHCXGODQagHRe4a3MrO1tgMBsGsyc= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 1C4E060867 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, linux-kernel@vger.kernel.org Cc: linux-tegra@vger.kernel.org, linux-usb@vger.kernel.org, jonathanh@nvidia.com, balbi@kernel.org, gregkh@linuxfoundation.org, linux-arm-msm@vger.kernel.org, Vivek Gautam Subject: [PATCH v4 3/4] usb: dwc3: of-simple: Add support to get resets for the device Date: Mon, 22 May 2017 16:53:26 +0530 Message-Id: <1495452207-6129-4-git-send-email-vivek.gautam@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1495452207-6129-1-git-send-email-vivek.gautam@codeaurora.org> References: <1495452207-6129-1-git-send-email-vivek.gautam@codeaurora.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-of-simple.c b/drivers/usb/dwc3/dwc3-of-simple.c index a9bac09d3750..463b744d6688 100644 --- a/drivers/usb/dwc3/dwc3-of-simple.c +++ b/drivers/usb/dwc3/dwc3-of-simple.c @@ -29,11 +29,13 @@ #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_clk_init(struct dwc3_of_simple *simple, int count) @@ -96,9 +98,20 @@ static int dwc3_of_simple_probe(struct platform_device *pdev) platform_set_drvdata(pdev, simple); simple->dev = dev; + simple->resets = of_reset_control_array_get_optional_exclusive(np); + if (IS_ERR(simple->resets)) { + ret = PTR_ERR(simple->resets); + dev_err(dev, "failed to get device resets, err=%d\n", ret); + return ret; + } + + ret = reset_control_array_deassert(simple->resets); + if (ret) + goto err_resetc_put; + ret = dwc3_of_simple_clk_init(simple, of_clk_get_parent_count(np)); if (ret) - return ret; + goto err_resetc_assert; ret = of_platform_populate(np, NULL, NULL, dev); if (ret) { @@ -107,7 +120,7 @@ static int dwc3_of_simple_probe(struct platform_device *pdev) clk_put(simple->clks[i]); } - return ret; + goto err_resetc_assert; } pm_runtime_set_active(dev); @@ -115,6 +128,13 @@ static int dwc3_of_simple_probe(struct platform_device *pdev) pm_runtime_get_sync(dev); return 0; + +err_resetc_assert: + reset_control_array_assert(simple->resets); + +err_resetc_put: + reset_control_array_put(simple->resets); + return ret; } static int dwc3_of_simple_remove(struct platform_device *pdev) @@ -130,6 +150,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); + pm_runtime_put_sync(dev); pm_runtime_disable(dev);