From patchwork Tue Dec 5 12:35:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lukasz Stelmach X-Patchwork-Id: 10092801 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 06FE1605B4 for ; Tue, 5 Dec 2017 12:36:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 09AB029510 for ; Tue, 5 Dec 2017 12:36:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F279029566; Tue, 5 Dec 2017 12:36:09 +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 3DAB029511 for ; Tue, 5 Dec 2017 12:36:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752723AbdLEMgH (ORCPT ); Tue, 5 Dec 2017 07:36:07 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:39898 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752700AbdLEMgF (ORCPT ); Tue, 5 Dec 2017 07:36:05 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20171205123603euoutp025ffcef18045e1d889bee0e3db72d4a42~9ZiYBfyPu1280712807euoutp02J; Tue, 5 Dec 2017 12:36:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20171205123603euoutp025ffcef18045e1d889bee0e3db72d4a42~9ZiYBfyPu1280712807euoutp02J DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1512477363; bh=el3ZmYk6iBb7qP9kEKvbMeaYMZAjzVzNYurKY7ThCZs=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=r7mYZ0jYfDu6giUCcbhZ3pfpRQY7O/6GdUl/OV9vJw/DvDyLDnmkOLpqTWRp7MdzB G2usX6QCQj7AiqVSlPDoZ4iTMZ3BU/9rIuwov3oGwbzqaXmWp/Q4mNj8E8gpOYim01 bfu7Fj9PLsygeSk7yGPZlOw5Dsh7/Be4XMGcxxa8= Received: from eusmges3.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20171205123602eucas1p2fe7f87535482fd901aff686aca24e4c4~9ZiXnhbOC0553305533eucas1p2t; Tue, 5 Dec 2017 12:36:02 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3.samsung.com (EUCPMTA) with SMTP id F7.16.12867.2B2962A5; Tue, 5 Dec 2017 12:36:02 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20171205123602eucas1p2d3ee1e53adc35df7c52917d43bcdebfd~9ZiXBjswo2850428504eucas1p2F; Tue, 5 Dec 2017 12:36:02 +0000 (GMT) X-AuditID: cbfec7f2-f793b6d000003243-5a-5a2692b20973 Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id CD.A7.18832.2B2962A5; Tue, 5 Dec 2017 12:36:02 +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 <0P0H00865N01WO50@eusync4.samsung.com>; Tue, 05 Dec 2017 12:36:02 +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?= , m.szyprowski@samsung.com, b.zolnierkie@samsung.com Subject: [PATCH 1/3] crypto: exynos - Support Exynos5250+ SoCs Date: Tue, 05 Dec 2017 13:35:56 +0100 Message-id: <20171205123558.31087-2-l.stelmach@samsung.com> X-Mailer: git-send-email 2.11.0 In-reply-to: <20171205123558.31087-1-l.stelmach@samsung.com> Organization: Samsung R&D Institute Poland X-Brightmail-Tracker: H4sIAAAAAAAAA01SfyyUYRzf877vvfe6Ob0d8Q2j3VBpiUV7i4yt1i3/tGWZa00X7zA/d4dQ a7dC7rQuOrnJyPKrG5ObJHYtR1E6V5gmYcuWDYWjRfTDebX893m+nx/P9/nsoXBRI8+VSkzN YOWpsmQxKSDaXq1aDhpKfKT+U/e9mBZdM4+psOQRTNGMO6OZmsUZi+Uxnxk1NSBmcmIVY4Y6 KkhGZ3mOMU0943wm39jDZ0r7m4gwe4l1eBiTtD4axSRtL7wlBr2KlNxu1SPJksHjDCkVhMSx yYlZrPxQ6EVBwpcbKyg9b092v07PVyKVqxpRFNCBYF3frUZ2G9AZ3k00k2okoER0LQK1do7g DksIyjoGME4VCJXKlzyOqEPwxlrDtxFCeies3J0gbKk47Qk9g0m2MU7vhyedzXxOv4ygRldO 2giSDgdNbd9mkBNtxGDObCQ4RyaYK8dwW5AjHQrKxSjbmKC9YXzkI+LuCobXIyYet5AndBS8 38R2dAhUm3Wb+TtoX2i8/mHzBUCvkbA6O0hwhhNQ+nZly+wIM72tfA67g6qwC+MMGgTdVT+2 CC2Ch9VhHA6GdX0xyS3qACVtZTjXoxA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11MaYq4GMNqzXhm7a7OlbzhIQ8+6sgKX5jI5XLB2+6f 4KyJJ03/Pllh9eqHzh9Oj2tmn/9fzFzvX6XxSnyqfFb1MfPExam/Nh3MOz15woStLfdchX6I zlddFhobwZ+wxmqBEktxRqKhFnNRcSIA0rEDYpMCAAA= X-CMS-MailID: 20171205123602eucas1p2d3ee1e53adc35df7c52917d43bcdebfd X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20171205123602eucas1p2d3ee1e53adc35df7c52917d43bcdebfd X-RootMTR: 20171205123602eucas1p2d3ee1e53adc35df7c52917d43bcdebfd References: <20171205123558.31087-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 --- .../bindings/crypto/samsung,exynos-rng4.txt | 4 ++- drivers/crypto/exynos-rng.c | 36 ++++++++++++++++++++-- 2 files changed, 36 insertions(+), 4 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 451620b475a0..894ef93ef5ec 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 0x02 + #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,11 @@ #define EXYNOS_RNG_SEED_REGS 5 #define EXYNOS_RNG_SEED_SIZE (EXYNOS_RNG_SEED_REGS * 4) +enum exynos_prng_type { + EXYNOS_PRNG_TYPE4 = 4, + EXYNOS_PRNG_TYPE5 = 5, +}; + /* * Driver re-seeds itself with generated random numbers to increase * the randomness. @@ -63,6 +73,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 +171,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_TYPE4) { + exynos_rng_writel(rng, EXYNOS_RNG_CONTROL_START, + EXYNOS_RNG_CONTROL); + } else if (rng->type == EXYNOS_PRNG_TYPE5) { + 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 +295,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_TYPE4 && + rng->type != EXYNOS_PRNG_TYPE5) { + 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)) { @@ -300,7 +323,10 @@ static int exynos_rng_probe(struct platform_device *pdev) dev_err(&pdev->dev, "Couldn't register rng crypto alg: %d\n", ret); exynos_rng_dev = NULL; - } + } else + dev_info(&pdev->dev, + "Exynos Pseudo Random Number Generator (type:%d)\n", + rng->type); return ret; } @@ -367,6 +393,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_TYPE4, + }, { + .compatible = "samsung,exynos5250-prng", + .data = (const void *)EXYNOS_PRNG_TYPE5, }, { }, };