From patchwork Tue Jun 18 00:37:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 13701579 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 49790C2BA18 for ; Tue, 18 Jun 2024 00:38:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=tJ9dFj/nuDozXVyK3hNWcLVDpuzjEVXmNkuXi4rgInU=; b=umPtpYTSQLv8sbEGHZOOLbi4dP hQsxMR4C9uaEp8Elvk45Vnqri3PRJLJJnqF9I7D8K/bqS+atA6/Fuy2AUZysdfcspL+M8R2S20xcY LrgF9TvimOImuNvtJ7JKNKuzzUSsUnbKiJj35SYhaLzKj6+iX0M1ThZ8SK7E5/TgUBcmUjpFKx3Ci /RzLx0N4utpCSqwTZ7+fOTwfhtuaIYxA/bcReTnc/bw5wZqM3dHvYia5CKucGo505OJn9JJv+o7J+ ZFpTpoVfg7MYa/Qsn25z3jPqeSuKoiVU4kZ/0Lv3q5ZOnkcH7xVwXbs7l6ovS0sGOr025oaY4Il7r 5uyzlYLw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJMr7-0000000D4nd-3dOk; Tue, 18 Jun 2024 00:37:49 +0000 Received: from mail-oa1-x29.google.com ([2001:4860:4864:20::29]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJMr4-0000000D4lJ-3HN6 for linux-arm-kernel@lists.infradead.org; Tue, 18 Jun 2024 00:37:48 +0000 Received: by mail-oa1-x29.google.com with SMTP id 586e51a60fabf-254e42df409so3124514fac.0 for ; Mon, 17 Jun 2024 17:37:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718671064; x=1719275864; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=tJ9dFj/nuDozXVyK3hNWcLVDpuzjEVXmNkuXi4rgInU=; b=PHZRV9yG0FFAuJJZUAk7JEbP13jbpz/yiFGAhtnkpdWKEVK3uzPmRuXzmM38xtSD8s XWa7kthwoMLGJ9rmDbTdd0IRzIWsa2Y6kIQV52XZwZKBkkVWmL6UHJc3SB36zmgik7QR Ur7k9M4Y0n4XWVkC+sYozdv53q2qWG8SZ8QsVHmsVla6UZ/OJvTcBxKqnNjNfkRK63LX OCeovIv26y0qUDP/K5ESme7OLesffF5bDomXKMUj5whdsWn+Hp+XJ3WUJ4wqTCxKnt05 +tM7nyn7tncpObcJn2uLn3TBEUwoFMjvb924nO8n+yku63St3FZcre/5AEzYJpIGbg3Q oAlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718671064; x=1719275864; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=tJ9dFj/nuDozXVyK3hNWcLVDpuzjEVXmNkuXi4rgInU=; b=tl9gcVMX3mOnBtL3MAzmOFxAx4e8MUVAUTy7hV1NmeoozgDLA4XOvGVhc+zk1SlwWm mOON2qs+ZrFs1LSQBt2oa+Hi9giCpVsSIMpC8nTDdYdnmt+xal9HLH/Vqf0pdIprBY4n aycmKexfO9atcc6Cxm1z+uCx19ZzEhzb7QUBD3vdqNEyITuMAC7LbDCgbqiEHd7uLP97 7tY+U1fXUo+D5vi+A/GCiwaErun66As4RbEhzHh9k8U82m00TkuDsDYTWkAwM7ouQdrr +o6Bd/XnG6QiKwsqNVfcuH/z2/IB7sDcSUTpBeBqhwesdB0IuziChqbJf9c3vMCJbnVs 601w== X-Forwarded-Encrypted: i=1; AJvYcCWBIX8K2TYGZD7R/wHGgl72iGMmgeNtyTD7htpVwAbSvS4xaAvv0ml+KVJU+T67/R5GjkFjb2+7RtQhTu+RHZJu+vUZSqyYOa1uwgTR7zxT/fYkyPQ= X-Gm-Message-State: AOJu0YyZ4LfeBYQBAeP6RJM0mGOYzvtAhVirAJH6vm/1rf6//BdLTHw1 l9JBc6WqBjY1S/CD/OpRtQIoAi/aTFPRN2XFG0F6cDUwm1j07DJ33n0sdVGp7eI= X-Google-Smtp-Source: AGHT+IGmDkEHWFbVOSVHrdqw/KQ9HDkYmOLjdE78AYml6rLtXM9nPkxgB4EdXv3a7VRep/PomFnNIQ== X-Received: by 2002:a05:6870:4728:b0:24f:d9de:3bed with SMTP id 586e51a60fabf-25842b793famr12435193fac.41.1718671063791; Mon, 17 Jun 2024 17:37:43 -0700 (PDT) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2569934d02dsm2879063fac.48.2024.06.17.17.37.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jun 2024 17:37:43 -0700 (PDT) From: Sam Protsenko To: =?utf-8?q?=C5=81ukasz_Stelmach?= , Krzysztof Kozlowski , Rob Herring , Conor Dooley Cc: Olivia Mackall , Herbert Xu , Alim Akhtar , linux-samsung-soc@vger.kernel.org, linux-crypto@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 0/7] hwrng: exynos: Add support for Exynos850 Date: Mon, 17 Jun 2024 19:37:36 -0500 Message-Id: <20240618003743.2975-1-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240617_173747_240136_0386992D X-CRM114-Status: GOOD ( 13.57 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Exynos850 has True Random Number Generator (TRNG) block which is very similar to Exynos5250 for which the driver already exists (exynos-trng.c). There are two differences though: 1. Additional SSS PCLK clock has to be enabled to make TRNG registers accessible. 2. All SSS registers (including TRNG area) are protected with TrustZone and can only be accessed from EL3 monitor. So the corresponding SMC calls have to be used instead to interact with TRNG block. This patch series enables TRNG support on Exynos850 SoC. It was tested on the E850-96 board running Debian rootfs like this: 8<-------------------------------------------------------------->8 # cat /sys/devices/virtual/misc/hw_random/rng_current exyswd_rng # dd if=/dev/hwrng bs=100000 count=1 > /dev/null ... 122KB/s # apt install rng-tools5 # rngtest -c 1000 < /dev/hwrng ... rngtest: starting FIPS tests... rngtest: bits received from input: 20000032 rngtest: FIPS 140-2 successes: 1000 rngtest: FIPS 140-2 failures: 0 rngtest: FIPS 140-2(2001-10-10) Monobit: 0 rngtest: FIPS 140-2(2001-10-10) Poker: 0 rngtest: FIPS 140-2(2001-10-10) Runs: 0 rngtest: FIPS 140-2(2001-10-10) Long run: 0 rngtest: FIPS 140-2(2001-10-10) Continuous run: 0 rngtest: input channel speed: (min=941.855; avg=965.515; max=968.236)Kibits/s rngtest: FIPS tests speed: (min=49.542; avg=52.886; max=53.577)Mibits/s rngtest: Program run time: 20590194 microseconds 8<-------------------------------------------------------------->8 Sam Protsenko (7): dt-bindings: rng: Rename exynos5250-trng to exynos-trng dt-bindings: rng: Add Exynos850 support to exynos-trng hwrng: exynos: Improve coding style hwrng: exynos: Implement bus clock control hwrng: exynos: Add SMC based TRNG operation hwrng: exynos: Enable Exynos850 support arm64: dts: exynos850: Enable TRNG .../bindings/rng/samsung,exynos-trng.yaml | 85 +++++++ .../bindings/rng/samsung,exynos5250-trng.yaml | 44 ---- MAINTAINERS | 2 +- arch/arm64/boot/dts/exynos/exynos850.dtsi | 8 + drivers/char/hw_random/exynos-trng.c | 216 ++++++++++++++---- 5 files changed, 266 insertions(+), 89 deletions(-) create mode 100644 Documentation/devicetree/bindings/rng/samsung,exynos-trng.yaml delete mode 100644 Documentation/devicetree/bindings/rng/samsung,exynos5250-trng.yaml