1// Copyright 2018 The Fuchsia Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#include <ddk/debug.h> 6#include <ddk/device.h> 7#include <ddk/protocol/platform-bus.h> 8#include <ddk/protocol/platform-defs.h> 9 10#include "astro.h" 11 12// The Astro Secure OS memory region is defined within the bootloader image. The ZBI provided to the 13// kernel must mark this memory space as reserved. The OP-TEE driver will query OP-TEE for the exact 14// sub-range of this memory space to be used by the driver. 15#define ASTRO_SECURE_OS_BASE 0x05300000 16#define ASTRO_SECURE_OS_LENGTH 0x02000000 17 18static const pbus_mmio_t astro_tee_mmios[] = { 19 { 20 .base = ASTRO_SECURE_OS_BASE, 21 .length = ASTRO_SECURE_OS_LENGTH, 22 }, 23}; 24 25static const pbus_bti_t astro_tee_btis[] = { 26 { 27 .iommu_index = 0, 28 .bti_id = BTI_TEE, 29 }, 30}; 31 32static const pbus_dev_t tee_dev = { 33 .name = "tee", 34 .vid = PDEV_VID_GENERIC, 35 .pid = PDEV_PID_GENERIC, 36 .did = PDEV_DID_OPTEE, 37 .mmios = astro_tee_mmios, 38 .mmio_count = countof(astro_tee_mmios), 39 .btis = astro_tee_btis, 40 .bti_count = countof(astro_tee_btis), 41}; 42 43zx_status_t astro_tee_init(aml_bus_t* bus) { 44 zx_status_t status = pbus_device_add(&bus->pbus, &tee_dev); 45 46 if (status != ZX_OK) { 47 zxlogf(ERROR, "%s: pbus_device_add tee failed: %d\n", __FUNCTION__, status); 48 return status; 49 } 50 return ZX_OK; 51} 52