From patchwork Thu Jun 20 23:13:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 13706538 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 2752EC2BA18 for ; Thu, 20 Jun 2024 23:13:56 +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: Content-Type:MIME-Version:Message-Id:Date:Subject:Cc:To:From:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=NpwkSv9KEC+Z0xSBroaOsC+eSM7dr3lxu3/BMAtc54s=; b=WAZRAh+naaCaaNs/sIIvLR4eGD kWbDVAvB+dOEMMoP1Zzqa7od6P2AZPAoFRlfYXj0l5UInDmPIvMweVflvTDwQZJZvuv/FsSN5VCGh tvD0xK1C9yCohJ30Nac9dWRrf3JuN1ONcySEprWXfJxYnsTcjNRewf7AkB0zbtAApwiNZSwvqk48U TO0ByFEz8pz9w1w39zcc1NLjOcnIRAix1YfWwcbPtx8QVCYQq49elqzalE3FKkM3UwbX1YU1eTEmN LZRe39Te64YU9KR/eu1N4nm3m37lMXruRIiQPZiFUlSINP0h8HoMPmZZHscin6QxQKq35BPeKMKgZ /ZmjliFA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sKQyP-0000000751y-3NDa; Thu, 20 Jun 2024 23:13:45 +0000 Received: from mail-ot1-x334.google.com ([2607:f8b0:4864:20::334]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sKQyL-000000074zX-3J9Q for linux-arm-kernel@lists.infradead.org; Thu, 20 Jun 2024 23:13:43 +0000 Received: by mail-ot1-x334.google.com with SMTP id 46e09a7af769-6fc36865561so726179a34.3 for ; Thu, 20 Jun 2024 16:13:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718925220; x=1719530020; 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=NpwkSv9KEC+Z0xSBroaOsC+eSM7dr3lxu3/BMAtc54s=; b=SveD8DOyPrgV9DerxcLtIOcj/WqL/TT891lFbbKagI9SMg1/mdBXyg642cR+55eVVX 0M8V6LpfoH4CxVJgK8SVyWqrFxCu5WEhhGDONAHiUFveN/36VbX51NSncfQ7hhkePtNk BLrHe/r0AZ45IN8G9iEP8r59Q7UKaulkjrETvqWU96YckWbXjyI79fmtXbzX7NeZG+vn 7yAkv5A/jwvLrnHgt8isQoXWs+p/nQpNBWfIGiNP9XMBvpbnzEL+0HC8j1PkcvuTfs5k Ds0HXO8DsF84u8hBbM0b1iHBuQoyEjWAcUx0lQD/rKf3ah0rgLeOtYSRi9ADOJPsHxsN HRUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718925220; x=1719530020; 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=NpwkSv9KEC+Z0xSBroaOsC+eSM7dr3lxu3/BMAtc54s=; b=MtTzSqOAC5m4apOER3SShFIzL7A24HLpNxEbekfg10cl1E6G0naCpgbVkH0e3eDx7z Bl9dZcAj1cz3QDKI4zya+Mdd9enPodvCyX4vR8PxgdzXsBW1hw2C6VhtcCzDsyZGWJcU 05jT+wPtJYXUmfvokoyyOw863bnR+opd2yG+XAi6d7NFicll9wjtsGUWC0J855Zzqghe tfjCcvX2Z0zvONZtunEkzqG4SPMhez9XGF3Ln8QK2ufd72psqgEWqS0G56Auq5eQNJ3r yHfSD2OJ5jCVhe8sK1Tly8e0fMEFFZULP2gnm3Ay+CXJzg7t2uximS/7kn43lgqNi0L/ xuzw== X-Forwarded-Encrypted: i=1; AJvYcCVxDs5DGhBejMEecFc7vEctoVRor1uPtY86UMZLK+ZLR8Qpii4VCYQj1zvjPod7zT3UbsstAA2yGaRje2OWlA3iginOHCOFPpfIOeomiZbF4TS9qX8= X-Gm-Message-State: AOJu0YzWMm9W4djQmGMzHbd5CAfGHAncNmjmil6LvmuZ9PpkTyWv+bF5 ghaw8rTeeuZNf9bcYUUB0LjyOcg+3A9VGcxyZWWRg94cJzQ8G5wnnt3IstnzZOo= X-Google-Smtp-Source: AGHT+IEzPzN/aMnfj5b73omu5ib7OPwkka1Y2/64FBGQsxHICvhZtCMGfoJmvMptfycgLlXfEvq8pw== X-Received: by 2002:a9d:6510:0:b0:6fd:6240:9dba with SMTP id 46e09a7af769-70074ebf134mr6416843a34.16.1718925219979; Thu, 20 Jun 2024 16:13:39 -0700 (PDT) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7009c5df34fsm89509a34.3.2024.06.20.16.13.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jun 2024 16:13:39 -0700 (PDT) From: Sam Protsenko To: =?utf-8?q?=C5=81ukasz_Stelmach?= , Krzysztof Kozlowski , Rob Herring , Conor Dooley Cc: Anand Moon , 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 v3 0/6] hwrng: exynos: Add support for Exynos850 Date: Thu, 20 Jun 2024 18:13:33 -0500 Message-Id: <20240620231339.1574-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-20240620_161342_069022_88193CFA X-CRM114-Status: GOOD ( 15.72 ) 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 12081400.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 SMC commands added in this series require LDFW (Loadable Firmware) to be loaded by the bootloader. In case of E850-96 board, at the moment only the LittleKernel based bootloader [1] is able to load LDFW. It is expected to be added into U-Boot port soon as well. See [2] for more details. [1] https://gitlab.com/Linaro/96boards/e850-96/lk [2] https://docs.u-boot.org/en/latest/board/samsung/e850-96.html Changes in v3: - Rebased on top of the most recent linux-next - Removed dts patch (7/7) from the series, as suggested by Krzysztof - Addressed all review comments for v2 series Changes in v2: - Removed the patch for renaming the dt-bindings doc file - Added the patch for using devm_clk_get_enabled() to get the clock - Addressed all review comments for v1 series Sam Protsenko (6): dt-bindings: rng: Add Exynos850 support to exynos-trng hwrng: exynos: Improve coding style hwrng: exynos: Use devm_clk_get_enabled() to get the clock hwrng: exynos: Implement bus clock control hwrng: exynos: Add SMC based TRNG operation hwrng: exynos: Enable Exynos850 support .../bindings/rng/samsung,exynos5250-trng.yaml | 40 +++- drivers/char/hw_random/exynos-trng.c | 225 +++++++++++++----- 2 files changed, 206 insertions(+), 59 deletions(-)