From patchwork Mon Dec 11 14:06:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lukasz Stelmach X-Patchwork-Id: 10105179 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 5E89B602A7 for ; Mon, 11 Dec 2017 14:06:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 685C1295FA for ; Mon, 11 Dec 2017 14:06:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5D38F29605; Mon, 11 Dec 2017 14:06: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=ham 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 DC2A5295FA for ; Mon, 11 Dec 2017 14:06:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753007AbdLKOGp (ORCPT ); Mon, 11 Dec 2017 09:06:45 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:51082 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752470AbdLKOGk (ORCPT ); Mon, 11 Dec 2017 09:06:40 -0500 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20171211140637euoutp01ece3f583da87b71594ae9fed6fc57e0e~-QpK2bdC52700327003euoutp01a; Mon, 11 Dec 2017 14:06:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20171211140637euoutp01ece3f583da87b71594ae9fed6fc57e0e~-QpK2bdC52700327003euoutp01a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1513001197; bh=PbTzcpA7ntK9G5wW0rK51UgYRFvK0t8Asuoh7Y5Dr6g=; h=From:To:Cc:Subject:Date:In-reply-to:In-reply-to:References:From; b=U6F1XG9KNXN55v694FgtODySIsMOaY9s/mOxlb962tqQKOyrFJrbiFi2OrqXYQa1w s3Pu7uCsEzLn+1Gm4dmRcw3N52i4FQ+o1+wcg8MX3GSOSyGxRiBSJIRkuCBgKbKsYG zpNkzG4GOYqU2QWJB5k7LsYnMZZUW7B5eDoqfw6U= Received: from eusmges1.samsung.com (unknown [203.254.199.239]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20171211140637eucas1p1af88715d2f365bba0cc02ade4da48f63~-QpKYSSIm2052820528eucas1p1l; Mon, 11 Dec 2017 14:06:37 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1.samsung.com (EUCPMTA) with SMTP id 12.F4.12576.CE09E2A5; Mon, 11 Dec 2017 14:06:36 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20171211140636eucas1p26abbf1220ed98fc86ecbd2cd1a9b99c7~-QpJs5sX72966629666eucas1p2D; Mon, 11 Dec 2017 14:06:36 +0000 (GMT) X-AuditID: cbfec7ef-f79ee6d000003120-bc-5a2e90eca4ab Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 10.54.18832.CE09E2A5; Mon, 11 Dec 2017 14:06:36 +0000 (GMT) MIME-version: 1.0 Content-transfer-encoding: 8BIT Content-type: text/plain; charset="UTF-8" Received: from localhost ([106.116.147.110]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P0S007ZGV70R2B0@eusync4.samsung.com>; Mon, 11 Dec 2017 14:06:36 +0000 (GMT) From: =?UTF-8?q?=C5=81ukasz=20Stelmach?= To: Krzysztof Kozlowski , robh+dt@kernel.org, Stephan Mueller , Herbert Xu , "David S . Miller" , Kukjin Kim , linux-crypto@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?UTF-8?q?=C5=81ukasz=20Stelmach?= , Marek Szyprowski , Bartlomiej Zolnierkiewicz Subject: [PATCH v2 1/4] crypto: exynos - Support Exynos5250+ SoCs Date: Mon, 11 Dec 2017 15:06:20 +0100 Message-id: <20171211140623.7673-2-l.stelmach@samsung.com> X-Mailer: git-send-email 2.11.0 In-reply-to: <20171211140623.7673-1-l.stelmach@samsung.com> In-reply-to: <20171205123558.31087-1-l.stelmach@samsung.com> Organization: Samsung R&D Institute Poland X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrNKsWRmVeSWpSXmKPExsWy7djP87pvJuhFGZy+ZWGxccZ6Vos551tY LLpfyVj0P37NbHH+/AZ2i5uHVjBa3L/3k8ni8q45bBYzzu9jslh75C67ReveI+wWU0+vZXHg 8fh05QqTx5aVN5k8th1Q9di0qpPNo2/LKkaPz5vkAtiiuGxSUnMyy1KL9O0SuDK+/VrIUnBd rmL73ybmBsbJkl2MnBwSAiYSM5cfYoSwxSQu3FvP1sXIxSEksIxRonHlMVYI5zOjxOez65lh Omb3XWOGq9q7cR4LSIJXQFDix+R7QDYHB7OAvMSRS9kgYWYBTYmtu9ezQ9R/YZRYumYX2CA2 AUeJ/qUnwDaICOxjkng8cSojiMMMMvXgtpNsIFXCQFVPVtwB28AioCrx8ttOZohtVhL/psyA OlxeYlfbRVYQm1PAWqLzeDsbhG0jsfDsDDCbX0BLYk3TdRaQBRIC09kljlyfwgrR7CKx6tJ9 qEHCEq+Ob2GHsGUkOjsOMkE09DNKHJ7/HSoxhVFi8UIHCNta4s+qiWwQj/JJTNo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xHl796yOFBJITyxJzU5NLUgtgsky cXBKNTBOsOl8sSzKUXOvw/eow+vMtl6+IDfx0jGHMzWVwq55UTMP7Kh8xLa14FFB9+4T2pb/ Sm8d/1FeG++4OcyhNLXIJV2LQ2HZfDeFdRKHpLo+Lfs7Vz7RS/ZcrGIyh5H7Gh6RG0y/fpv+ dNXsKRLVDs0PXGHvNiVm8kGed1bfnnRf4gmcP/ON5g8lluKMREMt5qLiRAB0yBYKrQIAAA== X-CMS-MailID: 20171211140636eucas1p26abbf1220ed98fc86ecbd2cd1a9b99c7 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20171211140636eucas1p26abbf1220ed98fc86ecbd2cd1a9b99c7 X-RootMTR: 20171211140636eucas1p26abbf1220ed98fc86ecbd2cd1a9b99c7 References: <20171211140623.7673-1-l.stelmach@samsung.com> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Cc: Marek Szyprowski , Bartlomiej Zolnierkiewicz Add support for PRNG in Exynos5250+ SoCs. Signed-off-by: Ɓukasz Stelmach --- .../bindings/crypto/samsung,exynos-rng4.txt | 4 ++- drivers/crypto/exynos-rng.c | 32 ++++++++++++++++++++-- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/crypto/samsung,exynos-rng4.txt b/Documentation/devicetree/bindings/crypto/samsung,exynos-rng4.txt index 4ca8dd4d7e66..a13fbdb4bd88 100644 --- a/Documentation/devicetree/bindings/crypto/samsung,exynos-rng4.txt +++ b/Documentation/devicetree/bindings/crypto/samsung,exynos-rng4.txt @@ -2,7 +2,9 @@ Exynos Pseudo Random Number Generator Required properties: -- compatible : Should be "samsung,exynos4-rng". +- compatible : One of: + - "samsung,exynos4-rng" for Exynos4210 and Exynos4412 + - "samsung,exynos5250-prng" for Exynos5250+ - reg : Specifies base physical address and size of the registers map. - clocks : Phandle to clock-controller plus clock-specifier pair. - clock-names : "secss" as a clock name. diff --git a/drivers/crypto/exynos-rng.c b/drivers/crypto/exynos-rng.c index ed6ba796ad71..2f554b82f49f 100644 --- a/drivers/crypto/exynos-rng.c +++ b/drivers/crypto/exynos-rng.c @@ -22,12 +22,17 @@ #include #include #include +#include #include #include #define EXYNOS_RNG_CONTROL 0x0 #define EXYNOS_RNG_STATUS 0x10 + +#define EXYNOS_RNG_SEED_CONF 0x14 +#define EXYNOS_RNG_GEN_PRNG BIT(1) + #define EXYNOS_RNG_SEED_BASE 0x140 #define EXYNOS_RNG_SEED(n) (EXYNOS_RNG_SEED_BASE + (n * 0x4)) #define EXYNOS_RNG_OUT_BASE 0x160 @@ -43,6 +48,12 @@ #define EXYNOS_RNG_SEED_REGS 5 #define EXYNOS_RNG_SEED_SIZE (EXYNOS_RNG_SEED_REGS * 4) +enum exynos_prng_type { + EXYNOS_PRNG_UNKNOWN = 0, + EXYNOS_PRNG_EXYNOS4, + EXYNOS_PRNG_EXYNOS5, +}; + /* * Driver re-seeds itself with generated random numbers to increase * the randomness. @@ -63,6 +74,7 @@ struct exynos_rng_ctx { /* Device associated memory */ struct exynos_rng_dev { struct device *dev; + enum exynos_prng_type type; void __iomem *mem; struct clk *clk; /* Generated numbers stored for seeding during resume */ @@ -160,8 +172,13 @@ static int exynos_rng_get_random(struct exynos_rng_dev *rng, { int retry = EXYNOS_RNG_WAIT_RETRIES; - exynos_rng_writel(rng, EXYNOS_RNG_CONTROL_START, - EXYNOS_RNG_CONTROL); + if (rng->type == EXYNOS_PRNG_EXYNOS4) { + exynos_rng_writel(rng, EXYNOS_RNG_CONTROL_START, + EXYNOS_RNG_CONTROL); + } else if (rng->type == EXYNOS_PRNG_EXYNOS5) { + exynos_rng_writel(rng, EXYNOS_RNG_GEN_PRNG, + EXYNOS_RNG_SEED_CONF); + } while (!(exynos_rng_readl(rng, EXYNOS_RNG_STATUS) & EXYNOS_RNG_STATUS_RNG_DONE) && --retry) @@ -279,6 +296,13 @@ static int exynos_rng_probe(struct platform_device *pdev) if (!rng) return -ENOMEM; + rng->type = (enum exynos_prng_type)of_device_get_match_data(&pdev->dev); + if (rng->type != EXYNOS_PRNG_EXYNOS4 && + rng->type != EXYNOS_PRNG_EXYNOS5) { + dev_err(&pdev->dev, "Unsupported PRNG type: %d", rng->type); + return -ENOTSUPP; + } + rng->dev = &pdev->dev; rng->clk = devm_clk_get(&pdev->dev, "secss"); if (IS_ERR(rng->clk)) { @@ -367,6 +391,10 @@ static SIMPLE_DEV_PM_OPS(exynos_rng_pm_ops, exynos_rng_suspend, static const struct of_device_id exynos_rng_dt_match[] = { { .compatible = "samsung,exynos4-rng", + .data = (const void *)EXYNOS_PRNG_EXYNOS4, + }, { + .compatible = "samsung,exynos5250-prng", + .data = (const void *)EXYNOS_PRNG_EXYNOS5, }, { }, };