Skip to content

Commit

Permalink
[nrf fromtree] platform: nordic_nrf: Add nrf9161 DK and nrf9120 SoC s…
Browse files Browse the repository at this point in the history
…upport

Add support for the nrf9161 development kit and the nrf9120 SoC.

Change-Id: I6e3c0a01b80e6d14b4bbc6befb7ab7e75b31ac4b
Signed-off-by: Joakim Andersson <[email protected]>
(cherry picked from commit 4580baf)
  • Loading branch information
joerchan authored and rlubos committed May 15, 2023
1 parent 5c1378c commit f0bac93
Show file tree
Hide file tree
Showing 13 changed files with 377 additions and 0 deletions.
21 changes: 21 additions & 0 deletions platform/ext/target/nordic_nrf/common/nrf9120/preload.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#
# Copyright (c) 2023, Nordic Semiconductor ASA.
#
# SPDX-License-Identifier: BSD-3-Clause
#

# preload.cmake is used to set things that related to the platform that are both
# immutable and global, which is to say they should apply to any kind of project
# that uses this platform. In practise this is normally compiler definitions and
# variables related to hardware.

# Set architecture and CPU
set(TFM_SYSTEM_PROCESSOR cortex-m33)
set(TFM_SYSTEM_ARCHITECTURE armv8-m.main)
set(TFM_SYSTEM_DSP OFF)
set(CONFIG_TFM_FP_ARCH "fpv5-sp-d16")

add_compile_definitions(
NRF9120_XXAA
NRF91_SERIES
)
54 changes: 54 additions & 0 deletions platform/ext/target/nordic_nrf/nrf9161dk_nrf9161/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#
# Copyright (c) 2023, Nordic Semiconductor ASA.
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

cmake_policy(SET CMP0076 NEW)
set(CMAKE_CURRENT_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR})
set(NRF_BOARD_SELECTED True)

add_subdirectory(../common/nrf91 nrf91)

target_include_directories(platform_region_defs
INTERFACE
../common/nrf91/partition
)

target_sources(platform_s
PRIVATE
$<$<BOOL:${TFM_PARTITION_PLATFORM}>:${CMAKE_CURRENT_SOURCE_DIR}/services/src/tfm_platform_system.c>
)

target_include_directories(platform_s
PUBLIC
.
../common/nrf91/partition
services/include
)

target_include_directories(platform_ns
PUBLIC
.
)

if(BL2)
target_include_directories(platform_bl2
PUBLIC
../common/nrf91/partition
PRIVATE
.
)
endif()

if (TFM_PARTITION_PLATFORM)
install(FILES services/include/tfm_ioctl_api.h
DESTINATION ${TFM_INSTALL_PATH}/interface/include)
endif()

#========================= tfm_spm ============================================#

target_sources(tfm_spm
PRIVATE
tfm_hal_platform.c
)
77 changes: 77 additions & 0 deletions platform/ext/target/nordic_nrf/nrf9161dk_nrf9161/RTE_Device.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* Copyright (c) 2023 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

//-------- <<< Use Configuration Wizard in Context Menu >>> --------------------

#ifndef __RTE_DEVICE_H
#define __RTE_DEVICE_H

// <e> USART (Universal synchronous - asynchronous receiver transmitter) [Driver_USART0]
// <i> Configuration settings for Driver_USART0 in component ::Drivers:USART
#define RTE_USART0 1
// <h> Pin Selection (0xFFFFFFFF means Disconnected)
// <o> TXD
#define RTE_USART0_TXD_PIN 27
// <o> RXD
#define RTE_USART0_RXD_PIN 26
// <o> RTS
#define RTE_USART0_RTS_PIN 14
// <o> CTS
#define RTE_USART0_CTS_PIN 15
// </h> Pin Configuration
// </e> USART (Universal synchronous - asynchronous receiver transmitter) [Driver_USART0]

// <e> USART (Universal synchronous - asynchronous receiver transmitter) [Driver_USART1]
// <i> Configuration settings for Driver_USART1 in component ::Drivers:USART
#define RTE_USART1 1
// <h> Pin Selection (0xFFFFFFFF means Disconnected)
// <o> TXD
#define RTE_USART1_TXD_PIN 29
// <o> RXD
#define RTE_USART1_RXD_PIN 28
// <o> RTS
#define RTE_USART1_RTS_PIN 16
// <o> CTS
#define RTE_USART1_CTS_PIN 17
// </h> Pin Configuration
// </e> USART (Universal synchronous - asynchronous receiver transmitter) [Driver_USART1]

// <e> USART (Universal synchronous - asynchronous receiver transmitter) [Driver_USART2]
// <i> Configuration settings for Driver_USART2 in component ::Drivers:USART
#define RTE_USART2 0
// <h> Pin Selection (0xFFFFFFFF means Disconnected)
// <o> TXD
#define RTE_USART2_TXD_PIN 0xFFFFFFFF
// <o> RXD
#define RTE_USART2_RXD_PIN 0xFFFFFFFF
// <o> RTS
#define RTE_USART2_RTS_PIN 0xFFFFFFFF
// <o> CTS
#define RTE_USART2_CTS_PIN 0xFFFFFFFF
// </h> Pin Configuration
// </e> USART (Universal synchronous - asynchronous receiver transmitter) [Driver_USART2]

// <e> USART (Universal synchronous - asynchronous receiver transmitter) [Driver_USART3]
// <i> Configuration settings for Driver_USART3 in component ::Drivers:USART
#define RTE_USART3 0
// <h> Pin Selection (0xFFFFFFFF means Disconnected)
// <o> TXD
#define RTE_USART3_TXD_PIN 0xFFFFFFFF
// <o> RXD
#define RTE_USART3_RXD_PIN 0xFFFFFFFF
// <o> RTS
#define RTE_USART3_RTS_PIN 0xFFFFFFFF
// <o> CTS
#define RTE_USART3_RTS_PIN 0xFFFFFFFF
// </h> Pin Configuration
// </e> USART (Universal synchronous - asynchronous receiver transmitter) [Driver_USART3]

// <e> FLASH (Flash Memory) [Driver_FLASH0]
// <i> Configuration settings for Driver_FLASH0 in component ::Drivers:FLASH
#define RTE_FLASH0 1
// </e> FLASH (Flash Memory) [Driver_FLASH0]

#endif /* __RTE_DEVICE_H */
9 changes: 9 additions & 0 deletions platform/ext/target/nordic_nrf/nrf9161dk_nrf9161/config.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#
# Copyright (c) 2023, Nordic Semiconductor ASA.
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

set(PLATFORM_PATH platform/ext/target/${TFM_PLATFORM}/..)

include(${PLATFORM_PATH}/common/nrf91/config.cmake)
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright (c) 2023 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

#ifndef __CONFIG_TFM_TARGET_H__
#define __CONFIG_TFM_TARGET_H__

/* Include optional claims in initial attestation token */
#undef ATTEST_INCLUDE_OPTIONAL_CLAIMS
#define ATTEST_INCLUDE_OPTIONAL_CLAIMS 0

#endif /* __CONFIG_TFM_TARGET_H__ */
20 changes: 20 additions & 0 deletions platform/ext/target/nordic_nrf/nrf9161dk_nrf9161/device_cfg.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright (c) 2023 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

#ifndef __ARM_LTD_DEVICE_CFG_H__
#define __ARM_LTD_DEVICE_CFG_H__

/**
* \file device_cfg.h
* \brief
* This is the default device configuration file with all peripherals
* defined and configured to be use via the secure and/or non-secure base
* address.
*/

#define DEFAULT_UART_BAUDRATE 115200

#endif /* __ARM_LTD_DEVICE_CFG_H__ */
18 changes: 18 additions & 0 deletions platform/ext/target/nordic_nrf/nrf9161dk_nrf9161/nrf_board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright (c) 2023 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

#ifndef NRF_BOARD_H__
#define NRF_BOARD_H__

#include <hal/nrf_gpio.h>

#define BUTTON1_PIN (8UL)
#define BUTTON1_ACTIVE_LEVEL (0UL)
#define BUTTON1_PULL (NRF_GPIO_PIN_PULLUP)
#define LED1_PIN (2UL)
#define LED1_ACTIVE_LEVEL (1UL)

#endif // NRF_BOARD_H__
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#
# Copyright (c) 2023, Nordic Semiconductor ASA.
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

set(PLATFORM_PATH platform/ext/target/${TFM_PLATFORM}/..)

include(${PLATFORM_PATH}/common/nrf9120/preload.cmake)
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (c) 2023 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

/** @file
* @brief TFM IOCTL API header.
*/


#ifndef TFM_IOCTL_API_H__
#define TFM_IOCTL_API_H__

/**
* @defgroup tfm_ioctl_api TFM IOCTL API
* @{
*
*/

#include <limits.h>
#include <stdint.h>
#include <tfm_api.h>
#include <tfm_platform_api.h>

/* Include core IOCTL services */
#include <tfm_ioctl_core_api.h>

#ifdef __cplusplus
extern "C" {
#endif

/* Board specific IOCTL services can be added here */

#ifdef __cplusplus
}
#endif

/**
* @}
*/

#endif /* TFM_IOCTL_API_H__ */
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright (c) 2023 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

#ifndef TFM_READ_RANGES_H__
#define TFM_READ_RANGES_H__

#include <tfm_ioctl_core_api.h>

#include "nrf.h"

#define FICR_BASE NRF_FICR_S_BASE

#define FICR_INFO_ADDR (FICR_BASE + offsetof(NRF_FICR_Type, INFO))
#define FICR_INFO_SIZE (sizeof(FICR_INFO_Type))

/* Used by nrf_erratas.h */
#define FICR_RESTRICTED_ADDR (FICR_BASE + 0x130)
#define FICR_RESTRICTED_SIZE 0x8

static const struct tfm_read_service_range ranges[] = {
{ .start = FICR_INFO_ADDR, .size = FICR_INFO_SIZE },
{ .start = FICR_RESTRICTED_ADDR, .size = FICR_RESTRICTED_SIZE },
};

#endif /* TFM_READ_RANGES_H__ */
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2023 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

#include "platform/include/tfm_platform_system.h"
#include "cmsis.h"
#include "tfm_platform_hal_ioctl.h"
#include "tfm_ioctl_core_api.h"

void tfm_platform_hal_system_reset(void)
{
/* Reset the system */
NVIC_SystemReset();
}

enum tfm_platform_err_t tfm_platform_hal_ioctl(tfm_platform_ioctl_req_t request,
psa_invec *in_vec,
psa_outvec *out_vec)
{
/* Core IOCTL services */
switch (request) {
case TFM_PLATFORM_IOCTL_READ_SERVICE:
return tfm_platform_hal_read_service(in_vec, out_vec);

/* Board specific IOCTL services */

/* Not a supported IOCTL service.*/
default:
return TFM_PLATFORM_ERR_NOT_SUPPORTED;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright (c) 2023 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

#include "tfm_hal_defs.h"
#include "tfm_hal_platform_common.h"

enum tfm_hal_status_t tfm_hal_platform_init(void)
{
return tfm_hal_platform_common_init();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2023 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

#ifndef TFM_PERIPHERALS_CONFIG_H__
#define TFM_PERIPHERALS_CONFIG_H__

#ifdef __cplusplus
extern "C" {
#endif

#ifdef SECURE_UART1
#define TFM_PERIPHERAL_UARTE1_SECURE 1
#endif

#if TEST_NS_SLIH_IRQ || TEST_NS_FLIH_IRQ
#define TFM_PERIPHERAL_TIMER0_SECURE 1
#endif

#ifdef PSA_API_TEST_IPC
#define TFM_PERIPHERAL_EGU5_SECURE 1

#define TFM_PERIPHERAL_WDT_SECURE 1
#endif

#if defined(NRF91_SERIES)
#include <tfm_peripherals_config_nrf91.h>
#else
#error "Unknown device."
#endif

#ifdef __cplusplus
}
#endif

#endif /* TFM_PERIPHERAL_CONFIG_H__ */

0 comments on commit f0bac93

Please sign in to comment.