summaryrefslogtreecommitdiff
path: root/Silicon/Atmel/AtSha204a/AtSha204aDriver.h
diff options
context:
space:
mode:
Diffstat (limited to 'Silicon/Atmel/AtSha204a/AtSha204aDriver.h')
-rw-r--r--Silicon/Atmel/AtSha204a/AtSha204aDriver.h81
1 files changed, 81 insertions, 0 deletions
diff --git a/Silicon/Atmel/AtSha204a/AtSha204aDriver.h b/Silicon/Atmel/AtSha204a/AtSha204aDriver.h
new file mode 100644
index 0000000000..315a450d34
--- /dev/null
+++ b/Silicon/Atmel/AtSha204a/AtSha204aDriver.h
@@ -0,0 +1,81 @@
+/** @file
+ Device driver for the Atmel ATSHA204A random number generator.
+
+ Copyright (c) 2018, Linaro Ltd. All rights reserved.<BR>
+
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD
+ License which accompanies this distribution. The full text of the license may
+ be found at http://opensource.org/licenses/bsd-license.php.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef _ATSHA204A_I2C_HWRNG_DRIVER_H_
+#define _ATSHA204A_I2C_HWRNG_DRIVER_H_
+
+#include <Uefi.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiLib.h>
+
+#include <Protocol/Rng.h>
+#include <Protocol/I2cIo.h>
+
+#define ATSHA204A_OUTPUT_SIZE 32
+
+#define ATSHA204A_DEV_SIGNATURE SIGNATURE_32('a','t','s','h')
+
+typedef struct {
+ UINT32 Signature;
+ EFI_I2C_IO_PROTOCOL *I2cIo;
+ EFI_RNG_PROTOCOL Rng;
+} ATSHA204A_DEV;
+
+#define ATSHA204A_DEV_FROM_THIS(a) \
+ CR(a, ATSHA204A_DEV, Rng, ATSHA204A_DEV_SIGNATURE)
+
+#pragma pack(1)
+typedef struct {
+ UINT8 Command;
+ UINT8 Count;
+ UINT8 Opcode;
+ UINT8 Param1;
+ UINT16 Param2;
+ UINT16 Crc;
+} ATSHA204A_I2C_RNG_COMMAND;
+
+typedef struct {
+ UINT8 Count;
+ UINT8 Result[ATSHA204A_OUTPUT_SIZE];
+ UINT16 Crc;
+} ATSHA204A_I2C_RNG_RESULT;
+#pragma pack()
+
+typedef struct {
+ UINTN OperationCount;
+ EFI_I2C_OPERATION Operation;
+} I2C_RNG_REQUEST;
+
+#define ATSHA204A_COMMAND 0x3
+
+#define ATSHA204A_OPCODE_RANDOM 0x1b
+
+extern EFI_COMPONENT_NAME2_PROTOCOL gAtSha204aDriverComponentName2;
+
+EFI_STATUS
+AtSha204aInit (
+ IN EFI_HANDLE DriverBindingHandle,
+ IN EFI_HANDLE ControllerHandle
+ );
+
+EFI_STATUS
+AtSha204aRelease (
+ IN EFI_HANDLE DriverBindingHandle,
+ IN EFI_HANDLE ControllerHandle
+ );
+
+#endif // _ATSHA204A_I2C_HWRNG_DRIVER_H_