From patchwork Tue Aug 11 05:32:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 6988301 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8855A9F373 for ; Tue, 11 Aug 2015 05:36:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AFC6E205FF for ; Tue, 11 Aug 2015 05:36:23 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C096620570 for ; Tue, 11 Aug 2015 05:36:22 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZP2CD-0000aK-M4; Tue, 11 Aug 2015 05:33:57 +0000 Received: from smtp.csie.ntu.edu.tw ([140.112.30.61]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZP2Bl-0000Sn-DS for linux-arm-kernel@lists.infradead.org; Tue, 11 Aug 2015 05:33:31 +0000 Received: from mirror2.csie.ntu.edu.tw (mirror2.csie.ntu.edu.tw [140.112.30.76]) (Authenticated sender: b93043) by smtp.csie.ntu.edu.tw (Postfix) with ESMTPSA id F283F24F33; Tue, 11 Aug 2015 13:33:01 +0800 (CST) Received: by mirror2.csie.ntu.edu.tw (Postfix, from userid 1000) id D4EE15F87D; Tue, 11 Aug 2015 13:33:01 +0800 (CST) From: Chen-Yu Tsai To: Corentin Labbe , Herbert Xu , Maxime Ripard , Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala Subject: [PATCH 2/3] crypto: sunxi-ss: Add optional reset control support Date: Tue, 11 Aug 2015 13:32:56 +0800 Message-Id: <1439271177-26523-3-git-send-email-wens@csie.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1439271177-26523-1-git-send-email-wens@csie.org> References: <1439271177-26523-1-git-send-email-wens@csie.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150810_223329_755749_7B482AF3 X-CRM114-Status: GOOD ( 13.76 ) X-Spam-Score: -4.2 (----) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Chen-Yu Tsai , linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.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-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On sun6i and later platforms, the reset control is split out of the clock gates. Add support for an optional reset control. Signed-off-by: Chen-Yu Tsai --- drivers/crypto/sunxi-ss/sun4i-ss-core.c | 22 ++++++++++++++++++++++ drivers/crypto/sunxi-ss/sun4i-ss.h | 2 ++ 2 files changed, 24 insertions(+) diff --git a/drivers/crypto/sunxi-ss/sun4i-ss-core.c b/drivers/crypto/sunxi-ss/sun4i-ss-core.c index 0b79b58c913b..eab6fe227fa0 100644 --- a/drivers/crypto/sunxi-ss/sun4i-ss-core.c +++ b/drivers/crypto/sunxi-ss/sun4i-ss-core.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "sun4i-ss.h" @@ -253,6 +254,14 @@ static int sun4i_ss_probe(struct platform_device *pdev) } dev_dbg(&pdev->dev, "clock ahb_ss acquired\n"); + ss->reset = devm_reset_control_get_optional(&pdev->dev, "ahb"); + if (IS_ERR(ss->reset)) { + if (PTR_ERR(ss->reset) == -EPROBE_DEFER) + return PTR_ERR(ss->reset); + dev_info(&pdev->dev, "no reset control found\n"); + ss->reset = NULL; + } + /* Enable both clocks */ err = clk_prepare_enable(ss->busclk); if (err != 0) { @@ -275,6 +284,15 @@ static int sun4i_ss_probe(struct platform_device *pdev) goto error_clk; } + /* Deassert reset if we have a reset control */ + if (ss->reset) { + err = reset_control_deassert(ss->reset); + if (err) { + dev_err(&pdev->dev, "Cannot deassert reset control\n"); + goto error_clk; + } + } + /* * The only impact on clocks below requirement are bad performance, * so do not print "errors" @@ -352,6 +370,8 @@ error_alg: break; } } + if (ss->reset) + reset_control_assert(ss->reset); error_clk: clk_disable_unprepare(ss->ssclk); error_ssclk: @@ -376,6 +396,8 @@ static int sun4i_ss_remove(struct platform_device *pdev) } writel(0, ss->base + SS_CTL); + if (ss->reset) + reset_control_assert(ss->reset); clk_disable_unprepare(ss->busclk); clk_disable_unprepare(ss->ssclk); return 0; diff --git a/drivers/crypto/sunxi-ss/sun4i-ss.h b/drivers/crypto/sunxi-ss/sun4i-ss.h index db18b2554e6f..8e9c05f6e4d4 100644 --- a/drivers/crypto/sunxi-ss/sun4i-ss.h +++ b/drivers/crypto/sunxi-ss/sun4i-ss.h @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -129,6 +130,7 @@ struct sun4i_ss_ctx { int irq; struct clk *busclk; struct clk *ssclk; + struct reset_control *reset; struct device *dev; struct resource *res; spinlock_t slock; /* control the use of the device */