From patchwork Mon Jul 31 08:45:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: LeoLiu-oc X-Patchwork-Id: 128488 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp1889153vqg; Mon, 31 Jul 2023 02:11:49 -0700 (PDT) X-Google-Smtp-Source: APBJJlHq8DCjI9/Up1hF91c5JArlxYryqEVRiZXiXpdgJmK0LSfLV8pDsDdnkUYvBa/7bU5bC3De X-Received: by 2002:a05:6a00:1991:b0:668:98a1:5e9d with SMTP id d17-20020a056a00199100b0066898a15e9dmr10433342pfl.6.1690794708840; Mon, 31 Jul 2023 02:11:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690794708; cv=none; d=google.com; s=arc-20160816; b=z/g5/HEnhWcrri3H6CurkO8ELCwDOHt5UufHwTBp3meXOID61F2CmxTTUMTGp/Y7RW LfIFK/T0iphLymEeMDzRyljRZPR1MzNeJvC1NOd4N4HEQ/l4+1ktZ2ca8d6+vKb5OANN MW8ZCCV9Xwo+kD2I46/mZrL3XfCso6xAtUwCtqHsPY0qG2Sn4SxgaMxwYHfLxUSB6SDX m7vWxG4Z3CK5Hz0dY8IuRZK+7Pw2iVqRxDCpAGpX2lFk/ZJ5AXZ2a3KLXzeWVEwwR2/F EO42nOmz7wN+2j7Os42bM885vQADfPd0ode76lSyozo0ycZzWpNdZfk3+DAwB/MCSbSE U7yA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=yZEKW9k82hKggWgN4sgkCzsd+9dkMRfO3guifBvET+w=; fh=3ZSPIWnd+HK6Z7GAIKhGwlldu45YVuy58q4HCcukU/M=; b=FPNjRx429/BqYX12C++mQ/Zw+Q01ixy7rHtshtLcET4hYVxAPmJRVwUgOBOqEcG74w pRwHuzwsuvt/bznIo8W5AerciHnZRGNyuSorNGqGMKkCbEkLJZoBrveMqdo7rT7teEaC PSdfZID8QtUhEBF8L2c05YhJ4AfYwfEWg5P5RGP83zYbgpxlovIWZurrADNaYdGLOmk2 WVV7IFjgrjRSTle71J7U9tRGb1dSQ4raQifkwGzhKLi1nXxdjtMgloxtGsJ5BtqZhccN iFEENlNr8OtE4UfEBh9zlIPjJDzONTLGHbzhEhXWkJT/E95L4+5bPOOWX444JEe6gEow RWMg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k11-20020a056a00134b00b0067e5edde6eesi7272851pfu.302.2023.07.31.02.11.35; Mon, 31 Jul 2023 02:11:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230035AbjGaIrW (ORCPT + 99 others); Mon, 31 Jul 2023 04:47:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230001AbjGaIql (ORCPT ); Mon, 31 Jul 2023 04:46:41 -0400 Received: from mx1.zhaoxin.com (MX1.ZHAOXIN.COM [210.0.225.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09A2A2112 for ; Mon, 31 Jul 2023 01:45:23 -0700 (PDT) X-ASG-Debug-ID: 1690793119-086e231869033b0001-xx1T2L Received: from ZXSHMBX3.zhaoxin.com (ZXSHMBX3.zhaoxin.com [10.28.252.165]) by mx1.zhaoxin.com with ESMTP id Z2HnKAJvtAwZKXyU (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Mon, 31 Jul 2023 16:45:19 +0800 (CST) X-Barracuda-Envelope-From: LeoLiu-oc@zhaoxin.com X-Barracuda-RBL-Trusted-Forwarder: 10.28.252.165 Received: from ZXBJMBX03.zhaoxin.com (10.29.252.7) by ZXSHMBX3.zhaoxin.com (10.28.252.165) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Mon, 31 Jul 2023 16:45:18 +0800 Received: from xin.lan (10.32.64.1) by ZXBJMBX03.zhaoxin.com (10.29.252.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Mon, 31 Jul 2023 16:45:17 +0800 X-Barracuda-RBL-Trusted-Forwarder: 10.28.252.165 From: LeoLiu-oc X-Barracuda-RBL-Trusted-Forwarder: 10.29.252.7 To: , , , , , , , , CC: , , , , leoliu-oc Subject: [PATCH v2 1/2] hwrng: via-rng: convert to x86_cpu_id probing Date: Mon, 31 Jul 2023 16:45:14 +0800 X-ASG-Orig-Subj: [PATCH v2 1/2] hwrng: via-rng: convert to x86_cpu_id probing Message-ID: <20230731084515.2057375-2-LeoLiu-oc@zhaoxin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230731084515.2057375-1-LeoLiu-oc@zhaoxin.com> References: <20230731084515.2057375-1-LeoLiu-oc@zhaoxin.com> MIME-Version: 1.0 X-Originating-IP: [10.32.64.1] X-ClientProxiedBy: zxbjmbx1.zhaoxin.com (10.29.252.163) To ZXBJMBX03.zhaoxin.com (10.29.252.7) X-Barracuda-Connect: ZXSHMBX3.zhaoxin.com[10.28.252.165] X-Barracuda-Start-Time: 1690793119 X-Barracuda-Encrypted: ECDHE-RSA-AES128-GCM-SHA256 X-Barracuda-URL: https://10.28.252.35:4443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at zhaoxin.com X-Barracuda-Scan-Msg-Size: 1824 X-Barracuda-BRTS-Status: 1 X-Barracuda-Bayes: INNOCENT GLOBAL 0.0000 1.0000 -2.0210 X-Barracuda-Spam-Score: -2.02 X-Barracuda-Spam-Status: No, SCORE=-2.02 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=9.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.112114 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772926752587190557 X-GMAIL-MSGID: 1772926752587190557 From: leoliu-oc With this, In addition to the Feature matching check, add the CPU Vendor ID/Family check. Signed-off-by: leoliu-oc --- drivers/char/hw_random/via-rng.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/char/hw_random/via-rng.c b/drivers/char/hw_random/via-rng.c index a9a0a3b09c8b..d7feb3923819 100644 --- a/drivers/char/hw_random/via-rng.c +++ b/drivers/char/hw_random/via-rng.c @@ -135,7 +135,7 @@ static int via_rng_init(struct hwrng *rng) * is always enabled if CPUID rng_en is set. There is no * RNG configuration like it used to be the case in this * register */ - if (((c->x86 == 6) && (c->x86_model >= 0x0f)) || (c->x86 > 6)){ + if (((c->x86 == 6) && (c->x86_model >= 0x0f))) { if (!boot_cpu_has(X86_FEATURE_XSTORE_EN)) { pr_err(PFX "can't enable hardware RNG " "if XSTORE is not enabled\n"); @@ -191,12 +191,17 @@ static struct hwrng via_rng = { .data_read = via_rng_data_read, }; +static const struct x86_cpu_id via_rng_cpu_ids[] = { + X86_MATCH_VENDOR_FAM_FEATURE(CENTAUR, 6, X86_FEATURE_XSTORE, NULL), + {} +}; +MODULE_DEVICE_TABLE(x86cpu, via_rng_cpu_ids); static int __init via_rng_mod_init(void) { int err; - if (!boot_cpu_has(X86_FEATURE_XSTORE)) + if (!x86_match_cpu(via_rng_cpu_ids)) return -ENODEV; pr_info("VIA RNG detected\n"); @@ -217,11 +222,5 @@ static void __exit via_rng_mod_exit(void) } module_exit(via_rng_mod_exit); -static struct x86_cpu_id __maybe_unused via_rng_cpu_id[] = { - X86_MATCH_FEATURE(X86_FEATURE_XSTORE, NULL), - {} -}; -MODULE_DEVICE_TABLE(x86cpu, via_rng_cpu_id); - MODULE_DESCRIPTION("H/W RNG driver for VIA CPU with PadLock"); MODULE_LICENSE("GPL"); From patchwork Mon Jul 31 08:45:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: LeoLiu-oc X-Patchwork-Id: 128496 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp1894134vqg; Mon, 31 Jul 2023 02:25:16 -0700 (PDT) X-Google-Smtp-Source: APBJJlEDy8+BeYb6uJcLZ3Wx0oMfrllbZFz2JJ2DwVmkJKAwKdDBDX/c0yqCiiGTZmO59gkqJ2c/ X-Received: by 2002:a05:6a20:9681:b0:134:dc23:2994 with SMTP id hp1-20020a056a20968100b00134dc232994mr8216906pzc.31.1690795516712; Mon, 31 Jul 2023 02:25:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690795516; cv=none; d=google.com; s=arc-20160816; b=CRoRFMEqHFdXwcDo4vsYrsPv6cEIo4R5oZknTOskuSHf4o3PKAy3npj8kP3BClQwxp H/qt8YN13giStqap3FVZovCD1CcAzYGyrZq6XsHSWDDNbXz58ZcXmAkCTsXt9weJ8mX4 ZI8aQw7kh/Fw8bV/nA14bqKgNoYnYZ12iY1j0NXrVWsIqz8sk7k7KqO9l0V+unVB7tGO 3CrtuC71EVt4JQ13P5UzwNHQMirorRjNNdk1ARHvzETqlO8vCfafySuahVZqZoIdsY6b S3U2x/BWMx5SIUZ64kiCxdmQW5a+LKsb+uyf+RqZ33cKv4T0gjybFoMcSVehpqgnxsdE xvVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=gYVYkOdYttWjCBhkGHvR1GiY0ZTp+Z3X7hx9HHV+Hgg=; fh=3ZSPIWnd+HK6Z7GAIKhGwlldu45YVuy58q4HCcukU/M=; b=u6Rb1wvQAkzpn/B3jgH97zN94Y401exBbwRTiHH4v76W+S08RLJpk7cDPL01fkfVON S6kRwDLWeOaQDzuMXR/UO9G9r6FmXB+NHfHZTlTy1/QmbWsgsAKfokCIg0QfyrqumJtF rLBwPKNm/48yTHic6+v0bJm1cX6XtzzGLR3D1gXA5PmIGr9kJUyvwBd2ywPtMWslIq8Y PGMsJgu7bXkTwRKsGZMz5Vxw1qLNX+ERE8F64rUeWnu5LoA1WBoPbcWdFEbFhjdZTUVj 5S2JZz+2Hwu50KXUbXu+hAA4RJ5rUmm4KulynzzPicf/SZKIx8lR241Zn4Yy6Yd1O7BS BmDA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e10-20020a65688a000000b005638d4f21a8si6835825pgt.855.2023.07.31.02.25.02; Mon, 31 Jul 2023 02:25:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232136AbjGaIri (ORCPT + 99 others); Mon, 31 Jul 2023 04:47:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230174AbjGaIqq (ORCPT ); Mon, 31 Jul 2023 04:46:46 -0400 Received: from mx1.zhaoxin.com (MX1.ZHAOXIN.COM [210.0.225.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D837213C for ; Mon, 31 Jul 2023 01:45:29 -0700 (PDT) X-ASG-Debug-ID: 1690793120-086e23186c033c0001-xx1T2L Received: from ZXSHMBX2.zhaoxin.com (ZXSHMBX2.zhaoxin.com [10.28.252.164]) by mx1.zhaoxin.com with ESMTP id S2cxMzuC0SFUPNlg (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Mon, 31 Jul 2023 16:45:20 +0800 (CST) X-Barracuda-Envelope-From: LeoLiu-oc@zhaoxin.com X-Barracuda-RBL-Trusted-Forwarder: 10.28.252.164 Received: from ZXBJMBX03.zhaoxin.com (10.29.252.7) by ZXSHMBX2.zhaoxin.com (10.28.252.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Mon, 31 Jul 2023 16:45:20 +0800 Received: from xin.lan (10.32.64.1) by ZXBJMBX03.zhaoxin.com (10.29.252.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Mon, 31 Jul 2023 16:45:18 +0800 X-Barracuda-RBL-Trusted-Forwarder: 10.28.252.164 From: LeoLiu-oc X-Barracuda-RBL-Trusted-Forwarder: 10.29.252.7 To: , , , , , , , , CC: , , , , leoliu-oc Subject: [PATCH v2 2/2] hwrng: add Zhaoxin HW RNG driver Date: Mon, 31 Jul 2023 16:45:15 +0800 X-ASG-Orig-Subj: [PATCH v2 2/2] hwrng: add Zhaoxin HW RNG driver Message-ID: <20230731084515.2057375-3-LeoLiu-oc@zhaoxin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230731084515.2057375-1-LeoLiu-oc@zhaoxin.com> References: <20230731084515.2057375-1-LeoLiu-oc@zhaoxin.com> MIME-Version: 1.0 X-Originating-IP: [10.32.64.1] X-ClientProxiedBy: zxbjmbx1.zhaoxin.com (10.29.252.163) To ZXBJMBX03.zhaoxin.com (10.29.252.7) X-Barracuda-Connect: ZXSHMBX2.zhaoxin.com[10.28.252.164] X-Barracuda-Start-Time: 1690793120 X-Barracuda-Encrypted: ECDHE-RSA-AES128-GCM-SHA256 X-Barracuda-URL: https://10.28.252.35:4443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at zhaoxin.com X-Barracuda-Scan-Msg-Size: 4487 X-Barracuda-BRTS-Status: 1 X-Barracuda-Bayes: INNOCENT GLOBAL 0.0000 1.0000 -2.0210 X-Barracuda-Spam-Score: -2.02 X-Barracuda-Spam-Status: No, SCORE=-2.02 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=9.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.112114 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772927599627966790 X-GMAIL-MSGID: 1772927599627966790 From: leoliu-oc Add support for Zhaoxin HW RNG. Signed-off-by: leoliu-oc --- drivers/char/hw_random/Kconfig | 13 +++++ drivers/char/hw_random/Makefile | 1 + drivers/char/hw_random/zhaoxin-rng.c | 87 ++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+) create mode 100644 drivers/char/hw_random/zhaoxin-rng.c diff --git a/drivers/char/hw_random/Kconfig b/drivers/char/hw_random/Kconfig index e0b3786ca51b..e315cd444c77 100644 --- a/drivers/char/hw_random/Kconfig +++ b/drivers/char/hw_random/Kconfig @@ -150,6 +150,19 @@ config HW_RANDOM_VIA If unsure, say Y. +config HW_RANDOM_ZHAOXIN + tristate "Zhaoxin HW Random Number Generator support" + depends on X86 || COMPILE_TEST + default HW_RANDOM + help + This driver provides kernel-side support for the Random Number + Generator hardware found on Zhaoxin based motherboards. + + To compile this driver as a module, choose M here: the + module will be called zhaoxin-rng. + + If unsure, say Y. + config HW_RANDOM_IXP4XX tristate "Intel IXP4xx NPU HW Pseudo-Random Number Generator support" depends on ARCH_IXP4XX || COMPILE_TEST diff --git a/drivers/char/hw_random/Makefile b/drivers/char/hw_random/Makefile index 32549a1186dc..ef5b3ae0794d 100644 --- a/drivers/char/hw_random/Makefile +++ b/drivers/char/hw_random/Makefile @@ -14,6 +14,7 @@ obj-$(CONFIG_HW_RANDOM_GEODE) += geode-rng.o obj-$(CONFIG_HW_RANDOM_N2RNG) += n2-rng.o n2-rng-y := n2-drv.o n2-asm.o obj-$(CONFIG_HW_RANDOM_VIA) += via-rng.o +obj-$(CONFIG_HW_RANDOM_ZHAOXIN) += zhaoxin-rng.o obj-$(CONFIG_HW_RANDOM_EXYNOS) += exynos-trng.o obj-$(CONFIG_HW_RANDOM_IXP4XX) += ixp4xx-rng.o obj-$(CONFIG_HW_RANDOM_OMAP) += omap-rng.o diff --git a/drivers/char/hw_random/zhaoxin-rng.c b/drivers/char/hw_random/zhaoxin-rng.c new file mode 100644 index 000000000000..0ceeb9c3f989 --- /dev/null +++ b/drivers/char/hw_random/zhaoxin-rng.c @@ -0,0 +1,87 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * RNG driver for Zhaoxin RNGs + * + * Copyright 2023 (c) Zhaoxin Semiconductor Co., Ltd. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +enum { + ZHAOXIN_RNG_CHUNK_8 = 0x00, /* 64 rand bits, 64 stored bits*/ + ZHAOXIN_RNG_CHUNK_4 = 0x01, /* 32 rand bits, 32 stored bits */ + ZHAOXIN_RNG_CHUNK_2 = 0x02, /* 16 rand bits, 32 stored bits */ + ZHAOXIN_RNG_CHUNK_1 = 0x03, /* 8 rand bits, 32 stored bits */ + ZHAOXIN_RNG_MAX_SIZE = (128*1024), +}; + +static int zhaoxin_rng_init(struct hwrng *rng) +{ + if (!boot_cpu_has(X86_FEATURE_XSTORE_EN)) { + pr_err(PFX "can't enable hardware RNG if XSTORE is not enabled\n"); + return -ENODEV; + } + return 0; +} + +static inline void rep_xstore(size_t size, size_t factor, void *result) +{ + asm(".byte 0xF3, 0x0F, 0xA7, 0xC0 /*rep xstore*/" + : "=m" (*(size_t *)result), "+c" (size), "+d" (factor), "+D" (result)); +} + +static int zhaoxin_rng_read(struct hwrng *rng, void *data, size_t max, bool wait) +{ + if (max > ZHAOXIN_RNG_MAX_SIZE) + max = ZHAOXIN_RNG_MAX_SIZE; + rep_xstore(max, ZHAOXIN_RNG_CHUNK_1, data); + return max; +} + +static struct hwrng zhaoxin_rng = { + .name = "zhaoxin", + .init = zhaoxin_rng_init, + .read = zhaoxin_rng_read, +}; + +static const struct x86_cpu_id zhaoxin_rng_cpu_ids[] = { + X86_MATCH_VENDOR_FAM_FEATURE(ZHAOXIN, 6, X86_FEATURE_XSTORE, NULL), + X86_MATCH_VENDOR_FAM_FEATURE(ZHAOXIN, 7, X86_FEATURE_XSTORE, NULL), + X86_MATCH_VENDOR_FAM_FEATURE(CENTAUR, 7, X86_FEATURE_XSTORE, NULL), + {} +}; +MODULE_DEVICE_TABLE(x86cpu, zhaoxin_rng_cpu_ids); + +static int __init zhaoxin_rng_mod_init(void) +{ + int err; + + if (!x86_match_cpu(zhaoxin_rng_cpu_ids)) + return -ENODEV; + + pr_info("Zhaoxin RNG detected\n"); + err = hwrng_register(&zhaoxin_rng); + if (err) + pr_err(PFX "RNG registering failed (%d)\n", err); + + return err; +} +module_init(zhaoxin_rng_mod_init); + +static void __exit zhaoxin_rng_mod_exit(void) +{ + hwrng_unregister(&zhaoxin_rng); +} +module_exit(zhaoxin_rng_mod_exit); +MODULE_DESCRIPTION("H/W RNG driver for Zhaoxin CPU"); +MODULE_AUTHOR("YunShen@zhaoxin.com"); +MODULE_LICENSE("GPL");