[astro][tee] Enable OP-TEE for Astro

In order to communicate with the OP-TEE OS on Astro, the Astro board
driver must add the OP-TEE device to the platform bus. This change
enables the OP-TEE device and allows it to map the Secure OS memory
region. This memory region is used for communication between the secure
world and the non-secure world.

Test: Manual testing on Astro to ensure device was initialized.
Change-Id: I6c2e6f05c9579a9999df1056ec3215a4f9ab9406
diff --git a/system/dev/board/astro/astro-tee.c b/system/dev/board/astro/astro-tee.c
new file mode 100644
index 0000000..e7b1af5
--- /dev/null
+++ b/system/dev/board/astro/astro-tee.c
@@ -0,0 +1,51 @@
+// Copyright 2018 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <ddk/debug.h>
+#include <ddk/device.h>
+#include <ddk/protocol/platform-bus.h>
+#include <ddk/protocol/platform-defs.h>
+
+#include "astro.h"
+
+// The Astro Secure OS memory region is defined within the bootloader image. The ZBI provided to the
+// kernel must mark this memory space as reserved. The OP-TEE driver will query OP-TEE for the exact
+// sub-range of this memory space to be used by the driver.
+#define ASTRO_SECURE_OS_BASE 0x05300000
+#define ASTRO_SECURE_OS_LENGTH 0x02000000
+
+static const pbus_mmio_t astro_tee_mmios[] = {
+    {
+        .base = ASTRO_SECURE_OS_BASE,
+        .length = ASTRO_SECURE_OS_LENGTH,
+    },
+};
+
+static const pbus_bti_t astro_tee_btis[] = {
+    {
+        .iommu_index = 0,
+        .bti_id = BTI_TEE,
+    },
+};
+
+static const pbus_dev_t tee_dev = {
+    .name = "tee",
+    .vid = PDEV_VID_GENERIC,
+    .pid = PDEV_PID_GENERIC,
+    .did = PDEV_DID_OPTEE,
+    .mmios = astro_tee_mmios,
+    .mmio_count = countof(astro_tee_mmios),
+    .btis = astro_tee_btis,
+    .bti_count = countof(astro_tee_btis),
+};
+
+zx_status_t astro_tee_init(aml_bus_t* bus) {
+    zx_status_t status = pbus_device_add(&bus->pbus, &tee_dev);
+
+    if (status != ZX_OK) {
+        zxlogf(ERROR, "%s: pbus_device_add tee failed: %d\n", __FUNCTION__, status);
+        return status;
+    }
+    return ZX_OK;
+}
diff --git a/system/dev/board/astro/astro.c b/system/dev/board/astro/astro.c
index c6ab1b5..2a4b677 100644
--- a/system/dev/board/astro/astro.c
+++ b/system/dev/board/astro/astro.c
@@ -112,6 +112,11 @@
         goto fail;
     }
 
+    if ((status = astro_tee_init(bus)) != ZX_OK) {
+        zxlogf(ERROR, "astro_tee_init failed: %d\n", status);
+        goto fail;
+    }
+
     if ((status = aml_video_init(bus)) != ZX_OK) {
         zxlogf(ERROR, "aml_video_init failed: %d\n", status);
         goto fail;
diff --git a/system/dev/board/astro/astro.h b/system/dev/board/astro/astro.h
index c54e3dc..1708e77 100644
--- a/system/dev/board/astro/astro.h
+++ b/system/dev/board/astro/astro.h
@@ -24,6 +24,7 @@
     BTI_THERMAL,
     BTI_AUDIO_IN,
     BTI_AUDIO_OUT,
+    BTI_TEE,
 };
 
 typedef struct {
@@ -90,4 +91,6 @@
 // astro-clk.c
 zx_status_t aml_clk_init(aml_bus_t* bus);
 // astro-audio.c
-zx_status_t astro_tdm_init(aml_bus_t* bus);
\ No newline at end of file
+zx_status_t astro_tdm_init(aml_bus_t* bus);
+// astro-tee.c
+zx_status_t astro_tee_init(aml_bus_t* bus);
diff --git a/system/dev/board/astro/rules.mk b/system/dev/board/astro/rules.mk
index f4edb6f..ad70fbd 100644
--- a/system/dev/board/astro/rules.mk
+++ b/system/dev/board/astro/rules.mk
@@ -24,6 +24,7 @@
     $(LOCAL_DIR)/astro-video.c \
     $(LOCAL_DIR)/astro-clk.c \
     $(LOCAL_DIR)/astro-audio.c \
+    $(LOCAL_DIR)/astro-tee.c \
 
 MODULE_STATIC_LIBS := \
     system/dev/lib/amlogic \