* [PATCH edk2-platforms v2 0/7] Add Secure96 mezzanine support
@ 2018-02-20 17:49 Ard Biesheuvel
2018-02-20 17:49 ` [PATCH edk2-platforms v2 1/7] Silicon/Atmel: add support for AtSha204a RNG Ard Biesheuvel
` (7 more replies)
0 siblings, 8 replies; 21+ messages in thread
From: Ard Biesheuvel @ 2018-02-20 17:49 UTC (permalink / raw)
To: edk2-devel; +Cc: leif.lindholm, Ard Biesheuvel
Almost a complete rewrite of the v1. I omitted the patches that add SPI
and I2C DT nodes to the SynQuacer DTS. I did include the v2 of the Atmel
AtSha204a driver, since the latter patches depend on it.
This version implements a complete split between the generic 96boards
LS connector support and its associated plumbing (defining which I2C,
SPI and GPIO controllers are connected) on the one hand, and support
for the Secure96 mezzanine board in particular on the other. More
specifically, all Secure96 PCDs were dropped, and the only platform
specific configuration that remains is including the Secure96 driver
and the driver for its peripherals to the build.
Patch #1 is v2 of the AtSha204a driver, with Leif's review comments
addressed.
Patch #2 introduces the mezzanine protocol, which abstracts away from
any particular mezzanine implementation.
Patch #3 introduces the generic I2C plumbing for any mezzanine that exposes
I2C peripherals.
Patch #4 implements the protocol that asserts the presence of a 96boards LS
connector and the type of mezzanine connected to it.
Patch #5 adds the Secure96 driver, which incorporates the DT overlay, and
a description of the I2C peripheral.
Patch #6 adds a generic driver for configuring the type of mezzanine, and
to interface with it at end of DXE time to install the appropriate DT
overlay.
Patch #7 wires everything up for the DeveloperBox platform.
Ard Biesheuvel (7):
Silicon/Atmel: add support for AtSha204a RNG
Platform/NinetySixBoards: introduce package and mezzanine protocol
Platform/NinetySixBoards: introduce I2C driver
Platform/NinetySixBoards: introduce LsConnector protocol
Platform/NinetySixBoards: add a driver for the Secure96 mezzanine
board
Platform/NinetySixBoards: add core driver for LS connector and config
Platform/Socionext/DeveloperBox: add 96boards mezzanine support
Platform/NinetySixBoards/Include/Guid/FormSet.h | 23 ++
Platform/NinetySixBoards/Include/Protocol/LsConnector.h | 35 +++
Platform/NinetySixBoards/Include/Protocol/Mezzanine.h | 71 +++++
Platform/NinetySixBoards/NinetySixBoards.dec | 73 +++++
Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.c | 221 ++++++++++++++
Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.h | 32 ++
Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.inf | 57 ++++
Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsHii.uni | 27 ++
Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsHii.vfr | 51 ++++
Platform/NinetySixBoards/NinetySixBoardsI2cDxe/NinetySixBoardsI2cDxe.c | 202 +++++++++++++
Platform/NinetySixBoards/NinetySixBoardsI2cDxe/NinetySixBoardsI2cDxe.inf | 51 ++++
Platform/NinetySixBoards/Secure96Dxe/Secure96.dts | 76 +++++
Platform/NinetySixBoards/Secure96Dxe/Secure96.h | 26 ++
Platform/NinetySixBoards/Secure96Dxe/Secure96Dxe.c | 211 +++++++++++++
Platform/NinetySixBoards/Secure96Dxe/Secure96Dxe.inf | 67 +++++
Platform/Socionext/DeveloperBox/DeveloperBox.dsc | 34 +++
Platform/Socionext/DeveloperBox/DeveloperBox.fdf | 10 +
Silicon/Atmel/AtSha204a/AtSha204a.dec | 22 ++
Silicon/Atmel/AtSha204a/AtSha204aDriver.c | 309 ++++++++++++++++++++
Silicon/Atmel/AtSha204a/AtSha204aDriver.h | 81 +++++
Silicon/Atmel/AtSha204a/AtSha204aDxe.inf | 52 ++++
Silicon/Atmel/AtSha204a/ComponentName.c | 186 ++++++++++++
Silicon/Atmel/AtSha204a/DriverBinding.c | 242 +++++++++++++++
Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c | 9 +
Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf | 2 +
25 files changed, 2170 insertions(+)
create mode 100644 Platform/NinetySixBoards/Include/Guid/FormSet.h
create mode 100644 Platform/NinetySixBoards/Include/Protocol/LsConnector.h
create mode 100644 Platform/NinetySixBoards/Include/Protocol/Mezzanine.h
create mode 100644 Platform/NinetySixBoards/NinetySixBoards.dec
create mode 100644 Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.c
create mode 100644 Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.h
create mode 100644 Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.inf
create mode 100644 Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsHii.uni
create mode 100644 Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsHii.vfr
create mode 100644 Platform/NinetySixBoards/NinetySixBoardsI2cDxe/NinetySixBoardsI2cDxe.c
create mode 100644 Platform/NinetySixBoards/NinetySixBoardsI2cDxe/NinetySixBoardsI2cDxe.inf
create mode 100644 Platform/NinetySixBoards/Secure96Dxe/Secure96.dts
create mode 100644 Platform/NinetySixBoards/Secure96Dxe/Secure96.h
create mode 100644 Platform/NinetySixBoards/Secure96Dxe/Secure96Dxe.c
create mode 100644 Platform/NinetySixBoards/Secure96Dxe/Secure96Dxe.inf
create mode 100644 Silicon/Atmel/AtSha204a/AtSha204a.dec
create mode 100644 Silicon/Atmel/AtSha204a/AtSha204aDriver.c
create mode 100644 Silicon/Atmel/AtSha204a/AtSha204aDriver.h
create mode 100644 Silicon/Atmel/AtSha204a/AtSha204aDxe.inf
create mode 100644 Silicon/Atmel/AtSha204a/ComponentName.c
create mode 100644 Silicon/Atmel/AtSha204a/DriverBinding.c
--
2.11.0
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH edk2-platforms v2 1/7] Silicon/Atmel: add support for AtSha204a RNG
2018-02-20 17:49 [PATCH edk2-platforms v2 0/7] Add Secure96 mezzanine support Ard Biesheuvel
@ 2018-02-20 17:49 ` Ard Biesheuvel
2018-02-22 13:08 ` Leif Lindholm
2018-02-20 17:49 ` [PATCH edk2-platforms v2 2/7] Platform/NinetySixBoards: introduce package and mezzanine protocol Ard Biesheuvel
` (6 subsequent siblings)
7 siblings, 1 reply; 21+ messages in thread
From: Ard Biesheuvel @ 2018-02-20 17:49 UTC (permalink / raw)
To: edk2-devel; +Cc: leif.lindholm, Ard Biesheuvel
This adds support for using the random number generator in the Atmel
AtSha204a over I2C. Other functionality of the chip is currently
unsupported.
Note that the the I2C support in this device essentially violates the
protocol layering, by requiring that the device is woken up by driving
SDA low for a certain amount of time, which is something that cannot be
expressed in terms of an I2C packet sent to the device's slave address.
Instead, the slave address 0x0 is added to the device's address array,
and the wake is sent by sending a dummy write to address 0x0, and
ignoring the subsequent error. This requires the I2C bus to be clocked
at 100 kHz.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
Silicon/Atmel/AtSha204a/AtSha204a.dec | 22 ++
Silicon/Atmel/AtSha204a/AtSha204aDriver.c | 309 ++++++++++++++++++++
Silicon/Atmel/AtSha204a/AtSha204aDriver.h | 81 +++++
Silicon/Atmel/AtSha204a/AtSha204aDxe.inf | 52 ++++
Silicon/Atmel/AtSha204a/ComponentName.c | 186 ++++++++++++
Silicon/Atmel/AtSha204a/DriverBinding.c | 242 +++++++++++++++
6 files changed, 892 insertions(+)
diff --git a/Silicon/Atmel/AtSha204a/AtSha204a.dec b/Silicon/Atmel/AtSha204a/AtSha204a.dec
new file mode 100644
index 000000000000..f1fdea59843d
--- /dev/null
+++ b/Silicon/Atmel/AtSha204a/AtSha204a.dec
@@ -0,0 +1,22 @@
+## @file
+#
+# Copyright (c) 2018, Linaro Ltd. All rights reserved.
+#
+# 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.
+#
+##
+
+[Defines]
+ DEC_SPECIFICATION = 0x0001001A
+ PACKAGE_NAME = AtSha204a
+ PACKAGE_GUID = 86085a5b-355b-4e72-92ab-fc3e1d71c9ad
+ PACKAGE_VERSION = 0.1
+
+[Guids]
+ gAtSha204aI2cDeviceGuid = { 0x52e9b64b, 0x4ec1, 0x4bd6, { 0x9e, 0x1c, 0x6d, 0xac, 0xef, 0x35, 0x18, 0x21 } }
diff --git a/Silicon/Atmel/AtSha204a/AtSha204aDriver.c b/Silicon/Atmel/AtSha204a/AtSha204aDriver.c
new file mode 100644
index 000000000000..5db2de21a731
--- /dev/null
+++ b/Silicon/Atmel/AtSha204a/AtSha204aDriver.c
@@ -0,0 +1,309 @@
+/** @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.
+
+**/
+
+#include "AtSha204aDriver.h"
+
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/MemoryAllocationLib.h>
+
+#define MAX_RETRIES 5
+
+// Don't bother calculating the CRC for the immutable RANDOM opcode packet
+#define OPCODE_COMMAND_PACKET_CRC 0xcd24
+
+/**
+ Returns information about the random number generation implementation.
+
+ @param[in] This A pointer to the EFI_RNG_PROTOCOL instance.
+ @param[in,out] AlgorithmListSize On input, the size in bytes of AlgorithmList
+ On output with a return code of EFI_SUCCESS,
+ the size in bytes of the data returned in
+ AlgorithmList. On output with a return
+ code of EFI_BUFFER_TOO_SMALL, the size of
+ AlgorithmList required to obtain the list.
+ @param[out] AlgorithmList A caller-allocated memory buffer filled by
+ the driver with one EFI_RNG_ALGORITHM
+ element for each supported RNG algorithm.
+ The list must not change across multiple
+ calls to the same driver. The first
+ algorithm in the list is the default
+ algorithm for the driver.
+
+ @retval EFI_SUCCESS The RNG algorithm list was returned
+ successfully.
+ @retval EFI_UNSUPPORTED The services is not supported by this driver
+ @retval EFI_DEVICE_ERROR The list of algorithms could not be
+ retrieved due to a hardware or firmware
+ error.
+ @retval EFI_INVALID_PARAMETER One or more of the parameters are incorrect.
+ @retval EFI_BUFFER_TOO_SMALL The buffer RNGAlgorithmList is too small to
+ hold the result.
+
+**/
+STATIC
+EFI_STATUS
+EFIAPI
+AtSha240aGetInfo (
+ IN EFI_RNG_PROTOCOL *This,
+ IN OUT UINTN *AlgorithmListSize,
+ OUT EFI_RNG_ALGORITHM *AlgorithmList
+)
+{
+ UINTN Size;
+
+ //
+ // We only implement the raw algorithm
+ //
+ Size = sizeof (EFI_GUID);
+
+ if (*AlgorithmListSize < Size) {
+ *AlgorithmListSize = Size;
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ CopyGuid (AlgorithmList, &gEfiRngAlgorithmRaw);
+ *AlgorithmListSize = Size;
+
+ return EFI_SUCCESS;
+}
+
+
+/**
+ Produces and returns an RNG value using either the default or specified RNG
+ algorithm.
+
+ @param[in] This A pointer to the EFI_RNG_PROTOCOL instance.
+ @param[in] Algorithm A pointer to the EFI_RNG_ALGORITHM that
+ identifies the RNG algorithm to use. May be
+ NULL in which case the function will use its
+ default RNG algorithm.
+ @param[in] ValueLength The length in bytes of the memory buffer
+ pointed to by RNGValue. The driver shall
+ return exactly this numbers of bytes.
+ @param[out] Value A caller-allocated memory buffer filled by the
+ driver with the resulting RNG value.
+
+ @retval EFI_SUCCESS The RNG value was returned successfully.
+ @retval EFI_UNSUPPORTED The algorithm specified by RNGAlgorithm is not
+ supported by this driver.
+ @retval EFI_DEVICE_ERROR An RNG value could not be retrieved due to a
+ hardware or firmware error.
+ @retval EFI_NOT_READY There is not enough random data available to
+ satisfy the length requested by
+ RNGValueLength.
+ @retval EFI_INVALID_PARAMETER RNGValue is NULL or RNGValueLength is zero.
+
+**/
+STATIC
+EFI_STATUS
+EFIAPI
+AtSha240aGetRNG (
+ IN EFI_RNG_PROTOCOL *This,
+ IN EFI_RNG_ALGORITHM *Algorithm OPTIONAL,
+ IN UINTN ValueLength,
+ OUT UINT8 *Value
+)
+{
+ EFI_STATUS Status;
+ ATSHA204A_DEV *AtSha204a;
+ ATSHA204A_I2C_RNG_COMMAND Command;
+ ATSHA204A_I2C_RNG_RESULT Result;
+ I2C_RNG_REQUEST Request;
+ I2C_RNG_REQUEST Response;
+ UINTN Retries;
+
+ if (Algorithm != NULL && !CompareGuid (Algorithm, &gEfiRngAlgorithmRaw)) {
+ return EFI_UNSUPPORTED;
+ }
+
+ AtSha204a = ATSHA204A_DEV_FROM_THIS (This);
+
+ Request.OperationCount = 1;
+ Request.Operation.Flags = 0;
+
+ Command.Command = ATSHA204A_COMMAND;
+ Command.Count = sizeof (Command) - 1;
+ Command.Opcode = ATSHA204A_OPCODE_RANDOM;
+ Command.Param1 = 0;
+ Command.Param2 = 0;
+ Command.Crc = OPCODE_COMMAND_PACKET_CRC;
+
+ Response.OperationCount = 1;
+ Response.Operation.Flags = I2C_FLAG_READ;
+ Response.Operation.LengthInBytes = sizeof (Result);
+ Response.Operation.Buffer = (VOID *)&Result;
+
+ Retries = 0;
+ while (ValueLength > 0) {
+ //
+ // The AtSha204a will go back to sleep right in the middle of a transaction
+ // if it does not complete in ~1.3 seconds. So send the wake sequence for
+ // each iteration, which consists of a dummy write to slave address 0x0.
+ //
+ Request.Operation.LengthInBytes = 0;
+ Status = AtSha204a->I2cIo->QueueRequest (AtSha204a->I2cIo, 1, NULL,
+ (VOID *)&Request, NULL);
+ DEBUG ((DEBUG_INFO, "%a: wake AtSha204a: I2cIo->QueueRequest() - %r\n",
+ __FUNCTION__, Status));
+
+ gBS->Stall (2500); // wait 2.5 ms for wake to complete
+
+ Request.Operation.LengthInBytes = sizeof (Command);
+ Request.Operation.Buffer = (VOID *)&Command;
+ Status = AtSha204a->I2cIo->QueueRequest (AtSha204a->I2cIo, 0, NULL,
+ (VOID *)&Request, NULL);
+ if (EFI_ERROR (Status)) {
+ if (++Retries <= MAX_RETRIES) {
+ continue;
+ }
+ DEBUG ((DEBUG_ERROR, "%a: I2C request transfer failed, Status == %r\n",
+ __FUNCTION__, Status));
+ return EFI_DEVICE_ERROR;
+ }
+
+ gBS->Stall (50 * 1000); // 50 ms max execution time for RANDOM opcode
+
+ Status = AtSha204a->I2cIo->QueueRequest (AtSha204a->I2cIo, 0, NULL,
+ (VOID *)&Response, NULL);
+ if (EFI_ERROR (Status)) {
+ if (++Retries <= MAX_RETRIES) {
+ continue;
+ }
+ DEBUG ((DEBUG_ERROR, "%a: I2C response transfer failed, Status == %r\n",
+ __FUNCTION__, Status));
+ return EFI_DEVICE_ERROR;
+ }
+
+ if (Result.Count < sizeof (Result)) {
+ //
+ // Incomplete packet received, most likely due to an error. Retry.
+ //
+ if (++Retries <= MAX_RETRIES) {
+ continue;
+ }
+ DEBUG ((DEBUG_WARN, "%a: incomplete packet received\n", __FUNCTION__));
+ return EFI_DEVICE_ERROR;
+ }
+
+ gBS->CopyMem (Value, Result.Result, MIN (ValueLength,
+ ATSHA204A_OUTPUT_SIZE));
+ if (ValueLength < ATSHA204A_OUTPUT_SIZE) {
+ break;
+ }
+
+ Value += ATSHA204A_OUTPUT_SIZE;
+ ValueLength -= ATSHA204A_OUTPUT_SIZE;
+ Retries = 0;
+ }
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+AtSha204aInit (
+ IN EFI_HANDLE DriverBindingHandle,
+ IN EFI_HANDLE ControllerHandle
+ )
+{
+ EFI_STATUS Status;
+ ATSHA204A_DEV *AtSha204a;
+
+ Status = gBS->AllocatePool (EfiBootServicesData, sizeof (ATSHA204A_DEV),
+ (VOID **) &AtSha204a);
+ if (EFI_ERROR (Status)) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ AtSha204a->Signature = ATSHA204A_DEV_SIGNATURE;
+ AtSha204a->Rng.GetInfo = AtSha240aGetInfo;
+ AtSha204a->Rng.GetRNG = AtSha240aGetRNG;
+
+ //
+ // Open I2C I/O Protocol
+ //
+ Status = gBS->OpenProtocol (ControllerHandle,
+ &gEfiI2cIoProtocolGuid,
+ (VOID **)&AtSha204a->I2cIo,
+ DriverBindingHandle,
+ ControllerHandle,
+ EFI_OPEN_PROTOCOL_BY_DRIVER);
+ if (EFI_ERROR (Status)) {
+ goto ErrorFreeDev;
+ }
+
+ Status = gBS->InstallProtocolInterface (&ControllerHandle,
+ &gEfiRngProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ &AtSha204a->Rng);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR,
+ "Failed to install RNG protocol interface (Status == %r)\n",
+ Status));
+ goto ErrorCloseProtocol;
+ }
+
+ return EFI_SUCCESS;
+
+ErrorCloseProtocol:
+ gBS->CloseProtocol (ControllerHandle, &gEfiI2cIoProtocolGuid,
+ DriverBindingHandle, ControllerHandle);
+
+ErrorFreeDev:
+ gBS->FreePool (AtSha204a);
+
+ return Status;
+}
+
+EFI_STATUS
+AtSha204aRelease (
+ IN EFI_HANDLE DriverBindingHandle,
+ IN EFI_HANDLE ControllerHandle
+ )
+{
+ EFI_RNG_PROTOCOL *Rng;
+ ATSHA204A_DEV *AtSha204a;
+ EFI_STATUS Status;
+
+ Status = gBS->HandleProtocol (ControllerHandle,
+ &gEfiRngProtocolGuid,
+ (VOID **)&Rng);
+ ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ AtSha204a = ATSHA204A_DEV_FROM_THIS (Rng);
+
+ Status = gBS->UninstallProtocolInterface (ControllerHandle,
+ &gEfiRngProtocolGuid,
+ Rng);
+ ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Status = gBS->CloseProtocol (ControllerHandle,
+ &gEfiI2cIoProtocolGuid,
+ DriverBindingHandle,
+ ControllerHandle);
+ ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ gBS->FreePool (AtSha204a);
+
+ return EFI_SUCCESS;
+}
diff --git a/Silicon/Atmel/AtSha204a/AtSha204aDriver.h b/Silicon/Atmel/AtSha204a/AtSha204aDriver.h
new file mode 100644
index 000000000000..315a450d34f2
--- /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_
diff --git a/Silicon/Atmel/AtSha204a/AtSha204aDxe.inf b/Silicon/Atmel/AtSha204a/AtSha204aDxe.inf
new file mode 100644
index 000000000000..fe90cc538114
--- /dev/null
+++ b/Silicon/Atmel/AtSha204a/AtSha204aDxe.inf
@@ -0,0 +1,52 @@
+## @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.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x0001001A
+ BASE_NAME = AtSha204aDxe
+ FILE_GUID = 8b8f683b-f376-4ba0-b8d7-b4bbd30319cc
+ MODULE_TYPE = UEFI_DRIVER
+ VERSION_STRING = 1.0
+ ENTRY_POINT = EntryPoint
+ UNLOAD_IMAGE = UnloadImage
+
+#
+# VALID_ARCHITECTURES = AARCH64 ARM EBC IA32 IPF X64
+#
+
+[Sources]
+ AtSha204aDriver.c
+ AtSha204aDriver.h
+ ComponentName.c
+ DriverBinding.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ Silicon/Atmel/AtSha204a/AtSha204a.dec
+
+[LibraryClasses]
+ BaseMemoryLib
+ DebugLib
+ UefiBootServicesTableLib
+ UefiDriverEntryPoint
+ UefiLib
+
+[Protocols]
+ gEfiRngProtocolGuid # PROTOCOL BY_START
+ gEfiI2cIoProtocolGuid # PROTOCOL TO_START
+
+[Guids]
+ gAtSha204aI2cDeviceGuid
+ gEfiRngAlgorithmRaw
diff --git a/Silicon/Atmel/AtSha204a/ComponentName.c b/Silicon/Atmel/AtSha204a/ComponentName.c
new file mode 100644
index 000000000000..9893e7c4c2bf
--- /dev/null
+++ b/Silicon/Atmel/AtSha204a/ComponentName.c
@@ -0,0 +1,186 @@
+/** @file
+ UEFI Component Name(2) protocol implementation for AtSha204a driver.
+
+ Copyright (c) 2018, Linaro Ltd. All rights reserved.
+
+ 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.
+
+**/
+
+#include "AtSha204aDriver.h"
+
+STATIC EFI_UNICODE_STRING_TABLE mAtSha204aDriverNameTable[] = {
+ {
+ "en",
+ (CHAR16 *)L"AtSha204a RNG I2C driver"
+ },
+ { }
+};
+
+STATIC EFI_UNICODE_STRING_TABLE mAtSha204aControllerNameTable[] = {
+ {
+ "en",
+ (CHAR16 *)L"AtSha204a Random Number Generator (I2C)"
+ },
+ { }
+};
+
+/**
+ Retrieves a Unicode string that is the user readable name of the driver.
+
+ This function retrieves the user readable name of a driver in the form of a
+ Unicode string. If the driver specified by This has a user readable name in
+ the language specified by Language, then a pointer to the driver name is
+ returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
+ by This does not support the language specified by Language,
+ then EFI_UNSUPPORTED is returned.
+
+ @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
+ EFI_COMPONENT_NAME_PROTOCOL instance.
+
+ @param Language[in] A pointer to a Null-terminated ASCII string
+ array indicating the language. This is the
+ language of the driver name that the caller is
+ requesting, and it must match one of the
+ languages specified in SupportedLanguages. The
+ number of languages supported by a driver is up
+ to the driver writer. Language is specified
+ in RFC 4646 or ISO 639-2 language code format.
+
+ @param DriverName[out] A pointer to the Unicode string to return.
+ This Unicode string is the name of the
+ driver specified by This in the language
+ specified by Language.
+
+ @retval EFI_SUCCESS The Unicode string for the Driver specified by
+ This and the language specified by Language was
+ returned in DriverName.
+
+ @retval EFI_INVALID_PARAMETER Language is NULL.
+
+ @retval EFI_INVALID_PARAMETER DriverName is NULL.
+
+ @retval EFI_UNSUPPORTED The driver specified by This does not support
+ the language specified by Language.
+
+**/
+STATIC
+EFI_STATUS
+EFIAPI
+AtSha204aGetDriverName (
+ IN EFI_COMPONENT_NAME2_PROTOCOL *This,
+ IN CHAR8 *Language,
+ OUT CHAR16 **DriverName
+ )
+{
+ return LookupUnicodeString2 (Language,
+ This->SupportedLanguages,
+ mAtSha204aDriverNameTable,
+ DriverName,
+ FALSE);
+}
+
+/**
+ Retrieves a Unicode string that is the user readable name of the controller
+ that is being managed by a driver.
+
+ This function retrieves the user readable name of the controller specified by
+ ControllerHandle and ChildHandle in the form of a Unicode string. If the
+ driver specified by This has a user readable name in the language specified by
+ Language, then a pointer to the controller name is returned in ControllerName,
+ and EFI_SUCCESS is returned. If the driver specified by This is not currently
+ managing the controller specified by ControllerHandle and ChildHandle,
+ then EFI_UNSUPPORTED is returned. If the driver specified by This does not
+ support the language specified by Language, then EFI_UNSUPPORTED is returned.
+
+ @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
+ EFI_COMPONENT_NAME_PROTOCOL instance.
+
+ @param ControllerHandle[in] The handle of a controller that the driver
+ specified by This is managing. This handle
+ specifies the controller whose name is to be
+ returned.
+
+ @param ChildHandle[in] The handle of the child controller to retrieve
+ the name of. This is an optional parameter that
+ may be NULL. It will be NULL for device
+ drivers. It will also be NULL for a bus drivers
+ that wish to retrieve the name of the bus
+ controller. It will not be NULL for a bus
+ driver that wishes to retrieve the name of a
+ child controller.
+
+ @param Language[in] A pointer to a Null-terminated ASCII string
+ array indicating the language. This is the
+ language of the driver name that the caller is
+ requesting, and it must match one of the
+ languages specified in SupportedLanguages. The
+ number of languages supported by a driver is up
+ to the driver writer. Language is specified in
+ RFC 4646 or ISO 639-2 language code format.
+
+ @param ControllerName[out] A pointer to the Unicode string to return.
+ This Unicode string is the name of the
+ controller specified by ControllerHandle and
+ ChildHandle in the language specified by
+ Language from the point of view of the driver
+ specified by This.
+
+ @retval EFI_SUCCESS The Unicode string for the user readable name in
+ the language specified by Language for the
+ driver specified by This was returned in
+ DriverName.
+
+ @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
+
+ @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
+ EFI_HANDLE.
+
+ @retval EFI_INVALID_PARAMETER Language is NULL.
+
+ @retval EFI_INVALID_PARAMETER ControllerName is NULL.
+
+ @retval EFI_UNSUPPORTED The driver specified by This is not currently
+ managing the controller specified by
+ ControllerHandle and ChildHandle.
+
+ @retval EFI_UNSUPPORTED The driver specified by This does not support
+ the language specified by Language.
+
+**/
+STATIC
+EFI_STATUS
+EFIAPI
+AtSha204aGetControllerName (
+ IN EFI_COMPONENT_NAME2_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
+ )
+{
+ if (ChildHandle != NULL) {
+ return EFI_UNSUPPORTED;
+ }
+
+ return LookupUnicodeString2 (Language,
+ This->SupportedLanguages,
+ mAtSha204aControllerNameTable,
+ ControllerName,
+ FALSE);
+}
+
+//
+// EFI Component Name 2 Protocol
+//
+EFI_COMPONENT_NAME2_PROTOCOL gAtSha204aDriverComponentName2 = {
+ AtSha204aGetDriverName,
+ AtSha204aGetControllerName,
+ "en"
+};
diff --git a/Silicon/Atmel/AtSha204a/DriverBinding.c b/Silicon/Atmel/AtSha204a/DriverBinding.c
new file mode 100644
index 000000000000..17e61f96e8c5
--- /dev/null
+++ b/Silicon/Atmel/AtSha204a/DriverBinding.c
@@ -0,0 +1,242 @@
+/** @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.
+
+**/
+
+#include <Library/UefiDriverEntryPoint.h>
+
+#include "AtSha204aDriver.h"
+
+/**
+ Tests to see if this driver supports a given controller.
+
+ @param This[in] A pointer to the EFI_DRIVER_BINDING_PROTOCOL
+ instance.
+ @param ControllerHandle[in] The handle of the controller to test.
+ @param RemainingDevicePath[in] The remaining device path.
+ (Ignored - this is not a bus driver.)
+
+ @retval EFI_SUCCESS The driver supports this controller.
+ @retval EFI_ALREADY_STARTED The device specified by ControllerHandle is
+ already being managed by the driver specified
+ by This.
+ @retval EFI_UNSUPPORTED The device specified by ControllerHandle is
+ not supported by the driver specified by This.
+
+**/
+EFI_STATUS
+EFIAPI
+I2cHwrngDriverBindingSupported (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ )
+{
+ EFI_I2C_IO_PROTOCOL *I2cIo;
+ EFI_STATUS Status;
+
+ //
+ // Connect to the I2C stack
+ //
+ Status = gBS->OpenProtocol (ControllerHandle,
+ &gEfiI2cIoProtocolGuid,
+ (VOID **) &I2cIo,
+ This->DriverBindingHandle,
+ ControllerHandle,
+ EFI_OPEN_PROTOCOL_BY_DRIVER);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ if (CompareGuid (I2cIo->DeviceGuid, &gAtSha204aI2cDeviceGuid)) {
+ DEBUG ((DEBUG_INIT | DEBUG_INFO, "Detected AtSha204a RNG device\n"));
+ Status = EFI_SUCCESS;
+ } else {
+ Status = EFI_UNSUPPORTED;
+ }
+
+ //
+ // Clean up.
+ //
+ gBS->CloseProtocol (ControllerHandle,
+ &gEfiI2cIoProtocolGuid,
+ This->DriverBindingHandle,
+ ControllerHandle);
+
+ return Status;
+}
+
+
+/**
+ Starts a device controller or a bus controller.
+
+ @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL
+ instance.
+ @param[in] ControllerHandle The handle of the device to start. This
+ handle must support a protocol interface that
+ supplies an I/O abstraction to the driver.
+ @param[in] RemainingDevicePath The remaining portion of the device path.
+ (Ignored - this is not a bus driver.)
+
+ @retval EFI_SUCCESS The device was started.
+ @retval EFI_DEVICE_ERROR The device could not be started due to a
+ device error.
+ @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a
+ lack of resources.
+
+**/
+EFI_STATUS
+EFIAPI
+I2cHwrngDriverBindingStart (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
+ )
+{
+ return AtSha204aInit (This->DriverBindingHandle, ControllerHandle);
+}
+
+
+/**
+ Stops a device controller or a bus controller.
+
+ @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL
+ instance.
+ @param[in] ControllerHandle A handle to the device being stopped. The handle
+ must support a bus specific I/O protocol for the
+ driver to use to stop the device.
+ @param[in] NumberOfChildren The number of child device handles in
+ ChildHandleBuffer.
+ @param[in] ChildHandleBuffer An array of child handles to be freed. May be
+ NULL if NumberOfChildren is 0.
+
+ @retval EFI_SUCCESS The device was stopped.
+ @retval EFI_DEVICE_ERROR The device could not be stopped due to a device
+ error.
+
+**/
+EFI_STATUS
+EFIAPI
+I2cHwrngDriverBindingStop (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
+ )
+{
+ return AtSha204aRelease (This->DriverBindingHandle, ControllerHandle);
+}
+
+
+STATIC
+EFI_DRIVER_BINDING_PROTOCOL gI2cHwrngDriverBinding = {
+ I2cHwrngDriverBindingSupported,
+ I2cHwrngDriverBindingStart,
+ I2cHwrngDriverBindingStop,
+ 0xa,
+ NULL,
+ NULL
+};
+
+
+/**
+ The entry point of AtSha204a UEFI Driver.
+
+ @param ImageHandle The image handle of the UEFI Driver.
+ @param SystemTable A pointer to the EFI System Table.
+
+ @retval EFI_SUCCESS The Driver or UEFI Driver exited normally.
+ @retval EFI_INCOMPATIBLE_VERSION _gUefiDriverRevision is greater than
+ SystemTable->Hdr.Revision.
+
+**/
+EFI_STATUS
+EFIAPI
+EntryPoint (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+
+ //
+ // Add the driver to the list of drivers
+ //
+ Status = EfiLibInstallDriverBindingComponentName2 (
+ ImageHandle, SystemTable, &gI2cHwrngDriverBinding, ImageHandle,
+ NULL, &gAtSha204aDriverComponentName2);
+ ASSERT_EFI_ERROR (Status);
+
+ DEBUG ((DEBUG_INIT | DEBUG_INFO, "*** Installed AtSha204a driver! ***\n"));
+
+ return EFI_SUCCESS;
+}
+
+
+/**
+ Unload function for the AtSha204a Driver.
+
+ @param ImageHandle[in] The allocated handle for the EFI image
+
+ @retval EFI_SUCCESS The driver was unloaded successfully
+ @retval EFI_INVALID_PARAMETER ImageHandle is not a valid image handle.
+
+**/
+EFI_STATUS
+EFIAPI
+UnloadImage (
+ IN EFI_HANDLE ImageHandle
+ )
+{
+ EFI_STATUS Status;
+ EFI_HANDLE *HandleBuffer;
+ UINTN HandleCount;
+ UINTN Index;
+
+ //
+ // Retrieve all I2C I/O handles in the handle database
+ //
+ Status = gBS->LocateHandleBuffer (ByProtocol,
+ &gEfiI2cIoProtocolGuid,
+ NULL,
+ &HandleCount,
+ &HandleBuffer);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Disconnect the driver from the handles in the handle database
+ //
+ for (Index = 0; Index < HandleCount; Index++) {
+ Status = gBS->DisconnectController (HandleBuffer[Index],
+ gImageHandle,
+ NULL);
+ }
+
+ //
+ // Free the handle array
+ //
+ gBS->FreePool (HandleBuffer);
+
+ //
+ // Uninstall protocols installed by the driver in its entrypoint
+ //
+ Status = gBS->UninstallMultipleProtocolInterfaces (ImageHandle,
+ &gEfiDriverBindingProtocolGuid,
+ &gI2cHwrngDriverBinding,
+ NULL
+ );
+
+ return EFI_SUCCESS;
+}
--
2.11.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH edk2-platforms v2 2/7] Platform/NinetySixBoards: introduce package and mezzanine protocol
2018-02-20 17:49 [PATCH edk2-platforms v2 0/7] Add Secure96 mezzanine support Ard Biesheuvel
2018-02-20 17:49 ` [PATCH edk2-platforms v2 1/7] Silicon/Atmel: add support for AtSha204a RNG Ard Biesheuvel
@ 2018-02-20 17:49 ` Ard Biesheuvel
2018-02-22 13:15 ` Leif Lindholm
2018-02-20 17:49 ` [PATCH edk2-platforms v2 3/7] Platform/NinetySixBoards: introduce I2C driver Ard Biesheuvel
` (5 subsequent siblings)
7 siblings, 1 reply; 21+ messages in thread
From: Ard Biesheuvel @ 2018-02-20 17:49 UTC (permalink / raw)
To: edk2-devel; +Cc: leif.lindholm, Ard Biesheuvel
Introduce the mezzanine protocol and the 96boards package defining
the PCDs and GUIDs that may be used by implementations of the
protocol.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
Platform/NinetySixBoards/Include/Protocol/Mezzanine.h | 71 ++++++++++++++++++++
Platform/NinetySixBoards/NinetySixBoards.dec | 67 ++++++++++++++++++
2 files changed, 138 insertions(+)
diff --git a/Platform/NinetySixBoards/Include/Protocol/Mezzanine.h b/Platform/NinetySixBoards/Include/Protocol/Mezzanine.h
new file mode 100644
index 000000000000..7869ea979b48
--- /dev/null
+++ b/Platform/NinetySixBoards/Include/Protocol/Mezzanine.h
@@ -0,0 +1,71 @@
+/** @file
+
+ 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 _MEZZANINE_H_
+#define _MEZZANINE_H_
+
+#include <Pi/PiI2c.h>
+#include <Protocol/SpiConfiguration.h>
+
+#define MEZZANINE_PROTOCOL_GUID \
+ { 0xf0467a37, 0x3436, 0x40ef, { 0x94, 0x09, 0x4d, 0x1d, 0x7f, 0x51, 0x06, 0xd3 } }
+
+typedef struct _MEZZANINE_PROTOCOL MEZZANINE_PROTOCOL;
+
+/**
+ Apply the mezzanine's DT overlay
+
+ @param[in] This Pointer to the MEZZANINE_PROTOCOL instance.
+ @param[in,out] Dtb Pointer to the device tree blob
+
+ @return EFI_SUCCESS Operation succeeded.
+ @return other An error has occurred.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *APPLY_DEVICE_TREE_OVERLAY) (
+ IN MEZZANINE_PROTOCOL *This,
+ IN OUT VOID *Dtb
+ );
+
+struct _MEZZANINE_PROTOCOL {
+ //
+ // Get the device tree overlay for this mezzanine board
+ //
+ APPLY_DEVICE_TREE_OVERLAY ApplyDeviceTreeOverlay;
+ //
+ // The number of devices on LS connector I2C bus #0
+ //
+ UINT32 I2c0NumDevices;
+ //
+ // The number of devices on LS connector I2C bus #1
+ //
+ UINT32 I2c1NumDevices;
+ //
+ // Linear array of I2C devices on LS connector bus #0
+ //
+ CONST EFI_I2C_DEVICE *I2c0DeviceArray;
+ //
+ // Linear array of I2C devices on LS connector bus #0
+ //
+ CONST EFI_I2C_DEVICE *I2c1DeviceArray;
+ //
+ // NULL terminated linked list of SPI devices attached to the LS connector
+ //
+ CONST EFI_SPI_PERIPHERAL *SpiDeviceLinkedList;
+};
+
+extern EFI_GUID gNinetySixBoardsMezzanineProtocolGuid;
+
+#endif // _MEZZANINE_H_
diff --git a/Platform/NinetySixBoards/NinetySixBoards.dec b/Platform/NinetySixBoards/NinetySixBoards.dec
new file mode 100644
index 000000000000..f7e2b01459d7
--- /dev/null
+++ b/Platform/NinetySixBoards/NinetySixBoards.dec
@@ -0,0 +1,67 @@
+## @file
+#
+# Copyright (c) 2018, Linaro Ltd. All rights reserved.
+#
+# 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.
+#
+##
+
+[Defines]
+ DEC_SPECIFICATION = 0x0001001A
+ PACKAGE_NAME = NinetySixBoards
+ PACKAGE_GUID = ce4a4683-6e2d-4ec3-bc11-974289a09ab0
+ PACKAGE_VERSION = 0.1
+
+[Includes]
+ Include
+
+[Protocols]
+ ## Include/Protocol/Mezzanine.h
+ gNinetySixBoardsMezzanineProtocolGuid = { 0xf0467a37, 0x3436, 0x40ef, { 0x94, 0x09, 0x4d, 0x1d, 0x7f, 0x51, 0x06, 0xd3 } }
+
+[Guids]
+ # PCD scope GUID
+ gNinetySixBoardsTokenSpaceGuid = { 0xe0d2f33a, 0xb7dd, 0x4a69, { 0xb6, 0x76, 0xda, 0xe8, 0xa4, 0x17, 0xa7, 0xb5 } }
+
+ # GUIDs to be installed as protocols to identify which controller connects to which bus
+ gNinetySixBoardsI2c0MasterGuid = { 0xba10e402, 0xcfdd, 0x4b87, { 0xbd, 0x02, 0x6e, 0x26, 0x9f, 0x01, 0x94, 0x11 } }
+ gNinetySixBoardsI2c1MasterGuid = { 0xcf64ac46, 0xd0be, 0x4a69, { 0x90, 0xa2, 0xf2, 0x82, 0x5b, 0x92, 0x25, 0x61 } }
+ gNinetySixBoardsSpiMasterGuid = { 0x9703fd99, 0xe638, 0x42b8, { 0xab, 0x81, 0x52, 0x61, 0x1b, 0xf7, 0xf7, 0x5d } }
+
+[PcdsFixedAtBuild]
+ # ASCII DT paths to the I2C parent nodes of the 96boards LS connector
+ gNinetySixBoardsTokenSpaceGuid.PcdI2c0Parent|""|VOID*|0x00000001
+ gNinetySixBoardsTokenSpaceGuid.PcdI2c1Parent|""|VOID*|0x00000002
+
+ # I2C bus frequency in Hertz
+ gNinetySixBoardsTokenSpaceGuid.PcdI2c0BusFrequencyHz|0|UINT32|0x00000003
+ gNinetySixBoardsTokenSpaceGuid.PcdI2c1BusFrequencyHz|0|UINT32|0x00000004
+
+ # ASCII DT path to the SPI parent node of the 96boards LS connector
+ gNinetySixBoardsTokenSpaceGuid.PcdSpiParent|""|VOID*|0x00000005
+
+ # ASCII DT path to the GPIO parent node of the 96boards LS connector
+ gNinetySixBoardsTokenSpaceGuid.PcdGpioParent|""|VOID*|0x00000006
+
+ # Polarity of the 96boards LS connector GPIOs (0 == GPIO_ACTIVE_HIGH, 1 == GPIO_ACTIVE_LOW)
+ gNinetySixBoardsTokenSpaceGuid.PcdGpioPolarity|0|UINT32|0x00000007
+
+ # Pin numbers of the 96boards LS connector GPIOs
+ gNinetySixBoardsTokenSpaceGuid.PcdGpioPinA|0|UINT32|0x00000010
+ gNinetySixBoardsTokenSpaceGuid.PcdGpioPinB|0|UINT32|0x00000011
+ gNinetySixBoardsTokenSpaceGuid.PcdGpioPinC|0|UINT32|0x00000012
+ gNinetySixBoardsTokenSpaceGuid.PcdGpioPinD|0|UINT32|0x00000013
+ gNinetySixBoardsTokenSpaceGuid.PcdGpioPinE|0|UINT32|0x00000014
+ gNinetySixBoardsTokenSpaceGuid.PcdGpioPinF|0|UINT32|0x00000015
+ gNinetySixBoardsTokenSpaceGuid.PcdGpioPinG|0|UINT32|0x00000016
+ gNinetySixBoardsTokenSpaceGuid.PcdGpioPinH|0|UINT32|0x00000017
+ gNinetySixBoardsTokenSpaceGuid.PcdGpioPinI|0|UINT32|0x00000018
+ gNinetySixBoardsTokenSpaceGuid.PcdGpioPinJ|0|UINT32|0x00000019
+ gNinetySixBoardsTokenSpaceGuid.PcdGpioPinK|0|UINT32|0x0000001A
+ gNinetySixBoardsTokenSpaceGuid.PcdGpioPinL|0|UINT32|0x0000001B
--
2.11.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH edk2-platforms v2 3/7] Platform/NinetySixBoards: introduce I2C driver
2018-02-20 17:49 [PATCH edk2-platforms v2 0/7] Add Secure96 mezzanine support Ard Biesheuvel
2018-02-20 17:49 ` [PATCH edk2-platforms v2 1/7] Silicon/Atmel: add support for AtSha204a RNG Ard Biesheuvel
2018-02-20 17:49 ` [PATCH edk2-platforms v2 2/7] Platform/NinetySixBoards: introduce package and mezzanine protocol Ard Biesheuvel
@ 2018-02-20 17:49 ` Ard Biesheuvel
2018-02-20 17:49 ` [PATCH edk2-platforms v2 4/7] Platform/NinetySixBoards: introduce LsConnector protocol Ard Biesheuvel
` (4 subsequent siblings)
7 siblings, 0 replies; 21+ messages in thread
From: Ard Biesheuvel @ 2018-02-20 17:49 UTC (permalink / raw)
To: edk2-devel; +Cc: leif.lindholm, Ard Biesheuvel
Implement a I2C DXE driver that wires up the I2C devices exposed by
a 96boards mezzanine into the EDK2 I2C stack. Note that this requires
the platform to identify its I2C master implementations using special
GUIDs-as-protocols. It also assumes [for now] that I2C buses are not
shared between the 96boards connector and other platform peripherals.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
Platform/NinetySixBoards/NinetySixBoardsI2cDxe/NinetySixBoardsI2cDxe.c | 202 ++++++++++++++++++++
Platform/NinetySixBoards/NinetySixBoardsI2cDxe/NinetySixBoardsI2cDxe.inf | 51 +++++
2 files changed, 253 insertions(+)
diff --git a/Platform/NinetySixBoards/NinetySixBoardsI2cDxe/NinetySixBoardsI2cDxe.c b/Platform/NinetySixBoards/NinetySixBoardsI2cDxe/NinetySixBoardsI2cDxe.c
new file mode 100644
index 000000000000..9a779626b19f
--- /dev/null
+++ b/Platform/NinetySixBoards/NinetySixBoardsI2cDxe/NinetySixBoardsI2cDxe.c
@@ -0,0 +1,202 @@
+/** @file
+
+ 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.
+
+**/
+
+#include <PiDxe.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiLib.h>
+#include <Protocol/I2cBusConfigurationManagement.h>
+#include <Protocol/I2cEnumerate.h>
+#include <Protocol/I2cMaster.h>
+#include <Protocol/Mezzanine.h>
+
+STATIC MEZZANINE_PROTOCOL *mMezzanine;
+
+typedef struct {
+ EFI_I2C_ENUMERATE_PROTOCOL I2cEnumerate;
+ EFI_I2C_BUS_CONFIGURATION_MANAGEMENT_PROTOCOL I2cConfigManagement;
+ EFI_HANDLE I2cMasterHandle;
+ UINT32 BusFrequency;
+ UINTN NumDevices;
+ CONST EFI_I2C_DEVICE *Devices;
+} I2C_BUS;
+
+STATIC
+EFI_STATUS
+EFIAPI
+I2cEnumerate (
+ IN CONST EFI_I2C_ENUMERATE_PROTOCOL *This,
+ IN OUT CONST EFI_I2C_DEVICE **Device
+ )
+{
+ I2C_BUS *Bus;
+
+ if (Device == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Bus = BASE_CR (This, I2C_BUS, I2cEnumerate);
+
+ if (*Device == NULL) {
+ *Device = &Bus->Devices[0];
+ } else if (*Device >= &Bus->Devices[0] &&
+ *Device < &Bus->Devices[Bus->NumDevices - 2]) {
+ ++*Device;
+ } else {
+ return EFI_NO_MAPPING;
+ }
+ return EFI_SUCCESS;
+}
+
+STATIC
+EFI_STATUS
+EFIAPI
+I2cGetBusFrequency (
+ IN CONST EFI_I2C_ENUMERATE_PROTOCOL *This,
+ IN UINTN I2cBusConfiguration,
+ OUT UINTN *BusClockHertz
+ )
+{
+ I2C_BUS *Bus;
+
+ if (BusClockHertz == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (I2cBusConfiguration > 0) {
+ return EFI_NO_MAPPING;
+ }
+
+ Bus = BASE_CR (This, I2C_BUS, I2cEnumerate);
+
+ *BusClockHertz = Bus->BusFrequency;
+
+ return EFI_SUCCESS;
+}
+
+STATIC
+EFI_STATUS
+EFIAPI
+EnableI2cBusConfiguration (
+ IN CONST EFI_I2C_BUS_CONFIGURATION_MANAGEMENT_PROTOCOL *This,
+ IN UINTN I2cBusConfiguration,
+ IN EFI_EVENT Event OPTIONAL,
+ IN EFI_STATUS *I2cStatus OPTIONAL
+ )
+{
+ EFI_I2C_MASTER_PROTOCOL *I2cMaster;
+ EFI_STATUS Status;
+ UINTN BusClockHertz;
+ I2C_BUS *Bus;
+
+ if (I2cBusConfiguration > 0) {
+ return EFI_NO_MAPPING;
+ }
+
+ Bus = BASE_CR (This, I2C_BUS, I2cConfigManagement);
+
+ Status = gBS->HandleProtocol (Bus->I2cMasterHandle,
+ &gEfiI2cMasterProtocolGuid, (VOID **)&I2cMaster);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: gBS->HandleProtocol() failed - %r\n",
+ __FUNCTION__, Status));
+ return Status;
+ }
+
+ BusClockHertz = Bus->BusFrequency;
+ Status = I2cMaster->SetBusFrequency (I2cMaster, &BusClockHertz);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: I2cMaster->SetBusFrequency() failed - %r\n",
+ __FUNCTION__, Status));
+ return Status;
+ }
+
+ if (Event != NULL) {
+ *I2cStatus = EFI_SUCCESS;
+ gBS->SignalEvent (Event);
+ }
+ return EFI_SUCCESS;
+}
+
+STATIC I2C_BUS mI2cBus0 = {
+ { I2cEnumerate, I2cGetBusFrequency },
+ { EnableI2cBusConfiguration },
+ NULL,
+ FixedPcdGet32 (PcdI2c0BusFrequencyHz),
+ 0,
+ NULL,
+};
+
+STATIC I2C_BUS mI2cBus1 = {
+ { I2cEnumerate, I2cGetBusFrequency },
+ { EnableI2cBusConfiguration },
+ NULL,
+ FixedPcdGet32 (PcdI2c1BusFrequencyHz),
+ 0,
+ NULL,
+};
+
+STATIC
+VOID
+RegisterI2cBus (
+ IN EFI_GUID *Guid,
+ IN I2C_BUS *I2cBus,
+ IN UINTN NumDevices,
+ IN CONST EFI_I2C_DEVICE *Devices
+ )
+{
+ EFI_STATUS Status;
+ UINTN BufferSize;
+
+ BufferSize = sizeof (EFI_HANDLE);
+ Status = gBS->LocateHandle (ByProtocol, Guid, NULL, &BufferSize,
+ &I2cBus->I2cMasterHandle);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_INFO, "%a: gBS->LocateHandle() failed - %r\n", __FUNCTION__,
+ Status));
+ return;
+ }
+
+ I2cBus->NumDevices = NumDevices;
+ I2cBus->Devices = Devices;
+
+ Status = gBS->InstallMultipleProtocolInterfaces (&I2cBus->I2cMasterHandle,
+ &gEfiI2cEnumerateProtocolGuid,
+ &I2cBus->I2cEnumerate,
+ &gEfiI2cBusConfigurationManagementProtocolGuid,
+ &I2cBus->I2cConfigManagement,
+ NULL);
+ ASSERT_EFI_ERROR (Status);
+}
+
+EFI_STATUS
+EFIAPI
+EntryPoint (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+
+ Status = gBS->LocateProtocol (&gNinetySixBoardsMezzanineProtocolGuid, NULL,
+ (VOID **)&mMezzanine);
+ ASSERT_EFI_ERROR (Status);
+
+ RegisterI2cBus (&gNinetySixBoardsI2c0MasterGuid, &mI2cBus0,
+ mMezzanine->I2c0NumDevices, mMezzanine->I2c0DeviceArray);
+ RegisterI2cBus (&gNinetySixBoardsI2c1MasterGuid, &mI2cBus1,
+ mMezzanine->I2c1NumDevices, mMezzanine->I2c1DeviceArray);
+
+ return EFI_SUCCESS;
+}
diff --git a/Platform/NinetySixBoards/NinetySixBoardsI2cDxe/NinetySixBoardsI2cDxe.inf b/Platform/NinetySixBoards/NinetySixBoardsI2cDxe/NinetySixBoardsI2cDxe.inf
new file mode 100644
index 000000000000..9875566b6425
--- /dev/null
+++ b/Platform/NinetySixBoards/NinetySixBoardsI2cDxe/NinetySixBoardsI2cDxe.inf
@@ -0,0 +1,51 @@
+## @file
+#
+# 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.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x0001001A
+ BASE_NAME = NinetySixBoardsI2cDxe
+ FILE_GUID = a59176bc-a151-49c8-b54a-b4ac96f436c3
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 0.1
+ ENTRY_POINT = EntryPoint
+
+[Sources]
+ NinetySixBoardsI2cDxe.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ Platform/NinetySixBoards/NinetySixBoards.dec
+
+[LibraryClasses]
+ DebugLib
+ UefiBootServicesTableLib
+ UefiDriverEntryPoint
+ UefiLib
+
+[Protocols]
+ gNinetySixBoardsMezzanineProtocolGuid ## CONSUMES
+ gEfiI2cBusConfigurationManagementProtocolGuid ## PRODUCES
+ gEfiI2cEnumerateProtocolGuid ## PRODUCES
+ gEfiI2cMasterProtocolGuid ## CONSUMES
+
+[Guids]
+ gNinetySixBoardsI2c0MasterGuid
+ gNinetySixBoardsI2c1MasterGuid
+
+[FixedPcd]
+ gNinetySixBoardsTokenSpaceGuid.PcdI2c0BusFrequencyHz
+ gNinetySixBoardsTokenSpaceGuid.PcdI2c1BusFrequencyHz
+
+[Depex]
+ gNinetySixBoardsMezzanineProtocolGuid AND gNinetySixBoardsI2c0MasterGuid OR gNinetySixBoardsI2c1MasterGuid
--
2.11.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH edk2-platforms v2 4/7] Platform/NinetySixBoards: introduce LsConnector protocol
2018-02-20 17:49 [PATCH edk2-platforms v2 0/7] Add Secure96 mezzanine support Ard Biesheuvel
` (2 preceding siblings ...)
2018-02-20 17:49 ` [PATCH edk2-platforms v2 3/7] Platform/NinetySixBoards: introduce I2C driver Ard Biesheuvel
@ 2018-02-20 17:49 ` Ard Biesheuvel
2018-02-22 15:29 ` Leif Lindholm
2018-02-20 17:49 ` [PATCH edk2-platforms v2 5/7] Platform/NinetySixBoards: add a driver for the Secure96 mezzanine board Ard Biesheuvel
` (3 subsequent siblings)
7 siblings, 1 reply; 21+ messages in thread
From: Ard Biesheuvel @ 2018-02-20 17:49 UTC (permalink / raw)
To: edk2-devel; +Cc: leif.lindholm, Ard Biesheuvel
Introduce a protocol describing the presence of a 96boards LS connector,
and identifying the type of mezzanine that has been installed.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
Platform/NinetySixBoards/Include/Protocol/LsConnector.h | 35 ++++++++++++++++++++
Platform/NinetySixBoards/NinetySixBoards.dec | 3 ++
2 files changed, 38 insertions(+)
diff --git a/Platform/NinetySixBoards/Include/Protocol/LsConnector.h b/Platform/NinetySixBoards/Include/Protocol/LsConnector.h
new file mode 100644
index 000000000000..a1f0132c85ae
--- /dev/null
+++ b/Platform/NinetySixBoards/Include/Protocol/LsConnector.h
@@ -0,0 +1,35 @@
+/** @file
+
+ 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 _LS_CONNECTOR_H_
+#define _LS_CONNECTOR_H_
+
+#define LS_CONNECTOR_PROTOCOL_GUID \
+ { 0xae548d4c, 0x9062, 0x4eed, { 0x83, 0x5f, 0xf5, 0x10, 0xf8, 0xfc, 0x48, 0xaf } }
+
+typedef struct _LS_CONNECTOR_PROTOCOL LS_CONNECTOR_PROTOCOL;
+
+typedef enum {
+ MezzanineUnknown,
+ MezzanineSecure96,
+ MezzanineMax
+} MEZZANINE_TYPE;
+
+struct _LS_CONNECTOR_PROTOCOL {
+ MEZZANINE_TYPE MezzanineType;
+};
+
+extern EFI_GUID gNinetySixBoardsLsConnectorProtocolGuid;
+
+#endif // _LS_CONNECTOR_H_
diff --git a/Platform/NinetySixBoards/NinetySixBoards.dec b/Platform/NinetySixBoards/NinetySixBoards.dec
index f7e2b01459d7..5c3fe43dbb24 100644
--- a/Platform/NinetySixBoards/NinetySixBoards.dec
+++ b/Platform/NinetySixBoards/NinetySixBoards.dec
@@ -25,6 +25,9 @@ [Protocols]
## Include/Protocol/Mezzanine.h
gNinetySixBoardsMezzanineProtocolGuid = { 0xf0467a37, 0x3436, 0x40ef, { 0x94, 0x09, 0x4d, 0x1d, 0x7f, 0x51, 0x06, 0xd3 } }
+ ## Include/Protocol/LsConnector.h
+ gNinetySixBoardsLsConnectorProtocolGuid = { 0xae548d4c, 0x9062, 0x4eed, { 0x83, 0x5f, 0xf5, 0x10, 0xf8, 0xfc, 0x48, 0xaf } }
+
[Guids]
# PCD scope GUID
gNinetySixBoardsTokenSpaceGuid = { 0xe0d2f33a, 0xb7dd, 0x4a69, { 0xb6, 0x76, 0xda, 0xe8, 0xa4, 0x17, 0xa7, 0xb5 } }
--
2.11.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH edk2-platforms v2 5/7] Platform/NinetySixBoards: add a driver for the Secure96 mezzanine board
2018-02-20 17:49 [PATCH edk2-platforms v2 0/7] Add Secure96 mezzanine support Ard Biesheuvel
` (3 preceding siblings ...)
2018-02-20 17:49 ` [PATCH edk2-platforms v2 4/7] Platform/NinetySixBoards: introduce LsConnector protocol Ard Biesheuvel
@ 2018-02-20 17:49 ` Ard Biesheuvel
2018-02-22 15:38 ` Leif Lindholm
2018-02-20 17:49 ` [PATCH edk2-platforms v2 6/7] Platform/NinetySixBoards: add core driver for LS connector and config Ard Biesheuvel
` (2 subsequent siblings)
7 siblings, 1 reply; 21+ messages in thread
From: Ard Biesheuvel @ 2018-02-20 17:49 UTC (permalink / raw)
To: edk2-devel; +Cc: leif.lindholm, Ard Biesheuvel
Add a driver that describes the Secure96 mezzanine board, and exposes
both the information required to describe it to the OS using a DT overlay,
and to describe it to UEFI itself.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
Platform/NinetySixBoards/Secure96Dxe/Secure96.dts | 76 +++++++
Platform/NinetySixBoards/Secure96Dxe/Secure96.h | 26 +++
Platform/NinetySixBoards/Secure96Dxe/Secure96Dxe.c | 211 ++++++++++++++++++++
Platform/NinetySixBoards/Secure96Dxe/Secure96Dxe.inf | 67 +++++++
4 files changed, 380 insertions(+)
diff --git a/Platform/NinetySixBoards/Secure96Dxe/Secure96.dts b/Platform/NinetySixBoards/Secure96Dxe/Secure96.dts
new file mode 100644
index 000000000000..08f59978c06f
--- /dev/null
+++ b/Platform/NinetySixBoards/Secure96Dxe/Secure96.dts
@@ -0,0 +1,76 @@
+/** @file
+ * Copyright (c) 2018, Linaro Limited. All rights reserved.
+ *
+ * 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.
+ */
+
+#include "Secure96.h"
+
+#define GPIO_PARENT_PLACEHOLDER_PHANDLE 0x0
+
+/dts-v1/;
+/plugin/;
+
+/ {
+ fragment@0 {
+ target-path = "I2C_PARENT_PLACEHOLDER_STRING";
+ __overlay__ {
+ ATSHA204A_DT_NODENAME {
+ compatible = "atmel,atsha204a";
+ reg = <ATSHA204A_SLAVE_ADDRESS>;
+ };
+ ATECC508A_DT_NODENAME {
+ compatible = "atmel,atecc508a";
+ reg = <ATECC508A_SLAVE_ADDRESS>;
+ };
+ };
+ };
+
+ fragment@1 {
+ target-path = "SPI_PARENT_PLACEHOLDER_STRING";
+ __overlay__ {
+ INFINEON_SLB9670_DT_NODENAME {
+ compatible = "infineon,slb9670";
+ reg = <INFINEON_SLB9670_SPI_CS>;
+ spi-max-frequency = <22500000>;
+ };
+ };
+ };
+
+ fragment@2 {
+ target-path = "/";
+ __overlay__ {
+ gpio-leds {
+ compatible = "gpio-leds";
+
+ secure96-u1 {
+ gpios = <GPIO_PARENT_PLACEHOLDER_PHANDLE
+ FixedPcdGet32 (PcdGpioPinG)
+ FixedPcdGet32 (PcdGpioPolarity)>;
+ };
+ secure96-u2 {
+ gpios = <GPIO_PARENT_PLACEHOLDER_PHANDLE
+ FixedPcdGet32 (PcdGpioPinF)
+ FixedPcdGet32 (PcdGpioPolarity)>;
+ };
+ secure96-u3 {
+ gpios = <GPIO_PARENT_PLACEHOLDER_PHANDLE
+ FixedPcdGet32 (PcdGpioPinI)
+ FixedPcdGet32 (PcdGpioPolarity)>;
+ };
+ secure96-u4 {
+ gpios = <GPIO_PARENT_PLACEHOLDER_PHANDLE
+ FixedPcdGet32 (PcdGpioPinH)
+ FixedPcdGet32 (PcdGpioPolarity)>;
+ };
+ };
+ };
+ };
+};
diff --git a/Platform/NinetySixBoards/Secure96Dxe/Secure96.h b/Platform/NinetySixBoards/Secure96Dxe/Secure96.h
new file mode 100644
index 000000000000..84b8aed13d1e
--- /dev/null
+++ b/Platform/NinetySixBoards/Secure96Dxe/Secure96.h
@@ -0,0 +1,26 @@
+/** @file
+
+ 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 _SECURE96_H_
+#define _SECURE96_H_
+
+#define ATSHA204A_SLAVE_ADDRESS 0x60
+#define ATSHA204A_DT_NODENAME atsha204a@60
+
+#define ATECC508A_SLAVE_ADDRESS 0x51
+#define ATECC508A_DT_NODENAME atecc508a@51
+
+#define INFINEON_SLB9670_SPI_CS 0x0
+#define INFINEON_SLB9670_DT_NODENAME tpm@0
+
+#endif // _SECURE96_H_
diff --git a/Platform/NinetySixBoards/Secure96Dxe/Secure96Dxe.c b/Platform/NinetySixBoards/Secure96Dxe/Secure96Dxe.c
new file mode 100644
index 000000000000..000f4b4abba4
--- /dev/null
+++ b/Platform/NinetySixBoards/Secure96Dxe/Secure96Dxe.c
@@ -0,0 +1,211 @@
+/** @file
+ 96boards Secure96 mezzanine board DXE driver.
+
+ 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.
+**/
+
+#include <PiDxe.h>
+#include <libfdt.h>
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+#include <Library/DxeServicesLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiLib.h>
+#include <Protocol/LsConnector.h>
+#include <Protocol/Mezzanine.h>
+
+#include "Secure96.h"
+
+STATIC CONST UINT32 mI2cAtmelSha204aSlaveAddress[] = {
+ ATSHA204A_SLAVE_ADDRESS,
+
+ //
+ // The Atmel AtSha204a has an annoying 'wake' mode where it will only wake
+ // up if SDA is held low for a certain amount of time. Attempting to access
+ // a device at address 0x0 at 100 kHz should be sufficient to create this
+ // wake condition, so add address 0x0 to the slave addresses.
+ //
+ 0
+};
+
+STATIC CONST EFI_I2C_DEVICE mI2c0Devices[] = {
+ {
+ &gAtSha204aI2cDeviceGuid, // DeviceGuid
+ 0, // DeviceIndex
+ 0, // HardwareRevision
+ 0, // I2C bus configuration
+ ARRAY_SIZE (mI2cAtmelSha204aSlaveAddress), // SlaveAddressCount
+ mI2cAtmelSha204aSlaveAddress // SlaveAddressArray
+ }
+};
+
+STATIC CONST CHAR8 mLedNodes[][46] = {
+ "/fragment@2/__overlay__/gpio-leds/secure96-u1",
+ "/fragment@2/__overlay__/gpio-leds/secure96-u2",
+ "/fragment@2/__overlay__/gpio-leds/secure96-u3",
+ "/fragment@2/__overlay__/gpio-leds/secure96-u4",
+};
+
+STATIC
+VOID
+SetOverlayFragmentTarget (
+ VOID *Overlay,
+ CONST CHAR8 *NodeName,
+ CONST CHAR8 *Target
+ )
+{
+ INT32 Node;
+ INT32 Err;
+
+ Node = fdt_path_offset (Overlay, NodeName);
+ ASSERT (Node > 0);
+
+ Err = fdt_setprop (Overlay, Node, "target-path", Target,
+ AsciiStrLen (Target) + 1);
+ if (Err) {
+ DEBUG ((DEBUG_ERROR, "%a: fdt_setprop() failed - %a\n",
+ __FUNCTION__, fdt_strerror (Err)));
+ }
+}
+
+STATIC
+VOID
+FixupOverlay (
+ VOID *Dtb,
+ VOID *Overlay
+ )
+{
+ INT32 Node;
+ UINT32 GpioPhandle;
+ UINTN Idx;
+ UINT32 *GpioProp;
+ INT32 Err;
+
+ //
+ // Set the correct GPIO phandle in the LED nodes
+ //
+ Node = fdt_path_offset (Dtb, FixedPcdGetPtr (PcdGpioParent));
+ ASSERT (Node > 0);
+
+ GpioPhandle = fdt_get_phandle (Dtb, Node);
+ if (!GpioPhandle) {
+ //
+ // Node has no phandle yet -> create one
+ //
+ GpioPhandle = 1 + fdt_get_max_phandle (Dtb);
+ ASSERT (GpioPhandle >= 1);
+
+ Err = fdt_setprop_u32 (Dtb, Node, "phandle", GpioPhandle);
+ if (Err) {
+ DEBUG ((DEBUG_ERROR,
+ "%a: fdt_setprop_u32(.., .., \"phandle\", 0x%x) failed - %a\n",
+ __FUNCTION__, GpioPhandle, fdt_strerror (Err)));
+ }
+ }
+
+ for (Idx = 0; Idx < ARRAY_SIZE (mLedNodes); Idx++) {
+ Node = fdt_path_offset (Overlay, mLedNodes[Idx]);
+ ASSERT (Node > 0);
+
+ GpioProp = fdt_getprop_w (Overlay, Node, "gpios", NULL);
+ ASSERT (GpioProp != NULL);
+
+ *GpioProp = cpu_to_fdt32 (GpioPhandle);
+ }
+
+ SetOverlayFragmentTarget (Overlay, "/fragment@0",
+ FixedPcdGetPtr (PcdI2c0Parent));
+
+ SetOverlayFragmentTarget (Overlay, "/fragment@1",
+ FixedPcdGetPtr (PcdSpiParent));
+}
+
+/**
+ Apply the mezzanine's DT overlay
+
+ @param[in] This Pointer to the MEZZANINE_PROTOCOL instance.
+ @param[in,out] Dtb Pointer to the device tree blob
+
+ @return EFI_SUCCESS Operation succeeded.
+ @return other An error has occurred.
+**/
+STATIC
+EFI_STATUS
+ApplyDeviceTreeOverlay (
+ IN MEZZANINE_PROTOCOL *This,
+ IN OUT VOID *Dtb
+ )
+{
+ VOID *Overlay;
+ UINTN OverlaySize;
+ EFI_STATUS Status;
+ INT32 Err;
+
+ //
+ // Load the raw overlay DTB image from the raw section of this FFS file.
+ //
+ Status = GetSectionFromFv (&gEfiCallerIdGuid,
+ EFI_SECTION_RAW, 0, &Overlay, &OverlaySize);
+ ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR (Status)) {
+ return EFI_NOT_FOUND;
+ }
+
+ //
+ // Fix up unresolved references in the overlay.
+ //
+ FixupOverlay (Dtb, Overlay);
+
+ //
+ // Merge the overlay with the DTB
+ //
+ Err = fdt_overlay_apply (Dtb, Overlay);
+ if (Err) {
+ DEBUG ((DEBUG_ERROR, "%a: fdt_overlay_apply() failed - %a\n",
+ __FUNCTION__, fdt_strerror (Err)));
+ return EFI_NOT_FOUND;
+ }
+
+ return EFI_SUCCESS;
+}
+
+STATIC MEZZANINE_PROTOCOL mMezzanine = {
+ ApplyDeviceTreeOverlay,
+ ARRAY_SIZE (mI2c0Devices),
+ 0,
+ mI2c0Devices,
+ NULL,
+ NULL,
+};
+
+EFI_STATUS
+EFIAPI
+Secure96DxeEntryPoint (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+ LS_CONNECTOR_PROTOCOL *LsConnector;
+
+ Status = gBS->LocateProtocol (&gNinetySixBoardsLsConnectorProtocolGuid, NULL,
+ (VOID **)&LsConnector);
+ ASSERT_EFI_ERROR (Status);
+
+ if (LsConnector->MezzanineType != MezzanineSecure96) {
+ return EFI_NOT_FOUND;
+ }
+
+ return gBS->InstallProtocolInterface (&ImageHandle,
+ &gNinetySixBoardsMezzanineProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ &mMezzanine);
+}
diff --git a/Platform/NinetySixBoards/Secure96Dxe/Secure96Dxe.inf b/Platform/NinetySixBoards/Secure96Dxe/Secure96Dxe.inf
new file mode 100644
index 000000000000..e5686b9f5382
--- /dev/null
+++ b/Platform/NinetySixBoards/Secure96Dxe/Secure96Dxe.inf
@@ -0,0 +1,67 @@
+## @file
+#
+# 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.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x0001001A
+ BASE_NAME = Secure96Dxe
+ FILE_GUID = 31519ec4-65f1-4790-b223-aa9330dd75fd
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ ENTRY_POINT = Secure96DxeEntryPoint
+
+[Sources]
+ Secure96.dts
+ Secure96.h
+ Secure96Dxe.c
+
+[Packages]
+ EmbeddedPkg/EmbeddedPkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ MdePkg/MdePkg.dec
+ Platform/NinetySixBoards/NinetySixBoards.dec
+ Silicon/Atmel/AtSha204a/AtSha204a.dec
+
+[LibraryClasses]
+ BaseLib
+ DebugLib
+ DxeServicesLib
+ FdtLib
+ UefiBootServicesTableLib
+ UefiDriverEntryPoint
+ UefiLib
+
+[Protocols]
+ gNinetySixBoardsLsConnectorProtocolGuid ## CONSUMES
+ gNinetySixBoardsMezzanineProtocolGuid ## PRODUCES
+
+[Guids]
+ gAtSha204aI2cDeviceGuid
+ gFdtTableGuid
+
+[FixedPcd]
+ gNinetySixBoardsTokenSpaceGuid.PcdGpioParent
+ gNinetySixBoardsTokenSpaceGuid.PcdGpioPinF
+ gNinetySixBoardsTokenSpaceGuid.PcdGpioPinG
+ gNinetySixBoardsTokenSpaceGuid.PcdGpioPinH
+ gNinetySixBoardsTokenSpaceGuid.PcdGpioPinI
+ gNinetySixBoardsTokenSpaceGuid.PcdGpioPolarity
+ gNinetySixBoardsTokenSpaceGuid.PcdI2c0Parent
+ gNinetySixBoardsTokenSpaceGuid.PcdSpiParent
+
+[Depex]
+ gNinetySixBoardsLsConnectorProtocolGuid
+
+[BuildOptions]
+ # dtc emits lots of spurious warnings for overlays
+ *_*_*_DTC_FLAGS = -q
--
2.11.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH edk2-platforms v2 6/7] Platform/NinetySixBoards: add core driver for LS connector and config
2018-02-20 17:49 [PATCH edk2-platforms v2 0/7] Add Secure96 mezzanine support Ard Biesheuvel
` (4 preceding siblings ...)
2018-02-20 17:49 ` [PATCH edk2-platforms v2 5/7] Platform/NinetySixBoards: add a driver for the Secure96 mezzanine board Ard Biesheuvel
@ 2018-02-20 17:49 ` Ard Biesheuvel
2018-02-22 15:59 ` Leif Lindholm
2018-02-20 17:49 ` [PATCH edk2-platforms v2 7/7] Platform/Socionext/DeveloperBox: add 96boards mezzanine support Ard Biesheuvel
2018-02-22 16:04 ` [PATCH edk2-platforms v2 0/7] Add Secure96 " Leif Lindholm
7 siblings, 1 reply; 21+ messages in thread
From: Ard Biesheuvel @ 2018-02-20 17:49 UTC (permalink / raw)
To: edk2-devel; +Cc: leif.lindholm, Ard Biesheuvel
This adds a driver that manages the 96boards LS connector, i.e, it
installs a HII page to configure the type of mezzanine that is installed
in the slot, and it exposes this information via the LS connector protocol.
It is also in charge of applying the overlay to the platform device tree
at end of DXE.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
Platform/NinetySixBoards/Include/Guid/FormSet.h | 23 ++
Platform/NinetySixBoards/NinetySixBoards.dec | 3 +
Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.c | 221 ++++++++++++++++++++
Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.h | 32 +++
Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.inf | 57 +++++
Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsHii.uni | 27 +++
Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsHii.vfr | 51 +++++
7 files changed, 414 insertions(+)
diff --git a/Platform/NinetySixBoards/Include/Guid/FormSet.h b/Platform/NinetySixBoards/Include/Guid/FormSet.h
new file mode 100644
index 000000000000..db16657f0848
--- /dev/null
+++ b/Platform/NinetySixBoards/Include/Guid/FormSet.h
@@ -0,0 +1,23 @@
+/** @file
+
+ Copyright (c) 2018, Linaro Limited. All rights reserved.
+
+ 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 __NINETY_SIX_BOARDS_FORMSET_H__
+#define __NINETY_SIX_BOARDS_FORMSET_H__
+
+#define NINETY_SIX_BOARDS_FORMSET_GUID \
+ { 0x7500c9d2, 0x9203, 0x4a37, { 0x84, 0xbb, 0x92, 0xa9, 0xce, 0x34, 0x38, 0xbd } }
+
+extern EFI_GUID gNinetySixBoardsFormsetGuid;
+
+#endif // __NINETY_SIX_BOARDS_FORMSET_H__
diff --git a/Platform/NinetySixBoards/NinetySixBoards.dec b/Platform/NinetySixBoards/NinetySixBoards.dec
index 5c3fe43dbb24..e7d1705d47ff 100644
--- a/Platform/NinetySixBoards/NinetySixBoards.dec
+++ b/Platform/NinetySixBoards/NinetySixBoards.dec
@@ -37,6 +37,9 @@ [Guids]
gNinetySixBoardsI2c1MasterGuid = { 0xcf64ac46, 0xd0be, 0x4a69, { 0x90, 0xa2, 0xf2, 0x82, 0x5b, 0x92, 0x25, 0x61 } }
gNinetySixBoardsSpiMasterGuid = { 0x9703fd99, 0xe638, 0x42b8, { 0xab, 0x81, 0x52, 0x61, 0x1b, 0xf7, 0xf7, 0x5d } }
+ # GUID for the HII configuration form
+ gNinetySixBoardsFormsetGuid = { 0x7500c9d2, 0x9203, 0x4a37, { 0x84, 0xbb, 0x92, 0xa9, 0xce, 0x34, 0x38, 0xbd } }
+
[PcdsFixedAtBuild]
# ASCII DT paths to the I2C parent nodes of the 96boards LS connector
gNinetySixBoardsTokenSpaceGuid.PcdI2c0Parent|""|VOID*|0x00000001
diff --git a/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.c b/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.c
new file mode 100644
index 000000000000..6dc5f549e560
--- /dev/null
+++ b/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.c
@@ -0,0 +1,221 @@
+/** @file
+
+ Copyright (c) 2018, Linaro, Ltd. All rights reserved.
+
+ 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.
+
+**/
+
+#include <Uefi.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/DevicePathLib.h>
+#include <Library/HiiLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiLib.h>
+#include <Library/UefiRuntimeServicesTableLib.h>
+#include <Protocol/LsConnector.h>
+#include <Protocol/Mezzanine.h>
+
+#include "NinetySixBoardsDxe.h"
+
+extern UINT8 NinetySixBoardsHiiBin[];
+extern UINT8 NinetySixBoardsDxeStrings[];
+
+typedef struct {
+ VENDOR_DEVICE_PATH VendorDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL End;
+} HII_VENDOR_DEVICE_PATH;
+
+STATIC HII_VENDOR_DEVICE_PATH mNinetySixBoardsDxeVendorDevicePath = {
+ {
+ {
+ HARDWARE_DEVICE_PATH,
+ HW_VENDOR_DP,
+ {
+ (UINT8) (sizeof (VENDOR_DEVICE_PATH)),
+ (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
+ }
+ },
+ NINETY_SIX_BOARDS_FORMSET_GUID
+ },
+ {
+ END_DEVICE_PATH_TYPE,
+ END_ENTIRE_DEVICE_PATH_SUBTYPE,
+ {
+ (UINT8) (END_DEVICE_PATH_LENGTH),
+ (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)
+ }
+ }
+};
+
+STATIC LS_CONNECTOR_PROTOCOL mLsConnector;
+STATIC EFI_EVENT EndOfDxeEvent;
+
+STATIC
+EFI_STATUS
+InstallHiiPages (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ EFI_HII_HANDLE HiiHandle;
+ EFI_HANDLE DriverHandle;
+
+ DriverHandle = NULL;
+ Status = gBS->InstallMultipleProtocolInterfaces (&DriverHandle,
+ &gEfiDevicePathProtocolGuid,
+ &mNinetySixBoardsDxeVendorDevicePath,
+ NULL);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ HiiHandle = HiiAddPackages (&gNinetySixBoardsFormsetGuid,
+ DriverHandle,
+ NinetySixBoardsDxeStrings,
+ NinetySixBoardsHiiBin,
+ NULL);
+
+ if (HiiHandle == NULL) {
+ gBS->UninstallMultipleProtocolInterfaces (DriverHandle,
+ &gEfiDevicePathProtocolGuid,
+ &mNinetySixBoardsDxeVendorDevicePath,
+ NULL);
+ return EFI_OUT_OF_RESOURCES;
+ }
+ return EFI_SUCCESS;
+}
+
+STATIC
+VOID
+EFIAPI
+ApplyDeviceTreeOverlay (
+ EFI_EVENT Event,
+ VOID *Context
+ )
+{
+ VOID *Dtb;
+ MEZZANINE_PROTOCOL *Mezzanine;
+ EFI_STATUS Status;
+
+ //
+ // Find the DTB in the configuration table array. If it isn't there, just
+ // bail without an error: we may be running on an ACPI platform even if
+ // this driver does not support it [yet].
+ //
+ Status = EfiGetSystemConfigurationTable (&gFdtTableGuid, &Dtb);
+ if (Status == EFI_NOT_FOUND) {
+ return;
+ }
+ ASSERT_EFI_ERROR (Status);
+
+ Status = gBS->LocateProtocol (&gNinetySixBoardsMezzanineProtocolGuid, NULL,
+ (VOID **)&Mezzanine);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_INFO, "%a: no mezzanine driver active\n", __FUNCTION__));
+ return;
+ }
+
+ Status = Mezzanine->ApplyDeviceTreeOverlay (Mezzanine, Dtb);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_WARN, "%a: failed to apply DT overlay - %r\n", __FUNCTION__,
+ Status));
+ }
+}
+
+/**
+ The entry point for NinetySixBoardsDxe driver.
+
+ @param[in] ImageHandle The image handle of the driver.
+ @param[in] SystemTable The system table.
+
+ @retval EFI_ALREADY_STARTED The driver already exists in system.
+ @retval EFI_OUT_OF_RESOURCES Fail to execute entry point due to lack of
+ resources.
+ @retval EFI_SUCCES All the related protocols are installed on
+ the driver.
+
+**/
+EFI_STATUS
+EFIAPI
+EntryPoint (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+ NINETY_SIX_BOARDS_CONFIG_DATA ConfigData;
+ UINTN BufferSize;
+
+ //
+ // Get the current config settings from the EFI variable.
+ //
+ BufferSize = sizeof (ConfigData);
+ Status = gRT->GetVariable (NINETY_SIX_BOARDS_CONFIG_VARIABLE_NAME,
+ &gNinetySixBoardsFormsetGuid, NULL, &BufferSize, &ConfigData);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_INFO, "%a: no config data found\n", __FUNCTION__));
+ ConfigData.MezzanineType = MEZZANINE_NONE;
+ }
+
+ if (!EFI_ERROR (Status) &&
+ ConfigData.MezzanineType > MEZZANINE_MAX) {
+ DEBUG ((DEBUG_WARN,
+ "%a: invalid value for %s, defaulting to MEZZANINE_NONE\n",
+ __FUNCTION__, NINETY_SIX_BOARDS_CONFIG_VARIABLE_NAME));
+ ConfigData.MezzanineType = MEZZANINE_NONE;
+ Status = EFI_INVALID_PARAMETER; // trigger setvar below
+ }
+
+ //
+ // Write the newly selected value back to the variable store.
+ //
+ if (EFI_ERROR (Status)) {
+ ZeroMem (&ConfigData.Reserved, sizeof (ConfigData.Reserved));
+ Status = gRT->SetVariable (NINETY_SIX_BOARDS_CONFIG_VARIABLE_NAME,
+ &gNinetySixBoardsFormsetGuid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ sizeof (ConfigData), &ConfigData);
+
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: gRT->SetVariable () failed - %r\n",
+ __FUNCTION__, Status));
+ return Status;
+ }
+ }
+
+ switch (ConfigData.MezzanineType) {
+ case MEZZANINE_SECURE96:
+ mLsConnector.MezzanineType = MezzanineSecure96;
+ break;
+ default:
+ mLsConnector.MezzanineType = MezzanineUnknown;
+ }
+
+ Status = gBS->InstallProtocolInterface (&ImageHandle,
+ &gNinetySixBoardsLsConnectorProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ &mLsConnector);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Status = gBS->CreateEventEx (
+ EVT_NOTIFY_SIGNAL,
+ TPL_NOTIFY,
+ ApplyDeviceTreeOverlay,
+ NULL,
+ &gEfiEndOfDxeEventGroupGuid,
+ &EndOfDxeEvent);
+ ASSERT_EFI_ERROR (Status);
+
+ return InstallHiiPages ();
+}
diff --git a/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.h b/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.h
new file mode 100644
index 000000000000..e94a115a5929
--- /dev/null
+++ b/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.h
@@ -0,0 +1,32 @@
+/** @file
+
+ Copyright (c) 2018, Linaro Limited. All rights reserved.
+
+ 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 __NINETY_SIX_BOARDS_DXE_H__
+#define __NINETY_SIX_BOARDS_DXE_H__
+
+#include <Guid/HiiPlatformSetupFormset.h>
+#include <Guid/FormSet.h>
+
+#define MEZZANINE_NONE 0x0
+#define MEZZANINE_SECURE96 0x1
+#define MEZZANINE_MAX 0x1
+
+#define NINETY_SIX_BOARDS_CONFIG_VARIABLE_NAME L"NinetySixBoardsConfig"
+
+typedef struct {
+ UINT8 MezzanineType;
+ UINT8 Reserved[7];
+} NINETY_SIX_BOARDS_CONFIG_DATA;
+
+#endif // __NINETY_SIX_BOARDS_DXE_H__
diff --git a/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.inf b/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.inf
new file mode 100644
index 000000000000..5c6f863e8db4
--- /dev/null
+++ b/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.inf
@@ -0,0 +1,57 @@
+## @file
+#
+# 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.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x0001001A
+ BASE_NAME = NinetySixBoardsDxe
+ FILE_GUID = 3f68e889-cb77-4efc-bc84-afa0a64ad26e
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ ENTRY_POINT = EntryPoint
+
+[Sources]
+ NinetySixBoardsDxe.c
+ NinetySixBoardsDxe.h
+ NinetySixBoardsHii.vfr
+ NinetySixBoardsHii.uni
+
+[Packages]
+ EmbeddedPkg/EmbeddedPkg.dec
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ Platform/NinetySixBoards/NinetySixBoards.dec
+
+[LibraryClasses]
+ BaseLib
+ BaseMemoryLib
+ DebugLib
+ HiiLib
+ UefiBootServicesTableLib
+ UefiDriverEntryPoint
+ UefiLib
+ UefiRuntimeServicesTableLib
+
+[Protocols]
+ gNinetySixBoardsLsConnectorProtocolGuid ## PRODUCES
+ gNinetySixBoardsMezzanineProtocolGuid ## CONSUMES
+
+[Guids]
+ gEfiEndOfDxeEventGroupGuid
+ gFdtTableGuid
+ gNinetySixBoardsFormsetGuid
+
+[Depex]
+ gEfiVariableArchProtocolGuid AND
+ gEfiVariableWriteArchProtocolGuid
diff --git a/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsHii.uni b/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsHii.uni
new file mode 100644
index 000000000000..23f4c5859207
--- /dev/null
+++ b/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsHii.uni
@@ -0,0 +1,27 @@
+/** @file
+
+ Copyright (c) 2018, Linaro, Ltd. All rights reserved.
+
+ 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.
+
+**/
+
+#langdef en-US "English"
+
+#string STR_FORM_SET_TITLE #language en-US "96boards Mezzanine options"
+#string STR_FORM_SET_TITLE_HELP #language en-US "Configure the installed 96boards mezzanine"
+
+#string STR_MAIN_FORM_TITLE #language en-US "96boards Mezzanine options"
+#string STR_NULL_STRING #language en-US ""
+
+#string STR_MEZZANINE_SELECT_PROMPT #language en-US "96boards mezzanine"
+#string STR_MEZZANINE_SELECT_HELP #language en-US "The type of mezzanine board plugged into the 96boards LS connector"
+
+#string STR_MEZZANINE_NONE #language en-US "None/Unknown"
+#string STR_MEZZANINE_SECURE96 #language en-US "Secure96"
diff --git a/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsHii.vfr b/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsHii.vfr
new file mode 100644
index 000000000000..7e78c9cfa22f
--- /dev/null
+++ b/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsHii.vfr
@@ -0,0 +1,51 @@
+/** @file
+
+ Copyright (c) 2018, Linaro, Ltd. All rights reserved.
+
+ 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.
+
+**/
+
+#include "NinetySixBoardsDxe.h"
+
+//
+// EFI Variable attributes
+//
+#define EFI_VARIABLE_NON_VOLATILE 0x00000001
+#define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002
+#define EFI_VARIABLE_RUNTIME_ACCESS 0x00000004
+#define EFI_VARIABLE_READ_ONLY 0x00000008
+
+formset
+ guid = NINETY_SIX_BOARDS_FORMSET_GUID,
+ title = STRING_TOKEN(STR_FORM_SET_TITLE),
+ help = STRING_TOKEN(STR_FORM_SET_TITLE_HELP),
+ classguid = EFI_HII_PLATFORM_SETUP_FORMSET_GUID,
+
+ efivarstore NINETY_SIX_BOARDS_CONFIG_DATA,
+ attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE, // EFI variable attributes
+ name = NinetySixBoardsConfig,
+ guid = NINETY_SIX_BOARDS_FORMSET_GUID;
+
+ form formid = 0x1000,
+ title = STRING_TOKEN(STR_MAIN_FORM_TITLE);
+
+ oneof varid = NinetySixBoardsConfig.MezzanineType,
+ prompt = STRING_TOKEN(STR_MEZZANINE_SELECT_PROMPT),
+ help = STRING_TOKEN(STR_MEZZANINE_SELECT_HELP),
+ flags = NUMERIC_SIZE_1 | INTERACTIVE | RESET_REQUIRED,
+ option text = STRING_TOKEN(STR_MEZZANINE_NONE), value = MEZZANINE_NONE, flags = DEFAULT;
+ option text = STRING_TOKEN(STR_MEZZANINE_SECURE96), value = MEZZANINE_SECURE96, flags = 0;
+ endoneof;
+
+ subtitle text = STRING_TOKEN(STR_NULL_STRING);
+
+ endform;
+
+endformset;
--
2.11.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH edk2-platforms v2 7/7] Platform/Socionext/DeveloperBox: add 96boards mezzanine support
2018-02-20 17:49 [PATCH edk2-platforms v2 0/7] Add Secure96 mezzanine support Ard Biesheuvel
` (5 preceding siblings ...)
2018-02-20 17:49 ` [PATCH edk2-platforms v2 6/7] Platform/NinetySixBoards: add core driver for LS connector and config Ard Biesheuvel
@ 2018-02-20 17:49 ` Ard Biesheuvel
2018-02-22 16:04 ` [PATCH edk2-platforms v2 0/7] Add Secure96 " Leif Lindholm
7 siblings, 0 replies; 21+ messages in thread
From: Ard Biesheuvel @ 2018-02-20 17:49 UTC (permalink / raw)
To: edk2-devel; +Cc: leif.lindholm, Ard Biesheuvel
Wire up the various drivers for the 96boards LS connector and the
optional Secure96 mezzanine board.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
Platform/Socionext/DeveloperBox/DeveloperBox.dsc | 34 ++++++++++++++++++++
Platform/Socionext/DeveloperBox/DeveloperBox.fdf | 10 ++++++
Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c | 9 ++++++
Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf | 2 ++
4 files changed, 55 insertions(+)
diff --git a/Platform/Socionext/DeveloperBox/DeveloperBox.dsc b/Platform/Socionext/DeveloperBox/DeveloperBox.dsc
index 9c95618a20fe..39f40534bb39 100644
--- a/Platform/Socionext/DeveloperBox/DeveloperBox.dsc
+++ b/Platform/Socionext/DeveloperBox/DeveloperBox.dsc
@@ -33,6 +33,9 @@ [Defines]
[BuildOptions]
RELEASE_*_*_CC_FLAGS = -DMDEPKG_NDEBUG -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
+ # add ample padding to the DTC so we can apply 96boards mezzanine overlays
+ *_*_*_DTC_FLAGS = -p 1024
+
[BuildOptions.common.EDKII.DXE_CORE,BuildOptions.common.EDKII.DXE_DRIVER,BuildOptions.common.EDKII.UEFI_DRIVER,BuildOptions.common.EDKII.UEFI_APPLICATION]
GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
@@ -398,6 +401,28 @@ [PcdsFixedAtBuild.common]
!endif
gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareRevision|$(BUILD_NUMBER)
+ #
+ # 96boards mezzanine support
+ #
+ gNinetySixBoardsTokenSpaceGuid.PcdI2c0Parent|"/i2c@51210000"
+ gNinetySixBoardsTokenSpaceGuid.PcdI2c0BusFrequencyHz|100000
+ gNinetySixBoardsTokenSpaceGuid.PcdSpiParent|"/spi@54810000"
+ gNinetySixBoardsTokenSpaceGuid.PcdGpioParent|"/gpio@51000000"
+ gNinetySixBoardsTokenSpaceGuid.PcdGpioPolarity|0
+
+ gNinetySixBoardsTokenSpaceGuid.PcdGpioPinA|10
+ gNinetySixBoardsTokenSpaceGuid.PcdGpioPinB|11
+ gNinetySixBoardsTokenSpaceGuid.PcdGpioPinC|12
+ gNinetySixBoardsTokenSpaceGuid.PcdGpioPinD|13
+ gNinetySixBoardsTokenSpaceGuid.PcdGpioPinE|18
+ gNinetySixBoardsTokenSpaceGuid.PcdGpioPinF|19
+ gNinetySixBoardsTokenSpaceGuid.PcdGpioPinG|20
+ gNinetySixBoardsTokenSpaceGuid.PcdGpioPinH|21
+ gNinetySixBoardsTokenSpaceGuid.PcdGpioPinI|22
+ gNinetySixBoardsTokenSpaceGuid.PcdGpioPinJ|23
+ gNinetySixBoardsTokenSpaceGuid.PcdGpioPinK|24
+ gNinetySixBoardsTokenSpaceGuid.PcdGpioPinL|25
+
[PcdsPatchableInModule]
gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution|0
gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution|0
@@ -644,8 +669,17 @@ [Components.common]
SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.inf
#
+ # 96board mezzanine support
+ #
+ Platform/NinetySixBoards/Secure96Dxe/Secure96Dxe.inf
+ Silicon/Atmel/AtSha204a/AtSha204aDxe.inf
+ Platform/NinetySixBoards/NinetySixBoardsI2cDxe/NinetySixBoardsI2cDxe.inf
+ Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.inf
+
+ #
# I2C
#
Silicon/Socionext/SynQuacer/Drivers/SynQuacerI2cDxe/SynQuacerI2cDxe.inf
+ MdeModulePkg/Bus/I2c/I2cDxe/I2cDxe.inf
Platform/Socionext/DeveloperBox/OsInstallerMenuDxe/OsInstallerMenuDxe.inf
diff --git a/Platform/Socionext/DeveloperBox/DeveloperBox.fdf b/Platform/Socionext/DeveloperBox/DeveloperBox.fdf
index c2bc5aa85739..636bfaa3dd29 100644
--- a/Platform/Socionext/DeveloperBox/DeveloperBox.fdf
+++ b/Platform/Socionext/DeveloperBox/DeveloperBox.fdf
@@ -237,9 +237,18 @@ [FV.FvMain]
}
#
+ # 96board mezzanine support
+ #
+ INF Platform/NinetySixBoards/Secure96Dxe/Secure96Dxe.inf
+ INF Platform/NinetySixBoards/NinetySixBoardsI2cDxe/NinetySixBoardsI2cDxe.inf
+ INF Silicon/Atmel/AtSha204a/AtSha204aDxe.inf
+ INF Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.inf
+
+ #
# I2C
#
INF Silicon/Socionext/SynQuacer/Drivers/SynQuacerI2cDxe/SynQuacerI2cDxe.inf
+ INF MdeModulePkg/Bus/I2c/I2cDxe/I2cDxe.inf
INF Platform/Socionext/DeveloperBox/OsInstallerMenuDxe/OsInstallerMenuDxe.inf
@@ -430,6 +439,7 @@ [Rule.Common.DXE_DRIVER]
DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex
PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi
UI STRING="$(MODULE_NAME)" Optional
+ RAW BIN Optional |.dtb
}
[Rule.Common.DXE_RUNTIME_DRIVER]
diff --git a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c
index aab830dc3a5a..11c0648c2ca0 100644
--- a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c
+++ b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c
@@ -313,6 +313,15 @@ PlatformDxeEntryPoint (
&Handle);
ASSERT_EFI_ERROR (Status);
+ //
+ // Install the gNinetySixBoardsI2c0MasterGuid GUID onto the same handle,
+ // identifying I2C #1 on our SoC as I2C #0 on the 96boards low speed connector
+ //
+ Status = gBS->InstallProtocolInterface (&Handle,
+ &gNinetySixBoardsI2c0MasterGuid,
+ EFI_NATIVE_INTERFACE, NULL);
+ ASSERT_EFI_ERROR (Status);
+
SmmuEnableCoherentDma ();
SetMmioTimerFrequency ();
diff --git a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf
index 49d9deee57ea..4ba8bf4f761e 100644
--- a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf
+++ b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf
@@ -34,6 +34,7 @@ [Packages]
EmbeddedPkg/EmbeddedPkg.dec
MdeModulePkg/MdeModulePkg.dec
MdePkg/MdePkg.dec
+ Platform/NinetySixBoards/NinetySixBoards.dec
Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.dec
Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.dec
Silicon/Socionext/SynQuacer/SynQuacer.dec
@@ -56,6 +57,7 @@ [LibraryClasses]
UefiRuntimeServicesTableLib
[Guids]
+ gNinetySixBoardsI2c0MasterGuid
gEfiHiiPlatformSetupFormsetGuid
gFdtTableGuid
gNetsecNonDiscoverableDeviceGuid
--
2.11.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH edk2-platforms v2 1/7] Silicon/Atmel: add support for AtSha204a RNG
2018-02-20 17:49 ` [PATCH edk2-platforms v2 1/7] Silicon/Atmel: add support for AtSha204a RNG Ard Biesheuvel
@ 2018-02-22 13:08 ` Leif Lindholm
2018-02-23 15:33 ` Ard Biesheuvel
0 siblings, 1 reply; 21+ messages in thread
From: Leif Lindholm @ 2018-02-22 13:08 UTC (permalink / raw)
To: Ard Biesheuvel; +Cc: edk2-devel
On Tue, Feb 20, 2018 at 05:49:38PM +0000, Ard Biesheuvel wrote:
> This adds support for using the random number generator in the Atmel
> AtSha204a over I2C. Other functionality of the chip is currently
> unsupported.
>
> Note that the the I2C support in this device essentially violates the
> protocol layering, by requiring that the device is woken up by driving
> SDA low for a certain amount of time, which is something that cannot be
> expressed in terms of an I2C packet sent to the device's slave address.
> Instead, the slave address 0x0 is added to the device's address array,
> and the wake is sent by sending a dummy write to address 0x0, and
> ignoring the subsequent error. This requires the I2C bus to be clocked
> at 100 kHz.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
All of my feedback from v1 has been addressed, so:
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH edk2-platforms v2 2/7] Platform/NinetySixBoards: introduce package and mezzanine protocol
2018-02-20 17:49 ` [PATCH edk2-platforms v2 2/7] Platform/NinetySixBoards: introduce package and mezzanine protocol Ard Biesheuvel
@ 2018-02-22 13:15 ` Leif Lindholm
2018-02-22 13:21 ` Ard Biesheuvel
0 siblings, 1 reply; 21+ messages in thread
From: Leif Lindholm @ 2018-02-22 13:15 UTC (permalink / raw)
To: Ard Biesheuvel; +Cc: edk2-devel
On Tue, Feb 20, 2018 at 05:49:39PM +0000, Ard Biesheuvel wrote:
> Introduce the mezzanine protocol and the 96boards package defining
> the PCDs and GUIDs that may be used by implementations of the
> protocol.
This looks really good. Comments below are all style related.
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> Platform/NinetySixBoards/Include/Protocol/Mezzanine.h | 71 ++++++++++++++++++++
> Platform/NinetySixBoards/NinetySixBoards.dec | 67 ++++++++++++++++++
Why NinetySixBoards? Is 96Boards ENOTENOUGHCAMEL?
> 2 files changed, 138 insertions(+)
>
> diff --git a/Platform/NinetySixBoards/Include/Protocol/Mezzanine.h b/Platform/NinetySixBoards/Include/Protocol/Mezzanine.h
> new file mode 100644
> index 000000000000..7869ea979b48
> --- /dev/null
> +++ b/Platform/NinetySixBoards/Include/Protocol/Mezzanine.h
> @@ -0,0 +1,71 @@
> +/** @file
> +
> + 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 _MEZZANINE_H_
> +#define _MEZZANINE_H_
Maybe do the fulle _96BOARDS_MEZZANINE_H_?
> +
> +#include <Pi/PiI2c.h>
> +#include <Protocol/SpiConfiguration.h>
> +
> +#define MEZZANINE_PROTOCOL_GUID \
> + { 0xf0467a37, 0x3436, 0x40ef, { 0x94, 0x09, 0x4d, 0x1d, 0x7f, 0x51, 0x06, 0xd3 } }
> +
> +typedef struct _MEZZANINE_PROTOCOL MEZZANINE_PROTOCOL;
> +
> +/**
> + Apply the mezzanine's DT overlay
> +
> + @param[in] This Pointer to the MEZZANINE_PROTOCOL instance.
> + @param[in,out] Dtb Pointer to the device tree blob
> +
> + @return EFI_SUCCESS Operation succeeded.
> + @return other An error has occurred.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *APPLY_DEVICE_TREE_OVERLAY) (
> + IN MEZZANINE_PROTOCOL *This,
> + IN OUT VOID *Dtb
> + );
> +
> +struct _MEZZANINE_PROTOCOL {
> + //
> + // Get the device tree overlay for this mezzanine board
> + //
> + APPLY_DEVICE_TREE_OVERLAY ApplyDeviceTreeOverlay;
> + //
> + // The number of devices on LS connector I2C bus #0
> + //
> + UINT32 I2c0NumDevices;
> + //
> + // The number of devices on LS connector I2C bus #1
> + //
> + UINT32 I2c1NumDevices;
> + //
> + // Linear array of I2C devices on LS connector bus #0
> + //
> + CONST EFI_I2C_DEVICE *I2c0DeviceArray;
> + //
> + // Linear array of I2C devices on LS connector bus #0
> + //
> + CONST EFI_I2C_DEVICE *I2c1DeviceArray;
> + //
> + // NULL terminated linked list of SPI devices attached to the LS connector
> + //
> + CONST EFI_SPI_PERIPHERAL *SpiDeviceLinkedList;
> +};
> +
> +extern EFI_GUID gNinetySixBoardsMezzanineProtocolGuid;
> +
> +#endif // _MEZZANINE_H_
> diff --git a/Platform/NinetySixBoards/NinetySixBoards.dec b/Platform/NinetySixBoards/NinetySixBoards.dec
> new file mode 100644
> index 000000000000..f7e2b01459d7
> --- /dev/null
> +++ b/Platform/NinetySixBoards/NinetySixBoards.dec
> @@ -0,0 +1,67 @@
> +## @file
> +#
> +# Copyright (c) 2018, Linaro Ltd. All rights reserved.
> +#
> +# 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.
> +#
> +##
> +
> +[Defines]
> + DEC_SPECIFICATION = 0x0001001A
> + PACKAGE_NAME = NinetySixBoards
> + PACKAGE_GUID = ce4a4683-6e2d-4ec3-bc11-974289a09ab0
> + PACKAGE_VERSION = 0.1
> +
> +[Includes]
> + Include
> +
> +[Protocols]
> + ## Include/Protocol/Mezzanine.h
> + gNinetySixBoardsMezzanineProtocolGuid = { 0xf0467a37, 0x3436, 0x40ef, { 0x94, 0x09, 0x4d, 0x1d, 0x7f, 0x51, 0x06, 0xd3 } }
> +
> +[Guids]
> + # PCD scope GUID
> + gNinetySixBoardsTokenSpaceGuid = { 0xe0d2f33a, 0xb7dd, 0x4a69, { 0xb6, 0x76, 0xda, 0xe8, 0xa4, 0x17, 0xa7, 0xb5 } }
> +
> + # GUIDs to be installed as protocols to identify which controller connects to which bus
> + gNinetySixBoardsI2c0MasterGuid = { 0xba10e402, 0xcfdd, 0x4b87, { 0xbd, 0x02, 0x6e, 0x26, 0x9f, 0x01, 0x94, 0x11 } }
> + gNinetySixBoardsI2c1MasterGuid = { 0xcf64ac46, 0xd0be, 0x4a69, { 0x90, 0xa2, 0xf2, 0x82, 0x5b, 0x92, 0x25, 0x61 } }
> + gNinetySixBoardsSpiMasterGuid = { 0x9703fd99, 0xe638, 0x42b8, { 0xab, 0x81, 0x52, 0x61, 0x1b, 0xf7, 0xf7, 0x5d } }
> +
> +[PcdsFixedAtBuild]
> + # ASCII DT paths to the I2C parent nodes of the 96boards LS connector
> + gNinetySixBoardsTokenSpaceGuid.PcdI2c0Parent|""|VOID*|0x00000001
> + gNinetySixBoardsTokenSpaceGuid.PcdI2c1Parent|""|VOID*|0x00000002
> +
> + # I2C bus frequency in Hertz
> + gNinetySixBoardsTokenSpaceGuid.PcdI2c0BusFrequencyHz|0|UINT32|0x00000003
> + gNinetySixBoardsTokenSpaceGuid.PcdI2c1BusFrequencyHz|0|UINT32|0x00000004
> +
> + # ASCII DT path to the SPI parent node of the 96boards LS connector
> + gNinetySixBoardsTokenSpaceGuid.PcdSpiParent|""|VOID*|0x00000005
> +
> + # ASCII DT path to the GPIO parent node of the 96boards LS connector
> + gNinetySixBoardsTokenSpaceGuid.PcdGpioParent|""|VOID*|0x00000006
> +
> + # Polarity of the 96boards LS connector GPIOs (0 == GPIO_ACTIVE_HIGH, 1 == GPIO_ACTIVE_LOW)
> + gNinetySixBoardsTokenSpaceGuid.PcdGpioPolarity|0|UINT32|0x00000007
> +
> + # Pin numbers of the 96boards LS connector GPIOs
> + gNinetySixBoardsTokenSpaceGuid.PcdGpioPinA|0|UINT32|0x00000010
> + gNinetySixBoardsTokenSpaceGuid.PcdGpioPinB|0|UINT32|0x00000011
> + gNinetySixBoardsTokenSpaceGuid.PcdGpioPinC|0|UINT32|0x00000012
> + gNinetySixBoardsTokenSpaceGuid.PcdGpioPinD|0|UINT32|0x00000013
> + gNinetySixBoardsTokenSpaceGuid.PcdGpioPinE|0|UINT32|0x00000014
> + gNinetySixBoardsTokenSpaceGuid.PcdGpioPinF|0|UINT32|0x00000015
> + gNinetySixBoardsTokenSpaceGuid.PcdGpioPinG|0|UINT32|0x00000016
> + gNinetySixBoardsTokenSpaceGuid.PcdGpioPinH|0|UINT32|0x00000017
> + gNinetySixBoardsTokenSpaceGuid.PcdGpioPinI|0|UINT32|0x00000018
> + gNinetySixBoardsTokenSpaceGuid.PcdGpioPinJ|0|UINT32|0x00000019
> + gNinetySixBoardsTokenSpaceGuid.PcdGpioPinK|0|UINT32|0x0000001A
> + gNinetySixBoardsTokenSpaceGuid.PcdGpioPinL|0|UINT32|0x0000001B
> --
> 2.11.0
>
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH edk2-platforms v2 2/7] Platform/NinetySixBoards: introduce package and mezzanine protocol
2018-02-22 13:15 ` Leif Lindholm
@ 2018-02-22 13:21 ` Ard Biesheuvel
2018-02-22 13:44 ` Leif Lindholm
0 siblings, 1 reply; 21+ messages in thread
From: Ard Biesheuvel @ 2018-02-22 13:21 UTC (permalink / raw)
To: Leif Lindholm; +Cc: edk2-devel@lists.01.org
On 22 February 2018 at 13:15, Leif Lindholm <leif.lindholm@linaro.org> wrote:
> On Tue, Feb 20, 2018 at 05:49:39PM +0000, Ard Biesheuvel wrote:
>> Introduce the mezzanine protocol and the 96boards package defining
>> the PCDs and GUIDs that may be used by implementations of the
>> protocol.
>
> This looks really good. Comments below are all style related.
>
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>> ---
>> Platform/NinetySixBoards/Include/Protocol/Mezzanine.h | 71 ++++++++++++++++++++
>> Platform/NinetySixBoards/NinetySixBoards.dec | 67 ++++++++++++++++++
>
> Why NinetySixBoards? Is 96Boards ENOTENOUGHCAMEL?
>
That is what I started out with, but having CPP macros and lots of VFR
identifiers and other bits and pieces using leading digits was making
me nervous about whether it is supported in all configurations, so I
bit the bullet and renamed everything.
>> 2 files changed, 138 insertions(+)
>>
>> diff --git a/Platform/NinetySixBoards/Include/Protocol/Mezzanine.h b/Platform/NinetySixBoards/Include/Protocol/Mezzanine.h
>> new file mode 100644
>> index 000000000000..7869ea979b48
>> --- /dev/null
>> +++ b/Platform/NinetySixBoards/Include/Protocol/Mezzanine.h
>> @@ -0,0 +1,71 @@
>> +/** @file
>> +
>> + 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 _MEZZANINE_H_
>> +#define _MEZZANINE_H_
>
> Maybe do the fulle _96BOARDS_MEZZANINE_H_?
>
Sure
>> +
>> +#include <Pi/PiI2c.h>
>> +#include <Protocol/SpiConfiguration.h>
>> +
>> +#define MEZZANINE_PROTOCOL_GUID \
>> + { 0xf0467a37, 0x3436, 0x40ef, { 0x94, 0x09, 0x4d, 0x1d, 0x7f, 0x51, 0x06, 0xd3 } }
>> +
>> +typedef struct _MEZZANINE_PROTOCOL MEZZANINE_PROTOCOL;
>> +
>> +/**
>> + Apply the mezzanine's DT overlay
>> +
>> + @param[in] This Pointer to the MEZZANINE_PROTOCOL instance.
>> + @param[in,out] Dtb Pointer to the device tree blob
>> +
>> + @return EFI_SUCCESS Operation succeeded.
>> + @return other An error has occurred.
>> +**/
>> +typedef
>> +EFI_STATUS
>> +(EFIAPI *APPLY_DEVICE_TREE_OVERLAY) (
>> + IN MEZZANINE_PROTOCOL *This,
>> + IN OUT VOID *Dtb
>> + );
>> +
>> +struct _MEZZANINE_PROTOCOL {
>> + //
>> + // Get the device tree overlay for this mezzanine board
>> + //
>> + APPLY_DEVICE_TREE_OVERLAY ApplyDeviceTreeOverlay;
>> + //
>> + // The number of devices on LS connector I2C bus #0
>> + //
>> + UINT32 I2c0NumDevices;
>> + //
>> + // The number of devices on LS connector I2C bus #1
>> + //
>> + UINT32 I2c1NumDevices;
>> + //
>> + // Linear array of I2C devices on LS connector bus #0
>> + //
>> + CONST EFI_I2C_DEVICE *I2c0DeviceArray;
>> + //
>> + // Linear array of I2C devices on LS connector bus #0
>> + //
>> + CONST EFI_I2C_DEVICE *I2c1DeviceArray;
>> + //
>> + // NULL terminated linked list of SPI devices attached to the LS connector
>> + //
>> + CONST EFI_SPI_PERIPHERAL *SpiDeviceLinkedList;
>> +};
>> +
>> +extern EFI_GUID gNinetySixBoardsMezzanineProtocolGuid;
>> +
>> +#endif // _MEZZANINE_H_
>> diff --git a/Platform/NinetySixBoards/NinetySixBoards.dec b/Platform/NinetySixBoards/NinetySixBoards.dec
>> new file mode 100644
>> index 000000000000..f7e2b01459d7
>> --- /dev/null
>> +++ b/Platform/NinetySixBoards/NinetySixBoards.dec
>> @@ -0,0 +1,67 @@
>> +## @file
>> +#
>> +# Copyright (c) 2018, Linaro Ltd. All rights reserved.
>> +#
>> +# 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.
>> +#
>> +##
>> +
>> +[Defines]
>> + DEC_SPECIFICATION = 0x0001001A
>> + PACKAGE_NAME = NinetySixBoards
>> + PACKAGE_GUID = ce4a4683-6e2d-4ec3-bc11-974289a09ab0
>> + PACKAGE_VERSION = 0.1
>> +
>> +[Includes]
>> + Include
>> +
>> +[Protocols]
>> + ## Include/Protocol/Mezzanine.h
>> + gNinetySixBoardsMezzanineProtocolGuid = { 0xf0467a37, 0x3436, 0x40ef, { 0x94, 0x09, 0x4d, 0x1d, 0x7f, 0x51, 0x06, 0xd3 } }
>> +
>> +[Guids]
>> + # PCD scope GUID
>> + gNinetySixBoardsTokenSpaceGuid = { 0xe0d2f33a, 0xb7dd, 0x4a69, { 0xb6, 0x76, 0xda, 0xe8, 0xa4, 0x17, 0xa7, 0xb5 } }
>> +
>> + # GUIDs to be installed as protocols to identify which controller connects to which bus
>> + gNinetySixBoardsI2c0MasterGuid = { 0xba10e402, 0xcfdd, 0x4b87, { 0xbd, 0x02, 0x6e, 0x26, 0x9f, 0x01, 0x94, 0x11 } }
>> + gNinetySixBoardsI2c1MasterGuid = { 0xcf64ac46, 0xd0be, 0x4a69, { 0x90, 0xa2, 0xf2, 0x82, 0x5b, 0x92, 0x25, 0x61 } }
>> + gNinetySixBoardsSpiMasterGuid = { 0x9703fd99, 0xe638, 0x42b8, { 0xab, 0x81, 0x52, 0x61, 0x1b, 0xf7, 0xf7, 0x5d } }
>> +
>> +[PcdsFixedAtBuild]
>> + # ASCII DT paths to the I2C parent nodes of the 96boards LS connector
>> + gNinetySixBoardsTokenSpaceGuid.PcdI2c0Parent|""|VOID*|0x00000001
>> + gNinetySixBoardsTokenSpaceGuid.PcdI2c1Parent|""|VOID*|0x00000002
>> +
>> + # I2C bus frequency in Hertz
>> + gNinetySixBoardsTokenSpaceGuid.PcdI2c0BusFrequencyHz|0|UINT32|0x00000003
>> + gNinetySixBoardsTokenSpaceGuid.PcdI2c1BusFrequencyHz|0|UINT32|0x00000004
>> +
>> + # ASCII DT path to the SPI parent node of the 96boards LS connector
>> + gNinetySixBoardsTokenSpaceGuid.PcdSpiParent|""|VOID*|0x00000005
>> +
>> + # ASCII DT path to the GPIO parent node of the 96boards LS connector
>> + gNinetySixBoardsTokenSpaceGuid.PcdGpioParent|""|VOID*|0x00000006
>> +
>> + # Polarity of the 96boards LS connector GPIOs (0 == GPIO_ACTIVE_HIGH, 1 == GPIO_ACTIVE_LOW)
>> + gNinetySixBoardsTokenSpaceGuid.PcdGpioPolarity|0|UINT32|0x00000007
>> +
>> + # Pin numbers of the 96boards LS connector GPIOs
>> + gNinetySixBoardsTokenSpaceGuid.PcdGpioPinA|0|UINT32|0x00000010
>> + gNinetySixBoardsTokenSpaceGuid.PcdGpioPinB|0|UINT32|0x00000011
>> + gNinetySixBoardsTokenSpaceGuid.PcdGpioPinC|0|UINT32|0x00000012
>> + gNinetySixBoardsTokenSpaceGuid.PcdGpioPinD|0|UINT32|0x00000013
>> + gNinetySixBoardsTokenSpaceGuid.PcdGpioPinE|0|UINT32|0x00000014
>> + gNinetySixBoardsTokenSpaceGuid.PcdGpioPinF|0|UINT32|0x00000015
>> + gNinetySixBoardsTokenSpaceGuid.PcdGpioPinG|0|UINT32|0x00000016
>> + gNinetySixBoardsTokenSpaceGuid.PcdGpioPinH|0|UINT32|0x00000017
>> + gNinetySixBoardsTokenSpaceGuid.PcdGpioPinI|0|UINT32|0x00000018
>> + gNinetySixBoardsTokenSpaceGuid.PcdGpioPinJ|0|UINT32|0x00000019
>> + gNinetySixBoardsTokenSpaceGuid.PcdGpioPinK|0|UINT32|0x0000001A
>> + gNinetySixBoardsTokenSpaceGuid.PcdGpioPinL|0|UINT32|0x0000001B
>> --
>> 2.11.0
>>
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH edk2-platforms v2 2/7] Platform/NinetySixBoards: introduce package and mezzanine protocol
2018-02-22 13:21 ` Ard Biesheuvel
@ 2018-02-22 13:44 ` Leif Lindholm
2018-02-22 15:13 ` Ard Biesheuvel
0 siblings, 1 reply; 21+ messages in thread
From: Leif Lindholm @ 2018-02-22 13:44 UTC (permalink / raw)
To: Ard Biesheuvel; +Cc: edk2-devel@lists.01.org
On Thu, Feb 22, 2018 at 01:21:37PM +0000, Ard Biesheuvel wrote:
> On 22 February 2018 at 13:15, Leif Lindholm <leif.lindholm@linaro.org> wrote:
> > On Tue, Feb 20, 2018 at 05:49:39PM +0000, Ard Biesheuvel wrote:
> >> Introduce the mezzanine protocol and the 96boards package defining
> >> the PCDs and GUIDs that may be used by implementations of the
> >> protocol.
> >
> > This looks really good. Comments below are all style related.
> >
> >> Contributed-under: TianoCore Contribution Agreement 1.1
> >> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> >> ---
> >> Platform/NinetySixBoards/Include/Protocol/Mezzanine.h | 71 ++++++++++++++++++++
> >> Platform/NinetySixBoards/NinetySixBoards.dec | 67 ++++++++++++++++++
> >
> > Why NinetySixBoards? Is 96Boards ENOTENOUGHCAMEL?
> >
>
> That is what I started out with, but having CPP macros and lots of VFR
> identifiers and other bits and pieces using leading digits was making
> me nervous about whether it is supported in all configurations, so I
> bit the bullet and renamed everything.
I understand the paranoia, but we do have
PcAtChipsetPkg/8259InterruptControllerDxe
and
PcAtChipsetPkg/8254TimerDxe
so I would expect this to actually be reasonably well supported.
We may not have to worry about 3com and 3ware anymore, but if someone
wants to write drivers for ancient cards, I'd still prefer to be able
to give them predictable paths.
/
Leif
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH edk2-platforms v2 2/7] Platform/NinetySixBoards: introduce package and mezzanine protocol
2018-02-22 13:44 ` Leif Lindholm
@ 2018-02-22 15:13 ` Ard Biesheuvel
0 siblings, 0 replies; 21+ messages in thread
From: Ard Biesheuvel @ 2018-02-22 15:13 UTC (permalink / raw)
To: Leif Lindholm; +Cc: edk2-devel@lists.01.org
On 22 February 2018 at 13:44, Leif Lindholm <leif.lindholm@linaro.org> wrote:
> On Thu, Feb 22, 2018 at 01:21:37PM +0000, Ard Biesheuvel wrote:
>> On 22 February 2018 at 13:15, Leif Lindholm <leif.lindholm@linaro.org> wrote:
>> > On Tue, Feb 20, 2018 at 05:49:39PM +0000, Ard Biesheuvel wrote:
>> >> Introduce the mezzanine protocol and the 96boards package defining
>> >> the PCDs and GUIDs that may be used by implementations of the
>> >> protocol.
>> >
>> > This looks really good. Comments below are all style related.
>> >
>> >> Contributed-under: TianoCore Contribution Agreement 1.1
>> >> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>> >> ---
>> >> Platform/NinetySixBoards/Include/Protocol/Mezzanine.h | 71 ++++++++++++++++++++
>> >> Platform/NinetySixBoards/NinetySixBoards.dec | 67 ++++++++++++++++++
>> >
>> > Why NinetySixBoards? Is 96Boards ENOTENOUGHCAMEL?
>> >
>>
>> That is what I started out with, but having CPP macros and lots of VFR
>> identifiers and other bits and pieces using leading digits was making
>> me nervous about whether it is supported in all configurations, so I
>> bit the bullet and renamed everything.
>
> I understand the paranoia, but we do have
> PcAtChipsetPkg/8259InterruptControllerDxe
> and
> PcAtChipsetPkg/8254TimerDxe
> so I would expect this to actually be reasonably well supported.
>
> We may not have to worry about 3com and 3ware anymore, but if someone
> wants to write drivers for ancient cards, I'd still prefer to be able
> to give them predictable paths.
>
Fair enough, I'll change it back.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH edk2-platforms v2 4/7] Platform/NinetySixBoards: introduce LsConnector protocol
2018-02-20 17:49 ` [PATCH edk2-platforms v2 4/7] Platform/NinetySixBoards: introduce LsConnector protocol Ard Biesheuvel
@ 2018-02-22 15:29 ` Leif Lindholm
0 siblings, 0 replies; 21+ messages in thread
From: Leif Lindholm @ 2018-02-22 15:29 UTC (permalink / raw)
To: Ard Biesheuvel; +Cc: edk2-devel
On Tue, Feb 20, 2018 at 05:49:41PM +0000, Ard Biesheuvel wrote:
> Introduce a protocol describing the presence of a 96boards LS connector,
Can you expand the LS here?
(It's used as a proper name, so I don't consider it needing expansion
below, but useful for introduction.)
> and identifying the type of mezzanine that has been installed.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> Platform/NinetySixBoards/Include/Protocol/LsConnector.h | 35 ++++++++++++++++++++
> Platform/NinetySixBoards/NinetySixBoards.dec | 3 ++
> 2 files changed, 38 insertions(+)
>
> diff --git a/Platform/NinetySixBoards/Include/Protocol/LsConnector.h b/Platform/NinetySixBoards/Include/Protocol/LsConnector.h
> new file mode 100644
> index 000000000000..a1f0132c85ae
> --- /dev/null
> +++ b/Platform/NinetySixBoards/Include/Protocol/LsConnector.h
> @@ -0,0 +1,35 @@
> +/** @file
> +
> + 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 _LS_CONNECTOR_H_
> +#define _LS_CONNECTOR_H_
> +
> +#define LS_CONNECTOR_PROTOCOL_GUID \
> + { 0xae548d4c, 0x9062, 0x4eed, { 0x83, 0x5f, 0xf5, 0x10, 0xf8, 0xfc, 0x48, 0xaf } }
> +
> +typedef struct _LS_CONNECTOR_PROTOCOL LS_CONNECTOR_PROTOCOL;
> +
> +typedef enum {
> + MezzanineUnknown,
> + MezzanineSecure96,
> + MezzanineMax
> +} MEZZANINE_TYPE;
> +
> +struct _LS_CONNECTOR_PROTOCOL {
> + MEZZANINE_TYPE MezzanineType;
> +};
> +
> +extern EFI_GUID gNinetySixBoardsLsConnectorProtocolGuid;
> +
> +#endif // _LS_CONNECTOR_H_
> diff --git a/Platform/NinetySixBoards/NinetySixBoards.dec b/Platform/NinetySixBoards/NinetySixBoards.dec
> index f7e2b01459d7..5c3fe43dbb24 100644
> --- a/Platform/NinetySixBoards/NinetySixBoards.dec
> +++ b/Platform/NinetySixBoards/NinetySixBoards.dec
> @@ -25,6 +25,9 @@ [Protocols]
> ## Include/Protocol/Mezzanine.h
> gNinetySixBoardsMezzanineProtocolGuid = { 0xf0467a37, 0x3436, 0x40ef, { 0x94, 0x09, 0x4d, 0x1d, 0x7f, 0x51, 0x06, 0xd3 } }
>
> + ## Include/Protocol/LsConnector.h
> + gNinetySixBoardsLsConnectorProtocolGuid = { 0xae548d4c, 0x9062, 0x4eed, { 0x83, 0x5f, 0xf5, 0x10, 0xf8, 0xfc, 0x48, 0xaf } }
> +
> [Guids]
> # PCD scope GUID
> gNinetySixBoardsTokenSpaceGuid = { 0xe0d2f33a, 0xb7dd, 0x4a69, { 0xb6, 0x76, 0xda, 0xe8, 0xa4, 0x17, 0xa7, 0xb5 } }
> --
> 2.11.0
>
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH edk2-platforms v2 5/7] Platform/NinetySixBoards: add a driver for the Secure96 mezzanine board
2018-02-20 17:49 ` [PATCH edk2-platforms v2 5/7] Platform/NinetySixBoards: add a driver for the Secure96 mezzanine board Ard Biesheuvel
@ 2018-02-22 15:38 ` Leif Lindholm
0 siblings, 0 replies; 21+ messages in thread
From: Leif Lindholm @ 2018-02-22 15:38 UTC (permalink / raw)
To: Ard Biesheuvel; +Cc: edk2-devel
On Tue, Feb 20, 2018 at 05:49:42PM +0000, Ard Biesheuvel wrote:
> Add a driver that describes the Secure96 mezzanine board, and exposes
> both the information required to describe it to the OS using a DT overlay,
> and to describe it to UEFI itself.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> Platform/NinetySixBoards/Secure96Dxe/Secure96.dts | 76 +++++++
> Platform/NinetySixBoards/Secure96Dxe/Secure96.h | 26 +++
> Platform/NinetySixBoards/Secure96Dxe/Secure96Dxe.c | 211 ++++++++++++++++++++
> Platform/NinetySixBoards/Secure96Dxe/Secure96Dxe.inf | 67 +++++++
> 4 files changed, 380 insertions(+)
>
> diff --git a/Platform/NinetySixBoards/Secure96Dxe/Secure96.dts b/Platform/NinetySixBoards/Secure96Dxe/Secure96.dts
> new file mode 100644
> index 000000000000..08f59978c06f
> --- /dev/null
> +++ b/Platform/NinetySixBoards/Secure96Dxe/Secure96.dts
> @@ -0,0 +1,76 @@
> +/** @file
> + * Copyright (c) 2018, Linaro Limited. All rights reserved.
> + *
> + * 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.
> + */
> +
> +#include "Secure96.h"
> +
> +#define GPIO_PARENT_PLACEHOLDER_PHANDLE 0x0
Since this is likely to be used as a template for future drivers
including DT overlays (not just mezzanine), could you over-comment a
bit? Could you say "32-bit value filled in by this driver's helper
function FixupOverlay() when applying overlay" (if that's correct)?
/
Leif
> +
> +/dts-v1/;
> +/plugin/;
> +
> +/ {
> + fragment@0 {
> + target-path = "I2C_PARENT_PLACEHOLDER_STRING";
> + __overlay__ {
> + ATSHA204A_DT_NODENAME {
> + compatible = "atmel,atsha204a";
> + reg = <ATSHA204A_SLAVE_ADDRESS>;
> + };
> + ATECC508A_DT_NODENAME {
> + compatible = "atmel,atecc508a";
> + reg = <ATECC508A_SLAVE_ADDRESS>;
> + };
> + };
> + };
> +
> + fragment@1 {
> + target-path = "SPI_PARENT_PLACEHOLDER_STRING";
> + __overlay__ {
> + INFINEON_SLB9670_DT_NODENAME {
> + compatible = "infineon,slb9670";
> + reg = <INFINEON_SLB9670_SPI_CS>;
> + spi-max-frequency = <22500000>;
> + };
> + };
> + };
> +
> + fragment@2 {
> + target-path = "/";
> + __overlay__ {
> + gpio-leds {
> + compatible = "gpio-leds";
> +
> + secure96-u1 {
> + gpios = <GPIO_PARENT_PLACEHOLDER_PHANDLE
> + FixedPcdGet32 (PcdGpioPinG)
> + FixedPcdGet32 (PcdGpioPolarity)>;
> + };
> + secure96-u2 {
> + gpios = <GPIO_PARENT_PLACEHOLDER_PHANDLE
> + FixedPcdGet32 (PcdGpioPinF)
> + FixedPcdGet32 (PcdGpioPolarity)>;
> + };
> + secure96-u3 {
> + gpios = <GPIO_PARENT_PLACEHOLDER_PHANDLE
> + FixedPcdGet32 (PcdGpioPinI)
> + FixedPcdGet32 (PcdGpioPolarity)>;
> + };
> + secure96-u4 {
> + gpios = <GPIO_PARENT_PLACEHOLDER_PHANDLE
> + FixedPcdGet32 (PcdGpioPinH)
> + FixedPcdGet32 (PcdGpioPolarity)>;
> + };
> + };
> + };
> + };
> +};
> diff --git a/Platform/NinetySixBoards/Secure96Dxe/Secure96.h b/Platform/NinetySixBoards/Secure96Dxe/Secure96.h
> new file mode 100644
> index 000000000000..84b8aed13d1e
> --- /dev/null
> +++ b/Platform/NinetySixBoards/Secure96Dxe/Secure96.h
> @@ -0,0 +1,26 @@
> +/** @file
> +
> + 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 _SECURE96_H_
> +#define _SECURE96_H_
> +
> +#define ATSHA204A_SLAVE_ADDRESS 0x60
> +#define ATSHA204A_DT_NODENAME atsha204a@60
> +
> +#define ATECC508A_SLAVE_ADDRESS 0x51
> +#define ATECC508A_DT_NODENAME atecc508a@51
> +
> +#define INFINEON_SLB9670_SPI_CS 0x0
> +#define INFINEON_SLB9670_DT_NODENAME tpm@0
> +
> +#endif // _SECURE96_H_
> diff --git a/Platform/NinetySixBoards/Secure96Dxe/Secure96Dxe.c b/Platform/NinetySixBoards/Secure96Dxe/Secure96Dxe.c
> new file mode 100644
> index 000000000000..000f4b4abba4
> --- /dev/null
> +++ b/Platform/NinetySixBoards/Secure96Dxe/Secure96Dxe.c
> @@ -0,0 +1,211 @@
> +/** @file
> + 96boards Secure96 mezzanine board DXE driver.
> +
> + 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.
> +**/
> +
> +#include <PiDxe.h>
> +#include <libfdt.h>
> +#include <Library/BaseLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/DxeServicesLib.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +#include <Library/UefiLib.h>
> +#include <Protocol/LsConnector.h>
> +#include <Protocol/Mezzanine.h>
> +
> +#include "Secure96.h"
> +
> +STATIC CONST UINT32 mI2cAtmelSha204aSlaveAddress[] = {
> + ATSHA204A_SLAVE_ADDRESS,
> +
> + //
> + // The Atmel AtSha204a has an annoying 'wake' mode where it will only wake
> + // up if SDA is held low for a certain amount of time. Attempting to access
> + // a device at address 0x0 at 100 kHz should be sufficient to create this
> + // wake condition, so add address 0x0 to the slave addresses.
> + //
> + 0
> +};
> +
> +STATIC CONST EFI_I2C_DEVICE mI2c0Devices[] = {
> + {
> + &gAtSha204aI2cDeviceGuid, // DeviceGuid
> + 0, // DeviceIndex
> + 0, // HardwareRevision
> + 0, // I2C bus configuration
> + ARRAY_SIZE (mI2cAtmelSha204aSlaveAddress), // SlaveAddressCount
> + mI2cAtmelSha204aSlaveAddress // SlaveAddressArray
> + }
> +};
> +
> +STATIC CONST CHAR8 mLedNodes[][46] = {
> + "/fragment@2/__overlay__/gpio-leds/secure96-u1",
> + "/fragment@2/__overlay__/gpio-leds/secure96-u2",
> + "/fragment@2/__overlay__/gpio-leds/secure96-u3",
> + "/fragment@2/__overlay__/gpio-leds/secure96-u4",
> +};
> +
> +STATIC
> +VOID
> +SetOverlayFragmentTarget (
> + VOID *Overlay,
> + CONST CHAR8 *NodeName,
> + CONST CHAR8 *Target
> + )
> +{
> + INT32 Node;
> + INT32 Err;
> +
> + Node = fdt_path_offset (Overlay, NodeName);
> + ASSERT (Node > 0);
> +
> + Err = fdt_setprop (Overlay, Node, "target-path", Target,
> + AsciiStrLen (Target) + 1);
> + if (Err) {
> + DEBUG ((DEBUG_ERROR, "%a: fdt_setprop() failed - %a\n",
> + __FUNCTION__, fdt_strerror (Err)));
> + }
> +}
> +
> +STATIC
> +VOID
> +FixupOverlay (
> + VOID *Dtb,
> + VOID *Overlay
> + )
> +{
> + INT32 Node;
> + UINT32 GpioPhandle;
> + UINTN Idx;
> + UINT32 *GpioProp;
> + INT32 Err;
> +
> + //
> + // Set the correct GPIO phandle in the LED nodes
> + //
> + Node = fdt_path_offset (Dtb, FixedPcdGetPtr (PcdGpioParent));
> + ASSERT (Node > 0);
> +
> + GpioPhandle = fdt_get_phandle (Dtb, Node);
> + if (!GpioPhandle) {
> + //
> + // Node has no phandle yet -> create one
> + //
> + GpioPhandle = 1 + fdt_get_max_phandle (Dtb);
> + ASSERT (GpioPhandle >= 1);
> +
> + Err = fdt_setprop_u32 (Dtb, Node, "phandle", GpioPhandle);
> + if (Err) {
> + DEBUG ((DEBUG_ERROR,
> + "%a: fdt_setprop_u32(.., .., \"phandle\", 0x%x) failed - %a\n",
> + __FUNCTION__, GpioPhandle, fdt_strerror (Err)));
> + }
> + }
> +
> + for (Idx = 0; Idx < ARRAY_SIZE (mLedNodes); Idx++) {
> + Node = fdt_path_offset (Overlay, mLedNodes[Idx]);
> + ASSERT (Node > 0);
> +
> + GpioProp = fdt_getprop_w (Overlay, Node, "gpios", NULL);
> + ASSERT (GpioProp != NULL);
> +
> + *GpioProp = cpu_to_fdt32 (GpioPhandle);
> + }
> +
> + SetOverlayFragmentTarget (Overlay, "/fragment@0",
> + FixedPcdGetPtr (PcdI2c0Parent));
> +
> + SetOverlayFragmentTarget (Overlay, "/fragment@1",
> + FixedPcdGetPtr (PcdSpiParent));
> +}
> +
> +/**
> + Apply the mezzanine's DT overlay
> +
> + @param[in] This Pointer to the MEZZANINE_PROTOCOL instance.
> + @param[in,out] Dtb Pointer to the device tree blob
> +
> + @return EFI_SUCCESS Operation succeeded.
> + @return other An error has occurred.
> +**/
> +STATIC
> +EFI_STATUS
> +ApplyDeviceTreeOverlay (
> + IN MEZZANINE_PROTOCOL *This,
> + IN OUT VOID *Dtb
> + )
> +{
> + VOID *Overlay;
> + UINTN OverlaySize;
> + EFI_STATUS Status;
> + INT32 Err;
> +
> + //
> + // Load the raw overlay DTB image from the raw section of this FFS file.
> + //
> + Status = GetSectionFromFv (&gEfiCallerIdGuid,
> + EFI_SECTION_RAW, 0, &Overlay, &OverlaySize);
> + ASSERT_EFI_ERROR (Status);
> + if (EFI_ERROR (Status)) {
> + return EFI_NOT_FOUND;
> + }
> +
> + //
> + // Fix up unresolved references in the overlay.
> + //
> + FixupOverlay (Dtb, Overlay);
> +
> + //
> + // Merge the overlay with the DTB
> + //
> + Err = fdt_overlay_apply (Dtb, Overlay);
> + if (Err) {
> + DEBUG ((DEBUG_ERROR, "%a: fdt_overlay_apply() failed - %a\n",
> + __FUNCTION__, fdt_strerror (Err)));
> + return EFI_NOT_FOUND;
> + }
> +
> + return EFI_SUCCESS;
> +}
> +
> +STATIC MEZZANINE_PROTOCOL mMezzanine = {
> + ApplyDeviceTreeOverlay,
> + ARRAY_SIZE (mI2c0Devices),
> + 0,
> + mI2c0Devices,
> + NULL,
> + NULL,
> +};
> +
> +EFI_STATUS
> +EFIAPI
> +Secure96DxeEntryPoint (
> + IN EFI_HANDLE ImageHandle,
> + IN EFI_SYSTEM_TABLE *SystemTable
> + )
> +{
> + EFI_STATUS Status;
> + LS_CONNECTOR_PROTOCOL *LsConnector;
> +
> + Status = gBS->LocateProtocol (&gNinetySixBoardsLsConnectorProtocolGuid, NULL,
> + (VOID **)&LsConnector);
> + ASSERT_EFI_ERROR (Status);
> +
> + if (LsConnector->MezzanineType != MezzanineSecure96) {
> + return EFI_NOT_FOUND;
> + }
> +
> + return gBS->InstallProtocolInterface (&ImageHandle,
> + &gNinetySixBoardsMezzanineProtocolGuid,
> + EFI_NATIVE_INTERFACE,
> + &mMezzanine);
> +}
> diff --git a/Platform/NinetySixBoards/Secure96Dxe/Secure96Dxe.inf b/Platform/NinetySixBoards/Secure96Dxe/Secure96Dxe.inf
> new file mode 100644
> index 000000000000..e5686b9f5382
> --- /dev/null
> +++ b/Platform/NinetySixBoards/Secure96Dxe/Secure96Dxe.inf
> @@ -0,0 +1,67 @@
> +## @file
> +#
> +# 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.
> +#
> +##
> +
> +[Defines]
> + INF_VERSION = 0x0001001A
> + BASE_NAME = Secure96Dxe
> + FILE_GUID = 31519ec4-65f1-4790-b223-aa9330dd75fd
> + MODULE_TYPE = DXE_DRIVER
> + VERSION_STRING = 1.0
> + ENTRY_POINT = Secure96DxeEntryPoint
> +
> +[Sources]
> + Secure96.dts
> + Secure96.h
> + Secure96Dxe.c
> +
> +[Packages]
> + EmbeddedPkg/EmbeddedPkg.dec
> + MdeModulePkg/MdeModulePkg.dec
> + MdePkg/MdePkg.dec
> + Platform/NinetySixBoards/NinetySixBoards.dec
> + Silicon/Atmel/AtSha204a/AtSha204a.dec
> +
> +[LibraryClasses]
> + BaseLib
> + DebugLib
> + DxeServicesLib
> + FdtLib
> + UefiBootServicesTableLib
> + UefiDriverEntryPoint
> + UefiLib
> +
> +[Protocols]
> + gNinetySixBoardsLsConnectorProtocolGuid ## CONSUMES
> + gNinetySixBoardsMezzanineProtocolGuid ## PRODUCES
> +
> +[Guids]
> + gAtSha204aI2cDeviceGuid
> + gFdtTableGuid
> +
> +[FixedPcd]
> + gNinetySixBoardsTokenSpaceGuid.PcdGpioParent
> + gNinetySixBoardsTokenSpaceGuid.PcdGpioPinF
> + gNinetySixBoardsTokenSpaceGuid.PcdGpioPinG
> + gNinetySixBoardsTokenSpaceGuid.PcdGpioPinH
> + gNinetySixBoardsTokenSpaceGuid.PcdGpioPinI
> + gNinetySixBoardsTokenSpaceGuid.PcdGpioPolarity
> + gNinetySixBoardsTokenSpaceGuid.PcdI2c0Parent
> + gNinetySixBoardsTokenSpaceGuid.PcdSpiParent
> +
> +[Depex]
> + gNinetySixBoardsLsConnectorProtocolGuid
> +
> +[BuildOptions]
> + # dtc emits lots of spurious warnings for overlays
> + *_*_*_DTC_FLAGS = -q
> --
> 2.11.0
>
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH edk2-platforms v2 6/7] Platform/NinetySixBoards: add core driver for LS connector and config
2018-02-20 17:49 ` [PATCH edk2-platforms v2 6/7] Platform/NinetySixBoards: add core driver for LS connector and config Ard Biesheuvel
@ 2018-02-22 15:59 ` Leif Lindholm
2018-02-22 19:00 ` Ard Biesheuvel
0 siblings, 1 reply; 21+ messages in thread
From: Leif Lindholm @ 2018-02-22 15:59 UTC (permalink / raw)
To: Ard Biesheuvel; +Cc: edk2-devel
On Tue, Feb 20, 2018 at 05:49:43PM +0000, Ard Biesheuvel wrote:
> This adds a driver that manages the 96boards LS connector, i.e, it
> installs a HII page to configure the type of mezzanine that is installed
> in the slot, and it exposes this information via the LS connector protocol.
> It is also in charge of applying the overlay to the platform device tree
> at end of DXE.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> Platform/NinetySixBoards/Include/Guid/FormSet.h | 23 ++
> Platform/NinetySixBoards/NinetySixBoards.dec | 3 +
> Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.c | 221 ++++++++++++++++++++
> Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.h | 32 +++
> Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.inf | 57 +++++
> Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsHii.uni | 27 +++
> Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsHii.vfr | 51 +++++
> 7 files changed, 414 insertions(+)
>
> diff --git a/Platform/NinetySixBoards/Include/Guid/FormSet.h b/Platform/NinetySixBoards/Include/Guid/FormSet.h
> new file mode 100644
> index 000000000000..db16657f0848
> --- /dev/null
> +++ b/Platform/NinetySixBoards/Include/Guid/FormSet.h
> @@ -0,0 +1,23 @@
> +/** @file
> +
> + Copyright (c) 2018, Linaro Limited. All rights reserved.
> +
> + 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 __NINETY_SIX_BOARDS_FORMSET_H__
> +#define __NINETY_SIX_BOARDS_FORMSET_H__
> +
> +#define NINETY_SIX_BOARDS_FORMSET_GUID \
> + { 0x7500c9d2, 0x9203, 0x4a37, { 0x84, 0xbb, 0x92, 0xa9, 0xce, 0x34, 0x38, 0xbd } }
> +
> +extern EFI_GUID gNinetySixBoardsFormsetGuid;
> +
> +#endif // __NINETY_SIX_BOARDS_FORMSET_H__
> diff --git a/Platform/NinetySixBoards/NinetySixBoards.dec b/Platform/NinetySixBoards/NinetySixBoards.dec
> index 5c3fe43dbb24..e7d1705d47ff 100644
> --- a/Platform/NinetySixBoards/NinetySixBoards.dec
> +++ b/Platform/NinetySixBoards/NinetySixBoards.dec
> @@ -37,6 +37,9 @@ [Guids]
> gNinetySixBoardsI2c1MasterGuid = { 0xcf64ac46, 0xd0be, 0x4a69, { 0x90, 0xa2, 0xf2, 0x82, 0x5b, 0x92, 0x25, 0x61 } }
> gNinetySixBoardsSpiMasterGuid = { 0x9703fd99, 0xe638, 0x42b8, { 0xab, 0x81, 0x52, 0x61, 0x1b, 0xf7, 0xf7, 0x5d } }
>
> + # GUID for the HII configuration form
> + gNinetySixBoardsFormsetGuid = { 0x7500c9d2, 0x9203, 0x4a37, { 0x84, 0xbb, 0x92, 0xa9, 0xce, 0x34, 0x38, 0xbd } }
> +
> [PcdsFixedAtBuild]
> # ASCII DT paths to the I2C parent nodes of the 96boards LS connector
> gNinetySixBoardsTokenSpaceGuid.PcdI2c0Parent|""|VOID*|0x00000001
> diff --git a/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.c b/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.c
> new file mode 100644
> index 000000000000..6dc5f549e560
> --- /dev/null
> +++ b/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.c
> @@ -0,0 +1,221 @@
> +/** @file
> +
> + Copyright (c) 2018, Linaro, Ltd. All rights reserved.
> +
> + 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.
> +
> +**/
> +
> +#include <Uefi.h>
> +#include <Library/BaseLib.h>
> +#include <Library/BaseMemoryLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/DevicePathLib.h>
> +#include <Library/HiiLib.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +#include <Library/UefiLib.h>
> +#include <Library/UefiRuntimeServicesTableLib.h>
> +#include <Protocol/LsConnector.h>
> +#include <Protocol/Mezzanine.h>
> +
> +#include "NinetySixBoardsDxe.h"
> +
> +extern UINT8 NinetySixBoardsHiiBin[];
> +extern UINT8 NinetySixBoardsDxeStrings[];
> +
> +typedef struct {
> + VENDOR_DEVICE_PATH VendorDevicePath;
> + EFI_DEVICE_PATH_PROTOCOL End;
> +} HII_VENDOR_DEVICE_PATH;
> +
> +STATIC HII_VENDOR_DEVICE_PATH mNinetySixBoardsDxeVendorDevicePath = {
> + {
> + {
> + HARDWARE_DEVICE_PATH,
> + HW_VENDOR_DP,
> + {
> + (UINT8) (sizeof (VENDOR_DEVICE_PATH)),
> + (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
> + }
> + },
> + NINETY_SIX_BOARDS_FORMSET_GUID
> + },
> + {
> + END_DEVICE_PATH_TYPE,
> + END_ENTIRE_DEVICE_PATH_SUBTYPE,
> + {
> + (UINT8) (END_DEVICE_PATH_LENGTH),
> + (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)
> + }
> + }
> +};
> +
> +STATIC LS_CONNECTOR_PROTOCOL mLsConnector;
> +STATIC EFI_EVENT EndOfDxeEvent;
> +
> +STATIC
> +EFI_STATUS
> +InstallHiiPages (
> + VOID
> + )
> +{
> + EFI_STATUS Status;
> + EFI_HII_HANDLE HiiHandle;
> + EFI_HANDLE DriverHandle;
> +
> + DriverHandle = NULL;
> + Status = gBS->InstallMultipleProtocolInterfaces (&DriverHandle,
> + &gEfiDevicePathProtocolGuid,
> + &mNinetySixBoardsDxeVendorDevicePath,
> + NULL);
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + HiiHandle = HiiAddPackages (&gNinetySixBoardsFormsetGuid,
> + DriverHandle,
> + NinetySixBoardsDxeStrings,
> + NinetySixBoardsHiiBin,
> + NULL);
> +
> + if (HiiHandle == NULL) {
> + gBS->UninstallMultipleProtocolInterfaces (DriverHandle,
> + &gEfiDevicePathProtocolGuid,
> + &mNinetySixBoardsDxeVendorDevicePath,
> + NULL);
> + return EFI_OUT_OF_RESOURCES;
> + }
> + return EFI_SUCCESS;
> +}
> +
> +STATIC
> +VOID
> +EFIAPI
> +ApplyDeviceTreeOverlay (
> + EFI_EVENT Event,
> + VOID *Context
> + )
> +{
> + VOID *Dtb;
> + MEZZANINE_PROTOCOL *Mezzanine;
> + EFI_STATUS Status;
> +
> + //
> + // Find the DTB in the configuration table array. If it isn't there, just
> + // bail without an error: we may be running on an ACPI platform even if
> + // this driver does not support it [yet].
> + //
> + Status = EfiGetSystemConfigurationTable (&gFdtTableGuid, &Dtb);
> + if (Status == EFI_NOT_FOUND) {
> + return;
> + }
> + ASSERT_EFI_ERROR (Status);
> +
> + Status = gBS->LocateProtocol (&gNinetySixBoardsMezzanineProtocolGuid, NULL,
> + (VOID **)&Mezzanine);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_INFO, "%a: no mezzanine driver active\n", __FUNCTION__));
> + return;
> + }
> +
> + Status = Mezzanine->ApplyDeviceTreeOverlay (Mezzanine, Dtb);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_WARN, "%a: failed to apply DT overlay - %r\n", __FUNCTION__,
> + Status));
> + }
> +}
> +
> +/**
> + The entry point for NinetySixBoardsDxe driver.
> +
> + @param[in] ImageHandle The image handle of the driver.
> + @param[in] SystemTable The system table.
> +
> + @retval EFI_ALREADY_STARTED The driver already exists in system.
> + @retval EFI_OUT_OF_RESOURCES Fail to execute entry point due to lack of
> + resources.
> + @retval EFI_SUCCES All the related protocols are installed on
> + the driver.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +EntryPoint (
> + IN EFI_HANDLE ImageHandle,
> + IN EFI_SYSTEM_TABLE *SystemTable
> + )
> +{
> + EFI_STATUS Status;
> + NINETY_SIX_BOARDS_CONFIG_DATA ConfigData;
> + UINTN BufferSize;
> +
> + //
> + // Get the current config settings from the EFI variable.
> + //
> + BufferSize = sizeof (ConfigData);
> + Status = gRT->GetVariable (NINETY_SIX_BOARDS_CONFIG_VARIABLE_NAME,
> + &gNinetySixBoardsFormsetGuid, NULL, &BufferSize, &ConfigData);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_INFO, "%a: no config data found\n", __FUNCTION__));
> + ConfigData.MezzanineType = MEZZANINE_NONE;
> + }
> +
> + if (!EFI_ERROR (Status) &&
> + ConfigData.MezzanineType > MEZZANINE_MAX) {
> + DEBUG ((DEBUG_WARN,
> + "%a: invalid value for %s, defaulting to MEZZANINE_NONE\n",
> + __FUNCTION__, NINETY_SIX_BOARDS_CONFIG_VARIABLE_NAME));
> + ConfigData.MezzanineType = MEZZANINE_NONE;
> + Status = EFI_INVALID_PARAMETER; // trigger setvar below
> + }
> +
> + //
> + // Write the newly selected value back to the variable store.
> + //
> + if (EFI_ERROR (Status)) {
> + ZeroMem (&ConfigData.Reserved, sizeof (ConfigData.Reserved));
> + Status = gRT->SetVariable (NINETY_SIX_BOARDS_CONFIG_VARIABLE_NAME,
> + &gNinetySixBoardsFormsetGuid,
> + EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
> + sizeof (ConfigData), &ConfigData);
> +
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "%a: gRT->SetVariable () failed - %r\n",
> + __FUNCTION__, Status));
> + return Status;
> + }
> + }
> +
> + switch (ConfigData.MezzanineType) {
> + case MEZZANINE_SECURE96:
> + mLsConnector.MezzanineType = MezzanineSecure96;
> + break;
> + default:
> + mLsConnector.MezzanineType = MezzanineUnknown;
> + }
> +
> + Status = gBS->InstallProtocolInterface (&ImageHandle,
> + &gNinetySixBoardsLsConnectorProtocolGuid,
> + EFI_NATIVE_INTERFACE,
> + &mLsConnector);
> + if (EFI_ERROR (Status)) {
> + return Status;
> + }
> +
> + Status = gBS->CreateEventEx (
> + EVT_NOTIFY_SIGNAL,
> + TPL_NOTIFY,
> + ApplyDeviceTreeOverlay,
> + NULL,
> + &gEfiEndOfDxeEventGroupGuid,
> + &EndOfDxeEvent);
> + ASSERT_EFI_ERROR (Status);
> +
> + return InstallHiiPages ();
> +}
> diff --git a/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.h b/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.h
> new file mode 100644
> index 000000000000..e94a115a5929
> --- /dev/null
> +++ b/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.h
> @@ -0,0 +1,32 @@
> +/** @file
> +
> + Copyright (c) 2018, Linaro Limited. All rights reserved.
> +
> + 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 __NINETY_SIX_BOARDS_DXE_H__
> +#define __NINETY_SIX_BOARDS_DXE_H__
> +
> +#include <Guid/HiiPlatformSetupFormset.h>
> +#include <Guid/FormSet.h>
> +
> +#define MEZZANINE_NONE 0x0
> +#define MEZZANINE_SECURE96 0x1
> +#define MEZZANINE_MAX 0x1
Would this be simpler as an enum with a permanent final element called
MaxMezzanineType? This seems like the common EDK2 (and even UEFI)
pattern.
> +
> +#define NINETY_SIX_BOARDS_CONFIG_VARIABLE_NAME L"NinetySixBoardsConfig"
> +
> +typedef struct {
> + UINT8 MezzanineType;
> + UINT8 Reserved[7];
> +} NINETY_SIX_BOARDS_CONFIG_DATA;
> +
> +#endif // __NINETY_SIX_BOARDS_DXE_H__
> diff --git a/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.inf b/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.inf
> new file mode 100644
> index 000000000000..5c6f863e8db4
> --- /dev/null
> +++ b/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.inf
> @@ -0,0 +1,57 @@
> +## @file
> +#
> +# 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.
> +#
> +##
> +
> +[Defines]
> + INF_VERSION = 0x0001001A
> + BASE_NAME = NinetySixBoardsDxe
> + FILE_GUID = 3f68e889-cb77-4efc-bc84-afa0a64ad26e
> + MODULE_TYPE = DXE_DRIVER
> + VERSION_STRING = 1.0
> + ENTRY_POINT = EntryPoint
> +
> +[Sources]
> + NinetySixBoardsDxe.c
> + NinetySixBoardsDxe.h
> + NinetySixBoardsHii.vfr
> + NinetySixBoardsHii.uni
> +
> +[Packages]
> + EmbeddedPkg/EmbeddedPkg.dec
> + MdePkg/MdePkg.dec
> + MdeModulePkg/MdeModulePkg.dec
> + Platform/NinetySixBoards/NinetySixBoards.dec
> +
> +[LibraryClasses]
> + BaseLib
> + BaseMemoryLib
> + DebugLib
> + HiiLib
> + UefiBootServicesTableLib
> + UefiDriverEntryPoint
> + UefiLib
> + UefiRuntimeServicesTableLib
> +
> +[Protocols]
> + gNinetySixBoardsLsConnectorProtocolGuid ## PRODUCES
> + gNinetySixBoardsMezzanineProtocolGuid ## CONSUMES
> +
> +[Guids]
> + gEfiEndOfDxeEventGroupGuid
> + gFdtTableGuid
> + gNinetySixBoardsFormsetGuid
> +
> +[Depex]
> + gEfiVariableArchProtocolGuid AND
> + gEfiVariableWriteArchProtocolGuid
> diff --git a/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsHii.uni b/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsHii.uni
> new file mode 100644
> index 000000000000..23f4c5859207
> --- /dev/null
> +++ b/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsHii.uni
> @@ -0,0 +1,27 @@
> +/** @file
> +
> + Copyright (c) 2018, Linaro, Ltd. All rights reserved.
> +
> + 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.
> +
> +**/
> +
> +#langdef en-US "English"
> +
> +#string STR_FORM_SET_TITLE #language en-US "96boards Mezzanine options"
> +#string STR_FORM_SET_TITLE_HELP #language en-US "Configure the installed 96boards mezzanine"
> +
> +#string STR_MAIN_FORM_TITLE #language en-US "96boards Mezzanine options"
> +#string STR_NULL_STRING #language en-US ""
> +
> +#string STR_MEZZANINE_SELECT_PROMPT #language en-US "96boards mezzanine"
> +#string STR_MEZZANINE_SELECT_HELP #language en-US "The type of mezzanine board plugged into the 96boards LS connector"
> +
> +#string STR_MEZZANINE_NONE #language en-US "None/Unknown"
> +#string STR_MEZZANINE_SECURE96 #language en-US "Secure96"
> diff --git a/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsHii.vfr b/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsHii.vfr
> new file mode 100644
> index 000000000000..7e78c9cfa22f
> --- /dev/null
> +++ b/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsHii.vfr
> @@ -0,0 +1,51 @@
> +/** @file
> +
> + Copyright (c) 2018, Linaro, Ltd. All rights reserved.
> +
> + 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.
> +
> +**/
> +
> +#include "NinetySixBoardsDxe.h"
> +
> +//
> +// EFI Variable attributes
> +//
> +#define EFI_VARIABLE_NON_VOLATILE 0x00000001
> +#define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002
> +#define EFI_VARIABLE_RUNTIME_ACCESS 0x00000004
> +#define EFI_VARIABLE_READ_ONLY 0x00000008
Hmm, that jogged my memory - I need to follow up on
https://www.mail-archive.com/edk2-devel@lists.01.org/msg34156.html
... and I would appreciate an R-b on
https://www.mail-archive.com/edk2-devel@lists.01.org/msg34154.html
:)
I would prefer if we could get this one in with a
#include <Uefi/UefiMultiPhase.h>
instead.
/
Leif
> +
> +formset
> + guid = NINETY_SIX_BOARDS_FORMSET_GUID,
> + title = STRING_TOKEN(STR_FORM_SET_TITLE),
> + help = STRING_TOKEN(STR_FORM_SET_TITLE_HELP),
> + classguid = EFI_HII_PLATFORM_SETUP_FORMSET_GUID,
> +
> + efivarstore NINETY_SIX_BOARDS_CONFIG_DATA,
> + attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE, // EFI variable attributes
> + name = NinetySixBoardsConfig,
> + guid = NINETY_SIX_BOARDS_FORMSET_GUID;
> +
> + form formid = 0x1000,
> + title = STRING_TOKEN(STR_MAIN_FORM_TITLE);
> +
> + oneof varid = NinetySixBoardsConfig.MezzanineType,
> + prompt = STRING_TOKEN(STR_MEZZANINE_SELECT_PROMPT),
> + help = STRING_TOKEN(STR_MEZZANINE_SELECT_HELP),
> + flags = NUMERIC_SIZE_1 | INTERACTIVE | RESET_REQUIRED,
> + option text = STRING_TOKEN(STR_MEZZANINE_NONE), value = MEZZANINE_NONE, flags = DEFAULT;
> + option text = STRING_TOKEN(STR_MEZZANINE_SECURE96), value = MEZZANINE_SECURE96, flags = 0;
> + endoneof;
> +
> + subtitle text = STRING_TOKEN(STR_NULL_STRING);
> +
> + endform;
> +
> +endformset;
> --
> 2.11.0
>
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH edk2-platforms v2 0/7] Add Secure96 mezzanine support
2018-02-20 17:49 [PATCH edk2-platforms v2 0/7] Add Secure96 mezzanine support Ard Biesheuvel
` (6 preceding siblings ...)
2018-02-20 17:49 ` [PATCH edk2-platforms v2 7/7] Platform/Socionext/DeveloperBox: add 96boards mezzanine support Ard Biesheuvel
@ 2018-02-22 16:04 ` Leif Lindholm
7 siblings, 0 replies; 21+ messages in thread
From: Leif Lindholm @ 2018-02-22 16:04 UTC (permalink / raw)
To: Ard Biesheuvel; +Cc: edk2-devel
So, the ones I haven't commented on in this series, I'm happy with,
but since there may be non-trivial refactoring I'm not posting R-b on yet.
On Tue, Feb 20, 2018 at 05:49:37PM +0000, Ard Biesheuvel wrote:
> Almost a complete rewrite of the v1. I omitted the patches that add SPI
> and I2C DT nodes to the SynQuacer DTS. I did include the v2 of the Atmel
> AtSha204a driver, since the latter patches depend on it.
>
> This version implements a complete split between the generic 96boards
> LS connector support and its associated plumbing (defining which I2C,
> SPI and GPIO controllers are connected) on the one hand, and support
> for the Secure96 mezzanine board in particular on the other. More
> specifically, all Secure96 PCDs were dropped, and the only platform
> specific configuration that remains is including the Secure96 driver
> and the driver for its peripherals to the build.
>
> Patch #1 is v2 of the AtSha204a driver, with Leif's review comments
> addressed.
>
> Patch #2 introduces the mezzanine protocol, which abstracts away from
> any particular mezzanine implementation.
>
> Patch #3 introduces the generic I2C plumbing for any mezzanine that exposes
> I2C peripherals.
>
> Patch #4 implements the protocol that asserts the presence of a 96boards LS
> connector and the type of mezzanine connected to it.
>
> Patch #5 adds the Secure96 driver, which incorporates the DT overlay, and
> a description of the I2C peripheral.
>
> Patch #6 adds a generic driver for configuring the type of mezzanine, and
> to interface with it at end of DXE time to install the appropriate DT
> overlay.
>
> Patch #7 wires everything up for the DeveloperBox platform.
>
> Ard Biesheuvel (7):
> Silicon/Atmel: add support for AtSha204a RNG
> Platform/NinetySixBoards: introduce package and mezzanine protocol
> Platform/NinetySixBoards: introduce I2C driver
> Platform/NinetySixBoards: introduce LsConnector protocol
> Platform/NinetySixBoards: add a driver for the Secure96 mezzanine
> board
> Platform/NinetySixBoards: add core driver for LS connector and config
> Platform/Socionext/DeveloperBox: add 96boards mezzanine support
>
> Platform/NinetySixBoards/Include/Guid/FormSet.h | 23 ++
> Platform/NinetySixBoards/Include/Protocol/LsConnector.h | 35 +++
> Platform/NinetySixBoards/Include/Protocol/Mezzanine.h | 71 +++++
> Platform/NinetySixBoards/NinetySixBoards.dec | 73 +++++
> Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.c | 221 ++++++++++++++
> Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.h | 32 ++
> Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.inf | 57 ++++
> Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsHii.uni | 27 ++
> Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsHii.vfr | 51 ++++
> Platform/NinetySixBoards/NinetySixBoardsI2cDxe/NinetySixBoardsI2cDxe.c | 202 +++++++++++++
> Platform/NinetySixBoards/NinetySixBoardsI2cDxe/NinetySixBoardsI2cDxe.inf | 51 ++++
> Platform/NinetySixBoards/Secure96Dxe/Secure96.dts | 76 +++++
> Platform/NinetySixBoards/Secure96Dxe/Secure96.h | 26 ++
> Platform/NinetySixBoards/Secure96Dxe/Secure96Dxe.c | 211 +++++++++++++
> Platform/NinetySixBoards/Secure96Dxe/Secure96Dxe.inf | 67 +++++
> Platform/Socionext/DeveloperBox/DeveloperBox.dsc | 34 +++
> Platform/Socionext/DeveloperBox/DeveloperBox.fdf | 10 +
> Silicon/Atmel/AtSha204a/AtSha204a.dec | 22 ++
> Silicon/Atmel/AtSha204a/AtSha204aDriver.c | 309 ++++++++++++++++++++
> Silicon/Atmel/AtSha204a/AtSha204aDriver.h | 81 +++++
> Silicon/Atmel/AtSha204a/AtSha204aDxe.inf | 52 ++++
> Silicon/Atmel/AtSha204a/ComponentName.c | 186 ++++++++++++
> Silicon/Atmel/AtSha204a/DriverBinding.c | 242 +++++++++++++++
> Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c | 9 +
> Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf | 2 +
> 25 files changed, 2170 insertions(+)
> create mode 100644 Platform/NinetySixBoards/Include/Guid/FormSet.h
> create mode 100644 Platform/NinetySixBoards/Include/Protocol/LsConnector.h
> create mode 100644 Platform/NinetySixBoards/Include/Protocol/Mezzanine.h
> create mode 100644 Platform/NinetySixBoards/NinetySixBoards.dec
> create mode 100644 Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.c
> create mode 100644 Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.h
> create mode 100644 Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.inf
> create mode 100644 Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsHii.uni
> create mode 100644 Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsHii.vfr
> create mode 100644 Platform/NinetySixBoards/NinetySixBoardsI2cDxe/NinetySixBoardsI2cDxe.c
> create mode 100644 Platform/NinetySixBoards/NinetySixBoardsI2cDxe/NinetySixBoardsI2cDxe.inf
> create mode 100644 Platform/NinetySixBoards/Secure96Dxe/Secure96.dts
> create mode 100644 Platform/NinetySixBoards/Secure96Dxe/Secure96.h
> create mode 100644 Platform/NinetySixBoards/Secure96Dxe/Secure96Dxe.c
> create mode 100644 Platform/NinetySixBoards/Secure96Dxe/Secure96Dxe.inf
> create mode 100644 Silicon/Atmel/AtSha204a/AtSha204a.dec
> create mode 100644 Silicon/Atmel/AtSha204a/AtSha204aDriver.c
> create mode 100644 Silicon/Atmel/AtSha204a/AtSha204aDriver.h
> create mode 100644 Silicon/Atmel/AtSha204a/AtSha204aDxe.inf
> create mode 100644 Silicon/Atmel/AtSha204a/ComponentName.c
> create mode 100644 Silicon/Atmel/AtSha204a/DriverBinding.c
>
> --
> 2.11.0
>
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH edk2-platforms v2 6/7] Platform/NinetySixBoards: add core driver for LS connector and config
2018-02-22 15:59 ` Leif Lindholm
@ 2018-02-22 19:00 ` Ard Biesheuvel
2018-02-22 19:10 ` Ard Biesheuvel
0 siblings, 1 reply; 21+ messages in thread
From: Ard Biesheuvel @ 2018-02-22 19:00 UTC (permalink / raw)
To: Leif Lindholm; +Cc: edk2-devel@lists.01.org
On 22 February 2018 at 15:59, Leif Lindholm <leif.lindholm@linaro.org> wrote:
> On Tue, Feb 20, 2018 at 05:49:43PM +0000, Ard Biesheuvel wrote:
>> This adds a driver that manages the 96boards LS connector, i.e, it
>> installs a HII page to configure the type of mezzanine that is installed
>> in the slot, and it exposes this information via the LS connector protocol.
>> It is also in charge of applying the overlay to the platform device tree
>> at end of DXE.
>>
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>> ---
>> Platform/NinetySixBoards/Include/Guid/FormSet.h | 23 ++
>> Platform/NinetySixBoards/NinetySixBoards.dec | 3 +
>> Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.c | 221 ++++++++++++++++++++
>> Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.h | 32 +++
>> Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.inf | 57 +++++
>> Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsHii.uni | 27 +++
>> Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsHii.vfr | 51 +++++
>> 7 files changed, 414 insertions(+)
>>
>> diff --git a/Platform/NinetySixBoards/Include/Guid/FormSet.h b/Platform/NinetySixBoards/Include/Guid/FormSet.h
>> new file mode 100644
>> index 000000000000..db16657f0848
>> --- /dev/null
>> +++ b/Platform/NinetySixBoards/Include/Guid/FormSet.h
>> @@ -0,0 +1,23 @@
>> +/** @file
>> +
>> + Copyright (c) 2018, Linaro Limited. All rights reserved.
>> +
>> + 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 __NINETY_SIX_BOARDS_FORMSET_H__
>> +#define __NINETY_SIX_BOARDS_FORMSET_H__
>> +
>> +#define NINETY_SIX_BOARDS_FORMSET_GUID \
>> + { 0x7500c9d2, 0x9203, 0x4a37, { 0x84, 0xbb, 0x92, 0xa9, 0xce, 0x34, 0x38, 0xbd } }
>> +
>> +extern EFI_GUID gNinetySixBoardsFormsetGuid;
>> +
>> +#endif // __NINETY_SIX_BOARDS_FORMSET_H__
>> diff --git a/Platform/NinetySixBoards/NinetySixBoards.dec b/Platform/NinetySixBoards/NinetySixBoards.dec
>> index 5c3fe43dbb24..e7d1705d47ff 100644
>> --- a/Platform/NinetySixBoards/NinetySixBoards.dec
>> +++ b/Platform/NinetySixBoards/NinetySixBoards.dec
>> @@ -37,6 +37,9 @@ [Guids]
>> gNinetySixBoardsI2c1MasterGuid = { 0xcf64ac46, 0xd0be, 0x4a69, { 0x90, 0xa2, 0xf2, 0x82, 0x5b, 0x92, 0x25, 0x61 } }
>> gNinetySixBoardsSpiMasterGuid = { 0x9703fd99, 0xe638, 0x42b8, { 0xab, 0x81, 0x52, 0x61, 0x1b, 0xf7, 0xf7, 0x5d } }
>>
>> + # GUID for the HII configuration form
>> + gNinetySixBoardsFormsetGuid = { 0x7500c9d2, 0x9203, 0x4a37, { 0x84, 0xbb, 0x92, 0xa9, 0xce, 0x34, 0x38, 0xbd } }
>> +
>> [PcdsFixedAtBuild]
>> # ASCII DT paths to the I2C parent nodes of the 96boards LS connector
>> gNinetySixBoardsTokenSpaceGuid.PcdI2c0Parent|""|VOID*|0x00000001
...
>> diff --git a/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.h b/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.h
>> new file mode 100644
>> index 000000000000..e94a115a5929
>> --- /dev/null
>> +++ b/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.h
>> @@ -0,0 +1,32 @@
>> +/** @file
>> +
>> + Copyright (c) 2018, Linaro Limited. All rights reserved.
>> +
>> + 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 __NINETY_SIX_BOARDS_DXE_H__
>> +#define __NINETY_SIX_BOARDS_DXE_H__
>> +
>> +#include <Guid/HiiPlatformSetupFormset.h>
>> +#include <Guid/FormSet.h>
>> +
>> +#define MEZZANINE_NONE 0x0
>> +#define MEZZANINE_SECURE96 0x1
>> +#define MEZZANINE_MAX 0x1
>
> Would this be simpler as an enum with a permanent final element called
> MaxMezzanineType? This seems like the common EDK2 (and even UEFI)
> pattern.
>
Does C guarantee a certain size for enums? Because the struct below is
projected onto the EFI variable directly.
>> +
>> +#define NINETY_SIX_BOARDS_CONFIG_VARIABLE_NAME L"NinetySixBoardsConfig"
>> +
>> +typedef struct {
>> + UINT8 MezzanineType;
>> + UINT8 Reserved[7];
>> +} NINETY_SIX_BOARDS_CONFIG_DATA;
>> +
>> +#endif // __NINETY_SIX_BOARDS_DXE_H__
>> diff --git a/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.inf b/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.inf
>> new file mode 100644
>> index 000000000000..5c6f863e8db4
>> --- /dev/null
>> +++ b/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.inf
>> @@ -0,0 +1,57 @@
>> +## @file
>> +#
>> +# 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.
>> +#
>> +##
>> +
>> +[Defines]
>> + INF_VERSION = 0x0001001A
>> + BASE_NAME = NinetySixBoardsDxe
>> + FILE_GUID = 3f68e889-cb77-4efc-bc84-afa0a64ad26e
>> + MODULE_TYPE = DXE_DRIVER
>> + VERSION_STRING = 1.0
>> + ENTRY_POINT = EntryPoint
>> +
>> +[Sources]
>> + NinetySixBoardsDxe.c
>> + NinetySixBoardsDxe.h
>> + NinetySixBoardsHii.vfr
>> + NinetySixBoardsHii.uni
>> +
>> +[Packages]
>> + EmbeddedPkg/EmbeddedPkg.dec
>> + MdePkg/MdePkg.dec
>> + MdeModulePkg/MdeModulePkg.dec
>> + Platform/NinetySixBoards/NinetySixBoards.dec
>> +
>> +[LibraryClasses]
>> + BaseLib
>> + BaseMemoryLib
>> + DebugLib
>> + HiiLib
>> + UefiBootServicesTableLib
>> + UefiDriverEntryPoint
>> + UefiLib
>> + UefiRuntimeServicesTableLib
>> +
>> +[Protocols]
>> + gNinetySixBoardsLsConnectorProtocolGuid ## PRODUCES
>> + gNinetySixBoardsMezzanineProtocolGuid ## CONSUMES
>> +
>> +[Guids]
>> + gEfiEndOfDxeEventGroupGuid
>> + gFdtTableGuid
>> + gNinetySixBoardsFormsetGuid
>> +
>> +[Depex]
>> + gEfiVariableArchProtocolGuid AND
>> + gEfiVariableWriteArchProtocolGuid
>> diff --git a/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsHii.uni b/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsHii.uni
>> new file mode 100644
>> index 000000000000..23f4c5859207
>> --- /dev/null
>> +++ b/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsHii.uni
>> @@ -0,0 +1,27 @@
>> +/** @file
>> +
>> + Copyright (c) 2018, Linaro, Ltd. All rights reserved.
>> +
>> + 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.
>> +
>> +**/
>> +
>> +#langdef en-US "English"
>> +
>> +#string STR_FORM_SET_TITLE #language en-US "96boards Mezzanine options"
>> +#string STR_FORM_SET_TITLE_HELP #language en-US "Configure the installed 96boards mezzanine"
>> +
>> +#string STR_MAIN_FORM_TITLE #language en-US "96boards Mezzanine options"
>> +#string STR_NULL_STRING #language en-US ""
>> +
>> +#string STR_MEZZANINE_SELECT_PROMPT #language en-US "96boards mezzanine"
>> +#string STR_MEZZANINE_SELECT_HELP #language en-US "The type of mezzanine board plugged into the 96boards LS connector"
>> +
>> +#string STR_MEZZANINE_NONE #language en-US "None/Unknown"
>> +#string STR_MEZZANINE_SECURE96 #language en-US "Secure96"
>> diff --git a/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsHii.vfr b/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsHii.vfr
>> new file mode 100644
>> index 000000000000..7e78c9cfa22f
>> --- /dev/null
>> +++ b/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsHii.vfr
>> @@ -0,0 +1,51 @@
>> +/** @file
>> +
>> + Copyright (c) 2018, Linaro, Ltd. All rights reserved.
>> +
>> + 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.
>> +
>> +**/
>> +
>> +#include "NinetySixBoardsDxe.h"
>> +
>> +//
>> +// EFI Variable attributes
>> +//
>> +#define EFI_VARIABLE_NON_VOLATILE 0x00000001
>> +#define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002
>> +#define EFI_VARIABLE_RUNTIME_ACCESS 0x00000004
>> +#define EFI_VARIABLE_READ_ONLY 0x00000008
>
> Hmm, that jogged my memory - I need to follow up on
> https://www.mail-archive.com/edk2-devel@lists.01.org/msg34156.html
>
> ... and I would appreciate an R-b on
> https://www.mail-archive.com/edk2-devel@lists.01.org/msg34154.html
>
> :)
>
> I would prefer if we could get this one in with a
> #include <Uefi/UefiMultiPhase.h>
> instead.
>
OK, but please chase this with the other maintainers then.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH edk2-platforms v2 6/7] Platform/NinetySixBoards: add core driver for LS connector and config
2018-02-22 19:00 ` Ard Biesheuvel
@ 2018-02-22 19:10 ` Ard Biesheuvel
2018-02-22 20:21 ` Leif Lindholm
0 siblings, 1 reply; 21+ messages in thread
From: Ard Biesheuvel @ 2018-02-22 19:10 UTC (permalink / raw)
To: Leif Lindholm; +Cc: edk2-devel@lists.01.org
On 22 February 2018 at 19:00, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
> On 22 February 2018 at 15:59, Leif Lindholm <leif.lindholm@linaro.org> wrote:
>> On Tue, Feb 20, 2018 at 05:49:43PM +0000, Ard Biesheuvel wrote:
>>> This adds a driver that manages the 96boards LS connector, i.e, it
>>> installs a HII page to configure the type of mezzanine that is installed
>>> in the slot, and it exposes this information via the LS connector protocol.
>>> It is also in charge of applying the overlay to the platform device tree
>>> at end of DXE.
>>>
>>> Contributed-under: TianoCore Contribution Agreement 1.1
>>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>>> ---
>>> Platform/NinetySixBoards/Include/Guid/FormSet.h | 23 ++
>>> Platform/NinetySixBoards/NinetySixBoards.dec | 3 +
>>> Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.c | 221 ++++++++++++++++++++
>>> Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.h | 32 +++
>>> Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.inf | 57 +++++
>>> Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsHii.uni | 27 +++
>>> Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsHii.vfr | 51 +++++
>>> 7 files changed, 414 insertions(+)
>>>
>>> diff --git a/Platform/NinetySixBoards/Include/Guid/FormSet.h b/Platform/NinetySixBoards/Include/Guid/FormSet.h
>>> new file mode 100644
>>> index 000000000000..db16657f0848
>>> --- /dev/null
>>> +++ b/Platform/NinetySixBoards/Include/Guid/FormSet.h
>>> @@ -0,0 +1,23 @@
>>> +/** @file
>>> +
>>> + Copyright (c) 2018, Linaro Limited. All rights reserved.
>>> +
>>> + 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 __NINETY_SIX_BOARDS_FORMSET_H__
>>> +#define __NINETY_SIX_BOARDS_FORMSET_H__
>>> +
>>> +#define NINETY_SIX_BOARDS_FORMSET_GUID \
>>> + { 0x7500c9d2, 0x9203, 0x4a37, { 0x84, 0xbb, 0x92, 0xa9, 0xce, 0x34, 0x38, 0xbd } }
>>> +
>>> +extern EFI_GUID gNinetySixBoardsFormsetGuid;
>>> +
>>> +#endif // __NINETY_SIX_BOARDS_FORMSET_H__
>>> diff --git a/Platform/NinetySixBoards/NinetySixBoards.dec b/Platform/NinetySixBoards/NinetySixBoards.dec
>>> index 5c3fe43dbb24..e7d1705d47ff 100644
>>> --- a/Platform/NinetySixBoards/NinetySixBoards.dec
>>> +++ b/Platform/NinetySixBoards/NinetySixBoards.dec
>>> @@ -37,6 +37,9 @@ [Guids]
>>> gNinetySixBoardsI2c1MasterGuid = { 0xcf64ac46, 0xd0be, 0x4a69, { 0x90, 0xa2, 0xf2, 0x82, 0x5b, 0x92, 0x25, 0x61 } }
>>> gNinetySixBoardsSpiMasterGuid = { 0x9703fd99, 0xe638, 0x42b8, { 0xab, 0x81, 0x52, 0x61, 0x1b, 0xf7, 0xf7, 0x5d } }
>>>
>>> + # GUID for the HII configuration form
>>> + gNinetySixBoardsFormsetGuid = { 0x7500c9d2, 0x9203, 0x4a37, { 0x84, 0xbb, 0x92, 0xa9, 0xce, 0x34, 0x38, 0xbd } }
>>> +
>>> [PcdsFixedAtBuild]
>>> # ASCII DT paths to the I2C parent nodes of the 96boards LS connector
>>> gNinetySixBoardsTokenSpaceGuid.PcdI2c0Parent|""|VOID*|0x00000001
> ...
>>> diff --git a/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.h b/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.h
>>> new file mode 100644
>>> index 000000000000..e94a115a5929
>>> --- /dev/null
>>> +++ b/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.h
>>> @@ -0,0 +1,32 @@
>>> +/** @file
>>> +
>>> + Copyright (c) 2018, Linaro Limited. All rights reserved.
>>> +
>>> + 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 __NINETY_SIX_BOARDS_DXE_H__
>>> +#define __NINETY_SIX_BOARDS_DXE_H__
>>> +
>>> +#include <Guid/HiiPlatformSetupFormset.h>
>>> +#include <Guid/FormSet.h>
>>> +
>>> +#define MEZZANINE_NONE 0x0
>>> +#define MEZZANINE_SECURE96 0x1
>>> +#define MEZZANINE_MAX 0x1
>>
>> Would this be simpler as an enum with a permanent final element called
>> MaxMezzanineType? This seems like the common EDK2 (and even UEFI)
>> pattern.
>>
>
> Does C guarantee a certain size for enums? Because the struct below is
> projected onto the EFI variable directly.
>
OK, so apparently an enum is an int, unless you explicitly tell the
compiler otherwise.
That does mean the type field uses up 32 bits rather than 8, so I'd
prefer to keep a UINT8 here instead.
I could still use 0x2 rather than 0x1 as the max value if you prefer.
>>> +
>>> +#define NINETY_SIX_BOARDS_CONFIG_VARIABLE_NAME L"NinetySixBoardsConfig"
>>> +
>>> +typedef struct {
>>> + UINT8 MezzanineType;
>>> + UINT8 Reserved[7];
>>> +} NINETY_SIX_BOARDS_CONFIG_DATA;
>>> +
>>> +#endif // __NINETY_SIX_BOARDS_DXE_H__
>>> diff --git a/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.inf b/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.inf
>>> new file mode 100644
>>> index 000000000000..5c6f863e8db4
>>> --- /dev/null
>>> +++ b/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsDxe.inf
>>> @@ -0,0 +1,57 @@
>>> +## @file
>>> +#
>>> +# 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.
>>> +#
>>> +##
>>> +
>>> +[Defines]
>>> + INF_VERSION = 0x0001001A
>>> + BASE_NAME = NinetySixBoardsDxe
>>> + FILE_GUID = 3f68e889-cb77-4efc-bc84-afa0a64ad26e
>>> + MODULE_TYPE = DXE_DRIVER
>>> + VERSION_STRING = 1.0
>>> + ENTRY_POINT = EntryPoint
>>> +
>>> +[Sources]
>>> + NinetySixBoardsDxe.c
>>> + NinetySixBoardsDxe.h
>>> + NinetySixBoardsHii.vfr
>>> + NinetySixBoardsHii.uni
>>> +
>>> +[Packages]
>>> + EmbeddedPkg/EmbeddedPkg.dec
>>> + MdePkg/MdePkg.dec
>>> + MdeModulePkg/MdeModulePkg.dec
>>> + Platform/NinetySixBoards/NinetySixBoards.dec
>>> +
>>> +[LibraryClasses]
>>> + BaseLib
>>> + BaseMemoryLib
>>> + DebugLib
>>> + HiiLib
>>> + UefiBootServicesTableLib
>>> + UefiDriverEntryPoint
>>> + UefiLib
>>> + UefiRuntimeServicesTableLib
>>> +
>>> +[Protocols]
>>> + gNinetySixBoardsLsConnectorProtocolGuid ## PRODUCES
>>> + gNinetySixBoardsMezzanineProtocolGuid ## CONSUMES
>>> +
>>> +[Guids]
>>> + gEfiEndOfDxeEventGroupGuid
>>> + gFdtTableGuid
>>> + gNinetySixBoardsFormsetGuid
>>> +
>>> +[Depex]
>>> + gEfiVariableArchProtocolGuid AND
>>> + gEfiVariableWriteArchProtocolGuid
>>> diff --git a/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsHii.uni b/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsHii.uni
>>> new file mode 100644
>>> index 000000000000..23f4c5859207
>>> --- /dev/null
>>> +++ b/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsHii.uni
>>> @@ -0,0 +1,27 @@
>>> +/** @file
>>> +
>>> + Copyright (c) 2018, Linaro, Ltd. All rights reserved.
>>> +
>>> + 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.
>>> +
>>> +**/
>>> +
>>> +#langdef en-US "English"
>>> +
>>> +#string STR_FORM_SET_TITLE #language en-US "96boards Mezzanine options"
>>> +#string STR_FORM_SET_TITLE_HELP #language en-US "Configure the installed 96boards mezzanine"
>>> +
>>> +#string STR_MAIN_FORM_TITLE #language en-US "96boards Mezzanine options"
>>> +#string STR_NULL_STRING #language en-US ""
>>> +
>>> +#string STR_MEZZANINE_SELECT_PROMPT #language en-US "96boards mezzanine"
>>> +#string STR_MEZZANINE_SELECT_HELP #language en-US "The type of mezzanine board plugged into the 96boards LS connector"
>>> +
>>> +#string STR_MEZZANINE_NONE #language en-US "None/Unknown"
>>> +#string STR_MEZZANINE_SECURE96 #language en-US "Secure96"
>>> diff --git a/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsHii.vfr b/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsHii.vfr
>>> new file mode 100644
>>> index 000000000000..7e78c9cfa22f
>>> --- /dev/null
>>> +++ b/Platform/NinetySixBoards/NinetySixBoardsDxe/NinetySixBoardsHii.vfr
>>> @@ -0,0 +1,51 @@
>>> +/** @file
>>> +
>>> + Copyright (c) 2018, Linaro, Ltd. All rights reserved.
>>> +
>>> + 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.
>>> +
>>> +**/
>>> +
>>> +#include "NinetySixBoardsDxe.h"
>>> +
>>> +//
>>> +// EFI Variable attributes
>>> +//
>>> +#define EFI_VARIABLE_NON_VOLATILE 0x00000001
>>> +#define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002
>>> +#define EFI_VARIABLE_RUNTIME_ACCESS 0x00000004
>>> +#define EFI_VARIABLE_READ_ONLY 0x00000008
>>
>> Hmm, that jogged my memory - I need to follow up on
>> https://www.mail-archive.com/edk2-devel@lists.01.org/msg34156.html
>>
>> ... and I would appreciate an R-b on
>> https://www.mail-archive.com/edk2-devel@lists.01.org/msg34154.html
>>
>> :)
>>
>> I would prefer if we could get this one in with a
>> #include <Uefi/UefiMultiPhase.h>
>> instead.
>>
>
> OK, but please chase this with the other maintainers then.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH edk2-platforms v2 6/7] Platform/NinetySixBoards: add core driver for LS connector and config
2018-02-22 19:10 ` Ard Biesheuvel
@ 2018-02-22 20:21 ` Leif Lindholm
0 siblings, 0 replies; 21+ messages in thread
From: Leif Lindholm @ 2018-02-22 20:21 UTC (permalink / raw)
To: Ard Biesheuvel; +Cc: edk2-devel@lists.01.org
On Thu, Feb 22, 2018 at 07:10:52PM +0000, Ard Biesheuvel wrote:
> >>> +#define MEZZANINE_NONE 0x0
> >>> +#define MEZZANINE_SECURE96 0x1
> >>> +#define MEZZANINE_MAX 0x1
> >>
> >> Would this be simpler as an enum with a permanent final element called
> >> MaxMezzanineType? This seems like the common EDK2 (and even UEFI)
> >> pattern.
> >>
> >
> > Does C guarantee a certain size for enums? Because the struct below is
> > projected onto the EFI variable directly.
>
> OK, so apparently an enum is an int, unless you explicitly tell the
> compiler otherwise.
Not exactly.
Enums are compile-time resolved, so it is entirely within the
compiler's ability to handle this situation safely.
Try the following for yourself:
#include <stdio.h>
typedef enum {
TestFirst = 255,
TestMax
} MYTEST;
typedef struct {
unsigned char test;
} Foo;
int main(void)
{
Foo bar;
bar.test = TestFirst;
bar.test = TestMax;
printf("bar.test: %d\n", bar.test);
}
I'd be astonished if you can find a compiler that won't give you
something similar to:
warning: large integer implicitly truncated to unsigned type [-Woverflow]
bar.test = TestMax;
> That does mean the type field uses up 32 bits rather than 8, so I'd
> prefer to keep a UINT8 here instead.
Does the above change your opinion in any way?...
> I could still use 0x2 rather than 0x1 as the max value if you prefer.
...if not, that would be preferable, yes.
> >> I would prefer if we could get this one in with a
> >> #include <Uefi/UefiMultiPhase.h>
> >> instead.
> >>
> >
> > OK, but please chase this with the other maintainers then.
Done.
/
Leif
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH edk2-platforms v2 1/7] Silicon/Atmel: add support for AtSha204a RNG
2018-02-22 13:08 ` Leif Lindholm
@ 2018-02-23 15:33 ` Ard Biesheuvel
0 siblings, 0 replies; 21+ messages in thread
From: Ard Biesheuvel @ 2018-02-23 15:33 UTC (permalink / raw)
To: Leif Lindholm; +Cc: edk2-devel@lists.01.org
On 22 February 2018 at 13:08, Leif Lindholm <leif.lindholm@linaro.org> wrote:
> On Tue, Feb 20, 2018 at 05:49:38PM +0000, Ard Biesheuvel wrote:
>> This adds support for using the random number generator in the Atmel
>> AtSha204a over I2C. Other functionality of the chip is currently
>> unsupported.
>>
>> Note that the the I2C support in this device essentially violates the
>> protocol layering, by requiring that the device is woken up by driving
>> SDA low for a certain amount of time, which is something that cannot be
>> expressed in terms of an I2C packet sent to the device's slave address.
>> Instead, the slave address 0x0 is added to the device's address array,
>> and the wake is sent by sending a dummy write to address 0x0, and
>> ignoring the subsequent error. This requires the I2C bus to be clocked
>> at 100 kHz.
>>
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>
> All of my feedback from v1 has been addressed, so:
> Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
Thanks.
Pushed as 487015fb23c1a40f0d05240cadde4faf979483ee
^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2018-02-23 15:27 UTC | newest]
Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-20 17:49 [PATCH edk2-platforms v2 0/7] Add Secure96 mezzanine support Ard Biesheuvel
2018-02-20 17:49 ` [PATCH edk2-platforms v2 1/7] Silicon/Atmel: add support for AtSha204a RNG Ard Biesheuvel
2018-02-22 13:08 ` Leif Lindholm
2018-02-23 15:33 ` Ard Biesheuvel
2018-02-20 17:49 ` [PATCH edk2-platforms v2 2/7] Platform/NinetySixBoards: introduce package and mezzanine protocol Ard Biesheuvel
2018-02-22 13:15 ` Leif Lindholm
2018-02-22 13:21 ` Ard Biesheuvel
2018-02-22 13:44 ` Leif Lindholm
2018-02-22 15:13 ` Ard Biesheuvel
2018-02-20 17:49 ` [PATCH edk2-platforms v2 3/7] Platform/NinetySixBoards: introduce I2C driver Ard Biesheuvel
2018-02-20 17:49 ` [PATCH edk2-platforms v2 4/7] Platform/NinetySixBoards: introduce LsConnector protocol Ard Biesheuvel
2018-02-22 15:29 ` Leif Lindholm
2018-02-20 17:49 ` [PATCH edk2-platforms v2 5/7] Platform/NinetySixBoards: add a driver for the Secure96 mezzanine board Ard Biesheuvel
2018-02-22 15:38 ` Leif Lindholm
2018-02-20 17:49 ` [PATCH edk2-platforms v2 6/7] Platform/NinetySixBoards: add core driver for LS connector and config Ard Biesheuvel
2018-02-22 15:59 ` Leif Lindholm
2018-02-22 19:00 ` Ard Biesheuvel
2018-02-22 19:10 ` Ard Biesheuvel
2018-02-22 20:21 ` Leif Lindholm
2018-02-20 17:49 ` [PATCH edk2-platforms v2 7/7] Platform/Socionext/DeveloperBox: add 96boards mezzanine support Ard Biesheuvel
2018-02-22 16:04 ` [PATCH edk2-platforms v2 0/7] Add Secure96 " Leif Lindholm
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox