Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip: nrf9131ek board files #12080

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions boards/arm/nrf9131ek_nrf9131/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright (c) 2023 Nordic Semiconductor ASA.
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause

if (CONFIG_BOARD_NRF9131EK_NRF9131 OR CONFIG_BOARD_NRF9131EK_NRF9131_NS)
zephyr_library()
zephyr_library_sources(npm1300.c)
endif()
18 changes: 18 additions & 0 deletions boards/arm/nrf9131ek_nrf9131/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# nRF9131-EK board configuration
#
# Copyright (c) 2023 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause

if BOARD_NRF9131EK_NRF9131 || BOARD_NRF9131EK_NRF9131_NS

config BOARD_INIT_PRIORITY
int "Initialization priority for board configuration"
default 80

endif # BOARD_NRF9131EK_NRF9131 || BOARD_NRF9131EK_NRF9131_NS

module=BOARD
module-dep=LOG
module-str=Log level for board
source "${ZEPHYR_BASE}/subsys/logging/Kconfig.template.log_config"
14 changes: 14 additions & 0 deletions boards/arm/nrf9131ek_nrf9131/Kconfig.board
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# nRF9131-EK board configuration

Check failure on line 1 in boards/arm/nrf9131ek_nrf9131/Kconfig.board

View workflow job for this annotation

GitHub Actions / call-workflow / Run license checks on patch series (PR)

License Problem

"APACHE-2.0" license is not allowed for this file.

# Copyright (c) 2023 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

if SOC_NRF9161_SICA
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should there be a new SOC also?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good question! technically, it shouldn't be necessary, but it could be for documentation reasons. we could also nename nRF9161 to nRF91X1. Who would decide this?


config BOARD_NRF9131EK_NRF9131
bool "nRF9131 EK NRF9131"

config BOARD_NRF9131EK_NRF9131_NS
bool "nRF9131 EK NRF9131 non-secure"

endif # SOC_NRF9161_SICA
62 changes: 62 additions & 0 deletions boards/arm/nrf9131ek_nrf9131/Kconfig.defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# nRF9131 EK NRF9131 board configuration

Check failure on line 1 in boards/arm/nrf9131ek_nrf9131/Kconfig.defconfig

View workflow job for this annotation

GitHub Actions / call-workflow / Run license checks on patch series (PR)

License Problem

"APACHE-2.0" license is not allowed for this file.

# Copyright (c) 2023 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

if BOARD_NRF9131EK_NRF9131 || BOARD_NRF9131EK_NRF9131_NS

config BOARD
default "nrf9131ek_nrf9131"

# By default, if we build for a Non-Secure version of the board,
# enable building with TF-M as the Secure Execution Environment.
config BUILD_WITH_TFM
default y if BOARD_NRF9131EK_NRF9131_NS

if BUILD_WITH_TFM

# By default, if we build with TF-M, instruct build system to
# flash the combined TF-M (Secure) & Zephyr (Non Secure) image
config TFM_FLASH_MERGED_BINARY
bool
default y

endif # BUILD_WITH_TFM

# For the secure version of the board the firmware is linked at the beginning
# of the flash, or into the code-partition defined in DT if it is intended to
# be loaded by MCUboot. If the secure firmware is to be combined with a non-
# secure image (TRUSTED_EXECUTION_SECURE=y), the secure FW image shall always
# be restricted to the size of its code partition.
# For the non-secure version of the board, the firmware
# must be linked into the code-partition (non-secure) defined in DT, regardless.
# Apply this configuration below by setting the Kconfig symbols used by
# the linker according to the information extracted from DT partitions.

# Workaround for not being able to have commas in macro arguments
DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition

config FLASH_LOAD_SIZE
default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION))
depends on BOARD_NRF9131EK_NRF9131 && TRUSTED_EXECUTION_SECURE

if BOARD_NRF9131EK_NRF9131_NS

config FLASH_LOAD_OFFSET
default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION))

config FLASH_LOAD_SIZE
default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION))

endif # BOARD_NRF9131EK_NRF9131_NS

config BT_HCI_VS
default y if BT

config BT_WAIT_NOP
default BT && $(dt_nodelabel_enabled,nrf5340_reset)

config I2C
default $(dt_compat_on_bus,$(DT_COMPAT_NXP_PCAL6408A),i2c)

endif # BOARD_NRF9131EK_NRF9131 || BOARD_NRF9131EK_NRF9131_NS
14 changes: 14 additions & 0 deletions boards/arm/nrf9131ek_nrf9131/board.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# SPDX-License-Identifier: Apache-2.0

Check failure on line 1 in boards/arm/nrf9131ek_nrf9131/board.cmake

View workflow job for this annotation

GitHub Actions / call-workflow / Run license checks on patch series (PR)

License Problem

"APACHE-2.0" license is not allowed for this file.

if(CONFIG_BOARD_NRF9131EK_NRF9131_NS)
set(TFM_PUBLIC_KEY_FORMAT "full")
endif()

if(CONFIG_TFM_FLASH_MERGED_BINARY)
set_property(TARGET runners_yaml_props_target PROPERTY hex_file tfm_merged.hex)
endif()

# TODO: change to nRF9131_xxAA when such device is available in JLink
board_runner_args(jlink "--device=nRF9160_xxAA" "--speed=4000")
include(${ZEPHYR_BASE}/boards/common/nrfjprog.board.cmake)
include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake)
53 changes: 53 additions & 0 deletions boards/arm/nrf9131ek_nrf9131/npm1300.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright (c) 2023 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

#include <zephyr/kernel.h>
#include <zephyr/init.h>
#include <zephyr/logging/log.h>
#include <zephyr/device.h>
#include <zephyr/drivers/i2c.h>

LOG_MODULE_REGISTER(board_secure, CONFIG_BOARD_LOG_LEVEL);

#define CHECKERR if (err) {LOG_ERR("I2C error: %d", err); return err;}

Check failure on line 15 in boards/arm/nrf9131ek_nrf9131/npm1300.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

SPACING

boards/arm/nrf9131ek_nrf9131/npm1300.c:15 space required after that ';' (ctx:VxV)

static const struct i2c_dt_spec pmic = I2C_DT_SPEC_GET(DT_NODELABEL(pmic_main));

static int pmic_write_reg(uint16_t address, uint8_t value)
{
uint8_t buf[] = {
address >> 8,
address & 0xFF,
value,
};

return i2c_write_dt(&pmic, buf, ARRAY_SIZE(buf));
}

static int thingy91x_board_init(void)
{
int err = 0;

if (!device_is_ready(pmic.bus)) {
LOG_ERR("cannot reach PMIC!");
return -ENODEV;
}

// disable charger for config

Check failure on line 39 in boards/arm/nrf9131ek_nrf9131/npm1300.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

C99_COMMENTS

boards/arm/nrf9131ek_nrf9131/npm1300.c:39 do not use C99 // comments
err = pmic_write_reg(0x0305, 0x03); CHECKERR;

// set VBUS current limit 500mA

Check failure on line 42 in boards/arm/nrf9131ek_nrf9131/npm1300.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

TRAILING_WHITESPACE

boards/arm/nrf9131ek_nrf9131/npm1300.c:42 trailing whitespace

Check failure on line 42 in boards/arm/nrf9131ek_nrf9131/npm1300.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

C99_COMMENTS

boards/arm/nrf9131ek_nrf9131/npm1300.c:42 do not use C99 // comments
err = pmic_write_reg(0x0201, 0x00); CHECKERR;
err = pmic_write_reg(0x0202, 0x00); CHECKERR;
err = pmic_write_reg(0x0200, 0x01); CHECKERR;

// enable charger

Check failure on line 47 in boards/arm/nrf9131ek_nrf9131/npm1300.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

C99_COMMENTS

boards/arm/nrf9131ek_nrf9131/npm1300.c:47 do not use C99 // comments
err = pmic_write_reg(0x0304, 0x03); CHECKERR;

return err;
}

SYS_INIT(thingy91x_board_init, POST_KERNEL, CONFIG_BOARD_INIT_PRIORITY);
19 changes: 19 additions & 0 deletions boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*

Check failure on line 1 in boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131.dts

View workflow job for this annotation

GitHub Actions / call-workflow / Run license checks on patch series (PR)

License Problem

"APACHE-2.0" license is not allowed for this file.
* Copyright (c) 2023 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/

/dts-v1/;
#include <nordic/nrf9161_sica.dtsi>
#include "nrf9131ek_nrf9131_common.dtsi"

/ {
chosen {
zephyr,sram = &sram0_s;
zephyr,flash = &flash0;
zephyr,code-partition = &slot0_partition;
zephyr,sram-secure-partition = &sram0_s;
zephyr,sram-non-secure-partition = &sram0_ns;
};
};
21 changes: 21 additions & 0 deletions boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
identifier: nrf9131ek_nrf9131
name: nRF9131-DK-NRF9131
type: mcu
arch: arm
toolchain:
- gnuarmemb
- xtools
- zephyr
ram: 88
flash: 1024
supported:
- arduino_gpio
- arduino_i2c
- arduino_serial
- arduino_spi
- gpio
- i2c
- pwm
- spi
- watchdog
- counter
100 changes: 100 additions & 0 deletions boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_common-pinctrl.dtsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/*

Check failure on line 1 in boards/arm/nrf9131ek_nrf9131/nrf9131ek_nrf9131_common-pinctrl.dtsi

View workflow job for this annotation

GitHub Actions / call-workflow / Run license checks on patch series (PR)

License Problem

"APACHE-2.0" license is not allowed for this file.
* Copyright (c) 2023 Nordic Semiconductor
* SPDX-License-Identifier: Apache-2.0
*/

&pinctrl {
uart0_default: uart0_default {
group1 {
psels = <NRF_PSEL(UART_TX, 0, 11)>,
<NRF_PSEL(UART_RTS, 0, 10)>;
};
group2 {
psels = <NRF_PSEL(UART_RX, 0, 12)>,
<NRF_PSEL(UART_CTS, 0, 9)>;
bias-pull-up;
};
};

uart0_sleep: uart0_sleep {
group1 {
psels = <NRF_PSEL(UART_TX, 0, 11)>,
<NRF_PSEL(UART_RX, 0, 12)>,
<NRF_PSEL(UART_RTS, 0, 10)>,
<NRF_PSEL(UART_CTS, 0, 9)>;
low-power-enable;
};
};

uart1_default: uart1_default {
group1 {
psels = <NRF_PSEL(UART_TX, 0, 24)>,
<NRF_PSEL(UART_RTS, 0, 25)>;
};
group2 {
psels = <NRF_PSEL(UART_RX, 0, 23)>,
<NRF_PSEL(UART_CTS, 0, 17)>;
bias-pull-up;
};
};

uart1_sleep: uart1_sleep {
group1 {
psels = <NRF_PSEL(UART_TX, 0, 24)>,
<NRF_PSEL(UART_RX, 0, 23)>,
<NRF_PSEL(UART_RTS, 0, 25)>,
<NRF_PSEL(UART_CTS, 0, 17)>;
low-power-enable;
};
};

i2c2_default: i2c2_default {
group1 {
psels = <NRF_PSEL(TWIM_SDA, 0, 8)>,
<NRF_PSEL(TWIM_SCL, 0, 7)>;
};
};

i2c2_sleep: i2c2_sleep {
group1 {
psels = <NRF_PSEL(TWIM_SDA, 0, 8)>,
<NRF_PSEL(TWIM_SCL, 0, 7)>;
low-power-enable;
};
};

pwm0_default: pwm0_default {
group1 {
psels = <NRF_PSEL(PWM_OUT0, 0, 29)>,
<NRF_PSEL(PWM_OUT1, 0, 30)>,
<NRF_PSEL(PWM_OUT2, 0, 31)>;
};
};

pwm0_sleep: pwm0_sleep {
group1 {
psels = <NRF_PSEL(PWM_OUT0, 0, 29)>,
<NRF_PSEL(PWM_OUT1, 0, 30)>,
<NRF_PSEL(PWM_OUT2, 0, 31)>;
low-power-enable;
};
};

spi3_default: spi3_default {
group1 {
psels = <NRF_PSEL(SPIM_SCK, 0, 20)>,
<NRF_PSEL(SPIM_MISO, 0, 22)>,
<NRF_PSEL(SPIM_MOSI, 0, 21)>;
nordic,drive-mode = <NRF_DRIVE_H0H1>;
};
};

spi3_sleep: spi3_sleep {
group1 {
psels = <NRF_PSEL(SPIM_SCK, 0, 20)>,
<NRF_PSEL(SPIM_MISO, 0, 22)>,
<NRF_PSEL(SPIM_MOSI, 0, 21)>;
low-power-enable;
};
};
};
Loading
Loading