From patchwork Tue Dec 12 16:36:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lukasz Stelmach X-Patchwork-Id: 10107839 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 18327602B3 for ; Tue, 12 Dec 2017 16:36:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0AC0D2947B for ; Tue, 12 Dec 2017 16:36:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F3995294AF; Tue, 12 Dec 2017 16:36:20 +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 7DBA02947B for ; Tue, 12 Dec 2017 16:36:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750853AbdLLQgS (ORCPT ); Tue, 12 Dec 2017 11:36:18 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:40510 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751612AbdLLQgO (ORCPT ); Tue, 12 Dec 2017 11:36:14 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20171212163611euoutp02645ca98346611030f8bc502935ff0207~-mVC_DOc-3187531875euoutp02W; Tue, 12 Dec 2017 16:36:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20171212163611euoutp02645ca98346611030f8bc502935ff0207~-mVC_DOc-3187531875euoutp02W DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1513096571; bh=JA5EQRuWfqQ18LSoVo1Uq7YyZLDsZE3y3MR5cG9Kr7g=; h=From:To:Cc:Subject:Date:In-reply-to:In-reply-to:References:From; b=HOlmDTVrWrCYPdTKO+Ma5Kr3+OLwRRg2JdZDJMT5du4vW2+Xs0uFiVOmC9mglD9lR aTjCUJK+Ci6ZokDva2G/rLDR8fVuCMqLdvEiY3AHPK6LH79twbHRjd3cdLNcKLQPfi Sr61Rm5cUFtWtFrwXxdz1Q+cVIi5TzpbDkT1PJek= Received: from eusmges2.samsung.com (unknown [203.254.199.241]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20171212163611eucas1p1562298289bbd09656e47ecc43bb22422~-mVCNFoIF2040520405eucas1p18; Tue, 12 Dec 2017 16:36:11 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2.samsung.com (EUCPMTA) with SMTP id 10.CB.12907.A75003A5; Tue, 12 Dec 2017 16:36:10 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20171212163610eucas1p2c42f1448547bb4914fd7c1b79fc2e892~-mVBkAfdQ2509425094eucas1p21; Tue, 12 Dec 2017 16:36:10 +0000 (GMT) X-AuditID: cbfec7f1-f793a6d00000326b-63-5a30057a675e Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id B0.ED.18832.A75003A5; Tue, 12 Dec 2017 16:36:10 +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 <0P0U00B1FWSAJH60@eusync4.samsung.com>; Tue, 12 Dec 2017 16:36:10 +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 v3 1/4] crypto: exynos - Support Exynos5250+ SoCs Date: Tue, 12 Dec 2017 17:36:04 +0100 Message-id: <20171212163607.2985-2-l.stelmach@samsung.com> X-Mailer: git-send-email 2.11.0 In-reply-to: <20171212163607.2985-1-l.stelmach@samsung.com> In-reply-to: <20171211140623.7673-1-l.stelmach@samsung.com> Organization: Samsung R&D Institute Poland X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrNKsWRmVeSWpSXmKPExsWy7djPc7pVrAZRBifu6FtsnLGe1WLO+RYW i+5XMhb9j18zW5w/v4Hd4uahFYwW9+/9ZLK4vGsOm8WM8/uYLNYeuctu0br3CLvF1NNrWRx4 PD5ducLksWXlTSaPbQdUPTat6mTz6NuyitHj8ya5ALYoLpuU1JzMstQifbsEroznj48zFuyR qeib+J21gXGJeBcjJ4eEgInEhKln2CFsMYkL99azdTFycQgJLGWUWHPoCCOE85lRomHGW0aY jgXr2pghEssYJWZPW8AGkuAVEJT4MfkeSxcjBwezgLzEkUvZIGFmAU2JrbvXs0PUf2GUeLZy DjNIgk3AUaJ/6QlWkISIwD4miccTp4KtYwaZenDbSbCpwkBVu77tAlvNIqAqMbX7IxPENiuJ R/9OQx0uL7Gr7SIriM0pYC3x5d86Jhi783g72Bx+AS2JNU3XWUAWSAhMZpfo2fieFaLZReLC vEYmCFtY4tXxLVBDZSQ6Ow4yQTT0M0ocnv8dKjGFUWLxQgcI21riz6qJbBCP8klM2jadGeR/ CQFeiY42IYgSD4kVV6az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BKdXA aOy9j8lAX7flveomy8Cnq77+CFqUeZ39SQLfx13V+1Pcdpnpyz7Sarm063pK9rTK1u+P5mty TBIwPMfyO0uN+1z1l+nbzWM+7qhb9uDANr0Fj16dc3nFFLu75Ksf67fv5o9D34Ycm7iEb+/E eyyMyWJbph8VO6hdcevZOsYD0w+wRwi2caRdTlJiKc5INNRiLipOBACqX/uNrQIAAA== X-CMS-MailID: 20171212163610eucas1p2c42f1448547bb4914fd7c1b79fc2e892 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20171212163610eucas1p2c42f1448547bb4914fd7c1b79fc2e892 X-RootMTR: 20171212163610eucas1p2c42f1448547bb4914fd7c1b79fc2e892 References: <20171212163607.2985-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 Add support for PRNG in Exynos5250+ SoCs. Signed-off-by: Ɓukasz Stelmach Reviewed-by: Krzysztof Kozlowski --- .../bindings/crypto/samsung,exynos-rng4.txt | 4 +++- drivers/crypto/exynos-rng.c | 27 ++++++++++++++++++++-- 2 files changed, 28 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..825c09619eb8 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,8 @@ 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); + rng->dev = &pdev->dev; rng->clk = devm_clk_get(&pdev->dev, "secss"); if (IS_ERR(rng->clk)) { @@ -367,6 +386,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, }, { }, };