public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH edk2-platforms v3 0/6] Add Secure96 mezzanine support
@ 2018-02-23 15:40 Ard Biesheuvel
  2018-02-23 15:40 ` [PATCH edk2-platforms v3 1/6] Platform/96Boards: introduce package and mezzanine protocol Ard Biesheuvel
                   ` (6 more replies)
  0 siblings, 7 replies; 9+ messages in thread
From: Ard Biesheuvel @ 2018-02-23 15:40 UTC (permalink / raw)
  To: edk2-devel; +Cc: leif.lindholm, Ard Biesheuvel

This v3 (as did v2) 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.

v3:
- The ATSHA204A driver has been merged, so it has been dropped from this
  series.
- Rename Platform/NinetySixBoards back to Platform/96Boards. Note that in
  some places, using leading digits is problematic so the string does still
  occur in a couple of places.
- Rebase onto EDK2 that has the MultiPhase.h VFR changes.

Patch #1 introduces the mezzanine protocol, which abstracts away from
any particular mezzanine implementation.

Patch #2 introduces the generic I2C plumbing for any mezzanine that exposes
I2C peripherals.

Patch #3 implements the protocol that asserts the presence of a 96boards LS
connector and the type of mezzanine connected to it.

Patch #4 adds the Secure96 driver, which incorporates the DT overlay, and
a description of the I2C peripheral.

Patch #5 adds a LS connector driver for configuring the type of mezzanine,
and to interface with it at end of DXE time to install the appropriate DT
overlay.

Patch #6 wires everything up for the DeveloperBox platform.

Ard Biesheuvel (6):
  Platform/96Boards: introduce package and mezzanine protocol
  Platform/96Boards: introduce I2C driver
  Platform/96Boards: introduce LsConnector protocol
  Platform/96Boards: add a driver for the Secure96 mezzanine board
  Platform/96Boards: add driver for low speed (LS) connector
  Platform/Socionext/DeveloperBox: add 96Boards mezzanine support

 Platform/96Boards/96Boards.dec                                  |  73 +++++++
 Platform/96Boards/96BoardsI2cDxe/96BoardsI2cDxe.c               | 206 ++++++++++++++++++
 Platform/96Boards/96BoardsI2cDxe/96BoardsI2cDxe.inf             |  51 +++++
 Platform/96Boards/Include/Guid/FormSet.h                        |  23 ++
 Platform/96Boards/Include/Protocol/LsConnector.h                |  35 ++++
 Platform/96Boards/Include/Protocol/Mezzanine.h                  |  71 +++++++
 Platform/96Boards/LsConnectorDxe/LsConnectorDxe.c               | 221 ++++++++++++++++++++
 Platform/96Boards/LsConnectorDxe/LsConnectorDxe.h               |  32 +++
 Platform/96Boards/LsConnectorDxe/LsConnectorDxe.inf             |  57 +++++
 Platform/96Boards/LsConnectorDxe/LsConnectorHii.uni             |  27 +++
 Platform/96Boards/LsConnectorDxe/LsConnectorHii.vfr             |  45 ++++
 Platform/96Boards/Secure96Dxe/Secure96.dts                      |  85 ++++++++
 Platform/96Boards/Secure96Dxe/Secure96.h                        |  26 +++
 Platform/96Boards/Secure96Dxe/Secure96Dxe.c                     | 211 +++++++++++++++++++
 Platform/96Boards/Secure96Dxe/Secure96Dxe.inf                   |  67 ++++++
 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 +
 19 files changed, 1285 insertions(+)
 create mode 100644 Platform/96Boards/96Boards.dec
 create mode 100644 Platform/96Boards/96BoardsI2cDxe/96BoardsI2cDxe.c
 create mode 100644 Platform/96Boards/96BoardsI2cDxe/96BoardsI2cDxe.inf
 create mode 100644 Platform/96Boards/Include/Guid/FormSet.h
 create mode 100644 Platform/96Boards/Include/Protocol/LsConnector.h
 create mode 100644 Platform/96Boards/Include/Protocol/Mezzanine.h
 create mode 100644 Platform/96Boards/LsConnectorDxe/LsConnectorDxe.c
 create mode 100644 Platform/96Boards/LsConnectorDxe/LsConnectorDxe.h
 create mode 100644 Platform/96Boards/LsConnectorDxe/LsConnectorDxe.inf
 create mode 100644 Platform/96Boards/LsConnectorDxe/LsConnectorHii.uni
 create mode 100644 Platform/96Boards/LsConnectorDxe/LsConnectorHii.vfr
 create mode 100644 Platform/96Boards/Secure96Dxe/Secure96.dts
 create mode 100644 Platform/96Boards/Secure96Dxe/Secure96.h
 create mode 100644 Platform/96Boards/Secure96Dxe/Secure96Dxe.c
 create mode 100644 Platform/96Boards/Secure96Dxe/Secure96Dxe.inf

-- 
2.11.0



^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH edk2-platforms v3 1/6] Platform/96Boards: introduce package and mezzanine protocol
  2018-02-23 15:40 [PATCH edk2-platforms v3 0/6] Add Secure96 mezzanine support Ard Biesheuvel
@ 2018-02-23 15:40 ` Ard Biesheuvel
  2018-02-23 15:40 ` [PATCH edk2-platforms v3 2/6] Platform/96Boards: introduce I2C driver Ard Biesheuvel
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Ard Biesheuvel @ 2018-02-23 15:40 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/96Boards/96Boards.dec                 | 67 ++++++++++++++++++
 Platform/96Boards/Include/Protocol/Mezzanine.h | 71 ++++++++++++++++++++
 2 files changed, 138 insertions(+)

diff --git a/Platform/96Boards/96Boards.dec b/Platform/96Boards/96Boards.dec
new file mode 100644
index 000000000000..2a063ced9e4a
--- /dev/null
+++ b/Platform/96Boards/96Boards.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                   = 96Boards
+  PACKAGE_GUID                   = ce4a4683-6e2d-4ec3-bc11-974289a09ab0
+  PACKAGE_VERSION                = 0.1
+
+[Includes]
+  Include
+
+[Protocols]
+  ## Include/Protocol/Mezzanine.h
+  g96BoardsMezzanineProtocolGuid = { 0xf0467a37, 0x3436, 0x40ef, { 0x94, 0x09, 0x4d, 0x1d, 0x7f, 0x51, 0x06, 0xd3 } }
+
+[Guids]
+  # PCD scope GUID
+  g96BoardsTokenSpaceGuid = { 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
+  g96BoardsI2c0MasterGuid = { 0xba10e402, 0xcfdd, 0x4b87, { 0xbd, 0x02, 0x6e, 0x26, 0x9f, 0x01, 0x94, 0x11 } }
+  g96BoardsI2c1MasterGuid = { 0xcf64ac46, 0xd0be, 0x4a69, { 0x90, 0xa2, 0xf2, 0x82, 0x5b, 0x92, 0x25, 0x61 } }
+  g96BoardsSpiMasterGuid = { 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
+  g96BoardsTokenSpaceGuid.PcdI2c0Parent|""|VOID*|0x00000001
+  g96BoardsTokenSpaceGuid.PcdI2c1Parent|""|VOID*|0x00000002
+
+  # I2C bus frequency in Hertz
+  g96BoardsTokenSpaceGuid.PcdI2c0BusFrequencyHz|0|UINT32|0x00000003
+  g96BoardsTokenSpaceGuid.PcdI2c1BusFrequencyHz|0|UINT32|0x00000004
+
+  # ASCII DT path to the SPI parent node of the 96boards LS connector
+  g96BoardsTokenSpaceGuid.PcdSpiParent|""|VOID*|0x00000005
+
+  # ASCII DT path to the GPIO parent node of the 96boards LS connector
+  g96BoardsTokenSpaceGuid.PcdGpioParent|""|VOID*|0x00000006
+
+  # Polarity of the 96boards LS connector GPIOs (0 == GPIO_ACTIVE_HIGH, 1 == GPIO_ACTIVE_LOW)
+  g96BoardsTokenSpaceGuid.PcdGpioPolarity|0|UINT32|0x00000007
+
+  # Pin numbers of the 96boards LS connector GPIOs
+  g96BoardsTokenSpaceGuid.PcdGpioPinA|0|UINT32|0x00000010
+  g96BoardsTokenSpaceGuid.PcdGpioPinB|0|UINT32|0x00000011
+  g96BoardsTokenSpaceGuid.PcdGpioPinC|0|UINT32|0x00000012
+  g96BoardsTokenSpaceGuid.PcdGpioPinD|0|UINT32|0x00000013
+  g96BoardsTokenSpaceGuid.PcdGpioPinE|0|UINT32|0x00000014
+  g96BoardsTokenSpaceGuid.PcdGpioPinF|0|UINT32|0x00000015
+  g96BoardsTokenSpaceGuid.PcdGpioPinG|0|UINT32|0x00000016
+  g96BoardsTokenSpaceGuid.PcdGpioPinH|0|UINT32|0x00000017
+  g96BoardsTokenSpaceGuid.PcdGpioPinI|0|UINT32|0x00000018
+  g96BoardsTokenSpaceGuid.PcdGpioPinJ|0|UINT32|0x00000019
+  g96BoardsTokenSpaceGuid.PcdGpioPinK|0|UINT32|0x0000001A
+  g96BoardsTokenSpaceGuid.PcdGpioPinL|0|UINT32|0x0000001B
diff --git a/Platform/96Boards/Include/Protocol/Mezzanine.h b/Platform/96Boards/Include/Protocol/Mezzanine.h
new file mode 100644
index 000000000000..9847649d2ac3
--- /dev/null
+++ b/Platform/96Boards/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 _96BOARDS_MEZZANINE_H_
+#define _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 g96BoardsMezzanineProtocolGuid;
+
+#endif // _96BOARDS_MEZZANINE_H_
-- 
2.11.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH edk2-platforms v3 2/6] Platform/96Boards: introduce I2C driver
  2018-02-23 15:40 [PATCH edk2-platforms v3 0/6] Add Secure96 mezzanine support Ard Biesheuvel
  2018-02-23 15:40 ` [PATCH edk2-platforms v3 1/6] Platform/96Boards: introduce package and mezzanine protocol Ard Biesheuvel
@ 2018-02-23 15:40 ` Ard Biesheuvel
  2018-02-23 15:40 ` [PATCH edk2-platforms v3 3/6] Platform/96Boards: introduce LsConnector protocol Ard Biesheuvel
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Ard Biesheuvel @ 2018-02-23 15:40 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/96Boards/96BoardsI2cDxe/96BoardsI2cDxe.c   | 206 ++++++++++++++++++++
 Platform/96Boards/96BoardsI2cDxe/96BoardsI2cDxe.inf |  51 +++++
 2 files changed, 257 insertions(+)

diff --git a/Platform/96Boards/96BoardsI2cDxe/96BoardsI2cDxe.c b/Platform/96Boards/96BoardsI2cDxe/96BoardsI2cDxe.c
new file mode 100644
index 000000000000..79bb9ed5ffee
--- /dev/null
+++ b/Platform/96Boards/96BoardsI2cDxe/96BoardsI2cDxe.c
@@ -0,0 +1,206 @@
+/** @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 (Bus->NumDevices == 0 ||
+      (Bus->NumDevices > 0 && *Device == &Bus->Devices[Bus->NumDevices - 1])) {
+    *Device = NULL;
+  } else if (*Device == NULL) {
+    *Device = &Bus->Devices[0];
+  } else if (Bus->NumDevices > 1 &&
+             *Device >= &Bus->Devices[0] &&
+             *Device < &Bus->Devices[Bus->NumDevices - 1]) {
+    ++*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 (&g96BoardsMezzanineProtocolGuid, NULL,
+                  (VOID **)&mMezzanine);
+  ASSERT_EFI_ERROR (Status);
+
+  RegisterI2cBus (&g96BoardsI2c0MasterGuid, &mI2cBus0,
+    mMezzanine->I2c0NumDevices, mMezzanine->I2c0DeviceArray);
+  RegisterI2cBus (&g96BoardsI2c1MasterGuid, &mI2cBus1,
+    mMezzanine->I2c1NumDevices, mMezzanine->I2c1DeviceArray);
+
+  return EFI_SUCCESS;
+}
diff --git a/Platform/96Boards/96BoardsI2cDxe/96BoardsI2cDxe.inf b/Platform/96Boards/96BoardsI2cDxe/96BoardsI2cDxe.inf
new file mode 100644
index 000000000000..7eb1fc503062
--- /dev/null
+++ b/Platform/96Boards/96BoardsI2cDxe/96BoardsI2cDxe.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                      = 96BoardsI2cDxe
+  FILE_GUID                      = a59176bc-a151-49c8-b54a-b4ac96f436c3
+  MODULE_TYPE                    = DXE_DRIVER
+  VERSION_STRING                 = 0.1
+  ENTRY_POINT                    = EntryPoint
+
+[Sources]
+  96BoardsI2cDxe.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  Platform/96Boards/96Boards.dec
+
+[LibraryClasses]
+  DebugLib
+  UefiBootServicesTableLib
+  UefiDriverEntryPoint
+  UefiLib
+
+[Protocols]
+  g96BoardsMezzanineProtocolGuid           ## CONSUMES
+  gEfiI2cBusConfigurationManagementProtocolGuid   ## PRODUCES
+  gEfiI2cEnumerateProtocolGuid                    ## PRODUCES
+  gEfiI2cMasterProtocolGuid                       ## CONSUMES
+
+[Guids]
+  g96BoardsI2c0MasterGuid
+  g96BoardsI2c1MasterGuid
+
+[FixedPcd]
+  g96BoardsTokenSpaceGuid.PcdI2c0BusFrequencyHz
+  g96BoardsTokenSpaceGuid.PcdI2c1BusFrequencyHz
+
+[Depex]
+  g96BoardsMezzanineProtocolGuid AND g96BoardsI2c0MasterGuid OR g96BoardsI2c1MasterGuid
-- 
2.11.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH edk2-platforms v3 3/6] Platform/96Boards: introduce LsConnector protocol
  2018-02-23 15:40 [PATCH edk2-platforms v3 0/6] Add Secure96 mezzanine support Ard Biesheuvel
  2018-02-23 15:40 ` [PATCH edk2-platforms v3 1/6] Platform/96Boards: introduce package and mezzanine protocol Ard Biesheuvel
  2018-02-23 15:40 ` [PATCH edk2-platforms v3 2/6] Platform/96Boards: introduce I2C driver Ard Biesheuvel
@ 2018-02-23 15:40 ` Ard Biesheuvel
  2018-02-23 15:40 ` [PATCH edk2-platforms v3 4/6] Platform/96Boards: add a driver for the Secure96 mezzanine board Ard Biesheuvel
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Ard Biesheuvel @ 2018-02-23 15:40 UTC (permalink / raw)
  To: edk2-devel; +Cc: leif.lindholm, Ard Biesheuvel

Introduce a protocol describing the presence of a 96boards low speed (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/96Boards/96Boards.dec                   |  3 ++
 Platform/96Boards/Include/Protocol/LsConnector.h | 35 ++++++++++++++++++++
 2 files changed, 38 insertions(+)

diff --git a/Platform/96Boards/96Boards.dec b/Platform/96Boards/96Boards.dec
index 2a063ced9e4a..fa8e639b1a11 100644
--- a/Platform/96Boards/96Boards.dec
+++ b/Platform/96Boards/96Boards.dec
@@ -25,6 +25,9 @@ [Protocols]
   ## Include/Protocol/Mezzanine.h
   g96BoardsMezzanineProtocolGuid = { 0xf0467a37, 0x3436, 0x40ef, { 0x94, 0x09, 0x4d, 0x1d, 0x7f, 0x51, 0x06, 0xd3 } }
 
+  ## Include/Protocol/LsConnector.h
+  g96BoardsLsConnectorProtocolGuid = { 0xae548d4c, 0x9062, 0x4eed, { 0x83, 0x5f, 0xf5, 0x10, 0xf8, 0xfc, 0x48, 0xaf } }
+
 [Guids]
   # PCD scope GUID
   g96BoardsTokenSpaceGuid = { 0xe0d2f33a, 0xb7dd, 0x4a69, { 0xb6, 0x76, 0xda, 0xe8, 0xa4, 0x17, 0xa7, 0xb5 } }
diff --git a/Platform/96Boards/Include/Protocol/LsConnector.h b/Platform/96Boards/Include/Protocol/LsConnector.h
new file mode 100644
index 000000000000..f337cfe0f709
--- /dev/null
+++ b/Platform/96Boards/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 g96BoardsLsConnectorProtocolGuid;
+
+#endif // _LS_CONNECTOR_H_
-- 
2.11.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH edk2-platforms v3 4/6] Platform/96Boards: add a driver for the Secure96 mezzanine board
  2018-02-23 15:40 [PATCH edk2-platforms v3 0/6] Add Secure96 mezzanine support Ard Biesheuvel
                   ` (2 preceding siblings ...)
  2018-02-23 15:40 ` [PATCH edk2-platforms v3 3/6] Platform/96Boards: introduce LsConnector protocol Ard Biesheuvel
@ 2018-02-23 15:40 ` Ard Biesheuvel
  2018-02-23 15:40 ` [PATCH edk2-platforms v3 5/6] Platform/96Boards: add driver for low speed (LS) connector Ard Biesheuvel
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Ard Biesheuvel @ 2018-02-23 15:40 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/96Boards/Secure96Dxe/Secure96.dts    |  85 ++++++++
 Platform/96Boards/Secure96Dxe/Secure96.h      |  26 +++
 Platform/96Boards/Secure96Dxe/Secure96Dxe.c   | 211 ++++++++++++++++++++
 Platform/96Boards/Secure96Dxe/Secure96Dxe.inf |  67 +++++++
 4 files changed, 389 insertions(+)

diff --git a/Platform/96Boards/Secure96Dxe/Secure96.dts b/Platform/96Boards/Secure96Dxe/Secure96.dts
new file mode 100644
index 000000000000..b56ce59985cc
--- /dev/null
+++ b/Platform/96Boards/Secure96Dxe/Secure96.dts
@@ -0,0 +1,85 @@
+/** @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 a placeholder value for the GPIO phandle property cells appearing
+// in this file. It is up to the driver code to discover the actual phandle
+// value from the platform device tree and patch the overlay DTB before it
+// can be applied.
+//
+#define GPIO_PARENT_PLACEHOLDER_PHANDLE     0x0
+
+/dts-v1/;
+/plugin/;
+
+/ {
+    fragment@0 {
+        target-path = "I2C_PARENT_PLACEHOLDER_STRING";
+        __overlay__ {
+            clock-frequency = <100000>;
+
+            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/96Boards/Secure96Dxe/Secure96.h b/Platform/96Boards/Secure96Dxe/Secure96.h
new file mode 100644
index 000000000000..84b8aed13d1e
--- /dev/null
+++ b/Platform/96Boards/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/96Boards/Secure96Dxe/Secure96Dxe.c b/Platform/96Boards/Secure96Dxe/Secure96Dxe.c
new file mode 100644
index 000000000000..6c48d7c0b024
--- /dev/null
+++ b/Platform/96Boards/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 (&g96BoardsLsConnectorProtocolGuid, NULL,
+                  (VOID **)&LsConnector);
+  ASSERT_EFI_ERROR (Status);
+
+  if (LsConnector->MezzanineType != MezzanineSecure96) {
+    return EFI_NOT_FOUND;
+  }
+
+  return gBS->InstallProtocolInterface (&ImageHandle,
+                &g96BoardsMezzanineProtocolGuid,
+                EFI_NATIVE_INTERFACE,
+                &mMezzanine);
+}
diff --git a/Platform/96Boards/Secure96Dxe/Secure96Dxe.inf b/Platform/96Boards/Secure96Dxe/Secure96Dxe.inf
new file mode 100644
index 000000000000..72dbf1314c15
--- /dev/null
+++ b/Platform/96Boards/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/96Boards/96Boards.dec
+  Silicon/Atmel/AtSha204a/AtSha204a.dec
+
+[LibraryClasses]
+  BaseLib
+  DebugLib
+  DxeServicesLib
+  FdtLib
+  UefiBootServicesTableLib
+  UefiDriverEntryPoint
+  UefiLib
+
+[Protocols]
+  g96BoardsLsConnectorProtocolGuid            ## CONSUMES
+  g96BoardsMezzanineProtocolGuid              ## PRODUCES
+
+[Guids]
+  gAtSha204aI2cDeviceGuid
+  gFdtTableGuid
+
+[FixedPcd]
+  g96BoardsTokenSpaceGuid.PcdGpioParent
+  g96BoardsTokenSpaceGuid.PcdGpioPinF
+  g96BoardsTokenSpaceGuid.PcdGpioPinG
+  g96BoardsTokenSpaceGuid.PcdGpioPinH
+  g96BoardsTokenSpaceGuid.PcdGpioPinI
+  g96BoardsTokenSpaceGuid.PcdGpioPolarity
+  g96BoardsTokenSpaceGuid.PcdI2c0Parent
+  g96BoardsTokenSpaceGuid.PcdSpiParent
+
+[Depex]
+  g96BoardsLsConnectorProtocolGuid
+
+[BuildOptions]
+  # dtc emits lots of spurious warnings for overlays
+  *_*_*_DTC_FLAGS = -q
-- 
2.11.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH edk2-platforms v3 5/6] Platform/96Boards: add driver for low speed (LS) connector
  2018-02-23 15:40 [PATCH edk2-platforms v3 0/6] Add Secure96 mezzanine support Ard Biesheuvel
                   ` (3 preceding siblings ...)
  2018-02-23 15:40 ` [PATCH edk2-platforms v3 4/6] Platform/96Boards: add a driver for the Secure96 mezzanine board Ard Biesheuvel
@ 2018-02-23 15:40 ` Ard Biesheuvel
  2018-02-23 15:40 ` [PATCH edk2-platforms v3 6/6] Platform/Socionext/DeveloperBox: add 96Boards mezzanine support Ard Biesheuvel
  2018-02-23 15:56 ` [PATCH edk2-platforms v3 0/6] Add Secure96 " Leif Lindholm
  6 siblings, 0 replies; 9+ messages in thread
From: Ard Biesheuvel @ 2018-02-23 15:40 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/96Boards/96Boards.dec                      |   3 +
 Platform/96Boards/Include/Guid/FormSet.h            |  23 ++
 Platform/96Boards/LsConnectorDxe/LsConnectorDxe.c   | 221 ++++++++++++++++++++
 Platform/96Boards/LsConnectorDxe/LsConnectorDxe.h   |  32 +++
 Platform/96Boards/LsConnectorDxe/LsConnectorDxe.inf |  57 +++++
 Platform/96Boards/LsConnectorDxe/LsConnectorHii.uni |  27 +++
 Platform/96Boards/LsConnectorDxe/LsConnectorHii.vfr |  45 ++++
 7 files changed, 408 insertions(+)

diff --git a/Platform/96Boards/96Boards.dec b/Platform/96Boards/96Boards.dec
index fa8e639b1a11..49641828aa60 100644
--- a/Platform/96Boards/96Boards.dec
+++ b/Platform/96Boards/96Boards.dec
@@ -37,6 +37,9 @@ [Guids]
   g96BoardsI2c1MasterGuid = { 0xcf64ac46, 0xd0be, 0x4a69, { 0x90, 0xa2, 0xf2, 0x82, 0x5b, 0x92, 0x25, 0x61 } }
   g96BoardsSpiMasterGuid = { 0x9703fd99, 0xe638, 0x42b8, { 0xab, 0x81, 0x52, 0x61, 0x1b, 0xf7, 0xf7, 0x5d } }
 
+  # GUID for the HII configuration form
+  g96BoardsFormsetGuid = { 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
   g96BoardsTokenSpaceGuid.PcdI2c0Parent|""|VOID*|0x00000001
diff --git a/Platform/96Boards/Include/Guid/FormSet.h b/Platform/96Boards/Include/Guid/FormSet.h
new file mode 100644
index 000000000000..a0475e641d69
--- /dev/null
+++ b/Platform/96Boards/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 __96BOARDS_FORMSET_H__
+#define __96BOARDS_FORMSET_H__
+
+#define NINETY_SIX_BOARDS_FORMSET_GUID  \
+  { 0x7500c9d2, 0x9203, 0x4a37, { 0x84, 0xbb, 0x92, 0xa9, 0xce, 0x34, 0x38, 0xbd } }
+
+extern EFI_GUID g96BoardsFormsetGuid;
+
+#endif // __96BOARDS_FORMSET_H__
diff --git a/Platform/96Boards/LsConnectorDxe/LsConnectorDxe.c b/Platform/96Boards/LsConnectorDxe/LsConnectorDxe.c
new file mode 100644
index 000000000000..f19d95635056
--- /dev/null
+++ b/Platform/96Boards/LsConnectorDxe/LsConnectorDxe.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 "LsConnectorDxe.h"
+
+extern  UINT8                     LsConnectorHiiBin[];
+extern  UINT8                     LsConnectorDxeStrings[];
+
+typedef struct {
+  VENDOR_DEVICE_PATH              VendorDevicePath;
+  EFI_DEVICE_PATH_PROTOCOL        End;
+} HII_VENDOR_DEVICE_PATH;
+
+STATIC HII_VENDOR_DEVICE_PATH     m96BoardsDxeVendorDevicePath = {
+  {
+    {
+      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,
+                  &m96BoardsDxeVendorDevicePath,
+                  NULL);
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+
+  HiiHandle = HiiAddPackages (&g96BoardsFormsetGuid,
+                              DriverHandle,
+                              LsConnectorDxeStrings,
+                              LsConnectorHiiBin,
+                              NULL);
+
+  if (HiiHandle == NULL) {
+    gBS->UninstallMultipleProtocolInterfaces (DriverHandle,
+           &gEfiDevicePathProtocolGuid,
+           &m96BoardsDxeVendorDevicePath,
+           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 (&g96BoardsMezzanineProtocolGuid, 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 96BoardsDxe 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,
+                  &g96BoardsFormsetGuid, 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,
+                    &g96BoardsFormsetGuid,
+                    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,
+                  &g96BoardsLsConnectorProtocolGuid,
+                  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/96Boards/LsConnectorDxe/LsConnectorDxe.h b/Platform/96Boards/LsConnectorDxe/LsConnectorDxe.h
new file mode 100644
index 000000000000..c2a21c52b7a2
--- /dev/null
+++ b/Platform/96Boards/LsConnectorDxe/LsConnectorDxe.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 __LSCONNECTOR_DXE_H__
+#define __LSCONNECTOR_DXE_H__
+
+#include <Guid/HiiPlatformSetupFormset.h>
+#include <Guid/FormSet.h>
+
+#define MEZZANINE_NONE                            0x0
+#define MEZZANINE_SECURE96                        0x1
+#define MEZZANINE_MAX                             0x2
+
+#define NINETY_SIX_BOARDS_CONFIG_VARIABLE_NAME    L"NinetySixBoardsConfig"
+
+typedef struct {
+  UINT8         MezzanineType;
+  UINT8         Reserved[7];
+} NINETY_SIX_BOARDS_CONFIG_DATA;
+
+#endif // __LSCONNECTOR_DXE_H__
diff --git a/Platform/96Boards/LsConnectorDxe/LsConnectorDxe.inf b/Platform/96Boards/LsConnectorDxe/LsConnectorDxe.inf
new file mode 100644
index 000000000000..1bf528ceaa84
--- /dev/null
+++ b/Platform/96Boards/LsConnectorDxe/LsConnectorDxe.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                 = LsConnectorDxe
+  FILE_GUID                 = 3f68e889-cb77-4efc-bc84-afa0a64ad26e
+  MODULE_TYPE               = DXE_DRIVER
+  VERSION_STRING            = 1.0
+  ENTRY_POINT               = EntryPoint
+
+[Sources]
+  LsConnectorDxe.c
+  LsConnectorDxe.h
+  LsConnectorHii.vfr
+  LsConnectorHii.uni
+
+[Packages]
+  EmbeddedPkg/EmbeddedPkg.dec
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  Platform/96Boards/96Boards.dec
+
+[LibraryClasses]
+  BaseLib
+  BaseMemoryLib
+  DebugLib
+  HiiLib
+  UefiBootServicesTableLib
+  UefiDriverEntryPoint
+  UefiLib
+  UefiRuntimeServicesTableLib
+
+[Protocols]
+  g96BoardsLsConnectorProtocolGuid     ## PRODUCES
+  g96BoardsMezzanineProtocolGuid       ## CONSUMES
+
+[Guids]
+  gEfiEndOfDxeEventGroupGuid
+  gFdtTableGuid
+  g96BoardsFormsetGuid
+
+[Depex]
+  gEfiVariableArchProtocolGuid        AND
+  gEfiVariableWriteArchProtocolGuid
diff --git a/Platform/96Boards/LsConnectorDxe/LsConnectorHii.uni b/Platform/96Boards/LsConnectorDxe/LsConnectorHii.uni
new file mode 100644
index 000000000000..23f4c5859207
--- /dev/null
+++ b/Platform/96Boards/LsConnectorDxe/LsConnectorHii.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/96Boards/LsConnectorDxe/LsConnectorHii.vfr b/Platform/96Boards/LsConnectorDxe/LsConnectorHii.vfr
new file mode 100644
index 000000000000..c4dd69db8e2f
--- /dev/null
+++ b/Platform/96Boards/LsConnectorDxe/LsConnectorHii.vfr
@@ -0,0 +1,45 @@
+/** @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 "LsConnectorDxe.h"
+
+#include <Uefi/UefiMultiPhase.h>
+
+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] 9+ messages in thread

* [PATCH edk2-platforms v3 6/6] Platform/Socionext/DeveloperBox: add 96Boards mezzanine support
  2018-02-23 15:40 [PATCH edk2-platforms v3 0/6] Add Secure96 mezzanine support Ard Biesheuvel
                   ` (4 preceding siblings ...)
  2018-02-23 15:40 ` [PATCH edk2-platforms v3 5/6] Platform/96Boards: add driver for low speed (LS) connector Ard Biesheuvel
@ 2018-02-23 15:40 ` Ard Biesheuvel
  2018-02-23 15:56 ` [PATCH edk2-platforms v3 0/6] Add Secure96 " Leif Lindholm
  6 siblings, 0 replies; 9+ messages in thread
From: Ard Biesheuvel @ 2018-02-23 15:40 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. Note that this includes a [Rule]
update that allows .dtb binaries to be bundled with DXE drivers.

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 3c109b495fbc..afd0a4f59f00 100644
--- a/Platform/Socionext/DeveloperBox/DeveloperBox.dsc
+++ b/Platform/Socionext/DeveloperBox/DeveloperBox.dsc
@@ -31,6 +31,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
 
@@ -396,6 +399,28 @@ [PcdsFixedAtBuild.common]
 !endif
   gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareRevision|$(BUILD_NUMBER)
 
+  #
+  # 96boards mezzanine support
+  #
+  g96BoardsTokenSpaceGuid.PcdI2c0Parent|"/i2c@51210000"
+  g96BoardsTokenSpaceGuid.PcdI2c0BusFrequencyHz|100000
+  g96BoardsTokenSpaceGuid.PcdSpiParent|"/spi@54810000"
+  g96BoardsTokenSpaceGuid.PcdGpioParent|"/gpio@51000000"
+  g96BoardsTokenSpaceGuid.PcdGpioPolarity|0
+
+  g96BoardsTokenSpaceGuid.PcdGpioPinA|10
+  g96BoardsTokenSpaceGuid.PcdGpioPinB|11
+  g96BoardsTokenSpaceGuid.PcdGpioPinC|12
+  g96BoardsTokenSpaceGuid.PcdGpioPinD|13
+  g96BoardsTokenSpaceGuid.PcdGpioPinE|18
+  g96BoardsTokenSpaceGuid.PcdGpioPinF|19
+  g96BoardsTokenSpaceGuid.PcdGpioPinG|20
+  g96BoardsTokenSpaceGuid.PcdGpioPinH|21
+  g96BoardsTokenSpaceGuid.PcdGpioPinI|22
+  g96BoardsTokenSpaceGuid.PcdGpioPinJ|23
+  g96BoardsTokenSpaceGuid.PcdGpioPinK|24
+  g96BoardsTokenSpaceGuid.PcdGpioPinL|25
+
 [PcdsPatchableInModule]
   gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution|0
   gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution|0
@@ -642,6 +667,15 @@ [Components.common]
   SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.inf
 
   #
+  # 96board mezzanine support
+  #
+  Platform/96Boards/Secure96Dxe/Secure96Dxe.inf
+  Silicon/Atmel/AtSha204a/AtSha204aDxe.inf
+  Platform/96Boards/96BoardsI2cDxe/96BoardsI2cDxe.inf
+  Platform/96Boards/LsConnectorDxe/LsConnectorDxe.inf
+
+  #
   # I2C
   #
   Silicon/Socionext/SynQuacer/Drivers/SynQuacerI2cDxe/SynQuacerI2cDxe.inf
+  MdeModulePkg/Bus/I2c/I2cDxe/I2cDxe.inf
diff --git a/Platform/Socionext/DeveloperBox/DeveloperBox.fdf b/Platform/Socionext/DeveloperBox/DeveloperBox.fdf
index b668f42c7962..130572009fd0 100644
--- a/Platform/Socionext/DeveloperBox/DeveloperBox.fdf
+++ b/Platform/Socionext/DeveloperBox/DeveloperBox.fdf
@@ -237,9 +237,18 @@ [FV.FvMain]
   }
 
   #
+  # 96board mezzanine support
+  #
+  INF Platform/96Boards/Secure96Dxe/Secure96Dxe.inf
+  INF Platform/96Boards/96BoardsI2cDxe/96BoardsI2cDxe.inf
+  INF Silicon/Atmel/AtSha204a/AtSha204aDxe.inf
+  INF Platform/96Boards/LsConnectorDxe/LsConnectorDxe.inf
+
+  #
   # I2C
   #
   INF Silicon/Socionext/SynQuacer/Drivers/SynQuacerI2cDxe/SynQuacerI2cDxe.inf
+  INF MdeModulePkg/Bus/I2c/I2cDxe/I2cDxe.inf
 
 [FV.FVMAIN_COMPACT]
 FvAlignment        = 16
@@ -421,6 +430,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..8787aa6288a7 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 g96BoardsI2c0MasterGuid GUID onto the same handle,
+  // identifying I2C #1 on our SoC as I2C #0 on the 96boards low speed connector
+  //
+  Status = gBS->InstallProtocolInterface (&Handle,
+                  &g96BoardsI2c0MasterGuid,
+                  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..fca66799ebcb 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/96Boards/96Boards.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]
+  g96BoardsI2c0MasterGuid
   gEfiHiiPlatformSetupFormsetGuid
   gFdtTableGuid
   gNetsecNonDiscoverableDeviceGuid
-- 
2.11.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH edk2-platforms v3 0/6] Add Secure96 mezzanine support
  2018-02-23 15:40 [PATCH edk2-platforms v3 0/6] Add Secure96 mezzanine support Ard Biesheuvel
                   ` (5 preceding siblings ...)
  2018-02-23 15:40 ` [PATCH edk2-platforms v3 6/6] Platform/Socionext/DeveloperBox: add 96Boards mezzanine support Ard Biesheuvel
@ 2018-02-23 15:56 ` Leif Lindholm
  2018-02-23 16:02   ` Ard Biesheuvel
  6 siblings, 1 reply; 9+ messages in thread
From: Leif Lindholm @ 2018-02-23 15:56 UTC (permalink / raw)
  To: Ard Biesheuvel; +Cc: edk2-devel

On Fri, Feb 23, 2018 at 03:40:46PM +0000, Ard Biesheuvel wrote:
> This v3 (as did v2) 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.
> 
> v3:
> - The ATSHA204A driver has been merged, so it has been dropped from this
>   series.
> - Rename Platform/NinetySixBoards back to Platform/96Boards. Note that in
>   some places, using leading digits is problematic so the string does still
>   occur in a couple of places.
> - Rebase onto EDK2 that has the MultiPhase.h VFR changes.

All of my feedback has been addressed, so for the series:
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>

If we get enum support in VfrCompile in the future, a minor cleanup to
the code introduced by 5/6 will be possible, but this is an excellent
start to a generic mezzanine infrastructure - thanks!


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH edk2-platforms v3 0/6] Add Secure96 mezzanine support
  2018-02-23 15:56 ` [PATCH edk2-platforms v3 0/6] Add Secure96 " Leif Lindholm
@ 2018-02-23 16:02   ` Ard Biesheuvel
  0 siblings, 0 replies; 9+ messages in thread
From: Ard Biesheuvel @ 2018-02-23 16:02 UTC (permalink / raw)
  To: Leif Lindholm; +Cc: edk2-devel@lists.01.org

On 23 February 2018 at 15:56, Leif Lindholm <leif.lindholm@linaro.org> wrote:
> On Fri, Feb 23, 2018 at 03:40:46PM +0000, Ard Biesheuvel wrote:
>> This v3 (as did v2) 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.
>>
>> v3:
>> - The ATSHA204A driver has been merged, so it has been dropped from this
>>   series.
>> - Rename Platform/NinetySixBoards back to Platform/96Boards. Note that in
>>   some places, using leading digits is problematic so the string does still
>>   occur in a couple of places.
>> - Rebase onto EDK2 that has the MultiPhase.h VFR changes.
>
> All of my feedback has been addressed, so for the series:
> Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
>
> If we get enum support in VfrCompile in the future, a minor cleanup to
> the code introduced by 5/6 will be possible, but this is an excellent
> start to a generic mezzanine infrastructure - thanks!


Thank you

Pushed as 487015fb23c1..d8e4d4565841


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-02-23 15:56 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-23 15:40 [PATCH edk2-platforms v3 0/6] Add Secure96 mezzanine support Ard Biesheuvel
2018-02-23 15:40 ` [PATCH edk2-platforms v3 1/6] Platform/96Boards: introduce package and mezzanine protocol Ard Biesheuvel
2018-02-23 15:40 ` [PATCH edk2-platforms v3 2/6] Platform/96Boards: introduce I2C driver Ard Biesheuvel
2018-02-23 15:40 ` [PATCH edk2-platforms v3 3/6] Platform/96Boards: introduce LsConnector protocol Ard Biesheuvel
2018-02-23 15:40 ` [PATCH edk2-platforms v3 4/6] Platform/96Boards: add a driver for the Secure96 mezzanine board Ard Biesheuvel
2018-02-23 15:40 ` [PATCH edk2-platforms v3 5/6] Platform/96Boards: add driver for low speed (LS) connector Ard Biesheuvel
2018-02-23 15:40 ` [PATCH edk2-platforms v3 6/6] Platform/Socionext/DeveloperBox: add 96Boards mezzanine support Ard Biesheuvel
2018-02-23 15:56 ` [PATCH edk2-platforms v3 0/6] Add Secure96 " Leif Lindholm
2018-02-23 16:02   ` Ard Biesheuvel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox