mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-08 16:41:55 +00:00
The TRNG operation is simple: once started it begins to fill up an
internal FIFO with random values. The consumer of these values might
have to wait if the next number is not ready yet.
BRANCH=none
BUG=chrome-os-partner:43025
TEST=with the rest of the patches in place TPM2 gets a stream of
random numbers when required
Change-Id: I877452733377ec5b179fb6df8581af570b4f3668
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/306689
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
23 lines
428 B
C
23 lines
428 B
C
/* Copyright 2015 The Chromium OS Authors. All rights reserved.
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#include "registers.h"
|
|
|
|
void init_trng(void)
|
|
{
|
|
GWRITE(TRNG, POWER_DOWN_B, 1);
|
|
GWRITE(TRNG, GO_EVENT, 1);
|
|
while (GREAD(TRNG, EMPTY))
|
|
;
|
|
GREAD(TRNG, READ_DATA);
|
|
}
|
|
|
|
uint32_t rand(void)
|
|
{
|
|
while (GREAD(TRNG, EMPTY))
|
|
;
|
|
return GREAD(TRNG, READ_DATA);
|
|
}
|