rng_plat.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright (c) 2024, MediaTek Inc. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef RNG_PLAT_H
  7. #define RNG_PLAT_H
  8. #include <lib/utils_def.h>
  9. #define MTK_TIMEOUT_POLL 1000
  10. #define MTK_RETRY_CNT 10
  11. #define RNG_DEFAULT_CUTOFF 0x04871C0B
  12. /*******************************************************************************
  13. * TRNG related constants
  14. ******************************************************************************/
  15. #define RNG_STATUS (TRNG_BASE + 0x0004)
  16. #define RNG_SWRST (TRNG_BASE + 0x0010)
  17. #define RNG_IRQ_CFG (TRNG_BASE + 0x0014)
  18. #define RNG_EN (TRNG_BASE + 0x0020)
  19. #define RNG_HTEST (TRNG_BASE + 0x0028)
  20. #define RNG_OUT (TRNG_BASE + 0x0030)
  21. #define RNG_RAW (TRNG_BASE + 0x0038)
  22. #define RNG_SRC (TRNG_BASE + 0x0050)
  23. #define RAW_VALID BIT(12)
  24. #define DRBG_VALID BIT(4)
  25. #define RAW_EN BIT(8)
  26. #define NRBG_EN BIT(4)
  27. #define DRBG_EN BIT(0)
  28. #define IRQ_EN BIT(0)
  29. #define SWRST_B BIT(0)
  30. /* Error conditions */
  31. #define RNG_ERROR GENMASK_32(28, 24)
  32. #define APB_ERROR BIT(16)
  33. /* External swrst */
  34. #define TRNG_SWRST_SET_REG (INFRACFG_AO_BASE + 0x150)
  35. #define TRNG_SWRST_CLR_REG (INFRACFG_AO_BASE + 0x154)
  36. #define RNG_SWRST_B BIT(13)
  37. #endif /* RNG_PLAT_H */