From b16e4b8d1a59abc67e1e7f2f4a5d297fbac6ee73 Mon Sep 17 00:00:00 2001 From: Christian Lamparter Date: Mon, 15 Feb 2016 00:33:56 +0100 Subject: [PATCH] carl9170 firmware: add get_random_u16 helper The HW has a built-in random number generator. This patch adds a convenient helper to get random 16-bit values in the firmware. Signed-off-by: Christian Lamparter --- carlfw/include/gpio.h | 5 +++++ carlfw/include/io.h | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/carlfw/include/gpio.h b/carlfw/include/gpio.h index a9c0b88..56c554a 100644 --- a/carlfw/include/gpio.h +++ b/carlfw/include/gpio.h @@ -36,6 +36,11 @@ static inline __inline void led_set(const unsigned int ledstate) set(AR9170_GPIO_REG_PORT_DATA, ledstate); } +static inline __inline u16 get_random_u16(void) +{ + return getw(AR9170_RAND_REG_NUM); +} + #ifdef CONFIG_CARL9170FW_GPIO_INTERRUPT void gpio_timer(void); diff --git a/carlfw/include/io.h b/carlfw/include/io.h index d480594..5bdc821 100644 --- a/carlfw/include/io.h +++ b/carlfw/include/io.h @@ -149,4 +149,9 @@ static inline __inline void orb(const volatile uint32_t addr, const volatile uin setb(addr, getb(addr) | val); } +static inline __inline uint16_t getw(const volatile uint32_t addr) +{ + return readw((const volatile void *) addr); +} + #endif /* __CARL9170FW_IO_H */ -- 2.31.1