blob: 9a53e29680f4162d8513fe2a9a00f3b3abbba4c9 [file] [log] [blame]
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00001/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _ASM_POWERPC_ARCHRANDOM_H
3#define _ASM_POWERPC_ARCHRANDOM_H
4
5#ifdef CONFIG_ARCH_RANDOM
6
7#include <asm/machdep.h>
8
Olivier Deprez157378f2022-04-04 15:47:50 +02009static inline bool __must_check arch_get_random_long(unsigned long *v)
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000010{
Olivier Deprez157378f2022-04-04 15:47:50 +020011 return false;
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000012}
13
Olivier Deprez157378f2022-04-04 15:47:50 +020014static inline bool __must_check arch_get_random_int(unsigned int *v)
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000015{
Olivier Deprez157378f2022-04-04 15:47:50 +020016 return false;
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000017}
18
Olivier Deprez157378f2022-04-04 15:47:50 +020019static inline bool __must_check arch_get_random_seed_long(unsigned long *v)
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000020{
21 if (ppc_md.get_random_seed)
22 return ppc_md.get_random_seed(v);
23
Olivier Deprez157378f2022-04-04 15:47:50 +020024 return false;
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000025}
Olivier Deprez157378f2022-04-04 15:47:50 +020026
27static inline bool __must_check arch_get_random_seed_int(unsigned int *v)
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000028{
29 unsigned long val;
Olivier Deprez157378f2022-04-04 15:47:50 +020030 bool rc;
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000031
Olivier Deprez0e641232021-09-23 10:07:05 +020032 rc = arch_get_random_seed_long(&val);
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000033 if (rc)
34 *v = val;
35
36 return rc;
37}
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000038#endif /* CONFIG_ARCH_RANDOM */
39
40#ifdef CONFIG_PPC_POWERNV
41int powernv_hwrng_present(void);
42int powernv_get_random_long(unsigned long *v);
43int powernv_get_random_real_mode(unsigned long *v);
44#else
45static inline int powernv_hwrng_present(void) { return 0; }
46static inline int powernv_get_random_real_mode(unsigned long *v) { return 0; }
47#endif
48
49#endif /* _ASM_POWERPC_ARCHRANDOM_H */