]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
mxs: tx28: init random seed to get at least some sort of randomness
authorLothar Waßmann <LW@KARO-electronics.de>
Mon, 15 Jul 2013 10:04:26 +0000 (12:04 +0200)
committerLothar Waßmann <LW@KARO-electronics.de>
Mon, 15 Jul 2013 10:04:26 +0000 (12:04 +0200)
board/karo/tx28/tx28.c
include/configs/tx28.h

index c0c9107da70c7ed7eab56632c238828289b637cf..79fe6f477522c36f17657dc4a4f4bf2f4deade2d 100644 (file)
@@ -100,8 +100,31 @@ static const iomux_cfg_t tx28_pads[] = {
 /*
  * Functions
  */
+
+/* provide at least _some_ sort of randomness */
+#define MAX_LOOPS       100
+
+static u32 random;
+
+static inline void random_init(void)
+{
+       struct mxs_digctl_regs *digctl_regs = (void *)MXS_DIGCTL_BASE;
+       u32 seed = 0;
+       int i;
+
+       for (i = 0; i < MAX_LOOPS; i++) {
+               unsigned int usec = readl(&digctl_regs->hw_digctl_microseconds);
+
+               seed = get_timer(usec + random + seed);
+               srand(seed);
+               random = rand();
+       }
+}
+
 int board_early_init_f(void)
 {
+       random_init();
+
        /* IO0 clock at 480MHz */
        mx28_set_ioclk(MXC_IOCLK0, 480000);
        /* IO1 clock at 480MHz */
index 4a060d92546227cdc67260fbac644dc8373d81d2..528853592ffdc729c6f80c712daa6202834b9582 100644 (file)
 #define CONFIG_BOOTP_SUBNETMASK
 #define CONFIG_BOOTP_GATEWAY
 #define CONFIG_BOOTP_DNS
+#define CONFIG_BOOTP_RANDOM_ID
 #endif
 
 #ifndef CONFIG_ENV_IS_NOWHERE