/openbmc/linux/drivers/crypto/ |
H A D | exynos-rng.c | 3 * exynos-rng.c - Random Number Generator driver for the Exynos 7 * Loosely based on old driver from drivers/char/hw_random/exynos-rng.c: 21 #include <crypto/internal/rng.h> 66 struct exynos_rng_dev *rng; member 87 static u32 exynos_rng_readl(struct exynos_rng_dev *rng, u32 offset) in exynos_rng_readl() argument 89 return readl_relaxed(rng->mem + offset); in exynos_rng_readl() 92 static void exynos_rng_writel(struct exynos_rng_dev *rng, u32 val, u32 offset) in exynos_rng_writel() argument 94 writel_relaxed(val, rng->mem + offset); in exynos_rng_writel() 97 static int exynos_rng_set_seed(struct exynos_rng_dev *rng, in exynos_rng_set_seed() argument 117 exynos_rng_writel(rng, val, EXYNOS_RNG_SEED(seed_reg)); in exynos_rng_set_seed() [all …]
|
H A D | qcom-rng.c | 4 // Based on msm-rng.c and downstream driver 6 #include <crypto/internal/rng.h> 39 struct qcom_rng *rng; member 44 static int qcom_rng_read(struct qcom_rng *rng, u8 *data, unsigned int max) in qcom_rng_read() argument 52 ret = readl_poll_timeout(rng->base + PRNG_STATUS, val, in qcom_rng_read() 58 val = readl_relaxed(rng->base + PRNG_DATA_OUT); in qcom_rng_read() 81 struct qcom_rng *rng = ctx->rng; in qcom_rng_generate() local 84 ret = clk_prepare_enable(rng->clk); in qcom_rng_generate() 88 mutex_lock(&rng->lock); in qcom_rng_generate() 90 ret = qcom_rng_read(rng, dstn, dlen); in qcom_rng_generate() [all …]
|
/openbmc/linux/drivers/char/hw_random/ |
H A D | core.c | 34 /* the current rng has been explicitly chosen by user via sysfs */ 41 /* Protects rng read functions, data_avail, rng_buffer and rng_fillbuf */ 56 static int hwrng_init(struct hwrng *rng); 59 static inline int rng_get_data(struct hwrng *rng, u8 *buffer, size_t size, 67 static void add_early_randomness(struct hwrng *rng) in add_early_randomness() argument 72 bytes_read = rng_get_data(rng, rng_fillbuf, 32, 0); in add_early_randomness() 75 size_t entropy = bytes_read * 8 * rng->quality / 1024; in add_early_randomness() 82 struct hwrng *rng = container_of(kref, struct hwrng, ref); in cleanup_rng() local 84 if (rng->cleanup) in cleanup_rng() 85 rng->cleanup(rng); in cleanup_rng() [all …]
|
H A D | Makefile | 3 # Makefile for HW Random Number Generator (RNG) device drivers. 6 obj-$(CONFIG_HW_RANDOM) += rng-core.o 7 rng-core-y := core.o 8 obj-$(CONFIG_HW_RANDOM_TIMERIOMEM) += timeriomem-rng.o 9 obj-$(CONFIG_HW_RANDOM_INTEL) += intel-rng.o 10 obj-$(CONFIG_HW_RANDOM_AMD) += amd-rng.o 11 obj-$(CONFIG_HW_RANDOM_ATMEL) += atmel-rng.o 12 obj-$(CONFIG_HW_RANDOM_BA431) += ba431-rng.o 13 obj-$(CONFIG_HW_RANDOM_GEODE) += geode-rng.o 14 obj-$(CONFIG_HW_RANDOM_N2RNG) += n2-rng.o [all …]
|
H A D | cavium-rng-vf.c | 82 static int check_rng_health(struct cavium_rng *rng) in check_rng_health() argument 90 if (!rng->pf_regbase) in check_rng_health() 93 status = readq(rng->pf_regbase + HEALTH_STATUS_REG); in check_rng_health() 95 dev_err(&rng->pdev->dev, "HWRNG: Startup health test failed\n"); in check_rng_health() 110 cur_err = (cycles * 1000000000) / rng->clock_rate; /* In nanosec */ in check_rng_health() 116 rng->prev_error = 0; in check_rng_health() 117 rng->prev_time = 0; in check_rng_health() 121 if (rng->prev_error) { in check_rng_health() 125 time_elapsed = (cur_time - rng->prev_time) * 10; in check_rng_health() 126 time_elapsed += rng->prev_error; in check_rng_health() [all …]
|
H A D | hisi-rng.c | 23 #define to_hisi_rng(p) container_of(p, struct hisi_rng, rng) 31 struct hwrng rng; member 34 static int hisi_rng_init(struct hwrng *rng) in hisi_rng_init() argument 36 struct hisi_rng *hrng = to_hisi_rng(rng); in hisi_rng_init() 57 static void hisi_rng_cleanup(struct hwrng *rng) in hisi_rng_cleanup() argument 59 struct hisi_rng *hrng = to_hisi_rng(rng); in hisi_rng_cleanup() 64 static int hisi_rng_read(struct hwrng *rng, void *buf, size_t max, bool wait) in hisi_rng_read() argument 66 struct hisi_rng *hrng = to_hisi_rng(rng); in hisi_rng_read() 75 struct hisi_rng *rng; in hisi_rng_probe() local 78 rng = devm_kzalloc(&pdev->dev, sizeof(*rng), GFP_KERNEL); in hisi_rng_probe() [all …]
|
H A D | cn10k-rng.c | 69 static unsigned long reset_rng_health_state(struct cn10k_rng *rng) in reset_rng_health_state() argument 78 static int check_rng_health(struct cn10k_rng *rng) in check_rng_health() argument 84 if (!rng->reg_base) in check_rng_health() 87 status = readq(rng->reg_base + RNM_PF_EBG_HEALTH); in check_rng_health() 89 err = reset_rng_health_state(rng); in check_rng_health() 91 dev_err(&rng->pdev->dev, "HWRNG: Health test failed (status=%llx)\n", in check_rng_health() 93 dev_err(&rng->pdev->dev, "HWRNG: error during reset (error=%lx)\n", in check_rng_health() 102 static bool cn10k_read_trng(struct cn10k_rng *rng, u64 *value) in cn10k_read_trng() argument 108 if (rng->extended_trng_regs) { in cn10k_read_trng() 110 *value = readq(rng->reg_base + RNM_PF_TRNG_DAT); in cn10k_read_trng() [all …]
|
H A D | cavium-rng.c | 22 /* Enable the RNG hardware and activate the VF */ 26 struct cavium_rng_pf *rng; in cavium_rng_probe() local 29 rng = devm_kzalloc(&pdev->dev, sizeof(*rng), GFP_KERNEL); in cavium_rng_probe() 30 if (!rng) in cavium_rng_probe() 33 /*Map the RNG control */ in cavium_rng_probe() 34 rng->control_status = pcim_iomap(pdev, 0, 0); in cavium_rng_probe() 35 if (!rng->control_status) { in cavium_rng_probe() 41 /* Enable the RNG hardware and entropy source */ in cavium_rng_probe() 43 rng->control_status); in cavium_rng_probe() 45 pci_set_drvdata(pdev, rng); in cavium_rng_probe() [all …]
|
H A D | mtk-rng.c | 33 #define to_mtk_rng(p) container_of(p, struct mtk_rng, rng) 38 struct hwrng rng; member 41 static int mtk_rng_init(struct hwrng *rng) in mtk_rng_init() argument 43 struct mtk_rng *priv = to_mtk_rng(rng); in mtk_rng_init() 58 static void mtk_rng_cleanup(struct hwrng *rng) in mtk_rng_cleanup() argument 60 struct mtk_rng *priv = to_mtk_rng(rng); in mtk_rng_cleanup() 70 static bool mtk_rng_wait_ready(struct hwrng *rng, bool wait) in mtk_rng_wait_ready() argument 72 struct mtk_rng *priv = to_mtk_rng(rng); in mtk_rng_wait_ready() 83 static int mtk_rng_read(struct hwrng *rng, void *buf, size_t max, bool wait) in mtk_rng_read() argument 85 struct mtk_rng *priv = to_mtk_rng(rng); in mtk_rng_read() [all …]
|
H A D | ingenic-rng.c | 18 /* RNG register offsets */ 36 struct hwrng rng; member 39 static int ingenic_rng_init(struct hwrng *rng) in ingenic_rng_init() argument 41 struct ingenic_rng *priv = container_of(rng, struct ingenic_rng, rng); in ingenic_rng_init() 48 static void ingenic_rng_cleanup(struct hwrng *rng) in ingenic_rng_cleanup() argument 50 struct ingenic_rng *priv = container_of(rng, struct ingenic_rng, rng); in ingenic_rng_cleanup() 55 static int ingenic_rng_read(struct hwrng *rng, void *buf, size_t max, bool wait) in ingenic_rng_read() argument 57 struct ingenic_rng *priv = container_of(rng, struct ingenic_rng, rng); in ingenic_rng_read() 66 pr_err("%s: Wait for RNG data ready timeout\n", __func__); in ingenic_rng_read() 71 * A delay is required so that the current RNG data is not bit shifted in ingenic_rng_read() [all …]
|
H A D | stm32-rng.c | 32 struct hwrng rng; member 39 static int stm32_rng_read(struct hwrng *rng, void *data, size_t max, bool wait) in stm32_rng_read() argument 42 container_of(rng, struct stm32_rng_private, rng); in stm32_rng_read() 46 pm_runtime_get_sync((struct device *) priv->rng.priv); in stm32_rng_read() 51 /* care of initial delay time when enabling rng */ in stm32_rng_read() 60 dev_err((struct device *)priv->rng.priv, in stm32_rng_read() 67 "bad RNG status - %x\n", sr)) in stm32_rng_read() 79 pm_runtime_mark_last_busy((struct device *) priv->rng.priv); in stm32_rng_read() 80 pm_runtime_put_sync_autosuspend((struct device *) priv->rng.priv); in stm32_rng_read() 85 static int stm32_rng_init(struct hwrng *rng) in stm32_rng_init() argument [all …]
|
H A D | bcm2835-rng.c | 22 /* enable rng */ 31 struct hwrng rng; member 38 static inline struct bcm2835_rng_priv *to_rng_priv(struct hwrng *rng) in to_rng_priv() argument 40 return container_of(rng, struct bcm2835_rng_priv, rng); in to_rng_priv() 63 static int bcm2835_rng_read(struct hwrng *rng, void *buf, size_t max, in bcm2835_rng_read() argument 66 struct bcm2835_rng_priv *priv = to_rng_priv(rng); in bcm2835_rng_read() 73 hwrng_yield(rng); in bcm2835_rng_read() 86 static int bcm2835_rng_init(struct hwrng *rng) in bcm2835_rng_init() argument 88 struct bcm2835_rng_priv *priv = to_rng_priv(rng); in bcm2835_rng_init() 116 static void bcm2835_rng_cleanup(struct hwrng *rng) in bcm2835_rng_cleanup() argument [all …]
|
H A D | npcm-rng.c | 30 #define to_npcm_rng(p) container_of(p, struct npcm_rng, rng) 34 struct hwrng rng; member 38 static int npcm_rng_init(struct hwrng *rng) in npcm_rng_init() argument 40 struct npcm_rng *priv = to_npcm_rng(rng); in npcm_rng_init() 47 static void npcm_rng_cleanup(struct hwrng *rng) in npcm_rng_cleanup() argument 49 struct npcm_rng *priv = to_npcm_rng(rng); in npcm_rng_cleanup() 54 static int npcm_rng_read(struct hwrng *rng, void *buf, size_t max, bool wait) in npcm_rng_read() argument 56 struct npcm_rng *priv = to_npcm_rng(rng); in npcm_rng_read() 60 pm_runtime_get_sync((struct device *)priv->rng.priv); in npcm_rng_read() 82 pm_runtime_mark_last_busy((struct device *)priv->rng.priv); in npcm_rng_read() [all …]
|
H A D | pic32-rng.c | 3 * PIC32 RNG driver 30 struct hwrng rng; member 40 static int pic32_rng_init(struct hwrng *rng) in pic32_rng_init() argument 42 struct pic32_rng *priv = container_of(rng, struct pic32_rng, rng); in pic32_rng_init() 49 static int pic32_rng_read(struct hwrng *rng, void *buf, size_t max, in pic32_rng_read() argument 52 struct pic32_rng *priv = container_of(rng, struct pic32_rng, rng); in pic32_rng_read() 70 static void pic32_rng_cleanup(struct hwrng *rng) in pic32_rng_cleanup() argument 72 struct pic32_rng *priv = container_of(rng, struct pic32_rng, rng); in pic32_rng_cleanup() 94 priv->rng.name = pdev->name; in pic32_rng_probe() 95 priv->rng.init = pic32_rng_init; in pic32_rng_probe() [all …]
|
H A D | octeon-rng.c | 28 static int octeon_rng_init(struct hwrng *rng) in octeon_rng_init() argument 31 struct octeon_rng *p = container_of(rng, struct octeon_rng, ops); in octeon_rng_init() 35 ctl.s.rng_en = 1; /* Enable the RNG hardware. */ in octeon_rng_init() 40 static void octeon_rng_cleanup(struct hwrng *rng) in octeon_rng_cleanup() argument 43 struct octeon_rng *p = container_of(rng, struct octeon_rng, ops); in octeon_rng_cleanup() 50 static int octeon_rng_data_read(struct hwrng *rng, u32 *data) in octeon_rng_data_read() argument 52 struct octeon_rng *p = container_of(rng, struct octeon_rng, ops); in octeon_rng_data_read() 62 struct octeon_rng *rng; in octeon_rng_probe() local 71 rng = devm_kzalloc(&pdev->dev, sizeof(*rng), GFP_KERNEL); in octeon_rng_probe() 72 if (!rng) in octeon_rng_probe() [all …]
|
H A D | mxc-rnga.c | 3 * RNG driver for Freescale RNGA 11 * This driver is based on other RNG drivers. 56 struct hwrng rng; member 61 static int mxc_rnga_data_present(struct hwrng *rng, int wait) in mxc_rnga_data_present() argument 64 struct mxc_rng *mxc_rng = container_of(rng, struct mxc_rng, rng); in mxc_rnga_data_present() 77 static int mxc_rnga_data_read(struct hwrng *rng, u32 * data) in mxc_rnga_data_read() argument 81 struct mxc_rng *mxc_rng = container_of(rng, struct mxc_rng, rng); in mxc_rnga_data_read() 100 static int mxc_rnga_init(struct hwrng *rng) in mxc_rnga_init() argument 103 struct mxc_rng *mxc_rng = container_of(rng, struct mxc_rng, rng); in mxc_rnga_init() 123 static void mxc_rnga_cleanup(struct hwrng *rng) in mxc_rnga_cleanup() argument [all …]
|
H A D | iproc-rng200.c | 42 struct hwrng rng; member 46 #define to_rng_priv(rng) container_of(rng, struct iproc_rng200_dev, rng) argument 70 /* Reset RNG and RBG */ in iproc_rng200_restart() 90 static int iproc_rng200_read(struct hwrng *rng, void *buf, size_t max, in iproc_rng200_read() argument 93 struct iproc_rng200_dev *priv = to_rng_priv(rng); in iproc_rng200_read() 105 /* Is RNG sane? If not, reset it. */ in iproc_rng200_read() 151 static int iproc_rng200_init(struct hwrng *rng) in iproc_rng200_init() argument 153 struct iproc_rng200_dev *priv = to_rng_priv(rng); in iproc_rng200_init() 160 static void iproc_rng200_cleanup(struct hwrng *rng) in iproc_rng200_cleanup() argument 162 struct iproc_rng200_dev *priv = to_rng_priv(rng); in iproc_rng200_cleanup() [all …]
|
/openbmc/linux/arch/powerpc/platforms/powernv/ |
H A D | rng.c | 6 #define pr_fmt(fmt) "powernv-rng: " fmt 32 static unsigned long rng_whiten(struct pnv_rng *rng, unsigned long val) in rng_whiten() argument 44 val ^= rng->mask; in rng_whiten() 47 rng->mask = (rng->mask << 1) | (parity & 1); in rng_whiten() 86 struct pnv_rng *rng; in pnv_get_random_long() local 89 rng = get_cpu_var(pnv_rng); in pnv_get_random_long() 90 *v = rng_whiten(rng, in_be64(rng->regs)); in pnv_get_random_long() 91 put_cpu_var(rng); in pnv_get_random_long() 93 rng = raw_cpu_read(pnv_rng); in pnv_get_random_long() 94 *v = rng_whiten(rng, __raw_rm_readq(rng->regs_real)); in pnv_get_random_long() [all …]
|
/openbmc/qemu/tests/qtest/libqos/ |
H A D | virtio-rng.c | 23 #include "virtio-rng.h" 25 /* virtio-rng-device */ 29 if (!g_strcmp0(interface, "virtio-rng")) { in qvirtio_rng_get_driver() 36 fprintf(stderr, "%s not present in virtio-rng-device\n", interface); in qvirtio_rng_get_driver() 44 return qvirtio_rng_get_driver(&v_rng->rng, interface); in qvirtio_rng_device_get_driver() 52 QVirtioRng *interface = &virtio_rdevice->rng; in virtio_rng_device_create() 61 /* virtio-rng-pci */ 68 return qvirtio_rng_get_driver(&v_rng->rng, interface); in qvirtio_rng_pci_get_driver() 75 QVirtioRng *interface = &virtio_rpci->rng; in virtio_rng_pci_create() 96 /* virtio-rng-device */ in virtio_rng_register_nodes() [all …]
|
/openbmc/linux/Documentation/devicetree/bindings/rng/ |
H A D | mtk-rng.yaml | 4 $id: http://devicetree.org/schemas/rng/mtk-rng.yaml# 14 pattern: "^rng@[0-9a-f]+$" 19 - mediatek,mt7623-rng 22 - mediatek,mt7622-rng 23 - mediatek,mt7629-rng 24 - mediatek,mt7986-rng 25 - mediatek,mt8365-rng 26 - mediatek,mt8516-rng 27 - const: mediatek,mt7623-rng 37 - const: rng [all …]
|
H A D | brcm,bcm2835.yaml | 4 $id: http://devicetree.org/schemas/rng/brcm,bcm2835.yaml# 17 - brcm,bcm2835-rng 18 - brcm,bcm-nsp-rng 19 - brcm,bcm5301x-rng 20 - brcm,bcm6368-rng 48 - brcm,bcm6368-rng 60 rng@7e104000 { 61 compatible = "brcm,bcm2835-rng"; 67 rng@18033000 { 68 compatible = "brcm,bcm-nsp-rng"; [all …]
|
/openbmc/linux/drivers/crypto/caam/ |
H A D | caamrng.c | 36 /* rng per-device context */ 38 struct hwrng rng; member 78 print_hex_dump_debug("rng job desc@: ", DUMP_PREFIX_ADDRESS, in caam_init_desc() 147 static int caam_read(struct hwrng *rng, void *dst, size_t max, bool wait) in caam_read() argument 149 struct caam_rng_ctx *ctx = to_caam_rng_ctx(rng); in caam_read() 166 static void caam_cleanup(struct hwrng *rng) in caam_cleanup() argument 168 struct caam_rng_ctx *ctx = to_caam_rng_ctx(rng); in caam_cleanup() 176 static inline void test_len(struct hwrng *rng, size_t len, bool wait) in test_len() argument 180 struct caam_rng_ctx *ctx = to_caam_rng_ctx(rng); in test_len() 186 read_len = rng->read(rng, buf, len, wait); in test_len() [all …]
|
/openbmc/linux/include/linux/ |
H A D | hw_random.h | 22 * @name: Unique RNG name. 26 * on the RNG. If NULL, it is assumed that 28 * @data_read: Read data from the RNG device. 34 * @priv: Private data, for use by the RNG driver. 35 * @quality: Estimation of true entropy in RNG's bitstream 41 int (*init)(struct hwrng *rng); 42 void (*cleanup)(struct hwrng *rng); 43 int (*data_present)(struct hwrng *rng, int wait); 44 int (*data_read)(struct hwrng *rng, u32 *data); 45 int (*read)(struct hwrng *rng, void *data, size_t max, bool wait); [all …]
|
/openbmc/linux/drivers/crypto/amcc/ |
H A D | crypto4xx_trng.c | 3 * Generic PowerPC 44x RNG driver 28 static int ppc4xx_trng_data_present(struct hwrng *rng, int wait) in ppc4xx_trng_data_present() argument 30 struct crypto4xx_device *dev = (void *)rng->priv; in ppc4xx_trng_data_present() 45 static int ppc4xx_trng_data_read(struct hwrng *rng, u32 *data) in ppc4xx_trng_data_read() argument 47 struct crypto4xx_device *dev = (void *)rng->priv; in ppc4xx_trng_data_read() 65 { .compatible = "ppc4xx-rng", }, 66 { .compatible = "amcc,ppc460ex-rng", }, 67 { .compatible = "amcc,ppc440epx-rng", }, 75 struct hwrng *rng = NULL; in ppc4xx_trng_probe() local 90 rng = kzalloc(sizeof(*rng), GFP_KERNEL); in ppc4xx_trng_probe() [all …]
|
/openbmc/openbmc/poky/meta/recipes-support/rng-tools/ |
H A D | rng-tools_6.17.bb | 3 HOMEPAGE = "https://github.com/nhorman/rng-tools" 4 BUGTRACKER = "https://github.com/nhorman/rng-tools/issues" 9 SRC_URI = "git://github.com/nhorman/rng-tools.git;branch=master;protocol=https \ 12 file://rng-tools.service \ 32 INITSCRIPT_NAME:${PN}-service = "rng-tools" 36 SYSTEMD_SERVICE:${PN}-service = "rng-tools.service" 43 ${sysconfdir}/init.d/rng-tools \ 44 ${sysconfdir}/default/rng-tools \ 47 # Refer autogen.sh in rng-tools 53 install -Dm 0644 ${UNPACKDIR}/default ${D}${sysconfdir}/default/rng-tools [all …]
|