linux/drivers/char/hw_random/rockchip-rng.c

// SPDX-License-Identifier: GPL-2.0
/*
 * rockchip-rng.c True Random Number Generator driver for Rockchip RK3568 SoC
 *
 * Copyright (c) 2018, Fuzhou Rockchip Electronics Co., Ltd.
 * Copyright (c) 2022, Aurelien Jarno
 * Authors:
 *  Lin Jinhan <[email protected]>
 *  Aurelien Jarno <[email protected]>
 */
#include <linux/clk.h>
#include <linux/hw_random.h>
#include <linux/io.h>
#include <linux/iopoll.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/reset.h>
#include <linux/slab.h>

#define RK_RNG_AUTOSUSPEND_DELAY
#define RK_RNG_MAX_BYTE
#define RK_RNG_POLL_PERIOD_US
#define RK_RNG_POLL_TIMEOUT_US

/*
 * TRNG collects osc ring output bit every RK_RNG_SAMPLE_CNT time. The value is
 * a tradeoff between speed and quality and has been adjusted to get a quality
 * of ~900 (~87.5% of FIPS 140-2 successes).
 */
#define RK_RNG_SAMPLE_CNT

/* TRNG registers from RK3568 TRM-Part2, section 5.4.1 */
#define TRNG_RST_CTL
#define TRNG_RNG_CTL
#define TRNG_RNG_CTL_LEN_64_BIT
#define TRNG_RNG_CTL_LEN_128_BIT
#define TRNG_RNG_CTL_LEN_192_BIT
#define TRNG_RNG_CTL_LEN_256_BIT
#define TRNG_RNG_CTL_OSC_RING_SPEED_0
#define TRNG_RNG_CTL_OSC_RING_SPEED_1
#define TRNG_RNG_CTL_OSC_RING_SPEED_2
#define TRNG_RNG_CTL_OSC_RING_SPEED_3
#define TRNG_RNG_CTL_MASK
#define TRNG_RNG_CTL_ENABLE
#define TRNG_RNG_CTL_START
#define TRNG_RNG_SAMPLE_CNT
#define TRNG_RNG_DOUT

struct rk_rng {};

/* The mask in the upper 16 bits determines the bits that are updated */
static void rk_rng_write_ctl(struct rk_rng *rng, u32 val, u32 mask)
{}

static int rk_rng_init(struct hwrng *rng)
{}

static void rk_rng_cleanup(struct hwrng *rng)
{}

static int rk_rng_read(struct hwrng *rng, void *buf, size_t max, bool wait)
{}

static int rk_rng_probe(struct platform_device *pdev)
{}

static int __maybe_unused rk_rng_runtime_suspend(struct device *dev)
{}

static int __maybe_unused rk_rng_runtime_resume(struct device *dev)
{}

static const struct dev_pm_ops rk_rng_pm_ops =;

static const struct of_device_id rk_rng_dt_match[] =;

MODULE_DEVICE_TABLE(of, rk_rng_dt_match);

static struct platform_driver rk_rng_driver =;

module_platform_driver();

MODULE_DESCRIPTION();
MODULE_AUTHOR();
MODULE_AUTHOR();
MODULE_AUTHOR();
MODULE_LICENSE();