/linux/drivers/crypto/ |
H A D | exynos-rng.c | 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() 120 val = exynos_rng_readl(rng, EXYNOS_RNG_STATUS); in exynos_rng_set_seed() 122 dev_warn(rng->dev, "Seed setting not finished\n"); in exynos_rng_set_seed() 126 rng->last_seeding = jiffies; in exynos_rng_set_seed() [all …]
|
H A D | qcom-rng.c | 43 struct qcom_rng *rng; member 53 static int qcom_rng_read(struct qcom_rng *rng, u8 *data, unsigned int max) in qcom_rng_read() argument 61 ret = readl_poll_timeout(rng->base + PRNG_STATUS, val, in qcom_rng_read() 67 val = readl_relaxed(rng->base + PRNG_DATA_OUT); in qcom_rng_read() 90 struct qcom_rng *rng = ctx->rng; in qcom_rng_generate() local 93 ret = clk_prepare_enable(rng->clk); in qcom_rng_generate() 97 mutex_lock(&rng->lock); in qcom_rng_generate() 99 ret = qcom_rng_read(rng, dstn, dlen); in qcom_rng_generate() 101 mutex_unlock(&rng->lock); in qcom_rng_generate() 102 clk_disable_unprepare(rng->clk); in qcom_rng_generate() [all …]
|
/linux/drivers/char/hw_random/ |
H A D | core.c | 56 static int hwrng_init(struct hwrng *rng); 59 static inline int rng_get_data(struct hwrng *rng, u8 *buffer, size_t size, 69 struct hwrng *rng = container_of(kref, struct hwrng, ref); in cleanup_rng() local 71 if (rng->cleanup) in cleanup_rng() 72 rng->cleanup(rng); in cleanup_rng() 74 complete(&rng->cleanup_done); in cleanup_rng() 77 static int set_current_rng(struct hwrng *rng) in set_current_rng() argument 83 err = hwrng_init(rng); in set_current_rng() 88 current_rng = rng; in set_current_rng() 124 struct hwrng *rng; in get_current_rng() local [all …]
|
H A D | Makefile | 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 15 n2-rng-y := n2-drv.o n2-asm.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 | 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 | 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 | rockchip-rng.c | 53 struct hwrng rng; member 60 static void rk_rng_write_ctl(struct rk_rng *rng, u32 val, u32 mask) in rk_rng_write_ctl() argument 62 writel((mask << 16) | val, rng->base + TRNG_RNG_CTL); in rk_rng_write_ctl() 65 static int rk_rng_init(struct hwrng *rng) in rk_rng_init() argument 67 struct rk_rng *rk_rng = container_of(rng, struct rk_rng, rng); in rk_rng_init() 73 dev_err((struct device *) rk_rng->rng.priv, in rk_rng_init() 90 static void rk_rng_cleanup(struct hwrng *rng) in rk_rng_cleanup() argument 92 struct rk_rng *rk_rng = container_of(rng, struct rk_rng, rng); in rk_rng_cleanup() 101 static int rk_rng_read(struct hwrng *rng, void *buf, size_t max, bool wait) in rk_rng_read() argument 103 struct rk_rng *rk_rng = container_of(rng, struct rk_rng, rng); in rk_rng_read() [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 | 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() 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() 84 rng->control_status = devm_ioremap(&pdev->dev, in octeon_rng_probe() [all …]
|
H A D | mxc-rnga.c | 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 126 struct mxc_rng *mxc_rng = container_of(rng, struct mxc_rng, rng); in mxc_rnga_cleanup() 144 mxc_rng->rng.name = "mxc-rnga"; in mxc_rnga_probe() [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 | 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() 96 priv->rng.read = pic32_rng_read; in pic32_rng_probe() [all …]
|
H A D | ingenic-rng.c | 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() 100 priv->rng.name = pdev->name; in ingenic_rng_probe() 101 priv->rng.init = ingenic_rng_init; in ingenic_rng_probe() 102 priv->rng.cleanup = ingenic_rng_cleanup; in ingenic_rng_probe() [all …]
|
H A D | cavium-rng.c | 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() 34 rng->control_status = pcim_iomap(pdev, 0, 0); in cavium_rng_probe() 35 if (!rng->control_status) { in cavium_rng_probe() 43 rng->control_status); in cavium_rng_probe() 45 pci_set_drvdata(pdev, rng); in cavium_rng_probe() 51 writeq(0, rng->control_status); in cavium_rng_probe() 64 struct cavium_rng_pf *rng; in cavium_rng_remove() local 66 rng = pci_get_drvdata(pdev); in cavium_rng_remove() [all …]
|
H A D | ingenic-trng.c | 32 struct hwrng rng; member 35 static int ingenic_trng_init(struct hwrng *rng) in ingenic_trng_init() argument 37 struct ingenic_trng *trng = container_of(rng, struct ingenic_trng, rng); in ingenic_trng_init() 47 static void ingenic_trng_cleanup(struct hwrng *rng) in ingenic_trng_cleanup() argument 49 struct ingenic_trng *trng = container_of(rng, struct ingenic_trng, rng); in ingenic_trng_cleanup() 57 static int ingenic_trng_read(struct hwrng *rng, void *buf, size_t max, bool wait) in ingenic_trng_read() argument 59 struct ingenic_trng *trng = container_of(rng, struct ingenic_trng, rng); in ingenic_trng_read() 96 trng->rng.name = pdev->name; in ingenic_trng_probe() 97 trng->rng.init = ingenic_trng_init; in ingenic_trng_probe() 98 trng->rng.cleanup = ingenic_trng_cleanup; in ingenic_trng_probe() [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 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() 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() 186 priv->rng.name = "iproc-rng200"; in iproc_rng200_probe() 187 priv->rng.read = iproc_rng200_read; in iproc_rng200_probe() [all …]
|
H A D | bcm2835-rng.c | 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 118 struct bcm2835_rng_priv *priv = to_rng_priv(rng); in bcm2835_rng_cleanup() [all …]
|
H A D | ba431-rng.c | 42 struct hwrng rng; member 115 static int ba431_trng_read(struct hwrng *rng, void *buf, size_t max, bool wait) in ba431_trng_read() argument 117 struct ba431_trng *ba431 = container_of(rng, struct ba431_trng, rng); in ba431_trng_read() 155 static void ba431_trng_cleanup(struct hwrng *rng) in ba431_trng_cleanup() argument 157 struct ba431_trng *ba431 = container_of(rng, struct ba431_trng, rng); in ba431_trng_cleanup() 163 static int ba431_trng_init(struct hwrng *rng) in ba431_trng_init() argument 165 struct ba431_trng *ba431 = container_of(rng, struct ba431_trng, rng); in ba431_trng_init() 187 ba431->rng.name = pdev->name; in ba431_trng_probe() 188 ba431->rng.init = ba431_trng_init; in ba431_trng_probe() 189 ba431->rng.cleanup = ba431_trng_cleanup; in ba431_trng_probe() [all …]
|
H A D | ks-sa-rng.c | 84 struct hwrng rng; member 112 static int ks_sa_rng_init(struct hwrng *rng) in ks_sa_rng_init() argument 115 struct ks_sa_rng *ks_sa_rng = container_of(rng, struct ks_sa_rng, rng); in ks_sa_rng_init() 152 static void ks_sa_rng_cleanup(struct hwrng *rng) in ks_sa_rng_cleanup() argument 154 struct ks_sa_rng *ks_sa_rng = container_of(rng, struct ks_sa_rng, rng); in ks_sa_rng_cleanup() 162 static int ks_sa_rng_data_read(struct hwrng *rng, u32 *data) in ks_sa_rng_data_read() argument 164 struct ks_sa_rng *ks_sa_rng = container_of(rng, struct ks_sa_rng, rng); in ks_sa_rng_data_read() 176 static int ks_sa_rng_data_present(struct hwrng *rng, int wait) in ks_sa_rng_data_present() argument 178 struct ks_sa_rng *ks_sa_rng = container_of(rng, struct ks_sa_rng, rng); in ks_sa_rng_data_present() 215 ks_sa_rng->rng = (struct hwrng) { in ks_sa_rng_probe() [all …]
|
/linux/arch/powerpc/platforms/powernv/ |
H A D | rng.c | 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() 100 static __init void rng_init_per_cpu(struct pnv_rng *rng, in rng_init_per_cpu() argument [all …]
|
/linux/crypto/ |
H A D | jitterentropy-kcapi.c | 202 struct jitterentropy *rng = crypto_tfm_ctx(tfm); in jent_kcapi_cleanup() local 204 spin_lock(&rng->jent_lock); in jent_kcapi_cleanup() 206 if (rng->sdesc) { in jent_kcapi_cleanup() 207 shash_desc_zero(rng->sdesc); in jent_kcapi_cleanup() 208 kfree(rng->sdesc); in jent_kcapi_cleanup() 210 rng->sdesc = NULL; in jent_kcapi_cleanup() 212 if (rng->tfm) in jent_kcapi_cleanup() 213 crypto_free_shash(rng->tfm); in jent_kcapi_cleanup() 214 rng->tfm = NULL; in jent_kcapi_cleanup() 216 if (rng->entropy_collector) in jent_kcapi_cleanup() [all …]
|
/linux/include/linux/ |
H A D | hw_random.h | 40 int (*init)(struct hwrng *rng); 41 void (*cleanup)(struct hwrng *rng); 42 int (*data_present)(struct hwrng *rng, int wait); 43 int (*data_read)(struct hwrng *rng, u32 *data); 44 int (*read)(struct hwrng *rng, void *data, size_t max, bool wait); 58 extern int hwrng_register(struct hwrng *rng); 59 extern int devm_hwrng_register(struct device *dev, struct hwrng *rng); 61 extern void hwrng_unregister(struct hwrng *rng); 62 extern void devm_hwrng_unregister(struct device *dve, struct hwrng *rng); 64 extern long hwrng_msleep(struct hwrng *rng, unsigned int msecs); [all …]
|
/linux/drivers/crypto/caam/ |
H A D | caamrng.c | 38 struct hwrng rng; member 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() 205 static inline void test_mode_once(struct hwrng *rng, bool wait) in test_mode_once() argument 207 test_len(rng, 32, wait); in test_mode_once() [all …]
|
/linux/drivers/crypto/amcc/ |
H A D | crypto4xx_trng.c | 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() 75 struct hwrng *rng = NULL; in ppc4xx_trng_probe() local 90 rng = kzalloc(sizeof(*rng), GFP_KERNEL); in ppc4xx_trng_probe() 91 if (!rng) in ppc4xx_trng_probe() 94 rng->name = KBUILD_MODNAME; in ppc4xx_trng_probe() 95 rng->data_present = ppc4xx_trng_data_present; in ppc4xx_trng_probe() 96 rng->data_read = ppc4xx_trng_data_read; in ppc4xx_trng_probe() [all …]
|